2021-06-16 00:43:02 +03:00
|
|
|
import './polyfills'
|
|
|
|
|
2021-05-24 18:48:12 +03:00
|
|
|
import 'zone.js'
|
|
|
|
import 'core-js/proposals/reflect-metadata'
|
|
|
|
import 'core-js/features/array/flat'
|
|
|
|
import 'rxjs'
|
|
|
|
|
2021-06-16 00:43:02 +03:00
|
|
|
import '../app/src/global.scss'
|
|
|
|
import '../app/src/toastr.scss'
|
2021-05-24 18:48:12 +03:00
|
|
|
|
|
|
|
import { enableProdMode, NgModuleRef, ApplicationRef } from '@angular/core'
|
|
|
|
import { enableDebugTools } from '@angular/platform-browser'
|
|
|
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
|
|
|
|
2021-06-16 00:43:02 +03:00
|
|
|
import { getRootModule } from '../app/src/app.module'
|
|
|
|
import { BootstrapData, BOOTSTRAP_DATA } from '../terminus-core/src/api/mainProcess'
|
2021-05-24 18:48:12 +03:00
|
|
|
|
|
|
|
|
|
|
|
window['bootstrapTerminus'] = async function bootstrap (packageModules: any[], bootstrapData: BootstrapData, debugMode = false): Promise<NgModuleRef<any>> {
|
2021-06-16 00:43:02 +03:00
|
|
|
window.parent.postMessage('request-connector', '*')
|
|
|
|
|
2021-05-24 18:48:12 +03:00
|
|
|
const pluginModules = []
|
|
|
|
for (const packageModule of packageModules) {
|
|
|
|
const pluginModule = packageModule.default.forRoot ? packageModule.default.forRoot() : packageModule.default
|
|
|
|
pluginModule.pluginName = packageModule.pluginName
|
|
|
|
pluginModule.bootstrap = packageModule.bootstrap
|
|
|
|
pluginModules.push(pluginModule)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!debugMode) {
|
|
|
|
enableProdMode()
|
|
|
|
}
|
|
|
|
|
|
|
|
const module = getRootModule(pluginModules)
|
|
|
|
window['rootModule'] = module
|
|
|
|
|
|
|
|
const moduleRef = await platformBrowserDynamic([
|
|
|
|
{ provide: BOOTSTRAP_DATA, useValue: bootstrapData },
|
|
|
|
]).bootstrapModule(module)
|
|
|
|
if (debugMode) {
|
|
|
|
const applicationRef = moduleRef.injector.get(ApplicationRef)
|
|
|
|
const componentRef = applicationRef.components[0]
|
|
|
|
enableDebugTools(componentRef)
|
|
|
|
}
|
|
|
|
return moduleRef
|
|
|
|
}
|