@vpmedia/phaser 1.117.0 → 1.118.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 +140 -134
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +1 -1
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +70 -42
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +1 -1
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +8 -7
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +30 -1
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +24 -4
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +13 -3
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +3 -3
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +8 -6
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +13 -8
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/phaser/core/animation_manager.ts +1 -1
- package/src/phaser/core/cache.test.ts +201 -0
- package/src/phaser/core/cache.ts +126 -86
- package/src/phaser/core/input.ts +1 -1
- package/src/phaser/core/input_mspointer.ts +10 -13
- package/src/phaser/core/loader.ts +82 -42
- package/src/phaser/core/loader_parser.test.ts +115 -0
- package/src/phaser/core/loader_parser.ts +64 -36
- package/src/phaser/core/sound.ts +29 -17
- package/src/phaser/core/sound_manager.ts +1 -1
- package/src/phaser/core/tween.ts +6 -6
- package/src/phaser/core/tween_manager.ts +42 -35
- package/src/phaser/display/bitmap_text.test.ts +212 -0
- package/src/phaser/display/bitmap_text.ts +39 -24
package/dist/index.js
CHANGED
|
@@ -4370,12 +4370,13 @@ var BitmapText = class extends DisplayObject {
|
|
|
4370
4370
|
charCode = 32;
|
|
4371
4371
|
charData = data.chars[charCode];
|
|
4372
4372
|
}
|
|
4373
|
-
|
|
4373
|
+
if (charData === void 0) continue;
|
|
4374
|
+
const kerning = (prevCharCode === null ? 0 : charData.kerning[prevCharCode]) ?? 0;
|
|
4374
4375
|
if (/(\s)/.test(text.charAt(i))) {
|
|
4375
4376
|
lastSpace = i;
|
|
4376
4377
|
wrappedWidth = w;
|
|
4377
4378
|
}
|
|
4378
|
-
c = (kerning + charData.texture
|
|
4379
|
+
c = (kerning + (charData.texture?.width ?? 0) + charData.xOffset) * scale;
|
|
4379
4380
|
if (maxWidth && w + c >= maxWidth && lastSpace > -1) return {
|
|
4380
4381
|
width: wrappedWidth || w,
|
|
4381
4382
|
text: text.substr(0, i - (i - lastSpace)),
|
|
@@ -4401,7 +4402,7 @@ var BitmapText = class extends DisplayObject {
|
|
|
4401
4402
|
* @returns {string} The cleaned text.
|
|
4402
4403
|
*/
|
|
4403
4404
|
cleanText(text, replace = "") {
|
|
4404
|
-
const data = this._data
|
|
4405
|
+
const data = this._data?.font;
|
|
4405
4406
|
if (!data) return "";
|
|
4406
4407
|
const lines = text.replace(/\r\n|\n\r|\n|\r/g, "\n").split("\n");
|
|
4407
4408
|
for (let i = 0; i < lines.length; i += 1) {
|
|
@@ -4417,22 +4418,25 @@ var BitmapText = class extends DisplayObject {
|
|
|
4417
4418
|
* Updates the internal text rendering based on current properties and content.
|
|
4418
4419
|
*/
|
|
4419
4420
|
updateText() {
|
|
4420
|
-
const data = this._data
|
|
4421
|
+
const data = this._data?.font;
|
|
4421
4422
|
if (!data) return;
|
|
4422
4423
|
let text = this.text;
|
|
4423
4424
|
const scale = this._fontSize / data.size;
|
|
4424
4425
|
const lines = [];
|
|
4425
4426
|
let y = 0;
|
|
4426
4427
|
this.textWidth = 0;
|
|
4427
|
-
let
|
|
4428
|
+
let end = false;
|
|
4428
4429
|
do {
|
|
4429
|
-
line =
|
|
4430
|
-
|
|
4430
|
+
const line = {
|
|
4431
|
+
...this.scanLine(data, scale, text),
|
|
4432
|
+
y
|
|
4433
|
+
};
|
|
4431
4434
|
lines.push(line);
|
|
4432
4435
|
if (line.width > this.textWidth) this.textWidth = line.width;
|
|
4433
4436
|
y += data.lineHeight * scale;
|
|
4434
4437
|
text = text.slice(line.text.length + 1);
|
|
4435
|
-
|
|
4438
|
+
end = line.end;
|
|
4439
|
+
} while (!end);
|
|
4436
4440
|
this.textHeight = y;
|
|
4437
4441
|
let t = 0;
|
|
4438
4442
|
let align = 0;
|
|
@@ -4448,14 +4452,15 @@ var BitmapText = class extends DisplayObject {
|
|
|
4448
4452
|
charCode = 32;
|
|
4449
4453
|
charData = data.chars[charCode];
|
|
4450
4454
|
}
|
|
4455
|
+
if (charData?.texture === void 0) continue;
|
|
4451
4456
|
let g = this._glyphs[t];
|
|
4452
4457
|
if (g) g.texture = charData.texture;
|
|
4453
4458
|
else {
|
|
4454
4459
|
g = new Image$1(this.game, 0, 0, charData.texture);
|
|
4455
|
-
g.name = currentLine.text[c];
|
|
4460
|
+
g.name = currentLine.text[c] ?? "";
|
|
4456
4461
|
this._glyphs.push(g);
|
|
4457
4462
|
}
|
|
4458
|
-
g.position.x = currentLine.chars[c] + align - ax;
|
|
4463
|
+
g.position.x = (currentLine.chars[c] ?? 0) + align - ax;
|
|
4459
4464
|
g.position.y = currentLine.y + charData.yOffset * scale - ay;
|
|
4460
4465
|
g.scale.setTo(scale, scale);
|
|
4461
4466
|
g.tint = this.tint;
|
|
@@ -4590,9 +4595,9 @@ var BitmapText = class extends DisplayObject {
|
|
|
4590
4595
|
* @param {number} value - The new font size to use.
|
|
4591
4596
|
*/
|
|
4592
4597
|
set fontSize(value) {
|
|
4593
|
-
|
|
4594
|
-
if (
|
|
4595
|
-
this._fontSize =
|
|
4598
|
+
const size = Math.trunc(Number(value));
|
|
4599
|
+
if (size !== this._fontSize && size > 0) {
|
|
4600
|
+
this._fontSize = size;
|
|
4596
4601
|
this.updateText();
|
|
4597
4602
|
}
|
|
4598
4603
|
}
|
|
@@ -4636,15 +4641,14 @@ var BitmapText = class extends DisplayObject {
|
|
|
4636
4641
|
* @returns {boolean} True if smoothing is enabled, false otherwise.
|
|
4637
4642
|
*/
|
|
4638
4643
|
get smoothed() {
|
|
4639
|
-
return !this._data
|
|
4644
|
+
return !this._data?.base.scaleMode;
|
|
4640
4645
|
}
|
|
4641
4646
|
/**
|
|
4642
4647
|
* Sets whether smoothing is enabled for this bitmap text's font.
|
|
4643
4648
|
* @param {boolean} value - Whether to enable smoothing (true) or not (false).
|
|
4644
4649
|
*/
|
|
4645
4650
|
set smoothed(value) {
|
|
4646
|
-
if (
|
|
4647
|
-
else this._data.base.scaleMode = 1;
|
|
4651
|
+
if (this._data) this._data.base.scaleMode = value ? 0 : 1;
|
|
4648
4652
|
}
|
|
4649
4653
|
};
|
|
4650
4654
|
//#endregion
|
|
@@ -12105,10 +12109,7 @@ const JSONDataHash = (game, json, _key) => {
|
|
|
12105
12109
|
* @returns {object} The finalized bitmap font data.
|
|
12106
12110
|
*/
|
|
12107
12111
|
const finalizeBitmapFont = (baseTexture, bitmapFontData) => {
|
|
12108
|
-
Object.
|
|
12109
|
-
const letter = bitmapFontData.chars[charCode];
|
|
12110
|
-
letter.texture = new Texture(baseTexture, new Rectangle(letter.x, letter.y, letter.width, letter.height));
|
|
12111
|
-
});
|
|
12112
|
+
for (const letter of Object.values(bitmapFontData.chars)) letter.texture = new Texture(baseTexture, new Rectangle(letter.x, letter.y, letter.width, letter.height));
|
|
12112
12113
|
return bitmapFontData;
|
|
12113
12114
|
};
|
|
12114
12115
|
/**
|
|
@@ -12120,33 +12121,28 @@ const finalizeBitmapFont = (baseTexture, bitmapFontData) => {
|
|
|
12120
12121
|
* @returns {object} The parsed bitmap font data.
|
|
12121
12122
|
*/
|
|
12122
12123
|
const xmlBitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
|
|
12123
|
-
const data = {};
|
|
12124
12124
|
const info = xml.querySelectorAll("info")[0];
|
|
12125
12125
|
const common = xml.querySelectorAll("common")[0];
|
|
12126
|
-
|
|
12127
|
-
data
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
const first = Math.trunc(Number(kernings[i].getAttribute("first")));
|
|
12147
|
-
const second = Math.trunc(Number(kernings[i].getAttribute("second")));
|
|
12148
|
-
const amount = Math.trunc(Number(kernings[i].getAttribute("amount")));
|
|
12149
|
-
data.chars[second].kerning[first] = amount;
|
|
12126
|
+
const attr = (element, name) => Math.trunc(Number(element?.getAttribute(name)));
|
|
12127
|
+
const data = {
|
|
12128
|
+
font: info?.getAttribute("face") ?? "",
|
|
12129
|
+
size: attr(info, "size"),
|
|
12130
|
+
lineHeight: attr(common, "lineHeight") + ySpacing,
|
|
12131
|
+
chars: {}
|
|
12132
|
+
};
|
|
12133
|
+
for (const letter of xml.querySelectorAll("char")) data.chars[attr(letter, "id")] = {
|
|
12134
|
+
x: attr(letter, "x"),
|
|
12135
|
+
y: attr(letter, "y"),
|
|
12136
|
+
width: attr(letter, "width"),
|
|
12137
|
+
height: attr(letter, "height"),
|
|
12138
|
+
xOffset: attr(letter, "xoffset"),
|
|
12139
|
+
yOffset: attr(letter, "yoffset"),
|
|
12140
|
+
xAdvance: attr(letter, "xadvance") + xSpacing,
|
|
12141
|
+
kerning: {}
|
|
12142
|
+
};
|
|
12143
|
+
for (const kerning of xml.querySelectorAll("kerning")) {
|
|
12144
|
+
const char = data.chars[attr(kerning, "second")];
|
|
12145
|
+
if (char) char.kerning[attr(kerning, "first")] = attr(kerning, "amount");
|
|
12150
12146
|
}
|
|
12151
12147
|
return finalizeBitmapFont(baseTexture, data);
|
|
12152
12148
|
};
|
|
@@ -12306,9 +12302,9 @@ var Cache = class {
|
|
|
12306
12302
|
key,
|
|
12307
12303
|
url,
|
|
12308
12304
|
data,
|
|
12309
|
-
base: new BaseTexture(data)
|
|
12305
|
+
base: new BaseTexture(data),
|
|
12306
|
+
frameData: JSONDataHash(this.game, atlasData, key)
|
|
12310
12307
|
};
|
|
12311
|
-
obj.frameData = JSONDataHash(this.game, atlasData, key);
|
|
12312
12308
|
this._cache.image[key] = obj;
|
|
12313
12309
|
this._resolveURL(url, obj);
|
|
12314
12310
|
}
|
|
@@ -12319,13 +12315,14 @@ var Cache = class {
|
|
|
12319
12315
|
* @param {object} data - The sound data to cache.
|
|
12320
12316
|
*/
|
|
12321
12317
|
addSound(key, url, data) {
|
|
12322
|
-
|
|
12318
|
+
const obj = {
|
|
12323
12319
|
url,
|
|
12324
12320
|
data,
|
|
12325
12321
|
isDecoding: false,
|
|
12326
12322
|
decoded: false
|
|
12327
12323
|
};
|
|
12328
|
-
this.
|
|
12324
|
+
this._cache.sound[key] = obj;
|
|
12325
|
+
this._resolveURL(url, obj);
|
|
12329
12326
|
}
|
|
12330
12327
|
/**
|
|
12331
12328
|
* Adds text data to the cache.
|
|
@@ -12334,11 +12331,12 @@ var Cache = class {
|
|
|
12334
12331
|
* @param {string} data - The text data to cache.
|
|
12335
12332
|
*/
|
|
12336
12333
|
addText(key, url, data) {
|
|
12337
|
-
|
|
12334
|
+
const obj = {
|
|
12338
12335
|
url,
|
|
12339
12336
|
data
|
|
12340
12337
|
};
|
|
12341
|
-
this.
|
|
12338
|
+
this._cache.text[key] = obj;
|
|
12339
|
+
this._resolveURL(url, obj);
|
|
12342
12340
|
}
|
|
12343
12341
|
/**
|
|
12344
12342
|
* Adds a bitmap font to the cache.
|
|
@@ -12351,14 +12349,13 @@ var Cache = class {
|
|
|
12351
12349
|
* @param {number} ySpacing - Vertical spacing between characters.
|
|
12352
12350
|
*/
|
|
12353
12351
|
addBitmapFont(key, url, data, atlasData, atlasType, xSpacing = 0, ySpacing = 0) {
|
|
12352
|
+
const base = new BaseTexture(data);
|
|
12354
12353
|
const obj = {
|
|
12355
12354
|
url,
|
|
12356
12355
|
data,
|
|
12357
|
-
font:
|
|
12358
|
-
base
|
|
12356
|
+
font: atlasType === "json" ? jsonBitmapFont(atlasData, base, xSpacing, ySpacing) : xmlBitmapFont(atlasData, base, xSpacing, ySpacing),
|
|
12357
|
+
base
|
|
12359
12358
|
};
|
|
12360
|
-
if (atlasType === "json") obj.font = jsonBitmapFont(atlasData, obj.base, xSpacing, ySpacing);
|
|
12361
|
-
else obj.font = xmlBitmapFont(atlasData, obj.base, xSpacing, ySpacing);
|
|
12362
12359
|
this._cache.bitmapFont[key] = obj;
|
|
12363
12360
|
this._resolveURL(url, obj);
|
|
12364
12361
|
}
|
|
@@ -12369,11 +12366,12 @@ var Cache = class {
|
|
|
12369
12366
|
* @param {object} data - The JSON data to cache.
|
|
12370
12367
|
*/
|
|
12371
12368
|
addJSON(key, url, data) {
|
|
12372
|
-
|
|
12369
|
+
const obj = {
|
|
12373
12370
|
url,
|
|
12374
12371
|
data
|
|
12375
12372
|
};
|
|
12376
|
-
this.
|
|
12373
|
+
this._cache.json[key] = obj;
|
|
12374
|
+
this._resolveURL(url, obj);
|
|
12377
12375
|
}
|
|
12378
12376
|
/**
|
|
12379
12377
|
* Adds XML data to the cache.
|
|
@@ -12382,11 +12380,12 @@ var Cache = class {
|
|
|
12382
12380
|
* @param {XMLDocument} data - The XML data to cache.
|
|
12383
12381
|
*/
|
|
12384
12382
|
addXML(key, url, data) {
|
|
12385
|
-
|
|
12383
|
+
const obj = {
|
|
12386
12384
|
url,
|
|
12387
12385
|
data
|
|
12388
12386
|
};
|
|
12389
|
-
this.
|
|
12387
|
+
this._cache.xml[key] = obj;
|
|
12388
|
+
this._resolveURL(url, obj);
|
|
12390
12389
|
}
|
|
12391
12390
|
/**
|
|
12392
12391
|
* Updates a sound property in the cache.
|
|
@@ -12405,6 +12404,7 @@ var Cache = class {
|
|
|
12405
12404
|
*/
|
|
12406
12405
|
decodedSound(key, data) {
|
|
12407
12406
|
const sound = this.getSound(key);
|
|
12407
|
+
if (!sound) return;
|
|
12408
12408
|
sound.data = data;
|
|
12409
12409
|
sound.decoded = true;
|
|
12410
12410
|
sound.isDecoding = false;
|
|
@@ -12415,7 +12415,7 @@ var Cache = class {
|
|
|
12415
12415
|
* @returns {boolean} True if the sound is decoded, false otherwise.
|
|
12416
12416
|
*/
|
|
12417
12417
|
isSoundDecoded(key) {
|
|
12418
|
-
const sound = this.
|
|
12418
|
+
const sound = this.getSound(key);
|
|
12419
12419
|
if (sound) return sound.decoded;
|
|
12420
12420
|
return null;
|
|
12421
12421
|
}
|
|
@@ -12425,7 +12425,7 @@ var Cache = class {
|
|
|
12425
12425
|
* @returns {boolean} True if the sound is ready, false otherwise.
|
|
12426
12426
|
*/
|
|
12427
12427
|
isSoundReady(key) {
|
|
12428
|
-
const sound = this.
|
|
12428
|
+
const sound = this.getSound(key);
|
|
12429
12429
|
if (sound) return sound.decoded && !this.game.sound.isLocked;
|
|
12430
12430
|
return false;
|
|
12431
12431
|
}
|
|
@@ -12545,15 +12545,8 @@ var Cache = class {
|
|
|
12545
12545
|
getCanvas(key) {
|
|
12546
12546
|
return this.getItem(key, 0, "getCanvas", "canvas");
|
|
12547
12547
|
}
|
|
12548
|
-
/**
|
|
12549
|
-
* TBD.
|
|
12550
|
-
* @param {string} key - TBD.
|
|
12551
|
-
* @param {boolean} full - TBD.
|
|
12552
|
-
* @returns {HTMLImageElement} TBD.
|
|
12553
|
-
*/
|
|
12554
12548
|
getImage(key = "__default", full = false) {
|
|
12555
|
-
|
|
12556
|
-
if (img === null) img = this.getItem("__missing", 1, "getImage");
|
|
12549
|
+
const img = this.getItem(String(key), 1, "getImage") ?? this.getItem("__missing", 1, "getImage");
|
|
12557
12550
|
if (full) return img;
|
|
12558
12551
|
return img.data;
|
|
12559
12552
|
}
|
|
@@ -12731,8 +12724,9 @@ var Cache = class {
|
|
|
12731
12724
|
*/
|
|
12732
12725
|
getKeys(cache = 1) {
|
|
12733
12726
|
const result = [];
|
|
12734
|
-
|
|
12735
|
-
|
|
12727
|
+
const bucket = this._cacheMap[cache];
|
|
12728
|
+
if (bucket) {
|
|
12729
|
+
const keys = Object.keys(bucket);
|
|
12736
12730
|
for (const key of keys) if (key !== "__default" && key !== "__missing") result.push(key);
|
|
12737
12731
|
}
|
|
12738
12732
|
return result;
|
|
@@ -12751,7 +12745,7 @@ var Cache = class {
|
|
|
12751
12745
|
*/
|
|
12752
12746
|
removeImage(key, destroyBaseTexture = true) {
|
|
12753
12747
|
const img = this.getImage(key, true);
|
|
12754
|
-
if (destroyBaseTexture
|
|
12748
|
+
if (destroyBaseTexture) img.base.destroy();
|
|
12755
12749
|
delete this._cache.image[key];
|
|
12756
12750
|
}
|
|
12757
12751
|
/**
|
|
@@ -12821,8 +12815,7 @@ var Cache = class {
|
|
|
12821
12815
|
* Clears all GL textures from the cache.
|
|
12822
12816
|
*/
|
|
12823
12817
|
clearGLTextures() {
|
|
12824
|
-
const
|
|
12825
|
-
for (const key of keys) this._cache.image[key].base._glTextures = [];
|
|
12818
|
+
for (const entry of Object.values(this._cache.image)) entry.base._glTextures = [];
|
|
12826
12819
|
}
|
|
12827
12820
|
/**
|
|
12828
12821
|
* Resolves a URL and stores it in the cache.
|
|
@@ -12846,7 +12839,7 @@ var Cache = class {
|
|
|
12846
12839
|
for (const cache of this._cacheMap) {
|
|
12847
12840
|
const keys = cache ? Object.keys(cache) : [];
|
|
12848
12841
|
for (const key of keys) if (key !== "__default" && key !== "__missing") {
|
|
12849
|
-
|
|
12842
|
+
cache[key].destroy?.();
|
|
12850
12843
|
delete cache[key];
|
|
12851
12844
|
}
|
|
12852
12845
|
}
|
|
@@ -13560,14 +13553,10 @@ var MSPointer = class {
|
|
|
13560
13553
|
if (this._onMSPointerDown) canvas.removeEventListener("pointerdown", this._onMSPointerDown, false);
|
|
13561
13554
|
if (this._onMSPointerMove) canvas.removeEventListener("pointermove", this._onMSPointerMove, false);
|
|
13562
13555
|
if (this._onMSPointerUp) canvas.removeEventListener("pointerup", this._onMSPointerUp, false);
|
|
13563
|
-
if (this._onMSPointerUpGlobal)
|
|
13564
|
-
if (this._onMSPointerUpGlobal) globalThis.removeEventListener("MSPointerUp", this._onMSPointerUpGlobal, true);
|
|
13565
|
-
}
|
|
13556
|
+
if (this._onMSPointerUpGlobal) globalThis.removeEventListener("MSPointerUp", this._onMSPointerUpGlobal, true);
|
|
13566
13557
|
if (this._onMSPointerOver) canvas.removeEventListener("MSPointerOver", this._onMSPointerOver, true);
|
|
13567
13558
|
if (this._onMSPointerOut) canvas.removeEventListener("MSPointerOut", this._onMSPointerOut, true);
|
|
13568
|
-
if (this._onMSPointerUpGlobal)
|
|
13569
|
-
if (this._onMSPointerUpGlobal) globalThis.removeEventListener("pointerup", this._onMSPointerUpGlobal, true);
|
|
13570
|
-
}
|
|
13559
|
+
if (this._onMSPointerUpGlobal) globalThis.removeEventListener("pointerup", this._onMSPointerUpGlobal, true);
|
|
13571
13560
|
if (this._onMSPointerOver) canvas.removeEventListener("pointerover", this._onMSPointerOver, true);
|
|
13572
13561
|
if (this._onMSPointerOut) canvas.removeEventListener("pointerout", this._onMSPointerOut, true);
|
|
13573
13562
|
}
|
|
@@ -15281,41 +15270,41 @@ var Loader = class {
|
|
|
15281
15270
|
* @param {object} pack - The pack file object to process.
|
|
15282
15271
|
*/
|
|
15283
15272
|
processPack(pack) {
|
|
15284
|
-
const packData = pack.data[pack.key];
|
|
15273
|
+
const packData = (pack.data ?? {})[pack.key];
|
|
15285
15274
|
if (!packData) {
|
|
15286
15275
|
this.game.logger.warn("Missing loader pack key", { key: pack.key });
|
|
15287
15276
|
return;
|
|
15288
15277
|
}
|
|
15289
|
-
const packDataCompat = Array.isArray(packData) ? packData : packData.files;
|
|
15278
|
+
const packDataCompat = Array.isArray(packData) ? packData : packData.files ?? [];
|
|
15290
15279
|
for (const file of packDataCompat) switch (file.type) {
|
|
15291
15280
|
case "image":
|
|
15292
|
-
this.image(file.key, file.url, file.overwrite);
|
|
15281
|
+
this.image(file.key, file.url ?? file.key, file.overwrite);
|
|
15293
15282
|
break;
|
|
15294
15283
|
case "text":
|
|
15295
|
-
this.text(file.key, file.url, file.overwrite);
|
|
15284
|
+
this.text(file.key, file.url ?? file.key, file.overwrite);
|
|
15296
15285
|
break;
|
|
15297
15286
|
case "json":
|
|
15298
|
-
this.json(file.key, file.url, file.overwrite);
|
|
15287
|
+
this.json(file.key, file.url ?? file.key, file.overwrite);
|
|
15299
15288
|
break;
|
|
15300
15289
|
case "xml":
|
|
15301
|
-
this.xml(file.key, file.url, file.overwrite);
|
|
15290
|
+
this.xml(file.key, file.url ?? file.key, file.overwrite);
|
|
15302
15291
|
break;
|
|
15303
15292
|
case "spritesheet":
|
|
15304
|
-
this.spritesheet(file.key, file.url, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
|
|
15293
|
+
this.spritesheet(file.key, file.url ?? file.key, file.frameWidth ?? 0, file.frameHeight ?? 0, file.frameMax ?? -1, file.margin, file.spacing);
|
|
15305
15294
|
break;
|
|
15306
15295
|
case "audio":
|
|
15307
|
-
this.audio(file.key, file.urls ?? file.url);
|
|
15296
|
+
this.audio(file.key, file.urls ?? file.url ?? file.key);
|
|
15308
15297
|
break;
|
|
15309
15298
|
case "audiosprite":
|
|
15310
|
-
this.audioSprite(file.key, file.urls ?? file.url, file.jsonURL, file.jsonData);
|
|
15299
|
+
this.audioSprite(file.key, String(file.urls ?? file.url ?? file.key), file.jsonURL ?? "", file.jsonData);
|
|
15311
15300
|
break;
|
|
15312
15301
|
case "audioSprite":
|
|
15313
|
-
this.audioSprite(file.key, file.audioURL, file.jsonURL, file.jsonData);
|
|
15302
|
+
this.audioSprite(file.key, file.audioURL ?? file.key, file.jsonURL ?? "", file.jsonData);
|
|
15314
15303
|
break;
|
|
15315
15304
|
case "bitmapFont":
|
|
15316
15305
|
this.bitmapFont(file.key, file.textureURL, file.fontDataURL ?? file.atlasURL, file.atlasData, file.xSpacing, file.ySpacing);
|
|
15317
15306
|
break;
|
|
15318
|
-
case "atlas": this.atlas(file.key, file.textureURL, file.atlasURL, file.atlasData, TEXTURE_ATLAS_JSON_HASH);
|
|
15307
|
+
case "atlas": this.atlas(file.key, file.textureURL ?? file.key, file.atlasURL, file.atlasData, TEXTURE_ATLAS_JSON_HASH);
|
|
15319
15308
|
}
|
|
15320
15309
|
}
|
|
15321
15310
|
/**
|
|
@@ -15371,28 +15360,34 @@ var Loader = class {
|
|
|
15371
15360
|
loadImageTag(file) {
|
|
15372
15361
|
this.log("loadImageTag", file);
|
|
15373
15362
|
const scope = this;
|
|
15374
|
-
|
|
15375
|
-
file.data
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15363
|
+
const image = new globalThis.Image();
|
|
15364
|
+
file.data = image;
|
|
15365
|
+
image.name = file.key;
|
|
15366
|
+
if (typeof this.crossOrigin === "string" && this.crossOrigin) image.crossOrigin = this.crossOrigin;
|
|
15367
|
+
image.onload = () => {
|
|
15368
|
+
if (image.onload) {
|
|
15369
|
+
image.onload = null;
|
|
15370
|
+
image.onerror = null;
|
|
15381
15371
|
scope.fileComplete(file);
|
|
15382
15372
|
}
|
|
15383
15373
|
};
|
|
15384
|
-
|
|
15374
|
+
image.onerror = () => {
|
|
15385
15375
|
if (scope.isUseRetry && (!file.numRetry || file.numRetry < scope.maxRetry)) setTimeout(() => {
|
|
15386
15376
|
file.numRetry = !file.numRetry ? 1 : file.numRetry += 1;
|
|
15387
15377
|
scope.loadImageTag(file);
|
|
15388
15378
|
}, 1e3);
|
|
15389
|
-
else if (
|
|
15390
|
-
|
|
15391
|
-
|
|
15379
|
+
else if (image.onload) {
|
|
15380
|
+
image.onload = null;
|
|
15381
|
+
image.onerror = null;
|
|
15392
15382
|
scope.fileError(file);
|
|
15393
15383
|
}
|
|
15394
15384
|
};
|
|
15395
|
-
|
|
15385
|
+
const src = this.transformUrl(file.url, file);
|
|
15386
|
+
if (src === false) {
|
|
15387
|
+
this.fileError(file, null, "Could not resolve the file URL");
|
|
15388
|
+
return;
|
|
15389
|
+
}
|
|
15390
|
+
image.src = src;
|
|
15396
15391
|
}
|
|
15397
15392
|
/**
|
|
15398
15393
|
* Loads a file using XMLHttpRequest with the specified parameters.
|
|
@@ -15550,14 +15545,19 @@ var Loader = class {
|
|
|
15550
15545
|
});
|
|
15551
15546
|
}
|
|
15552
15547
|
break;
|
|
15553
|
-
case "audio":
|
|
15554
|
-
|
|
15555
|
-
|
|
15548
|
+
case "audio": {
|
|
15549
|
+
const audio = response.response;
|
|
15550
|
+
file.data = audio;
|
|
15551
|
+
this.cache.addSound(file.key, url, audio);
|
|
15556
15552
|
if (file.autoDecode) this.game.sound.decode(file.key);
|
|
15557
15553
|
break;
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
|
|
15554
|
+
}
|
|
15555
|
+
case "text": {
|
|
15556
|
+
const { responseText } = response;
|
|
15557
|
+
file.data = responseText;
|
|
15558
|
+
this.cache.addText(file.key, url, responseText);
|
|
15559
|
+
break;
|
|
15560
|
+
}
|
|
15561
15561
|
}
|
|
15562
15562
|
if (loadNext) this.asyncComplete(file);
|
|
15563
15563
|
}
|
|
@@ -17287,8 +17287,9 @@ var Sound = class {
|
|
|
17287
17287
|
*/
|
|
17288
17288
|
soundHasUnlocked(key) {
|
|
17289
17289
|
if (key === this.key) {
|
|
17290
|
-
|
|
17291
|
-
this.
|
|
17290
|
+
const buffer = this.game.cache.getSoundData(this.key);
|
|
17291
|
+
this._sound = buffer;
|
|
17292
|
+
this.totalDuration = buffer.duration;
|
|
17292
17293
|
}
|
|
17293
17294
|
}
|
|
17294
17295
|
/**
|
|
@@ -17402,14 +17403,15 @@ var Sound = class {
|
|
|
17402
17403
|
this.isPlaying = false;
|
|
17403
17404
|
}
|
|
17404
17405
|
if (marker === "" && Object.keys(this.markers).length > 0) return this;
|
|
17406
|
+
const markerData = marker === "" ? void 0 : this.markers[marker];
|
|
17405
17407
|
if (marker !== "") {
|
|
17406
|
-
if (
|
|
17408
|
+
if (markerData) {
|
|
17407
17409
|
this.currentMarker = marker;
|
|
17408
|
-
this.position =
|
|
17409
|
-
this.volume =
|
|
17410
|
-
this.loop =
|
|
17411
|
-
this.duration =
|
|
17412
|
-
this.durationMS =
|
|
17410
|
+
this.position = markerData.start;
|
|
17411
|
+
this.volume = markerData.volume;
|
|
17412
|
+
this.loop = markerData.loop;
|
|
17413
|
+
this.duration = markerData.duration;
|
|
17414
|
+
this.durationMS = markerData.durationMS;
|
|
17413
17415
|
if (volume !== void 0) this.volume = volume;
|
|
17414
17416
|
if (loop !== void 0) this.loop = loop;
|
|
17415
17417
|
this._tempMarker = marker;
|
|
@@ -17421,8 +17423,8 @@ var Sound = class {
|
|
|
17421
17423
|
return this;
|
|
17422
17424
|
}
|
|
17423
17425
|
} else {
|
|
17424
|
-
position
|
|
17425
|
-
|
|
17426
|
+
position ??= 0;
|
|
17427
|
+
volume ??= this._volume;
|
|
17426
17428
|
if (loop === void 0) ({loop} = this);
|
|
17427
17429
|
this.position = Math.max(0, position);
|
|
17428
17430
|
this.volume = volume;
|
|
@@ -17457,7 +17459,7 @@ var Sound = class {
|
|
|
17457
17459
|
this.onPlay.dispatch(this);
|
|
17458
17460
|
} else {
|
|
17459
17461
|
this.pendingPlayback = true;
|
|
17460
|
-
if (this.game.cache.getSound(this.key)
|
|
17462
|
+
if (this.game.cache.getSound(this.key)?.isDecoding === false) this.game.sound.decode(this.key);
|
|
17461
17463
|
}
|
|
17462
17464
|
return this;
|
|
17463
17465
|
}
|
|
@@ -17909,7 +17911,7 @@ var SoundManager = class {
|
|
|
17909
17911
|
*/
|
|
17910
17912
|
decode(key) {
|
|
17911
17913
|
const soundData = this.game.cache.getSoundData(key);
|
|
17912
|
-
if (!soundData) return;
|
|
17914
|
+
if (!(soundData instanceof ArrayBuffer)) return;
|
|
17913
17915
|
if (this.game.cache.isSoundDecoded(key) === true) return;
|
|
17914
17916
|
this.game.cache.updateSound(key, "isDecoding", true);
|
|
17915
17917
|
this.context.decodeAudioData(soundData).then((buffer) => {
|
|
@@ -19825,7 +19827,7 @@ var TweenManager = class {
|
|
|
19825
19827
|
* This method removes all active and pending tweens.
|
|
19826
19828
|
*/
|
|
19827
19829
|
removeAll() {
|
|
19828
|
-
for (
|
|
19830
|
+
for (const tween of this._tweens) tween.pendingDelete = true;
|
|
19829
19831
|
this._add = [];
|
|
19830
19832
|
}
|
|
19831
19833
|
/**
|
|
@@ -19834,14 +19836,17 @@ var TweenManager = class {
|
|
|
19834
19836
|
* @param {object[]} children - Optional array of child objects to remove tweens from.
|
|
19835
19837
|
*/
|
|
19836
19838
|
removeFrom(obj, children = null) {
|
|
19837
|
-
|
|
19838
|
-
|
|
19839
|
-
|
|
19840
|
-
|
|
19841
|
-
|
|
19842
|
-
|
|
19843
|
-
for (
|
|
19839
|
+
if (Array.isArray(obj)) {
|
|
19840
|
+
for (const entry of obj) this.removeFrom(entry);
|
|
19841
|
+
return;
|
|
19842
|
+
}
|
|
19843
|
+
const group = obj;
|
|
19844
|
+
if (group.type === 7 && children && group.children) {
|
|
19845
|
+
for (const child of group.children) this.removeFrom(child);
|
|
19846
|
+
return;
|
|
19844
19847
|
}
|
|
19848
|
+
for (const tween of this._tweens.slice()) if (obj === tween.target) this.remove(tween);
|
|
19849
|
+
for (const tween of this._add.slice()) if (obj === tween.target) this.remove(tween);
|
|
19845
19850
|
}
|
|
19846
19851
|
/**
|
|
19847
19852
|
* Add a tween to the manager.
|
|
@@ -19864,6 +19869,7 @@ var TweenManager = class {
|
|
|
19864
19869
|
* @param {Tween | null | undefined} tween - The tween to remove.
|
|
19865
19870
|
*/
|
|
19866
19871
|
remove(tween) {
|
|
19872
|
+
if (!tween) return;
|
|
19867
19873
|
let i = this._tweens.indexOf(tween);
|
|
19868
19874
|
if (i !== -1) this._tweens[i].pendingDelete = true;
|
|
19869
19875
|
else {
|
|
@@ -19904,28 +19910,28 @@ var TweenManager = class {
|
|
|
19904
19910
|
* This method pauses all active tweens.
|
|
19905
19911
|
*/
|
|
19906
19912
|
_pauseAll() {
|
|
19907
|
-
for (
|
|
19913
|
+
for (const tween of this._tweens) tween._pause();
|
|
19908
19914
|
}
|
|
19909
19915
|
/**
|
|
19910
19916
|
* Resume all tweens managed by this manager.
|
|
19911
19917
|
* This method resumes all paused tweens.
|
|
19912
19918
|
*/
|
|
19913
19919
|
_resumeAll() {
|
|
19914
|
-
for (
|
|
19920
|
+
for (const tween of this._tweens) tween._resume();
|
|
19915
19921
|
}
|
|
19916
19922
|
/**
|
|
19917
19923
|
* Pause all tweens managed by this manager.
|
|
19918
19924
|
* This method pauses all active tweens.
|
|
19919
19925
|
*/
|
|
19920
19926
|
pauseAll() {
|
|
19921
|
-
for (
|
|
19927
|
+
for (const tween of this._tweens) tween.pause();
|
|
19922
19928
|
}
|
|
19923
19929
|
/**
|
|
19924
19930
|
* Resume all tweens managed by this manager.
|
|
19925
19931
|
* This method resumes all paused tweens.
|
|
19926
19932
|
*/
|
|
19927
19933
|
resumeAll() {
|
|
19928
|
-
for (
|
|
19934
|
+
for (const tween of this._tweens) tween.resume();
|
|
19929
19935
|
}
|
|
19930
19936
|
};
|
|
19931
19937
|
//#endregion
|