@vpmedia/phaser 1.104.0 → 1.106.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 (300) hide show
  1. package/dist/index.d.ts +5 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +164 -592
  4. package/dist/index.js.map +1 -1
  5. package/dist/phaser/core/animation.d.ts +35 -57
  6. package/dist/phaser/core/animation.d.ts.map +1 -1
  7. package/dist/phaser/core/animation_manager.d.ts +11 -10
  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 +3 -3
  12. package/dist/phaser/core/array_set.d.ts.map +1 -1
  13. package/dist/phaser/core/cache.d.ts +60 -60
  14. package/dist/phaser/core/cache.d.ts.map +1 -1
  15. package/dist/phaser/core/device.d.ts.map +1 -1
  16. package/dist/phaser/core/device_util.d.ts +10 -10
  17. package/dist/phaser/core/device_util.d.ts.map +1 -1
  18. package/dist/phaser/core/dom.d.ts +6 -5
  19. package/dist/phaser/core/dom.d.ts.map +1 -1
  20. package/dist/phaser/core/event_manager.d.ts +49 -174
  21. package/dist/phaser/core/event_manager.d.ts.map +1 -1
  22. package/dist/phaser/core/factory.d.ts +7 -7
  23. package/dist/phaser/core/factory.d.ts.map +1 -1
  24. package/dist/phaser/core/frame.d.ts +27 -48
  25. package/dist/phaser/core/frame.d.ts.map +1 -1
  26. package/dist/phaser/core/frame_data.d.ts +11 -60
  27. package/dist/phaser/core/frame_data.d.ts.map +1 -1
  28. package/dist/phaser/core/frame_util.d.ts +4 -14
  29. package/dist/phaser/core/frame_util.d.ts.map +1 -1
  30. package/dist/phaser/core/game.d.ts +49 -58
  31. package/dist/phaser/core/game.d.ts.map +1 -1
  32. package/dist/phaser/core/input.d.ts +15 -13
  33. package/dist/phaser/core/input.d.ts.map +1 -1
  34. package/dist/phaser/core/input_handler.d.ts +23 -20
  35. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  36. package/dist/phaser/core/input_mouse.d.ts +26 -1
  37. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  38. package/dist/phaser/core/input_mspointer.d.ts +2 -2
  39. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  40. package/dist/phaser/core/input_pointer.d.ts +9 -9
  41. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  42. package/dist/phaser/core/input_touch.d.ts +2 -1
  43. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  44. package/dist/phaser/core/loader.d.ts +38 -28
  45. package/dist/phaser/core/loader.d.ts.map +1 -1
  46. package/dist/phaser/core/loader_parser.d.ts +4 -4
  47. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  48. package/dist/phaser/core/raf.d.ts +2 -2
  49. package/dist/phaser/core/raf.d.ts.map +1 -1
  50. package/dist/phaser/core/scale_manager.d.ts +22 -17
  51. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  52. package/dist/phaser/core/scene.d.ts +1 -1
  53. package/dist/phaser/core/scene.d.ts.map +1 -1
  54. package/dist/phaser/core/scene_manager.d.ts +10 -9
  55. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  56. package/dist/phaser/core/signal.d.ts +9 -8
  57. package/dist/phaser/core/signal.d.ts.map +1 -1
  58. package/dist/phaser/core/signal_binding.d.ts +2 -2
  59. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  60. package/dist/phaser/core/sound.d.ts +56 -101
  61. package/dist/phaser/core/sound.d.ts.map +1 -1
  62. package/dist/phaser/core/sound_manager.d.ts +11 -9
  63. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  64. package/dist/phaser/core/sound_sprite.d.ts +4 -4
  65. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  66. package/dist/phaser/core/stage.d.ts +3 -3
  67. package/dist/phaser/core/stage.d.ts.map +1 -1
  68. package/dist/phaser/core/time.d.ts +5 -5
  69. package/dist/phaser/core/time.d.ts.map +1 -1
  70. package/dist/phaser/core/timer.d.ts +10 -10
  71. package/dist/phaser/core/timer.d.ts.map +1 -1
  72. package/dist/phaser/core/timer_event.d.ts +11 -21
  73. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  74. package/dist/phaser/core/tween.d.ts +37 -59
  75. package/dist/phaser/core/tween.d.ts.map +1 -1
  76. package/dist/phaser/core/tween_data.d.ts +6 -5
  77. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  78. package/dist/phaser/core/tween_easing.d.ts +31 -31
  79. package/dist/phaser/core/tween_easing.d.ts.map +1 -1
  80. package/dist/phaser/core/tween_manager.d.ts +4 -4
  81. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  82. package/dist/phaser/core/world.d.ts +1 -1
  83. package/dist/phaser/core/world.d.ts.map +1 -1
  84. package/dist/phaser/display/bitmap_text.d.ts +22 -20
  85. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  86. package/dist/phaser/display/button.d.ts +23 -35
  87. package/dist/phaser/display/button.d.ts.map +1 -1
  88. package/dist/phaser/display/canvas/buffer.d.ts +2 -2
  89. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  90. package/dist/phaser/display/canvas/graphics.d.ts +3 -3
  91. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  92. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  93. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  94. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  95. package/dist/phaser/display/canvas/renderer.d.ts +5 -5
  96. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  97. package/dist/phaser/display/canvas/tinter.d.ts +3 -3
  98. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  99. package/dist/phaser/display/canvas/util.d.ts +9 -9
  100. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  101. package/dist/phaser/display/display_object.d.ts +45 -42
  102. package/dist/phaser/display/display_object.d.ts.map +1 -1
  103. package/dist/phaser/display/graphics.d.ts +24 -16
  104. package/dist/phaser/display/graphics.d.ts.map +1 -1
  105. package/dist/phaser/display/graphics_data.d.ts +1 -1
  106. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  107. package/dist/phaser/display/graphics_data_util.d.ts +1 -1
  108. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  109. package/dist/phaser/display/group.d.ts +24 -37
  110. package/dist/phaser/display/group.d.ts.map +1 -1
  111. package/dist/phaser/display/image.d.ts +34 -49
  112. package/dist/phaser/display/image.d.ts.map +1 -1
  113. package/dist/phaser/display/sprite_batch.d.ts +1 -1
  114. package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
  115. package/dist/phaser/display/sprite_util.d.ts +5 -5
  116. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  117. package/dist/phaser/display/text.d.ts +86 -66
  118. package/dist/phaser/display/text.d.ts.map +1 -1
  119. package/dist/phaser/display/webgl/abstract_filter.d.ts +2 -1
  120. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  121. package/dist/phaser/display/webgl/base_texture.d.ts +2 -2
  122. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  123. package/dist/phaser/display/webgl/blend_manager.d.ts +3 -2
  124. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  125. package/dist/phaser/display/webgl/earcut.d.ts +10 -10
  126. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  127. package/dist/phaser/display/webgl/earcut_node.d.ts +1 -1
  128. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  129. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +2 -1
  130. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  131. package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
  132. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  133. package/dist/phaser/display/webgl/filter_texture.d.ts +3 -2
  134. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  135. package/dist/phaser/display/webgl/graphics.d.ts +11 -10
  136. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  137. package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
  138. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  139. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  140. package/dist/phaser/display/webgl/render_texture.d.ts +2 -1
  141. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  142. package/dist/phaser/display/webgl/renderer.d.ts +8 -6
  143. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  144. package/dist/phaser/display/webgl/shader/complex.d.ts +2 -1
  145. package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  146. package/dist/phaser/display/webgl/shader/fast.d.ts +2 -1
  147. package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  148. package/dist/phaser/display/webgl/shader/normal.d.ts +1 -0
  149. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  150. package/dist/phaser/display/webgl/shader/primitive.d.ts +2 -1
  151. package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  152. package/dist/phaser/display/webgl/shader/strip.d.ts +2 -1
  153. package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  154. package/dist/phaser/display/webgl/shader_manager.d.ts +4 -2
  155. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  156. package/dist/phaser/display/webgl/sprite_batch.d.ts +3 -2
  157. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  158. package/dist/phaser/display/webgl/stencil_manager.d.ts +5 -4
  159. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  160. package/dist/phaser/display/webgl/texture.d.ts +15 -2
  161. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  162. package/dist/phaser/display/webgl/texture_util.d.ts +2 -2
  163. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  164. package/dist/phaser/display/webgl/util.d.ts +6 -6
  165. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  166. package/dist/phaser/geom/circle.d.ts +11 -10
  167. package/dist/phaser/geom/circle.d.ts.map +1 -1
  168. package/dist/phaser/geom/ellipse.d.ts +6 -5
  169. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  170. package/dist/phaser/geom/line.d.ts +14 -14
  171. package/dist/phaser/geom/line.d.ts.map +1 -1
  172. package/dist/phaser/geom/matrix.d.ts +13 -12
  173. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  174. package/dist/phaser/geom/point.d.ts +19 -19
  175. package/dist/phaser/geom/point.d.ts.map +1 -1
  176. package/dist/phaser/geom/polygon.d.ts +6 -6
  177. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  178. package/dist/phaser/geom/rectangle.d.ts +20 -20
  179. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  180. package/dist/phaser/geom/rounded_rectangle.d.ts +2 -2
  181. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  182. package/dist/phaser/geom/util/circle.d.ts +9 -7
  183. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  184. package/dist/phaser/geom/util/ellipse.d.ts +1 -1
  185. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  186. package/dist/phaser/geom/util/line.d.ts +5 -3
  187. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  188. package/dist/phaser/geom/util/matrix.d.ts +2 -1
  189. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  190. package/dist/phaser/geom/util/point.d.ts +19 -19
  191. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  192. package/dist/phaser/geom/util/polygon.d.ts +2 -1
  193. package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
  194. package/dist/phaser/geom/util/rectangle.d.ts +17 -15
  195. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  196. package/dist/phaser/geom/util/rounded_rectangle.d.ts +2 -1
  197. package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  198. package/dist/phaser/util/math.d.ts +51 -142
  199. package/dist/phaser/util/math.d.ts.map +1 -1
  200. package/package.json +13 -13
  201. package/src/index.ts +8 -0
  202. package/src/phaser/core/animation.ts +46 -61
  203. package/src/phaser/core/animation_manager.ts +27 -21
  204. package/src/phaser/core/animation_parser.ts +11 -3
  205. package/src/phaser/core/array_set.ts +8 -8
  206. package/src/phaser/core/cache.ts +75 -68
  207. package/src/phaser/core/device.ts +24 -25
  208. package/src/phaser/core/device_util.ts +10 -10
  209. package/src/phaser/core/dom.ts +5 -5
  210. package/src/phaser/core/event_manager.ts +52 -193
  211. package/src/phaser/core/factory.ts +25 -18
  212. package/src/phaser/core/frame.ts +37 -51
  213. package/src/phaser/core/frame_data.ts +29 -76
  214. package/src/phaser/core/frame_util.ts +3 -16
  215. package/src/phaser/core/game.ts +36 -63
  216. package/src/phaser/core/input.ts +72 -68
  217. package/src/phaser/core/input_handler.ts +93 -84
  218. package/src/phaser/core/input_mouse.ts +42 -36
  219. package/src/phaser/core/input_mspointer.ts +24 -25
  220. package/src/phaser/core/input_pointer.ts +55 -56
  221. package/src/phaser/core/input_touch.ts +26 -26
  222. package/src/phaser/core/loader.ts +108 -70
  223. package/src/phaser/core/loader_parser.ts +24 -7
  224. package/src/phaser/core/raf.ts +2 -2
  225. package/src/phaser/core/scale_manager.ts +85 -82
  226. package/src/phaser/core/scene.ts +3 -4
  227. package/src/phaser/core/scene_manager.ts +26 -26
  228. package/src/phaser/core/signal.ts +16 -10
  229. package/src/phaser/core/signal_binding.ts +9 -2
  230. package/src/phaser/core/sound.ts +71 -112
  231. package/src/phaser/core/sound_manager.ts +31 -30
  232. package/src/phaser/core/sound_sprite.ts +11 -12
  233. package/src/phaser/core/stage.ts +8 -8
  234. package/src/phaser/core/time.ts +34 -35
  235. package/src/phaser/core/timer.ts +40 -34
  236. package/src/phaser/core/timer_event.ts +23 -23
  237. package/src/phaser/core/tween.ts +62 -68
  238. package/src/phaser/core/tween_data.ts +31 -31
  239. package/src/phaser/core/tween_easing.ts +31 -31
  240. package/src/phaser/core/tween_manager.ts +11 -12
  241. package/src/phaser/core/world.ts +1 -2
  242. package/src/phaser/display/bitmap_text.ts +41 -31
  243. package/src/phaser/display/button.ts +34 -49
  244. package/src/phaser/display/canvas/buffer.ts +6 -7
  245. package/src/phaser/display/canvas/graphics.ts +3 -4
  246. package/src/phaser/display/canvas/masker.ts +2 -3
  247. package/src/phaser/display/canvas/pool.ts +3 -4
  248. package/src/phaser/display/canvas/renderer.ts +19 -20
  249. package/src/phaser/display/canvas/tinter.ts +4 -5
  250. package/src/phaser/display/canvas/util.ts +17 -9
  251. package/src/phaser/display/display_object.ts +49 -50
  252. package/src/phaser/display/graphics.ts +56 -43
  253. package/src/phaser/display/graphics_data.ts +19 -12
  254. package/src/phaser/display/graphics_data_util.ts +1 -2
  255. package/src/phaser/display/group.ts +32 -42
  256. package/src/phaser/display/image.ts +38 -52
  257. package/src/phaser/display/sprite_batch.ts +1 -2
  258. package/src/phaser/display/sprite_util.ts +17 -6
  259. package/src/phaser/display/text.ts +82 -56
  260. package/src/phaser/display/webgl/abstract_filter.ts +8 -8
  261. package/src/phaser/display/webgl/base_texture.ts +14 -15
  262. package/src/phaser/display/webgl/blend_manager.ts +5 -5
  263. package/src/phaser/display/webgl/earcut.ts +44 -27
  264. package/src/phaser/display/webgl/earcut_node.ts +1 -1
  265. package/src/phaser/display/webgl/fast_sprite_batch.ts +19 -19
  266. package/src/phaser/display/webgl/filter_manager.ts +5 -5
  267. package/src/phaser/display/webgl/filter_texture.ts +7 -7
  268. package/src/phaser/display/webgl/graphics.ts +17 -11
  269. package/src/phaser/display/webgl/graphics_data.ts +11 -11
  270. package/src/phaser/display/webgl/mask_manager.ts +2 -3
  271. package/src/phaser/display/webgl/render_texture.ts +18 -12
  272. package/src/phaser/display/webgl/renderer.ts +24 -24
  273. package/src/phaser/display/webgl/shader/complex.ts +7 -7
  274. package/src/phaser/display/webgl/shader/fast.ts +8 -8
  275. package/src/phaser/display/webgl/shader/normal.ts +12 -12
  276. package/src/phaser/display/webgl/shader/primitive.ts +7 -7
  277. package/src/phaser/display/webgl/shader/strip.ts +7 -7
  278. package/src/phaser/display/webgl/shader_manager.ts +13 -13
  279. package/src/phaser/display/webgl/sprite_batch.ts +20 -20
  280. package/src/phaser/display/webgl/stencil_manager.ts +20 -8
  281. package/src/phaser/display/webgl/texture.ts +40 -24
  282. package/src/phaser/display/webgl/texture_util.ts +2 -3
  283. package/src/phaser/display/webgl/util.ts +10 -6
  284. package/src/phaser/geom/circle.ts +10 -10
  285. package/src/phaser/geom/ellipse.ts +6 -6
  286. package/src/phaser/geom/line.ts +14 -14
  287. package/src/phaser/geom/matrix.ts +12 -12
  288. package/src/phaser/geom/point.ts +19 -19
  289. package/src/phaser/geom/polygon.ts +5 -5
  290. package/src/phaser/geom/rectangle.ts +21 -21
  291. package/src/phaser/geom/rounded_rectangle.ts +2 -2
  292. package/src/phaser/geom/util/circle.ts +7 -7
  293. package/src/phaser/geom/util/ellipse.ts +1 -1
  294. package/src/phaser/geom/util/line.ts +5 -5
  295. package/src/phaser/geom/util/matrix.ts +1 -1
  296. package/src/phaser/geom/util/point.ts +27 -20
  297. package/src/phaser/geom/util/polygon.ts +1 -1
  298. package/src/phaser/geom/util/rectangle.ts +22 -15
  299. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
  300. package/src/phaser/util/math.ts +65 -151
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  import { Rectangle } from '../geom/rectangle.js';
3
2
  import { canPlayAudio } from './device_util.js';
4
3
  import { ENGINE_ERROR_INVALID_BITMAP_FONT_ATLAS } from './error_code.js';
@@ -6,40 +5,51 @@ import { Signal } from './signal.js';
6
5
 
7
6
  const TEXTURE_ATLAS_JSON_HASH = 1;
8
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
+
9
19
  export class Loader {
10
- game;
11
- cache;
12
- isLoading;
13
- isUseLog;
14
- isUseRetry;
15
- maxRetry;
16
- hasLoaded;
17
- preloadSprite;
18
- crossOrigin;
19
- baseURL;
20
- path;
21
- headers;
22
- onLoadStart;
23
- onLoadComplete;
24
- onPackComplete;
25
- onFileStart;
26
- onFileComplete;
27
- onFileError;
28
- maxParallelDownloads;
29
- _withSyncPointDepth;
30
- _fileList;
31
- _flightQueue;
32
- _processingHead;
33
- _fileLoadStarted;
34
- _totalPackCount;
35
- _totalFileCount;
36
- _loadedPackCount;
37
- _loadedFileCount;
20
+ game!: any;
21
+ cache!: any;
22
+ isLoading!: any;
23
+ isUseLog!: any;
24
+ isUseRetry!: any;
25
+ maxRetry!: any;
26
+ hasLoaded!: any;
27
+ preloadSprite!: any;
28
+ crossOrigin!: any;
29
+ baseURL!: any;
30
+ path!: any;
31
+ headers!: any;
32
+ onLoadStart!: any;
33
+ onLoadComplete!: any;
34
+ onPackComplete!: any;
35
+ onFileStart!: any;
36
+ onFileComplete!: any;
37
+ onFileError!: any;
38
+ maxParallelDownloads!: any;
39
+ _withSyncPointDepth!: any;
40
+ _fileList!: any;
41
+ _flightQueue!: any;
42
+ _processingHead!: any;
43
+ _fileLoadStarted!: any;
44
+ _totalPackCount!: any;
45
+ _totalFileCount!: any;
46
+ _loadedPackCount!: any;
47
+ _loadedFileCount!: any;
38
48
  /**
39
49
  * Creates a new Loader instance.
40
50
  * @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
41
51
  */
42
- constructor(game) {
52
+ constructor(game: import('./game.js').Game) {
43
53
  this.game = game;
44
54
  this.cache = game.cache;
45
55
  this.isLoading = false;
@@ -79,7 +89,7 @@ _loadedFileCount;
79
89
  * @param {import('../display/image.js').Image} sprite - The image to use as the preload sprite.
80
90
  * @param {number} direction - The direction of the progress (0 = horizontal, 1 = vertical).
81
91
  */
82
- setPreloadSprite(sprite, direction = 0) {
92
+ setPreloadSprite(sprite: import('../display/image.js').Image, direction: number = 0) {
83
93
  this.preloadSprite = {
84
94
  sprite,
85
95
  direction,
@@ -113,7 +123,7 @@ _loadedFileCount;
113
123
  * @param {string} key - The key of the file to check for.
114
124
  * @returns {boolean} True if the file exists, false otherwise.
115
125
  */
116
- checkKeyExists(type, key) {
126
+ checkKeyExists(type: string, key: string) {
117
127
  return this.getAssetIndex(type, key) > -1;
118
128
  }
119
129
 
@@ -123,7 +133,7 @@ _loadedFileCount;
123
133
  * @param {string} key - The key of the file to find.
124
134
  * @returns {number} The index of the file in the list, or -1 if not found.
125
135
  */
126
- getAssetIndex(type, key) {
136
+ getAssetIndex(type: string, key: string) {
127
137
  let bestFound = -1;
128
138
  for (let i = 0; i < this._fileList.length; i += 1) {
129
139
  const file = this._fileList[i];
@@ -145,7 +155,7 @@ _loadedFileCount;
145
155
  * @param {string} key - The key of the file to get.
146
156
  * @returns {{index: number, file: object} | null} The file and its index, or null if not found.
147
157
  */
148
- getAsset(type, key) {
158
+ getAsset(type: string, key: string) {
149
159
  const fileIndex = this.getAssetIndex(type, key);
150
160
  if (fileIndex > -1) {
151
161
  return { index: fileIndex, file: this._fileList[fileIndex] };
@@ -158,7 +168,7 @@ _loadedFileCount;
158
168
  * @param {boolean} hard - Whether to perform a hard reset (clears preload sprite).
159
169
  * @param {boolean} clearEvents - Whether to clear event listeners.
160
170
  */
161
- reset(hard = false, clearEvents = false) {
171
+ reset(hard: boolean = false, clearEvents: boolean = false) {
162
172
  if (hard) {
163
173
  this.preloadSprite = null;
164
174
  }
@@ -191,7 +201,14 @@ _loadedFileCount;
191
201
  * @param {string} extension - The file extension to use if URL is not provided.
192
202
  * @returns {Loader} This Loader instance for chaining.
193
203
  */
194
- addToFileList(type, key = '', url = null, properties = null, overwrite = false, extension = null) {
204
+ addToFileList(
205
+ type: string,
206
+ key: string = '',
207
+ url: string = null,
208
+ properties: any = null,
209
+ overwrite: boolean = false,
210
+ extension: string = null
211
+ ) {
195
212
  if (key === undefined || key === '') {
196
213
  this.game.logger.warn(`Loader: Invalid or no key given of type ${type}`);
197
214
  return this;
@@ -246,7 +263,7 @@ _loadedFileCount;
246
263
  * @param {object} properties - The new properties for the file.
247
264
  * @returns {Loader} This Loader instance for chaining.
248
265
  */
249
- replaceInFileList(type, key, url, properties) {
266
+ replaceInFileList(type: string, key: string, url: string, properties: any) {
250
267
  return this.addToFileList(type, key, url, properties, true);
251
268
  }
252
269
 
@@ -258,7 +275,7 @@ _loadedFileCount;
258
275
  * @param {object} callbackContext - The context in which to call the callback.
259
276
  * @returns {Loader} This Loader instance for chaining.
260
277
  */
261
- pack(key, url, data, callbackContext) {
278
+ pack(key: string, url: string, data: any, callbackContext: any) {
262
279
  const pack = {
263
280
  type: 'packfile',
264
281
  key: key,
@@ -296,7 +313,7 @@ _loadedFileCount;
296
313
  * @param {boolean} overwrite - Whether to overwrite an existing file with the same key.
297
314
  * @returns {Loader} This Loader instance for chaining.
298
315
  */
299
- image(key, url, overwrite = false) {
316
+ image(key: string, url?: any, overwrite: boolean = false) {
300
317
  return this.addToFileList('image', key, url, undefined, overwrite, '.png');
301
318
  }
302
319
 
@@ -306,7 +323,7 @@ _loadedFileCount;
306
323
  * @param {string[]} urls - The URLs of the image files to load.
307
324
  * @returns {Loader} This Loader instance for chaining.
308
325
  */
309
- images(keys, urls) {
326
+ images(keys: string[], urls: string[]) {
310
327
  if (Array.isArray(urls)) {
311
328
  for (let i = 0; i < keys.length; i += 1) {
312
329
  this.image(keys[i], urls[i]);
@@ -326,7 +343,7 @@ _loadedFileCount;
326
343
  * @param {boolean} overwrite - Whether to overwrite an existing file with the same key.
327
344
  * @returns {Loader} This Loader instance for chaining.
328
345
  */
329
- text(key, url, overwrite = false) {
346
+ text(key: string, url: string, overwrite: boolean = false) {
330
347
  return this.addToFileList('text', key, url, undefined, overwrite, '.txt');
331
348
  }
332
349
 
@@ -337,7 +354,7 @@ _loadedFileCount;
337
354
  * @param {boolean} overwrite - Whether to overwrite an existing file with the same key.
338
355
  * @returns {Loader} This Loader instance for chaining.
339
356
  */
340
- json(key, url, overwrite = false) {
357
+ json(key: string, url: string, overwrite: boolean = false) {
341
358
  return this.addToFileList('json', key, url, undefined, overwrite, '.json');
342
359
  }
343
360
 
@@ -348,7 +365,7 @@ _loadedFileCount;
348
365
  * @param {boolean} overwrite - Whether to overwrite an existing file with the same key.
349
366
  * @returns {Loader} This Loader instance for chaining.
350
367
  */
351
- xml(key, url, overwrite = false) {
368
+ xml(key: string, url: string, overwrite: boolean = false) {
352
369
  return this.addToFileList('xml', key, url, undefined, overwrite, '.xml');
353
370
  }
354
371
 
@@ -363,7 +380,15 @@ _loadedFileCount;
363
380
  * @param {number} spacing - The spacing between frames in pixels.
364
381
  * @returns {Loader} This Loader instance for chaining.
365
382
  */
366
- spritesheet(key, url, frameWidth, frameHeight, frameMax = -1, margin = 0, spacing = 0) {
383
+ spritesheet(
384
+ key: string,
385
+ url: string,
386
+ frameWidth: number,
387
+ frameHeight: number,
388
+ frameMax: number = -1,
389
+ margin: number = 0,
390
+ spacing: number = 0
391
+ ) {
367
392
  return this.addToFileList(
368
393
  'spritesheet',
369
394
  key,
@@ -381,7 +406,7 @@ _loadedFileCount;
381
406
  * @param {boolean} autoDecode - Whether to automatically decode the audio file.
382
407
  * @returns {Loader} This Loader instance for chaining.
383
408
  */
384
- audio(key, urls, autoDecode = true) {
409
+ audio(key: string, urls: any, autoDecode: boolean = true) {
385
410
  if (this.game.sound.noAudio || this.game.device.noAudioFormat) {
386
411
  return this;
387
412
  }
@@ -400,7 +425,7 @@ _loadedFileCount;
400
425
  * @param {boolean} autoDecode - Whether to automatically decode the audio file.
401
426
  * @returns {Loader} This Loader instance for chaining.
402
427
  */
403
- audioSprite(key, urls, jsonURL, jsonData, autoDecode = true) {
428
+ audioSprite(key: string, urls: string, jsonURL: string, jsonData: any, autoDecode: boolean = true) {
404
429
  if (this.game.sound.noAudio || this.game.device.noAudioFormat) {
405
430
  return this;
406
431
  }
@@ -427,7 +452,14 @@ _loadedFileCount;
427
452
  * @returns {Loader} This Loader instance for chaining.
428
453
  * @throws {Error} If the bitmap font atlas data is invalid.
429
454
  */
430
- bitmapFont(key, textureURL = null, atlasURL = null, atlasData = null, xSpacing = 0, ySpacing = 0) {
455
+ bitmapFont(
456
+ key: string,
457
+ textureURL: string = null,
458
+ atlasURL: string = null,
459
+ atlasData: any = null,
460
+ xSpacing: number = 0,
461
+ ySpacing: number = 0
462
+ ) {
431
463
  if (textureURL === undefined || textureURL === null) {
432
464
  textureURL = `${key}.png`;
433
465
  }
@@ -469,7 +501,13 @@ _loadedFileCount;
469
501
  * @param {number} format - The format of the atlas file (JSON or XML).
470
502
  * @returns {Loader} This Loader instance for chaining.
471
503
  */
472
- atlas(key, textureURL, atlasURL = null, atlasData = null, format = TEXTURE_ATLAS_JSON_HASH) {
504
+ atlas(
505
+ key: string,
506
+ textureURL: string,
507
+ atlasURL: string = null,
508
+ atlasData: any = null,
509
+ format: number = TEXTURE_ATLAS_JSON_HASH
510
+ ) {
473
511
  if (textureURL === undefined || textureURL === null) {
474
512
  textureURL = `${key}.png`;
475
513
  }
@@ -491,7 +529,7 @@ _loadedFileCount;
491
529
  * @param {object} callbackContext - The context in which to call the callback.
492
530
  * @returns {Loader} This Loader instance for chaining.
493
531
  */
494
- withSyncPoint(callback, callbackContext) {
532
+ withSyncPoint(callback: Function, callbackContext: any) {
495
533
  this._withSyncPointDepth += 1;
496
534
  try {
497
535
  callback.call(callbackContext || this, this);
@@ -507,7 +545,7 @@ _loadedFileCount;
507
545
  * @param {string} key - The key of the file to add a sync point to.
508
546
  * @returns {Loader} This Loader instance for chaining.
509
547
  */
510
- addSyncPoint(type, key) {
548
+ addSyncPoint(type: string, key: string) {
511
549
  const asset = this.getAsset(type, key);
512
550
  if (asset) {
513
551
  asset.file.syncPoint = true;
@@ -520,10 +558,10 @@ _loadedFileCount;
520
558
  * @param {string} type - The type of file to remove.
521
559
  * @param {string} key - The key of the file to remove.
522
560
  */
523
- removeFile(type, key) {
561
+ removeFile(type: string, key: string) {
524
562
  const asset = this.getAsset(type, key);
525
563
  if (asset) {
526
- if (!asset.loaded && !asset.loading) {
564
+ if (!asset.file.loaded && !asset.file.loading) {
527
565
  this._fileList.splice(asset.index, 1);
528
566
  }
529
567
  }
@@ -652,7 +690,7 @@ _loadedFileCount;
652
690
  * Finishes the loading process, optionally reporting an abnormal termination.
653
691
  * @param {boolean} abnormal - Whether the loading was terminated abnormally.
654
692
  */
655
- finishedLoading(abnormal = false) {
693
+ finishedLoading(abnormal: boolean = false) {
656
694
  if (this.hasLoaded) {
657
695
  return;
658
696
  }
@@ -676,7 +714,7 @@ _loadedFileCount;
676
714
  * @param {object} file - The file to complete or mark as failed.
677
715
  * @param {string} errorMessage - An error message if the file failed to load.
678
716
  */
679
- asyncComplete(file, errorMessage = '') {
717
+ asyncComplete(file: any, errorMessage: string = '') {
680
718
  file.loaded = true;
681
719
  file.error = !!errorMessage;
682
720
  if (file.error) {
@@ -691,7 +729,7 @@ _loadedFileCount;
691
729
  * Processes a pack file, adding its contained files to the loader.
692
730
  * @param {object} pack - The pack file object to process.
693
731
  */
694
- processPack(pack) {
732
+ processPack(pack: any) {
695
733
  const packData = pack.data[pack.key];
696
734
  if (!packData) {
697
735
  this.game.logger.warn('Missing loader pack key', { key: pack.key });
@@ -756,7 +794,7 @@ _loadedFileCount;
756
794
  * @param {object} file - The file object containing path information.
757
795
  * @returns {string} The transformed URL.
758
796
  */
759
- transformUrl(url, file) {
797
+ transformUrl(url: any, file: any): any {
760
798
  if (!url) {
761
799
  return false;
762
800
  }
@@ -770,7 +808,7 @@ _loadedFileCount;
770
808
  * Loads a file using XMLHttpRequest, handling image files specially.
771
809
  * @param {object} file - The file object to load.
772
810
  */
773
- loadFile(file) {
811
+ loadFile(file: any) {
774
812
  switch (file.type) {
775
813
  case 'packfile':
776
814
  this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.fileComplete);
@@ -812,7 +850,7 @@ _loadedFileCount;
812
850
  * Loads an image file using the Image DOM element.
813
851
  * @param {object} file - The file object to load.
814
852
  */
815
- loadImageTag(file) {
853
+ loadImageTag(file: any) {
816
854
  this.log('loadImageTag', file);
817
855
  const scope = this;
818
856
  file.data = new Image();
@@ -850,7 +888,7 @@ _loadedFileCount;
850
888
  * @param {Function} onload - The function to call when the file loads successfully.
851
889
  * @param {Function} onerror - The function to call if the file fails to load.
852
890
  */
853
- xhrLoad(file, url, type, onload, onerror = null) {
891
+ xhrLoad(file: any, url: any, type: any, onload: Function, onerror: Function = null) {
854
892
  this.log('xhrLoad', file);
855
893
  const scope = this;
856
894
  const xhr = new XMLHttpRequest();
@@ -883,7 +921,7 @@ _loadedFileCount;
883
921
  // If this was the last file in the queue and an error is thrown in the create method
884
922
  // then it's caught here, so be sure we don't carry on processing it
885
923
  if (!scope.hasLoaded) {
886
- scope.asyncComplete(file, error.message || 'Exception');
924
+ scope.asyncComplete(file, typedError.message || 'Exception');
887
925
  } else {
888
926
  scope.game.logger.exception('Loader', typedError);
889
927
  }
@@ -902,7 +940,7 @@ _loadedFileCount;
902
940
  } catch (error) {
903
941
  const typedError = error instanceof Error ? error : new Error(String(error));
904
942
  if (!scope.hasLoaded) {
905
- scope.asyncComplete(file, error.message || 'Exception');
943
+ scope.asyncComplete(file, typedError.message || 'Exception');
906
944
  } else {
907
945
  scope.game.logger.exception('Loader', typedError);
908
946
  }
@@ -928,7 +966,7 @@ _loadedFileCount;
928
966
  * @param {object[]} urls - The array of URLs to check for supported audio formats.
929
967
  * @returns {string} The first URL with a supported audio format, or null if none found.
930
968
  */
931
- getAudioURL(urls) {
969
+ getAudioURL(urls: any[]) {
932
970
  if (this.game.sound.noAudio || this.game.device.noAudioFormat) {
933
971
  return null;
934
972
  }
@@ -969,7 +1007,7 @@ _loadedFileCount;
969
1007
  * @param {XMLHttpRequest} xhr - The XMLHttpRequest object that failed.
970
1008
  * @param {number | string} reason - The error code or message explaining the failure.
971
1009
  */
972
- fileError(file, xhr = null, reason = 0) {
1010
+ fileError(file: any, xhr: any = null, reason: any = 0) {
973
1011
  // const url = file.requestUrl || this.transformUrl(file.url, file);
974
1012
  if (!reason && xhr) {
975
1013
  reason = xhr.status;
@@ -984,7 +1022,7 @@ _loadedFileCount;
984
1022
  * @param {XMLHttpRequest} xhr - TBD.
985
1023
  * @throws {Error}
986
1024
  */
987
- fileComplete(file, xhr) {
1025
+ fileComplete(file: any, xhr?: any) {
988
1026
  let loadNext = true;
989
1027
  switch (file.type) {
990
1028
  case 'packfile':
@@ -1075,7 +1113,7 @@ _loadedFileCount;
1075
1113
  * @param {object} file - The file object that was loaded successfully.
1076
1114
  * @param {XMLHttpRequest} xhr - The XMLHttpRequest object containing the file data.
1077
1115
  */
1078
- jsonLoadComplete(file, xhr) {
1116
+ jsonLoadComplete(file: any, xhr: XMLHttpRequest) {
1079
1117
  const data = JSON.parse(xhr.responseText);
1080
1118
  if (file.type === 'bitmapfont') {
1081
1119
  this.cache.addBitmapFont(file.key, file.url, file.data, data, file.atlasType, file.xSpacing, file.ySpacing);
@@ -1100,12 +1138,12 @@ _loadedFileCount;
1100
1138
  * @param {object} file - The file object containing the JSON data.
1101
1139
  * @param {XMLHttpRequest} xhr - The XMLHttpRequest object containing the file data.
1102
1140
  */
1103
- xmlLoadComplete(file, xhr) {
1141
+ xmlLoadComplete(file: any, xhr: XMLHttpRequest) {
1104
1142
  // Always try parsing the content as XML, regardless of actually response type
1105
1143
  const data = xhr.responseText;
1106
1144
  const xml = this.parseXml(data);
1107
1145
  if (!xml) {
1108
- const responseType = xhr.responseType || xhr.contentType; // contentType for MS-XDomainRequest
1146
+ const responseType = xhr.responseType || (xhr as any).contentType; // contentType for MS-XDomainRequest
1109
1147
  this.game.logger.warn(`${file.key}: invalid XML (${responseType})`);
1110
1148
  this.asyncComplete(file, 'invalid XML');
1111
1149
  return;
@@ -1125,7 +1163,7 @@ _loadedFileCount;
1125
1163
  * @param {object} data - The XML string data to parse.
1126
1164
  * @returns {Document} The parsed DOM Document, or null if parsing failed.
1127
1165
  */
1128
- parseXml(data) {
1166
+ parseXml(data: any) {
1129
1167
  let xml = null;
1130
1168
  try {
1131
1169
  if (window.DOMParser) {
@@ -1170,7 +1208,7 @@ _loadedFileCount;
1170
1208
  * @param {string} message - The message to log.
1171
1209
  * @param {string|object} data - Additional data to log with the message.
1172
1210
  */
1173
- log(message, data = '') {
1211
+ log(message: string, data: string | any = '') {
1174
1212
  if (!this.isUseLog) {
1175
1213
  return;
1176
1214
  }
@@ -1225,4 +1263,4 @@ _loadedFileCount;
1225
1263
  get progress() {
1226
1264
  return Math.round(this.progressFloat);
1227
1265
  }
1228
- }
1266
+ }
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  import { Texture } from '../display/webgl/texture.js';
3
2
  import { Rectangle } from '../geom/rectangle.js';
4
3
 
@@ -8,7 +7,10 @@ import { Rectangle } from '../geom/rectangle.js';
8
7
  * @param {object} bitmapFontData - The bitmap font data to finalize.
9
8
  * @returns {object} The finalized bitmap font data.
10
9
  */
11
- export const finalizeBitmapFont = (baseTexture, bitmapFontData) => {
10
+ export const finalizeBitmapFont = (
11
+ baseTexture: import('../display/webgl/base_texture.js').BaseTexture,
12
+ bitmapFontData: any
13
+ ) => {
12
14
  Object.keys(bitmapFontData.chars).forEach((charCode) => {
13
15
  const letter = bitmapFontData.chars[charCode];
14
16
  letter.texture = new Texture(baseTexture, new Rectangle(letter.x, letter.y, letter.width, letter.height));
@@ -24,8 +26,13 @@ export const finalizeBitmapFont = (baseTexture, bitmapFontData) => {
24
26
  * @param {number} ySpacing - Vertical spacing between characters.
25
27
  * @returns {object} The parsed bitmap font data.
26
28
  */
27
- export const xmlBitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
28
- const data = {};
29
+ export const xmlBitmapFont = (
30
+ xml: any,
31
+ baseTexture: import('../display/webgl/base_texture.js').BaseTexture,
32
+ xSpacing: number,
33
+ ySpacing: number
34
+ ) => {
35
+ const data: any = {};
29
36
  const info = xml.getElementsByTagName('info')[0];
30
37
  const common = xml.getElementsByTagName('common')[0];
31
38
  data.font = info.getAttribute('face');
@@ -64,7 +71,12 @@ export const xmlBitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
64
71
  * @param {number} ySpacing - Vertical spacing between characters.
65
72
  * @returns {object} The parsed bitmap font data.
66
73
  */
67
- export const bitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
74
+ export const bitmapFont = (
75
+ xml: any,
76
+ baseTexture: import('../display/webgl/base_texture.js').BaseTexture,
77
+ xSpacing: number,
78
+ ySpacing: number
79
+ ) => {
68
80
  return xmlBitmapFont(xml, baseTexture, xSpacing, ySpacing);
69
81
  };
70
82
 
@@ -76,7 +88,12 @@ export const bitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
76
88
  * @param {number} ySpacing - Vertical spacing between characters.
77
89
  * @returns {object} The parsed bitmap font data.
78
90
  */
79
- export const jsonBitmapFont = (json, baseTexture, xSpacing, ySpacing) => {
91
+ export const jsonBitmapFont = (
92
+ json: any,
93
+ baseTexture: import('../display/webgl/base_texture.js').BaseTexture,
94
+ xSpacing: number,
95
+ ySpacing: number
96
+ ) => {
80
97
  const data = {
81
98
  font: json.font.info._face,
82
99
  size: Number.parseInt(json.font.info._size, 10),
@@ -102,4 +119,4 @@ export const jsonBitmapFont = (json, baseTexture, xSpacing, ySpacing) => {
102
119
  });
103
120
  }
104
121
  return finalizeBitmapFont(baseTexture, data);
105
- };
122
+ };
@@ -6,7 +6,7 @@ export class RequestAnimationFrame {
6
6
  * Constructor.
7
7
  * @param {import('./game.js').Game} game - Reference to the game instance.
8
8
  */
9
- constructor(game) {
9
+ constructor(game: import('./game.js').Game) {
10
10
  this.game = game;
11
11
  this.rafId = 0;
12
12
  }
@@ -29,7 +29,7 @@ export class RequestAnimationFrame {
29
29
  * Performs an animation frame request.
30
30
  * @param {number} rafTime - The timestamp provided by the browser's animation frame.
31
31
  */
32
- update = (rafTime) => {
32
+ update = (rafTime: number) => {
33
33
  this.game.update(rafTime);
34
34
  this.rafId = requestAnimationFrame(this.update);
35
35
  };