-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
23 lines (22 loc) · 862 Bytes
/
preload.js
File metadata and controls
23 lines (22 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const { contextBridge, ipcRenderer } = require('electron');
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld(
'electron', {
ipcRenderer: {
invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),
on: (channel, func) => {
ipcRenderer.on(channel, (event, ...args) => func(...args));
},
removeListener: (channel, func) => {
ipcRenderer.removeListener(channel, func);
}
}
}
);
contextBridge.exposeInMainWorld('api', {
analyzeCode: (codeData) => ipcRenderer.invoke('analyze-code', codeData),
saveReport: (reportData) => ipcRenderer.invoke('save-report', reportData),
openFile: () => ipcRenderer.invoke('open-file'),
saveFile: (fileData) => ipcRenderer.invoke('save-file', fileData)
});