melonjs 15.1.2 → 15.1.4

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.
Files changed (145) hide show
  1. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  2. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  5. package/dist/melonjs.mjs/application/application.js +1 -1
  6. package/dist/melonjs.mjs/application/header.js +1 -1
  7. package/dist/melonjs.mjs/application/resize.js +1 -1
  8. package/dist/melonjs.mjs/application/settings.js +1 -1
  9. package/dist/melonjs.mjs/audio/audio.js +3 -3
  10. package/dist/melonjs.mjs/camera/camera2d.js +1 -1
  11. package/dist/melonjs.mjs/const.js +2 -2
  12. package/dist/melonjs.mjs/entity/entity.js +1 -1
  13. package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
  14. package/dist/melonjs.mjs/geometries/line.js +1 -1
  15. package/dist/melonjs.mjs/geometries/path2d.js +1 -1
  16. package/dist/melonjs.mjs/geometries/point.js +1 -1
  17. package/dist/melonjs.mjs/geometries/poly.js +1 -1
  18. package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
  19. package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
  20. package/dist/melonjs.mjs/index.js +2 -2
  21. package/dist/melonjs.mjs/input/gamepad.js +1 -1
  22. package/dist/melonjs.mjs/input/input.js +1 -1
  23. package/dist/melonjs.mjs/input/keyboard.js +1 -1
  24. package/dist/melonjs.mjs/input/pointer.js +1 -1
  25. package/dist/melonjs.mjs/input/pointerevent.js +1 -1
  26. package/dist/melonjs.mjs/lang/console.js +1 -1
  27. package/dist/melonjs.mjs/lang/deprecated.js +1 -1
  28. package/dist/melonjs.mjs/level/level.js +1 -1
  29. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  30. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -1
  31. package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
  32. package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
  33. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +1 -1
  34. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
  35. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
  36. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +1 -1
  37. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  38. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  39. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  40. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  41. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
  42. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  43. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  44. package/dist/melonjs.mjs/loader/cache.js +1 -1
  45. package/dist/melonjs.mjs/loader/loader.js +52 -67
  46. package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
  47. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  48. package/dist/melonjs.mjs/loader/parser.js +1 -1
  49. package/dist/melonjs.mjs/loader/settings.js +1 -1
  50. package/dist/melonjs.mjs/math/color.js +1 -1
  51. package/dist/melonjs.mjs/math/math.js +1 -1
  52. package/dist/melonjs.mjs/math/matrix2.js +1 -1
  53. package/dist/melonjs.mjs/math/matrix3.js +1 -1
  54. package/dist/melonjs.mjs/math/observable_vector2.js +1 -1
  55. package/dist/melonjs.mjs/math/observable_vector3.js +1 -1
  56. package/dist/melonjs.mjs/math/vector2.js +1 -1
  57. package/dist/melonjs.mjs/math/vector3.js +1 -1
  58. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
  59. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
  60. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  61. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
  62. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  63. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  64. package/dist/melonjs.mjs/particles/emitter.js +1 -1
  65. package/dist/melonjs.mjs/particles/particle.js +1 -1
  66. package/dist/melonjs.mjs/particles/settings.js +1 -1
  67. package/dist/melonjs.mjs/physics/body.js +1 -1
  68. package/dist/melonjs.mjs/physics/bounds.js +1 -1
  69. package/dist/melonjs.mjs/physics/collision.js +1 -1
  70. package/dist/melonjs.mjs/physics/detector.js +1 -1
  71. package/dist/melonjs.mjs/physics/quadtree.js +1 -1
  72. package/dist/melonjs.mjs/physics/response.js +1 -1
  73. package/dist/melonjs.mjs/physics/sat.js +1 -1
  74. package/dist/melonjs.mjs/physics/world.js +1 -1
  75. package/dist/melonjs.mjs/plugin/plugin.js +3 -3
  76. package/dist/melonjs.mjs/renderable/collectable.js +1 -1
  77. package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
  78. package/dist/melonjs.mjs/renderable/container.js +1 -1
  79. package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
  80. package/dist/melonjs.mjs/renderable/imagelayer.js +1 -1
  81. package/dist/melonjs.mjs/renderable/light2d.js +1 -1
  82. package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
  83. package/dist/melonjs.mjs/renderable/renderable.js +1 -1
  84. package/dist/melonjs.mjs/renderable/sprite.js +1 -1
  85. package/dist/melonjs.mjs/renderable/trigger.js +1 -1
  86. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
  87. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
  88. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
  89. package/dist/melonjs.mjs/state/stage.js +1 -1
  90. package/dist/melonjs.mjs/state/state.js +1 -1
  91. package/dist/melonjs.mjs/system/device.js +1 -1
  92. package/dist/melonjs.mjs/system/dom.js +1 -1
  93. package/dist/melonjs.mjs/system/event.js +1 -1
  94. package/dist/melonjs.mjs/system/platform.js +1 -1
  95. package/dist/melonjs.mjs/system/pooling.js +1 -1
  96. package/dist/melonjs.mjs/system/save.js +1 -1
  97. package/dist/melonjs.mjs/system/timer.js +1 -1
  98. package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
  99. package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
  100. package/dist/melonjs.mjs/text/glyph.js +1 -1
  101. package/dist/melonjs.mjs/text/text.js +1 -1
  102. package/dist/melonjs.mjs/text/textmetrics.js +1 -1
  103. package/dist/melonjs.mjs/text/textstyle.js +1 -1
  104. package/dist/melonjs.mjs/tweens/easing.js +1 -1
  105. package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
  106. package/dist/melonjs.mjs/tweens/tween.js +1 -1
  107. package/dist/melonjs.mjs/utils/agent.js +1 -1
  108. package/dist/melonjs.mjs/utils/array.js +1 -1
  109. package/dist/melonjs.mjs/utils/file.js +1 -1
  110. package/dist/melonjs.mjs/utils/function.js +1 -1
  111. package/dist/melonjs.mjs/utils/string.js +1 -1
  112. package/dist/melonjs.mjs/utils/utils.js +1 -1
  113. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +1 -1
  114. package/dist/melonjs.mjs/video/renderer.js +1 -1
  115. package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
  116. package/dist/melonjs.mjs/video/texture/cache.js +1 -1
  117. package/dist/melonjs.mjs/video/texture/canvas_texture.js +1 -1
  118. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  119. package/dist/melonjs.mjs/video/video.js +10 -3
  120. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
  121. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +1 -1
  122. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +1 -1
  123. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +2 -2
  124. package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
  125. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  126. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  127. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  128. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  129. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  130. package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
  131. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  132. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  133. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  134. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1 -1
  135. package/dist/melonjs.module.js +60 -75
  136. package/dist/types/audio/audio.d.ts +2 -2
  137. package/dist/types/const.d.ts +2 -2
  138. package/dist/types/loader/loader.d.ts +49 -55
  139. package/dist/types/video/video.d.ts +1 -1
  140. package/package.json +4 -4
  141. package/src/audio/audio.js +2 -2
  142. package/src/const.js +1 -1
  143. package/src/loader/loader.js +51 -66
  144. package/src/video/video.js +1 -1
  145. package/src/video/webgl/compositors/quad_compositor.js +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.2
2
+ * melonJS Game Engine - v15.1.4
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -13758,7 +13758,7 @@ function hasAudio() {
13758
13758
  * enable audio output <br>
13759
13759
  * only useful if audio supported and previously disabled through
13760
13760
  * @function audio.enable
13761
- * @see audio#disable
13761
+ * @see audio.disable
13762
13762
  */
13763
13763
  function enable() {
13764
13764
  unmuteAll();
@@ -14010,7 +14010,7 @@ function playTrack(sound_name, volume) {
14010
14010
  /**
14011
14011
  * stop the current audio track
14012
14012
  * @function audio.stopTrack
14013
- * @see audio#playTrack
14013
+ * @see audio.playTrack
14014
14014
  * @example
14015
14015
  * // play a awesome music
14016
14016
  * me.audio.playTrack("awesome_music");
@@ -14218,7 +14218,7 @@ const WEBGL$1 = 1;
14218
14218
  /**
14219
14219
  * constant to auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
14220
14220
  * @static
14221
- * @type (number)
14221
+ * @type {number}
14222
14222
  * @see Application
14223
14223
  */
14224
14224
  const AUTO$1 = 2;
@@ -14374,7 +14374,7 @@ function createCanvas(width, height, returnOffscreenCanvas = false) {
14374
14374
  throw new Error("width or height was zero, Canvas could not be initialized !");
14375
14375
  }
14376
14376
 
14377
- if (undefined === true && returnOffscreenCanvas === true) {
14377
+ if (offscreenCanvas === true && returnOffscreenCanvas === true) {
14378
14378
  _canvas = new globalThis.OffscreenCanvas(0, 0);
14379
14379
  // stubbing style for compatibility,
14380
14380
  // as OffscreenCanvas is detached from the DOM
@@ -26672,9 +26672,9 @@ function preloadJavascript(data, onload, onerror) {
26672
26672
 
26673
26673
  /**
26674
26674
  * onload callback
26675
- * @name onload
26676
26675
  * @default undefined
26677
26676
  * @memberof loader
26677
+ * @type {function}
26678
26678
  * @example
26679
26679
  * // set a callback when everything is loaded
26680
26680
  * me.loader.onload = this.loaded.bind(this);
@@ -26685,9 +26685,9 @@ let onload;
26685
26685
  * onProgress callback<br>
26686
26686
  * each time a resource is loaded, the loader will fire the specified function,
26687
26687
  * giving the actual progress [0 ... 1], as argument, and an object describing the resource loaded
26688
- * @name onProgress
26689
26688
  * @default undefined
26690
26689
  * @memberof loader
26690
+ * @type {function}
26691
26691
  * @example
26692
26692
  * // set a callback for progress notification
26693
26693
  * me.loader.onProgress = this.updateProgress.bind(this);
@@ -26756,19 +26756,24 @@ function onLoadingError(res) {
26756
26756
  }
26757
26757
 
26758
26758
  /**
26759
- * set all the specified game resources to be preloaded.
26760
- * @name preload
26759
+ * an asset definition to be used with the loader
26760
+ * @typedef {object} loader.Asset
26761
+ * @property {string} name - name of the asset
26762
+ * @property {string} type - the type of the asset : "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
26763
+ * @property {string} src - path and/or file name of the resource (for audio assets only the path is required)
26764
+ * @property {boolean} [stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
26765
+ * @see loader.preload
26766
+ * @see loader.load
26767
+ */
26768
+
26769
+ /**
26770
+ * set all the specified game assets to be preloaded.
26761
26771
  * @memberof loader
26762
- * @public
26763
- * @param {object[]} res
26764
- * @param {string} res.name - internal name of the resource
26765
- * @param {string} res.type - "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
26766
- * @param {string} res.src - path and/or file name of the resource (for audio assets only the path is required)
26767
- * @param {boolean} [res.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
26768
- * @param {Function} [onload=loader.onload] - function to be called when all resources are loaded
26772
+ * @param {loader.Asset[]} assets - list of assets to load
26773
+ * @param {Function} [onloadcb=loader.onload] - function to be called when all resources are loaded
26769
26774
  * @param {boolean} [switchToLoadState=true] - automatically switch to the loading screen
26770
26775
  * @example
26771
- * game_resources = [
26776
+ * game.assets = [
26772
26777
  * // PNG tileset
26773
26778
  * {name: "tileset-platformer", type: "image", src: "data/map/tileset.png"},
26774
26779
  * // PNG packed texture
@@ -26798,15 +26803,15 @@ function onLoadingError(res) {
26798
26803
  * ];
26799
26804
  * ...
26800
26805
  * // set all resources to be loaded
26801
- * me.loader.preload(game.resources, () => this.loaded());
26806
+ * me.loader.preload(game.assets, () => this.loaded());
26802
26807
  */
26803
- function preload(res, onloadcb, switchToLoadState = true) {
26808
+ function preload(assets, onloadcb, switchToLoadState = true) {
26804
26809
  // parse the resources
26805
- for (let i = 0; i < res.length; i++) {
26810
+ for (let i = 0; i < assets.length; i++) {
26806
26811
  resourceCount += load(
26807
- res[i],
26808
- onResourceLoaded.bind(this, res[i]),
26809
- onLoadingError.bind(this, res[i])
26812
+ assets[i],
26813
+ onResourceLoaded.bind(this, assets[i]),
26814
+ onLoadingError.bind(this, assets[i])
26810
26815
  );
26811
26816
  }
26812
26817
  // set the onload callback if defined
@@ -26824,15 +26829,9 @@ function preload(res, onloadcb, switchToLoadState = true) {
26824
26829
  }
26825
26830
 
26826
26831
  /**
26827
- * Load a single resource (to be used if you need to load additional resource during the game)
26828
- * @name load
26832
+ * Load a single asset (to be used if you need to load additional asset(s) during the game)
26829
26833
  * @memberof loader
26830
- * @public
26831
- * @param {object} res
26832
- * @param {string} res.name - internal name of the resource
26833
- * @param {string} res.type - "audio", binary", "image", "json", "tmx", "tsx"
26834
- * @param {string} res.src - path and/or file name of the resource (for audio assets only the path is required)
26835
- * @param {boolean} [res.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
26834
+ * @param {loader.Asset} asset
26836
26835
  * @param {Function} [onload] - function to be called when the resource is loaded
26837
26836
  * @param {Function} [onerror] - function to be called in case of error
26838
26837
  * @returns {number} the amount of corresponding resource to be preloaded
@@ -26850,83 +26849,79 @@ function preload(res, onloadcb, switchToLoadState = true) {
26850
26849
  * me.audio.play("bgmusic");
26851
26850
  * });
26852
26851
  */
26853
- function load(res, onload, onerror) {
26852
+ function load(asset, onload, onerror) {
26854
26853
  // transform the url if necessary
26855
- if (typeof (baseURL[res.type]) !== "undefined") {
26856
- res.src = baseURL[res.type] + res.src;
26854
+ if (typeof (baseURL[asset.type]) !== "undefined") {
26855
+ asset.src = baseURL[asset.type] + asset.src;
26857
26856
  }
26858
26857
  // check ressource type
26859
- switch (res.type) {
26858
+ switch (asset.type) {
26860
26859
  case "binary":
26861
26860
  // reuse the preloadImage fn
26862
- preloadBinary.call(this, res, onload, onerror);
26861
+ preloadBinary.call(this, asset, onload, onerror);
26863
26862
  return 1;
26864
26863
 
26865
26864
  case "image":
26866
26865
  // reuse the preloadImage fn
26867
- preloadImage.call(this, res, onload, onerror);
26866
+ preloadImage.call(this, asset, onload, onerror);
26868
26867
  return 1;
26869
26868
 
26870
26869
  case "json":
26871
- preloadJSON.call(this, res, onload, onerror);
26870
+ preloadJSON.call(this, asset, onload, onerror);
26872
26871
  return 1;
26873
26872
 
26874
26873
  case "js":
26875
- preloadJavascript.call(this, res, onload, onerror);
26874
+ preloadJavascript.call(this, asset, onload, onerror);
26876
26875
  return 1;
26877
26876
 
26878
26877
  case "tmx":
26879
26878
  case "tsx":
26880
- preloadTMX.call(this, res, onload, onerror);
26879
+ preloadTMX.call(this, asset, onload, onerror);
26881
26880
  return 1;
26882
26881
 
26883
26882
  case "audio":
26884
- load$1(res, !!res.stream, onload, onerror);
26883
+ load$1(asset, !!asset.stream, onload, onerror);
26885
26884
  return 1;
26886
26885
 
26887
26886
  case "fontface":
26888
- preloadFontFace.call(this, res, onload, onerror);
26887
+ preloadFontFace.call(this, asset, onload, onerror);
26889
26888
  return 1;
26890
26889
 
26891
26890
  default:
26892
- throw new Error("load : unknown or invalid resource type : " + res.type);
26891
+ throw new Error("load : unknown or invalid resource type : " + asset.type);
26893
26892
  }
26894
26893
  }
26895
26894
 
26896
26895
  /**
26897
- * unload specified resource to free memory
26898
- * @name unload
26896
+ * unload the specified asset to free memory
26899
26897
  * @memberof loader
26900
- * @public
26901
- * @param {object} res
26902
- * @param {string} res.name - internal name of the resource
26903
- * @param {string} res.type - "audio", binary", "image", "json", "tmx", "tsx"
26898
+ * @param {loader.Asset} asset
26904
26899
  * @returns {boolean} true if unloaded
26905
26900
  * @example me.loader.unload({name: "avatar", type:"image"});
26906
26901
  */
26907
- function unload(res) {
26908
- switch (res.type) {
26902
+ function unload(asset) {
26903
+ switch (asset.type) {
26909
26904
  case "binary":
26910
- if (!(res.name in binList)) {
26905
+ if (!(asset.name in binList)) {
26911
26906
  return false;
26912
26907
  }
26913
26908
 
26914
- delete binList[res.name];
26909
+ delete binList[asset.name];
26915
26910
  return true;
26916
26911
 
26917
26912
  case "image":
26918
- if (!(res.name in imgList)) {
26913
+ if (!(asset.name in imgList)) {
26919
26914
  return false;
26920
26915
  }
26921
- delete imgList[res.name];
26916
+ delete imgList[asset.name];
26922
26917
  return true;
26923
26918
 
26924
26919
  case "json":
26925
- if (!(res.name in jsonList)) {
26920
+ if (!(asset.name in jsonList)) {
26926
26921
  return false;
26927
26922
  }
26928
26923
 
26929
- delete jsonList[res.name];
26924
+ delete jsonList[asset.name];
26930
26925
  return true;
26931
26926
 
26932
26927
  case "js":
@@ -26939,26 +26934,24 @@ function unload(res) {
26939
26934
 
26940
26935
  case "tmx":
26941
26936
  case "tsx":
26942
- if (!(res.name in tmxList)) {
26937
+ if (!(asset.name in tmxList)) {
26943
26938
  return false;
26944
26939
  }
26945
26940
 
26946
- delete tmxList[res.name];
26941
+ delete tmxList[asset.name];
26947
26942
  return true;
26948
26943
 
26949
26944
  case "audio":
26950
- return unload$1(res.name);
26945
+ return unload$1(asset.name);
26951
26946
 
26952
26947
  default:
26953
- throw new Error("unload : unknown or invalid resource type : " + res.type);
26948
+ throw new Error("unload : unknown or invalid resource type : " + asset.type);
26954
26949
  }
26955
26950
  }
26956
26951
 
26957
26952
  /**
26958
26953
  * unload all resources to free memory
26959
- * @name unloadAll
26960
26954
  * @memberof loader
26961
- * @public
26962
26955
  * @example me.loader.unloadAll();
26963
26956
  */
26964
26957
  function unloadAll() {
@@ -27010,9 +27003,7 @@ function unloadAll() {
27010
27003
 
27011
27004
  /**
27012
27005
  * return the specified TMX/TSX object
27013
- * @name getTMX
27014
27006
  * @memberof loader
27015
- * @public
27016
27007
  * @param {string} elt - name of the tmx/tsx element ("map1");
27017
27008
  * @returns {object} requested element or null if not found
27018
27009
  */
@@ -27027,9 +27018,7 @@ function getTMX(elt) {
27027
27018
 
27028
27019
  /**
27029
27020
  * return the specified Binary object
27030
- * @name getBinary
27031
27021
  * @memberof loader
27032
- * @public
27033
27022
  * @param {string} elt - name of the binary object ("ymTrack");
27034
27023
  * @returns {object} requested element or null if not found
27035
27024
  */
@@ -27044,9 +27033,7 @@ function getBinary(elt) {
27044
27033
 
27045
27034
  /**
27046
27035
  * return the specified Image Object
27047
- * @name getImage
27048
27036
  * @memberof loader
27049
- * @public
27050
27037
  * @param {string} image - name of the Image element ("tileset-platformer");
27051
27038
  * @returns {HTMLImageElement} requested element or null if not found
27052
27039
  */
@@ -27062,9 +27049,7 @@ function getImage(image) {
27062
27049
 
27063
27050
  /**
27064
27051
  * return the specified JSON Object
27065
- * @name getJSON
27066
27052
  * @memberof loader
27067
- * @public
27068
27053
  * @param {string} elt - name of the json file to load
27069
27054
  * @returns {object}
27070
27055
  */
@@ -31149,7 +31134,7 @@ let V_ARRAY = [
31149
31134
  if (pixels === null || typeof pixels.byteLength !== "undefined") {
31150
31135
  // if pixels is undefined, or if it's Uint8Array/Float32Array TypedArray
31151
31136
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, 0, gl.RGBA, gl.UNSIGNED_BYTE, pixels, 0);
31152
- } else if (pixels instanceof OffscreenCanvas) {
31137
+ } else if (typeof globalThis.OffscreenCanvas !== "undefined" && pixels instanceof globalThis.OffscreenCanvas) {
31153
31138
  // convert to ImageBitmap first (else Safari 16.4 and higher will throw an TypeError exception)
31154
31139
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, pixels.transferToImageBitmap());
31155
31140
  } else {
@@ -38007,10 +37992,10 @@ class BasePlugin {
38007
37992
  * this can be overridden by the plugin
38008
37993
  * @public
38009
37994
  * @type {string}
38010
- * @default "15.1.2"
37995
+ * @default "15.1.4"
38011
37996
  * @name plugin.Base#version
38012
37997
  */
38013
- this.version = "15.1.2";
37998
+ this.version = "15.1.4";
38014
37999
  }
38015
38000
  }
38016
38001
 
@@ -38238,7 +38223,7 @@ Renderer.prototype.getScreenContext = function() {
38238
38223
  * @name version
38239
38224
  * @type {string}
38240
38225
  */
38241
- const version = "15.1.2";
38226
+ const version = "15.1.4";
38242
38227
 
38243
38228
  /**
38244
38229
  * a flag indicating that melonJS is fully initialized
@@ -35,7 +35,7 @@ export function hasAudio(): boolean;
35
35
  * enable audio output <br>
36
36
  * only useful if audio supported and previously disabled through
37
37
  * @function audio.enable
38
- * @see audio#disable
38
+ * @see audio.disable
39
39
  */
40
40
  export function enable(): void;
41
41
  /**
@@ -159,7 +159,7 @@ export function playTrack(sound_name: string, volume?: number | undefined): numb
159
159
  /**
160
160
  * stop the current audio track
161
161
  * @function audio.stopTrack
162
- * @see audio#playTrack
162
+ * @see audio.playTrack
163
163
  * @example
164
164
  * // play a awesome music
165
165
  * me.audio.playTrack("awesome_music");
@@ -15,7 +15,7 @@ export const WEBGL: number;
15
15
  /**
16
16
  * constant to auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
17
17
  * @static
18
- * @type (number)
18
+ * @type {number}
19
19
  * @see Application
20
20
  */
21
- export const AUTO: any;
21
+ export const AUTO: number;
@@ -1,17 +1,21 @@
1
1
  /**
2
- * set all the specified game resources to be preloaded.
3
- * @name preload
2
+ * an asset definition to be used with the loader
3
+ * @typedef {object} loader.Asset
4
+ * @property {string} name - name of the asset
5
+ * @property {string} type - the type of the asset : "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
6
+ * @property {string} src - path and/or file name of the resource (for audio assets only the path is required)
7
+ * @property {boolean} [stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
8
+ * @see loader.preload
9
+ * @see loader.load
10
+ */
11
+ /**
12
+ * set all the specified game assets to be preloaded.
4
13
  * @memberof loader
5
- * @public
6
- * @param {object[]} res
7
- * @param {string} res.name - internal name of the resource
8
- * @param {string} res.type - "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
9
- * @param {string} res.src - path and/or file name of the resource (for audio assets only the path is required)
10
- * @param {boolean} [res.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
11
- * @param {Function} [onload=loader.onload] - function to be called when all resources are loaded
14
+ * @param {loader.Asset[]} assets - list of assets to load
15
+ * @param {Function} [onloadcb=loader.onload] - function to be called when all resources are loaded
12
16
  * @param {boolean} [switchToLoadState=true] - automatically switch to the loading screen
13
17
  * @example
14
- * game_resources = [
18
+ * game.assets = [
15
19
  * // PNG tileset
16
20
  * {name: "tileset-platformer", type: "image", src: "data/map/tileset.png"},
17
21
  * // PNG packed texture
@@ -41,24 +45,13 @@
41
45
  * ];
42
46
  * ...
43
47
  * // set all resources to be loaded
44
- * me.loader.preload(game.resources, () => this.loaded());
48
+ * me.loader.preload(game.assets, () => this.loaded());
45
49
  */
46
- export function preload(res: {
47
- name: string;
48
- type: string;
49
- src: string;
50
- stream?: boolean;
51
- }, onloadcb: any, switchToLoadState?: boolean | undefined): void;
50
+ export function preload(assets: loader.Asset[], onloadcb?: Function | undefined, switchToLoadState?: boolean | undefined): void;
52
51
  /**
53
- * Load a single resource (to be used if you need to load additional resource during the game)
54
- * @name load
52
+ * Load a single asset (to be used if you need to load additional asset(s) during the game)
55
53
  * @memberof loader
56
- * @public
57
- * @param {object} res
58
- * @param {string} res.name - internal name of the resource
59
- * @param {string} res.type - "audio", binary", "image", "json", "tmx", "tsx"
60
- * @param {string} res.src - path and/or file name of the resource (for audio assets only the path is required)
61
- * @param {boolean} [res.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
54
+ * @param {loader.Asset} asset
62
55
  * @param {Function} [onload] - function to be called when the resource is loaded
63
56
  * @param {Function} [onerror] - function to be called in case of error
64
57
  * @returns {number} the amount of corresponding resource to be preloaded
@@ -76,67 +69,45 @@ export function preload(res: {
76
69
  * me.audio.play("bgmusic");
77
70
  * });
78
71
  */
79
- export function load(res: {
80
- name: string;
81
- type: string;
82
- src: string;
83
- stream?: boolean | undefined;
84
- }, onload?: Function | undefined, onerror?: Function | undefined): number;
72
+ export function load(asset: loader.Asset, onload?: Function | undefined, onerror?: Function | undefined): number;
85
73
  /**
86
- * unload specified resource to free memory
87
- * @name unload
74
+ * unload the specified asset to free memory
88
75
  * @memberof loader
89
- * @public
90
- * @param {object} res
91
- * @param {string} res.name - internal name of the resource
92
- * @param {string} res.type - "audio", binary", "image", "json", "tmx", "tsx"
76
+ * @param {loader.Asset} asset
93
77
  * @returns {boolean} true if unloaded
94
78
  * @example me.loader.unload({name: "avatar", type:"image"});
95
79
  */
96
- export function unload(res: {
97
- name: string;
98
- type: string;
99
- }): boolean;
80
+ export function unload(asset: loader.Asset): boolean;
100
81
  /**
101
82
  * unload all resources to free memory
102
- * @name unloadAll
103
83
  * @memberof loader
104
- * @public
105
84
  * @example me.loader.unloadAll();
106
85
  */
107
86
  export function unloadAll(): void;
108
87
  /**
109
88
  * return the specified TMX/TSX object
110
- * @name getTMX
111
89
  * @memberof loader
112
- * @public
113
90
  * @param {string} elt - name of the tmx/tsx element ("map1");
114
91
  * @returns {object} requested element or null if not found
115
92
  */
116
93
  export function getTMX(elt: string): object;
117
94
  /**
118
95
  * return the specified Binary object
119
- * @name getBinary
120
96
  * @memberof loader
121
- * @public
122
97
  * @param {string} elt - name of the binary object ("ymTrack");
123
98
  * @returns {object} requested element or null if not found
124
99
  */
125
100
  export function getBinary(elt: string): object;
126
101
  /**
127
102
  * return the specified Image Object
128
- * @name getImage
129
103
  * @memberof loader
130
- * @public
131
104
  * @param {string} image - name of the Image element ("tileset-platformer");
132
105
  * @returns {HTMLImageElement} requested element or null if not found
133
106
  */
134
107
  export function getImage(image: string): HTMLImageElement;
135
108
  /**
136
109
  * return the specified JSON Object
137
- * @name getJSON
138
110
  * @memberof loader
139
- * @public
140
111
  * @param {string} elt - name of the json file to load
141
112
  * @returns {object}
142
113
  */
@@ -144,23 +115,46 @@ export function getJSON(elt: string): object;
144
115
  export * from "./settings.js";
145
116
  /**
146
117
  * onload callback
147
- * @name onload
148
118
  * @default undefined
149
119
  * @memberof loader
120
+ * @type {function}
150
121
  * @example
151
122
  * // set a callback when everything is loaded
152
123
  * me.loader.onload = this.loaded.bind(this);
153
124
  */
154
- export let onload: any;
125
+ export let onload: Function;
155
126
  /**
156
127
  * onProgress callback<br>
157
128
  * each time a resource is loaded, the loader will fire the specified function,
158
129
  * giving the actual progress [0 ... 1], as argument, and an object describing the resource loaded
159
- * @name onProgress
160
130
  * @default undefined
161
131
  * @memberof loader
132
+ * @type {function}
162
133
  * @example
163
134
  * // set a callback for progress notification
164
135
  * me.loader.onProgress = this.updateProgress.bind(this);
165
136
  */
166
- export let onProgress: any;
137
+ export let onProgress: Function;
138
+ export namespace loader {
139
+ /**
140
+ * an asset definition to be used with the loader
141
+ */
142
+ type Asset = {
143
+ /**
144
+ * - name of the asset
145
+ */
146
+ name: string;
147
+ /**
148
+ * - the type of the asset : "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
149
+ */
150
+ type: string;
151
+ /**
152
+ * - path and/or file name of the resource (for audio assets only the path is required)
153
+ */
154
+ src: string;
155
+ /**
156
+ * - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
157
+ */
158
+ stream?: boolean | undefined;
159
+ };
160
+ }
@@ -84,7 +84,7 @@ export const WEBGL: number;
84
84
  * @memberof video
85
85
  * @static
86
86
  */
87
- export const AUTO: any;
87
+ export const AUTO: number;
88
88
  /**
89
89
  * A reference to the active Canvas or WebGL active renderer renderer
90
90
  * @memberof video
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "melonjs",
3
- "version": "15.1.2",
3
+ "version": "15.1.4",
4
4
  "description": "melonJS Game Engine",
5
5
  "homepage": "http://www.melonjs.org/",
6
6
  "type": "module",
@@ -72,13 +72,13 @@
72
72
  "cross-env": "^7.0.3",
73
73
  "del-cli": "^5.0.0",
74
74
  "eslint": "^8.39.0",
75
- "eslint-plugin-jsdoc": "^43.0.7",
75
+ "eslint-plugin-jsdoc": "^43.1.1",
76
76
  "expect": "^29.5.0",
77
77
  "expect-mocha-image-snapshot": "^3.0.13",
78
- "fastify": "^4.15.0",
78
+ "fastify": "^4.16.3",
79
79
  "mocha": "^10.2.0",
80
80
  "npm-self-link": "^1.1.7",
81
- "puppeteer": "^19.10.1",
81
+ "puppeteer": "^19.11.1",
82
82
  "rollup": "^3.21.0",
83
83
  "rollup-plugin-bundle-size": "^1.0.3",
84
84
  "rollup-plugin-string": "^3.0.0",
@@ -123,7 +123,7 @@ export function hasAudio() {
123
123
  * enable audio output <br>
124
124
  * only useful if audio supported and previously disabled through
125
125
  * @function audio.enable
126
- * @see audio#disable
126
+ * @see audio.disable
127
127
  */
128
128
  export function enable() {
129
129
  unmuteAll();
@@ -375,7 +375,7 @@ export function playTrack(sound_name, volume) {
375
375
  /**
376
376
  * stop the current audio track
377
377
  * @function audio.stopTrack
378
- * @see audio#playTrack
378
+ * @see audio.playTrack
379
379
  * @example
380
380
  * // play a awesome music
381
381
  * me.audio.playTrack("awesome_music");
package/src/const.js CHANGED
@@ -17,7 +17,7 @@ export const WEBGL = 1;
17
17
  /**
18
18
  * constant to auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
19
19
  * @static
20
- * @type (number)
20
+ * @type {number}
21
21
  * @see Application
22
22
  */
23
23
  export const AUTO = 2;