import { contextBridge , ipcRenderer } from 'electron' ; import { IpcRendererEvent } from 'electron/main' ; import { IPCKey } from './Constants' ; contextBridge . exposeInMainWorld ( 'myAPI' , { sendMessage : async ( targetWindowId , message ) : Promise < void > => await ipcRenderer . invoke ( IPCKey . SendMessage , targetWindowId , message ) , createNewWindow : async ( ) : Promise < void > => await ipcRenderer . invoke ( IPCKey . CreateNewWindow ) , getWindowIds : async ( ) : Promise < number [ ] > => await ipcRenderer . invoke ( IPCKey . GetWindowIds ) , onUpdateMessage : ( listener ) => ipcRenderer . on ( IPCKey . UpdateMessage , ( ev , message ) => listener ( message ) ) , onUpdateWindowIds : ( listener ) => ipcRenderer . on ( IPCKey . UpdateWindowIds , ( ev , windowIds ) => listener ( windowIds ) ) } ) ;