@vpmedia/phaser 1.104.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.
- package/dist/index.js +151 -574
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +35 -57
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +11 -10
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +2 -2
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts +3 -3
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +60 -60
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts +10 -10
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +6 -5
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts +49 -174
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +7 -7
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame.d.ts +27 -48
- package/dist/phaser/core/frame.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts +11 -60
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/frame_util.d.ts +4 -14
- package/dist/phaser/core/frame_util.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts +49 -58
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +15 -13
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +23 -20
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +26 -1
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +2 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +9 -9
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +2 -1
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +28 -28
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +4 -4
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +2 -2
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/scale_manager.d.ts +22 -17
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +1 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +10 -9
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +9 -8
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +2 -2
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +56 -101
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +11 -9
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +4 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +3 -3
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +5 -5
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +10 -10
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts +11 -21
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +37 -59
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +6 -5
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts +31 -31
- package/dist/phaser/core/tween_easing.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +4 -4
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts +1 -1
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +22 -20
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +23 -35
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts +2 -2
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts +3 -3
- package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts +2 -2
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +5 -5
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +3 -3
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts +9 -9
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +45 -42
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +24 -16
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts +1 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +24 -37
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +34 -49
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_batch.d.ts +1 -1
- package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +5 -5
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +86 -66
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts +2 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts +2 -2
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +3 -2
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts +10 -10
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +2 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +3 -2
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +11 -10
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +2 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +8 -6
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +1 -0
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +4 -2
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +3 -2
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +5 -4
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +15 -2
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts +2 -2
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts +6 -6
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts +11 -10
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts +6 -5
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +14 -14
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts +13 -12
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts +19 -19
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts +6 -6
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts +20 -20
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts +2 -2
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts +9 -7
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts +5 -3
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts +2 -1
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts +19 -19
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/polygon.d.ts +2 -1
- package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +17 -15
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts +2 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts +51 -142
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/phaser/core/animation.ts +38 -61
- package/src/phaser/core/animation_manager.ts +21 -21
- package/src/phaser/core/animation_parser.ts +11 -3
- package/src/phaser/core/array_set.ts +8 -8
- package/src/phaser/core/cache.ts +75 -68
- package/src/phaser/core/device.ts +23 -24
- package/src/phaser/core/device_util.ts +10 -10
- package/src/phaser/core/dom.ts +5 -5
- package/src/phaser/core/event_manager.ts +52 -193
- package/src/phaser/core/factory.ts +25 -18
- package/src/phaser/core/frame.ts +37 -51
- package/src/phaser/core/frame_data.ts +29 -76
- package/src/phaser/core/frame_util.ts +3 -16
- package/src/phaser/core/game.ts +36 -63
- package/src/phaser/core/input.ts +68 -68
- package/src/phaser/core/input_handler.ts +81 -86
- package/src/phaser/core/input_mouse.ts +42 -36
- package/src/phaser/core/input_mspointer.ts +24 -25
- package/src/phaser/core/input_pointer.ts +55 -56
- package/src/phaser/core/input_touch.ts +26 -26
- package/src/phaser/core/loader.ts +97 -70
- package/src/phaser/core/loader_parser.ts +6 -7
- package/src/phaser/core/raf.ts +2 -2
- package/src/phaser/core/scale_manager.ts +85 -82
- package/src/phaser/core/scene.ts +3 -4
- package/src/phaser/core/scene_manager.ts +26 -26
- package/src/phaser/core/signal.ts +10 -10
- package/src/phaser/core/signal_binding.ts +2 -2
- package/src/phaser/core/sound.ts +65 -112
- package/src/phaser/core/sound_manager.ts +31 -30
- package/src/phaser/core/sound_sprite.ts +10 -11
- package/src/phaser/core/stage.ts +8 -8
- package/src/phaser/core/time.ts +33 -34
- package/src/phaser/core/timer.ts +40 -34
- package/src/phaser/core/timer_event.ts +23 -23
- package/src/phaser/core/tween.ts +42 -68
- package/src/phaser/core/tween_data.ts +31 -31
- package/src/phaser/core/tween_easing.ts +31 -31
- package/src/phaser/core/tween_manager.ts +10 -11
- package/src/phaser/core/world.ts +1 -2
- package/src/phaser/display/bitmap_text.ts +41 -31
- package/src/phaser/display/button.ts +24 -51
- package/src/phaser/display/canvas/buffer.ts +6 -7
- package/src/phaser/display/canvas/graphics.ts +3 -4
- package/src/phaser/display/canvas/masker.ts +2 -3
- package/src/phaser/display/canvas/pool.ts +3 -4
- package/src/phaser/display/canvas/renderer.ts +19 -20
- package/src/phaser/display/canvas/tinter.ts +4 -5
- package/src/phaser/display/canvas/util.ts +9 -9
- package/src/phaser/display/display_object.ts +49 -50
- package/src/phaser/display/graphics.ts +56 -43
- package/src/phaser/display/graphics_data.ts +11 -12
- package/src/phaser/display/graphics_data_util.ts +1 -2
- package/src/phaser/display/group.ts +32 -42
- package/src/phaser/display/image.ts +32 -52
- package/src/phaser/display/sprite_batch.ts +1 -2
- package/src/phaser/display/sprite_util.ts +5 -6
- package/src/phaser/display/text.ts +82 -56
- package/src/phaser/display/webgl/abstract_filter.ts +8 -8
- package/src/phaser/display/webgl/base_texture.ts +14 -15
- package/src/phaser/display/webgl/blend_manager.ts +5 -5
- package/src/phaser/display/webgl/earcut.ts +27 -27
- package/src/phaser/display/webgl/earcut_node.ts +1 -1
- package/src/phaser/display/webgl/fast_sprite_batch.ts +19 -19
- package/src/phaser/display/webgl/filter_manager.ts +5 -5
- package/src/phaser/display/webgl/filter_texture.ts +7 -7
- package/src/phaser/display/webgl/graphics.ts +10 -11
- package/src/phaser/display/webgl/graphics_data.ts +11 -11
- package/src/phaser/display/webgl/mask_manager.ts +2 -3
- package/src/phaser/display/webgl/render_texture.ts +12 -12
- package/src/phaser/display/webgl/renderer.ts +24 -24
- package/src/phaser/display/webgl/shader/complex.ts +7 -7
- package/src/phaser/display/webgl/shader/fast.ts +8 -8
- package/src/phaser/display/webgl/shader/normal.ts +12 -12
- package/src/phaser/display/webgl/shader/primitive.ts +7 -7
- package/src/phaser/display/webgl/shader/strip.ts +7 -7
- package/src/phaser/display/webgl/shader_manager.ts +13 -13
- package/src/phaser/display/webgl/sprite_batch.ts +20 -20
- package/src/phaser/display/webgl/stencil_manager.ts +8 -8
- package/src/phaser/display/webgl/texture.ts +35 -24
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +6 -6
- package/src/phaser/geom/circle.ts +10 -10
- package/src/phaser/geom/ellipse.ts +6 -6
- package/src/phaser/geom/line.ts +14 -14
- package/src/phaser/geom/matrix.ts +12 -12
- package/src/phaser/geom/point.ts +19 -19
- package/src/phaser/geom/polygon.ts +5 -5
- package/src/phaser/geom/rectangle.ts +21 -21
- package/src/phaser/geom/rounded_rectangle.ts +2 -2
- package/src/phaser/geom/util/circle.ts +7 -7
- package/src/phaser/geom/util/ellipse.ts +1 -1
- package/src/phaser/geom/util/line.ts +5 -5
- package/src/phaser/geom/util/matrix.ts +1 -1
- package/src/phaser/geom/util/point.ts +20 -20
- package/src/phaser/geom/util/polygon.ts +1 -1
- package/src/phaser/geom/util/rectangle.ts +15 -15
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
- package/src/phaser/util/math.ts +65 -151
package/src/phaser/core/cache.ts
CHANGED
|
@@ -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,19 +18,19 @@ export const XML = 8;
|
|
|
19
18
|
export const RENDER_TEXTURE = 9;
|
|
20
19
|
|
|
21
20
|
export class Cache {
|
|
22
|
-
game;
|
|
23
|
-
autoResolveURL;
|
|
24
|
-
_cache;
|
|
25
|
-
_urlMap;
|
|
26
|
-
_urlResolver;
|
|
27
|
-
_urlTemp;
|
|
28
|
-
onSoundUnlock;
|
|
29
|
-
_cacheMap;
|
|
21
|
+
game!: any;
|
|
22
|
+
autoResolveURL!: any;
|
|
23
|
+
_cache!: any;
|
|
24
|
+
_urlMap!: any;
|
|
25
|
+
_urlResolver!: any;
|
|
26
|
+
_urlTemp!: any;
|
|
27
|
+
onSoundUnlock!: any;
|
|
28
|
+
_cacheMap!: any;
|
|
30
29
|
/**
|
|
31
30
|
* Creates a new Cache instance.
|
|
32
31
|
* @param {import('./game.js').Game} game - The game instance.
|
|
33
32
|
*/
|
|
34
|
-
constructor(game) {
|
|
33
|
+
constructor(game: import('./game.js').Game) {
|
|
35
34
|
this.game = game;
|
|
36
35
|
this.autoResolveURL = false;
|
|
37
36
|
this._cache = {
|
|
@@ -95,7 +94,7 @@ _cacheMap;
|
|
|
95
94
|
* @param {HTMLImageElement} data - The image data to cache.
|
|
96
95
|
* @returns {object} The cached image object.
|
|
97
96
|
*/
|
|
98
|
-
addImage(key, url, data) {
|
|
97
|
+
addImage(key: string, url: string, data: HTMLImageElement) {
|
|
99
98
|
if (this.checkImageKey(key)) {
|
|
100
99
|
this.removeImage(key);
|
|
101
100
|
}
|
|
@@ -123,8 +122,8 @@ _cacheMap;
|
|
|
123
122
|
* @param {HTMLCanvasElement} data - The canvas data for the atlas.
|
|
124
123
|
* @param {object} atlasData - The atlas data to cache.
|
|
125
124
|
*/
|
|
126
|
-
addTextureAtlas(key, url, data, atlasData) {
|
|
127
|
-
const obj = {
|
|
125
|
+
addTextureAtlas(key: string, url: string, data: HTMLCanvasElement, atlasData: any) {
|
|
126
|
+
const obj: any = {
|
|
128
127
|
key,
|
|
129
128
|
url,
|
|
130
129
|
data,
|
|
@@ -141,7 +140,7 @@ _cacheMap;
|
|
|
141
140
|
* @param {string} url - The URL the sound was loaded from.
|
|
142
141
|
* @param {object} data - The sound data to cache.
|
|
143
142
|
*/
|
|
144
|
-
addSound(key, url, data) {
|
|
143
|
+
addSound(key: string, url: string, data: any) {
|
|
145
144
|
this._cache.sound[key] = {
|
|
146
145
|
url,
|
|
147
146
|
data,
|
|
@@ -157,7 +156,7 @@ _cacheMap;
|
|
|
157
156
|
* @param {string} url - The URL the text was loaded from.
|
|
158
157
|
* @param {string} data - The text data to cache.
|
|
159
158
|
*/
|
|
160
|
-
addText(key, url, data) {
|
|
159
|
+
addText(key: string, url: string, data: string) {
|
|
161
160
|
this._cache.text[key] = { url, data };
|
|
162
161
|
this._resolveURL(url, this._cache.text[key]);
|
|
163
162
|
}
|
|
@@ -172,7 +171,15 @@ _cacheMap;
|
|
|
172
171
|
* @param {number} xSpacing - Horizontal spacing between characters.
|
|
173
172
|
* @param {number} ySpacing - Vertical spacing between characters.
|
|
174
173
|
*/
|
|
175
|
-
addBitmapFont(
|
|
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
|
+
) {
|
|
176
183
|
const obj = {
|
|
177
184
|
url,
|
|
178
185
|
data,
|
|
@@ -194,7 +201,7 @@ _cacheMap;
|
|
|
194
201
|
* @param {string} url - The URL the JSON was loaded from.
|
|
195
202
|
* @param {object} data - The JSON data to cache.
|
|
196
203
|
*/
|
|
197
|
-
addJSON(key, url, data) {
|
|
204
|
+
addJSON(key: string, url: string, data: any) {
|
|
198
205
|
this._cache.json[key] = { url, data };
|
|
199
206
|
this._resolveURL(url, this._cache.json[key]);
|
|
200
207
|
}
|
|
@@ -205,7 +212,7 @@ _cacheMap;
|
|
|
205
212
|
* @param {string} url - The URL the XML was loaded from.
|
|
206
213
|
* @param {XMLDocument} data - The XML data to cache.
|
|
207
214
|
*/
|
|
208
|
-
addXML(key, url, data) {
|
|
215
|
+
addXML(key: string, url: string, data: XMLDocument) {
|
|
209
216
|
this._cache.xml[key] = { url, data };
|
|
210
217
|
this._resolveURL(url, this._cache.xml[key]);
|
|
211
218
|
}
|
|
@@ -218,7 +225,7 @@ _cacheMap;
|
|
|
218
225
|
* @param {string} property - The property to update.
|
|
219
226
|
* @param {any} value - The new value for the property.
|
|
220
227
|
*/
|
|
221
|
-
updateSound(key, property, value) {
|
|
228
|
+
updateSound(key: string, property: string, value: any) {
|
|
222
229
|
const sound = this.getSound(key);
|
|
223
230
|
if (sound) {
|
|
224
231
|
sound[property] = value;
|
|
@@ -230,7 +237,7 @@ _cacheMap;
|
|
|
230
237
|
* @param {string} key - The unique key for the cached sound.
|
|
231
238
|
* @param {AudioBuffer} data - The decoded audio buffer.
|
|
232
239
|
*/
|
|
233
|
-
decodedSound(key, data) {
|
|
240
|
+
decodedSound(key: string, data: AudioBuffer) {
|
|
234
241
|
const sound = this.getSound(key);
|
|
235
242
|
sound.data = data;
|
|
236
243
|
sound.decoded = true;
|
|
@@ -242,7 +249,7 @@ _cacheMap;
|
|
|
242
249
|
* @param {string} key - The unique key for the cached sound.
|
|
243
250
|
* @returns {boolean} True if the sound is decoded, false otherwise.
|
|
244
251
|
*/
|
|
245
|
-
isSoundDecoded(key) {
|
|
252
|
+
isSoundDecoded(key: string) {
|
|
246
253
|
const sound = this.getItem(key, SOUND, 'isSoundDecoded');
|
|
247
254
|
if (sound) {
|
|
248
255
|
return sound.decoded;
|
|
@@ -255,7 +262,7 @@ _cacheMap;
|
|
|
255
262
|
* @param {string} key - The unique key for the cached sound.
|
|
256
263
|
* @returns {boolean} True if the sound is ready, false otherwise.
|
|
257
264
|
*/
|
|
258
|
-
isSoundReady(key) {
|
|
265
|
+
isSoundReady(key: string) {
|
|
259
266
|
const sound = this.getItem(key, SOUND, 'isSoundDecoded');
|
|
260
267
|
if (sound) {
|
|
261
268
|
return sound.decoded && !this.game.sound.isLocked;
|
|
@@ -271,7 +278,7 @@ _cacheMap;
|
|
|
271
278
|
* @param {string} key - The unique key for the cache entry.
|
|
272
279
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
273
280
|
*/
|
|
274
|
-
checkKey(cache, key) {
|
|
281
|
+
checkKey(cache: number, key: string) {
|
|
275
282
|
if (this._cacheMap[cache][key]) {
|
|
276
283
|
return true;
|
|
277
284
|
}
|
|
@@ -283,7 +290,7 @@ _cacheMap;
|
|
|
283
290
|
* @param {string} url - The URL to check.
|
|
284
291
|
* @returns {boolean} True if the URL has been resolved and cached, false otherwise.
|
|
285
292
|
*/
|
|
286
|
-
checkURL(url) {
|
|
293
|
+
checkURL(url: string) {
|
|
287
294
|
if (this._urlMap[this._resolveURL(url)]) {
|
|
288
295
|
return true;
|
|
289
296
|
}
|
|
@@ -295,7 +302,7 @@ _cacheMap;
|
|
|
295
302
|
* @param {string} key - The unique key for the cache entry.
|
|
296
303
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
297
304
|
*/
|
|
298
|
-
checkCanvasKey(key) {
|
|
305
|
+
checkCanvasKey(key: string) {
|
|
299
306
|
return this.checkKey(CANVAS, key);
|
|
300
307
|
}
|
|
301
308
|
|
|
@@ -304,7 +311,7 @@ _cacheMap;
|
|
|
304
311
|
* @param {string} key - The unique key for the cache entry.
|
|
305
312
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
306
313
|
*/
|
|
307
|
-
checkImageKey(key) {
|
|
314
|
+
checkImageKey(key: string) {
|
|
308
315
|
return this.checkKey(IMAGE, key);
|
|
309
316
|
}
|
|
310
317
|
|
|
@@ -313,7 +320,7 @@ _cacheMap;
|
|
|
313
320
|
* @param {string} key - The unique key for the cache entry.
|
|
314
321
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
315
322
|
*/
|
|
316
|
-
checkTextureKey(key) {
|
|
323
|
+
checkTextureKey(key: string) {
|
|
317
324
|
return this.checkKey(TEXTURE, key);
|
|
318
325
|
}
|
|
319
326
|
|
|
@@ -322,7 +329,7 @@ _cacheMap;
|
|
|
322
329
|
* @param {string} key - The unique key for the cache entry.
|
|
323
330
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
324
331
|
*/
|
|
325
|
-
checkSoundKey(key) {
|
|
332
|
+
checkSoundKey(key: string) {
|
|
326
333
|
return this.checkKey(SOUND, key);
|
|
327
334
|
}
|
|
328
335
|
|
|
@@ -331,7 +338,7 @@ _cacheMap;
|
|
|
331
338
|
* @param {string} key - The unique key for the cache entry.
|
|
332
339
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
333
340
|
*/
|
|
334
|
-
checkTextKey(key) {
|
|
341
|
+
checkTextKey(key: string) {
|
|
335
342
|
return this.checkKey(TEXT, key);
|
|
336
343
|
}
|
|
337
344
|
|
|
@@ -340,7 +347,7 @@ _cacheMap;
|
|
|
340
347
|
* @param {string} key - The unique key for the cache entry.
|
|
341
348
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
342
349
|
*/
|
|
343
|
-
checkBitmapDataKey(key) {
|
|
350
|
+
checkBitmapDataKey(key: string) {
|
|
344
351
|
return this.checkKey(BITMAPDATA, key);
|
|
345
352
|
}
|
|
346
353
|
|
|
@@ -349,7 +356,7 @@ _cacheMap;
|
|
|
349
356
|
* @param {string} key - The unique key for the cache entry.
|
|
350
357
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
351
358
|
*/
|
|
352
|
-
checkBitmapFontKey(key) {
|
|
359
|
+
checkBitmapFontKey(key: string) {
|
|
353
360
|
return this.checkKey(BITMAPFONT, key);
|
|
354
361
|
}
|
|
355
362
|
|
|
@@ -358,7 +365,7 @@ _cacheMap;
|
|
|
358
365
|
* @param {string} key - The unique key for the cache entry.
|
|
359
366
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
360
367
|
*/
|
|
361
|
-
checkJSONKey(key) {
|
|
368
|
+
checkJSONKey(key: string) {
|
|
362
369
|
return this.checkKey(JSONDATA, key);
|
|
363
370
|
}
|
|
364
371
|
|
|
@@ -367,7 +374,7 @@ _cacheMap;
|
|
|
367
374
|
* @param {string} key - The unique key for the cache entry.
|
|
368
375
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
369
376
|
*/
|
|
370
|
-
checkXMLKey(key) {
|
|
377
|
+
checkXMLKey(key: string) {
|
|
371
378
|
return this.checkKey(XML, key);
|
|
372
379
|
}
|
|
373
380
|
|
|
@@ -381,7 +388,7 @@ _cacheMap;
|
|
|
381
388
|
* @param {string} property - TBD.
|
|
382
389
|
* @returns {*} TBD.
|
|
383
390
|
*/
|
|
384
|
-
getItem(key, cache, method, property = null) {
|
|
391
|
+
getItem(key: string, cache: number, method: string, property: string = null) {
|
|
385
392
|
if (this.checkKey(cache, key)) {
|
|
386
393
|
if (!property) {
|
|
387
394
|
return this._cacheMap[cache][key];
|
|
@@ -396,7 +403,7 @@ _cacheMap;
|
|
|
396
403
|
* @param {string} key - TBD.
|
|
397
404
|
* @returns {HTMLCanvasElement} TBD.
|
|
398
405
|
*/
|
|
399
|
-
getCanvas(key) {
|
|
406
|
+
getCanvas(key: string) {
|
|
400
407
|
return this.getItem(key, CANVAS, 'getCanvas', 'canvas');
|
|
401
408
|
}
|
|
402
409
|
|
|
@@ -406,7 +413,7 @@ _cacheMap;
|
|
|
406
413
|
* @param {boolean} full - TBD.
|
|
407
414
|
* @returns {HTMLImageElement} TBD.
|
|
408
415
|
*/
|
|
409
|
-
getImage(key = '__default', full = false) {
|
|
416
|
+
getImage(key: any = '__default', full: boolean = false) {
|
|
410
417
|
let img = this.getItem(key, IMAGE, 'getImage');
|
|
411
418
|
if (img === null) {
|
|
412
419
|
img = this.getItem('__missing', IMAGE, 'getImage');
|
|
@@ -422,7 +429,7 @@ _cacheMap;
|
|
|
422
429
|
* @param {string} key - TBD.
|
|
423
430
|
* @returns {object} TBD.
|
|
424
431
|
*/
|
|
425
|
-
getTextureFrame(key) {
|
|
432
|
+
getTextureFrame(key: string) {
|
|
426
433
|
return this.getItem(key, TEXTURE, 'getTextureFrame', 'frame');
|
|
427
434
|
}
|
|
428
435
|
|
|
@@ -431,7 +438,7 @@ _cacheMap;
|
|
|
431
438
|
* @param {string} key - TBD.
|
|
432
439
|
* @returns {object} TBD.
|
|
433
440
|
*/
|
|
434
|
-
getSound(key) {
|
|
441
|
+
getSound(key: string) {
|
|
435
442
|
return this.getItem(key, SOUND, 'getSound');
|
|
436
443
|
}
|
|
437
444
|
|
|
@@ -440,7 +447,7 @@ _cacheMap;
|
|
|
440
447
|
* @param {string} key - TBD.
|
|
441
448
|
* @returns {object} TBD.
|
|
442
449
|
*/
|
|
443
|
-
getSoundData(key) {
|
|
450
|
+
getSoundData(key: string) {
|
|
444
451
|
return this.getItem(key, SOUND, 'getSoundData', 'data');
|
|
445
452
|
}
|
|
446
453
|
|
|
@@ -449,7 +456,7 @@ _cacheMap;
|
|
|
449
456
|
* @param {string} key - TBD.
|
|
450
457
|
* @returns {object} TBD.
|
|
451
458
|
*/
|
|
452
|
-
getText(key) {
|
|
459
|
+
getText(key: string) {
|
|
453
460
|
return this.getItem(key, TEXT, 'getText', 'data');
|
|
454
461
|
}
|
|
455
462
|
|
|
@@ -458,7 +465,7 @@ _cacheMap;
|
|
|
458
465
|
* @param {string} key - TBD.
|
|
459
466
|
* @returns {object} TBD.
|
|
460
467
|
*/
|
|
461
|
-
getBitmapData(key) {
|
|
468
|
+
getBitmapData(key: string) {
|
|
462
469
|
return this.getItem(key, BITMAPDATA, 'getBitmapData', 'data');
|
|
463
470
|
}
|
|
464
471
|
|
|
@@ -467,7 +474,7 @@ _cacheMap;
|
|
|
467
474
|
* @param {string} key - TBD.
|
|
468
475
|
* @returns {object} TBD.
|
|
469
476
|
*/
|
|
470
|
-
getBitmapFont(key) {
|
|
477
|
+
getBitmapFont(key: string) {
|
|
471
478
|
return this.getItem(key, BITMAPFONT, 'getBitmapFont');
|
|
472
479
|
}
|
|
473
480
|
|
|
@@ -477,7 +484,7 @@ _cacheMap;
|
|
|
477
484
|
* @param {boolean} isClone - TBD.
|
|
478
485
|
* @returns {object} TBD.
|
|
479
486
|
*/
|
|
480
|
-
getJSON(key, isClone = false) {
|
|
487
|
+
getJSON(key: string, isClone: boolean = false) {
|
|
481
488
|
const data = this.getItem(key, JSONDATA, 'getJSON', 'data');
|
|
482
489
|
return isClone ? JSON.parse(JSON.stringify(data)) : data;
|
|
483
490
|
}
|
|
@@ -487,7 +494,7 @@ _cacheMap;
|
|
|
487
494
|
* @param {string} key - TBD.
|
|
488
495
|
* @returns {XMLDocument} TBD.
|
|
489
496
|
*/
|
|
490
|
-
getXML(key) {
|
|
497
|
+
getXML(key: string) {
|
|
491
498
|
return this.getItem(key, XML, 'getXML', 'data');
|
|
492
499
|
}
|
|
493
500
|
|
|
@@ -496,7 +503,7 @@ _cacheMap;
|
|
|
496
503
|
* @param {string} key - TBD.
|
|
497
504
|
* @returns {import('../display/webgl/render_texture.js').RenderTexture} TBD.
|
|
498
505
|
*/
|
|
499
|
-
getRenderTexture(key) {
|
|
506
|
+
getRenderTexture(key: string) {
|
|
500
507
|
return this.getItem(key, RENDER_TEXTURE, 'getRenderTexture');
|
|
501
508
|
}
|
|
502
509
|
|
|
@@ -508,7 +515,7 @@ _cacheMap;
|
|
|
508
515
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
509
516
|
* @returns {BaseTexture} The base texture.
|
|
510
517
|
*/
|
|
511
|
-
getBaseTexture(key, cache = IMAGE) {
|
|
518
|
+
getBaseTexture(key: string, cache: number = IMAGE) {
|
|
512
519
|
return this.getItem(key, cache, 'getBaseTexture', 'base');
|
|
513
520
|
}
|
|
514
521
|
|
|
@@ -518,7 +525,7 @@ _cacheMap;
|
|
|
518
525
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
519
526
|
* @returns {Frame} The frame.
|
|
520
527
|
*/
|
|
521
|
-
getFrame(key, cache = IMAGE) {
|
|
528
|
+
getFrame(key: string, cache: number = IMAGE) {
|
|
522
529
|
return this.getItem(key, cache, 'getFrame', 'frame');
|
|
523
530
|
}
|
|
524
531
|
|
|
@@ -528,7 +535,7 @@ _cacheMap;
|
|
|
528
535
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
529
536
|
* @returns {number} The number of frames.
|
|
530
537
|
*/
|
|
531
|
-
getFrameCount(key, cache = IMAGE) {
|
|
538
|
+
getFrameCount(key: string, cache: number = IMAGE) {
|
|
532
539
|
const data = this.getFrameData(key, cache);
|
|
533
540
|
if (data) {
|
|
534
541
|
return data.total;
|
|
@@ -542,7 +549,7 @@ _cacheMap;
|
|
|
542
549
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
543
550
|
* @returns {FrameData} The frame data.
|
|
544
551
|
*/
|
|
545
|
-
getFrameData(key, cache = IMAGE) {
|
|
552
|
+
getFrameData(key: string, cache: number = IMAGE) {
|
|
546
553
|
return this.getItem(key, cache, 'getFrameData', 'frameData');
|
|
547
554
|
}
|
|
548
555
|
|
|
@@ -552,7 +559,7 @@ _cacheMap;
|
|
|
552
559
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
553
560
|
* @returns {boolean} True if the entry has frame data, false otherwise.
|
|
554
561
|
*/
|
|
555
|
-
hasFrameData(key, cache = IMAGE) {
|
|
562
|
+
hasFrameData(key: string, cache: number = IMAGE) {
|
|
556
563
|
return this.getItem(key, cache, '', 'frameData') !== null;
|
|
557
564
|
}
|
|
558
565
|
|
|
@@ -562,7 +569,7 @@ _cacheMap;
|
|
|
562
569
|
* @param {FrameData} frameData - The new frame data.
|
|
563
570
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
564
571
|
*/
|
|
565
|
-
updateFrameData(key, frameData, cache = IMAGE) {
|
|
572
|
+
updateFrameData(key: string, frameData: FrameData, cache: number = IMAGE) {
|
|
566
573
|
if (this._cacheMap[cache][key]) {
|
|
567
574
|
this._cacheMap[cache][key].frameData = frameData;
|
|
568
575
|
}
|
|
@@ -575,7 +582,7 @@ _cacheMap;
|
|
|
575
582
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
576
583
|
* @returns {Frame} The frame at the specified index.
|
|
577
584
|
*/
|
|
578
|
-
getFrameByIndex(key, index, cache = IMAGE) {
|
|
585
|
+
getFrameByIndex(key: string, index: number, cache: number = IMAGE) {
|
|
579
586
|
const data = this.getFrameData(key, cache);
|
|
580
587
|
if (data) {
|
|
581
588
|
return data.getFrame(index);
|
|
@@ -590,7 +597,7 @@ _cacheMap;
|
|
|
590
597
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
591
598
|
* @returns {Frame} The frame with the specified name.
|
|
592
599
|
*/
|
|
593
|
-
getFrameByName(key, name, cache = IMAGE) {
|
|
600
|
+
getFrameByName(key: string, name: string, cache: number = IMAGE) {
|
|
594
601
|
const data = this.getFrameData(key, cache);
|
|
595
602
|
if (data) {
|
|
596
603
|
return data.getFrameByName(name);
|
|
@@ -603,7 +610,7 @@ _cacheMap;
|
|
|
603
610
|
* @param {string} url - The original URL to resolve.
|
|
604
611
|
* @returns {string} The resolved URL or null if not found.
|
|
605
612
|
*/
|
|
606
|
-
getURL(url) {
|
|
613
|
+
getURL(url: string) {
|
|
607
614
|
const resolvedURL = this._resolveURL(url);
|
|
608
615
|
if (resolvedURL) {
|
|
609
616
|
return this._urlMap[resolvedURL];
|
|
@@ -617,7 +624,7 @@ _cacheMap;
|
|
|
617
624
|
* @param {object} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
618
625
|
* @returns {string[]} An array of cache keys.
|
|
619
626
|
*/
|
|
620
|
-
getKeys(cache = IMAGE) {
|
|
627
|
+
getKeys(cache: any = IMAGE) {
|
|
621
628
|
const result = [];
|
|
622
629
|
if (this._cacheMap[cache]) {
|
|
623
630
|
const keys = Object.keys(this._cacheMap[cache]);
|
|
@@ -637,7 +644,7 @@ _cacheMap;
|
|
|
637
644
|
* Removes a canvas cache entry.
|
|
638
645
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
639
646
|
*/
|
|
640
|
-
removeCanvas(key) {
|
|
647
|
+
removeCanvas(key: string) {
|
|
641
648
|
delete this._cache.canvas[key];
|
|
642
649
|
}
|
|
643
650
|
|
|
@@ -646,7 +653,7 @@ _cacheMap;
|
|
|
646
653
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
647
654
|
* @param {boolean} destroyBaseTexture - Whether to destroy the base texture (default: true).
|
|
648
655
|
*/
|
|
649
|
-
removeImage(key, destroyBaseTexture = true) {
|
|
656
|
+
removeImage(key: string, destroyBaseTexture: boolean = true) {
|
|
650
657
|
const img = this.getImage(key, true);
|
|
651
658
|
if (destroyBaseTexture && img.base) {
|
|
652
659
|
img.base.destroy();
|
|
@@ -658,7 +665,7 @@ _cacheMap;
|
|
|
658
665
|
* Removes a sound cache entry.
|
|
659
666
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
660
667
|
*/
|
|
661
|
-
removeSound(key) {
|
|
668
|
+
removeSound(key: string) {
|
|
662
669
|
delete this._cache.sound[key];
|
|
663
670
|
}
|
|
664
671
|
|
|
@@ -666,7 +673,7 @@ _cacheMap;
|
|
|
666
673
|
* Removes a text cache entry.
|
|
667
674
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
668
675
|
*/
|
|
669
|
-
removeText(key) {
|
|
676
|
+
removeText(key: string) {
|
|
670
677
|
delete this._cache.text[key];
|
|
671
678
|
}
|
|
672
679
|
|
|
@@ -674,7 +681,7 @@ _cacheMap;
|
|
|
674
681
|
* Removes a bitmap data cache entry.
|
|
675
682
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
676
683
|
*/
|
|
677
|
-
removeBitmapData(key) {
|
|
684
|
+
removeBitmapData(key: string) {
|
|
678
685
|
delete this._cache.bitmapData[key];
|
|
679
686
|
}
|
|
680
687
|
|
|
@@ -682,7 +689,7 @@ _cacheMap;
|
|
|
682
689
|
* Removes a bitmap font cache entry.
|
|
683
690
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
684
691
|
*/
|
|
685
|
-
removeBitmapFont(key) {
|
|
692
|
+
removeBitmapFont(key: string) {
|
|
686
693
|
delete this._cache.bitmapFont[key];
|
|
687
694
|
}
|
|
688
695
|
|
|
@@ -690,7 +697,7 @@ _cacheMap;
|
|
|
690
697
|
* Removes a JSON cache entry.
|
|
691
698
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
692
699
|
*/
|
|
693
|
-
removeJSON(key) {
|
|
700
|
+
removeJSON(key: string) {
|
|
694
701
|
delete this._cache.json[key];
|
|
695
702
|
}
|
|
696
703
|
|
|
@@ -698,7 +705,7 @@ _cacheMap;
|
|
|
698
705
|
* Removes an XML cache entry.
|
|
699
706
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
700
707
|
*/
|
|
701
|
-
removeXML(key) {
|
|
708
|
+
removeXML(key: string) {
|
|
702
709
|
delete this._cache.xml[key];
|
|
703
710
|
}
|
|
704
711
|
|
|
@@ -706,7 +713,7 @@ _cacheMap;
|
|
|
706
713
|
* Removes a render texture cache entry.
|
|
707
714
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
708
715
|
*/
|
|
709
|
-
removeRenderTexture(key) {
|
|
716
|
+
removeRenderTexture(key: string) {
|
|
710
717
|
delete this._cache.renderTexture[key];
|
|
711
718
|
}
|
|
712
719
|
|
|
@@ -714,7 +721,7 @@ _cacheMap;
|
|
|
714
721
|
* Removes a sprite sheet cache entry.
|
|
715
722
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
716
723
|
*/
|
|
717
|
-
removeSpriteSheet(key) {
|
|
724
|
+
removeSpriteSheet(key: string) {
|
|
718
725
|
delete this._cache.spriteSheet[key];
|
|
719
726
|
}
|
|
720
727
|
|
|
@@ -722,7 +729,7 @@ _cacheMap;
|
|
|
722
729
|
* Removes a texture atlas cache entry.
|
|
723
730
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
724
731
|
*/
|
|
725
|
-
removeTextureAtlas(key) {
|
|
732
|
+
removeTextureAtlas(key: string) {
|
|
726
733
|
delete this._cache.atlas[key];
|
|
727
734
|
}
|
|
728
735
|
|
|
@@ -743,7 +750,7 @@ _cacheMap;
|
|
|
743
750
|
* @param {object} data - The data to associate with the resolved URL.
|
|
744
751
|
* @returns {string} The resolved URL or null if not enabled.
|
|
745
752
|
*/
|
|
746
|
-
_resolveURL(url, data) {
|
|
753
|
+
_resolveURL(url: string, data: any = null) {
|
|
747
754
|
if (!this.autoResolveURL) {
|
|
748
755
|
return null;
|
|
749
756
|
}
|
|
@@ -779,4 +786,4 @@ _cacheMap;
|
|
|
779
786
|
this._urlResolver = null;
|
|
780
787
|
this._urlTemp = null;
|
|
781
788
|
}
|
|
782
|
-
}
|
|
789
|
+
}
|
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
export class Device {
|
|
3
|
-
desktop;
|
|
4
|
-
iOS;
|
|
5
|
-
android;
|
|
6
|
-
chromeOS;
|
|
7
|
-
linux;
|
|
8
|
-
macOS;
|
|
9
|
-
windows;
|
|
10
|
-
windowsPhone;
|
|
11
|
-
canvas;
|
|
12
|
-
touch;
|
|
13
|
-
mspointer;
|
|
14
|
-
wheelEvent;
|
|
15
|
-
chrome;
|
|
16
|
-
firefox;
|
|
17
|
-
edge;
|
|
18
|
-
safari;
|
|
19
|
-
fullscreen;
|
|
20
|
-
requestFullscreen;
|
|
21
|
-
cancelFullscreen;
|
|
22
|
-
fullscreenKeyboard;
|
|
23
|
-
noAudioFormat;
|
|
24
|
-
supportedAudioFormats;
|
|
25
|
-
supportedImageFormats;
|
|
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;
|
|
26
25
|
/**
|
|
27
26
|
* Creates a new Device instance.
|
|
28
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);
|