mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-24 21:25:45 +00:00
27 lines
917 B
JavaScript
27 lines
917 B
JavaScript
const { ipcRenderer, contextBridge, webUtils, shell } = require('electron');
|
|
|
|
contextBridge.exposeInMainWorld('isPlaywright', process.env.PLAYWRIGHT === 'true');
|
|
|
|
contextBridge.exposeInMainWorld('ipcRenderer', {
|
|
invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),
|
|
send: (channel, ...args) => ipcRenderer.send(channel, ...args),
|
|
on: (channel, handler) => {
|
|
// Deliberately strip event as it includes `sender`
|
|
const subscription = (event, ...args) => {
|
|
// Ensure args is always an array to prevent undefined errors
|
|
const safeArgs = args && args.length ? args : [];
|
|
handler(...safeArgs);
|
|
};
|
|
ipcRenderer.on(channel, subscription);
|
|
|
|
return () => {
|
|
ipcRenderer.removeListener(channel, subscription);
|
|
};
|
|
},
|
|
getFilePath(file) {
|
|
const path = webUtils.getPathForFile(file);
|
|
return path;
|
|
},
|
|
openExternal: (url) => shell.openExternal(url)
|
|
});
|