pixi.js 7.0.4 → 7.0.5

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.0.4
3
- * Compiled Fri, 11 Nov 2022 12:31:03 UTC
2
+ * pixi.js - v7.0.5
3
+ * Compiled Mon, 12 Dec 2022 15:56:40 UTC
4
4
  *
5
5
  * pixi.js is licensed under the MIT License.
6
6
  * http://www.opensource.org/licenses/mit-license
@@ -211,7 +211,11 @@ var PIXI = (function (exports) {
211
211
  getNavigator: () => navigator,
212
212
  getBaseUrl: () => document.baseURI ?? window.location.href,
213
213
  getFontFaceSet: () => document.fonts,
214
- fetch: (url, options) => fetch(url, options)
214
+ fetch: (url, options) => fetch(url, options),
215
+ parseXML: (xml) => {
216
+ const parser = new DOMParser();
217
+ return parser.parseFromString(xml, "text/xml");
218
+ }
215
219
  };
216
220
 
217
221
  var appleIphone = /iPhone/i;
@@ -385,7 +389,7 @@ var PIXI = (function (exports) {
385
389
  autoDensity: false,
386
390
  backgroundColor: 0,
387
391
  backgroundAlpha: 1,
388
- useContextAlpha: true,
392
+ premultipliedAlpha: true,
389
393
  clearBeforeRender: true,
390
394
  preserveDrawingBuffer: false,
391
395
  width: 800,
@@ -424,6 +428,9 @@ var PIXI = (function (exports) {
424
428
  })(ExtensionType || {});
425
429
  const normalizeExtension = (ext) => {
426
430
  if (typeof ext === "function" || typeof ext === "object" && ext.extension) {
431
+ if (!ext.extension) {
432
+ throw new Error("Extension class must have an extension object");
433
+ }
427
434
  const metadata = typeof ext.extension !== "object" ? { type: ext.extension } : ext.extension;
428
435
  ext = { ...metadata, ref: ext };
429
436
  }
@@ -437,6 +444,7 @@ var PIXI = (function (exports) {
437
444
  }
438
445
  return ext;
439
446
  };
447
+ const normalizePriority = (ext, defaultPriority) => normalizeExtension(ext).priority ?? defaultPriority;
440
448
  const extensions$1 = {
441
449
  _addHandlers: {},
442
450
  _removeHandlers: {},
@@ -465,6 +473,9 @@ var PIXI = (function (exports) {
465
473
  handle(type, onAdd, onRemove) {
466
474
  const addHandlers = this._addHandlers;
467
475
  const removeHandlers = this._removeHandlers;
476
+ if (addHandlers[type] || removeHandlers[type]) {
477
+ throw new Error(`Extension type ${type} already has a handler`);
478
+ }
468
479
  addHandlers[type] = onAdd;
469
480
  removeHandlers[type] = onRemove;
470
481
  const queue = this._queue;
@@ -481,13 +492,13 @@ var PIXI = (function (exports) {
481
492
  delete map[extension.name];
482
493
  });
483
494
  },
484
- handleByList(type, list) {
495
+ handleByList(type, list, defaultPriority = -1) {
485
496
  return this.handle(type, (extension) => {
486
497
  if (list.includes(extension.ref)) {
487
498
  return;
488
499
  }
489
500
  list.push(extension.ref);
490
- list.sort((a, b) => (b.priority ?? -1) - (a.priority ?? -1));
501
+ list.sort((a, b) => normalizePriority(b, defaultPriority) - normalizePriority(a, defaultPriority));
491
502
  }, (extension) => {
492
503
  const index = list.indexOf(extension.ref);
493
504
  if (index !== -1) {
@@ -535,6 +546,9 @@ var PIXI = (function (exports) {
535
546
  this.y = y;
536
547
  return this;
537
548
  }
549
+ toString() {
550
+ return `[@pixi/math:Point x=${this.x} y=${this.y}]`;
551
+ }
538
552
  }
539
553
 
540
554
  const tempPoints$1 = [new Point(), new Point(), new Point(), new Point()];
@@ -683,6 +697,9 @@ var PIXI = (function (exports) {
683
697
  this.height = y2 - y1;
684
698
  return this;
685
699
  }
700
+ toString() {
701
+ return `[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`;
702
+ }
686
703
  }
687
704
 
688
705
  class Circle {
@@ -709,6 +726,9 @@ var PIXI = (function (exports) {
709
726
  getBounds() {
710
727
  return new Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2);
711
728
  }
729
+ toString() {
730
+ return `[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`;
731
+ }
712
732
  }
713
733
 
714
734
  class Ellipse {
@@ -735,6 +755,9 @@ var PIXI = (function (exports) {
735
755
  getBounds() {
736
756
  return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);
737
757
  }
758
+ toString() {
759
+ return `[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`;
760
+ }
738
761
  }
739
762
 
740
763
  class Polygon {
@@ -772,6 +795,9 @@ var PIXI = (function (exports) {
772
795
  }
773
796
  return inside;
774
797
  }
798
+ toString() {
799
+ return `[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((pointsDesc, currentPoint) => `${pointsDesc}, ${currentPoint}`, "")}]`;
800
+ }
775
801
  }
776
802
 
777
803
  class RoundedRectangle {
@@ -818,6 +844,9 @@ var PIXI = (function (exports) {
818
844
  }
819
845
  return false;
820
846
  }
847
+ toString() {
848
+ return `[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`;
849
+ }
821
850
  }
822
851
 
823
852
  class ObservablePoint {
@@ -853,6 +882,9 @@ var PIXI = (function (exports) {
853
882
  equals(p) {
854
883
  return p.x === this._x && p.y === this._y;
855
884
  }
885
+ toString() {
886
+ return `[@pixi/math:ObservablePoint x=${0} y=${0} scope=${this.scope}]`;
887
+ }
856
888
  get x() {
857
889
  return this._x;
858
890
  }
@@ -1084,6 +1116,9 @@ var PIXI = (function (exports) {
1084
1116
  this.ty = matrix.ty;
1085
1117
  return this;
1086
1118
  }
1119
+ toString() {
1120
+ return `[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`;
1121
+ }
1087
1122
  static get IDENTITY() {
1088
1123
  return new Matrix();
1089
1124
  }
@@ -1207,6 +1242,9 @@ var PIXI = (function (exports) {
1207
1242
  this._sy = Math.cos(this._rotation - this.skew.x);
1208
1243
  this._localID++;
1209
1244
  }
1245
+ toString() {
1246
+ return `[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`;
1247
+ }
1210
1248
  updateLocalTransform() {
1211
1249
  const lt = this.localTransform;
1212
1250
  if (this._localID !== this._currentLocalID) {
@@ -4533,9 +4571,36 @@ var PIXI = (function (exports) {
4533
4571
  settings.RETINA_PREFIX = /@([0-9\.]+)x/;
4534
4572
  settings.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT = false;
4535
4573
 
4574
+ const warnings = {};
4575
+ function deprecation(version, message, ignoreDepth = 3) {
4576
+ if (warnings[message]) {
4577
+ return;
4578
+ }
4579
+ let stack = new Error().stack;
4580
+ if (typeof stack === "undefined") {
4581
+ console.warn("PixiJS Deprecation Warning: ", `${message}
4582
+ Deprecated since v${version}`);
4583
+ } else {
4584
+ stack = stack.split("\n").splice(ignoreDepth).join("\n");
4585
+ if (console.groupCollapsed) {
4586
+ console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s", "color:#614108;background:#fffbe6", "font-weight:normal;color:#614108;background:#fffbe6", `${message}
4587
+ Deprecated since v${version}`);
4588
+ console.warn(stack);
4589
+ console.groupEnd();
4590
+ } else {
4591
+ console.warn("PixiJS Deprecation Warning: ", `${message}
4592
+ Deprecated since v${version}`);
4593
+ console.warn(stack);
4594
+ }
4595
+ }
4596
+ warnings[message] = true;
4597
+ }
4598
+
4536
4599
  function skipHello() {
4600
+ deprecation("7.0.0", "skipHello is deprecated, please use PIXI.settings.RENDER_OPTIONS.hello");
4537
4601
  }
4538
4602
  function sayHello() {
4603
+ deprecation("7.0.0", `sayHello is deprecated, please use Renderer's "hello" option`);
4539
4604
  }
4540
4605
 
4541
4606
  let supported;
@@ -5081,31 +5146,6 @@ var PIXI = (function (exports) {
5081
5146
  return ++nextUid;
5082
5147
  }
5083
5148
 
5084
- const warnings = {};
5085
- function deprecation(version, message, ignoreDepth = 3) {
5086
- if (warnings[message]) {
5087
- return;
5088
- }
5089
- let stack = new Error().stack;
5090
- if (typeof stack === "undefined") {
5091
- console.warn("PixiJS Deprecation Warning: ", `${message}
5092
- Deprecated since v${version}`);
5093
- } else {
5094
- stack = stack.split("\n").splice(ignoreDepth).join("\n");
5095
- if (console.groupCollapsed) {
5096
- console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s", "color:#614108;background:#fffbe6", "font-weight:normal;color:#614108;background:#fffbe6", `${message}
5097
- Deprecated since v${version}`);
5098
- console.warn(stack);
5099
- console.groupEnd();
5100
- } else {
5101
- console.warn("PixiJS Deprecation Warning: ", `${message}
5102
- Deprecated since v${version}`);
5103
- console.warn(stack);
5104
- }
5105
- }
5106
- warnings[message] = true;
5107
- }
5108
-
5109
5149
  const ProgramCache = {};
5110
5150
  const TextureCache = /* @__PURE__ */ Object.create(null);
5111
5151
  const BaseTextureCache = /* @__PURE__ */ Object.create(null);
@@ -5161,58 +5201,49 @@ Deprecated since v${version}`);
5161
5201
  }
5162
5202
  }
5163
5203
 
5204
+ function checkRow(data, width, y) {
5205
+ for (let x = 0, index = 4 * y * width; x < width; ++x, index += 4) {
5206
+ if (data[index + 3] !== 0)
5207
+ return false;
5208
+ }
5209
+ return true;
5210
+ }
5211
+ function checkColumn(data, width, x, top, bottom) {
5212
+ const stride = 4 * width;
5213
+ for (let y = top, index = top * stride + 4 * x; y <= bottom; ++y, index += stride) {
5214
+ if (data[index + 3] !== 0)
5215
+ return false;
5216
+ }
5217
+ return true;
5218
+ }
5164
5219
  function trimCanvas(canvas) {
5165
- let width = canvas.width;
5166
- let height = canvas.height;
5220
+ let { width, height } = canvas;
5167
5221
  const context = canvas.getContext("2d", {
5168
5222
  willReadFrequently: true
5169
5223
  });
5170
5224
  const imageData = context.getImageData(0, 0, width, height);
5171
- const pixels = imageData.data;
5172
- const len = pixels.length;
5173
- const bound = {
5174
- top: null,
5175
- left: null,
5176
- right: null,
5177
- bottom: null
5178
- };
5179
- let data = null;
5180
- let i;
5181
- let x;
5182
- let y;
5183
- for (i = 0; i < len; i += 4) {
5184
- if (pixels[i + 3] !== 0) {
5185
- x = i / 4 % width;
5186
- y = ~~(i / 4 / width);
5187
- if (bound.top === null) {
5188
- bound.top = y;
5189
- }
5190
- if (bound.left === null) {
5191
- bound.left = x;
5192
- } else if (x < bound.left) {
5193
- bound.left = x;
5194
- }
5195
- if (bound.right === null) {
5196
- bound.right = x + 1;
5197
- } else if (bound.right < x) {
5198
- bound.right = x + 1;
5199
- }
5200
- if (bound.bottom === null) {
5201
- bound.bottom = y;
5202
- } else if (bound.bottom < y) {
5203
- bound.bottom = y;
5204
- }
5205
- }
5206
- }
5207
- if (bound.top !== null) {
5208
- width = bound.right - bound.left;
5209
- height = bound.bottom - bound.top + 1;
5210
- data = context.getImageData(bound.left, bound.top, width, height);
5211
- }
5225
+ const data = imageData.data;
5226
+ let top = 0;
5227
+ let bottom = height - 1;
5228
+ let left = 0;
5229
+ let right = width - 1;
5230
+ while (top < height && checkRow(data, width, top))
5231
+ ++top;
5232
+ if (top === height) {
5233
+ return { width: 0, height: 0, data: null };
5234
+ }
5235
+ while (checkRow(data, width, bottom))
5236
+ --bottom;
5237
+ while (checkColumn(data, width, left, top, bottom))
5238
+ ++left;
5239
+ while (checkColumn(data, width, right, top, bottom))
5240
+ --right;
5241
+ width = right - left + 1;
5242
+ height = bottom - top + 1;
5212
5243
  return {
5213
- height,
5214
5244
  width,
5215
- data
5245
+ height,
5246
+ data: context.getImageData(left, top, width, height)
5216
5247
  };
5217
5248
  }
5218
5249
 
@@ -5638,7 +5669,7 @@ Deprecated since v${version}`);
5638
5669
  if (!baseTexture.textureCacheIds.includes(id)) {
5639
5670
  baseTexture.textureCacheIds.push(id);
5640
5671
  }
5641
- if (BaseTextureCache[id]) {
5672
+ if (BaseTextureCache[id] && BaseTextureCache[id] !== baseTexture) {
5642
5673
  console.warn(`BaseTexture added to the cache with an id [${id}] that already had an entry`);
5643
5674
  }
5644
5675
  BaseTextureCache[id] = baseTexture;
@@ -6606,6 +6637,9 @@ Deprecated since v${version}`);
6606
6637
  this.uvsFloat32[6] = this.x3;
6607
6638
  this.uvsFloat32[7] = this.y3;
6608
6639
  }
6640
+ toString() {
6641
+ return `[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`;
6642
+ }
6609
6643
  }
6610
6644
 
6611
6645
  const DEFAULT_UVS = new TextureUvs();
@@ -6795,7 +6829,7 @@ Deprecated since v${version}`);
6795
6829
  if (!texture.textureCacheIds.includes(id)) {
6796
6830
  texture.textureCacheIds.push(id);
6797
6831
  }
6798
- if (TextureCache[id]) {
6832
+ if (TextureCache[id] && TextureCache[id] !== texture) {
6799
6833
  console.warn(`Texture added to the cache with an id [${id}] that already had an entry`);
6800
6834
  }
6801
6835
  TextureCache[id] = texture;
@@ -7443,7 +7477,7 @@ Deprecated since v${version}`);
7443
7477
  }
7444
7478
 
7445
7479
  const tempPoints = [new Point(), new Point(), new Point(), new Point()];
7446
- const tempMatrix$1 = new Matrix();
7480
+ const tempMatrix$2 = new Matrix();
7447
7481
  class FilterSystem {
7448
7482
  constructor(renderer) {
7449
7483
  this.renderer = renderer;
@@ -7499,7 +7533,7 @@ Deprecated since v${version}`);
7499
7533
  state.sourceFrame.pad(padding);
7500
7534
  const sourceFrameProjected = this.tempRect.copyFrom(renderTextureSystem.sourceFrame);
7501
7535
  if (renderer.projection.transform) {
7502
- this.transformAABB(tempMatrix$1.copyFrom(renderer.projection.transform).invert(), sourceFrameProjected);
7536
+ this.transformAABB(tempMatrix$2.copyFrom(renderer.projection.transform).invert(), sourceFrameProjected);
7503
7537
  }
7504
7538
  if (autoFit) {
7505
7539
  state.sourceFrame.fit(sourceFrameProjected);
@@ -7705,7 +7739,7 @@ Deprecated since v${version}`);
7705
7739
  return;
7706
7740
  }
7707
7741
  }
7708
- transform = transform ? tempMatrix$1.copyFrom(transform) : tempMatrix$1.identity();
7742
+ transform = transform ? tempMatrix$2.copyFrom(transform) : tempMatrix$2.identity();
7709
7743
  transform.translate(-bindingSourceFrame.x, -bindingSourceFrame.y).scale(bindingDestinationFrame.width / bindingSourceFrame.width, bindingDestinationFrame.height / bindingSourceFrame.height).translate(bindingDestinationFrame.x, bindingDestinationFrame.y);
7710
7744
  this.transformAABB(transform, frame);
7711
7745
  frame.ceil(resolution);
@@ -7817,16 +7851,13 @@ Deprecated since v${version}`);
7817
7851
  this.gl = gl;
7818
7852
  this.renderer.gl = gl;
7819
7853
  this.renderer.CONTEXT_UID = CONTEXT_UID_COUNTER++;
7820
- if (gl.isContextLost() && gl.getExtension("WEBGL_lose_context")) {
7821
- gl.getExtension("WEBGL_lose_context").restoreContext();
7822
- }
7823
7854
  }
7824
7855
  init(options) {
7825
7856
  if (options.context) {
7826
7857
  this.initFromContext(options.context);
7827
7858
  } else {
7828
7859
  const alpha = this.renderer.background.alpha < 1;
7829
- const premultipliedAlpha = options.premultipliedAlpha ?? true;
7860
+ const premultipliedAlpha = options.premultipliedAlpha;
7830
7861
  this.preserveDrawingBuffer = options.preserveDrawingBuffer;
7831
7862
  this.useContextAlpha = options.useContextAlpha;
7832
7863
  this.powerPreference = options.powerPreference;
@@ -7877,6 +7908,7 @@ Deprecated since v${version}`);
7877
7908
  getExtensions() {
7878
7909
  const { gl } = this;
7879
7910
  const common = {
7911
+ loseContext: gl.getExtension("WEBGL_lose_context"),
7880
7912
  anisotropicFiltering: gl.getExtension("EXT_texture_filter_anisotropic"),
7881
7913
  floatTextureLinear: gl.getExtension("OES_texture_float_linear"),
7882
7914
  s3tc: gl.getExtension("WEBGL_compressed_texture_s3tc"),
@@ -7891,7 +7923,6 @@ Deprecated since v${version}`);
7891
7923
  Object.assign(this.extensions, common, {
7892
7924
  drawBuffers: gl.getExtension("WEBGL_draw_buffers"),
7893
7925
  depthTexture: gl.getExtension("WEBGL_depth_texture"),
7894
- loseContext: gl.getExtension("WEBGL_lose_context"),
7895
7926
  vertexArrayObject: gl.getExtension("OES_vertex_array_object") || gl.getExtension("MOZ_OES_vertex_array_object") || gl.getExtension("WEBKIT_OES_vertex_array_object"),
7896
7927
  uint32ElementIndex: gl.getExtension("OES_element_index_uint"),
7897
7928
  floatTexture: gl.getExtension("OES_texture_float"),
@@ -7907,6 +7938,11 @@ Deprecated since v${version}`);
7907
7938
  }
7908
7939
  handleContextLost(event) {
7909
7940
  event.preventDefault();
7941
+ setTimeout(() => {
7942
+ if (this.gl.isContextLost() && this.extensions.loseContext) {
7943
+ this.extensions.loseContext.restoreContext();
7944
+ }
7945
+ }, 0);
7910
7946
  }
7911
7947
  handleContextRestored() {
7912
7948
  this.renderer.runners.contextChange.emit(this.gl);
@@ -7973,13 +8009,13 @@ Deprecated since v${version}`);
7973
8009
  this.msaaSamples = null;
7974
8010
  }
7975
8011
  contextChange() {
8012
+ this.disposeAll(true);
7976
8013
  const gl = this.gl = this.renderer.gl;
7977
8014
  this.CONTEXT_UID = this.renderer.CONTEXT_UID;
7978
8015
  this.current = this.unknownFramebuffer;
7979
8016
  this.viewport = new Rectangle();
7980
8017
  this.hasMRT = true;
7981
8018
  this.writeDepthTexture = true;
7982
- this.disposeAll(true);
7983
8019
  if (this.renderer.context.webGLVersion === 1) {
7984
8020
  let nativeDrawBuffersExtension = this.renderer.context.extensions.drawBuffers;
7985
8021
  let nativeDepthTextureExtension = this.renderer.context.extensions.depthTexture;
@@ -9460,6 +9496,9 @@ ${this.fragmentSrc}`;
9460
9496
  this.offsets = !!value;
9461
9497
  this._polygonOffset = value;
9462
9498
  }
9499
+ toString() {
9500
+ return `[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`;
9501
+ }
9463
9502
  static for2d() {
9464
9503
  const state = new State();
9465
9504
  state.depthTest = false;
@@ -9815,7 +9854,7 @@ ${this.fragmentSrc}`;
9815
9854
  }
9816
9855
  }
9817
9856
 
9818
- const tempMatrix = new Matrix();
9857
+ const tempMatrix$1 = new Matrix();
9819
9858
  const rectPool = [];
9820
9859
  const _ScissorSystem = class extends AbstractMaskSystem {
9821
9860
  constructor(renderer) {
@@ -9870,7 +9909,7 @@ ${this.fragmentSrc}`;
9870
9909
  if (_ScissorSystem.isMatrixRotated(transform)) {
9871
9910
  return;
9872
9911
  }
9873
- transform = transform ? tempMatrix.copyFrom(transform) : tempMatrix.identity();
9912
+ transform = transform ? tempMatrix$1.copyFrom(transform) : tempMatrix$1.identity();
9874
9913
  transform.translate(-bindingSourceFrame.x, -bindingSourceFrame.y).scale(bindingDestinationFrame.width / bindingSourceFrame.width, bindingDestinationFrame.height / bindingSourceFrame.height).translate(bindingDestinationFrame.x, bindingDestinationFrame.y);
9875
9914
  this.renderer.filter.transformAABB(transform, frame);
9876
9915
  frame.fit(bindingDestinationFrame);
@@ -10399,6 +10438,7 @@ ${this.fragmentSrc}`;
10399
10438
  const transformFeedbackVaryings = program.extra?.transformFeedbackVaryings;
10400
10439
  if (transformFeedbackVaryings) {
10401
10440
  if (typeof gl.transformFeedbackVaryings !== "function") {
10441
+ console.warn(`TransformFeedback is not supported but TransformFeedbackVaryings are given.`);
10402
10442
  } else {
10403
10443
  gl.transformFeedbackVaryings(webGLProgram, transformFeedbackVaryings.names, transformFeedbackVaryings.bufferMode === "separate" ? gl.SEPARATE_ATTRIBS : gl.INTERLEAVED_ATTRIBS);
10404
10444
  }
@@ -11288,6 +11328,29 @@ ${this.fragmentSrc}`;
11288
11328
  constructor(renderer) {
11289
11329
  this.renderer = renderer;
11290
11330
  this.plugins = {};
11331
+ Object.defineProperties(this.plugins, {
11332
+ extract: {
11333
+ enumerable: false,
11334
+ get() {
11335
+ deprecation("7.0.0", "renderer.plugins.extract has moved to renderer.extract");
11336
+ return renderer.extract;
11337
+ }
11338
+ },
11339
+ prepare: {
11340
+ enumerable: false,
11341
+ get() {
11342
+ deprecation("7.0.0", "renderer.plugins.prepare has moved to renderer.prepare");
11343
+ return renderer.prepare;
11344
+ }
11345
+ },
11346
+ interaction: {
11347
+ enumerable: false,
11348
+ get() {
11349
+ deprecation("7.0.0", "renderer.plugins.interaction has been deprecated, use renderer.events");
11350
+ return renderer.events;
11351
+ }
11352
+ }
11353
+ });
11291
11354
  }
11292
11355
  init(staticMap) {
11293
11356
  for (const o in staticMap) {
@@ -11367,7 +11430,7 @@ ${this.fragmentSrc}`;
11367
11430
  const renderer = this.renderer;
11368
11431
  renderer.emitWithCustomOptions(renderer.runners.init, options);
11369
11432
  if (options.hello) {
11370
- console.log(`PixiJS ${"7.0.4"} - ${renderer.rendererLogId} - https://pixijs.com`);
11433
+ console.log(`PixiJS ${"7.0.5"} - ${renderer.rendererLogId} - https://pixijs.com`);
11371
11434
  }
11372
11435
  renderer.resize(this.renderer.screen.width, this.renderer.screen.height);
11373
11436
  }
@@ -11493,7 +11556,17 @@ ${this.fragmentSrc}`;
11493
11556
  projectionMatrix: new Matrix()
11494
11557
  }, true);
11495
11558
  const systemConfig = {
11496
- runners: ["init", "destroy", "contextChange", "reset", "update", "postrender", "prerender", "resize"],
11559
+ runners: [
11560
+ "init",
11561
+ "destroy",
11562
+ "contextChange",
11563
+ "resolutionChange",
11564
+ "reset",
11565
+ "update",
11566
+ "postrender",
11567
+ "prerender",
11568
+ "resize"
11569
+ ],
11497
11570
  systems: _Renderer.__systems,
11498
11571
  priority: [
11499
11572
  "_view",
@@ -11521,6 +11594,11 @@ ${this.fragmentSrc}`;
11521
11594
  ]
11522
11595
  };
11523
11596
  this.setup(systemConfig);
11597
+ if ("useContextAlpha" in options) {
11598
+ deprecation("7.0.0", "options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead");
11599
+ options.premultipliedAlpha = options.useContextAlpha && options.useContextAlpha !== "notMultiplied";
11600
+ options.backgroundAlpha = options.useContextAlpha === false ? 1 : options.backgroundAlpha;
11601
+ }
11524
11602
  const startupOptions = {
11525
11603
  hello: options.hello,
11526
11604
  _plugin: _Renderer.__plugins,
@@ -11540,7 +11618,7 @@ ${this.fragmentSrc}`;
11540
11618
  antialias: options.antialias,
11541
11619
  context: options.context,
11542
11620
  powerPreference: options.powerPreference,
11543
- premultipliedAlpha: options.premultipliedAlpha ?? (options.useContextAlpha && options.useContextAlpha !== "notMultiplied"),
11621
+ premultipliedAlpha: options.premultipliedAlpha,
11544
11622
  preserveDrawingBuffer: options.preserveDrawingBuffer
11545
11623
  }
11546
11624
  };
@@ -11588,6 +11666,10 @@ ${this.fragmentSrc}`;
11588
11666
  get resolution() {
11589
11667
  return this._view.resolution;
11590
11668
  }
11669
+ set resolution(value) {
11670
+ this._view.resolution = value;
11671
+ this.runners.resolutionChange.emit(value);
11672
+ }
11591
11673
  get autoDensity() {
11592
11674
  return this._view.autoDensity;
11593
11675
  }
@@ -11607,27 +11689,35 @@ ${this.fragmentSrc}`;
11607
11689
  return `WebGL ${this.context.webGLVersion}`;
11608
11690
  }
11609
11691
  get clearBeforeRender() {
11692
+ deprecation("7.0.0", "renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead.");
11610
11693
  return this.background.clearBeforeRender;
11611
11694
  }
11612
11695
  get useContextAlpha() {
11696
+ deprecation("7.0.0", "renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead.");
11613
11697
  return this.context.useContextAlpha;
11614
11698
  }
11615
11699
  get preserveDrawingBuffer() {
11700
+ deprecation("7.0.0", "renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context");
11616
11701
  return this.context.preserveDrawingBuffer;
11617
11702
  }
11618
11703
  get backgroundColor() {
11704
+ deprecation("7.0.0", "renderer.backgroundColor has been deprecated, use renderer.background.color instead.");
11619
11705
  return this.background.color;
11620
11706
  }
11621
11707
  set backgroundColor(value) {
11708
+ deprecation("7.0.0", "renderer.backgroundColor has been deprecated, use renderer.background.color instead.");
11622
11709
  this.background.color = value;
11623
11710
  }
11624
11711
  get backgroundAlpha() {
11712
+ deprecation("7.0.0", "renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead.");
11625
11713
  return this.background.color;
11626
11714
  }
11627
11715
  set backgroundAlpha(value) {
11716
+ deprecation("7.0.0", "renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead.");
11628
11717
  this.background.alpha = value;
11629
11718
  }
11630
11719
  get powerPreference() {
11720
+ deprecation("7.0.0", "renderer.powerPreference has been deprecated, we can only know this if pixi creates the context");
11631
11721
  return this.context.powerPreference;
11632
11722
  }
11633
11723
  generateTexture(displayObject, options) {
@@ -12336,7 +12426,7 @@ ${this.fragmentSrc}`;
12336
12426
  };
12337
12427
  extensions$1.add(ObjectRendererSystem);
12338
12428
 
12339
- const VERSION = "7.0.4";
12429
+ const VERSION = "7.0.5";
12340
12430
 
12341
12431
  var fragment$6 = "varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float uAlpha;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;\n}\n";
12342
12432
 
@@ -13809,6 +13899,7 @@ ${this.fragmentSrc}`;
13809
13899
  }
13810
13900
  DisplayObject.prototype.displayObjectUpdateTransform = DisplayObject.prototype.updateTransform;
13811
13901
 
13902
+ const tempMatrix = new Matrix();
13812
13903
  function sortChildren(a, b) {
13813
13904
  if (a.zIndex === b.zIndex) {
13814
13905
  return a._lastSortedIndex - b._lastSortedIndex;
@@ -14030,6 +14121,15 @@ ${this.fragmentSrc}`;
14030
14121
  } else if (this._render !== Container.prototype._render) {
14031
14122
  bounds = this.getBounds(true);
14032
14123
  }
14124
+ const projectionTransform = renderer.projection.transform;
14125
+ if (projectionTransform) {
14126
+ if (transform) {
14127
+ transform = tempMatrix.copyFrom(transform);
14128
+ transform.prepend(projectionTransform);
14129
+ } else {
14130
+ transform = projectionTransform;
14131
+ }
14132
+ }
14033
14133
  if (bounds && sourceFrame.intersects(bounds, transform)) {
14034
14134
  this._render(renderer);
14035
14135
  } else if (this.cullArea) {
@@ -15392,6 +15492,9 @@ ${this.fragmentSrc}`;
15392
15492
  this.setTargetElement(view);
15393
15493
  this.resolution = resolution;
15394
15494
  }
15495
+ resolutionChange(resolution) {
15496
+ this.resolution = resolution;
15497
+ }
15395
15498
  destroy() {
15396
15499
  this.setTargetElement(null);
15397
15500
  this.renderer = null;
@@ -16178,6 +16281,26 @@ ${this.fragmentSrc}`;
16178
16281
  }
16179
16282
  }
16180
16283
 
16284
+ function checkDataUrl(url, mimes) {
16285
+ if (Array.isArray(mimes)) {
16286
+ for (const mime of mimes) {
16287
+ if (url.startsWith(`data:${mime}`))
16288
+ return true;
16289
+ }
16290
+ return false;
16291
+ }
16292
+ return url.startsWith(`data:${mimes}`);
16293
+ }
16294
+
16295
+ function checkExtension(url, extension) {
16296
+ const tempURL = url.split("?")[0];
16297
+ const ext = path.extname(tempURL).toLowerCase();
16298
+ if (Array.isArray(extension)) {
16299
+ return extension.includes(ext.toLowerCase());
16300
+ }
16301
+ return ext.toLowerCase() === extension;
16302
+ }
16303
+
16181
16304
  const convertToList = (input, transform) => {
16182
16305
  if (!Array.isArray(input)) {
16183
16306
  input = [input];
@@ -16239,6 +16362,7 @@ ${this.fragmentSrc}`;
16239
16362
  get(key) {
16240
16363
  const result = this._cache.get(key);
16241
16364
  if (!result) {
16365
+ console.warn(`[Assets] Asset id ${key} was not found in the Cache`);
16242
16366
  }
16243
16367
  return result;
16244
16368
  }
@@ -16268,6 +16392,7 @@ ${this.fragmentSrc}`;
16268
16392
  });
16269
16393
  cacheKeys.forEach((key2) => {
16270
16394
  if (this._cache.has(key2) && this._cache.get(key2) !== value) {
16395
+ console.warn("[Cache] already has key:", key2);
16271
16396
  }
16272
16397
  this._cache.set(key2, cacheableAssets[key2]);
16273
16398
  });
@@ -16284,6 +16409,7 @@ ${this.fragmentSrc}`;
16284
16409
  remove(key) {
16285
16410
  this._cacheMap.get(key);
16286
16411
  if (!this._cacheMap.has(key)) {
16412
+ console.warn(`[Assets] Asset id ${key} was not found in the Cache`);
16287
16413
  return;
16288
16414
  }
16289
16415
  const cacheMap = this._cacheMap.get(key);
@@ -16325,6 +16451,7 @@ ${this.fragmentSrc}`;
16325
16451
  }
16326
16452
  }
16327
16453
  if (!result.parser) {
16454
+ console.warn(`[Assets] ${url} could not be loaded as we don't know how to parse it, ensure the correct parser has being added`);
16328
16455
  return null;
16329
16456
  }
16330
16457
  for (let i = 0; i < this.parsers.length; i++) {
@@ -16431,6 +16558,7 @@ ${e}`);
16431
16558
  }
16432
16559
  addManifest(manifest) {
16433
16560
  if (this._manifest) {
16561
+ console.warn("[Resolver] Manifest already exists, this will be overwritten");
16434
16562
  }
16435
16563
  this._manifest = manifest;
16436
16564
  manifest.bundles.forEach((bundle) => {
@@ -16460,6 +16588,7 @@ ${e}`);
16460
16588
  const keys = convertToList(keysIn);
16461
16589
  keys.forEach((key) => {
16462
16590
  if (this._assetMap[key]) {
16591
+ console.warn(`[Resolver] already has key: ${key} overwriting`);
16463
16592
  }
16464
16593
  });
16465
16594
  if (!Array.isArray(assetsIn)) {
@@ -16589,6 +16718,7 @@ ${e}`);
16589
16718
  }
16590
16719
  async init(options = {}) {
16591
16720
  if (this._initialized) {
16721
+ console.warn("[Assets]AssetManager already initialized, did you load before calling this Asset.init()?");
16592
16722
  return;
16593
16723
  }
16594
16724
  this._initialized = true;
@@ -16844,7 +16974,13 @@ ${e}`);
16844
16974
  "800",
16845
16975
  "900"
16846
16976
  ];
16847
- const validFonts = ["woff", "woff2", "ttf", "otf"];
16977
+ const validFontExtensions = [".ttf", ".otf", ".woff", ".woff2"];
16978
+ const validFontMIMEs = [
16979
+ "font/ttf",
16980
+ "font/otf",
16981
+ "font/woff",
16982
+ "font/woff2"
16983
+ ];
16848
16984
  function getFontFamilyName(url) {
16849
16985
  const ext = path.extname(url);
16850
16986
  const name = path.basename(url, ext);
@@ -16858,9 +16994,7 @@ ${e}`);
16858
16994
  priority: LoaderParserPriority.Low
16859
16995
  },
16860
16996
  test(url) {
16861
- const tempURL = url.split("?")[0];
16862
- const extension = tempURL.split(".").pop();
16863
- return validFonts.includes(extension);
16997
+ return checkDataUrl(url, validFontMIMEs) || checkExtension(url, validFontExtensions);
16864
16998
  },
16865
16999
  async load(url, options) {
16866
17000
  if (!globalThis.navigator.onLine) {
@@ -16874,7 +17008,7 @@ ${e}`);
16874
17008
  const data = options.data ?? {};
16875
17009
  for (let i = 0; i < weights.length; i++) {
16876
17010
  const weight = weights[i];
16877
- const font = new FontFace(name, `url(${url})`, {
17011
+ const font = new FontFace(name, `url(${encodeURI(url)})`, {
16878
17012
  ...data,
16879
17013
  weight
16880
17014
  });
@@ -16884,6 +17018,7 @@ ${e}`);
16884
17018
  }
16885
17019
  return fontFaces.length === 1 ? fontFaces[0] : fontFaces;
16886
17020
  }
17021
+ console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font");
16887
17022
  return null;
16888
17023
  },
16889
17024
  unload(font) {
@@ -17046,15 +17181,6 @@ ${e}`);
17046
17181
  }
17047
17182
  const WorkerManager = new WorkerManagerClass();
17048
17183
 
17049
- function checkExtension(url, extension) {
17050
- const tempURL = url.split("?")[0];
17051
- const ext = path.extname(tempURL).toLowerCase();
17052
- if (Array.isArray(extension)) {
17053
- return extension.includes(ext.toLowerCase());
17054
- }
17055
- return ext.toLowerCase() === extension;
17056
- }
17057
-
17058
17184
  function createTexture(base, loader, url) {
17059
17185
  const texture = new Texture(base);
17060
17186
  texture.baseTexture.on("dispose", () => {
@@ -17063,7 +17189,13 @@ ${e}`);
17063
17189
  return texture;
17064
17190
  }
17065
17191
 
17066
- const validImages$1 = [".jpg", ".png", ".jpeg", ".avif", ".webp"];
17192
+ const validImageExtensions = [".jpeg", ".jpg", ".png", ".webp", ".avif"];
17193
+ const validImageMIMEs = [
17194
+ "image/jpeg",
17195
+ "image/png",
17196
+ "image/webp",
17197
+ "image/avif"
17198
+ ];
17067
17199
  async function loadImageBitmap(url) {
17068
17200
  const response = await settings.ADAPTER.fetch(url);
17069
17201
  if (!response.ok) {
@@ -17082,14 +17214,7 @@ ${e}`);
17082
17214
  preferWorkers: true
17083
17215
  },
17084
17216
  test(url) {
17085
- let isValidBase64Suffix = false;
17086
- for (let i = 0; i < validImages$1.length; i++) {
17087
- if (url.startsWith(`data:image/${validImages$1[i].slice(1)}`)) {
17088
- isValidBase64Suffix = true;
17089
- break;
17090
- }
17091
- }
17092
- return isValidBase64Suffix || checkExtension(url, validImages$1);
17217
+ return checkDataUrl(url, validImageMIMEs) || checkExtension(url, validImageExtensions);
17093
17218
  },
17094
17219
  async load(url, asset, loader) {
17095
17220
  let src = null;
@@ -17403,6 +17528,7 @@ ${e}`);
17403
17528
  const canvas = settings.ADAPTER.createCanvas();
17404
17529
  const gl = canvas.getContext("webgl");
17405
17530
  if (!gl) {
17531
+ console.warn("WebGL not available for compressed textures.");
17406
17532
  return false;
17407
17533
  }
17408
17534
  storedGl = gl;
@@ -17864,6 +17990,7 @@ ${e}`);
17864
17990
  function validate(url, dataView) {
17865
17991
  for (let i = 0; i < FILE_IDENTIFIER.length; i++) {
17866
17992
  if (dataView.getUint8(i) !== FILE_IDENTIFIER[i]) {
17993
+ console.error(`${url} is not a valid *.ktx file!`);
17867
17994
  return false;
17868
17995
  }
17869
17996
  }
@@ -21428,7 +21555,7 @@ ${e}`);
21428
21555
  width += style.dropShadowDistance;
21429
21556
  }
21430
21557
  const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness;
21431
- let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + (lines.length - 1) * (lineHeight + style.leading);
21558
+ let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness * 2) + (lines.length - 1) * (lineHeight + style.leading);
21432
21559
  if (style.dropShadow) {
21433
21560
  height += style.dropShadowDistance;
21434
21561
  }
@@ -22994,7 +23121,8 @@ ${e}`);
22994
23121
 
22995
23122
  class XMLFormat {
22996
23123
  static test(data) {
22997
- return data instanceof XMLDocument && data.getElementsByTagName("page").length && data.getElementsByTagName("info")[0].getAttribute("face") !== null;
23124
+ const xml = data;
23125
+ return "getElementsByTagName" in xml && xml.getElementsByTagName("page").length && xml.getElementsByTagName("info")[0].getAttribute("face") !== null;
22998
23126
  }
22999
23127
  static parse(xml) {
23000
23128
  const data = new BitmapFontData();
@@ -23055,14 +23183,12 @@ ${e}`);
23055
23183
  class XMLStringFormat {
23056
23184
  static test(data) {
23057
23185
  if (typeof data === "string" && data.includes("<font>")) {
23058
- const xml = new globalThis.DOMParser().parseFromString(data, "text/xml");
23059
- return XMLFormat.test(xml);
23186
+ return XMLFormat.test(settings.ADAPTER.parseXML(data));
23060
23187
  }
23061
23188
  return false;
23062
23189
  }
23063
23190
  static parse(xmlTxt) {
23064
- const xml = new globalThis.DOMParser().parseFromString(xmlTxt, "text/xml");
23065
- return XMLFormat.parse(xml);
23191
+ return XMLFormat.parse(settings.ADAPTER.parseXML(xmlTxt));
23066
23192
  }
23067
23193
  }
23068
23194
 
@@ -24137,6 +24263,7 @@ ${e}`);
24137
24263
  exports.autoDetectRenderer = autoDetectRenderer;
24138
24264
  exports.autoDetectResource = autoDetectResource;
24139
24265
  exports.cacheTextureArray = cacheTextureArray;
24266
+ exports.checkDataUrl = checkDataUrl;
24140
24267
  exports.checkExtension = checkExtension;
24141
24268
  exports.checkMaxIfStatementsInShader = checkMaxIfStatementsInShader;
24142
24269
  exports.convertToList = convertToList;