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.cjs
CHANGED
|
@@ -6053,18 +6053,21 @@ exports.Node = class Node extends CoreObject {
|
|
|
6053
6053
|
toJSON() {
|
|
6054
6054
|
return modernIdoc.clearUndef({
|
|
6055
6055
|
...super.toJSON(),
|
|
6056
|
-
is: this.is,
|
|
6057
6056
|
children: this._children.length ? [...this._children.map((child) => child.toJSON())] : void 0,
|
|
6058
|
-
meta:
|
|
6057
|
+
meta: {
|
|
6058
|
+
...this.meta,
|
|
6059
|
+
inCanvasIs: this.is
|
|
6060
|
+
}
|
|
6059
6061
|
});
|
|
6060
6062
|
}
|
|
6061
6063
|
static parse(value) {
|
|
6062
6064
|
if (Array.isArray(value)) {
|
|
6063
6065
|
return value.map((val) => this.parse(val));
|
|
6064
6066
|
}
|
|
6065
|
-
const {
|
|
6066
|
-
const
|
|
6067
|
-
const
|
|
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 });
|
|
6068
6071
|
children?.forEach((child) => node.appendChild(this.parse(child)));
|
|
6069
6072
|
return node;
|
|
6070
6073
|
}
|
|
@@ -7106,7 +7109,19 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
7106
7109
|
if (!this.curves.length) {
|
|
7107
7110
|
return;
|
|
7108
7111
|
}
|
|
7109
|
-
|
|
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
|
+
}
|
|
7110
7125
|
this._draws.push({
|
|
7111
7126
|
...options,
|
|
7112
7127
|
type: "stroke",
|
|
@@ -7134,7 +7149,19 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
7134
7149
|
if (!this.curves.length) {
|
|
7135
7150
|
return;
|
|
7136
7151
|
}
|
|
7137
|
-
|
|
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
|
+
}
|
|
7138
7165
|
this._draws.push({
|
|
7139
7166
|
...options,
|
|
7140
7167
|
type: "fill",
|
|
@@ -9279,6 +9306,8 @@ class BaseElement2DText extends CoreObject {
|
|
|
9279
9306
|
switch (args[0]) {
|
|
9280
9307
|
case "content":
|
|
9281
9308
|
case "effects":
|
|
9309
|
+
case "fill":
|
|
9310
|
+
case "outline":
|
|
9282
9311
|
this.setter(args[0], args[1]);
|
|
9283
9312
|
break;
|
|
9284
9313
|
}
|
|
@@ -9295,12 +9324,14 @@ class BaseElement2DText extends CoreObject {
|
|
|
9295
9324
|
_updateProperty(key, value, oldValue, declaration) {
|
|
9296
9325
|
super._updateProperty(key, value, oldValue, declaration);
|
|
9297
9326
|
switch (key) {
|
|
9327
|
+
case "enabled":
|
|
9298
9328
|
case "content":
|
|
9299
9329
|
case "effects":
|
|
9300
|
-
case "
|
|
9330
|
+
case "measureDom":
|
|
9301
9331
|
case "fonts":
|
|
9332
|
+
case "fill":
|
|
9333
|
+
case "outline":
|
|
9302
9334
|
case "split":
|
|
9303
|
-
case "enabled":
|
|
9304
9335
|
this.parent.requestRedraw();
|
|
9305
9336
|
break;
|
|
9306
9337
|
}
|
|
@@ -9351,8 +9382,14 @@ __decorateClass$o([
|
|
|
9351
9382
|
modernIdoc.property({ alias: "base.effects" })
|
|
9352
9383
|
], BaseElement2DText.prototype, "effects");
|
|
9353
9384
|
__decorateClass$o([
|
|
9354
|
-
modernIdoc.property({
|
|
9355
|
-
], BaseElement2DText.prototype, "
|
|
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");
|
|
9356
9393
|
__decorateClass$o([
|
|
9357
9394
|
modernIdoc.property({ protected: true, alias: "base.fonts" })
|
|
9358
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,
|
|
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;
|
|
@@ -1960,7 +1961,7 @@ declare class BaseElement2DShape extends CoreObject {
|
|
|
1960
1961
|
drawRect(): void;
|
|
1961
1962
|
}
|
|
1962
1963
|
|
|
1963
|
-
interface BaseElement2DStyleProperties extends Omit<
|
|
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
|
-
|
|
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,
|
|
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;
|
|
@@ -1960,7 +1961,7 @@ declare class BaseElement2DShape extends CoreObject {
|
|
|
1960
1961
|
drawRect(): void;
|
|
1961
1962
|
}
|
|
1962
1963
|
|
|
1963
|
-
interface BaseElement2DStyleProperties extends Omit<
|
|
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
|
-
|
|
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,
|
|
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;
|
|
@@ -1960,7 +1961,7 @@ declare class BaseElement2DShape extends CoreObject {
|
|
|
1960
1961
|
drawRect(): void;
|
|
1961
1962
|
}
|
|
1962
1963
|
|
|
1963
|
-
interface BaseElement2DStyleProperties extends Omit<
|
|
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
|
-
|
|
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;
|