@woosh/meep-engine 2.126.71 → 2.126.72

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": "Pure JavaScript game engine. Fully featured and production ready.",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.126.71",
8
+ "version": "2.126.72",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"AssetManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/asset/AssetManager.js"],"names":[],"mappings":"AA8CA;;;;GAIG;AACH;IAgII;;;;;OAKG;IACH,oCAJW,GAAG,EAYb;IA7ID;;;;OAIG;IACH,eAEG;IAEH;;;OAGG;IACH,aAFU,YAAY,gBAAgB,EAAE,YAAY,CAAC,CAER;IAe7C;;;;;;OAMG;IACH,kBAFU,MAAM,CAEY;IAyB5B;;;;OAIG;IACH,iBAAc;IAEd;;;OAGG;IACH,mBAFU,iBAAiB,CAEiB;IAwE5C,gBAQC;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,QAAQ,IAAI,CAAC,CAexB;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAOnB;IAED;;OAEG;IACH,cAEC;IAED,8BAEC;IAED;;;;;;OAMG;IACH,4DAJW,iBAAiB,GAEf,cAAc,CAY1B;IAED;;;;;;;;;OASG;IACH,qFAsCC;IAED;;;;;;;OAOG;IACH,gBAJW,MAAM,QACN,MAAM,GACL,OAAO,CAKlB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,uBAZW,MAAM,QACN,MAAM,gBAEJ,mBAAiB,CA4D7B;IAED;;;;;;;;OAQG;IACH,kBAJW,MAAM,QACN,MAAM,2BAiChB;IA2QD;;;;;OAKG;IACH,sBA2BC;IAGD;;;;OAIG;IACH,uBAHW,MAAM,GACL,OAAO,CAIlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACJ,wBAAY,SAAS,CAMjC;IAaD;;;;OAIG;IACH,+BAHW,MAAM,4CAqBhB;IAED;;;;OAIG;IACH,iCAHW,MAAM,+CAyBhB;IAED;;;;;;OAMG;IACH,6BAJW,MAAM,kCAEJ,QAAQ,OAAO,CAAC,CAU5B;IAED;;;;;OAKG;IACH,0BAJW,MAAM,iEAwChB;IAED;;;OAGG;IACH,uBAFW,MAAM,iBAkBhB;IAED;;;;;;OAMG;IACH,yCAFa,aAAS,IAAI,CAYzB;IAED;;;;;OAKG;IACH,eAJW,MAAM,QACN,MAAM,GACJ,OAAO,CAMnB;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACL,mBAAiB,CAa5B;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACL,gBAAgB,GAAC,SAAS,CAQrC;IAED;;;;;OAKG;IACH,mBAJW,MAAM,QACN,MAAM,QACN,MAAM,QAUhB;IAGL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;;CANpC;4BA19B2B,0CAA0C;iCAOrC,uBAAuB;6BAM3B,mBAAmB;kCAFd,6BAA6B;kCAD7B,wBAAwB;4BAE9B,0BAA0B"}
1
+ {"version":3,"file":"AssetManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/asset/AssetManager.js"],"names":[],"mappings":"AA8CA;;;;GAIG;AACH;IAmII;;;;;OAKG;IACH,oCAJW,GAAG,EAYb;IAhJD;;;;OAIG;IACH,eAEG;IAEH;;;OAGG;IACH,aAFU,YAAY,gBAAgB,EAAE,YAAY,CAAC,CAER;IAe7C;;;;;;OAMG;IACH,kBAFU,MAAM,CAEY;IA4B5B;;;;OAIG;IACH,iBAAc;IAEd;;;OAGG;IACH,mBAFU,iBAAiB,CAEiB;IAwE5C,gBAQC;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,QAAQ,IAAI,CAAC,CAexB;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAOnB;IAED;;OAEG;IACH,cAEC;IAED,8BAEC;I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,14 @@ export class AssetManager {
88
88
  load_concurrency = Infinity;
89
89
 
90
90
  /**
91
- * Registered #loaders
91
+ * Registered asset loaders
92
92
  * @private
93
93
  * @type {Object<AssetLoader>}
94
94
  */
95
95
  #loaders = {};
96
96
 
97
97
  /**
98
- * After asset is loaded, a chain of transforms can be applied to it, these are registered here
98
+ * After an asset is loaded, a chain of transforms can be applied to it, these are registered here
99
99
  * Transformers are executed in the order in which they are added
100
100
  * Identified by asset "type" string
101
101
  * @type {Object<AssetTransformer[]>}
@@ -107,6 +107,9 @@ export class AssetManager {
107
107
  * Named links to specific assets. Useful to later re-mapping assets and having meaningful names for them
108
108
  * @type {Map<string, AssetDescription>}
109
109
  * @private
110
+ * @see resolveAlias
111
+ * @see assignAlias
112
+ * @see promiseByAlias
110
113
  */
111
114
  #aliases = new Map();
112
115
 
@@ -329,6 +332,34 @@ export class AssetManager {
329
332
  return this.request_map.has(assetDescription);
330
333
  }
331
334
 
335
+
336
+ /**
337
+ *
338
+ * @param {string} path
339
+ * @param {string} type
340
+ * @returns {boolean}
341
+ * @see isPending
342
+ */
343
+ isFailed(path, type) {
344
+ const ad = new AssetDescription(path, type);
345
+
346
+ return this.#failures.has(ad);
347
+ }
348
+
349
+ /**
350
+ * Checks if an asset is loaded.
351
+ * If the asset is loaded, calls to {@link tryGet} are guaranteed to succeed.
352
+ *
353
+ * @param {string} path
354
+ * @param {string} type
355
+ * @return {boolean}
356
+ */
357
+ isLoaded(path, type) {
358
+ const ad = new AssetDescription(path, type);
359
+
360
+ return this.assets.has(ad);
361
+ }
362
+
332
363
  /**
333
364
  * Same as {@link insert}, but will register the asset as pending until loader function resolves.
334
365
  *
@@ -424,6 +455,9 @@ export class AssetManager {
424
455
  console.warn(`Another asset under ${asset_descritptor} already exists and will be replaced`);
425
456
  }
426
457
 
458
+ // clear failures
459
+ this.#failures.delete(asset_descritptor);
460
+
427
461
  // check for assets in-flight
428
462
  const pending = this.request_map.get(asset_descritptor);
429
463
  if (pending !== undefined) {
@@ -586,7 +620,7 @@ export class AssetManager {
586
620
 
587
621
  let asset = loaded_asset;
588
622
 
589
- // apply transform chain
623
+ // apply the transform chain
590
624
  const transformers = this.#transformers[type];
591
625
  if (transformers !== undefined) {
592
626
  const transformer_count = transformers.length;
@@ -603,13 +637,16 @@ export class AssetManager {
603
637
  }
604
638
  }
605
639
 
606
- //link asset description
640
+ // link asset description
607
641
  asset.description = assetDescription;
608
642
 
609
- //register asset
643
+ // clear possible failure
644
+ this.#failures.delete(assetDescription);
645
+
646
+ // register asset
610
647
  assets.set(assetDescription, asset);
611
648
 
612
- //clear callbacks etc.
649
+ // clear callbacks etc.
613
650
  this.#handle_asset_resolved(pendingAsset);
614
651
 
615
652
 
@@ -776,9 +813,15 @@ export class AssetManager {
776
813
  }
777
814
 
778
815
  /**
816
+ * Transformer will be applied to all assets of the given type in order of registration.
817
+ *
818
+ * Does not apply retroactively, assets that were already loaded will not be transformed.
819
+ *
779
820
  * @template T
780
821
  * @param {string} type
781
822
  * @param {AssetTransformer<T>} transformer
823
+ * @returns {void}
824
+ * @see removeTransformer
782
825
  */
783
826
  registerTransformer(type, transformer) {
784
827
  let transformers = this.#transformers[type];
@@ -804,6 +847,8 @@ export class AssetManager {
804
847
  * @template T
805
848
  * @param {string} type
806
849
  * @param {AssetTransformer<T>} transformer
850
+ * @returns {boolean} true if removed, false if not found
851
+ * @see registerTransformer
807
852
  */
808
853
  unregisterTransformer(type, transformer) {
809
854
 
@@ -834,7 +879,7 @@ export class AssetManager {
834
879
  * @template T
835
880
  * @param {string} type
836
881
  * @param {AssetLoader<T>} loader
837
- * @returns {Promise<boolean>} true if registered , false otherwise
882
+ * @returns {Promise<boolean>} true if registered, false otherwise
838
883
  */
839
884
  async tryRegisterLoader(type, loader) {
840
885
  if (this.hasLoaderForType(type)) {
@@ -850,7 +895,7 @@ export class AssetManager {
850
895
  * @template T
851
896
  * @param {string} type
852
897
  * @param {AssetLoader<T>} loader
853
- * @throws if a loader is already registered for the given type
898
+ * @throws {Error} if a loader is already registered for the given type
854
899
  */
855
900
  async registerLoader(type, loader) {
856
901
  assert.isString(type, 'type');
@@ -913,8 +958,9 @@ export class AssetManager {
913
958
  }
914
959
 
915
960
  /**
961
+ * Retrieve an asset if it is loaded, returns null if the asset is not loaded.
962
+ * Does not trigger loading if the asset is not loaded.
916
963
  * @template T
917
- * Retrieve an asset if it is loaded, returns null if asset is not loaded.
918
964
  * @param {String} path
919
965
  * @param {String} type
920
966
  * @returns {Asset<T>|null}
@@ -931,18 +977,6 @@ export class AssetManager {
931
977
  }
932
978
  }
933
979
 
934
- /**
935
- *
936
- * @param {string} path
937
- * @param {string} type
938
- * @returns {boolean}
939
- */
940
- isFailed(path, type) {
941
- const ad = new AssetDescription(path, type);
942
-
943
- return this.#failures.has(ad);
944
- }
945
-
946
980
  /**
947
981
  * @template T
948
982
  * @param {string} alias