@woosh/meep-engine 2.47.13 → 2.47.15
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/build/meep.cjs +10 -1
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +10 -1
- package/package.json +1 -1
- package/src/core/IdPool.js +10 -1
- package/src/core/json/abstractJSONSerializer.js +1 -1
- package/src/core/model/node-graph/NodeGraph.js +23 -6
- package/src/core/model/node-graph/node/NodeInstance.d.ts +4 -0
package/build/meep.module.js
CHANGED
|
@@ -117652,12 +117652,21 @@ function IdPool() {
|
|
|
117652
117652
|
this.bitSet = new BitSet();
|
|
117653
117653
|
}
|
|
117654
117654
|
|
|
117655
|
+
/**
|
|
117656
|
+
* Looks up next available ID without reserving it
|
|
117657
|
+
* If you want to also reserve the ID - use {@link get} instead
|
|
117658
|
+
* @returns {number}
|
|
117659
|
+
*/
|
|
117660
|
+
IdPool.prototype.peek = function () {
|
|
117661
|
+
return this.bitSet.nextClearBit(0);
|
|
117662
|
+
};
|
|
117663
|
+
|
|
117655
117664
|
/**
|
|
117656
117665
|
*
|
|
117657
117666
|
* @returns {number}
|
|
117658
117667
|
*/
|
|
117659
117668
|
IdPool.prototype.get = function () {
|
|
117660
|
-
const bitIndex = this.
|
|
117669
|
+
const bitIndex = this.peek();
|
|
117661
117670
|
|
|
117662
117671
|
this.bitSet.set(bitIndex, true);
|
|
117663
117672
|
|
package/package.json
CHANGED
package/src/core/IdPool.js
CHANGED
|
@@ -18,12 +18,21 @@ function IdPool() {
|
|
|
18
18
|
this.bitSet = new BitSet();
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Looks up next available ID without reserving it
|
|
23
|
+
* If you want to also reserve the ID - use {@link get} instead
|
|
24
|
+
* @returns {number}
|
|
25
|
+
*/
|
|
26
|
+
IdPool.prototype.peek = function () {
|
|
27
|
+
return this.bitSet.nextClearBit(0);
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
/**
|
|
22
31
|
*
|
|
23
32
|
* @returns {number}
|
|
24
33
|
*/
|
|
25
34
|
IdPool.prototype.get = function () {
|
|
26
|
-
const bitIndex = this.
|
|
35
|
+
const bitIndex = this.peek();
|
|
27
36
|
|
|
28
37
|
this.bitSet.set(bitIndex, true);
|
|
29
38
|
|
|
@@ -24,7 +24,7 @@ export function abstractJSONSerializer(source, serializers, classNames) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (typeName === undefined) {
|
|
27
|
-
throw new Error(`Failed to resolve type name
|
|
27
|
+
throw new Error(`Failed to resolve type name. No name found in classNames registry and no .typeName field on the constructor`);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
let serializer = serializers.get(typeName);
|
|
@@ -127,6 +127,7 @@ export class NodeGraph {
|
|
|
127
127
|
* Merge foreign nodes and associated connections into this graph
|
|
128
128
|
* New node instances and connections will be created to reflect these inside this graph
|
|
129
129
|
* NOTE: parameters on merged nodes are shallow copies
|
|
130
|
+
* NOTE: if IDs are available - copied nodes will have the same IDs as the originals
|
|
130
131
|
* @param {NodeInstance[]} nodes
|
|
131
132
|
* @param {Connection[]} [connections]
|
|
132
133
|
* @returns {{connections:Connection[], nodes:NodeInstance[]}} local created instances
|
|
@@ -147,12 +148,28 @@ export class NodeGraph {
|
|
|
147
148
|
for (let i = 0; i < additional_node_count; i++) {
|
|
148
149
|
const other_node = nodes[i];
|
|
149
150
|
|
|
150
|
-
const
|
|
151
|
-
this_nodes[other_node.id] = this_node_id;
|
|
151
|
+
const other_node_id = other_node.id;
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
const this_node = new NodeInstance();
|
|
154
|
+
this_node.setDescription(other_node.description);
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
// attempt to gain the same ID
|
|
158
|
+
const can_use_same_id = this.__idpNodes.isUsed(other_node_id);
|
|
159
|
+
|
|
160
|
+
let this_node_id;
|
|
161
|
+
if (can_use_same_id) {
|
|
162
|
+
this_node_id = other_node_id;
|
|
163
|
+
} else {
|
|
164
|
+
this_node_id = this.__idpNodes.peek();
|
|
165
|
+
}
|
|
155
166
|
|
|
167
|
+
this.addNode(this_node);
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
this_nodes[other_node_id] = this_node_id;
|
|
171
|
+
|
|
172
|
+
// copy parameters
|
|
156
173
|
this_node.setParameters(other_node.parameters);
|
|
157
174
|
|
|
158
175
|
}
|
|
@@ -376,13 +393,13 @@ export class NodeGraph {
|
|
|
376
393
|
createNode(node) {
|
|
377
394
|
const nodeInstance = new NodeInstance();
|
|
378
395
|
|
|
379
|
-
const id = this.__idpNodes.
|
|
396
|
+
const id = this.__idpNodes.peek();
|
|
380
397
|
|
|
381
398
|
nodeInstance.id = id;
|
|
382
399
|
nodeInstance.setDescription(node);
|
|
383
400
|
|
|
384
401
|
//record the node
|
|
385
|
-
this.
|
|
402
|
+
this.addNode(nodeInstance);
|
|
386
403
|
|
|
387
404
|
return id;
|
|
388
405
|
}
|