-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
46 lines (44 loc) · 2.07 KB
/
Copy pathpreload.js
File metadata and controls
46 lines (44 loc) · 2.07 KB
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
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('api', {
// Updater API
checkForUpdates: () => ipcRenderer.invoke('checkForUpdates'),
downloadUpdate: () => ipcRenderer.invoke('downloadUpdate'),
installUpdate: () => ipcRenderer.invoke('installUpdate'),
getAppVersion: () => ipcRenderer.invoke('getAppVersion'),
onUpdateAvailable: (cb) => {
const listener = (_, data) => cb(data);
ipcRenderer.on('updateAvailable', listener);
return () => ipcRenderer.removeListener('updateAvailable', listener);
},
onUpdateDownloaded: (cb) => {
const listener = (_, data) => cb(data);
ipcRenderer.on('updateDownloaded', listener);
return () => ipcRenderer.removeListener('updateDownloaded', listener);
},
onUpdateProgress: (cb) => {
const listener = (_, data) => cb(data);
ipcRenderer.on('updateProgress', listener);
return () => ipcRenderer.removeListener('updateProgress', listener);
},
onUpdateError: (cb) => {
const listener = (_, data) => cb(data);
ipcRenderer.on('updateError', listener);
return () => ipcRenderer.removeListener('updateError', listener);
},
// Existing API
fetchVideoInfo: (url, cookiesOptions) => ipcRenderer.invoke('fetchVideoInfo', url, cookiesOptions),
getLastVideoInfo: () => ipcRenderer.invoke('getLastVideoInfo'),
openEditorPage: () => ipcRenderer.invoke('openEditorPage'),
chooseOutputPath: (opts) => ipcRenderer.invoke('chooseOutputPath', opts),
chooseFolder: () => ipcRenderer.invoke('chooseFolder'),
chooseCookiesFile: () => ipcRenderer.invoke('chooseCookiesFile'),
getDefaultDocumentsPath: () => ipcRenderer.invoke('getDefaultDocumentsPath'),
startExport: (params) => ipcRenderer.invoke('startExport', params),
onExportProgress: (cb) => {
const listener = (_, data) => cb(data);
ipcRenderer.on('exportProgress', listener);
return () => ipcRenderer.removeListener('exportProgress', listener);
},
revealInFolder: (filePath) => ipcRenderer.invoke('revealInFolder', filePath),
openExternal: (url) => ipcRenderer.invoke('openExternal', url)
});