mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Renderer file logging transport Add file logging to renderer, writing separate log files for renderer main frame and each cluster frame. Related to lensapp/support-lens-extension#118 Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com> * Switch renderer file log level to info There is too much noise on debug level from api responses etc Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com> * Unmount on pagehide instead of beforeunload It seems cluster onbeforeunload is not triggered when iframe is removed from dom by the parent (when disconnecting a cluster). While on root/main frame the beforeunload event does work, it seems to be adviced to use pagehide instead. Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com> * Close log files on unmount Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com> * Improve file handle closing in different situations This should cover reloading main and cluster frames and closing cluster frame throught disconnecting cluster. No file handles should be left open now. Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com> * Fix renderer log rotation Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com> * Switch back to beforeunload in root frame Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com> * Remove capturing phase event usage Does not seem to be needed for log files to be successfully closed and caused integration tests to fail. Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com> --------- Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com>
78 lines
2.6 KiB
TypeScript
78 lines
2.6 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
|
|
import "./components/app.scss";
|
|
|
|
import React from "react";
|
|
import { render, unmountComponentAtNode } from "react-dom";
|
|
import { DefaultProps } from "./mui-base-theme";
|
|
import { DiContextProvider } from "@ogre-tools/injectable-react";
|
|
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";
|
|
|
|
export async function bootstrap(di: DiContainer) {
|
|
const startFrame = di.inject(startFrameInjectable);
|
|
|
|
await startFrame();
|
|
|
|
const rootElem = document.getElementById("app");
|
|
|
|
assert(rootElem, "#app MUST exist");
|
|
|
|
const extensionLoader = di.inject(extensionLoaderInjectable);
|
|
|
|
extensionLoader.init();
|
|
|
|
const extensionDiscovery = di.inject(extensionDiscoveryInjectable);
|
|
|
|
extensionDiscovery.init();
|
|
|
|
const extensionInstallationStateStore = di.inject(extensionInstallationStateStoreInjectable);
|
|
|
|
extensionInstallationStateStore.bindIpcListeners();
|
|
|
|
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);
|
|
});
|
|
} catch (error) {
|
|
console.error(`[BOOTSTRAP]: view initialization error: ${error}`, {
|
|
origin: location.href,
|
|
isTopFrameView: process.isMainFrame,
|
|
});
|
|
}
|
|
|
|
const history = di.inject(historyInjectable);
|
|
|
|
render(
|
|
<DiContextProvider value={{ di }}>
|
|
<Router history={history}>
|
|
{DefaultProps(App)}
|
|
</Router>
|
|
</DiContextProvider>,
|
|
rootElem,
|
|
);
|
|
}
|