@vpmedia/phaser 1.115.0 → 1.117.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 (193) hide show
  1. package/dist/index.js +56 -96
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts.map +1 -1
  4. package/dist/phaser/core/animation_manager.d.ts +15 -14
  5. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  6. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  7. package/dist/phaser/core/array_set.d.ts.map +1 -1
  8. package/dist/phaser/core/cache.d.ts +10 -9
  9. package/dist/phaser/core/cache.d.ts.map +1 -1
  10. package/dist/phaser/core/device_util.d.ts.map +1 -1
  11. package/dist/phaser/core/dom.d.ts.map +1 -1
  12. package/dist/phaser/core/factory.d.ts.map +1 -1
  13. package/dist/phaser/core/game.d.ts.map +1 -1
  14. package/dist/phaser/core/input.d.ts +20 -20
  15. package/dist/phaser/core/input.d.ts.map +1 -1
  16. package/dist/phaser/core/input_handler.d.ts +11 -13
  17. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  18. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  19. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  20. package/dist/phaser/core/input_pointer.d.ts +19 -8
  21. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  22. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  23. package/dist/phaser/core/loader.d.ts.map +1 -1
  24. package/dist/phaser/core/raf.d.ts.map +1 -1
  25. package/dist/phaser/core/scale_manager.d.ts +38 -13
  26. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  27. package/dist/phaser/core/scene.d.ts.map +1 -1
  28. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  29. package/dist/phaser/core/signal.d.ts.map +1 -1
  30. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  31. package/dist/phaser/core/sound.d.ts +2 -2
  32. package/dist/phaser/core/sound.d.ts.map +1 -1
  33. package/dist/phaser/core/sound_manager.d.ts +24 -22
  34. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  35. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  36. package/dist/phaser/core/stage.d.ts.map +1 -1
  37. package/dist/phaser/core/time.d.ts.map +1 -1
  38. package/dist/phaser/core/timer.d.ts +1 -1
  39. package/dist/phaser/core/timer.d.ts.map +1 -1
  40. package/dist/phaser/core/tween.d.ts.map +1 -1
  41. package/dist/phaser/core/tween_data.d.ts +26 -26
  42. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  43. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  44. package/dist/phaser/core/world.d.ts.map +1 -1
  45. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  46. package/dist/phaser/display/button.d.ts.map +1 -1
  47. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  48. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  49. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  50. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  51. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  52. package/dist/phaser/display/canvas/tinter.d.ts +3 -2
  53. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  54. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  55. package/dist/phaser/display/display_object.d.ts.map +1 -1
  56. package/dist/phaser/display/graphics.d.ts.map +1 -1
  57. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  58. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  59. package/dist/phaser/display/group.d.ts.map +1 -1
  60. package/dist/phaser/display/image.d.ts +2 -2
  61. package/dist/phaser/display/image.d.ts.map +1 -1
  62. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  63. package/dist/phaser/display/text.d.ts.map +1 -1
  64. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  65. package/dist/phaser/display/webgl/base_texture.d.ts +12 -10
  66. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  67. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  68. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  69. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +13 -12
  70. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  71. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  72. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  73. package/dist/phaser/display/webgl/graphics.d.ts +9 -7
  74. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  75. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  76. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  77. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  78. package/dist/phaser/display/webgl/renderer.d.ts +12 -10
  79. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  80. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  81. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  82. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  83. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  84. package/dist/phaser/display/webgl/texture.d.ts +18 -33
  85. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  86. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  87. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  88. package/dist/phaser/geom/circle.d.ts.map +1 -1
  89. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  90. package/dist/phaser/geom/line.d.ts.map +1 -1
  91. package/dist/phaser/geom/matrix.d.ts +1 -1
  92. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  93. package/dist/phaser/geom/point.d.ts.map +1 -1
  94. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  95. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  96. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  97. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  98. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  99. package/dist/phaser/geom/util/line.d.ts +5 -4
  100. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  101. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  102. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  103. package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
  104. package/dist/phaser/geom/util/rectangle.d.ts +10 -1
  105. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  106. package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  107. package/package.json +1 -1
  108. package/src/phaser/core/animation.ts +20 -20
  109. package/src/phaser/core/animation_manager.ts +27 -24
  110. package/src/phaser/core/animation_parser.ts +2 -2
  111. package/src/phaser/core/array_set.ts +7 -7
  112. package/src/phaser/core/cache.ts +55 -51
  113. package/src/phaser/core/callback_context.test.ts +70 -0
  114. package/src/phaser/core/device_util.ts +13 -13
  115. package/src/phaser/core/dom.ts +26 -22
  116. package/src/phaser/core/factory.ts +6 -6
  117. package/src/phaser/core/game.ts +10 -10
  118. package/src/phaser/core/input.ts +37 -39
  119. package/src/phaser/core/input_handler.ts +90 -93
  120. package/src/phaser/core/input_mouse.ts +19 -19
  121. package/src/phaser/core/input_mspointer.ts +15 -15
  122. package/src/phaser/core/input_pointer.ts +37 -28
  123. package/src/phaser/core/input_touch.ts +17 -17
  124. package/src/phaser/core/loader.ts +52 -52
  125. package/src/phaser/core/loader_parser.ts +3 -3
  126. package/src/phaser/core/raf.ts +3 -3
  127. package/src/phaser/core/scale_manager.ts +86 -67
  128. package/src/phaser/core/scene.ts +7 -7
  129. package/src/phaser/core/scene_manager.ts +16 -16
  130. package/src/phaser/core/signal.ts +29 -19
  131. package/src/phaser/core/signal_binding.ts +4 -4
  132. package/src/phaser/core/sound.ts +17 -17
  133. package/src/phaser/core/sound_manager.ts +71 -72
  134. package/src/phaser/core/sound_sprite.ts +1 -1
  135. package/src/phaser/core/stage.ts +7 -7
  136. package/src/phaser/core/time.ts +16 -16
  137. package/src/phaser/core/timer.ts +36 -26
  138. package/src/phaser/core/tween.ts +23 -23
  139. package/src/phaser/core/tween_data.ts +41 -37
  140. package/src/phaser/core/tween_manager.ts +11 -11
  141. package/src/phaser/core/world.ts +1 -1
  142. package/src/phaser/display/bitmap_text.ts +13 -13
  143. package/src/phaser/display/button.ts +13 -13
  144. package/src/phaser/display/canvas/buffer.ts +3 -3
  145. package/src/phaser/display/canvas/graphics.ts +3 -3
  146. package/src/phaser/display/canvas/masker.ts +2 -2
  147. package/src/phaser/display/canvas/pool.ts +6 -6
  148. package/src/phaser/display/canvas/renderer.ts +6 -6
  149. package/src/phaser/display/canvas/tinter.ts +39 -8
  150. package/src/phaser/display/canvas/util.ts +15 -9
  151. package/src/phaser/display/display_object.ts +38 -38
  152. package/src/phaser/display/graphics.ts +30 -30
  153. package/src/phaser/display/graphics_data.ts +1 -1
  154. package/src/phaser/display/graphics_data_util.ts +1 -1
  155. package/src/phaser/display/group.ts +16 -16
  156. package/src/phaser/display/image.ts +30 -26
  157. package/src/phaser/display/sprite_util.ts +12 -4
  158. package/src/phaser/display/text.ts +55 -55
  159. package/src/phaser/display/webgl/abstract_filter.ts +1 -1
  160. package/src/phaser/display/webgl/base_texture.ts +22 -18
  161. package/src/phaser/display/webgl/blend_manager.ts +3 -3
  162. package/src/phaser/display/webgl/earcut.ts +3 -3
  163. package/src/phaser/display/webgl/fast_sprite_batch.ts +26 -24
  164. package/src/phaser/display/webgl/filter_manager.ts +7 -7
  165. package/src/phaser/display/webgl/filter_texture.ts +3 -3
  166. package/src/phaser/display/webgl/graphics.ts +43 -41
  167. package/src/phaser/display/webgl/graphics_data.ts +2 -2
  168. package/src/phaser/display/webgl/mask_manager.ts +2 -2
  169. package/src/phaser/display/webgl/render_texture.ts +6 -6
  170. package/src/phaser/display/webgl/renderer.ts +20 -25
  171. package/src/phaser/display/webgl/shader/normal.ts +3 -3
  172. package/src/phaser/display/webgl/shader_manager.ts +2 -2
  173. package/src/phaser/display/webgl/sprite_batch.ts +9 -9
  174. package/src/phaser/display/webgl/stencil_manager.ts +4 -4
  175. package/src/phaser/display/webgl/texture.ts +23 -42
  176. package/src/phaser/display/webgl/texture_util.ts +2 -2
  177. package/src/phaser/display/webgl/util.ts +11 -7
  178. package/src/phaser/geom/circle.ts +21 -21
  179. package/src/phaser/geom/ellipse.ts +7 -7
  180. package/src/phaser/geom/line.ts +29 -29
  181. package/src/phaser/geom/matrix.ts +13 -13
  182. package/src/phaser/geom/point.ts +36 -30
  183. package/src/phaser/geom/polygon.ts +6 -6
  184. package/src/phaser/geom/rectangle.ts +42 -42
  185. package/src/phaser/geom/rounded_rectangle.ts +2 -2
  186. package/src/phaser/geom/util/circle.ts +7 -7
  187. package/src/phaser/geom/util/ellipse.ts +1 -1
  188. package/src/phaser/geom/util/line.ts +13 -5
  189. package/src/phaser/geom/util/matrix.ts +3 -3
  190. package/src/phaser/geom/util/point.ts +20 -20
  191. package/src/phaser/geom/util/polygon.ts +1 -1
  192. package/src/phaser/geom/util/rectangle.ts +34 -17
  193. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
package/dist/index.js CHANGED
@@ -767,12 +767,6 @@ const containsRect = (a, b) => {
767
767
  * @returns {boolean} True if the rectangles are equal, false otherwise.
768
768
  */
769
769
  const equals$1 = (a, b) => a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
770
- /**
771
- * Checks if two rectangles intersect.
772
- * @param {Rectangle} a - The first rectangle to check.
773
- * @param {Rectangle} b - The second rectangle to check.
774
- * @returns {boolean} True if the rectangles intersect, false otherwise.
775
- */
776
770
  const intersects$1 = (a, b) => {
777
771
  if (a.width <= 0 || a.height <= 0 || b.width <= 0 || b.height <= 0) return false;
778
772
  return !(a.right < b.x || a.bottom < b.y || a.x > b.right || a.y > b.bottom);
@@ -3426,7 +3420,6 @@ var AnimationManager = class {
3426
3420
  this._frameData = null;
3427
3421
  this.currentAnim = null;
3428
3422
  this.currentFrame = null;
3429
- this.sprite = null;
3430
3423
  }
3431
3424
  /**
3432
3425
  * Loads frame data into the AnimationManager.
@@ -3488,9 +3481,12 @@ var AnimationManager = class {
3488
3481
  * @returns {boolean} True if all frames are valid, false otherwise.
3489
3482
  */
3490
3483
  validateFrames(frames, useNumericIndex = false) {
3491
- for (let i = 0; i < frames.length; i += 1) if (useNumericIndex) {
3492
- if (frames[i] > this._frameData.total) return false;
3493
- } else if (this._frameData.checkFrameName(frames[i]) === false) return false;
3484
+ for (let i = 0; i < frames.length; i += 1) {
3485
+ const frame = frames[i];
3486
+ if (useNumericIndex) {
3487
+ if (Number(frame) > this._frameData.total) return false;
3488
+ } else if (!this._frameData.checkFrameName(String(frame))) return false;
3489
+ }
3494
3490
  return true;
3495
3491
  }
3496
3492
  /**
@@ -3503,7 +3499,7 @@ var AnimationManager = class {
3503
3499
  play(name, frameRate = null, loop = null) {
3504
3500
  if (this._anims[name]) {
3505
3501
  if (this.currentAnim === this._anims[name]) {
3506
- if (this.currentAnim.isPlaying === false) {
3502
+ if (!this.currentAnim.isPlaying) {
3507
3503
  this.currentAnim.paused = false;
3508
3504
  return this.currentAnim.play(frameRate, loop);
3509
3505
  }
@@ -3591,13 +3587,13 @@ var AnimationManager = class {
3591
3587
  * @returns {boolean} True if the current animation is paused, false otherwise.
3592
3588
  */
3593
3589
  get paused() {
3594
- return this.currentAnim.isPaused;
3590
+ return this.currentAnim?.isPaused ?? false;
3595
3591
  }
3596
3592
  /**
3597
3593
  * Sets the paused state of the current animation.
3598
3594
  */
3599
3595
  set paused(value) {
3600
- this.currentAnim.paused = value;
3596
+ if (this.currentAnim) this.currentAnim.paused = value;
3601
3597
  }
3602
3598
  /**
3603
3599
  * Gets the name of the current animation.
@@ -3814,35 +3810,16 @@ var EventManager = class {
3814
3810
  };
3815
3811
  //#endregion
3816
3812
  //#region src/phaser/display/webgl/texture.ts
3813
+ /** The four corners of a texture frame in normalised texture space. */
3817
3814
  var TextureUvs = class {
3818
- noFrame;
3819
- baseTexture;
3820
- frame;
3821
- trim;
3822
- valid;
3823
- isTiling;
3824
- requiresUpdate;
3825
- requiresReTint;
3826
- _uvs;
3827
- width;
3828
- height;
3829
- crop;
3830
3815
  x0 = 0;
3831
3816
  y0 = 0;
3832
3817
  x1 = 0;
3833
3818
  y1 = 0;
3834
3819
  x2 = 0;
3835
- y2;
3836
- x3;
3837
- y3;
3838
- /**
3839
- * Creates a new Texture instance.
3840
- */
3841
- constructor() {
3842
- this.y2 = 0;
3843
- this.x3 = 0;
3844
- this.y3 = 0;
3845
- }
3820
+ y2 = 0;
3821
+ x3 = 0;
3822
+ y3 = 0;
3846
3823
  };
3847
3824
  var Texture = class Texture {
3848
3825
  noFrame = false;
@@ -3929,7 +3906,7 @@ var Texture = class Texture {
3929
3906
  this.valid = false;
3930
3907
  return;
3931
3908
  }
3932
- this.valid = frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded;
3909
+ this.valid = Boolean(frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded);
3933
3910
  if (this.trim) {
3934
3911
  this.width = this.trim.width;
3935
3912
  this.height = this.trim.height;
@@ -4075,7 +4052,7 @@ var Image$1 = class extends DisplayObject {
4075
4052
  let setFrame = true;
4076
4053
  if (key instanceof Texture) this.setTexture(key);
4077
4054
  else {
4078
- const img = cache.getImage(key, true);
4055
+ const img = cache.getImage(key ?? void 0, true);
4079
4056
  if (img) {
4080
4057
  this.key = img.key;
4081
4058
  this.setTexture(new Texture(img.base));
@@ -4107,12 +4084,7 @@ var Image$1 = class extends DisplayObject {
4107
4084
  this.texture.trim.y = frame.spriteSourceSizeY;
4108
4085
  this.texture.trim.width = frame.sourceSizeW;
4109
4086
  this.texture.trim.height = frame.sourceSizeH;
4110
- } else this.texture.trim = {
4111
- x: frame.spriteSourceSizeX,
4112
- y: frame.spriteSourceSizeY,
4113
- width: frame.sourceSizeW,
4114
- height: frame.sourceSizeH
4115
- };
4087
+ } else this.texture.trim = new Rectangle(frame.spriteSourceSizeX, frame.spriteSourceSizeY, frame.sourceSizeW, frame.sourceSizeH);
4116
4088
  this.texture.width = frame.sourceSizeW;
4117
4089
  this.texture.height = frame.sourceSizeH;
4118
4090
  this.texture.frame.width = frame.sourceSizeW;
@@ -4705,7 +4677,6 @@ var InputHandler = class {
4705
4677
  isDragged;
4706
4678
  allowHorizontalDrag;
4707
4679
  allowVerticalDrag;
4708
- bringToTop;
4709
4680
  snapOffset;
4710
4681
  snapOnDrag;
4711
4682
  snapOnRelease;
@@ -4753,7 +4724,6 @@ var InputHandler = class {
4753
4724
  this.isDragged = false;
4754
4725
  this.allowHorizontalDrag = true;
4755
4726
  this.allowVerticalDrag = true;
4756
- this.bringToTop = false;
4757
4727
  this.snapOffset = null;
4758
4728
  this.snapOnDrag = false;
4759
4729
  this.snapOnRelease = false;
@@ -4863,7 +4833,6 @@ var InputHandler = class {
4863
4833
  this._pointerData.length = 0;
4864
4834
  this.boundsRect = null;
4865
4835
  this.boundsSprite = null;
4866
- this.sprite = null;
4867
4836
  }
4868
4837
  }
4869
4838
  /**
@@ -5054,7 +5023,7 @@ var InputHandler = class {
5054
5023
  */
5055
5024
  update(pointer) {
5056
5025
  if (this.sprite === null || this.sprite.parent === void 0) return false;
5057
- if (!this.enabled || !this.sprite.visible || !this.sprite.parent.visible) {
5026
+ if (!this.enabled || !this.sprite.visible || !this.sprite.parent?.visible) {
5058
5027
  this._pointerOutHandler(pointer);
5059
5028
  return false;
5060
5029
  }
@@ -5147,7 +5116,6 @@ var InputHandler = class {
5147
5116
  } else this._dragTimePass = true;
5148
5117
  }
5149
5118
  }
5150
- if (this.bringToTop) this.sprite.bringToTop();
5151
5119
  }
5152
5120
  }
5153
5121
  /**
@@ -5276,12 +5244,11 @@ var InputHandler = class {
5276
5244
  * @param {boolean} pixelPerfect - TBD.
5277
5245
  * @param {number} alphaThreshold - TBD.
5278
5246
  * @param {Rectangle | null | undefined} boundsRect - TBD.
5279
- * @param {DisplayObject | null | undefined} boundsSprite - TBD.
5247
+ * @param {Image | null | undefined} boundsSprite - TBD.
5280
5248
  */
5281
- enableDrag(lockCenter = false, bringToTop = false, pixelPerfect = false, alphaThreshold = 255, boundsRect = null, boundsSprite = null) {
5249
+ enableDrag(lockCenter = false, _bringToTop = false, pixelPerfect = false, alphaThreshold = 255, boundsRect = null, boundsSprite = null) {
5282
5250
  this._dragPoint = new Point();
5283
5251
  this.draggable = true;
5284
- this.bringToTop = bringToTop;
5285
5252
  this.dragOffset = new Point();
5286
5253
  this.dragFromCenter = lockCenter;
5287
5254
  this.pixelPerfectClick = pixelPerfect;
@@ -5318,10 +5285,6 @@ var InputHandler = class {
5318
5285
  }
5319
5286
  this._dragPoint.setTo(this.sprite.x - this.globalToLocalX(pointer.x), this.sprite.y - this.globalToLocalY(pointer.y));
5320
5287
  this.updateDrag(pointer, true);
5321
- if (this.bringToTop) {
5322
- this._dragPhase = true;
5323
- this.sprite.parent.bringToTop(this.sprite);
5324
- }
5325
5288
  this.dragStartPoint.setTo(x, y);
5326
5289
  this.sprite.events.onDragStart$dispatch(this.sprite, pointer, x, y);
5327
5290
  this._pendingDrag = false;
@@ -7440,7 +7403,7 @@ const buildRectangle = (graphicsData, webGLData) => {
7440
7403
  const { width } = rectData;
7441
7404
  const { height } = rectData;
7442
7405
  if (graphicsData.fill) {
7443
- const color = hex2rgb(graphicsData.fillColor);
7406
+ const color = hex2rgb(graphicsData.fillColor ?? 0);
7444
7407
  const alpha = graphicsData.fillAlpha;
7445
7408
  const r = color[0] * alpha;
7446
7409
  const g = color[1] * alpha;
@@ -7530,7 +7493,7 @@ const buildRoundedRectangle = (graphicsData, webGLData) => {
7530
7493
  recPoints = recPoints.concat(quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y));
7531
7494
  recPoints = recPoints.concat(quadraticBezierCurve(x + radius, y, x, y, x, y + radius));
7532
7495
  if (graphicsData.fill) {
7533
- const color = hex2rgb(graphicsData.fillColor);
7496
+ const color = hex2rgb(graphicsData.fillColor ?? 0);
7534
7497
  const alpha = graphicsData.fillAlpha;
7535
7498
  const r = color[0] * alpha;
7536
7499
  const g = color[1] * alpha;
@@ -7566,7 +7529,7 @@ const buildCircle = (graphicsData, webGLData) => {
7566
7529
  const { y } = circleData;
7567
7530
  let width;
7568
7531
  let height;
7569
- if (graphicsData.shape instanceof Circle) {
7532
+ if (circleData instanceof Circle) {
7570
7533
  width = circleData.radius;
7571
7534
  height = circleData.radius;
7572
7535
  } else {
@@ -7575,7 +7538,7 @@ const buildCircle = (graphicsData, webGLData) => {
7575
7538
  }
7576
7539
  const seg = Math.PI * 2 / 40;
7577
7540
  if (graphicsData.fill) {
7578
- const color = hex2rgb(graphicsData.fillColor);
7541
+ const color = hex2rgb(graphicsData.fillColor ?? 0);
7579
7542
  const alpha = graphicsData.fillAlpha;
7580
7543
  const r = color[0] * alpha;
7581
7544
  const g = color[1] * alpha;
@@ -7611,7 +7574,7 @@ const buildComplexPoly = (graphicsData, webGLData) => {
7611
7574
  const { indices } = webGLData;
7612
7575
  webGLData.points = points;
7613
7576
  webGLData.alpha = graphicsData.fillAlpha;
7614
- webGLData.color = hex2rgb(graphicsData.fillColor);
7577
+ webGLData.color = hex2rgb(graphicsData.fillColor ?? 0);
7615
7578
  let minX = Infinity;
7616
7579
  let maxX = -Infinity;
7617
7580
  let minY = Infinity;
@@ -7642,7 +7605,7 @@ const buildPoly = (graphicsData, webGLData) => {
7642
7605
  const verts = webGLData.points;
7643
7606
  const { indices } = webGLData;
7644
7607
  const length = points.length / 2;
7645
- const color = hex2rgb(graphicsData.fillColor);
7608
+ const color = hex2rgb(graphicsData.fillColor ?? 0);
7646
7609
  const alpha = graphicsData.fillAlpha;
7647
7610
  const r = color[0] * alpha;
7648
7611
  const g = color[1] * alpha;
@@ -7799,10 +7762,10 @@ var BaseTexture = class {
7799
7762
  true
7800
7763
  ];
7801
7764
  if (source) {
7802
- if ((this.source.complete || this.source.getContext) && this.source.width && this.source.height) {
7765
+ if ((source instanceof HTMLImageElement ? source.complete : true) && source.width && source.height) {
7803
7766
  this.hasLoaded = true;
7804
- this.width = this.source.naturalWidth ?? this.source.width;
7805
- this.height = this.source.naturalHeight ?? this.source.height;
7767
+ this.width = source instanceof HTMLImageElement ? source.naturalWidth : source.width;
7768
+ this.height = source instanceof HTMLImageElement ? source.naturalHeight : source.height;
7806
7769
  this.dirty();
7807
7770
  }
7808
7771
  }
@@ -7822,7 +7785,7 @@ var BaseTexture = class {
7822
7785
  * Destroys the texture.
7823
7786
  */
7824
7787
  destroy() {
7825
- if (this.source) removeByCanvas(this.source);
7788
+ if (this.source instanceof HTMLCanvasElement) removeByCanvas(this.source);
7826
7789
  this.source = null;
7827
7790
  this.unloadFromGPU();
7828
7791
  }
@@ -11493,7 +11456,7 @@ var WebGLSpriteBatch = class {
11493
11456
  const { gl } = this;
11494
11457
  if (texture._dirty[gl.id]) {
11495
11458
  if (!this.renderSession.renderer.updateTexture(texture)) return;
11496
- } else gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id]);
11459
+ } else gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id] ?? null);
11497
11460
  gl.drawElements(gl.TRIANGLES, size * 6, gl.UNSIGNED_SHORT, startIndex * 6 * 2);
11498
11461
  this.renderSession.drawCount += 1;
11499
11462
  }
@@ -11759,14 +11722,9 @@ var WebGLRenderer = class {
11759
11722
  */
11760
11723
  destroy() {
11761
11724
  globalThis.PhaserRegistry.GL_CONTEXTS[this.glContextId] = null;
11762
- this.projection = null;
11763
- this.offset = null;
11764
11725
  this.shaderManager.destroy();
11765
11726
  this.spriteBatch.destroy();
11766
11727
  this.filterManager.destroy();
11767
- this.shaderManager = null;
11768
- this.spriteBatch = null;
11769
- this.filterManager = null;
11770
11728
  if (this.gl) {
11771
11729
  this.gl.canvas.width = 1;
11772
11730
  this.gl.canvas.height = 1;
@@ -11883,7 +11841,7 @@ var WebGLRenderer = class {
11883
11841
  if (!texture.hasLoaded) return false;
11884
11842
  const { gl } = this;
11885
11843
  texture._glTextures[gl.id] ??= gl.createTexture();
11886
- gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id]);
11844
+ gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id] ?? null);
11887
11845
  gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha);
11888
11846
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source);
11889
11847
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === 0 ? gl.LINEAR : gl.NEAREST);
@@ -12487,7 +12445,8 @@ var Cache = class {
12487
12445
  * @returns {boolean} True if the URL has been resolved and cached, false otherwise.
12488
12446
  */
12489
12447
  checkURL(url) {
12490
- if (this._urlMap[this._resolveURL(url)]) return true;
12448
+ const resolved = this._resolveURL(url);
12449
+ if (resolved && this._urlMap?.[resolved]) return true;
12491
12450
  return false;
12492
12451
  }
12493
12452
  /**
@@ -12593,7 +12552,7 @@ var Cache = class {
12593
12552
  * @returns {HTMLImageElement} TBD.
12594
12553
  */
12595
12554
  getImage(key = "__default", full = false) {
12596
- let img = this.getItem(key, 1, "getImage");
12555
+ let img = this.getItem(String(key), 1, "getImage");
12597
12556
  if (img === null) img = this.getItem("__missing", 1, "getImage");
12598
12557
  if (full) return img;
12599
12558
  return img.data;
@@ -12761,7 +12720,7 @@ var Cache = class {
12761
12720
  */
12762
12721
  getURL(url) {
12763
12722
  const resolvedURL = this._resolveURL(url);
12764
- if (resolvedURL) return this._urlMap[resolvedURL];
12723
+ if (resolvedURL) return this._urlMap?.[resolvedURL] ?? null;
12765
12724
  this.game.logger.warn("Cache invalid url", { resolvedURL });
12766
12725
  return null;
12767
12726
  }
@@ -12873,10 +12832,11 @@ var Cache = class {
12873
12832
  */
12874
12833
  _resolveURL(url, data = null) {
12875
12834
  if (!this.autoResolveURL) return null;
12835
+ if (!this._urlResolver) return null;
12876
12836
  this._urlResolver.src = this.game.load.baseURL + url;
12877
12837
  this._urlTemp = this._urlResolver.src;
12878
12838
  this._urlResolver.src = "";
12879
- if (data) this._urlMap[this._urlTemp] = data;
12839
+ if (data && this._urlMap) this._urlMap[this._urlTemp] = data;
12880
12840
  return this._urlTemp;
12881
12841
  }
12882
12842
  /**
@@ -13930,8 +13890,8 @@ var Pointer = class {
13930
13890
  const moveCallback = input.moveCallbacks[i];
13931
13891
  moveCallback.callback.call(moveCallback.context, this, this.x, this.y, fromClick);
13932
13892
  }
13933
- if (this.targetObject !== null && this.targetObject.isDragged === true) {
13934
- if (this.targetObject.update(this) === false) this.targetObject = null;
13893
+ if (this.targetObject !== null && this.targetObject.isDragged) {
13894
+ if (!this.targetObject.update(this)) this.targetObject = null;
13935
13895
  } else if (input.interactiveItems.total > 0) this.processInteractiveObjects(fromClick);
13936
13896
  return this;
13937
13897
  }
@@ -14393,8 +14353,6 @@ var Input = class {
14393
14353
  this.recordPointerHistory = false;
14394
14354
  this.recordRate = 100;
14395
14355
  this.recordLimit = 100;
14396
- this.pointer1 = null;
14397
- this.pointer2 = null;
14398
14356
  this.pointer3 = null;
14399
14357
  this.pointer4 = null;
14400
14358
  this.pointer5 = null;
@@ -16694,8 +16652,9 @@ var ScaleManager = class {
16694
16652
  if (canvas.parentNode) canvas.before(fsTarget);
16695
16653
  fsTarget.append(canvas);
16696
16654
  }
16697
- if (this.game.device.fullscreenKeyboard) fsTarget[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
16698
- else fsTarget[this.game.device.requestFullscreen]();
16655
+ const requestFullscreen = fsTarget[this.game.device.requestFullscreen];
16656
+ if (this.game.device.fullscreenKeyboard) requestFullscreen?.call(fsTarget, Element.ALLOW_KEYBOARD_INPUT);
16657
+ else requestFullscreen?.call(fsTarget);
16699
16658
  return true;
16700
16659
  }
16701
16660
  /**
@@ -17928,21 +17887,21 @@ var SoundManager = class {
17928
17887
  */
17929
17888
  stopAll() {
17930
17889
  if (this.noAudio) return;
17931
- for (let i = 0; i < this._sounds.length; i += 1) if (this._sounds[i]) this._sounds[i].stop();
17890
+ for (const sound of this._sounds) if (sound) sound.stop();
17932
17891
  }
17933
17892
  /**
17934
17893
  * Pauses all sounds in the manager.
17935
17894
  */
17936
17895
  pauseAll() {
17937
17896
  if (this.noAudio) return;
17938
- for (let i = 0; i < this._sounds.length; i += 1) if (this._sounds[i]) this._sounds[i].pause();
17897
+ for (const sound of this._sounds) if (sound) sound.pause();
17939
17898
  }
17940
17899
  /**
17941
17900
  * Resumes all sounds in the manager.
17942
17901
  */
17943
17902
  resumeAll() {
17944
17903
  if (this.noAudio) return;
17945
- for (let i = 0; i < this._sounds.length; i += 1) if (this._sounds[i]) this._sounds[i].resume();
17904
+ for (const sound of this._sounds) if (sound) sound.resume();
17946
17905
  }
17947
17906
  /**
17948
17907
  * Decodes an audio file for playback.
@@ -17974,11 +17933,12 @@ var SoundManager = class {
17974
17933
  * @param {object} callbackContext - The context in which to call the callback.
17975
17934
  */
17976
17935
  setDecodedCallback(files, callback, callbackContext) {
17977
- if (typeof files === "string") files = [files];
17936
+ const candidates = typeof files === "string" ? [files] : Array.isArray(files) ? files : [files];
17978
17937
  this._watchList.reset();
17979
- for (let i = 0; i < files.length; i += 1) if (files[i] instanceof Sound) {
17980
- if (!this.game.cache.isSoundDecoded(files[i].key)) this._watchList.add(files[i].key);
17981
- } else if (!this.game.cache.isSoundDecoded(files[i])) this._watchList.add(files[i]);
17938
+ for (const file of candidates) {
17939
+ const key = file instanceof Sound ? file.key : file;
17940
+ if (!this.game.cache.isSoundDecoded(key)) this._watchList.add(key);
17941
+ }
17982
17942
  if (this._watchList.total === 0) {
17983
17943
  this._watching = false;
17984
17944
  callback.call(callbackContext);
@@ -17993,7 +17953,7 @@ var SoundManager = class {
17993
17953
  */
17994
17954
  update() {
17995
17955
  if (this.noAudio) return;
17996
- for (let i = 0; i < this._sounds.length; i += 1) this._sounds[i].update();
17956
+ for (const sound of this._sounds) sound.update();
17997
17957
  if (this._watching) {
17998
17958
  let key = this._watchList.first;
17999
17959
  while (key) {
@@ -18003,7 +17963,7 @@ var SoundManager = class {
18003
17963
  if (this._watchList.total === 0) {
18004
17964
  this.game.logger.info("All sounds decoded");
18005
17965
  this._watching = false;
18006
- this._watchCallback.call(this._watchContext);
17966
+ this._watchCallback?.call(this._watchContext);
18007
17967
  }
18008
17968
  }
18009
17969
  }
@@ -18102,7 +18062,7 @@ var SoundManager = class {
18102
18062
  */
18103
18063
  destroy() {
18104
18064
  this.stopAll();
18105
- for (let i = 0; i < this._sounds.length; i += 1) if (this._sounds[i]) this._sounds[i].destroy();
18065
+ for (const sound of this._sounds) if (sound) sound.destroy();
18106
18066
  this._sounds = [];
18107
18067
  this.onChange.dispose();
18108
18068
  if (this.context?.close) this.context.close();
@@ -18999,9 +18959,9 @@ var TweenData = class {
18999
18959
  */
19000
18960
  update(time) {
19001
18961
  if (!this.isRunning) {
19002
- if (time >= this.startTime) this.isRunning = true;
18962
+ if (time >= (this.startTime ?? 0)) this.isRunning = true;
19003
18963
  else return 0;
19004
- } else if (time < this.startTime) return 1;
18964
+ } else if (time < (this.startTime ?? 0)) return 1;
19005
18965
  const ms = this.game.time.elapsedMS;
19006
18966
  if (this.parent.reverse) {
19007
18967
  this.dt -= ms * this.parent.timeScale;
@@ -19403,7 +19363,7 @@ var Tween = class {
19403
19363
  if (this.isPaused) {
19404
19364
  this.isPaused = false;
19405
19365
  this._codePaused = false;
19406
- for (const tweenData of this.timeline) if (!tweenData.isRunning) tweenData.startTime += this.game.time.time - this._pausedTime;
19366
+ for (const tweenData of this.timeline) if (!tweenData.isRunning) tweenData.startTime = (tweenData.startTime ?? 0) + (this.game.time.time - this._pausedTime);
19407
19367
  }
19408
19368
  }
19409
19369
  /**