modern-idoc 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -75,3 +75,14 @@ const pdf: IDOCDocument = {
75
75
  ],
76
76
  }
77
77
  ```
78
+
79
+ ## Types
80
+
81
+ [view d.ts type file](https://unpkg.com/modern-idoc/dist/index.d.ts)
82
+
83
+ ## Refer to these packages for usage
84
+
85
+ - [modern-text](https://github.com/qq15725/modern-text)
86
+ - [modern-pdf](https://github.com/qq15725/modern-pdf)
87
+ - [modern-openxml](https://github.com/qq15725/modern-openxml)
88
+ - [modern-canvas](https://github.com/qq15725/modern-canvas)
package/dist/index.cjs CHANGED
@@ -4,11 +4,7 @@ function normalizeBackground(background) {
4
4
  if (!background || background === "none") {
5
5
  return void 0;
6
6
  } else if (typeof background === "string") {
7
- return [
8
- { type: "texture", src: background }
9
- ];
10
- } else if (!Array.isArray(background)) {
11
- return [background];
7
+ return { src: background };
12
8
  } else {
13
9
  return background;
14
10
  }
@@ -18,11 +14,7 @@ function normalizeFill(fill) {
18
14
  if (!fill || fill === "none") {
19
15
  return void 0;
20
16
  } else if (typeof fill === "string") {
21
- return [
22
- { type: "solid", color: fill }
23
- ];
24
- } else if (!Array.isArray(fill)) {
25
- return [fill];
17
+ return { color: fill };
26
18
  } else {
27
19
  return fill;
28
20
  }
package/dist/index.d.cts CHANGED
@@ -1,14 +1,10 @@
1
1
  type None = 'none';
2
2
 
3
3
  interface GradientFillDeclaration {
4
- type: 'gradient';
5
- opacity?: number;
6
4
  }
7
5
 
8
6
  interface SolidFillDeclaration {
9
- type: 'solid';
10
7
  color: string;
11
- opacity?: number;
12
8
  }
13
9
 
14
10
  /**
@@ -46,30 +42,24 @@ interface TextureFillTile {
46
42
  }
47
43
  type TextureFillSourceURL = string;
48
44
  interface TextureFillDeclaration {
49
- type: 'texture';
50
45
  src: TextureFillSourceURL;
51
46
  srcRect?: TextureFillSourceRect;
52
47
  dpi?: number;
53
- rotateWithShape?: boolean;
54
48
  stretch?: TextureFillStretch;
55
49
  tile?: TextureFillTile;
56
50
  opacity?: number;
51
+ rotateWithShape?: boolean;
57
52
  }
58
53
 
59
- type SingleFillDeclaration = TextureFillDeclaration | SolidFillDeclaration | GradientFillDeclaration;
60
- type FillDeclaration = SingleFillDeclaration[];
61
- type FillProperty = None | string | SingleFillDeclaration | FillDeclaration;
54
+ type FillDeclaration = Partial<TextureFillDeclaration> & Partial<SolidFillDeclaration> & Partial<GradientFillDeclaration>;
55
+ type FillProperty = None | string | FillDeclaration;
62
56
  declare function normalizeFill(fill?: FillProperty): FillDeclaration | undefined;
63
57
 
64
- type TextureBackgroundSourceURL = TextureFillSourceURL;
65
- type TextureBackgroundDeclaration = TextureFillDeclaration;
66
58
  interface AudioBackgroundDeclaration {
67
- type: 'audio';
68
59
  src: string;
69
60
  }
70
- type SingleBackgroundDeclaration = AudioBackgroundDeclaration | TextureBackgroundDeclaration;
71
- type BackgroundDeclaration = SingleBackgroundDeclaration[];
72
- type BackgroundProperty = None | TextureBackgroundSourceURL | SingleBackgroundDeclaration | BackgroundDeclaration;
61
+ type BackgroundDeclaration = FillDeclaration & Partial<AudioBackgroundDeclaration>;
62
+ type BackgroundProperty = None | string | BackgroundDeclaration;
73
63
 
74
64
  type SVGPathData = string;
75
65
  type FillRule = 'nonzero' | 'evenodd';
@@ -383,4 +373,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
383
373
 
384
374
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
385
375
 
386
- 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 };
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 };
package/dist/index.d.mts CHANGED
@@ -1,14 +1,10 @@
1
1
  type None = 'none';
2
2
 
3
3
  interface GradientFillDeclaration {
4
- type: 'gradient';
5
- opacity?: number;
6
4
  }
7
5
 
8
6
  interface SolidFillDeclaration {
9
- type: 'solid';
10
7
  color: string;
11
- opacity?: number;
12
8
  }
13
9
 
14
10
  /**
@@ -46,30 +42,24 @@ interface TextureFillTile {
46
42
  }
47
43
  type TextureFillSourceURL = string;
48
44
  interface TextureFillDeclaration {
49
- type: 'texture';
50
45
  src: TextureFillSourceURL;
51
46
  srcRect?: TextureFillSourceRect;
52
47
  dpi?: number;
53
- rotateWithShape?: boolean;
54
48
  stretch?: TextureFillStretch;
55
49
  tile?: TextureFillTile;
56
50
  opacity?: number;
51
+ rotateWithShape?: boolean;
57
52
  }
58
53
 
59
- type SingleFillDeclaration = TextureFillDeclaration | SolidFillDeclaration | GradientFillDeclaration;
60
- type FillDeclaration = SingleFillDeclaration[];
61
- type FillProperty = None | string | SingleFillDeclaration | FillDeclaration;
54
+ type FillDeclaration = Partial<TextureFillDeclaration> & Partial<SolidFillDeclaration> & Partial<GradientFillDeclaration>;
55
+ type FillProperty = None | string | FillDeclaration;
62
56
  declare function normalizeFill(fill?: FillProperty): FillDeclaration | undefined;
63
57
 
64
- type TextureBackgroundSourceURL = TextureFillSourceURL;
65
- type TextureBackgroundDeclaration = TextureFillDeclaration;
66
58
  interface AudioBackgroundDeclaration {
67
- type: 'audio';
68
59
  src: string;
69
60
  }
70
- type SingleBackgroundDeclaration = AudioBackgroundDeclaration | TextureBackgroundDeclaration;
71
- type BackgroundDeclaration = SingleBackgroundDeclaration[];
72
- type BackgroundProperty = None | TextureBackgroundSourceURL | SingleBackgroundDeclaration | BackgroundDeclaration;
61
+ type BackgroundDeclaration = FillDeclaration & Partial<AudioBackgroundDeclaration>;
62
+ type BackgroundProperty = None | string | BackgroundDeclaration;
73
63
 
74
64
  type SVGPathData = string;
75
65
  type FillRule = 'nonzero' | 'evenodd';
@@ -383,4 +373,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
383
373
 
384
374
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
385
375
 
386
- 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  type None = 'none';
2
2
 
3
3
  interface GradientFillDeclaration {
4
- type: 'gradient';
5
- opacity?: number;
6
4
  }
7
5
 
8
6
  interface SolidFillDeclaration {
9
- type: 'solid';
10
7
  color: string;
11
- opacity?: number;
12
8
  }
13
9
 
14
10
  /**
@@ -46,30 +42,24 @@ interface TextureFillTile {
46
42
  }
47
43
  type TextureFillSourceURL = string;
48
44
  interface TextureFillDeclaration {
49
- type: 'texture';
50
45
  src: TextureFillSourceURL;
51
46
  srcRect?: TextureFillSourceRect;
52
47
  dpi?: number;
53
- rotateWithShape?: boolean;
54
48
  stretch?: TextureFillStretch;
55
49
  tile?: TextureFillTile;
56
50
  opacity?: number;
51
+ rotateWithShape?: boolean;
57
52
  }
58
53
 
59
- type SingleFillDeclaration = TextureFillDeclaration | SolidFillDeclaration | GradientFillDeclaration;
60
- type FillDeclaration = SingleFillDeclaration[];
61
- type FillProperty = None | string | SingleFillDeclaration | FillDeclaration;
54
+ type FillDeclaration = Partial<TextureFillDeclaration> & Partial<SolidFillDeclaration> & Partial<GradientFillDeclaration>;
55
+ type FillProperty = None | string | FillDeclaration;
62
56
  declare function normalizeFill(fill?: FillProperty): FillDeclaration | undefined;
63
57
 
64
- type TextureBackgroundSourceURL = TextureFillSourceURL;
65
- type TextureBackgroundDeclaration = TextureFillDeclaration;
66
58
  interface AudioBackgroundDeclaration {
67
- type: 'audio';
68
59
  src: string;
69
60
  }
70
- type SingleBackgroundDeclaration = AudioBackgroundDeclaration | TextureBackgroundDeclaration;
71
- type BackgroundDeclaration = SingleBackgroundDeclaration[];
72
- type BackgroundProperty = None | TextureBackgroundSourceURL | SingleBackgroundDeclaration | BackgroundDeclaration;
61
+ type BackgroundDeclaration = FillDeclaration & Partial<AudioBackgroundDeclaration>;
62
+ type BackgroundProperty = None | string | BackgroundDeclaration;
73
63
 
74
64
  type SVGPathData = string;
75
65
  type FillRule = 'nonzero' | 'evenodd';
@@ -383,4 +373,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
383
373
 
384
374
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
385
375
 
386
- 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 };
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 };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- (function(t,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(t=typeof globalThis<"u"?globalThis:t||self,o(t.modernIdoc={}))})(this,function(t){"use strict";function o(e){if(!(!e||e==="none"))return typeof e=="string"?[{type:"texture",src:e}]:Array.isArray(e)?e:[e]}function d(e){if(!(!e||e==="none"))return typeof e=="string"?[{type:"solid",color:e}]:Array.isArray(e)?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 y(){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(r=>({...r}))}:Array.isArray(n)?{fragments:n.map(r=>typeof r=="string"?{content:r}:{...r})}:{fragments:[]})}function c(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(r=>l(r,i)):e;const n={};for(const r in e){const a=e[r];a!=null&&(i?n[r]=l(a,i):n[r]=a)}return n}function u(e){var i;return l({...e,background:o(e.background),text:c(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 A(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(),...y(),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 w(){return{...S(),...b()}}t.clearUndef=l,t.getDefaultElementStyle=S,t.getDefaultHighlightStyle=D,t.getDefaultLayoutStyle=v,t.getDefaultListStyleStyle=z,t.getDefaultShadowStyle=y,t.getDefaultStyle=w,t.getDefaultTextInlineStyle=T,t.getDefaultTextLineStyle=p,t.getDefaultTextStyle=b,t.getDefaultTransformStyle=h,t.normalizeDocument=A,t.normalizeElement=u,t.normalizeFill=d,t.normalizeGeometry=g,t.normalizeOutline=s,t.normalizeShadow=m,t.normalizeText=c,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 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"})});
package/dist/index.mjs CHANGED
@@ -2,11 +2,7 @@ function normalizeBackground(background) {
2
2
  if (!background || background === "none") {
3
3
  return void 0;
4
4
  } else if (typeof background === "string") {
5
- return [
6
- { type: "texture", src: background }
7
- ];
8
- } else if (!Array.isArray(background)) {
9
- return [background];
5
+ return { src: background };
10
6
  } else {
11
7
  return background;
12
8
  }
@@ -16,11 +12,7 @@ function normalizeFill(fill) {
16
12
  if (!fill || fill === "none") {
17
13
  return void 0;
18
14
  } else if (typeof fill === "string") {
19
- return [
20
- { type: "solid", color: fill }
21
- ];
22
- } else if (!Array.isArray(fill)) {
23
- return [fill];
15
+ return { color: fill };
24
16
  } else {
25
17
  return fill;
26
18
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-idoc",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.3.2",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "Intermediate document for modern codec libs",
7
7
  "author": "wxm",