diff --git a/src/common/configure-packages.ts b/src/common/configure-packages.ts deleted file mode 100644 index ec48be44ce..0000000000 --- a/src/common/configure-packages.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ - -import * as Mobx from "mobx"; -import * as Immer from "immer"; - -/** - * Setup default configuration for external npm-packages - */ -export default function configurePackages() { - // Docs: https://mobx.js.org/configuration.html - Mobx.configure({ - enforceActions: "never", - - // TODO: enable later (read more: https://mobx.js.org/migrating-from-4-or-5.html) - // computedRequiresReaction: true, - // reactionRequiresObservable: true, - // observableRequiresReaction: true, - }); - - // 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 -} diff --git a/src/common/k8s-api/api-manager/auto-registration.injectable.ts b/src/common/k8s-api/api-manager/auto-registration.injectable.ts deleted file mode 100644 index 178426650f..0000000000 --- a/src/common/k8s-api/api-manager/auto-registration.injectable.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ -import { getInjectable } from "@ogre-tools/injectable"; -import clusterFrameContextForNamespacedResourcesInjectable from "../../../renderer/cluster-frame-context/for-namespaced-resources.injectable"; -import type { CustomResourceDefinition } from "../endpoints"; -import { KubeApi } from "../kube-api"; -import { KubeObject } from "../kube-object"; -import type { KubeObjectStoreDependencies } from "../kube-object.store"; -import autoRegistrationEmitterInjectable from "./auto-registration-emitter.injectable"; -import apiManagerInjectable from "./manager.injectable"; -import { CustomResourceStore } from "./resource.store"; - -const autoRegistrationInjectable = getInjectable({ - id: "api-manager-auto-registration", - instantiate: (di) => { - const autoRegistrationEmitter = di.inject(autoRegistrationEmitterInjectable); - const beforeApiManagerInitializationCrds: CustomResourceDefinition[] = []; - const beforeApiManagerInitializationApis: KubeApi[] = []; - const deps: KubeObjectStoreDependencies = { - context: di.inject(clusterFrameContextForNamespacedResourcesInjectable), - }; - let initialized = false; - - const autoInitCustomResourceStore = (crd: CustomResourceDefinition) => { - const objectConstructor = class extends KubeObject { - static readonly kind = crd.getResourceKind(); - static readonly namespaced = crd.isNamespaced(); - static readonly apiBase = crd.getResourceApiBase(); - }; - - const api = (() => { - const rawApi = apiManager.getApi(objectConstructor.apiBase); - - if (rawApi) { - return rawApi; - } - - const api = new KubeApi({ objectConstructor }); - - apiManager.registerApi(api); - - return api; - })(); - - if (!apiManager.getStore(api)) { - apiManager.registerStore(new CustomResourceStore(deps, api)); - } - }; - const autoInitKubeApi = (api: KubeApi) => { - apiManager.registerApi(api); - }; - - autoRegistrationEmitter - .on("customResourceDefinition", (crd) => { - if (initialized) { - autoInitCustomResourceStore(crd); - } else { - beforeApiManagerInitializationCrds.push(crd); - } - }) - .on("kubeApi", (api) => { - if (initialized) { - autoInitKubeApi(api); - } else { - beforeApiManagerInitializationApis.push(api); - } - }); - - const apiManager = di.inject(apiManagerInjectable); - - beforeApiManagerInitializationCrds.forEach(autoInitCustomResourceStore); - beforeApiManagerInitializationApis.forEach(autoInitKubeApi); - initialized = true; - }, -}); - -export default autoRegistrationInjectable; diff --git a/src/common/vars.ts b/src/common/vars.ts index cbde12ff5d..dadab42798 100644 --- a/src/common/vars.ts +++ b/src/common/vars.ts @@ -6,11 +6,6 @@ // App's common configuration for any process (main, renderer, build pipeline, etc.) import type { ThemeId } from "../renderer/themes/lens-theme"; -/** - * @deprecated Switch to using isMacInjectable - */ -export const isMac = process.platform === "darwin"; - /** * @deprecated Switch to using isWindowsInjectable */ diff --git a/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts b/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts index 9d760a8bc2..d2d8f344eb 100644 --- a/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts +++ b/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts @@ -5,7 +5,6 @@ import { getInjectable } from "@ogre-tools/injectable"; import type { ContentSource, ElectronWindowTitleBarStyle } from "./create-electron-window.injectable"; import createElectronWindowForInjectable from "./create-electron-window.injectable"; -import assert from "assert"; import type { ClusterFrameInfo } from "../../../../common/cluster-frames"; export interface ElectronWindow { @@ -69,7 +68,9 @@ const createLensWindowInjectable = getInjectable({ let windowIsStarting = false; const showWindow = () => { - assert(browserWindow); + if (!browserWindow) { + throw new Error("Cannot show browserWindow, does not exist"); + } browserWindow.show(); windowIsShown = true; diff --git a/src/renderer/before-frame-starts/runnables/setup-auto-registration.injectable.ts b/src/renderer/before-frame-starts/runnables/setup-auto-registration.injectable.ts index c2c58c22b0..bae9ca595e 100644 --- a/src/renderer/before-frame-starts/runnables/setup-auto-registration.injectable.ts +++ b/src/renderer/before-frame-starts/runnables/setup-auto-registration.injectable.ts @@ -10,6 +10,8 @@ import type { CustomResourceDefinition } from "../../../common/k8s-api/endpoints import { KubeApi } from "../../../common/k8s-api/kube-api"; import { KubeObject } from "../../../common/k8s-api/kube-object"; import { beforeClusterFrameStartsInjectionToken } from "../tokens"; +import type { KubeObjectStoreDependencies } from "../../../common/k8s-api/kube-object.store"; +import clusterFrameContextForNamespacedResourcesInjectable from "../../cluster-frame-context/for-namespaced-resources.injectable"; const setupAutoRegistrationInjectable = getInjectable({ id: "setup-auto-registration", @@ -19,6 +21,9 @@ const setupAutoRegistrationInjectable = getInjectable({ const autoRegistrationEmitter = di.inject(autoRegistrationEmitterInjectable); const beforeApiManagerInitializationCrds: CustomResourceDefinition[] = []; const beforeApiManagerInitializationApis: KubeApi[] = []; + const deps: KubeObjectStoreDependencies = { + context: di.inject(clusterFrameContextForNamespacedResourcesInjectable), + }; let initialized = false; const autoInitCustomResourceStore = (crd: CustomResourceDefinition) => { @@ -43,7 +48,7 @@ const setupAutoRegistrationInjectable = getInjectable({ })(); if (!apiManager.getStore(api)) { - apiManager.registerStore(new CustomResourceStore(api)); + apiManager.registerStore(new CustomResourceStore(deps, api)); } }; const autoInitKubeApi = (api: KubeApi) => { diff --git a/src/renderer/components/monaco-editor/monaco-themes/clouds-midnight.json b/src/renderer/components/monaco-editor/monaco-themes/clouds-midnight.json deleted file mode 100644 index 48696d8d0a..0000000000 --- a/src/renderer/components/monaco-editor/monaco-themes/clouds-midnight.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "name": "clouds-midnight", - "base": "vs-dark", - "inherit": true, - "rules": [ - { - "background": "191919", - "token": "" - }, - { - "foreground": "3c403b", - "token": "comment" - }, - { - "foreground": "5d90cd", - "token": "string" - }, - { - "foreground": "46a609", - "token": "constant.numeric" - }, - { - "foreground": "39946a", - "token": "constant.language" - }, - { - "foreground": "927c5d", - "token": "keyword" - }, - { - "foreground": "927c5d", - "token": "support.constant.property-value" - }, - { - "foreground": "927c5d", - "token": "constant.other.color" - }, - { - "foreground": "366f1a", - "token": "keyword.other.unit" - }, - { - "foreground": "a46763", - "token": "entity.other.attribute-name.html" - }, - { - "foreground": "4b4b4b", - "token": "keyword.operator" - }, - { - "foreground": "e92e2e", - "token": "storage" - }, - { - "foreground": "858585", - "token": "entity.other.inherited-class" - }, - { - "foreground": "606060", - "token": "entity.name.tag" - }, - { - "foreground": "a165ac", - "token": "constant.character.entity" - }, - { - "foreground": "a165ac", - "token": "support.class.js" - }, - { - "foreground": "606060", - "token": "entity.other.attribute-name" - }, - { - "foreground": "e92e2e", - "token": "meta.selector.css" - }, - { - "foreground": "e92e2e", - "token": "entity.name.tag.css" - }, - { - "foreground": "e92e2e", - "token": "entity.other.attribute-name.id.css" - }, - { - "foreground": "e92e2e", - "token": "entity.other.attribute-name.class.css" - }, - { - "foreground": "616161", - "token": "meta.property-name.css" - }, - { - "foreground": "e92e2e", - "token": "support.function" - }, - { - "foreground": "ffffff", - "background": "e92e2e", - "token": "invalid" - }, - { - "foreground": "e92e2e", - "token": "punctuation.section.embedded" - }, - { - "foreground": "606060", - "token": "punctuation.definition.tag" - }, - { - "foreground": "a165ac", - "token": "constant.other.color.rgb-value.css" - }, - { - "foreground": "a165ac", - "token": "support.constant.property-value.css" - } - ], - "colors": { - "editor.foreground": "#929292", - "editor.background": "#191919", - "editor.selectionBackground": "#000000", - "editor.lineHighlightBackground": "#D7D7D708", - "editorCursor.foreground": "#7DA5DC", - "editorWhitespace.foreground": "#BFBFBF" - } -} \ No newline at end of file diff --git a/src/renderer/navigation/events.ts b/src/renderer/navigation/events.ts index 7cacd1b313..452d16af9b 100644 --- a/src/renderer/navigation/events.ts +++ b/src/renderer/navigation/events.ts @@ -3,39 +3,9 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ -import { ipcRenderer } from "electron"; -import { reaction } from "mobx"; -import { broadcastMessage } from "../../common/ipc"; -import { getLegacyGlobalDiForExtensionApi } from "../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api"; -import matchedClusterIdInjectable from "./matched-cluster-id.injectable"; - +// export const enum IpcRendererNavigationEvents { - CLUSTER_VIEW_CURRENT_ID = "renderer:cluster-id-of-active-view", NAVIGATE_IN_APP = "renderer:navigate", NAVIGATE_IN_CLUSTER = "renderer:navigate-in-cluster", LOADED = "renderer:loaded", } - -export function bindEvents() { - if (!ipcRenderer) { - return; - } - - if (process.isMainFrame) { - bindClusterManagerRouteEvents(); - } -} - -// Handle events only in main window renderer process (see also: cluster-manager.tsx) -function bindClusterManagerRouteEvents() { - const di = getLegacyGlobalDiForExtensionApi(); - - const matchedClusterId = di.inject(matchedClusterIdInjectable); - - // Keep track of active cluster-id for handling IPC/menus/etc. - reaction(() => matchedClusterId.get(), clusterId => { - broadcastMessage(IpcRendererNavigationEvents.CLUSTER_VIEW_CURRENT_ID, clusterId); - }, { - fireImmediately: true, - }); -}