modern-idoc 0.8.10 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -189,32 +189,35 @@ function setObjectValueByPath(obj, path, value) {
189
189
 
190
190
  class Observable {
191
191
  _observers = /* @__PURE__ */ new Map();
192
- on(name, f) {
193
- let set = this._observers.get(name);
192
+ on(event, listener) {
193
+ let set = this._observers.get(event);
194
194
  if (set === void 0) {
195
- this._observers.set(name, set = /* @__PURE__ */ new Set());
195
+ this._observers.set(event, set = /* @__PURE__ */ new Set());
196
196
  }
197
- set.add(f);
198
- return f;
197
+ set.add(listener);
198
+ return this;
199
199
  }
200
- once(name, f) {
200
+ once(event, listener) {
201
201
  const _f = (...args) => {
202
- this.off(name, _f);
203
- f(...args);
202
+ this.off(event, _f);
203
+ listener(...args);
204
204
  };
205
- this.on(name, _f);
205
+ this.on(event, _f);
206
+ return this;
206
207
  }
207
- off(name, f) {
208
- const observers = this._observers.get(name);
208
+ off(event, listener) {
209
+ const observers = this._observers.get(event);
209
210
  if (observers !== void 0) {
210
- observers.delete(f);
211
+ observers.delete(listener);
211
212
  if (observers.size === 0) {
212
- this._observers.delete(name);
213
+ this._observers.delete(event);
213
214
  }
214
215
  }
216
+ return this;
215
217
  }
216
- emit(name, ...args) {
217
- return Array.from((this._observers.get(name) || /* @__PURE__ */ new Map()).values()).forEach((f) => f(...args));
218
+ emit(event, ...args) {
219
+ Array.from((this._observers.get(event) || /* @__PURE__ */ new Map()).values()).forEach((f) => f(...args));
220
+ return this;
218
221
  }
219
222
  destroy() {
220
223
  this._observers = /* @__PURE__ */ new Map();
@@ -248,6 +251,164 @@ class RawWeakMap {
248
251
  }
249
252
  }
250
253
 
254
+ const propertiesSymbol = Symbol("properties");
255
+ const initedSymbol = Symbol("inited");
256
+ function getDeclarations(constructor) {
257
+ let declarations;
258
+ if (Object.hasOwn(constructor, propertiesSymbol)) {
259
+ declarations = constructor[propertiesSymbol];
260
+ } else {
261
+ const superConstructor = Object.getPrototypeOf(constructor);
262
+ declarations = new Map(superConstructor ? getDeclarations(superConstructor) : void 0);
263
+ constructor[propertiesSymbol] = declarations;
264
+ }
265
+ return declarations;
266
+ }
267
+ function getPropertyInternalKey(key) {
268
+ return `__internal:${key}`;
269
+ }
270
+ function getPropertyDescriptor(key, declaration = {}) {
271
+ const internalKey = getPropertyInternalKey(key);
272
+ const {
273
+ default: _default,
274
+ fallback,
275
+ alias,
276
+ internal
277
+ } = declaration;
278
+ const getDefaultValue = () => {
279
+ return typeof _default === "function" ? _default() : _default;
280
+ };
281
+ const getFallbackValue = () => {
282
+ return typeof fallback === "function" ? fallback() : fallback;
283
+ };
284
+ function get() {
285
+ let result;
286
+ if (alias && alias !== key) {
287
+ result = getObjectValueByPath(this, alias);
288
+ } else if (!internal && typeof this.getProperty !== "undefined") {
289
+ result = this.getProperty(key);
290
+ } else {
291
+ result = this[internalKey];
292
+ }
293
+ result = result ?? getFallbackValue();
294
+ if (result === void 0 && _default !== void 0 && !this[initedSymbol]) {
295
+ this[initedSymbol] = true;
296
+ const defaultValue = getDefaultValue();
297
+ if (defaultValue !== void 0) {
298
+ set.call(this, defaultValue);
299
+ result = defaultValue;
300
+ }
301
+ }
302
+ return result;
303
+ }
304
+ function set(newValue) {
305
+ if (alias && alias !== key) {
306
+ setObjectValueByPath(this, alias, newValue);
307
+ } else if (!internal && typeof this.setProperty !== "undefined") {
308
+ this.setProperty(key, newValue);
309
+ } else {
310
+ this[internalKey] = newValue;
311
+ }
312
+ }
313
+ return {
314
+ get,
315
+ set
316
+ };
317
+ }
318
+ function defineProperty(constructor, key, declaration = {}) {
319
+ getDeclarations(constructor).set(key, declaration);
320
+ const descriptor = getPropertyDescriptor(key, declaration);
321
+ Object.defineProperty(constructor.prototype, key, {
322
+ get() {
323
+ return descriptor.get.call(this);
324
+ },
325
+ set(newValue) {
326
+ descriptor.set.call(this, newValue);
327
+ },
328
+ configurable: true,
329
+ enumerable: true
330
+ });
331
+ }
332
+ function property(declaration) {
333
+ return function(target, key) {
334
+ if (typeof key !== "string") {
335
+ throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
336
+ }
337
+ defineProperty(target.constructor, key, declaration);
338
+ };
339
+ }
340
+ function property2(declaration = {}) {
341
+ return function(_, context) {
342
+ const key = context.name;
343
+ if (typeof key !== "string") {
344
+ throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
345
+ }
346
+ const descriptor = getPropertyDescriptor(key, declaration);
347
+ return {
348
+ init(v) {
349
+ getDeclarations(this.constructor).set(key, declaration);
350
+ descriptor.set.call(this, v);
351
+ return v;
352
+ },
353
+ get() {
354
+ return descriptor.get.call(this);
355
+ },
356
+ set(newValue) {
357
+ descriptor.set.call(this, newValue);
358
+ }
359
+ };
360
+ };
361
+ }
362
+
363
+ class Reactivable extends Observable {
364
+ _propertyAccessor;
365
+ _properties = /* @__PURE__ */ new Map();
366
+ getProperty(key, defaultValue) {
367
+ if (this._propertyAccessor?.getProperty) {
368
+ return this._propertyAccessor.getProperty(key, defaultValue);
369
+ } else {
370
+ return this._properties.get(key) ?? defaultValue;
371
+ }
372
+ }
373
+ setProperty(key, newValue) {
374
+ const oldValue = this[key];
375
+ if (Object.is(newValue, oldValue)) {
376
+ return;
377
+ }
378
+ if (this._propertyAccessor?.setProperty) {
379
+ this._propertyAccessor.setProperty(key, newValue);
380
+ } else {
381
+ this._properties.set(key, newValue);
382
+ }
383
+ this.onUpdateProperty(key, newValue, oldValue);
384
+ }
385
+ getPropertyDeclarations() {
386
+ return getDeclarations(this.constructor);
387
+ }
388
+ setPropertyAccessor(accessor) {
389
+ this._propertyAccessor = accessor;
390
+ this.getPropertyDeclarations().forEach((_declaration, key) => {
391
+ const newValue = this[key];
392
+ const oldValue = this._properties.get(key);
393
+ if (newValue === void 0) {
394
+ if (oldValue !== void 0) {
395
+ this[key] = oldValue;
396
+ }
397
+ } else if (newValue !== oldValue) {
398
+ this[key] = newValue;
399
+ }
400
+ });
401
+ return this;
402
+ }
403
+ onUpdateProperty(key, newValue, oldValue) {
404
+ this._updateProperty(key, newValue, oldValue);
405
+ this.emit("updateProperty", key, newValue, oldValue);
406
+ }
407
+ // eslint-disable-next-line unused-imports/no-unused-vars
408
+ _updateProperty(key, newValue, oldValue) {
409
+ }
410
+ }
411
+
251
412
  function parseColor(color) {
252
413
  let input;
253
414
  if (typeof color === "number") {
@@ -1007,120 +1168,6 @@ function normalizeBackground(background) {
1007
1168
  }
1008
1169
  }
1009
1170
 
1010
- const propertiesSymbol = Symbol("properties");
1011
- const defaultValueInitedSymbol = Symbol("defaultValueInited");
1012
- function getDeclarations(constructor) {
1013
- let declarations;
1014
- if (Object.hasOwn(constructor, propertiesSymbol)) {
1015
- declarations = constructor[propertiesSymbol];
1016
- } else {
1017
- const superConstructor = Object.getPrototypeOf(constructor);
1018
- declarations = new Map(superConstructor ? getDeclarations(superConstructor) : void 0);
1019
- constructor[propertiesSymbol] = declarations;
1020
- }
1021
- return declarations;
1022
- }
1023
- function getPropertyDescriptor(key, declaration = {}) {
1024
- const internalKey = Symbol.for(key);
1025
- const {
1026
- default: _default,
1027
- fallback,
1028
- alias
1029
- } = declaration;
1030
- const ctx = { declaration, internalKey };
1031
- const getDefaultValue = () => {
1032
- return typeof _default === "function" ? _default() : _default;
1033
- };
1034
- const getFallbackValue = () => {
1035
- return typeof fallback === "function" ? fallback() : fallback;
1036
- };
1037
- function get() {
1038
- let result;
1039
- if (alias && alias !== key) {
1040
- result = getObjectValueByPath(this, alias);
1041
- } else {
1042
- if (typeof this.getter !== "undefined") {
1043
- result = this.getter(key, ctx);
1044
- } else {
1045
- result = this[internalKey];
1046
- }
1047
- }
1048
- result = result ?? getFallbackValue();
1049
- if (result === void 0 && _default !== void 0 && !this[defaultValueInitedSymbol]) {
1050
- this[defaultValueInitedSymbol] = true;
1051
- const defaultValue = getDefaultValue();
1052
- if (defaultValue !== void 0) {
1053
- set.call(this, defaultValue);
1054
- result = defaultValue;
1055
- }
1056
- }
1057
- return result;
1058
- }
1059
- function set(newValue) {
1060
- if (alias && alias !== key) {
1061
- setObjectValueByPath(this, alias, newValue);
1062
- } else {
1063
- if (typeof this.setter !== "undefined") {
1064
- this.setter(key, newValue, ctx);
1065
- } else {
1066
- this[internalKey] = newValue;
1067
- }
1068
- }
1069
- }
1070
- return {
1071
- get,
1072
- set
1073
- };
1074
- }
1075
- function defineProperty(constructor, key, declaration = {}) {
1076
- getDeclarations(constructor).set(key, declaration);
1077
- const descriptor = getPropertyDescriptor(key, declaration);
1078
- Object.defineProperty(constructor.prototype, key, {
1079
- get() {
1080
- return descriptor.get.call(this);
1081
- },
1082
- set(newValue) {
1083
- const oldValue = descriptor.get.call(this);
1084
- descriptor.set.call(this, newValue);
1085
- this.onUpdateProperty?.(key, newValue, oldValue, declaration);
1086
- },
1087
- configurable: true,
1088
- enumerable: true
1089
- });
1090
- }
1091
- function property(declaration) {
1092
- return function(target, key) {
1093
- if (typeof key !== "string") {
1094
- throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
1095
- }
1096
- defineProperty(target.constructor, key, declaration);
1097
- };
1098
- }
1099
- function property2(declaration = {}) {
1100
- return function(_, context) {
1101
- const key = context.name;
1102
- if (typeof key !== "string") {
1103
- throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
1104
- }
1105
- const descriptor = getPropertyDescriptor(key, declaration);
1106
- return {
1107
- init(v) {
1108
- getDeclarations(this.constructor).set(key, declaration);
1109
- descriptor.set.call(this, v);
1110
- return v;
1111
- },
1112
- get() {
1113
- return descriptor.get.call(this);
1114
- },
1115
- set(newValue) {
1116
- const oldValue = descriptor.get?.call(this);
1117
- descriptor.set.call(this, newValue);
1118
- this.onUpdateProperty?.(key, newValue, oldValue, declaration);
1119
- }
1120
- };
1121
- };
1122
- }
1123
-
1124
1171
  function getDefaultInnerShadow() {
1125
1172
  return {
1126
1173
  color: defaultColor,
@@ -1650,6 +1697,7 @@ function flatDocumentToDocument(flatDoc) {
1650
1697
  exports.EventEmitter = EventEmitter;
1651
1698
  exports.Observable = Observable;
1652
1699
  exports.RawWeakMap = RawWeakMap;
1700
+ exports.Reactivable = Reactivable;
1653
1701
  exports.clearUndef = clearUndef;
1654
1702
  exports.defaultColor = defaultColor;
1655
1703
  exports.defineProperty = defineProperty;
@@ -1670,6 +1718,7 @@ exports.getDefaultTransformStyle = getDefaultTransformStyle;
1670
1718
  exports.getNestedValue = getNestedValue;
1671
1719
  exports.getObjectValueByPath = getObjectValueByPath;
1672
1720
  exports.getPropertyDescriptor = getPropertyDescriptor;
1721
+ exports.getPropertyInternalKey = getPropertyInternalKey;
1673
1722
  exports.hasCRLF = hasCRLF;
1674
1723
  exports.idGenerator = idGenerator;
1675
1724
  exports.isCRLF = isCRLF;
package/dist/index.d.cts CHANGED
@@ -326,24 +326,21 @@ interface PropertyDeclaration {
326
326
  default?: unknown | (() => unknown);
327
327
  fallback?: unknown | (() => unknown);
328
328
  alias?: string;
329
+ internal?: boolean;
329
330
  }
330
- interface ReactiveObject {
331
- getter?: (key: string, context: ReactiveObjectPropertyAccessorContext) => any;
332
- setter?: (key: string, value: any, context: ReactiveObjectPropertyAccessorContext) => void;
333
- onUpdateProperty?: (key: string, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
334
- }
335
- interface ReactiveObjectPropertyAccessorContext {
336
- declaration: PropertyDeclaration;
337
- internalKey: symbol;
331
+ interface PropertyAccessor {
332
+ getProperty?: (key: string, defaultValue?: any) => any;
333
+ setProperty?: (key: string, newValue: any) => void;
338
334
  }
339
335
  declare function getDeclarations(constructor: any): Map<string, PropertyDeclaration>;
340
- declare function getPropertyDescriptor<V, T extends ReactiveObject>(key: string, declaration?: PropertyDeclaration): {
336
+ declare function getPropertyInternalKey(key: string): string;
337
+ declare function getPropertyDescriptor<V, T extends PropertyAccessor>(key: string, declaration?: PropertyDeclaration): {
341
338
  get: () => any;
342
339
  set: (v: any) => void;
343
340
  };
344
- declare function defineProperty<V, T extends ReactiveObject>(constructor: any, key: string, declaration?: PropertyDeclaration): void;
345
- declare function property<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): PropertyDecorator;
346
- declare function property2<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
341
+ declare function defineProperty<V, T extends PropertyAccessor>(constructor: any, key: string, declaration?: PropertyDeclaration): void;
342
+ declare function property<V, T extends PropertyAccessor>(declaration?: PropertyDeclaration): PropertyDecorator;
343
+ declare function property2<V, T extends PropertyAccessor>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
347
344
 
348
345
  interface NormalizedInnerShadow {
349
346
  color: NormalizedColor;
@@ -841,14 +838,14 @@ declare function setNestedValue(obj: any, path: (string | number)[], value: any)
841
838
  declare function getObjectValueByPath(obj: any, path: string, fallback?: any): any;
842
839
  declare function setObjectValueByPath(obj: any, path: string, value: any): void;
843
840
 
844
- declare class Observable<EVENTS extends {
845
- [key in keyof EVENTS]: (...args: any[]) => void;
841
+ declare class Observable<T extends {
842
+ [K in keyof T]: (...args: any[]) => void;
846
843
  }> {
847
844
  _observers: Map<string, Set<any>>;
848
- on<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): EVENTS[NAME];
849
- once<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): void;
850
- off<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): void;
851
- emit<NAME extends keyof EVENTS & string>(name: NAME, ...args: Parameters<EVENTS[NAME]>): void;
845
+ on<K extends keyof T & string>(event: K, listener: T[K]): this;
846
+ once<K extends keyof T & string>(event: K, listener: T[K]): this;
847
+ off<K extends keyof T & string>(event: K, listener: T[K]): this;
848
+ emit<K extends keyof T & string>(event: K, ...args: Parameters<T[K]>): this;
852
849
  destroy(): void;
853
850
  }
854
851
 
@@ -861,5 +858,19 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
861
858
  set(key: K, value: V): this;
862
859
  }
863
860
 
864
- export { EventEmitter, Observable, RawWeakMap, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
865
- export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, FullStyle, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineCap, LineEndSize, LineEndType, LineJoin, 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, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedFragment, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedParagraph, 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, ReactiveObject, ReactiveObjectPropertyAccessorContext, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextObject, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
861
+ interface ReactivableEvents {
862
+ updateProperty: (key: string, newValue: any, oldValue: any) => void;
863
+ }
864
+ declare class Reactivable extends Observable<ReactivableEvents> implements PropertyAccessor {
865
+ protected _propertyAccessor?: PropertyAccessor;
866
+ protected _properties: Map<string, unknown>;
867
+ getProperty(key: string, defaultValue?: any): any;
868
+ setProperty(key: string, newValue: any): void;
869
+ getPropertyDeclarations(): Map<string, PropertyDeclaration>;
870
+ setPropertyAccessor(accessor: PropertyAccessor): this;
871
+ onUpdateProperty(key: string, newValue: any, oldValue: any): void;
872
+ protected _updateProperty(key: string, newValue: any, oldValue: any): void;
873
+ }
874
+
875
+ export { EventEmitter, Observable, RawWeakMap, Reactivable, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, getPropertyInternalKey, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
876
+ export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, FullStyle, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineCap, LineEndSize, LineEndType, LineJoin, 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, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedFragment, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedParagraph, 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, PropertyAccessor, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactivableEvents, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextObject, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
package/dist/index.d.mts CHANGED
@@ -326,24 +326,21 @@ interface PropertyDeclaration {
326
326
  default?: unknown | (() => unknown);
327
327
  fallback?: unknown | (() => unknown);
328
328
  alias?: string;
329
+ internal?: boolean;
329
330
  }
330
- interface ReactiveObject {
331
- getter?: (key: string, context: ReactiveObjectPropertyAccessorContext) => any;
332
- setter?: (key: string, value: any, context: ReactiveObjectPropertyAccessorContext) => void;
333
- onUpdateProperty?: (key: string, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
334
- }
335
- interface ReactiveObjectPropertyAccessorContext {
336
- declaration: PropertyDeclaration;
337
- internalKey: symbol;
331
+ interface PropertyAccessor {
332
+ getProperty?: (key: string, defaultValue?: any) => any;
333
+ setProperty?: (key: string, newValue: any) => void;
338
334
  }
339
335
  declare function getDeclarations(constructor: any): Map<string, PropertyDeclaration>;
340
- declare function getPropertyDescriptor<V, T extends ReactiveObject>(key: string, declaration?: PropertyDeclaration): {
336
+ declare function getPropertyInternalKey(key: string): string;
337
+ declare function getPropertyDescriptor<V, T extends PropertyAccessor>(key: string, declaration?: PropertyDeclaration): {
341
338
  get: () => any;
342
339
  set: (v: any) => void;
343
340
  };
344
- declare function defineProperty<V, T extends ReactiveObject>(constructor: any, key: string, declaration?: PropertyDeclaration): void;
345
- declare function property<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): PropertyDecorator;
346
- declare function property2<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
341
+ declare function defineProperty<V, T extends PropertyAccessor>(constructor: any, key: string, declaration?: PropertyDeclaration): void;
342
+ declare function property<V, T extends PropertyAccessor>(declaration?: PropertyDeclaration): PropertyDecorator;
343
+ declare function property2<V, T extends PropertyAccessor>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
347
344
 
348
345
  interface NormalizedInnerShadow {
349
346
  color: NormalizedColor;
@@ -841,14 +838,14 @@ declare function setNestedValue(obj: any, path: (string | number)[], value: any)
841
838
  declare function getObjectValueByPath(obj: any, path: string, fallback?: any): any;
842
839
  declare function setObjectValueByPath(obj: any, path: string, value: any): void;
843
840
 
844
- declare class Observable<EVENTS extends {
845
- [key in keyof EVENTS]: (...args: any[]) => void;
841
+ declare class Observable<T extends {
842
+ [K in keyof T]: (...args: any[]) => void;
846
843
  }> {
847
844
  _observers: Map<string, Set<any>>;
848
- on<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): EVENTS[NAME];
849
- once<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): void;
850
- off<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): void;
851
- emit<NAME extends keyof EVENTS & string>(name: NAME, ...args: Parameters<EVENTS[NAME]>): void;
845
+ on<K extends keyof T & string>(event: K, listener: T[K]): this;
846
+ once<K extends keyof T & string>(event: K, listener: T[K]): this;
847
+ off<K extends keyof T & string>(event: K, listener: T[K]): this;
848
+ emit<K extends keyof T & string>(event: K, ...args: Parameters<T[K]>): this;
852
849
  destroy(): void;
853
850
  }
854
851
 
@@ -861,5 +858,19 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
861
858
  set(key: K, value: V): this;
862
859
  }
863
860
 
864
- export { EventEmitter, Observable, RawWeakMap, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
865
- export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, FullStyle, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineCap, LineEndSize, LineEndType, LineJoin, 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, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedFragment, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedParagraph, 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, ReactiveObject, ReactiveObjectPropertyAccessorContext, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextObject, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
861
+ interface ReactivableEvents {
862
+ updateProperty: (key: string, newValue: any, oldValue: any) => void;
863
+ }
864
+ declare class Reactivable extends Observable<ReactivableEvents> implements PropertyAccessor {
865
+ protected _propertyAccessor?: PropertyAccessor;
866
+ protected _properties: Map<string, unknown>;
867
+ getProperty(key: string, defaultValue?: any): any;
868
+ setProperty(key: string, newValue: any): void;
869
+ getPropertyDeclarations(): Map<string, PropertyDeclaration>;
870
+ setPropertyAccessor(accessor: PropertyAccessor): this;
871
+ onUpdateProperty(key: string, newValue: any, oldValue: any): void;
872
+ protected _updateProperty(key: string, newValue: any, oldValue: any): void;
873
+ }
874
+
875
+ export { EventEmitter, Observable, RawWeakMap, Reactivable, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, getPropertyInternalKey, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
876
+ export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, FullStyle, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineCap, LineEndSize, LineEndType, LineJoin, 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, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedFragment, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedParagraph, 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, PropertyAccessor, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactivableEvents, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextObject, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
package/dist/index.d.ts CHANGED
@@ -326,24 +326,21 @@ interface PropertyDeclaration {
326
326
  default?: unknown | (() => unknown);
327
327
  fallback?: unknown | (() => unknown);
328
328
  alias?: string;
329
+ internal?: boolean;
329
330
  }
330
- interface ReactiveObject {
331
- getter?: (key: string, context: ReactiveObjectPropertyAccessorContext) => any;
332
- setter?: (key: string, value: any, context: ReactiveObjectPropertyAccessorContext) => void;
333
- onUpdateProperty?: (key: string, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
334
- }
335
- interface ReactiveObjectPropertyAccessorContext {
336
- declaration: PropertyDeclaration;
337
- internalKey: symbol;
331
+ interface PropertyAccessor {
332
+ getProperty?: (key: string, defaultValue?: any) => any;
333
+ setProperty?: (key: string, newValue: any) => void;
338
334
  }
339
335
  declare function getDeclarations(constructor: any): Map<string, PropertyDeclaration>;
340
- declare function getPropertyDescriptor<V, T extends ReactiveObject>(key: string, declaration?: PropertyDeclaration): {
336
+ declare function getPropertyInternalKey(key: string): string;
337
+ declare function getPropertyDescriptor<V, T extends PropertyAccessor>(key: string, declaration?: PropertyDeclaration): {
341
338
  get: () => any;
342
339
  set: (v: any) => void;
343
340
  };
344
- declare function defineProperty<V, T extends ReactiveObject>(constructor: any, key: string, declaration?: PropertyDeclaration): void;
345
- declare function property<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): PropertyDecorator;
346
- declare function property2<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
341
+ declare function defineProperty<V, T extends PropertyAccessor>(constructor: any, key: string, declaration?: PropertyDeclaration): void;
342
+ declare function property<V, T extends PropertyAccessor>(declaration?: PropertyDeclaration): PropertyDecorator;
343
+ declare function property2<V, T extends PropertyAccessor>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
347
344
 
348
345
  interface NormalizedInnerShadow {
349
346
  color: NormalizedColor;
@@ -841,14 +838,14 @@ declare function setNestedValue(obj: any, path: (string | number)[], value: any)
841
838
  declare function getObjectValueByPath(obj: any, path: string, fallback?: any): any;
842
839
  declare function setObjectValueByPath(obj: any, path: string, value: any): void;
843
840
 
844
- declare class Observable<EVENTS extends {
845
- [key in keyof EVENTS]: (...args: any[]) => void;
841
+ declare class Observable<T extends {
842
+ [K in keyof T]: (...args: any[]) => void;
846
843
  }> {
847
844
  _observers: Map<string, Set<any>>;
848
- on<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): EVENTS[NAME];
849
- once<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): void;
850
- off<NAME extends keyof EVENTS & string>(name: NAME, f: EVENTS[NAME]): void;
851
- emit<NAME extends keyof EVENTS & string>(name: NAME, ...args: Parameters<EVENTS[NAME]>): void;
845
+ on<K extends keyof T & string>(event: K, listener: T[K]): this;
846
+ once<K extends keyof T & string>(event: K, listener: T[K]): this;
847
+ off<K extends keyof T & string>(event: K, listener: T[K]): this;
848
+ emit<K extends keyof T & string>(event: K, ...args: Parameters<T[K]>): this;
852
849
  destroy(): void;
853
850
  }
854
851
 
@@ -861,5 +858,19 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
861
858
  set(key: K, value: V): this;
862
859
  }
863
860
 
864
- export { EventEmitter, Observable, RawWeakMap, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
865
- export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, FullStyle, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineCap, LineEndSize, LineEndType, LineJoin, 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, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedFragment, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedParagraph, 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, ReactiveObject, ReactiveObjectPropertyAccessorContext, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextObject, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
861
+ interface ReactivableEvents {
862
+ updateProperty: (key: string, newValue: any, oldValue: any) => void;
863
+ }
864
+ declare class Reactivable extends Observable<ReactivableEvents> implements PropertyAccessor {
865
+ protected _propertyAccessor?: PropertyAccessor;
866
+ protected _properties: Map<string, unknown>;
867
+ getProperty(key: string, defaultValue?: any): any;
868
+ setProperty(key: string, newValue: any): void;
869
+ getPropertyDeclarations(): Map<string, PropertyDeclaration>;
870
+ setPropertyAccessor(accessor: PropertyAccessor): this;
871
+ onUpdateProperty(key: string, newValue: any, oldValue: any): void;
872
+ protected _updateProperty(key: string, newValue: any, oldValue: any): void;
873
+ }
874
+
875
+ export { EventEmitter, Observable, RawWeakMap, Reactivable, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, getPropertyInternalKey, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
876
+ export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, FullStyle, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineCap, LineEndSize, LineEndType, LineJoin, 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, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedFragment, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedParagraph, 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, PropertyAccessor, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactivableEvents, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextObject, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(o,G){typeof exports=="object"&&typeof module<"u"?G(exports):typeof define=="function"&&define.amd?define(["exports"],G):(o=typeof globalThis<"u"?globalThis:o||self,G(o.modernIdoc={}))})(this,(function(o){"use strict";function G(t){return typeof t=="string"?{src:t}:t}var ye={grad:.9,turn:360,rad:360/(2*Math.PI)},N=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},b=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},E=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},ht=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},vt=function(t){return{r:E(t.r,0,255),g:E(t.g,0,255),b:E(t.b,0,255),a:E(t.a)}},tt=function(t){return{r:b(t.r),g:b(t.g),b:b(t.b),a:b(t.a,3)}},be=/^#([0-9a-f]{3,8})$/i,B=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},pt=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=Math.max(e,n,r),l=a-Math.min(e,n,r),u=l?a===e?(n-r)/l:a===n?2+(r-e)/l:4+(e-n)/l:0;return{h:60*(u<0?u+6:u),s:a?l/a*100:0,v:a/255*100,a:i}},mt=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var a=Math.floor(e),l=r*(1-n),u=r*(1-(e-a)*n),f=r*(1-(1-e+a)*n),v=a%6;return{r:255*[r,u,l,l,f,r][v],g:255*[f,r,r,u,l,l][v],b:255*[l,l,f,r,r,u][v],a:i}},yt=function(t){return{h:ht(t.h),s:E(t.s,0,100),l:E(t.l,0,100),a:E(t.a)}},bt=function(t){return{h:b(t.h),s:b(t.s),l:b(t.l),a:b(t.a,3)}},St=function(t){return mt((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},j=function(t){return{h:(e=pt(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},Se=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ce=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,we=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,_e=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ct={string:[[function(t){var e=be.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?b(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?b(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=we.exec(t)||_e.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:vt({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=Se.exec(t)||Ce.exec(t);if(!e)return null;var n,r,i=yt({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(ye[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return St(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=i===void 0?1:i;return N(e)&&N(n)&&N(r)?vt({r:Number(e),g:Number(n),b:Number(r),a:Number(a)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,a=i===void 0?1:i;if(!N(e)||!N(n)||!N(r))return null;var l=yt({h:Number(e),s:Number(n),l:Number(r),a:Number(a)});return St(l)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,a=i===void 0?1:i;if(!N(e)||!N(n)||!N(r))return null;var l=(function(u){return{h:ht(u.h),s:E(u.s,0,100),v:E(u.v,0,100),a:E(u.a)}})({h:Number(e),s:Number(n),v:Number(r),a:Number(a)});return mt(l)},"hsv"]]},wt=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]},ze=function(t){return typeof t=="string"?wt(t.trim(),Ct.string):typeof t=="object"&&t!==null?wt(t,Ct.object):[null,void 0]},et=function(t,e){var n=j(t);return{h:n.h,s:E(n.s+100*e,0,100),l:n.l,a:n.a}},nt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},_t=function(t,e){var n=j(t);return{h:n.h,s:n.s,l:E(n.l+100*e,0,100),a:n.a}},zt=(function(){function t(e){this.parsed=ze(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 b(nt(this.rgba),2)},t.prototype.isDark=function(){return nt(this.rgba)<.5},t.prototype.isLight=function(){return nt(this.rgba)>=.5},t.prototype.toHex=function(){return e=tt(this.rgba),n=e.r,r=e.g,i=e.b,l=(a=e.a)<1?B(b(255*a)):"","#"+B(n)+B(r)+B(i)+l;var e,n,r,i,a,l},t.prototype.toRgb=function(){return tt(this.rgba)},t.prototype.toRgbString=function(){return e=tt(this.rgba),n=e.r,r=e.g,i=e.b,(a=e.a)<1?"rgba("+n+", "+r+", "+i+", "+a+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,a},t.prototype.toHsl=function(){return bt(j(this.rgba))},t.prototype.toHslString=function(){return e=bt(j(this.rgba)),n=e.h,r=e.s,i=e.l,(a=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+a+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,a},t.prototype.toHsv=function(){return e=pt(this.rgba),{h:b(e.h),s:b(e.s),v:b(e.v),a:b(e.a,3)};var e},t.prototype.invert=function(){return D({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),D(et(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),D(et(this.rgba,-e))},t.prototype.grayscale=function(){return D(et(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),D(_t(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),D(_t(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"?D({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):b(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=j(this.rgba);return typeof e=="number"?D({h:e,s:n.s,l:n.l,a:n.a}):b(n.h)},t.prototype.isEqual=function(e){return this.toHex()===D(e).toHex()},t})(),D=function(t){return t instanceof zt?t:new zt(t)};class Ee{eventListeners=new Map;addEventListener(e,n,r){const i={value:n,options:r},a=this.eventListeners.get(e);return a?Array.isArray(a)?a.push(i):this.eventListeners.set(e,[a,i]):this.eventListeners.set(e,i),this}removeEventListener(e,n,r){if(!n)return this.eventListeners.delete(e),this;const i=this.eventListeners.get(e);if(!i)return this;if(Array.isArray(i)){const a=[];for(let l=0,u=i.length;l<u;l++){const f=i[l];(f.value!==n||typeof r=="object"&&r?.once&&(typeof f.options=="boolean"||!f.options?.once))&&a.push(f)}a.length?this.eventListeners.set(e,a.length===1?a[0]:a):this.eventListeners.delete(e)}else i.value===n&&(typeof r=="boolean"||!r?.once||typeof i.options=="boolean"||i.options?.once)&&this.eventListeners.delete(e);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(e){return this.eventListeners.has(e)}dispatchEvent(e,...n){const r=this.eventListeners.get(e);if(r){if(Array.isArray(r))for(let i=r.length,a=0;a<i;a++){const l=r[a];typeof l.options=="object"&&l.options?.once&&this.off(e,l.value,l.options),l.value.apply(this,n)}else typeof r.options=="object"&&r.options?.once&&this.off(e,r.value,r.options),r.value.apply(this,n);return!0}else return!1}on(e,n,r){return this.addEventListener(e,n,r)}once(e,n){return this.addEventListener(e,n,{once:!0})}off(e,n,r){return this.removeEventListener(e,n,r)}emit(e,...n){this.dispatchEvent(e,...n)}}function h(t){return t==null||t==="none"}function R(t,e=0,n=10**e){return Math.round(n*t)/n+0}function w(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>w(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=w(i,e):n[r]=i)}return n}function K(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function x(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){const n=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!n.length||n.every(r=>t[r]===e[r])}return!1}function Et(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 Ft(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 Lt(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(/^\./,""),Et(t,e.split("."),n))}function Ot(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Ft(t,e.split("."),n)}class Fe{_observers=new Map;on(e,n){let r=this._observers.get(e);return r===void 0&&this._observers.set(e,r=new Set),r.add(n),n}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,...n){return Array.from((this._observers.get(e)||new Map).values()).forEach(r=>r(...n))}destroy(){this._observers=new Map}}class Le{_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 rt(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,D(e)}function Oe(t){return{r:R(t.r),g:R(t.g),b:R(t.b),a:R(t.a,3)}}function U(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const M="#000000FF";function Dt(t){return rt(t).isValid()}function C(t,e=!1){const n=rt(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),M}const{r,g:i,b:a,a:l}=Oe(n.rgba);return`#${U(r)}${U(i)}${U(a)}${U(R(l*255))}`}var X=X||{};X.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(s){const c=new Error(`${e}: ${s}`);throw c.source=e,c}function r(){const s=i();return e.length>0&&n("Invalid input not EOF"),s}function i(){return V(a)}function a(){return l("linear-gradient",t.linearGradient,f)||l("repeating-linear-gradient",t.repeatingLinearGradient,f)||l("radial-gradient",t.radialGradient,d)||l("repeating-radial-gradient",t.repeatingRadialGradient,d)}function l(s,c,g){return u(c,S=>{const A=g();return A&&(y(t.comma)||n("Missing comma before color stops")),{type:s,orientation:A,colorStops:V(dt)}})}function u(s,c){const g=y(s);if(g){y(t.startCall)||n("Missing (");const S=c(g);return y(t.endCall)||n("Missing )"),S}}function f(){const s=v();if(s)return s;const c=z("position-keyword",t.positionKeywords,1);return c?{type:"directional",value:c.value}:p()}function v(){return z("directional",t.sideOrCorner,1)}function p(){return z("angular",t.angleValue,1)||z("angular",t.radianValue,1)}function d(){let s,c=m(),g;return c&&(s=[],s.push(c),g=e,y(t.comma)&&(c=m(),c?s.push(c):e=g)),s}function m(){let s=_()||I();if(s)s.at=O();else{const c=F();if(c){s=c;const g=O();g&&(s.at=g)}else{const g=O();if(g)s={type:"default-radial",at:g};else{const S=k();S&&(s={type:"default-radial",at:S})}}}return s}function _(){const s=z("shape",/^(circle)/i,0);return s&&(s.style=me()||F()),s}function I(){const s=z("shape",/^(ellipse)/i,0);return s&&(s.style=k()||Q()||F()),s}function F(){return z("extent-keyword",t.extentKeywords,1)}function O(){if(z("position",/^at/,0)){const s=k();return s||n("Missing positioning value"),s}}function k(){const s=H();if(s.x||s.y)return{type:"position",value:s}}function H(){return{x:Q(),y:Q()}}function V(s){let c=s();const g=[];if(c)for(g.push(c);y(t.comma);)c=s(),c?g.push(c):n("One extra comma");return g}function dt(){const s=We();return s||n("Expected color definition"),s.length=Q(),s}function We(){return Ke()||qe()||Ye()||Ue()||xe()||Xe()||Be()}function Be(){return z("literal",t.literalColor,0)}function Ke(){return z("hex",t.hexColor,1)}function xe(){return u(t.rgbColor,()=>({type:"rgb",value:V(W)}))}function Ue(){return u(t.rgbaColor,()=>({type:"rgba",value:V(W)}))}function Xe(){return u(t.varColor,()=>({type:"var",value:Ze()}))}function Ye(){return u(t.hslColor,()=>{y(t.percentageValue)&&n("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const c=W();y(t.comma);let g=y(t.percentageValue);const S=g?g[1]:null;y(t.comma),g=y(t.percentageValue);const A=g?g[1]:null;return(!S||!A)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[c,S,A]}})}function qe(){return u(t.hslaColor,()=>{const s=W();y(t.comma);let c=y(t.percentageValue);const g=c?c[1]:null;y(t.comma),c=y(t.percentageValue);const S=c?c[1]:null;y(t.comma);const A=W();return(!g||!S)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[s,g,S,A]}})}function Ze(){return y(t.variableName)[1]}function W(){return y(t.number)[1]}function Q(){return z("%",t.percentageValue,1)||Je()||Qe()||me()}function Je(){return z("position-keyword",t.positionKeywords,1)}function Qe(){return u(t.calcValue,()=>{let s=1,c=0;for(;s>0&&c<e.length;){const S=e.charAt(c);S==="("?s++:S===")"&&s--,c++}s>0&&n("Missing closing parenthesis in calc() expression");const g=e.substring(0,c-1);return gt(c-1),{type:"calc",value:g}})}function me(){return z("px",t.pixelValue,1)||z("em",t.emValue,1)}function z(s,c,g){const S=y(c);if(S)return{type:s,value:S[g]}}function y(s){let c,g;return g=/^\s+/.exec(e),g&&gt(g[0].length),c=s.exec(e),c&&gt(c[0].length),c}function gt(s){e=e.substr(s)}return function(s){return e=s.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}})();const Nt=X.parse.bind(X);var Y=Y||{};Y.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,a){n+=t.visit(i),a<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 De=Y.stringify.bind(Y);function Rt(t){const e=t.length-1;return t.map((n,r)=>{const i=n.value;let a=R(r/e,3),l="#00000000";switch(n.type){case"rgb":l=C({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":l=C({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":l=C(n.value);break;case"hex":l=C(`#${n.value}`);break}switch(n.length?.type){case"%":a=Number(n.length.value)/100;break}return{offset:a,color:l}})}function It(t){let e=0;switch(t.orientation?.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:Rt(t.colorStops)}}function kt(t){return t.orientation?.map(e=>{switch(e?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:Rt(t.colorStops)}}function T(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function At(t){return Nt(t).map(e=>{switch(e?.type){case"linear-gradient":return It(e);case"repeating-linear-gradient":return{...It(e),repeat:!0};case"radial-gradient":return kt(e);case"repeating-radial-gradient":return{...kt(e),repeat:!0};default:return}}).filter(Boolean)}function Gt(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:C(e.color)}}function Pt(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=At(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function Vt(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function jt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:h(e.foregroundColor)?void 0:C(e.foregroundColor),backgroundColor:h(e.backgroundColor)?void 0:C(e.backgroundColor)}}function Mt(t){return!h(t.color)}function Tt(t){return typeof t=="string"?Dt(t):Mt(t)}function $t(t){return!h(t.image)&&T(t.image)||!!t.linearGradient||!!t.radialGradient}function Ht(t){return typeof t=="string"?T(t):$t(t)}function Wt(t){return!h(t.image)&&!T(t.image)}function Bt(t){return typeof t=="string"?!T(t):Wt(t)}function Kt(t){return!h(t.preset)}function xt(t){return typeof t=="string"?!1:Kt(t)}function L(t){const e=t&&typeof t=="object"?t.enabled:void 0;return Tt(t)?w({enabled:e,...Gt(t)}):Ht(t)?w({enabled:e,...Pt(t)}):Bt(t)?w({enabled:e,...Vt(t)}):xt(t)?w({enabled:e,...jt(t)}):{}}function Ut(t){return typeof t=="string"?{...L(t)}:{...L(t),...K(t,["fillWithShape"])}}const it=Symbol("properties"),Xt=Symbol("defaultValueInited");function q(t){let e;if(Object.hasOwn(t,it))e=t[it];else{const n=Object.getPrototypeOf(t);e=new Map(n?q(n):void 0),t[it]=e}return e}function ot(t,e={}){const n=Symbol.for(t),{default:r,fallback:i,alias:a}=e,l={declaration:e,internalKey:n},u=()=>typeof r=="function"?r():r,f=()=>typeof i=="function"?i():i;function v(){let d;if(a&&a!==t?d=Lt(this,a):typeof this.getter<"u"?d=this.getter(t,l):d=this[n],d=d??f(),d===void 0&&r!==void 0&&!this[Xt]){this[Xt]=!0;const m=u();m!==void 0&&(p.call(this,m),d=m)}return d}function p(d){a&&a!==t?Ot(this,a,d):typeof this.setter<"u"?this.setter(t,d,l):this[n]=d}return{get:v,set:p}}function Yt(t,e,n={}){q(t).set(e,n);const r=ot(e,n);Object.defineProperty(t.prototype,e,{get(){return r.get.call(this)},set(i){const a=r.get.call(this);r.set.call(this,i),this.onUpdateProperty?.(e,i,a,n)},configurable:!0,enumerable:!0})}function Ne(t){return function(e,n){if(typeof n!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");Yt(e.constructor,n,t)}}function Re(t={}){return function(e,n){const r=n.name;if(typeof r!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");const i=ot(r,t);return{init(a){return q(this.constructor).set(r,t),i.set.call(this,a),a},get(){return i.get.call(this)},set(a){const l=i.get?.call(this);i.set.call(this,a),this.onUpdateProperty?.(r,a,l,t)}}}}function at(){return{color:M,offsetX:0,offsetY:0,blurRadius:1}}function st(t){return{...at(),...w({...t,color:h(t.color)?M:C(t.color)})}}function qt(){return{...at(),scaleX:1,scaleY:1}}function Zt(t){return{...qt(),...st(t)}}function Ie(t){return t}function Jt(t){return w({...t,softEdge:h(t.softEdge)?void 0:t.softEdge,outerShadow:h(t.outerShadow)?void 0:Zt(t.outerShadow),innerShadow:h(t.innerShadow)?void 0:st(t.innerShadow)})}function Qt(t){return typeof t=="string"?{...L(t)}:{...L(t),...K(t,["fillWithShape"])}}const ke="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ae=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=ke[n[t]&63];return e};const te=()=>Ae(10),ee=te;function $(t){return typeof t=="string"?{...L(t)}:{...L(t),...K(t,["width","style","lineCap","lineJoin","headEnd","tailEnd"])}}function ne(t){return typeof t=="string"?{color:C(t)}:{...t,color:h(t.color)?M:C(t.color)}}function re(){return{boxShadow:"none"}}function ie(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 oe(){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 ae(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function se(){return{...oe(),...ae(),...re(),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 le(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function ue(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function ce(){return{...le(),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 fe(){return{...ue(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function de(){return{...fe(),...ce(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function P(t){return w({...t,color:h(t.color)?void 0:C(t.color),backgroundColor:h(t.backgroundColor)?void 0:C(t.backgroundColor),borderColor:h(t.borderColor)?void 0:C(t.borderColor),outlineColor:h(t.outlineColor)?void 0:C(t.outlineColor),shadowColor:h(t.shadowColor)?void 0:C(t.shadowColor)})}function Ge(){return{...se(),...de()}}const lt=/\r\n|\n\r|\n|\r/,Pe=new RegExp(`${lt.source}|<br\\/>`,"g"),Ve=new RegExp(`^(${lt.source})$`),ut=`
2
- `;function je(t){return lt.test(t)}function ct(t){return Ve.test(t)}function ge(t){return t.replace(Pe,ut)}function Z(t){const e=[];function n(){return e[e.length-1]}function r(u,f,v){const p=u?P(u):{},d=f?L(f):void 0,m=v?$(v):void 0,_=w({...p,fill:d,outline:m,fragments:[]});return e[e.length-1]?.fragments.length===0?e[e.length-1]=_:e.push(_),_}function i(u="",f,v,p){const d=f?P(f):{},m=v?L(v):void 0,_=p?$(p):void 0;Array.from(u).forEach(I=>{if(ct(I)){const{fragments:F,fill:O,outline:k,...H}=n()||r();F.length||F.push(w({...d,fill:m,outline:_,content:ut})),r(H,O,k)}else{const F=n()||r(),O=F.fragments[F.fragments.length-1];if(O){const{content:k,fill:H,outline:V,...dt}=O;if(x(m,H)&&x(_,V)&&x(d,dt)){O.content=`${k}${I}`;return}}F.fragments.push(w({...d,fill:m,outline:_,content:I}))}})}(Array.isArray(t)?t:[t]).forEach(u=>{if(typeof u=="string")r(),i(u);else if(ft(u)){const{content:f,fill:v,outline:p,...d}=u;r(d,v,p),i(f)}else if(he(u)){const{fragments:f,fill:v,outline:p,...d}=u;r(d,v,p),f.forEach(m=>{const{content:_,fill:I,outline:F,...O}=m;i(_,O,I,F)})}else Array.isArray(u)?(r(),u.forEach(f=>{if(typeof f=="string")i(f);else if(ft(f)){const{content:v,fill:p,outline:d,...m}=f;i(v,m,p,d)}})):console.warn("Failed to parse text content",u)});const l=n();return l&&!l.fragments.length&&l.fragments.push({content:""}),e}function he(t){return t&&typeof t=="object"&&"fragments"in t&&Array.isArray(t.fragments)}function ft(t){return t&&typeof t=="object"&&"content"in t&&typeof t.content=="string"}function ve(t){return typeof t=="string"||Array.isArray(t)?{content:Z(t)}:w({...t,content:Z(t.content??""),style:t.style?P(t.style):void 0,effects:t.effects?t.effects.map(e=>P(e)):void 0,measureDom:t.measureDom,fonts:t.fonts,fill:t.fill?L(t.fill):void 0,outline:t.outline?$(t.outline):void 0})}function Me(t){return Z(t).map(e=>{const n=ge(e.fragments.flatMap(r=>r.content).join(""));return ct(n)?"":n}).join(ut)}function pe(t){return typeof t=="string"?{src:t}:t}function J(t){return w({...t,id:t.id??ee(),style:h(t.style)?void 0:P(t.style),text:h(t.text)?void 0:ve(t.text),background:h(t.background)?void 0:Ut(t.background),shape:h(t.shape)?void 0:ie(t.shape),fill:h(t.fill)?void 0:L(t.fill),outline:h(t.outline)?void 0:$(t.outline),foreground:h(t.foreground)?void 0:Qt(t.foreground),shadow:h(t.shadow)?void 0:ne(t.shadow),video:h(t.video)?void 0:pe(t.video),audio:h(t.audio)?void 0:G(t.audio),effect:h(t.effect)?void 0:Jt(t.effect),children:t.children?.map(e=>J(e))})}function Te(t){return J(t)}function $e(t){const e={};for(const n in t.children){const r=J(t.children[n]);delete r.children,e[n]=r}return{...t,children:e}}function He(t){const{children:e,...n}=t;function r(f){const{parentId:v,childrenIds:p,...d}=f;return{...d,children:[]}}const i={},a=[],l={...n,children:a};function u(f){if(!e[f]||i[f])return;const v=e[f],p=r(v);i[f]=p;const d=v.parentId;if(d){u(d);const m=e[d],_=i[d];if(!_)return;m?.childrenIds&&_?.children&&(_.children[m.childrenIds.indexOf(f)]=p)}else a.push(p)}for(const f in e)u(f);return l}o.EventEmitter=Ee,o.Observable=Fe,o.RawWeakMap=Le,o.clearUndef=w,o.defaultColor=M,o.defineProperty=Yt,o.flatDocumentToDocument=He,o.getDeclarations=q,o.getDefaultElementStyle=se,o.getDefaultHighlightStyle=le,o.getDefaultInnerShadow=at,o.getDefaultLayoutStyle=oe,o.getDefaultListStyleStyle=ue,o.getDefaultOuterShadow=qt,o.getDefaultShadowStyle=re,o.getDefaultStyle=Ge,o.getDefaultTextInlineStyle=ce,o.getDefaultTextLineStyle=fe,o.getDefaultTextStyle=de,o.getDefaultTransformStyle=ae,o.getNestedValue=Et,o.getObjectValueByPath=Lt,o.getPropertyDescriptor=ot,o.hasCRLF=je,o.idGenerator=ee,o.isCRLF=ct,o.isColor=Dt,o.isColorFill=Tt,o.isColorFillObject=Mt,o.isEqualObject=x,o.isFragmentObject=ft,o.isGradient=T,o.isGradientFill=Ht,o.isGradientFillObject=$t,o.isImageFill=Bt,o.isImageFillObject=Wt,o.isNone=h,o.isParagraphObject=he,o.isPresetFill=xt,o.isPresetFillObject=Kt,o.nanoid=te,o.normalizeAudio=G,o.normalizeBackground=Ut,o.normalizeCRLF=ge,o.normalizeColor=C,o.normalizeColorFill=Gt,o.normalizeDocument=Te,o.normalizeEffect=Jt,o.normalizeElement=J,o.normalizeFill=L,o.normalizeFlatDocument=$e,o.normalizeForeground=Qt,o.normalizeGradient=At,o.normalizeGradientFill=Pt,o.normalizeImageFill=Vt,o.normalizeInnerShadow=st,o.normalizeOuterShadow=Zt,o.normalizeOutline=$,o.normalizePresetFill=jt,o.normalizeShadow=ne,o.normalizeShape=ie,o.normalizeSoftEdge=Ie,o.normalizeStyle=P,o.normalizeText=ve,o.normalizeTextContent=Z,o.normalizeVideo=pe,o.parseColor=rt,o.parseGradient=Nt,o.pick=K,o.property=Ne,o.property2=Re,o.round=R,o.setNestedValue=Ft,o.setObjectValueByPath=Ot,o.stringifyGradient=De,o.textContentToString=Me,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(o,G){typeof exports=="object"&&typeof module<"u"?G(exports):typeof define=="function"&&define.amd?define(["exports"],G):(o=typeof globalThis<"u"?globalThis:o||self,G(o.modernIdoc={}))})(this,(function(o){"use strict";function G(t){return typeof t=="string"?{src:t}:t}var Se={grad:.9,turn:360,rad:360/(2*Math.PI)},D=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},b=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},E=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},ht=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},pt=function(t){return{r:E(t.r,0,255),g:E(t.g,0,255),b:E(t.b,0,255),a:E(t.a)}},tt=function(t){return{r:b(t.r),g:b(t.g),b:b(t.b),a:b(t.a,3)}},Ce=/^#([0-9a-f]{3,8})$/i,K=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},vt=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=Math.max(e,n,r),l=a-Math.min(e,n,r),u=l?a===e?(n-r)/l:a===n?2+(r-e)/l:4+(e-n)/l:0;return{h:60*(u<0?u+6:u),s:a?l/a*100:0,v:a/255*100,a:i}},mt=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var a=Math.floor(e),l=r*(1-n),u=r*(1-(e-a)*n),f=r*(1-(1-e+a)*n),p=a%6;return{r:255*[r,u,l,l,f,r][p],g:255*[f,r,r,u,l,l][p],b:255*[l,l,f,r,r,u][p],a:i}},yt=function(t){return{h:ht(t.h),s:E(t.s,0,100),l:E(t.l,0,100),a:E(t.a)}},bt=function(t){return{h:b(t.h),s:b(t.s),l:b(t.l),a:b(t.a,3)}},St=function(t){return mt((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},V=function(t){return{h:(e=vt(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},we=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,_e=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ze=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ee=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ct={string:[[function(t){var e=Ce.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?b(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?b(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=ze.exec(t)||Ee.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:pt({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=we.exec(t)||_e.exec(t);if(!e)return null;var n,r,i=yt({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(Se[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return St(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=i===void 0?1:i;return D(e)&&D(n)&&D(r)?pt({r:Number(e),g:Number(n),b:Number(r),a:Number(a)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,a=i===void 0?1:i;if(!D(e)||!D(n)||!D(r))return null;var l=yt({h:Number(e),s:Number(n),l:Number(r),a:Number(a)});return St(l)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,a=i===void 0?1:i;if(!D(e)||!D(n)||!D(r))return null;var l=(function(u){return{h:ht(u.h),s:E(u.s,0,100),v:E(u.v,0,100),a:E(u.a)}})({h:Number(e),s:Number(n),v:Number(r),a:Number(a)});return mt(l)},"hsv"]]},wt=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]},Fe=function(t){return typeof t=="string"?wt(t.trim(),Ct.string):typeof t=="object"&&t!==null?wt(t,Ct.object):[null,void 0]},et=function(t,e){var n=V(t);return{h:n.h,s:E(n.s+100*e,0,100),l:n.l,a:n.a}},nt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},_t=function(t,e){var n=V(t);return{h:n.h,s:n.s,l:E(n.l+100*e,0,100),a:n.a}},zt=(function(){function t(e){this.parsed=Fe(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 b(nt(this.rgba),2)},t.prototype.isDark=function(){return nt(this.rgba)<.5},t.prototype.isLight=function(){return nt(this.rgba)>=.5},t.prototype.toHex=function(){return e=tt(this.rgba),n=e.r,r=e.g,i=e.b,l=(a=e.a)<1?K(b(255*a)):"","#"+K(n)+K(r)+K(i)+l;var e,n,r,i,a,l},t.prototype.toRgb=function(){return tt(this.rgba)},t.prototype.toRgbString=function(){return e=tt(this.rgba),n=e.r,r=e.g,i=e.b,(a=e.a)<1?"rgba("+n+", "+r+", "+i+", "+a+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,a},t.prototype.toHsl=function(){return bt(V(this.rgba))},t.prototype.toHslString=function(){return e=bt(V(this.rgba)),n=e.h,r=e.s,i=e.l,(a=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+a+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,a},t.prototype.toHsv=function(){return e=vt(this.rgba),{h:b(e.h),s:b(e.s),v:b(e.v),a:b(e.a,3)};var e},t.prototype.invert=function(){return O({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),O(et(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),O(et(this.rgba,-e))},t.prototype.grayscale=function(){return O(et(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),O(_t(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),O(_t(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"?O({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):b(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=V(this.rgba);return typeof e=="number"?O({h:e,s:n.s,l:n.l,a:n.a}):b(n.h)},t.prototype.isEqual=function(e){return this.toHex()===O(e).toHex()},t})(),O=function(t){return t instanceof zt?t:new zt(t)};class Le{eventListeners=new Map;addEventListener(e,n,r){const i={value:n,options:r},a=this.eventListeners.get(e);return a?Array.isArray(a)?a.push(i):this.eventListeners.set(e,[a,i]):this.eventListeners.set(e,i),this}removeEventListener(e,n,r){if(!n)return this.eventListeners.delete(e),this;const i=this.eventListeners.get(e);if(!i)return this;if(Array.isArray(i)){const a=[];for(let l=0,u=i.length;l<u;l++){const f=i[l];(f.value!==n||typeof r=="object"&&r?.once&&(typeof f.options=="boolean"||!f.options?.once))&&a.push(f)}a.length?this.eventListeners.set(e,a.length===1?a[0]:a):this.eventListeners.delete(e)}else i.value===n&&(typeof r=="boolean"||!r?.once||typeof i.options=="boolean"||i.options?.once)&&this.eventListeners.delete(e);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(e){return this.eventListeners.has(e)}dispatchEvent(e,...n){const r=this.eventListeners.get(e);if(r){if(Array.isArray(r))for(let i=r.length,a=0;a<i;a++){const l=r[a];typeof l.options=="object"&&l.options?.once&&this.off(e,l.value,l.options),l.value.apply(this,n)}else typeof r.options=="object"&&r.options?.once&&this.off(e,r.value,r.options),r.value.apply(this,n);return!0}else return!1}on(e,n,r){return this.addEventListener(e,n,r)}once(e,n){return this.addEventListener(e,n,{once:!0})}off(e,n,r){return this.removeEventListener(e,n,r)}emit(e,...n){this.dispatchEvent(e,...n)}}function h(t){return t==null||t==="none"}function A(t,e=0,n=10**e){return Math.round(n*t)/n+0}function w(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>w(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=w(i,e):n[r]=i)}return n}function U(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function X(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){const n=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!n.length||n.every(r=>t[r]===e[r])}return!1}function Et(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 Ft(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 Lt(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(/^\./,""),Et(t,e.split("."),n))}function Pt(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Ft(t,e.split("."),n)}class Ot{_observers=new Map;on(e,n){let r=this._observers.get(e);return r===void 0&&this._observers.set(e,r=new Set),r.add(n),this}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};return this.on(e,r),this}off(e,n){const r=this._observers.get(e);return r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e)),this}emit(e,...n){return Array.from((this._observers.get(e)||new Map).values()).forEach(r=>r(...n)),this}destroy(){this._observers=new Map}}class Pe{_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}}const rt=Symbol("properties"),Dt=Symbol("inited");function M(t){let e;if(Object.hasOwn(t,rt))e=t[rt];else{const n=Object.getPrototypeOf(t);e=new Map(n?M(n):void 0),t[rt]=e}return e}function At(t){return`__internal:${t}`}function it(t,e={}){const n=At(t),{default:r,fallback:i,alias:a,internal:l}=e,u=()=>typeof r=="function"?r():r,f=()=>typeof i=="function"?i():i;function p(){let d;if(a&&a!==t?d=Lt(this,a):!l&&typeof this.getProperty<"u"?d=this.getProperty(t):d=this[n],d=d??f(),d===void 0&&r!==void 0&&!this[Dt]){this[Dt]=!0;const m=u();m!==void 0&&(v.call(this,m),d=m)}return d}function v(d){a&&a!==t?Pt(this,a,d):!l&&typeof this.setProperty<"u"?this.setProperty(t,d):this[n]=d}return{get:p,set:v}}function Nt(t,e,n={}){M(t).set(e,n);const r=it(e,n);Object.defineProperty(t.prototype,e,{get(){return r.get.call(this)},set(i){r.set.call(this,i)},configurable:!0,enumerable:!0})}function Oe(t){return function(e,n){if(typeof n!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");Nt(e.constructor,n,t)}}function De(t={}){return function(e,n){const r=n.name;if(typeof r!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");const i=it(r,t);return{init(a){return M(this.constructor).set(r,t),i.set.call(this,a),a},get(){return i.get.call(this)},set(a){i.set.call(this,a)}}}}class Ae extends Ot{_propertyAccessor;_properties=new Map;getProperty(e,n){return this._propertyAccessor?.getProperty?this._propertyAccessor.getProperty(e,n):this._properties.get(e)??n}setProperty(e,n){const r=this[e];Object.is(n,r)||(this._propertyAccessor?.setProperty?this._propertyAccessor.setProperty(e,n):this._properties.set(e,n),this.onUpdateProperty(e,n,r))}getPropertyDeclarations(){return M(this.constructor)}setPropertyAccessor(e){return this._propertyAccessor=e,this.getPropertyDeclarations().forEach((n,r)=>{const i=this[r],a=this._properties.get(r);i===void 0?a!==void 0&&(this[r]=a):i!==a&&(this[r]=i)}),this}onUpdateProperty(e,n,r){this._updateProperty(e,n,r),this.emit("updateProperty",e,n,r)}_updateProperty(e,n,r){}}function ot(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,O(e)}function Ne(t){return{r:A(t.r),g:A(t.g),b:A(t.b),a:A(t.a,3)}}function Y(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const T="#000000FF";function Rt(t){return ot(t).isValid()}function C(t,e=!1){const n=ot(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),T}const{r,g:i,b:a,a:l}=Ne(n.rgba);return`#${Y(r)}${Y(i)}${Y(a)}${Y(A(l*255))}`}var x=x||{};x.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(s){const c=new Error(`${e}: ${s}`);throw c.source=e,c}function r(){const s=i();return e.length>0&&n("Invalid input not EOF"),s}function i(){return j(a)}function a(){return l("linear-gradient",t.linearGradient,f)||l("repeating-linear-gradient",t.repeatingLinearGradient,f)||l("radial-gradient",t.radialGradient,d)||l("repeating-radial-gradient",t.repeatingRadialGradient,d)}function l(s,c,g){return u(c,S=>{const I=g();return I&&(y(t.comma)||n("Missing comma before color stops")),{type:s,orientation:I,colorStops:j(dt)}})}function u(s,c){const g=y(s);if(g){y(t.startCall)||n("Missing (");const S=c(g);return y(t.endCall)||n("Missing )"),S}}function f(){const s=p();if(s)return s;const c=z("position-keyword",t.positionKeywords,1);return c?{type:"directional",value:c.value}:v()}function p(){return z("directional",t.sideOrCorner,1)}function v(){return z("angular",t.angleValue,1)||z("angular",t.radianValue,1)}function d(){let s,c=m(),g;return c&&(s=[],s.push(c),g=e,y(t.comma)&&(c=m(),c?s.push(c):e=g)),s}function m(){let s=_()||N();if(s)s.at=P();else{const c=F();if(c){s=c;const g=P();g&&(s.at=g)}else{const g=P();if(g)s={type:"default-radial",at:g};else{const S=R();S&&(s={type:"default-radial",at:S})}}}return s}function _(){const s=z("shape",/^(circle)/i,0);return s&&(s.style=be()||F()),s}function N(){const s=z("shape",/^(ellipse)/i,0);return s&&(s.style=R()||Q()||F()),s}function F(){return z("extent-keyword",t.extentKeywords,1)}function P(){if(z("position",/^at/,0)){const s=R();return s||n("Missing positioning value"),s}}function R(){const s=W();if(s.x||s.y)return{type:"position",value:s}}function W(){return{x:Q(),y:Q()}}function j(s){let c=s();const g=[];if(c)for(g.push(c);y(t.comma);)c=s(),c?g.push(c):n("One extra comma");return g}function dt(){const s=Ke();return s||n("Expected color definition"),s.length=Q(),s}function Ke(){return Xe()||Je()||Ze()||xe()||Ye()||qe()||Ue()}function Ue(){return z("literal",t.literalColor,0)}function Xe(){return z("hex",t.hexColor,1)}function Ye(){return u(t.rgbColor,()=>({type:"rgb",value:j(B)}))}function xe(){return u(t.rgbaColor,()=>({type:"rgba",value:j(B)}))}function qe(){return u(t.varColor,()=>({type:"var",value:Qe()}))}function Ze(){return u(t.hslColor,()=>{y(t.percentageValue)&&n("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const c=B();y(t.comma);let g=y(t.percentageValue);const S=g?g[1]:null;y(t.comma),g=y(t.percentageValue);const I=g?g[1]:null;return(!S||!I)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[c,S,I]}})}function Je(){return u(t.hslaColor,()=>{const s=B();y(t.comma);let c=y(t.percentageValue);const g=c?c[1]:null;y(t.comma),c=y(t.percentageValue);const S=c?c[1]:null;y(t.comma);const I=B();return(!g||!S)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[s,g,S,I]}})}function Qe(){return y(t.variableName)[1]}function B(){return y(t.number)[1]}function Q(){return z("%",t.percentageValue,1)||tn()||en()||be()}function tn(){return z("position-keyword",t.positionKeywords,1)}function en(){return u(t.calcValue,()=>{let s=1,c=0;for(;s>0&&c<e.length;){const S=e.charAt(c);S==="("?s++:S===")"&&s--,c++}s>0&&n("Missing closing parenthesis in calc() expression");const g=e.substring(0,c-1);return gt(c-1),{type:"calc",value:g}})}function be(){return z("px",t.pixelValue,1)||z("em",t.emValue,1)}function z(s,c,g){const S=y(c);if(S)return{type:s,value:S[g]}}function y(s){let c,g;return g=/^\s+/.exec(e),g&&gt(g[0].length),c=s.exec(e),c&&gt(c[0].length),c}function gt(s){e=e.substr(s)}return function(s){return e=s.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}})();const It=x.parse.bind(x);var q=q||{};q.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,a){n+=t.visit(i),a<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 Re=q.stringify.bind(q);function Gt(t){const e=t.length-1;return t.map((n,r)=>{const i=n.value;let a=A(r/e,3),l="#00000000";switch(n.type){case"rgb":l=C({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":l=C({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":l=C(n.value);break;case"hex":l=C(`#${n.value}`);break}switch(n.length?.type){case"%":a=Number(n.length.value)/100;break}return{offset:a,color:l}})}function kt(t){let e=0;switch(t.orientation?.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:Gt(t.colorStops)}}function jt(t){return t.orientation?.map(e=>{switch(e?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:Gt(t.colorStops)}}function $(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function Vt(t){return It(t).map(e=>{switch(e?.type){case"linear-gradient":return kt(e);case"repeating-linear-gradient":return{...kt(e),repeat:!0};case"radial-gradient":return jt(e);case"repeating-radial-gradient":return{...jt(e),repeat:!0};default:return}}).filter(Boolean)}function Mt(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:C(e.color)}}function Tt(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=Vt(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function $t(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function Ht(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:h(e.foregroundColor)?void 0:C(e.foregroundColor),backgroundColor:h(e.backgroundColor)?void 0:C(e.backgroundColor)}}function Wt(t){return!h(t.color)}function Bt(t){return typeof t=="string"?Rt(t):Wt(t)}function Kt(t){return!h(t.image)&&$(t.image)||!!t.linearGradient||!!t.radialGradient}function Ut(t){return typeof t=="string"?$(t):Kt(t)}function Xt(t){return!h(t.image)&&!$(t.image)}function Yt(t){return typeof t=="string"?!$(t):Xt(t)}function xt(t){return!h(t.preset)}function qt(t){return typeof t=="string"?!1:xt(t)}function L(t){const e=t&&typeof t=="object"?t.enabled:void 0;return Bt(t)?w({enabled:e,...Mt(t)}):Ut(t)?w({enabled:e,...Tt(t)}):Yt(t)?w({enabled:e,...$t(t)}):qt(t)?w({enabled:e,...Ht(t)}):{}}function Zt(t){return typeof t=="string"?{...L(t)}:{...L(t),...U(t,["fillWithShape"])}}function at(){return{color:T,offsetX:0,offsetY:0,blurRadius:1}}function st(t){return{...at(),...w({...t,color:h(t.color)?T:C(t.color)})}}function Jt(){return{...at(),scaleX:1,scaleY:1}}function Qt(t){return{...Jt(),...st(t)}}function Ie(t){return t}function te(t){return w({...t,softEdge:h(t.softEdge)?void 0:t.softEdge,outerShadow:h(t.outerShadow)?void 0:Qt(t.outerShadow),innerShadow:h(t.innerShadow)?void 0:st(t.innerShadow)})}function ee(t){return typeof t=="string"?{...L(t)}:{...L(t),...U(t,["fillWithShape"])}}const Ge="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ke=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=Ge[n[t]&63];return e};const ne=()=>ke(10),re=ne;function H(t){return typeof t=="string"?{...L(t)}:{...L(t),...U(t,["width","style","lineCap","lineJoin","headEnd","tailEnd"])}}function ie(t){return typeof t=="string"?{color:C(t)}:{...t,color:h(t.color)?T:C(t.color)}}function oe(){return{boxShadow:"none"}}function ae(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 se(){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 le(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function ue(){return{...se(),...le(),...oe(),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 ce(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function fe(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function de(){return{...ce(),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 ge(){return{...fe(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function he(){return{...ge(),...de(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function k(t){return w({...t,color:h(t.color)?void 0:C(t.color),backgroundColor:h(t.backgroundColor)?void 0:C(t.backgroundColor),borderColor:h(t.borderColor)?void 0:C(t.borderColor),outlineColor:h(t.outlineColor)?void 0:C(t.outlineColor),shadowColor:h(t.shadowColor)?void 0:C(t.shadowColor)})}function je(){return{...ue(),...he()}}const lt=/\r\n|\n\r|\n|\r/,Ve=new RegExp(`${lt.source}|<br\\/>`,"g"),Me=new RegExp(`^(${lt.source})$`),ut=`
2
+ `;function Te(t){return lt.test(t)}function ct(t){return Me.test(t)}function pe(t){return t.replace(Ve,ut)}function Z(t){const e=[];function n(){return e[e.length-1]}function r(u,f,p){const v=u?k(u):{},d=f?L(f):void 0,m=p?H(p):void 0,_=w({...v,fill:d,outline:m,fragments:[]});return e[e.length-1]?.fragments.length===0?e[e.length-1]=_:e.push(_),_}function i(u="",f,p,v){const d=f?k(f):{},m=p?L(p):void 0,_=v?H(v):void 0;Array.from(u).forEach(N=>{if(ct(N)){const{fragments:F,fill:P,outline:R,...W}=n()||r();F.length||F.push(w({...d,fill:m,outline:_,content:ut})),r(W,P,R)}else{const F=n()||r(),P=F.fragments[F.fragments.length-1];if(P){const{content:R,fill:W,outline:j,...dt}=P;if(X(m,W)&&X(_,j)&&X(d,dt)){P.content=`${R}${N}`;return}}F.fragments.push(w({...d,fill:m,outline:_,content:N}))}})}(Array.isArray(t)?t:[t]).forEach(u=>{if(typeof u=="string")r(),i(u);else if(ft(u)){const{content:f,fill:p,outline:v,...d}=u;r(d,p,v),i(f)}else if(ve(u)){const{fragments:f,fill:p,outline:v,...d}=u;r(d,p,v),f.forEach(m=>{const{content:_,fill:N,outline:F,...P}=m;i(_,P,N,F)})}else Array.isArray(u)?(r(),u.forEach(f=>{if(typeof f=="string")i(f);else if(ft(f)){const{content:p,fill:v,outline:d,...m}=f;i(p,m,v,d)}})):console.warn("Failed to parse text content",u)});const l=n();return l&&!l.fragments.length&&l.fragments.push({content:""}),e}function ve(t){return t&&typeof t=="object"&&"fragments"in t&&Array.isArray(t.fragments)}function ft(t){return t&&typeof t=="object"&&"content"in t&&typeof t.content=="string"}function me(t){return typeof t=="string"||Array.isArray(t)?{content:Z(t)}:w({...t,content:Z(t.content??""),style:t.style?k(t.style):void 0,effects:t.effects?t.effects.map(e=>k(e)):void 0,measureDom:t.measureDom,fonts:t.fonts,fill:t.fill?L(t.fill):void 0,outline:t.outline?H(t.outline):void 0})}function $e(t){return Z(t).map(e=>{const n=pe(e.fragments.flatMap(r=>r.content).join(""));return ct(n)?"":n}).join(ut)}function ye(t){return typeof t=="string"?{src:t}:t}function J(t){return w({...t,id:t.id??re(),style:h(t.style)?void 0:k(t.style),text:h(t.text)?void 0:me(t.text),background:h(t.background)?void 0:Zt(t.background),shape:h(t.shape)?void 0:ae(t.shape),fill:h(t.fill)?void 0:L(t.fill),outline:h(t.outline)?void 0:H(t.outline),foreground:h(t.foreground)?void 0:ee(t.foreground),shadow:h(t.shadow)?void 0:ie(t.shadow),video:h(t.video)?void 0:ye(t.video),audio:h(t.audio)?void 0:G(t.audio),effect:h(t.effect)?void 0:te(t.effect),children:t.children?.map(e=>J(e))})}function He(t){return J(t)}function We(t){const e={};for(const n in t.children){const r=J(t.children[n]);delete r.children,e[n]=r}return{...t,children:e}}function Be(t){const{children:e,...n}=t;function r(f){const{parentId:p,childrenIds:v,...d}=f;return{...d,children:[]}}const i={},a=[],l={...n,children:a};function u(f){if(!e[f]||i[f])return;const p=e[f],v=r(p);i[f]=v;const d=p.parentId;if(d){u(d);const m=e[d],_=i[d];if(!_)return;m?.childrenIds&&_?.children&&(_.children[m.childrenIds.indexOf(f)]=v)}else a.push(v)}for(const f in e)u(f);return l}o.EventEmitter=Le,o.Observable=Ot,o.RawWeakMap=Pe,o.Reactivable=Ae,o.clearUndef=w,o.defaultColor=T,o.defineProperty=Nt,o.flatDocumentToDocument=Be,o.getDeclarations=M,o.getDefaultElementStyle=ue,o.getDefaultHighlightStyle=ce,o.getDefaultInnerShadow=at,o.getDefaultLayoutStyle=se,o.getDefaultListStyleStyle=fe,o.getDefaultOuterShadow=Jt,o.getDefaultShadowStyle=oe,o.getDefaultStyle=je,o.getDefaultTextInlineStyle=de,o.getDefaultTextLineStyle=ge,o.getDefaultTextStyle=he,o.getDefaultTransformStyle=le,o.getNestedValue=Et,o.getObjectValueByPath=Lt,o.getPropertyDescriptor=it,o.getPropertyInternalKey=At,o.hasCRLF=Te,o.idGenerator=re,o.isCRLF=ct,o.isColor=Rt,o.isColorFill=Bt,o.isColorFillObject=Wt,o.isEqualObject=X,o.isFragmentObject=ft,o.isGradient=$,o.isGradientFill=Ut,o.isGradientFillObject=Kt,o.isImageFill=Yt,o.isImageFillObject=Xt,o.isNone=h,o.isParagraphObject=ve,o.isPresetFill=qt,o.isPresetFillObject=xt,o.nanoid=ne,o.normalizeAudio=G,o.normalizeBackground=Zt,o.normalizeCRLF=pe,o.normalizeColor=C,o.normalizeColorFill=Mt,o.normalizeDocument=He,o.normalizeEffect=te,o.normalizeElement=J,o.normalizeFill=L,o.normalizeFlatDocument=We,o.normalizeForeground=ee,o.normalizeGradient=Vt,o.normalizeGradientFill=Tt,o.normalizeImageFill=$t,o.normalizeInnerShadow=st,o.normalizeOuterShadow=Qt,o.normalizeOutline=H,o.normalizePresetFill=Ht,o.normalizeShadow=ie,o.normalizeShape=ae,o.normalizeSoftEdge=Ie,o.normalizeStyle=k,o.normalizeText=me,o.normalizeTextContent=Z,o.normalizeVideo=ye,o.parseColor=ot,o.parseGradient=It,o.pick=U,o.property=Oe,o.property2=De,o.round=A,o.setNestedValue=Ft,o.setObjectValueByPath=Pt,o.stringifyGradient=Re,o.textContentToString=$e,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
package/dist/index.mjs CHANGED
@@ -187,32 +187,35 @@ function setObjectValueByPath(obj, path, value) {
187
187
 
188
188
  class Observable {
189
189
  _observers = /* @__PURE__ */ new Map();
190
- on(name, f) {
191
- let set = this._observers.get(name);
190
+ on(event, listener) {
191
+ let set = this._observers.get(event);
192
192
  if (set === void 0) {
193
- this._observers.set(name, set = /* @__PURE__ */ new Set());
193
+ this._observers.set(event, set = /* @__PURE__ */ new Set());
194
194
  }
195
- set.add(f);
196
- return f;
195
+ set.add(listener);
196
+ return this;
197
197
  }
198
- once(name, f) {
198
+ once(event, listener) {
199
199
  const _f = (...args) => {
200
- this.off(name, _f);
201
- f(...args);
200
+ this.off(event, _f);
201
+ listener(...args);
202
202
  };
203
- this.on(name, _f);
203
+ this.on(event, _f);
204
+ return this;
204
205
  }
205
- off(name, f) {
206
- const observers = this._observers.get(name);
206
+ off(event, listener) {
207
+ const observers = this._observers.get(event);
207
208
  if (observers !== void 0) {
208
- observers.delete(f);
209
+ observers.delete(listener);
209
210
  if (observers.size === 0) {
210
- this._observers.delete(name);
211
+ this._observers.delete(event);
211
212
  }
212
213
  }
214
+ return this;
213
215
  }
214
- emit(name, ...args) {
215
- return Array.from((this._observers.get(name) || /* @__PURE__ */ new Map()).values()).forEach((f) => f(...args));
216
+ emit(event, ...args) {
217
+ Array.from((this._observers.get(event) || /* @__PURE__ */ new Map()).values()).forEach((f) => f(...args));
218
+ return this;
216
219
  }
217
220
  destroy() {
218
221
  this._observers = /* @__PURE__ */ new Map();
@@ -246,6 +249,164 @@ class RawWeakMap {
246
249
  }
247
250
  }
248
251
 
252
+ const propertiesSymbol = Symbol("properties");
253
+ const initedSymbol = Symbol("inited");
254
+ function getDeclarations(constructor) {
255
+ let declarations;
256
+ if (Object.hasOwn(constructor, propertiesSymbol)) {
257
+ declarations = constructor[propertiesSymbol];
258
+ } else {
259
+ const superConstructor = Object.getPrototypeOf(constructor);
260
+ declarations = new Map(superConstructor ? getDeclarations(superConstructor) : void 0);
261
+ constructor[propertiesSymbol] = declarations;
262
+ }
263
+ return declarations;
264
+ }
265
+ function getPropertyInternalKey(key) {
266
+ return `__internal:${key}`;
267
+ }
268
+ function getPropertyDescriptor(key, declaration = {}) {
269
+ const internalKey = getPropertyInternalKey(key);
270
+ const {
271
+ default: _default,
272
+ fallback,
273
+ alias,
274
+ internal
275
+ } = declaration;
276
+ const getDefaultValue = () => {
277
+ return typeof _default === "function" ? _default() : _default;
278
+ };
279
+ const getFallbackValue = () => {
280
+ return typeof fallback === "function" ? fallback() : fallback;
281
+ };
282
+ function get() {
283
+ let result;
284
+ if (alias && alias !== key) {
285
+ result = getObjectValueByPath(this, alias);
286
+ } else if (!internal && typeof this.getProperty !== "undefined") {
287
+ result = this.getProperty(key);
288
+ } else {
289
+ result = this[internalKey];
290
+ }
291
+ result = result ?? getFallbackValue();
292
+ if (result === void 0 && _default !== void 0 && !this[initedSymbol]) {
293
+ this[initedSymbol] = true;
294
+ const defaultValue = getDefaultValue();
295
+ if (defaultValue !== void 0) {
296
+ set.call(this, defaultValue);
297
+ result = defaultValue;
298
+ }
299
+ }
300
+ return result;
301
+ }
302
+ function set(newValue) {
303
+ if (alias && alias !== key) {
304
+ setObjectValueByPath(this, alias, newValue);
305
+ } else if (!internal && typeof this.setProperty !== "undefined") {
306
+ this.setProperty(key, newValue);
307
+ } else {
308
+ this[internalKey] = newValue;
309
+ }
310
+ }
311
+ return {
312
+ get,
313
+ set
314
+ };
315
+ }
316
+ function defineProperty(constructor, key, declaration = {}) {
317
+ getDeclarations(constructor).set(key, declaration);
318
+ const descriptor = getPropertyDescriptor(key, declaration);
319
+ Object.defineProperty(constructor.prototype, key, {
320
+ get() {
321
+ return descriptor.get.call(this);
322
+ },
323
+ set(newValue) {
324
+ descriptor.set.call(this, newValue);
325
+ },
326
+ configurable: true,
327
+ enumerable: true
328
+ });
329
+ }
330
+ function property(declaration) {
331
+ return function(target, key) {
332
+ if (typeof key !== "string") {
333
+ throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
334
+ }
335
+ defineProperty(target.constructor, key, declaration);
336
+ };
337
+ }
338
+ function property2(declaration = {}) {
339
+ return function(_, context) {
340
+ const key = context.name;
341
+ if (typeof key !== "string") {
342
+ throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
343
+ }
344
+ const descriptor = getPropertyDescriptor(key, declaration);
345
+ return {
346
+ init(v) {
347
+ getDeclarations(this.constructor).set(key, declaration);
348
+ descriptor.set.call(this, v);
349
+ return v;
350
+ },
351
+ get() {
352
+ return descriptor.get.call(this);
353
+ },
354
+ set(newValue) {
355
+ descriptor.set.call(this, newValue);
356
+ }
357
+ };
358
+ };
359
+ }
360
+
361
+ class Reactivable extends Observable {
362
+ _propertyAccessor;
363
+ _properties = /* @__PURE__ */ new Map();
364
+ getProperty(key, defaultValue) {
365
+ if (this._propertyAccessor?.getProperty) {
366
+ return this._propertyAccessor.getProperty(key, defaultValue);
367
+ } else {
368
+ return this._properties.get(key) ?? defaultValue;
369
+ }
370
+ }
371
+ setProperty(key, newValue) {
372
+ const oldValue = this[key];
373
+ if (Object.is(newValue, oldValue)) {
374
+ return;
375
+ }
376
+ if (this._propertyAccessor?.setProperty) {
377
+ this._propertyAccessor.setProperty(key, newValue);
378
+ } else {
379
+ this._properties.set(key, newValue);
380
+ }
381
+ this.onUpdateProperty(key, newValue, oldValue);
382
+ }
383
+ getPropertyDeclarations() {
384
+ return getDeclarations(this.constructor);
385
+ }
386
+ setPropertyAccessor(accessor) {
387
+ this._propertyAccessor = accessor;
388
+ this.getPropertyDeclarations().forEach((_declaration, key) => {
389
+ const newValue = this[key];
390
+ const oldValue = this._properties.get(key);
391
+ if (newValue === void 0) {
392
+ if (oldValue !== void 0) {
393
+ this[key] = oldValue;
394
+ }
395
+ } else if (newValue !== oldValue) {
396
+ this[key] = newValue;
397
+ }
398
+ });
399
+ return this;
400
+ }
401
+ onUpdateProperty(key, newValue, oldValue) {
402
+ this._updateProperty(key, newValue, oldValue);
403
+ this.emit("updateProperty", key, newValue, oldValue);
404
+ }
405
+ // eslint-disable-next-line unused-imports/no-unused-vars
406
+ _updateProperty(key, newValue, oldValue) {
407
+ }
408
+ }
409
+
249
410
  function parseColor(color) {
250
411
  let input;
251
412
  if (typeof color === "number") {
@@ -1005,120 +1166,6 @@ function normalizeBackground(background) {
1005
1166
  }
1006
1167
  }
1007
1168
 
1008
- const propertiesSymbol = Symbol("properties");
1009
- const defaultValueInitedSymbol = Symbol("defaultValueInited");
1010
- function getDeclarations(constructor) {
1011
- let declarations;
1012
- if (Object.hasOwn(constructor, propertiesSymbol)) {
1013
- declarations = constructor[propertiesSymbol];
1014
- } else {
1015
- const superConstructor = Object.getPrototypeOf(constructor);
1016
- declarations = new Map(superConstructor ? getDeclarations(superConstructor) : void 0);
1017
- constructor[propertiesSymbol] = declarations;
1018
- }
1019
- return declarations;
1020
- }
1021
- function getPropertyDescriptor(key, declaration = {}) {
1022
- const internalKey = Symbol.for(key);
1023
- const {
1024
- default: _default,
1025
- fallback,
1026
- alias
1027
- } = declaration;
1028
- const ctx = { declaration, internalKey };
1029
- const getDefaultValue = () => {
1030
- return typeof _default === "function" ? _default() : _default;
1031
- };
1032
- const getFallbackValue = () => {
1033
- return typeof fallback === "function" ? fallback() : fallback;
1034
- };
1035
- function get() {
1036
- let result;
1037
- if (alias && alias !== key) {
1038
- result = getObjectValueByPath(this, alias);
1039
- } else {
1040
- if (typeof this.getter !== "undefined") {
1041
- result = this.getter(key, ctx);
1042
- } else {
1043
- result = this[internalKey];
1044
- }
1045
- }
1046
- result = result ?? getFallbackValue();
1047
- if (result === void 0 && _default !== void 0 && !this[defaultValueInitedSymbol]) {
1048
- this[defaultValueInitedSymbol] = true;
1049
- const defaultValue = getDefaultValue();
1050
- if (defaultValue !== void 0) {
1051
- set.call(this, defaultValue);
1052
- result = defaultValue;
1053
- }
1054
- }
1055
- return result;
1056
- }
1057
- function set(newValue) {
1058
- if (alias && alias !== key) {
1059
- setObjectValueByPath(this, alias, newValue);
1060
- } else {
1061
- if (typeof this.setter !== "undefined") {
1062
- this.setter(key, newValue, ctx);
1063
- } else {
1064
- this[internalKey] = newValue;
1065
- }
1066
- }
1067
- }
1068
- return {
1069
- get,
1070
- set
1071
- };
1072
- }
1073
- function defineProperty(constructor, key, declaration = {}) {
1074
- getDeclarations(constructor).set(key, declaration);
1075
- const descriptor = getPropertyDescriptor(key, declaration);
1076
- Object.defineProperty(constructor.prototype, key, {
1077
- get() {
1078
- return descriptor.get.call(this);
1079
- },
1080
- set(newValue) {
1081
- const oldValue = descriptor.get.call(this);
1082
- descriptor.set.call(this, newValue);
1083
- this.onUpdateProperty?.(key, newValue, oldValue, declaration);
1084
- },
1085
- configurable: true,
1086
- enumerable: true
1087
- });
1088
- }
1089
- function property(declaration) {
1090
- return function(target, key) {
1091
- if (typeof key !== "string") {
1092
- throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
1093
- }
1094
- defineProperty(target.constructor, key, declaration);
1095
- };
1096
- }
1097
- function property2(declaration = {}) {
1098
- return function(_, context) {
1099
- const key = context.name;
1100
- if (typeof key !== "string") {
1101
- throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
1102
- }
1103
- const descriptor = getPropertyDescriptor(key, declaration);
1104
- return {
1105
- init(v) {
1106
- getDeclarations(this.constructor).set(key, declaration);
1107
- descriptor.set.call(this, v);
1108
- return v;
1109
- },
1110
- get() {
1111
- return descriptor.get.call(this);
1112
- },
1113
- set(newValue) {
1114
- const oldValue = descriptor.get?.call(this);
1115
- descriptor.set.call(this, newValue);
1116
- this.onUpdateProperty?.(key, newValue, oldValue, declaration);
1117
- }
1118
- };
1119
- };
1120
- }
1121
-
1122
1169
  function getDefaultInnerShadow() {
1123
1170
  return {
1124
1171
  color: defaultColor,
@@ -1645,4 +1692,4 @@ function flatDocumentToDocument(flatDoc) {
1645
1692
  return doc;
1646
1693
  }
1647
1694
 
1648
- export { EventEmitter, Observable, RawWeakMap, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
1695
+ export { EventEmitter, Observable, RawWeakMap, Reactivable, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, getPropertyInternalKey, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-idoc",
3
3
  "type": "module",
4
- "version": "0.8.10",
4
+ "version": "0.9.0",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "Intermediate document for modern codec libs",
7
7
  "author": "wxm",