-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreload.js
35 lines (31 loc) · 1.5 KB
/
preload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const { contextBridge, ipcRenderer } = require("electron");
contextBridge.exposeInMainWorld("devices", {
//Expose devices object to renderer
getDevices: () => ipcRenderer.invoke("devices:getDevices"),
locateDevice: (ip) => ipcRenderer.invoke("devices:locateDevice", ip),
});
contextBridge.exposeInMainWorld("serial", {
//Expose serial object to renderer
getDevices: () => ipcRenderer.invoke("serial:getDevices"),
connectTo: (port) => ipcRenderer.invoke("serial:connectTo", port),
disconnect: () => ipcRenderer.invoke("serial:disconnect"),
getState: () => ipcRenderer.invoke("serial:getState"),
});
contextBridge.exposeInMainWorld("game", {
//Expose game object to renderer
getGamemodes: () => ipcRenderer.invoke("game:getGamemodes"),
getState: () => ipcRenderer.invoke("game:getState"),
startGame: () => ipcRenderer.invoke("game:startGame"),
stopGame: () => ipcRenderer.invoke("game:stopGame"),
selectGame: (gameid) => ipcRenderer.invoke("game:selectGame", gameid),
getPlayers: () => ipcRenderer.invoke("game:getPlayers"),
setTeams: (teams) => ipcRenderer.invoke("game:setTeams", teams),
getTeams: () => ipcRenderer.invoke("game:getTeams"),
getScores: () => ipcRenderer.invoke("game:getScores"),
setSettings: (settings) => ipcRenderer.invoke("game:setSettings", settings),
getSettings: () => ipcRenderer.invoke("game:getSettings"),
toggleLeaderboardWindow: () => ipcRenderer.invoke("game:toggleLeaderboardWindow")
});
window.addEventListener("DOMContentLoaded", () => {
// Preload Code
});