From d12f59a6a4f72ce83490f7ee056156343c718439 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 27 Feb 2023 15:58:32 -0500 Subject: [PATCH] Fixup type errors due to new Runnable requirements Signed-off-by: Sebastian Malton --- .../kube-api-version-detection.test.ts | 8 +- .../main/start-application-menu.injectable.ts | 19 ++-- .../main/stop-application-menu.injectable.ts | 17 +-- .../start-checking-for-updates.injectable.ts | 23 ++-- .../stop-checking-for-updates.injectable.ts | 23 ++-- ...current-version-to-analytics.injectable.ts | 33 +++--- ...update-should-happen-on-quit.injectable.ts | 17 ++- ...update-should-happen-on-quit.injectable.ts | 17 +-- .../state-sync/main/setup-sync.injectable.ts | 5 +- .../renderer/setup-sync.injectable.ts | 7 +- .../cluster/store/main/init.injectable.ts | 19 ++-- .../cluster/store/renderer/init.injectable.ts | 3 +- .../main/init-store.injectable.ts | 3 +- .../renderer/init-store.injectable.ts | 1 - .../hotbar/store/main/init.injectable.ts | 19 ++-- .../hotbar/store/renderer/init.injectable.ts | 3 +- .../shell-sync/main/setup-shell.injectable.ts | 83 +++++++------- .../fonts/preload-fonts.injectable.ts | 1 - .../main/setup-update-emitter.injectable.ts | 31 +++-- .../renderer/initialize.injectable.ts | 3 +- .../app-paths/setup-app-paths.injectable.ts | 49 ++++---- .../start-catalog-sync.injectable.ts | 21 ++-- .../stop-catalog-sync.injectable.ts | 23 ++-- .../cluster/initialize-manager.injectable.ts | 17 ++- .../clean-up-deep-linking.injectable.ts | 17 +-- ...-dock-for-last-closed-window.injectable.ts | 28 ++--- ...dock-for-first-opened-window.injectable.ts | 17 ++- ...-single-application-instance.injectable.ts | 25 ++-- .../setup-application-name.injectable.ts | 21 ++-- .../setup-deep-linking.injectable.ts | 85 +++++++------- ...s-in-development-environment.injectable.ts | 51 +++++---- .../setup-device-shutdown.injectable.ts | 21 ++-- .../setup-ipc-main-handlers.injectable.ts | 41 ++++--- ...-visibility-after-activation.injectable.ts | 31 +++-- ...ables-after-window-is-opened.injectable.ts | 26 ++--- ...efore-closing-of-application.injectable.ts | 58 +++++----- packages/core/src/main/library.ts | 10 +- .../get-visible-windows.injectable.ts | 15 +-- ...r-application-is-loaded-injection-token.ts | 10 -- ...ter-root-frame-is-ready-injection-token.ts | 10 -- .../after-window-is-opened-injection-token.ts | 10 -- ...-application-is-loading-injection-token.ts | 10 -- ...efore-electron-is-ready-injection-token.ts | 10 -- ...before-quit-of-back-end-injection-token.ts | 10 -- ...efore-quit-of-front-end-injection-token.ts | 10 -- .../on-load-of-application-injection-token.ts | 10 -- .../runnable-tokens/phases.ts | 35 +++++- .../clean-up-shell-sessions.injectable.ts | 3 +- .../emit-close-to-event-bus.injectable.ts | 19 ++-- ...t-service-start-to-event-bus.injectable.ts | 17 ++- .../flag-renderer-as-loaded.injectable.ts | 23 ++-- .../flag-renderer-as-not-loaded.injectable.ts | 25 ++-- .../initialize-extensions.injectable.ts | 71 ++++++------ .../kube-config-sync/add-source.injectable.ts | 19 ++-- .../start-kube-config-sync.injectable.ts | 25 ++-- .../stop-kube-config-sync.injectable.ts | 17 +-- .../channel-listener.injectable.ts | 2 +- .../runnables/sentry/setup.injectable.ts | 19 ++-- .../setup-hardware-acceleration.injectable.ts | 25 ++-- .../runnables/setup-hostnames.injectable.ts | 27 ++--- .../runnables/setup-immer.injectable.ts | 9 +- ...setup-lens-proxy-certificate.injectable.ts | 65 +++++------ .../runnables/setup-lens-proxy.injectable.ts | 107 +++++++++--------- .../runnables/setup-mobx.injectable.ts | 3 +- .../runnables/setup-proxy-env.injectable.ts | 45 ++++---- ...-of-general-catalog-entities.injectable.ts | 19 ++-- .../setup-syncing-of-weblinks.injectable.ts | 17 ++- .../runnables/setup-system-ca.injectable.ts | 9 +- .../show-initial-window.injectable.ts | 43 ++++--- .../runnables/show-loading.injectable.ts | 24 ++-- .../stop-cluster-manager.injectable.ts | 19 ++-- .../start-main-application.injectable.ts | 20 ++-- .../main/stores/init-user-store.injectable.ts | 23 ++-- ...-theme-from-operating-system.injectable.ts | 17 ++- ...-theme-from-operating-system.injectable.ts | 17 +-- .../electron-tray/start-tray.injectable.ts | 17 ++- .../electron-tray/stop-tray.injectable.ts | 19 ++-- .../menu-icon/start-reactivity.injectable.ts | 19 ++-- .../menu-icon/stop-reactivity.injectable.ts | 17 +-- ...art-reactive-tray-menu-items.injectable.ts | 20 ++-- ...top-reactive-tray-menu-items.injectable.ts | 17 +-- .../sync-open-at-login-with-os.injectable.ts | 33 +++--- .../start-listening-on-channels.injectable.ts | 21 ++-- .../vars/build-version/init.injectable.ts | 15 ++- .../default-update-channel/init.injectable.ts | 17 ++- .../vars/release-channel/init.injectable.ts | 17 ++- .../semantic-build-version/init.injectable.ts | 13 ++- .../app-paths/setup-app-paths.injectable.ts | 1 - .../runnables/configure-immer.injectable.ts | 1 - .../runnables/configure-mobx.injectable.ts | 1 - .../load-monaco-themes.injectable.ts | 1 - .../setup-auto-registration.injectable.ts | 1 - ...up-current-cluster-broadcast.injectable.ts | 1 - ...tes-cluster-catalog-add-menu.injectable.ts | 1 - ...es-cluster-context-menu-open.injectable.ts | 1 - ...setup-lens-proxy-certificate.injectable.ts | 1 - .../setup-root-mac-class.injectable.ts | 1 - .../runnables/setup-sentry.injectable.ts | 1 - ...p-weblink-context-menu-open.injectable.tsx | 7 +- .../renderer/before-frame-starts/tokens.ts | 2 +- .../top-bar/start-state-sync.injectable.ts | 1 - .../root-frame/setup-system-ca.injectable.ts | 7 +- ...setup-logging-for-navigation.injectable.ts | 1 - .../stores/init-user-store.injectable.ts | 4 +- .../setup-apply-active-theme.injectable.ts | 5 +- .../start-listening-of-channels.injectable.ts | 1 - .../initialize-state.injectable.ts | 3 +- ...nitial-values-for-sync-boxes.injectable.ts | 1 - .../vars/build-version/init.injectable.ts | 1 - .../default-update-channel/init.injectable.ts | 3 +- .../vars/release-channel/init.injectable.ts | 3 +- .../semantic-build-version/init.injectable.ts | 3 +- 112 files changed, 889 insertions(+), 1124 deletions(-) delete mode 100644 packages/core/src/main/start-main-application/runnable-tokens/after-application-is-loaded-injection-token.ts delete mode 100644 packages/core/src/main/start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token.ts delete mode 100644 packages/core/src/main/start-main-application/runnable-tokens/after-window-is-opened-injection-token.ts delete mode 100644 packages/core/src/main/start-main-application/runnable-tokens/before-application-is-loading-injection-token.ts delete mode 100644 packages/core/src/main/start-main-application/runnable-tokens/before-electron-is-ready-injection-token.ts delete mode 100644 packages/core/src/main/start-main-application/runnable-tokens/before-quit-of-back-end-injection-token.ts delete mode 100644 packages/core/src/main/start-main-application/runnable-tokens/before-quit-of-front-end-injection-token.ts delete mode 100644 packages/core/src/main/start-main-application/runnable-tokens/on-load-of-application-injection-token.ts diff --git a/packages/core/src/common/k8s-api/__tests__/kube-api-version-detection.test.ts b/packages/core/src/common/k8s-api/__tests__/kube-api-version-detection.test.ts index 16c2ae0e04..49f1347e68 100644 --- a/packages/core/src/common/k8s-api/__tests__/kube-api-version-detection.test.ts +++ b/packages/core/src/common/k8s-api/__tests__/kube-api-version-detection.test.ts @@ -121,7 +121,7 @@ describe("KubeApi", () => { ]); }); - describe("when resource request fufills with a resource", () => { + describe("when resource request fulfills with a resource", () => { beforeEach(async () => { await fetchMock.resolveSpecific( ["https://127.0.0.1:12345/api-kube/apis/networking.k8s.io/v1"], @@ -283,7 +283,7 @@ describe("KubeApi", () => { }); }); - describe("when resource request fufills with no resource", () => { + describe("when resource request fulfills with no resource", () => { beforeEach(async () => { await fetchMock.resolveSpecific( ["https://127.0.0.1:12345/api-kube/apis/networking.k8s.io/v1"], @@ -307,7 +307,7 @@ describe("KubeApi", () => { - describe("when resource request fufills with a resource", () => { + describe("when resource request fulfills with a resource", () => { beforeEach(async () => { await fetchMock.resolveSpecific( ["https://127.0.0.1:12345/api-kube/apis/networking.k8s.io/v1beta1"], @@ -509,7 +509,7 @@ describe("KubeApi", () => { ]); }); - describe("when resource request fufills with a resource", () => { + describe("when resource request fulfills with a resource", () => { beforeEach(async () => { await fetchMock.resolveSpecific( ["https://127.0.0.1:12345/api-kube/apis/extensions"], diff --git a/packages/core/src/features/application-menu/main/start-application-menu.injectable.ts b/packages/core/src/features/application-menu/main/start-application-menu.injectable.ts index a3edd09ca1..13fd8e4938 100644 --- a/packages/core/src/features/application-menu/main/start-application-menu.injectable.ts +++ b/packages/core/src/features/application-menu/main/start-application-menu.injectable.ts @@ -4,23 +4,18 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import applicationMenuReactivityInjectable from "./application-menu-reactivity.injectable"; -import { onLoadOfApplicationInjectionToken } from "../../../main/start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../../main/start-main-application/runnable-tokens/phases"; const startApplicationMenuInjectable = getInjectable({ id: "start-application-menu", - instantiate: (di) => { - const applicationMenu = di.inject( - applicationMenuReactivityInjectable, - ); + instantiate: (di) => ({ + run: () => { + const applicationMenu = di.inject(applicationMenuReactivityInjectable); - return { - id: "start-application-menu", - run: () => { - applicationMenu.start(); - }, - }; - }, + applicationMenu.start(); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/features/application-menu/main/stop-application-menu.injectable.ts b/packages/core/src/features/application-menu/main/stop-application-menu.injectable.ts index 62abd439df..816683b2de 100644 --- a/packages/core/src/features/application-menu/main/stop-application-menu.injectable.ts +++ b/packages/core/src/features/application-menu/main/stop-application-menu.injectable.ts @@ -4,19 +4,20 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import applicationMenuReactivityInjectable from "./application-menu-reactivity.injectable"; -import { beforeQuitOfBackEndInjectionToken } from "../../../main/start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; +import { beforeQuitOfBackEndInjectionToken } from "../../../main/start-main-application/runnable-tokens/phases"; const stopApplicationMenuInjectable = getInjectable({ id: "stop-application-menu", - instantiate: (di) => { - const applicationMenu = di.inject(applicationMenuReactivityInjectable); + instantiate: (di) => ({ + run: () => { + const applicationMenu = di.inject(applicationMenuReactivityInjectable); - return { - id: "stop-application-menu", - run: () => void applicationMenu.stop(), - }; - }, + applicationMenu.stop(); + + return undefined; + }, + }), injectionToken: beforeQuitOfBackEndInjectionToken, }); diff --git a/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/main/start-checking-for-updates.injectable.ts b/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/main/start-checking-for-updates.injectable.ts index 20b60af2fa..fa129f8522 100644 --- a/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/main/start-checking-for-updates.injectable.ts +++ b/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/main/start-checking-for-updates.injectable.ts @@ -5,24 +5,21 @@ import { getInjectable } from "@ogre-tools/injectable"; import periodicalCheckForUpdatesInjectable from "./periodical-check-for-updates.injectable"; import updatingIsEnabledInjectable from "../../../main/updating-is-enabled/updating-is-enabled.injectable"; -import { afterApplicationIsLoadedInjectionToken } from "../../../../../main/start-main-application/runnable-tokens/after-application-is-loaded-injection-token"; +import { afterApplicationIsLoadedInjectionToken } from "../../../../../main/start-main-application/runnable-tokens/phases"; const startCheckingForUpdatesInjectable = getInjectable({ id: "start-checking-for-updates", - instantiate: (di) => { - const periodicalCheckForUpdates = di.inject(periodicalCheckForUpdatesInjectable); - const updatingIsEnabled = di.inject(updatingIsEnabledInjectable); + instantiate: (di) => ({ + run: () => { + const periodicalCheckForUpdates = di.inject(periodicalCheckForUpdatesInjectable); + const updatingIsEnabled = di.inject(updatingIsEnabledInjectable); - return { - id: "start-checking-for-updates", - run: () => { - if (updatingIsEnabled && !periodicalCheckForUpdates.started) { - periodicalCheckForUpdates.start(); - } - }, - }; - }, + if (updatingIsEnabled && !periodicalCheckForUpdates.started) { + periodicalCheckForUpdates.start(); + } + }, + }), injectionToken: afterApplicationIsLoadedInjectionToken, }); diff --git a/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/main/stop-checking-for-updates.injectable.ts b/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/main/stop-checking-for-updates.injectable.ts index 6e58d7dd77..df1557466e 100644 --- a/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/main/stop-checking-for-updates.injectable.ts +++ b/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/main/stop-checking-for-updates.injectable.ts @@ -4,25 +4,22 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import periodicalCheckForUpdatesInjectable from "./periodical-check-for-updates.injectable"; -import { beforeQuitOfBackEndInjectionToken } from "../../../../../main/start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; +import { beforeQuitOfBackEndInjectionToken } from "../../../../../main/start-main-application/runnable-tokens/phases"; const stopCheckingForUpdatesInjectable = getInjectable({ id: "stop-checking-for-updates", - instantiate: (di) => { - const periodicalCheckForUpdates = di.inject(periodicalCheckForUpdatesInjectable); + instantiate: (di) => ({ + run: () => { + const periodicalCheckForUpdates = di.inject(periodicalCheckForUpdatesInjectable); - return { - id: "stop-checking-for-updates", - run: () => { - if (periodicalCheckForUpdates.started) { - periodicalCheckForUpdates.stop(); - } + if (periodicalCheckForUpdates.started) { + periodicalCheckForUpdates.stop(); + } - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeQuitOfBackEndInjectionToken, }); diff --git a/packages/core/src/features/application-update/main/emit-current-version-to-analytics.injectable.ts b/packages/core/src/features/application-update/main/emit-current-version-to-analytics.injectable.ts index 17fdf89944..b976b78625 100644 --- a/packages/core/src/features/application-update/main/emit-current-version-to-analytics.injectable.ts +++ b/packages/core/src/features/application-update/main/emit-current-version-to-analytics.injectable.ts @@ -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 "../../../main/start-main-application/runnable-tokens/after-application-is-loaded-injection-token"; +import { afterApplicationIsLoadedInjectionToken } from "../../../main/start-main-application/runnable-tokens/phases"; import emitAppEventInjectable from "../../../common/app-event-bus/emit-event.injectable"; import { getCurrentDateTime } from "../../../common/utils/date/get-current-date-time"; import buildVersionInjectable from "../../../main/vars/build-version/build-version.injectable"; @@ -11,25 +11,22 @@ import buildVersionInjectable from "../../../main/vars/build-version/build-versi const emitCurrentVersionToAnalyticsInjectable = getInjectable({ id: "emit-current-version-to-analytics", - instantiate: (di) => { - const emitAppEvent = di.inject(emitAppEventInjectable); - const buildVersion = di.inject(buildVersionInjectable); + instantiate: (di) => ({ + run: () => { + const emitAppEvent = di.inject(emitAppEventInjectable); + const buildVersion = di.inject(buildVersionInjectable); - return { - id: "emit-current-version-to-analytics", - run: () => { - emitAppEvent({ - name: "app", - action: "current-version", + emitAppEvent({ + name: "app", + action: "current-version", - params: { - version: buildVersion.get(), - currentDateTime: getCurrentDateTime(), - }, - }); - }, - }; - }, + params: { + version: buildVersion.get(), + currentDateTime: getCurrentDateTime(), + }, + }); + }, + }), injectionToken: afterApplicationIsLoadedInjectionToken, }); diff --git a/packages/core/src/features/application-update/main/watch-if-update-should-happen-on-quit/start-watching-if-update-should-happen-on-quit.injectable.ts b/packages/core/src/features/application-update/main/watch-if-update-should-happen-on-quit/start-watching-if-update-should-happen-on-quit.injectable.ts index 2609f8f46f..f540c9f082 100644 --- a/packages/core/src/features/application-update/main/watch-if-update-should-happen-on-quit/start-watching-if-update-should-happen-on-quit.injectable.ts +++ b/packages/core/src/features/application-update/main/watch-if-update-should-happen-on-quit/start-watching-if-update-should-happen-on-quit.injectable.ts @@ -3,22 +3,19 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { onLoadOfApplicationInjectionToken } from "../../../../main/start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases"; import watchIfUpdateShouldHappenOnQuitInjectable from "./watch-if-update-should-happen-on-quit.injectable"; const startWatchingIfUpdateShouldHappenOnQuitInjectable = getInjectable({ id: "start-watching-if-update-should-happen-on-quit", - instantiate: (di) => { - const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable); + instantiate: (di) => ({ + run: () => { + const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable); - return { - id: "start-watching-if-update-should-happen-on-quit", - run: () => { - watchIfUpdateShouldHappenOnQuit.start(); - }, - }; - }, + watchIfUpdateShouldHappenOnQuit.start(); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/features/application-update/main/watch-if-update-should-happen-on-quit/stop-watching-if-update-should-happen-on-quit.injectable.ts b/packages/core/src/features/application-update/main/watch-if-update-should-happen-on-quit/stop-watching-if-update-should-happen-on-quit.injectable.ts index faf67b4ffc..36a6d3174d 100644 --- a/packages/core/src/features/application-update/main/watch-if-update-should-happen-on-quit/stop-watching-if-update-should-happen-on-quit.injectable.ts +++ b/packages/core/src/features/application-update/main/watch-if-update-should-happen-on-quit/stop-watching-if-update-should-happen-on-quit.injectable.ts @@ -4,19 +4,20 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import watchIfUpdateShouldHappenOnQuitInjectable from "./watch-if-update-should-happen-on-quit.injectable"; -import { beforeQuitOfBackEndInjectionToken } from "../../../../main/start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; +import { beforeQuitOfBackEndInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases"; const stopWatchingIfUpdateShouldHappenOnQuitInjectable = getInjectable({ id: "stop-watching-if-update-should-happen-on-quit", - instantiate: (di) => { - const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable); + instantiate: (di) => ({ + run: () => { + const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable); - return { - id: "stop-watching-if-update-should-happen-on-quit", - run: () => void watchIfUpdateShouldHappenOnQuit.stop(), - }; - }, + watchIfUpdateShouldHappenOnQuit.stop(); + + return undefined; + }, + }), injectionToken: beforeQuitOfBackEndInjectionToken, }); diff --git a/packages/core/src/features/cluster/state-sync/main/setup-sync.injectable.ts b/packages/core/src/features/cluster/state-sync/main/setup-sync.injectable.ts index 9b0e13249d..b161d57b5c 100644 --- a/packages/core/src/features/cluster/state-sync/main/setup-sync.injectable.ts +++ b/packages/core/src/features/cluster/state-sync/main/setup-sync.injectable.ts @@ -7,14 +7,13 @@ import { isEqual } from "lodash"; import { autorun } from "mobx"; import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.injectable"; import type { ClusterId, ClusterState } from "../../../../common/cluster-types"; -import { beforeApplicationIsLoadingInjectionToken } from "../../../../main/start-main-application/runnable-tokens/before-application-is-loading-injection-token"; +import { beforeApplicationIsLoadingInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases"; import initClusterStoreInjectable from "../../store/main/init.injectable"; import emitClusterStateUpdateInjectable from "./emit-update.injectable"; const setupClusterStateBroadcastingInjectable = getInjectable({ id: "setup-cluster-state-broadcasting", instantiate: (di) => ({ - id: "setup-cluster-state-broadcasting", run: () => { const emitClusterStateUpdate = di.inject(emitClusterStateUpdateInjectable); const clusterStore = di.inject(clusterStoreInjectable); @@ -36,7 +35,7 @@ const setupClusterStateBroadcastingInjectable = getInjectable({ } }); }, - runAfter: di.inject(initClusterStoreInjectable), + runAfter: initClusterStoreInjectable, }), injectionToken: beforeApplicationIsLoadingInjectionToken, }); diff --git a/packages/core/src/features/cluster/state-sync/renderer/setup-sync.injectable.ts b/packages/core/src/features/cluster/state-sync/renderer/setup-sync.injectable.ts index e4df4c7f8e..da43ace234 100644 --- a/packages/core/src/features/cluster/state-sync/renderer/setup-sync.injectable.ts +++ b/packages/core/src/features/cluster/state-sync/renderer/setup-sync.injectable.ts @@ -11,17 +11,16 @@ import requestInitialClusterStatesInjectable from "./request-initial.injectable" const setupClusterStateSyncInjectable = getInjectable({ id: "setup-cluster-state-sync", instantiate: (di) => ({ - id: "setup-cluster-state-sync", run: async () => { const requestInitialClusterStates = di.inject(requestInitialClusterStatesInjectable); const getClusterById = di.inject(getClusterByIdInjectable); - const initalStates = await requestInitialClusterStates(); + const initialStates = await requestInitialClusterStates(); - for (const { clusterId, state } of initalStates) { + for (const { clusterId, state } of initialStates) { getClusterById(clusterId)?.setState(state); } }, - runAfter: di.inject(initClusterStoreInjectable), + runAfter: initClusterStoreInjectable, }), injectionToken: beforeFrameStartsSecondInjectionToken, }); diff --git a/packages/core/src/features/cluster/store/main/init.injectable.ts b/packages/core/src/features/cluster/store/main/init.injectable.ts index 7849ab6acd..b98dec70b7 100644 --- a/packages/core/src/features/cluster/store/main/init.injectable.ts +++ b/packages/core/src/features/cluster/store/main/init.injectable.ts @@ -4,22 +4,19 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.injectable"; -import { beforeApplicationIsLoadingInjectionToken } from "../../../../main/start-main-application/runnable-tokens/before-application-is-loading-injection-token"; +import { beforeApplicationIsLoadingInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases"; import initUserStoreInjectable from "../../../../main/stores/init-user-store.injectable"; const initClusterStoreInjectable = getInjectable({ id: "init-cluster-store", - instantiate: (di) => { - const clusterStore = di.inject(clusterStoreInjectable); + instantiate: (di) => ({ + run: () => { + const clusterStore = di.inject(clusterStoreInjectable); - return { - id: "init-cluster-store", - run: () => { - clusterStore.load(); - }, - runAfter: di.inject(initUserStoreInjectable), - }; - }, + clusterStore.load(); + }, + runAfter: initUserStoreInjectable, + }), injectionToken: beforeApplicationIsLoadingInjectionToken, }); diff --git a/packages/core/src/features/cluster/store/renderer/init.injectable.ts b/packages/core/src/features/cluster/store/renderer/init.injectable.ts index 66d2e31e09..f937796bae 100644 --- a/packages/core/src/features/cluster/store/renderer/init.injectable.ts +++ b/packages/core/src/features/cluster/store/renderer/init.injectable.ts @@ -10,13 +10,12 @@ import initUserStoreInjectable from "../../../../renderer/stores/init-user-store const initClusterStoreInjectable = getInjectable({ id: "init-cluster-store", instantiate: (di) => ({ - id: "init-cluster-store", run: () => { const clusterStore = di.inject(clusterStoreInjectable); clusterStore.load(); }, - runAfter: di.inject(initUserStoreInjectable), + runAfter: initUserStoreInjectable, }), injectionToken: beforeFrameStartsSecondInjectionToken, }); diff --git a/packages/core/src/features/file-system-provisioner/main/init-store.injectable.ts b/packages/core/src/features/file-system-provisioner/main/init-store.injectable.ts index 0fe3d4f77b..33709e7ca4 100644 --- a/packages/core/src/features/file-system-provisioner/main/init-store.injectable.ts +++ b/packages/core/src/features/file-system-provisioner/main/init-store.injectable.ts @@ -4,12 +4,11 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import fileSystemProvisionerStoreInjectable from "../../../extensions/extension-loader/file-system-provisioner-store/file-system-provisioner-store.injectable"; -import { onLoadOfApplicationInjectionToken } from "../../../main/start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../../main/start-main-application/runnable-tokens/phases"; const initFileSystemProvisionerStoreInjectable = getInjectable({ id: "init-file-system-provisioner-store", instantiate: (di) => ({ - id: "init-file-system-provisioner-store", run: () => { const store = di.inject(fileSystemProvisionerStoreInjectable); diff --git a/packages/core/src/features/file-system-provisioner/renderer/init-store.injectable.ts b/packages/core/src/features/file-system-provisioner/renderer/init-store.injectable.ts index 0e64e49fd6..a133c54d20 100644 --- a/packages/core/src/features/file-system-provisioner/renderer/init-store.injectable.ts +++ b/packages/core/src/features/file-system-provisioner/renderer/init-store.injectable.ts @@ -9,7 +9,6 @@ import { beforeFrameStartsSecondInjectionToken } from "../../../renderer/before- const initFileSystemProvisionerStoreInjectable = getInjectable({ id: "init-file-system-provisioner-store", instantiate: (di) => ({ - id: "init-file-system-provisioner-store", run: () => { const store = di.inject(fileSystemProvisionerStoreInjectable); diff --git a/packages/core/src/features/hotbar/store/main/init.injectable.ts b/packages/core/src/features/hotbar/store/main/init.injectable.ts index 0717151b53..3ce13d7eb9 100644 --- a/packages/core/src/features/hotbar/store/main/init.injectable.ts +++ b/packages/core/src/features/hotbar/store/main/init.injectable.ts @@ -4,22 +4,19 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import hotbarStoreInjectable from "../../../../common/hotbars/store.injectable"; -import { onLoadOfApplicationInjectionToken } from "../../../../main/start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases"; import setupSyncingOfGeneralCatalogEntitiesInjectable from "../../../../main/start-main-application/runnables/setup-syncing-of-general-catalog-entities.injectable"; const initHotbarStoreInjectable = getInjectable({ id: "init-hotbar-store", - instantiate: (di) => { - const hotbarStore = di.inject(hotbarStoreInjectable); + instantiate: (di) => ({ + run: () => { + const hotbarStore = di.inject(hotbarStoreInjectable); - return { - id: "init-hotbar-store", - run: () => { - hotbarStore.load(); - }, - runAfter: di.inject(setupSyncingOfGeneralCatalogEntitiesInjectable), - }; - }, + hotbarStore.load(); + }, + runAfter: setupSyncingOfGeneralCatalogEntitiesInjectable, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/features/hotbar/store/renderer/init.injectable.ts b/packages/core/src/features/hotbar/store/renderer/init.injectable.ts index c17e3a4858..239807dfda 100644 --- a/packages/core/src/features/hotbar/store/renderer/init.injectable.ts +++ b/packages/core/src/features/hotbar/store/renderer/init.injectable.ts @@ -10,13 +10,12 @@ import initClusterStoreInjectable from "../../../cluster/store/renderer/init.inj const initHotbarStoreInjectable = getInjectable({ id: "init-hotbar-store", instantiate: (di) => ({ - id: "init-hotbar-store", run: () => { const hotbarStore = di.inject(hotbarStoreInjectable); hotbarStore.load(); }, - runAfter: di.inject(initClusterStoreInjectable), + runAfter: initClusterStoreInjectable, }), injectionToken: beforeFrameStartsSecondInjectionToken, }); diff --git a/packages/core/src/features/shell-sync/main/setup-shell.injectable.ts b/packages/core/src/features/shell-sync/main/setup-shell.injectable.ts index 82d623ec28..c75f5cc04b 100644 --- a/packages/core/src/features/shell-sync/main/setup-shell.injectable.ts +++ b/packages/core/src/features/shell-sync/main/setup-shell.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import loggerInjectable from "../../../common/logger.injectable"; -import { onLoadOfApplicationInjectionToken } from "../../../main/start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../../main/start-main-application/runnable-tokens/phases"; import { unionPATHs } from "../../../common/utils/union-env-path"; import isSnapPackageInjectable from "../../../common/vars/is-snap-package.injectable"; import electronAppInjectable from "../../../main/electron-app/electron-app.injectable"; @@ -15,57 +15,56 @@ import emitShellSyncFailedInjectable from "./emit-failure.injectable"; const setupShellInjectable = getInjectable({ id: "setup-shell", - instantiate: (di) => { - const logger = di.inject(loggerInjectable); - const isSnapPackage = di.inject(isSnapPackageInjectable); - const electronApp = di.inject(electronAppInjectable); - const resolvedUserShellSetting = di.inject(userShellSettingInjectable); - const computeShellEnvironment = di.inject(computeShellEnvironmentInjectable); - const emitShellSyncFailed = di.inject(emitShellSyncFailedInjectable); + instantiate: (di) => ({ + run: async () => { + const logger = di.inject(loggerInjectable); + const isSnapPackage = di.inject(isSnapPackageInjectable); + const electronApp = di.inject(electronAppInjectable); + const resolvedUserShellSetting = di.inject(userShellSettingInjectable); + const computeShellEnvironment = di.inject(computeShellEnvironmentInjectable); + const emitShellSyncFailed = di.inject(emitShellSyncFailedInjectable); - return { - id: "setup-shell", - run: async (): Promise => { - logger.info("🐚 Syncing shell environment"); + logger.info("🐚 Syncing shell environment"); - const result = await computeShellEnvironment(resolvedUserShellSetting.get()); + const result = await computeShellEnvironment(resolvedUserShellSetting.get()); - if (!result.callWasSuccessful) { - logger.error(`[SHELL-SYNC]: ${result.error}`); - emitShellSyncFailed(result.error); + if (!result.callWasSuccessful) { + logger.error(`[SHELL-SYNC]: ${result.error}`); + emitShellSyncFailed(result.error); - return; - } + return; + } - const env = result.response; + const env = result.response; - if (!env) { - return void logger.debug("[SHELL-SYNC]: nothing to do, env not special in shells"); - } + if (!env) { + logger.debug("[SHELL-SYNC]: nothing to do, env not special in shells"); - if (!env.LANG) { - // the LANG env var expects an underscore instead of electron's dash - env.LANG = `${electronApp.getLocale().replace("-", "_")}.UTF-8`; - } else if (!env.LANG.endsWith(".UTF-8")) { - env.LANG += ".UTF-8"; - } + return; + } - if (!isSnapPackage) { - // Prefer the synced PATH over the initial one - process.env.PATH = unionPATHs(env.PATH ?? "", process.env.PATH ?? ""); - } + if (!env.LANG) { + // the LANG env var expects an underscore instead of electron's dash + env.LANG = `${electronApp.getLocale().replace("-", "_")}.UTF-8`; + } else if (!env.LANG.endsWith(".UTF-8")) { + env.LANG += ".UTF-8"; + } - // The spread operator allows joining of objects. The precedence is last to first. - process.env = { - ...env, - ...process.env, - }; + if (!isSnapPackage) { + // Prefer the synced PATH over the initial one + process.env.PATH = unionPATHs(env.PATH ?? "", process.env.PATH ?? ""); + } - logger.info(`[SHELL-SYNC]: Synced shell env`); - logger.debug(`[SHELL-SYNC]: updated env`, process.env); - }, - }; - }, + // The spread operator allows joining of objects. The precedence is last to first. + process.env = { + ...env, + ...process.env, + }; + + logger.info(`[SHELL-SYNC]: Synced shell env`); + logger.debug(`[SHELL-SYNC]: updated env`, process.env); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/features/terminal/renderer/fonts/preload-fonts.injectable.ts b/packages/core/src/features/terminal/renderer/fonts/preload-fonts.injectable.ts index 64c40247b7..afb0c969fd 100644 --- a/packages/core/src/features/terminal/renderer/fonts/preload-fonts.injectable.ts +++ b/packages/core/src/features/terminal/renderer/fonts/preload-fonts.injectable.ts @@ -10,7 +10,6 @@ import loadTerminalFontInjectable from "./load-font.injectable"; const preloadTerminalFontsInjectable = getInjectable({ id: "preload-terminal-fonts", instantiate: (di) => ({ - id: "preload-terminal-fonts", run: async () => { const terminalFonts = di.inject(terminalFontsInjectable); const loadTerminalFont = di.inject(loadTerminalFontInjectable); diff --git a/packages/core/src/features/theme/system-type/main/setup-update-emitter.injectable.ts b/packages/core/src/features/theme/system-type/main/setup-update-emitter.injectable.ts index 75129fa128..0125799531 100644 --- a/packages/core/src/features/theme/system-type/main/setup-update-emitter.injectable.ts +++ b/packages/core/src/features/theme/system-type/main/setup-update-emitter.injectable.ts @@ -4,29 +4,26 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { reaction } from "mobx"; -import { onLoadOfApplicationInjectionToken } from "../../../../main/start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases"; import operatingSystemThemeInjectable from "../../../../main/theme/operating-system-theme.injectable"; import emitSystemThemeTypeUpdateInjectable from "./emit-update.injectable"; const setupSystemThemeTypeUpdaterEmitterInjectable = getInjectable({ id: "setup-system-theme-type-updater-emitter", - instantiate: (di) => { - const operatingSystemTheme = di.inject(operatingSystemThemeInjectable); - const emitSystemThemeTypeUpdate = di.inject(emitSystemThemeTypeUpdateInjectable); + instantiate: (di) => ({ + run: () => { + const operatingSystemTheme = di.inject(operatingSystemThemeInjectable); + const emitSystemThemeTypeUpdate = di.inject(emitSystemThemeTypeUpdateInjectable); - return { - id: "setup-system-theme-type-updater-emitter", - run: () => { - reaction( - () => operatingSystemTheme.get(), - emitSystemThemeTypeUpdate, - { - fireImmediately: true, - }, - ); - }, - }; - }, + reaction( + () => operatingSystemTheme.get(), + emitSystemThemeTypeUpdate, + { + fireImmediately: true, + }, + ); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/features/theme/system-type/renderer/initialize.injectable.ts b/packages/core/src/features/theme/system-type/renderer/initialize.injectable.ts index 849c8328b2..2e09f8e9d1 100644 --- a/packages/core/src/features/theme/system-type/renderer/initialize.injectable.ts +++ b/packages/core/src/features/theme/system-type/renderer/initialize.injectable.ts @@ -11,14 +11,13 @@ import requestInitialSystemThemeTypeInjectable from "./request-initial.injectabl const initializeSystemThemeTypeInjectable = getInjectable({ id: "initialize-system-theme-type", instantiate: (di) => ({ - id: "initialize-system-theme-type", run: async () => { const systemThemeConfiguration = di.inject(systemThemeConfigurationInjectable); const requestInitialSystemThemeType = di.inject(requestInitialSystemThemeTypeInjectable); systemThemeConfiguration.set(await requestInitialSystemThemeType()); }, - runAfter: di.inject(initUserStoreInjectable), + runAfter: initUserStoreInjectable, }), injectionToken: beforeFrameStartsSecondInjectionToken, }); diff --git a/packages/core/src/main/app-paths/setup-app-paths.injectable.ts b/packages/core/src/main/app-paths/setup-app-paths.injectable.ts index 0b3c67b60f..5f316014a4 100644 --- a/packages/core/src/main/app-paths/setup-app-paths.injectable.ts +++ b/packages/core/src/main/app-paths/setup-app-paths.injectable.ts @@ -18,38 +18,35 @@ import { appPathsRunnablePhaseInjectionToken } from "../start-main-application/r const setupAppPathsInjectable = getInjectable({ id: "setup-app-paths", - instantiate: (di) => { - const setElectronAppPath = di.inject(setElectronAppPathInjectable); - const appName = di.inject(appNameInjectable); - const getElectronAppPath = di.inject(getElectronAppPathInjectable); - const appPathsState = di.inject(appPathsStateInjectable); - const directoryForIntegrationTesting = di.inject(directoryForIntegrationTestingInjectable); - const joinPaths = di.inject(joinPathsInjectable); + instantiate: (di) => ({ + run: () => { + const setElectronAppPath = di.inject(setElectronAppPathInjectable); + const appName = di.inject(appNameInjectable); + const getElectronAppPath = di.inject(getElectronAppPathInjectable); + const appPathsState = di.inject(appPathsStateInjectable); + const directoryForIntegrationTesting = di.inject(directoryForIntegrationTestingInjectable); + const joinPaths = di.inject(joinPathsInjectable); - return { - id: "setup-app-paths", - run: () => { - if (directoryForIntegrationTesting) { - setElectronAppPath("appData", directoryForIntegrationTesting); - } + if (directoryForIntegrationTesting) { + setElectronAppPath("appData", directoryForIntegrationTesting); + } - const appDataPath = getElectronAppPath("appData"); + const appDataPath = getElectronAppPath("appData"); - setElectronAppPath("userData", joinPaths(appDataPath, appName)); + setElectronAppPath("userData", joinPaths(appDataPath, appName)); - const appPaths = pipeline( - pathNames, - map(name => [name, getElectronAppPath(name)]), - fromPairs, - ) as AppPaths; + const appPaths = pipeline( + pathNames, + map(name => [name, getElectronAppPath(name)]), + fromPairs, + ) as AppPaths; - appPathsState.set(appPaths); + appPathsState.set(appPaths); - // NOTE: this is the worse of two evils. This makes sure that `RunnableSync` always is sync - return undefined; - }, - }; - }, + // NOTE: this is the worse of two evils. This makes sure that `RunnableSync` always is sync + return undefined; + }, + }), injectionToken: appPathsRunnablePhaseInjectionToken, }); diff --git a/packages/core/src/main/catalog-sync-to-renderer/start-catalog-sync.injectable.ts b/packages/core/src/main/catalog-sync-to-renderer/start-catalog-sync.injectable.ts index ebe1f2a1ac..41db32b8f2 100644 --- a/packages/core/src/main/catalog-sync-to-renderer/start-catalog-sync.injectable.ts +++ b/packages/core/src/main/catalog-sync-to-renderer/start-catalog-sync.injectable.ts @@ -3,24 +3,21 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { afterRootFrameIsReadyInjectionToken } from "../start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token"; +import { afterRootFrameIsReadyInjectionToken } from "../start-main-application/runnable-tokens/phases"; import catalogSyncToRendererInjectable from "./catalog-sync-to-renderer.injectable"; const startCatalogSyncInjectable = getInjectable({ id: "start-catalog-sync", - instantiate: (di) => { - const catalogSyncToRenderer = di.inject(catalogSyncToRendererInjectable); + instantiate: (di) => ({ + run: () => { + const catalogSyncToRenderer = di.inject(catalogSyncToRendererInjectable); - return { - id: "start-catalog-sync", - run: () => { - if (!catalogSyncToRenderer.started) { - catalogSyncToRenderer.start(); - } - }, - }; - }, + if (!catalogSyncToRenderer.started) { + catalogSyncToRenderer.start(); + } + }, + }), injectionToken: afterRootFrameIsReadyInjectionToken, }); diff --git a/packages/core/src/main/catalog-sync-to-renderer/stop-catalog-sync.injectable.ts b/packages/core/src/main/catalog-sync-to-renderer/stop-catalog-sync.injectable.ts index 353790d8b2..faf5013a5f 100644 --- a/packages/core/src/main/catalog-sync-to-renderer/stop-catalog-sync.injectable.ts +++ b/packages/core/src/main/catalog-sync-to-renderer/stop-catalog-sync.injectable.ts @@ -4,25 +4,22 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import catalogSyncToRendererInjectable from "./catalog-sync-to-renderer.injectable"; -import { beforeQuitOfFrontEndInjectionToken } from "../start-main-application/runnable-tokens/before-quit-of-front-end-injection-token"; +import { beforeQuitOfFrontEndInjectionToken } from "../start-main-application/runnable-tokens/phases"; const stopCatalogSyncInjectable = getInjectable({ id: "stop-catalog-sync", - instantiate: (di) => { - const catalogSyncToRenderer = di.inject(catalogSyncToRendererInjectable); + instantiate: (di) => ({ + run: () => { + const catalogSyncToRenderer = di.inject(catalogSyncToRendererInjectable); - return { - id: "stop-catalog-sync", - run: () => { - if (catalogSyncToRenderer.started) { - catalogSyncToRenderer.stop(); - } + if (catalogSyncToRenderer.started) { + catalogSyncToRenderer.stop(); + } - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeQuitOfFrontEndInjectionToken, }); diff --git a/packages/core/src/main/cluster/initialize-manager.injectable.ts b/packages/core/src/main/cluster/initialize-manager.injectable.ts index adabcf416c..76cafb44a1 100644 --- a/packages/core/src/main/cluster/initialize-manager.injectable.ts +++ b/packages/core/src/main/cluster/initialize-manager.injectable.ts @@ -3,21 +3,18 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { onLoadOfApplicationInjectionToken } from "../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../start-main-application/runnable-tokens/phases"; import clusterManagerInjectable from "./manager.injectable"; const initializeClusterManagerInjectable = getInjectable({ id: "initialize-cluster-manager", - instantiate: (di) => { - const clusterManager = di.inject(clusterManagerInjectable); + instantiate: (di) => ({ + run: () => { + const clusterManager = di.inject(clusterManagerInjectable); - return { - id: "initialize-cluster-manager", - run: () => { - clusterManager.init(); - }, - }; - }, + clusterManager.init(); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, causesSideEffects: true, }); diff --git a/packages/core/src/main/electron-app/runnables/clean-up-deep-linking.injectable.ts b/packages/core/src/main/electron-app/runnables/clean-up-deep-linking.injectable.ts index b5088a667a..19fb7e1143 100644 --- a/packages/core/src/main/electron-app/runnables/clean-up-deep-linking.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/clean-up-deep-linking.injectable.ts @@ -3,20 +3,21 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; +import { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import lensProtocolRouterMainInjectable from "../../protocol-handler/lens-protocol-router-main/lens-protocol-router-main.injectable"; const cleanUpDeepLinkingInjectable = getInjectable({ id: "clean-up-deep-linking", - instantiate: (di) => { - const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable); + instantiate: (di) => ({ + run: () => { + const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable); - return { - id: "clean-up-deep-linking", - run: () => void lensProtocolRouterMain.cleanup(), - }; - }, + lensProtocolRouterMain.cleanup(); + + return undefined; + }, + }), injectionToken: beforeQuitOfBackEndInjectionToken, }); diff --git a/packages/core/src/main/electron-app/runnables/dock-visibility/hide-dock-for-last-closed-window.injectable.ts b/packages/core/src/main/electron-app/runnables/dock-visibility/hide-dock-for-last-closed-window.injectable.ts index 5586c93586..e61af65da4 100644 --- a/packages/core/src/main/electron-app/runnables/dock-visibility/hide-dock-for-last-closed-window.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/dock-visibility/hide-dock-for-last-closed-window.injectable.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { beforeQuitOfFrontEndInjectionToken } from "../../../start-main-application/runnable-tokens/before-quit-of-front-end-injection-token"; +import { beforeQuitOfFrontEndInjectionToken } from "../../../start-main-application/runnable-tokens/phases"; import electronAppInjectable from "../../electron-app.injectable"; import { isEmpty } from "lodash/fp"; import getVisibleWindowsInjectable from "../../../start-main-application/lens-window/get-visible-windows.injectable"; @@ -11,23 +11,19 @@ import getVisibleWindowsInjectable from "../../../start-main-application/lens-wi const hideDockForLastClosedWindowInjectable = getInjectable({ id: "hide-dock-when-there-are-no-windows", - instantiate: (di) => { - const app = di.inject(electronAppInjectable); - const getVisibleWindows = di.inject(getVisibleWindowsInjectable); + instantiate: (di) => ({ + run: () => { + const app = di.inject(electronAppInjectable); + const getVisibleWindows = di.inject(getVisibleWindowsInjectable); + const visibleWindows = getVisibleWindows(); - return { - id: "hide-dock-when-there-are-no-windows", - run: () => { - const visibleWindows = getVisibleWindows(); + if (isEmpty(visibleWindows)) { + app.dock?.hide(); + } - if (isEmpty(visibleWindows)) { - app.dock?.hide(); - } - - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeQuitOfFrontEndInjectionToken, }); diff --git a/packages/core/src/main/electron-app/runnables/dock-visibility/show-dock-for-first-opened-window.injectable.ts b/packages/core/src/main/electron-app/runnables/dock-visibility/show-dock-for-first-opened-window.injectable.ts index b47e511c14..9f52dcab42 100644 --- a/packages/core/src/main/electron-app/runnables/dock-visibility/show-dock-for-first-opened-window.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/dock-visibility/show-dock-for-first-opened-window.injectable.ts @@ -4,21 +4,18 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import electronAppInjectable from "../../electron-app.injectable"; -import { afterWindowIsOpenedInjectionToken } from "../../../start-main-application/runnable-tokens/after-window-is-opened-injection-token"; +import { afterWindowIsOpenedInjectionToken } from "../../../start-main-application/runnable-tokens/phases"; const showDockForFirstOpenedWindowInjectable = getInjectable({ id: "show-dock-for-first-opened-window", - instantiate: (di) => { - const app = di.inject(electronAppInjectable); + instantiate: (di) => ({ + run: () => { + const app = di.inject(electronAppInjectable); - return { - id: "show-dock-for-first-opened-window", - run: () => { - app.dock?.show(); - }, - }; - }, + app.dock?.show(); + }, + }), injectionToken: afterWindowIsOpenedInjectionToken, }); diff --git a/packages/core/src/main/electron-app/runnables/enforce-single-application-instance.injectable.ts b/packages/core/src/main/electron-app/runnables/enforce-single-application-instance.injectable.ts index f69036ffed..b310838cbe 100644 --- a/packages/core/src/main/electron-app/runnables/enforce-single-application-instance.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/enforce-single-application-instance.injectable.ts @@ -3,28 +3,25 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { beforeElectronIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/before-electron-is-ready-injection-token"; +import { beforeElectronIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import requestSingleInstanceLockInjectable from "../features/request-single-instance-lock.injectable"; import exitAppInjectable from "../features/exit-app.injectable"; const enforceSingleApplicationInstanceInjectable = getInjectable({ id: "enforce-single-application-instance", - instantiate: (di) => { - const requestSingleInstanceLock = di.inject(requestSingleInstanceLockInjectable); - const exitApp = di.inject(exitAppInjectable); + instantiate: (di) => ({ + run: () => { + const requestSingleInstanceLock = di.inject(requestSingleInstanceLockInjectable); + const exitApp = di.inject(exitAppInjectable); - return { - id: "enforce-single-application-instance", - run: () => { - if (!requestSingleInstanceLock()) { - exitApp(); - } + if (!requestSingleInstanceLock()) { + exitApp(); + } - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeElectronIsReadyInjectionToken, }); diff --git a/packages/core/src/main/electron-app/runnables/setup-application-name.injectable.ts b/packages/core/src/main/electron-app/runnables/setup-application-name.injectable.ts index fd47480f09..ac67925125 100644 --- a/packages/core/src/main/electron-app/runnables/setup-application-name.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/setup-application-name.injectable.ts @@ -4,25 +4,22 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import appNameInjectable from "../../../common/vars/app-name.injectable"; -import { beforeElectronIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/before-electron-is-ready-injection-token"; +import { beforeElectronIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import electronAppInjectable from "../electron-app.injectable"; const setupApplicationNameInjectable = getInjectable({ id: "setup-application-name", - instantiate: (di) => { - const app = di.inject(electronAppInjectable); - const appName = di.inject(appNameInjectable); + instantiate: (di) => ({ + run: () => { + const app = di.inject(electronAppInjectable); + const appName = di.inject(appNameInjectable); - return { - id: "setup-application-name", - run: () => { - app.setName(appName); + app.setName(appName); - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeElectronIsReadyInjectionToken, }); diff --git a/packages/core/src/main/electron-app/runnables/setup-deep-linking.injectable.ts b/packages/core/src/main/electron-app/runnables/setup-deep-linking.injectable.ts index 5f82d60f42..979693b822 100644 --- a/packages/core/src/main/electron-app/runnables/setup-deep-linking.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/setup-deep-linking.injectable.ts @@ -7,68 +7,63 @@ import electronAppInjectable from "../electron-app.injectable"; import openDeepLinkInjectable from "../../protocol-handler/lens-protocol-router-main/open-deep-link-for-url/open-deep-link.injectable"; import loggerInjectable from "../../../common/logger.injectable"; import commandLineArgumentsInjectable from "../../utils/command-line-arguments.injectable"; -import { pipeline } from "@ogre-tools/fp"; -import { find, startsWith, toLower, map } from "lodash/fp"; -import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { startsWith, toLower } from "lodash/fp"; +import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import showApplicationWindowInjectable from "../../start-main-application/lens-window/show-application-window.injectable"; const setupDeepLinkingInjectable = getInjectable({ id: "setup-deep-linking", - instantiate: (di) => { - const app = di.inject(electronAppInjectable); - const logger = di.inject(loggerInjectable); - const openDeepLinkForUrl = di.inject(openDeepLinkInjectable); - const showApplicationWindow = di.inject(showApplicationWindowInjectable); + instantiate: (di) => ({ + run: async () => { + const app = di.inject(electronAppInjectable); + const logger = di.inject(loggerInjectable); + const openDeepLinkForUrl = di.inject(openDeepLinkInjectable); + const showApplicationWindow = di.inject(showApplicationWindowInjectable); + const firstInstanceCommandLineArguments = di.inject(commandLineArgumentsInjectable); - const firstInstanceCommandLineArguments = di.inject( - commandLineArgumentsInjectable, - ); + logger.info(`📟 Setting protocol client for lens://`); - return { - id: "setup-deep-linking", - run: async () => { - logger.info(`📟 Setting protocol client for lens://`); + if (app.setAsDefaultProtocolClient("lens")) { + logger.info("📟 Protocol client register succeeded ✅"); + } else { + logger.info("📟 Protocol client register failed ❗"); + } - if (app.setAsDefaultProtocolClient("lens")) { - logger.info("📟 Protocol client register succeeded ✅"); - } else { - logger.info("📟 Protocol client register failed ❗"); - } + const url = getDeepLinkUrl(firstInstanceCommandLineArguments); - const url = getDeepLinkUrl(firstInstanceCommandLineArguments); + if (url) { + await openDeepLinkForUrl(url); + } - if (url) { - await openDeepLinkForUrl(url); - } + app.on("open-url", async (event, url) => { + event.preventDefault(); - app.on("open-url", async (event, url) => { - event.preventDefault(); + await openDeepLinkForUrl(url); + }); - await openDeepLinkForUrl(url); - }); + app.on( + "second-instance", + async (_, secondInstanceCommandLineArguments) => { + const url = getDeepLinkUrl(secondInstanceCommandLineArguments); - app.on( - "second-instance", + await showApplicationWindow(); - async (_, secondInstanceCommandLineArguments) => { - const url = getDeepLinkUrl(secondInstanceCommandLineArguments); - - await showApplicationWindow(); - - if (url) { - await openDeepLinkForUrl(url); - } - }, - ); - }, - }; - }, + if (url) { + await openDeepLinkForUrl(url); + } + }, + ); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); export default setupDeepLinkingInjectable; -const getDeepLinkUrl = (commandLineArguments: string[]) => - pipeline(commandLineArguments, map(toLower), find(startsWith("lens://"))); +const getDeepLinkUrl = (commandLineArguments: string[]) => ( + commandLineArguments + .map(toLower) + .find(startsWith("lens://")) +); diff --git a/packages/core/src/main/electron-app/runnables/setup-developer-tools-in-development-environment.injectable.ts b/packages/core/src/main/electron-app/runnables/setup-developer-tools-in-development-environment.injectable.ts index 5572887b06..22fe933748 100644 --- a/packages/core/src/main/electron-app/runnables/setup-developer-tools-in-development-environment.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/setup-developer-tools-in-development-environment.injectable.ts @@ -5,37 +5,38 @@ import { getInjectable } from "@ogre-tools/injectable"; import nodeEnvInjectionToken from "../../../common/vars/node-env-injection-token"; import loggerInjectable from "../../../common/logger.injectable"; -import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases"; const setupDeveloperToolsInDevelopmentEnvironmentInjectable = getInjectable({ id: "setup-developer-tools-in-development-environment", - instantiate: (di) => { - const logger = di.inject(loggerInjectable); - const nodeEnv = di.inject(nodeEnvInjectionToken); + instantiate: (di) => ({ + run: () => { + const logger = di.inject(loggerInjectable); + const nodeEnv = di.inject(nodeEnvInjectionToken); - return { - id: "setup-developer-tools-in-development-environment", - run: () => { - if (nodeEnv !== "development") { - return; + if (nodeEnv !== "development") { + return; + } + + logger.info("🤓 Installing developer tools"); + + void (async () => { + try { + const { + default: devToolsInstaller, + REACT_DEVELOPER_TOOLS, + } = await import("electron-devtools-installer"); + + const name = await devToolsInstaller([REACT_DEVELOPER_TOOLS]); + + logger.info(`[DEVTOOLS-INSTALLER]: installed ${name}`); + } catch (error) { + logger.error(`[DEVTOOLS-INSTALLER]: failed`, { error }); } - - logger.info("🤓 Installing developer tools"); - - import("electron-devtools-installer") - .then(({ default: devToolsInstaller, REACT_DEVELOPER_TOOLS }) => - devToolsInstaller([REACT_DEVELOPER_TOOLS]), - ) - .then((name) => - logger.info(`[DEVTOOLS-INSTALLER]: installed ${name}`), - ) - .catch((error) => - logger.error(`[DEVTOOLS-INSTALLER]: failed`, { error }), - ); - }, - }; - }, + })(); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/main/electron-app/runnables/setup-device-shutdown.injectable.ts b/packages/core/src/main/electron-app/runnables/setup-device-shutdown.injectable.ts index 8c3c21ae30..a8502d3738 100644 --- a/packages/core/src/main/electron-app/runnables/setup-device-shutdown.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/setup-device-shutdown.injectable.ts @@ -5,24 +5,19 @@ import { getInjectable } from "@ogre-tools/injectable"; import powerMonitorInjectable from "../features/power-monitor.injectable"; import exitAppInjectable from "../features/exit-app.injectable"; -import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases"; const setupDeviceShutdownInjectable = getInjectable({ id: "setup-device-shutdown", - instantiate: (di) => { - const powerMonitor = di.inject(powerMonitorInjectable); - const exitApp = di.inject(exitAppInjectable); + instantiate: (di) => ({ + run: () => { + const powerMonitor = di.inject(powerMonitorInjectable); + const exitApp = di.inject(exitAppInjectable); - return { - id: "setup-device-shutdown", - run: () => { - powerMonitor.on("shutdown", async () => { - exitApp(); - }); - }, - }; - }, + powerMonitor.on("shutdown", exitApp); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/main/electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.injectable.ts b/packages/core/src/main/electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.injectable.ts index b8a869f7fe..0781ee04c3 100644 --- a/packages/core/src/main/electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.injectable.ts @@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable"; import { setupIpcMainHandlers } from "./setup-ipc-main-handlers"; import loggerInjectable from "../../../../common/logger.injectable"; import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.injectable"; -import { onLoadOfApplicationInjectionToken } from "../../../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../../start-main-application/runnable-tokens/phases"; import applicationMenuItemCompositeInjectable from "../../../../features/application-menu/main/application-menu-item-composite.injectable"; import emitAppEventInjectable from "../../../../common/app-event-bus/emit-event.injectable"; import getClusterByIdInjectable from "../../../../common/cluster-store/get-by-id.injectable"; @@ -15,29 +15,26 @@ import pushCatalogToRendererInjectable from "../../../catalog-sync-to-renderer/p const setupIpcMainHandlersInjectable = getInjectable({ id: "setup-ipc-main-handlers", - instantiate: (di) => { - const logger = di.inject(loggerInjectable); - const applicationMenuItemComposite = di.inject(applicationMenuItemCompositeInjectable); - const pushCatalogToRenderer = di.inject(pushCatalogToRendererInjectable); - const clusterStore = di.inject(clusterStoreInjectable); - const emitAppEvent = di.inject(emitAppEventInjectable); - const getClusterById = di.inject(getClusterByIdInjectable); + instantiate: (di) => ({ + run: () => { + const logger = di.inject(loggerInjectable); + const applicationMenuItemComposite = di.inject(applicationMenuItemCompositeInjectable); + const pushCatalogToRenderer = di.inject(pushCatalogToRendererInjectable); + const clusterStore = di.inject(clusterStoreInjectable); + const emitAppEvent = di.inject(emitAppEventInjectable); + const getClusterById = di.inject(getClusterByIdInjectable); - return { - id: "setup-ipc-main-handlers", - run: () => { - logger.debug("[APP-MAIN] initializing ipc main handlers"); + logger.debug("[APP-MAIN] initializing ipc main handlers"); - setupIpcMainHandlers({ - applicationMenuItemComposite, - pushCatalogToRenderer, - clusterStore, - emitAppEvent, - getClusterById, - }); - }, - }; - }, + setupIpcMainHandlers({ + applicationMenuItemComposite, + pushCatalogToRenderer, + clusterStore, + emitAppEvent, + getClusterById, + }); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, causesSideEffects: true, diff --git a/packages/core/src/main/electron-app/runnables/setup-main-window-visibility-after-activation.injectable.ts b/packages/core/src/main/electron-app/runnables/setup-main-window-visibility-after-activation.injectable.ts index c32cfe0765..90ca7c73cb 100644 --- a/packages/core/src/main/electron-app/runnables/setup-main-window-visibility-after-activation.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/setup-main-window-visibility-after-activation.injectable.ts @@ -5,30 +5,27 @@ import { getInjectable } from "@ogre-tools/injectable"; import electronAppInjectable from "../electron-app.injectable"; import loggerInjectable from "../../../common/logger.injectable"; -import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import showApplicationWindowInjectable from "../../start-main-application/lens-window/show-application-window.injectable"; const setupMainWindowVisibilityAfterActivationInjectable = getInjectable({ id: "setup-main-window-visibility-after-activation", - instantiate: (di) => { - const app = di.inject(electronAppInjectable); - const showApplicationWindow = di.inject(showApplicationWindowInjectable); - const logger = di.inject(loggerInjectable); + instantiate: (di) => ({ + run: () => { + const app = di.inject(electronAppInjectable); + const showApplicationWindow = di.inject(showApplicationWindowInjectable); + const logger = di.inject(loggerInjectable); - return { - id: "setup-main-window-visibility-after-activation", - run: () => { - app.on("activate", async (_, windowIsVisible) => { - logger.info("APP:ACTIVATE", { hasVisibleWindows: windowIsVisible }); + app.on("activate", (_, windowIsVisible) => { + logger.info("APP:ACTIVATE", { hasVisibleWindows: windowIsVisible }); - if (!windowIsVisible) { - await showApplicationWindow(); - } - }); - }, - }; - }, + if (!windowIsVisible) { + void showApplicationWindow(); + } + }); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/main/electron-app/runnables/setup-runnables-after-window-is-opened.injectable.ts b/packages/core/src/main/electron-app/runnables/setup-runnables-after-window-is-opened.injectable.ts index dc80998de0..2d4461e423 100644 --- a/packages/core/src/main/electron-app/runnables/setup-runnables-after-window-is-opened.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/setup-runnables-after-window-is-opened.injectable.ts @@ -3,29 +3,25 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { beforeElectronIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/before-electron-is-ready-injection-token"; +import { beforeElectronIsReadyInjectionToken, afterWindowIsOpenedInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import electronAppInjectable from "../electron-app.injectable"; import { runManyFor } from "../../../common/runnable/run-many-for"; -import { afterWindowIsOpenedInjectionToken } from "../../start-main-application/runnable-tokens/after-window-is-opened-injection-token"; const setupRunnablesAfterWindowIsOpenedInjectable = getInjectable({ id: "setup-runnables-after-window-is-opened", - instantiate: (di) => { - const afterWindowIsOpened = runManyFor(di)(afterWindowIsOpenedInjectionToken); - const app = di.inject(electronAppInjectable); + instantiate: (di) => ({ + run: () => { + const afterWindowIsOpened = runManyFor(di)(afterWindowIsOpenedInjectionToken); + const app = di.inject(electronAppInjectable); - return { - id: "setup-runnables-after-window-is-opened", - run: () => { - app.on("browser-window-created", () => { - afterWindowIsOpened(); - }); + app.on("browser-window-created", () => { + afterWindowIsOpened(); + }); - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeElectronIsReadyInjectionToken, }); diff --git a/packages/core/src/main/electron-app/runnables/setup-runnables-before-closing-of-application.injectable.ts b/packages/core/src/main/electron-app/runnables/setup-runnables-before-closing-of-application.injectable.ts index c0bc3ae620..d8cdbaa01b 100644 --- a/packages/core/src/main/electron-app/runnables/setup-runnables-before-closing-of-application.injectable.ts +++ b/packages/core/src/main/electron-app/runnables/setup-runnables-before-closing-of-application.injectable.ts @@ -3,9 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { beforeElectronIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/before-electron-is-ready-injection-token"; -import { beforeQuitOfFrontEndInjectionToken } from "../../start-main-application/runnable-tokens/before-quit-of-front-end-injection-token"; -import { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; +import { beforeElectronIsReadyInjectionToken, beforeQuitOfFrontEndInjectionToken, beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import electronAppInjectable from "../electron-app.injectable"; import isIntegrationTestingInjectable from "../../../common/vars/is-integration-testing.injectable"; import autoUpdaterInjectable from "../features/auto-updater.injectable"; @@ -14,40 +12,36 @@ import { runManySyncFor } from "../../../common/runnable/run-many-sync-for"; const setupRunnablesBeforeClosingOfApplicationInjectable = getInjectable({ id: "setup-closing-of-application", - instantiate: (di) => { - const runManySync = runManySyncFor(di); - const runRunnablesBeforeQuitOfFrontEnd = runManySync(beforeQuitOfFrontEndInjectionToken); - const runRunnablesBeforeQuitOfBackEnd = runManySync(beforeQuitOfBackEndInjectionToken); - const app = di.inject(electronAppInjectable); - const isIntegrationTesting = di.inject(isIntegrationTestingInjectable); - const autoUpdater = di.inject(autoUpdaterInjectable); + instantiate: (di) => ({ + run: () => { + const runManySync = runManySyncFor(di); + const runRunnablesBeforeQuitOfFrontEnd = runManySync(beforeQuitOfFrontEndInjectionToken); + const runRunnablesBeforeQuitOfBackEnd = runManySync(beforeQuitOfBackEndInjectionToken); + const app = di.inject(electronAppInjectable); + const isIntegrationTesting = di.inject(isIntegrationTestingInjectable); + const autoUpdater = di.inject(autoUpdaterInjectable); + let isAutoUpdating = false; - return { - id: "setup-closing-of-application", - run: () => { - let isAutoUpdating = false; + autoUpdater.on("before-quit-for-update", () => { + isAutoUpdating = true; + }); - autoUpdater.on("before-quit-for-update", () => { - isAutoUpdating = true; - }); + app.on("will-quit", (event) => { + runRunnablesBeforeQuitOfFrontEnd(); - app.on("will-quit", (event) => { - runRunnablesBeforeQuitOfFrontEnd(); + const shouldQuitBackEnd = isIntegrationTesting || isAutoUpdating; - const shouldQuitBackEnd = isIntegrationTesting || isAutoUpdating; + if (shouldQuitBackEnd) { + runRunnablesBeforeQuitOfBackEnd(); + } else { + // IMPORTANT: This cannot be destructured as it would break binding of "this" for the Electron event + event.preventDefault(); + } + }); - if (shouldQuitBackEnd) { - runRunnablesBeforeQuitOfBackEnd(); - } else { - // IMPORTANT: This cannot be destructured as it would break binding of "this" for the Electron event - event.preventDefault(); - } - }); - - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeElectronIsReadyInjectionToken, }); diff --git a/packages/core/src/main/library.ts b/packages/core/src/main/library.ts index ab1f56528e..ab5d681935 100644 --- a/packages/core/src/main/library.ts +++ b/packages/core/src/main/library.ts @@ -4,10 +4,12 @@ */ // @experimental -export { afterApplicationIsLoadedInjectionToken } from "./start-main-application/runnable-tokens/after-application-is-loaded-injection-token"; -export { beforeApplicationIsLoadingInjectionToken } from "./start-main-application/runnable-tokens/before-application-is-loading-injection-token"; -export { beforeElectronIsReadyInjectionToken } from "./start-main-application/runnable-tokens/before-electron-is-ready-injection-token"; -export { onLoadOfApplicationInjectionToken } from "./start-main-application/runnable-tokens/on-load-of-application-injection-token"; +export { + afterApplicationIsLoadedInjectionToken, + beforeApplicationIsLoadingInjectionToken, + beforeElectronIsReadyInjectionToken, + onLoadOfApplicationInjectionToken, +} from "./start-main-application/runnable-tokens/phases"; export { createApplication } from "./create-app"; export type { CreateApplication, Application, ApplicationConfig } from "../common/create-app"; export * as Mobx from "mobx"; diff --git a/packages/core/src/main/start-main-application/lens-window/get-visible-windows.injectable.ts b/packages/core/src/main/start-main-application/lens-window/get-visible-windows.injectable.ts index f8e1ceb562..f22e064ca4 100644 --- a/packages/core/src/main/start-main-application/lens-window/get-visible-windows.injectable.ts +++ b/packages/core/src/main/start-main-application/lens-window/get-visible-windows.injectable.ts @@ -2,23 +2,16 @@ * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ -import { pipeline } from "@ogre-tools/fp"; import { getInjectable } from "@ogre-tools/injectable"; -import { filter } from "lodash/fp"; import { applicationWindowInjectionToken } from "./application-window/application-window-injection-token"; const getVisibleWindowsInjectable = getInjectable({ id: "get-visible-windows", - instantiate: (di) => { - const getAllLensWindows = () => di.injectMany(applicationWindowInjectionToken); - - return () => - pipeline( - getAllLensWindows(), - filter((lensWindow) => !!lensWindow.isVisible), - ); - }, + instantiate: (di) => () => ( + di.injectMany(applicationWindowInjectionToken) + .filter(window => window.isVisible) + ), }); export default getVisibleWindowsInjectable; diff --git a/packages/core/src/main/start-main-application/runnable-tokens/after-application-is-loaded-injection-token.ts b/packages/core/src/main/start-main-application/runnable-tokens/after-application-is-loaded-injection-token.ts deleted file mode 100644 index f89f445ecf..0000000000 --- a/packages/core/src/main/start-main-application/runnable-tokens/after-application-is-loaded-injection-token.ts +++ /dev/null @@ -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 { Runnable } from "../../../common/runnable/run-many-for"; - -export const afterApplicationIsLoadedInjectionToken = getInjectionToken({ - id: "after-application-is-loaded", -}); diff --git a/packages/core/src/main/start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token.ts b/packages/core/src/main/start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token.ts deleted file mode 100644 index f066c124ba..0000000000 --- a/packages/core/src/main/start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token.ts +++ /dev/null @@ -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 { Runnable } from "../../../common/runnable/run-many-for"; - -export const afterRootFrameIsReadyInjectionToken = getInjectionToken({ - id: "after-root-frame-is-ready", -}); diff --git a/packages/core/src/main/start-main-application/runnable-tokens/after-window-is-opened-injection-token.ts b/packages/core/src/main/start-main-application/runnable-tokens/after-window-is-opened-injection-token.ts deleted file mode 100644 index d5f33bceff..0000000000 --- a/packages/core/src/main/start-main-application/runnable-tokens/after-window-is-opened-injection-token.ts +++ /dev/null @@ -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 { Runnable } from "../../../common/runnable/run-many-for"; - -export const afterWindowIsOpenedInjectionToken = getInjectionToken({ - id: "after-window-is-opened", -}); diff --git a/packages/core/src/main/start-main-application/runnable-tokens/before-application-is-loading-injection-token.ts b/packages/core/src/main/start-main-application/runnable-tokens/before-application-is-loading-injection-token.ts deleted file mode 100644 index 7cda9e6aee..0000000000 --- a/packages/core/src/main/start-main-application/runnable-tokens/before-application-is-loading-injection-token.ts +++ /dev/null @@ -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 { Runnable } from "../../../common/runnable/run-many-for"; - -export const beforeApplicationIsLoadingInjectionToken = getInjectionToken({ - id: "before-application-is-loading", -}); diff --git a/packages/core/src/main/start-main-application/runnable-tokens/before-electron-is-ready-injection-token.ts b/packages/core/src/main/start-main-application/runnable-tokens/before-electron-is-ready-injection-token.ts deleted file mode 100644 index 4bdef1ff90..0000000000 --- a/packages/core/src/main/start-main-application/runnable-tokens/before-electron-is-ready-injection-token.ts +++ /dev/null @@ -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({ - id: "before-electron-is-ready", -}); diff --git a/packages/core/src/main/start-main-application/runnable-tokens/before-quit-of-back-end-injection-token.ts b/packages/core/src/main/start-main-application/runnable-tokens/before-quit-of-back-end-injection-token.ts deleted file mode 100644 index d11ecf57d2..0000000000 --- a/packages/core/src/main/start-main-application/runnable-tokens/before-quit-of-back-end-injection-token.ts +++ /dev/null @@ -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 beforeQuitOfBackEndInjectionToken = getInjectionToken({ - id: "before-quit-of-back-end", -}); diff --git a/packages/core/src/main/start-main-application/runnable-tokens/before-quit-of-front-end-injection-token.ts b/packages/core/src/main/start-main-application/runnable-tokens/before-quit-of-front-end-injection-token.ts deleted file mode 100644 index 0a45a684cd..0000000000 --- a/packages/core/src/main/start-main-application/runnable-tokens/before-quit-of-front-end-injection-token.ts +++ /dev/null @@ -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 beforeQuitOfFrontEndInjectionToken = getInjectionToken({ - id: "before-quit-of-front-end", -}); diff --git a/packages/core/src/main/start-main-application/runnable-tokens/on-load-of-application-injection-token.ts b/packages/core/src/main/start-main-application/runnable-tokens/on-load-of-application-injection-token.ts deleted file mode 100644 index 35b7a6c0ff..0000000000 --- a/packages/core/src/main/start-main-application/runnable-tokens/on-load-of-application-injection-token.ts +++ /dev/null @@ -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 { Runnable } from "../../../common/runnable/run-many-for"; - -export const onLoadOfApplicationInjectionToken = getInjectionToken({ - id: "on-load-of-application", -}); diff --git a/packages/core/src/main/start-main-application/runnable-tokens/phases.ts b/packages/core/src/main/start-main-application/runnable-tokens/phases.ts index 0b61ae88f2..b33d34f39a 100644 --- a/packages/core/src/main/start-main-application/runnable-tokens/phases.ts +++ b/packages/core/src/main/start-main-application/runnable-tokens/phases.ts @@ -4,8 +4,7 @@ */ 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"; +import type { Runnable, RunnableSync } from "../../../common/runnable/types"; /** * These tokens are here so that the importing of their respective dependencies @@ -26,3 +25,35 @@ export const showLoadingRunnablePhaseInjectionToken = getInjectionToken({ id: "show-initial-window-runnable-phase", }); + +export const onLoadOfApplicationInjectionToken = getInjectionToken({ + id: "on-load-of-application", +}); + +export const beforeQuitOfFrontEndInjectionToken = getInjectionToken({ + id: "before-quit-of-front-end", +}); + +export const beforeQuitOfBackEndInjectionToken = getInjectionToken({ + id: "before-quit-of-back-end", +}); + +export const beforeElectronIsReadyInjectionToken = getInjectionToken({ + id: "before-electron-is-ready", +}); + +export const beforeApplicationIsLoadingInjectionToken = getInjectionToken({ + id: "before-application-is-loading", +}); + +export const afterWindowIsOpenedInjectionToken = getInjectionToken({ + id: "after-window-is-opened", +}); + +export const afterRootFrameIsReadyInjectionToken = getInjectionToken({ + id: "after-root-frame-is-ready", +}); + +export const afterApplicationIsLoadedInjectionToken = getInjectionToken({ + id: "after-application-is-loaded", +}); diff --git a/packages/core/src/main/start-main-application/runnables/clean-up-shell-sessions.injectable.ts b/packages/core/src/main/start-main-application/runnables/clean-up-shell-sessions.injectable.ts index 46afa5e692..2388f0fa73 100644 --- a/packages/core/src/main/start-main-application/runnables/clean-up-shell-sessions.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/clean-up-shell-sessions.injectable.ts @@ -3,14 +3,13 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { beforeQuitOfBackEndInjectionToken } from "../runnable-tokens/before-quit-of-back-end-injection-token"; +import { beforeQuitOfBackEndInjectionToken } from "../runnable-tokens/phases"; import { ShellSession } from "../../shell-session/shell-session"; const cleanUpShellSessionsInjectable = getInjectable({ id: "clean-up-shell-sessions", instantiate: () => ({ - id: "clean-up-shell-sessions", run: () => void ShellSession.cleanup(), }), diff --git a/packages/core/src/main/start-main-application/runnables/emit-close-to-event-bus.injectable.ts b/packages/core/src/main/start-main-application/runnables/emit-close-to-event-bus.injectable.ts index e1da8c1d67..cbd7a2d289 100644 --- a/packages/core/src/main/start-main-application/runnables/emit-close-to-event-bus.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/emit-close-to-event-bus.injectable.ts @@ -4,23 +4,20 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import emitAppEventInjectable from "../../../common/app-event-bus/emit-event.injectable"; -import { beforeQuitOfFrontEndInjectionToken } from "../runnable-tokens/before-quit-of-front-end-injection-token"; +import { beforeQuitOfFrontEndInjectionToken } from "../runnable-tokens/phases"; const emitCloseToEventBusInjectable = getInjectable({ id: "emit-close-to-event-bus", - instantiate: (di) => { - const emitAppEvent = di.inject(emitAppEventInjectable); + instantiate: (di) => ({ + run: () => { + const emitAppEvent = di.inject(emitAppEventInjectable); - return { - id: "emit-close-to-event-bus", - run: () => { - emitAppEvent({ name: "app", action: "close" }); + emitAppEvent({ name: "app", action: "close" }); - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeQuitOfFrontEndInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/emit-service-start-to-event-bus.injectable.ts b/packages/core/src/main/start-main-application/runnables/emit-service-start-to-event-bus.injectable.ts index 9655748a72..8d9e8a1a38 100644 --- a/packages/core/src/main/start-main-application/runnables/emit-service-start-to-event-bus.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/emit-service-start-to-event-bus.injectable.ts @@ -4,21 +4,18 @@ */ 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 "../runnable-tokens/phases"; const emitServiceStartToEventBusInjectable = getInjectable({ id: "emit-service-start-to-event-bus", - instantiate: (di) => { - const emitAppEvent = di.inject(emitAppEventInjectable); + instantiate: (di) => ({ + run: () => { + const emitAppEvent = di.inject(emitAppEventInjectable); - return { - id: "emit-service-start-to-event-bus", - run: () => { - emitAppEvent({ name: "service", action: "start" }); - }, - }; - }, + emitAppEvent({ name: "service", action: "start" }); + }, + }), injectionToken: afterApplicationIsLoadedInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/flag-renderer/flag-renderer-as-loaded.injectable.ts b/packages/core/src/main/start-main-application/runnables/flag-renderer/flag-renderer-as-loaded.injectable.ts index 2bb05cfb52..2fe71ed7d5 100644 --- a/packages/core/src/main/start-main-application/runnables/flag-renderer/flag-renderer-as-loaded.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/flag-renderer/flag-renderer-as-loaded.injectable.ts @@ -3,26 +3,23 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { afterRootFrameIsReadyInjectionToken } from "../../runnable-tokens/after-root-frame-is-ready-injection-token"; +import { afterRootFrameIsReadyInjectionToken } from "../../runnable-tokens/phases"; import lensProtocolRouterMainInjectable from "../../../protocol-handler/lens-protocol-router-main/lens-protocol-router-main.injectable"; import { runInAction } from "mobx"; const flagRendererAsLoadedInjectable = getInjectable({ id: "flag-renderer-as-loaded", - instantiate: (di) => { - const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable); + instantiate: (di) => ({ + run: () => { + const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable); - return { - id: "flag-renderer-as-loaded", - run: () => { - runInAction(() => { - // Todo: remove this kludge which enables out-of-place temporal dependency. - lensProtocolRouterMain.rendererLoaded = true; - }); - }, - }; - }, + runInAction(() => { + // Todo: remove this kludge which enables out-of-place temporal dependency. + lensProtocolRouterMain.rendererLoaded = true; + }); + }, + }), injectionToken: afterRootFrameIsReadyInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/flag-renderer/flag-renderer-as-not-loaded.injectable.ts b/packages/core/src/main/start-main-application/runnables/flag-renderer/flag-renderer-as-not-loaded.injectable.ts index d5f7444232..899b234f39 100644 --- a/packages/core/src/main/start-main-application/runnables/flag-renderer/flag-renderer-as-not-loaded.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/flag-renderer/flag-renderer-as-not-loaded.injectable.ts @@ -5,26 +5,23 @@ import { getInjectable } from "@ogre-tools/injectable"; import { runInAction } from "mobx"; import lensProtocolRouterMainInjectable from "../../../protocol-handler/lens-protocol-router-main/lens-protocol-router-main.injectable"; -import { beforeQuitOfFrontEndInjectionToken } from "../../runnable-tokens/before-quit-of-front-end-injection-token"; +import { beforeQuitOfFrontEndInjectionToken } from "../../runnable-tokens/phases"; const flagRendererAsNotLoadedInjectable = getInjectable({ id: "stop-deep-linking", - instantiate: (di) => { - const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable); + instantiate: (di) => ({ + run: () => { + const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable); - return { - id: "stop-deep-linking", - run: () => { - runInAction(() => { - // Todo: remove this kludge which enables out-of-place temporal dependency. - lensProtocolRouterMain.rendererLoaded = false; - }); + runInAction(() => { + // Todo: remove this kludge which enables out-of-place temporal dependency. + lensProtocolRouterMain.rendererLoaded = false; + }); - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeQuitOfFrontEndInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/initialize-extensions.injectable.ts b/packages/core/src/main/start-main-application/runnables/initialize-extensions.injectable.ts index 8765721d90..14ef494e02 100644 --- a/packages/core/src/main/start-main-application/runnables/initialize-extensions.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/initialize-extensions.injectable.ts @@ -9,56 +9,51 @@ 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 "../runnable-tokens/phases"; const initializeExtensionsInjectable = getInjectable({ id: "initialize-extensions", - instantiate: (di) => { - const logger = di.inject(loggerInjectable); - const extensionDiscovery = di.inject(extensionDiscoveryInjectable); - const extensionLoader = di.inject(extensionLoaderInjectable); - const showErrorPopup = di.inject(showErrorPopupInjectable); + instantiate: (di) => ({ + run: async () => { + const logger = di.inject(loggerInjectable); + const extensionDiscovery = di.inject(extensionDiscoveryInjectable); + const extensionLoader = di.inject(extensionLoaderInjectable); + const showErrorPopup = di.inject(showErrorPopupInjectable); - return { - id: "initialize-extensions", - run: async () => { - logger.info("🧩 Initializing extensions"); + logger.info("🧩 Initializing extensions"); - await extensionDiscovery.init(); + await extensionDiscovery.init(); - await extensionLoader.init(); + await extensionLoader.init(); - try { - const extensions = await extensionDiscovery.load(); + try { + const extensions = await extensionDiscovery.load(); - // Start watching after bundled extensions are loaded - extensionDiscovery.watchExtensions(); + // Start watching after bundled extensions are loaded + extensionDiscovery.watchExtensions(); - // Subscribe to extensions that are copied or deleted to/from the extensions folder - extensionDiscovery.events - .on("add", (extension: InstalledExtension) => { - extensionLoader.addExtension(extension); - }) - .on("remove", (lensExtensionId: LensExtensionId) => { - extensionLoader.removeExtension(lensExtensionId); - }); + // Subscribe to extensions that are copied or deleted to/from the extensions folder + extensionDiscovery.events + .on("add", (extension: InstalledExtension) => { + extensionLoader.addExtension(extension); + }) + .on("remove", (lensExtensionId: LensExtensionId) => { + extensionLoader.removeExtension(lensExtensionId); + }); - extensionLoader.initExtensions(extensions); - } catch (error: any) { - showErrorPopup( - "Lens Error", - `Could not load extensions${ - error?.message ? `: ${error.message}` : "" - }`, - ); + extensionLoader.initExtensions(extensions); + } catch (error: any) { + showErrorPopup( + "Lens Error", + `Could not load extensions${error?.message ? `: ${error.message}` : ""}`, + ); - console.error(error); - console.trace(); - } - }, - }; - }, + console.error(error); + console.trace(); + } + }, + }), causesSideEffects: true, diff --git a/packages/core/src/main/start-main-application/runnables/kube-config-sync/add-source.injectable.ts b/packages/core/src/main/start-main-application/runnables/kube-config-sync/add-source.injectable.ts index f95a39f665..a9117e840d 100644 --- a/packages/core/src/main/start-main-application/runnables/kube-config-sync/add-source.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/kube-config-sync/add-source.injectable.ts @@ -5,21 +5,18 @@ 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 "../../runnable-tokens/phases"; const addKubeconfigSyncAsEntitySourceInjectable = getInjectable({ id: "add-kubeconfig-sync-as-entity-source", - instantiate: (di) => { - const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable); - const entityRegistry = di.inject(catalogEntityRegistryInjectable); + instantiate: (di) => ({ + run: () => { + const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable); + const entityRegistry = di.inject(catalogEntityRegistryInjectable); - return { - id: "add-kubeconfig-sync-as-entity-source", - run: () => { - entityRegistry.addComputedSource("kubeconfig-sync", kubeConfigSyncManager.source); - }, - }; - }, + entityRegistry.addComputedSource("kubeconfig-sync", kubeConfigSyncManager.source); + }, + }), injectionToken: afterApplicationIsLoadedInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/kube-config-sync/start-kube-config-sync.injectable.ts b/packages/core/src/main/start-main-application/runnables/kube-config-sync/start-kube-config-sync.injectable.ts index 1dbadc4246..f1f5c34510 100644 --- a/packages/core/src/main/start-main-application/runnables/kube-config-sync/start-kube-config-sync.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/kube-config-sync/start-kube-config-sync.injectable.ts @@ -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 "../../runnable-tokens/phases"; 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"; @@ -12,21 +12,18 @@ import addKubeconfigSyncAsEntitySourceInjectable from "./add-source.injectable"; const startKubeConfigSyncInjectable = getInjectable({ id: "start-kubeconfig-sync", - instantiate: (di) => { - const directoryForKubeConfigs = di.inject(directoryForKubeConfigsInjectable); - const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable); - const ensureDir = di.inject(ensureDirInjectable); + instantiate: (di) => ({ + run: async () => { + const directoryForKubeConfigs = di.inject(directoryForKubeConfigsInjectable); + const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable); + const ensureDir = di.inject(ensureDirInjectable); - return { - id: "start-kubeconfig-sync", - run: async () => { - await ensureDir(directoryForKubeConfigs); + await ensureDir(directoryForKubeConfigs); - kubeConfigSyncManager.startSync(); - }, - runAfter: di.inject(addKubeconfigSyncAsEntitySourceInjectable), - }; - }, + kubeConfigSyncManager.startSync(); + }, + runAfter: addKubeconfigSyncAsEntitySourceInjectable, + }), injectionToken: afterApplicationIsLoadedInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/kube-config-sync/stop-kube-config-sync.injectable.ts b/packages/core/src/main/start-main-application/runnables/kube-config-sync/stop-kube-config-sync.injectable.ts index 4cb5a98a3f..118dac2ed4 100644 --- a/packages/core/src/main/start-main-application/runnables/kube-config-sync/stop-kube-config-sync.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/kube-config-sync/stop-kube-config-sync.injectable.ts @@ -3,20 +3,21 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { beforeQuitOfBackEndInjectionToken } from "../../runnable-tokens/before-quit-of-back-end-injection-token"; +import { beforeQuitOfBackEndInjectionToken } from "../../runnable-tokens/phases"; import kubeconfigSyncManagerInjectable from "../../../catalog-sources/kubeconfig-sync/manager.injectable"; const stopKubeConfigSyncInjectable = getInjectable({ id: "stop-kube-config-sync", - instantiate: (di) => { - const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable); + instantiate: (di) => ({ + run: () => { + const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable); - return { - id: "stop-kube-config-sync", - run: () => void kubeConfigSyncManager.stopSync(), - }; - }, + kubeConfigSyncManager.stopSync(); + + return undefined; + }, + }), injectionToken: beforeQuitOfBackEndInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/root-frame-has-rendered/channel-listener.injectable.ts b/packages/core/src/main/start-main-application/runnables/root-frame-has-rendered/channel-listener.injectable.ts index 40f5ceb788..bef7b5a490 100644 --- a/packages/core/src/main/start-main-application/runnables/root-frame-has-rendered/channel-listener.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/root-frame-has-rendered/channel-listener.injectable.ts @@ -5,7 +5,7 @@ import { getMessageChannelListenerInjectable } from "../../../../common/utils/channel/message-channel-listener-injection-token"; import { rootFrameHasRenderedChannel } from "../../../../common/root-frame/root-frame-rendered-channel"; import { runManyFor } from "../../../../common/runnable/run-many-for"; -import { afterRootFrameIsReadyInjectionToken } from "../../runnable-tokens/after-root-frame-is-ready-injection-token"; +import { afterRootFrameIsReadyInjectionToken } from "../../runnable-tokens/phases"; const rootFrameRenderedChannelListenerInjectable = getMessageChannelListenerInjectable({ id: "action", diff --git a/packages/core/src/main/start-main-application/runnables/sentry/setup.injectable.ts b/packages/core/src/main/start-main-application/runnables/sentry/setup.injectable.ts index 6d4111ae78..54504caa68 100644 --- a/packages/core/src/main/start-main-application/runnables/sentry/setup.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/sentry/setup.injectable.ts @@ -3,21 +3,22 @@ * 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 "../../runnable-tokens/phases"; import initializeSentryReportingWithInjectable from "../../../../common/error-reporting/initialize-sentry-reporting.injectable"; import initializeSentryOnMainInjectable from "./initialize-on-main.injectable"; const setupSentryInjectable = getInjectable({ id: "setup-sentry", - instantiate: (di) => { - const initializeSentryReportingWith = di.inject(initializeSentryReportingWithInjectable); - const initializeSentryOnMain = di.inject(initializeSentryOnMainInjectable); + instantiate: (di) => ({ + run: () => { + const initializeSentryReportingWith = di.inject(initializeSentryReportingWithInjectable); + const initializeSentryOnMain = di.inject(initializeSentryOnMainInjectable); - return { - id: "setup-sentry", - run: () => void initializeSentryReportingWith(initializeSentryOnMain), - }; - }, + initializeSentryReportingWith(initializeSentryOnMain); + + return undefined; + }, + }), injectionToken: beforeElectronIsReadyInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/setup-hardware-acceleration.injectable.ts b/packages/core/src/main/start-main-application/runnables/setup-hardware-acceleration.injectable.ts index ffcff08434..f78c9fc4f6 100644 --- a/packages/core/src/main/start-main-application/runnables/setup-hardware-acceleration.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/setup-hardware-acceleration.injectable.ts @@ -5,26 +5,23 @@ 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 "../runnable-tokens/phases"; const setupHardwareAccelerationInjectable = getInjectable({ id: "setup-hardware-acceleration", - instantiate: (di) => { - const hardwareAccelerationShouldBeDisabled = di.inject(hardwareAccelerationShouldBeDisabledInjectable); - const disableHardwareAcceleration = di.inject(disableHardwareAccelerationInjectable); + instantiate: (di) => ({ + run: () => { + const hardwareAccelerationShouldBeDisabled = di.inject(hardwareAccelerationShouldBeDisabledInjectable); + const disableHardwareAcceleration = di.inject(disableHardwareAccelerationInjectable); - return { - id: "setup-hardware-acceleration", - run: () => { - if (hardwareAccelerationShouldBeDisabled) { - disableHardwareAcceleration(); - } + if (hardwareAccelerationShouldBeDisabled) { + disableHardwareAcceleration(); + } - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeElectronIsReadyInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/setup-hostnames.injectable.ts b/packages/core/src/main/start-main-application/runnables/setup-hostnames.injectable.ts index 265ff49162..312baa19fb 100644 --- a/packages/core/src/main/start-main-application/runnables/setup-hostnames.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/setup-hostnames.injectable.ts @@ -4,27 +4,24 @@ */ 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 "../runnable-tokens/phases"; const setupHostnamesInjectable = getInjectable({ id: "setup-hostnames", - instantiate: (di) => { - const app = di.inject(electronAppInjectable); + instantiate: (di) => ({ + run: () => { + const app = di.inject(electronAppInjectable); - return { - id: "setup-hostnames", - run: () => { - app.commandLine.appendSwitch("host-rules", [ - "MAP localhost 127.0.0.1", - "MAP lens.app 127.0.0.1", - "MAP *.lens.app 127.0.0.1", - ].join()); + app.commandLine.appendSwitch("host-rules", [ + "MAP localhost 127.0.0.1", + "MAP lens.app 127.0.0.1", + "MAP *.lens.app 127.0.0.1", + ].join()); - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeElectronIsReadyInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/setup-immer.injectable.ts b/packages/core/src/main/start-main-application/runnables/setup-immer.injectable.ts index 61420cf35b..fb36d3f491 100644 --- a/packages/core/src/main/start-main-application/runnables/setup-immer.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/setup-immer.injectable.ts @@ -3,19 +3,18 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import * as Immer from "immer"; -import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/before-electron-is-ready-injection-token"; +import { setAutoFreeze, enableMapSet } from "immer"; +import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/phases"; const setupImmerInjectable = getInjectable({ id: "setup-immer", instantiate: () => ({ - id: "setup-immer", run: () => { // Docs: https://immerjs.github.io/immer/ // Required in `utils/storage-helper.ts` - Immer.setAutoFreeze(false); // allow to merge mobx observables - Immer.enableMapSet(); // allow to merge maps and sets + setAutoFreeze(false); // allow to merge mobx observables + enableMapSet(); // allow to merge maps and sets return undefined; }, diff --git a/packages/core/src/main/start-main-application/runnables/setup-lens-proxy-certificate.injectable.ts b/packages/core/src/main/start-main-application/runnables/setup-lens-proxy-certificate.injectable.ts index 9957877ab5..33bec82906 100644 --- a/packages/core/src/main/start-main-application/runnables/setup-lens-proxy-certificate.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/setup-lens-proxy-certificate.injectable.ts @@ -5,47 +5,44 @@ 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 "../runnable-tokens/phases"; const setupLensProxyCertificateInjectable = getInjectable({ id: "setup-lens-proxy-certificate", - instantiate: (di) => { - const lensProxyCertificate = di.inject(lensProxyCertificateInjectable); + instantiate: (di) => ({ + run: () => { + const lensProxyCertificate = di.inject(lensProxyCertificateInjectable); - return { - id: "setup-lens-proxy-certificate", - run: () => { - const cert = generate([ - { name: "commonName", value: "Lens Certificate Authority" }, - { name: "organizationName", value: "Lens" }, - ], { - keySize: 2048, - algorithm: "sha256", - days: 365, - extensions: [ - { - name: "basicConstraints", - cA: true, - }, - { - name: "subjectAltName", - altNames: [ - { type: 2, value: "*.lens.app" }, - { type: 2, value: "lens.app" }, - { type: 2, value: "localhost" }, - { type: 7, ip: "127.0.0.1" }, - ], - }, - ], - }); + const cert = generate([ + { name: "commonName", value: "Lens Certificate Authority" }, + { name: "organizationName", value: "Lens" }, + ], { + keySize: 2048, + algorithm: "sha256", + days: 365, + extensions: [ + { + name: "basicConstraints", + cA: true, + }, + { + name: "subjectAltName", + altNames: [ + { type: 2, value: "*.lens.app" }, + { type: 2, value: "lens.app" }, + { type: 2, value: "localhost" }, + { type: 7, ip: "127.0.0.1" }, + ], + }, + ], + }); - lensProxyCertificate.set(cert); + lensProxyCertificate.set(cert); - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeElectronIsReadyInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/setup-lens-proxy.injectable.ts b/packages/core/src/main/start-main-application/runnables/setup-lens-proxy.injectable.ts index 69184ddec2..9aa384b308 100644 --- a/packages/core/src/main/start-main-application/runnables/setup-lens-proxy.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/setup-lens-proxy.injectable.ts @@ -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 "../runnable-tokens/phases"; 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"; @@ -19,68 +19,65 @@ import { Agent } from "https"; const setupLensProxyInjectable = getInjectable({ id: "setup-lens-proxy", - instantiate: (di) => { - const lensProxy = di.inject(lensProxyInjectable); - const exitApp = di.inject(exitAppInjectable); - const logger = di.inject(loggerInjectable); - const lensProxyPort = di.inject(lensProxyPortInjectable); - const isWindows = di.inject(isWindowsInjectable); - const showErrorPopup = di.inject(showErrorPopupInjectable); - const buildVersion = di.inject(buildVersionInjectable); - const lensProxyCertificate = di.inject(lensProxyCertificateInjectable); - const fetch = di.inject(fetchInjectable); + instantiate: (di) => ({ + run: async () => { + const lensProxy = di.inject(lensProxyInjectable); + const exitApp = di.inject(exitAppInjectable); + const logger = di.inject(loggerInjectable); + const lensProxyPort = di.inject(lensProxyPortInjectable); + const isWindows = di.inject(isWindowsInjectable); + const showErrorPopup = di.inject(showErrorPopupInjectable); + const buildVersion = di.inject(buildVersionInjectable); + const lensProxyCertificate = di.inject(lensProxyCertificateInjectable); + const fetch = di.inject(fetchInjectable); - return { - id: "setup-lens-proxy", - run: async () => { - try { - logger.info("🔌 Starting LensProxy"); - await lensProxy.listen(); // lensProxy.port available - } catch (error: any) { - showErrorPopup("Lens Error", `Could not start proxy: ${error?.message || "unknown error"}`); + try { + logger.info("🔌 Starting LensProxy"); + await lensProxy.listen(); // lensProxy.port available + } catch (error: any) { + showErrorPopup("Lens Error", `Could not start proxy: ${error?.message || "unknown error"}`); + + return exitApp(); + } + + // test proxy connection + try { + logger.info("🔎 Testing LensProxy connection ..."); + const versionResponse = await fetch(`https://127.0.0.1:${lensProxyPort.get()}/version`, { + agent: new Agent({ + ca: lensProxyCertificate.get()?.cert, + }), + }); + + const { version: versionFromProxy } = await versionResponse.json() as { version: string }; + + if (buildVersion.get() !== versionFromProxy) { + logger.error("Proxy server responded with invalid response"); return exitApp(); } - // test proxy connection - try { - logger.info("🔎 Testing LensProxy connection ..."); - const versionResponse = await fetch(`https://127.0.0.1:${lensProxyPort.get()}/version`, { - agent: new Agent({ - ca: lensProxyCertificate.get()?.cert, - }), - }); + logger.info("⚡ LensProxy connection OK"); + } catch (error) { + logger.error(`🛑 LensProxy: failed connection test: ${error}`); - const { version: versionFromProxy } = await versionResponse.json() as { version: string }; + const hostsPath = isWindows + ? "C:\\windows\\system32\\drivers\\etc\\hosts" + : "/etc/hosts"; + const message = [ + `Failed connection test: ${error}`, + "Check to make sure that no other versions of Lens are running", + `Check ${hostsPath} to make sure that it is clean and that the localhost loopback is at the top and set to 127.0.0.1`, + "If you have HTTP_PROXY or http_proxy set in your environment, make sure that the localhost and the ipv4 loopback address 127.0.0.1 are added to the NO_PROXY environment variable.", + ]; - if (buildVersion.get() !== versionFromProxy) { - logger.error("Proxy server responded with invalid response"); + showErrorPopup("Lens Proxy Error", message.join("\n\n")); - return exitApp(); - } - - logger.info("⚡ LensProxy connection OK"); - } catch (error) { - logger.error(`🛑 LensProxy: failed connection test: ${error}`); - - const hostsPath = isWindows - ? "C:\\windows\\system32\\drivers\\etc\\hosts" - : "/etc/hosts"; - const message = [ - `Failed connection test: ${error}`, - "Check to make sure that no other versions of Lens are running", - `Check ${hostsPath} to make sure that it is clean and that the localhost loopback is at the top and set to 127.0.0.1`, - "If you have HTTP_PROXY or http_proxy set in your environment, make sure that the localhost and the ipv4 loopback address 127.0.0.1 are added to the NO_PROXY environment variable.", - ]; - - showErrorPopup("Lens Proxy Error", message.join("\n\n")); - - return exitApp(); - } - }, - runAfter: di.inject(initializeBuildVersionInjectable), - }; - }, + return exitApp(); + } + }, + runAfter: initializeBuildVersionInjectable, + }), causesSideEffects: true, diff --git a/packages/core/src/main/start-main-application/runnables/setup-mobx.injectable.ts b/packages/core/src/main/start-main-application/runnables/setup-mobx.injectable.ts index d13021cdc6..3352663dd3 100644 --- a/packages/core/src/main/start-main-application/runnables/setup-mobx.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/setup-mobx.injectable.ts @@ -4,13 +4,12 @@ */ 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 "../runnable-tokens/phases"; const setupMobxInjectable = getInjectable({ id: "setup-mobx", instantiate: () => ({ - id: "setup-mobx", run: () => { // Docs: https://mobx.js.org/configuration.html Mobx.configure({ diff --git a/packages/core/src/main/start-main-application/runnables/setup-proxy-env.injectable.ts b/packages/core/src/main/start-main-application/runnables/setup-proxy-env.injectable.ts index 0541c2cfda..96b3dca4b9 100644 --- a/packages/core/src/main/start-main-application/runnables/setup-proxy-env.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/setup-proxy-env.injectable.ts @@ -3,42 +3,37 @@ * 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 "../runnable-tokens/phases"; import getCommandLineSwitchInjectable from "../../electron-app/features/get-command-line-switch.injectable"; const setupProxyEnvInjectable = getInjectable({ id: "setup-proxy-env", - instantiate: (di) => { - const getCommandLineSwitch = di.inject(getCommandLineSwitchInjectable); + instantiate: (di) => ({ + run: () => { + const getCommandLineSwitch = di.inject(getCommandLineSwitchInjectable); + const switchValue = getCommandLineSwitch("proxy-server"); - return { - id: "setup-proxy-env", - run: () => { - const switchValue = getCommandLineSwitch("proxy-server"); + let httpsProxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || ""; - let httpsProxy = - process.env.HTTPS_PROXY || process.env.HTTP_PROXY || ""; + delete process.env.HTTPS_PROXY; + delete process.env.HTTP_PROXY; - delete process.env.HTTPS_PROXY; - delete process.env.HTTP_PROXY; + if (switchValue !== "") { + httpsProxy = switchValue; + } - if (switchValue !== "") { - httpsProxy = switchValue; - } + if (httpsProxy !== "") { + process.env.APP_HTTPS_PROXY = httpsProxy; + } - if (httpsProxy !== "") { - process.env.APP_HTTPS_PROXY = httpsProxy; - } + if (getCommandLineSwitch("proxy-server") !== "") { + process.env.HTTPS_PROXY = getCommandLineSwitch("proxy-server"); + } - if (getCommandLineSwitch("proxy-server") !== "") { - process.env.HTTPS_PROXY = getCommandLineSwitch("proxy-server"); - } - - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeElectronIsReadyInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/setup-syncing-of-general-catalog-entities.injectable.ts b/packages/core/src/main/start-main-application/runnables/setup-syncing-of-general-catalog-entities.injectable.ts index 6dc0b27512..c263ac6195 100644 --- a/packages/core/src/main/start-main-application/runnables/setup-syncing-of-general-catalog-entities.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/setup-syncing-of-general-catalog-entities.injectable.ts @@ -4,23 +4,18 @@ */ 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 "../runnable-tokens/phases"; const setupSyncingOfGeneralCatalogEntitiesInjectable = getInjectable({ id: "setup-syncing-of-general-catalog-entities", - instantiate: (di) => { - const syncGeneralCatalogEntities = di.inject( - syncGeneralCatalogEntitiesInjectable, - ); + instantiate: (di) => ({ + run: () => { + const syncGeneralCatalogEntities = di.inject(syncGeneralCatalogEntitiesInjectable); - return { - id: "setup-syncing-of-general-catalog-entities", - run: () => { - syncGeneralCatalogEntities(); - }, - }; - }, + syncGeneralCatalogEntities(); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/setup-syncing-of-weblinks.injectable.ts b/packages/core/src/main/start-main-application/runnables/setup-syncing-of-weblinks.injectable.ts index fa4e6b436c..058fdcb64b 100644 --- a/packages/core/src/main/start-main-application/runnables/setup-syncing-of-weblinks.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/setup-syncing-of-weblinks.injectable.ts @@ -3,22 +3,19 @@ * 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 "../runnable-tokens/phases"; import syncWeblinksInjectable from "../../catalog-sources/sync-weblinks.injectable"; const setupSyncingOfWeblinksInjectable = getInjectable({ id: "setup-syncing-of-weblinks", - instantiate: (di) => { - const syncWeblinks = di.inject(syncWeblinksInjectable); + instantiate: (di) => ({ + run: () => { + const syncWeblinks = di.inject(syncWeblinksInjectable); - return { - id: "setup-syncing-of-weblinks", - run: () => { - syncWeblinks(); - }, - }; - }, + syncWeblinks(); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/setup-system-ca.injectable.ts b/packages/core/src/main/start-main-application/runnables/setup-system-ca.injectable.ts index e819c42596..9d25476278 100644 --- a/packages/core/src/main/start-main-application/runnables/setup-system-ca.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/setup-system-ca.injectable.ts @@ -3,14 +3,17 @@ * 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 "../runnable-tokens/phases"; import injectSystemCAsInjectable from "../../../features/certificate-authorities/common/inject-system-cas.injectable"; const setupSystemCaInjectable = getInjectable({ id: "setup-system-ca", instantiate: (di) => ({ - id: "setup-system-ca", - run: di.inject(injectSystemCAsInjectable), + run: async () => { + const injectSystemCAs = di.inject(injectSystemCAsInjectable); + + await injectSystemCAs(); + }, }), injectionToken: beforeApplicationIsLoadingInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/show-initial-window.injectable.ts b/packages/core/src/main/start-main-application/runnables/show-initial-window.injectable.ts index 0ce02bfa85..a50396d8fa 100644 --- a/packages/core/src/main/start-main-application/runnables/show-initial-window.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/show-initial-window.injectable.ts @@ -18,33 +18,30 @@ const getDeepLinkUrl = (commandLineArguments: string[]) => ( const showInitialWindowInjectable = getInjectable({ id: "show-initial-window", - instantiate: (di) => { - const shouldStartHidden = di.inject(shouldStartHiddenInjectable); - const shouldStartWindow = !shouldStartHidden; - const createFirstApplicationWindow = di.inject(createFirstApplicationWindowInjectable); - const splashWindow = di.inject(splashWindowInjectable); - const openDeepLink = di.inject(openDeepLinkInjectable); - const commandLineArguments = di.inject(commandLineArgumentsInjectable); + instantiate: (di) => ({ + run: async () => { + const shouldStartHidden = di.inject(shouldStartHiddenInjectable); + const shouldStartWindow = !shouldStartHidden; + const createFirstApplicationWindow = di.inject(createFirstApplicationWindowInjectable); + const splashWindow = di.inject(splashWindowInjectable); + const openDeepLink = di.inject(openDeepLinkInjectable); + const commandLineArguments = di.inject(commandLineArgumentsInjectable); - return { - id: "show-initial-window", - run: async () => { - if (shouldStartWindow) { - const deepLinkUrl = getDeepLinkUrl(commandLineArguments); + if (shouldStartWindow) { + const deepLinkUrl = getDeepLinkUrl(commandLineArguments); - if (deepLinkUrl) { - await openDeepLink(deepLinkUrl); - } else { - const applicationWindow = createFirstApplicationWindow(); + if (deepLinkUrl) { + await openDeepLink(deepLinkUrl); + } else { + const applicationWindow = createFirstApplicationWindow(); - await applicationWindow.start(); - } - - splashWindow.close(); + await applicationWindow.start(); } - }, - }; - }, + + splashWindow.close(); + } + }, + }), injectionToken: showInitialWindowRunnablePhaseInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/show-loading.injectable.ts b/packages/core/src/main/start-main-application/runnables/show-loading.injectable.ts index 2305d4cf3b..162f6a4937 100644 --- a/packages/core/src/main/start-main-application/runnables/show-loading.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/show-loading.injectable.ts @@ -9,20 +9,18 @@ import { showLoadingRunnablePhaseInjectionToken } from "../runnable-tokens/phase const showLoadingInjectable = getInjectable({ id: "show-loading", - instantiate: (di) => { - const shouldStartHidden = di.inject(shouldStartHiddenInjectable); - const shouldShowLoadingWindow = !shouldStartHidden; - const splashWindow = di.inject(splashWindowInjectable); - return { - id: "show-loading", - run: async () => { - if (shouldShowLoadingWindow) { - await splashWindow.start(); - } - }, - }; - }, + instantiate: (di) => ({ + run: async () => { + const shouldStartHidden = di.inject(shouldStartHiddenInjectable); + const shouldShowLoadingWindow = !shouldStartHidden; + const splashWindow = di.inject(splashWindowInjectable); + + if (shouldShowLoadingWindow) { + await splashWindow.start(); + } + }, + }), injectionToken: showLoadingRunnablePhaseInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/runnables/stop-cluster-manager.injectable.ts b/packages/core/src/main/start-main-application/runnables/stop-cluster-manager.injectable.ts index c0a39c51ae..f26feb01d7 100644 --- a/packages/core/src/main/start-main-application/runnables/stop-cluster-manager.injectable.ts +++ b/packages/core/src/main/start-main-application/runnables/stop-cluster-manager.injectable.ts @@ -4,23 +4,20 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import clusterManagerInjectable from "../../cluster/manager.injectable"; -import { beforeQuitOfFrontEndInjectionToken } from "../runnable-tokens/before-quit-of-front-end-injection-token"; +import { beforeQuitOfFrontEndInjectionToken } from "../runnable-tokens/phases"; const stopClusterManagerInjectable = getInjectable({ id: "stop-cluster-manager", - instantiate: (di) => { - const clusterManager = di.inject(clusterManagerInjectable); + instantiate: (di) => ({ + run: () => { + const clusterManager = di.inject(clusterManagerInjectable); - return { - id: "stop-cluster-manager", - run: () => { - clusterManager.stop(); + clusterManager.stop(); - return undefined; - }, - }; - }, + return undefined; + }, + }), injectionToken: beforeQuitOfFrontEndInjectionToken, }); diff --git a/packages/core/src/main/start-main-application/start-main-application.injectable.ts b/packages/core/src/main/start-main-application/start-main-application.injectable.ts index 51b0a7f3b7..99689de0f0 100644 --- a/packages/core/src/main/start-main-application/start-main-application.injectable.ts +++ b/packages/core/src/main/start-main-application/start-main-application.injectable.ts @@ -6,12 +6,8 @@ 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 * as phases from "./runnable-tokens/phases"; 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", @@ -21,13 +17,13 @@ const startMainApplicationInjectable = getInjectable({ 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); + const appPathsRunnablePhase = runManySync(phases.appPathsRunnablePhaseInjectionToken); + const beforeElectronIsReady = runManySync(phases.beforeElectronIsReadyInjectionToken); + const beforeApplicationIsLoading = runMany(phases.beforeApplicationIsLoadingInjectionToken); + const showLoadingRunnablePhase = runMany(phases.showLoadingRunnablePhaseInjectionToken); + const onLoadOfApplication = runMany(phases.onLoadOfApplicationInjectionToken); + const showInitialWindowRunnablePhase = runMany(phases.showInitialWindowRunnablePhaseInjectionToken); + const afterApplicationIsLoaded = runMany(phases.afterApplicationIsLoadedInjectionToken); return () => { // Stuff happening before application is ready needs to be synchronous because of diff --git a/packages/core/src/main/stores/init-user-store.injectable.ts b/packages/core/src/main/stores/init-user-store.injectable.ts index c8d7ec9fe0..d9cc9ee72d 100644 --- a/packages/core/src/main/stores/init-user-store.injectable.ts +++ b/packages/core/src/main/stores/init-user-store.injectable.ts @@ -5,24 +5,21 @@ import { getInjectable } from "@ogre-tools/injectable"; import userStoreFileNameMigrationInjectable from "../../common/user-store/file-name-migration.injectable"; import userStoreInjectable from "../../common/user-store/user-store.injectable"; -import { beforeApplicationIsLoadingInjectionToken } from "../start-main-application/runnable-tokens/before-application-is-loading-injection-token"; +import { beforeApplicationIsLoadingInjectionToken } from "../start-main-application/runnable-tokens/phases"; import initDefaultUpdateChannelInjectable from "../vars/default-update-channel/init.injectable"; const initUserStoreInjectable = getInjectable({ id: "init-user-store", - instantiate: (di) => { - const userStore = di.inject(userStoreInjectable); - const userStoreFileNameMigration = di.inject(userStoreFileNameMigrationInjectable); + instantiate: (di) => ({ + run: async () => { + const userStore = di.inject(userStoreInjectable); + const userStoreFileNameMigration = di.inject(userStoreFileNameMigrationInjectable); - return { - id: "init-user-store", - run: async () => { - await userStoreFileNameMigration(); - userStore.load(); - }, - runAfter: di.inject(initDefaultUpdateChannelInjectable), - }; - }, + await userStoreFileNameMigration(); + userStore.load(); + }, + runAfter: initDefaultUpdateChannelInjectable, + }), injectionToken: beforeApplicationIsLoadingInjectionToken, }); diff --git a/packages/core/src/main/theme/sync-theme-from-os/start-syncing-theme-from-operating-system.injectable.ts b/packages/core/src/main/theme/sync-theme-from-os/start-syncing-theme-from-operating-system.injectable.ts index d5c8f51c76..8c53850880 100644 --- a/packages/core/src/main/theme/sync-theme-from-os/start-syncing-theme-from-operating-system.injectable.ts +++ b/packages/core/src/main/theme/sync-theme-from-os/start-syncing-theme-from-operating-system.injectable.ts @@ -4,21 +4,18 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import syncThemeFromOperatingSystemInjectable from "../../electron-app/features/sync-theme-from-operating-system.injectable"; -import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases"; const startSyncingThemeFromOperatingSystemInjectable = getInjectable({ id: "start-syncing-theme-from-operating-system", - instantiate: (di) => { - const syncTheme = di.inject(syncThemeFromOperatingSystemInjectable); + instantiate: (di) => ({ + run: () => { + const syncTheme = di.inject(syncThemeFromOperatingSystemInjectable); - return { - id: "start-syncing-theme-from-operating-system", - run: () => { - syncTheme.start(); - }, - }; - }, + syncTheme.start(); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/main/theme/sync-theme-from-os/stop-syncing-theme-from-operating-system.injectable.ts b/packages/core/src/main/theme/sync-theme-from-os/stop-syncing-theme-from-operating-system.injectable.ts index b45184a3bd..f50a298822 100644 --- a/packages/core/src/main/theme/sync-theme-from-os/stop-syncing-theme-from-operating-system.injectable.ts +++ b/packages/core/src/main/theme/sync-theme-from-os/stop-syncing-theme-from-operating-system.injectable.ts @@ -4,19 +4,20 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import syncThemeFromOperatingSystemInjectable from "../../electron-app/features/sync-theme-from-operating-system.injectable"; -import { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; +import { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/phases"; const stopSyncingThemeFromOperatingSystemInjectable = getInjectable({ id: "stop-syncing-theme-from-operating-system", - instantiate: (di) => { - const syncTheme = di.inject(syncThemeFromOperatingSystemInjectable); + instantiate: (di) => ({ + run: () => { + const syncTheme = di.inject(syncThemeFromOperatingSystemInjectable); - return { - id: "stop-syncing-theme-from-operating-system", - run: () => void syncTheme.stop(), - }; - }, + syncTheme.stop(); + + return undefined; + }, + }), injectionToken: beforeQuitOfBackEndInjectionToken, }); diff --git a/packages/core/src/main/tray/electron-tray/start-tray.injectable.ts b/packages/core/src/main/tray/electron-tray/start-tray.injectable.ts index 2226205244..a7457df25a 100644 --- a/packages/core/src/main/tray/electron-tray/start-tray.injectable.ts +++ b/packages/core/src/main/tray/electron-tray/start-tray.injectable.ts @@ -3,22 +3,19 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import electronTrayInjectable from "./electron-tray.injectable"; const startTrayInjectable = getInjectable({ id: "start-tray", - instantiate: (di) => { - const electronTray = di.inject(electronTrayInjectable); + instantiate: (di) => ({ + run: () => { + const electronTray = di.inject(electronTrayInjectable); - return { - id: "start-tray", - run: () => { - electronTray.start(); - }, - }; - }, + electronTray.start(); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/main/tray/electron-tray/stop-tray.injectable.ts b/packages/core/src/main/tray/electron-tray/stop-tray.injectable.ts index d2e58be039..4bd6bd6c3a 100644 --- a/packages/core/src/main/tray/electron-tray/stop-tray.injectable.ts +++ b/packages/core/src/main/tray/electron-tray/stop-tray.injectable.ts @@ -4,21 +4,22 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import electronTrayInjectable from "./electron-tray.injectable"; -import { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; +import { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import stopReactiveTrayMenuItemsInjectable from "../reactive-tray-menu-items/stop-reactive-tray-menu-items.injectable"; const stopTrayInjectable = getInjectable({ id: "stop-tray", - instantiate: (di) => { - const electronTray = di.inject(electronTrayInjectable); + instantiate: (di) => ({ + run: () => { + const electronTray = di.inject(electronTrayInjectable); - return { - id: "stop-tray", - run: () => void electronTray.stop(), - runAfter: di.inject(stopReactiveTrayMenuItemsInjectable), - }; - }, + electronTray.stop(); + + return undefined; + }, + runAfter: stopReactiveTrayMenuItemsInjectable, + }), injectionToken: beforeQuitOfBackEndInjectionToken, }); diff --git a/packages/core/src/main/tray/menu-icon/start-reactivity.injectable.ts b/packages/core/src/main/tray/menu-icon/start-reactivity.injectable.ts index 2c03735904..286160e1ee 100644 --- a/packages/core/src/main/tray/menu-icon/start-reactivity.injectable.ts +++ b/packages/core/src/main/tray/menu-icon/start-reactivity.injectable.ts @@ -3,25 +3,22 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import startTrayInjectable from "../electron-tray/start-tray.injectable"; import reactiveTrayMenuIconInjectable from "./reactive.injectable"; const startReactiveTrayMenuIconInjectable = getInjectable({ id: "start-reactive-tray-menu-icon", - instantiate: (di) => { - const reactiveTrayMenuIcon = di.inject(reactiveTrayMenuIconInjectable); + instantiate: (di) => ({ + run: () => { + const reactiveTrayMenuIcon = di.inject(reactiveTrayMenuIconInjectable); - return { - id: "start-reactive-tray-menu-icon", - run: () => { - reactiveTrayMenuIcon.start(); - }, + reactiveTrayMenuIcon.start(); + }, - runAfter: di.inject(startTrayInjectable), - }; - }, + runAfter: startTrayInjectable, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/main/tray/menu-icon/stop-reactivity.injectable.ts b/packages/core/src/main/tray/menu-icon/stop-reactivity.injectable.ts index 94e91ec607..b5908104d2 100644 --- a/packages/core/src/main/tray/menu-icon/stop-reactivity.injectable.ts +++ b/packages/core/src/main/tray/menu-icon/stop-reactivity.injectable.ts @@ -3,20 +3,21 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; +import { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import reactiveTrayMenuIconInjectable from "./reactive.injectable"; const stopReactiveTrayMenuIconInjectable = getInjectable({ id: "stop-reactive-tray-menu-icon", - instantiate: (di) => { - const reactiveTrayMenuIcon = di.inject(reactiveTrayMenuIconInjectable); + instantiate: (di) => ({ + run: () => { + const reactiveTrayMenuIcon = di.inject(reactiveTrayMenuIconInjectable); - return { - id: "stop-reactive-tray-menu-icon", - run: () => void reactiveTrayMenuIcon.stop(), - }; - }, + reactiveTrayMenuIcon.stop(); + + return undefined; + }, + }), injectionToken: beforeQuitOfBackEndInjectionToken, }); diff --git a/packages/core/src/main/tray/reactive-tray-menu-items/start-reactive-tray-menu-items.injectable.ts b/packages/core/src/main/tray/reactive-tray-menu-items/start-reactive-tray-menu-items.injectable.ts index 634c6cd875..34a46118ee 100644 --- a/packages/core/src/main/tray/reactive-tray-menu-items/start-reactive-tray-menu-items.injectable.ts +++ b/packages/core/src/main/tray/reactive-tray-menu-items/start-reactive-tray-menu-items.injectable.ts @@ -4,24 +4,20 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import reactiveTrayMenuItemsInjectable from "./reactive-tray-menu-items.injectable"; -import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import startTrayInjectable from "../electron-tray/start-tray.injectable"; const startReactiveTrayMenuItemsInjectable = getInjectable({ id: "start-reactive-tray-menu-items", - instantiate: (di) => { - const reactiveTrayMenuItems = di.inject(reactiveTrayMenuItemsInjectable); + instantiate: (di) => ({ + run: () => { + const reactiveTrayMenuItems = di.inject(reactiveTrayMenuItemsInjectable); - return { - id: "start-reactive-tray-menu-items", - run: () => { - reactiveTrayMenuItems.start(); - }, - - runAfter: di.inject(startTrayInjectable), - }; - }, + reactiveTrayMenuItems.start(); + }, + runAfter: startTrayInjectable, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/main/tray/reactive-tray-menu-items/stop-reactive-tray-menu-items.injectable.ts b/packages/core/src/main/tray/reactive-tray-menu-items/stop-reactive-tray-menu-items.injectable.ts index 122e9c059a..d5e5063e92 100644 --- a/packages/core/src/main/tray/reactive-tray-menu-items/stop-reactive-tray-menu-items.injectable.ts +++ b/packages/core/src/main/tray/reactive-tray-menu-items/stop-reactive-tray-menu-items.injectable.ts @@ -4,19 +4,20 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import reactiveTrayMenuItemsInjectable from "./reactive-tray-menu-items.injectable"; -import { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; +import { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/phases"; const stopReactiveTrayMenuItemsInjectable = getInjectable({ id: "stop-reactive-tray-menu-items", - instantiate: (di) => { - const reactiveTrayMenuItems = di.inject(reactiveTrayMenuItemsInjectable); + instantiate: (di) => ({ + run: () => { + const reactiveTrayMenuItems = di.inject(reactiveTrayMenuItemsInjectable); - return { - id: "stop-reactive-tray-menu-items", - run: () => void reactiveTrayMenuItems.stop(), - }; - }, + reactiveTrayMenuItems.stop(); + + return undefined; + }, + }), injectionToken: beforeQuitOfBackEndInjectionToken, }); diff --git a/packages/core/src/main/user-store/sync-open-at-login-with-os.injectable.ts b/packages/core/src/main/user-store/sync-open-at-login-with-os.injectable.ts index abad89af97..a95f3aa570 100644 --- a/packages/core/src/main/user-store/sync-open-at-login-with-os.injectable.ts +++ b/packages/core/src/main/user-store/sync-open-at-login-with-os.injectable.ts @@ -6,29 +6,26 @@ import { getInjectable } from "@ogre-tools/injectable"; import { reaction } from "mobx"; import userStoreInjectable from "../../common/user-store/user-store.injectable"; import setLoginItemSettingsInjectable from "../electron-app/features/set-login-item-settings.injectable"; -import { onLoadOfApplicationInjectionToken } from "../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../start-main-application/runnable-tokens/phases"; const setupSyncOpenAtLoginWithOsInjectable = getInjectable({ id: "setup-sync-open-at-login-with-os", - instantiate: (di) => { - const setLoginItemSettings = di.inject(setLoginItemSettingsInjectable); - const userStore = di.inject(userStoreInjectable); + instantiate: (di) => ({ + run: () => { + const setLoginItemSettings = di.inject(setLoginItemSettingsInjectable); + const userStore = di.inject(userStoreInjectable); - return { - id: "setup-sync-open-at-login-with-os", - run: () => { - reaction(() => userStore.openAtLogin, openAtLogin => { - setLoginItemSettings({ - openAtLogin, - openAsHidden: true, - args: ["--hidden"], - }); - }, { - fireImmediately: true, + reaction(() => userStore.openAtLogin, openAtLogin => { + setLoginItemSettings({ + openAtLogin, + openAsHidden: true, + args: ["--hidden"], }); - }, - }; - }, + }, { + fireImmediately: true, + }); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/main/utils/channel/channel-listeners/start-listening-on-channels.injectable.ts b/packages/core/src/main/utils/channel/channel-listeners/start-listening-on-channels.injectable.ts index ce6008add4..3eaf6d50f2 100644 --- a/packages/core/src/main/utils/channel/channel-listeners/start-listening-on-channels.injectable.ts +++ b/packages/core/src/main/utils/channel/channel-listeners/start-listening-on-channels.injectable.ts @@ -3,25 +3,22 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { onLoadOfApplicationInjectionToken } from "../../../start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import { onLoadOfApplicationInjectionToken } from "../../../start-main-application/runnable-tokens/phases"; import listeningOnMessageChannelsInjectable from "../../../../common/utils/channel/listening-on-message-channels.injectable"; import listeningOnRequestChannelsInjectable from "./listening-on-request-channels.injectable"; const startListeningOnChannelsInjectable = getInjectable({ id: "start-listening-on-channels-main", - instantiate: (di) => { - const listeningOnMessageChannels = di.inject(listeningOnMessageChannelsInjectable); - const listeningOnRequestChannels = di.inject(listeningOnRequestChannelsInjectable); + instantiate: (di) => ({ + run: () => { + const listeningOnMessageChannels = di.inject(listeningOnMessageChannelsInjectable); + const listeningOnRequestChannels = di.inject(listeningOnRequestChannelsInjectable); - return { - id: "start-listening-on-channels-main", - run: () => { - listeningOnMessageChannels.start(); - listeningOnRequestChannels.start(); - }, - }; - }, + listeningOnMessageChannels.start(); + listeningOnRequestChannels.start(); + }, + }), injectionToken: onLoadOfApplicationInjectionToken, }); diff --git a/packages/core/src/main/vars/build-version/init.injectable.ts b/packages/core/src/main/vars/build-version/init.injectable.ts index f53e735a47..9ea2ee8f4e 100644 --- a/packages/core/src/main/vars/build-version/init.injectable.ts +++ b/packages/core/src/main/vars/build-version/init.injectable.ts @@ -3,19 +3,18 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/before-application-is-loading-injection-token"; +import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import buildVersionInjectable from "./build-version.injectable"; const initializeBuildVersionInjectable = getInjectable({ id: "initialize-build-version", - instantiate: (di) => { - const buildVersion = di.inject(buildVersionInjectable); + instantiate: (di) => ({ + run: async () => { + const buildVersion = di.inject(buildVersionInjectable); - return { - id: "initialize-build-version", - run: () => buildVersion.init(), - }; - }, + await buildVersion.init(); + }, + }), injectionToken: beforeApplicationIsLoadingInjectionToken, }); diff --git a/packages/core/src/main/vars/default-update-channel/init.injectable.ts b/packages/core/src/main/vars/default-update-channel/init.injectable.ts index 56e90252f3..ddde251d44 100644 --- a/packages/core/src/main/vars/default-update-channel/init.injectable.ts +++ b/packages/core/src/main/vars/default-update-channel/init.injectable.ts @@ -3,21 +3,20 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/before-application-is-loading-injection-token"; +import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import initReleaseChannelInjectable from "../release-channel/init.injectable"; import defaultUpdateChannelInjectable from "../../../features/application-update/common/selected-update-channel/default-update-channel.injectable"; const initDefaultUpdateChannelInjectable = getInjectable({ id: "init-default-update-channel", - instantiate: (di) => { - const defaultUpdateChannel = di.inject(defaultUpdateChannelInjectable); + instantiate: (di) => ({ + run: async () => { + const defaultUpdateChannel = di.inject(defaultUpdateChannelInjectable); - return { - id: "init-default-update-channel", - run: () => defaultUpdateChannel.init(), - runAfter: di.inject(initReleaseChannelInjectable), - }; - }, + await defaultUpdateChannel.init(); + }, + runAfter: initReleaseChannelInjectable, + }), injectionToken: beforeApplicationIsLoadingInjectionToken, }); diff --git a/packages/core/src/main/vars/release-channel/init.injectable.ts b/packages/core/src/main/vars/release-channel/init.injectable.ts index 59527d2194..f1da431264 100644 --- a/packages/core/src/main/vars/release-channel/init.injectable.ts +++ b/packages/core/src/main/vars/release-channel/init.injectable.ts @@ -4,20 +4,19 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import releaseChannelInjectable from "../../../common/vars/release-channel.injectable"; -import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/before-application-is-loading-injection-token"; +import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import initSemanticBuildVersionInjectable from "../semantic-build-version/init.injectable"; const initReleaseChannelInjectable = getInjectable({ id: "init-release-channel", - instantiate: (di) => { - const releaseChannel = di.inject(releaseChannelInjectable); + instantiate: (di) => ({ + run: async () => { + const releaseChannel = di.inject(releaseChannelInjectable); - return { - id: "init-release-channel", - run: () => releaseChannel.init(), - runAfter: di.inject(initSemanticBuildVersionInjectable), - }; - }, + await releaseChannel.init(); + }, + runAfter: initSemanticBuildVersionInjectable, + }), injectionToken: beforeApplicationIsLoadingInjectionToken, }); diff --git a/packages/core/src/main/vars/semantic-build-version/init.injectable.ts b/packages/core/src/main/vars/semantic-build-version/init.injectable.ts index ee822a8796..ec05e4d341 100644 --- a/packages/core/src/main/vars/semantic-build-version/init.injectable.ts +++ b/packages/core/src/main/vars/semantic-build-version/init.injectable.ts @@ -4,18 +4,19 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import buildSemanticVersionInjectable from "../../../common/vars/build-semantic-version.injectable"; -import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/before-application-is-loading-injection-token"; +import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/phases"; import initializeBuildVersionInjectable from "../build-version/init.injectable"; const initSemanticBuildVersionInjectable = getInjectable({ id: "init-semantic-build-version", instantiate: (di) => { - const buildSemanticVersion = di.inject(buildSemanticVersionInjectable); - return { - id: "init-semantic-build-version", - run: () => buildSemanticVersion.init(), - runAfter: di.inject(initializeBuildVersionInjectable), + run: async () => { + const buildSemanticVersion = di.inject(buildSemanticVersionInjectable); + + await buildSemanticVersion.init(); + }, + runAfter: initializeBuildVersionInjectable, }; }, injectionToken: beforeApplicationIsLoadingInjectionToken, diff --git a/packages/core/src/renderer/app-paths/setup-app-paths.injectable.ts b/packages/core/src/renderer/app-paths/setup-app-paths.injectable.ts index d69d8dcbab..d80cc668ac 100644 --- a/packages/core/src/renderer/app-paths/setup-app-paths.injectable.ts +++ b/packages/core/src/renderer/app-paths/setup-app-paths.injectable.ts @@ -12,7 +12,6 @@ const setupAppPathsInjectable = getInjectable({ id: "setup-app-paths", instantiate: (di) => ({ - id: "setup-app-paths", run: async () => { const requestFromChannel = di.inject(requestFromChannelInjectionToken); const appPathsState = di.inject(appPathsStateInjectable); diff --git a/packages/core/src/renderer/before-frame-starts/runnables/configure-immer.injectable.ts b/packages/core/src/renderer/before-frame-starts/runnables/configure-immer.injectable.ts index 73ec9f99bc..a52ed6bc48 100644 --- a/packages/core/src/renderer/before-frame-starts/runnables/configure-immer.injectable.ts +++ b/packages/core/src/renderer/before-frame-starts/runnables/configure-immer.injectable.ts @@ -9,7 +9,6 @@ import { beforeFrameStartsFirstInjectionToken } from "../tokens"; const configureImmerInjectable = getInjectable({ id: "configure-immer", instantiate: () => ({ - id: "configure-immer", run: () => { // Docs: https://immerjs.github.io/immer/ // Required in `utils/storage-helper.ts` diff --git a/packages/core/src/renderer/before-frame-starts/runnables/configure-mobx.injectable.ts b/packages/core/src/renderer/before-frame-starts/runnables/configure-mobx.injectable.ts index 20953b8a8a..9c91f76a6d 100644 --- a/packages/core/src/renderer/before-frame-starts/runnables/configure-mobx.injectable.ts +++ b/packages/core/src/renderer/before-frame-starts/runnables/configure-mobx.injectable.ts @@ -9,7 +9,6 @@ import { beforeFrameStartsFirstInjectionToken } from "../tokens"; const configureMobxInjectable = getInjectable({ id: "configure-mobx", instantiate: () => ({ - id: "configure-mobx", run: () => { // Docs: https://mobx.js.org/configuration.html configure({ diff --git a/packages/core/src/renderer/before-frame-starts/runnables/load-monaco-themes.injectable.ts b/packages/core/src/renderer/before-frame-starts/runnables/load-monaco-themes.injectable.ts index ef85a84cd0..f8456bdca6 100644 --- a/packages/core/src/renderer/before-frame-starts/runnables/load-monaco-themes.injectable.ts +++ b/packages/core/src/renderer/before-frame-starts/runnables/load-monaco-themes.injectable.ts @@ -10,7 +10,6 @@ import { beforeFrameStartsSecondInjectionToken } from "../tokens"; const loadMonacoThemesInjectable = getInjectable({ id: "load-monaco-themes", instantiate: (di) => ({ - id: "load-monaco-themes", run: () => { const customThemes = di.injectMany(customMonacoThemeInjectionToken); const addNewMonacoTheme = di.inject(addNewMonacoThemeInjectable); diff --git a/packages/core/src/renderer/before-frame-starts/runnables/setup-auto-registration.injectable.ts b/packages/core/src/renderer/before-frame-starts/runnables/setup-auto-registration.injectable.ts index 64bc9dee58..dbc77a92b8 100644 --- a/packages/core/src/renderer/before-frame-starts/runnables/setup-auto-registration.injectable.ts +++ b/packages/core/src/renderer/before-frame-starts/runnables/setup-auto-registration.injectable.ts @@ -19,7 +19,6 @@ import maybeKubeApiInjectable from "../../../common/k8s-api/maybe-kube-api.injec const setupAutoRegistrationInjectable = getInjectable({ id: "setup-auto-registration", instantiate: (di) => ({ - id: "setup-auto-registration", run: () => { const autoRegistrationEmitter = di.inject(autoRegistrationEmitterInjectable); const beforeApiManagerInitializationCrds: CustomResourceDefinition[] = []; diff --git a/packages/core/src/renderer/before-frame-starts/runnables/setup-current-cluster-broadcast.injectable.ts b/packages/core/src/renderer/before-frame-starts/runnables/setup-current-cluster-broadcast.injectable.ts index a89ba58ec2..0d9c8bc65a 100644 --- a/packages/core/src/renderer/before-frame-starts/runnables/setup-current-cluster-broadcast.injectable.ts +++ b/packages/core/src/renderer/before-frame-starts/runnables/setup-current-cluster-broadcast.injectable.ts @@ -12,7 +12,6 @@ import { beforeMainFrameStartsFirstInjectionToken } from "../tokens"; const setupCurrentClusterBroadcastInjectable = getInjectable({ id: "setup-current-cluster-broadcast", instantiate: (di) => ({ - id: "setup-current-cluster-broadcast", run: () => { const matchedClusterId = di.inject(matchedClusterIdInjectable); const sendMessageToChannel = di.inject(sendMessageToChannelInjectionToken); diff --git a/packages/core/src/renderer/before-frame-starts/runnables/setup-kubernetes-cluster-catalog-add-menu.injectable.ts b/packages/core/src/renderer/before-frame-starts/runnables/setup-kubernetes-cluster-catalog-add-menu.injectable.ts index 5d6efad5eb..e62fb6d830 100644 --- a/packages/core/src/renderer/before-frame-starts/runnables/setup-kubernetes-cluster-catalog-add-menu.injectable.ts +++ b/packages/core/src/renderer/before-frame-starts/runnables/setup-kubernetes-cluster-catalog-add-menu.injectable.ts @@ -14,7 +14,6 @@ import { beforeFrameStartsSecondInjectionToken } from "../tokens"; const setupKubernetesClusterCatalogAddMenuListenerInjectable = getInjectable({ id: "setup-kubernetes-cluster-catalog-add-menu-listener", instantiate: (di) => ({ - id: "setup-kubernetes-cluster-catalog-add-menu-listener", run: () => { const navigateToAddCluster = di.inject(navigateToAddClusterInjectable); const addSyncEntries = di.inject(addSyncEntriesInjectable); diff --git a/packages/core/src/renderer/before-frame-starts/runnables/setup-kubernetes-cluster-context-menu-open.injectable.ts b/packages/core/src/renderer/before-frame-starts/runnables/setup-kubernetes-cluster-context-menu-open.injectable.ts index 99a3bfa9f3..6da76f1803 100644 --- a/packages/core/src/renderer/before-frame-starts/runnables/setup-kubernetes-cluster-context-menu-open.injectable.ts +++ b/packages/core/src/renderer/before-frame-starts/runnables/setup-kubernetes-cluster-context-menu-open.injectable.ts @@ -14,7 +14,6 @@ import { beforeFrameStartsSecondInjectionToken } from "../tokens"; const setupKubernetesClusterContextMenuOpenInjectable = getInjectable({ id: "setup-kubernetes-cluster-context-menu-open", instantiate: (di) => ({ - id: "setup-kubernetes-cluster-context-menu-open", run: () => { const catalogCategoryRegistry = di.inject(catalogCategoryRegistryInjectable); const openDeleteClusterDialog = di.inject(openDeleteClusterDialogInjectable); diff --git a/packages/core/src/renderer/before-frame-starts/runnables/setup-lens-proxy-certificate.injectable.ts b/packages/core/src/renderer/before-frame-starts/runnables/setup-lens-proxy-certificate.injectable.ts index e698eda6dd..d3a01a3eea 100644 --- a/packages/core/src/renderer/before-frame-starts/runnables/setup-lens-proxy-certificate.injectable.ts +++ b/packages/core/src/renderer/before-frame-starts/runnables/setup-lens-proxy-certificate.injectable.ts @@ -10,7 +10,6 @@ import requestLensProxyCertificateInjectable from "../../certificate/request-len const setupLensProxyCertificateInjectable = getInjectable({ id: "setup-lens-proxy-certificate", instantiate: (di) => ({ - id: "setup-lens-proxy-certificate", run: async () => { const requestLensProxyCertificate = di.inject(requestLensProxyCertificateInjectable); const lensProxyCertificate = di.inject(lensProxyCertificateInjectable); diff --git a/packages/core/src/renderer/before-frame-starts/runnables/setup-root-mac-class.injectable.ts b/packages/core/src/renderer/before-frame-starts/runnables/setup-root-mac-class.injectable.ts index 56b9ce66fa..241628fe42 100644 --- a/packages/core/src/renderer/before-frame-starts/runnables/setup-root-mac-class.injectable.ts +++ b/packages/core/src/renderer/before-frame-starts/runnables/setup-root-mac-class.injectable.ts @@ -9,7 +9,6 @@ import { beforeFrameStartsSecondInjectionToken } from "../tokens"; const setupRootMacClassnameInjectable = getInjectable({ id: "setup-root-mac-classname", instantiate: (di) => ({ - id: "setup-root-mac-classname", run: () => { const isMac = di.inject(isMacInjectable); const rootElem = document.getElementById("app"); diff --git a/packages/core/src/renderer/before-frame-starts/runnables/setup-sentry.injectable.ts b/packages/core/src/renderer/before-frame-starts/runnables/setup-sentry.injectable.ts index c6af3b7614..0472144249 100644 --- a/packages/core/src/renderer/before-frame-starts/runnables/setup-sentry.injectable.ts +++ b/packages/core/src/renderer/before-frame-starts/runnables/setup-sentry.injectable.ts @@ -10,7 +10,6 @@ import { init } from "@sentry/electron/renderer"; const setupSentryInjectable = getInjectable({ id: "setup-sentry", instantiate: (di) => ({ - id: "setup-sentry", run: () => { const initializeSentryReportingWith = di.inject(initializeSentryReportingWithInjectable); diff --git a/packages/core/src/renderer/before-frame-starts/runnables/setup-weblink-context-menu-open.injectable.tsx b/packages/core/src/renderer/before-frame-starts/runnables/setup-weblink-context-menu-open.injectable.tsx index 7bf8f29422..ce620894e1 100644 --- a/packages/core/src/renderer/before-frame-starts/runnables/setup-weblink-context-menu-open.injectable.tsx +++ b/packages/core/src/renderer/before-frame-starts/runnables/setup-weblink-context-menu-open.injectable.tsx @@ -9,10 +9,9 @@ import { WeblinkAddCommand } from "../../components/catalog-entities/weblink-add import commandOverlayInjectable from "../../components/command-palette/command-overlay.injectable"; import { beforeFrameStartsSecondInjectionToken } from "../tokens"; -const setupWeblickContextMenuOpenInjectable = getInjectable({ - id: "setup-weblick-context-menu-open", +const setupWeblinkContextMenuOpenInjectable = getInjectable({ + id: "setup-weblink-context-menu-open", instantiate: (di) => ({ - id: "setup-weblick-context-menu-open", run: () => { const catalogCategoryRegistry = di.inject(catalogCategoryRegistryInjectable); const commandOverlay = di.inject(commandOverlayInjectable); @@ -31,4 +30,4 @@ const setupWeblickContextMenuOpenInjectable = getInjectable({ injectionToken: beforeFrameStartsSecondInjectionToken, }); -export default setupWeblickContextMenuOpenInjectable; +export default setupWeblinkContextMenuOpenInjectable; diff --git a/packages/core/src/renderer/before-frame-starts/tokens.ts b/packages/core/src/renderer/before-frame-starts/tokens.ts index 460c44cde9..b73ca3d5df 100644 --- a/packages/core/src/renderer/before-frame-starts/tokens.ts +++ b/packages/core/src/renderer/before-frame-starts/tokens.ts @@ -3,7 +3,7 @@ * 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 { Runnable } from "../../common/runnable/types"; // NOTE: these are run before any other token, mostly to set up things that all other runnables need export const beforeFrameStartsFirstInjectionToken = getInjectionToken({ diff --git a/packages/core/src/renderer/components/layout/top-bar/start-state-sync.injectable.ts b/packages/core/src/renderer/components/layout/top-bar/start-state-sync.injectable.ts index 92488851c5..aca3e9ff76 100644 --- a/packages/core/src/renderer/components/layout/top-bar/start-state-sync.injectable.ts +++ b/packages/core/src/renderer/components/layout/top-bar/start-state-sync.injectable.ts @@ -12,7 +12,6 @@ import topBarStateInjectable from "./state.injectable"; const startTopbarStateSyncInjectable = getInjectable({ id: "start-topbar-state-sync", instantiate: (di) => ({ - id: "start-topbar-state-sync", run: () => { const state = di.inject(topBarStateInjectable); const ipcRenderer = di.inject(ipcRendererInjectable); diff --git a/packages/core/src/renderer/frames/root-frame/setup-system-ca.injectable.ts b/packages/core/src/renderer/frames/root-frame/setup-system-ca.injectable.ts index 4fe4d07758..43ace24cc2 100644 --- a/packages/core/src/renderer/frames/root-frame/setup-system-ca.injectable.ts +++ b/packages/core/src/renderer/frames/root-frame/setup-system-ca.injectable.ts @@ -9,8 +9,11 @@ import injectSystemCAsInjectable from "../../../features/certificate-authorities const setupSystemCaInjectable = getInjectable({ id: "setup-system-ca", instantiate: (di) => ({ - id: "setup-system-ca", - run: di.inject(injectSystemCAsInjectable), + run: async () => { + const injectSystemCAs = di.inject(injectSystemCAsInjectable); + + await injectSystemCAs(); + }, }), injectionToken: beforeFrameStartsSecondInjectionToken, }); diff --git a/packages/core/src/renderer/navigation/setup-logging-for-navigation.injectable.ts b/packages/core/src/renderer/navigation/setup-logging-for-navigation.injectable.ts index e6a1bce903..b56eb979a2 100644 --- a/packages/core/src/renderer/navigation/setup-logging-for-navigation.injectable.ts +++ b/packages/core/src/renderer/navigation/setup-logging-for-navigation.injectable.ts @@ -10,7 +10,6 @@ import observableHistoryInjectable from "./observable-history.injectable"; const setupLoggingForNavigationInjectable = getInjectable({ id: "setup-logging-for-navigation", instantiate: (di) => ({ - id: "setup-logging-for-navigation", run: () => { const logger = di.inject(loggerInjectable); const observableHistory = di.inject(observableHistoryInjectable); diff --git a/packages/core/src/renderer/stores/init-user-store.injectable.ts b/packages/core/src/renderer/stores/init-user-store.injectable.ts index fba2287fe0..af192d9b2e 100644 --- a/packages/core/src/renderer/stores/init-user-store.injectable.ts +++ b/packages/core/src/renderer/stores/init-user-store.injectable.ts @@ -10,14 +10,12 @@ import initDefaultUpdateChannelInjectable from "../vars/default-update-channel/i const initUserStoreInjectable = getInjectable({ id: "init-user-store", instantiate: (di) => ({ - id: "init-user-store", run: () => { - // This must be done here so as to actually only be instantiated after the dependencies are const userStore = di.inject(userStoreInjectable); return userStore.load(); }, - runAfter: di.inject(initDefaultUpdateChannelInjectable), + runAfter: initDefaultUpdateChannelInjectable, }), injectionToken: beforeFrameStartsSecondInjectionToken, }); diff --git a/packages/core/src/renderer/themes/setup-apply-active-theme.injectable.ts b/packages/core/src/renderer/themes/setup-apply-active-theme.injectable.ts index 960f5f8764..c71dd5baa7 100644 --- a/packages/core/src/renderer/themes/setup-apply-active-theme.injectable.ts +++ b/packages/core/src/renderer/themes/setup-apply-active-theme.injectable.ts @@ -13,7 +13,6 @@ import applyLensThemeInjectable from "./apply-lens-theme.injectable"; const setupApplyActiveThemeInjectable = getInjectable({ id: "setup-apply-active-theme", instantiate: (di) => ({ - id: "setup-apply-active-theme", run: () => { const activeTheme = di.inject(activeThemeInjectable); const applyLensTheme = di.inject(applyLensThemeInjectable); @@ -27,8 +26,8 @@ const setupApplyActiveThemeInjectable = getInjectable({ ); }, runAfter: [ - di.inject(initializeSystemThemeTypeInjectable), - di.inject(initUserStoreInjectable), + initializeSystemThemeTypeInjectable, + initUserStoreInjectable, ], }), injectionToken: beforeFrameStartsSecondInjectionToken, diff --git a/packages/core/src/renderer/utils/channel/channel-listeners/start-listening-of-channels.injectable.ts b/packages/core/src/renderer/utils/channel/channel-listeners/start-listening-of-channels.injectable.ts index aea98b3360..c11b34e7e3 100644 --- a/packages/core/src/renderer/utils/channel/channel-listeners/start-listening-of-channels.injectable.ts +++ b/packages/core/src/renderer/utils/channel/channel-listeners/start-listening-of-channels.injectable.ts @@ -10,7 +10,6 @@ const startListeningOfChannelsInjectable = getInjectable({ id: "start-listening-of-channels-renderer", instantiate: (di) => ({ - id: "start-listening-of-channels-renderer", run: () => { const listeningOfChannels = di.inject(listeningOnMessageChannelsInjectable); diff --git a/packages/core/src/renderer/utils/create-storage/initialize-state.injectable.ts b/packages/core/src/renderer/utils/create-storage/initialize-state.injectable.ts index 2c0d832c9e..75d61908cd 100644 --- a/packages/core/src/renderer/utils/create-storage/initialize-state.injectable.ts +++ b/packages/core/src/renderer/utils/create-storage/initialize-state.injectable.ts @@ -20,7 +20,6 @@ import storageSaveDelayInjectable from "./storage-save-delay.injectable"; const initializeStateInjectable = getInjectable({ id: "initialize-lens-local-storage-state", instantiate: (di) => ({ - id: "initialize-lens-local-storage-state", run: async () => { const joinPaths = di.inject(joinPathsInjectable); const directoryForLensLocalStorage = di.inject(directoryForLensLocalStorageInjectable); @@ -67,7 +66,7 @@ const initializeStateInjectable = getInjectable({ } } }, - runAfter: di.inject(setupAppPathsInjectable), + runAfter: setupAppPathsInjectable, }), injectionToken: beforeFrameStartsFirstInjectionToken, }); diff --git a/packages/core/src/renderer/utils/sync-box/provide-initial-values-for-sync-boxes.injectable.ts b/packages/core/src/renderer/utils/sync-box/provide-initial-values-for-sync-boxes.injectable.ts index 3666bf0840..aceb20cea4 100644 --- a/packages/core/src/renderer/utils/sync-box/provide-initial-values-for-sync-boxes.injectable.ts +++ b/packages/core/src/renderer/utils/sync-box/provide-initial-values-for-sync-boxes.injectable.ts @@ -15,7 +15,6 @@ const provideInitialValuesForSyncBoxesInjectable = getInjectable({ id: "provide-initial-values-for-sync-boxes", instantiate: (di) => ({ - id: "provide-initial-values-for-sync-boxes", run: async () => { const requestFromChannel = di.inject(requestFromChannelInjectionToken); const syncBoxes = di.injectMany(syncBoxInjectionToken); diff --git a/packages/core/src/renderer/vars/build-version/init.injectable.ts b/packages/core/src/renderer/vars/build-version/init.injectable.ts index 0734960289..0eeecaa838 100644 --- a/packages/core/src/renderer/vars/build-version/init.injectable.ts +++ b/packages/core/src/renderer/vars/build-version/init.injectable.ts @@ -9,7 +9,6 @@ import buildVersionInjectable from "./build-version.injectable"; const initializeBuildVersionInjectable = getInjectable({ id: "initialize-build-version", instantiate: (di) => ({ - id: "initialize-build-version", run: async () => { const buildVersion = di.inject(buildVersionInjectable); diff --git a/packages/core/src/renderer/vars/default-update-channel/init.injectable.ts b/packages/core/src/renderer/vars/default-update-channel/init.injectable.ts index a349769815..7624d1f335 100644 --- a/packages/core/src/renderer/vars/default-update-channel/init.injectable.ts +++ b/packages/core/src/renderer/vars/default-update-channel/init.injectable.ts @@ -10,13 +10,12 @@ import defaultUpdateChannelInjectable from "../../../features/application-update const initDefaultUpdateChannelInjectable = getInjectable({ id: "init-default-update-channel", instantiate: (di) => ({ - id: "init-default-update-channel", run: async () => { const defaultUpdateChannel = di.inject(defaultUpdateChannelInjectable); await defaultUpdateChannel.init(); }, - runAfter: di.inject(initReleaseChannelInjectable), + runAfter: initReleaseChannelInjectable, }), injectionToken: beforeFrameStartsSecondInjectionToken, }); diff --git a/packages/core/src/renderer/vars/release-channel/init.injectable.ts b/packages/core/src/renderer/vars/release-channel/init.injectable.ts index e0092abf55..e49b9649a8 100644 --- a/packages/core/src/renderer/vars/release-channel/init.injectable.ts +++ b/packages/core/src/renderer/vars/release-channel/init.injectable.ts @@ -10,13 +10,12 @@ import initSemanticBuildVersionInjectable from "../semantic-build-version/init.i const initReleaseChannelInjectable = getInjectable({ id: "init-release-channel", instantiate: (di) => ({ - id: "init-release-channel", run: async () => { const releaseChannel = di.inject(releaseChannelInjectable); await releaseChannel.init(); }, - runAfter: di.inject(initSemanticBuildVersionInjectable), + runAfter: initSemanticBuildVersionInjectable, }), injectionToken: beforeFrameStartsSecondInjectionToken, }); diff --git a/packages/core/src/renderer/vars/semantic-build-version/init.injectable.ts b/packages/core/src/renderer/vars/semantic-build-version/init.injectable.ts index 62a9a3387f..3ef0a6a496 100644 --- a/packages/core/src/renderer/vars/semantic-build-version/init.injectable.ts +++ b/packages/core/src/renderer/vars/semantic-build-version/init.injectable.ts @@ -10,13 +10,12 @@ import initializeBuildVersionInjectable from "../build-version/init.injectable"; const initSemanticBuildVersionInjectable = getInjectable({ id: "init-semantic-build-version", instantiate: (di) => ({ - id: "init-semantic-build-version", run: async () => { const buildSemanticVersion = di.inject(buildSemanticVersionInjectable); await buildSemanticVersion.init(); }, - runAfter: di.inject(initializeBuildVersionInjectable), + runAfter: initializeBuildVersionInjectable, }), injectionToken: beforeFrameStartsSecondInjectionToken, });