-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreload.js
47 lines (45 loc) · 3.19 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
42
43
44
45
46
47
const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld('electronAPI', {
autoDetectDevices: () => ipcRenderer.send('autoDetectDevices'),
onAutoDetect: (callback) => ipcRenderer.on("autoDetectResult", callback),
addDevice: (device) => ipcRenderer.send("addDevice", device),
getDevices: () => ipcRenderer.invoke("getDevices"),
setColorTheme: (color) => ipcRenderer.invoke("setColorTheme", color),
getColorTheme: () => ipcRenderer.invoke("getColorTheme"),
setAutoUpdateFirmware: (value) => ipcRenderer.invoke("setAutoUpdateFirmware", value),
getAutoUpdateFirmware: () => ipcRenderer.invoke("getAutoUpdateFirmware"),
saveMacro: (macro) => ipcRenderer.invoke("saveMacro", JSON.stringify(macro)),
setMacros: (macros) => ipcRenderer.invoke("setMacros", JSON.stringify(macros)),
removeMacro: (uuid) => ipcRenderer.invoke("removeMacro", uuid),
getMacros: () => ipcRenderer.invoke("getMacros"),
onDeviceRefresh: (callback) => ipcRenderer.on("refreshDevices", callback),
getLayouts: () => ipcRenderer.invoke("getLayouts"),
getParts: () => ipcRenderer.invoke("getParts"),
removeDevice: (index) => {ipcRenderer.invoke("removeDevice", index)},
renameDevice: (index, name) => {ipcRenderer.invoke("renameDevice", index, name)},
flashDevice: (index, callback) => ipcRenderer.invoke("flashDevice", index),
onFlashResult: (callback) => {ipcRenderer.on("flashResult", callback)},
flashPort: (port, type) => ipcRenderer.invoke("flashPort", port, type),
onPortFlashResult: (callback) => {ipcRenderer.on("portFlashResult", callback)},
writeDevice: (device, message) => ipcRenderer.invoke("writeDevice", device, message),
setDevicePinOut: (device, config) => ipcRenderer.invoke("setDevicePinOut", device, config),
setDevicePinProperties: (device, config) => ipcRenderer.invoke("setDevicePinProperties", device, config),
getInstalledPlugins: () => ipcRenderer.invoke("getInstalledPlugins"),
enablePlugin: (packageName) => ipcRenderer.invoke("enablePlugin", packageName),
disablePlugin: (packageName) => ipcRenderer.invoke("disablePlugin", packageName),
uninstallPlugin: (packageName) => ipcRenderer.invoke("uninstallPlugin", packageName),
addPluginDialog: () => ipcRenderer.invoke("addPluginDialog"),
addPluginFromFile: (pluginPath) => ipcRenderer.invoke("addPluginFromFile", pluginPath),
setOpenAtLogin: (openAtLogin) => ipcRenderer.invoke("setOpenAtLogin", openAtLogin),
getOpenAtLogin: () => ipcRenderer.invoke("getOpenAtLogin"),
getPluginREADME: (packageName) => ipcRenderer.invoke("getPluginREADME", packageName),
getPlugin: (packageName) => ipcRenderer.invoke("getPlugin", packageName),
getPluginSettings: (packageName) => ipcRenderer.invoke("getPluginSettings", packageName),
setPluginSettings: (packageName, settings) => ipcRenderer.invoke("setPluginSettings", packageName, settings),
getLoadedPlugins: () => ipcRenderer.invoke("getLoadedPlugins"),
getAllActions: () => ipcRenderer.invoke("getAllActions"),
openLinkInBrowser: (link) => ipcRenderer.invoke("openLinkInBrowser", link),
isAppBundled: () => ipcRenderer.invoke("isAppBundled"),
getAppVersion: () => ipcRenderer.invoke("getAppVersion"),
installUpdates: () => ipcRenderer.invoke("installUpdates")
});