Files
bruno/packages/bruno-electron/src/preload.js
2025-08-20 16:24:49 +05:30

19 lines
566 B
JavaScript

const { ipcRenderer, contextBridge, webUtils } = require('electron');
contextBridge.exposeInMainWorld('ipcRenderer', {
invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),
on: (channel, handler) => {
// Deliberately strip event as it includes `sender`
const subscription = (event, ...args) => handler(...args);
ipcRenderer.on(channel, subscription);
return () => {
ipcRenderer.removeListener(channel, subscription);
};
},
getFilePath(file) {
const path = webUtils.getPathForFile(file);
return path;
}
});