modern-idoc 0.3.3 → 0.3.5
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 +38 -1
- package/dist/index.d.cts +32 -12
- package/dist/index.d.mts +32 -12
- package/dist/index.d.ts +32 -12
- package/dist/index.js +1 -1
- package/dist/index.mjs +35 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
function normalizeAudio(audio) {
|
|
4
|
+
if (!audio || audio === "none") {
|
|
5
|
+
return void 0;
|
|
6
|
+
} else if (typeof audio === "string") {
|
|
7
|
+
return { src: audio };
|
|
8
|
+
} else {
|
|
9
|
+
return audio;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
function normalizeBackground(background) {
|
|
4
14
|
if (!background || background === "none") {
|
|
5
15
|
return void 0;
|
|
@@ -20,6 +30,16 @@ function normalizeFill(fill) {
|
|
|
20
30
|
}
|
|
21
31
|
}
|
|
22
32
|
|
|
33
|
+
function normalizeForeground(foreground) {
|
|
34
|
+
if (!foreground || foreground === "none") {
|
|
35
|
+
return void 0;
|
|
36
|
+
} else if (typeof foreground === "string") {
|
|
37
|
+
return { src: foreground };
|
|
38
|
+
} else {
|
|
39
|
+
return foreground;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
23
43
|
function normalizeGeometry(geometry) {
|
|
24
44
|
if (!geometry || geometry === "none") {
|
|
25
45
|
return void 0;
|
|
@@ -164,15 +184,28 @@ function clearUndef(obj, deep = false) {
|
|
|
164
184
|
return newObj;
|
|
165
185
|
}
|
|
166
186
|
|
|
187
|
+
function normalizeVideo(video) {
|
|
188
|
+
if (!video || video === "none") {
|
|
189
|
+
return void 0;
|
|
190
|
+
} else if (typeof video === "string") {
|
|
191
|
+
return { src: video };
|
|
192
|
+
} else {
|
|
193
|
+
return video;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
167
197
|
function normalizeElement(element) {
|
|
168
198
|
return clearUndef({
|
|
169
199
|
...element,
|
|
170
|
-
background: normalizeBackground(element.background),
|
|
171
200
|
text: normalizeText(element.text),
|
|
201
|
+
background: normalizeBackground(element.background),
|
|
172
202
|
geometry: normalizeGeometry(element.geometry),
|
|
173
203
|
fill: normalizeFill(element.fill),
|
|
174
204
|
outline: normalizeOutline(element.outline),
|
|
205
|
+
foreground: normalizeForeground(element.foreground),
|
|
175
206
|
shadow: normalizeShadow(element.shadow),
|
|
207
|
+
video: normalizeVideo(element.video),
|
|
208
|
+
audio: normalizeVideo(element.audio),
|
|
176
209
|
children: element.children?.map((child) => normalizeElement(child))
|
|
177
210
|
});
|
|
178
211
|
}
|
|
@@ -354,11 +387,15 @@ exports.getDefaultTextInlineStyle = getDefaultTextInlineStyle;
|
|
|
354
387
|
exports.getDefaultTextLineStyle = getDefaultTextLineStyle;
|
|
355
388
|
exports.getDefaultTextStyle = getDefaultTextStyle;
|
|
356
389
|
exports.getDefaultTransformStyle = getDefaultTransformStyle;
|
|
390
|
+
exports.normalizeAudio = normalizeAudio;
|
|
391
|
+
exports.normalizeBackground = normalizeBackground;
|
|
357
392
|
exports.normalizeDocument = normalizeDocument;
|
|
358
393
|
exports.normalizeElement = normalizeElement;
|
|
359
394
|
exports.normalizeFill = normalizeFill;
|
|
395
|
+
exports.normalizeForeground = normalizeForeground;
|
|
360
396
|
exports.normalizeGeometry = normalizeGeometry;
|
|
361
397
|
exports.normalizeOutline = normalizeOutline;
|
|
362
398
|
exports.normalizeShadow = normalizeShadow;
|
|
363
399
|
exports.normalizeText = normalizeText;
|
|
364
400
|
exports.normalizeTextContent = normalizeTextContent;
|
|
401
|
+
exports.normalizeVideo = normalizeVideo;
|
package/dist/index.d.cts
CHANGED
|
@@ -57,6 +57,12 @@ declare type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColo
|
|
|
57
57
|
declare type AnyColor = string | ObjectColor;
|
|
58
58
|
type ColorValue = number | AnyColor;
|
|
59
59
|
|
|
60
|
+
interface AudioDeclaration {
|
|
61
|
+
src: string;
|
|
62
|
+
}
|
|
63
|
+
type AudioProperty = None | string | AudioDeclaration;
|
|
64
|
+
declare function normalizeAudio(audio?: AudioProperty): AudioDeclaration | undefined;
|
|
65
|
+
|
|
60
66
|
interface GradientFillDeclaration {
|
|
61
67
|
}
|
|
62
68
|
|
|
@@ -112,11 +118,13 @@ type FillDeclaration = Partial<TextureFillDeclaration> & Partial<SolidFillDeclar
|
|
|
112
118
|
type FillProperty = None | string | FillDeclaration;
|
|
113
119
|
declare function normalizeFill(fill?: FillProperty): FillDeclaration | undefined;
|
|
114
120
|
|
|
115
|
-
|
|
116
|
-
src: string;
|
|
117
|
-
}
|
|
118
|
-
type BackgroundDeclaration = FillDeclaration & Partial<AudioBackgroundDeclaration>;
|
|
121
|
+
type BackgroundDeclaration = FillDeclaration;
|
|
119
122
|
type BackgroundProperty = None | string | BackgroundDeclaration;
|
|
123
|
+
declare function normalizeBackground(background?: BackgroundProperty): BackgroundDeclaration | undefined;
|
|
124
|
+
|
|
125
|
+
type ForegroundDeclaration = FillDeclaration;
|
|
126
|
+
type ForegroundProperty = None | string | ForegroundDeclaration;
|
|
127
|
+
declare function normalizeForeground(foreground?: ForegroundProperty): ForegroundDeclaration | undefined;
|
|
120
128
|
|
|
121
129
|
type SVGPathData = string;
|
|
122
130
|
type FillRule = 'nonzero' | 'evenodd';
|
|
@@ -158,10 +166,10 @@ interface MetaProperty {
|
|
|
158
166
|
[key: string]: any;
|
|
159
167
|
}
|
|
160
168
|
|
|
161
|
-
interface IDOCNode {
|
|
169
|
+
interface IDOCNode<T = MetaProperty> {
|
|
162
170
|
name?: string;
|
|
163
171
|
children?: IDOCNode[];
|
|
164
|
-
meta?:
|
|
172
|
+
meta?: T;
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
interface OutlineDeclaration {
|
|
@@ -399,26 +407,38 @@ type TextProperty = string | TextContent | (TextDeclaration & {
|
|
|
399
407
|
declare function normalizeTextContent(content?: TextContent): TextContentDeclaration;
|
|
400
408
|
declare function normalizeText(text?: TextProperty): TextDeclaration | undefined;
|
|
401
409
|
|
|
402
|
-
interface
|
|
410
|
+
interface VideoDeclaration {
|
|
411
|
+
src: string;
|
|
412
|
+
}
|
|
413
|
+
type VideoProperty = None | string | VideoDeclaration;
|
|
414
|
+
declare function normalizeVideo(video?: VideoProperty): VideoDeclaration | undefined;
|
|
415
|
+
|
|
416
|
+
interface IDOCElement<T = MetaProperty> extends IDOCNode<T> {
|
|
403
417
|
style?: StyleProperty;
|
|
404
418
|
text?: TextProperty;
|
|
419
|
+
background?: BackgroundProperty;
|
|
405
420
|
geometry?: GeometryProperty;
|
|
406
421
|
fill?: FillProperty;
|
|
407
422
|
outline?: OutlineProperty;
|
|
408
|
-
|
|
423
|
+
foreground?: ForegroundProperty;
|
|
409
424
|
shadow?: ShadowProperty;
|
|
425
|
+
video?: VideoProperty;
|
|
426
|
+
audio?: AudioProperty;
|
|
410
427
|
children?: IDOCElement[];
|
|
411
428
|
}
|
|
412
|
-
interface IDOCElementDeclaration extends IDOCElement {
|
|
429
|
+
interface IDOCElementDeclaration<T = MetaProperty> extends IDOCElement<T> {
|
|
413
430
|
text?: TextDeclaration;
|
|
431
|
+
background?: BackgroundDeclaration;
|
|
414
432
|
geometry?: GeometryDeclaration;
|
|
415
433
|
fill?: FillDeclaration;
|
|
416
434
|
outline?: OutlineDeclaration;
|
|
417
|
-
|
|
435
|
+
foreground?: ForegroundDeclaration;
|
|
418
436
|
shadow?: ShadowDeclaration;
|
|
437
|
+
video?: VideoDeclaration;
|
|
438
|
+
audio?: AudioDeclaration;
|
|
419
439
|
children?: IDOCElementDeclaration[];
|
|
420
440
|
}
|
|
421
|
-
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration
|
|
441
|
+
declare function normalizeElement<T = MetaProperty>(element: IDOCElement<T>): IDOCElementDeclaration<T>;
|
|
422
442
|
|
|
423
443
|
interface IDOCDocument extends IDOCElement {
|
|
424
444
|
fonts?: any;
|
|
@@ -430,4 +450,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
|
|
|
430
450
|
|
|
431
451
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
432
452
|
|
|
433
|
-
export { type Align, type AnyColor, 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, normalizeDocument, normalizeElement, normalizeFill, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent };
|
|
453
|
+
export { type Align, type AnyColor, type AudioDeclaration, type AudioProperty, 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 ForegroundDeclaration, type ForegroundProperty, 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 VideoDeclaration, type VideoProperty, type Visibility, type WritingMode, type XyzColor, type XyzaColor, clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeAudio, normalizeBackground, normalizeDocument, normalizeElement, normalizeFill, normalizeForeground, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent, normalizeVideo };
|
package/dist/index.d.mts
CHANGED
|
@@ -57,6 +57,12 @@ declare type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColo
|
|
|
57
57
|
declare type AnyColor = string | ObjectColor;
|
|
58
58
|
type ColorValue = number | AnyColor;
|
|
59
59
|
|
|
60
|
+
interface AudioDeclaration {
|
|
61
|
+
src: string;
|
|
62
|
+
}
|
|
63
|
+
type AudioProperty = None | string | AudioDeclaration;
|
|
64
|
+
declare function normalizeAudio(audio?: AudioProperty): AudioDeclaration | undefined;
|
|
65
|
+
|
|
60
66
|
interface GradientFillDeclaration {
|
|
61
67
|
}
|
|
62
68
|
|
|
@@ -112,11 +118,13 @@ type FillDeclaration = Partial<TextureFillDeclaration> & Partial<SolidFillDeclar
|
|
|
112
118
|
type FillProperty = None | string | FillDeclaration;
|
|
113
119
|
declare function normalizeFill(fill?: FillProperty): FillDeclaration | undefined;
|
|
114
120
|
|
|
115
|
-
|
|
116
|
-
src: string;
|
|
117
|
-
}
|
|
118
|
-
type BackgroundDeclaration = FillDeclaration & Partial<AudioBackgroundDeclaration>;
|
|
121
|
+
type BackgroundDeclaration = FillDeclaration;
|
|
119
122
|
type BackgroundProperty = None | string | BackgroundDeclaration;
|
|
123
|
+
declare function normalizeBackground(background?: BackgroundProperty): BackgroundDeclaration | undefined;
|
|
124
|
+
|
|
125
|
+
type ForegroundDeclaration = FillDeclaration;
|
|
126
|
+
type ForegroundProperty = None | string | ForegroundDeclaration;
|
|
127
|
+
declare function normalizeForeground(foreground?: ForegroundProperty): ForegroundDeclaration | undefined;
|
|
120
128
|
|
|
121
129
|
type SVGPathData = string;
|
|
122
130
|
type FillRule = 'nonzero' | 'evenodd';
|
|
@@ -158,10 +166,10 @@ interface MetaProperty {
|
|
|
158
166
|
[key: string]: any;
|
|
159
167
|
}
|
|
160
168
|
|
|
161
|
-
interface IDOCNode {
|
|
169
|
+
interface IDOCNode<T = MetaProperty> {
|
|
162
170
|
name?: string;
|
|
163
171
|
children?: IDOCNode[];
|
|
164
|
-
meta?:
|
|
172
|
+
meta?: T;
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
interface OutlineDeclaration {
|
|
@@ -399,26 +407,38 @@ type TextProperty = string | TextContent | (TextDeclaration & {
|
|
|
399
407
|
declare function normalizeTextContent(content?: TextContent): TextContentDeclaration;
|
|
400
408
|
declare function normalizeText(text?: TextProperty): TextDeclaration | undefined;
|
|
401
409
|
|
|
402
|
-
interface
|
|
410
|
+
interface VideoDeclaration {
|
|
411
|
+
src: string;
|
|
412
|
+
}
|
|
413
|
+
type VideoProperty = None | string | VideoDeclaration;
|
|
414
|
+
declare function normalizeVideo(video?: VideoProperty): VideoDeclaration | undefined;
|
|
415
|
+
|
|
416
|
+
interface IDOCElement<T = MetaProperty> extends IDOCNode<T> {
|
|
403
417
|
style?: StyleProperty;
|
|
404
418
|
text?: TextProperty;
|
|
419
|
+
background?: BackgroundProperty;
|
|
405
420
|
geometry?: GeometryProperty;
|
|
406
421
|
fill?: FillProperty;
|
|
407
422
|
outline?: OutlineProperty;
|
|
408
|
-
|
|
423
|
+
foreground?: ForegroundProperty;
|
|
409
424
|
shadow?: ShadowProperty;
|
|
425
|
+
video?: VideoProperty;
|
|
426
|
+
audio?: AudioProperty;
|
|
410
427
|
children?: IDOCElement[];
|
|
411
428
|
}
|
|
412
|
-
interface IDOCElementDeclaration extends IDOCElement {
|
|
429
|
+
interface IDOCElementDeclaration<T = MetaProperty> extends IDOCElement<T> {
|
|
413
430
|
text?: TextDeclaration;
|
|
431
|
+
background?: BackgroundDeclaration;
|
|
414
432
|
geometry?: GeometryDeclaration;
|
|
415
433
|
fill?: FillDeclaration;
|
|
416
434
|
outline?: OutlineDeclaration;
|
|
417
|
-
|
|
435
|
+
foreground?: ForegroundDeclaration;
|
|
418
436
|
shadow?: ShadowDeclaration;
|
|
437
|
+
video?: VideoDeclaration;
|
|
438
|
+
audio?: AudioDeclaration;
|
|
419
439
|
children?: IDOCElementDeclaration[];
|
|
420
440
|
}
|
|
421
|
-
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration
|
|
441
|
+
declare function normalizeElement<T = MetaProperty>(element: IDOCElement<T>): IDOCElementDeclaration<T>;
|
|
422
442
|
|
|
423
443
|
interface IDOCDocument extends IDOCElement {
|
|
424
444
|
fonts?: any;
|
|
@@ -430,4 +450,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
|
|
|
430
450
|
|
|
431
451
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
432
452
|
|
|
433
|
-
export { type Align, type AnyColor, 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, normalizeDocument, normalizeElement, normalizeFill, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent };
|
|
453
|
+
export { type Align, type AnyColor, type AudioDeclaration, type AudioProperty, 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 ForegroundDeclaration, type ForegroundProperty, 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 VideoDeclaration, type VideoProperty, type Visibility, type WritingMode, type XyzColor, type XyzaColor, clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeAudio, normalizeBackground, normalizeDocument, normalizeElement, normalizeFill, normalizeForeground, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent, normalizeVideo };
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,12 @@ declare type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColo
|
|
|
57
57
|
declare type AnyColor = string | ObjectColor;
|
|
58
58
|
type ColorValue = number | AnyColor;
|
|
59
59
|
|
|
60
|
+
interface AudioDeclaration {
|
|
61
|
+
src: string;
|
|
62
|
+
}
|
|
63
|
+
type AudioProperty = None | string | AudioDeclaration;
|
|
64
|
+
declare function normalizeAudio(audio?: AudioProperty): AudioDeclaration | undefined;
|
|
65
|
+
|
|
60
66
|
interface GradientFillDeclaration {
|
|
61
67
|
}
|
|
62
68
|
|
|
@@ -112,11 +118,13 @@ type FillDeclaration = Partial<TextureFillDeclaration> & Partial<SolidFillDeclar
|
|
|
112
118
|
type FillProperty = None | string | FillDeclaration;
|
|
113
119
|
declare function normalizeFill(fill?: FillProperty): FillDeclaration | undefined;
|
|
114
120
|
|
|
115
|
-
|
|
116
|
-
src: string;
|
|
117
|
-
}
|
|
118
|
-
type BackgroundDeclaration = FillDeclaration & Partial<AudioBackgroundDeclaration>;
|
|
121
|
+
type BackgroundDeclaration = FillDeclaration;
|
|
119
122
|
type BackgroundProperty = None | string | BackgroundDeclaration;
|
|
123
|
+
declare function normalizeBackground(background?: BackgroundProperty): BackgroundDeclaration | undefined;
|
|
124
|
+
|
|
125
|
+
type ForegroundDeclaration = FillDeclaration;
|
|
126
|
+
type ForegroundProperty = None | string | ForegroundDeclaration;
|
|
127
|
+
declare function normalizeForeground(foreground?: ForegroundProperty): ForegroundDeclaration | undefined;
|
|
120
128
|
|
|
121
129
|
type SVGPathData = string;
|
|
122
130
|
type FillRule = 'nonzero' | 'evenodd';
|
|
@@ -158,10 +166,10 @@ interface MetaProperty {
|
|
|
158
166
|
[key: string]: any;
|
|
159
167
|
}
|
|
160
168
|
|
|
161
|
-
interface IDOCNode {
|
|
169
|
+
interface IDOCNode<T = MetaProperty> {
|
|
162
170
|
name?: string;
|
|
163
171
|
children?: IDOCNode[];
|
|
164
|
-
meta?:
|
|
172
|
+
meta?: T;
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
interface OutlineDeclaration {
|
|
@@ -399,26 +407,38 @@ type TextProperty = string | TextContent | (TextDeclaration & {
|
|
|
399
407
|
declare function normalizeTextContent(content?: TextContent): TextContentDeclaration;
|
|
400
408
|
declare function normalizeText(text?: TextProperty): TextDeclaration | undefined;
|
|
401
409
|
|
|
402
|
-
interface
|
|
410
|
+
interface VideoDeclaration {
|
|
411
|
+
src: string;
|
|
412
|
+
}
|
|
413
|
+
type VideoProperty = None | string | VideoDeclaration;
|
|
414
|
+
declare function normalizeVideo(video?: VideoProperty): VideoDeclaration | undefined;
|
|
415
|
+
|
|
416
|
+
interface IDOCElement<T = MetaProperty> extends IDOCNode<T> {
|
|
403
417
|
style?: StyleProperty;
|
|
404
418
|
text?: TextProperty;
|
|
419
|
+
background?: BackgroundProperty;
|
|
405
420
|
geometry?: GeometryProperty;
|
|
406
421
|
fill?: FillProperty;
|
|
407
422
|
outline?: OutlineProperty;
|
|
408
|
-
|
|
423
|
+
foreground?: ForegroundProperty;
|
|
409
424
|
shadow?: ShadowProperty;
|
|
425
|
+
video?: VideoProperty;
|
|
426
|
+
audio?: AudioProperty;
|
|
410
427
|
children?: IDOCElement[];
|
|
411
428
|
}
|
|
412
|
-
interface IDOCElementDeclaration extends IDOCElement {
|
|
429
|
+
interface IDOCElementDeclaration<T = MetaProperty> extends IDOCElement<T> {
|
|
413
430
|
text?: TextDeclaration;
|
|
431
|
+
background?: BackgroundDeclaration;
|
|
414
432
|
geometry?: GeometryDeclaration;
|
|
415
433
|
fill?: FillDeclaration;
|
|
416
434
|
outline?: OutlineDeclaration;
|
|
417
|
-
|
|
435
|
+
foreground?: ForegroundDeclaration;
|
|
418
436
|
shadow?: ShadowDeclaration;
|
|
437
|
+
video?: VideoDeclaration;
|
|
438
|
+
audio?: AudioDeclaration;
|
|
419
439
|
children?: IDOCElementDeclaration[];
|
|
420
440
|
}
|
|
421
|
-
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration
|
|
441
|
+
declare function normalizeElement<T = MetaProperty>(element: IDOCElement<T>): IDOCElementDeclaration<T>;
|
|
422
442
|
|
|
423
443
|
interface IDOCDocument extends IDOCElement {
|
|
424
444
|
fonts?: any;
|
|
@@ -430,4 +450,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
|
|
|
430
450
|
|
|
431
451
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
432
452
|
|
|
433
|
-
export { type Align, type AnyColor, 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, normalizeDocument, normalizeElement, normalizeFill, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent };
|
|
453
|
+
export { type Align, type AnyColor, type AudioDeclaration, type AudioProperty, 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 ForegroundDeclaration, type ForegroundProperty, 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 VideoDeclaration, type VideoProperty, type Visibility, type WritingMode, type XyzColor, type XyzaColor, clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeAudio, normalizeBackground, normalizeDocument, normalizeElement, normalizeFill, normalizeForeground, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent, normalizeVideo };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.modernIdoc={}))})(this,function(n){"use strict";function o(e){if(!(!e||e==="none"))return typeof e=="string"?{src:e}:e}function g(e){if(!(!e||e==="none"))return typeof e=="string"?{src:e}:e}function s(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function c(e){if(!(!e||e==="none"))return typeof e=="string"?{src:e}:e}function m(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 y(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function v(){return{boxShadow:"none"}}function h(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function f(e=""){return(Array.isArray(e)?e:[e]).map(t=>typeof t=="string"?{fragments:[{content:t}]}:"content"in t?{fragments:[{...t}]}:"fragments"in t?{...t,fragments:t.fragments.map(r=>({...r}))}:Array.isArray(t)?{fragments:t.map(r=>typeof r=="string"?{content:r}:{...r})}:{fragments:[]})}function S(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 t={};for(const r in e){const a=e[r];a!=null&&(i?t[r]=l(a,i):t[r]=a)}return t}function u(e){if(!(!e||e==="none"))return typeof e=="string"?{src:e}:e}function d(e){var i;return l({...e,text:S(e.text),background:g(e.background),geometry:m(e.geometry),fill:s(e.fill),outline:y(e.outline),foreground:c(e.foreground),shadow:h(e.shadow),video:u(e.video),audio:u(e.audio),children:(i=e.children)==null?void 0:i.map(t=>d(t))})}function C(e){return d(e)}function z(){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 D(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function T(){return{...z(),...D(),...v(),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 b(){return{highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function p(){return{listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function k(){return{...b(),color:"black",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function w(){return{...p(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function A(){return{...w(),...k(),textStrokeWidth:0,textStrokeColor:"black"}}function I(){return{...T(),...A()}}n.clearUndef=l,n.getDefaultElementStyle=T,n.getDefaultHighlightStyle=b,n.getDefaultLayoutStyle=z,n.getDefaultListStyleStyle=p,n.getDefaultShadowStyle=v,n.getDefaultStyle=I,n.getDefaultTextInlineStyle=k,n.getDefaultTextLineStyle=w,n.getDefaultTextStyle=A,n.getDefaultTransformStyle=D,n.normalizeAudio=o,n.normalizeBackground=g,n.normalizeDocument=C,n.normalizeElement=d,n.normalizeFill=s,n.normalizeForeground=c,n.normalizeGeometry=m,n.normalizeOutline=y,n.normalizeShadow=h,n.normalizeText=S,n.normalizeTextContent=f,n.normalizeVideo=u,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
function normalizeAudio(audio) {
|
|
2
|
+
if (!audio || audio === "none") {
|
|
3
|
+
return void 0;
|
|
4
|
+
} else if (typeof audio === "string") {
|
|
5
|
+
return { src: audio };
|
|
6
|
+
} else {
|
|
7
|
+
return audio;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
1
11
|
function normalizeBackground(background) {
|
|
2
12
|
if (!background || background === "none") {
|
|
3
13
|
return void 0;
|
|
@@ -18,6 +28,16 @@ function normalizeFill(fill) {
|
|
|
18
28
|
}
|
|
19
29
|
}
|
|
20
30
|
|
|
31
|
+
function normalizeForeground(foreground) {
|
|
32
|
+
if (!foreground || foreground === "none") {
|
|
33
|
+
return void 0;
|
|
34
|
+
} else if (typeof foreground === "string") {
|
|
35
|
+
return { src: foreground };
|
|
36
|
+
} else {
|
|
37
|
+
return foreground;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
21
41
|
function normalizeGeometry(geometry) {
|
|
22
42
|
if (!geometry || geometry === "none") {
|
|
23
43
|
return void 0;
|
|
@@ -162,15 +182,28 @@ function clearUndef(obj, deep = false) {
|
|
|
162
182
|
return newObj;
|
|
163
183
|
}
|
|
164
184
|
|
|
185
|
+
function normalizeVideo(video) {
|
|
186
|
+
if (!video || video === "none") {
|
|
187
|
+
return void 0;
|
|
188
|
+
} else if (typeof video === "string") {
|
|
189
|
+
return { src: video };
|
|
190
|
+
} else {
|
|
191
|
+
return video;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
165
195
|
function normalizeElement(element) {
|
|
166
196
|
return clearUndef({
|
|
167
197
|
...element,
|
|
168
|
-
background: normalizeBackground(element.background),
|
|
169
198
|
text: normalizeText(element.text),
|
|
199
|
+
background: normalizeBackground(element.background),
|
|
170
200
|
geometry: normalizeGeometry(element.geometry),
|
|
171
201
|
fill: normalizeFill(element.fill),
|
|
172
202
|
outline: normalizeOutline(element.outline),
|
|
203
|
+
foreground: normalizeForeground(element.foreground),
|
|
173
204
|
shadow: normalizeShadow(element.shadow),
|
|
205
|
+
video: normalizeVideo(element.video),
|
|
206
|
+
audio: normalizeVideo(element.audio),
|
|
174
207
|
children: element.children?.map((child) => normalizeElement(child))
|
|
175
208
|
});
|
|
176
209
|
}
|
|
@@ -341,4 +374,4 @@ function getDefaultStyle() {
|
|
|
341
374
|
};
|
|
342
375
|
}
|
|
343
376
|
|
|
344
|
-
export { clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeDocument, normalizeElement, normalizeFill, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent };
|
|
377
|
+
export { clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeAudio, normalizeBackground, normalizeDocument, normalizeElement, normalizeFill, normalizeForeground, normalizeGeometry, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent, normalizeVideo };
|