modern-idoc 0.2.13 → 0.3.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,21 +1,42 @@
1
1
  type None = 'none';
2
2
 
3
- type AudioSource = string;
4
- interface AudioDeclaration {
5
- src: AudioSource;
3
+ interface GradientFillDeclaration {
4
+ type: 'gradient';
5
+ opacity?: number;
6
+ }
7
+
8
+ interface SolidFillDeclaration {
9
+ type: 'solid';
10
+ color: string;
11
+ opacity?: number;
6
12
  }
7
- type AudioProp = None | AudioSource | AudioDeclaration;
8
13
 
9
- interface ImageFillStretchRect {
14
+ /**
15
+ * 0 -0.5 0
16
+ * -0.5 -0.5
17
+ * 0 -0.5 0
18
+ */
19
+ interface TextureFillSourceRect {
10
20
  left?: number;
11
21
  top?: number;
12
22
  bottom?: number;
13
23
  right?: number;
14
24
  }
15
- interface ImageFillStretch {
16
- rect?: ImageFillStretchRect;
25
+ /**
26
+ * 0 0.5 0
27
+ * 0.5 0.5
28
+ * 0 0.5 0
29
+ */
30
+ interface TextureFillStretchRect {
31
+ left?: number;
32
+ top?: number;
33
+ bottom?: number;
34
+ right?: number;
35
+ }
36
+ interface TextureFillStretch {
37
+ rect?: TextureFillStretchRect;
17
38
  }
18
- interface ImageFillTile {
39
+ interface TextureFillTile {
19
40
  alignment?: string;
20
41
  scaleX?: number;
21
42
  scaleY?: number;
@@ -23,30 +44,36 @@ interface ImageFillTile {
23
44
  translateY?: number;
24
45
  flip?: string;
25
46
  }
26
- interface CommonFillDeclaration {
27
- opacity?: number;
28
- }
29
- type ImageFillSource = string;
30
- interface ImageFillDeclaration extends CommonFillDeclaration {
31
- type: 'image';
32
- image: ImageFillSource;
47
+ type TextureFillSourceURL = string;
48
+ interface TextureFillDeclaration {
49
+ type: 'texture';
50
+ src: TextureFillSourceURL;
51
+ srcRect?: TextureFillSourceRect;
33
52
  dpi?: number;
34
53
  rotateWithShape?: boolean;
35
- stretch?: ImageFillStretch;
36
- tile?: ImageFillTile;
54
+ stretch?: TextureFillStretch;
55
+ tile?: TextureFillTile;
56
+ opacity?: number;
37
57
  }
38
- interface ColorFillDeclaration extends CommonFillDeclaration {
39
- type: 'color';
40
- color: string;
58
+
59
+ type SingleFillDeclaration = TextureFillDeclaration | SolidFillDeclaration | GradientFillDeclaration;
60
+ type FillDeclaration = SingleFillDeclaration[];
61
+ type FillProperty = None | string | SingleFillDeclaration | FillDeclaration;
62
+ declare function normalizeFill(fill?: FillProperty): FillDeclaration | undefined;
63
+
64
+ interface AudioBackgroundDeclaration {
65
+ type: 'audio';
66
+ src: string;
41
67
  }
42
- type FillDeclaration = ImageFillDeclaration | ColorFillDeclaration;
43
- type FillProp = None | string | FillDeclaration;
68
+ type SingleBackgroundDeclaration = SingleFillDeclaration | AudioBackgroundDeclaration;
69
+ type BackgroundDeclaration = SingleBackgroundDeclaration[];
70
+ type BackgroundProperty = None | string | SingleBackgroundDeclaration | BackgroundDeclaration;
44
71
 
45
72
  type SVGPathData = string;
46
73
  type FillRule = 'nonzero' | 'evenodd';
47
74
  type StrokeLinecap = 'butt' | 'round' | 'square';
48
75
  type StrokeLinejoin = 'arcs' | 'bevel' | 'miter' | 'miter-clip' | 'round';
49
- interface Path2DStyle {
76
+ interface GeometryPathStyle {
50
77
  [key: string]: any;
51
78
  opacity: number;
52
79
  visibility: string;
@@ -66,41 +93,28 @@ interface Path2DStyle {
66
93
  strokeDasharray: number[];
67
94
  strokeDashoffset: number;
68
95
  }
69
- interface Path2DDeclaration extends Partial<Path2DStyle> {
96
+ interface GeometryPathDeclaration extends Partial<GeometryPathStyle> {
70
97
  data: SVGPathData;
71
98
  }
72
99
  interface GeometryDeclaration {
73
100
  name?: string;
74
101
  svg?: string;
75
102
  viewBox?: number[];
76
- data?: Path2DDeclaration[];
103
+ paths?: GeometryPathDeclaration[];
77
104
  }
78
- type GeometryProp = None | SVGPathData | SVGPathData[] | Path2DDeclaration[] | GeometryDeclaration;
105
+ type GeometryProperty = None | SVGPathData | SVGPathData[] | GeometryPathDeclaration[] | GeometryDeclaration;
106
+ declare function normalizeGeometry(geometry?: GeometryProperty): GeometryDeclaration | undefined;
79
107
 
80
- interface MetaProp {
108
+ interface MetaProperty {
81
109
  [key: string]: any;
82
110
  }
83
111
 
84
112
  interface IDOCNode {
85
113
  name?: string;
86
114
  children?: IDOCNode[];
87
- meta?: MetaProp;
115
+ meta?: MetaProperty;
88
116
  }
89
117
 
90
- type ImageSource = string;
91
- interface ImageSourceRect {
92
- left?: number;
93
- top?: number;
94
- bottom?: number;
95
- right?: number;
96
- }
97
- interface ImageDeclaration {
98
- src: ImageSource;
99
- srcRect?: ImageSourceRect;
100
- opacity?: number;
101
- }
102
- type ImageProp = None | ImageSource | ImageDeclaration;
103
-
104
118
  interface OutlineDeclaration {
105
119
  width?: number;
106
120
  style?: 'dashed' | 'solid' | string;
@@ -108,7 +122,8 @@ interface OutlineDeclaration {
108
122
  color?: string;
109
123
  opacity?: number;
110
124
  }
111
- type OutlineProp = None | string | Partial<OutlineDeclaration>;
125
+ type OutlineProperty = None | string | Partial<OutlineDeclaration>;
126
+ declare function normalizeOutline(outline?: OutlineProperty): OutlineDeclaration | undefined;
112
127
 
113
128
  type BoxShadow = None | string;
114
129
  interface ShadowDeclaration {
@@ -117,7 +132,7 @@ interface ShadowDeclaration {
117
132
  offsetY?: number;
118
133
  blur?: number;
119
134
  }
120
- type ShadowProp = None | BoxShadow | ShadowDeclaration;
135
+ type ShadowProperty = None | BoxShadow | ShadowDeclaration;
121
136
  interface ShadowStyleDeclaration {
122
137
  boxShadow: BoxShadow;
123
138
  shadowColor?: string;
@@ -125,6 +140,8 @@ interface ShadowStyleDeclaration {
125
140
  shadowOffsetY?: number;
126
141
  shadowBlur?: number;
127
142
  }
143
+ declare function getDefaultShadowStyle(): ShadowStyleDeclaration;
144
+ declare function normalizeShadow(shadow?: ShadowProperty): ShadowDeclaration | undefined;
128
145
 
129
146
  type StyleUnit = `${number}%` | number;
130
147
  type Display = 'flex' | 'contents';
@@ -205,6 +222,7 @@ interface LayoutStyleDeclaration {
205
222
  paddingBottom?: StyleUnit;
206
223
  padding?: StyleUnit;
207
224
  }
225
+ declare function getDefaultLayoutStyle(): LayoutStyleDeclaration;
208
226
 
209
227
  interface TransformStyleDeclaration {
210
228
  rotate: number;
@@ -217,6 +235,7 @@ interface TransformStyleDeclaration {
217
235
  transform: None | string;
218
236
  transformOrigin: string;
219
237
  }
238
+ declare function getDefaultTransformStyle(): TransformStyleDeclaration;
220
239
 
221
240
  interface ElementStyleDeclaration extends LayoutStyleDeclaration, TransformStyleDeclaration, ShadowStyleDeclaration {
222
241
  backgroundImage?: None | string;
@@ -234,6 +253,7 @@ interface ElementStyleDeclaration extends LayoutStyleDeclaration, TransformStyle
234
253
  pointerEvents: PointerEvents;
235
254
  maskImage: None | string;
236
255
  }
256
+ declare function getDefaultElementStyle(): ElementStyleDeclaration;
237
257
 
238
258
  interface HighlightDeclaration {
239
259
  image: HighlightImage;
@@ -252,6 +272,7 @@ interface HighlightStyleDeclaration {
252
272
  highlightSize: HighlightSize;
253
273
  highlightThickness: HighlightThickness;
254
274
  }
275
+ declare function getDefaultHighlightStyle(): HighlightStyleDeclaration;
255
276
 
256
277
  interface ListStyleDeclaration {
257
278
  type: ListStyleType;
@@ -268,6 +289,7 @@ interface ListStyleStyleDeclaration {
268
289
  listStyleSize: ListStyleSize;
269
290
  listStylePosition: ListStylePosition;
270
291
  }
292
+ declare function getDefaultListStyleStyle(): ListStyleStyleDeclaration;
271
293
 
272
294
  interface TextInlineStyleDeclaration extends HighlightStyleDeclaration {
273
295
  color: string;
@@ -283,6 +305,7 @@ interface TextInlineStyleDeclaration extends HighlightStyleDeclaration {
283
305
  textOrientation: TextOrientation;
284
306
  textDecoration: TextDecoration;
285
307
  }
308
+ declare function getDefaultTextInlineStyle(): TextInlineStyleDeclaration;
286
309
 
287
310
  interface TextLineStyleDeclaration extends ListStyleStyleDeclaration {
288
311
  writingMode: WritingMode;
@@ -291,6 +314,7 @@ interface TextLineStyleDeclaration extends ListStyleStyleDeclaration {
291
314
  textIndent: number;
292
315
  lineHeight: number;
293
316
  }
317
+ declare function getDefaultTextLineStyle(): TextLineStyleDeclaration;
294
318
 
295
319
  interface TextDrawStyleDeclaration {
296
320
  textStrokeWidth: number;
@@ -298,10 +322,12 @@ interface TextDrawStyleDeclaration {
298
322
  }
299
323
  interface TextStyleDeclaration extends TextLineStyleDeclaration, TextInlineStyleDeclaration, TextDrawStyleDeclaration {
300
324
  }
325
+ declare function getDefaultTextStyle(): TextStyleDeclaration;
301
326
 
302
327
  interface StyleDeclaration extends TextStyleDeclaration, ElementStyleDeclaration {
303
328
  }
304
- type StyleProp = Partial<StyleDeclaration>;
329
+ type StyleProperty = Partial<StyleDeclaration>;
330
+ declare function getDefaultStyle(): StyleDeclaration;
305
331
 
306
332
  interface FragmentContent extends Partial<StyleDeclaration> {
307
333
  content: string;
@@ -318,40 +344,32 @@ interface TextDeclaration {
318
344
  measureDom?: any;
319
345
  fonts?: any;
320
346
  }
321
- type TextProp = string | TextContent | (TextDeclaration & {
347
+ type TextProperty = string | TextContent | (TextDeclaration & {
322
348
  content: TextContent;
323
349
  }) | TextDeclaration;
324
-
325
- type VideoSource = string;
326
- interface VideoDeclaration {
327
- src: VideoSource;
328
- opacity?: number;
329
- }
330
- type VideoProp = None | VideoSource | VideoDeclaration;
350
+ declare function normalizeTextContent(content?: TextContent): TextContentDeclaration;
351
+ declare function normalizeText(text?: TextProperty): TextDeclaration | undefined;
331
352
 
332
353
  interface IDOCElement extends IDOCNode {
333
- style?: StyleProp;
334
- image?: ImageProp;
335
- video?: VideoProp;
336
- audio?: AudioProp;
337
- text?: TextProp;
338
- geometry?: GeometryProp;
339
- fill?: FillProp;
340
- outline?: OutlineProp;
341
- shadow?: ShadowProp;
354
+ style?: StyleProperty;
355
+ text?: TextProperty;
356
+ geometry?: GeometryProperty;
357
+ fill?: FillProperty;
358
+ outline?: OutlineProperty;
359
+ background?: BackgroundProperty;
360
+ shadow?: ShadowProperty;
342
361
  children?: IDOCElement[];
343
362
  }
344
363
  interface IDOCElementDeclaration extends IDOCElement {
345
- image?: ImageDeclaration;
346
- video?: VideoDeclaration;
347
- audio?: AudioDeclaration;
348
364
  text?: TextDeclaration;
349
365
  geometry?: GeometryDeclaration;
350
366
  fill?: FillDeclaration;
351
367
  outline?: OutlineDeclaration;
368
+ background?: BackgroundDeclaration;
352
369
  shadow?: ShadowDeclaration;
353
370
  children?: IDOCElementDeclaration[];
354
371
  }
372
+ declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration;
355
373
 
356
374
  interface IDOCDocument extends IDOCElement {
357
375
  fonts?: any;
@@ -359,40 +377,8 @@ interface IDOCDocument extends IDOCElement {
359
377
  interface IDOCDocumentDeclaration extends IDOCElementDeclaration {
360
378
  fonts?: any;
361
379
  }
362
-
363
- declare function getDefaultElementStyle(): ElementStyleDeclaration;
364
-
365
- declare function getDefaultLayoutStyle(): LayoutStyleDeclaration;
366
-
367
- declare function getDefaultShadowStyle(): ShadowStyleDeclaration;
368
-
369
- declare function getDefaultStyle(): StyleDeclaration;
370
-
371
- declare function getDefaultTextStyle(): TextStyleDeclaration;
372
-
373
- declare function getDefaultTransformStyle(): TransformStyleDeclaration;
380
+ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
374
381
 
375
382
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
376
- declare function deepClearUndef<T>(obj: T): T;
377
-
378
- declare function normalizeAudio(audio?: AudioProp): AudioDeclaration | undefined;
379
-
380
- declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration;
381
-
382
- declare function normalizeFill(fill?: FillProp): FillDeclaration | undefined;
383
-
384
- declare function normalizeGeometry(geometry?: GeometryProp): GeometryDeclaration | undefined;
385
-
386
- declare function normalizeImage(image?: ImageProp): ImageDeclaration | undefined;
387
-
388
- declare function normalizeOutline(outline?: OutlineProp): OutlineDeclaration | undefined;
389
-
390
- declare function normalizeShadow(shadow?: ShadowProp): ShadowDeclaration | undefined;
391
-
392
- declare function normalizeText(text?: TextProp): TextDeclaration | undefined;
393
-
394
- declare function normalizeTextContent(content?: TextContent): TextContentDeclaration;
395
-
396
- declare function normalizeVideo(video?: VideoProp): VideoDeclaration | undefined;
397
383
 
398
- export { type Align, type AudioDeclaration, type AudioProp, type AudioSource, type BorderStyle, type BoxShadow, type BoxSizing, type ColorFillDeclaration, type CommonFillDeclaration, type Direction, type Display, type ElementStyleDeclaration, type FillDeclaration, type FillProp, type FillRule, type FlexDirection, type FlexWrap, type FontKerning, type FontStyle, type FontWeight, type FragmentContent, type GeometryDeclaration, type GeometryProp, type HighlightColormap, type HighlightDeclaration, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightStyleDeclaration, type HighlightThickness, type IDOCDocument, type IDOCDocumentDeclaration, type IDOCElement, type IDOCElementDeclaration, type IDOCNode, type ImageDeclaration, type ImageFillDeclaration, type ImageFillSource, type ImageFillStretch, type ImageFillStretchRect, type ImageFillTile, type ImageProp, type ImageSource, type ImageSourceRect, type Justify, type LayoutStyleDeclaration, type ListStyleColormap, type ListStyleDeclaration, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleStyleDeclaration, type ListStyleType, type MetaProp, type OutlineDeclaration, type OutlineProp, type Overflow, type ParagraphContent, type Path2DDeclaration, type Path2DStyle, type PointerEvents, type Position, type SVGPathData, type ShadowDeclaration, type ShadowProp, type ShadowStyleDeclaration, type StrokeLinecap, type StrokeLinejoin, type StyleDeclaration, type StyleProp, type StyleUnit, type TextAlign, type TextContent, type TextContentDeclaration, type TextContentFlat, type TextDeclaration, type TextDecoration, type TextDrawStyleDeclaration, type TextInlineStyleDeclaration, type TextLineStyleDeclaration, type TextOrientation, type TextProp, type TextStyleDeclaration, type TextTransform, type TextWrap, type TransformStyleDeclaration, type VerticalAlign, type VideoDeclaration, type VideoProp, type VideoSource, type Visibility, type WritingMode, clearUndef, deepClearUndef, getDefaultElementStyle, getDefaultLayoutStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeAudio, normalizeElement, normalizeFill, normalizeGeometry, normalizeImage, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent, normalizeVideo };
384
+ export { type Align, type BorderStyle, type BoxShadow, type BoxSizing, type Direction, type Display, type ElementStyleDeclaration, type FillDeclaration, type FillProperty, type FillRule, type FlexDirection, type FlexWrap, type FontKerning, type FontStyle, type FontWeight, type FragmentContent, type GeometryDeclaration, type GeometryPathDeclaration, type GeometryPathStyle, type GeometryProperty, type GradientFillDeclaration, type HighlightColormap, type HighlightDeclaration, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightStyleDeclaration, type HighlightThickness, type IDOCDocument, type IDOCDocumentDeclaration, type IDOCElement, type IDOCElementDeclaration, type IDOCNode, type Justify, type LayoutStyleDeclaration, type ListStyleColormap, type ListStyleDeclaration, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleStyleDeclaration, type ListStyleType, type MetaProperty, type None, type OutlineDeclaration, type OutlineProperty, type Overflow, type ParagraphContent, type PointerEvents, type Position, type SVGPathData, type ShadowDeclaration, type ShadowProperty, type ShadowStyleDeclaration, type SingleFillDeclaration, type SolidFillDeclaration, type StrokeLinecap, type StrokeLinejoin, type StyleDeclaration, type StyleProperty, type StyleUnit, type TextAlign, type TextContent, type TextContentDeclaration, type TextContentFlat, type TextDeclaration, type TextDecoration, type TextDrawStyleDeclaration, type TextInlineStyleDeclaration, type TextLineStyleDeclaration, type TextOrientation, type TextProperty, type TextStyleDeclaration, type TextTransform, type TextWrap, type TextureFillDeclaration, type TextureFillSourceRect, type TextureFillSourceURL, type TextureFillStretch, type TextureFillStretchRect, type TextureFillTile, type TransformStyleDeclaration, type VerticalAlign, type Visibility, type WritingMode, clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeDocument, normalizeElement, normalizeFill, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent };