-
Notifications
You must be signed in to change notification settings - Fork 26
/
preload.js
41 lines (40 loc) · 1.79 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
40
41
const {contextBridge, ipcRenderer} = require("electron");
const Store = require('electron-store');
const store = new Store();
// Expose protected methods from node modules
contextBridge.exposeInMainWorld("electron", {
ipcRenderer: {
send: (channel, data) => {
// whitelist channels
let validChannels = ["quitApp", "keyPress", "updateCache", "deleteCache", "openCache", "selectCustomLocation", "selectCacheLocation", "refreshCache", "openPreview", "refreshConfig", "resetConfig", "updateLocation", "openConfigFolder", "selectFile", "openInfoEditor", "newGlobalShortcut", "consoleLog"];
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, data);
}
},
on: (channel, func) => {
let validChannels = ["displaySettings", "newCustomVideos", "newVideo", "blankTheScreen", "showWelcome", "updateAttribute", "screenNumber"];
if (validChannels.includes(channel)) {
// Deliberately strip event as it includes `sender`
ipcRenderer.on(channel, (event, ...args) => func(...args));
}
},
// From render to main and back again.
invoke: (channel, args) => {
let validChannels = ["newVideoId"];
if (validChannels.includes(channel)) {
return ipcRenderer.invoke(channel, args);
}
}
},
store: {
get: (key) => {
return store.get(key);
},
set: (key, value) => {
return store.set(key, value);
}
},
videos: require("./videos.json"),
fontListUniversal: require('font-list-universal'),
}
)