-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
38 lines (34 loc) · 1.39 KB
/
preload.js
File metadata and controls
38 lines (34 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { contextBridge, ipcRenderer } = require('electron');
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld(
'api', {
// File operations
selectFiles: () => ipcRenderer.invoke('select-files'),
copyFiles: (filePaths) => ipcRenderer.invoke('copy-files', filePaths),
// Analysis operations
runAnalysis: (options) => ipcRenderer.invoke('run-analysis', options),
getResults: () => ipcRenderer.invoke('get-results'),
generateHeatmap: (runId) => ipcRenderer.invoke('generate-heatmap', runId),
// Communication channels
onAnalysisUpdate: (callback) => {
ipcRenderer.on('analysis-update', (_, data) => callback(data));
},
onNewHypothesis: (callback) => {
ipcRenderer.on('new-hypothesis', (_, data) => callback(data));
},
onRunCompleted: (callback) => {
ipcRenderer.on('run-completed', (_, data) => callback(data));
},
onAnalysisComplete: (callback) => {
ipcRenderer.on('analysis-complete', (_, data) => callback(data));
},
// Remove event listeners
removeListeners: () => {
ipcRenderer.removeAllListeners('analysis-update');
ipcRenderer.removeAllListeners('new-hypothesis');
ipcRenderer.removeAllListeners('run-completed');
ipcRenderer.removeAllListeners('analysis-complete');
}
}
);