Repository navigation
Expand file tree
/
Copy pathindex.ts
More file actions
147 lines (119 loc) · 3.7 KB
/
Copy pathindex.ts
File metadata and controls
147 lines (119 loc) · 3.7 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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import {app} from 'electron';
import {is, enforceMacOSAppLocation} from 'electron-util';
import log from 'electron-log';
import {autoUpdater} from 'electron-updater';
import toMilliseconds from '@sindresorhus/to-milliseconds';
import './windows/load';
import './utils/sentry';
require('electron-timber').hookConsole({main: true, renderer: true});
import {settings} from './common/settings';
import {plugins} from './plugins';
import {initializeTray} from './tray';
import {initializeDevices} from './utils/devices';
import {initializeAnalytics, track} from './common/analytics';
import {initializeGlobalAccelerators} from './global-accelerators';
import {openFiles} from './utils/open-files';
import {hasMicrophoneAccess, ensureScreenCapturePermissions} from './common/system-permissions';
import {handleDeepLink} from './utils/deep-linking';
import {hasActiveRecording, cleanPastRecordings} from './recording-history';
import {setupRemoteStates} from './remote-states';
import {setUpExportsListeners} from './export';
import {windowManager} from './windows/manager';
import {setupProtocol} from './utils/protocol';
import {stopRecordingWithNoEdit} from './aperture';
const prepareNext = require('electron-next');
const filesToOpen: string[] = [];
let >
app.commandLine.appendSwitch('--enable-features', 'OverlayScrollbar');
app.on('open-file', (event, path) => {
event.preventDefault();
if (app.isReady()) {
track('editor/opened/running');
openFiles(path);
} else {
filesToOpen.push(path);
}
});
const initializePlugins = async () => {
if (!is.development) {
try {
await plugins.upgrade();
} catch (error) {
console.log(error);
}
}
};
const checkForUpdates = () => {
if (is.development) {
return false;
}
const checkForUpdates = async () => {
try {
await autoUpdater.checkForUpdates();
} catch (error) {
autoUpdater.logger?.error(error);
}
};
// For auto-update debugging in Console.app
autoUpdater.logger = log;
// @ts-expect-error
autoUpdater.logger.transports.file.level = 'info';
setInterval(checkForUpdates, toMilliseconds({hours: 1}));
checkForUpdates();
return true;
};
// Prepare the renderer once the app is ready
(async () => {
await app.whenReady();
require('./utils/errors').setupErrorHandling();
// Initialize remote states
setupRemoteStates();
setupProtocol();
app.dock.hide();
app.setAboutPanelOptions({copyright: 'Copyright © Wulkano'});
// Ensure the app is in the Applications folder
enforceMacOSAppLocation();
await prepareNext('./renderer');
// Ensure all plugins are up to date
initializePlugins();
initializeDevices();
initializeAnalytics();
initializeTray();
initializeGlobalAccelerators();
setUpExportsListeners();
if (!app.isDefaultProtocolClient('kap')) {
app.setAsDefaultProtocolClient('kap');
}
if (filesToOpen.length > 0) {
track('editor/opened/startup');
openFiles(...filesToOpen);
hasActiveRecording();
} else if (
!(await hasActiveRecording()) &&
!app.getLoginItemSettings().wasOpenedAtLogin &&
ensureScreenCapturePermissions() &&
(!settings.get('recordAudio') || hasMicrophoneAccess())
) {
windowManager.cropper?.open();
}
checkForUpdates();
})();
app.on('window-all-closed', (event: any) => {
app.dock.hide();
event.preventDefault();
});
app.on('will-finish-launching', () => {
app.on('open-url', (event, url) => {
event.preventDefault();
handleDeepLink(url);
});
});
app.on('before-quit', async (event: any) => {
if (!onExitCleanupComplete) {
event.preventDefault();
await stopRecordingWithNoEdit();
cleanPastRecordings();
>
app.quit();
}
});
You can’t perform that action at this time.