2017-06-30 22:55:21 +00:00
|
|
|
import 'zone.js'
|
2016-12-23 09:06:53 +00:00
|
|
|
import 'core-js/es7/reflect'
|
2017-06-20 21:28:58 +00:00
|
|
|
import 'core-js/core/delay'
|
2017-04-16 21:04:29 +00:00
|
|
|
import 'rxjs'
|
2018-08-25 07:37:56 +00:00
|
|
|
|
|
|
|
import './global.scss'
|
2018-03-30 21:24:34 +00:00
|
|
|
import './toastr.scss'
|
2016-12-23 09:06:53 +00:00
|
|
|
|
|
|
|
// Always land on the start view
|
|
|
|
location.hash = ''
|
|
|
|
|
2017-08-13 12:13:04 +00:00
|
|
|
import { enableProdMode, NgModuleRef } from '@angular/core'
|
2016-12-23 09:06:53 +00:00
|
|
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
|
|
|
|
2017-04-23 22:34:07 +00:00
|
|
|
import { getRootModule } from './app.module'
|
2017-08-13 12:13:04 +00:00
|
|
|
import { findPlugins, loadPlugins, IPluginInfo } from './plugins'
|
2017-04-23 22:34:07 +00:00
|
|
|
|
2019-01-03 14:20:02 +00:00
|
|
|
;(process as any).enablePromiseAPI = true
|
|
|
|
|
2017-07-15 17:07:41 +00:00
|
|
|
if (process.platform === 'win32') {
|
2017-07-04 16:25:58 +00:00
|
|
|
process.env.HOME = process.env.HOMEDRIVE + process.env.HOMEPATH
|
|
|
|
}
|
|
|
|
|
2017-05-01 11:35:26 +00:00
|
|
|
if (require('electron-is-dev')) {
|
2016-12-23 09:06:53 +00:00
|
|
|
console.warn('Running in debug mode')
|
|
|
|
} else {
|
|
|
|
enableProdMode()
|
|
|
|
}
|
|
|
|
|
2017-08-13 12:13:04 +00:00
|
|
|
async function bootstrap (plugins: IPluginInfo[], safeMode = false): Promise<NgModuleRef<any>> {
|
|
|
|
if (safeMode) {
|
|
|
|
plugins = plugins.filter(x => x.isBuiltin)
|
|
|
|
}
|
2017-04-28 20:40:58 +00:00
|
|
|
let pluginsModules = await loadPlugins(plugins, (current, total) => {
|
2017-05-01 11:35:26 +00:00
|
|
|
(document.querySelector('.progress .bar') as HTMLElement).style.width = 100 * current / total + '%'
|
2017-04-24 19:26:59 +00:00
|
|
|
})
|
2017-08-13 12:13:04 +00:00
|
|
|
let module = getRootModule(pluginsModules)
|
2017-11-26 21:14:46 +00:00
|
|
|
window['rootModule'] = module
|
2018-12-21 22:18:22 +00:00
|
|
|
return platformBrowserDynamic().bootstrapModule(module)
|
2017-08-13 12:13:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
findPlugins().then(async plugins => {
|
|
|
|
console.log('Starting with plugins:', plugins)
|
|
|
|
try {
|
|
|
|
await bootstrap(plugins)
|
|
|
|
} catch (error) {
|
|
|
|
console.error('Angular bootstrapping error:', error)
|
|
|
|
console.warn('Trying safe mode')
|
|
|
|
window['safeModeReason'] = error
|
|
|
|
try {
|
|
|
|
await bootstrap(plugins, true)
|
|
|
|
} catch (error) {
|
|
|
|
console.error('Bootstrap failed:', error)
|
|
|
|
}
|
|
|
|
}
|
2017-04-15 13:20:18 +00:00
|
|
|
})
|