melonjs 15.1.6 → 15.2.0

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 (151) hide show
  1. package/README.md +2 -2
  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 +10 -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 +6 -8
  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 +4 -4
  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 +460 -449
  138. package/dist/types/index.d.ts +3 -3
  139. package/dist/types/plugin/plugin.d.ts +60 -5
  140. package/dist/types/utils/utils.d.ts +56 -17
  141. package/package.json +3 -3
  142. package/src/application/application.js +2 -2
  143. package/src/index.js +3 -2
  144. package/src/level/level.js +4 -3
  145. package/src/level/tiled/TMXTileMap.js +2 -2
  146. package/src/level/tiled/TMXUtils.js +4 -3
  147. package/src/plugin/plugin.js +103 -105
  148. package/src/renderable/container.js +6 -5
  149. package/src/system/timer.js +3 -3
  150. package/src/utils/utils.js +102 -111
  151. package/src/video/video.js +3 -3
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.6
2
+ * melonJS Game Engine - v15.2.0
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
  /**
@@ -14322,7 +14081,7 @@ function init(width, height, options) {
14322
14081
  //add a channel for the onresize/onorientationchange event
14323
14082
  globalThis.addEventListener(
14324
14083
  "resize",
14325
- utils.function.throttle(
14084
+ throttle(
14326
14085
  (e) => {
14327
14086
  emit(WINDOW_ONRESIZE, e);
14328
14087
  }, 100
@@ -14354,7 +14113,7 @@ function init(width, height, options) {
14354
14113
  }
14355
14114
 
14356
14115
  // Automatically update relative canvas position on scroll
14357
- globalThis.addEventListener("scroll", utils.function.throttle((e) => {
14116
+ globalThis.addEventListener("scroll", throttle((e) => {
14358
14117
  emit(WINDOW_ONSCROLL, e);
14359
14118
  }, 100), false);
14360
14119
 
@@ -14561,6 +14320,78 @@ let save = {
14561
14320
  }
14562
14321
  };
14563
14322
 
14323
+ /**
14324
+ * a collection of utility functons to ease porting between different user agents.
14325
+ * @namespace utils.agent
14326
+ */
14327
+
14328
+ /**
14329
+ * Known agent vendors
14330
+ * @ignore
14331
+ */
14332
+ const vendors = [ "ms", "MS", "moz", "webkit", "o" ];
14333
+
14334
+ /**
14335
+ * Get a vendor-prefixed property
14336
+ * @public
14337
+ * @name prefixed
14338
+ * @param {string} name - Property name
14339
+ * @param {object} [obj=globalThis] - Object or element reference to access
14340
+ * @returns {string} Value of property
14341
+ * @memberof utils.agent
14342
+ */
14343
+ function prefixed(name, obj) {
14344
+ obj = obj || globalThis;
14345
+ if (name in obj) {
14346
+ return obj[name];
14347
+ }
14348
+
14349
+ let uc_name = capitalize(name);
14350
+
14351
+ let result;
14352
+ vendors.some((vendor) => {
14353
+ let name = vendor + uc_name;
14354
+ return (result = (name in obj) ? obj[name] : undefined);
14355
+ });
14356
+ return result;
14357
+ }
14358
+
14359
+ /**
14360
+ * Set a vendor-prefixed property
14361
+ * @public
14362
+ * @name setPrefixed
14363
+ * @param {string} name - Property name
14364
+ * @param {string} value - Property value
14365
+ * @param {object} [obj=globalThis] - Object or element reference to access
14366
+ * @returns {boolean} true if one of the vendor-prefixed property was found
14367
+ * @memberof utils.agent
14368
+ */
14369
+ function setPrefixed(name, value, obj) {
14370
+ obj = obj || globalThis;
14371
+ if (name in obj) {
14372
+ obj[name] = value;
14373
+ return;
14374
+ }
14375
+
14376
+ let uc_name = capitalize(name);
14377
+
14378
+ vendors.some((vendor) => {
14379
+ let name = vendor + uc_name;
14380
+ if (name in obj) {
14381
+ obj[name] = value;
14382
+ return true;
14383
+ }
14384
+ });
14385
+
14386
+ return false;
14387
+ }
14388
+
14389
+ var agent$1 = {
14390
+ __proto__: null,
14391
+ prefixed: prefixed,
14392
+ setPrefixed: setPrefixed
14393
+ };
14394
+
14564
14395
  /**
14565
14396
  * The device platform type
14566
14397
  * @namespace platform
@@ -19500,6 +19331,46 @@ let default_settings = {
19500
19331
  }
19501
19332
  }
19502
19333
 
19334
+ /**
19335
+ * a collection of file utility functions
19336
+ * @namespace utils.file
19337
+ */
19338
+
19339
+ // regexp to deal with file name & path
19340
+ const REMOVE_PATH = /^.*(\\|\/|\:)/;
19341
+ const REMOVE_EXT = /\.[^\.]*$/;
19342
+
19343
+
19344
+ /**
19345
+ * return the base name of the file without path info
19346
+ * @public
19347
+ * @memberof utils.file
19348
+ * @name getBasename
19349
+ * @param {string} path- - path containing the filename
19350
+ * @returns {string} the base name without path information.
19351
+ */
19352
+ function getBasename(path) {
19353
+ return path.replace(REMOVE_PATH, "").replace(REMOVE_EXT, "");
19354
+ }
19355
+
19356
+ /**
19357
+ * return the extension of the file in the given path
19358
+ * @public
19359
+ * @memberof utils.file
19360
+ * @name getExtension
19361
+ * @param {string} path- - path containing the filename
19362
+ * @returns {string} filename extension.
19363
+ */
19364
+ function getExtension(path) {
19365
+ return path.substring(path.lastIndexOf(".") + 1, path.length);
19366
+ }
19367
+
19368
+ var file$1 = {
19369
+ __proto__: null,
19370
+ getBasename: getBasename,
19371
+ getExtension: getExtension
19372
+ };
19373
+
19503
19374
  /**
19504
19375
  * where all preloaded content is cached
19505
19376
  */
@@ -19516,6 +19387,139 @@ let binList = {};
19516
19387
  // contains all the JSON files
19517
19388
  let jsonList = {};
19518
19389
 
19390
+ /**
19391
+ * a collection of utility functions
19392
+ * @namespace utils
19393
+ */
19394
+
19395
+ // guid default value
19396
+ let GUID_base = "";
19397
+ let GUID_index = 0;
19398
+
19399
+ /**
19400
+ * Compare two version strings
19401
+ * @public
19402
+ * @memberof utils
19403
+ * @name checkVersion
19404
+ * @param {string} first - First version string to compare
19405
+ * @param {string} second - second version string to compare
19406
+ * @returns {number} comparison result <br>&lt; 0 : first &lt; second<br>
19407
+ * 0 : first == second<br>
19408
+ * &gt; 0 : first &gt; second
19409
+ * @example
19410
+ * if (me.utils.checkVersion("7.0.0") > 0) {
19411
+ * console.error(
19412
+ * "melonJS is too old. Expected: 7.0.0, Got: 6.3.0"
19413
+ * );
19414
+ * }
19415
+ */
19416
+ function checkVersion(first, second) {
19417
+ let a = first.split(".");
19418
+ let b = second.split(".");
19419
+ let len = Math.min(a.length, b.length);
19420
+ let result = 0;
19421
+
19422
+ for (let i = 0; i < len; i++) {
19423
+ if ((result = +a[i] - +b[i])) {
19424
+ break;
19425
+ }
19426
+ }
19427
+
19428
+ return result ? result : a.length - b.length;
19429
+ }
19430
+
19431
+ /**
19432
+ * parse the fragment (hash) from a URL and returns them into
19433
+ * @public
19434
+ * @memberof utils
19435
+ * @name getUriFragment
19436
+ * @param {string} [url=document.location] - an optional params string or URL containing fragment (hash) params to be parsed
19437
+ * @returns {object} an object representing the deserialized params string.
19438
+ * @property {boolean} [hitbox=false] draw the hitbox in the debug panel (if enabled)
19439
+ * @property {boolean} [velocity=false] draw the entities velocity in the debug panel (if enabled)
19440
+ * @property {boolean} [quadtree=false] draw the quadtree in the debug panel (if enabled)
19441
+ * @property {boolean} [webgl=false] force the renderer to WebGL
19442
+ * @property {boolean} [debug=false] display the debug panel (if preloaded)
19443
+ * @property {string} [debugToggleKey="s"] show/hide the debug panel (if preloaded)
19444
+ * @example
19445
+ * // http://www.example.com/index.html#debug&hitbox=true&mytag=value
19446
+ * let UriFragment = me.utils.getUriFragment();
19447
+ * console.log(UriFragment["mytag"]); //> "value"
19448
+ */
19449
+ function getUriFragment(url) {
19450
+ let hash = {};
19451
+
19452
+ if (typeof url === "undefined") {
19453
+ if (typeof globalThis.document !== "undefined") {
19454
+ let location = globalThis.document.location;
19455
+
19456
+ if (location && location.hash) {
19457
+ url = location.hash;
19458
+ } else {
19459
+ // No "document.location" exist for Wechat mini game platform.
19460
+ return hash;
19461
+ }
19462
+ } else {
19463
+ // "document" undefined on node.js
19464
+ return hash;
19465
+ }
19466
+ } else {
19467
+ // never cache if a url is passed as parameter
19468
+ let index = url.indexOf("#");
19469
+ if (index !== -1) {
19470
+ url = url.slice(index, url.length);
19471
+ } else {
19472
+ return hash;
19473
+ }
19474
+ }
19475
+
19476
+ // parse the url
19477
+ url.slice(1).split("&").filter((value) => value !== "").forEach((value) => {
19478
+ let kv = value.split("=");
19479
+ let k = kv.shift();
19480
+ let v = kv.join("=");
19481
+ hash[k] = v || true;
19482
+ });
19483
+
19484
+ return hash;
19485
+ }
19486
+
19487
+ /**
19488
+ * reset the GUID Base Name
19489
+ * the idea here being to have a unique ID
19490
+ * per level / object
19491
+ * @ignore
19492
+ */
19493
+ function resetGUID(base, index = 0) {
19494
+ // also ensure it's only 8bit ASCII characters
19495
+ GUID_base = toHex(base.toString().toUpperCase());
19496
+ GUID_index = index;
19497
+ }
19498
+
19499
+ /**
19500
+ * create and return a very simple GUID
19501
+ * Game Unique ID
19502
+ * @ignore
19503
+ */
19504
+ function createGUID(index = 1) {
19505
+ // to cover the case of undefined id for groups
19506
+ GUID_index += index;
19507
+ return GUID_base + "-" + (index || GUID_index);
19508
+ }
19509
+
19510
+ var utils = {
19511
+ __proto__: null,
19512
+ agent: agent$1,
19513
+ array: array$1,
19514
+ checkVersion: checkVersion,
19515
+ createGUID: createGUID,
19516
+ file: file$1,
19517
+ function: _function,
19518
+ getUriFragment: getUriFragment,
19519
+ resetGUID: resetGUID,
19520
+ string: string$1
19521
+ };
19522
+
19519
19523
  /**
19520
19524
  * @classdesc
19521
19525
  * a TMX Tile Set Object
@@ -19895,11 +19899,11 @@ function setTMXValue(name, type, value) {
19895
19899
 
19896
19900
  default :
19897
19901
  // try to parse it anyway
19898
- if (!value || utils.string.isBoolean(value)) {
19902
+ if (!value || isBoolean(value)) {
19899
19903
  // if value not defined or boolean
19900
19904
  value = value ? (value === "true") : true;
19901
19905
  }
19902
- else if (utils.string.isNumeric(value)) {
19906
+ else if (isNumeric(value)) {
19903
19907
  // check if numeric
19904
19908
  value = Number(value);
19905
19909
  }
@@ -19974,8 +19978,8 @@ function parseAttributes(obj, elt) {
19974
19978
  * @returns {Uint32Array} Decoded and decompress data
19975
19979
  */
19976
19980
  function decompress(data, format) {
19977
- if (typeof utils.inflateb64 === "function") {
19978
- return utils.inflateb64(data, format);
19981
+ if (typeof undefined === "function") {
19982
+ return undefined(data, format);
19979
19983
  } else {
19980
19984
  throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
19981
19985
  }
@@ -23690,7 +23694,7 @@ let globalFloatingCounter = 0;
23690
23694
  // (e.g. move one child from one container to another)
23691
23695
  if (child.isRenderable) {
23692
23696
  // allocated a GUID value (use child.id as based index if defined)
23693
- child.GUID = utils.createGUID(child.id);
23697
+ child.GUID = createGUID(child.id);
23694
23698
  }
23695
23699
  }
23696
23700
 
@@ -23773,7 +23777,7 @@ let globalFloatingCounter = 0;
23773
23777
  // (e.g. move one child from one container to another)
23774
23778
  if (child.isRenderable) {
23775
23779
  // allocated a GUID value
23776
- child.GUID = utils.createGUID();
23780
+ child.GUID = createGUID();
23777
23781
  }
23778
23782
  }
23779
23783
 
@@ -24144,7 +24148,7 @@ let globalFloatingCounter = 0;
24144
24148
  */
24145
24149
  removeChild(child, keepalive) {
24146
24150
  if (this.hasChild(child)) {
24147
- utils.function.defer(deferredRemove, this, child, keepalive);
24151
+ defer(deferredRemove, this, child, keepalive);
24148
24152
  }
24149
24153
  else {
24150
24154
  throw new Error("Child is not mine.");
@@ -24295,7 +24299,7 @@ let globalFloatingCounter = 0;
24295
24299
  });
24296
24300
  }
24297
24301
  /** @ignore */
24298
- this.pendingSort = utils.function.defer(function () {
24302
+ this.pendingSort = defer(function () {
24299
24303
  // sort everything in this container
24300
24304
  this.getChildren().sort(this["_sort" + this.sortOn.toUpperCase()]);
24301
24305
  // clear the defer id
@@ -25760,7 +25764,7 @@ function readObjectGroup(map, data, z) {
25760
25764
  // if version is undefined or empty it usually means the map was not created with Tiled
25761
25765
  if (this.version !== "undefined" && this.version !== "") {
25762
25766
  // deprecation warning if map tiled version is older than 1.5
25763
- if (utils.checkVersion(this.version, "1.5") < 0) {
25767
+ if (checkVersion(this.version, "1.5") < 0) {
25764
25768
  warning("("+this.name+") Tiled Map format version 1.4 and below", "format 1.5 or higher", "10.4.4");
25765
25769
  }
25766
25770
  }
@@ -26185,7 +26189,7 @@ function loadTMXLevel(levelId, container, flatten, setViewportBounds) {
26185
26189
 
26186
26190
  // reset the GUID generator
26187
26191
  // and pass the level id as parameter
26188
- utils.resetGUID(levelId, level.nextobjectid);
26192
+ resetGUID(levelId, level.nextobjectid);
26189
26193
 
26190
26194
  // Tiled use 0,0 anchor coordinates
26191
26195
  container.anchorPoint.set(0, 0);
@@ -26301,7 +26305,7 @@ let level = {
26301
26305
  // some silly side effects
26302
26306
  state$1.stop();
26303
26307
 
26304
- utils.function.defer(safeLoadLevel, this, levelId, options, true);
26308
+ defer(safeLoadLevel, this, levelId, options, true);
26305
26309
  }
26306
26310
  else {
26307
26311
  safeLoadLevel(levelId, options);
@@ -28563,7 +28567,7 @@ class Timer {
28563
28567
  */
28564
28568
  clearTimeout(timeoutID) {
28565
28569
  if (timeoutID > 0) {
28566
- utils.function.defer(this.clearTimer.bind(this), this, timeoutID);
28570
+ defer(this.clearTimer.bind(this), this, timeoutID);
28567
28571
  }
28568
28572
  }
28569
28573
 
@@ -28573,7 +28577,7 @@ class Timer {
28573
28577
  */
28574
28578
  clearInterval(intervalID) {
28575
28579
  if (intervalID > 0) {
28576
- utils.function.defer(this.clearTimer.bind(this), this, intervalID);
28580
+ defer(this.clearTimer.bind(this), this, intervalID);
28577
28581
  }
28578
28582
  }
28579
28583
 
@@ -37767,7 +37771,7 @@ function consoleHeader(app) {
37767
37771
  }
37768
37772
 
37769
37773
  // override renderer settings if &webgl or &canvas is defined in the URL
37770
- let uriFragment = utils.getUriFragment();
37774
+ let uriFragment = getUriFragment();
37771
37775
  if (uriFragment.webgl === true || uriFragment.webgl1 === true || uriFragment.webgl2 === true) {
37772
37776
  this.settings.renderer = WEBGL$1;
37773
37777
  if (uriFragment.webgl1 === true) {
@@ -37995,133 +37999,140 @@ function consoleHeader(app) {
37995
37999
  }
37996
38000
 
37997
38001
  /**
37998
- * This namespace is a container for all registered plugins.
37999
- * @see plugin.register
38000
- * @namespace plugins
38002
+ * Contains all registered plugins.
38003
+ * @name cache
38004
+ * @memberof plugin
38001
38005
  */
38002
- let plugins = {};
38006
+ let cache = {};
38003
38007
 
38008
+ /**
38009
+ * @namespace plugin
38010
+ */
38004
38011
 
38012
+ /**
38013
+ * a base Object class for plugin
38014
+ * (plugin must be installed using the register function)
38015
+ * @class
38016
+ * @name BasePlugin
38017
+ * @memberof plugin
38018
+ */
38005
38019
  class BasePlugin {
38006
38020
 
38007
38021
  constructor() {
38008
38022
  /**
38009
38023
  * define the minimum required version of melonJS<br>
38010
38024
  * this can be overridden by the plugin
38011
- * @public
38012
38025
  * @type {string}
38013
- * @default "15.1.6"
38014
- * @name plugin.Base#version
38026
+ * @default "15.2.0"
38015
38027
  */
38016
- this.version = "15.1.6";
38028
+ this.version = "15.2.0";
38017
38029
  }
38018
38030
  }
38019
38031
 
38032
+
38020
38033
  /**
38021
- * @namespace plugin
38034
+ * @class
38035
+ * @name Base
38036
+ * @memberof plugin
38037
+ * @deprecated since 15.1.6, see {@link plugin.BasePlugin}
38022
38038
  */
38023
- let plugin = {
38039
+ class Base extends BasePlugin {}
38024
38040
 
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,
38041
+ /**
38042
+ * patch a melonJS function
38043
+ * @name patch
38044
+ * @memberof plugin
38045
+ * @param {object} proto - target object
38046
+ * @param {string} name - target function
38047
+ * @param {Function} fn - replacement function
38048
+ * @example
38049
+ * // redefine the me.game.update function with a new one
38050
+ * me.plugin.patch(me.game, "update", function () {
38051
+ * // display something in the console
38052
+ * console.log("duh");
38053
+ * // call the original me.game.update function
38054
+ * this._patched();
38055
+ * });
38056
+ */
38057
+ function patch(proto, name, fn) {
38058
+ // use the object prototype if possible
38059
+ if (typeof proto.prototype !== "undefined") {
38060
+ proto = proto.prototype;
38061
+ }
38062
+ // reuse the logic behind object extends
38063
+ if (typeof(proto[name]) === "function") {
38064
+ // save the original function
38065
+ let _parent = proto[name];
38066
+ // override the function with the new one
38067
+ Object.defineProperty(proto, name, {
38068
+ "configurable" : true,
38069
+ "value" : (function (name, fn) {
38070
+ return function () {
38071
+ this._patched = _parent;
38072
+ let ret = fn.apply(this, arguments);
38073
+ this._patched = null;
38074
+ return ret;
38075
+ };
38076
+ })(name, fn)
38077
+ });
38078
+ }
38079
+ else {
38080
+ throw new Error(name + " is not an existing function");
38081
+ }
38082
+ }
38034
38083
 
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
- },
38084
+ /**
38085
+ * Register a plugin.
38086
+ * @name register
38087
+ * @memberof plugin
38088
+ * @param {plugin.BasePlugin} plugin - Plugin object to instantiate and register
38089
+ * @param {string} [name=plugin.constructor.name] - a unique name for this plugin
38090
+ * @param {object} [...arguments] - all extra parameters will be passed to the plugin constructor
38091
+ * @example
38092
+ * // register a new plugin
38093
+ * me.plugin.register(TestPlugin, "testPlugin");
38094
+ * // the plugin then also become available
38095
+ * // under then me.plugins namespace
38096
+ * me.plugins.testPlugin.myfunction ();
38097
+ */
38098
+ function register(plugin, name = plugin.toString().match(/ (\w+)/)[1]) {
38099
+ // ensure me.plugins[name] is not already "used"
38100
+ if (cache[name]) {
38101
+ throw new Error("plugin " + name + " already registered");
38102
+ }
38078
38103
 
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
- }
38104
+ // get extra arguments
38105
+ let _args = [];
38106
+ if (arguments.length > 2) {
38107
+ // store extra arguments if any
38108
+ _args = Array.prototype.slice.call(arguments, 1);
38109
+ }
38100
38110
 
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
- }
38111
+ // try to instantiate the plugin
38112
+ _args[0] = plugin;
38113
+ let instance = new (plugin.bind.apply(plugin, _args))();
38107
38114
 
38108
- // try to instantiate the plugin
38109
- _args[0] = pluginObj;
38110
- let instance = new (pluginObj.bind.apply(pluginObj, _args))();
38115
+ // inheritance check
38116
+ if (typeof instance === "undefined" || !(instance instanceof BasePlugin)) {
38117
+ throw new Error("Plugin should extend the BasePlugin Class !");
38118
+ }
38111
38119
 
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
- }
38120
+ // compatibility testing
38121
+ if (checkVersion(instance.version, version) > 0) {
38122
+ throw new Error("Plugin version mismatch, expected: " + instance.version + ", got: " + version);
38123
+ }
38116
38124
 
38117
- // compatibility testing
38118
- if (utils.checkVersion(instance.version, version) > 0) {
38119
- throw new Error("Plugin version mismatch, expected: " + instance.version + ", got: " + version);
38120
- }
38125
+ // create a reference to the new plugin
38126
+ cache[name] = instance;
38127
+ }
38121
38128
 
38122
- // create a reference to the new plugin
38123
- plugins[name] = instance;
38124
- }
38129
+ var plugin = {
38130
+ __proto__: null,
38131
+ Base: Base,
38132
+ BasePlugin: BasePlugin,
38133
+ cache: cache,
38134
+ patch: patch,
38135
+ register: register
38125
38136
  };
38126
38137
 
38127
38138
  /*
@@ -38241,7 +38252,7 @@ Renderer.prototype.getScreenContext = function() {
38241
38252
  * @name version
38242
38253
  * @type {string}
38243
38254
  */
38244
- const version = "15.1.6";
38255
+ const version = "15.2.0";
38245
38256
 
38246
38257
  /**
38247
38258
  * a flag indicating that melonJS is fully initialized
@@ -38349,7 +38360,7 @@ function boot() {
38349
38360
  emit(BOOT);
38350
38361
 
38351
38362
  // enable/disable the cache
38352
- setNocache( utils.getUriFragment().nocache || false );
38363
+ setNocache( getUriFragment().nocache || false );
38353
38364
 
38354
38365
  // automatically enable keyboard events
38355
38366
  initKeyboardEvent();
@@ -38370,4 +38381,4 @@ onReady(() => {
38370
38381
  }
38371
38382
  });
38372
38383
 
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 };
38384
+ 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, cache as plugins, pool, save, skipAutoInit, state$1 as state, timer$1 as timer, utils, version, video };