mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-29 21:54:37 +00:00
started separating terminus-electron and terminus-web
This commit is contained in:
@@ -16,10 +16,15 @@ export function getRootModule (plugins: any[]) {
|
||||
extendedTimeOut: 1000,
|
||||
}),
|
||||
]
|
||||
|
||||
const bootstrap = [
|
||||
...plugins.filter(x => x.bootstrap).map(x => x.bootstrap),
|
||||
]
|
||||
|
||||
const providers = [
|
||||
...plugins.filter(x => x.providers).map(x => x.providers),
|
||||
].flat()
|
||||
|
||||
if (bootstrap.length === 0) {
|
||||
throw new Error('Did not find any bootstrap components. Are there any plugins installed?')
|
||||
}
|
||||
@@ -27,6 +32,7 @@ export function getRootModule (plugins: any[]) {
|
||||
@NgModule({
|
||||
imports,
|
||||
bootstrap,
|
||||
providers,
|
||||
}) class RootModule { } // eslint-disable-line @typescript-eslint/no-extraneous-class
|
||||
|
||||
return RootModule
|
||||
|
42
app/src/entry-web.ts
Normal file
42
app/src/entry-web.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'zone.js'
|
||||
import 'core-js/proposals/reflect-metadata'
|
||||
import 'core-js/features/array/flat'
|
||||
import 'rxjs'
|
||||
|
||||
import './global.scss'
|
||||
import './toastr.scss'
|
||||
|
||||
import { enableProdMode, NgModuleRef, ApplicationRef } from '@angular/core'
|
||||
import { enableDebugTools } from '@angular/platform-browser'
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
||||
|
||||
import { getRootModule } from './app.module'
|
||||
import { BootstrapData, BOOTSTRAP_DATA } from '../../terminus-core/src/api/mainProcess'
|
||||
|
||||
|
||||
window['bootstrapTerminus'] = async function bootstrap (packageModules: any[], bootstrapData: BootstrapData, debugMode = false): Promise<NgModuleRef<any>> {
|
||||
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
|
||||
}
|
@@ -12,7 +12,7 @@ import { ipcRenderer } from 'electron'
|
||||
|
||||
import { getRootModule } from './app.module'
|
||||
import { findPlugins, loadPlugins, PluginInfo } from './plugins'
|
||||
import { BootstrapData } from '../common'
|
||||
import { BootstrapData, BOOTSTRAP_DATA } from '../../terminus-core/src/api/mainProcess'
|
||||
|
||||
// Always land on the start view
|
||||
location.hash = ''
|
||||
@@ -39,11 +39,9 @@ async function bootstrap (plugins: PluginInfo[], bootstrapData: BootstrapData, s
|
||||
})
|
||||
const module = getRootModule(pluginModules)
|
||||
window['rootModule'] = module
|
||||
const moduleRef = await platformBrowserDynamic().bootstrapModule(module, {
|
||||
providers: [
|
||||
{ provide: 'bootstrapData', useValue: bootstrapData },
|
||||
],
|
||||
})
|
||||
const moduleRef = await platformBrowserDynamic([
|
||||
{ provide: BOOTSTRAP_DATA, useValue: bootstrapData },
|
||||
]).bootstrapModule(module)
|
||||
if (process.env.TERMINUS_DEV) {
|
||||
const applicationRef = moduleRef.injector.get(ApplicationRef)
|
||||
const componentRef = applicationRef.components[0]
|
||||
@@ -54,12 +52,12 @@ async function bootstrap (plugins: PluginInfo[], bootstrapData: BootstrapData, s
|
||||
|
||||
ipcRenderer.once('start', async (_$event, bootstrapData: BootstrapData) => {
|
||||
console.log('Window bootstrap data:', bootstrapData)
|
||||
;(window as any).bootstrapData = bootstrapData
|
||||
|
||||
let plugins = await findPlugins()
|
||||
if (bootstrapData.config.pluginBlacklist) {
|
||||
plugins = plugins.filter(x => !bootstrapData.config.pluginBlacklist.includes(x.name))
|
||||
}
|
||||
plugins = plugins.filter(x => x.name !== 'web')
|
||||
console.log('Starting with plugins:', plugins)
|
||||
try {
|
||||
await bootstrap(plugins, bootstrapData)
|
||||
|
Reference in New Issue
Block a user