@vpmedia/phaser 1.103.0 → 1.105.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 (298) hide show
  1. package/dist/index.js +997 -403
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts +35 -11
  4. package/dist/phaser/core/animation.d.ts.map +1 -1
  5. package/dist/phaser/core/animation_manager.d.ts +20 -10
  6. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  7. package/dist/phaser/core/animation_parser.d.ts +2 -2
  8. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  9. package/dist/phaser/core/array_set.d.ts +3 -3
  10. package/dist/phaser/core/array_set.d.ts.map +1 -1
  11. package/dist/phaser/core/cache.d.ts +68 -60
  12. package/dist/phaser/core/cache.d.ts.map +1 -1
  13. package/dist/phaser/core/device.d.ts +23 -0
  14. package/dist/phaser/core/device.d.ts.map +1 -1
  15. package/dist/phaser/core/device_util.d.ts +10 -10
  16. package/dist/phaser/core/device_util.d.ts.map +1 -1
  17. package/dist/phaser/core/dom.d.ts +6 -5
  18. package/dist/phaser/core/dom.d.ts.map +1 -1
  19. package/dist/phaser/core/event_manager.d.ts +49 -158
  20. package/dist/phaser/core/event_manager.d.ts.map +1 -1
  21. package/dist/phaser/core/factory.d.ts +8 -7
  22. package/dist/phaser/core/factory.d.ts.map +1 -1
  23. package/dist/phaser/core/frame.d.ts +27 -48
  24. package/dist/phaser/core/frame.d.ts.map +1 -1
  25. package/dist/phaser/core/frame_data.d.ts +11 -58
  26. package/dist/phaser/core/frame_data.d.ts.map +1 -1
  27. package/dist/phaser/core/frame_util.d.ts +4 -14
  28. package/dist/phaser/core/frame_util.d.ts.map +1 -1
  29. package/dist/phaser/core/game.d.ts +50 -3
  30. package/dist/phaser/core/game.d.ts.map +1 -1
  31. package/dist/phaser/core/input.d.ts +66 -13
  32. package/dist/phaser/core/input.d.ts.map +1 -1
  33. package/dist/phaser/core/input_handler.d.ts +64 -20
  34. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  35. package/dist/phaser/core/input_mouse.d.ts +26 -1
  36. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  37. package/dist/phaser/core/input_mspointer.d.ts +18 -2
  38. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  39. package/dist/phaser/core/input_pointer.d.ts +53 -9
  40. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  41. package/dist/phaser/core/input_touch.d.ts +19 -1
  42. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  43. package/dist/phaser/core/loader.d.ts +56 -28
  44. package/dist/phaser/core/loader.d.ts.map +1 -1
  45. package/dist/phaser/core/loader_parser.d.ts +4 -4
  46. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  47. package/dist/phaser/core/raf.d.ts +2 -2
  48. package/dist/phaser/core/raf.d.ts.map +1 -1
  49. package/dist/phaser/core/scale_manager.d.ts +77 -17
  50. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  51. package/dist/phaser/core/scene.d.ts +3 -1
  52. package/dist/phaser/core/scene.d.ts.map +1 -1
  53. package/dist/phaser/core/scene_manager.d.ts +25 -9
  54. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  55. package/dist/phaser/core/signal.d.ts +9 -8
  56. package/dist/phaser/core/signal.d.ts.map +1 -1
  57. package/dist/phaser/core/signal_binding.d.ts +2 -2
  58. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  59. package/dist/phaser/core/sound.d.ts +58 -10
  60. package/dist/phaser/core/sound.d.ts.map +1 -1
  61. package/dist/phaser/core/sound_manager.d.ts +28 -9
  62. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  63. package/dist/phaser/core/sound_sprite.d.ts +10 -4
  64. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  65. package/dist/phaser/core/stage.d.ts +7 -3
  66. package/dist/phaser/core/stage.d.ts.map +1 -1
  67. package/dist/phaser/core/time.d.ts +32 -5
  68. package/dist/phaser/core/time.d.ts.map +1 -1
  69. package/dist/phaser/core/timer.d.ts +30 -10
  70. package/dist/phaser/core/timer.d.ts.map +1 -1
  71. package/dist/phaser/core/timer_event.d.ts +11 -12
  72. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  73. package/dist/phaser/core/tween.d.ts +38 -14
  74. package/dist/phaser/core/tween.d.ts.map +1 -1
  75. package/dist/phaser/core/tween_data.d.ts +30 -5
  76. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  77. package/dist/phaser/core/tween_easing.d.ts +31 -31
  78. package/dist/phaser/core/tween_easing.d.ts.map +1 -1
  79. package/dist/phaser/core/tween_manager.d.ts +8 -4
  80. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  81. package/dist/phaser/core/world.d.ts +1 -1
  82. package/dist/phaser/core/world.d.ts.map +1 -1
  83. package/dist/phaser/display/bitmap_text.d.ts +35 -20
  84. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  85. package/dist/phaser/display/button.d.ts +24 -8
  86. package/dist/phaser/display/button.d.ts.map +1 -1
  87. package/dist/phaser/display/canvas/buffer.d.ts +6 -2
  88. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  89. package/dist/phaser/display/canvas/graphics.d.ts +3 -3
  90. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  91. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  92. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  93. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  94. package/dist/phaser/display/canvas/renderer.d.ts +18 -5
  95. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  96. package/dist/phaser/display/canvas/tinter.d.ts +3 -3
  97. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  98. package/dist/phaser/display/canvas/util.d.ts +9 -9
  99. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  100. package/dist/phaser/display/display_object.d.ts +82 -23
  101. package/dist/phaser/display/display_object.d.ts.map +1 -1
  102. package/dist/phaser/display/graphics.d.ts +42 -16
  103. package/dist/phaser/display/graphics.d.ts.map +1 -1
  104. package/dist/phaser/display/graphics_data.d.ts +11 -1
  105. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  106. package/dist/phaser/display/graphics_data_util.d.ts +1 -1
  107. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  108. package/dist/phaser/display/group.d.ts +24 -9
  109. package/dist/phaser/display/group.d.ts.map +1 -1
  110. package/dist/phaser/display/image.d.ts +36 -13
  111. package/dist/phaser/display/image.d.ts.map +1 -1
  112. package/dist/phaser/display/sprite_batch.d.ts +1 -1
  113. package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
  114. package/dist/phaser/display/sprite_util.d.ts +5 -5
  115. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  116. package/dist/phaser/display/text.d.ts +86 -66
  117. package/dist/phaser/display/text.d.ts.map +1 -1
  118. package/dist/phaser/display/webgl/abstract_filter.d.ts +8 -1
  119. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  120. package/dist/phaser/display/webgl/base_texture.d.ts +14 -2
  121. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  122. package/dist/phaser/display/webgl/blend_manager.d.ts +5 -2
  123. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  124. package/dist/phaser/display/webgl/earcut.d.ts +10 -10
  125. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  126. package/dist/phaser/display/webgl/earcut_node.d.ts +1 -1
  127. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  128. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +17 -1
  129. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  130. package/dist/phaser/display/webgl/filter_manager.d.ts +5 -1
  131. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  132. package/dist/phaser/display/webgl/filter_texture.d.ts +7 -2
  133. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  134. package/dist/phaser/display/webgl/graphics.d.ts +11 -10
  135. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  136. package/dist/phaser/display/webgl/graphics_data.d.ts +11 -1
  137. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  138. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  139. package/dist/phaser/display/webgl/render_texture.d.ts +12 -1
  140. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  141. package/dist/phaser/display/webgl/renderer.d.ts +25 -6
  142. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  143. package/dist/phaser/display/webgl/shader/complex.d.ts +7 -1
  144. package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  145. package/dist/phaser/display/webgl/shader/fast.d.ts +8 -1
  146. package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  147. package/dist/phaser/display/webgl/shader/normal.d.ts +11 -0
  148. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  149. package/dist/phaser/display/webgl/shader/primitive.d.ts +7 -1
  150. package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  151. package/dist/phaser/display/webgl/shader/strip.d.ts +7 -1
  152. package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  153. package/dist/phaser/display/webgl/shader_manager.d.ts +14 -2
  154. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  155. package/dist/phaser/display/webgl/sprite_batch.d.ts +19 -2
  156. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  157. package/dist/phaser/display/webgl/stencil_manager.d.ts +8 -4
  158. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  159. package/dist/phaser/display/webgl/texture.d.ts +35 -2
  160. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  161. package/dist/phaser/display/webgl/texture_util.d.ts +2 -2
  162. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  163. package/dist/phaser/display/webgl/util.d.ts +6 -6
  164. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  165. package/dist/phaser/geom/circle.d.ts +11 -10
  166. package/dist/phaser/geom/circle.d.ts.map +1 -1
  167. package/dist/phaser/geom/ellipse.d.ts +6 -5
  168. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  169. package/dist/phaser/geom/line.d.ts +14 -14
  170. package/dist/phaser/geom/line.d.ts.map +1 -1
  171. package/dist/phaser/geom/matrix.d.ts +13 -12
  172. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  173. package/dist/phaser/geom/point.d.ts +19 -19
  174. package/dist/phaser/geom/point.d.ts.map +1 -1
  175. package/dist/phaser/geom/polygon.d.ts +6 -6
  176. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  177. package/dist/phaser/geom/rectangle.d.ts +20 -20
  178. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  179. package/dist/phaser/geom/rounded_rectangle.d.ts +2 -2
  180. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  181. package/dist/phaser/geom/util/circle.d.ts +9 -7
  182. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  183. package/dist/phaser/geom/util/ellipse.d.ts +1 -1
  184. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  185. package/dist/phaser/geom/util/line.d.ts +5 -3
  186. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  187. package/dist/phaser/geom/util/matrix.d.ts +2 -1
  188. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  189. package/dist/phaser/geom/util/point.d.ts +19 -19
  190. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  191. package/dist/phaser/geom/util/polygon.d.ts +2 -1
  192. package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
  193. package/dist/phaser/geom/util/rectangle.d.ts +17 -15
  194. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  195. package/dist/phaser/geom/util/rounded_rectangle.d.ts +2 -1
  196. package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  197. package/dist/phaser/util/math.d.ts +51 -142
  198. package/dist/phaser/util/math.d.ts.map +1 -1
  199. package/package.json +2 -2
  200. package/src/phaser/core/animation.ts +41 -18
  201. package/src/phaser/core/animation_manager.ts +21 -12
  202. package/src/phaser/core/animation_parser.ts +11 -3
  203. package/src/phaser/core/array_set.ts +8 -8
  204. package/src/phaser/core/cache.ts +75 -60
  205. package/src/phaser/core/device.ts +23 -1
  206. package/src/phaser/core/device_util.ts +10 -10
  207. package/src/phaser/core/dom.ts +5 -5
  208. package/src/phaser/core/event_manager.ts +52 -177
  209. package/src/phaser/core/factory.ts +25 -17
  210. package/src/phaser/core/frame.ts +37 -51
  211. package/src/phaser/core/frame_data.ts +29 -74
  212. package/src/phaser/core/frame_util.ts +3 -16
  213. package/src/phaser/core/game.ts +40 -11
  214. package/src/phaser/core/input.ts +68 -17
  215. package/src/phaser/core/input_handler.ts +81 -45
  216. package/src/phaser/core/input_mouse.ts +42 -13
  217. package/src/phaser/core/input_mspointer.ts +24 -9
  218. package/src/phaser/core/input_pointer.ts +55 -12
  219. package/src/phaser/core/input_touch.ts +26 -9
  220. package/src/phaser/core/loader.ts +97 -42
  221. package/src/phaser/core/loader_parser.ts +6 -7
  222. package/src/phaser/core/raf.ts +2 -2
  223. package/src/phaser/core/scale_manager.ts +85 -27
  224. package/src/phaser/core/scene.ts +3 -2
  225. package/src/phaser/core/scene_manager.ts +26 -11
  226. package/src/phaser/core/signal.ts +10 -10
  227. package/src/phaser/core/signal_binding.ts +2 -2
  228. package/src/phaser/core/sound.ts +72 -26
  229. package/src/phaser/core/sound_manager.ts +31 -13
  230. package/src/phaser/core/sound_sprite.ts +10 -5
  231. package/src/phaser/core/stage.ts +8 -4
  232. package/src/phaser/core/time.ts +33 -7
  233. package/src/phaser/core/timer.ts +40 -14
  234. package/src/phaser/core/timer_event.ts +23 -14
  235. package/src/phaser/core/tween.ts +43 -23
  236. package/src/phaser/core/tween_data.ts +31 -7
  237. package/src/phaser/core/tween_easing.ts +31 -31
  238. package/src/phaser/core/tween_manager.ts +10 -7
  239. package/src/phaser/core/world.ts +1 -2
  240. package/src/phaser/display/bitmap_text.ts +41 -18
  241. package/src/phaser/display/button.ts +24 -23
  242. package/src/phaser/display/canvas/buffer.ts +6 -3
  243. package/src/phaser/display/canvas/graphics.ts +3 -4
  244. package/src/phaser/display/canvas/masker.ts +2 -3
  245. package/src/phaser/display/canvas/pool.ts +3 -4
  246. package/src/phaser/display/canvas/renderer.ts +19 -7
  247. package/src/phaser/display/canvas/tinter.ts +4 -5
  248. package/src/phaser/display/canvas/util.ts +9 -9
  249. package/src/phaser/display/display_object.ts +120 -61
  250. package/src/phaser/display/graphics.ts +56 -25
  251. package/src/phaser/display/graphics_data.ts +11 -2
  252. package/src/phaser/display/graphics_data_util.ts +1 -2
  253. package/src/phaser/display/group.ts +32 -14
  254. package/src/phaser/display/image.ts +37 -19
  255. package/src/phaser/display/sprite_batch.ts +1 -2
  256. package/src/phaser/display/sprite_util.ts +5 -6
  257. package/src/phaser/display/text.ts +82 -56
  258. package/src/phaser/display/webgl/abstract_filter.ts +8 -2
  259. package/src/phaser/display/webgl/base_texture.ts +14 -3
  260. package/src/phaser/display/webgl/blend_manager.ts +5 -3
  261. package/src/phaser/display/webgl/earcut.ts +27 -27
  262. package/src/phaser/display/webgl/earcut_node.ts +1 -1
  263. package/src/phaser/display/webgl/fast_sprite_batch.ts +19 -4
  264. package/src/phaser/display/webgl/filter_manager.ts +5 -2
  265. package/src/phaser/display/webgl/filter_texture.ts +7 -3
  266. package/src/phaser/display/webgl/graphics.ts +10 -11
  267. package/src/phaser/display/webgl/graphics_data.ts +11 -2
  268. package/src/phaser/display/webgl/mask_manager.ts +2 -3
  269. package/src/phaser/display/webgl/render_texture.ts +12 -2
  270. package/src/phaser/display/webgl/renderer.ts +24 -7
  271. package/src/phaser/display/webgl/shader/complex.ts +7 -2
  272. package/src/phaser/display/webgl/shader/fast.ts +8 -2
  273. package/src/phaser/display/webgl/shader/normal.ts +12 -2
  274. package/src/phaser/display/webgl/shader/primitive.ts +7 -2
  275. package/src/phaser/display/webgl/shader/strip.ts +7 -2
  276. package/src/phaser/display/webgl/shader_manager.ts +13 -3
  277. package/src/phaser/display/webgl/sprite_batch.ts +20 -4
  278. package/src/phaser/display/webgl/stencil_manager.ts +8 -5
  279. package/src/phaser/display/webgl/texture.ts +35 -4
  280. package/src/phaser/display/webgl/texture_util.ts +2 -3
  281. package/src/phaser/display/webgl/util.ts +6 -6
  282. package/src/phaser/geom/circle.ts +10 -10
  283. package/src/phaser/geom/ellipse.ts +6 -6
  284. package/src/phaser/geom/line.ts +14 -14
  285. package/src/phaser/geom/matrix.ts +12 -12
  286. package/src/phaser/geom/point.ts +19 -19
  287. package/src/phaser/geom/polygon.ts +5 -5
  288. package/src/phaser/geom/rectangle.ts +21 -21
  289. package/src/phaser/geom/rounded_rectangle.ts +2 -2
  290. package/src/phaser/geom/util/circle.ts +7 -7
  291. package/src/phaser/geom/util/ellipse.ts +1 -1
  292. package/src/phaser/geom/util/line.ts +5 -5
  293. package/src/phaser/geom/util/matrix.ts +1 -1
  294. package/src/phaser/geom/util/point.ts +20 -20
  295. package/src/phaser/geom/util/polygon.ts +1 -1
  296. package/src/phaser/geom/util/rectangle.ts +15 -15
  297. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
  298. package/src/phaser/util/math.ts +65 -151
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  import { BaseTexture } from '../display/webgl/base_texture.js';
3
2
  import { Texture } from '../display/webgl/texture.js';
4
3
  import { JSONDataHash } from './animation_parser.js';
@@ -19,11 +18,19 @@ export const XML = 8;
19
18
  export const RENDER_TEXTURE = 9;
20
19
 
21
20
  export class Cache {
21
+ game!: any;
22
+ autoResolveURL!: any;
23
+ _cache!: any;
24
+ _urlMap!: any;
25
+ _urlResolver!: any;
26
+ _urlTemp!: any;
27
+ onSoundUnlock!: any;
28
+ _cacheMap!: any;
22
29
  /**
23
30
  * Creates a new Cache instance.
24
31
  * @param {import('./game.js').Game} game - The game instance.
25
32
  */
26
- constructor(game) {
33
+ constructor(game: import('./game.js').Game) {
27
34
  this.game = game;
28
35
  this.autoResolveURL = false;
29
36
  this._cache = {
@@ -87,7 +94,7 @@ export class Cache {
87
94
  * @param {HTMLImageElement} data - The image data to cache.
88
95
  * @returns {object} The cached image object.
89
96
  */
90
- addImage(key, url, data) {
97
+ addImage(key: string, url: string, data: HTMLImageElement) {
91
98
  if (this.checkImageKey(key)) {
92
99
  this.removeImage(key);
93
100
  }
@@ -115,8 +122,8 @@ export class Cache {
115
122
  * @param {HTMLCanvasElement} data - The canvas data for the atlas.
116
123
  * @param {object} atlasData - The atlas data to cache.
117
124
  */
118
- addTextureAtlas(key, url, data, atlasData) {
119
- const obj = {
125
+ addTextureAtlas(key: string, url: string, data: HTMLCanvasElement, atlasData: any) {
126
+ const obj: any = {
120
127
  key,
121
128
  url,
122
129
  data,
@@ -133,7 +140,7 @@ export class Cache {
133
140
  * @param {string} url - The URL the sound was loaded from.
134
141
  * @param {object} data - The sound data to cache.
135
142
  */
136
- addSound(key, url, data) {
143
+ addSound(key: string, url: string, data: any) {
137
144
  this._cache.sound[key] = {
138
145
  url,
139
146
  data,
@@ -149,7 +156,7 @@ export class Cache {
149
156
  * @param {string} url - The URL the text was loaded from.
150
157
  * @param {string} data - The text data to cache.
151
158
  */
152
- addText(key, url, data) {
159
+ addText(key: string, url: string, data: string) {
153
160
  this._cache.text[key] = { url, data };
154
161
  this._resolveURL(url, this._cache.text[key]);
155
162
  }
@@ -164,7 +171,15 @@ export class Cache {
164
171
  * @param {number} xSpacing - Horizontal spacing between characters.
165
172
  * @param {number} ySpacing - Vertical spacing between characters.
166
173
  */
167
- addBitmapFont(key, url, data, atlasData, atlasType, xSpacing = 0, ySpacing = 0) {
174
+ addBitmapFont(
175
+ key: string,
176
+ url: string,
177
+ data: HTMLCanvasElement,
178
+ atlasData: any,
179
+ atlasType: string,
180
+ xSpacing: number = 0,
181
+ ySpacing: number = 0
182
+ ) {
168
183
  const obj = {
169
184
  url,
170
185
  data,
@@ -186,7 +201,7 @@ export class Cache {
186
201
  * @param {string} url - The URL the JSON was loaded from.
187
202
  * @param {object} data - The JSON data to cache.
188
203
  */
189
- addJSON(key, url, data) {
204
+ addJSON(key: string, url: string, data: any) {
190
205
  this._cache.json[key] = { url, data };
191
206
  this._resolveURL(url, this._cache.json[key]);
192
207
  }
@@ -197,7 +212,7 @@ export class Cache {
197
212
  * @param {string} url - The URL the XML was loaded from.
198
213
  * @param {XMLDocument} data - The XML data to cache.
199
214
  */
200
- addXML(key, url, data) {
215
+ addXML(key: string, url: string, data: XMLDocument) {
201
216
  this._cache.xml[key] = { url, data };
202
217
  this._resolveURL(url, this._cache.xml[key]);
203
218
  }
@@ -210,7 +225,7 @@ export class Cache {
210
225
  * @param {string} property - The property to update.
211
226
  * @param {any} value - The new value for the property.
212
227
  */
213
- updateSound(key, property, value) {
228
+ updateSound(key: string, property: string, value: any) {
214
229
  const sound = this.getSound(key);
215
230
  if (sound) {
216
231
  sound[property] = value;
@@ -222,7 +237,7 @@ export class Cache {
222
237
  * @param {string} key - The unique key for the cached sound.
223
238
  * @param {AudioBuffer} data - The decoded audio buffer.
224
239
  */
225
- decodedSound(key, data) {
240
+ decodedSound(key: string, data: AudioBuffer) {
226
241
  const sound = this.getSound(key);
227
242
  sound.data = data;
228
243
  sound.decoded = true;
@@ -234,7 +249,7 @@ export class Cache {
234
249
  * @param {string} key - The unique key for the cached sound.
235
250
  * @returns {boolean} True if the sound is decoded, false otherwise.
236
251
  */
237
- isSoundDecoded(key) {
252
+ isSoundDecoded(key: string) {
238
253
  const sound = this.getItem(key, SOUND, 'isSoundDecoded');
239
254
  if (sound) {
240
255
  return sound.decoded;
@@ -247,7 +262,7 @@ export class Cache {
247
262
  * @param {string} key - The unique key for the cached sound.
248
263
  * @returns {boolean} True if the sound is ready, false otherwise.
249
264
  */
250
- isSoundReady(key) {
265
+ isSoundReady(key: string) {
251
266
  const sound = this.getItem(key, SOUND, 'isSoundDecoded');
252
267
  if (sound) {
253
268
  return sound.decoded && !this.game.sound.isLocked;
@@ -263,7 +278,7 @@ export class Cache {
263
278
  * @param {string} key - The unique key for the cache entry.
264
279
  * @returns {boolean} True if the entry exists, false otherwise.
265
280
  */
266
- checkKey(cache, key) {
281
+ checkKey(cache: number, key: string) {
267
282
  if (this._cacheMap[cache][key]) {
268
283
  return true;
269
284
  }
@@ -275,7 +290,7 @@ export class Cache {
275
290
  * @param {string} url - The URL to check.
276
291
  * @returns {boolean} True if the URL has been resolved and cached, false otherwise.
277
292
  */
278
- checkURL(url) {
293
+ checkURL(url: string) {
279
294
  if (this._urlMap[this._resolveURL(url)]) {
280
295
  return true;
281
296
  }
@@ -287,7 +302,7 @@ export class Cache {
287
302
  * @param {string} key - The unique key for the cache entry.
288
303
  * @returns {boolean} True if the entry exists, false otherwise.
289
304
  */
290
- checkCanvasKey(key) {
305
+ checkCanvasKey(key: string) {
291
306
  return this.checkKey(CANVAS, key);
292
307
  }
293
308
 
@@ -296,7 +311,7 @@ export class Cache {
296
311
  * @param {string} key - The unique key for the cache entry.
297
312
  * @returns {boolean} True if the entry exists, false otherwise.
298
313
  */
299
- checkImageKey(key) {
314
+ checkImageKey(key: string) {
300
315
  return this.checkKey(IMAGE, key);
301
316
  }
302
317
 
@@ -305,7 +320,7 @@ export class Cache {
305
320
  * @param {string} key - The unique key for the cache entry.
306
321
  * @returns {boolean} True if the entry exists, false otherwise.
307
322
  */
308
- checkTextureKey(key) {
323
+ checkTextureKey(key: string) {
309
324
  return this.checkKey(TEXTURE, key);
310
325
  }
311
326
 
@@ -314,7 +329,7 @@ export class Cache {
314
329
  * @param {string} key - The unique key for the cache entry.
315
330
  * @returns {boolean} True if the entry exists, false otherwise.
316
331
  */
317
- checkSoundKey(key) {
332
+ checkSoundKey(key: string) {
318
333
  return this.checkKey(SOUND, key);
319
334
  }
320
335
 
@@ -323,7 +338,7 @@ export class Cache {
323
338
  * @param {string} key - The unique key for the cache entry.
324
339
  * @returns {boolean} True if the entry exists, false otherwise.
325
340
  */
326
- checkTextKey(key) {
341
+ checkTextKey(key: string) {
327
342
  return this.checkKey(TEXT, key);
328
343
  }
329
344
 
@@ -332,7 +347,7 @@ export class Cache {
332
347
  * @param {string} key - The unique key for the cache entry.
333
348
  * @returns {boolean} True if the entry exists, false otherwise.
334
349
  */
335
- checkBitmapDataKey(key) {
350
+ checkBitmapDataKey(key: string) {
336
351
  return this.checkKey(BITMAPDATA, key);
337
352
  }
338
353
 
@@ -341,7 +356,7 @@ export class Cache {
341
356
  * @param {string} key - The unique key for the cache entry.
342
357
  * @returns {boolean} True if the entry exists, false otherwise.
343
358
  */
344
- checkBitmapFontKey(key) {
359
+ checkBitmapFontKey(key: string) {
345
360
  return this.checkKey(BITMAPFONT, key);
346
361
  }
347
362
 
@@ -350,7 +365,7 @@ export class Cache {
350
365
  * @param {string} key - The unique key for the cache entry.
351
366
  * @returns {boolean} True if the entry exists, false otherwise.
352
367
  */
353
- checkJSONKey(key) {
368
+ checkJSONKey(key: string) {
354
369
  return this.checkKey(JSONDATA, key);
355
370
  }
356
371
 
@@ -359,7 +374,7 @@ export class Cache {
359
374
  * @param {string} key - The unique key for the cache entry.
360
375
  * @returns {boolean} True if the entry exists, false otherwise.
361
376
  */
362
- checkXMLKey(key) {
377
+ checkXMLKey(key: string) {
363
378
  return this.checkKey(XML, key);
364
379
  }
365
380
 
@@ -373,7 +388,7 @@ export class Cache {
373
388
  * @param {string} property - TBD.
374
389
  * @returns {*} TBD.
375
390
  */
376
- getItem(key, cache, method, property = null) {
391
+ getItem(key: string, cache: number, method: string, property: string = null) {
377
392
  if (this.checkKey(cache, key)) {
378
393
  if (!property) {
379
394
  return this._cacheMap[cache][key];
@@ -388,7 +403,7 @@ export class Cache {
388
403
  * @param {string} key - TBD.
389
404
  * @returns {HTMLCanvasElement} TBD.
390
405
  */
391
- getCanvas(key) {
406
+ getCanvas(key: string) {
392
407
  return this.getItem(key, CANVAS, 'getCanvas', 'canvas');
393
408
  }
394
409
 
@@ -398,7 +413,7 @@ export class Cache {
398
413
  * @param {boolean} full - TBD.
399
414
  * @returns {HTMLImageElement} TBD.
400
415
  */
401
- getImage(key = '__default', full = false) {
416
+ getImage(key: any = '__default', full: boolean = false) {
402
417
  let img = this.getItem(key, IMAGE, 'getImage');
403
418
  if (img === null) {
404
419
  img = this.getItem('__missing', IMAGE, 'getImage');
@@ -414,7 +429,7 @@ export class Cache {
414
429
  * @param {string} key - TBD.
415
430
  * @returns {object} TBD.
416
431
  */
417
- getTextureFrame(key) {
432
+ getTextureFrame(key: string) {
418
433
  return this.getItem(key, TEXTURE, 'getTextureFrame', 'frame');
419
434
  }
420
435
 
@@ -423,7 +438,7 @@ export class Cache {
423
438
  * @param {string} key - TBD.
424
439
  * @returns {object} TBD.
425
440
  */
426
- getSound(key) {
441
+ getSound(key: string) {
427
442
  return this.getItem(key, SOUND, 'getSound');
428
443
  }
429
444
 
@@ -432,7 +447,7 @@ export class Cache {
432
447
  * @param {string} key - TBD.
433
448
  * @returns {object} TBD.
434
449
  */
435
- getSoundData(key) {
450
+ getSoundData(key: string) {
436
451
  return this.getItem(key, SOUND, 'getSoundData', 'data');
437
452
  }
438
453
 
@@ -441,7 +456,7 @@ export class Cache {
441
456
  * @param {string} key - TBD.
442
457
  * @returns {object} TBD.
443
458
  */
444
- getText(key) {
459
+ getText(key: string) {
445
460
  return this.getItem(key, TEXT, 'getText', 'data');
446
461
  }
447
462
 
@@ -450,7 +465,7 @@ export class Cache {
450
465
  * @param {string} key - TBD.
451
466
  * @returns {object} TBD.
452
467
  */
453
- getBitmapData(key) {
468
+ getBitmapData(key: string) {
454
469
  return this.getItem(key, BITMAPDATA, 'getBitmapData', 'data');
455
470
  }
456
471
 
@@ -459,7 +474,7 @@ export class Cache {
459
474
  * @param {string} key - TBD.
460
475
  * @returns {object} TBD.
461
476
  */
462
- getBitmapFont(key) {
477
+ getBitmapFont(key: string) {
463
478
  return this.getItem(key, BITMAPFONT, 'getBitmapFont');
464
479
  }
465
480
 
@@ -469,7 +484,7 @@ export class Cache {
469
484
  * @param {boolean} isClone - TBD.
470
485
  * @returns {object} TBD.
471
486
  */
472
- getJSON(key, isClone = false) {
487
+ getJSON(key: string, isClone: boolean = false) {
473
488
  const data = this.getItem(key, JSONDATA, 'getJSON', 'data');
474
489
  return isClone ? JSON.parse(JSON.stringify(data)) : data;
475
490
  }
@@ -479,7 +494,7 @@ export class Cache {
479
494
  * @param {string} key - TBD.
480
495
  * @returns {XMLDocument} TBD.
481
496
  */
482
- getXML(key) {
497
+ getXML(key: string) {
483
498
  return this.getItem(key, XML, 'getXML', 'data');
484
499
  }
485
500
 
@@ -488,7 +503,7 @@ export class Cache {
488
503
  * @param {string} key - TBD.
489
504
  * @returns {import('../display/webgl/render_texture.js').RenderTexture} TBD.
490
505
  */
491
- getRenderTexture(key) {
506
+ getRenderTexture(key: string) {
492
507
  return this.getItem(key, RENDER_TEXTURE, 'getRenderTexture');
493
508
  }
494
509
 
@@ -500,7 +515,7 @@ export class Cache {
500
515
  * @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
501
516
  * @returns {BaseTexture} The base texture.
502
517
  */
503
- getBaseTexture(key, cache = IMAGE) {
518
+ getBaseTexture(key: string, cache: number = IMAGE) {
504
519
  return this.getItem(key, cache, 'getBaseTexture', 'base');
505
520
  }
506
521
 
@@ -510,7 +525,7 @@ export class Cache {
510
525
  * @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
511
526
  * @returns {Frame} The frame.
512
527
  */
513
- getFrame(key, cache = IMAGE) {
528
+ getFrame(key: string, cache: number = IMAGE) {
514
529
  return this.getItem(key, cache, 'getFrame', 'frame');
515
530
  }
516
531
 
@@ -520,7 +535,7 @@ export class Cache {
520
535
  * @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
521
536
  * @returns {number} The number of frames.
522
537
  */
523
- getFrameCount(key, cache = IMAGE) {
538
+ getFrameCount(key: string, cache: number = IMAGE) {
524
539
  const data = this.getFrameData(key, cache);
525
540
  if (data) {
526
541
  return data.total;
@@ -534,7 +549,7 @@ export class Cache {
534
549
  * @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
535
550
  * @returns {FrameData} The frame data.
536
551
  */
537
- getFrameData(key, cache = IMAGE) {
552
+ getFrameData(key: string, cache: number = IMAGE) {
538
553
  return this.getItem(key, cache, 'getFrameData', 'frameData');
539
554
  }
540
555
 
@@ -544,7 +559,7 @@ export class Cache {
544
559
  * @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
545
560
  * @returns {boolean} True if the entry has frame data, false otherwise.
546
561
  */
547
- hasFrameData(key, cache = IMAGE) {
562
+ hasFrameData(key: string, cache: number = IMAGE) {
548
563
  return this.getItem(key, cache, '', 'frameData') !== null;
549
564
  }
550
565
 
@@ -554,7 +569,7 @@ export class Cache {
554
569
  * @param {FrameData} frameData - The new frame data.
555
570
  * @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
556
571
  */
557
- updateFrameData(key, frameData, cache = IMAGE) {
572
+ updateFrameData(key: string, frameData: FrameData, cache: number = IMAGE) {
558
573
  if (this._cacheMap[cache][key]) {
559
574
  this._cacheMap[cache][key].frameData = frameData;
560
575
  }
@@ -567,7 +582,7 @@ export class Cache {
567
582
  * @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
568
583
  * @returns {Frame} The frame at the specified index.
569
584
  */
570
- getFrameByIndex(key, index, cache = IMAGE) {
585
+ getFrameByIndex(key: string, index: number, cache: number = IMAGE) {
571
586
  const data = this.getFrameData(key, cache);
572
587
  if (data) {
573
588
  return data.getFrame(index);
@@ -582,7 +597,7 @@ export class Cache {
582
597
  * @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
583
598
  * @returns {Frame} The frame with the specified name.
584
599
  */
585
- getFrameByName(key, name, cache = IMAGE) {
600
+ getFrameByName(key: string, name: string, cache: number = IMAGE) {
586
601
  const data = this.getFrameData(key, cache);
587
602
  if (data) {
588
603
  return data.getFrameByName(name);
@@ -595,7 +610,7 @@ export class Cache {
595
610
  * @param {string} url - The original URL to resolve.
596
611
  * @returns {string} The resolved URL or null if not found.
597
612
  */
598
- getURL(url) {
613
+ getURL(url: string) {
599
614
  const resolvedURL = this._resolveURL(url);
600
615
  if (resolvedURL) {
601
616
  return this._urlMap[resolvedURL];
@@ -609,7 +624,7 @@ export class Cache {
609
624
  * @param {object} cache - The cache type (CANVAS, IMAGE, etc.).
610
625
  * @returns {string[]} An array of cache keys.
611
626
  */
612
- getKeys(cache = IMAGE) {
627
+ getKeys(cache: any = IMAGE) {
613
628
  const result = [];
614
629
  if (this._cacheMap[cache]) {
615
630
  const keys = Object.keys(this._cacheMap[cache]);
@@ -629,7 +644,7 @@ export class Cache {
629
644
  * Removes a canvas cache entry.
630
645
  * @param {string} key - The unique key for the cache entry to remove.
631
646
  */
632
- removeCanvas(key) {
647
+ removeCanvas(key: string) {
633
648
  delete this._cache.canvas[key];
634
649
  }
635
650
 
@@ -638,7 +653,7 @@ export class Cache {
638
653
  * @param {string} key - The unique key for the cache entry to remove.
639
654
  * @param {boolean} destroyBaseTexture - Whether to destroy the base texture (default: true).
640
655
  */
641
- removeImage(key, destroyBaseTexture = true) {
656
+ removeImage(key: string, destroyBaseTexture: boolean = true) {
642
657
  const img = this.getImage(key, true);
643
658
  if (destroyBaseTexture && img.base) {
644
659
  img.base.destroy();
@@ -650,7 +665,7 @@ export class Cache {
650
665
  * Removes a sound cache entry.
651
666
  * @param {string} key - The unique key for the cache entry to remove.
652
667
  */
653
- removeSound(key) {
668
+ removeSound(key: string) {
654
669
  delete this._cache.sound[key];
655
670
  }
656
671
 
@@ -658,7 +673,7 @@ export class Cache {
658
673
  * Removes a text cache entry.
659
674
  * @param {string} key - The unique key for the cache entry to remove.
660
675
  */
661
- removeText(key) {
676
+ removeText(key: string) {
662
677
  delete this._cache.text[key];
663
678
  }
664
679
 
@@ -666,7 +681,7 @@ export class Cache {
666
681
  * Removes a bitmap data cache entry.
667
682
  * @param {string} key - The unique key for the cache entry to remove.
668
683
  */
669
- removeBitmapData(key) {
684
+ removeBitmapData(key: string) {
670
685
  delete this._cache.bitmapData[key];
671
686
  }
672
687
 
@@ -674,7 +689,7 @@ export class Cache {
674
689
  * Removes a bitmap font cache entry.
675
690
  * @param {string} key - The unique key for the cache entry to remove.
676
691
  */
677
- removeBitmapFont(key) {
692
+ removeBitmapFont(key: string) {
678
693
  delete this._cache.bitmapFont[key];
679
694
  }
680
695
 
@@ -682,7 +697,7 @@ export class Cache {
682
697
  * Removes a JSON cache entry.
683
698
  * @param {string} key - The unique key for the cache entry to remove.
684
699
  */
685
- removeJSON(key) {
700
+ removeJSON(key: string) {
686
701
  delete this._cache.json[key];
687
702
  }
688
703
 
@@ -690,7 +705,7 @@ export class Cache {
690
705
  * Removes an XML cache entry.
691
706
  * @param {string} key - The unique key for the cache entry to remove.
692
707
  */
693
- removeXML(key) {
708
+ removeXML(key: string) {
694
709
  delete this._cache.xml[key];
695
710
  }
696
711
 
@@ -698,7 +713,7 @@ export class Cache {
698
713
  * Removes a render texture cache entry.
699
714
  * @param {string} key - The unique key for the cache entry to remove.
700
715
  */
701
- removeRenderTexture(key) {
716
+ removeRenderTexture(key: string) {
702
717
  delete this._cache.renderTexture[key];
703
718
  }
704
719
 
@@ -706,7 +721,7 @@ export class Cache {
706
721
  * Removes a sprite sheet cache entry.
707
722
  * @param {string} key - The unique key for the cache entry to remove.
708
723
  */
709
- removeSpriteSheet(key) {
724
+ removeSpriteSheet(key: string) {
710
725
  delete this._cache.spriteSheet[key];
711
726
  }
712
727
 
@@ -714,7 +729,7 @@ export class Cache {
714
729
  * Removes a texture atlas cache entry.
715
730
  * @param {string} key - The unique key for the cache entry to remove.
716
731
  */
717
- removeTextureAtlas(key) {
732
+ removeTextureAtlas(key: string) {
718
733
  delete this._cache.atlas[key];
719
734
  }
720
735
 
@@ -735,7 +750,7 @@ export class Cache {
735
750
  * @param {object} data - The data to associate with the resolved URL.
736
751
  * @returns {string} The resolved URL or null if not enabled.
737
752
  */
738
- _resolveURL(url, data) {
753
+ _resolveURL(url: string, data: any = null) {
739
754
  if (!this.autoResolveURL) {
740
755
  return null;
741
756
  }
@@ -771,4 +786,4 @@ export class Cache {
771
786
  this._urlResolver = null;
772
787
  this._urlTemp = null;
773
788
  }
774
- }
789
+ }
@@ -1,5 +1,27 @@
1
- // @ts-nocheck
2
1
  export class Device {
2
+ desktop!: any;
3
+ iOS!: any;
4
+ android!: any;
5
+ chromeOS!: any;
6
+ linux!: any;
7
+ macOS!: any;
8
+ windows!: any;
9
+ windowsPhone!: any;
10
+ canvas!: any;
11
+ touch!: any;
12
+ mspointer!: any;
13
+ wheelEvent!: any;
14
+ chrome!: any;
15
+ firefox!: any;
16
+ edge!: any;
17
+ safari!: any;
18
+ fullscreen!: any;
19
+ requestFullscreen!: any;
20
+ cancelFullscreen!: any;
21
+ fullscreenKeyboard!: any;
22
+ noAudioFormat!: any;
23
+ supportedAudioFormats!: any;
24
+ supportedImageFormats!: any;
3
25
  /**
4
26
  * Creates a new Device instance.
5
27
  * This class provides information about the current device and browser capabilities.
@@ -9,7 +9,7 @@ const logger = new Logger('device');
9
9
  * @param {string} type - The audio format type to check.
10
10
  * @returns {boolean} True if the device can play this audio format, false otherwise.
11
11
  */
12
- export const canPlayAudio = (device, type) => {
12
+ export const canPlayAudio = (device: Device, type: string) => {
13
13
  return device.supportedAudioFormats[type] === true;
14
14
  };
15
15
 
@@ -17,7 +17,7 @@ export const canPlayAudio = (device, type) => {
17
17
  * Detect the operating system of the device.
18
18
  * @param {Device} device - The device instance to update.
19
19
  */
20
- export const checkOS = (device) => {
20
+ export const checkOS = (device: Device) => {
21
21
  const ua = navigator.userAgent;
22
22
  if (/Android/.test(ua)) {
23
23
  device.android = true;
@@ -54,7 +54,7 @@ export const checkOS = (device) => {
54
54
  * Detect input capabilities of the device.
55
55
  * @param {Device} device - The device instance to update.
56
56
  */
57
- export const checkInput = (device) => {
57
+ export const checkInput = (device: Device) => {
58
58
  if (
59
59
  'ontouchstart' in document.documentElement ||
60
60
  (window.navigator.maxTouchPoints && window.navigator.maxTouchPoints >= 1)
@@ -74,7 +74,7 @@ export const checkInput = (device) => {
74
74
  * Check for fullscreen support capabilities.
75
75
  * @param {Device} device - The device instance to update.
76
76
  */
77
- export const checkFullScreenSupport = (device) => {
77
+ export const checkFullScreenSupport = (device: Device) => {
78
78
  const fs = [
79
79
  'requestFullscreen',
80
80
  'requestFullScreen',
@@ -121,7 +121,7 @@ export const checkFullScreenSupport = (device) => {
121
121
  * Detect the browser type.
122
122
  * @param {Device} device - The device instance to update.
123
123
  */
124
- export const checkBrowser = (device) => {
124
+ export const checkBrowser = (device: Device) => {
125
125
  const ua = navigator.userAgent;
126
126
  if (/Edge\/\d+/.test(ua)) {
127
127
  device.edge = true;
@@ -140,7 +140,7 @@ export const checkBrowser = (device) => {
140
140
  * @param {string} type - The codec type to check.
141
141
  * @returns {boolean} True if the codec is supported, false otherwise.
142
142
  */
143
- export const canPlayType = (audioElement, type) => {
143
+ export const canPlayType = (audioElement: HTMLAudioElement, type: string) => {
144
144
  try {
145
145
  const canPlayResult = audioElement.canPlayType(type);
146
146
  return canPlayResult === 'maybe' || canPlayResult === 'probably';
@@ -156,7 +156,7 @@ export const canPlayType = (audioElement, type) => {
156
156
  * @param {string} type - The media source type to check.
157
157
  * @returns {boolean} True if the media source type is supported, false otherwise.
158
158
  */
159
- export const isMediaSourceTypeSupported = (type) => {
159
+ export const isMediaSourceTypeSupported = (type: string) => {
160
160
  if ('MediaSource' in window) {
161
161
  try {
162
162
  return MediaSource.isTypeSupported(type);
@@ -176,7 +176,7 @@ export const isMediaSourceTypeSupported = (type) => {
176
176
  * @see https://developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements
177
177
  * @see https://bit.ly/iphoneoscodecs
178
178
  */
179
- export const checkAudio = (device) => {
179
+ export const checkAudio = (device: Device) => {
180
180
  const audioElement = document.createElement('audio');
181
181
  const formats = [
182
182
  { type: 'ogg', codecs: ['audio/ogg; codecs="vorbis"'] },
@@ -208,7 +208,7 @@ export const checkAudio = (device) => {
208
208
  * Check for supported image formats on the device.
209
209
  * @param {Device} device - The device instance to update with image format support.
210
210
  */
211
- export const checkImage = (device) => {
211
+ export const checkImage = (device: Device) => {
212
212
  try {
213
213
  const avif = new Image();
214
214
  avif.src =
@@ -236,7 +236,7 @@ export const checkImage = (device) => {
236
236
  * Initialize device capabilities detection.
237
237
  * @param {Device} device - The device instance to initialize.
238
238
  */
239
- export const initialize = (device) => {
239
+ export const initialize = (device: Device) => {
240
240
  logger.info('initialize');
241
241
  checkOS(device);
242
242
  checkBrowser(device);
@@ -191,7 +191,7 @@ export class DOM {
191
191
  * TBD.
192
192
  * @param {import('./device.js').Device} device - TBD.
193
193
  */
194
- constructor(device) {
194
+ constructor(device: import('./device.js').Device) {
195
195
  this.treatAsDesktop =
196
196
  device.desktop &&
197
197
  document.documentElement.clientWidth <= window.innerWidth &&
@@ -211,7 +211,7 @@ export class DOM {
211
211
  * @param {Point} point - Optional Point object to store the result.
212
212
  * @returns {Point} The offset position of the element.
213
213
  */
214
- getOffset(element, point = null) {
214
+ getOffset(element: HTMLCanvasElement, point: Point = null) {
215
215
  point = point || new Point();
216
216
  const box = element.getBoundingClientRect();
217
217
  const scrollTop = this.scrollY;
@@ -229,7 +229,7 @@ export class DOM {
229
229
  * @param {number} cushion - Optional padding to add around the element.
230
230
  * @returns {boolean} True if bounds were successfully retrieved, false otherwise.
231
231
  */
232
- getBounds(element, cushion = 0) {
232
+ getBounds(element: HTMLCanvasElement, cushion: number = 0) {
233
233
  element = element && !element.nodeType ? element[0] : element;
234
234
  if (!element || element.nodeType !== 1) {
235
235
  return false;
@@ -243,7 +243,7 @@ export class DOM {
243
243
  * @param {number} cushion - Optional padding to add around the rectangle.
244
244
  * @returns {{width: number, height: number, left: number, right: number, top: number, bottom: number}} The calibrated rectangle.
245
245
  */
246
- calibrate(coords, cushion = 0) {
246
+ calibrate(coords: DOMRect, cushion: number = 0) {
247
247
  const output = {
248
248
  width: 0,
249
249
  height: 0,
@@ -262,7 +262,7 @@ export class DOM {
262
262
  * @param {string} primaryFallback - The fallback method to use if screen orientation API is not available.
263
263
  * @returns {string} The screen orientation ('portrait-primary', 'landscape-primary', etc.).
264
264
  */
265
- getScreenOrientation(primaryFallback) {
265
+ getScreenOrientation(primaryFallback: string) {
266
266
  const screen = window.screen;
267
267
  // @ts-ignore
268
268
  const orientation = screen.orientation || screen.mozOrientation || screen.msOrientation;