@tbela99/css-parser 1.4.2 → 1.4.4
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/CHANGELOG.md +354 -4
- package/README.md +69 -1077
- package/dist/config.json.js +76 -3
- package/dist/index-umd-web.js +26838 -18743
- package/dist/index.cjs +26819 -18731
- package/dist/index.d.ts +2471 -1884
- package/dist/lib/ast/clone.js +46 -0
- package/dist/lib/ast/expand.js +90 -65
- package/dist/lib/ast/features/calc.js +86 -43
- package/dist/lib/ast/features/if.js +221 -0
- package/dist/lib/ast/features/index.js +1 -0
- package/dist/lib/ast/features/inlinecssvariables.js +33 -28
- package/dist/lib/ast/features/prefix.js +406 -44
- package/dist/lib/ast/features/shorthand.js +6 -9
- package/dist/lib/ast/features/transform.js +14 -15
- package/dist/lib/ast/find.js +175 -0
- package/dist/lib/ast/math/expression.js +145 -99
- package/dist/lib/ast/math/math.js +30 -41
- package/dist/lib/ast/minify.js +551 -232
- package/dist/lib/ast/transform/compute.js +82 -69
- package/dist/lib/ast/transform/matrix.js +12 -26
- package/dist/lib/ast/transform/minify.js +154 -150
- package/dist/lib/ast/transform/perspective.js +1 -1
- package/dist/lib/ast/transform/rotate.js +1 -1
- package/dist/lib/ast/transform/scale.js +1 -1
- package/dist/lib/ast/transform/skew.js +1 -1
- package/dist/lib/ast/transform/translate.js +1 -1
- package/dist/lib/ast/transform/utils.js +3 -2
- package/dist/lib/ast/types.js +345 -30
- package/dist/lib/ast/walk.js +119 -64
- package/dist/lib/fs/resolve.js +94 -88
- package/dist/lib/parser/declaration/list.js +117 -26
- package/dist/lib/parser/declaration/map.js +141 -96
- package/dist/lib/parser/declaration/set.js +30 -25
- package/dist/lib/parser/parse.js +1810 -1739
- package/dist/lib/parser/tokenize.js +662 -403
- package/dist/lib/parser/utils/angle.js +29 -0
- package/dist/lib/parser/utils/at-rule-container.js +486 -0
- package/dist/lib/parser/utils/at-rule-font-feature-values.js +13 -0
- package/dist/lib/parser/utils/at-rule-generic.js +118 -0
- package/dist/lib/parser/utils/at-rule-import.js +393 -0
- package/dist/lib/parser/utils/at-rule-media.js +603 -0
- package/dist/lib/parser/utils/at-rule-support.js +431 -0
- package/dist/lib/parser/utils/at-rule-when-else.js +363 -0
- package/dist/lib/parser/utils/at-rule.js +31 -0
- package/dist/lib/parser/utils/cache.js +19 -0
- package/dist/lib/parser/utils/config.js +1 -0
- package/dist/lib/parser/utils/declaration.js +672 -91
- package/dist/lib/parser/utils/hash.js +1 -1
- package/dist/lib/parser/utils/selector.js +518 -0
- package/dist/lib/parser/utils/text.js +17 -1
- package/dist/lib/parser/utils/token.js +104 -0
- package/dist/lib/parser/utils/type.js +29 -18
- package/dist/lib/renderer/render.js +870 -269
- package/dist/lib/renderer/sourcemap/sourcemap.js +17 -7
- package/dist/lib/syntax/color/a98rgb.js +8 -12
- package/dist/lib/syntax/color/alpha.js +64 -0
- package/dist/lib/syntax/color/cmyk.js +23 -21
- package/dist/lib/syntax/color/color-mix.js +311 -237
- package/dist/lib/syntax/color/color.js +98 -92
- package/dist/lib/syntax/color/hex.js +29 -33
- package/dist/lib/syntax/color/hsl.js +7 -14
- package/dist/lib/syntax/color/hwb.js +14 -27
- package/dist/lib/syntax/color/lab.js +23 -24
- package/dist/lib/syntax/color/lch.js +16 -18
- package/dist/lib/syntax/color/oklab.js +21 -40
- package/dist/lib/syntax/color/oklch.js +16 -18
- package/dist/lib/syntax/color/p3.js +0 -8
- package/dist/lib/syntax/color/rec2020.js +9 -13
- package/dist/lib/syntax/color/relativecolor.js +160 -48
- package/dist/lib/syntax/color/rgb.js +14 -18
- package/dist/lib/syntax/color/srgb.js +30 -29
- package/dist/lib/syntax/color/utils/color-type.js +18 -0
- package/dist/lib/syntax/color/utils/colorspace.js +46 -0
- package/dist/lib/syntax/color/utils/components.js +36 -16
- package/dist/lib/syntax/color/utils/distance.js +21 -11
- package/dist/lib/syntax/color/utils/make-color.js +56 -0
- package/dist/lib/syntax/color/xyz.js +10 -22
- package/dist/lib/syntax/color/xyzd50.js +6 -20
- package/dist/lib/syntax/constants.js +464 -0
- package/dist/lib/syntax/syntax.js +825 -592
- package/dist/lib/validation/config.js +72 -33
- package/dist/lib/validation/config.json.js +1185 -85
- package/dist/lib/validation/match.js +3120 -0
- package/dist/lib/validation/parser/parse.js +683 -935
- package/dist/lib/validation/parser/typedef.js +106 -0
- package/dist/lib/validation/utils/list.js +4 -11
- package/dist/lib/validation/utils/whitespace.js +2 -8
- package/dist/node.js +102 -57
- package/dist/web.js +100 -48
- package/package.json +31 -17
- package/dist/lib/syntax/color/utils/constants.js +0 -214
- package/dist/lib/syntax/utils.js +0 -70
- package/dist/lib/validation/at-rules/container.js +0 -342
- package/dist/lib/validation/at-rules/counter-style.js +0 -90
- package/dist/lib/validation/at-rules/custom-media.js +0 -50
- package/dist/lib/validation/at-rules/document.js +0 -89
- package/dist/lib/validation/at-rules/else.js +0 -5
- package/dist/lib/validation/at-rules/font-feature-values.js +0 -63
- package/dist/lib/validation/at-rules/import.js +0 -150
- package/dist/lib/validation/at-rules/keyframes.js +0 -67
- package/dist/lib/validation/at-rules/layer.js +0 -41
- package/dist/lib/validation/at-rules/media.js +0 -255
- package/dist/lib/validation/at-rules/namespace.js +0 -81
- package/dist/lib/validation/at-rules/page-margin-box.js +0 -64
- package/dist/lib/validation/at-rules/page.js +0 -100
- package/dist/lib/validation/at-rules/supports.js +0 -295
- package/dist/lib/validation/at-rules/when.js +0 -185
- package/dist/lib/validation/atrule.js +0 -184
- package/dist/lib/validation/selector.js +0 -36
- package/dist/lib/validation/syntax.js +0 -1073
- package/dist/lib/validation/syntaxes/complex-selector-list.js +0 -27
- package/dist/lib/validation/syntaxes/complex-selector.js +0 -52
- package/dist/lib/validation/syntaxes/compound-selector.js +0 -196
- package/dist/lib/validation/syntaxes/family-name.js +0 -57
- package/dist/lib/validation/syntaxes/keyframe-selector.js +0 -36
- package/dist/lib/validation/syntaxes/layer-name.js +0 -57
- package/dist/lib/validation/syntaxes/relative-selector-list.js +0 -31
- package/dist/lib/validation/syntaxes/relative-selector.js +0 -38
- package/dist/lib/validation/syntaxes/selector-list.js +0 -5
- package/dist/lib/validation/syntaxes/selector.js +0 -5
- package/dist/lib/validation/syntaxes/url.js +0 -40
package/dist/lib/ast/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Syntax validation enum
|
|
3
3
|
*/
|
|
4
4
|
var SyntaxValidationResult;
|
|
5
5
|
(function (SyntaxValidationResult) {
|
|
@@ -11,7 +11,46 @@ var SyntaxValidationResult;
|
|
|
11
11
|
SyntaxValidationResult[SyntaxValidationResult["Lenient"] = 2] = "Lenient";
|
|
12
12
|
})(SyntaxValidationResult || (SyntaxValidationResult = {}));
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Enum of node statuses
|
|
15
|
+
*/
|
|
16
|
+
var EnumAstNodeStatus;
|
|
17
|
+
(function (EnumAstNodeStatus) {
|
|
18
|
+
/**
|
|
19
|
+
* Node passed validation
|
|
20
|
+
*/
|
|
21
|
+
EnumAstNodeStatus[EnumAstNodeStatus["Validated"] = 0] = "Validated";
|
|
22
|
+
/**
|
|
23
|
+
* Node is invalid
|
|
24
|
+
*/
|
|
25
|
+
EnumAstNodeStatus[EnumAstNodeStatus["Invalid"] = 1] = "Invalid";
|
|
26
|
+
/**
|
|
27
|
+
* node is not validated
|
|
28
|
+
*/
|
|
29
|
+
EnumAstNodeStatus[EnumAstNodeStatus["Unvalidated"] = 2] = "Unvalidated";
|
|
30
|
+
/**
|
|
31
|
+
* Node did not pass validation, but is preserved.
|
|
32
|
+
*/
|
|
33
|
+
EnumAstNodeStatus[EnumAstNodeStatus["ValidationFailed"] = 3] = "ValidationFailed";
|
|
34
|
+
/**
|
|
35
|
+
* Parsing the node is not supported yet or the node syntax definition does not exist.
|
|
36
|
+
*/
|
|
37
|
+
EnumAstNodeStatus[EnumAstNodeStatus["Unknown"] = 4] = "Unknown";
|
|
38
|
+
/**
|
|
39
|
+
* Failed to parse the node.
|
|
40
|
+
*/
|
|
41
|
+
EnumAstNodeStatus[EnumAstNodeStatus["Unparsed"] = 5] = "Unparsed";
|
|
42
|
+
/**
|
|
43
|
+
* Node is disallowed in the context
|
|
44
|
+
*/
|
|
45
|
+
EnumAstNodeStatus[EnumAstNodeStatus["Disallowed"] = 6] = "Disallowed";
|
|
46
|
+
/**
|
|
47
|
+
* Node is malformed
|
|
48
|
+
*/
|
|
49
|
+
EnumAstNodeStatus[EnumAstNodeStatus["Malformed"] = 7] = "Malformed";
|
|
50
|
+
})(EnumAstNodeStatus || (EnumAstNodeStatus = {}));
|
|
51
|
+
/**
|
|
52
|
+
* Enum of validation levels
|
|
53
|
+
* @deprecated
|
|
15
54
|
*/
|
|
16
55
|
var ValidationLevel;
|
|
17
56
|
(function (ValidationLevel) {
|
|
@@ -38,10 +77,14 @@ var ValidationLevel;
|
|
|
38
77
|
/**
|
|
39
78
|
* validate selectors, at-rules and declarations
|
|
40
79
|
*/
|
|
41
|
-
ValidationLevel[ValidationLevel["All"] = 7] = "All";
|
|
80
|
+
ValidationLevel[ValidationLevel["All"] = 7] = "All";
|
|
81
|
+
/**
|
|
82
|
+
* Report only. Apply validation and report nodes that are marked as invalid
|
|
83
|
+
*/
|
|
84
|
+
ValidationLevel[ValidationLevel["ReportOnly"] = 8] = "ReportOnly";
|
|
42
85
|
})(ValidationLevel || (ValidationLevel = {}));
|
|
43
86
|
/**
|
|
44
|
-
*
|
|
87
|
+
* Enum of all token types
|
|
45
88
|
*/
|
|
46
89
|
var EnumToken;
|
|
47
90
|
(function (EnumToken) {
|
|
@@ -372,9 +415,10 @@ var EnumToken;
|
|
|
372
415
|
*/
|
|
373
416
|
EnumToken[EnumToken["NestingSelectorTokenType"] = 80] = "NestingSelectorTokenType";
|
|
374
417
|
/**
|
|
375
|
-
*
|
|
418
|
+
* Invalid rule token type
|
|
419
|
+
* @deprecated
|
|
376
420
|
*/
|
|
377
|
-
EnumToken[EnumToken["
|
|
421
|
+
EnumToken[EnumToken["InvalidRuleNodeType"] = 81] = "InvalidRuleNodeType";
|
|
378
422
|
/**
|
|
379
423
|
* invalid class selector token type
|
|
380
424
|
*/
|
|
@@ -384,9 +428,10 @@ var EnumToken;
|
|
|
384
428
|
*/
|
|
385
429
|
EnumToken[EnumToken["InvalidAttrTokenType"] = 83] = "InvalidAttrTokenType";
|
|
386
430
|
/**
|
|
387
|
-
*
|
|
431
|
+
* Invalid at rule token type
|
|
432
|
+
* @deprecated
|
|
388
433
|
*/
|
|
389
|
-
EnumToken[EnumToken["
|
|
434
|
+
EnumToken[EnumToken["InvalidAtRuleNodeType"] = 84] = "InvalidAtRuleNodeType";
|
|
390
435
|
/**
|
|
391
436
|
* media query condition token type
|
|
392
437
|
*/
|
|
@@ -398,19 +443,19 @@ var EnumToken;
|
|
|
398
443
|
/**
|
|
399
444
|
* media feature only token type
|
|
400
445
|
*/
|
|
401
|
-
EnumToken[EnumToken["
|
|
446
|
+
EnumToken[EnumToken["OnlyTokenType"] = 87] = "OnlyTokenType";
|
|
402
447
|
/**
|
|
403
448
|
* media feature not token type
|
|
404
449
|
*/
|
|
405
|
-
EnumToken[EnumToken["
|
|
450
|
+
EnumToken[EnumToken["NotTokenType"] = 88] = "NotTokenType";
|
|
406
451
|
/**
|
|
407
452
|
* media feature and token type
|
|
408
453
|
*/
|
|
409
|
-
EnumToken[EnumToken["
|
|
454
|
+
EnumToken[EnumToken["AndTokenType"] = 89] = "AndTokenType";
|
|
410
455
|
/**
|
|
411
456
|
* media feature or token type
|
|
412
457
|
*/
|
|
413
|
-
EnumToken[EnumToken["
|
|
458
|
+
EnumToken[EnumToken["OrTokenType"] = 90] = "OrTokenType";
|
|
414
459
|
/**
|
|
415
460
|
* pseudo page token type
|
|
416
461
|
*/
|
|
@@ -424,7 +469,8 @@ var EnumToken;
|
|
|
424
469
|
*/
|
|
425
470
|
EnumToken[EnumToken["KeyframesAtRuleNodeType"] = 93] = "KeyframesAtRuleNodeType";
|
|
426
471
|
/**
|
|
427
|
-
* invalid declaration node type
|
|
472
|
+
* invalid declaration node type.
|
|
473
|
+
* @deprecated
|
|
428
474
|
*/
|
|
429
475
|
EnumToken[EnumToken["InvalidDeclarationNodeType"] = 94] = "InvalidDeclarationNodeType";
|
|
430
476
|
/* css module nodes */
|
|
@@ -444,6 +490,172 @@ var EnumToken;
|
|
|
444
490
|
* css variable declaration map token type
|
|
445
491
|
*/
|
|
446
492
|
EnumToken[EnumToken["CssVariableDeclarationMapTokenType"] = 98] = "CssVariableDeclarationMapTokenType";
|
|
493
|
+
/**
|
|
494
|
+
* media range query token type
|
|
495
|
+
*/
|
|
496
|
+
EnumToken[EnumToken["MediaRangeQueryTokenType"] = 99] = "MediaRangeQueryTokenType";
|
|
497
|
+
/**
|
|
498
|
+
* invalid media query token type
|
|
499
|
+
*/
|
|
500
|
+
EnumToken[EnumToken["InvalidMediaQueryTokenType"] = 100] = "InvalidMediaQueryTokenType";
|
|
501
|
+
/**
|
|
502
|
+
* supports query condition token type
|
|
503
|
+
*/
|
|
504
|
+
EnumToken[EnumToken["SupportsQueryConditionTokenType"] = 101] = "SupportsQueryConditionTokenType";
|
|
505
|
+
/**
|
|
506
|
+
* supports query unary condition token type
|
|
507
|
+
*/
|
|
508
|
+
EnumToken[EnumToken["SupportsQueryUnaryConditionTokenType"] = 102] = "SupportsQueryUnaryConditionTokenType";
|
|
509
|
+
/**
|
|
510
|
+
* when else query condition token type
|
|
511
|
+
*/
|
|
512
|
+
EnumToken[EnumToken["WhenElseQueryConditionTokenType"] = 103] = "WhenElseQueryConditionTokenType";
|
|
513
|
+
/**
|
|
514
|
+
* when else query unary condition token type
|
|
515
|
+
*/
|
|
516
|
+
EnumToken[EnumToken["WhenElseUnaryConditionTokenType"] = 104] = "WhenElseUnaryConditionTokenType";
|
|
517
|
+
/**
|
|
518
|
+
* container style range token type
|
|
519
|
+
*/
|
|
520
|
+
EnumToken[EnumToken["ContainerStyleRangeTokenType"] = 105] = "ContainerStyleRangeTokenType";
|
|
521
|
+
/**
|
|
522
|
+
* '*'
|
|
523
|
+
*/
|
|
524
|
+
EnumToken[EnumToken["Star"] = 106] = "Star";
|
|
525
|
+
/**
|
|
526
|
+
* '+'
|
|
527
|
+
*/
|
|
528
|
+
EnumToken[EnumToken["Plus"] = 107] = "Plus";
|
|
529
|
+
/**
|
|
530
|
+
* '~'
|
|
531
|
+
*/
|
|
532
|
+
EnumToken[EnumToken["Tilda"] = 108] = "Tilda";
|
|
533
|
+
/**
|
|
534
|
+
* '|'
|
|
535
|
+
*/
|
|
536
|
+
EnumToken[EnumToken["Pipe"] = 109] = "Pipe";
|
|
537
|
+
/**
|
|
538
|
+
* '::'
|
|
539
|
+
*/
|
|
540
|
+
EnumToken[EnumToken["DoubleColonTokenType"] = 110] = "DoubleColonTokenType";
|
|
541
|
+
/**
|
|
542
|
+
* math function token type such as'calc(' etc.
|
|
543
|
+
*/
|
|
544
|
+
EnumToken[EnumToken["MathFunctionTokenType"] = 111] = "MathFunctionTokenType";
|
|
545
|
+
/**
|
|
546
|
+
* transform function token type such as 'translate(' etc.
|
|
547
|
+
*/
|
|
548
|
+
EnumToken[EnumToken["TransformFunctionTokenType"] = 112] = "TransformFunctionTokenType";
|
|
549
|
+
/**
|
|
550
|
+
* when function token type such as 'supports(' etc.
|
|
551
|
+
*/
|
|
552
|
+
EnumToken[EnumToken["WhenElseFunctionTokenType"] = 113] = "WhenElseFunctionTokenType";
|
|
553
|
+
/**
|
|
554
|
+
* general enclosed function token type 'font-tech(' etc.
|
|
555
|
+
*/
|
|
556
|
+
EnumToken[EnumToken["GeneralEnclosedFunctionTokenType"] = 114] = "GeneralEnclosedFunctionTokenType";
|
|
557
|
+
/**
|
|
558
|
+
* supports function token type such as 'at-rule('
|
|
559
|
+
*/
|
|
560
|
+
EnumToken[EnumToken["SupportsFunctionTokenType"] = 115] = "SupportsFunctionTokenType";
|
|
561
|
+
/**
|
|
562
|
+
* container function token type such as 'style(' or 'scroll-state('
|
|
563
|
+
*/
|
|
564
|
+
EnumToken[EnumToken["ContainerFunctionTokenType"] = 116] = "ContainerFunctionTokenType";
|
|
565
|
+
/**
|
|
566
|
+
* unrecognized node token type
|
|
567
|
+
*/
|
|
568
|
+
EnumToken[EnumToken["RawNodeTokenType"] = 117] = "RawNodeTokenType";
|
|
569
|
+
/**
|
|
570
|
+
* media query boolean token type
|
|
571
|
+
* @media not ()
|
|
572
|
+
* @media only ()
|
|
573
|
+
*/
|
|
574
|
+
EnumToken[EnumToken["MediaQueryUnaryFeatureTokenType"] = 118] = "MediaQueryUnaryFeatureTokenType";
|
|
575
|
+
/**
|
|
576
|
+
* grid template function token type such as 'minmax('
|
|
577
|
+
*/
|
|
578
|
+
EnumToken[EnumToken["GridTemplateFuncTokenDefType"] = 119] = "GridTemplateFuncTokenDefType";
|
|
579
|
+
/**
|
|
580
|
+
* image function token type such as 'image(' etc.
|
|
581
|
+
*/
|
|
582
|
+
EnumToken[EnumToken["ImageFunctionTokenDefType"] = 120] = "ImageFunctionTokenDefType";
|
|
583
|
+
/**
|
|
584
|
+
* function token type such as 'view(' etc.
|
|
585
|
+
*/
|
|
586
|
+
EnumToken[EnumToken["TimelineFunctionTokenDefType"] = 121] = "TimelineFunctionTokenDefType";
|
|
587
|
+
/**
|
|
588
|
+
* function token type
|
|
589
|
+
*/
|
|
590
|
+
EnumToken[EnumToken["FunctionTokenDefType"] = 122] = "FunctionTokenDefType";
|
|
591
|
+
/**
|
|
592
|
+
* timing function token type such as 'linear(' etc.
|
|
593
|
+
*/
|
|
594
|
+
EnumToken[EnumToken["TimingFunctionTokenDefType"] = 123] = "TimingFunctionTokenDefType";
|
|
595
|
+
/**
|
|
596
|
+
* color function token type such as 'rgb(' etc.
|
|
597
|
+
*/
|
|
598
|
+
EnumToken[EnumToken["ColorFunctionTokenDefType"] = 124] = "ColorFunctionTokenDefType";
|
|
599
|
+
/**
|
|
600
|
+
* math function token type such as 'calc(' etc.
|
|
601
|
+
*/
|
|
602
|
+
EnumToken[EnumToken["MathFunctionTokenDefType"] = 125] = "MathFunctionTokenDefType";
|
|
603
|
+
/**
|
|
604
|
+
* container function token type such as 'style(' or 'scroll-state('
|
|
605
|
+
*/
|
|
606
|
+
EnumToken[EnumToken["ContainerFunctionTokenDefType"] = 126] = "ContainerFunctionTokenDefType";
|
|
607
|
+
/**
|
|
608
|
+
* url function token type 'url('
|
|
609
|
+
*/
|
|
610
|
+
EnumToken[EnumToken["UrlFunctionTokenDefType"] = 127] = "UrlFunctionTokenDefType";
|
|
611
|
+
/**
|
|
612
|
+
* pseudo-class function token type
|
|
613
|
+
*/
|
|
614
|
+
EnumToken[EnumToken["PseudoClassFunctionTokenDefType"] = 128] = "PseudoClassFunctionTokenDefType";
|
|
615
|
+
/**
|
|
616
|
+
* transform function token type such as 'translate(' etc.
|
|
617
|
+
*/
|
|
618
|
+
EnumToken[EnumToken["TransformFunctionTokenDefType"] = 129] = "TransformFunctionTokenDefType";
|
|
619
|
+
/**
|
|
620
|
+
* when function token type such as 'supports(' or 'media('
|
|
621
|
+
*/
|
|
622
|
+
EnumToken[EnumToken["WhenElseFunctionTokenDefType"] = 130] = "WhenElseFunctionTokenDefType";
|
|
623
|
+
/**
|
|
624
|
+
* general enclosed function token type 'font-tech(' etc.
|
|
625
|
+
*/
|
|
626
|
+
EnumToken[EnumToken["GeneralEnclosedFunctionTokenDefType"] = 131] = "GeneralEnclosedFunctionTokenDefType";
|
|
627
|
+
/**
|
|
628
|
+
* supports function token type 'font-tech('
|
|
629
|
+
*/
|
|
630
|
+
EnumToken[EnumToken["SupportsFunctionTokenDefType"] = 132] = "SupportsFunctionTokenDefType";
|
|
631
|
+
/**
|
|
632
|
+
* CDOCOMMTokenType not allowed in this context
|
|
633
|
+
*/
|
|
634
|
+
EnumToken[EnumToken["InvalidCommentTokenType"] = 133] = "InvalidCommentTokenType";
|
|
635
|
+
/**
|
|
636
|
+
* custom function token type '--function-name('
|
|
637
|
+
*/
|
|
638
|
+
EnumToken[EnumToken["CustomFunctionTokenDefType"] = 134] = "CustomFunctionTokenDefType";
|
|
639
|
+
/**
|
|
640
|
+
* custom function token type
|
|
641
|
+
*/
|
|
642
|
+
EnumToken[EnumToken["CustomFunctionTokenType"] = 135] = "CustomFunctionTokenType";
|
|
643
|
+
/**
|
|
644
|
+
* function tokens such as 'var(', 'env(', 'if(')
|
|
645
|
+
*/
|
|
646
|
+
EnumToken[EnumToken["WildCardFunctionTokenDefType"] = 136] = "WildCardFunctionTokenDefType";
|
|
647
|
+
/**
|
|
648
|
+
* function such as 'var()', 'env()', 'if()'
|
|
649
|
+
*/
|
|
650
|
+
EnumToken[EnumToken["WildCardFunctionTokenType"] = 137] = "WildCardFunctionTokenType";
|
|
651
|
+
/**
|
|
652
|
+
* if condition token
|
|
653
|
+
*/
|
|
654
|
+
EnumToken[EnumToken["IfConditionTokenType"] = 138] = "IfConditionTokenType";
|
|
655
|
+
/**
|
|
656
|
+
* if-Else condition token
|
|
657
|
+
*/
|
|
658
|
+
EnumToken[EnumToken["IfElseConditionTokenType"] = 139] = "IfElseConditionTokenType";
|
|
447
659
|
/* aliases */
|
|
448
660
|
/**
|
|
449
661
|
* alias for time token type
|
|
@@ -555,7 +767,7 @@ var EnumToken;
|
|
|
555
767
|
EnumToken[EnumToken["TimelineFunction"] = 16] = "TimelineFunction";
|
|
556
768
|
})(EnumToken || (EnumToken = {}));
|
|
557
769
|
/**
|
|
558
|
-
*
|
|
770
|
+
* Supported color types enum
|
|
559
771
|
*/
|
|
560
772
|
var ColorType;
|
|
561
773
|
(function (ColorType) {
|
|
@@ -580,31 +792,31 @@ var ColorType;
|
|
|
580
792
|
*/
|
|
581
793
|
ColorType[ColorType["RGBA"] = 4] = "RGBA";
|
|
582
794
|
/**
|
|
583
|
-
* colors
|
|
795
|
+
* colors using rgb
|
|
584
796
|
*/
|
|
585
797
|
ColorType[ColorType["HSLA"] = 5] = "HSLA";
|
|
586
798
|
/**
|
|
587
|
-
* colors
|
|
799
|
+
* colors using hwb
|
|
588
800
|
*/
|
|
589
801
|
ColorType[ColorType["HWB"] = 6] = "HWB";
|
|
590
802
|
/**
|
|
591
|
-
* colors
|
|
803
|
+
* colors using cmyk
|
|
592
804
|
*/
|
|
593
805
|
ColorType[ColorType["CMYK"] = 7] = "CMYK";
|
|
594
806
|
/**
|
|
595
|
-
* colors
|
|
807
|
+
* colors using oklab
|
|
596
808
|
* */
|
|
597
809
|
ColorType[ColorType["OKLAB"] = 8] = "OKLAB";
|
|
598
810
|
/**
|
|
599
|
-
* colors
|
|
811
|
+
* colors using oklch
|
|
600
812
|
* */
|
|
601
813
|
ColorType[ColorType["OKLCH"] = 9] = "OKLCH";
|
|
602
814
|
/**
|
|
603
|
-
* colors
|
|
815
|
+
* colors using lab
|
|
604
816
|
*/
|
|
605
817
|
ColorType[ColorType["LAB"] = 10] = "LAB";
|
|
606
818
|
/**
|
|
607
|
-
* colors
|
|
819
|
+
* colors using lch
|
|
608
820
|
*/
|
|
609
821
|
ColorType[ColorType["LCH"] = 11] = "LCH";
|
|
610
822
|
/**
|
|
@@ -612,35 +824,35 @@ var ColorType;
|
|
|
612
824
|
*/
|
|
613
825
|
ColorType[ColorType["COLOR"] = 12] = "COLOR";
|
|
614
826
|
/**
|
|
615
|
-
* color using srgb
|
|
827
|
+
* color using srgb
|
|
616
828
|
*/
|
|
617
829
|
ColorType[ColorType["SRGB"] = 13] = "SRGB";
|
|
618
830
|
/**
|
|
619
|
-
* color using prophoto-rgb
|
|
831
|
+
* color using prophoto-rgb
|
|
620
832
|
*/
|
|
621
833
|
ColorType[ColorType["PROPHOTO_RGB"] = 14] = "PROPHOTO_RGB";
|
|
622
834
|
/**
|
|
623
|
-
* color using a98-rgb
|
|
835
|
+
* color using a98-rgb
|
|
624
836
|
*/
|
|
625
837
|
ColorType[ColorType["A98_RGB"] = 15] = "A98_RGB";
|
|
626
838
|
/**
|
|
627
|
-
* color using rec2020
|
|
839
|
+
* color using rec2020
|
|
628
840
|
*/
|
|
629
841
|
ColorType[ColorType["REC2020"] = 16] = "REC2020";
|
|
630
842
|
/**
|
|
631
|
-
* color using display-p3
|
|
843
|
+
* color using display-p3
|
|
632
844
|
*/
|
|
633
845
|
ColorType[ColorType["DISPLAY_P3"] = 17] = "DISPLAY_P3";
|
|
634
846
|
/**
|
|
635
|
-
* color using srgb-linear
|
|
847
|
+
* color using srgb-linear
|
|
636
848
|
*/
|
|
637
849
|
ColorType[ColorType["SRGB_LINEAR"] = 18] = "SRGB_LINEAR";
|
|
638
850
|
/**
|
|
639
|
-
* color using xyz-d50
|
|
851
|
+
* color using xyz-d50
|
|
640
852
|
*/
|
|
641
853
|
ColorType[ColorType["XYZ_D50"] = 19] = "XYZ_D50";
|
|
642
854
|
/**
|
|
643
|
-
* color using xyz-d65
|
|
855
|
+
* color using xyz-d65
|
|
644
856
|
*/
|
|
645
857
|
ColorType[ColorType["XYZ_D65"] = 20] = "XYZ_D65";
|
|
646
858
|
/**
|
|
@@ -651,6 +863,18 @@ var ColorType;
|
|
|
651
863
|
* color-mix() color function
|
|
652
864
|
*/
|
|
653
865
|
ColorType[ColorType["COLOR_MIX"] = 22] = "COLOR_MIX";
|
|
866
|
+
/**
|
|
867
|
+
* non-standard color
|
|
868
|
+
*/
|
|
869
|
+
ColorType[ColorType["NON_STD"] = 23] = "NON_STD";
|
|
870
|
+
/**
|
|
871
|
+
* custom color
|
|
872
|
+
*/
|
|
873
|
+
ColorType[ColorType["CUSTOM_COLOR"] = 24] = "CUSTOM_COLOR";
|
|
874
|
+
/**
|
|
875
|
+
* alpha() color function
|
|
876
|
+
*/
|
|
877
|
+
ColorType[ColorType["ALPHA"] = 25] = "ALPHA";
|
|
654
878
|
/**
|
|
655
879
|
* alias for rgba
|
|
656
880
|
*/
|
|
@@ -668,6 +892,9 @@ var ColorType;
|
|
|
668
892
|
*/
|
|
669
893
|
ColorType[ColorType["DEVICE_CMYK"] = 7] = "DEVICE_CMYK";
|
|
670
894
|
})(ColorType || (ColorType = {}));
|
|
895
|
+
/**
|
|
896
|
+
* Supported module case transform
|
|
897
|
+
*/
|
|
671
898
|
var ModuleCaseTransformEnum;
|
|
672
899
|
(function (ModuleCaseTransformEnum) {
|
|
673
900
|
/**
|
|
@@ -691,6 +918,9 @@ var ModuleCaseTransformEnum;
|
|
|
691
918
|
*/
|
|
692
919
|
ModuleCaseTransformEnum[ModuleCaseTransformEnum["DashCaseOnly"] = 16] = "DashCaseOnly";
|
|
693
920
|
})(ModuleCaseTransformEnum || (ModuleCaseTransformEnum = {}));
|
|
921
|
+
/**
|
|
922
|
+
* Supported module scope
|
|
923
|
+
*/
|
|
694
924
|
var ModuleScopeEnumOptions;
|
|
695
925
|
(function (ModuleScopeEnumOptions) {
|
|
696
926
|
/**
|
|
@@ -709,6 +939,91 @@ var ModuleScopeEnumOptions;
|
|
|
709
939
|
* export using ICSS module format
|
|
710
940
|
*/
|
|
711
941
|
ModuleScopeEnumOptions[ModuleScopeEnumOptions["ICSS"] = 256] = "ICSS";
|
|
942
|
+
/**
|
|
943
|
+
* use the shortest name possible. pattern is ignored.
|
|
944
|
+
* it will produce names such as
|
|
945
|
+
*
|
|
946
|
+
* ```css
|
|
947
|
+
* .a {
|
|
948
|
+
* content: 'a';
|
|
949
|
+
* }
|
|
950
|
+
*
|
|
951
|
+
* .b {
|
|
952
|
+
* content: 'b';
|
|
953
|
+
* }
|
|
954
|
+
*
|
|
955
|
+
* .c {
|
|
956
|
+
* content: 'c';
|
|
957
|
+
* }
|
|
958
|
+
* ...
|
|
959
|
+
* ```
|
|
960
|
+
*/
|
|
961
|
+
ModuleScopeEnumOptions[ModuleScopeEnumOptions["Shortest"] = 512] = "Shortest";
|
|
712
962
|
})(ModuleScopeEnumOptions || (ModuleScopeEnumOptions = {}));
|
|
963
|
+
// https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Values_and_units#absolute_length_units
|
|
964
|
+
/**
|
|
965
|
+
* Convert length to px
|
|
966
|
+
* @param value
|
|
967
|
+
* @returns
|
|
968
|
+
*/
|
|
969
|
+
function length2Px(value) {
|
|
970
|
+
let result = null;
|
|
971
|
+
if (value.typ == EnumToken.NumberTokenType) {
|
|
972
|
+
result = +value.val;
|
|
973
|
+
}
|
|
974
|
+
else {
|
|
975
|
+
switch (value.unit) {
|
|
976
|
+
case "cm":
|
|
977
|
+
// @ts-ignore
|
|
978
|
+
result = value.val * 37.8;
|
|
979
|
+
break;
|
|
980
|
+
case "mm":
|
|
981
|
+
// @ts-ignore
|
|
982
|
+
result = value.val * 3.78;
|
|
983
|
+
break;
|
|
984
|
+
case "Q":
|
|
985
|
+
// @ts-ignore
|
|
986
|
+
result = (value.val * 37.8) / 40;
|
|
987
|
+
break;
|
|
988
|
+
case "in":
|
|
989
|
+
// @ts-ignore
|
|
990
|
+
result = value.val / 96;
|
|
991
|
+
break;
|
|
992
|
+
case "pc":
|
|
993
|
+
// @ts-ignore
|
|
994
|
+
result = value.val / 16;
|
|
995
|
+
break;
|
|
996
|
+
case "pt":
|
|
997
|
+
// @ts-ignore
|
|
998
|
+
result = (value.val * 4) / 3;
|
|
999
|
+
break;
|
|
1000
|
+
case "px":
|
|
1001
|
+
result = +value.val;
|
|
1002
|
+
break;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
return isNaN(result) ? null : result;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* minify number
|
|
1009
|
+
* @param val
|
|
1010
|
+
*/
|
|
1011
|
+
function minifyNumber(val) {
|
|
1012
|
+
val = String(val);
|
|
1013
|
+
if (val === "0") {
|
|
1014
|
+
return "0";
|
|
1015
|
+
}
|
|
1016
|
+
const chr = val.charAt(0);
|
|
1017
|
+
if (chr == "-") {
|
|
1018
|
+
const slice = val.slice(0, 2);
|
|
1019
|
+
if (slice == "-0") {
|
|
1020
|
+
return val.length == 2 ? "0" : "-" + val.slice(2);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
if (chr == "0") {
|
|
1024
|
+
return val.slice(1);
|
|
1025
|
+
}
|
|
1026
|
+
return val;
|
|
1027
|
+
}
|
|
713
1028
|
|
|
714
|
-
export { ColorType, EnumToken, ModuleCaseTransformEnum, ModuleScopeEnumOptions, SyntaxValidationResult, ValidationLevel };
|
|
1029
|
+
export { ColorType, EnumAstNodeStatus, EnumToken, ModuleCaseTransformEnum, ModuleScopeEnumOptions, SyntaxValidationResult, ValidationLevel, length2Px, minifyNumber };
|