mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Make Inject-component usable in both LensApp and "App"
Note: this will need some rehaul, as current design with "bootstrap" and iframe make single root for injectables somewhat challenging. Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
c4c4bc5845
commit
3bc01dc50f
2 files changed
+54
-47
No files matched your search
@@ -50,6 +50,9 @@ import { SentryInit } from "../common/sentry";
|
||||
import { TerminalStore } from "./components/dock/terminal.store";
|
||||
import { AppPaths } from "../common/app-paths";
|
||||
import { registerCustomThemes } from "./components/monaco-editor";
|
||||
import { getDi } from "./components/getDi";
|
||||
import { DiContextProvider } from "@ogre-tools/injectable-react";
|
||||
import type { IDependencyInjectionContainer } from "@ogre-tools/injectable";
|
||||
|
||||
if (process.isMainFrame) {
|
||||
SentryInit();
|
||||
@@ -73,7 +76,7 @@ type AppComponent = React.ComponentType & {
|
||||
init(rootElem: HTMLElement): Promise<void>;
|
||||
};
|
||||
|
||||
export async function bootstrap(comp: () => Promise<AppComponent>) {
|
||||
export async function bootstrap(comp: () => Promise<AppComponent>, di: IDependencyInjectionContainer) {
|
||||
const rootElem = document.getElementById("app");
|
||||
const logPrefix = `[BOOTSTRAP-${process.isMainFrame ? "ROOT" : "CLUSTER"}-FRAME]:`;
|
||||
|
||||
@@ -147,17 +150,26 @@ export async function bootstrap(comp: () => Promise<AppComponent>) {
|
||||
|
||||
await App.init(rootElem);
|
||||
|
||||
render(<>
|
||||
{isMac && <div id="draggable-top" />}
|
||||
{DefaultProps(App)}
|
||||
</>, rootElem);
|
||||
render(
|
||||
<DiContextProvider value={{ di }}>
|
||||
{isMac && <div id="draggable-top" />}
|
||||
|
||||
{DefaultProps(App)}
|
||||
</DiContextProvider>,
|
||||
|
||||
rootElem,
|
||||
);
|
||||
}
|
||||
|
||||
const di = getDi();
|
||||
|
||||
// run
|
||||
bootstrap(
|
||||
async () => process.isMainFrame
|
||||
? (await import("./root-frame")).RootFrame
|
||||
: (await import("./cluster-frame")).ClusterFrame,
|
||||
async () =>
|
||||
process.isMainFrame
|
||||
? (await import("./root-frame")).RootFrame
|
||||
: (await import("./cluster-frame")).ClusterFrame,
|
||||
di,
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user