/**
 * desktop/src/preload.ts — the minimal, contextIsolation-safe renderer bridge.
 *
 * Exposes exactly one thing: a deep-link listener. The unchanged frontend does
 * not require this bridge (deep links are actually applied by main via a same-
 * origin navigation to /?join=<id>), so it is an optional, forward-looking hook
 * for future page-cooperative features. Crucially it exposes NO Node access
 * (no require/fs/process) — only a callback registration over one whitelisted
 * IPC channel — so it cannot widen the renderer's attack surface.
 */
import { contextBridge, ipcRenderer } from 'electron'

const DEEP_LINK_CHANNEL = 'deep-link'

contextBridge.exposeInMainWorld('desktop', {
  onDeepLink: (cb: (path: string) => void): void => {
    ipcRenderer.on(DEEP_LINK_CHANNEL, (_event, path: string) => cb(path))
  },
})
