@woosh/meep-engine 2.98.3 → 2.99.1
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 +5 -3
- package/build/meep.module.js +5 -3
- package/package.json +1 -1
- package/src/core/collection/array/isArrayEqual.d.ts +1 -0
- package/src/core/collection/array/isArrayEqual.d.ts.map +1 -1
- package/src/core/collection/array/isArrayEqual.js +11 -3
- package/src/core/events/signal/Signal.d.ts +5 -2
- package/src/core/events/signal/Signal.d.ts.map +1 -1
- package/src/core/events/signal/Signal.js +1 -0
- package/src/core/events/signal/Signal.spec.js +88 -0
- package/src/core/model/node-graph/NodeGraph.d.ts +8 -4
- package/src/core/model/node-graph/NodeGraph.d.ts.map +1 -1
- package/src/core/model/node-graph/NodeGraph.js +27 -11
- package/src/core/model/node-graph/node/NodeDescription.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeDescription.js +20 -12
- package/src/core/model/node-graph/node/NodeDescription.spec.js +17 -1
- package/src/core/model/node-graph/node/NodeInstance.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeInstance.js +3 -3
package/build/meep.cjs
CHANGED
|
@@ -1150,6 +1150,7 @@ class Signal {
|
|
|
1150
1150
|
* Please note that this will remove even all handlers, irrespective of where they were added from. If another script is attaching to the same signal, using this method will potentially break that code.
|
|
1151
1151
|
* For most use cases, prefer to use {@link remove} method instead, or make use of {@link SignalBinding} if you need to keep track of multiple handlers
|
|
1152
1152
|
* NOTE: Consider this method to be unsafe, only use it when you understand the implications
|
|
1153
|
+
* @deprecated
|
|
1153
1154
|
*/
|
|
1154
1155
|
removeAll() {
|
|
1155
1156
|
const handlers = this.handlers;
|
|
@@ -97291,6 +97292,7 @@ ObjectPoolFactory.prototype.release = function (object) {
|
|
|
97291
97292
|
};
|
|
97292
97293
|
|
|
97293
97294
|
/**
|
|
97295
|
+
* Will invoke A.equals(B) on members if such exists
|
|
97294
97296
|
* @template T,R
|
|
97295
97297
|
* @param {T[]} first
|
|
97296
97298
|
* @param {R[]} second
|
|
@@ -97318,16 +97320,16 @@ function isArrayEqual(first, second) {
|
|
|
97318
97320
|
|
|
97319
97321
|
|
|
97320
97322
|
if (a === undefined) {
|
|
97321
|
-
//
|
|
97323
|
+
// A is undefined, and B is something else
|
|
97322
97324
|
return false;
|
|
97323
97325
|
}
|
|
97324
97326
|
|
|
97325
97327
|
if (a === null) {
|
|
97326
|
-
//
|
|
97328
|
+
// A is null and B is something else
|
|
97327
97329
|
return false;
|
|
97328
97330
|
}
|
|
97329
97331
|
|
|
97330
|
-
//try "equals" method
|
|
97332
|
+
// try "equals" method
|
|
97331
97333
|
if (typeof a.equals === "function") {
|
|
97332
97334
|
|
|
97333
97335
|
if (!a.equals(b)) {
|
package/build/meep.module.js
CHANGED
|
@@ -1148,6 +1148,7 @@ class Signal {
|
|
|
1148
1148
|
* Please note that this will remove even all handlers, irrespective of where they were added from. If another script is attaching to the same signal, using this method will potentially break that code.
|
|
1149
1149
|
* For most use cases, prefer to use {@link remove} method instead, or make use of {@link SignalBinding} if you need to keep track of multiple handlers
|
|
1150
1150
|
* NOTE: Consider this method to be unsafe, only use it when you understand the implications
|
|
1151
|
+
* @deprecated
|
|
1151
1152
|
*/
|
|
1152
1153
|
removeAll() {
|
|
1153
1154
|
const handlers = this.handlers;
|
|
@@ -97289,6 +97290,7 @@ ObjectPoolFactory.prototype.release = function (object) {
|
|
|
97289
97290
|
};
|
|
97290
97291
|
|
|
97291
97292
|
/**
|
|
97293
|
+
* Will invoke A.equals(B) on members if such exists
|
|
97292
97294
|
* @template T,R
|
|
97293
97295
|
* @param {T[]} first
|
|
97294
97296
|
* @param {R[]} second
|
|
@@ -97316,16 +97318,16 @@ function isArrayEqual(first, second) {
|
|
|
97316
97318
|
|
|
97317
97319
|
|
|
97318
97320
|
if (a === undefined) {
|
|
97319
|
-
//
|
|
97321
|
+
// A is undefined, and B is something else
|
|
97320
97322
|
return false;
|
|
97321
97323
|
}
|
|
97322
97324
|
|
|
97323
97325
|
if (a === null) {
|
|
97324
|
-
//
|
|
97326
|
+
// A is null and B is something else
|
|
97325
97327
|
return false;
|
|
97326
97328
|
}
|
|
97327
97329
|
|
|
97328
|
-
//try "equals" method
|
|
97330
|
+
// try "equals" method
|
|
97329
97331
|
if (typeof a.equals === "function") {
|
|
97330
97332
|
|
|
97331
97333
|
if (!a.equals(b)) {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isArrayEqual.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/isArrayEqual.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isArrayEqual.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/isArrayEqual.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,6DAFY,OAAO,CAqDlB"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
4
|
+
* Will invoke A.equals(B) on members if such exists
|
|
2
5
|
* @template T,R
|
|
3
6
|
* @param {T[]} first
|
|
4
7
|
* @param {R[]} second
|
|
5
8
|
* @return {boolean}
|
|
6
9
|
*/
|
|
7
10
|
export function isArrayEqual(first, second) {
|
|
11
|
+
assert.defined(first, 'first');
|
|
12
|
+
assert.isArray(first, 'first');
|
|
13
|
+
|
|
14
|
+
assert.defined(second, 'second');
|
|
15
|
+
assert.isArray(second, 'second');
|
|
8
16
|
|
|
9
17
|
const il = first.length;
|
|
10
18
|
|
|
@@ -26,16 +34,16 @@ export function isArrayEqual(first, second) {
|
|
|
26
34
|
|
|
27
35
|
|
|
28
36
|
if (a === undefined) {
|
|
29
|
-
//
|
|
37
|
+
// A is undefined, and B is something else
|
|
30
38
|
return false;
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
if (a === null) {
|
|
34
|
-
//
|
|
42
|
+
// A is null and B is something else
|
|
35
43
|
return false;
|
|
36
44
|
}
|
|
37
45
|
|
|
38
|
-
//try "equals" method
|
|
46
|
+
// try "equals" method
|
|
39
47
|
if (typeof a.equals === "function") {
|
|
40
48
|
|
|
41
49
|
if (!a.equals(b)) {
|
|
@@ -39,14 +39,17 @@ export default class Signal<A = any, B = any, C = any, D = any, E = any, F = any
|
|
|
39
39
|
|
|
40
40
|
send4(a: A, b: B, c: C, d: D): void
|
|
41
41
|
|
|
42
|
-
send5(a: A, b: B, c: C, d: D, e: E): void
|
|
43
|
-
|
|
44
42
|
send6(a: A, b: B, c: C, d: D, e: E, f: F): void
|
|
45
43
|
|
|
44
|
+
send8(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H): void
|
|
45
|
+
|
|
46
46
|
/**
|
|
47
47
|
* @deprecated use strongly typed dispatch methods instead (send0, send1 etc)
|
|
48
48
|
*/
|
|
49
49
|
dispatch(...params: any[]): void
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated
|
|
53
|
+
*/
|
|
51
54
|
removeAll(): void
|
|
52
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"AAulBA;;;;;;GAMG;AACH,yDALW,aAAa,EAAE,+BAGb,MAAM,CAoBlB;AAED;;;;;;GAMG;AACH,mEALW,aAAa,EAAE,0BAGb,MAAM,CAclB;AAiDD;;;;GAIG;AACH,2CAHW,aAAa,EAAE,sBA8BzB;AAnsBD;;;;GAIG;AACH;IACI;;;OAGG;IACH,iBAAc;IAEd;;;;OAIG;IACH,cAAU;IAWV;;;OAGG;IACH,yBAEC;IAfD;;;OAGG;IACH,sBAEC;IAYD;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,SAClB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,OAAO,CAInB;IAGD;;;;;OAKG;IACH,4CAFa,OAAO,CAQnB;IAED,aAEC;IAED,eAEC;IAED;;;OAGG;IACH,eAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,yCAQC;IAED;;;;OAIG;IACH,sCAYC;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAUnB;IAED;;;;;;OAMG;IACH,kBAGC;IAED;;;OAGG;IACH,+BAQC;IAED;;;OAGG;IACH,cA4CC;IAED;;;;OAIG;IACH,sBA6CC;IAED;;;;OAIG;IACH,4BA4CC;IAED;;;;;OAKG;IACH,oCA4CC;IAED;;;;;;OAMG;IACH,4CA4CC;IAED;;;;;;;;OAQG;IACH,4DA4CC;IAED;;;;;;;;;;OAUG;IACH,4EA4CC;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,MAAM,CAalB;IAIL;;;OAGG;IACH,mBAFU,OAAO,CAEQ;CAPxB;;8BArkBiD,oBAAoB"}
|
|
@@ -180,6 +180,7 @@ export class Signal {
|
|
|
180
180
|
* Please note that this will remove even all handlers, irrespective of where they were added from. If another script is attaching to the same signal, using this method will potentially break that code.
|
|
181
181
|
* For most use cases, prefer to use {@link remove} method instead, or make use of {@link SignalBinding} if you need to keep track of multiple handlers
|
|
182
182
|
* NOTE: Consider this method to be unsafe, only use it when you understand the implications
|
|
183
|
+
* @deprecated
|
|
183
184
|
*/
|
|
184
185
|
removeAll() {
|
|
185
186
|
const handlers = this.handlers;
|
|
@@ -163,3 +163,91 @@ test("handlers should be executed in the order in which they are added", () => {
|
|
|
163
163
|
|
|
164
164
|
expect(marks).toEqual([1, 2]);
|
|
165
165
|
});
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
test("send0", () => {
|
|
169
|
+
|
|
170
|
+
function handler() {
|
|
171
|
+
|
|
172
|
+
expect(arguments.length).toEqual(0);
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const signal = new Signal();
|
|
177
|
+
|
|
178
|
+
signal.add(handler);
|
|
179
|
+
|
|
180
|
+
signal.send0();
|
|
181
|
+
});
|
|
182
|
+
test("send1", () => {
|
|
183
|
+
|
|
184
|
+
const call_param_list = [];
|
|
185
|
+
|
|
186
|
+
const signal = new Signal();
|
|
187
|
+
|
|
188
|
+
signal.add(Array.prototype.push, call_param_list);
|
|
189
|
+
|
|
190
|
+
signal.send1(7);
|
|
191
|
+
|
|
192
|
+
expect(call_param_list).toEqual([7]);
|
|
193
|
+
});
|
|
194
|
+
test("send2", () => {
|
|
195
|
+
|
|
196
|
+
const call_param_list = [];
|
|
197
|
+
|
|
198
|
+
const signal = new Signal();
|
|
199
|
+
|
|
200
|
+
signal.add(Array.prototype.push, call_param_list);
|
|
201
|
+
|
|
202
|
+
signal.send2(3, 7);
|
|
203
|
+
|
|
204
|
+
expect(call_param_list).toEqual([3, 7]);
|
|
205
|
+
});
|
|
206
|
+
test("send3", () => {
|
|
207
|
+
|
|
208
|
+
const call_param_list = [];
|
|
209
|
+
|
|
210
|
+
const signal = new Signal();
|
|
211
|
+
|
|
212
|
+
signal.add(Array.prototype.push, call_param_list);
|
|
213
|
+
|
|
214
|
+
signal.send3(3, 7, 11);
|
|
215
|
+
|
|
216
|
+
expect(call_param_list).toEqual([3, 7, 11]);
|
|
217
|
+
});
|
|
218
|
+
test("send4", () => {
|
|
219
|
+
|
|
220
|
+
const call_param_list = [];
|
|
221
|
+
|
|
222
|
+
const signal = new Signal();
|
|
223
|
+
|
|
224
|
+
signal.add(Array.prototype.push, call_param_list);
|
|
225
|
+
|
|
226
|
+
signal.send4(3, 7, 11, 13);
|
|
227
|
+
|
|
228
|
+
expect(call_param_list).toEqual([3, 7, 11, 13]);
|
|
229
|
+
});
|
|
230
|
+
test("send6", () => {
|
|
231
|
+
|
|
232
|
+
const call_param_list = [];
|
|
233
|
+
|
|
234
|
+
const signal = new Signal();
|
|
235
|
+
|
|
236
|
+
signal.add(Array.prototype.push, call_param_list);
|
|
237
|
+
|
|
238
|
+
signal.send6(3, 7, 11, 13, 17, 23);
|
|
239
|
+
|
|
240
|
+
expect(call_param_list).toEqual([3, 7, 11, 13, 17, 23]);
|
|
241
|
+
});
|
|
242
|
+
test("send8", () => {
|
|
243
|
+
|
|
244
|
+
const call_param_list = [];
|
|
245
|
+
|
|
246
|
+
const signal = new Signal();
|
|
247
|
+
|
|
248
|
+
signal.add(Array.prototype.push, call_param_list);
|
|
249
|
+
|
|
250
|
+
signal.send8(3, 7, 11, 13, 17, 23, 31, 37);
|
|
251
|
+
|
|
252
|
+
expect(call_param_list).toEqual([3, 7, 11, 13, 17, 23, 31, 37]);
|
|
253
|
+
});
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
export class NodeGraph {
|
|
2
2
|
/**
|
|
3
3
|
* @private
|
|
4
|
+
* @readonly
|
|
4
5
|
* @type {List<NodeInstance>}
|
|
5
6
|
*/
|
|
6
|
-
private nodes;
|
|
7
|
+
private readonly nodes;
|
|
7
8
|
/**
|
|
8
9
|
* @private
|
|
10
|
+
* @readonly
|
|
9
11
|
* @type {List<Connection>}
|
|
10
12
|
*/
|
|
11
|
-
private connections;
|
|
13
|
+
private readonly connections;
|
|
12
14
|
/**
|
|
13
15
|
*
|
|
14
16
|
* @type {IdPool}
|
|
17
|
+
* @readonly
|
|
15
18
|
* @private
|
|
16
19
|
*/
|
|
17
|
-
private __idpNodes;
|
|
20
|
+
private readonly __idpNodes;
|
|
18
21
|
/**
|
|
19
22
|
*
|
|
20
23
|
* @type {IdPool}
|
|
24
|
+
* @readonly
|
|
21
25
|
* @private
|
|
22
26
|
*/
|
|
23
|
-
private __idpConnections;
|
|
27
|
+
private readonly __idpConnections;
|
|
24
28
|
/**
|
|
25
29
|
* @readonly
|
|
26
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeGraph.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/node-graph/NodeGraph.js"],"names":[],"mappings":"AASA;IAEI
|
|
1
|
+
{"version":3,"file":"NodeGraph.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/node-graph/NodeGraph.js"],"names":[],"mappings":"AASA;IAEI;;;;OAIG;IACH,uBAAmB;IAEnB;;;;OAIG;IACH,6BAAyB;IAEzB;;;;;OAKG;IACH,4BAA0B;IAE1B;;;;;OAKG;IACH,kCAAgC;IAEhC;;OAEG;IACH;QACI;;;WAGG;;QAGH;;;WAGG;;QAGH;;;WAGG;;QAGH;;;WAGG;;MAEL;IAEF;;OAEG;IACH,cAMC;IAED;;;OAGG;IACH,YAFW,SAAS,QAYnB;IAED;;;OAGG;IACH,SAFa,SAAS,CAQrB;IAED;;;;;;OAMG;IACH,aAHW,SAAS,GACP;QAAC,WAAW,EAAC,UAAU,EAAE,CAAC;QAAC,KAAK,EAAC,YAAY,EAAE,CAAA;KAAC,CAe5D;IAED;;;;;;;;OAQG;IACH,sCAJW,YAAY,EAAE,GAEZ;QAAC,WAAW,EAAC,UAAU,EAAE,CAAC;QAAC,KAAK,EAAC,YAAY,EAAE,CAAA;KAAC,CAmF5D;IAED;;;;OAIG;IACH,8BAHoB,YAAY,+BAK/B;IAED;;;;OAIG;IACH,oCAHoB,UAAU,+BAK7B;IAED;;;OAGG;IACH,YAFY,YAAY,EAAE,CAIzB;IAED;;;OAGG;IACH,kBAFY,UAAU,EAAE,CAIvB;IAED;;;;OAIG;IACH,cAHW,YAAY,GACV,OAAO,CAenB;IAED;;;;OAIG;IACH,qDAFa,YAAY,EAAE,CAqB1B;IAED;;;;OAIG;IACH,0DAFa,YAAY,EAAE,CAqB1B;IAED;;;;OAIG;IACH,YAHW,MAAM,GACJ,YAAY,GAAC,SAAS,CAkBlC;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,YAAY,CAUxB;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,UAAU,GAAC,SAAS,CAgBhC;IAED;;;;;OAKG;IACH,+BAJW,MAAM,WACN,MAAM,GACJ,4BAA0B,SAAS,CAY/C;IAED;;;;OAIG;IACH,mCAFa,MAAM,CAclB;IAED;;;OAGG;IACH,cAFW,YAAY,QAgBtB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACJ,OAAO,CA4BnB;IAED;;;;;;;;OAQG;IACH,uCANW,MAAM,cACN,MAAM,cACN,MAAM,cACN,MAAM,GACJ,MAAM,CAqClB;IAED;;;;;;;OAOG;IACH,6BANW,MAAM,cACN,MAAM,cACN,MAAM,cACN,MAAM,GACJ,MAAM,CAoDlB;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACJ,OAAO,CAuBnB;IAED;;;;;OAKG;IACH,iCAJW,MAAM,UACN,MAAM,EAAE,GACN,MAAM,CAyBlB;IAGL;;;OAGG;IACH,sBAFU,OAAO,CAEc;CAN9B;6BA5nB4B,wBAAwB;2BAD1B,iBAAiB"}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import {assert} from "../../assert.js";
|
|
2
|
-
import {array_push_if_unique} from "../../collection/array/array_push_if_unique.js";
|
|
3
|
-
import {array_remove_first} from "../../collection/array/array_remove_first.js";
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { array_push_if_unique } from "../../collection/array/array_push_if_unique.js";
|
|
3
|
+
import { array_remove_first } from "../../collection/array/array_remove_first.js";
|
|
4
4
|
import List from "../../collection/list/List.js";
|
|
5
5
|
import IdPool from "../../IdPool.js";
|
|
6
|
-
import {Connection} from "./Connection.js";
|
|
7
|
-
import {NodeInstance} from "./node/NodeInstance.js";
|
|
8
|
-
import {PortDirection} from "./node/PortDirection.js";
|
|
6
|
+
import { Connection } from "./Connection.js";
|
|
7
|
+
import { NodeInstance } from "./node/NodeInstance.js";
|
|
8
|
+
import { PortDirection } from "./node/PortDirection.js";
|
|
9
9
|
|
|
10
10
|
export class NodeGraph {
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @private
|
|
14
|
+
* @readonly
|
|
14
15
|
* @type {List<NodeInstance>}
|
|
15
16
|
*/
|
|
16
17
|
nodes = new List();
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* @private
|
|
21
|
+
* @readonly
|
|
20
22
|
* @type {List<Connection>}
|
|
21
23
|
*/
|
|
22
24
|
connections = new List();
|
|
@@ -24,6 +26,7 @@ export class NodeGraph {
|
|
|
24
26
|
/**
|
|
25
27
|
*
|
|
26
28
|
* @type {IdPool}
|
|
29
|
+
* @readonly
|
|
27
30
|
* @private
|
|
28
31
|
*/
|
|
29
32
|
__idpNodes = new IdPool();
|
|
@@ -31,6 +34,7 @@ export class NodeGraph {
|
|
|
31
34
|
/**
|
|
32
35
|
*
|
|
33
36
|
* @type {IdPool}
|
|
37
|
+
* @readonly
|
|
34
38
|
* @private
|
|
35
39
|
*/
|
|
36
40
|
__idpConnections = new IdPool();
|
|
@@ -111,6 +115,9 @@ export class NodeGraph {
|
|
|
111
115
|
* @returns {{connections:Connection[], nodes:NodeInstance[]}}
|
|
112
116
|
*/
|
|
113
117
|
merge(other) {
|
|
118
|
+
assert.defined(other, 'other');
|
|
119
|
+
assert.notNull(other, 'other');
|
|
120
|
+
|
|
114
121
|
if (other === this) {
|
|
115
122
|
// can't merge with self, invalid operation
|
|
116
123
|
throw new Error("Can't merge with self, invalid operation");
|
|
@@ -131,7 +138,18 @@ export class NodeGraph {
|
|
|
131
138
|
* @param {Connection[]} [connections]
|
|
132
139
|
* @returns {{connections:Connection[], nodes:NodeInstance[]}} local created instances
|
|
133
140
|
*/
|
|
134
|
-
mergeFragment({
|
|
141
|
+
mergeFragment({
|
|
142
|
+
nodes,
|
|
143
|
+
connections = []
|
|
144
|
+
}) {
|
|
145
|
+
|
|
146
|
+
assert.defined(nodes, 'nodes');
|
|
147
|
+
assert.notNull(nodes, 'nodes');
|
|
148
|
+
assert.isArray(nodes, 'nodes');
|
|
149
|
+
|
|
150
|
+
assert.defined(connections, 'connections');
|
|
151
|
+
assert.notNull(connections, 'connections');
|
|
152
|
+
assert.isArray(connections, 'connections');
|
|
135
153
|
|
|
136
154
|
const previous_node_count = this.nodes.length;
|
|
137
155
|
const previous_connection_count = this.connections.length;
|
|
@@ -518,8 +536,6 @@ export class NodeGraph {
|
|
|
518
536
|
assert.isNonNegativeInteger(targetNode, 'targetNode');
|
|
519
537
|
assert.isNonNegativeInteger(targetPort, 'targetPort');
|
|
520
538
|
|
|
521
|
-
//TODO validate if connection already exists
|
|
522
|
-
|
|
523
539
|
const sourceNodeInstance = this.getNode(sourceNode);
|
|
524
540
|
|
|
525
541
|
if (sourceNodeInstance === undefined) {
|
|
@@ -536,13 +552,13 @@ export class NodeGraph {
|
|
|
536
552
|
const sourceEndpoint = sourceNodeInstance.getEndpoint(sourcePort);
|
|
537
553
|
|
|
538
554
|
if (sourceEndpoint === undefined) {
|
|
539
|
-
throw new Error(`Source port '${sourcePort}' not found`);
|
|
555
|
+
throw new Error(`Source port '${sourcePort}' not found on ${sourceNodeInstance}`);
|
|
540
556
|
}
|
|
541
557
|
|
|
542
558
|
const targetEndpoint = targetNodeInstance.getEndpoint(targetPort);
|
|
543
559
|
|
|
544
560
|
if (targetEndpoint === undefined) {
|
|
545
|
-
throw new Error(`Target port '${targetPort}' not found`);
|
|
561
|
+
throw new Error(`Target port '${targetPort}' not found on ${targetNodeInstance}`);
|
|
546
562
|
}
|
|
547
563
|
|
|
548
564
|
//create connection
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeDescription.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/node/NodeDescription.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeDescription.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/node/NodeDescription.js"],"names":[],"mappings":"AAwCA;IACI;;;OAGG;IACH,MAFU,MAAM,CAEN;IAEV;;;;;;OAMG;IACH,IAFU,MAAM,CAEO;IAEvB;;;OAGG;IACH,iBAFU,IAAI,EAAE,CAEL;IAEX;;;OAGG;IACH,YAFU,wBAAwB,EAAE,CAEpB;IAEhB;;OAEG;IACH;QACI;;;WAGG;4BADO,OAAO,IAAI,CAAC;QAGtB;;;WAGG;8BADO,OAAO,IAAI,CAAC;MAGxB;IAEF;;;;OAIG;IACH,4CAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,sBAEC;IAED;;;;;;OAMG;IACH,sBALW,MAAM,QACN,qBAAqB,iBACrB,MAAM,GAAC,OAAO,GAAC,MAAM,GACnB,MAAM,CA0ClB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,wBAAwB,CAiBpC;IAGD;;;;;;OAMG;IACH,oDAHW,aAAa,GACX,MAAM,CA2BlB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACJ,OAAO,CAuBnB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,IAAI,GAAC,IAAI,CAgBrB;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,IAAI,EAAE,CAwBjB;IAED;;;;OAIG;IACH,+BAHW,aAAa,GACZ,IAAI,EAAE,CAuBjB;IAED;;;;;OAKG;IACH,iCAJW,MAAM,aACN,aAAa,GACZ,IAAI,GAAC,SAAS,CAmBzB;IAED;;;OAGG;IACH,YAFa,IAAI,EAAE,CAIlB;IAED;;;;OAIG;IACH,cAHW,eAAe,GACb,OAAO,CAYnB;IAED,mBAEC;IAED;;;;MAMC;IAED;;;;;;OAMG;IACH,8BALW,EAAE,gCAaZ;IAKL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAR1C;;;;qBAxYoB,WAAW;yCADS,yCAAyC;mBAH/D,kCAAkC;sCAEf,sCAAsC;8BAG9C,oBAAoB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../../assert.js";
|
|
2
|
+
import { BitSet } from "../../../binary/BitSet.js";
|
|
2
3
|
import { isArrayEqual } from "../../../collection/array/isArrayEqual.js";
|
|
3
4
|
import Signal from "../../../events/signal/Signal.js";
|
|
4
5
|
import { invokeObjectToJSON } from "../../object/invokeObjectToJSON.js";
|
|
@@ -9,28 +10,26 @@ import { PortDirection } from "./PortDirection.js";
|
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
* @template T
|
|
13
13
|
* @private
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {{id:number}[]} things
|
|
15
15
|
* @returns {number}
|
|
16
16
|
*/
|
|
17
17
|
function pickNewSetId(things) {
|
|
18
18
|
|
|
19
|
+
const used = new BitSet();
|
|
19
20
|
|
|
20
21
|
const n = things.length;
|
|
21
22
|
|
|
22
|
-
let r = n;
|
|
23
|
-
|
|
24
23
|
for (let i = 0; i < n; i++) {
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const thing = things[i];
|
|
26
|
+
if (thing !== undefined) {
|
|
27
|
+
used.set(thing.id, true);
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
return
|
|
32
|
+
return used.nextClearBit(0);
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
/**
|
|
@@ -359,6 +358,11 @@ export class NodeDescription {
|
|
|
359
358
|
* @returns {boolean}
|
|
360
359
|
*/
|
|
361
360
|
equals(other) {
|
|
361
|
+
if (this === other) {
|
|
362
|
+
// fast shortcut
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
|
|
362
366
|
return this.id === other.id
|
|
363
367
|
&& this.name === other.name
|
|
364
368
|
&& isArrayEqual(this.ports, other.ports)
|
|
@@ -379,12 +383,16 @@ export class NodeDescription {
|
|
|
379
383
|
|
|
380
384
|
/**
|
|
381
385
|
*
|
|
382
|
-
* @param ports
|
|
383
|
-
* @param id
|
|
384
|
-
* @param name
|
|
386
|
+
* @param {[]} ports
|
|
387
|
+
* @param {number} id
|
|
388
|
+
* @param {string} name
|
|
385
389
|
* @param {NodeRegistry} registry
|
|
386
390
|
*/
|
|
387
|
-
fromJSON({ ports, id, name }, registry) {
|
|
391
|
+
fromJSON({ ports = [], id, name = "" }, registry) {
|
|
392
|
+
assert.isNonNegativeInteger(id, 'id');
|
|
393
|
+
assert.isString(name, 'name');
|
|
394
|
+
assert.isArray(ports, 'ports');
|
|
395
|
+
|
|
388
396
|
this.id = id;
|
|
389
397
|
this.name = name;
|
|
390
398
|
this.ports = ports.map(p => Port.fromJSON(p, registry));
|
|
@@ -57,9 +57,25 @@ test("delete port", () => {
|
|
|
57
57
|
expect(node.getPorts()).toEqual([]);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
+
test("id uniqueness is preserved when ports are added and deleted out of order", () => {
|
|
61
|
+
|
|
62
|
+
const node = new NodeDescription();
|
|
63
|
+
|
|
64
|
+
const a = node.createPort(DUMMY_TYPE, "a", PortDirection.In);
|
|
65
|
+
const b = node.createPort(DUMMY_TYPE, "b", PortDirection.In);
|
|
66
|
+
const c = node.createPort(DUMMY_TYPE, "c", PortDirection.In);
|
|
67
|
+
|
|
68
|
+
node.deletePort(b);
|
|
69
|
+
|
|
70
|
+
const d = node.createPort(DUMMY_TYPE, "d", PortDirection.In);
|
|
71
|
+
|
|
72
|
+
expect(d).toEqual(b);
|
|
73
|
+
|
|
74
|
+
});
|
|
75
|
+
|
|
60
76
|
test("toString", () => {
|
|
61
77
|
const node = new NodeDescription();
|
|
62
78
|
|
|
63
79
|
expect(typeof node.toString()).toBe("string");
|
|
64
80
|
expect(node.toString().length).toBeGreaterThan(0);
|
|
65
|
-
});
|
|
81
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeInstance.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/node/NodeInstance.js"],"names":[],"mappings":"AAcA;;;;GAIG;AACH;IAEI;;;;OAIG;IACH,aAFU,MAAM,CAEE;IAElB;;;OAGG;IACH,6BAAmB;IAEnB;;;OAGG;IACH,WAFU,yBAAyB,EAAE,CAEtB;IAEf;;;OAGG;IACH,gBAAgB;IAEhB;;;OAGG;IACH,qBAAmB;IAEnB;;;OAGG;IACH,aAFU,gBAAgB,CAED;IAEzB;;;;;;OAMG;IACH,wBAFU,MAAM,CAEE;IAElB;;OAEG;IACH;QACI;;;WAGG;mCADO,OAAO,MAAM,WAAO;QAG9B;;;WAGG;iCADO,OAAO,MAAM,MAAI;QAG3B;;;WAGG;mCADO,OAAO,MAAM,MAAI;QAI3B;;;;WAIG;qCADO,
|
|
1
|
+
{"version":3,"file":"NodeInstance.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/node/NodeInstance.js"],"names":[],"mappings":"AAcA;;;;GAIG;AACH;IAEI;;;;OAIG;IACH,aAFU,MAAM,CAEE;IAElB;;;OAGG;IACH,6BAAmB;IAEnB;;;OAGG;IACH,WAFU,yBAAyB,EAAE,CAEtB;IAEf;;;OAGG;IACH,gBAAgB;IAEhB;;;OAGG;IACH,qBAAmB;IAEnB;;;OAGG;IACH,aAFU,gBAAgB,CAED;IAEzB;;;;;;OAMG;IACH,wBAFU,MAAM,CAEE;IAElB;;OAEG;IACH;QACI;;;WAGG;mCADO,OAAO,MAAM,WAAO;QAG9B;;;WAGG;iCADO,OAAO,MAAM,MAAI;QAG3B;;;WAGG;mCADO,OAAO,MAAM,MAAI;QAI3B;;;;WAIG;qCADO,yCAAyC,YAAY,CAAC;MAGlE;IAEF;;;;;;OAMG;IACH,yBALW,MAAM,aACN,aAAa,UACb,YAAY,GACV,MAAM,CAsBlB;IAED;;;OAGG;IACH,gDAEC;IAED;;;OAGG;IACH,+CAEC;IAGD;;;OAGG;IACH,mCAEC;IAED;;;;OAIG;IACH,kCAEC;IAED;;;;OAIG;IACH,mBAHW,MAAM,oBAKhB;IAED;;;;OAIG;IACH,mBAHW,MAAM,OAKhB;IAED;;;;OAIG;IACH,yBAHW,MAAM,KAOhB;IAED;;;;OAIG;IACH,2BAHW,MAAM,oBAmChB;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACJ,OAAO,CAkBnB;IAED;;;OAGG;IACH,uCAQC;IAED,wBAIC;IAED;;;OAGG;IACH,mDAqCC;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,yBAAyB,GAAC,SAAS,CAe/C;IAED,eAEC;IAED;;;;OAIG;IACH,cAHW,YAAY,GACV,OAAO,CAQnB;IAED,mBAEC;IAIL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;CAPpC;0CA3VyC,gCAAgC;iBAHzD,kCAAkC;mBAChC,kCAAkC;8BAGvB,oBAAoB"}
|
|
@@ -86,9 +86,9 @@ export class NodeInstance {
|
|
|
86
86
|
parameterRemoved: new Signal(),
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* fires: (newDescription:NodeDescription, oldDescription:NodeDescription|null)
|
|
89
|
+
* fires: (newDescription:NodeDescription, oldDescription:NodeDescription|null, this)
|
|
90
90
|
* @readonly
|
|
91
|
-
* @type {Signal<NodeDescription, NodeDescription>}
|
|
91
|
+
* @type {Signal<NodeDescription, NodeDescription, NodeInstance>}
|
|
92
92
|
*/
|
|
93
93
|
descriptionChanged: new Signal()
|
|
94
94
|
};
|
|
@@ -307,7 +307,7 @@ export class NodeInstance {
|
|
|
307
307
|
this.parameters[pd.id] = pd.defaultValue;
|
|
308
308
|
});
|
|
309
309
|
|
|
310
|
-
this.on.descriptionChanged.
|
|
310
|
+
this.on.descriptionChanged.send3(description, old_description, this);
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
/**
|