2021-06-15 21:43:02 +00:00
|
|
|
import './polyfills'
|
|
|
|
|
2021-05-24 15:48:12 +00:00
|
|
|
import 'zone.js'
|
|
|
|
import 'core-js/proposals/reflect-metadata'
|
|
|
|
import 'core-js/features/array/flat'
|
|
|
|
import 'rxjs'
|
|
|
|
|
2021-06-15 21:43:02 +00:00
|
|
|
import '../app/src/global.scss'
|
|
|
|
import '../app/src/toastr.scss'
|
2021-05-24 15:48:12 +00:00
|
|
|
|
|
|
|
import { enableProdMode, NgModuleRef, ApplicationRef } from '@angular/core'
|
|
|
|
import { enableDebugTools } from '@angular/platform-browser'
|
|
|
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
|
|
|
|
2021-06-15 21:43:02 +00:00
|
|
|
import { getRootModule } from '../app/src/app.module'
|
2021-06-29 21:57:04 +00:00
|
|
|
import { BootstrapData, BOOTSTRAP_DATA } from '../tabby-core/src/api/mainProcess'
|
2021-05-24 15:48:12 +00:00
|
|
|
|
2021-06-27 17:08:37 +00:00
|
|
|
interface BootstrapOptions {
|
|
|
|
packageModules: any[]
|
|
|
|
bootstrapData: BootstrapData
|
|
|
|
debugMode: boolean
|
|
|
|
connector: any
|
|
|
|
}
|
2021-05-24 15:48:12 +00:00
|
|
|
|
2021-06-29 21:57:04 +00:00
|
|
|
window['bootstrapTabby'] = async function bootstrap (options: BootstrapOptions): Promise<NgModuleRef<any>> {
|
2021-06-15 21:43:02 +00:00
|
|
|
window.parent.postMessage('request-connector', '*')
|
|
|
|
|
2021-05-24 15:48:12 +00:00
|
|
|
const pluginModules = []
|
2021-06-27 17:08:37 +00:00
|
|
|
for (const packageModule of options.packageModules) {
|
2022-02-07 15:36:20 +00:00
|
|
|
if (!packageModule.default) {
|
|
|
|
continue
|
|
|
|
}
|
2021-05-24 15:48:12 +00:00
|
|
|
const pluginModule = packageModule.default.forRoot ? packageModule.default.forRoot() : packageModule.default
|
|
|
|
pluginModule.pluginName = packageModule.pluginName
|
|
|
|
pluginModule.bootstrap = packageModule.bootstrap
|
|
|
|
pluginModules.push(pluginModule)
|
|
|
|
}
|
|
|
|
|
2021-06-27 17:08:37 +00:00
|
|
|
if (!options.debugMode) {
|
2021-05-24 15:48:12 +00:00
|
|
|
enableProdMode()
|
|
|
|
}
|
|
|
|
|
|
|
|
const module = getRootModule(pluginModules)
|
|
|
|
window['rootModule'] = module
|
|
|
|
|
|
|
|
const moduleRef = await platformBrowserDynamic([
|
2021-06-27 17:08:37 +00:00
|
|
|
{ provide: BOOTSTRAP_DATA, useValue: options.bootstrapData },
|
|
|
|
{ provide: 'WEB_CONNECTOR', useValue: options.connector },
|
2021-05-24 15:48:12 +00:00
|
|
|
]).bootstrapModule(module)
|
2021-06-27 17:08:37 +00:00
|
|
|
if (options.debugMode) {
|
2021-05-24 15:48:12 +00:00
|
|
|
const applicationRef = moduleRef.injector.get(ApplicationRef)
|
|
|
|
const componentRef = applicationRef.components[0]
|
|
|
|
enableDebugTools(componentRef)
|
|
|
|
}
|
|
|
|
return moduleRef
|
|
|
|
}
|