modern-idoc 0.6.0 → 0.6.2

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.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Colord } from 'colord';
2
2
 
3
- interface AudioDeclaration {
3
+ interface NormalizedAudio {
4
4
  src: string;
5
5
  }
6
- type AudioProperty = string | AudioDeclaration;
7
- declare function normalizeAudio(audio: AudioProperty): AudioDeclaration | undefined;
6
+ type Audio = string | NormalizedAudio;
7
+ declare function normalizeAudio(audio: Audio): NormalizedAudio | undefined;
8
8
 
9
9
  interface RgbColor {
10
10
  r: number;
@@ -64,14 +64,15 @@ type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | Hsva
64
64
  type Uint32Color = number;
65
65
  type Color = Uint32Color | ObjectColor | string;
66
66
  type Hex8Color = string;
67
- type ColorDeclaration = Hex8Color;
67
+ type NormalizedColor = Hex8Color;
68
68
  declare function parseColor(color: Color): Colord;
69
- declare const defaultColor: ColorDeclaration;
70
- declare function normalizeColor(color: Color, orFail?: boolean): ColorDeclaration;
69
+ declare const defaultColor: NormalizedColor;
70
+ declare function isColor(value: string): boolean;
71
+ declare function normalizeColor(color: Color, orFail?: boolean): NormalizedColor;
71
72
 
72
73
  interface ColorStop {
73
74
  offset: number;
74
- color: ColorDeclaration;
75
+ color: NormalizedColor;
75
76
  }
76
77
  interface LinearGradient {
77
78
  type: 'linear-gradient';
@@ -84,6 +85,7 @@ interface RadialGradient {
84
85
  stops: ColorStop[];
85
86
  repeat?: boolean;
86
87
  }
88
+ declare function isGradient(cssText: string): boolean;
87
89
  declare function normalizeGradient(cssText: string): (LinearGradient | RadialGradient)[];
88
90
 
89
91
  interface LinearGradientNode {
@@ -208,22 +210,32 @@ type GradientNode = LinearGradientNode | RepeatingLinearGradientNode | RadialGra
208
210
  declare function parseGradient(cssText: string): GradientNode[]
209
211
  declare function stringifyGradient(ast: GradientNode[]): string
210
212
 
211
- type None = undefined | null | 'none';
212
- type WithNone<T> = T | None;
213
-
214
- interface GradientFillDeclaration {
213
+ interface ColorFillObject {
214
+ color: Color;
215
215
  }
216
+ type ColorFill = string | ColorFillObject;
217
+ interface NormalizedColorFill {
218
+ color: NormalizedColor;
219
+ }
220
+ declare function normalizeColorFill(fill: ColorFill): NormalizedColorFill;
216
221
 
217
- interface SolidFillDeclaration {
218
- color: ColorDeclaration;
222
+ interface GradientFillObject {
223
+ image: string;
219
224
  }
225
+ type GradientFill = string | GradientFillObject;
226
+ interface NormalizedGradientFill {
227
+ linearGradient?: LinearGradient;
228
+ radialGradient?: RadialGradient;
229
+ rotateWithShape?: boolean;
230
+ }
231
+ declare function normalizeGradientFill(fill: GradientFill): NormalizedGradientFill;
220
232
 
221
233
  /**
222
234
  * 0 -0.5 0
223
235
  * -0.5 -0.5
224
236
  * 0 -0.5 0
225
237
  */
226
- interface TextureFillSourceRect {
238
+ interface ImageFillCropRect {
227
239
  left?: number;
228
240
  top?: number;
229
241
  bottom?: number;
@@ -234,16 +246,13 @@ interface TextureFillSourceRect {
234
246
  * 0.5 0.5
235
247
  * 0 0.5 0
236
248
  */
237
- interface TextureFillStretchRect {
249
+ interface ImageFillStretchRect {
238
250
  left?: number;
239
251
  top?: number;
240
252
  bottom?: number;
241
253
  right?: number;
242
254
  }
243
- interface TextureFillStretch {
244
- rect?: TextureFillStretchRect;
245
- }
246
- interface TextureFillTile {
255
+ interface ImageFillTile {
247
256
  alignment?: string;
248
257
  scaleX?: number;
249
258
  scaleY?: number;
@@ -251,123 +260,102 @@ interface TextureFillTile {
251
260
  translateY?: number;
252
261
  flip?: string;
253
262
  }
254
- type TextureFillSourceURL = string;
255
- interface TextureFillDeclaration {
256
- src: TextureFillSourceURL;
257
- srcRect?: TextureFillSourceRect;
263
+ interface ImageFillObject {
264
+ image: string;
265
+ cropRect?: ImageFillCropRect;
266
+ stretchRect?: ImageFillStretchRect;
267
+ tile?: ImageFillTile;
258
268
  dpi?: number;
259
- stretch?: TextureFillStretch;
260
- tile?: TextureFillTile;
261
269
  opacity?: number;
262
270
  rotateWithShape?: boolean;
263
271
  }
272
+ interface NormalizedImageFill extends ImageFillObject {
273
+ }
274
+ declare function normalizeImageFill(fill: ImageFillObject): NormalizedImageFill;
264
275
 
265
- type FillDeclaration = Partial<TextureFillDeclaration> & Partial<SolidFillDeclaration> & Partial<GradientFillDeclaration>;
266
- type FillPropertyObject = FillDeclaration & {
267
- color: WithNone<Color>;
268
- };
269
- type FillProperty = string | FillPropertyObject;
270
- declare function normalizeFill(fill: FillProperty): FillDeclaration | undefined;
276
+ type None = undefined | null | 'none';
277
+ type WithNone<T> = T | None;
271
278
 
272
- interface BaseBackgroundDeclaration {
273
- withGeometry?: boolean;
279
+ interface PresetFillObject {
280
+ preset: string;
281
+ foregroundColor?: WithNone<Color>;
282
+ backgroundColor?: WithNone<Color>;
283
+ }
284
+ type PresetFill = string | PresetFillObject;
285
+ interface NormalizedPresetFill extends PresetFillObject {
286
+ foregroundColor?: NormalizedColor;
287
+ backgroundColor?: NormalizedColor;
274
288
  }
275
- type BackgroundDeclaration = BaseBackgroundDeclaration & FillDeclaration;
276
- type BackgroundPropertyObject = BaseBackgroundDeclaration & FillPropertyObject;
277
- type BackgroundProperty = string | BackgroundPropertyObject;
278
- declare function normalizeBackground(background: BackgroundProperty): BackgroundDeclaration;
289
+ declare function normalizePresetFill(fill: PresetFill): NormalizedPresetFill;
279
290
 
280
- interface InnerShadowDeclaration {
281
- color: ColorDeclaration;
291
+ type FillObject = Partial<ColorFillObject> & Partial<GradientFillObject> & Partial<ImageFillObject> & Partial<PresetFillObject>;
292
+ type Fill = string | FillObject;
293
+ type NormalizedFill = Partial<NormalizedColorFill> & Partial<NormalizedGradientFill> & Partial<NormalizedImageFill> & Partial<NormalizedPresetFill>;
294
+ declare function normalizeFill(fill: Fill): NormalizedFill;
295
+
296
+ interface NormalizedBaseBackground {
297
+ fillWithShape: boolean;
298
+ }
299
+ type NormalizedBackground = NormalizedBaseBackground & NormalizedFill;
300
+ type BackgroundObject = Partial<NormalizedBaseBackground> & FillObject;
301
+ type Background = string | BackgroundObject;
302
+ declare function normalizeBackground(background: Background): NormalizedBackground;
303
+
304
+ interface NormalizedInnerShadow {
305
+ color: NormalizedColor;
282
306
  offsetX: number;
283
307
  offsetY: number;
284
308
  blurRadius: number;
285
309
  }
286
- type InnerShadowPropertyObject = Partial<InnerShadowDeclaration> & {
310
+ type InnerShadowObject = Partial<NormalizedInnerShadow> & {
287
311
  color: WithNone<Color>;
288
312
  };
289
- type InnerShadowProperty = InnerShadowPropertyObject;
290
- declare function getDefaultInnerShadow(): InnerShadowDeclaration;
291
- declare function normalizeInnerShadow(shadow: InnerShadowProperty): InnerShadowDeclaration;
313
+ type InnerShadow = InnerShadowObject;
314
+ declare function getDefaultInnerShadow(): NormalizedInnerShadow;
315
+ declare function normalizeInnerShadow(shadow: InnerShadow): NormalizedInnerShadow;
292
316
 
293
- interface BaseOuterShadowDeclaration {
317
+ interface NormalizedBaseOuterShadow {
294
318
  scaleX: number;
295
319
  scaleY: number;
296
320
  }
297
- type OuterShadowDeclaration = BaseOuterShadowDeclaration & InnerShadowDeclaration;
298
- type OuterShadowPropertyObject = Partial<BaseOuterShadowDeclaration> & InnerShadowPropertyObject;
299
- type OuterShadowProperty = OuterShadowPropertyObject;
300
- declare function getDefaultOuterShadow(): OuterShadowDeclaration;
301
- declare function normalizeOuterShadow(shadow: OuterShadowProperty): OuterShadowDeclaration;
321
+ type NormalizedOuterShadow = NormalizedBaseOuterShadow & NormalizedInnerShadow;
322
+ type OuterShadowObject = Partial<NormalizedBaseOuterShadow> & InnerShadowObject;
323
+ type OuterShadow = OuterShadowObject;
324
+ declare function getDefaultOuterShadow(): NormalizedOuterShadow;
325
+ declare function normalizeOuterShadow(shadow: OuterShadow): NormalizedOuterShadow;
302
326
 
303
- interface SoftEdgeDeclaration {
327
+ interface NormalizedSoftEdge {
304
328
  radius: number;
305
329
  }
306
- type SoftEdgeProperty = SoftEdgeDeclaration;
307
- declare function normalizeSoftEdge(softEdge: SoftEdgeProperty): SoftEdgeDeclaration;
330
+ type SoftEdge = NormalizedSoftEdge;
331
+ declare function normalizeSoftEdge(softEdge: SoftEdge): NormalizedSoftEdge;
308
332
 
309
- interface EffectDeclaration {
310
- innerShadow?: InnerShadowDeclaration;
311
- outerShadow?: OuterShadowDeclaration;
312
- softEdge?: SoftEdgeDeclaration;
313
- }
314
- interface EffectPropertyObject {
315
- innerShadow: WithNone<InnerShadowProperty>;
316
- outerShadow: WithNone<OuterShadowProperty>;
317
- softEdge: WithNone<SoftEdgeProperty>;
333
+ interface NormalizedEffect {
334
+ innerShadow?: NormalizedInnerShadow;
335
+ outerShadow?: NormalizedOuterShadow;
336
+ softEdge?: NormalizedSoftEdge;
318
337
  }
319
- type EffectProperty = EffectPropertyObject;
320
- declare function normalizeEffect(effect: EffectProperty): EffectDeclaration;
321
-
322
- interface BaseForegroundDeclaration {
323
- withGeometry?: boolean;
338
+ interface EffectObject {
339
+ innerShadow: WithNone<InnerShadow>;
340
+ outerShadow: WithNone<OuterShadow>;
341
+ softEdge: WithNone<SoftEdge>;
324
342
  }
325
- type ForegroundDeclaration = BaseForegroundDeclaration & FillDeclaration;
326
- type ForegroundPropertyObject = BaseForegroundDeclaration & FillPropertyObject;
327
- type ForegroundProperty = string | ForegroundPropertyObject;
328
- declare function normalizeForeground(foreground: ForegroundProperty): ForegroundDeclaration | undefined;
343
+ type Effect = EffectObject;
344
+ declare function normalizeEffect(effect: Effect): NormalizedEffect;
329
345
 
330
- type SVGPathData = string;
331
- type FillRule = 'nonzero' | 'evenodd';
332
- type StrokeLinecap = 'butt' | 'round' | 'square';
333
- type StrokeLinejoin = 'arcs' | 'bevel' | 'miter' | 'miter-clip' | 'round';
334
- interface GeometryPathStyle {
335
- [key: string]: any;
336
- opacity: number;
337
- visibility: string;
338
- shadowColor: ColorDeclaration;
339
- shadowOffsetX: number;
340
- shadowOffsetY: number;
341
- shadowBlur: number;
342
- fill: string;
343
- fillOpacity: number;
344
- fillRule: FillRule;
345
- stroke: string;
346
- strokeOpacity: number;
347
- strokeWidth: number;
348
- strokeLinecap: StrokeLinecap;
349
- strokeLinejoin: StrokeLinejoin;
350
- strokeMiterlimit: number;
351
- strokeDasharray: number[];
352
- strokeDashoffset: number;
353
- }
354
- interface GeometryPathDeclaration extends Partial<GeometryPathStyle> {
355
- data: SVGPathData;
356
- }
357
- interface GeometryDeclaration {
358
- name?: string;
359
- svg?: string;
360
- viewBox?: number[];
361
- paths?: GeometryPathDeclaration[];
346
+ interface NormalizedBaseForeground {
347
+ fillWithShape: boolean;
362
348
  }
363
- type GeometryProperty = SVGPathData | SVGPathData[] | GeometryPathDeclaration[] | GeometryDeclaration;
364
- declare function normalizeGeometry(geometry: GeometryProperty): GeometryDeclaration;
349
+ type NormalizedForeground = NormalizedBaseForeground & NormalizedFill;
350
+ type ForegroundObject = Partial<NormalizedBaseForeground> & FillObject;
351
+ type Foreground = string | ForegroundObject;
352
+ declare function normalizeForeground(foreground: Foreground): NormalizedForeground | undefined;
365
353
 
366
- interface MetaProperty {
354
+ interface Meta {
367
355
  [key: string]: any;
368
356
  }
369
357
 
370
- interface Node<T = MetaProperty> {
358
+ interface Node<T = Meta> {
371
359
  name?: string;
372
360
  children?: Node[];
373
361
  meta?: T;
@@ -388,41 +376,76 @@ interface TailEnd {
388
376
  height?: WithNone<LineEndSize>;
389
377
  }
390
378
 
391
- type OutlineFillDeclaration = Partial<SolidFillDeclaration> & Partial<GradientFillDeclaration>;
379
+ type NormalizedOutlineFill = Partial<NormalizedColorFill> & Partial<NormalizedGradientFill>;
392
380
  type OutlineStyle = 'dashed' | 'solid' | string;
393
- interface OutlineDeclaration extends OutlineFillDeclaration {
381
+ interface NormalizedOutline extends NormalizedOutlineFill {
394
382
  width?: number;
395
- color?: ColorDeclaration;
383
+ color?: NormalizedColor;
396
384
  style?: OutlineStyle;
397
385
  headEnd?: HeadEnd;
398
386
  tailEnd?: TailEnd;
399
387
  }
400
- type OutlinePropertyObject = Partial<OutlineDeclaration> & {
388
+ type OutlineObject = Partial<NormalizedOutline> & {
401
389
  color: WithNone<Color>;
402
390
  };
403
- type OutlineProperty = string | OutlinePropertyObject;
404
- declare function normalizeOutline(outline: OutlineProperty): OutlineDeclaration;
391
+ type Outline = string | OutlineObject;
392
+ declare function normalizeOutline(outline: Outline): NormalizedOutline;
405
393
 
406
394
  type BoxShadow = string;
407
- interface ShadowDeclaration {
408
- color: ColorDeclaration;
395
+ interface NormalizedShadow {
396
+ color: NormalizedColor;
409
397
  offsetX?: number;
410
398
  offsetY?: number;
411
399
  blur?: number;
412
400
  }
413
- type ShadowPropertyObject = Partial<ShadowDeclaration> & {
401
+ type ShadowObject = Partial<NormalizedShadow> & {
414
402
  color: WithNone<Color>;
415
403
  };
416
- type ShadowProperty = BoxShadow | ShadowPropertyObject;
417
- declare function normalizeShadow(shadow: ShadowProperty): ShadowDeclaration;
418
- interface ShadowStyleDeclaration {
404
+ type Shadow = BoxShadow | ShadowObject;
405
+ declare function normalizeShadow(shadow: Shadow): NormalizedShadow;
406
+ interface NormalizedShadowStyle {
419
407
  boxShadow: BoxShadow;
420
- shadowColor?: ColorDeclaration;
408
+ shadowColor?: NormalizedColor;
421
409
  shadowOffsetX?: number;
422
410
  shadowOffsetY?: number;
423
411
  shadowBlur?: number;
424
412
  }
425
- declare function getDefaultShadowStyle(): ShadowStyleDeclaration;
413
+ declare function getDefaultShadowStyle(): NormalizedShadowStyle;
414
+
415
+ type SVGPathData = string;
416
+ type FillRule = 'nonzero' | 'evenodd';
417
+ type StrokeLinecap = 'butt' | 'round' | 'square';
418
+ type StrokeLinejoin = 'arcs' | 'bevel' | 'miter' | 'miter-clip' | 'round';
419
+ interface ShapePathStyle {
420
+ [key: string]: any;
421
+ opacity: number;
422
+ visibility: string;
423
+ shadowColor: NormalizedColor;
424
+ shadowOffsetX: number;
425
+ shadowOffsetY: number;
426
+ shadowBlur: number;
427
+ fill: string;
428
+ fillOpacity: number;
429
+ fillRule: FillRule;
430
+ stroke: string;
431
+ strokeOpacity: number;
432
+ strokeWidth: number;
433
+ strokeLinecap: StrokeLinecap;
434
+ strokeLinejoin: StrokeLinejoin;
435
+ strokeMiterlimit: number;
436
+ strokeDasharray: number[];
437
+ strokeDashoffset: number;
438
+ }
439
+ interface ShapePath extends Partial<ShapePathStyle> {
440
+ data: SVGPathData;
441
+ }
442
+ interface NormalizedShape {
443
+ preset?: string;
444
+ viewBox?: number[];
445
+ paths?: ShapePath[];
446
+ }
447
+ type Shape = SVGPathData | SVGPathData[] | ShapePath[] | NormalizedShape;
448
+ declare function normalizeShape(shape: Shape): NormalizedShape;
426
449
 
427
450
  type StyleUnit = `${number}%` | number;
428
451
  type Display = 'flex' | 'contents';
@@ -459,7 +482,7 @@ type HighlightColormap = WithNone<Record<string, string>>;
459
482
  type HighlightSize = StyleUnit | `${number}rem` | 'cover';
460
483
  type HighlightThickness = StyleUnit;
461
484
 
462
- interface LayoutStyleDeclaration {
485
+ interface NormalizedLayoutStyle {
463
486
  overflow: Overflow;
464
487
  direction: Direction;
465
488
  display: Display;
@@ -503,9 +526,9 @@ interface LayoutStyleDeclaration {
503
526
  paddingBottom: StyleUnit;
504
527
  padding: StyleUnit;
505
528
  }
506
- declare function getDefaultLayoutStyle(): Partial<LayoutStyleDeclaration>;
529
+ declare function getDefaultLayoutStyle(): Partial<NormalizedLayoutStyle>;
507
530
 
508
- interface TransformStyleDeclaration {
531
+ interface NormalizedTransformStyle {
509
532
  rotate: number;
510
533
  scaleX: number;
511
534
  scaleY: number;
@@ -516,20 +539,20 @@ interface TransformStyleDeclaration {
516
539
  transform: WithNone<string>;
517
540
  transformOrigin: string;
518
541
  }
519
- declare function getDefaultTransformStyle(): TransformStyleDeclaration;
542
+ declare function getDefaultTransformStyle(): NormalizedTransformStyle;
520
543
 
521
544
  type BackgroundSize = 'contain' | 'cover' | string | 'stretch' | 'rigid';
522
- type ElementStyleDeclaration = Partial<LayoutStyleDeclaration> & TransformStyleDeclaration & ShadowStyleDeclaration & {
545
+ type NormalizedElementStyle = Partial<NormalizedLayoutStyle> & NormalizedTransformStyle & NormalizedShadowStyle & {
523
546
  backgroundImage: WithNone<string>;
524
547
  backgroundSize: BackgroundSize;
525
- backgroundColor: WithNone<ColorDeclaration>;
548
+ backgroundColor: WithNone<NormalizedColor>;
526
549
  backgroundColormap: WithNone<Record<string, string>>;
527
550
  borderRadius: number;
528
- borderColor: WithNone<ColorDeclaration>;
551
+ borderColor: WithNone<NormalizedColor>;
529
552
  borderStyle: BorderStyle;
530
553
  outlineWidth: number;
531
554
  outlineOffset: number;
532
- outlineColor: WithNone<ColorDeclaration>;
555
+ outlineColor: WithNone<NormalizedColor>;
533
556
  outlineStyle: string;
534
557
  visibility: Visibility;
535
558
  filter: string;
@@ -537,9 +560,9 @@ type ElementStyleDeclaration = Partial<LayoutStyleDeclaration> & TransformStyleD
537
560
  pointerEvents: PointerEvents;
538
561
  maskImage: WithNone<string>;
539
562
  };
540
- declare function getDefaultElementStyle(): ElementStyleDeclaration;
563
+ declare function getDefaultElementStyle(): NormalizedElementStyle;
541
564
 
542
- interface HighlightDeclaration {
565
+ interface NormalizedHighlight {
543
566
  image: HighlightImage;
544
567
  referImage: HighlightReferImage;
545
568
  colormap: HighlightColormap;
@@ -547,8 +570,8 @@ interface HighlightDeclaration {
547
570
  size: HighlightSize;
548
571
  thickness: HighlightThickness;
549
572
  }
550
- interface HighlightStyleDeclaration {
551
- highlight: Partial<HighlightDeclaration>;
573
+ interface NormalizedHighlightStyle {
574
+ highlight: Partial<NormalizedHighlight>;
552
575
  highlightImage: HighlightImage;
553
576
  highlightReferImage: HighlightReferImage;
554
577
  highlightColormap: HighlightColormap;
@@ -556,27 +579,27 @@ interface HighlightStyleDeclaration {
556
579
  highlightSize: HighlightSize;
557
580
  highlightThickness: HighlightThickness;
558
581
  }
559
- declare function getDefaultHighlightStyle(): Required<HighlightStyleDeclaration>;
582
+ declare function getDefaultHighlightStyle(): Required<NormalizedHighlightStyle>;
560
583
 
561
- interface ListStyleDeclaration {
584
+ interface NormalizedListStyle {
562
585
  type: ListStyleType;
563
586
  image: ListStyleImage;
564
587
  colormap: ListStyleColormap;
565
588
  size: ListStyleSize;
566
589
  position: ListStylePosition;
567
590
  }
568
- interface ListStyleStyleDeclaration {
569
- listStyle: Partial<ListStyleDeclaration>;
591
+ interface NormalizedListStyleStyle {
592
+ listStyle: Partial<NormalizedListStyle>;
570
593
  listStyleType: ListStyleType;
571
594
  listStyleImage: ListStyleImage;
572
595
  listStyleColormap: ListStyleColormap;
573
596
  listStyleSize: ListStyleSize;
574
597
  listStylePosition: ListStylePosition;
575
598
  }
576
- declare function getDefaultListStyleStyle(): ListStyleStyleDeclaration;
599
+ declare function getDefaultListStyleStyle(): NormalizedListStyleStyle;
577
600
 
578
- type TextInlineStyleDeclaration = HighlightStyleDeclaration & {
579
- color: ColorDeclaration;
601
+ type NormalizedTextInlineStyle = NormalizedHighlightStyle & {
602
+ color: NormalizedColor;
580
603
  verticalAlign: VerticalAlign;
581
604
  letterSpacing: number;
582
605
  wordSpacing: number;
@@ -589,104 +612,105 @@ type TextInlineStyleDeclaration = HighlightStyleDeclaration & {
589
612
  textOrientation: TextOrientation;
590
613
  textDecoration: TextDecoration;
591
614
  };
592
- declare function getDefaultTextInlineStyle(): Required<TextInlineStyleDeclaration>;
615
+ declare function getDefaultTextInlineStyle(): Required<NormalizedTextInlineStyle>;
593
616
 
594
- type TextLineStyleDeclaration = ListStyleStyleDeclaration & {
617
+ type NormalizedTextLineStyle = NormalizedListStyleStyle & {
595
618
  writingMode: WritingMode;
596
619
  textWrap: TextWrap;
597
620
  textAlign: TextAlign;
598
621
  textIndent: number;
599
622
  lineHeight: number;
600
623
  };
601
- declare function getDefaultTextLineStyle(): TextLineStyleDeclaration;
624
+ declare function getDefaultTextLineStyle(): NormalizedTextLineStyle;
602
625
 
603
- interface TextDrawStyleDeclaration {
626
+ interface NormalizedTextDrawStyle {
604
627
  textStrokeWidth: number;
605
- textStrokeColor: ColorDeclaration;
628
+ textStrokeColor: NormalizedColor;
606
629
  }
607
- type TextStyleDeclaration = TextLineStyleDeclaration & TextInlineStyleDeclaration & TextDrawStyleDeclaration;
608
- declare function getDefaultTextStyle(): Required<TextStyleDeclaration>;
630
+ type NormalizedTextStyle = NormalizedTextLineStyle & NormalizedTextInlineStyle & NormalizedTextDrawStyle;
631
+ declare function getDefaultTextStyle(): Required<NormalizedTextStyle>;
609
632
 
610
- interface StyleDeclaration extends TextStyleDeclaration, ElementStyleDeclaration {
633
+ interface NormalizedStyle extends NormalizedTextStyle, NormalizedElementStyle {
611
634
  }
612
- type StylePropertyObject = Partial<StyleDeclaration> & {
635
+ type StyleObject = Partial<NormalizedStyle> & {
613
636
  color?: WithNone<Color>;
614
637
  backgroundColor?: WithNone<Color>;
615
638
  borderColor?: WithNone<Color>;
616
639
  outlineColor?: WithNone<Color>;
617
640
  shadowColor?: WithNone<Color>;
618
641
  };
619
- type StyleProperty = StylePropertyObject;
620
- declare function normalizeStyle(style: StyleProperty): Partial<StyleDeclaration>;
621
- declare function getDefaultStyle(): StyleDeclaration;
642
+ type Style = StyleObject;
643
+ declare function normalizeStyle(style: Style): Partial<NormalizedStyle>;
644
+ declare function getDefaultStyle(): NormalizedStyle;
622
645
 
623
- interface FragmentContent extends StylePropertyObject {
646
+ interface FragmentContent extends StyleObject {
624
647
  content: string;
625
648
  }
626
- interface ParagraphContent extends StylePropertyObject {
649
+ interface ParagraphContent extends StyleObject {
627
650
  fragments: FragmentContent[];
628
651
  }
629
652
  type TextContentFlat = string | FragmentContent | ParagraphContent | (string | FragmentContent)[];
630
653
  type TextContent = string | FragmentContent | ParagraphContent | TextContentFlat[];
631
- type TextContentDeclaration = (ParagraphContent & StylePropertyObject)[];
632
- interface TextDeclaration {
633
- content: TextContentDeclaration;
634
- effects?: StylePropertyObject[];
654
+ type NormalizedTextContent = (ParagraphContent & StyleObject)[];
655
+ interface NormalizedText {
656
+ content: NormalizedTextContent;
657
+ effects?: StyleObject[];
635
658
  measureDom?: any;
636
659
  fonts?: any;
637
660
  }
638
- type TextProperty = string | TextContent | (TextDeclaration & {
661
+ type Text = string | TextContent | (NormalizedText & {
639
662
  content: TextContent;
640
- }) | TextDeclaration;
641
- declare function normalizeTextContent(content?: TextContent): TextContentDeclaration;
642
- declare function normalizeText(text: TextProperty): TextDeclaration;
663
+ }) | NormalizedText;
664
+ declare function normalizeTextContent(content?: TextContent): NormalizedTextContent;
665
+ declare function normalizeText(text: Text): NormalizedText;
643
666
 
644
- interface VideoDeclaration {
667
+ interface NormalizedVideo {
645
668
  src: string;
646
669
  }
647
- type VideoProperty = string | VideoDeclaration;
648
- declare function normalizeVideo(video: VideoProperty): VideoDeclaration | undefined;
649
-
650
- interface Element<T = MetaProperty> extends Node<T> {
651
- style?: WithNone<StyleProperty>;
652
- text?: WithNone<TextProperty>;
653
- background?: WithNone<BackgroundProperty>;
654
- geometry?: WithNone<GeometryProperty>;
655
- fill?: WithNone<FillProperty>;
656
- outline?: WithNone<OutlineProperty>;
657
- foreground?: WithNone<ForegroundProperty>;
658
- shadow?: WithNone<ShadowProperty>;
659
- video?: WithNone<VideoProperty>;
660
- audio?: WithNone<AudioProperty>;
661
- effect?: WithNone<EffectProperty>;
670
+ type Video = string | NormalizedVideo;
671
+ declare function normalizeVideo(video: Video): NormalizedVideo | undefined;
672
+
673
+ interface Element<T = Meta> extends Node<T> {
674
+ style?: WithNone<Style>;
675
+ text?: WithNone<Text>;
676
+ background?: WithNone<Background>;
677
+ shape?: WithNone<Shape>;
678
+ fill?: WithNone<Fill>;
679
+ outline?: WithNone<Outline>;
680
+ foreground?: WithNone<Foreground>;
681
+ shadow?: WithNone<Shadow>;
682
+ video?: WithNone<Video>;
683
+ audio?: WithNone<Audio>;
684
+ effect?: WithNone<Effect>;
662
685
  children?: Element[];
663
686
  }
664
- type ElementDeclaration<T = MetaProperty> = Node<T> & {
665
- style?: Partial<StyleDeclaration>;
666
- text?: TextDeclaration;
667
- background?: BackgroundDeclaration;
668
- geometry?: GeometryDeclaration;
669
- fill?: FillDeclaration;
670
- outline?: OutlineDeclaration;
671
- foreground?: ForegroundDeclaration;
672
- shadow?: ShadowDeclaration;
673
- video?: VideoDeclaration;
674
- audio?: AudioDeclaration;
675
- effect?: EffectDeclaration;
676
- children?: ElementDeclaration[];
687
+ type NormalizedElement<T = Meta> = Node<T> & {
688
+ style?: Partial<NormalizedStyle>;
689
+ text?: NormalizedText;
690
+ background?: NormalizedBackground;
691
+ shape?: NormalizedShape;
692
+ fill?: NormalizedFill;
693
+ outline?: NormalizedOutline;
694
+ foreground?: NormalizedForeground;
695
+ shadow?: NormalizedShadow;
696
+ video?: NormalizedVideo;
697
+ audio?: NormalizedAudio;
698
+ effect?: NormalizedEffect;
699
+ children?: NormalizedElement[];
677
700
  };
678
- declare function normalizeElement<T = MetaProperty>(element: Element<T>): ElementDeclaration<T>;
701
+ declare function normalizeElement<T = Meta>(element: Element<T>): NormalizedElement<T>;
679
702
 
680
703
  interface Document extends Element {
681
704
  fonts?: any;
682
705
  }
683
- interface DocumentDeclaration extends ElementDeclaration {
706
+ interface NormalizedDocument extends NormalizedElement {
684
707
  fonts?: any;
685
708
  }
686
- declare function normalizeDocument(doc: Document): DocumentDeclaration;
709
+ declare function normalizeDocument(doc: Document): NormalizedDocument;
687
710
 
688
711
  declare function isNone<T>(value: T): value is Extract<T, null | undefined | 'none'>;
712
+ declare function round(number: number, digits?: number, base?: number): number;
689
713
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
690
714
 
691
- export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, isNone, normalizeAudio, normalizeBackground, normalizeColor, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGeometry, normalizeGradient, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizeShadow, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, stringifyGradient };
692
- export type { Align, AngularNode, AudioDeclaration, AudioProperty, BackgroundDeclaration, BackgroundProperty, BackgroundPropertyObject, BackgroundSize, BaseBackgroundDeclaration, BaseForegroundDeclaration, BaseOuterShadowDeclaration, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorDeclaration, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, DocumentDeclaration, EffectDeclaration, EffectProperty, EffectPropertyObject, Element, ElementDeclaration, ElementStyleDeclaration, EmNode, ExtentKeywordNode, FillDeclaration, FillProperty, FillPropertyObject, FillRule, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, ForegroundDeclaration, ForegroundProperty, ForegroundPropertyObject, FragmentContent, GeometryDeclaration, GeometryPathDeclaration, GeometryPathStyle, GeometryProperty, GradientFillDeclaration, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightDeclaration, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightStyleDeclaration, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, InnerShadowDeclaration, InnerShadowProperty, InnerShadowPropertyObject, Justify, LabColor, LabaColor, LayoutStyleDeclaration, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, ListStyleColormap, ListStyleDeclaration, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleStyleDeclaration, ListStyleType, LiteralNode, MetaProperty, Node, None, ObjectColor, OuterShadowDeclaration, OuterShadowProperty, OuterShadowPropertyObject, OutlineDeclaration, OutlineFillDeclaration, OutlineProperty, OutlinePropertyObject, OutlineStyle, Overflow, ParagraphContent, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PxNode, RadialGradient, RadialGradientNode, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, ShadowDeclaration, ShadowProperty, ShadowPropertyObject, ShadowStyleDeclaration, ShapeNode, SoftEdgeDeclaration, SoftEdgeProperty, SolidFillDeclaration, StrokeLinecap, StrokeLinejoin, StyleDeclaration, StyleProperty, StylePropertyObject, StyleUnit, TailEnd, TextAlign, TextContent, TextContentDeclaration, TextContentFlat, TextDeclaration, TextDecoration, TextDrawStyleDeclaration, TextInlineStyleDeclaration, TextLineStyleDeclaration, TextOrientation, TextProperty, TextStyleDeclaration, TextTransform, TextWrap, TextureFillDeclaration, TextureFillSourceRect, TextureFillSourceURL, TextureFillStretch, TextureFillStretchRect, TextureFillTile, TransformStyleDeclaration, Uint32Color, VerticalAlign, VideoDeclaration, VideoProperty, Visibility, WithNone, WritingMode, XyzColor, XyzaColor };
715
+ export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, isColor, isGradient, isNone, normalizeAudio, normalizeBackground, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, round, stringifyGradient };
716
+ 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, ExtentKeywordNode, Fill, FillObject, FillRule, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentContent, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedOutlineFill, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphContent, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PxNode, RadialGradient, RadialGradientNode, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextContentFlat, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WritingMode, XyzColor, XyzaColor };