modern-idoc 0.6.13 → 0.6.15
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 +151 -0
- package/dist/index.d.cts +42 -2
- package/dist/index.d.mts +42 -2
- package/dist/index.d.ts +42 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +144 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -51,6 +51,87 @@ function pick(obj, keys) {
|
|
|
51
51
|
return result;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
function getNestedValue(obj, path, fallback) {
|
|
55
|
+
const last = path.length - 1;
|
|
56
|
+
if (last < 0)
|
|
57
|
+
return obj === void 0 ? fallback : obj;
|
|
58
|
+
for (let i = 0; i < last; i++) {
|
|
59
|
+
if (obj == null) {
|
|
60
|
+
return fallback;
|
|
61
|
+
}
|
|
62
|
+
obj = obj[path[i]];
|
|
63
|
+
}
|
|
64
|
+
if (obj == null)
|
|
65
|
+
return fallback;
|
|
66
|
+
return obj[path[last]] === void 0 ? fallback : obj[path[last]];
|
|
67
|
+
}
|
|
68
|
+
function setNestedValue(obj, path, value) {
|
|
69
|
+
const last = path.length - 1;
|
|
70
|
+
for (let i = 0; i < last; i++) {
|
|
71
|
+
if (typeof obj[path[i]] !== "object")
|
|
72
|
+
obj[path[i]] = {};
|
|
73
|
+
obj = obj[path[i]];
|
|
74
|
+
}
|
|
75
|
+
obj[path[last]] = value;
|
|
76
|
+
}
|
|
77
|
+
function getObjectValueByPath(obj, path, fallback) {
|
|
78
|
+
if (obj == null || !path || typeof path !== "string")
|
|
79
|
+
return fallback;
|
|
80
|
+
if (obj[path] !== void 0)
|
|
81
|
+
return obj[path];
|
|
82
|
+
path = path.replace(/\[(\w+)\]/g, ".$1");
|
|
83
|
+
path = path.replace(/^\./, "");
|
|
84
|
+
return getNestedValue(obj, path.split("."), fallback);
|
|
85
|
+
}
|
|
86
|
+
function setObjectValueByPath(obj, path, value) {
|
|
87
|
+
if (typeof obj !== "object" || !path)
|
|
88
|
+
return;
|
|
89
|
+
path = path.replace(/\[(\w+)\]/g, ".$1");
|
|
90
|
+
path = path.replace(/^\./, "");
|
|
91
|
+
return setNestedValue(obj, path.split("."), value);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
class RawWeakMap {
|
|
95
|
+
_map = /* @__PURE__ */ new WeakMap();
|
|
96
|
+
// fix: vue reactive object
|
|
97
|
+
_toRaw(value) {
|
|
98
|
+
if (value && typeof value === "object") {
|
|
99
|
+
const raw = value.__v_raw;
|
|
100
|
+
if (raw) {
|
|
101
|
+
value = this._toRaw(raw);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Removes the specified element from the WeakMap.
|
|
108
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
109
|
+
*/
|
|
110
|
+
delete(key) {
|
|
111
|
+
return this._map.delete(this._toRaw(key));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @returns a specified element.
|
|
115
|
+
*/
|
|
116
|
+
get(key) {
|
|
117
|
+
return this._map.get(this._toRaw(key));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @returns a boolean indicating whether an element with the specified key exists or not.
|
|
121
|
+
*/
|
|
122
|
+
has(key) {
|
|
123
|
+
return this._map.has(this._toRaw(key));
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Adds a new element with a specified key and value.
|
|
127
|
+
* @param key Must be an object or symbol.
|
|
128
|
+
*/
|
|
129
|
+
set(key, value) {
|
|
130
|
+
this._map.set(this._toRaw(key), this._toRaw(value));
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
54
135
|
function parseColor(color) {
|
|
55
136
|
let input;
|
|
56
137
|
if (typeof color === "number") {
|
|
@@ -809,6 +890,68 @@ function normalizeBackground(background) {
|
|
|
809
890
|
}
|
|
810
891
|
}
|
|
811
892
|
|
|
893
|
+
const declarationMap = new RawWeakMap();
|
|
894
|
+
function getDeclarations(constructor) {
|
|
895
|
+
let declarations = declarationMap.get(constructor);
|
|
896
|
+
if (!declarations) {
|
|
897
|
+
const superConstructor = Object.getPrototypeOf(constructor);
|
|
898
|
+
declarations = new Map(superConstructor ? getDeclarations(superConstructor) : void 0);
|
|
899
|
+
declarationMap.set(constructor, declarations);
|
|
900
|
+
}
|
|
901
|
+
return declarations;
|
|
902
|
+
}
|
|
903
|
+
function defineProperty(constructor, key, declaration = {}) {
|
|
904
|
+
getDeclarations(constructor).set(key, declaration);
|
|
905
|
+
const {
|
|
906
|
+
default: defaultValue,
|
|
907
|
+
alias = Symbol.for(String(key))
|
|
908
|
+
} = declaration;
|
|
909
|
+
const getDefaultValue = () => typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
910
|
+
const descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, key) || {
|
|
911
|
+
get() {
|
|
912
|
+
if (typeof alias === "string") {
|
|
913
|
+
return getObjectValueByPath(this, alias);
|
|
914
|
+
} else {
|
|
915
|
+
return this[alias];
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
set(v) {
|
|
919
|
+
if (typeof alias === "string") {
|
|
920
|
+
setObjectValueByPath(this, alias, v);
|
|
921
|
+
} else {
|
|
922
|
+
this[alias] = v;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
Object.defineProperty(constructor.prototype, key, {
|
|
927
|
+
get() {
|
|
928
|
+
let value = descriptor.get?.call(this);
|
|
929
|
+
if (value === void 0) {
|
|
930
|
+
value = getDefaultValue();
|
|
931
|
+
if (value !== void 0) {
|
|
932
|
+
descriptor.set?.call(this, value);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
return value;
|
|
936
|
+
},
|
|
937
|
+
set(newValue) {
|
|
938
|
+
let oldValue = descriptor.get?.call(this);
|
|
939
|
+
if (oldValue === void 0) {
|
|
940
|
+
oldValue = getDefaultValue();
|
|
941
|
+
}
|
|
942
|
+
descriptor.set?.call(this, newValue);
|
|
943
|
+
this.requestUpdate?.(key, newValue, oldValue, declaration);
|
|
944
|
+
},
|
|
945
|
+
configurable: true,
|
|
946
|
+
enumerable: true
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
function property(options) {
|
|
950
|
+
return function(proto, name) {
|
|
951
|
+
defineProperty(proto.constructor, name, options);
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
|
|
812
955
|
function getDefaultInnerShadow() {
|
|
813
956
|
return {
|
|
814
957
|
color: defaultColor,
|
|
@@ -1257,8 +1400,11 @@ function normalizeDocument(doc) {
|
|
|
1257
1400
|
return normalizeElement(doc);
|
|
1258
1401
|
}
|
|
1259
1402
|
|
|
1403
|
+
exports.RawWeakMap = RawWeakMap;
|
|
1260
1404
|
exports.clearUndef = clearUndef;
|
|
1261
1405
|
exports.defaultColor = defaultColor;
|
|
1406
|
+
exports.defineProperty = defineProperty;
|
|
1407
|
+
exports.getDeclarations = getDeclarations;
|
|
1262
1408
|
exports.getDefaultElementStyle = getDefaultElementStyle;
|
|
1263
1409
|
exports.getDefaultHighlightStyle = getDefaultHighlightStyle;
|
|
1264
1410
|
exports.getDefaultInnerShadow = getDefaultInnerShadow;
|
|
@@ -1271,6 +1417,8 @@ exports.getDefaultTextInlineStyle = getDefaultTextInlineStyle;
|
|
|
1271
1417
|
exports.getDefaultTextLineStyle = getDefaultTextLineStyle;
|
|
1272
1418
|
exports.getDefaultTextStyle = getDefaultTextStyle;
|
|
1273
1419
|
exports.getDefaultTransformStyle = getDefaultTransformStyle;
|
|
1420
|
+
exports.getNestedValue = getNestedValue;
|
|
1421
|
+
exports.getObjectValueByPath = getObjectValueByPath;
|
|
1274
1422
|
exports.hasCRLF = hasCRLF;
|
|
1275
1423
|
exports.isCRLF = isCRLF;
|
|
1276
1424
|
exports.isColor = isColor;
|
|
@@ -1312,6 +1460,9 @@ exports.normalizeVideo = normalizeVideo;
|
|
|
1312
1460
|
exports.parseColor = parseColor;
|
|
1313
1461
|
exports.parseGradient = parseGradient;
|
|
1314
1462
|
exports.pick = pick;
|
|
1463
|
+
exports.property = property;
|
|
1315
1464
|
exports.round = round;
|
|
1465
|
+
exports.setNestedValue = setNestedValue;
|
|
1466
|
+
exports.setObjectValueByPath = setObjectValueByPath;
|
|
1316
1467
|
exports.stringifyGradient = stringifyGradient;
|
|
1317
1468
|
exports.textContentToString = textContentToString;
|
package/dist/index.d.cts
CHANGED
|
@@ -315,6 +315,18 @@ type BackgroundObject = FillObject & Partial<NormalizedBaseBackground>;
|
|
|
315
315
|
type Background = string | BackgroundObject;
|
|
316
316
|
declare function normalizeBackground(background: Background): NormalizedBackground;
|
|
317
317
|
|
|
318
|
+
interface Definable {
|
|
319
|
+
requestUpdate?: (key: PropertyKey, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
|
|
320
|
+
}
|
|
321
|
+
interface PropertyDeclaration {
|
|
322
|
+
readonly [key: string]: any;
|
|
323
|
+
readonly default?: any | (() => any);
|
|
324
|
+
readonly alias?: string | symbol;
|
|
325
|
+
}
|
|
326
|
+
declare function getDeclarations(constructor: any): Map<PropertyKey, PropertyDeclaration>;
|
|
327
|
+
declare function defineProperty(constructor: any, key: PropertyKey, declaration?: PropertyDeclaration): void;
|
|
328
|
+
declare function property(options?: PropertyDeclaration): PropertyDecorator;
|
|
329
|
+
|
|
318
330
|
interface NormalizedInnerShadow {
|
|
319
331
|
color: NormalizedColor;
|
|
320
332
|
offsetX: number;
|
|
@@ -735,5 +747,33 @@ declare function round(number: number, digits?: number, base?: number): number;
|
|
|
735
747
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
736
748
|
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
737
749
|
|
|
738
|
-
|
|
739
|
-
|
|
750
|
+
declare function getNestedValue(obj: any, path: (string | number)[], fallback?: any): any;
|
|
751
|
+
declare function setNestedValue(obj: any, path: (string | number)[], value: any): void;
|
|
752
|
+
declare function getObjectValueByPath(obj: any, path: string, fallback?: any): any;
|
|
753
|
+
declare function setObjectValueByPath(obj: any, path: string, value: any): void;
|
|
754
|
+
|
|
755
|
+
declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
|
|
756
|
+
protected _map: WeakMap<K, V>;
|
|
757
|
+
protected _toRaw(value: any): any;
|
|
758
|
+
/**
|
|
759
|
+
* Removes the specified element from the WeakMap.
|
|
760
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
761
|
+
*/
|
|
762
|
+
delete(key: K): boolean;
|
|
763
|
+
/**
|
|
764
|
+
* @returns a specified element.
|
|
765
|
+
*/
|
|
766
|
+
get(key: K): V | undefined;
|
|
767
|
+
/**
|
|
768
|
+
* @returns a boolean indicating whether an element with the specified key exists or not.
|
|
769
|
+
*/
|
|
770
|
+
has(key: K): boolean;
|
|
771
|
+
/**
|
|
772
|
+
* Adds a new element with a specified key and value.
|
|
773
|
+
* @param key Must be an object or symbol.
|
|
774
|
+
*/
|
|
775
|
+
set(key: K, value: V): this;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
|
|
779
|
+
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Definable, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, ExtentKeywordNode, Fill, FillObject, FillRule, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphObject, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
package/dist/index.d.mts
CHANGED
|
@@ -315,6 +315,18 @@ type BackgroundObject = FillObject & Partial<NormalizedBaseBackground>;
|
|
|
315
315
|
type Background = string | BackgroundObject;
|
|
316
316
|
declare function normalizeBackground(background: Background): NormalizedBackground;
|
|
317
317
|
|
|
318
|
+
interface Definable {
|
|
319
|
+
requestUpdate?: (key: PropertyKey, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
|
|
320
|
+
}
|
|
321
|
+
interface PropertyDeclaration {
|
|
322
|
+
readonly [key: string]: any;
|
|
323
|
+
readonly default?: any | (() => any);
|
|
324
|
+
readonly alias?: string | symbol;
|
|
325
|
+
}
|
|
326
|
+
declare function getDeclarations(constructor: any): Map<PropertyKey, PropertyDeclaration>;
|
|
327
|
+
declare function defineProperty(constructor: any, key: PropertyKey, declaration?: PropertyDeclaration): void;
|
|
328
|
+
declare function property(options?: PropertyDeclaration): PropertyDecorator;
|
|
329
|
+
|
|
318
330
|
interface NormalizedInnerShadow {
|
|
319
331
|
color: NormalizedColor;
|
|
320
332
|
offsetX: number;
|
|
@@ -735,5 +747,33 @@ declare function round(number: number, digits?: number, base?: number): number;
|
|
|
735
747
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
736
748
|
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
737
749
|
|
|
738
|
-
|
|
739
|
-
|
|
750
|
+
declare function getNestedValue(obj: any, path: (string | number)[], fallback?: any): any;
|
|
751
|
+
declare function setNestedValue(obj: any, path: (string | number)[], value: any): void;
|
|
752
|
+
declare function getObjectValueByPath(obj: any, path: string, fallback?: any): any;
|
|
753
|
+
declare function setObjectValueByPath(obj: any, path: string, value: any): void;
|
|
754
|
+
|
|
755
|
+
declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
|
|
756
|
+
protected _map: WeakMap<K, V>;
|
|
757
|
+
protected _toRaw(value: any): any;
|
|
758
|
+
/**
|
|
759
|
+
* Removes the specified element from the WeakMap.
|
|
760
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
761
|
+
*/
|
|
762
|
+
delete(key: K): boolean;
|
|
763
|
+
/**
|
|
764
|
+
* @returns a specified element.
|
|
765
|
+
*/
|
|
766
|
+
get(key: K): V | undefined;
|
|
767
|
+
/**
|
|
768
|
+
* @returns a boolean indicating whether an element with the specified key exists or not.
|
|
769
|
+
*/
|
|
770
|
+
has(key: K): boolean;
|
|
771
|
+
/**
|
|
772
|
+
* Adds a new element with a specified key and value.
|
|
773
|
+
* @param key Must be an object or symbol.
|
|
774
|
+
*/
|
|
775
|
+
set(key: K, value: V): this;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
|
|
779
|
+
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Definable, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, ExtentKeywordNode, Fill, FillObject, FillRule, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphObject, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
package/dist/index.d.ts
CHANGED
|
@@ -315,6 +315,18 @@ type BackgroundObject = FillObject & Partial<NormalizedBaseBackground>;
|
|
|
315
315
|
type Background = string | BackgroundObject;
|
|
316
316
|
declare function normalizeBackground(background: Background): NormalizedBackground;
|
|
317
317
|
|
|
318
|
+
interface Definable {
|
|
319
|
+
requestUpdate?: (key: PropertyKey, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
|
|
320
|
+
}
|
|
321
|
+
interface PropertyDeclaration {
|
|
322
|
+
readonly [key: string]: any;
|
|
323
|
+
readonly default?: any | (() => any);
|
|
324
|
+
readonly alias?: string | symbol;
|
|
325
|
+
}
|
|
326
|
+
declare function getDeclarations(constructor: any): Map<PropertyKey, PropertyDeclaration>;
|
|
327
|
+
declare function defineProperty(constructor: any, key: PropertyKey, declaration?: PropertyDeclaration): void;
|
|
328
|
+
declare function property(options?: PropertyDeclaration): PropertyDecorator;
|
|
329
|
+
|
|
318
330
|
interface NormalizedInnerShadow {
|
|
319
331
|
color: NormalizedColor;
|
|
320
332
|
offsetX: number;
|
|
@@ -735,5 +747,33 @@ declare function round(number: number, digits?: number, base?: number): number;
|
|
|
735
747
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
736
748
|
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
737
749
|
|
|
738
|
-
|
|
739
|
-
|
|
750
|
+
declare function getNestedValue(obj: any, path: (string | number)[], fallback?: any): any;
|
|
751
|
+
declare function setNestedValue(obj: any, path: (string | number)[], value: any): void;
|
|
752
|
+
declare function getObjectValueByPath(obj: any, path: string, fallback?: any): any;
|
|
753
|
+
declare function setObjectValueByPath(obj: any, path: string, value: any): void;
|
|
754
|
+
|
|
755
|
+
declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
|
|
756
|
+
protected _map: WeakMap<K, V>;
|
|
757
|
+
protected _toRaw(value: any): any;
|
|
758
|
+
/**
|
|
759
|
+
* Removes the specified element from the WeakMap.
|
|
760
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
761
|
+
*/
|
|
762
|
+
delete(key: K): boolean;
|
|
763
|
+
/**
|
|
764
|
+
* @returns a specified element.
|
|
765
|
+
*/
|
|
766
|
+
get(key: K): V | undefined;
|
|
767
|
+
/**
|
|
768
|
+
* @returns a boolean indicating whether an element with the specified key exists or not.
|
|
769
|
+
*/
|
|
770
|
+
has(key: K): boolean;
|
|
771
|
+
/**
|
|
772
|
+
* Adds a new element with a specified key and value.
|
|
773
|
+
* @param key Must be an object or symbol.
|
|
774
|
+
*/
|
|
775
|
+
set(key: K, value: V): this;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
|
|
779
|
+
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Definable, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, ExtentKeywordNode, Fill, FillObject, FillRule, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphObject, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(o,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(o=typeof globalThis<"u"?globalThis:o||self,E(o.modernIdoc={}))})(this,function(o){"use strict";function E(t){return typeof t=="string"?{src:t}:t}var nn={grad:.9,turn:360,rad:360/(2*Math.PI)},w=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},h=function(t,n,e){return n===void 0&&(n=0),e===void 0&&(e=Math.pow(10,n)),Math.round(e*t)/e+0},S=function(t,n,e){return n===void 0&&(n=0),e===void 0&&(e=1),t>e?e:t>n?t:n},it=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},ot=function(t){return{r:S(t.r,0,255),g:S(t.g,0,255),b:S(t.b,0,255),a:S(t.a)}},B=function(t){return{r:h(t.r),g:h(t.g),b:h(t.b),a:h(t.a,3)}},en=/^#([0-9a-f]{3,8})$/i,T=function(t){var n=t.toString(16);return n.length<2?"0"+n:n},at=function(t){var n=t.r,e=t.g,r=t.b,i=t.a,c=Math.max(n,e,r),u=c-Math.min(n,e,r),l=u?c===n?(e-r)/u:c===e?2+(r-n)/u:4+(n-e)/u:0;return{h:60*(l<0?l+6:l),s:c?u/c*100:0,v:c/255*100,a:i}},ut=function(t){var n=t.h,e=t.s,r=t.v,i=t.a;n=n/360*6,e/=100,r/=100;var c=Math.floor(n),u=r*(1-e),l=r*(1-(n-c)*e),p=r*(1-(1-n+c)*e),b=c%6;return{r:255*[r,l,u,u,p,r][b],g:255*[p,r,r,l,u,u][b],b:255*[u,u,p,r,r,l][b],a:i}},lt=function(t){return{h:it(t.h),s:S(t.s,0,100),l:S(t.l,0,100),a:S(t.a)}},st=function(t){return{h:h(t.h),s:h(t.s),l:h(t.l),a:h(t.a,3)}},ct=function(t){return ut((e=(n=t).s,{h:n.h,s:(e*=((r=n.l)<50?r:100-r)/100)>0?2*e/(r+e)*100:0,v:r+e,a:n.a}));var n,e,r},G=function(t){return{h:(n=at(t)).h,s:(i=(200-(e=n.s))*(r=n.v)/100)>0&&i<200?e*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:n.a};var n,e,r,i},rn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,on=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,un=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ft={string:[[function(t){var n=en.exec(t);return n?(t=n[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?h(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?h(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var n=an.exec(t)||un.exec(t);return n?n[2]!==n[4]||n[4]!==n[6]?null:ot({r:Number(n[1])/(n[2]?100/255:1),g:Number(n[3])/(n[4]?100/255:1),b:Number(n[5])/(n[6]?100/255:1),a:n[7]===void 0?1:Number(n[7])/(n[8]?100:1)}):null},"rgb"],[function(t){var n=rn.exec(t)||on.exec(t);if(!n)return null;var e,r,i=lt({h:(e=n[1],r=n[2],r===void 0&&(r="deg"),Number(e)*(nn[r]||1)),s:Number(n[3]),l:Number(n[4]),a:n[5]===void 0?1:Number(n[5])/(n[6]?100:1)});return ct(i)},"hsl"]],object:[[function(t){var n=t.r,e=t.g,r=t.b,i=t.a,c=i===void 0?1:i;return w(n)&&w(e)&&w(r)?ot({r:Number(n),g:Number(e),b:Number(r),a:Number(c)}):null},"rgb"],[function(t){var n=t.h,e=t.s,r=t.l,i=t.a,c=i===void 0?1:i;if(!w(n)||!w(e)||!w(r))return null;var u=lt({h:Number(n),s:Number(e),l:Number(r),a:Number(c)});return ct(u)},"hsl"],[function(t){var n=t.h,e=t.s,r=t.v,i=t.a,c=i===void 0?1:i;if(!w(n)||!w(e)||!w(r))return null;var u=function(l){return{h:it(l.h),s:S(l.s,0,100),v:S(l.v,0,100),a:S(l.a)}}({h:Number(n),s:Number(e),v:Number(r),a:Number(c)});return ut(u)},"hsv"]]},dt=function(t,n){for(var e=0;e<n.length;e++){var r=n[e][0](t);if(r)return[r,n[e][1]]}return[null,void 0]},ln=function(t){return typeof t=="string"?dt(t.trim(),ft.string):typeof t=="object"&&t!==null?dt(t,ft.object):[null,void 0]},K=function(t,n){var e=G(t);return{h:e.h,s:S(e.s+100*n,0,100),l:e.l,a:e.a}},X=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},gt=function(t,n){var e=G(t);return{h:e.h,s:e.s,l:S(e.l+100*n,0,100),a:e.a}},ht=function(){function t(n){this.parsed=ln(n)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return h(X(this.rgba),2)},t.prototype.isDark=function(){return X(this.rgba)<.5},t.prototype.isLight=function(){return X(this.rgba)>=.5},t.prototype.toHex=function(){return n=B(this.rgba),e=n.r,r=n.g,i=n.b,u=(c=n.a)<1?T(h(255*c)):"","#"+T(e)+T(r)+T(i)+u;var n,e,r,i,c,u},t.prototype.toRgb=function(){return B(this.rgba)},t.prototype.toRgbString=function(){return n=B(this.rgba),e=n.r,r=n.g,i=n.b,(c=n.a)<1?"rgba("+e+", "+r+", "+i+", "+c+")":"rgb("+e+", "+r+", "+i+")";var n,e,r,i,c},t.prototype.toHsl=function(){return st(G(this.rgba))},t.prototype.toHslString=function(){return n=st(G(this.rgba)),e=n.h,r=n.s,i=n.l,(c=n.a)<1?"hsla("+e+", "+r+"%, "+i+"%, "+c+")":"hsl("+e+", "+r+"%, "+i+"%)";var n,e,r,i,c},t.prototype.toHsv=function(){return n=at(this.rgba),{h:h(n.h),s:h(n.s),v:h(n.v),a:h(n.a,3)};var n},t.prototype.invert=function(){return C({r:255-(n=this.rgba).r,g:255-n.g,b:255-n.b,a:n.a});var n},t.prototype.saturate=function(n){return n===void 0&&(n=.1),C(K(this.rgba,n))},t.prototype.desaturate=function(n){return n===void 0&&(n=.1),C(K(this.rgba,-n))},t.prototype.grayscale=function(){return C(K(this.rgba,-1))},t.prototype.lighten=function(n){return n===void 0&&(n=.1),C(gt(this.rgba,n))},t.prototype.darken=function(n){return n===void 0&&(n=.1),C(gt(this.rgba,-n))},t.prototype.rotate=function(n){return n===void 0&&(n=15),this.hue(this.hue()+n)},t.prototype.alpha=function(n){return typeof n=="number"?C({r:(e=this.rgba).r,g:e.g,b:e.b,a:n}):h(this.rgba.a,3);var e},t.prototype.hue=function(n){var e=G(this.rgba);return typeof n=="number"?C({h:n,s:e.s,l:e.l,a:e.a}):h(e.h)},t.prototype.isEqual=function(n){return this.toHex()===C(n).toHex()},t}(),C=function(t){return t instanceof ht?t:new ht(t)};function d(t){return t==null||t==="none"}function F(t,n=0,e=10**n){return Math.round(e*t)/e+0}function k(t,n=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return n?t.map(r=>k(r,n)):t;const e={};for(const r in t){const i=t[r];i!=null&&(n?e[r]=k(i,n):e[r]=i)}return e}function V(t,n){const e={};return n.forEach(r=>{r in t&&(e[r]=t[r])}),e}function Y(t){let n;return typeof t=="number"?n={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:n=t,C(n)}function sn(t){return{r:F(t.r),g:F(t.g),b:F(t.b),a:F(t.a,3)}}function x(t){const n=t.toString(16);return n.length<2?`0${n}`:n}const I="#000000FF";function vt(t){return Y(t).isValid()}function m(t,n=!1){const e=Y(t);if(!e.isValid()){if(typeof t=="string")return t;const l=`Failed to normalizeColor ${t}`;if(n)throw new Error(l);return console.warn(l),I}const{r,g:i,b:c,a:u}=sn(e.rgba);return`#${x(r)}${x(i)}${x(c)}${x(F(u*255))}`}var $=$||{};$.parse=function(){const t={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let n="";function e(a){const s=new Error(`${n}: ${a}`);throw s.source=n,s}function r(){const a=i();return n.length>0&&e("Invalid input not EOF"),a}function i(){return H(c)}function c(){return u("linear-gradient",t.linearGradient,p)||u("repeating-linear-gradient",t.repeatingLinearGradient,p)||u("radial-gradient",t.radialGradient,D)||u("repeating-radial-gradient",t.repeatingRadialGradient,D)}function u(a,s,f){return l(s,v=>{const N=f();return N&&(g(t.comma)||e("Missing comma before color stops")),{type:a,orientation:N,colorStops:H(Cn)}})}function l(a,s){const f=g(a);if(f){g(t.startCall)||e("Missing (");const v=s(f);return g(t.endCall)||e("Missing )"),v}}function p(){const a=b();if(a)return a;const s=y("position-keyword",t.positionKeywords,1);return s?{type:"directional",value:s.value}:z()}function b(){return y("directional",t.sideOrCorner,1)}function z(){return y("angular",t.angleValue,1)||y("angular",t.radianValue,1)}function D(){let a,s=P(),f;return s&&(a=[],a.push(s),f=n,g(t.comma)&&(s=P(),s?a.push(s):n=f)),a}function P(){let a=bn()||yn();if(a)a.at=nt();else{const s=tt();if(s){a=s;const f=nt();f&&(a.at=f)}else{const f=nt();if(f)a={type:"default-radial",at:f};else{const v=et();v&&(a={type:"default-radial",at:v})}}}return a}function bn(){const a=y("shape",/^(circle)/i,0);return a&&(a.style=tn()||tt()),a}function yn(){const a=y("shape",/^(ellipse)/i,0);return a&&(a.style=et()||W()||tt()),a}function tt(){return y("extent-keyword",t.extentKeywords,1)}function nt(){if(y("position",/^at/,0)){const a=et();return a||e("Missing positioning value"),a}}function et(){const a=Sn();if(a.x||a.y)return{type:"position",value:a}}function Sn(){return{x:W(),y:W()}}function H(a){let s=a();const f=[];if(s)for(f.push(s);g(t.comma);)s=a(),s?f.push(s):e("One extra comma");return f}function Cn(){const a=wn();return a||e("Expected color definition"),a.length=W(),a}function wn(){return _n()||Ln()||En()||kn()||Fn()||Nn()||zn()}function zn(){return y("literal",t.literalColor,0)}function _n(){return y("hex",t.hexColor,1)}function Fn(){return l(t.rgbColor,()=>({type:"rgb",value:H(A)}))}function kn(){return l(t.rgbaColor,()=>({type:"rgba",value:H(A)}))}function Nn(){return l(t.varColor,()=>({type:"var",value:Dn()}))}function En(){return l(t.hslColor,()=>{g(t.percentageValue)&&e("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const s=A();g(t.comma);let f=g(t.percentageValue);const v=f?f[1]:null;g(t.comma),f=g(t.percentageValue);const N=f?f[1]:null;return(!v||!N)&&e("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[s,v,N]}})}function Ln(){return l(t.hslaColor,()=>{const a=A();g(t.comma);let s=g(t.percentageValue);const f=s?s[1]:null;g(t.comma),s=g(t.percentageValue);const v=s?s[1]:null;g(t.comma);const N=A();return(!f||!v)&&e("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[a,f,v,N]}})}function Dn(){return g(t.variableName)[1]}function A(){return g(t.number)[1]}function W(){return y("%",t.percentageValue,1)||Gn()||In()||tn()}function Gn(){return y("position-keyword",t.positionKeywords,1)}function In(){return l(t.calcValue,()=>{let a=1,s=0;for(;a>0&&s<n.length;){const v=n.charAt(s);v==="("?a++:v===")"&&a--,s++}a>0&&e("Missing closing parenthesis in calc() expression");const f=n.substring(0,s-1);return rt(s-1),{type:"calc",value:f}})}function tn(){return y("px",t.pixelValue,1)||y("em",t.emValue,1)}function y(a,s,f){const v=g(s);if(v)return{type:a,value:v[f]}}function g(a){let s,f;return f=/^\s+/.exec(n),f&&rt(f[0].length),s=a.exec(n),s&&rt(s[0].length),s}function rt(a){n=n.substr(a)}return function(a){return n=a.toString().trim(),n.endsWith(";")&&(n=n.slice(0,-1)),r()}}();const mt=$.parse.bind($);var j=j||{};j.stringify=function(){var t={"visit_linear-gradient":function(n){return t.visit_gradient(n)},"visit_repeating-linear-gradient":function(n){return t.visit_gradient(n)},"visit_radial-gradient":function(n){return t.visit_gradient(n)},"visit_repeating-radial-gradient":function(n){return t.visit_gradient(n)},visit_gradient:function(n){var e=t.visit(n.orientation);return e&&(e+=", "),n.type+"("+e+t.visit(n.colorStops)+")"},visit_shape:function(n){var e=n.value,r=t.visit(n.at),i=t.visit(n.style);return i&&(e+=" "+i),r&&(e+=" at "+r),e},"visit_default-radial":function(n){var e="",r=t.visit(n.at);return r&&(e+=r),e},"visit_extent-keyword":function(n){var e=n.value,r=t.visit(n.at);return r&&(e+=" at "+r),e},"visit_position-keyword":function(n){return n.value},visit_position:function(n){return t.visit(n.value.x)+" "+t.visit(n.value.y)},"visit_%":function(n){return n.value+"%"},visit_em:function(n){return n.value+"em"},visit_px:function(n){return n.value+"px"},visit_calc:function(n){return"calc("+n.value+")"},visit_literal:function(n){return t.visit_color(n.value,n)},visit_hex:function(n){return t.visit_color("#"+n.value,n)},visit_rgb:function(n){return t.visit_color("rgb("+n.value.join(", ")+")",n)},visit_rgba:function(n){return t.visit_color("rgba("+n.value.join(", ")+")",n)},visit_hsl:function(n){return t.visit_color("hsl("+n.value[0]+", "+n.value[1]+"%, "+n.value[2]+"%)",n)},visit_hsla:function(n){return t.visit_color("hsla("+n.value[0]+", "+n.value[1]+"%, "+n.value[2]+"%, "+n.value[3]+")",n)},visit_var:function(n){return t.visit_color("var("+n.value+")",n)},visit_color:function(n,e){var r=n,i=t.visit(e.length);return i&&(r+=" "+i),r},visit_angular:function(n){return n.value+"deg"},visit_directional:function(n){return"to "+n.value},visit_array:function(n){var e="",r=n.length;return n.forEach(function(i,c){e+=t.visit(i),c<r-1&&(e+=", ")}),e},visit_object:function(n){return n.width&&n.height?t.visit(n.width)+" "+t.visit(n.height):""},visit:function(n){if(!n)return"";if(n instanceof Array)return t.visit_array(n);if(typeof n=="object"&&!n.type)return t.visit_object(n);if(n.type){var e=t["visit_"+n.type];if(e)return e(n);throw Error("Missing visitor visit_"+n.type)}else throw Error("Invalid node.")}};return function(n){return t.visit(n)}}();const cn=j.stringify.bind(j);function pt(t){const n=t.length-1;return t.map((e,r)=>{var l;const i=e.value;let c=F(r/n,3),u="#00000000";switch(e.type){case"rgb":u=m({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":u=m({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":u=m(e.value);break;case"hex":u=m(`#${e.value}`);break}switch((l=e.length)==null?void 0:l.type){case"%":c=Number(e.length.value)/100;break}return{offset:c,color:u}})}function bt(t){var e;let n=0;switch((e=t.orientation)==null?void 0:e.type){case"angular":n=Number(t.orientation.value);break}return{type:"linear-gradient",angle:n,stops:pt(t.colorStops)}}function yt(t){var n;return(n=t.orientation)==null||n.map(e=>{switch(e==null?void 0:e.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:pt(t.colorStops)}}function O(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function St(t){return mt(t).map(n=>{switch(n==null?void 0:n.type){case"linear-gradient":return bt(n);case"repeating-linear-gradient":return{...bt(n),repeat:!0};case"radial-gradient":return yt(n);case"repeating-radial-gradient":return{...yt(n),repeat:!0};default:return}}).filter(Boolean)}function Ct(t){let n;return typeof t=="string"?n={color:t}:n=t,{color:m(n.color)}}function wt(t){let n;if(typeof t=="string"?n={image:t}:n=t,n.image){const{type:e,...r}=St(n.image)[0]??{};switch(e){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return n}function zt(t){let n;return typeof t=="string"?n={image:t}:n=t,n}function _t(t){let n;return typeof t=="string"?n={preset:t}:n=t,{preset:n.preset,foregroundColor:d(n.foregroundColor)?void 0:m(n.foregroundColor),backgroundColor:d(n.backgroundColor)?void 0:m(n.backgroundColor)}}function Ft(t){return!d(t.color)}function kt(t){return typeof t=="string"?vt(t):Ft(t)}function Nt(t){return!d(t.image)&&O(t.image)||!!t.linearGradient||!!t.radialGradient}function Et(t){return typeof t=="string"?O(t):Nt(t)}function Lt(t){return!d(t.image)&&!O(t.image)}function Dt(t){return typeof t=="string"?!O(t):Lt(t)}function Gt(t){return!d(t.preset)}function It(t){return typeof t=="string"?!1:Gt(t)}function _(t){return kt(t)?Ct(t):Et(t)?wt(t):Dt(t)?zt(t):It(t)?_t(t):{}}function Ot(t){return typeof t=="string"?{..._(t)}:{..._(t),...V(t,["fillWithShape"])}}function q(){return{color:I,offsetX:0,offsetY:0,blurRadius:1}}function U(t){return{...q(),...k({...t,color:d(t.color)?I:m(t.color)})}}function Rt(){return{...q(),scaleX:1,scaleY:1}}function At(t){return{...Rt(),...U(t)}}function fn(t){return t}function Tt(t){return k({...t,softEdge:d(t.softEdge)?void 0:t.softEdge,outerShadow:d(t.outerShadow)?void 0:At(t.outerShadow),innerShadow:d(t.innerShadow)?void 0:U(t.innerShadow)})}function Vt(t){return typeof t=="string"?{..._(t)}:{..._(t),...V(t,["fillWithShape"])}}function xt(t){return typeof t=="string"?{..._(t)}:{..._(t),...V(t,["width","style","headEnd","tailEnd"])}}function $t(t){return typeof t=="string"?{color:m(t)}:{...t,color:d(t.color)?I:m(t.color)}}function jt(){return{boxShadow:"none"}}function Mt(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(n=>typeof n=="string"?{data:n}:n)}:t}function Pt(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function Ht(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Wt(){return{...Pt(),...Ht(),...jt(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function Bt(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function Kt(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function Xt(){return{...Bt(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function Yt(){return{...Kt(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function qt(){return{...Yt(),...Xt(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function L(t){return k({...t,color:d(t.color)?void 0:m(t.color),backgroundColor:d(t.backgroundColor)?void 0:m(t.backgroundColor),borderColor:d(t.borderColor)?void 0:m(t.borderColor),outlineColor:d(t.outlineColor)?void 0:m(t.outlineColor),shadowColor:d(t.shadowColor)?void 0:m(t.shadowColor)})}function dn(){return{...Wt(),...qt()}}const Z=/\r\n|\n\r|\n|\r/,gn=new RegExp(`${Z.source}|<br\\/>`,"g"),hn=new RegExp(`^(${Z.source})$`),M=`
|
|
2
|
-
`;function
|
|
1
|
+
(function(o,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(o=typeof globalThis<"u"?globalThis:o||self,y(o.modernIdoc={}))})(this,function(o){"use strict";var We=Object.defineProperty;var Be=(o,y,E)=>y in o?We(o,y,{enumerable:!0,configurable:!0,writable:!0,value:E}):o[y]=E;var ce=(o,y,E)=>Be(o,typeof y!="symbol"?y+"":y,E);function y(t){return typeof t=="string"?{src:t}:t}var E={grad:.9,turn:360,rad:360/(2*Math.PI)},_=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},m=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},C=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},at=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},ut=function(t){return{r:C(t.r,0,255),g:C(t.g,0,255),b:C(t.b,0,255),a:C(t.a)}},K=function(t){return{r:m(t.r),g:m(t.g),b:m(t.b),a:m(t.a,3)}},fe=/^#([0-9a-f]{3,8})$/i,A=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},lt=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,c=Math.max(e,n,r),l=c-Math.min(e,n,r),u=l?c===e?(n-r)/l:c===n?2+(r-e)/l:4+(e-n)/l:0;return{h:60*(u<0?u+6:u),s:c?l/c*100:0,v:c/255*100,a:i}},st=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var c=Math.floor(e),l=r*(1-n),u=r*(1-(e-c)*n),g=r*(1-(1-e+c)*n),h=c%6;return{r:255*[r,u,l,l,g,r][h],g:255*[g,r,r,u,l,l][h],b:255*[l,l,g,r,r,u][h],a:i}},ct=function(t){return{h:at(t.h),s:C(t.s,0,100),l:C(t.l,0,100),a:C(t.a)}},ft=function(t){return{h:m(t.h),s:m(t.s),l:m(t.l),a:m(t.a,3)}},dt=function(t){return st((n=(e=t).s,{h:e.h,s:(n*=((r=e.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:e.a}));var e,n,r},L=function(t){return{h:(e=lt(t)).h,s:(i=(200-(n=e.s))*(r=e.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,r,i},de=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ge=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,he=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ve=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gt={string:[[function(t){var e=fe.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?m(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?m(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=he.exec(t)||ve.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:ut({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=de.exec(t)||ge.exec(t);if(!e)return null;var n,r,i=ct({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(E[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return dt(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,c=i===void 0?1:i;return _(e)&&_(n)&&_(r)?ut({r:Number(e),g:Number(n),b:Number(r),a:Number(c)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,c=i===void 0?1:i;if(!_(e)||!_(n)||!_(r))return null;var l=ct({h:Number(e),s:Number(n),l:Number(r),a:Number(c)});return dt(l)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,c=i===void 0?1:i;if(!_(e)||!_(n)||!_(r))return null;var l=function(u){return{h:at(u.h),s:C(u.s,0,100),v:C(u.v,0,100),a:C(u.a)}}({h:Number(e),s:Number(n),v:Number(r),a:Number(c)});return st(l)},"hsv"]]},ht=function(t,e){for(var n=0;n<e.length;n++){var r=e[n][0](t);if(r)return[r,e[n][1]]}return[null,void 0]},me=function(t){return typeof t=="string"?ht(t.trim(),gt.string):typeof t=="object"&&t!==null?ht(t,gt.object):[null,void 0]},X=function(t,e){var n=L(t);return{h:n.h,s:C(n.s+100*e,0,100),l:n.l,a:n.a}},Y=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},vt=function(t,e){var n=L(t);return{h:n.h,s:n.s,l:C(n.l+100*e,0,100),a:n.a}},mt=function(){function t(e){this.parsed=me(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return m(Y(this.rgba),2)},t.prototype.isDark=function(){return Y(this.rgba)<.5},t.prototype.isLight=function(){return Y(this.rgba)>=.5},t.prototype.toHex=function(){return e=K(this.rgba),n=e.r,r=e.g,i=e.b,l=(c=e.a)<1?A(m(255*c)):"","#"+A(n)+A(r)+A(i)+l;var e,n,r,i,c,l},t.prototype.toRgb=function(){return K(this.rgba)},t.prototype.toRgbString=function(){return e=K(this.rgba),n=e.r,r=e.g,i=e.b,(c=e.a)<1?"rgba("+n+", "+r+", "+i+", "+c+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,c},t.prototype.toHsl=function(){return ft(L(this.rgba))},t.prototype.toHslString=function(){return e=ft(L(this.rgba)),n=e.h,r=e.s,i=e.l,(c=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+c+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,c},t.prototype.toHsv=function(){return e=lt(this.rgba),{h:m(e.h),s:m(e.s),v:m(e.v),a:m(e.a,3)};var e},t.prototype.invert=function(){return z({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),z(X(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),z(X(this.rgba,-e))},t.prototype.grayscale=function(){return z(X(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),z(vt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),z(vt(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?z({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):m(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=L(this.rgba);return typeof e=="number"?z({h:e,s:n.s,l:n.l,a:n.a}):m(n.h)},t.prototype.isEqual=function(e){return this.toHex()===z(e).toHex()},t}(),z=function(t){return t instanceof mt?t:new mt(t)};function d(t){return t==null||t==="none"}function O(t,e=0,n=10**e){return Math.round(n*t)/n+0}function R(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>R(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=R(i,e):n[r]=i)}return n}function M(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function pt(t,e,n){const r=e.length-1;if(r<0)return t===void 0?n:t;for(let i=0;i<r;i++){if(t==null)return n;t=t[e[i]]}return t==null||t[e[r]]===void 0?n:t[e[r]]}function bt(t,e,n){const r=e.length-1;for(let i=0;i<r;i++)typeof t[e[i]]!="object"&&(t[e[i]]={}),t=t[e[i]];t[e[r]]=n}function yt(t,e,n){return t==null||!e||typeof e!="string"?n:t[e]!==void 0?t[e]:(e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),pt(t,e.split("."),n))}function St(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),bt(t,e.split("."),n)}class Ct{constructor(){ce(this,"_map",new WeakMap)}_toRaw(e){if(e&&typeof e=="object"){const n=e.__v_raw;n&&(e=this._toRaw(n))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,n){return this._map.set(this._toRaw(e),this._toRaw(n)),this}}function q(t){let e;return typeof t=="number"?e={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:e=t,z(e)}function pe(t){return{r:O(t.r),g:O(t.g),b:O(t.b),a:O(t.a,3)}}function T(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const G="#000000FF";function wt(t){return q(t).isValid()}function b(t,e=!1){const n=q(t);if(!n.isValid()){if(typeof t=="string")return t;const u=`Failed to normalizeColor ${t}`;if(e)throw new Error(u);return console.warn(u),G}const{r,g:i,b:c,a:l}=pe(n.rgba);return`#${T(r)}${T(i)}${T(c)}${T(O(l*255))}`}var $=$||{};$.parse=function(){const t={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let e="";function n(a){const s=new Error(`${e}: ${a}`);throw s.source=e,s}function r(){const a=i();return e.length>0&&n("Invalid input not EOF"),a}function i(){return j(c)}function c(){return l("linear-gradient",t.linearGradient,g)||l("repeating-linear-gradient",t.repeatingLinearGradient,g)||l("radial-gradient",t.radialGradient,F)||l("repeating-radial-gradient",t.repeatingRadialGradient,F)}function l(a,s,f){return u(s,p=>{const k=f();return k&&(v(t.comma)||n("Missing comma before color stops")),{type:a,orientation:k,colorStops:j(Ee)}})}function u(a,s){const f=v(a);if(f){v(t.startCall)||n("Missing (");const p=s(f);return v(t.endCall)||n("Missing )"),p}}function g(){const a=h();if(a)return a;const s=S("position-keyword",t.positionKeywords,1);return s?{type:"directional",value:s.value}:w()}function h(){return S("directional",t.sideOrCorner,1)}function w(){return S("angular",t.angleValue,1)||S("angular",t.radianValue,1)}function F(){let a,s=B(),f;return s&&(a=[],a.push(s),f=e,v(t.comma)&&(s=B(),s?a.push(s):e=f)),a}function B(){let a=Oe()||Re();if(a)a.at=rt();else{const s=nt();if(s){a=s;const f=rt();f&&(a.at=f)}else{const f=rt();if(f)a={type:"default-radial",at:f};else{const p=it();p&&(a={type:"default-radial",at:p})}}}return a}function Oe(){const a=S("shape",/^(circle)/i,0);return a&&(a.style=se()||nt()),a}function Re(){const a=S("shape",/^(ellipse)/i,0);return a&&(a.style=it()||x()||nt()),a}function nt(){return S("extent-keyword",t.extentKeywords,1)}function rt(){if(S("position",/^at/,0)){const a=it();return a||n("Missing positioning value"),a}}function it(){const a=ke();if(a.x||a.y)return{type:"position",value:a}}function ke(){return{x:x(),y:x()}}function j(a){let s=a();const f=[];if(s)for(f.push(s);v(t.comma);)s=a(),s?f.push(s):n("One extra comma");return f}function Ee(){const a=De();return a||n("Expected color definition"),a.length=x(),a}function De(){return Ge()||Me()||Ae()||Ve()||Ie()||Pe()||Le()}function Le(){return S("literal",t.literalColor,0)}function Ge(){return S("hex",t.hexColor,1)}function Ie(){return u(t.rgbColor,()=>({type:"rgb",value:j(P)}))}function Ve(){return u(t.rgbaColor,()=>({type:"rgba",value:j(P)}))}function Pe(){return u(t.varColor,()=>({type:"var",value:Te()}))}function Ae(){return u(t.hslColor,()=>{v(t.percentageValue)&&n("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const s=P();v(t.comma);let f=v(t.percentageValue);const p=f?f[1]:null;v(t.comma),f=v(t.percentageValue);const k=f?f[1]:null;return(!p||!k)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[s,p,k]}})}function Me(){return u(t.hslaColor,()=>{const a=P();v(t.comma);let s=v(t.percentageValue);const f=s?s[1]:null;v(t.comma),s=v(t.percentageValue);const p=s?s[1]:null;v(t.comma);const k=P();return(!f||!p)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[a,f,p,k]}})}function Te(){return v(t.variableName)[1]}function P(){return v(t.number)[1]}function x(){return S("%",t.percentageValue,1)||$e()||He()||se()}function $e(){return S("position-keyword",t.positionKeywords,1)}function He(){return u(t.calcValue,()=>{let a=1,s=0;for(;a>0&&s<e.length;){const p=e.charAt(s);p==="("?a++:p===")"&&a--,s++}a>0&&n("Missing closing parenthesis in calc() expression");const f=e.substring(0,s-1);return ot(s-1),{type:"calc",value:f}})}function se(){return S("px",t.pixelValue,1)||S("em",t.emValue,1)}function S(a,s,f){const p=v(s);if(p)return{type:a,value:p[f]}}function v(a){let s,f;return f=/^\s+/.exec(e),f&&ot(f[0].length),s=a.exec(e),s&&ot(s[0].length),s}function ot(a){e=e.substr(a)}return function(a){return e=a.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}}();const zt=$.parse.bind($);var H=H||{};H.stringify=function(){var t={"visit_linear-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return t.visit_gradient(e)},"visit_radial-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return t.visit_gradient(e)},visit_gradient:function(e){var n=t.visit(e.orientation);return n&&(n+=", "),e.type+"("+n+t.visit(e.colorStops)+")"},visit_shape:function(e){var n=e.value,r=t.visit(e.at),i=t.visit(e.style);return i&&(n+=" "+i),r&&(n+=" at "+r),n},"visit_default-radial":function(e){var n="",r=t.visit(e.at);return r&&(n+=r),n},"visit_extent-keyword":function(e){var n=e.value,r=t.visit(e.at);return r&&(n+=" at "+r),n},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return t.visit(e.value.x)+" "+t.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_calc:function(e){return"calc("+e.value+")"},visit_literal:function(e){return t.visit_color(e.value,e)},visit_hex:function(e){return t.visit_color("#"+e.value,e)},visit_rgb:function(e){return t.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return t.visit_color("rgba("+e.value.join(", ")+")",e)},visit_hsl:function(e){return t.visit_color("hsl("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%)",e)},visit_hsla:function(e){return t.visit_color("hsla("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%, "+e.value[3]+")",e)},visit_var:function(e){return t.visit_color("var("+e.value+")",e)},visit_color:function(e,n){var r=e,i=t.visit(n.length);return i&&(r+=" "+i),r},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var n="",r=e.length;return e.forEach(function(i,c){n+=t.visit(i),c<r-1&&(n+=", ")}),n},visit_object:function(e){return e.width&&e.height?t.visit(e.width)+" "+t.visit(e.height):""},visit:function(e){if(!e)return"";if(e instanceof Array)return t.visit_array(e);if(typeof e=="object"&&!e.type)return t.visit_object(e);if(e.type){var n=t["visit_"+e.type];if(n)return n(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return t.visit(e)}}();const be=H.stringify.bind(H);function _t(t){const e=t.length-1;return t.map((n,r)=>{var u;const i=n.value;let c=O(r/e,3),l="#00000000";switch(n.type){case"rgb":l=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":l=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":l=b(n.value);break;case"hex":l=b(`#${n.value}`);break}switch((u=n.length)==null?void 0:u.type){case"%":c=Number(n.length.value)/100;break}return{offset:c,color:l}})}function Ft(t){var n;let e=0;switch((n=t.orientation)==null?void 0:n.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:_t(t.colorStops)}}function Nt(t){var e;return(e=t.orientation)==null||e.map(n=>{switch(n==null?void 0:n.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:_t(t.colorStops)}}function I(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function Ot(t){return zt(t).map(e=>{switch(e==null?void 0:e.type){case"linear-gradient":return Ft(e);case"repeating-linear-gradient":return{...Ft(e),repeat:!0};case"radial-gradient":return Nt(e);case"repeating-radial-gradient":return{...Nt(e),repeat:!0};default:return}}).filter(Boolean)}function Rt(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:b(e.color)}}function kt(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=Ot(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function Et(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function Dt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:d(e.foregroundColor)?void 0:b(e.foregroundColor),backgroundColor:d(e.backgroundColor)?void 0:b(e.backgroundColor)}}function Lt(t){return!d(t.color)}function Gt(t){return typeof t=="string"?wt(t):Lt(t)}function It(t){return!d(t.image)&&I(t.image)||!!t.linearGradient||!!t.radialGradient}function Vt(t){return typeof t=="string"?I(t):It(t)}function Pt(t){return!d(t.image)&&!I(t.image)}function At(t){return typeof t=="string"?!I(t):Pt(t)}function Mt(t){return!d(t.preset)}function Tt(t){return typeof t=="string"?!1:Mt(t)}function N(t){return Gt(t)?Rt(t):Vt(t)?kt(t):At(t)?Et(t):Tt(t)?Dt(t):{}}function $t(t){return typeof t=="string"?{...N(t)}:{...N(t),...M(t,["fillWithShape"])}}const Ht=new Ct;function U(t){let e=Ht.get(t);if(!e){const n=Object.getPrototypeOf(t);e=new Map(n?U(n):void 0),Ht.set(t,e)}return e}function Wt(t,e,n={}){U(t).set(e,n);const{default:r,alias:i=Symbol.for(String(e))}=n,c=()=>typeof r=="function"?r():r,l=Object.getOwnPropertyDescriptor(t.prototype,e)||{get(){return typeof i=="string"?yt(this,i):this[i]},set(u){typeof i=="string"?St(this,i,u):this[i]=u}};Object.defineProperty(t.prototype,e,{get(){var g,h;let u=(g=l.get)==null?void 0:g.call(this);return u===void 0&&(u=c(),u!==void 0&&((h=l.set)==null||h.call(this,u))),u},set(u){var h,w,F;let g=(h=l.get)==null?void 0:h.call(this);g===void 0&&(g=c()),(w=l.set)==null||w.call(this,u),(F=this.requestUpdate)==null||F.call(this,e,u,g,n)},configurable:!0,enumerable:!0})}function ye(t){return function(e,n){Wt(e.constructor,n,t)}}function Z(){return{color:G,offsetX:0,offsetY:0,blurRadius:1}}function J(t){return{...Z(),...R({...t,color:d(t.color)?G:b(t.color)})}}function Bt(){return{...Z(),scaleX:1,scaleY:1}}function jt(t){return{...Bt(),...J(t)}}function Se(t){return t}function xt(t){return R({...t,softEdge:d(t.softEdge)?void 0:t.softEdge,outerShadow:d(t.outerShadow)?void 0:jt(t.outerShadow),innerShadow:d(t.innerShadow)?void 0:J(t.innerShadow)})}function Kt(t){return typeof t=="string"?{...N(t)}:{...N(t),...M(t,["fillWithShape"])}}function Xt(t){return typeof t=="string"?{...N(t)}:{...N(t),...M(t,["width","style","headEnd","tailEnd"])}}function Yt(t){return typeof t=="string"?{color:b(t)}:{...t,color:d(t.color)?G:b(t.color)}}function qt(){return{boxShadow:"none"}}function Ut(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(e=>typeof e=="string"?{data:e}:e)}:t}function Zt(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function Jt(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Qt(){return{...Zt(),...Jt(),...qt(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function te(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function ee(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function ne(){return{...te(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function re(){return{...ee(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function ie(){return{...re(),...ne(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function D(t){return R({...t,color:d(t.color)?void 0:b(t.color),backgroundColor:d(t.backgroundColor)?void 0:b(t.backgroundColor),borderColor:d(t.borderColor)?void 0:b(t.borderColor),outlineColor:d(t.outlineColor)?void 0:b(t.outlineColor),shadowColor:d(t.shadowColor)?void 0:b(t.shadowColor)})}function Ce(){return{...Qt(),...ie()}}const Q=/\r\n|\n\r|\n|\r/,we=new RegExp(`${Q.source}|<br\\/>`,"g"),ze=new RegExp(`^(${Q.source})$`),W=`
|
|
2
|
+
`;function _e(t){return Q.test(t)}function tt(t){return ze.test(t)}function oe(t){return t.replace(we,W)}function ae(t,e){const n=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!n.length||n.every(r=>t[r]===e[r])}function V(t){const e=[];function n(){return e[e.length-1]||r()}function r(l={}){let u=e[e.length-1];return(u==null?void 0:u.fragments.length)===0?(u={...l,fragments:[]},e[e.length-1]=u):(u={...l,fragments:[]},e.push(u)),u}function i(l="",u={}){Array.from(l).forEach(g=>{if(tt(g)){const{fragments:h,...w}=n();h.length||h.push({...u,content:W}),r(w)}else{const h=n(),w=h.fragments[h.fragments.length-1];if(w){const{content:F,...B}=w;if(ae(u,B)){w.content=`${F}${g}`;return}}h.fragments.push({...u,content:g})}})}return(Array.isArray(t)?t:[t]).forEach(l=>{if(typeof l=="string")r(),i(l);else if("content"in l){const{content:u,...g}=l;r(D(g)),i(u)}else if("fragments"in l){const{fragments:u,...g}=l;r(D(g)),u.forEach(h=>{const{content:w,...F}=h;i(w,D(F))})}else Array.isArray(l)?(r(),l.forEach(u=>{if(typeof u=="string")i(u);else{const{content:g,...h}=u;i(g,D(h))}})):console.warn("Failed to parse text content",l)}),n().fragments.length||i(W),e}function ue(t){return typeof t=="string"?{content:V(t)}:"content"in t?{...t,content:V(t.content)}:{content:V(t)}}function Fe(t){return V(t).map(e=>{const n=oe(e.fragments.flatMap(r=>r.content).join(""));return tt(n)?"":n}).join(W)}function le(t){return typeof t=="string"?{src:t}:t}function et(t){var e;return R({...t,style:d(t.style)?void 0:D(t.style),text:d(t.text)?void 0:ue(t.text),background:d(t.background)?void 0:$t(t.background),shape:d(t.shape)?void 0:Ut(t.shape),fill:d(t.fill)?void 0:N(t.fill),outline:d(t.outline)?void 0:Xt(t.outline),foreground:d(t.foreground)?void 0:Kt(t.foreground),shadow:d(t.shadow)?void 0:Yt(t.shadow),video:d(t.video)?void 0:le(t.video),audio:d(t.audio)?void 0:y(t.audio),effect:d(t.effect)?void 0:xt(t.effect),children:(e=t.children)==null?void 0:e.map(n=>et(n))})}function Ne(t){return et(t)}o.RawWeakMap=Ct,o.clearUndef=R,o.defaultColor=G,o.defineProperty=Wt,o.getDeclarations=U,o.getDefaultElementStyle=Qt,o.getDefaultHighlightStyle=te,o.getDefaultInnerShadow=Z,o.getDefaultLayoutStyle=Zt,o.getDefaultListStyleStyle=ee,o.getDefaultOuterShadow=Bt,o.getDefaultShadowStyle=qt,o.getDefaultStyle=Ce,o.getDefaultTextInlineStyle=ne,o.getDefaultTextLineStyle=re,o.getDefaultTextStyle=ie,o.getDefaultTransformStyle=Jt,o.getNestedValue=pt,o.getObjectValueByPath=yt,o.hasCRLF=_e,o.isCRLF=tt,o.isColor=wt,o.isColorFill=Gt,o.isColorFillObject=Lt,o.isEqualStyle=ae,o.isGradient=I,o.isGradientFill=Vt,o.isGradientFillObject=It,o.isImageFill=At,o.isImageFillObject=Pt,o.isNone=d,o.isPresetFill=Tt,o.isPresetFillObject=Mt,o.normalizeAudio=y,o.normalizeBackground=$t,o.normalizeCRLF=oe,o.normalizeColor=b,o.normalizeColorFill=Rt,o.normalizeDocument=Ne,o.normalizeEffect=xt,o.normalizeElement=et,o.normalizeFill=N,o.normalizeForeground=Kt,o.normalizeGradient=Ot,o.normalizeGradientFill=kt,o.normalizeImageFill=Et,o.normalizeInnerShadow=J,o.normalizeOuterShadow=jt,o.normalizeOutline=Xt,o.normalizePresetFill=Dt,o.normalizeShadow=Yt,o.normalizeShape=Ut,o.normalizeSoftEdge=Se,o.normalizeStyle=D,o.normalizeText=ue,o.normalizeTextContent=V,o.normalizeVideo=le,o.parseColor=q,o.parseGradient=zt,o.pick=M,o.property=ye,o.round=O,o.setNestedValue=bt,o.setObjectValueByPath=St,o.stringifyGradient=be,o.textContentToString=Fe,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -49,6 +49,87 @@ function pick(obj, keys) {
|
|
|
49
49
|
return result;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
function getNestedValue(obj, path, fallback) {
|
|
53
|
+
const last = path.length - 1;
|
|
54
|
+
if (last < 0)
|
|
55
|
+
return obj === void 0 ? fallback : obj;
|
|
56
|
+
for (let i = 0; i < last; i++) {
|
|
57
|
+
if (obj == null) {
|
|
58
|
+
return fallback;
|
|
59
|
+
}
|
|
60
|
+
obj = obj[path[i]];
|
|
61
|
+
}
|
|
62
|
+
if (obj == null)
|
|
63
|
+
return fallback;
|
|
64
|
+
return obj[path[last]] === void 0 ? fallback : obj[path[last]];
|
|
65
|
+
}
|
|
66
|
+
function setNestedValue(obj, path, value) {
|
|
67
|
+
const last = path.length - 1;
|
|
68
|
+
for (let i = 0; i < last; i++) {
|
|
69
|
+
if (typeof obj[path[i]] !== "object")
|
|
70
|
+
obj[path[i]] = {};
|
|
71
|
+
obj = obj[path[i]];
|
|
72
|
+
}
|
|
73
|
+
obj[path[last]] = value;
|
|
74
|
+
}
|
|
75
|
+
function getObjectValueByPath(obj, path, fallback) {
|
|
76
|
+
if (obj == null || !path || typeof path !== "string")
|
|
77
|
+
return fallback;
|
|
78
|
+
if (obj[path] !== void 0)
|
|
79
|
+
return obj[path];
|
|
80
|
+
path = path.replace(/\[(\w+)\]/g, ".$1");
|
|
81
|
+
path = path.replace(/^\./, "");
|
|
82
|
+
return getNestedValue(obj, path.split("."), fallback);
|
|
83
|
+
}
|
|
84
|
+
function setObjectValueByPath(obj, path, value) {
|
|
85
|
+
if (typeof obj !== "object" || !path)
|
|
86
|
+
return;
|
|
87
|
+
path = path.replace(/\[(\w+)\]/g, ".$1");
|
|
88
|
+
path = path.replace(/^\./, "");
|
|
89
|
+
return setNestedValue(obj, path.split("."), value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
class RawWeakMap {
|
|
93
|
+
_map = /* @__PURE__ */ new WeakMap();
|
|
94
|
+
// fix: vue reactive object
|
|
95
|
+
_toRaw(value) {
|
|
96
|
+
if (value && typeof value === "object") {
|
|
97
|
+
const raw = value.__v_raw;
|
|
98
|
+
if (raw) {
|
|
99
|
+
value = this._toRaw(raw);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Removes the specified element from the WeakMap.
|
|
106
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
107
|
+
*/
|
|
108
|
+
delete(key) {
|
|
109
|
+
return this._map.delete(this._toRaw(key));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* @returns a specified element.
|
|
113
|
+
*/
|
|
114
|
+
get(key) {
|
|
115
|
+
return this._map.get(this._toRaw(key));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @returns a boolean indicating whether an element with the specified key exists or not.
|
|
119
|
+
*/
|
|
120
|
+
has(key) {
|
|
121
|
+
return this._map.has(this._toRaw(key));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Adds a new element with a specified key and value.
|
|
125
|
+
* @param key Must be an object or symbol.
|
|
126
|
+
*/
|
|
127
|
+
set(key, value) {
|
|
128
|
+
this._map.set(this._toRaw(key), this._toRaw(value));
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
52
133
|
function parseColor(color) {
|
|
53
134
|
let input;
|
|
54
135
|
if (typeof color === "number") {
|
|
@@ -807,6 +888,68 @@ function normalizeBackground(background) {
|
|
|
807
888
|
}
|
|
808
889
|
}
|
|
809
890
|
|
|
891
|
+
const declarationMap = new RawWeakMap();
|
|
892
|
+
function getDeclarations(constructor) {
|
|
893
|
+
let declarations = declarationMap.get(constructor);
|
|
894
|
+
if (!declarations) {
|
|
895
|
+
const superConstructor = Object.getPrototypeOf(constructor);
|
|
896
|
+
declarations = new Map(superConstructor ? getDeclarations(superConstructor) : void 0);
|
|
897
|
+
declarationMap.set(constructor, declarations);
|
|
898
|
+
}
|
|
899
|
+
return declarations;
|
|
900
|
+
}
|
|
901
|
+
function defineProperty(constructor, key, declaration = {}) {
|
|
902
|
+
getDeclarations(constructor).set(key, declaration);
|
|
903
|
+
const {
|
|
904
|
+
default: defaultValue,
|
|
905
|
+
alias = Symbol.for(String(key))
|
|
906
|
+
} = declaration;
|
|
907
|
+
const getDefaultValue = () => typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
908
|
+
const descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, key) || {
|
|
909
|
+
get() {
|
|
910
|
+
if (typeof alias === "string") {
|
|
911
|
+
return getObjectValueByPath(this, alias);
|
|
912
|
+
} else {
|
|
913
|
+
return this[alias];
|
|
914
|
+
}
|
|
915
|
+
},
|
|
916
|
+
set(v) {
|
|
917
|
+
if (typeof alias === "string") {
|
|
918
|
+
setObjectValueByPath(this, alias, v);
|
|
919
|
+
} else {
|
|
920
|
+
this[alias] = v;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
Object.defineProperty(constructor.prototype, key, {
|
|
925
|
+
get() {
|
|
926
|
+
let value = descriptor.get?.call(this);
|
|
927
|
+
if (value === void 0) {
|
|
928
|
+
value = getDefaultValue();
|
|
929
|
+
if (value !== void 0) {
|
|
930
|
+
descriptor.set?.call(this, value);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
return value;
|
|
934
|
+
},
|
|
935
|
+
set(newValue) {
|
|
936
|
+
let oldValue = descriptor.get?.call(this);
|
|
937
|
+
if (oldValue === void 0) {
|
|
938
|
+
oldValue = getDefaultValue();
|
|
939
|
+
}
|
|
940
|
+
descriptor.set?.call(this, newValue);
|
|
941
|
+
this.requestUpdate?.(key, newValue, oldValue, declaration);
|
|
942
|
+
},
|
|
943
|
+
configurable: true,
|
|
944
|
+
enumerable: true
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
function property(options) {
|
|
948
|
+
return function(proto, name) {
|
|
949
|
+
defineProperty(proto.constructor, name, options);
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
|
|
810
953
|
function getDefaultInnerShadow() {
|
|
811
954
|
return {
|
|
812
955
|
color: defaultColor,
|
|
@@ -1255,4 +1398,4 @@ function normalizeDocument(doc) {
|
|
|
1255
1398
|
return normalizeElement(doc);
|
|
1256
1399
|
}
|
|
1257
1400
|
|
|
1258
|
-
export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, round, stringifyGradient, textContentToString };
|
|
1401
|
+
export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
|