-
-
Notifications
You must be signed in to change notification settings - Fork 485
/
preload.js
72 lines (69 loc) · 2.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const Sentry = require("@sentry/electron");
const Tracing = require("@sentry/tracing");
const version = require('./package.json').version;
const { contextBridge, ipcRenderer } = require('electron')
function initSentry() {
if(process.argv[2] === '--dev' && !process.argv.includes("--sentry")) return;
Sentry.init({
dsn: process.env.SENTRY_DSN,
release: "youtube-dl-gui@" + version,
sendDefaultPii: true,
integrations: [new Tracing.Integrations.BrowserTracing()],
tracesSampleRate: process.argv[2] === '--dev' ? 1.0 : 0.01,
environment: process.argv[2] === '--dev' ? "development" : "production",
autoSessionTracking: true
});
}
initSentry();
contextBridge.exposeInMainWorld(
"main",
{
invoke: async (channel, data) => {
let validChannels = [
"platform",
"messageBox",
"errorReport",
"titlebarClick",
"openInputMenu",
"openCopyMenu",
"settingsAction",
"videoAction",
"cookieFile",
"downloadFolder",
"installUpdate",
"iconProgress",
"theme",
"restoreTaskList",
"getDoneActions",
"setDoneAction",
"getSubtitles",
"getSelectedSubtitles",
"getLog",
"saveLog"
];
if (validChannels.includes(channel)) {
return await ipcRenderer.invoke(channel, data);
}
},
receive: (channel, cb) => {
let validChannels = [
"log",
"error",
"toast",
"maximized",
"videoAction",
"updateGlobalButtons",
"updateLinkPlaceholder",
"totalSize",
"binaryLock",
"addShortcut",
"downloadShortcut"
];
if (validChannels.includes(channel)) {
ipcRenderer.on(channel, (event, arg) => {
cb(arg)
});
}
}
}
);