@woosh/meep-engine 2.94.8 → 2.95.0

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.94.8",
8
+ "version": "2.95.0",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns a copy without any duplicate elements
3
+ * @template T
4
+ * @param {T[]} input
5
+ * @return {T[]}
6
+ */
7
+ export function array_deduplicate<T>(input: T[]): T[];
8
+ //# sourceMappingURL=array_deduplicate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_deduplicate.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_deduplicate.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,sDAEC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns a copy without any duplicate elements
3
+ * @template T
4
+ * @param {T[]} input
5
+ * @return {T[]}
6
+ */
7
+ export function array_deduplicate(input) {
8
+ return Array.from(new Set(input));
9
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=array_deduplicate.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_deduplicate.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_deduplicate.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { array_deduplicate } from "./array_deduplicate.js";
2
+
3
+ test("basics", () => {
4
+ expect(array_deduplicate([])).toEqual([]);
5
+ expect(array_deduplicate([1])).toEqual([1]);
6
+ expect(array_deduplicate([1, 2])).toEqual([1, 2]);
7
+ expect(array_deduplicate([1, 2, 2])).toEqual([1, 2]);
8
+ expect(array_deduplicate([1, 2, 1])).toEqual([1, 2]);
9
+ expect(array_deduplicate([1, 1, 2])).toEqual([1, 2]);
10
+ expect(array_deduplicate([1, 2])).toEqual([1, 2]);
11
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"NodeInstance.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/node/NodeInstance.js"],"names":[],"mappings":"AAcA;IAEI;;;OAGG;IACH,IAFU,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;MAG7B;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,4CAwBC;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;0CAjUuC,gCAAgC;iBAHvD,kCAAkC;mBAChC,kCAAkC;8BAGzB,oBAAoB"}
1
+ {"version":3,"file":"NodeInstance.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/node/NodeInstance.js"],"names":[],"mappings":"AAcA;IAEI;;;OAGG;IACH,IAFU,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,wCAAwC;MAGpD;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;0CArVyC,gCAAgC;iBAHzD,kCAAkC;mBAChC,kCAAkC;8BAGvB,oBAAoB"}
@@ -1,10 +1,10 @@
1
- import {assert} from "../../../assert.js";
2
- import {isArrayEqual} from "../../../collection/array/isArrayEqual.js";
1
+ import { assert } from "../../../assert.js";
2
+ import { isArrayEqual } from "../../../collection/array/isArrayEqual.js";
3
3
  import List from "../../../collection/list/List.js";
4
4
  import Signal from "../../../events/signal/Signal.js";
5
- import {objectDeepEquals} from "../../object/objectDeepEquals.js";
6
- import {NodeInstancePortReference} from "./NodeInstancePortReference.js";
7
- import {PortDirection} from "./PortDirection.js";
5
+ import { objectDeepEquals } from "../../object/objectDeepEquals.js";
6
+ import { NodeInstancePortReference } from "./NodeInstancePortReference.js";
7
+ import { PortDirection } from "./PortDirection.js";
8
8
 
9
9
  /**
10
10
  *
@@ -78,6 +78,13 @@ export class NodeInstance {
78
78
  * @type {Signal<string, *>}
79
79
  */
80
80
  parameterRemoved: new Signal(),
81
+
82
+ /**
83
+ * fires: (newDescription:NodeDescription, oldDescription:NodeDescription|null)
84
+ * @readonly
85
+ * @type {Signal<NodeDescription, NodeDescription>}
86
+ */
87
+ descriptionChanged: new Signal()
81
88
  };
82
89
 
83
90
  /**
@@ -256,32 +263,45 @@ export class NodeInstance {
256
263
 
257
264
  /**
258
265
  *
259
- * @param {NodeDescription} node
266
+ * @param {NodeDescription} description
260
267
  */
261
- setDescription(node) {
262
- this.description = node;
268
+ setDescription(description) {
269
+ assert.defined(description, 'description');
270
+ assert.isObject(description, 'description');
271
+ assert.equal(description.isNodeDescription, true, 'description.isNodeDescription !== true');
272
+
273
+ if (!this.connections.isEmpty()) {
274
+ throw new Error("Node is has connections, can only change description for unconnected nodes");
275
+ }
263
276
 
264
- node.configureNode(this);
277
+ const old_description = this.description;
278
+
279
+ this.description = description;
280
+
281
+ description.configureNode(this);
265
282
 
266
283
  //generate endpoints
267
- this.endpoints = node.getPorts().map((port, port_index) => {
268
- const endpoint = new NodeInstancePortReference();
284
+ this.endpoints = description.getPorts()
285
+ .map((port, port_index) => {
286
+ const endpoint = new NodeInstancePortReference();
269
287
 
270
- endpoint.id = port_index;
271
- endpoint.port = port;
272
- endpoint.instance = this;
288
+ endpoint.id = port_index;
289
+ endpoint.port = port;
290
+ endpoint.instance = this;
273
291
 
274
- return endpoint;
275
- });
292
+ return endpoint;
293
+ });
276
294
 
277
295
  //clear parameters
278
296
  this.clearParameters();
279
297
 
280
298
  // TODO address parameters in NodeDescription as well
281
299
  //populate parameter defaults
282
- node.parameters.forEach(pd => {
300
+ description.parameters.forEach(pd => {
283
301
  this.parameters[pd.id] = pd.defaultValue;
284
302
  });
303
+
304
+ this.on.descriptionChanged.send2(description, old_description);
285
305
  }
286
306
 
287
307
  /**