@woosh/meep-engine 2.43.48 → 2.43.50

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.
@@ -92,6 +92,21 @@ List.prototype.add = function (el) {
92
92
  return this;
93
93
  };
94
94
 
95
+ /**
96
+ *
97
+ * @param {T} el
98
+ * @return {boolean}
99
+ */
100
+ List.prototype.addUnique = function (el) {
101
+ if (this.contains(el)) {
102
+ return false;
103
+ }
104
+
105
+ this.add(el);
106
+
107
+ return true;
108
+ }
109
+
95
110
  /**
96
111
  * Insert element at a specific position into the list
97
112
  * @param {number} index
@@ -9,7 +9,7 @@ export class DataType {
9
9
  this.id = 0;
10
10
 
11
11
  /**
12
- *
12
+ * Name is not guaranteed to be unique, it is intended mainly for debug purposes
13
13
  * @type {string}
14
14
  */
15
15
  this.name = "";
@@ -55,6 +55,9 @@ export class DataType {
55
55
  * @returns {DataType}
56
56
  */
57
57
  static from(id, name) {
58
+ assert.isNonNegativeInteger(id, 'id');
59
+ assert.isString(name, 'name');
60
+
58
61
  const r = new DataType();
59
62
 
60
63
  r.id = id;
@@ -63,3 +66,10 @@ export class DataType {
63
66
  return r;
64
67
  }
65
68
  }
69
+
70
+
71
+ /**
72
+ * @readonly
73
+ * @type {boolean}
74
+ */
75
+ DataType.prototype.isDataType = true;
@@ -243,6 +243,10 @@ export class NodeGraph {
243
243
 
244
244
  this.connections.add(connection);
245
245
 
246
+ // add connection links to the nodes
247
+ sourceNodeInstance.connections.addUnique(connection);
248
+ targetNodeInstance.connections.addUnique(connection);
249
+
246
250
  return id;
247
251
  }
248
252
 
@@ -261,6 +265,10 @@ export class NodeGraph {
261
265
 
262
266
  this.connections.removeOneOf(connection);
263
267
 
268
+ // remove from end-point nodes
269
+ connection.source.instance.connections.removeOneOf(connection);
270
+ connection.target.instance.connections.removeOneOf(connection);
271
+
264
272
  return true;
265
273
  }
266
274
 
@@ -110,6 +110,7 @@ export class NodeDescription {
110
110
  * @returns {NodeParameterDescription}
111
111
  */
112
112
  getParameter(id) {
113
+ assert.isNonNegativeInteger(id, 'id');
113
114
 
114
115
  const paramDescriptors = this.parameters;
115
116
 
@@ -133,6 +134,13 @@ export class NodeDescription {
133
134
  * @param {PortDirection} direction
134
135
  */
135
136
  createPort(type, name, direction) {
137
+ assert.defined(type, 'type');
138
+ assert.notNull(type, 'type');
139
+ assert.equal(type.isDataType, true, 'type.isDataType !== true');
140
+
141
+ assert.defined(direction, 'direction');
142
+ assert.isString(name, 'name');
143
+
136
144
  const port = new Port();
137
145
 
138
146
  const id = pickNewSetId(this.ports);
@@ -154,6 +162,8 @@ export class NodeDescription {
154
162
  * @returns {Port|null}
155
163
  */
156
164
  getPortById(id) {
165
+ assert.isNonNegativeInteger(id, 'id');
166
+
157
167
  for (const port of this.ports) {
158
168
  if (port.id === id) {
159
169
  return port;
@@ -170,6 +180,7 @@ export class NodeDescription {
170
180
  * @return {Port|undefined}
171
181
  */
172
182
  getPortByName(name) {
183
+ assert.isString(name, 'name');
173
184
 
174
185
  for (const port of this.ports) {
175
186
  if (port.name === name) {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.43.48",
8
+ "version": "2.43.50",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",