1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-13 18:30:54 +01:00
upscayl/electron/preload.ts

15 lines
572 B
TypeScript
Raw Normal View History

2022-11-11 21:39:28 +01:00
import { ipcRenderer, contextBridge } from "electron";
2023-09-10 20:00:49 +02:00
import { getPlatform } from "./utils/get-device-specs";
2022-08-15 06:53:14 +02:00
2022-08-15 09:06:31 +02:00
// 'ipcRenderer' will be available in index.js with the method 'window.electron'
2022-08-17 04:37:50 +02:00
contextBridge.exposeInMainWorld("electron", {
2022-11-11 21:47:00 +01:00
send: (command: string, payload: any) => ipcRenderer.send(command, payload),
on: (command: string, func: (...args: any) => any) =>
2022-08-17 04:37:50 +02:00
ipcRenderer.on(command, (event, args) => {
2022-08-17 13:36:19 +02:00
func(event, args);
2022-08-17 04:37:50 +02:00
}),
2022-11-11 21:47:00 +01:00
invoke: (command: string, payload: any) =>
ipcRenderer.invoke(command, payload),
2023-08-30 06:54:16 +02:00
platform: getPlatform(),
2022-08-17 04:37:50 +02:00
});