melonjs 15.1.5 → 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 (168) 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 +3 -3
  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 -7
  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 +3 -2
  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 +3 -3
  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 +4 -4
  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 +9 -9
  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 +20 -19
  80. package/dist/melonjs.mjs/renderable/draggable.js +121 -0
  81. package/dist/melonjs.mjs/renderable/dragndrop.js +3 -113
  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 +2 -2
  86. package/dist/melonjs.mjs/renderable/sprite.js +1 -1
  87. package/dist/melonjs.mjs/renderable/trigger.js +2 -2
  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 +516 -500
  138. package/dist/types/camera/camera2d.d.ts +4 -4
  139. package/dist/types/index.d.ts +4 -4
  140. package/dist/types/physics/body.d.ts +4 -4
  141. package/dist/types/physics/detector.d.ts +5 -5
  142. package/dist/types/physics/sat.d.ts +12 -12
  143. package/dist/types/plugin/plugin.d.ts +60 -5
  144. package/dist/types/renderable/container.d.ts +25 -25
  145. package/dist/types/renderable/draggable.d.ts +53 -0
  146. package/dist/types/renderable/dragndrop.d.ts +0 -52
  147. package/dist/types/renderable/renderable.d.ts +2 -2
  148. package/dist/types/utils/utils.d.ts +56 -17
  149. package/package.json +8 -8
  150. package/src/application/application.js +2 -2
  151. package/src/camera/camera2d.js +2 -2
  152. package/src/index.js +5 -3
  153. package/src/lang/deprecated.js +2 -1
  154. package/src/level/level.js +4 -3
  155. package/src/level/tiled/TMXTileMap.js +2 -2
  156. package/src/level/tiled/TMXUtils.js +4 -3
  157. package/src/physics/body.js +2 -2
  158. package/src/physics/detector.js +3 -3
  159. package/src/physics/sat.js +8 -8
  160. package/src/plugin/plugin.js +103 -105
  161. package/src/renderable/container.js +19 -18
  162. package/src/renderable/draggable.js +114 -0
  163. package/src/renderable/dragndrop.js +0 -109
  164. package/src/renderable/renderable.js +1 -1
  165. package/src/renderable/trigger.js +1 -1
  166. package/src/system/timer.js +3 -3
  167. package/src/utils/utils.js +102 -111
  168. package/src/video/video.js +3 -3
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
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
@@ -56,7 +56,7 @@ var check = function (it) {
56
56
  };
57
57
 
58
58
  // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
59
- var global$d =
59
+ var global$e =
60
60
  // eslint-disable-next-line es/no-global-this -- safe
61
61
  check(typeof globalThis == 'object' && globalThis) ||
62
62
  check(typeof window == 'object' && window) ||
@@ -64,9 +64,9 @@ var global$d =
64
64
  check(typeof self == 'object' && self) ||
65
65
  check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
66
66
  // eslint-disable-next-line no-new-func -- fallback
67
- (function () { return this; })() || Function('return this')();
67
+ (function () { return this; })() || commonjsGlobal || Function('return this')();
68
68
 
69
- var global$e = /*@__PURE__*/getDefaultExportFromCjs(global$d);
69
+ var global$f = /*@__PURE__*/getDefaultExportFromCjs(global$e);
70
70
 
71
71
  var objectGetOwnPropertyDescriptor = {};
72
72
 
@@ -253,7 +253,7 @@ var isObject$5 = $documentAll.IS_HTMLDDA ? function (it) {
253
253
 
254
254
  var isObject$6 = /*@__PURE__*/getDefaultExportFromCjs(isObject$5);
255
255
 
256
- var global$c = global$d;
256
+ var global$d = global$e;
257
257
  var isCallable$9 = isCallable$b;
258
258
 
259
259
  var aFunction = function (argument) {
@@ -261,7 +261,7 @@ var aFunction = function (argument) {
261
261
  };
262
262
 
263
263
  var getBuiltIn$2 = function (namespace, method) {
264
- return arguments.length < 2 ? aFunction(global$c[namespace]) : global$c[namespace] && global$c[namespace][method];
264
+ return arguments.length < 2 ? aFunction(global$d[namespace]) : global$d[namespace] && global$d[namespace][method];
265
265
  };
266
266
 
267
267
  var getBuiltIn$3 = /*@__PURE__*/getDefaultExportFromCjs(getBuiltIn$2);
@@ -276,11 +276,11 @@ var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAg
276
276
 
277
277
  var engineUserAgent$1 = /*@__PURE__*/getDefaultExportFromCjs(engineUserAgent);
278
278
 
279
- var global$b = global$d;
279
+ var global$c = global$e;
280
280
  var userAgent = engineUserAgent;
281
281
 
282
- var process = global$b.process;
283
- var Deno = global$b.Deno;
282
+ var process = global$c.process;
283
+ var Deno = global$c.Deno;
284
284
  var versions = process && process.versions || Deno && Deno.version;
285
285
  var v8 = versions && versions.v8;
286
286
  var match, version$1;
@@ -310,13 +310,18 @@ var engineV8Version$1 = /*@__PURE__*/getDefaultExportFromCjs(engineV8Version);
310
310
 
311
311
  var V8_VERSION = engineV8Version;
312
312
  var fails$5 = fails$9;
313
+ var global$b = global$e;
314
+
315
+ var $String$4 = global$b.String;
313
316
 
314
317
  // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
315
318
  var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$5(function () {
316
319
  var symbol = Symbol();
317
320
  // Chrome 38 Symbol has incorrect toString conversion
318
321
  // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
319
- return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
322
+ // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
323
+ // of course, fail.
324
+ return !$String$4(symbol) || !(Object(symbol) instanceof Symbol) ||
320
325
  // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
321
326
  !Symbol.sham && V8_VERSION && V8_VERSION < 41;
322
327
  });
@@ -410,7 +415,7 @@ var isPure = false;
410
415
 
411
416
  var isPure$1 = /*@__PURE__*/getDefaultExportFromCjs(isPure);
412
417
 
413
- var global$a = global$d;
418
+ var global$a = global$e;
414
419
 
415
420
  // eslint-disable-next-line es/no-object-defineproperty -- safe
416
421
  var defineProperty$1 = Object.defineProperty;
@@ -425,7 +430,7 @@ var defineGlobalProperty$3 = function (key, value) {
425
430
 
426
431
  var defineGlobalProperty$4 = /*@__PURE__*/getDefaultExportFromCjs(defineGlobalProperty$3);
427
432
 
428
- var global$9 = global$d;
433
+ var global$9 = global$e;
429
434
  var defineGlobalProperty$2 = defineGlobalProperty$3;
430
435
 
431
436
  var SHARED = '__core-js_shared__';
@@ -443,10 +448,10 @@ var store$2 = sharedStore;
443
448
  (shared$5.exports = function (key, value) {
444
449
  return store$2[key] || (store$2[key] = value !== undefined ? value : {});
445
450
  })('versions', []).push({
446
- version: '3.30.1',
451
+ version: '3.30.2',
447
452
  mode: IS_PURE ? 'pure' : 'global',
448
453
  copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
449
- license: 'https://github.com/zloirock/core-js/blob/v3.30.1/LICENSE',
454
+ license: 'https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE',
450
455
  source: 'https://github.com/zloirock/core-js'
451
456
  });
452
457
 
@@ -491,7 +496,7 @@ var uid$2 = function (key) {
491
496
 
492
497
  var uid$3 = /*@__PURE__*/getDefaultExportFromCjs(uid$2);
493
498
 
494
- var global$8 = global$d;
499
+ var global$8 = global$e;
495
500
  var shared$2 = sharedExports;
496
501
  var hasOwn$6 = hasOwnProperty_1;
497
502
  var uid$1 = uid$2;
@@ -552,7 +557,7 @@ var toPropertyKey$2 = function (argument) {
552
557
 
553
558
  var toPropertyKey$3 = /*@__PURE__*/getDefaultExportFromCjs(toPropertyKey$2);
554
559
 
555
- var global$7 = global$d;
560
+ var global$7 = global$e;
556
561
  var isObject$2 = isObject$5;
557
562
 
558
563
  var document$1 = global$7.document;
@@ -728,7 +733,7 @@ var inspectSource$1 = store$1.inspectSource;
728
733
 
729
734
  var inspectSource$2 = /*@__PURE__*/getDefaultExportFromCjs(inspectSource$1);
730
735
 
731
- var global$6 = global$d;
736
+ var global$6 = global$e;
732
737
  var isCallable$4 = isCallable$b;
733
738
 
734
739
  var WeakMap$1 = global$6.WeakMap;
@@ -753,7 +758,7 @@ var hiddenKeys$3 = {};
753
758
  var hiddenKeys$4 = /*@__PURE__*/getDefaultExportFromCjs(hiddenKeys$3);
754
759
 
755
760
  var NATIVE_WEAK_MAP = weakMapBasicDetection;
756
- var global$5 = global$d;
761
+ var global$5 = global$e;
757
762
  var isObject = isObject$5;
758
763
  var createNonEnumerableProperty$1 = createNonEnumerableProperty$2;
759
764
  var hasOwn$3 = hasOwnProperty_1;
@@ -1128,7 +1133,7 @@ var isForced_1 = isForced$1;
1128
1133
 
1129
1134
  var isForced$2 = /*@__PURE__*/getDefaultExportFromCjs(isForced_1);
1130
1135
 
1131
- var global$4 = global$d;
1136
+ var global$4 = global$e;
1132
1137
  var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
1133
1138
  var createNonEnumerableProperty = createNonEnumerableProperty$2;
1134
1139
  var defineBuiltIn = defineBuiltIn$1;
@@ -1186,7 +1191,7 @@ var _export = function (options, source) {
1186
1191
  var _export$1 = /*@__PURE__*/getDefaultExportFromCjs(_export);
1187
1192
 
1188
1193
  var $$4 = _export;
1189
- var global$3 = global$d;
1194
+ var global$3 = global$e;
1190
1195
 
1191
1196
  // `globalThis` object
1192
1197
  // https://tc39.es/ecma262/#sec-globalthis
@@ -1196,7 +1201,7 @@ $$4({ global: true, forced: global$3.globalThis !== global$3 }, {
1196
1201
 
1197
1202
  // https://github.com/tc39/proposal-global
1198
1203
 
1199
- var global$2 = global$d;
1204
+ var global$2 = global$e;
1200
1205
 
1201
1206
  var globalThis$1 = global$2;
1202
1207
 
@@ -1353,7 +1358,7 @@ $$2({ target: 'String', proto: true, name: 'trimStart', forced: ''.trimStart !==
1353
1358
  trimStart: trimStart$2
1354
1359
  });
1355
1360
 
1356
- var global$1 = global$d;
1361
+ var global$1 = global$e;
1357
1362
  var uncurryThis = functionUncurryThis;
1358
1363
 
1359
1364
  var entryUnbind$2 = function (CONSTRUCTOR, METHOD) {
@@ -8091,7 +8096,7 @@ function weightedRandom(arr) {
8091
8096
  return arr[weightedRandom$1(0, arr.length)];
8092
8097
  }
8093
8098
 
8094
- var arrayUtils = {
8099
+ var array$1 = {
8095
8100
  __proto__: null,
8096
8101
  random: random,
8097
8102
  remove: remove,
@@ -8997,201 +9002,6 @@ let collision = {
8997
9002
  rayCast(line, result) { return game.world.detector.rayCast(line, result); }
8998
9003
  };
8999
9004
 
9000
- /**
9001
- * a collection of string utility functions
9002
- * @namespace utils.string
9003
- */
9004
-
9005
- /**
9006
- * converts the first character of the given string to uppercase
9007
- * @public
9008
- * @memberof utils.string
9009
- * @name capitalize
9010
- * @param {string} str - the string to be capitalized
9011
- * @returns {string} the capitalized string
9012
- */
9013
- function capitalize(str) {
9014
- return str.charAt(0).toUpperCase() + str.slice(1);
9015
- }
9016
-
9017
- /**
9018
- * returns true if the given string contains a numeric integer or float value
9019
- * @public
9020
- * @memberof utils.string
9021
- * @name isNumeric
9022
- * @param {string} str - the string to be tested
9023
- * @returns {boolean} true if string contains only digits
9024
- */
9025
- function isNumeric(str) {
9026
- if (typeof str === "string") {
9027
- str = str.trim();
9028
- }
9029
- return !isNaN(str) && /^[+-]?(\d+(\.\d+)?|\.\d+)$/.test(str);
9030
- }
9031
-
9032
- /**
9033
- * returns true if the given string contains a true or false
9034
- * @public
9035
- * @memberof utils.string
9036
- * @name isBoolean
9037
- * @param {string} str - the string to be tested
9038
- * @returns {boolean} true if the string is either true or false
9039
- */
9040
- function isBoolean(str) {
9041
- const trimmed = str.trim();
9042
- return (trimmed === "true") || (trimmed === "false");
9043
- }
9044
-
9045
- /**
9046
- * convert a string to the corresponding hexadecimal value
9047
- * @public
9048
- * @memberof utils.string
9049
- * @name toHex
9050
- * @param {string} str - the string to be converted
9051
- * @returns {string} the converted hexadecimal value
9052
- */
9053
- function toHex(str) {
9054
- let res = "", c = 0;
9055
- while (c < str.length) {
9056
- res += str.charCodeAt(c++).toString(16);
9057
- }
9058
- return res;
9059
- }
9060
-
9061
- /**
9062
- * returns true if the given string is a data url in the `data:[<mediatype>][;base64],<data>` format.
9063
- * (this will not test the validity of the Data or Base64 encoding)
9064
- * @public
9065
- * @memberof utils.string
9066
- * @name isDataUrl
9067
- * @param {string} str - the string (url) to be tested
9068
- * @returns {boolean} true if the string is a data url
9069
- */
9070
- function isDataUrl(str) {
9071
- return /^data:(.+);base64,(.+)$/.test(str);
9072
- }
9073
-
9074
- var stringUtils = {
9075
- __proto__: null,
9076
- capitalize: capitalize,
9077
- isBoolean: isBoolean,
9078
- isDataUrl: isDataUrl,
9079
- isNumeric: isNumeric,
9080
- toHex: toHex
9081
- };
9082
-
9083
- /**
9084
- * a collection of utility functons to ease porting between different user agents.
9085
- * @namespace utils.agent
9086
- */
9087
-
9088
- /**
9089
- * Known agent vendors
9090
- * @ignore
9091
- */
9092
- const vendors = [ "ms", "MS", "moz", "webkit", "o" ];
9093
-
9094
- /**
9095
- * Get a vendor-prefixed property
9096
- * @public
9097
- * @name prefixed
9098
- * @param {string} name - Property name
9099
- * @param {object} [obj=globalThis] - Object or element reference to access
9100
- * @returns {string} Value of property
9101
- * @memberof utils.agent
9102
- */
9103
- function prefixed(name, obj) {
9104
- obj = obj || globalThis;
9105
- if (name in obj) {
9106
- return obj[name];
9107
- }
9108
-
9109
- let uc_name = capitalize(name);
9110
-
9111
- let result;
9112
- vendors.some((vendor) => {
9113
- let name = vendor + uc_name;
9114
- return (result = (name in obj) ? obj[name] : undefined);
9115
- });
9116
- return result;
9117
- }
9118
-
9119
- /**
9120
- * Set a vendor-prefixed property
9121
- * @public
9122
- * @name setPrefixed
9123
- * @param {string} name - Property name
9124
- * @param {string} value - Property value
9125
- * @param {object} [obj=globalThis] - Object or element reference to access
9126
- * @returns {boolean} true if one of the vendor-prefixed property was found
9127
- * @memberof utils.agent
9128
- */
9129
- function setPrefixed(name, value, obj) {
9130
- obj = obj || globalThis;
9131
- if (name in obj) {
9132
- obj[name] = value;
9133
- return;
9134
- }
9135
-
9136
- let uc_name = capitalize(name);
9137
-
9138
- vendors.some((vendor) => {
9139
- let name = vendor + uc_name;
9140
- if (name in obj) {
9141
- obj[name] = value;
9142
- return true;
9143
- }
9144
- });
9145
-
9146
- return false;
9147
- }
9148
-
9149
- var agentUtils = {
9150
- __proto__: null,
9151
- prefixed: prefixed,
9152
- setPrefixed: setPrefixed
9153
- };
9154
-
9155
- /**
9156
- * a collection of file utility functions
9157
- * @namespace utils.file
9158
- */
9159
-
9160
- // regexp to deal with file name & path
9161
- const REMOVE_PATH = /^.*(\\|\/|\:)/;
9162
- const REMOVE_EXT = /\.[^\.]*$/;
9163
-
9164
-
9165
- /**
9166
- * return the base name of the file without path info
9167
- * @public
9168
- * @memberof utils.file
9169
- * @name getBasename
9170
- * @param {string} path- - path containing the filename
9171
- * @returns {string} the base name without path information.
9172
- */
9173
- function getBasename(path) {
9174
- return path.replace(REMOVE_PATH, "").replace(REMOVE_EXT, "");
9175
- }
9176
-
9177
- /**
9178
- * return the extension of the file in the given path
9179
- * @public
9180
- * @memberof utils.file
9181
- * @name getExtension
9182
- * @param {string} path- - path containing the filename
9183
- * @returns {string} filename extension.
9184
- */
9185
- function getExtension(path) {
9186
- return path.substring(path.lastIndexOf(".") + 1, path.length);
9187
- }
9188
-
9189
- var fileUtils = {
9190
- __proto__: null,
9191
- getBasename: getBasename,
9192
- getExtension: getExtension
9193
- };
9194
-
9195
9005
  /**
9196
9006
  * a collection of utility functions
9197
9007
  * @namespace utils.function
@@ -9254,141 +9064,12 @@ function throttle(fn, delay, no_trailing) {
9254
9064
  };
9255
9065
  }
9256
9066
 
9257
- var fnUtils = {
9067
+ var _function = {
9258
9068
  __proto__: null,
9259
9069
  defer: defer,
9260
9070
  throttle: throttle
9261
9071
  };
9262
9072
 
9263
- /**
9264
- * a collection of utility functions
9265
- * @namespace utils
9266
- */
9267
-
9268
- // guid default value
9269
- let GUID_base = "";
9270
- let GUID_index = 0;
9271
-
9272
- let utils = {
9273
-
9274
- agent : agentUtils,
9275
- array : arrayUtils,
9276
- file : fileUtils,
9277
- string : stringUtils,
9278
- function : fnUtils,
9279
-
9280
- /**
9281
- * Compare two version strings
9282
- * @public
9283
- * @memberof utils
9284
- * @name checkVersion
9285
- * @param {string} first - First version string to compare
9286
- * @param {string} second - second version string to compare
9287
- * @returns {number} comparison result <br>&lt; 0 : first &lt; second<br>
9288
- * 0 : first == second<br>
9289
- * &gt; 0 : first &gt; second
9290
- * @example
9291
- * if (me.utils.checkVersion("7.0.0") > 0) {
9292
- * console.error(
9293
- * "melonJS is too old. Expected: 7.0.0, Got: 6.3.0"
9294
- * );
9295
- * }
9296
- */
9297
- checkVersion : function (first, second) {
9298
- let a = first.split(".");
9299
- let b = second.split(".");
9300
- let len = Math.min(a.length, b.length);
9301
- let result = 0;
9302
-
9303
- for (let i = 0; i < len; i++) {
9304
- if ((result = +a[i] - +b[i])) {
9305
- break;
9306
- }
9307
- }
9308
-
9309
- return result ? result : a.length - b.length;
9310
- },
9311
-
9312
- /**
9313
- * parse the fragment (hash) from a URL and returns them into
9314
- * @public
9315
- * @memberof utils
9316
- * @name getUriFragment
9317
- * @param {string} [url=document.location] - an optional params string or URL containing fragment (hash) params to be parsed
9318
- * @returns {object} an object representing the deserialized params string.
9319
- * @property {boolean} [hitbox=false] draw the hitbox in the debug panel (if enabled)
9320
- * @property {boolean} [velocity=false] draw the entities velocity in the debug panel (if enabled)
9321
- * @property {boolean} [quadtree=false] draw the quadtree in the debug panel (if enabled)
9322
- * @property {boolean} [webgl=false] force the renderer to WebGL
9323
- * @property {boolean} [debug=false] display the debug panel (if preloaded)
9324
- * @property {string} [debugToggleKey="s"] show/hide the debug panel (if preloaded)
9325
- * @example
9326
- * // http://www.example.com/index.html#debug&hitbox=true&mytag=value
9327
- * let UriFragment = me.utils.getUriFragment();
9328
- * console.log(UriFragment["mytag"]); //> "value"
9329
- */
9330
- getUriFragment : function (url) {
9331
- let hash = {};
9332
-
9333
- if (typeof url === "undefined") {
9334
- if (typeof globalThis.document !== "undefined") {
9335
- let location = globalThis.document.location;
9336
-
9337
- if (location && location.hash) {
9338
- url = location.hash;
9339
- } else {
9340
- // No "document.location" exist for Wechat mini game platform.
9341
- return hash;
9342
- }
9343
- } else {
9344
- // "document" undefined on node.js
9345
- return hash;
9346
- }
9347
- } else {
9348
- // never cache if a url is passed as parameter
9349
- let index = url.indexOf("#");
9350
- if (index !== -1) {
9351
- url = url.slice(index, url.length);
9352
- } else {
9353
- return hash;
9354
- }
9355
- }
9356
-
9357
- // parse the url
9358
- url.slice(1).split("&").filter((value) => value !== "").forEach((value) => {
9359
- let kv = value.split("=");
9360
- let k = kv.shift();
9361
- let v = kv.join("=");
9362
- hash[k] = v || true;
9363
- });
9364
-
9365
- return hash;
9366
- },
9367
-
9368
- /**
9369
- * reset the GUID Base Name
9370
- * the idea here being to have a unique ID
9371
- * per level / object
9372
- * @ignore
9373
- */
9374
- resetGUID : function (base, index = 0) {
9375
- // also ensure it's only 8bit ASCII characters
9376
- GUID_base = toHex(base.toString().toUpperCase());
9377
- GUID_index = index;
9378
- },
9379
-
9380
- /**
9381
- * create and return a very simple GUID
9382
- * Game Unique ID
9383
- * @ignore
9384
- */
9385
- createGUID : function (index = 1) {
9386
- // to cover the case of undefined id for groups
9387
- GUID_index += index;
9388
- return GUID_base + "-" + (index || GUID_index);
9389
- }
9390
- };
9391
-
9392
9073
  var eventemitter3$1 = {exports: {}};
9393
9074
 
9394
9075
  var eventemitter3 = eventemitter3$1.exports;
@@ -13637,6 +13318,89 @@ function setBaseURL(type, url) {
13637
13318
  }
13638
13319
  }
13639
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
+
13640
13404
  // external import
13641
13405
 
13642
13406
  /**
@@ -14317,7 +14081,7 @@ function init(width, height, options) {
14317
14081
  //add a channel for the onresize/onorientationchange event
14318
14082
  globalThis.addEventListener(
14319
14083
  "resize",
14320
- utils.function.throttle(
14084
+ throttle(
14321
14085
  (e) => {
14322
14086
  emit(WINDOW_ONRESIZE, e);
14323
14087
  }, 100
@@ -14349,7 +14113,7 @@ function init(width, height, options) {
14349
14113
  }
14350
14114
 
14351
14115
  // Automatically update relative canvas position on scroll
14352
- globalThis.addEventListener("scroll", utils.function.throttle((e) => {
14116
+ globalThis.addEventListener("scroll", throttle((e) => {
14353
14117
  emit(WINDOW_ONSCROLL, e);
14354
14118
  }, 100), false);
14355
14119
 
@@ -14556,6 +14320,78 @@ let save = {
14556
14320
  }
14557
14321
  };
14558
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
+
14559
14395
  /**
14560
14396
  * The device platform type
14561
14397
  * @namespace platform
@@ -18474,7 +18310,7 @@ var input = {
18474
18310
  * onCollision callback, triggered in case of collision,
18475
18311
  * when this renderable body is colliding with another one
18476
18312
  * @param {ResponseObject} response - the collision response object
18477
- * @param {Renderable} other - the other renderable touching this one (a reference to response.a or response.b)
18313
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} other - the other renderable touching this one (a reference to response.a or response.b)
18478
18314
  * @returns {boolean} true if the object should respond to the collision (its position and velocity will be corrected)
18479
18315
  * @example
18480
18316
  * // colision handler
@@ -19121,7 +18957,7 @@ let targetV = new Vector2d();
19121
18957
  * set the camera position around the specified object
19122
18958
  * @name focusOn
19123
18959
  * @memberof Camera2d
19124
- * @param {Renderable} target - the renderable to focus the camera on
18960
+ * @param {Renderable|Entity|Sprite|NineSliceSprite} target - the renderable to focus the camera on
19125
18961
  */
19126
18962
  focusOn(target) {
19127
18963
  let bounds = target.getBounds();
@@ -19135,7 +18971,7 @@ let targetV = new Vector2d();
19135
18971
  * check if the specified renderable is in the camera
19136
18972
  * @name isVisible
19137
18973
  * @memberof Camera2d
19138
- * @param {Renderable} obj - to be checked against
18974
+ * @param {Renderable|Entity|Sprite|NineSliceSprite} obj - to be checked against
19139
18975
  * @param {boolean} [floating = obj.floating] - if visibility check should be done against screen coordinates
19140
18976
  * @returns {boolean}
19141
18977
  */
@@ -19495,6 +19331,46 @@ let default_settings = {
19495
19331
  }
19496
19332
  }
19497
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
+
19498
19374
  /**
19499
19375
  * where all preloaded content is cached
19500
19376
  */
@@ -19511,6 +19387,139 @@ let binList = {};
19511
19387
  // contains all the JSON files
19512
19388
  let jsonList = {};
19513
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
+
19514
19523
  /**
19515
19524
  * @classdesc
19516
19525
  * a TMX Tile Set Object
@@ -19890,11 +19899,11 @@ function setTMXValue(name, type, value) {
19890
19899
 
19891
19900
  default :
19892
19901
  // try to parse it anyway
19893
- if (!value || utils.string.isBoolean(value)) {
19902
+ if (!value || isBoolean(value)) {
19894
19903
  // if value not defined or boolean
19895
19904
  value = value ? (value === "true") : true;
19896
19905
  }
19897
- else if (utils.string.isNumeric(value)) {
19906
+ else if (isNumeric(value)) {
19898
19907
  // check if numeric
19899
19908
  value = Number(value);
19900
19909
  }
@@ -19969,8 +19978,8 @@ function parseAttributes(obj, elt) {
19969
19978
  * @returns {Uint32Array} Decoded and decompress data
19970
19979
  */
19971
19980
  function decompress(data, format) {
19972
- if (typeof utils.inflateb64 === "function") {
19973
- return utils.inflateb64(data, format);
19981
+ if (typeof undefined === "function") {
19982
+ return undefined(data, format);
19974
19983
  } else {
19975
19984
  throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
19976
19985
  }
@@ -23672,7 +23681,7 @@ let globalFloatingCounter = 0;
23672
23681
  * will not be in any container. <br>
23673
23682
  * if the given child implements a onActivateEvent method, that method will be called
23674
23683
  * once the child is added to this container.
23675
- * @param {Renderable} child
23684
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
23676
23685
  * @param {number} [z] - forces the z index of the child to the specified value
23677
23686
  * @returns {Renderable} the added child
23678
23687
  */
@@ -23685,7 +23694,7 @@ let globalFloatingCounter = 0;
23685
23694
  // (e.g. move one child from one container to another)
23686
23695
  if (child.isRenderable) {
23687
23696
  // allocated a GUID value (use child.id as based index if defined)
23688
- child.GUID = utils.createGUID(child.id);
23697
+ child.GUID = createGUID(child.id);
23689
23698
  }
23690
23699
  }
23691
23700
 
@@ -23754,7 +23763,7 @@ let globalFloatingCounter = 0;
23754
23763
  /**
23755
23764
  * Add a child to the container at the specified index<br>
23756
23765
  * (the list won't be sorted after insertion)
23757
- * @param {Renderable} child
23766
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
23758
23767
  * @param {number} index
23759
23768
  * @returns {Renderable} the added child
23760
23769
  */
@@ -23768,7 +23777,7 @@ let globalFloatingCounter = 0;
23768
23777
  // (e.g. move one child from one container to another)
23769
23778
  if (child.isRenderable) {
23770
23779
  // allocated a GUID value
23771
- child.GUID = utils.createGUID();
23780
+ child.GUID = createGUID();
23772
23781
  }
23773
23782
  }
23774
23783
 
@@ -23865,8 +23874,8 @@ let globalFloatingCounter = 0;
23865
23874
 
23866
23875
  /**
23867
23876
  * Swaps the position (z-index) of 2 children
23868
- * @param {Renderable} child
23869
- * @param {Renderable} child2
23877
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
23878
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child2
23870
23879
  */
23871
23880
  swapChildren(child, child2) {
23872
23881
  let index = this.getChildIndex(child);
@@ -23904,7 +23913,7 @@ let globalFloatingCounter = 0;
23904
23913
 
23905
23914
  /**
23906
23915
  * Returns the index of the given Child
23907
- * @param {Renderable} child
23916
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
23908
23917
  * @returns {number} index
23909
23918
  */
23910
23919
  getChildIndex(child) {
@@ -23913,7 +23922,7 @@ let globalFloatingCounter = 0;
23913
23922
 
23914
23923
  /**
23915
23924
  * Returns the next child within the container or undefined if none
23916
- * @param {Renderable} child
23925
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
23917
23926
  * @returns {Renderable} child
23918
23927
  */
23919
23928
  getNextChild(child) {
@@ -23926,7 +23935,7 @@ let globalFloatingCounter = 0;
23926
23935
 
23927
23936
  /**
23928
23937
  * Returns true if contains the specified Child
23929
- * @param {Renderable} child
23938
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
23930
23939
  * @returns {boolean}
23931
23940
  */
23932
23941
  hasChild(child) {
@@ -24134,12 +24143,12 @@ let globalFloatingCounter = 0;
24134
24143
  /**
24135
24144
  * Invokes the removeChildNow in a defer, to ensure the child is removed safely after the update & draw stack has completed. <br>
24136
24145
  * if the given child implements a onDeactivateEvent() method, that method will be called once the child is removed from this container.
24137
- * @param {Renderable} child
24146
+ * @param {RendRenderable|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapTexterable} child
24138
24147
  * @param {boolean} [keepalive=false] - true to prevent calling child.destroy()
24139
24148
  */
24140
24149
  removeChild(child, keepalive) {
24141
24150
  if (this.hasChild(child)) {
24142
- utils.function.defer(deferredRemove, this, child, keepalive);
24151
+ defer(deferredRemove, this, child, keepalive);
24143
24152
  }
24144
24153
  else {
24145
24154
  throw new Error("Child is not mine.");
@@ -24150,7 +24159,7 @@ let globalFloatingCounter = 0;
24150
24159
  * Removes (and optionally destroys) a child from the container.<br>
24151
24160
  * (removal is immediate and unconditional)<br>
24152
24161
  * Never use keepalive=true with objects from {@link pool}. Doing so will create a memory leak.
24153
- * @param {Renderable} child
24162
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
24154
24163
  * @param {boolean} [keepalive=False] - True to prevent calling child.destroy()
24155
24164
  */
24156
24165
  removeChildNow(child, keepalive) {
@@ -24213,7 +24222,7 @@ let globalFloatingCounter = 0;
24213
24222
 
24214
24223
  /**
24215
24224
  * Move the child in the group one step forward (z depth).
24216
- * @param {Renderable} child
24225
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
24217
24226
  */
24218
24227
  moveUp(child) {
24219
24228
  let childIndex = this.getChildIndex(child);
@@ -24227,7 +24236,7 @@ let globalFloatingCounter = 0;
24227
24236
 
24228
24237
  /**
24229
24238
  * Move the child in the group one step backward (z depth).
24230
- * @param {Renderable} child
24239
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
24231
24240
  */
24232
24241
  moveDown(child) {
24233
24242
  let childIndex = this.getChildIndex(child);
@@ -24241,7 +24250,7 @@ let globalFloatingCounter = 0;
24241
24250
 
24242
24251
  /**
24243
24252
  * Move the specified child to the top(z depth).
24244
- * @param {Renderable} child
24253
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
24245
24254
  */
24246
24255
  moveToTop(child) {
24247
24256
  let childIndex = this.getChildIndex(child);
@@ -24258,7 +24267,7 @@ let globalFloatingCounter = 0;
24258
24267
 
24259
24268
  /**
24260
24269
  * Move the specified child the bottom (z depth).
24261
- * @param {Renderable} child
24270
+ * @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
24262
24271
  */
24263
24272
  moveToBottom(child) {
24264
24273
  let childIndex = this.getChildIndex(child);
@@ -24290,7 +24299,7 @@ let globalFloatingCounter = 0;
24290
24299
  });
24291
24300
  }
24292
24301
  /** @ignore */
24293
- this.pendingSort = utils.function.defer(function () {
24302
+ this.pendingSort = defer(function () {
24294
24303
  // sort everything in this container
24295
24304
  this.getChildren().sort(this["_sort" + this.sortOn.toUpperCase()]);
24296
24305
  // clear the defer id
@@ -25755,7 +25764,7 @@ function readObjectGroup(map, data, z) {
25755
25764
  // if version is undefined or empty it usually means the map was not created with Tiled
25756
25765
  if (this.version !== "undefined" && this.version !== "") {
25757
25766
  // deprecation warning if map tiled version is older than 1.5
25758
- if (utils.checkVersion(this.version, "1.5") < 0) {
25767
+ if (checkVersion(this.version, "1.5") < 0) {
25759
25768
  warning("("+this.name+") Tiled Map format version 1.4 and below", "format 1.5 or higher", "10.4.4");
25760
25769
  }
25761
25770
  }
@@ -26180,7 +26189,7 @@ function loadTMXLevel(levelId, container, flatten, setViewportBounds) {
26180
26189
 
26181
26190
  // reset the GUID generator
26182
26191
  // and pass the level id as parameter
26183
- utils.resetGUID(levelId, level.nextobjectid);
26192
+ resetGUID(levelId, level.nextobjectid);
26184
26193
 
26185
26194
  // Tiled use 0,0 anchor coordinates
26186
26195
  container.anchorPoint.set(0, 0);
@@ -26296,7 +26305,7 @@ let level = {
26296
26305
  // some silly side effects
26297
26306
  state$1.stop();
26298
26307
 
26299
- utils.function.defer(safeLoadLevel, this, levelId, options, true);
26308
+ defer(safeLoadLevel, this, levelId, options, true);
26300
26309
  }
26301
26310
  else {
26302
26311
  safeLoadLevel(levelId, options);
@@ -28558,7 +28567,7 @@ class Timer {
28558
28567
  */
28559
28568
  clearTimeout(timeoutID) {
28560
28569
  if (timeoutID > 0) {
28561
- utils.function.defer(this.clearTimer.bind(this), this, timeoutID);
28570
+ defer(this.clearTimer.bind(this), this, timeoutID);
28562
28571
  }
28563
28572
  }
28564
28573
 
@@ -28568,7 +28577,7 @@ class Timer {
28568
28577
  */
28569
28578
  clearInterval(intervalID) {
28570
28579
  if (intervalID > 0) {
28571
- utils.function.defer(this.clearTimer.bind(this), this, intervalID);
28580
+ defer(this.clearTimer.bind(this), this, intervalID);
28572
28581
  }
28573
28582
  }
28574
28583
 
@@ -28684,7 +28693,7 @@ var timer$1 = timer;
28684
28693
  */
28685
28694
  class Body {
28686
28695
  /**
28687
- * @param {Renderable} ancestor - the parent object this body is attached to
28696
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} ancestor - the parent object this body is attached to
28688
28697
  * @param {Rect|Rect[]|Polygon|Polygon[]|Line|Line[]|Ellipse|Ellipse[]|Point|Point[]|Bounds|Bounds[]|object} [shapes] - a initial shape, list of shapes, or JSON object defining the body
28689
28698
  * @param {Function} [onBodyUpdate] - callback for when the body is updated (e.g. add/remove shapes)
28690
28699
  */
@@ -28694,7 +28703,7 @@ var timer$1 = timer;
28694
28703
  * a reference to the parent object that contains this body,
28695
28704
  * or undefined if it has not been added to one.
28696
28705
  * @public
28697
- * @type {Renderable}
28706
+ * @type {Renderable|Container|Entity|Sprite|NineSliceSprite}
28698
28707
  * @default undefined
28699
28708
  */
28700
28709
  this.ancestor = ancestor;
@@ -34925,7 +34934,7 @@ const toPX = [12, 24, 0.75, 1];
34925
34934
  * @name onCollision
34926
34935
  * @memberof Trigger
34927
34936
  * @param {ResponseObject} response - the collision response object
34928
- * @param {Renderable} other - the other renderable touching this one (a reference to response.a or response.b)
34937
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} other - the other renderable touching this one (a reference to response.a or response.b)
34929
34938
  * @returns {boolean} true if the object should respond to the collision (its position and velocity will be corrected)
34930
34939
  */
34931
34940
  onCollision(response, other) { // eslint-disable-line no-unused-vars
@@ -35725,9 +35734,9 @@ function vornoiRegion(line, point) {
35725
35734
  /**
35726
35735
  * Checks whether polygons collide.
35727
35736
  * @ignore
35728
- * @param {Renderable} a - a reference to the object A.
35737
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
35729
35738
  * @param {Polygon} polyA - a reference to the object A Polygon to be tested
35730
- * @param {Renderable} b - a reference to the object B.
35739
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
35731
35740
  * @param {Polygon} polyB - a reference to the object B Polygon to be tested
35732
35741
  * @param {Response=} response - Response object (optional) that will be populated if they intersect.
35733
35742
  * @returns {boolean} true if they intersect, false if they don't.
@@ -35779,9 +35788,9 @@ function testPolygonPolygon(a, polyA, b, polyB, response) {
35779
35788
  /**
35780
35789
  * Check if two Ellipse collide.
35781
35790
  * @ignore
35782
- * @param {Renderable} a - a reference to the object A.
35791
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
35783
35792
  * @param {Ellipse} ellipseA - a reference to the object A Ellipse to be tested
35784
- * @param {Renderable} b - a reference to the object B.
35793
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
35785
35794
  * @param {Ellipse} ellipseB - a reference to the object B Ellipse to be tested
35786
35795
  * @param {Response=} response - Response object (optional) that will be populated if
35787
35796
  * the circles intersect.
@@ -35820,9 +35829,9 @@ function testEllipseEllipse(a, ellipseA, b, ellipseB, response) {
35820
35829
  /**
35821
35830
  * Check if a polygon and an ellipse collide.
35822
35831
  * @ignore
35823
- * @param {Renderable} a - a reference to the object A.
35832
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
35824
35833
  * @param {Polygon} polyA - a reference to the object A Polygon to be tested
35825
- * @param {Renderable} b - a reference to the object B.
35834
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
35826
35835
  * @param {Ellipse} ellipseB - a reference to the object B Ellipse to be tested
35827
35836
  * @param {Response=} response - Response object (optional) that will be populated if they intersect.
35828
35837
  * @returns {boolean} true if they intersect, false if they don't.
@@ -35986,9 +35995,9 @@ function testPolygonEllipse(a, polyA, b, ellipseB, response) {
35986
35995
  * **NOTE:** This is slightly less efficient than testPolygonEllipse as it just
35987
35996
  * runs testPolygonEllipse and reverses the response at the end.
35988
35997
  * @ignore
35989
- * @param {Renderable} a - a reference to the object A.
35998
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
35990
35999
  * @param {Ellipse} ellipseA - a reference to the object A Ellipse to be tested
35991
- * @param {Renderable} b - a reference to the object B.
36000
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
35992
36001
  * @param {Polygon} polyB - a reference to the object B Polygon to be tested
35993
36002
  * @param {Response=} response - Response object (optional) that will be populated if
35994
36003
  * they intersect.
@@ -36103,8 +36112,8 @@ class Detector {
36103
36112
  /**
36104
36113
  * determine if two objects should collide (based on both respective objects body collision mask and type).<br>
36105
36114
  * you can redefine this function if you need any specific rules over what should collide with what.
36106
- * @param {Renderable} a - a reference to the object A.
36107
- * @param {Renderable} b - a reference to the object B.
36115
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
36116
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
36108
36117
  * @returns {boolean} true if they should collide, false otherwise
36109
36118
  */
36110
36119
  shouldCollide(a, b) {
@@ -36157,7 +36166,7 @@ class Detector {
36157
36166
  /**
36158
36167
  * find all the collisions for the specified object using a broadphase algorithm
36159
36168
  * @ignore
36160
- * @param {Renderable} objA - object to be tested for collision
36169
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} objA - object to be tested for collision
36161
36170
  * @returns {boolean} in case of collision, false otherwise
36162
36171
  */
36163
36172
  collisions(objA) {
@@ -37762,7 +37771,7 @@ function consoleHeader(app) {
37762
37771
  }
37763
37772
 
37764
37773
  // override renderer settings if &webgl or &canvas is defined in the URL
37765
- let uriFragment = utils.getUriFragment();
37774
+ let uriFragment = getUriFragment();
37766
37775
  if (uriFragment.webgl === true || uriFragment.webgl1 === true || uriFragment.webgl2 === true) {
37767
37776
  this.settings.renderer = WEBGL$1;
37768
37777
  if (uriFragment.webgl1 === true) {
@@ -37990,133 +37999,140 @@ function consoleHeader(app) {
37990
37999
  }
37991
38000
 
37992
38001
  /**
37993
- * This namespace is a container for all registered plugins.
37994
- * @see plugin.register
37995
- * @namespace plugins
38002
+ * Contains all registered plugins.
38003
+ * @name cache
38004
+ * @memberof plugin
37996
38005
  */
37997
- let plugins = {};
38006
+ let cache = {};
37998
38007
 
38008
+ /**
38009
+ * @namespace plugin
38010
+ */
37999
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
+ */
38000
38019
  class BasePlugin {
38001
38020
 
38002
38021
  constructor() {
38003
38022
  /**
38004
38023
  * define the minimum required version of melonJS<br>
38005
38024
  * this can be overridden by the plugin
38006
- * @public
38007
38025
  * @type {string}
38008
- * @default "15.1.5"
38009
- * @name plugin.Base#version
38026
+ * @default "15.2.0"
38010
38027
  */
38011
- this.version = "15.1.5";
38028
+ this.version = "15.2.0";
38012
38029
  }
38013
38030
  }
38014
38031
 
38032
+
38015
38033
  /**
38016
- * @namespace plugin
38034
+ * @class
38035
+ * @name Base
38036
+ * @memberof plugin
38037
+ * @deprecated since 15.1.6, see {@link plugin.BasePlugin}
38017
38038
  */
38018
- let plugin = {
38039
+ class Base extends BasePlugin {}
38019
38040
 
38020
- /**
38021
- * a base Object for plugin <br>
38022
- * plugin must be installed using the register function
38023
- * @see plugin
38024
- * @class
38025
- * @name Base
38026
- * @memberof plugin
38027
- */
38028
- 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
+ }
38029
38083
 
38030
- /**
38031
- * patch a melonJS function
38032
- * @name patch
38033
- * @memberof plugin
38034
- * @public
38035
- * @param {object} proto - target object
38036
- * @param {string} name - target function
38037
- * @param {Function} fn - replacement function
38038
- * @example
38039
- * // redefine the me.game.update function with a new one
38040
- * me.plugin.patch(me.game, "update", function () {
38041
- * // display something in the console
38042
- * console.log("duh");
38043
- * // call the original me.game.update function
38044
- * this._patched();
38045
- * });
38046
- */
38047
- patch : function (proto, name, fn) {
38048
- // use the object prototype if possible
38049
- if (typeof proto.prototype !== "undefined") {
38050
- proto = proto.prototype;
38051
- }
38052
- // reuse the logic behind object extends
38053
- if (typeof(proto[name]) === "function") {
38054
- // save the original function
38055
- let _parent = proto[name];
38056
- // override the function with the new one
38057
- Object.defineProperty(proto, name, {
38058
- "configurable" : true,
38059
- "value" : (function (name, fn) {
38060
- return function () {
38061
- this._patched = _parent;
38062
- let ret = fn.apply(this, arguments);
38063
- this._patched = null;
38064
- return ret;
38065
- };
38066
- })(name, fn)
38067
- });
38068
- }
38069
- else {
38070
- throw new Error(name + " is not an existing function");
38071
- }
38072
- },
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
+ }
38073
38103
 
38074
- /**
38075
- * Register a plugin.
38076
- * @name register
38077
- * @memberof plugin
38078
- * @see Base
38079
- * @public
38080
- * @param {plugin.Base} pluginObj - Plugin object to instantiate and register
38081
- * @param {string} [name=pluginObj.constructor.name] - a unique name for this plugin
38082
- * @param {object} [...arguments] - all extra parameters will be passed to the plugin constructor
38083
- * @example
38084
- * // register a new plugin
38085
- * me.plugin.register(TestPlugin, "testPlugin");
38086
- * // the plugin then also become available
38087
- * // under then me.plugins namespace
38088
- * me.plugins.testPlugin.myfunction ();
38089
- */
38090
- register : function (pluginObj, name = pluginObj.toString().match(/ (\w+)/)[1]) {
38091
- // ensure me.plugins[name] is not already "used"
38092
- if (plugins[name]) {
38093
- throw new Error("plugin " + name + " already registered");
38094
- }
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
+ }
38095
38110
 
38096
- // get extra arguments
38097
- let _args = [];
38098
- if (arguments.length > 2) {
38099
- // store extra arguments if any
38100
- _args = Array.prototype.slice.call(arguments, 1);
38101
- }
38111
+ // try to instantiate the plugin
38112
+ _args[0] = plugin;
38113
+ let instance = new (plugin.bind.apply(plugin, _args))();
38102
38114
 
38103
- // try to instantiate the plugin
38104
- _args[0] = pluginObj;
38105
- 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
+ }
38106
38119
 
38107
- // inheritance check
38108
- if (typeof instance === "undefined" || !(instance instanceof plugin.Base)) {
38109
- throw new Error("Plugin should extend the me.plugin.Base Class !");
38110
- }
38120
+ // compatibility testing
38121
+ if (checkVersion(instance.version, version) > 0) {
38122
+ throw new Error("Plugin version mismatch, expected: " + instance.version + ", got: " + version);
38123
+ }
38111
38124
 
38112
- // compatibility testing
38113
- if (utils.checkVersion(instance.version, version) > 0) {
38114
- throw new Error("Plugin version mismatch, expected: " + instance.version + ", got: " + version);
38115
- }
38125
+ // create a reference to the new plugin
38126
+ cache[name] = instance;
38127
+ }
38116
38128
 
38117
- // create a reference to the new plugin
38118
- plugins[name] = instance;
38119
- }
38129
+ var plugin = {
38130
+ __proto__: null,
38131
+ Base: Base,
38132
+ BasePlugin: BasePlugin,
38133
+ cache: cache,
38134
+ patch: patch,
38135
+ register: register
38120
38136
  };
38121
38137
 
38122
38138
  /*
@@ -38236,7 +38252,7 @@ Renderer.prototype.getScreenContext = function() {
38236
38252
  * @name version
38237
38253
  * @type {string}
38238
38254
  */
38239
- const version = "15.1.5";
38255
+ const version = "15.2.0";
38240
38256
 
38241
38257
  /**
38242
38258
  * a flag indicating that melonJS is fully initialized
@@ -38344,7 +38360,7 @@ function boot() {
38344
38360
  emit(BOOT);
38345
38361
 
38346
38362
  // enable/disable the cache
38347
- setNocache( utils.getUriFragment().nocache || false );
38363
+ setNocache( getUriFragment().nocache || false );
38348
38364
 
38349
38365
  // automatically enable keyboard events
38350
38366
  initKeyboardEvent();
@@ -38365,4 +38381,4 @@ onReady(() => {
38365
38381
  }
38366
38382
  });
38367
38383
 
38368
- 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 };