@vpmedia/phaser 1.106.0 → 1.107.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
@@ -39,8 +39,8 @@ export class Image extends DisplayObject {
39
39
  game: import('../core/game.js').Game,
40
40
  x: number,
41
41
  y: number,
42
- key: string | number | Texture,
43
- frame: string | number = 0
42
+ key: string | number | Texture | null,
43
+ frame: string | number | null = 0
44
44
  ) {
45
45
  super(game);
46
46
  /** @type {number} */
@@ -84,11 +84,11 @@ export class Image extends DisplayObject {
84
84
  /**
85
85
  * Destroys this image and cleans up resources.
86
86
  */
87
- destroy() {
88
- this.game = null;
87
+ override destroy() {
88
+ this.game = null!;
89
89
  this.key = null;
90
90
  this.data = null;
91
- this.texture = null;
91
+ this.texture = null!;
92
92
  this.tint = 0xff_ff_ff;
93
93
  this.cachedTint = -1;
94
94
  this.tintedTexture = null;
@@ -97,23 +97,23 @@ export class Image extends DisplayObject {
97
97
  if (this.events) {
98
98
  this.events.destroy();
99
99
  }
100
- this.events = null;
100
+ this.events = null!;
101
101
  if (this.animations) {
102
102
  this.animations.destroy();
103
103
  }
104
- this.animations = null;
104
+ this.animations = null!;
105
105
  super.destroy();
106
106
  }
107
107
 
108
108
  /**
109
109
  * Called before the update cycle for this image.
110
110
  */
111
- preUpdate() {
111
+ override preUpdate() {
112
112
  if (this.pendingDestroy) {
113
113
  this.destroy();
114
114
  return;
115
115
  }
116
- if (!this.exists || !this.parent.exists) {
116
+ if (!this.exists || !this.parent?.exists) {
117
117
  this.renderOrderID = -1;
118
118
  return;
119
119
  }
@@ -137,9 +137,9 @@ export class Image extends DisplayObject {
137
137
  * @param {string | number | null | undefined} frame - The frame identifier (name or index) to use.
138
138
  * @param {boolean} stopAnimation - Whether to stop the animation when changing textures.
139
139
  */
140
- loadTexture(key: string | number | Texture, frame: string | number | null = 0, stopAnimation: boolean = true) {
140
+ loadTexture(key: string | number | Texture | null, frame: string | number | null = 0, stopAnimation: boolean = true) {
141
141
  if (key === PENDING_ATLAS) {
142
- key = frame;
142
+ key = frame ?? 0;
143
143
  frame = 0;
144
144
  } else {
145
145
  frame = frame || 0;
@@ -222,11 +222,11 @@ export class Image extends DisplayObject {
222
222
 
223
223
  /**
224
224
  * Resizes the frame of this image.
225
- * @param {DisplayObject} parent - The parent display object.
225
+ * @param {DisplayObject} _parent - The parent display object.
226
226
  * @param {number} width - The new width of the frame.
227
227
  * @param {number} height - The new height of the frame.
228
228
  */
229
- resizeFrame(parent: DisplayObject, width: number, height: number) {
229
+ resizeFrame(_parent: DisplayObject, width: number, height: number) {
230
230
  this.texture.frame.resize(width, height);
231
231
  this.texture.setFrame(this.texture.frame);
232
232
  }
@@ -332,7 +332,7 @@ export class Image extends DisplayObject {
332
332
  * Gets the width of this image.
333
333
  * @returns {number} The width in pixels.
334
334
  */
335
- get width() {
335
+ override get width() {
336
336
  return this.scale.x * this.texture.frame.width;
337
337
  }
338
338
 
@@ -340,7 +340,7 @@ export class Image extends DisplayObject {
340
340
  * Sets the width of this image.
341
341
  * @param {number} value - The new width in pixels.
342
342
  */
343
- set width(value: number) {
343
+ override set width(value: number) {
344
344
  this.scale.x = value / this.texture.frame.width;
345
345
  this._width = value;
346
346
  }
@@ -349,7 +349,7 @@ export class Image extends DisplayObject {
349
349
  * Gets the height of this image.
350
350
  * @returns {number} The height in pixels.
351
351
  */
352
- get height() {
352
+ override get height() {
353
353
  return this.scale.y * this.texture.frame.height;
354
354
  }
355
355
 
@@ -357,7 +357,7 @@ export class Image extends DisplayObject {
357
357
  * Sets the height of this image.
358
358
  * @param {number} value - The new height in pixels.
359
359
  */
360
- set height(value: number) {
360
+ override set height(value: number) {
361
361
  this.scale.y = value / this.texture.frame.height;
362
362
  this._height = value;
363
363
  }
@@ -389,7 +389,7 @@ export class Image extends DisplayObject {
389
389
  * @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
390
390
  * @returns {Rectangle} The bounds rectangle of this image.
391
391
  */
392
- getBounds(matrix: import('../geom/matrix.js').Matrix = null) {
392
+ override getBounds(matrix: import('../geom/matrix.js').Matrix | null = null) {
393
393
  return getBounds(this, matrix);
394
394
  }
395
395
 
@@ -397,7 +397,7 @@ export class Image extends DisplayObject {
397
397
  * Gets the local bounds of this image.
398
398
  * @returns {Rectangle} The local bounds rectangle of this image.
399
399
  */
400
- getLocalBounds() {
400
+ override getLocalBounds() {
401
401
  return getLocalBounds(this);
402
402
  }
403
403
 
@@ -406,7 +406,7 @@ export class Image extends DisplayObject {
406
406
  * @param {object} renderSession - The WebGL rendering session.
407
407
  * @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
408
408
  */
409
- renderWebGL(renderSession: any, matrix: import('../geom/matrix.js').Matrix = null) {
409
+ override renderWebGL(renderSession: any, matrix: import('../geom/matrix.js').Matrix | null = null) {
410
410
  renderWebGL(this, renderSession, matrix);
411
411
  }
412
412
 
@@ -415,7 +415,7 @@ export class Image extends DisplayObject {
415
415
  * @param {object} renderSession - The Canvas rendering session.
416
416
  * @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
417
417
  */
418
- renderCanvas(renderSession: any, matrix: import('../geom/matrix.js').Matrix = null) {
418
+ override renderCanvas(renderSession: any, matrix: import('../geom/matrix.js').Matrix | null = null) {
419
419
  renderCanvas(this, renderSession, matrix);
420
420
  }
421
421
  }
@@ -28,7 +28,7 @@ export const setTexture = (
28
28
  * @param {object} matrix - The transformation matrix.
29
29
  * @returns {import('../geom/rectangle.js').Rectangle} The bounds rectangle.
30
30
  */
31
- export const getBounds = (target: import('./image.js').Image, matrix: any = null) => {
31
+ export const getBounds = (target: import('./image.js').Image, matrix: any | null = null) => {
32
32
  // TODO verify
33
33
  if (target.currentBounds) {
34
34
  return target.currentBounds;
@@ -77,7 +77,7 @@ export class Text extends Image {
77
77
  /**
78
78
  * Destroys this text object and cleans up resources.
79
79
  */
80
- destroy() {
80
+ override destroy() {
81
81
  this.texture.destroy(true);
82
82
  remove(this);
83
83
  this.canvas = null;
@@ -128,7 +128,7 @@ export class Text extends Image {
128
128
  * @param {boolean} update - Whether to update the text immediately.
129
129
  * @returns {Text} This Text object for chaining.
130
130
  */
131
- setStyle(style: any = null, update: boolean = false) {
131
+ setStyle(style: any | null = null, update: boolean = false) {
132
132
  style = JSON.parse(JSON.stringify(style)) || {};
133
133
  style.font = style.font || 'bold 20pt Arial';
134
134
  style.backgroundColor = style.backgroundColor || null;
@@ -878,7 +878,7 @@ export class Text extends Image {
878
878
  * Renders this text object using WebGL.
879
879
  * @param {object} renderSession - The render session to use.
880
880
  */
881
- renderWebGL(renderSession: any) {
881
+ override renderWebGL(renderSession: any) {
882
882
  if (this.dirty) {
883
883
  this.updateText();
884
884
  this.dirty = false;
@@ -890,7 +890,7 @@ export class Text extends Image {
890
890
  * Renders this text object using Canvas.
891
891
  * @param {object} renderSession - The render session to use.
892
892
  */
893
- renderCanvas(renderSession: any) {
893
+ override renderCanvas(renderSession: any) {
894
894
  if (this.dirty) {
895
895
  this.updateText();
896
896
  this.dirty = false;
@@ -1044,7 +1044,7 @@ export class Text extends Image {
1044
1044
  * @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
1045
1045
  * @returns {Rectangle} The bounds of this text object.
1046
1046
  */
1047
- getBounds(matrix: import('../geom/matrix.js').Matrix = null) {
1047
+ override getBounds(matrix: import('../geom/matrix.js').Matrix | null = null) {
1048
1048
  if (this.dirty) {
1049
1049
  this.updateText();
1050
1050
  this.dirty = false;
@@ -1521,7 +1521,7 @@ export class Text extends Image {
1521
1521
  * Gets the width of this object.
1522
1522
  * @returns {number} The width in pixels.
1523
1523
  */
1524
- get width() {
1524
+ override get width() {
1525
1525
  if (this.dirty) {
1526
1526
  this.updateText();
1527
1527
  this.dirty = false;
@@ -1533,7 +1533,7 @@ export class Text extends Image {
1533
1533
  * Sets the width of this object.
1534
1534
  * @param {number} value - The new width to set in pixels.
1535
1535
  */
1536
- set width(value: number) {
1536
+ override set width(value: number) {
1537
1537
  this.scale.x = value / this.texture.frame.width;
1538
1538
  this._width = value;
1539
1539
  }
@@ -1542,7 +1542,7 @@ export class Text extends Image {
1542
1542
  * Gets the height of this object.
1543
1543
  * @returns {number} The height in pixels.
1544
1544
  */
1545
- get height() {
1545
+ override get height() {
1546
1546
  if (this.dirty) {
1547
1547
  this.updateText();
1548
1548
  this.dirty = false;
@@ -1554,7 +1554,7 @@ export class Text extends Image {
1554
1554
  * Sets the height of this object.
1555
1555
  * @param {number} value - The new height to set in pixels.
1556
1556
  */
1557
- set height(value: number) {
1557
+ override set height(value: number) {
1558
1558
  this.scale.y = value / this.texture.frame.height;
1559
1559
  this._height = value;
1560
1560
  }
@@ -107,7 +107,7 @@ export function zOrder(x: number, y: number, minX: number, minY: number, size: n
107
107
  * @param {number} minY - The minimum y-coordinate of the bounding box.
108
108
  * @param {number} size - The size of the bounding box.
109
109
  */
110
- export function indexCurve(start: any, minX: number, minY: number, size: number) {
110
+ export function indexCurve(start: any, minX: number = 0, minY: number = 0, size: number = 0) {
111
111
  let p = start;
112
112
  do {
113
113
  if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size);
@@ -348,7 +348,7 @@ export function isEar(ear: any) {
348
348
  * @param {number} size - TBD.
349
349
  * @returns {boolean} TBD.
350
350
  */
351
- export function isEarHashed(ear: any, minX: number, minY: number, size: number) {
351
+ export function isEarHashed(ear: any, minX: number = 0, minY: number = 0, size: number = 0) {
352
352
  const a = ear.prev;
353
353
  const b = ear;
354
354
  const c = ear.next;
@@ -526,6 +526,7 @@ export function eliminateHoles(data: any, holeIndices: any, outerNode: any, dim:
526
526
  start = holeIndices[i] * dim;
527
527
  end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
528
528
  list = linkedList(data, start, end, dim, false);
529
+ if (!list) continue;
529
530
  if (list === list.next) list.steiner = true;
530
531
  queue.push(getLeftmost(list));
531
532
  }
@@ -575,7 +576,14 @@ export function cureLocalIntersections(start: any, triangles: any, dim: number)
575
576
  * @param {number} minY - The minimum y-coordinate of the bounding box.
576
577
  * @param {number} size - The size of the bounding box.
577
578
  */
578
- export function splitEarcut(start: any, triangles: any, dim: number, minX: number, minY: number, size: number) {
579
+ export function splitEarcut(
580
+ start: any,
581
+ triangles: any,
582
+ dim: number,
583
+ minX: number = 0,
584
+ minY: number = 0,
585
+ size: number = 0
586
+ ) {
579
587
  // look for a valid diagonal that divides the polygon into two
580
588
  let a = start;
581
589
  do {
@@ -669,7 +677,7 @@ export function triangulate(data: any, holeIndices: any, dim: number) {
669
677
  const hasHoles = holeIndices && holeIndices.length;
670
678
  const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
671
679
  let outerNode = linkedList(data, 0, outerLen, dim, true);
672
- const triangles = [];
680
+ const triangles: number[] = [];
673
681
  if (!outerNode) return triangles;
674
682
  let minX;
675
683
  let minY;
@@ -1,3 +1,5 @@
1
+ import type { IdentifiedWebGLRenderingContext } from './util.js';
2
+
1
3
  export class FastSpriteBatch {
2
4
  [key: string]: any;
3
5
  vertSize!: any;
@@ -19,7 +21,7 @@ export class FastSpriteBatch {
19
21
  * Creates a new FastSpriteBatch instance.
20
22
  * @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
21
23
  */
22
- constructor(gl) {
24
+ constructor(gl: IdentifiedWebGLRenderingContext) {
23
25
  this.vertSize = 10;
24
26
  this.maxSize = 6000; // Math.pow(2, 16) / this.vertSize;
25
27
  this.size = this.maxSize;
@@ -54,7 +56,7 @@ export class FastSpriteBatch {
54
56
  * Sets the WebGL context for this batch.
55
57
  * @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
56
58
  */
57
- setContext(gl) {
59
+ setContext(gl: IdentifiedWebGLRenderingContext) {
58
60
  this.gl = gl;
59
61
  // create a couple of buffers
60
62
  this.vertexBuffer = gl.createBuffer();
@@ -3,6 +3,7 @@ import { Point } from '../../geom/point.js';
3
3
  import { hex2rgb } from '../../util/math.js';
4
4
  import { triangulate } from './earcut.js';
5
5
  import { GraphicsData } from './graphics_data.js';
6
+ import type { IdentifiedWebGLRenderingContext } from './util.js';
6
7
 
7
8
  /**
8
9
  * Updates the graphics data for WebGL rendering.
@@ -285,7 +286,7 @@ export const quadraticBezierCurve = (
285
286
  let y;
286
287
  const n = 20;
287
288
  const points = [];
288
- const getPt = (n1, n2, perc) => {
289
+ const getPt = (n1: number, n2: number, perc: number) => {
289
290
  const diff = n2 - n1;
290
291
  return n1 + diff * perc;
291
292
  };
@@ -494,7 +495,7 @@ export const buildPoly = (graphicsData: any, webGLData: GraphicsData) => {
494
495
  * @param {import('../graphics.js').Graphics} graphics - The graphics object to update.
495
496
  * @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
496
497
  */
497
- export const updateGraphics = (graphics: import('../graphics.js').Graphics, gl) => {
498
+ export const updateGraphics = (graphics: import('../graphics.js').Graphics, gl: IdentifiedWebGLRenderingContext) => {
498
499
  const stencilBufferLimit = getStencilBufferLimit();
499
500
  // get the contexts graphics object
500
501
  let webGL = graphics._webGL[gl.id];
@@ -110,14 +110,14 @@ export class RenderTexture extends Texture {
110
110
  * @returns {string} The base64 string representation.
111
111
  */
112
112
  getBase64() {
113
- return this.getCanvas().toDataURL();
113
+ return this.getCanvas()?.toDataURL() ?? '';
114
114
  }
115
115
 
116
116
  /**
117
117
  * Gets the canvas element for this render texture.
118
118
  * @returns {HTMLCanvasElement} The canvas element.
119
119
  */
120
- getCanvas() {
120
+ getCanvas(): HTMLCanvasElement | null {
121
121
  // TODO
122
122
  return null;
123
123
  }
@@ -39,7 +39,7 @@ export class NormalShader {
39
39
  * Creates a new NormalShader instance.
40
40
  * @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
41
41
  */
42
- constructor(gl) {
42
+ constructor(gl: WebGLRenderingContext) {
43
43
  this.gl = gl;
44
44
  this._UID = uuidv4();
45
45
  /** @type {WebGLProgram} */
@@ -3,6 +3,7 @@ import { FastShader } from './shader/fast.js';
3
3
  import { NormalShader } from './shader/normal.js';
4
4
  import { PrimitiveShader } from './shader/primitive.js';
5
5
  import { StripShader } from './shader/strip.js';
6
+ import type { IdentifiedWebGLRenderingContext } from './util.js';
6
7
 
7
8
  export class WebGLShaderManager {
8
9
  [key: string]: any;
@@ -39,7 +40,7 @@ export class WebGLShaderManager {
39
40
  * Initializes the shader manager with a WebGL context.
40
41
  * @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
41
42
  */
42
- setContext(gl) {
43
+ setContext(gl: IdentifiedWebGLRenderingContext) {
43
44
  this.gl = gl;
44
45
  this.primitiveShader = new PrimitiveShader(gl);
45
46
  this.complexPrimitiveShader = new ComplexPrimitiveShader(gl);
@@ -1,5 +1,6 @@
1
1
  import { AbstractFilter } from './abstract_filter.js';
2
2
  import { NormalShader } from './shader/normal.js';
3
+ import type { IdentifiedWebGLRenderingContext } from './util.js';
3
4
 
4
5
  export class WebGLSpriteBatch {
5
6
  [key: string]: any;
@@ -65,7 +66,7 @@ export class WebGLSpriteBatch {
65
66
  * Renders a sprite using WebGL.
66
67
  * @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
67
68
  */
68
- setContext(gl) {
69
+ setContext(gl: IdentifiedWebGLRenderingContext) {
69
70
  this.gl = gl;
70
71
  // create a couple of buffers
71
72
  this.vertexBuffer = gl.createBuffer();
@@ -1,3 +1,6 @@
1
+ /** WebGL context tagged with the per-context id the renderer assigns, used to key shader caches. */
2
+ export type IdentifiedWebGLRenderingContext = WebGLRenderingContext & { id: number };
3
+
1
4
  // No error has been recorded. The value of this constant is 0.
2
5
  export const NO_ERROR = 0;
3
6
  // An unacceptable value has been specified for an enumerated argument. The command is ignored and the error flag is set.
@@ -63,6 +66,9 @@ export const initDefaultShaders = () => {};
63
66
  export const compileShader = (gl: WebGLRenderingContext, shaderSrc: string[] | string, shaderType: any) => {
64
67
  const src = Array.isArray(shaderSrc) ? shaderSrc.join('\n') : shaderSrc;
65
68
  const shader = gl.createShader(shaderType);
69
+ if (!shader) {
70
+ return null;
71
+ }
66
72
  gl.shaderSource(shader, src);
67
73
  gl.compileShader(shader);
68
74
  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
@@ -112,6 +118,9 @@ export const compileProgram = (
112
118
 
113
119
  const shaderProgram = gl.createProgram();
114
120
 
121
+ if (!shaderProgram || !vertexShader || !fragmentShader) {
122
+ return null;
123
+ }
115
124
  gl.attachShader(shaderProgram, vertexShader);
116
125
  gl.attachShader(shaderProgram, fragmentShader);
117
126
  gl.linkProgram(shaderProgram);
@@ -46,7 +46,7 @@ export class Circle {
46
46
  * @param {Point} output - The point to store the result in (optional).
47
47
  * @returns {Point} A random point within this circle.
48
48
  */
49
- random(output: Point = null) {
49
+ random(output: Point | null = null) {
50
50
  const result = output || new Point();
51
51
  const t = 2 * Math.PI * Math.random();
52
52
  const u = Math.random() + Math.random();
@@ -91,7 +91,7 @@ export class Ellipse {
91
91
  * @param {Point} output - The point to store the result in (optional).
92
92
  * @returns {Point} A random point within this ellipse.
93
93
  */
94
- random(output: Point = null) {
94
+ random(output: Point | null = null) {
95
95
  const result = output || new Point();
96
96
  const p = Math.random() * Math.PI * 2;
97
97
  const r = Math.random();
@@ -119,7 +119,7 @@ export class Line {
119
119
  * @param {Point} output - The point to store the result in (optional).
120
120
  * @returns {Point} The midpoint of this line.
121
121
  */
122
- midPoint(output: Point = null) {
122
+ midPoint(output: Point | null = null) {
123
123
  const result = output || new Point();
124
124
  result.x = (this.start.x + this.end.x) / 2;
125
125
  result.y = (this.start.y + this.end.y) / 2;
@@ -169,7 +169,7 @@ export class Line {
169
169
  * @param {Point} output - The point to store the result in (optional).
170
170
  * @returns {Point} A random point on this line.
171
171
  */
172
- random(output: Point = null) {
172
+ random(output: Point | null = null) {
173
173
  const result = output || new Point();
174
174
  const t = Math.random();
175
175
  result.x = this.start.x + t * (this.end.x - this.start.x);
@@ -105,7 +105,7 @@ export class Matrix {
105
105
  * @param {Float32Array} output - The array to store the result in (optional).
106
106
  * @returns {Float32Array} A Float32Array containing the matrix elements.
107
107
  */
108
- toArray(transpose: boolean = false, output: Float32Array = null) {
108
+ toArray(transpose: boolean = false, output: Float32Array | null = null) {
109
109
  const result = output || new Float32Array(9);
110
110
  if (transpose) {
111
111
  result[0] = this.a;
@@ -137,7 +137,7 @@ export class Matrix {
137
137
  * @param {Point} output - The point to store the result in (optional).
138
138
  * @returns {Point} The transformed point.
139
139
  */
140
- apply(pos: Point, output: Point = null) {
140
+ apply(pos: Point, output: Point | null = null) {
141
141
  const result = output || new Point();
142
142
  result.x = this.a * pos.x + this.c * pos.y + this.tx;
143
143
  result.y = this.b * pos.x + this.d * pos.y + this.ty;
@@ -150,7 +150,7 @@ export class Matrix {
150
150
  * @param {Point} output - The point to store the result in (optional).
151
151
  * @returns {Point} The transformed point.
152
152
  */
153
- applyInverse(pos: Point, output: Point = null) {
153
+ applyInverse(pos: Point, output: Point | null = null) {
154
154
  const result = output || new Point();
155
155
  const id = 1 / (this.a * this.d + this.c * -this.b);
156
156
  const x = pos.x;
@@ -13,7 +13,7 @@ export class Polygon {
13
13
  * Creates a new Polygon instance.
14
14
  * @param {object[]} points - The array of points to define the polygon (optional).
15
15
  */
16
- constructor(points: any[] = null) {
16
+ constructor(points: any[] | null = null) {
17
17
  /** @type {number} */
18
18
  this.area = 0;
19
19
  /** @type {Point[]} */
@@ -288,7 +288,7 @@ export class Rectangle {
288
288
  * @param {Point} output - The point to store the result in (optional).
289
289
  * @returns {Point} A random point within this rectangle.
290
290
  */
291
- random(output: Point = null) {
291
+ random(output: Point | null = null) {
292
292
  const result = output || new Point();
293
293
  result.x = this.randomX;
294
294
  result.y = this.randomY;
@@ -301,7 +301,7 @@ export class Rectangle {
301
301
  * @param {Point} output - The point to store the result in (optional).
302
302
  * @returns {Point} A point at the specified position on the rectangle.
303
303
  */
304
- getPoint(position: number, output: Point = null) {
304
+ getPoint(position: number, output: Point | null = null) {
305
305
  const result = output || new Point();
306
306
  switch (position) {
307
307
  case TOP_LEFT:
@@ -8,7 +8,7 @@ import { Point } from '../point.js';
8
8
  * @param {Circle} output - Optional circle to store the result in.
9
9
  * @returns {Circle} The cloned circle.
10
10
  */
11
- export const clone = (input: Circle, output: Circle = null) => {
11
+ export const clone = (input: Circle, output: Circle | null = null) => {
12
12
  const result = output || new Circle();
13
13
  result.x = input.x;
14
14
  result.y = input.y;
@@ -60,7 +60,12 @@ export const intersects = (a: Circle, b: Circle) => {
60
60
  * @param {Point} output - Optional point to store the result in.
61
61
  * @returns {Point} The point on the circumference of the circle.
62
62
  */
63
- export const circumferencePoint = (a: Circle, angle: number, asDegrees: boolean = false, output: Point = null) => {
63
+ export const circumferencePoint = (
64
+ a: Circle,
65
+ angle: number,
66
+ asDegrees: boolean = false,
67
+ output: Point | null = null
68
+ ) => {
64
69
  const result = output || new Point();
65
70
  if (asDegrees === true) {
66
71
  angle = degToRad(angle);
@@ -78,7 +83,7 @@ export const circumferencePoint = (a: Circle, angle: number, asDegrees: boolean
78
83
  * @param {Point} output - Optional point to store the result in.
79
84
  * @returns {Point} The point on the circumference of the circle.
80
85
  */
81
- export const intersectsPoint = (a: Circle, angle: number, asDegrees: boolean = false, output: Point = null) => {
86
+ export const intersectsPoint = (a: Circle, angle: number, asDegrees: boolean = false, output: Point | null = null) => {
82
87
  const result = output || new Point();
83
88
  if (asDegrees === true) {
84
89
  angle = degToRad(angle);
@@ -8,7 +8,7 @@ import { intersects as intersectsRect } from './rectangle.js';
8
8
  * @param {Line} output - Optional line to store the result in.
9
9
  * @returns {Line} The cloned line.
10
10
  */
11
- export const clone = (input: Line, output: Line = null) => {
11
+ export const clone = (input: Line, output: Line | null = null) => {
12
12
  const result = output || new Line();
13
13
  result.start.x = input.start.x;
14
14
  result.start.y = input.start.y;
@@ -27,7 +27,14 @@ export const clone = (input: Line, output: Line = null) => {
27
27
  * @param {Point} output - Optional point to store the result in.
28
28
  * @returns {Point} The intersection point, or null if there is no intersection.
29
29
  */
30
- export const intersectsPoints = (a: any, b: any, e: any, f: any, asSegment: boolean = true, output: Point = null) => {
30
+ export const intersectsPoints = (
31
+ a: any,
32
+ b: any,
33
+ e: any,
34
+ f: any,
35
+ asSegment: boolean = true,
36
+ output: Point | null = null
37
+ ) => {
31
38
  const result = output || new Point();
32
39
  const a1 = b.y - a.y;
33
40
  const a2 = f.y - e.y;
@@ -6,7 +6,7 @@ import { Matrix } from '../matrix.js';
6
6
  * @param {Matrix} output - Optional matrix to store the result in.
7
7
  * @returns {Matrix} The cloned matrix.
8
8
  */
9
- export const clone = (input: Matrix, output: Matrix = null) => {
9
+ export const clone = (input: Matrix, output: Matrix | null = null) => {
10
10
  const result = output || new Matrix();
11
11
  result.a = input.a;
12
12
  result.b = input.b;