pixi.js 7.3.0 → 7.3.2

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/pixi.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * pixi.js - v7.3.0
3
- * Compiled Mon, 18 Sep 2023 15:35:01 UTC
2
+ * pixi.js - v7.3.2
3
+ * Compiled Fri, 20 Oct 2023 15:28:31 UTC
4
4
  *
5
5
  * pixi.js is licensed under the MIT License.
6
6
  * http://www.opensource.org/licenses/mit-license
@@ -4588,7 +4588,10 @@ function getMaxFragmentPrecision() {
4588
4588
  if (!maxFragmentPrecision) {
4589
4589
  maxFragmentPrecision = PRECISION.MEDIUM;
4590
4590
  const gl = getTestContext();
4591
- gl && gl.getShaderPrecisionFormat && (maxFragmentPrecision = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT).precision ? PRECISION.HIGH : PRECISION.MEDIUM);
4591
+ if (gl && gl.getShaderPrecisionFormat) {
4592
+ const shaderFragment = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
4593
+ shaderFragment && (maxFragmentPrecision = shaderFragment.precision ? PRECISION.HIGH : PRECISION.MEDIUM);
4594
+ }
4592
4595
  }
4593
4596
  return maxFragmentPrecision;
4594
4597
  }
@@ -8273,7 +8276,7 @@ class StartupSystem {
8273
8276
  */
8274
8277
  run(options) {
8275
8278
  const { renderer } = this;
8276
- renderer.runners.init.emit(renderer.options), options.hello && console.log(`PixiJS 7.3.0 - ${renderer.rendererLogId} - https://pixijs.com`), renderer.resize(renderer.screen.width, renderer.screen.height);
8279
+ renderer.runners.init.emit(renderer.options), options.hello && console.log(`PixiJS 7.3.2 - ${renderer.rendererLogId} - https://pixijs.com`), renderer.resize(renderer.screen.width, renderer.screen.height);
8277
8280
  }
8278
8281
  destroy() {
8279
8282
  }
@@ -10653,7 +10656,7 @@ const _VideoResource = class _VideoResource2 extends BaseImageResource {
10653
10656
  */
10654
10657
  _isSourcePlaying() {
10655
10658
  const source = this.source;
10656
- return !source.paused && !source.ended && this._isSourceReady();
10659
+ return !source.paused && !source.ended;
10657
10660
  }
10658
10661
  /**
10659
10662
  * Returns true if the underlying source is ready for playing.
@@ -10756,7 +10759,7 @@ class TransformFeedback {
10756
10759
  this.disposeRunner.emit(this, !1);
10757
10760
  }
10758
10761
  }
10759
- const VERSION = "7.3.0";
10762
+ const VERSION = "7.3.2";
10760
10763
  class Bounds {
10761
10764
  constructor() {
10762
10765
  this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0, this.rect = null, this.updateID = -1;
@@ -11679,7 +11682,11 @@ class Sprite extends Container {
11679
11682
  return;
11680
11683
  this._transformTrimmedID = this.transform._worldID, this._textureTrimmedID = this._texture._updateID;
11681
11684
  const texture = this._texture, vertexData = this.vertexTrimmedData, orig = texture.orig, anchor = this._anchor, wt = this.transform.worldTransform, a2 = wt.a, b2 = wt.b, c2 = wt.c, d2 = wt.d, tx = wt.tx, ty = wt.ty, w1 = -anchor._x * orig.width, w0 = w1 + orig.width, h1 = -anchor._y * orig.height, h0 = h1 + orig.height;
11682
- vertexData[0] = a2 * w1 + c2 * h1 + tx, vertexData[1] = d2 * h1 + b2 * w1 + ty, vertexData[2] = a2 * w0 + c2 * h1 + tx, vertexData[3] = d2 * h1 + b2 * w0 + ty, vertexData[4] = a2 * w0 + c2 * h0 + tx, vertexData[5] = d2 * h0 + b2 * w0 + ty, vertexData[6] = a2 * w1 + c2 * h0 + tx, vertexData[7] = d2 * h0 + b2 * w1 + ty;
11685
+ if (vertexData[0] = a2 * w1 + c2 * h1 + tx, vertexData[1] = d2 * h1 + b2 * w1 + ty, vertexData[2] = a2 * w0 + c2 * h1 + tx, vertexData[3] = d2 * h1 + b2 * w0 + ty, vertexData[4] = a2 * w0 + c2 * h0 + tx, vertexData[5] = d2 * h0 + b2 * w0 + ty, vertexData[6] = a2 * w1 + c2 * h0 + tx, vertexData[7] = d2 * h0 + b2 * w1 + ty, this._roundPixels) {
11686
+ const resolution = settings.RESOLUTION;
11687
+ for (let i2 = 0; i2 < vertexData.length; ++i2)
11688
+ vertexData[i2] = Math.round(vertexData[i2] * resolution) / resolution;
11689
+ }
11683
11690
  }
11684
11691
  /**
11685
11692
  *
@@ -11752,7 +11759,7 @@ class Sprite extends Container {
11752
11759
  * @default false
11753
11760
  */
11754
11761
  set roundPixels(value) {
11755
- this._roundPixels !== value && (this._transformID = -1), this._roundPixels = value;
11762
+ this._roundPixels !== value && (this._transformID = -1, this._transformTrimmedID = -1), this._roundPixels = value;
11756
11763
  }
11757
11764
  get roundPixels() {
11758
11765
  return this._roundPixels;
@@ -13771,7 +13778,7 @@ class EventBoundary {
13771
13778
  }
13772
13779
  }
13773
13780
  const isInteractiveMode = this._isInteractive(eventMode), isInteractiveTarget = currentTarget.isInteractive();
13774
- return isInteractiveTarget && isInteractiveTarget && this._allInteractiveElements.push(currentTarget), ignore || this._hitElements.length > 0 ? null : shouldReturn ? this._hitElements : isInteractiveMode && !pruneFn(currentTarget, location) && testFn(currentTarget, location) ? isInteractiveTarget ? [currentTarget] : [] : null;
13781
+ return isInteractiveMode && isInteractiveTarget && this._allInteractiveElements.push(currentTarget), ignore || this._hitElements.length > 0 ? null : shouldReturn ? this._hitElements : isInteractiveMode && !pruneFn(currentTarget, location) && testFn(currentTarget, location) ? isInteractiveTarget ? [currentTarget] : [] : null;
13775
13782
  }
13776
13783
  /**
13777
13784
  * Recursive implementation for {@link PIXI.EventBoundary.hitTest hitTest}.
@@ -15460,7 +15467,7 @@ function checkExtension(url2, extension) {
15460
15467
  const tempURL = url2.split("?")[0], ext = path.extname(tempURL).toLowerCase();
15461
15468
  return Array.isArray(extension) ? extension.includes(ext) : ext === extension;
15462
15469
  }
15463
- const convertToList = (input, transform) => (Array.isArray(input) || (input = [input]), transform ? input.map((item) => typeof item == "string" ? transform(item) : item) : input), copySearchParams = (targetUrl, sourceUrl) => {
15470
+ const convertToList = (input, transform, forceTransform = !1) => (Array.isArray(input) || (input = [input]), transform ? input.map((item) => typeof item == "string" || forceTransform ? transform(item) : item) : input), copySearchParams = (targetUrl, sourceUrl) => {
15464
15471
  const searchParams = sourceUrl.split("?")[1];
15465
15472
  return searchParams && (targetUrl += `?${searchParams}`), targetUrl;
15466
15473
  };
@@ -15730,6 +15737,10 @@ function getFontFamilyName(url2) {
15730
15737
  let fontFamilyName = nameTokens.join(" ");
15731
15738
  return valid || (fontFamilyName = `"${fontFamilyName.replace(/[\\"]/g, "\\$&")}"`), fontFamilyName;
15732
15739
  }
15740
+ const validURICharactersRegex = /^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;
15741
+ function encodeURIWhenNeeded(uri) {
15742
+ return validURICharactersRegex.test(uri) ? uri : encodeURI(uri);
15743
+ }
15733
15744
  const loadWebFont = {
15734
15745
  extension: {
15735
15746
  type: ExtensionType.LoadParser,
@@ -15745,7 +15756,7 @@ const loadWebFont = {
15745
15756
  if (fonts) {
15746
15757
  const fontFaces = [], name = (_b = (_a2 = options.data) == null ? void 0 : _a2.family) != null ? _b : getFontFamilyName(url2), weights = (_e = (_d = (_c = options.data) == null ? void 0 : _c.weights) == null ? void 0 : _d.filter((weight) => validWeights.includes(weight))) != null ? _e : ["normal"], data = (_f = options.data) != null ? _f : {};
15747
15758
  for (let i2 = 0; i2 < weights.length; i2++) {
15748
- const weight = weights[i2], font = new FontFace(name, `url(${encodeURI(url2)})`, __spreadProps$2(__spreadValues$8({}, data), {
15759
+ const weight = weights[i2], font = new FontFace(name, `url(${encodeURIWhenNeeded(url2)})`, __spreadProps$2(__spreadValues$8({}, data), {
15749
15760
  weight
15750
15761
  }));
15751
15762
  await font.load(), fonts.add(font), fontFaces.push(font);
@@ -16162,6 +16173,24 @@ class Resolver {
16162
16173
  this._defaultSearchParams = Object.keys(queryValues).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(queryValues[key])}`).join("&");
16163
16174
  }
16164
16175
  }
16176
+ /**
16177
+ * Returns the aliases for a given asset
16178
+ * @param asset - the asset to get the aliases for
16179
+ */
16180
+ getAlias(asset) {
16181
+ const { alias, name, src, srcs } = asset;
16182
+ return convertToList(
16183
+ alias || name || src || srcs,
16184
+ (value) => {
16185
+ var _a2;
16186
+ return typeof value == "string" ? value : Array.isArray(value) ? value.map((v2) => {
16187
+ var _a22, _b;
16188
+ return (_b = (_a22 = v2 == null ? void 0 : v2.src) != null ? _a22 : v2 == null ? void 0 : v2.srcs) != null ? _b : v2;
16189
+ }) : value != null && value.src || value != null && value.srcs ? (_a2 = value.src) != null ? _a2 : value.srcs : value;
16190
+ },
16191
+ !0
16192
+ );
16193
+ }
16165
16194
  /**
16166
16195
  * Add a manifest to the asset resolver. This is a nice way to add all the asset information in one go.
16167
16196
  * generally a manifest would be built using a tool.
@@ -16226,38 +16255,6 @@ class Resolver {
16226
16255
  assetNames.push(...aliases);
16227
16256
  }), this._bundles[bundleId] = assetNames;
16228
16257
  }
16229
- /**
16230
- * Tells the resolver what keys are associated with witch asset.
16231
- * The most important thing the resolver does
16232
- * @example
16233
- * // Single key, single asset:
16234
- * resolver.add({alias: 'foo', src: 'bar.png');
16235
- * resolver.resolveUrl('foo') // => 'bar.png'
16236
- *
16237
- * // Multiple keys, single asset:
16238
- * resolver.add({alias: ['foo', 'boo'], src: 'bar.png'});
16239
- * resolver.resolveUrl('foo') // => 'bar.png'
16240
- * resolver.resolveUrl('boo') // => 'bar.png'
16241
- *
16242
- * // Multiple keys, multiple assets:
16243
- * resolver.add({alias: ['foo', 'boo'], src: ['bar.png', 'bar.webp']});
16244
- * resolver.resolveUrl('foo') // => 'bar.png'
16245
- *
16246
- * // Add custom data attached to the resolver
16247
- * Resolver.add({
16248
- * alias: 'bunnyBooBooSmooth',
16249
- * src: 'bunny{png,webp}',
16250
- * data: { scaleMode:SCALE_MODES.NEAREST }, // Base texture options
16251
- * });
16252
- *
16253
- * resolver.resolve('bunnyBooBooSmooth') // => { src: 'bunny.png', data: { scaleMode: SCALE_MODES.NEAREST } }
16254
- * @param aliases - the key or keys that you will reference when loading this asset
16255
- * @param srcs - the asset or assets that will be chosen from when loading via the specified key
16256
- * @param data - asset-specific data that will be passed to the loaders
16257
- * - Useful if you want to initiate loaded objects with specific data
16258
- * @param format - the format of the asset
16259
- * @param loadParser - the name of the load parser to use
16260
- */
16261
16258
  add(aliases, srcs, data, format2, loadParser) {
16262
16259
  const assets = [];
16263
16260
  typeof aliases == "string" || Array.isArray(aliases) && typeof aliases[0] == "string" ? (deprecation("7.2.0", `Assets.add now uses an object instead of individual parameters.
@@ -16266,10 +16263,10 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16266
16263
  keyCheck = (key) => {
16267
16264
  this.hasKey(key) && console.warn(`[Resolver] already has key: ${key} overwriting`);
16268
16265
  }, convertToList(assets).forEach((asset) => {
16269
- const { alias, name, src, srcs: srcs2 } = asset;
16266
+ const { src, srcs: srcs2 } = asset;
16270
16267
  let { data: data2, format: format22, loadParser: loadParser2 } = asset;
16271
- const srcsToUse = convertToList(src || srcs2).map((src2) => typeof src2 == "string" ? createStringVariations(src2) : Array.isArray(src2) ? src2 : [src2]), aliasesToUse = convertToList(alias || name);
16272
- Array.isArray(alias) ? alias.forEach(keyCheck) : keyCheck(alias);
16268
+ const srcsToUse = convertToList(src || srcs2).map((src2) => typeof src2 == "string" ? createStringVariations(src2) : Array.isArray(src2) ? src2 : [src2]), aliasesToUse = this.getAlias(asset);
16269
+ Array.isArray(aliasesToUse) ? aliasesToUse.forEach(keyCheck) : keyCheck(aliasesToUse);
16273
16270
  const resolvedAssets = [];
16274
16271
  srcsToUse.forEach((srcs3) => {
16275
16272
  srcs3.forEach((src2) => {
@@ -16286,6 +16283,8 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16286
16283
  }
16287
16284
  } else
16288
16285
  data2 = (_a2 = src2.data) != null ? _a2 : data2, format22 = (_b = src2.format) != null ? _b : format22, loadParser2 = (_c = src2.loadParser) != null ? _c : loadParser2, formattedAsset = __spreadValues$4(__spreadValues$4({}, formattedAsset), src2);
16286
+ if (!aliasesToUse)
16287
+ throw new Error(`[Resolver] alias is undefined for this asset: ${formattedAsset.src}`);
16289
16288
  formattedAsset = this.buildResolvedAsset(formattedAsset, {
16290
16289
  aliases: aliasesToUse,
16291
16290
  data: data2,
@@ -16293,8 +16292,8 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16293
16292
  loadParser: loadParser2
16294
16293
  }), resolvedAssets.push(formattedAsset);
16295
16294
  });
16296
- }), aliasesToUse.forEach((alias2) => {
16297
- this._assetMap[alias2] = resolvedAssets;
16295
+ }), aliasesToUse.forEach((alias) => {
16296
+ this._assetMap[alias] = resolvedAssets;
16298
16297
  });
16299
16298
  });
16300
16299
  }
@@ -16310,12 +16309,12 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16310
16309
  * name: 'load-screen',
16311
16310
  * assets: [
16312
16311
  * {
16313
- * name: 'background',
16314
- * srcs: 'sunset.png',
16312
+ * alias: 'background',
16313
+ * src: 'sunset.png',
16315
16314
  * },
16316
16315
  * {
16317
- * name: 'bar',
16318
- * srcs: 'load-bar.{png,webp}',
16316
+ * alias: 'bar',
16317
+ * src: 'load-bar.{png,webp}',
16319
16318
  * },
16320
16319
  * ],
16321
16320
  * },
@@ -16323,12 +16322,12 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16323
16322
  * name: 'game-screen',
16324
16323
  * assets: [
16325
16324
  * {
16326
- * name: 'character',
16327
- * srcs: 'robot.png',
16325
+ * alias: 'character',
16326
+ * src: 'robot.png',
16328
16327
  * },
16329
16328
  * {
16330
- * name: 'enemy',
16331
- * srcs: 'bad-guy.png',
16329
+ * alias: 'enemy',
16330
+ * src: 'bad-guy.png',
16332
16331
  * },
16333
16332
  * ],
16334
16333
  * },
@@ -16435,7 +16434,7 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16435
16434
  buildResolvedAsset(formattedAsset, data) {
16436
16435
  var _a2;
16437
16436
  const { aliases, data: assetData, loadParser, format: format2 } = data;
16438
- return (this._basePath || this._rootPath) && (formattedAsset.src = path.toAbsolute(formattedAsset.src, this._basePath, this._rootPath)), formattedAsset.alias = (_a2 = aliases != null ? aliases : formattedAsset.alias) != null ? _a2 : [formattedAsset.src], formattedAsset.src = this._appendDefaultSearchParams(formattedAsset.src), formattedAsset.data = __spreadValues$4(__spreadValues$4({}, assetData || {}), formattedAsset.data), formattedAsset.loadParser = loadParser != null ? loadParser : formattedAsset.loadParser, formattedAsset.format = format2 != null ? format2 : formattedAsset.src.split(".").pop(), formattedAsset.srcs = formattedAsset.src, formattedAsset.name = formattedAsset.alias, formattedAsset;
16437
+ return (this._basePath || this._rootPath) && (formattedAsset.src = path.toAbsolute(formattedAsset.src, this._basePath, this._rootPath)), formattedAsset.alias = (_a2 = aliases != null ? aliases : formattedAsset.alias) != null ? _a2 : [formattedAsset.src], formattedAsset.src = this._appendDefaultSearchParams(formattedAsset.src), formattedAsset.data = __spreadValues$4(__spreadValues$4({}, assetData || {}), formattedAsset.data), formattedAsset.loadParser = loadParser != null ? loadParser : formattedAsset.loadParser, formattedAsset.format = format2 != null ? format2 : path.extname(formattedAsset.src).slice(1), formattedAsset.srcs = formattedAsset.src, formattedAsset.name = formattedAsset.alias, formattedAsset;
16439
16438
  }
16440
16439
  }
16441
16440
  class AssetsClass {
@@ -16471,51 +16470,6 @@ class AssetsClass {
16471
16470
  }
16472
16471
  }), options.preferences && this.setPreferences(options.preferences);
16473
16472
  }
16474
- /**
16475
- * Allows you to specify how to resolve any assets load requests.
16476
- * There are a few ways to add things here as shown below:
16477
- * @example
16478
- * import { Assets } from 'pixi.js';
16479
- *
16480
- * // Simple
16481
- * Assets.add({alias: 'bunnyBooBoo', src: 'bunny.png'});
16482
- * const bunny = await Assets.load('bunnyBooBoo');
16483
- *
16484
- * // Multiple keys:
16485
- * Assets.add({alias: ['burger', 'chicken'], src: 'bunny.png'});
16486
- *
16487
- * const bunny = await Assets.load('burger');
16488
- * const bunny2 = await Assets.load('chicken');
16489
- *
16490
- * // passing options to to the object
16491
- * Assets.add({
16492
- * alias: 'bunnyBooBooSmooth',
16493
- * src: 'bunny{png,webp}',
16494
- * data: { scaleMode: SCALE_MODES.NEAREST }, // Base texture options
16495
- * });
16496
- *
16497
- * // Multiple assets
16498
- *
16499
- * // The following all do the same thing:
16500
- *
16501
- * Assets.add({alias: 'bunnyBooBoo', src: 'bunny{png,webp}'});
16502
- *
16503
- * Assets.add({
16504
- * alias: 'bunnyBooBoo',
16505
- * src: [
16506
- * 'bunny.png',
16507
- * 'bunny.webp',
16508
- * ],
16509
- * });
16510
- *
16511
- * const bunny = await Assets.load('bunnyBooBoo'); // Will try to load WebP if available
16512
- * @param aliases - the key or keys that you will reference when loading this asset
16513
- * @param srcs - the asset or assets that will be chosen from when loading via the specified key
16514
- * @param data - asset-specific data that will be passed to the loaders
16515
- * - Useful if you want to initiate loaded objects with specific data
16516
- * @param format - the format of the asset
16517
- * @param loadParser - the name of the load parser to use
16518
- */
16519
16473
  add(aliases, srcs, data, format2, loadParser) {
16520
16474
  this.resolver.add(aliases, srcs, data, format2, loadParser);
16521
16475
  }
@@ -16523,9 +16477,8 @@ class AssetsClass {
16523
16477
  this._initialized || await this.init();
16524
16478
  const singleAsset = isSingleItem(urls), urlArray = convertToList(urls).map((url2) => {
16525
16479
  if (typeof url2 != "string") {
16526
- this.add(url2);
16527
- const srcs = url2.src || url2.srcs, aliases = url2.alias || url2.name;
16528
- return aliases && Array.isArray(aliases) ? aliases[0] : srcs && Array.isArray(srcs) ? srcs[0] : aliases || srcs;
16480
+ const aliases = this.resolver.getAlias(url2);
16481
+ return aliases.some((alias) => !this.resolver.hasKey(alias)) && this.add(url2), Array.isArray(aliases) ? aliases[0] : aliases;
16529
16482
  }
16530
16483
  return this.resolver.hasKey(url2) || this.add({ alias: url2, src: url2 }), url2;
16531
16484
  }), resolveResults = this.resolver.resolve(urlArray), out = await this._mapLoadToResolve(resolveResults, onProgress);
@@ -16564,12 +16517,12 @@ class AssetsClass {
16564
16517
  * name: 'load-screen',
16565
16518
  * assets: [
16566
16519
  * {
16567
- * name: 'background',
16568
- * srcs: 'sunset.png',
16520
+ * alias: 'background',
16521
+ * src: 'sunset.png',
16569
16522
  * },
16570
16523
  * {
16571
- * name: 'bar',
16572
- * srcs: 'load-bar.{png,webp}',
16524
+ * alias: 'bar',
16525
+ * src: 'load-bar.{png,webp}',
16573
16526
  * },
16574
16527
  * ],
16575
16528
  * },
@@ -16577,12 +16530,12 @@ class AssetsClass {
16577
16530
  * name: 'game-screen',
16578
16531
  * assets: [
16579
16532
  * {
16580
- * name: 'character',
16581
- * srcs: 'robot.png',
16533
+ * alias: 'character',
16534
+ * src: 'robot.png',
16582
16535
  * },
16583
16536
  * {
16584
- * name: 'enemy',
16585
- * srcs: 'bad-guy.png',
16537
+ * alias: 'enemy',
16538
+ * src: 'bad-guy.png',
16586
16539
  * },
16587
16540
  * ],
16588
16541
  * },
@@ -16819,22 +16772,36 @@ const cacheTextureArray = {
16819
16772
  }
16820
16773
  };
16821
16774
  extensions$1.add(cacheTextureArray);
16822
- const detectAvif = {
16823
- extension: {
16824
- type: ExtensionType.DetectionParser,
16825
- priority: 1
16826
- },
16827
- test: async () => {
16828
- const avifData = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=";
16775
+ async function testImageFormat(imageData) {
16776
+ if ("Image" in globalThis)
16829
16777
  return new Promise((resolve2) => {
16830
- const avif = new Image();
16831
- avif.onload = () => {
16778
+ const image = new Image();
16779
+ image.onload = () => {
16832
16780
  resolve2(!0);
16833
- }, avif.onerror = () => {
16781
+ }, image.onerror = () => {
16834
16782
  resolve2(!1);
16835
- }, avif.src = avifData;
16783
+ }, image.src = imageData;
16836
16784
  });
16785
+ if ("createImageBitmap" in globalThis && "fetch" in globalThis) {
16786
+ try {
16787
+ const blob = await (await fetch(imageData)).blob();
16788
+ await createImageBitmap(blob);
16789
+ } catch (e2) {
16790
+ return !1;
16791
+ }
16792
+ return !0;
16793
+ }
16794
+ return !1;
16795
+ }
16796
+ const detectAvif = {
16797
+ extension: {
16798
+ type: ExtensionType.DetectionParser,
16799
+ priority: 1
16837
16800
  },
16801
+ test: async () => testImageFormat(
16802
+ // eslint-disable-next-line max-len
16803
+ "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="
16804
+ ),
16838
16805
  add: async (formats2) => [...formats2, "avif"],
16839
16806
  remove: async (formats2) => formats2.filter((f2) => f2 !== "avif")
16840
16807
  };
@@ -16844,17 +16811,9 @@ const detectWebp = {
16844
16811
  type: ExtensionType.DetectionParser,
16845
16812
  priority: 0
16846
16813
  },
16847
- test: async () => {
16848
- const webpData = "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=";
16849
- return new Promise((resolve2) => {
16850
- const webp = new Image();
16851
- webp.onload = () => {
16852
- resolve2(!0);
16853
- }, webp.onerror = () => {
16854
- resolve2(!1);
16855
- }, webp.src = webpData;
16856
- });
16857
- },
16814
+ test: async () => testImageFormat(
16815
+ "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="
16816
+ ),
16858
16817
  add: async (formats2) => [...formats2, "webp"],
16859
16818
  remove: async (formats2) => formats2.filter((f2) => f2 !== "webp")
16860
16819
  };
@@ -16910,7 +16869,7 @@ const resolveTextureUrl = {
16910
16869
  var _a2, _b;
16911
16870
  return {
16912
16871
  resolution: parseFloat((_b = (_a2 = settings.RETINA_PREFIX.exec(value)) == null ? void 0 : _a2[1]) != null ? _b : "1"),
16913
- format: value.split(".").pop(),
16872
+ format: path.extname(value).slice(1),
16914
16873
  src: value
16915
16874
  };
16916
16875
  }
@@ -17431,12 +17390,13 @@ extensions$1.add(loadKTX);
17431
17390
  const resolveCompressedTextureUrl = {
17432
17391
  extension: ExtensionType.ResolveParser,
17433
17392
  test: (value) => {
17434
- const extension = value.split("?")[0].split(".").pop();
17393
+ const extension = path.extname(value).slice(1);
17435
17394
  return ["basis", "ktx", "dds"].includes(extension);
17436
17395
  },
17437
17396
  parse: (value) => {
17438
17397
  var _a2, _b, _c, _d;
17439
- if (value.split("?")[0].split(".").pop() === "ktx") {
17398
+ const extension = path.extname(value).slice(1);
17399
+ if (extension === "ktx") {
17440
17400
  const extensions2 = [
17441
17401
  ".s3tc.ktx",
17442
17402
  ".s3tc_sRGB.ktx",
@@ -17455,7 +17415,7 @@ const resolveCompressedTextureUrl = {
17455
17415
  }
17456
17416
  return {
17457
17417
  resolution: parseFloat((_d = (_c = settings.RETINA_PREFIX.exec(value)) == null ? void 0 : _c[1]) != null ? _d : "1"),
17458
- format: value.split(".").pop(),
17418
+ format: extension,
17459
17419
  src: value
17460
17420
  };
17461
17421
  }