@axi-engine/fields 0.3.5 → 0.3.7
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.mts +50 -3
- package/dist/index.d.ts +1044 -18
- package/dist/index.js +1271 -18
- package/dist/index.mjs +42 -2
- package/package.json +3 -3
- package/dist/core-field-tree-factory.d.ts +0 -13
- package/dist/core-field-tree-factory.d.ts.map +0 -1
- package/dist/core-field-tree-factory.js +0 -14
- package/dist/core-field-tree-factory.js.map +0 -1
- package/dist/core-field-tree.d.ts +0 -5
- package/dist/core-field-tree.d.ts.map +0 -1
- package/dist/core-field-tree.js +0 -4
- package/dist/core-field-tree.js.map +0 -1
- package/dist/core-fields-factory.d.ts +0 -10
- package/dist/core-fields-factory.d.ts.map +0 -1
- package/dist/core-fields-factory.js +0 -14
- package/dist/core-fields-factory.js.map +0 -1
- package/dist/core-fields.d.ts +0 -47
- package/dist/core-fields.d.ts.map +0 -1
- package/dist/core-fields.js +0 -8
- package/dist/core-fields.js.map +0 -1
- package/dist/data-store-field-resolver.d.ts +0 -26
- package/dist/data-store-field-resolver.d.ts.map +0 -1
- package/dist/data-store-field-resolver.js +0 -21
- package/dist/data-store-field-resolver.js.map +0 -1
- package/dist/data-store.d.ts +0 -38
- package/dist/data-store.d.ts.map +0 -1
- package/dist/data-store.js +0 -141
- package/dist/data-store.js.map +0 -1
- package/dist/field-definitions/core-boolean-field.d.ts +0 -11
- package/dist/field-definitions/core-boolean-field.d.ts.map +0 -1
- package/dist/field-definitions/core-boolean-field.js +0 -13
- package/dist/field-definitions/core-boolean-field.js.map +0 -1
- package/dist/field-definitions/core-field.d.ts +0 -51
- package/dist/field-definitions/core-field.d.ts.map +0 -1
- package/dist/field-definitions/core-field.js +0 -74
- package/dist/field-definitions/core-field.js.map +0 -1
- package/dist/field-definitions/core-numeric-field.d.ts +0 -18
- package/dist/field-definitions/core-numeric-field.d.ts.map +0 -1
- package/dist/field-definitions/core-numeric-field.js +0 -45
- package/dist/field-definitions/core-numeric-field.js.map +0 -1
- package/dist/field-definitions/core-string-field.d.ts +0 -15
- package/dist/field-definitions/core-string-field.d.ts.map +0 -1
- package/dist/field-definitions/core-string-field.js +0 -27
- package/dist/field-definitions/core-string-field.js.map +0 -1
- package/dist/field-definitions/index.d.ts +0 -5
- package/dist/field-definitions/index.d.ts.map +0 -1
- package/dist/field-definitions/index.js +0 -5
- package/dist/field-definitions/index.js.map +0 -1
- package/dist/field-registry.d.ts +0 -5
- package/dist/field-registry.d.ts.map +0 -1
- package/dist/field-registry.js +0 -4
- package/dist/field-registry.js.map +0 -1
- package/dist/field-tree-factory.d.ts +0 -12
- package/dist/field-tree-factory.d.ts.map +0 -1
- package/dist/field-tree-factory.js +0 -2
- package/dist/field-tree-factory.js.map +0 -1
- package/dist/field-tree.d.ts +0 -171
- package/dist/field-tree.d.ts.map +0 -1
- package/dist/field-tree.js +0 -248
- package/dist/field-tree.js.map +0 -1
- package/dist/field.d.ts +0 -34
- package/dist/field.d.ts.map +0 -1
- package/dist/field.js +0 -2
- package/dist/field.js.map +0 -1
- package/dist/fields-factory.d.ts +0 -5
- package/dist/fields-factory.d.ts.map +0 -1
- package/dist/fields-factory.js +0 -2
- package/dist/fields-factory.js.map +0 -1
- package/dist/fields.d.ts +0 -101
- package/dist/fields.d.ts.map +0 -1
- package/dist/fields.js +0 -143
- package/dist/fields.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mixins/mixin-factory.d.ts +0 -29
- package/dist/mixins/mixin-factory.d.ts.map +0 -1
- package/dist/mixins/mixin-factory.js +0 -32
- package/dist/mixins/mixin-factory.js.map +0 -1
- package/dist/mixins/with-boolean-fields.mixin.d.ts +0 -9
- package/dist/mixins/with-boolean-fields.mixin.d.ts.map +0 -1
- package/dist/mixins/with-boolean-fields.mixin.js +0 -4
- package/dist/mixins/with-boolean-fields.mixin.js.map +0 -1
- package/dist/mixins/with-default-generic-fields.mixin.d.ts +0 -31
- package/dist/mixins/with-default-generic-fields.mixin.d.ts.map +0 -1
- package/dist/mixins/with-default-generic-fields.mixin.js +0 -15
- package/dist/mixins/with-default-generic-fields.mixin.js.map +0 -1
- package/dist/mixins/with-numeric-fields.mixin.d.ts +0 -9
- package/dist/mixins/with-numeric-fields.mixin.d.ts.map +0 -1
- package/dist/mixins/with-numeric-fields.mixin.js +0 -4
- package/dist/mixins/with-numeric-fields.mixin.js.map +0 -1
- package/dist/mixins/with-string-fields.mixin.d.ts +0 -9
- package/dist/mixins/with-string-fields.mixin.d.ts.map +0 -1
- package/dist/mixins/with-string-fields.mixin.js +0 -4
- package/dist/mixins/with-string-fields.mixin.js.map +0 -1
- package/dist/policies/clamp-max-policy.d.ts +0 -11
- package/dist/policies/clamp-max-policy.d.ts.map +0 -1
- package/dist/policies/clamp-max-policy.js +0 -18
- package/dist/policies/clamp-max-policy.js.map +0 -1
- package/dist/policies/clamp-min-policy.d.ts +0 -11
- package/dist/policies/clamp-min-policy.d.ts.map +0 -1
- package/dist/policies/clamp-min-policy.js +0 -18
- package/dist/policies/clamp-min-policy.js.map +0 -1
- package/dist/policies/clamp-policy.d.ts +0 -12
- package/dist/policies/clamp-policy.d.ts.map +0 -1
- package/dist/policies/clamp-policy.js +0 -21
- package/dist/policies/clamp-policy.js.map +0 -1
- package/dist/policies/index.d.ts +0 -6
- package/dist/policies/index.d.ts.map +0 -1
- package/dist/policies/index.js +0 -6
- package/dist/policies/index.js.map +0 -1
- package/dist/policies/policies.d.ts +0 -38
- package/dist/policies/policies.d.ts.map +0 -1
- package/dist/policies/policies.js +0 -62
- package/dist/policies/policies.js.map +0 -1
- package/dist/policies/policy.d.ts +0 -6
- package/dist/policies/policy.d.ts.map +0 -1
- package/dist/policies/policy.js +0 -2
- package/dist/policies/policy.js.map +0 -1
- package/dist/serializer/field-serializer.d.ts +0 -52
- package/dist/serializer/field-serializer.d.ts.map +0 -1
- package/dist/serializer/field-serializer.js +0 -66
- package/dist/serializer/field-serializer.js.map +0 -1
- package/dist/serializer/field-tree-serializer.d.ts +0 -50
- package/dist/serializer/field-tree-serializer.d.ts.map +0 -1
- package/dist/serializer/field-tree-serializer.js +0 -68
- package/dist/serializer/field-tree-serializer.js.map +0 -1
- package/dist/serializer/fields-serializer.d.ts +0 -49
- package/dist/serializer/fields-serializer.d.ts.map +0 -1
- package/dist/serializer/fields-serializer.js +0 -57
- package/dist/serializer/fields-serializer.js.map +0 -1
- package/dist/serializer/index.d.ts +0 -8
- package/dist/serializer/index.d.ts.map +0 -1
- package/dist/serializer/index.js +0 -8
- package/dist/serializer/index.js.map +0 -1
- package/dist/serializer/policies/clamp-max-policy-serializer-handler.d.ts +0 -13
- package/dist/serializer/policies/clamp-max-policy-serializer-handler.d.ts.map +0 -1
- package/dist/serializer/policies/clamp-max-policy-serializer-handler.js +0 -10
- package/dist/serializer/policies/clamp-max-policy-serializer-handler.js.map +0 -1
- package/dist/serializer/policies/clamp-min-policy-serializer-handler.d.ts +0 -13
- package/dist/serializer/policies/clamp-min-policy-serializer-handler.d.ts.map +0 -1
- package/dist/serializer/policies/clamp-min-policy-serializer-handler.js +0 -10
- package/dist/serializer/policies/clamp-min-policy-serializer-handler.js.map +0 -1
- package/dist/serializer/policies/clamp-policy-serializer-handler.d.ts +0 -16
- package/dist/serializer/policies/clamp-policy-serializer-handler.d.ts.map +0 -1
- package/dist/serializer/policies/clamp-policy-serializer-handler.js +0 -10
- package/dist/serializer/policies/clamp-policy-serializer-handler.js.map +0 -1
- package/dist/serializer/policy-serializer.d.ts +0 -41
- package/dist/serializer/policy-serializer.d.ts.map +0 -1
- package/dist/serializer/policy-serializer.js +0 -43
- package/dist/serializer/policy-serializer.js.map +0 -1
- package/dist/setup.d.ts +0 -41
- package/dist/setup.d.ts.map +0 -1
- package/dist/setup.js +0 -57
- package/dist/setup.js.map +0 -1
- package/dist/store.d.ts +0 -137
- package/dist/store.d.ts.map +0 -1
- package/dist/store.js +0 -2
- package/dist/store.js.map +0 -1
package/dist/field-tree.js
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { Emitter, ensurePathArray, ensurePathString, throwIf, throwIfEmpty } from '@axi-engine/utils';
|
|
2
|
-
import { Fields } from './fields';
|
|
3
|
-
/**
|
|
4
|
-
* Represents a hierarchical data structure for managing the global state of the system.
|
|
5
|
-
*
|
|
6
|
-
* This class acts as the single source of truth for long-term data that exists
|
|
7
|
-
* across different scenes and scripts, such as player stats, inventory,
|
|
8
|
-
* and overall game progress. It uses a path-based system for accessing and
|
|
9
|
-
* manipulating nested data, similar to a file system.
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
export class FieldTree {
|
|
13
|
-
static typeName = 'fieldTree';
|
|
14
|
-
typeName = FieldTree.typeName;
|
|
15
|
-
/** @private The internal map storing child nodes (branches or leaves). */
|
|
16
|
-
_nodes = new Map();
|
|
17
|
-
/** @private The factory used to create new child nodes. */
|
|
18
|
-
_factory;
|
|
19
|
-
/**
|
|
20
|
-
* An event emitter that fires immediately after a new node is added to this tree branch.
|
|
21
|
-
* @event
|
|
22
|
-
* @param {object} event - The event payload.
|
|
23
|
-
* @param {string} event.name - The name (key) of the added node.
|
|
24
|
-
* @param event.node - The node instance that was added.
|
|
25
|
-
* @example
|
|
26
|
-
* myTree.onAdd.subscribe(({ name, node }) => {
|
|
27
|
-
* console.log(`Node '${name}' was added.`, node);
|
|
28
|
-
* });
|
|
29
|
-
*/
|
|
30
|
-
onAdd = new Emitter();
|
|
31
|
-
/**
|
|
32
|
-
* An event emitter that fires once after one or more nodes have been successfully removed.
|
|
33
|
-
* @event
|
|
34
|
-
* @param {object} event - The event payload.
|
|
35
|
-
* @param {string[]} event.names - An array of names of the nodes that were removed.
|
|
36
|
-
* @example
|
|
37
|
-
* myTree.onRemove.subscribe(({ names }) => {
|
|
38
|
-
* console.log(`Nodes removed: ${names.join(', ')}`);
|
|
39
|
-
* });
|
|
40
|
-
*/
|
|
41
|
-
onRemove = new Emitter();
|
|
42
|
-
/**
|
|
43
|
-
* Gets the collection of direct child nodes of this tree branch.
|
|
44
|
-
*/
|
|
45
|
-
get nodes() {
|
|
46
|
-
return this._nodes;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Creates an instance of FieldTree.
|
|
50
|
-
* @param {FieldTreeFactory} factory - A factory responsible for creating new nodes within the tree.
|
|
51
|
-
*/
|
|
52
|
-
constructor(factory) {
|
|
53
|
-
this._factory = factory;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Checks if a direct child node with the given name exists.
|
|
57
|
-
* @param {string} name - The name of the direct child node.
|
|
58
|
-
* @returns {boolean} `true` if the node exists, otherwise `false`.
|
|
59
|
-
*/
|
|
60
|
-
has(name) {
|
|
61
|
-
return this._nodes.has(name);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Checks if a node exists at a given path, traversing the tree.
|
|
65
|
-
* @param {PathType} path - The path to check (e.g., 'player/stats' or ['player', 'stats']).
|
|
66
|
-
* @returns {boolean} `true` if the entire path resolves to a node, otherwise `false`.
|
|
67
|
-
*/
|
|
68
|
-
hasPath(path) {
|
|
69
|
-
const traversedPath = this.traversePath(path);
|
|
70
|
-
return traversedPath.branch.has(traversedPath.leafName);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Adds a pre-existing node as a direct child of this tree branch.
|
|
74
|
-
* @param {string} name - The name to assign to the new child node.
|
|
75
|
-
* @param {TreeNode} node - The node instance to add.
|
|
76
|
-
* @returns {TreeNode} The added node.
|
|
77
|
-
* @throws If a node with the same name already exists.
|
|
78
|
-
*/
|
|
79
|
-
addNode(name, node) {
|
|
80
|
-
throwIf(this.has(name), `Can't add node with name: '${name}', node already exists`);
|
|
81
|
-
this._nodes.set(name, node);
|
|
82
|
-
this.onAdd.emit({ name, node });
|
|
83
|
-
return node;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Retrieves a direct child node by its name.
|
|
87
|
-
* @param {string} name - The name of the child node.
|
|
88
|
-
* @returns {TreeNode} The retrieved node.
|
|
89
|
-
* @throws If a node with the given name cannot be found.
|
|
90
|
-
*/
|
|
91
|
-
getNode(name) {
|
|
92
|
-
const node = this._nodes.get(name);
|
|
93
|
-
throwIfEmpty(node, `Can't find node with name '${name}'`);
|
|
94
|
-
return node;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Removes one or more nodes from this tree branch.
|
|
98
|
-
*
|
|
99
|
-
* This method first validates that all specified nodes exist. If validation passes,
|
|
100
|
-
* it recursively calls `destroy()` on each node to ensure proper cleanup of the entire subtree.
|
|
101
|
-
* Finally, it emits a single `onRemove` event with the names of all successfully removed nodes.
|
|
102
|
-
*
|
|
103
|
-
* @param {string | string[]} names - A single name or an array of names of the nodes to remove.
|
|
104
|
-
* @throws If any of the specified names do not correspond to an existing node.
|
|
105
|
-
*/
|
|
106
|
-
removeNode(names) {
|
|
107
|
-
const toRemoveNames = Array.isArray(names) ? names : [names];
|
|
108
|
-
toRemoveNames.forEach(name => {
|
|
109
|
-
throwIf(!this.has(name), `Can't remove node with name: '${name}', node doesn't exists`);
|
|
110
|
-
});
|
|
111
|
-
toRemoveNames.forEach(name => {
|
|
112
|
-
this._nodes.get(name).destroy();
|
|
113
|
-
this._nodes.delete(name);
|
|
114
|
-
});
|
|
115
|
-
if (toRemoveNames.length) {
|
|
116
|
-
this.onRemove.emit({ names: toRemoveNames });
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Creates a new `FieldTree` (branch) node at the specified path.
|
|
121
|
-
* @param {PathType} path - The path where the new `FieldTree` should be created.
|
|
122
|
-
* @param {boolean} [createPath=false] - If `true`, any missing parent branches in the path will be created automatically.
|
|
123
|
-
* @returns {FieldTree} The newly created `FieldTree` instance.
|
|
124
|
-
* @throws If the path is invalid or a node already exists at the target location.
|
|
125
|
-
*/
|
|
126
|
-
createFieldTree(path, createPath) {
|
|
127
|
-
const traversedPath = this.traversePath(path, createPath);
|
|
128
|
-
return traversedPath.branch.addNode(traversedPath.leafName, this._factory.tree());
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Creates a new `Fields` (leaf) container at the specified path.
|
|
132
|
-
* @param {PathType} path - The path where the new `Fields` container should be created.
|
|
133
|
-
* @param {boolean} [createPath=false] - If `true`, any missing parent branches in the path will be created automatically.
|
|
134
|
-
* @returns {Fields} The newly created `Fields` instance.
|
|
135
|
-
* @throws If the path is invalid or a node already exists at the target location.
|
|
136
|
-
*/
|
|
137
|
-
createFields(path, createPath) {
|
|
138
|
-
const traversedPath = this.traversePath(path, createPath);
|
|
139
|
-
return traversedPath.branch.addNode(traversedPath.leafName, this._factory.fields());
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Retrieves a `FieldTree` (branch) node from a specified path.
|
|
143
|
-
* @param {PathType} path - The path to the `FieldTree` node.
|
|
144
|
-
* @returns {FieldTree} The `FieldTree` instance at the specified path.
|
|
145
|
-
* @throws If the path is invalid or the node at the path is not a `FieldTree`.
|
|
146
|
-
*/
|
|
147
|
-
getFieldTree(path) {
|
|
148
|
-
const traversedPath = this.traversePath(path);
|
|
149
|
-
const node = traversedPath.branch.getNode(traversedPath.leafName);
|
|
150
|
-
throwIf(!(node instanceof FieldTree), `Node with name: ${traversedPath.leafName} by path: '${ensurePathString(path)}' should be instance of FieldTree`);
|
|
151
|
-
return node;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Retrieves a `Fields` (leaf) container from a specified path.
|
|
155
|
-
* @param {PathType} path - The path to the `Fields` container.
|
|
156
|
-
* @returns {Fields} The `Fields` instance at the specified path.
|
|
157
|
-
* @throws If the path is invalid or the node at the path is not a `Fields` container.
|
|
158
|
-
*/
|
|
159
|
-
getFields(path) {
|
|
160
|
-
const traversedPath = this.traversePath(path);
|
|
161
|
-
const node = traversedPath.branch.getNode(traversedPath.leafName);
|
|
162
|
-
throwIf(!(node instanceof Fields), `Node with name: ${traversedPath.leafName} by path: '${ensurePathString(path)}' should be instance of Fields`);
|
|
163
|
-
return node;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Retrieves a `FieldTree` at the specified path. If it or any part of the path doesn't exist, it will be created.
|
|
167
|
-
* @param {PathType} path - The path to the `FieldTree` node.
|
|
168
|
-
* @returns {FieldTree} The existing or newly created `FieldTree` instance.
|
|
169
|
-
*/
|
|
170
|
-
getOrCreateFieldTree(path) {
|
|
171
|
-
const traversedPath = this.traversePath(path, true);
|
|
172
|
-
return traversedPath.branch.has(traversedPath.leafName) ?
|
|
173
|
-
traversedPath.branch.getFieldTree(traversedPath.leafName) :
|
|
174
|
-
traversedPath.branch.createFieldTree(traversedPath.leafName);
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Retrieves a `Fields` container at the specified path. If it or any part of the path doesn't exist, it will be created.
|
|
178
|
-
* @param {PathType} path - The path to the `Fields` container.
|
|
179
|
-
* @returns {Fields} The existing or newly created `Fields` instance.
|
|
180
|
-
*/
|
|
181
|
-
getOrCreateFields(path) {
|
|
182
|
-
const traversedPath = this.traversePath(path, true);
|
|
183
|
-
return traversedPath.branch.has(traversedPath.leafName) ?
|
|
184
|
-
traversedPath.branch.getFields(traversedPath.leafName) :
|
|
185
|
-
traversedPath.branch.createFields(traversedPath.leafName);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Finds the parent node for a given path.
|
|
189
|
-
* @param path The path to the target node.
|
|
190
|
-
* @returns The parent node (either a FieldTree or Fields).
|
|
191
|
-
* @throws An error if the path is invalid or any intermediate node is not a FieldTree.
|
|
192
|
-
*/
|
|
193
|
-
findParentNode(path) {
|
|
194
|
-
const info = this.traversePath(path);
|
|
195
|
-
return info.branch;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Removes all child nodes from this tree branch.
|
|
199
|
-
* This method ensures that `destroy()` is called on each child node, allowing for
|
|
200
|
-
* a full, recursive cleanup of the entire subtree.
|
|
201
|
-
*/
|
|
202
|
-
clear() {
|
|
203
|
-
this.removeNode(Array.from(this._nodes.keys()));
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Performs a complete cleanup of this node and its entire subtree.
|
|
207
|
-
*
|
|
208
|
-
* It recursively destroys all child nodes by calling `clear()` and then
|
|
209
|
-
* unsubscribes all listeners from its own event emitters.
|
|
210
|
-
* This method should be called when a node is no longer needed.
|
|
211
|
-
*/
|
|
212
|
-
destroy() {
|
|
213
|
-
this.clear();
|
|
214
|
-
this.onAdd.clear();
|
|
215
|
-
this.onRemove.clear();
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* @private
|
|
219
|
-
* Navigates the tree to the parent of a target node.
|
|
220
|
-
* This is the core traversal logic for all path-based operations.
|
|
221
|
-
* @param {PathType} path - The full path to the target node.
|
|
222
|
-
* @param {boolean} [createPath=false] - If `true`, creates missing `FieldTree` branches along the path.
|
|
223
|
-
* @returns {{branch: FieldTree, leafName: string}} An object containing the final branch (parent node) and the name of the leaf (target node).
|
|
224
|
-
* @throws If the path is empty, invalid, or contains a `Fields` container as an intermediate segment.
|
|
225
|
-
*/
|
|
226
|
-
traversePath(path, createPath) {
|
|
227
|
-
const pathArr = ensurePathArray(path);
|
|
228
|
-
throwIfEmpty(pathArr, 'The path is empty');
|
|
229
|
-
const leafName = pathArr.pop();
|
|
230
|
-
let currentNode = this;
|
|
231
|
-
for (const pathPart of pathArr) {
|
|
232
|
-
let node;
|
|
233
|
-
if (currentNode.has(pathPart)) {
|
|
234
|
-
node = currentNode.getNode(pathPart);
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
if (createPath) {
|
|
238
|
-
node = currentNode.createFieldTree(pathPart);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
throwIfEmpty(node, `Can't find node with name ${pathPart} by path parsing: ${ensurePathString(path)}`);
|
|
242
|
-
throwIf(node instanceof Fields, `Node with name ${pathPart} should be instance of FieldTree`);
|
|
243
|
-
currentNode = node;
|
|
244
|
-
}
|
|
245
|
-
return { branch: currentNode, leafName: leafName };
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
//# sourceMappingURL=field-tree.js.map
|
package/dist/field-tree.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field-tree.js","sourceRoot":"","sources":["../src/field-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAY,OAAO,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC9G,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAMhC;;;;;;;;GAQG;AACH,MAAM,OAAO,SAAS;IACpB,MAAM,CAAU,QAAQ,GAAG,WAAW,CAAC;IAC9B,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;IAEvC,0EAA0E;IACzD,MAAM,GAAmC,IAAI,GAAG,EAAE,CAAC;IAEpE,2DAA2D;IAC1C,QAAQ,CAA4B;IAErD;;;;;;;;;;OAUG;IACH,KAAK,GAAG,IAAI,OAAO,EAGd,CAAC;IAEN;;;;;;;;;OASG;IACH,QAAQ,GAAG,IAAI,OAAO,EAEjB,CAAC;IAEN;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,YAAY,OAAkC;QAC5C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,IAAc;QACpB,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC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C;QACnB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAED;;;;;;;;OAQG;IACK,YAAY,CAClB,IAAc,EACd,UAAoB;QAEpB,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACtC,YAAY,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAG,CAAC;QAChC,IAAI,WAAW,GAAuB,IAAI,CAAC;QAE3C,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;YAC/B,IAAI,IAAmC,CAAC;YACxC,IAAI,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC9B,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACvC,CAAC;iBAAM,CAAC;gBACN,IAAI,UAAU,EAAE,CAAC;oBACf,IAAI,GAAG,WAAW,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;gBAC/C,CAAC;YACH,CAAC;YACD,YAAY,CAAC,IAAI,EAAE,6BAA6B,QAAQ,qBAAqB,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACvG,OAAO,CAAC,IAAI,YAAY,MAAM,EAAE,kBAAkB,QAAQ,kCAAkC,CAAC,CAAC;YAC9F,WAAW,GAAG,IAA0B,CAAC;QAC3C,CAAC;QAED,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAC,CAAC;IACnD,CAAC"}
|
package/dist/field.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Subscribable } from '@axi-engine/utils';
|
|
2
|
-
import { Policies, Policy } from './policies';
|
|
3
|
-
export interface FieldOptions<T> {
|
|
4
|
-
policies?: Policy<T>[];
|
|
5
|
-
}
|
|
6
|
-
export interface Field<T> {
|
|
7
|
-
readonly typeName: string;
|
|
8
|
-
readonly name: string;
|
|
9
|
-
value: T;
|
|
10
|
-
policies: Policies<T>;
|
|
11
|
-
setValueSilently(val: T): void;
|
|
12
|
-
batchUpdate(updateFn: (currentValue: T) => T): void;
|
|
13
|
-
onChange: Subscribable<[newValue: T, oldValue: T]>;
|
|
14
|
-
destroy(): void;
|
|
15
|
-
}
|
|
16
|
-
export interface NumericField extends Field<number> {
|
|
17
|
-
readonly min: number | undefined;
|
|
18
|
-
readonly max: number | undefined;
|
|
19
|
-
isMin(): boolean;
|
|
20
|
-
isMax(): boolean;
|
|
21
|
-
inc(val: number): void;
|
|
22
|
-
dec(val: number): void;
|
|
23
|
-
}
|
|
24
|
-
export interface BooleanField extends Field<boolean> {
|
|
25
|
-
toggle(): boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface StringField extends Field<string> {
|
|
28
|
-
append(str: string | number): this;
|
|
29
|
-
prepend(str: string | number): this;
|
|
30
|
-
trim(): this;
|
|
31
|
-
isEmpty(): boolean;
|
|
32
|
-
clear(): void;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=field.d.ts.map
|
package/dist/field.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;CACvB;AAED,MAAM,WAAW,KAAK,CAAC,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEtB,gBAAgB,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;IAE/B,WAAW,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAEpD,QAAQ,EAAE,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC,CAAC;IAClD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,MAAM,CAAC;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjC,KAAK,IAAI,OAAO,CAAC;IACjB,KAAK,IAAI,OAAO,CAAC;IAEjB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,OAAO,CAAC;IAClD,MAAM,IAAI,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,WAAY,SAAQ,KAAK,CAAC,MAAM,CAAC;IAChD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAClC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,IAAI,IAAI,IAAI,CAAA;IACZ,OAAO,IAAI,OAAO,CAAA;IAClB,KAAK,IAAI,IAAI,CAAA;CACd"}
|
package/dist/field.js
DELETED
package/dist/field.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":""}
|
package/dist/fields-factory.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fields-factory.d.ts","sourceRoot":"","sources":["../src/fields-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,MAAM,WAAW,aAAa,CAAC,OAAO,SAAS,MAAM;IACnD,MAAM,IAAI,OAAO,CAAC;CACnB"}
|
package/dist/fields-factory.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fields-factory.js","sourceRoot":"","sources":["../src/fields-factory.ts"],"names":[],"mappings":""}
|
package/dist/fields.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { Emitter } from '@axi-engine/utils';
|
|
2
|
-
import { FieldRegistry } from './field-registry';
|
|
3
|
-
import { Field } from './field';
|
|
4
|
-
/**
|
|
5
|
-
* A container for a collection of named `Field` instances.
|
|
6
|
-
*
|
|
7
|
-
* This class acts as a "leaf" node in the `FieldTree` hierarchy, managing a flat
|
|
8
|
-
* key-value store of reactive data points. It uses a `FieldRegistry` to dynamically
|
|
9
|
-
* create `Field` instances of different types.
|
|
10
|
-
*/
|
|
11
|
-
export declare class Fields {
|
|
12
|
-
static readonly typeName = "fields";
|
|
13
|
-
readonly typeName = "fields";
|
|
14
|
-
readonly _fields: Map<string, Field<any>>;
|
|
15
|
-
readonly _fieldRegistry: FieldRegistry;
|
|
16
|
-
/**
|
|
17
|
-
* An event emitter that fires when a new field is added to the collection.
|
|
18
|
-
* @event
|
|
19
|
-
* @param {object} event - The event payload.
|
|
20
|
-
* @param {string} event.name - The name of the added field.
|
|
21
|
-
* @param {Field<any>} event.field - The `Field` instance that was added.
|
|
22
|
-
*/
|
|
23
|
-
onAdd: Emitter<[event: {
|
|
24
|
-
name: string;
|
|
25
|
-
field: Field<any>;
|
|
26
|
-
}]>;
|
|
27
|
-
/**
|
|
28
|
-
* An event emitter that fires after one or more fields have been removed.
|
|
29
|
-
* @event
|
|
30
|
-
* @param {object} event - The event payload.
|
|
31
|
-
* @param {string[]} event.names - An array of names of the fields that were successfully removed.
|
|
32
|
-
*/
|
|
33
|
-
onRemove: Emitter<[event: {
|
|
34
|
-
names: string[];
|
|
35
|
-
}]>;
|
|
36
|
-
/**
|
|
37
|
-
* Gets the read-only map of all `Field` instances in this container.
|
|
38
|
-
* @returns {Map<string, Field<any>>} The collection of fields.
|
|
39
|
-
*/
|
|
40
|
-
get fields(): Map<string, Field<any>>;
|
|
41
|
-
/**
|
|
42
|
-
* Creates an instance of Fields.
|
|
43
|
-
* @param {FieldRegistry} fieldRegistry - The registry used to create new `Field` instances.
|
|
44
|
-
*/
|
|
45
|
-
constructor(fieldRegistry: FieldRegistry);
|
|
46
|
-
/**
|
|
47
|
-
* Checks if a field with the given name exists in the collection.
|
|
48
|
-
* @param {string} name The name of the field to check.
|
|
49
|
-
* @returns {boolean} `true` if the field exists, otherwise `false`.
|
|
50
|
-
*/
|
|
51
|
-
has(name: string): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Adds a pre-existing `Field` instance to the collection and fires the `onAdd` event.
|
|
54
|
-
* @template T - The specific `Field` type being added.
|
|
55
|
-
* @param {Field<any>} field - The `Field` instance to add.
|
|
56
|
-
* @returns {T} The added `Field` instance, cast to type `T`.
|
|
57
|
-
* @throws If a field with the same name already exists.
|
|
58
|
-
*/
|
|
59
|
-
add<T extends Field<any>>(field: Field<any>): T;
|
|
60
|
-
/**
|
|
61
|
-
* Creates a new `Field` instance of a specified type, adds it to the collection, and returns it.
|
|
62
|
-
* This is the primary factory method for creating fields within this container.
|
|
63
|
-
* @template T - The expected `Field` type to be returned.
|
|
64
|
-
* @param {string} typeName - The registered type name of the field to create (e.g., 'numeric', 'boolean').
|
|
65
|
-
* @param {string} name - The unique name for the new field.
|
|
66
|
-
* @param {*} initialValue - The initial value for the new field.
|
|
67
|
-
* @param {*} [options] - Optional configuration passed to the field's constructor.
|
|
68
|
-
* @returns {T} The newly created `Field` instance.
|
|
69
|
-
*/
|
|
70
|
-
create<T extends Field<any>>(typeName: string, name: string, initialValue: any, options?: any): T;
|
|
71
|
-
/**
|
|
72
|
-
* Updates an existing field's value or creates a new one if it doesn't exist.
|
|
73
|
-
* @template T - The expected `Field` type.
|
|
74
|
-
* @param {string} typeName - The type name to use if a new field needs to be created.
|
|
75
|
-
* @param {string} name - The name of the field to update or create.
|
|
76
|
-
* @param {*} value - The new value to set.
|
|
77
|
-
* @param {*} [options] - Optional configuration, used only if a new field is created.
|
|
78
|
-
* @returns {T} The existing or newly created `Field` instance.
|
|
79
|
-
*/
|
|
80
|
-
upset<T extends Field<any>>(typeName: string, name: string, value: any, options?: any): T;
|
|
81
|
-
/**
|
|
82
|
-
* Retrieves a field by its name.
|
|
83
|
-
* @template TField - The expected `Field` type to be returned.
|
|
84
|
-
* @param {string} name - The name of the field to retrieve.
|
|
85
|
-
* @returns {TField} The `Field` instance.
|
|
86
|
-
* @throws If the field does not exist.
|
|
87
|
-
*/
|
|
88
|
-
get<TField extends Field<any>>(name: string): TField;
|
|
89
|
-
/**
|
|
90
|
-
* Removes one or more fields from the collection.
|
|
91
|
-
* This method ensures that the `destroy` method of each removed field is called to clean up its resources.
|
|
92
|
-
* @param {string| string[]} names A single name or an array of names to remove.
|
|
93
|
-
*/
|
|
94
|
-
remove(names: string | string[]): void;
|
|
95
|
-
/**
|
|
96
|
-
* Removes all fields from the collection, ensuring each is properly destroyed.
|
|
97
|
-
*/
|
|
98
|
-
clear(): void;
|
|
99
|
-
destroy(): void;
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=fields.d.ts.map
|
package/dist/fields.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAU,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B;;;;;;GAMG;AACH,qBAAa,MAAM;IACjB,MAAM,CAAC,QAAQ,CAAC,QAAQ,YAA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ist/fields.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { Emitter, throwIf } from '@axi-engine/utils';
|
|
2
|
-
/**
|
|
3
|
-
* A container for a collection of named `Field` instances.
|
|
4
|
-
*
|
|
5
|
-
* This class acts as a "leaf" node in the `FieldTree` hierarchy, managing a flat
|
|
6
|
-
* key-value store of reactive data points. It uses a `FieldRegistry` to dynamically
|
|
7
|
-
* create `Field` instances of different types.
|
|
8
|
-
*/
|
|
9
|
-
export class Fields {
|
|
10
|
-
static typeName = 'fields';
|
|
11
|
-
typeName = Fields.typeName;
|
|
12
|
-
_fields = new Map();
|
|
13
|
-
_fieldRegistry;
|
|
14
|
-
/**
|
|
15
|
-
* An event emitter that fires when a new field is added to the collection.
|
|
16
|
-
* @event
|
|
17
|
-
* @param {object} event - The event payload.
|
|
18
|
-
* @param {string} event.name - The name of the added field.
|
|
19
|
-
* @param {Field<any>} event.field - The `Field` instance that was added.
|
|
20
|
-
*/
|
|
21
|
-
onAdd = new Emitter();
|
|
22
|
-
/**
|
|
23
|
-
* An event emitter that fires after one or more fields have been removed.
|
|
24
|
-
* @event
|
|
25
|
-
* @param {object} event - The event payload.
|
|
26
|
-
* @param {string[]} event.names - An array of names of the fields that were successfully removed.
|
|
27
|
-
*/
|
|
28
|
-
onRemove = new Emitter();
|
|
29
|
-
/**
|
|
30
|
-
* Gets the read-only map of all `Field` instances in this container.
|
|
31
|
-
* @returns {Map<string, Field<any>>} The collection of fields.
|
|
32
|
-
*/
|
|
33
|
-
get fields() {
|
|
34
|
-
return this._fields;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Creates an instance of Fields.
|
|
38
|
-
* @param {FieldRegistry} fieldRegistry - The registry used to create new `Field` instances.
|
|
39
|
-
*/
|
|
40
|
-
constructor(fieldRegistry) {
|
|
41
|
-
this._fieldRegistry = fieldRegistry;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Checks if a field with the given name exists in the collection.
|
|
45
|
-
* @param {string} name The name of the field to check.
|
|
46
|
-
* @returns {boolean} `true` if the field exists, otherwise `false`.
|
|
47
|
-
*/
|
|
48
|
-
has(name) {
|
|
49
|
-
return this._fields.has(name);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Adds a pre-existing `Field` instance to the collection and fires the `onAdd` event.
|
|
53
|
-
* @template T - The specific `Field` type being added.
|
|
54
|
-
* @param {Field<any>} field - The `Field` instance to add.
|
|
55
|
-
* @returns {T} The added `Field` instance, cast to type `T`.
|
|
56
|
-
* @throws If a field with the same name already exists.
|
|
57
|
-
*/
|
|
58
|
-
add(field) {
|
|
59
|
-
throwIf(this.has(field.name), `Field with name '${field.name}' already exists`);
|
|
60
|
-
this._fields.set(field.name, field);
|
|
61
|
-
this.onAdd.emit({
|
|
62
|
-
name: field.name,
|
|
63
|
-
field: field
|
|
64
|
-
});
|
|
65
|
-
return field;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Creates a new `Field` instance of a specified type, adds it to the collection, and returns it.
|
|
69
|
-
* This is the primary factory method for creating fields within this container.
|
|
70
|
-
* @template T - The expected `Field` type to be returned.
|
|
71
|
-
* @param {string} typeName - The registered type name of the field to create (e.g., 'numeric', 'boolean').
|
|
72
|
-
* @param {string} name - The unique name for the new field.
|
|
73
|
-
* @param {*} initialValue - The initial value for the new field.
|
|
74
|
-
* @param {*} [options] - Optional configuration passed to the field's constructor.
|
|
75
|
-
* @returns {T} The newly created `Field` instance.
|
|
76
|
-
*/
|
|
77
|
-
create(typeName, name, initialValue, options) {
|
|
78
|
-
const Ctor = this._fieldRegistry.get(typeName);
|
|
79
|
-
const field = new Ctor(name, initialValue, options);
|
|
80
|
-
this.add(field);
|
|
81
|
-
return field;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Updates an existing field's value or creates a new one if it doesn't exist.
|
|
85
|
-
* @template T - The expected `Field` type.
|
|
86
|
-
* @param {string} typeName - The type name to use if a new field needs to be created.
|
|
87
|
-
* @param {string} name - The name of the field to update or create.
|
|
88
|
-
* @param {*} value - The new value to set.
|
|
89
|
-
* @param {*} [options] - Optional configuration, used only if a new field is created.
|
|
90
|
-
* @returns {T} The existing or newly created `Field` instance.
|
|
91
|
-
*/
|
|
92
|
-
upset(typeName, name, value, options) {
|
|
93
|
-
if (this.has(name)) {
|
|
94
|
-
const field = this.get(name);
|
|
95
|
-
field.value = value;
|
|
96
|
-
return field;
|
|
97
|
-
}
|
|
98
|
-
return this.create(typeName, name, value, options);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Retrieves a field by its name.
|
|
102
|
-
* @template TField - The expected `Field` type to be returned.
|
|
103
|
-
* @param {string} name - The name of the field to retrieve.
|
|
104
|
-
* @returns {TField} The `Field` instance.
|
|
105
|
-
* @throws If the field does not exist.
|
|
106
|
-
*/
|
|
107
|
-
get(name) {
|
|
108
|
-
throwIf(!this._fields.has(name), `Field with name '${name}' not exists`);
|
|
109
|
-
return this._fields.get(name);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Removes one or more fields from the collection.
|
|
113
|
-
* This method ensures that the `destroy` method of each removed field is called to clean up its resources.
|
|
114
|
-
* @param {string| string[]} names A single name or an array of names to remove.
|
|
115
|
-
*/
|
|
116
|
-
remove(names) {
|
|
117
|
-
const namesToRemove = Array.isArray(names) ? names : [names];
|
|
118
|
-
const reallyRemoved = namesToRemove.filter(name => {
|
|
119
|
-
const field = this._fields.get(name);
|
|
120
|
-
if (!field) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
field.destroy();
|
|
124
|
-
return this._fields.delete(name);
|
|
125
|
-
});
|
|
126
|
-
if (!reallyRemoved.length) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
this.onRemove.emit({ names: reallyRemoved });
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Removes all fields from the collection, ensuring each is properly destroyed.
|
|
133
|
-
*/
|
|
134
|
-
clear() {
|
|
135
|
-
this.remove(Array.from(this._fields.keys()));
|
|
136
|
-
}
|
|
137
|
-
destroy() {
|
|
138
|
-
this.clear();
|
|
139
|
-
this.onAdd.clear();
|
|
140
|
-
this.onRemove.clear();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=fields.js.map
|
package/dist/fields.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAInD;;;;;;GAMG;AACH,MAAM,OAAO,MAAM;IACjB,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC;IAC3B,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAE3B,OAAO,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC7C,cAAc,CAAgB;IAEvC;;;;;;OAMG;IACH,KAAK,GAAG,IAAI,OAAO,EAGd,CAAC;IAEN;;;;;OAKG;IACH,QAAQ,GAAG,IAAI,OAAO,EAEjB,CAAC;IAEN;;;OAGG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,YAAY,aAA4B;QACtC,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAuB,KAAiB;QACzC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,oBAAoB,KAAK,CAAC,IAAI,kBAAkB,CAAC,CAAC;QAEhF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAEpC,IA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,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AAEzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAE5B,cAAc,SAAS,CAAA"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAEhC,cAAc,wBAAwB,CAAA;AACtC,cAAc,SAAS,CAAA;AACvB,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAE5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AAEpC,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AAEzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAE5B,cAAc,SAAS,CAAA"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Constructor } from '@axi-engine/utils';
|
|
2
|
-
import { Field } from '../field';
|
|
3
|
-
import { Fields } from '../fields';
|
|
4
|
-
/**
|
|
5
|
-
* extract field type
|
|
6
|
-
*/
|
|
7
|
-
type GetValueType<TField extends Field<any>> = TField extends Field<infer U> ? U : any;
|
|
8
|
-
/**
|
|
9
|
-
* A mapped type that creates the method signatures for a typed mixin.
|
|
10
|
-
* e.g., createBoolean, upsetBoolean, getBoolean
|
|
11
|
-
*/
|
|
12
|
-
type TypedMethods<TCtor extends Constructor<Field<any>>, TBaseName extends string> = {
|
|
13
|
-
[K in `create${TBaseName}`]: (name: string, initialValue: GetValueType<InstanceType<TCtor>>, options?: ConstructorParameters<TCtor>[2]) => InstanceType<TCtor>;
|
|
14
|
-
} & {
|
|
15
|
-
[K in `upset${TBaseName}`]: (name: string, value: GetValueType<InstanceType<TCtor>>, options?: ConstructorParameters<TCtor>[2]) => InstanceType<TCtor>;
|
|
16
|
-
} & {
|
|
17
|
-
[K in `get${TBaseName}`]: (name: string) => InstanceType<TCtor>;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* A higher-order function that generates a mixin for a specific Field type.
|
|
21
|
-
* This factory removes the need to write boilerplate mixin code for every new field type.
|
|
22
|
-
*
|
|
23
|
-
* @param typeName The `typeName` of the Field to create (e.g., 'boolean', 'my-signal-field').
|
|
24
|
-
* @param baseMethodName The base name for the generated methods (e.g., 'Boolean', 'MySignal').
|
|
25
|
-
* @returns A fully functional, typed mixin.
|
|
26
|
-
*/
|
|
27
|
-
export declare function createTypedMethodsMixin<TCtor extends Constructor<Field<any>>, TBaseName extends string>(typeName: string, baseMethodName: TBaseName): <TBase extends Constructor<Fields>>(Base: TBase) => Constructor<InstanceType<TBase> & TypedMethods<TCtor, TBaseName>>;
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=mixin-factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mixin-factory.d.ts","sourceRoot":"","sources":["../../src/mixins/mixin-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAEjC;;GAEG;AACH,KAAK,YAAY,CAAC,MAAM,SAAS,KAAK,CAAC,GAAG,CAAC,IAAI,MAAM,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AAEvF;;;GAGG;AACH,KAAK,YAAY,CACf,KAAK,SAAS,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EACrC,SAAS,SAAS,MAAM,IACtB;KACD,CAAC,IAAI,SAAS,SAAS,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,KAAK,CAAC;CAC/J,GAAG;KACD,CAAC,IAAI,QAAQ,SAAS,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,KAAK,CAAC;CACvJ,GAAG;KACD,CAAC,IAAI,MAAM,SAAS,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,YAAY,CAAC,KAAK,CAAC;CAChE,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,SAAS,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EACrC,SAAS,SAAS,MAAM,EAExB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,SAAS,IAQR,KAAK,SAAS,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,KAC7D,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAmBpE"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A higher-order function that generates a mixin for a specific Field type.
|
|
3
|
-
* This factory removes the need to write boilerplate mixin code for every new field type.
|
|
4
|
-
*
|
|
5
|
-
* @param typeName The `typeName` of the Field to create (e.g., 'boolean', 'my-signal-field').
|
|
6
|
-
* @param baseMethodName The base name for the generated methods (e.g., 'Boolean', 'MySignal').
|
|
7
|
-
* @returns A fully functional, typed mixin.
|
|
8
|
-
*/
|
|
9
|
-
export function createTypedMethodsMixin(typeName, baseMethodName) {
|
|
10
|
-
const methodNames = {
|
|
11
|
-
create: `create${baseMethodName}`,
|
|
12
|
-
upset: `upset${baseMethodName}`,
|
|
13
|
-
get: `get${baseMethodName}`,
|
|
14
|
-
};
|
|
15
|
-
return function (Base) {
|
|
16
|
-
return class FieldsWith extends Base {
|
|
17
|
-
// createBoolean, createMySignal, etc.
|
|
18
|
-
[methodNames.create](name, initialValue, options) {
|
|
19
|
-
return this.create(typeName, name, initialValue, options);
|
|
20
|
-
}
|
|
21
|
-
// upsetBoolean, upsetMySignal, etc.
|
|
22
|
-
[methodNames.upset](name, value, options) {
|
|
23
|
-
return this.upset(typeName, name, value, options);
|
|
24
|
-
}
|
|
25
|
-
// getBoolean, getMySignal, etc.
|
|
26
|
-
[methodNames.get](name) {
|
|
27
|
-
return this.get(name);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=mixin-factory.js.map
|