1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fixup type errors

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-03-02 10:51:54 -05:00
parent 2301270d54
commit 45b630553a
31 changed files with 60 additions and 60 deletions

View File

@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { generalCatalogEntityInjectionToken } from "../general-catalog-entity-injection-token"; import { generalCatalogEntityInjectionToken } from "../general-catalog-entity-injection-token";
import { GeneralEntity } from "../../index"; import { GeneralEntity } from "../../index";
import { buildURL } from "@k8slens/utilities/src/buildUrl"; import { buildURL } from "@k8slens/utilities";
import welcomeRouteInjectable from "../../../front-end-routing/routes/welcome/welcome-route.injectable"; import welcomeRouteInjectable from "../../../front-end-routing/routes/welcome/welcome-route.injectable";
const welcomeCatalogEntityInjectable = getInjectable({ const welcomeCatalogEntityInjectable = getInjectable({

View File

@ -10,7 +10,7 @@ import { autorun, action, observable } from "mobx";
import type { KubeApi } from "../kube-api"; import type { KubeApi } from "../kube-api";
import type { KubeObject, ObjectReference } from "../kube-object"; import type { KubeObject, ObjectReference } from "../kube-object";
import { parseKubeApi, createKubeApiURL } from "../kube-api-parse"; import { parseKubeApi, createKubeApiURL } from "../kube-api-parse";
import { chain, find } from "@k8slens/utilities/src/iter"; import { chain, find } from "@k8slens/utilities";
export type RegisterableStore<Store> = Store extends KubeObjectStore<any, any, any> export type RegisterableStore<Store> = Store extends KubeObjectStore<any, any, any>
? Store ? Store

View File

@ -5,7 +5,7 @@
import { getLegacyGlobalDiForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api"; import { getLegacyGlobalDiForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
import customResourcesRouteInjectable from "../../front-end-routing/routes/cluster/custom-resources/custom-resources/custom-resources-route.injectable"; import customResourcesRouteInjectable from "../../front-end-routing/routes/cluster/custom-resources/custom-resources/custom-resources-route.injectable";
import { buildURL } from "@k8slens/utilities/src/buildUrl"; import { buildURL } from "@k8slens/utilities";
import type { BaseKubeObjectCondition, ClusterScopedMetadata } from "../kube-object"; import type { BaseKubeObjectCondition, ClusterScopedMetadata } from "../kube-object";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import type { DerivedKubeApiOptions, KubeApiDependencies } from "../kube-api"; import type { DerivedKubeApiOptions, KubeApiDependencies } from "../kube-api";

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import { HelmChart } from "../helm-charts.api"; import { HelmChart } from "../helm-charts.api";
import type { RawHelmChart } from "../helm-charts.api"; import type { RawHelmChart } from "../helm-charts.api";
import { isDefined } from "@k8slens/utilities"; import { isDefined } from "@k8slens/utilities";

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import apiBaseInjectable from "../../api-base.injectable"; import apiBaseInjectable from "../../api-base.injectable";
export type RequestHelmReleaseConfiguration = ( export type RequestHelmReleaseConfiguration = (

View File

@ -5,7 +5,7 @@
import yaml from "js-yaml"; import yaml from "js-yaml";
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import type { HelmReleaseUpdateDetails } from "../helm-releases.api"; import type { HelmReleaseUpdateDetails } from "../helm-releases.api";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import apiBaseInjectable from "../../api-base.injectable"; import apiBaseInjectable from "../../api-base.injectable";
interface HelmReleaseCreatePayload { interface HelmReleaseCreatePayload {

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import apiBaseInjectable from "../../api-base.injectable"; import apiBaseInjectable from "../../api-base.injectable";
export type RequestDeleteHelmRelease = (name: string, namespace: string) => Promise<void>; export type RequestDeleteHelmRelease = (name: string, namespace: string) => Promise<void>;

View File

@ -4,7 +4,7 @@
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import type { KubeJsonApiData } from "../../kube-json-api"; import type { KubeJsonApiData } from "../../kube-json-api";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import apiBaseInjectable from "../../api-base.injectable"; import apiBaseInjectable from "../../api-base.injectable";
export interface HelmReleaseDetails { export interface HelmReleaseDetails {

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import apiBaseInjectable from "../../api-base.injectable"; import apiBaseInjectable from "../../api-base.injectable";
export interface HelmReleaseRevision { export interface HelmReleaseRevision {

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import apiBaseInjectable from "../../api-base.injectable"; import apiBaseInjectable from "../../api-base.injectable";
import type { HelmReleaseDto } from "../helm-releases.api"; import type { HelmReleaseDto } from "../helm-releases.api";

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import apiBaseInjectable from "../../api-base.injectable"; import apiBaseInjectable from "../../api-base.injectable";
export type RequestHelmReleaseRollback = (name: string, namespace: string, revision: number) => Promise<void>; export type RequestHelmReleaseRollback = (name: string, namespace: string, revision: number) => Promise<void>;

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import type { AsyncResult } from "@k8slens/utilities"; import type { AsyncResult } from "@k8slens/utilities";
import apiBaseInjectable from "../../api-base.injectable"; import apiBaseInjectable from "../../api-base.injectable";

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import apiBaseInjectable from "../../api-base.injectable"; import apiBaseInjectable from "../../api-base.injectable";
export type RequestHelmReleaseValues = (name: string, namespace: string, all?: boolean) => Promise<string>; export type RequestHelmReleaseValues = (name: string, namespace: string, all?: boolean) => Promise<string>;

View File

@ -12,7 +12,7 @@ import navigateInjectable from "../../renderer/navigation/navigate.injectable";
import { asLegacyGlobalFunctionForExtensionApi } from "../as-legacy-globals-for-extension-api/as-legacy-global-function-for-extension-api"; import { asLegacyGlobalFunctionForExtensionApi } from "../as-legacy-globals-for-extension-api/as-legacy-global-function-for-extension-api";
export type { PageParamInit, PageParam } from "../../renderer/navigation/page-param"; export type { PageParamInit, PageParam } from "../../renderer/navigation/page-param";
export type { URLParams } from "@k8slens/utilities/src/buildUrl"; export type { URLParams } from "@k8slens/utilities";
export const getDetailsUrl = asLegacyGlobalFunctionForExtensionApi(getDetailsUrlInjectable); export const getDetailsUrl = asLegacyGlobalFunctionForExtensionApi(getDetailsUrlInjectable);
export const showDetails = asLegacyGlobalFunctionForExtensionApi(showDetailsInjectable); export const showDetails = asLegacyGlobalFunctionForExtensionApi(showDetailsInjectable);

View File

@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { generalCatalogEntityInjectionToken } from "../../../common/catalog-entities/general-catalog-entities/general-catalog-entity-injection-token"; import { generalCatalogEntityInjectionToken } from "../../../common/catalog-entities/general-catalog-entities/general-catalog-entity-injection-token";
import { GeneralEntity } from "../../../common/catalog-entities"; import { GeneralEntity } from "../../../common/catalog-entities";
import { buildURL } from "@k8slens/utilities/src/buildUrl"; import { buildURL } from "@k8slens/utilities";
import preferencesRouteInjectable from "./preferences-route.injectable"; import preferencesRouteInjectable from "./preferences-route.injectable";
const preferencesCatalogEntityInjectable = getInjectable({ const preferencesCatalogEntityInjectable = getInjectable({

View File

@ -8,7 +8,7 @@ import loggerInjectable from "../../common/logger.injectable";
import type { KubeApiResource } from "../../common/rbac"; import type { KubeApiResource } from "../../common/rbac";
import type { Cluster } from "../../common/cluster/cluster"; import type { Cluster } from "../../common/cluster/cluster";
import { requestApiVersionsInjectionToken } from "./request-api-versions"; import { requestApiVersionsInjectionToken } from "./request-api-versions";
import { withConcurrencyLimit } from "@k8slens/utilities/src/with-concurrency-limit"; import { withConcurrencyLimit } from "@k8slens/utilities";
import requestKubeApiResourcesForInjectable from "./request-kube-api-resources-for.injectable"; import requestKubeApiResourcesForInjectable from "./request-kube-api-resources-for.injectable";
import type { AsyncResult } from "../../common/utils/async-result"; import type { AsyncResult } from "../../common/utils/async-result";
import { backoffCaller } from "../../common/utils/backoff-caller"; import { backoffCaller } from "../../common/utils/backoff-caller";

View File

@ -4,7 +4,7 @@
*/ */
import type { V1APIGroupList } from "@kubernetes/client-node"; import type { V1APIGroupList } from "@kubernetes/client-node";
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { chain } from "@k8slens/utilities/src/iter"; import { chain } from "@k8slens/utilities";
import k8sRequestInjectable from "../k8s-request.injectable"; import k8sRequestInjectable from "../k8s-request.injectable";
import { requestApiVersionsInjectionToken } from "./request-api-versions"; import { requestApiVersionsInjectionToken } from "./request-api-versions";

View File

@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { navigateToUrlInjectionToken } from "../../common/front-end-routing/navigate-to-url-injection-token"; import { navigateToUrlInjectionToken } from "../../common/front-end-routing/navigate-to-url-injection-token";
import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token"; import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token";
import { buildURL } from "@k8slens/utilities/src/buildUrl"; import { buildURL } from "@k8slens/utilities";
const navigateToRouteInjectable = getInjectable({ const navigateToRouteInjectable = getInjectable({
id: "navigate-to-route", id: "navigate-to-route",

View File

@ -8,7 +8,7 @@ import styles from "./badge.module.scss";
import React, { useEffect, useRef, useState } from "react"; import React, { useEffect, useRef, useState } from "react";
import { action, observable } from "mobx"; import { action, observable } from "mobx";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { cssNames } from "@k8slens/utilities/src/cssNames"; import { cssNames } from "@k8slens/utilities";
import { withTooltip } from "../tooltip"; import { withTooltip } from "../tooltip";
export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement> { export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement> {

View File

@ -17,7 +17,7 @@ import catalogPreviousActiveTabStorageInjectable from "../+catalog/catalog-previ
import type { IComputedValue } from "mobx"; import type { IComputedValue } from "mobx";
import currentRouteComponentInjectable from "../../routes/current-route-component.injectable"; import currentRouteComponentInjectable from "../../routes/current-route-component.injectable";
import welcomeRouteInjectable from "../../../common/front-end-routing/routes/welcome/welcome-route.injectable"; import welcomeRouteInjectable from "../../../common/front-end-routing/routes/welcome/welcome-route.injectable";
import { buildURL } from "@k8slens/utilities/src/buildUrl"; import { buildURL } from "@k8slens/utilities";
import type { StorageLayer } from "@k8slens/utilities"; import type { StorageLayer } from "@k8slens/utilities";
import type { WatchForGeneralEntityNavigation } from "../../api/helpers/watch-for-general-entity-navigation.injectable"; import type { WatchForGeneralEntityNavigation } from "../../api/helpers/watch-for-general-entity-navigation.injectable";
import watchForGeneralEntityNavigationInjectable from "../../api/helpers/watch-for-general-entity-navigation.injectable"; import watchForGeneralEntityNavigationInjectable from "../../api/helpers/watch-for-general-entity-navigation.injectable";

View File

@ -6,7 +6,7 @@
import type { IComputedValue } from "mobx"; import type { IComputedValue } from "mobx";
import { observable } from "mobx"; import { observable } from "mobx";
import type { PodLogsQuery, Pod } from "../../../../common/k8s-api/endpoints"; import type { PodLogsQuery, Pod } from "../../../../common/k8s-api/endpoints";
import { waitUntilDefined } from "@k8slens/utilities/src/wait"; import { waitUntilDefined } from "@k8slens/utilities";
import type { IntervalFn } from "@k8slens/utilities"; import type { IntervalFn } from "@k8slens/utilities";
import { getOrInsertWith, interval } from "@k8slens/utilities"; import { getOrInsertWith, interval } from "@k8slens/utilities";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";

View File

@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable";
import { when } from "mobx"; import { when } from "mobx";
import loggerInjectable from "../../../../common/logger.injectable"; import loggerInjectable from "../../../../common/logger.injectable";
import { TerminalChannels } from "../../../../common/terminal/channels"; import { TerminalChannels } from "../../../../common/terminal/channels";
import { waitUntilDefined } from "@k8slens/utilities/src/wait"; import { waitUntilDefined } from "@k8slens/utilities";
import { noop } from "@k8slens/utilities"; import { noop } from "@k8slens/utilities";
import showSuccessNotificationInjectable from "../../notifications/show-success-notification.injectable"; import showSuccessNotificationInjectable from "../../notifications/show-success-notification.injectable";
import selectDockTabInjectable from "../dock/select-dock-tab.injectable"; import selectDockTabInjectable from "../dock/select-dock-tab.injectable";

View File

@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import apiBaseInjectable from "../../../common/k8s-api/api-base.injectable"; import apiBaseInjectable from "../../../common/k8s-api/api-base.injectable";
import type { ServiceAccount } from "../../../common/k8s-api/endpoints"; import type { ServiceAccount } from "../../../common/k8s-api/endpoints";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import openKubeconfigDialogInjectable from "./open.injectable"; import openKubeconfigDialogInjectable from "./open.injectable";
export type OpenServiceAccountKubeConfigDialog = (account: ServiceAccount) => void; export type OpenServiceAccountKubeConfigDialog = (account: ServiceAccount) => void;

View File

@ -6,7 +6,7 @@
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import apiBaseInjectable from "../../../common/k8s-api/api-base.injectable"; import apiBaseInjectable from "../../../common/k8s-api/api-base.injectable";
import loggerInjectable from "../../../common/logger.injectable"; import loggerInjectable from "../../../common/logger.injectable";
import { urlBuilderFor } from "@k8slens/utilities/src/buildUrl"; import { urlBuilderFor } from "@k8slens/utilities";
import type { ForwardedPort } from "../port-forward-item"; import type { ForwardedPort } from "../port-forward-item";
export type RequestActivePortForward = (portForward: ForwardedPort) => Promise<ForwardedPort | undefined>; export type RequestActivePortForward = (portForward: ForwardedPort) => Promise<ForwardedPort | undefined>;

View File

@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable";
import { navigateToUrlInjectionToken } from "../../common/front-end-routing/navigate-to-url-injection-token"; import { navigateToUrlInjectionToken } from "../../common/front-end-routing/navigate-to-url-injection-token";
import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token"; import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token";
import currentlyInClusterFrameInjectable from "./currently-in-cluster-frame.injectable"; import currentlyInClusterFrameInjectable from "./currently-in-cluster-frame.injectable";
import { buildURL } from "@k8slens/utilities/src/buildUrl"; import { buildURL } from "@k8slens/utilities";
const navigateToRouteInjectable = getInjectable({ const navigateToRouteInjectable = getInjectable({
id: "navigate-to-route", id: "navigate-to-route",

View File

@ -3,9 +3,9 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import type { AsyncResult } from "./async-result"; import type { AsyncResult, Result } from "./result";
import { delay } from "./delay"; import { delay } from "./delay";
import { noop } from "@k8slens/utilities/src/noop"; import { noop } from "./noop";
/** /**
* @param error The error that resulted in the failure * @param error The error that resulted in the failure
@ -25,7 +25,7 @@ export interface BackoffCallerOptions<E> {
maxAttempts?: number; maxAttempts?: number;
/** /**
* In miliseconds * In milliseconds
* @default 1000 * @default 1000
*/ */
initialTimeout?: number; initialTimeout?: number;
@ -41,7 +41,7 @@ export interface BackoffCallerOptions<E> {
* @param fn The function to repeatedly attempt * @param fn The function to repeatedly attempt
* @returns The first success or the last failure * @returns The first success or the last failure
*/ */
export const backoffCaller = async <T, E, R extends AsyncResult<T, E>>(fn: () => Promise<R>, options?: BackoffCallerOptions<E>): Promise<R> => { export const backoffCaller = async <T, E>(fn: () => AsyncResult<T, E>, options?: BackoffCallerOptions<E>): AsyncResult<T, E> => {
const { const {
initialTimeout = 1000, initialTimeout = 1000,
maxAttempts = 5, maxAttempts = 5,
@ -51,7 +51,7 @@ export const backoffCaller = async <T, E, R extends AsyncResult<T, E>>(fn: () =>
let timeout = initialTimeout; let timeout = initialTimeout;
let attempt = 0; let attempt = 0;
let result: R; let result: Result<T, E>;
do { do {
result = await fn(); result = await fn();

View File

@ -7,7 +7,7 @@
import { camelCase } from "lodash"; import { camelCase } from "lodash";
import type { SingleOrMany } from "./types"; import type { SingleOrMany } from "./types";
import { isObject, isString } from "./type-narrowing"; import { isObject, isString } from "./type-narrowing";
import * as object from "./object"; import { object } from "./object";
export function toCamelCase<T extends Record<string, unknown>[]>(obj: T): T; export function toCamelCase<T extends Record<string, unknown>[]>(obj: T): T;
export function toCamelCase<T extends Record<string, unknown>>(obj: T): T; export function toCamelCase<T extends Record<string, unknown>>(obj: T): T;

View File

@ -3,8 +3,8 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import * as iter from "./iter"; import { iter } from "./iter";
import * as object from "./object"; import { object } from "./object";
import { isObject } from "./type-narrowing"; import { isObject } from "./type-narrowing";
export type IgnoredClassNames = number | symbol | Function; export type IgnoredClassNames = number | symbol | Function;

View File

@ -4,7 +4,7 @@
*/ */
import type { IInterceptable, IInterceptor, IListenable, ISetWillChange, ObservableMap } from "mobx"; import type { IInterceptable, IInterceptor, IListenable, ISetWillChange, ObservableMap } from "mobx";
import { action, observable, ObservableSet } from "mobx"; import { observable, ObservableSet, runInAction } from "mobx";
export function makeIterableIterator<T>(iterator: Iterator<T>): IterableIterator<T> { export function makeIterableIterator<T>(iterator: Iterator<T>): IterableIterator<T> {
(iterator as IterableIterator<T>)[Symbol.iterator] = () => iterator as IterableIterator<T>; (iterator as IterableIterator<T>)[Symbol.iterator] = () => iterator as IterableIterator<T>;
@ -138,23 +138,24 @@ export class ObservableHashSet<T> implements Set<T>, IInterceptable<ISetWillChan
this.#hashmap = observable.map<string, T>(Array.from(initialValues, value => [this.hasher(value), value]), undefined); this.#hashmap = observable.map<string, T>(Array.from(initialValues, value => [this.hasher(value), value]), undefined);
} }
@action
replace(other: ObservableHashSet<T> | ObservableSet<T> | Set<T> | readonly T[]): this { replace(other: ObservableHashSet<T> | ObservableSet<T> | Set<T> | readonly T[]): this {
if (other === null || other === undefined) { return runInAction(() => {
if (other === null || other === undefined) {
return this;
}
if (!(Array.isArray(other) || other instanceof Set || other instanceof ObservableHashSet || other instanceof ObservableSet)) {
throw new Error(`ObservableHashSet: Cannot initialize set from ${other}`);
}
this.clear();
for (const value of other) {
this.add(value);
}
return this; return this;
} });
if (!(Array.isArray(other) || other instanceof Set || other instanceof ObservableHashSet || other instanceof ObservableSet)) {
throw new Error(`ObservableHashSet: Cannot initialize set from ${other}`);
}
this.clear();
for (const value of other) {
this.add(value);
}
return this;
} }
clear(): void { clear(): void {
@ -167,15 +168,16 @@ export class ObservableHashSet<T> implements Set<T>, IInterceptable<ISetWillChan
return this; return this;
} }
@action
toggle(value: T): void { toggle(value: T): void {
const hash = this.hasher(value); runInAction(() => {
const hash = this.hasher(value);
if (this.#hashmap.has(hash)) { if (this.#hashmap.has(hash)) {
this.#hashmap.delete(hash); this.#hashmap.delete(hash);
} else { } else {
this.#hashmap.set(hash, value); this.#hashmap.set(hash, value);
} }
});
} }
delete(value: T): boolean { delete(value: T): boolean {

View File

@ -3,8 +3,6 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import type { WindowEventListener } from "../window/event-listener.injectable";
function parseKeyDownDescriptor(descriptor: string): (event: KeyboardEvent) => boolean { function parseKeyDownDescriptor(descriptor: string): (event: KeyboardEvent) => boolean {
const parts = new Set(( const parts = new Set((
descriptor descriptor
@ -43,7 +41,7 @@ function parseKeyDownDescriptor(descriptor: string): (event: KeyboardEvent) => b
}; };
} }
export function onKeyboardShortcut(descriptor: string, action: () => void): WindowEventListener<"keydown"> { export function onKeyboardShortcut(descriptor: string, action: () => void): (this: Window, ev: WindowEventMap["keydown"]) => any {
const isMatchingEvent = parseKeyDownDescriptor(descriptor); const isMatchingEvent = parseKeyDownDescriptor(descriptor);
return (event) => { return (event) => {

View File

@ -4,7 +4,7 @@
*/ */
import path from "path"; import path from "path";
import * as iter from "@k8slens/utilities/src/iter"; import { iter } from "./iter";
/** /**
* Join all entires with a PATH env var delimited string together * Join all entires with a PATH env var delimited string together