@vpmedia/phaser 1.106.0 → 1.108.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 (217) hide show
  1. package/dist/index.js +225 -226
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts +2 -2
  4. package/dist/phaser/core/animation.d.ts.map +1 -1
  5. package/dist/phaser/core/animation_manager.d.ts +2 -2
  6. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  7. package/dist/phaser/core/animation_parser.d.ts +2 -2
  8. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  9. package/dist/phaser/core/array_set.d.ts.map +1 -1
  10. package/dist/phaser/core/cache.d.ts +6 -6
  11. package/dist/phaser/core/cache.d.ts.map +1 -1
  12. package/dist/phaser/core/device.d.ts.map +1 -1
  13. package/dist/phaser/core/device_util.d.ts.map +1 -1
  14. package/dist/phaser/core/dom.d.ts +2 -2
  15. package/dist/phaser/core/dom.d.ts.map +1 -1
  16. package/dist/phaser/core/event_manager.d.ts.map +1 -1
  17. package/dist/phaser/core/factory.d.ts +1 -1
  18. package/dist/phaser/core/factory.d.ts.map +1 -1
  19. package/dist/phaser/core/frame.d.ts.map +1 -1
  20. package/dist/phaser/core/frame_data.d.ts.map +1 -1
  21. package/dist/phaser/core/frame_util.d.ts.map +1 -1
  22. package/dist/phaser/core/game.d.ts +1 -1
  23. package/dist/phaser/core/game.d.ts.map +1 -1
  24. package/dist/phaser/core/input.d.ts +3 -3
  25. package/dist/phaser/core/input.d.ts.map +1 -1
  26. package/dist/phaser/core/input_handler.d.ts +8 -8
  27. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  28. package/dist/phaser/core/input_mouse.d.ts +8 -8
  29. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  30. package/dist/phaser/core/input_mspointer.d.ts +6 -6
  31. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  32. package/dist/phaser/core/input_pointer.d.ts +3 -3
  33. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  34. package/dist/phaser/core/input_touch.d.ts +7 -7
  35. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  36. package/dist/phaser/core/loader.d.ts +6 -6
  37. package/dist/phaser/core/loader.d.ts.map +1 -1
  38. package/dist/phaser/core/loader_parser.d.ts +4 -4
  39. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  40. package/dist/phaser/core/raf.d.ts.map +1 -1
  41. package/dist/phaser/core/scale_manager.d.ts +5 -5
  42. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  43. package/dist/phaser/core/scene.d.ts +3 -3
  44. package/dist/phaser/core/scene.d.ts.map +1 -1
  45. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  46. package/dist/phaser/core/signal.d.ts +7 -7
  47. package/dist/phaser/core/signal.d.ts.map +1 -1
  48. package/dist/phaser/core/signal_binding.d.ts +1 -1
  49. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  50. package/dist/phaser/core/sound.d.ts +3 -3
  51. package/dist/phaser/core/sound.d.ts.map +1 -1
  52. package/dist/phaser/core/sound_manager.d.ts +1 -1
  53. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  54. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  55. package/dist/phaser/core/stage.d.ts.map +1 -1
  56. package/dist/phaser/core/time.d.ts.map +1 -1
  57. package/dist/phaser/core/timer.d.ts +5 -5
  58. package/dist/phaser/core/timer.d.ts.map +1 -1
  59. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  60. package/dist/phaser/core/tween.d.ts +1 -1
  61. package/dist/phaser/core/tween.d.ts.map +1 -1
  62. package/dist/phaser/core/tween_data.d.ts +1 -1
  63. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  64. package/dist/phaser/core/tween_easing.d.ts.map +1 -1
  65. package/dist/phaser/core/tween_manager.d.ts +1 -1
  66. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  67. package/dist/phaser/core/world.d.ts.map +1 -1
  68. package/dist/phaser/display/bitmap_text.d.ts +3 -3
  69. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  70. package/dist/phaser/display/button.d.ts +12 -11
  71. package/dist/phaser/display/button.d.ts.map +1 -1
  72. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  73. package/dist/phaser/display/canvas/graphics.d.ts +3 -3
  74. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  75. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  76. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  77. package/dist/phaser/display/canvas/renderer.d.ts +2 -2
  78. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  79. package/dist/phaser/display/canvas/tinter.d.ts +1 -1
  80. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  81. package/dist/phaser/display/canvas/util.d.ts +1 -1
  82. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  83. package/dist/phaser/display/display_object.d.ts +12 -21
  84. package/dist/phaser/display/display_object.d.ts.map +1 -1
  85. package/dist/phaser/display/graphics.d.ts +1 -1
  86. package/dist/phaser/display/graphics.d.ts.map +1 -1
  87. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  88. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  89. package/dist/phaser/display/group.d.ts +3 -3
  90. package/dist/phaser/display/group.d.ts.map +1 -1
  91. package/dist/phaser/display/image.d.ts +8 -8
  92. package/dist/phaser/display/image.d.ts.map +1 -1
  93. package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
  94. package/dist/phaser/display/sprite_util.d.ts +5 -5
  95. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  96. package/dist/phaser/display/text.d.ts +8 -7
  97. package/dist/phaser/display/text.d.ts.map +1 -1
  98. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  99. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  100. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  101. package/dist/phaser/display/webgl/earcut.d.ts +5 -5
  102. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  103. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  104. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +3 -2
  105. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  106. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  107. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  108. package/dist/phaser/display/webgl/graphics.d.ts +4 -3
  109. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  110. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  111. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  112. package/dist/phaser/display/webgl/render_texture.d.ts +2 -2
  113. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  114. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  115. package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  116. package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  117. package/dist/phaser/display/webgl/shader/normal.d.ts +1 -1
  118. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  119. package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  120. package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  121. package/dist/phaser/display/webgl/shader_manager.d.ts +2 -1
  122. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  123. package/dist/phaser/display/webgl/sprite_batch.d.ts +2 -1
  124. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  125. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  126. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  127. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  128. package/dist/phaser/display/webgl/util.d.ts +8 -4
  129. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  130. package/dist/phaser/geom/circle.d.ts +1 -1
  131. package/dist/phaser/geom/circle.d.ts.map +1 -1
  132. package/dist/phaser/geom/ellipse.d.ts +1 -1
  133. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  134. package/dist/phaser/geom/line.d.ts +3 -3
  135. package/dist/phaser/geom/line.d.ts.map +1 -1
  136. package/dist/phaser/geom/matrix.d.ts +3 -3
  137. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  138. package/dist/phaser/geom/point.d.ts.map +1 -1
  139. package/dist/phaser/geom/polygon.d.ts +1 -1
  140. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  141. package/dist/phaser/geom/rectangle.d.ts +2 -2
  142. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  143. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  144. package/dist/phaser/geom/util/circle.d.ts +3 -3
  145. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  146. package/dist/phaser/geom/util/ellipse.d.ts +1 -1
  147. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  148. package/dist/phaser/geom/util/line.d.ts +3 -3
  149. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  150. package/dist/phaser/geom/util/matrix.d.ts +1 -1
  151. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  152. package/dist/phaser/geom/util/point.d.ts +15 -15
  153. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  154. package/dist/phaser/geom/util/polygon.d.ts +1 -1
  155. package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
  156. package/dist/phaser/geom/util/rectangle.d.ts +5 -5
  157. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  158. package/dist/phaser/geom/util/rounded_rectangle.d.ts +1 -1
  159. package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  160. package/dist/phaser/util/math.d.ts.map +1 -1
  161. package/package.json +13 -13
  162. package/src/phaser/core/animation.ts +6 -6
  163. package/src/phaser/core/animation_manager.ts +2 -2
  164. package/src/phaser/core/cache.ts +9 -8
  165. package/src/phaser/core/device_util.ts +4 -2
  166. package/src/phaser/core/dom.ts +2 -2
  167. package/src/phaser/core/factory.ts +3 -5
  168. package/src/phaser/core/game.ts +21 -34
  169. package/src/phaser/core/input.ts +2 -2
  170. package/src/phaser/core/input_handler.ts +6 -5
  171. package/src/phaser/core/input_mouse.ts +8 -84
  172. package/src/phaser/core/input_mspointer.ts +12 -8
  173. package/src/phaser/core/input_touch.ts +7 -7
  174. package/src/phaser/core/loader.ts +35 -31
  175. package/src/phaser/core/loader_parser.ts +12 -4
  176. package/src/phaser/core/scale_manager.ts +5 -5
  177. package/src/phaser/core/scene.ts +3 -3
  178. package/src/phaser/core/signal.ts +9 -9
  179. package/src/phaser/core/signal_binding.ts +1 -1
  180. package/src/phaser/core/sound.ts +12 -21
  181. package/src/phaser/core/sound_manager.ts +3 -3
  182. package/src/phaser/core/stage.ts +6 -6
  183. package/src/phaser/core/timer.ts +4 -4
  184. package/src/phaser/core/tween.ts +7 -5
  185. package/src/phaser/core/tween_data.ts +2 -2
  186. package/src/phaser/core/tween_manager.ts +2 -2
  187. package/src/phaser/display/bitmap_text.ts +6 -6
  188. package/src/phaser/display/button.ts +33 -26
  189. package/src/phaser/display/canvas/renderer.ts +2 -2
  190. package/src/phaser/display/canvas/util.ts +12 -12
  191. package/src/phaser/display/display_object.ts +17 -31
  192. package/src/phaser/display/graphics.ts +9 -9
  193. package/src/phaser/display/group.ts +8 -8
  194. package/src/phaser/display/image.ts +21 -21
  195. package/src/phaser/display/sprite_util.ts +1 -1
  196. package/src/phaser/display/text.ts +9 -9
  197. package/src/phaser/display/webgl/earcut.ts +12 -4
  198. package/src/phaser/display/webgl/fast_sprite_batch.ts +4 -2
  199. package/src/phaser/display/webgl/graphics.ts +3 -2
  200. package/src/phaser/display/webgl/render_texture.ts +2 -2
  201. package/src/phaser/display/webgl/shader/normal.ts +1 -1
  202. package/src/phaser/display/webgl/shader_manager.ts +2 -1
  203. package/src/phaser/display/webgl/sprite_batch.ts +2 -1
  204. package/src/phaser/display/webgl/util.ts +9 -0
  205. package/src/phaser/geom/circle.ts +1 -1
  206. package/src/phaser/geom/ellipse.ts +1 -1
  207. package/src/phaser/geom/line.ts +2 -2
  208. package/src/phaser/geom/matrix.ts +3 -3
  209. package/src/phaser/geom/polygon.ts +1 -1
  210. package/src/phaser/geom/rectangle.ts +2 -2
  211. package/src/phaser/geom/util/circle.ts +8 -3
  212. package/src/phaser/geom/util/line.ts +9 -2
  213. package/src/phaser/geom/util/matrix.ts +1 -1
  214. package/src/phaser/geom/util/point.ts +15 -15
  215. package/src/phaser/geom/util/polygon.ts +1 -1
  216. package/src/phaser/geom/util/rectangle.ts +5 -5
  217. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
@@ -84,7 +84,7 @@ export class Timer {
84
84
  loop: boolean,
85
85
  repeatCount: number,
86
86
  callback: Function,
87
- callbackContext: any = null,
87
+ callbackContext: any | null = null,
88
88
  args: any = []
89
89
  ) {
90
90
  const roundedDelay = Math.round(delay);
@@ -109,7 +109,7 @@ export class Timer {
109
109
  * @param {...any} args - Arguments to pass to the callback function.
110
110
  * @returns {TimerEvent} The created TimerEvent.
111
111
  */
112
- add(delay: number, callback: Function, callbackContext: any = null, ...args: any[]) {
112
+ add(delay: number, callback: Function, callbackContext: any | null = null, ...args: any[]) {
113
113
  return this.create(delay, false, 0, callback, callbackContext, args);
114
114
  }
115
115
 
@@ -137,7 +137,7 @@ export class Timer {
137
137
  * @param {...any} args - Arguments to pass to the callback function.
138
138
  * @returns {TimerEvent} The created TimerEvent.
139
139
  */
140
- repeat(delay: number, repeatCount: number, callback: Function, callbackContext: any = null, ...args: any[]) {
140
+ repeat(delay: number, repeatCount: number, callback: Function, callbackContext: any | null = null, ...args: any[]) {
141
141
  return this.create(delay, false, repeatCount, callback, callbackContext, args);
142
142
  }
143
143
 
@@ -149,7 +149,7 @@ export class Timer {
149
149
  * @param {...any} args - Arguments to pass to the callback function.
150
150
  * @returns {TimerEvent} The created TimerEvent.
151
151
  */
152
- loop(delay: number, callback: Function, callbackContext: any = null, ...args: any[]) {
152
+ loop(delay: number, callback: Function, callbackContext: any | null = null, ...args: any[]) {
153
153
  return this.create(delay, true, 0, callback, callbackContext, args);
154
154
  }
155
155
 
@@ -162,7 +162,8 @@ export class Tween {
162
162
  const keys = Object.keys(this.timeline[i].vEnd);
163
163
  for (let k = 0; k < keys.length; k += 1) {
164
164
  const property = keys[k];
165
- this.properties[property] = this.target[property] || 0;
165
+ const targetProperties = this.target as unknown as Record<string, number>;
166
+ this.properties[property] = targetProperties[property] || 0;
166
167
  if (!Array.isArray(this.properties[property])) {
167
168
  // Ensures we're using numbers, not strings
168
169
  this.properties[property] *= 1;
@@ -214,11 +215,11 @@ export class Tween {
214
215
  return this;
215
216
  }
216
217
  if (index === -1) {
217
- for (let i = 0; i < this.timeline.length; i += 1) {
218
- this.timeline[i][property] = value;
218
+ for (const timelineEntry of this.timeline) {
219
+ (timelineEntry as unknown as Record<string, unknown>)[property] = value;
219
220
  }
220
221
  } else {
221
- this.timeline[index][property] = value;
222
+ (this.timeline[index] as unknown as Record<string, unknown>)[property] = value;
222
223
  }
223
224
  return this;
224
225
  }
@@ -494,7 +495,8 @@ export class Tween {
494
495
  const keys = Object.keys(this.timeline[i].vEnd);
495
496
  for (let k = 0; k < keys.length; k += 1) {
496
497
  const property = keys[k];
497
- this.properties[property] = this.target[property] || 0;
498
+ const targetProperties = this.target as unknown as Record<string, number>;
499
+ this.properties[property] = targetProperties[property] || 0;
498
500
  if (!Array.isArray(this.properties[property])) {
499
501
  // Ensures we're using numbers, not strings
500
502
  this.properties[property] *= 1;
@@ -51,7 +51,7 @@ export class TweenData {
51
51
  this.delay = 0;
52
52
  this.dt = 0;
53
53
  this.startTime = null;
54
- this.easingFunction = (k) => k;
54
+ this.easingFunction = (k: number) => k;
55
55
  this.interpolationFunction = MathUtils.linearInterpolation;
56
56
  this.interpolationContext = MathUtils;
57
57
  this.isRunning = false;
@@ -236,7 +236,7 @@ export class TweenData {
236
236
  }
237
237
  this.percent = this.dt / this.duration;
238
238
  this.value = this.easingFunction(this.percent);
239
- const blob = {};
239
+ const blob: Record<string, number> = {};
240
240
  const keys = Object.keys(this.vEnd);
241
241
  for (let k = 0; k < keys.length; k += 1) {
242
242
  const property = keys[k];
@@ -122,7 +122,7 @@ export class TweenManager {
122
122
  * @param {object} obj - The object to remove tweens from.
123
123
  * @param {object[]} children - Optional array of child objects to remove tweens from.
124
124
  */
125
- removeFrom(obj: any, children: any[] = null) {
125
+ removeFrom(obj: any, children: any[] | null = null) {
126
126
  let i;
127
127
  let len;
128
128
  if (Array.isArray(obj)) {
@@ -214,7 +214,7 @@ export class TweenManager {
214
214
  * @returns {boolean} True if the object is being tweened, false otherwise.
215
215
  */
216
216
  isTweening(object: any) {
217
- return this._tweens.some((tween) => tween.target === object);
217
+ return this._tweens.some((tween: Tween) => tween.target === object);
218
218
  }
219
219
 
220
220
  /**
@@ -70,7 +70,7 @@ export class BitmapText extends DisplayObject {
70
70
  /**
71
71
  * Destroys this bitmap text and cleans up resources.
72
72
  */
73
- destroy() {
73
+ override destroy() {
74
74
  this._prevAnchor = null;
75
75
  this._glyphs = null;
76
76
  this._text = null;
@@ -81,13 +81,13 @@ export class BitmapText extends DisplayObject {
81
81
  /**
82
82
  * Called before the update cycle for this bitmap text.
83
83
  */
84
- preUpdate() {
84
+ override preUpdate() {
85
85
  if (this.pendingDestroy) {
86
86
  this.destroy();
87
87
  return;
88
88
  }
89
89
 
90
- if (!this.exists || !this.parent.exists) {
90
+ if (!this.exists || !this.parent?.exists) {
91
91
  this.renderOrderID = -1;
92
92
  return;
93
93
  }
@@ -299,7 +299,7 @@ export class BitmapText extends DisplayObject {
299
299
  /**
300
300
  * Updates the transform of this bitmap text, updating its text if needed.
301
301
  */
302
- updateTransform(): this {
302
+ override updateTransform(): this {
303
303
  if (this.dirty || !this.anchor.equals(this._prevAnchor)) {
304
304
  this.updateText();
305
305
  this.dirty = false;
@@ -312,10 +312,10 @@ export class BitmapText extends DisplayObject {
312
312
  /**
313
313
  * Adds a color to a specific position in the text.
314
314
  * @param {string} value - The color to apply (in hex format or CSS color name).
315
- * @param {number} position - The character position to apply the color to.
315
+ * @param {number} _position - The character position to apply the color to.
316
316
  * @returns {BitmapText} This bitmap text instance for chaining.
317
317
  */
318
- addColor(value: string, position: number) {
318
+ addColor(value: string, _position: number) {
319
319
  const color = typeof value === 'string' ? Number.parseInt(value.replace('#', ''), 16) : value;
320
320
  if (color !== this._tint) {
321
321
  this._tint = color;
@@ -10,6 +10,7 @@ const STATE_UP = 'Up';
10
10
  const STATE_DISABLED = 'Disabled';
11
11
 
12
12
  export class Button extends Image {
13
+ [key: `_on${string}Frame`]: string | null;
13
14
  _onOverFrame!: string | null;
14
15
  _onOutFrame!: string | null;
15
16
  _onDownFrame!: string | null;
@@ -42,14 +43,14 @@ export class Button extends Image {
42
43
  game: import('../core/game.js').Game,
43
44
  x: number = 0,
44
45
  y: number = 0,
45
- key: string = null,
46
- callback: Function = null,
47
- callbackContext: any = null,
48
- overFrame: string = null,
49
- outFrame: string = null,
50
- downFrame: string = null,
51
- upFrame: string = null,
52
- disabledFrame: string = null
46
+ key: string | null = null,
47
+ callback: Function | null = null,
48
+ callbackContext: any | null = null,
49
+ overFrame: string | null = null,
50
+ outFrame: string | null = null,
51
+ downFrame: string | null = null,
52
+ upFrame: string | null = null,
53
+ disabledFrame: string | null = null
53
54
  ) {
54
55
  super(game, x, y, key, outFrame);
55
56
  this.type = BUTTON;
@@ -83,7 +84,7 @@ export class Button extends Image {
83
84
  /**
84
85
  * Destroys this button and cleans up resources.
85
86
  */
86
- destroy() {
87
+ override destroy() {
87
88
  this._onOverFrame = null;
88
89
  this._onOutFrame = null;
89
90
  this._onDownFrame = null;
@@ -95,14 +96,14 @@ export class Button extends Image {
95
96
  this.onInputDown.dispose();
96
97
  this.onInputUp.dispose();
97
98
  }
98
- this.onInputOver = null;
99
- this.onInputOut = null;
100
- this.onInputDown = null;
101
- this.onInputUp = null;
99
+ this.onInputOver = null!;
100
+ this.onInputOut = null!;
101
+ this.onInputDown = null!;
102
+ this.onInputUp = null!;
102
103
  if (this.input) {
103
104
  this.input.destroy();
104
105
  }
105
- this.input = null;
106
+ this.input = null!;
106
107
  super.destroy();
107
108
  }
108
109
 
@@ -142,8 +143,8 @@ export class Button extends Image {
142
143
  * @param {string} frame - The frame identifier to set for this state.
143
144
  * @param {boolean} switchImmediately - Whether to switch to the new frame immediately (default: false).
144
145
  */
145
- setStateFrame(state: string, frame: string, switchImmediately: boolean = false) {
146
- const frameKey = `_on${state}Frame`;
146
+ setStateFrame(state: string, frame: string | null, switchImmediately: boolean = false) {
147
+ const frameKey: `_on${string}Frame` = `_on${state}Frame`;
147
148
  if (frame) {
148
149
  this[frameKey] = frame;
149
150
  if (switchImmediately) {
@@ -164,7 +165,7 @@ export class Button extends Image {
164
165
  return false;
165
166
  }
166
167
  const state = this.input.enabled || !this._onDisabledFrame ? newState : STATE_DISABLED;
167
- const frameKey = `_on${state}Frame`;
168
+ const frameKey: `_on${string}Frame` = `_on${state}Frame`;
168
169
  const frame = this[frameKey];
169
170
  if (typeof frame === 'string') {
170
171
  this.frameName = frame;
@@ -184,7 +185,13 @@ export class Button extends Image {
184
185
  * @param {string} upFrame - The frame identifier to use when the button is released.
185
186
  * @param {string} disabledFrame - The frame identifier to use when the button is disabled.
186
187
  */
187
- setFrames(overFrame: string, outFrame: string, downFrame: string, upFrame: string, disabledFrame: string = null) {
188
+ setFrames(
189
+ overFrame: string | null,
190
+ outFrame: string | null,
191
+ downFrame: string | null,
192
+ upFrame: string | null,
193
+ disabledFrame: string | null = null
194
+ ) {
188
195
  this.setStateFrame(STATE_OVER, overFrame, this.input.pointerOver());
189
196
  this.setStateFrame(STATE_OUT, outFrame, !this.input.pointerOver());
190
197
  this.setStateFrame(STATE_DOWN, downFrame, this.input.pointerDown());
@@ -196,10 +203,10 @@ export class Button extends Image {
196
203
 
197
204
  /**
198
205
  * Handles the input over event for this button.
199
- * @param {object} sprite - The sprite that triggered the event.
206
+ * @param {object} _sprite - The sprite that triggered the event.
200
207
  * @param {object} pointer - The pointer that triggered the event.
201
208
  */
202
- onInputOverHandler(sprite: any, pointer: any) {
209
+ onInputOverHandler(_sprite: any, pointer: any) {
203
210
  if (pointer.justReleased() && (this.justReleasedPreventsOver & pointer.pointerMode) === pointer.pointerMode) {
204
211
  // If the Pointer was only just released then we don't fire an over event
205
212
  return;
@@ -215,10 +222,10 @@ export class Button extends Image {
215
222
 
216
223
  /**
217
224
  * Handles the input out event for this button.
218
- * @param {object} sprite - The sprite that triggered the event.
225
+ * @param {object} _sprite - The sprite that triggered the event.
219
226
  * @param {object} pointer - The pointer that triggered the event.
220
227
  */
221
- onInputOutHandler(sprite: any, pointer: any) {
228
+ onInputOutHandler(_sprite: any, pointer: any) {
222
229
  this.changeStateFrame(STATE_OUT);
223
230
  if (this.onInputOut) {
224
231
  this.onInputOut.dispatch(this, pointer);
@@ -227,10 +234,10 @@ export class Button extends Image {
227
234
 
228
235
  /**
229
236
  * Handles the input down event for this button.
230
- * @param {object} sprite - The sprite that triggered the event.
237
+ * @param {object} _sprite - The sprite that triggered the event.
231
238
  * @param {object} pointer - The pointer that triggered the event.
232
239
  */
233
- onInputDownHandler(sprite: any, pointer: any) {
240
+ onInputDownHandler(_sprite: any, pointer: any) {
234
241
  this.changeStateFrame(STATE_DOWN);
235
242
  if (this.onInputDown) {
236
243
  this.onInputDown.dispatch(this, pointer);
@@ -239,11 +246,11 @@ export class Button extends Image {
239
246
 
240
247
  /**
241
248
  * Handles the input up event for this button.
242
- * @param {object} sprite - The sprite that triggered the event.
249
+ * @param {object} _sprite - The sprite that triggered the event.
243
250
  * @param {object} pointer - The pointer that triggered the event.
244
251
  * @param {boolean} isOver - Whether the pointer is currently over the button (default: true).
245
252
  */
246
- onInputUpHandler(sprite: any, pointer: any, isOver: boolean) {
253
+ onInputUpHandler(_sprite: any, pointer: any, isOver: boolean) {
247
254
  if (this.onInputUp) {
248
255
  this.onInputUp.dispatch(this, pointer, isOver);
249
256
  }
@@ -41,7 +41,7 @@ export class CanvasRenderer {
41
41
  renderSession!: any;
42
42
  /**
43
43
  * Creates a new CanvasRenderer instance.
44
- * @param {import('../../core/game.js').Game} game - The game instance.
44
+ * @param {import('../../core/game.js').Game} _game - The game instance.
45
45
  */
46
46
  constructor(game: import('../../core/game.js').Game) {
47
47
  detectCapabilities(game);
@@ -176,7 +176,7 @@ export class CanvasRenderer {
176
176
  * Initializes the WebGL context for rendering.
177
177
  * @param {import('../../core/game.js').Game} game - The game instance.
178
178
  */
179
- initContext(game: import('../../core/game.js').Game) {
179
+ initContext(_game: import('../../core/game.js').Game) {
180
180
  // stub
181
181
  }
182
182
  }
@@ -42,10 +42,8 @@ export const setBackgroundColor = (canvas: HTMLCanvasElement, color: string) =>
42
42
  */
43
43
  export const setTouchAction = (canvas: HTMLCanvasElement, value: string = 'none') => {
44
44
  value = value || 'none';
45
- // @ts-ignore
46
- canvas.style.msTouchAction = value;
47
- canvas.style['ms-touch-action'] = value;
48
- canvas.style['touch-action'] = value;
45
+ canvas.style.setProperty('-ms-touch-action', value);
46
+ canvas.style.setProperty('touch-action', value);
49
47
  return canvas;
50
48
  };
51
49
 
@@ -57,13 +55,13 @@ export const setTouchAction = (canvas: HTMLCanvasElement, value: string = 'none'
57
55
  */
58
56
  export const setUserSelect = (canvas: HTMLCanvasElement, value: string = 'none') => {
59
57
  value = value || 'none';
60
- canvas.style['-webkit-touch-callout'] = value;
61
- canvas.style['-webkit-user-select'] = value;
62
- canvas.style['-khtml-user-select'] = value;
63
- canvas.style['-moz-user-select'] = value;
64
- canvas.style['-ms-user-select'] = value;
65
- canvas.style['user-select'] = value;
66
- canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)';
58
+ canvas.style.setProperty('-webkit-touch-callout', value);
59
+ canvas.style.setProperty('-webkit-user-select', value);
60
+ canvas.style.setProperty('-khtml-user-select', value);
61
+ canvas.style.setProperty('-moz-user-select', value);
62
+ canvas.style.setProperty('-ms-user-select', value);
63
+ canvas.style.setProperty('user-select', value);
64
+ canvas.style.setProperty('-webkit-tap-highlight-color', 'rgba(0, 0, 0, 0)');
67
65
  return canvas;
68
66
  };
69
67
 
@@ -137,9 +135,11 @@ export const setTransform = (
137
135
  */
138
136
  export const getSmoothingPrefix = (context: CanvasRenderingContext2D) => {
139
137
  const VENDORS = ['i', 'webkitI', 'msI', 'mozI', 'oI'];
138
+ // the vendor-prefixed smoothing flags predate the standard property and are absent from lib.dom
139
+ const smoothingFlags = context as unknown as Record<string, boolean | undefined>;
140
140
  for (let i = 0; i < VENDORS.length; i += 1) {
141
141
  const s = `${VENDORS[i]}mageSmoothingEnabled`;
142
- if (context && context[s]) {
142
+ if (context && smoothingFlags[s]) {
143
143
  return s;
144
144
  }
145
145
  }
@@ -20,36 +20,27 @@ export class DisplayObject {
20
20
  rotation = 0;
21
21
  /** @type {number} */
22
22
  alpha = 1;
23
- /** @type {Rectangle} */
24
- hitArea = null;
25
- /** @type {DisplayObject} */
26
- parent = null;
23
+ hitArea: Rectangle | null = null;
24
+ parent: DisplayObject | null = null;
27
25
  /** @type {number} */
28
26
  worldAlpha = 1;
29
27
  worldTransform!: Matrix;
30
28
  worldScale!: Point;
31
- /** @type {Rectangle} */
32
- filterArea = null;
29
+ filterArea: Rectangle | null = null;
33
30
  /** @type {number} */
34
31
  _sr = 0;
35
32
  /** @type {number} */
36
33
  _cr = 1;
37
34
  cachedBounds!: Rectangle;
38
- /** @type {Rectangle} */
39
- currentBounds = null;
40
- /** @type {import('./graphics.js').Graphics} */
41
- _mask = null;
42
- /** @type {object[]} */
43
- _filters = null;
44
- /** @type {object} */
45
- _filterBlock = null;
35
+ currentBounds: Rectangle | null = null;
36
+ _mask: import('./graphics.js').Graphics | null = null;
37
+ _filters: object[] | null = null;
38
+ _filterBlock: object | null = null;
46
39
  children!: any[];
47
40
  /** @type {boolean} */
48
41
  ignoreChildInput = false;
49
- /** @type {string | null} */
50
- name = null;
51
- /** @type {object | null} */
52
- data = null;
42
+ name: string | null = null;
43
+ data: Record<string, any> | null = null;
53
44
  game!: import('../core/game.js').Game;
54
45
  type!: number;
55
46
  _cachedSprite!: any;
@@ -135,7 +126,7 @@ export class DisplayObject {
135
126
  this.children[i].destroy();
136
127
  }
137
128
  }
138
- this.children = null;
129
+ this.children = null!;
139
130
  this.exists = false;
140
131
  this.renderable = false;
141
132
  this.visible = false;
@@ -148,11 +139,11 @@ export class DisplayObject {
148
139
  */
149
140
  this.hitArea = null;
150
141
  this.parent = null;
151
- this.worldTransform = null;
142
+ this.worldTransform = null!;
152
143
  // This.worldPosition = null;
153
- this.worldScale = null;
144
+ this.worldScale = null!;
154
145
  this.filterArea = null;
155
- this.cachedBounds = null;
146
+ this.cachedBounds = null!;
156
147
  this.currentBounds = null;
157
148
  this._mask = null;
158
149
  this.destroyCachedSprite();
@@ -319,12 +310,7 @@ export class DisplayObject {
319
310
  if (!this.game || !this.visible) {
320
311
  return this;
321
312
  }
322
- let p = this.parent;
323
- if (parent) {
324
- p = parent;
325
- } else if (!this.parent) {
326
- p = this.game.world;
327
- }
313
+ const p = parent ?? this.parent ?? this.game.world;
328
314
  // Create some matrix refs for easy access
329
315
  const pt = p.worldTransform;
330
316
  const wt = this.worldTransform;
@@ -510,7 +496,7 @@ export class DisplayObject {
510
496
  * @param {DisplayObject} child - The child display object to check.
511
497
  * @returns {boolean} True if the child is contained within this container, false otherwise.
512
498
  */
513
- contains(child: DisplayObject) {
499
+ contains(child: DisplayObject | null): boolean {
514
500
  if (!child) {
515
501
  return false;
516
502
  }
@@ -778,13 +764,13 @@ export class DisplayObject {
778
764
  * Sets the mask for this display object.
779
765
  * @param {import('./graphics.js').Graphics} value - The mask object to set, or null to remove the mask.
780
766
  */
781
- set mask(value: import('./graphics.js').Graphics) {
767
+ set mask(value: import('./graphics.js').Graphics | null) {
782
768
  if (this._mask) {
783
769
  this._mask.isMask = false;
784
770
  }
785
771
  this._mask = value;
786
772
  if (value) {
787
- this._mask.isMask = true;
773
+ value.isMask = true;
788
774
  }
789
775
  }
790
776
 
@@ -98,7 +98,7 @@ export class Graphics extends DisplayObject {
98
98
  /**
99
99
  * Destroys the graphics object and clears all data.
100
100
  */
101
- destroy() {
101
+ override destroy() {
102
102
  // TODO
103
103
  this.clear();
104
104
  super.destroy();
@@ -478,7 +478,7 @@ export class Graphics extends DisplayObject {
478
478
  /**
479
479
  * Generates a texture from the graphics object (not implemented).
480
480
  */
481
- generateTexture() {
481
+ override generateTexture() {
482
482
  // TODO
483
483
  this.game.logger.warn('graphics.generateTexture() is not implemented');
484
484
  }
@@ -487,7 +487,7 @@ export class Graphics extends DisplayObject {
487
487
  * Renders the graphics object using WebGL.
488
488
  * @param {object} renderSession - The render session to use.
489
489
  */
490
- renderWebGL(renderSession: any) {
490
+ override renderWebGL(renderSession: any) {
491
491
  // if the sprite is not visible or the alpha is 0 then no need to render this element
492
492
  if (this.visible === false || this.alpha === 0 || this.isMask === true) {
493
493
  return;
@@ -547,7 +547,7 @@ export class Graphics extends DisplayObject {
547
547
  * Renders the graphics object using Canvas.
548
548
  * @param {object} renderSession - The render session to use.
549
549
  */
550
- renderCanvas(renderSession: any) {
550
+ override renderCanvas(renderSession: any) {
551
551
  // if the sprite is not visible or the alpha is 0 then no need to render this element
552
552
  if (this.visible === false || this.alpha === 0 || this.isMask === true) {
553
553
  return;
@@ -604,7 +604,7 @@ export class Graphics extends DisplayObject {
604
604
  * @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
605
605
  * @returns {Rectangle} The bounds rectangle of the graphics object.
606
606
  */
607
- getBounds(matrix: import('../geom/matrix.js').Matrix = null) {
607
+ override getBounds(matrix: import('../geom/matrix.js').Matrix | null = null) {
608
608
  if (!this.renderable) {
609
609
  return getEmptyRectangle();
610
610
  }
@@ -664,7 +664,7 @@ export class Graphics extends DisplayObject {
664
664
  * Gets the local bounds of the graphics object.
665
665
  * @returns {Rectangle} The local bounds rectangle of the graphics object.
666
666
  */
667
- getLocalBounds() {
667
+ override getLocalBounds() {
668
668
  const matrixCache = this.worldTransform;
669
669
  this.worldTransform = getIdentityMatrix();
670
670
  for (let i = 0; i < this.children.length; i += 1) {
@@ -782,7 +782,7 @@ export class Graphics extends DisplayObject {
782
782
  /**
783
783
  * Generates a cached sprite representation of the graphics object.
784
784
  */
785
- generateCachedSprite() {
785
+ override generateCachedSprite() {
786
786
  const bounds = this.getLocalBounds();
787
787
  if (!this._cachedSprite) {
788
788
  const canvasBuffer = new CanvasBuffer(bounds.width, bounds.height);
@@ -827,7 +827,7 @@ export class Graphics extends DisplayObject {
827
827
  /**
828
828
  * Destroys the cached sprite.
829
829
  */
830
- destroyCachedSprite() {
830
+ override destroyCachedSprite() {
831
831
  if (!this._cachedSprite) {
832
832
  return;
833
833
  }
@@ -875,7 +875,7 @@ export class Graphics extends DisplayObject {
875
875
  /**
876
876
  * Performs post-update operations for the graphics object.
877
877
  */
878
- postUpdate() {
878
+ override postUpdate() {
879
879
  if (this._boundsDirty) {
880
880
  this.updateLocalBounds();
881
881
  this._boundsDirty = false;
@@ -30,8 +30,8 @@ export class Group extends DisplayObject {
30
30
  */
31
31
  constructor(
32
32
  game: import('../core/game.js').Game,
33
- parent: DisplayObject = null,
34
- name: string = null,
33
+ parent: DisplayObject | null = null,
34
+ name: string | null = null,
35
35
  addToStage: boolean = false
36
36
  ) {
37
37
  super(game);
@@ -80,7 +80,7 @@ export class Group extends DisplayObject {
80
80
  * @param {boolean} destroyChildren - Whether to destroy children as well.
81
81
  * @param {boolean} soft - Whether to perform a soft destroy (leaving the group in the parent's children list).
82
82
  */
83
- destroy(destroyChildren: boolean = true, soft: boolean = false) {
83
+ override destroy(destroyChildren: boolean = true, soft: boolean = false) {
84
84
  if (this.game === null || this.ignoreDestroy) {
85
85
  return;
86
86
  }
@@ -93,7 +93,7 @@ export class Group extends DisplayObject {
93
93
  if (this.parent) {
94
94
  this.parent.removeChild(this);
95
95
  }
96
- this.game = null;
96
+ this.game = null!;
97
97
  this.exists = false;
98
98
  }
99
99
  }
@@ -253,12 +253,12 @@ export class Group extends DisplayObject {
253
253
  /**
254
254
  * Updates the Z indices of all children in this group before the update cycle.
255
255
  */
256
- preUpdate() {
256
+ override preUpdate() {
257
257
  if (this.pendingDestroy) {
258
258
  this.destroy();
259
259
  return;
260
260
  }
261
- if (!this.exists || !this.parent.exists) {
261
+ if (!this.exists || !this.parent?.exists) {
262
262
  this.renderOrderID = -1;
263
263
  return;
264
264
  }
@@ -270,7 +270,7 @@ export class Group extends DisplayObject {
270
270
  /**
271
271
  * Updates all children in this group during the update cycle.
272
272
  */
273
- update() {
273
+ override update() {
274
274
  let i = this.children.length;
275
275
  while (i) {
276
276
  i -= 1;
@@ -281,7 +281,7 @@ export class Group extends DisplayObject {
281
281
  /**
282
282
  * Updates all children in this group after the update cycle.
283
283
  */
284
- postUpdate() {
284
+ override postUpdate() {
285
285
  for (let i = 0; i < this.children.length; i += 1) {
286
286
  this.children[i].postUpdate();
287
287
  }