mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-24 23:05:29 +08:00
Co-authored-by: mr-anton-t <42037741+mr-anton-t@users.noreply.github.com>
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
/*
|
|
* CloudBeaver - Cloud Database Manager
|
|
* Copyright (C) 2020-2025 DBeaver Corp and others
|
|
*
|
|
* Licensed under the Apache License, Version 2.0.
|
|
* you may not use this file except in compliance with the License.
|
|
*/
|
|
import { configure } from 'mobx';
|
|
|
|
import { App, type IModule } from '@cloudbeaver/core-di';
|
|
import { executionExceptionContext, SyncExecutor } from '@cloudbeaver/core-executor';
|
|
|
|
export async function bootstrap(modules: IModule[]): Promise<App> {
|
|
configure({ enforceActions: 'never' });
|
|
|
|
const app = new App(modules);
|
|
(window as any).internalRestartApp = () => app.restart();
|
|
let exception: Error | null = null;
|
|
|
|
try {
|
|
await app.start();
|
|
} catch (e: any) {
|
|
exception = e;
|
|
}
|
|
|
|
const { renderLayout } = await import('./renderLayout.js');
|
|
const render = renderLayout(app);
|
|
const unmountExecutor = new SyncExecutor();
|
|
|
|
unmountExecutor.addHandler(() => render.unmount());
|
|
app.onStart.before(unmountExecutor, undefined, data => data.preload);
|
|
app.onStart.addHandler(({ preload }) => {
|
|
if (!preload) {
|
|
render.renderApp(app.getServiceProvider());
|
|
}
|
|
});
|
|
app.onStart.addPostHandler((_, context) => {
|
|
const exception = context.getContext(executionExceptionContext);
|
|
|
|
if (exception.exception) {
|
|
render.renderError(app.getServiceProvider(), exception.exception);
|
|
}
|
|
});
|
|
|
|
if (exception) {
|
|
render.renderError(app.getServiceProvider(), exception);
|
|
} else {
|
|
render.renderApp(app.getServiceProvider());
|
|
}
|
|
|
|
return app;
|
|
}
|