node
Bridge from the renderer to the main (Node) process.
- Kind: builtin
- Version: 0.1.0
- Platforms: Linux, Windows
This is the only module whose calls are forwarded out of the kernel. Everything
else runs renderer → kernel → module directly; node routes through the
control socket to the main process.
Functions
| Function | Signature |
|---|---|
call |
({ fn, args? }) → result |
Usage
Register a handler in the main process:
import { app } from '@owear/core'
app.handle('db.query', async (sql: string) => db.prepare(sql).all())
Call it from the renderer:
const rows = await ow.invoke('node', 'call', { fn: 'db.query', args: ['select 1'] })
The kernel forwards the call as node.request to the main process, which
dispatches to the handler and answers with node.respond. The handler's return
value (or an error message) comes back to the renderer.
Main → renderer events use app.send, received with ow.on:
// main
app.send('job.progress', { percent: 42 })
// renderer
ow.on('job.progress', ({ percent }) => update(percent))
Notes
- Opt-in: only use it for features that genuinely need Node. For filesystem, dialogs, clipboard, and the like, call the native module directly.
- Use
app.handleContextwhen the handler needs the calling window id. - Reserved handler
__ow_port_postis used internally by message ports.