modern-canvas 0.4.32 → 0.4.34

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,6 +1,6 @@
1
- import { colord, extend } from 'colord';
1
+ import { extend } from 'colord';
2
2
  import namesPlugin from 'colord/plugins/names';
3
- import { normalizeFill, normalizeBackground, normalizeForeground, normalizeGeometry, normalizeOutline, normalizeShadow, getDefaultStyle, normalizeText } from 'modern-idoc';
3
+ import { parseColor, normalizeFill, normalizeBackground, normalizeForeground, normalizeGeometry, normalizeOutline, normalizeShadow, getDefaultStyle, normalizeText } from 'modern-idoc';
4
4
  import { Path2D, Path2DSet, svgToDOM, svgToPath2DSet, Matrix3 as Matrix3$1 } from 'modern-path2d';
5
5
  import { Text, textDefaultStyle } from 'modern-text';
6
6
  import { loadYoga, BoxSizing, PositionType, Edge, Overflow, Gutter, Justify, Wrap, FlexDirection, Display, Direction, Align } from 'yoga-layout/load';
@@ -555,7 +555,17 @@ class CoreObject extends EventEmitter {
555
555
  }
556
556
  }
557
557
  toJSON() {
558
- return this.getProperties(Array.from(this._changedProperties));
558
+ const json = {};
559
+ const properties = this.getProperties(Array.from(this._changedProperties));
560
+ for (const key in properties) {
561
+ const value = properties[key];
562
+ if (value && typeof value === "object" && "toJSON" in value && typeof value.toJSON === "function") {
563
+ json[key] = value.toJSON();
564
+ } else {
565
+ json[key] = value;
566
+ }
567
+ }
568
+ return json;
559
569
  }
560
570
  clone() {
561
571
  return new this.constructor(this.toJSON());
@@ -1058,27 +1068,7 @@ class Color {
1058
1068
  return this._value;
1059
1069
  }
1060
1070
  set value(value) {
1061
- if (value === void 0 || this._value === value)
1062
- return;
1063
- this._value = value;
1064
- let input;
1065
- if (typeof value === "number") {
1066
- input = {
1067
- r: value >> 24 & 255,
1068
- g: value >> 16 & 255,
1069
- b: value >> 8 & 255,
1070
- a: (value & 255) / 255
1071
- };
1072
- } else {
1073
- input = value;
1074
- }
1075
- const parsed = colord(input);
1076
- if (parsed.isValid()) {
1077
- this._colord = parsed;
1078
- } else {
1079
- this._colord = colord("#000000");
1080
- console.warn(`Unable to convert color ${value}`);
1081
- }
1071
+ this._colord = parseColor(value ?? "none");
1082
1072
  }
1083
1073
  get r8() {
1084
1074
  return this._colord.rgba.r;
@@ -9208,12 +9198,6 @@ __decorateClass$q([
9208
9198
  __decorateClass$q([
9209
9199
  property({ default: "solid" })
9210
9200
  ], BaseElement2DOutline.prototype, "style");
9211
- __decorateClass$q([
9212
- property()
9213
- ], BaseElement2DOutline.prototype, "src");
9214
- __decorateClass$q([
9215
- property({ default: 1 })
9216
- ], BaseElement2DOutline.prototype, "opacity");
9217
9201
 
9218
9202
  var __defProp$i = Object.defineProperty;
9219
9203
  var __decorateClass$p = (decorators, target, key, kind) => {
@@ -9802,13 +9786,15 @@ let BaseElement2D = class extends Node2D {
9802
9786
  return {
9803
9787
  ...json,
9804
9788
  props: {
9789
+ ...json.props,
9805
9790
  style: this.style.toJSON(),
9806
- text: this.text.toJSON(),
9791
+ background: this.background.toJSON(),
9807
9792
  geometry: this.geometry.toJSON(),
9808
9793
  fill: this.fill.toJSON(),
9809
9794
  outline: this.outline.toJSON(),
9810
- shadow: this.shadow.toJSON(),
9811
- ...json.props
9795
+ text: this.text.toJSON(),
9796
+ foreground: this.foreground.toJSON(),
9797
+ shadow: this.shadow.toJSON()
9812
9798
  }
9813
9799
  };
9814
9800
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.4.32",
4
+ "version": "0.4.34",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",
@@ -70,26 +70,26 @@
70
70
  "colord": "^2.9.3",
71
71
  "earcut": "^3.0.1",
72
72
  "modern-font": "^0.4.1",
73
- "modern-idoc": "^0.4.0",
74
- "modern-path2d": "^1.2.18",
75
- "modern-text": "^1.3.5",
73
+ "modern-idoc": "^0.5.3",
74
+ "modern-path2d": "^1.2.19",
75
+ "modern-text": "^1.3.10",
76
76
  "yoga-layout": "^3.2.1"
77
77
  },
78
78
  "devDependencies": {
79
- "@antfu/eslint-config": "^4.12.0",
79
+ "@antfu/eslint-config": "^4.13.0",
80
80
  "@types/earcut": "^3.0.0",
81
- "@types/node": "^22.14.0",
81
+ "@types/node": "^22.15.17",
82
82
  "bumpp": "^10.1.0",
83
83
  "conventional-changelog-cli": "^5.0.0",
84
- "eslint": "^9.24.0",
85
- "lint-staged": "^15.5.0",
84
+ "eslint": "^9.26.0",
85
+ "lint-staged": "^15.5.2",
86
86
  "lottie-web": "^5.12.2",
87
87
  "modern-gif": "^2.0.4",
88
- "simple-git-hooks": "^2.12.1",
88
+ "simple-git-hooks": "^2.13.0",
89
89
  "typescript": "^5.8.3",
90
90
  "unbuild": "^3.5.0",
91
- "vite": "^6.2.5",
92
- "vitest": "^3.1.1"
91
+ "vite": "^6.3.5",
92
+ "vitest": "^3.1.3"
93
93
  },
94
94
  "simple-git-hooks": {
95
95
  "pre-commit": "pnpm lint-staged"