mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Revert src/ changes in favour of asyncChunks:false
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
7f50302cb3
commit
115fe4f203
@ -13,12 +13,12 @@ import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import extensionLoaderInjectable from "../extensions/extension-loader/extension-loader.injectable";
|
||||
import extensionDiscoveryInjectable from "../extensions/extension-discovery/extension-discovery.injectable";
|
||||
import extensionInstallationStateStoreInjectable from "../extensions/extension-installation-state-store/extension-installation-state-store.injectable";
|
||||
import initRootFrameInjectable from "./frames/root-frame/init-root-frame.injectable";
|
||||
import initClusterFrameInjectable from "./frames/cluster-frame/init-cluster-frame/init-cluster-frame.injectable";
|
||||
import { Router } from "react-router";
|
||||
import historyInjectable from "./navigation/history.injectable";
|
||||
import assert from "assert";
|
||||
import startFrameInjectable from "./start-frame/start-frame.injectable";
|
||||
import rootComponentInjectable from "./bootstrap/root-component.injectable";
|
||||
import initializeAppInjectable from "./bootstrap/initialize-app.injectable";
|
||||
|
||||
export async function bootstrap(di: DiContainer) {
|
||||
const startFrame = di.inject(startFrameInjectable);
|
||||
@ -41,8 +41,17 @@ export async function bootstrap(di: DiContainer) {
|
||||
|
||||
extensionInstallationStateStore.bindIpcListeners();
|
||||
|
||||
const App = di.inject(rootComponentInjectable);
|
||||
const initializeApp = di.inject(initializeAppInjectable);
|
||||
let App;
|
||||
let initializeApp;
|
||||
|
||||
// TODO: Introduce proper architectural boundaries between root and cluster iframes
|
||||
if (process.isMainFrame) {
|
||||
initializeApp = di.inject(initRootFrameInjectable);
|
||||
App = (await import("./frames/root-frame/root-frame")).RootFrame;
|
||||
} else {
|
||||
initializeApp = di.inject(initClusterFrameInjectable);
|
||||
App = (await import("./frames/cluster-frame/cluster-frame")).ClusterFrame;
|
||||
}
|
||||
|
||||
try {
|
||||
await initializeApp(() => unmountComponentAtNode(rootElem));
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { initializeAppInjectionToken } from "./tokens";
|
||||
|
||||
const initializeAppInjectable = getInjectable({
|
||||
id: "initialize-app",
|
||||
instantiate: (di) => {
|
||||
const options = di.injectMany(initializeAppInjectionToken);
|
||||
|
||||
if (options.length === 0) {
|
||||
throw new Error("No intializeApp registered");
|
||||
}
|
||||
|
||||
const intializeApp = options.find(opt => opt.isActive);
|
||||
const howManyActive = options.reduce((count, cur) => count + +cur.isActive, 0);
|
||||
|
||||
if (!intializeApp) {
|
||||
throw new Error("No initializeApp registrations are active");
|
||||
}
|
||||
|
||||
if (howManyActive > 1) {
|
||||
throw new Error("Too many initiazlizeApp registrations are active");
|
||||
}
|
||||
|
||||
return intializeApp.init;
|
||||
},
|
||||
});
|
||||
|
||||
export default initializeAppInjectable;
|
||||
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { rootComponentInjectionToken } from "./tokens";
|
||||
|
||||
const rootComponentInjectable = getInjectable({
|
||||
id: "root-component",
|
||||
instantiate: (di) => {
|
||||
const options = di.injectMany(rootComponentInjectionToken);
|
||||
|
||||
if (options.length === 0) {
|
||||
throw new Error("No intializeApp registered");
|
||||
}
|
||||
|
||||
const intializeApp = options.find(opt => opt.isActive);
|
||||
const howManyActive = options.reduce((count, cur) => count + +cur.isActive, 0);
|
||||
|
||||
if (!intializeApp) {
|
||||
throw new Error("No initializeApp registrations are active");
|
||||
}
|
||||
|
||||
if (howManyActive > 1) {
|
||||
throw new Error("Too many initiazlizeApp registrations are active");
|
||||
}
|
||||
|
||||
return intializeApp.Component;
|
||||
},
|
||||
});
|
||||
|
||||
export default rootComponentInjectable;
|
||||
@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { FunctionComponent } from "react";
|
||||
|
||||
export interface InitializeApp {
|
||||
init: (unmountRoot: () => void) => Promise<void>;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
export const initializeAppInjectionToken = getInjectionToken<InitializeApp>({
|
||||
id: "initialize-app-token",
|
||||
});
|
||||
|
||||
export interface RootComponent {
|
||||
Component: FunctionComponent<{}>;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
export const rootComponentInjectionToken = getInjectionToken<RootComponent>({
|
||||
id: "root-component-token",
|
||||
});
|
||||
@ -7,28 +7,30 @@ import { initClusterFrame } from "./init-cluster-frame";
|
||||
import catalogEntityRegistryInjectable from "../../../api/catalog/entity/registry.injectable";
|
||||
import frameRoutingIdInjectable from "./frame-routing-id/frame-routing-id.injectable";
|
||||
import hostedClusterInjectable from "../../../cluster-frame-context/hosted-cluster.injectable";
|
||||
import assert from "assert";
|
||||
import emitAppEventInjectable from "../../../../common/app-event-bus/emit-event.injectable";
|
||||
import loadExtensionsInjectable from "../../load-extensions.injectable";
|
||||
import loggerInjectable from "../../../../common/logger.injectable";
|
||||
import showErrorNotificationInjectable from "../../../components/notifications/show-error-notification.injectable";
|
||||
import { initializeAppInjectionToken } from "../../../bootstrap/tokens";
|
||||
|
||||
const initClusterFrameInjectable = getInjectable({
|
||||
id: "init-cluster-frame",
|
||||
|
||||
instantiate: (di) => ({
|
||||
init: initClusterFrame({
|
||||
hostedCluster: di.inject(hostedClusterInjectable),
|
||||
instantiate: (di) => {
|
||||
const hostedCluster = di.inject(hostedClusterInjectable);
|
||||
|
||||
assert(hostedCluster, "This can only be injected within a cluster frame");
|
||||
|
||||
return initClusterFrame({
|
||||
hostedCluster,
|
||||
loadExtensions: di.inject(loadExtensionsInjectable),
|
||||
catalogEntityRegistry: di.inject(catalogEntityRegistryInjectable),
|
||||
frameRoutingId: di.inject(frameRoutingIdInjectable),
|
||||
emitAppEvent: di.inject(emitAppEventInjectable),
|
||||
logger: di.inject(loggerInjectable),
|
||||
showErrorNotification: di.inject(showErrorNotificationInjectable),
|
||||
}),
|
||||
isActive: !process.isMainFrame,
|
||||
}),
|
||||
injectionToken: initializeAppInjectionToken,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default initClusterFrameInjectable;
|
||||
|
||||
@ -9,10 +9,9 @@ import { when } from "mobx";
|
||||
import { requestSetClusterFrameId } from "../../../ipc";
|
||||
import type { EmitAppEvent } from "../../../../common/app-event-bus/emit-event.injectable";
|
||||
import type { Logger } from "../../../../common/logger";
|
||||
import assert from "assert";
|
||||
|
||||
interface Dependencies {
|
||||
hostedCluster: Cluster | undefined;
|
||||
hostedCluster: Cluster;
|
||||
loadExtensions: () => void;
|
||||
catalogEntityRegistry: CatalogEntityRegistry;
|
||||
frameRoutingId: number;
|
||||
@ -33,8 +32,6 @@ export const initClusterFrame = ({
|
||||
showErrorNotification,
|
||||
}: Dependencies) =>
|
||||
async (unmountRoot: () => void) => {
|
||||
assert(hostedCluster, "This can only be injected within a cluster frame");
|
||||
|
||||
// TODO: Make catalogEntityRegistry already initialized when passed as dependency
|
||||
catalogEntityRegistry.init();
|
||||
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { rootComponentInjectionToken } from "../../bootstrap/tokens";
|
||||
import { ClusterFrame } from "./cluster-frame";
|
||||
|
||||
const clusterFrameRootComponentInjectable = getInjectable({
|
||||
id: "cluster-frame-root-component",
|
||||
instantiate: () => ({
|
||||
Component: ClusterFrame,
|
||||
isActive: !process.isMainFrame,
|
||||
}),
|
||||
injectionToken: rootComponentInjectionToken,
|
||||
});
|
||||
|
||||
export default clusterFrameRootComponentInjectable;
|
||||
@ -13,12 +13,10 @@ import loggerInjectable from "../../../common/logger.injectable";
|
||||
import { delay } from "../../../common/utils";
|
||||
import { broadcastMessage } from "../../../common/ipc";
|
||||
import { bundledExtensionsLoaded } from "../../../common/ipc/extension-handling";
|
||||
import { initializeAppInjectionToken } from "../../bootstrap/tokens";
|
||||
|
||||
const initRootFrameInjectable = getInjectable({
|
||||
id: "init-root-frame",
|
||||
instantiate: (di) => ({
|
||||
init: async (unmountRoot: () => void) => {
|
||||
instantiate: (di) => {
|
||||
const loadExtensions = di.inject(loadExtensionsInjectable);
|
||||
const registerIpcListeners = di.inject(registerIpcListenersInjectable);
|
||||
const ipcRenderer = di.inject(ipcRendererInjectable);
|
||||
@ -27,6 +25,7 @@ const initRootFrameInjectable = getInjectable({
|
||||
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
|
||||
const logger = di.inject(loggerInjectable);
|
||||
|
||||
return async (unmountRoot: () => void) => {
|
||||
catalogEntityRegistry.init();
|
||||
|
||||
try {
|
||||
@ -50,7 +49,8 @@ const initRootFrameInjectable = getInjectable({
|
||||
|
||||
bindProtocolAddRouteHandlers();
|
||||
|
||||
window.addEventListener("offline", () => broadcastMessage("network:offline"),
|
||||
window.addEventListener("offline", () =>
|
||||
broadcastMessage("network:offline"),
|
||||
);
|
||||
|
||||
window.addEventListener("online", () => broadcastMessage("network:online"));
|
||||
@ -62,10 +62,8 @@ const initRootFrameInjectable = getInjectable({
|
||||
|
||||
unmountRoot();
|
||||
});
|
||||
};
|
||||
},
|
||||
isActive: process.isMainFrame,
|
||||
}),
|
||||
injectionToken: initializeAppInjectionToken,
|
||||
});
|
||||
|
||||
export default initRootFrameInjectable;
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { rootComponentInjectionToken } from "../../bootstrap/tokens";
|
||||
import { RootFrame } from "./root-frame";
|
||||
|
||||
const rootFrameRootComponentInjectable = getInjectable({
|
||||
id: "root-frame-root-component",
|
||||
instantiate: () => ({
|
||||
Component: RootFrame,
|
||||
isActive: process.isMainFrame,
|
||||
}),
|
||||
injectionToken: rootComponentInjectionToken,
|
||||
});
|
||||
|
||||
export default rootFrameRootComponentInjectable;
|
||||
@ -38,6 +38,7 @@ export const webpackLensRenderer = (): webpack.Configuration => ({
|
||||
type: "commonjs2",
|
||||
},
|
||||
path: path.resolve(buildDir, "library"),
|
||||
asyncChunks: false,
|
||||
},
|
||||
watchOptions: {
|
||||
ignored: /node_modules/, // https://webpack.js.org/configuration/watch/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user