@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.
- package/dist/index.js +997 -403
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +35 -11
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +20 -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 +68 -60
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts +23 -0
- 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 -158
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +8 -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 -58
- 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 +50 -3
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +66 -13
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +64 -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 +18 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +53 -9
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +19 -1
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +56 -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 +77 -17
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +3 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +25 -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 +58 -10
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +28 -9
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +10 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +7 -3
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +32 -5
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +30 -10
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts +11 -12
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +38 -14
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +30 -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 +8 -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 +35 -20
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +24 -8
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts +6 -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 +18 -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 +82 -23
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +42 -16
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts +11 -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 -9
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +36 -13
- 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 +8 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts +14 -2
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +5 -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 +17 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +5 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +7 -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 +11 -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 +12 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +25 -6
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +8 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +11 -0
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +14 -2
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +19 -2
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +8 -4
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +35 -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 +2 -2
- package/src/phaser/core/animation.ts +41 -18
- package/src/phaser/core/animation_manager.ts +21 -12
- 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 -60
- package/src/phaser/core/device.ts +23 -1
- 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 -177
- package/src/phaser/core/factory.ts +25 -17
- package/src/phaser/core/frame.ts +37 -51
- package/src/phaser/core/frame_data.ts +29 -74
- package/src/phaser/core/frame_util.ts +3 -16
- package/src/phaser/core/game.ts +40 -11
- package/src/phaser/core/input.ts +68 -17
- package/src/phaser/core/input_handler.ts +81 -45
- package/src/phaser/core/input_mouse.ts +42 -13
- package/src/phaser/core/input_mspointer.ts +24 -9
- package/src/phaser/core/input_pointer.ts +55 -12
- package/src/phaser/core/input_touch.ts +26 -9
- package/src/phaser/core/loader.ts +97 -42
- 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 -27
- package/src/phaser/core/scene.ts +3 -2
- package/src/phaser/core/scene_manager.ts +26 -11
- package/src/phaser/core/signal.ts +10 -10
- package/src/phaser/core/signal_binding.ts +2 -2
- package/src/phaser/core/sound.ts +72 -26
- package/src/phaser/core/sound_manager.ts +31 -13
- package/src/phaser/core/sound_sprite.ts +10 -5
- package/src/phaser/core/stage.ts +8 -4
- package/src/phaser/core/time.ts +33 -7
- package/src/phaser/core/timer.ts +40 -14
- package/src/phaser/core/timer_event.ts +23 -14
- package/src/phaser/core/tween.ts +43 -23
- package/src/phaser/core/tween_data.ts +31 -7
- package/src/phaser/core/tween_easing.ts +31 -31
- package/src/phaser/core/tween_manager.ts +10 -7
- package/src/phaser/core/world.ts +1 -2
- package/src/phaser/display/bitmap_text.ts +41 -18
- package/src/phaser/display/button.ts +24 -23
- package/src/phaser/display/canvas/buffer.ts +6 -3
- 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 -7
- 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 +120 -61
- package/src/phaser/display/graphics.ts +56 -25
- package/src/phaser/display/graphics_data.ts +11 -2
- package/src/phaser/display/graphics_data_util.ts +1 -2
- package/src/phaser/display/group.ts +32 -14
- package/src/phaser/display/image.ts +37 -19
- 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 -2
- package/src/phaser/display/webgl/base_texture.ts +14 -3
- package/src/phaser/display/webgl/blend_manager.ts +5 -3
- 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 -4
- package/src/phaser/display/webgl/filter_manager.ts +5 -2
- package/src/phaser/display/webgl/filter_texture.ts +7 -3
- package/src/phaser/display/webgl/graphics.ts +10 -11
- package/src/phaser/display/webgl/graphics_data.ts +11 -2
- package/src/phaser/display/webgl/mask_manager.ts +2 -3
- package/src/phaser/display/webgl/render_texture.ts +12 -2
- package/src/phaser/display/webgl/renderer.ts +24 -7
- package/src/phaser/display/webgl/shader/complex.ts +7 -2
- package/src/phaser/display/webgl/shader/fast.ts +8 -2
- package/src/phaser/display/webgl/shader/normal.ts +12 -2
- package/src/phaser/display/webgl/shader/primitive.ts +7 -2
- package/src/phaser/display/webgl/shader/strip.ts +7 -2
- package/src/phaser/display/webgl/shader_manager.ts +13 -3
- package/src/phaser/display/webgl/sprite_batch.ts +20 -4
- package/src/phaser/display/webgl/stencil_manager.ts +8 -5
- package/src/phaser/display/webgl/texture.ts +35 -4
- 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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Circle } from '../geom/circle.js';
|
|
3
2
|
import { Point } from '../geom/point.js';
|
|
4
3
|
import {
|
|
@@ -11,13 +10,57 @@ import {
|
|
|
11
10
|
} from './const.js';
|
|
12
11
|
|
|
13
12
|
export class Pointer {
|
|
13
|
+
game!: any;
|
|
14
|
+
id!: any;
|
|
15
|
+
type!: any;
|
|
16
|
+
exists!: any;
|
|
17
|
+
identifier!: any;
|
|
18
|
+
pointerId!: any;
|
|
19
|
+
pointerMode!: any;
|
|
20
|
+
target!: any;
|
|
21
|
+
button!: any;
|
|
22
|
+
_holdSent!: any;
|
|
23
|
+
_history!: any;
|
|
24
|
+
_nextDrop!: any;
|
|
25
|
+
_stateReset!: any;
|
|
26
|
+
withinGame!: any;
|
|
27
|
+
clientX!: any;
|
|
28
|
+
clientY!: any;
|
|
29
|
+
pageX!: any;
|
|
30
|
+
pageY!: any;
|
|
31
|
+
screenX!: any;
|
|
32
|
+
screenY!: any;
|
|
33
|
+
rawMovementX!: any;
|
|
34
|
+
rawMovementY!: any;
|
|
35
|
+
movementX!: any;
|
|
36
|
+
movementY!: any;
|
|
37
|
+
x!: any;
|
|
38
|
+
y!: any;
|
|
39
|
+
isMouse!: any;
|
|
40
|
+
isDown!: any;
|
|
41
|
+
isUp!: any;
|
|
42
|
+
timeDown!: any;
|
|
43
|
+
timeUp!: any;
|
|
44
|
+
previousTapTime!: any;
|
|
45
|
+
totalTouches!: any;
|
|
46
|
+
msSinceLastClick!: any;
|
|
47
|
+
targetObject!: any;
|
|
48
|
+
interactiveCandidates!: any;
|
|
49
|
+
active!: any;
|
|
50
|
+
dirty!: any;
|
|
51
|
+
position!: any;
|
|
52
|
+
positionDown!: any;
|
|
53
|
+
positionUp!: any;
|
|
54
|
+
circle!: any;
|
|
55
|
+
_clickTrampolines!: any;
|
|
56
|
+
_trampolineTargetObject!: any;
|
|
14
57
|
/**
|
|
15
58
|
* TBD.
|
|
16
59
|
* @param {import('./game.js').Game} game - TBD.
|
|
17
60
|
* @param {number} id - TBD.
|
|
18
61
|
* @param {number} pointerMode - TBD.
|
|
19
62
|
*/
|
|
20
|
-
constructor(game, id, pointerMode) {
|
|
63
|
+
constructor(game: import('./game.js').Game, id: number, pointerMode: number) {
|
|
21
64
|
this.game = game;
|
|
22
65
|
this.id = id;
|
|
23
66
|
/** @type {number} */
|
|
@@ -94,7 +137,7 @@ export class Pointer {
|
|
|
94
137
|
* TBD.
|
|
95
138
|
* @param {MouseEvent|PointerEvent} event - TBD.
|
|
96
139
|
*/
|
|
97
|
-
updateButtons(event) {
|
|
140
|
+
updateButtons(event: any|PointerEvent) {
|
|
98
141
|
if (event.type.toLowerCase().substr(-4) === 'down') {
|
|
99
142
|
this.isUp = false;
|
|
100
143
|
this.isDown = true;
|
|
@@ -109,7 +152,7 @@ export class Pointer {
|
|
|
109
152
|
* @param {PointerEvent} event - TBD.
|
|
110
153
|
* @returns {Pointer} TBD.
|
|
111
154
|
*/
|
|
112
|
-
start(event) {
|
|
155
|
+
start(event: any) {
|
|
113
156
|
const input = this.game.input;
|
|
114
157
|
if (event.pointerId) {
|
|
115
158
|
this.pointerId = event.pointerId;
|
|
@@ -198,7 +241,7 @@ export class Pointer {
|
|
|
198
241
|
* @param {boolean} fromClick - TBD.
|
|
199
242
|
* @returns {Pointer} TBD.
|
|
200
243
|
*/
|
|
201
|
-
move(event, fromClick = false) {
|
|
244
|
+
move(event: any|PointerEvent, fromClick: boolean = false) {
|
|
202
245
|
const input = this.game.input;
|
|
203
246
|
if (input.pollLocked) {
|
|
204
247
|
return null;
|
|
@@ -261,7 +304,7 @@ export class Pointer {
|
|
|
261
304
|
* @param {boolean} fromClick - TBD.
|
|
262
305
|
* @returns {boolean} TBD.
|
|
263
306
|
*/
|
|
264
|
-
processInteractiveObjects(fromClick = false) {
|
|
307
|
+
processInteractiveObjects(fromClick: boolean = false) {
|
|
265
308
|
// Work out which object is on the top
|
|
266
309
|
let highestRenderOrderID = 0;
|
|
267
310
|
let highestInputPriorityID = -1;
|
|
@@ -323,7 +366,7 @@ export class Pointer {
|
|
|
323
366
|
* @param {import('./input_handler.js').InputHandler} newTarget - TBD.
|
|
324
367
|
* @param {boolean} silent - TBD.
|
|
325
368
|
*/
|
|
326
|
-
swapTarget(newTarget, silent = false) {
|
|
369
|
+
swapTarget(newTarget: import('./input_handler.js').InputHandler, silent: boolean = false) {
|
|
327
370
|
// Now we know the top-most item (if any) we can process it
|
|
328
371
|
if (newTarget === null) {
|
|
329
372
|
// The pointer isn't currently over anything, check if we've got a lingering previous target
|
|
@@ -354,7 +397,7 @@ export class Pointer {
|
|
|
354
397
|
* TBD.
|
|
355
398
|
* @param {MouseEvent|PointerEvent} event - TBD.
|
|
356
399
|
*/
|
|
357
|
-
leave(event) {
|
|
400
|
+
leave(event: any|PointerEvent) {
|
|
358
401
|
this.withinGame = false;
|
|
359
402
|
this.move(event, false);
|
|
360
403
|
}
|
|
@@ -364,7 +407,7 @@ export class Pointer {
|
|
|
364
407
|
* @param {MouseEvent|PointerEvent} event - TBD.
|
|
365
408
|
* @returns {Pointer} TBD.
|
|
366
409
|
*/
|
|
367
|
-
stop(event) {
|
|
410
|
+
stop(event: any|PointerEvent) {
|
|
368
411
|
const input = this.game.input;
|
|
369
412
|
if (this._stateReset && this.withinGame) {
|
|
370
413
|
event.preventDefault();
|
|
@@ -420,7 +463,7 @@ export class Pointer {
|
|
|
420
463
|
* @param {number} duration - TBD.
|
|
421
464
|
* @returns {boolean} TBD.
|
|
422
465
|
*/
|
|
423
|
-
justPressed(duration) {
|
|
466
|
+
justPressed(duration: number) {
|
|
424
467
|
duration = duration || this.game.input.justPressedRate;
|
|
425
468
|
return this.isDown === true && this.timeDown + duration > this.game.time.time;
|
|
426
469
|
}
|
|
@@ -430,7 +473,7 @@ export class Pointer {
|
|
|
430
473
|
* @param {number} duration - TBD.
|
|
431
474
|
* @returns {boolean} TBD.
|
|
432
475
|
*/
|
|
433
|
-
justReleased(duration) {
|
|
476
|
+
justReleased(duration: number) {
|
|
434
477
|
duration = duration || this.game.input.justReleasedRate;
|
|
435
478
|
return this.isUp && this.timeUp + duration > this.game.time.time;
|
|
436
479
|
}
|
|
@@ -442,7 +485,7 @@ export class Pointer {
|
|
|
442
485
|
* @param {object} callbackContext - TBD.
|
|
443
486
|
* @param {...any} callbackArgs - TBD.
|
|
444
487
|
*/
|
|
445
|
-
addClickTrampoline(name, callback, callbackContext, callbackArgs) {
|
|
488
|
+
addClickTrampoline(name: string, callback: Function, callbackContext: any, callbackArgs: any) {
|
|
446
489
|
if (!this.isDown) {
|
|
447
490
|
return;
|
|
448
491
|
}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
export class Touch {
|
|
2
|
+
game!: any;
|
|
3
|
+
enabled!: any;
|
|
4
|
+
callbackContext!: any;
|
|
5
|
+
touchStartCallback!: any;
|
|
6
|
+
touchMoveCallback!: any;
|
|
7
|
+
touchEndCallback!: any;
|
|
8
|
+
touchEnterCallback!: any;
|
|
9
|
+
touchLeaveCallback!: any;
|
|
10
|
+
touchCancelCallback!: any;
|
|
11
|
+
preventDefault!: any;
|
|
12
|
+
event!: any;
|
|
13
|
+
_onTouchStart!: any;
|
|
14
|
+
_onTouchMove!: any;
|
|
15
|
+
_onTouchEnd!: any;
|
|
16
|
+
_onTouchEnter!: any;
|
|
17
|
+
_onTouchLeave!: any;
|
|
18
|
+
_onTouchCancel!: any;
|
|
19
|
+
_documentTouchMove!: any;
|
|
3
20
|
/**
|
|
4
21
|
* TBD.
|
|
5
22
|
* @param {import('./game.js').Game} game - TBD.
|
|
6
23
|
*/
|
|
7
|
-
constructor(game) {
|
|
24
|
+
constructor(game: import('./game.js').Game) {
|
|
8
25
|
this.game = game;
|
|
9
26
|
this.enabled = true;
|
|
10
27
|
this.callbackContext = this.game;
|
|
@@ -76,7 +93,7 @@ export class Touch {
|
|
|
76
93
|
* TBD.
|
|
77
94
|
* @param {TouchEvent} event - TBD.
|
|
78
95
|
*/
|
|
79
|
-
onTouchStart(event) {
|
|
96
|
+
onTouchStart(event: any) {
|
|
80
97
|
this.event = event;
|
|
81
98
|
if (!this.game.input.enabled || !this.enabled) {
|
|
82
99
|
return;
|
|
@@ -97,7 +114,7 @@ export class Touch {
|
|
|
97
114
|
* TBD.
|
|
98
115
|
* @param {TouchEvent} event - TBD.
|
|
99
116
|
*/
|
|
100
|
-
onTouchCancel(event) {
|
|
117
|
+
onTouchCancel(event: any) {
|
|
101
118
|
this.event = event;
|
|
102
119
|
if (this.touchCancelCallback) {
|
|
103
120
|
this.touchCancelCallback.call(this.callbackContext, event);
|
|
@@ -117,7 +134,7 @@ export class Touch {
|
|
|
117
134
|
* TBD.
|
|
118
135
|
* @param {TouchEvent} event - TBD.
|
|
119
136
|
*/
|
|
120
|
-
onTouchEnter(event) {
|
|
137
|
+
onTouchEnter(event: any) {
|
|
121
138
|
this.event = event;
|
|
122
139
|
if (this.touchEnterCallback) {
|
|
123
140
|
this.touchEnterCallback.call(this.callbackContext, event);
|
|
@@ -132,7 +149,7 @@ export class Touch {
|
|
|
132
149
|
* TBD.
|
|
133
150
|
* @param {TouchEvent} event - TBD.
|
|
134
151
|
*/
|
|
135
|
-
onTouchLeave(event) {
|
|
152
|
+
onTouchLeave(event: any) {
|
|
136
153
|
this.event = event;
|
|
137
154
|
if (this.touchLeaveCallback) {
|
|
138
155
|
this.touchLeaveCallback.call(this.callbackContext, event);
|
|
@@ -144,7 +161,7 @@ export class Touch {
|
|
|
144
161
|
* TBD.
|
|
145
162
|
* @param {TouchEvent} event - TBD.
|
|
146
163
|
*/
|
|
147
|
-
onTouchMove(event) {
|
|
164
|
+
onTouchMove(event: any) {
|
|
148
165
|
this.event = event;
|
|
149
166
|
if (this.touchMoveCallback) {
|
|
150
167
|
this.touchMoveCallback.call(this.callbackContext, event);
|
|
@@ -159,7 +176,7 @@ export class Touch {
|
|
|
159
176
|
* TBD.
|
|
160
177
|
* @param {TouchEvent} event - TBD.
|
|
161
178
|
*/
|
|
162
|
-
onTouchEnd(event) {
|
|
179
|
+
onTouchEnd(event: any) {
|
|
163
180
|
this.event = event;
|
|
164
181
|
if (this.touchEndCallback) {
|
|
165
182
|
this.touchEndCallback.call(this.callbackContext, event);
|
|
@@ -177,7 +194,7 @@ export class Touch {
|
|
|
177
194
|
* TBD.
|
|
178
195
|
* @param {TouchEvent} event - TBD.
|
|
179
196
|
*/
|
|
180
|
-
eventPreventDefault(event) {
|
|
197
|
+
eventPreventDefault(event: any) {
|
|
181
198
|
if (this.preventDefault) {
|
|
182
199
|
if (typeof event.cancelable !== 'boolean' || event.cancelable) {
|
|
183
200
|
event.preventDefault();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Rectangle } from '../geom/rectangle.js';
|
|
3
2
|
import { canPlayAudio } from './device_util.js';
|
|
4
3
|
import { ENGINE_ERROR_INVALID_BITMAP_FONT_ATLAS } from './error_code.js';
|
|
@@ -7,11 +6,39 @@ import { Signal } from './signal.js';
|
|
|
7
6
|
const TEXTURE_ATLAS_JSON_HASH = 1;
|
|
8
7
|
|
|
9
8
|
export class Loader {
|
|
9
|
+
game!: any;
|
|
10
|
+
cache!: any;
|
|
11
|
+
isLoading!: any;
|
|
12
|
+
isUseLog!: any;
|
|
13
|
+
isUseRetry!: any;
|
|
14
|
+
maxRetry!: any;
|
|
15
|
+
hasLoaded!: any;
|
|
16
|
+
preloadSprite!: any;
|
|
17
|
+
crossOrigin!: any;
|
|
18
|
+
baseURL!: any;
|
|
19
|
+
path!: any;
|
|
20
|
+
headers!: any;
|
|
21
|
+
onLoadStart!: any;
|
|
22
|
+
onLoadComplete!: any;
|
|
23
|
+
onPackComplete!: any;
|
|
24
|
+
onFileStart!: any;
|
|
25
|
+
onFileComplete!: any;
|
|
26
|
+
onFileError!: any;
|
|
27
|
+
maxParallelDownloads!: any;
|
|
28
|
+
_withSyncPointDepth!: any;
|
|
29
|
+
_fileList!: any;
|
|
30
|
+
_flightQueue!: any;
|
|
31
|
+
_processingHead!: any;
|
|
32
|
+
_fileLoadStarted!: any;
|
|
33
|
+
_totalPackCount!: any;
|
|
34
|
+
_totalFileCount!: any;
|
|
35
|
+
_loadedPackCount!: any;
|
|
36
|
+
_loadedFileCount!: any;
|
|
10
37
|
/**
|
|
11
38
|
* Creates a new Loader instance.
|
|
12
39
|
* @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
|
|
13
40
|
*/
|
|
14
|
-
constructor(game) {
|
|
41
|
+
constructor(game: import('./game.js').Game) {
|
|
15
42
|
this.game = game;
|
|
16
43
|
this.cache = game.cache;
|
|
17
44
|
this.isLoading = false;
|
|
@@ -51,7 +78,7 @@ export class Loader {
|
|
|
51
78
|
* @param {import('../display/image.js').Image} sprite - The image to use as the preload sprite.
|
|
52
79
|
* @param {number} direction - The direction of the progress (0 = horizontal, 1 = vertical).
|
|
53
80
|
*/
|
|
54
|
-
setPreloadSprite(sprite, direction = 0) {
|
|
81
|
+
setPreloadSprite(sprite: import('../display/image.js').Image, direction: number = 0) {
|
|
55
82
|
this.preloadSprite = {
|
|
56
83
|
sprite,
|
|
57
84
|
direction,
|
|
@@ -85,7 +112,7 @@ export class Loader {
|
|
|
85
112
|
* @param {string} key - The key of the file to check for.
|
|
86
113
|
* @returns {boolean} True if the file exists, false otherwise.
|
|
87
114
|
*/
|
|
88
|
-
checkKeyExists(type, key) {
|
|
115
|
+
checkKeyExists(type: string, key: string) {
|
|
89
116
|
return this.getAssetIndex(type, key) > -1;
|
|
90
117
|
}
|
|
91
118
|
|
|
@@ -95,7 +122,7 @@ export class Loader {
|
|
|
95
122
|
* @param {string} key - The key of the file to find.
|
|
96
123
|
* @returns {number} The index of the file in the list, or -1 if not found.
|
|
97
124
|
*/
|
|
98
|
-
getAssetIndex(type, key) {
|
|
125
|
+
getAssetIndex(type: string, key: string) {
|
|
99
126
|
let bestFound = -1;
|
|
100
127
|
for (let i = 0; i < this._fileList.length; i += 1) {
|
|
101
128
|
const file = this._fileList[i];
|
|
@@ -117,7 +144,7 @@ export class Loader {
|
|
|
117
144
|
* @param {string} key - The key of the file to get.
|
|
118
145
|
* @returns {{index: number, file: object} | null} The file and its index, or null if not found.
|
|
119
146
|
*/
|
|
120
|
-
getAsset(type, key) {
|
|
147
|
+
getAsset(type: string, key: string) {
|
|
121
148
|
const fileIndex = this.getAssetIndex(type, key);
|
|
122
149
|
if (fileIndex > -1) {
|
|
123
150
|
return { index: fileIndex, file: this._fileList[fileIndex] };
|
|
@@ -130,7 +157,7 @@ export class Loader {
|
|
|
130
157
|
* @param {boolean} hard - Whether to perform a hard reset (clears preload sprite).
|
|
131
158
|
* @param {boolean} clearEvents - Whether to clear event listeners.
|
|
132
159
|
*/
|
|
133
|
-
reset(hard = false, clearEvents = false) {
|
|
160
|
+
reset(hard: boolean = false, clearEvents: boolean = false) {
|
|
134
161
|
if (hard) {
|
|
135
162
|
this.preloadSprite = null;
|
|
136
163
|
}
|
|
@@ -163,7 +190,14 @@ export class Loader {
|
|
|
163
190
|
* @param {string} extension - The file extension to use if URL is not provided.
|
|
164
191
|
* @returns {Loader} This Loader instance for chaining.
|
|
165
192
|
*/
|
|
166
|
-
addToFileList(
|
|
193
|
+
addToFileList(
|
|
194
|
+
type: string,
|
|
195
|
+
key: string = '',
|
|
196
|
+
url: string = null,
|
|
197
|
+
properties: any = null,
|
|
198
|
+
overwrite: boolean = false,
|
|
199
|
+
extension: string = null
|
|
200
|
+
) {
|
|
167
201
|
if (key === undefined || key === '') {
|
|
168
202
|
this.game.logger.warn(`Loader: Invalid or no key given of type ${type}`);
|
|
169
203
|
return this;
|
|
@@ -218,7 +252,7 @@ export class Loader {
|
|
|
218
252
|
* @param {object} properties - The new properties for the file.
|
|
219
253
|
* @returns {Loader} This Loader instance for chaining.
|
|
220
254
|
*/
|
|
221
|
-
replaceInFileList(type, key, url, properties) {
|
|
255
|
+
replaceInFileList(type: string, key: string, url: string, properties: any) {
|
|
222
256
|
return this.addToFileList(type, key, url, properties, true);
|
|
223
257
|
}
|
|
224
258
|
|
|
@@ -230,7 +264,7 @@ export class Loader {
|
|
|
230
264
|
* @param {object} callbackContext - The context in which to call the callback.
|
|
231
265
|
* @returns {Loader} This Loader instance for chaining.
|
|
232
266
|
*/
|
|
233
|
-
pack(key, url, data, callbackContext) {
|
|
267
|
+
pack(key: string, url: string, data: any, callbackContext: any) {
|
|
234
268
|
const pack = {
|
|
235
269
|
type: 'packfile',
|
|
236
270
|
key: key,
|
|
@@ -268,7 +302,7 @@ export class Loader {
|
|
|
268
302
|
* @param {boolean} overwrite - Whether to overwrite an existing file with the same key.
|
|
269
303
|
* @returns {Loader} This Loader instance for chaining.
|
|
270
304
|
*/
|
|
271
|
-
image(key, url, overwrite = false) {
|
|
305
|
+
image(key: string, url?: any, overwrite: boolean = false) {
|
|
272
306
|
return this.addToFileList('image', key, url, undefined, overwrite, '.png');
|
|
273
307
|
}
|
|
274
308
|
|
|
@@ -278,7 +312,7 @@ export class Loader {
|
|
|
278
312
|
* @param {string[]} urls - The URLs of the image files to load.
|
|
279
313
|
* @returns {Loader} This Loader instance for chaining.
|
|
280
314
|
*/
|
|
281
|
-
images(keys, urls) {
|
|
315
|
+
images(keys: string[], urls: string[]) {
|
|
282
316
|
if (Array.isArray(urls)) {
|
|
283
317
|
for (let i = 0; i < keys.length; i += 1) {
|
|
284
318
|
this.image(keys[i], urls[i]);
|
|
@@ -298,7 +332,7 @@ export class Loader {
|
|
|
298
332
|
* @param {boolean} overwrite - Whether to overwrite an existing file with the same key.
|
|
299
333
|
* @returns {Loader} This Loader instance for chaining.
|
|
300
334
|
*/
|
|
301
|
-
text(key, url, overwrite = false) {
|
|
335
|
+
text(key: string, url: string, overwrite: boolean = false) {
|
|
302
336
|
return this.addToFileList('text', key, url, undefined, overwrite, '.txt');
|
|
303
337
|
}
|
|
304
338
|
|
|
@@ -309,7 +343,7 @@ export class Loader {
|
|
|
309
343
|
* @param {boolean} overwrite - Whether to overwrite an existing file with the same key.
|
|
310
344
|
* @returns {Loader} This Loader instance for chaining.
|
|
311
345
|
*/
|
|
312
|
-
json(key, url, overwrite = false) {
|
|
346
|
+
json(key: string, url: string, overwrite: boolean = false) {
|
|
313
347
|
return this.addToFileList('json', key, url, undefined, overwrite, '.json');
|
|
314
348
|
}
|
|
315
349
|
|
|
@@ -320,7 +354,7 @@ export class Loader {
|
|
|
320
354
|
* @param {boolean} overwrite - Whether to overwrite an existing file with the same key.
|
|
321
355
|
* @returns {Loader} This Loader instance for chaining.
|
|
322
356
|
*/
|
|
323
|
-
xml(key, url, overwrite = false) {
|
|
357
|
+
xml(key: string, url: string, overwrite: boolean = false) {
|
|
324
358
|
return this.addToFileList('xml', key, url, undefined, overwrite, '.xml');
|
|
325
359
|
}
|
|
326
360
|
|
|
@@ -335,7 +369,15 @@ export class Loader {
|
|
|
335
369
|
* @param {number} spacing - The spacing between frames in pixels.
|
|
336
370
|
* @returns {Loader} This Loader instance for chaining.
|
|
337
371
|
*/
|
|
338
|
-
spritesheet(
|
|
372
|
+
spritesheet(
|
|
373
|
+
key: string,
|
|
374
|
+
url: string,
|
|
375
|
+
frameWidth: number,
|
|
376
|
+
frameHeight: number,
|
|
377
|
+
frameMax: number = -1,
|
|
378
|
+
margin: number = 0,
|
|
379
|
+
spacing: number = 0
|
|
380
|
+
) {
|
|
339
381
|
return this.addToFileList(
|
|
340
382
|
'spritesheet',
|
|
341
383
|
key,
|
|
@@ -353,7 +395,7 @@ export class Loader {
|
|
|
353
395
|
* @param {boolean} autoDecode - Whether to automatically decode the audio file.
|
|
354
396
|
* @returns {Loader} This Loader instance for chaining.
|
|
355
397
|
*/
|
|
356
|
-
audio(key, urls, autoDecode = true) {
|
|
398
|
+
audio(key: string, urls: any, autoDecode: boolean = true) {
|
|
357
399
|
if (this.game.sound.noAudio || this.game.device.noAudioFormat) {
|
|
358
400
|
return this;
|
|
359
401
|
}
|
|
@@ -372,7 +414,7 @@ export class Loader {
|
|
|
372
414
|
* @param {boolean} autoDecode - Whether to automatically decode the audio file.
|
|
373
415
|
* @returns {Loader} This Loader instance for chaining.
|
|
374
416
|
*/
|
|
375
|
-
audioSprite(key, urls, jsonURL, jsonData, autoDecode = true) {
|
|
417
|
+
audioSprite(key: string, urls: string, jsonURL: string, jsonData: any, autoDecode: boolean = true) {
|
|
376
418
|
if (this.game.sound.noAudio || this.game.device.noAudioFormat) {
|
|
377
419
|
return this;
|
|
378
420
|
}
|
|
@@ -399,7 +441,14 @@ export class Loader {
|
|
|
399
441
|
* @returns {Loader} This Loader instance for chaining.
|
|
400
442
|
* @throws {Error} If the bitmap font atlas data is invalid.
|
|
401
443
|
*/
|
|
402
|
-
bitmapFont(
|
|
444
|
+
bitmapFont(
|
|
445
|
+
key: string,
|
|
446
|
+
textureURL: string = null,
|
|
447
|
+
atlasURL: string = null,
|
|
448
|
+
atlasData: any = null,
|
|
449
|
+
xSpacing: number = 0,
|
|
450
|
+
ySpacing: number = 0
|
|
451
|
+
) {
|
|
403
452
|
if (textureURL === undefined || textureURL === null) {
|
|
404
453
|
textureURL = `${key}.png`;
|
|
405
454
|
}
|
|
@@ -441,7 +490,13 @@ export class Loader {
|
|
|
441
490
|
* @param {number} format - The format of the atlas file (JSON or XML).
|
|
442
491
|
* @returns {Loader} This Loader instance for chaining.
|
|
443
492
|
*/
|
|
444
|
-
atlas(
|
|
493
|
+
atlas(
|
|
494
|
+
key: string,
|
|
495
|
+
textureURL: string,
|
|
496
|
+
atlasURL: string = null,
|
|
497
|
+
atlasData: any = null,
|
|
498
|
+
format: number = TEXTURE_ATLAS_JSON_HASH
|
|
499
|
+
) {
|
|
445
500
|
if (textureURL === undefined || textureURL === null) {
|
|
446
501
|
textureURL = `${key}.png`;
|
|
447
502
|
}
|
|
@@ -463,7 +518,7 @@ export class Loader {
|
|
|
463
518
|
* @param {object} callbackContext - The context in which to call the callback.
|
|
464
519
|
* @returns {Loader} This Loader instance for chaining.
|
|
465
520
|
*/
|
|
466
|
-
withSyncPoint(callback, callbackContext) {
|
|
521
|
+
withSyncPoint(callback: Function, callbackContext: any) {
|
|
467
522
|
this._withSyncPointDepth += 1;
|
|
468
523
|
try {
|
|
469
524
|
callback.call(callbackContext || this, this);
|
|
@@ -479,7 +534,7 @@ export class Loader {
|
|
|
479
534
|
* @param {string} key - The key of the file to add a sync point to.
|
|
480
535
|
* @returns {Loader} This Loader instance for chaining.
|
|
481
536
|
*/
|
|
482
|
-
addSyncPoint(type, key) {
|
|
537
|
+
addSyncPoint(type: string, key: string) {
|
|
483
538
|
const asset = this.getAsset(type, key);
|
|
484
539
|
if (asset) {
|
|
485
540
|
asset.file.syncPoint = true;
|
|
@@ -492,10 +547,10 @@ export class Loader {
|
|
|
492
547
|
* @param {string} type - The type of file to remove.
|
|
493
548
|
* @param {string} key - The key of the file to remove.
|
|
494
549
|
*/
|
|
495
|
-
removeFile(type, key) {
|
|
550
|
+
removeFile(type: string, key: string) {
|
|
496
551
|
const asset = this.getAsset(type, key);
|
|
497
552
|
if (asset) {
|
|
498
|
-
if (!asset.loaded && !asset.loading) {
|
|
553
|
+
if (!asset.file.loaded && !asset.file.loading) {
|
|
499
554
|
this._fileList.splice(asset.index, 1);
|
|
500
555
|
}
|
|
501
556
|
}
|
|
@@ -624,7 +679,7 @@ export class Loader {
|
|
|
624
679
|
* Finishes the loading process, optionally reporting an abnormal termination.
|
|
625
680
|
* @param {boolean} abnormal - Whether the loading was terminated abnormally.
|
|
626
681
|
*/
|
|
627
|
-
finishedLoading(abnormal = false) {
|
|
682
|
+
finishedLoading(abnormal: boolean = false) {
|
|
628
683
|
if (this.hasLoaded) {
|
|
629
684
|
return;
|
|
630
685
|
}
|
|
@@ -648,7 +703,7 @@ export class Loader {
|
|
|
648
703
|
* @param {object} file - The file to complete or mark as failed.
|
|
649
704
|
* @param {string} errorMessage - An error message if the file failed to load.
|
|
650
705
|
*/
|
|
651
|
-
asyncComplete(file, errorMessage = '') {
|
|
706
|
+
asyncComplete(file: any, errorMessage: string = '') {
|
|
652
707
|
file.loaded = true;
|
|
653
708
|
file.error = !!errorMessage;
|
|
654
709
|
if (file.error) {
|
|
@@ -663,7 +718,7 @@ export class Loader {
|
|
|
663
718
|
* Processes a pack file, adding its contained files to the loader.
|
|
664
719
|
* @param {object} pack - The pack file object to process.
|
|
665
720
|
*/
|
|
666
|
-
processPack(pack) {
|
|
721
|
+
processPack(pack: any) {
|
|
667
722
|
const packData = pack.data[pack.key];
|
|
668
723
|
if (!packData) {
|
|
669
724
|
this.game.logger.warn('Missing loader pack key', { key: pack.key });
|
|
@@ -728,7 +783,7 @@ export class Loader {
|
|
|
728
783
|
* @param {object} file - The file object containing path information.
|
|
729
784
|
* @returns {string} The transformed URL.
|
|
730
785
|
*/
|
|
731
|
-
transformUrl(url, file) {
|
|
786
|
+
transformUrl(url: any, file: any): any {
|
|
732
787
|
if (!url) {
|
|
733
788
|
return false;
|
|
734
789
|
}
|
|
@@ -742,7 +797,7 @@ export class Loader {
|
|
|
742
797
|
* Loads a file using XMLHttpRequest, handling image files specially.
|
|
743
798
|
* @param {object} file - The file object to load.
|
|
744
799
|
*/
|
|
745
|
-
loadFile(file) {
|
|
800
|
+
loadFile(file: any) {
|
|
746
801
|
switch (file.type) {
|
|
747
802
|
case 'packfile':
|
|
748
803
|
this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.fileComplete);
|
|
@@ -784,7 +839,7 @@ export class Loader {
|
|
|
784
839
|
* Loads an image file using the Image DOM element.
|
|
785
840
|
* @param {object} file - The file object to load.
|
|
786
841
|
*/
|
|
787
|
-
loadImageTag(file) {
|
|
842
|
+
loadImageTag(file: any) {
|
|
788
843
|
this.log('loadImageTag', file);
|
|
789
844
|
const scope = this;
|
|
790
845
|
file.data = new Image();
|
|
@@ -822,7 +877,7 @@ export class Loader {
|
|
|
822
877
|
* @param {Function} onload - The function to call when the file loads successfully.
|
|
823
878
|
* @param {Function} onerror - The function to call if the file fails to load.
|
|
824
879
|
*/
|
|
825
|
-
xhrLoad(file, url, type, onload, onerror = null) {
|
|
880
|
+
xhrLoad(file: any, url: any, type: any, onload: Function, onerror: Function = null) {
|
|
826
881
|
this.log('xhrLoad', file);
|
|
827
882
|
const scope = this;
|
|
828
883
|
const xhr = new XMLHttpRequest();
|
|
@@ -855,7 +910,7 @@ export class Loader {
|
|
|
855
910
|
// If this was the last file in the queue and an error is thrown in the create method
|
|
856
911
|
// then it's caught here, so be sure we don't carry on processing it
|
|
857
912
|
if (!scope.hasLoaded) {
|
|
858
|
-
scope.asyncComplete(file,
|
|
913
|
+
scope.asyncComplete(file, typedError.message || 'Exception');
|
|
859
914
|
} else {
|
|
860
915
|
scope.game.logger.exception('Loader', typedError);
|
|
861
916
|
}
|
|
@@ -874,7 +929,7 @@ export class Loader {
|
|
|
874
929
|
} catch (error) {
|
|
875
930
|
const typedError = error instanceof Error ? error : new Error(String(error));
|
|
876
931
|
if (!scope.hasLoaded) {
|
|
877
|
-
scope.asyncComplete(file,
|
|
932
|
+
scope.asyncComplete(file, typedError.message || 'Exception');
|
|
878
933
|
} else {
|
|
879
934
|
scope.game.logger.exception('Loader', typedError);
|
|
880
935
|
}
|
|
@@ -900,7 +955,7 @@ export class Loader {
|
|
|
900
955
|
* @param {object[]} urls - The array of URLs to check for supported audio formats.
|
|
901
956
|
* @returns {string} The first URL with a supported audio format, or null if none found.
|
|
902
957
|
*/
|
|
903
|
-
getAudioURL(urls) {
|
|
958
|
+
getAudioURL(urls: any[]) {
|
|
904
959
|
if (this.game.sound.noAudio || this.game.device.noAudioFormat) {
|
|
905
960
|
return null;
|
|
906
961
|
}
|
|
@@ -941,7 +996,7 @@ export class Loader {
|
|
|
941
996
|
* @param {XMLHttpRequest} xhr - The XMLHttpRequest object that failed.
|
|
942
997
|
* @param {number | string} reason - The error code or message explaining the failure.
|
|
943
998
|
*/
|
|
944
|
-
fileError(file, xhr = null, reason = 0) {
|
|
999
|
+
fileError(file: any, xhr: any = null, reason: any = 0) {
|
|
945
1000
|
// const url = file.requestUrl || this.transformUrl(file.url, file);
|
|
946
1001
|
if (!reason && xhr) {
|
|
947
1002
|
reason = xhr.status;
|
|
@@ -956,7 +1011,7 @@ export class Loader {
|
|
|
956
1011
|
* @param {XMLHttpRequest} xhr - TBD.
|
|
957
1012
|
* @throws {Error}
|
|
958
1013
|
*/
|
|
959
|
-
fileComplete(file, xhr) {
|
|
1014
|
+
fileComplete(file: any, xhr?: any) {
|
|
960
1015
|
let loadNext = true;
|
|
961
1016
|
switch (file.type) {
|
|
962
1017
|
case 'packfile':
|
|
@@ -1047,7 +1102,7 @@ export class Loader {
|
|
|
1047
1102
|
* @param {object} file - The file object that was loaded successfully.
|
|
1048
1103
|
* @param {XMLHttpRequest} xhr - The XMLHttpRequest object containing the file data.
|
|
1049
1104
|
*/
|
|
1050
|
-
jsonLoadComplete(file, xhr) {
|
|
1105
|
+
jsonLoadComplete(file: any, xhr: XMLHttpRequest) {
|
|
1051
1106
|
const data = JSON.parse(xhr.responseText);
|
|
1052
1107
|
if (file.type === 'bitmapfont') {
|
|
1053
1108
|
this.cache.addBitmapFont(file.key, file.url, file.data, data, file.atlasType, file.xSpacing, file.ySpacing);
|
|
@@ -1072,12 +1127,12 @@ export class Loader {
|
|
|
1072
1127
|
* @param {object} file - The file object containing the JSON data.
|
|
1073
1128
|
* @param {XMLHttpRequest} xhr - The XMLHttpRequest object containing the file data.
|
|
1074
1129
|
*/
|
|
1075
|
-
xmlLoadComplete(file, xhr) {
|
|
1130
|
+
xmlLoadComplete(file: any, xhr: XMLHttpRequest) {
|
|
1076
1131
|
// Always try parsing the content as XML, regardless of actually response type
|
|
1077
1132
|
const data = xhr.responseText;
|
|
1078
1133
|
const xml = this.parseXml(data);
|
|
1079
1134
|
if (!xml) {
|
|
1080
|
-
const responseType = xhr.responseType || xhr.contentType; // contentType for MS-XDomainRequest
|
|
1135
|
+
const responseType = xhr.responseType || (xhr as any).contentType; // contentType for MS-XDomainRequest
|
|
1081
1136
|
this.game.logger.warn(`${file.key}: invalid XML (${responseType})`);
|
|
1082
1137
|
this.asyncComplete(file, 'invalid XML');
|
|
1083
1138
|
return;
|
|
@@ -1097,7 +1152,7 @@ export class Loader {
|
|
|
1097
1152
|
* @param {object} data - The XML string data to parse.
|
|
1098
1153
|
* @returns {Document} The parsed DOM Document, or null if parsing failed.
|
|
1099
1154
|
*/
|
|
1100
|
-
parseXml(data) {
|
|
1155
|
+
parseXml(data: any) {
|
|
1101
1156
|
let xml = null;
|
|
1102
1157
|
try {
|
|
1103
1158
|
if (window.DOMParser) {
|
|
@@ -1142,7 +1197,7 @@ export class Loader {
|
|
|
1142
1197
|
* @param {string} message - The message to log.
|
|
1143
1198
|
* @param {string|object} data - Additional data to log with the message.
|
|
1144
1199
|
*/
|
|
1145
|
-
log(message, data = '') {
|
|
1200
|
+
log(message: string, data: string | any = '') {
|
|
1146
1201
|
if (!this.isUseLog) {
|
|
1147
1202
|
return;
|
|
1148
1203
|
}
|
|
@@ -1197,4 +1252,4 @@ export class Loader {
|
|
|
1197
1252
|
get progress() {
|
|
1198
1253
|
return Math.round(this.progressFloat);
|
|
1199
1254
|
}
|
|
1200
|
-
}
|
|
1255
|
+
}
|