modern-canvas 0.6.10 → 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.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';
@@ -5593,7 +5593,6 @@ function getNodeIid(key) {
5593
5593
  return iid;
5594
5594
  }
5595
5595
  let Node = class extends CoreObject {
5596
- meta = {};
5597
5596
  _readyed = false;
5598
5597
  constructor(properties, nodes = []) {
5599
5598
  super();
@@ -6048,18 +6047,21 @@ let Node = class extends CoreObject {
6048
6047
  toJSON() {
6049
6048
  return clearUndef({
6050
6049
  ...super.toJSON(),
6051
- is: this.is,
6052
6050
  children: this._children.length ? [...this._children.map((child) => child.toJSON())] : void 0,
6053
- meta: Object.keys(this.meta).length ? { ...this.meta } : void 0
6051
+ meta: {
6052
+ ...this.meta,
6053
+ inCanvasIs: this.is
6054
+ }
6054
6055
  });
6055
6056
  }
6056
6057
  static parse(value) {
6057
6058
  if (Array.isArray(value)) {
6058
6059
  return value.map((val) => this.parse(val));
6059
6060
  }
6060
- const { is, props, children } = value;
6061
- const Class = customNodes.get(is) ?? Node;
6062
- const node = new Class(props);
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 });
6063
6065
  children?.forEach((child) => node.appendChild(this.parse(child)));
6064
6066
  return node;
6065
6067
  }
@@ -6082,6 +6084,9 @@ __decorateClass$R([
6082
6084
  __decorateClass$R([
6083
6085
  property({ fallback: "default" })
6084
6086
  ], Node.prototype, "internalMode", 2);
6087
+ __decorateClass$R([
6088
+ property({ default: () => ({}) })
6089
+ ], Node.prototype, "meta", 2);
6085
6090
  __decorateClass$R([
6086
6091
  property({ protected: true })
6087
6092
  ], Node.prototype, "mask", 2);
@@ -7098,7 +7103,19 @@ class CanvasContext extends Path2D {
7098
7103
  if (!this.curves.length) {
7099
7104
  return;
7100
7105
  }
7101
- const strokeStyle = this.strokeStyle ?? (typeof this.style.stroke === "string" ? this.style.stroke : void 0);
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
+ }
7102
7119
  this._draws.push({
7103
7120
  ...options,
7104
7121
  type: "stroke",
@@ -7126,7 +7143,19 @@ class CanvasContext extends Path2D {
7126
7143
  if (!this.curves.length) {
7127
7144
  return;
7128
7145
  }
7129
- const fillStyle = this.fillStyle ?? (typeof this.style.fill === "string" ? this.style.fill : void 0);
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
+ }
7130
7159
  this._draws.push({
7131
7160
  ...options,
7132
7161
  type: "fill",
@@ -9271,6 +9300,8 @@ class BaseElement2DText extends CoreObject {
9271
9300
  switch (args[0]) {
9272
9301
  case "content":
9273
9302
  case "effects":
9303
+ case "fill":
9304
+ case "outline":
9274
9305
  this.setter(args[0], args[1]);
9275
9306
  break;
9276
9307
  }
@@ -9287,12 +9318,14 @@ class BaseElement2DText extends CoreObject {
9287
9318
  _updateProperty(key, value, oldValue, declaration) {
9288
9319
  super._updateProperty(key, value, oldValue, declaration);
9289
9320
  switch (key) {
9321
+ case "enabled":
9290
9322
  case "content":
9291
9323
  case "effects":
9292
- case "measureDOM":
9324
+ case "measureDom":
9293
9325
  case "fonts":
9326
+ case "fill":
9327
+ case "outline":
9294
9328
  case "split":
9295
- case "enabled":
9296
9329
  this.parent.requestRedraw();
9297
9330
  break;
9298
9331
  }
@@ -9343,8 +9376,14 @@ __decorateClass$o([
9343
9376
  property({ alias: "base.effects" })
9344
9377
  ], BaseElement2DText.prototype, "effects");
9345
9378
  __decorateClass$o([
9346
- property({ protected: true, alias: "base.measureDOM" })
9347
- ], BaseElement2DText.prototype, "measureDOM");
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");
9348
9387
  __decorateClass$o([
9349
9388
  property({ protected: true, alias: "base.fonts" })
9350
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.10",
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.4",
74
- "modern-path2d": "^1.4.3",
75
- "modern-text": "^1.6.4",
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.3",
91
+ "vite": "^7.0.4",
92
92
  "vitest": "^3.2.4"
93
93
  },
94
94
  "simple-git-hooks": {