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.cjs CHANGED
@@ -5599,7 +5599,6 @@ function getNodeIid(key) {
5599
5599
  return iid;
5600
5600
  }
5601
5601
  exports.Node = class Node extends CoreObject {
5602
- meta = {};
5603
5602
  _readyed = false;
5604
5603
  constructor(properties, nodes = []) {
5605
5604
  super();
@@ -6054,18 +6053,21 @@ exports.Node = class Node extends CoreObject {
6054
6053
  toJSON() {
6055
6054
  return modernIdoc.clearUndef({
6056
6055
  ...super.toJSON(),
6057
- is: this.is,
6058
6056
  children: this._children.length ? [...this._children.map((child) => child.toJSON())] : void 0,
6059
- meta: Object.keys(this.meta).length ? { ...this.meta } : void 0
6057
+ meta: {
6058
+ ...this.meta,
6059
+ inCanvasIs: this.is
6060
+ }
6060
6061
  });
6061
6062
  }
6062
6063
  static parse(value) {
6063
6064
  if (Array.isArray(value)) {
6064
6065
  return value.map((val) => this.parse(val));
6065
6066
  }
6066
- const { is, props, children } = value;
6067
- const Class = customNodes.get(is) ?? exports.Node;
6068
- const node = new Class(props);
6067
+ const { meta = {}, children, ...props } = value;
6068
+ const { inCanvasIs = "Node" } = meta;
6069
+ const Class = customNodes.get(inCanvasIs) ?? exports.Node;
6070
+ const node = new Class({ ...props, meta });
6069
6071
  children?.forEach((child) => node.appendChild(this.parse(child)));
6070
6072
  return node;
6071
6073
  }
@@ -6088,6 +6090,9 @@ __decorateClass$R([
6088
6090
  __decorateClass$R([
6089
6091
  modernIdoc.property({ fallback: "default" })
6090
6092
  ], exports.Node.prototype, "internalMode", 2);
6093
+ __decorateClass$R([
6094
+ modernIdoc.property({ default: () => ({}) })
6095
+ ], exports.Node.prototype, "meta", 2);
6091
6096
  __decorateClass$R([
6092
6097
  modernIdoc.property({ protected: true })
6093
6098
  ], exports.Node.prototype, "mask", 2);
@@ -7104,7 +7109,19 @@ class CanvasContext extends modernPath2d.Path2D {
7104
7109
  if (!this.curves.length) {
7105
7110
  return;
7106
7111
  }
7107
- const strokeStyle = this.strokeStyle ?? (typeof this.style.stroke === "string" ? this.style.stroke : void 0);
7112
+ let strokeStyle = this.strokeStyle;
7113
+ if (!strokeStyle && this.style.stroke) {
7114
+ switch (typeof this.style.stroke) {
7115
+ case "string":
7116
+ strokeStyle = this.style.stroke;
7117
+ break;
7118
+ case "object":
7119
+ if (modernIdoc.isColorFillObject(this.style.stroke)) {
7120
+ strokeStyle = this.style.stroke.color;
7121
+ }
7122
+ break;
7123
+ }
7124
+ }
7108
7125
  this._draws.push({
7109
7126
  ...options,
7110
7127
  type: "stroke",
@@ -7132,7 +7149,19 @@ class CanvasContext extends modernPath2d.Path2D {
7132
7149
  if (!this.curves.length) {
7133
7150
  return;
7134
7151
  }
7135
- const fillStyle = this.fillStyle ?? (typeof this.style.fill === "string" ? this.style.fill : void 0);
7152
+ let fillStyle = this.fillStyle;
7153
+ if (!fillStyle && this.style.fill) {
7154
+ switch (typeof this.style.fill) {
7155
+ case "string":
7156
+ fillStyle = this.style.fill;
7157
+ break;
7158
+ case "object":
7159
+ if (modernIdoc.isColorFillObject(this.style.fill)) {
7160
+ fillStyle = this.style.fill.color;
7161
+ }
7162
+ break;
7163
+ }
7164
+ }
7136
7165
  this._draws.push({
7137
7166
  ...options,
7138
7167
  type: "fill",
@@ -9277,6 +9306,8 @@ class BaseElement2DText extends CoreObject {
9277
9306
  switch (args[0]) {
9278
9307
  case "content":
9279
9308
  case "effects":
9309
+ case "fill":
9310
+ case "outline":
9280
9311
  this.setter(args[0], args[1]);
9281
9312
  break;
9282
9313
  }
@@ -9293,12 +9324,14 @@ class BaseElement2DText extends CoreObject {
9293
9324
  _updateProperty(key, value, oldValue, declaration) {
9294
9325
  super._updateProperty(key, value, oldValue, declaration);
9295
9326
  switch (key) {
9327
+ case "enabled":
9296
9328
  case "content":
9297
9329
  case "effects":
9298
- case "measureDOM":
9330
+ case "measureDom":
9299
9331
  case "fonts":
9332
+ case "fill":
9333
+ case "outline":
9300
9334
  case "split":
9301
- case "enabled":
9302
9335
  this.parent.requestRedraw();
9303
9336
  break;
9304
9337
  }
@@ -9349,8 +9382,14 @@ __decorateClass$o([
9349
9382
  modernIdoc.property({ alias: "base.effects" })
9350
9383
  ], BaseElement2DText.prototype, "effects");
9351
9384
  __decorateClass$o([
9352
- modernIdoc.property({ protected: true, alias: "base.measureDOM" })
9353
- ], BaseElement2DText.prototype, "measureDOM");
9385
+ modernIdoc.property({ alias: "base.fill" })
9386
+ ], BaseElement2DText.prototype, "fill");
9387
+ __decorateClass$o([
9388
+ modernIdoc.property({ alias: "base.outline" })
9389
+ ], BaseElement2DText.prototype, "outline");
9390
+ __decorateClass$o([
9391
+ modernIdoc.property({ protected: true, alias: "base.measureDom" })
9392
+ ], BaseElement2DText.prototype, "measureDom");
9354
9393
  __decorateClass$o([
9355
9394
  modernIdoc.property({ protected: true, alias: "base.fonts" })
9356
9395
  ], BaseElement2DText.prototype, "fonts");
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Font } from 'modern-font';
2
- import { EventListenerOptions, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, NormalizedStyle, Text as Text$1, Style, ImageFillCropRect } from 'modern-idoc';
2
+ import { EventListenerOptions, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, Style, ImageFillCropRect } from 'modern-idoc';
3
3
  export { Color as ColorValue } from 'modern-idoc';
4
4
  import { AnimationItem } from 'lottie-web';
5
5
  import { Colord, RgbaColor, HslaColor, HsvaColor } from 'colord';
@@ -1607,6 +1607,7 @@ type ProcessSortMode = 'default' | 'parent_before';
1607
1607
  type RenderMode = 'inherit' | 'always' | 'disabled';
1608
1608
  type InternalMode = 'default' | 'front' | 'back';
1609
1609
  interface NodeProperties {
1610
+ id: string;
1610
1611
  name: string;
1611
1612
  mask: Maskable;
1612
1613
  processMode: ProcessMode;
@@ -1629,8 +1630,8 @@ declare class Node extends CoreObject {
1629
1630
  processSortMode: ProcessSortMode;
1630
1631
  renderMode: RenderMode;
1631
1632
  internalMode: InternalMode;
1633
+ meta: Record<string, any>;
1632
1634
  mask?: Maskable;
1633
- readonly meta: Record<string, any>;
1634
1635
  protected _readyed: boolean;
1635
1636
  constructor(properties?: Partial<NodeProperties>, nodes?: Node[]);
1636
1637
  setProperties(properties?: Record<string, any>): this;
@@ -1960,7 +1961,7 @@ declare class BaseElement2DShape extends CoreObject {
1960
1961
  drawRect(): void;
1961
1962
  }
1962
1963
 
1963
- interface BaseElement2DStyleProperties extends Omit<NormalizedStyle, 'left' | 'top' | 'width' | 'height'> {
1964
+ interface BaseElement2DStyleProperties extends Omit<FullStyle, 'left' | 'top' | 'width' | 'height'> {
1964
1965
  left: number;
1965
1966
  top: number;
1966
1967
  width: number;
@@ -1977,7 +1978,9 @@ declare class BaseElement2DText extends CoreObject {
1977
1978
  enabled: boolean;
1978
1979
  content: Text['content'];
1979
1980
  effects: Text['effects'];
1980
- measureDOM: Text['measureDOM'];
1981
+ fill: Text['fill'];
1982
+ outline: Text['outline'];
1983
+ measureDom: Text['measureDom'];
1981
1984
  fonts: Text['fonts'];
1982
1985
  readonly base: Text;
1983
1986
  measureResult?: MeasureResult;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Font } from 'modern-font';
2
- import { EventListenerOptions, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, NormalizedStyle, Text as Text$1, Style, ImageFillCropRect } from 'modern-idoc';
2
+ import { EventListenerOptions, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, Style, ImageFillCropRect } from 'modern-idoc';
3
3
  export { Color as ColorValue } from 'modern-idoc';
4
4
  import { AnimationItem } from 'lottie-web';
5
5
  import { Colord, RgbaColor, HslaColor, HsvaColor } from 'colord';
@@ -1607,6 +1607,7 @@ type ProcessSortMode = 'default' | 'parent_before';
1607
1607
  type RenderMode = 'inherit' | 'always' | 'disabled';
1608
1608
  type InternalMode = 'default' | 'front' | 'back';
1609
1609
  interface NodeProperties {
1610
+ id: string;
1610
1611
  name: string;
1611
1612
  mask: Maskable;
1612
1613
  processMode: ProcessMode;
@@ -1629,8 +1630,8 @@ declare class Node extends CoreObject {
1629
1630
  processSortMode: ProcessSortMode;
1630
1631
  renderMode: RenderMode;
1631
1632
  internalMode: InternalMode;
1633
+ meta: Record<string, any>;
1632
1634
  mask?: Maskable;
1633
- readonly meta: Record<string, any>;
1634
1635
  protected _readyed: boolean;
1635
1636
  constructor(properties?: Partial<NodeProperties>, nodes?: Node[]);
1636
1637
  setProperties(properties?: Record<string, any>): this;
@@ -1960,7 +1961,7 @@ declare class BaseElement2DShape extends CoreObject {
1960
1961
  drawRect(): void;
1961
1962
  }
1962
1963
 
1963
- interface BaseElement2DStyleProperties extends Omit<NormalizedStyle, 'left' | 'top' | 'width' | 'height'> {
1964
+ interface BaseElement2DStyleProperties extends Omit<FullStyle, 'left' | 'top' | 'width' | 'height'> {
1964
1965
  left: number;
1965
1966
  top: number;
1966
1967
  width: number;
@@ -1977,7 +1978,9 @@ declare class BaseElement2DText extends CoreObject {
1977
1978
  enabled: boolean;
1978
1979
  content: Text['content'];
1979
1980
  effects: Text['effects'];
1980
- measureDOM: Text['measureDOM'];
1981
+ fill: Text['fill'];
1982
+ outline: Text['outline'];
1983
+ measureDom: Text['measureDom'];
1981
1984
  fonts: Text['fonts'];
1982
1985
  readonly base: Text;
1983
1986
  measureResult?: MeasureResult;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Font } from 'modern-font';
2
- import { EventListenerOptions, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, NormalizedStyle, Text as Text$1, Style, ImageFillCropRect } from 'modern-idoc';
2
+ import { EventListenerOptions, EventListenerValue, EventEmitter, PropertyDeclaration, ReactiveObject, ReactiveObjectPropertyAccessorContext, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, Style, ImageFillCropRect } from 'modern-idoc';
3
3
  export { Color as ColorValue } from 'modern-idoc';
4
4
  import { AnimationItem } from 'lottie-web';
5
5
  import { Colord, RgbaColor, HslaColor, HsvaColor } from 'colord';
@@ -1607,6 +1607,7 @@ type ProcessSortMode = 'default' | 'parent_before';
1607
1607
  type RenderMode = 'inherit' | 'always' | 'disabled';
1608
1608
  type InternalMode = 'default' | 'front' | 'back';
1609
1609
  interface NodeProperties {
1610
+ id: string;
1610
1611
  name: string;
1611
1612
  mask: Maskable;
1612
1613
  processMode: ProcessMode;
@@ -1629,8 +1630,8 @@ declare class Node extends CoreObject {
1629
1630
  processSortMode: ProcessSortMode;
1630
1631
  renderMode: RenderMode;
1631
1632
  internalMode: InternalMode;
1633
+ meta: Record<string, any>;
1632
1634
  mask?: Maskable;
1633
- readonly meta: Record<string, any>;
1634
1635
  protected _readyed: boolean;
1635
1636
  constructor(properties?: Partial<NodeProperties>, nodes?: Node[]);
1636
1637
  setProperties(properties?: Record<string, any>): this;
@@ -1960,7 +1961,7 @@ declare class BaseElement2DShape extends CoreObject {
1960
1961
  drawRect(): void;
1961
1962
  }
1962
1963
 
1963
- interface BaseElement2DStyleProperties extends Omit<NormalizedStyle, 'left' | 'top' | 'width' | 'height'> {
1964
+ interface BaseElement2DStyleProperties extends Omit<FullStyle, 'left' | 'top' | 'width' | 'height'> {
1964
1965
  left: number;
1965
1966
  top: number;
1966
1967
  width: number;
@@ -1977,7 +1978,9 @@ declare class BaseElement2DText extends CoreObject {
1977
1978
  enabled: boolean;
1978
1979
  content: Text['content'];
1979
1980
  effects: Text['effects'];
1980
- measureDOM: Text['measureDOM'];
1981
+ fill: Text['fill'];
1982
+ outline: Text['outline'];
1983
+ measureDom: Text['measureDom'];
1981
1984
  fonts: Text['fonts'];
1982
1985
  readonly base: Text;
1983
1986
  measureResult?: MeasureResult;