pixi.js 7.3.0-rc.2 → 7.3.1

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * pixi.js - v7.3.0-rc.2
3
- * Compiled Fri, 11 Aug 2023 16:01:54 UTC
2
+ * pixi.js - v7.3.1
3
+ * Compiled Fri, 22 Sep 2023 18:50:32 UTC
4
4
  *
5
5
  * pixi.js is licensed under the MIT License.
6
6
  * http://www.opensource.org/licenses/mit-license
@@ -1010,7 +1010,7 @@ Deprecated since v${version}`), console.warn(stack))), warnings[message] = !0;
1010
1010
  return replaceAll(path2, "\\", "/");
1011
1011
  },
1012
1012
  /**
1013
- * Checks if the path is a URL
1013
+ * Checks if the path is a URL e.g. http://, https://
1014
1014
  * @param path - The path to check
1015
1015
  */
1016
1016
  isUrl(path2) {
@@ -1024,26 +1024,31 @@ Deprecated since v${version}`), console.warn(stack))), warnings[message] = !0;
1024
1024
  return /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(path2);
1025
1025
  },
1026
1026
  /**
1027
- * Checks if the path has a protocol e.g. http://
1027
+ * Checks if the path is a blob URL
1028
+ * @param path - The path to check
1029
+ */
1030
+ isBlobUrl(path2) {
1031
+ return path2.startsWith("blob:");
1032
+ },
1033
+ /**
1034
+ * Checks if the path has a protocol e.g. http://, https://, file:///, data:, blob:, C:/
1028
1035
  * This will return true for windows file paths
1029
1036
  * @param path - The path to check
1030
1037
  */
1031
1038
  hasProtocol(path2) {
1032
- return /^[^/:]+:\//.test(this.toPosix(path2));
1039
+ return /^[^/:]+:/.test(this.toPosix(path2));
1033
1040
  },
1034
1041
  /**
1035
- * Returns the protocol of the path e.g. http://, C:/, file:///
1042
+ * Returns the protocol of the path e.g. http://, https://, file:///, data:, blob:, C:/
1036
1043
  * @param path - The path to get the protocol from
1037
1044
  */
1038
1045
  getProtocol(path2) {
1039
1046
  assertPath(path2), path2 = this.toPosix(path2);
1040
- let protocol = "";
1041
- const isFile = /^file:\/\/\//.exec(path2), isHttp = /^[^/:]+:\/\//.exec(path2), isWindows = /^[^/:]+:\//.exec(path2);
1042
- if (isFile || isHttp || isWindows) {
1043
- const arr = (isFile == null ? void 0 : isFile[0]) || (isHttp == null ? void 0 : isHttp[0]) || (isWindows == null ? void 0 : isWindows[0]);
1044
- protocol = arr, path2 = path2.slice(arr.length);
1045
- }
1046
- return protocol;
1047
+ const matchFile = /^file:\/\/\//.exec(path2);
1048
+ if (matchFile)
1049
+ return matchFile[0];
1050
+ const matchProtocol = /^[^/:]+:\/{0,2}/.exec(path2);
1051
+ return matchProtocol ? matchProtocol[0] : "";
1047
1052
  },
1048
1053
  /**
1049
1054
  * Converts URL to an absolute path.
@@ -1055,18 +1060,21 @@ Deprecated since v${version}`), console.warn(stack))), warnings[message] = !0;
1055
1060
  * @param customRootUrl - The root URL to use
1056
1061
  */
1057
1062
  toAbsolute(url2, customBaseUrl, customRootUrl) {
1058
- if (this.isDataUrl(url2))
1063
+ if (assertPath(url2), this.isDataUrl(url2) || this.isBlobUrl(url2))
1059
1064
  return url2;
1060
1065
  const baseUrl = removeUrlParams(this.toPosix(customBaseUrl != null ? customBaseUrl : settings.ADAPTER.getBaseUrl())), rootUrl = removeUrlParams(this.toPosix(customRootUrl != null ? customRootUrl : this.rootname(baseUrl)));
1061
- return assertPath(url2), url2 = this.toPosix(url2), url2.startsWith("/") ? path.join(rootUrl, url2.slice(1)) : this.isAbsolute(url2) ? url2 : this.join(baseUrl, url2);
1066
+ return url2 = this.toPosix(url2), url2.startsWith("/") ? path.join(rootUrl, url2.slice(1)) : this.isAbsolute(url2) ? url2 : this.join(baseUrl, url2);
1062
1067
  },
1063
1068
  /**
1064
1069
  * Normalizes the given path, resolving '..' and '.' segments
1065
1070
  * @param path - The path to normalize
1066
1071
  */
1067
1072
  normalize(path2) {
1068
- if (path2 = this.toPosix(path2), assertPath(path2), path2.length === 0)
1073
+ if (assertPath(path2), path2.length === 0)
1069
1074
  return ".";
1075
+ if (this.isDataUrl(path2) || this.isBlobUrl(path2))
1076
+ return path2;
1077
+ path2 = this.toPosix(path2);
1070
1078
  let protocol = "";
1071
1079
  const isAbsolute = path2.startsWith("/");
1072
1080
  this.hasProtocol(path2) && (protocol = this.rootname(path2), path2 = path2.slice(protocol.length));
@@ -2772,7 +2780,7 @@ else `), i2 < maxIfs - 1 && (src += `if(test == ${i2}.0){}`);
2772
2780
  * @fires PIXI.BaseTexture#destroyed
2773
2781
  */
2774
2782
  destroy() {
2775
- this.resource && (this.resource.unbind(this), this.resource.internal && this.resource.destroy(), this.resource = null), this.cacheId && (delete BaseTextureCache[this.cacheId], delete TextureCache[this.cacheId], this.cacheId = null), this.valid = !1, this.dispose(), _BaseTexture2.removeFromCache(this), this.textureCacheIds = null, this.destroyed = !0, this.emit("destroyed", this);
2783
+ this.resource && (this.resource.unbind(this), this.resource.internal && this.resource.destroy(), this.resource = null), this.cacheId && (delete BaseTextureCache[this.cacheId], delete TextureCache[this.cacheId], this.cacheId = null), this.valid = !1, this.dispose(), _BaseTexture2.removeFromCache(this), this.textureCacheIds = null, this.destroyed = !0, this.emit("destroyed", this), this.removeAllListeners();
2776
2784
  }
2777
2785
  /**
2778
2786
  * Frees the texture from WebGL memory without destroying this texture object.
@@ -6005,7 +6013,7 @@ void main(void)
6005
6013
  * @param borders - Default borders used for 9-slice scaling. See {@link PIXI.NineSlicePlane}
6006
6014
  */
6007
6015
  constructor(baseTexture, frame, orig, trim, rotate, anchor, borders) {
6008
- if (super(), this.noFrame = !1, frame || (this.noFrame = !0, frame = new Rectangle(0, 0, 1, 1)), baseTexture instanceof Texture && (baseTexture = baseTexture.baseTexture), this.baseTexture = baseTexture, this._frame = frame, this.trim = trim, this.valid = !1, this._uvs = DEFAULT_UVS, this.uvMatrix = null, this.orig = orig || frame, this._rotate = Number(rotate || 0), rotate === !0)
6016
+ if (super(), this.noFrame = !1, frame || (this.noFrame = !0, frame = new Rectangle(0, 0, 1, 1)), baseTexture instanceof Texture && (baseTexture = baseTexture.baseTexture), this.baseTexture = baseTexture, this._frame = frame, this.trim = trim, this.valid = !1, this.destroyed = !1, this._uvs = DEFAULT_UVS, this.uvMatrix = null, this.orig = orig || frame, this._rotate = Number(rotate || 0), rotate === !0)
6009
6017
  this._rotate = 2;
6010
6018
  else if (this._rotate % 2 !== 0)
6011
6019
  throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");
@@ -6038,6 +6046,7 @@ void main(void)
6038
6046
  /**
6039
6047
  * Destroys this texture
6040
6048
  * @param [destroyBase=false] - Whether to destroy the base texture as well
6049
+ * @fires PIXI.Texture#destroyed
6041
6050
  */
6042
6051
  destroy(destroyBase) {
6043
6052
  if (this.baseTexture) {
@@ -6047,7 +6056,7 @@ void main(void)
6047
6056
  }
6048
6057
  this.baseTexture.off("loaded", this.onBaseTextureUpdated, this), this.baseTexture.off("update", this.onBaseTextureUpdated, this), this.baseTexture = null;
6049
6058
  }
6050
- this._frame = null, this._uvs = null, this.trim = null, this.orig = null, this.valid = !1, Texture.removeFromCache(this), this.textureCacheIds = null;
6059
+ this._frame = null, this._uvs = null, this.trim = null, this.orig = null, this.valid = !1, Texture.removeFromCache(this), this.textureCacheIds = null, this.destroyed = !0, this.emit("destroyed", this), this.removeAllListeners();
6051
6060
  }
6052
6061
  /**
6053
6062
  * Creates a new texture object that acts the same as this one.
@@ -8283,7 +8292,7 @@ void main(void)
8283
8292
  */
8284
8293
  run(options) {
8285
8294
  const { renderer } = this;
8286
- renderer.runners.init.emit(renderer.options), options.hello && console.log(`PixiJS 7.3.0-rc.2 - ${renderer.rendererLogId} - https://pixijs.com`), renderer.resize(renderer.screen.width, renderer.screen.height);
8295
+ 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);
8287
8296
  }
8288
8297
  destroy() {
8289
8298
  }
@@ -10753,7 +10762,7 @@ void main(void)
10753
10762
  this.disposeRunner.emit(this, !1);
10754
10763
  }
10755
10764
  }
10756
- const VERSION = "7.3.0-rc.2";
10765
+ const VERSION = "7.3.1";
10757
10766
  class Bounds {
10758
10767
  constructor() {
10759
10768
  this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0, this.rect = null, this.updateID = -1;
@@ -11022,9 +11031,10 @@ void main(void)
11022
11031
  * @returns - The rectangular bounding area.
11023
11032
  */
11024
11033
  getLocalBounds(rect) {
11034
+ var _a2;
11025
11035
  rect || (this._localBoundsRect || (this._localBoundsRect = new Rectangle()), rect = this._localBoundsRect), this._localBounds || (this._localBounds = new Bounds());
11026
11036
  const transformRef = this.transform, parentRef = this.parent;
11027
- this.parent = null, this.transform = this._tempDisplayObjectParent.transform;
11037
+ this.parent = null, this._tempDisplayObjectParent.worldAlpha = (_a2 = parentRef == null ? void 0 : parentRef.worldAlpha) != null ? _a2 : 1, this.transform = this._tempDisplayObjectParent.transform;
11028
11038
  const worldBounds = this._bounds, worldBoundsID = this._boundsID;
11029
11039
  this._bounds = this._localBounds;
11030
11040
  const bounds = this.getBounds(!1, rect);
@@ -11674,7 +11684,11 @@ void main(void)
11674
11684
  return;
11675
11685
  this._transformTrimmedID = this.transform._worldID, this._textureTrimmedID = this._texture._updateID;
11676
11686
  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;
11677
- 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;
11687
+ 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) {
11688
+ const resolution = settings.RESOLUTION;
11689
+ for (let i2 = 0; i2 < vertexData.length; ++i2)
11690
+ vertexData[i2] = Math.round(vertexData[i2] * resolution) / resolution;
11691
+ }
11678
11692
  }
11679
11693
  /**
11680
11694
  *
@@ -11747,7 +11761,7 @@ void main(void)
11747
11761
  * @default false
11748
11762
  */
11749
11763
  set roundPixels(value) {
11750
- this._roundPixels !== value && (this._transformID = -1), this._roundPixels = value;
11764
+ this._roundPixels !== value && (this._transformID = -1, this._transformTrimmedID = -1), this._roundPixels = value;
11751
11765
  }
11752
11766
  get roundPixels() {
11753
11767
  return this._roundPixels;
@@ -14313,8 +14327,9 @@ void main()
14313
14327
  * @param nativeEvent - The native mouse/pointer/touch event.
14314
14328
  */
14315
14329
  onPointerDown(nativeEvent) {
14316
- if (!this.features.click || (this.rootBoundary.rootTarget = this.renderer.lastObjectRendered, this.supportsTouchEvents && nativeEvent.pointerType === "touch"))
14330
+ if (!this.features.click)
14317
14331
  return;
14332
+ this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
14318
14333
  const events = this.normalizeToPointerData(nativeEvent);
14319
14334
  this.autoPreventDefault && events[0].isNormalized && (nativeEvent.cancelable || !("cancelable" in nativeEvent)) && nativeEvent.preventDefault();
14320
14335
  for (let i2 = 0, j2 = events.length; i2 < j2; i2++) {
@@ -14328,9 +14343,9 @@ void main()
14328
14343
  * @param nativeEvent - The native mouse/pointer/touch events.
14329
14344
  */
14330
14345
  onPointerMove(nativeEvent) {
14331
- if (!this.features.move || (this.rootBoundary.rootTarget = this.renderer.lastObjectRendered, this.supportsTouchEvents && nativeEvent.pointerType === "touch"))
14346
+ if (!this.features.move)
14332
14347
  return;
14333
- EventsTicker.pointerMoved();
14348
+ this.rootBoundary.rootTarget = this.renderer.lastObjectRendered, EventsTicker.pointerMoved();
14334
14349
  const normalizedEvents = this.normalizeToPointerData(nativeEvent);
14335
14350
  for (let i2 = 0, j2 = normalizedEvents.length; i2 < j2; i2++) {
14336
14351
  const event = this.bootstrapEvent(this.rootPointerEvent, normalizedEvents[i2]);
@@ -14343,8 +14358,9 @@ void main()
14343
14358
  * @param nativeEvent - The native mouse/pointer/touch event.
14344
14359
  */
14345
14360
  onPointerUp(nativeEvent) {
14346
- if (!this.features.click || (this.rootBoundary.rootTarget = this.renderer.lastObjectRendered, this.supportsTouchEvents && nativeEvent.pointerType === "touch"))
14361
+ if (!this.features.click)
14347
14362
  return;
14363
+ this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
14348
14364
  let target = nativeEvent.target;
14349
14365
  nativeEvent.composedPath && nativeEvent.composedPath().length > 0 && (target = nativeEvent.composedPath()[0]);
14350
14366
  const outside = target !== this.domElement ? "outside" : "", normalizedEvents = this.normalizeToPointerData(nativeEvent);
@@ -14359,8 +14375,9 @@ void main()
14359
14375
  * @param nativeEvent - The native mouse/pointer/touch event.
14360
14376
  */
14361
14377
  onPointerOverOut(nativeEvent) {
14362
- if (!this.features.click || (this.rootBoundary.rootTarget = this.renderer.lastObjectRendered, this.supportsTouchEvents && nativeEvent.pointerType === "touch"))
14378
+ if (!this.features.click)
14363
14379
  return;
14380
+ this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
14364
14381
  const normalizedEvents = this.normalizeToPointerData(nativeEvent);
14365
14382
  for (let i2 = 0, j2 = normalizedEvents.length; i2 < j2; i2++) {
14366
14383
  const event = this.bootstrapEvent(this.rootPointerEvent, normalizedEvents[i2]);
@@ -14393,7 +14410,7 @@ void main()
14393
14410
  return;
14394
14411
  EventsTicker.addTickerListener();
14395
14412
  const style = this.domElement.style;
14396
- style && (globalThis.navigator.msPointerEnabled ? (style.msContentZooming = "none", style.msTouchAction = "none") : this.supportsPointerEvents && (style.touchAction = "none")), this.supportsPointerEvents ? (globalThis.document.addEventListener("pointermove", this.onPointerMove, !0), this.domElement.addEventListener("pointerdown", this.onPointerDown, !0), this.domElement.addEventListener("pointerleave", this.onPointerOverOut, !0), this.domElement.addEventListener("pointerover", this.onPointerOverOut, !0), globalThis.addEventListener("pointerup", this.onPointerUp, !0)) : (globalThis.document.addEventListener("mousemove", this.onPointerMove, !0), this.domElement.addEventListener("mousedown", this.onPointerDown, !0), this.domElement.addEventListener("mouseout", this.onPointerOverOut, !0), this.domElement.addEventListener("mouseover", this.onPointerOverOut, !0), globalThis.addEventListener("mouseup", this.onPointerUp, !0)), this.supportsTouchEvents && (this.domElement.addEventListener("touchstart", this.onPointerDown, !0), this.domElement.addEventListener("touchend", this.onPointerUp, !0), this.domElement.addEventListener("touchmove", this.onPointerMove, !0)), this.domElement.addEventListener("wheel", this.onWheel, {
14413
+ style && (globalThis.navigator.msPointerEnabled ? (style.msContentZooming = "none", style.msTouchAction = "none") : this.supportsPointerEvents && (style.touchAction = "none")), this.supportsPointerEvents ? (globalThis.document.addEventListener("pointermove", this.onPointerMove, !0), this.domElement.addEventListener("pointerdown", this.onPointerDown, !0), this.domElement.addEventListener("pointerleave", this.onPointerOverOut, !0), this.domElement.addEventListener("pointerover", this.onPointerOverOut, !0), globalThis.addEventListener("pointerup", this.onPointerUp, !0)) : (globalThis.document.addEventListener("mousemove", this.onPointerMove, !0), this.domElement.addEventListener("mousedown", this.onPointerDown, !0), this.domElement.addEventListener("mouseout", this.onPointerOverOut, !0), this.domElement.addEventListener("mouseover", this.onPointerOverOut, !0), globalThis.addEventListener("mouseup", this.onPointerUp, !0), this.supportsTouchEvents && (this.domElement.addEventListener("touchstart", this.onPointerDown, !0), this.domElement.addEventListener("touchend", this.onPointerUp, !0), this.domElement.addEventListener("touchmove", this.onPointerMove, !0))), this.domElement.addEventListener("wheel", this.onWheel, {
14397
14414
  passive: !0,
14398
14415
  capture: !0
14399
14416
  }), this.eventsAdded = !0;
@@ -14404,7 +14421,7 @@ void main()
14404
14421
  return;
14405
14422
  EventsTicker.removeTickerListener();
14406
14423
  const style = this.domElement.style;
14407
- globalThis.navigator.msPointerEnabled ? (style.msContentZooming = "", style.msTouchAction = "") : this.supportsPointerEvents && (style.touchAction = ""), this.supportsPointerEvents ? (globalThis.document.removeEventListener("pointermove", this.onPointerMove, !0), this.domElement.removeEventListener("pointerdown", this.onPointerDown, !0), this.domElement.removeEventListener("pointerleave", this.onPointerOverOut, !0), this.domElement.removeEventListener("pointerover", this.onPointerOverOut, !0), globalThis.removeEventListener("pointerup", this.onPointerUp, !0)) : (globalThis.document.removeEventListener("mousemove", this.onPointerMove, !0), this.domElement.removeEventListener("mousedown", this.onPointerDown, !0), this.domElement.removeEventListener("mouseout", this.onPointerOverOut, !0), this.domElement.removeEventListener("mouseover", this.onPointerOverOut, !0), globalThis.removeEventListener("mouseup", this.onPointerUp, !0)), this.supportsTouchEvents && (this.domElement.removeEventListener("touchstart", this.onPointerDown, !0), this.domElement.removeEventListener("touchend", this.onPointerUp, !0), this.domElement.removeEventListener("touchmove", this.onPointerMove, !0)), this.domElement.removeEventListener("wheel", this.onWheel, !0), this.domElement = null, this.eventsAdded = !1;
14424
+ globalThis.navigator.msPointerEnabled ? (style.msContentZooming = "", style.msTouchAction = "") : this.supportsPointerEvents && (style.touchAction = ""), this.supportsPointerEvents ? (globalThis.document.removeEventListener("pointermove", this.onPointerMove, !0), this.domElement.removeEventListener("pointerdown", this.onPointerDown, !0), this.domElement.removeEventListener("pointerleave", this.onPointerOverOut, !0), this.domElement.removeEventListener("pointerover", this.onPointerOverOut, !0), globalThis.removeEventListener("pointerup", this.onPointerUp, !0)) : (globalThis.document.removeEventListener("mousemove", this.onPointerMove, !0), this.domElement.removeEventListener("mousedown", this.onPointerDown, !0), this.domElement.removeEventListener("mouseout", this.onPointerOverOut, !0), this.domElement.removeEventListener("mouseover", this.onPointerOverOut, !0), globalThis.removeEventListener("mouseup", this.onPointerUp, !0), this.supportsTouchEvents && (this.domElement.removeEventListener("touchstart", this.onPointerDown, !0), this.domElement.removeEventListener("touchend", this.onPointerUp, !0), this.domElement.removeEventListener("touchmove", this.onPointerMove, !0))), this.domElement.removeEventListener("wheel", this.onWheel, !0), this.domElement = null, this.eventsAdded = !1;
14408
14425
  }
14409
14426
  /**
14410
14427
  * Maps x and y coords from a DOM object and maps them correctly to the PixiJS view. The
@@ -14853,12 +14870,12 @@ void main()
14853
14870
  _internalEventMode: void 0,
14854
14871
  /**
14855
14872
  * Enable interaction events for the DisplayObject. Touch, pointer and mouse.
14856
- * This now replaces the `interactive` property
14857
- * There is 5 types of interaction settings:
14873
+ * This now replaces the `interactive` property.
14874
+ * There are 5 types of interaction settings:
14858
14875
  * - `'none'`: Ignores all interaction events, even on its children.
14859
14876
  * - `'passive'`: Does not emit events and ignores all hit testing on itself and non-interactive children.
14860
14877
  * Interactive children will still emit events.
14861
- * - `'auto'`: Does not emit events and but is hit tested if parent is interactive. Same as `interactive = false` in v7
14878
+ * - `'auto'`: Does not emit events but is hit tested if parent is interactive. Same as `interactive = false` in v7
14862
14879
  * - `'static'`: Emit events and is hit tested. Same as `interaction = true` in v7
14863
14880
  * - `'dynamic'`: Emits events and is hit tested but will also receive mock interaction events fired from a ticker to
14864
14881
  * allow for interaction when the mouse isn't moving
@@ -15436,7 +15453,7 @@ void main()
15436
15453
  const tempURL = url2.split("?")[0], ext = path.extname(tempURL).toLowerCase();
15437
15454
  return Array.isArray(extension) ? extension.includes(ext) : ext === extension;
15438
15455
  }
15439
- const convertToList = (input, transform) => (Array.isArray(input) || (input = [input]), transform ? input.map((item) => typeof item == "string" ? transform(item) : item) : input), copySearchParams = (targetUrl, sourceUrl) => {
15456
+ 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) => {
15440
15457
  const searchParams = sourceUrl.split("?")[1];
15441
15458
  return searchParams && (targetUrl += `?${searchParams}`), targetUrl;
15442
15459
  };
@@ -15630,7 +15647,7 @@ ${e2}`);
15630
15647
  const url2 = path.toAbsolute(asset.src), loadPromise = this.promiseCache[url2];
15631
15648
  if (loadPromise) {
15632
15649
  const loadedAsset = await loadPromise.promise;
15633
- (_b = (_a2 = loadPromise.parser) == null ? void 0 : _a2.unload) == null || _b.call(_a2, loadedAsset, asset, this), delete this.promiseCache[url2];
15650
+ delete this.promiseCache[url2], (_b = (_a2 = loadPromise.parser) == null ? void 0 : _a2.unload) == null || _b.call(_a2, loadedAsset, asset, this);
15634
15651
  }
15635
15652
  });
15636
15653
  await Promise.all(promises);
@@ -15857,9 +15874,13 @@ ${e2}`);
15857
15874
  const WorkerManager = new WorkerManagerClass();
15858
15875
  function createTexture(base, loader, url2) {
15859
15876
  base.resource.internal = !0;
15860
- const texture = new Texture(base);
15861
- return texture.baseTexture.once("destroyed", () => {
15877
+ const texture = new Texture(base), unload = () => {
15862
15878
  delete loader.promiseCache[url2], Cache.has(url2) && Cache.remove(url2);
15879
+ };
15880
+ return texture.baseTexture.once("destroyed", () => {
15881
+ url2 in loader.promiseCache && (console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."), unload());
15882
+ }), texture.once("destroyed", () => {
15883
+ base.destroyed || (console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."), unload());
15863
15884
  }), texture;
15864
15885
  }
15865
15886
  var __defProp$7 = Object.defineProperty, __getOwnPropSymbols$7 = Object.getOwnPropertySymbols, __hasOwnProp$7 = Object.prototype.hasOwnProperty, __propIsEnum$7 = Object.prototype.propertyIsEnumerable, __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$7 = (a2, b2) => {
@@ -16134,6 +16155,24 @@ ${e2}`);
16134
16155
  this._defaultSearchParams = Object.keys(queryValues).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(queryValues[key])}`).join("&");
16135
16156
  }
16136
16157
  }
16158
+ /**
16159
+ * Returns the aliases for a given asset
16160
+ * @param asset - the asset to get the aliases for
16161
+ */
16162
+ getAlias(asset) {
16163
+ const { alias, name, src, srcs } = asset;
16164
+ return convertToList(
16165
+ alias || name || src || srcs,
16166
+ (value) => {
16167
+ var _a2;
16168
+ return typeof value == "string" ? value : Array.isArray(value) ? value.map((v2) => {
16169
+ var _a22, _b;
16170
+ return (_b = (_a22 = v2 == null ? void 0 : v2.src) != null ? _a22 : v2 == null ? void 0 : v2.srcs) != null ? _b : v2;
16171
+ }) : value != null && value.src || value != null && value.srcs ? (_a2 = value.src) != null ? _a2 : value.srcs : value;
16172
+ },
16173
+ !0
16174
+ );
16175
+ }
16137
16176
  /**
16138
16177
  * Add a manifest to the asset resolver. This is a nice way to add all the asset information in one go.
16139
16178
  * generally a manifest would be built using a tool.
@@ -16238,10 +16277,10 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16238
16277
  keyCheck = (key) => {
16239
16278
  this.hasKey(key) && console.warn(`[Resolver] already has key: ${key} overwriting`);
16240
16279
  }, convertToList(assets).forEach((asset) => {
16241
- const { alias, name, src, srcs: srcs2 } = asset;
16280
+ const { src, srcs: srcs2 } = asset;
16242
16281
  let { data: data2, format: format22, loadParser: loadParser2 } = asset;
16243
- const srcsToUse = convertToList(src || srcs2).map((src2) => typeof src2 == "string" ? createStringVariations(src2) : Array.isArray(src2) ? src2 : [src2]), aliasesToUse = convertToList(alias || name);
16244
- Array.isArray(alias) ? alias.forEach(keyCheck) : keyCheck(alias);
16282
+ const srcsToUse = convertToList(src || srcs2).map((src2) => typeof src2 == "string" ? createStringVariations(src2) : Array.isArray(src2) ? src2 : [src2]), aliasesToUse = this.getAlias(asset);
16283
+ Array.isArray(aliasesToUse) ? aliasesToUse.forEach(keyCheck) : keyCheck(aliasesToUse);
16245
16284
  const resolvedAssets = [];
16246
16285
  srcsToUse.forEach((srcs3) => {
16247
16286
  srcs3.forEach((src2) => {
@@ -16258,6 +16297,8 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16258
16297
  }
16259
16298
  } else
16260
16299
  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);
16300
+ if (!aliasesToUse)
16301
+ throw new Error(`[Resolver] alias is undefined for this asset: ${formattedAsset.src}`);
16261
16302
  formattedAsset = this.buildResolvedAsset(formattedAsset, {
16262
16303
  aliases: aliasesToUse,
16263
16304
  data: data2,
@@ -16265,8 +16306,8 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16265
16306
  loadParser: loadParser2
16266
16307
  }), resolvedAssets.push(formattedAsset);
16267
16308
  });
16268
- }), aliasesToUse.forEach((alias2) => {
16269
- this._assetMap[alias2] = resolvedAssets;
16309
+ }), aliasesToUse.forEach((alias) => {
16310
+ this._assetMap[alias] = resolvedAssets;
16270
16311
  });
16271
16312
  });
16272
16313
  }
@@ -16495,9 +16536,8 @@ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), asse
16495
16536
  this._initialized || await this.init();
16496
16537
  const singleAsset = isSingleItem(urls), urlArray = convertToList(urls).map((url2) => {
16497
16538
  if (typeof url2 != "string") {
16498
- this.add(url2);
16499
- const srcs = url2.src || url2.srcs, aliases = url2.alias || url2.name;
16500
- return aliases && Array.isArray(aliases) ? aliases[0] : srcs && Array.isArray(srcs) ? srcs[0] : aliases || srcs;
16539
+ const aliases = this.resolver.getAlias(url2);
16540
+ return aliases.some((alias) => !this.resolver.hasKey(alias)) && this.add(url2), Array.isArray(aliases) ? aliases[0] : aliases;
16501
16541
  }
16502
16542
  return this.resolver.hasKey(url2) || this.add({ alias: url2, src: url2 }), url2;
16503
16543
  }), resolveResults = this.resolver.resolve(urlArray), out = await this._mapLoadToResolve(resolveResults, onProgress);
@@ -22183,7 +22223,7 @@ void main(void)
22183
22223
  */
22184
22224
  static test(data) {
22185
22225
  const xml = data;
22186
- return "getElementsByTagName" in xml && xml.getElementsByTagName("page").length && xml.getElementsByTagName("info")[0].getAttribute("face") !== null;
22226
+ return typeof data != "string" && "getElementsByTagName" in data && xml.getElementsByTagName("page").length && xml.getElementsByTagName("info")[0].getAttribute("face") !== null;
22187
22227
  }
22188
22228
  /**
22189
22229
  * Convert the XML into BitmapFontData that we can use.