@vpmedia/phaser 1.109.0 → 1.111.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/index.js +102 -168
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation_manager.d.ts +8 -7
  4. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  5. package/dist/phaser/core/cache.d.ts +38 -12
  6. package/dist/phaser/core/cache.d.ts.map +1 -1
  7. package/dist/phaser/core/device.d.ts +23 -23
  8. package/dist/phaser/core/device.d.ts.map +1 -1
  9. package/dist/phaser/core/dom.d.ts +1 -1
  10. package/dist/phaser/core/dom.d.ts.map +1 -1
  11. package/dist/phaser/core/factory.d.ts +13 -7
  12. package/dist/phaser/core/factory.d.ts.map +1 -1
  13. package/dist/phaser/core/input.d.ts +54 -45
  14. package/dist/phaser/core/input.d.ts.map +1 -1
  15. package/dist/phaser/core/input_handler.d.ts +70 -51
  16. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  17. package/dist/phaser/core/input_mouse.d.ts +15 -14
  18. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  19. package/dist/phaser/core/input_pointer.d.ts +40 -38
  20. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  21. package/dist/phaser/core/loader.d.ts +31 -28
  22. package/dist/phaser/core/loader.d.ts.map +1 -1
  23. package/dist/phaser/core/scale_manager.d.ts +57 -53
  24. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  25. package/dist/phaser/core/scene_manager.d.ts +7 -4
  26. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  27. package/dist/phaser/core/signal.d.ts +9 -9
  28. package/dist/phaser/core/signal.d.ts.map +1 -1
  29. package/dist/phaser/core/time.d.ts +31 -30
  30. package/dist/phaser/core/time.d.ts.map +1 -1
  31. package/dist/phaser/core/timer.d.ts +25 -23
  32. package/dist/phaser/core/timer.d.ts.map +1 -1
  33. package/dist/phaser/core/tween_manager.d.ts +1 -1
  34. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  35. package/dist/phaser/display/bitmap_text.d.ts +17 -15
  36. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  37. package/dist/phaser/display/display_object.d.ts +13 -12
  38. package/dist/phaser/display/display_object.d.ts.map +1 -1
  39. package/dist/phaser/display/group.d.ts +5 -4
  40. package/dist/phaser/display/group.d.ts.map +1 -1
  41. package/dist/phaser/display/text.d.ts +13 -12
  42. package/dist/phaser/display/text.d.ts.map +1 -1
  43. package/package.json +10 -10
  44. package/src/phaser/core/animation_manager.ts +5 -9
  45. package/src/phaser/core/cache.ts +58 -12
  46. package/src/phaser/core/device.ts +23 -83
  47. package/src/phaser/core/dom.ts +1 -1
  48. package/src/phaser/core/factory.ts +3 -2
  49. package/src/phaser/core/input.ts +51 -51
  50. package/src/phaser/core/input_handler.ts +57 -35
  51. package/src/phaser/core/input_mouse.ts +16 -14
  52. package/src/phaser/core/input_pointer.ts +35 -53
  53. package/src/phaser/core/loader.ts +34 -31
  54. package/src/phaser/core/scale_manager.ts +51 -49
  55. package/src/phaser/core/scene_manager.ts +6 -4
  56. package/src/phaser/core/signal.ts +8 -6
  57. package/src/phaser/core/time.ts +29 -53
  58. package/src/phaser/core/timer.ts +22 -40
  59. package/src/phaser/core/tween_manager.ts +2 -2
  60. package/src/phaser/display/bitmap_text.ts +18 -30
  61. package/src/phaser/display/display_object.ts +11 -10
  62. package/src/phaser/display/group.ts +7 -5
  63. package/src/phaser/display/text.ts +14 -14
package/dist/index.js CHANGED
@@ -1789,8 +1789,8 @@ const getBounds = (target, matrix = null) => {
1789
1789
  const getLocalBounds = (target) => {
1790
1790
  const matrixCache = target.worldTransform;
1791
1791
  target.worldTransform = getIdentityMatrix();
1792
- let i;
1793
- for (i = 0; i < target.children.length; i += 1) target.children[i].updateTransform();
1792
+ let i = 0;
1793
+ for (; i < target.children.length; i += 1) target.children[i].updateTransform();
1794
1794
  const bounds = target.getBounds();
1795
1795
  target.worldTransform = matrixCache;
1796
1796
  for (i = 0; i < target.children.length; i += 1) target.children[i].updateTransform();
@@ -2104,7 +2104,7 @@ var DisplayObject = class {
2104
2104
  removeChildAt(index) {
2105
2105
  const child = this.getChildAt(index);
2106
2106
  if (child) {
2107
- child.parent = void 0;
2107
+ child.parent = null;
2108
2108
  this.children.splice(index, 1);
2109
2109
  }
2110
2110
  return child;
@@ -2124,7 +2124,7 @@ var DisplayObject = class {
2124
2124
  const removed = this.children.splice(beginIndex, range);
2125
2125
  for (let i = 0; i < removed.length; i += 1) {
2126
2126
  const child = removed[i];
2127
- child.parent = void 0;
2127
+ child.parent = null;
2128
2128
  }
2129
2129
  return removed;
2130
2130
  }
@@ -2300,8 +2300,9 @@ var DisplayObject = class {
2300
2300
  /**
2301
2301
  * Renders this display object using WebGL.
2302
2302
  * @param {object} renderSession - The WebGL rendering session.
2303
+ * @param {import('../geom/matrix.js').Matrix | null} _matrix - The transform matrix to render with.
2303
2304
  */
2304
- renderWebGL(renderSession) {
2305
+ renderWebGL(renderSession, _matrix = null) {
2305
2306
  if (!this.visible || this.alpha <= 0) return;
2306
2307
  let i;
2307
2308
  if (this._mask || this._filters) {
@@ -2726,7 +2727,7 @@ var Signal = class {
2726
2727
  _registerListener(listener, isOnce = false, listenerContext = null, priority = 0, args = null) {
2727
2728
  const prevIndex = this._indexOfListener(listener, listenerContext);
2728
2729
  let binding;
2729
- if (prevIndex !== -1) {
2730
+ if (prevIndex !== -1 && this._bindings) {
2730
2731
  binding = this._bindings[prevIndex];
2731
2732
  if (binding.isOnce() !== isOnce) throw new Error(`You cannot add${isOnce ? "" : "Once"}() then add${!isOnce ? "" : "Once"}() the same listener without removing the relationship first.`);
2732
2733
  } else {
@@ -2807,7 +2808,7 @@ var Signal = class {
2807
2808
  remove(listener, context = null) {
2808
2809
  this.validateListener(listener, "remove");
2809
2810
  const i = this._indexOfListener(listener, context);
2810
- if (i !== -1) {
2811
+ if (i !== -1 && this._bindings) {
2811
2812
  this._bindings[i]._destroy();
2812
2813
  this._bindings.splice(i, 1);
2813
2814
  }
@@ -2890,7 +2891,9 @@ var Signal = class {
2890
2891
  */
2891
2892
  get boundDispatch() {
2892
2893
  const _this = this;
2893
- if (!this._boundDispatch) this._boundDispatch = (...rest) => _this.dispatch(...rest);
2894
+ if (!this._boundDispatch) this._boundDispatch = (...rest) => {
2895
+ _this.dispatch(...rest);
2896
+ };
2894
2897
  return this._boundDispatch;
2895
2898
  }
2896
2899
  /**
@@ -3325,17 +3328,13 @@ var AnimationManager = class {
3325
3328
  constructor(sprite) {
3326
3329
  this.sprite = sprite;
3327
3330
  this.game = sprite.game;
3328
- /** @type {import('./frame.js').Frame} */
3329
3331
  this.currentFrame = null;
3330
- /** @type {Animation} */
3331
3332
  this.currentAnim = null;
3332
3333
  this.updateIfVisible = true;
3333
3334
  this.isLoaded = false;
3334
- /** @type {import('./frame_data.js').FrameData} */
3335
3335
  this._frameData = null;
3336
3336
  /** @type {{[key: string]: Animation}} */
3337
3337
  this._anims = {};
3338
- /** @type {number[]} */
3339
3338
  this._outputFrames = [];
3340
3339
  }
3341
3340
  /**
@@ -4252,31 +4251,20 @@ var BitmapText = class extends DisplayObject {
4252
4251
  */
4253
4252
  constructor(game, x = 0, y = 0, font = "", text = "", size = 32, align = "left") {
4254
4253
  super(game);
4255
- /** @type {number} */
4256
4254
  this.type = 6;
4257
4255
  this.position.setTo(x, y);
4258
- /** @type {number} */
4259
4256
  this.textWidth = 0;
4260
- /** @type {number} */
4261
4257
  this.textHeight = 0;
4262
- /** @type {Point} */
4263
4258
  this._prevAnchor = new Point();
4264
4259
  this._glyphs = [];
4265
- /** @type {number} */
4266
4260
  this._maxWidth = 0;
4267
- /** @type {string} */
4268
4261
  this._text = text.toString() || "";
4269
4262
  this._data = game.cache.getBitmapFont(font);
4270
- /** @type {string} */
4271
4263
  this._font = font;
4272
- /** @type {number} */
4273
4264
  this._fontSize = size;
4274
- /** @type {string} */
4275
4265
  this._align = align;
4276
- /** @type {number} */
4277
4266
  this._tint = 16777215;
4278
4267
  this.updateText();
4279
- /** @type {boolean} */
4280
4268
  this.dirty = false;
4281
4269
  }
4282
4270
  /**
@@ -4451,7 +4439,6 @@ var BitmapText = class extends DisplayObject {
4451
4439
  const kept = [];
4452
4440
  for (let i = 0; i < this._glyphs.length; i += 1) if (this._glyphs[i].parent !== this) this._glyphs[i].destroy();
4453
4441
  else kept.push(this._glyphs[i]);
4454
- /** @type {Image[]} */
4455
4442
  this._glyphs = [];
4456
4443
  this._glyphs = kept;
4457
4444
  this.updateText();
@@ -4750,6 +4737,8 @@ var InputHandler = class {
4750
4737
  id: i,
4751
4738
  x: 0,
4752
4739
  y: 0,
4740
+ camX: 0,
4741
+ camY: 0,
4753
4742
  isDown: false,
4754
4743
  isUp: false,
4755
4744
  isOver: false,
@@ -4795,6 +4784,8 @@ var InputHandler = class {
4795
4784
  id: i,
4796
4785
  x: 0,
4797
4786
  y: 0,
4787
+ camX: 0,
4788
+ camY: 0,
4798
4789
  isDown: false,
4799
4790
  isUp: false,
4800
4791
  isOver: false,
@@ -8696,10 +8687,11 @@ var Group = class extends DisplayObject {
8696
8687
  }
8697
8688
  /**
8698
8689
  * Adds a child to this group.
8699
- * @param {DisplayObject} child - The child to add.
8690
+ * @template T
8691
+ * @param {T} child - The child to add.
8700
8692
  * @param {boolean} silent - Whether to dispatch events.
8701
8693
  * @param {number} index - The index to add the child at.
8702
- * @returns {DisplayObject} The added child.
8694
+ * @returns {T} The added child.
8703
8695
  */
8704
8696
  add(child, silent = false, index = -1) {
8705
8697
  if (child.parent === this) return child;
@@ -8710,7 +8702,8 @@ var Group = class extends DisplayObject {
8710
8702
  this.addChildAt(child, index);
8711
8703
  this.updateZ();
8712
8704
  }
8713
- if (this.inputEnableChildren && (!child.input || child.inputEnabled)) child.inputEnabled = true;
8705
+ const inputChild = child;
8706
+ if (this.inputEnableChildren && (!inputChild.input || inputChild.inputEnabled)) inputChild.inputEnabled = true;
8714
8707
  if (!silent && child.events) child.events.onAddedToGroup$dispatch(child, this);
8715
8708
  if (this.cursor === null) this.cursor = child;
8716
8709
  return child;
@@ -11195,8 +11188,8 @@ var WebGLShaderManager = class {
11195
11188
  * @param {number[]} attribs - The attribute locations to set up.
11196
11189
  */
11197
11190
  setAttribs(attribs) {
11198
- let i;
11199
- for (i = 0; i < this.tempAttribState.length; i += 1) this.tempAttribState[i] = false;
11191
+ let i = 0;
11192
+ for (; i < this.tempAttribState.length; i += 1) this.tempAttribState[i] = false;
11200
11193
  for (i = 0; i < attribs.length; i += 1) {
11201
11194
  const attribId = attribs[i];
11202
11195
  this.tempAttribState[attribId] = true;
@@ -12115,6 +12108,44 @@ var Frame = class {
12115
12108
  /**
12116
12109
  * TBD.
12117
12110
  * @param {import('./game.js').Game} game - TBD.
12111
+ * @param {string} key - TBD.
12112
+ * @param {number} frameWidth - TBD.
12113
+ * @param {number} frameHeight - TBD.
12114
+ * @param {number} frameMax - TBD.
12115
+ * @param {number} margin - TBD.
12116
+ * @param {number} spacing - TBD.
12117
+ * @returns {FrameData} TBD.
12118
+ */
12119
+ const spriteSheet = (game, key, frameWidth, frameHeight, frameMax, margin, spacing) => {
12120
+ let img = key;
12121
+ if (typeof key === "string") img = game.cache.getImage(key);
12122
+ if (img === null) return null;
12123
+ const width = img.width;
12124
+ const height = img.height;
12125
+ if (frameWidth <= 0) frameWidth = Math.floor(-width / Math.min(-1, frameWidth));
12126
+ if (frameHeight <= 0) frameHeight = Math.floor(-height / Math.min(-1, frameHeight));
12127
+ let total = Math.floor((width - margin) / (frameWidth + spacing)) * Math.floor((height - margin) / (frameHeight + spacing));
12128
+ if (frameMax !== -1) total = frameMax;
12129
+ if (width === 0 || height === 0 || width < frameWidth || height < frameHeight || total === 0) {
12130
+ game.logger.warn(`AnimationParser.spriteSheet: '${key}'s width/height zero or width/height < given frameWidth/frameHeight`);
12131
+ return null;
12132
+ }
12133
+ const data = new FrameData();
12134
+ let x = margin;
12135
+ let y = margin;
12136
+ for (let i = 0; i < total; i += 1) {
12137
+ data.addFrame(new Frame(i, x, y, frameWidth, frameHeight, ""));
12138
+ x += frameWidth + spacing;
12139
+ if (x + frameWidth > width) {
12140
+ x = margin;
12141
+ y += frameHeight + spacing;
12142
+ }
12143
+ }
12144
+ return data;
12145
+ };
12146
+ /**
12147
+ * TBD.
12148
+ * @param {import('./game.js').Game} game - TBD.
12118
12149
  * @param {object} json - TBD.
12119
12150
  * @returns {FrameData} TBD.
12120
12151
  */
@@ -12313,6 +12344,28 @@ var Cache = class {
12313
12344
  return img;
12314
12345
  }
12315
12346
  /**
12347
+ * Adds a sprite sheet to the cache.
12348
+ * @param {string} key - The unique key for this cache entry.
12349
+ * @param {string} url - The URL the sprite sheet was loaded from.
12350
+ * @param {HTMLImageElement} data - The image data to cache.
12351
+ * @param {number} frameWidth - The width of each frame in the sprite sheet.
12352
+ * @param {number} frameHeight - The height of each frame in the sprite sheet.
12353
+ * @param {number} frameMax - The maximum number of frames to parse (-1 for all).
12354
+ * @param {number} margin - The margin around each frame in pixels.
12355
+ * @param {number} spacing - The spacing between frames in pixels.
12356
+ */
12357
+ addSpriteSheet(key, url, data, frameWidth, frameHeight, frameMax = -1, margin = 0, spacing = 0) {
12358
+ const obj = {
12359
+ key,
12360
+ url,
12361
+ data,
12362
+ base: new BaseTexture(data),
12363
+ frameData: spriteSheet(this.game, data, frameWidth, frameHeight, frameMax, margin, spacing)
12364
+ };
12365
+ this._cache.image[key] = obj;
12366
+ this._resolveURL(url, obj);
12367
+ }
12368
+ /**
12316
12369
  * Adds a texture atlas to the cache.
12317
12370
  * @param {string} key - The unique key for this cache entry.
12318
12371
  * @param {string} url - The URL the atlas was loaded from.
@@ -12622,10 +12675,11 @@ var Cache = class {
12622
12675
  return this.getItem(key, 6, "getBitmapFont");
12623
12676
  }
12624
12677
  /**
12625
- * TBD.
12626
- * @param {string} key - TBD.
12627
- * @param {boolean} isClone - TBD.
12628
- * @returns {object} TBD.
12678
+ * Gets JSON data from the cache.
12679
+ * @template T
12680
+ * @param {string} key - The unique key for the cache entry.
12681
+ * @param {boolean} isClone - Whether to return a deep clone of the cached data.
12682
+ * @returns {T} The cached JSON data.
12629
12683
  */
12630
12684
  getJSON(key, isClone = false) {
12631
12685
  const data = this.getItem(key, 7, "getJSON", "data");
@@ -12680,7 +12734,7 @@ var Cache = class {
12680
12734
  * Gets the frame data of a cache entry.
12681
12735
  * @param {string} key - The unique key for the cache entry.
12682
12736
  * @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
12683
- * @returns {FrameData} The frame data.
12737
+ * @returns {FrameData | null} The frame data, or null when the entry has none.
12684
12738
  */
12685
12739
  getFrameData(key, cache = 1) {
12686
12740
  return this.getItem(key, cache, "getFrameData", "frameData");
@@ -12825,14 +12879,14 @@ var Cache = class {
12825
12879
  * @param {string} key - The unique key for the cache entry to remove.
12826
12880
  */
12827
12881
  removeSpriteSheet(key) {
12828
- delete this._cache.spriteSheet[key];
12882
+ delete this._cache.image[key];
12829
12883
  }
12830
12884
  /**
12831
12885
  * Removes a texture atlas cache entry.
12832
12886
  * @param {string} key - The unique key for the cache entry to remove.
12833
12887
  */
12834
12888
  removeTextureAtlas(key) {
12835
- delete this._cache.atlas[key];
12889
+ delete this._cache.image[key];
12836
12890
  }
12837
12891
  /**
12838
12892
  * Clears all GL textures from the cache.
@@ -12909,86 +12963,26 @@ var Device = class {
12909
12963
  * This class provides information about the current device and browser capabilities.
12910
12964
  */
12911
12965
  constructor() {
12912
- /**
12913
- * @type {boolean}
12914
- */
12915
12966
  this.desktop = false;
12916
- /**
12917
- * @type {boolean}
12918
- */
12919
12967
  this.iOS = false;
12920
- /**
12921
- * @type {boolean}
12922
- */
12923
12968
  this.android = false;
12924
- /**
12925
- * @type {boolean}
12926
- */
12927
12969
  this.chromeOS = false;
12928
- /**
12929
- * @type {boolean}
12930
- */
12931
12970
  this.linux = false;
12932
- /**
12933
- * @type {boolean}
12934
- */
12935
12971
  this.macOS = false;
12936
- /**
12937
- * @type {boolean}
12938
- */
12939
12972
  this.windows = false;
12940
- /**
12941
- * @type {boolean}
12942
- */
12943
12973
  this.windowsPhone = false;
12944
- /**
12945
- * @type {boolean}
12946
- */
12947
12974
  this.canvas = false;
12948
- /**
12949
- * @type {boolean}
12950
- */
12951
12975
  this.touch = false;
12952
- /**
12953
- * @type {boolean}
12954
- */
12955
12976
  this.mspointer = false;
12956
12977
  this.wheelEvent = null;
12957
- /**
12958
- * @type {boolean}
12959
- */
12960
12978
  this.chrome = false;
12961
- /**
12962
- * @type {boolean}
12963
- */
12964
12979
  this.firefox = false;
12965
- /**
12966
- * @type {boolean}
12967
- */
12968
12980
  this.edge = false;
12969
- /**
12970
- * @type {boolean}
12971
- */
12972
12981
  this.safari = false;
12973
- /**
12974
- * @type {boolean}
12975
- */
12976
12982
  this.fullscreen = false;
12977
- /**
12978
- * @type {string}
12979
- */
12980
12983
  this.requestFullscreen = "";
12981
- /**
12982
- * @type {string}
12983
- */
12984
12984
  this.cancelFullscreen = "";
12985
- /**
12986
- * @type {boolean}
12987
- */
12988
12985
  this.fullscreenKeyboard = false;
12989
- /**
12990
- * @type {boolean}
12991
- */
12992
12986
  this.noAudioFormat = false;
12993
12987
  /**
12994
12988
  * @type {{[key: string]: boolean}}
@@ -13773,10 +13767,8 @@ var Pointer = class {
13773
13767
  constructor(game, id, pointerMode) {
13774
13768
  this.game = game;
13775
13769
  this.id = id;
13776
- /** @type {number} */
13777
13770
  this.type = 19;
13778
13771
  this.exists = true;
13779
- /** @type {number} */
13780
13772
  this.identifier = 0;
13781
13773
  this.pointerId = null;
13782
13774
  this.pointerMode = pointerMode || 3;
@@ -13784,43 +13776,27 @@ var Pointer = class {
13784
13776
  this.button = null;
13785
13777
  this._holdSent = false;
13786
13778
  this._history = [];
13787
- /** @type {number} */
13788
13779
  this._nextDrop = 0;
13789
13780
  this._stateReset = false;
13790
13781
  this.withinGame = false;
13791
13782
  this.clientX = -1;
13792
- /** @type {number} */
13793
13783
  this.clientY = -1;
13794
- /** @type {number} */
13795
13784
  this.pageX = -1;
13796
- /** @type {number} */
13797
13785
  this.pageY = -1;
13798
- /** @type {number} */
13799
13786
  this.screenX = -1;
13800
- /** @type {number} */
13801
13787
  this.screenY = -1;
13802
- /** @type {number} */
13803
13788
  this.rawMovementX = 0;
13804
- /** @type {number} */
13805
13789
  this.rawMovementY = 0;
13806
- /** @type {number} */
13807
13790
  this.movementX = 0;
13808
- /** @type {number} */
13809
13791
  this.movementY = 0;
13810
- /** @type {number} */
13811
13792
  this.x = -1;
13812
- /** @type {number} */
13813
13793
  this.y = -1;
13814
13794
  this.isMouse = id === 0;
13815
13795
  this.isDown = false;
13816
13796
  this.isUp = true;
13817
- /** @type {number} */
13818
13797
  this.timeDown = 0;
13819
- /** @type {number} */
13820
13798
  this.timeUp = 0;
13821
- /** @type {number} */
13822
13799
  this.previousTapTime = 0;
13823
- /** @type {number} */
13824
13800
  this.totalTouches = 0;
13825
13801
  this.msSinceLastClick = Number.MAX_VALUE;
13826
13802
  this.targetObject = null;
@@ -15479,7 +15455,8 @@ var Loader = class {
15479
15455
  xhr.open("GET", url, true);
15480
15456
  xhr.responseType = type;
15481
15457
  if (this.headers.requestedWith !== false) xhr.setRequestHeader("X-Requested-With", this.headers.requestedWith);
15482
- if (this.headers[file.type]) xhr.setRequestHeader("Accept", this.headers[file.type]);
15458
+ const acceptHeader = this.headers[file.type];
15459
+ if (acceptHeader) xhr.setRequestHeader("Accept", acceptHeader);
15483
15460
  onerror = onerror || this.fileError;
15484
15461
  xhr.onload = () => {
15485
15462
  try {
@@ -15582,7 +15559,7 @@ var Loader = class {
15582
15559
  this.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
15583
15560
  break;
15584
15561
  case "textureatlas":
15585
- if (file.atlasURL == null) this.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format);
15562
+ if (file.atlasURL == null) this.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData);
15586
15563
  else {
15587
15564
  loadNext = false;
15588
15565
  if (file.format === TEXTURE_ATLAS_JSON_HASH) this.xhrLoad(file, this.transformUrl(file.atlasURL, file), "text", this.jsonLoadComplete);
@@ -15628,7 +15605,7 @@ var Loader = class {
15628
15605
  const data = JSON.parse(xhr.responseText);
15629
15606
  if (file.type === "bitmapfont") this.cache.addBitmapFont(file.key, file.url, file.data, data, file.atlasType, file.xSpacing, file.ySpacing);
15630
15607
  else if (file.type === "json") this.cache.addJSON(file.key, file.url, data);
15631
- else this.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format);
15608
+ else this.cache.addTextureAtlas(file.key, file.url, file.data, data);
15632
15609
  this.asyncComplete(file);
15633
15610
  }
15634
15611
  /**
@@ -15652,7 +15629,7 @@ var Loader = class {
15652
15629
  return;
15653
15630
  }
15654
15631
  if (file.type === "bitmapfont") this.cache.addBitmapFont(file.key, file.url, file.data, xml, file.atlasType, file.xSpacing, file.ySpacing);
15655
- else if (file.type === "textureatlas") this.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format);
15632
+ else if (file.type === "textureatlas") this.cache.addTextureAtlas(file.key, file.url, file.data, xml);
15656
15633
  else if (file.type === "xml") this.cache.addXML(file.key, file.url, xml);
15657
15634
  this.asyncComplete(file);
15658
15635
  }
@@ -16003,7 +15980,7 @@ var DOM = class {
16003
15980
  * @param {string} primaryFallback - The fallback method to use if screen orientation API is not available.
16004
15981
  * @returns {string} The screen orientation ('portrait-primary', 'landscape-primary', etc.).
16005
15982
  */
16006
- getScreenOrientation(primaryFallback) {
15983
+ getScreenOrientation(primaryFallback = null) {
16007
15984
  const screen = window.screen;
16008
15985
  const orientation = screen.orientation || screen.mozOrientation || screen.msOrientation;
16009
15986
  if (orientation && typeof orientation.type === "string") return orientation.type;
@@ -16154,7 +16131,6 @@ var ScaleManager = class {
16154
16131
  this.bounds = new Rectangle();
16155
16132
  this.aspectRatio = 0;
16156
16133
  this.sourceAspectRatio = 0;
16157
- /** @type {Event | null | undefined} */
16158
16134
  this.event = null;
16159
16135
  this.windowConstraints = {
16160
16136
  right: "layout",
@@ -16338,7 +16314,7 @@ var ScaleManager = class {
16338
16314
  this.onSizeChange.dispatch(this, width, height);
16339
16315
  if (this.currentScaleMode === 3) {
16340
16316
  this.game.state.resize(width, height);
16341
- this.game.load.resize(width, height);
16317
+ this.game.load.resize();
16342
16318
  }
16343
16319
  }
16344
16320
  }
@@ -16710,7 +16686,8 @@ var ScaleManager = class {
16710
16686
  this.onFullScreenInit.dispatch(this, { targetElement: fsTarget });
16711
16687
  if (this._createdFullScreenTarget) {
16712
16688
  const canvas = this.game.canvas;
16713
- canvas.parentNode.insertBefore(fsTarget, canvas);
16689
+ const parent = canvas.parentNode;
16690
+ if (parent) parent.insertBefore(fsTarget, canvas);
16714
16691
  fsTarget.appendChild(canvas);
16715
16692
  }
16716
16693
  if (this.game.device.fullscreenKeyboard) fsTarget[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
@@ -16818,7 +16795,7 @@ var ScaleManager = class {
16818
16795
  */
16819
16796
  get boundingParent() {
16820
16797
  if (this.parentIsWindow || this.isFullScreen && this.hasPhaserSetFullScreen && !this._createdFullScreenTarget) return null;
16821
- return this.game.canvas && this.game.canvas.parentNode || null;
16798
+ return (this.game.canvas ? this.game.canvas.parentNode : null) || null;
16822
16799
  }
16823
16800
  /**
16824
16801
  * TBD.
@@ -17165,7 +17142,8 @@ var SceneManager = class {
17165
17142
  }
17166
17143
  /**
17167
17144
  * Get the current scene state.
17168
- * @returns {Scene} The current scene state.
17145
+ * @template T
17146
+ * @returns {T} The current scene state.
17169
17147
  */
17170
17148
  getCurrentState() {
17171
17149
  return this.states[this.current];
@@ -18332,43 +18310,24 @@ var Timer = class {
18332
18310
  */
18333
18311
  constructor(game, autoDestroy = false) {
18334
18312
  this.game = game;
18335
- /** @type {boolean} */
18336
18313
  this.running = false;
18337
- /** @type {boolean} */
18338
18314
  this.autoDestroy = autoDestroy;
18339
- /** @type {boolean} */
18340
18315
  this.expired = false;
18341
- /** @type {number} */
18342
18316
  this.elapsed = 0;
18343
- /** @type {TimerEvent[]} */
18344
18317
  this.events = [];
18345
- /** @type {Signal} */
18346
18318
  this.onComplete = new Signal();
18347
- /** @type {number} */
18348
18319
  this.nextTick = 0;
18349
- /** @type {number} */
18350
18320
  this.timeCap = 1e3;
18351
- /** @type {boolean} */
18352
18321
  this.paused = false;
18353
- /** @type {boolean} */
18354
18322
  this._codePaused = false;
18355
- /** @type {number} */
18356
18323
  this._started = 0;
18357
- /** @type {number} */
18358
18324
  this._pauseStarted = 0;
18359
- /** @type {number} */
18360
18325
  this._pauseTotal = 0;
18361
- /** @type {number} */
18362
18326
  this._now = Date.now();
18363
- /** @type {number} */
18364
18327
  this._len = 0;
18365
- /** @type {number} */
18366
18328
  this._marked = 0;
18367
- /** @type {number} */
18368
18329
  this._i = 0;
18369
- /** @type {number} */
18370
18330
  this._diff = 0;
18371
- /** @type {number} */
18372
18331
  this._newTick = 0;
18373
18332
  }
18374
18333
  /**
@@ -18686,56 +18645,31 @@ var Time = class {
18686
18645
  */
18687
18646
  constructor(game) {
18688
18647
  this.game = game;
18689
- /** @type {number} */
18690
18648
  this.time = 0;
18691
- /** @type {number} */
18692
18649
  this.prevTime = 0;
18693
- /** @type {number} */
18694
18650
  this.now = 0;
18695
- /** @type {number} */
18696
18651
  this.elapsed = 0;
18697
- /** @type {number} */
18698
18652
  this.elapsedMS = 0;
18699
- /** @type {number} */
18700
18653
  this.desiredFpsMult = 1 / 60;
18701
- /** @type {number} */
18702
18654
  this._desiredFps = 60;
18703
- /** @type {number} */
18704
18655
  this.suggestedFps = this.desiredFps;
18705
- /** @type {boolean} */
18706
18656
  this.advancedTiming = false;
18707
- /** @type {number} */
18708
18657
  this.frames = 0;
18709
- /** @type {number} */
18710
18658
  this.fps = 0;
18711
- /** @type {number} */
18712
18659
  this.fpsMin = 1e3;
18713
- /** @type {number} */
18714
18660
  this.fpsMax = 0;
18715
- /** @type {number} */
18716
18661
  this.msMin = 1e3;
18717
- /** @type {number} */
18718
18662
  this.msMax = 0;
18719
- /** @type {number} */
18720
18663
  this.pauseDuration = 0;
18721
- /** @type {number} */
18722
18664
  this.timeToCall = 0;
18723
- /** @type {number} */
18724
18665
  this.timeExpected = 0;
18725
- /** @type {Timer} */
18726
18666
  this.events = new Timer(this.game, false);
18727
- /** @type {number} */
18728
18667
  this._frameCount = 0;
18729
- /** @type {number} */
18730
18668
  this._elapsedAccumulator = 0;
18731
18669
  this._started = 0;
18732
- /** @type {number} */
18733
18670
  this._timeLastSecond = 0;
18734
- /** @type {number} */
18735
18671
  this._pauseStarted = 0;
18736
- /** @type {boolean} */
18737
18672
  this._justResumed = false;
18738
- /** @type {Timer[]} */
18739
18673
  this._timers = [];
18740
18674
  }
18741
18675
  /**