2026-06-30 17:49:41 +05:30
|
|
|
// Minimal, safe bridge into the web UI. Runs with contextIsolation, so it only exposes a
|
|
|
|
|
// frozen marker the web app can feature-detect against (e.g. to hide the PWA install prompt
|
|
|
|
|
// or prefer native push). No Node APIs are exposed to page JS.
|
2026-07-01 16:16:40 +05:30
|
|
|
const { contextBridge, ipcRenderer } = require('electron');
|
2026-06-30 17:49:41 +05:30
|
|
|
|
2026-07-01 21:28:53 +05:30
|
|
|
// Pull the stable install id + version/os from main (synchronous, one-time at preload).
|
|
|
|
|
let info = { installId: '', appVersion: '', os: '' };
|
|
|
|
|
try { info = ipcRenderer.sendSync('get-install-info') || info; } catch (_) {}
|
|
|
|
|
|
2026-06-30 17:49:41 +05:30
|
|
|
contextBridge.exposeInMainWorld('__NATIVE__', 'desktop');
|
|
|
|
|
contextBridge.exposeInMainWorld('bizConnectNative', Object.freeze({
|
|
|
|
|
platform: 'desktop',
|
2026-07-01 21:28:53 +05:30
|
|
|
version: info.appVersion || '0.1.0',
|
|
|
|
|
installId: info.installId || '',
|
|
|
|
|
os: info.os || '',
|
2026-07-01 16:16:40 +05:30
|
|
|
// Bring the app window to the foreground (e.g. when a notification is clicked) — the web
|
|
|
|
|
// Notification's window.focus() can't raise an Electron window; the main process must.
|
|
|
|
|
focusApp: () => ipcRenderer.send('focus-window'),
|
2026-07-01 16:28:15 +05:30
|
|
|
// Show the unread-chat count as a badge on the taskbar icon. count=number of chats with
|
|
|
|
|
// unread; dataUrl=a small PNG badge the renderer drew (null to clear).
|
|
|
|
|
setUnread: (count, dataUrl) => ipcRenderer.send('set-unread', { count, dataUrl }),
|
2026-07-01 22:36:02 +05:30
|
|
|
// Native Windows toast with an inline reply box. Resolves to {text} (replied), {open} (clicked)
|
|
|
|
|
// or null. Lets the user reply to a chat straight from the notification.
|
|
|
|
|
replyNotify: (payload) => ipcRenderer.invoke('reply-notification', payload),
|
2026-06-30 17:49:41 +05:30
|
|
|
}));
|