@vpmedia/phaser 1.113.0 → 1.115.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 (170) hide show
  1. package/dist/index.js +402 -379
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation_manager.d.ts +2 -1
  4. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  5. package/dist/phaser/core/array_set.d.ts +1 -1
  6. package/dist/phaser/core/array_set.d.ts.map +1 -1
  7. package/dist/phaser/core/cache.d.ts +1 -1
  8. package/dist/phaser/core/cache.d.ts.map +1 -1
  9. package/dist/phaser/core/factory.d.ts +1 -1
  10. package/dist/phaser/core/factory.d.ts.map +1 -1
  11. package/dist/phaser/core/game.d.ts +2 -0
  12. package/dist/phaser/core/game.d.ts.map +1 -1
  13. package/dist/phaser/core/input.d.ts +5 -5
  14. package/dist/phaser/core/input.d.ts.map +1 -1
  15. package/dist/phaser/core/input_event.d.ts +35 -0
  16. package/dist/phaser/core/input_event.d.ts.map +1 -0
  17. package/dist/phaser/core/input_handler.d.ts +2 -2
  18. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  19. package/dist/phaser/core/input_mouse.d.ts +27 -26
  20. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  21. package/dist/phaser/core/input_mspointer.d.ts +16 -15
  22. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  23. package/dist/phaser/core/input_pointer.d.ts +9 -8
  24. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  25. package/dist/phaser/core/input_touch.d.ts +18 -17
  26. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  27. package/dist/phaser/core/loader.d.ts +64 -30
  28. package/dist/phaser/core/loader.d.ts.map +1 -1
  29. package/dist/phaser/core/scale_manager.d.ts +1 -1
  30. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  31. package/dist/phaser/core/scene_manager.d.ts +14 -4
  32. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  33. package/dist/phaser/core/signal.d.ts +8 -8
  34. package/dist/phaser/core/signal.d.ts.map +1 -1
  35. package/dist/phaser/core/signal_binding.d.ts +2 -2
  36. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  37. package/dist/phaser/core/sound.d.ts +1 -1
  38. package/dist/phaser/core/sound.d.ts.map +1 -1
  39. package/dist/phaser/core/sound_manager.d.ts +3 -3
  40. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  41. package/dist/phaser/core/sound_sprite.d.ts +1 -1
  42. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  43. package/dist/phaser/core/timer.d.ts +5 -5
  44. package/dist/phaser/core/timer.d.ts.map +1 -1
  45. package/dist/phaser/core/timer_event.d.ts +2 -2
  46. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  47. package/dist/phaser/core/tween.d.ts +4 -4
  48. package/dist/phaser/core/tween.d.ts.map +1 -1
  49. package/dist/phaser/core/tween_data.d.ts +2 -1
  50. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  51. package/dist/phaser/core/tween_manager.d.ts +1 -1
  52. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  53. package/dist/phaser/display/button.d.ts +1 -1
  54. package/dist/phaser/display/button.d.ts.map +1 -1
  55. package/dist/phaser/display/canvas/buffer.d.ts +3 -3
  56. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  57. package/dist/phaser/display/canvas/graphics.d.ts +2 -2
  58. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  59. package/dist/phaser/display/canvas/masker.d.ts +5 -2
  60. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  61. package/dist/phaser/display/canvas/renderer.d.ts +6 -5
  62. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  63. package/dist/phaser/display/canvas/tinter.d.ts +2 -1
  64. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  65. package/dist/phaser/display/canvas/util.d.ts +11 -4
  66. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  67. package/dist/phaser/display/display_object.d.ts +4 -3
  68. package/dist/phaser/display/display_object.d.ts.map +1 -1
  69. package/dist/phaser/display/graphics.d.ts +47 -27
  70. package/dist/phaser/display/graphics.d.ts.map +1 -1
  71. package/dist/phaser/display/graphics_data.d.ts +20 -11
  72. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  73. package/dist/phaser/display/image.d.ts +4 -3
  74. package/dist/phaser/display/image.d.ts.map +1 -1
  75. package/dist/phaser/display/render_session.d.ts +44 -0
  76. package/dist/phaser/display/render_session.d.ts.map +1 -0
  77. package/dist/phaser/display/sprite_util.d.ts +4 -3
  78. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  79. package/dist/phaser/display/text.d.ts +65 -31
  80. package/dist/phaser/display/text.d.ts.map +1 -1
  81. package/dist/phaser/display/webgl/base_texture.d.ts +3 -3
  82. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  83. package/dist/phaser/display/webgl/earcut.d.ts +25 -25
  84. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  85. package/dist/phaser/display/webgl/earcut_node.d.ts +2 -2
  86. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  87. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +3 -2
  88. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  89. package/dist/phaser/display/webgl/filter_manager.d.ts +1 -1
  90. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  91. package/dist/phaser/display/webgl/graphics.d.ts +2 -1
  92. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  93. package/dist/phaser/display/webgl/graphics_data.d.ts +9 -9
  94. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  95. package/dist/phaser/display/webgl/mask_manager.d.ts +3 -2
  96. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  97. package/dist/phaser/display/webgl/render_texture.d.ts +3 -3
  98. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  99. package/dist/phaser/display/webgl/renderer.d.ts +5 -4
  100. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  101. package/dist/phaser/display/webgl/shader/normal.d.ts +3 -1
  102. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  103. package/dist/phaser/display/webgl/shader_manager.d.ts +10 -4
  104. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  105. package/dist/phaser/display/webgl/sprite_batch.d.ts +4 -3
  106. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  107. package/dist/phaser/display/webgl/stencil_manager.d.ts +4 -3
  108. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  109. package/dist/phaser/display/webgl/texture.d.ts +6 -6
  110. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  111. package/package.json +1 -1
  112. package/src/phaser/core/animation_manager.ts +2 -2
  113. package/src/phaser/core/array_set.ts +1 -1
  114. package/src/phaser/core/cache.ts +1 -1
  115. package/src/phaser/core/factory.ts +1 -1
  116. package/src/phaser/core/game.ts +2 -0
  117. package/src/phaser/core/input.ts +7 -6
  118. package/src/phaser/core/input_event.ts +34 -0
  119. package/src/phaser/core/input_handler.ts +2 -11
  120. package/src/phaser/core/input_mouse.ts +53 -36
  121. package/src/phaser/core/input_mspointer.ts +54 -29
  122. package/src/phaser/core/input_pointer.test.ts +149 -0
  123. package/src/phaser/core/input_pointer.ts +20 -21
  124. package/src/phaser/core/input_touch.ts +48 -31
  125. package/src/phaser/core/loader.test.ts +139 -0
  126. package/src/phaser/core/loader.ts +146 -83
  127. package/src/phaser/core/scale_manager.ts +1 -1
  128. package/src/phaser/core/scene_manager.ts +16 -8
  129. package/src/phaser/core/signal.ts +8 -8
  130. package/src/phaser/core/signal_binding.ts +2 -2
  131. package/src/phaser/core/sound.ts +4 -4
  132. package/src/phaser/core/sound_manager.ts +17 -19
  133. package/src/phaser/core/sound_sprite.ts +2 -2
  134. package/src/phaser/core/timer.ts +6 -6
  135. package/src/phaser/core/timer_event.ts +2 -2
  136. package/src/phaser/core/tween.ts +6 -6
  137. package/src/phaser/core/tween_data.ts +2 -1
  138. package/src/phaser/core/tween_manager.ts +1 -1
  139. package/src/phaser/display/button.ts +1 -1
  140. package/src/phaser/display/canvas/buffer.ts +3 -3
  141. package/src/phaser/display/canvas/graphics.ts +24 -20
  142. package/src/phaser/display/canvas/masker.ts +5 -2
  143. package/src/phaser/display/canvas/renderer.ts +10 -11
  144. package/src/phaser/display/canvas/tinter.ts +4 -3
  145. package/src/phaser/display/canvas/util.ts +15 -5
  146. package/src/phaser/display/display_object.ts +6 -5
  147. package/src/phaser/display/graphics.test.ts +122 -0
  148. package/src/phaser/display/graphics.ts +73 -64
  149. package/src/phaser/display/graphics_data.ts +22 -12
  150. package/src/phaser/display/image.ts +4 -3
  151. package/src/phaser/display/render_session.ts +45 -0
  152. package/src/phaser/display/sprite_util.ts +10 -8
  153. package/src/phaser/display/text.test.ts +136 -0
  154. package/src/phaser/display/text.ts +183 -119
  155. package/src/phaser/display/webgl/base_texture.ts +3 -3
  156. package/src/phaser/display/webgl/earcut.test.ts +132 -0
  157. package/src/phaser/display/webgl/earcut.ts +84 -74
  158. package/src/phaser/display/webgl/earcut_node.ts +5 -5
  159. package/src/phaser/display/webgl/fast_sprite_batch.ts +4 -4
  160. package/src/phaser/display/webgl/filter_manager.ts +1 -1
  161. package/src/phaser/display/webgl/graphics.ts +26 -17
  162. package/src/phaser/display/webgl/graphics_data.ts +9 -9
  163. package/src/phaser/display/webgl/mask_manager.ts +3 -2
  164. package/src/phaser/display/webgl/render_texture.ts +3 -3
  165. package/src/phaser/display/webgl/renderer.ts +7 -6
  166. package/src/phaser/display/webgl/shader/normal.ts +23 -6
  167. package/src/phaser/display/webgl/shader_manager.ts +15 -6
  168. package/src/phaser/display/webgl/sprite_batch.ts +4 -3
  169. package/src/phaser/display/webgl/stencil_manager.ts +10 -3
  170. package/src/phaser/display/webgl/texture.ts +6 -6
package/dist/index.js CHANGED
@@ -1637,9 +1637,9 @@ const canUseNewCanvasBlendModes = () => {
1637
1637
  if (document === void 0) throw new Error(ENGINE_ERROR_GETTING_DOCUMENT);
1638
1638
  const pngHead = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/";
1639
1639
  const pngEnd = "AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==";
1640
- const magenta = new Image();
1640
+ const magenta = new globalThis.Image();
1641
1641
  magenta.src = `${pngHead}AP804Oa6${pngEnd}`;
1642
- const yellow = new Image();
1642
+ const yellow = new globalThis.Image();
1643
1643
  yellow.src = `${pngHead}/wCKxvRF${pngEnd}`;
1644
1644
  const canvas = create$1("CanvasTinter", 6, 1, true);
1645
1645
  const context = canvas.getContext("2d", { willReadFrequently: false });
@@ -1678,6 +1678,110 @@ const detectCapabilities = (game) => {
1678
1678
  globalThis.PhaserRegistry.CANVAS_TINT_METHOD = globalThis.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY ? tintWithMultiply : tintWithPerPixel;
1679
1679
  };
1680
1680
  //#endregion
1681
+ //#region src/phaser/display/canvas/util.ts
1682
+ /**
1683
+ * Creates a new HTML canvas element.
1684
+ * @param {object} parent - The parent element to append the canvas to.
1685
+ * @param {number} width - The width of the canvas.
1686
+ * @param {number} height - The height of the canvas.
1687
+ * @param {string} id - The ID to assign to the canvas.
1688
+ * @param {boolean} skipPool - Whether to skip using the canvas pool.
1689
+ * @returns {HTMLCanvasElement} The created HTML canvas element.
1690
+ */
1691
+ const create = (parent, width, height, id, skipPool) => {
1692
+ width = width || 256;
1693
+ height = height || 256;
1694
+ const canvas = skipPool ? document.createElement("canvas") : create$1(parent, width, height);
1695
+ if (typeof id === "string" && id !== "") canvas.id = id;
1696
+ canvas.width = width;
1697
+ canvas.height = height;
1698
+ canvas.style.display = "block";
1699
+ return canvas;
1700
+ };
1701
+ /**
1702
+ * Sets the touch action property of a canvas element.
1703
+ * @param {HTMLCanvasElement} canvas - The canvas element to modify.
1704
+ * @param {string} value - The touch action value to set.
1705
+ * @returns {HTMLCanvasElement} The modified canvas element.
1706
+ */
1707
+ const setTouchAction = (canvas, value = "none") => {
1708
+ value = value || "none";
1709
+ canvas.style.setProperty("-ms-touch-action", value);
1710
+ canvas.style.setProperty("touch-action", value);
1711
+ return canvas;
1712
+ };
1713
+ /**
1714
+ * Sets the user select property of a canvas element.
1715
+ * @param {HTMLCanvasElement} canvas - The canvas element to modify.
1716
+ * @param {string} value - The user select value to set.
1717
+ * @returns {HTMLCanvasElement} The modified canvas element.
1718
+ */
1719
+ const setUserSelect = (canvas, value = "none") => {
1720
+ value = value || "none";
1721
+ canvas.style.setProperty("-webkit-touch-callout", value);
1722
+ canvas.style.setProperty("-webkit-user-select", value);
1723
+ canvas.style.setProperty("-khtml-user-select", value);
1724
+ canvas.style.setProperty("-moz-user-select", value);
1725
+ canvas.style.setProperty("-ms-user-select", value);
1726
+ canvas.style.setProperty("user-select", value);
1727
+ canvas.style.setProperty("-webkit-tap-highlight-color", "rgba(0, 0, 0, 0)");
1728
+ return canvas;
1729
+ };
1730
+ /**
1731
+ * Adds a canvas element to the DOM.
1732
+ * @param {HTMLCanvasElement} canvas - The canvas element to add.
1733
+ * @param {object} parent - The parent element to append the canvas to.
1734
+ * @param {boolean} overflowHidden - Whether to set overflow hidden on the parent.
1735
+ * @returns {HTMLCanvasElement} The added canvas element.
1736
+ */
1737
+ const addToDOM = (canvas, parent, overflowHidden = true) => {
1738
+ let target;
1739
+ if (parent) {
1740
+ if (typeof parent === "string") target = document.querySelector(`#${parent}`);
1741
+ else if (typeof parent === "object" && parent.nodeType === 1) target = parent;
1742
+ }
1743
+ target ??= document.body;
1744
+ if (overflowHidden && target.style) target.style.overflow = "hidden";
1745
+ target.append(canvas);
1746
+ return canvas;
1747
+ };
1748
+ /**
1749
+ * Removes a canvas element from the DOM.
1750
+ * @param {HTMLCanvasElement} canvas - The canvas element to remove.
1751
+ */
1752
+ const removeFromDOM = (canvas) => {
1753
+ if (canvas && canvas.parentNode) canvas.parentNode.removeChild(canvas);
1754
+ };
1755
+ /**
1756
+ * Gets the smoothing prefix for a canvas rendering context.
1757
+ * @param {CanvasRenderingContext2D} context - The canvas rendering context.
1758
+ * @returns {string | null} The smoothing property name or null if not found.
1759
+ */
1760
+ const getSmoothingPrefix = (context) => {
1761
+ const VENDORS = [
1762
+ "i",
1763
+ "webkitI",
1764
+ "msI",
1765
+ "mozI",
1766
+ "oI"
1767
+ ];
1768
+ const smoothingFlags = context;
1769
+ for (let i = 0; i < VENDORS.length; i += 1) {
1770
+ const s = `${VENDORS[i]}mageSmoothingEnabled`;
1771
+ if (context && smoothingFlags[s]) return s;
1772
+ }
1773
+ return null;
1774
+ };
1775
+ /**
1776
+ * Writes one of the vendor-prefixed image smoothing properties, which are not on the DOM type.
1777
+ * @param {CanvasRenderingContext2D} context - The canvas rendering context.
1778
+ * @param {string} property - The smoothing property name to write.
1779
+ * @param {boolean} value - The smoothing value to set.
1780
+ */
1781
+ const setSmoothing = (context, property, value) => {
1782
+ context[property] = value;
1783
+ };
1784
+ //#endregion
1681
1785
  //#region src/phaser/display/sprite_util.ts
1682
1786
  /**
1683
1787
  * Sets the texture of a sprite.
@@ -1826,7 +1930,7 @@ const renderCanvas = (target, renderSession, matrix = null) => {
1826
1930
  if (matrix) wt = matrix;
1827
1931
  if (target.blendMode !== renderSession.currentBlendMode) {
1828
1932
  renderSession.currentBlendMode = target.blendMode;
1829
- renderSession.context.globalCompositeOperation = globalThis.PhaserRegistry.blendModesCanvas[renderSession.currentBlendMode];
1933
+ renderSession.context.globalCompositeOperation = globalThis.PhaserRegistry.blendModesCanvas[renderSession.currentBlendMode] ?? "source-over";
1830
1934
  }
1831
1935
  if (target._mask) renderSession.maskManager.pushMask(target._mask, renderSession);
1832
1936
  if (target.texture.valid) {
@@ -1834,7 +1938,7 @@ const renderCanvas = (target, renderSession, matrix = null) => {
1834
1938
  renderSession.context.globalAlpha = target.worldAlpha;
1835
1939
  if (renderSession.smoothProperty && renderSession.scaleMode !== target.texture.baseTexture.scaleMode) {
1836
1940
  renderSession.scaleMode = target.texture.baseTexture.scaleMode;
1837
- renderSession.context[renderSession.smoothProperty] = renderSession.scaleMode === 0;
1941
+ setSmoothing(renderSession.context, renderSession.smoothProperty, renderSession.scaleMode === 0);
1838
1942
  }
1839
1943
  let dx = target.texture.trim ? target.texture.trim.x - target.anchor.x * target.texture.trim.width : target.anchor.x * -target.texture.frame.width;
1840
1944
  let dy = target.texture.trim ? target.texture.trim.y - target.anchor.y * target.texture.trim.height : target.anchor.y * -target.texture.frame.height;
@@ -1850,7 +1954,7 @@ const renderCanvas = (target, renderSession, matrix = null) => {
1850
1954
  dx /= resolution;
1851
1955
  dy /= resolution;
1852
1956
  if (target.tint !== 16777215) {
1853
- if (target.texture.requiresReTint || target.cachedTint !== target.tint) {
1957
+ if (target.texture.requiresReTint || target.cachedTint !== target.tint || !target.tintedTexture) {
1854
1958
  target.tintedTexture = getTintedTexture(target, target.tint);
1855
1959
  target.cachedTint = target.tint;
1856
1960
  target.texture.requiresReTint = false;
@@ -1865,7 +1969,7 @@ const renderCanvas = (target, renderSession, matrix = null) => {
1865
1969
  }
1866
1970
  }
1867
1971
  for (const child of target.children) child.renderCanvas(renderSession);
1868
- if (target._mask) renderSession.maskManager.popMask(renderSession);
1972
+ if (target._mask) renderSession.maskManager.popMask(target._mask, renderSession);
1869
1973
  };
1870
1974
  //#endregion
1871
1975
  //#region src/phaser/display/display_object.ts
@@ -2312,7 +2416,7 @@ var DisplayObject = class {
2312
2416
  if (!this.visible || this.alpha <= 0) return;
2313
2417
  if (this._mask) renderSession.maskManager.pushMask(this._mask, renderSession);
2314
2418
  for (const child of this.children) child.renderCanvas(renderSession);
2315
- if (this._mask) renderSession.maskManager.popMask(renderSession);
2419
+ if (this._mask) renderSession.maskManager.popMask(this._mask, renderSession);
2316
2420
  }
2317
2421
  /**
2318
2422
  * Called before the update cycle for this display object.
@@ -3323,7 +3427,6 @@ var AnimationManager = class {
3323
3427
  this.currentAnim = null;
3324
3428
  this.currentFrame = null;
3325
3429
  this.sprite = null;
3326
- this.game = null;
3327
3430
  }
3328
3431
  /**
3329
3432
  * Loads frame data into the AnimationManager.
@@ -4616,7 +4719,6 @@ var InputHandler = class {
4616
4719
  draggable;
4617
4720
  boundsRect;
4618
4721
  boundsSprite;
4619
- scaleLayer;
4620
4722
  dragOffset;
4621
4723
  dragFromCenter;
4622
4724
  dragStopBlocksInputUp;
@@ -4665,7 +4767,6 @@ var InputHandler = class {
4665
4767
  this.draggable = false;
4666
4768
  this.boundsRect = null;
4667
4769
  this.boundsSprite = null;
4668
- this.scaleLayer = false;
4669
4770
  this.dragOffset = new Point();
4670
4771
  this.dragFromCenter = false;
4671
4772
  this.dragStopBlocksInputUp = false;
@@ -5231,10 +5332,6 @@ var InputHandler = class {
5231
5332
  * @returns {number} TBD.
5232
5333
  */
5233
5334
  globalToLocalX(x) {
5234
- if (this.scaleLayer) {
5235
- x -= this.game.scale.grid.boundsFluid.x;
5236
- x *= this.game.scale.grid.scaleFluidInversed.x;
5237
- }
5238
5335
  return x;
5239
5336
  }
5240
5337
  /**
@@ -5243,10 +5340,6 @@ var InputHandler = class {
5243
5340
  * @returns {number} TBD.
5244
5341
  */
5245
5342
  globalToLocalY(y) {
5246
- if (this.scaleLayer) {
5247
- y -= this.game.scale.grid.boundsFluid.y;
5248
- y *= this.game.scale.grid.scaleFluidInversed.y;
5249
- }
5250
5343
  return y;
5251
5344
  }
5252
5345
  /**
@@ -6245,7 +6338,7 @@ const updateGraphicsTint = (graphics) => {
6245
6338
  const tintG = (graphics.tint >> 8 & 255) / 255;
6246
6339
  const tintB = (graphics.tint & 255) / 255;
6247
6340
  for (const data of graphics.graphicsData) {
6248
- const fillColor = Math.trunc(data.fillColor);
6341
+ const fillColor = Math.trunc(data.fillColor ?? 0);
6249
6342
  const lineColor = Math.trunc(data.lineColor);
6250
6343
  data._fillTint = ((fillColor >> 16 & 255) / 255 * tintR * 255 << 16) + ((fillColor >> 8 & 255) / 255 * tintG * 255 << 8) + (fillColor & 255) / 255 * tintB * 255;
6251
6344
  data._lineTint = ((lineColor >> 16 & 255) / 255 * tintR * 255 << 16) + ((lineColor >> 8 & 255) / 255 * tintG * 255 << 8) + (lineColor & 255) / 255 * tintB * 255;
@@ -6267,7 +6360,7 @@ const renderGraphics$1 = (graphics, context) => {
6267
6360
  const fillColor = data._fillTint;
6268
6361
  const lineColor = data._lineTint;
6269
6362
  context.lineWidth = data.lineWidth;
6270
- if (data.type === 12) {
6363
+ if (shape instanceof Polygon) {
6271
6364
  context.beginPath();
6272
6365
  const { points } = shape;
6273
6366
  context.moveTo(points[0], points[1]);
@@ -6276,7 +6369,7 @@ const renderGraphics$1 = (graphics, context) => {
6276
6369
  if (points[0] === points.at(-2) && points[1] === points.at(-1)) context.closePath();
6277
6370
  if (data.fill) {
6278
6371
  context.globalAlpha = data.fillAlpha * worldAlpha;
6279
- context.fillStyle = `#${`00000${Math.trunc(fillColor).toString(16)}`.slice(-6)}`;
6372
+ context.fillStyle = `#${`00000${Math.trunc(fillColor ?? 0).toString(16)}`.slice(-6)}`;
6280
6373
  context.fill();
6281
6374
  }
6282
6375
  if (data.lineWidth) {
@@ -6284,10 +6377,10 @@ const renderGraphics$1 = (graphics, context) => {
6284
6377
  context.strokeStyle = `#${`00000${Math.trunc(lineColor).toString(16)}`.slice(-6)}`;
6285
6378
  context.stroke();
6286
6379
  }
6287
- } else if (data.type === 22) {
6380
+ } else if (shape instanceof Rectangle) {
6288
6381
  if (data.fillColor || data.fillColor === 0) {
6289
6382
  context.globalAlpha = data.fillAlpha * worldAlpha;
6290
- context.fillStyle = `#${`00000${Math.trunc(fillColor).toString(16)}`.slice(-6)}`;
6383
+ context.fillStyle = `#${`00000${Math.trunc(fillColor ?? 0).toString(16)}`.slice(-6)}`;
6291
6384
  context.fillRect(shape.x, shape.y, shape.width, shape.height);
6292
6385
  }
6293
6386
  if (data.lineWidth) {
@@ -6295,13 +6388,13 @@ const renderGraphics$1 = (graphics, context) => {
6295
6388
  context.strokeStyle = `#${`00000${Math.trunc(lineColor).toString(16)}`.slice(-6)}`;
6296
6389
  context.strokeRect(shape.x, shape.y, shape.width, shape.height);
6297
6390
  }
6298
- } else if (data.type === 21) {
6391
+ } else if (shape instanceof Circle) {
6299
6392
  context.beginPath();
6300
6393
  context.arc(shape.x, shape.y, shape.radius, 0, 2 * Math.PI);
6301
6394
  context.closePath();
6302
6395
  if (data.fill) {
6303
6396
  context.globalAlpha = data.fillAlpha * worldAlpha;
6304
- context.fillStyle = `#${`00000${Math.trunc(fillColor).toString(16)}`.slice(-6)}`;
6397
+ context.fillStyle = `#${`00000${Math.trunc(fillColor ?? 0).toString(16)}`.slice(-6)}`;
6305
6398
  context.fill();
6306
6399
  }
6307
6400
  if (data.lineWidth) {
@@ -6309,7 +6402,7 @@ const renderGraphics$1 = (graphics, context) => {
6309
6402
  context.strokeStyle = `#${`00000${Math.trunc(lineColor).toString(16)}`.slice(-6)}`;
6310
6403
  context.stroke();
6311
6404
  }
6312
- } else if (data.type === 16) {
6405
+ } else if (shape instanceof Ellipse) {
6313
6406
  const w = shape.width * 2;
6314
6407
  const h = shape.height * 2;
6315
6408
  const x = shape.x - w / 2;
@@ -6330,7 +6423,7 @@ const renderGraphics$1 = (graphics, context) => {
6330
6423
  context.closePath();
6331
6424
  if (data.fill) {
6332
6425
  context.globalAlpha = data.fillAlpha * worldAlpha;
6333
- context.fillStyle = `#${`00000${Math.trunc(fillColor).toString(16)}`.slice(-6)}`;
6426
+ context.fillStyle = `#${`00000${Math.trunc(fillColor ?? 0).toString(16)}`.slice(-6)}`;
6334
6427
  context.fill();
6335
6428
  }
6336
6429
  if (data.lineWidth) {
@@ -6338,7 +6431,7 @@ const renderGraphics$1 = (graphics, context) => {
6338
6431
  context.strokeStyle = `#${`00000${Math.trunc(lineColor).toString(16)}`.slice(-6)}`;
6339
6432
  context.stroke();
6340
6433
  }
6341
- } else if (data.type === 26) {
6434
+ } else if (shape instanceof RoundedRectangle) {
6342
6435
  const rx = shape.x;
6343
6436
  const ry = shape.y;
6344
6437
  const { width } = shape;
@@ -6359,7 +6452,7 @@ const renderGraphics$1 = (graphics, context) => {
6359
6452
  context.closePath();
6360
6453
  if (data.fillColor || data.fillColor === 0) {
6361
6454
  context.globalAlpha = data.fillAlpha * worldAlpha;
6362
- context.fillStyle = `#${`00000${Math.trunc(fillColor).toString(16)}`.slice(-6)}`;
6455
+ context.fillStyle = `#${`00000${Math.trunc(fillColor ?? 0).toString(16)}`.slice(-6)}`;
6363
6456
  context.fill();
6364
6457
  }
6365
6458
  if (data.lineWidth) {
@@ -6380,20 +6473,19 @@ const renderGraphicsMask = (graphics, context) => {
6380
6473
  if (len === 0) return;
6381
6474
  context.beginPath();
6382
6475
  for (let i = 0; i < len; i += 1) {
6383
- const data = graphics.graphicsData[i];
6384
- const { shape } = data;
6385
- if (data.type === 12) {
6476
+ const { shape } = graphics.graphicsData[i];
6477
+ if (shape instanceof Polygon) {
6386
6478
  const { points } = shape;
6387
6479
  context.moveTo(points[0], points[1]);
6388
6480
  for (let j = 1; j < points.length / 2; j += 1) context.lineTo(points[j * 2], points[j * 2 + 1]);
6389
6481
  if (points[0] === points.at(-2) && points[1] === points.at(-1)) context.closePath();
6390
- } else if (data.type === 22) {
6482
+ } else if (shape instanceof Rectangle) {
6391
6483
  context.rect(shape.x, shape.y, shape.width, shape.height);
6392
6484
  context.closePath();
6393
- } else if (data.type === 21) {
6485
+ } else if (shape instanceof Circle) {
6394
6486
  context.arc(shape.x, shape.y, shape.radius, 0, 2 * Math.PI);
6395
6487
  context.closePath();
6396
- } else if (data.type === 16) {
6488
+ } else if (shape instanceof Ellipse) {
6397
6489
  const w = shape.width * 2;
6398
6490
  const h = shape.height * 2;
6399
6491
  const x = shape.x - w / 2;
@@ -6411,7 +6503,7 @@ const renderGraphicsMask = (graphics, context) => {
6411
6503
  context.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
6412
6504
  context.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
6413
6505
  context.closePath();
6414
- } else if (data.type === 26) {
6506
+ } else if (shape instanceof RoundedRectangle) {
6415
6507
  const rx = shape.x;
6416
6508
  const ry = shape.y;
6417
6509
  const { width } = shape;
@@ -6453,6 +6545,8 @@ var GraphicsData$1 = class {
6453
6545
  fill;
6454
6546
  shape;
6455
6547
  type;
6548
+ /** Flattened points the WebGL builders work from, filled in while updating the graphics. */
6549
+ points = [];
6456
6550
  /**
6457
6551
  * Creates a new GraphicsData object.
6458
6552
  * @param {number} lineWidth - The line width.
@@ -6505,8 +6599,8 @@ var Node = class {
6505
6599
  this.i = i;
6506
6600
  this.x = x;
6507
6601
  this.y = y;
6508
- this.prev = null;
6509
- this.next = null;
6602
+ this.prev = this;
6603
+ this.next = this;
6510
6604
  this.z = null;
6511
6605
  this.prevZ = null;
6512
6606
  this.nextZ = null;
@@ -6521,46 +6615,42 @@ var Node = class {
6521
6615
  * @returns {object} The processed earcut data structure.
6522
6616
  */
6523
6617
  function sortLinked(list) {
6524
- let i;
6525
- let p;
6526
- let q;
6527
- let e;
6528
- let tail;
6529
6618
  let numMerges;
6530
- let pSize;
6531
- let qSize;
6532
6619
  let inSize = 1;
6533
6620
  do {
6534
- p = list;
6621
+ let p = list;
6622
+ let tail = null;
6535
6623
  list = null;
6536
- tail = null;
6537
6624
  numMerges = 0;
6538
6625
  while (p) {
6539
6626
  numMerges += 1;
6540
- q = p;
6541
- pSize = 0;
6542
- for (i = 0; i < inSize; i += 1) {
6627
+ let q = p;
6628
+ let pSize = 0;
6629
+ for (let i = 0; i < inSize; i += 1) {
6543
6630
  pSize += 1;
6544
6631
  q = q.nextZ;
6545
6632
  if (!q) break;
6546
6633
  }
6547
- qSize = inSize;
6634
+ let qSize = inSize;
6548
6635
  while (pSize > 0 || qSize > 0 && q) {
6636
+ let e;
6549
6637
  if (pSize === 0) {
6638
+ if (!q) break;
6550
6639
  e = q;
6551
- q = q.nextZ;
6640
+ q = e.nextZ;
6552
6641
  qSize -= 1;
6553
6642
  } else if (qSize === 0 || !q) {
6643
+ if (!p) break;
6554
6644
  e = p;
6555
- p = p.nextZ;
6645
+ p = e.nextZ;
6556
6646
  pSize -= 1;
6557
- } else if (p.z <= q.z) {
6647
+ } else if (p && (p.z ?? 0) <= (q.z ?? 0)) {
6558
6648
  e = p;
6559
- p = p.nextZ;
6649
+ p = e.nextZ;
6560
6650
  pSize -= 1;
6561
6651
  } else {
6562
6652
  e = q;
6563
- q = q.nextZ;
6653
+ q = e.nextZ;
6564
6654
  qSize -= 1;
6565
6655
  }
6566
6656
  if (tail) tail.nextZ = e;
@@ -6570,7 +6660,7 @@ function sortLinked(list) {
6570
6660
  }
6571
6661
  p = q;
6572
6662
  }
6573
- tail.nextZ = null;
6663
+ if (tail) tail.nextZ = null;
6574
6664
  inSize *= 2;
6575
6665
  } while (numMerges > 1);
6576
6666
  return list;
@@ -6616,7 +6706,7 @@ function zOrder(x, y, minX, minY, size) {
6616
6706
  function indexCurve(start, minX = 0, minY = 0, size = 0) {
6617
6707
  let p = start;
6618
6708
  do {
6619
- if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size);
6709
+ p.z ??= zOrder(p.x, p.y, minX, minY, size);
6620
6710
  p.prevZ = p.prev;
6621
6711
  p.nextZ = p.next;
6622
6712
  p = p.next;
@@ -6846,13 +6936,13 @@ function linkedList(data, start, end, dim, clockwise) {
6846
6936
  let sum = 0;
6847
6937
  let i;
6848
6938
  let j;
6849
- let last;
6939
+ let last = null;
6850
6940
  for (i = start, j = end - dim; i < end; i += dim) {
6851
6941
  sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
6852
6942
  j = i;
6853
6943
  }
6854
- if (clockwise === sum > 0) for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
6855
- else for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
6944
+ if (clockwise === sum > 0) for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last ?? null);
6945
+ else for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last ?? null);
6856
6946
  return last;
6857
6947
  }
6858
6948
  /**
@@ -6924,9 +7014,9 @@ function findHoleBridge(hole, outerNode) {
6924
7014
  * @param {object} outerNode - The outer node that contains the hole.
6925
7015
  */
6926
7016
  function eliminateHole(hole, outerNode) {
6927
- outerNode = findHoleBridge(hole, outerNode);
6928
- if (outerNode) {
6929
- const b = splitPolygon(outerNode, hole);
7017
+ const bridge = findHoleBridge(hole, outerNode);
7018
+ if (bridge) {
7019
+ const b = splitPolygon(bridge, hole);
6930
7020
  filterPoints(b, b.next);
6931
7021
  }
6932
7022
  }
@@ -6955,6 +7045,7 @@ function eliminateHoles(data, holeIndices, outerNode, dim) {
6955
7045
  }
6956
7046
  queue.sort(compareX);
6957
7047
  for (i = 0; i < queue.length; i += 1) {
7048
+ if (!outerNode) return outerNode;
6958
7049
  eliminateHole(queue[i], outerNode);
6959
7050
  outerNode = filterPoints(outerNode, outerNode.next);
6960
7051
  }
@@ -7000,11 +7091,11 @@ function splitEarcut(start, triangles, dim, minX = 0, minY = 0, size = 0) {
7000
7091
  let b = a.next.next;
7001
7092
  while (b !== a.prev) {
7002
7093
  if (a.i !== b.i && isValidDiagonal(a, b)) {
7003
- let c = splitPolygon(a, b);
7004
- a = filterPoints(a, a.next);
7005
- c = filterPoints(c, c.next);
7006
- earcutLinked(a, triangles, dim, minX, minY, size);
7007
- earcutLinked(c, triangles, dim, minX, minY, size);
7094
+ const c = splitPolygon(a, b);
7095
+ const halfA = filterPoints(a, a.next);
7096
+ const halfC = filterPoints(c, c.next);
7097
+ earcutLinked(halfA, triangles, dim, minX, minY, size);
7098
+ earcutLinked(halfC, triangles, dim, minX, minY, size);
7008
7099
  return;
7009
7100
  }
7010
7101
  b = b.next;
@@ -7475,7 +7566,7 @@ const buildCircle = (graphicsData, webGLData) => {
7475
7566
  const { y } = circleData;
7476
7567
  let width;
7477
7568
  let height;
7478
- if (graphicsData.type === 21) {
7569
+ if (graphicsData.shape instanceof Circle) {
7479
7570
  width = circleData.radius;
7480
7571
  height = circleData.radius;
7481
7572
  } else {
@@ -7600,7 +7691,7 @@ const updateGraphics = (graphics, gl) => {
7600
7691
  let webGLData;
7601
7692
  for (i = webGL.lastIndex; i < graphics.graphicsData.length; i += 1) {
7602
7693
  const data = graphics.graphicsData[i];
7603
- if (data.type === 12) {
7694
+ if (data.shape instanceof Polygon) {
7604
7695
  data.points = [...data.shape.points];
7605
7696
  if (data.shape.closed) {
7606
7697
  if (data.points[0] !== data.points.at(-2) || data.points[1] !== data.points.at(-1)) data.points.push(data.points[0], data.points[1]);
@@ -7625,16 +7716,13 @@ const updateGraphics = (graphics, gl) => {
7625
7716
  }
7626
7717
  } else {
7627
7718
  webGLData = switchMode(webGL, 0);
7628
- if (data.type === 22) buildRectangle(data, webGLData);
7629
- else if (data.type === 21 || data.type === 16) buildCircle(data, webGLData);
7630
- else if (data.type === 26) buildRoundedRectangle(data, webGLData);
7719
+ if (data.shape instanceof Rectangle) buildRectangle(data, webGLData);
7720
+ else if (data.shape instanceof Circle || data.shape instanceof Ellipse) buildCircle(data, webGLData);
7721
+ else if (data.shape instanceof RoundedRectangle) buildRoundedRectangle(data, webGLData);
7631
7722
  }
7632
7723
  webGL.lastIndex += 1;
7633
7724
  }
7634
- for (i = 0; i < webGL.data.length; i += 1) {
7635
- webGLData = webGL.data[i];
7636
- if (webGLData.dirty) webGLData.upload();
7637
- }
7725
+ for (const uploadable of webGL.data) if (uploadable.dirty) uploadable.upload();
7638
7726
  };
7639
7727
  /**
7640
7728
  * Updates the graphics data for WebGL rendering.
@@ -7646,30 +7734,33 @@ const renderGraphics = (graphics, renderSession) => {
7646
7734
  const { projection } = renderSession;
7647
7735
  const { offset } = renderSession;
7648
7736
  let shader = renderSession.shaderManager.primitiveShader;
7737
+ if (!shader) return;
7649
7738
  let webGLData;
7650
7739
  if (graphics.dirty) updateGraphics(graphics, gl);
7651
7740
  const webGL = graphics._webGL[gl.id];
7652
7741
  if (!webGL) return;
7653
- for (let i = 0; i < webGL.data.length; i += 1) if (webGL.data[i].mode === 1) {
7742
+ for (let i = 0; i < webGL.data.length; i += 1) {
7654
7743
  webGLData = webGL.data[i];
7655
- renderSession.stencilManager.pushStencil(graphics, webGLData, renderSession);
7656
- gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, (webGLData.indices.length - 4) * 2);
7657
- renderSession.stencilManager.popStencil(graphics, webGLData, renderSession);
7658
- } else {
7659
- webGLData = webGL.data[i];
7660
- renderSession.shaderManager.setShader(shader);
7661
- shader = renderSession.shaderManager.primitiveShader;
7662
- gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true));
7663
- gl.uniform1f(shader.flipY, 1);
7664
- gl.uniform2f(shader.projectionVector, projection.x, -projection.y);
7665
- gl.uniform2f(shader.offsetVector, -offset.x, -offset.y);
7666
- gl.uniform3fv(shader.tintColor, hex2rgb(graphics.tint));
7667
- gl.uniform1f(shader.alpha, graphics.worldAlpha);
7668
- gl.bindBuffer(gl.ARRAY_BUFFER, webGLData.buffer);
7669
- gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 24, 0);
7670
- gl.vertexAttribPointer(shader.colorAttribute, 4, gl.FLOAT, false, 24, 8);
7671
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, webGLData.indexBuffer);
7672
- gl.drawElements(gl.TRIANGLE_STRIP, webGLData.indices.length, gl.UNSIGNED_SHORT, 0);
7744
+ if (webGLData.mode === 1) {
7745
+ renderSession.stencilManager.pushStencil(graphics, webGLData, renderSession);
7746
+ gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, (webGLData.indices.length - 4) * 2);
7747
+ renderSession.stencilManager.popStencil(graphics, webGLData, renderSession);
7748
+ } else {
7749
+ renderSession.shaderManager.setShader(shader);
7750
+ shader = renderSession.shaderManager.primitiveShader;
7751
+ if (!shader) return;
7752
+ gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true));
7753
+ gl.uniform1f(shader.flipY, 1);
7754
+ gl.uniform2f(shader.projectionVector, projection.x, -projection.y);
7755
+ gl.uniform2f(shader.offsetVector, -offset.x, -offset.y);
7756
+ gl.uniform3fv(shader.tintColor, hex2rgb(graphics.tint));
7757
+ gl.uniform1f(shader.alpha, graphics.worldAlpha);
7758
+ gl.bindBuffer(gl.ARRAY_BUFFER, webGLData.buffer);
7759
+ gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 24, 0);
7760
+ gl.vertexAttribPointer(shader.colorAttribute, 4, gl.FLOAT, false, 24, 8);
7761
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, webGLData.indexBuffer);
7762
+ gl.drawElements(gl.TRIANGLE_STRIP, webGLData.indices.length, gl.UNSIGNED_SHORT, 0);
7763
+ }
7673
7764
  }
7674
7765
  };
7675
7766
  //#endregion
@@ -8159,7 +8250,7 @@ var Graphics = class extends DisplayObject {
8159
8250
  * @param {object} renderSession - The render session to use.
8160
8251
  */
8161
8252
  renderWebGL(renderSession) {
8162
- if (!this.visible || this.alpha === 0 || this.isMask === true) return;
8253
+ if (!this.visible || this.alpha === 0 || this.isMask) return;
8163
8254
  if (this._cacheAsBitmap) {
8164
8255
  if (this.dirty || this.cachedSpriteDirty) {
8165
8256
  this.generateCachedSprite();
@@ -8168,7 +8259,7 @@ var Graphics = class extends DisplayObject {
8168
8259
  this.dirty = false;
8169
8260
  }
8170
8261
  this._cachedSprite.worldAlpha = this.worldAlpha;
8171
- renderWebGL.call(this._cachedSprite, renderSession);
8262
+ renderWebGL(this._cachedSprite, renderSession);
8172
8263
  } else {
8173
8264
  renderSession.spriteBatch.stop();
8174
8265
  renderSession.blendModeManager.setBlendMode(this.blendMode);
@@ -8200,7 +8291,7 @@ var Graphics = class extends DisplayObject {
8200
8291
  * @param {object} renderSession - The render session to use.
8201
8292
  */
8202
8293
  renderCanvas(renderSession) {
8203
- if (!this.visible || this.alpha === 0 || this.isMask === true) return;
8294
+ if (!this.visible || this.alpha === 0 || this.isMask) return;
8204
8295
  if (this._prevTint !== this.tint) {
8205
8296
  this.dirty = true;
8206
8297
  this._prevTint = this.tint;
@@ -8219,7 +8310,7 @@ var Graphics = class extends DisplayObject {
8219
8310
  const transform = this.worldTransform;
8220
8311
  if (this.blendMode !== renderSession.currentBlendMode) {
8221
8312
  renderSession.currentBlendMode = this.blendMode;
8222
- context.globalCompositeOperation = globalThis.PhaserRegistry.blendModesCanvas[renderSession.currentBlendMode];
8313
+ context.globalCompositeOperation = globalThis.PhaserRegistry.blendModesCanvas[renderSession.currentBlendMode] ?? "source-over";
8223
8314
  }
8224
8315
  if (this._mask) renderSession.maskManager.pushMask(this._mask, renderSession);
8225
8316
  const { resolution } = renderSession;
@@ -8228,7 +8319,7 @@ var Graphics = class extends DisplayObject {
8228
8319
  context.setTransform(transform.a * resolution, transform.b * resolution, transform.c * resolution, transform.d * resolution, tx, ty);
8229
8320
  renderGraphics$1(this, context);
8230
8321
  for (const child of this.children) child.renderCanvas(renderSession);
8231
- if (this._mask) renderSession.maskManager.popMask(renderSession);
8322
+ if (this._mask) renderSession.maskManager.popMask(this._mask, renderSession);
8232
8323
  }
8233
8324
  }
8234
8325
  /**
@@ -8309,11 +8400,8 @@ var Graphics = class extends DisplayObject {
8309
8400
  containsPoint(point, tempPoint) {
8310
8401
  this.worldTransform.applyInverse(point, tempPoint);
8311
8402
  const { graphicsData } = this;
8312
- for (let i = 0; i < graphicsData.length; i += 0) {
8313
- const data = graphicsData[i];
8314
- if (data.fill && data.shape) {
8315
- if (data.shape.contains(tempPoint.x, tempPoint.y)) return true;
8316
- }
8403
+ for (const data of graphicsData) if (data.fill && data.shape) {
8404
+ if (data.shape.contains(tempPoint.x, tempPoint.y)) return true;
8317
8405
  }
8318
8406
  return false;
8319
8407
  }
@@ -8333,10 +8421,9 @@ var Graphics = class extends DisplayObject {
8333
8421
  let w;
8334
8422
  let h;
8335
8423
  for (const data of this.graphicsData) {
8336
- const { type } = data;
8337
8424
  const { lineWidth } = data;
8338
8425
  shape = data.shape;
8339
- if (type === 22 || type === 26) {
8426
+ if (shape instanceof Rectangle || shape instanceof RoundedRectangle) {
8340
8427
  x = shape.x - lineWidth / 2;
8341
8428
  y = shape.y - lineWidth / 2;
8342
8429
  w = shape.width + lineWidth;
@@ -8345,7 +8432,7 @@ var Graphics = class extends DisplayObject {
8345
8432
  maxX = x + w > maxX ? x + w : maxX;
8346
8433
  minY = y < minY ? y : minY;
8347
8434
  maxY = y + h > maxY ? y + h : maxY;
8348
- } else if (type === 21) {
8435
+ } else if (shape instanceof Circle) {
8349
8436
  x = shape.x;
8350
8437
  y = shape.y;
8351
8438
  w = shape.radius + lineWidth / 2;
@@ -8354,7 +8441,7 @@ var Graphics = class extends DisplayObject {
8354
8441
  maxX = x + w > maxX ? x + w : maxX;
8355
8442
  minY = y - h < minY ? y - h : minY;
8356
8443
  maxY = y + h > maxY ? y + h : maxY;
8357
- } else if (type === 16) {
8444
+ } else if (shape instanceof Ellipse) {
8358
8445
  x = shape.x;
8359
8446
  y = shape.y;
8360
8447
  w = shape.width + lineWidth / 2;
@@ -8447,13 +8534,14 @@ var Graphics = class extends DisplayObject {
8447
8534
  if (this.currentPath.shape.points.length <= 2) this.graphicsData.pop();
8448
8535
  }
8449
8536
  this.currentPath = null;
8450
- if (shape instanceof Polygon) {
8451
- shape = shape.clone();
8452
- shape.flatten();
8537
+ let target = shape;
8538
+ if (target instanceof Polygon) {
8539
+ target = target.clone();
8540
+ target.flatten();
8453
8541
  }
8454
- const data = new GraphicsData$1(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.filling, shape);
8542
+ const data = new GraphicsData$1(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.filling, target);
8455
8543
  this.graphicsData.push(data);
8456
- if (data.type === 12) {
8544
+ if (data.shape instanceof Polygon) {
8457
8545
  data.shape.closed = this.filling;
8458
8546
  this.currentPath = data;
8459
8547
  }
@@ -8830,7 +8918,7 @@ var Text = class extends Image$1 {
8830
8918
  * @param {Game} game - The game instance this text belongs to.
8831
8919
  * @param {number} x - The x position of the text.
8832
8920
  * @param {number} y - The y position of the text.
8833
- * @param {string} text - The text content to display.
8921
+ * @param {string | number} text - The text content to display.
8834
8922
  * @param {object} style - The style settings for the text.
8835
8923
  */
8836
8924
  constructor(game, x, y, text = "", style = {}) {
@@ -8839,10 +8927,11 @@ var Text = class extends Image$1 {
8839
8927
  /** @type {number} */
8840
8928
  this.type = 4;
8841
8929
  this.canvas = create$1(this);
8842
- this.context = this.canvas.getContext("2d", { willReadFrequently: false });
8930
+ const context = this.canvas.getContext("2d", { willReadFrequently: false });
8931
+ if (!context) throw new Error(ENGINE_ERROR_CREATING_CANVAS_2D_CONTEXT);
8932
+ this.context = context;
8843
8933
  this.padding = new Point();
8844
8934
  this.textBounds = null;
8845
- this.style = null;
8846
8935
  /** @type {string[]} */
8847
8936
  this.colors = [];
8848
8937
  /** @type {string[]} */
@@ -8854,8 +8943,7 @@ var Text = class extends Image$1 {
8854
8943
  this.autoRound = false;
8855
8944
  this.useAdvancedWrap = false;
8856
8945
  this._res = game.renderer.resolution;
8857
- this._text = text;
8858
- this._fontComponents = null;
8946
+ this._text = text.toString();
8859
8947
  /** @type {number} */
8860
8948
  this._lineSpacing = 0;
8861
8949
  /** @type {number} */
@@ -8874,17 +8962,12 @@ var Text = class extends Image$1 {
8874
8962
  destroy() {
8875
8963
  this.texture.destroy(true);
8876
8964
  remove(this);
8877
- this.canvas = null;
8878
- this.context = null;
8879
8965
  this.textBounds = null;
8880
- this.style = null;
8881
- this.colors = null;
8882
- this.strokeColors = null;
8883
- this.fontStyles = null;
8884
- this.fontWeights = null;
8885
- this.padding = null;
8886
- this._text = null;
8887
- this._fontComponents = null;
8966
+ this.colors = [];
8967
+ this.strokeColors = [];
8968
+ this.fontStyles = [];
8969
+ this.fontWeights = [];
8970
+ this._text = "";
8888
8971
  super.destroy();
8889
8972
  }
8890
8973
  /**
@@ -8914,34 +8997,38 @@ var Text = class extends Image$1 {
8914
8997
  * @returns {Text} This Text object for chaining.
8915
8998
  */
8916
8999
  setStyle(style = null, update = false) {
8917
- style = structuredClone(style) ?? {};
8918
- style.font = style.font ?? "bold 20pt Arial";
8919
- style.backgroundColor = style.backgroundColor ?? null;
8920
- style.fill = style.fill ?? "black";
8921
- style.align = style.align ?? "left";
8922
- style.boundsAlignH = style.boundsAlignH ?? "left";
8923
- style.boundsAlignV = style.boundsAlignV ?? "top";
8924
- style.stroke = style.stroke ?? "black";
8925
- style.strokeThickness = style.strokeThickness ?? 0;
8926
- style.wordWrap = style.wordWrap ?? false;
8927
- style.wordWrapWidth = style.wordWrapWidth ?? 100;
8928
- style.maxLines = style.maxLines ?? 0;
8929
- style.shadowOffsetX = style.shadowOffsetX ?? 0;
8930
- style.shadowOffsetY = style.shadowOffsetY ?? 0;
8931
- style.shadowColor = style.shadowColor ?? "rgba(0,0,0,0)";
8932
- style.shadowBlur = style.shadowBlur ?? 0;
8933
- style.tabs = style.tabs ?? 0;
8934
- const components = this.fontToComponents(style.font);
8935
- if (style.fontStyle) components.fontStyle = style.fontStyle;
8936
- if (style.fontVariant) components.fontVariant = style.fontVariant;
8937
- if (style.fontWeight) components.fontWeight = style.fontWeight;
8938
- if (style.fontSize) {
8939
- if (typeof style.fontSize === "number") style.fontSize += "px";
8940
- components.fontSize = style.fontSize;
9000
+ const source = structuredClone(style) ?? {};
9001
+ const resolved = {
9002
+ ...source,
9003
+ font: source.font ?? "bold 20pt Arial",
9004
+ backgroundColor: source.backgroundColor ?? null,
9005
+ fill: source.fill ?? "black",
9006
+ align: source.align ?? "left",
9007
+ boundsAlignH: source.boundsAlignH ?? "left",
9008
+ boundsAlignV: source.boundsAlignV ?? "top",
9009
+ stroke: source.stroke ?? "black",
9010
+ strokeThickness: source.strokeThickness ?? 0,
9011
+ wordWrap: source.wordWrap ?? false,
9012
+ wordWrapWidth: source.wordWrapWidth ?? 100,
9013
+ maxLines: source.maxLines ?? 0,
9014
+ shadowOffsetX: source.shadowOffsetX ?? 0,
9015
+ shadowOffsetY: source.shadowOffsetY ?? 0,
9016
+ shadowColor: source.shadowColor ?? "rgba(0,0,0,0)",
9017
+ shadowBlur: source.shadowBlur ?? 0,
9018
+ tabs: source.tabs ?? 0
9019
+ };
9020
+ const components = this.fontToComponents(resolved.font);
9021
+ if (resolved.fontStyle) components.fontStyle = resolved.fontStyle;
9022
+ if (resolved.fontVariant) components.fontVariant = resolved.fontVariant;
9023
+ if (resolved.fontWeight) components.fontWeight = String(resolved.fontWeight);
9024
+ if (resolved.fontSize) {
9025
+ const fontSize = typeof resolved.fontSize === "number" ? `${resolved.fontSize}px` : resolved.fontSize;
9026
+ resolved.fontSize = fontSize;
9027
+ components.fontSize = fontSize;
8941
9028
  }
8942
9029
  this._fontComponents = components;
8943
- style.font = this.componentsToFont(this._fontComponents);
8944
- this.style = style;
9030
+ resolved.font = this.componentsToFont(components);
9031
+ this.style = resolved;
8945
9032
  this.dirty = true;
8946
9033
  if (update) this.updateText();
8947
9034
  return this;
@@ -9027,12 +9114,12 @@ var Text = class extends Image$1 {
9027
9114
  if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0) this.updateLine(lines[i], linePositionX, linePositionY);
9028
9115
  else {
9029
9116
  if (this.style.stroke && this.style.strokeThickness) {
9030
- this.updateShadow(this.style.shadowStroke);
9117
+ this.updateShadow(this.style.shadowStroke ?? false);
9031
9118
  if (tabs === 0) this.context.strokeText(lines[i], linePositionX, linePositionY);
9032
9119
  else this.renderTabLine(lines[i], linePositionX, linePositionY, false);
9033
9120
  }
9034
9121
  if (this.style.fill) {
9035
- this.updateShadow(this.style.shadowFill);
9122
+ this.updateShadow(this.style.shadowFill ?? false);
9036
9123
  if (tabs === 0) this.context.fillText(lines[i], linePositionX, linePositionY);
9037
9124
  else this.renderTabLine(lines[i], linePositionX, linePositionY, true);
9038
9125
  }
@@ -9081,7 +9168,7 @@ var Text = class extends Image$1 {
9081
9168
  } else {
9082
9169
  this.context.shadowOffsetX = 0;
9083
9170
  this.context.shadowOffsetY = 0;
9084
- this.context.shadowColor = 0;
9171
+ this.context.shadowColor = "rgba(0,0,0,0)";
9085
9172
  this.context.shadowBlur = 0;
9086
9173
  }
9087
9174
  }
@@ -9095,17 +9182,21 @@ var Text = class extends Image$1 {
9095
9182
  for (const letter of line) {
9096
9183
  if (this.fontWeights.length > 0 || this.fontStyles.length > 0) {
9097
9184
  const components = this.fontToComponents(this.context.font);
9098
- if (this.fontStyles[this._charCount]) components.fontStyle = this.fontStyles[this._charCount];
9099
- if (this.fontWeights[this._charCount]) components.fontWeight = this.fontWeights[this._charCount];
9185
+ const charFontStyle = this.fontStyles[this._charCount];
9186
+ const charFontWeight = this.fontWeights[this._charCount];
9187
+ if (charFontStyle) components.fontStyle = charFontStyle;
9188
+ if (charFontWeight) components.fontWeight = charFontWeight;
9100
9189
  this.context.font = this.componentsToFont(components);
9101
9190
  }
9102
9191
  if (this.style.stroke && this.style.strokeThickness) {
9103
- if (this.strokeColors[this._charCount]) this.context.strokeStyle = this.strokeColors[this._charCount];
9104
- this.updateShadow(this.style.shadowStroke);
9192
+ const charStrokeColor = this.strokeColors[this._charCount];
9193
+ if (charStrokeColor) this.context.strokeStyle = charStrokeColor;
9194
+ this.updateShadow(this.style.shadowStroke ?? false);
9105
9195
  }
9106
9196
  if (this.style.fill) {
9107
- if (this.colors[this._charCount]) this.context.fillStyle = this.colors[this._charCount];
9108
- this.updateShadow(this.style.shadowFill);
9197
+ const charFillColor = this.colors[this._charCount];
9198
+ if (charFillColor) this.context.fillStyle = charFillColor;
9199
+ this.updateShadow(this.style.shadowFill ?? false);
9109
9200
  }
9110
9201
  lineLength += this.context.measureText(letter).width;
9111
9202
  this._charCount += 1;
@@ -9122,18 +9213,22 @@ var Text = class extends Image$1 {
9122
9213
  for (const letter of line) {
9123
9214
  if (this.fontWeights.length > 0 || this.fontStyles.length > 0) {
9124
9215
  const components = this.fontToComponents(this.context.font);
9125
- if (this.fontStyles[this._charCount]) components.fontStyle = this.fontStyles[this._charCount];
9126
- if (this.fontWeights[this._charCount]) components.fontWeight = this.fontWeights[this._charCount];
9216
+ const charFontStyle = this.fontStyles[this._charCount];
9217
+ const charFontWeight = this.fontWeights[this._charCount];
9218
+ if (charFontStyle) components.fontStyle = charFontStyle;
9219
+ if (charFontWeight) components.fontWeight = charFontWeight;
9127
9220
  this.context.font = this.componentsToFont(components);
9128
9221
  }
9129
9222
  if (this.style.stroke && this.style.strokeThickness) {
9130
- if (this.strokeColors[this._charCount]) this.context.strokeStyle = this.strokeColors[this._charCount];
9131
- this.updateShadow(this.style.shadowStroke);
9223
+ const charStrokeColor = this.strokeColors[this._charCount];
9224
+ if (charStrokeColor) this.context.strokeStyle = charStrokeColor;
9225
+ this.updateShadow(this.style.shadowStroke ?? false);
9132
9226
  this.context.strokeText(letter, x, y);
9133
9227
  }
9134
9228
  if (this.style.fill) {
9135
- if (this.colors[this._charCount]) this.context.fillStyle = this.colors[this._charCount];
9136
- this.updateShadow(this.style.shadowFill);
9229
+ const charFillColor = this.colors[this._charCount];
9230
+ if (charFillColor) this.context.fillStyle = charFillColor;
9231
+ this.updateShadow(this.style.shadowFill ?? false);
9137
9232
  this.context.fillText(letter, x, y);
9138
9233
  }
9139
9234
  x += this.context.measureText(letter).width;
@@ -9628,7 +9723,7 @@ var Text = class extends Image$1 {
9628
9723
  * @returns {number} The font family.
9629
9724
  */
9630
9725
  get font() {
9631
- return this._fontComponents.fontFamily;
9726
+ return this._fontComponents.fontFamily ?? "";
9632
9727
  }
9633
9728
  /**
9634
9729
  * Sets the font family of this object.
@@ -9647,17 +9742,16 @@ var Text = class extends Image$1 {
9647
9742
  */
9648
9743
  get fontSize() {
9649
9744
  const size = this._fontComponents.fontSize;
9650
- if (size && /(?:^0$|px$)/.exec(size)) return Math.trunc(Number(size));
9651
- return size;
9745
+ if (typeof size === "number") return size;
9746
+ if (size && /(?:^0$|px$)/.exec(size)) return Number.parseInt(size, 10);
9747
+ return 0;
9652
9748
  }
9653
9749
  /**
9654
9750
  * Sets the font size of this object.
9655
9751
  * @param {number} value - The new font size to set.
9656
9752
  */
9657
9753
  set fontSize(value) {
9658
- let mutatedValue = value || "0";
9659
- if (typeof mutatedValue === "number") mutatedValue = `${mutatedValue}px`;
9660
- this._fontComponents.fontSize = mutatedValue;
9754
+ this._fontComponents.fontSize = value ? `${value}px` : "0";
9661
9755
  this.updateFont(this._fontComponents);
9662
9756
  }
9663
9757
  /**
@@ -9665,7 +9759,7 @@ var Text = class extends Image$1 {
9665
9759
  * @returns {string} The font weight.
9666
9760
  */
9667
9761
  get fontWeight() {
9668
- return this._fontComponents.fontWeight ?? "normal";
9762
+ return String(this._fontComponents.fontWeight ?? "normal");
9669
9763
  }
9670
9764
  /**
9671
9765
  * Sets the font weight of this object.
@@ -9888,7 +9982,7 @@ var Text = class extends Image$1 {
9888
9982
  */
9889
9983
  set lineSpacing(value) {
9890
9984
  if (value !== this._lineSpacing) {
9891
- this._lineSpacing = Number(value);
9985
+ this._lineSpacing = value;
9892
9986
  this.dirty = true;
9893
9987
  if (this.parent) this.updateTransform();
9894
9988
  }
@@ -9966,7 +10060,7 @@ var Text = class extends Image$1 {
9966
10060
  * @returns {number} The shadow stroke setting.
9967
10061
  */
9968
10062
  get shadowStroke() {
9969
- return this.style.shadowStroke;
10063
+ return this.style.shadowStroke ?? false;
9970
10064
  }
9971
10065
  /**
9972
10066
  * Sets the shadow stroke setting of this object.
@@ -9983,7 +10077,7 @@ var Text = class extends Image$1 {
9983
10077
  * @returns {number} The shadow fill setting.
9984
10078
  */
9985
10079
  get shadowFill() {
9986
- return this.style.shadowFill;
10080
+ return this.style.shadowFill ?? false;
9987
10081
  }
9988
10082
  /**
9989
10083
  * Sets the shadow fill setting of this object.
@@ -10145,107 +10239,13 @@ const pushMask$1 = (maskData, renderSession) => {
10145
10239
  };
10146
10240
  /**
10147
10241
  * Pops a mask from the rendering stack.
10242
+ * @param {object} _maskData - Unused; the canvas path restores whatever was saved.
10148
10243
  * @param {object} renderSession - The rendering session object.
10149
10244
  */
10150
- const popMask$1 = (renderSession) => {
10245
+ const popMask$1 = (_maskData, renderSession) => {
10151
10246
  renderSession.context.restore();
10152
10247
  };
10153
10248
  //#endregion
10154
- //#region src/phaser/display/canvas/util.ts
10155
- /**
10156
- * Creates a new HTML canvas element.
10157
- * @param {object} parent - The parent element to append the canvas to.
10158
- * @param {number} width - The width of the canvas.
10159
- * @param {number} height - The height of the canvas.
10160
- * @param {string} id - The ID to assign to the canvas.
10161
- * @param {boolean} skipPool - Whether to skip using the canvas pool.
10162
- * @returns {HTMLCanvasElement} The created HTML canvas element.
10163
- */
10164
- const create = (parent, width, height, id, skipPool) => {
10165
- width = width || 256;
10166
- height = height || 256;
10167
- const canvas = skipPool ? document.createElement("canvas") : create$1(parent, width, height);
10168
- if (typeof id === "string" && id !== "") canvas.id = id;
10169
- canvas.width = width;
10170
- canvas.height = height;
10171
- canvas.style.display = "block";
10172
- return canvas;
10173
- };
10174
- /**
10175
- * Sets the touch action property of a canvas element.
10176
- * @param {HTMLCanvasElement} canvas - The canvas element to modify.
10177
- * @param {string} value - The touch action value to set.
10178
- * @returns {HTMLCanvasElement} The modified canvas element.
10179
- */
10180
- const setTouchAction = (canvas, value = "none") => {
10181
- value = value || "none";
10182
- canvas.style.setProperty("-ms-touch-action", value);
10183
- canvas.style.setProperty("touch-action", value);
10184
- return canvas;
10185
- };
10186
- /**
10187
- * Sets the user select property of a canvas element.
10188
- * @param {HTMLCanvasElement} canvas - The canvas element to modify.
10189
- * @param {string} value - The user select value to set.
10190
- * @returns {HTMLCanvasElement} The modified canvas element.
10191
- */
10192
- const setUserSelect = (canvas, value = "none") => {
10193
- value = value || "none";
10194
- canvas.style.setProperty("-webkit-touch-callout", value);
10195
- canvas.style.setProperty("-webkit-user-select", value);
10196
- canvas.style.setProperty("-khtml-user-select", value);
10197
- canvas.style.setProperty("-moz-user-select", value);
10198
- canvas.style.setProperty("-ms-user-select", value);
10199
- canvas.style.setProperty("user-select", value);
10200
- canvas.style.setProperty("-webkit-tap-highlight-color", "rgba(0, 0, 0, 0)");
10201
- return canvas;
10202
- };
10203
- /**
10204
- * Adds a canvas element to the DOM.
10205
- * @param {HTMLCanvasElement} canvas - The canvas element to add.
10206
- * @param {object} parent - The parent element to append the canvas to.
10207
- * @param {boolean} overflowHidden - Whether to set overflow hidden on the parent.
10208
- * @returns {HTMLCanvasElement} The added canvas element.
10209
- */
10210
- const addToDOM = (canvas, parent, overflowHidden = true) => {
10211
- let target;
10212
- if (parent) {
10213
- if (typeof parent === "string") target = document.querySelector(`#${parent}`);
10214
- else if (typeof parent === "object" && parent.nodeType === 1) target = parent;
10215
- }
10216
- target ??= document.body;
10217
- if (overflowHidden && target.style) target.style.overflow = "hidden";
10218
- target.append(canvas);
10219
- return canvas;
10220
- };
10221
- /**
10222
- * Removes a canvas element from the DOM.
10223
- * @param {HTMLCanvasElement} canvas - The canvas element to remove.
10224
- */
10225
- const removeFromDOM = (canvas) => {
10226
- if (canvas && canvas.parentNode) canvas.parentNode.removeChild(canvas);
10227
- };
10228
- /**
10229
- * Gets the smoothing prefix for a canvas rendering context.
10230
- * @param {CanvasRenderingContext2D} context - The canvas rendering context.
10231
- * @returns {string | null} The smoothing property name or null if not found.
10232
- */
10233
- const getSmoothingPrefix = (context) => {
10234
- const VENDORS = [
10235
- "i",
10236
- "webkitI",
10237
- "msI",
10238
- "mozI",
10239
- "oI"
10240
- ];
10241
- const smoothingFlags = context;
10242
- for (let i = 0; i < VENDORS.length; i += 1) {
10243
- const s = `${VENDORS[i]}mageSmoothingEnabled`;
10244
- if (context && smoothingFlags[s]) return s;
10245
- }
10246
- return null;
10247
- };
10248
- //#endregion
10249
10249
  //#region src/phaser/display/canvas/renderer.ts
10250
10250
  var CanvasRenderer = class {
10251
10251
  type;
@@ -10322,9 +10322,6 @@ var CanvasRenderer = class {
10322
10322
  */
10323
10323
  destroy(removeView = true) {
10324
10324
  if (removeView && this.view.parent) this.view.parent.removeChild(this.view);
10325
- this.view = null;
10326
- this.context = null;
10327
- this.renderSession = null;
10328
10325
  }
10329
10326
  /**
10330
10327
  * Resizes the canvas to the specified dimensions.
@@ -10340,7 +10337,7 @@ var CanvasRenderer = class {
10340
10337
  this.view.style.width = `${this.width / this.resolution}px`;
10341
10338
  this.view.style.height = `${this.height / this.resolution}px`;
10342
10339
  }
10343
- if (this.renderSession.smoothProperty) this.context[this.renderSession.smoothProperty] = this.renderSession.scaleMode === 0;
10340
+ if (this.renderSession.smoothProperty) setSmoothing(this.context, this.renderSession.smoothProperty, this.renderSession.scaleMode === 0);
10344
10341
  }
10345
10342
  /**
10346
10343
  * Renders a display object to canvas.
@@ -10451,7 +10448,7 @@ var WebGLFilterManager = class {
10451
10448
  /**
10452
10449
  * Updates the filter texture for the specified size.
10453
10450
  */
10454
- pushFilter() {}
10451
+ pushFilter(_filterBlock) {}
10455
10452
  /**
10456
10453
  * Resizes the filter manager to the specified dimensions.
10457
10454
  */
@@ -10790,6 +10787,10 @@ const defaultVertexSrc = [
10790
10787
  "}"
10791
10788
  ];
10792
10789
  const glMember = (gl, name) => gl[name];
10790
+ /** Applies one of the gl uniform setters, whose signatures vary by uniform kind. */
10791
+ const callUniformSetter = (setter, gl, ...args) => {
10792
+ if (typeof setter === "function") setter.apply(gl, args);
10793
+ };
10793
10794
  var NormalShader = class {
10794
10795
  gl;
10795
10796
  _UID;
@@ -10929,11 +10930,11 @@ var NormalShader = class {
10929
10930
  this.textureCount = 1;
10930
10931
  const { gl } = this;
10931
10932
  for (const uniform of Object.values(this.uniforms)) if (uniform.glValueLength === 1) {
10932
- if (uniform.glMatrix === true) uniform.glFunc?.call(gl, uniform.uniformLocation, uniform.transpose, uniform.value);
10933
- else uniform.glFunc?.call(gl, uniform.uniformLocation, uniform.value);
10934
- } else if (uniform.glValueLength === 2) uniform.glFunc?.call(gl, uniform.uniformLocation, uniform.value.x, uniform.value.y);
10935
- else if (uniform.glValueLength === 3) uniform.glFunc?.call(gl, uniform.uniformLocation, uniform.value.x, uniform.value.y, uniform.value.z);
10936
- else if (uniform.glValueLength === 4) uniform.glFunc?.call(gl, uniform.uniformLocation, uniform.value.x, uniform.value.y, uniform.value.z, uniform.value.w);
10933
+ if (uniform.glMatrix === true) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.transpose, uniform.value);
10934
+ else callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.value);
10935
+ } else if (uniform.glValueLength === 2) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.value.x, uniform.value.y);
10936
+ else if (uniform.glValueLength === 3) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.value.x, uniform.value.y, uniform.value.z);
10937
+ else if (uniform.glValueLength === 4) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.value.x, uniform.value.y, uniform.value.z, uniform.value.w);
10937
10938
  else if (uniform.type === "sampler2D") {
10938
10939
  if (uniform._init) {
10939
10940
  gl.activeTexture(glMember(gl, `TEXTURE${this.textureCount}`));
@@ -11162,7 +11163,7 @@ var WebGLShaderManager = class {
11162
11163
  setAttribs(attribs) {
11163
11164
  let i = 0;
11164
11165
  for (; i < this.tempAttribState.length; i += 1) this.tempAttribState[i] = false;
11165
- for (const attribId of attribs) this.tempAttribState[attribId] = true;
11166
+ for (const attribId of attribs) if (attribId !== void 0) this.tempAttribState[attribId] = true;
11166
11167
  const { gl } = this;
11167
11168
  for (i = 0; i < this.attribState.length; i += 1) if (this.attribState[i] !== this.tempAttribState[i]) {
11168
11169
  this.attribState[i] = this.tempAttribState[i];
@@ -11180,7 +11181,7 @@ var WebGLShaderManager = class {
11180
11181
  this._currentId = shader._UID;
11181
11182
  this.currentShader = shader;
11182
11183
  this.gl.useProgram(shader.program);
11183
- this.setAttribs(shader.attributes);
11184
+ this.setAttribs(shader.attributes ?? []);
11184
11185
  return true;
11185
11186
  }
11186
11187
  /**
@@ -11328,7 +11329,7 @@ var WebGLSpriteBatch = class {
11328
11329
  * @param {Image} sprite - The sprite to render.
11329
11330
  * @param {Matrix} matrix - The transformation matrix.
11330
11331
  */
11331
- render(sprite, matrix) {
11332
+ render(sprite, matrix = null) {
11332
11333
  const { texture } = sprite;
11333
11334
  let wt = sprite.worldTransform;
11334
11335
  if (matrix) wt = matrix;
@@ -11612,6 +11613,7 @@ var WebGLStencilManager = class {
11612
11613
  let shader;
11613
11614
  if (webGLData.mode === 1) {
11614
11615
  shader = renderSession.shaderManager.complexPrimitiveShader;
11616
+ if (!shader) return;
11615
11617
  renderSession.shaderManager.setShader(shader);
11616
11618
  gl.uniform1f(shader.flipY, renderSession.flipY);
11617
11619
  gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true));
@@ -11625,6 +11627,7 @@ var WebGLStencilManager = class {
11625
11627
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, webGLData.indexBuffer);
11626
11628
  } else {
11627
11629
  shader = renderSession.shaderManager.primitiveShader;
11630
+ if (!shader) return;
11628
11631
  renderSession.shaderManager.setShader(shader);
11629
11632
  gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true));
11630
11633
  gl.uniform1f(shader.flipY, renderSession.flipY);
@@ -11770,7 +11773,6 @@ var WebGLRenderer = class {
11770
11773
  const loseContextExt = this.gl.getExtension("WEBGL_lose_context");
11771
11774
  if (loseContextExt) loseContextExt.loseContext();
11772
11775
  }
11773
- this.renderSession = null;
11774
11776
  remove(this);
11775
11777
  globalThis.PhaserRegistry.INSTANCES[this.glContextId] = null;
11776
11778
  globalThis.PhaserRegistry.GL_CONTEXT_ID -= 1;
@@ -13346,7 +13348,7 @@ var Mouse = class {
13346
13348
  * TBD.
13347
13349
  */
13348
13350
  start() {
13349
- if (this.game.device.android && this.game.device.chrome === false) return;
13351
+ if (this.game.device.android && !this.game.device.chrome) return;
13350
13352
  if (this._onMouseDown !== null) return;
13351
13353
  const scope = this;
13352
13354
  this._onMouseDown = (event) => {
@@ -13389,15 +13391,17 @@ var Mouse = class {
13389
13391
  */
13390
13392
  stop() {
13391
13393
  const { canvas } = this.game;
13392
- canvas.removeEventListener("mousedown", this._onMouseDown, true);
13393
- canvas.removeEventListener("mousemove", this._onMouseMove, true);
13394
- canvas.removeEventListener("mouseup", this._onMouseUp, true);
13395
- canvas.removeEventListener("mouseover", this._onMouseOver, true);
13396
- canvas.removeEventListener("mouseout", this._onMouseOut, true);
13394
+ if (this._onMouseDown) canvas.removeEventListener("mousedown", this._onMouseDown, true);
13395
+ if (this._onMouseMove) canvas.removeEventListener("mousemove", this._onMouseMove, true);
13396
+ if (this._onMouseUp) canvas.removeEventListener("mouseup", this._onMouseUp, true);
13397
+ if (this._onMouseOver) canvas.removeEventListener("mouseover", this._onMouseOver, true);
13398
+ if (this._onMouseOut) canvas.removeEventListener("mouseout", this._onMouseOut, true);
13397
13399
  const { wheelEvent } = this.game.device;
13398
- if (wheelEvent) canvas.removeEventListener(wheelEvent, this._onMouseWheel, true);
13399
- globalThis.removeEventListener("mouseup", this._onMouseUpGlobal, true);
13400
- globalThis.removeEventListener("mouseout", this._onMouseOutGlobal, true);
13400
+ if (wheelEvent) {
13401
+ if (this._onMouseWheel) canvas.removeEventListener(wheelEvent, this._onMouseWheel, true);
13402
+ }
13403
+ if (this._onMouseUpGlobal) globalThis.removeEventListener("mouseup", this._onMouseUpGlobal, true);
13404
+ if (this._onMouseOutGlobal) globalThis.removeEventListener("mouseout", this._onMouseOutGlobal, true);
13401
13405
  }
13402
13406
  /**
13403
13407
  * TBD.
@@ -13490,7 +13494,7 @@ var Mouse = class {
13490
13494
  if (this._wheelEvent) event = this._wheelEvent.bindEvent(event);
13491
13495
  this.event = event;
13492
13496
  this.eventPreventDefault(event);
13493
- this.wheelDelta = Math.max(-1, Math.min(1, -event.deltaY));
13497
+ this.wheelDelta = Math.max(-1, Math.min(1, -(event.deltaY ?? 0)));
13494
13498
  if (this.mouseWheelCallback) this.mouseWheelCallback.call(this.callbackContext, event);
13495
13499
  }
13496
13500
  /**
@@ -13575,8 +13579,8 @@ var MSPointer = class {
13575
13579
  canvas.addEventListener("pointerdown", this._onMSPointerDown, false);
13576
13580
  canvas.addEventListener("pointermove", this._onMSPointerMove, false);
13577
13581
  canvas.addEventListener("pointerup", this._onMSPointerUp, false);
13578
- canvas.style["-ms-content-zooming"] = "none";
13579
- canvas.style["-ms-touch-action"] = "none";
13582
+ canvas.style.setProperty("-ms-content-zooming", "none");
13583
+ canvas.style.setProperty("-ms-touch-action", "none");
13580
13584
  globalThis.addEventListener("MSPointerUp", this._onMSPointerUpGlobal, true);
13581
13585
  canvas.addEventListener("MSPointerOver", this._onMSPointerOver, true);
13582
13586
  canvas.addEventListener("MSPointerOut", this._onMSPointerOut, true);
@@ -13590,18 +13594,22 @@ var MSPointer = class {
13590
13594
  stop() {
13591
13595
  if (!this.game.device.mspointer) return;
13592
13596
  const { canvas } = this.game;
13593
- canvas.removeEventListener("MSPointerDown", this._onMSPointerDown, false);
13594
- canvas.removeEventListener("MSPointerMove", this._onMSPointerMove, false);
13595
- canvas.removeEventListener("MSPointerUp", this._onMSPointerUp, false);
13596
- canvas.removeEventListener("pointerdown", this._onMSPointerDown, false);
13597
- canvas.removeEventListener("pointermove", this._onMSPointerMove, false);
13598
- canvas.removeEventListener("pointerup", this._onMSPointerUp, false);
13599
- if (this._onMSPointerUpGlobal) globalThis.removeEventListener("MSPointerUp", this._onMSPointerUpGlobal, true);
13600
- canvas.removeEventListener("MSPointerOver", this._onMSPointerOver, true);
13601
- canvas.removeEventListener("MSPointerOut", this._onMSPointerOut, true);
13602
- if (this._onMSPointerUpGlobal) globalThis.removeEventListener("pointerup", this._onMSPointerUpGlobal, true);
13603
- canvas.removeEventListener("pointerover", this._onMSPointerOver, true);
13604
- canvas.removeEventListener("pointerout", this._onMSPointerOut, true);
13597
+ if (this._onMSPointerDown) canvas.removeEventListener("MSPointerDown", this._onMSPointerDown, false);
13598
+ if (this._onMSPointerMove) canvas.removeEventListener("MSPointerMove", this._onMSPointerMove, false);
13599
+ if (this._onMSPointerUp) canvas.removeEventListener("MSPointerUp", this._onMSPointerUp, false);
13600
+ if (this._onMSPointerDown) canvas.removeEventListener("pointerdown", this._onMSPointerDown, false);
13601
+ if (this._onMSPointerMove) canvas.removeEventListener("pointermove", this._onMSPointerMove, false);
13602
+ if (this._onMSPointerUp) canvas.removeEventListener("pointerup", this._onMSPointerUp, false);
13603
+ if (this._onMSPointerUpGlobal) {
13604
+ if (this._onMSPointerUpGlobal) globalThis.removeEventListener("MSPointerUp", this._onMSPointerUpGlobal, true);
13605
+ }
13606
+ if (this._onMSPointerOver) canvas.removeEventListener("MSPointerOver", this._onMSPointerOver, true);
13607
+ if (this._onMSPointerOut) canvas.removeEventListener("MSPointerOut", this._onMSPointerOut, true);
13608
+ if (this._onMSPointerUpGlobal) {
13609
+ if (this._onMSPointerUpGlobal) globalThis.removeEventListener("pointerup", this._onMSPointerUpGlobal, true);
13610
+ }
13611
+ if (this._onMSPointerOver) canvas.removeEventListener("pointerover", this._onMSPointerOver, true);
13612
+ if (this._onMSPointerOut) canvas.removeEventListener("pointerout", this._onMSPointerOut, true);
13605
13613
  }
13606
13614
  /**
13607
13615
  * TBD.
@@ -13809,7 +13817,7 @@ var Pointer = class {
13809
13817
  * @param {MouseEvent|PointerEvent} event - TBD.
13810
13818
  */
13811
13819
  updateButtons(event) {
13812
- if (event.type.toLowerCase().slice(-4) === "down") {
13820
+ if (event.type.toLowerCase().endsWith("down")) {
13813
13821
  this.isUp = false;
13814
13822
  this.isDown = true;
13815
13823
  } else {
@@ -13825,7 +13833,7 @@ var Pointer = class {
13825
13833
  start(event) {
13826
13834
  const { input } = this.game;
13827
13835
  if (event.pointerId) this.pointerId = event.pointerId;
13828
- this.identifier = event.identifier;
13836
+ this.identifier = event.identifier ?? null;
13829
13837
  this.target = event.target;
13830
13838
  if (this.isMouse) this.updateButtons(event);
13831
13839
  else {
@@ -13889,12 +13897,12 @@ var Pointer = class {
13889
13897
  const { input } = this.game;
13890
13898
  if (input.pollLocked) return null;
13891
13899
  if (fromClick && this.isMouse) this.updateButtons(event);
13892
- this.clientX = event.clientX;
13893
- this.clientY = event.clientY;
13894
- this.pageX = event.pageX;
13895
- this.pageY = event.pageY;
13896
- this.screenX = event.screenX;
13897
- this.screenY = event.screenY;
13900
+ this.clientX = event.clientX ?? 0;
13901
+ this.clientY = event.clientY ?? 0;
13902
+ this.pageX = event.pageX ?? 0;
13903
+ this.pageY = event.pageY ?? 0;
13904
+ this.screenX = event.screenX ?? 0;
13905
+ this.screenY = event.screenY ?? 0;
13898
13906
  if (this.isMouse && input.mouse.locked && !fromClick) {
13899
13907
  this.rawMovementX = event.movementX ?? event.mozMovementX ?? event.webkitMovementX ?? 0;
13900
13908
  this.rawMovementY = event.movementY ?? event.mozMovementY ?? event.webkitMovementY ?? 0;
@@ -13919,7 +13927,8 @@ var Pointer = class {
13919
13927
  let i = input.moveCallbacks.length;
13920
13928
  while (i) {
13921
13929
  i -= 1;
13922
- input.moveCallbacks[i].callback.call(input.moveCallbacks[i].context, this, this.x, this.y, fromClick);
13930
+ const moveCallback = input.moveCallbacks[i];
13931
+ moveCallback.callback.call(moveCallback.context, this, this.x, this.y, fromClick);
13923
13932
  }
13924
13933
  if (this.targetObject !== null && this.targetObject.isDragged === true) {
13925
13934
  if (this.targetObject.update(this) === false) this.targetObject = null;
@@ -14022,11 +14031,10 @@ var Pointer = class {
14022
14031
  this.isUp = true;
14023
14032
  }
14024
14033
  if (this.id > 0) this.active = false;
14025
- this.withinGame = this.game.scale.bounds.contains(event.pageX, event.pageY);
14034
+ this.withinGame = this.game.scale.bounds.contains(event.pageX ?? 0, event.pageY ?? 0);
14026
14035
  this.pointerId = null;
14027
14036
  this.identifier = null;
14028
14037
  this.positionUp.setTo(this.x, this.y);
14029
- if (!this.isMouse) input.currentPointers -= 1;
14030
14038
  input.interactiveItems.callAll("_releasedHandler", this);
14031
14039
  if (this._clickTrampolines) this._trampolineTargetObject = this.targetObject;
14032
14040
  this.targetObject = null;
@@ -14210,12 +14218,12 @@ var Touch = class {
14210
14218
  */
14211
14219
  stop() {
14212
14220
  if (!this.game.device.touch) return;
14213
- this.game.canvas.removeEventListener("touchstart", this._onTouchStart);
14214
- this.game.canvas.removeEventListener("touchmove", this._onTouchMove);
14215
- this.game.canvas.removeEventListener("touchend", this._onTouchEnd);
14216
- this.game.canvas.removeEventListener("touchenter", this._onTouchEnter);
14217
- this.game.canvas.removeEventListener("touchleave", this._onTouchLeave);
14218
- this.game.canvas.removeEventListener("touchcancel", this._onTouchCancel);
14221
+ if (this._onTouchStart) this.game.canvas.removeEventListener("touchstart", this._onTouchStart);
14222
+ if (this._onTouchMove) this.game.canvas.removeEventListener("touchmove", this._onTouchMove);
14223
+ if (this._onTouchEnd) this.game.canvas.removeEventListener("touchend", this._onTouchEnd);
14224
+ if (this._onTouchEnter) this.game.canvas.removeEventListener("touchenter", this._onTouchEnter);
14225
+ if (this._onTouchLeave) this.game.canvas.removeEventListener("touchleave", this._onTouchLeave);
14226
+ if (this._onTouchCancel) this.game.canvas.removeEventListener("touchcancel", this._onTouchCancel);
14219
14227
  }
14220
14228
  /**
14221
14229
  * TBD.
@@ -14235,7 +14243,8 @@ var Touch = class {
14235
14243
  if (!this.game.input.enabled || !this.enabled) return;
14236
14244
  if (this.touchStartCallback) this.touchStartCallback.call(this.callbackContext, event);
14237
14245
  this.eventPreventDefault(event);
14238
- for (let i = 0; i < event.changedTouches.length; i += 1) this.game.input.startPointer(event.changedTouches[i]);
14246
+ const changed = event.changedTouches ?? [];
14247
+ for (let i = 0; i < changed.length; i += 1) this.game.input.startPointer(changed[i]);
14239
14248
  }
14240
14249
  /**
14241
14250
  * TBD.
@@ -14246,7 +14255,8 @@ var Touch = class {
14246
14255
  if (this.touchCancelCallback) this.touchCancelCallback.call(this.callbackContext, event);
14247
14256
  if (!this.game.input.enabled || !this.enabled) return;
14248
14257
  this.eventPreventDefault(event);
14249
- for (let i = 0; i < event.changedTouches.length; i += 1) this.game.input.stopPointer(event.changedTouches[i]);
14258
+ const changed = event.changedTouches ?? [];
14259
+ for (let i = 0; i < changed.length; i += 1) this.game.input.stopPointer(changed[i]);
14250
14260
  }
14251
14261
  /**
14252
14262
  * TBD.
@@ -14275,7 +14285,8 @@ var Touch = class {
14275
14285
  this.event = event;
14276
14286
  if (this.touchMoveCallback) this.touchMoveCallback.call(this.callbackContext, event);
14277
14287
  this.eventPreventDefault(event);
14278
- for (let i = 0; i < event.changedTouches.length; i += 1) this.game.input.updatePointer(event.changedTouches[i]);
14288
+ const changed = event.changedTouches ?? [];
14289
+ for (let i = 0; i < changed.length; i += 1) this.game.input.updatePointer(changed[i]);
14279
14290
  }
14280
14291
  /**
14281
14292
  * TBD.
@@ -14285,7 +14296,8 @@ var Touch = class {
14285
14296
  this.event = event;
14286
14297
  if (this.touchEndCallback) this.touchEndCallback.call(this.callbackContext, event);
14287
14298
  this.eventPreventDefault(event);
14288
- for (let i = 0; i < event.changedTouches.length; i += 1) this.game.input.stopPointer(event.changedTouches[i]);
14299
+ const changed = event.changedTouches ?? [];
14300
+ for (let i = 0; i < changed.length; i += 1) this.game.input.stopPointer(changed[i]);
14289
14301
  }
14290
14302
  /**
14291
14303
  * TBD.
@@ -14924,12 +14936,9 @@ var Loader = class {
14924
14936
  data: null,
14925
14937
  loading: false,
14926
14938
  loaded: false,
14927
- error: false
14939
+ error: false,
14940
+ ...properties
14928
14941
  };
14929
- if (properties) {
14930
- const extraProperties = properties;
14931
- for (const prop of Object.keys(extraProperties)) file[prop] = extraProperties[prop];
14932
- }
14933
14942
  const fileIndex = this.getAssetIndex(type, key);
14934
14943
  if (overwrite && fileIndex > -1) {
14935
14944
  const currentFile = this._fileList[fileIndex];
@@ -15358,6 +15367,7 @@ var Loader = class {
15358
15367
  * @returns {string} The transformed URL.
15359
15368
  */
15360
15369
  transformUrl(url, file) {
15370
+ if (typeof url !== "string") return false;
15361
15371
  if (!url) return false;
15362
15372
  if (/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/.test(url)) return url;
15363
15373
  return this.baseURL + file.path + url;
@@ -15377,13 +15387,16 @@ var Loader = class {
15377
15387
  case "bitmapfont":
15378
15388
  this.loadImageTag(file);
15379
15389
  break;
15380
- case "audio":
15381
- file.url = this.getAudioURL(file.url);
15382
- if (file.url) this.xhrLoad(file, this.transformUrl(file.url, file), "arraybuffer", this.fileComplete);
15383
- else if (this.game.sound.noAudio) this.fileError(file, null, "Device does not have audio playback support");
15390
+ case "audio": {
15391
+ const resolved = this.getAudioURL(file.url);
15392
+ if (resolved) {
15393
+ file.url = resolved;
15394
+ this.xhrLoad(file, this.transformUrl(resolved, file), "arraybuffer", this.fileComplete);
15395
+ } else if (this.game.sound.noAudio) this.fileError(file, null, "Device does not have audio playback support");
15384
15396
  else if (this.game.device.noAudioFormat) this.fileError(file, null, "Device does not have audio format support");
15385
15397
  else this.fileError(file, null, "No supported audio URL specified");
15386
15398
  break;
15399
+ }
15387
15400
  case "json":
15388
15401
  this.xhrLoad(file, this.transformUrl(file.url, file), "text", this.jsonLoadComplete);
15389
15402
  break;
@@ -15432,6 +15445,10 @@ var Loader = class {
15432
15445
  * @param {Function} onerror - The function to call if the file fails to load.
15433
15446
  */
15434
15447
  xhrLoad(file, url, type, onload, onerror = null) {
15448
+ if (url === false) {
15449
+ this.fileError(file, null, "Could not resolve the file URL");
15450
+ return;
15451
+ }
15435
15452
  this.log("xhrLoad", file);
15436
15453
  const scope = this;
15437
15454
  const xhr = new XMLHttpRequest();
@@ -15493,18 +15510,21 @@ var Loader = class {
15493
15510
  */
15494
15511
  getAudioURL(urls) {
15495
15512
  if (this.game.sound.noAudio || this.game.device.noAudioFormat) return null;
15496
- for (let i = 0; i < urls.length; i += 1) {
15497
- let url = urls[i];
15513
+ const candidates = typeof urls === "string" ? [urls] : urls;
15514
+ for (let i = 0; i < candidates.length; i += 1) {
15515
+ const candidate = candidates[i];
15516
+ let url;
15498
15517
  let audioType = null;
15499
- if (url.uri) {
15500
- audioType = url.type;
15501
- url = url.uri;
15518
+ if (typeof candidate !== "string") {
15519
+ audioType = candidate.type ?? "";
15520
+ url = candidate.uri;
15502
15521
  if (canPlayAudio(this.game.device, audioType)) return url;
15503
15522
  } else {
15504
- if (url.indexOf("blob:") === 0 || url.indexOf("data:") === 0) return url;
15505
- if (url.includes("?")) url = url.substr(0, url.indexOf("?"));
15506
- audioType = url.slice((Math.max(0, url.lastIndexOf(".")) || Infinity) + 1).toLowerCase();
15507
- if (canPlayAudio(this.game.device, audioType)) return urls[i];
15523
+ url = candidate;
15524
+ if (url.startsWith("blob:") || url.startsWith("data:")) return url;
15525
+ const withoutQuery = url.includes("?") ? url.slice(0, url.indexOf("?")) : url;
15526
+ audioType = withoutQuery.slice((Math.max(0, withoutQuery.lastIndexOf(".")) || Infinity) + 1).toLowerCase();
15527
+ if (canPlayAudio(this.game.device, audioType)) return candidate;
15508
15528
  }
15509
15529
  }
15510
15530
  const formats = this.game.device.supportedAudioFormats;
@@ -15533,18 +15553,20 @@ var Loader = class {
15533
15553
  */
15534
15554
  fileComplete(file, xhr) {
15535
15555
  let loadNext = true;
15556
+ const url = typeof file.url === "string" ? file.url : "";
15557
+ const response = xhr;
15536
15558
  switch (file.type) {
15537
15559
  case "packfile":
15538
- file.data = JSON.parse(xhr.responseText) ?? {};
15560
+ file.data = JSON.parse(response.responseText) ?? {};
15539
15561
  break;
15540
15562
  case "image":
15541
- this.cache.addImage(file.key, file.url, file.data);
15563
+ this.cache.addImage(file.key, url, file.data);
15542
15564
  break;
15543
15565
  case "spritesheet":
15544
- this.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
15566
+ this.cache.addSpriteSheet(file.key, url, file.data, file.frameWidth ?? 0, file.frameHeight ?? 0, file.frameMax ?? -1, file.margin ?? 0, file.spacing ?? 0);
15545
15567
  break;
15546
15568
  case "textureatlas":
15547
- if (file.atlasURL == null) this.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData);
15569
+ if (file.atlasURL == null) this.cache.addTextureAtlas(file.key, url, file.data, file.atlasData);
15548
15570
  else {
15549
15571
  loadNext = false;
15550
15572
  if (file.format === TEXTURE_ATLAS_JSON_HASH) this.xhrLoad(file, this.transformUrl(file.atlasURL, file), "text", this.jsonLoadComplete);
@@ -15552,7 +15574,7 @@ var Loader = class {
15552
15574
  }
15553
15575
  break;
15554
15576
  case "bitmapfont":
15555
- if (!file.atlasURL) this.cache.addBitmapFont(file.key, file.url, file.data, file.atlasData, file.atlasType, file.xSpacing, file.ySpacing);
15577
+ if (!file.atlasURL) this.cache.addBitmapFont(file.key, url, file.data, file.atlasData, file.atlasType ?? "xml", file.xSpacing ?? 0, file.ySpacing ?? 0);
15556
15578
  else {
15557
15579
  loadNext = false;
15558
15580
  this.xhrLoad(file, this.transformUrl(file.atlasURL, file), "text", (bitmapFontFile, bitmapFontXhr) => {
@@ -15561,23 +15583,23 @@ var Loader = class {
15561
15583
  json = JSON.parse(bitmapFontXhr.responseText);
15562
15584
  } catch {}
15563
15585
  if (json) {
15564
- bitmapFontFile["atlasType"] = "json";
15586
+ bitmapFontFile.atlasType = "json";
15565
15587
  this.jsonLoadComplete(bitmapFontFile, bitmapFontXhr);
15566
15588
  } else {
15567
- bitmapFontFile["atlasType"] = "xml";
15589
+ bitmapFontFile.atlasType = "xml";
15568
15590
  this.xmlLoadComplete(bitmapFontFile, bitmapFontXhr);
15569
15591
  }
15570
15592
  });
15571
15593
  }
15572
15594
  break;
15573
15595
  case "audio":
15574
- file.data = xhr.response;
15575
- this.cache.addSound(file.key, file.url, file.data);
15596
+ file.data = response.response;
15597
+ this.cache.addSound(file.key, url, file.data);
15576
15598
  if (file.autoDecode) this.game.sound.decode(file.key);
15577
15599
  break;
15578
15600
  case "text":
15579
- file.data = xhr.responseText;
15580
- this.cache.addText(file.key, file.url, file.data);
15601
+ file.data = response.responseText;
15602
+ this.cache.addText(file.key, url, file.data);
15581
15603
  }
15582
15604
  if (loadNext) this.asyncComplete(file);
15583
15605
  }
@@ -15588,9 +15610,10 @@ var Loader = class {
15588
15610
  */
15589
15611
  jsonLoadComplete(file, xhr) {
15590
15612
  const data = JSON.parse(xhr.responseText);
15591
- if (file.type === "bitmapfont") this.cache.addBitmapFont(file.key, file.url, file.data, data, file.atlasType, file.xSpacing, file.ySpacing);
15592
- else if (file.type === "json") this.cache.addJSON(file.key, file.url, data);
15593
- else this.cache.addTextureAtlas(file.key, file.url, file.data, data);
15613
+ const url = typeof file.url === "string" ? file.url : "";
15614
+ if (file.type === "bitmapfont") this.cache.addBitmapFont(file.key, url, file.data, data, file.atlasType ?? "json", file.xSpacing ?? 0, file.ySpacing ?? 0);
15615
+ else if (file.type === "json") this.cache.addJSON(file.key, url, data);
15616
+ else this.cache.addTextureAtlas(file.key, url, file.data, data);
15594
15617
  this.asyncComplete(file);
15595
15618
  }
15596
15619
  /**
@@ -15613,9 +15636,10 @@ var Loader = class {
15613
15636
  this.asyncComplete(file, "invalid XML");
15614
15637
  return;
15615
15638
  }
15616
- if (file.type === "bitmapfont") this.cache.addBitmapFont(file.key, file.url, file.data, xml, file.atlasType, file.xSpacing, file.ySpacing);
15617
- else if (file.type === "textureatlas") this.cache.addTextureAtlas(file.key, file.url, file.data, xml);
15618
- else if (file.type === "xml") this.cache.addXML(file.key, file.url, xml);
15639
+ const url = typeof file.url === "string" ? file.url : "";
15640
+ if (file.type === "bitmapfont") this.cache.addBitmapFont(file.key, url, file.data, xml, file.atlasType ?? "xml", file.xSpacing ?? 0, file.ySpacing ?? 0);
15641
+ else if (file.type === "textureatlas") this.cache.addTextureAtlas(file.key, url, file.data, xml);
15642
+ else if (file.type === "xml") this.cache.addXML(file.key, url, xml);
15619
15643
  this.asyncComplete(file);
15620
15644
  }
15621
15645
  /**
@@ -16994,7 +17018,6 @@ var SceneManager = class {
16994
17018
  */
16995
17019
  remove(key) {
16996
17020
  if (this.current === key) {
16997
- this.callbackContext = null;
16998
17021
  this.onInitCallback = null;
16999
17022
  this.onShutDownCallback = null;
17000
17023
  this.onPreloadCallback = null;
@@ -17062,7 +17085,7 @@ var SceneManager = class {
17062
17085
  this.game.tweens.removeAll();
17063
17086
  this.game.input.reset(true);
17064
17087
  this.game.time.removeAll();
17065
- this.game.scale.reset(this._clearWorld);
17088
+ this.game.scale.reset();
17066
17089
  if (this._clearWorld) {
17067
17090
  this.game.world.destroy(true, true);
17068
17091
  if (this._clearCache) this.game.cache.destroy();
@@ -17164,14 +17187,12 @@ var SceneManager = class {
17164
17187
  this._clearWorld = true;
17165
17188
  this._clearCache = true;
17166
17189
  this.clearCurrentState();
17167
- this.callbackContext = null;
17168
17190
  this.onInitCallback = null;
17169
17191
  this.onShutDownCallback = null;
17170
17192
  this.onPreloadCallback = null;
17171
17193
  this.onCreateCallback = null;
17172
17194
  this.onUpdateCallback = null;
17173
17195
  this.onPauseUpdateCallback = null;
17174
- this.game = null;
17175
17196
  this.states = {};
17176
17197
  this._pendingState = null;
17177
17198
  this.current = "";
@@ -17672,7 +17693,7 @@ var SoundSprite = class {
17672
17693
  for (const k in this.config.spritemap) {
17673
17694
  const marker = this.config.spritemap[k];
17674
17695
  const sound = this.game.sound.add(this.key);
17675
- sound.addMarker(k, marker.start, marker.end - marker.start, null, marker.loop);
17696
+ sound.addMarker(k, marker.start, marker.end - marker.start, void 0, marker.loop);
17676
17697
  this.sounds[k] = sound;
17677
17698
  }
17678
17699
  if (this.config.autoplay) {
@@ -19333,8 +19354,8 @@ var Tween = class {
19333
19354
  let i = args.length;
19334
19355
  while (i) {
19335
19356
  i -= 1;
19336
- if (i > 0) args[i - 1].chainedTween = args[i];
19337
- else this.chainedTween = args[i];
19357
+ if (i > 0) args[i - 1].chainedTween = args[i] ?? null;
19358
+ else this.chainedTween = args[i] ?? null;
19338
19359
  }
19339
19360
  return this;
19340
19361
  }
@@ -19968,6 +19989,8 @@ var World = class extends Group {
19968
19989
  //#endregion
19969
19990
  //#region src/phaser/core/game.ts
19970
19991
  var Game = class {
19992
+ /** Set when the scene manager kick-starts the first scene. */
19993
+ isKickStart = false;
19971
19994
  config;
19972
19995
  id;
19973
19996
  parent;