modern-canvas 0.6.11 → 0.6.12
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 +48 -11
- package/dist/index.d.cts +6 -3
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +41 -41
- package/dist/index.mjs +49 -12
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineProperty, EventEmitter, getDeclarations, parseColor, property, RawWeakMap as RawWeakMap$1, isGradient, clearUndef, idGenerator, normalizeFill, isNone, normalizeBackground, normalizeForeground, normalizeOutline, normalizeShadow, normalizeShape, getDefaultStyle, normalizeText } from 'modern-idoc';
|
|
1
|
+
import { defineProperty, EventEmitter, getDeclarations, parseColor, property, RawWeakMap as RawWeakMap$1, isGradient, clearUndef, idGenerator, isColorFillObject, normalizeFill, isNone, normalizeBackground, normalizeForeground, normalizeOutline, normalizeShadow, normalizeShape, getDefaultStyle, normalizeText } from 'modern-idoc';
|
|
2
2
|
import { extend } from 'colord';
|
|
3
3
|
import namesPlugin from 'colord/plugins/names';
|
|
4
4
|
import { Path2D, Path2DSet, svgToDom, svgToPath2DSet, Matrix3 as Matrix3$1 } from 'modern-path2d';
|
|
@@ -6047,18 +6047,21 @@ let Node = class extends CoreObject {
|
|
|
6047
6047
|
toJSON() {
|
|
6048
6048
|
return clearUndef({
|
|
6049
6049
|
...super.toJSON(),
|
|
6050
|
-
is: this.is,
|
|
6051
6050
|
children: this._children.length ? [...this._children.map((child) => child.toJSON())] : void 0,
|
|
6052
|
-
meta:
|
|
6051
|
+
meta: {
|
|
6052
|
+
...this.meta,
|
|
6053
|
+
inCanvasIs: this.is
|
|
6054
|
+
}
|
|
6053
6055
|
});
|
|
6054
6056
|
}
|
|
6055
6057
|
static parse(value) {
|
|
6056
6058
|
if (Array.isArray(value)) {
|
|
6057
6059
|
return value.map((val) => this.parse(val));
|
|
6058
6060
|
}
|
|
6059
|
-
const {
|
|
6060
|
-
const
|
|
6061
|
-
const
|
|
6061
|
+
const { meta = {}, children, ...props } = value;
|
|
6062
|
+
const { inCanvasIs = "Node" } = meta;
|
|
6063
|
+
const Class = customNodes.get(inCanvasIs) ?? Node;
|
|
6064
|
+
const node = new Class({ ...props, meta });
|
|
6062
6065
|
children?.forEach((child) => node.appendChild(this.parse(child)));
|
|
6063
6066
|
return node;
|
|
6064
6067
|
}
|
|
@@ -7100,7 +7103,19 @@ class CanvasContext extends Path2D {
|
|
|
7100
7103
|
if (!this.curves.length) {
|
|
7101
7104
|
return;
|
|
7102
7105
|
}
|
|
7103
|
-
|
|
7106
|
+
let strokeStyle = this.strokeStyle;
|
|
7107
|
+
if (!strokeStyle && this.style.stroke) {
|
|
7108
|
+
switch (typeof this.style.stroke) {
|
|
7109
|
+
case "string":
|
|
7110
|
+
strokeStyle = this.style.stroke;
|
|
7111
|
+
break;
|
|
7112
|
+
case "object":
|
|
7113
|
+
if (isColorFillObject(this.style.stroke)) {
|
|
7114
|
+
strokeStyle = this.style.stroke.color;
|
|
7115
|
+
}
|
|
7116
|
+
break;
|
|
7117
|
+
}
|
|
7118
|
+
}
|
|
7104
7119
|
this._draws.push({
|
|
7105
7120
|
...options,
|
|
7106
7121
|
type: "stroke",
|
|
@@ -7128,7 +7143,19 @@ class CanvasContext extends Path2D {
|
|
|
7128
7143
|
if (!this.curves.length) {
|
|
7129
7144
|
return;
|
|
7130
7145
|
}
|
|
7131
|
-
|
|
7146
|
+
let fillStyle = this.fillStyle;
|
|
7147
|
+
if (!fillStyle && this.style.fill) {
|
|
7148
|
+
switch (typeof this.style.fill) {
|
|
7149
|
+
case "string":
|
|
7150
|
+
fillStyle = this.style.fill;
|
|
7151
|
+
break;
|
|
7152
|
+
case "object":
|
|
7153
|
+
if (isColorFillObject(this.style.fill)) {
|
|
7154
|
+
fillStyle = this.style.fill.color;
|
|
7155
|
+
}
|
|
7156
|
+
break;
|
|
7157
|
+
}
|
|
7158
|
+
}
|
|
7132
7159
|
this._draws.push({
|
|
7133
7160
|
...options,
|
|
7134
7161
|
type: "fill",
|
|
@@ -9273,6 +9300,8 @@ class BaseElement2DText extends CoreObject {
|
|
|
9273
9300
|
switch (args[0]) {
|
|
9274
9301
|
case "content":
|
|
9275
9302
|
case "effects":
|
|
9303
|
+
case "fill":
|
|
9304
|
+
case "outline":
|
|
9276
9305
|
this.setter(args[0], args[1]);
|
|
9277
9306
|
break;
|
|
9278
9307
|
}
|
|
@@ -9289,12 +9318,14 @@ class BaseElement2DText extends CoreObject {
|
|
|
9289
9318
|
_updateProperty(key, value, oldValue, declaration) {
|
|
9290
9319
|
super._updateProperty(key, value, oldValue, declaration);
|
|
9291
9320
|
switch (key) {
|
|
9321
|
+
case "enabled":
|
|
9292
9322
|
case "content":
|
|
9293
9323
|
case "effects":
|
|
9294
|
-
case "
|
|
9324
|
+
case "measureDom":
|
|
9295
9325
|
case "fonts":
|
|
9326
|
+
case "fill":
|
|
9327
|
+
case "outline":
|
|
9296
9328
|
case "split":
|
|
9297
|
-
case "enabled":
|
|
9298
9329
|
this.parent.requestRedraw();
|
|
9299
9330
|
break;
|
|
9300
9331
|
}
|
|
@@ -9345,8 +9376,14 @@ __decorateClass$o([
|
|
|
9345
9376
|
property({ alias: "base.effects" })
|
|
9346
9377
|
], BaseElement2DText.prototype, "effects");
|
|
9347
9378
|
__decorateClass$o([
|
|
9348
|
-
property({
|
|
9349
|
-
], BaseElement2DText.prototype, "
|
|
9379
|
+
property({ alias: "base.fill" })
|
|
9380
|
+
], BaseElement2DText.prototype, "fill");
|
|
9381
|
+
__decorateClass$o([
|
|
9382
|
+
property({ alias: "base.outline" })
|
|
9383
|
+
], BaseElement2DText.prototype, "outline");
|
|
9384
|
+
__decorateClass$o([
|
|
9385
|
+
property({ protected: true, alias: "base.measureDom" })
|
|
9386
|
+
], BaseElement2DText.prototype, "measureDom");
|
|
9350
9387
|
__decorateClass$o([
|
|
9351
9388
|
property({ protected: true, alias: "base.fonts" })
|
|
9352
9389
|
], BaseElement2DText.prototype, "fonts");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modern-canvas",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.12",
|
|
5
5
|
"packageManager": "pnpm@9.15.1",
|
|
6
6
|
"description": "A JavaScript WebGL rendering engine.",
|
|
7
7
|
"author": "wxm",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"colord": "^2.9.3",
|
|
71
71
|
"earcut": "^3.0.1",
|
|
72
72
|
"modern-font": "^0.4.1",
|
|
73
|
-
"modern-idoc": "^0.8.
|
|
74
|
-
"modern-path2d": "^1.4.
|
|
75
|
-
"modern-text": "^1.
|
|
73
|
+
"modern-idoc": "^0.8.5",
|
|
74
|
+
"modern-path2d": "^1.4.5",
|
|
75
|
+
"modern-text": "^1.7.1",
|
|
76
76
|
"yoga-layout": "^3.2.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"simple-git-hooks": "^2.13.0",
|
|
89
89
|
"typescript": "^5.8.3",
|
|
90
90
|
"unbuild": "^3.5.0",
|
|
91
|
-
"vite": "^7.0.
|
|
91
|
+
"vite": "^7.0.4",
|
|
92
92
|
"vitest": "^3.2.4"
|
|
93
93
|
},
|
|
94
94
|
"simple-git-hooks": {
|