import { contextBridge } from 'electron'; import type { IpcEventMap, IpcInvokeMap } from '../shared/ipc/contracts'; import { invoke, on } from './ipcClient'; export type DndApi = { invoke: ( channel: K, payload: IpcInvokeMap[K]['req'], ) => Promise; on: (channel: K, listener: (payload: IpcEventMap[K]) => void) => () => void; }; const api: DndApi = { invoke, on }; contextBridge.exposeInMainWorld('dnd', api); declare global { var dnd: DndApi | undefined; interface Window { dnd: DndApi; } }