@woosh/meep-engine 2.110.0 → 2.110.2

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.
@@ -84121,6 +84121,8 @@ class ConcurrentExecutor {
84121
84121
  task.state.set(TaskState.FAILED);
84122
84122
  task.on.failed.send1(reason);
84123
84123
 
84124
+ if (!task.on.failed.hasHandlers()) ;
84125
+
84124
84126
  this.resolveTasks();
84125
84127
 
84126
84128
  this.on.task_completed.send1(task);
@@ -84208,7 +84210,12 @@ class ConcurrentExecutor {
84208
84210
  try {
84209
84211
  executionTime = this.#runTaskForTimeMonitored(task, sliceTimeLeft);
84210
84212
  } catch (e) {
84211
- this.#fail_task(task, e);
84213
+ const error = new Error("Task threw an exception");
84214
+
84215
+ error.cause = e;
84216
+
84217
+ // console.error(`Task threw an exception`, task, e);
84218
+ this.#fail_task(task, error);
84212
84219
  }
84213
84220
 
84214
84221
  this.#cycle_count++;
@@ -97931,15 +97938,21 @@ class ImmutableObjectPool {
97931
97938
  }
97932
97939
  }
97933
97940
 
97941
+ /**
97942
+ * @template T
97943
+ */
97934
97944
  class ObjectPoolFactory {
97935
97945
  /**
97936
- * @template T
97937
97946
  * @param {function():T} creator
97938
97947
  * @param {function(T)} destroyer
97939
97948
  * @param {function(T)} resetter
97940
- * @constructor
97941
97949
  */
97942
- constructor(creator, destroyer, resetter) {
97950
+ constructor(
97951
+ creator,
97952
+ destroyer = noop,
97953
+ resetter = noop
97954
+ ) {
97955
+
97943
97956
  /**
97944
97957
  * @private
97945
97958
  * @type {function(): T}
@@ -97963,7 +97976,6 @@ class ObjectPoolFactory {
97963
97976
  this.pool = [];
97964
97977
 
97965
97978
  /**
97966
- * @private
97967
97979
  * @type {number}
97968
97980
  */
97969
97981
  this.maxSize = 256;
@@ -97981,17 +97993,20 @@ class ObjectPoolFactory {
97981
97993
  this.resetter(oldInstance);
97982
97994
 
97983
97995
  return oldInstance;
97996
+
97984
97997
  } else {
97998
+
97985
97999
  const newInstance = this.creator();
97986
98000
 
97987
98001
  return newInstance;
98002
+
97988
98003
  }
97989
98004
  }
97990
98005
 
97991
98006
  /**
97992
98007
  *
97993
98008
  * @param {T} object
97994
- * @returns {boolean}
98009
+ * @returns {boolean} true if object was added back to the pool, false if pool was full and object was destroyed instead
97995
98010
  */
97996
98011
  release(object) {
97997
98012
 
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.110.0",
8
+ "version": "2.110.2",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,12 +1,13 @@
1
- export class ObjectPoolFactory {
1
+ /**
2
+ * @template T
3
+ */
4
+ export class ObjectPoolFactory<T> {
2
5
  /**
3
- * @template T
4
6
  * @param {function():T} creator
5
7
  * @param {function(T)} destroyer
6
8
  * @param {function(T)} resetter
7
- * @constructor
8
9
  */
9
- constructor(creator: () => T, destroyer: (arg0: T) => any, resetter: (arg0: T) => any);
10
+ constructor(creator: () => T, destroyer?: (arg0: T) => any, resetter?: (arg0: T) => any);
10
11
  /**
11
12
  * @private
12
13
  * @type {function(): T}
@@ -28,10 +29,9 @@ export class ObjectPoolFactory {
28
29
  */
29
30
  private pool;
30
31
  /**
31
- * @private
32
32
  * @type {number}
33
33
  */
34
- private maxSize;
34
+ maxSize: number;
35
35
  /**
36
36
  *
37
37
  * @returns {T}
@@ -40,7 +40,7 @@ export class ObjectPoolFactory {
40
40
  /**
41
41
  *
42
42
  * @param {T} object
43
- * @returns {boolean}
43
+ * @returns {boolean} true if object was added back to the pool, false if pool was full and object was destroyed instead
44
44
  */
45
45
  release(object: T): boolean;
46
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectPoolFactory.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/object/ObjectPoolFactory.js"],"names":[],"mappings":"AAIA;IACI;;;;;;OAMG;IACH,uFA4BC;IA3BG;;;OAGG;IACH,gBAAsB;IACtB;;;OAGG;IACH,kBAA0B;IAC1B;;;OAGG;IACH,iBAAwB;IAExB;;;OAGG;IACH,aAAc;IAEd;;;OAGG;IACH,gBAAkB;IAGtB;;;OAGG;IACH,YAoBC;IAED;;;;OAIG;IACH,oBAFa,OAAO,CAqBnB;CACJ"}
1
+ {"version":3,"file":"ObjectPoolFactory.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/object/ObjectPoolFactory.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IACI;;;;OAIG;IACH,2BAJsB,CAAC,qBACH,CAAC,4BACD,CAAC,UAqCpB;IA1BG;;;OAGG;IACH,gBAAsB;IACtB;;;OAGG;IACH,kBAA0B;IAC1B;;;OAGG;IACH,iBAAwB;IAExB;;;OAGG;IACH,aAAc;IAEd;;OAEG;IACH,SAFU,MAAM,CAEE;IAGtB;;;OAGG;IACH,UAFa,CAAC,CAwBb;IAED;;;;OAIG;IACH,gBAHW,CAAC,GACC,OAAO,CAqBnB;CACJ"}
@@ -2,15 +2,24 @@ import { assert } from "../../assert.js";
2
2
 
3
3
  import { noop } from "../../function/noop.js";
4
4
 
5
+ /**
6
+ * @template T
7
+ */
5
8
  export class ObjectPoolFactory {
6
9
  /**
7
- * @template T
8
10
  * @param {function():T} creator
9
11
  * @param {function(T)} destroyer
10
12
  * @param {function(T)} resetter
11
- * @constructor
12
13
  */
13
- constructor(creator, destroyer, resetter) {
14
+ constructor(
15
+ creator,
16
+ destroyer = noop,
17
+ resetter = noop
18
+ ) {
19
+ assert.isFunction(creator, 'creator');
20
+ assert.isFunction(destroyer, 'destroyer');
21
+ assert.isFunction(resetter, 'resetter');
22
+
14
23
  /**
15
24
  * @private
16
25
  * @type {function(): T}
@@ -34,7 +43,6 @@ export class ObjectPoolFactory {
34
43
  this.pool = [];
35
44
 
36
45
  /**
37
- * @private
38
46
  * @type {number}
39
47
  */
40
48
  this.maxSize = 256;
@@ -55,21 +63,23 @@ export class ObjectPoolFactory {
55
63
  assert.defined(oldInstance, 'oldInstance');
56
64
 
57
65
  return oldInstance;
66
+
58
67
  } else {
59
- const newInstance = this.creator();
60
68
 
69
+ const newInstance = this.creator();
61
70
 
62
71
  assert.notNull(newInstance, 'newInstance');
63
72
  assert.defined(newInstance, 'newInstance');
64
73
 
65
74
  return newInstance;
75
+
66
76
  }
67
77
  }
68
78
 
69
79
  /**
70
80
  *
71
81
  * @param {T} object
72
- * @returns {boolean}
82
+ * @returns {boolean} true if object was added back to the pool, false if pool was full and object was destroyed instead
73
83
  */
74
84
  release(object) {
75
85
  assert.notNull(object, 'object');
@@ -1 +1 @@
1
- {"version":3,"file":"ConcurrentExecutor.d.ts","sourceRoot":"","sources":["../../../../../src/core/process/executor/ConcurrentExecutor.js"],"names":[],"mappings":";AAgBA;;GAEG;AACH;IAaI;;;;;OAKG;IACH,wBAJW,MAAM,aACN,MAAM,EAwChB;IApCG;;;OAGG;IACH,WAFU,MAAM,CAEU;IAC1B;;;OAGG;IACH,UAFU,MAAM,CAEQ;IAExB;;;OAGG;IACH,iBAFU,MAAM,CAES;IAEzB;;;OAGG;IACH,YAFU,MAAM,CAEI;IAEpB;;;;MAIC;IAED,cAAiB;IAEjB;;;OAGG;IACH,QAFU,MAAM,GAAC,gBAAgB,CAES;IAG9C;;;OAGG;IACH,qCAmEC;IAED;;;OAGG;IACH,oCAaC;IAED;;;;OAIG;IACH,wBAFY,OAAO,CAwBlB;IAED;;;OAGG;IACH,sBAGC;IAED;;;OAGG;IACH,eAFW,MAAM,QAMhB;IAED;;;;OAIG;IACH,kBAkCC;IAED;;OAEG;IACH,qBA8BC;IAED;;;;OAIG;IACH,sBAFa,OAAO,CAYnB;IA+KD;;;OAGG;IACH,aAQC;IAED,0BAMC;;CACJ;;;;mBAvfkB,+BAA+B;wBA2fxC,MAAM"}
1
+ {"version":3,"file":"ConcurrentExecutor.d.ts","sourceRoot":"","sources":["../../../../../src/core/process/executor/ConcurrentExecutor.js"],"names":[],"mappings":";AAgBA;;GAEG;AACH;IAaI;;;;;OAKG;IACH,wBAJW,MAAM,aACN,MAAM,EAwChB;IApCG;;;OAGG;IACH,WAFU,MAAM,CAEU;IAC1B;;;OAGG;IACH,UAFU,MAAM,CAEQ;IAExB;;;OAGG;IACH,iBAFU,MAAM,CAES;IAEzB;;;OAGG;IACH,YAFU,MAAM,CAEI;IAEpB;;;;MAIC;IAED,cAAiB;IAEjB;;;OAGG;IACH,QAFU,MAAM,GAAC,gBAAgB,CAES;IAG9C;;;OAGG;IACH,qCAmEC;IAED;;;OAGG;IACH,oCAaC;IAED;;;;OAIG;IACH,wBAFY,OAAO,CAwBlB;IAED;;;OAGG;IACH,sBAGC;IAED;;;OAGG;IACH,eAFW,MAAM,QAMhB;IAED;;;;OAIG;IACH,kBAkCC;IAED;;OAEG;IACH,qBA8BC;IAED;;;;OAIG;IACH,sBAFa,OAAO,CAYnB;IAwLD;;;OAGG;IACH,aAQC;IAED,0BAMC;;CACJ;;;;mBAhgBkB,+BAA+B;wBAogBxC,MAAM"}
@@ -370,6 +370,11 @@ class ConcurrentExecutor {
370
370
  task.state.set(TaskState.FAILED);
371
371
  task.on.failed.send1(reason);
372
372
 
373
+ if (!task.on.failed.hasHandlers()) {
374
+ // no one is watching for task failure
375
+ console.warn(`Task '${task.name}' failed.`, reason);
376
+ }
377
+
373
378
  this.resolveTasks();
374
379
 
375
380
  this.on.task_completed.send1(task);
@@ -458,8 +463,12 @@ class ConcurrentExecutor {
458
463
  try {
459
464
  executionTime = this.#runTaskForTimeMonitored(task, sliceTimeLeft);
460
465
  } catch (e) {
461
- console.error(`Task threw an exception`, task, e);
462
- this.#fail_task(task, e);
466
+ const error = new Error("Task threw an exception");
467
+
468
+ error.cause = e;
469
+
470
+ // console.error(`Task threw an exception`, task, e);
471
+ this.#fail_task(task, error);
463
472
  }
464
473
 
465
474
  this.#cycle_count++;
@@ -16,6 +16,7 @@ export class IKProblem {
16
16
  terrain: Terrain;
17
17
  }
18
18
  export namespace IKProblem {
19
- let pool: any;
19
+ let pool: ObjectPoolFactory<IKProblem>;
20
20
  }
21
+ import { ObjectPoolFactory } from "../../../core/model/object/ObjectPoolFactory.js";
21
22
  //# sourceMappingURL=IKProblem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IKProblem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/ik/IKProblem.js"],"names":[],"mappings":"AAGA;IAEI;;;OAGG;IACH,yBAAkB;IAClB;;;OAGG;IACH,mBAAgB;IAChB;;;OAGG;IACH,iBAAe;CAElB"}
1
+ {"version":3,"file":"IKProblem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/ik/IKProblem.js"],"names":[],"mappings":"AAGA;IAEI;;;OAGG;IACH,yBAAkB;IAClB;;;OAGG;IACH,mBAAgB;IAChB;;;OAGG;IACH,iBAAe;CAElB;;cAIS,kBAAkB,SAAS,CAAC;;kCAxBJ,iDAAiD"}