2022-01-18 18:21:53 +01:00
|
|
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
2022-04-07 01:30:08 +02:00
|
|
|
const { ipcRenderer, contextBridge } = require("electron");
|
2022-01-18 18:21:53 +01:00
|
|
|
|
2022-04-07 01:30:08 +02:00
|
|
|
contextBridge.exposeInMainWorld("electronBridge", {
|
|
|
|
send: (channel, data) => {
|
|
|
|
// 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);
|
2022-01-18 18:21:53 +01:00
|
|
|
}
|
2022-04-07 01:30:08 +02:00
|
|
|
},
|
|
|
|
receive: (channel, func) => {
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|