You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{createInterprocess}from'../interprocess';exportconst{ipcMain: utilsIpcMain,ipcRenderer: utilsIpcRenderer}=createInterprocess({main: {/** * Returns the electron application version */asyncgetElectronVersion(){return'1.0.0';},},renderer: {/** * Prints a log message in the frontend console. * The first parameter is always an IPC event object. */asynclogMessage(_,_msg: string){return;},},});
If I want to implement the invoker directly to the context bridge:
import{contextBridge}from'electron';import{utilsIpcRenderer}from'../ipc/handlers/utils.ipc';constapi={utils: {// typescript complains about the first parameter even though the handler is defined without any params// so I have to satisfy it by using undefinedgetElectronVersion: ()=>utilsIpcRenderer.invoke.getElectronVersion(undefined),onLogMessage: (callback)=>{utilsIpcRenderer.handle.logMessage(async(_,{data: msg})=>{callback(msg);});},},};try{contextBridge.exposeInMainWorld('native',api);}catch(error){console.error(error);}
I'm using Typescript 4.9.5
I'm not using the package installed as an npm module but copied the src files to my project to get around sandbox: true limitations
The text was updated successfully, but these errors were encountered:
Given this example:
If I want to implement the invoker directly to the context bridge:
sandbox: true
limitationsThe text was updated successfully, but these errors were encountered: