modern-idoc 0.5.5 → 0.5.6

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
@@ -26,6 +26,21 @@ function parseColor(color) {
26
26
  }
27
27
  return colord.colord(input);
28
28
  }
29
+ function round(number, digits = 0, base = 10 ** digits) {
30
+ return Math.round(base * number) / base + 0;
31
+ }
32
+ function roundRgba(rgba) {
33
+ return {
34
+ r: round(rgba.r),
35
+ g: round(rgba.g),
36
+ b: round(rgba.b),
37
+ a: round(rgba.a, 3)
38
+ };
39
+ }
40
+ function format(number) {
41
+ const hex = number.toString(16);
42
+ return hex.length < 2 ? `0${hex}` : hex;
43
+ }
29
44
  function normalizeColor(color, orFail = false) {
30
45
  if (color === void 0 || color === "none") {
31
46
  return void 0;
@@ -40,11 +55,11 @@ function normalizeColor(color, orFail = false) {
40
55
  throw new Error(message);
41
56
  } else {
42
57
  console.warn(message);
43
- return `rgba(0, 0, 0, 1)`;
58
+ return "#000000FF";
44
59
  }
45
60
  }
46
- const { r, g, b, a } = parsed.rgba;
47
- return `rgba(${r}, ${g}, ${b}, ${a})`;
61
+ const { r, g, b, a } = roundRgba(parsed.rgba);
62
+ return `#${format(r)}${format(g)}${format(b)}${format(round(a * 255))}`;
48
63
  }
49
64
 
50
65
  function normalizeFill(fill) {
package/dist/index.d.cts CHANGED
@@ -65,8 +65,8 @@ type CmykaColor = WithAlpha<CmykColor>;
65
65
  type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor | LchColor | LchaColor | CmykColor | CmykaColor;
66
66
  type Uint32Color = number;
67
67
  type Color = None | Uint32Color | ObjectColor | string;
68
- type RgbString = string;
69
- type ColorDeclaration = RgbString;
68
+ type Hex8Color = string;
69
+ type ColorDeclaration = Hex8Color;
70
70
  declare function parseColor(color: Color): Colord;
71
71
  declare function normalizeColor(color?: Color, orFail?: boolean): ColorDeclaration | undefined;
72
72
 
@@ -546,4 +546,5 @@ declare function normalizeDocument(doc: Document): DocumentDeclaration;
546
546
 
547
547
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
548
548
 
549
- export { type Align, type AudioDeclaration, type AudioProperty, type BackgroundDeclaration, type BackgroundProperty, type BackgroundPropertyObject, type BackgroundSize, type BaseBackgroundDeclaration, type BaseForegroundDeclaration, type BaseOuterShadowDeclaration, type BorderStyle, type BoxShadow, type BoxSizing, type CmykColor, type CmykaColor, type Color, type ColorDeclaration, type Direction, type Display, type Document, type DocumentDeclaration, type EffectDeclaration, type EffectProperty, type EffectPropertyObject, type Element, type ElementDeclaration, type ElementStyleDeclaration, type FillDeclaration, type FillProperty, type FillPropertyObject, type FillRule, type FlexDirection, type FlexWrap, type FontKerning, type FontStyle, type FontWeight, type ForegroundDeclaration, type ForegroundProperty, type ForegroundPropertyObject, type FragmentContent, type GeometryDeclaration, type GeometryPathDeclaration, type GeometryPathStyle, type GeometryProperty, type GradientFillDeclaration, type HeadEnd, 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 InnerShadowDeclaration, type InnerShadowProperty, type InnerShadowPropertyObject, type Justify, type LabColor, type LabaColor, type LayoutStyleDeclaration, type LchColor, type LchaColor, type LineEndSize, type LineEndType, type ListStyleColormap, type ListStyleDeclaration, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleStyleDeclaration, type ListStyleType, type MetaProperty, type Node, type None, type ObjectColor, type OuterShadowDeclaration, type OuterShadowProperty, type OuterShadowPropertyObject, type OutlineDeclaration, type OutlineFillDeclaration, type OutlineProperty, type OutlinePropertyObject, type OutlineStyle, type Overflow, type ParagraphContent, type PointerEvents, type Position, type RgbColor, type RgbString, type RgbaColor, type SVGPathData, type ShadowDeclaration, type ShadowProperty, type ShadowPropertyObject, type ShadowStyleDeclaration, type SoftEdgeDeclaration, type SoftEdgeProperty, type SolidFillDeclaration, type StrokeLinecap, type StrokeLinejoin, type StyleDeclaration, type StyleProperty, type StylePropertyObject, type StyleUnit, type TailEnd, 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 Uint32Color, type VerticalAlign, type VideoDeclaration, type VideoProperty, type Visibility, type WritingMode, type XyzColor, type XyzaColor, 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 };
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 };
package/dist/index.d.mts CHANGED
@@ -65,8 +65,8 @@ type CmykaColor = WithAlpha<CmykColor>;
65
65
  type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor | LchColor | LchaColor | CmykColor | CmykaColor;
66
66
  type Uint32Color = number;
67
67
  type Color = None | Uint32Color | ObjectColor | string;
68
- type RgbString = string;
69
- type ColorDeclaration = RgbString;
68
+ type Hex8Color = string;
69
+ type ColorDeclaration = Hex8Color;
70
70
  declare function parseColor(color: Color): Colord;
71
71
  declare function normalizeColor(color?: Color, orFail?: boolean): ColorDeclaration | undefined;
72
72
 
@@ -546,4 +546,5 @@ declare function normalizeDocument(doc: Document): DocumentDeclaration;
546
546
 
547
547
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
548
548
 
549
- export { type Align, type AudioDeclaration, type AudioProperty, type BackgroundDeclaration, type BackgroundProperty, type BackgroundPropertyObject, type BackgroundSize, type BaseBackgroundDeclaration, type BaseForegroundDeclaration, type BaseOuterShadowDeclaration, type BorderStyle, type BoxShadow, type BoxSizing, type CmykColor, type CmykaColor, type Color, type ColorDeclaration, type Direction, type Display, type Document, type DocumentDeclaration, type EffectDeclaration, type EffectProperty, type EffectPropertyObject, type Element, type ElementDeclaration, type ElementStyleDeclaration, type FillDeclaration, type FillProperty, type FillPropertyObject, type FillRule, type FlexDirection, type FlexWrap, type FontKerning, type FontStyle, type FontWeight, type ForegroundDeclaration, type ForegroundProperty, type ForegroundPropertyObject, type FragmentContent, type GeometryDeclaration, type GeometryPathDeclaration, type GeometryPathStyle, type GeometryProperty, type GradientFillDeclaration, type HeadEnd, 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 InnerShadowDeclaration, type InnerShadowProperty, type InnerShadowPropertyObject, type Justify, type LabColor, type LabaColor, type LayoutStyleDeclaration, type LchColor, type LchaColor, type LineEndSize, type LineEndType, type ListStyleColormap, type ListStyleDeclaration, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleStyleDeclaration, type ListStyleType, type MetaProperty, type Node, type None, type ObjectColor, type OuterShadowDeclaration, type OuterShadowProperty, type OuterShadowPropertyObject, type OutlineDeclaration, type OutlineFillDeclaration, type OutlineProperty, type OutlinePropertyObject, type OutlineStyle, type Overflow, type ParagraphContent, type PointerEvents, type Position, type RgbColor, type RgbString, type RgbaColor, type SVGPathData, type ShadowDeclaration, type ShadowProperty, type ShadowPropertyObject, type ShadowStyleDeclaration, type SoftEdgeDeclaration, type SoftEdgeProperty, type SolidFillDeclaration, type StrokeLinecap, type StrokeLinejoin, type StyleDeclaration, type StyleProperty, type StylePropertyObject, type StyleUnit, type TailEnd, 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 Uint32Color, type VerticalAlign, type VideoDeclaration, type VideoProperty, type Visibility, type WritingMode, type XyzColor, type XyzaColor, 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -65,8 +65,8 @@ type CmykaColor = WithAlpha<CmykColor>;
65
65
  type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor | LchColor | LchaColor | CmykColor | CmykaColor;
66
66
  type Uint32Color = number;
67
67
  type Color = None | Uint32Color | ObjectColor | string;
68
- type RgbString = string;
69
- type ColorDeclaration = RgbString;
68
+ type Hex8Color = string;
69
+ type ColorDeclaration = Hex8Color;
70
70
  declare function parseColor(color: Color): Colord;
71
71
  declare function normalizeColor(color?: Color, orFail?: boolean): ColorDeclaration | undefined;
72
72
 
@@ -546,4 +546,5 @@ declare function normalizeDocument(doc: Document): DocumentDeclaration;
546
546
 
547
547
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
548
548
 
549
- export { type Align, type AudioDeclaration, type AudioProperty, type BackgroundDeclaration, type BackgroundProperty, type BackgroundPropertyObject, type BackgroundSize, type BaseBackgroundDeclaration, type BaseForegroundDeclaration, type BaseOuterShadowDeclaration, type BorderStyle, type BoxShadow, type BoxSizing, type CmykColor, type CmykaColor, type Color, type ColorDeclaration, type Direction, type Display, type Document, type DocumentDeclaration, type EffectDeclaration, type EffectProperty, type EffectPropertyObject, type Element, type ElementDeclaration, type ElementStyleDeclaration, type FillDeclaration, type FillProperty, type FillPropertyObject, type FillRule, type FlexDirection, type FlexWrap, type FontKerning, type FontStyle, type FontWeight, type ForegroundDeclaration, type ForegroundProperty, type ForegroundPropertyObject, type FragmentContent, type GeometryDeclaration, type GeometryPathDeclaration, type GeometryPathStyle, type GeometryProperty, type GradientFillDeclaration, type HeadEnd, 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 InnerShadowDeclaration, type InnerShadowProperty, type InnerShadowPropertyObject, type Justify, type LabColor, type LabaColor, type LayoutStyleDeclaration, type LchColor, type LchaColor, type LineEndSize, type LineEndType, type ListStyleColormap, type ListStyleDeclaration, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleStyleDeclaration, type ListStyleType, type MetaProperty, type Node, type None, type ObjectColor, type OuterShadowDeclaration, type OuterShadowProperty, type OuterShadowPropertyObject, type OutlineDeclaration, type OutlineFillDeclaration, type OutlineProperty, type OutlinePropertyObject, type OutlineStyle, type Overflow, type ParagraphContent, type PointerEvents, type Position, type RgbColor, type RgbString, type RgbaColor, type SVGPathData, type ShadowDeclaration, type ShadowProperty, type ShadowPropertyObject, type ShadowStyleDeclaration, type SoftEdgeDeclaration, type SoftEdgeProperty, type SolidFillDeclaration, type StrokeLinecap, type StrokeLinejoin, type StyleDeclaration, type StyleProperty, type StylePropertyObject, type StyleUnit, type TailEnd, 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 Uint32Color, type VerticalAlign, type VideoDeclaration, type VideoProperty, type Visibility, type WritingMode, type XyzColor, type XyzaColor, 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 };
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 };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- (function(o,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(o=typeof globalThis<"u"?globalThis:o||self,v(o.modernIdoc={}))})(this,function(o){"use strict";function v(n){if(!(!n||n==="none"))return typeof n=="string"?{src:n}:n}var ln={grad:.9,turn:360,rad:360/(2*Math.PI)},c=function(n){return typeof n=="string"?n.length>0:typeof n=="number"},l=function(n,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*n)/e+0},d=function(n,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),n>e?e:n>t?n:t},A=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},H=function(n){return{r:d(n.r,0,255),g:d(n.g,0,255),b:d(n.b,0,255),a:d(n.a)}},S=function(n){return{r:l(n.r),g:l(n.g),b:l(n.b),a:l(n.a,3)}},fn=/^#([0-9a-f]{3,8})$/i,y=function(n){var t=n.toString(16);return t.length<2?"0"+t:t},E=function(n){var t=n.r,e=n.g,r=n.b,i=n.a,u=Math.max(t,e,r),a=u-Math.min(t,e,r),f=a?u===t?(e-r)/a:u===e?2+(r-t)/a:4+(t-e)/a:0;return{h:60*(f<0?f+6:f),s:u?a/u*100:0,v:u/255*100,a:i}},L=function(n){var t=n.h,e=n.s,r=n.v,i=n.a;t=t/360*6,e/=100,r/=100;var u=Math.floor(t),a=r*(1-e),f=r*(1-(t-u)*e),T=r*(1-(1-t+u)*e),k=u%6;return{r:255*[r,f,a,a,T,r][k],g:255*[T,r,r,f,a,a][k],b:255*[a,a,T,r,r,f][k],a:i}},O=function(n){return{h:A(n.h),s:d(n.s,0,100),l:d(n.l,0,100),a:d(n.a)}},$=function(n){return{h:l(n.h),s:l(n.s),l:l(n.l),a:l(n.a,3)}},M=function(n){return L((e=(t=n).s,{h:t.h,s:(e*=((r=t.l)<50?r:100-r)/100)>0?2*e/(r+e)*100:0,v:r+e,a:t.a}));var t,e,r},m=function(n){return{h:(t=E(n)).h,s:(i=(200-(e=t.s))*(r=t.v)/100)>0&&i<200?e*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,e,r,i},sn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,dn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,cn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,R={string:[[function(n){var t=fn.exec(n);return t?(n=t[1]).length<=4?{r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:n.length===4?l(parseInt(n[3]+n[3],16)/255,2):1}:n.length===6||n.length===8?{r:parseInt(n.substr(0,2),16),g:parseInt(n.substr(2,2),16),b:parseInt(n.substr(4,2),16),a:n.length===8?l(parseInt(n.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(n){var t=gn.exec(n)||cn.exec(n);return t?t[2]!==t[4]||t[4]!==t[6]?null:H({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(n){var t=sn.exec(n)||dn.exec(n);if(!t)return null;var e,r,i=O({h:(e=t[1],r=t[2],r===void 0&&(r="deg"),Number(e)*(ln[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return M(i)},"hsl"]],object:[[function(n){var t=n.r,e=n.g,r=n.b,i=n.a,u=i===void 0?1:i;return c(t)&&c(e)&&c(r)?H({r:Number(t),g:Number(e),b:Number(r),a:Number(u)}):null},"rgb"],[function(n){var t=n.h,e=n.s,r=n.l,i=n.a,u=i===void 0?1:i;if(!c(t)||!c(e)||!c(r))return null;var a=O({h:Number(t),s:Number(e),l:Number(r),a:Number(u)});return M(a)},"hsl"],[function(n){var t=n.h,e=n.s,r=n.v,i=n.a,u=i===void 0?1:i;if(!c(t)||!c(e)||!c(r))return null;var a=function(f){return{h:A(f.h),s:d(f.s,0,100),v:d(f.v,0,100),a:d(f.a)}}({h:Number(t),s:Number(e),v:Number(r),a:Number(u)});return L(a)},"hsv"]]},W=function(n,t){for(var e=0;e<t.length;e++){var r=t[e][0](n);if(r)return[r,t[e][1]]}return[null,void 0]},hn=function(n){return typeof n=="string"?W(n.trim(),R.string):typeof n=="object"&&n!==null?W(n,R.object):[null,void 0]},z=function(n,t){var e=m(n);return{h:e.h,s:d(e.s+100*t,0,100),l:e.l,a:e.a}},D=function(n){return(299*n.r+587*n.g+114*n.b)/1e3/255},F=function(n,t){var e=m(n);return{h:e.h,s:e.s,l:d(e.l+100*t,0,100),a:e.a}},x=function(){function n(t){this.parsed=hn(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return n.prototype.isValid=function(){return this.parsed!==null},n.prototype.brightness=function(){return l(D(this.rgba),2)},n.prototype.isDark=function(){return D(this.rgba)<.5},n.prototype.isLight=function(){return D(this.rgba)>=.5},n.prototype.toHex=function(){return t=S(this.rgba),e=t.r,r=t.g,i=t.b,a=(u=t.a)<1?y(l(255*u)):"","#"+y(e)+y(r)+y(i)+a;var t,e,r,i,u,a},n.prototype.toRgb=function(){return S(this.rgba)},n.prototype.toRgbString=function(){return t=S(this.rgba),e=t.r,r=t.g,i=t.b,(u=t.a)<1?"rgba("+e+", "+r+", "+i+", "+u+")":"rgb("+e+", "+r+", "+i+")";var t,e,r,i,u},n.prototype.toHsl=function(){return $(m(this.rgba))},n.prototype.toHslString=function(){return t=$(m(this.rgba)),e=t.h,r=t.s,i=t.l,(u=t.a)<1?"hsla("+e+", "+r+"%, "+i+"%, "+u+")":"hsl("+e+", "+r+"%, "+i+"%)";var t,e,r,i,u},n.prototype.toHsv=function(){return t=E(this.rgba),{h:l(t.h),s:l(t.s),v:l(t.v),a:l(t.a,3)};var t},n.prototype.invert=function(){return g({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},n.prototype.saturate=function(t){return t===void 0&&(t=.1),g(z(this.rgba,t))},n.prototype.desaturate=function(t){return t===void 0&&(t=.1),g(z(this.rgba,-t))},n.prototype.grayscale=function(){return g(z(this.rgba,-1))},n.prototype.lighten=function(t){return t===void 0&&(t=.1),g(F(this.rgba,t))},n.prototype.darken=function(t){return t===void 0&&(t=.1),g(F(this.rgba,-t))},n.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},n.prototype.alpha=function(t){return typeof t=="number"?g({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):l(this.rgba.a,3);var e},n.prototype.hue=function(t){var e=m(this.rgba);return typeof t=="number"?g({h:t,s:e.s,l:e.l,a:e.a}):l(e.h)},n.prototype.isEqual=function(t){return this.toHex()===g(t).toHex()},n}(),g=function(n){return n instanceof x?n:new x(n)};function B(n){let t;return typeof n=="number"?t={r:n>>24&255,g:n>>16&255,b:n>>8&255,a:(n&255)/255}:t=n,g(t)}function s(n,t=!1){if(n===void 0||n==="none")return;const e=B(n);if(!e.isValid()){if(typeof n=="string")return n;const f=`Failed to normalizeColor ${n}`;if(t)throw new Error(f);return console.warn(f),"rgba(0, 0, 0, 1)"}const{r,g:i,b:u,a}=e.rgba;return`rgba(${r}, ${i}, ${u}, ${a})`}function p(n){if(!(!n||n==="none"))return typeof n=="string"?{color:s(n)}:{...n,color:s(n.color)}}function X(n){if(!(!n||n==="none"))return typeof n=="string"?{src:n}:{...n,...p(n)}}function h(n,t=!1){if(typeof n!="object"||!n)return n;if(Array.isArray(n))return t?n.map(r=>h(r,t)):n;const e={};for(const r in n){const i=n[r];i!=null&&(t?e[r]=h(i,t):e[r]=i)}return e}function w(){return{color:"rgb(0, 0, 0)",offsetX:0,offsetY:0,blurRadius:1}}function C(n){if(!(!n||n==="none"))return{...w(),...h({...n,color:s(n.color)})}}function Y(){return{...w(),scaleX:1,scaleY:1}}function V(n){if(!(!n||n==="none"))return{...Y(),...C(n)}}function G(n){if(!(!n||n==="none"))return n}function P(n){if(!(!n||n==="none"))return h({...n,softEdge:G(n.softEdge),outerShadow:V(n.outerShadow),innerShadow:C(n.innerShadow)})}function j(n){if(!(!n||n==="none"))return typeof n=="string"?{src:n}:{...n,...p(n)}}function U(n){if(!(!n||n==="none"))return typeof n=="string"?{paths:[{data:n}]}:Array.isArray(n)?{paths:n.map(t=>typeof t=="string"?{data:t}:t)}:n}function q(n){if(!(!n||n==="none"))return typeof n=="string"?{color:s(n)}:{...n,color:s(n.color)}}function K(n){if(!(!n||n==="none"))return typeof n=="string"?{color:s(n)}:{...n,color:s(n.color)}}function J(){return{boxShadow:"none"}}function Q(){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 Z(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function _(){return{...Q(),...Z(),...J(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function nn(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function tn(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function en(){return{...nn(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function rn(){return{...tn(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function on(){return{...rn(),...en(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function b(n){if(!(!n||n==="none"))return h({...n,color:s(n.color),backgroundColor:s(n.backgroundColor),borderColor:s(n.borderColor),outlineColor:s(n.outlineColor),shadowColor:s(n.shadowColor)})}function vn(){return{..._(),...on()}}function I(n=""){return(Array.isArray(n)?n:[n]).map(e=>typeof e=="string"?{fragments:[{content:e}]}:"content"in e?{fragments:[b(e)]}:"fragments"in e?{...b(e),fragments:e.fragments.map(r=>b(r))}:Array.isArray(e)?{fragments:e.map(r=>typeof r=="string"?{content:r}:b(r))}:{fragments:[]})}function un(n){if(!(!n||n==="none"))return typeof n=="string"?{content:[{fragments:[{content:n}]}]}:"content"in n?{...n,content:I(n.content)}:{content:I(n)}}function an(n){if(!(!n||n==="none"))return typeof n=="string"?{src:n}:n}function N(n){var t;return h({...n,style:b(n.style),text:un(n.text),background:X(n.background),geometry:U(n.geometry),fill:p(n.fill),outline:q(n.outline),foreground:j(n.foreground),shadow:K(n.shadow),video:an(n.video),audio:v(n.audio),effect:P(n.effect),children:(t=n.children)==null?void 0:t.map(e=>N(e))})}function bn(n){return N(n)}o.clearUndef=h,o.getDefaultElementStyle=_,o.getDefaultHighlightStyle=nn,o.getDefaultInnerShadow=w,o.getDefaultLayoutStyle=Q,o.getDefaultListStyleStyle=tn,o.getDefaultOuterShadow=Y,o.getDefaultShadowStyle=J,o.getDefaultStyle=vn,o.getDefaultTextInlineStyle=en,o.getDefaultTextLineStyle=rn,o.getDefaultTextStyle=on,o.getDefaultTransformStyle=Z,o.normalizeAudio=v,o.normalizeBackground=X,o.normalizeColor=s,o.normalizeDocument=bn,o.normalizeEffect=P,o.normalizeElement=N,o.normalizeFill=p,o.normalizeForeground=j,o.normalizeGeometry=U,o.normalizeInnerShadow=C,o.normalizeOuterShadow=V,o.normalizeOutline=q,o.normalizeShadow=K,o.normalizeSoftEdge=G,o.normalizeStyle=b,o.normalizeText=un,o.normalizeTextContent=I,o.normalizeVideo=an,o.parseColor=B,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(i,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(i=typeof globalThis<"u"?globalThis:i||self,v(i.modernIdoc={}))})(this,function(i){"use strict";function v(n){if(!(!n||n==="none"))return typeof n=="string"?{src:n}:n}var sn={grad:.9,turn:360,rad:360/(2*Math.PI)},c=function(n){return typeof n=="string"?n.length>0:typeof n=="number"},l=function(n,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*n)/e+0},d=function(n,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),n>e?e:n>t?n:t},$=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},E=function(n){return{r:d(n.r,0,255),g:d(n.g,0,255),b:d(n.b,0,255),a:d(n.a)}},D=function(n){return{r:l(n.r),g:l(n.g),b:l(n.b),a:l(n.a,3)}},dn=/^#([0-9a-f]{3,8})$/i,p=function(n){var t=n.toString(16);return t.length<2?"0"+t:t},L=function(n){var t=n.r,e=n.g,r=n.b,o=n.a,u=Math.max(t,e,r),a=u-Math.min(t,e,r),f=a?u===t?(e-r)/a:u===e?2+(r-t)/a:4+(t-e)/a:0;return{h:60*(f<0?f+6:f),s:u?a/u*100:0,v:u/255*100,a:o}},O=function(n){var t=n.h,e=n.s,r=n.v,o=n.a;t=t/360*6,e/=100,r/=100;var u=Math.floor(t),a=r*(1-e),f=r*(1-(t-u)*e),A=r*(1-(1-t+u)*e),H=u%6;return{r:255*[r,f,a,a,A,r][H],g:255*[A,r,r,f,a,a][H],b:255*[a,a,A,r,r,f][H],a:o}},M=function(n){return{h:$(n.h),s:d(n.s,0,100),l:d(n.l,0,100),a:d(n.a)}},F=function(n){return{h:l(n.h),s:l(n.s),l:l(n.l),a:l(n.a,3)}},R=function(n){return O((e=(t=n).s,{h:t.h,s:(e*=((r=t.l)<50?r:100-r)/100)>0?2*e/(r+e)*100:0,v:r+e,a:t.a}));var t,e,r},b=function(n){return{h:(t=L(n)).h,s:(o=(200-(e=t.s))*(r=t.v)/100)>0&&o<200?e*r/100/(o<=100?o:200-o)*100:0,l:o/2,a:t.a};var t,e,r,o},gn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,cn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,vn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,W={string:[[function(n){var t=dn.exec(n);return t?(n=t[1]).length<=4?{r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:n.length===4?l(parseInt(n[3]+n[3],16)/255,2):1}:n.length===6||n.length===8?{r:parseInt(n.substr(0,2),16),g:parseInt(n.substr(2,2),16),b:parseInt(n.substr(4,2),16),a:n.length===8?l(parseInt(n.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(n){var t=hn.exec(n)||vn.exec(n);return t?t[2]!==t[4]||t[4]!==t[6]?null:E({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(n){var t=gn.exec(n)||cn.exec(n);if(!t)return null;var e,r,o=M({h:(e=t[1],r=t[2],r===void 0&&(r="deg"),Number(e)*(sn[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return R(o)},"hsl"]],object:[[function(n){var t=n.r,e=n.g,r=n.b,o=n.a,u=o===void 0?1:o;return c(t)&&c(e)&&c(r)?E({r:Number(t),g:Number(e),b:Number(r),a:Number(u)}):null},"rgb"],[function(n){var t=n.h,e=n.s,r=n.l,o=n.a,u=o===void 0?1:o;if(!c(t)||!c(e)||!c(r))return null;var a=M({h:Number(t),s:Number(e),l:Number(r),a:Number(u)});return R(a)},"hsl"],[function(n){var t=n.h,e=n.s,r=n.v,o=n.a,u=o===void 0?1:o;if(!c(t)||!c(e)||!c(r))return null;var a=function(f){return{h:$(f.h),s:d(f.s,0,100),v:d(f.v,0,100),a:d(f.a)}}({h:Number(t),s:Number(e),v:Number(r),a:Number(u)});return O(a)},"hsv"]]},x=function(n,t){for(var e=0;e<t.length;e++){var r=t[e][0](n);if(r)return[r,t[e][1]]}return[null,void 0]},mn=function(n){return typeof n=="string"?x(n.trim(),W.string):typeof n=="object"&&n!==null?x(n,W.object):[null,void 0]},w=function(n,t){var e=b(n);return{h:e.h,s:d(e.s+100*t,0,100),l:e.l,a:e.a}},C=function(n){return(299*n.r+587*n.g+114*n.b)/1e3/255},B=function(n,t){var e=b(n);return{h:e.h,s:e.s,l:d(e.l+100*t,0,100),a:e.a}},X=function(){function n(t){this.parsed=mn(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return n.prototype.isValid=function(){return this.parsed!==null},n.prototype.brightness=function(){return l(C(this.rgba),2)},n.prototype.isDark=function(){return C(this.rgba)<.5},n.prototype.isLight=function(){return C(this.rgba)>=.5},n.prototype.toHex=function(){return t=D(this.rgba),e=t.r,r=t.g,o=t.b,a=(u=t.a)<1?p(l(255*u)):"","#"+p(e)+p(r)+p(o)+a;var t,e,r,o,u,a},n.prototype.toRgb=function(){return D(this.rgba)},n.prototype.toRgbString=function(){return t=D(this.rgba),e=t.r,r=t.g,o=t.b,(u=t.a)<1?"rgba("+e+", "+r+", "+o+", "+u+")":"rgb("+e+", "+r+", "+o+")";var t,e,r,o,u},n.prototype.toHsl=function(){return F(b(this.rgba))},n.prototype.toHslString=function(){return t=F(b(this.rgba)),e=t.h,r=t.s,o=t.l,(u=t.a)<1?"hsla("+e+", "+r+"%, "+o+"%, "+u+")":"hsl("+e+", "+r+"%, "+o+"%)";var t,e,r,o,u},n.prototype.toHsv=function(){return t=L(this.rgba),{h:l(t.h),s:l(t.s),v:l(t.v),a:l(t.a,3)};var t},n.prototype.invert=function(){return g({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},n.prototype.saturate=function(t){return t===void 0&&(t=.1),g(w(this.rgba,t))},n.prototype.desaturate=function(t){return t===void 0&&(t=.1),g(w(this.rgba,-t))},n.prototype.grayscale=function(){return g(w(this.rgba,-1))},n.prototype.lighten=function(t){return t===void 0&&(t=.1),g(B(this.rgba,t))},n.prototype.darken=function(t){return t===void 0&&(t=.1),g(B(this.rgba,-t))},n.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},n.prototype.alpha=function(t){return typeof t=="number"?g({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):l(this.rgba.a,3);var e},n.prototype.hue=function(t){var e=b(this.rgba);return typeof t=="number"?g({h:t,s:e.s,l:e.l,a:e.a}):l(e.h)},n.prototype.isEqual=function(t){return this.toHex()===g(t).toHex()},n}(),g=function(n){return n instanceof X?n:new X(n)};function Y(n){let t;return typeof n=="number"?t={r:n>>24&255,g:n>>16&255,b:n>>8&255,a:(n&255)/255}:t=n,g(t)}function y(n,t=0,e=10**t){return Math.round(e*n)/e+0}function bn(n){return{r:y(n.r),g:y(n.g),b:y(n.b),a:y(n.a,3)}}function S(n){const t=n.toString(16);return t.length<2?`0${t}`:t}function s(n,t=!1){if(n===void 0||n==="none")return;const e=Y(n);if(!e.isValid()){if(typeof n=="string")return n;const f=`Failed to normalizeColor ${n}`;if(t)throw new Error(f);return console.warn(f),"#000000FF"}const{r,g:o,b:u,a}=bn(e.rgba);return`#${S(r)}${S(o)}${S(u)}${S(y(a*255))}`}function z(n){if(!(!n||n==="none"))return typeof n=="string"?{color:s(n)}:{...n,color:s(n.color)}}function V(n){if(!(!n||n==="none"))return typeof n=="string"?{src:n}:{...n,...z(n)}}function h(n,t=!1){if(typeof n!="object"||!n)return n;if(Array.isArray(n))return t?n.map(r=>h(r,t)):n;const e={};for(const r in n){const o=n[r];o!=null&&(t?e[r]=h(o,t):e[r]=o)}return e}function I(){return{color:"rgb(0, 0, 0)",offsetX:0,offsetY:0,blurRadius:1}}function N(n){if(!(!n||n==="none"))return{...I(),...h({...n,color:s(n.color)})}}function G(){return{...I(),scaleX:1,scaleY:1}}function P(n){if(!(!n||n==="none"))return{...G(),...N(n)}}function j(n){if(!(!n||n==="none"))return n}function U(n){if(!(!n||n==="none"))return h({...n,softEdge:j(n.softEdge),outerShadow:P(n.outerShadow),innerShadow:N(n.innerShadow)})}function q(n){if(!(!n||n==="none"))return typeof n=="string"?{src:n}:{...n,...z(n)}}function K(n){if(!(!n||n==="none"))return typeof n=="string"?{paths:[{data:n}]}:Array.isArray(n)?{paths:n.map(t=>typeof t=="string"?{data:t}:t)}:n}function J(n){if(!(!n||n==="none"))return typeof n=="string"?{color:s(n)}:{...n,color:s(n.color)}}function Q(n){if(!(!n||n==="none"))return typeof n=="string"?{color:s(n)}:{...n,color:s(n.color)}}function Z(){return{boxShadow:"none"}}function _(){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 nn(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function tn(){return{..._(),...nn(),...Z(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function en(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function rn(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function on(){return{...en(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function un(){return{...rn(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function an(){return{...un(),...on(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function m(n){if(!(!n||n==="none"))return h({...n,color:s(n.color),backgroundColor:s(n.backgroundColor),borderColor:s(n.borderColor),outlineColor:s(n.outlineColor),shadowColor:s(n.shadowColor)})}function yn(){return{...tn(),...an()}}function T(n=""){return(Array.isArray(n)?n:[n]).map(e=>typeof e=="string"?{fragments:[{content:e}]}:"content"in e?{fragments:[m(e)]}:"fragments"in e?{...m(e),fragments:e.fragments.map(r=>m(r))}:Array.isArray(e)?{fragments:e.map(r=>typeof r=="string"?{content:r}:m(r))}:{fragments:[]})}function ln(n){if(!(!n||n==="none"))return typeof n=="string"?{content:[{fragments:[{content:n}]}]}:"content"in n?{...n,content:T(n.content)}:{content:T(n)}}function fn(n){if(!(!n||n==="none"))return typeof n=="string"?{src:n}:n}function k(n){var t;return h({...n,style:m(n.style),text:ln(n.text),background:V(n.background),geometry:K(n.geometry),fill:z(n.fill),outline:J(n.outline),foreground:q(n.foreground),shadow:Q(n.shadow),video:fn(n.video),audio:v(n.audio),effect:U(n.effect),children:(t=n.children)==null?void 0:t.map(e=>k(e))})}function pn(n){return k(n)}i.clearUndef=h,i.getDefaultElementStyle=tn,i.getDefaultHighlightStyle=en,i.getDefaultInnerShadow=I,i.getDefaultLayoutStyle=_,i.getDefaultListStyleStyle=rn,i.getDefaultOuterShadow=G,i.getDefaultShadowStyle=Z,i.getDefaultStyle=yn,i.getDefaultTextInlineStyle=on,i.getDefaultTextLineStyle=un,i.getDefaultTextStyle=an,i.getDefaultTransformStyle=nn,i.normalizeAudio=v,i.normalizeBackground=V,i.normalizeColor=s,i.normalizeDocument=pn,i.normalizeEffect=U,i.normalizeElement=k,i.normalizeFill=z,i.normalizeForeground=q,i.normalizeGeometry=K,i.normalizeInnerShadow=N,i.normalizeOuterShadow=P,i.normalizeOutline=J,i.normalizeShadow=Q,i.normalizeSoftEdge=j,i.normalizeStyle=m,i.normalizeText=ln,i.normalizeTextContent=T,i.normalizeVideo=fn,i.parseColor=Y,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -24,6 +24,21 @@ function parseColor(color) {
24
24
  }
25
25
  return colord(input);
26
26
  }
27
+ function round(number, digits = 0, base = 10 ** digits) {
28
+ return Math.round(base * number) / base + 0;
29
+ }
30
+ function roundRgba(rgba) {
31
+ return {
32
+ r: round(rgba.r),
33
+ g: round(rgba.g),
34
+ b: round(rgba.b),
35
+ a: round(rgba.a, 3)
36
+ };
37
+ }
38
+ function format(number) {
39
+ const hex = number.toString(16);
40
+ return hex.length < 2 ? `0${hex}` : hex;
41
+ }
27
42
  function normalizeColor(color, orFail = false) {
28
43
  if (color === void 0 || color === "none") {
29
44
  return void 0;
@@ -38,11 +53,11 @@ function normalizeColor(color, orFail = false) {
38
53
  throw new Error(message);
39
54
  } else {
40
55
  console.warn(message);
41
- return `rgba(0, 0, 0, 1)`;
56
+ return "#000000FF";
42
57
  }
43
58
  }
44
- const { r, g, b, a } = parsed.rgba;
45
- return `rgba(${r}, ${g}, ${b}, ${a})`;
59
+ const { r, g, b, a } = roundRgba(parsed.rgba);
60
+ return `#${format(r)}${format(g)}${format(b)}${format(round(a * 255))}`;
46
61
  }
47
62
 
48
63
  function normalizeFill(fill) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-idoc",
3
3
  "type": "module",
4
- "version": "0.5.5",
4
+ "version": "0.5.6",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "Intermediate document for modern codec libs",
7
7
  "author": "wxm",
@@ -57,17 +57,17 @@
57
57
  "colord": "^2.9.3"
58
58
  },
59
59
  "devDependencies": {
60
- "@antfu/eslint-config": "^4.3.0",
61
- "@types/node": "^22.13.4",
62
- "bumpp": "^10.0.3",
60
+ "@antfu/eslint-config": "^4.13.1",
61
+ "@types/node": "^22.15.19",
62
+ "bumpp": "^10.1.1",
63
63
  "conventional-changelog-cli": "^5.0.0",
64
- "eslint": "^9.20.1",
65
- "lint-staged": "^15.4.3",
66
- "simple-git-hooks": "^2.11.1",
67
- "typescript": "^5.7.3",
68
- "unbuild": "^3.3.1",
69
- "vite": "^6.1.1",
70
- "vitest": "^3.0.6"
64
+ "eslint": "^9.27.0",
65
+ "lint-staged": "^16.0.0",
66
+ "simple-git-hooks": "^2.13.0",
67
+ "typescript": "^5.8.3",
68
+ "unbuild": "^3.5.0",
69
+ "vite": "^6.3.5",
70
+ "vitest": "^3.1.4"
71
71
  },
72
72
  "simple-git-hooks": {
73
73
  "pre-commit": "pnpm lint-staged"