modern-canvas 0.9.3 → 0.9.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.mjs CHANGED
@@ -4470,7 +4470,7 @@ class VertexAttribute extends Resource {
4470
4470
  }
4471
4471
  }
4472
4472
  __decorateClass$W([
4473
- property({ protected: true })
4473
+ property({ internal: true })
4474
4474
  ], VertexAttribute.prototype, "buffer");
4475
4475
  __decorateClass$W([
4476
4476
  property({ fallback: 0 })
@@ -4864,7 +4864,7 @@ class Texture2D extends Resource {
4864
4864
  }
4865
4865
  }
4866
4866
  __decorateClass$V([
4867
- property({ protected: true })
4867
+ property({ internal: true })
4868
4868
  ], Texture2D.prototype, "source");
4869
4869
  __decorateClass$V([
4870
4870
  property({ fallback: 0 })
@@ -6198,7 +6198,7 @@ __decorateClass$S([
6198
6198
  property({ internal: true, fallback: "default" })
6199
6199
  ], Node.prototype, "internalMode", 2);
6200
6200
  __decorateClass$S([
6201
- property({ protected: true })
6201
+ property({ internal: true })
6202
6202
  ], Node.prototype, "mask", 2);
6203
6203
  Node = __decorateClass$S([
6204
6204
  customNode("Node")
@@ -6882,7 +6882,7 @@ let Effect = class extends TimelineNode {
6882
6882
  }
6883
6883
  };
6884
6884
  __decorateClass$O([
6885
- property({ protected: true })
6885
+ property({ internal: true })
6886
6886
  ], Effect.prototype, "material", 2);
6887
6887
  __decorateClass$O([
6888
6888
  property()
@@ -7016,6 +7016,7 @@ var __decorateClass$L = (decorators, target, key, kind) => {
7016
7016
  return result;
7017
7017
  };
7018
7018
  class SceneTree extends MainLoop {
7019
+ fonts;
7019
7020
  input = new Input();
7020
7021
  renderStack = new RenderStack();
7021
7022
  root = new Window(true).setTree(this);
@@ -8899,7 +8900,7 @@ void main(void) {
8899
8900
  }`
8900
8901
  }));
8901
8902
  __decorateClass$w([
8902
- property({ protected: true })
8903
+ property({ internal: true })
8903
8904
  ], MaskEffect.prototype, "texture", 2);
8904
8905
  __decorateClass$w([
8905
8906
  property({ fallback: "" })
@@ -9701,9 +9702,9 @@ class BaseElement2DText extends CoreObject {
9701
9702
  constructor(parent) {
9702
9703
  super();
9703
9704
  this.parent = parent;
9704
- this.base.setPropertyAccessor(this);
9705
+ this.base = new Text().setPropertyAccessor(this);
9705
9706
  }
9706
- base = new Text();
9707
+ base;
9707
9708
  measureResult;
9708
9709
  _textureMap = /* @__PURE__ */ new Map();
9709
9710
  setProperties(properties) {
@@ -9727,8 +9728,12 @@ class BaseElement2DText extends CoreObject {
9727
9728
  break;
9728
9729
  }
9729
9730
  }
9730
- _updateTextureMap() {
9731
+ _updateBase() {
9732
+ this.base.fonts = this.base.fonts ?? this.parent.tree?.fonts;
9731
9733
  this.base.update();
9734
+ }
9735
+ _updateTextureMap() {
9736
+ this._updateBase();
9732
9737
  this._textureMap.clear();
9733
9738
  const pGlyphBoxs = [];
9734
9739
  this.base.paragraphs.forEach((p, pIndex) => {
@@ -9784,6 +9789,7 @@ class BaseElement2DText extends CoreObject {
9784
9789
  this.content = normalizeTextContent(content);
9785
9790
  }
9786
9791
  measure() {
9792
+ this._updateBase();
9787
9793
  return this.base.measure();
9788
9794
  }
9789
9795
  updateMeasure() {
@@ -9806,7 +9812,7 @@ class BaseElement2DText extends CoreObject {
9806
9812
  }
9807
9813
  draw() {
9808
9814
  const ctx = this.parent.context;
9809
- this.base.update();
9815
+ this._updateBase();
9810
9816
  this.base.pathSets.forEach((pathSet) => {
9811
9817
  pathSet.paths.forEach((path) => {
9812
9818
  const meta = path.getMeta();
@@ -10929,7 +10935,7 @@ let Image2D = class extends Element2D {
10929
10935
  }
10930
10936
  };
10931
10937
  __decorateClass$i([
10932
- property({ protected: true })
10938
+ property({ internal: true })
10933
10939
  ], Image2D.prototype, "texture", 2);
10934
10940
  __decorateClass$i([
10935
10941
  property({ fallback: "" })
@@ -14168,6 +14174,7 @@ class Engine extends SceneTree {
14168
14174
  height,
14169
14175
  pixelRatio = DEVICE_PIXEL_RATIO,
14170
14176
  backgroundColor = 0,
14177
+ fonts,
14171
14178
  autoResize,
14172
14179
  autoStart,
14173
14180
  timeline,
@@ -14182,6 +14189,7 @@ class Engine extends SceneTree {
14182
14189
  this._setupInput();
14183
14190
  this.pixelRatio = pixelRatio;
14184
14191
  this.backgroundColor = backgroundColor;
14192
+ this.fonts = fonts;
14185
14193
  if (autoResize) {
14186
14194
  if (!view && this.renderer.view) {
14187
14195
  this.renderer.view.style.width = "100%";
@@ -14332,13 +14340,14 @@ async function start(sleep = 100) {
14332
14340
  starting = false;
14333
14341
  }
14334
14342
  async function task(options) {
14335
- const { data, width, height, debug = false, time = 0 } = options;
14343
+ const { debug = false, fonts, width, height, time = 0, data } = options;
14336
14344
  engine ??= new Engine({
14337
14345
  width: 1,
14338
14346
  height: 1,
14339
14347
  preserveDrawingBuffer: true
14340
14348
  });
14341
14349
  engine.debug = debug;
14350
+ engine.fonts = fonts;
14342
14351
  engine.root.removeChildren();
14343
14352
  engine.timeline.currentTime = time;
14344
14353
  engine.resize(width, height, true);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.9.3",
4
+ "version": "0.9.4",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",