melonjs 13.4.0 → 14.0.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 (99) hide show
  1. package/README.md +4 -6
  2. package/dist/melonjs.module.d.ts +13108 -11652
  3. package/dist/melonjs.module.js +581 -128
  4. package/package.json +21 -21
  5. package/src/application/application.js +3 -3
  6. package/src/audio/audio.js +27 -27
  7. package/src/camera/camera2d.js +1 -2
  8. package/src/entity/entity.js +1 -2
  9. package/src/geometries/ellipse.js +1 -2
  10. package/src/geometries/line.js +2 -3
  11. package/src/geometries/poly.js +2 -2
  12. package/src/geometries/rectangle.js +1 -3
  13. package/src/geometries/roundrect.js +1 -2
  14. package/src/index.js +8 -4
  15. package/src/input/gamepad.js +12 -12
  16. package/src/input/keyboard.js +8 -8
  17. package/src/input/pointer.js +1 -1
  18. package/src/input/pointerevent.js +9 -9
  19. package/src/lang/deprecated.js +21 -2
  20. package/src/level/level.js +2 -2
  21. package/src/level/tiled/TMXGroup.js +1 -1
  22. package/src/level/tiled/TMXLayer.js +1 -1
  23. package/src/level/tiled/TMXTile.js +2 -2
  24. package/src/level/tiled/TMXTileMap.js +4 -4
  25. package/src/level/tiled/TMXTileset.js +2 -2
  26. package/src/level/tiled/TMXTilesetGroup.js +1 -1
  27. package/src/level/tiled/TMXUtils.js +7 -7
  28. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  29. package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  30. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  31. package/src/level/tiled/renderer/TMXRenderer.js +1 -1
  32. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  33. package/src/loader/loader.js +9 -9
  34. package/src/loader/loadingscreen.js +2 -2
  35. package/src/math/color.js +3 -3
  36. package/src/math/math.js +10 -10
  37. package/src/math/matrix2.js +1 -1
  38. package/src/math/matrix3.js +1 -1
  39. package/src/math/observable_vector2.js +1 -1
  40. package/src/math/observable_vector3.js +1 -1
  41. package/src/math/vector2.js +1 -1
  42. package/src/math/vector3.js +1 -1
  43. package/src/particles/emitter.js +2 -2
  44. package/src/particles/particle.js +1 -1
  45. package/src/physics/body.js +2 -2
  46. package/src/physics/bounds.js +1 -1
  47. package/src/physics/detector.js +3 -3
  48. package/src/physics/quadtree.js +2 -2
  49. package/src/physics/world.js +2 -2
  50. package/src/polyfill/performance.js +1 -1
  51. package/src/polyfill/requestAnimationFrame.js +1 -1
  52. package/src/renderable/collectable.js +1 -1
  53. package/src/renderable/colorlayer.js +1 -1
  54. package/src/renderable/container.js +10 -6
  55. package/src/renderable/dragndrop.js +2 -2
  56. package/src/renderable/imagelayer.js +1 -2
  57. package/src/renderable/light2d.js +1 -1
  58. package/src/renderable/nineslicesprite.js +1 -2
  59. package/src/renderable/renderable.js +1 -3
  60. package/src/renderable/sprite.js +3 -4
  61. package/src/renderable/trigger.js +3 -4
  62. package/src/renderable/ui/uibaseelement.js +204 -0
  63. package/src/renderable/{GUI.js → ui/uispriteelement.js} +8 -35
  64. package/src/renderable/ui/uitextbutton.js +121 -0
  65. package/src/state/stage.js +4 -5
  66. package/src/system/device.js +27 -27
  67. package/src/system/dom.js +1 -1
  68. package/src/system/event.js +4 -4
  69. package/src/system/pooling.js +2 -3
  70. package/src/system/save.js +2 -2
  71. package/src/system/timer.js +1 -1
  72. package/src/text/bitmaptext.js +2 -3
  73. package/src/text/bitmaptextdata.js +4 -7
  74. package/src/text/glyph.js +1 -2
  75. package/src/text/text.js +2 -3
  76. package/src/text/textstyle.js +1 -1
  77. package/src/tweens/tween.js +2 -3
  78. package/src/utils/agent.js +4 -4
  79. package/src/utils/array.js +3 -3
  80. package/src/utils/file.js +2 -2
  81. package/src/utils/function.js +3 -3
  82. package/src/utils/string.js +5 -5
  83. package/src/utils/utils.js +2 -2
  84. package/src/video/canvas/canvas_renderer.js +1 -2
  85. package/src/video/renderer.js +2 -3
  86. package/src/video/texture/atlas.js +2 -2
  87. package/src/video/texture/cache.js +1 -2
  88. package/src/video/video.js +12 -14
  89. package/src/video/webgl/buffer/vertex.js +1 -2
  90. package/src/video/webgl/glshader.js +1 -2
  91. package/src/video/webgl/utils/attributes.js +1 -1
  92. package/src/video/webgl/utils/precision.js +1 -1
  93. package/src/video/webgl/utils/program.js +2 -2
  94. package/src/video/webgl/utils/string.js +1 -1
  95. package/src/video/webgl/utils/uniforms.js +3 -3
  96. package/src/video/webgl/webgl_compositor.js +1 -2
  97. package/src/video/webgl/webgl_renderer.js +1 -2
  98. package/dist/melonjs.js +0 -37922
  99. package/dist/melonjs.min.js +0 -29
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v13.4.0
2
+ * melonJS Game Engine - v14.0.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
@@ -85,33 +85,40 @@ var createPropertyDescriptor$2 = function (bitmap, value) {
85
85
  var NATIVE_BIND = functionBindNative;
86
86
 
87
87
  var FunctionPrototype$1 = Function.prototype;
88
- var bind = FunctionPrototype$1.bind;
89
88
  var call$3 = FunctionPrototype$1.call;
90
- var uncurryThis$b = NATIVE_BIND && bind.bind(call$3, call$3);
89
+ var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype$1.bind.bind(call$3, call$3);
91
90
 
92
- var functionUncurryThis = NATIVE_BIND ? function (fn) {
93
- return fn && uncurryThis$b(fn);
94
- } : function (fn) {
95
- return fn && function () {
91
+ var functionUncurryThisRaw = function (fn) {
92
+ return NATIVE_BIND ? uncurryThisWithBind(fn) : function () {
96
93
  return call$3.apply(fn, arguments);
97
94
  };
98
95
  };
99
96
 
100
- var uncurryThis$a = functionUncurryThis;
97
+ var uncurryThisRaw$1 = functionUncurryThisRaw;
101
98
 
102
- var toString$4 = uncurryThis$a({}.toString);
103
- var stringSlice = uncurryThis$a(''.slice);
99
+ var toString$4 = uncurryThisRaw$1({}.toString);
100
+ var stringSlice = uncurryThisRaw$1(''.slice);
104
101
 
105
- var classofRaw$1 = function (it) {
102
+ var classofRaw$2 = function (it) {
106
103
  return stringSlice(toString$4(it), 8, -1);
107
104
  };
108
105
 
109
- var uncurryThis$9 = functionUncurryThis;
106
+ var classofRaw$1 = classofRaw$2;
107
+ var uncurryThisRaw = functionUncurryThisRaw;
108
+
109
+ var functionUncurryThis = function (fn) {
110
+ // Nashorn bug:
111
+ // https://github.com/zloirock/core-js/issues/1128
112
+ // https://github.com/zloirock/core-js/issues/1130
113
+ if (classofRaw$1(fn) === 'Function') return uncurryThisRaw(fn);
114
+ };
115
+
116
+ var uncurryThis$8 = functionUncurryThis;
110
117
  var fails$6 = fails$9;
111
- var classof$2 = classofRaw$1;
118
+ var classof$2 = classofRaw$2;
112
119
 
113
120
  var $Object$3 = Object;
114
- var split = uncurryThis$9(''.split);
121
+ var split = uncurryThis$8(''.split);
115
122
 
116
123
  // fallback for non-array-like ES3 and non-enumerable old V8 strings
117
124
  var indexedObject = fails$6(function () {
@@ -191,9 +198,9 @@ var getBuiltIn$3 = function (namespace, method) {
191
198
  return arguments.length < 2 ? aFunction(global$b[namespace]) : global$b[namespace] && global$b[namespace][method];
192
199
  };
193
200
 
194
- var uncurryThis$8 = functionUncurryThis;
201
+ var uncurryThis$7 = functionUncurryThis;
195
202
 
196
- var objectIsPrototypeOf = uncurryThis$8({}.isPrototypeOf);
203
+ var objectIsPrototypeOf = uncurryThis$7({}.isPrototypeOf);
197
204
 
198
205
  var getBuiltIn$2 = getBuiltIn$3;
199
206
 
@@ -339,10 +346,10 @@ var store$2 = sharedStore;
339
346
  (shared$3.exports = function (key, value) {
340
347
  return store$2[key] || (store$2[key] = value !== undefined ? value : {});
341
348
  })('versions', []).push({
342
- version: '3.25.3',
349
+ version: '3.25.5',
343
350
  mode: 'global',
344
351
  copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
345
- license: 'https://github.com/zloirock/core-js/blob/v3.25.3/LICENSE',
352
+ license: 'https://github.com/zloirock/core-js/blob/v3.25.5/LICENSE',
346
353
  source: 'https://github.com/zloirock/core-js'
347
354
  });
348
355
 
@@ -356,10 +363,10 @@ var toObject$1 = function (argument) {
356
363
  return $Object$1(requireObjectCoercible$1(argument));
357
364
  };
358
365
 
359
- var uncurryThis$7 = functionUncurryThis;
366
+ var uncurryThis$6 = functionUncurryThis;
360
367
  var toObject = toObject$1;
361
368
 
362
- var hasOwnProperty = uncurryThis$7({}.hasOwnProperty);
369
+ var hasOwnProperty = uncurryThis$6({}.hasOwnProperty);
363
370
 
364
371
  // `HasOwnProperty` abstract operation
365
372
  // https://tc39.es/ecma262/#sec-hasownproperty
@@ -368,11 +375,11 @@ var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
368
375
  return hasOwnProperty(toObject(it), key);
369
376
  };
370
377
 
371
- var uncurryThis$6 = functionUncurryThis;
378
+ var uncurryThis$5 = functionUncurryThis;
372
379
 
373
380
  var id = 0;
374
381
  var postfix = Math.random();
375
- var toString$3 = uncurryThis$6(1.0.toString);
382
+ var toString$3 = uncurryThis$5(1.0.toString);
376
383
 
377
384
  var uid$2 = function (key) {
378
385
  return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$3(++id + postfix, 36);
@@ -586,11 +593,11 @@ var functionName = {
586
593
  CONFIGURABLE: CONFIGURABLE
587
594
  };
588
595
 
589
- var uncurryThis$5 = functionUncurryThis;
596
+ var uncurryThis$4 = functionUncurryThis;
590
597
  var isCallable$5 = isCallable$b;
591
598
  var store$1 = sharedStore;
592
599
 
593
- var functionToString = uncurryThis$5(Function.toString);
600
+ var functionToString = uncurryThis$4(Function.toString);
594
601
 
595
602
  // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
596
603
  if (!isCallable$5(store$1.inspectSource)) {
@@ -621,7 +628,6 @@ var hiddenKeys$3 = {};
621
628
 
622
629
  var NATIVE_WEAK_MAP = weakMapBasicDetection;
623
630
  var global$4 = global$c;
624
- var uncurryThis$4 = functionUncurryThis;
625
631
  var isObject = isObject$5;
626
632
  var createNonEnumerableProperty$1 = createNonEnumerableProperty$2;
627
633
  var hasOwn$3 = hasOwnProperty_1;
@@ -649,20 +655,22 @@ var getterFor = function (TYPE) {
649
655
 
650
656
  if (NATIVE_WEAK_MAP || shared.state) {
651
657
  var store = shared.state || (shared.state = new WeakMap());
652
- var wmget = uncurryThis$4(store.get);
653
- var wmhas = uncurryThis$4(store.has);
654
- var wmset = uncurryThis$4(store.set);
658
+ /* eslint-disable no-self-assign -- prototype methods protection */
659
+ store.get = store.get;
660
+ store.has = store.has;
661
+ store.set = store.set;
662
+ /* eslint-enable no-self-assign -- prototype methods protection */
655
663
  set = function (it, metadata) {
656
- if (wmhas(store, it)) throw TypeError$1(OBJECT_ALREADY_INITIALIZED);
664
+ if (store.has(it)) throw TypeError$1(OBJECT_ALREADY_INITIALIZED);
657
665
  metadata.facade = it;
658
- wmset(store, it, metadata);
666
+ store.set(it, metadata);
659
667
  return metadata;
660
668
  };
661
669
  get = function (it) {
662
- return wmget(store, it) || {};
670
+ return store.get(it) || {};
663
671
  };
664
672
  has = function (it) {
665
- return wmhas(store, it);
673
+ return store.has(it);
666
674
  };
667
675
  } else {
668
676
  var STATE = sharedKey('state');
@@ -1033,7 +1041,7 @@ var toStringTagSupport = String(test) === '[object z]';
1033
1041
 
1034
1042
  var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1035
1043
  var isCallable = isCallable$b;
1036
- var classofRaw = classofRaw$1;
1044
+ var classofRaw = classofRaw$2;
1037
1045
  var wellKnownSymbol = wellKnownSymbol$3;
1038
1046
 
1039
1047
  var TO_STRING_TAG = wellKnownSymbol('toStringTag');
@@ -1225,7 +1233,7 @@ Date.now = (Date.now || function () { // thanks IE8
1225
1233
 
1226
1234
  if ("now" in globalThis.performance === false) {
1227
1235
 
1228
- var nowOffset = Date.now();
1236
+ let nowOffset = Date.now();
1229
1237
 
1230
1238
  if (performance.timing && performance.timing.navigationStart) {
1231
1239
  nowOffset = performance.timing.navigationStart;
@@ -1252,6 +1260,7 @@ if ("now" in globalThis.performance === false) {
1252
1260
  function capitalize(str) {
1253
1261
  return str.charAt(0).toUpperCase() + str.slice(1);
1254
1262
  }
1263
+
1255
1264
  /**
1256
1265
  * returns true if the given string contains a numeric integer or float value
1257
1266
  * @public
@@ -1266,6 +1275,7 @@ function isNumeric(str) {
1266
1275
  }
1267
1276
  return !isNaN(str) && /[+-]?([0-9]*[.])?[0-9]+/.test(str);
1268
1277
  }
1278
+
1269
1279
  /**
1270
1280
  * returns true if the given string contains a true or false
1271
1281
  * @public
@@ -1278,6 +1288,7 @@ function isBoolean(str) {
1278
1288
  var trimmed = str.trim();
1279
1289
  return (trimmed === "true") || (trimmed === "false");
1280
1290
  }
1291
+
1281
1292
  /**
1282
1293
  * convert a string to the corresponding hexadecimal value
1283
1294
  * @public
@@ -1293,6 +1304,7 @@ function toHex$1(str) {
1293
1304
  }
1294
1305
  return res;
1295
1306
  }
1307
+
1296
1308
  /**
1297
1309
  * returns true if the given string is a data url in the `data:[<mediatype>][;base64],<data>` format.
1298
1310
  * (this will not test the validity of the Data or Base64 encoding)
@@ -1344,12 +1356,13 @@ function prefixed(name, obj) {
1344
1356
  var uc_name = capitalize(name);
1345
1357
 
1346
1358
  var result;
1347
- vendors$1.some(function (vendor) {
1359
+ vendors$1.some((vendor) => {
1348
1360
  var name = vendor + uc_name;
1349
1361
  return (result = (name in obj) ? obj[name] : undefined);
1350
1362
  });
1351
1363
  return result;
1352
1364
  }
1365
+
1353
1366
  /**
1354
1367
  * Set a vendor-prefixed property
1355
1368
  * @public
@@ -1369,7 +1382,7 @@ function setPrefixed(name, value, obj) {
1369
1382
 
1370
1383
  var uc_name = capitalize(name);
1371
1384
 
1372
- vendors$1.some(function (vendor) {
1385
+ vendors$1.some((vendor) => {
1373
1386
  var name = vendor + uc_name;
1374
1387
  if (name in obj) {
1375
1388
  obj[name] = value;
@@ -1447,6 +1460,7 @@ const EPSILON = 0.000001;
1447
1460
  function isPowerOfTwo(val) {
1448
1461
  return (val & (val - 1)) === 0;
1449
1462
  }
1463
+
1450
1464
  /**
1451
1465
  * returns the next power of two for the given value
1452
1466
  * @public
@@ -1465,6 +1479,7 @@ function nextPowerOfTwo(val) {
1465
1479
  val ++;
1466
1480
  return val;
1467
1481
  }
1482
+
1468
1483
  /**
1469
1484
  * Converts an angle in degrees to an angle in radians
1470
1485
  * @public
@@ -1479,6 +1494,7 @@ function nextPowerOfTwo(val) {
1479
1494
  function degToRad(angle) {
1480
1495
  return angle * DEG_TO_RAD;
1481
1496
  }
1497
+
1482
1498
  /**
1483
1499
  * Converts an angle in radians to an angle in degrees.
1484
1500
  * @public
@@ -1493,6 +1509,7 @@ function degToRad(angle) {
1493
1509
  function radToDeg(radians) {
1494
1510
  return radians * RAD_TO_DEG;
1495
1511
  }
1512
+
1496
1513
  /**
1497
1514
  * clamp the given value
1498
1515
  * @public
@@ -1506,6 +1523,7 @@ function radToDeg(radians) {
1506
1523
  function clamp(val, low, high) {
1507
1524
  return val < low ? low : val > high ? high : +val;
1508
1525
  }
1526
+
1509
1527
  /**
1510
1528
  * return a random integer between min (included) and max (excluded)
1511
1529
  * @public
@@ -1521,6 +1539,7 @@ function clamp(val, low, high) {
1521
1539
  function random$1(min, max) {
1522
1540
  return (~~(Math.random() * (max - min)) + min);
1523
1541
  }
1542
+
1524
1543
  /**
1525
1544
  * return a random float between min, max (exclusive)
1526
1545
  * @public
@@ -1536,6 +1555,7 @@ function random$1(min, max) {
1536
1555
  function randomFloat(min, max) {
1537
1556
  return (Math.random() * (max - min)) + min;
1538
1557
  }
1558
+
1539
1559
  /**
1540
1560
  * return a weighted random between min, max (exclusive)
1541
1561
  * @public
@@ -1551,6 +1571,7 @@ function randomFloat(min, max) {
1551
1571
  function weightedRandom$1(min, max) {
1552
1572
  return (~~(Math.pow(Math.random(), 2) * (max - min)) + min);
1553
1573
  }
1574
+
1554
1575
  /**
1555
1576
  * round a value to the specified number of digit
1556
1577
  * @public
@@ -1568,6 +1589,7 @@ function round(num, dec = 0) {
1568
1589
  var powres = Math.pow(10, dec);
1569
1590
  return (~~(0.5 + num * powres) / powres);
1570
1591
  }
1592
+
1571
1593
  /**
1572
1594
  * check if the given value is close to the expected one
1573
1595
  * @public
@@ -1630,6 +1652,7 @@ function remove(arr, obj) {
1630
1652
  }
1631
1653
  return arr;
1632
1654
  }
1655
+
1633
1656
  /**
1634
1657
  * return a random array element
1635
1658
  * @public
@@ -1645,6 +1668,7 @@ function remove(arr, obj) {
1645
1668
  function random(arr) {
1646
1669
  return arr[random$1(0, arr.length)];
1647
1670
  }
1671
+
1648
1672
  /**
1649
1673
  * return a weighted random array element, favoring the earlier entries
1650
1674
  * @public
@@ -1685,6 +1709,7 @@ const REMOVE_EXT = /\.[^\.]*$/;
1685
1709
  function getBasename(path) {
1686
1710
  return path.replace(REMOVE_PATH, "").replace(REMOVE_EXT, "");
1687
1711
  }
1712
+
1688
1713
  /**
1689
1714
  * return the extension of the file in the given path
1690
1715
  * @public
@@ -1726,6 +1751,7 @@ var fileUtils = /*#__PURE__*/Object.freeze({
1726
1751
  function defer(func, thisArg, ...args) {
1727
1752
  return setTimeout(func.bind(thisArg), 0.01, ...args);
1728
1753
  }
1754
+
1729
1755
  /**
1730
1756
  * returns a function that, when invoked will only be triggered at most
1731
1757
  * once during a given window of time
@@ -1751,7 +1777,7 @@ function throttle(fn, delay, no_trailing) {
1751
1777
  if (no_trailing === false) {
1752
1778
  // hold on to it
1753
1779
  clearTimeout(deferTimer);
1754
- deferTimer = setTimeout(function () {
1780
+ deferTimer = setTimeout(() => {
1755
1781
  last = now;
1756
1782
  return fn.apply(null, args);
1757
1783
  }, elasped);
@@ -1921,7 +1947,7 @@ class ObjectPool {
1921
1947
  */
1922
1948
  exists(name) {
1923
1949
  return name in this.objectClass;
1924
- };
1950
+ }
1925
1951
 
1926
1952
  /**
1927
1953
  * Check if an object is poolable
@@ -2473,6 +2499,7 @@ class Vector2d {
2473
2499
  function toHex(component) {
2474
2500
  return "0123456789ABCDEF".charAt((component - (component % 16)) >> 4) + "0123456789ABCDEF".charAt(component % 16);
2475
2501
  }
2502
+
2476
2503
  function hue2rgb(p, q, t) {
2477
2504
  if (t < 0) t += 1;
2478
2505
  if (t > 1) t -= 1;
@@ -2641,7 +2668,7 @@ var cssToRGB = new Map();
2641
2668
  [ "wheat", [ 245, 222, 179 ] ],
2642
2669
  [ "whitesmoke", [ 245, 245, 245 ] ],
2643
2670
  [ "yellowgreen", [ 154, 205, 50 ] ]
2644
- ].forEach(function (value) {
2671
+ ].forEach((value) => {
2645
2672
  cssToRGB.set(value[0], value[1]);
2646
2673
  });
2647
2674
 
@@ -5055,6 +5082,7 @@ const ONCONTEXT_RESTORED = "renderer.contextrestored";
5055
5082
  function emit(eventName, ...args) {
5056
5083
  return eventEmitter.emit(eventName, ...args);
5057
5084
  }
5085
+
5058
5086
  /**
5059
5087
  * Add a listener for a given event.
5060
5088
  * @function event.on
@@ -5069,6 +5097,7 @@ function emit(eventName, ...args) {
5069
5097
  function on(eventName, listener, context) {
5070
5098
  return eventEmitter.on(eventName, listener, context);
5071
5099
  }
5100
+
5072
5101
  /**
5073
5102
  * Add a one-time listener for a given event.
5074
5103
  * @function event.once
@@ -5083,6 +5112,7 @@ function on(eventName, listener, context) {
5083
5112
  function once(eventName, listener, context) {
5084
5113
  return eventEmitter.once(eventName, listener, context);
5085
5114
  }
5115
+
5086
5116
  /**
5087
5117
  * remove the given listener for a given event.
5088
5118
  * @function event.off
@@ -5201,7 +5231,7 @@ on(BOOT, () => {
5201
5231
 
5202
5232
  if (typeof me_save_content === "string" && me_save_content.length > 0) {
5203
5233
  var keys = JSON.parse(me_save_content) || [];
5204
- keys.forEach(function (key) {
5234
+ keys.forEach((key) => {
5205
5235
  data[key] = JSON.parse(globalThis.localStorage.getItem("me.save." + key));
5206
5236
  });
5207
5237
  }
@@ -5224,7 +5254,7 @@ var save = {
5224
5254
  add(props) {
5225
5255
  var obj = save;
5226
5256
 
5227
- Object.keys(props).forEach(function (key) {
5257
+ Object.keys(props).forEach((key) => {
5228
5258
  if (isReserved(key)) {
5229
5259
  return;
5230
5260
  }
@@ -5322,6 +5352,7 @@ function _domReady() {
5322
5352
  isDOMReady = true;
5323
5353
  }
5324
5354
  }
5355
+
5325
5356
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event
5326
5357
  function DOMContentLoaded(fn) {
5327
5358
  // If the DOM is already ready
@@ -5421,6 +5452,7 @@ function disableSwipeFn(e) {
5421
5452
  }
5422
5453
  return false;
5423
5454
  }
5455
+
5424
5456
  function hasLocalStorage() {
5425
5457
  try {
5426
5458
  return !!globalThis.localStorage;
@@ -5449,6 +5481,7 @@ function onDeviceMotion(e) {
5449
5481
  accelerationY = e.accelerationIncludingGravity.y;
5450
5482
  accelerationZ = e.accelerationIncludingGravity.z;
5451
5483
  }
5484
+
5452
5485
  /**
5453
5486
  * used by [un]watchDeviceOrientation()
5454
5487
  */
@@ -5457,6 +5490,7 @@ function onDeviceRotate(e) {
5457
5490
  beta = e.beta;
5458
5491
  alpha = e.alpha;
5459
5492
  }
5493
+
5460
5494
  /**
5461
5495
  * the device platform type
5462
5496
  * @name platform
@@ -5827,6 +5861,7 @@ let stopOnBlur = false;
5827
5861
  function onReady(fn) {
5828
5862
  DOMContentLoaded(fn);
5829
5863
  }
5864
+
5830
5865
  /**
5831
5866
  * enable/disable swipe on WebView.
5832
5867
  * @function enableSwipe
@@ -5846,6 +5881,7 @@ function enableSwipe(enable) {
5846
5881
  swipeEnabled = false;
5847
5882
  }
5848
5883
  }
5884
+
5849
5885
  /**
5850
5886
  * Returns true if the browser/device is in full screen mode.
5851
5887
  * @function isFullscreen
@@ -5860,6 +5896,7 @@ function isFullscreen() {
5860
5896
  return false;
5861
5897
  }
5862
5898
  }
5899
+
5863
5900
  /**
5864
5901
  * Triggers a fullscreen request. Requires fullscreen support from the browser/device.
5865
5902
  * @function requestFullscreen
@@ -5885,6 +5922,7 @@ function requestFullscreen(element) {
5885
5922
  element.requestFullscreen();
5886
5923
  }
5887
5924
  }
5925
+
5888
5926
  /**
5889
5927
  * Exit fullscreen mode. Requires fullscreen support from the browser/device.
5890
5928
  * @function exitFullscreen
@@ -5896,6 +5934,7 @@ function exitFullscreen() {
5896
5934
  document.exitFullscreen();
5897
5935
  }
5898
5936
  }
5937
+
5899
5938
  /**
5900
5939
  * Return a string representing the orientation of the device screen.
5901
5940
  * It can be "any", "natural", "landscape", "portrait", "portrait-primary", "portrait-secondary", "landscape-primary", "landscape-secondary"
@@ -5931,6 +5970,7 @@ function getScreenOrientation() {
5931
5970
  // fallback to window size check
5932
5971
  return (globalThis.outerWidth > globalThis.outerHeight) ? LANDSCAPE : PORTRAIT;
5933
5972
  }
5973
+
5934
5974
  /**
5935
5975
  * locks the device screen into the specified orientation.<br>
5936
5976
  * This method only works for installed Web apps or for Web pages in full-screen mode.
@@ -5951,6 +5991,7 @@ function lockOrientation(orientation) {
5951
5991
  }
5952
5992
  return false;
5953
5993
  }
5994
+
5954
5995
  /**
5955
5996
  * unlocks the device screen into the specified orientation.<br>
5956
5997
  * This method only works for installed Web apps or for Web pages in full-screen mode.
@@ -5970,6 +6011,7 @@ function unlockOrientation() {
5970
6011
  }
5971
6012
  return false;
5972
6013
  }
6014
+
5973
6015
  /**
5974
6016
  * return true if the device screen orientation is in Portrait mode
5975
6017
  * @function isPortrait
@@ -5980,6 +6022,7 @@ function unlockOrientation() {
5980
6022
  function isPortrait() {
5981
6023
  return getScreenOrientation().includes("portrait");
5982
6024
  }
6025
+
5983
6026
  /**
5984
6027
  * return true if the device screen orientation is in Portrait mode
5985
6028
  * @function isLandscape
@@ -5990,6 +6033,7 @@ function isPortrait() {
5990
6033
  function isLandscape() {
5991
6034
  return getScreenOrientation().includes("landscape");
5992
6035
  }
6036
+
5993
6037
  /**
5994
6038
  * return the device storage
5995
6039
  * @function getStorage
@@ -6008,6 +6052,7 @@ function getStorage(type = "local") {
6008
6052
  throw new Error("storage type " + type + " not supported");
6009
6053
  }
6010
6054
  }
6055
+
6011
6056
  /**
6012
6057
  * return the parent DOM element for the given parent name or HTMLElement object
6013
6058
  * @function getParentElement
@@ -6025,6 +6070,7 @@ function getParentElement(element) {
6025
6070
 
6026
6071
  return target;
6027
6072
  }
6073
+
6028
6074
  /**
6029
6075
  * return the DOM element for the given element name or HTMLElement object
6030
6076
  * @function getElement
@@ -6052,6 +6098,7 @@ function getElement(element) {
6052
6098
 
6053
6099
  return target;
6054
6100
  }
6101
+
6055
6102
  /**
6056
6103
  * returns the size of the given HTMLElement and its position relative to the viewport
6057
6104
  * <br><img src="images/element-box-diagram.png"/>
@@ -6069,7 +6116,9 @@ function getElementBounds(element) {
6069
6116
  domRect.width = domRect.right = globalThis.innerWidth;
6070
6117
  domRect.height = domRect.bottom = globalThis.innerHeight;
6071
6118
  return domRect;
6072
- }}
6119
+ }
6120
+ }
6121
+
6073
6122
  /**
6074
6123
  * returns the size of the given HTMLElement Parent and its position relative to the viewport
6075
6124
  * <br><img src="images/element-box-diagram.png"/>
@@ -6083,6 +6132,7 @@ function getElementBounds(element) {
6083
6132
  function getParentBounds(element) {
6084
6133
  return getElementBounds(getParentElement(element));
6085
6134
  }
6135
+
6086
6136
  /**
6087
6137
  * returns true if the device supports WebGL
6088
6138
  * @function isWebGLSupported
@@ -6107,6 +6157,7 @@ function isWebGLSupported(options) {
6107
6157
 
6108
6158
  return _supported;
6109
6159
  }
6160
+
6110
6161
  /**
6111
6162
  * return the highest precision format supported by this device for GL Shaders
6112
6163
  * @function getMaxShaderPrecision
@@ -6126,6 +6177,7 @@ function getMaxShaderPrecision(gl) {
6126
6177
  }
6127
6178
  return "lowp";
6128
6179
  }
6180
+
6129
6181
  /**
6130
6182
  * Makes a request to bring this device window to the front.
6131
6183
  * @function focus
@@ -6141,6 +6193,7 @@ function focus() {
6141
6193
  globalThis.focus();
6142
6194
  }
6143
6195
  }
6196
+
6144
6197
  /**
6145
6198
  * Enable monitor of the device accelerator to detect the amount of physical force of acceleration the device is receiving.
6146
6199
  * (one some device a first user gesture will be required before calling this function)
@@ -6183,6 +6236,7 @@ function watchAccelerometer() {
6183
6236
  }
6184
6237
  return accelInitialized;
6185
6238
  }
6239
+
6186
6240
  /**
6187
6241
  * unwatch Accelerometor event
6188
6242
  * @function unwatchAccelerometer
@@ -6196,6 +6250,7 @@ function unwatchAccelerometer() {
6196
6250
  accelInitialized = false;
6197
6251
  }
6198
6252
  }
6253
+
6199
6254
  /**
6200
6255
  * Enable monitor of the device orientation to detect the current orientation of the device as compared to the Earth coordinate frame.
6201
6256
  * (one some device a first user gesture will be required before calling this function)
@@ -6234,6 +6289,7 @@ function watchDeviceOrientation() {
6234
6289
  }
6235
6290
  return deviceOrientationInitialized;
6236
6291
  }
6292
+
6237
6293
  /**
6238
6294
  * unwatch Device orientation event
6239
6295
  * @function unwatchDeviceOrientation
@@ -6246,6 +6302,7 @@ function unwatchDeviceOrientation() {
6246
6302
  deviceOrientationInitialized = false;
6247
6303
  }
6248
6304
  }
6305
+
6249
6306
  /**
6250
6307
  * the vibrate method pulses the vibration hardware on the device, <br>
6251
6308
  * If the device doesn't support vibration, this method has no effect. <br>
@@ -6364,14 +6421,14 @@ function extractUniforms(gl, shader) {
6364
6421
  match;
6365
6422
 
6366
6423
  // Detect all uniform names and types
6367
- [ shader.vertex, shader.fragment ].forEach(function (shader) {
6424
+ [ shader.vertex, shader.fragment ].forEach((shader) => {
6368
6425
  while ((match = uniRx.exec(shader))) {
6369
6426
  uniformsData[match[2]] = match[1];
6370
6427
  }
6371
6428
  });
6372
6429
 
6373
6430
  // Get uniform references
6374
- Object.keys(uniformsData).forEach(function (name) {
6431
+ Object.keys(uniformsData).forEach((name) => {
6375
6432
  var type = uniformsData[name];
6376
6433
  locations[name] = gl.getUniformLocation(shader.program, name);
6377
6434
 
@@ -6444,6 +6501,7 @@ function compileShader(gl, type, source) {
6444
6501
 
6445
6502
  return shader;
6446
6503
  }
6504
+
6447
6505
  /**
6448
6506
  * Compile GLSL into a shader object
6449
6507
  * @ignore
@@ -8446,7 +8504,7 @@ class Polygon {
8446
8504
  */
8447
8505
  clone() {
8448
8506
  var copy = [];
8449
- this.points.forEach(function (point) {
8507
+ this.points.forEach((point) => {
8450
8508
  copy.push(point.clone());
8451
8509
  });
8452
8510
  return new Polygon(this.pos.x, this.pos.y, copy);
@@ -9333,7 +9391,7 @@ class Line extends Polygon {
9333
9391
  */
9334
9392
  clone() {
9335
9393
  var copy = [];
9336
- this.points.forEach(function (point) {
9394
+ this.points.forEach((point) => {
9337
9395
  copy.push(point.clone());
9338
9396
  });
9339
9397
  return new Line(this.pos.x, this.pos.y, copy);
@@ -10228,7 +10286,7 @@ class Renderer {
10228
10286
  this.currentBlendMode = "none";
10229
10287
 
10230
10288
  // create the main screen canvas
10231
- if (undefined === true) {
10289
+ if (platform.ejecta === true) {
10232
10290
  // a main canvas is already automatically created by Ejecta
10233
10291
  this.canvas = document.getElementById("canvas");
10234
10292
  } else if (typeof globalThis.canvas !== "undefined") {
@@ -13878,6 +13936,7 @@ let stopOnAudioError = true;
13878
13936
 
13879
13937
  return !howler.Howler.noAudio;
13880
13938
  }
13939
+
13881
13940
  /**
13882
13941
  * check if the given audio format is supported
13883
13942
  * @function audio.hasFormat
@@ -13887,6 +13946,7 @@ let stopOnAudioError = true;
13887
13946
  function hasFormat(codec) {
13888
13947
  return hasAudio() && howler.Howler.codecs(codec);
13889
13948
  }
13949
+
13890
13950
  /**
13891
13951
  * check if audio (HTML5 or WebAudio) is supported
13892
13952
  * @function audio.hasAudio
@@ -13895,6 +13955,7 @@ function hasFormat(codec) {
13895
13955
  function hasAudio() {
13896
13956
  return !howler.Howler.noAudio;
13897
13957
  }
13958
+
13898
13959
  /**
13899
13960
  * enable audio output <br>
13900
13961
  * only useful if audio supported and previously disabled through
@@ -13904,6 +13965,7 @@ function hasAudio() {
13904
13965
  function enable() {
13905
13966
  unmuteAll();
13906
13967
  }
13968
+
13907
13969
  /**
13908
13970
  * disable audio output
13909
13971
  * @function audio.disable
@@ -13911,6 +13973,7 @@ function enable() {
13911
13973
  function disable() {
13912
13974
  muteAll();
13913
13975
  }
13976
+
13914
13977
  /**
13915
13978
  * Load an audio file.<br>
13916
13979
  * <br>
@@ -13956,6 +14019,7 @@ function load(sound, html5, onload_cb, onerror_cb) {
13956
14019
 
13957
14020
  return 1;
13958
14021
  }
14022
+
13959
14023
  /**
13960
14024
  * play the specified sound
13961
14025
  * @function audio.play
@@ -13996,6 +14060,7 @@ function play(sound_name, loop = false, onend, volume) {
13996
14060
  throw new Error("audio clip " + sound_name + " does not exist");
13997
14061
  }
13998
14062
  }
14063
+
13999
14064
  /**
14000
14065
  * Fade a currently playing sound between two volumee.
14001
14066
  * @function audio.fade
@@ -14013,6 +14078,7 @@ function fade(sound_name, from, to, duration, id) {
14013
14078
  throw new Error("audio clip " + sound_name + " does not exist");
14014
14079
  }
14015
14080
  }
14081
+
14016
14082
  /**
14017
14083
  * get/set the position of playback for a sound.
14018
14084
  * @function audio.seek
@@ -14034,6 +14100,7 @@ function seek(sound_name, ...args) {
14034
14100
  throw new Error("audio clip " + sound_name + " does not exist");
14035
14101
  }
14036
14102
  }
14103
+
14037
14104
  /**
14038
14105
  * get or set the rate of playback for a sound.
14039
14106
  * @function audio.rate
@@ -14055,6 +14122,7 @@ function rate(sound_name, ...args) {
14055
14122
  throw new Error("audio clip " + sound_name + " does not exist");
14056
14123
  }
14057
14124
  }
14125
+
14058
14126
  /**
14059
14127
  * stop the specified sound on all channels
14060
14128
  * @function audio.stop
@@ -14077,6 +14145,7 @@ function stop(sound_name, id) {
14077
14145
  howler.Howler.stop();
14078
14146
  }
14079
14147
  }
14148
+
14080
14149
  /**
14081
14150
  * pause the specified sound on all channels<br>
14082
14151
  * this function does not reset the currentTime property
@@ -14094,6 +14163,7 @@ function pause(sound_name, id) {
14094
14163
  throw new Error("audio clip " + sound_name + " does not exist");
14095
14164
  }
14096
14165
  }
14166
+
14097
14167
  /**
14098
14168
  * resume the specified sound on all channels<br>
14099
14169
  * @function audio.resume
@@ -14117,6 +14187,7 @@ function resume(sound_name, id) {
14117
14187
  throw new Error("audio clip " + sound_name + " does not exist");
14118
14188
  }
14119
14189
  }
14190
+
14120
14191
  /**
14121
14192
  * play the specified audio track<br>
14122
14193
  * this function automatically set the loop property to true<br>
@@ -14137,6 +14208,7 @@ function playTrack(sound_name, volume) {
14137
14208
  volume
14138
14209
  );
14139
14210
  }
14211
+
14140
14212
  /**
14141
14213
  * stop the current audio track
14142
14214
  * @function audio.stopTrack
@@ -14153,6 +14225,7 @@ function stopTrack() {
14153
14225
  current_track_id = null;
14154
14226
  }
14155
14227
  }
14228
+
14156
14229
  /**
14157
14230
  * pause the current audio track
14158
14231
  * @function audio.pauseTrack
@@ -14164,6 +14237,7 @@ function pauseTrack() {
14164
14237
  audioTracks[current_track_id].pause();
14165
14238
  }
14166
14239
  }
14240
+
14167
14241
  /**
14168
14242
  * resume the previously paused audio track
14169
14243
  * @function audio.resumeTrack
@@ -14180,6 +14254,7 @@ function resumeTrack() {
14180
14254
  audioTracks[current_track_id].play();
14181
14255
  }
14182
14256
  }
14257
+
14183
14258
  /**
14184
14259
  * returns the current track Id
14185
14260
  * @function audio.getCurrentTrack
@@ -14188,6 +14263,7 @@ function resumeTrack() {
14188
14263
  function getCurrentTrack() {
14189
14264
  return current_track_id;
14190
14265
  }
14266
+
14191
14267
  /**
14192
14268
  * set the default global volume
14193
14269
  * @function audio.setVolume
@@ -14196,6 +14272,7 @@ function getCurrentTrack() {
14196
14272
  function setVolume(volume) {
14197
14273
  howler.Howler.volume(volume);
14198
14274
  }
14275
+
14199
14276
  /**
14200
14277
  * get the default global volume
14201
14278
  * @function audio.getVolume
@@ -14204,6 +14281,7 @@ function setVolume(volume) {
14204
14281
  function getVolume() {
14205
14282
  return howler.Howler.volume();
14206
14283
  }
14284
+
14207
14285
  /**
14208
14286
  * mute or unmute the specified sound, but does not pause the playback.
14209
14287
  * @function audio.mute
@@ -14224,6 +14302,7 @@ function mute(sound_name, id, mute) {
14224
14302
  throw new Error("audio clip " + sound_name + " does not exist");
14225
14303
  }
14226
14304
  }
14305
+
14227
14306
  /**
14228
14307
  * unmute the specified sound
14229
14308
  * @function audio.unmute
@@ -14233,6 +14312,7 @@ function mute(sound_name, id, mute) {
14233
14312
  function unmute(sound_name, id) {
14234
14313
  mute(sound_name, id, false);
14235
14314
  }
14315
+
14236
14316
  /**
14237
14317
  * mute all audio
14238
14318
  * @function audio.muteAll
@@ -14240,6 +14320,7 @@ function unmute(sound_name, id) {
14240
14320
  function muteAll() {
14241
14321
  howler.Howler.mute(true);
14242
14322
  }
14323
+
14243
14324
  /**
14244
14325
  * unmute all audio
14245
14326
  * @function audio.unmuteAll
@@ -14247,6 +14328,7 @@ function muteAll() {
14247
14328
  function unmuteAll() {
14248
14329
  howler.Howler.mute(false);
14249
14330
  }
14331
+
14250
14332
  /**
14251
14333
  * Returns true if audio is muted globally.
14252
14334
  * @function audio.muted
@@ -14255,6 +14337,7 @@ function unmuteAll() {
14255
14337
  function muted() {
14256
14338
  return howler.Howler._muted;
14257
14339
  }
14340
+
14258
14341
  /**
14259
14342
  * unload specified audio track to free memory
14260
14343
  * @function audio.unload
@@ -14273,6 +14356,7 @@ function unload(sound_name) {
14273
14356
  delete audioTracks[sound_name];
14274
14357
  return true;
14275
14358
  }
14359
+
14276
14360
  /**
14277
14361
  * unload all audio to free memory
14278
14362
  * @function audio.unloadAll
@@ -16202,6 +16286,7 @@ function initKeyboardEvent() {
16202
16286
  }
16203
16287
  }
16204
16288
  }
16289
+
16205
16290
  /**
16206
16291
  * return the key press status of the specified action
16207
16292
  * @name isKeyPressed
@@ -16226,6 +16311,7 @@ function isKeyPressed(action) {
16226
16311
  }
16227
16312
  return false;
16228
16313
  }
16314
+
16229
16315
  /**
16230
16316
  * return the key status of the specified action
16231
16317
  * @name keyStatus
@@ -16238,6 +16324,7 @@ function keyStatus(action) {
16238
16324
  return (_keyStatus[action] > 0);
16239
16325
  }
16240
16326
 
16327
+
16241
16328
  /**
16242
16329
  * trigger the specified key (simulated) event <br>
16243
16330
  * @name triggerKeyEvent
@@ -16259,6 +16346,7 @@ function triggerKeyEvent(keycode, status, mouseButton) {
16259
16346
  }
16260
16347
  }
16261
16348
 
16349
+
16262
16350
  /**
16263
16351
  * associate a user defined action to a keycode
16264
16352
  * @name bindKey
@@ -16284,6 +16372,7 @@ function bindKey(keycode, action, lock, preventDefault$1 = preventDefault) {
16284
16372
  _keyLocked[action] = false;
16285
16373
  _keyRefs[action] = {};
16286
16374
  }
16375
+
16287
16376
  /**
16288
16377
  * return the action associated with the given keycode
16289
16378
  * @name getBindingKey
@@ -16295,6 +16384,7 @@ function bindKey(keycode, action, lock, preventDefault$1 = preventDefault) {
16295
16384
  function getBindingKey(keycode) {
16296
16385
  return _keyBindings[keycode];
16297
16386
  }
16387
+
16298
16388
  /**
16299
16389
  * unlock a key manually
16300
16390
  * @name unlockKey
@@ -16310,6 +16400,7 @@ function getBindingKey(keycode) {
16310
16400
  function unlockKey(action) {
16311
16401
  _keyLocked[action] = false;
16312
16402
  }
16403
+
16313
16404
  /**
16314
16405
  * unbind the defined keycode
16315
16406
  * @name unbindKey
@@ -16847,7 +16938,7 @@ function enablePointerEvent() {
16847
16938
  focus();
16848
16939
  pointerEventTarget.addEventListener(
16849
16940
  activeEventList[2], // MOUSE/POINTER DOWN
16850
- function () {
16941
+ () => {
16851
16942
  focus();
16852
16943
  },
16853
16944
  { passive: (preventDefault === false) }
@@ -17263,6 +17354,7 @@ function globalToLocal(x, y, v) {
17263
17354
  }
17264
17355
  return v.set(x * pixelRatio, y * pixelRatio);
17265
17356
  }
17357
+
17266
17358
  /**
17267
17359
  * enable/disable all gestures on the given element.<br>
17268
17360
  * by default melonJS will disable browser handling of all panning and zooming gestures.
@@ -17276,6 +17368,7 @@ function globalToLocal(x, y, v) {
17276
17368
  function setTouchAction(element, value) {
17277
17369
  element.style["touch-action"] = value || "none";
17278
17370
  }
17371
+
17279
17372
  /**
17280
17373
  * Associate a pointer event to a keycode<br>
17281
17374
  * Left button – 0
@@ -17308,6 +17401,7 @@ function bindPointer() {
17308
17401
  // map the mouse button to the keycode
17309
17402
  pointer.bind[button] = keyCode;
17310
17403
  }
17404
+
17311
17405
  /**
17312
17406
  * unbind the defined keycode
17313
17407
  * @name unbindPointer
@@ -17325,6 +17419,7 @@ function unbindPointer(button) {
17325
17419
  ] = null;
17326
17420
  }
17327
17421
 
17422
+
17328
17423
  /**
17329
17424
  * allows registration of event listeners on the object target. <br>
17330
17425
  * melonJS will pass a me.Pointer object to the defined callback.
@@ -17397,6 +17492,7 @@ function registerPointerEvent(eventType, region, callback) {
17397
17492
  }
17398
17493
  }
17399
17494
  }
17495
+
17400
17496
  /**
17401
17497
  * allows the removal of event listeners from the object target.
17402
17498
  * @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events|W3C Pointer Event list}
@@ -17441,6 +17537,7 @@ function releasePointerEvent(eventType, region, callback) {
17441
17537
  }
17442
17538
  }
17443
17539
  }
17540
+
17444
17541
  /**
17445
17542
  * allows the removal of all registered event listeners from the object target.
17446
17543
  * @name releaseAllPointerEvents
@@ -17456,7 +17553,9 @@ function releaseAllPointerEvents(region) {
17456
17553
  for (var i = 0; i < pointerEventList.length; i++) {
17457
17554
  releasePointerEvent(pointerEventList[i], region);
17458
17555
  }
17459
- }}
17556
+ }
17557
+ }
17558
+
17460
17559
  /**
17461
17560
  * request for the pointer to be locked on the parent DOM element.
17462
17561
  * (Must be called in a click event or an event that requires user interaction)
@@ -17549,13 +17648,13 @@ var leadingZeroRE = /^0+/;
17549
17648
  * @ignore
17550
17649
  */
17551
17650
  function addMapping(id, mapping) {
17552
- var expanded_id = id.replace(vendorProductRE, function (_, a, b) {
17651
+ var expanded_id = id.replace(vendorProductRE, (_, a, b) => {
17553
17652
  return (
17554
17653
  "000".slice(a.length - 1) + a + "-" +
17555
17654
  "000".slice(b.length - 1) + b + "-"
17556
17655
  );
17557
17656
  });
17558
- var sparse_id = id.replace(vendorProductRE, function (_, a, b) {
17657
+ var sparse_id = id.replace(vendorProductRE, (_, a, b) => {
17559
17658
  return (
17560
17659
  a.replace(leadingZeroRE, "") + "-" +
17561
17660
  b.replace(leadingZeroRE, "") + "-"
@@ -17563,7 +17662,7 @@ function addMapping(id, mapping) {
17563
17662
  });
17564
17663
 
17565
17664
  // Normalize optional parameters
17566
- mapping.analog = mapping.analog || mapping.buttons.map(function () {
17665
+ mapping.analog = mapping.analog || mapping.buttons.map(() => {
17567
17666
  return -1;
17568
17667
  });
17569
17668
  mapping.normalize_fn = mapping.normalize_fn || function (value) { return value; };
@@ -17626,7 +17725,7 @@ var updateEventHandler;
17626
17725
  "normalize_fn" : ouyaNormalizeFn
17627
17726
  }
17628
17727
  ]
17629
- ].forEach(function (value) {
17728
+ ].forEach((value) => {
17630
17729
  addMapping(value[0], value[1]);
17631
17730
  });
17632
17731
 
@@ -17638,7 +17737,7 @@ var updateGamepads = function () {
17638
17737
  var gamepads = navigator.getGamepads();
17639
17738
 
17640
17739
  // Trigger button bindings
17641
- Object.keys(bindings).forEach(function (index) {
17740
+ Object.keys(bindings).forEach((index) => {
17642
17741
  var gamepad = gamepads[index];
17643
17742
  if (!gamepad) {
17644
17743
  return;
@@ -17652,7 +17751,7 @@ var updateGamepads = function () {
17652
17751
  var binding = bindings[index];
17653
17752
 
17654
17753
  // Iterate all buttons that have active bindings
17655
- Object.keys(binding.buttons).forEach(function (button) {
17754
+ Object.keys(binding.buttons).forEach((button) => {
17656
17755
  var last = binding.buttons[button];
17657
17756
  var mapped_button = button;
17658
17757
  var mapped_axis = -1;
@@ -17699,7 +17798,7 @@ var updateGamepads = function () {
17699
17798
  });
17700
17799
 
17701
17800
  // Iterate all axes that have active bindings
17702
- Object.keys(binding.axes).forEach(function (axis) {
17801
+ Object.keys(binding.axes).forEach((axis) => {
17703
17802
  var last = binding.axes[axis];
17704
17803
  var mapped_axis = axis;
17705
17804
 
@@ -17754,14 +17853,14 @@ var updateGamepads = function () {
17754
17853
 
17755
17854
  // gamepad connected callback
17756
17855
  if (globalThis.navigator && typeof globalThis.navigator.getGamepads === "function") {
17757
- globalThis.addEventListener("gamepadconnected", function (e) {
17856
+ globalThis.addEventListener("gamepadconnected", (e) => {
17758
17857
  emit(GAMEPAD_CONNECTED, e.gamepad);
17759
17858
  }, false);
17760
17859
 
17761
17860
  /*
17762
17861
  * gamepad disconnected callback
17763
17862
  */
17764
- globalThis.addEventListener("gamepaddisconnected", function (e) {
17863
+ globalThis.addEventListener("gamepaddisconnected", (e) => {
17765
17864
  emit(GAMEPAD_DISCONNECTED, e.gamepad);
17766
17865
  }, false);
17767
17866
  }
@@ -17917,6 +18016,7 @@ function bindGamepad(index, button, keyCode) {
17917
18016
  }
17918
18017
  }
17919
18018
  }
18019
+
17920
18020
  /**
17921
18021
  * unbind the defined keycode
17922
18022
  * @name unbindGamepad
@@ -17933,6 +18033,7 @@ function unbindGamepad(index, button) {
17933
18033
  }
17934
18034
  bindings[index].buttons[button] = {};
17935
18035
  }
18036
+
17936
18037
  /**
17937
18038
  * Set deadzone for analog gamepad inputs<br>
17938
18039
  * The default deadzone is 0.1 (10%) Analog values less than this will be ignored
@@ -17944,6 +18045,7 @@ function unbindGamepad(index, button) {
17944
18045
  function setGamepadDeadzone(value) {
17945
18046
  deadzone = value;
17946
18047
  }
18048
+
17947
18049
  /**
17948
18050
  * specify a custom mapping for a specific gamepad id<br>
17949
18051
  * see below for the default mapping : <br>
@@ -19358,6 +19460,7 @@ function shouldCollide(a, b) {
19358
19460
  }
19359
19461
 
19360
19462
 
19463
+
19361
19464
  /**
19362
19465
  * find all the collisions for the specified object
19363
19466
  * @name collisionCheck
@@ -19428,6 +19531,7 @@ function collisionCheck(objA, response = globalResponse) {
19428
19531
  // we could return the amount of objects we collided with ?
19429
19532
  return collisionCounter > 0;
19430
19533
  }
19534
+
19431
19535
  /**
19432
19536
  * Checks for object colliding with the given line
19433
19537
  * @name rayCast
@@ -20158,7 +20262,8 @@ class Body {
20158
20262
  if (shape.contains(_x, _y)) {
20159
20263
  return true;
20160
20264
  }
20161
- } }
20265
+ }
20266
+ }
20162
20267
  return false;
20163
20268
  }
20164
20269
 
@@ -20326,10 +20431,14 @@ class Container extends Renderable {
20326
20431
  * @param {number} [width=game.viewport.width] width of the container
20327
20432
  * @param {number} [height=game.viewport.height] height of the container
20328
20433
  */
20329
- constructor(x = 0, y = 0, width = game.viewport.width, height = game.viewport.height, root = false) {
20434
+ constructor(x = 0, y = 0, width, height, root = false) {
20330
20435
 
20331
20436
  // call the super constructor
20332
- super(x, y, width, height);
20437
+ super(
20438
+ x, y,
20439
+ typeof width === "undefined" ? (typeof game.viewport !== "undefined" ? game.viewport.width : Infinity) : width,
20440
+ typeof height === "undefined" ? (typeof game.viewport !== "undefined" ? game.viewport.height : Infinity) : height
20441
+ );
20333
20442
 
20334
20443
  /**
20335
20444
  * keep track of pending sort
@@ -20470,6 +20579,7 @@ class Container extends Renderable {
20470
20579
  this.removeChildNow(child);
20471
20580
  }
20472
20581
  }
20582
+
20473
20583
  if (typeof this.currentTransform !== "undefined") {
20474
20584
  // just reset some variables
20475
20585
  this.currentTransform.identity();
@@ -21209,10 +21319,11 @@ class Container extends Renderable {
21209
21319
  // check if object is in any active cameras
21210
21320
  obj.inViewport = false;
21211
21321
  // iterate through all cameras
21212
- state.current().cameras.forEach(function(camera) {
21322
+ state.current().cameras.forEach((camera) => {
21213
21323
  if (camera.isVisible(obj, isFloating)) {
21214
21324
  obj.inViewport = true;
21215
- } });
21325
+ }
21326
+ });
21216
21327
 
21217
21328
  // update our object
21218
21329
  this.isDirty |= ((obj.inViewport || obj.alwaysUpdate) && obj.update(dt));
@@ -21329,6 +21440,7 @@ function QT_ARRAY_POP(world, bounds, max_objects = 4, max_levels = 4, level = 0)
21329
21440
  return new QuadTree(world, bounds, max_objects, max_levels, level);
21330
21441
  }
21331
21442
  }
21443
+
21332
21444
  /**
21333
21445
  * Push back a quadtree back into the array
21334
21446
  * @ignore
@@ -21336,6 +21448,7 @@ function QT_ARRAY_POP(world, bounds, max_objects = 4, max_levels = 4, level = 0)
21336
21448
  function QT_ARRAY_PUSH(qt) {
21337
21449
  QT_ARRAY.push(qt);
21338
21450
  }
21451
+
21339
21452
  /**
21340
21453
  * a temporary vector object to be reused
21341
21454
  * @ignore
@@ -21861,7 +21974,8 @@ class World extends Container {
21861
21974
  if (body.update(dt) === true) {
21862
21975
  // mark ancestor as dirty
21863
21976
  ancestor.isDirty = true;
21864
- } // handle collisions against other objects
21977
+ }
21978
+ // handle collisions against other objects
21865
21979
  collisionCheck(ancestor);
21866
21980
  // clear body force
21867
21981
  body.force.set(0, 0);
@@ -21888,7 +22002,7 @@ class Application {
21888
22002
  * @public
21889
22003
  * @type {Camera2d}
21890
22004
  */
21891
- this.viewport = null;
22005
+ this.viewport = undefined;
21892
22006
 
21893
22007
  /**
21894
22008
  * a reference to the game world, <br>
@@ -21896,7 +22010,7 @@ class Application {
21896
22010
  * @public
21897
22011
  * @type {World}
21898
22012
  */
21899
- this.world = null;
22013
+ this.world = undefined;
21900
22014
 
21901
22015
  /**
21902
22016
  * when true, all objects will be added under the root world container.<br>
@@ -21988,7 +22102,7 @@ class Application {
21988
22102
  * // call myFunction () everytime a level is loaded
21989
22103
  * me.game.onLevelLoaded = this.myFunction.bind(this);
21990
22104
  */
21991
- onLevelLoaded() {};
22105
+ onLevelLoaded() {}
21992
22106
 
21993
22107
  /**
21994
22108
  * Update the renderer framerate using the system config variables.
@@ -22946,16 +23060,18 @@ class Stage {
22946
23060
 
22947
23061
  // update the camera/viewport
22948
23062
  // iterate through all cameras
22949
- this.cameras.forEach(function(camera) {
23063
+ this.cameras.forEach((camera) => {
22950
23064
  if (camera.update(dt) === true) {
22951
23065
  isDirty = true;
22952
- } });
23066
+ }
23067
+ });
22953
23068
 
22954
23069
  // update all lights
22955
23070
  this.lights.forEach((light) => {
22956
23071
  if (light.update(dt) === true) {
22957
23072
  isDirty = true;
22958
- } });
23073
+ }
23074
+ });
22959
23075
 
22960
23076
  return isDirty;
22961
23077
  }
@@ -23100,6 +23216,7 @@ class ProgressBar extends Renderable {
23100
23216
  }
23101
23217
 
23102
23218
  }
23219
+
23103
23220
  /**
23104
23221
  * a default loading screen
23105
23222
  * @ignore
@@ -23831,6 +23948,7 @@ function parseAttributes(obj, elt) {
23831
23948
  function decompress() {
23832
23949
  throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
23833
23950
  }
23951
+
23834
23952
  /**
23835
23953
  * Decode a CSV encoded array into a binary array
23836
23954
  * @ignore
@@ -23847,6 +23965,7 @@ function decodeCSV(input) {
23847
23965
  }
23848
23966
  return result;
23849
23967
  }
23968
+
23850
23969
  /**
23851
23970
  * Decode a base64 encoded string into a byte array
23852
23971
  * @ignore
@@ -23870,6 +23989,7 @@ function decodeBase64AsArray(input, bytes) {
23870
23989
  }
23871
23990
  return ar;
23872
23991
  }
23992
+
23873
23993
  /**
23874
23994
  * Decode the given data
23875
23995
  * @ignore
@@ -23900,6 +24020,7 @@ function decode(data, encoding, compression) {
23900
24020
  throw new Error("Unknown layer encoding: " + encoding);
23901
24021
  }
23902
24022
  }
24023
+
23903
24024
  /**
23904
24025
  * Normalize TMX format to Tiled JSON format
23905
24026
  * @ignore
@@ -24007,6 +24128,7 @@ function normalize(obj, item) {
24007
24128
  break;
24008
24129
  }
24009
24130
  }
24131
+
24010
24132
  /**
24011
24133
  * Parse a XML TMX object and returns the corresponding javascript object
24012
24134
  * @ignore
@@ -24045,6 +24167,7 @@ function parse(xml) {
24045
24167
 
24046
24168
  return obj;
24047
24169
  }
24170
+
24048
24171
  /**
24049
24172
  * Apply TMX Properties to the given object
24050
24173
  * @ignore
@@ -24217,7 +24340,7 @@ class Tile extends Bounds {
24217
24340
  if (tileset.animations.has(this.tileId)) {
24218
24341
  var frames = [];
24219
24342
  var frameId = [];
24220
- (tileset.animations.get(this.tileId).frames).forEach(function (frame) {
24343
+ (tileset.animations.get(this.tileId).frames).forEach((frame) => {
24221
24344
  frameId.push(frame.tileid);
24222
24345
  frames.push({
24223
24346
  name : "" + frame.tileid,
@@ -25585,6 +25708,7 @@ class TMXRenderer {
25585
25708
  }
25586
25709
 
25587
25710
  }
25711
+
25588
25712
  /* eslint-enable no-unused-vars */
25589
25713
 
25590
25714
  /**
@@ -26756,7 +26880,7 @@ class TMXTileset {
26756
26880
  if (this._lastUpdate !== now) {
26757
26881
  this._lastUpdate = now;
26758
26882
 
26759
- this.animations.forEach(function (anim) {
26883
+ this.animations.forEach((anim) => {
26760
26884
  anim.dt += dt;
26761
26885
  duration = anim.cur.duration;
26762
26886
  while (anim.dt >= duration) {
@@ -27614,7 +27738,8 @@ class TMXTileMap {
27614
27738
  getRenderer() {
27615
27739
  if ((typeof(this.renderer) === "undefined") || (!this.renderer.canRender(this))) {
27616
27740
  this.renderer = getNewDefaultRenderer(this);
27617
- } return this.renderer;
27741
+ }
27742
+ return this.renderer;
27618
27743
  }
27619
27744
 
27620
27745
  /**
@@ -27724,12 +27849,12 @@ class TMXTileMap {
27724
27849
  }
27725
27850
 
27726
27851
  // add all layers instances
27727
- this.getLayers().forEach(function (layer) {
27852
+ this.getLayers().forEach((layer) => {
27728
27853
  container.addChild(layer);
27729
27854
  });
27730
27855
 
27731
27856
  // add all Object instances
27732
- this.getObjects(flatten).forEach(function (object) {
27857
+ this.getObjects(flatten).forEach((object) => {
27733
27858
  container.addChild(object);
27734
27859
  });
27735
27860
 
@@ -28008,6 +28133,7 @@ function safeLoadLevel(levelId, options, restart) {
28008
28133
  state.restart();
28009
28134
  }
28010
28135
  }
28136
+
28011
28137
  /**
28012
28138
  * Load a TMX level
28013
28139
  * @name loadTMXLevel
@@ -28033,6 +28159,7 @@ function loadTMXLevel(levelId, container, flatten, setViewportBounds) {
28033
28159
  level.addTo(container, flatten, setViewportBounds);
28034
28160
  }
28035
28161
 
28162
+
28036
28163
  /**
28037
28164
  * a level manager. once ressources loaded, the level manager contains all references of defined levels.
28038
28165
  * @namespace level
@@ -28276,7 +28403,7 @@ function checkLoadStatus(onload) {
28276
28403
  // trigger the onload callback
28277
28404
  // we call either the supplied callback (which takes precedence) or the global one
28278
28405
  var callback = onload || loader.onload;
28279
- setTimeout(function () {
28406
+ setTimeout(() => {
28280
28407
  callback();
28281
28408
  emit(LOADER_COMPLETE);
28282
28409
  }, 300);
@@ -28291,6 +28418,7 @@ function checkLoadStatus(onload) {
28291
28418
  }, 100);
28292
28419
  }
28293
28420
  }
28421
+
28294
28422
  /**
28295
28423
  * load Images
28296
28424
  * @example
@@ -28316,6 +28444,7 @@ function preloadImage(img, onload, onerror) {
28316
28444
  }
28317
28445
  imgList[img.name].src = img.src + loader.nocache;
28318
28446
  }
28447
+
28319
28448
  /**
28320
28449
  * load a font face
28321
28450
  * @example
@@ -28344,13 +28473,14 @@ function preloadFontFace(data, onload, onerror) {
28344
28473
  // onloaded callback
28345
28474
  onload();
28346
28475
  }
28347
- }, function () {
28476
+ }, () => {
28348
28477
  if (typeof onerror === "function") {
28349
28478
  // rejected
28350
28479
  onerror(data.name);
28351
28480
  }
28352
28481
  });
28353
28482
  }
28483
+
28354
28484
  /**
28355
28485
  * preload TMX files
28356
28486
  * @ignore
@@ -28458,6 +28588,7 @@ function preloadTMX(tmxData, onload, onerror) {
28458
28588
  // send the request
28459
28589
  xmlhttp.send();
28460
28590
  }
28591
+
28461
28592
  /**
28462
28593
  * preload JSON files
28463
28594
  * @ignore
@@ -28494,6 +28625,7 @@ function preloadJSON(data, onload, onerror) {
28494
28625
  // send the request
28495
28626
  xmlhttp.send();
28496
28627
  }
28628
+
28497
28629
  /**
28498
28630
  * preload Binary files
28499
28631
  * @ignore
@@ -28524,6 +28656,7 @@ function preloadBinary(data, onload, onerror) {
28524
28656
  };
28525
28657
  httpReq.send();
28526
28658
  }
28659
+
28527
28660
  /**
28528
28661
  * preload Binary files
28529
28662
  * @ignore
@@ -28554,6 +28687,7 @@ function preloadJavascript(data, onload, onerror) {
28554
28687
 
28555
28688
  document.getElementsByTagName("body")[0].appendChild(script);
28556
28689
  }
28690
+
28557
28691
  /**
28558
28692
  * a small class to manage loading of stuff and manage resources
28559
28693
  * @namespace loader
@@ -29218,6 +29352,7 @@ class Sprite extends Renderable {
29218
29352
  if (typeof settings.z !== "undefined") {
29219
29353
  this.pos.z = settings.z;
29220
29354
  }
29355
+
29221
29356
  // for sprite, addAnimation will return !=0
29222
29357
  if (this.addAnimation("default", null) !== 0) {
29223
29358
  // set as default
@@ -29317,7 +29452,7 @@ class Sprite extends Renderable {
29317
29452
  if (index == null) {
29318
29453
  index = [];
29319
29454
  // create a default animation with all frame
29320
- Object.keys(this.textureAtlas).forEach(function (v, i) {
29455
+ Object.keys(this.textureAtlas).forEach((v, i) => {
29321
29456
  index[i] = i;
29322
29457
  });
29323
29458
  }
@@ -29998,7 +30133,7 @@ class TextureAtlas {
29998
30133
  region = this.getAtlas(atlas)[name];
29999
30134
  } else {
30000
30135
  // look for the given region in each existing atlas
30001
- this.atlases.forEach(function (atlas) {
30136
+ this.atlases.forEach((atlas) => {
30002
30137
  if (typeof atlas[name] !== "undefined") {
30003
30138
  // there should be only one
30004
30139
  region = atlas[name];
@@ -31795,6 +31930,7 @@ function autoDetectRenderer(options) {
31795
31930
  }
31796
31931
  return new CanvasRenderer(options);
31797
31932
  }
31933
+
31798
31934
  /**
31799
31935
  * callback for window resize event
31800
31936
  * @ignore
@@ -31869,6 +32005,7 @@ function onresize() {
31869
32005
  scale(settings.scale, settings.scale);
31870
32006
  }
31871
32007
  }
32008
+
31872
32009
  /**
31873
32010
  * Select the HTML5 Canvas renderer
31874
32011
  * @name CANVAS
@@ -32020,7 +32157,7 @@ function init(width, height, options) {
32020
32157
  globalThis.addEventListener(
32021
32158
  "resize",
32022
32159
  utils.function.throttle(
32023
- function (e) {
32160
+ (e) => {
32024
32161
  emit(WINDOW_ONRESIZE, e);
32025
32162
  }, 100
32026
32163
  ), false
@@ -32029,7 +32166,7 @@ function init(width, height, options) {
32029
32166
  // Screen Orientation API
32030
32167
  globalThis.addEventListener(
32031
32168
  "orientationchange",
32032
- function (e) {
32169
+ (e) => {
32033
32170
  emit(WINDOW_ONORIENTATION_CHANGE, e);
32034
32171
  },
32035
32172
  false
@@ -32037,7 +32174,7 @@ function init(width, height, options) {
32037
32174
  // pre-fixed implementation on mozzila
32038
32175
  globalThis.addEventListener(
32039
32176
  "onmozorientationchange",
32040
- function (e) {
32177
+ (e) => {
32041
32178
  emit(WINDOW_ONORIENTATION_CHANGE, e);
32042
32179
  },
32043
32180
  false
@@ -32050,11 +32187,9 @@ function init(width, height, options) {
32050
32187
  }
32051
32188
 
32052
32189
  // Automatically update relative canvas position on scroll
32053
- globalThis.addEventListener("scroll", utils.function.throttle(
32054
- function (e) {
32055
- emit(WINDOW_ONSCROLL, e);
32056
- }, 100
32057
- ), false);
32190
+ globalThis.addEventListener("scroll", utils.function.throttle((e) => {
32191
+ emit(WINDOW_ONSCROLL, e);
32192
+ }, 100), false);
32058
32193
 
32059
32194
  // register to the channel
32060
32195
  on(WINDOW_ONRESIZE, onresize, this);
@@ -32123,6 +32258,7 @@ function init(width, height, options) {
32123
32258
 
32124
32259
  return true;
32125
32260
  }
32261
+
32126
32262
  /**
32127
32263
  * Create and return a new Canvas element
32128
32264
  * @function video.createCanvas
@@ -32154,6 +32290,7 @@ function createCanvas(width, height, returnOffscreenCanvas = false) {
32154
32290
 
32155
32291
  return _canvas;
32156
32292
  }
32293
+
32157
32294
  /**
32158
32295
  * return a reference to the parent DOM element holding the main canvas
32159
32296
  * @function video.getParent
@@ -32162,6 +32299,7 @@ function createCanvas(width, height, returnOffscreenCanvas = false) {
32162
32299
  function getParent() {
32163
32300
  return parent;
32164
32301
  }
32302
+
32165
32303
  /**
32166
32304
  * scale the "displayed" canvas by the given scalar.
32167
32305
  * this will modify the size of canvas element directly.
@@ -32326,9 +32464,9 @@ var utils = {
32326
32464
  }
32327
32465
 
32328
32466
  // parse the url
32329
- url.slice(1).split("&").filter(function (value) {
32467
+ url.slice(1).split("&").filter((value) => {
32330
32468
  return (value !== "");
32331
- }).forEach(function (value) {
32469
+ }).forEach((value) => {
32332
32470
  var kv = value.split("=");
32333
32471
  var k = kv.shift();
32334
32472
  var v = kv.join("=");
@@ -32616,6 +32754,7 @@ class Timer {
32616
32754
  }
32617
32755
  }
32618
32756
  }
32757
+
32619
32758
  const timer = new Timer();
32620
32759
 
32621
32760
  var lastTime = 0;
@@ -32640,7 +32779,7 @@ if (!requestAnimationFrame || !cancelAnimationFrame) {
32640
32779
  requestAnimationFrame = function (callback) {
32641
32780
  var currTime = globalThis.performance.now();
32642
32781
  var timeToCall = Math.max(0, (1000 / timer.maxfps) - (currTime - lastTime));
32643
- var id = globalThis.setTimeout(function () {
32782
+ var id = globalThis.setTimeout(() => {
32644
32783
  callback(currTime + timeToCall);
32645
32784
  }, timeToCall);
32646
32785
  lastTime = currTime + timeToCall;
@@ -32908,10 +33047,10 @@ class BasePlugin {
32908
33047
  * this can be overridden by the plugin
32909
33048
  * @public
32910
33049
  * @type {string}
32911
- * @default "13.4.0"
33050
+ * @default "14.0.0"
32912
33051
  * @name plugin.Base#version
32913
33052
  */
32914
- this.version = "13.4.0";
33053
+ this.version = "14.0.0";
32915
33054
  }
32916
33055
  }
32917
33056
 
@@ -33792,7 +33931,7 @@ class Tween {
33792
33931
  onComplete( onCompleteCallback ) {
33793
33932
  this._onCompleteCallback = onCompleteCallback;
33794
33933
  return this;
33795
- };
33934
+ }
33796
33935
 
33797
33936
  /** @ignore */
33798
33937
  update( dt ) {
@@ -34456,7 +34595,7 @@ class Text extends Renderable {
34456
34595
  */
34457
34596
  setFont(font, size = 10) {
34458
34597
  // font name and type
34459
- var font_names = font.split(",").map(function (value) {
34598
+ var font_names = font.split(",").map((value) => {
34460
34599
  value = value.trim();
34461
34600
  return (
34462
34601
  !/(^".*"$)|(^'.*'$)/.test(value)
@@ -34769,6 +34908,7 @@ class BitmapText extends Renderable {
34769
34908
  (settings.fontData.includes("info face")) ? settings.fontData : loader.getBinary(settings.fontData)
34770
34909
  );
34771
34910
  }
34911
+
34772
34912
  // if floating was specified through settings
34773
34913
  if (typeof settings.floating !== "undefined") {
34774
34914
  this.floating = !!settings.floating;
@@ -35083,6 +35223,7 @@ function getValueFromPair(string, pattern) {
35083
35223
 
35084
35224
  return value[0].split("=")[1];
35085
35225
  }
35226
+
35086
35227
  /**
35087
35228
  * Gets the first glyph in the map that is not a space character
35088
35229
  * @ignore
@@ -35100,6 +35241,7 @@ function getFirstGlyph(glyphs) {
35100
35241
  }
35101
35242
  return null;
35102
35243
  }
35244
+
35103
35245
  /**
35104
35246
  * Creates a glyph to use for the space character
35105
35247
  * @ignore
@@ -35118,7 +35260,6 @@ function createSpaceGlyph(glyphs) {
35118
35260
  }
35119
35261
  }
35120
35262
 
35121
-
35122
35263
  /**
35123
35264
  * Class for storing relevant data from the font file.
35124
35265
  * @ignore
@@ -35850,20 +35991,331 @@ class NineSliceSprite extends Sprite {
35850
35991
 
35851
35992
  /**
35852
35993
  * @classdesc
35853
- * GUI Object<br>
35854
- * A very basic object to manage GUI elements <br>
35855
- * The object simply register on the "pointerdown" <br>
35856
- * or "touchstart" event and call the onClick function"
35994
+ * This is a basic clickable container which you can use in your game UI.
35995
+ * Use this for example if you want to display a button which contains
35996
+ * text and images.
35997
+ * @augments Container
35998
+ */
35999
+ class UIBaseElement extends Container {
36000
+ /**
36001
+ *
36002
+ * @param {number} x The x position of the container
36003
+ * @param {number} y The y position of the container
36004
+ * @param {number} w width of the container (default: viewport width)
36005
+ * @param {number} h height of the container (default: viewport height)
36006
+ */
36007
+ constructor(x, y, w, h) {
36008
+ super(x, y, w, h);
36009
+ /**
36010
+ * object can be clicked or not
36011
+ * @type {boolean}
36012
+ */
36013
+ this.isClickable = true;
36014
+
36015
+ /**
36016
+ * Tap and hold threshold timeout in ms
36017
+ * @type {number}
36018
+ * @default 250
36019
+ */
36020
+ this.holdThreshold = 250;
36021
+
36022
+ /**
36023
+ * object can be tap and hold
36024
+ * @type {boolean}
36025
+ * @default false
36026
+ */
36027
+ this.isHoldable = false;
36028
+
36029
+ /**
36030
+ * true if the pointer is over the object
36031
+ * @type {boolean}
36032
+ * @default false
36033
+ */
36034
+ this.hover = false;
36035
+
36036
+ // object has been updated (clicked,etc..)
36037
+ this.holdTimeout = null;
36038
+ this.released = true;
36039
+
36040
+ // GUI items use screen coordinates
36041
+ this.floating = true;
36042
+
36043
+ // enable event detection
36044
+ this.isKinematic = false;
36045
+ }
36046
+
36047
+ /**
36048
+ * function callback for the pointerdown event
36049
+ * @ignore
36050
+ */
36051
+ clicked(event) {
36052
+ // Check if left mouse button is pressed
36053
+ if (event.button === 0 && this.isClickable) {
36054
+ this.dirty = true;
36055
+ this.released = false;
36056
+ if (this.isHoldable) {
36057
+ if (this.holdTimeout !== null) {
36058
+ timer.clearTimeout(this.holdTimeout);
36059
+ }
36060
+ this.holdTimeout = timer.setTimeout(
36061
+ this.hold.bind(this),
36062
+ this.holdThreshold,
36063
+ false
36064
+ );
36065
+ this.released = false;
36066
+ }
36067
+ return this.onClick(event);
36068
+ }
36069
+ }
36070
+
36071
+ /**
36072
+ * function called when the object is pressed (to be extended)
36073
+ * @param {Pointer} event the event object
36074
+ * @returns {boolean} return false if we need to stop propagating the event
36075
+ */
36076
+ onClick(event) { // eslint-disable-line no-unused-vars
36077
+ return false;
36078
+ }
36079
+
36080
+ /**
36081
+ * function callback for the pointerEnter event
36082
+ * @ignore
36083
+ */
36084
+ enter(event) {
36085
+ this.hover = true;
36086
+ this.dirty = true;
36087
+ return this.onOver(event);
36088
+ }
36089
+
36090
+ /**
36091
+ * function called when the pointer is over the object
36092
+ * @param {Pointer} event the event object
36093
+ */
36094
+ onOver(event) { // eslint-disable-line no-unused-vars
36095
+ // to be extended
36096
+ }
36097
+
36098
+ /**
36099
+ * function callback for the pointerLeave event
36100
+ * @ignore
36101
+ */
36102
+ leave(event) {
36103
+ this.hover = false;
36104
+ this.dirty = true;
36105
+ this.release(event);
36106
+ return this.onOut(event);
36107
+ }
36108
+
36109
+ /**
36110
+ * function called when the pointer is leaving the object area
36111
+ * @param {Pointer} event the event object
36112
+ */
36113
+ onOut(event) { // eslint-disable-line no-unused-vars
36114
+ // to be extended
36115
+ }
36116
+
36117
+ /**
36118
+ * function callback for the pointerup event
36119
+ * @ignore
36120
+ */
36121
+ release(event) {
36122
+ if (this.released === false) {
36123
+ this.released = true;
36124
+ this.dirty = true;
36125
+ timer.clearTimeout(this.holdTimeout);
36126
+ return this.onRelease(event);
36127
+ }
36128
+ }
36129
+
36130
+ /**
36131
+ * function called when the object is pressed and released (to be extended)
36132
+ * @returns {boolean} return false if we need to stop propagating the event
36133
+ */
36134
+ onRelease() {
36135
+ return false;
36136
+ }
36137
+
36138
+ /**
36139
+ * function callback for the tap and hold timer event
36140
+ * @ignore
36141
+ */
36142
+ hold() {
36143
+ timer.clearTimeout(this.holdTimeout);
36144
+ this.dirty = true;
36145
+ if (!this.released) {
36146
+ this.onHold();
36147
+ }
36148
+ }
36149
+
36150
+ /**
36151
+ * function called when the object is pressed and held<br>
36152
+ * to be extended <br>
36153
+ */
36154
+ onHold() {}
36155
+
36156
+ /**
36157
+ * function called when added to the game world or a container
36158
+ * @ignore
36159
+ */
36160
+ onActivateEvent() {
36161
+ // register pointer events
36162
+ registerPointerEvent(
36163
+ "pointerdown",
36164
+ this,
36165
+ this.clicked.bind(this)
36166
+ );
36167
+ registerPointerEvent("pointerup", this, this.release.bind(this));
36168
+ registerPointerEvent(
36169
+ "pointercancel",
36170
+ this,
36171
+ this.release.bind(this)
36172
+ );
36173
+ registerPointerEvent("pointerenter", this, this.enter.bind(this));
36174
+ registerPointerEvent("pointerleave", this, this.leave.bind(this));
36175
+ }
36176
+
36177
+ /**
36178
+ * function called when removed from the game world or a container
36179
+ * @ignore
36180
+ */
36181
+ onDeactivateEvent() {
36182
+ // release pointer events
36183
+ releasePointerEvent("pointerdown", this.hitbox);
36184
+ releasePointerEvent("pointerup", this);
36185
+ releasePointerEvent("pointercancel", this);
36186
+ releasePointerEvent("pointerenter", this);
36187
+ releasePointerEvent("pointerleave", this);
36188
+ timer.clearTimeout(this.holdTimeout);
36189
+ }
36190
+ }
36191
+
36192
+ /**
36193
+ * @classdesc
36194
+ * This is a basic base text button which you can use in your Game UI.
36195
+ * @augments UIBaseElement
36196
+ */
36197
+ class UITextButton extends UIBaseElement {
36198
+ /**
36199
+ * A Text Button with an outlined background border, filled with background color.
36200
+ * It uses a RoundRect as background and changes the background color on hovering over.
36201
+ * The background will be drawn with 0.5 opacity, so that the background of the button is
36202
+ * slightly shining through.
36203
+ * @param {number} x x pos of the button
36204
+ * @param {number} y y pos of the button
36205
+ * @param {string} [settings.font] The name of the BitmapText font to use
36206
+ * @param {number} [settings.size] The scale factor of the font (default: 1)
36207
+ * @param {string} [settings.text] The text to display (default: 'click me')
36208
+ * @param {string} [settings.bindKey] The key to bind the action to (default: none)
36209
+ * @param {string} [settings.backgroundColor] The css value of a background color
36210
+ * @param {string} [settings.hoverColor] The css value of a color to be used if the pointer hovers over the button
36211
+ * @param {string} [settings.borderStrokeColor] The css value of a color to be used to draw the border
36212
+ * @param {boolean} [settings.offScreenCanvas] Weather to use an offScreen canvas or not
36213
+ * @param {string} [settings.fillStyle] The css value of a tint color to be used to tint the text
36214
+ * @param {number} [settings.borderWidth] Width of the button
36215
+ * @param {number} [settings.borderHeight] Height of the button
36216
+ * @example
36217
+ * // Create a new Button
36218
+ * class PlayButton extends BaseTextButton {
36219
+ * constructor(x,y) {
36220
+ * super(x,y, {
36221
+ * font: 'my-font',
36222
+ * text: 'Play',
36223
+ * // if you omit the next two, size is calculated by the size of the text
36224
+ * borderWidth: 200,
36225
+ * borderHeight: 20,
36226
+ * });
36227
+ * }
36228
+ *
36229
+ * onClick(){
36230
+ * state.change(state.PLAY);
36231
+ * }
36232
+ * }
36233
+ *
36234
+ * game.world.addChild(new PlayButton(15,200));
36235
+ */
36236
+ constructor(x, y, settings) {
36237
+ super(x, y);
36238
+ settings.font = settings.font || "24Outline";
36239
+ settings.size = settings.size || 1;
36240
+ settings.text = settings.text || "<Click Me>";
36241
+ settings.bindKey = settings.bindKey || -1;
36242
+ settings.backgroundColor = settings.backgroundColor || "#00aa00";
36243
+ settings.hoverColor = settings.hoverColor || "#00ff00";
36244
+ settings.borderStrokeColor = settings.borderStrokeColor || "#000000";
36245
+ settings.offScreenCanvas = settings.offScreenCanvas || false;
36246
+ settings.fillStyle = settings.fillStyle || "#ffffff";
36247
+ settings.lineWidth = settings.lineWidth || 1;
36248
+ settings.anchorPoint = settings.anchorPoint || new Vector2d(0, 0);
36249
+
36250
+ let font = new BitmapText(x, y, settings);
36251
+ let dimensions = font.measureText();
36252
+ settings.borderWidth = settings.borderWidth || dimensions.width + 16;
36253
+ settings.borderHeight = settings.borderHeight || dimensions.height + 16;
36254
+
36255
+ let border = new RoundRect(
36256
+ x,
36257
+ y,
36258
+ settings.borderWidth,
36259
+ settings.borderHeight
36260
+ );
36261
+ super.setShape(
36262
+ x,
36263
+ y,
36264
+ border.getBounds().width,
36265
+ border.getBounds().height
36266
+ );
36267
+
36268
+ // build up
36269
+ this.font = font;
36270
+ this.dimensions = dimensions;
36271
+ this.border = border;
36272
+ this.settings = settings;
36273
+
36274
+ // adjust text position
36275
+ this.font.pos.set(
36276
+ Math.round((border.width - dimensions.width) / 2) + this.font.pos.x,
36277
+ Math.round((border.height - dimensions.height) / 2) +
36278
+ this.font.pos.y
36279
+ );
36280
+ }
36281
+
36282
+ draw(renderer) {
36283
+ renderer.setGlobalAlpha(0.5);
36284
+ if (!this.hover) {
36285
+ renderer.setColor(this.settings.backgroundColor);
36286
+ } else {
36287
+ renderer.setColor(this.settings.hoverColor);
36288
+ }
36289
+
36290
+ renderer.fill(this.border);
36291
+ renderer.setGlobalAlpha(1);
36292
+ renderer.setColor(this.settings.borderStrokeColor);
36293
+ renderer.stroke(this.border);
36294
+
36295
+ // fix: supporting tint
36296
+ renderer.setTint(this.font.tint, this.font.getOpacity());
36297
+ this.font.draw(
36298
+ renderer,
36299
+ this.settings.text,
36300
+ this.font.pos.x,
36301
+ this.font.pos.y
36302
+ );
36303
+ }
36304
+ }
36305
+
36306
+ /**
36307
+ * @classdesc
36308
+ * This is a basic sprite based button which you can use in your Game UI.
35857
36309
  * @augments Sprite
35858
36310
  */
35859
- class GUI_Object extends Sprite {
36311
+ class UISpriteElement extends Sprite {
35860
36312
  /**
35861
36313
  * @param {number} x the x coordinate of the GUI Object
35862
36314
  * @param {number} y the y coordinate of the GUI Object
35863
36315
  * @param {object} settings See {@link Sprite}
35864
36316
  * @example
35865
36317
  * // create a basic GUI Object
35866
- * class myButton extends GUI_Object {
36318
+ * class myButton extends UISpriteElement {
35867
36319
  * constructor(x, y) {
35868
36320
  * var settings = {}
35869
36321
  * settings.image = "button";
@@ -35894,10 +36346,8 @@ class GUI_Object extends Sprite {
35894
36346
 
35895
36347
  /**
35896
36348
  * object can be clicked or not
35897
- * @public
35898
36349
  * @type {boolean}
35899
36350
  * @default true
35900
- * @name GUI_Object#isClickable
35901
36351
  */
35902
36352
  this.isClickable = true;
35903
36353
 
@@ -35905,25 +36355,20 @@ class GUI_Object extends Sprite {
35905
36355
  * Tap and hold threshold timeout in ms
35906
36356
  * @type {number}
35907
36357
  * @default 250
35908
- * @name GUI_Object#holdThreshold
35909
36358
  */
35910
36359
  this.holdThreshold = 250;
35911
36360
 
35912
36361
  /**
35913
36362
  * object can be tap and hold
35914
- * @public
35915
36363
  * @type {boolean}
35916
36364
  * @default false
35917
- * @name GUI_Object#isHoldable
35918
36365
  */
35919
36366
  this.isHoldable = false;
35920
36367
 
35921
36368
  /**
35922
36369
  * true if the pointer is over the object
35923
- * @public
35924
36370
  * @type {boolean}
35925
36371
  * @default false
35926
- * @name GUI_Object#hover
35927
36372
  */
35928
36373
  this.hover = false;
35929
36374
 
@@ -35960,9 +36405,6 @@ class GUI_Object extends Sprite {
35960
36405
 
35961
36406
  /**
35962
36407
  * function called when the object is pressed (to be extended)
35963
- * @name onClick
35964
- * @memberof GUI_Object
35965
- * @public
35966
36408
  * @param {Pointer} event the event object
35967
36409
  * @returns {boolean} return false if we need to stop propagating the event
35968
36410
  */
@@ -35982,9 +36424,6 @@ class GUI_Object extends Sprite {
35982
36424
 
35983
36425
  /**
35984
36426
  * function called when the pointer is over the object
35985
- * @name onOver
35986
- * @memberof GUI_Object
35987
- * @public
35988
36427
  * @param {Pointer} event the event object
35989
36428
  */
35990
36429
  onOver(event) { // eslint-disable-line no-unused-vars
@@ -36004,9 +36443,6 @@ class GUI_Object extends Sprite {
36004
36443
 
36005
36444
  /**
36006
36445
  * function called when the pointer is leaving the object area
36007
- * @name onOut
36008
- * @memberof GUI_Object
36009
- * @public
36010
36446
  * @param {Pointer} event the event object
36011
36447
  */
36012
36448
  onOut(event) { // eslint-disable-line no-unused-vars
@@ -36028,9 +36464,6 @@ class GUI_Object extends Sprite {
36028
36464
 
36029
36465
  /**
36030
36466
  * function called when the object is pressed and released (to be extended)
36031
- * @name onRelease
36032
- * @memberof GUI_Object
36033
- * @public
36034
36467
  * @returns {boolean} return false if we need to stop propagating the event
36035
36468
  */
36036
36469
  onRelease() {
@@ -36052,9 +36485,6 @@ class GUI_Object extends Sprite {
36052
36485
  /**
36053
36486
  * function called when the object is pressed and held<br>
36054
36487
  * to be extended <br>
36055
- * @name onHold
36056
- * @memberof GUI_Object
36057
- * @public
36058
36488
  */
36059
36489
  onHold() {}
36060
36490
 
@@ -36188,11 +36618,11 @@ class Trigger extends Renderable {
36188
36618
  event: "level"
36189
36619
  };
36190
36620
 
36191
- [ "type", "container", "onLoaded", "flatten", "setViewportBounds", "to" ].forEach(function(property) {
36621
+ [ "type", "container", "onLoaded", "flatten", "setViewportBounds", "to" ].forEach((property) => {
36192
36622
  if (typeof settings[property] !== "undefined") {
36193
36623
  this.triggerSettings[property] = settings[property];
36194
36624
  }
36195
- }.bind(this));
36625
+ });
36196
36626
 
36197
36627
  // add and configure the physic body
36198
36628
  var shape = settings.shapes;
@@ -36525,6 +36955,7 @@ class Draggable extends Renderable {
36525
36955
  super.destroy();
36526
36956
  }
36527
36957
  }
36958
+
36528
36959
  /**
36529
36960
  * @classdesc
36530
36961
  * a base drop target object
@@ -36948,6 +37379,7 @@ function createDefaultParticleTexture(w = 8, h = 8) {
36948
37379
 
36949
37380
  return defaultParticleTexture;
36950
37381
  }
37382
+
36951
37383
  /**
36952
37384
  * @classdesc
36953
37385
  * Particle Emitter Object.
@@ -37635,6 +38067,7 @@ function warning(deprecated, replacement, version) {
37635
38067
  console.groupEnd();
37636
38068
  }
37637
38069
  }
38070
+
37638
38071
  /**
37639
38072
  * Alias of {@link TextureAtlas}
37640
38073
  * @public
@@ -37719,6 +38152,25 @@ Renderer.prototype.getScreenContext = function() {
37719
38152
  return this.getContext();
37720
38153
  };
37721
38154
 
38155
+ /**
38156
+ * @classdesc
38157
+ * A very basic object to manage GUI elements
38158
+ * @augments Sprite
38159
+ * @deprecated since 14.0.0
38160
+ * @see UISpriteElement
38161
+ */
38162
+ class GUI_Object extends UISpriteElement {
38163
+ /**
38164
+ * @param {number} x the x coordinate of the GUI Object
38165
+ * @param {number} y the y coordinate of the GUI Object
38166
+ * @param {object} settings See {@link Sprite}
38167
+ */
38168
+ constructor(x, y, settings) {
38169
+ warning("GUI_Object", "UISpriteElement", "14.0.0");
38170
+ super(x, y, settings);
38171
+ }
38172
+ }
38173
+
37722
38174
  // ES5/ES6 polyfills
37723
38175
 
37724
38176
 
@@ -37729,7 +38181,7 @@ Renderer.prototype.getScreenContext = function() {
37729
38181
  * @name version
37730
38182
  * @type {string}
37731
38183
  */
37732
- const version = "13.4.0";
38184
+ const version = "14.0.0";
37733
38185
 
37734
38186
 
37735
38187
  /**
@@ -37835,11 +38287,12 @@ function boot() {
37835
38287
  // mark melonJS as initialized
37836
38288
  initialized = true;
37837
38289
  }
38290
+
37838
38291
  // call the library init function when ready
37839
- onReady(function () {
38292
+ onReady(() => {
37840
38293
  {
37841
38294
  boot();
37842
38295
  }
37843
38296
  });
37844
38297
 
37845
- export { BitmapText, BitmapTextData, Body, Bounds, Camera2d, CanvasRenderer, Collectable, Color, ColorLayer, 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, QuadTree, Rect, Renderable, Renderer, RoundRect, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, Text, TextureAtlas, Tile, Trigger, Tween, Vector2d, Vector3d, WebGLCompositor, WebGLRenderer, World, audio, boot, collision, device, event, game, initialized, input, level, loader, plugin, plugins, pool, save, skipAutoInit, state, timer, utils, version, video, warning };
38298
+ export { BitmapText, BitmapTextData, Body, Bounds, Camera2d, CanvasRenderer, Collectable, Color, ColorLayer, 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, 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, WebGLCompositor, WebGLRenderer, World, audio, boot, collision, device, event, game, initialized, input, level, loader, plugin, plugins, pool, save, skipAutoInit, state, timer, utils, version, video, warning };