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 extensionLoaderInjectable from "../extensions/extension-loader/extension-loader.injectable";
|
||||||
import extensionDiscoveryInjectable from "../extensions/extension-discovery/extension-discovery.injectable";
|
import extensionDiscoveryInjectable from "../extensions/extension-discovery/extension-discovery.injectable";
|
||||||
import extensionInstallationStateStoreInjectable from "../extensions/extension-installation-state-store/extension-installation-state-store.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 { Router } from "react-router";
|
||||||
import historyInjectable from "./navigation/history.injectable";
|
import historyInjectable from "./navigation/history.injectable";
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
import startFrameInjectable from "./start-frame/start-frame.injectable";
|
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) {
|
export async function bootstrap(di: DiContainer) {
|
||||||
const startFrame = di.inject(startFrameInjectable);
|
const startFrame = di.inject(startFrameInjectable);
|
||||||
@ -41,8 +41,17 @@ export async function bootstrap(di: DiContainer) {
|
|||||||
|
|
||||||
extensionInstallationStateStore.bindIpcListeners();
|
extensionInstallationStateStore.bindIpcListeners();
|
||||||
|
|
||||||
const App = di.inject(rootComponentInjectable);
|
let App;
|
||||||
const initializeApp = di.inject(initializeAppInjectable);
|
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 {
|
try {
|
||||||
await initializeApp(() => unmountComponentAtNode(rootElem));
|
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 catalogEntityRegistryInjectable from "../../../api/catalog/entity/registry.injectable";
|
||||||
import frameRoutingIdInjectable from "./frame-routing-id/frame-routing-id.injectable";
|
import frameRoutingIdInjectable from "./frame-routing-id/frame-routing-id.injectable";
|
||||||
import hostedClusterInjectable from "../../../cluster-frame-context/hosted-cluster.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 emitAppEventInjectable from "../../../../common/app-event-bus/emit-event.injectable";
|
||||||
import loadExtensionsInjectable from "../../load-extensions.injectable";
|
import loadExtensionsInjectable from "../../load-extensions.injectable";
|
||||||
import loggerInjectable from "../../../../common/logger.injectable";
|
import loggerInjectable from "../../../../common/logger.injectable";
|
||||||
import showErrorNotificationInjectable from "../../../components/notifications/show-error-notification.injectable";
|
import showErrorNotificationInjectable from "../../../components/notifications/show-error-notification.injectable";
|
||||||
import { initializeAppInjectionToken } from "../../../bootstrap/tokens";
|
|
||||||
|
|
||||||
const initClusterFrameInjectable = getInjectable({
|
const initClusterFrameInjectable = getInjectable({
|
||||||
id: "init-cluster-frame",
|
id: "init-cluster-frame",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
init: initClusterFrame({
|
const hostedCluster = di.inject(hostedClusterInjectable);
|
||||||
hostedCluster: di.inject(hostedClusterInjectable),
|
|
||||||
|
assert(hostedCluster, "This can only be injected within a cluster frame");
|
||||||
|
|
||||||
|
return initClusterFrame({
|
||||||
|
hostedCluster,
|
||||||
loadExtensions: di.inject(loadExtensionsInjectable),
|
loadExtensions: di.inject(loadExtensionsInjectable),
|
||||||
catalogEntityRegistry: di.inject(catalogEntityRegistryInjectable),
|
catalogEntityRegistry: di.inject(catalogEntityRegistryInjectable),
|
||||||
frameRoutingId: di.inject(frameRoutingIdInjectable),
|
frameRoutingId: di.inject(frameRoutingIdInjectable),
|
||||||
emitAppEvent: di.inject(emitAppEventInjectable),
|
emitAppEvent: di.inject(emitAppEventInjectable),
|
||||||
logger: di.inject(loggerInjectable),
|
logger: di.inject(loggerInjectable),
|
||||||
showErrorNotification: di.inject(showErrorNotificationInjectable),
|
showErrorNotification: di.inject(showErrorNotificationInjectable),
|
||||||
}),
|
});
|
||||||
isActive: !process.isMainFrame,
|
},
|
||||||
}),
|
|
||||||
injectionToken: initializeAppInjectionToken,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default initClusterFrameInjectable;
|
export default initClusterFrameInjectable;
|
||||||
|
|||||||
@ -9,10 +9,9 @@ import { when } from "mobx";
|
|||||||
import { requestSetClusterFrameId } from "../../../ipc";
|
import { requestSetClusterFrameId } from "../../../ipc";
|
||||||
import type { EmitAppEvent } from "../../../../common/app-event-bus/emit-event.injectable";
|
import type { EmitAppEvent } from "../../../../common/app-event-bus/emit-event.injectable";
|
||||||
import type { Logger } from "../../../../common/logger";
|
import type { Logger } from "../../../../common/logger";
|
||||||
import assert from "assert";
|
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
hostedCluster: Cluster | undefined;
|
hostedCluster: Cluster;
|
||||||
loadExtensions: () => void;
|
loadExtensions: () => void;
|
||||||
catalogEntityRegistry: CatalogEntityRegistry;
|
catalogEntityRegistry: CatalogEntityRegistry;
|
||||||
frameRoutingId: number;
|
frameRoutingId: number;
|
||||||
@ -33,8 +32,6 @@ export const initClusterFrame = ({
|
|||||||
showErrorNotification,
|
showErrorNotification,
|
||||||
}: Dependencies) =>
|
}: Dependencies) =>
|
||||||
async (unmountRoot: () => void) => {
|
async (unmountRoot: () => void) => {
|
||||||
assert(hostedCluster, "This can only be injected within a cluster frame");
|
|
||||||
|
|
||||||
// TODO: Make catalogEntityRegistry already initialized when passed as dependency
|
// TODO: Make catalogEntityRegistry already initialized when passed as dependency
|
||||||
catalogEntityRegistry.init();
|
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 { delay } from "../../../common/utils";
|
||||||
import { broadcastMessage } from "../../../common/ipc";
|
import { broadcastMessage } from "../../../common/ipc";
|
||||||
import { bundledExtensionsLoaded } from "../../../common/ipc/extension-handling";
|
import { bundledExtensionsLoaded } from "../../../common/ipc/extension-handling";
|
||||||
import { initializeAppInjectionToken } from "../../bootstrap/tokens";
|
|
||||||
|
|
||||||
const initRootFrameInjectable = getInjectable({
|
const initRootFrameInjectable = getInjectable({
|
||||||
id: "init-root-frame",
|
id: "init-root-frame",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
init: async (unmountRoot: () => void) => {
|
|
||||||
const loadExtensions = di.inject(loadExtensionsInjectable);
|
const loadExtensions = di.inject(loadExtensionsInjectable);
|
||||||
const registerIpcListeners = di.inject(registerIpcListenersInjectable);
|
const registerIpcListeners = di.inject(registerIpcListenersInjectable);
|
||||||
const ipcRenderer = di.inject(ipcRendererInjectable);
|
const ipcRenderer = di.inject(ipcRendererInjectable);
|
||||||
@ -27,6 +25,7 @@ const initRootFrameInjectable = getInjectable({
|
|||||||
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
|
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
|
|
||||||
|
return async (unmountRoot: () => void) => {
|
||||||
catalogEntityRegistry.init();
|
catalogEntityRegistry.init();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -50,7 +49,8 @@ const initRootFrameInjectable = getInjectable({
|
|||||||
|
|
||||||
bindProtocolAddRouteHandlers();
|
bindProtocolAddRouteHandlers();
|
||||||
|
|
||||||
window.addEventListener("offline", () => broadcastMessage("network:offline"),
|
window.addEventListener("offline", () =>
|
||||||
|
broadcastMessage("network:offline"),
|
||||||
);
|
);
|
||||||
|
|
||||||
window.addEventListener("online", () => broadcastMessage("network:online"));
|
window.addEventListener("online", () => broadcastMessage("network:online"));
|
||||||
@ -62,10 +62,8 @@ const initRootFrameInjectable = getInjectable({
|
|||||||
|
|
||||||
unmountRoot();
|
unmountRoot();
|
||||||
});
|
});
|
||||||
|
};
|
||||||
},
|
},
|
||||||
isActive: process.isMainFrame,
|
|
||||||
}),
|
|
||||||
injectionToken: initializeAppInjectionToken,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default initRootFrameInjectable;
|
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",
|
type: "commonjs2",
|
||||||
},
|
},
|
||||||
path: path.resolve(buildDir, "library"),
|
path: path.resolve(buildDir, "library"),
|
||||||
|
asyncChunks: false,
|
||||||
},
|
},
|
||||||
watchOptions: {
|
watchOptions: {
|
||||||
ignored: /node_modules/, // https://webpack.js.org/configuration/watch/
|
ignored: /node_modules/, // https://webpack.js.org/configuration/watch/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user