-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
30 lines (25 loc) · 1.44 KB
/
preload.js
File metadata and controls
30 lines (25 loc) · 1.44 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
/**
* @fileoverview Secure IPC bridge for Hexbloop
* @author Hexbloop Audio Labs
* @description Preload script providing secure IPC communication
*/
const { contextBridge, ipcRenderer, webUtils } = require('electron');
// Expose protected methods that allow the renderer process to use the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld('electronAPI', {
processAudio: (filePaths) => ipcRenderer.invoke('process-audio', filePaths),
selectFiles: () => ipcRenderer.invoke('select-files'),
getFilePathsFromDrop: (files) => ipcRenderer.invoke('get-file-paths-from-drop', files),
openPreferences: () => ipcRenderer.invoke('open-preferences'),
getSettings: () => ipcRenderer.invoke('get-settings'),
// New method for getting file paths from dropped files (Electron v32+ compatible)
getFilePathsFromFiles: (files) => {
return files.map(file => webUtils.getPathForFile(file));
},
// Event listeners for progress updates
onProcessingUpdate: (callback) => ipcRenderer.on('processing-update', callback),
onProcessingProgress: (callback) => ipcRenderer.on('processing-progress', callback),
onFileDropped: (callback) => ipcRenderer.on('file-dropped', callback),
onAmbientToggle: (callback) => ipcRenderer.on('toggle-ambient-audio', callback),
removeAllListeners: (channel) => ipcRenderer.removeAllListeners(channel)
});
console.log('⚡ Preload script loaded - IPC bridge ready!');