modern-canvas 0.26.1 → 0.26.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.js CHANGED
@@ -7297,7 +7297,9 @@ var Z = class extends T {
7297
7297
  });
7298
7298
  }
7299
7299
  update() {
7300
- if (this.base.fonts = this.base.fonts ?? this._parent.tree?.fonts, this.base.update(), this._atlasEligible = this._computeAtlasEligible(), this._atlasEligible) {
7300
+ this.base.fonts = this.base.fonts ?? this._parent.tree?.fonts, this.base.update();
7301
+ let e = this.base.boundingBox, t = this._parent.size;
7302
+ if (e && (e.left < 0 || e.top < 0 || e.left + e.width > t.width || e.top + e.height > t.height) && this._parent.updateContentAabb(), this._atlasEligible = this._computeAtlasEligible(), this._atlasEligible) {
7301
7303
  this._releaseTiles(), this._textureStale = !0, this._parent.requestDraw();
7302
7304
  return;
7303
7305
  }
@@ -7441,6 +7443,12 @@ var Z = class extends T {
7441
7443
  }
7442
7444
  _computeAtlasEligible() {
7443
7445
  if (this.drawMode === "texture" || this.drawMode === "path" || this.effects?.length || this.outline?.width || this.deformation && !d(this.deformation) && this.deformation.type || this.fill && !d(this.fill) || this.content.some((e) => e.fragments.some((e) => !!(e.highlightImage || e.highlight?.image || e.fill && !d(e.fill))))) return !1;
7446
+ for (let e of [
7447
+ "background",
7448
+ "textDecoration",
7449
+ "listStyle",
7450
+ "highlight"
7451
+ ]) if (this.base.plugins.get(e)?.pathSet?.paths?.length) return !1;
7444
7452
  let e = 2048 / cr.superSample / 1.5, t = this.base.characters;
7445
7453
  for (let n = 0; n < t.length; n++) {
7446
7454
  let r = t[n].computedStyle;
@@ -7845,6 +7853,9 @@ var Q = {
7845
7853
  _updateTransform() {
7846
7854
  super._updateTransform(), this._updateAabb();
7847
7855
  }
7856
+ updateContentAabb() {
7857
+ this._updateAabb(), this._updateGlobalAabb();
7858
+ }
7848
7859
  _updateAabb() {
7849
7860
  let { a: e, b: t, c: n, d: r, tx: i, ty: a } = this.transform, o = [], s = [];
7850
7861
  this._getPointArray().forEach((c) => {
@@ -8045,6 +8056,30 @@ var Q = {
8045
8056
  }
8046
8057
  _getPointArray() {
8047
8058
  let { width: e, height: t } = this.size;
8059
+ if (this._text.isValid()) {
8060
+ let n = this._text.base.boundingBox;
8061
+ if (n && (n.left < 0 || n.top < 0 || n.left + n.width > e || n.top + n.height > t)) {
8062
+ let r = Math.min(0, n.left), i = Math.min(0, n.top), a = Math.max(e, n.left + n.width), o = Math.max(t, n.top + n.height);
8063
+ return [
8064
+ {
8065
+ x: r,
8066
+ y: i
8067
+ },
8068
+ {
8069
+ x: r,
8070
+ y: o
8071
+ },
8072
+ {
8073
+ x: a,
8074
+ y: i
8075
+ },
8076
+ {
8077
+ x: a,
8078
+ y: o
8079
+ }
8080
+ ];
8081
+ }
8082
+ }
8048
8083
  return [
8049
8084
  {
8050
8085
  x: 0,
@@ -102,6 +102,11 @@ export declare class Element2D extends Node2D implements Rectangulable {
102
102
  protected _treeEnter(tree: SceneTree): void;
103
103
  setProperties(properties?: Record<string, any>): this;
104
104
  _updateTransform(): void;
105
+ /**
106
+ * 供文字渲染子(Element2DText)在变形/内容改变、渲染范围可能超出布局框时调用,
107
+ * 按最新的 _getPointArray(已并入变形后字形范围)重算本地/全局 aabb,让选框贴合。
108
+ */
109
+ updateContentAabb(): void;
105
110
  protected _updateAabb(): void;
106
111
  updateGlobalTransform(): void;
107
112
  protected _updateGlobalAabb(): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.26.1",
4
+ "version": "0.26.2",
5
5
  "packageManager": "pnpm@10.19.0",
6
6
  "description": "A JavaScript WebGL rendering engine. only the ESM.",
7
7
  "author": "wxm",
@@ -64,8 +64,8 @@
64
64
  "earcut": "^3.2.0",
65
65
  "modern-font": "^0.6.2",
66
66
  "modern-idoc": "^0.12.3",
67
- "modern-path2d": "^1.8.6",
68
- "modern-text": "^2.1.2"
67
+ "modern-path2d": "^1.8.7",
68
+ "modern-text": "^2.1.3"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "echarts": "^5 || ^6",