Switch to using start application from Feature (#7260)

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen authored and GitHub committed 2023-03-06 10:40:04 +02:00
1 parent a9bd5ae7e2
commit 129565f08a
79 files changed
+272 -339

No files matched your search

@@ -1,10 +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 { RunnableSync } from "../../../common/runnable/run-many-sync-for";
export const beforeElectronIsReadyInjectionToken = getInjectionToken<RunnableSync>({
id: "before-electron-is-ready",
});
@@ -1,28 +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 { Runnable } from "../../../common/runnable/run-many-for";
import type { RunnableSync } from "../../../common/runnable/run-many-sync-for";
/**
* These tokens are here so that the importing of their respective dependencies
* can be delayed until all of them are ready
*/
/**
* This runnable token should only have the app paths init so that it can be run by itself
*/
export const appPathsRunnablePhaseInjectionToken = getInjectionToken<RunnableSync>({
id: "app-paths-runnable-phase",
});
export const showLoadingRunnablePhaseInjectionToken = getInjectionToken<Runnable>({
id: "show-loading-runnable-phase",
});
export const showInitialWindowRunnablePhaseInjectionToken = getInjectionToken<Runnable>({
id: "show-initial-window-runnable-phase",
});
@@ -4,7 +4,7 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import emitAppEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
import { afterApplicationIsLoadedInjectionToken } from "../runnable-tokens/after-application-is-loaded-injection-token";
import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
const emitServiceStartToEventBusInjectable = getInjectable({
id: "emit-service-start-to-event-bus",
@@ -9,7 +9,7 @@ import loggerInjectable from "../../../common/logger.injectable";
import extensionDiscoveryInjectable from "../../../extensions/extension-discovery/extension-discovery.injectable";
import extensionLoaderInjectable from "../../../extensions/extension-loader/extension-loader.injectable";
import showErrorPopupInjectable from "../../electron-app/features/show-error-popup.injectable";
import { onLoadOfApplicationInjectionToken } from "../runnable-tokens/on-load-of-application-injection-token";
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
const initializeExtensionsInjectable = getInjectable({
id: "initialize-extensions",
@@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable";
import kubeconfigSyncManagerInjectable from "../../../catalog-sources/kubeconfig-sync/manager.injectable";
import catalogEntityRegistryInjectable from "../../../catalog/entity-registry.injectable";
import { afterApplicationIsLoadedInjectionToken } from "../../runnable-tokens/after-application-is-loaded-injection-token";
import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
const addKubeconfigSyncAsEntitySourceInjectable = getInjectable({
id: "add-kubeconfig-sync-as-entity-source",
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { afterApplicationIsLoadedInjectionToken } from "../../runnable-tokens/after-application-is-loaded-injection-token";
import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
import directoryForKubeConfigsInjectable from "../../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
import ensureDirInjectable from "../../../../common/fs/ensure-dir.injectable";
import kubeconfigSyncManagerInjectable from "../../../catalog-sources/kubeconfig-sync/manager.injectable";
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { beforeElectronIsReadyInjectionToken } from "../../runnable-tokens/before-electron-is-ready-injection-token";
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
import initializeSentryReportingWithInjectable from "../../../../common/error-reporting/initialize-sentry-reporting.injectable";
import initializeSentryOnMainInjectable from "./initialize-on-main.injectable";
@@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable";
import disableHardwareAccelerationInjectable from "../../electron-app/features/disable-hardware-acceleration.injectable";
import hardwareAccelerationShouldBeDisabledInjectable from "../../vars/hardware-acceleration-should-be-disabled.injectable";
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/before-electron-is-ready-injection-token";
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
const setupHardwareAccelerationInjectable = getInjectable({
id: "setup-hardware-acceleration",
@@ -4,7 +4,7 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import electronAppInjectable from "../../electron-app/electron-app.injectable";
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/before-electron-is-ready-injection-token";
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
const setupHostnamesInjectable = getInjectable({
id: "setup-hostnames",
@@ -4,7 +4,7 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import * as Immer from "immer";
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/before-electron-is-ready-injection-token";
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
const setupImmerInjectable = getInjectable({
id: "setup-immer",
@@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable";
import { generate } from "selfsigned";
import lensProxyCertificateInjectable from "../../../common/certificate/lens-proxy-certificate.injectable";
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/before-electron-is-ready-injection-token";
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
const setupLensProxyCertificateInjectable = getInjectable({
id: "setup-lens-proxy-certificate",
@@ -9,7 +9,7 @@ import loggerInjectable from "../../../common/logger.injectable";
import lensProxyPortInjectable from "../../lens-proxy/lens-proxy-port.injectable";
import isWindowsInjectable from "../../../common/vars/is-windows.injectable";
import showErrorPopupInjectable from "../../electron-app/features/show-error-popup.injectable";
import { beforeApplicationIsLoadingInjectionToken } from "../runnable-tokens/before-application-is-loading-injection-token";
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
import buildVersionInjectable from "../../vars/build-version/build-version.injectable";
import initializeBuildVersionInjectable from "../../vars/build-version/init.injectable";
import lensProxyCertificateInjectable from "../../../common/certificate/lens-proxy-certificate.injectable";
@@ -4,7 +4,7 @@
*/
import * as Mobx from "mobx";
import { getInjectable } from "@ogre-tools/injectable";
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/before-electron-is-ready-injection-token";
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
const setupMobxInjectable = getInjectable({
id: "setup-mobx",
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/before-electron-is-ready-injection-token";
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
import getCommandLineSwitchInjectable from "../../electron-app/features/get-command-line-switch.injectable";
const setupProxyEnvInjectable = getInjectable({
@@ -4,7 +4,7 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import syncGeneralCatalogEntitiesInjectable from "../../catalog-sources/sync-general-catalog-entities.injectable";
import { onLoadOfApplicationInjectionToken } from "../runnable-tokens/on-load-of-application-injection-token";
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
const setupSyncingOfGeneralCatalogEntitiesInjectable = getInjectable({
id: "setup-syncing-of-general-catalog-entities",
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { onLoadOfApplicationInjectionToken } from "../runnable-tokens/on-load-of-application-injection-token";
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
import syncWeblinksInjectable from "../../catalog-sources/sync-weblinks.injectable";
const setupSyncingOfWeblinksInjectable = getInjectable({
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { beforeApplicationIsLoadingInjectionToken } from "../runnable-tokens/before-application-is-loading-injection-token";
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
import injectSystemCAsInjectable from "../../../features/certificate-authorities/common/inject-system-cas.injectable";
const setupSystemCaInjectable = getInjectable({
@@ -8,7 +8,7 @@ import openDeepLinkInjectable from "../../protocol-handler/lens-protocol-router-
import commandLineArgumentsInjectable from "../../utils/command-line-arguments.injectable";
import createFirstApplicationWindowInjectable from "../lens-window/application-window/create-first-application-window.injectable";
import splashWindowInjectable from "../lens-window/splash-window/splash-window.injectable";
import { showInitialWindowRunnablePhaseInjectionToken } from "../runnable-tokens/phases";
import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
const getDeepLinkUrl = (commandLineArguments: string[]) => (
commandLineArguments
@@ -45,7 +45,7 @@ const showInitialWindowInjectable = getInjectable({
},
};
},
injectionToken: showInitialWindowRunnablePhaseInjectionToken,
injectionToken: afterApplicationIsLoadedInjectionToken,
});
export default showInitialWindowInjectable;
@@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable";
import shouldStartHiddenInjectable from "../../electron-app/features/should-start-hidden.injectable";
import splashWindowInjectable from "../lens-window/splash-window/splash-window.injectable";
import { showLoadingRunnablePhaseInjectionToken } from "../runnable-tokens/phases";
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
const showLoadingInjectable = getInjectable({
id: "show-loading",
@@ -23,7 +23,7 @@ const showLoadingInjectable = getInjectable({
},
};
},
injectionToken: showLoadingRunnablePhaseInjectionToken,
injectionToken: onLoadOfApplicationInjectionToken,
});
export default showLoadingInjectable;
@@ -1,50 +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 { runManyFor } from "../../common/runnable/run-many-for";
import { runManySyncFor } from "../../common/runnable/run-many-sync-for";
import { beforeElectronIsReadyInjectionToken } from "./runnable-tokens/before-electron-is-ready-injection-token";
import { beforeApplicationIsLoadingInjectionToken } from "./runnable-tokens/before-application-is-loading-injection-token";
import { onLoadOfApplicationInjectionToken } from "./runnable-tokens/on-load-of-application-injection-token";
import { afterApplicationIsLoadedInjectionToken } from "./runnable-tokens/after-application-is-loaded-injection-token";
import waitForElectronToBeReadyInjectable from "../electron-app/features/wait-for-electron-to-be-ready.injectable";
import { appPathsRunnablePhaseInjectionToken, showInitialWindowRunnablePhaseInjectionToken, showLoadingRunnablePhaseInjectionToken } from "./runnable-tokens/phases";
const startMainApplicationInjectable = getInjectable({
id: "start-main-application",
instantiate: (di) => {
const runMany = runManyFor(di);
const runManySync = runManySyncFor(di);
const waitForElectronToBeReady = di.inject(waitForElectronToBeReadyInjectable);
const appPathsRunnablePhase = runManySync(appPathsRunnablePhaseInjectionToken);
const beforeElectronIsReady = runManySync(beforeElectronIsReadyInjectionToken);
const beforeApplicationIsLoading = runMany(beforeApplicationIsLoadingInjectionToken);
const showLoadingRunnablePhase = runMany(showLoadingRunnablePhaseInjectionToken);
const onLoadOfApplication = runMany(onLoadOfApplicationInjectionToken);
const showInitialWindowRunnablePhase = runMany(showInitialWindowRunnablePhaseInjectionToken);
const afterApplicationIsLoaded = runMany(afterApplicationIsLoadedInjectionToken);
return () => {
// Stuff happening before application is ready needs to be synchronous because of
// https://github.com/electron/electron/issues/21370
appPathsRunnablePhase();
beforeElectronIsReady();
return (async () => {
await waitForElectronToBeReady();
await beforeApplicationIsLoading();
await showLoadingRunnablePhase();
await onLoadOfApplication();
await showInitialWindowRunnablePhase();
await afterApplicationIsLoaded();
})();
};
},
});
export default startMainApplicationInjectable;