@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 { Texture } from '../display/webgl/texture.js';
|
|
3
2
|
import { Rectangle } from '../geom/rectangle.js';
|
|
4
3
|
|
|
@@ -8,7 +7,7 @@ import { Rectangle } from '../geom/rectangle.js';
|
|
|
8
7
|
* @param {object} bitmapFontData - The bitmap font data to finalize.
|
|
9
8
|
* @returns {object} The finalized bitmap font data.
|
|
10
9
|
*/
|
|
11
|
-
export const finalizeBitmapFont = (baseTexture, bitmapFontData) => {
|
|
10
|
+
export const finalizeBitmapFont = (baseTexture: import('../display/webgl/base_texture.js').BaseTexture, bitmapFontData: any) => {
|
|
12
11
|
Object.keys(bitmapFontData.chars).forEach((charCode) => {
|
|
13
12
|
const letter = bitmapFontData.chars[charCode];
|
|
14
13
|
letter.texture = new Texture(baseTexture, new Rectangle(letter.x, letter.y, letter.width, letter.height));
|
|
@@ -24,8 +23,8 @@ export const finalizeBitmapFont = (baseTexture, bitmapFontData) => {
|
|
|
24
23
|
* @param {number} ySpacing - Vertical spacing between characters.
|
|
25
24
|
* @returns {object} The parsed bitmap font data.
|
|
26
25
|
*/
|
|
27
|
-
export const xmlBitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
|
|
28
|
-
const data = {};
|
|
26
|
+
export const xmlBitmapFont = (xml: any, baseTexture: import('../display/webgl/base_texture.js').BaseTexture, xSpacing: number, ySpacing: number) => {
|
|
27
|
+
const data: any = {};
|
|
29
28
|
const info = xml.getElementsByTagName('info')[0];
|
|
30
29
|
const common = xml.getElementsByTagName('common')[0];
|
|
31
30
|
data.font = info.getAttribute('face');
|
|
@@ -64,7 +63,7 @@ export const xmlBitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
|
|
|
64
63
|
* @param {number} ySpacing - Vertical spacing between characters.
|
|
65
64
|
* @returns {object} The parsed bitmap font data.
|
|
66
65
|
*/
|
|
67
|
-
export const bitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
|
|
66
|
+
export const bitmapFont = (xml: any, baseTexture: import('../display/webgl/base_texture.js').BaseTexture, xSpacing: number, ySpacing: number) => {
|
|
68
67
|
return xmlBitmapFont(xml, baseTexture, xSpacing, ySpacing);
|
|
69
68
|
};
|
|
70
69
|
|
|
@@ -76,7 +75,7 @@ export const bitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
|
|
|
76
75
|
* @param {number} ySpacing - Vertical spacing between characters.
|
|
77
76
|
* @returns {object} The parsed bitmap font data.
|
|
78
77
|
*/
|
|
79
|
-
export const jsonBitmapFont = (json, baseTexture, xSpacing, ySpacing) => {
|
|
78
|
+
export const jsonBitmapFont = (json: any, baseTexture: import('../display/webgl/base_texture.js').BaseTexture, xSpacing: number, ySpacing: number) => {
|
|
80
79
|
const data = {
|
|
81
80
|
font: json.font.info._face,
|
|
82
81
|
size: Number.parseInt(json.font.info._size, 10),
|
|
@@ -102,4 +101,4 @@ export const jsonBitmapFont = (json, baseTexture, xSpacing, ySpacing) => {
|
|
|
102
101
|
});
|
|
103
102
|
}
|
|
104
103
|
return finalizeBitmapFont(baseTexture, data);
|
|
105
|
-
};
|
|
104
|
+
};
|
package/src/phaser/core/raf.ts
CHANGED
|
@@ -6,7 +6,7 @@ export class RequestAnimationFrame {
|
|
|
6
6
|
* Constructor.
|
|
7
7
|
* @param {import('./game.js').Game} game - Reference to the game instance.
|
|
8
8
|
*/
|
|
9
|
-
constructor(game) {
|
|
9
|
+
constructor(game: import('./game.js').Game) {
|
|
10
10
|
this.game = game;
|
|
11
11
|
this.rafId = 0;
|
|
12
12
|
}
|
|
@@ -29,7 +29,7 @@ export class RequestAnimationFrame {
|
|
|
29
29
|
* Performs an animation frame request.
|
|
30
30
|
* @param {number} rafTime - The timestamp provided by the browser's animation frame.
|
|
31
31
|
*/
|
|
32
|
-
update = (rafTime) => {
|
|
32
|
+
update = (rafTime: number) => {
|
|
33
33
|
this.game.update(rafTime);
|
|
34
34
|
this.rafId = requestAnimationFrame(this.update);
|
|
35
35
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Point } from '../geom/point.js';
|
|
3
2
|
import { Rectangle } from '../geom/rectangle.js';
|
|
4
3
|
import { RENDER_CANVAS, SCALE_EXACT_FIT, SCALE_OFF, SCALE_RESIZE, SCALE_SHOW_ALL, SCALE_USER } from './const.js';
|
|
@@ -6,13 +5,72 @@ import { DOM } from './dom.js';
|
|
|
6
5
|
import { Signal } from './signal.js';
|
|
7
6
|
|
|
8
7
|
export class ScaleManager {
|
|
8
|
+
game!: any;
|
|
9
|
+
dom!: any;
|
|
10
|
+
width!: any;
|
|
11
|
+
height!: any;
|
|
12
|
+
minWidth!: any;
|
|
13
|
+
maxWidth!: any;
|
|
14
|
+
minHeight!: any;
|
|
15
|
+
maxHeight!: any;
|
|
16
|
+
offset!: any;
|
|
17
|
+
forceLandscape!: any;
|
|
18
|
+
forcePortrait!: any;
|
|
19
|
+
incorrectOrientation!: any;
|
|
20
|
+
_pageAlignHorizontally!: any;
|
|
21
|
+
_pageAlignVertically!: any;
|
|
22
|
+
onOrientationChange!: any;
|
|
23
|
+
enterIncorrectOrientation!: any;
|
|
24
|
+
leaveIncorrectOrientation!: any;
|
|
25
|
+
hasPhaserSetFullScreen!: any;
|
|
26
|
+
fullScreenTarget!: any;
|
|
27
|
+
_createdFullScreenTarget!: any;
|
|
28
|
+
onFullScreenInit!: any;
|
|
29
|
+
onFullScreenChange!: any;
|
|
30
|
+
onFullScreenError!: any;
|
|
31
|
+
screenOrientation!: any;
|
|
32
|
+
scaleFactor!: any;
|
|
33
|
+
scaleFactorInversed!: any;
|
|
34
|
+
margin!: any;
|
|
35
|
+
bounds!: any;
|
|
36
|
+
aspectRatio!: any;
|
|
37
|
+
sourceAspectRatio!: any;
|
|
38
|
+
event!: any;
|
|
39
|
+
windowConstraints!: any;
|
|
40
|
+
compatibility!: any;
|
|
41
|
+
_scaleMode!: any;
|
|
42
|
+
_fullScreenScaleMode!: any;
|
|
43
|
+
parentIsWindow!: any;
|
|
44
|
+
parentNode!: any;
|
|
45
|
+
parentScaleFactor!: any;
|
|
46
|
+
trackParentInterval!: any;
|
|
47
|
+
onSizeChange!: any;
|
|
48
|
+
onResize!: any;
|
|
49
|
+
onResizeContext!: any;
|
|
50
|
+
_pendingScaleMode!: any;
|
|
51
|
+
_fullScreenRestore!: any;
|
|
52
|
+
_gameSize!: any;
|
|
53
|
+
_userScaleFactor!: any;
|
|
54
|
+
_userScaleTrim!: any;
|
|
55
|
+
_lastUpdate!: any;
|
|
56
|
+
_updateThrottle!: any;
|
|
57
|
+
_updateThrottleReset!: any;
|
|
58
|
+
_parentBounds!: any;
|
|
59
|
+
_tempBounds!: any;
|
|
60
|
+
_lastReportedCanvasSize!: any;
|
|
61
|
+
_lastReportedGameSize!: any;
|
|
62
|
+
_booted!: any;
|
|
63
|
+
_orientationChange!: any;
|
|
64
|
+
_windowResize!: any;
|
|
65
|
+
_fullScreenChange!: any;
|
|
66
|
+
_fullScreenError!: any;
|
|
9
67
|
/**
|
|
10
68
|
* TBD.
|
|
11
69
|
* @param {import('./game.js').Game} game - TBD.
|
|
12
70
|
* @param {number} width - TBD.
|
|
13
71
|
* @param {number} height - TBD.
|
|
14
72
|
*/
|
|
15
|
-
constructor(game, width, height) {
|
|
73
|
+
constructor(game: import('./game.js').Game, width: number, height: number) {
|
|
16
74
|
this.game = game;
|
|
17
75
|
this.dom = new DOM(game.device);
|
|
18
76
|
this.width = 0;
|
|
@@ -142,7 +200,7 @@ export class ScaleManager {
|
|
|
142
200
|
* TBD.
|
|
143
201
|
* @param {object} config - TBD.
|
|
144
202
|
*/
|
|
145
|
-
parseConfig(config) {
|
|
203
|
+
parseConfig(config: any) {
|
|
146
204
|
if (config.scaleMode !== undefined) {
|
|
147
205
|
if (this._booted) {
|
|
148
206
|
this.scaleMode = config.scaleMode;
|
|
@@ -165,7 +223,7 @@ export class ScaleManager {
|
|
|
165
223
|
* @param {number} width - TBD.
|
|
166
224
|
* @param {number} height - TBD.
|
|
167
225
|
*/
|
|
168
|
-
setupScale(width, height) {
|
|
226
|
+
setupScale(width: number, height: number) {
|
|
169
227
|
let target;
|
|
170
228
|
const rect = new Rectangle();
|
|
171
229
|
if (this.game.parent !== '') {
|
|
@@ -227,7 +285,7 @@ export class ScaleManager {
|
|
|
227
285
|
* @param {number} width - TBD.
|
|
228
286
|
* @param {number} height - TBD.
|
|
229
287
|
*/
|
|
230
|
-
setGameSize(width, height) {
|
|
288
|
+
setGameSize(width: number, height: number) {
|
|
231
289
|
this._gameSize.setTo(0, 0, width, height);
|
|
232
290
|
if (this.currentScaleMode !== SCALE_RESIZE) {
|
|
233
291
|
this.updateDimensions(width, height, true);
|
|
@@ -242,7 +300,7 @@ export class ScaleManager {
|
|
|
242
300
|
* @param {number} hTrim - TBD.
|
|
243
301
|
* @param {number} vTrim - TBD.
|
|
244
302
|
*/
|
|
245
|
-
setUserScale(hScale, vScale, hTrim, vTrim) {
|
|
303
|
+
setUserScale(hScale: number, vScale: number, hTrim: number, vTrim: number) {
|
|
246
304
|
this._userScaleFactor.setTo(hScale, vScale);
|
|
247
305
|
this._userScaleTrim.setTo(hTrim | 0, vTrim | 0);
|
|
248
306
|
this.queueUpdate(true);
|
|
@@ -253,7 +311,7 @@ export class ScaleManager {
|
|
|
253
311
|
* @param {Function} callback - TBD.
|
|
254
312
|
* @param {object} context - TBD.
|
|
255
313
|
*/
|
|
256
|
-
setResizeCallback(callback, context) {
|
|
314
|
+
setResizeCallback(callback: Function, context: any) {
|
|
257
315
|
this.onResize = callback;
|
|
258
316
|
this.onResizeContext = context;
|
|
259
317
|
}
|
|
@@ -288,7 +346,7 @@ export class ScaleManager {
|
|
|
288
346
|
* @param {number} maxWidth - TBD.
|
|
289
347
|
* @param {number} maxHeight - TBD.
|
|
290
348
|
*/
|
|
291
|
-
setMinMax(minWidth, minHeight, maxWidth, maxHeight) {
|
|
349
|
+
setMinMax(minWidth: number, minHeight: number, maxWidth: number, maxHeight: number) {
|
|
292
350
|
this.minWidth = minWidth;
|
|
293
351
|
this.minHeight = minHeight;
|
|
294
352
|
if (typeof maxWidth !== 'undefined') {
|
|
@@ -347,7 +405,7 @@ export class ScaleManager {
|
|
|
347
405
|
* @param {number} height - TBD.
|
|
348
406
|
* @param {boolean} resize - TBD.
|
|
349
407
|
*/
|
|
350
|
-
updateDimensions(width, height, resize) {
|
|
408
|
+
updateDimensions(width: number, height: number, resize: boolean) {
|
|
351
409
|
this.width = width * this.parentScaleFactor.x;
|
|
352
410
|
this.height = height * this.parentScaleFactor.y;
|
|
353
411
|
this.game.width = this.width;
|
|
@@ -385,7 +443,7 @@ export class ScaleManager {
|
|
|
385
443
|
* @param {boolean} forceLandscape - TBD.
|
|
386
444
|
* @param {boolean} forcePortrait - TBD.
|
|
387
445
|
*/
|
|
388
|
-
forceOrientation(forceLandscape = false, forcePortrait = false) {
|
|
446
|
+
forceOrientation(forceLandscape: boolean = false, forcePortrait: boolean = false) {
|
|
389
447
|
this.forceLandscape = forceLandscape;
|
|
390
448
|
this.forcePortrait = forcePortrait;
|
|
391
449
|
this.queueUpdate(true);
|
|
@@ -396,7 +454,7 @@ export class ScaleManager {
|
|
|
396
454
|
* @param {string} orientation - TBD.
|
|
397
455
|
* @returns {string} TBD.
|
|
398
456
|
*/
|
|
399
|
-
classifyOrientation(orientation) {
|
|
457
|
+
classifyOrientation(orientation: string) {
|
|
400
458
|
if (orientation === 'portrait-primary' || orientation === 'portrait-secondary') {
|
|
401
459
|
return 'portrait';
|
|
402
460
|
} else if (orientation === 'landscape-primary' || orientation === 'landscape-secondary') {
|
|
@@ -433,7 +491,7 @@ export class ScaleManager {
|
|
|
433
491
|
* TBD.
|
|
434
492
|
* @param {Event} event - TBD.
|
|
435
493
|
*/
|
|
436
|
-
orientationChange(event) {
|
|
494
|
+
orientationChange(event: Event) {
|
|
437
495
|
this.event = event;
|
|
438
496
|
this.queueUpdate(true);
|
|
439
497
|
}
|
|
@@ -442,7 +500,7 @@ export class ScaleManager {
|
|
|
442
500
|
* TBD.
|
|
443
501
|
* @param {Event} event - TBD.
|
|
444
502
|
*/
|
|
445
|
-
windowResize(event) {
|
|
503
|
+
windowResize(event: Event) {
|
|
446
504
|
this.event = event;
|
|
447
505
|
this.queueUpdate(true);
|
|
448
506
|
}
|
|
@@ -501,7 +559,7 @@ export class ScaleManager {
|
|
|
501
559
|
* @param {Rectangle} target - TBD.
|
|
502
560
|
* @returns {Rectangle} TBD.
|
|
503
561
|
*/
|
|
504
|
-
getParentBounds(target) {
|
|
562
|
+
getParentBounds(target: Rectangle) {
|
|
505
563
|
const bounds = target || new Rectangle();
|
|
506
564
|
const parentNode = this.boundingParent;
|
|
507
565
|
const visualBounds = this.dom.visualBounds;
|
|
@@ -539,7 +597,7 @@ export class ScaleManager {
|
|
|
539
597
|
* @param {boolean} horizontal - TBD.
|
|
540
598
|
* @param {boolean} vertical - TBD.
|
|
541
599
|
*/
|
|
542
|
-
alignCanvas(horizontal, vertical) {
|
|
600
|
+
alignCanvas(horizontal: boolean, vertical: boolean) {
|
|
543
601
|
const parentBounds = this.getParentBounds(this._tempBounds);
|
|
544
602
|
const canvas = this.game.canvas;
|
|
545
603
|
const margin = this.margin;
|
|
@@ -615,7 +673,7 @@ export class ScaleManager {
|
|
|
615
673
|
* @param {string} cssWidth - TBD.
|
|
616
674
|
* @param {string} cssHeight - TBD.
|
|
617
675
|
*/
|
|
618
|
-
resetCanvas(cssWidth = `${this.width}px`, cssHeight = `${this.height}px`) {
|
|
676
|
+
resetCanvas(cssWidth: string = `${this.width}px`, cssHeight: string = `${this.height}px`) {
|
|
619
677
|
const canvas = this.game.canvas;
|
|
620
678
|
if (!this.compatibility.noMargins) {
|
|
621
679
|
canvas.style.marginLeft = '';
|
|
@@ -631,7 +689,7 @@ export class ScaleManager {
|
|
|
631
689
|
* TBD.
|
|
632
690
|
* @param {boolean} force - TBD.
|
|
633
691
|
*/
|
|
634
|
-
queueUpdate(force) {
|
|
692
|
+
queueUpdate(force: boolean) {
|
|
635
693
|
if (force) {
|
|
636
694
|
this._parentBounds.width = 0;
|
|
637
695
|
this._parentBounds.height = 0;
|
|
@@ -658,7 +716,7 @@ export class ScaleManager {
|
|
|
658
716
|
* TBD.
|
|
659
717
|
* @param {boolean} expanding - TBD.
|
|
660
718
|
*/
|
|
661
|
-
setShowAll(expanding = false) {
|
|
719
|
+
setShowAll(expanding: boolean = false) {
|
|
662
720
|
const bounds = this.getParentBounds(this._tempBounds);
|
|
663
721
|
const width = bounds.width;
|
|
664
722
|
const height = bounds.height;
|
|
@@ -709,7 +767,7 @@ export class ScaleManager {
|
|
|
709
767
|
* @param {boolean} allowTrampoline - TBD.
|
|
710
768
|
* @returns {boolean} TBD.
|
|
711
769
|
*/
|
|
712
|
-
startFullScreen(antialias, allowTrampoline) {
|
|
770
|
+
startFullScreen(antialias: boolean, allowTrampoline: boolean) {
|
|
713
771
|
if (this.isFullScreen) {
|
|
714
772
|
return false;
|
|
715
773
|
}
|
|
@@ -717,7 +775,7 @@ export class ScaleManager {
|
|
|
717
775
|
// Error is called in timeout to emulate the real fullscreenerror event better
|
|
718
776
|
const scope = this;
|
|
719
777
|
setTimeout(() => {
|
|
720
|
-
scope.fullScreenError();
|
|
778
|
+
scope.fullScreenError({} as any);
|
|
721
779
|
}, 10);
|
|
722
780
|
return false;
|
|
723
781
|
}
|
|
@@ -752,7 +810,7 @@ export class ScaleManager {
|
|
|
752
810
|
fsTarget.appendChild(canvas);
|
|
753
811
|
}
|
|
754
812
|
if (this.game.device.fullscreenKeyboard) {
|
|
755
|
-
fsTarget[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
|
|
813
|
+
fsTarget[this.game.device.requestFullscreen]((Element as any).ALLOW_KEYBOARD_INPUT);
|
|
756
814
|
} else {
|
|
757
815
|
fsTarget[this.game.device.requestFullscreen]();
|
|
758
816
|
}
|
|
@@ -791,7 +849,7 @@ export class ScaleManager {
|
|
|
791
849
|
* TBD.
|
|
792
850
|
* @param {boolean} enteringFullscreen - TBD.
|
|
793
851
|
*/
|
|
794
|
-
prepScreenMode(enteringFullscreen) {
|
|
852
|
+
prepScreenMode(enteringFullscreen: boolean) {
|
|
795
853
|
const fsTarget = this._createdFullScreenTarget || this.fullScreenTarget;
|
|
796
854
|
if (!fsTarget) {
|
|
797
855
|
return;
|
|
@@ -825,7 +883,7 @@ export class ScaleManager {
|
|
|
825
883
|
* TBD.
|
|
826
884
|
* @param {Event} event - TBD.
|
|
827
885
|
*/
|
|
828
|
-
fullScreenChange(event) {
|
|
886
|
+
fullScreenChange(event: Event) {
|
|
829
887
|
this.event = event;
|
|
830
888
|
if (this.isFullScreen) {
|
|
831
889
|
this.prepScreenMode(true);
|
|
@@ -844,7 +902,7 @@ export class ScaleManager {
|
|
|
844
902
|
* TBD.
|
|
845
903
|
* @param {Event} [event] - TBD.
|
|
846
904
|
*/
|
|
847
|
-
fullScreenError(event) {
|
|
905
|
+
fullScreenError(event: Event) {
|
|
848
906
|
this.event = event;
|
|
849
907
|
this.cleanupCreatedTarget();
|
|
850
908
|
this.onFullScreenError.dispatch(this);
|
|
@@ -961,9 +1019,9 @@ export class ScaleManager {
|
|
|
961
1019
|
get isFullScreen() {
|
|
962
1020
|
return !!(
|
|
963
1021
|
document.fullscreenElement ||
|
|
964
|
-
document.webkitFullscreenElement ||
|
|
965
|
-
document.mozFullScreenElement ||
|
|
966
|
-
document.msFullscreenElement
|
|
1022
|
+
(document as any).webkitFullscreenElement ||
|
|
1023
|
+
(document as any).mozFullScreenElement ||
|
|
1024
|
+
(document as any).msFullscreenElement
|
|
967
1025
|
);
|
|
968
1026
|
}
|
|
969
1027
|
|
package/src/phaser/core/scene.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
export class Scene {
|
|
2
|
+
game!: any;
|
|
3
|
+
key!: any;
|
|
3
4
|
/**
|
|
4
5
|
* Creates a new Scene instance.
|
|
5
6
|
*/
|
|
@@ -45,7 +46,7 @@ export class Scene {
|
|
|
45
46
|
* @param {number} width - The new width of the scene.
|
|
46
47
|
* @param {number} height - The new height of the scene.
|
|
47
48
|
*/
|
|
48
|
-
resize(width, height) {
|
|
49
|
+
resize(width: number, height: number) {
|
|
49
50
|
// inherit
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Scene } from './scene.js';
|
|
3
2
|
|
|
4
3
|
export class SceneManager {
|
|
4
|
+
game!: any;
|
|
5
|
+
states!: any;
|
|
6
|
+
_pendingState!: any;
|
|
7
|
+
_clearWorld!: any;
|
|
8
|
+
_clearCache!: any;
|
|
9
|
+
_created!: any;
|
|
10
|
+
_args!: any;
|
|
11
|
+
current!: any;
|
|
12
|
+
onInitCallback!: any;
|
|
13
|
+
onPreloadCallback!: any;
|
|
14
|
+
onCreateCallback!: any;
|
|
15
|
+
onUpdateCallback!: any;
|
|
16
|
+
onResizeCallback!: any;
|
|
17
|
+
onPauseUpdateCallback!: any;
|
|
18
|
+
onShutDownCallback!: any;
|
|
19
|
+
callbackContext!: any;
|
|
5
20
|
/**
|
|
6
21
|
* Creates a new SceneManager instance.
|
|
7
22
|
* @param {import('./game.js').Game} game - The game instance this manager belongs to.
|
|
8
23
|
* @param {string} pendingState - The state to load when the game boots.
|
|
9
24
|
*/
|
|
10
|
-
constructor(game, pendingState) {
|
|
25
|
+
constructor(game: import('./game.js').Game, pendingState: string) {
|
|
11
26
|
this.game = game;
|
|
12
27
|
this.states = {};
|
|
13
28
|
this._pendingState = null;
|
|
@@ -45,7 +60,7 @@ export class SceneManager {
|
|
|
45
60
|
* @param {boolean} autoStart - Whether to start this state immediately.
|
|
46
61
|
* @returns {Scene|object} The created scene or state object.
|
|
47
62
|
*/
|
|
48
|
-
add(key, state, autoStart = false) {
|
|
63
|
+
add(key: string, state: any, autoStart: boolean = false) {
|
|
49
64
|
let newState = null;
|
|
50
65
|
if (state instanceof Scene) {
|
|
51
66
|
newState = state;
|
|
@@ -70,7 +85,7 @@ export class SceneManager {
|
|
|
70
85
|
* Remove a scene state from the manager.
|
|
71
86
|
* @param {string} key - The unique key for the state to remove.
|
|
72
87
|
*/
|
|
73
|
-
remove(key) {
|
|
88
|
+
remove(key: string) {
|
|
74
89
|
if (this.current === key) {
|
|
75
90
|
this.callbackContext = null;
|
|
76
91
|
this.onInitCallback = null;
|
|
@@ -91,7 +106,7 @@ export class SceneManager {
|
|
|
91
106
|
* @param {boolean} clearCache - Whether to clear the cache before starting.
|
|
92
107
|
* @param {...any} args - Additional arguments to pass to the state.
|
|
93
108
|
*/
|
|
94
|
-
start(key, clearWorld = true, clearCache = false, ...args) {
|
|
109
|
+
start(key: string, clearWorld: boolean = true, clearCache: boolean = false, ...args: any[]) {
|
|
95
110
|
if (this.checkState(key)) {
|
|
96
111
|
// Place the state in the queue. It will be started the next time the game loop begins.
|
|
97
112
|
this._pendingState = key;
|
|
@@ -109,7 +124,7 @@ export class SceneManager {
|
|
|
109
124
|
* @param {boolean} clearCache - Whether to clear the cache before restarting.
|
|
110
125
|
* @param {...any} args - Additional arguments to pass to the state.
|
|
111
126
|
*/
|
|
112
|
-
restart(clearWorld = true, clearCache = false, ...args) {
|
|
127
|
+
restart(clearWorld: boolean = true, clearCache: boolean = false, ...args: any[]) {
|
|
113
128
|
this._pendingState = this.current;
|
|
114
129
|
this._clearWorld = clearWorld;
|
|
115
130
|
this._clearCache = clearCache;
|
|
@@ -180,7 +195,7 @@ export class SceneManager {
|
|
|
180
195
|
* @param {string} key - The unique key for the state to check.
|
|
181
196
|
* @returns {boolean} True if the scene exists, false otherwise.
|
|
182
197
|
*/
|
|
183
|
-
checkState(key) {
|
|
198
|
+
checkState(key: string) {
|
|
184
199
|
if (this.states[key]) {
|
|
185
200
|
if (this.states[key].preload || this.states[key].create || this.states[key].update || this.states[key].render) {
|
|
186
201
|
return true;
|
|
@@ -194,7 +209,7 @@ export class SceneManager {
|
|
|
194
209
|
* Link a scene state to the manager.
|
|
195
210
|
* @param {string} key - The unique key for the state to link.
|
|
196
211
|
*/
|
|
197
|
-
link(key) {
|
|
212
|
+
link(key: string) {
|
|
198
213
|
this.states[key].game = this.game;
|
|
199
214
|
this.states[key].key = key;
|
|
200
215
|
}
|
|
@@ -203,7 +218,7 @@ export class SceneManager {
|
|
|
203
218
|
* Unlink a scene state from the manager.
|
|
204
219
|
* @param {string} key - The unique key for the state to unlink.
|
|
205
220
|
*/
|
|
206
|
-
unlink(key) {
|
|
221
|
+
unlink(key: string) {
|
|
207
222
|
if (this.states[key]) {
|
|
208
223
|
this.states[key].game = null;
|
|
209
224
|
}
|
|
@@ -213,7 +228,7 @@ export class SceneManager {
|
|
|
213
228
|
* Set the current scene state.
|
|
214
229
|
* @param {string} key - The unique key for the state to set as current.
|
|
215
230
|
*/
|
|
216
|
-
setCurrentState(key) {
|
|
231
|
+
setCurrentState(key: string) {
|
|
217
232
|
this.callbackContext = this.states[key];
|
|
218
233
|
this.link(key);
|
|
219
234
|
// Used when the state is set as being the current active state
|
|
@@ -279,7 +294,7 @@ export class SceneManager {
|
|
|
279
294
|
* @param {number} width - The new width of the scene.
|
|
280
295
|
* @param {number} height - The new height of the scene.
|
|
281
296
|
*/
|
|
282
|
-
resize(width, height) {
|
|
297
|
+
resize(width: number, height: number) {
|
|
283
298
|
if (this.onResizeCallback) {
|
|
284
299
|
this.onResizeCallback.call(this.callbackContext, width, height);
|
|
285
300
|
}
|
|
@@ -27,7 +27,7 @@ export class Signal {
|
|
|
27
27
|
* @param {string} fnName - The name of the function this validation is for.
|
|
28
28
|
* @throws {Error} If the listener is not a function.
|
|
29
29
|
*/
|
|
30
|
-
validateListener(listener, fnName) {
|
|
30
|
+
validateListener(listener: Function, fnName: string) {
|
|
31
31
|
if (typeof listener !== 'function') {
|
|
32
32
|
throw new TypeError(
|
|
33
33
|
'Signal: listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName)
|
|
@@ -45,7 +45,7 @@ export class Signal {
|
|
|
45
45
|
* @returns {SignalBinding} The binding for this listener.
|
|
46
46
|
* @throws {Error} If the listener is already registered with a different once setting.
|
|
47
47
|
*/
|
|
48
|
-
_registerListener(listener, isOnce = false, listenerContext = null, priority = 0, args = null) {
|
|
48
|
+
_registerListener(listener: Function, isOnce: boolean = false, listenerContext: any = null, priority: number = 0, args: any = null) {
|
|
49
49
|
const prevIndex = this._indexOfListener(listener, listenerContext);
|
|
50
50
|
let binding;
|
|
51
51
|
if (prevIndex !== -1) {
|
|
@@ -71,7 +71,7 @@ export class Signal {
|
|
|
71
71
|
* Add a binding to the list of listeners.
|
|
72
72
|
* @param {SignalBinding} binding - The binding to add.
|
|
73
73
|
*/
|
|
74
|
-
_addBinding(binding) {
|
|
74
|
+
_addBinding(binding: SignalBinding) {
|
|
75
75
|
if (!this._bindings) {
|
|
76
76
|
this._bindings = [];
|
|
77
77
|
}
|
|
@@ -89,7 +89,7 @@ export class Signal {
|
|
|
89
89
|
* @param {object} context - The context of the listener.
|
|
90
90
|
* @returns {number} The index of the listener in the bindings array, or -1 if not found.
|
|
91
91
|
*/
|
|
92
|
-
_indexOfListener(listener, context = null) {
|
|
92
|
+
_indexOfListener(listener: Function, context: any = null) {
|
|
93
93
|
if (!this._bindings) {
|
|
94
94
|
return -1;
|
|
95
95
|
}
|
|
@@ -111,7 +111,7 @@ export class Signal {
|
|
|
111
111
|
* @param {object} context - The context of the listener.
|
|
112
112
|
* @returns {boolean} True if the listener is registered, false otherwise.
|
|
113
113
|
*/
|
|
114
|
-
has(listener, context = null) {
|
|
114
|
+
has(listener: Function, context: any = null) {
|
|
115
115
|
return this._indexOfListener(listener, context) !== -1;
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -123,7 +123,7 @@ export class Signal {
|
|
|
123
123
|
* @param {...any} args - Additional arguments to pass to the listener.
|
|
124
124
|
* @returns {SignalBinding} The binding for this listener.
|
|
125
125
|
*/
|
|
126
|
-
add(listener, listenerContext = null, priority = 0, ...args) {
|
|
126
|
+
add(listener: Function, listenerContext: any = null, priority: number = 0, ...args: any[]) {
|
|
127
127
|
this.validateListener(listener, 'add');
|
|
128
128
|
return this._registerListener(listener, false, listenerContext, priority, args);
|
|
129
129
|
}
|
|
@@ -136,7 +136,7 @@ export class Signal {
|
|
|
136
136
|
* @param {...any} args - Additional arguments to pass to the listener.
|
|
137
137
|
* @returns {SignalBinding} The binding for this listener.
|
|
138
138
|
*/
|
|
139
|
-
addOnce(listener, listenerContext = null, priority = 0, ...args) {
|
|
139
|
+
addOnce(listener: Function, listenerContext: any = null, priority: number = 0, ...args: any[]) {
|
|
140
140
|
this.validateListener(listener, 'addOnce');
|
|
141
141
|
return this._registerListener(listener, true, listenerContext, priority, args);
|
|
142
142
|
}
|
|
@@ -147,7 +147,7 @@ export class Signal {
|
|
|
147
147
|
* @param {object} context - The context of the listener.
|
|
148
148
|
* @returns {Function} The removed listener function.
|
|
149
149
|
*/
|
|
150
|
-
remove(listener, context = null) {
|
|
150
|
+
remove(listener: Function, context: any = null) {
|
|
151
151
|
this.validateListener(listener, 'remove');
|
|
152
152
|
const i = this._indexOfListener(listener, context);
|
|
153
153
|
if (i !== -1) {
|
|
@@ -162,7 +162,7 @@ export class Signal {
|
|
|
162
162
|
* Remove all listeners from the signal, or only those in a specific context.
|
|
163
163
|
* @param {object} context - The context to filter listeners by, or null to remove all.
|
|
164
164
|
*/
|
|
165
|
-
removeAll(context = null) {
|
|
165
|
+
removeAll(context: any = null) {
|
|
166
166
|
if (!this._bindings) {
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
@@ -203,7 +203,7 @@ export class Signal {
|
|
|
203
203
|
* Dispatch the signal to all registered listeners.
|
|
204
204
|
* @param {...any} args - Arguments to pass to the listeners.
|
|
205
205
|
*/
|
|
206
|
-
dispatch(...args) {
|
|
206
|
+
dispatch(...args: any[]) {
|
|
207
207
|
if (!this.active || !this._bindings) {
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
@@ -18,7 +18,7 @@ export class SignalBinding {
|
|
|
18
18
|
* @param {number} priority - TBD.
|
|
19
19
|
* @param {...any} args - TBD.
|
|
20
20
|
*/
|
|
21
|
-
constructor(signal, listener, isOnce = false, listenerContext = null, priority = 0, args = null) {
|
|
21
|
+
constructor(signal: import('./signal.js').Signal, listener: Function, isOnce: boolean = false, listenerContext: any = null, priority: number = 0, args: any = null) {
|
|
22
22
|
this._signal = signal;
|
|
23
23
|
this._listener = listener;
|
|
24
24
|
this._args = args;
|
|
@@ -35,7 +35,7 @@ export class SignalBinding {
|
|
|
35
35
|
* @param {any[]} paramsArr - TBD.
|
|
36
36
|
* @returns {Function} TBD.
|
|
37
37
|
*/
|
|
38
|
-
execute(paramsArr) {
|
|
38
|
+
execute(paramsArr: any[]) {
|
|
39
39
|
let handlerReturn;
|
|
40
40
|
let params;
|
|
41
41
|
if (this.active && !!this._listener) {
|