@vpmedia/phaser 1.111.0 → 1.113.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 +1300 -1334
  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 +1 -1
  23. package/dist/phaser/core/game.d.ts.map +1 -1
  24. package/dist/phaser/core/input.d.ts +8 -6
  25. package/dist/phaser/core/input.d.ts.map +1 -1
  26. package/dist/phaser/core/input_handler.d.ts +40 -30
  27. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  28. package/dist/phaser/core/input_mouse.d.ts +3 -2
  29. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  30. package/dist/phaser/core/input_mspointer.d.ts +3 -2
  31. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  32. package/dist/phaser/core/input_pointer.d.ts +6 -4
  33. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  34. package/dist/phaser/core/input_touch.d.ts +3 -2
  35. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  36. package/dist/phaser/core/loader.d.ts +4 -3
  37. package/dist/phaser/core/loader.d.ts.map +1 -1
  38. package/dist/phaser/core/loader_parser.d.ts +9 -8
  39. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  40. package/dist/phaser/core/raf.d.ts +3 -2
  41. package/dist/phaser/core/raf.d.ts.map +1 -1
  42. package/dist/phaser/core/registry.d.ts +7 -0
  43. package/dist/phaser/core/registry.d.ts.map +1 -0
  44. package/dist/phaser/core/scale_manager.d.ts +1 -1
  45. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  46. package/dist/phaser/core/scene.d.ts +0 -1
  47. package/dist/phaser/core/scene.d.ts.map +1 -1
  48. package/dist/phaser/core/scene_manager.d.ts +1 -1
  49. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  50. package/dist/phaser/core/signal.d.ts +0 -1
  51. package/dist/phaser/core/signal.d.ts.map +1 -1
  52. package/dist/phaser/core/signal_binding.d.ts +4 -3
  53. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  54. package/dist/phaser/core/sound.d.ts +6 -4
  55. package/dist/phaser/core/sound.d.ts.map +1 -1
  56. package/dist/phaser/core/sound_manager.d.ts +3 -2
  57. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  58. package/dist/phaser/core/sound_sprite.d.ts +5 -4
  59. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  60. package/dist/phaser/core/stage.d.ts +3 -2
  61. package/dist/phaser/core/stage.d.ts.map +1 -1
  62. package/dist/phaser/core/time.d.ts +1 -1
  63. package/dist/phaser/core/time.d.ts.map +1 -1
  64. package/dist/phaser/core/timer.d.ts +1 -1
  65. package/dist/phaser/core/timer.d.ts.map +1 -1
  66. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  67. package/dist/phaser/core/tween.d.ts +10 -7
  68. package/dist/phaser/core/tween.d.ts.map +1 -1
  69. package/dist/phaser/core/tween_data.d.ts +3 -2
  70. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  71. package/dist/phaser/core/tween_easing.d.ts.map +1 -1
  72. package/dist/phaser/core/tween_manager.d.ts +3 -2
  73. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  74. package/dist/phaser/core/world.d.ts +3 -2
  75. package/dist/phaser/core/world.d.ts.map +1 -1
  76. package/dist/phaser/display/bitmap_text.d.ts +3 -2
  77. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  78. package/dist/phaser/display/button.d.ts +3 -2
  79. package/dist/phaser/display/button.d.ts.map +1 -1
  80. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  81. package/dist/phaser/display/canvas/graphics.d.ts +7 -6
  82. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  83. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  84. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  85. package/dist/phaser/display/canvas/renderer.d.ts +10 -8
  86. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  87. package/dist/phaser/display/canvas/tinter.d.ts +3 -2
  88. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  89. package/dist/phaser/display/canvas/util.d.ts +2 -2
  90. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  91. package/dist/phaser/display/display_object.d.ts +14 -12
  92. package/dist/phaser/display/display_object.d.ts.map +1 -1
  93. package/dist/phaser/display/graphics.d.ts +8 -5
  94. package/dist/phaser/display/graphics.d.ts.map +1 -1
  95. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  96. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  97. package/dist/phaser/display/group.d.ts +4 -3
  98. package/dist/phaser/display/group.d.ts.map +1 -1
  99. package/dist/phaser/display/image.d.ts +13 -10
  100. package/dist/phaser/display/image.d.ts.map +1 -1
  101. package/dist/phaser/display/sprite_batch.d.ts +3 -2
  102. package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
  103. package/dist/phaser/display/sprite_util.d.ts +18 -15
  104. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  105. package/dist/phaser/display/text.d.ts +11 -9
  106. package/dist/phaser/display/text.d.ts.map +1 -1
  107. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  108. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  109. package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
  110. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  111. package/dist/phaser/display/webgl/earcut.d.ts +1 -1
  112. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  113. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  114. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
  115. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  116. package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
  117. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  118. package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
  119. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  120. package/dist/phaser/display/webgl/graphics.d.ts +7 -6
  121. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  122. package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
  123. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  124. package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
  125. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  126. package/dist/phaser/display/webgl/renderer.d.ts +16 -11
  127. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  128. package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
  129. package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  130. package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
  131. package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  132. package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
  133. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  134. package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
  135. package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  136. package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
  137. package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  138. package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
  139. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  140. package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
  141. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  142. package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
  143. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  144. package/dist/phaser/display/webgl/texture.d.ts +3 -2
  145. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  146. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  147. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  148. package/dist/phaser/geom/circle.d.ts +4 -1
  149. package/dist/phaser/geom/circle.d.ts.map +1 -1
  150. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  151. package/dist/phaser/geom/line.d.ts +1 -1
  152. package/dist/phaser/geom/line.d.ts.map +1 -1
  153. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  154. package/dist/phaser/geom/point.d.ts.map +1 -1
  155. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  156. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  157. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  158. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  159. package/dist/phaser/geom/util/ellipse.d.ts +3 -2
  160. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  161. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  162. package/dist/phaser/geom/util/matrix.d.ts +2 -2
  163. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  164. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  165. package/dist/phaser/geom/util/rectangle.d.ts +1 -1
  166. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  167. package/dist/phaser/util/math.d.ts.map +1 -1
  168. package/package.json +5 -4
  169. package/src/phaser/core/animation.ts +64 -60
  170. package/src/phaser/core/animation_manager.ts +54 -55
  171. package/src/phaser/core/animation_parser.ts +9 -9
  172. package/src/phaser/core/array_set.ts +16 -17
  173. package/src/phaser/core/cache.ts +92 -93
  174. package/src/phaser/core/const.ts +1 -1
  175. package/src/phaser/core/device.ts +24 -29
  176. package/src/phaser/core/device_util.ts +28 -32
  177. package/src/phaser/core/dom.ts +54 -65
  178. package/src/phaser/core/event_manager.ts +64 -94
  179. package/src/phaser/core/factory.ts +14 -14
  180. package/src/phaser/core/frame.ts +28 -28
  181. package/src/phaser/core/frame_data.test.ts +100 -0
  182. package/src/phaser/core/frame_data.ts +24 -24
  183. package/src/phaser/core/frame_util.ts +2 -2
  184. package/src/phaser/core/game.ts +50 -51
  185. package/src/phaser/core/input.ts +104 -110
  186. package/src/phaser/core/input_handler.test.ts +113 -0
  187. package/src/phaser/core/input_handler.ts +199 -218
  188. package/src/phaser/core/input_mouse.ts +71 -54
  189. package/src/phaser/core/input_mspointer.ts +52 -39
  190. package/src/phaser/core/input_pointer.ts +81 -80
  191. package/src/phaser/core/input_touch.ts +49 -36
  192. package/src/phaser/core/loader.ts +175 -154
  193. package/src/phaser/core/loader_parser.ts +39 -57
  194. package/src/phaser/core/raf.ts +8 -7
  195. package/src/phaser/core/registry.test.ts +31 -0
  196. package/src/phaser/core/registry.ts +9 -0
  197. package/src/phaser/core/scale_manager.ts +156 -152
  198. package/src/phaser/core/scene.ts +9 -13
  199. package/src/phaser/core/scene_manager.ts +47 -47
  200. package/src/phaser/core/signal.test.ts +4 -4
  201. package/src/phaser/core/signal.ts +41 -52
  202. package/src/phaser/core/signal_binding.ts +26 -25
  203. package/src/phaser/core/signal_dispatch.test.ts +180 -0
  204. package/src/phaser/core/sound.ts +75 -83
  205. package/src/phaser/core/sound_manager.ts +58 -56
  206. package/src/phaser/core/sound_sprite.ts +17 -16
  207. package/src/phaser/core/stage.ts +25 -24
  208. package/src/phaser/core/time.ts +52 -52
  209. package/src/phaser/core/timer.test.ts +187 -0
  210. package/src/phaser/core/timer.ts +82 -69
  211. package/src/phaser/core/timer_event.ts +10 -10
  212. package/src/phaser/core/tween.ts +90 -93
  213. package/src/phaser/core/tween_data.ts +45 -51
  214. package/src/phaser/core/tween_easing.test.ts +106 -0
  215. package/src/phaser/core/tween_easing.ts +151 -123
  216. package/src/phaser/core/tween_manager.ts +19 -18
  217. package/src/phaser/core/world.ts +4 -3
  218. package/src/phaser/display/bitmap_text.ts +56 -64
  219. package/src/phaser/display/button.ts +33 -32
  220. package/src/phaser/display/canvas/buffer.ts +8 -8
  221. package/src/phaser/display/canvas/graphics.ts +36 -37
  222. package/src/phaser/display/canvas/masker.ts +2 -2
  223. package/src/phaser/display/canvas/pool.test.ts +106 -0
  224. package/src/phaser/display/canvas/pool.ts +25 -27
  225. package/src/phaser/display/canvas/renderer.ts +32 -31
  226. package/src/phaser/display/canvas/tinter.ts +27 -27
  227. package/src/phaser/display/canvas/util.ts +7 -10
  228. package/src/phaser/display/display_object.ts +114 -118
  229. package/src/phaser/display/graphics.ts +121 -119
  230. package/src/phaser/display/graphics_data.ts +12 -12
  231. package/src/phaser/display/graphics_data_util.ts +2 -3
  232. package/src/phaser/display/group.ts +50 -57
  233. package/src/phaser/display/image.ts +55 -52
  234. package/src/phaser/display/sprite_batch.ts +3 -2
  235. package/src/phaser/display/sprite_util.ts +48 -54
  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,35 +72,35 @@ 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;
81
82
  setAudioDisabledState();
82
83
  const typedError = error instanceof Error ? error : new Error(String(error));
83
- this.game.logger.exception('SoundManager', typedError);
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;
92
93
  setAudioDisabledState();
93
94
  const typedError = error instanceof Error ? error : new Error(String(error));
94
- this.game.logger.exception('SoundManager', typedError);
95
+ this.game.logger.fatal('SoundManager', { error: typedError });
95
96
  }
96
97
  }
97
98
  if (!this.context) {
98
- this.game.logger.exception('SoundManager', new Error(ENGINE_ERROR_CREATING_AUDIO_CONTEXT));
99
+ this.game.logger.fatal('SoundManager', { error: new Error(ENGINE_ERROR_CREATING_AUDIO_CONTEXT) });
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', {
@@ -217,7 +218,8 @@ export class SoundManager {
217
218
  error,
218
219
  });
219
220
  this.removeUnlockHandlers();
220
- this.game.logger.exception('', error, {
221
+ this.game.logger.fatal('SoundManager', {
222
+ error,
221
223
  tags: { 'audio.initialState': initialState, 'audio.state': this.context.state },
222
224
  });
223
225
  });
@@ -226,7 +228,7 @@ export class SoundManager {
226
228
  /**
227
229
  * Stops all sounds in the manager.
228
230
  */
229
- stopAll() {
231
+ public stopAll() {
230
232
  if (this.noAudio) {
231
233
  return;
232
234
  }
@@ -240,7 +242,7 @@ export class SoundManager {
240
242
  /**
241
243
  * Pauses all sounds in the manager.
242
244
  */
243
- pauseAll() {
245
+ public pauseAll() {
244
246
  if (this.noAudio) {
245
247
  return;
246
248
  }
@@ -254,7 +256,7 @@ export class SoundManager {
254
256
  /**
255
257
  * Resumes all sounds in the manager.
256
258
  */
257
- resumeAll() {
259
+ public resumeAll() {
258
260
  if (this.noAudio) {
259
261
  return;
260
262
  }
@@ -269,7 +271,7 @@ export class SoundManager {
269
271
  * Decodes an audio file for playback.
270
272
  * @param {string} key - The key of the sound to decode.
271
273
  */
272
- decode(key: string) {
274
+ public decode(key: string) {
273
275
  const soundData = this.game.cache.getSoundData(key);
274
276
  if (!soundData) {
275
277
  return;
@@ -285,7 +287,7 @@ export class SoundManager {
285
287
  })
286
288
  .catch((error: unknown) => {
287
289
  const typedError = error instanceof Error ? error : new Error(String(error));
288
- this.game.logger.exception('SoundManager', typedError, { tags: { 'asset.key': key } });
290
+ this.game.logger.fatal('SoundManager', { error: typedError, tags: { 'asset.key': key } });
289
291
  if (typedError.name === 'InvalidStateError') {
290
292
  addPageLifecycleCallback(PAGE_LIFECYCLE_STATE_ACTIVE, () => {
291
293
  this.decode(key);
@@ -302,7 +304,7 @@ export class SoundManager {
302
304
  * @param {Function} callback - The callback function to call when all files are decoded.
303
305
  * @param {object} callbackContext - The context in which to call the callback.
304
306
  */
305
- setDecodedCallback(files: any, callback: Function, callbackContext: any) {
307
+ public setDecodedCallback(files: any, callback: Function, callbackContext: any) {
306
308
  if (typeof files === 'string') {
307
309
  files = [files];
308
310
  }
@@ -330,7 +332,7 @@ export class SoundManager {
330
332
  /**
331
333
  * Updates the sound manager state.
332
334
  */
333
- update() {
335
+ public update() {
334
336
  if (this.noAudio) {
335
337
  return;
336
338
  }
@@ -361,7 +363,7 @@ export class SoundManager {
361
363
  * @param {boolean} connect - Whether to connect to the master gain node.
362
364
  * @returns {Sound} The created Sound object.
363
365
  */
364
- 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) {
365
367
  const sound = new Sound(this.game, key, volume, loop, connect);
366
368
  this._sounds.push(sound);
367
369
  return sound;
@@ -372,7 +374,7 @@ export class SoundManager {
372
374
  * @param {string} key - The key of the sound sprite to add.
373
375
  * @returns {SoundSprite} The created SoundSprite object.
374
376
  */
375
- addSprite(key: string) {
377
+ public addSprite(key: string) {
376
378
  return new SoundSprite(this.game, key);
377
379
  }
378
380
 
@@ -381,7 +383,7 @@ export class SoundManager {
381
383
  * @param {Sound | null | undefined} sound - The sound object to remove.
382
384
  * @returns {boolean} True if the sound was removed, false otherwise.
383
385
  */
384
- remove(sound: Sound | null | undefined) {
386
+ public remove(sound: Sound | null | undefined) {
385
387
  let i = this._sounds.length;
386
388
  while (i) {
387
389
  i -= 1;
@@ -399,7 +401,7 @@ export class SoundManager {
399
401
  * @param {string} key - The key of sounds to remove.
400
402
  * @returns {number} The number of sounds removed.
401
403
  */
402
- removeByKey(key: string) {
404
+ public removeByKey(key: string) {
403
405
  let i = this._sounds.length;
404
406
  let removed = 0;
405
407
  while (i) {
@@ -420,7 +422,7 @@ export class SoundManager {
420
422
  * @param {boolean} loop - Whether the sound should loop.
421
423
  * @returns {Sound} The created Sound object, or null if audio is disabled.
422
424
  */
423
- play(key: string, volume: number = 1, loop: boolean = false) {
425
+ public play(key: string, volume = 1, loop = false) {
424
426
  if (this.noAudio) {
425
427
  return null;
426
428
  }
@@ -432,7 +434,7 @@ export class SoundManager {
432
434
  /**
433
435
  * Mutes all sounds in the manager.
434
436
  */
435
- setMute() {
437
+ public setMute() {
436
438
  if (this._muted) {
437
439
  return;
438
440
  }
@@ -447,7 +449,7 @@ export class SoundManager {
447
449
  /**
448
450
  * Unmutes all sounds in the manager.
449
451
  */
450
- unsetMute() {
452
+ public unsetMute() {
451
453
  if (!this._muted || this._codeMuted) {
452
454
  return;
453
455
  }
@@ -461,7 +463,7 @@ export class SoundManager {
461
463
  /**
462
464
  * Destroys the sound manager and cleans up resources.
463
465
  */
464
- destroy() {
466
+ public destroy() {
465
467
  this.stopAll();
466
468
  for (let i = 0; i < this._sounds.length; i += 1) {
467
469
  if (this._sounds[i]) {
@@ -479,14 +481,14 @@ export class SoundManager {
479
481
  * Gets the muted state of the sound manager.
480
482
  * @returns {boolean} True if the manager is muted, false otherwise.
481
483
  */
482
- get mute() {
484
+ public get mute() {
483
485
  return this._muted;
484
486
  }
485
487
 
486
488
  /**
487
489
  * Sets the muted state of the sound manager.
488
490
  */
489
- set mute(value) {
491
+ public set mute(value) {
490
492
  if (value || false) {
491
493
  if (this._muted) {
492
494
  return;
@@ -506,14 +508,14 @@ export class SoundManager {
506
508
  * Gets the volume level of the sound manager.
507
509
  * @returns {number} The volume level (0.0 to 1.0).
508
510
  */
509
- get volume() {
511
+ public get volume() {
510
512
  return this._volume;
511
513
  }
512
514
 
513
515
  /**
514
516
  * Sets the volume level of the sound manager.
515
517
  */
516
- set volume(value) {
518
+ public set volume(value) {
517
519
  if (value < 0) {
518
520
  value = 0;
519
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
  }