mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-21 05:35:45 +01:00
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||
|
const { ipcRenderer, contextBridge } = require('electron')
|
||
|
const log = require("electron-log");
|
||
|
|
||
|
contextBridge.exposeInMainWorld(
|
||
|
"electronBridge", {
|
||
|
send: (channel, data) => {
|
||
|
log.log("Send on channel " + channel)
|
||
|
// whitelist channels
|
||
|
let validChannels = [
|
||
|
"get-save-data-response",
|
||
|
"get-save-info-response",
|
||
|
"push-game-saved",
|
||
|
"push-game-ready",
|
||
|
"push-import-result",
|
||
|
"push-disable-restore",
|
||
|
];
|
||
|
if (validChannels.includes(channel)) {
|
||
|
ipcRenderer.send(channel, data);
|
||
|
}
|
||
|
},
|
||
|
receive: (channel, func) => {
|
||
|
log.log("Receive on channel " + channel)
|
||
|
let validChannels = [
|
||
|
"get-save-data-request",
|
||
|
"get-save-info-request",
|
||
|
"push-save-request",
|
||
|
"trigger-save",
|
||
|
"trigger-game-export",
|
||
|
"trigger-scripts-export",
|
||
|
];
|
||
|
if (validChannels.includes(channel)) {
|
||
|
// Deliberately strip event as it includes `sender`
|
||
|
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
);
|