-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
22 lines (18 loc) · 1.04 KB
/
Copy pathpreload.js
File metadata and controls
22 lines (18 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('api', {
// Project management
getDefaultPath: () => ipcRenderer.invoke('get-default-path'),
loadProject: (path) => ipcRenderer.invoke('load-project', path),
selectFolder: () => ipcRenderer.invoke('select-folder'),
openInFinder: (path) => ipcRenderer.invoke('open-in-finder', path),
// Script management
runScript: (projectPath, scriptName) => ipcRenderer.invoke('run-script', { projectPath, scriptName }),
stopScript: (scriptName) => ipcRenderer.invoke('stop-script', scriptName),
getRunningScripts: () => ipcRenderer.invoke('get-running-scripts'),
// Utilities
openUrl: (url) => ipcRenderer.invoke('open-url', url),
installDeps: (projectPath) => ipcRenderer.invoke('install-deps', projectPath),
// Event listeners
onScriptOutput: (callback) => ipcRenderer.on('script-output', (event, data) => callback(data)),
onScriptExit: (callback) => ipcRenderer.on('script-exit', (event, data) => callback(data))
});