@amodx/ncs 0.0.24 → 0.0.27
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 +2 -1
- package/Components/ComponentArray.d.ts +4 -2
- package/Components/ComponentArray.js +15 -15
- package/Components/ComponentCursor.d.ts +8 -3
- package/Components/ComponentCursor.js +27 -9
- package/Contexts/ContextArray.d.ts +1 -1
- package/Contexts/ContextArray.js +6 -2
- package/Contexts/ContextCursor.d.ts +2 -1
- package/Contexts/ContextCursor.js +9 -1
- package/Data/serializeComponent.js +1 -1
- package/Data/serializeNode.js +4 -0
- package/Functional.d.ts +3 -3
- package/Functional.js +3 -3
- package/Graphs/Graph.d.ts +2 -1
- package/Graphs/Graph.js +14 -11
- package/Graphs/GraphClock.d.ts +8 -0
- package/Graphs/GraphClock.js +18 -0
- package/NCS.d.ts +10 -1
- package/Nodes/Node.types.d.ts +2 -2
- package/Nodes/NodeArray.d.ts +1 -0
- package/Nodes/NodeArray.js +6 -3
- package/Nodes/NodeComponents.d.ts +3 -3
- package/Nodes/NodeComponents.js +34 -13
- package/Nodes/NodeContext.js +6 -6
- package/Nodes/NodeCursor.d.ts +1 -1
- package/Nodes/NodeCursor.js +22 -11
- package/Nodes/NodeTags.js +2 -0
- package/Register/registerComponent.d.ts +12 -2
- package/Register/registerComponent.js +71 -14
- package/Schema/Functions/createSchemaBinaryObjectCursorClass.js +4 -4
- package/Schema/Functions/createSchemaObjectCursorClass.js +4 -4
- package/Schema/Functions/createSchemaTypedArrayCursorClass.js +4 -4
- package/Schema/Schema.js +6 -8
- package/Schema/SchemaArrayCursor.d.ts +1 -2
- package/Schema/SchemaArrayCursor.js +2 -6
- package/Schema/SchemaView.d.ts +3 -0
- package/Schema/SchemaView.js +16 -14
- package/Systems/System.types.d.ts +2 -1
- package/Systems/SystemInstance.d.ts +2 -1
- package/Systems/SystemInstance.js +2 -2
- package/Tags/Tag.js +1 -1
- package/Tags/TagArray.js +1 -1
- package/Util/ItemPool.js +1 -1
- package/package.json +1 -1
package/Schema/SchemaView.js
CHANGED
|
@@ -13,7 +13,6 @@ function traverseCreateJSON(parent, target, source) {
|
|
|
13
13
|
}
|
|
14
14
|
return target;
|
|
15
15
|
}
|
|
16
|
-
const tempData = [];
|
|
17
16
|
export class SchemaView {
|
|
18
17
|
schema;
|
|
19
18
|
id;
|
|
@@ -23,6 +22,8 @@ export class SchemaView {
|
|
|
23
22
|
_createData;
|
|
24
23
|
_cursorClass;
|
|
25
24
|
_dataPool = new ItemPool();
|
|
25
|
+
_cursorPool = new ItemPool();
|
|
26
|
+
_tempData = [];
|
|
26
27
|
constructor(schema, id, meta, byteOffset, byteSize, _createData, _cursorClass) {
|
|
27
28
|
this.schema = schema;
|
|
28
29
|
this.id = id;
|
|
@@ -35,20 +36,20 @@ export class SchemaView {
|
|
|
35
36
|
returnData(returnData) {
|
|
36
37
|
this._dataPool.addItem(returnData);
|
|
37
38
|
}
|
|
39
|
+
returnCursor(cursor) {
|
|
40
|
+
this._cursorPool.addItem(cursor);
|
|
41
|
+
}
|
|
38
42
|
createData(overrides) {
|
|
39
43
|
const data = this._createData;
|
|
40
|
-
overrides && (
|
|
44
|
+
overrides && (this._tempData.length = 0);
|
|
41
45
|
let baseData = !overrides
|
|
42
46
|
? this.schema._data
|
|
43
|
-
: this.schema.createData(
|
|
47
|
+
: this.schema.createData(this._tempData, overrides);
|
|
44
48
|
if (this._dataPool.items.length) {
|
|
45
49
|
const newData = this._dataPool.get();
|
|
46
50
|
if (data.type == "object") {
|
|
47
51
|
for (let i = 0; i < baseData.length; i++) {
|
|
48
|
-
newData[i] =
|
|
49
|
-
typeof baseData[i] == "object"
|
|
50
|
-
? structuredClone(baseData[i])
|
|
51
|
-
: baseData[i];
|
|
52
|
+
newData[i] = baseData[i];
|
|
52
53
|
}
|
|
53
54
|
return newData;
|
|
54
55
|
}
|
|
@@ -69,10 +70,7 @@ export class SchemaView {
|
|
|
69
70
|
if (data.type == "object") {
|
|
70
71
|
const newData = new Array(baseData.length);
|
|
71
72
|
for (let i = 0; i < baseData.length; i++) {
|
|
72
|
-
newData[i] =
|
|
73
|
-
typeof baseData[i] == "object"
|
|
74
|
-
? structuredClone(baseData[i])
|
|
75
|
-
: baseData[i];
|
|
73
|
+
newData[i] = baseData[i];
|
|
76
74
|
}
|
|
77
75
|
return newData;
|
|
78
76
|
}
|
|
@@ -106,18 +104,22 @@ export class SchemaView {
|
|
|
106
104
|
throw new Error(`NCS: Invalid create data`);
|
|
107
105
|
}
|
|
108
106
|
createCursor() {
|
|
107
|
+
const pooled = this._cursorPool.get();
|
|
108
|
+
if (pooled) {
|
|
109
|
+
return pooled;
|
|
110
|
+
}
|
|
109
111
|
return new this._cursorClass(this, this.meta, this._createData, this.byteOffset);
|
|
110
112
|
}
|
|
111
113
|
/** Converts data for use of remote components */
|
|
112
114
|
toRemote(cursor) {
|
|
113
115
|
if (this._createData.type == "object") {
|
|
114
|
-
return cursor.__cursor.
|
|
116
|
+
return cursor.__cursor._cachedData;
|
|
115
117
|
}
|
|
116
118
|
if (this._createData.type == "typed-array") {
|
|
117
|
-
return cursor.__cursor.
|
|
119
|
+
return cursor.__cursor._cachedData;
|
|
118
120
|
}
|
|
119
121
|
if (this._createData.type == "binary-object") {
|
|
120
|
-
return cursor.__cursor.
|
|
122
|
+
return cursor.__cursor._cachedData.buffer;
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
/** Converts data for remote data to local data*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GraphClock } from "../Graphs/GraphClock";
|
|
1
2
|
import { QueryPrototype } from "../Queries/QueryPrototype";
|
|
2
3
|
import { SystemInstance } from "./SystemInstance";
|
|
3
4
|
export type SystemRegisterData = {
|
|
@@ -12,5 +13,5 @@ export type SystemRegisterData = {
|
|
|
12
13
|
/**
|
|
13
14
|
* The update function of the system.
|
|
14
15
|
*/
|
|
15
|
-
update(system: SystemInstance,
|
|
16
|
+
update(system: SystemInstance, clock: GraphClock): void;
|
|
16
17
|
};
|
|
@@ -2,12 +2,13 @@ import { Graph } from "../Graphs/Graph";
|
|
|
2
2
|
import { SystemRegisterData } from "./System.types";
|
|
3
3
|
import { QueryInstance } from "../Queries/QueryInstance";
|
|
4
4
|
import { NodeCursor } from "../Nodes/NodeCursor";
|
|
5
|
+
import { GraphClock } from "../Graphs/GraphClock";
|
|
5
6
|
export declare class SystemInstance {
|
|
6
7
|
graph: Graph;
|
|
7
8
|
proto: SystemRegisterData;
|
|
8
9
|
queries: QueryInstance[];
|
|
9
10
|
node: NodeCursor;
|
|
10
11
|
constructor(graph: Graph, proto: SystemRegisterData);
|
|
11
|
-
update(
|
|
12
|
+
update(clock: GraphClock): void;
|
|
12
13
|
dispose(): void;
|
|
13
14
|
}
|
|
@@ -12,8 +12,8 @@ export class SystemInstance {
|
|
|
12
12
|
}
|
|
13
13
|
this.graph._systems.push(this);
|
|
14
14
|
}
|
|
15
|
-
update(
|
|
16
|
-
this.proto.update(this,
|
|
15
|
+
update(clock) {
|
|
16
|
+
this.proto.update(this, clock);
|
|
17
17
|
}
|
|
18
18
|
dispose() {
|
|
19
19
|
for (let i = 0; i < this.graph._systems.length; i++) {
|
package/Tags/Tag.js
CHANGED
|
@@ -12,7 +12,7 @@ export class Tag {
|
|
|
12
12
|
*traverseChildren() {
|
|
13
13
|
const children = [...this.children];
|
|
14
14
|
while (children.length) {
|
|
15
|
-
const child = children.
|
|
15
|
+
const child = children.pop();
|
|
16
16
|
yield child;
|
|
17
17
|
if (child.children.length)
|
|
18
18
|
children.push(...child.children);
|
package/Tags/TagArray.js
CHANGED
package/Util/ItemPool.js
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@amodx/ncs","version":"0.0.
|
|
1
|
+
{"name":"@amodx/ncs","version":"0.0.27","module":"index.js","types":"index.d.ts","type":"module","description":"NCS (Node Component System) is a library for the base of any NCS/ECS system.","keywords":[],"scripts":{"build":"mkdir -p dist && rm -rf dist/* && cp package.json dist/package.json && cd ./src && npx tsc","compile":"cd ./src && npx tsc --watch"},"repository":{"url":"git+https://github.com/Amodx/Libraries.git"},"bugs":{"url":"https://github.com/Amodx/Libraries/issues"},"homepage":"https://github.com/Amodx/Libraries","author":"Amodx","license":"MIT","devDependencies":{},"main":"index.js","publishConfig":{"access":"public"}}
|