wraplet 0.27.0 → 0.29.0
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/AbstractWraplet.d.ts +16 -28
- package/dist/Core/DefaultArgCreator.d.ts +10 -0
- package/dist/{DefaultCore.d.ts → Core/DefaultCore.d.ts} +11 -13
- package/dist/Core/defaultWrapletCreator.d.ts +6 -0
- package/dist/Core/types/ArgCreator.d.ts +9 -0
- package/dist/{types → Core/types}/Core.d.ts +10 -23
- package/dist/{types → Core/types}/CoreInitOptions.d.ts +1 -1
- package/dist/Core/types/DestroyChildListener.d.ts +3 -0
- package/dist/Core/types/DestroyListener.d.ts +2 -0
- package/dist/Core/types/InstantiateChildListener.d.ts +3 -0
- package/dist/Core/types/WrapletCreator.d.ts +15 -0
- package/dist/Map/MapRepeat.d.ts +2 -2
- package/dist/Map/MapWrapper.d.ts +1 -1
- package/dist/{types/Map → Map/types}/DynamicMap.d.ts +2 -2
- package/dist/{WrapletChildrenMap.d.ts → Map/utils.d.ts} +2 -2
- package/dist/NodeTreeManager/DefaultNodeTreeManager.d.ts +6 -6
- package/dist/NodeTreeManager/types/NodeTreeManager.d.ts +8 -0
- package/dist/{types → NodeTreeManager/types}/NodeTreeParent.d.ts +4 -2
- package/dist/{utils.d.ts → NodeTreeManager/utils.d.ts} +4 -4
- package/dist/Set/DefaultSearchableSet.d.ts +1 -1
- package/dist/Set/DefaultWrapletSet.d.ts +3 -3
- package/dist/Set/DefaultWrapletSetReadonly.d.ts +2 -2
- package/dist/{types/Set → Set/types}/WrapletSet.d.ts +1 -1
- package/dist/{types/Set → Set/types}/WrapletSetReadonly.d.ts +1 -1
- package/dist/Storage/AbstractNongranularKeyValueStorage.d.ts +28 -0
- package/dist/Storage/ElementAttributeStorage.d.ts +17 -0
- package/dist/Storage/ElementStorage.d.ts +10 -28
- package/dist/Storage/InMemoryKeyValueStorage.d.ts +0 -0
- package/dist/Storage/NongranularStorageOptions.d.ts +5 -0
- package/dist/Storage/StorageWrapper.d.ts +21 -0
- package/dist/Storage/types/KeyValueStorage.d.ts +13 -0
- package/dist/Storage/types/KeyValueStorageReadonly.d.ts +6 -0
- package/dist/Wraplet/createWrapletApi.d.ts +6 -0
- package/dist/Wraplet/types/Status.d.ts +9 -0
- package/dist/Wraplet/types/Wraplet.d.ts +8 -0
- package/dist/Wraplet/types/WrapletApi.d.ts +12 -0
- package/dist/Wraplet/types/WrapletApiFactoryArgs.d.ts +16 -0
- package/dist/Wraplet/types/WrapletApiFactoryBasicCallback.d.ts +1 -0
- package/dist/{types → Wraplet/types}/WrapletChildDefinition.d.ts +3 -3
- package/dist/{types → Wraplet/types}/WrapletChildren.d.ts +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -12
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.cjs.map +1 -1
- package/dist/storage.d.ts +7 -2
- package/dist/storage.js +1 -1
- package/dist/storage.js.map +1 -1
- package/dist/types/Groupable.d.ts +4 -2
- package/dist/types/global.d.ts +1 -1
- package/dist/utils/is.d.ts +5 -0
- package/dist/{types → utils/types}/Utils.d.ts +0 -5
- package/package.json +2 -2
- package/dist/NodeTreeManager/NodeTreeManager.d.ts +0 -8
- package/dist/types/DestroyChildListener.d.ts +0 -3
- package/dist/types/DestroyListener.d.ts +0 -2
- package/dist/types/InstantiateChildListener.d.ts +0 -3
- package/dist/types/Storage/Storage.d.ts +0 -9
- package/dist/types/Storage/StorageReadonly.d.ts +0 -6
- package/dist/types/Wraplet.d.ts +0 -14
- package/dist/types/WrapletCreator.d.ts +0 -15
- /package/dist/{types/Set → Set/types}/BaseSet.d.ts +0 -0
- /package/dist/{types/Storage → Storage/types}/StorageValidators.d.ts +0 -0
- /package/dist/{types → Wraplet/types}/ChildInstance.d.ts +0 -0
- /package/dist/{types → Wraplet/types}/WrapletChildrenMap.d.ts +0 -0
|
@@ -1,44 +1,32 @@
|
|
|
1
|
-
import { WrapletChildrenMap } from "./types/WrapletChildrenMap";
|
|
2
|
-
import { WrapletChildren } from "./types/WrapletChildren";
|
|
3
|
-
import { Wraplet, WrapletSymbol } from "./types/Wraplet";
|
|
4
|
-
import { DestroyListener } from "./types/DestroyListener";
|
|
5
|
-
import { ChildInstance } from "./types/ChildInstance";
|
|
6
|
-
import { Groupable, GroupableSymbol
|
|
7
|
-
import { NodeTreeParent, NodeTreeParentSymbol } from "./types/NodeTreeParent";
|
|
8
|
-
import { Core } from "./types/Core";
|
|
1
|
+
import { WrapletChildrenMap } from "./Wraplet/types/WrapletChildrenMap";
|
|
2
|
+
import { WrapletChildren } from "./Wraplet/types/WrapletChildren";
|
|
3
|
+
import { Wraplet, WrapletSymbol } from "./Wraplet/types/Wraplet";
|
|
4
|
+
import { DestroyListener } from "./Core/types/DestroyListener";
|
|
5
|
+
import { ChildInstance } from "./Wraplet/types/ChildInstance";
|
|
6
|
+
import { Groupable, GroupableSymbol } from "./types/Groupable";
|
|
7
|
+
import { NodeTreeParent, NodeTreeParentSymbol } from "./NodeTreeManager/types/NodeTreeParent";
|
|
8
|
+
import { Core } from "./Core/types/Core";
|
|
9
|
+
import { WrapletApiFactoryArgs } from "./Wraplet/types/WrapletApiFactoryArgs";
|
|
10
|
+
import { WrapletApi } from "./Wraplet/types/WrapletApi";
|
|
9
11
|
export declare abstract class AbstractWraplet<N extends Node = Node, M extends WrapletChildrenMap = {}> implements Wraplet<N>, Groupable, NodeTreeParent {
|
|
10
12
|
protected core: Core<N, M>;
|
|
11
13
|
[WrapletSymbol]: true;
|
|
12
14
|
[GroupableSymbol]: true;
|
|
13
15
|
[NodeTreeParentSymbol]: true;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
isGettingInitialized: boolean;
|
|
17
|
-
isInitialized: boolean;
|
|
18
|
-
private groupsExtractor;
|
|
19
|
-
private destroyListeners;
|
|
20
|
-
/**
|
|
21
|
-
* This is the log of all node accessors, available for easier debugging.
|
|
22
|
-
*/
|
|
23
|
-
private __debugNodeAccessors;
|
|
16
|
+
protected destroyListeners: DestroyListener<N>[];
|
|
17
|
+
wraplet: WrapletApi<N> & NodeTreeParent["wraplet"] & Groupable["wraplet"];
|
|
24
18
|
constructor(core: Core<N, M>);
|
|
25
|
-
|
|
26
|
-
setGroupsExtractor(callback: GroupExtractor): void;
|
|
27
|
-
getGroups(): string[];
|
|
19
|
+
protected createWrapletApi(args: WrapletApiFactoryArgs<N, M>): WrapletApi<N> & NodeTreeParent["wraplet"] & Groupable["wraplet"];
|
|
28
20
|
protected get children(): WrapletChildren<M>;
|
|
29
|
-
accessNode(callback: (node: N) => void): void;
|
|
30
|
-
destroy(): void;
|
|
31
|
-
addDestroyListener(callback: DestroyListener<N>): void;
|
|
32
21
|
/**
|
|
33
22
|
* This method will be ivoked if one of the wraplet's children has been destroyed.
|
|
34
23
|
*/
|
|
35
|
-
protected
|
|
36
|
-
protected initialize(): void;
|
|
24
|
+
protected onChildDestroy(child: ChildInstance<M, keyof M>, id: keyof M): void;
|
|
37
25
|
protected get node(): N;
|
|
38
26
|
/**
|
|
39
|
-
* This method will be
|
|
27
|
+
* This method will be invoked if one of the wraplet's children has been instantiated.
|
|
40
28
|
*/
|
|
41
|
-
protected
|
|
29
|
+
protected onChildInstantiate(child: ChildInstance<M, keyof M>, id: keyof M): void;
|
|
42
30
|
/**
|
|
43
31
|
* This method makes sure that the given instance is an instance of a class belonging to the
|
|
44
32
|
* given child.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ArgCreator, ArgCreatorSymbol } from "./types/ArgCreator";
|
|
2
|
+
import { WrapletChildrenMap } from "../Wraplet/types/WrapletChildrenMap";
|
|
3
|
+
import { WrapletCreatorArgs } from "./types/WrapletCreator";
|
|
4
|
+
export declare class DefaultArgCreator<N extends Node, M extends WrapletChildrenMap = WrapletChildrenMap> implements ArgCreator<N, M> {
|
|
5
|
+
private creator;
|
|
6
|
+
[ArgCreatorSymbol]: true;
|
|
7
|
+
constructor(creator: ArgCreator<N, M>["createArg"]);
|
|
8
|
+
createArg(args: WrapletCreatorArgs<N, M>): unknown;
|
|
9
|
+
static create<N extends Node, M extends WrapletChildrenMap = WrapletChildrenMap>(creator: ArgCreator<N, M>["createArg"]): DefaultArgCreator<N, M>;
|
|
10
|
+
}
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import { WrapletChildren } from "
|
|
2
|
-
import { Wraplet } from "
|
|
3
|
-
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "
|
|
1
|
+
import { WrapletChildren } from "../Wraplet/types/WrapletChildren";
|
|
2
|
+
import { Wraplet } from "../Wraplet/types/Wraplet";
|
|
3
|
+
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "../Wraplet/types/WrapletChildrenMap";
|
|
4
4
|
import { InstantiateChildListener } from "./types/InstantiateChildListener";
|
|
5
5
|
import { DestroyChildListener } from "./types/DestroyChildListener";
|
|
6
6
|
import { CoreInitOptions } from "./types/CoreInitOptions";
|
|
7
7
|
import { Core, CoreSymbol } from "./types/Core";
|
|
8
|
-
import { NodeTreeParentSymbol } from "
|
|
9
|
-
import { MapWrapper } from "
|
|
8
|
+
import { NodeTreeParentSymbol } from "../NodeTreeManager/types/NodeTreeParent";
|
|
9
|
+
import { MapWrapper } from "../Map/MapWrapper";
|
|
10
10
|
import { WrapletCreator } from "./types/WrapletCreator";
|
|
11
|
+
import { Status } from "../Wraplet/types/Status";
|
|
11
12
|
export declare class DefaultCore<N extends Node = Node, M extends WrapletChildrenMap = {}> implements Core<N, M> {
|
|
12
13
|
node: N;
|
|
13
14
|
[CoreSymbol]: true;
|
|
14
15
|
[NodeTreeParentSymbol]: true;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
isGettingInitialized: boolean;
|
|
18
|
-
isInitialized: boolean;
|
|
16
|
+
private statusWritable;
|
|
17
|
+
get status(): Status;
|
|
19
18
|
mapWrapper: MapWrapper<M>;
|
|
20
19
|
private instantiatedChildren;
|
|
21
20
|
private destroyChildListeners;
|
|
22
21
|
private instantiateChildListeners;
|
|
23
22
|
private listeners;
|
|
24
|
-
private defaultWrapletCreator;
|
|
25
23
|
private wrapletCreator;
|
|
26
24
|
constructor(node: N, map: M | MapWrapper<M>, initOptions?: Partial<CoreInitOptions<M>>);
|
|
27
25
|
/**
|
|
@@ -31,7 +29,7 @@ export declare class DefaultCore<N extends Node = Node, M extends WrapletChildre
|
|
|
31
29
|
* processing occurs (instantiate child listeners) that needs access to the children manager,
|
|
32
30
|
* so the children manager has to exist already.
|
|
33
31
|
*/
|
|
34
|
-
|
|
32
|
+
initialize(): Promise<void>;
|
|
35
33
|
get map(): WrapletChildrenMapWithDefaults<M>;
|
|
36
34
|
instantiateChildren(): WrapletChildren<M>;
|
|
37
35
|
syncChildren(): void;
|
|
@@ -42,12 +40,12 @@ export declare class DefaultCore<N extends Node = Node, M extends WrapletChildre
|
|
|
42
40
|
private instantiateMultipleWrapletsChild;
|
|
43
41
|
addDestroyChildListener(callback: DestroyChildListener<M, keyof M>): void;
|
|
44
42
|
addInstantiateChildListener(callback: InstantiateChildListener<M, keyof M>): void;
|
|
45
|
-
setWrapletCreator(wrapletCreator: WrapletCreator<
|
|
43
|
+
setWrapletCreator(wrapletCreator: WrapletCreator<Node, WrapletChildrenMap>): void;
|
|
46
44
|
private prepareIndividualWraplet;
|
|
47
45
|
/**
|
|
48
46
|
* This method removes from nodes references to this wraplet and its children recursively.
|
|
49
47
|
*/
|
|
50
|
-
destroy(): void
|
|
48
|
+
destroy(): Promise<void>;
|
|
51
49
|
private findChildren;
|
|
52
50
|
addEventListener(node: Node, eventName: string, callback: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean): void;
|
|
53
51
|
get children(): WrapletChildren<M>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WrapletCreatorArgs } from "./types/WrapletCreator";
|
|
2
|
+
import { WrapletChildrenMap } from "../Wraplet/types/WrapletChildrenMap";
|
|
3
|
+
import { Constructable } from "../utils/types/Utils";
|
|
4
|
+
import { Core } from "./types/Core";
|
|
5
|
+
import { Wraplet } from "../Wraplet/types/Wraplet";
|
|
6
|
+
export declare function defaultWrapletCreator(args: WrapletCreatorArgs<Node, WrapletChildrenMap>, currentCoreClass: Constructable<Core>): Wraplet;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WrapletCreatorArgs } from "./WrapletCreator";
|
|
2
|
+
import { WrapletChildrenMap } from "../../Wraplet/types/WrapletChildrenMap";
|
|
3
|
+
declare const ArgCreatorSymbol: unique symbol;
|
|
4
|
+
export { ArgCreatorSymbol };
|
|
5
|
+
export interface ArgCreator<N extends Node, M extends WrapletChildrenMap = {}> {
|
|
6
|
+
[ArgCreatorSymbol]: true;
|
|
7
|
+
createArg(args: WrapletCreatorArgs<N, M>): unknown;
|
|
8
|
+
}
|
|
9
|
+
export declare function isArgCreator<N extends Node, M extends WrapletChildrenMap = {}>(object: unknown): object is ArgCreator<N, M>;
|
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
import { WrapletChildren } from "
|
|
2
|
-
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "
|
|
1
|
+
import { WrapletChildren } from "../../Wraplet/types/WrapletChildren";
|
|
2
|
+
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "../../Wraplet/types/WrapletChildrenMap";
|
|
3
3
|
import { DestroyChildListener } from "./DestroyChildListener";
|
|
4
4
|
import { InstantiateChildListener } from "./InstantiateChildListener";
|
|
5
|
-
import {
|
|
6
|
-
import { Wraplet } from "./Wraplet";
|
|
5
|
+
import { Wraplet } from "../../Wraplet/types/Wraplet";
|
|
7
6
|
import { WrapletCreator } from "./WrapletCreator";
|
|
7
|
+
import { Status } from "../../Wraplet/types/Status";
|
|
8
8
|
declare const CoreSymbol: unique symbol;
|
|
9
9
|
export { CoreSymbol };
|
|
10
10
|
/**
|
|
11
11
|
* Children manager interface that defines the public API for managing wraplet relationships
|
|
12
12
|
* and lifecycles.
|
|
13
13
|
*/
|
|
14
|
-
export interface Core<N extends Node = Node, M extends WrapletChildrenMap = {}>
|
|
14
|
+
export interface Core<N extends Node = Node, M extends WrapletChildrenMap = {}> {
|
|
15
15
|
[CoreSymbol]: true;
|
|
16
|
-
[NodeTreeParentSymbol]: true;
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
17
|
+
* Core status.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Indicates whether the core is in the process of being destroyed.
|
|
23
|
-
*/
|
|
24
|
-
isGettingDestroyed: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Indicates whether the core is in the process of being initialized.
|
|
27
|
-
*/
|
|
28
|
-
isGettingInitialized: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Indicates whether the core has been initialized.
|
|
31
|
-
*/
|
|
32
|
-
isInitialized: boolean;
|
|
19
|
+
status: Status;
|
|
33
20
|
/**
|
|
34
21
|
* The children map that defines the relationships between nodes.
|
|
35
22
|
*/
|
|
@@ -42,7 +29,7 @@ export interface Core<N extends Node = Node, M extends WrapletChildrenMap = {}>
|
|
|
42
29
|
* Initialize the core.
|
|
43
30
|
* This must be called after construction to fully initialize the core.
|
|
44
31
|
*/
|
|
45
|
-
|
|
32
|
+
initialize(): Promise<void>;
|
|
46
33
|
/**
|
|
47
34
|
* Instantiate children based on the map and the current node.
|
|
48
35
|
*/
|
|
@@ -62,7 +49,7 @@ export interface Core<N extends Node = Node, M extends WrapletChildrenMap = {}>
|
|
|
62
49
|
/**
|
|
63
50
|
* Destroy all children.
|
|
64
51
|
*/
|
|
65
|
-
destroy(): void
|
|
52
|
+
destroy(): Promise<void>;
|
|
66
53
|
/**
|
|
67
54
|
* Add an event listener to a node and track it for cleanup.
|
|
68
55
|
*/
|
|
@@ -71,7 +58,7 @@ export interface Core<N extends Node = Node, M extends WrapletChildrenMap = {}>
|
|
|
71
58
|
/**
|
|
72
59
|
* Allows for overriding the default wraplet creation process.
|
|
73
60
|
*/
|
|
74
|
-
setWrapletCreator(wrapletCreator: WrapletCreator<
|
|
61
|
+
setWrapletCreator(wrapletCreator: WrapletCreator<Node, WrapletChildrenMap>): void;
|
|
75
62
|
/**
|
|
76
63
|
* Get the instantiated children.
|
|
77
64
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InstantiateChildListener } from "./InstantiateChildListener";
|
|
2
|
-
import { WrapletChildrenMap } from "
|
|
2
|
+
import { WrapletChildrenMap } from "../../Wraplet/types/WrapletChildrenMap";
|
|
3
3
|
import { DestroyChildListener } from "./DestroyChildListener";
|
|
4
4
|
export type CoreInitOptions<M extends WrapletChildrenMap = WrapletChildrenMap> = {
|
|
5
5
|
instantiateChildListeners: InstantiateChildListener<M, keyof M>[];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { WrapletChildrenMap } from "../../Wraplet/types/WrapletChildrenMap";
|
|
2
|
+
import { ChildInstance } from "../../Wraplet/types/ChildInstance";
|
|
3
|
+
export type DestroyChildListener<M extends WrapletChildrenMap, K extends keyof M> = (wraplet: ChildInstance<M, K>, id: K) => void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { WrapletChildrenMap } from "../../Wraplet/types/WrapletChildrenMap";
|
|
2
|
+
import { ChildInstance } from "../../Wraplet/types/ChildInstance";
|
|
3
|
+
export type InstantiateChildListener<M extends WrapletChildrenMap, K extends keyof M> = (wraplet: ChildInstance<M, K>, id: K) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Wraplet } from "../../Wraplet/types/Wraplet";
|
|
2
|
+
import { MapWrapper } from "../../Map/MapWrapper";
|
|
3
|
+
import { WrapletChildrenMap } from "../../Wraplet/types/WrapletChildrenMap";
|
|
4
|
+
import { CoreInitOptions } from "./CoreInitOptions";
|
|
5
|
+
import { Constructable } from "../../utils/types/Utils";
|
|
6
|
+
import { Core } from "./Core";
|
|
7
|
+
export type WrapletCreator<N extends Node, M extends WrapletChildrenMap> = (args: WrapletCreatorArgs<N, M>, currentCoreClass: Constructable<Core>) => Wraplet<N>;
|
|
8
|
+
export type WrapletCreatorArgs<N extends Node, M extends WrapletChildrenMap> = {
|
|
9
|
+
id: keyof M;
|
|
10
|
+
Class: Constructable<Wraplet<N>>;
|
|
11
|
+
element: N;
|
|
12
|
+
map: MapWrapper<M>;
|
|
13
|
+
initOptions: CoreInitOptions<M>;
|
|
14
|
+
args: unknown[];
|
|
15
|
+
};
|
package/dist/Map/MapRepeat.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MapWrapper } from "./MapWrapper";
|
|
2
|
-
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "../types/WrapletChildrenMap";
|
|
3
|
-
import { DynamicMap, DynamicMapSymbol } from "
|
|
2
|
+
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "../Wraplet/types/WrapletChildrenMap";
|
|
3
|
+
import { DynamicMap, DynamicMapSymbol } from "./types/DynamicMap";
|
|
4
4
|
export declare class MapRepeat implements DynamicMap {
|
|
5
5
|
private readonly levels;
|
|
6
6
|
[DynamicMapSymbol]: true;
|
package/dist/Map/MapWrapper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "../types/WrapletChildrenMap";
|
|
1
|
+
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "../Wraplet/types/WrapletChildrenMap";
|
|
2
2
|
type RecursiveMapKeys<T extends WrapletChildrenMap> = {
|
|
3
3
|
[K in keyof T]: T[K] extends {
|
|
4
4
|
map: infer M extends WrapletChildrenMap;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "
|
|
2
|
-
import { MapWrapper } from "
|
|
1
|
+
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "../../Wraplet/types/WrapletChildrenMap";
|
|
2
|
+
import { MapWrapper } from "../MapWrapper";
|
|
3
3
|
declare const DynamicMapSymbol: unique symbol;
|
|
4
4
|
export { DynamicMapSymbol };
|
|
5
5
|
export interface DynamicMap {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WrapletChildDefinition, WrapletChildDefinitionWithDefaults } from "
|
|
2
|
-
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "
|
|
1
|
+
import { WrapletChildDefinition, WrapletChildDefinitionWithDefaults } from "../Wraplet/types/WrapletChildDefinition";
|
|
2
|
+
import { WrapletChildrenMap, WrapletChildrenMapWithDefaults } from "../Wraplet/types/WrapletChildrenMap";
|
|
3
3
|
export declare function addDefaultsToChildDefinition<M extends WrapletChildrenMap, T extends WrapletChildDefinition<M>>(definition: T): WrapletChildDefinitionWithDefaults<T, M>;
|
|
4
4
|
export declare function fillMapWithDefaults<M extends WrapletChildrenMap>(map: M): WrapletChildrenMapWithDefaults<M>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { NodeTreeManager } from "./NodeTreeManager";
|
|
2
|
-
import { Wraplet } from "../types/Wraplet";
|
|
3
|
-
import { WrapletSetReadonly } from "../types/
|
|
4
|
-
export type Initializer = (node: Node) => Wraplet[]
|
|
1
|
+
import { NodeTreeManager } from "./types/NodeTreeManager";
|
|
2
|
+
import { Wraplet } from "../Wraplet/types/Wraplet";
|
|
3
|
+
import { WrapletSetReadonly } from "../Set/types/WrapletSetReadonly";
|
|
4
|
+
export type Initializer = (node: Node) => Promise<Wraplet[]>;
|
|
5
5
|
export default class DefaultNodeTreeManager implements NodeTreeManager {
|
|
6
6
|
private initializers;
|
|
7
7
|
private items;
|
|
8
8
|
addWrapletInitializer(callback: Initializer): void;
|
|
9
|
-
initializeNodeTree(node: Node): void
|
|
10
|
-
destroyNodeTree(node: Node): void
|
|
9
|
+
initializeNodeTree(node: Node): Promise<void>;
|
|
10
|
+
destroyNodeTree(node: Node): Promise<void>;
|
|
11
11
|
getSet(): WrapletSetReadonly;
|
|
12
12
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Initializer } from "../DefaultNodeTreeManager";
|
|
2
|
+
import { WrapletSetReadonly } from "../../Set/types/WrapletSetReadonly";
|
|
3
|
+
export interface NodeTreeManager {
|
|
4
|
+
addWrapletInitializer(callback: Initializer): void;
|
|
5
|
+
initializeNodeTree(node: Node): Promise<void>;
|
|
6
|
+
destroyNodeTree(node: Node): Promise<void>;
|
|
7
|
+
getSet(): WrapletSetReadonly;
|
|
8
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Wraplet } from "
|
|
1
|
+
import { Wraplet } from "../../Wraplet/types/Wraplet";
|
|
2
2
|
declare const NodeTreeParentSymbol: unique symbol;
|
|
3
3
|
export { NodeTreeParentSymbol };
|
|
4
4
|
export interface NodeTreeParent {
|
|
5
5
|
[NodeTreeParentSymbol]: true;
|
|
6
|
-
|
|
6
|
+
wraplet: {
|
|
7
|
+
getNodeTreeChildren(): Wraplet[];
|
|
8
|
+
};
|
|
7
9
|
}
|
|
8
10
|
export declare function isNodeTreeParent(object: object): object is NodeTreeParent;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Wraplet } from "
|
|
2
|
-
import { WrapletSet } from "
|
|
1
|
+
import { Wraplet } from "../Wraplet/types/Wraplet";
|
|
2
|
+
import { WrapletSet } from "../Set/types/WrapletSet";
|
|
3
3
|
export declare function isParentNode(node: Node): node is ParentNode;
|
|
4
4
|
export declare function getWrapletsFromNode<N extends Node = Node, W extends Wraplet<N> = Wraplet<N>>(node: N): WrapletSet<W>;
|
|
5
5
|
export declare function removeWrapletFromNode<N extends Node>(wraplet: Wraplet<N>, node: N): boolean;
|
|
6
6
|
export declare function addWrapletToNode<N extends Node>(wraplet: Wraplet<N>, node: N): void;
|
|
7
|
-
export declare function actOnNodesRecursively(node: Node, callback: (node: Node) => void): void
|
|
8
|
-
export declare function destroyWrapletsRecursively(node: Node): void
|
|
7
|
+
export declare function actOnNodesRecursively(node: Node, callback: (node: Node) => Promise<void>): Promise<void>;
|
|
8
|
+
export declare function destroyWrapletsRecursively(node: Node): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseSet } from "
|
|
1
|
+
import { BaseSet } from "./types/BaseSet";
|
|
2
2
|
export declare class DefaultSearchableSet<T> extends Set<T> implements BaseSet<T> {
|
|
3
3
|
find(filter: (wraplet: T) => boolean): T[];
|
|
4
4
|
findOne(filter: (wraplet: T) => boolean): T | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WrapletSet, WrapletSetSymbol } from "
|
|
2
|
-
import { Wraplet } from "../types/Wraplet";
|
|
1
|
+
import { WrapletSet, WrapletSetSymbol } from "./types/WrapletSet";
|
|
2
|
+
import { Wraplet } from "../Wraplet/types/Wraplet";
|
|
3
3
|
import { DefaultSearchableSet } from "./DefaultSearchableSet";
|
|
4
|
-
import { WrapletSetReadonlySymbol } from "
|
|
4
|
+
import { WrapletSetReadonlySymbol } from "./types/WrapletSetReadonly";
|
|
5
5
|
export declare class DefaultWrapletSet<T extends Wraplet> extends DefaultSearchableSet<T> implements WrapletSet {
|
|
6
6
|
[WrapletSetReadonlySymbol]: true;
|
|
7
7
|
[WrapletSetSymbol]: true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Wraplet } from "../types/Wraplet";
|
|
2
|
-
import { WrapletSetReadonly, WrapletSetReadonlySymbol } from "
|
|
1
|
+
import { Wraplet } from "../Wraplet/types/Wraplet";
|
|
2
|
+
import { WrapletSetReadonly, WrapletSetReadonlySymbol } from "./types/WrapletSetReadonly";
|
|
3
3
|
import { DefaultSearchableSet } from "./DefaultSearchableSet";
|
|
4
4
|
export declare class DefaultWrapletSetReadonly<T extends Wraplet> extends DefaultSearchableSet<T> implements WrapletSetReadonly {
|
|
5
5
|
[WrapletSetReadonlySymbol]: true;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { KeyValueStorage, KeyValueStorageSymbol } from "./types/KeyValueStorage";
|
|
2
|
+
import { StorageValidators } from "./types/StorageValidators";
|
|
3
|
+
import { NongranularStorageOptions } from "./NongranularStorageOptions";
|
|
4
|
+
export declare abstract class AbstractNongranularKeyValueStorage<D extends Record<string, unknown>> implements KeyValueStorage<D> {
|
|
5
|
+
protected defaults: D;
|
|
6
|
+
protected validators: StorageValidators<D>;
|
|
7
|
+
[KeyValueStorageSymbol]: true;
|
|
8
|
+
private data;
|
|
9
|
+
private options;
|
|
10
|
+
constructor(defaults: D, validators: StorageValidators<D>, options: Partial<NongranularStorageOptions<D>>);
|
|
11
|
+
has(key: keyof D): Promise<boolean>;
|
|
12
|
+
get<T extends keyof D>(key: T): Promise<D[T]>;
|
|
13
|
+
getMultiple<T extends keyof D>(keys: T[]): Promise<Pick<D, T>>;
|
|
14
|
+
getAll(): Promise<D>;
|
|
15
|
+
set<T extends keyof D>(key: T, value: D[T]): Promise<void>;
|
|
16
|
+
setMultiple(data: Partial<D>): Promise<void>;
|
|
17
|
+
setAll(data: D): Promise<void>;
|
|
18
|
+
delete(key: keyof D): Promise<void>;
|
|
19
|
+
deleteMultiple(keys: (keyof D)[]): Promise<void>;
|
|
20
|
+
deleteAll(): Promise<void>;
|
|
21
|
+
refresh(): Promise<void>;
|
|
22
|
+
private fetchFreshData;
|
|
23
|
+
private validateData;
|
|
24
|
+
private validateValidators;
|
|
25
|
+
protected abstract getValue(): Promise<string>;
|
|
26
|
+
protected abstract setValue(value: D): Promise<void>;
|
|
27
|
+
protected abstract deleteAllValues(): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StorageValidators } from "./types/StorageValidators";
|
|
2
|
+
import { ElementOptionsMerger } from "./ElementOptionsMerger";
|
|
3
|
+
import { AbstractNongranularKeyValueStorage } from "./AbstractNongranularKeyValueStorage";
|
|
4
|
+
export type ElementStorageOptions<D extends Record<string, unknown>> = {
|
|
5
|
+
keepFresh: boolean;
|
|
6
|
+
elementOptionsMerger: ElementOptionsMerger<D>;
|
|
7
|
+
};
|
|
8
|
+
export declare class ElementAttributeStorage<D extends Record<string, unknown>> extends AbstractNongranularKeyValueStorage<D> {
|
|
9
|
+
private element;
|
|
10
|
+
private attribute;
|
|
11
|
+
protected defaults: D;
|
|
12
|
+
protected validators: StorageValidators<D>;
|
|
13
|
+
constructor(element: Element, attribute: string, defaults: D, validators: StorageValidators<D>, options?: Partial<ElementStorageOptions<D>>);
|
|
14
|
+
protected getValue(): Promise<string>;
|
|
15
|
+
protected setValue(value: D): Promise<void>;
|
|
16
|
+
protected deleteAllValues(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
5
|
-
keepFresh: boolean;
|
|
6
|
-
elementOptionsMerger: ElementOptionsMerger<D>;
|
|
7
|
-
};
|
|
8
|
-
export declare class ElementStorage<D extends Record<string, unknown>> implements Storage<D> {
|
|
1
|
+
import { StorageValidators } from "./types/StorageValidators";
|
|
2
|
+
import { AbstractNongranularKeyValueStorage } from "./AbstractNongranularKeyValueStorage";
|
|
3
|
+
import { NongranularStorageOptions } from "./NongranularStorageOptions";
|
|
4
|
+
export declare class ElementStorage<D extends Record<string, unknown>, E extends Element = HTMLScriptElement> extends AbstractNongranularKeyValueStorage<D> {
|
|
9
5
|
private element;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
has(key: keyof D): boolean;
|
|
17
|
-
get<T extends keyof D>(key: T): D[T];
|
|
18
|
-
getMultiple<T extends keyof D>(keys: T[]): Pick<D, T>;
|
|
19
|
-
getAll(): D;
|
|
20
|
-
set<T extends keyof D>(key: T, value: D[T]): void;
|
|
21
|
-
setMultiple(data: Partial<D>): void;
|
|
22
|
-
setAll(data: D): void;
|
|
23
|
-
delete(key: keyof D): void;
|
|
24
|
-
deleteMultiple(keys: (keyof D)[]): void;
|
|
25
|
-
deleteAll(): void;
|
|
26
|
-
refresh(): void;
|
|
27
|
-
private fetchFreshData;
|
|
28
|
-
private validateData;
|
|
29
|
-
private getAttributeValue;
|
|
6
|
+
protected defaults: D;
|
|
7
|
+
protected validators: StorageValidators<D>;
|
|
8
|
+
constructor(element: E, defaults: D, validators: StorageValidators<D>, options?: Partial<NongranularStorageOptions<D>>);
|
|
9
|
+
protected getValue(): Promise<string>;
|
|
10
|
+
protected setValue(value: D): Promise<void>;
|
|
11
|
+
protected deleteAllValues(): Promise<void>;
|
|
30
12
|
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { KeyValueStorage, KeyValueStorageSymbol } from "./types/KeyValueStorage";
|
|
2
|
+
import { StorageValidators } from "./types/StorageValidators";
|
|
3
|
+
export declare class StorageWrapper<D extends Record<string, unknown>> implements KeyValueStorage<D> {
|
|
4
|
+
private storage;
|
|
5
|
+
private defaults;
|
|
6
|
+
private validators;
|
|
7
|
+
[KeyValueStorageSymbol]: true;
|
|
8
|
+
constructor(storage: KeyValueStorage<D>, defaults: D, validators: StorageValidators<D>);
|
|
9
|
+
has(key: keyof D): Promise<boolean>;
|
|
10
|
+
get<T extends keyof D>(key: T): Promise<D[T]>;
|
|
11
|
+
getMultiple<T extends keyof D>(keys: T[]): Promise<Pick<D, T>>;
|
|
12
|
+
getAll(): Promise<D>;
|
|
13
|
+
set<T extends keyof D>(key: T, value: D[T]): Promise<void>;
|
|
14
|
+
setMultiple(data: Partial<D>): Promise<void>;
|
|
15
|
+
setAll(data: D): Promise<void>;
|
|
16
|
+
delete(key: keyof D): Promise<void>;
|
|
17
|
+
deleteMultiple(keys: (keyof D)[]): Promise<void>;
|
|
18
|
+
deleteAll(): Promise<void>;
|
|
19
|
+
private validateGetValue;
|
|
20
|
+
private validateSetValue;
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { KeyValueStorageReadonly } from "./KeyValueStorageReadonly";
|
|
2
|
+
declare const KeyValueStorageSymbol: unique symbol;
|
|
3
|
+
export { KeyValueStorageSymbol };
|
|
4
|
+
export interface KeyValueStorage<D extends Record<string, unknown>> extends KeyValueStorageReadonly<D> {
|
|
5
|
+
[KeyValueStorageSymbol]: true;
|
|
6
|
+
set: <T extends keyof D>(key: T, value: D[T]) => Promise<void>;
|
|
7
|
+
setMultiple: (data: Partial<D>) => Promise<void>;
|
|
8
|
+
setAll: (data: D) => Promise<void>;
|
|
9
|
+
delete: (key: keyof D) => Promise<void>;
|
|
10
|
+
deleteMultiple: (keys: (keyof D)[]) => Promise<void>;
|
|
11
|
+
deleteAll: () => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare function isKeyValueStorage<D extends Record<string, unknown>>(object: unknown): object is KeyValueStorage<D>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type KeyValueStorageReadonly<D extends Record<string, unknown>> = {
|
|
2
|
+
get: <T extends keyof D>(key: T) => Promise<D[T]>;
|
|
3
|
+
getMultiple: <T extends keyof D>(keys: T[]) => Promise<Pick<D, T>>;
|
|
4
|
+
getAll: () => Promise<D>;
|
|
5
|
+
has: (key: keyof D) => Promise<boolean>;
|
|
6
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WrapletChildrenMap } from "./types/WrapletChildrenMap";
|
|
2
|
+
import { Groupable } from "../types/Groupable";
|
|
3
|
+
import { NodeTreeParent } from "../NodeTreeManager/types/NodeTreeParent";
|
|
4
|
+
import { WrapletApiFactoryArgs } from "./types/WrapletApiFactoryArgs";
|
|
5
|
+
import { WrapletApi, WrapletApiDebug } from "./types/WrapletApi";
|
|
6
|
+
export declare const createWrapletApi: <N extends Node, M extends WrapletChildrenMap>(args: WrapletApiFactoryArgs<N, M>) => WrapletApi<N> & WrapletApiDebug<N> & NodeTreeParent["wraplet"] & Groupable["wraplet"];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WrapletApi } from "./WrapletApi";
|
|
2
|
+
declare const WrapletSymbol: unique symbol;
|
|
3
|
+
export { WrapletSymbol };
|
|
4
|
+
export interface Wraplet<N extends Node = Node> {
|
|
5
|
+
[WrapletSymbol]: true;
|
|
6
|
+
wraplet: WrapletApi<N>;
|
|
7
|
+
}
|
|
8
|
+
export declare function isWraplet<N extends Node>(object: unknown): object is Wraplet<N>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DestroyListener } from "../../Core/types/DestroyListener";
|
|
2
|
+
import { Status } from "./Status";
|
|
3
|
+
export interface WrapletApi<N extends Node = Node> {
|
|
4
|
+
status: Status;
|
|
5
|
+
accessNode(callback: (node: N) => void): void;
|
|
6
|
+
destroy(): Promise<void>;
|
|
7
|
+
initialize(): Promise<void>;
|
|
8
|
+
addDestroyListener(callback: DestroyListener<N>): void;
|
|
9
|
+
}
|
|
10
|
+
export interface WrapletApiDebug<N extends Node> {
|
|
11
|
+
__nodeAccessors: ((node: N) => void)[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WrapletChildrenMap } from "./WrapletChildrenMap";
|
|
2
|
+
import { Core } from "../../Core/types/Core";
|
|
3
|
+
import { DestroyListener } from "../../Core/types/DestroyListener";
|
|
4
|
+
import { WrapletApiFactoryBasicCallback } from "./WrapletApiFactoryBasicCallback";
|
|
5
|
+
import { GroupExtractor } from "../../types/Groupable";
|
|
6
|
+
import { Status } from "./Status";
|
|
7
|
+
import { Wraplet } from "./Wraplet";
|
|
8
|
+
export type WrapletApiFactoryArgs<N extends Node = Node, M extends WrapletChildrenMap = WrapletChildrenMap> = {
|
|
9
|
+
core: Core<N, M>;
|
|
10
|
+
wraplet: Wraplet<N>;
|
|
11
|
+
status?: Status;
|
|
12
|
+
destroyListeners?: DestroyListener<N>[];
|
|
13
|
+
initializeCallback?: WrapletApiFactoryBasicCallback;
|
|
14
|
+
destroyCallback?: WrapletApiFactoryBasicCallback;
|
|
15
|
+
groupExtractor?: GroupExtractor;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type WrapletApiFactoryBasicCallback = () => Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Wraplet } from "./Wraplet";
|
|
2
2
|
import { WrapletChildrenMap } from "./WrapletChildrenMap";
|
|
3
|
-
import { CoreInitOptions } from "
|
|
4
|
-
import { DynamicMap } from "
|
|
5
|
-
import { Constructable } from "
|
|
3
|
+
import { CoreInitOptions } from "../../Core/types/CoreInitOptions";
|
|
4
|
+
import { DynamicMap } from "../../Map/types/DynamicMap";
|
|
5
|
+
import { Constructable } from "../../utils/types/Utils";
|
|
6
6
|
export type SelectorCallback<N extends ParentNode = ParentNode> = (node: N) => Node[];
|
|
7
7
|
export type WrapletChildDefinition<M extends WrapletChildrenMap = WrapletChildrenMap> = {
|
|
8
8
|
selector?: string | SelectorCallback;
|