modern-canvas 0.4.43 → 0.4.45

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
@@ -239,12 +239,13 @@ function defineProperty(constructor, name, declaration = {}) {
239
239
  }
240
240
  };
241
241
  }
242
+ const getDefaultValue = () => typeof defaultValue === "function" ? defaultValue() : defaultValue;
242
243
  Object.defineProperty(constructor.prototype, name, {
243
244
  get() {
244
- return descriptor.get?.call(this) ?? defaultValue;
245
+ return descriptor.get?.call(this) ?? getDefaultValue();
245
246
  },
246
247
  set(value) {
247
- const oldValue = descriptor.get?.call(this) ?? defaultValue;
248
+ const oldValue = descriptor.get?.call(this) ?? getDefaultValue();
248
249
  descriptor.set?.call(this, value);
249
250
  this.requestUpdate?.(name, oldValue, declaration);
250
251
  },
@@ -505,7 +506,7 @@ class CoreObject extends EventEmitter {
505
506
  this._defaultProperties = {};
506
507
  for (const [name, property] of this.getPropertyDeclarations()) {
507
508
  if (!property.protected && !property.alias) {
508
- this._defaultProperties[name] = property.default;
509
+ this._defaultProperties[name] = typeof property.default === "function" ? property.default() : property.default;
509
510
  }
510
511
  }
511
512
  }
@@ -537,6 +538,12 @@ class CoreObject extends EventEmitter {
537
538
  }
538
539
  return this;
539
540
  }
541
+ resetProperties() {
542
+ for (const [name, property] of this.getPropertyDeclarations()) {
543
+ this.setProperty(name, property.default);
544
+ }
545
+ return this;
546
+ }
540
547
  requestUpdate(key, oldValue, declaration) {
541
548
  if (key !== void 0) {
542
549
  const newValue = this[key];
@@ -559,8 +566,12 @@ class CoreObject extends EventEmitter {
559
566
  const properties = this.getProperties(Array.from(this._changedProperties));
560
567
  for (const key in properties) {
561
568
  const value = properties[key];
562
- if (value && typeof value === "object" && "toJSON" in value && typeof value.toJSON === "function") {
563
- json[key] = value.toJSON();
569
+ if (value && typeof value === "object") {
570
+ if ("toJSON" in value && typeof value.toJSON === "function") {
571
+ json[key] = value.toJSON();
572
+ } else {
573
+ json[key] = { ...value };
574
+ }
564
575
  } else {
565
576
  json[key] = value;
566
577
  }
@@ -5155,7 +5166,8 @@ class GradientTexture extends Texture2D {
5155
5166
  if (!ctx) {
5156
5167
  throw new Error("Failed to parse linear gradient, get canvas context is null.");
5157
5168
  }
5158
- const { angle, stops } = linearGradient;
5169
+ let { angle = 0, stops } = linearGradient;
5170
+ angle -= Math.PI / 2;
5159
5171
  const halfWidth = width / 2;
5160
5172
  const halfHeight = height / 2;
5161
5173
  const length = Math.sqrt(width * width + height * height) / 2;
@@ -5592,6 +5604,56 @@ class ViewportTexture extends PixelsTexture {
5592
5604
  //
5593
5605
  }
5594
5606
 
5607
+ class Children extends Array {
5608
+ front = [];
5609
+ back = [];
5610
+ get internal() {
5611
+ return [
5612
+ ...this.front,
5613
+ ...this,
5614
+ ...this.back
5615
+ ];
5616
+ }
5617
+ constructor(...items) {
5618
+ super();
5619
+ this.set(items);
5620
+ }
5621
+ set(items) {
5622
+ this.front.length = 0;
5623
+ this.length = 0;
5624
+ this.back.length = 0;
5625
+ items.forEach((item) => {
5626
+ switch (item.internalMode) {
5627
+ case "front":
5628
+ this.front.push(item);
5629
+ break;
5630
+ case "default":
5631
+ this.push(item);
5632
+ break;
5633
+ case "back":
5634
+ this.back.push(item);
5635
+ break;
5636
+ }
5637
+ });
5638
+ return this;
5639
+ }
5640
+ getInternal(includeInternal) {
5641
+ switch (includeInternal) {
5642
+ case "front":
5643
+ return this.front;
5644
+ case "default":
5645
+ return this;
5646
+ case "back":
5647
+ return this.back;
5648
+ default:
5649
+ throw new Error(`Unknown internal mode: ${includeInternal}`);
5650
+ }
5651
+ }
5652
+ toJSON() {
5653
+ return [...this];
5654
+ }
5655
+ }
5656
+
5595
5657
  var __defProp$J = Object.defineProperty;
5596
5658
  var __getOwnPropDesc$I = Object.getOwnPropertyDescriptor;
5597
5659
  var __decorateClass$R = (decorators, target, key, kind) => {
@@ -5633,7 +5695,7 @@ let Node = class extends CoreObject {
5633
5695
  } = properties;
5634
5696
  if (meta) {
5635
5697
  for (const key in meta) {
5636
- this.setMeta(key, meta[key]);
5698
+ this.meta[key] = meta[key];
5637
5699
  }
5638
5700
  }
5639
5701
  super.setProperties(restProperties);
@@ -5678,8 +5740,9 @@ let Node = class extends CoreObject {
5678
5740
  if (tree) {
5679
5741
  this.emit("treeEnter", tree);
5680
5742
  }
5681
- for (let len = this._children.length, i = 0; i < len; i++) {
5682
- const node = this._children[i];
5743
+ const children = this._children.internal;
5744
+ for (let len = children.length, i = 0; i < len; i++) {
5745
+ const node = children[i];
5683
5746
  !tree && this.emit("childExitingTree", node);
5684
5747
  node.setTree(tree);
5685
5748
  tree && this.emit("childEnteredTree", node);
@@ -5703,7 +5766,7 @@ let Node = class extends CoreObject {
5703
5766
  this.setParent(parent);
5704
5767
  }
5705
5768
  hasParent() {
5706
- return !!this._parent;
5769
+ return Boolean(this._parent);
5707
5770
  }
5708
5771
  getParent() {
5709
5772
  return this._parent;
@@ -5723,7 +5786,13 @@ let Node = class extends CoreObject {
5723
5786
  return this;
5724
5787
  }
5725
5788
  /** Children */
5726
- _children = [];
5789
+ _children = new Children();
5790
+ get children() {
5791
+ return this._children;
5792
+ }
5793
+ set children(value) {
5794
+ value instanceof Children ? this._children = value : this._children.set(value);
5795
+ }
5727
5796
  get siblingIndex() {
5728
5797
  return this.getIndex();
5729
5798
  }
@@ -5731,35 +5800,18 @@ let Node = class extends CoreObject {
5731
5800
  this._parent?.moveChild(this, toIndex);
5732
5801
  }
5733
5802
  get previousSibling() {
5734
- return this._parent?.getChildren()[this.getIndex() - 1];
5803
+ return this._parent?.children[this.getIndex() - 1];
5735
5804
  }
5736
5805
  get nextSibling() {
5737
- return this._parent?.getChildren()[this.getIndex() + 1];
5806
+ return this._parent?.children[this.getIndex() + 1];
5738
5807
  }
5739
5808
  get firstSibling() {
5740
- return this._parent?.getChildren()[0];
5809
+ return this._parent?.children[0];
5741
5810
  }
5742
5811
  get lastSibling() {
5743
- const children = this._parent?.getChildren();
5812
+ const children = this._parent?.children;
5744
5813
  return children ? children[children.length - 1] : void 0;
5745
5814
  }
5746
- /** Meta */
5747
- _meta = /* @__PURE__ */ new Map();
5748
- hasMeta(name) {
5749
- return this._meta.has(name);
5750
- }
5751
- getMeta(name, defaultVal) {
5752
- return this._meta.get(name) ?? defaultVal;
5753
- }
5754
- setMeta(name, value) {
5755
- this._meta.set(name, value);
5756
- }
5757
- deleteMeta(name) {
5758
- this._meta.delete(name);
5759
- }
5760
- clearMeta() {
5761
- this._meta.clear();
5762
- }
5763
5815
  canProcess() {
5764
5816
  if (!this._tree)
5765
5817
  return false;
@@ -5820,8 +5872,7 @@ let Node = class extends CoreObject {
5820
5872
  const canProcess = this.canProcess();
5821
5873
  const childrenInBefore = [];
5822
5874
  const childrenInAfter = [];
5823
- for (let len = this._children.length, i = 0; i < len; i++) {
5824
- const child = this._children[i];
5875
+ this._children.internal.forEach((child) => {
5825
5876
  switch (child.processSortMode) {
5826
5877
  case "default":
5827
5878
  childrenInAfter.push(child);
@@ -5830,7 +5881,7 @@ let Node = class extends CoreObject {
5830
5881
  childrenInBefore.push(child);
5831
5882
  break;
5832
5883
  }
5833
- }
5884
+ });
5834
5885
  childrenInBefore.forEach((child) => {
5835
5886
  child.emit("process", delta);
5836
5887
  });
@@ -5881,27 +5932,14 @@ let Node = class extends CoreObject {
5881
5932
  }
5882
5933
  }
5883
5934
  input(event, key) {
5884
- for (let i = this._children.length - 1; i >= 0; i--) {
5885
- this._children[i].input(event, key);
5886
- }
5935
+ this._children.internal.forEach((child) => child.input(event, key));
5887
5936
  this._input(event, key);
5888
5937
  }
5889
- /** Children */
5890
- getChildren(includeInternal = false) {
5891
- switch (includeInternal) {
5892
- case true:
5893
- return this._children;
5894
- case false:
5895
- return this._children.filter((child) => child.internalMode === "default");
5896
- default:
5897
- return this._children.filter((child) => child.internalMode === includeInternal);
5898
- }
5899
- }
5900
- getIndex(includeInternal = false) {
5901
- return this._parent?.getChildren(includeInternal).indexOf(this) ?? 0;
5938
+ getIndex() {
5939
+ return this._parent?.children.getInternal(this.internalMode).indexOf(this) ?? 0;
5902
5940
  }
5903
5941
  getNode(path) {
5904
- return this._children.find((child) => child.name === path);
5942
+ return this._children.internal.find((child) => child.name === path);
5905
5943
  }
5906
5944
  removeNode(path) {
5907
5945
  this.getNode(path)?.remove();
@@ -5911,7 +5949,7 @@ let Node = class extends CoreObject {
5911
5949
  return this;
5912
5950
  }
5913
5951
  sibling.internalMode = this.internalMode;
5914
- this._parent.moveChild(sibling, this.getIndex(true) + 1);
5952
+ this._parent.moveChild(sibling, this.getIndex() + 1);
5915
5953
  return this;
5916
5954
  }
5917
5955
  prepend(...nodes) {
@@ -5944,7 +5982,7 @@ let Node = class extends CoreObject {
5944
5982
  _nodes = nodes;
5945
5983
  }
5946
5984
  _nodes.forEach((node) => {
5947
- this._parent?.moveChild(node, this.getIndex(true));
5985
+ this._parent?.moveChild(node, this.getIndex());
5948
5986
  });
5949
5987
  }
5950
5988
  after(...nodes) {
@@ -5955,128 +5993,83 @@ let Node = class extends CoreObject {
5955
5993
  _nodes = nodes;
5956
5994
  }
5957
5995
  _nodes.forEach((node) => {
5958
- this._parent?.moveChild(node, this.getIndex(true) + 1);
5996
+ this._parent?.moveChild(node, this.getIndex() + 1);
5959
5997
  });
5960
5998
  }
5961
5999
  insertBefore(node, child) {
5962
6000
  if (!child.hasParent() || !this.is(child.parent)) {
5963
6001
  return node;
5964
6002
  }
5965
- this.moveChild(node, child.getIndex(true));
6003
+ this.moveChild(node, child.getIndex());
5966
6004
  return node;
5967
6005
  }
5968
6006
  appendChild(node, internalMode = node.internalMode) {
5969
6007
  if (this.is(node) || node.hasParent()) {
5970
6008
  return node;
5971
6009
  }
5972
- let index = -1;
5973
6010
  switch (internalMode) {
5974
- case "default":
5975
- index = this._children.findLastIndex((node2) => node2.internalMode === "default");
5976
- if (index > -1) {
5977
- index += 1;
5978
- } else {
5979
- index = this._children.findIndex((node2) => node2.internalMode === "back");
5980
- }
6011
+ case "front":
6012
+ this._children.front.push(node);
5981
6013
  break;
5982
- case "front": {
5983
- index = this._children.findLastIndex((node2) => node2.internalMode === "front");
5984
- if (index > -1) {
5985
- index += 1;
5986
- } else {
5987
- index = this._children.findIndex((node2) => node2.internalMode === "default");
5988
- }
5989
- if (index > -1) {
5990
- index += 1;
5991
- } else {
5992
- index = this._children.findIndex((node2) => node2.internalMode === "back");
5993
- }
6014
+ case "default":
6015
+ this._children.push(node);
5994
6016
  break;
5995
- }
5996
6017
  case "back":
5997
- this._children.push(node);
6018
+ this._children.back.push(node);
5998
6019
  break;
5999
6020
  }
6000
- if (index > -1) {
6001
- this._children.splice(index, 0, node);
6002
- } else {
6003
- this._children.push(node);
6004
- }
6005
6021
  node.internalMode = internalMode;
6006
6022
  node.setParent(this);
6007
6023
  this.emit("appendChild", node);
6008
6024
  return node;
6009
6025
  }
6010
- moveChild(child, toIndex, internalMode = child.internalMode) {
6011
- if (this.is(child) || child.hasParent() && !this.is(child.parent)) {
6026
+ moveChild(node, toIndex, internalMode = node.internalMode) {
6027
+ if (this.is(node) || node.hasParent() && !this.is(node.parent)) {
6012
6028
  return this;
6013
6029
  }
6014
- child.internalMode = internalMode;
6015
- const oldIndex = this._children.indexOf(child);
6016
- let minIndex = this._children.findIndex((_child) => {
6017
- switch (internalMode) {
6018
- case "default":
6019
- return _child.internalMode !== "front";
6020
- case "back":
6021
- return _child.internalMode === "back";
6022
- case "front":
6023
- default:
6024
- return true;
6025
- }
6026
- });
6027
- minIndex = minIndex > -1 ? minIndex : Math.max(0, this._children.length - 1);
6028
- let maxIndex = this._children.slice(minIndex).findIndex((_child) => {
6029
- switch (internalMode) {
6030
- case "front":
6031
- return _child.internalMode !== "front";
6032
- case "default":
6033
- return _child.internalMode === "back";
6034
- case "back":
6035
- default:
6036
- return false;
6030
+ const fromArray = this._children.getInternal(node.internalMode);
6031
+ const fromIndex = fromArray.indexOf(node);
6032
+ const toArray = this._children.getInternal(internalMode);
6033
+ if (node.internalMode !== internalMode || toIndex !== fromIndex) {
6034
+ if (fromIndex > -1) {
6035
+ fromArray.splice(fromIndex, 1);
6037
6036
  }
6038
- });
6039
- maxIndex = maxIndex > -1 ? minIndex + maxIndex : Math.max(0, this._children.length);
6040
- const newIndex = clamp(minIndex, toIndex > -1 ? toIndex : maxIndex, maxIndex);
6041
- if (newIndex !== oldIndex) {
6042
- if (oldIndex > -1) {
6043
- this._children.splice(oldIndex, 1);
6044
- }
6045
- child.setParent(this);
6046
- if (newIndex > -1 && newIndex < this._children.length) {
6047
- this._children.splice(newIndex, 0, child);
6037
+ node.setParent(this);
6038
+ if (toIndex > -1 && toIndex < toArray.length) {
6039
+ toArray.splice(toIndex, 0, node);
6048
6040
  } else {
6049
- this._children.push(child);
6041
+ toArray.push(node);
6050
6042
  }
6051
- if (oldIndex > -1) {
6052
- this.emit("moveChild", child, newIndex, oldIndex);
6043
+ if (fromIndex > -1) {
6044
+ this.emit("moveChild", node, toIndex, fromIndex);
6053
6045
  } else {
6054
- this.emit("appendChild", child);
6046
+ this.emit("appendChild", node);
6055
6047
  }
6056
6048
  }
6049
+ node.internalMode = internalMode;
6057
6050
  return this;
6058
6051
  }
6059
6052
  removeChild(child) {
6060
- const index = child.getIndex(true);
6053
+ const index = child.getIndex();
6061
6054
  if (this.is(child.parent) && index > -1) {
6062
- this._children.splice(index, 1);
6055
+ this._children.internal.splice(index, 1);
6063
6056
  child.setParent(void 0);
6064
6057
  this.emit("removeChild", child, index);
6065
6058
  }
6066
6059
  return child;
6067
6060
  }
6068
6061
  removeChildren() {
6069
- this.getChildren().forEach((child) => this.removeChild(child));
6062
+ this._children.forEach((child) => this.removeChild(child));
6070
6063
  }
6071
6064
  remove() {
6072
6065
  this._parent?.removeChild(this);
6073
6066
  }
6074
6067
  forEachChild(callbackfn) {
6075
- this.getChildren().forEach(callbackfn);
6068
+ this._children.forEach(callbackfn);
6076
6069
  return this;
6077
6070
  }
6078
6071
  forEachDescendant(callbackfn) {
6079
- this.getChildren().forEach((child) => {
6072
+ this._children.forEach((child) => {
6080
6073
  callbackfn(child);
6081
6074
  child.forEachDescendant(callbackfn);
6082
6075
  });
@@ -6109,18 +6102,14 @@ let Node = class extends CoreObject {
6109
6102
  clone() {
6110
6103
  return new this.constructor(
6111
6104
  this.toJSON().props,
6112
- this.getChildren(true)
6105
+ this._children.internal
6113
6106
  );
6114
6107
  }
6115
6108
  toJSON() {
6116
6109
  return {
6117
6110
  tag: this.tag,
6118
- props: {
6119
- name: this.name,
6120
- ...super.toJSON()
6121
- },
6122
- meta: Object.fromEntries(this._meta.entries()),
6123
- children: this.getChildren().map((child) => child.toJSON())
6111
+ props: super.toJSON(),
6112
+ children: [...this._children.map((child) => child.toJSON())]
6124
6113
  };
6125
6114
  }
6126
6115
  static parse(JSON) {
@@ -6135,7 +6124,7 @@ let Node = class extends CoreObject {
6135
6124
  }
6136
6125
  };
6137
6126
  __decorateClass$R([
6138
- protectedProperty()
6127
+ property()
6139
6128
  ], Node.prototype, "name", 2);
6140
6129
  __decorateClass$R([
6141
6130
  property()
@@ -6152,6 +6141,9 @@ __decorateClass$R([
6152
6141
  __decorateClass$R([
6153
6142
  property({ default: "default" })
6154
6143
  ], Node.prototype, "internalMode", 2);
6144
+ __decorateClass$R([
6145
+ property({ default: () => ({}) })
6146
+ ], Node.prototype, "meta", 2);
6155
6147
  Node = __decorateClass$R([
6156
6148
  customNode("Node")
6157
6149
  ], Node);
@@ -6940,7 +6932,7 @@ void main(void) {
6940
6932
  }`
6941
6933
  }));
6942
6934
  __decorateClass$L([
6943
- property({ default: [] })
6935
+ property({ default: () => [] })
6944
6936
  ], ColorOverlayEffect.prototype, "colors", 2);
6945
6937
  __decorateClass$L([
6946
6938
  property({ default: 0.5 })
@@ -7025,7 +7017,7 @@ void main(void) {
7025
7017
  }`
7026
7018
  }));
7027
7019
  __decorateClass$K([
7028
- property({ default: [] })
7020
+ property({ default: () => [] })
7029
7021
  ], ColorRemoveEffect.prototype, "colors", 2);
7030
7022
  __decorateClass$K([
7031
7023
  property({ default: 0.5 })
@@ -7667,7 +7659,7 @@ class SceneTree extends MainLoop {
7667
7659
  }
7668
7660
  free() {
7669
7661
  super.free();
7670
- this.root.getChildren(true).forEach((node) => this.root.removeChild(node));
7662
+ this.root.children.internal.forEach((node) => this.root.removeChild(node));
7671
7663
  this.input.removeEventListeners();
7672
7664
  }
7673
7665
  }
@@ -8393,7 +8385,7 @@ __decorateClass$A([
8393
8385
  property({ default: true })
8394
8386
  ], GodrayEffect.prototype, "parallel", 2);
8395
8387
  __decorateClass$A([
8396
- property({ default: [0, 0] })
8388
+ property({ default: () => [0, 0] })
8397
8389
  ], GodrayEffect.prototype, "center", 2);
8398
8390
  __decorateClass$A([
8399
8391
  property({ default: 1 })
@@ -8968,7 +8960,9 @@ class BaseElement2DFill extends CoreObject {
8968
8960
  return super.setProperties(properties);
8969
8961
  }
8970
8962
  setProperties(properties) {
8971
- return this._setProperties(isNone(properties) ? void 0 : normalizeFill(properties));
8963
+ return this._setProperties(
8964
+ isNone(properties) ? void 0 : normalizeFill(properties)
8965
+ );
8972
8966
  }
8973
8967
  _updateProperty(key, value, oldValue, declaration) {
8974
8968
  super._updateProperty(key, value, oldValue, declaration);
@@ -9099,7 +9093,9 @@ var __decorateClass$t = (decorators, target, key, kind) => {
9099
9093
  };
9100
9094
  class BaseElement2DBackground extends BaseElement2DFill {
9101
9095
  setProperties(properties) {
9102
- return super._setProperties(isNone(properties) ? void 0 : normalizeBackground(properties));
9096
+ return super._setProperties(
9097
+ isNone(properties) ? void 0 : normalizeBackground(properties)
9098
+ );
9103
9099
  }
9104
9100
  }
9105
9101
  __decorateClass$t([
@@ -9117,7 +9113,9 @@ var __decorateClass$s = (decorators, target, key, kind) => {
9117
9113
  };
9118
9114
  class BaseElement2DForeground extends BaseElement2DFill {
9119
9115
  setProperties(properties) {
9120
- return super._setProperties(isNone(properties) ? void 0 : normalizeForeground(properties));
9116
+ return super._setProperties(
9117
+ isNone(properties) ? void 0 : normalizeForeground(properties)
9118
+ );
9121
9119
  }
9122
9120
  }
9123
9121
  __decorateClass$s([
@@ -9135,7 +9133,9 @@ var __decorateClass$r = (decorators, target, key, kind) => {
9135
9133
  };
9136
9134
  class BaseElement2DOutline extends BaseElement2DFill {
9137
9135
  setProperties(properties) {
9138
- return super._setProperties(isNone(properties) ? void 0 : normalizeOutline(properties));
9136
+ return super._setProperties(
9137
+ isNone(properties) ? void 0 : normalizeOutline(properties)
9138
+ );
9139
9139
  }
9140
9140
  _updateProperty(key, value, oldValue, declaration) {
9141
9141
  super._updateProperty(key, value, oldValue, declaration);
@@ -9185,7 +9185,9 @@ class BaseElement2DShadow extends CoreObject {
9185
9185
  this.parent = parent;
9186
9186
  }
9187
9187
  setProperties(properties) {
9188
- return super.setProperties(isNone(properties) ? void 0 : normalizeShadow(properties));
9188
+ return super.setProperties(
9189
+ isNone(properties) ? void 0 : normalizeShadow(properties)
9190
+ );
9189
9191
  }
9190
9192
  _updateProperty(key, value, oldValue, declaration) {
9191
9193
  super._updateProperty(key, value, oldValue, declaration);
@@ -9244,7 +9246,9 @@ class BaseElement2DShape extends CoreObject {
9244
9246
  }
9245
9247
  _path2DSet = new Path2DSet();
9246
9248
  setProperties(properties) {
9247
- return super.setProperties(isNone(properties) ? void 0 : normalizeShape(properties));
9249
+ return super.setProperties(
9250
+ isNone(properties) ? void 0 : normalizeShape(properties)
9251
+ );
9248
9252
  }
9249
9253
  _updateProperty(key, value, oldValue, declaration) {
9250
9254
  super._updateProperty(key, value, oldValue, declaration);
@@ -9309,10 +9313,10 @@ __decorateClass$p([
9309
9313
  property()
9310
9314
  ], BaseElement2DShape.prototype, "svg");
9311
9315
  __decorateClass$p([
9312
- property({ default: [0, 0, 1, 1] })
9316
+ property({ default: () => [0, 0, 1, 1] })
9313
9317
  ], BaseElement2DShape.prototype, "viewBox");
9314
9318
  __decorateClass$p([
9315
- property({ default: [] })
9319
+ property({ default: () => [] })
9316
9320
  ], BaseElement2DShape.prototype, "data");
9317
9321
 
9318
9322
  class BaseElement2DStyle extends Resource {
@@ -9353,7 +9357,9 @@ class BaseElement2DText extends CoreObject {
9353
9357
  baseText = new Text();
9354
9358
  measureResult;
9355
9359
  setProperties(properties) {
9356
- return super.setProperties(isNone(properties) ? void 0 : normalizeText(properties));
9360
+ return super.setProperties(
9361
+ isNone(properties) ? void 0 : normalizeText(properties)
9362
+ );
9357
9363
  }
9358
9364
  _updateProperty(key, value, oldValue, declaration) {
9359
9365
  super._updateProperty(key, value, oldValue, declaration);
@@ -9538,49 +9544,49 @@ let BaseElement2D = class extends Node2D {
9538
9544
  return this._background;
9539
9545
  }
9540
9546
  set background(value) {
9541
- this._background.setProperties(value);
9547
+ this._background.resetProperties().setProperties(value);
9542
9548
  }
9543
9549
  _shape = new BaseElement2DShape(this);
9544
9550
  get shape() {
9545
9551
  return this._shape;
9546
9552
  }
9547
9553
  set shape(value) {
9548
- this._shape.setProperties(value);
9554
+ this._shape.resetProperties().setProperties(value);
9549
9555
  }
9550
9556
  _fill = new BaseElement2DFill(this);
9551
9557
  get fill() {
9552
9558
  return this._fill;
9553
9559
  }
9554
9560
  set fill(value) {
9555
- this._fill.setProperties(value);
9561
+ this._fill.resetProperties().setProperties(value);
9556
9562
  }
9557
9563
  _outline = new BaseElement2DOutline(this);
9558
9564
  get outline() {
9559
9565
  return this._outline;
9560
9566
  }
9561
9567
  set outline(value) {
9562
- this._outline.setProperties(value);
9568
+ this._outline.resetProperties().setProperties(value);
9563
9569
  }
9564
9570
  _foreground = new BaseElement2DForeground(this);
9565
9571
  get foreground() {
9566
9572
  return this._foreground;
9567
9573
  }
9568
9574
  set foreground(value) {
9569
- this._foreground.setProperties(value);
9575
+ this._foreground.resetProperties().setProperties(value);
9570
9576
  }
9571
9577
  _text = new BaseElement2DText(this);
9572
9578
  get text() {
9573
9579
  return this._text;
9574
9580
  }
9575
9581
  set text(value) {
9576
- this._text.setProperties(value);
9582
+ this._text.resetProperties().setProperties(value);
9577
9583
  }
9578
9584
  _shadow = new BaseElement2DShadow(this);
9579
9585
  get shadow() {
9580
9586
  return this._shadow;
9581
9587
  }
9582
9588
  set shadow(value) {
9583
- this._shadow.setProperties(value);
9589
+ this._shadow.resetProperties().setProperties(value);
9584
9590
  }
9585
9591
  constructor(properties, nodes = []) {
9586
9592
  super();
@@ -10690,7 +10696,7 @@ let Text2D = class extends TextureRect2D {
10690
10696
  }
10691
10697
  }
10692
10698
  _getSubTexts() {
10693
- return this.getChildren("front").filter((node) => node instanceof Text2D);
10699
+ return this.children.front.filter((node) => node instanceof Text2D);
10694
10700
  }
10695
10701
  _updateSubTexts() {
10696
10702
  const subTexts = this._getSubTexts();
@@ -10726,7 +10732,7 @@ let Text2D = class extends TextureRect2D {
10726
10732
  }
10727
10733
  _updateSplit() {
10728
10734
  if (this._subTextsCount) {
10729
- this.getChildren("front").forEach((child) => this.removeChild(child));
10735
+ this.children.front.forEach((child) => this.removeChild(child));
10730
10736
  this._subTextsCount = 0;
10731
10737
  }
10732
10738
  if (this.split) {
@@ -10760,7 +10766,7 @@ let Text2D = class extends TextureRect2D {
10760
10766
  }
10761
10767
  _drawContent() {
10762
10768
  if (!this.split) {
10763
- const onText2DRender = this.getChildren()?.find((child) => "onText2DRender" in child)?.onText2DRender;
10769
+ const onText2DRender = this.children?.find((child) => "onText2DRender" in child)?.onText2DRender;
10764
10770
  if (onText2DRender) {
10765
10771
  onText2DRender();
10766
10772
  } else {
@@ -11019,7 +11025,7 @@ let Animation = class extends TimelineNode {
11019
11025
  let targets;
11020
11026
  switch (this.effectMode) {
11021
11027
  case "sibling":
11022
- targets = this.getParent()?.getChildren(true).filter((val) => val instanceof CanvasItem) ?? [];
11028
+ targets = this.getParent()?.children.internal.filter((val) => val instanceof CanvasItem) ?? [];
11023
11029
  break;
11024
11030
  case "parent":
11025
11031
  default:
@@ -11250,7 +11256,7 @@ __decorateClass$d([
11250
11256
  property({ default: false })
11251
11257
  ], Animation.prototype, "loop", 2);
11252
11258
  __decorateClass$d([
11253
- property({ default: [] })
11259
+ property({ default: () => [] })
11254
11260
  ], Animation.prototype, "keyframes", 2);
11255
11261
  __decorateClass$d([
11256
11262
  property()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.4.43",
4
+ "version": "0.4.45",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",