fix: use contextBridge for Electron API exposure with context isolation

Replace direct window.ea assignment with contextBridge.exposeInMainWorld()
to properly expose the Electron API when contextIsolation is enabled.
This resolves the "window.ea is not available" error.
This commit is contained in:
Johannes Millan 2025-06-27 22:48:28 +02:00
parent 2fcd310ea1
commit d2eecb49ec

View file

@ -1,4 +1,4 @@
import { ipcRenderer, IpcRendererEvent, webFrame } from 'electron';
import { ipcRenderer, IpcRendererEvent, webFrame, contextBridge } from 'electron';
import { ElectronAPI } from './electronAPI.d';
import { IPCEventValue } from './shared-with-frontend/ipc-events.const';
import { LocalBackupMeta } from '../src/app/imex/local-backup/local-backup.model';
@ -125,5 +125,5 @@ const ea: ElectronAPI = {
) as Promise<PluginNodeScriptResult>,
};
// Expose ea to window for ipc-event.ts
(window as any).ea = ea;
// Expose ea to window for ipc-event.ts using contextBridge for context isolation
contextBridge.exposeInMainWorld('ea', ea);