@vpmedia/phaser 1.112.0 → 1.114.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 (296) hide show
  1. package/dist/index.js +1261 -1314
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts +14 -10
  4. package/dist/phaser/core/animation.d.ts.map +1 -1
  5. package/dist/phaser/core/animation_manager.d.ts +10 -8
  6. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  7. package/dist/phaser/core/animation_parser.d.ts +5 -4
  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 +4 -3
  11. package/dist/phaser/core/cache.d.ts.map +1 -1
  12. package/dist/phaser/core/const.d.ts.map +1 -1
  13. package/dist/phaser/core/device.d.ts.map +1 -1
  14. package/dist/phaser/core/device_util.d.ts.map +1 -1
  15. package/dist/phaser/core/dom.d.ts +3 -2
  16. package/dist/phaser/core/dom.d.ts.map +1 -1
  17. package/dist/phaser/core/event_manager.d.ts.map +1 -1
  18. package/dist/phaser/core/factory.d.ts +1 -1
  19. package/dist/phaser/core/factory.d.ts.map +1 -1
  20. package/dist/phaser/core/frame.d.ts.map +1 -1
  21. package/dist/phaser/core/frame_data.d.ts.map +1 -1
  22. package/dist/phaser/core/game.d.ts.map +1 -1
  23. package/dist/phaser/core/input.d.ts +8 -6
  24. package/dist/phaser/core/input.d.ts.map +1 -1
  25. package/dist/phaser/core/input_handler.d.ts +40 -30
  26. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  27. package/dist/phaser/core/input_mouse.d.ts +3 -2
  28. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  29. package/dist/phaser/core/input_mspointer.d.ts +3 -2
  30. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  31. package/dist/phaser/core/input_pointer.d.ts +6 -4
  32. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  33. package/dist/phaser/core/input_touch.d.ts +3 -2
  34. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  35. package/dist/phaser/core/loader.d.ts +4 -3
  36. package/dist/phaser/core/loader.d.ts.map +1 -1
  37. package/dist/phaser/core/loader_parser.d.ts +9 -8
  38. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  39. package/dist/phaser/core/raf.d.ts +3 -2
  40. package/dist/phaser/core/raf.d.ts.map +1 -1
  41. package/dist/phaser/core/registry.d.ts +7 -0
  42. package/dist/phaser/core/registry.d.ts.map +1 -0
  43. package/dist/phaser/core/scale_manager.d.ts +1 -1
  44. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  45. package/dist/phaser/core/scene.d.ts +0 -1
  46. package/dist/phaser/core/scene.d.ts.map +1 -1
  47. package/dist/phaser/core/scene_manager.d.ts +1 -1
  48. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  49. package/dist/phaser/core/signal.d.ts +0 -1
  50. package/dist/phaser/core/signal.d.ts.map +1 -1
  51. package/dist/phaser/core/signal_binding.d.ts +4 -3
  52. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  53. package/dist/phaser/core/sound.d.ts +6 -4
  54. package/dist/phaser/core/sound.d.ts.map +1 -1
  55. package/dist/phaser/core/sound_manager.d.ts +3 -2
  56. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  57. package/dist/phaser/core/sound_sprite.d.ts +5 -4
  58. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  59. package/dist/phaser/core/stage.d.ts +3 -2
  60. package/dist/phaser/core/stage.d.ts.map +1 -1
  61. package/dist/phaser/core/time.d.ts +1 -1
  62. package/dist/phaser/core/time.d.ts.map +1 -1
  63. package/dist/phaser/core/timer.d.ts +1 -1
  64. package/dist/phaser/core/timer.d.ts.map +1 -1
  65. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  66. package/dist/phaser/core/tween.d.ts +10 -7
  67. package/dist/phaser/core/tween.d.ts.map +1 -1
  68. package/dist/phaser/core/tween_data.d.ts +3 -2
  69. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  70. package/dist/phaser/core/tween_easing.d.ts.map +1 -1
  71. package/dist/phaser/core/tween_manager.d.ts +3 -2
  72. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  73. package/dist/phaser/core/world.d.ts +3 -2
  74. package/dist/phaser/core/world.d.ts.map +1 -1
  75. package/dist/phaser/display/bitmap_text.d.ts +3 -2
  76. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  77. package/dist/phaser/display/button.d.ts +3 -2
  78. package/dist/phaser/display/button.d.ts.map +1 -1
  79. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  80. package/dist/phaser/display/canvas/graphics.d.ts +7 -6
  81. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  82. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  83. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  84. package/dist/phaser/display/canvas/renderer.d.ts +10 -8
  85. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  86. package/dist/phaser/display/canvas/tinter.d.ts +3 -2
  87. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  88. package/dist/phaser/display/canvas/util.d.ts +2 -2
  89. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  90. package/dist/phaser/display/display_object.d.ts +14 -12
  91. package/dist/phaser/display/display_object.d.ts.map +1 -1
  92. package/dist/phaser/display/graphics.d.ts +8 -5
  93. package/dist/phaser/display/graphics.d.ts.map +1 -1
  94. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  95. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  96. package/dist/phaser/display/group.d.ts +4 -3
  97. package/dist/phaser/display/group.d.ts.map +1 -1
  98. package/dist/phaser/display/image.d.ts +13 -10
  99. package/dist/phaser/display/image.d.ts.map +1 -1
  100. package/dist/phaser/display/sprite_batch.d.ts +3 -2
  101. package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
  102. package/dist/phaser/display/sprite_util.d.ts +18 -15
  103. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  104. package/dist/phaser/display/text.d.ts +12 -10
  105. package/dist/phaser/display/text.d.ts.map +1 -1
  106. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  107. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  108. package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
  109. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  110. package/dist/phaser/display/webgl/earcut.d.ts +1 -1
  111. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  112. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  113. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
  114. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  115. package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
  116. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  117. package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
  118. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  119. package/dist/phaser/display/webgl/graphics.d.ts +7 -6
  120. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  121. package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
  122. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  123. package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
  124. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  125. package/dist/phaser/display/webgl/renderer.d.ts +16 -11
  126. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  127. package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
  128. package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  129. package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
  130. package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  131. package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
  132. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  133. package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
  134. package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  135. package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
  136. package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  137. package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
  138. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  139. package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
  140. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  141. package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
  142. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  143. package/dist/phaser/display/webgl/texture.d.ts +3 -2
  144. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  145. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  146. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  147. package/dist/phaser/geom/circle.d.ts +4 -1
  148. package/dist/phaser/geom/circle.d.ts.map +1 -1
  149. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  150. package/dist/phaser/geom/line.d.ts +1 -1
  151. package/dist/phaser/geom/line.d.ts.map +1 -1
  152. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  153. package/dist/phaser/geom/point.d.ts.map +1 -1
  154. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  155. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  156. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  157. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  158. package/dist/phaser/geom/util/ellipse.d.ts +3 -2
  159. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  160. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  161. package/dist/phaser/geom/util/matrix.d.ts +2 -2
  162. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  163. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  164. package/dist/phaser/geom/util/rectangle.d.ts +1 -1
  165. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  166. package/dist/phaser/util/math.d.ts.map +1 -1
  167. package/package.json +5 -5
  168. package/src/phaser/core/animation.ts +64 -60
  169. package/src/phaser/core/animation_manager.ts +50 -53
  170. package/src/phaser/core/animation_parser.ts +9 -9
  171. package/src/phaser/core/array_set.ts +16 -17
  172. package/src/phaser/core/cache.ts +92 -93
  173. package/src/phaser/core/const.ts +1 -1
  174. package/src/phaser/core/device.ts +24 -29
  175. package/src/phaser/core/device_util.ts +22 -26
  176. package/src/phaser/core/dom.ts +54 -65
  177. package/src/phaser/core/event_manager.ts +64 -94
  178. package/src/phaser/core/factory.ts +14 -14
  179. package/src/phaser/core/frame.ts +28 -28
  180. package/src/phaser/core/frame_data.test.ts +100 -0
  181. package/src/phaser/core/frame_data.ts +24 -24
  182. package/src/phaser/core/frame_util.ts +2 -2
  183. package/src/phaser/core/game.ts +47 -48
  184. package/src/phaser/core/input.ts +104 -110
  185. package/src/phaser/core/input_handler.test.ts +113 -0
  186. package/src/phaser/core/input_handler.ts +199 -218
  187. package/src/phaser/core/input_mouse.ts +71 -54
  188. package/src/phaser/core/input_mspointer.ts +52 -39
  189. package/src/phaser/core/input_pointer.ts +81 -80
  190. package/src/phaser/core/input_touch.ts +49 -36
  191. package/src/phaser/core/loader.ts +173 -152
  192. package/src/phaser/core/loader_parser.ts +39 -57
  193. package/src/phaser/core/raf.ts +8 -7
  194. package/src/phaser/core/registry.test.ts +31 -0
  195. package/src/phaser/core/registry.ts +9 -0
  196. package/src/phaser/core/scale_manager.ts +156 -152
  197. package/src/phaser/core/scene.ts +9 -13
  198. package/src/phaser/core/scene_manager.ts +47 -47
  199. package/src/phaser/core/signal.test.ts +4 -4
  200. package/src/phaser/core/signal.ts +41 -52
  201. package/src/phaser/core/signal_binding.ts +26 -25
  202. package/src/phaser/core/signal_dispatch.test.ts +180 -0
  203. package/src/phaser/core/sound.ts +75 -83
  204. package/src/phaser/core/sound_manager.ts +52 -51
  205. package/src/phaser/core/sound_sprite.ts +17 -16
  206. package/src/phaser/core/stage.ts +25 -24
  207. package/src/phaser/core/time.ts +52 -52
  208. package/src/phaser/core/timer.test.ts +187 -0
  209. package/src/phaser/core/timer.ts +82 -69
  210. package/src/phaser/core/timer_event.ts +10 -10
  211. package/src/phaser/core/tween.ts +90 -93
  212. package/src/phaser/core/tween_data.ts +45 -51
  213. package/src/phaser/core/tween_easing.test.ts +106 -0
  214. package/src/phaser/core/tween_easing.ts +151 -123
  215. package/src/phaser/core/tween_manager.ts +19 -18
  216. package/src/phaser/core/world.ts +4 -3
  217. package/src/phaser/display/bitmap_text.ts +56 -64
  218. package/src/phaser/display/button.ts +33 -32
  219. package/src/phaser/display/canvas/buffer.ts +8 -8
  220. package/src/phaser/display/canvas/graphics.ts +36 -37
  221. package/src/phaser/display/canvas/masker.ts +2 -2
  222. package/src/phaser/display/canvas/pool.test.ts +106 -0
  223. package/src/phaser/display/canvas/pool.ts +25 -27
  224. package/src/phaser/display/canvas/renderer.ts +32 -31
  225. package/src/phaser/display/canvas/tinter.ts +25 -25
  226. package/src/phaser/display/canvas/util.ts +7 -10
  227. package/src/phaser/display/display_object.ts +114 -118
  228. package/src/phaser/display/graphics.ts +121 -119
  229. package/src/phaser/display/graphics_data.ts +12 -12
  230. package/src/phaser/display/graphics_data_util.ts +2 -3
  231. package/src/phaser/display/group.ts +50 -57
  232. package/src/phaser/display/image.ts +55 -52
  233. package/src/phaser/display/sprite_batch.ts +3 -2
  234. package/src/phaser/display/sprite_util.ts +48 -54
  235. package/src/phaser/display/text.test.ts +110 -0
  236. package/src/phaser/display/text.ts +199 -204
  237. package/src/phaser/display/webgl/abstract_filter.ts +9 -9
  238. package/src/phaser/display/webgl/base_texture.ts +21 -24
  239. package/src/phaser/display/webgl/blend_manager.ts +6 -10
  240. package/src/phaser/display/webgl/earcut.ts +73 -37
  241. package/src/phaser/display/webgl/earcut_node.ts +10 -10
  242. package/src/phaser/display/webgl/fast_sprite_batch.ts +34 -34
  243. package/src/phaser/display/webgl/filter_manager.ts +13 -12
  244. package/src/phaser/display/webgl/filter_texture.ts +14 -13
  245. package/src/phaser/display/webgl/graphics.ts +51 -57
  246. package/src/phaser/display/webgl/graphics_data.ts +15 -14
  247. package/src/phaser/display/webgl/mask_manager.ts +2 -2
  248. package/src/phaser/display/webgl/render_texture.ts +26 -25
  249. package/src/phaser/display/webgl/renderer.ts +57 -62
  250. package/src/phaser/display/webgl/shader/complex.ts +28 -12
  251. package/src/phaser/display/webgl/shader/fast.ts +30 -12
  252. package/src/phaser/display/webgl/shader/normal.ts +70 -57
  253. package/src/phaser/display/webgl/shader/primitive.ts +26 -11
  254. package/src/phaser/display/webgl/shader/shader.test.ts +148 -0
  255. package/src/phaser/display/webgl/shader/strip.ts +27 -12
  256. package/src/phaser/display/webgl/shader_manager.test.ts +124 -0
  257. package/src/phaser/display/webgl/shader_manager.ts +26 -34
  258. package/src/phaser/display/webgl/sprite_batch.ts +67 -61
  259. package/src/phaser/display/webgl/stencil_manager.ts +23 -34
  260. package/src/phaser/display/webgl/texture.ts +43 -50
  261. package/src/phaser/display/webgl/texture_util.ts +2 -3
  262. package/src/phaser/display/webgl/util.ts +26 -25
  263. package/src/phaser/geom/circle.test.ts +2 -3
  264. package/src/phaser/geom/circle.ts +36 -36
  265. package/src/phaser/geom/ellipse.test.ts +73 -71
  266. package/src/phaser/geom/ellipse.ts +14 -14
  267. package/src/phaser/geom/line.test.ts +5 -5
  268. package/src/phaser/geom/line.ts +35 -35
  269. package/src/phaser/geom/matrix.test.ts +1 -1
  270. package/src/phaser/geom/matrix.ts +27 -27
  271. package/src/phaser/geom/point.test.ts +1 -2
  272. package/src/phaser/geom/point.ts +35 -35
  273. package/src/phaser/geom/polygon.test.ts +82 -0
  274. package/src/phaser/geom/polygon.ts +16 -16
  275. package/src/phaser/geom/rectangle.test.ts +14 -14
  276. package/src/phaser/geom/rectangle.ts +83 -75
  277. package/src/phaser/geom/rounded_rectangle.test.ts +1 -7
  278. package/src/phaser/geom/rounded_rectangle.ts +9 -9
  279. package/src/phaser/geom/util/circle.test.ts +25 -23
  280. package/src/phaser/geom/util/circle.ts +9 -18
  281. package/src/phaser/geom/util/ellipse.test.ts +7 -5
  282. package/src/phaser/geom/util/ellipse.ts +3 -2
  283. package/src/phaser/geom/util/line.test.ts +10 -8
  284. package/src/phaser/geom/util/line.ts +6 -16
  285. package/src/phaser/geom/util/matrix.test.ts +20 -18
  286. package/src/phaser/geom/util/matrix.ts +8 -15
  287. package/src/phaser/geom/util/point.test.ts +8 -6
  288. package/src/phaser/geom/util/point.ts +24 -28
  289. package/src/phaser/geom/util/polygon.test.ts +12 -10
  290. package/src/phaser/geom/util/polygon.ts +2 -2
  291. package/src/phaser/geom/util/rectangle.test.ts +10 -8
  292. package/src/phaser/geom/util/rectangle.ts +18 -37
  293. package/src/phaser/geom/util/rounded_rectangle.test.ts +11 -9
  294. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
  295. package/src/phaser/util/math.test.ts +11 -11
  296. package/src/phaser/util/math.ts +29 -46
@@ -1,3 +1,4 @@
1
+ import type { Game } from './game.js';
1
2
  import {
2
3
  addPageLifecycleCallback,
3
4
  getPageLifecycleEventEmitter,
@@ -12,30 +13,30 @@ import { Sound } from './sound.js';
12
13
  import { SoundSprite } from './sound_sprite.js';
13
14
 
14
15
  export class SoundManager {
15
- game!: any;
16
- onChange!: any;
17
- context!: any;
18
- baseLatency!: any;
19
- noAudio!: any;
20
- type!: any;
21
- connectToMaster!: any;
22
- isLocked!: any;
23
- _codeMuted!: any;
24
- _muted!: any;
25
- _unlockSource!: any;
26
- _volume!: any;
27
- _sounds!: any;
28
- _watchList!: any;
29
- _watching!: any;
30
- _watchCallback!: any;
31
- _watchContext!: any;
32
- masterGain!: any;
33
- _muteVolume!: any;
16
+ public game!: any;
17
+ public onChange!: any;
18
+ public context!: any;
19
+ public baseLatency!: any;
20
+ public noAudio!: any;
21
+ public type!: any;
22
+ public connectToMaster!: any;
23
+ public isLocked!: any;
24
+ public _codeMuted!: any;
25
+ public _muted!: any;
26
+ public _unlockSource!: any;
27
+ public _volume!: any;
28
+ public _sounds!: any;
29
+ public _watchList!: any;
30
+ public _watching!: any;
31
+ public _watchCallback!: any;
32
+ public _watchContext!: any;
33
+ public masterGain!: any;
34
+ public _muteVolume!: any;
34
35
  /**
35
36
  * Creates a new SoundManager instance.
36
- * @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
37
+ * @param {Game} game - Reference to the Phaser Game instance.
37
38
  */
38
- constructor(game: import('./game.js').Game) {
39
+ public constructor(game: Game) {
39
40
  this.game = game;
40
41
  this.onChange = new Signal();
41
42
  /** @type {AudioContext} */
@@ -61,7 +62,7 @@ export class SoundManager {
61
62
  /**
62
63
  * Initializes the sound manager and sets up audio context.
63
64
  */
64
- boot() {
65
+ public boot() {
65
66
  const setAudioDisabledState = () => {
66
67
  this.type = AUDIO_DISABLED;
67
68
  this.noAudio = true;
@@ -71,10 +72,10 @@ export class SoundManager {
71
72
  setAudioDisabledState();
72
73
  return;
73
74
  }
74
- if (window.AudioContext) {
75
+ if (globalThis.AudioContext) {
75
76
  try {
76
77
  this.game.logger.info('initAudioContext');
77
- this.context = new window.AudioContext();
78
+ this.context = new globalThis.AudioContext();
78
79
  this.type = AUDIO_STANDARD;
79
80
  } catch (error) {
80
81
  this.context = null;
@@ -82,10 +83,10 @@ export class SoundManager {
82
83
  const typedError = error instanceof Error ? error : new Error(String(error));
83
84
  this.game.logger.fatal('SoundManager', { error: typedError });
84
85
  }
85
- } else if ((window as any).webkitAudioContext) {
86
+ } else if ((globalThis as any).webkitAudioContext) {
86
87
  try {
87
88
  this.game.logger.info('initWebkitAudioContext');
88
- this.context = new (window as any).webkitAudioContext();
89
+ this.context = new (globalThis as any).webkitAudioContext();
89
90
  this.type = AUDIO_WEBKIT;
90
91
  } catch (error) {
91
92
  this.context = null;
@@ -99,7 +100,7 @@ export class SoundManager {
99
100
  setAudioDisabledState();
100
101
  return;
101
102
  }
102
- this.baseLatency = this.context.baseLatency || 256 / (this.context.sampleRate || 44100);
103
+ this.baseLatency = this.context.baseLatency ?? 256 / (this.context.sampleRate ?? 44_100);
103
104
  if (this.context.createGain === undefined) {
104
105
  this.masterGain = this.context.createGainNode();
105
106
  } else {
@@ -119,7 +120,7 @@ export class SoundManager {
119
120
  /**
120
121
  * Handles page lifecycle changes for audio management.
121
122
  */
122
- onPageLifecycleChange = () => {
123
+ public onPageLifecycleChange = () => {
123
124
  if (!document.hidden) {
124
125
  this.checkUnlockHandlers();
125
126
  }
@@ -128,7 +129,7 @@ export class SoundManager {
128
129
  /**
129
130
  * Handles audio context state changes.
130
131
  */
131
- onContextStateChange = () => {
132
+ public onContextStateChange = () => {
132
133
  this.game.logger.info('onContextStateChange', {
133
134
  state: this.context.state,
134
135
  isLocked: this.isLocked,
@@ -139,7 +140,7 @@ export class SoundManager {
139
140
  /**
140
141
  * Checks if audio unlock handlers need to be added or removed.
141
142
  */
142
- checkUnlockHandlers = () => {
143
+ public checkUnlockHandlers = () => {
143
144
  this.game.logger.info('checkUnlockHandlers', {
144
145
  state: this.context.state,
145
146
  isLocked: this.isLocked,
@@ -154,7 +155,7 @@ export class SoundManager {
154
155
  /**
155
156
  * Adds event listeners to unlock audio context.
156
157
  */
157
- addUnlockHandlers = () => {
158
+ public addUnlockHandlers = () => {
158
159
  this.isLocked = true;
159
160
  this.game.logger.info('addUnlockHandlers', {
160
161
  state: this.context.state,
@@ -168,7 +169,7 @@ export class SoundManager {
168
169
  /**
169
170
  * Removes event listeners that unlock audio context.
170
171
  */
171
- removeUnlockHandlers = () => {
172
+ public removeUnlockHandlers = () => {
172
173
  this.isLocked = false;
173
174
  this.game.logger.info('removeUnlockHandlers', {
174
175
  state: this.context.state,
@@ -183,7 +184,7 @@ export class SoundManager {
183
184
  * Handles unlock events to resume audio context.
184
185
  * @param {Event} event - The DOM event that triggered the unlock.
185
186
  */
186
- onUnlockEvent = (event: Event) => {
187
+ public onUnlockEvent = (event: Event) => {
187
188
  const initialState = this.context.state;
188
189
  if (initialState !== 'suspended' && initialState !== 'interrupted') {
189
190
  this.game.logger.info('onUnlockResumeDenied', {
@@ -227,7 +228,7 @@ export class SoundManager {
227
228
  /**
228
229
  * Stops all sounds in the manager.
229
230
  */
230
- stopAll() {
231
+ public stopAll() {
231
232
  if (this.noAudio) {
232
233
  return;
233
234
  }
@@ -241,7 +242,7 @@ export class SoundManager {
241
242
  /**
242
243
  * Pauses all sounds in the manager.
243
244
  */
244
- pauseAll() {
245
+ public pauseAll() {
245
246
  if (this.noAudio) {
246
247
  return;
247
248
  }
@@ -255,7 +256,7 @@ export class SoundManager {
255
256
  /**
256
257
  * Resumes all sounds in the manager.
257
258
  */
258
- resumeAll() {
259
+ public resumeAll() {
259
260
  if (this.noAudio) {
260
261
  return;
261
262
  }
@@ -270,7 +271,7 @@ export class SoundManager {
270
271
  * Decodes an audio file for playback.
271
272
  * @param {string} key - The key of the sound to decode.
272
273
  */
273
- decode(key: string) {
274
+ public decode(key: string) {
274
275
  const soundData = this.game.cache.getSoundData(key);
275
276
  if (!soundData) {
276
277
  return;
@@ -303,7 +304,7 @@ export class SoundManager {
303
304
  * @param {Function} callback - The callback function to call when all files are decoded.
304
305
  * @param {object} callbackContext - The context in which to call the callback.
305
306
  */
306
- setDecodedCallback(files: any, callback: Function, callbackContext: any) {
307
+ public setDecodedCallback(files: any, callback: Function, callbackContext: any) {
307
308
  if (typeof files === 'string') {
308
309
  files = [files];
309
310
  }
@@ -331,7 +332,7 @@ export class SoundManager {
331
332
  /**
332
333
  * Updates the sound manager state.
333
334
  */
334
- update() {
335
+ public update() {
335
336
  if (this.noAudio) {
336
337
  return;
337
338
  }
@@ -362,7 +363,7 @@ export class SoundManager {
362
363
  * @param {boolean} connect - Whether to connect to the master gain node.
363
364
  * @returns {Sound} The created Sound object.
364
365
  */
365
- add(key: string, volume: number = 1, loop: boolean = false, connect: boolean = this.connectToMaster) {
366
+ public add(key: string, volume = 1, loop = false, connect: boolean = this.connectToMaster) {
366
367
  const sound = new Sound(this.game, key, volume, loop, connect);
367
368
  this._sounds.push(sound);
368
369
  return sound;
@@ -373,7 +374,7 @@ export class SoundManager {
373
374
  * @param {string} key - The key of the sound sprite to add.
374
375
  * @returns {SoundSprite} The created SoundSprite object.
375
376
  */
376
- addSprite(key: string) {
377
+ public addSprite(key: string) {
377
378
  return new SoundSprite(this.game, key);
378
379
  }
379
380
 
@@ -382,7 +383,7 @@ export class SoundManager {
382
383
  * @param {Sound | null | undefined} sound - The sound object to remove.
383
384
  * @returns {boolean} True if the sound was removed, false otherwise.
384
385
  */
385
- remove(sound: Sound | null | undefined) {
386
+ public remove(sound: Sound | null | undefined) {
386
387
  let i = this._sounds.length;
387
388
  while (i) {
388
389
  i -= 1;
@@ -400,7 +401,7 @@ export class SoundManager {
400
401
  * @param {string} key - The key of sounds to remove.
401
402
  * @returns {number} The number of sounds removed.
402
403
  */
403
- removeByKey(key: string) {
404
+ public removeByKey(key: string) {
404
405
  let i = this._sounds.length;
405
406
  let removed = 0;
406
407
  while (i) {
@@ -421,7 +422,7 @@ export class SoundManager {
421
422
  * @param {boolean} loop - Whether the sound should loop.
422
423
  * @returns {Sound} The created Sound object, or null if audio is disabled.
423
424
  */
424
- play(key: string, volume: number = 1, loop: boolean = false) {
425
+ public play(key: string, volume = 1, loop = false) {
425
426
  if (this.noAudio) {
426
427
  return null;
427
428
  }
@@ -433,7 +434,7 @@ export class SoundManager {
433
434
  /**
434
435
  * Mutes all sounds in the manager.
435
436
  */
436
- setMute() {
437
+ public setMute() {
437
438
  if (this._muted) {
438
439
  return;
439
440
  }
@@ -448,7 +449,7 @@ export class SoundManager {
448
449
  /**
449
450
  * Unmutes all sounds in the manager.
450
451
  */
451
- unsetMute() {
452
+ public unsetMute() {
452
453
  if (!this._muted || this._codeMuted) {
453
454
  return;
454
455
  }
@@ -462,7 +463,7 @@ export class SoundManager {
462
463
  /**
463
464
  * Destroys the sound manager and cleans up resources.
464
465
  */
465
- destroy() {
466
+ public destroy() {
466
467
  this.stopAll();
467
468
  for (let i = 0; i < this._sounds.length; i += 1) {
468
469
  if (this._sounds[i]) {
@@ -480,14 +481,14 @@ export class SoundManager {
480
481
  * Gets the muted state of the sound manager.
481
482
  * @returns {boolean} True if the manager is muted, false otherwise.
482
483
  */
483
- get mute() {
484
+ public get mute() {
484
485
  return this._muted;
485
486
  }
486
487
 
487
488
  /**
488
489
  * Sets the muted state of the sound manager.
489
490
  */
490
- set mute(value) {
491
+ public set mute(value) {
491
492
  if (value || false) {
492
493
  if (this._muted) {
493
494
  return;
@@ -507,14 +508,14 @@ export class SoundManager {
507
508
  * Gets the volume level of the sound manager.
508
509
  * @returns {number} The volume level (0.0 to 1.0).
509
510
  */
510
- get volume() {
511
+ public get volume() {
511
512
  return this._volume;
512
513
  }
513
514
 
514
515
  /**
515
516
  * Sets the volume level of the sound manager.
516
517
  */
517
- set volume(value) {
518
+ public set volume(value) {
518
519
  if (value < 0) {
519
520
  value = 0;
520
521
  } else if (value > 1) {
@@ -1,24 +1,25 @@
1
+ import type { Game } from './game.js';
1
2
  export class SoundSprite {
2
- game!: any;
3
- key!: any;
4
- config!: any;
5
- autoplayKey!: any;
6
- autoplay!: any;
7
- sounds!: any;
3
+ public game!: any;
4
+ public key!: any;
5
+ public config!: any;
6
+ public autoplayKey!: any;
7
+ public autoplay!: any;
8
+ public sounds!: any;
8
9
  /**
9
10
  * TBD.
10
- * @param {import('./game.js').Game} game - TBD.
11
+ * @param {Game} game - TBD.
11
12
  * @param {string} key - TBD.
12
13
  */
13
- constructor(game: import('./game.js').Game, key: string) {
14
+ public constructor(game: Game, key: string) {
14
15
  this.game = game;
15
16
  this.key = key;
16
17
  this.config = this.game.cache.getJSON(`${key}-audioatlas`);
17
18
  this.autoplayKey = null;
18
19
  this.autoplay = false;
19
- /** @type {{[key: string]: import('./sound.js').Sound}} */
20
+ /** @type {{[key: string]: Sound}} */
20
21
  this.sounds = {};
21
- for (let k in this.config.spritemap) {
22
+ for (const k in this.config.spritemap) {
22
23
  const marker = this.config.spritemap[k];
23
24
  const sound = this.game.sound.add(this.key);
24
25
  sound.addMarker(k, marker.start, marker.end - marker.start, null, marker.loop);
@@ -35,9 +36,9 @@ export class SoundSprite {
35
36
  * TBD.
36
37
  * @param {string} marker - TBD.
37
38
  * @param {number} volume - TBD.
38
- * @returns {import('./sound.js').Sound} TBD.
39
+ * @returns {Sound} TBD.
39
40
  */
40
- play(marker: string, volume: number = 1) {
41
+ public play(marker: string, volume = 1) {
41
42
  return this.sounds[marker].play(marker, null, volume);
42
43
  }
43
44
 
@@ -45,9 +46,9 @@ export class SoundSprite {
45
46
  * TBD.
46
47
  * @param {string} marker - TBD.
47
48
  */
48
- stop(marker: string) {
49
+ public stop(marker: string) {
49
50
  if (!marker) {
50
- for (let key in this.sounds) {
51
+ for (const key in this.sounds) {
51
52
  this.sounds[key].stop();
52
53
  }
53
54
  } else {
@@ -58,9 +59,9 @@ export class SoundSprite {
58
59
  /**
59
60
  * TBD.
60
61
  * @param {string} marker - TBD.
61
- * @returns {import('./sound.js').Sound} TBD.
62
+ * @returns {Sound} TBD.
62
63
  */
63
- get(marker: string) {
64
+ public get(marker: string) {
64
65
  return this.sounds[marker];
65
66
  }
66
67
  }
@@ -3,17 +3,18 @@ import { DisplayObject } from '../display/display_object.js';
3
3
  import { Matrix } from '../geom/matrix.js';
4
4
  import { valueToColor } from '../util/math.js';
5
5
  import { SCALE_LINEAR, SCALE_NEAREST } from './const.js';
6
+ import type { Game } from './game.js';
6
7
 
7
8
  export class Stage extends DisplayObject {
8
- declare name: any;
9
- declare worldTransform: any;
10
- currentRenderOrderID!: any;
11
- _bgColor!: any;
9
+ declare public name: any;
10
+ declare public worldTransform: any;
11
+ public currentRenderOrderID!: any;
12
+ public _bgColor!: any;
12
13
  /**
13
14
  * Creates a new Stage instance.
14
- * @param {import('./game.js').Game} game - The game instance.
15
+ * @param {Game} game - The game instance.
15
16
  */
16
- constructor(game: import('./game.js').Game) {
17
+ public constructor(game: Game) {
17
18
  super(game);
18
19
  this.name = '_stage_root';
19
20
  this.worldTransform = new Matrix();
@@ -39,7 +40,7 @@ export class Stage extends DisplayObject {
39
40
  * Sets the background color of the stage.
40
41
  * @param {number} color - The color to set as the background.
41
42
  */
42
- setBackgroundColor(color: number) {
43
+ public setBackgroundColor(color: number) {
43
44
  if (this.game.config.transparent) {
44
45
  return;
45
46
  }
@@ -54,7 +55,7 @@ export class Stage extends DisplayObject {
54
55
  /**
55
56
  * Initializes the stage after game creation.
56
57
  */
57
- boot() {
58
+ public boot() {
58
59
  setUserSelect(this.game.canvas, 'none');
59
60
  setTouchAction(this.game.canvas, 'none');
60
61
  }
@@ -62,31 +63,31 @@ export class Stage extends DisplayObject {
62
63
  /**
63
64
  * Pre-updates the stage and its children.
64
65
  */
65
- override preUpdate() {
66
+ public override preUpdate() {
66
67
  this.currentRenderOrderID = 0;
67
68
  // This can't loop in reverse, we need the renderOrderID to be in sequence
68
69
  for (let i = 0; i < this.children.length; i += 1) {
69
- this.children[i].preUpdate();
70
+ this.children[i]!.preUpdate();
70
71
  }
71
72
  }
72
73
 
73
74
  /**
74
75
  * Updates the stage and its children.
75
76
  */
76
- override update() {
77
+ public override update() {
77
78
  let i = this.children.length;
78
79
  while (i) {
79
80
  i -= 1;
80
- this.children[i].update();
81
+ this.children[i]!.update();
81
82
  }
82
83
  }
83
84
 
84
85
  /**
85
86
  * Post-updates the stage and its children.
86
87
  */
87
- override postUpdate() {
88
+ public override postUpdate() {
88
89
  for (let i = 0; i < this.children.length; i += 1) {
89
- this.children[i].postUpdate();
90
+ this.children[i]!.postUpdate();
90
91
  }
91
92
  this.updateTransform();
92
93
  }
@@ -94,10 +95,10 @@ export class Stage extends DisplayObject {
94
95
  /**
95
96
  * Updates the stage's transformation matrix.
96
97
  */
97
- override updateTransform(): this {
98
+ public override updateTransform(): this {
98
99
  this.worldAlpha = 1;
99
- for (let i = 0; i < this.children.length; i += 1) {
100
- this.children[i].updateTransform();
100
+ for (const child of this.children) {
101
+ child.updateTransform();
101
102
  }
102
103
  return this;
103
104
  }
@@ -105,7 +106,7 @@ export class Stage extends DisplayObject {
105
106
  /**
106
107
  * Destroys the stage and cleans up resources.
107
108
  */
108
- override destroy() {
109
+ public override destroy() {
109
110
  this.exists = false;
110
111
  this.game = null!;
111
112
  this.worldTransform = null;
@@ -116,14 +117,14 @@ export class Stage extends DisplayObject {
116
117
  * Gets the background color of the stage.
117
118
  * @returns {number} The background color.
118
119
  */
119
- get backgroundColor() {
120
+ public get backgroundColor() {
120
121
  return this._bgColor.color;
121
122
  }
122
123
 
123
124
  /**
124
125
  * Sets the background color of the stage.
125
126
  */
126
- set backgroundColor(value) {
127
+ public set backgroundColor(value) {
127
128
  this.setBackgroundColor(value);
128
129
  }
129
130
 
@@ -131,14 +132,14 @@ export class Stage extends DisplayObject {
131
132
  * Gets whether texture smoothing is enabled.
132
133
  * @returns {boolean} True if texture smoothing is enabled, false otherwise.
133
134
  */
134
- get smoothed() {
135
- return window.PhaserRegistry.TEXTURE_SCALE_MODE === SCALE_LINEAR;
135
+ public get smoothed() {
136
+ return globalThis.PhaserRegistry.TEXTURE_SCALE_MODE === SCALE_LINEAR;
136
137
  }
137
138
 
138
139
  /**
139
140
  * Sets whether texture smoothing is enabled.
140
141
  */
141
- set smoothed(value) {
142
- window.PhaserRegistry.TEXTURE_SCALE_MODE = value ? SCALE_LINEAR : SCALE_NEAREST;
142
+ public set smoothed(value) {
143
+ globalThis.PhaserRegistry.TEXTURE_SCALE_MODE = value ? SCALE_LINEAR : SCALE_NEAREST;
143
144
  }
144
145
  }