-
-
Notifications
You must be signed in to change notification settings - Fork 319
/
Copy pathmain.ts
51 lines (47 loc) · 1.59 KB
/
main.ts
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
/// <reference path="dts/index.d.ts" />
import { Capacitor, registerPlugin } from '@capacitor/core'
import { App } from '@capacitor/app'
import { Device } from '@capacitor/device'
import { SplashScreen } from '@capacitor/splash-screen'
import appInit from './app'
import { init as settingsInit } from './settings'
import { StockfishVariants } from './stockfish'
import { init as i18nInit } from './i18n'
import { init as themeInit } from './theme'
import routes from './routes'
import { processWindowLocation } from './router'
import push from './push'
import deepLinks from './deepLinks'
import globalConfig from './config'
interface XNavigator extends Navigator {
hardwareConcurrency: number
}
interface CPUInfoPlugin {
nbCores(): Promise<{ value: number }>
}
const CPUInfo = registerPlugin<CPUInfoPlugin>('CPUInfo')
settingsInit()
.then(() => Promise.all([
App.getInfo().catch(() => ({ version: globalConfig.packageVersion })),
Device.getInfo(),
Device.getId(),
Capacitor.getPlatform() === 'ios' ?
CPUInfo.nbCores().then((r: { value: number }) => r.value).catch(() => 1) :
Promise.resolve((<XNavigator>navigator).hardwareConcurrency || 1),
StockfishVariants.getMaxMemory().then((r: { value: number }) => r.value).catch(() => 16),
StockfishVariants.getCPUArch().then((r: { value: string }) => r.value).catch(() => 'x86'),
]))
.then(([ai, di, did, c, m, cpu]) => appInit(ai, di, did, c, m, cpu))
.then(() => {
routes.init()
deepLinks.init()
push.init()
})
.then(themeInit)
.then(i18nInit)
.then(() => processWindowLocation())
.then(() => {
setTimeout(() => {
SplashScreen.hide()
}, 500)
})