modern-canvas 0.4.27 → 0.4.29
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.cjs +23 -18
- package/dist/index.d.cts +14 -4
- package/dist/index.d.mts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +45 -45
- package/dist/index.mjs +23 -18
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -10443,13 +10443,18 @@ let Text2D = class extends TextureRect2D {
|
|
|
10443
10443
|
measureDom;
|
|
10444
10444
|
fonts;
|
|
10445
10445
|
texture = new CanvasTexture();
|
|
10446
|
-
|
|
10446
|
+
base = new Text();
|
|
10447
10447
|
measureResult;
|
|
10448
10448
|
_subTextsCount = 0;
|
|
10449
10449
|
constructor(properties, children = []) {
|
|
10450
10450
|
super();
|
|
10451
10451
|
this.setProperties(properties);
|
|
10452
10452
|
this.append(children);
|
|
10453
|
+
if (properties?.plugins) {
|
|
10454
|
+
properties.plugins.forEach((plugin) => {
|
|
10455
|
+
this.base.use(plugin);
|
|
10456
|
+
});
|
|
10457
|
+
}
|
|
10453
10458
|
}
|
|
10454
10459
|
_updateProperty(key, value, oldValue, declaration) {
|
|
10455
10460
|
super._updateProperty(key, value, oldValue, declaration);
|
|
@@ -10469,13 +10474,14 @@ let Text2D = class extends TextureRect2D {
|
|
|
10469
10474
|
});
|
|
10470
10475
|
}
|
|
10471
10476
|
}
|
|
10472
|
-
|
|
10473
|
-
this.
|
|
10474
|
-
this.
|
|
10475
|
-
this.
|
|
10476
|
-
this.
|
|
10477
|
-
this.
|
|
10478
|
-
this.
|
|
10477
|
+
_updateBase() {
|
|
10478
|
+
this.base.style = this.style.toJSON();
|
|
10479
|
+
this.base.content = this.content ?? "";
|
|
10480
|
+
this.base.effects = this.effects;
|
|
10481
|
+
this.base.fonts = this.fonts;
|
|
10482
|
+
this.base.measureDom = this.measureDom;
|
|
10483
|
+
this.emit("updateBase", this.base);
|
|
10484
|
+
this.base.requestUpdate();
|
|
10479
10485
|
}
|
|
10480
10486
|
_updateStyleProperty(key, value, oldValue) {
|
|
10481
10487
|
switch (key) {
|
|
@@ -10527,18 +10533,17 @@ let Text2D = class extends TextureRect2D {
|
|
|
10527
10533
|
}
|
|
10528
10534
|
}
|
|
10529
10535
|
measure() {
|
|
10530
|
-
this.
|
|
10531
|
-
return this.
|
|
10536
|
+
this._updateBase();
|
|
10537
|
+
return this.base.measure();
|
|
10532
10538
|
}
|
|
10533
10539
|
updateMeasure() {
|
|
10534
10540
|
this.measureResult = this.measure();
|
|
10535
|
-
const
|
|
10536
|
-
const
|
|
10537
|
-
|
|
10538
|
-
this.position.
|
|
10539
|
-
this.
|
|
10540
|
-
this.size.
|
|
10541
|
-
this.size.height = textHeight;
|
|
10541
|
+
const { boundingBox } = this.measureResult;
|
|
10542
|
+
const { left, top } = this.style;
|
|
10543
|
+
this.position.x = left + Math.min(0, boundingBox.left);
|
|
10544
|
+
this.position.y = top + Math.min(0, boundingBox.top);
|
|
10545
|
+
this.size.width = boundingBox.width;
|
|
10546
|
+
this.size.height = boundingBox.height;
|
|
10542
10547
|
return this;
|
|
10543
10548
|
}
|
|
10544
10549
|
_updateSplit() {
|
|
@@ -10580,7 +10585,7 @@ let Text2D = class extends TextureRect2D {
|
|
|
10580
10585
|
if (onText2DRender) {
|
|
10581
10586
|
onText2DRender();
|
|
10582
10587
|
} else {
|
|
10583
|
-
this.
|
|
10588
|
+
this.base.render({
|
|
10584
10589
|
pixelRatio: this.texture.pixelRatio,
|
|
10585
10590
|
view: this.texture.source
|
|
10586
10591
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modern-canvas",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.29",
|
|
5
5
|
"packageManager": "pnpm@9.15.1",
|
|
6
6
|
"description": "A JavaScript WebGL rendering engine.",
|
|
7
7
|
"author": "wxm",
|
|
@@ -69,27 +69,27 @@
|
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"colord": "^2.9.3",
|
|
71
71
|
"earcut": "^3.0.1",
|
|
72
|
-
"modern-font": "^0.4.
|
|
72
|
+
"modern-font": "^0.4.1",
|
|
73
73
|
"modern-idoc": "^0.2.13",
|
|
74
74
|
"modern-path2d": "^1.2.18",
|
|
75
|
-
"modern-text": "^1.3.
|
|
75
|
+
"modern-text": "^1.3.4",
|
|
76
76
|
"yoga-layout": "^3.2.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@antfu/eslint-config": "^4.
|
|
79
|
+
"@antfu/eslint-config": "^4.11.0",
|
|
80
80
|
"@types/earcut": "^3.0.0",
|
|
81
|
-
"@types/node": "^22.13.
|
|
82
|
-
"bumpp": "^10.0
|
|
81
|
+
"@types/node": "^22.13.17",
|
|
82
|
+
"bumpp": "^10.1.0",
|
|
83
83
|
"conventional-changelog-cli": "^5.0.0",
|
|
84
|
-
"eslint": "^9.
|
|
85
|
-
"lint-staged": "^15.
|
|
84
|
+
"eslint": "^9.23.0",
|
|
85
|
+
"lint-staged": "^15.5.0",
|
|
86
86
|
"lottie-web": "^5.12.2",
|
|
87
87
|
"modern-gif": "^2.0.4",
|
|
88
|
-
"simple-git-hooks": "^2.
|
|
88
|
+
"simple-git-hooks": "^2.12.1",
|
|
89
89
|
"typescript": "^5.8.2",
|
|
90
90
|
"unbuild": "^3.5.0",
|
|
91
|
-
"vite": "^6.2.
|
|
92
|
-
"vitest": "^3.
|
|
91
|
+
"vite": "^6.2.4",
|
|
92
|
+
"vitest": "^3.1.1"
|
|
93
93
|
},
|
|
94
94
|
"simple-git-hooks": {
|
|
95
95
|
"pre-commit": "pnpm lint-staged"
|