@vpmedia/phaser 1.11.0 → 1.13.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/README.md +1 -1
- package/package.json +8 -5
- package/src/index.js +19 -19
- package/src/phaser/core/animation.js +12 -9
- package/src/phaser/core/animation_manager.js +16 -6
- package/src/phaser/core/animation_parser.js +40 -17
- package/src/phaser/core/array_set.js +3 -5
- package/src/phaser/core/cache.js +12 -12
- package/src/phaser/core/const.js +1 -1
- package/src/phaser/core/device.js +2 -4
- package/src/phaser/core/device_util.js +50 -17
- package/src/phaser/core/dom.js +36 -27
- package/src/phaser/core/event_manager.js +47 -19
- package/src/phaser/core/factory.js +34 -12
- package/src/phaser/core/frame.js +3 -5
- package/src/phaser/core/frame_data.js +2 -4
- package/src/phaser/core/frame_util.js +11 -9
- package/src/phaser/core/game.js +22 -19
- package/src/phaser/core/input.js +24 -16
- package/src/phaser/core/input_handler.js +102 -28
- package/src/phaser/core/input_mouse.js +12 -16
- package/src/phaser/core/input_mspointer.js +11 -10
- package/src/phaser/core/input_pointer.js +61 -20
- package/src/phaser/core/input_touch.js +7 -9
- package/src/phaser/core/loader.js +171 -54
- package/src/phaser/core/loader_parser.js +29 -22
- package/src/phaser/core/raf.js +2 -4
- package/src/phaser/core/scale_manager.js +75 -31
- package/src/phaser/core/scene.js +2 -4
- package/src/phaser/core/scene_manager.js +9 -6
- package/src/phaser/core/signal.js +19 -11
- package/src/phaser/core/signal_binding.js +12 -7
- package/src/phaser/core/sound.js +23 -14
- package/src/phaser/core/sound_manager.js +62 -26
- package/src/phaser/core/sound_sprite.js +34 -34
- package/src/phaser/core/stage.js +4 -7
- package/src/phaser/core/time.js +3 -5
- package/src/phaser/core/timer.js +27 -10
- package/src/phaser/core/timer_event.js +1 -3
- package/src/phaser/core/tween.js +36 -12
- package/src/phaser/core/tween_data.js +17 -9
- package/src/phaser/core/tween_easing.js +87 -83
- package/src/phaser/core/tween_manager.js +34 -16
- package/src/phaser/core/world.js +3 -5
- package/src/phaser/display/bitmap_text.js +25 -14
- package/src/phaser/display/button.js +35 -8
- package/src/phaser/display/canvas/buffer.js +1 -3
- package/src/phaser/display/canvas/graphics.js +30 -15
- package/src/phaser/display/canvas/masker.js +7 -5
- package/src/phaser/display/canvas/pool.js +18 -11
- package/src/phaser/display/canvas/renderer.js +40 -20
- package/src/phaser/display/canvas/tinter.js +61 -19
- package/src/phaser/display/canvas/util.js +44 -35
- package/src/phaser/display/display_object.js +42 -24
- package/src/phaser/display/graphics.js +72 -39
- package/src/phaser/display/graphics_data.js +3 -4
- package/src/phaser/display/graphics_data_util.js +15 -5
- package/src/phaser/display/group.js +15 -9
- package/src/phaser/display/image.js +17 -9
- package/src/phaser/display/sprite_batch.js +8 -4
- package/src/phaser/display/sprite_util.js +67 -26
- package/src/phaser/display/text.js +92 -31
- package/src/phaser/display/webgl/abstract_filter.js +1 -3
- package/src/phaser/display/webgl/base_texture.js +8 -5
- package/src/phaser/display/webgl/blend_manager.js +1 -3
- package/src/phaser/display/webgl/earcut.js +170 -129
- package/src/phaser/display/webgl/earcut_node.js +1 -3
- package/src/phaser/display/webgl/fast_sprite_batch.js +48 -47
- package/src/phaser/display/webgl/filter_manager.js +1 -3
- package/src/phaser/display/webgl/filter_texture.js +17 -6
- package/src/phaser/display/webgl/graphics.js +72 -50
- package/src/phaser/display/webgl/graphics_data.js +2 -4
- package/src/phaser/display/webgl/mask_manager.js +17 -7
- package/src/phaser/display/webgl/render_texture.js +19 -10
- package/src/phaser/display/webgl/renderer.js +41 -9
- package/src/phaser/display/webgl/shader/complex.js +1 -3
- package/src/phaser/display/webgl/shader/fast.js +9 -4
- package/src/phaser/display/webgl/shader/normal.js +43 -15
- package/src/phaser/display/webgl/shader/primitive.js +1 -3
- package/src/phaser/display/webgl/shader/strip.js +1 -3
- package/src/phaser/display/webgl/shader_manager.js +1 -3
- package/src/phaser/display/webgl/sprite_batch.js +14 -15
- package/src/phaser/display/webgl/stencil_manager.js +19 -21
- package/src/phaser/display/webgl/texture.js +14 -10
- package/src/phaser/display/webgl/texture_util.js +11 -9
- package/src/phaser/display/webgl/util.js +21 -18
- package/src/phaser/geom/circle.js +27 -11
- package/src/phaser/geom/ellipse.js +26 -10
- package/src/phaser/geom/line.js +31 -13
- package/src/phaser/geom/matrix.js +14 -5
- package/src/phaser/geom/point.js +18 -13
- package/src/phaser/geom/polygon.js +13 -8
- package/src/phaser/geom/rectangle.js +57 -14
- package/src/phaser/geom/rounded_rectangle.js +12 -4
- package/src/phaser/geom/util/circle.js +40 -32
- package/src/phaser/geom/util/ellipse.js +10 -18
- package/src/phaser/geom/util/line.js +46 -37
- package/src/phaser/geom/util/matrix.js +11 -9
- package/src/phaser/geom/util/point.js +101 -79
- package/src/phaser/geom/util/polygon.js +7 -15
- package/src/phaser/geom/util/rectangle.js +95 -69
- package/src/phaser/geom/util/rounded_rectangle.js +7 -15
- package/src/phaser/util/math.js +123 -89
- package/types/global.d.ts +7 -0
- package/types/index.d.ts +22 -0
- package/types/index.d.ts.map +1 -0
- package/types/phaser/core/animation.d.ts +55 -0
- package/types/phaser/core/animation.d.ts.map +1 -0
- package/types/phaser/core/animation_manager.d.ts +35 -0
- package/types/phaser/core/animation_manager.d.ts.map +1 -0
- package/types/phaser/core/animation_parser.d.ts +22 -0
- package/types/phaser/core/animation_parser.d.ts.map +1 -0
- package/types/phaser/core/array_set.d.ts +23 -0
- package/types/phaser/core/array_set.d.ts.map +1 -0
- package/types/phaser/core/cache.d.ts +106 -0
- package/types/phaser/core/cache.d.ts.map +1 -0
- package/types/phaser/core/const.d.ts +81 -0
- package/types/phaser/core/const.d.ts.map +1 -0
- package/types/phaser/core/device.d.ts +36 -0
- package/types/phaser/core/device.d.ts.map +1 -0
- package/types/phaser/core/device_util.d.ts +58 -0
- package/types/phaser/core/device_util.d.ts.map +1 -0
- package/types/phaser/core/dom.d.ts +63 -0
- package/types/phaser/core/dom.d.ts.map +1 -0
- package/types/phaser/core/event_manager.d.ts +53 -0
- package/types/phaser/core/event_manager.d.ts.map +1 -0
- package/types/phaser/core/factory.d.ts +12 -0
- package/types/phaser/core/factory.d.ts.map +1 -0
- package/types/phaser/core/frame.d.ts +30 -0
- package/types/phaser/core/frame.d.ts.map +1 -0
- package/types/phaser/core/frame_data.d.ts +14 -0
- package/types/phaser/core/frame_data.d.ts.map +1 -0
- package/types/phaser/core/frame_util.d.ts +17 -0
- package/types/phaser/core/frame_util.d.ts.map +1 -0
- package/types/phaser/core/game.d.ts +57 -0
- package/types/phaser/core/game.d.ts.map +1 -0
- package/types/phaser/core/input.d.ts +92 -0
- package/types/phaser/core/input.d.ts.map +1 -0
- package/types/phaser/core/input_handler.d.ts +111 -0
- package/types/phaser/core/input_handler.d.ts.map +1 -0
- package/types/phaser/core/input_mouse.d.ts +39 -0
- package/types/phaser/core/input_mouse.d.ts.map +1 -0
- package/types/phaser/core/input_mspointer.d.ts +34 -0
- package/types/phaser/core/input_mspointer.d.ts.map +1 -0
- package/types/phaser/core/input_pointer.d.ts +68 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -0
- package/types/phaser/core/input_touch.d.ts +37 -0
- package/types/phaser/core/input_touch.d.ts.map +1 -0
- package/types/phaser/core/loader.d.ts +94 -0
- package/types/phaser/core/loader.d.ts.map +1 -0
- package/types/phaser/core/loader_parser.d.ts +39 -0
- package/types/phaser/core/loader_parser.d.ts.map +1 -0
- package/types/phaser/core/raf.d.ts +15 -0
- package/types/phaser/core/raf.d.ts.map +1 -0
- package/types/phaser/core/scale_manager.d.ts +137 -0
- package/types/phaser/core/scale_manager.d.ts.map +1 -0
- package/types/phaser/core/scene.d.ts +17 -0
- package/types/phaser/core/scene.d.ts.map +1 -0
- package/types/phaser/core/scene_manager.d.ts +39 -0
- package/types/phaser/core/scene_manager.d.ts.map +1 -0
- package/types/phaser/core/signal.d.ts +25 -0
- package/types/phaser/core/signal.d.ts.map +1 -0
- package/types/phaser/core/signal_binding.d.ts +26 -0
- package/types/phaser/core/signal_binding.d.ts.map +1 -0
- package/types/phaser/core/sound.d.ts +72 -0
- package/types/phaser/core/sound.d.ts.map +1 -0
- package/types/phaser/core/sound_manager.d.ts +50 -0
- package/types/phaser/core/sound_manager.d.ts.map +1 -0
- package/types/phaser/core/sound_sprite.d.ts +18 -0
- package/types/phaser/core/sound_sprite.d.ts.map +1 -0
- package/types/phaser/core/stage.d.ts +23 -0
- package/types/phaser/core/stage.d.ts.map +1 -0
- package/types/phaser/core/time.d.ts +49 -0
- package/types/phaser/core/time.d.ts.map +1 -0
- package/types/phaser/core/timer.d.ts +49 -0
- package/types/phaser/core/timer.d.ts.map +1 -0
- package/types/phaser/core/timer_event.d.ts +18 -0
- package/types/phaser/core/timer_event.d.ts.map +1 -0
- package/types/phaser/core/tween.d.ts +52 -0
- package/types/phaser/core/tween.d.ts.map +1 -0
- package/types/phaser/core/tween_data.d.ts +37 -0
- package/types/phaser/core/tween_data.d.ts.map +1 -0
- package/types/phaser/core/tween_easing.d.ts +192 -0
- package/types/phaser/core/tween_easing.d.ts.map +1 -0
- package/types/phaser/core/tween_manager.d.ts +94 -0
- package/types/phaser/core/tween_manager.d.ts.map +1 -0
- package/types/phaser/core/world.d.ts +6 -0
- package/types/phaser/core/world.d.ts.map +1 -0
- package/types/phaser/display/bitmap_text.d.ts +59 -0
- package/types/phaser/display/bitmap_text.d.ts.map +1 -0
- package/types/phaser/display/button.d.ts +47 -0
- package/types/phaser/display/button.d.ts.map +1 -0
- package/types/phaser/display/canvas/buffer.d.ts +11 -0
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -0
- package/types/phaser/display/canvas/graphics.d.ts +21 -0
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -0
- package/types/phaser/display/canvas/masker.d.ts +14 -0
- package/types/phaser/display/canvas/masker.d.ts.map +1 -0
- package/types/phaser/display/canvas/pool.d.ts +52 -0
- package/types/phaser/display/canvas/pool.d.ts.map +1 -0
- package/types/phaser/display/canvas/renderer.d.ts +28 -0
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -0
- package/types/phaser/display/canvas/tinter.d.ts +41 -0
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -0
- package/types/phaser/display/canvas/util.d.ts +79 -0
- package/types/phaser/display/canvas/util.d.ts.map +1 -0
- package/types/phaser/display/display_object.d.ts +83 -0
- package/types/phaser/display/display_object.d.ts.map +1 -0
- package/types/phaser/display/graphics.d.ts +60 -0
- package/types/phaser/display/graphics.d.ts.map +1 -0
- package/types/phaser/display/graphics_data.d.ts +15 -0
- package/types/phaser/display/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/graphics_data_util.d.ts +8 -0
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -0
- package/types/phaser/display/group.d.ts +49 -0
- package/types/phaser/display/group.d.ts.map +1 -0
- package/types/phaser/display/image.d.ts +52 -0
- package/types/phaser/display/image.d.ts.map +1 -0
- package/types/phaser/display/sprite_batch.d.ts +11 -0
- package/types/phaser/display/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/sprite_util.d.ts +40 -0
- package/types/phaser/display/sprite_util.d.ts.map +1 -0
- package/types/phaser/display/text.d.ts +125 -0
- package/types/phaser/display/text.d.ts.map +1 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts +17 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -0
- package/types/phaser/display/webgl/base_texture.d.ts +20 -0
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/blend_manager.d.ts +14 -0
- package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut.d.ts +215 -0
- package/types/phaser/display/webgl/earcut.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut_node.d.ts +19 -0
- package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +34 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_manager.d.ts +21 -0
- package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_texture.d.ts +13 -0
- package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics.d.ts +80 -0
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics_data.d.ts +23 -0
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/webgl/mask_manager.d.ts +15 -0
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/render_texture.d.ts +25 -0
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/renderer.d.ts +44 -0
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/complex.d.ts +22 -0
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/fast.d.ts +25 -0
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/normal.d.ts +25 -0
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts +21 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/strip.d.ts +22 -0
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader_manager.d.ts +24 -0
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts +36 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts +12 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture.d.ts +30 -0
- package/types/phaser/display/webgl/texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture_util.d.ts +17 -0
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -0
- package/types/phaser/display/webgl/util.d.ts +45 -0
- package/types/phaser/display/webgl/util.d.ts.map +1 -0
- package/types/phaser/geom/circle.d.ts +46 -0
- package/types/phaser/geom/circle.d.ts.map +1 -0
- package/types/phaser/geom/ellipse.d.ts +26 -0
- package/types/phaser/geom/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/line.d.ts +45 -0
- package/types/phaser/geom/line.d.ts.map +1 -0
- package/types/phaser/geom/matrix.d.ts +35 -0
- package/types/phaser/geom/matrix.d.ts.map +1 -0
- package/types/phaser/geom/point.d.ts +43 -0
- package/types/phaser/geom/point.d.ts.map +1 -0
- package/types/phaser/geom/polygon.d.ts +17 -0
- package/types/phaser/geom/polygon.d.ts.map +1 -0
- package/types/phaser/geom/rectangle.d.ts +71 -0
- package/types/phaser/geom/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/rounded_rectangle.d.ts +21 -0
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/circle.d.ts +64 -0
- package/types/phaser/geom/util/circle.d.ts.map +1 -0
- package/types/phaser/geom/util/ellipse.d.ts +16 -0
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/util/line.d.ts +49 -0
- package/types/phaser/geom/util/line.d.ts.map +1 -0
- package/types/phaser/geom/util/matrix.d.ts +22 -0
- package/types/phaser/geom/util/matrix.d.ts.map +1 -0
- package/types/phaser/geom/util/point.d.ts +179 -0
- package/types/phaser/geom/util/point.d.ts.map +1 -0
- package/types/phaser/geom/util/polygon.d.ts +10 -0
- package/types/phaser/geom/util/polygon.d.ts.map +1 -0
- package/types/phaser/geom/util/rectangle.d.ts +141 -0
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts +10 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/util/math.d.ts +182 -0
- package/types/phaser/util/math.d.ts.map +1 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@vpmedia/phaser
|
|
2
2
|
===============
|
|
3
3
|
|
|
4
|
-
[](https://badge.fury.io/js/@vpmedia%2Fphaser)
|
|
5
5
|
[](https://github.com/vpmedia/phaser/actions/workflows/node.js.yml)
|
|
6
6
|
|
|
7
7
|
@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2",
|
|
5
5
|
"author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,22 +20,25 @@
|
|
|
20
20
|
"canvas"
|
|
21
21
|
],
|
|
22
22
|
"main": "./src/index.js",
|
|
23
|
+
"types": "./types/index.d.ts",
|
|
23
24
|
"devDependencies": {
|
|
24
|
-
"eslint": "^8.
|
|
25
|
+
"eslint": "^8.38.0",
|
|
25
26
|
"eslint-config-prettier": "^8.8.0",
|
|
26
27
|
"eslint-plugin-import": "^2.27.5",
|
|
27
28
|
"eslint-plugin-jest": "^27.2.1",
|
|
28
|
-
"eslint-plugin-jsdoc": "^
|
|
29
|
+
"eslint-plugin-jsdoc": "^41.1.2",
|
|
29
30
|
"eslint-plugin-prettier": "^4.2.1",
|
|
30
31
|
"husky": "^8.0.3",
|
|
31
32
|
"jest": "^29.5.0",
|
|
32
|
-
"lint-staged": "^13.2.
|
|
33
|
-
"prettier": "^2.8.7"
|
|
33
|
+
"lint-staged": "^13.2.1",
|
|
34
|
+
"prettier": "^2.8.7",
|
|
35
|
+
"typescript": "^5.0.4"
|
|
34
36
|
},
|
|
35
37
|
"scripts": {
|
|
36
38
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
|
|
37
39
|
"lint": "eslint \"**/*.js\"",
|
|
38
40
|
"lint-fix": "eslint \"**/*.js\" --fix",
|
|
41
|
+
"typecheck": "tsc",
|
|
39
42
|
"format": "prettier --write \"**/*.{js,json}\"",
|
|
40
43
|
"lint-staged": "lint-staged"
|
|
41
44
|
},
|
package/src/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
6
|
// core
|
|
7
7
|
import * as Const from './phaser/core/const';
|
|
8
|
-
import Game from './phaser/core/game';
|
|
9
|
-
import Signal from
|
|
8
|
+
import { Game } from './phaser/core/game';
|
|
9
|
+
import { Signal } from './phaser/core/signal';
|
|
10
10
|
import * as MathUtils from './phaser/util/math';
|
|
11
11
|
// texture
|
|
12
|
-
import BaseTexture from './phaser/display/webgl/base_texture';
|
|
13
|
-
import Texture from './phaser/display/webgl/texture';
|
|
12
|
+
import { BaseTexture } from './phaser/display/webgl/base_texture';
|
|
13
|
+
import { Texture } from './phaser/display/webgl/texture';
|
|
14
14
|
// geom
|
|
15
|
-
import Circle from
|
|
16
|
-
import Ellipse from
|
|
17
|
-
import Line from
|
|
18
|
-
import Matrix from
|
|
19
|
-
import Point from './phaser/geom/point';
|
|
20
|
-
import Polygon from
|
|
21
|
-
import Rectangle from
|
|
22
|
-
import RoundedRectangle from
|
|
15
|
+
import { Circle } from './phaser/geom/circle';
|
|
16
|
+
import { Ellipse } from './phaser/geom/ellipse';
|
|
17
|
+
import { Line } from './phaser/geom/line';
|
|
18
|
+
import { Matrix } from './phaser/geom/matrix';
|
|
19
|
+
import { Point } from './phaser/geom/point';
|
|
20
|
+
import { Polygon } from './phaser/geom/polygon';
|
|
21
|
+
import { Rectangle } from './phaser/geom/rectangle';
|
|
22
|
+
import { RoundedRectangle } from './phaser/geom/rounded_rectangle';
|
|
23
23
|
// display
|
|
24
|
-
import BitmapText from
|
|
25
|
-
import DisplayObject from
|
|
26
|
-
import Button from
|
|
27
|
-
import Image from './phaser/display/image';
|
|
28
|
-
import Group from
|
|
29
|
-
import Text from
|
|
24
|
+
import { BitmapText } from './phaser/display/bitmap_text';
|
|
25
|
+
import { DisplayObject } from './phaser/display/display_object';
|
|
26
|
+
import { Button } from './phaser/display/button';
|
|
27
|
+
import { Image } from './phaser/display/image';
|
|
28
|
+
import { Group } from './phaser/display/group';
|
|
29
|
+
import { Text } from './phaser/display/text';
|
|
30
30
|
// exports
|
|
31
31
|
export {
|
|
32
32
|
Const,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
|
-
import Signal from
|
|
7
|
-
|
|
8
|
-
export default class {
|
|
6
|
+
import { Signal } from './signal';
|
|
9
7
|
|
|
8
|
+
export class Animation {
|
|
10
9
|
constructor(game, parent, name, frameData, frames, frameRate, loop = false) {
|
|
11
10
|
this.game = game;
|
|
12
11
|
this._parent = parent;
|
|
@@ -158,7 +157,7 @@ export default class {
|
|
|
158
157
|
if (this._frameDiff > this.delay) {
|
|
159
158
|
// We need to skip a frame, work out how many
|
|
160
159
|
this._frameSkip = Math.floor(this._frameDiff / this.delay);
|
|
161
|
-
this._frameDiff -=
|
|
160
|
+
this._frameDiff -= this._frameSkip * this.delay;
|
|
162
161
|
}
|
|
163
162
|
// And what's left now?
|
|
164
163
|
this._timeNextFrame = this.game.time.time + (this.delay - this._frameDiff);
|
|
@@ -167,7 +166,10 @@ export default class {
|
|
|
167
166
|
} else {
|
|
168
167
|
this._frameIndex += this._frameSkip;
|
|
169
168
|
}
|
|
170
|
-
if (
|
|
169
|
+
if (
|
|
170
|
+
(!this.isReversed && this._frameIndex >= this._frames.length) ||
|
|
171
|
+
(this.isReversed && this._frameIndex <= -1)
|
|
172
|
+
) {
|
|
171
173
|
if (this.loop) {
|
|
172
174
|
// Update current state before event callback
|
|
173
175
|
this._frameIndex = Math.abs(this._frameIndex) % this._frames.length;
|
|
@@ -249,7 +251,9 @@ export default class {
|
|
|
249
251
|
|
|
250
252
|
updateFrameData(frameData) {
|
|
251
253
|
this._frameData = frameData;
|
|
252
|
-
this.currentFrame = this._frameData
|
|
254
|
+
this.currentFrame = this._frameData
|
|
255
|
+
? this._frameData.getFrame(this._frames[this._frameIndex % this._frames.length])
|
|
256
|
+
: null;
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
destroy() {
|
|
@@ -340,7 +344,7 @@ export default class {
|
|
|
340
344
|
}
|
|
341
345
|
|
|
342
346
|
get enableUpdate() {
|
|
343
|
-
return
|
|
347
|
+
return this.onUpdate !== null;
|
|
344
348
|
}
|
|
345
349
|
|
|
346
350
|
set enableUpdate(value) {
|
|
@@ -351,5 +355,4 @@ export default class {
|
|
|
351
355
|
this.onUpdate = null;
|
|
352
356
|
}
|
|
353
357
|
}
|
|
354
|
-
|
|
355
358
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
|
-
import Animation from './animation';
|
|
6
|
+
import { Animation } from './animation';
|
|
7
7
|
|
|
8
8
|
export default class {
|
|
9
|
-
|
|
10
9
|
constructor(sprite) {
|
|
11
10
|
this.sprite = sprite;
|
|
12
11
|
this.game = sprite.game;
|
|
@@ -90,7 +89,15 @@ export default class {
|
|
|
90
89
|
}
|
|
91
90
|
this._outputFrames = [];
|
|
92
91
|
this._frameData.getFrameIndexes(frames, useNumericIndex, this._outputFrames);
|
|
93
|
-
this._anims[name] = new Animation(
|
|
92
|
+
this._anims[name] = new Animation(
|
|
93
|
+
this.game,
|
|
94
|
+
this.sprite,
|
|
95
|
+
name,
|
|
96
|
+
this._frameData,
|
|
97
|
+
this._outputFrames,
|
|
98
|
+
frameRate,
|
|
99
|
+
loop
|
|
100
|
+
);
|
|
94
101
|
this.currentAnim = this._anims[name];
|
|
95
102
|
if (this.sprite.tilingTexture) {
|
|
96
103
|
this.sprite.refreshTexture = true;
|
|
@@ -224,7 +231,11 @@ export default class {
|
|
|
224
231
|
}
|
|
225
232
|
|
|
226
233
|
set frameName(value) {
|
|
227
|
-
if (
|
|
234
|
+
if (
|
|
235
|
+
typeof value === 'string' &&
|
|
236
|
+
this._frameData &&
|
|
237
|
+
this._frameData.getFrameByName(value) !== null
|
|
238
|
+
) {
|
|
228
239
|
this.currentFrame = this._frameData.getFrameByName(value);
|
|
229
240
|
if (this.currentFrame) {
|
|
230
241
|
this._frameIndex = this.currentFrame.index;
|
|
@@ -234,5 +245,4 @@ export default class {
|
|
|
234
245
|
console.warn('Cannot set frameName: ' + value);
|
|
235
246
|
}
|
|
236
247
|
}
|
|
237
|
-
|
|
238
248
|
}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
|
-
import Frame from './frame';
|
|
7
|
-
import FrameData from './frame_data';
|
|
6
|
+
import { Frame } from './frame';
|
|
7
|
+
import { FrameData } from './frame_data';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* TBD.
|
|
10
11
|
*
|
|
11
|
-
* @param {object} game TBD
|
|
12
|
-
* @param {object} key TBD
|
|
13
|
-
* @param {number} frameWidth TBD
|
|
14
|
-
* @param {number} frameHeight TBD
|
|
15
|
-
* @param {number} frameMax TBD
|
|
16
|
-
* @param {number} margin TBD
|
|
17
|
-
* @param {number} spacing TBD
|
|
18
|
-
* @returns {object} TBD
|
|
12
|
+
* @param {object} game - TBD.
|
|
13
|
+
* @param {object} key - TBD.
|
|
14
|
+
* @param {number} frameWidth - TBD.
|
|
15
|
+
* @param {number} frameHeight - TBD.
|
|
16
|
+
* @param {number} frameMax - TBD.
|
|
17
|
+
* @param {number} margin - TBD.
|
|
18
|
+
* @param {number} spacing - TBD.
|
|
19
|
+
* @returns {object} TBD.
|
|
19
20
|
*/
|
|
20
21
|
export function spriteSheet(game, key, frameWidth, frameHeight, frameMax, margin, spacing) {
|
|
21
22
|
let img = key;
|
|
@@ -41,7 +42,11 @@ export function spriteSheet(game, key, frameWidth, frameHeight, frameMax, margin
|
|
|
41
42
|
}
|
|
42
43
|
// Zero or smaller than frame sizes?
|
|
43
44
|
if (width === 0 || height === 0 || width < frameWidth || height < frameHeight || total === 0) {
|
|
44
|
-
console.warn(
|
|
45
|
+
console.warn(
|
|
46
|
+
"AnimationParser.spriteSheet: '" +
|
|
47
|
+
key +
|
|
48
|
+
"'s width/height zero or width/height < given frameWidth/frameHeight"
|
|
49
|
+
);
|
|
45
50
|
return null;
|
|
46
51
|
}
|
|
47
52
|
// Let's create some frames then
|
|
@@ -60,10 +65,11 @@ export function spriteSheet(game, key, frameWidth, frameHeight, frameMax, margin
|
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
/**
|
|
68
|
+
* TBD.
|
|
63
69
|
*
|
|
64
|
-
* @param {object} game TBD
|
|
65
|
-
* @param {object} json TBD
|
|
66
|
-
* @returns {object} TBD
|
|
70
|
+
* @param {object} game - TBD.
|
|
71
|
+
* @param {object} json - TBD.
|
|
72
|
+
* @returns {object} TBD.
|
|
67
73
|
*/
|
|
68
74
|
export function JSONDataHash(game, json) {
|
|
69
75
|
if (!json.frames) {
|
|
@@ -79,9 +85,26 @@ export function JSONDataHash(game, json) {
|
|
|
79
85
|
const keys = Object.keys(frames);
|
|
80
86
|
for (let k = 0; k < keys.length; k += 1) {
|
|
81
87
|
const key = keys[k];
|
|
82
|
-
newFrame = data.addFrame(
|
|
88
|
+
newFrame = data.addFrame(
|
|
89
|
+
new Frame(
|
|
90
|
+
i,
|
|
91
|
+
frames[key].frame.x,
|
|
92
|
+
frames[key].frame.y,
|
|
93
|
+
frames[key].frame.w,
|
|
94
|
+
frames[key].frame.h,
|
|
95
|
+
key
|
|
96
|
+
)
|
|
97
|
+
);
|
|
83
98
|
if (frames[key].trimmed) {
|
|
84
|
-
newFrame.setTrim(
|
|
99
|
+
newFrame.setTrim(
|
|
100
|
+
frames[key].trimmed,
|
|
101
|
+
frames[key].sourceSize.w,
|
|
102
|
+
frames[key].sourceSize.h,
|
|
103
|
+
frames[key].spriteSourceSize.x,
|
|
104
|
+
frames[key].spriteSourceSize.y,
|
|
105
|
+
frames[key].spriteSourceSize.w,
|
|
106
|
+
frames[key].spriteSourceSize.h
|
|
107
|
+
);
|
|
85
108
|
}
|
|
86
109
|
i += 1;
|
|
87
110
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
7
|
-
|
|
6
|
+
export class ArraySet {
|
|
8
7
|
constructor(list = []) {
|
|
9
8
|
this.position = 0;
|
|
10
9
|
this.list = list;
|
|
@@ -33,7 +32,7 @@ export default class {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
exists(item) {
|
|
36
|
-
return
|
|
35
|
+
return this.list.indexOf(item) > -1;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
reset() {
|
|
@@ -103,5 +102,4 @@ export default class {
|
|
|
103
102
|
}
|
|
104
103
|
return null;
|
|
105
104
|
}
|
|
106
|
-
|
|
107
105
|
}
|
package/src/phaser/core/cache.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
|
-
import Texture from '../display/webgl/texture';
|
|
7
|
-
import BaseTexture from '../display/webgl/base_texture';
|
|
8
|
-
import Signal from
|
|
9
|
-
import Frame from './frame';
|
|
10
|
-
import FrameData from './frame_data';
|
|
6
|
+
import { Texture } from '../display/webgl/texture';
|
|
7
|
+
import { BaseTexture } from '../display/webgl/base_texture';
|
|
8
|
+
import { Signal } from './signal';
|
|
9
|
+
import { Frame } from './frame';
|
|
10
|
+
import { FrameData } from './frame_data';
|
|
11
11
|
import { JSONDataHash } from './animation_parser';
|
|
12
12
|
import { jsonBitmapFont, xmlBitmapFont } from './loader_parser';
|
|
13
13
|
|
|
@@ -23,7 +23,6 @@ export const XML = 8;
|
|
|
23
23
|
export const RENDER_TEXTURE = 9;
|
|
24
24
|
|
|
25
25
|
export default class {
|
|
26
|
-
|
|
27
26
|
constructor(game) {
|
|
28
27
|
this.game = game;
|
|
29
28
|
this.autoResolveURL = false;
|
|
@@ -60,7 +59,8 @@ export default class {
|
|
|
60
59
|
|
|
61
60
|
addDefaultImage() {
|
|
62
61
|
const img = new Image();
|
|
63
|
-
img.src =
|
|
62
|
+
img.src =
|
|
63
|
+
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==';
|
|
64
64
|
const obj = this.addImage('__default', null, img);
|
|
65
65
|
obj.base.skipRender = true; // invisible texture
|
|
66
66
|
window.PhaserRegistry.CACHE_DEFAULT_IMAGE = new Texture(obj.base);
|
|
@@ -68,7 +68,8 @@ export default class {
|
|
|
68
68
|
|
|
69
69
|
addMissingImage() {
|
|
70
70
|
const img = new Image();
|
|
71
|
-
img.src =
|
|
71
|
+
img.src =
|
|
72
|
+
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==';
|
|
72
73
|
const obj = this.addImage('__missing', null, img);
|
|
73
74
|
window.PhaserRegistry.CACHE_MISSING_IMAGE = new Texture(obj.base);
|
|
74
75
|
}
|
|
@@ -193,7 +194,7 @@ export default class {
|
|
|
193
194
|
isSoundReady(key) {
|
|
194
195
|
const sound = this.getItem(key, SOUND, 'isSoundDecoded');
|
|
195
196
|
if (sound) {
|
|
196
|
-
return
|
|
197
|
+
return sound.decoded && !this.game.sound.isLocked;
|
|
197
198
|
}
|
|
198
199
|
return false;
|
|
199
200
|
}
|
|
@@ -337,7 +338,7 @@ export default class {
|
|
|
337
338
|
}
|
|
338
339
|
|
|
339
340
|
hasFrameData(key, cache = IMAGE) {
|
|
340
|
-
return
|
|
341
|
+
return this.getItem(key, cache, '', 'frameData') !== null;
|
|
341
342
|
}
|
|
342
343
|
|
|
343
344
|
updateFrameData(key, frameData, cache = IMAGE) {
|
|
@@ -476,5 +477,4 @@ export default class {
|
|
|
476
477
|
this._urlResolver = null;
|
|
477
478
|
this._urlTemp = null;
|
|
478
479
|
}
|
|
479
|
-
|
|
480
480
|
}
|
package/src/phaser/core/const.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
6
|
// rectangle
|
|
7
7
|
export const TOP_LEFT = 0;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export
|
|
8
|
-
|
|
7
|
+
export class Device {
|
|
9
8
|
constructor() {
|
|
10
9
|
this.desktop = false;
|
|
11
10
|
this.iOS = false;
|
|
@@ -36,5 +35,4 @@ export default class {
|
|
|
36
35
|
this.cancelFullscreen = '';
|
|
37
36
|
this.fullscreenKeyboard = false;
|
|
38
37
|
}
|
|
39
|
-
|
|
40
38
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
|
+
import { Device } from "./device";
|
|
6
7
|
|
|
7
8
|
/**
|
|
9
|
+
* TBD.
|
|
8
10
|
*
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {string} type TBD
|
|
11
|
-
* @returns {boolean} TBD
|
|
11
|
+
* @param {Device} device - TBD.
|
|
12
|
+
* @param {string} type - TBD.
|
|
13
|
+
* @returns {boolean} TBD.
|
|
12
14
|
*/
|
|
13
15
|
export function canPlayAudio(device, type) {
|
|
14
16
|
if (type === 'mp3' && device.mp3) {
|
|
@@ -30,8 +32,9 @@ export function canPlayAudio(device, type) {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/**
|
|
35
|
+
* TBD.
|
|
33
36
|
*
|
|
34
|
-
* @param {
|
|
37
|
+
* @param {Device} device - TBD.
|
|
35
38
|
*/
|
|
36
39
|
export function checkOS(device) {
|
|
37
40
|
const ua = navigator.userAgent;
|
|
@@ -62,17 +65,26 @@ export function checkOS(device) {
|
|
|
62
65
|
device.desktop = true;
|
|
63
66
|
}
|
|
64
67
|
// iOS / Windows Phone / Tablet reset
|
|
65
|
-
if (
|
|
68
|
+
if (
|
|
69
|
+
device.android ||
|
|
70
|
+
device.iOS ||
|
|
71
|
+
device.windowsPhone ||
|
|
72
|
+
(/Windows NT/i.test(ua) && /Touch/i.test(ua))
|
|
73
|
+
) {
|
|
66
74
|
device.desktop = false;
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
/**
|
|
79
|
+
* TBD.
|
|
71
80
|
*
|
|
72
|
-
* @param {
|
|
81
|
+
* @param {Device} device - TBD.
|
|
73
82
|
*/
|
|
74
83
|
export function checkInput(device) {
|
|
75
|
-
if (
|
|
84
|
+
if (
|
|
85
|
+
'ontouchstart' in document.documentElement ||
|
|
86
|
+
(window.navigator.maxTouchPoints && window.navigator.maxTouchPoints >= 1)
|
|
87
|
+
) {
|
|
76
88
|
device.touch = true;
|
|
77
89
|
}
|
|
78
90
|
// if (window.navigator.msPointerEnabled || window.navigator.pointerEnabled) {
|
|
@@ -85,8 +97,9 @@ export function checkInput(device) {
|
|
|
85
97
|
}
|
|
86
98
|
|
|
87
99
|
/**
|
|
100
|
+
* TBD.
|
|
88
101
|
*
|
|
89
|
-
* @param {
|
|
102
|
+
* @param {Device} device - TBD.
|
|
90
103
|
*/
|
|
91
104
|
export function checkFullScreenSupport(device) {
|
|
92
105
|
const fs = [
|
|
@@ -131,8 +144,9 @@ export function checkFullScreenSupport(device) {
|
|
|
131
144
|
}
|
|
132
145
|
|
|
133
146
|
/**
|
|
147
|
+
* TBD.
|
|
134
148
|
*
|
|
135
|
-
* @param {
|
|
149
|
+
* @param {Device} device - TBD.
|
|
136
150
|
*/
|
|
137
151
|
export function checkBrowser(device) {
|
|
138
152
|
const ua = navigator.userAgent;
|
|
@@ -152,8 +166,9 @@ export function checkBrowser(device) {
|
|
|
152
166
|
}
|
|
153
167
|
|
|
154
168
|
/**
|
|
169
|
+
* TBD.
|
|
155
170
|
*
|
|
156
|
-
* @param {
|
|
171
|
+
* @param {Device} device - TBD.
|
|
157
172
|
*/
|
|
158
173
|
export function checkAudio(device) {
|
|
159
174
|
const audioElement = document.createElement('audio');
|
|
@@ -162,7 +177,10 @@ export function checkAudio(device) {
|
|
|
162
177
|
if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
|
|
163
178
|
device.ogg = true;
|
|
164
179
|
}
|
|
165
|
-
if (
|
|
180
|
+
if (
|
|
181
|
+
audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '') ||
|
|
182
|
+
audioElement.canPlayType('audio/opus;').replace(/^no$/, '')
|
|
183
|
+
) {
|
|
166
184
|
device.opus = true;
|
|
167
185
|
}
|
|
168
186
|
if (audioElement.canPlayType('audio/mpeg;').replace(/^no$/, '')) {
|
|
@@ -174,7 +192,10 @@ export function checkAudio(device) {
|
|
|
174
192
|
if (audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '')) {
|
|
175
193
|
device.wav = true;
|
|
176
194
|
}
|
|
177
|
-
if (
|
|
195
|
+
if (
|
|
196
|
+
audioElement.canPlayType('audio/x-m4a;') ||
|
|
197
|
+
audioElement.canPlayType('audio/aac;').replace(/^no$/, '')
|
|
198
|
+
) {
|
|
178
199
|
device.m4a = true;
|
|
179
200
|
}
|
|
180
201
|
if (audioElement.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')) {
|
|
@@ -192,20 +213,22 @@ export function checkAudio(device) {
|
|
|
192
213
|
}
|
|
193
214
|
|
|
194
215
|
/**
|
|
216
|
+
* TBD.
|
|
195
217
|
*
|
|
196
|
-
* @param {
|
|
218
|
+
* @param {Device} device - TBD.
|
|
197
219
|
*/
|
|
198
220
|
export function checkImage(device) {
|
|
199
221
|
device.avif = false;
|
|
200
222
|
device.webp = false;
|
|
201
223
|
try {
|
|
202
224
|
const avif = new Image();
|
|
203
|
-
avif.src =
|
|
225
|
+
avif.src =
|
|
226
|
+
'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=';
|
|
204
227
|
avif.onload = function () {
|
|
205
228
|
device.avif = true;
|
|
206
229
|
};
|
|
207
230
|
const webp = new Image();
|
|
208
|
-
webp.src =
|
|
231
|
+
webp.src = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=';
|
|
209
232
|
webp.onload = function () {
|
|
210
233
|
device.webp = true;
|
|
211
234
|
};
|
|
@@ -215,8 +238,9 @@ export function checkImage(device) {
|
|
|
215
238
|
}
|
|
216
239
|
|
|
217
240
|
/**
|
|
241
|
+
* TBD.
|
|
218
242
|
*
|
|
219
|
-
* @param {
|
|
243
|
+
* @param {Device} device - TBD.
|
|
220
244
|
*/
|
|
221
245
|
export function initialize(device) {
|
|
222
246
|
checkOS(device);
|
|
@@ -226,3 +250,12 @@ export function initialize(device) {
|
|
|
226
250
|
checkFullScreenSupport(device);
|
|
227
251
|
checkInput(device);
|
|
228
252
|
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* TBD.
|
|
256
|
+
*
|
|
257
|
+
* @returns {Device} TBD.
|
|
258
|
+
*/
|
|
259
|
+
export function createDevice() {
|
|
260
|
+
return new Device();
|
|
261
|
+
}
|