@k8slens/hotbar-contracts 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +308 -0
- package/dist/src/add-to-hotbar.d.ts +54 -0
- package/dist/src/add-to-hotbar.d.ts.map +1 -0
- package/dist/src/eject-hotbar-item.d.ts +18 -0
- package/dist/src/eject-hotbar-item.d.ts.map +1 -0
- package/dist/src/get-hotbar-item-kind-injectable-bunch.d.ts +60 -0
- package/dist/src/get-hotbar-item-kind-injectable-bunch.d.ts.map +1 -0
- package/dist/src/has-hotbar-item.d.ts +27 -0
- package/dist/src/has-hotbar-item.d.ts.map +1 -0
- package/dist/src/hotbar-item-component.d.ts +44 -0
- package/dist/src/hotbar-item-component.d.ts.map +1 -0
- package/dist/src/hotbar-item-context-menu-item.d.ts +48 -0
- package/dist/src/hotbar-item-context-menu-item.d.ts.map +1 -0
- package/dist/src/hotbar-item-frame.d.ts +18 -0
- package/dist/src/hotbar-item-frame.d.ts.map +1 -0
- package/dist/src/hotbar-item-id.d.ts +6 -0
- package/dist/src/hotbar-item-id.d.ts.map +1 -0
- package/dist/src/hotbar-item-kind.d.ts +69 -0
- package/dist/src/hotbar-item-kind.d.ts.map +1 -0
- package/dist/src/hotbar-item-persisted-data.d.ts +33 -0
- package/dist/src/hotbar-item-persisted-data.d.ts.map +1 -0
- package/dist/src/hotbar-item.d.ts +12 -0
- package/dist/src/hotbar-item.d.ts.map +1 -0
- package/dist/src/insert-hotbar-item.d.ts +17 -0
- package/dist/src/insert-hotbar-item.d.ts.map +1 -0
- package/dist/src/is-in-hotbar.d.ts +89 -0
- package/dist/src/is-in-hotbar.d.ts.map +1 -0
- package/dist/src/remove-from-hotbar.d.ts +47 -0
- package/dist/src/remove-from-hotbar.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IComputedValue } from "mobx";
|
|
2
|
+
import type { HotbarItem } from "./hotbar-item";
|
|
3
|
+
/** Whether the item, as `{ id, kind }`, is on the current hotbar page, as of now. */
|
|
4
|
+
export type HasHotbarItem = (item: HotbarItem) => Promise<boolean>;
|
|
5
|
+
/**
|
|
6
|
+
* The hotbar's own membership query: one implementation for every kind, asked with the whole
|
|
7
|
+
* `{ id, kind }`. `getHotbarItemKindInjectableBunch` builds `isInHotbarInjectionToken.for(kind)`
|
|
8
|
+
* on it, so reach for that one instead.
|
|
9
|
+
*
|
|
10
|
+
* Implemented by the hotbar.
|
|
11
|
+
*/
|
|
12
|
+
export declare const hasHotbarItemInjectionToken: import("@k8slens/injectable").InjectionToken2Base<() => HasHotbarItem, () => HasHotbarItem[], "one", () => import("@k8slens/injectable").InjectionInstanceWithMeta<HasHotbarItem>, () => import("@k8slens/injectable").InjectionInstanceWithMeta<HasHotbarItem>[]> & {
|
|
13
|
+
readonly __abstract?: never;
|
|
14
|
+
};
|
|
15
|
+
/** Whether the item, as `{ id, kind }`, is on the current hotbar page, reactively. */
|
|
16
|
+
export type HasHotbarItemReactive = (item: HotbarItem) => IComputedValue<boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* The hotbar's own reactive membership query, asked with the whole `{ id, kind }`.
|
|
19
|
+
* `getHotbarItemKindInjectableBunch` builds `isInHotbarReactiveInjectionToken.for(kind)` on it,
|
|
20
|
+
* so reach for that one instead.
|
|
21
|
+
*
|
|
22
|
+
* Implemented by the hotbar.
|
|
23
|
+
*/
|
|
24
|
+
export declare const hasHotbarItemReactiveInjectionToken: import("@k8slens/injectable").InjectionToken2Base<HasHotbarItemReactive, (item: HotbarItem) => IComputedValue<boolean>[], "one", (item: HotbarItem) => import("@k8slens/injectable").InjectionInstanceWithMeta<IComputedValue<boolean>>, (item: HotbarItem) => import("@k8slens/injectable").InjectionInstanceWithMeta<IComputedValue<boolean>>[]> & {
|
|
25
|
+
readonly __abstract?: never;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=has-hotbar-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-hotbar-item.d.ts","sourceRoot":"","sources":["../../src/has-hotbar-item.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,qFAAqF;AACrF,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEnE;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,0DAA6C,aAAa;;CAG9F,CAAC;AAEL,sFAAsF;AACtF,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC;AAElF;;;;;;GAMG;AACH,eAAO,MAAM,mCAAmC;;CAG5C,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ManyFactory, type MaybeResultFactory, type SpecificInjectionToken2 } from "@k8slens/injectable";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { HotbarItem } from "./hotbar-item";
|
|
4
|
+
import { type HotbarItemKind } from "./hotbar-item-kind";
|
|
5
|
+
/** What the hotbar hands a kind's component: the item, as `{ id, kind }`. */
|
|
6
|
+
export type HotbarItemComponentProps = {
|
|
7
|
+
item: HotbarItem;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Renders one item of a kind inside its hotbar slot. The hotbar hands it the item only;
|
|
11
|
+
* the component resolves whatever else it needs from the item's id and kind.
|
|
12
|
+
*/
|
|
13
|
+
export type HotbarItemComponent = React.ComponentType<HotbarItemComponentProps>;
|
|
14
|
+
/** How the component is registered: a v2 token models a factory, so a component is wrapped in one. */
|
|
15
|
+
export type HotbarItemComponentFactory = () => HotbarItemComponent;
|
|
16
|
+
/** What `.for(kind).for(scopeIds)` yields: at most one component per kind per scope. */
|
|
17
|
+
export type HotbarItemComponentTokenFor = SpecificInjectionToken2<{
|
|
18
|
+
singleFactory: HotbarItemComponentFactory;
|
|
19
|
+
maybeFactory: MaybeResultFactory<HotbarItemComponentFactory>;
|
|
20
|
+
specificTokenFactory: undefined;
|
|
21
|
+
cardinality: "zero-or-one";
|
|
22
|
+
}>;
|
|
23
|
+
/** What `.for(kind)` yields: the kind's components, one per scope, reached with `.for(scopeIds)`. */
|
|
24
|
+
export type HotbarItemComponentTokenForKind = SpecificInjectionToken2<{
|
|
25
|
+
singleFactory: HotbarItemComponentFactory;
|
|
26
|
+
manyFactory: ManyFactory<HotbarItemComponentFactory>;
|
|
27
|
+
specificTokenFactory: (scopeIds: readonly string[]) => HotbarItemComponentTokenFor;
|
|
28
|
+
cardinality: "zero-or-many";
|
|
29
|
+
}>;
|
|
30
|
+
declare const hotbarItemComponentTokenForKind: (kind: HotbarItemKind<any>) => HotbarItemComponentTokenForKind;
|
|
31
|
+
/**
|
|
32
|
+
* How the hotbar renders an item: the component registered for the item's kind, via
|
|
33
|
+
* `.for(kind).for(scopeIds)`. A kind with no component is unknown to the hotbar, and its items
|
|
34
|
+
* render as unavailable.
|
|
35
|
+
*
|
|
36
|
+
* `getHotbarItemKindInjectableBunch` registers this for a kind; prefer it over binding
|
|
37
|
+
* to the token by hand, since it also wires the persisted data and the adder.
|
|
38
|
+
*/
|
|
39
|
+
export declare const hotbarItemComponentInjectionToken: import("@k8slens/injectable").InjectionToken2Base<HotbarItemComponentFactory, () => HotbarItemComponent[], "zero-or-many", () => import("@k8slens/injectable").InjectionInstanceWithMeta<HotbarItemComponent>, () => import("@k8slens/injectable").InjectionInstanceWithMeta<HotbarItemComponent>[]> & {
|
|
40
|
+
readonly __abstract: true;
|
|
41
|
+
for: typeof hotbarItemComponentTokenForKind;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=hotbar-item-component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotbar-item-component.d.ts","sourceRoot":"","sources":["../../src/hotbar-item-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE9E,6EAA6E;AAC7E,MAAM,MAAM,wBAAwB,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAC;AAEhF,sGAAsG;AACtG,MAAM,MAAM,0BAA0B,GAAG,MAAM,mBAAmB,CAAC;AAEnE,wFAAwF;AACxF,MAAM,MAAM,2BAA2B,GAAG,uBAAuB,CAAC;IAChE,aAAa,EAAE,0BAA0B,CAAC;IAC1C,YAAY,EAAE,kBAAkB,CAAC,0BAA0B,CAAC,CAAC;IAC7D,oBAAoB,EAAE,SAAS,CAAC;IAChC,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC,CAAC;AAEH,qGAAqG;AACrG,MAAM,MAAM,+BAA+B,GAAG,uBAAuB,CAAC;IACpE,aAAa,EAAE,0BAA0B,CAAC;IAC1C,WAAW,EAAE,WAAW,CAAC,0BAA0B,CAAC,CAAC;IACrD,oBAAoB,EAAE,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,KAAK,2BAA2B,CAAC;IACnF,WAAW,EAAE,cAAc,CAAC;CAC7B,CAAC,CAAC;AAEH,QAAA,MAAM,+BAA+B,SAAU,cAAc,CAAC,GAAG,CAAC,KAAG,+BAkBlE,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC;;;CAMX,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ManyFactory, type SpecificInjectionToken2 } from "@k8slens/injectable";
|
|
2
|
+
import type { MenuItem } from "@k8slens/drop-down-menu-contracts";
|
|
3
|
+
import type { MaybePromise } from "@k8slens/public-utilities";
|
|
4
|
+
import type { HotbarItemId } from "./hotbar-item-id";
|
|
5
|
+
import { type HotbarItemKind } from "./hotbar-item-kind";
|
|
6
|
+
/** Produces the menu item for one hotbar item, possibly later. */
|
|
7
|
+
export type HotbarItemContextMenuItemFor = (id: HotbarItemId) => MaybePromise<MenuItem>;
|
|
8
|
+
/** What `.for(kind).for(scopeIds)` yields: the menu items contributed to one kind as registered under those scopes. */
|
|
9
|
+
export type HotbarItemContextMenuItemTokenFor = SpecificInjectionToken2<{
|
|
10
|
+
singleFactory: HotbarItemContextMenuItemFor;
|
|
11
|
+
manyFactory: ManyFactory<HotbarItemContextMenuItemFor>;
|
|
12
|
+
specificTokenFactory: undefined;
|
|
13
|
+
cardinality: "zero-or-many";
|
|
14
|
+
}>;
|
|
15
|
+
/** What `.for(kind)` yields: the kind's menu items, per scope, reached with `.for(scopeIds)`. */
|
|
16
|
+
export type HotbarItemContextMenuItemTokenForKind = SpecificInjectionToken2<{
|
|
17
|
+
singleFactory: HotbarItemContextMenuItemFor;
|
|
18
|
+
manyFactory: ManyFactory<HotbarItemContextMenuItemFor>;
|
|
19
|
+
specificTokenFactory: (scopeIds: readonly string[]) => HotbarItemContextMenuItemTokenFor;
|
|
20
|
+
cardinality: "zero-or-many";
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* The right-click menu of a hotbar item: one entry per contribution, registered against the
|
|
24
|
+
* item's kind via `.for(kind).for(scopeIds)`. The scopes are those of the registration, so the
|
|
25
|
+
* `injectionToken` is given as a function of them. The hotbar contributes the way to remove
|
|
26
|
+
* the item to every kind itself.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* export const openBookmarkInBrowserInjectable = getInjectable2({
|
|
31
|
+
* id: "open-bookmark-in-browser",
|
|
32
|
+
* instantiate: () => (id): MenuItem => ({
|
|
33
|
+
* id: "open-in-browser",
|
|
34
|
+
* kind: "action",
|
|
35
|
+
* labelText: "Open in browser",
|
|
36
|
+
* onClick: () => openInBrowser(urlOf(id)),
|
|
37
|
+
* orderNumber: 10,
|
|
38
|
+
* parentId: undefined,
|
|
39
|
+
* }),
|
|
40
|
+
* injectionToken: ({ scopeIds }) => hotbarItemContextMenuItemInjectionToken.for(bookmarkHotbarItemKind).for(scopeIds),
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const hotbarItemContextMenuItemInjectionToken: import("@k8slens/injectable").InjectionToken2Base<HotbarItemContextMenuItemFor, (id: string) => MaybePromise<MenuItem>[], "zero-or-many", (id: string) => import("@k8slens/injectable").InjectionInstanceWithMeta<MaybePromise<MenuItem>>, (id: string) => import("@k8slens/injectable").InjectionInstanceWithMeta<MaybePromise<MenuItem>>[]> & {
|
|
45
|
+
readonly __abstract: true;
|
|
46
|
+
for: (kind: HotbarItemKind<any>) => HotbarItemContextMenuItemTokenForKind;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=hotbar-item-context-menu-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotbar-item-context-menu-item.d.ts","sourceRoot":"","sources":["../../src/hotbar-item-context-menu-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACzG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE9E,kEAAkE;AAClE,MAAM,MAAM,4BAA4B,GAAG,CAAC,EAAE,EAAE,YAAY,KAAK,YAAY,CAAC,QAAQ,CAAC,CAAC;AAExF,uHAAuH;AACvH,MAAM,MAAM,iCAAiC,GAAG,uBAAuB,CAAC;IACtE,aAAa,EAAE,4BAA4B,CAAC;IAC5C,WAAW,EAAE,WAAW,CAAC,4BAA4B,CAAC,CAAC;IACvD,oBAAoB,EAAE,SAAS,CAAC;IAChC,WAAW,EAAE,cAAc,CAAC;CAC7B,CAAC,CAAC;AAEH,iGAAiG;AACjG,MAAM,MAAM,qCAAqC,GAAG,uBAAuB,CAAC;IAC1E,aAAa,EAAE,4BAA4B,CAAC;IAC5C,WAAW,EAAE,WAAW,CAAC,4BAA4B,CAAC,CAAC;IACvD,oBAAoB,EAAE,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,KAAK,iCAAiC,CAAC;IACzF,WAAW,EAAE,cAAc,CAAC;CAC7B,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,uCAAuC;;gBAO3C,cAAc,CAAC,GAAG,CAAC,KAAG,qCAAqC;CAmBnE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { HotbarItem } from "./hotbar-item";
|
|
3
|
+
export interface HotbarItemFrameProps {
|
|
4
|
+
readonly item: HotbarItem;
|
|
5
|
+
readonly children?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* What every hotbar item sits in: the slot's chrome, plus the item's right-click menu,
|
|
9
|
+
* which is where the hotbar offers to remove the item. Whatever is rendered inside decides
|
|
10
|
+
* what clicking the item does.
|
|
11
|
+
*
|
|
12
|
+
* Implemented by the hotbar. `getHotbarItemKindInjectableBunch` wraps a kind's component
|
|
13
|
+
* in it, so a kind needs to render only its own content.
|
|
14
|
+
*/
|
|
15
|
+
export declare const HotbarItemFrame: React.ComponentType<HotbarItemFrameProps> & import("@k8slens/injectable").InjectionToken2Base<() => React.ComponentType<HotbarItemFrameProps>, () => React.ComponentType<HotbarItemFrameProps>[], "one", () => import("@k8slens/injectable").InjectionInstanceWithMeta<React.ComponentType<HotbarItemFrameProps>>, () => import("@k8slens/injectable").InjectionInstanceWithMeta<React.ComponentType<HotbarItemFrameProps>>[]> & {
|
|
16
|
+
readonly __abstract?: never;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=hotbar-item-frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotbar-item-frame.d.ts","sourceRoot":"","sources":["../../src/hotbar-item-frame.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe;;CAExB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotbar-item-id.d.ts","sourceRoot":"","sources":["../../src/hotbar-item-id.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type TypedSpecifier, type TypedSpecifierType } from "@k8slens/injectable";
|
|
2
|
+
/**
|
|
3
|
+
* Identifies one kind of hotbar item: what an item is, as opposed to which item it is.
|
|
4
|
+
* Every item in the hotbar is persisted as `{ id, kind }`, and the kind decides how the
|
|
5
|
+
* item renders.
|
|
6
|
+
*
|
|
7
|
+
* `PersistedData` is what the hotbar persists next to the item's id when the item is
|
|
8
|
+
* added, and hands back to the kind's component whenever the item renders. A kind
|
|
9
|
+
* created without `PersistedData` persists nothing beyond the id.
|
|
10
|
+
*
|
|
11
|
+
* At runtime a kind is a branded string, so it is usable as a `.for()` key.
|
|
12
|
+
*/
|
|
13
|
+
export type HotbarItemKind<PersistedData = unknown> = TypedSpecifier<string, {
|
|
14
|
+
persistedData: PersistedData;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Recovers the persisted data type bound to a {@link HotbarItemKind} or a {@link HotbarItemKindId}.
|
|
18
|
+
*/
|
|
19
|
+
export type HotbarItemPersistedData<K extends HotbarItemKind<any> | HotbarItemKindId<any>> = TypedSpecifierType<"persistedData", K>;
|
|
20
|
+
/**
|
|
21
|
+
* What the hotbar knows a kind by: the kind's specifier, scoped to whoever registered it, as
|
|
22
|
+
* one string. It is what the hotbar persists as an item's `kind` and what keys the kind's
|
|
23
|
+
* persisted data. Two extensions declaring a kind with the same specifier get two ids, because
|
|
24
|
+
* their scopes differ; the specifier alone is never an identity.
|
|
25
|
+
*
|
|
26
|
+
* The tokens take the two parts separately, `token.for(kind).for(scopeIds)`; the id is the
|
|
27
|
+
* hotbar's side of the same identity. Made by {@link getHotbarItemKindId}, taken apart by
|
|
28
|
+
* {@link parseHotbarItemKindId}. Typed by the kind's persisted data, like the kind itself.
|
|
29
|
+
*/
|
|
30
|
+
export type HotbarItemKindId<PersistedData = unknown> = TypedSpecifier<string, {
|
|
31
|
+
persistedData: PersistedData;
|
|
32
|
+
scopedHotbarItemKind: true;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* The id of a kind as registered under the given scopes: the scope ids, then the specifier,
|
|
36
|
+
* joined with ":", which is why a specifier may not contain one. The same kind under the same
|
|
37
|
+
* scopes always yields the same id. The hotbar computes it from an item's kind and scopes;
|
|
38
|
+
* a kind's own code has no need for it, the tokens take the parts.
|
|
39
|
+
*/
|
|
40
|
+
export declare const getHotbarItemKindId: <K extends HotbarItemKind<any>>(kind: K, scopeIds: readonly string[]) => HotbarItemKindId<HotbarItemPersistedData<K>>;
|
|
41
|
+
/**
|
|
42
|
+
* The two parts of a kind id: the scopes the kind was registered under and the kind itself,
|
|
43
|
+
* as the tokens take them: `token.for(kind).for(scopeIds)`. The inverse of
|
|
44
|
+
* {@link getHotbarItemKindId}. A kind registered at container level, or persisted before kinds
|
|
45
|
+
* were scoped, parses to no scopes.
|
|
46
|
+
*/
|
|
47
|
+
export declare const parseHotbarItemKindId: <Data>(kindId: HotbarItemKindId<Data>) => {
|
|
48
|
+
readonly kind: HotbarItemKind<Data>;
|
|
49
|
+
readonly scopeIds: readonly string[];
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Curried creator for a {@link HotbarItemKind}. The first call binds the persisted data
|
|
53
|
+
* type; the second the globally unique specifier string. Register the kind with
|
|
54
|
+
* `getHotbarItemKindInjectableBunch`, then add items of it with
|
|
55
|
+
* `addToHotbarInjectionToken.for(kind)`.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* // A kind whose items carry a URL:
|
|
60
|
+
* export const bookmarkHotbarItemKind = getHotbarItemKind<{ url: string }>()("my-extension-bookmark");
|
|
61
|
+
*
|
|
62
|
+
* // A kind whose items need nothing beyond their id:
|
|
63
|
+
* export const dashboardHotbarItemKind = getHotbarItemKind()("my-extension-dashboard");
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare const getHotbarItemKind: <PersistedData = void>() => <S extends string>(specifier: S) => TypedSpecifier<S, {
|
|
67
|
+
persistedData: PersistedData;
|
|
68
|
+
}>;
|
|
69
|
+
//# sourceMappingURL=hotbar-item-kind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotbar-item-kind.d.ts","sourceRoot":"","sources":["../../src/hotbar-item-kind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEtG;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,CAAC,aAAa,GAAG,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE;IAAE,aAAa,EAAE,aAAa,CAAA;CAAE,CAAC,CAAC;AAE/G;;GAEG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,cAAc,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAC7G,eAAe,EACf,CAAC,CACF,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,CAAC,aAAa,GAAG,OAAO,IAAI,cAAc,CACpE,MAAM,EACN;IAAE,aAAa,EAAE,aAAa,CAAC;IAAC,oBAAoB,EAAE,IAAI,CAAA;CAAE,CAC7D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,cAAc,CAAC,GAAG,CAAC,QACzD,CAAC,YACG,SAAS,MAAM,EAAE,KAC1B,gBAAgB,CAAC,uBAAuB,CAAC,CAAC,CAAC,CACiC,CAAC;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,IAAI,UAChC,gBAAgB,CAAC,IAAI,CAAC,KAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAO7E,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,GAC3B,aAAa,GAAG,IAAI,QACpB,CAAC,SAAS,MAAM,aAAa,CAAC;mBAOa,aAAa;EACxD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IComputedValue } from "mobx";
|
|
2
|
+
import type { HotbarItemId } from "./hotbar-item-id";
|
|
3
|
+
import type { HotbarItemKindId } from "./hotbar-item-kind";
|
|
4
|
+
/**
|
|
5
|
+
* The persisted data of one item, wrapped so that "no data persisted" and "persisted
|
|
6
|
+
* `undefined`" (a kind without data) stay distinguishable.
|
|
7
|
+
*/
|
|
8
|
+
export interface HotbarItemPersistedDataEntry<PersistedData = unknown> {
|
|
9
|
+
readonly persistedData: PersistedData;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The persisted data of every item of one kind, keyed by item id.
|
|
13
|
+
*/
|
|
14
|
+
export interface HotbarItemPersistedDataStore<PersistedData = unknown> {
|
|
15
|
+
/** The item's entry, `undefined` until the store has loaded and while the item has none. */
|
|
16
|
+
readonly get: (id: HotbarItemId) => IComputedValue<HotbarItemPersistedDataEntry<PersistedData> | undefined>;
|
|
17
|
+
/** Persists the item's data, resolving once the store has loaded and taken it. */
|
|
18
|
+
readonly set: (id: HotbarItemId, persistedData: PersistedData) => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/** What {@link hotbarItemPersistedDataInjectionToken} yields: the store of one kind, by the kind's id. */
|
|
21
|
+
export type HotbarItemPersistedDataStoreFor = (kindId: HotbarItemKindId<any>) => HotbarItemPersistedDataStore;
|
|
22
|
+
/**
|
|
23
|
+
* Where the hotbar keeps the persisted data of items, one store per kind. The data is
|
|
24
|
+
* typed by the kind, which is why the store itself is untyped: `getHotbarItemKindInjectableBunch`
|
|
25
|
+
* binds the type on both the way in (the adder) and the way out (the component), so a kind
|
|
26
|
+
* never touches this directly.
|
|
27
|
+
*
|
|
28
|
+
* Implemented by the hotbar.
|
|
29
|
+
*/
|
|
30
|
+
export declare const hotbarItemPersistedDataInjectionToken: import("@k8slens/injectable").InjectionToken2Base<HotbarItemPersistedDataStoreFor, (kindId: HotbarItemKindId<any>) => HotbarItemPersistedDataStore<unknown>[], "one", (kindId: HotbarItemKindId<any>) => import("@k8slens/injectable").InjectionInstanceWithMeta<HotbarItemPersistedDataStore<unknown>>, (kindId: HotbarItemKindId<any>) => import("@k8slens/injectable").InjectionInstanceWithMeta<HotbarItemPersistedDataStore<unknown>>[]> & {
|
|
31
|
+
readonly __abstract?: never;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=hotbar-item-persisted-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotbar-item-persisted-data.d.ts","sourceRoot":"","sources":["../../src/hotbar-item-persisted-data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,4BAA4B,CAAC,aAAa,GAAG,OAAO;IACnE,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B,CAAC,aAAa,GAAG,OAAO;IACnE,4FAA4F;IAC5F,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,cAAc,CAAC,4BAA4B,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5G,kFAAkF;IAClF,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACjF;AAED,0GAA0G;AAC1G,MAAM,MAAM,+BAA+B,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAC,KAAK,4BAA4B,CAAC;AAE9G;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC;;CAK9C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HotbarItemId } from "./hotbar-item-id";
|
|
2
|
+
import type { HotbarItemKindId } from "./hotbar-item-kind";
|
|
3
|
+
/**
|
|
4
|
+
* One item in the hotbar, as the hotbar persists it: which item it is, and what kind of
|
|
5
|
+
* item it is, as the kind's id. Anything else an item needs travels as the kind's persisted
|
|
6
|
+
* data.
|
|
7
|
+
*/
|
|
8
|
+
export type HotbarItem = {
|
|
9
|
+
id: HotbarItemId;
|
|
10
|
+
kind: HotbarItemKindId;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=hotbar-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotbar-item.d.ts","sourceRoot":"","sources":["../../src/hotbar-item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,YAAY,CAAC;IACjB,IAAI,EAAE,gBAAgB,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HotbarItem } from "./hotbar-item";
|
|
2
|
+
/**
|
|
3
|
+
* Puts an item into the first free slot of the current hotbar page. Tells the user when
|
|
4
|
+
* there is none, or when the item's kind is unknown, instead of throwing.
|
|
5
|
+
*/
|
|
6
|
+
export type InsertHotbarItem = (item: HotbarItem) => Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* The hotbar's own insertion: id and kind only, no persisted data. The typed adder a kind
|
|
9
|
+
* gets from `addToHotbarInjectionToken.for(kind)` persists the data first and then comes
|
|
10
|
+
* here, so reach for that one instead.
|
|
11
|
+
*
|
|
12
|
+
* Implemented by the hotbar.
|
|
13
|
+
*/
|
|
14
|
+
export declare const insertHotbarItemInjectionToken: import("@k8slens/injectable").InjectionToken2Base<() => InsertHotbarItem, () => InsertHotbarItem[], "one", () => import("@k8slens/injectable").InjectionInstanceWithMeta<InsertHotbarItem>, () => import("@k8slens/injectable").InjectionInstanceWithMeta<InsertHotbarItem>[]> & {
|
|
15
|
+
readonly __abstract?: never;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=insert-hotbar-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-hotbar-item.d.ts","sourceRoot":"","sources":["../../src/insert-hotbar-item.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnE;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,0DAA6C,gBAAgB;;CAGpG,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type ManyFactory, type SpecificInjectionToken2 } from "@k8slens/injectable";
|
|
2
|
+
import type { IComputedValue } from "mobx";
|
|
3
|
+
import type { HotbarItemId } from "./hotbar-item-id";
|
|
4
|
+
import { type HotbarItemKind } from "./hotbar-item-kind";
|
|
5
|
+
/** Whether the item of the kind with the id is on the current hotbar page, as of now. */
|
|
6
|
+
export type IsInHotbar = (id: HotbarItemId) => Promise<boolean>;
|
|
7
|
+
/** What `.for(kind).for(scopeIds)` yields: exactly one membership query per kind per scope. */
|
|
8
|
+
export type IsInHotbarTokenFor = SpecificInjectionToken2<{
|
|
9
|
+
singleFactory: () => IsInHotbar;
|
|
10
|
+
specificTokenFactory: undefined;
|
|
11
|
+
cardinality: "one";
|
|
12
|
+
}>;
|
|
13
|
+
/** What `.for(kind)` yields: the kind's membership queries, one per scope, reached with `.for(scopeIds)`. */
|
|
14
|
+
export type IsInHotbarTokenForKind = SpecificInjectionToken2<{
|
|
15
|
+
singleFactory: () => IsInHotbar;
|
|
16
|
+
manyFactory: ManyFactory<() => IsInHotbar>;
|
|
17
|
+
specificTokenFactory: (scopeIds: readonly string[]) => IsInHotbarTokenFor;
|
|
18
|
+
cardinality: "zero-or-many";
|
|
19
|
+
}>;
|
|
20
|
+
declare const isInHotbarTokenForKind: (kind: HotbarItemKind<any>) => IsInHotbarTokenForKind;
|
|
21
|
+
/**
|
|
22
|
+
* Whether an item is in the hotbar, asked once: `.for(kind).for(scopeIds)` yields the query
|
|
23
|
+
* of that kind as registered under those scopes, which takes the id. An item is identified by
|
|
24
|
+
* its kind and then its id, never by the id alone, so two kinds using the same id never answer
|
|
25
|
+
* for each other; the scopes come from the `di.scopeIds` of the injectable asking. For
|
|
26
|
+
* deciding in a handler, say whether a click should add the item or remove it.
|
|
27
|
+
*
|
|
28
|
+
* A promise rather than a boolean because the hotbar loads what it persisted lazily: asked
|
|
29
|
+
* before that, a boolean could only be a guess. For following the answer as it changes, see
|
|
30
|
+
* {@link isInHotbarReactiveInjectionToken}.
|
|
31
|
+
*
|
|
32
|
+
* Registered by `getHotbarItemKindInjectableBunch`, so every registered kind has one.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const isBookmarkInHotbar = di.inject(isInHotbarInjectionToken.for(bookmarkHotbarItemKind).for(di.scopeIds))();
|
|
37
|
+
*
|
|
38
|
+
* if (await isBookmarkInHotbar(id)) {
|
|
39
|
+
* await removeBookmarkFromHotbar(id);
|
|
40
|
+
* } else {
|
|
41
|
+
* await addBookmarkToHotbar({ id, persistedData: { url } });
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const isInHotbarInjectionToken: import("@k8slens/injectable").InjectionToken2Base<() => IsInHotbar, () => IsInHotbar[], "zero-or-many", () => import("@k8slens/injectable").InjectionInstanceWithMeta<IsInHotbar>, () => import("@k8slens/injectable").InjectionInstanceWithMeta<IsInHotbar>[]> & {
|
|
46
|
+
readonly __abstract: true;
|
|
47
|
+
for: typeof isInHotbarTokenForKind;
|
|
48
|
+
};
|
|
49
|
+
/** Whether the item of the kind with the id is on the current hotbar page, reactively. */
|
|
50
|
+
export type IsInHotbarReactive = (id: HotbarItemId) => IComputedValue<boolean>;
|
|
51
|
+
/** What `.for(kind).for(scopeIds)` yields: exactly one reactive membership query per kind per scope. */
|
|
52
|
+
export type IsInHotbarReactiveTokenFor = SpecificInjectionToken2<{
|
|
53
|
+
singleFactory: IsInHotbarReactive;
|
|
54
|
+
specificTokenFactory: undefined;
|
|
55
|
+
cardinality: "one";
|
|
56
|
+
}>;
|
|
57
|
+
/** What `.for(kind)` yields: the kind's reactive membership queries, one per scope, reached with `.for(scopeIds)`. */
|
|
58
|
+
export type IsInHotbarReactiveTokenForKind = SpecificInjectionToken2<{
|
|
59
|
+
singleFactory: IsInHotbarReactive;
|
|
60
|
+
manyFactory: ManyFactory<IsInHotbarReactive>;
|
|
61
|
+
specificTokenFactory: (scopeIds: readonly string[]) => IsInHotbarReactiveTokenFor;
|
|
62
|
+
cardinality: "zero-or-many";
|
|
63
|
+
}>;
|
|
64
|
+
declare const isInHotbarReactiveTokenForKind: (kind: HotbarItemKind<any>) => IsInHotbarReactiveTokenForKind;
|
|
65
|
+
/**
|
|
66
|
+
* Whether an item is in the hotbar, as a MobX computed: `.for(kind).for(scopeIds)` yields the
|
|
67
|
+
* query of that kind as registered under those scopes, which takes the id. Read it under an
|
|
68
|
+
* observer (or a reaction) to follow the user pinning and unpinning. `false` until the hotbar
|
|
69
|
+
* has loaded what it persisted. For a one-off answer, see {@link isInHotbarInjectionToken}.
|
|
70
|
+
*
|
|
71
|
+
* Registered by `getHotbarItemKindInjectableBunch`, so every registered kind has one. A
|
|
72
|
+
* component has no scope of its own, so it takes the query from an injectable that reached it
|
|
73
|
+
* with its `di.scopeIds`.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* const PinState = observer(({ url }: { url: string }) => {
|
|
78
|
+
* const isInHotbar = useInject(isBookmarkInHotbarReactiveInjectable)(idOf(url)).get();
|
|
79
|
+
*
|
|
80
|
+
* return <span>{isInHotbar ? "Pinned" : "Not pinned"}</span>;
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare const isInHotbarReactiveInjectionToken: import("@k8slens/injectable").InjectionToken2Base<IsInHotbarReactive, (id: string) => IComputedValue<boolean>[], "zero-or-many", (id: string) => import("@k8slens/injectable").InjectionInstanceWithMeta<IComputedValue<boolean>>, (id: string) => import("@k8slens/injectable").InjectionInstanceWithMeta<IComputedValue<boolean>>[]> & {
|
|
85
|
+
readonly __abstract: true;
|
|
86
|
+
for: typeof isInHotbarReactiveTokenForKind;
|
|
87
|
+
};
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=is-in-hotbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-in-hotbar.d.ts","sourceRoot":"","sources":["../../src/is-in-hotbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACzG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE9E,yFAAyF;AACzF,MAAM,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhE,+FAA+F;AAC/F,MAAM,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACvD,aAAa,EAAE,MAAM,UAAU,CAAC;IAChC,oBAAoB,EAAE,SAAS,CAAC;IAChC,WAAW,EAAE,KAAK,CAAC;CACpB,CAAC,CAAC;AAEH,6GAA6G;AAC7G,MAAM,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;IAC3D,aAAa,EAAE,MAAM,UAAU,CAAC;IAChC,WAAW,EAAE,WAAW,CAAC,MAAM,UAAU,CAAC,CAAC;IAC3C,oBAAoB,EAAE,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,KAAK,kBAAkB,CAAC;IAC1E,WAAW,EAAE,cAAc,CAAC;CAC7B,CAAC,CAAC;AAEH,QAAA,MAAM,sBAAsB,SAAU,cAAc,CAAC,GAAG,CAAC,KAAG,sBAYzD,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,wBAAwB,0DACd,UAAU;;;CAKP,CAAC;AAE3B,0FAA0F;AAC1F,MAAM,MAAM,kBAAkB,GAAG,CAAC,EAAE,EAAE,YAAY,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC;AAE/E,wGAAwG;AACxG,MAAM,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;IAC/D,aAAa,EAAE,kBAAkB,CAAC;IAClC,oBAAoB,EAAE,SAAS,CAAC;IAChC,WAAW,EAAE,KAAK,CAAC;CACpB,CAAC,CAAC;AAEH,sHAAsH;AACtH,MAAM,MAAM,8BAA8B,GAAG,uBAAuB,CAAC;IACnE,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAC7C,oBAAoB,EAAE,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,KAAK,0BAA0B,CAAC;IAClF,WAAW,EAAE,cAAc,CAAC;CAC7B,CAAC,CAAC;AAEH,QAAA,MAAM,8BAA8B,SAAU,cAAc,CAAC,GAAG,CAAC,KAAG,8BAYjE,CAAC;AAEJ;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gCAAgC;;;CAMX,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type ManyFactory, type SpecificInjectionToken2 } from "@k8slens/injectable";
|
|
2
|
+
import type { HotbarItemId } from "./hotbar-item-id";
|
|
3
|
+
import { type HotbarItemKind } from "./hotbar-item-kind";
|
|
4
|
+
/**
|
|
5
|
+
* Removes the item of the kind with the id from the current hotbar page. Throws when no
|
|
6
|
+
* such item is there.
|
|
7
|
+
*/
|
|
8
|
+
export type RemoveFromHotbar = (id: HotbarItemId) => Promise<void>;
|
|
9
|
+
/** What `.for(kind).for(scopeIds)` yields: exactly one remover per kind per scope. */
|
|
10
|
+
export type RemoveFromHotbarTokenFor = SpecificInjectionToken2<{
|
|
11
|
+
singleFactory: () => RemoveFromHotbar;
|
|
12
|
+
specificTokenFactory: undefined;
|
|
13
|
+
cardinality: "one";
|
|
14
|
+
}>;
|
|
15
|
+
/** What `.for(kind)` yields: the kind's removers, one per scope, reached with `.for(scopeIds)`. */
|
|
16
|
+
export type RemoveFromHotbarTokenForKind = SpecificInjectionToken2<{
|
|
17
|
+
singleFactory: () => RemoveFromHotbar;
|
|
18
|
+
manyFactory: ManyFactory<() => RemoveFromHotbar>;
|
|
19
|
+
specificTokenFactory: (scopeIds: readonly string[]) => RemoveFromHotbarTokenFor;
|
|
20
|
+
cardinality: "zero-or-many";
|
|
21
|
+
}>;
|
|
22
|
+
declare const removeFromHotbarTokenForKind: (kind: HotbarItemKind<any>) => RemoveFromHotbarTokenForKind;
|
|
23
|
+
/**
|
|
24
|
+
* Remove an item from the hotbar: `.for(kind).for(scopeIds)` yields the remover of that kind
|
|
25
|
+
* as registered under those scopes, which takes the id. An item is identified by its kind and
|
|
26
|
+
* then its id, so removing one kind's item leaves another kind's item with the same id alone.
|
|
27
|
+
* The persisted data of the item is left in place, so adding the same id back finds it again.
|
|
28
|
+
* The scopes come from the `di.scopeIds` of the injectable asking.
|
|
29
|
+
*
|
|
30
|
+
* Throws when no item of the kind with the id is on the current page: removing is something
|
|
31
|
+
* done to an item known to be there, so a toggle asks {@link isInHotbarInjectionToken} first.
|
|
32
|
+
*
|
|
33
|
+
* Registered by `getHotbarItemKindInjectableBunch`, so every registered kind has one.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const removeBookmarkFromHotbar = di.inject(removeFromHotbarInjectionToken.for(bookmarkHotbarItemKind).for(di.scopeIds))();
|
|
38
|
+
*
|
|
39
|
+
* await removeBookmarkFromHotbar(`my-extension-bookmark(${url})`);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare const removeFromHotbarInjectionToken: import("@k8slens/injectable").InjectionToken2Base<() => RemoveFromHotbar, () => RemoveFromHotbar[], "zero-or-many", () => import("@k8slens/injectable").InjectionInstanceWithMeta<RemoveFromHotbar>, () => import("@k8slens/injectable").InjectionInstanceWithMeta<RemoveFromHotbar>[]> & {
|
|
43
|
+
readonly __abstract: true;
|
|
44
|
+
for: typeof removeFromHotbarTokenForKind;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=remove-from-hotbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-from-hotbar.d.ts","sourceRoot":"","sources":["../../src/remove-from-hotbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACzG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAG9E;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,EAAE,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnE,sFAAsF;AACtF,MAAM,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;IAC7D,aAAa,EAAE,MAAM,gBAAgB,CAAC;IACtC,oBAAoB,EAAE,SAAS,CAAC;IAChC,WAAW,EAAE,KAAK,CAAC;CACpB,CAAC,CAAC;AAEH,mGAAmG;AACnG,MAAM,MAAM,4BAA4B,GAAG,uBAAuB,CAAC;IACjE,aAAa,EAAE,MAAM,gBAAgB,CAAC;IACtC,WAAW,EAAE,WAAW,CAAC,MAAM,gBAAgB,CAAC,CAAC;IACjD,oBAAoB,EAAE,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,KAAK,wBAAwB,CAAC;IAChF,WAAW,EAAE,cAAc,CAAC;CAC7B,CAAC,CAAC;AAEH,QAAA,MAAM,4BAA4B,SAAU,cAAc,CAAC,GAAG,CAAC,KAAG,4BAY/D,CAAC;AAEJ;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,8BAA8B,0DACpB,gBAAgB;;;CAKP,CAAC"}
|