Migrating from Electron
Owear deliberately mirrors Electron's main-process API, so most of the port is mechanical. The biggest conceptual difference is in the renderer: there is no preload/IPC hop, and you call native modules directly.
Concept mapping
| Electron | Owear |
|---|---|
app.whenReady() |
app.whenReady() (same) |
BrowserWindow |
BrowserWindow (same shape) |
ipcMain.handle / ipcRenderer.invoke |
app.handle + ow.invoke('node','call',{fn,args}) |
webContents.send / ipcRenderer.on |
app.send / ow.on |
contextBridge.exposeInMainWorld + preload |
window.ow injected by the kernel |
electron-builder |
ow build app / ow build installer |
electron-updater |
autoUpdater |
nativeImage |
nativeImage (same) |
Tray, Menu, dialog, session, safeStorage, nativeTheme, powerMonitor, powerSaveBlocker, screen |
same names in @owear/core |
N-API addons (electron-rebuild) |
N-API addons (no rebuild) |
| Bundled Chromium | the OS WebView |
Renderer: no preload, no IPC
Electron pushes everything through a preload script and IPC. In Owear the kernel
injects window.ow, and most capabilities are native modules you call directly:
// Electron: ipcRenderer.invoke('read-file', path) → ipcMain.handle(...)
const text = await window.ow.invoke<string>('fs', 'readText', path)
Only reach for Node when you truly need it:
const rows = await window.ow.invoke('node', 'call', { fn: 'db.query', args: [sql] })
See Renderer API and IPC.
Main process
Main-process code ports almost unchanged:
// Electron and Owear
import { app, BrowserWindow, Menu, Tray, dialog, session, nativeTheme } from '@owear/core'
Differences to watch:
BrowserWindowconstruction is async (the window is created by the kernel). Usewin.on('ready-to-show')before relying onwin.id.webContents.sendexists, plusapp.send.Menu.setApplicationMenuis a no-op on Linux; draw your own menubar.dialog/printToPDFsupport depends on the platform's WebView (LinuxprintToPDFis not available in WebKitGTK v2.52 and returns a clear error).
Packaging
Replace electron-builder/electron-updater:
ow build app --format deb # instead of electron-builder
ow build installer # a real installer + uninstaller
ow update --file … --version … # instead of electron-updater's publish
Native addons
Electron binaries must be rebuilt for Node; N-API addons need nothing. See Native addons.
Things that simply do not exist
require('electron'),ipcRenderer,ipcMain,contextBridge,preload.utilityProcess— useapp.forkWorker(which shimsprocess.parentPort).BrowserView— use embedded webviews (webview).- Chromium-specific flags and DevTools protocol parity.
A porting recipe
- Move
main/preloadcode intoapp/main.ts; keep window/menu/tray there. - Replace
ipcMain.handlewithapp.handle. - In the renderer, replace
ipcRenderer.invokecalls withow.invoketo the corresponding native module (fs,dialog,clipboard, …). - Rebuild native addons for Node if needed.
- Swap the packager for
ow buildand, if you used updates,autoUpdater.