modern-idoc 0.5.6 → 0.6.1

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,12 +1,10 @@
1
1
  import { Colord } from 'colord';
2
2
 
3
- type None = 'none';
4
-
5
- interface AudioDeclaration {
3
+ interface NormalizedAudio {
6
4
  src: string;
7
5
  }
8
- type AudioProperty = None | string | AudioDeclaration;
9
- declare function normalizeAudio(audio?: AudioProperty): AudioDeclaration | undefined;
6
+ type Audio = string | NormalizedAudio;
7
+ declare function normalizeAudio(audio: Audio): NormalizedAudio | undefined;
10
8
 
11
9
  interface RgbColor {
12
10
  r: number;
@@ -64,25 +62,180 @@ type LchaColor = WithAlpha<LchColor>;
64
62
  type CmykaColor = WithAlpha<CmykColor>;
65
63
  type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor | LchColor | LchaColor | CmykColor | CmykaColor;
66
64
  type Uint32Color = number;
67
- type Color = None | Uint32Color | ObjectColor | string;
65
+ type Color = Uint32Color | ObjectColor | string;
68
66
  type Hex8Color = string;
69
- type ColorDeclaration = Hex8Color;
67
+ type NormalizedColor = Hex8Color;
70
68
  declare function parseColor(color: Color): Colord;
71
- declare function normalizeColor(color?: Color, orFail?: boolean): ColorDeclaration | undefined;
69
+ declare const defaultColor: NormalizedColor;
70
+ declare function isColor(value: string): boolean;
71
+ declare function normalizeColor(color: Color, orFail?: boolean): NormalizedColor;
72
+
73
+ interface ColorStop {
74
+ offset: number;
75
+ color: NormalizedColor;
76
+ }
77
+ interface LinearGradient {
78
+ type: 'linear-gradient';
79
+ angle: number;
80
+ stops: ColorStop[];
81
+ repeat?: boolean;
82
+ }
83
+ interface RadialGradient {
84
+ type: 'radial-gradient';
85
+ stops: ColorStop[];
86
+ repeat?: boolean;
87
+ }
88
+ declare function isGradient(cssText: string): boolean;
89
+ declare function normalizeGradient(cssText: string): (LinearGradient | RadialGradient)[];
90
+
91
+ interface LinearGradientNode {
92
+ type: 'linear-gradient'
93
+ orientation?: DirectionalNode | AngularNode | undefined
94
+ colorStops: ColorStopNode[]
95
+ }
96
+
97
+ interface RepeatingLinearGradientNode {
98
+ type: 'repeating-linear-gradient'
99
+ orientation?: DirectionalNode | AngularNode | undefined
100
+ colorStops: ColorStopNode[]
101
+ }
102
+
103
+ interface RadialGradientNode {
104
+ type: 'radial-gradient'
105
+ orientation?: (ShapeNode | DefaultRadialNode | ExtentKeywordNode)[] | undefined
106
+ colorStops: ColorStopNode[]
107
+ }
108
+
109
+ interface RepeatingRadialGradientNode {
110
+ type: 'repeating-radial-gradient'
111
+ orientation?: (ShapeNode | DefaultRadialNode | ExtentKeywordNode)[] | undefined
112
+ colorStops: ColorStopNode[]
113
+ }
114
+
115
+ interface DirectionalNode {
116
+ type: 'directional'
117
+ value:
118
+ | 'left'
119
+ | 'top'
120
+ | 'bottom'
121
+ | 'right'
122
+ | 'left top'
123
+ | 'top left'
124
+ | 'left bottom'
125
+ | 'bottom left'
126
+ | 'right top'
127
+ | 'top right'
128
+ | 'right bottom'
129
+ | 'bottom right'
130
+ }
131
+
132
+ interface AngularNode {
133
+ type: 'angular'
134
+ value: string
135
+ }
136
+
137
+ interface LiteralNode {
138
+ type: 'literal'
139
+ value: string
140
+ length?: PxNode | EmNode | PercentNode | undefined
141
+ }
142
+
143
+ interface HexNode {
144
+ type: 'hex'
145
+ value: string
146
+ length?: PxNode | EmNode | PercentNode | undefined
147
+ }
148
+
149
+ interface RgbNode {
150
+ type: 'rgb'
151
+ value: [string, string, string]
152
+ length?: PxNode | EmNode | PercentNode | undefined
153
+ }
154
+
155
+ interface RgbaNode {
156
+ type: 'rgba'
157
+ value: [string, string, string, string?]
158
+ length?: PxNode | EmNode | PercentNode | undefined
159
+ }
160
+
161
+ interface ShapeNode {
162
+ type: 'shape'
163
+ style?: ExtentKeywordNode | PxNode | EmNode | PercentNode | PositionKeywordNode | undefined
164
+ value: 'ellipse' | 'circle'
165
+ at?: PositionNode | undefined
166
+ }
167
+
168
+ interface DefaultRadialNode {
169
+ type: 'default-radial'
170
+ at: PositionNode
171
+ }
172
+
173
+ interface PositionKeywordNode {
174
+ type: 'position-keyword'
175
+ value: 'center' | 'left' | 'top' | 'bottom' | 'right'
176
+ }
177
+
178
+ interface PositionNode {
179
+ type: 'position'
180
+ value: {
181
+ x: ExtentKeywordNode | PxNode | EmNode | PercentNode | PositionKeywordNode
182
+ y: ExtentKeywordNode | PxNode | EmNode | PercentNode | PositionKeywordNode
183
+ }
184
+ }
185
+
186
+ interface ExtentKeywordNode {
187
+ type: 'extent-keyword'
188
+ value: 'closest-side' | 'closest-corner' | 'farthest-side' | 'farthest-corner' | 'contain' | 'cover'
189
+ at?: PositionNode | undefined
190
+ }
191
+
192
+ interface PxNode {
193
+ type: 'px'
194
+ value: string
195
+ }
196
+
197
+ interface EmNode {
198
+ type: 'em'
199
+ value: string
200
+ }
201
+
202
+ interface PercentNode {
203
+ type: '%'
204
+ value: string
205
+ }
206
+
207
+ type ColorStopNode = LiteralNode | HexNode | RgbNode | RgbaNode
208
+ type GradientNode = LinearGradientNode | RepeatingLinearGradientNode | RadialGradientNode | RepeatingRadialGradientNode
72
209
 
73
- interface GradientFillDeclaration {
210
+ declare function parseGradient(cssText: string): GradientNode[]
211
+ declare function stringifyGradient(ast: GradientNode[]): string
212
+
213
+ interface ColorFillObject {
214
+ color: Color;
74
215
  }
216
+ type ColorFill = string | ColorFillObject;
217
+ interface NormalizedColorFill {
218
+ color: NormalizedColor;
219
+ }
220
+ declare function normalizeColorFill(fill: ColorFill): NormalizedColorFill;
75
221
 
76
- interface SolidFillDeclaration {
77
- color: ColorDeclaration;
222
+ interface GradientFillObject {
223
+ image: string;
78
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;
79
232
 
80
233
  /**
81
234
  * 0 -0.5 0
82
235
  * -0.5 -0.5
83
236
  * 0 -0.5 0
84
237
  */
85
- interface TextureFillSourceRect {
238
+ interface ImageFillCropRect {
86
239
  left?: number;
87
240
  top?: number;
88
241
  bottom?: number;
@@ -93,16 +246,13 @@ interface TextureFillSourceRect {
93
246
  * 0.5 0.5
94
247
  * 0 0.5 0
95
248
  */
96
- interface TextureFillStretchRect {
249
+ interface ImageFillStretchRect {
97
250
  left?: number;
98
251
  top?: number;
99
252
  bottom?: number;
100
253
  right?: number;
101
254
  }
102
- interface TextureFillStretch {
103
- rect?: TextureFillStretchRect;
104
- }
105
- interface TextureFillTile {
255
+ interface ImageFillTile {
106
256
  alignment?: string;
107
257
  scaleX?: number;
108
258
  scaleY?: number;
@@ -110,123 +260,102 @@ interface TextureFillTile {
110
260
  translateY?: number;
111
261
  flip?: string;
112
262
  }
113
- type TextureFillSourceURL = string;
114
- interface TextureFillDeclaration {
115
- src: TextureFillSourceURL;
116
- srcRect?: TextureFillSourceRect;
263
+ interface ImageFillObject {
264
+ image: string;
265
+ cropRect?: ImageFillCropRect;
266
+ stretchRect?: ImageFillStretchRect;
267
+ tile?: ImageFillTile;
117
268
  dpi?: number;
118
- stretch?: TextureFillStretch;
119
- tile?: TextureFillTile;
120
269
  opacity?: number;
121
270
  rotateWithShape?: boolean;
122
271
  }
272
+ interface NormalizedImageFill extends ImageFillObject {
273
+ }
274
+ declare function normalizeImageFill(fill: ImageFillObject): NormalizedImageFill;
123
275
 
124
- type FillDeclaration = Partial<TextureFillDeclaration> & Partial<SolidFillDeclaration> & Partial<GradientFillDeclaration>;
125
- type FillPropertyObject = FillDeclaration & {
126
- color?: Color;
127
- };
128
- type FillProperty = None | string | FillPropertyObject;
129
- declare function normalizeFill(fill?: FillProperty): FillDeclaration | undefined;
276
+ type None = undefined | null | 'none';
277
+ type WithNone<T> = T | None;
130
278
 
131
- interface BaseBackgroundDeclaration {
132
- 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;
133
288
  }
134
- type BackgroundDeclaration = BaseBackgroundDeclaration & FillDeclaration;
135
- type BackgroundPropertyObject = BaseBackgroundDeclaration & FillPropertyObject;
136
- type BackgroundProperty = None | string | BackgroundPropertyObject;
137
- declare function normalizeBackground(background?: BackgroundProperty): BackgroundDeclaration | undefined;
289
+ declare function normalizePresetFill(fill: PresetFill): NormalizedPresetFill;
138
290
 
139
- interface InnerShadowDeclaration {
140
- 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;
141
306
  offsetX: number;
142
307
  offsetY: number;
143
308
  blurRadius: number;
144
309
  }
145
- type InnerShadowPropertyObject = Partial<InnerShadowDeclaration> & {
146
- color: Color;
310
+ type InnerShadowObject = Partial<NormalizedInnerShadow> & {
311
+ color: WithNone<Color>;
147
312
  };
148
- type InnerShadowProperty = None | InnerShadowPropertyObject;
149
- declare function getDefaultInnerShadow(): InnerShadowDeclaration;
150
- declare function normalizeInnerShadow(shadow?: InnerShadowProperty): InnerShadowDeclaration | undefined;
313
+ type InnerShadow = InnerShadowObject;
314
+ declare function getDefaultInnerShadow(): NormalizedInnerShadow;
315
+ declare function normalizeInnerShadow(shadow: InnerShadow): NormalizedInnerShadow;
151
316
 
152
- interface BaseOuterShadowDeclaration {
317
+ interface NormalizedBaseOuterShadow {
153
318
  scaleX: number;
154
319
  scaleY: number;
155
320
  }
156
- type OuterShadowDeclaration = BaseOuterShadowDeclaration & InnerShadowDeclaration;
157
- type OuterShadowPropertyObject = Partial<BaseOuterShadowDeclaration> & InnerShadowPropertyObject;
158
- type OuterShadowProperty = None | OuterShadowPropertyObject;
159
- declare function getDefaultOuterShadow(): OuterShadowDeclaration;
160
- declare function normalizeOuterShadow(shadow?: OuterShadowProperty): OuterShadowDeclaration | undefined;
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;
161
326
 
162
- interface SoftEdgeDeclaration {
327
+ interface NormalizedSoftEdge {
163
328
  radius: number;
164
329
  }
165
- type SoftEdgeProperty = None | SoftEdgeDeclaration;
166
- declare function normalizeSoftEdge(softEdge?: SoftEdgeProperty): SoftEdgeDeclaration | undefined;
330
+ type SoftEdge = NormalizedSoftEdge;
331
+ declare function normalizeSoftEdge(softEdge: SoftEdge): NormalizedSoftEdge;
167
332
 
168
- interface EffectDeclaration {
169
- innerShadow?: InnerShadowDeclaration;
170
- outerShadow?: OuterShadowDeclaration;
171
- softEdge?: SoftEdgeDeclaration;
333
+ interface NormalizedEffect {
334
+ innerShadow?: NormalizedInnerShadow;
335
+ outerShadow?: NormalizedOuterShadow;
336
+ softEdge?: NormalizedSoftEdge;
172
337
  }
173
- interface EffectPropertyObject {
174
- innerShadow?: InnerShadowProperty;
175
- outerShadow?: OuterShadowProperty;
176
- softEdge?: SoftEdgeProperty;
338
+ interface EffectObject {
339
+ innerShadow: WithNone<InnerShadow>;
340
+ outerShadow: WithNone<OuterShadow>;
341
+ softEdge: WithNone<SoftEdge>;
177
342
  }
178
- type EffectProperty = None | EffectPropertyObject;
179
- declare function normalizeEffect(effect?: EffectProperty): EffectDeclaration | undefined;
343
+ type Effect = EffectObject;
344
+ declare function normalizeEffect(effect: Effect): NormalizedEffect;
180
345
 
181
- interface BaseForegroundDeclaration {
182
- withGeometry?: boolean;
346
+ interface NormalizedBaseForeground {
347
+ fillWithShape: boolean;
183
348
  }
184
- type ForegroundDeclaration = BaseForegroundDeclaration & FillDeclaration;
185
- type ForegroundPropertyObject = BaseForegroundDeclaration & FillPropertyObject;
186
- type ForegroundProperty = None | string | ForegroundPropertyObject;
187
- declare function normalizeForeground(foreground?: ForegroundProperty): ForegroundDeclaration | undefined;
349
+ type NormalizedForeground = NormalizedBaseForeground & NormalizedFill;
350
+ type ForegroundObject = Partial<NormalizedBaseForeground> & FillObject;
351
+ type Foreground = string | ForegroundObject;
352
+ declare function normalizeForeground(foreground: Foreground): NormalizedForeground | undefined;
188
353
 
189
- type SVGPathData = string;
190
- type FillRule = 'nonzero' | 'evenodd';
191
- type StrokeLinecap = 'butt' | 'round' | 'square';
192
- type StrokeLinejoin = 'arcs' | 'bevel' | 'miter' | 'miter-clip' | 'round';
193
- interface GeometryPathStyle {
194
- [key: string]: any;
195
- opacity: number;
196
- visibility: string;
197
- shadowColor: ColorDeclaration;
198
- shadowOffsetX: number;
199
- shadowOffsetY: number;
200
- shadowBlur: number;
201
- fill: string;
202
- fillOpacity: number;
203
- fillRule: FillRule;
204
- stroke: string;
205
- strokeOpacity: number;
206
- strokeWidth: number;
207
- strokeLinecap: StrokeLinecap;
208
- strokeLinejoin: StrokeLinejoin;
209
- strokeMiterlimit: number;
210
- strokeDasharray: number[];
211
- strokeDashoffset: number;
212
- }
213
- interface GeometryPathDeclaration extends Partial<GeometryPathStyle> {
214
- data: SVGPathData;
215
- }
216
- interface GeometryDeclaration {
217
- name?: string;
218
- svg?: string;
219
- viewBox?: number[];
220
- paths?: GeometryPathDeclaration[];
221
- }
222
- type GeometryProperty = None | SVGPathData | SVGPathData[] | GeometryPathDeclaration[] | GeometryDeclaration;
223
- declare function normalizeGeometry(geometry?: GeometryProperty): GeometryDeclaration | undefined;
224
-
225
- interface MetaProperty {
354
+ interface Meta {
226
355
  [key: string]: any;
227
356
  }
228
357
 
229
- interface Node<T = MetaProperty> {
358
+ interface Node<T = Meta> {
230
359
  name?: string;
231
360
  children?: Node[];
232
361
  meta?: T;
@@ -237,51 +366,86 @@ type LineEndSize = 'sm' | 'md' | 'lg';
237
366
 
238
367
  interface HeadEnd {
239
368
  type: LineEndType;
240
- width?: None | LineEndSize;
241
- height?: None | LineEndSize;
369
+ width?: WithNone<LineEndSize>;
370
+ height?: WithNone<LineEndSize>;
242
371
  }
243
372
 
244
373
  interface TailEnd {
245
374
  type: LineEndType;
246
- width?: None | LineEndSize;
247
- height?: None | LineEndSize;
375
+ width?: WithNone<LineEndSize>;
376
+ height?: WithNone<LineEndSize>;
248
377
  }
249
378
 
250
- type OutlineFillDeclaration = Partial<SolidFillDeclaration> & Partial<GradientFillDeclaration>;
379
+ type NormalizedOutlineFill = Partial<NormalizedColorFill> & Partial<NormalizedGradientFill>;
251
380
  type OutlineStyle = 'dashed' | 'solid' | string;
252
- interface OutlineDeclaration extends OutlineFillDeclaration {
381
+ interface NormalizedOutline extends NormalizedOutlineFill {
253
382
  width?: number;
254
- color?: ColorDeclaration;
383
+ color?: NormalizedColor;
255
384
  style?: OutlineStyle;
256
385
  headEnd?: HeadEnd;
257
386
  tailEnd?: TailEnd;
258
387
  }
259
- type OutlinePropertyObject = Partial<OutlineDeclaration> & {
260
- color?: Color;
388
+ type OutlineObject = Partial<NormalizedOutline> & {
389
+ color: WithNone<Color>;
261
390
  };
262
- type OutlineProperty = None | string | OutlinePropertyObject;
263
- declare function normalizeOutline(outline?: OutlineProperty): OutlineDeclaration | undefined;
391
+ type Outline = string | OutlineObject;
392
+ declare function normalizeOutline(outline: Outline): NormalizedOutline;
264
393
 
265
- type BoxShadow = None | string;
266
- interface ShadowDeclaration {
267
- color: ColorDeclaration;
394
+ type BoxShadow = string;
395
+ interface NormalizedShadow {
396
+ color: NormalizedColor;
268
397
  offsetX?: number;
269
398
  offsetY?: number;
270
399
  blur?: number;
271
400
  }
272
- type ShadowPropertyObject = Partial<ShadowDeclaration> & {
273
- color?: Color;
401
+ type ShadowObject = Partial<NormalizedShadow> & {
402
+ color: WithNone<Color>;
274
403
  };
275
- type ShadowProperty = None | BoxShadow | ShadowPropertyObject;
276
- declare function normalizeShadow(shadow?: ShadowProperty): ShadowDeclaration | undefined;
277
- interface ShadowStyleDeclaration {
404
+ type Shadow = BoxShadow | ShadowObject;
405
+ declare function normalizeShadow(shadow: Shadow): NormalizedShadow;
406
+ interface NormalizedShadowStyle {
278
407
  boxShadow: BoxShadow;
279
- shadowColor?: ColorDeclaration;
408
+ shadowColor?: NormalizedColor;
280
409
  shadowOffsetX?: number;
281
410
  shadowOffsetY?: number;
282
411
  shadowBlur?: number;
283
412
  }
284
- 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;
285
449
 
286
450
  type StyleUnit = `${number}%` | number;
287
451
  type Display = 'flex' | 'contents';
@@ -290,12 +454,12 @@ type Overflow = 'hidden' | 'visible';
290
454
  type Visibility = 'hidden' | 'visible';
291
455
  type FontWeight = 'normal' | 'bold' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
292
456
  type FontStyle = 'normal' | 'italic' | 'oblique' | `oblique ${string}`;
293
- type FontKerning = None | 'auto' | 'normal';
457
+ type FontKerning = WithNone<'auto' | 'normal'>;
294
458
  type TextWrap = 'wrap' | 'nowrap';
295
- type TextAlign = None | 'center' | 'end' | 'left' | 'right' | 'start' | 'justify';
296
- type TextTransform = None | 'uppercase' | 'lowercase';
459
+ type TextAlign = WithNone<'center' | 'end' | 'left' | 'right' | 'start' | 'justify'>;
460
+ type TextTransform = WithNone<'uppercase' | 'lowercase'>;
297
461
  type TextOrientation = 'mixed' | 'upright' | 'sideways-right' | 'sideways';
298
- type TextDecoration = None | 'underline' | 'line-through' | 'overline';
462
+ type TextDecoration = WithNone<'underline' | 'line-through' | 'overline'>;
299
463
  type VerticalAlign = 'baseline' | 'top' | 'middle' | 'bottom' | 'sub' | 'super' | 'text-top' | 'text-bottom';
300
464
  type WritingMode = 'horizontal-tb' | 'vertical-lr' | 'vertical-rl';
301
465
  type Align = 'auto' | 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline' | 'space-between' | 'space-around' | 'space-evenly';
@@ -303,22 +467,22 @@ type FlexDirection = 'column' | 'column-reverse' | 'row' | 'row-reverse';
303
467
  type FlexWrap = 'nowrap' | 'wrap' | 'Wrap-reverse';
304
468
  type Justify = 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly';
305
469
  type Position = 'static' | 'relative' | 'absolute';
306
- type BorderStyle = None | 'dashed' | 'solid';
470
+ type BorderStyle = WithNone<'dashed' | 'solid'>;
307
471
  type BoxSizing = 'border-box' | 'content-box';
308
472
  type PointerEvents = 'auto' | 'none';
309
- type ListStyleType = None | 'disc';
310
- type ListStyleImage = None | string;
311
- type ListStyleColormap = None | Record<string, string>;
473
+ type ListStyleType = WithNone<'disc'>;
474
+ type ListStyleImage = WithNone<string>;
475
+ type ListStyleColormap = WithNone<Record<string, string>>;
312
476
  type ListStyleSize = StyleUnit | `${number}rem` | 'cover';
313
477
  type ListStylePosition = 'inside' | 'outside';
314
478
  type HighlightLine = TextDecoration | 'outline';
315
- type HighlightImage = None | string;
316
- type HighlightReferImage = None | string;
317
- type HighlightColormap = None | Record<string, string>;
479
+ type HighlightImage = WithNone<string>;
480
+ type HighlightReferImage = WithNone<string>;
481
+ type HighlightColormap = WithNone<Record<string, string>>;
318
482
  type HighlightSize = StyleUnit | `${number}rem` | 'cover';
319
483
  type HighlightThickness = StyleUnit;
320
484
 
321
- interface LayoutStyleDeclaration {
485
+ interface NormalizedLayoutStyle {
322
486
  overflow: Overflow;
323
487
  direction: Direction;
324
488
  display: Display;
@@ -351,20 +515,20 @@ interface LayoutStyleDeclaration {
351
515
  alignSelf: Align;
352
516
  justifyContent: Justify;
353
517
  gap: StyleUnit;
354
- marginTop: None | StyleUnit | 'auto';
355
- marginLeft: None | StyleUnit | 'auto';
356
- marginRight: None | StyleUnit | 'auto';
357
- marginBottom: None | StyleUnit | 'auto';
358
- margin: None | StyleUnit | 'auto';
518
+ marginTop: WithNone<StyleUnit | 'auto'>;
519
+ marginLeft: WithNone<StyleUnit | 'auto'>;
520
+ marginRight: WithNone<StyleUnit | 'auto'>;
521
+ marginBottom: WithNone<StyleUnit | 'auto'>;
522
+ margin: WithNone<StyleUnit | 'auto'>;
359
523
  paddingTop: StyleUnit;
360
524
  paddingLeft: StyleUnit;
361
525
  paddingRight: StyleUnit;
362
526
  paddingBottom: StyleUnit;
363
527
  padding: StyleUnit;
364
528
  }
365
- declare function getDefaultLayoutStyle(): Partial<LayoutStyleDeclaration>;
529
+ declare function getDefaultLayoutStyle(): Partial<NormalizedLayoutStyle>;
366
530
 
367
- interface TransformStyleDeclaration {
531
+ interface NormalizedTransformStyle {
368
532
  rotate: number;
369
533
  scaleX: number;
370
534
  scaleY: number;
@@ -372,33 +536,33 @@ interface TransformStyleDeclaration {
372
536
  skewY: number;
373
537
  translateX: number;
374
538
  translateY: number;
375
- transform: None | string;
539
+ transform: WithNone<string>;
376
540
  transformOrigin: string;
377
541
  }
378
- declare function getDefaultTransformStyle(): TransformStyleDeclaration;
542
+ declare function getDefaultTransformStyle(): NormalizedTransformStyle;
379
543
 
380
544
  type BackgroundSize = 'contain' | 'cover' | string | 'stretch' | 'rigid';
381
- type ElementStyleDeclaration = Partial<LayoutStyleDeclaration> & TransformStyleDeclaration & ShadowStyleDeclaration & {
382
- backgroundImage: None | string;
545
+ type NormalizedElementStyle = Partial<NormalizedLayoutStyle> & NormalizedTransformStyle & NormalizedShadowStyle & {
546
+ backgroundImage: WithNone<string>;
383
547
  backgroundSize: BackgroundSize;
384
- backgroundColor: None | ColorDeclaration;
385
- backgroundColormap: None | Record<string, string>;
548
+ backgroundColor: WithNone<NormalizedColor>;
549
+ backgroundColormap: WithNone<Record<string, string>>;
386
550
  borderRadius: number;
387
- borderColor: None | ColorDeclaration;
551
+ borderColor: WithNone<NormalizedColor>;
388
552
  borderStyle: BorderStyle;
389
553
  outlineWidth: number;
390
554
  outlineOffset: number;
391
- outlineColor: None | ColorDeclaration;
555
+ outlineColor: WithNone<NormalizedColor>;
392
556
  outlineStyle: string;
393
557
  visibility: Visibility;
394
558
  filter: string;
395
559
  opacity: number;
396
560
  pointerEvents: PointerEvents;
397
- maskImage: None | string;
561
+ maskImage: WithNone<string>;
398
562
  };
399
- declare function getDefaultElementStyle(): ElementStyleDeclaration;
563
+ declare function getDefaultElementStyle(): NormalizedElementStyle;
400
564
 
401
- interface HighlightDeclaration {
565
+ interface NormalizedHighlight {
402
566
  image: HighlightImage;
403
567
  referImage: HighlightReferImage;
404
568
  colormap: HighlightColormap;
@@ -406,8 +570,8 @@ interface HighlightDeclaration {
406
570
  size: HighlightSize;
407
571
  thickness: HighlightThickness;
408
572
  }
409
- interface HighlightStyleDeclaration {
410
- highlight: Partial<HighlightDeclaration>;
573
+ interface NormalizedHighlightStyle {
574
+ highlight: Partial<NormalizedHighlight>;
411
575
  highlightImage: HighlightImage;
412
576
  highlightReferImage: HighlightReferImage;
413
577
  highlightColormap: HighlightColormap;
@@ -415,27 +579,27 @@ interface HighlightStyleDeclaration {
415
579
  highlightSize: HighlightSize;
416
580
  highlightThickness: HighlightThickness;
417
581
  }
418
- declare function getDefaultHighlightStyle(): Required<HighlightStyleDeclaration>;
582
+ declare function getDefaultHighlightStyle(): Required<NormalizedHighlightStyle>;
419
583
 
420
- interface ListStyleDeclaration {
584
+ interface NormalizedListStyle {
421
585
  type: ListStyleType;
422
586
  image: ListStyleImage;
423
587
  colormap: ListStyleColormap;
424
588
  size: ListStyleSize;
425
589
  position: ListStylePosition;
426
590
  }
427
- interface ListStyleStyleDeclaration {
428
- listStyle: Partial<ListStyleDeclaration>;
591
+ interface NormalizedListStyleStyle {
592
+ listStyle: Partial<NormalizedListStyle>;
429
593
  listStyleType: ListStyleType;
430
594
  listStyleImage: ListStyleImage;
431
595
  listStyleColormap: ListStyleColormap;
432
596
  listStyleSize: ListStyleSize;
433
597
  listStylePosition: ListStylePosition;
434
598
  }
435
- declare function getDefaultListStyleStyle(): ListStyleStyleDeclaration;
599
+ declare function getDefaultListStyleStyle(): NormalizedListStyleStyle;
436
600
 
437
- type TextInlineStyleDeclaration = HighlightStyleDeclaration & {
438
- color: ColorDeclaration;
601
+ type NormalizedTextInlineStyle = NormalizedHighlightStyle & {
602
+ color: NormalizedColor;
439
603
  verticalAlign: VerticalAlign;
440
604
  letterSpacing: number;
441
605
  wordSpacing: number;
@@ -448,103 +612,105 @@ type TextInlineStyleDeclaration = HighlightStyleDeclaration & {
448
612
  textOrientation: TextOrientation;
449
613
  textDecoration: TextDecoration;
450
614
  };
451
- declare function getDefaultTextInlineStyle(): Required<TextInlineStyleDeclaration>;
615
+ declare function getDefaultTextInlineStyle(): Required<NormalizedTextInlineStyle>;
452
616
 
453
- type TextLineStyleDeclaration = ListStyleStyleDeclaration & {
617
+ type NormalizedTextLineStyle = NormalizedListStyleStyle & {
454
618
  writingMode: WritingMode;
455
619
  textWrap: TextWrap;
456
620
  textAlign: TextAlign;
457
621
  textIndent: number;
458
622
  lineHeight: number;
459
623
  };
460
- declare function getDefaultTextLineStyle(): TextLineStyleDeclaration;
624
+ declare function getDefaultTextLineStyle(): NormalizedTextLineStyle;
461
625
 
462
- interface TextDrawStyleDeclaration {
626
+ interface NormalizedTextDrawStyle {
463
627
  textStrokeWidth: number;
464
- textStrokeColor: ColorDeclaration;
628
+ textStrokeColor: NormalizedColor;
465
629
  }
466
- type TextStyleDeclaration = TextLineStyleDeclaration & TextInlineStyleDeclaration & TextDrawStyleDeclaration;
467
- declare function getDefaultTextStyle(): Required<TextStyleDeclaration>;
630
+ type NormalizedTextStyle = NormalizedTextLineStyle & NormalizedTextInlineStyle & NormalizedTextDrawStyle;
631
+ declare function getDefaultTextStyle(): Required<NormalizedTextStyle>;
468
632
 
469
- interface StyleDeclaration extends TextStyleDeclaration, ElementStyleDeclaration {
633
+ interface NormalizedStyle extends NormalizedTextStyle, NormalizedElementStyle {
470
634
  }
471
- type StylePropertyObject = Partial<StyleDeclaration> & {
472
- color?: Color;
473
- backgroundColor?: Color;
474
- borderColor?: Color;
475
- outlineColor?: Color;
476
- shadowColor?: Color;
635
+ type StyleObject = Partial<NormalizedStyle> & {
636
+ color?: WithNone<Color>;
637
+ backgroundColor?: WithNone<Color>;
638
+ borderColor?: WithNone<Color>;
639
+ outlineColor?: WithNone<Color>;
640
+ shadowColor?: WithNone<Color>;
477
641
  };
478
- type StyleProperty = None | StylePropertyObject;
479
- declare function normalizeStyle(style?: StyleProperty): Partial<StyleDeclaration> | undefined;
480
- declare function getDefaultStyle(): StyleDeclaration;
642
+ type Style = StyleObject;
643
+ declare function normalizeStyle(style: Style): Partial<NormalizedStyle>;
644
+ declare function getDefaultStyle(): NormalizedStyle;
481
645
 
482
- interface FragmentContent extends StylePropertyObject {
646
+ interface FragmentContent extends StyleObject {
483
647
  content: string;
484
648
  }
485
- interface ParagraphContent extends StylePropertyObject {
649
+ interface ParagraphContent extends StyleObject {
486
650
  fragments: FragmentContent[];
487
651
  }
488
652
  type TextContentFlat = string | FragmentContent | ParagraphContent | (string | FragmentContent)[];
489
653
  type TextContent = string | FragmentContent | ParagraphContent | TextContentFlat[];
490
- type TextContentDeclaration = (ParagraphContent & StylePropertyObject)[];
491
- interface TextDeclaration {
492
- content: TextContentDeclaration;
493
- effects?: StylePropertyObject[];
654
+ type NormalizedTextContent = (ParagraphContent & StyleObject)[];
655
+ interface NormalizedText {
656
+ content: NormalizedTextContent;
657
+ effects?: StyleObject[];
494
658
  measureDom?: any;
495
659
  fonts?: any;
496
660
  }
497
- type TextProperty = string | TextContent | (TextDeclaration & {
661
+ type Text = string | TextContent | (NormalizedText & {
498
662
  content: TextContent;
499
- }) | TextDeclaration;
500
- declare function normalizeTextContent(content?: TextContent): TextContentDeclaration;
501
- declare function normalizeText(text?: TextProperty): TextDeclaration | undefined;
663
+ }) | NormalizedText;
664
+ declare function normalizeTextContent(content?: TextContent): NormalizedTextContent;
665
+ declare function normalizeText(text: Text): NormalizedText;
502
666
 
503
- interface VideoDeclaration {
667
+ interface NormalizedVideo {
504
668
  src: string;
505
669
  }
506
- type VideoProperty = None | string | VideoDeclaration;
507
- declare function normalizeVideo(video?: VideoProperty): VideoDeclaration | undefined;
508
-
509
- interface Element<T = MetaProperty> extends Node<T> {
510
- style?: StyleProperty;
511
- text?: TextProperty;
512
- background?: BackgroundProperty;
513
- geometry?: GeometryProperty;
514
- fill?: FillProperty;
515
- outline?: OutlineProperty;
516
- foreground?: ForegroundProperty;
517
- shadow?: ShadowProperty;
518
- video?: VideoProperty;
519
- audio?: AudioProperty;
520
- effect?: 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>;
521
685
  children?: Element[];
522
686
  }
523
- interface ElementDeclaration<T = MetaProperty> extends Element<T> {
524
- style?: Partial<StyleDeclaration>;
525
- text?: TextDeclaration;
526
- background?: BackgroundDeclaration;
527
- geometry?: GeometryDeclaration;
528
- fill?: FillDeclaration;
529
- outline?: OutlineDeclaration;
530
- foreground?: ForegroundDeclaration;
531
- shadow?: ShadowDeclaration;
532
- video?: VideoDeclaration;
533
- audio?: AudioDeclaration;
534
- effect?: EffectDeclaration;
535
- children?: ElementDeclaration[];
536
- }
537
- declare function normalizeElement<T = MetaProperty>(element: Element<T>): ElementDeclaration<T>;
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[];
700
+ };
701
+ declare function normalizeElement<T = Meta>(element: Element<T>): NormalizedElement<T>;
538
702
 
539
703
  interface Document extends Element {
540
704
  fonts?: any;
541
705
  }
542
- interface DocumentDeclaration extends ElementDeclaration {
706
+ interface NormalizedDocument extends NormalizedElement {
543
707
  fonts?: any;
544
708
  }
545
- declare function normalizeDocument(doc: Document): DocumentDeclaration;
709
+ declare function normalizeDocument(doc: Document): NormalizedDocument;
546
710
 
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;
547
713
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
548
714
 
549
- export { clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeAudio, normalizeBackground, normalizeColor, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGeometry, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizeShadow, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor };
550
- export type { Align, AudioDeclaration, AudioProperty, BackgroundDeclaration, BackgroundProperty, BackgroundPropertyObject, BackgroundSize, BaseBackgroundDeclaration, BaseForegroundDeclaration, BaseOuterShadowDeclaration, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorDeclaration, Direction, Display, Document, DocumentDeclaration, EffectDeclaration, EffectProperty, EffectPropertyObject, Element, ElementDeclaration, ElementStyleDeclaration, FillDeclaration, FillProperty, FillPropertyObject, FillRule, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, ForegroundDeclaration, ForegroundProperty, ForegroundPropertyObject, FragmentContent, GeometryDeclaration, GeometryPathDeclaration, GeometryPathStyle, GeometryProperty, GradientFillDeclaration, HeadEnd, Hex8Color, 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, ListStyleColormap, ListStyleDeclaration, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleStyleDeclaration, ListStyleType, MetaProperty, Node, None, ObjectColor, OuterShadowDeclaration, OuterShadowProperty, OuterShadowPropertyObject, OutlineDeclaration, OutlineFillDeclaration, OutlineProperty, OutlinePropertyObject, OutlineStyle, Overflow, ParagraphContent, PointerEvents, Position, RgbColor, RgbaColor, SVGPathData, ShadowDeclaration, ShadowProperty, ShadowPropertyObject, ShadowStyleDeclaration, 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, 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 };