modern-idoc 0.3.4 → 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 +37 -1
- package/dist/index.d.cts +31 -12
- package/dist/index.d.mts +31 -12
- package/dist/index.d.ts +31 -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,12 +387,15 @@ exports.getDefaultTextInlineStyle = getDefaultTextInlineStyle;
|
|
|
354
387
|
exports.getDefaultTextLineStyle = getDefaultTextLineStyle;
|
|
355
388
|
exports.getDefaultTextStyle = getDefaultTextStyle;
|
|
356
389
|
exports.getDefaultTransformStyle = getDefaultTransformStyle;
|
|
390
|
+
exports.normalizeAudio = normalizeAudio;
|
|
357
391
|
exports.normalizeBackground = normalizeBackground;
|
|
358
392
|
exports.normalizeDocument = normalizeDocument;
|
|
359
393
|
exports.normalizeElement = normalizeElement;
|
|
360
394
|
exports.normalizeFill = normalizeFill;
|
|
395
|
+
exports.normalizeForeground = normalizeForeground;
|
|
361
396
|
exports.normalizeGeometry = normalizeGeometry;
|
|
362
397
|
exports.normalizeOutline = normalizeOutline;
|
|
363
398
|
exports.normalizeShadow = normalizeShadow;
|
|
364
399
|
exports.normalizeText = normalizeText;
|
|
365
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,13 +118,14 @@ 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;
|
|
120
123
|
declare function normalizeBackground(background?: BackgroundProperty): BackgroundDeclaration | undefined;
|
|
121
124
|
|
|
125
|
+
type ForegroundDeclaration = FillDeclaration;
|
|
126
|
+
type ForegroundProperty = None | string | ForegroundDeclaration;
|
|
127
|
+
declare function normalizeForeground(foreground?: ForegroundProperty): ForegroundDeclaration | undefined;
|
|
128
|
+
|
|
122
129
|
type SVGPathData = string;
|
|
123
130
|
type FillRule = 'nonzero' | 'evenodd';
|
|
124
131
|
type StrokeLinecap = 'butt' | 'round' | 'square';
|
|
@@ -159,10 +166,10 @@ interface MetaProperty {
|
|
|
159
166
|
[key: string]: any;
|
|
160
167
|
}
|
|
161
168
|
|
|
162
|
-
interface IDOCNode {
|
|
169
|
+
interface IDOCNode<T = MetaProperty> {
|
|
163
170
|
name?: string;
|
|
164
171
|
children?: IDOCNode[];
|
|
165
|
-
meta?:
|
|
172
|
+
meta?: T;
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
interface OutlineDeclaration {
|
|
@@ -400,26 +407,38 @@ type TextProperty = string | TextContent | (TextDeclaration & {
|
|
|
400
407
|
declare function normalizeTextContent(content?: TextContent): TextContentDeclaration;
|
|
401
408
|
declare function normalizeText(text?: TextProperty): TextDeclaration | undefined;
|
|
402
409
|
|
|
403
|
-
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> {
|
|
404
417
|
style?: StyleProperty;
|
|
405
418
|
text?: TextProperty;
|
|
419
|
+
background?: BackgroundProperty;
|
|
406
420
|
geometry?: GeometryProperty;
|
|
407
421
|
fill?: FillProperty;
|
|
408
422
|
outline?: OutlineProperty;
|
|
409
|
-
|
|
423
|
+
foreground?: ForegroundProperty;
|
|
410
424
|
shadow?: ShadowProperty;
|
|
425
|
+
video?: VideoProperty;
|
|
426
|
+
audio?: AudioProperty;
|
|
411
427
|
children?: IDOCElement[];
|
|
412
428
|
}
|
|
413
|
-
interface IDOCElementDeclaration extends IDOCElement {
|
|
429
|
+
interface IDOCElementDeclaration<T = MetaProperty> extends IDOCElement<T> {
|
|
414
430
|
text?: TextDeclaration;
|
|
431
|
+
background?: BackgroundDeclaration;
|
|
415
432
|
geometry?: GeometryDeclaration;
|
|
416
433
|
fill?: FillDeclaration;
|
|
417
434
|
outline?: OutlineDeclaration;
|
|
418
|
-
|
|
435
|
+
foreground?: ForegroundDeclaration;
|
|
419
436
|
shadow?: ShadowDeclaration;
|
|
437
|
+
video?: VideoDeclaration;
|
|
438
|
+
audio?: AudioDeclaration;
|
|
420
439
|
children?: IDOCElementDeclaration[];
|
|
421
440
|
}
|
|
422
|
-
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration
|
|
441
|
+
declare function normalizeElement<T = MetaProperty>(element: IDOCElement<T>): IDOCElementDeclaration<T>;
|
|
423
442
|
|
|
424
443
|
interface IDOCDocument extends IDOCElement {
|
|
425
444
|
fonts?: any;
|
|
@@ -431,4 +450,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
|
|
|
431
450
|
|
|
432
451
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
433
452
|
|
|
434
|
-
export { type Align, type AnyColor, type
|
|
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,13 +118,14 @@ 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;
|
|
120
123
|
declare function normalizeBackground(background?: BackgroundProperty): BackgroundDeclaration | undefined;
|
|
121
124
|
|
|
125
|
+
type ForegroundDeclaration = FillDeclaration;
|
|
126
|
+
type ForegroundProperty = None | string | ForegroundDeclaration;
|
|
127
|
+
declare function normalizeForeground(foreground?: ForegroundProperty): ForegroundDeclaration | undefined;
|
|
128
|
+
|
|
122
129
|
type SVGPathData = string;
|
|
123
130
|
type FillRule = 'nonzero' | 'evenodd';
|
|
124
131
|
type StrokeLinecap = 'butt' | 'round' | 'square';
|
|
@@ -159,10 +166,10 @@ interface MetaProperty {
|
|
|
159
166
|
[key: string]: any;
|
|
160
167
|
}
|
|
161
168
|
|
|
162
|
-
interface IDOCNode {
|
|
169
|
+
interface IDOCNode<T = MetaProperty> {
|
|
163
170
|
name?: string;
|
|
164
171
|
children?: IDOCNode[];
|
|
165
|
-
meta?:
|
|
172
|
+
meta?: T;
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
interface OutlineDeclaration {
|
|
@@ -400,26 +407,38 @@ type TextProperty = string | TextContent | (TextDeclaration & {
|
|
|
400
407
|
declare function normalizeTextContent(content?: TextContent): TextContentDeclaration;
|
|
401
408
|
declare function normalizeText(text?: TextProperty): TextDeclaration | undefined;
|
|
402
409
|
|
|
403
|
-
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> {
|
|
404
417
|
style?: StyleProperty;
|
|
405
418
|
text?: TextProperty;
|
|
419
|
+
background?: BackgroundProperty;
|
|
406
420
|
geometry?: GeometryProperty;
|
|
407
421
|
fill?: FillProperty;
|
|
408
422
|
outline?: OutlineProperty;
|
|
409
|
-
|
|
423
|
+
foreground?: ForegroundProperty;
|
|
410
424
|
shadow?: ShadowProperty;
|
|
425
|
+
video?: VideoProperty;
|
|
426
|
+
audio?: AudioProperty;
|
|
411
427
|
children?: IDOCElement[];
|
|
412
428
|
}
|
|
413
|
-
interface IDOCElementDeclaration extends IDOCElement {
|
|
429
|
+
interface IDOCElementDeclaration<T = MetaProperty> extends IDOCElement<T> {
|
|
414
430
|
text?: TextDeclaration;
|
|
431
|
+
background?: BackgroundDeclaration;
|
|
415
432
|
geometry?: GeometryDeclaration;
|
|
416
433
|
fill?: FillDeclaration;
|
|
417
434
|
outline?: OutlineDeclaration;
|
|
418
|
-
|
|
435
|
+
foreground?: ForegroundDeclaration;
|
|
419
436
|
shadow?: ShadowDeclaration;
|
|
437
|
+
video?: VideoDeclaration;
|
|
438
|
+
audio?: AudioDeclaration;
|
|
420
439
|
children?: IDOCElementDeclaration[];
|
|
421
440
|
}
|
|
422
|
-
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration
|
|
441
|
+
declare function normalizeElement<T = MetaProperty>(element: IDOCElement<T>): IDOCElementDeclaration<T>;
|
|
423
442
|
|
|
424
443
|
interface IDOCDocument extends IDOCElement {
|
|
425
444
|
fonts?: any;
|
|
@@ -431,4 +450,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
|
|
|
431
450
|
|
|
432
451
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
433
452
|
|
|
434
|
-
export { type Align, type AnyColor, type
|
|
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,13 +118,14 @@ 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;
|
|
120
123
|
declare function normalizeBackground(background?: BackgroundProperty): BackgroundDeclaration | undefined;
|
|
121
124
|
|
|
125
|
+
type ForegroundDeclaration = FillDeclaration;
|
|
126
|
+
type ForegroundProperty = None | string | ForegroundDeclaration;
|
|
127
|
+
declare function normalizeForeground(foreground?: ForegroundProperty): ForegroundDeclaration | undefined;
|
|
128
|
+
|
|
122
129
|
type SVGPathData = string;
|
|
123
130
|
type FillRule = 'nonzero' | 'evenodd';
|
|
124
131
|
type StrokeLinecap = 'butt' | 'round' | 'square';
|
|
@@ -159,10 +166,10 @@ interface MetaProperty {
|
|
|
159
166
|
[key: string]: any;
|
|
160
167
|
}
|
|
161
168
|
|
|
162
|
-
interface IDOCNode {
|
|
169
|
+
interface IDOCNode<T = MetaProperty> {
|
|
163
170
|
name?: string;
|
|
164
171
|
children?: IDOCNode[];
|
|
165
|
-
meta?:
|
|
172
|
+
meta?: T;
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
interface OutlineDeclaration {
|
|
@@ -400,26 +407,38 @@ type TextProperty = string | TextContent | (TextDeclaration & {
|
|
|
400
407
|
declare function normalizeTextContent(content?: TextContent): TextContentDeclaration;
|
|
401
408
|
declare function normalizeText(text?: TextProperty): TextDeclaration | undefined;
|
|
402
409
|
|
|
403
|
-
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> {
|
|
404
417
|
style?: StyleProperty;
|
|
405
418
|
text?: TextProperty;
|
|
419
|
+
background?: BackgroundProperty;
|
|
406
420
|
geometry?: GeometryProperty;
|
|
407
421
|
fill?: FillProperty;
|
|
408
422
|
outline?: OutlineProperty;
|
|
409
|
-
|
|
423
|
+
foreground?: ForegroundProperty;
|
|
410
424
|
shadow?: ShadowProperty;
|
|
425
|
+
video?: VideoProperty;
|
|
426
|
+
audio?: AudioProperty;
|
|
411
427
|
children?: IDOCElement[];
|
|
412
428
|
}
|
|
413
|
-
interface IDOCElementDeclaration extends IDOCElement {
|
|
429
|
+
interface IDOCElementDeclaration<T = MetaProperty> extends IDOCElement<T> {
|
|
414
430
|
text?: TextDeclaration;
|
|
431
|
+
background?: BackgroundDeclaration;
|
|
415
432
|
geometry?: GeometryDeclaration;
|
|
416
433
|
fill?: FillDeclaration;
|
|
417
434
|
outline?: OutlineDeclaration;
|
|
418
|
-
|
|
435
|
+
foreground?: ForegroundDeclaration;
|
|
419
436
|
shadow?: ShadowDeclaration;
|
|
437
|
+
video?: VideoDeclaration;
|
|
438
|
+
audio?: AudioDeclaration;
|
|
420
439
|
children?: IDOCElementDeclaration[];
|
|
421
440
|
}
|
|
422
|
-
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration
|
|
441
|
+
declare function normalizeElement<T = MetaProperty>(element: IDOCElement<T>): IDOCElementDeclaration<T>;
|
|
423
442
|
|
|
424
443
|
interface IDOCDocument extends IDOCElement {
|
|
425
444
|
fonts?: any;
|
|
@@ -431,4 +450,4 @@ declare function normalizeDocument(doc: IDOCDocument): IDOCDocumentDeclaration;
|
|
|
431
450
|
|
|
432
451
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
433
452
|
|
|
434
|
-
export { type Align, type AnyColor, type
|
|
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, normalizeBackground, 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 };
|