-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
18 lines (16 loc) · 816 Bytes
/
Copy pathpreload.js
File metadata and controls
18 lines (16 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Preload bridge: the only surface exposed to the renderer.
//
// contextIsolation is on and nodeIntegration is off, so the renderer has no
// direct Node access. We expose a minimal, explicit API: get the sidecar port
// and signal readiness. The renderer opens the WebSocket itself (browsers have
// native WebSocket), keeping this bridge tiny.
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('lognotes', {
getSidecarPort: () => ipcRenderer.invoke('get-sidecar-port'),
signalReady: () => ipcRenderer.send('renderer-ready'),
onSidecarDown: (cb) => {
ipcRenderer.on('sidecar-down', () => cb());
},
// Overlay: ask main to reposition the overlay window to a named corner.
setOverlayCorner: (corner) => ipcRenderer.send('overlay-set-corner', corner),
});