This repository has been archived by the owner on Apr 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpreload.js
39 lines (33 loc) · 1.99 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
36
37
38
39
const { contextBridge, ipcRenderer } = require('electron');
// Client config
contextBridge.exposeInMainWorld('clientConfig', {
setLauncher: (launcher) => ipcRenderer.send('setLauncher', launcher),
});
// Used for logging
contextBridge.exposeInMainWorld('logging', {
writeToLog: (data) => ipcRenderer.invoke('writeToLog', data),
});
// Version checking
contextBridge.exposeInMainWorld('versioning', {
clientUpdatePrompt: (tag) => ipcRenderer.invoke('clientUpdatePrompt', tag),
});
// OoT Interaction
contextBridge.exposeInMainWorld('oot', {
// Functions callable by renderer to cause IPCMain to perform an action
receiveItem: (requestId, itemOffset) => ipcRenderer.send('receiveItem', requestId, itemOffset),
isItemReceivable: (requestId) => ipcRenderer.send('isItemReceivable', requestId),
getReceivedItemCount: (requestId) => ipcRenderer.send('getReceivedItemCount', requestId),
getRomName: (requestId) => ipcRenderer.send('getRomName', requestId),
setNames: (requestId, namesObj) => ipcRenderer.send('setNames', requestId, namesObj),
getLocationChecks: (requestId) => ipcRenderer.send('getLocationChecks', requestId),
getCurrentGameMode: (requestId) => ipcRenderer.send('getCurrentGameMode', requestId),
isGameComplete: (requestId) => ipcRenderer.send('isGameComplete', requestId),
isDeathLinkEnabled: (requestId) => ipcRenderer.send('isDeathLinkEnabled', requestId),
isLinkAlive: (requestId) => ipcRenderer.send('isLinkAlive', requestId),
killLink: (requestId) => ipcRenderer.send('killLink', requestId),
disconnectAllClients: () => ipcRenderer.send('disconnectAllClients'),
// Function listenable by renderer to allow IPCMain to report a completed request
requestComplete: (callback) => ipcRenderer.on('requestComplete', (event, ...args) => callback.apply(null, ...args)),
// Function listenable by renderer to allow IPCMain to report a connected or disconnected client
deviceConnected: (callback) => ipcRenderer.on('deviceConnected', (event, connected) => callback(connected)),
});