|
1 | 1 | /* eslint global-require: off, no-console: off */
|
2 | 2 | import { app, nativeTheme } from 'electron'
|
3 | 3 |
|
4 |
| -import { initHandlers } from 'desktopSrc/handlers' |
5 |
| -import { initLogging } from 'desktopSrc/lib/logging' |
| 4 | +import { initElectronHandlers } from 'desktopSrc/handlers' |
6 | 5 | import { launchApiServer } from 'desktopSrc/services'
|
7 | 6 | import { wrapErrorMessageSensitiveData } from 'desktopSrc/utils'
|
8 |
| -import { createSplashScreen, createWindow } from 'desktopSrc/window' |
9 |
| -import { AboutPanelOptions, checkForUpdate, installExtensions, initTray } from 'desktopSrc/lib' |
10 |
| -import config from 'desktopSrc/config' |
11 |
| - |
12 |
| -if (process.env.NODE_ENV !== 'production') { |
| 7 | +import { configMain as config } from 'desktopSrc/config' |
| 8 | +import { |
| 9 | + initLogging, |
| 10 | + WindowType, |
| 11 | + windowFactory, |
| 12 | + AboutPanelOptions, |
| 13 | + checkForUpdate, |
| 14 | + installExtensions, |
| 15 | + initTray, |
| 16 | + initAutoUpdaterHandlers |
| 17 | +} from 'desktopSrc/lib' |
| 18 | + |
| 19 | +if (!config.isProduction) { |
13 | 20 | const sourceMapSupport = require('source-map-support')
|
14 | 21 | sourceMapSupport.install()
|
15 | 22 | }
|
16 | 23 |
|
17 | 24 | const init = async () => {
|
18 | 25 | await launchApiServer()
|
19 | 26 | initLogging()
|
20 |
| - initHandlers() |
| 27 | + initElectronHandlers() |
| 28 | + initAutoUpdaterHandlers() |
21 | 29 | initTray()
|
22 | 30 |
|
23 | 31 | nativeTheme.themeSource = config.themeSource
|
24 | 32 |
|
25 |
| - const upgradeUrl = process.env.MANUAL_UPGRADES_LINK || process.env.UPGRADES_LINK |
26 |
| - |
27 |
| - if (upgradeUrl && !process.mas) { |
28 |
| - checkForUpdate(upgradeUrl) |
29 |
| - } |
| 33 | + checkForUpdate(process.env.MANUAL_UPGRADES_LINK || process.env.UPGRADES_LINK) |
30 | 34 |
|
31 | 35 | app.setName(config.name)
|
32 | 36 | app.setAppUserModelId(config.name)
|
33 | 37 | if (process.platform !== 'darwin') {
|
34 | 38 | app.setAboutPanelOptions(AboutPanelOptions)
|
35 | 39 | }
|
36 | 40 |
|
37 |
| - if (process.env.NODE_ENV !== 'production') { |
38 |
| - await installExtensions() |
39 |
| - } |
| 41 | + await installExtensions() |
40 | 42 |
|
41 |
| - app |
42 |
| - .whenReady() |
43 |
| - .then(createSplashScreen) |
44 |
| - .then(createWindow) |
45 |
| - .catch((e) => console.log(wrapErrorMessageSensitiveData(e))) |
| 43 | + try { |
| 44 | + await app.whenReady() |
| 45 | + const splashWindow = await windowFactory(WindowType.Splash) |
| 46 | + await windowFactory(WindowType.Main, splashWindow) |
| 47 | + } catch (_err) { |
| 48 | + const error = _err as Error |
| 49 | + console.log(wrapErrorMessageSensitiveData(error)) |
| 50 | + } |
46 | 51 | }
|
47 | 52 |
|
48 | 53 | export default init
|
0 commit comments