@vpmedia/phaser 1.105.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 (236) hide show
  1. package/dist/index.d.ts +5 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +238 -244
  4. package/dist/index.js.map +1 -1
  5. package/dist/phaser/core/animation.d.ts +2 -2
  6. package/dist/phaser/core/animation.d.ts.map +1 -1
  7. package/dist/phaser/core/animation_manager.d.ts +2 -2
  8. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  9. package/dist/phaser/core/animation_parser.d.ts +2 -2
  10. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  11. package/dist/phaser/core/array_set.d.ts.map +1 -1
  12. package/dist/phaser/core/cache.d.ts +6 -6
  13. package/dist/phaser/core/cache.d.ts.map +1 -1
  14. package/dist/phaser/core/device.d.ts.map +1 -1
  15. package/dist/phaser/core/device_util.d.ts.map +1 -1
  16. package/dist/phaser/core/dom.d.ts +2 -2
  17. package/dist/phaser/core/dom.d.ts.map +1 -1
  18. package/dist/phaser/core/event_manager.d.ts.map +1 -1
  19. package/dist/phaser/core/factory.d.ts +1 -1
  20. package/dist/phaser/core/factory.d.ts.map +1 -1
  21. package/dist/phaser/core/frame.d.ts.map +1 -1
  22. package/dist/phaser/core/frame_data.d.ts.map +1 -1
  23. package/dist/phaser/core/frame_util.d.ts.map +1 -1
  24. package/dist/phaser/core/game.d.ts +1 -1
  25. package/dist/phaser/core/game.d.ts.map +1 -1
  26. package/dist/phaser/core/input.d.ts +3 -3
  27. package/dist/phaser/core/input.d.ts.map +1 -1
  28. package/dist/phaser/core/input_handler.d.ts +8 -8
  29. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  30. package/dist/phaser/core/input_mouse.d.ts +8 -8
  31. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  32. package/dist/phaser/core/input_mspointer.d.ts +6 -6
  33. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  34. package/dist/phaser/core/input_pointer.d.ts +3 -3
  35. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  36. package/dist/phaser/core/input_touch.d.ts +7 -7
  37. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  38. package/dist/phaser/core/loader.d.ts +16 -6
  39. package/dist/phaser/core/loader.d.ts.map +1 -1
  40. package/dist/phaser/core/loader_parser.d.ts +4 -4
  41. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  42. package/dist/phaser/core/raf.d.ts.map +1 -1
  43. package/dist/phaser/core/scale_manager.d.ts +5 -5
  44. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  45. package/dist/phaser/core/scene.d.ts +3 -3
  46. package/dist/phaser/core/scene.d.ts.map +1 -1
  47. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  48. package/dist/phaser/core/signal.d.ts +7 -7
  49. package/dist/phaser/core/signal.d.ts.map +1 -1
  50. package/dist/phaser/core/signal_binding.d.ts +1 -1
  51. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  52. package/dist/phaser/core/sound.d.ts +3 -3
  53. package/dist/phaser/core/sound.d.ts.map +1 -1
  54. package/dist/phaser/core/sound_manager.d.ts +1 -1
  55. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  56. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  57. package/dist/phaser/core/stage.d.ts.map +1 -1
  58. package/dist/phaser/core/time.d.ts.map +1 -1
  59. package/dist/phaser/core/timer.d.ts +5 -5
  60. package/dist/phaser/core/timer.d.ts.map +1 -1
  61. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  62. package/dist/phaser/core/tween.d.ts +1 -1
  63. package/dist/phaser/core/tween.d.ts.map +1 -1
  64. package/dist/phaser/core/tween_data.d.ts +1 -1
  65. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  66. package/dist/phaser/core/tween_easing.d.ts.map +1 -1
  67. package/dist/phaser/core/tween_manager.d.ts +1 -1
  68. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  69. package/dist/phaser/core/world.d.ts.map +1 -1
  70. package/dist/phaser/display/bitmap_text.d.ts +3 -3
  71. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  72. package/dist/phaser/display/button.d.ts +12 -11
  73. package/dist/phaser/display/button.d.ts.map +1 -1
  74. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  75. package/dist/phaser/display/canvas/graphics.d.ts +3 -3
  76. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  77. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  78. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  79. package/dist/phaser/display/canvas/renderer.d.ts +2 -2
  80. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  81. package/dist/phaser/display/canvas/tinter.d.ts +1 -1
  82. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  83. package/dist/phaser/display/canvas/util.d.ts +1 -1
  84. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  85. package/dist/phaser/display/display_object.d.ts +12 -21
  86. package/dist/phaser/display/display_object.d.ts.map +1 -1
  87. package/dist/phaser/display/graphics.d.ts +1 -1
  88. package/dist/phaser/display/graphics.d.ts.map +1 -1
  89. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  90. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  91. package/dist/phaser/display/group.d.ts +3 -3
  92. package/dist/phaser/display/group.d.ts.map +1 -1
  93. package/dist/phaser/display/image.d.ts +8 -8
  94. package/dist/phaser/display/image.d.ts.map +1 -1
  95. package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
  96. package/dist/phaser/display/sprite_util.d.ts +5 -5
  97. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  98. package/dist/phaser/display/text.d.ts +8 -7
  99. package/dist/phaser/display/text.d.ts.map +1 -1
  100. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  101. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  102. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  103. package/dist/phaser/display/webgl/earcut.d.ts +5 -5
  104. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  105. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  106. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +3 -2
  107. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  108. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  109. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  110. package/dist/phaser/display/webgl/graphics.d.ts +4 -3
  111. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  112. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  113. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  114. package/dist/phaser/display/webgl/render_texture.d.ts +2 -2
  115. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  116. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  117. package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  118. package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  119. package/dist/phaser/display/webgl/shader/normal.d.ts +1 -1
  120. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  121. package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  122. package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  123. package/dist/phaser/display/webgl/shader_manager.d.ts +2 -1
  124. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  125. package/dist/phaser/display/webgl/sprite_batch.d.ts +2 -1
  126. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  127. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  128. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  129. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  130. package/dist/phaser/display/webgl/util.d.ts +8 -4
  131. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  132. package/dist/phaser/geom/circle.d.ts +1 -1
  133. package/dist/phaser/geom/circle.d.ts.map +1 -1
  134. package/dist/phaser/geom/ellipse.d.ts +1 -1
  135. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  136. package/dist/phaser/geom/line.d.ts +3 -3
  137. package/dist/phaser/geom/line.d.ts.map +1 -1
  138. package/dist/phaser/geom/matrix.d.ts +3 -3
  139. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  140. package/dist/phaser/geom/point.d.ts.map +1 -1
  141. package/dist/phaser/geom/polygon.d.ts +1 -1
  142. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  143. package/dist/phaser/geom/rectangle.d.ts +2 -2
  144. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  145. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  146. package/dist/phaser/geom/util/circle.d.ts +3 -3
  147. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  148. package/dist/phaser/geom/util/ellipse.d.ts +1 -1
  149. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  150. package/dist/phaser/geom/util/line.d.ts +3 -3
  151. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  152. package/dist/phaser/geom/util/matrix.d.ts +1 -1
  153. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  154. package/dist/phaser/geom/util/point.d.ts +15 -15
  155. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  156. package/dist/phaser/geom/util/polygon.d.ts +1 -1
  157. package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
  158. package/dist/phaser/geom/util/rectangle.d.ts +5 -5
  159. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  160. package/dist/phaser/geom/util/rounded_rectangle.d.ts +1 -1
  161. package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  162. package/dist/phaser/util/math.d.ts.map +1 -1
  163. package/package.json +15 -15
  164. package/src/index.ts +8 -0
  165. package/src/phaser/core/animation.ts +16 -8
  166. package/src/phaser/core/animation_manager.ts +11 -5
  167. package/src/phaser/core/cache.ts +9 -8
  168. package/src/phaser/core/device.ts +24 -24
  169. package/src/phaser/core/device_util.ts +4 -2
  170. package/src/phaser/core/dom.ts +2 -2
  171. package/src/phaser/core/factory.ts +3 -5
  172. package/src/phaser/core/game.ts +21 -34
  173. package/src/phaser/core/input.ts +9 -5
  174. package/src/phaser/core/input_handler.ts +22 -7
  175. package/src/phaser/core/input_mouse.ts +8 -84
  176. package/src/phaser/core/input_mspointer.ts +22 -18
  177. package/src/phaser/core/input_pointer.ts +48 -48
  178. package/src/phaser/core/input_touch.ts +7 -7
  179. package/src/phaser/core/loader.ts +46 -31
  180. package/src/phaser/core/loader_parser.ts +34 -8
  181. package/src/phaser/core/scale_manager.ts +5 -5
  182. package/src/phaser/core/scene.ts +5 -5
  183. package/src/phaser/core/signal.ts +15 -9
  184. package/src/phaser/core/signal_binding.ts +8 -1
  185. package/src/phaser/core/sound.ts +18 -21
  186. package/src/phaser/core/sound_manager.ts +3 -3
  187. package/src/phaser/core/sound_sprite.ts +7 -7
  188. package/src/phaser/core/stage.ts +6 -6
  189. package/src/phaser/core/time.ts +28 -28
  190. package/src/phaser/core/timer.ts +4 -4
  191. package/src/phaser/core/tween.ts +31 -9
  192. package/src/phaser/core/tween_data.ts +2 -2
  193. package/src/phaser/core/tween_manager.ts +7 -7
  194. package/src/phaser/display/bitmap_text.ts +6 -6
  195. package/src/phaser/display/button.ts +38 -19
  196. package/src/phaser/display/canvas/buffer.ts +4 -4
  197. package/src/phaser/display/canvas/renderer.ts +2 -2
  198. package/src/phaser/display/canvas/util.ts +21 -13
  199. package/src/phaser/display/display_object.ts +17 -31
  200. package/src/phaser/display/graphics.ts +9 -9
  201. package/src/phaser/display/graphics_data.ts +19 -11
  202. package/src/phaser/display/group.ts +8 -8
  203. package/src/phaser/display/image.ts +26 -20
  204. package/src/phaser/display/sprite_util.ts +16 -4
  205. package/src/phaser/display/text.ts +9 -9
  206. package/src/phaser/display/webgl/blend_manager.ts +2 -2
  207. package/src/phaser/display/webgl/earcut.ts +31 -6
  208. package/src/phaser/display/webgl/fast_sprite_batch.ts +19 -17
  209. package/src/phaser/display/webgl/filter_manager.ts +3 -3
  210. package/src/phaser/display/webgl/filter_texture.ts +4 -4
  211. package/src/phaser/display/webgl/graphics.ts +11 -3
  212. package/src/phaser/display/webgl/graphics_data.ts +9 -9
  213. package/src/phaser/display/webgl/render_texture.ts +9 -3
  214. package/src/phaser/display/webgl/shader/complex.ts +5 -5
  215. package/src/phaser/display/webgl/shader/fast.ts +6 -6
  216. package/src/phaser/display/webgl/shader/normal.ts +11 -11
  217. package/src/phaser/display/webgl/shader/primitive.ts +5 -5
  218. package/src/phaser/display/webgl/shader/strip.ts +5 -5
  219. package/src/phaser/display/webgl/shader_manager.ts +12 -11
  220. package/src/phaser/display/webgl/sprite_batch.ts +18 -17
  221. package/src/phaser/display/webgl/stencil_manager.ts +18 -6
  222. package/src/phaser/display/webgl/texture.ts +6 -1
  223. package/src/phaser/display/webgl/util.ts +17 -4
  224. package/src/phaser/geom/circle.ts +1 -1
  225. package/src/phaser/geom/ellipse.ts +1 -1
  226. package/src/phaser/geom/line.ts +2 -2
  227. package/src/phaser/geom/matrix.ts +3 -3
  228. package/src/phaser/geom/polygon.ts +1 -1
  229. package/src/phaser/geom/rectangle.ts +2 -2
  230. package/src/phaser/geom/util/circle.ts +8 -3
  231. package/src/phaser/geom/util/line.ts +9 -2
  232. package/src/phaser/geom/util/matrix.ts +1 -1
  233. package/src/phaser/geom/util/point.ts +23 -16
  234. package/src/phaser/geom/util/polygon.ts +1 -1
  235. package/src/phaser/geom/util/rectangle.ts +13 -6
  236. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
@@ -5,6 +5,17 @@ import { Signal } from './signal.js';
5
5
 
6
6
  const TEXTURE_ATLAS_JSON_HASH = 1;
7
7
 
8
+ /**
9
+ * Describes a file entry managed by the Loader.
10
+ */
11
+ export interface LoaderFile {
12
+ key: string;
13
+ type: string;
14
+ url: string;
15
+ error: boolean;
16
+ errorMessage: string;
17
+ }
18
+
8
19
  export class Loader {
9
20
  game!: any;
10
21
  cache!: any;
@@ -193,10 +204,10 @@ export class Loader {
193
204
  addToFileList(
194
205
  type: string,
195
206
  key: string = '',
196
- url: string = null,
197
- properties: any = null,
207
+ url: string | null = null,
208
+ properties: any | null = null,
198
209
  overwrite: boolean = false,
199
- extension: string = null
210
+ extension: string | null = null
200
211
  ) {
201
212
  if (key === undefined || key === '') {
202
213
  this.game.logger.warn(`Loader: Invalid or no key given of type ${type}`);
@@ -210,7 +221,7 @@ export class Loader {
210
221
  return this;
211
222
  }
212
223
  }
213
- const file = {
224
+ const file: Record<string, unknown> = {
214
225
  type,
215
226
  key,
216
227
  path: this.path,
@@ -222,10 +233,9 @@ export class Loader {
222
233
  error: false,
223
234
  };
224
235
  if (properties) {
225
- const keys = Object.keys(properties);
226
- for (let i = 0; i < keys.length; i += 1) {
227
- const prop = keys[i];
228
- file[prop] = properties[prop];
236
+ const extraProperties = properties as Record<string, unknown>;
237
+ for (const prop of Object.keys(extraProperties)) {
238
+ file[prop] = extraProperties[prop];
229
239
  }
230
240
  }
231
241
  const fileIndex = this.getAssetIndex(type, key);
@@ -271,7 +281,7 @@ export class Loader {
271
281
  url: url,
272
282
  path: this.path,
273
283
  syncPoint: true,
274
- data: null,
284
+ data: null as unknown,
275
285
  loading: false,
276
286
  loaded: false,
277
287
  error: false,
@@ -443,9 +453,9 @@ export class Loader {
443
453
  */
444
454
  bitmapFont(
445
455
  key: string,
446
- textureURL: string = null,
447
- atlasURL: string = null,
448
- atlasData: any = null,
456
+ textureURL: string | null = null,
457
+ atlasURL: string | null = null,
458
+ atlasData: any | null = null,
449
459
  xSpacing: number = 0,
450
460
  ySpacing: number = 0
451
461
  ) {
@@ -493,8 +503,8 @@ export class Loader {
493
503
  atlas(
494
504
  key: string,
495
505
  textureURL: string,
496
- atlasURL: string = null,
497
- atlasData: any = null,
506
+ atlasURL: string | null = null,
507
+ atlasData: any | null = null,
498
508
  format: number = TEXTURE_ATLAS_JSON_HASH
499
509
  ) {
500
510
  if (textureURL === undefined || textureURL === null) {
@@ -877,7 +887,7 @@ export class Loader {
877
887
  * @param {Function} onload - The function to call when the file loads successfully.
878
888
  * @param {Function} onerror - The function to call if the file fails to load.
879
889
  */
880
- xhrLoad(file: any, url: any, type: any, onload: Function, onerror: Function = null) {
890
+ xhrLoad(file: any, url: any, type: any, onload: Function, onerror: Function | null = null) {
881
891
  this.log('xhrLoad', file);
882
892
  const scope = this;
883
893
  const xhr = new XMLHttpRequest();
@@ -996,7 +1006,7 @@ export class Loader {
996
1006
  * @param {XMLHttpRequest} xhr - The XMLHttpRequest object that failed.
997
1007
  * @param {number | string} reason - The error code or message explaining the failure.
998
1008
  */
999
- fileError(file: any, xhr: any = null, reason: any = 0) {
1009
+ fileError(file: any, xhr: any | null = null, reason: any = 0) {
1000
1010
  // const url = file.requestUrl || this.transformUrl(file.url, file);
1001
1011
  if (!reason && xhr) {
1002
1012
  reason = xhr.status;
@@ -1059,22 +1069,27 @@ export class Loader {
1059
1069
  } else {
1060
1070
  // Load the XML before carrying on with the next file
1061
1071
  loadNext = false;
1062
- this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', (bitmapFontFile, bitmapFontXhr) => {
1063
- let json;
1064
- try {
1065
- // Try to parse as JSON, if it fails, then it's hopefully XML
1066
- json = JSON.parse(bitmapFontXhr.responseText);
1067
- } catch (error) {
1068
- // pass
1069
- }
1070
- if (json) {
1071
- bitmapFontFile.atlasType = 'json';
1072
- this.jsonLoadComplete(bitmapFontFile, bitmapFontXhr);
1073
- } else {
1074
- bitmapFontFile.atlasType = 'xml';
1075
- this.xmlLoadComplete(bitmapFontFile, bitmapFontXhr);
1072
+ this.xhrLoad(
1073
+ file,
1074
+ this.transformUrl(file.atlasURL, file),
1075
+ 'text',
1076
+ (bitmapFontFile: Record<string, unknown>, bitmapFontXhr: XMLHttpRequest) => {
1077
+ let json;
1078
+ try {
1079
+ // Try to parse as JSON, if it fails, then it's hopefully XML
1080
+ json = JSON.parse(bitmapFontXhr.responseText);
1081
+ } catch (error) {
1082
+ // pass
1083
+ }
1084
+ if (json) {
1085
+ bitmapFontFile.atlasType = 'json';
1086
+ this.jsonLoadComplete(bitmapFontFile, bitmapFontXhr);
1087
+ } else {
1088
+ bitmapFontFile.atlasType = 'xml';
1089
+ this.xmlLoadComplete(bitmapFontFile, bitmapFontXhr);
1090
+ }
1076
1091
  }
1077
- });
1092
+ );
1078
1093
  }
1079
1094
  break;
1080
1095
  case 'audio':
@@ -7,7 +7,10 @@ import { Rectangle } from '../geom/rectangle.js';
7
7
  * @param {object} bitmapFontData - The bitmap font data to finalize.
8
8
  * @returns {object} The finalized bitmap font data.
9
9
  */
10
- export const finalizeBitmapFont = (baseTexture: import('../display/webgl/base_texture.js').BaseTexture, bitmapFontData: any) => {
10
+ export const finalizeBitmapFont = (
11
+ baseTexture: import('../display/webgl/base_texture.js').BaseTexture,
12
+ bitmapFontData: any
13
+ ) => {
11
14
  Object.keys(bitmapFontData.chars).forEach((charCode) => {
12
15
  const letter = bitmapFontData.chars[charCode];
13
16
  letter.texture = new Texture(baseTexture, new Rectangle(letter.x, letter.y, letter.width, letter.height));
@@ -23,7 +26,12 @@ export const finalizeBitmapFont = (baseTexture: import('../display/webgl/base_te
23
26
  * @param {number} ySpacing - Vertical spacing between characters.
24
27
  * @returns {object} The parsed bitmap font data.
25
28
  */
26
- export const xmlBitmapFont = (xml: any, baseTexture: import('../display/webgl/base_texture.js').BaseTexture, xSpacing: number, ySpacing: number) => {
29
+ export const xmlBitmapFont = (
30
+ xml: any,
31
+ baseTexture: import('../display/webgl/base_texture.js').BaseTexture,
32
+ xSpacing: number,
33
+ ySpacing: number
34
+ ) => {
27
35
  const data: any = {};
28
36
  const info = xml.getElementsByTagName('info')[0];
29
37
  const common = xml.getElementsByTagName('common')[0];
@@ -63,7 +71,12 @@ export const xmlBitmapFont = (xml: any, baseTexture: import('../display/webgl/ba
63
71
  * @param {number} ySpacing - Vertical spacing between characters.
64
72
  * @returns {object} The parsed bitmap font data.
65
73
  */
66
- export const bitmapFont = (xml: any, baseTexture: import('../display/webgl/base_texture.js').BaseTexture, xSpacing: number, ySpacing: number) => {
74
+ export const bitmapFont = (
75
+ xml: any,
76
+ baseTexture: import('../display/webgl/base_texture.js').BaseTexture,
77
+ xSpacing: number,
78
+ ySpacing: number
79
+ ) => {
67
80
  return xmlBitmapFont(xml, baseTexture, xSpacing, ySpacing);
68
81
  };
69
82
 
@@ -75,14 +88,24 @@ export const bitmapFont = (xml: any, baseTexture: import('../display/webgl/base_
75
88
  * @param {number} ySpacing - Vertical spacing between characters.
76
89
  * @returns {object} The parsed bitmap font data.
77
90
  */
78
- export const jsonBitmapFont = (json: any, baseTexture: import('../display/webgl/base_texture.js').BaseTexture, xSpacing: number, ySpacing: number) => {
79
- const data = {
91
+ export const jsonBitmapFont = (
92
+ json: any,
93
+ baseTexture: import('../display/webgl/base_texture.js').BaseTexture,
94
+ xSpacing: number,
95
+ ySpacing: number
96
+ ) => {
97
+ const data: {
98
+ font: string;
99
+ size: number;
100
+ lineHeight: number;
101
+ chars: Record<number, { kerning: Record<number, number>; [key: string]: unknown }>;
102
+ } = {
80
103
  font: json.font.info._face,
81
104
  size: Number.parseInt(json.font.info._size, 10),
82
105
  lineHeight: Number.parseInt(json.font.common._lineHeight, 10) + ySpacing,
83
106
  chars: {},
84
107
  };
85
- json.font.chars.char.forEach((letter) => {
108
+ json.font.chars.char.forEach((letter: Record<string, string>) => {
86
109
  const charCode = Number.parseInt(letter._id, 10);
87
110
  data.chars[charCode] = {
88
111
  x: Number.parseInt(letter._x, 10),
@@ -96,8 +119,11 @@ export const jsonBitmapFont = (json: any, baseTexture: import('../display/webgl/
96
119
  };
97
120
  });
98
121
  if (json.font.kernings && json.font.kernings.kerning) {
99
- json.font.kernings.kerning.forEach((kerning) => {
100
- data.chars[kerning._second].kerning[kerning._first] = Number.parseInt(kerning._amount, 10);
122
+ json.font.kernings.kerning.forEach((kerning: Record<string, string>) => {
123
+ const char = data.chars[Number.parseInt(kerning._second, 10)];
124
+ if (char) {
125
+ char.kerning[Number.parseInt(kerning._first, 10)] = Number.parseInt(kerning._amount, 10);
126
+ }
101
127
  });
102
128
  }
103
129
  return finalizeBitmapFont(baseTexture, data);
@@ -60,10 +60,10 @@ export class ScaleManager {
60
60
  _lastReportedCanvasSize!: any;
61
61
  _lastReportedGameSize!: any;
62
62
  _booted!: any;
63
- _orientationChange!: any;
64
- _windowResize!: any;
65
- _fullScreenChange!: any;
66
- _fullScreenError!: any;
63
+ _orientationChange!: (event: Event) => void;
64
+ _windowResize!: (event: UIEvent) => void;
65
+ _fullScreenChange!: (event: Event) => void;
66
+ _fullScreenError!: (event: Event) => void;
67
67
  /**
68
68
  * TBD.
69
69
  * @param {import('./game.js').Game} game - TBD.
@@ -826,7 +826,7 @@ export class ScaleManager {
826
826
  return false;
827
827
  }
828
828
  this.hasPhaserSetFullScreen = false;
829
- document[this.game.device.cancelFullscreen]();
829
+ (document as unknown as Record<string, () => void>)[this.game.device.cancelFullscreen]();
830
830
  return true;
831
831
  }
832
832
 
@@ -1,6 +1,6 @@
1
1
  export class Scene {
2
- game!: any;
3
- key!: any;
2
+ game!: any;
3
+ key!: any;
4
4
  /**
5
5
  * Creates a new Scene instance.
6
6
  */
@@ -43,10 +43,10 @@ key!: any;
43
43
 
44
44
  /**
45
45
  * Handle scene resize.
46
- * @param {number} width - The new width of the scene.
47
- * @param {number} height - The new height of the scene.
46
+ * @param {number} _width - The new width of the scene.
47
+ * @param {number} _height - The new height of the scene.
48
48
  */
49
- resize(width: number, height: number) {
49
+ resize(_width: number, _height: number) {
50
50
  // inherit
51
51
  }
52
52
 
@@ -45,7 +45,13 @@ export class Signal {
45
45
  * @returns {SignalBinding} The binding for this listener.
46
46
  * @throws {Error} If the listener is already registered with a different once setting.
47
47
  */
48
- _registerListener(listener: Function, isOnce: boolean = false, listenerContext: any = null, priority: number = 0, args: any = null) {
48
+ _registerListener(
49
+ listener: Function,
50
+ isOnce: boolean = false,
51
+ listenerContext: any | null = null,
52
+ priority: number = 0,
53
+ args: any = null
54
+ ) {
49
55
  const prevIndex = this._indexOfListener(listener, listenerContext);
50
56
  let binding;
51
57
  if (prevIndex !== -1) {
@@ -89,7 +95,7 @@ export class Signal {
89
95
  * @param {object} context - The context of the listener.
90
96
  * @returns {number} The index of the listener in the bindings array, or -1 if not found.
91
97
  */
92
- _indexOfListener(listener: Function, context: any = null) {
98
+ _indexOfListener(listener: Function, context: any | null = null) {
93
99
  if (!this._bindings) {
94
100
  return -1;
95
101
  }
@@ -111,7 +117,7 @@ export class Signal {
111
117
  * @param {object} context - The context of the listener.
112
118
  * @returns {boolean} True if the listener is registered, false otherwise.
113
119
  */
114
- has(listener: Function, context: any = null) {
120
+ has(listener: Function, context: any | null = null) {
115
121
  return this._indexOfListener(listener, context) !== -1;
116
122
  }
117
123
 
@@ -123,7 +129,7 @@ export class Signal {
123
129
  * @param {...any} args - Additional arguments to pass to the listener.
124
130
  * @returns {SignalBinding} The binding for this listener.
125
131
  */
126
- add(listener: Function, listenerContext: any = null, priority: number = 0, ...args: any[]) {
132
+ add(listener: Function, listenerContext: any | null = null, priority: number = 0, ...args: any[]) {
127
133
  this.validateListener(listener, 'add');
128
134
  return this._registerListener(listener, false, listenerContext, priority, args);
129
135
  }
@@ -136,7 +142,7 @@ export class Signal {
136
142
  * @param {...any} args - Additional arguments to pass to the listener.
137
143
  * @returns {SignalBinding} The binding for this listener.
138
144
  */
139
- addOnce(listener: Function, listenerContext: any = null, priority: number = 0, ...args: any[]) {
145
+ addOnce(listener: Function, listenerContext: any | null = null, priority: number = 0, ...args: any[]) {
140
146
  this.validateListener(listener, 'addOnce');
141
147
  return this._registerListener(listener, true, listenerContext, priority, args);
142
148
  }
@@ -147,7 +153,7 @@ export class Signal {
147
153
  * @param {object} context - The context of the listener.
148
154
  * @returns {Function} The removed listener function.
149
155
  */
150
- remove(listener: Function, context: any = null) {
156
+ remove(listener: Function, context: any | null = null) {
151
157
  this.validateListener(listener, 'remove');
152
158
  const i = this._indexOfListener(listener, context);
153
159
  if (i !== -1) {
@@ -162,7 +168,7 @@ export class Signal {
162
168
  * Remove all listeners from the signal, or only those in a specific context.
163
169
  * @param {object} context - The context to filter listeners by, or null to remove all.
164
170
  */
165
- removeAll(context: any = null) {
171
+ removeAll(context: any | null = null) {
166
172
  if (!this._bindings) {
167
173
  return;
168
174
  }
@@ -262,7 +268,7 @@ export class Signal {
262
268
  get boundDispatch() {
263
269
  const _this = this;
264
270
  if (!this._boundDispatch) {
265
- this._boundDispatch = (...rest) => _this.dispatch(...rest);
271
+ this._boundDispatch = (...rest: unknown[]) => _this.dispatch(...rest);
266
272
  }
267
273
  return this._boundDispatch;
268
274
  }
@@ -273,7 +279,7 @@ export class Signal {
273
279
  */
274
280
  toPromise() {
275
281
  return new Promise((resolve) => {
276
- this.addOnce((...args) => {
282
+ this.addOnce((...args: unknown[]) => {
277
283
  resolve(args.length <= 1 ? args[0] : args);
278
284
  }, this);
279
285
  });
@@ -18,7 +18,14 @@ export class SignalBinding {
18
18
  * @param {number} priority - TBD.
19
19
  * @param {...any} args - TBD.
20
20
  */
21
- constructor(signal: import('./signal.js').Signal, listener: Function, isOnce: boolean = false, listenerContext: any = null, priority: number = 0, args: any = null) {
21
+ constructor(
22
+ signal: import('./signal.js').Signal,
23
+ listener: Function,
24
+ isOnce: boolean = false,
25
+ listenerContext: any | null = null,
26
+ priority: number = 0,
27
+ args: any = null
28
+ ) {
22
29
  this._signal = signal;
23
30
  this._listener = listener;
24
31
  this._args = args;
@@ -27,8 +27,8 @@ export class Sound {
27
27
  allowMultiple!: boolean;
28
28
  externalNode!: AudioNode | null;
29
29
  masterGainNode!: GainNode | null;
30
- gainNode!: GainNode | null;
31
- _sound!: AudioBufferSourceNode | null;
30
+ gainNode!: GainNode;
31
+ _sound!: AudioBufferSourceNode;
32
32
  _markedToDelete!: boolean;
33
33
  _removeFromSoundManager!: boolean;
34
34
  onPlay!: Signal;
@@ -56,7 +56,13 @@ export class Sound {
56
56
  * @param {boolean} loop - Whether the sound should loop.
57
57
  * @param {boolean} connect - Whether to connect to the master gain node.
58
58
  */
59
- constructor(game: import('./game.js').Game, key: string, volume: number = 1, loop: boolean = false, connect: boolean = null) {
59
+ constructor(
60
+ game: import('./game.js').Game,
61
+ key: string,
62
+ volume: number = 1,
63
+ loop: boolean = false,
64
+ connect: boolean | null = null
65
+ ) {
60
66
  // TODO
61
67
  // https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Migrating_from_webkitAudioContext
62
68
  if (!connect) {
@@ -67,7 +73,6 @@ export class Sound {
67
73
  this.key = key;
68
74
  this.loop = loop;
69
75
  this.markers = {};
70
- this.context = null;
71
76
  this.autoplay = false;
72
77
  this.totalDuration = 0;
73
78
  this.startTime = 0;
@@ -87,24 +92,16 @@ export class Sound {
87
92
  this.allowMultiple = false;
88
93
  /** @type {GainNode} */
89
94
  this.externalNode = null;
90
- /** @type {GainNode} */
91
- this.masterGainNode = null;
92
- /** @type {GainNode} */
93
- this.gainNode = null;
94
- /** @type {AudioBufferSourceNode} */
95
- this._sound = null;
96
95
  this._markedToDelete = false;
97
96
  this._removeFromSoundManager = false;
98
97
  this.context = this.game.sound.context;
99
98
  this.masterGainNode = this.game.sound.masterGain;
100
- if (this.context.createGain === undefined) {
101
- this.gainNode = (this.context as any).createGainNode();
102
- } else {
103
- this.gainNode = this.context.createGain();
104
- }
105
- this.gainNode.gain.value = volume * this.game.sound.volume;
106
- if (connect) {
107
- this.gainNode.connect(this.masterGainNode);
99
+ const gainNode: GainNode =
100
+ this.context.createGain === undefined ? (this.context as any).createGainNode() : this.context.createGain();
101
+ this.gainNode = gainNode;
102
+ gainNode.gain.value = volume * this.game.sound.volume;
103
+ if (connect && this.masterGainNode) {
104
+ gainNode.connect(this.masterGainNode);
108
105
  }
109
106
  this.onPlay = new Signal();
110
107
  this.onPause = new Signal();
@@ -186,7 +183,7 @@ export class Sound {
186
183
  this.game.sound.remove(this);
187
184
  } else {
188
185
  this.markers = {};
189
- this.context = null;
186
+ this.context = null!;
190
187
  this._buffer = null;
191
188
  this.externalNode = null;
192
189
  this.onPlay.dispose();
@@ -342,7 +339,7 @@ export class Sound {
342
339
  if (!this.loop && marker === '') {
343
340
  this._sound.onended = this.onEndedHandler.bind(this);
344
341
  }
345
- this.totalDuration = this._sound.buffer.duration;
342
+ this.totalDuration = this._sound.buffer?.duration ?? 0;
346
343
  if (this.duration === 0) {
347
344
  this.duration = this.totalDuration;
348
345
  this.durationMS = Math.ceil(this.totalDuration * 1000);
@@ -514,7 +511,7 @@ export class Sound {
514
511
  this.game.sound.remove(this);
515
512
  } else {
516
513
  this.markers = {};
517
- this.context = null;
514
+ this.context = null!;
518
515
  this._buffer = null;
519
516
  this.externalNode = null;
520
517
  this.onPlay.dispose();
@@ -209,7 +209,7 @@ export class SoundManager {
209
209
  });
210
210
  this.removeUnlockHandlers();
211
211
  })
212
- .catch((error) => {
212
+ .catch((error: unknown) => {
213
213
  this.game.logger.info('onContextResumeReject', {
214
214
  initialState,
215
215
  state: this.context.state,
@@ -280,10 +280,10 @@ export class SoundManager {
280
280
  this.game.cache.updateSound(key, 'isDecoding', true);
281
281
  this.context
282
282
  .decodeAudioData(soundData)
283
- .then((buffer) => {
283
+ .then((buffer: AudioBuffer) => {
284
284
  this.game.cache.decodedSound(key, buffer);
285
285
  })
286
- .catch((error) => {
286
+ .catch((error: unknown) => {
287
287
  const typedError = error instanceof Error ? error : new Error(String(error));
288
288
  this.game.logger.exception('SoundManager', typedError, { tags: { 'asset.key': key } });
289
289
  if (typedError.name === 'InvalidStateError') {
@@ -1,10 +1,10 @@
1
1
  export class SoundSprite {
2
- game!: any;
3
- key!: any;
4
- config!: any;
5
- autoplayKey!: any;
6
- autoplay!: any;
7
- sounds!: any;
2
+ game!: any;
3
+ key!: any;
4
+ config!: any;
5
+ autoplayKey!: any;
6
+ autoplay!: any;
7
+ sounds!: any;
8
8
  /**
9
9
  * TBD.
10
10
  * @param {import('./game.js').Game} game - TBD.
@@ -63,4 +63,4 @@ sounds!: any;
63
63
  get(marker: string) {
64
64
  return this.sounds[marker];
65
65
  }
66
- }
66
+ }
@@ -62,7 +62,7 @@ export class Stage extends DisplayObject {
62
62
  /**
63
63
  * Pre-updates the stage and its children.
64
64
  */
65
- preUpdate() {
65
+ override preUpdate() {
66
66
  this.currentRenderOrderID = 0;
67
67
  // This can't loop in reverse, we need the renderOrderID to be in sequence
68
68
  for (let i = 0; i < this.children.length; i += 1) {
@@ -73,7 +73,7 @@ export class Stage extends DisplayObject {
73
73
  /**
74
74
  * Updates the stage and its children.
75
75
  */
76
- update() {
76
+ override update() {
77
77
  let i = this.children.length;
78
78
  while (i) {
79
79
  i -= 1;
@@ -84,7 +84,7 @@ export class Stage extends DisplayObject {
84
84
  /**
85
85
  * Post-updates the stage and its children.
86
86
  */
87
- postUpdate() {
87
+ override postUpdate() {
88
88
  for (let i = 0; i < this.children.length; i += 1) {
89
89
  this.children[i].postUpdate();
90
90
  }
@@ -94,7 +94,7 @@ export class Stage extends DisplayObject {
94
94
  /**
95
95
  * Updates the stage's transformation matrix.
96
96
  */
97
- updateTransform(): this {
97
+ override updateTransform(): this {
98
98
  this.worldAlpha = 1;
99
99
  for (let i = 0; i < this.children.length; i += 1) {
100
100
  this.children[i].updateTransform();
@@ -105,9 +105,9 @@ export class Stage extends DisplayObject {
105
105
  /**
106
106
  * Destroys the stage and cleans up resources.
107
107
  */
108
- destroy() {
108
+ override destroy() {
109
109
  this.exists = false;
110
- this.game = null;
110
+ this.game = null!;
111
111
  this.worldTransform = null;
112
112
  this._bgColor = null;
113
113
  }
@@ -1,33 +1,33 @@
1
1
  import { Timer } from './timer.js';
2
2
 
3
3
  export class Time {
4
- game!: any;
5
- time!: any;
6
- prevTime!: any;
7
- now!: any;
8
- elapsed!: any;
9
- elapsedMS!: any;
10
- desiredFpsMult!: any;
11
- _desiredFps!: any;
12
- suggestedFps!: any;
13
- advancedTiming!: any;
14
- frames!: any;
15
- fps!: any;
16
- fpsMin!: any;
17
- fpsMax!: any;
18
- msMin!: any;
19
- msMax!: any;
20
- pauseDuration!: any;
21
- timeToCall!: any;
22
- timeExpected!: any;
23
- events!: any;
24
- _frameCount!: any;
25
- _elapsedAccumulator!: any;
26
- _started!: any;
27
- _timeLastSecond!: any;
28
- _pauseStarted!: any;
29
- _justResumed!: any;
30
- _timers!: any;
4
+ game!: any;
5
+ time!: any;
6
+ prevTime!: any;
7
+ now!: any;
8
+ elapsed!: any;
9
+ elapsedMS!: any;
10
+ desiredFpsMult!: any;
11
+ _desiredFps!: any;
12
+ suggestedFps!: any;
13
+ advancedTiming!: any;
14
+ frames!: any;
15
+ fps!: any;
16
+ fpsMin!: any;
17
+ fpsMax!: any;
18
+ msMin!: any;
19
+ msMax!: any;
20
+ pauseDuration!: any;
21
+ timeToCall!: any;
22
+ timeExpected!: any;
23
+ events!: any;
24
+ _frameCount!: any;
25
+ _elapsedAccumulator!: any;
26
+ _started!: any;
27
+ _timeLastSecond!: any;
28
+ _pauseStarted!: any;
29
+ _justResumed!: any;
30
+ _timers!: any;
31
31
  /**
32
32
  * Creates a new Time instance.
33
33
  * @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
@@ -296,4 +296,4 @@ _timers!: any;
296
296
  this._desiredFps = value;
297
297
  this.desiredFpsMult = 1 / value;
298
298
  }
299
- }
299
+ }
@@ -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