@amodx/ncs 0.0.1 → 0.0.2
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/Components/Component.types.d.ts +78 -0
- package/Components/ComponentArray.d.ts +30 -0
- package/Components/ComponentArray.js +82 -0
- package/Components/ComponentCursor.d.ts +27 -0
- package/Components/ComponentCursor.js +72 -0
- package/Contexts/Context.types.d.ts +76 -0
- package/Contexts/ContextArray.d.ts +14 -0
- package/Contexts/ContextArray.js +47 -0
- package/Contexts/ContextCursor.d.ts +20 -0
- package/Contexts/ContextCursor.js +39 -0
- package/Data/SerializedData.types.d.ts +44 -0
- package/Data/deserializeComponent.d.ts +3 -0
- package/Data/deserializeComponent.js +3 -0
- package/Data/deserializeNode.d.ts +3 -0
- package/Data/deserializeNode.js +34 -0
- package/Data/serializeComponent.d.ts +7 -0
- package/Data/serializeComponent.js +36 -0
- package/Data/serializeNode.d.ts +13 -0
- package/Data/serializeNode.js +83 -0
- package/Functional.d.ts +12 -0
- package/Functional.js +31 -0
- package/Graphs/Graph.d.ts +19 -21
- package/Graphs/Graph.js +85 -74
- package/NCS.d.ts +79 -48
- package/NCS.js +108 -32
- package/Nodes/Node.types.d.ts +39 -0
- package/Nodes/Node.types.js +16 -0
- package/Nodes/NodeArray.d.ts +25 -0
- package/Nodes/NodeArray.js +96 -0
- package/Nodes/NodeComponents.d.ts +19 -0
- package/Nodes/NodeComponents.js +180 -0
- package/Nodes/NodeContext.d.ts +14 -0
- package/Nodes/NodeContext.js +107 -0
- package/Nodes/NodeCursor.d.ts +65 -0
- package/Nodes/NodeCursor.js +348 -0
- package/Nodes/NodeEvents.d.ts +10 -13
- package/Nodes/NodeEvents.js +51 -26
- package/Nodes/NodeId.d.ts +4 -13
- package/Nodes/NodeId.js +16 -48
- package/Nodes/NodeObservers.d.ts +35 -20
- package/Nodes/NodeObservers.js +162 -37
- package/Nodes/NodeTags.d.ts +17 -0
- package/Nodes/NodeTags.js +102 -0
- package/Pools/NCSPools.d.ts +27 -4
- package/Pools/NCSPools.js +14 -2
- package/Queries/Query.types.d.ts +8 -0
- package/Queries/QueryInstance.d.ts +6 -4
- package/Queries/QueryInstance.js +89 -44
- package/Queries/QueryPrototype.d.ts +1 -1
- package/Register/NCSRegister.d.ts +17 -9
- package/Register/NCSRegister.js +25 -2
- package/Register/registerComponent.d.ts +31 -25
- package/Register/registerComponent.js +88 -36
- package/Register/registerContext.d.ts +10 -13
- package/Register/registerContext.js +13 -18
- package/Register/registerSystem.d.ts +1 -1
- package/Register/registerSystem.js +1 -1
- package/Register/registerTag.d.ts +15 -17
- package/Register/registerTag.js +20 -23
- package/Schema/Functions/createBaseSchemaCursor.d.ts +18 -0
- package/Schema/Functions/createBaseSchemaCursor.js +34 -0
- package/Schema/Functions/createSchemaBinaryObjectCursorClass.d.ts +22 -0
- package/Schema/Functions/createSchemaBinaryObjectCursorClass.js +134 -0
- package/Schema/Functions/createSchemaIndex.d.ts +3 -0
- package/Schema/Functions/createSchemaIndex.js +18 -0
- package/Schema/Functions/createSchemaObjectCursorClass.d.ts +18 -0
- package/Schema/Functions/createSchemaObjectCursorClass.js +66 -0
- package/Schema/Functions/createSchemaTypedArrayCursorClass.d.ts +17 -0
- package/Schema/Functions/createSchemaTypedArrayCursorClass.js +66 -0
- package/Schema/Property/Property.d.ts +11 -0
- package/Schema/Property/Property.js +16 -0
- package/Schema/Property/Property.types.d.ts +26 -0
- package/Schema/Property/Property.types.js +20 -0
- package/Schema/Schema.d.ts +28 -0
- package/Schema/Schema.js +223 -0
- package/Schema/Schema.types.d.ts +59 -0
- package/Schema/Schema.types.js +8 -0
- package/Schema/SchemaArray.d.ts +23 -0
- package/Schema/SchemaArray.js +87 -0
- package/Schema/SchemaArrayCursor.d.ts +19 -0
- package/Schema/SchemaArrayCursor.js +56 -0
- package/Schema/SchemaView.d.ts +24 -0
- package/Schema/SchemaView.js +141 -0
- package/Systems/{SystemData.d.ts → System.types.d.ts} +0 -4
- package/Systems/SystemInstance.d.ts +6 -4
- package/Systems/SystemInstance.js +14 -8
- package/Systems/SystemPrototype.d.ts +1 -1
- package/Systems/SystemPrototype.js +0 -1
- package/Tags/Tag.d.ts +1 -1
- package/Tags/Tag.js +1 -1
- package/Tags/{TagData.d.ts → Tag.types.d.ts} +0 -17
- package/Tags/TagArray.d.ts +18 -0
- package/Tags/TagArray.js +37 -0
- package/Tags/TagCursor.d.ts +20 -0
- package/Tags/TagCursor.js +45 -0
- package/Util/IdPalette.d.ts +13 -0
- package/Util/IdPalette.js +38 -0
- package/{Pools → Util}/ItemPool.d.ts +2 -3
- package/{Pools → Util}/ItemPool.js +2 -4
- package/Util/Observable.d.ts +28 -0
- package/Util/Observable.js +58 -0
- package/Util/Util.types.d.ts +4 -0
- package/index.d.ts +16 -6
- package/index.js +24 -6
- package/package.json +1 -1
- package/Components/ComponentData.d.ts +0 -112
- package/Components/ComponentInstance.d.ts +0 -36
- package/Components/ComponentInstance.js +0 -125
- package/Components/ComponentInstanceMap.d.ts +0 -7
- package/Components/ComponentInstanceMap.js +0 -15
- package/Components/ComponentObservers.d.ts +0 -8
- package/Components/ComponentObservers.js +0 -13
- package/Components/ComponentPipelines.d.ts +0 -16
- package/Components/ComponentPipelines.js +0 -33
- package/Components/ComponentPrototype.d.ts +0 -17
- package/Components/ComponentPrototype.js +0 -73
- package/Contexts/ContextData.d.ts +0 -59
- package/Contexts/ContextInstance.d.ts +0 -14
- package/Contexts/ContextInstance.js +0 -26
- package/Contexts/ContextInstanceAnchor.d.ts +0 -15
- package/Contexts/ContextInstanceAnchor.js +0 -33
- package/Contexts/ContextPrototype.d.ts +0 -9
- package/Contexts/ContextPrototype.js +0 -19
- package/Graphs/GraphEvents.d.ts +0 -9
- package/Graphs/GraphEvents.js +0 -35
- package/Graphs/GraphObservers.d.ts +0 -9
- package/Graphs/GraphObservers.js +0 -6
- package/Graphs/GraphUpdate.d.ts +0 -13
- package/Graphs/GraphUpdate.js +0 -38
- package/Maps/ItemGraphMap.d.ts +0 -11
- package/Maps/ItemGraphMap.js +0 -30
- package/Maps/ItemNodeMap.d.ts +0 -17
- package/Maps/ItemNodeMap.js +0 -41
- package/Nodes/Components/NodeComponentObservers.d.ts +0 -15
- package/Nodes/Components/NodeComponentObservers.js +0 -33
- package/Nodes/Components/NodeComponents.d.ts +0 -22
- package/Nodes/Components/NodeComponents.js +0 -107
- package/Nodes/Context/NodeContext.d.ts +0 -13
- package/Nodes/Context/NodeContext.js +0 -45
- package/Nodes/NodeData.d.ts +0 -40
- package/Nodes/NodeInstance.d.ts +0 -50
- package/Nodes/NodeInstance.js +0 -202
- package/Nodes/NodePipelines.d.ts +0 -16
- package/Nodes/NodePipelines.js +0 -33
- package/Nodes/Tags/NodeTagObservers.d.ts +0 -15
- package/Nodes/Tags/NodeTagObservers.js +0 -33
- package/Nodes/Tags/NodeTags.d.ts +0 -21
- package/Nodes/Tags/NodeTags.js +0 -95
- package/Queries/QueryData.d.ts +0 -8
- package/Register/ItemRegister.d.ts +0 -7
- package/Register/ItemRegister.js +0 -24
- package/Register/registerTrait.d.ts +0 -15
- package/Register/registerTrait.js +0 -39
- package/Tags/TagInstance.d.ts +0 -13
- package/Tags/TagInstance.js +0 -17
- package/Tags/TagInstanceMap.d.ts +0 -7
- package/Tags/TagInstanceMap.js +0 -15
- package/Tags/TagPrototype.d.ts +0 -16
- package/Tags/TagPrototype.js +0 -34
- package/Traits/TraitContaienrObservers.d.ts +0 -15
- package/Traits/TraitContaienrObservers.js +0 -33
- package/Traits/TraitContainer.d.ts +0 -22
- package/Traits/TraitContainer.js +0 -114
- package/Traits/TraitData.d.ts +0 -106
- package/Traits/TraitInstance.d.ts +0 -35
- package/Traits/TraitInstance.js +0 -115
- package/Traits/TraitInstanceMap.d.ts +0 -7
- package/Traits/TraitInstanceMap.js +0 -15
- package/Traits/TraitObservers.d.ts +0 -8
- package/Traits/TraitObservers.js +0 -13
- package/Traits/TraitPipelines.d.ts +0 -16
- package/Traits/TraitPipelines.js +0 -33
- package/Traits/TraitPrototype.d.ts +0 -16
- package/Traits/TraitPrototype.js +0 -74
- /package/Components/{ComponentData.js → Component.types.js} +0 -0
- /package/Contexts/{ContextData.js → Context.types.js} +0 -0
- /package/{Nodes/NodeData.js → Data/SerializedData.types.js} +0 -0
- /package/Queries/{QueryData.js → Query.types.js} +0 -0
- /package/Systems/{SystemData.js → System.types.js} +0 -0
- /package/Tags/{TagData.js → Tag.types.js} +0 -0
- /package/{Traits/TraitData.js → Util/Util.types.js} +0 -0
package/Nodes/NodeObservers.js
CHANGED
|
@@ -1,63 +1,188 @@
|
|
|
1
|
-
import { Observable } from "
|
|
1
|
+
import { Observable } from "../Util/Observable";
|
|
2
|
+
import { NodeObserverIds } from "./Node.types";
|
|
3
|
+
import { NCSPools } from "../Pools/NCSPools";
|
|
2
4
|
export class NodeObservers {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
node;
|
|
6
|
+
static Get() {
|
|
7
|
+
const cursor = NCSPools.nodeObservers.get();
|
|
8
|
+
if (!cursor)
|
|
9
|
+
return new NodeObservers();
|
|
10
|
+
return cursor;
|
|
11
|
+
}
|
|
12
|
+
static Retrun(cursor) {
|
|
13
|
+
return NCSPools.nodeObservers.addItem(cursor);
|
|
14
|
+
}
|
|
15
|
+
constructor() { }
|
|
16
|
+
get observers() {
|
|
17
|
+
return this.node.arrays._observers;
|
|
18
|
+
}
|
|
9
19
|
get disposed() {
|
|
10
|
-
|
|
11
|
-
|
|
20
|
+
let observer = this.observers[NodeObserverIds.Disposed][this.node.index];
|
|
21
|
+
if (!observer) {
|
|
22
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
23
|
+
this.observers[NodeObserverIds.Disposed][this.node.index] = observer;
|
|
12
24
|
}
|
|
13
|
-
|
|
25
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
26
|
+
return observer;
|
|
27
|
+
}
|
|
28
|
+
get enabled() {
|
|
29
|
+
let observer = this.observers[NodeObserverIds.Enabled][this.node.index];
|
|
30
|
+
if (!observer) {
|
|
31
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
32
|
+
this.observers[NodeObserverIds.Enabled][this.node.index] = observer;
|
|
33
|
+
}
|
|
34
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
35
|
+
return observer;
|
|
14
36
|
}
|
|
15
37
|
get parented() {
|
|
16
|
-
|
|
17
|
-
|
|
38
|
+
let observer = this.observers[NodeObserverIds.Parented][this.node.index];
|
|
39
|
+
if (!observer) {
|
|
40
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
41
|
+
this.observers[NodeObserverIds.Parented][this.node.index] = observer;
|
|
18
42
|
}
|
|
19
|
-
|
|
43
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
44
|
+
return observer;
|
|
20
45
|
}
|
|
21
46
|
get removedFromParent() {
|
|
22
|
-
|
|
23
|
-
|
|
47
|
+
let observer = this.observers[NodeObserverIds.RemovedFromParent][this.node.index];
|
|
48
|
+
if (!observer) {
|
|
49
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
50
|
+
this.observers[NodeObserverIds.RemovedFromParent][this.node.index] =
|
|
51
|
+
observer;
|
|
24
52
|
}
|
|
25
|
-
|
|
53
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
54
|
+
return observer;
|
|
26
55
|
}
|
|
27
56
|
get childAdded() {
|
|
28
|
-
|
|
29
|
-
|
|
57
|
+
let observer = this.observers[NodeObserverIds.ChildAdded][this.node.index];
|
|
58
|
+
if (!observer) {
|
|
59
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
60
|
+
this.observers[NodeObserverIds.ChildAdded][this.node.index] = observer;
|
|
30
61
|
}
|
|
31
|
-
|
|
62
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
63
|
+
return observer;
|
|
32
64
|
}
|
|
33
65
|
get childRemoved() {
|
|
34
|
-
|
|
35
|
-
|
|
66
|
+
let observer = this.observers[NodeObserverIds.ChildRemoved][this.node.index];
|
|
67
|
+
if (!observer) {
|
|
68
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
69
|
+
this.observers[NodeObserverIds.ChildRemoved][this.node.index] = observer;
|
|
36
70
|
}
|
|
37
|
-
|
|
71
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
72
|
+
return observer;
|
|
38
73
|
}
|
|
39
74
|
get childrenUpdated() {
|
|
40
|
-
|
|
41
|
-
|
|
75
|
+
let observer = this.observers[NodeObserverIds.ChildrenUpdated][this.node.index];
|
|
76
|
+
if (!observer) {
|
|
77
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
78
|
+
this.observers[NodeObserverIds.ChildrenUpdated][this.node.index] =
|
|
79
|
+
observer;
|
|
80
|
+
}
|
|
81
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
82
|
+
return observer;
|
|
83
|
+
}
|
|
84
|
+
get isDisposedSet() {
|
|
85
|
+
return (this.observers[NodeObserverIds.Disposed][this.node.index] !== undefined);
|
|
86
|
+
}
|
|
87
|
+
get isEnabledSet() {
|
|
88
|
+
return (this.observers[NodeObserverIds.Enabled][this.node.index] !== undefined);
|
|
89
|
+
}
|
|
90
|
+
get isParentedSet() {
|
|
91
|
+
return (this.observers[NodeObserverIds.Parented][this.node.index] !== undefined);
|
|
92
|
+
}
|
|
93
|
+
get isRemovedFromParentSet() {
|
|
94
|
+
return (this.observers[NodeObserverIds.RemovedFromParent][this.node.index] !==
|
|
95
|
+
undefined);
|
|
96
|
+
}
|
|
97
|
+
get isChildAddedSet() {
|
|
98
|
+
return (this.observers[NodeObserverIds.ChildAdded][this.node.index] !== undefined);
|
|
99
|
+
}
|
|
100
|
+
get isChildRemovedSet() {
|
|
101
|
+
return (this.observers[NodeObserverIds.ChildRemoved][this.node.index] !==
|
|
102
|
+
undefined);
|
|
103
|
+
}
|
|
104
|
+
get isChildrenUpdatedSet() {
|
|
105
|
+
return (this.observers[NodeObserverIds.ChildrenUpdated][this.node.index] !==
|
|
106
|
+
undefined);
|
|
107
|
+
}
|
|
108
|
+
get componentAdded() {
|
|
109
|
+
let observer = this.observers[NodeObserverIds.ComponentAdded][this.node.index];
|
|
110
|
+
if (!observer) {
|
|
111
|
+
observer = new Observable();
|
|
112
|
+
this.observers[NodeObserverIds.ComponentAdded][this.node.index] =
|
|
113
|
+
observer;
|
|
114
|
+
}
|
|
115
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
116
|
+
return observer;
|
|
117
|
+
}
|
|
118
|
+
get componentRemoved() {
|
|
119
|
+
// This is the one you already fixed
|
|
120
|
+
let observer = this.observers[NodeObserverIds.ComponentRemoved][this.node.index];
|
|
121
|
+
if (!observer) {
|
|
122
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
123
|
+
this.observers[NodeObserverIds.ComponentRemoved][this.node.index] =
|
|
124
|
+
observer;
|
|
125
|
+
}
|
|
126
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
127
|
+
return observer;
|
|
128
|
+
}
|
|
129
|
+
get componentsUpdated() {
|
|
130
|
+
let observer = this.observers[NodeObserverIds.ComponentsUpdated][this.node.index];
|
|
131
|
+
if (!observer) {
|
|
132
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
133
|
+
this.observers[NodeObserverIds.ComponentsUpdated][this.node.index] =
|
|
134
|
+
observer;
|
|
42
135
|
}
|
|
43
|
-
|
|
136
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
137
|
+
return observer;
|
|
44
138
|
}
|
|
45
|
-
|
|
46
|
-
return
|
|
139
|
+
get isComponentAddedSet() {
|
|
140
|
+
return (this.observers[NodeObserverIds.ComponentAdded][this.node.index] !==
|
|
141
|
+
undefined);
|
|
47
142
|
}
|
|
48
|
-
|
|
49
|
-
return
|
|
143
|
+
get isComponentRemovedSet() {
|
|
144
|
+
return (this.observers[NodeObserverIds.ComponentRemoved][this.node.index] !==
|
|
145
|
+
undefined);
|
|
50
146
|
}
|
|
51
|
-
|
|
52
|
-
return
|
|
147
|
+
get isComponentsUpdatedSet() {
|
|
148
|
+
return (this.observers[NodeObserverIds.ComponentsUpdated][this.node.index] !==
|
|
149
|
+
undefined);
|
|
150
|
+
}
|
|
151
|
+
get tagsAdded() {
|
|
152
|
+
let observer = this.observers[NodeObserverIds.TagAdded][this.node.index];
|
|
153
|
+
if (!observer) {
|
|
154
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
155
|
+
this.observers[NodeObserverIds.TagAdded][this.node.index] = observer;
|
|
156
|
+
}
|
|
157
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
158
|
+
return observer;
|
|
159
|
+
}
|
|
160
|
+
get tagsRemoved() {
|
|
161
|
+
let observer = this.observers[NodeObserverIds.TagRemoved][this.node.index];
|
|
162
|
+
if (!observer) {
|
|
163
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
164
|
+
this.observers[NodeObserverIds.TagRemoved][this.node.index] = observer;
|
|
165
|
+
}
|
|
166
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
167
|
+
return observer;
|
|
168
|
+
}
|
|
169
|
+
get tagsUpdated() {
|
|
170
|
+
let observer = this.observers[NodeObserverIds.TagsUpdated][this.node.index];
|
|
171
|
+
if (!observer) {
|
|
172
|
+
observer = NCSPools.observers.get() || new Observable();
|
|
173
|
+
this.observers[NodeObserverIds.TagsUpdated][this.node.index] = observer;
|
|
174
|
+
}
|
|
175
|
+
this.node.arrays._hasObservers[this.node.index] = true;
|
|
176
|
+
return observer;
|
|
53
177
|
}
|
|
54
|
-
|
|
55
|
-
return
|
|
178
|
+
get isTagsAddedSet() {
|
|
179
|
+
return (this.observers[NodeObserverIds.TagAdded][this.node.index] !== undefined);
|
|
56
180
|
}
|
|
57
|
-
|
|
58
|
-
return
|
|
181
|
+
get isTagsRemovedSet() {
|
|
182
|
+
return (this.observers[NodeObserverIds.TagRemoved][this.node.index] !== undefined);
|
|
59
183
|
}
|
|
60
|
-
|
|
61
|
-
return
|
|
184
|
+
get isTagsUpdatedSet() {
|
|
185
|
+
return (this.observers[NodeObserverIds.TagsUpdated][this.node.index] !==
|
|
186
|
+
undefined);
|
|
62
187
|
}
|
|
63
188
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TagCursor } from "../Tags/TagCursor";
|
|
2
|
+
import { NodeCursor } from "./NodeCursor";
|
|
3
|
+
export declare class NodeTags {
|
|
4
|
+
node: NodeCursor;
|
|
5
|
+
static Get(): NodeTags;
|
|
6
|
+
static Retrun(cursor: NodeTags): boolean;
|
|
7
|
+
get tags(): number[];
|
|
8
|
+
private constructor();
|
|
9
|
+
dispose(): void;
|
|
10
|
+
add(id: number, cursor?: TagCursor): any;
|
|
11
|
+
remove(id: string): boolean;
|
|
12
|
+
get(type: string, cursor?: TagCursor): TagCursor | null;
|
|
13
|
+
getChild(type: string, cursor?: TagCursor): TagCursor | null;
|
|
14
|
+
getAllChildlren(type: string): TagCursor[];
|
|
15
|
+
getParent(type: string, cursor?: TagCursor): TagCursor | null;
|
|
16
|
+
getAllParents(type: string): TagCursor[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { NCSPools } from "../Pools/NCSPools";
|
|
2
|
+
import { NCSRegister } from "../Register/NCSRegister";
|
|
3
|
+
import { TagCursor } from "../Tags/TagCursor";
|
|
4
|
+
const tagCursor = TagCursor.Get();
|
|
5
|
+
export class NodeTags {
|
|
6
|
+
node;
|
|
7
|
+
static Get() {
|
|
8
|
+
const cursor = NCSPools.nodeTags.get();
|
|
9
|
+
if (!cursor)
|
|
10
|
+
return new NodeTags();
|
|
11
|
+
return cursor;
|
|
12
|
+
}
|
|
13
|
+
static Retrun(cursor) {
|
|
14
|
+
return NCSPools.nodeTags.addItem(cursor);
|
|
15
|
+
}
|
|
16
|
+
get tags() {
|
|
17
|
+
return this.node.arrays._tags[this.node.index];
|
|
18
|
+
}
|
|
19
|
+
constructor() { }
|
|
20
|
+
dispose() {
|
|
21
|
+
for (let i = 0; i < this.tags.length; i += 2) {
|
|
22
|
+
tagCursor.setTag(this.node, this.tags[i], this.tags[i + 1]);
|
|
23
|
+
tagCursor.dispose();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
add(id, cursor = tagCursor) {
|
|
27
|
+
const newTag = this.node.graph._tags[id].addTag(this.node.index);
|
|
28
|
+
this.tags.push(id, newTag);
|
|
29
|
+
cursor.setTag(this.node, id, newTag);
|
|
30
|
+
if (this.node.hasObservers) {
|
|
31
|
+
this.node.observers.isTagsAddedSet &&
|
|
32
|
+
this.node.observers.tagsAdded.notify(cursor);
|
|
33
|
+
}
|
|
34
|
+
return cursor;
|
|
35
|
+
}
|
|
36
|
+
remove(id) {
|
|
37
|
+
const tagId = NCSRegister.tags.idPalette.getNumberId(id);
|
|
38
|
+
const tags = this.tags;
|
|
39
|
+
for (let i = 0; i < tags.length; i++) {
|
|
40
|
+
if (tags[i] == tagId) {
|
|
41
|
+
tagCursor.setTag(this.node, tagId, tags[i]);
|
|
42
|
+
tagCursor.dispose();
|
|
43
|
+
this.tags.splice(i, 2);
|
|
44
|
+
this.node.hasObservers &&
|
|
45
|
+
this.node.observers.isTagsRemovedSet &&
|
|
46
|
+
this.node.observers.tagsRemoved.notify(tagCursor);
|
|
47
|
+
this.node.hasObservers &&
|
|
48
|
+
this.node.observers.isTagsUpdatedSet &&
|
|
49
|
+
this.node.observers.tagsUpdated.notify(0);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
get(type, cursor = tagCursor) {
|
|
56
|
+
const tagId = NCSRegister.tags.idPalette.getNumberId(type);
|
|
57
|
+
const tags = this.tags;
|
|
58
|
+
for (let i = 0; i < tags.length; i += 2) {
|
|
59
|
+
if (tags[i] == tagId) {
|
|
60
|
+
cursor.setTag(this.node, tags[i], tags[i + 1]);
|
|
61
|
+
return cursor;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
getChild(type, cursor = tagCursor) {
|
|
67
|
+
for (const child of this.node.traverseChildren()) {
|
|
68
|
+
const found = child.tags.get(type, cursor);
|
|
69
|
+
if (found)
|
|
70
|
+
return found;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
getAllChildlren(type) {
|
|
75
|
+
const tags = [];
|
|
76
|
+
for (const child of this.node.traverseChildren()) {
|
|
77
|
+
const found = child.tags.get(type);
|
|
78
|
+
if (found) {
|
|
79
|
+
tags.push(TagCursor.Get().setTag(this.node, found.typeId, found.index));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return tags;
|
|
83
|
+
}
|
|
84
|
+
getParent(type, cursor = tagCursor) {
|
|
85
|
+
for (const parent of this.node.traverseParents()) {
|
|
86
|
+
const found = parent.tags.get(type, cursor);
|
|
87
|
+
if (found)
|
|
88
|
+
return found;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
getAllParents(type) {
|
|
93
|
+
const tags = [];
|
|
94
|
+
for (const child of this.node.traverseParents()) {
|
|
95
|
+
const found = child.tags.get(type, tagCursor);
|
|
96
|
+
if (found) {
|
|
97
|
+
tags.push(TagCursor.Get().setTag(this.node, found.typeId, found.index));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return tags;
|
|
101
|
+
}
|
|
102
|
+
}
|
package/Pools/NCSPools.d.ts
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import { ItemPool } from "
|
|
2
|
-
import { Observable } from "
|
|
3
|
-
import {
|
|
1
|
+
import { ItemPool } from "../Util/ItemPool";
|
|
2
|
+
import { Observable } from "../Util/Observable";
|
|
3
|
+
import { NodeCursor } from "../Nodes/NodeCursor";
|
|
4
|
+
import { NodeObservers } from "../Nodes/NodeObservers";
|
|
5
|
+
import { NodeEvents } from "../Nodes/NodeEvents";
|
|
6
|
+
import { NodeComponents } from "../Nodes/NodeComponents";
|
|
7
|
+
import { NodeTags } from "../Nodes/NodeTags";
|
|
8
|
+
import { ComponentCursor } from "../Components/ComponentCursor";
|
|
9
|
+
import { ContextCursor } from "../Contexts/ContextCursor";
|
|
10
|
+
import { TagCursor } from "../Tags/TagCursor";
|
|
11
|
+
import { NodeContext } from "../Nodes/NodeContext";
|
|
12
|
+
import { CreateNodeData } from "../Nodes/Node.types";
|
|
13
|
+
import { CreateComponentData } from "../Components/Component.types";
|
|
14
|
+
import { CreateContextData } from "../Contexts/Context.types";
|
|
4
15
|
export declare class NCSPools {
|
|
5
16
|
static observers: ItemPool<Observable<void>>;
|
|
6
|
-
static
|
|
17
|
+
static numberArray: ItemPool<number[]>;
|
|
18
|
+
static createNodeData: ItemPool<CreateNodeData>;
|
|
19
|
+
static createComponentData: ItemPool<CreateComponentData>;
|
|
20
|
+
static createContextData: ItemPool<CreateContextData>;
|
|
21
|
+
static nodeCursor: ItemPool<NodeCursor>;
|
|
22
|
+
static nodeContext: ItemPool<NodeContext>;
|
|
23
|
+
static nodeObservers: ItemPool<NodeObservers>;
|
|
24
|
+
static nodeEvents: ItemPool<NodeEvents>;
|
|
25
|
+
static nodeComponents: ItemPool<NodeComponents>;
|
|
26
|
+
static nodeTags: ItemPool<NodeTags>;
|
|
27
|
+
static tagCursor: ItemPool<TagCursor>;
|
|
28
|
+
static componentCursor: ItemPool<ComponentCursor<{}, any, any>>;
|
|
29
|
+
static contextCursor: ItemPool<ContextCursor<{}, {}>>;
|
|
7
30
|
}
|
package/Pools/NCSPools.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import { ItemPool } from "
|
|
1
|
+
import { ItemPool } from "../Util/ItemPool";
|
|
2
2
|
export class NCSPools {
|
|
3
3
|
static observers = new ItemPool();
|
|
4
|
-
static
|
|
4
|
+
static numberArray = new ItemPool();
|
|
5
|
+
static createNodeData = new ItemPool();
|
|
6
|
+
static createComponentData = new ItemPool();
|
|
7
|
+
static createContextData = new ItemPool();
|
|
8
|
+
static nodeCursor = new ItemPool();
|
|
9
|
+
static nodeContext = new ItemPool();
|
|
10
|
+
static nodeObservers = new ItemPool();
|
|
11
|
+
static nodeEvents = new ItemPool();
|
|
12
|
+
static nodeComponents = new ItemPool();
|
|
13
|
+
static nodeTags = new ItemPool();
|
|
14
|
+
static tagCursor = new ItemPool();
|
|
15
|
+
static componentCursor = new ItemPool();
|
|
16
|
+
static contextCursor = new ItemPool();
|
|
5
17
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentRegisterData } from "../Components/Component.types";
|
|
2
|
+
import { TagRegisterData } from "../Tags/Tag.types";
|
|
3
|
+
export type QueryData = {
|
|
4
|
+
inclueComponents?: ComponentRegisterData<any, any, any>[];
|
|
5
|
+
includeTags?: TagRegisterData[];
|
|
6
|
+
excludeComponents?: ComponentRegisterData<any, any, any>[];
|
|
7
|
+
excludeTags?: TagRegisterData[];
|
|
8
|
+
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Graph } from "../Graphs/Graph";
|
|
2
|
-
import { QueryData } from "./
|
|
3
|
-
import {
|
|
2
|
+
import { QueryData } from "./Query.types";
|
|
3
|
+
import { NodeCursor } from "../Nodes/NodeCursor";
|
|
4
4
|
export declare class QueryInstance {
|
|
5
5
|
graph: Graph;
|
|
6
6
|
data: QueryData;
|
|
7
|
-
nodes:
|
|
7
|
+
nodes: number[];
|
|
8
|
+
private _updateFunction;
|
|
9
|
+
private nodeCursor;
|
|
8
10
|
constructor(graph: Graph, data: QueryData);
|
|
9
|
-
evulate(node:
|
|
11
|
+
evulate(node: NodeCursor): boolean;
|
|
10
12
|
init(): void;
|
|
11
13
|
dispose(): void;
|
|
12
14
|
}
|
package/Queries/QueryInstance.js
CHANGED
|
@@ -1,77 +1,122 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TagInstanceMap } from "../Tags/TagInstanceMap";
|
|
1
|
+
import { NodeCursor } from "../Nodes/NodeCursor";
|
|
3
2
|
import { NCSRegister } from "../Register/NCSRegister";
|
|
3
|
+
import { ComponentArray } from "../Components/ComponentArray";
|
|
4
|
+
import { TagArray } from "../Tags/TagArray";
|
|
4
5
|
export class QueryInstance {
|
|
5
6
|
graph;
|
|
6
7
|
data;
|
|
7
|
-
nodes =
|
|
8
|
+
nodes = [];
|
|
9
|
+
_updateFunction;
|
|
10
|
+
nodeCursor = NodeCursor.Get();
|
|
8
11
|
constructor(graph, data) {
|
|
9
12
|
this.graph = graph;
|
|
10
13
|
this.data = data;
|
|
11
14
|
}
|
|
12
15
|
evulate(node) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
if (this.data.inclueComponents) {
|
|
17
|
+
for (const comp of this.data.inclueComponents) {
|
|
18
|
+
if (!node.components.has(comp.type)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
if (this.data.includeTags) {
|
|
24
|
+
for (const tag of this.data.includeTags) {
|
|
25
|
+
if (!(node.hasTags && node.tags.get(tag.id))) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
21
28
|
}
|
|
22
29
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
if (this.data.excludeComponents) {
|
|
31
|
+
for (const comp of this.data.excludeComponents) {
|
|
32
|
+
if (node.components.has(comp.type)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
26
35
|
}
|
|
27
36
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
if (this.data.excludeTags) {
|
|
38
|
+
for (const tag of this.data.excludeTags) {
|
|
39
|
+
if (node.hasTags && node.tags.get(tag.id)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
31
42
|
}
|
|
32
43
|
}
|
|
33
44
|
return true;
|
|
34
45
|
}
|
|
35
46
|
init() {
|
|
36
|
-
|
|
47
|
+
this._updateFunction = (nodeIndex) => {
|
|
48
|
+
const node = this.nodeCursor.setNode(this.graph, nodeIndex);
|
|
37
49
|
if (!this.evulate(node)) {
|
|
38
|
-
this.nodes.
|
|
50
|
+
for (let i = 0; i < this.nodes.length; i++) {
|
|
51
|
+
if (this.nodes[i] == node.index) {
|
|
52
|
+
this.nodes.splice(i, 1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
39
55
|
return;
|
|
40
56
|
}
|
|
41
|
-
this.nodes.
|
|
57
|
+
this.nodes.push(nodeIndex);
|
|
42
58
|
};
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
59
|
+
if (this.data.inclueComponents) {
|
|
60
|
+
for (const comp of this.data.inclueComponents) {
|
|
61
|
+
const compId = NCSRegister.components.idPalette.getNumberId(comp.type);
|
|
62
|
+
let map = this.graph._components[compId];
|
|
63
|
+
if (!map) {
|
|
64
|
+
map = new ComponentArray(this.graph, compId);
|
|
65
|
+
this.graph._components[compId] = map;
|
|
66
|
+
}
|
|
67
|
+
map.observers.nodeAdded.subscribe(this._updateFunction);
|
|
68
|
+
map.observers.nodeRemoved.subscribe(this._updateFunction);
|
|
69
|
+
}
|
|
47
70
|
}
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
if (this.data.includeTags) {
|
|
72
|
+
for (const includeTag of this.data.includeTags) {
|
|
73
|
+
const tag = NCSRegister.tags.get(includeTag.id);
|
|
74
|
+
const tagId = NCSRegister.tags.idPalette.getNumberId(includeTag.id);
|
|
75
|
+
let tagMap = this.graph._tags[tagId];
|
|
76
|
+
if (!tagMap) {
|
|
77
|
+
tagMap = new TagArray(includeTag.id);
|
|
78
|
+
this.graph._tags[tagId] = tagMap;
|
|
79
|
+
}
|
|
80
|
+
tagMap.observers.nodeAdded.subscribe(this._updateFunction);
|
|
81
|
+
tagMap.observers.nodeRemoved.subscribe(this._updateFunction);
|
|
82
|
+
for (const child of tag.traverseChildren()) {
|
|
83
|
+
const tagId = NCSRegister.tags.idPalette.getNumberId(child.id);
|
|
84
|
+
let chidMap = this.graph._tags[tagId];
|
|
85
|
+
if (!chidMap) {
|
|
86
|
+
chidMap = new TagArray(child.id);
|
|
87
|
+
this.graph._tags[tagId] = chidMap;
|
|
88
|
+
}
|
|
89
|
+
chidMap.observers.nodeAdded.subscribe(this._updateFunction);
|
|
90
|
+
chidMap.observers.nodeRemoved.subscribe(this._updateFunction);
|
|
91
|
+
}
|
|
57
92
|
}
|
|
58
93
|
}
|
|
59
94
|
}
|
|
60
95
|
dispose() {
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
96
|
+
if (this.data.inclueComponents) {
|
|
97
|
+
for (const comp of this.data.inclueComponents) {
|
|
98
|
+
const map = this.graph._components[NCSRegister.components.idPalette.getNumberId(comp.type)];
|
|
99
|
+
if (!map)
|
|
100
|
+
continue;
|
|
101
|
+
map.observers.nodeAdded.unsubscribe(this._updateFunction);
|
|
102
|
+
map.observers.nodeRemoved.unsubscribe(this._updateFunction);
|
|
103
|
+
}
|
|
65
104
|
}
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
105
|
+
if (this.data.includeTags) {
|
|
106
|
+
for (const includeTag of this.data.includeTags) {
|
|
107
|
+
const tag = NCSRegister.tags.get(includeTag.id);
|
|
108
|
+
const tagMap = this.graph._tags[NCSRegister.tags.idPalette.getNumberId(includeTag.id)];
|
|
109
|
+
if (!tagMap)
|
|
110
|
+
continue;
|
|
111
|
+
tagMap.observers.nodeAdded.unsubscribe(this._updateFunction);
|
|
112
|
+
tagMap.observers.nodeRemoved.unsubscribe(this._updateFunction);
|
|
113
|
+
for (const child of tag.traverseChildren()) {
|
|
114
|
+
const childMap = this.graph._tags[NCSRegister.tags.idPalette.getNumberId(child.id)];
|
|
115
|
+
if (!childMap)
|
|
116
|
+
continue;
|
|
117
|
+
childMap.observers.nodeAdded.unsubscribe(this._updateFunction);
|
|
118
|
+
childMap.observers.nodeRemoved.unsubscribe(this._updateFunction);
|
|
119
|
+
}
|
|
75
120
|
}
|
|
76
121
|
}
|
|
77
122
|
}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { ContextPrototype } from "../Contexts/ContextPrototype";
|
|
2
|
-
import { ComponentPrototype } from "../Components/ComponentPrototype";
|
|
3
|
-
import { TraitPrototype } from "../Traits/TraitPrototype";
|
|
4
|
-
import { ItemRegister } from "./ItemRegister";
|
|
5
1
|
import { SystemPrototype } from "../Systems/SystemPrototype";
|
|
6
|
-
import {
|
|
2
|
+
import { ComponentRegisterData } from "../Components/Component.types";
|
|
3
|
+
import { Tag } from "../Tags/Tag";
|
|
4
|
+
import { ContextRegisterData } from "../Contexts/Context.types";
|
|
5
|
+
import { IdPalette } from "../Util/IdPalette";
|
|
6
|
+
declare class ItemRegister<Item extends any> {
|
|
7
|
+
itemtype: string;
|
|
8
|
+
items: Item[];
|
|
9
|
+
idPalette: IdPalette;
|
|
10
|
+
constructor(itemtype: string);
|
|
11
|
+
get(id: string | number): Item;
|
|
12
|
+
has(id: string): boolean;
|
|
13
|
+
register(id: string, item: Item): number;
|
|
14
|
+
}
|
|
7
15
|
export declare class NCSRegister {
|
|
8
|
-
static components: ItemRegister<
|
|
9
|
-
static
|
|
10
|
-
static
|
|
11
|
-
static tags: ItemRegister<TagPrototype>;
|
|
16
|
+
static components: ItemRegister<ComponentRegisterData<any, any, any>>;
|
|
17
|
+
static contexts: ItemRegister<ContextRegisterData<any, any>>;
|
|
18
|
+
static tags: ItemRegister<Tag>;
|
|
12
19
|
static systems: ItemRegister<SystemPrototype>;
|
|
13
20
|
}
|
|
21
|
+
export {};
|