pixi.js 7.3.1 → 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.1
3
- * Compiled Fri, 22 Sep 2023 18:50:32 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.1 - ${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.1";
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;
@@ -13775,7 +13778,7 @@ class EventBoundary {
13775
13778
  }
13776
13779
  }
13777
13780
  const isInteractiveMode = this._isInteractive(eventMode), isInteractiveTarget = currentTarget.isInteractive();
13778
- 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;
13779
13782
  }
13780
13783
  /**
13781
13784
  * Recursive implementation for {@link PIXI.EventBoundary.hitTest hitTest}.
@@ -15734,6 +15737,10 @@ function getFontFamilyName(url2) {
15734
15737
  let fontFamilyName = nameTokens.join(" ");
15735
15738
  return valid || (fontFamilyName = `"${fontFamilyName.replace(/[\\"]/g, "\\$&")}"`), fontFamilyName;
15736
15739
  }
15740
+ const validURICharactersRegex = /^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;
15741
+ function encodeURIWhenNeeded(uri) {
15742
+ return validURICharactersRegex.test(uri) ? uri : encodeURI(uri);
15743
+ }
15737
15744
  const loadWebFont = {
15738
15745
  extension: {
15739
15746
  type: ExtensionType.LoadParser,
@@ -15749,7 +15756,7 @@ const loadWebFont = {
15749
15756
  if (fonts) {
15750
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 : {};
15751
15758
  for (let i2 = 0; i2 < weights.length; i2++) {
15752
- 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), {
15753
15760
  weight
15754
15761
  }));
15755
15762
  await font.load(), fonts.add(font), fontFaces.push(font);
@@ -16248,38 +16255,6 @@ class Resolver {
16248
16255
  assetNames.push(...aliases);
16249
16256
  }), this._bundles[bundleId] = assetNames;
16250
16257
  }
16251
- /**
16252
- * Tells the resolver what keys are associated with witch asset.
16253
- * The most important thing the resolver does
16254
- * @example
16255
- * // Single key, single asset:
16256
- * resolver.add({alias: 'foo', src: 'bar.png');
16257
- * resolver.resolveUrl('foo') // => 'bar.png'
16258
- *
16259
- * // Multiple keys, single asset:
16260
- * resolver.add({alias: ['foo', 'boo'], src: 'bar.png'});
16261
- * resolver.resolveUrl('foo') // => 'bar.png'
16262
- * resolver.resolveUrl('boo') // => 'bar.png'
16263
- *
16264
- * // Multiple keys, multiple assets:
16265
- * resolver.add({alias: ['foo', 'boo'], src: ['bar.png', 'bar.webp']});
16266
- * resolver.resolveUrl('foo') // => 'bar.png'
16267
- *
16268
- * // Add custom data attached to the resolver
16269
- * Resolver.add({
16270
- * alias: 'bunnyBooBooSmooth',
16271
- * src: 'bunny{png,webp}',
16272
- * data: { scaleMode:SCALE_MODES.NEAREST }, // Base texture options
16273
- * });
16274
- *
16275
- * resolver.resolve('bunnyBooBooSmooth') // => { src: 'bunny.png', data: { scaleMode: SCALE_MODES.NEAREST } }
16276
- * @param aliases - the key or keys that you will reference when loading this asset
16277
- * @param srcs - the asset or assets that will be chosen from when loading via the specified key
16278
- * @param data - asset-specific data that will be passed to the loaders
16279
- * - Useful if you want to initiate loaded objects with specific data
16280
- * @param format - the format of the asset
16281
- * @param loadParser - the name of the load parser to use
16282
- */
16283
16258
  add(aliases, srcs, data, format2, loadParser) {
16284
16259
  const assets = [];
16285
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.
@@ -16334,12 +16309,12 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16334
16309
  * name: 'load-screen',
16335
16310
  * assets: [
16336
16311
  * {
16337
- * name: 'background',
16338
- * srcs: 'sunset.png',
16312
+ * alias: 'background',
16313
+ * src: 'sunset.png',
16339
16314
  * },
16340
16315
  * {
16341
- * name: 'bar',
16342
- * srcs: 'load-bar.{png,webp}',
16316
+ * alias: 'bar',
16317
+ * src: 'load-bar.{png,webp}',
16343
16318
  * },
16344
16319
  * ],
16345
16320
  * },
@@ -16347,12 +16322,12 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16347
16322
  * name: 'game-screen',
16348
16323
  * assets: [
16349
16324
  * {
16350
- * name: 'character',
16351
- * srcs: 'robot.png',
16325
+ * alias: 'character',
16326
+ * src: 'robot.png',
16352
16327
  * },
16353
16328
  * {
16354
- * name: 'enemy',
16355
- * srcs: 'bad-guy.png',
16329
+ * alias: 'enemy',
16330
+ * src: 'bad-guy.png',
16356
16331
  * },
16357
16332
  * ],
16358
16333
  * },
@@ -16459,7 +16434,7 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16459
16434
  buildResolvedAsset(formattedAsset, data) {
16460
16435
  var _a2;
16461
16436
  const { aliases, data: assetData, loadParser, format: format2 } = data;
16462
- 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;
16463
16438
  }
16464
16439
  }
16465
16440
  class AssetsClass {
@@ -16495,51 +16470,6 @@ class AssetsClass {
16495
16470
  }
16496
16471
  }), options.preferences && this.setPreferences(options.preferences);
16497
16472
  }
16498
- /**
16499
- * Allows you to specify how to resolve any assets load requests.
16500
- * There are a few ways to add things here as shown below:
16501
- * @example
16502
- * import { Assets } from 'pixi.js';
16503
- *
16504
- * // Simple
16505
- * Assets.add({alias: 'bunnyBooBoo', src: 'bunny.png'});
16506
- * const bunny = await Assets.load('bunnyBooBoo');
16507
- *
16508
- * // Multiple keys:
16509
- * Assets.add({alias: ['burger', 'chicken'], src: 'bunny.png'});
16510
- *
16511
- * const bunny = await Assets.load('burger');
16512
- * const bunny2 = await Assets.load('chicken');
16513
- *
16514
- * // passing options to to the object
16515
- * Assets.add({
16516
- * alias: 'bunnyBooBooSmooth',
16517
- * src: 'bunny{png,webp}',
16518
- * data: { scaleMode: SCALE_MODES.NEAREST }, // Base texture options
16519
- * });
16520
- *
16521
- * // Multiple assets
16522
- *
16523
- * // The following all do the same thing:
16524
- *
16525
- * Assets.add({alias: 'bunnyBooBoo', src: 'bunny{png,webp}'});
16526
- *
16527
- * Assets.add({
16528
- * alias: 'bunnyBooBoo',
16529
- * src: [
16530
- * 'bunny.png',
16531
- * 'bunny.webp',
16532
- * ],
16533
- * });
16534
- *
16535
- * const bunny = await Assets.load('bunnyBooBoo'); // Will try to load WebP if available
16536
- * @param aliases - the key or keys that you will reference when loading this asset
16537
- * @param srcs - the asset or assets that will be chosen from when loading via the specified key
16538
- * @param data - asset-specific data that will be passed to the loaders
16539
- * - Useful if you want to initiate loaded objects with specific data
16540
- * @param format - the format of the asset
16541
- * @param loadParser - the name of the load parser to use
16542
- */
16543
16473
  add(aliases, srcs, data, format2, loadParser) {
16544
16474
  this.resolver.add(aliases, srcs, data, format2, loadParser);
16545
16475
  }
@@ -16587,12 +16517,12 @@ class AssetsClass {
16587
16517
  * name: 'load-screen',
16588
16518
  * assets: [
16589
16519
  * {
16590
- * name: 'background',
16591
- * srcs: 'sunset.png',
16520
+ * alias: 'background',
16521
+ * src: 'sunset.png',
16592
16522
  * },
16593
16523
  * {
16594
- * name: 'bar',
16595
- * srcs: 'load-bar.{png,webp}',
16524
+ * alias: 'bar',
16525
+ * src: 'load-bar.{png,webp}',
16596
16526
  * },
16597
16527
  * ],
16598
16528
  * },
@@ -16600,12 +16530,12 @@ class AssetsClass {
16600
16530
  * name: 'game-screen',
16601
16531
  * assets: [
16602
16532
  * {
16603
- * name: 'character',
16604
- * srcs: 'robot.png',
16533
+ * alias: 'character',
16534
+ * src: 'robot.png',
16605
16535
  * },
16606
16536
  * {
16607
- * name: 'enemy',
16608
- * srcs: 'bad-guy.png',
16537
+ * alias: 'enemy',
16538
+ * src: 'bad-guy.png',
16609
16539
  * },
16610
16540
  * ],
16611
16541
  * },
@@ -16842,22 +16772,36 @@ const cacheTextureArray = {
16842
16772
  }
16843
16773
  };
16844
16774
  extensions$1.add(cacheTextureArray);
16845
- const detectAvif = {
16846
- extension: {
16847
- type: ExtensionType.DetectionParser,
16848
- priority: 1
16849
- },
16850
- test: async () => {
16851
- const avifData = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=";
16775
+ async function testImageFormat(imageData) {
16776
+ if ("Image" in globalThis)
16852
16777
  return new Promise((resolve2) => {
16853
- const avif = new Image();
16854
- avif.onload = () => {
16778
+ const image = new Image();
16779
+ image.onload = () => {
16855
16780
  resolve2(!0);
16856
- }, avif.onerror = () => {
16781
+ }, image.onerror = () => {
16857
16782
  resolve2(!1);
16858
- }, avif.src = avifData;
16783
+ }, image.src = imageData;
16859
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
16860
16800
  },
16801
+ test: async () => testImageFormat(
16802
+ // eslint-disable-next-line max-len
16803
+ "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="
16804
+ ),
16861
16805
  add: async (formats2) => [...formats2, "avif"],
16862
16806
  remove: async (formats2) => formats2.filter((f2) => f2 !== "avif")
16863
16807
  };
@@ -16867,17 +16811,9 @@ const detectWebp = {
16867
16811
  type: ExtensionType.DetectionParser,
16868
16812
  priority: 0
16869
16813
  },
16870
- test: async () => {
16871
- const webpData = "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=";
16872
- return new Promise((resolve2) => {
16873
- const webp = new Image();
16874
- webp.onload = () => {
16875
- resolve2(!0);
16876
- }, webp.onerror = () => {
16877
- resolve2(!1);
16878
- }, webp.src = webpData;
16879
- });
16880
- },
16814
+ test: async () => testImageFormat(
16815
+ "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="
16816
+ ),
16881
16817
  add: async (formats2) => [...formats2, "webp"],
16882
16818
  remove: async (formats2) => formats2.filter((f2) => f2 !== "webp")
16883
16819
  };
@@ -16933,7 +16869,7 @@ const resolveTextureUrl = {
16933
16869
  var _a2, _b;
16934
16870
  return {
16935
16871
  resolution: parseFloat((_b = (_a2 = settings.RETINA_PREFIX.exec(value)) == null ? void 0 : _a2[1]) != null ? _b : "1"),
16936
- format: value.split(".").pop(),
16872
+ format: path.extname(value).slice(1),
16937
16873
  src: value
16938
16874
  };
16939
16875
  }
@@ -17454,12 +17390,13 @@ extensions$1.add(loadKTX);
17454
17390
  const resolveCompressedTextureUrl = {
17455
17391
  extension: ExtensionType.ResolveParser,
17456
17392
  test: (value) => {
17457
- const extension = value.split("?")[0].split(".").pop();
17393
+ const extension = path.extname(value).slice(1);
17458
17394
  return ["basis", "ktx", "dds"].includes(extension);
17459
17395
  },
17460
17396
  parse: (value) => {
17461
17397
  var _a2, _b, _c, _d;
17462
- if (value.split("?")[0].split(".").pop() === "ktx") {
17398
+ const extension = path.extname(value).slice(1);
17399
+ if (extension === "ktx") {
17463
17400
  const extensions2 = [
17464
17401
  ".s3tc.ktx",
17465
17402
  ".s3tc_sRGB.ktx",
@@ -17478,7 +17415,7 @@ const resolveCompressedTextureUrl = {
17478
17415
  }
17479
17416
  return {
17480
17417
  resolution: parseFloat((_d = (_c = settings.RETINA_PREFIX.exec(value)) == null ? void 0 : _c[1]) != null ? _d : "1"),
17481
- format: value.split(".").pop(),
17418
+ format: extension,
17482
17419
  src: value
17483
17420
  };
17484
17421
  }