modern-canvas 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  import { extend, colord } from 'colord';
2
2
  import namesPlugin from 'colord/plugins/names';
3
3
  import earcut from 'earcut';
4
- import { textDefaultStyle, measureText, renderText } from 'modern-text';
4
+ import { getDefaultTextStyle, getDefaultTransformStyle } from 'modern-idoc';
5
+ import { textDefaultStyle, Text } from 'modern-text';
5
6
 
6
7
  const PI = Math.PI;
7
8
  const PI_2 = PI * 2;
@@ -616,13 +617,13 @@ class Geometry extends Resource {
616
617
  }
617
618
  }
618
619
 
619
- var __defProp$C = Object.defineProperty;
620
- var __decorateClass$C = (decorators, target, key, kind) => {
620
+ var __defProp$B = Object.defineProperty;
621
+ var __decorateClass$B = (decorators, target, key, kind) => {
621
622
  var result = void 0 ;
622
623
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
623
624
  if (decorator = decorators[i])
624
625
  result = (decorator(target, key, result) ) || result;
625
- if (result) __defProp$C(target, key, result);
626
+ if (result) __defProp$B(target, key, result);
626
627
  return result;
627
628
  };
628
629
  class IndexBuffer extends Resource {
@@ -666,20 +667,20 @@ class IndexBuffer extends Resource {
666
667
  return result;
667
668
  }
668
669
  }
669
- __decorateClass$C([
670
+ __decorateClass$B([
670
671
  protectedProperty({ default: null })
671
672
  ], IndexBuffer.prototype, "data");
672
- __decorateClass$C([
673
+ __decorateClass$B([
673
674
  protectedProperty({ default: false })
674
675
  ], IndexBuffer.prototype, "dynamic");
675
676
 
676
- var __defProp$B = Object.defineProperty;
677
- var __decorateClass$B = (decorators, target, key, kind) => {
677
+ var __defProp$A = Object.defineProperty;
678
+ var __decorateClass$A = (decorators, target, key, kind) => {
678
679
  var result = void 0 ;
679
680
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
680
681
  if (decorator = decorators[i])
681
682
  result = (decorator(target, key, result) ) || result;
682
- if (result) __defProp$B(target, key, result);
683
+ if (result) __defProp$A(target, key, result);
683
684
  return result;
684
685
  };
685
686
  class VertexBuffer extends Resource {
@@ -723,20 +724,20 @@ class VertexBuffer extends Resource {
723
724
  return result;
724
725
  }
725
726
  }
726
- __decorateClass$B([
727
+ __decorateClass$A([
727
728
  protectedProperty({ default: null })
728
729
  ], VertexBuffer.prototype, "data");
729
- __decorateClass$B([
730
+ __decorateClass$A([
730
731
  protectedProperty({ default: false })
731
732
  ], VertexBuffer.prototype, "dynamic");
732
733
 
733
- var __defProp$A = Object.defineProperty;
734
- var __decorateClass$A = (decorators, target, key, kind) => {
734
+ var __defProp$z = Object.defineProperty;
735
+ var __decorateClass$z = (decorators, target, key, kind) => {
735
736
  var result = void 0 ;
736
737
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
737
738
  if (decorator = decorators[i])
738
739
  result = (decorator(target, key, result) ) || result;
739
- if (result) __defProp$A(target, key, result);
740
+ if (result) __defProp$z(target, key, result);
740
741
  return result;
741
742
  };
742
743
  class VertexAttribute extends Resource {
@@ -773,25 +774,25 @@ class VertexAttribute extends Resource {
773
774
  return result;
774
775
  }
775
776
  }
776
- __decorateClass$A([
777
+ __decorateClass$z([
777
778
  protectedProperty()
778
779
  ], VertexAttribute.prototype, "buffer");
779
- __decorateClass$A([
780
+ __decorateClass$z([
780
781
  protectedProperty({ default: 0 })
781
782
  ], VertexAttribute.prototype, "size");
782
- __decorateClass$A([
783
+ __decorateClass$z([
783
784
  protectedProperty({ default: false })
784
785
  ], VertexAttribute.prototype, "normalized");
785
- __decorateClass$A([
786
+ __decorateClass$z([
786
787
  protectedProperty({ default: "float" })
787
788
  ], VertexAttribute.prototype, "type");
788
- __decorateClass$A([
789
+ __decorateClass$z([
789
790
  protectedProperty()
790
791
  ], VertexAttribute.prototype, "stride");
791
- __decorateClass$A([
792
+ __decorateClass$z([
792
793
  protectedProperty()
793
794
  ], VertexAttribute.prototype, "offset");
794
- __decorateClass$A([
795
+ __decorateClass$z([
795
796
  protectedProperty()
796
797
  ], VertexAttribute.prototype, "divisor");
797
798
 
@@ -975,13 +976,13 @@ class UvGeometry extends Geometry {
975
976
  }
976
977
  }
977
978
 
978
- var __defProp$z = Object.defineProperty;
979
- var __decorateClass$z = (decorators, target, key, kind) => {
979
+ var __defProp$y = Object.defineProperty;
980
+ var __decorateClass$y = (decorators, target, key, kind) => {
980
981
  var result = void 0 ;
981
982
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
982
983
  if (decorator = decorators[i])
983
984
  result = (decorator(target, key, result) ) || result;
984
- if (result) __defProp$z(target, key, result);
985
+ if (result) __defProp$y(target, key, result);
985
986
  return result;
986
987
  };
987
988
  class MainLoop extends _Object {
@@ -1022,10 +1023,10 @@ class MainLoop extends _Object {
1022
1023
  }
1023
1024
  }
1024
1025
  }
1025
- __decorateClass$z([
1026
+ __decorateClass$y([
1026
1027
  property({ default: 24 })
1027
1028
  ], MainLoop.prototype, "fps");
1028
- __decorateClass$z([
1029
+ __decorateClass$y([
1029
1030
  property({ default: 1 })
1030
1031
  ], MainLoop.prototype, "speed");
1031
1032
 
@@ -3998,14 +3999,14 @@ class Vector4 extends Vector {
3998
3999
  }
3999
4000
  }
4000
4001
 
4001
- var __defProp$y = Object.defineProperty;
4002
- var __getOwnPropDesc$u = Object.getOwnPropertyDescriptor;
4003
- var __decorateClass$y = (decorators, target, key, kind) => {
4004
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$u(target, key) : target;
4002
+ var __defProp$x = Object.defineProperty;
4003
+ var __getOwnPropDesc$t = Object.getOwnPropertyDescriptor;
4004
+ var __decorateClass$x = (decorators, target, key, kind) => {
4005
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$t(target, key) : target;
4005
4006
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4006
4007
  if (decorator = decorators[i])
4007
4008
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
4008
- if (kind && result) __defProp$y(target, key, result);
4009
+ if (kind && result) __defProp$x(target, key, result);
4009
4010
  return result;
4010
4011
  };
4011
4012
  var InternalMode = /* @__PURE__ */ ((InternalMode2) => {
@@ -4403,22 +4404,22 @@ let Node = class extends Reference {
4403
4404
  return node;
4404
4405
  }
4405
4406
  };
4406
- __decorateClass$y([
4407
+ __decorateClass$x([
4407
4408
  property()
4408
4409
  ], Node.prototype, "name", 2);
4409
- __decorateClass$y([
4410
+ __decorateClass$x([
4410
4411
  property()
4411
4412
  ], Node.prototype, "mask", 2);
4412
- __decorateClass$y([
4413
+ __decorateClass$x([
4413
4414
  property({ default: "visible" })
4414
4415
  ], Node.prototype, "visibility", 2);
4415
- __decorateClass$y([
4416
+ __decorateClass$x([
4416
4417
  property({ default: 0 })
4417
4418
  ], Node.prototype, "visibleDelay", 2);
4418
- __decorateClass$y([
4419
+ __decorateClass$x([
4419
4420
  property({ default: Number.MAX_SAFE_INTEGER })
4420
4421
  ], Node.prototype, "visibleDuration", 2);
4421
- Node = __decorateClass$y([
4422
+ Node = __decorateClass$x([
4422
4423
  customNode("Node")
4423
4424
  ], Node);
4424
4425
 
@@ -4448,14 +4449,14 @@ class RenderStack {
4448
4449
  }
4449
4450
  }
4450
4451
 
4451
- var __defProp$x = Object.defineProperty;
4452
- var __getOwnPropDesc$t = Object.getOwnPropertyDescriptor;
4453
- var __decorateClass$x = (decorators, target, key, kind) => {
4454
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$t(target, key) : target;
4452
+ var __defProp$w = Object.defineProperty;
4453
+ var __getOwnPropDesc$s = Object.getOwnPropertyDescriptor;
4454
+ var __decorateClass$w = (decorators, target, key, kind) => {
4455
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$s(target, key) : target;
4455
4456
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4456
4457
  if (decorator = decorators[i])
4457
4458
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
4458
- if (kind && result) __defProp$x(target, key, result);
4459
+ if (kind && result) __defProp$w(target, key, result);
4459
4460
  return result;
4460
4461
  };
4461
4462
  let Timer = class extends Node {
@@ -4497,29 +4498,29 @@ let Timer = class extends Node {
4497
4498
  this.addTime(delta);
4498
4499
  }
4499
4500
  };
4500
- __decorateClass$x([
4501
+ __decorateClass$w([
4501
4502
  property({ default: 0 })
4502
4503
  ], Timer.prototype, "start", 2);
4503
- __decorateClass$x([
4504
+ __decorateClass$w([
4504
4505
  property({ default: 0 })
4505
4506
  ], Timer.prototype, "current", 2);
4506
- __decorateClass$x([
4507
+ __decorateClass$w([
4507
4508
  property({ default: Number.MAX_SAFE_INTEGER })
4508
4509
  ], Timer.prototype, "end", 2);
4509
- __decorateClass$x([
4510
+ __decorateClass$w([
4510
4511
  property({ default: false })
4511
4512
  ], Timer.prototype, "loop", 2);
4512
- Timer = __decorateClass$x([
4513
+ Timer = __decorateClass$w([
4513
4514
  customNode("Timer")
4514
4515
  ], Timer);
4515
4516
 
4516
- var __defProp$w = Object.defineProperty;
4517
- var __decorateClass$w = (decorators, target, key, kind) => {
4517
+ var __defProp$v = Object.defineProperty;
4518
+ var __decorateClass$v = (decorators, target, key, kind) => {
4518
4519
  var result = void 0 ;
4519
4520
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4520
4521
  if (decorator = decorators[i])
4521
4522
  result = (decorator(target, key, result) ) || result;
4522
- if (result) __defProp$w(target, key, result);
4523
+ if (result) __defProp$v(target, key, result);
4523
4524
  return result;
4524
4525
  };
4525
4526
  class Texture extends Resource {
@@ -4645,22 +4646,22 @@ class Texture extends Resource {
4645
4646
  }
4646
4647
  }
4647
4648
  }
4648
- __decorateClass$w([
4649
+ __decorateClass$v([
4649
4650
  protectedProperty()
4650
4651
  ], Texture.prototype, "source");
4651
- __decorateClass$w([
4652
+ __decorateClass$v([
4652
4653
  protectedProperty({ default: 0 })
4653
4654
  ], Texture.prototype, "width");
4654
- __decorateClass$w([
4655
+ __decorateClass$v([
4655
4656
  protectedProperty({ default: 0 })
4656
4657
  ], Texture.prototype, "height");
4657
- __decorateClass$w([
4658
+ __decorateClass$v([
4658
4659
  protectedProperty({ default: "linear" })
4659
4660
  ], Texture.prototype, "filterMode");
4660
- __decorateClass$w([
4661
+ __decorateClass$v([
4661
4662
  protectedProperty({ default: "clamp_to_edge" })
4662
4663
  ], Texture.prototype, "wrapMode");
4663
- __decorateClass$w([
4664
+ __decorateClass$v([
4664
4665
  protectedProperty({ default: 1 })
4665
4666
  ], Texture.prototype, "pixelRatio");
4666
4667
 
@@ -4796,13 +4797,13 @@ class PixelsTexture extends Texture {
4796
4797
  }
4797
4798
  }
4798
4799
 
4799
- var __defProp$v = Object.defineProperty;
4800
- var __decorateClass$v = (decorators, target, key, kind) => {
4800
+ var __defProp$u = Object.defineProperty;
4801
+ var __decorateClass$u = (decorators, target, key, kind) => {
4801
4802
  var result = void 0 ;
4802
4803
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4803
4804
  if (decorator = decorators[i])
4804
4805
  result = (decorator(target, key, result) ) || result;
4805
- if (result) __defProp$v(target, key, result);
4806
+ if (result) __defProp$u(target, key, result);
4806
4807
  return result;
4807
4808
  };
4808
4809
  function resolveOptions(options) {
@@ -5045,10 +5046,10 @@ const _VideoTexture = class _VideoTexture extends Texture {
5045
5046
  }
5046
5047
  }
5047
5048
  };
5048
- __decorateClass$v([
5049
+ __decorateClass$u([
5049
5050
  protectedProperty({ default: true })
5050
5051
  ], _VideoTexture.prototype, "autoUpdate");
5051
- __decorateClass$v([
5052
+ __decorateClass$u([
5052
5053
  protectedProperty({ default: 0 })
5053
5054
  ], _VideoTexture.prototype, "fps");
5054
5055
  let VideoTexture = _VideoTexture;
@@ -5057,14 +5058,14 @@ class ViewportTexture extends PixelsTexture {
5057
5058
  //
5058
5059
  }
5059
5060
 
5060
- var __defProp$u = Object.defineProperty;
5061
- var __getOwnPropDesc$s = Object.getOwnPropertyDescriptor;
5062
- var __decorateClass$u = (decorators, target, key, kind) => {
5063
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$s(target, key) : target;
5061
+ var __defProp$t = Object.defineProperty;
5062
+ var __getOwnPropDesc$r = Object.getOwnPropertyDescriptor;
5063
+ var __decorateClass$t = (decorators, target, key, kind) => {
5064
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$r(target, key) : target;
5064
5065
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
5065
5066
  if (decorator = decorators[i])
5066
5067
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
5067
- if (kind && result) __defProp$u(target, key, result);
5068
+ if (kind && result) __defProp$t(target, key, result);
5068
5069
  return result;
5069
5070
  };
5070
5071
  let Viewport = class extends Node {
@@ -5185,19 +5186,19 @@ let Viewport = class extends Node {
5185
5186
  return this._projection.toArray(transpose);
5186
5187
  }
5187
5188
  };
5188
- __decorateClass$u([
5189
+ __decorateClass$t([
5189
5190
  property({ default: 0 })
5190
5191
  ], Viewport.prototype, "x", 2);
5191
- __decorateClass$u([
5192
+ __decorateClass$t([
5192
5193
  property({ default: 0 })
5193
5194
  ], Viewport.prototype, "y", 2);
5194
- __decorateClass$u([
5195
+ __decorateClass$t([
5195
5196
  property({ default: 0 })
5196
5197
  ], Viewport.prototype, "width", 2);
5197
- __decorateClass$u([
5198
+ __decorateClass$t([
5198
5199
  property({ default: 0 })
5199
5200
  ], Viewport.prototype, "height", 2);
5200
- Viewport = __decorateClass$u([
5201
+ Viewport = __decorateClass$t([
5201
5202
  customNode({
5202
5203
  tag: "Viewport",
5203
5204
  renderable: true
@@ -5616,13 +5617,13 @@ class ColorTexture extends Texture {
5616
5617
  }
5617
5618
  }
5618
5619
 
5619
- var __defProp$t = Object.defineProperty;
5620
- var __decorateClass$t = (decorators, target, key, kind) => {
5620
+ var __defProp$s = Object.defineProperty;
5621
+ var __decorateClass$s = (decorators, target, key, kind) => {
5621
5622
  var result = void 0 ;
5622
5623
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
5623
5624
  if (decorator = decorators[i])
5624
5625
  result = (decorator(target, key, result) ) || result;
5625
- if (result) __defProp$t(target, key, result);
5626
+ if (result) __defProp$s(target, key, result);
5626
5627
  return result;
5627
5628
  };
5628
5629
  function proxy$1() {
@@ -5778,46 +5779,46 @@ class CanvasContext {
5778
5779
  return batchables;
5779
5780
  }
5780
5781
  }
5781
- __decorateClass$t([
5782
+ __decorateClass$s([
5782
5783
  proxy$1()
5783
5784
  ], CanvasContext.prototype, "moveTo");
5784
- __decorateClass$t([
5785
+ __decorateClass$s([
5785
5786
  proxy$1()
5786
5787
  ], CanvasContext.prototype, "lineTo");
5787
- __decorateClass$t([
5788
+ __decorateClass$s([
5788
5789
  proxy$1()
5789
5790
  ], CanvasContext.prototype, "bezierCurveTo");
5790
- __decorateClass$t([
5791
+ __decorateClass$s([
5791
5792
  proxy$1()
5792
5793
  ], CanvasContext.prototype, "quadraticCurveTo");
5793
- __decorateClass$t([
5794
+ __decorateClass$s([
5794
5795
  proxy$1()
5795
5796
  ], CanvasContext.prototype, "ellipticalArc");
5796
- __decorateClass$t([
5797
+ __decorateClass$s([
5797
5798
  proxy$1()
5798
5799
  ], CanvasContext.prototype, "rect");
5799
- __decorateClass$t([
5800
+ __decorateClass$s([
5800
5801
  proxy$1()
5801
5802
  ], CanvasContext.prototype, "roundRect");
5802
- __decorateClass$t([
5803
+ __decorateClass$s([
5803
5804
  proxy$1()
5804
5805
  ], CanvasContext.prototype, "ellipse");
5805
- __decorateClass$t([
5806
+ __decorateClass$s([
5806
5807
  proxy$1()
5807
5808
  ], CanvasContext.prototype, "arc");
5808
- __decorateClass$t([
5809
+ __decorateClass$s([
5809
5810
  proxy$1()
5810
5811
  ], CanvasContext.prototype, "poly");
5811
- __decorateClass$t([
5812
+ __decorateClass$s([
5812
5813
  proxy$1()
5813
5814
  ], CanvasContext.prototype, "addShape");
5814
- __decorateClass$t([
5815
+ __decorateClass$s([
5815
5816
  proxy$1()
5816
5817
  ], CanvasContext.prototype, "addPath");
5817
- __decorateClass$t([
5818
+ __decorateClass$s([
5818
5819
  proxy$1()
5819
5820
  ], CanvasContext.prototype, "addSvgPath");
5820
- __decorateClass$t([
5821
+ __decorateClass$s([
5821
5822
  proxy$1()
5822
5823
  ], CanvasContext.prototype, "closePath");
5823
5824
 
@@ -6185,16 +6186,13 @@ class Style2DBackgroundModule extends Style2DModule {
6185
6186
  install(Style2D) {
6186
6187
  defineProperty(Style2D, "backgroundColor");
6187
6188
  defineProperty(Style2D, "backgroundImage");
6188
- Style2D.prototype.getComputedBackground = getComputedBackground;
6189
+ Style2D.prototype.getComputedBackgroundImage = getComputedBackgroundImage;
6189
6190
  }
6190
6191
  }
6191
- async function getComputedBackground() {
6192
+ async function getComputedBackgroundImage() {
6192
6193
  if (this.backgroundImage) {
6193
6194
  return await assets.texture.load(this.backgroundImage);
6194
6195
  }
6195
- if (this.backgroundColor) {
6196
- return new ColorTexture(this.backgroundColor);
6197
- }
6198
6196
  }
6199
6197
 
6200
6198
  class Style2DFilterModule extends Style2DModule {
@@ -6259,61 +6257,22 @@ function getComputedFilterColorMatrix() {
6259
6257
  return m;
6260
6258
  }
6261
6259
 
6262
- class Style2DOffsetModule extends Style2DModule {
6263
- install(Style2D) {
6264
- defineProperty(Style2D, "offsetPath");
6265
- defineProperty(Style2D, "offsetAnchor");
6266
- defineProperty(Style2D, "offsetDistance");
6267
- defineProperty(Style2D, "offsetPosition");
6268
- Style2D.prototype.getComputedOffset = getComputedOffset;
6269
- }
6270
- }
6271
- function getComputedOffset() {
6272
- const offsetPath = this.offsetPath;
6273
- if (!offsetPath)
6274
- return;
6275
- if (offsetPath.startsWith("path")) {
6276
- const path = offsetPath.match(/path\(["'](.+)["']\)/)?.[1];
6277
- if (!path)
6278
- return;
6279
- path.split(" ").forEach((arg) => {
6280
- });
6281
- } else if (offsetPath.startsWith("ray")) ; else if (offsetPath.startsWith("url")) ; else if (offsetPath.startsWith("circle")) ; else if (offsetPath.startsWith("ellipse")) ; else if (offsetPath.startsWith("insett")) ; else if (offsetPath.startsWith("polygon")) ; else if (offsetPath.startsWith("rect")) ; else if (offsetPath.startsWith("xywh")) ;
6282
- }
6283
-
6284
6260
  class Style2DTextModule extends Style2DModule {
6285
6261
  install(Style2D) {
6286
- defineProperty(Style2D, "color", { default: "#000000" });
6287
- defineProperty(Style2D, "fontSize", { default: 14 });
6288
- defineProperty(Style2D, "fontWeight", { default: "normal" });
6289
- defineProperty(Style2D, "fontFamily", { default: "sans-serif" });
6290
- defineProperty(Style2D, "fontStyle", { default: "normal" });
6291
- defineProperty(Style2D, "fontKerning", { default: "normal" });
6292
- defineProperty(Style2D, "textWrap", { default: "wrap" });
6293
- defineProperty(Style2D, "textAlign", { default: "start" });
6294
- defineProperty(Style2D, "verticalAlign", { default: "middle" });
6295
- defineProperty(Style2D, "textTransform", { default: "none" });
6296
- defineProperty(Style2D, "textDecoration", { default: null });
6297
- defineProperty(Style2D, "textStrokeWidth", { default: 0 });
6298
- defineProperty(Style2D, "textStrokeColor", { default: "#000000" });
6262
+ const style = getDefaultTextStyle();
6263
+ for (const key in style) {
6264
+ defineProperty(Style2D, key, { default: style[key] });
6265
+ }
6299
6266
  defineProperty(Style2D, "direction", { default: "inherit" });
6300
- defineProperty(Style2D, "lineHeight", { default: 1 });
6301
- defineProperty(Style2D, "letterSpacing", { default: 0 });
6302
- defineProperty(Style2D, "writingMode", { default: "horizontal-tb" });
6303
6267
  }
6304
6268
  }
6305
6269
 
6306
6270
  class Style2DTransformModule extends Style2DModule {
6307
6271
  install(Style2D) {
6308
- defineProperty(Style2D, "left", { default: 0 });
6309
- defineProperty(Style2D, "top", { default: 0 });
6310
- defineProperty(Style2D, "width", { default: 0 });
6311
- defineProperty(Style2D, "height", { default: 0 });
6312
- defineProperty(Style2D, "rotate", { default: 0 });
6313
- defineProperty(Style2D, "scaleX", { default: 1 });
6314
- defineProperty(Style2D, "scaleY", { default: 1 });
6315
- defineProperty(Style2D, "transform");
6316
- defineProperty(Style2D, "transformOrigin", { default: "center" });
6272
+ const style = getDefaultTransformStyle();
6273
+ for (const key in style) {
6274
+ defineProperty(Style2D, key, { default: style[key] });
6275
+ }
6317
6276
  Style2D.prototype.getComputedTransform = getComputedTransform;
6318
6277
  Style2D.prototype.getComputedTransformOrigin = getComputedTransformOrigin;
6319
6278
  }
@@ -6322,7 +6281,11 @@ function getComputedTransform() {
6322
6281
  const transform = new Transform2D();
6323
6282
  const transform3d = new Transform2D(false);
6324
6283
  const transform2d = new Transform2D(false).scale(this.scaleX, this.scaleY).translate(this.left, this.top).rotate(this.rotate * DEG_TO_RAD);
6325
- parseCssFunctions(this.transform ?? "", { width: this.width, height: this.height }).forEach(({ name, args }) => {
6284
+ let _transform = this.transform;
6285
+ if (!_transform || _transform === "none") {
6286
+ _transform = "";
6287
+ }
6288
+ parseCssFunctions(_transform, { width: this.width, height: this.height }).forEach(({ name, args }) => {
6326
6289
  const values = args.map((arg) => arg.normalizedIntValue);
6327
6290
  transform.identity();
6328
6291
  switch (name) {
@@ -6433,22 +6396,13 @@ function getComputedTransformOrigin() {
6433
6396
  });
6434
6397
  }
6435
6398
 
6436
- const modules = {
6437
- __proto__: null,
6438
- Style2DBackgroundModule: Style2DBackgroundModule,
6439
- Style2DFilterModule: Style2DFilterModule,
6440
- Style2DOffsetModule: Style2DOffsetModule,
6441
- Style2DTextModule: Style2DTextModule,
6442
- Style2DTransformModule: Style2DTransformModule
6443
- };
6444
-
6445
- var __defProp$s = Object.defineProperty;
6446
- var __decorateClass$s = (decorators, target, key, kind) => {
6399
+ var __defProp$r = Object.defineProperty;
6400
+ var __decorateClass$r = (decorators, target, key, kind) => {
6447
6401
  var result = void 0 ;
6448
6402
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6449
6403
  if (decorator = decorators[i])
6450
6404
  result = (decorator(target, key, result) ) || result;
6451
- if (result) __defProp$s(target, key, result);
6405
+ if (result) __defProp$r(target, key, result);
6452
6406
  return result;
6453
6407
  };
6454
6408
  class Style2D extends _Object {
@@ -6474,39 +6428,44 @@ class Style2D extends _Object {
6474
6428
  }
6475
6429
  }
6476
6430
  }
6477
- __decorateClass$s([
6431
+ __decorateClass$r([
6478
6432
  property({ default: "#000000" })
6479
6433
  ], Style2D.prototype, "shadowColor");
6480
- __decorateClass$s([
6434
+ __decorateClass$r([
6481
6435
  property({ default: 0 })
6482
6436
  ], Style2D.prototype, "shadowOffsetX");
6483
- __decorateClass$s([
6437
+ __decorateClass$r([
6484
6438
  property({ default: 0 })
6485
6439
  ], Style2D.prototype, "shadowOffsetY");
6486
- __decorateClass$s([
6440
+ __decorateClass$r([
6487
6441
  property({ default: 0 })
6488
6442
  ], Style2D.prototype, "shadowBlur");
6489
- __decorateClass$s([
6443
+ __decorateClass$r([
6490
6444
  property({ default: 1 })
6491
6445
  ], Style2D.prototype, "opacity");
6492
- __decorateClass$s([
6446
+ __decorateClass$r([
6493
6447
  property({ default: 0 })
6494
6448
  ], Style2D.prototype, "borderRadius");
6495
- __decorateClass$s([
6449
+ __decorateClass$r([
6496
6450
  property({ default: "visible" })
6497
6451
  ], Style2D.prototype, "overflow");
6498
- Object.values(modules).forEach((Module) => {
6452
+ [
6453
+ Style2DBackgroundModule,
6454
+ Style2DFilterModule,
6455
+ Style2DTextModule,
6456
+ Style2DTransformModule
6457
+ ].forEach((Module) => {
6499
6458
  new Module().install(Style2D);
6500
6459
  });
6501
6460
 
6502
- var __defProp$r = Object.defineProperty;
6503
- var __getOwnPropDesc$r = Object.getOwnPropertyDescriptor;
6504
- var __decorateClass$r = (decorators, target, key, kind) => {
6505
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$r(target, key) : target;
6461
+ var __defProp$q = Object.defineProperty;
6462
+ var __getOwnPropDesc$q = Object.getOwnPropertyDescriptor;
6463
+ var __decorateClass$q = (decorators, target, key, kind) => {
6464
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$q(target, key) : target;
6506
6465
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6507
6466
  if (decorator = decorators[i])
6508
6467
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
6509
- if (kind && result) __defProp$r(target, key, result);
6468
+ if (kind && result) __defProp$q(target, key, result);
6510
6469
  return result;
6511
6470
  };
6512
6471
  let CanvasItem = class extends Node {
@@ -6525,12 +6484,13 @@ let CanvasItem = class extends Node {
6525
6484
  _parentOpacity;
6526
6485
  _tint = new Color(4294967295);
6527
6486
  _backgroundColor = new Color(0);
6528
- // 2d batch render
6487
+ _backgroundImage;
6488
+ // Batch render
6529
6489
  context = new CanvasContext();
6530
6490
  _resetContext = true;
6531
- _waitingRedraw = false;
6532
- _waitingReflow = false;
6533
- _waitingRepaint = false;
6491
+ _redrawing = false;
6492
+ _reflowing = false;
6493
+ _repainting = false;
6534
6494
  _originalBatchables = [];
6535
6495
  _layoutedBatchables = [];
6536
6496
  _batchables = [];
@@ -6564,12 +6524,10 @@ let CanvasItem = class extends Node {
6564
6524
  _onUpdateStyleProperty(key, newValue, oldValue, declaration) {
6565
6525
  switch (key) {
6566
6526
  case "backgroundColor":
6567
- this._backgroundColor.value = newValue || 0;
6568
- if (this._originalBatchables.length) {
6569
- this.requestRepaint();
6570
- } else if (this._backgroundColor.a > 0) {
6571
- this.requestRedraw();
6572
- }
6527
+ this._updateBackgroundColor();
6528
+ break;
6529
+ case "backgroundImage":
6530
+ this._updateBackgroundImage();
6573
6531
  break;
6574
6532
  case "opacity":
6575
6533
  this._updateOpacity();
@@ -6577,8 +6535,23 @@ let CanvasItem = class extends Node {
6577
6535
  case "filter":
6578
6536
  this.requestRepaint();
6579
6537
  break;
6538
+ case "borderRadius":
6539
+ this.requestRedraw();
6540
+ break;
6580
6541
  }
6581
6542
  }
6543
+ _updateBackgroundColor() {
6544
+ this._backgroundColor.value = this.style.backgroundColor || 0;
6545
+ if (this._originalBatchables.length) {
6546
+ this.requestRepaint();
6547
+ } else if (this._backgroundColor.a > 0) {
6548
+ this.requestRedraw();
6549
+ }
6550
+ }
6551
+ async _updateBackgroundImage() {
6552
+ this._backgroundImage = await this.style.getComputedBackgroundImage();
6553
+ this.requestRedraw();
6554
+ }
6582
6555
  _updateOpacity() {
6583
6556
  const opacity = clamp(0, this.style.opacity, 1) * (this._parent?.opacity ?? 1);
6584
6557
  if (this.opacity !== opacity) {
@@ -6590,13 +6563,13 @@ let CanvasItem = class extends Node {
6590
6563
  return this.opacity > 0 && super.isVisible();
6591
6564
  }
6592
6565
  requestRedraw() {
6593
- this._waitingRedraw = true;
6566
+ this._redrawing = true;
6594
6567
  }
6595
6568
  requestReflow() {
6596
- this._waitingReflow = true;
6569
+ this._reflowing = true;
6597
6570
  }
6598
6571
  requestRepaint() {
6599
- this._waitingRepaint = true;
6572
+ this._repainting = true;
6600
6573
  }
6601
6574
  _process(delta) {
6602
6575
  const parentOpacity = this._parent?.opacity;
@@ -6607,6 +6580,30 @@ let CanvasItem = class extends Node {
6607
6580
  super._process(delta);
6608
6581
  }
6609
6582
  _draw() {
6583
+ this._drawBackground();
6584
+ this._drawContent();
6585
+ }
6586
+ _drawBackground() {
6587
+ const texture = this._backgroundImage;
6588
+ if (texture?.valid) {
6589
+ this.context.fillStyle = texture;
6590
+ this.context.textureTransform = new Transform2D().scale(
6591
+ this.style.width / texture.width,
6592
+ this.style.height / texture.height
6593
+ );
6594
+ this._fill();
6595
+ }
6596
+ }
6597
+ _drawContent() {
6598
+ this._fill();
6599
+ }
6600
+ _fill() {
6601
+ if (this.style.borderRadius) {
6602
+ this.context.roundRect(0, 0, this.style.width, this.style.height, this.style.borderRadius);
6603
+ } else {
6604
+ this.context.rect(0, 0, this.style.width, this.style.height);
6605
+ }
6606
+ this.context.fill();
6610
6607
  }
6611
6608
  _relayout(batchables) {
6612
6609
  return this._reflow(batchables);
@@ -6629,7 +6626,7 @@ let CanvasItem = class extends Node {
6629
6626
  }
6630
6627
  _render(renderer) {
6631
6628
  let batchables;
6632
- if (this._waitingRedraw) {
6629
+ if (this._redrawing) {
6633
6630
  this._draw();
6634
6631
  this._originalBatchables = this.context.toBatchables();
6635
6632
  this._layoutedBatchables = this._relayout(this._originalBatchables);
@@ -6637,17 +6634,17 @@ let CanvasItem = class extends Node {
6637
6634
  if (this._resetContext) {
6638
6635
  this.context.reset();
6639
6636
  }
6640
- } else if (this._waitingReflow) {
6637
+ } else if (this._reflowing) {
6641
6638
  this._layoutedBatchables = this._reflow(this._originalBatchables);
6642
6639
  batchables = this._layoutedBatchables;
6643
- } else if (this._waitingRepaint) {
6640
+ } else if (this._repainting) {
6644
6641
  batchables = this._repaint(this._layoutedBatchables);
6645
6642
  }
6646
6643
  if (batchables) {
6647
6644
  this._batchables = batchables;
6648
- this._waitingRedraw = false;
6649
- this._waitingReflow = false;
6650
- this._waitingRepaint = false;
6645
+ this._redrawing = false;
6646
+ this._reflowing = false;
6647
+ this._repainting = false;
6651
6648
  }
6652
6649
  this._batchables.forEach((batchable) => {
6653
6650
  batchable.texture?.upload(renderer);
@@ -6669,24 +6666,24 @@ let CanvasItem = class extends Node {
6669
6666
  };
6670
6667
  }
6671
6668
  };
6672
- __decorateClass$r([
6669
+ __decorateClass$q([
6673
6670
  property()
6674
6671
  ], CanvasItem.prototype, "tint", 2);
6675
- __decorateClass$r([
6672
+ __decorateClass$q([
6676
6673
  property()
6677
6674
  ], CanvasItem.prototype, "blendMode", 2);
6678
- CanvasItem = __decorateClass$r([
6675
+ CanvasItem = __decorateClass$q([
6679
6676
  customNode("CanvasItem")
6680
6677
  ], CanvasItem);
6681
6678
 
6682
- var __defProp$q = Object.defineProperty;
6683
- var __getOwnPropDesc$q = Object.getOwnPropertyDescriptor;
6684
- var __decorateClass$q = (decorators, target, key, kind) => {
6685
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$q(target, key) : target;
6679
+ var __defProp$p = Object.defineProperty;
6680
+ var __getOwnPropDesc$p = Object.getOwnPropertyDescriptor;
6681
+ var __decorateClass$p = (decorators, target, key, kind) => {
6682
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$p(target, key) : target;
6686
6683
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6687
6684
  if (decorator = decorators[i])
6688
6685
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
6689
- if (kind && result) __defProp$q(target, key, result);
6686
+ if (kind && result) __defProp$p(target, key, result);
6690
6687
  return result;
6691
6688
  };
6692
6689
  const linear = (amount) => amount;
@@ -6753,8 +6750,8 @@ let Animation2D = class extends Node {
6753
6750
  _startProps = /* @__PURE__ */ new WeakMap();
6754
6751
  constructor(options) {
6755
6752
  super();
6756
- this.setProperties(options);
6757
6753
  this._onUpdateTime = this._onUpdateTime.bind(this);
6754
+ this.setProperties(options);
6758
6755
  }
6759
6756
  _enterTree() {
6760
6757
  this._tree?.timeline.on("update", this._onUpdateTime);
@@ -6973,36 +6970,36 @@ let Animation2D = class extends Node {
6973
6970
  });
6974
6971
  }
6975
6972
  };
6976
- __decorateClass$q([
6973
+ __decorateClass$p([
6977
6974
  property({ default: "parent" })
6978
6975
  ], Animation2D.prototype, "mode", 2);
6979
- __decorateClass$q([
6976
+ __decorateClass$p([
6980
6977
  property({ default: false })
6981
6978
  ], Animation2D.prototype, "loop", 2);
6982
- __decorateClass$q([
6979
+ __decorateClass$p([
6983
6980
  property({ default: [] })
6984
6981
  ], Animation2D.prototype, "keyframes", 2);
6985
- __decorateClass$q([
6982
+ __decorateClass$p([
6986
6983
  property()
6987
6984
  ], Animation2D.prototype, "easing", 2);
6988
- __decorateClass$q([
6985
+ __decorateClass$p([
6989
6986
  property({ alias: "visibleDelay", default: 0 })
6990
6987
  ], Animation2D.prototype, "delay", 2);
6991
- __decorateClass$q([
6988
+ __decorateClass$p([
6992
6989
  property({ alias: "visibleDuration", default: 2e3 })
6993
6990
  ], Animation2D.prototype, "duration", 2);
6994
- Animation2D = __decorateClass$q([
6991
+ Animation2D = __decorateClass$p([
6995
6992
  customNode("Animation2D")
6996
6993
  ], Animation2D);
6997
6994
 
6998
- var __defProp$p = Object.defineProperty;
6999
- var __getOwnPropDesc$p = Object.getOwnPropertyDescriptor;
7000
- var __decorateClass$p = (decorators, target, key, kind) => {
7001
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$p(target, key) : target;
6995
+ var __defProp$o = Object.defineProperty;
6996
+ var __getOwnPropDesc$o = Object.getOwnPropertyDescriptor;
6997
+ var __decorateClass$o = (decorators, target, key, kind) => {
6998
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$o(target, key) : target;
7002
6999
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
7003
7000
  if (decorator = decorators[i])
7004
7001
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7005
- if (kind && result) __defProp$p(target, key, result);
7002
+ if (kind && result) __defProp$o(target, key, result);
7006
7003
  return result;
7007
7004
  };
7008
7005
  let Node2D = class extends CanvasItem {
@@ -7048,6 +7045,9 @@ let Node2D = class extends CanvasItem {
7048
7045
  case "transformOrigin":
7049
7046
  this._updateTransform();
7050
7047
  break;
7048
+ case "overflow":
7049
+ this._updateOverflow();
7050
+ break;
7051
7051
  }
7052
7052
  }
7053
7053
  _updateTransform() {
@@ -7073,8 +7073,24 @@ let Node2D = class extends CanvasItem {
7073
7073
  transform = t3dT2d;
7074
7074
  }
7075
7075
  this._transform.set(transform);
7076
+ this._updateOverflow();
7076
7077
  this.requestReflow();
7077
7078
  }
7079
+ _updateOverflow() {
7080
+ if (this.style.overflow === "hidden") {
7081
+ const [a, c, tx, b, d, ty] = this._transform.toArray();
7082
+ const width = this.style.width;
7083
+ const height = this.style.height;
7084
+ this.mask = {
7085
+ x: tx,
7086
+ y: ty,
7087
+ width: a * width + c * height,
7088
+ height: b * width + d * height
7089
+ };
7090
+ } else {
7091
+ this.mask = void 0;
7092
+ }
7093
+ }
7078
7094
  _transformVertices(vertices) {
7079
7095
  const [a, c, tx, b, d, ty] = this._transform.toArray();
7080
7096
  const newVertices = vertices.slice();
@@ -7117,101 +7133,12 @@ let Node2D = class extends CanvasItem {
7117
7133
  }
7118
7134
  }
7119
7135
  };
7120
- Node2D = __decorateClass$p([
7121
- customNode("Node2D")
7122
- ], Node2D);
7123
-
7124
- var __defProp$o = Object.defineProperty;
7125
- var __getOwnPropDesc$o = Object.getOwnPropertyDescriptor;
7126
- var __decorateClass$o = (decorators, target, key, kind) => {
7127
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$o(target, key) : target;
7128
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
7129
- if (decorator = decorators[i])
7130
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7131
- if (kind && result) __defProp$o(target, key, result);
7132
- return result;
7133
- };
7134
- let Element2D = class extends Node2D {
7135
- draggable;
7136
- _background;
7137
- constructor(options) {
7138
- super();
7139
- this.setProperties(options);
7140
- }
7141
- _onUpdateStyleProperty(key, value, oldValue) {
7142
- super._onUpdateStyleProperty(key, value, oldValue);
7143
- switch (key) {
7144
- case "backgroundImage":
7145
- this._updateBackground();
7146
- break;
7147
- case "borderRadius":
7148
- this.requestRedraw();
7149
- break;
7150
- case "overflow":
7151
- this._updateOverflow();
7152
- break;
7153
- }
7154
- }
7155
- async _updateBackground() {
7156
- this._background = await this.style.getComputedBackground();
7157
- this.requestRedraw();
7158
- }
7159
- _updateTransform() {
7160
- super._updateTransform();
7161
- this._updateOverflow();
7162
- }
7163
- _updateOverflow() {
7164
- if (this.style.overflow === "hidden") {
7165
- const [a, c, tx, b, d, ty] = this._transform.toArray();
7166
- const width = this.style.width;
7167
- const height = this.style.height;
7168
- this.mask = {
7169
- x: tx,
7170
- y: ty,
7171
- width: a * width + c * height,
7172
- height: b * width + d * height
7173
- };
7174
- } else {
7175
- this.mask = void 0;
7176
- }
7177
- }
7178
- _draw() {
7179
- super._draw();
7180
- this._drawBackground();
7181
- this._drawContent();
7182
- }
7183
- _drawBackground() {
7184
- const texture = this._background;
7185
- if (!texture?.valid)
7186
- return;
7187
- this.context.fillStyle = texture;
7188
- this.context.textureTransform = new Transform2D().scale(
7189
- this.style.width / texture.width,
7190
- this.style.height / texture.height
7191
- );
7192
- this._drawRect();
7193
- }
7194
- _drawContent() {
7195
- this._drawRect();
7196
- }
7197
- _drawRect() {
7198
- if (this.style.borderRadius) {
7199
- this.context.roundRect(0, 0, this.style.width, this.style.height, this.style.borderRadius);
7200
- } else {
7201
- this.context.rect(0, 0, this.style.width, this.style.height);
7202
- }
7203
- this.context.fill();
7204
- }
7205
- };
7206
- __decorateClass$o([
7207
- property()
7208
- ], Element2D.prototype, "draggable", 2);
7209
- Element2D = __decorateClass$o([
7136
+ Node2D = __decorateClass$o([
7210
7137
  customNode({
7211
- tag: "Element2D",
7138
+ tag: "Node2D",
7212
7139
  renderable: true
7213
7140
  })
7214
- ], Element2D);
7141
+ ], Node2D);
7215
7142
 
7216
7143
  var __defProp$n = Object.defineProperty;
7217
7144
  var __getOwnPropDesc$n = Object.getOwnPropertyDescriptor;
@@ -7320,10 +7247,7 @@ __decorateClass$n([
7320
7247
  proxy({ method: true, redraw: true })
7321
7248
  ], Graphics2D.prototype, "stroke", 2);
7322
7249
  Graphics2D = __decorateClass$n([
7323
- customNode({
7324
- tag: "Graphics2D",
7325
- renderable: true
7326
- })
7250
+ customNode("Graphics2D")
7327
7251
  ], Graphics2D);
7328
7252
 
7329
7253
  class Image2DResource extends Resource {
@@ -7362,7 +7286,7 @@ var __decorateClass$m = (decorators, target, key, kind) => {
7362
7286
  if (kind && result) __defProp$m(target, key, result);
7363
7287
  return result;
7364
7288
  };
7365
- let Image2D = class extends Element2D {
7289
+ let Image2D = class extends Node2D {
7366
7290
  resource;
7367
7291
  get currentTexture() {
7368
7292
  return this.resource?.frames[this._frameIndex]?.texture;
@@ -7481,7 +7405,7 @@ let Image2D = class extends Element2D {
7481
7405
  const texture = this.currentTexture;
7482
7406
  return super._repaint(
7483
7407
  batchables.map((batchable, i) => {
7484
- if ((this._background ? i === 1 : i === 0) && batchable.type === "fill") {
7408
+ if ((this._backgroundImage ? i === 1 : i === 0) && batchable.type === "fill") {
7485
7409
  return {
7486
7410
  ...batchable,
7487
7411
  texture: texture?.valid ? texture : void 0
@@ -7515,7 +7439,7 @@ var __decorateClass$l = (decorators, target, key, kind) => {
7515
7439
  if (kind && result) __defProp$l(target, key, result);
7516
7440
  return result;
7517
7441
  };
7518
- let Lottie2D = class extends Element2D {
7442
+ let Lottie2D = class extends Node2D {
7519
7443
  duration = 0;
7520
7444
  texture = new Texture(document.createElement("canvas"));
7521
7445
  animation;
@@ -7587,8 +7511,11 @@ var __decorateClass$k = (decorators, target, key, kind) => {
7587
7511
  return result;
7588
7512
  };
7589
7513
  const textStyles = new Set(Object.keys(textDefaultStyle));
7590
- let Text2D = class extends Element2D {
7514
+ let Text2D = class extends Node2D {
7591
7515
  effects;
7516
+ measureDom;
7517
+ fonts;
7518
+ text = new Text();
7592
7519
  texture = new Texture(document.createElement("canvas"));
7593
7520
  _subTextsCount = 0;
7594
7521
  constructor(options) {
@@ -7599,6 +7526,8 @@ let Text2D = class extends Element2D {
7599
7526
  super._onUpdateProperty(key, value, oldValue);
7600
7527
  switch (key) {
7601
7528
  case "content":
7529
+ case "effects":
7530
+ case "fonts":
7602
7531
  case "split":
7603
7532
  this._updateSplit();
7604
7533
  this.requestRedraw();
@@ -7610,6 +7539,13 @@ let Text2D = class extends Element2D {
7610
7539
  });
7611
7540
  }
7612
7541
  }
7542
+ _updateText() {
7543
+ this.text.style = this.style.toJSON();
7544
+ this.text.content = this.content ?? "";
7545
+ this.text.effects = this.effects;
7546
+ this.text.fonts = this.fonts;
7547
+ this.text.measureDom = this.measureDom;
7548
+ }
7613
7549
  _onUpdateStyleProperty(key, value, oldValue) {
7614
7550
  if (key === "height")
7615
7551
  return;
@@ -7653,13 +7589,8 @@ let Text2D = class extends Element2D {
7653
7589
  }
7654
7590
  }
7655
7591
  measure() {
7656
- const result = measureText({
7657
- content: this.content,
7658
- style: {
7659
- ...this.style.toJSON(),
7660
- height: void 0
7661
- }
7662
- });
7592
+ this._updateText();
7593
+ const result = this.text.measure();
7663
7594
  if (!this.style.width)
7664
7595
  this.style.width = result.boundingBox.width;
7665
7596
  if (!this.style.height)
@@ -7703,12 +7634,10 @@ let Text2D = class extends Element2D {
7703
7634
  if (onText2DRender) {
7704
7635
  onText2DRender();
7705
7636
  } else {
7706
- renderText({
7707
- view: this.texture.source,
7637
+ this._updateText();
7638
+ this.text.render({
7708
7639
  pixelRatio: this.pixelRatio,
7709
- content: this.content,
7710
- effects: this.effects,
7711
- style: this.style.toJSON()
7640
+ view: this.texture.source
7712
7641
  });
7713
7642
  }
7714
7643
  this.texture.requestUpload();
@@ -7733,6 +7662,12 @@ __decorateClass$k([
7733
7662
  __decorateClass$k([
7734
7663
  property()
7735
7664
  ], Text2D.prototype, "effects", 2);
7665
+ __decorateClass$k([
7666
+ protectedProperty()
7667
+ ], Text2D.prototype, "measureDom", 2);
7668
+ __decorateClass$k([
7669
+ protectedProperty()
7670
+ ], Text2D.prototype, "fonts", 2);
7736
7671
  Text2D = __decorateClass$k([
7737
7672
  customNode("Text2D")
7738
7673
  ], Text2D);
@@ -7747,7 +7682,7 @@ var __decorateClass$j = (decorators, target, key, kind) => {
7747
7682
  if (kind && result) __defProp$j(target, key, result);
7748
7683
  return result;
7749
7684
  };
7750
- let Video2D = class extends Element2D {
7685
+ let Video2D = class extends Node2D {
7751
7686
  texture;
7752
7687
  get duration() {
7753
7688
  return (this.texture?.duration ?? 0) * 1e3;
@@ -8913,7 +8848,7 @@ Audio = __decorateClass$i([
8913
8848
  customNode("Audio")
8914
8849
  ], Audio);
8915
8850
 
8916
- class AudioSpectrum extends Element2D {
8851
+ class AudioSpectrum extends Node2D {
8917
8852
  //
8918
8853
  }
8919
8854
 
@@ -8927,7 +8862,7 @@ var __decorateClass$h = (decorators, target, key, kind) => {
8927
8862
  if (kind && result) __defProp$h(target, key, result);
8928
8863
  return result;
8929
8864
  };
8930
- let AudioWaveform = class extends Element2D {
8865
+ let AudioWaveform = class extends Node2D {
8931
8866
  src;
8932
8867
  gap = 0;
8933
8868
  color = "#000000";
@@ -13756,7 +13691,8 @@ class Engine extends SceneTree {
13756
13691
  } else {
13757
13692
  this.resize(
13758
13693
  width || this.gl.drawingBufferWidth || this.view?.clientWidth || 200,
13759
- height || this.gl.drawingBufferHeight || this.view?.clientHeight || 200
13694
+ height || this.gl.drawingBufferHeight || this.view?.clientHeight || 200,
13695
+ !view
13760
13696
  );
13761
13697
  }
13762
13698
  }
@@ -13891,4 +13827,4 @@ async function render(options) {
13891
13827
  });
13892
13828
  }
13893
13829
 
13894
- export { Animation2D, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, BlurEffect, Bounds, CanvasContext, CanvasItem, Circle, Color, ColorAdjustEffect, ColorFilterEffect, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, DEG_TO_RAD, DEVICE_PIXEL_RATIO, Effect, EffectMaterial, Element2D, Ellipse, EmbossEffect, Engine, EventEmitter, FontLoader, Geometry, GifLoader, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, IN_BROWSER, Image2D, Image2DResource, ImageTexture, IndexBuffer, Input, InternalMode, JsonLoader, KawaseEffect, LeftEraseEffect, Loader, Lottie2D, LottieLoader, MainLoop, MaskEffect, Material, Matrix, Matrix2, Matrix3, Matrix4, MouseInputEvent, Node, Node2D, PI, PI_2, Path2D, PixelateEffect, PixelsTexture, Point, PointerInputEvent, Polygon, Projection2D, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Rectangle, Reference, RenderStack, Renderer, Resource, RoundedRectangle, SUPPORTS_AUDIO_CONTEXT, SUPPORTS_CLICK_EVENTS, SUPPORTS_CREATE_IMAGE_BITMAP, SUPPORTS_IMAGE_BITMAP, SUPPORTS_MOUSE_EVENTS, SUPPORTS_OFFLINE_AUDIO_CONTEXT, SUPPORTS_POINTER_EVENTS, SUPPORTS_RESIZE_OBSERVER, SUPPORTS_TOUCH_EVENTS, SUPPORTS_WEBGL2, SUPPORTS_WEBKIT_AUDIO_CONTEXT, SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, SUPPORTS_WEB_AUDIO, SUPPORTS_WHEEL_EVENTS, SVGPath, SceneTree, Star, Style2D, Style2DBackgroundModule, Style2DFilterModule, Style2DModule, Style2DOffsetModule, Style2DTextModule, Style2DTransformModule, Text2D, TextLoader, Texture, TextureLoader, Ticker, TiltShiftEffect, Timer, Transform2D, Triangle, TwistEffect, UIInputEvent, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, VertexAttribute, VertexBuffer, Video2D, VideoLoader, VideoTexture, Viewport, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, WebGLBufferModule, WebGLFramebufferModule, WebGLMaskModule, WebGLModule, WebGLProgramModule, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, WebGLTextureModule, WebGLVertexArrayModule, WebGLViewportModule, WebSound, WheelInputEvent, ZoomBlurEffect, _Object, assets, buildAdaptiveBezier, buildAdaptiveQuadratic, buildArc, buildArcTo, buildArcToSvg, buildCircle, buildLine, buildPolygon, buildRectangle, buildTriangle, clamp, closePointEps, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curveEps, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCssFunctions, parseCssProperty, property, protectedProperty, render, squaredDistanceToLineSegment, timingFunctions, uid };
13830
+ export { Animation2D, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, BlurEffect, Bounds, CanvasContext, CanvasItem, Circle, Color, ColorAdjustEffect, ColorFilterEffect, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, DEG_TO_RAD, DEVICE_PIXEL_RATIO, Effect, EffectMaterial, Ellipse, EmbossEffect, Engine, EventEmitter, FontLoader, Geometry, GifLoader, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, IN_BROWSER, Image2D, Image2DResource, ImageTexture, IndexBuffer, Input, InternalMode, JsonLoader, KawaseEffect, LeftEraseEffect, Loader, Lottie2D, LottieLoader, MainLoop, MaskEffect, Material, Matrix, Matrix2, Matrix3, Matrix4, MouseInputEvent, Node, Node2D, PI, PI_2, Path2D, PixelateEffect, PixelsTexture, Point, PointerInputEvent, Polygon, Projection2D, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Rectangle, Reference, RenderStack, Renderer, Resource, RoundedRectangle, SUPPORTS_AUDIO_CONTEXT, SUPPORTS_CLICK_EVENTS, SUPPORTS_CREATE_IMAGE_BITMAP, SUPPORTS_IMAGE_BITMAP, SUPPORTS_MOUSE_EVENTS, SUPPORTS_OFFLINE_AUDIO_CONTEXT, SUPPORTS_POINTER_EVENTS, SUPPORTS_RESIZE_OBSERVER, SUPPORTS_TOUCH_EVENTS, SUPPORTS_WEBGL2, SUPPORTS_WEBKIT_AUDIO_CONTEXT, SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, SUPPORTS_WEB_AUDIO, SUPPORTS_WHEEL_EVENTS, SVGPath, SceneTree, Star, Style2D, Style2DBackgroundModule, Style2DFilterModule, Style2DModule, Style2DTextModule, Style2DTransformModule, Text2D, TextLoader, Texture, TextureLoader, Ticker, TiltShiftEffect, Timer, Transform2D, Triangle, TwistEffect, UIInputEvent, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, VertexAttribute, VertexBuffer, Video2D, VideoLoader, VideoTexture, Viewport, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, WebGLBufferModule, WebGLFramebufferModule, WebGLMaskModule, WebGLModule, WebGLProgramModule, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, WebGLTextureModule, WebGLVertexArrayModule, WebGLViewportModule, WebSound, WheelInputEvent, ZoomBlurEffect, _Object, assets, buildAdaptiveBezier, buildAdaptiveQuadratic, buildArc, buildArcTo, buildArcToSvg, buildCircle, buildLine, buildPolygon, buildRectangle, buildTriangle, clamp, closePointEps, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curveEps, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCssFunctions, parseCssProperty, property, protectedProperty, render, squaredDistanceToLineSegment, timingFunctions, uid };