modern-idoc 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -354,6 +354,7 @@ exports.getDefaultTextInlineStyle = getDefaultTextInlineStyle;
354
354
  exports.getDefaultTextLineStyle = getDefaultTextLineStyle;
355
355
  exports.getDefaultTextStyle = getDefaultTextStyle;
356
356
  exports.getDefaultTransformStyle = getDefaultTransformStyle;
357
+ exports.normalizeBackground = normalizeBackground;
357
358
  exports.normalizeDocument = normalizeDocument;
358
359
  exports.normalizeElement = normalizeElement;
359
360
  exports.normalizeFill = normalizeFill;
package/dist/index.d.cts CHANGED
@@ -1,10 +1,67 @@
1
1
  type None = 'none';
2
+ declare interface RgbColor {
3
+ r: number;
4
+ g: number;
5
+ b: number;
6
+ }
7
+ declare interface HslColor {
8
+ h: number;
9
+ s: number;
10
+ l: number;
11
+ }
12
+ declare interface HsvColor {
13
+ h: number;
14
+ s: number;
15
+ v: number;
16
+ }
17
+ declare interface HwbColor {
18
+ h: number;
19
+ w: number;
20
+ b: number;
21
+ }
22
+ interface XyzColor {
23
+ x: number;
24
+ y: number;
25
+ z: number;
26
+ }
27
+ interface LabColor {
28
+ l: number;
29
+ a: number;
30
+ b: number;
31
+ }
32
+ interface LchColor {
33
+ l: number;
34
+ c: number;
35
+ h: number;
36
+ }
37
+ interface CmykColor {
38
+ c: number;
39
+ m: number;
40
+ y: number;
41
+ k: number;
42
+ }
43
+ declare type WithAlpha<O> = O & {
44
+ a: number;
45
+ };
46
+ declare type RgbaColor = WithAlpha<RgbColor>;
47
+ declare type HslaColor = WithAlpha<HslColor>;
48
+ declare type HsvaColor = WithAlpha<HsvColor>;
49
+ declare type HwbaColor = WithAlpha<HwbColor>;
50
+ declare type XyzaColor = WithAlpha<XyzColor>;
51
+ declare type LabaColor = LabColor & {
52
+ alpha: number;
53
+ };
54
+ declare type LchaColor = WithAlpha<LchColor>;
55
+ declare type CmykaColor = WithAlpha<CmykColor>;
56
+ declare type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor | LchColor | LchaColor | CmykColor | CmykaColor;
57
+ declare type AnyColor = string | ObjectColor;
58
+ type ColorValue = number | AnyColor;
2
59
 
3
60
  interface GradientFillDeclaration {
4
61
  }
5
62
 
6
63
  interface SolidFillDeclaration {
7
- color: string;
64
+ color: ColorValue;
8
65
  }
9
66
 
10
67
  /**
@@ -60,6 +117,7 @@ interface AudioBackgroundDeclaration {
60
117
  }
61
118
  type BackgroundDeclaration = FillDeclaration & Partial<AudioBackgroundDeclaration>;
62
119
  type BackgroundProperty = None | string | BackgroundDeclaration;
120
+ declare function normalizeBackground(background?: BackgroundProperty): BackgroundDeclaration | undefined;
63
121
 
64
122
  type SVGPathData = string;
65
123
  type FillRule = 'nonzero' | 'evenodd';
@@ -69,7 +127,7 @@ interface GeometryPathStyle {
69
127
  [key: string]: any;
70
128
  opacity: number;
71
129
  visibility: string;
72
- shadowColor: string;
130
+ shadowColor: ColorValue;
73
131
  shadowOffsetX: number;
74
132
  shadowOffsetY: number;
75
133
  shadowBlur: number;
@@ -110,8 +168,8 @@ interface IDOCNode {
110
168
  interface OutlineDeclaration {
111
169
  width?: number;
112
170
  style?: 'dashed' | 'solid' | string;
113
- image?: string;
114
- color?: string;
171
+ src?: string;
172
+ color?: ColorValue;
115
173
  opacity?: number;
116
174
  }
117
175
  type OutlineProperty = None | string | Partial<OutlineDeclaration>;
@@ -119,7 +177,7 @@ declare function normalizeOutline(outline?: OutlineProperty): OutlineDeclaration
119
177
 
120
178
  type BoxShadow = None | string;
121
179
  interface ShadowDeclaration {
122
- color: string;
180
+ color: ColorValue;
123
181
  offsetX?: number;
124
182
  offsetY?: number;
125
183
  blur?: number;
@@ -127,7 +185,7 @@ interface ShadowDeclaration {
127
185
  type ShadowProperty = None | BoxShadow | ShadowDeclaration;
128
186
  interface ShadowStyleDeclaration {
129
187
  boxShadow: BoxShadow;
130
- shadowColor?: string;
188
+ shadowColor?: ColorValue;
131
189
  shadowOffsetX?: number;
132
190
  shadowOffsetY?: number;
133
191
  shadowBlur?: number;
@@ -231,13 +289,13 @@ declare function getDefaultTransformStyle(): TransformStyleDeclaration;
231
289
 
232
290
  interface ElementStyleDeclaration extends LayoutStyleDeclaration, TransformStyleDeclaration, ShadowStyleDeclaration {
233
291
  backgroundImage?: None | string;
234
- backgroundColor?: None | string;
292
+ backgroundColor?: None | ColorValue;
235
293
  borderRadius: number;
236
- borderColor?: None | string;
294
+ borderColor?: None | ColorValue;
237
295
  borderStyle: BorderStyle;
238
296
  outlineWidth: number;
239
297
  outlineOffset: number;
240
- outlineColor: None | string;
298
+ outlineColor: None | ColorValue;
241
299
  outlineStyle: string;
242
300
  visibility: Visibility;
243
301
  filter: string;
@@ -284,7 +342,7 @@ interface ListStyleStyleDeclaration {
284
342
  declare function getDefaultListStyleStyle(): ListStyleStyleDeclaration;
285
343
 
286
344
  interface TextInlineStyleDeclaration extends HighlightStyleDeclaration {
287
- color: string;
345
+ color: ColorValue;
288
346
  verticalAlign: VerticalAlign;
289
347
  letterSpacing: number;
290
348
  wordSpacing: number;
@@ -310,7 +368,7 @@ declare function getDefaultTextLineStyle(): TextLineStyleDeclaration;
310
368
 
311
369
  interface TextDrawStyleDeclaration {
312
370
  textStrokeWidth: number;
313
- textStrokeColor: string;
371
+ textStrokeColor: ColorValue;
314
372
  }
315
373
  interface TextStyleDeclaration extends TextLineStyleDeclaration, TextInlineStyleDeclaration, TextDrawStyleDeclaration {
316
374
  }
@@ -373,4 +431,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
373
431
 
374
432
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
375
433
 
376
- 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 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 };
434
+ export { type Align, type AnyColor, type AudioBackgroundDeclaration, type BackgroundDeclaration, type BackgroundProperty, type BorderStyle, type BoxShadow, type BoxSizing, type CmykColor, type CmykaColor, type ColorValue, 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 HslColor, type HslaColor, type HsvColor, type HsvaColor, type HwbColor, type HwbaColor, type IDOCDocument, type IDOCDocumentDeclaration, type IDOCElement, type IDOCElementDeclaration, type IDOCNode, type Justify, type LabColor, type LabaColor, type LayoutStyleDeclaration, type LchColor, type LchaColor, type ListStyleColormap, type ListStyleDeclaration, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleStyleDeclaration, type ListStyleType, type MetaProperty, type None, type ObjectColor, type OutlineDeclaration, type OutlineProperty, type Overflow, type ParagraphContent, type PointerEvents, type Position, type RgbColor, type RgbaColor, type SVGPathData, type ShadowDeclaration, type ShadowProperty, type ShadowStyleDeclaration, 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, type XyzColor, type XyzaColor, clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeBackground, normalizeDocument, normalizeElement, normalizeFill, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent };
package/dist/index.d.mts CHANGED
@@ -1,10 +1,67 @@
1
1
  type None = 'none';
2
+ declare interface RgbColor {
3
+ r: number;
4
+ g: number;
5
+ b: number;
6
+ }
7
+ declare interface HslColor {
8
+ h: number;
9
+ s: number;
10
+ l: number;
11
+ }
12
+ declare interface HsvColor {
13
+ h: number;
14
+ s: number;
15
+ v: number;
16
+ }
17
+ declare interface HwbColor {
18
+ h: number;
19
+ w: number;
20
+ b: number;
21
+ }
22
+ interface XyzColor {
23
+ x: number;
24
+ y: number;
25
+ z: number;
26
+ }
27
+ interface LabColor {
28
+ l: number;
29
+ a: number;
30
+ b: number;
31
+ }
32
+ interface LchColor {
33
+ l: number;
34
+ c: number;
35
+ h: number;
36
+ }
37
+ interface CmykColor {
38
+ c: number;
39
+ m: number;
40
+ y: number;
41
+ k: number;
42
+ }
43
+ declare type WithAlpha<O> = O & {
44
+ a: number;
45
+ };
46
+ declare type RgbaColor = WithAlpha<RgbColor>;
47
+ declare type HslaColor = WithAlpha<HslColor>;
48
+ declare type HsvaColor = WithAlpha<HsvColor>;
49
+ declare type HwbaColor = WithAlpha<HwbColor>;
50
+ declare type XyzaColor = WithAlpha<XyzColor>;
51
+ declare type LabaColor = LabColor & {
52
+ alpha: number;
53
+ };
54
+ declare type LchaColor = WithAlpha<LchColor>;
55
+ declare type CmykaColor = WithAlpha<CmykColor>;
56
+ declare type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor | LchColor | LchaColor | CmykColor | CmykaColor;
57
+ declare type AnyColor = string | ObjectColor;
58
+ type ColorValue = number | AnyColor;
2
59
 
3
60
  interface GradientFillDeclaration {
4
61
  }
5
62
 
6
63
  interface SolidFillDeclaration {
7
- color: string;
64
+ color: ColorValue;
8
65
  }
9
66
 
10
67
  /**
@@ -60,6 +117,7 @@ interface AudioBackgroundDeclaration {
60
117
  }
61
118
  type BackgroundDeclaration = FillDeclaration & Partial<AudioBackgroundDeclaration>;
62
119
  type BackgroundProperty = None | string | BackgroundDeclaration;
120
+ declare function normalizeBackground(background?: BackgroundProperty): BackgroundDeclaration | undefined;
63
121
 
64
122
  type SVGPathData = string;
65
123
  type FillRule = 'nonzero' | 'evenodd';
@@ -69,7 +127,7 @@ interface GeometryPathStyle {
69
127
  [key: string]: any;
70
128
  opacity: number;
71
129
  visibility: string;
72
- shadowColor: string;
130
+ shadowColor: ColorValue;
73
131
  shadowOffsetX: number;
74
132
  shadowOffsetY: number;
75
133
  shadowBlur: number;
@@ -110,8 +168,8 @@ interface IDOCNode {
110
168
  interface OutlineDeclaration {
111
169
  width?: number;
112
170
  style?: 'dashed' | 'solid' | string;
113
- image?: string;
114
- color?: string;
171
+ src?: string;
172
+ color?: ColorValue;
115
173
  opacity?: number;
116
174
  }
117
175
  type OutlineProperty = None | string | Partial<OutlineDeclaration>;
@@ -119,7 +177,7 @@ declare function normalizeOutline(outline?: OutlineProperty): OutlineDeclaration
119
177
 
120
178
  type BoxShadow = None | string;
121
179
  interface ShadowDeclaration {
122
- color: string;
180
+ color: ColorValue;
123
181
  offsetX?: number;
124
182
  offsetY?: number;
125
183
  blur?: number;
@@ -127,7 +185,7 @@ interface ShadowDeclaration {
127
185
  type ShadowProperty = None | BoxShadow | ShadowDeclaration;
128
186
  interface ShadowStyleDeclaration {
129
187
  boxShadow: BoxShadow;
130
- shadowColor?: string;
188
+ shadowColor?: ColorValue;
131
189
  shadowOffsetX?: number;
132
190
  shadowOffsetY?: number;
133
191
  shadowBlur?: number;
@@ -231,13 +289,13 @@ declare function getDefaultTransformStyle(): TransformStyleDeclaration;
231
289
 
232
290
  interface ElementStyleDeclaration extends LayoutStyleDeclaration, TransformStyleDeclaration, ShadowStyleDeclaration {
233
291
  backgroundImage?: None | string;
234
- backgroundColor?: None | string;
292
+ backgroundColor?: None | ColorValue;
235
293
  borderRadius: number;
236
- borderColor?: None | string;
294
+ borderColor?: None | ColorValue;
237
295
  borderStyle: BorderStyle;
238
296
  outlineWidth: number;
239
297
  outlineOffset: number;
240
- outlineColor: None | string;
298
+ outlineColor: None | ColorValue;
241
299
  outlineStyle: string;
242
300
  visibility: Visibility;
243
301
  filter: string;
@@ -284,7 +342,7 @@ interface ListStyleStyleDeclaration {
284
342
  declare function getDefaultListStyleStyle(): ListStyleStyleDeclaration;
285
343
 
286
344
  interface TextInlineStyleDeclaration extends HighlightStyleDeclaration {
287
- color: string;
345
+ color: ColorValue;
288
346
  verticalAlign: VerticalAlign;
289
347
  letterSpacing: number;
290
348
  wordSpacing: number;
@@ -310,7 +368,7 @@ declare function getDefaultTextLineStyle(): TextLineStyleDeclaration;
310
368
 
311
369
  interface TextDrawStyleDeclaration {
312
370
  textStrokeWidth: number;
313
- textStrokeColor: string;
371
+ textStrokeColor: ColorValue;
314
372
  }
315
373
  interface TextStyleDeclaration extends TextLineStyleDeclaration, TextInlineStyleDeclaration, TextDrawStyleDeclaration {
316
374
  }
@@ -373,4 +431,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
373
431
 
374
432
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
375
433
 
376
- 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 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 };
434
+ export { type Align, type AnyColor, type AudioBackgroundDeclaration, type BackgroundDeclaration, type BackgroundProperty, type BorderStyle, type BoxShadow, type BoxSizing, type CmykColor, type CmykaColor, type ColorValue, 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 HslColor, type HslaColor, type HsvColor, type HsvaColor, type HwbColor, type HwbaColor, type IDOCDocument, type IDOCDocumentDeclaration, type IDOCElement, type IDOCElementDeclaration, type IDOCNode, type Justify, type LabColor, type LabaColor, type LayoutStyleDeclaration, type LchColor, type LchaColor, type ListStyleColormap, type ListStyleDeclaration, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleStyleDeclaration, type ListStyleType, type MetaProperty, type None, type ObjectColor, type OutlineDeclaration, type OutlineProperty, type Overflow, type ParagraphContent, type PointerEvents, type Position, type RgbColor, type RgbaColor, type SVGPathData, type ShadowDeclaration, type ShadowProperty, type ShadowStyleDeclaration, 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, type XyzColor, type XyzaColor, clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeBackground, normalizeDocument, normalizeElement, normalizeFill, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,67 @@
1
1
  type None = 'none';
2
+ declare interface RgbColor {
3
+ r: number;
4
+ g: number;
5
+ b: number;
6
+ }
7
+ declare interface HslColor {
8
+ h: number;
9
+ s: number;
10
+ l: number;
11
+ }
12
+ declare interface HsvColor {
13
+ h: number;
14
+ s: number;
15
+ v: number;
16
+ }
17
+ declare interface HwbColor {
18
+ h: number;
19
+ w: number;
20
+ b: number;
21
+ }
22
+ interface XyzColor {
23
+ x: number;
24
+ y: number;
25
+ z: number;
26
+ }
27
+ interface LabColor {
28
+ l: number;
29
+ a: number;
30
+ b: number;
31
+ }
32
+ interface LchColor {
33
+ l: number;
34
+ c: number;
35
+ h: number;
36
+ }
37
+ interface CmykColor {
38
+ c: number;
39
+ m: number;
40
+ y: number;
41
+ k: number;
42
+ }
43
+ declare type WithAlpha<O> = O & {
44
+ a: number;
45
+ };
46
+ declare type RgbaColor = WithAlpha<RgbColor>;
47
+ declare type HslaColor = WithAlpha<HslColor>;
48
+ declare type HsvaColor = WithAlpha<HsvColor>;
49
+ declare type HwbaColor = WithAlpha<HwbColor>;
50
+ declare type XyzaColor = WithAlpha<XyzColor>;
51
+ declare type LabaColor = LabColor & {
52
+ alpha: number;
53
+ };
54
+ declare type LchaColor = WithAlpha<LchColor>;
55
+ declare type CmykaColor = WithAlpha<CmykColor>;
56
+ declare type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor | LchColor | LchaColor | CmykColor | CmykaColor;
57
+ declare type AnyColor = string | ObjectColor;
58
+ type ColorValue = number | AnyColor;
2
59
 
3
60
  interface GradientFillDeclaration {
4
61
  }
5
62
 
6
63
  interface SolidFillDeclaration {
7
- color: string;
64
+ color: ColorValue;
8
65
  }
9
66
 
10
67
  /**
@@ -60,6 +117,7 @@ interface AudioBackgroundDeclaration {
60
117
  }
61
118
  type BackgroundDeclaration = FillDeclaration & Partial<AudioBackgroundDeclaration>;
62
119
  type BackgroundProperty = None | string | BackgroundDeclaration;
120
+ declare function normalizeBackground(background?: BackgroundProperty): BackgroundDeclaration | undefined;
63
121
 
64
122
  type SVGPathData = string;
65
123
  type FillRule = 'nonzero' | 'evenodd';
@@ -69,7 +127,7 @@ interface GeometryPathStyle {
69
127
  [key: string]: any;
70
128
  opacity: number;
71
129
  visibility: string;
72
- shadowColor: string;
130
+ shadowColor: ColorValue;
73
131
  shadowOffsetX: number;
74
132
  shadowOffsetY: number;
75
133
  shadowBlur: number;
@@ -110,8 +168,8 @@ interface IDOCNode {
110
168
  interface OutlineDeclaration {
111
169
  width?: number;
112
170
  style?: 'dashed' | 'solid' | string;
113
- image?: string;
114
- color?: string;
171
+ src?: string;
172
+ color?: ColorValue;
115
173
  opacity?: number;
116
174
  }
117
175
  type OutlineProperty = None | string | Partial<OutlineDeclaration>;
@@ -119,7 +177,7 @@ declare function normalizeOutline(outline?: OutlineProperty): OutlineDeclaration
119
177
 
120
178
  type BoxShadow = None | string;
121
179
  interface ShadowDeclaration {
122
- color: string;
180
+ color: ColorValue;
123
181
  offsetX?: number;
124
182
  offsetY?: number;
125
183
  blur?: number;
@@ -127,7 +185,7 @@ interface ShadowDeclaration {
127
185
  type ShadowProperty = None | BoxShadow | ShadowDeclaration;
128
186
  interface ShadowStyleDeclaration {
129
187
  boxShadow: BoxShadow;
130
- shadowColor?: string;
188
+ shadowColor?: ColorValue;
131
189
  shadowOffsetX?: number;
132
190
  shadowOffsetY?: number;
133
191
  shadowBlur?: number;
@@ -231,13 +289,13 @@ declare function getDefaultTransformStyle(): TransformStyleDeclaration;
231
289
 
232
290
  interface ElementStyleDeclaration extends LayoutStyleDeclaration, TransformStyleDeclaration, ShadowStyleDeclaration {
233
291
  backgroundImage?: None | string;
234
- backgroundColor?: None | string;
292
+ backgroundColor?: None | ColorValue;
235
293
  borderRadius: number;
236
- borderColor?: None | string;
294
+ borderColor?: None | ColorValue;
237
295
  borderStyle: BorderStyle;
238
296
  outlineWidth: number;
239
297
  outlineOffset: number;
240
- outlineColor: None | string;
298
+ outlineColor: None | ColorValue;
241
299
  outlineStyle: string;
242
300
  visibility: Visibility;
243
301
  filter: string;
@@ -284,7 +342,7 @@ interface ListStyleStyleDeclaration {
284
342
  declare function getDefaultListStyleStyle(): ListStyleStyleDeclaration;
285
343
 
286
344
  interface TextInlineStyleDeclaration extends HighlightStyleDeclaration {
287
- color: string;
345
+ color: ColorValue;
288
346
  verticalAlign: VerticalAlign;
289
347
  letterSpacing: number;
290
348
  wordSpacing: number;
@@ -310,7 +368,7 @@ declare function getDefaultTextLineStyle(): TextLineStyleDeclaration;
310
368
 
311
369
  interface TextDrawStyleDeclaration {
312
370
  textStrokeWidth: number;
313
- textStrokeColor: string;
371
+ textStrokeColor: ColorValue;
314
372
  }
315
373
  interface TextStyleDeclaration extends TextLineStyleDeclaration, TextInlineStyleDeclaration, TextDrawStyleDeclaration {
316
374
  }
@@ -373,4 +431,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
373
431
 
374
432
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
375
433
 
376
- 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 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 };
434
+ export { type Align, type AnyColor, type AudioBackgroundDeclaration, type BackgroundDeclaration, type BackgroundProperty, type BorderStyle, type BoxShadow, type BoxSizing, type CmykColor, type CmykaColor, type ColorValue, 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 HslColor, type HslaColor, type HsvColor, type HsvaColor, type HwbColor, type HwbaColor, type IDOCDocument, type IDOCDocumentDeclaration, type IDOCElement, type IDOCElementDeclaration, type IDOCNode, type Justify, type LabColor, type LabaColor, type LayoutStyleDeclaration, type LchColor, type LchaColor, type ListStyleColormap, type ListStyleDeclaration, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleStyleDeclaration, type ListStyleType, type MetaProperty, type None, type ObjectColor, type OutlineDeclaration, type OutlineProperty, type Overflow, type ParagraphContent, type PointerEvents, type Position, type RgbColor, type RgbaColor, type SVGPathData, type ShadowDeclaration, type ShadowProperty, type ShadowStyleDeclaration, 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, type XyzColor, type XyzaColor, clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeBackground, normalizeDocument, normalizeElement, normalizeFill, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- (function(t,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(t=typeof globalThis<"u"?globalThis:t||self,r(t.modernIdoc={}))})(this,function(t){"use strict";function r(e){if(!(!e||e==="none"))return typeof e=="string"?{src:e}:e}function d(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function g(e){if(!(!e||e==="none"))return typeof e=="string"?{paths:[{data:e}]}:Array.isArray(e)?{paths:e.map(i=>typeof i=="string"?{data:i}:i)}:e}function s(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function c(){return{boxShadow:"none"}}function m(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function f(e=""){return(Array.isArray(e)?e:[e]).map(n=>typeof n=="string"?{fragments:[{content:n}]}:"content"in n?{fragments:[{...n}]}:"fragments"in n?{...n,fragments:n.fragments.map(o=>({...o}))}:Array.isArray(n)?{fragments:n.map(o=>typeof o=="string"?{content:o}:{...o})}:{fragments:[]})}function y(e){if(!(!e||e==="none"))return typeof e=="string"?{content:[{fragments:[{content:e}]}]}:"content"in e?{...e,content:f(e.content)}:{content:f(e)}}function l(e,i=!1){if(typeof e!="object"||!e)return e;if(Array.isArray(e))return i?e.map(o=>l(o,i)):e;const n={};for(const o in e){const a=e[o];a!=null&&(i?n[o]=l(a,i):n[o]=a)}return n}function u(e){var i;return l({...e,background:r(e.background),text:y(e.text),geometry:g(e.geometry),fill:d(e.fill),outline:s(e.outline),shadow:m(e.shadow),children:(i=e.children)==null?void 0:i.map(n=>u(n))})}function w(e){return u(e)}function v(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function h(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function S(){return{...v(),...h(),...c(),backgroundImage:"none",backgroundColor:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"#000000",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function D(){return{highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function z(){return{listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function T(){return{...D(),color:"black",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function p(){return{...z(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function b(){return{...p(),...T(),textStrokeWidth:0,textStrokeColor:"black"}}function k(){return{...S(),...b()}}t.clearUndef=l,t.getDefaultElementStyle=S,t.getDefaultHighlightStyle=D,t.getDefaultLayoutStyle=v,t.getDefaultListStyleStyle=z,t.getDefaultShadowStyle=c,t.getDefaultStyle=k,t.getDefaultTextInlineStyle=T,t.getDefaultTextLineStyle=p,t.getDefaultTextStyle=b,t.getDefaultTransformStyle=h,t.normalizeDocument=w,t.normalizeElement=u,t.normalizeFill=d,t.normalizeGeometry=g,t.normalizeOutline=s,t.normalizeShadow=m,t.normalizeText=y,t.normalizeTextContent=f,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
1
+ (function(t,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(t=typeof globalThis<"u"?globalThis:t||self,r(t.modernIdoc={}))})(this,function(t){"use strict";function r(e){if(!(!e||e==="none"))return typeof e=="string"?{src:e}:e}function d(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function g(e){if(!(!e||e==="none"))return typeof e=="string"?{paths:[{data:e}]}:Array.isArray(e)?{paths:e.map(i=>typeof i=="string"?{data:i}:i)}:e}function s(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function c(){return{boxShadow:"none"}}function m(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function f(e=""){return(Array.isArray(e)?e:[e]).map(n=>typeof n=="string"?{fragments:[{content:n}]}:"content"in n?{fragments:[{...n}]}:"fragments"in n?{...n,fragments:n.fragments.map(o=>({...o}))}:Array.isArray(n)?{fragments:n.map(o=>typeof o=="string"?{content:o}:{...o})}:{fragments:[]})}function y(e){if(!(!e||e==="none"))return typeof e=="string"?{content:[{fragments:[{content:e}]}]}:"content"in e?{...e,content:f(e.content)}:{content:f(e)}}function l(e,i=!1){if(typeof e!="object"||!e)return e;if(Array.isArray(e))return i?e.map(o=>l(o,i)):e;const n={};for(const o in e){const a=e[o];a!=null&&(i?n[o]=l(a,i):n[o]=a)}return n}function u(e){var i;return l({...e,background:r(e.background),text:y(e.text),geometry:g(e.geometry),fill:d(e.fill),outline:s(e.outline),shadow:m(e.shadow),children:(i=e.children)==null?void 0:i.map(n=>u(n))})}function k(e){return u(e)}function v(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function h(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function S(){return{...v(),...h(),...c(),backgroundImage:"none",backgroundColor:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"#000000",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function D(){return{highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function z(){return{listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function T(){return{...D(),color:"black",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function b(){return{...z(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function p(){return{...b(),...T(),textStrokeWidth:0,textStrokeColor:"black"}}function w(){return{...S(),...p()}}t.clearUndef=l,t.getDefaultElementStyle=S,t.getDefaultHighlightStyle=D,t.getDefaultLayoutStyle=v,t.getDefaultListStyleStyle=z,t.getDefaultShadowStyle=c,t.getDefaultStyle=w,t.getDefaultTextInlineStyle=T,t.getDefaultTextLineStyle=b,t.getDefaultTextStyle=p,t.getDefaultTransformStyle=h,t.normalizeBackground=r,t.normalizeDocument=k,t.normalizeElement=u,t.normalizeFill=d,t.normalizeGeometry=g,t.normalizeOutline=s,t.normalizeShadow=m,t.normalizeText=y,t.normalizeTextContent=f,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -341,4 +341,4 @@ function getDefaultStyle() {
341
341
  };
342
342
  }
343
343
 
344
- export { clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeDocument, normalizeElement, normalizeFill, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent };
344
+ export { clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeBackground, normalizeDocument, normalizeElement, normalizeFill, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-idoc",
3
3
  "type": "module",
4
- "version": "0.3.2",
4
+ "version": "0.3.4",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "Intermediate document for modern codec libs",
7
7
  "author": "wxm",