melonjs 15.1.6 → 15.2.1

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 (153) hide show
  1. package/README.md +6 -6
  2. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  5. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  6. package/dist/melonjs.mjs/application/application.js +3 -3
  7. package/dist/melonjs.mjs/application/header.js +1 -1
  8. package/dist/melonjs.mjs/application/resize.js +1 -1
  9. package/dist/melonjs.mjs/application/settings.js +1 -1
  10. package/dist/melonjs.mjs/audio/audio.js +1 -1
  11. package/dist/melonjs.mjs/camera/camera2d.js +1 -1
  12. package/dist/melonjs.mjs/const.js +1 -1
  13. package/dist/melonjs.mjs/entity/entity.js +1 -1
  14. package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
  15. package/dist/melonjs.mjs/geometries/line.js +1 -1
  16. package/dist/melonjs.mjs/geometries/path2d.js +1 -1
  17. package/dist/melonjs.mjs/geometries/point.js +1 -1
  18. package/dist/melonjs.mjs/geometries/poly.js +1 -1
  19. package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
  20. package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
  21. package/dist/melonjs.mjs/index.js +12 -6
  22. package/dist/melonjs.mjs/input/gamepad.js +1 -1
  23. package/dist/melonjs.mjs/input/input.js +1 -1
  24. package/dist/melonjs.mjs/input/keyboard.js +1 -1
  25. package/dist/melonjs.mjs/input/pointer.js +1 -1
  26. package/dist/melonjs.mjs/input/pointerevent.js +1 -1
  27. package/dist/melonjs.mjs/lang/console.js +1 -1
  28. package/dist/melonjs.mjs/lang/deprecated.js +1 -1
  29. package/dist/melonjs.mjs/level/level.js +5 -4
  30. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  31. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -1
  32. package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
  33. package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
  34. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
  35. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
  36. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
  37. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +127 -95
  38. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  39. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  40. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  41. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  42. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
  43. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  44. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  45. package/dist/melonjs.mjs/loader/cache.js +1 -1
  46. package/dist/melonjs.mjs/loader/loader.js +1 -1
  47. package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
  48. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  49. package/dist/melonjs.mjs/loader/parser.js +1 -1
  50. package/dist/melonjs.mjs/loader/settings.js +1 -1
  51. package/dist/melonjs.mjs/math/color.js +1 -1
  52. package/dist/melonjs.mjs/math/math.js +1 -1
  53. package/dist/melonjs.mjs/math/matrix2.js +1 -1
  54. package/dist/melonjs.mjs/math/matrix3.js +1 -1
  55. package/dist/melonjs.mjs/math/observable_vector2.js +1 -1
  56. package/dist/melonjs.mjs/math/observable_vector3.js +1 -1
  57. package/dist/melonjs.mjs/math/vector2.js +1 -1
  58. package/dist/melonjs.mjs/math/vector3.js +1 -1
  59. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
  60. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
  61. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  62. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
  63. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  64. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  65. package/dist/melonjs.mjs/particles/emitter.js +1 -1
  66. package/dist/melonjs.mjs/particles/particle.js +1 -1
  67. package/dist/melonjs.mjs/particles/settings.js +1 -1
  68. package/dist/melonjs.mjs/physics/body.js +1 -1
  69. package/dist/melonjs.mjs/physics/bounds.js +1 -1
  70. package/dist/melonjs.mjs/physics/collision.js +1 -1
  71. package/dist/melonjs.mjs/physics/detector.js +1 -1
  72. package/dist/melonjs.mjs/physics/quadtree.js +1 -1
  73. package/dist/melonjs.mjs/physics/response.js +1 -1
  74. package/dist/melonjs.mjs/physics/sat.js +1 -1
  75. package/dist/melonjs.mjs/physics/world.js +1 -1
  76. package/dist/melonjs.mjs/plugin/plugin.js +106 -108
  77. package/dist/melonjs.mjs/renderable/collectable.js +1 -1
  78. package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
  79. package/dist/melonjs.mjs/renderable/container.js +7 -6
  80. package/dist/melonjs.mjs/renderable/draggable.js +1 -1
  81. package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
  82. package/dist/melonjs.mjs/renderable/imagelayer.js +1 -1
  83. package/dist/melonjs.mjs/renderable/light2d.js +1 -1
  84. package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
  85. package/dist/melonjs.mjs/renderable/renderable.js +1 -1
  86. package/dist/melonjs.mjs/renderable/sprite.js +1 -1
  87. package/dist/melonjs.mjs/renderable/trigger.js +1 -1
  88. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
  89. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
  90. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
  91. package/dist/melonjs.mjs/state/stage.js +1 -1
  92. package/dist/melonjs.mjs/state/state.js +1 -1
  93. package/dist/melonjs.mjs/system/device.js +1 -1
  94. package/dist/melonjs.mjs/system/dom.js +1 -1
  95. package/dist/melonjs.mjs/system/event.js +1 -1
  96. package/dist/melonjs.mjs/system/platform.js +1 -1
  97. package/dist/melonjs.mjs/system/pooling.js +1 -1
  98. package/dist/melonjs.mjs/system/save.js +1 -1
  99. package/dist/melonjs.mjs/system/timer.js +4 -4
  100. package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
  101. package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
  102. package/dist/melonjs.mjs/text/glyph.js +1 -1
  103. package/dist/melonjs.mjs/text/text.js +1 -1
  104. package/dist/melonjs.mjs/text/textmetrics.js +1 -1
  105. package/dist/melonjs.mjs/text/textstyle.js +1 -1
  106. package/dist/melonjs.mjs/tweens/easing.js +1 -1
  107. package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
  108. package/dist/melonjs.mjs/tweens/tween.js +1 -1
  109. package/dist/melonjs.mjs/utils/agent.js +1 -1
  110. package/dist/melonjs.mjs/utils/array.js +1 -1
  111. package/dist/melonjs.mjs/utils/file.js +1 -1
  112. package/dist/melonjs.mjs/utils/function.js +1 -1
  113. package/dist/melonjs.mjs/utils/string.js +1 -1
  114. package/dist/melonjs.mjs/utils/utils.js +105 -111
  115. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +1 -1
  116. package/dist/melonjs.mjs/video/renderer.js +1 -1
  117. package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
  118. package/dist/melonjs.mjs/video/texture/cache.js +1 -1
  119. package/dist/melonjs.mjs/video/texture/canvas_texture.js +1 -1
  120. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  121. package/dist/melonjs.mjs/video/video.js +6 -32
  122. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
  123. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +1 -1
  124. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +1 -1
  125. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +1 -1
  126. package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
  127. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  128. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  129. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  130. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  131. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  132. package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
  133. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  134. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  135. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  136. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1 -1
  137. package/dist/melonjs.module.js +595 -570
  138. package/dist/types/index.d.ts +5 -4
  139. package/dist/types/level/tiled/TMXUtils.d.ts +19 -36
  140. package/dist/types/plugin/plugin.d.ts +60 -5
  141. package/dist/types/utils/utils.d.ts +56 -17
  142. package/dist/types/video/video.d.ts +1 -21
  143. package/package.json +5 -5
  144. package/src/application/application.js +2 -2
  145. package/src/index.js +5 -2
  146. package/src/level/level.js +4 -3
  147. package/src/level/tiled/TMXTileMap.js +2 -2
  148. package/src/level/tiled/TMXUtils.js +126 -94
  149. package/src/plugin/plugin.js +103 -105
  150. package/src/renderable/container.js +6 -5
  151. package/src/system/timer.js +3 -3
  152. package/src/utils/utils.js +102 -111
  153. package/src/video/video.js +6 -8
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.6
2
+ * melonJS Game Engine - v15.2.1
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -8096,7 +8096,7 @@ function weightedRandom(arr) {
8096
8096
  return arr[weightedRandom$1(0, arr.length)];
8097
8097
  }
8098
8098
 
8099
- var arrayUtils = {
8099
+ var array$1 = {
8100
8100
  __proto__: null,
8101
8101
  random: random,
8102
8102
  remove: remove,
@@ -9002,201 +9002,6 @@ let collision = {
9002
9002
  rayCast(line, result) { return game.world.detector.rayCast(line, result); }
9003
9003
  };
9004
9004
 
9005
- /**
9006
- * a collection of string utility functions
9007
- * @namespace utils.string
9008
- */
9009
-
9010
- /**
9011
- * converts the first character of the given string to uppercase
9012
- * @public
9013
- * @memberof utils.string
9014
- * @name capitalize
9015
- * @param {string} str - the string to be capitalized
9016
- * @returns {string} the capitalized string
9017
- */
9018
- function capitalize(str) {
9019
- return str.charAt(0).toUpperCase() + str.slice(1);
9020
- }
9021
-
9022
- /**
9023
- * returns true if the given string contains a numeric integer or float value
9024
- * @public
9025
- * @memberof utils.string
9026
- * @name isNumeric
9027
- * @param {string} str - the string to be tested
9028
- * @returns {boolean} true if string contains only digits
9029
- */
9030
- function isNumeric(str) {
9031
- if (typeof str === "string") {
9032
- str = str.trim();
9033
- }
9034
- return !isNaN(str) && /^[+-]?(\d+(\.\d+)?|\.\d+)$/.test(str);
9035
- }
9036
-
9037
- /**
9038
- * returns true if the given string contains a true or false
9039
- * @public
9040
- * @memberof utils.string
9041
- * @name isBoolean
9042
- * @param {string} str - the string to be tested
9043
- * @returns {boolean} true if the string is either true or false
9044
- */
9045
- function isBoolean(str) {
9046
- const trimmed = str.trim();
9047
- return (trimmed === "true") || (trimmed === "false");
9048
- }
9049
-
9050
- /**
9051
- * convert a string to the corresponding hexadecimal value
9052
- * @public
9053
- * @memberof utils.string
9054
- * @name toHex
9055
- * @param {string} str - the string to be converted
9056
- * @returns {string} the converted hexadecimal value
9057
- */
9058
- function toHex(str) {
9059
- let res = "", c = 0;
9060
- while (c < str.length) {
9061
- res += str.charCodeAt(c++).toString(16);
9062
- }
9063
- return res;
9064
- }
9065
-
9066
- /**
9067
- * returns true if the given string is a data url in the `data:[<mediatype>][;base64],<data>` format.
9068
- * (this will not test the validity of the Data or Base64 encoding)
9069
- * @public
9070
- * @memberof utils.string
9071
- * @name isDataUrl
9072
- * @param {string} str - the string (url) to be tested
9073
- * @returns {boolean} true if the string is a data url
9074
- */
9075
- function isDataUrl(str) {
9076
- return /^data:(.+);base64,(.+)$/.test(str);
9077
- }
9078
-
9079
- var stringUtils = {
9080
- __proto__: null,
9081
- capitalize: capitalize,
9082
- isBoolean: isBoolean,
9083
- isDataUrl: isDataUrl,
9084
- isNumeric: isNumeric,
9085
- toHex: toHex
9086
- };
9087
-
9088
- /**
9089
- * a collection of utility functons to ease porting between different user agents.
9090
- * @namespace utils.agent
9091
- */
9092
-
9093
- /**
9094
- * Known agent vendors
9095
- * @ignore
9096
- */
9097
- const vendors = [ "ms", "MS", "moz", "webkit", "o" ];
9098
-
9099
- /**
9100
- * Get a vendor-prefixed property
9101
- * @public
9102
- * @name prefixed
9103
- * @param {string} name - Property name
9104
- * @param {object} [obj=globalThis] - Object or element reference to access
9105
- * @returns {string} Value of property
9106
- * @memberof utils.agent
9107
- */
9108
- function prefixed(name, obj) {
9109
- obj = obj || globalThis;
9110
- if (name in obj) {
9111
- return obj[name];
9112
- }
9113
-
9114
- let uc_name = capitalize(name);
9115
-
9116
- let result;
9117
- vendors.some((vendor) => {
9118
- let name = vendor + uc_name;
9119
- return (result = (name in obj) ? obj[name] : undefined);
9120
- });
9121
- return result;
9122
- }
9123
-
9124
- /**
9125
- * Set a vendor-prefixed property
9126
- * @public
9127
- * @name setPrefixed
9128
- * @param {string} name - Property name
9129
- * @param {string} value - Property value
9130
- * @param {object} [obj=globalThis] - Object or element reference to access
9131
- * @returns {boolean} true if one of the vendor-prefixed property was found
9132
- * @memberof utils.agent
9133
- */
9134
- function setPrefixed(name, value, obj) {
9135
- obj = obj || globalThis;
9136
- if (name in obj) {
9137
- obj[name] = value;
9138
- return;
9139
- }
9140
-
9141
- let uc_name = capitalize(name);
9142
-
9143
- vendors.some((vendor) => {
9144
- let name = vendor + uc_name;
9145
- if (name in obj) {
9146
- obj[name] = value;
9147
- return true;
9148
- }
9149
- });
9150
-
9151
- return false;
9152
- }
9153
-
9154
- var agentUtils = {
9155
- __proto__: null,
9156
- prefixed: prefixed,
9157
- setPrefixed: setPrefixed
9158
- };
9159
-
9160
- /**
9161
- * a collection of file utility functions
9162
- * @namespace utils.file
9163
- */
9164
-
9165
- // regexp to deal with file name & path
9166
- const REMOVE_PATH = /^.*(\\|\/|\:)/;
9167
- const REMOVE_EXT = /\.[^\.]*$/;
9168
-
9169
-
9170
- /**
9171
- * return the base name of the file without path info
9172
- * @public
9173
- * @memberof utils.file
9174
- * @name getBasename
9175
- * @param {string} path- - path containing the filename
9176
- * @returns {string} the base name without path information.
9177
- */
9178
- function getBasename(path) {
9179
- return path.replace(REMOVE_PATH, "").replace(REMOVE_EXT, "");
9180
- }
9181
-
9182
- /**
9183
- * return the extension of the file in the given path
9184
- * @public
9185
- * @memberof utils.file
9186
- * @name getExtension
9187
- * @param {string} path- - path containing the filename
9188
- * @returns {string} filename extension.
9189
- */
9190
- function getExtension(path) {
9191
- return path.substring(path.lastIndexOf(".") + 1, path.length);
9192
- }
9193
-
9194
- var fileUtils = {
9195
- __proto__: null,
9196
- getBasename: getBasename,
9197
- getExtension: getExtension
9198
- };
9199
-
9200
9005
  /**
9201
9006
  * a collection of utility functions
9202
9007
  * @namespace utils.function
@@ -9259,141 +9064,12 @@ function throttle(fn, delay, no_trailing) {
9259
9064
  };
9260
9065
  }
9261
9066
 
9262
- var fnUtils = {
9067
+ var _function = {
9263
9068
  __proto__: null,
9264
9069
  defer: defer,
9265
9070
  throttle: throttle
9266
9071
  };
9267
9072
 
9268
- /**
9269
- * a collection of utility functions
9270
- * @namespace utils
9271
- */
9272
-
9273
- // guid default value
9274
- let GUID_base = "";
9275
- let GUID_index = 0;
9276
-
9277
- let utils = {
9278
-
9279
- agent : agentUtils,
9280
- array : arrayUtils,
9281
- file : fileUtils,
9282
- string : stringUtils,
9283
- function : fnUtils,
9284
-
9285
- /**
9286
- * Compare two version strings
9287
- * @public
9288
- * @memberof utils
9289
- * @name checkVersion
9290
- * @param {string} first - First version string to compare
9291
- * @param {string} second - second version string to compare
9292
- * @returns {number} comparison result <br>&lt; 0 : first &lt; second<br>
9293
- * 0 : first == second<br>
9294
- * &gt; 0 : first &gt; second
9295
- * @example
9296
- * if (me.utils.checkVersion("7.0.0") > 0) {
9297
- * console.error(
9298
- * "melonJS is too old. Expected: 7.0.0, Got: 6.3.0"
9299
- * );
9300
- * }
9301
- */
9302
- checkVersion : function (first, second) {
9303
- let a = first.split(".");
9304
- let b = second.split(".");
9305
- let len = Math.min(a.length, b.length);
9306
- let result = 0;
9307
-
9308
- for (let i = 0; i < len; i++) {
9309
- if ((result = +a[i] - +b[i])) {
9310
- break;
9311
- }
9312
- }
9313
-
9314
- return result ? result : a.length - b.length;
9315
- },
9316
-
9317
- /**
9318
- * parse the fragment (hash) from a URL and returns them into
9319
- * @public
9320
- * @memberof utils
9321
- * @name getUriFragment
9322
- * @param {string} [url=document.location] - an optional params string or URL containing fragment (hash) params to be parsed
9323
- * @returns {object} an object representing the deserialized params string.
9324
- * @property {boolean} [hitbox=false] draw the hitbox in the debug panel (if enabled)
9325
- * @property {boolean} [velocity=false] draw the entities velocity in the debug panel (if enabled)
9326
- * @property {boolean} [quadtree=false] draw the quadtree in the debug panel (if enabled)
9327
- * @property {boolean} [webgl=false] force the renderer to WebGL
9328
- * @property {boolean} [debug=false] display the debug panel (if preloaded)
9329
- * @property {string} [debugToggleKey="s"] show/hide the debug panel (if preloaded)
9330
- * @example
9331
- * // http://www.example.com/index.html#debug&hitbox=true&mytag=value
9332
- * let UriFragment = me.utils.getUriFragment();
9333
- * console.log(UriFragment["mytag"]); //> "value"
9334
- */
9335
- getUriFragment : function (url) {
9336
- let hash = {};
9337
-
9338
- if (typeof url === "undefined") {
9339
- if (typeof globalThis.document !== "undefined") {
9340
- let location = globalThis.document.location;
9341
-
9342
- if (location && location.hash) {
9343
- url = location.hash;
9344
- } else {
9345
- // No "document.location" exist for Wechat mini game platform.
9346
- return hash;
9347
- }
9348
- } else {
9349
- // "document" undefined on node.js
9350
- return hash;
9351
- }
9352
- } else {
9353
- // never cache if a url is passed as parameter
9354
- let index = url.indexOf("#");
9355
- if (index !== -1) {
9356
- url = url.slice(index, url.length);
9357
- } else {
9358
- return hash;
9359
- }
9360
- }
9361
-
9362
- // parse the url
9363
- url.slice(1).split("&").filter((value) => value !== "").forEach((value) => {
9364
- let kv = value.split("=");
9365
- let k = kv.shift();
9366
- let v = kv.join("=");
9367
- hash[k] = v || true;
9368
- });
9369
-
9370
- return hash;
9371
- },
9372
-
9373
- /**
9374
- * reset the GUID Base Name
9375
- * the idea here being to have a unique ID
9376
- * per level / object
9377
- * @ignore
9378
- */
9379
- resetGUID : function (base, index = 0) {
9380
- // also ensure it's only 8bit ASCII characters
9381
- GUID_base = toHex(base.toString().toUpperCase());
9382
- GUID_index = index;
9383
- },
9384
-
9385
- /**
9386
- * create and return a very simple GUID
9387
- * Game Unique ID
9388
- * @ignore
9389
- */
9390
- createGUID : function (index = 1) {
9391
- // to cover the case of undefined id for groups
9392
- GUID_index += index;
9393
- return GUID_base + "-" + (index || GUID_index);
9394
- }
9395
- };
9396
-
9397
9073
  var eventemitter3$1 = {exports: {}};
9398
9074
 
9399
9075
  var eventemitter3 = eventemitter3$1.exports;
@@ -13642,6 +13318,89 @@ function setBaseURL(type, url) {
13642
13318
  }
13643
13319
  }
13644
13320
 
13321
+ /**
13322
+ * a collection of string utility functions
13323
+ * @namespace utils.string
13324
+ */
13325
+
13326
+ /**
13327
+ * converts the first character of the given string to uppercase
13328
+ * @public
13329
+ * @memberof utils.string
13330
+ * @name capitalize
13331
+ * @param {string} str - the string to be capitalized
13332
+ * @returns {string} the capitalized string
13333
+ */
13334
+ function capitalize(str) {
13335
+ return str.charAt(0).toUpperCase() + str.slice(1);
13336
+ }
13337
+
13338
+ /**
13339
+ * returns true if the given string contains a numeric integer or float value
13340
+ * @public
13341
+ * @memberof utils.string
13342
+ * @name isNumeric
13343
+ * @param {string} str - the string to be tested
13344
+ * @returns {boolean} true if string contains only digits
13345
+ */
13346
+ function isNumeric(str) {
13347
+ if (typeof str === "string") {
13348
+ str = str.trim();
13349
+ }
13350
+ return !isNaN(str) && /^[+-]?(\d+(\.\d+)?|\.\d+)$/.test(str);
13351
+ }
13352
+
13353
+ /**
13354
+ * returns true if the given string contains a true or false
13355
+ * @public
13356
+ * @memberof utils.string
13357
+ * @name isBoolean
13358
+ * @param {string} str - the string to be tested
13359
+ * @returns {boolean} true if the string is either true or false
13360
+ */
13361
+ function isBoolean(str) {
13362
+ const trimmed = str.trim();
13363
+ return (trimmed === "true") || (trimmed === "false");
13364
+ }
13365
+
13366
+ /**
13367
+ * convert a string to the corresponding hexadecimal value
13368
+ * @public
13369
+ * @memberof utils.string
13370
+ * @name toHex
13371
+ * @param {string} str - the string to be converted
13372
+ * @returns {string} the converted hexadecimal value
13373
+ */
13374
+ function toHex(str) {
13375
+ let res = "", c = 0;
13376
+ while (c < str.length) {
13377
+ res += str.charCodeAt(c++).toString(16);
13378
+ }
13379
+ return res;
13380
+ }
13381
+
13382
+ /**
13383
+ * returns true if the given string is a data url in the `data:[<mediatype>][;base64],<data>` format.
13384
+ * (this will not test the validity of the Data or Base64 encoding)
13385
+ * @public
13386
+ * @memberof utils.string
13387
+ * @name isDataUrl
13388
+ * @param {string} str - the string (url) to be tested
13389
+ * @returns {boolean} true if the string is a data url
13390
+ */
13391
+ function isDataUrl(str) {
13392
+ return /^data:(.+);base64,(.+)$/.test(str);
13393
+ }
13394
+
13395
+ var string$1 = {
13396
+ __proto__: null,
13397
+ capitalize: capitalize,
13398
+ isBoolean: isBoolean,
13399
+ isDataUrl: isDataUrl,
13400
+ isNumeric: isNumeric,
13401
+ toHex: toHex
13402
+ };
13403
+
13645
13404
  // external import
13646
13405
 
13647
13406
  /**
@@ -14210,7 +13969,7 @@ var audio = {
14210
13969
  * @static
14211
13970
  * @see Application
14212
13971
  */
14213
- const CANVAS$1 = 0;
13972
+ const CANVAS = 0;
14214
13973
 
14215
13974
  /**
14216
13975
  * constant to select select the WebGL renderer
@@ -14218,7 +13977,7 @@ const CANVAS$1 = 0;
14218
13977
  * @static
14219
13978
  * @see Application
14220
13979
  */
14221
- const WEBGL$1 = 1;
13980
+ const WEBGL = 1;
14222
13981
 
14223
13982
  /**
14224
13983
  * constant to auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
@@ -14226,33 +13985,7 @@ const WEBGL$1 = 1;
14226
13985
  * @type {number}
14227
13986
  * @see Application
14228
13987
  */
14229
- const AUTO$1 = 2;
14230
-
14231
- /**
14232
- * @namespace video
14233
- */
14234
-
14235
-
14236
- /**
14237
- * Select the HTML5 Canvas renderer
14238
- * @memberof video
14239
- * @static
14240
- */
14241
- const CANVAS = CANVAS$1;
14242
-
14243
- /**
14244
- * Select the WebGL renderer
14245
- * @memberof video
14246
- * @static
14247
- */
14248
- const WEBGL = WEBGL$1;
14249
-
14250
- /**
14251
- * Auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
14252
- * @memberof video
14253
- * @static
14254
- */
14255
- const AUTO = AUTO$1;
13988
+ const AUTO = 2;
14256
13989
 
14257
13990
  /**
14258
13991
  * A reference to the active Canvas or WebGL active renderer renderer
@@ -14322,7 +14055,7 @@ function init(width, height, options) {
14322
14055
  //add a channel for the onresize/onorientationchange event
14323
14056
  globalThis.addEventListener(
14324
14057
  "resize",
14325
- utils.function.throttle(
14058
+ throttle(
14326
14059
  (e) => {
14327
14060
  emit(WINDOW_ONRESIZE, e);
14328
14061
  }, 100
@@ -14354,7 +14087,7 @@ function init(width, height, options) {
14354
14087
  }
14355
14088
 
14356
14089
  // Automatically update relative canvas position on scroll
14357
- globalThis.addEventListener("scroll", utils.function.throttle((e) => {
14090
+ globalThis.addEventListener("scroll", throttle((e) => {
14358
14091
  emit(WINDOW_ONSCROLL, e);
14359
14092
  }, 100), false);
14360
14093
 
@@ -14561,6 +14294,78 @@ let save = {
14561
14294
  }
14562
14295
  };
14563
14296
 
14297
+ /**
14298
+ * a collection of utility functons to ease porting between different user agents.
14299
+ * @namespace utils.agent
14300
+ */
14301
+
14302
+ /**
14303
+ * Known agent vendors
14304
+ * @ignore
14305
+ */
14306
+ const vendors = [ "ms", "MS", "moz", "webkit", "o" ];
14307
+
14308
+ /**
14309
+ * Get a vendor-prefixed property
14310
+ * @public
14311
+ * @name prefixed
14312
+ * @param {string} name - Property name
14313
+ * @param {object} [obj=globalThis] - Object or element reference to access
14314
+ * @returns {string} Value of property
14315
+ * @memberof utils.agent
14316
+ */
14317
+ function prefixed(name, obj) {
14318
+ obj = obj || globalThis;
14319
+ if (name in obj) {
14320
+ return obj[name];
14321
+ }
14322
+
14323
+ let uc_name = capitalize(name);
14324
+
14325
+ let result;
14326
+ vendors.some((vendor) => {
14327
+ let name = vendor + uc_name;
14328
+ return (result = (name in obj) ? obj[name] : undefined);
14329
+ });
14330
+ return result;
14331
+ }
14332
+
14333
+ /**
14334
+ * Set a vendor-prefixed property
14335
+ * @public
14336
+ * @name setPrefixed
14337
+ * @param {string} name - Property name
14338
+ * @param {string} value - Property value
14339
+ * @param {object} [obj=globalThis] - Object or element reference to access
14340
+ * @returns {boolean} true if one of the vendor-prefixed property was found
14341
+ * @memberof utils.agent
14342
+ */
14343
+ function setPrefixed(name, value, obj) {
14344
+ obj = obj || globalThis;
14345
+ if (name in obj) {
14346
+ obj[name] = value;
14347
+ return;
14348
+ }
14349
+
14350
+ let uc_name = capitalize(name);
14351
+
14352
+ vendors.some((vendor) => {
14353
+ let name = vendor + uc_name;
14354
+ if (name in obj) {
14355
+ obj[name] = value;
14356
+ return true;
14357
+ }
14358
+ });
14359
+
14360
+ return false;
14361
+ }
14362
+
14363
+ var agent$1 = {
14364
+ __proto__: null,
14365
+ prefixed: prefixed,
14366
+ setPrefixed: setPrefixed
14367
+ };
14368
+
14564
14369
  /**
14565
14370
  * The device platform type
14566
14371
  * @namespace platform
@@ -19500,6 +19305,46 @@ let default_settings = {
19500
19305
  }
19501
19306
  }
19502
19307
 
19308
+ /**
19309
+ * a collection of file utility functions
19310
+ * @namespace utils.file
19311
+ */
19312
+
19313
+ // regexp to deal with file name & path
19314
+ const REMOVE_PATH = /^.*(\\|\/|\:)/;
19315
+ const REMOVE_EXT = /\.[^\.]*$/;
19316
+
19317
+
19318
+ /**
19319
+ * return the base name of the file without path info
19320
+ * @public
19321
+ * @memberof utils.file
19322
+ * @name getBasename
19323
+ * @param {string} path- - path containing the filename
19324
+ * @returns {string} the base name without path information.
19325
+ */
19326
+ function getBasename(path) {
19327
+ return path.replace(REMOVE_PATH, "").replace(REMOVE_EXT, "");
19328
+ }
19329
+
19330
+ /**
19331
+ * return the extension of the file in the given path
19332
+ * @public
19333
+ * @memberof utils.file
19334
+ * @name getExtension
19335
+ * @param {string} path- - path containing the filename
19336
+ * @returns {string} filename extension.
19337
+ */
19338
+ function getExtension(path) {
19339
+ return path.substring(path.lastIndexOf(".") + 1, path.length);
19340
+ }
19341
+
19342
+ var file$1 = {
19343
+ __proto__: null,
19344
+ getBasename: getBasename,
19345
+ getExtension: getExtension
19346
+ };
19347
+
19503
19348
  /**
19504
19349
  * where all preloaded content is cached
19505
19350
  */
@@ -19516,6 +19361,139 @@ let binList = {};
19516
19361
  // contains all the JSON files
19517
19362
  let jsonList = {};
19518
19363
 
19364
+ /**
19365
+ * a collection of utility functions
19366
+ * @namespace utils
19367
+ */
19368
+
19369
+ // guid default value
19370
+ let GUID_base = "";
19371
+ let GUID_index = 0;
19372
+
19373
+ /**
19374
+ * Compare two version strings
19375
+ * @public
19376
+ * @memberof utils
19377
+ * @name checkVersion
19378
+ * @param {string} first - First version string to compare
19379
+ * @param {string} second - second version string to compare
19380
+ * @returns {number} comparison result <br>&lt; 0 : first &lt; second<br>
19381
+ * 0 : first == second<br>
19382
+ * &gt; 0 : first &gt; second
19383
+ * @example
19384
+ * if (me.utils.checkVersion("7.0.0") > 0) {
19385
+ * console.error(
19386
+ * "melonJS is too old. Expected: 7.0.0, Got: 6.3.0"
19387
+ * );
19388
+ * }
19389
+ */
19390
+ function checkVersion(first, second) {
19391
+ let a = first.split(".");
19392
+ let b = second.split(".");
19393
+ let len = Math.min(a.length, b.length);
19394
+ let result = 0;
19395
+
19396
+ for (let i = 0; i < len; i++) {
19397
+ if ((result = +a[i] - +b[i])) {
19398
+ break;
19399
+ }
19400
+ }
19401
+
19402
+ return result ? result : a.length - b.length;
19403
+ }
19404
+
19405
+ /**
19406
+ * parse the fragment (hash) from a URL and returns them into
19407
+ * @public
19408
+ * @memberof utils
19409
+ * @name getUriFragment
19410
+ * @param {string} [url=document.location] - an optional params string or URL containing fragment (hash) params to be parsed
19411
+ * @returns {object} an object representing the deserialized params string.
19412
+ * @property {boolean} [hitbox=false] draw the hitbox in the debug panel (if enabled)
19413
+ * @property {boolean} [velocity=false] draw the entities velocity in the debug panel (if enabled)
19414
+ * @property {boolean} [quadtree=false] draw the quadtree in the debug panel (if enabled)
19415
+ * @property {boolean} [webgl=false] force the renderer to WebGL
19416
+ * @property {boolean} [debug=false] display the debug panel (if preloaded)
19417
+ * @property {string} [debugToggleKey="s"] show/hide the debug panel (if preloaded)
19418
+ * @example
19419
+ * // http://www.example.com/index.html#debug&hitbox=true&mytag=value
19420
+ * let UriFragment = me.utils.getUriFragment();
19421
+ * console.log(UriFragment["mytag"]); //> "value"
19422
+ */
19423
+ function getUriFragment(url) {
19424
+ let hash = {};
19425
+
19426
+ if (typeof url === "undefined") {
19427
+ if (typeof globalThis.document !== "undefined") {
19428
+ let location = globalThis.document.location;
19429
+
19430
+ if (location && location.hash) {
19431
+ url = location.hash;
19432
+ } else {
19433
+ // No "document.location" exist for Wechat mini game platform.
19434
+ return hash;
19435
+ }
19436
+ } else {
19437
+ // "document" undefined on node.js
19438
+ return hash;
19439
+ }
19440
+ } else {
19441
+ // never cache if a url is passed as parameter
19442
+ let index = url.indexOf("#");
19443
+ if (index !== -1) {
19444
+ url = url.slice(index, url.length);
19445
+ } else {
19446
+ return hash;
19447
+ }
19448
+ }
19449
+
19450
+ // parse the url
19451
+ url.slice(1).split("&").filter((value) => value !== "").forEach((value) => {
19452
+ let kv = value.split("=");
19453
+ let k = kv.shift();
19454
+ let v = kv.join("=");
19455
+ hash[k] = v || true;
19456
+ });
19457
+
19458
+ return hash;
19459
+ }
19460
+
19461
+ /**
19462
+ * reset the GUID Base Name
19463
+ * the idea here being to have a unique ID
19464
+ * per level / object
19465
+ * @ignore
19466
+ */
19467
+ function resetGUID(base, index = 0) {
19468
+ // also ensure it's only 8bit ASCII characters
19469
+ GUID_base = toHex(base.toString().toUpperCase());
19470
+ GUID_index = index;
19471
+ }
19472
+
19473
+ /**
19474
+ * create and return a very simple GUID
19475
+ * Game Unique ID
19476
+ * @ignore
19477
+ */
19478
+ function createGUID(index = 1) {
19479
+ // to cover the case of undefined id for groups
19480
+ GUID_index += index;
19481
+ return GUID_base + "-" + (index || GUID_index);
19482
+ }
19483
+
19484
+ var utils = {
19485
+ __proto__: null,
19486
+ agent: agent$1,
19487
+ array: array$1,
19488
+ checkVersion: checkVersion,
19489
+ createGUID: createGUID,
19490
+ file: file$1,
19491
+ function: _function,
19492
+ getUriFragment: getUriFragment,
19493
+ resetGUID: resetGUID,
19494
+ string: string$1
19495
+ };
19496
+
19519
19497
  /**
19520
19498
  * @classdesc
19521
19499
  * a TMX Tile Set Object
@@ -19870,6 +19848,18 @@ const COLLISION_GROUP = "collision";
19870
19848
  }
19871
19849
  }
19872
19850
 
19851
+ /**
19852
+ * a collection of utility functions for parsing TMX maps
19853
+ * @namespace TMXUtils
19854
+ */
19855
+
19856
+
19857
+ /**
19858
+ * the function used to decompress zlib/gzip data
19859
+ * @ignore
19860
+ */
19861
+ let inflateFunction;
19862
+
19873
19863
  /**
19874
19864
  * set and interpret a TMX property value
19875
19865
  * @ignore
@@ -19895,11 +19885,11 @@ function setTMXValue(name, type, value) {
19895
19885
 
19896
19886
  default :
19897
19887
  // try to parse it anyway
19898
- if (!value || utils.string.isBoolean(value)) {
19888
+ if (!value || isBoolean(value)) {
19899
19889
  // if value not defined or boolean
19900
19890
  value = value ? (value === "true") : true;
19901
19891
  }
19902
- else if (utils.string.isNumeric(value)) {
19892
+ else if (isNumeric(value)) {
19903
19893
  // check if numeric
19904
19894
  value = Number(value);
19905
19895
  }
@@ -19965,94 +19955,6 @@ function parseAttributes(obj, elt) {
19965
19955
  }
19966
19956
  }
19967
19957
 
19968
- /**
19969
- * decompress and decode zlib/gzip data
19970
- * @ignore
19971
- * @name decompress
19972
- * @param {string} input - Base64 encoded and compressed data
19973
- * @param {string} format - compressed data format ("gzip","zlib", "zstd")
19974
- * @returns {Uint32Array} Decoded and decompress data
19975
- */
19976
- function decompress(data, format) {
19977
- if (typeof utils.inflateb64 === "function") {
19978
- return utils.inflateb64(data, format);
19979
- } else {
19980
- throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
19981
- }
19982
- }
19983
-
19984
- /**
19985
- * Decode a CSV encoded array into a binary array
19986
- * @ignore
19987
- * @name decodeCSV
19988
- * @param {string} input- - CSV formatted data (only numbers, everything else will be converted to NaN)
19989
- * @returns {number[]} Decoded data
19990
- */
19991
- function decodeCSV(input) {
19992
- let entries = input.replace("\n", "").trim().split(",");
19993
-
19994
- let result = [];
19995
- for (let i = 0; i < entries.length; i++) {
19996
- result.push(+entries[i]);
19997
- }
19998
- return result;
19999
- }
20000
-
20001
- /**
20002
- * Decode a base64 encoded string into a byte array
20003
- * @ignore
20004
- * @name decodeBase64AsArray
20005
- * @param {string} input - Base64 encoded data
20006
- * @param {number} [bytes] - number of bytes per array entry
20007
- * @returns {Uint32Array} Decoded data
20008
- */
20009
- function decodeBase64AsArray(input, bytes) {
20010
- bytes = bytes || 1;
20011
-
20012
- let i, j, len;
20013
- let dec = globalThis.atob(input.replace(/[^A-Za-z0-9\+\/\=]/g, ""));
20014
- let ar = new Uint32Array(dec.length / bytes);
20015
-
20016
- for (i = 0, len = dec.length / bytes; i < len; i++) {
20017
- ar[i] = 0;
20018
- for (j = bytes - 1; j >= 0; --j) {
20019
- ar[i] += dec.charCodeAt((i * bytes) + j) << (j << 3);
20020
- }
20021
- }
20022
- return ar;
20023
- }
20024
-
20025
- /**
20026
- * Decode the given data
20027
- * @ignore
20028
- */
20029
- function decode(data, encoding, compression) {
20030
- compression = compression || "none";
20031
- encoding = encoding || "none";
20032
-
20033
- switch (encoding) {
20034
- case "csv":
20035
- return decodeCSV(data);
20036
-
20037
- case "base64":
20038
- if (compression !== "none") {
20039
- data = decompress(data, compression);
20040
- } else {
20041
- data = decodeBase64AsArray(data, 4);
20042
- }
20043
- return data;
20044
-
20045
- case "none":
20046
- return data;
20047
-
20048
- case "xml":
20049
- throw new Error("XML encoding is deprecated, use base64 instead");
20050
-
20051
- default:
20052
- throw new Error("Unknown layer encoding: " + encoding);
20053
- }
20054
- }
20055
-
20056
19958
  /**
20057
19959
  * Normalize TMX format to Tiled JSON format
20058
19960
  * @ignore
@@ -20185,9 +20087,113 @@ function normalize(obj, item) {
20185
20087
  }
20186
20088
  }
20187
20089
 
20090
+
20091
+ /**
20092
+ * decompress and decode zlib/gzip data
20093
+ * @name decompress
20094
+ * @memberOf TMXUtils
20095
+ * @param {string} input - Base64 encoded and compressed data
20096
+ * @param {string} format - compressed data format ("gzip","zlib", "zstd")
20097
+ * @returns {Uint32Array} Decoded and decompress data
20098
+ */
20099
+ function decompress(data, format) {
20100
+ if (typeof inflateFunction === "function") {
20101
+ return inflateFunction(data, format);
20102
+ } else {
20103
+ throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
20104
+ }
20105
+ }
20106
+
20107
+ /**
20108
+ * Decode a CSV encoded array into a binary array
20109
+ * @name decodeCSV
20110
+ * @memberOf TMXUtils
20111
+ * @param {string} input- - CSV formatted data (only numbers, everything else will be converted to NaN)
20112
+ * @returns {number[]} Decoded data
20113
+ */
20114
+ function decodeCSV(input) {
20115
+ let entries = input.replace("\n", "").trim().split(",");
20116
+
20117
+ let result = [];
20118
+ for (let i = 0; i < entries.length; i++) {
20119
+ result.push(+entries[i]);
20120
+ }
20121
+ return result;
20122
+ }
20123
+
20124
+ /**
20125
+ * Decode a base64 encoded string into a byte array
20126
+ * @name decodeBase64AsArray
20127
+ * @memberOf TMXUtils
20128
+ * @param {string} input - Base64 encoded data
20129
+ * @param {number} [bytes] - number of bytes per array entry
20130
+ * @returns {Uint32Array} Decoded data
20131
+ */
20132
+ function decodeBase64AsArray(input, bytes) {
20133
+ bytes = bytes || 1;
20134
+
20135
+ let i, j, len;
20136
+ let dec = globalThis.atob(input.replace(/[^A-Za-z0-9\+\/\=]/g, ""));
20137
+ let ar = new Uint32Array(dec.length / bytes);
20138
+
20139
+ for (i = 0, len = dec.length / bytes; i < len; i++) {
20140
+ ar[i] = 0;
20141
+ for (j = bytes - 1; j >= 0; --j) {
20142
+ ar[i] += dec.charCodeAt((i * bytes) + j) << (j << 3);
20143
+ }
20144
+ }
20145
+ return ar;
20146
+ }
20147
+
20148
+ /**
20149
+ * set the function used to inflate gzip/zlib data
20150
+ * @param {Func} fn - inflate function
20151
+ */
20152
+ function setInflateFunction(fn) {
20153
+ inflateFunction = fn;
20154
+ }
20155
+
20156
+ /**
20157
+ * Decode a encoded array into a binary array
20158
+ * @name decodeCSV
20159
+ * @memberOf TMXUtils
20160
+ * @param {string} data - data to be decoded
20161
+ * @param {string} [encoding="none"] - data encoding ("csv", "base64", "xml")
20162
+ * @returns {number[]} Decoded data
20163
+ */
20164
+ function decode(data, encoding, compression) {
20165
+ compression = compression || "none";
20166
+ encoding = encoding || "none";
20167
+
20168
+ switch (encoding) {
20169
+ case "csv":
20170
+ return decodeCSV(data);
20171
+
20172
+ case "base64":
20173
+ if (compression !== "none") {
20174
+ data = decompress(data, compression);
20175
+ } else {
20176
+ data = decodeBase64AsArray(data, 4);
20177
+ }
20178
+ return data;
20179
+
20180
+ case "none":
20181
+ return data;
20182
+
20183
+ case "xml":
20184
+ throw new Error("XML encoding is deprecated, use base64 instead");
20185
+
20186
+ default:
20187
+ throw new Error("Unknown layer encoding: " + encoding);
20188
+ }
20189
+ }
20190
+
20188
20191
  /**
20189
20192
  * Parse a XML TMX object and returns the corresponding javascript object
20190
- * @ignore
20193
+ * @name parse
20194
+ * @memberOf TMXUtils
20195
+ * @param {Document} xml - XML TMX object
20196
+ * @returns {object} Javascript object
20191
20197
  */
20192
20198
  function parse(xml) {
20193
20199
  // Create the return object
@@ -20225,7 +20231,11 @@ function parse(xml) {
20225
20231
 
20226
20232
  /**
20227
20233
  * Apply TMX Properties to the given object
20228
- * @ignore
20234
+ * @name applyTMXProperties
20235
+ * @memberOf TMXUtils
20236
+ * @param {object} obj - object to apply the properties to
20237
+ * @param {object} data - TMX data object
20238
+ * @returns {object} obj
20229
20239
  */
20230
20240
  function applyTMXProperties(obj, data) {
20231
20241
  let properties = data.properties;
@@ -20255,6 +20265,14 @@ function applyTMXProperties(obj, data) {
20255
20265
  }
20256
20266
  }
20257
20267
 
20268
+ var TMXUtils = {
20269
+ __proto__: null,
20270
+ applyTMXProperties: applyTMXProperties,
20271
+ decode: decode,
20272
+ parse: parse,
20273
+ setInflateFunction: setInflateFunction
20274
+ };
20275
+
20258
20276
  /**
20259
20277
  * @classdesc
20260
20278
  * a basic tile object
@@ -23690,7 +23708,7 @@ let globalFloatingCounter = 0;
23690
23708
  // (e.g. move one child from one container to another)
23691
23709
  if (child.isRenderable) {
23692
23710
  // allocated a GUID value (use child.id as based index if defined)
23693
- child.GUID = utils.createGUID(child.id);
23711
+ child.GUID = createGUID(child.id);
23694
23712
  }
23695
23713
  }
23696
23714
 
@@ -23773,7 +23791,7 @@ let globalFloatingCounter = 0;
23773
23791
  // (e.g. move one child from one container to another)
23774
23792
  if (child.isRenderable) {
23775
23793
  // allocated a GUID value
23776
- child.GUID = utils.createGUID();
23794
+ child.GUID = createGUID();
23777
23795
  }
23778
23796
  }
23779
23797
 
@@ -24144,7 +24162,7 @@ let globalFloatingCounter = 0;
24144
24162
  */
24145
24163
  removeChild(child, keepalive) {
24146
24164
  if (this.hasChild(child)) {
24147
- utils.function.defer(deferredRemove, this, child, keepalive);
24165
+ defer(deferredRemove, this, child, keepalive);
24148
24166
  }
24149
24167
  else {
24150
24168
  throw new Error("Child is not mine.");
@@ -24295,7 +24313,7 @@ let globalFloatingCounter = 0;
24295
24313
  });
24296
24314
  }
24297
24315
  /** @ignore */
24298
- this.pendingSort = utils.function.defer(function () {
24316
+ this.pendingSort = defer(function () {
24299
24317
  // sort everything in this container
24300
24318
  this.getChildren().sort(this["_sort" + this.sortOn.toUpperCase()]);
24301
24319
  // clear the defer id
@@ -25760,7 +25778,7 @@ function readObjectGroup(map, data, z) {
25760
25778
  // if version is undefined or empty it usually means the map was not created with Tiled
25761
25779
  if (this.version !== "undefined" && this.version !== "") {
25762
25780
  // deprecation warning if map tiled version is older than 1.5
25763
- if (utils.checkVersion(this.version, "1.5") < 0) {
25781
+ if (checkVersion(this.version, "1.5") < 0) {
25764
25782
  warning("("+this.name+") Tiled Map format version 1.4 and below", "format 1.5 or higher", "10.4.4");
25765
25783
  }
25766
25784
  }
@@ -26185,7 +26203,7 @@ function loadTMXLevel(levelId, container, flatten, setViewportBounds) {
26185
26203
 
26186
26204
  // reset the GUID generator
26187
26205
  // and pass the level id as parameter
26188
- utils.resetGUID(levelId, level.nextobjectid);
26206
+ resetGUID(levelId, level.nextobjectid);
26189
26207
 
26190
26208
  // Tiled use 0,0 anchor coordinates
26191
26209
  container.anchorPoint.set(0, 0);
@@ -26301,7 +26319,7 @@ let level = {
26301
26319
  // some silly side effects
26302
26320
  state$1.stop();
26303
26321
 
26304
- utils.function.defer(safeLoadLevel, this, levelId, options, true);
26322
+ defer(safeLoadLevel, this, levelId, options, true);
26305
26323
  }
26306
26324
  else {
26307
26325
  safeLoadLevel(levelId, options);
@@ -28563,7 +28581,7 @@ class Timer {
28563
28581
  */
28564
28582
  clearTimeout(timeoutID) {
28565
28583
  if (timeoutID > 0) {
28566
- utils.function.defer(this.clearTimer.bind(this), this, timeoutID);
28584
+ defer(this.clearTimer.bind(this), this, timeoutID);
28567
28585
  }
28568
28586
  }
28569
28587
 
@@ -28573,7 +28591,7 @@ class Timer {
28573
28591
  */
28574
28592
  clearInterval(intervalID) {
28575
28593
  if (intervalID > 0) {
28576
- utils.function.defer(this.clearTimer.bind(this), this, intervalID);
28594
+ defer(this.clearTimer.bind(this), this, intervalID);
28577
28595
  }
28578
28596
  }
28579
28597
 
@@ -37767,14 +37785,14 @@ function consoleHeader(app) {
37767
37785
  }
37768
37786
 
37769
37787
  // override renderer settings if &webgl or &canvas is defined in the URL
37770
- let uriFragment = utils.getUriFragment();
37788
+ let uriFragment = getUriFragment();
37771
37789
  if (uriFragment.webgl === true || uriFragment.webgl1 === true || uriFragment.webgl2 === true) {
37772
- this.settings.renderer = WEBGL$1;
37790
+ this.settings.renderer = WEBGL;
37773
37791
  if (uriFragment.webgl1 === true) {
37774
37792
  this.settings.preferWebGL1 = true;
37775
37793
  }
37776
37794
  } else if (uriFragment.canvas === true) {
37777
- this.settings.renderer = CANVAS$1;
37795
+ this.settings.renderer = CANVAS;
37778
37796
  }
37779
37797
 
37780
37798
  // normalize scale
@@ -37786,8 +37804,8 @@ function consoleHeader(app) {
37786
37804
 
37787
37805
  if (typeof this.settings.renderer === "number") {
37788
37806
  switch (this.settings.renderer) {
37789
- case AUTO$1:
37790
- case WEBGL$1:
37807
+ case AUTO:
37808
+ case WEBGL:
37791
37809
  this.renderer = autoDetectRenderer(this.settings);
37792
37810
  break;
37793
37811
  default:
@@ -37995,133 +38013,140 @@ function consoleHeader(app) {
37995
38013
  }
37996
38014
 
37997
38015
  /**
37998
- * This namespace is a container for all registered plugins.
37999
- * @see plugin.register
38000
- * @namespace plugins
38016
+ * Contains all registered plugins.
38017
+ * @name cache
38018
+ * @memberof plugin
38001
38019
  */
38002
- let plugins = {};
38020
+ let cache = {};
38003
38021
 
38022
+ /**
38023
+ * @namespace plugin
38024
+ */
38004
38025
 
38026
+ /**
38027
+ * a base Object class for plugin
38028
+ * (plugin must be installed using the register function)
38029
+ * @class
38030
+ * @name BasePlugin
38031
+ * @memberof plugin
38032
+ */
38005
38033
  class BasePlugin {
38006
38034
 
38007
38035
  constructor() {
38008
38036
  /**
38009
38037
  * define the minimum required version of melonJS<br>
38010
38038
  * this can be overridden by the plugin
38011
- * @public
38012
38039
  * @type {string}
38013
- * @default "15.1.6"
38014
- * @name plugin.Base#version
38040
+ * @default "15.2.1"
38015
38041
  */
38016
- this.version = "15.1.6";
38042
+ this.version = "15.2.1";
38017
38043
  }
38018
38044
  }
38019
38045
 
38046
+
38020
38047
  /**
38021
- * @namespace plugin
38048
+ * @class
38049
+ * @name Base
38050
+ * @memberof plugin
38051
+ * @deprecated since 15.1.6, see {@link plugin.BasePlugin}
38022
38052
  */
38023
- let plugin = {
38053
+ class Base extends BasePlugin {}
38024
38054
 
38025
- /**
38026
- * a base Object for plugin <br>
38027
- * plugin must be installed using the register function
38028
- * @see plugin
38029
- * @class
38030
- * @name Base
38031
- * @memberof plugin
38032
- */
38033
- Base : BasePlugin,
38055
+ /**
38056
+ * patch a melonJS function
38057
+ * @name patch
38058
+ * @memberof plugin
38059
+ * @param {object} proto - target object
38060
+ * @param {string} name - target function
38061
+ * @param {Function} fn - replacement function
38062
+ * @example
38063
+ * // redefine the me.game.update function with a new one
38064
+ * me.plugin.patch(me.game, "update", function () {
38065
+ * // display something in the console
38066
+ * console.log("duh");
38067
+ * // call the original me.game.update function
38068
+ * this._patched();
38069
+ * });
38070
+ */
38071
+ function patch(proto, name, fn) {
38072
+ // use the object prototype if possible
38073
+ if (typeof proto.prototype !== "undefined") {
38074
+ proto = proto.prototype;
38075
+ }
38076
+ // reuse the logic behind object extends
38077
+ if (typeof(proto[name]) === "function") {
38078
+ // save the original function
38079
+ let _parent = proto[name];
38080
+ // override the function with the new one
38081
+ Object.defineProperty(proto, name, {
38082
+ "configurable" : true,
38083
+ "value" : (function (name, fn) {
38084
+ return function () {
38085
+ this._patched = _parent;
38086
+ let ret = fn.apply(this, arguments);
38087
+ this._patched = null;
38088
+ return ret;
38089
+ };
38090
+ })(name, fn)
38091
+ });
38092
+ }
38093
+ else {
38094
+ throw new Error(name + " is not an existing function");
38095
+ }
38096
+ }
38034
38097
 
38035
- /**
38036
- * patch a melonJS function
38037
- * @name patch
38038
- * @memberof plugin
38039
- * @public
38040
- * @param {object} proto - target object
38041
- * @param {string} name - target function
38042
- * @param {Function} fn - replacement function
38043
- * @example
38044
- * // redefine the me.game.update function with a new one
38045
- * me.plugin.patch(me.game, "update", function () {
38046
- * // display something in the console
38047
- * console.log("duh");
38048
- * // call the original me.game.update function
38049
- * this._patched();
38050
- * });
38051
- */
38052
- patch : function (proto, name, fn) {
38053
- // use the object prototype if possible
38054
- if (typeof proto.prototype !== "undefined") {
38055
- proto = proto.prototype;
38056
- }
38057
- // reuse the logic behind object extends
38058
- if (typeof(proto[name]) === "function") {
38059
- // save the original function
38060
- let _parent = proto[name];
38061
- // override the function with the new one
38062
- Object.defineProperty(proto, name, {
38063
- "configurable" : true,
38064
- "value" : (function (name, fn) {
38065
- return function () {
38066
- this._patched = _parent;
38067
- let ret = fn.apply(this, arguments);
38068
- this._patched = null;
38069
- return ret;
38070
- };
38071
- })(name, fn)
38072
- });
38073
- }
38074
- else {
38075
- throw new Error(name + " is not an existing function");
38076
- }
38077
- },
38098
+ /**
38099
+ * Register a plugin.
38100
+ * @name register
38101
+ * @memberof plugin
38102
+ * @param {plugin.BasePlugin} plugin - Plugin object to instantiate and register
38103
+ * @param {string} [name=plugin.constructor.name] - a unique name for this plugin
38104
+ * @param {object} [...arguments] - all extra parameters will be passed to the plugin constructor
38105
+ * @example
38106
+ * // register a new plugin
38107
+ * me.plugin.register(TestPlugin, "testPlugin");
38108
+ * // the plugin then also become available
38109
+ * // under then me.plugins namespace
38110
+ * me.plugins.testPlugin.myfunction ();
38111
+ */
38112
+ function register(plugin, name = plugin.toString().match(/ (\w+)/)[1]) {
38113
+ // ensure me.plugins[name] is not already "used"
38114
+ if (cache[name]) {
38115
+ throw new Error("plugin " + name + " already registered");
38116
+ }
38078
38117
 
38079
- /**
38080
- * Register a plugin.
38081
- * @name register
38082
- * @memberof plugin
38083
- * @see Base
38084
- * @public
38085
- * @param {plugin.Base} pluginObj - Plugin object to instantiate and register
38086
- * @param {string} [name=pluginObj.constructor.name] - a unique name for this plugin
38087
- * @param {object} [...arguments] - all extra parameters will be passed to the plugin constructor
38088
- * @example
38089
- * // register a new plugin
38090
- * me.plugin.register(TestPlugin, "testPlugin");
38091
- * // the plugin then also become available
38092
- * // under then me.plugins namespace
38093
- * me.plugins.testPlugin.myfunction ();
38094
- */
38095
- register : function (pluginObj, name = pluginObj.toString().match(/ (\w+)/)[1]) {
38096
- // ensure me.plugins[name] is not already "used"
38097
- if (plugins[name]) {
38098
- throw new Error("plugin " + name + " already registered");
38099
- }
38118
+ // get extra arguments
38119
+ let _args = [];
38120
+ if (arguments.length > 2) {
38121
+ // store extra arguments if any
38122
+ _args = Array.prototype.slice.call(arguments, 1);
38123
+ }
38100
38124
 
38101
- // get extra arguments
38102
- let _args = [];
38103
- if (arguments.length > 2) {
38104
- // store extra arguments if any
38105
- _args = Array.prototype.slice.call(arguments, 1);
38106
- }
38125
+ // try to instantiate the plugin
38126
+ _args[0] = plugin;
38127
+ let instance = new (plugin.bind.apply(plugin, _args))();
38107
38128
 
38108
- // try to instantiate the plugin
38109
- _args[0] = pluginObj;
38110
- let instance = new (pluginObj.bind.apply(pluginObj, _args))();
38129
+ // inheritance check
38130
+ if (typeof instance === "undefined" || !(instance instanceof BasePlugin)) {
38131
+ throw new Error("Plugin should extend the BasePlugin Class !");
38132
+ }
38111
38133
 
38112
- // inheritance check
38113
- if (typeof instance === "undefined" || !(instance instanceof plugin.Base)) {
38114
- throw new Error("Plugin should extend the me.plugin.Base Class !");
38115
- }
38134
+ // compatibility testing
38135
+ if (checkVersion(instance.version, version) > 0) {
38136
+ throw new Error("Plugin version mismatch, expected: " + instance.version + ", got: " + version);
38137
+ }
38116
38138
 
38117
- // compatibility testing
38118
- if (utils.checkVersion(instance.version, version) > 0) {
38119
- throw new Error("Plugin version mismatch, expected: " + instance.version + ", got: " + version);
38120
- }
38139
+ // create a reference to the new plugin
38140
+ cache[name] = instance;
38141
+ }
38121
38142
 
38122
- // create a reference to the new plugin
38123
- plugins[name] = instance;
38124
- }
38143
+ var plugin = {
38144
+ __proto__: null,
38145
+ Base: Base,
38146
+ BasePlugin: BasePlugin,
38147
+ cache: cache,
38148
+ patch: patch,
38149
+ register: register
38125
38150
  };
38126
38151
 
38127
38152
  /*
@@ -38241,7 +38266,7 @@ Renderer.prototype.getScreenContext = function() {
38241
38266
  * @name version
38242
38267
  * @type {string}
38243
38268
  */
38244
- const version = "15.1.6";
38269
+ const version = "15.2.1";
38245
38270
 
38246
38271
  /**
38247
38272
  * a flag indicating that melonJS is fully initialized
@@ -38349,7 +38374,7 @@ function boot() {
38349
38374
  emit(BOOT);
38350
38375
 
38351
38376
  // enable/disable the cache
38352
- setNocache( utils.getUriFragment().nocache || false );
38377
+ setNocache( getUriFragment().nocache || false );
38353
38378
 
38354
38379
  // automatically enable keyboard events
38355
38380
  initKeyboardEvent();
@@ -38370,4 +38395,4 @@ onReady(() => {
38370
38395
  }
38371
38396
  });
38372
38397
 
38373
- export { AUTO$1 as AUTO, Application, BitmapText, BitmapTextData, Body, Bounds, CANVAS$1 as CANVAS, Camera2d, CanvasRenderer, CanvasTexture, Collectable, Color, ColorLayer, Compositor, Container, Draggable, DraggableEntity, DropTarget, DroptargetEntity, Ellipse, Entity, GLShader, GUI_Object, ImageLayer, Light2d, Line, math as Math, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, ParticleEmitter, ParticleEmitterSettings, Point, Pointer, Polygon, PrimitiveCompositor, QuadCompositor, QuadTree, Rect, Renderable, Renderer, RoundRect, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, Text, TextureAtlas, Tile, Trigger, Tween, UIBaseElement, UISpriteElement, UITextButton, Vector2d, Vector3d, WEBGL$1 as WEBGL, WebGLRenderer, World, audio, boot, collision, device, event, game, initialized, input, level, loader, plugin, plugins, pool, save, skipAutoInit, state$1 as state, timer$1 as timer, utils, version, video };
38398
+ export { AUTO, Application, BitmapText, BitmapTextData, Body, Bounds, CANVAS, Camera2d, CanvasRenderer, CanvasTexture, Collectable, Color, ColorLayer, Compositor, Container, Draggable, DraggableEntity, DropTarget, DroptargetEntity, Ellipse, Entity, GLShader, GUI_Object, ImageLayer, Light2d, Line, math as Math, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, ParticleEmitter, ParticleEmitterSettings, Point, Pointer, Polygon, PrimitiveCompositor, QuadCompositor, QuadTree, Rect, Renderable, Renderer, RoundRect, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, TMXUtils, Text, TextureAtlas, Tile, Trigger, Tween, UIBaseElement, UISpriteElement, UITextButton, Vector2d, Vector3d, WEBGL, WebGLRenderer, World, audio, boot, collision, device, event, game, initialized, input, level, loader, plugin, cache as plugins, pool, save, skipAutoInit, state$1 as state, timer$1 as timer, utils, version, video };