-
Notifications
You must be signed in to change notification settings - Fork 0
/
preload.js
22 lines (19 loc) · 964 Bytes
/
preload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// See the Electron documentation for details on how to use preload scripts:
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
const { contextBridge, ipcRenderer } = require("electron");
console.log("👋 Preload.js loaded successfully");
// contextBridge.exposeInMainWorld("electronAPI", {
// read: () => ipcRenderer.send("read"),
// getFakeFile: () => ipcRenderer.invoke("fakeFile"),
// getFileFromPath: (path) => ipcRenderer.invoke("getFileFromPath", path),
// });
// contextBridge.exposeInMainWorld("ipcRenderer", {
// send: (event, data) => ipcRenderer.send(event, data),
// invoke: (event, data) => ipcRenderer.invoke(event, data)
// });
const api = {
getkeyboard: (arg) => ipcRenderer.invoke('get-keyboard', arg),
parseAndExecuteKeyCommand: (arg) => ipcRenderer.invoke('parse-and-execute-key-command', arg),
getSources: () => ipcRenderer.invoke('get-sources')
}
contextBridge.exposeInMainWorld("api", api);