modern-idoc 0.5.6 → 0.6.1
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 +796 -145
- package/dist/index.d.cts +393 -227
- package/dist/index.d.mts +393 -227
- package/dist/index.d.ts +393 -227
- package/dist/index.js +1 -1
- package/dist/index.mjs +784 -145
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,45 @@
|
|
|
1
1
|
import { colord } from 'colord';
|
|
2
2
|
|
|
3
3
|
function normalizeAudio(audio) {
|
|
4
|
-
if (
|
|
5
|
-
return void 0;
|
|
6
|
-
} else if (typeof audio === "string") {
|
|
4
|
+
if (typeof audio === "string") {
|
|
7
5
|
return { src: audio };
|
|
8
6
|
} else {
|
|
9
7
|
return audio;
|
|
10
8
|
}
|
|
11
9
|
}
|
|
12
10
|
|
|
11
|
+
function isNone(value) {
|
|
12
|
+
return value === null || value === void 0 || value === "none";
|
|
13
|
+
}
|
|
14
|
+
function round(number, digits = 0, base = 10 ** digits) {
|
|
15
|
+
return Math.round(base * number) / base + 0;
|
|
16
|
+
}
|
|
17
|
+
function clearUndef(obj, deep = false) {
|
|
18
|
+
if (typeof obj !== "object" || !obj) {
|
|
19
|
+
return obj;
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(obj)) {
|
|
22
|
+
if (deep) {
|
|
23
|
+
return obj.map((v) => clearUndef(v, deep));
|
|
24
|
+
} else {
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const newObj = {};
|
|
29
|
+
for (const key in obj) {
|
|
30
|
+
const value = obj[key];
|
|
31
|
+
if (value === void 0 || value === null) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (deep) {
|
|
35
|
+
newObj[key] = clearUndef(value, deep);
|
|
36
|
+
} else {
|
|
37
|
+
newObj[key] = value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return newObj;
|
|
41
|
+
}
|
|
42
|
+
|
|
13
43
|
function parseColor(color) {
|
|
14
44
|
let input;
|
|
15
45
|
if (typeof color === "number") {
|
|
@@ -24,9 +54,6 @@ function parseColor(color) {
|
|
|
24
54
|
}
|
|
25
55
|
return colord(input);
|
|
26
56
|
}
|
|
27
|
-
function round(number, digits = 0, base = 10 ** digits) {
|
|
28
|
-
return Math.round(base * number) / base + 0;
|
|
29
|
-
}
|
|
30
57
|
function roundRgba(rgba) {
|
|
31
58
|
return {
|
|
32
59
|
r: round(rgba.r),
|
|
@@ -39,10 +66,11 @@ function format(number) {
|
|
|
39
66
|
const hex = number.toString(16);
|
|
40
67
|
return hex.length < 2 ? `0${hex}` : hex;
|
|
41
68
|
}
|
|
69
|
+
const defaultColor = "#000000FF";
|
|
70
|
+
function isColor(value) {
|
|
71
|
+
return parseColor(value).isValid();
|
|
72
|
+
}
|
|
42
73
|
function normalizeColor(color, orFail = false) {
|
|
43
|
-
if (color === void 0 || color === "none") {
|
|
44
|
-
return void 0;
|
|
45
|
-
}
|
|
46
74
|
const parsed = parseColor(color);
|
|
47
75
|
if (!parsed.isValid()) {
|
|
48
76
|
if (typeof color === "string") {
|
|
@@ -53,85 +81,720 @@ function normalizeColor(color, orFail = false) {
|
|
|
53
81
|
throw new Error(message);
|
|
54
82
|
} else {
|
|
55
83
|
console.warn(message);
|
|
56
|
-
return
|
|
84
|
+
return defaultColor;
|
|
57
85
|
}
|
|
58
86
|
}
|
|
59
87
|
const { r, g, b, a } = roundRgba(parsed.rgba);
|
|
60
88
|
return `#${format(r)}${format(g)}${format(b)}${format(round(a * 255))}`;
|
|
61
89
|
}
|
|
62
90
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
91
|
+
var GradientParser$1 = GradientParser$1 || {};
|
|
92
|
+
GradientParser$1.parse = /* @__PURE__ */ function() {
|
|
93
|
+
const tokens = {
|
|
94
|
+
linearGradient: /^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,
|
|
95
|
+
repeatingLinearGradient: /^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,
|
|
96
|
+
radialGradient: /^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,
|
|
97
|
+
repeatingRadialGradient: /^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,
|
|
98
|
+
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
|
|
99
|
+
extentKeywords: /^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,
|
|
100
|
+
positionKeywords: /^(left|center|right|top|bottom)/i,
|
|
101
|
+
pixelValue: /^(-?((\d*\.\d+)|(\d+\.?)))px/,
|
|
102
|
+
percentageValue: /^(-?((\d*\.\d+)|(\d+\.?)))%/,
|
|
103
|
+
emValue: /^(-?((\d*\.\d+)|(\d+\.?)))em/,
|
|
104
|
+
angleValue: /^(-?((\d*\.\d+)|(\d+\.?)))deg/,
|
|
105
|
+
radianValue: /^(-?((\d*\.\d+)|(\d+\.?)))rad/,
|
|
106
|
+
startCall: /^\(/,
|
|
107
|
+
endCall: /^\)/,
|
|
108
|
+
comma: /^,/,
|
|
109
|
+
hexColor: /^#([0-9a-f]+)/i,
|
|
110
|
+
literalColor: /^([a-z]+)/i,
|
|
111
|
+
rgbColor: /^rgb/i,
|
|
112
|
+
rgbaColor: /^rgba/i,
|
|
113
|
+
varColor: /^var/i,
|
|
114
|
+
calcValue: /^calc/i,
|
|
115
|
+
variableName: /^(--[a-z0-9-,\s#]+)/i,
|
|
116
|
+
number: /^((\d*\.\d+)|(\d+\.?))/,
|
|
117
|
+
hslColor: /^hsl/i,
|
|
118
|
+
hslaColor: /^hsla/i
|
|
119
|
+
};
|
|
120
|
+
let input = "";
|
|
121
|
+
function error(msg) {
|
|
122
|
+
const err = new Error(`${input}: ${msg}`);
|
|
123
|
+
err.source = input;
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
126
|
+
function getAST() {
|
|
127
|
+
const ast = matchListDefinitions();
|
|
128
|
+
if (input.length > 0) {
|
|
129
|
+
error("Invalid input not EOF");
|
|
130
|
+
}
|
|
131
|
+
return ast;
|
|
132
|
+
}
|
|
133
|
+
function matchListDefinitions() {
|
|
134
|
+
return matchListing(matchDefinition);
|
|
135
|
+
}
|
|
136
|
+
function matchDefinition() {
|
|
137
|
+
return matchGradient(
|
|
138
|
+
"linear-gradient",
|
|
139
|
+
tokens.linearGradient,
|
|
140
|
+
matchLinearOrientation
|
|
141
|
+
) || matchGradient(
|
|
142
|
+
"repeating-linear-gradient",
|
|
143
|
+
tokens.repeatingLinearGradient,
|
|
144
|
+
matchLinearOrientation
|
|
145
|
+
) || matchGradient(
|
|
146
|
+
"radial-gradient",
|
|
147
|
+
tokens.radialGradient,
|
|
148
|
+
matchListRadialOrientations
|
|
149
|
+
) || matchGradient(
|
|
150
|
+
"repeating-radial-gradient",
|
|
151
|
+
tokens.repeatingRadialGradient,
|
|
152
|
+
matchListRadialOrientations
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
function matchGradient(gradientType, pattern, orientationMatcher) {
|
|
156
|
+
return matchCall(pattern, (captures) => {
|
|
157
|
+
const orientation = orientationMatcher();
|
|
158
|
+
if (orientation) {
|
|
159
|
+
if (!scan(tokens.comma)) {
|
|
160
|
+
error("Missing comma before color stops");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
type: gradientType,
|
|
165
|
+
orientation,
|
|
166
|
+
colorStops: matchListing(matchColorStop)
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function matchCall(pattern, callback) {
|
|
171
|
+
const captures = scan(pattern);
|
|
172
|
+
if (captures) {
|
|
173
|
+
if (!scan(tokens.startCall)) {
|
|
174
|
+
error("Missing (");
|
|
175
|
+
}
|
|
176
|
+
const result = callback(captures);
|
|
177
|
+
if (!scan(tokens.endCall)) {
|
|
178
|
+
error("Missing )");
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function matchLinearOrientation() {
|
|
184
|
+
const sideOrCorner = matchSideOrCorner();
|
|
185
|
+
if (sideOrCorner) {
|
|
186
|
+
return sideOrCorner;
|
|
187
|
+
}
|
|
188
|
+
const legacyDirection = match("position-keyword", tokens.positionKeywords, 1);
|
|
189
|
+
if (legacyDirection) {
|
|
190
|
+
return {
|
|
191
|
+
type: "directional",
|
|
192
|
+
value: legacyDirection.value
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return matchAngle();
|
|
196
|
+
}
|
|
197
|
+
function matchSideOrCorner() {
|
|
198
|
+
return match("directional", tokens.sideOrCorner, 1);
|
|
199
|
+
}
|
|
200
|
+
function matchAngle() {
|
|
201
|
+
return match("angular", tokens.angleValue, 1) || match("angular", tokens.radianValue, 1);
|
|
202
|
+
}
|
|
203
|
+
function matchListRadialOrientations() {
|
|
204
|
+
let radialOrientations;
|
|
205
|
+
let radialOrientation = matchRadialOrientation();
|
|
206
|
+
let lookaheadCache;
|
|
207
|
+
if (radialOrientation) {
|
|
208
|
+
radialOrientations = [];
|
|
209
|
+
radialOrientations.push(radialOrientation);
|
|
210
|
+
lookaheadCache = input;
|
|
211
|
+
if (scan(tokens.comma)) {
|
|
212
|
+
radialOrientation = matchRadialOrientation();
|
|
213
|
+
if (radialOrientation) {
|
|
214
|
+
radialOrientations.push(radialOrientation);
|
|
215
|
+
} else {
|
|
216
|
+
input = lookaheadCache;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return radialOrientations;
|
|
221
|
+
}
|
|
222
|
+
function matchRadialOrientation() {
|
|
223
|
+
let radialType = matchCircle() || matchEllipse();
|
|
224
|
+
if (radialType) {
|
|
225
|
+
radialType.at = matchAtPosition();
|
|
226
|
+
} else {
|
|
227
|
+
const extent = matchExtentKeyword();
|
|
228
|
+
if (extent) {
|
|
229
|
+
radialType = extent;
|
|
230
|
+
const positionAt = matchAtPosition();
|
|
231
|
+
if (positionAt) {
|
|
232
|
+
radialType.at = positionAt;
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
const atPosition = matchAtPosition();
|
|
236
|
+
if (atPosition) {
|
|
237
|
+
radialType = {
|
|
238
|
+
type: "default-radial",
|
|
239
|
+
at: atPosition
|
|
240
|
+
};
|
|
241
|
+
} else {
|
|
242
|
+
const defaultPosition = matchPositioning();
|
|
243
|
+
if (defaultPosition) {
|
|
244
|
+
radialType = {
|
|
245
|
+
type: "default-radial",
|
|
246
|
+
at: defaultPosition
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return radialType;
|
|
253
|
+
}
|
|
254
|
+
function matchCircle() {
|
|
255
|
+
const circle = match("shape", /^(circle)/i, 0);
|
|
256
|
+
if (circle) {
|
|
257
|
+
circle.style = matchLength() || matchExtentKeyword();
|
|
258
|
+
}
|
|
259
|
+
return circle;
|
|
260
|
+
}
|
|
261
|
+
function matchEllipse() {
|
|
262
|
+
const ellipse = match("shape", /^(ellipse)/i, 0);
|
|
263
|
+
if (ellipse) {
|
|
264
|
+
ellipse.style = matchPositioning() || matchDistance() || matchExtentKeyword();
|
|
265
|
+
}
|
|
266
|
+
return ellipse;
|
|
267
|
+
}
|
|
268
|
+
function matchExtentKeyword() {
|
|
269
|
+
return match("extent-keyword", tokens.extentKeywords, 1);
|
|
270
|
+
}
|
|
271
|
+
function matchAtPosition() {
|
|
272
|
+
if (match("position", /^at/, 0)) {
|
|
273
|
+
const positioning = matchPositioning();
|
|
274
|
+
if (!positioning) {
|
|
275
|
+
error("Missing positioning value");
|
|
276
|
+
}
|
|
277
|
+
return positioning;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function matchPositioning() {
|
|
281
|
+
const location = matchCoordinates();
|
|
282
|
+
if (location.x || location.y) {
|
|
283
|
+
return {
|
|
284
|
+
type: "position",
|
|
285
|
+
value: location
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function matchCoordinates() {
|
|
69
290
|
return {
|
|
70
|
-
|
|
71
|
-
|
|
291
|
+
x: matchDistance(),
|
|
292
|
+
y: matchDistance()
|
|
72
293
|
};
|
|
73
294
|
}
|
|
295
|
+
function matchListing(matcher) {
|
|
296
|
+
let captures = matcher();
|
|
297
|
+
const result = [];
|
|
298
|
+
if (captures) {
|
|
299
|
+
result.push(captures);
|
|
300
|
+
while (scan(tokens.comma)) {
|
|
301
|
+
captures = matcher();
|
|
302
|
+
if (captures) {
|
|
303
|
+
result.push(captures);
|
|
304
|
+
} else {
|
|
305
|
+
error("One extra comma");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
311
|
+
function matchColorStop() {
|
|
312
|
+
const color = matchColor();
|
|
313
|
+
if (!color) {
|
|
314
|
+
error("Expected color definition");
|
|
315
|
+
}
|
|
316
|
+
color.length = matchDistance();
|
|
317
|
+
return color;
|
|
318
|
+
}
|
|
319
|
+
function matchColor() {
|
|
320
|
+
return matchHexColor() || matchHSLAColor() || matchHSLColor() || matchRGBAColor() || matchRGBColor() || matchVarColor() || matchLiteralColor();
|
|
321
|
+
}
|
|
322
|
+
function matchLiteralColor() {
|
|
323
|
+
return match("literal", tokens.literalColor, 0);
|
|
324
|
+
}
|
|
325
|
+
function matchHexColor() {
|
|
326
|
+
return match("hex", tokens.hexColor, 1);
|
|
327
|
+
}
|
|
328
|
+
function matchRGBColor() {
|
|
329
|
+
return matchCall(tokens.rgbColor, () => {
|
|
330
|
+
return {
|
|
331
|
+
type: "rgb",
|
|
332
|
+
value: matchListing(matchNumber)
|
|
333
|
+
};
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
function matchRGBAColor() {
|
|
337
|
+
return matchCall(tokens.rgbaColor, () => {
|
|
338
|
+
return {
|
|
339
|
+
type: "rgba",
|
|
340
|
+
value: matchListing(matchNumber)
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
function matchVarColor() {
|
|
345
|
+
return matchCall(tokens.varColor, () => {
|
|
346
|
+
return {
|
|
347
|
+
type: "var",
|
|
348
|
+
value: matchVariableName()
|
|
349
|
+
};
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
function matchHSLColor() {
|
|
353
|
+
return matchCall(tokens.hslColor, () => {
|
|
354
|
+
const lookahead = scan(tokens.percentageValue);
|
|
355
|
+
if (lookahead) {
|
|
356
|
+
error("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");
|
|
357
|
+
}
|
|
358
|
+
const hue = matchNumber();
|
|
359
|
+
scan(tokens.comma);
|
|
360
|
+
let captures = scan(tokens.percentageValue);
|
|
361
|
+
const sat = captures ? captures[1] : null;
|
|
362
|
+
scan(tokens.comma);
|
|
363
|
+
captures = scan(tokens.percentageValue);
|
|
364
|
+
const light = captures ? captures[1] : null;
|
|
365
|
+
if (!sat || !light) {
|
|
366
|
+
error("Expected percentage value for saturation and lightness in HSL");
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
type: "hsl",
|
|
370
|
+
value: [hue, sat, light]
|
|
371
|
+
};
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
function matchHSLAColor() {
|
|
375
|
+
return matchCall(tokens.hslaColor, () => {
|
|
376
|
+
const hue = matchNumber();
|
|
377
|
+
scan(tokens.comma);
|
|
378
|
+
let captures = scan(tokens.percentageValue);
|
|
379
|
+
const sat = captures ? captures[1] : null;
|
|
380
|
+
scan(tokens.comma);
|
|
381
|
+
captures = scan(tokens.percentageValue);
|
|
382
|
+
const light = captures ? captures[1] : null;
|
|
383
|
+
scan(tokens.comma);
|
|
384
|
+
const alpha = matchNumber();
|
|
385
|
+
if (!sat || !light) {
|
|
386
|
+
error("Expected percentage value for saturation and lightness in HSLA");
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
type: "hsla",
|
|
390
|
+
value: [hue, sat, light, alpha]
|
|
391
|
+
};
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
function matchVariableName() {
|
|
395
|
+
return scan(tokens.variableName)[1];
|
|
396
|
+
}
|
|
397
|
+
function matchNumber() {
|
|
398
|
+
return scan(tokens.number)[1];
|
|
399
|
+
}
|
|
400
|
+
function matchDistance() {
|
|
401
|
+
return match("%", tokens.percentageValue, 1) || matchPositionKeyword() || matchCalc() || matchLength();
|
|
402
|
+
}
|
|
403
|
+
function matchPositionKeyword() {
|
|
404
|
+
return match("position-keyword", tokens.positionKeywords, 1);
|
|
405
|
+
}
|
|
406
|
+
function matchCalc() {
|
|
407
|
+
return matchCall(tokens.calcValue, () => {
|
|
408
|
+
let openParenCount = 1;
|
|
409
|
+
let i = 0;
|
|
410
|
+
while (openParenCount > 0 && i < input.length) {
|
|
411
|
+
const char = input.charAt(i);
|
|
412
|
+
if (char === "(") {
|
|
413
|
+
openParenCount++;
|
|
414
|
+
} else if (char === ")") {
|
|
415
|
+
openParenCount--;
|
|
416
|
+
}
|
|
417
|
+
i++;
|
|
418
|
+
}
|
|
419
|
+
if (openParenCount > 0) {
|
|
420
|
+
error("Missing closing parenthesis in calc() expression");
|
|
421
|
+
}
|
|
422
|
+
const calcContent = input.substring(0, i - 1);
|
|
423
|
+
consume(i - 1);
|
|
424
|
+
return {
|
|
425
|
+
type: "calc",
|
|
426
|
+
value: calcContent
|
|
427
|
+
};
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
function matchLength() {
|
|
431
|
+
return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
|
|
432
|
+
}
|
|
433
|
+
function match(type, pattern, captureIndex) {
|
|
434
|
+
const captures = scan(pattern);
|
|
435
|
+
if (captures) {
|
|
436
|
+
return {
|
|
437
|
+
type,
|
|
438
|
+
value: captures[captureIndex]
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function scan(regexp) {
|
|
443
|
+
let captures, blankCaptures;
|
|
444
|
+
blankCaptures = /^\s+/.exec(input);
|
|
445
|
+
if (blankCaptures) {
|
|
446
|
+
consume(blankCaptures[0].length);
|
|
447
|
+
}
|
|
448
|
+
captures = regexp.exec(input);
|
|
449
|
+
if (captures) {
|
|
450
|
+
consume(captures[0].length);
|
|
451
|
+
}
|
|
452
|
+
return captures;
|
|
453
|
+
}
|
|
454
|
+
function consume(size) {
|
|
455
|
+
input = input.substr(size);
|
|
456
|
+
}
|
|
457
|
+
return function(code) {
|
|
458
|
+
input = code.toString().trim();
|
|
459
|
+
if (input.endsWith(";")) {
|
|
460
|
+
input = input.slice(0, -1);
|
|
461
|
+
}
|
|
462
|
+
return getAST();
|
|
463
|
+
};
|
|
464
|
+
}();
|
|
465
|
+
const parseGradient = GradientParser$1.parse.bind(GradientParser$1);
|
|
466
|
+
|
|
467
|
+
var GradientParser = GradientParser || {};
|
|
468
|
+
GradientParser.stringify = /* @__PURE__ */ function() {
|
|
469
|
+
var visitor = {
|
|
470
|
+
"visit_linear-gradient": function(node) {
|
|
471
|
+
return visitor.visit_gradient(node);
|
|
472
|
+
},
|
|
473
|
+
"visit_repeating-linear-gradient": function(node) {
|
|
474
|
+
return visitor.visit_gradient(node);
|
|
475
|
+
},
|
|
476
|
+
"visit_radial-gradient": function(node) {
|
|
477
|
+
return visitor.visit_gradient(node);
|
|
478
|
+
},
|
|
479
|
+
"visit_repeating-radial-gradient": function(node) {
|
|
480
|
+
return visitor.visit_gradient(node);
|
|
481
|
+
},
|
|
482
|
+
"visit_gradient": function(node) {
|
|
483
|
+
var orientation = visitor.visit(node.orientation);
|
|
484
|
+
if (orientation) {
|
|
485
|
+
orientation += ", ";
|
|
486
|
+
}
|
|
487
|
+
return node.type + "(" + orientation + visitor.visit(node.colorStops) + ")";
|
|
488
|
+
},
|
|
489
|
+
"visit_shape": function(node) {
|
|
490
|
+
var result = node.value, at = visitor.visit(node.at), style = visitor.visit(node.style);
|
|
491
|
+
if (style) {
|
|
492
|
+
result += " " + style;
|
|
493
|
+
}
|
|
494
|
+
if (at) {
|
|
495
|
+
result += " at " + at;
|
|
496
|
+
}
|
|
497
|
+
return result;
|
|
498
|
+
},
|
|
499
|
+
"visit_default-radial": function(node) {
|
|
500
|
+
var result = "", at = visitor.visit(node.at);
|
|
501
|
+
if (at) {
|
|
502
|
+
result += at;
|
|
503
|
+
}
|
|
504
|
+
return result;
|
|
505
|
+
},
|
|
506
|
+
"visit_extent-keyword": function(node) {
|
|
507
|
+
var result = node.value, at = visitor.visit(node.at);
|
|
508
|
+
if (at) {
|
|
509
|
+
result += " at " + at;
|
|
510
|
+
}
|
|
511
|
+
return result;
|
|
512
|
+
},
|
|
513
|
+
"visit_position-keyword": function(node) {
|
|
514
|
+
return node.value;
|
|
515
|
+
},
|
|
516
|
+
"visit_position": function(node) {
|
|
517
|
+
return visitor.visit(node.value.x) + " " + visitor.visit(node.value.y);
|
|
518
|
+
},
|
|
519
|
+
"visit_%": function(node) {
|
|
520
|
+
return node.value + "%";
|
|
521
|
+
},
|
|
522
|
+
"visit_em": function(node) {
|
|
523
|
+
return node.value + "em";
|
|
524
|
+
},
|
|
525
|
+
"visit_px": function(node) {
|
|
526
|
+
return node.value + "px";
|
|
527
|
+
},
|
|
528
|
+
"visit_calc": function(node) {
|
|
529
|
+
return "calc(" + node.value + ")";
|
|
530
|
+
},
|
|
531
|
+
"visit_literal": function(node) {
|
|
532
|
+
return visitor.visit_color(node.value, node);
|
|
533
|
+
},
|
|
534
|
+
"visit_hex": function(node) {
|
|
535
|
+
return visitor.visit_color("#" + node.value, node);
|
|
536
|
+
},
|
|
537
|
+
"visit_rgb": function(node) {
|
|
538
|
+
return visitor.visit_color("rgb(" + node.value.join(", ") + ")", node);
|
|
539
|
+
},
|
|
540
|
+
"visit_rgba": function(node) {
|
|
541
|
+
return visitor.visit_color("rgba(" + node.value.join(", ") + ")", node);
|
|
542
|
+
},
|
|
543
|
+
"visit_hsl": function(node) {
|
|
544
|
+
return visitor.visit_color("hsl(" + node.value[0] + ", " + node.value[1] + "%, " + node.value[2] + "%)", node);
|
|
545
|
+
},
|
|
546
|
+
"visit_hsla": function(node) {
|
|
547
|
+
return visitor.visit_color("hsla(" + node.value[0] + ", " + node.value[1] + "%, " + node.value[2] + "%, " + node.value[3] + ")", node);
|
|
548
|
+
},
|
|
549
|
+
"visit_var": function(node) {
|
|
550
|
+
return visitor.visit_color("var(" + node.value + ")", node);
|
|
551
|
+
},
|
|
552
|
+
"visit_color": function(resultColor, node) {
|
|
553
|
+
var result = resultColor, length = visitor.visit(node.length);
|
|
554
|
+
if (length) {
|
|
555
|
+
result += " " + length;
|
|
556
|
+
}
|
|
557
|
+
return result;
|
|
558
|
+
},
|
|
559
|
+
"visit_angular": function(node) {
|
|
560
|
+
return node.value + "deg";
|
|
561
|
+
},
|
|
562
|
+
"visit_directional": function(node) {
|
|
563
|
+
return "to " + node.value;
|
|
564
|
+
},
|
|
565
|
+
"visit_array": function(elements) {
|
|
566
|
+
var result = "", size = elements.length;
|
|
567
|
+
elements.forEach(function(element, i) {
|
|
568
|
+
result += visitor.visit(element);
|
|
569
|
+
if (i < size - 1) {
|
|
570
|
+
result += ", ";
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
return result;
|
|
574
|
+
},
|
|
575
|
+
"visit_object": function(obj) {
|
|
576
|
+
if (obj.width && obj.height) {
|
|
577
|
+
return visitor.visit(obj.width) + " " + visitor.visit(obj.height);
|
|
578
|
+
}
|
|
579
|
+
return "";
|
|
580
|
+
},
|
|
581
|
+
"visit": function(element) {
|
|
582
|
+
if (!element) {
|
|
583
|
+
return "";
|
|
584
|
+
}
|
|
585
|
+
if (element instanceof Array) {
|
|
586
|
+
return visitor.visit_array(element);
|
|
587
|
+
} else if (typeof element === "object" && !element.type) {
|
|
588
|
+
return visitor.visit_object(element);
|
|
589
|
+
} else if (element.type) {
|
|
590
|
+
var nodeVisitor = visitor["visit_" + element.type];
|
|
591
|
+
if (nodeVisitor) {
|
|
592
|
+
return nodeVisitor(element);
|
|
593
|
+
} else {
|
|
594
|
+
throw Error("Missing visitor visit_" + element.type);
|
|
595
|
+
}
|
|
596
|
+
} else {
|
|
597
|
+
throw Error("Invalid node.");
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
return function(root) {
|
|
602
|
+
return visitor.visit(root);
|
|
603
|
+
};
|
|
604
|
+
}();
|
|
605
|
+
const stringifyGradient = GradientParser.stringify.bind(GradientParser);
|
|
606
|
+
|
|
607
|
+
function parseColorStopNodeList(colorStops) {
|
|
608
|
+
const count = colorStops.length - 1;
|
|
609
|
+
return colorStops.map((stop, index) => {
|
|
610
|
+
const value = stop.value;
|
|
611
|
+
let offset = round(index / count, 3);
|
|
612
|
+
let color = "#00000000";
|
|
613
|
+
switch (stop.type) {
|
|
614
|
+
case "rgb":
|
|
615
|
+
color = normalizeColor({
|
|
616
|
+
r: Number(value[0] ?? 0),
|
|
617
|
+
g: Number(value[1] ?? 0),
|
|
618
|
+
b: Number(value[2] ?? 0)
|
|
619
|
+
});
|
|
620
|
+
break;
|
|
621
|
+
case "rgba":
|
|
622
|
+
color = normalizeColor({
|
|
623
|
+
r: Number(value[0] ?? 0),
|
|
624
|
+
g: Number(value[1] ?? 0),
|
|
625
|
+
b: Number(value[2] ?? 0),
|
|
626
|
+
a: Number(value[3] ?? 0)
|
|
627
|
+
});
|
|
628
|
+
break;
|
|
629
|
+
case "literal":
|
|
630
|
+
color = normalizeColor(stop.value);
|
|
631
|
+
break;
|
|
632
|
+
case "hex":
|
|
633
|
+
color = normalizeColor(stop.value);
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
switch (stop.length?.type) {
|
|
637
|
+
case "%":
|
|
638
|
+
offset = Number(stop.length.value) / 100;
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
return { offset, color };
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function parseLinearGradientNode(node) {
|
|
645
|
+
let angle = 0;
|
|
646
|
+
switch (node.orientation?.type) {
|
|
647
|
+
case "angular":
|
|
648
|
+
angle = Number(node.orientation.value);
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
return {
|
|
652
|
+
type: "linear-gradient",
|
|
653
|
+
angle,
|
|
654
|
+
stops: parseColorStopNodeList(node.colorStops)
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
function parseRadialGradientNode(node) {
|
|
658
|
+
node.orientation?.map((item) => {
|
|
659
|
+
switch (item?.type) {
|
|
660
|
+
case "shape":
|
|
661
|
+
case "default-radial":
|
|
662
|
+
case "extent-keyword":
|
|
663
|
+
default:
|
|
664
|
+
return null;
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
return {
|
|
668
|
+
type: "radial-gradient",
|
|
669
|
+
stops: parseColorStopNodeList(node.colorStops)
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
function isGradient(cssText) {
|
|
673
|
+
return cssText.startsWith("linear-gradient") || cssText.startsWith("radial-gradient");
|
|
674
|
+
}
|
|
675
|
+
function normalizeGradient(cssText) {
|
|
676
|
+
return parseGradient(cssText).map((node) => {
|
|
677
|
+
switch (node?.type) {
|
|
678
|
+
case "linear-gradient":
|
|
679
|
+
return parseLinearGradientNode(node);
|
|
680
|
+
case "repeating-linear-gradient":
|
|
681
|
+
return { ...parseLinearGradientNode(node), repeat: true };
|
|
682
|
+
case "radial-gradient":
|
|
683
|
+
return parseRadialGradientNode(node);
|
|
684
|
+
case "repeating-radial-gradient":
|
|
685
|
+
return { ...parseRadialGradientNode(node), repeat: true };
|
|
686
|
+
default:
|
|
687
|
+
return void 0;
|
|
688
|
+
}
|
|
689
|
+
}).filter(Boolean);
|
|
74
690
|
}
|
|
75
691
|
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return { src: background };
|
|
692
|
+
function normalizeColorFill(fill) {
|
|
693
|
+
let obj;
|
|
694
|
+
if (typeof fill === "string") {
|
|
695
|
+
obj = { color: fill };
|
|
81
696
|
} else {
|
|
82
|
-
|
|
83
|
-
...background,
|
|
84
|
-
...normalizeFill(background)
|
|
85
|
-
};
|
|
697
|
+
obj = fill;
|
|
86
698
|
}
|
|
699
|
+
return {
|
|
700
|
+
color: normalizeColor(obj.color)
|
|
701
|
+
};
|
|
87
702
|
}
|
|
88
703
|
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
704
|
+
function normalizeGradientFill(fill) {
|
|
705
|
+
let obj;
|
|
706
|
+
if (typeof fill === "string") {
|
|
707
|
+
obj = { image: fill };
|
|
708
|
+
} else {
|
|
709
|
+
obj = fill;
|
|
92
710
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
711
|
+
const res = normalizeGradient(obj.image)[0];
|
|
712
|
+
switch (res?.type) {
|
|
713
|
+
case "radial-gradient":
|
|
714
|
+
return {
|
|
715
|
+
radialGradient: res
|
|
716
|
+
};
|
|
717
|
+
case "linear-gradient":
|
|
718
|
+
return {
|
|
719
|
+
linearGradient: res
|
|
720
|
+
};
|
|
99
721
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
722
|
+
return {};
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function normalizeImageFill(fill) {
|
|
726
|
+
return fill;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
function normalizePresetFill(fill) {
|
|
730
|
+
let obj;
|
|
731
|
+
if (typeof fill === "string") {
|
|
732
|
+
obj = { preset: fill };
|
|
733
|
+
} else {
|
|
734
|
+
obj = fill;
|
|
735
|
+
}
|
|
736
|
+
return {
|
|
737
|
+
preset: obj.preset,
|
|
738
|
+
foregroundColor: isNone(obj.foregroundColor) ? void 0 : normalizeColor(obj.foregroundColor),
|
|
739
|
+
backgroundColor: isNone(obj.backgroundColor) ? void 0 : normalizeColor(obj.backgroundColor)
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
function normalizeFill(fill) {
|
|
744
|
+
if (typeof fill === "string") {
|
|
745
|
+
if (isColor(fill)) {
|
|
746
|
+
return normalizeColorFill({ color: fill });
|
|
747
|
+
} else if (isGradient(fill)) {
|
|
748
|
+
return normalizeGradientFill({ image: fill });
|
|
108
749
|
} else {
|
|
109
|
-
|
|
750
|
+
return normalizeImageFill({ image: fill });
|
|
751
|
+
}
|
|
752
|
+
} else {
|
|
753
|
+
if (!isNone(fill.color)) {
|
|
754
|
+
return normalizeColorFill(fill);
|
|
755
|
+
} else if (!isNone(fill.image)) {
|
|
756
|
+
if (isGradient(fill.image)) {
|
|
757
|
+
return normalizeGradientFill(fill);
|
|
758
|
+
} else {
|
|
759
|
+
return normalizeImageFill(fill);
|
|
760
|
+
}
|
|
761
|
+
} else if (isNone(fill.preset)) {
|
|
762
|
+
return normalizePresetFill(fill);
|
|
110
763
|
}
|
|
111
764
|
}
|
|
112
|
-
|
|
765
|
+
throw new Error("Unknown fill property object");
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
function normalizeBackground(background) {
|
|
769
|
+
if (typeof background === "string") {
|
|
770
|
+
return {
|
|
771
|
+
...normalizeFill(background),
|
|
772
|
+
fillWithShape: false
|
|
773
|
+
};
|
|
774
|
+
} else {
|
|
775
|
+
return {
|
|
776
|
+
...normalizeFill(background),
|
|
777
|
+
fillWithShape: Boolean(background.fillWithShape)
|
|
778
|
+
};
|
|
779
|
+
}
|
|
113
780
|
}
|
|
114
781
|
|
|
115
782
|
function getDefaultInnerShadow() {
|
|
116
783
|
return {
|
|
117
|
-
color:
|
|
784
|
+
color: defaultColor,
|
|
118
785
|
offsetX: 0,
|
|
119
786
|
offsetY: 0,
|
|
120
787
|
blurRadius: 1
|
|
121
788
|
};
|
|
122
789
|
}
|
|
123
790
|
function normalizeInnerShadow(shadow) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
color: normalizeColor(shadow.color)
|
|
132
|
-
})
|
|
133
|
-
};
|
|
134
|
-
}
|
|
791
|
+
return {
|
|
792
|
+
...getDefaultInnerShadow(),
|
|
793
|
+
...clearUndef({
|
|
794
|
+
...shadow,
|
|
795
|
+
color: isNone(shadow.color) ? defaultColor : normalizeColor(shadow.color)
|
|
796
|
+
})
|
|
797
|
+
};
|
|
135
798
|
}
|
|
136
799
|
|
|
137
800
|
function getDefaultOuterShadow() {
|
|
@@ -142,101 +805,61 @@ function getDefaultOuterShadow() {
|
|
|
142
805
|
};
|
|
143
806
|
}
|
|
144
807
|
function normalizeOuterShadow(shadow) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
...getDefaultOuterShadow(),
|
|
150
|
-
...normalizeInnerShadow(shadow)
|
|
151
|
-
};
|
|
152
|
-
}
|
|
808
|
+
return {
|
|
809
|
+
...getDefaultOuterShadow(),
|
|
810
|
+
...normalizeInnerShadow(shadow)
|
|
811
|
+
};
|
|
153
812
|
}
|
|
154
813
|
|
|
155
814
|
function normalizeSoftEdge(softEdge) {
|
|
156
|
-
|
|
157
|
-
return void 0;
|
|
158
|
-
} else {
|
|
159
|
-
return softEdge;
|
|
160
|
-
}
|
|
815
|
+
return softEdge;
|
|
161
816
|
}
|
|
162
817
|
|
|
163
818
|
function normalizeEffect(effect) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
outerShadow: normalizeOuterShadow(effect.outerShadow),
|
|
171
|
-
innerShadow: normalizeInnerShadow(effect.innerShadow)
|
|
172
|
-
});
|
|
173
|
-
}
|
|
819
|
+
return clearUndef({
|
|
820
|
+
...effect,
|
|
821
|
+
softEdge: isNone(effect.softEdge) ? void 0 : normalizeSoftEdge(effect.softEdge),
|
|
822
|
+
outerShadow: isNone(effect.outerShadow) ? void 0 : normalizeOuterShadow(effect.outerShadow),
|
|
823
|
+
innerShadow: isNone(effect.innerShadow) ? void 0 : normalizeInnerShadow(effect.innerShadow)
|
|
824
|
+
});
|
|
174
825
|
}
|
|
175
826
|
|
|
176
827
|
function normalizeForeground(foreground) {
|
|
177
|
-
if (
|
|
178
|
-
return void 0;
|
|
179
|
-
} else if (typeof foreground === "string") {
|
|
180
|
-
return { src: foreground };
|
|
181
|
-
} else {
|
|
182
|
-
return {
|
|
183
|
-
...foreground,
|
|
184
|
-
...normalizeFill(foreground)
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function normalizeGeometry(geometry) {
|
|
190
|
-
if (!geometry || geometry === "none") {
|
|
191
|
-
return void 0;
|
|
192
|
-
} else if (typeof geometry === "string") {
|
|
828
|
+
if (typeof foreground === "string") {
|
|
193
829
|
return {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
]
|
|
830
|
+
...normalizeFill(foreground),
|
|
831
|
+
fillWithShape: false
|
|
197
832
|
};
|
|
198
|
-
} else
|
|
833
|
+
} else {
|
|
199
834
|
return {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
return {
|
|
203
|
-
data
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
return data;
|
|
207
|
-
})
|
|
835
|
+
...normalizeFill(foreground),
|
|
836
|
+
fillWithShape: Boolean(foreground.fillWithShape)
|
|
208
837
|
};
|
|
209
|
-
} else {
|
|
210
|
-
return geometry;
|
|
211
838
|
}
|
|
212
839
|
}
|
|
213
840
|
|
|
214
841
|
function normalizeOutline(outline) {
|
|
215
|
-
if (
|
|
216
|
-
return void 0;
|
|
217
|
-
} else if (typeof outline === "string") {
|
|
842
|
+
if (typeof outline === "string") {
|
|
218
843
|
return {
|
|
219
844
|
color: normalizeColor(outline)
|
|
220
845
|
};
|
|
221
846
|
} else {
|
|
222
847
|
return {
|
|
223
848
|
...outline,
|
|
224
|
-
color: normalizeColor(outline.color)
|
|
849
|
+
color: isNone(outline.color) ? void 0 : normalizeColor(outline.color)
|
|
225
850
|
};
|
|
226
851
|
}
|
|
227
852
|
}
|
|
228
853
|
|
|
229
854
|
function normalizeShadow(shadow) {
|
|
230
|
-
if (
|
|
231
|
-
return void 0;
|
|
232
|
-
} else if (typeof shadow === "string") {
|
|
855
|
+
if (typeof shadow === "string") {
|
|
233
856
|
return {
|
|
234
857
|
color: normalizeColor(shadow)
|
|
235
858
|
};
|
|
236
859
|
} else {
|
|
237
860
|
return {
|
|
238
861
|
...shadow,
|
|
239
|
-
color: normalizeColor(shadow.color)
|
|
862
|
+
color: isNone(shadow.color) ? defaultColor : normalizeColor(shadow.color)
|
|
240
863
|
};
|
|
241
864
|
}
|
|
242
865
|
}
|
|
@@ -246,6 +869,29 @@ function getDefaultShadowStyle() {
|
|
|
246
869
|
};
|
|
247
870
|
}
|
|
248
871
|
|
|
872
|
+
function normalizeShape(shape) {
|
|
873
|
+
if (typeof shape === "string") {
|
|
874
|
+
return {
|
|
875
|
+
paths: [
|
|
876
|
+
{ data: shape }
|
|
877
|
+
]
|
|
878
|
+
};
|
|
879
|
+
} else if (Array.isArray(shape)) {
|
|
880
|
+
return {
|
|
881
|
+
paths: shape.map((data) => {
|
|
882
|
+
if (typeof data === "string") {
|
|
883
|
+
return {
|
|
884
|
+
data
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
return data;
|
|
888
|
+
})
|
|
889
|
+
};
|
|
890
|
+
} else {
|
|
891
|
+
return shape;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
249
895
|
function getDefaultLayoutStyle() {
|
|
250
896
|
return {
|
|
251
897
|
// box
|
|
@@ -406,16 +1052,13 @@ function getDefaultTextStyle() {
|
|
|
406
1052
|
}
|
|
407
1053
|
|
|
408
1054
|
function normalizeStyle(style) {
|
|
409
|
-
if (!style || style === "none") {
|
|
410
|
-
return void 0;
|
|
411
|
-
}
|
|
412
1055
|
return clearUndef({
|
|
413
1056
|
...style,
|
|
414
|
-
color: normalizeColor(style.color),
|
|
415
|
-
backgroundColor: normalizeColor(style.backgroundColor),
|
|
416
|
-
borderColor: normalizeColor(style.borderColor),
|
|
417
|
-
outlineColor: normalizeColor(style.outlineColor),
|
|
418
|
-
shadowColor: normalizeColor(style.shadowColor)
|
|
1057
|
+
color: isNone(style.color) ? void 0 : normalizeColor(style.color),
|
|
1058
|
+
backgroundColor: isNone(style.backgroundColor) ? void 0 : normalizeColor(style.backgroundColor),
|
|
1059
|
+
borderColor: isNone(style.borderColor) ? void 0 : normalizeColor(style.borderColor),
|
|
1060
|
+
outlineColor: isNone(style.outlineColor) ? void 0 : normalizeColor(style.outlineColor),
|
|
1061
|
+
shadowColor: isNone(style.shadowColor) ? void 0 : normalizeColor(style.shadowColor)
|
|
419
1062
|
});
|
|
420
1063
|
}
|
|
421
1064
|
function getDefaultStyle() {
|
|
@@ -465,9 +1108,7 @@ function normalizeTextContent(content = "") {
|
|
|
465
1108
|
});
|
|
466
1109
|
}
|
|
467
1110
|
function normalizeText(text) {
|
|
468
|
-
if (
|
|
469
|
-
return void 0;
|
|
470
|
-
} else if (typeof text === "string") {
|
|
1111
|
+
if (typeof text === "string") {
|
|
471
1112
|
return {
|
|
472
1113
|
content: [
|
|
473
1114
|
{
|
|
@@ -490,9 +1131,7 @@ function normalizeText(text) {
|
|
|
490
1131
|
}
|
|
491
1132
|
|
|
492
1133
|
function normalizeVideo(video) {
|
|
493
|
-
if (
|
|
494
|
-
return void 0;
|
|
495
|
-
} else if (typeof video === "string") {
|
|
1134
|
+
if (typeof video === "string") {
|
|
496
1135
|
return { src: video };
|
|
497
1136
|
} else {
|
|
498
1137
|
return video;
|
|
@@ -502,17 +1141,17 @@ function normalizeVideo(video) {
|
|
|
502
1141
|
function normalizeElement(element) {
|
|
503
1142
|
return clearUndef({
|
|
504
1143
|
...element,
|
|
505
|
-
style: normalizeStyle(element.style),
|
|
506
|
-
text: normalizeText(element.text),
|
|
507
|
-
background: normalizeBackground(element.background),
|
|
508
|
-
|
|
509
|
-
fill: normalizeFill(element.fill),
|
|
510
|
-
outline: normalizeOutline(element.outline),
|
|
511
|
-
foreground: normalizeForeground(element.foreground),
|
|
512
|
-
shadow: normalizeShadow(element.shadow),
|
|
513
|
-
video: normalizeVideo(element.video),
|
|
514
|
-
audio: normalizeAudio(element.audio),
|
|
515
|
-
effect: normalizeEffect(element.effect),
|
|
1144
|
+
style: isNone(element.style) ? void 0 : normalizeStyle(element.style),
|
|
1145
|
+
text: isNone(element.text) ? void 0 : normalizeText(element.text),
|
|
1146
|
+
background: isNone(element.background) ? void 0 : normalizeBackground(element.background),
|
|
1147
|
+
shape: isNone(element.shape) ? void 0 : normalizeShape(element.shape),
|
|
1148
|
+
fill: isNone(element.fill) ? void 0 : normalizeFill(element.fill),
|
|
1149
|
+
outline: isNone(element.outline) ? void 0 : normalizeOutline(element.outline),
|
|
1150
|
+
foreground: isNone(element.foreground) ? void 0 : normalizeForeground(element.foreground),
|
|
1151
|
+
shadow: isNone(element.shadow) ? void 0 : normalizeShadow(element.shadow),
|
|
1152
|
+
video: isNone(element.video) ? void 0 : normalizeVideo(element.video),
|
|
1153
|
+
audio: isNone(element.audio) ? void 0 : normalizeAudio(element.audio),
|
|
1154
|
+
effect: isNone(element.effect) ? void 0 : normalizeEffect(element.effect),
|
|
516
1155
|
children: element.children?.map((child) => normalizeElement(child))
|
|
517
1156
|
});
|
|
518
1157
|
}
|
|
@@ -521,4 +1160,4 @@ function normalizeDocument(doc) {
|
|
|
521
1160
|
return normalizeElement(doc);
|
|
522
1161
|
}
|
|
523
1162
|
|
|
524
|
-
export { clearUndef, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeAudio, normalizeBackground, normalizeColor, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground,
|
|
1163
|
+
export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, isColor, isGradient, isNone, normalizeAudio, normalizeBackground, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, round, stringifyGradient };
|