pixi-watchface-engine 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -28030,60 +28030,6 @@ var init_CanvasRenderer = __esm(() => {
28030
28030
  };
28031
28031
  });
28032
28032
 
28033
- // node_modules/pixi.js/lib/scene/text-bitmap/AbstractBitmapFont.mjs
28034
- var AbstractBitmapFont;
28035
- var init_AbstractBitmapFont = __esm(() => {
28036
- init_eventemitter3();
28037
- init_deprecation();
28038
- AbstractBitmapFont = class AbstractBitmapFont extends eventemitter3_default {
28039
- constructor() {
28040
- super(...arguments);
28041
- this.chars = /* @__PURE__ */ Object.create(null);
28042
- this.lineHeight = 0;
28043
- this.fontFamily = "";
28044
- this.fontMetrics = { fontSize: 0, ascent: 0, descent: 0 };
28045
- this.baseLineOffset = 0;
28046
- this.distanceField = { type: "none", range: 0 };
28047
- this.pages = [];
28048
- this.applyFillAsTint = true;
28049
- this.baseMeasurementFontSize = 100;
28050
- this.baseRenderedFontSize = 100;
28051
- }
28052
- get font() {
28053
- deprecation(v8_0_0, "BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead.");
28054
- return this.fontFamily;
28055
- }
28056
- get pageTextures() {
28057
- deprecation(v8_0_0, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead.");
28058
- return this.pages;
28059
- }
28060
- get size() {
28061
- deprecation(v8_0_0, "BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead.");
28062
- return this.fontMetrics.fontSize;
28063
- }
28064
- get distanceFieldRange() {
28065
- deprecation(v8_0_0, "BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead.");
28066
- return this.distanceField.range;
28067
- }
28068
- get distanceFieldType() {
28069
- deprecation(v8_0_0, "BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead.");
28070
- return this.distanceField.type;
28071
- }
28072
- destroy(destroyTextures = false) {
28073
- this.emit("destroy", this);
28074
- this.removeAllListeners();
28075
- for (const i2 in this.chars) {
28076
- this.chars[i2].texture?.destroy();
28077
- }
28078
- this.chars = null;
28079
- if (destroyTextures) {
28080
- this.pages.forEach((page) => page.texture.destroy(true));
28081
- this.pages = null;
28082
- }
28083
- }
28084
- };
28085
- });
28086
-
28087
28033
  // node_modules/tiny-lru/dist/tiny-lru.js
28088
28034
  class LRU {
28089
28035
  constructor(max = 0, ttl = 0, resetTtl = false) {
@@ -29105,6 +29051,73 @@ var init_fontStringFromTextStyle = __esm(() => {
29105
29051
  ];
29106
29052
  });
29107
29053
 
29054
+ // node_modules/pixi.js/lib/scene/text/canvas/utils/getCanvasFillStyle.mjs
29055
+ function getCanvasFillStyle(fillStyle, context2, textMetrics, padding = 0, offsetX = 0, offsetY = 0) {
29056
+ if (fillStyle.texture === Texture.WHITE && !fillStyle.fill) {
29057
+ return Color.shared.setValue(fillStyle.color).setAlpha(fillStyle.alpha ?? 1).toHexa();
29058
+ } else if (!fillStyle.fill) {
29059
+ const pattern = context2.createPattern(fillStyle.texture.source.resource, "repeat");
29060
+ const tempMatrix8 = fillStyle.matrix.copyTo(Matrix.shared);
29061
+ tempMatrix8.scale(fillStyle.texture.source.pixelWidth, fillStyle.texture.source.pixelHeight);
29062
+ pattern.setTransform(tempMatrix8);
29063
+ return pattern;
29064
+ } else if (fillStyle.fill instanceof FillPattern) {
29065
+ const fillPattern = fillStyle.fill;
29066
+ const pattern = context2.createPattern(fillPattern.texture.source.resource, "repeat");
29067
+ const tempMatrix8 = fillPattern.transform.copyTo(Matrix.shared);
29068
+ tempMatrix8.scale(fillPattern.texture.source.pixelWidth, fillPattern.texture.source.pixelHeight);
29069
+ pattern.setTransform(tempMatrix8);
29070
+ return pattern;
29071
+ } else if (fillStyle.fill instanceof FillGradient) {
29072
+ const fillGradient = fillStyle.fill;
29073
+ const isLinear = fillGradient.type === "linear";
29074
+ const isLocal = fillGradient.textureSpace === "local";
29075
+ let width = 1;
29076
+ let height = 1;
29077
+ if (isLocal && textMetrics) {
29078
+ width = textMetrics.width + padding;
29079
+ height = textMetrics.height + padding;
29080
+ }
29081
+ let gradient;
29082
+ let isNearlyVertical = false;
29083
+ if (isLinear) {
29084
+ const { start, end } = fillGradient;
29085
+ gradient = context2.createLinearGradient(start.x * width + offsetX, start.y * height + offsetY, end.x * width + offsetX, end.y * height + offsetY);
29086
+ isNearlyVertical = Math.abs(end.x - start.x) < Math.abs((end.y - start.y) * 0.1);
29087
+ } else {
29088
+ const { center, innerRadius, outerCenter, outerRadius } = fillGradient;
29089
+ gradient = context2.createRadialGradient(center.x * width + offsetX, center.y * height + offsetY, innerRadius * width, outerCenter.x * width + offsetX, outerCenter.y * height + offsetY, outerRadius * width);
29090
+ }
29091
+ if (isNearlyVertical && isLocal && textMetrics) {
29092
+ const ratio = textMetrics.lineHeight / height;
29093
+ for (let i2 = 0;i2 < textMetrics.lines.length; i2++) {
29094
+ const start = (i2 * textMetrics.lineHeight + padding / 2) / height;
29095
+ fillGradient.colorStops.forEach((stop) => {
29096
+ let globalStop = start + stop.offset * ratio;
29097
+ globalStop = Math.max(0, Math.min(1, globalStop));
29098
+ gradient.addColorStop(Math.floor(globalStop * PRECISION) / PRECISION, Color.shared.setValue(stop.color).toHex());
29099
+ });
29100
+ }
29101
+ } else {
29102
+ fillGradient.colorStops.forEach((stop) => {
29103
+ gradient.addColorStop(stop.offset, Color.shared.setValue(stop.color).toHex());
29104
+ });
29105
+ }
29106
+ return gradient;
29107
+ }
29108
+ warn("FillStyle not recognised", fillStyle);
29109
+ return "red";
29110
+ }
29111
+ var PRECISION = 1e5;
29112
+ var init_getCanvasFillStyle = __esm(() => {
29113
+ init_Color();
29114
+ init_Matrix();
29115
+ init_Texture();
29116
+ init_warn();
29117
+ init_FillGradient();
29118
+ init_FillPattern();
29119
+ });
29120
+
29108
29121
  // node_modules/pixi.js/lib/scene/text/TextStyle.mjs
29109
29122
  function convertV7Tov8Style(style) {
29110
29123
  const oldStyle = style;
@@ -29536,811 +29549,71 @@ var init_TextStyle = __esm(() => {
29536
29549
  TextStyle = _TextStyle;
29537
29550
  });
29538
29551
 
29539
- // node_modules/pixi.js/lib/scene/text/canvas/utils/getCanvasFillStyle.mjs
29540
- function getCanvasFillStyle(fillStyle, context2, textMetrics, padding = 0, offsetX = 0, offsetY = 0) {
29541
- if (fillStyle.texture === Texture.WHITE && !fillStyle.fill) {
29542
- return Color.shared.setValue(fillStyle.color).setAlpha(fillStyle.alpha ?? 1).toHexa();
29543
- } else if (!fillStyle.fill) {
29544
- const pattern = context2.createPattern(fillStyle.texture.source.resource, "repeat");
29545
- const tempMatrix8 = fillStyle.matrix.copyTo(Matrix.shared);
29546
- tempMatrix8.scale(fillStyle.texture.source.pixelWidth, fillStyle.texture.source.pixelHeight);
29547
- pattern.setTransform(tempMatrix8);
29548
- return pattern;
29549
- } else if (fillStyle.fill instanceof FillPattern) {
29550
- const fillPattern = fillStyle.fill;
29551
- const pattern = context2.createPattern(fillPattern.texture.source.resource, "repeat");
29552
- const tempMatrix8 = fillPattern.transform.copyTo(Matrix.shared);
29553
- tempMatrix8.scale(fillPattern.texture.source.pixelWidth, fillPattern.texture.source.pixelHeight);
29554
- pattern.setTransform(tempMatrix8);
29555
- return pattern;
29556
- } else if (fillStyle.fill instanceof FillGradient) {
29557
- const fillGradient = fillStyle.fill;
29558
- const isLinear = fillGradient.type === "linear";
29559
- const isLocal = fillGradient.textureSpace === "local";
29560
- let width = 1;
29561
- let height = 1;
29562
- if (isLocal && textMetrics) {
29563
- width = textMetrics.width + padding;
29564
- height = textMetrics.height + padding;
29565
- }
29566
- let gradient;
29567
- let isNearlyVertical = false;
29568
- if (isLinear) {
29569
- const { start, end } = fillGradient;
29570
- gradient = context2.createLinearGradient(start.x * width + offsetX, start.y * height + offsetY, end.x * width + offsetX, end.y * height + offsetY);
29571
- isNearlyVertical = Math.abs(end.x - start.x) < Math.abs((end.y - start.y) * 0.1);
29572
- } else {
29573
- const { center, innerRadius, outerCenter, outerRadius } = fillGradient;
29574
- gradient = context2.createRadialGradient(center.x * width + offsetX, center.y * height + offsetY, innerRadius * width, outerCenter.x * width + offsetX, outerCenter.y * height + offsetY, outerRadius * width);
29575
- }
29576
- if (isNearlyVertical && isLocal && textMetrics) {
29577
- const ratio = textMetrics.lineHeight / height;
29578
- for (let i2 = 0;i2 < textMetrics.lines.length; i2++) {
29579
- const start = (i2 * textMetrics.lineHeight + padding / 2) / height;
29580
- fillGradient.colorStops.forEach((stop) => {
29581
- let globalStop = start + stop.offset * ratio;
29582
- globalStop = Math.max(0, Math.min(1, globalStop));
29583
- gradient.addColorStop(Math.floor(globalStop * PRECISION) / PRECISION, Color.shared.setValue(stop.color).toHex());
29584
- });
29585
- }
29586
- } else {
29587
- fillGradient.colorStops.forEach((stop) => {
29588
- gradient.addColorStop(stop.offset, Color.shared.setValue(stop.color).toHex());
29589
- });
29590
- }
29591
- return gradient;
29552
+ // node_modules/pixi.js/lib/environment-browser/browserExt.mjs
29553
+ init_Extensions();
29554
+ var browserExt = {
29555
+ extension: {
29556
+ type: ExtensionType.Environment,
29557
+ name: "browser",
29558
+ priority: -1
29559
+ },
29560
+ test: () => true,
29561
+ load: async () => {
29562
+ await Promise.resolve().then(() => (init_browserAll(), exports_browserAll));
29592
29563
  }
29593
- warn("FillStyle not recognised", fillStyle);
29594
- return "red";
29595
- }
29596
- var PRECISION = 1e5;
29597
- var init_getCanvasFillStyle = __esm(() => {
29598
- init_Color();
29599
- init_Matrix();
29600
- init_Texture();
29601
- init_warn();
29602
- init_FillGradient();
29603
- init_FillPattern();
29604
- });
29564
+ };
29605
29565
 
29606
- // node_modules/pixi.js/lib/scene/text-bitmap/DynamicBitmapFont.mjs
29607
- var _DynamicBitmapFont, DynamicBitmapFont;
29608
- var init_DynamicBitmapFont = __esm(() => {
29609
- init_Color();
29610
- init_Rectangle();
29611
- init_CanvasPool();
29612
- init_ImageSource();
29613
- init_Texture();
29614
- init_TextureStyle();
29615
- init_deprecation();
29616
- init_CanvasTextMetrics();
29617
- init_fontStringFromTextStyle();
29618
- init_getCanvasFillStyle();
29619
- init_TextStyle();
29620
- init_AbstractBitmapFont();
29621
- _DynamicBitmapFont = class _DynamicBitmapFont2 extends AbstractBitmapFont {
29622
- constructor(options) {
29623
- super();
29624
- this.resolution = 1;
29625
- this.pages = [];
29626
- this._padding = 0;
29627
- this._measureCache = /* @__PURE__ */ Object.create(null);
29628
- this._currentChars = [];
29629
- this._currentX = 0;
29630
- this._currentY = 0;
29631
- this._currentMaxCharHeight = 0;
29632
- this._currentPageIndex = -1;
29633
- this._skipKerning = false;
29634
- const dynamicOptions = { ..._DynamicBitmapFont2.defaultOptions, ...options };
29635
- this._textureSize = dynamicOptions.textureSize;
29636
- this._mipmap = dynamicOptions.mipmap;
29637
- const style = dynamicOptions.style.clone();
29638
- if (dynamicOptions.overrideFill) {
29639
- style._fill.color = 16777215;
29640
- style._fill.alpha = 1;
29641
- style._fill.texture = Texture.WHITE;
29642
- style._fill.fill = null;
29643
- }
29644
- this.applyFillAsTint = dynamicOptions.overrideFill;
29645
- const requestedFontSize = style.fontSize;
29646
- style.fontSize = this.baseMeasurementFontSize;
29647
- const font = fontStringFromTextStyle(style);
29648
- if (dynamicOptions.overrideSize) {
29649
- if (style._stroke) {
29650
- style._stroke.width *= this.baseRenderedFontSize / requestedFontSize;
29651
- }
29652
- } else {
29653
- style.fontSize = this.baseRenderedFontSize = requestedFontSize;
29654
- }
29655
- this._style = style;
29656
- this._skipKerning = dynamicOptions.skipKerning ?? false;
29657
- this.resolution = dynamicOptions.resolution ?? 1;
29658
- this._padding = dynamicOptions.padding ?? 4;
29659
- if (dynamicOptions.textureStyle) {
29660
- this._textureStyle = dynamicOptions.textureStyle instanceof TextureStyle ? dynamicOptions.textureStyle : new TextureStyle(dynamicOptions.textureStyle);
29661
- }
29662
- this.fontMetrics = CanvasTextMetrics.measureFont(font);
29663
- this.lineHeight = style.lineHeight || this.fontMetrics.fontSize || style.fontSize;
29664
- }
29665
- ensureCharacters(chars) {
29666
- const charList = CanvasTextMetrics.graphemeSegmenter(chars).filter((char) => !this._currentChars.includes(char)).filter((char, index, self2) => self2.indexOf(char) === index);
29667
- if (!charList.length)
29668
- return;
29669
- this._currentChars = [...this._currentChars, ...charList];
29670
- let pageData;
29671
- if (this._currentPageIndex === -1) {
29672
- pageData = this._nextPage();
29673
- } else {
29674
- pageData = this.pages[this._currentPageIndex];
29675
- }
29676
- let { canvas, context: context2 } = pageData.canvasAndContext;
29677
- let textureSource = pageData.texture.source;
29678
- const style = this._style;
29679
- let currentX = this._currentX;
29680
- let currentY = this._currentY;
29681
- let currentMaxCharHeight = this._currentMaxCharHeight;
29682
- const fontScale = this.baseRenderedFontSize / this.baseMeasurementFontSize;
29683
- const padding = this._padding * fontScale;
29684
- let skipTexture = false;
29685
- const maxTextureWidth = canvas.width / this.resolution;
29686
- const maxTextureHeight = canvas.height / this.resolution;
29687
- for (let i2 = 0;i2 < charList.length; i2++) {
29688
- const char = charList[i2];
29689
- const metrics = CanvasTextMetrics.measureText(char, style, canvas, false);
29690
- metrics.lineHeight = metrics.height;
29691
- const width = metrics.width * fontScale;
29692
- const textureGlyphWidth = Math.ceil((style.fontStyle === "italic" ? 2 : 1) * width);
29693
- const height = metrics.height * fontScale;
29694
- const paddedWidth = textureGlyphWidth + padding * 2;
29695
- const paddedHeight = height + padding * 2;
29696
- skipTexture = false;
29697
- if (char !== `
29698
- ` && char !== "\r" && char !== "\t" && char !== " ") {
29699
- skipTexture = true;
29700
- currentMaxCharHeight = Math.ceil(Math.max(paddedHeight, currentMaxCharHeight));
29701
- }
29702
- if (currentX + paddedWidth > maxTextureWidth) {
29703
- currentY += currentMaxCharHeight;
29704
- currentMaxCharHeight = paddedHeight;
29705
- currentX = 0;
29706
- if (currentY + currentMaxCharHeight > maxTextureHeight) {
29707
- textureSource.update();
29708
- const pageData2 = this._nextPage();
29709
- canvas = pageData2.canvasAndContext.canvas;
29710
- context2 = pageData2.canvasAndContext.context;
29711
- textureSource = pageData2.texture.source;
29712
- currentX = 0;
29713
- currentY = 0;
29714
- currentMaxCharHeight = 0;
29715
- }
29716
- }
29717
- const xAdvance = width / fontScale - (style.dropShadow?.distance ?? 0) - (style._stroke?.width ?? 0);
29718
- this.chars[char] = {
29719
- id: char.codePointAt(0),
29720
- xOffset: -this._padding,
29721
- yOffset: -this._padding,
29722
- xAdvance,
29723
- kerning: {}
29724
- };
29725
- if (skipTexture) {
29726
- this._drawGlyph(context2, metrics, currentX + padding, currentY + padding, fontScale, style);
29727
- const px = textureSource.width * fontScale;
29728
- const py = textureSource.height * fontScale;
29729
- const frame = new Rectangle(currentX / px * textureSource.width, currentY / py * textureSource.height, paddedWidth / px * textureSource.width, paddedHeight / py * textureSource.height);
29730
- this.chars[char].texture = new Texture({
29731
- source: textureSource,
29732
- frame
29733
- });
29734
- currentX += Math.ceil(paddedWidth);
29735
- }
29736
- }
29737
- textureSource.update();
29738
- this._currentX = currentX;
29739
- this._currentY = currentY;
29740
- this._currentMaxCharHeight = currentMaxCharHeight;
29741
- this._skipKerning && this._applyKerning(charList, context2);
29742
- }
29743
- get pageTextures() {
29744
- deprecation(v8_0_0, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead.");
29745
- return this.pages;
29746
- }
29747
- _applyKerning(newChars, context2) {
29748
- const measureCache = this._measureCache;
29749
- for (let i2 = 0;i2 < newChars.length; i2++) {
29750
- const first = newChars[i2];
29751
- for (let j2 = 0;j2 < this._currentChars.length; j2++) {
29752
- const second = this._currentChars[j2];
29753
- let c1 = measureCache[first];
29754
- if (!c1)
29755
- c1 = measureCache[first] = context2.measureText(first).width;
29756
- let c2 = measureCache[second];
29757
- if (!c2)
29758
- c2 = measureCache[second] = context2.measureText(second).width;
29759
- let total = context2.measureText(first + second).width;
29760
- let amount = total - (c1 + c2);
29761
- if (amount) {
29762
- this.chars[first].kerning[second] = amount;
29763
- }
29764
- total = context2.measureText(first + second).width;
29765
- amount = total - (c1 + c2);
29766
- if (amount) {
29767
- this.chars[second].kerning[first] = amount;
29768
- }
29769
- }
29770
- }
29771
- }
29772
- _nextPage() {
29773
- this._currentPageIndex++;
29774
- const textureResolution = this.resolution;
29775
- const canvasAndContext = CanvasPool.getOptimalCanvasAndContext(this._textureSize, this._textureSize, textureResolution);
29776
- this._setupContext(canvasAndContext.context, this._style, textureResolution);
29777
- const resolution = textureResolution * (this.baseRenderedFontSize / this.baseMeasurementFontSize);
29778
- const texture = new Texture({
29779
- source: new ImageSource({
29780
- resource: canvasAndContext.canvas,
29781
- resolution,
29782
- alphaMode: "premultiply-alpha-on-upload",
29783
- autoGenerateMipmaps: this._mipmap
29784
- })
29785
- });
29786
- if (this._textureStyle) {
29787
- texture.source.style = this._textureStyle;
29788
- }
29789
- const pageData = {
29790
- canvasAndContext,
29791
- texture
29792
- };
29793
- this.pages[this._currentPageIndex] = pageData;
29794
- return pageData;
29795
- }
29796
- _setupContext(context2, style, resolution) {
29797
- style.fontSize = this.baseRenderedFontSize;
29798
- context2.scale(resolution, resolution);
29799
- context2.font = fontStringFromTextStyle(style);
29800
- style.fontSize = this.baseMeasurementFontSize;
29801
- context2.textBaseline = style.textBaseline;
29802
- const stroke = style._stroke;
29803
- const strokeThickness = stroke?.width ?? 0;
29804
- if (stroke) {
29805
- context2.lineWidth = strokeThickness;
29806
- context2.lineJoin = stroke.join;
29807
- context2.miterLimit = stroke.miterLimit;
29808
- context2.strokeStyle = getCanvasFillStyle(stroke, context2);
29809
- }
29810
- if (style._fill) {
29811
- context2.fillStyle = getCanvasFillStyle(style._fill, context2);
29812
- }
29813
- if (style.dropShadow) {
29814
- const shadowOptions = style.dropShadow;
29815
- const rgb = Color.shared.setValue(shadowOptions.color).toArray();
29816
- const dropShadowBlur = shadowOptions.blur * resolution;
29817
- const dropShadowDistance = shadowOptions.distance * resolution;
29818
- context2.shadowColor = `rgba(${rgb[0] * 255},${rgb[1] * 255},${rgb[2] * 255},${shadowOptions.alpha})`;
29819
- context2.shadowBlur = dropShadowBlur;
29820
- context2.shadowOffsetX = Math.cos(shadowOptions.angle) * dropShadowDistance;
29821
- context2.shadowOffsetY = Math.sin(shadowOptions.angle) * dropShadowDistance;
29822
- } else {
29823
- context2.shadowColor = "black";
29824
- context2.shadowBlur = 0;
29825
- context2.shadowOffsetX = 0;
29826
- context2.shadowOffsetY = 0;
29827
- }
29828
- }
29829
- _drawGlyph(context2, metrics, x2, y2, fontScale, style) {
29830
- const char = metrics.text;
29831
- const fontProperties = metrics.fontProperties;
29832
- const stroke = style._stroke;
29833
- const strokeThickness = (stroke?.width ?? 0) * fontScale;
29834
- const tx = x2 + strokeThickness / 2;
29835
- const ty = y2 - strokeThickness / 2;
29836
- const descent = fontProperties.descent * fontScale;
29837
- const lineHeight = metrics.lineHeight * fontScale;
29838
- let removeShadow = false;
29839
- if (style.stroke && strokeThickness) {
29840
- removeShadow = true;
29841
- context2.strokeText(char, tx, ty + lineHeight - descent);
29842
- }
29843
- const { shadowBlur, shadowOffsetX, shadowOffsetY } = context2;
29844
- if (style._fill) {
29845
- if (removeShadow) {
29846
- context2.shadowBlur = 0;
29847
- context2.shadowOffsetX = 0;
29848
- context2.shadowOffsetY = 0;
29849
- }
29850
- context2.fillText(char, tx, ty + lineHeight - descent);
29851
- }
29852
- if (removeShadow) {
29853
- context2.shadowBlur = shadowBlur;
29854
- context2.shadowOffsetX = shadowOffsetX;
29855
- context2.shadowOffsetY = shadowOffsetY;
29856
- }
29857
- }
29858
- destroy() {
29859
- super.destroy();
29860
- for (let i2 = 0;i2 < this.pages.length; i2++) {
29861
- const { canvasAndContext, texture } = this.pages[i2];
29862
- CanvasPool.returnCanvasAndContext(canvasAndContext);
29863
- texture.destroy(true);
29864
- }
29865
- this.pages = null;
29866
- }
29867
- };
29868
- _DynamicBitmapFont.defaultOptions = {
29869
- textureSize: 512,
29870
- style: new TextStyle,
29871
- mipmap: true
29872
- };
29873
- DynamicBitmapFont = _DynamicBitmapFont;
29874
- });
29566
+ // node_modules/pixi.js/lib/environment-webworker/webworkerExt.mjs
29567
+ init_Extensions();
29568
+ var webworkerExt = {
29569
+ extension: {
29570
+ type: ExtensionType.Environment,
29571
+ name: "webworker",
29572
+ priority: 0
29573
+ },
29574
+ test: () => typeof self !== "undefined" && self.WorkerGlobalScope !== undefined,
29575
+ load: async () => {
29576
+ await Promise.resolve().then(() => (init_webworkerAll(), exports_webworkerAll));
29577
+ }
29578
+ };
29875
29579
 
29876
- // node_modules/pixi.js/lib/scene/text-bitmap/utils/getBitmapTextLayout.mjs
29877
- function getBitmapTextLayout(chars, style, font, trimEnd) {
29878
- const layoutData = {
29879
- width: 0,
29880
- height: 0,
29881
- offsetY: 0,
29882
- scale: style.fontSize / font.baseMeasurementFontSize,
29883
- lines: [{
29884
- width: 0,
29885
- charPositions: [],
29886
- spaceWidth: 0,
29887
- spacesIndex: [],
29888
- chars: []
29889
- }]
29890
- };
29891
- layoutData.offsetY = font.baseLineOffset;
29892
- let currentLine = layoutData.lines[0];
29893
- let previousChar = null;
29894
- let firstWord = true;
29895
- const currentWord = {
29896
- spaceWord: false,
29897
- width: 0,
29898
- start: 0,
29899
- index: 0,
29900
- positions: [],
29901
- chars: []
29902
- };
29903
- const scale = font.baseMeasurementFontSize / style.fontSize;
29904
- const adjustedLetterSpacing = style.letterSpacing * scale;
29905
- const adjustedWordWrapWidth = style.wordWrapWidth * scale;
29906
- const adjustedLineHeight = style.lineHeight ? style.lineHeight * scale : font.lineHeight;
29907
- const breakWords = style.wordWrap && style.breakWords;
29908
- const nextWord = (word) => {
29909
- const start = currentLine.width;
29910
- for (let j2 = 0;j2 < currentWord.index; j2++) {
29911
- const position = word.positions[j2];
29912
- currentLine.chars.push(word.chars[j2]);
29913
- currentLine.charPositions.push(position + start);
29914
- }
29915
- currentLine.width += word.width;
29916
- firstWord = false;
29917
- currentWord.width = 0;
29918
- currentWord.index = 0;
29919
- currentWord.chars.length = 0;
29920
- };
29921
- const nextLine = () => {
29922
- let index = currentLine.chars.length - 1;
29923
- if (trimEnd) {
29924
- let lastChar = currentLine.chars[index];
29925
- while (lastChar === " ") {
29926
- currentLine.width -= font.chars[lastChar].xAdvance;
29927
- lastChar = currentLine.chars[--index];
29928
- }
29929
- }
29930
- layoutData.width = Math.max(layoutData.width, currentLine.width);
29931
- currentLine = {
29932
- width: 0,
29933
- charPositions: [],
29934
- chars: [],
29935
- spaceWidth: 0,
29936
- spacesIndex: []
29580
+ // node_modules/pixi.js/lib/index.mjs
29581
+ init_Extensions();
29582
+ init_init4();
29583
+ init_init3();
29584
+
29585
+ // node_modules/pixi.js/lib/app/Application.mjs
29586
+ init_Extensions();
29587
+
29588
+ // node_modules/pixi.js/lib/utils/browser/isWebGLSupported.mjs
29589
+ init_adapter();
29590
+ init_AbstractRenderer();
29591
+ var _isWebGLSupported;
29592
+ function isWebGLSupported(failIfMajorPerformanceCaveat) {
29593
+ if (_isWebGLSupported !== undefined)
29594
+ return _isWebGLSupported;
29595
+ _isWebGLSupported = (() => {
29596
+ const contextOptions = {
29597
+ stencil: true,
29598
+ failIfMajorPerformanceCaveat: failIfMajorPerformanceCaveat ?? AbstractRenderer.defaultOptions.failIfMajorPerformanceCaveat
29937
29599
  };
29938
- firstWord = true;
29939
- layoutData.lines.push(currentLine);
29940
- layoutData.height += adjustedLineHeight;
29941
- };
29942
- const checkIsOverflow = (lineWidth) => lineWidth - adjustedLetterSpacing > adjustedWordWrapWidth;
29943
- for (let i2 = 0;i2 < chars.length + 1; i2++) {
29944
- let char;
29945
- const isEnd = i2 === chars.length;
29946
- if (!isEnd) {
29947
- char = chars[i2];
29948
- }
29949
- const charData = font.chars[char] || font.chars[" "];
29950
- const isSpace = /(?:\s)/.test(char);
29951
- const isWordBreak = isSpace || char === "\r" || char === `
29952
- ` || isEnd;
29953
- if (isWordBreak) {
29954
- const addWordToNextLine = !firstWord && style.wordWrap && checkIsOverflow(currentLine.width + currentWord.width);
29955
- if (addWordToNextLine) {
29956
- nextLine();
29957
- nextWord(currentWord);
29958
- if (!isEnd) {
29959
- currentLine.charPositions.push(0);
29960
- }
29961
- } else {
29962
- currentWord.start = currentLine.width;
29963
- nextWord(currentWord);
29964
- if (!isEnd) {
29965
- currentLine.charPositions.push(0);
29966
- }
29967
- }
29968
- if (char === "\r" || char === `
29969
- `) {
29970
- nextLine();
29971
- } else if (!isEnd) {
29972
- const spaceWidth = charData.xAdvance + (charData.kerning[previousChar] || 0) + adjustedLetterSpacing;
29973
- currentLine.width += spaceWidth;
29974
- currentLine.spaceWidth = spaceWidth;
29975
- currentLine.spacesIndex.push(currentLine.charPositions.length);
29976
- currentLine.chars.push(char);
29600
+ try {
29601
+ if (!DOMAdapter.get().getWebGLRenderingContext()) {
29602
+ return false;
29977
29603
  }
29978
- } else {
29979
- const kerning = charData.kerning[previousChar] || 0;
29980
- const nextCharWidth = charData.xAdvance + kerning + adjustedLetterSpacing;
29981
- const addWordToNextLine = breakWords && checkIsOverflow(currentLine.width + currentWord.width + nextCharWidth);
29982
- if (addWordToNextLine) {
29983
- nextWord(currentWord);
29984
- nextLine();
29604
+ const canvas = DOMAdapter.get().createCanvas();
29605
+ let gl = canvas.getContext("webgl", contextOptions);
29606
+ const success = !!gl?.getContextAttributes()?.stencil;
29607
+ if (gl) {
29608
+ const loseContext = gl.getExtension("WEBGL_lose_context");
29609
+ if (loseContext) {
29610
+ loseContext.loseContext();
29611
+ }
29985
29612
  }
29986
- currentWord.positions[currentWord.index++] = currentWord.width + kerning;
29987
- currentWord.chars.push(char);
29988
- currentWord.width += nextCharWidth;
29989
- }
29990
- previousChar = char;
29991
- }
29992
- nextLine();
29993
- if (style.align === "center") {
29994
- alignCenter(layoutData);
29995
- } else if (style.align === "right") {
29996
- alignRight(layoutData);
29997
- } else if (style.align === "justify") {
29998
- alignJustify(layoutData);
29999
- }
30000
- return layoutData;
30001
- }
30002
- function alignCenter(measurementData) {
30003
- for (let i2 = 0;i2 < measurementData.lines.length; i2++) {
30004
- const line = measurementData.lines[i2];
30005
- const offset = measurementData.width / 2 - line.width / 2;
30006
- for (let j2 = 0;j2 < line.charPositions.length; j2++) {
30007
- line.charPositions[j2] += offset;
30008
- }
30009
- }
30010
- }
30011
- function alignRight(measurementData) {
30012
- for (let i2 = 0;i2 < measurementData.lines.length; i2++) {
30013
- const line = measurementData.lines[i2];
30014
- const offset = measurementData.width - line.width;
30015
- for (let j2 = 0;j2 < line.charPositions.length; j2++) {
30016
- line.charPositions[j2] += offset;
30017
- }
30018
- }
30019
- }
30020
- function alignJustify(measurementData) {
30021
- const width = measurementData.width;
30022
- for (let i2 = 0;i2 < measurementData.lines.length; i2++) {
30023
- const line = measurementData.lines[i2];
30024
- let indy = 0;
30025
- let spaceIndex = line.spacesIndex[indy++];
30026
- let offset = 0;
30027
- const totalSpaces = line.spacesIndex.length;
30028
- const newSpaceWidth = (width - line.width) / totalSpaces;
30029
- const spaceWidth = newSpaceWidth;
30030
- for (let j2 = 0;j2 < line.charPositions.length; j2++) {
30031
- if (j2 === spaceIndex) {
30032
- spaceIndex = line.spacesIndex[indy++];
30033
- offset += spaceWidth;
30034
- }
30035
- line.charPositions[j2] += offset;
30036
- }
30037
- }
30038
- }
30039
- var init_getBitmapTextLayout = () => {};
30040
-
30041
- // node_modules/pixi.js/lib/scene/text-bitmap/utils/resolveCharacters.mjs
30042
- function resolveCharacters(chars) {
30043
- if (chars === "") {
30044
- return [];
30045
- }
30046
- if (typeof chars === "string") {
30047
- chars = [chars];
30048
- }
30049
- const result = [];
30050
- for (let i2 = 0, j2 = chars.length;i2 < j2; i2++) {
30051
- const item = chars[i2];
30052
- if (Array.isArray(item)) {
30053
- if (item.length !== 2) {
30054
- throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${item.length}.`);
30055
- }
30056
- if (item[0].length === 0 || item[1].length === 0) {
30057
- throw new Error("[BitmapFont]: Invalid character delimiter.");
30058
- }
30059
- const startCode = item[0].charCodeAt(0);
30060
- const endCode = item[1].charCodeAt(0);
30061
- if (endCode < startCode) {
30062
- throw new Error("[BitmapFont]: Invalid character range.");
30063
- }
30064
- for (let i22 = startCode, j22 = endCode;i22 <= j22; i22++) {
30065
- result.push(String.fromCharCode(i22));
30066
- }
30067
- } else {
30068
- result.push(...Array.from(item));
30069
- }
30070
- }
30071
- if (result.length === 0) {
30072
- throw new Error("[BitmapFont]: Empty set when resolving characters.");
30073
- }
30074
- return result;
30075
- }
30076
- var init_resolveCharacters = () => {};
30077
-
30078
- // node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.mjs
30079
- class BitmapFontManagerClass {
30080
- constructor() {
30081
- this.ALPHA = [["a", "z"], ["A", "Z"], " "];
30082
- this.NUMERIC = [["0", "9"]];
30083
- this.ALPHANUMERIC = [["a", "z"], ["A", "Z"], ["0", "9"], " "];
30084
- this.ASCII = [[" ", "~"]];
30085
- this.defaultOptions = {
30086
- chars: this.ALPHANUMERIC,
30087
- resolution: 1,
30088
- padding: 4,
30089
- skipKerning: false,
30090
- textureStyle: null
30091
- };
30092
- this.measureCache = lru(1000);
30093
- }
30094
- getFont(text, style) {
30095
- let fontFamilyKey = `${style.fontFamily}-bitmap`;
30096
- let overrideFill = true;
30097
- if (style._fill.fill && !style._stroke) {
30098
- fontFamilyKey += style._fill.fill.styleKey;
30099
- overrideFill = false;
30100
- } else if (style._stroke || style.dropShadow) {
30101
- fontFamilyKey = `${style.styleKey}-bitmap`;
30102
- overrideFill = false;
30103
- }
30104
- if (!Cache.has(fontFamilyKey)) {
30105
- const styleCopy = Object.create(style);
30106
- styleCopy._lineHeight = 0;
30107
- const fnt = new DynamicBitmapFont({
30108
- style: styleCopy,
30109
- overrideFill,
30110
- overrideSize: true,
30111
- ...this.defaultOptions
30112
- });
30113
- fontCount++;
30114
- if (fontCount > 50) {
30115
- warn("BitmapText", `You have dynamically created ${fontCount} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``);
30116
- }
30117
- fnt.once("destroy", () => {
30118
- fontCount--;
30119
- Cache.remove(fontFamilyKey);
30120
- });
30121
- Cache.set(fontFamilyKey, fnt);
30122
- }
30123
- const dynamicFont = Cache.get(fontFamilyKey);
30124
- dynamicFont.ensureCharacters?.(text);
30125
- return dynamicFont;
30126
- }
30127
- getLayout(text, style, trimEnd = true) {
30128
- const bitmapFont = this.getFont(text, style);
30129
- const id = `${text}-${style.styleKey}-${trimEnd}`;
30130
- if (this.measureCache.has(id)) {
30131
- return this.measureCache.get(id);
30132
- }
30133
- const segments = CanvasTextMetrics.graphemeSegmenter(text);
30134
- const layoutData = getBitmapTextLayout(segments, style, bitmapFont, trimEnd);
30135
- this.measureCache.set(id, layoutData);
30136
- return layoutData;
30137
- }
30138
- measureText(text, style, trimEnd = true) {
30139
- return this.getLayout(text, style, trimEnd);
30140
- }
30141
- install(...args) {
30142
- let options = args[0];
30143
- if (typeof options === "string") {
30144
- options = {
30145
- name: options,
30146
- style: args[1],
30147
- chars: args[2]?.chars,
30148
- resolution: args[2]?.resolution,
30149
- padding: args[2]?.padding,
30150
- skipKerning: args[2]?.skipKerning
30151
- };
30152
- deprecation(v8_0_0, "BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})");
30153
- }
30154
- const name = options?.name;
30155
- if (!name) {
30156
- throw new Error("[BitmapFontManager] Property `name` is required.");
30157
- }
30158
- options = { ...this.defaultOptions, ...options };
30159
- const textStyle = options.style;
30160
- const style = textStyle instanceof TextStyle ? textStyle : new TextStyle(textStyle);
30161
- const overrideFill = options.dynamicFill ?? this._canUseTintForStyle(style);
30162
- const font = new DynamicBitmapFont({
30163
- style,
30164
- overrideFill,
30165
- skipKerning: options.skipKerning,
30166
- padding: options.padding,
30167
- resolution: options.resolution,
30168
- overrideSize: false,
30169
- textureStyle: options.textureStyle
30170
- });
30171
- const flatChars = resolveCharacters(options.chars);
30172
- font.ensureCharacters(flatChars.join(""));
30173
- Cache.set(`${name}-bitmap`, font);
30174
- font.once("destroy", () => Cache.remove(`${name}-bitmap`));
30175
- return font;
30176
- }
30177
- uninstall(name) {
30178
- const cacheKey = `${name}-bitmap`;
30179
- const font = Cache.get(cacheKey);
30180
- if (font) {
30181
- font.destroy();
30182
- }
30183
- }
30184
- _canUseTintForStyle(style) {
30185
- return !style._stroke && (!style.dropShadow || style.dropShadow.color === 0) && !style._fill.fill && style._fill.color === 16777215;
30186
- }
30187
- }
30188
- var fontCount = 0, BitmapFontManager;
30189
- var init_BitmapFontManager = __esm(() => {
30190
- init_tiny_lru();
30191
- init_Cache();
30192
- init_deprecation();
30193
- init_warn();
30194
- init_CanvasTextMetrics();
30195
- init_TextStyle();
30196
- init_DynamicBitmapFont();
30197
- init_getBitmapTextLayout();
30198
- init_resolveCharacters();
30199
- BitmapFontManager = new BitmapFontManagerClass;
30200
- });
30201
-
30202
- // node_modules/pixi.js/lib/scene/text-bitmap/BitmapFont.mjs
30203
- var exports_BitmapFont = {};
30204
- __export(exports_BitmapFont, {
30205
- BitmapFont: () => BitmapFont
30206
- });
30207
- var BitmapFont;
30208
- var init_BitmapFont = __esm(() => {
30209
- init_groupD8();
30210
- init_Rectangle();
30211
- init_Texture();
30212
- init_AbstractBitmapFont();
30213
- init_BitmapFontManager();
30214
- BitmapFont = class BitmapFont extends AbstractBitmapFont {
30215
- constructor(options, url) {
30216
- super();
30217
- const { textures, data } = options;
30218
- Object.keys(data.pages).forEach((key) => {
30219
- const pageData = data.pages[parseInt(key, 10)];
30220
- const texture = textures[pageData.id];
30221
- this.pages.push({ texture });
30222
- });
30223
- Object.keys(data.chars).forEach((key) => {
30224
- const charData = data.chars[key];
30225
- const {
30226
- frame: textureFrame,
30227
- source: textureSource,
30228
- rotate: textureRotate
30229
- } = textures[charData.page];
30230
- const frame = groupD8.transformRectCoords(charData, textureFrame, textureRotate, new Rectangle);
30231
- const texture = new Texture({
30232
- frame,
30233
- orig: new Rectangle(0, 0, charData.width, charData.height),
30234
- source: textureSource,
30235
- rotate: textureRotate
30236
- });
30237
- this.chars[key] = {
30238
- id: key.codePointAt(0),
30239
- xOffset: charData.xOffset,
30240
- yOffset: charData.yOffset,
30241
- xAdvance: charData.xAdvance,
30242
- kerning: charData.kerning ?? {},
30243
- texture
30244
- };
30245
- });
30246
- this.baseRenderedFontSize = data.fontSize;
30247
- this.baseMeasurementFontSize = data.fontSize;
30248
- this.fontMetrics = {
30249
- ascent: 0,
30250
- descent: 0,
30251
- fontSize: data.fontSize
30252
- };
30253
- this.baseLineOffset = data.baseLineOffset;
30254
- this.lineHeight = data.lineHeight;
30255
- this.fontFamily = data.fontFamily;
30256
- this.distanceField = data.distanceField ?? {
30257
- type: "none",
30258
- range: 0
30259
- };
30260
- this.url = url;
30261
- }
30262
- destroy() {
30263
- super.destroy();
30264
- for (let i2 = 0;i2 < this.pages.length; i2++) {
30265
- const { texture } = this.pages[i2];
30266
- texture.destroy(true);
30267
- }
30268
- this.pages = null;
30269
- }
30270
- static install(options) {
30271
- BitmapFontManager.install(options);
30272
- }
30273
- static uninstall(name) {
30274
- BitmapFontManager.uninstall(name);
30275
- }
30276
- };
30277
- });
30278
-
30279
- // node_modules/pixi.js/lib/environment-browser/browserExt.mjs
30280
- init_Extensions();
30281
- var browserExt = {
30282
- extension: {
30283
- type: ExtensionType.Environment,
30284
- name: "browser",
30285
- priority: -1
30286
- },
30287
- test: () => true,
30288
- load: async () => {
30289
- await Promise.resolve().then(() => (init_browserAll(), exports_browserAll));
30290
- }
30291
- };
30292
-
30293
- // node_modules/pixi.js/lib/environment-webworker/webworkerExt.mjs
30294
- init_Extensions();
30295
- var webworkerExt = {
30296
- extension: {
30297
- type: ExtensionType.Environment,
30298
- name: "webworker",
30299
- priority: 0
30300
- },
30301
- test: () => typeof self !== "undefined" && self.WorkerGlobalScope !== undefined,
30302
- load: async () => {
30303
- await Promise.resolve().then(() => (init_webworkerAll(), exports_webworkerAll));
30304
- }
30305
- };
30306
-
30307
- // node_modules/pixi.js/lib/index.mjs
30308
- init_Extensions();
30309
- init_init4();
30310
- init_init3();
30311
-
30312
- // node_modules/pixi.js/lib/app/Application.mjs
30313
- init_Extensions();
30314
-
30315
- // node_modules/pixi.js/lib/utils/browser/isWebGLSupported.mjs
30316
- init_adapter();
30317
- init_AbstractRenderer();
30318
- var _isWebGLSupported;
30319
- function isWebGLSupported(failIfMajorPerformanceCaveat) {
30320
- if (_isWebGLSupported !== undefined)
30321
- return _isWebGLSupported;
30322
- _isWebGLSupported = (() => {
30323
- const contextOptions = {
30324
- stencil: true,
30325
- failIfMajorPerformanceCaveat: failIfMajorPerformanceCaveat ?? AbstractRenderer.defaultOptions.failIfMajorPerformanceCaveat
30326
- };
30327
- try {
30328
- if (!DOMAdapter.get().getWebGLRenderingContext()) {
30329
- return false;
30330
- }
30331
- const canvas = DOMAdapter.get().createCanvas();
30332
- let gl = canvas.getContext("webgl", contextOptions);
30333
- const success = !!gl?.getContextAttributes()?.stencil;
30334
- if (gl) {
30335
- const loseContext = gl.getExtension("WEBGL_lose_context");
30336
- if (loseContext) {
30337
- loseContext.loseContext();
30338
- }
30339
- }
30340
- gl = null;
30341
- return success;
30342
- } catch (_e) {
30343
- return false;
29613
+ gl = null;
29614
+ return success;
29615
+ } catch (_e) {
29616
+ return false;
30344
29617
  }
30345
29618
  })();
30346
29619
  return _isWebGLSupported;
@@ -30400,1794 +29673,191 @@ async function autoDetectRenderer(options) {
30400
29673
  } else if (rendererType === "canvas") {
30401
29674
  const { CanvasRenderer: CanvasRenderer2 } = await Promise.resolve().then(() => (init_CanvasRenderer(), exports_CanvasRenderer));
30402
29675
  RendererClass = CanvasRenderer2;
30403
- finalOptions = { ...options, ...options.canvasOptions };
30404
- break;
30405
- }
30406
- }
30407
- delete finalOptions.webgpu;
30408
- delete finalOptions.webgl;
30409
- delete finalOptions.canvasOptions;
30410
- if (!RendererClass) {
30411
- throw new Error("No available renderer for the current environment");
30412
- }
30413
- const renderer = new RendererClass;
30414
- await renderer.init(finalOptions);
30415
- return renderer;
30416
- }
30417
-
30418
- // node_modules/pixi.js/lib/app/Application.mjs
30419
- init_Container();
30420
- init_globalHooks();
30421
- init_deprecation();
30422
-
30423
- // node_modules/pixi.js/lib/app/init.mjs
30424
- init_Extensions();
30425
-
30426
- // node_modules/pixi.js/lib/app/ResizePlugin.mjs
30427
- init_Extensions();
30428
-
30429
- class ResizePlugin {
30430
- static init(options) {
30431
- Object.defineProperty(this, "resizeTo", {
30432
- configurable: true,
30433
- set(dom) {
30434
- globalThis.removeEventListener("resize", this.queueResize);
30435
- this._resizeTo = dom;
30436
- if (dom) {
30437
- globalThis.addEventListener("resize", this.queueResize);
30438
- this.resize();
30439
- }
30440
- },
30441
- get() {
30442
- return this._resizeTo;
30443
- }
30444
- });
30445
- this.queueResize = () => {
30446
- if (!this._resizeTo) {
30447
- return;
30448
- }
30449
- this._cancelResize();
30450
- this._resizeId = requestAnimationFrame(() => this.resize());
30451
- };
30452
- this._cancelResize = () => {
30453
- if (this._resizeId) {
30454
- cancelAnimationFrame(this._resizeId);
30455
- this._resizeId = null;
30456
- }
30457
- };
30458
- this.resize = () => {
30459
- if (!this._resizeTo) {
30460
- return;
30461
- }
30462
- this._cancelResize();
30463
- let width;
30464
- let height;
30465
- if (this._resizeTo === globalThis.window) {
30466
- width = globalThis.innerWidth;
30467
- height = globalThis.innerHeight;
30468
- } else {
30469
- const { clientWidth, clientHeight } = this._resizeTo;
30470
- width = clientWidth;
30471
- height = clientHeight;
30472
- }
30473
- this.renderer.resize(width, height);
30474
- this.render();
30475
- };
30476
- this._resizeId = null;
30477
- this._resizeTo = null;
30478
- this.resizeTo = options.resizeTo || null;
30479
- }
30480
- static destroy() {
30481
- globalThis.removeEventListener("resize", this.queueResize);
30482
- this._cancelResize();
30483
- this._cancelResize = null;
30484
- this.queueResize = null;
30485
- this.resizeTo = null;
30486
- this.resize = null;
30487
- }
30488
- }
30489
- ResizePlugin.extension = ExtensionType.Application;
30490
-
30491
- // node_modules/pixi.js/lib/app/TickerPlugin.mjs
30492
- init_Extensions();
30493
- init_const2();
30494
- init_Ticker();
30495
-
30496
- class TickerPlugin {
30497
- static init(options) {
30498
- options = Object.assign({
30499
- autoStart: true,
30500
- sharedTicker: false
30501
- }, options);
30502
- Object.defineProperty(this, "ticker", {
30503
- configurable: true,
30504
- set(ticker) {
30505
- if (this._ticker) {
30506
- this._ticker.remove(this.render, this);
30507
- }
30508
- this._ticker = ticker;
30509
- if (ticker) {
30510
- ticker.add(this.render, this, UPDATE_PRIORITY.LOW);
30511
- }
30512
- },
30513
- get() {
30514
- return this._ticker;
30515
- }
30516
- });
30517
- this.stop = () => {
30518
- this._ticker.stop();
30519
- };
30520
- this.start = () => {
30521
- this._ticker.start();
30522
- };
30523
- this._ticker = null;
30524
- this.ticker = options.sharedTicker ? Ticker.shared : new Ticker;
30525
- if (options.autoStart) {
30526
- this.start();
30527
- }
30528
- }
30529
- static destroy() {
30530
- if (this._ticker) {
30531
- const oldTicker = this._ticker;
30532
- this.ticker = null;
30533
- oldTicker.destroy();
30534
- }
30535
- }
30536
- }
30537
- TickerPlugin.extension = ExtensionType.Application;
30538
-
30539
- // node_modules/pixi.js/lib/app/init.mjs
30540
- extensions.add(ResizePlugin);
30541
- extensions.add(TickerPlugin);
30542
-
30543
- // node_modules/pixi.js/lib/app/Application.mjs
30544
- var _Application = class _Application2 {
30545
- constructor(...args) {
30546
- this.stage = new Container;
30547
- if (args[0] !== undefined) {
30548
- deprecation(v8_0_0, "Application constructor options are deprecated, please use Application.init() instead.");
30549
- }
30550
- }
30551
- async init(options) {
30552
- options = { ...options };
30553
- this.stage || (this.stage = new Container);
30554
- this.renderer = await autoDetectRenderer(options);
30555
- _Application2._plugins.forEach((plugin) => {
30556
- plugin.init.call(this, options);
30557
- });
30558
- }
30559
- render() {
30560
- this.renderer.render({ container: this.stage });
30561
- }
30562
- get canvas() {
30563
- return this.renderer.canvas;
30564
- }
30565
- get view() {
30566
- deprecation(v8_0_0, "Application.view is deprecated, please use Application.canvas instead.");
30567
- return this.renderer.canvas;
30568
- }
30569
- get screen() {
30570
- return this.renderer.screen;
30571
- }
30572
- destroy(rendererDestroyOptions = false, options = false) {
30573
- const plugins = _Application2._plugins.slice(0);
30574
- plugins.reverse();
30575
- plugins.forEach((plugin) => {
30576
- plugin.destroy.call(this);
30577
- });
30578
- this.stage.destroy(options);
30579
- this.stage = null;
30580
- this.renderer.destroy(rendererDestroyOptions);
30581
- this.renderer = null;
30582
- }
30583
- };
30584
- _Application._plugins = [];
30585
- var Application = _Application;
30586
- extensions.handleByList(ExtensionType.Application, Application._plugins);
30587
- extensions.add(ApplicationInitHook);
30588
-
30589
- // node_modules/pixi.js/lib/assets/Assets.mjs
30590
- init_Extensions();
30591
-
30592
- // node_modules/pixi.js/lib/scene/text-bitmap/asset/loadBitmapFont.mjs
30593
- init_LoaderParser();
30594
- init_copySearchParams();
30595
- init_adapter();
30596
- init_Extensions();
30597
- init_path();
30598
-
30599
- // node_modules/pixi.js/lib/scene/text-bitmap/asset/bitmapFontTextParser.mjs
30600
- var bitmapFontTextParser = {
30601
- test(data) {
30602
- return typeof data === "string" && data.startsWith("info face=");
30603
- },
30604
- parse(txt) {
30605
- const items = txt.match(/^[a-z]+\s+.+$/gm);
30606
- const rawData = {
30607
- info: [],
30608
- common: [],
30609
- page: [],
30610
- char: [],
30611
- chars: [],
30612
- kerning: [],
30613
- kernings: [],
30614
- distanceField: []
30615
- };
30616
- for (const i2 in items) {
30617
- const name = items[i2].match(/^[a-z]+/gm)[0];
30618
- const attributeList = items[i2].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm);
30619
- const itemData = {};
30620
- for (const i22 in attributeList) {
30621
- const split = attributeList[i22].split("=");
30622
- const key = split[0];
30623
- const strValue = split[1].replace(/"/gm, "");
30624
- const floatValue = parseFloat(strValue);
30625
- const value = isNaN(floatValue) ? strValue : floatValue;
30626
- itemData[key] = value;
30627
- }
30628
- rawData[name].push(itemData);
30629
- }
30630
- const font = {
30631
- chars: {},
30632
- pages: [],
30633
- lineHeight: 0,
30634
- fontSize: 0,
30635
- fontFamily: "",
30636
- distanceField: null,
30637
- baseLineOffset: 0
30638
- };
30639
- const [info] = rawData.info;
30640
- const [common] = rawData.common;
30641
- const [distanceField] = rawData.distanceField ?? [];
30642
- if (distanceField) {
30643
- font.distanceField = {
30644
- range: parseInt(distanceField.distanceRange, 10),
30645
- type: distanceField.fieldType
30646
- };
30647
- }
30648
- font.fontSize = parseInt(info.size, 10);
30649
- font.fontFamily = info.face;
30650
- font.lineHeight = parseInt(common.lineHeight, 10);
30651
- const page = rawData.page;
30652
- for (let i2 = 0;i2 < page.length; i2++) {
30653
- font.pages.push({
30654
- id: parseInt(page[i2].id, 10) || 0,
30655
- file: page[i2].file
30656
- });
30657
- }
30658
- const map = {};
30659
- font.baseLineOffset = font.lineHeight - parseInt(common.base, 10);
30660
- const char = rawData.char;
30661
- for (let i2 = 0;i2 < char.length; i2++) {
30662
- const charNode = char[i2];
30663
- const id = parseInt(charNode.id, 10);
30664
- let letter = charNode.letter ?? charNode.char ?? String.fromCharCode(id);
30665
- if (letter === "space")
30666
- letter = " ";
30667
- map[id] = letter;
30668
- font.chars[letter] = {
30669
- id,
30670
- page: parseInt(charNode.page, 10) || 0,
30671
- x: parseInt(charNode.x, 10),
30672
- y: parseInt(charNode.y, 10),
30673
- width: parseInt(charNode.width, 10),
30674
- height: parseInt(charNode.height, 10),
30675
- xOffset: parseInt(charNode.xoffset, 10),
30676
- yOffset: parseInt(charNode.yoffset, 10),
30677
- xAdvance: parseInt(charNode.xadvance, 10),
30678
- kerning: {}
30679
- };
30680
- }
30681
- const kerning = rawData.kerning || [];
30682
- for (let i2 = 0;i2 < kerning.length; i2++) {
30683
- const first = parseInt(kerning[i2].first, 10);
30684
- const second = parseInt(kerning[i2].second, 10);
30685
- const amount = parseInt(kerning[i2].amount, 10);
30686
- font.chars[map[second]].kerning[map[first]] = amount;
30687
- }
30688
- return font;
30689
- }
30690
- };
30691
-
30692
- // node_modules/pixi.js/lib/scene/text-bitmap/asset/bitmapFontXMLStringParser.mjs
30693
- init_adapter();
30694
-
30695
- // node_modules/pixi.js/lib/scene/text-bitmap/asset/bitmapFontXMLParser.mjs
30696
- var bitmapFontXMLParser = {
30697
- test(data) {
30698
- const xml = data;
30699
- return typeof xml !== "string" && "getElementsByTagName" in xml && xml.getElementsByTagName("page").length && xml.getElementsByTagName("info")[0].getAttribute("face") !== null;
30700
- },
30701
- parse(xml) {
30702
- const data = {
30703
- chars: {},
30704
- pages: [],
30705
- lineHeight: 0,
30706
- fontSize: 0,
30707
- fontFamily: "",
30708
- distanceField: null,
30709
- baseLineOffset: 0
30710
- };
30711
- const info = xml.getElementsByTagName("info")[0];
30712
- const common = xml.getElementsByTagName("common")[0];
30713
- const distanceField = xml.getElementsByTagName("distanceField")[0];
30714
- if (distanceField) {
30715
- data.distanceField = {
30716
- type: distanceField.getAttribute("fieldType"),
30717
- range: parseInt(distanceField.getAttribute("distanceRange"), 10)
30718
- };
30719
- }
30720
- const page = xml.getElementsByTagName("page");
30721
- const char = xml.getElementsByTagName("char");
30722
- const kerning = xml.getElementsByTagName("kerning");
30723
- data.fontSize = parseInt(info.getAttribute("size"), 10);
30724
- data.fontFamily = info.getAttribute("face");
30725
- data.lineHeight = parseInt(common.getAttribute("lineHeight"), 10);
30726
- for (let i2 = 0;i2 < page.length; i2++) {
30727
- data.pages.push({
30728
- id: parseInt(page[i2].getAttribute("id"), 10) || 0,
30729
- file: page[i2].getAttribute("file")
30730
- });
30731
- }
30732
- const map = {};
30733
- data.baseLineOffset = data.lineHeight - parseInt(common.getAttribute("base"), 10);
30734
- for (let i2 = 0;i2 < char.length; i2++) {
30735
- const charNode = char[i2];
30736
- const id = parseInt(charNode.getAttribute("id"), 10);
30737
- let letter = charNode.getAttribute("letter") ?? charNode.getAttribute("char") ?? String.fromCharCode(id);
30738
- if (letter === "space")
30739
- letter = " ";
30740
- map[id] = letter;
30741
- data.chars[letter] = {
30742
- id,
30743
- page: parseInt(charNode.getAttribute("page"), 10) || 0,
30744
- x: parseInt(charNode.getAttribute("x"), 10),
30745
- y: parseInt(charNode.getAttribute("y"), 10),
30746
- width: parseInt(charNode.getAttribute("width"), 10),
30747
- height: parseInt(charNode.getAttribute("height"), 10),
30748
- xOffset: parseInt(charNode.getAttribute("xoffset"), 10),
30749
- yOffset: parseInt(charNode.getAttribute("yoffset"), 10),
30750
- xAdvance: parseInt(charNode.getAttribute("xadvance"), 10),
30751
- kerning: {}
30752
- };
30753
- }
30754
- for (let i2 = 0;i2 < kerning.length; i2++) {
30755
- const first = parseInt(kerning[i2].getAttribute("first"), 10);
30756
- const second = parseInt(kerning[i2].getAttribute("second"), 10);
30757
- const amount = parseInt(kerning[i2].getAttribute("amount"), 10);
30758
- data.chars[map[second]].kerning[map[first]] = amount;
30759
- }
30760
- return data;
30761
- }
30762
- };
30763
-
30764
- // node_modules/pixi.js/lib/scene/text-bitmap/asset/bitmapFontXMLStringParser.mjs
30765
- var bitmapFontXMLStringParser = {
30766
- test(data) {
30767
- if (typeof data === "string" && data.match(/<font(\s|>)/)) {
30768
- return bitmapFontXMLParser.test(DOMAdapter.get().parseXML(data));
30769
- }
30770
- return false;
30771
- },
30772
- parse(data) {
30773
- return bitmapFontXMLParser.parse(DOMAdapter.get().parseXML(data));
30774
- }
30775
- };
30776
-
30777
- // node_modules/pixi.js/lib/scene/text-bitmap/asset/loadBitmapFont.mjs
30778
- var validExtensions = [".xml", ".fnt"];
30779
- var bitmapFontCachePlugin = {
30780
- extension: {
30781
- type: ExtensionType.CacheParser,
30782
- name: "cacheBitmapFont"
30783
- },
30784
- test: (asset) => !!asset?.pages && !!asset?.chars && typeof asset?.fontFamily === "string",
30785
- getCacheableAssets(keys, asset) {
30786
- const out2 = {};
30787
- keys.forEach((key) => {
30788
- out2[key] = asset;
30789
- out2[`${key}-bitmap`] = asset;
30790
- });
30791
- out2[`${asset.fontFamily}-bitmap`] = asset;
30792
- return out2;
30793
- }
30794
- };
30795
- var loadBitmapFont = {
30796
- extension: {
30797
- type: ExtensionType.LoadParser,
30798
- priority: LoaderParserPriority.Normal
30799
- },
30800
- name: "loadBitmapFont",
30801
- id: "bitmap-font",
30802
- test(url) {
30803
- return validExtensions.includes(path.extname(url).toLowerCase());
30804
- },
30805
- async testParse(data) {
30806
- return bitmapFontTextParser.test(data) || bitmapFontXMLStringParser.test(data);
30807
- },
30808
- async parse(asset, data, loader) {
30809
- const bitmapFontData = bitmapFontTextParser.test(asset) ? bitmapFontTextParser.parse(asset) : bitmapFontXMLStringParser.parse(asset);
30810
- const { src } = data;
30811
- const { pages } = bitmapFontData;
30812
- const textureUrls = [];
30813
- const textureOptions = bitmapFontData.distanceField ? {
30814
- scaleMode: "linear",
30815
- alphaMode: "premultiply-alpha-on-upload",
30816
- autoGenerateMipmaps: false,
30817
- resolution: 1
30818
- } : {};
30819
- for (let i2 = 0;i2 < pages.length; ++i2) {
30820
- const pageFile = pages[i2].file;
30821
- let imagePath = path.join(path.dirname(src), pageFile);
30822
- imagePath = copySearchParams(imagePath, src);
30823
- textureUrls.push({
30824
- src: imagePath,
30825
- data: textureOptions
30826
- });
30827
- }
30828
- const [loadedTextures, { BitmapFont: BitmapFont2 }] = await Promise.all([
30829
- loader.load(textureUrls),
30830
- Promise.resolve().then(() => (init_BitmapFont(), exports_BitmapFont))
30831
- ]);
30832
- const textures = textureUrls.map((url) => loadedTextures[url.src]);
30833
- const bitmapFont = new BitmapFont2({
30834
- data: bitmapFontData,
30835
- textures
30836
- }, src);
30837
- return bitmapFont;
30838
- },
30839
- async load(url, _options) {
30840
- const response = await DOMAdapter.get().fetch(url);
30841
- return await response.text();
30842
- },
30843
- async unload(bitmapFont, _resolvedAsset, loader) {
30844
- await Promise.all(bitmapFont.pages.map((page) => loader.unload(page.texture.source._sourceOrigin)));
30845
- bitmapFont.destroy();
30846
- }
30847
- };
30848
-
30849
- // node_modules/pixi.js/lib/assets/Assets.mjs
30850
- init_warn();
30851
-
30852
- // node_modules/pixi.js/lib/assets/BackgroundLoader.mjs
30853
- class BackgroundLoader {
30854
- constructor(loader, verbose = false) {
30855
- this._loader = loader;
30856
- this._assetList = [];
30857
- this._isLoading = false;
30858
- this._maxConcurrent = 1;
30859
- this.verbose = verbose;
30860
- }
30861
- add(assetUrls) {
30862
- assetUrls.forEach((a2) => {
30863
- this._assetList.push(a2);
30864
- });
30865
- if (this.verbose) {
30866
- console.log("[BackgroundLoader] assets: ", this._assetList);
30867
- }
30868
- if (this._isActive && !this._isLoading) {
30869
- this._next();
30870
- }
30871
- }
30872
- async _next() {
30873
- if (this._assetList.length && this._isActive) {
30874
- this._isLoading = true;
30875
- const toLoad = [];
30876
- const toLoadAmount = Math.min(this._assetList.length, this._maxConcurrent);
30877
- for (let i2 = 0;i2 < toLoadAmount; i2++) {
30878
- toLoad.push(this._assetList.pop());
30879
- }
30880
- await this._loader.load(toLoad);
30881
- this._isLoading = false;
30882
- this._next();
30883
- }
30884
- }
30885
- get active() {
30886
- return this._isActive;
30887
- }
30888
- set active(value) {
30889
- if (this._isActive === value)
30890
- return;
30891
- this._isActive = value;
30892
- if (value && !this._isLoading) {
30893
- this._next();
30894
- }
30895
- }
30896
- }
30897
-
30898
- // node_modules/pixi.js/lib/assets/Assets.mjs
30899
- init_Cache();
30900
-
30901
- // node_modules/pixi.js/lib/assets/cache/parsers/cacheTextureArray.mjs
30902
- init_Extensions();
30903
- init_Texture();
30904
- var cacheTextureArray = {
30905
- extension: {
30906
- type: ExtensionType.CacheParser,
30907
- name: "cacheTextureArray"
30908
- },
30909
- test: (asset) => Array.isArray(asset) && asset.every((t2) => t2 instanceof Texture),
30910
- getCacheableAssets: (keys, asset) => {
30911
- const out2 = {};
30912
- keys.forEach((key) => {
30913
- asset.forEach((item, i2) => {
30914
- out2[key + (i2 === 0 ? "" : i2 + 1)] = item;
30915
- });
30916
- });
30917
- return out2;
30918
- }
30919
- };
30920
-
30921
- // node_modules/pixi.js/lib/assets/detections/parsers/detectAvif.mjs
30922
- init_Extensions();
30923
-
30924
- // node_modules/pixi.js/lib/assets/detections/utils/testImageFormat.mjs
30925
- async function testImageFormat(imageData) {
30926
- if ("Image" in globalThis) {
30927
- return new Promise((resolve) => {
30928
- const image = new Image;
30929
- image.onload = () => {
30930
- resolve(true);
30931
- };
30932
- image.onerror = () => {
30933
- resolve(false);
30934
- };
30935
- image.src = imageData;
30936
- });
30937
- }
30938
- if ("createImageBitmap" in globalThis && "fetch" in globalThis) {
30939
- try {
30940
- const blob = await (await fetch(imageData)).blob();
30941
- await createImageBitmap(blob);
30942
- } catch (_e) {
30943
- return false;
30944
- }
30945
- return true;
30946
- }
30947
- return false;
30948
- }
30949
-
30950
- // node_modules/pixi.js/lib/assets/detections/parsers/detectAvif.mjs
30951
- var detectAvif = {
30952
- extension: {
30953
- type: ExtensionType.DetectionParser,
30954
- priority: 1
30955
- },
30956
- test: async () => testImageFormat("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),
30957
- add: async (formats) => [...formats, "avif"],
30958
- remove: async (formats) => formats.filter((f2) => f2 !== "avif")
30959
- };
30960
-
30961
- // node_modules/pixi.js/lib/assets/detections/parsers/detectDefaults.mjs
30962
- init_Extensions();
30963
- var imageFormats = ["png", "jpg", "jpeg"];
30964
- var detectDefaults = {
30965
- extension: {
30966
- type: ExtensionType.DetectionParser,
30967
- priority: -1
30968
- },
30969
- test: () => Promise.resolve(true),
30970
- add: async (formats) => [...formats, ...imageFormats],
30971
- remove: async (formats) => formats.filter((f2) => !imageFormats.includes(f2))
30972
- };
30973
-
30974
- // node_modules/pixi.js/lib/assets/detections/parsers/detectMp4.mjs
30975
- init_Extensions();
30976
-
30977
- // node_modules/pixi.js/lib/assets/detections/utils/testVideoFormat.mjs
30978
- var inWorker = "WorkerGlobalScope" in globalThis && globalThis instanceof globalThis.WorkerGlobalScope;
30979
- function testVideoFormat(mimeType) {
30980
- if (inWorker) {
30981
- return false;
30982
- }
30983
- const video = document.createElement("video");
30984
- return video.canPlayType(mimeType) !== "";
30985
- }
30986
-
30987
- // node_modules/pixi.js/lib/assets/detections/parsers/detectMp4.mjs
30988
- var detectMp4 = {
30989
- extension: {
30990
- type: ExtensionType.DetectionParser,
30991
- priority: 0
30992
- },
30993
- test: async () => testVideoFormat("video/mp4"),
30994
- add: async (formats) => [...formats, "mp4", "m4v"],
30995
- remove: async (formats) => formats.filter((f2) => f2 !== "mp4" && f2 !== "m4v")
30996
- };
30997
-
30998
- // node_modules/pixi.js/lib/assets/detections/parsers/detectOgv.mjs
30999
- init_Extensions();
31000
- var detectOgv = {
31001
- extension: {
31002
- type: ExtensionType.DetectionParser,
31003
- priority: 0
31004
- },
31005
- test: async () => testVideoFormat("video/ogg"),
31006
- add: async (formats) => [...formats, "ogv"],
31007
- remove: async (formats) => formats.filter((f2) => f2 !== "ogv")
31008
- };
31009
-
31010
- // node_modules/pixi.js/lib/assets/detections/parsers/detectWebm.mjs
31011
- init_Extensions();
31012
- var detectWebm = {
31013
- extension: {
31014
- type: ExtensionType.DetectionParser,
31015
- priority: 0
31016
- },
31017
- test: async () => testVideoFormat("video/webm"),
31018
- add: async (formats) => [...formats, "webm"],
31019
- remove: async (formats) => formats.filter((f2) => f2 !== "webm")
31020
- };
31021
-
31022
- // node_modules/pixi.js/lib/assets/detections/parsers/detectWebp.mjs
31023
- init_Extensions();
31024
- var detectWebp = {
31025
- extension: {
31026
- type: ExtensionType.DetectionParser,
31027
- priority: 0
31028
- },
31029
- test: async () => testImageFormat("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),
31030
- add: async (formats) => [...formats, "webp"],
31031
- remove: async (formats) => formats.filter((f2) => f2 !== "webp")
31032
- };
31033
-
31034
- // node_modules/pixi.js/lib/assets/loader/Loader.mjs
31035
- init_warn();
31036
- init_path();
31037
- init_convertToList();
31038
- init_isSingleItem();
31039
- var _Loader = class _Loader2 {
31040
- constructor() {
31041
- this.loadOptions = { ..._Loader2.defaultOptions };
31042
- this._parsers = [];
31043
- this._parsersValidated = false;
31044
- this.parsers = new Proxy(this._parsers, {
31045
- set: (target, key, value) => {
31046
- this._parsersValidated = false;
31047
- target[key] = value;
31048
- return true;
31049
- }
31050
- });
31051
- this.promiseCache = {};
31052
- }
31053
- reset() {
31054
- this._parsersValidated = false;
31055
- this.promiseCache = {};
31056
- }
31057
- _getLoadPromiseAndParser(url, data) {
31058
- const result = {
31059
- promise: null,
31060
- parser: null
31061
- };
31062
- result.promise = (async () => {
31063
- let asset = null;
31064
- let parser = null;
31065
- if (data.parser || data.loadParser) {
31066
- parser = this._parserHash[data.parser || data.loadParser];
31067
- if (data.loadParser) {
31068
- warn(`[Assets] "loadParser" is deprecated, use "parser" instead for ${url}`);
31069
- }
31070
- if (!parser) {
31071
- warn(`[Assets] specified load parser "${data.parser || data.loadParser}" not found while loading ${url}`);
31072
- }
31073
- }
31074
- if (!parser) {
31075
- for (let i2 = 0;i2 < this.parsers.length; i2++) {
31076
- const parserX = this.parsers[i2];
31077
- if (parserX.load && parserX.test?.(url, data, this)) {
31078
- parser = parserX;
31079
- break;
31080
- }
31081
- }
31082
- if (!parser) {
31083
- warn(`[Assets] ${url} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`);
31084
- return null;
31085
- }
31086
- }
31087
- asset = await parser.load(url, data, this);
31088
- result.parser = parser;
31089
- for (let i2 = 0;i2 < this.parsers.length; i2++) {
31090
- const parser2 = this.parsers[i2];
31091
- if (parser2.parse) {
31092
- if (parser2.parse && await parser2.testParse?.(asset, data, this)) {
31093
- asset = await parser2.parse(asset, data, this) || asset;
31094
- result.parser = parser2;
31095
- }
31096
- }
31097
- }
31098
- return asset;
31099
- })();
31100
- return result;
31101
- }
31102
- async load(assetsToLoadIn, onProgressOrOptions) {
31103
- if (!this._parsersValidated) {
31104
- this._validateParsers();
31105
- }
31106
- const options = typeof onProgressOrOptions === "function" ? { ..._Loader2.defaultOptions, ...this.loadOptions, onProgress: onProgressOrOptions } : { ..._Loader2.defaultOptions, ...this.loadOptions, ...onProgressOrOptions || {} };
31107
- const { onProgress, onError, strategy, retryCount, retryDelay } = options;
31108
- let count2 = 0;
31109
- const assets = {};
31110
- const singleAsset = isSingleItem(assetsToLoadIn);
31111
- const assetsToLoad = convertToList(assetsToLoadIn, (item) => ({
31112
- alias: [item],
31113
- src: item,
31114
- data: {}
31115
- }));
31116
- const total = assetsToLoad.reduce((sum, asset) => sum + (asset.progressSize || 1), 0);
31117
- const promises = assetsToLoad.map(async (asset) => {
31118
- const url = path.toAbsolute(asset.src);
31119
- if (assets[asset.src])
31120
- return;
31121
- await this._loadAssetWithRetry(url, asset, { onProgress, onError, strategy, retryCount, retryDelay }, assets);
31122
- count2 += asset.progressSize || 1;
31123
- if (onProgress)
31124
- onProgress(count2 / total);
31125
- });
31126
- await Promise.all(promises);
31127
- return singleAsset ? assets[assetsToLoad[0].src] : assets;
31128
- }
31129
- async unload(assetsToUnloadIn) {
31130
- const assetsToUnload = convertToList(assetsToUnloadIn, (item) => ({
31131
- alias: [item],
31132
- src: item
31133
- }));
31134
- const promises = assetsToUnload.map(async (asset) => {
31135
- const url = path.toAbsolute(asset.src);
31136
- const loadPromise = this.promiseCache[url];
31137
- if (loadPromise) {
31138
- const loadedAsset = await loadPromise.promise;
31139
- delete this.promiseCache[url];
31140
- await loadPromise.parser?.unload?.(loadedAsset, asset, this);
31141
- }
31142
- });
31143
- await Promise.all(promises);
31144
- }
31145
- _validateParsers() {
31146
- this._parsersValidated = true;
31147
- this._parserHash = this._parsers.filter((parser) => parser.name || parser.id).reduce((hash, parser) => {
31148
- if (!parser.name && !parser.id) {
31149
- warn(`[Assets] parser should have an id`);
31150
- } else if (hash[parser.name] || hash[parser.id]) {
31151
- warn(`[Assets] parser id conflict "${parser.id}"`);
31152
- }
31153
- hash[parser.name] = parser;
31154
- if (parser.id)
31155
- hash[parser.id] = parser;
31156
- return hash;
31157
- }, {});
31158
- }
31159
- async _loadAssetWithRetry(url, asset, options, assets) {
31160
- let attempt = 0;
31161
- const { onError, strategy, retryCount, retryDelay } = options;
31162
- const wait = (ms) => new Promise((r2) => setTimeout(r2, ms));
31163
- while (true) {
31164
- try {
31165
- if (!this.promiseCache[url]) {
31166
- this.promiseCache[url] = this._getLoadPromiseAndParser(url, asset);
31167
- }
31168
- assets[asset.src] = await this.promiseCache[url].promise;
31169
- return;
31170
- } catch (e2) {
31171
- delete this.promiseCache[url];
31172
- delete assets[asset.src];
31173
- attempt++;
31174
- const isLast = strategy !== "retry" || attempt > retryCount;
31175
- if (strategy === "retry" && !isLast) {
31176
- if (onError)
31177
- onError(e2, asset);
31178
- await wait(retryDelay);
31179
- continue;
31180
- }
31181
- if (strategy === "skip") {
31182
- if (onError)
31183
- onError(e2, asset);
31184
- return;
31185
- }
31186
- if (onError)
31187
- onError(e2, asset);
31188
- const error = new Error(`[Loader.load] Failed to load ${url}.
31189
- ${e2}`);
31190
- if (e2 instanceof Error && e2.stack) {
31191
- error.stack = e2.stack;
31192
- }
31193
- throw error;
31194
- }
31195
- }
31196
- }
31197
- };
31198
- _Loader.defaultOptions = {
31199
- onProgress: undefined,
31200
- onError: undefined,
31201
- strategy: "throw",
31202
- retryCount: 3,
31203
- retryDelay: 250
31204
- };
31205
- var Loader = _Loader;
31206
-
31207
- // node_modules/pixi.js/lib/assets/loader/parsers/loadJson.mjs
31208
- init_adapter();
31209
- init_Extensions();
31210
-
31211
- // node_modules/pixi.js/lib/assets/utils/checkDataUrl.mjs
31212
- function checkDataUrl(url, mimes) {
31213
- if (Array.isArray(mimes)) {
31214
- for (const mime of mimes) {
31215
- if (url.startsWith(`data:${mime}`))
31216
- return true;
31217
- }
31218
- return false;
31219
- }
31220
- return url.startsWith(`data:${mimes}`);
31221
- }
31222
-
31223
- // node_modules/pixi.js/lib/assets/utils/checkExtension.mjs
31224
- init_path();
31225
- function checkExtension(url, extension) {
31226
- const tempURL = url.split("?")[0];
31227
- const ext = path.extname(tempURL).toLowerCase();
31228
- if (Array.isArray(extension)) {
31229
- return extension.includes(ext);
31230
- }
31231
- return ext === extension;
31232
- }
31233
-
31234
- // node_modules/pixi.js/lib/assets/loader/parsers/loadJson.mjs
31235
- init_LoaderParser();
31236
- var validJSONExtension = ".json";
31237
- var validJSONMIME = "application/json";
31238
- var loadJson = {
31239
- extension: {
31240
- type: ExtensionType.LoadParser,
31241
- priority: LoaderParserPriority.Low
31242
- },
31243
- name: "loadJson",
31244
- id: "json",
31245
- test(url) {
31246
- return checkDataUrl(url, validJSONMIME) || checkExtension(url, validJSONExtension);
31247
- },
31248
- async load(url) {
31249
- const response = await DOMAdapter.get().fetch(url);
31250
- const json = await response.json();
31251
- return json;
31252
- }
31253
- };
31254
-
31255
- // node_modules/pixi.js/lib/assets/loader/parsers/loadTxt.mjs
31256
- init_adapter();
31257
- init_Extensions();
31258
- init_LoaderParser();
31259
- var validTXTExtension = ".txt";
31260
- var validTXTMIME = "text/plain";
31261
- var loadTxt = {
31262
- name: "loadTxt",
31263
- id: "text",
31264
- extension: {
31265
- type: ExtensionType.LoadParser,
31266
- priority: LoaderParserPriority.Low,
31267
- name: "loadTxt"
31268
- },
31269
- test(url) {
31270
- return checkDataUrl(url, validTXTMIME) || checkExtension(url, validTXTExtension);
31271
- },
31272
- async load(url) {
31273
- const response = await DOMAdapter.get().fetch(url);
31274
- const txt = await response.text();
31275
- return txt;
31276
- }
31277
- };
31278
-
31279
- // node_modules/pixi.js/lib/assets/loader/parsers/loadWebFont.mjs
31280
- init_adapter();
31281
- init_Extensions();
31282
- init_warn();
31283
- init_path();
31284
- init_Cache();
31285
- init_LoaderParser();
31286
- var validWeights = [
31287
- "normal",
31288
- "bold",
31289
- "100",
31290
- "200",
31291
- "300",
31292
- "400",
31293
- "500",
31294
- "600",
31295
- "700",
31296
- "800",
31297
- "900"
31298
- ];
31299
- var validFontExtensions = [".ttf", ".otf", ".woff", ".woff2"];
31300
- var validFontMIMEs = [
31301
- "font/ttf",
31302
- "font/otf",
31303
- "font/woff",
31304
- "font/woff2"
31305
- ];
31306
- var CSS_IDENT_TOKEN_REGEX = /^(--|-?[A-Z_])[0-9A-Z_-]*$/i;
31307
- function getFontFamilyName(url) {
31308
- const ext = path.extname(url);
31309
- const name = path.basename(url, ext);
31310
- const nameWithSpaces = name.replace(/(-|_)/g, " ");
31311
- const nameTokens = nameWithSpaces.toLowerCase().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1));
31312
- let valid = nameTokens.length > 0;
31313
- for (const token of nameTokens) {
31314
- if (!token.match(CSS_IDENT_TOKEN_REGEX)) {
31315
- valid = false;
31316
- break;
31317
- }
31318
- }
31319
- let fontFamilyName = nameTokens.join(" ");
31320
- if (!valid) {
31321
- fontFamilyName = `"${fontFamilyName.replace(/[\\"]/g, "\\$&")}"`;
31322
- }
31323
- return fontFamilyName;
31324
- }
31325
- var validURICharactersRegex = /^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;
31326
- function encodeURIWhenNeeded(uri) {
31327
- if (validURICharactersRegex.test(uri)) {
31328
- return uri;
31329
- }
31330
- return encodeURI(uri);
31331
- }
31332
- var loadWebFont = {
31333
- extension: {
31334
- type: ExtensionType.LoadParser,
31335
- priority: LoaderParserPriority.Low
31336
- },
31337
- name: "loadWebFont",
31338
- id: "web-font",
31339
- test(url) {
31340
- return checkDataUrl(url, validFontMIMEs) || checkExtension(url, validFontExtensions);
31341
- },
31342
- async load(url, options) {
31343
- const fonts = DOMAdapter.get().getFontFaceSet();
31344
- if (fonts) {
31345
- const fontFaces = [];
31346
- const name = options.data?.family ?? getFontFamilyName(url);
31347
- const weights = options.data?.weights?.filter((weight) => validWeights.includes(weight)) ?? ["normal"];
31348
- const data = options.data ?? {};
31349
- for (let i2 = 0;i2 < weights.length; i2++) {
31350
- const weight = weights[i2];
31351
- const font = new FontFace(name, `url(${encodeURIWhenNeeded(url)})`, {
31352
- ...data,
31353
- weight
31354
- });
31355
- await font.load();
31356
- fonts.add(font);
31357
- fontFaces.push(font);
31358
- }
31359
- if (Cache.has(`${name}-and-url`)) {
31360
- const cached = Cache.get(`${name}-and-url`);
31361
- cached.entries.push({ url, faces: fontFaces });
31362
- } else {
31363
- Cache.set(`${name}-and-url`, {
31364
- entries: [{ url, faces: fontFaces }]
31365
- });
31366
- }
31367
- return fontFaces.length === 1 ? fontFaces[0] : fontFaces;
31368
- }
31369
- warn("[loadWebFont] FontFace API is not supported. Skipping loading font");
31370
- return null;
31371
- },
31372
- unload(font) {
31373
- const fonts = Array.isArray(font) ? font : [font];
31374
- const fontFamily = fonts[0].family;
31375
- const cached = Cache.get(`${fontFamily}-and-url`);
31376
- const entry = cached.entries.find((f2) => f2.faces.some((t2) => fonts.indexOf(t2) !== -1));
31377
- entry.faces = entry.faces.filter((f2) => fonts.indexOf(f2) === -1);
31378
- if (entry.faces.length === 0) {
31379
- cached.entries = cached.entries.filter((f2) => f2 !== entry);
31380
- }
31381
- fonts.forEach((t2) => {
31382
- DOMAdapter.get().getFontFaceSet().delete(t2);
31383
- });
31384
- if (cached.entries.length === 0) {
31385
- Cache.remove(`${fontFamily}-and-url`);
31386
- }
31387
- }
31388
- };
31389
-
31390
- // node_modules/pixi.js/lib/assets/loader/parsers/textures/loadSVG.mjs
31391
- init_adapter();
31392
- init_Extensions();
31393
- init_ImageSource();
31394
- init_GraphicsContext();
31395
-
31396
- // node_modules/pixi.js/lib/utils/network/getResolutionOfUrl.mjs
31397
- init_Resolver();
31398
- function getResolutionOfUrl(url, defaultValue2 = 1) {
31399
- const resolution = Resolver.RETINA_PREFIX?.exec(url);
31400
- if (resolution) {
31401
- return parseFloat(resolution[1]);
31402
- }
31403
- return defaultValue2;
31404
- }
31405
-
31406
- // node_modules/pixi.js/lib/assets/loader/parsers/textures/loadSVG.mjs
31407
- init_LoaderParser();
31408
-
31409
- // node_modules/pixi.js/lib/assets/loader/parsers/textures/utils/createTexture.mjs
31410
- init_Texture();
31411
- init_warn();
31412
- init_Cache();
31413
- function createTexture(source3, loader, url) {
31414
- source3.label = url;
31415
- source3._sourceOrigin = url;
31416
- const texture = new Texture({
31417
- source: source3,
31418
- label: url
31419
- });
31420
- const unload = () => {
31421
- delete loader.promiseCache[url];
31422
- if (Cache.has(url)) {
31423
- Cache.remove(url);
31424
- }
31425
- };
31426
- texture.source.once("destroy", () => {
31427
- if (loader.promiseCache[url]) {
31428
- warn("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource.");
31429
- unload();
31430
- }
31431
- });
31432
- texture.once("destroy", () => {
31433
- if (!source3.destroyed) {
31434
- warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture.");
31435
- unload();
31436
- }
31437
- });
31438
- return texture;
31439
- }
31440
-
31441
- // node_modules/pixi.js/lib/assets/loader/parsers/textures/loadSVG.mjs
31442
- var validSVGExtension = ".svg";
31443
- var validSVGMIME = "image/svg+xml";
31444
- var loadSvg = {
31445
- extension: {
31446
- type: ExtensionType.LoadParser,
31447
- priority: LoaderParserPriority.Low,
31448
- name: "loadSVG"
31449
- },
31450
- name: "loadSVG",
31451
- id: "svg",
31452
- config: {
31453
- crossOrigin: "anonymous",
31454
- parseAsGraphicsContext: false
31455
- },
31456
- test(url) {
31457
- return checkDataUrl(url, validSVGMIME) || checkExtension(url, validSVGExtension);
31458
- },
31459
- async load(url, asset, loader) {
31460
- if (asset.data?.parseAsGraphicsContext ?? this.config.parseAsGraphicsContext) {
31461
- return loadAsGraphics(url);
31462
- }
31463
- return loadAsTexture(url, asset, loader, this.config.crossOrigin);
31464
- },
31465
- unload(asset) {
31466
- asset.destroy(true);
31467
- }
31468
- };
31469
- async function loadAsTexture(url, asset, loader, crossOrigin) {
31470
- const response = await DOMAdapter.get().fetch(url);
31471
- const image = DOMAdapter.get().createImage();
31472
- image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(await response.text())}`;
31473
- image.crossOrigin = crossOrigin;
31474
- await image.decode();
31475
- const width = asset.data?.width ?? image.width;
31476
- const height = asset.data?.height ?? image.height;
31477
- const resolution = asset.data?.resolution || getResolutionOfUrl(url);
31478
- const canvasWidth = Math.ceil(width * resolution);
31479
- const canvasHeight = Math.ceil(height * resolution);
31480
- const canvas = DOMAdapter.get().createCanvas(canvasWidth, canvasHeight);
31481
- const context2 = canvas.getContext("2d");
31482
- context2.imageSmoothingEnabled = true;
31483
- context2.imageSmoothingQuality = "high";
31484
- context2.drawImage(image, 0, 0, width * resolution, height * resolution);
31485
- const { parseAsGraphicsContext: _p, ...rest } = asset.data ?? {};
31486
- const base = new ImageSource({
31487
- resource: canvas,
31488
- alphaMode: "premultiply-alpha-on-upload",
31489
- resolution,
31490
- ...rest
31491
- });
31492
- return createTexture(base, loader, url);
31493
- }
31494
- async function loadAsGraphics(url) {
31495
- const response = await DOMAdapter.get().fetch(url);
31496
- const svgSource = await response.text();
31497
- const context2 = new GraphicsContext;
31498
- context2.svg(svgSource);
31499
- return context2;
31500
- }
31501
-
31502
- // node_modules/pixi.js/lib/assets/loader/parsers/textures/loadTextures.mjs
31503
- init_adapter();
31504
- init_Extensions();
31505
- init_ImageSource();
31506
-
31507
- // node_modules/pixi.js/lib/_virtual/checkImageBitmap.worker.mjs
31508
- var WORKER_CODE = `(function () {
31509
- 'use strict';
31510
-
31511
- const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
31512
- async function checkImageBitmap() {
31513
- try {
31514
- if (typeof createImageBitmap !== "function") return false;
31515
- const response = await fetch(WHITE_PNG);
31516
- const imageBlob = await response.blob();
31517
- const imageBitmap = await createImageBitmap(imageBlob);
31518
- return imageBitmap.width === 1 && imageBitmap.height === 1;
31519
- } catch (_e) {
31520
- return false;
31521
- }
31522
- }
31523
- void checkImageBitmap().then((result) => {
31524
- self.postMessage(result);
31525
- });
31526
-
31527
- })();
31528
- `;
31529
- var WORKER_URL = null;
31530
-
31531
- class WorkerInstance {
31532
- constructor() {
31533
- if (!WORKER_URL) {
31534
- WORKER_URL = URL.createObjectURL(new Blob([WORKER_CODE], { type: "application/javascript" }));
31535
- }
31536
- this.worker = new Worker(WORKER_URL);
31537
- }
31538
- }
31539
- WorkerInstance.revokeObjectURL = function revokeObjectURL() {
31540
- if (WORKER_URL) {
31541
- URL.revokeObjectURL(WORKER_URL);
31542
- WORKER_URL = null;
31543
- }
31544
- };
31545
-
31546
- // node_modules/pixi.js/lib/_virtual/loadImageBitmap.worker.mjs
31547
- var WORKER_CODE2 = `(function () {
31548
- 'use strict';
31549
-
31550
- async function loadImageBitmap(url, alphaMode) {
31551
- const response = await fetch(url);
31552
- if (!response.ok) {
31553
- throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
31554
- }
31555
- const imageBlob = await response.blob();
31556
- return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);
31557
- }
31558
- self.onmessage = async (event) => {
31559
- try {
31560
- const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);
31561
- self.postMessage({
31562
- data: imageBitmap,
31563
- uuid: event.data.uuid,
31564
- id: event.data.id
31565
- }, [imageBitmap]);
31566
- } catch (e) {
31567
- self.postMessage({
31568
- error: e,
31569
- uuid: event.data.uuid,
31570
- id: event.data.id
31571
- });
31572
- }
31573
- };
31574
-
31575
- })();
31576
- `;
31577
- var WORKER_URL2 = null;
31578
-
31579
- class WorkerInstance2 {
31580
- constructor() {
31581
- if (!WORKER_URL2) {
31582
- WORKER_URL2 = URL.createObjectURL(new Blob([WORKER_CODE2], { type: "application/javascript" }));
31583
- }
31584
- this.worker = new Worker(WORKER_URL2);
31585
- }
31586
- }
31587
- WorkerInstance2.revokeObjectURL = function revokeObjectURL2() {
31588
- if (WORKER_URL2) {
31589
- URL.revokeObjectURL(WORKER_URL2);
31590
- WORKER_URL2 = null;
31591
- }
31592
- };
31593
-
31594
- // node_modules/pixi.js/lib/assets/loader/workers/WorkerManager.mjs
31595
- var UUID = 0;
31596
- var MAX_WORKERS;
31597
-
31598
- class WorkerManagerClass {
31599
- constructor() {
31600
- this._initialized = false;
31601
- this._createdWorkers = 0;
31602
- this._workerPool = [];
31603
- this._queue = [];
31604
- this._resolveHash = {};
31605
- }
31606
- isImageBitmapSupported() {
31607
- if (this._isImageBitmapSupported !== undefined)
31608
- return this._isImageBitmapSupported;
31609
- this._isImageBitmapSupported = new Promise((resolve) => {
31610
- const { worker } = new WorkerInstance;
31611
- worker.addEventListener("message", (event) => {
31612
- worker.terminate();
31613
- WorkerInstance.revokeObjectURL();
31614
- resolve(event.data);
31615
- });
31616
- });
31617
- return this._isImageBitmapSupported;
31618
- }
31619
- loadImageBitmap(src, asset) {
31620
- return this._run("loadImageBitmap", [src, asset?.data?.alphaMode]);
31621
- }
31622
- async _initWorkers() {
31623
- if (this._initialized)
31624
- return;
31625
- this._initialized = true;
31626
- }
31627
- _getWorker() {
31628
- if (MAX_WORKERS === undefined) {
31629
- MAX_WORKERS = navigator.hardwareConcurrency || 4;
31630
- }
31631
- let worker = this._workerPool.pop();
31632
- if (!worker && this._createdWorkers < MAX_WORKERS) {
31633
- this._createdWorkers++;
31634
- worker = new WorkerInstance2().worker;
31635
- worker.addEventListener("message", (event) => {
31636
- this._complete(event.data);
31637
- this._returnWorker(event.target);
31638
- this._next();
31639
- });
31640
- }
31641
- return worker;
31642
- }
31643
- _returnWorker(worker) {
31644
- this._workerPool.push(worker);
31645
- }
31646
- _complete(data) {
31647
- if (!this._resolveHash[data.uuid]) {
31648
- return;
31649
- }
31650
- if (data.error !== undefined) {
31651
- this._resolveHash[data.uuid].reject(data.error);
31652
- } else {
31653
- this._resolveHash[data.uuid].resolve(data.data);
31654
- }
31655
- delete this._resolveHash[data.uuid];
31656
- }
31657
- async _run(id, args) {
31658
- await this._initWorkers();
31659
- const promise2 = new Promise((resolve, reject) => {
31660
- this._queue.push({ id, arguments: args, resolve, reject });
31661
- });
31662
- this._next();
31663
- return promise2;
31664
- }
31665
- _next() {
31666
- if (!this._queue.length)
31667
- return;
31668
- const worker = this._getWorker();
31669
- if (!worker) {
31670
- return;
31671
- }
31672
- const toDo = this._queue.pop();
31673
- const id = toDo.id;
31674
- this._resolveHash[UUID] = { resolve: toDo.resolve, reject: toDo.reject };
31675
- worker.postMessage({
31676
- data: toDo.arguments,
31677
- uuid: UUID++,
31678
- id
31679
- });
31680
- }
31681
- reset() {
31682
- this._workerPool.forEach((worker) => worker.terminate());
31683
- this._workerPool.length = 0;
31684
- Object.values(this._resolveHash).forEach(({ reject }) => {
31685
- reject?.(new Error("WorkerManager has been reset before completion"));
31686
- });
31687
- this._resolveHash = {};
31688
- this._queue.length = 0;
31689
- this._initialized = false;
31690
- this._createdWorkers = 0;
31691
- }
31692
- }
31693
- var WorkerManager = new WorkerManagerClass;
31694
-
31695
- // node_modules/pixi.js/lib/assets/loader/parsers/textures/loadTextures.mjs
31696
- init_LoaderParser();
31697
- var validImageExtensions = [".jpeg", ".jpg", ".png", ".webp", ".avif"];
31698
- var validImageMIMEs = [
31699
- "image/jpeg",
31700
- "image/png",
31701
- "image/webp",
31702
- "image/avif"
31703
- ];
31704
- async function loadImageBitmap(url, asset) {
31705
- const response = await DOMAdapter.get().fetch(url);
31706
- if (!response.ok) {
31707
- throw new Error(`[loadImageBitmap] Failed to fetch ${url}: ${response.status} ${response.statusText}`);
31708
- }
31709
- const imageBlob = await response.blob();
31710
- return asset?.data?.alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);
31711
- }
31712
- var loadTextures = {
31713
- name: "loadTextures",
31714
- id: "texture",
31715
- extension: {
31716
- type: ExtensionType.LoadParser,
31717
- priority: LoaderParserPriority.High,
31718
- name: "loadTextures"
31719
- },
31720
- config: {
31721
- preferWorkers: true,
31722
- preferCreateImageBitmap: true,
31723
- crossOrigin: "anonymous"
31724
- },
31725
- test(url) {
31726
- return checkDataUrl(url, validImageMIMEs) || checkExtension(url, validImageExtensions);
31727
- },
31728
- async load(url, asset, loader) {
31729
- let src = null;
31730
- if (globalThis.createImageBitmap && this.config.preferCreateImageBitmap) {
31731
- if (this.config.preferWorkers && await WorkerManager.isImageBitmapSupported()) {
31732
- src = await WorkerManager.loadImageBitmap(url, asset);
31733
- } else {
31734
- src = await loadImageBitmap(url, asset);
31735
- }
31736
- } else {
31737
- src = await new Promise((resolve, reject) => {
31738
- src = DOMAdapter.get().createImage();
31739
- src.crossOrigin = this.config.crossOrigin;
31740
- src.src = url;
31741
- if (src.complete) {
31742
- resolve(src);
31743
- } else {
31744
- src.onload = () => {
31745
- resolve(src);
31746
- };
31747
- src.onerror = reject;
31748
- }
31749
- });
31750
- }
31751
- const base = new ImageSource({
31752
- resource: src,
31753
- alphaMode: "premultiply-alpha-on-upload",
31754
- resolution: asset.data?.resolution || getResolutionOfUrl(url),
31755
- ...asset.data
31756
- });
31757
- return createTexture(base, loader, url);
31758
- },
31759
- unload(texture) {
31760
- texture.destroy(true);
31761
- }
31762
- };
31763
-
31764
- // node_modules/pixi.js/lib/assets/loader/parsers/textures/loadVideoTextures.mjs
31765
- init_Extensions();
31766
- init_VideoSource();
31767
- init_detectVideoAlphaMode();
31768
- var potentialVideoExtensions = [".mp4", ".m4v", ".webm", ".ogg", ".ogv", ".h264", ".avi", ".mov"];
31769
- var validVideoExtensions;
31770
- var validVideoMIMEs;
31771
- function crossOrigin(element, url, crossorigin) {
31772
- if (crossorigin === undefined && !url.startsWith("data:")) {
31773
- element.crossOrigin = determineCrossOrigin(url);
31774
- } else if (crossorigin !== false) {
31775
- element.crossOrigin = typeof crossorigin === "string" ? crossorigin : "anonymous";
31776
- }
31777
- }
31778
- function preloadVideo(element) {
31779
- return new Promise((resolve, reject) => {
31780
- element.addEventListener("canplaythrough", loaded);
31781
- element.addEventListener("error", error);
31782
- element.load();
31783
- function loaded() {
31784
- cleanup();
31785
- resolve();
31786
- }
31787
- function error(err) {
31788
- cleanup();
31789
- reject(err);
31790
- }
31791
- function cleanup() {
31792
- element.removeEventListener("canplaythrough", loaded);
31793
- element.removeEventListener("error", error);
31794
- }
31795
- });
31796
- }
31797
- function determineCrossOrigin(url, loc = globalThis.location) {
31798
- if (url.startsWith("data:")) {
31799
- return "";
31800
- }
31801
- loc || (loc = globalThis.location);
31802
- const parsedUrl = new URL(url, document.baseURI);
31803
- if (parsedUrl.hostname !== loc.hostname || parsedUrl.port !== loc.port || parsedUrl.protocol !== loc.protocol) {
31804
- return "anonymous";
31805
- }
31806
- return "";
31807
- }
31808
- function getBrowserSupportedVideoExtensions() {
31809
- const supportedExtensions = [];
31810
- const supportedMimes = [];
31811
- for (const ext of potentialVideoExtensions) {
31812
- const mimeType = VideoSource.MIME_TYPES[ext.substring(1)] || `video/${ext.substring(1)}`;
31813
- if (testVideoFormat(mimeType)) {
31814
- supportedExtensions.push(ext);
31815
- if (!supportedMimes.includes(mimeType)) {
31816
- supportedMimes.push(mimeType);
31817
- }
29676
+ finalOptions = { ...options, ...options.canvasOptions };
29677
+ break;
31818
29678
  }
31819
29679
  }
31820
- return {
31821
- validVideoExtensions: supportedExtensions,
31822
- validVideoMime: supportedMimes
31823
- };
31824
- }
31825
- var loadVideoTextures = {
31826
- name: "loadVideo",
31827
- id: "video",
31828
- extension: {
31829
- type: ExtensionType.LoadParser,
31830
- name: "loadVideo"
31831
- },
31832
- test(url) {
31833
- if (!validVideoExtensions || !validVideoMIMEs) {
31834
- const { validVideoExtensions: ve, validVideoMime: vm } = getBrowserSupportedVideoExtensions();
31835
- validVideoExtensions = ve;
31836
- validVideoMIMEs = vm;
31837
- }
31838
- const isValidDataUrl = checkDataUrl(url, validVideoMIMEs);
31839
- const isValidExtension = checkExtension(url, validVideoExtensions);
31840
- return isValidDataUrl || isValidExtension;
31841
- },
31842
- async load(url, asset, loader) {
31843
- const options = {
31844
- ...VideoSource.defaultOptions,
31845
- resolution: asset.data?.resolution || getResolutionOfUrl(url),
31846
- alphaMode: asset.data?.alphaMode || await detectVideoAlphaMode(),
31847
- ...asset.data
31848
- };
31849
- const videoElement = document.createElement("video");
31850
- const attributeMap = {
31851
- preload: options.autoLoad !== false ? "auto" : undefined,
31852
- "webkit-playsinline": options.playsinline !== false ? "" : undefined,
31853
- playsinline: options.playsinline !== false ? "" : undefined,
31854
- muted: options.muted === true ? "" : undefined,
31855
- loop: options.loop === true ? "" : undefined,
31856
- autoplay: options.autoPlay !== false ? "" : undefined
31857
- };
31858
- Object.keys(attributeMap).forEach((key) => {
31859
- const value = attributeMap[key];
31860
- if (value !== undefined)
31861
- videoElement.setAttribute(key, value);
31862
- });
31863
- if (options.muted === true) {
31864
- videoElement.muted = true;
31865
- }
31866
- crossOrigin(videoElement, url, options.crossorigin);
31867
- const sourceElement = document.createElement("source");
31868
- let mime;
31869
- if (options.mime) {
31870
- mime = options.mime;
31871
- } else if (url.startsWith("data:")) {
31872
- mime = url.slice(5, url.indexOf(";"));
31873
- } else if (!url.startsWith("blob:")) {
31874
- const ext = url.split("?")[0].slice(url.lastIndexOf(".") + 1).toLowerCase();
31875
- mime = VideoSource.MIME_TYPES[ext] || `video/${ext}`;
31876
- }
31877
- sourceElement.src = url;
31878
- if (mime) {
31879
- sourceElement.type = mime;
31880
- }
31881
- return new Promise((resolve, reject) => {
31882
- if (options.preload && !options.autoPlay) {
31883
- videoElement.load();
31884
- }
31885
- videoElement.addEventListener("canplay", onCanPlay);
31886
- videoElement.addEventListener("error", onError);
31887
- sourceElement.addEventListener("error", onError);
31888
- videoElement.appendChild(sourceElement);
31889
- async function onCanPlay() {
31890
- const base = new VideoSource({ ...options, resource: videoElement });
31891
- cleanup();
31892
- if (asset.data.preload) {
31893
- await preloadVideo(videoElement);
31894
- }
31895
- resolve(createTexture(base, loader, url));
31896
- }
31897
- function onError(event) {
31898
- cleanup();
31899
- reject(event);
31900
- }
31901
- function cleanup() {
31902
- videoElement.removeEventListener("canplay", onCanPlay);
31903
- videoElement.removeEventListener("error", onError);
31904
- sourceElement.removeEventListener("error", onError);
31905
- }
31906
- });
31907
- },
31908
- unload(texture) {
31909
- texture.destroy(true);
29680
+ delete finalOptions.webgpu;
29681
+ delete finalOptions.webgl;
29682
+ delete finalOptions.canvasOptions;
29683
+ if (!RendererClass) {
29684
+ throw new Error("No available renderer for the current environment");
31910
29685
  }
31911
- };
29686
+ const renderer = new RendererClass;
29687
+ await renderer.init(finalOptions);
29688
+ return renderer;
29689
+ }
31912
29690
 
31913
- // node_modules/pixi.js/lib/assets/resolver/parsers/resolveJsonUrl.mjs
31914
- init_Extensions();
31915
- init_Resolver();
29691
+ // node_modules/pixi.js/lib/app/Application.mjs
29692
+ init_Container();
29693
+ init_globalHooks();
29694
+ init_deprecation();
31916
29695
 
31917
- // node_modules/pixi.js/lib/assets/resolver/parsers/resolveTextureUrl.mjs
29696
+ // node_modules/pixi.js/lib/app/init.mjs
31918
29697
  init_Extensions();
31919
- init_Resolver();
31920
- var resolveTextureUrl = {
31921
- extension: {
31922
- type: ExtensionType.ResolveParser,
31923
- name: "resolveTexture"
31924
- },
31925
- test: loadTextures.test,
31926
- parse: (value) => ({
31927
- resolution: parseFloat(Resolver.RETINA_PREFIX.exec(value)?.[1] ?? "1"),
31928
- format: value.split(".").pop(),
31929
- src: value
31930
- })
31931
- };
31932
-
31933
- // node_modules/pixi.js/lib/assets/resolver/parsers/resolveJsonUrl.mjs
31934
- var resolveJsonUrl = {
31935
- extension: {
31936
- type: ExtensionType.ResolveParser,
31937
- priority: -2,
31938
- name: "resolveJson"
31939
- },
31940
- test: (value) => Resolver.RETINA_PREFIX.test(value) && value.endsWith(".json"),
31941
- parse: resolveTextureUrl.parse
31942
- };
31943
29698
 
31944
- // node_modules/pixi.js/lib/assets/Assets.mjs
31945
- init_Resolver();
31946
- init_convertToList();
31947
- init_isSingleItem();
29699
+ // node_modules/pixi.js/lib/app/ResizePlugin.mjs
29700
+ init_Extensions();
31948
29701
 
31949
- class AssetsClass {
31950
- constructor() {
31951
- this._detections = [];
31952
- this._initialized = false;
31953
- this.resolver = new Resolver;
31954
- this.loader = new Loader;
31955
- this.cache = Cache;
31956
- this._backgroundLoader = new BackgroundLoader(this.loader);
31957
- this._backgroundLoader.active = true;
31958
- this.reset();
31959
- }
31960
- async init(options = {}) {
31961
- if (this._initialized) {
31962
- warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");
31963
- return;
31964
- }
31965
- this._initialized = true;
31966
- if (options.defaultSearchParams) {
31967
- this.resolver.setDefaultSearchParams(options.defaultSearchParams);
31968
- }
31969
- if (options.basePath) {
31970
- this.resolver.basePath = options.basePath;
31971
- }
31972
- if (options.bundleIdentifier) {
31973
- this.resolver.setBundleIdentifier(options.bundleIdentifier);
31974
- }
31975
- if (options.manifest) {
31976
- let manifest = options.manifest;
31977
- if (typeof manifest === "string") {
31978
- manifest = await this.load(manifest);
29702
+ class ResizePlugin {
29703
+ static init(options) {
29704
+ Object.defineProperty(this, "resizeTo", {
29705
+ configurable: true,
29706
+ set(dom) {
29707
+ globalThis.removeEventListener("resize", this.queueResize);
29708
+ this._resizeTo = dom;
29709
+ if (dom) {
29710
+ globalThis.addEventListener("resize", this.queueResize);
29711
+ this.resize();
29712
+ }
29713
+ },
29714
+ get() {
29715
+ return this._resizeTo;
31979
29716
  }
31980
- this.resolver.addManifest(manifest);
31981
- }
31982
- const resolutionPref = options.texturePreference?.resolution ?? 1;
31983
- const resolution = typeof resolutionPref === "number" ? [resolutionPref] : resolutionPref;
31984
- const formats = await this._detectFormats({
31985
- preferredFormats: options.texturePreference?.format,
31986
- skipDetections: options.skipDetections,
31987
- detections: this._detections
31988
29717
  });
31989
- this.resolver.prefer({
31990
- params: {
31991
- format: formats,
31992
- resolution
29718
+ this.queueResize = () => {
29719
+ if (!this._resizeTo) {
29720
+ return;
31993
29721
  }
31994
- });
31995
- if (options.preferences) {
31996
- this.setPreferences(options.preferences);
31997
- }
31998
- if (options.loadOptions) {
31999
- this.loader.loadOptions = {
32000
- ...this.loader.loadOptions,
32001
- ...options.loadOptions
32002
- };
32003
- }
29722
+ this._cancelResize();
29723
+ this._resizeId = requestAnimationFrame(() => this.resize());
29724
+ };
29725
+ this._cancelResize = () => {
29726
+ if (this._resizeId) {
29727
+ cancelAnimationFrame(this._resizeId);
29728
+ this._resizeId = null;
29729
+ }
29730
+ };
29731
+ this.resize = () => {
29732
+ if (!this._resizeTo) {
29733
+ return;
29734
+ }
29735
+ this._cancelResize();
29736
+ let width;
29737
+ let height;
29738
+ if (this._resizeTo === globalThis.window) {
29739
+ width = globalThis.innerWidth;
29740
+ height = globalThis.innerHeight;
29741
+ } else {
29742
+ const { clientWidth, clientHeight } = this._resizeTo;
29743
+ width = clientWidth;
29744
+ height = clientHeight;
29745
+ }
29746
+ this.renderer.resize(width, height);
29747
+ this.render();
29748
+ };
29749
+ this._resizeId = null;
29750
+ this._resizeTo = null;
29751
+ this.resizeTo = options.resizeTo || null;
32004
29752
  }
32005
- add(assets) {
32006
- this.resolver.add(assets);
29753
+ static destroy() {
29754
+ globalThis.removeEventListener("resize", this.queueResize);
29755
+ this._cancelResize();
29756
+ this._cancelResize = null;
29757
+ this.queueResize = null;
29758
+ this.resizeTo = null;
29759
+ this.resize = null;
32007
29760
  }
32008
- async load(urls, onProgress) {
32009
- if (!this._initialized) {
32010
- await this.init();
32011
- }
32012
- const singleAsset = isSingleItem(urls);
32013
- const urlArray = convertToList(urls).map((url) => {
32014
- if (typeof url !== "string") {
32015
- const aliases = this.resolver.getAlias(url);
32016
- if (aliases.some((alias) => !this.resolver.hasKey(alias))) {
32017
- this.add(url);
29761
+ }
29762
+ ResizePlugin.extension = ExtensionType.Application;
29763
+
29764
+ // node_modules/pixi.js/lib/app/TickerPlugin.mjs
29765
+ init_Extensions();
29766
+ init_const2();
29767
+ init_Ticker();
29768
+
29769
+ class TickerPlugin {
29770
+ static init(options) {
29771
+ options = Object.assign({
29772
+ autoStart: true,
29773
+ sharedTicker: false
29774
+ }, options);
29775
+ Object.defineProperty(this, "ticker", {
29776
+ configurable: true,
29777
+ set(ticker) {
29778
+ if (this._ticker) {
29779
+ this._ticker.remove(this.render, this);
29780
+ }
29781
+ this._ticker = ticker;
29782
+ if (ticker) {
29783
+ ticker.add(this.render, this, UPDATE_PRIORITY.LOW);
32018
29784
  }
32019
- return Array.isArray(aliases) ? aliases[0] : aliases;
29785
+ },
29786
+ get() {
29787
+ return this._ticker;
32020
29788
  }
32021
- if (!this.resolver.hasKey(url))
32022
- this.add({ alias: url, src: url });
32023
- return url;
32024
29789
  });
32025
- const resolveResults = this.resolver.resolve(urlArray);
32026
- const out2 = await this._mapLoadToResolve(resolveResults, onProgress);
32027
- return singleAsset ? out2[urlArray[0]] : out2;
32028
- }
32029
- addBundle(bundleId, assets) {
32030
- this.resolver.addBundle(bundleId, assets);
32031
- }
32032
- async loadBundle(bundleIds, onProgress) {
32033
- if (!this._initialized) {
32034
- await this.init();
32035
- }
32036
- let singleAsset = false;
32037
- if (typeof bundleIds === "string") {
32038
- singleAsset = true;
32039
- bundleIds = [bundleIds];
32040
- }
32041
- const resolveResults = this.resolver.resolveBundle(bundleIds);
32042
- const out2 = {};
32043
- const keys = Object.keys(resolveResults);
32044
- let total = 0;
32045
- const counts = [];
32046
- const _onProgress = () => {
32047
- onProgress?.(counts.reduce((a2, b2) => a2 + b2, 0) / total);
29790
+ this.stop = () => {
29791
+ this._ticker.stop();
32048
29792
  };
32049
- const promises = keys.map((bundleId, i2) => {
32050
- const resolveResult = resolveResults[bundleId];
32051
- const values = Object.values(resolveResult);
32052
- const totalAssetsToLoad = [...new Set(values.flat())];
32053
- const progressSize = totalAssetsToLoad.reduce((sum, asset) => sum + (asset.progressSize || 1), 0);
32054
- counts.push(0);
32055
- total += progressSize;
32056
- return this._mapLoadToResolve(resolveResult, (e2) => {
32057
- counts[i2] = e2 * progressSize;
32058
- _onProgress();
32059
- }).then((resolveResult2) => {
32060
- out2[bundleId] = resolveResult2;
32061
- });
32062
- });
32063
- await Promise.all(promises);
32064
- return singleAsset ? out2[bundleIds[0]] : out2;
32065
- }
32066
- async backgroundLoad(urls) {
32067
- if (!this._initialized) {
32068
- await this.init();
32069
- }
32070
- if (typeof urls === "string") {
32071
- urls = [urls];
29793
+ this.start = () => {
29794
+ this._ticker.start();
29795
+ };
29796
+ this._ticker = null;
29797
+ this.ticker = options.sharedTicker ? Ticker.shared : new Ticker;
29798
+ if (options.autoStart) {
29799
+ this.start();
32072
29800
  }
32073
- const resolveResults = this.resolver.resolve(urls);
32074
- this._backgroundLoader.add(Object.values(resolveResults));
32075
29801
  }
32076
- async backgroundLoadBundle(bundleIds) {
32077
- if (!this._initialized) {
32078
- await this.init();
32079
- }
32080
- if (typeof bundleIds === "string") {
32081
- bundleIds = [bundleIds];
29802
+ static destroy() {
29803
+ if (this._ticker) {
29804
+ const oldTicker = this._ticker;
29805
+ this.ticker = null;
29806
+ oldTicker.destroy();
32082
29807
  }
32083
- const resolveResults = this.resolver.resolveBundle(bundleIds);
32084
- Object.values(resolveResults).forEach((resolveResult) => {
32085
- this._backgroundLoader.add(Object.values(resolveResult));
32086
- });
32087
- }
32088
- reset() {
32089
- this.resolver.reset();
32090
- this.loader.reset();
32091
- this.cache.reset();
32092
- this._initialized = false;
32093
29808
  }
32094
- get(keys) {
32095
- if (typeof keys === "string") {
32096
- return Cache.get(keys);
29809
+ }
29810
+ TickerPlugin.extension = ExtensionType.Application;
29811
+
29812
+ // node_modules/pixi.js/lib/app/init.mjs
29813
+ extensions.add(ResizePlugin);
29814
+ extensions.add(TickerPlugin);
29815
+
29816
+ // node_modules/pixi.js/lib/app/Application.mjs
29817
+ var _Application = class _Application2 {
29818
+ constructor(...args) {
29819
+ this.stage = new Container;
29820
+ if (args[0] !== undefined) {
29821
+ deprecation(v8_0_0, "Application constructor options are deprecated, please use Application.init() instead.");
32097
29822
  }
32098
- const assets = {};
32099
- for (let i2 = 0;i2 < keys.length; i2++) {
32100
- assets[i2] = Cache.get(keys[i2]);
32101
- }
32102
- return assets;
32103
- }
32104
- async _mapLoadToResolve(resolveResults, progressOrLoadOptions) {
32105
- const resolveArray = [...new Set(Object.values(resolveResults))];
32106
- this._backgroundLoader.active = false;
32107
- const loadedAssets = await this.loader.load(resolveArray, progressOrLoadOptions);
32108
- this._backgroundLoader.active = true;
32109
- const out2 = {};
32110
- resolveArray.forEach((resolveResult) => {
32111
- const asset = loadedAssets[resolveResult.src];
32112
- const keys = [resolveResult.src];
32113
- if (resolveResult.alias) {
32114
- keys.push(...resolveResult.alias);
32115
- }
32116
- keys.forEach((key) => {
32117
- out2[key] = asset;
32118
- });
32119
- Cache.set(keys, asset);
29823
+ }
29824
+ async init(options) {
29825
+ options = { ...options };
29826
+ this.stage || (this.stage = new Container);
29827
+ this.renderer = await autoDetectRenderer(options);
29828
+ _Application2._plugins.forEach((plugin) => {
29829
+ plugin.init.call(this, options);
32120
29830
  });
32121
- return out2;
32122
29831
  }
32123
- async unload(urls) {
32124
- if (!this._initialized) {
32125
- await this.init();
32126
- }
32127
- const urlArray = convertToList(urls).map((url) => typeof url !== "string" ? url.src : url);
32128
- const resolveResults = this.resolver.resolve(urlArray);
32129
- await this._unloadFromResolved(resolveResults);
29832
+ render() {
29833
+ this.renderer.render({ container: this.stage });
32130
29834
  }
32131
- async unloadBundle(bundleIds) {
32132
- if (!this._initialized) {
32133
- await this.init();
32134
- }
32135
- bundleIds = convertToList(bundleIds);
32136
- const resolveResults = this.resolver.resolveBundle(bundleIds);
32137
- const promises = Object.keys(resolveResults).map((bundleId) => this._unloadFromResolved(resolveResults[bundleId]));
32138
- await Promise.all(promises);
32139
- }
32140
- async _unloadFromResolved(resolveResult) {
32141
- const resolveArray = Object.values(resolveResult);
32142
- resolveArray.forEach((resolveResult2) => {
32143
- Cache.remove(resolveResult2.src);
32144
- });
32145
- await this.loader.unload(resolveArray);
29835
+ get canvas() {
29836
+ return this.renderer.canvas;
32146
29837
  }
32147
- async _detectFormats(options) {
32148
- let formats = [];
32149
- if (options.preferredFormats) {
32150
- formats = Array.isArray(options.preferredFormats) ? options.preferredFormats : [options.preferredFormats];
32151
- }
32152
- for (const detection of options.detections) {
32153
- if (options.skipDetections || await detection.test()) {
32154
- formats = await detection.add(formats);
32155
- } else if (!options.skipDetections) {
32156
- formats = await detection.remove(formats);
32157
- }
32158
- }
32159
- formats = formats.filter((format, index) => formats.indexOf(format) === index);
32160
- return formats;
29838
+ get view() {
29839
+ deprecation(v8_0_0, "Application.view is deprecated, please use Application.canvas instead.");
29840
+ return this.renderer.canvas;
32161
29841
  }
32162
- get detections() {
32163
- return this._detections;
29842
+ get screen() {
29843
+ return this.renderer.screen;
32164
29844
  }
32165
- setPreferences(preferences) {
32166
- this.loader.parsers.forEach((parser) => {
32167
- if (!parser.config)
32168
- return;
32169
- Object.keys(parser.config).filter((key) => (key in preferences)).forEach((key) => {
32170
- parser.config[key] = preferences[key];
32171
- });
29845
+ destroy(rendererDestroyOptions = false, options = false) {
29846
+ const plugins = _Application2._plugins.slice(0);
29847
+ plugins.reverse();
29848
+ plugins.forEach((plugin) => {
29849
+ plugin.destroy.call(this);
32172
29850
  });
29851
+ this.stage.destroy(options);
29852
+ this.stage = null;
29853
+ this.renderer.destroy(rendererDestroyOptions);
29854
+ this.renderer = null;
32173
29855
  }
32174
- }
32175
- var Assets = new AssetsClass;
32176
- extensions.handleByList(ExtensionType.LoadParser, Assets.loader.parsers).handleByList(ExtensionType.ResolveParser, Assets.resolver.parsers).handleByList(ExtensionType.CacheParser, Assets.cache.parsers).handleByList(ExtensionType.DetectionParser, Assets.detections);
32177
- extensions.add(cacheTextureArray, detectDefaults, detectAvif, detectWebp, detectMp4, detectOgv, detectWebm, loadJson, loadTxt, loadWebFont, loadSvg, loadTextures, loadVideoTextures, loadBitmapFont, bitmapFontCachePlugin, resolveTextureUrl, resolveJsonUrl);
32178
- var assetKeyMap = {
32179
- loader: ExtensionType.LoadParser,
32180
- resolver: ExtensionType.ResolveParser,
32181
- cache: ExtensionType.CacheParser,
32182
- detection: ExtensionType.DetectionParser
32183
29856
  };
32184
- extensions.handle(ExtensionType.Asset, (extension) => {
32185
- const ref = extension.ref;
32186
- Object.entries(assetKeyMap).filter(([key]) => !!ref[key]).forEach(([key, type]) => extensions.add(Object.assign(ref[key], { extension: ref[key].extension ?? type })));
32187
- }, (extension) => {
32188
- const ref = extension.ref;
32189
- Object.keys(assetKeyMap).filter((key) => !!ref[key]).forEach((key) => extensions.remove(ref[key]));
32190
- });
29857
+ _Application._plugins = [];
29858
+ var Application = _Application;
29859
+ extensions.handleByList(ExtensionType.Application, Application._plugins);
29860
+ extensions.add(ApplicationInitHook);
32191
29861
 
32192
29862
  // node_modules/pixi.js/lib/scene/text/Text.mjs
32193
29863
  init_TextureStyle();
@@ -33038,6 +30708,7 @@ class Text extends AbstractText {
33038
30708
  // node_modules/pixi.js/lib/index.mjs
33039
30709
  init_Point();
33040
30710
  init_Rectangle();
30711
+ init_ImageSource();
33041
30712
  init_Texture();
33042
30713
  init_textureFrom();
33043
30714
  init_Container();
@@ -33588,14 +31259,18 @@ class ImageElement extends BaseElement {
33588
31259
  this.y = y2;
33589
31260
  this.loadTexture(src);
33590
31261
  }
33591
- async loadTexture(src) {
33592
- try {
33593
- const texture = await Assets.load(src);
31262
+ loadTexture(src) {
31263
+ const img = new Image;
31264
+ img.onload = () => {
31265
+ const texture = new Texture({ source: new ImageSource({ resource: img }) });
33594
31266
  this.sprite.texture = texture;
33595
31267
  this._loaded = true;
33596
- } catch (err) {
33597
- console.warn(`Failed to load image: ${src}`, err);
33598
- }
31268
+ this.emitChange("loaded", false, true);
31269
+ };
31270
+ img.onerror = () => {
31271
+ console.warn(`Failed to load image: ${src}`);
31272
+ };
31273
+ img.src = src;
33599
31274
  }
33600
31275
  get src() {
33601
31276
  return this._src;
@@ -33606,8 +31281,8 @@ class ImageElement extends BaseElement {
33606
31281
  return;
33607
31282
  this._src = value;
33608
31283
  this._loaded = false;
33609
- this.loadTexture(value);
33610
31284
  this.emitChange("src", old, value);
31285
+ this.loadTexture(value);
33611
31286
  }
33612
31287
  get loaded() {
33613
31288
  return this._loaded;
@@ -33723,6 +31398,7 @@ class ShapeElement extends BaseElement {
33723
31398
  _fillPercentage;
33724
31399
  _fillDirection;
33725
31400
  _strokeWidth;
31401
+ _lineCap;
33726
31402
  _shapeParams;
33727
31403
  constructor(shapeType, params, options) {
33728
31404
  super("shape");
@@ -33733,6 +31409,7 @@ class ShapeElement extends BaseElement {
33733
31409
  this._fillPercentage = options?.fillPercentage ?? 100;
33734
31410
  this._fillDirection = options?.fillDirection ?? "left-to-right";
33735
31411
  this._strokeWidth = options?.strokeWidth ?? 2;
31412
+ this._lineCap = options?.lineCap ?? "butt";
33736
31413
  this.bgGraphics = new Graphics;
33737
31414
  this.fgGraphics = new Graphics;
33738
31415
  this.fillMask = new FillMask;
@@ -33832,6 +31509,17 @@ class ShapeElement extends BaseElement {
33832
31509
  this.redraw();
33833
31510
  this.emitChange("strokeWidth", old, value);
33834
31511
  }
31512
+ get lineCap() {
31513
+ return this._lineCap;
31514
+ }
31515
+ set lineCap(value) {
31516
+ const old = this._lineCap;
31517
+ if (old === value)
31518
+ return;
31519
+ this._lineCap = value;
31520
+ this.redraw();
31521
+ this.emitChange("lineCap", old, value);
31522
+ }
33835
31523
  get width() {
33836
31524
  return this.getLocalBounds().width;
33837
31525
  }
@@ -33884,7 +31572,7 @@ class ShapeElement extends BaseElement {
33884
31572
  switch (this._shapeType) {
33885
31573
  case "circle": {
33886
31574
  const r2 = this._shapeParams["radius"];
33887
- return { x: 0, y: 0, width: r2 * 2, height: r2 * 2 };
31575
+ return { x: -r2, y: -r2, width: r2 * 2, height: r2 * 2 };
33888
31576
  }
33889
31577
  case "rectangle":
33890
31578
  return { x: 0, y: 0, width: this._shapeParams["w"], height: this._shapeParams["h"] };
@@ -33893,13 +31581,15 @@ class ShapeElement extends BaseElement {
33893
31581
  const ly1 = this._shapeParams["ly1"];
33894
31582
  const lx2 = this._shapeParams["lx2"];
33895
31583
  const ly2 = this._shapeParams["ly2"];
31584
+ const half = this._strokeWidth / 2;
33896
31585
  const w2 = Math.abs(lx2 - lx1) || 1;
33897
31586
  const h2 = Math.abs(ly2 - ly1) || 1;
33898
- return { x: 0, y: 0, width: w2, height: h2 };
31587
+ return { x: -half, y: -half, width: w2 + this._strokeWidth, height: h2 + this._strokeWidth };
33899
31588
  }
33900
31589
  case "arc": {
33901
31590
  const r2 = this._shapeParams["radius"];
33902
- return { x: 0, y: 0, width: r2 * 2, height: r2 * 2 };
31591
+ const half = this._strokeWidth / 2;
31592
+ return { x: -r2 - half, y: -r2 - half, width: (r2 + half) * 2, height: (r2 + half) * 2 };
33903
31593
  }
33904
31594
  }
33905
31595
  }
@@ -33917,12 +31607,12 @@ class ShapeElement extends BaseElement {
33917
31607
  const ly1 = this._shapeParams["ly1"];
33918
31608
  const lx2 = this._shapeParams["lx2"];
33919
31609
  const ly2 = this._shapeParams["ly2"];
33920
- g2.moveTo(lx1, ly1).lineTo(lx2, ly2).stroke({ color, width: this._strokeWidth });
31610
+ g2.moveTo(lx1, ly1).lineTo(lx2, ly2).stroke({ color, width: this._strokeWidth, cap: this._lineCap });
33921
31611
  break;
33922
31612
  }
33923
31613
  case "circle": {
33924
31614
  const r2 = this._shapeParams["radius"];
33925
- g2.circle(r2, r2, r2).fill({ color });
31615
+ g2.circle(0, 0, r2).fill({ color });
33926
31616
  break;
33927
31617
  }
33928
31618
  case "rectangle": {
@@ -33935,7 +31625,7 @@ class ShapeElement extends BaseElement {
33935
31625
  const r2 = this._shapeParams["radius"];
33936
31626
  const start = this._shapeParams["startAngle"];
33937
31627
  const end = this._shapeParams["endAngle"];
33938
- g2.arc(r2, r2, r2, start, end).stroke({ color, width: this._strokeWidth });
31628
+ g2.arc(0, 0, r2, start, end).stroke({ color, width: this._strokeWidth, cap: this._lineCap });
33939
31629
  break;
33940
31630
  }
33941
31631
  }
@@ -33953,7 +31643,8 @@ class ShapeElement extends BaseElement {
33953
31643
  backgroundColor: this._backgroundColor,
33954
31644
  fillPercentage: this._fillPercentage,
33955
31645
  fillDirection: this._fillDirection,
33956
- strokeWidth: this._strokeWidth
31646
+ strokeWidth: this._strokeWidth,
31647
+ lineCap: this._lineCap
33957
31648
  };
33958
31649
  }
33959
31650
  applyJSON(data) {
@@ -33967,6 +31658,8 @@ class ShapeElement extends BaseElement {
33967
31658
  this.fillDirection = data.fillDirection;
33968
31659
  if (data.strokeWidth !== undefined)
33969
31660
  this.strokeWidth = data.strokeWidth;
31661
+ if (data.lineCap !== undefined)
31662
+ this.lineCap = data.lineCap;
33970
31663
  this.x = data.x;
33971
31664
  this.y = data.y;
33972
31665
  this.rotation = data.rotation;
@@ -33982,7 +31675,8 @@ class ShapeElement extends BaseElement {
33982
31675
  backgroundColor: data.backgroundColor,
33983
31676
  fillPercentage: data.fillPercentage,
33984
31677
  fillDirection: data.fillDirection,
33985
- strokeWidth: data.strokeWidth
31678
+ strokeWidth: data.strokeWidth,
31679
+ lineCap: data.lineCap
33986
31680
  });
33987
31681
  el.x = data.x;
33988
31682
  el.y = data.y;
@@ -34200,33 +31894,44 @@ class MarqueeSelect {
34200
31894
  // src/selection/TransformController.ts
34201
31895
  class TransformController {
34202
31896
  eventBus;
31897
+ contentRoot = null;
34203
31898
  dragState = null;
34204
31899
  activeElements = [];
34205
31900
  constructor(eventBus) {
34206
31901
  this.eventBus = eventBus;
34207
31902
  }
31903
+ setContentRoot(root) {
31904
+ this.contentRoot = root;
31905
+ }
34208
31906
  get isDragging() {
34209
31907
  return this.dragState !== null;
34210
31908
  }
34211
31909
  get currentMode() {
34212
31910
  return this.dragState?.mode ?? "none";
34213
31911
  }
31912
+ toWorld(event) {
31913
+ if (this.contentRoot) {
31914
+ return this.contentRoot.toLocal({ x: event.globalX, y: event.globalY });
31915
+ }
31916
+ return { x: event.globalX, y: event.globalY };
31917
+ }
34214
31918
  startMove(elements, event) {
34215
31919
  this.activeElements = elements;
34216
31920
  const startProps = new Map;
34217
31921
  for (const el of elements) {
34218
31922
  startProps.set(el.id, { x: el.x, y: el.y, width: el.width, height: el.height, rotation: el.rotation });
34219
31923
  }
31924
+ const world = this.toWorld(event);
34220
31925
  this.dragState = {
34221
31926
  mode: "move",
34222
- startX: event.globalX,
34223
- startY: event.globalY,
31927
+ startX: world.x,
31928
+ startY: world.y,
34224
31929
  elementStartProps: startProps
34225
31930
  };
34226
31931
  if (elements.length > 0) {
34227
31932
  this.eventBus.emit("interaction:dragStart", {
34228
31933
  element: elements[0],
34229
- position: { x: event.globalX, y: event.globalY }
31934
+ position: { x: world.x, y: world.y }
34230
31935
  });
34231
31936
  }
34232
31937
  }
@@ -34236,10 +31941,11 @@ class TransformController {
34236
31941
  for (const el of elements) {
34237
31942
  startProps.set(el.id, { x: el.x, y: el.y, width: el.width, height: el.height, rotation: el.rotation });
34238
31943
  }
31944
+ const world = this.toWorld(event);
34239
31945
  this.dragState = {
34240
31946
  mode: "resize",
34241
- startX: event.globalX,
34242
- startY: event.globalY,
31947
+ startX: world.x,
31948
+ startY: world.y,
34243
31949
  handlePosition,
34244
31950
  elementStartProps: startProps
34245
31951
  };
@@ -34253,10 +31959,11 @@ class TransformController {
34253
31959
  for (const el of elements) {
34254
31960
  startProps.set(el.id, { x: el.x, y: el.y, width: el.width, height: el.height, rotation: el.rotation });
34255
31961
  }
31962
+ const world = this.toWorld(event);
34256
31963
  this.dragState = {
34257
31964
  mode: "rotate",
34258
- startX: event.globalX,
34259
- startY: event.globalY,
31965
+ startX: world.x,
31966
+ startY: world.y,
34260
31967
  elementStartProps: startProps
34261
31968
  };
34262
31969
  if (elements.length > 0) {
@@ -34308,8 +32015,9 @@ class TransformController {
34308
32015
  handleMove(event) {
34309
32016
  if (!this.dragState)
34310
32017
  return;
34311
- const dx = event.globalX - this.dragState.startX;
34312
- const dy = event.globalY - this.dragState.startY;
32018
+ const world = this.toWorld(event);
32019
+ const dx = world.x - this.dragState.startX;
32020
+ const dy = world.y - this.dragState.startY;
34313
32021
  for (const el of this.activeElements) {
34314
32022
  const start = this.dragState.elementStartProps.get(el.id);
34315
32023
  if (start) {
@@ -34326,13 +32034,16 @@ class TransformController {
34326
32034
  handleResize(event) {
34327
32035
  if (!this.dragState || !this.dragState.handlePosition)
34328
32036
  return;
34329
- const dx = event.globalX - this.dragState.startX;
34330
- const dy = event.globalY - this.dragState.startY;
32037
+ const world = this.toWorld(event);
32038
+ const dx = world.x - this.dragState.startX;
32039
+ const dy = world.y - this.dragState.startY;
34331
32040
  const handle = this.dragState.handlePosition;
32041
+ const constrain = event.shiftKey;
34332
32042
  for (const el of this.activeElements) {
34333
32043
  const start = this.dragState.elementStartProps.get(el.id);
34334
32044
  if (!start)
34335
32045
  continue;
32046
+ const aspect = start.height === 0 ? 1 : start.width / start.height;
34336
32047
  let newX = start.x;
34337
32048
  let newY = start.y;
34338
32049
  let newW = start.width;
@@ -34351,13 +32062,41 @@ class TransformController {
34351
32062
  if (handle.includes("bottom")) {
34352
32063
  newH = start.height + dy;
34353
32064
  }
32065
+ if (constrain && start.width > 0 && start.height > 0) {
32066
+ const isCorner = (handle.includes("left") || handle.includes("right")) && (handle.includes("top") || handle.includes("bottom"));
32067
+ if (isCorner) {
32068
+ const absDx = Math.abs(newW - start.width);
32069
+ const absDy = Math.abs(newH - start.height);
32070
+ if (absDx / aspect >= absDy) {
32071
+ newH = newW / aspect;
32072
+ if (handle.includes("top"))
32073
+ newY = start.y + start.height - newH;
32074
+ } else {
32075
+ newW = newH * aspect;
32076
+ if (handle.includes("left"))
32077
+ newX = start.x + start.width - newW;
32078
+ }
32079
+ } else {
32080
+ if (handle === "middle-left" || handle === "middle-right") {
32081
+ const centerY = start.y + start.height / 2;
32082
+ newH = newW / aspect;
32083
+ newY = centerY - newH / 2;
32084
+ } else {
32085
+ const centerX = start.x + start.width / 2;
32086
+ newW = newH * aspect;
32087
+ newX = centerX - newW / 2;
32088
+ }
32089
+ }
32090
+ }
34354
32091
  if (newW < 5) {
34355
32092
  newW = 5;
34356
- newX = start.x + start.width - 5;
32093
+ if (handle.includes("left"))
32094
+ newX = start.x + start.width - 5;
34357
32095
  }
34358
32096
  if (newH < 5) {
34359
32097
  newH = 5;
34360
- newY = start.y + start.height - 5;
32098
+ if (handle.includes("top"))
32099
+ newY = start.y + start.height - 5;
34361
32100
  }
34362
32101
  el.x = newX;
34363
32102
  el.y = newY;
@@ -34368,13 +32107,14 @@ class TransformController {
34368
32107
  handleRotate(event) {
34369
32108
  if (!this.dragState)
34370
32109
  return;
32110
+ const world = this.toWorld(event);
34371
32111
  for (const el of this.activeElements) {
34372
32112
  const start = this.dragState.elementStartProps.get(el.id);
34373
32113
  if (!start)
34374
32114
  continue;
34375
32115
  const cx = el.x + el.width / 2;
34376
32116
  const cy = el.y + el.height / 2;
34377
- const angle = angleBetweenPoints(cx, cy, event.globalX, event.globalY);
32117
+ const angle = angleBetweenPoints(cx, cy, world.x, world.y);
34378
32118
  const startAngle = angleBetweenPoints(cx, cy, this.dragState.startX, this.dragState.startY);
34379
32119
  el.rotation = start.rotation + (angle - startAngle);
34380
32120
  }
@@ -34392,6 +32132,7 @@ class SelectionManager {
34392
32132
  transformController;
34393
32133
  clipboard = [];
34394
32134
  layer = null;
32135
+ contentRoot = null;
34395
32136
  handleConfig = { color: 35071, fillColor: 16777215, size: 8 };
34396
32137
  isMarqueeActive = false;
34397
32138
  marqueeStart = { x: 0, y: 0 };
@@ -34409,11 +32150,15 @@ class SelectionManager {
34409
32150
  setSerializationManager(sm) {
34410
32151
  this.serializationManager = sm;
34411
32152
  }
34412
- init(layer, app, config) {
32153
+ init(layer, app, config, contentRoot) {
34413
32154
  this.layer = layer;
34414
32155
  if (config) {
34415
32156
  this.handleConfig = { ...this.handleConfig, ...config };
34416
32157
  }
32158
+ if (contentRoot) {
32159
+ this.contentRoot = contentRoot;
32160
+ this.transformController.setContentRoot(contentRoot);
32161
+ }
34417
32162
  this.layer.addChild(this.selectionBox.container);
34418
32163
  this.layer.addChild(this.marquee.graphics);
34419
32164
  this.wireHandleEvents();
@@ -34428,6 +32173,11 @@ class SelectionManager {
34428
32173
  this.selected.delete(element);
34429
32174
  this.updateSelectionVisuals();
34430
32175
  });
32176
+ this.eventBus.on("element:changed", ({ element }) => {
32177
+ if (this.selected.has(element)) {
32178
+ this.updateSelectionVisuals();
32179
+ }
32180
+ });
34431
32181
  }
34432
32182
  handleElementPointerDown(element, event) {
34433
32183
  if (!element.interactable)
@@ -34464,6 +32214,9 @@ class SelectionManager {
34464
32214
  this.clearSelection();
34465
32215
  this.addToSelection(element);
34466
32216
  }
32217
+ selectOnly(element) {
32218
+ this.select(element);
32219
+ }
34467
32220
  addToSelection(element) {
34468
32221
  this.selected.add(element);
34469
32222
  this.updateSelectionVisuals();
@@ -34474,6 +32227,9 @@ class SelectionManager {
34474
32227
  this.updateSelectionVisuals();
34475
32228
  this.eventBus.emit("selection:changed", { selected: this.getSelected() });
34476
32229
  }
32230
+ deselectAll() {
32231
+ this.clearSelection();
32232
+ }
34477
32233
  clearSelection() {
34478
32234
  if (this.selected.size === 0)
34479
32235
  return;
@@ -34538,12 +32294,13 @@ class SelectionManager {
34538
32294
  computeCombinedBounds(elements) {
34539
32295
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
34540
32296
  for (const el of elements) {
34541
- const display = el.getDisplayObject();
34542
- const b2 = display.getBounds();
34543
- minX = Math.min(minX, b2.x);
34544
- minY = Math.min(minY, b2.y);
34545
- maxX = Math.max(maxX, b2.x + b2.width);
34546
- maxY = Math.max(maxY, b2.y + b2.height);
32297
+ const b2 = el.getDisplayObject().getLocalBounds();
32298
+ const wx = el.x + b2.x;
32299
+ const wy = el.y + b2.y;
32300
+ minX = Math.min(minX, wx);
32301
+ minY = Math.min(minY, wy);
32302
+ maxX = Math.max(maxX, wx + b2.width);
32303
+ maxY = Math.max(maxY, wy + b2.height);
34547
32304
  }
34548
32305
  return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
34549
32306
  }
@@ -34560,14 +32317,19 @@ class SelectionManager {
34560
32317
  });
34561
32318
  }
34562
32319
  }
32320
+ toWorld(globalX, globalY) {
32321
+ if (this.contentRoot) {
32322
+ return this.contentRoot.toLocal({ x: globalX, y: globalY });
32323
+ }
32324
+ return { x: globalX, y: globalY };
32325
+ }
34563
32326
  onStagePointerDown(event) {
34564
- if (event.target === event.currentTarget) {
34565
- if (!event.shiftKey) {
34566
- this.clearSelection();
34567
- }
34568
- this.isMarqueeActive = true;
34569
- this.marqueeStart = { x: event.globalX, y: event.globalY };
32327
+ if (!event.shiftKey) {
32328
+ this.clearSelection();
34570
32329
  }
32330
+ this.isMarqueeActive = true;
32331
+ const world = this.toWorld(event.globalX, event.globalY);
32332
+ this.marqueeStart = { x: world.x, y: world.y };
34571
32333
  }
34572
32334
  onStagePointerMove(event) {
34573
32335
  if (this.transformController.isDragging && !this.isDraggingElement) {
@@ -34576,7 +32338,8 @@ class SelectionManager {
34576
32338
  return;
34577
32339
  }
34578
32340
  if (this.isMarqueeActive) {
34579
- this.marquee.draw(this.marqueeStart.x, this.marqueeStart.y, event.globalX, event.globalY);
32341
+ const world = this.toWorld(event.globalX, event.globalY);
32342
+ this.marquee.draw(this.marqueeStart.x, this.marqueeStart.y, world.x, world.y);
34580
32343
  }
34581
32344
  }
34582
32345
  onStagePointerUp(event) {
@@ -34586,14 +32349,21 @@ class SelectionManager {
34586
32349
  }
34587
32350
  if (this.isMarqueeActive) {
34588
32351
  this.isMarqueeActive = false;
34589
- const rect = this.marquee.getRect(this.marqueeStart.x, this.marqueeStart.y, event.globalX, event.globalY);
32352
+ const world = this.toWorld(event.globalX, event.globalY);
32353
+ const rect = this.marquee.getRect(this.marqueeStart.x, this.marqueeStart.y, world.x, world.y);
34590
32354
  this.marquee.clear();
34591
32355
  if (rect.width > 3 || rect.height > 3) {
34592
32356
  for (const el of this.elementManager.getAll()) {
34593
32357
  if (!el.interactable)
34594
32358
  continue;
34595
- const b2 = el.getDisplayObject().getBounds();
34596
- if (this.boundsOverlap(rect, { x: b2.x, y: b2.y, width: b2.width, height: b2.height })) {
32359
+ const lb = el.getDisplayObject().getLocalBounds();
32360
+ const elBounds = {
32361
+ x: el.x + lb.x,
32362
+ y: el.y + lb.y,
32363
+ width: lb.width,
32364
+ height: lb.height
32365
+ };
32366
+ if (this.boundsOverlap(rect, elBounds)) {
34597
32367
  this.selected.add(el);
34598
32368
  }
34599
32369
  }
@@ -34726,7 +32496,7 @@ class WatchfaceEngine {
34726
32496
  handleConfig.fillColor = options.selectionHandleFillColor;
34727
32497
  if (options.selectionHandleSize !== undefined)
34728
32498
  handleConfig.size = options.selectionHandleSize;
34729
- this.selection.init(this.selectionLayer, this.app, handleConfig);
32499
+ this.selection.init(this.selectionLayer, this.app, handleConfig, this._contentRoot);
34730
32500
  this._initialized = true;
34731
32501
  this.eventBus.emit("engine:ready");
34732
32502
  }
@@ -34811,9 +32581,12 @@ class GridPlugin {
34811
32581
  this.gridGraphics = new Graphics;
34812
32582
  this.gridGraphics.alpha = this.options.opacity;
34813
32583
  this.gridGraphics.visible = this.options.visible;
34814
- engine.getBackgroundLayer().addChild(this.gridGraphics);
32584
+ engine.app.stage.addChild(this.gridGraphics);
34815
32585
  this.drawGrid();
34816
- const unsub = engine.eventBus.on("interaction:dragMove", ({ elements }) => {
32586
+ const unsubZoom = engine.eventBus.on("viewport:zoomed", () => this.drawGrid());
32587
+ const unsubMove = engine.eventBus.on("viewport:moved", () => this.drawGrid());
32588
+ this.unsubscribers.push(unsubZoom, unsubMove);
32589
+ const unsubDrag = engine.eventBus.on("interaction:dragMove", ({ elements }) => {
34817
32590
  if (!this.options.snapEnabled)
34818
32591
  return;
34819
32592
  for (const el of elements) {
@@ -34821,7 +32594,7 @@ class GridPlugin {
34821
32594
  el.y = this.snapValue(el.y);
34822
32595
  }
34823
32596
  });
34824
- this.unsubscribers.push(unsub);
32597
+ this.unsubscribers.push(unsubDrag);
34825
32598
  }
34826
32599
  snapValue(value) {
34827
32600
  return Math.round(value / this.options.cellSize) * this.options.cellSize;
@@ -34831,17 +32604,26 @@ class GridPlugin {
34831
32604
  const { width, height } = this.engine.options;
34832
32605
  const { x: ox, y: oy } = this.engine.originOffset;
34833
32606
  const { cellSize, color } = this.options;
34834
- const left = -ox;
34835
- const top = -oy;
34836
- const right = width - ox;
34837
- const bottom = height - oy;
34838
- const startX = Math.ceil(left / cellSize) * cellSize;
34839
- const startY = Math.ceil(top / cellSize) * cellSize;
34840
- for (let x2 = startX;x2 <= right; x2 += cellSize) {
34841
- this.gridGraphics.moveTo(x2, top).lineTo(x2, bottom).stroke({ color, width: 0.5 });
34842
- }
34843
- for (let y2 = startY;y2 <= bottom; y2 += cellSize) {
34844
- this.gridGraphics.moveTo(left, y2).lineTo(right, y2).stroke({ color, width: 0.5 });
32607
+ const viewportPlugin = this.engine.plugins.get("viewport");
32608
+ const viewport = viewportPlugin?.viewport;
32609
+ let scale = 1;
32610
+ let panX = 0;
32611
+ let panY = 0;
32612
+ if (viewport) {
32613
+ scale = viewport.scale.x;
32614
+ panX = viewport.x;
32615
+ panY = viewport.y;
32616
+ }
32617
+ const originScreenX = panX + ox * scale;
32618
+ const originScreenY = panY + oy * scale;
32619
+ const screenCell = cellSize * scale;
32620
+ const startX = originScreenX - Math.ceil(originScreenX / screenCell) * screenCell;
32621
+ const startY = originScreenY - Math.ceil(originScreenY / screenCell) * screenCell;
32622
+ for (let sx = startX;sx <= width; sx += screenCell) {
32623
+ this.gridGraphics.moveTo(sx, 0).lineTo(sx, height).stroke({ color, width: 0.5 });
32624
+ }
32625
+ for (let sy = startY;sy <= height; sy += screenCell) {
32626
+ this.gridGraphics.moveTo(0, sy).lineTo(width, sy).stroke({ color, width: 0.5 });
34845
32627
  }
34846
32628
  }
34847
32629
  destroy() {