-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTUILiveKit.preload.js
More file actions
65 lines (56 loc) · 2.34 KB
/
TUILiveKit.preload.js
File metadata and controls
65 lines (56 loc) · 2.34 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const logPrefix = '[TUILiveKit.preload]';
console.log(`${logPrefix} node version: ${process.versions.node}`);
console.log(`${logPrefix} chrome version: ${process.versions.chrome}`);
console.log(`${logPrefix} electron version: ${process.versions.electron}`);
console.log(`${logPrefix} process.cwd(): ${process.cwd()}`);
console.log(`${logPrefix} __dirname: ${__dirname}`);
console.log(`${logPrefix} env.NODE_ENV: ${process.env.NODE_ENV}`);
const { ipcRenderer } = require('electron');
const path = require('path');
ipcRenderer.on('crash-file-path', (event, args) => {
console.warn(`${logPrefix} crash-file-path:`, args);
});
ipcRenderer.on('native-window-handle', (event, args) => {
console.log(`${logPrefix} native window id:`, args);
window.nativeWindowHandle = args;
});
ipcRenderer.on('user-login', (event, { from, to }) => {
console.log(`${logPrefix} login from:${from} window to:${to}`);
if (to === 'main') {
if (window.location.hash.indexOf('tui-live-kit-main') === -1) {
window.location.hash = 'tui-live-kit-main';
}
} else if (to === 'child') {
if (window.location.hash.indexOf('tui-live-kit-child') === -1) {
window.location.hash = 'tui-live-kit-child';
}
} else if (to === 'cover') {
if (window.location.hash.indexOf('tui-live-kit-cover') === -1) {
window.location.hash = 'tui-live-kit-cover';
}
} else if (to === 'confirm') {
if (window.location.hash.indexOf('tui-live-kit-confirm') === -1) {
window.location.hash = 'tui-live-kit-confirm';
}
}
});
ipcRenderer.on('port-to-child', (event) => {
window.mainWindowPortInChild = event.ports[0];
console.log(`${logPrefix} port-to-child window:`, window.mainWindowPortInChild, Date.now());
});
ipcRenderer.on('port-to-cover', (event) => {
window.mainWindowPortInCover = event.ports[0];
console.log(`${logPrefix} port-to-cover window:`, window.mainWindowPortInCover, Date.now());
});
ipcRenderer.on('port-to-confirm', (event) => {
window.mainWindowPortInConfirm = event.ports[0];
console.log(`${logPrefix} port-to-confirm window:`, window.mainWindowPortInConfirm, Date.now());
});
window.ipcRenderer = ipcRenderer;
window.path = path;
window.ROOT_PATH = path.join(__dirname, '../');
window.PUBLIC_PATH = path.join(__dirname);
ipcRenderer.on('app-path', (event, appPath) => {
console.warn('APP_PATH:', appPath);
window.APP_PATH = appPath;
});