-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.js
99 lines (75 loc) · 2.7 KB
/
main.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const { app, BrowserWindow, ipcMain, shell } = require('electron');
const TallyServer = require('./models/tallyServer');
const AtemController = require('./models/atemController');
const Network = require('./models/network');
const Updates = require('./models/updateController');
const DeviceController = require('./models/deviceController');
const Telemetry = require('./models/telemetryMain.js');
const SettingsStore = require('./models/settingsStore.js');
const os = require('os')
const path = require('path')
const config = require('./config')
const windowStateKeeper = require('electron-window-state')
const pjson = require('./package.json')
const { MAX_BYTES_ON_DISK } = require('applicationinsights/out/Library/Sender')
let telemetry = new Telemetry((config && config.appInsightKey) ? config.appInsightKey : null);
telemetry.registerHandlers();
global.telemetry = telemetry;
telemetry.trackEvent({ name: "app_launch", properties: { type: os.type(), release: os.release(), platform: os.platform(), version: pjson.version } });
let tallyServer = new TallyServer();
tallyServer.startServer();
let atemController = new AtemController();
atemController.init(tallyServer);
let deviceController = new DeviceController();
deviceController.init(tallyServer);
// IPC network manager
let network = new Network();
// IPC settings store
let settings = new SettingsStore();
// IPC version checker
let updates = new Updates(pjson.version);
async function createWindow() {
let mainWindowState = windowStateKeeper({
defaultWidth: 1000,
defaultHeight: 800
});
let prepath = path.join(`${__dirname}`, 'preload.js');
win = new BrowserWindow({
'x': mainWindowState.x,
'y': mainWindowState.y,
'width': mainWindowState.width,
'height': mainWindowState.height,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true,
contextIsolation: true,
preload: prepath
}
})
atemController.registerHandlers(win);
deviceController.registerHandlers(win);
await win.loadFile('index.html')
win.setMenu(null);
// win.webContents.openDevTools({ "mode": "detach" });
mainWindowState.manage(win);
}
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
ipcMain.handle('app:version', () => {
return pjson.version
})
ipcMain.handle('app:open-url', (event, url) => {
telemetry.trackEvent('nav_ext', { url: url })
require('electron').shell.openExternal(url);
})