@tbela99/css-parser 0.1.0 → 0.2.0
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/README.md +205 -2
- package/dist/config.json.js +386 -4
- package/dist/index-umd-web.js +1540 -665
- package/dist/index.cjs +1540 -665
- package/dist/index.d.ts +498 -692
- package/dist/lib/ast/expand.js +11 -11
- package/dist/lib/ast/features/calc.js +17 -48
- package/dist/lib/ast/features/inlinecssvariables.js +42 -27
- package/dist/lib/ast/features/shorthand.js +4 -3
- package/dist/lib/ast/features/utils/math.js +95 -0
- package/dist/lib/ast/minify.js +34 -29
- package/dist/lib/ast/types.js +91 -78
- package/dist/lib/ast/walk.js +18 -5
- package/dist/lib/iterable/set.js +48 -0
- package/dist/lib/iterable/weakmap.js +53 -0
- package/dist/lib/parser/declaration/list.js +3 -3
- package/dist/lib/parser/declaration/map.js +53 -5
- package/dist/lib/parser/declaration/set.js +2 -2
- package/dist/lib/parser/parse.js +561 -361
- package/dist/lib/parser/tokenize.js +42 -13
- package/dist/lib/parser/utils/type.js +7 -2
- package/dist/lib/renderer/render.js +88 -41
- package/dist/node/index.js +8 -12
- package/dist/web/index.js +8 -12
- package/package.json +7 -5
- /package/dist/lib/ast/{utiles → utils}/minifyfeature.js +0 -0
package/dist/index.cjs
CHANGED
|
@@ -2,91 +2,104 @@
|
|
|
2
2
|
|
|
3
3
|
var promises = require('fs/promises');
|
|
4
4
|
|
|
5
|
-
exports.NodeType = void 0;
|
|
6
|
-
(function (NodeType) {
|
|
7
|
-
NodeType[NodeType["CommentNodeType"] = 0] = "CommentNodeType";
|
|
8
|
-
NodeType[NodeType["CDOCOMMNodeType"] = 1] = "CDOCOMMNodeType";
|
|
9
|
-
NodeType[NodeType["StyleSheetNodeType"] = 2] = "StyleSheetNodeType";
|
|
10
|
-
NodeType[NodeType["AtRuleNodeType"] = 3] = "AtRuleNodeType";
|
|
11
|
-
NodeType[NodeType["RuleNodeType"] = 4] = "RuleNodeType";
|
|
12
|
-
NodeType[NodeType["DeclarationNodeType"] = 5] = "DeclarationNodeType";
|
|
13
|
-
})(exports.NodeType || (exports.NodeType = {}));
|
|
14
5
|
exports.EnumToken = void 0;
|
|
15
6
|
(function (EnumToken) {
|
|
16
7
|
EnumToken[EnumToken["CommentTokenType"] = 0] = "CommentTokenType";
|
|
17
8
|
EnumToken[EnumToken["CDOCOMMTokenType"] = 1] = "CDOCOMMTokenType";
|
|
18
|
-
EnumToken[EnumToken["
|
|
19
|
-
EnumToken[EnumToken["
|
|
20
|
-
EnumToken[EnumToken["
|
|
21
|
-
EnumToken[EnumToken["
|
|
22
|
-
EnumToken[EnumToken["
|
|
23
|
-
EnumToken[EnumToken["
|
|
24
|
-
EnumToken[EnumToken["
|
|
25
|
-
EnumToken[EnumToken["
|
|
26
|
-
EnumToken[EnumToken["
|
|
27
|
-
EnumToken[EnumToken["
|
|
28
|
-
EnumToken[EnumToken["
|
|
29
|
-
EnumToken[EnumToken["
|
|
30
|
-
EnumToken[EnumToken["
|
|
31
|
-
EnumToken[EnumToken["
|
|
32
|
-
EnumToken[EnumToken["
|
|
33
|
-
EnumToken[EnumToken["
|
|
34
|
-
EnumToken[EnumToken["
|
|
35
|
-
EnumToken[EnumToken["
|
|
36
|
-
EnumToken[EnumToken["
|
|
37
|
-
EnumToken[EnumToken["
|
|
38
|
-
EnumToken[EnumToken["
|
|
39
|
-
EnumToken[EnumToken["
|
|
40
|
-
EnumToken[EnumToken["
|
|
41
|
-
EnumToken[EnumToken["
|
|
42
|
-
EnumToken[EnumToken["
|
|
43
|
-
EnumToken[EnumToken["
|
|
44
|
-
EnumToken[EnumToken["
|
|
45
|
-
EnumToken[EnumToken["
|
|
46
|
-
EnumToken[EnumToken["
|
|
47
|
-
EnumToken[EnumToken["
|
|
48
|
-
EnumToken[EnumToken["
|
|
49
|
-
EnumToken[EnumToken["
|
|
50
|
-
EnumToken[EnumToken["
|
|
51
|
-
EnumToken[EnumToken["
|
|
52
|
-
EnumToken[EnumToken["
|
|
53
|
-
EnumToken[EnumToken["
|
|
54
|
-
EnumToken[EnumToken["
|
|
55
|
-
EnumToken[EnumToken["
|
|
56
|
-
EnumToken[EnumToken["
|
|
57
|
-
EnumToken[EnumToken["
|
|
58
|
-
EnumToken[EnumToken["
|
|
59
|
-
EnumToken[EnumToken["
|
|
60
|
-
EnumToken[EnumToken["
|
|
61
|
-
EnumToken[EnumToken["
|
|
62
|
-
EnumToken[EnumToken["
|
|
63
|
-
EnumToken[EnumToken["
|
|
64
|
-
EnumToken[EnumToken["
|
|
9
|
+
EnumToken[EnumToken["StyleSheetNodeType"] = 2] = "StyleSheetNodeType";
|
|
10
|
+
EnumToken[EnumToken["AtRuleNodeType"] = 3] = "AtRuleNodeType";
|
|
11
|
+
EnumToken[EnumToken["RuleNodeType"] = 4] = "RuleNodeType";
|
|
12
|
+
EnumToken[EnumToken["DeclarationNodeType"] = 5] = "DeclarationNodeType";
|
|
13
|
+
EnumToken[EnumToken["LiteralTokenType"] = 6] = "LiteralTokenType";
|
|
14
|
+
EnumToken[EnumToken["IdenTokenType"] = 7] = "IdenTokenType";
|
|
15
|
+
EnumToken[EnumToken["DashedIdenTokenType"] = 8] = "DashedIdenTokenType";
|
|
16
|
+
EnumToken[EnumToken["CommaTokenType"] = 9] = "CommaTokenType";
|
|
17
|
+
EnumToken[EnumToken["ColonTokenType"] = 10] = "ColonTokenType";
|
|
18
|
+
EnumToken[EnumToken["SemiColonTokenType"] = 11] = "SemiColonTokenType";
|
|
19
|
+
EnumToken[EnumToken["NumberTokenType"] = 12] = "NumberTokenType";
|
|
20
|
+
EnumToken[EnumToken["AtRuleTokenType"] = 13] = "AtRuleTokenType";
|
|
21
|
+
EnumToken[EnumToken["PercentageTokenType"] = 14] = "PercentageTokenType";
|
|
22
|
+
EnumToken[EnumToken["FunctionTokenType"] = 15] = "FunctionTokenType";
|
|
23
|
+
EnumToken[EnumToken["TimelineFunctionTokenType"] = 16] = "TimelineFunctionTokenType";
|
|
24
|
+
EnumToken[EnumToken["TimingFunctionTokenType"] = 17] = "TimingFunctionTokenType";
|
|
25
|
+
EnumToken[EnumToken["UrlFunctionTokenType"] = 18] = "UrlFunctionTokenType";
|
|
26
|
+
EnumToken[EnumToken["ImageFunctionTokenType"] = 19] = "ImageFunctionTokenType";
|
|
27
|
+
EnumToken[EnumToken["StringTokenType"] = 20] = "StringTokenType";
|
|
28
|
+
EnumToken[EnumToken["UnclosedStringTokenType"] = 21] = "UnclosedStringTokenType";
|
|
29
|
+
EnumToken[EnumToken["DimensionTokenType"] = 22] = "DimensionTokenType";
|
|
30
|
+
EnumToken[EnumToken["LengthTokenType"] = 23] = "LengthTokenType";
|
|
31
|
+
EnumToken[EnumToken["AngleTokenType"] = 24] = "AngleTokenType";
|
|
32
|
+
EnumToken[EnumToken["TimeTokenType"] = 25] = "TimeTokenType";
|
|
33
|
+
EnumToken[EnumToken["FrequencyTokenType"] = 26] = "FrequencyTokenType";
|
|
34
|
+
EnumToken[EnumToken["ResolutionTokenType"] = 27] = "ResolutionTokenType";
|
|
35
|
+
EnumToken[EnumToken["HashTokenType"] = 28] = "HashTokenType";
|
|
36
|
+
EnumToken[EnumToken["BlockStartTokenType"] = 29] = "BlockStartTokenType";
|
|
37
|
+
EnumToken[EnumToken["BlockEndTokenType"] = 30] = "BlockEndTokenType";
|
|
38
|
+
EnumToken[EnumToken["AttrStartTokenType"] = 31] = "AttrStartTokenType";
|
|
39
|
+
EnumToken[EnumToken["AttrEndTokenType"] = 32] = "AttrEndTokenType";
|
|
40
|
+
EnumToken[EnumToken["StartParensTokenType"] = 33] = "StartParensTokenType";
|
|
41
|
+
EnumToken[EnumToken["EndParensTokenType"] = 34] = "EndParensTokenType";
|
|
42
|
+
EnumToken[EnumToken["ParensTokenType"] = 35] = "ParensTokenType";
|
|
43
|
+
EnumToken[EnumToken["WhitespaceTokenType"] = 36] = "WhitespaceTokenType";
|
|
44
|
+
EnumToken[EnumToken["IncludeMatchTokenType"] = 37] = "IncludeMatchTokenType";
|
|
45
|
+
EnumToken[EnumToken["DashMatchTokenType"] = 38] = "DashMatchTokenType";
|
|
46
|
+
EnumToken[EnumToken["LtTokenType"] = 39] = "LtTokenType";
|
|
47
|
+
EnumToken[EnumToken["LteTokenType"] = 40] = "LteTokenType";
|
|
48
|
+
EnumToken[EnumToken["GtTokenType"] = 41] = "GtTokenType";
|
|
49
|
+
EnumToken[EnumToken["GteTokenType"] = 42] = "GteTokenType";
|
|
50
|
+
EnumToken[EnumToken["PseudoClassTokenType"] = 43] = "PseudoClassTokenType";
|
|
51
|
+
EnumToken[EnumToken["PseudoClassFuncTokenType"] = 44] = "PseudoClassFuncTokenType";
|
|
52
|
+
EnumToken[EnumToken["DelimTokenType"] = 45] = "DelimTokenType";
|
|
53
|
+
EnumToken[EnumToken["UrlTokenTokenType"] = 46] = "UrlTokenTokenType";
|
|
54
|
+
EnumToken[EnumToken["EOFTokenType"] = 47] = "EOFTokenType";
|
|
55
|
+
EnumToken[EnumToken["ImportantTokenType"] = 48] = "ImportantTokenType";
|
|
56
|
+
EnumToken[EnumToken["ColorTokenType"] = 49] = "ColorTokenType";
|
|
57
|
+
EnumToken[EnumToken["AttrTokenType"] = 50] = "AttrTokenType";
|
|
58
|
+
EnumToken[EnumToken["BadCommentTokenType"] = 51] = "BadCommentTokenType";
|
|
59
|
+
EnumToken[EnumToken["BadCdoTokenType"] = 52] = "BadCdoTokenType";
|
|
60
|
+
EnumToken[EnumToken["BadUrlTokenType"] = 53] = "BadUrlTokenType";
|
|
61
|
+
EnumToken[EnumToken["BadStringTokenType"] = 54] = "BadStringTokenType";
|
|
62
|
+
EnumToken[EnumToken["BinaryExpressionTokenType"] = 55] = "BinaryExpressionTokenType";
|
|
63
|
+
EnumToken[EnumToken["UnaryExpressionTokenType"] = 56] = "UnaryExpressionTokenType";
|
|
65
64
|
/* catch all */
|
|
66
|
-
EnumToken[EnumToken["ListToken"] =
|
|
65
|
+
EnumToken[EnumToken["ListToken"] = 57] = "ListToken";
|
|
67
66
|
/* arithmetic tokens */
|
|
68
|
-
EnumToken[EnumToken["Add"] =
|
|
69
|
-
EnumToken[EnumToken["Mul"] =
|
|
70
|
-
EnumToken[EnumToken["Div"] =
|
|
71
|
-
EnumToken[EnumToken["Sub"] =
|
|
67
|
+
EnumToken[EnumToken["Add"] = 58] = "Add";
|
|
68
|
+
EnumToken[EnumToken["Mul"] = 59] = "Mul";
|
|
69
|
+
EnumToken[EnumToken["Div"] = 60] = "Div";
|
|
70
|
+
EnumToken[EnumToken["Sub"] = 61] = "Sub";
|
|
71
|
+
/* new tokens */
|
|
72
|
+
EnumToken[EnumToken["ColumnCombinatorTokenType"] = 62] = "ColumnCombinatorTokenType";
|
|
73
|
+
EnumToken[EnumToken["ContainMatchTokenType"] = 63] = "ContainMatchTokenType";
|
|
74
|
+
EnumToken[EnumToken["StartMatchTokenType"] = 64] = "StartMatchTokenType";
|
|
75
|
+
EnumToken[EnumToken["EndMatchTokenType"] = 65] = "EndMatchTokenType";
|
|
76
|
+
EnumToken[EnumToken["MatchExpressionTokenType"] = 66] = "MatchExpressionTokenType";
|
|
77
|
+
EnumToken[EnumToken["NameSpaceAttributeTokenType"] = 67] = "NameSpaceAttributeTokenType";
|
|
78
|
+
EnumToken[EnumToken["FractionTokenType"] = 68] = "FractionTokenType";
|
|
72
79
|
/* aliases */
|
|
73
|
-
EnumToken[EnumToken["Time"] =
|
|
74
|
-
EnumToken[EnumToken["Iden"] =
|
|
75
|
-
EnumToken[EnumToken["Hash"] =
|
|
76
|
-
EnumToken[EnumToken["Angle"] =
|
|
77
|
-
EnumToken[EnumToken["Color"] =
|
|
78
|
-
EnumToken[EnumToken["Comma"] =
|
|
79
|
-
EnumToken[EnumToken["String"] =
|
|
80
|
-
EnumToken[EnumToken["Length"] =
|
|
81
|
-
EnumToken[EnumToken["Number"] =
|
|
82
|
-
EnumToken[EnumToken["Perc"] =
|
|
83
|
-
EnumToken[EnumToken["Literal"] =
|
|
80
|
+
EnumToken[EnumToken["Time"] = 25] = "Time";
|
|
81
|
+
EnumToken[EnumToken["Iden"] = 7] = "Iden";
|
|
82
|
+
EnumToken[EnumToken["Hash"] = 28] = "Hash";
|
|
83
|
+
EnumToken[EnumToken["Angle"] = 24] = "Angle";
|
|
84
|
+
EnumToken[EnumToken["Color"] = 49] = "Color";
|
|
85
|
+
EnumToken[EnumToken["Comma"] = 9] = "Comma";
|
|
86
|
+
EnumToken[EnumToken["String"] = 20] = "String";
|
|
87
|
+
EnumToken[EnumToken["Length"] = 23] = "Length";
|
|
88
|
+
EnumToken[EnumToken["Number"] = 12] = "Number";
|
|
89
|
+
EnumToken[EnumToken["Perc"] = 14] = "Perc";
|
|
90
|
+
EnumToken[EnumToken["Literal"] = 6] = "Literal";
|
|
84
91
|
EnumToken[EnumToken["Comment"] = 0] = "Comment";
|
|
85
|
-
EnumToken[EnumToken["UrlFunc"] =
|
|
86
|
-
EnumToken[EnumToken["Dimension"] =
|
|
87
|
-
EnumToken[EnumToken["Frequency"] =
|
|
88
|
-
EnumToken[EnumToken["Resolution"] =
|
|
89
|
-
EnumToken[EnumToken["Whitespace"] =
|
|
92
|
+
EnumToken[EnumToken["UrlFunc"] = 18] = "UrlFunc";
|
|
93
|
+
EnumToken[EnumToken["Dimension"] = 22] = "Dimension";
|
|
94
|
+
EnumToken[EnumToken["Frequency"] = 26] = "Frequency";
|
|
95
|
+
EnumToken[EnumToken["Resolution"] = 27] = "Resolution";
|
|
96
|
+
EnumToken[EnumToken["Whitespace"] = 36] = "Whitespace";
|
|
97
|
+
EnumToken[EnumToken["DashedIden"] = 8] = "DashedIden";
|
|
98
|
+
EnumToken[EnumToken["ImageFunc"] = 19] = "ImageFunc";
|
|
99
|
+
EnumToken[EnumToken["CommentNodeType"] = 0] = "CommentNodeType";
|
|
100
|
+
EnumToken[EnumToken["CDOCOMMNodeType"] = 1] = "CDOCOMMNodeType";
|
|
101
|
+
EnumToken[EnumToken["TimingFunction"] = 17] = "TimingFunction";
|
|
102
|
+
EnumToken[EnumToken["TimelineFunction"] = 16] = "TimelineFunction";
|
|
90
103
|
})(exports.EnumToken || (exports.EnumToken = {}));
|
|
91
104
|
|
|
92
105
|
// name to color
|
|
@@ -743,21 +756,19 @@ function doRender(data, options = {}) {
|
|
|
743
756
|
}
|
|
744
757
|
if (sourcemap != null) {
|
|
745
758
|
result.map = sourcemap.toJSON();
|
|
746
|
-
// @ts-ignore
|
|
747
|
-
// result.map.sources = result.map.sources?.map(s => <string>options?.resolve(s, <string>options?.cwd)?.relative)
|
|
748
759
|
}
|
|
749
760
|
return result;
|
|
750
761
|
}
|
|
751
762
|
function updateSourceMap(node, options, cache, sourcemap, position, str) {
|
|
752
|
-
if ([
|
|
763
|
+
if ([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType].includes(node.typ)) {
|
|
753
764
|
let src = node.loc?.src ?? '';
|
|
754
765
|
let output = options.output ?? '';
|
|
755
|
-
if (src !== '') {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
}
|
|
766
|
+
// if (src !== '') {
|
|
767
|
+
if (!(src in cache)) {
|
|
768
|
+
// @ts-ignore
|
|
769
|
+
cache[src] = options.resolve(src, options.cwd ?? '').relative;
|
|
760
770
|
}
|
|
771
|
+
// }
|
|
761
772
|
if (!(output in cache)) {
|
|
762
773
|
// @ts-ignore
|
|
763
774
|
cache[output] = options.resolve(output, options.cwd).relative;
|
|
@@ -782,16 +793,16 @@ function renderAstNode(data, options, sourcemap, position, errors, reducer, cach
|
|
|
782
793
|
const indent = indents[level];
|
|
783
794
|
const indentSub = indents[level + 1];
|
|
784
795
|
switch (data.typ) {
|
|
785
|
-
case
|
|
796
|
+
case exports.EnumToken.DeclarationNodeType:
|
|
786
797
|
return `${data.nam}:${options.indent}${data.val.reduce(reducer, '')}`;
|
|
787
|
-
case
|
|
788
|
-
case
|
|
798
|
+
case exports.EnumToken.CommentNodeType:
|
|
799
|
+
case exports.EnumToken.CDOCOMMNodeType:
|
|
789
800
|
if (data.val.startsWith('# sourceMappingURL=')) {
|
|
790
801
|
// ignore sourcemap
|
|
791
802
|
return '';
|
|
792
803
|
}
|
|
793
804
|
return !options.removeComments || (options.preserveLicense && data.val.startsWith('/*!')) ? data.val : '';
|
|
794
|
-
case
|
|
805
|
+
case exports.EnumToken.StyleSheetNodeType:
|
|
795
806
|
return data.chi.reduce((css, node) => {
|
|
796
807
|
const str = renderAstNode(node, options, sourcemap, { ...position }, errors, reducer, cache, level, indents);
|
|
797
808
|
if (str === '') {
|
|
@@ -809,18 +820,18 @@ function renderAstNode(data, options, sourcemap, position, errors, reducer, cach
|
|
|
809
820
|
}
|
|
810
821
|
return `${css}${options.newLine}${str}`;
|
|
811
822
|
}, '');
|
|
812
|
-
case
|
|
813
|
-
case
|
|
814
|
-
if (data.typ ==
|
|
823
|
+
case exports.EnumToken.AtRuleNodeType:
|
|
824
|
+
case exports.EnumToken.RuleNodeType:
|
|
825
|
+
if (data.typ == exports.EnumToken.AtRuleNodeType && !('chi' in data)) {
|
|
815
826
|
return `${indent}@${data.nam}${data.val === '' ? '' : options.indent || ' '}${data.val};`;
|
|
816
827
|
}
|
|
817
828
|
// @ts-ignore
|
|
818
829
|
let children = data.chi.reduce((css, node) => {
|
|
819
830
|
let str;
|
|
820
|
-
if (node.typ ==
|
|
831
|
+
if (node.typ == exports.EnumToken.CommentNodeType) {
|
|
821
832
|
str = options.removeComments && (!options.preserveLicense || !node.val.startsWith('/*!')) ? '' : node.val;
|
|
822
833
|
}
|
|
823
|
-
else if (node.typ ==
|
|
834
|
+
else if (node.typ == exports.EnumToken.DeclarationNodeType) {
|
|
824
835
|
if (node.val.length == 0) {
|
|
825
836
|
// @ts-ignore
|
|
826
837
|
errors.push({
|
|
@@ -832,7 +843,7 @@ function renderAstNode(data, options, sourcemap, position, errors, reducer, cach
|
|
|
832
843
|
}
|
|
833
844
|
str = `${node.nam}:${options.indent}${node.val.reduce(reducer, '').trimEnd()};`;
|
|
834
845
|
}
|
|
835
|
-
else if (node.typ ==
|
|
846
|
+
else if (node.typ == exports.EnumToken.AtRuleNodeType && !('chi' in node)) {
|
|
836
847
|
str = `${data.val === '' ? '' : options.indent || ' '}${data.val};`;
|
|
837
848
|
}
|
|
838
849
|
else {
|
|
@@ -849,7 +860,7 @@ function renderAstNode(data, options, sourcemap, position, errors, reducer, cach
|
|
|
849
860
|
if (children.endsWith(';')) {
|
|
850
861
|
children = children.slice(0, -1);
|
|
851
862
|
}
|
|
852
|
-
if (data.typ ==
|
|
863
|
+
if (data.typ == exports.EnumToken.AtRuleNodeType) {
|
|
853
864
|
return `@${data.nam}${data.val === '' ? '' : options.indent || ' '}${data.val}${options.indent}{${options.newLine}` + (children === '' ? '' : indentSub + children + options.newLine) + indent + `}`;
|
|
854
865
|
}
|
|
855
866
|
return data.sel + `${options.indent}{${options.newLine}` + (children === '' ? '' : indentSub + children + options.newLine) + indent + `}`;
|
|
@@ -872,7 +883,35 @@ function renderToken(token, options = {}, cache = Object.create(null), reducer,
|
|
|
872
883
|
case exports.EnumToken.ListToken:
|
|
873
884
|
return token.chi.reduce((acc, curr) => acc + renderToken(curr, options, cache), '');
|
|
874
885
|
case exports.EnumToken.BinaryExpressionTokenType:
|
|
886
|
+
if ([exports.EnumToken.Mul, exports.EnumToken.Div].includes(token.op)) {
|
|
887
|
+
let result = '';
|
|
888
|
+
if (token.l.typ == exports.EnumToken.BinaryExpressionTokenType &&
|
|
889
|
+
[exports.EnumToken.Add, exports.EnumToken.Sub].includes(token.l.op)) {
|
|
890
|
+
result = '(' + renderToken(token.l, options, cache) + ')';
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
result = renderToken(token.l, options, cache);
|
|
894
|
+
}
|
|
895
|
+
result += token.op == exports.EnumToken.Mul ? '*' : '/';
|
|
896
|
+
if (token.r.typ == exports.EnumToken.BinaryExpressionTokenType &&
|
|
897
|
+
[exports.EnumToken.Add, exports.EnumToken.Sub].includes(token.r.op)) {
|
|
898
|
+
result += '(' + renderToken(token.r, options, cache) + ')';
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
result += renderToken(token.r, options, cache);
|
|
902
|
+
}
|
|
903
|
+
return result;
|
|
904
|
+
}
|
|
875
905
|
return renderToken(token.l, options, cache) + (token.op == exports.EnumToken.Add ? ' + ' : (token.op == exports.EnumToken.Sub ? ' - ' : (token.op == exports.EnumToken.Mul ? '*' : '/'))) + renderToken(token.r, options, cache);
|
|
906
|
+
case exports.EnumToken.FractionTokenType:
|
|
907
|
+
const fraction = renderToken(token.l) + '/' + renderToken(token.r);
|
|
908
|
+
if (+token.r.val != 0) {
|
|
909
|
+
const value = reduceNumber(+token.l.val / +token.r.val);
|
|
910
|
+
if (value.length <= fraction.length) {
|
|
911
|
+
return value;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
return fraction;
|
|
876
915
|
case exports.EnumToken.Add:
|
|
877
916
|
return ' + ';
|
|
878
917
|
case exports.EnumToken.Sub:
|
|
@@ -925,21 +964,45 @@ function renderToken(token, options = {}, cache = Object.create(null), reducer,
|
|
|
925
964
|
case exports.EnumToken.ParensTokenType:
|
|
926
965
|
case exports.EnumToken.FunctionTokenType:
|
|
927
966
|
case exports.EnumToken.UrlFunctionTokenType:
|
|
967
|
+
case exports.EnumToken.ImageFunctionTokenType:
|
|
928
968
|
case exports.EnumToken.PseudoClassFuncTokenType:
|
|
969
|
+
case exports.EnumToken.TimingFunctionTokenType:
|
|
970
|
+
case exports.EnumToken.TimelineFunctionTokenType:
|
|
929
971
|
if (token.typ == exports.EnumToken.FunctionTokenType &&
|
|
930
972
|
token.val == 'calc' &&
|
|
931
|
-
token.chi.length == 1
|
|
973
|
+
token.chi.length == 1 &&
|
|
974
|
+
token.chi[0].typ != exports.EnumToken.BinaryExpressionTokenType &&
|
|
975
|
+
token.chi[0].typ != exports.EnumToken.FractionTokenType &&
|
|
976
|
+
token.chi[0].val?.typ != exports.EnumToken.FractionTokenType) {
|
|
932
977
|
// calc(200px) => 200px
|
|
933
978
|
return token.chi.reduce((acc, curr) => acc + renderToken(curr, options, cache, reducer), '');
|
|
934
979
|
}
|
|
935
980
|
// @ts-ignore
|
|
936
981
|
return ( /* options.minify && 'Pseudo-class-func' == token.typ && token.val.slice(0, 2) == '::' ? token.val.slice(1) :*/token.val ?? '') + '(' + token.chi.reduce(reducer, '') + ')';
|
|
982
|
+
case exports.EnumToken.MatchExpressionTokenType:
|
|
983
|
+
return renderToken(token.l, options, cache, reducer, errors) +
|
|
984
|
+
renderToken({ typ: token.op }, options, cache, reducer, errors) +
|
|
985
|
+
renderToken(token.r, options, cache, reducer, errors) +
|
|
986
|
+
(token.attr ? ' ' + token.attr : '');
|
|
987
|
+
case exports.EnumToken.NameSpaceAttributeTokenType:
|
|
988
|
+
return (token.l == null ? '' : renderToken(token.l, options, cache, reducer, errors) + '|') +
|
|
989
|
+
renderToken(token.r, options, cache, reducer, errors);
|
|
990
|
+
case exports.EnumToken.BlockStartTokenType:
|
|
991
|
+
return '{';
|
|
992
|
+
case exports.EnumToken.BlockEndTokenType:
|
|
993
|
+
return '}';
|
|
937
994
|
case exports.EnumToken.StartParensTokenType:
|
|
938
995
|
return '(';
|
|
939
|
-
case exports.EnumToken.
|
|
996
|
+
case exports.EnumToken.IncludeMatchTokenType:
|
|
940
997
|
return '~=';
|
|
941
998
|
case exports.EnumToken.DashMatchTokenType:
|
|
942
999
|
return '|=';
|
|
1000
|
+
case exports.EnumToken.StartMatchTokenType:
|
|
1001
|
+
return '^=';
|
|
1002
|
+
case exports.EnumToken.EndMatchTokenType:
|
|
1003
|
+
return '$=';
|
|
1004
|
+
case exports.EnumToken.ContainMatchTokenType:
|
|
1005
|
+
return '*=';
|
|
943
1006
|
case exports.EnumToken.LtTokenType:
|
|
944
1007
|
return '<';
|
|
945
1008
|
case exports.EnumToken.LteTokenType:
|
|
@@ -948,6 +1011,8 @@ function renderToken(token, options = {}, cache = Object.create(null), reducer,
|
|
|
948
1011
|
return '>';
|
|
949
1012
|
case exports.EnumToken.GteTokenType:
|
|
950
1013
|
return '>=';
|
|
1014
|
+
case exports.EnumToken.ColumnCombinatorTokenType:
|
|
1015
|
+
return '||';
|
|
951
1016
|
case exports.EnumToken.EndParensTokenType:
|
|
952
1017
|
return ')';
|
|
953
1018
|
case exports.EnumToken.AttrStartTokenType:
|
|
@@ -972,19 +1037,9 @@ function renderToken(token, options = {}, cache = Object.create(null), reducer,
|
|
|
972
1037
|
case exports.EnumToken.DimensionTokenType:
|
|
973
1038
|
case exports.EnumToken.FrequencyTokenType:
|
|
974
1039
|
case exports.EnumToken.ResolutionTokenType:
|
|
975
|
-
|
|
976
|
-
const result = renderToken(token.val, options, cache);
|
|
977
|
-
if (!('unit' in token)) {
|
|
978
|
-
return result;
|
|
979
|
-
}
|
|
980
|
-
if (!result.includes(' ')) {
|
|
981
|
-
return result + token.unit;
|
|
982
|
-
}
|
|
983
|
-
return `(${result})*1${token.unit}`;
|
|
984
|
-
}
|
|
985
|
-
let val = reduceNumber(token.val);
|
|
1040
|
+
let val = token.val.typ == exports.EnumToken.FractionTokenType ? renderToken(token.val, options, cache) : reduceNumber(token.val);
|
|
986
1041
|
let unit = token.unit;
|
|
987
|
-
if (token.typ == exports.EnumToken.AngleTokenType) {
|
|
1042
|
+
if (token.typ == exports.EnumToken.AngleTokenType && !val.includes('/')) {
|
|
988
1043
|
const angle = getAngle(token);
|
|
989
1044
|
let v;
|
|
990
1045
|
let value = val + unit;
|
|
@@ -1041,16 +1096,21 @@ function renderToken(token, options = {}, cache = Object.create(null), reducer,
|
|
|
1041
1096
|
}
|
|
1042
1097
|
return '0';
|
|
1043
1098
|
}
|
|
1044
|
-
return val + unit;
|
|
1099
|
+
return val.includes('/') ? val.replace('/', unit + '/') : val + unit;
|
|
1045
1100
|
case exports.EnumToken.PercentageTokenType:
|
|
1046
|
-
const perc = reduceNumber(token.val);
|
|
1047
|
-
return options.minify && perc == '0' ? '0' : perc + '%';
|
|
1101
|
+
const perc = token.val.typ == exports.EnumToken.FractionTokenType ? renderToken(token.val, options, cache) : reduceNumber(token.val);
|
|
1102
|
+
return options.minify && perc == '0' ? '0' : (perc.includes('/') ? perc.replace('/', '%/') : perc + '%');
|
|
1048
1103
|
case exports.EnumToken.NumberTokenType:
|
|
1049
|
-
return reduceNumber(token.val);
|
|
1104
|
+
return token.val.typ == exports.EnumToken.FractionTokenType ? renderToken(token.val, options, cache) : reduceNumber(token.val);
|
|
1050
1105
|
case exports.EnumToken.CommentTokenType:
|
|
1051
1106
|
if (options.removeComments && (!options.preserveLicense || !token.val.startsWith('/*!'))) {
|
|
1052
1107
|
return '';
|
|
1053
1108
|
}
|
|
1109
|
+
case exports.EnumToken.PseudoClassTokenType:
|
|
1110
|
+
// https://www.w3.org/TR/selectors-4/#single-colon-pseudos
|
|
1111
|
+
if (token.typ == exports.EnumToken.PseudoClassTokenType && ['::before', '::after', '::first-line', '::first-letter'].includes(token.val)) {
|
|
1112
|
+
return token.val.slice(1);
|
|
1113
|
+
}
|
|
1054
1114
|
case exports.EnumToken.UrlTokenTokenType:
|
|
1055
1115
|
if (token.typ == exports.EnumToken.UrlTokenTokenType) {
|
|
1056
1116
|
if (options.output != null) {
|
|
@@ -1074,13 +1134,13 @@ function renderToken(token, options = {}, cache = Object.create(null), reducer,
|
|
|
1074
1134
|
token.val = cache[token.original];
|
|
1075
1135
|
}
|
|
1076
1136
|
}
|
|
1077
|
-
case exports.EnumToken.AtRuleTokenType:
|
|
1078
1137
|
case exports.EnumToken.HashTokenType:
|
|
1079
|
-
case exports.EnumToken.PseudoClassTokenType:
|
|
1080
|
-
case exports.EnumToken.LiteralTokenType:
|
|
1081
|
-
case exports.EnumToken.StringTokenType:
|
|
1082
1138
|
case exports.EnumToken.IdenTokenType:
|
|
1083
1139
|
case exports.EnumToken.DelimTokenType:
|
|
1140
|
+
case exports.EnumToken.AtRuleTokenType:
|
|
1141
|
+
case exports.EnumToken.StringTokenType:
|
|
1142
|
+
case exports.EnumToken.LiteralTokenType:
|
|
1143
|
+
case exports.EnumToken.DashedIdenTokenType:
|
|
1084
1144
|
return /* options.minify && 'Pseudo-class' == token.typ && '::' == token.val.slice(0, 2) ? token.val.slice(1) : */ token.val;
|
|
1085
1145
|
}
|
|
1086
1146
|
errors?.push({ action: 'ignore', message: `render: unexpected token ${JSON.stringify(token, null, 1)}` });
|
|
@@ -1584,6 +1644,317 @@ var properties = {
|
|
|
1584
1644
|
}
|
|
1585
1645
|
};
|
|
1586
1646
|
var map = {
|
|
1647
|
+
transition: {
|
|
1648
|
+
shorthand: "transition",
|
|
1649
|
+
multiple: true,
|
|
1650
|
+
separator: ",",
|
|
1651
|
+
pattern: "transition-property transition-duration transition-timing-function transition-delay transition-behavior",
|
|
1652
|
+
keywords: [
|
|
1653
|
+
"none",
|
|
1654
|
+
"all"
|
|
1655
|
+
],
|
|
1656
|
+
"default": [
|
|
1657
|
+
"0s",
|
|
1658
|
+
"0ms",
|
|
1659
|
+
"all",
|
|
1660
|
+
"ease",
|
|
1661
|
+
"none",
|
|
1662
|
+
"normal"
|
|
1663
|
+
],
|
|
1664
|
+
properties: {
|
|
1665
|
+
"transition-property": {
|
|
1666
|
+
keywords: [
|
|
1667
|
+
"none",
|
|
1668
|
+
"all"
|
|
1669
|
+
],
|
|
1670
|
+
"default": [
|
|
1671
|
+
],
|
|
1672
|
+
types: [
|
|
1673
|
+
"Iden"
|
|
1674
|
+
]
|
|
1675
|
+
},
|
|
1676
|
+
"transition-duration": {
|
|
1677
|
+
keywords: [
|
|
1678
|
+
],
|
|
1679
|
+
"default": [
|
|
1680
|
+
"0s",
|
|
1681
|
+
"0ms",
|
|
1682
|
+
"normal"
|
|
1683
|
+
],
|
|
1684
|
+
types: [
|
|
1685
|
+
"Time"
|
|
1686
|
+
]
|
|
1687
|
+
},
|
|
1688
|
+
"transition-timing-function": {
|
|
1689
|
+
keywords: [
|
|
1690
|
+
"ease",
|
|
1691
|
+
"ease-in",
|
|
1692
|
+
"ease-out",
|
|
1693
|
+
"ease-in-out",
|
|
1694
|
+
"linear",
|
|
1695
|
+
"step-start",
|
|
1696
|
+
"step-end"
|
|
1697
|
+
],
|
|
1698
|
+
"default": [
|
|
1699
|
+
"ease"
|
|
1700
|
+
],
|
|
1701
|
+
types: [
|
|
1702
|
+
"TimingFunction"
|
|
1703
|
+
],
|
|
1704
|
+
mapping: {
|
|
1705
|
+
"cubic-bezier(.25,.1,.25,1)": "ease",
|
|
1706
|
+
"cubic-bezier(0,0,1,1)": "linear",
|
|
1707
|
+
"cubic-bezier(.42,0,1,1)": "ease-in",
|
|
1708
|
+
"cubic-bezier(0,0,.58,1)": "ease-out",
|
|
1709
|
+
"cubic-bezier(.42,0,.58,.42)": "ease-in-out"
|
|
1710
|
+
}
|
|
1711
|
+
},
|
|
1712
|
+
"transition-delay": {
|
|
1713
|
+
keywords: [
|
|
1714
|
+
],
|
|
1715
|
+
"default": [
|
|
1716
|
+
"0s"
|
|
1717
|
+
],
|
|
1718
|
+
types: [
|
|
1719
|
+
"Time"
|
|
1720
|
+
]
|
|
1721
|
+
},
|
|
1722
|
+
"transition-behavior": {
|
|
1723
|
+
keywords: [
|
|
1724
|
+
"normal",
|
|
1725
|
+
"allow-discrete"
|
|
1726
|
+
],
|
|
1727
|
+
"default": [
|
|
1728
|
+
"normal"
|
|
1729
|
+
],
|
|
1730
|
+
types: [
|
|
1731
|
+
]
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
},
|
|
1735
|
+
"transition-property": {
|
|
1736
|
+
shorthand: "transition"
|
|
1737
|
+
},
|
|
1738
|
+
"transition-duration": {
|
|
1739
|
+
shorthand: "transition"
|
|
1740
|
+
},
|
|
1741
|
+
"transition-timing-function": {
|
|
1742
|
+
shorthand: "transition"
|
|
1743
|
+
},
|
|
1744
|
+
"transition-delay": {
|
|
1745
|
+
shorthand: "transition"
|
|
1746
|
+
},
|
|
1747
|
+
"transition-behavior": {
|
|
1748
|
+
shorthand: "transition"
|
|
1749
|
+
},
|
|
1750
|
+
animation: {
|
|
1751
|
+
shorthand: "animation",
|
|
1752
|
+
pattern: "animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-direction animation-fill-mode animation-play-state animation-timeline",
|
|
1753
|
+
"default": [
|
|
1754
|
+
"1",
|
|
1755
|
+
"0s",
|
|
1756
|
+
"0ms",
|
|
1757
|
+
"none",
|
|
1758
|
+
"ease",
|
|
1759
|
+
"normal",
|
|
1760
|
+
"running",
|
|
1761
|
+
"auto"
|
|
1762
|
+
],
|
|
1763
|
+
properties: {
|
|
1764
|
+
"animation-name": {
|
|
1765
|
+
keywords: [
|
|
1766
|
+
"none"
|
|
1767
|
+
],
|
|
1768
|
+
"default": [
|
|
1769
|
+
"none"
|
|
1770
|
+
],
|
|
1771
|
+
types: [
|
|
1772
|
+
"Iden"
|
|
1773
|
+
]
|
|
1774
|
+
},
|
|
1775
|
+
"animation-duration": {
|
|
1776
|
+
keywords: [
|
|
1777
|
+
"auto"
|
|
1778
|
+
],
|
|
1779
|
+
"default": [
|
|
1780
|
+
"0s",
|
|
1781
|
+
"0ms",
|
|
1782
|
+
"auto"
|
|
1783
|
+
],
|
|
1784
|
+
types: [
|
|
1785
|
+
"Time"
|
|
1786
|
+
],
|
|
1787
|
+
mapping: {
|
|
1788
|
+
auto: "0s"
|
|
1789
|
+
}
|
|
1790
|
+
},
|
|
1791
|
+
"animation-timing-function": {
|
|
1792
|
+
keywords: [
|
|
1793
|
+
"ease",
|
|
1794
|
+
"ease-in",
|
|
1795
|
+
"ease-out",
|
|
1796
|
+
"ease-in-out",
|
|
1797
|
+
"linear",
|
|
1798
|
+
"step-start",
|
|
1799
|
+
"step-end"
|
|
1800
|
+
],
|
|
1801
|
+
"default": [
|
|
1802
|
+
"ease"
|
|
1803
|
+
],
|
|
1804
|
+
types: [
|
|
1805
|
+
"TimingFunction"
|
|
1806
|
+
],
|
|
1807
|
+
mapping: {
|
|
1808
|
+
"cubic-bezier(.25,.1,.25,1)": "ease",
|
|
1809
|
+
"cubic-bezier(0,0,1,1)": "linear",
|
|
1810
|
+
"cubic-bezier(.42,0,1,1)": "ease-in",
|
|
1811
|
+
"cubic-bezier(0,0,.58,1)": "ease-out",
|
|
1812
|
+
"cubic-bezier(.42,0,.58,.42)": "ease-in-out"
|
|
1813
|
+
}
|
|
1814
|
+
},
|
|
1815
|
+
"animation-delay": {
|
|
1816
|
+
keywords: [
|
|
1817
|
+
],
|
|
1818
|
+
"default": [
|
|
1819
|
+
"0s",
|
|
1820
|
+
"0ms"
|
|
1821
|
+
],
|
|
1822
|
+
types: [
|
|
1823
|
+
"Time"
|
|
1824
|
+
]
|
|
1825
|
+
},
|
|
1826
|
+
"animation-iteration-count": {
|
|
1827
|
+
keywords: [
|
|
1828
|
+
"infinite"
|
|
1829
|
+
],
|
|
1830
|
+
"default": [
|
|
1831
|
+
"1"
|
|
1832
|
+
],
|
|
1833
|
+
types: [
|
|
1834
|
+
"Number"
|
|
1835
|
+
]
|
|
1836
|
+
},
|
|
1837
|
+
"animation-direction": {
|
|
1838
|
+
keywords: [
|
|
1839
|
+
"normal",
|
|
1840
|
+
"reverse",
|
|
1841
|
+
"alternate",
|
|
1842
|
+
"alternate-reverse"
|
|
1843
|
+
],
|
|
1844
|
+
"default": [
|
|
1845
|
+
"normal"
|
|
1846
|
+
],
|
|
1847
|
+
types: [
|
|
1848
|
+
]
|
|
1849
|
+
},
|
|
1850
|
+
"animation-fill-mode": {
|
|
1851
|
+
keywords: [
|
|
1852
|
+
"none",
|
|
1853
|
+
"forwards",
|
|
1854
|
+
"backwards",
|
|
1855
|
+
"both"
|
|
1856
|
+
],
|
|
1857
|
+
"default": [
|
|
1858
|
+
"none"
|
|
1859
|
+
],
|
|
1860
|
+
types: [
|
|
1861
|
+
]
|
|
1862
|
+
},
|
|
1863
|
+
"animation-play-state": {
|
|
1864
|
+
keywords: [
|
|
1865
|
+
"running",
|
|
1866
|
+
"paused"
|
|
1867
|
+
],
|
|
1868
|
+
"default": [
|
|
1869
|
+
"running"
|
|
1870
|
+
],
|
|
1871
|
+
types: [
|
|
1872
|
+
]
|
|
1873
|
+
},
|
|
1874
|
+
"animation-timeline": {
|
|
1875
|
+
keywords: [
|
|
1876
|
+
"none",
|
|
1877
|
+
"auto"
|
|
1878
|
+
],
|
|
1879
|
+
"default": [
|
|
1880
|
+
"auto"
|
|
1881
|
+
],
|
|
1882
|
+
types: [
|
|
1883
|
+
"DashedIden",
|
|
1884
|
+
"TimelineFunction"
|
|
1885
|
+
]
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
},
|
|
1889
|
+
"animation-name": {
|
|
1890
|
+
shorthand: "animation"
|
|
1891
|
+
},
|
|
1892
|
+
"animation-duration": {
|
|
1893
|
+
shorthand: "animation"
|
|
1894
|
+
},
|
|
1895
|
+
"animation-timing-function": {
|
|
1896
|
+
shorthand: "animation"
|
|
1897
|
+
},
|
|
1898
|
+
"animation-delay": {
|
|
1899
|
+
shorthand: "animation"
|
|
1900
|
+
},
|
|
1901
|
+
"animation-iteration-count": {
|
|
1902
|
+
shorthand: "animation"
|
|
1903
|
+
},
|
|
1904
|
+
"animation-direction": {
|
|
1905
|
+
shorthand: "animation"
|
|
1906
|
+
},
|
|
1907
|
+
"animation-fill-mode": {
|
|
1908
|
+
shorthand: "animation"
|
|
1909
|
+
},
|
|
1910
|
+
"animation-play-state": {
|
|
1911
|
+
shorthand: "animation"
|
|
1912
|
+
},
|
|
1913
|
+
"animation-timeline": {
|
|
1914
|
+
shorthand: "animation"
|
|
1915
|
+
},
|
|
1916
|
+
"text-emphasis": {
|
|
1917
|
+
shorthand: "text-emphasis",
|
|
1918
|
+
pattern: "text-emphasis-color text-emphasis-style",
|
|
1919
|
+
"default": [
|
|
1920
|
+
"none",
|
|
1921
|
+
"currentcolor"
|
|
1922
|
+
],
|
|
1923
|
+
properties: {
|
|
1924
|
+
"text-emphasis-style": {
|
|
1925
|
+
keywords: [
|
|
1926
|
+
"none",
|
|
1927
|
+
"filled",
|
|
1928
|
+
"open",
|
|
1929
|
+
"dot",
|
|
1930
|
+
"circle",
|
|
1931
|
+
"double-circle",
|
|
1932
|
+
"triangle",
|
|
1933
|
+
"sesame"
|
|
1934
|
+
],
|
|
1935
|
+
"default": [
|
|
1936
|
+
"none"
|
|
1937
|
+
],
|
|
1938
|
+
types: [
|
|
1939
|
+
"String"
|
|
1940
|
+
]
|
|
1941
|
+
},
|
|
1942
|
+
"text-emphasis-color": {
|
|
1943
|
+
"default": [
|
|
1944
|
+
"currentcolor"
|
|
1945
|
+
],
|
|
1946
|
+
types: [
|
|
1947
|
+
"Color"
|
|
1948
|
+
]
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
},
|
|
1952
|
+
"text-emphasis-style": {
|
|
1953
|
+
shorthand: "text-emphasis"
|
|
1954
|
+
},
|
|
1955
|
+
"text-emphasis-color": {
|
|
1956
|
+
shorthand: "text-emphasis"
|
|
1957
|
+
},
|
|
1587
1958
|
border: {
|
|
1588
1959
|
shorthand: "border",
|
|
1589
1960
|
pattern: "border-color border-style border-width",
|
|
@@ -1649,6 +2020,75 @@ var map = {
|
|
|
1649
2020
|
"border-width": {
|
|
1650
2021
|
shorthand: "border"
|
|
1651
2022
|
},
|
|
2023
|
+
"list-style": {
|
|
2024
|
+
shorthand: "list-style",
|
|
2025
|
+
pattern: "list-style-type list-style-position list-style-image",
|
|
2026
|
+
keywords: [
|
|
2027
|
+
"none",
|
|
2028
|
+
"outside"
|
|
2029
|
+
],
|
|
2030
|
+
"default": [
|
|
2031
|
+
"none",
|
|
2032
|
+
"outside"
|
|
2033
|
+
],
|
|
2034
|
+
properties: {
|
|
2035
|
+
"list-style-position": {
|
|
2036
|
+
types: [
|
|
2037
|
+
],
|
|
2038
|
+
"default": [
|
|
2039
|
+
"outside"
|
|
2040
|
+
],
|
|
2041
|
+
keywords: [
|
|
2042
|
+
"inside",
|
|
2043
|
+
"outside"
|
|
2044
|
+
]
|
|
2045
|
+
},
|
|
2046
|
+
"list-style-image": {
|
|
2047
|
+
"default": [
|
|
2048
|
+
"none"
|
|
2049
|
+
],
|
|
2050
|
+
keywords: [
|
|
2051
|
+
"node"
|
|
2052
|
+
],
|
|
2053
|
+
types: [
|
|
2054
|
+
"UrlFunc",
|
|
2055
|
+
"ImageFunc"
|
|
2056
|
+
]
|
|
2057
|
+
},
|
|
2058
|
+
"list-style-type": {
|
|
2059
|
+
types: [
|
|
2060
|
+
"String",
|
|
2061
|
+
"Iden",
|
|
2062
|
+
"Symbols"
|
|
2063
|
+
],
|
|
2064
|
+
"default": [
|
|
2065
|
+
"disc"
|
|
2066
|
+
],
|
|
2067
|
+
keywords: [
|
|
2068
|
+
"disc",
|
|
2069
|
+
"circle",
|
|
2070
|
+
"square",
|
|
2071
|
+
"decimal",
|
|
2072
|
+
"decimal-leading-zero",
|
|
2073
|
+
"lower-roman",
|
|
2074
|
+
"upper-roman",
|
|
2075
|
+
"lower-greek",
|
|
2076
|
+
"lower-latin",
|
|
2077
|
+
"upper-latin",
|
|
2078
|
+
"none"
|
|
2079
|
+
]
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
},
|
|
2083
|
+
"list-style-position": {
|
|
2084
|
+
shorthand: "list-style"
|
|
2085
|
+
},
|
|
2086
|
+
"list-style-image": {
|
|
2087
|
+
shorthand: "list-style"
|
|
2088
|
+
},
|
|
2089
|
+
"list-style-type": {
|
|
2090
|
+
shorthand: "list-style"
|
|
2091
|
+
},
|
|
1652
2092
|
overflow: {
|
|
1653
2093
|
shorthand: "overflow",
|
|
1654
2094
|
pattern: "overflow-x overflow-y",
|
|
@@ -1706,7 +2146,8 @@ var map = {
|
|
|
1706
2146
|
],
|
|
1707
2147
|
"default": [
|
|
1708
2148
|
"0",
|
|
1709
|
-
"none"
|
|
2149
|
+
"none",
|
|
2150
|
+
"currentcolor"
|
|
1710
2151
|
],
|
|
1711
2152
|
properties: {
|
|
1712
2153
|
"outline-color": {
|
|
@@ -1714,10 +2155,10 @@ var map = {
|
|
|
1714
2155
|
"Color"
|
|
1715
2156
|
],
|
|
1716
2157
|
"default": [
|
|
1717
|
-
"
|
|
2158
|
+
"currentcolor"
|
|
1718
2159
|
],
|
|
1719
2160
|
keywords: [
|
|
1720
|
-
"
|
|
2161
|
+
"currentcolor"
|
|
1721
2162
|
]
|
|
1722
2163
|
},
|
|
1723
2164
|
"outline-style": {
|
|
@@ -2061,7 +2502,8 @@ var map = {
|
|
|
2061
2502
|
},
|
|
2062
2503
|
"background-image": {
|
|
2063
2504
|
types: [
|
|
2064
|
-
"UrlFunc"
|
|
2505
|
+
"UrlFunc",
|
|
2506
|
+
"ImageFunc"
|
|
2065
2507
|
],
|
|
2066
2508
|
"default": [
|
|
2067
2509
|
"none"
|
|
@@ -2199,6 +2641,7 @@ var config$1 = {
|
|
|
2199
2641
|
|
|
2200
2642
|
const getConfig = () => config$1;
|
|
2201
2643
|
|
|
2644
|
+
// https://www.w3.org/TR/css-values-4/#math-function
|
|
2202
2645
|
const funcList = ['clamp', 'calc'];
|
|
2203
2646
|
function matchType(val, properties) {
|
|
2204
2647
|
if (val.typ == exports.EnumToken.IdenTokenType && properties.keywords.includes(val.val) ||
|
|
@@ -2214,8 +2657,12 @@ function matchType(val, properties) {
|
|
|
2214
2657
|
return typ == exports.EnumToken.LengthTokenType || typ == exports.EnumToken.AngleTokenType;
|
|
2215
2658
|
});
|
|
2216
2659
|
}
|
|
2217
|
-
if (val.typ == exports.EnumToken.FunctionTokenType
|
|
2218
|
-
|
|
2660
|
+
if (val.typ == exports.EnumToken.FunctionTokenType) {
|
|
2661
|
+
if (funcList.includes(val.val)) {
|
|
2662
|
+
return val.chi.every((t => [exports.EnumToken.LiteralTokenType, exports.EnumToken.CommaTokenType, exports.EnumToken.WhitespaceTokenType, exports.EnumToken.StartParensTokenType, exports.EnumToken.EndParensTokenType].includes(t.typ) || matchType(t, properties)));
|
|
2663
|
+
}
|
|
2664
|
+
// match type defined like function 'symbols()', 'url()', 'attr()' etc.
|
|
2665
|
+
// return properties.types.includes((<FunctionToken>val).val + '()')
|
|
2219
2666
|
}
|
|
2220
2667
|
return false;
|
|
2221
2668
|
}
|
|
@@ -2231,7 +2678,6 @@ function* tokenize(stream) {
|
|
|
2231
2678
|
};
|
|
2232
2679
|
let value;
|
|
2233
2680
|
let buffer = '';
|
|
2234
|
-
// let input: string = '';
|
|
2235
2681
|
function consumeWhiteSpace() {
|
|
2236
2682
|
let count = 0;
|
|
2237
2683
|
while (isWhiteSpace(stream.charAt(count + ind + 1).charCodeAt(0))) {
|
|
@@ -2241,7 +2687,7 @@ function* tokenize(stream) {
|
|
|
2241
2687
|
return count;
|
|
2242
2688
|
}
|
|
2243
2689
|
function pushToken(token, hint) {
|
|
2244
|
-
const result = { token, hint, position: { ...position }, bytesIn: ind };
|
|
2690
|
+
const result = { token, hint, position: { ...position }, bytesIn: ind + 1 };
|
|
2245
2691
|
position.ind = ind;
|
|
2246
2692
|
position.lin = lin;
|
|
2247
2693
|
position.col = col == 0 ? 1 : col;
|
|
@@ -2438,8 +2884,10 @@ function* tokenize(stream) {
|
|
|
2438
2884
|
// EOF
|
|
2439
2885
|
if (!(value = next())) {
|
|
2440
2886
|
// end of stream ignore \\
|
|
2441
|
-
|
|
2442
|
-
|
|
2887
|
+
if (buffer.length > 0) {
|
|
2888
|
+
yield pushToken(buffer);
|
|
2889
|
+
buffer = '';
|
|
2890
|
+
}
|
|
2443
2891
|
break;
|
|
2444
2892
|
}
|
|
2445
2893
|
buffer += prev() + value;
|
|
@@ -2448,29 +2896,51 @@ function* tokenize(stream) {
|
|
|
2448
2896
|
case "'":
|
|
2449
2897
|
yield* consumeString(value);
|
|
2450
2898
|
break;
|
|
2899
|
+
case '^':
|
|
2451
2900
|
case '~':
|
|
2452
2901
|
case '|':
|
|
2902
|
+
case '$':
|
|
2903
|
+
if (value == '|' && peek() == '|') {
|
|
2904
|
+
next();
|
|
2905
|
+
yield pushToken('', exports.EnumToken.ColumnCombinatorTokenType);
|
|
2906
|
+
buffer = '';
|
|
2907
|
+
break;
|
|
2908
|
+
}
|
|
2453
2909
|
if (buffer.length > 0) {
|
|
2454
2910
|
yield pushToken(buffer);
|
|
2455
2911
|
buffer = '';
|
|
2456
2912
|
}
|
|
2457
2913
|
buffer += value;
|
|
2458
|
-
if (!(value =
|
|
2914
|
+
if (!(value = peek())) {
|
|
2459
2915
|
yield pushToken(buffer);
|
|
2460
2916
|
buffer = '';
|
|
2461
2917
|
break;
|
|
2462
2918
|
}
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2919
|
+
// ~=
|
|
2920
|
+
// ^=
|
|
2921
|
+
// $=
|
|
2922
|
+
// |=
|
|
2923
|
+
if (peek() == '=') {
|
|
2924
|
+
next();
|
|
2925
|
+
switch (buffer.charAt(0)) {
|
|
2926
|
+
case '~':
|
|
2927
|
+
yield pushToken(buffer, exports.EnumToken.IncludeMatchTokenType);
|
|
2928
|
+
break;
|
|
2929
|
+
case '^':
|
|
2930
|
+
yield pushToken(buffer, exports.EnumToken.StartMatchTokenType);
|
|
2931
|
+
break;
|
|
2932
|
+
case '$':
|
|
2933
|
+
yield pushToken(buffer, exports.EnumToken.EndMatchTokenType);
|
|
2934
|
+
break;
|
|
2935
|
+
case '|':
|
|
2936
|
+
yield pushToken(buffer, exports.EnumToken.DashMatchTokenType);
|
|
2937
|
+
break;
|
|
2938
|
+
}
|
|
2939
|
+
buffer = '';
|
|
2940
|
+
break;
|
|
2941
|
+
}
|
|
2942
|
+
yield pushToken(buffer);
|
|
2943
|
+
buffer = '';
|
|
2474
2944
|
break;
|
|
2475
2945
|
case '>':
|
|
2476
2946
|
if (buffer !== '') {
|
|
@@ -2504,7 +2974,13 @@ function* tokenize(stream) {
|
|
|
2504
2974
|
yield pushToken(buffer);
|
|
2505
2975
|
buffer = '';
|
|
2506
2976
|
}
|
|
2507
|
-
|
|
2977
|
+
const val = peek();
|
|
2978
|
+
if (val == '=') {
|
|
2979
|
+
next();
|
|
2980
|
+
yield pushToken(value + val, exports.EnumToken.ContainMatchTokenType);
|
|
2981
|
+
break;
|
|
2982
|
+
}
|
|
2983
|
+
if (value == ':' && ':' == val) {
|
|
2508
2984
|
buffer += value + next();
|
|
2509
2985
|
break;
|
|
2510
2986
|
}
|
|
@@ -2720,251 +3196,236 @@ function* tokenize(stream) {
|
|
|
2720
3196
|
}
|
|
2721
3197
|
|
|
2722
3198
|
const urlTokenMatcher = /^(["']?)[a-zA-Z0-9_/.-][a-zA-Z0-9_/:.#?-]+(\1)$/;
|
|
2723
|
-
const trimWhiteSpace = [exports.EnumToken.GtTokenType, exports.EnumToken.GteTokenType, exports.EnumToken.LtTokenType, exports.EnumToken.LteTokenType];
|
|
2724
|
-
const funcLike = [
|
|
2725
|
-
|
|
3199
|
+
const trimWhiteSpace = [exports.EnumToken.CommentTokenType, exports.EnumToken.GtTokenType, exports.EnumToken.GteTokenType, exports.EnumToken.LtTokenType, exports.EnumToken.LteTokenType, exports.EnumToken.ColumnCombinatorTokenType];
|
|
3200
|
+
const funcLike = [
|
|
3201
|
+
exports.EnumToken.ParensTokenType,
|
|
3202
|
+
exports.EnumToken.FunctionTokenType,
|
|
3203
|
+
exports.EnumToken.UrlFunctionTokenType,
|
|
3204
|
+
exports.EnumToken.StartParensTokenType,
|
|
3205
|
+
exports.EnumToken.ImageFunctionTokenType,
|
|
3206
|
+
exports.EnumToken.PseudoClassFuncTokenType,
|
|
3207
|
+
exports.EnumToken.TimingFunctionTokenType,
|
|
3208
|
+
exports.EnumToken.TimingFunctionTokenType
|
|
3209
|
+
];
|
|
3210
|
+
const BadTokensTypes = [
|
|
3211
|
+
exports.EnumToken.BadCommentTokenType,
|
|
2726
3212
|
exports.EnumToken.BadCdoTokenType,
|
|
2727
3213
|
exports.EnumToken.BadUrlTokenType,
|
|
2728
|
-
exports.EnumToken.BadStringTokenType
|
|
3214
|
+
exports.EnumToken.BadStringTokenType
|
|
3215
|
+
];
|
|
3216
|
+
const webkitPseudoAliasMap = {
|
|
3217
|
+
'-webkit-autofill': 'autofill'
|
|
3218
|
+
};
|
|
2729
3219
|
async function doParse(iterator, options = {}) {
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
if (options.resolveImport) {
|
|
2749
|
-
options.resolveUrls = true;
|
|
2750
|
-
}
|
|
2751
|
-
const startTime = performance.now();
|
|
2752
|
-
const errors = [];
|
|
2753
|
-
const src = options.src;
|
|
2754
|
-
const stack = [];
|
|
2755
|
-
let ast = {
|
|
2756
|
-
typ: 2 /* NodeType.StyleSheetNodeType */,
|
|
2757
|
-
chi: []
|
|
2758
|
-
};
|
|
2759
|
-
let tokens = [];
|
|
2760
|
-
let map = new Map;
|
|
2761
|
-
let bytesIn = 0;
|
|
2762
|
-
let context = ast;
|
|
2763
|
-
if (options.sourcemap) {
|
|
2764
|
-
ast.loc = {
|
|
2765
|
-
sta: {
|
|
2766
|
-
ind: 0,
|
|
2767
|
-
lin: 1,
|
|
2768
|
-
col: 1
|
|
2769
|
-
},
|
|
2770
|
-
src: ''
|
|
3220
|
+
return new Promise(async (resolve, reject) => {
|
|
3221
|
+
if (options.signal != null) {
|
|
3222
|
+
options.signal.addEventListener('abort', reject);
|
|
3223
|
+
}
|
|
3224
|
+
options = {
|
|
3225
|
+
src: '',
|
|
3226
|
+
sourcemap: false,
|
|
3227
|
+
minify: true,
|
|
3228
|
+
nestingRules: false,
|
|
3229
|
+
resolveImport: false,
|
|
3230
|
+
resolveUrls: false,
|
|
3231
|
+
removeCharset: false,
|
|
3232
|
+
removeEmpty: true,
|
|
3233
|
+
removeDuplicateDeclarations: true,
|
|
3234
|
+
computeShorthand: true,
|
|
3235
|
+
computeCalcExpression: true,
|
|
3236
|
+
inlineCssVariables: false,
|
|
3237
|
+
...options
|
|
2771
3238
|
};
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
3239
|
+
if (options.expandNestingRules) {
|
|
3240
|
+
options.nestingRules = false;
|
|
3241
|
+
}
|
|
3242
|
+
if (options.resolveImport) {
|
|
3243
|
+
options.resolveUrls = true;
|
|
3244
|
+
}
|
|
3245
|
+
const startTime = performance.now();
|
|
3246
|
+
const errors = [];
|
|
3247
|
+
const src = options.src;
|
|
3248
|
+
const stack = [];
|
|
3249
|
+
let ast = {
|
|
3250
|
+
typ: exports.EnumToken.StyleSheetNodeType,
|
|
3251
|
+
chi: []
|
|
3252
|
+
};
|
|
3253
|
+
let tokens = [];
|
|
3254
|
+
let map = new Map;
|
|
3255
|
+
let bytesIn = 0;
|
|
3256
|
+
let context = ast;
|
|
3257
|
+
if (options.sourcemap) {
|
|
3258
|
+
ast.loc = {
|
|
3259
|
+
sta: {
|
|
3260
|
+
ind: 0,
|
|
3261
|
+
lin: 1,
|
|
3262
|
+
col: 1
|
|
3263
|
+
},
|
|
3264
|
+
src: ''
|
|
3265
|
+
};
|
|
3266
|
+
}
|
|
3267
|
+
async function parseNode(results) {
|
|
3268
|
+
let tokens = results.map(mapToken);
|
|
3269
|
+
let i;
|
|
3270
|
+
let loc;
|
|
3271
|
+
for (i = 0; i < tokens.length; i++) {
|
|
3272
|
+
if (tokens[i].typ == exports.EnumToken.CommentTokenType || tokens[i].typ == exports.EnumToken.CDOCOMMTokenType) {
|
|
3273
|
+
const position = map.get(tokens[i]);
|
|
3274
|
+
if (tokens[i].typ == exports.EnumToken.CDOCOMMTokenType && context.typ != exports.EnumToken.StyleSheetNodeType) {
|
|
3275
|
+
errors.push({
|
|
3276
|
+
action: 'drop',
|
|
3277
|
+
message: `CDOCOMM not allowed here ${JSON.stringify(tokens[i], null, 1)}`,
|
|
3278
|
+
location: { src, ...position }
|
|
3279
|
+
});
|
|
3280
|
+
continue;
|
|
3281
|
+
}
|
|
3282
|
+
loc = {
|
|
3283
|
+
sta: position,
|
|
3284
|
+
src
|
|
3285
|
+
};
|
|
3286
|
+
// @ts-ignore
|
|
3287
|
+
context.chi.push(tokens[i]);
|
|
3288
|
+
if (options.sourcemap) {
|
|
3289
|
+
tokens[i].loc = loc;
|
|
3290
|
+
}
|
|
2787
3291
|
}
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
src
|
|
2791
|
-
};
|
|
2792
|
-
// @ts-ignore
|
|
2793
|
-
context.chi.push(tokens[i]);
|
|
2794
|
-
if (options.sourcemap) {
|
|
2795
|
-
tokens[i].loc = loc;
|
|
3292
|
+
else if (tokens[i].typ != exports.EnumToken.WhitespaceTokenType) {
|
|
3293
|
+
break;
|
|
2796
3294
|
}
|
|
2797
3295
|
}
|
|
2798
|
-
|
|
2799
|
-
|
|
3296
|
+
tokens = tokens.slice(i);
|
|
3297
|
+
if (tokens.length == 0) {
|
|
3298
|
+
return null;
|
|
2800
3299
|
}
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
if (delim.typ == exports.EnumToken.SemiColonTokenType || delim.typ == exports.EnumToken.BlockStartTokenType || delim.typ == exports.EnumToken.BlockEndTokenType) {
|
|
2808
|
-
tokens.pop();
|
|
2809
|
-
}
|
|
2810
|
-
else {
|
|
2811
|
-
delim = { typ: exports.EnumToken.SemiColonTokenType };
|
|
2812
|
-
}
|
|
2813
|
-
// @ts-ignore
|
|
2814
|
-
while ([exports.EnumToken.WhitespaceTokenType, exports.EnumToken.BadStringTokenType, exports.EnumToken.BadCommentTokenType].includes(tokens.at(-1)?.typ)) {
|
|
2815
|
-
tokens.pop();
|
|
2816
|
-
}
|
|
2817
|
-
if (tokens.length == 0) {
|
|
2818
|
-
return null;
|
|
2819
|
-
}
|
|
2820
|
-
if (tokens[0]?.typ == exports.EnumToken.AtRuleTokenType) {
|
|
2821
|
-
const atRule = tokens.shift();
|
|
2822
|
-
const position = map.get(atRule);
|
|
2823
|
-
if (atRule.val == 'charset') {
|
|
2824
|
-
if (position.ind > 0) {
|
|
2825
|
-
errors.push({ action: 'drop', message: 'doParse: invalid @charset', location: { src, ...position } });
|
|
2826
|
-
return null;
|
|
2827
|
-
}
|
|
2828
|
-
if (options.removeCharset) {
|
|
2829
|
-
return null;
|
|
2830
|
-
}
|
|
3300
|
+
let delim = tokens.at(-1);
|
|
3301
|
+
if (delim.typ == exports.EnumToken.SemiColonTokenType || delim.typ == exports.EnumToken.BlockStartTokenType || delim.typ == exports.EnumToken.BlockEndTokenType) {
|
|
3302
|
+
tokens.pop();
|
|
3303
|
+
}
|
|
3304
|
+
else {
|
|
3305
|
+
delim = { typ: exports.EnumToken.SemiColonTokenType };
|
|
2831
3306
|
}
|
|
2832
3307
|
// @ts-ignore
|
|
2833
|
-
while ([exports.EnumToken.WhitespaceTokenType].includes(tokens
|
|
2834
|
-
tokens.
|
|
3308
|
+
while ([exports.EnumToken.WhitespaceTokenType, exports.EnumToken.BadStringTokenType, exports.EnumToken.BadCommentTokenType].includes(tokens.at(-1)?.typ)) {
|
|
3309
|
+
tokens.pop();
|
|
2835
3310
|
}
|
|
2836
|
-
if (
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
}
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
}
|
|
2854
|
-
break;
|
|
3311
|
+
if (tokens.length == 0) {
|
|
3312
|
+
return null;
|
|
3313
|
+
}
|
|
3314
|
+
if (tokens[0]?.typ == exports.EnumToken.AtRuleTokenType) {
|
|
3315
|
+
const atRule = tokens.shift();
|
|
3316
|
+
const position = map.get(atRule);
|
|
3317
|
+
if (atRule.val == 'charset') {
|
|
3318
|
+
if (position.ind > 0) {
|
|
3319
|
+
errors.push({
|
|
3320
|
+
action: 'drop',
|
|
3321
|
+
message: 'doParse: invalid @charset',
|
|
3322
|
+
location: { src, ...position }
|
|
3323
|
+
});
|
|
3324
|
+
return null;
|
|
3325
|
+
}
|
|
3326
|
+
if (options.removeCharset) {
|
|
3327
|
+
return null;
|
|
2855
3328
|
}
|
|
2856
3329
|
}
|
|
2857
3330
|
// @ts-ignore
|
|
2858
|
-
|
|
2859
|
-
errors.push({ action: 'drop', message: 'doParse: invalid @import', location: { src, ...position } });
|
|
2860
|
-
return null;
|
|
2861
|
-
}
|
|
2862
|
-
// @ts-ignore
|
|
2863
|
-
if (tokens[0].typ == exports.EnumToken.UrlFunctionTokenType && tokens[1]?.typ != exports.EnumToken.UrlTokenTokenType && tokens[1]?.typ != exports.EnumToken.StringTokenType) {
|
|
2864
|
-
errors.push({ action: 'drop', message: 'doParse: invalid @import', location: { src, ...position } });
|
|
2865
|
-
return null;
|
|
2866
|
-
}
|
|
2867
|
-
}
|
|
2868
|
-
if (atRule.val == 'import') {
|
|
2869
|
-
// @ts-ignore
|
|
2870
|
-
if (tokens[0].typ == exports.EnumToken.UrlFunctionTokenType && tokens[1].typ == exports.EnumToken.UrlTokenTokenType) {
|
|
3331
|
+
while ([exports.EnumToken.WhitespaceTokenType].includes(tokens[0]?.typ)) {
|
|
2871
3332
|
tokens.shift();
|
|
2872
|
-
// @ts-ignore
|
|
2873
|
-
tokens[0].typ = exports.EnumToken.StringTokenType;
|
|
2874
|
-
// @ts-ignore
|
|
2875
|
-
tokens[0].val = `"${tokens[0].val}"`;
|
|
2876
3333
|
}
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
if (
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
minify: false,
|
|
2886
|
-
// @ts-ignore
|
|
2887
|
-
src: options.resolve(url, options.src).absolute
|
|
2888
|
-
}));
|
|
2889
|
-
});
|
|
2890
|
-
bytesIn += root.stats.bytesIn;
|
|
2891
|
-
if (root.ast.chi.length > 0) {
|
|
2892
|
-
// @todo - filter charset, layer and scope
|
|
2893
|
-
context.chi.push(...root.ast.chi);
|
|
3334
|
+
if (atRule.val == 'import') {
|
|
3335
|
+
// only @charset and @layer are accepted before @import
|
|
3336
|
+
if (context.chi.length > 0) {
|
|
3337
|
+
let i = context.chi.length;
|
|
3338
|
+
while (i--) {
|
|
3339
|
+
const type = context.chi[i].typ;
|
|
3340
|
+
if (type == exports.EnumToken.CommentNodeType) {
|
|
3341
|
+
continue;
|
|
2894
3342
|
}
|
|
2895
|
-
if (
|
|
2896
|
-
errors.push(...
|
|
3343
|
+
if (type != exports.EnumToken.AtRuleNodeType) {
|
|
3344
|
+
errors.push({ action: 'drop', message: 'invalid @import', location: { src, ...position } });
|
|
3345
|
+
return null;
|
|
2897
3346
|
}
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
3347
|
+
const name = context.chi[i].nam;
|
|
3348
|
+
if (name != 'charset' && name != 'import' && name != 'layer') {
|
|
3349
|
+
errors.push({ action: 'drop', message: 'invalid @import', location: { src, ...position } });
|
|
3350
|
+
return null;
|
|
3351
|
+
}
|
|
3352
|
+
break;
|
|
2903
3353
|
}
|
|
2904
3354
|
}
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
}, []);
|
|
2914
|
-
const node = {
|
|
2915
|
-
typ: 3 /* NodeType.AtRuleNodeType */,
|
|
2916
|
-
nam: renderToken(atRule, { removeComments: true }),
|
|
2917
|
-
val: raw.join('')
|
|
2918
|
-
};
|
|
2919
|
-
Object.defineProperty(node, 'raw', { enumerable: false, configurable: true, writable: true, value: raw });
|
|
2920
|
-
if (delim.typ == exports.EnumToken.BlockStartTokenType) {
|
|
2921
|
-
node.chi = [];
|
|
2922
|
-
}
|
|
2923
|
-
loc = {
|
|
2924
|
-
sta: position,
|
|
2925
|
-
src
|
|
2926
|
-
};
|
|
2927
|
-
if (options.sourcemap) {
|
|
2928
|
-
node.loc = loc;
|
|
2929
|
-
}
|
|
2930
|
-
// @ts-ignore
|
|
2931
|
-
context.chi.push(node);
|
|
2932
|
-
return delim.typ == exports.EnumToken.BlockStartTokenType ? node : null;
|
|
2933
|
-
}
|
|
2934
|
-
else {
|
|
2935
|
-
// rule
|
|
2936
|
-
if (delim.typ == exports.EnumToken.BlockStartTokenType) {
|
|
2937
|
-
const position = map.get(tokens[0]);
|
|
2938
|
-
const uniq = new Map;
|
|
2939
|
-
parseTokens(tokens, { minify: true }).reduce((acc, curr, index, array) => {
|
|
2940
|
-
if (curr.typ == exports.EnumToken.WhitespaceTokenType) {
|
|
2941
|
-
if (trimWhiteSpace.includes(array[index - 1]?.typ) ||
|
|
2942
|
-
trimWhiteSpace.includes(array[index + 1]?.typ) ||
|
|
2943
|
-
combinators.includes(array[index - 1]?.val) ||
|
|
2944
|
-
combinators.includes(array[index + 1]?.val)) {
|
|
2945
|
-
return acc;
|
|
2946
|
-
}
|
|
3355
|
+
// @ts-ignore
|
|
3356
|
+
if (tokens[0]?.typ != exports.EnumToken.StringTokenType && tokens[0]?.typ != exports.EnumToken.UrlFunctionTokenType) {
|
|
3357
|
+
errors.push({
|
|
3358
|
+
action: 'drop',
|
|
3359
|
+
message: 'doParse: invalid @import',
|
|
3360
|
+
location: { src, ...position }
|
|
3361
|
+
});
|
|
3362
|
+
return null;
|
|
2947
3363
|
}
|
|
2948
|
-
|
|
2949
|
-
if (
|
|
2950
|
-
|
|
3364
|
+
// @ts-ignore
|
|
3365
|
+
if (tokens[0].typ == exports.EnumToken.UrlFunctionTokenType && tokens[1]?.typ != exports.EnumToken.UrlTokenTokenType && tokens[1]?.typ != exports.EnumToken.StringTokenType) {
|
|
3366
|
+
errors.push({
|
|
3367
|
+
action: 'drop',
|
|
3368
|
+
message: 'doParse: invalid @import',
|
|
3369
|
+
location: { src, ...position }
|
|
3370
|
+
});
|
|
3371
|
+
return null;
|
|
2951
3372
|
}
|
|
2952
|
-
|
|
2953
|
-
|
|
3373
|
+
}
|
|
3374
|
+
if (atRule.val == 'import') {
|
|
3375
|
+
// @ts-ignore
|
|
3376
|
+
if (tokens[0].typ == exports.EnumToken.UrlFunctionTokenType && tokens[1].typ == exports.EnumToken.UrlTokenTokenType) {
|
|
3377
|
+
tokens.shift();
|
|
3378
|
+
// @ts-ignore
|
|
3379
|
+
tokens[0].typ = exports.EnumToken.StringTokenType;
|
|
3380
|
+
// @ts-ignore
|
|
3381
|
+
tokens[0].val = `"${tokens[0].val}"`;
|
|
2954
3382
|
}
|
|
3383
|
+
// @ts-ignore
|
|
3384
|
+
if (tokens[0].typ == exports.EnumToken.StringTokenType) {
|
|
3385
|
+
if (options.resolveImport) {
|
|
3386
|
+
const url = tokens[0].val.slice(1, -1);
|
|
3387
|
+
try {
|
|
3388
|
+
// @ts-ignore
|
|
3389
|
+
const root = await options.load(url, options.src).then((src) => {
|
|
3390
|
+
return doParse(src, Object.assign({}, options, {
|
|
3391
|
+
minify: false,
|
|
3392
|
+
// @ts-ignore
|
|
3393
|
+
src: options.resolve(url, options.src).absolute
|
|
3394
|
+
}));
|
|
3395
|
+
});
|
|
3396
|
+
bytesIn += root.stats.bytesIn;
|
|
3397
|
+
if (root.ast.chi.length > 0) {
|
|
3398
|
+
// @todo - filter charset, layer and scope
|
|
3399
|
+
context.chi.push(...root.ast.chi);
|
|
3400
|
+
}
|
|
3401
|
+
if (root.errors.length > 0) {
|
|
3402
|
+
errors.push(...root.errors);
|
|
3403
|
+
}
|
|
3404
|
+
return null;
|
|
3405
|
+
}
|
|
3406
|
+
catch (error) {
|
|
3407
|
+
// @ts-ignore
|
|
3408
|
+
errors.push({ action: 'ignore', message: 'doParse: ' + error.message, error });
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
// https://www.w3.org/TR/css-nesting-1/#conditionals
|
|
3414
|
+
// allowed nesting at-rules
|
|
3415
|
+
// there must be a top level rule in the stack
|
|
3416
|
+
const raw = parseTokens(tokens, { minify: options.minify }).reduce((acc, curr) => {
|
|
3417
|
+
acc.push(renderToken(curr, { removeComments: true }));
|
|
2955
3418
|
return acc;
|
|
2956
|
-
}, [
|
|
2957
|
-
acc.set(curr.join(''), curr);
|
|
2958
|
-
return acc;
|
|
2959
|
-
}, uniq);
|
|
3419
|
+
}, []);
|
|
2960
3420
|
const node = {
|
|
2961
|
-
typ:
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
chi: []
|
|
3421
|
+
typ: exports.EnumToken.AtRuleNodeType,
|
|
3422
|
+
nam: renderToken(atRule, { removeComments: true }),
|
|
3423
|
+
val: raw.join('')
|
|
2965
3424
|
};
|
|
2966
|
-
let raw = [...uniq.values()];
|
|
2967
3425
|
Object.defineProperty(node, 'raw', { enumerable: false, configurable: true, writable: true, value: raw });
|
|
3426
|
+
if (delim.typ == exports.EnumToken.BlockStartTokenType) {
|
|
3427
|
+
node.chi = [];
|
|
3428
|
+
}
|
|
2968
3429
|
loc = {
|
|
2969
3430
|
sta: position,
|
|
2970
3431
|
src
|
|
@@ -2974,166 +3435,255 @@ async function doParse(iterator, options = {}) {
|
|
|
2974
3435
|
}
|
|
2975
3436
|
// @ts-ignore
|
|
2976
3437
|
context.chi.push(node);
|
|
2977
|
-
return node;
|
|
3438
|
+
return delim.typ == exports.EnumToken.BlockStartTokenType ? node : null;
|
|
2978
3439
|
}
|
|
2979
3440
|
else {
|
|
2980
|
-
//
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
3441
|
+
// rule
|
|
3442
|
+
if (delim.typ == exports.EnumToken.BlockStartTokenType) {
|
|
3443
|
+
const position = map.get(tokens[0]);
|
|
3444
|
+
const uniq = new Map;
|
|
3445
|
+
parseTokens(tokens, { minify: true }).reduce((acc, curr, index, array) => {
|
|
3446
|
+
if (curr.typ == exports.EnumToken.WhitespaceTokenType) {
|
|
3447
|
+
if (trimWhiteSpace.includes(array[index - 1]?.typ) ||
|
|
3448
|
+
trimWhiteSpace.includes(array[index + 1]?.typ) ||
|
|
3449
|
+
combinators.includes(array[index - 1]?.val) ||
|
|
3450
|
+
combinators.includes(array[index + 1]?.val)) {
|
|
3451
|
+
return acc;
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
let t = renderToken(curr, { minify: false });
|
|
3455
|
+
if (t == ',') {
|
|
3456
|
+
acc.push([]);
|
|
3457
|
+
}
|
|
3458
|
+
else {
|
|
3459
|
+
acc[acc.length - 1].push(t);
|
|
3460
|
+
}
|
|
3461
|
+
return acc;
|
|
3462
|
+
}, [[]]).reduce((acc, curr) => {
|
|
3463
|
+
acc.set(curr.join(''), curr);
|
|
3464
|
+
return acc;
|
|
3465
|
+
}, uniq);
|
|
3466
|
+
const node = {
|
|
3467
|
+
typ: exports.EnumToken.RuleNodeType,
|
|
3468
|
+
// @ts-ignore
|
|
3469
|
+
sel: [...uniq.keys()].join(','),
|
|
3470
|
+
chi: []
|
|
3471
|
+
};
|
|
3472
|
+
let raw = [...uniq.values()];
|
|
3473
|
+
Object.defineProperty(node, 'raw', {
|
|
3474
|
+
enumerable: false,
|
|
3475
|
+
configurable: true,
|
|
3476
|
+
writable: true,
|
|
3477
|
+
value: raw
|
|
3478
|
+
});
|
|
3479
|
+
loc = {
|
|
3480
|
+
sta: position,
|
|
3481
|
+
src
|
|
3482
|
+
};
|
|
3483
|
+
if (options.sourcemap) {
|
|
3484
|
+
node.loc = loc;
|
|
2998
3485
|
}
|
|
3486
|
+
// @ts-ignore
|
|
3487
|
+
context.chi.push(node);
|
|
3488
|
+
return node;
|
|
2999
3489
|
}
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3490
|
+
else {
|
|
3491
|
+
// declaration
|
|
3492
|
+
// @ts-ignore
|
|
3493
|
+
let name = null;
|
|
3494
|
+
// @ts-ignore
|
|
3495
|
+
let value = null;
|
|
3496
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
3497
|
+
if (tokens[i].typ == exports.EnumToken.CommentTokenType) {
|
|
3498
|
+
continue;
|
|
3499
|
+
}
|
|
3500
|
+
if (tokens[i].typ == exports.EnumToken.ColonTokenType) {
|
|
3501
|
+
name = tokens.slice(0, i);
|
|
3502
|
+
value = parseTokens(tokens.slice(i + 1), {
|
|
3503
|
+
parseColor: true,
|
|
3504
|
+
src: options.src,
|
|
3505
|
+
resolveUrls: options.resolveUrls,
|
|
3506
|
+
resolve: options.resolve,
|
|
3507
|
+
cwd: options.cwd
|
|
3011
3508
|
});
|
|
3012
|
-
return null;
|
|
3013
3509
|
}
|
|
3014
3510
|
}
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3511
|
+
if (name == null) {
|
|
3512
|
+
name = tokens;
|
|
3513
|
+
}
|
|
3514
|
+
const position = map.get(name[0]);
|
|
3515
|
+
if (name.length > 0) {
|
|
3516
|
+
for (let i = 1; i < name.length; i++) {
|
|
3517
|
+
if (name[i].typ != exports.EnumToken.WhitespaceTokenType && name[i].typ != exports.EnumToken.CommentTokenType) {
|
|
3518
|
+
errors.push({
|
|
3519
|
+
action: 'drop',
|
|
3520
|
+
message: 'doParse: invalid declaration',
|
|
3521
|
+
location: { src, ...position }
|
|
3522
|
+
});
|
|
3523
|
+
return null;
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
if (value == null || value.length == 0) {
|
|
3528
|
+
errors.push({
|
|
3529
|
+
action: 'drop',
|
|
3530
|
+
message: 'doParse: invalid declaration',
|
|
3531
|
+
location: { src, ...position }
|
|
3532
|
+
});
|
|
3533
|
+
return null;
|
|
3534
|
+
}
|
|
3535
|
+
const node = {
|
|
3536
|
+
typ: exports.EnumToken.DeclarationNodeType,
|
|
3537
|
+
// @ts-ignore
|
|
3538
|
+
nam: renderToken(name.shift(), { removeComments: true }),
|
|
3539
|
+
// @ts-ignore
|
|
3540
|
+
val: value
|
|
3541
|
+
};
|
|
3542
|
+
while (node.val[0]?.typ == exports.EnumToken.WhitespaceTokenType) {
|
|
3543
|
+
node.val.shift();
|
|
3544
|
+
}
|
|
3545
|
+
if (node.val.length == 0) {
|
|
3546
|
+
errors.push({
|
|
3547
|
+
action: 'drop',
|
|
3548
|
+
message: 'doParse: invalid declaration',
|
|
3549
|
+
location: { src, ...position }
|
|
3550
|
+
});
|
|
3551
|
+
return null;
|
|
3552
|
+
}
|
|
3028
3553
|
// @ts-ignore
|
|
3029
|
-
|
|
3030
|
-
};
|
|
3031
|
-
while (node.val[0]?.typ == exports.EnumToken.WhitespaceTokenType) {
|
|
3032
|
-
node.val.shift();
|
|
3033
|
-
}
|
|
3034
|
-
if (node.val.length == 0) {
|
|
3035
|
-
errors.push({
|
|
3036
|
-
action: 'drop',
|
|
3037
|
-
message: 'doParse: invalid declaration',
|
|
3038
|
-
location: { src, ...position }
|
|
3039
|
-
});
|
|
3554
|
+
context.chi.push(node);
|
|
3040
3555
|
return null;
|
|
3041
3556
|
}
|
|
3042
|
-
// @ts-ignore
|
|
3043
|
-
context.chi.push(node);
|
|
3044
|
-
return null;
|
|
3045
3557
|
}
|
|
3046
3558
|
}
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
return node;
|
|
3052
|
-
}
|
|
3053
|
-
const iter = tokenize(iterator);
|
|
3054
|
-
let item;
|
|
3055
|
-
while (item = iter.next().value) {
|
|
3056
|
-
bytesIn = item.bytesIn;
|
|
3057
|
-
// doParse error
|
|
3058
|
-
if (item.hint != null && BadTokensTypes.includes(item.hint)) {
|
|
3059
|
-
// bad token
|
|
3060
|
-
continue;
|
|
3559
|
+
function mapToken(token) {
|
|
3560
|
+
const node = getTokenType(token.token, token.hint);
|
|
3561
|
+
map.set(node, token.position);
|
|
3562
|
+
return node;
|
|
3061
3563
|
}
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3564
|
+
const iter = tokenize(iterator);
|
|
3565
|
+
let item;
|
|
3566
|
+
while (item = iter.next().value) {
|
|
3567
|
+
bytesIn = item.bytesIn;
|
|
3568
|
+
// doParse error
|
|
3569
|
+
if (item.hint != null && BadTokensTypes.includes(item.hint)) {
|
|
3570
|
+
// bad token
|
|
3571
|
+
continue;
|
|
3572
|
+
}
|
|
3573
|
+
tokens.push(item);
|
|
3574
|
+
if (item.token == ';' || item.token == '{') {
|
|
3575
|
+
let node = await parseNode(tokens);
|
|
3576
|
+
if (node != null) {
|
|
3577
|
+
stack.push(node);
|
|
3578
|
+
// @ts-ignore
|
|
3579
|
+
context = node;
|
|
3580
|
+
}
|
|
3581
|
+
else if (item.token == '{') {
|
|
3582
|
+
// node == null
|
|
3583
|
+
// consume and throw away until the closing '}' or EOF
|
|
3584
|
+
let inBlock = 1;
|
|
3585
|
+
do {
|
|
3586
|
+
item = iter.next().value;
|
|
3587
|
+
if (item == null) {
|
|
3588
|
+
break;
|
|
3589
|
+
}
|
|
3590
|
+
if (item.token == '{') {
|
|
3591
|
+
inBlock++;
|
|
3592
|
+
}
|
|
3593
|
+
else if (item.token == '}') {
|
|
3594
|
+
inBlock--;
|
|
3595
|
+
}
|
|
3596
|
+
} while (inBlock != 0);
|
|
3597
|
+
}
|
|
3598
|
+
tokens = [];
|
|
3599
|
+
map = new Map;
|
|
3600
|
+
}
|
|
3601
|
+
else if (item.token == '}') {
|
|
3602
|
+
await parseNode(tokens);
|
|
3603
|
+
const previousNode = stack.pop();
|
|
3067
3604
|
// @ts-ignore
|
|
3068
|
-
context =
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
item = iter.next().value;
|
|
3076
|
-
if (item == null) {
|
|
3077
|
-
break;
|
|
3078
|
-
}
|
|
3079
|
-
if (item.token == '{') {
|
|
3080
|
-
inBlock++;
|
|
3081
|
-
}
|
|
3082
|
-
else if (item.token == '}') {
|
|
3083
|
-
inBlock--;
|
|
3084
|
-
}
|
|
3085
|
-
} while (inBlock != 0);
|
|
3605
|
+
context = stack[stack.length - 1] || ast;
|
|
3606
|
+
// @ts-ignore
|
|
3607
|
+
if (options.removeEmpty && previousNode != null && previousNode.chi.length == 0 && context.chi[context.chi.length - 1] == previousNode) {
|
|
3608
|
+
context.chi.pop();
|
|
3609
|
+
}
|
|
3610
|
+
tokens = [];
|
|
3611
|
+
map = new Map;
|
|
3086
3612
|
}
|
|
3087
|
-
tokens = [];
|
|
3088
|
-
map = new Map;
|
|
3089
3613
|
}
|
|
3090
|
-
|
|
3614
|
+
if (tokens.length > 0) {
|
|
3091
3615
|
await parseNode(tokens);
|
|
3616
|
+
}
|
|
3617
|
+
while (stack.length > 0 && context != ast) {
|
|
3092
3618
|
const previousNode = stack.pop();
|
|
3093
3619
|
// @ts-ignore
|
|
3094
3620
|
context = stack[stack.length - 1] || ast;
|
|
3095
3621
|
// @ts-ignore
|
|
3096
3622
|
if (options.removeEmpty && previousNode != null && previousNode.chi.length == 0 && context.chi[context.chi.length - 1] == previousNode) {
|
|
3097
3623
|
context.chi.pop();
|
|
3624
|
+
continue;
|
|
3098
3625
|
}
|
|
3099
|
-
|
|
3100
|
-
map = new Map;
|
|
3626
|
+
break;
|
|
3101
3627
|
}
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
}
|
|
3106
|
-
while (stack.length > 0 && context != ast) {
|
|
3107
|
-
const previousNode = stack.pop();
|
|
3108
|
-
// @ts-ignore
|
|
3109
|
-
context = stack[stack.length - 1] || ast;
|
|
3110
|
-
// @ts-ignore
|
|
3111
|
-
if (options.removeEmpty && previousNode != null && previousNode.chi.length == 0 && context.chi[context.chi.length - 1] == previousNode) {
|
|
3112
|
-
context.chi.pop();
|
|
3113
|
-
continue;
|
|
3628
|
+
const endParseTime = performance.now();
|
|
3629
|
+
if (options.expandNestingRules) {
|
|
3630
|
+
ast = expand(ast);
|
|
3114
3631
|
}
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3632
|
+
if (options.visitor != null) {
|
|
3633
|
+
for (const result of walk(ast)) {
|
|
3634
|
+
if (result.node.typ == exports.EnumToken.DeclarationNodeType &&
|
|
3635
|
+
// @ts-ignore
|
|
3636
|
+
(typeof options.visitor.Declaration == 'function' || options.visitor.Declaration?.[result.node.nam] != null)) {
|
|
3637
|
+
const callable = typeof options.visitor.Declaration == 'function' ? options.visitor.Declaration : options.visitor.Declaration[result.node.nam];
|
|
3638
|
+
const results = callable(result.node);
|
|
3639
|
+
if (results == null || (Array.isArray(results) && results.length == 0)) {
|
|
3640
|
+
continue;
|
|
3641
|
+
}
|
|
3642
|
+
// @ts-ignore
|
|
3643
|
+
result.parent.chi.splice(result.parent.chi.indexOf(result.node), 1, ...(Array.isArray(results) ? results : [results]));
|
|
3644
|
+
}
|
|
3645
|
+
else if (options.visitor.Rule != null && result.node.typ == exports.EnumToken.RuleNodeType) {
|
|
3646
|
+
const results = options.visitor.Rule(result.node);
|
|
3647
|
+
if (results == null || (Array.isArray(results) && results.length == 0)) {
|
|
3648
|
+
continue;
|
|
3649
|
+
}
|
|
3650
|
+
// @ts-ignore
|
|
3651
|
+
result.parent.chi.splice(result.parent.chi.indexOf(result.node), 1, ...(Array.isArray(results) ? results : [results]));
|
|
3652
|
+
}
|
|
3653
|
+
else if (options.visitor.AtRule != null &&
|
|
3654
|
+
result.node.typ == exports.EnumToken.AtRuleNodeType &&
|
|
3655
|
+
// @ts-ignore
|
|
3656
|
+
(typeof options.visitor.AtRule == 'function' || options.visitor.AtRule?.[result.node.nam] != null)) {
|
|
3657
|
+
const callable = typeof options.visitor.AtRule == 'function' ? options.visitor.AtRule : options.visitor.AtRule[result.node.nam];
|
|
3658
|
+
const results = callable(result.node);
|
|
3659
|
+
if (results == null || (Array.isArray(results) && results.length == 0)) {
|
|
3660
|
+
continue;
|
|
3661
|
+
}
|
|
3662
|
+
// @ts-ignore
|
|
3663
|
+
result.parent.chi.splice(result.parent.chi.indexOf(result.node), 1, ...(Array.isArray(results) ? results : [results]));
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3124
3666
|
}
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
errors,
|
|
3130
|
-
stats: {
|
|
3131
|
-
bytesIn,
|
|
3132
|
-
parse: `${(endParseTime - startTime).toFixed(2)}ms`,
|
|
3133
|
-
minify: `${(endTime - endParseTime).toFixed(2)}ms`,
|
|
3134
|
-
total: `${(endTime - startTime).toFixed(2)}ms`
|
|
3667
|
+
if (options.minify) {
|
|
3668
|
+
if (ast.chi.length > 0) {
|
|
3669
|
+
minify(ast, options, true, errors, false);
|
|
3670
|
+
}
|
|
3135
3671
|
}
|
|
3136
|
-
|
|
3672
|
+
const endTime = performance.now();
|
|
3673
|
+
if (options.signal != null) {
|
|
3674
|
+
options.signal.removeEventListener('abort', reject);
|
|
3675
|
+
}
|
|
3676
|
+
resolve({
|
|
3677
|
+
ast,
|
|
3678
|
+
errors,
|
|
3679
|
+
stats: {
|
|
3680
|
+
bytesIn,
|
|
3681
|
+
parse: `${(endParseTime - startTime).toFixed(2)}ms`,
|
|
3682
|
+
minify: `${(endTime - endParseTime).toFixed(2)}ms`,
|
|
3683
|
+
total: `${(endTime - startTime).toFixed(2)}ms`
|
|
3684
|
+
}
|
|
3685
|
+
});
|
|
3686
|
+
});
|
|
3137
3687
|
}
|
|
3138
3688
|
function parseString(src, options = { location: false }) {
|
|
3139
3689
|
return parseTokens([...tokenize(src)].map(t => {
|
|
@@ -3152,7 +3702,9 @@ function getTokenType(val, hint) {
|
|
|
3152
3702
|
return ([
|
|
3153
3703
|
exports.EnumToken.WhitespaceTokenType, exports.EnumToken.SemiColonTokenType, exports.EnumToken.ColonTokenType, exports.EnumToken.BlockStartTokenType,
|
|
3154
3704
|
exports.EnumToken.BlockStartTokenType, exports.EnumToken.AttrStartTokenType, exports.EnumToken.AttrEndTokenType, exports.EnumToken.StartParensTokenType, exports.EnumToken.EndParensTokenType,
|
|
3155
|
-
exports.EnumToken.CommaTokenType, exports.EnumToken.GtTokenType, exports.EnumToken.LtTokenType, exports.EnumToken.GteTokenType, exports.EnumToken.LteTokenType, exports.EnumToken.
|
|
3705
|
+
exports.EnumToken.CommaTokenType, exports.EnumToken.GtTokenType, exports.EnumToken.LtTokenType, exports.EnumToken.GteTokenType, exports.EnumToken.LteTokenType, exports.EnumToken.CommaTokenType,
|
|
3706
|
+
exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.ContainMatchTokenType,
|
|
3707
|
+
exports.EnumToken.EOFTokenType
|
|
3156
3708
|
].includes(hint) ? { typ: hint } : { typ: hint, val });
|
|
3157
3709
|
}
|
|
3158
3710
|
if (val == ' ') {
|
|
@@ -3216,8 +3768,36 @@ function getTokenType(val, hint) {
|
|
|
3216
3768
|
}
|
|
3217
3769
|
if (isFunction(val)) {
|
|
3218
3770
|
val = val.slice(0, -1);
|
|
3771
|
+
if (val == 'url') {
|
|
3772
|
+
return {
|
|
3773
|
+
typ: exports.EnumToken.UrlFunctionTokenType,
|
|
3774
|
+
val,
|
|
3775
|
+
chi: []
|
|
3776
|
+
};
|
|
3777
|
+
}
|
|
3778
|
+
if (['linear-gradient', 'radial-gradient', 'repeating-linear-gradient', 'repeating-radial-gradient', 'conic-gradient', 'image', 'image-set', 'element', 'cross-fade'].includes(val)) {
|
|
3779
|
+
return {
|
|
3780
|
+
typ: exports.EnumToken.ImageFunctionTokenType,
|
|
3781
|
+
val,
|
|
3782
|
+
chi: []
|
|
3783
|
+
};
|
|
3784
|
+
}
|
|
3785
|
+
if (['ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear', 'step-start', 'step-end', 'steps', 'cubic-bezier'].includes(val)) {
|
|
3786
|
+
return {
|
|
3787
|
+
typ: exports.EnumToken.TimingFunctionTokenType,
|
|
3788
|
+
val,
|
|
3789
|
+
chi: []
|
|
3790
|
+
};
|
|
3791
|
+
}
|
|
3792
|
+
if (['view', 'scroll'].includes(val)) {
|
|
3793
|
+
return {
|
|
3794
|
+
typ: exports.EnumToken.TimelineFunctionTokenType,
|
|
3795
|
+
val,
|
|
3796
|
+
chi: []
|
|
3797
|
+
};
|
|
3798
|
+
}
|
|
3219
3799
|
return {
|
|
3220
|
-
typ:
|
|
3800
|
+
typ: exports.EnumToken.FunctionTokenType,
|
|
3221
3801
|
val,
|
|
3222
3802
|
chi: []
|
|
3223
3803
|
};
|
|
@@ -3247,7 +3827,7 @@ function getTokenType(val, hint) {
|
|
|
3247
3827
|
}
|
|
3248
3828
|
if (isIdent(val)) {
|
|
3249
3829
|
return {
|
|
3250
|
-
typ: exports.EnumToken.IdenTokenType,
|
|
3830
|
+
typ: val.startsWith('--') ? exports.EnumToken.DashedIdenTokenType : exports.EnumToken.IdenTokenType,
|
|
3251
3831
|
val
|
|
3252
3832
|
};
|
|
3253
3833
|
}
|
|
@@ -3280,7 +3860,7 @@ function parseTokens(tokens, options = {}) {
|
|
|
3280
3860
|
const t = tokens[i];
|
|
3281
3861
|
if (t.typ == exports.EnumToken.WhitespaceTokenType && ((i == 0 ||
|
|
3282
3862
|
i + 1 == tokens.length ||
|
|
3283
|
-
[exports.EnumToken.CommaTokenType, exports.EnumToken.GteTokenType, exports.EnumToken.LteTokenType].includes(tokens[i + 1].typ)) ||
|
|
3863
|
+
[exports.EnumToken.CommaTokenType, exports.EnumToken.GteTokenType, exports.EnumToken.LteTokenType, exports.EnumToken.ColumnCombinatorTokenType].includes(tokens[i + 1].typ)) ||
|
|
3284
3864
|
(i > 0 &&
|
|
3285
3865
|
// tokens[i + 1]?.typ != Literal ||
|
|
3286
3866
|
// funcLike.includes(tokens[i - 1].typ) &&
|
|
@@ -3297,15 +3877,18 @@ function parseTokens(tokens, options = {}) {
|
|
|
3297
3877
|
tokens[i + 1].typ = exports.EnumToken.PseudoClassFuncTokenType;
|
|
3298
3878
|
}
|
|
3299
3879
|
else if (typ == exports.EnumToken.IdenTokenType) {
|
|
3880
|
+
if (tokens[i + 1].val in webkitPseudoAliasMap) {
|
|
3881
|
+
tokens[i + 1].val = webkitPseudoAliasMap[tokens[i + 1].val];
|
|
3882
|
+
}
|
|
3300
3883
|
tokens[i + 1].val = ':' + tokens[i + 1].val;
|
|
3301
3884
|
tokens[i + 1].typ = exports.EnumToken.PseudoClassTokenType;
|
|
3302
3885
|
}
|
|
3303
3886
|
if (typ == exports.EnumToken.FunctionTokenType || typ == exports.EnumToken.IdenTokenType) {
|
|
3304
3887
|
tokens.splice(i, 1);
|
|
3305
3888
|
i--;
|
|
3306
|
-
continue;
|
|
3307
3889
|
}
|
|
3308
3890
|
}
|
|
3891
|
+
continue;
|
|
3309
3892
|
}
|
|
3310
3893
|
if (t.typ == exports.EnumToken.AttrStartTokenType) {
|
|
3311
3894
|
let k = i;
|
|
@@ -3326,21 +3909,114 @@ function parseTokens(tokens, options = {}) {
|
|
|
3326
3909
|
if (t.chi.at(-1).typ == exports.EnumToken.AttrEndTokenType) {
|
|
3327
3910
|
// @ts-ignore
|
|
3328
3911
|
t.chi.pop();
|
|
3912
|
+
}
|
|
3913
|
+
// @ts-ignore
|
|
3914
|
+
if (t.chi.length > 1) {
|
|
3915
|
+
/*(<AttrToken>t).chi =*/
|
|
3329
3916
|
// @ts-ignore
|
|
3330
|
-
|
|
3331
|
-
|
|
3917
|
+
parseTokens(t.chi, t.typ);
|
|
3918
|
+
}
|
|
3919
|
+
// @ts-ignore
|
|
3920
|
+
// t.chi.forEach(val => {
|
|
3921
|
+
// if (val.typ == EnumToken.StringTokenType) {
|
|
3922
|
+
// const slice = val.val.slice(1, -1);
|
|
3923
|
+
// if ((slice.charAt(0) != '-' || (slice.charAt(0) == '-' && isIdentStart(slice.charCodeAt(1)))) && isIdent(slice)) {
|
|
3924
|
+
// Object.assign(val, {typ: EnumToken.IdenTokenType, val: slice});
|
|
3925
|
+
// }
|
|
3926
|
+
// }
|
|
3927
|
+
// });
|
|
3928
|
+
let m = t.chi.length;
|
|
3929
|
+
let val;
|
|
3930
|
+
for (m = 0; m < t.chi.length; m++) {
|
|
3931
|
+
val = t.chi[m];
|
|
3932
|
+
if (val.typ == exports.EnumToken.StringTokenType) {
|
|
3933
|
+
const slice = val.val.slice(1, -1);
|
|
3934
|
+
if ((slice.charAt(0) != '-' || (slice.charAt(0) == '-' && isIdentStart(slice.charCodeAt(1)))) && isIdent(slice)) {
|
|
3935
|
+
Object.assign(val, { typ: exports.EnumToken.IdenTokenType, val: slice });
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
else if (val.typ == exports.EnumToken.LiteralTokenType && val.val == '|') {
|
|
3939
|
+
let upper = m;
|
|
3940
|
+
let lower = m;
|
|
3941
|
+
while (++upper < t.chi.length) {
|
|
3942
|
+
if (t.chi[upper].typ == exports.EnumToken.CommentTokenType) {
|
|
3943
|
+
continue;
|
|
3944
|
+
}
|
|
3945
|
+
break;
|
|
3946
|
+
}
|
|
3947
|
+
while (lower-- > 0) {
|
|
3948
|
+
if (t.chi[lower].typ == exports.EnumToken.CommentTokenType) {
|
|
3949
|
+
continue;
|
|
3950
|
+
}
|
|
3951
|
+
break;
|
|
3952
|
+
}
|
|
3332
3953
|
// @ts-ignore
|
|
3333
|
-
|
|
3954
|
+
t.chi[m] = {
|
|
3955
|
+
typ: exports.EnumToken.NameSpaceAttributeTokenType,
|
|
3956
|
+
l: t.chi[lower],
|
|
3957
|
+
r: t.chi[upper]
|
|
3958
|
+
};
|
|
3959
|
+
t.chi.splice(upper, 1);
|
|
3960
|
+
if (lower >= 0) {
|
|
3961
|
+
t.chi.splice(lower, 1);
|
|
3962
|
+
m--;
|
|
3963
|
+
}
|
|
3334
3964
|
}
|
|
3335
|
-
|
|
3336
|
-
|
|
3965
|
+
else if ([
|
|
3966
|
+
exports.EnumToken.DashMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.IncludeMatchTokenType
|
|
3967
|
+
].includes(t.chi[m].typ)) {
|
|
3968
|
+
let upper = m;
|
|
3969
|
+
let lower = m;
|
|
3970
|
+
while (++upper < t.chi.length) {
|
|
3971
|
+
if (t.chi[upper].typ == exports.EnumToken.CommentTokenType) {
|
|
3972
|
+
continue;
|
|
3973
|
+
}
|
|
3974
|
+
break;
|
|
3975
|
+
}
|
|
3976
|
+
while (lower-- > 0) {
|
|
3977
|
+
if (t.chi[lower].typ == exports.EnumToken.CommentTokenType) {
|
|
3978
|
+
continue;
|
|
3979
|
+
}
|
|
3980
|
+
break;
|
|
3981
|
+
}
|
|
3982
|
+
val = t.chi[lower];
|
|
3337
3983
|
if (val.typ == exports.EnumToken.StringTokenType) {
|
|
3338
3984
|
const slice = val.val.slice(1, -1);
|
|
3339
3985
|
if ((slice.charAt(0) != '-' || (slice.charAt(0) == '-' && isIdentStart(slice.charCodeAt(1)))) && isIdent(slice)) {
|
|
3340
3986
|
Object.assign(val, { typ: exports.EnumToken.IdenTokenType, val: slice });
|
|
3341
3987
|
}
|
|
3342
3988
|
}
|
|
3343
|
-
|
|
3989
|
+
val = t.chi[upper];
|
|
3990
|
+
if (val.typ == exports.EnumToken.StringTokenType) {
|
|
3991
|
+
const slice = val.val.slice(1, -1);
|
|
3992
|
+
if ((slice.charAt(0) != '-' || (slice.charAt(0) == '-' && isIdentStart(slice.charCodeAt(1)))) && isIdent(slice)) {
|
|
3993
|
+
Object.assign(val, { typ: exports.EnumToken.IdenTokenType, val: slice });
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
t.chi[m] = {
|
|
3997
|
+
typ: exports.EnumToken.MatchExpressionTokenType,
|
|
3998
|
+
op: t.chi[m].typ,
|
|
3999
|
+
l: t.chi[lower],
|
|
4000
|
+
r: t.chi[upper]
|
|
4001
|
+
};
|
|
4002
|
+
t.chi.splice(upper, 1);
|
|
4003
|
+
t.chi.splice(lower, 1);
|
|
4004
|
+
upper = m;
|
|
4005
|
+
m--;
|
|
4006
|
+
while (upper < t.chi.length && t.chi[upper].typ == exports.EnumToken.WhitespaceTokenType) {
|
|
4007
|
+
upper++;
|
|
4008
|
+
}
|
|
4009
|
+
if (upper < t.chi.length &&
|
|
4010
|
+
t.chi[upper].typ == exports.EnumToken.Iden &&
|
|
4011
|
+
['i', 's'].includes(t.chi[upper].val.toLowerCase())) {
|
|
4012
|
+
t.chi[m].attr = t.chi[upper].val;
|
|
4013
|
+
t.chi.splice(upper, 1);
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
m = t.chi.length;
|
|
4018
|
+
while (t.chi.at(-1)?.typ == exports.EnumToken.WhitespaceTokenType) {
|
|
4019
|
+
t.chi.pop();
|
|
3344
4020
|
}
|
|
3345
4021
|
continue;
|
|
3346
4022
|
}
|
|
@@ -3535,19 +4211,32 @@ function eq(a, b) {
|
|
|
3535
4211
|
return true;
|
|
3536
4212
|
}
|
|
3537
4213
|
|
|
3538
|
-
function* walk(node) {
|
|
4214
|
+
function* walk(node, filter) {
|
|
3539
4215
|
const parents = [node];
|
|
3540
4216
|
const root = node;
|
|
3541
4217
|
const weakMap = new WeakMap;
|
|
3542
4218
|
while (parents.length > 0) {
|
|
3543
4219
|
node = parents.shift();
|
|
4220
|
+
let option = null;
|
|
4221
|
+
if (filter != null) {
|
|
4222
|
+
option = filter(node);
|
|
4223
|
+
if (option === 'ignore') {
|
|
4224
|
+
continue;
|
|
4225
|
+
}
|
|
4226
|
+
if (option === 'stop') {
|
|
4227
|
+
break;
|
|
4228
|
+
}
|
|
4229
|
+
}
|
|
3544
4230
|
// @ts-ignore
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
4231
|
+
if (option !== 'children') {
|
|
4232
|
+
// @ts-ignore
|
|
4233
|
+
yield { node, parent: weakMap.get(node), root };
|
|
4234
|
+
}
|
|
4235
|
+
if (option !== 'ignore-children' && 'chi' in node) {
|
|
4236
|
+
parents.unshift(...node.chi);
|
|
4237
|
+
for (const child of node.chi.slice()) {
|
|
3548
4238
|
weakMap.set(child, node);
|
|
3549
4239
|
}
|
|
3550
|
-
parents.unshift(...node.chi);
|
|
3551
4240
|
}
|
|
3552
4241
|
}
|
|
3553
4242
|
}
|
|
@@ -3570,12 +4259,12 @@ function* walkValues(values) {
|
|
|
3570
4259
|
|
|
3571
4260
|
function expand(ast) {
|
|
3572
4261
|
//
|
|
3573
|
-
if (![
|
|
4262
|
+
if (![exports.EnumToken.RuleNodeType, exports.EnumToken.StyleSheetNodeType, exports.EnumToken.AtRuleNodeType].includes(ast.typ)) {
|
|
3574
4263
|
return ast;
|
|
3575
4264
|
}
|
|
3576
|
-
if (
|
|
4265
|
+
if (exports.EnumToken.RuleNodeType == ast.typ) {
|
|
3577
4266
|
return {
|
|
3578
|
-
typ:
|
|
4267
|
+
typ: exports.EnumToken.StyleSheetNodeType,
|
|
3579
4268
|
chi: expandRule(ast)
|
|
3580
4269
|
};
|
|
3581
4270
|
}
|
|
@@ -3587,16 +4276,16 @@ function expand(ast) {
|
|
|
3587
4276
|
for (let i = 0; i < ast.chi.length; i++) {
|
|
3588
4277
|
// @ts-ignore
|
|
3589
4278
|
const node = ast.chi[i];
|
|
3590
|
-
if (node.typ ==
|
|
4279
|
+
if (node.typ == exports.EnumToken.RuleNodeType) {
|
|
3591
4280
|
// @ts-ignore
|
|
3592
4281
|
result.chi.push(...expandRule(node));
|
|
3593
4282
|
// i += expanded.length - 1;
|
|
3594
4283
|
}
|
|
3595
|
-
else if (node.typ ==
|
|
4284
|
+
else if (node.typ == exports.EnumToken.AtRuleNodeType && 'chi' in node) {
|
|
3596
4285
|
let hasRule = false;
|
|
3597
4286
|
let j = node.chi.length;
|
|
3598
4287
|
while (j--) {
|
|
3599
|
-
if (node.chi[j].typ ==
|
|
4288
|
+
if (node.chi[j].typ == exports.EnumToken.RuleNodeType || node.chi[j].typ == exports.EnumToken.AtRuleNodeType) {
|
|
3600
4289
|
hasRule = true;
|
|
3601
4290
|
break;
|
|
3602
4291
|
}
|
|
@@ -3614,10 +4303,10 @@ function expand(ast) {
|
|
|
3614
4303
|
function expandRule(node) {
|
|
3615
4304
|
const ast = { ...node, chi: node.chi.slice() };
|
|
3616
4305
|
const result = [];
|
|
3617
|
-
if (ast.typ ==
|
|
4306
|
+
if (ast.typ == exports.EnumToken.RuleNodeType) {
|
|
3618
4307
|
let i = 0;
|
|
3619
4308
|
for (; i < ast.chi.length; i++) {
|
|
3620
|
-
if (ast.chi[i].typ ==
|
|
4309
|
+
if (ast.chi[i].typ == exports.EnumToken.RuleNodeType) {
|
|
3621
4310
|
const rule = ast.chi[i];
|
|
3622
4311
|
if (!rule.sel.includes('&')) {
|
|
3623
4312
|
const selRule = splitRule(rule.sel);
|
|
@@ -3633,7 +4322,7 @@ function expandRule(node) {
|
|
|
3633
4322
|
ast.chi.splice(i--, 1);
|
|
3634
4323
|
result.push(...expandRule(rule));
|
|
3635
4324
|
}
|
|
3636
|
-
else if (ast.chi[i].typ ==
|
|
4325
|
+
else if (ast.chi[i].typ == exports.EnumToken.AtRuleNodeType) {
|
|
3637
4326
|
let astAtRule = ast.chi[i];
|
|
3638
4327
|
const values = [];
|
|
3639
4328
|
if (astAtRule.nam == 'scope') {
|
|
@@ -3648,7 +4337,7 @@ function expandRule(node) {
|
|
|
3648
4337
|
// @ts-ignore
|
|
3649
4338
|
astAtRule.chi.length = 0;
|
|
3650
4339
|
for (const r of expandRule(clone)) {
|
|
3651
|
-
if (r.typ ==
|
|
4340
|
+
if (r.typ == exports.EnumToken.AtRuleNodeType && 'chi' in r) {
|
|
3652
4341
|
if (astAtRule.val !== '' && r.val !== '') {
|
|
3653
4342
|
if (astAtRule.nam == 'media' && r.nam == 'media') {
|
|
3654
4343
|
r.val = astAtRule.val + ' and ' + r.val;
|
|
@@ -3660,7 +4349,7 @@ function expandRule(node) {
|
|
|
3660
4349
|
// @ts-ignore
|
|
3661
4350
|
values.push(r);
|
|
3662
4351
|
}
|
|
3663
|
-
else if (r.typ ==
|
|
4352
|
+
else if (r.typ == exports.EnumToken.RuleNodeType) {
|
|
3664
4353
|
// @ts-ignore
|
|
3665
4354
|
astAtRule.chi.push(...expandRule(r));
|
|
3666
4355
|
}
|
|
@@ -3720,6 +4409,128 @@ class MinifyFeature {
|
|
|
3720
4409
|
}
|
|
3721
4410
|
}
|
|
3722
4411
|
|
|
4412
|
+
class IterableWeakSet {
|
|
4413
|
+
#weakset = new WeakSet;
|
|
4414
|
+
#set = new Set;
|
|
4415
|
+
constructor(iterable) {
|
|
4416
|
+
if (iterable) {
|
|
4417
|
+
for (const value of iterable) {
|
|
4418
|
+
const ref = new WeakRef(value);
|
|
4419
|
+
this.#weakset.add(value);
|
|
4420
|
+
this.#set.add(ref);
|
|
4421
|
+
}
|
|
4422
|
+
}
|
|
4423
|
+
}
|
|
4424
|
+
has(value) {
|
|
4425
|
+
return this.#weakset.has(value);
|
|
4426
|
+
}
|
|
4427
|
+
delete(value) {
|
|
4428
|
+
if (this.#weakset.has(value)) {
|
|
4429
|
+
for (const ref of this.#set) {
|
|
4430
|
+
if (ref.deref() === value) {
|
|
4431
|
+
this.#set.delete(ref);
|
|
4432
|
+
break;
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
return this.#weakset.delete(value);
|
|
4436
|
+
}
|
|
4437
|
+
return false;
|
|
4438
|
+
}
|
|
4439
|
+
add(value) {
|
|
4440
|
+
if (!this.#weakset.has(value)) {
|
|
4441
|
+
this.#weakset.add(value);
|
|
4442
|
+
this.#set.add(new WeakRef(value));
|
|
4443
|
+
}
|
|
4444
|
+
return this;
|
|
4445
|
+
}
|
|
4446
|
+
*[Symbol.iterator]() {
|
|
4447
|
+
for (const ref of new Set(this.#set)) {
|
|
4448
|
+
const key = ref.deref();
|
|
4449
|
+
if (key != null) {
|
|
4450
|
+
yield key;
|
|
4451
|
+
}
|
|
4452
|
+
else {
|
|
4453
|
+
this.#set.delete(ref);
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
}
|
|
4457
|
+
}
|
|
4458
|
+
|
|
4459
|
+
class IterableWeakMap {
|
|
4460
|
+
#map;
|
|
4461
|
+
#set;
|
|
4462
|
+
constructor(iterable) {
|
|
4463
|
+
this.#map = new WeakMap;
|
|
4464
|
+
this.#set = new Set;
|
|
4465
|
+
if (iterable) {
|
|
4466
|
+
for (const [key, value] of iterable) {
|
|
4467
|
+
const ref = new WeakRef(key);
|
|
4468
|
+
this.#set.add(ref);
|
|
4469
|
+
this.#map.set(key, value);
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
}
|
|
4473
|
+
has(key) {
|
|
4474
|
+
return this.#map.has(key);
|
|
4475
|
+
}
|
|
4476
|
+
set(key, value) {
|
|
4477
|
+
if (!this.#map.has(key)) {
|
|
4478
|
+
this.#set.add(new WeakRef(key));
|
|
4479
|
+
}
|
|
4480
|
+
this.#map.set(key, value);
|
|
4481
|
+
return this;
|
|
4482
|
+
}
|
|
4483
|
+
get(key) {
|
|
4484
|
+
return this.#map.get(key);
|
|
4485
|
+
}
|
|
4486
|
+
delete(key) {
|
|
4487
|
+
if (this.#map.has(key)) {
|
|
4488
|
+
for (const ref of this.#set) {
|
|
4489
|
+
if (ref.deref() === key) {
|
|
4490
|
+
this.#set.delete(ref);
|
|
4491
|
+
break;
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
return this.#map.delete(key);
|
|
4495
|
+
}
|
|
4496
|
+
return false;
|
|
4497
|
+
}
|
|
4498
|
+
*[Symbol.iterator]() {
|
|
4499
|
+
for (const ref of new Set(this.#set)) {
|
|
4500
|
+
const key = ref.deref();
|
|
4501
|
+
if (key == null) {
|
|
4502
|
+
this.#set.delete(ref);
|
|
4503
|
+
continue;
|
|
4504
|
+
}
|
|
4505
|
+
// @ts-ignore
|
|
4506
|
+
yield [key, this.#map.get(key)];
|
|
4507
|
+
}
|
|
4508
|
+
}
|
|
4509
|
+
}
|
|
4510
|
+
|
|
4511
|
+
function replace(node, variableScope) {
|
|
4512
|
+
for (const { value, parent: parentValue } of walkValues(node.val)) {
|
|
4513
|
+
if (value?.typ == exports.EnumToken.FunctionTokenType && value.val == 'var') {
|
|
4514
|
+
if (value.chi.length == 1 && value.chi[0].typ == exports.EnumToken.DashedIdenTokenType) {
|
|
4515
|
+
const info = variableScope.get(value.chi[0].val);
|
|
4516
|
+
if (info?.replaceable) {
|
|
4517
|
+
if (parentValue != null) {
|
|
4518
|
+
let i = 0;
|
|
4519
|
+
for (; i < parentValue.chi.length; i++) {
|
|
4520
|
+
if (parentValue.chi[i] == value) {
|
|
4521
|
+
parentValue.chi.splice(i, 1, ...info.node.val);
|
|
4522
|
+
break;
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
}
|
|
4526
|
+
else {
|
|
4527
|
+
node.val = info.node.val.slice();
|
|
4528
|
+
}
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
}
|
|
4532
|
+
}
|
|
4533
|
+
}
|
|
3723
4534
|
class InlineCssVariables extends MinifyFeature {
|
|
3724
4535
|
static get ordering() {
|
|
3725
4536
|
return 0;
|
|
@@ -3739,14 +4550,14 @@ class InlineCssVariables extends MinifyFeature {
|
|
|
3739
4550
|
if (!('variableScope' in context)) {
|
|
3740
4551
|
context.variableScope = new Map;
|
|
3741
4552
|
}
|
|
3742
|
-
const isRoot = parent.typ ==
|
|
4553
|
+
const isRoot = parent.typ == exports.EnumToken.StyleSheetNodeType && ast.typ == exports.EnumToken.RuleNodeType && ast.sel == ':root';
|
|
3743
4554
|
const variableScope = context.variableScope;
|
|
3744
4555
|
// @ts-ignore
|
|
3745
4556
|
for (const node of ast.chi) {
|
|
3746
|
-
if (node.typ ==
|
|
4557
|
+
if (node.typ == exports.EnumToken.CDOCOMMNodeType || node.typ == exports.EnumToken.CommentNodeType) {
|
|
3747
4558
|
continue;
|
|
3748
4559
|
}
|
|
3749
|
-
if (node.typ !=
|
|
4560
|
+
if (node.typ != exports.EnumToken.DeclarationNodeType) {
|
|
3750
4561
|
break;
|
|
3751
4562
|
}
|
|
3752
4563
|
// css variable
|
|
@@ -3755,13 +4566,23 @@ class InlineCssVariables extends MinifyFeature {
|
|
|
3755
4566
|
const info = {
|
|
3756
4567
|
globalScope: isRoot,
|
|
3757
4568
|
// @ts-ignore
|
|
3758
|
-
parent: new
|
|
4569
|
+
parent: new IterableWeakSet(),
|
|
3759
4570
|
declarationCount: 1,
|
|
3760
4571
|
replaceable: isRoot,
|
|
3761
4572
|
node: node
|
|
3762
4573
|
};
|
|
3763
4574
|
info.parent.add(ast);
|
|
3764
4575
|
variableScope.set(node.nam, info);
|
|
4576
|
+
let recursive = false;
|
|
4577
|
+
for (const { value, parent: parentValue } of walkValues(node.val)) {
|
|
4578
|
+
if (value?.typ == exports.EnumToken.FunctionTokenType && value.val == 'var') {
|
|
4579
|
+
recursive = true;
|
|
4580
|
+
break;
|
|
4581
|
+
}
|
|
4582
|
+
}
|
|
4583
|
+
if (recursive) {
|
|
4584
|
+
replace(node, variableScope);
|
|
4585
|
+
}
|
|
3765
4586
|
}
|
|
3766
4587
|
else {
|
|
3767
4588
|
const info = variableScope.get(node.nam);
|
|
@@ -3777,27 +4598,7 @@ class InlineCssVariables extends MinifyFeature {
|
|
|
3777
4598
|
}
|
|
3778
4599
|
}
|
|
3779
4600
|
else {
|
|
3780
|
-
|
|
3781
|
-
if (value?.typ == exports.EnumToken.FunctionTokenType && value.val == 'var') {
|
|
3782
|
-
if (value.chi.length == 1 && value.chi[0].typ == exports.EnumToken.IdenTokenType) {
|
|
3783
|
-
const info = variableScope.get(value.chi[0].val);
|
|
3784
|
-
if (info?.replaceable) {
|
|
3785
|
-
if (parentValue != null) {
|
|
3786
|
-
let i = 0;
|
|
3787
|
-
for (; i < parentValue.chi.length; i++) {
|
|
3788
|
-
if (parentValue.chi[i] == value) {
|
|
3789
|
-
parentValue.chi.splice(i, 1, ...info.node.val);
|
|
3790
|
-
break;
|
|
3791
|
-
}
|
|
3792
|
-
}
|
|
3793
|
-
}
|
|
3794
|
-
else {
|
|
3795
|
-
node.val = info.node.val.slice();
|
|
3796
|
-
}
|
|
3797
|
-
}
|
|
3798
|
-
}
|
|
3799
|
-
}
|
|
3800
|
-
}
|
|
4601
|
+
replace(node, variableScope);
|
|
3801
4602
|
}
|
|
3802
4603
|
}
|
|
3803
4604
|
}
|
|
@@ -3806,10 +4607,11 @@ class InlineCssVariables extends MinifyFeature {
|
|
|
3806
4607
|
for (const info of variableScope.values()) {
|
|
3807
4608
|
if (info.replaceable) {
|
|
3808
4609
|
let i;
|
|
4610
|
+
// drop declarations from :root{}
|
|
3809
4611
|
for (const parent of info.parent) {
|
|
3810
4612
|
i = parent.chi?.length ?? 0;
|
|
3811
4613
|
while (i--) {
|
|
3812
|
-
if (parent.chi[i].typ ==
|
|
4614
|
+
if (parent.chi[i].typ == exports.EnumToken.DeclarationNodeType && parent.chi[i].nam == info.node.nam) {
|
|
3813
4615
|
parent.chi.splice(i, 1);
|
|
3814
4616
|
}
|
|
3815
4617
|
}
|
|
@@ -3884,7 +4686,7 @@ class PropertySet {
|
|
|
3884
4686
|
this.config.properties.forEach((property, index) => {
|
|
3885
4687
|
if (!this.declarations.has(property)) {
|
|
3886
4688
|
this.declarations.set(property, {
|
|
3887
|
-
typ:
|
|
4689
|
+
typ: exports.EnumToken.DeclarationNodeType,
|
|
3888
4690
|
nam: property,
|
|
3889
4691
|
val: []
|
|
3890
4692
|
});
|
|
@@ -3963,7 +4765,7 @@ class PropertySet {
|
|
|
3963
4765
|
}
|
|
3964
4766
|
}
|
|
3965
4767
|
iterator = [{
|
|
3966
|
-
typ:
|
|
4768
|
+
typ: exports.EnumToken.DeclarationNodeType,
|
|
3967
4769
|
nam: this.config.shorthand,
|
|
3968
4770
|
val: values.reduce((acc, curr) => {
|
|
3969
4771
|
if (curr.length > 1) {
|
|
@@ -3998,6 +4800,7 @@ class PropertySet {
|
|
|
3998
4800
|
}
|
|
3999
4801
|
}
|
|
4000
4802
|
|
|
4803
|
+
const cache = new IterableWeakMap();
|
|
4001
4804
|
const propertiesConfig = getConfig();
|
|
4002
4805
|
class PropertyMap {
|
|
4003
4806
|
config;
|
|
@@ -4118,7 +4921,7 @@ class PropertyMap {
|
|
|
4118
4921
|
if (values.length == 0) {
|
|
4119
4922
|
this.declarations = Object.entries(tokens).reduce((acc, curr) => {
|
|
4120
4923
|
acc.set(curr[0], {
|
|
4121
|
-
typ:
|
|
4924
|
+
typ: exports.EnumToken.DeclarationNodeType,
|
|
4122
4925
|
nam: curr[0],
|
|
4123
4926
|
val: curr[1].reduce((acc, curr) => {
|
|
4124
4927
|
if (acc.length > 0) {
|
|
@@ -4182,6 +4985,44 @@ class PropertyMap {
|
|
|
4182
4985
|
requiredCount = this.declarations.size;
|
|
4183
4986
|
}
|
|
4184
4987
|
if (!isShorthand || requiredCount < this.requiredCount) {
|
|
4988
|
+
if (isShorthand && this.declarations.has(this.config.shorthand)) {
|
|
4989
|
+
// console.debug(...this.declarations.values());
|
|
4990
|
+
const removeDefaults = (declaration) => {
|
|
4991
|
+
// const dec: AstDeclaration = {...declaration};
|
|
4992
|
+
const config = this.config.shorthand == declaration.nam ? this.config : this.config.properties[declaration.nam];
|
|
4993
|
+
declaration.val = declaration.val.filter((val) => {
|
|
4994
|
+
if (!cache.has(val)) {
|
|
4995
|
+
cache.set(val, renderToken(val, { minify: true }));
|
|
4996
|
+
}
|
|
4997
|
+
return !config.default.includes(cache.get(val));
|
|
4998
|
+
})
|
|
4999
|
+
.filter((val, index, array) => !(index > 0 &&
|
|
5000
|
+
val.typ == exports.EnumToken.WhitespaceTokenType &&
|
|
5001
|
+
array[index - 1].typ == exports.EnumToken.WhitespaceTokenType));
|
|
5002
|
+
if (declaration.val.at(-1)?.typ == exports.EnumToken.WhitespaceTokenType) {
|
|
5003
|
+
declaration.val.pop();
|
|
5004
|
+
}
|
|
5005
|
+
return declaration;
|
|
5006
|
+
};
|
|
5007
|
+
const values = [...this.declarations.values()].reduce((acc, curr) => {
|
|
5008
|
+
if (curr instanceof PropertySet) {
|
|
5009
|
+
acc.push(...curr);
|
|
5010
|
+
}
|
|
5011
|
+
else {
|
|
5012
|
+
acc.push(curr);
|
|
5013
|
+
}
|
|
5014
|
+
return acc;
|
|
5015
|
+
}, []);
|
|
5016
|
+
const filtered = values.map(removeDefaults).filter((x) => x.val.length > 0);
|
|
5017
|
+
if (filtered.length == 0 && this.config.default.length > 0) {
|
|
5018
|
+
filtered.push({
|
|
5019
|
+
typ: exports.EnumToken.DeclarationNodeType,
|
|
5020
|
+
nam: this.config.shorthand,
|
|
5021
|
+
val: parseString(this.config.default[0])
|
|
5022
|
+
});
|
|
5023
|
+
}
|
|
5024
|
+
return (filtered.length > 0 ? filtered : values)[Symbol.iterator]();
|
|
5025
|
+
}
|
|
4185
5026
|
// @ts-ignore
|
|
4186
5027
|
iterable = this.declarations.values();
|
|
4187
5028
|
}
|
|
@@ -4194,7 +5035,6 @@ class PropertyMap {
|
|
|
4194
5035
|
} : null;
|
|
4195
5036
|
const tokens = {};
|
|
4196
5037
|
// @ts-ignore
|
|
4197
|
-
/* const valid: string[] =*/
|
|
4198
5038
|
Object.entries(this.config.properties).reduce((acc, curr) => {
|
|
4199
5039
|
if (!this.declarations.has(curr[0])) {
|
|
4200
5040
|
if (curr[1].required) {
|
|
@@ -4260,7 +5100,7 @@ class PropertyMap {
|
|
|
4260
5100
|
iterable = this.declarations.values();
|
|
4261
5101
|
}
|
|
4262
5102
|
else {
|
|
4263
|
-
|
|
5103
|
+
let values = Object.entries(tokens).reduce((acc, curr) => {
|
|
4264
5104
|
const props = this.config.properties[curr[0]];
|
|
4265
5105
|
for (let i = 0; i < curr[1].length; i++) {
|
|
4266
5106
|
if (acc.length == i) {
|
|
@@ -4277,6 +5117,7 @@ class PropertyMap {
|
|
|
4277
5117
|
if (props.default.includes(curr[1][i].reduce((acc, curr) => acc + renderToken(curr) + ' ', '').trimEnd())) {
|
|
4278
5118
|
continue;
|
|
4279
5119
|
}
|
|
5120
|
+
// remove default values
|
|
4280
5121
|
let doFilterDefault = true;
|
|
4281
5122
|
if (curr[0] in propertiesConfig.properties) {
|
|
4282
5123
|
for (let v of values) {
|
|
@@ -4349,7 +5190,7 @@ class PropertyMap {
|
|
|
4349
5190
|
return acc;
|
|
4350
5191
|
}, []);
|
|
4351
5192
|
if (this.config.mapping != null) {
|
|
4352
|
-
const val = values.reduce((acc, curr) => acc + renderToken(curr, { removeComments: true }), '');
|
|
5193
|
+
const val = values.reduce((acc, curr) => acc + renderToken(curr, { removeComments: true, minify: true }), '');
|
|
4353
5194
|
if (val in this.config.mapping) {
|
|
4354
5195
|
values.length = 0;
|
|
4355
5196
|
values.push({
|
|
@@ -4359,8 +5200,16 @@ class PropertyMap {
|
|
|
4359
5200
|
});
|
|
4360
5201
|
}
|
|
4361
5202
|
}
|
|
5203
|
+
// @ts-ignore
|
|
5204
|
+
if (values.length == 1 &&
|
|
5205
|
+
typeof values[0].val == 'string' &&
|
|
5206
|
+
this.config.default.includes(values[0].val.toLowerCase()) &&
|
|
5207
|
+
this.config.default[0] != values[0].val.toLowerCase()) {
|
|
5208
|
+
// @ts-ignore/
|
|
5209
|
+
values = parseString(this.config.default[0]);
|
|
5210
|
+
}
|
|
4362
5211
|
iterable = [{
|
|
4363
|
-
typ:
|
|
5212
|
+
typ: exports.EnumToken.DeclarationNodeType,
|
|
4364
5213
|
nam: this.config.shorthand,
|
|
4365
5214
|
val: values
|
|
4366
5215
|
}][Symbol.iterator]();
|
|
@@ -4409,10 +5258,10 @@ class PropertyList {
|
|
|
4409
5258
|
this.declarations = new Map;
|
|
4410
5259
|
}
|
|
4411
5260
|
set(nam, value) {
|
|
4412
|
-
return this.add({ typ:
|
|
5261
|
+
return this.add({ typ: exports.EnumToken.DeclarationNodeType, nam, val: Array.isArray(value) ? value : parseString(String(value)) });
|
|
4413
5262
|
}
|
|
4414
5263
|
add(declaration) {
|
|
4415
|
-
if (declaration.typ !=
|
|
5264
|
+
if (declaration.typ != exports.EnumToken.DeclarationNodeType || !this.options.removeDuplicateDeclarations) {
|
|
4416
5265
|
this.declarations.set(Number(Math.random().toString().slice(2)).toString(36), declaration);
|
|
4417
5266
|
return this;
|
|
4418
5267
|
}
|
|
@@ -4519,7 +5368,7 @@ class ComputeShorthand extends MinifyFeature {
|
|
|
4519
5368
|
for (; k < j; k++) {
|
|
4520
5369
|
// @ts-ignore
|
|
4521
5370
|
const node = ast.chi[k];
|
|
4522
|
-
if (node.typ ==
|
|
5371
|
+
if (node.typ == exports.EnumToken.CommentNodeType || node.typ == exports.EnumToken.DeclarationNodeType) {
|
|
4523
5372
|
properties.add(node);
|
|
4524
5373
|
continue;
|
|
4525
5374
|
}
|
|
@@ -4531,6 +5380,97 @@ class ComputeShorthand extends MinifyFeature {
|
|
|
4531
5380
|
}
|
|
4532
5381
|
}
|
|
4533
5382
|
|
|
5383
|
+
const gcd = (x, y) => {
|
|
5384
|
+
x = Math.abs(x);
|
|
5385
|
+
y = Math.abs(y);
|
|
5386
|
+
let t;
|
|
5387
|
+
if (x == 0 || y == 0) {
|
|
5388
|
+
return 1;
|
|
5389
|
+
}
|
|
5390
|
+
while (y) {
|
|
5391
|
+
t = y;
|
|
5392
|
+
y = x % y;
|
|
5393
|
+
x = t;
|
|
5394
|
+
}
|
|
5395
|
+
return x;
|
|
5396
|
+
};
|
|
5397
|
+
function compute(a, b, op) {
|
|
5398
|
+
if (typeof a == 'number' && typeof b == 'number') {
|
|
5399
|
+
switch (op) {
|
|
5400
|
+
case exports.EnumToken.Add:
|
|
5401
|
+
return a + b;
|
|
5402
|
+
case exports.EnumToken.Sub:
|
|
5403
|
+
return a - b;
|
|
5404
|
+
case exports.EnumToken.Mul:
|
|
5405
|
+
return a * b;
|
|
5406
|
+
case exports.EnumToken.Div:
|
|
5407
|
+
const r = simplify(a, b);
|
|
5408
|
+
if (r[1] == 1) {
|
|
5409
|
+
return r[0];
|
|
5410
|
+
}
|
|
5411
|
+
const result = a / b;
|
|
5412
|
+
const r2 = reduceNumber(r[0]) + '/' + reduceNumber(r[1]);
|
|
5413
|
+
return reduceNumber(result).length <= r2.length ? result : {
|
|
5414
|
+
typ: exports.EnumToken.FractionTokenType,
|
|
5415
|
+
l: { typ: exports.EnumToken.NumberTokenType, val: reduceNumber(r[0]) },
|
|
5416
|
+
r: { typ: exports.EnumToken.NumberTokenType, val: reduceNumber(r[1]) }
|
|
5417
|
+
};
|
|
5418
|
+
}
|
|
5419
|
+
}
|
|
5420
|
+
let l1 = typeof a == 'number' ? {
|
|
5421
|
+
typ: exports.EnumToken.FractionTokenType,
|
|
5422
|
+
l: { typ: exports.EnumToken.NumberTokenType, val: reduceNumber(a) },
|
|
5423
|
+
r: { typ: exports.EnumToken.NumberTokenType, val: '1' }
|
|
5424
|
+
} : a;
|
|
5425
|
+
let r1 = typeof b == 'number' ? {
|
|
5426
|
+
typ: exports.EnumToken.FractionTokenType,
|
|
5427
|
+
l: { typ: exports.EnumToken.NumberTokenType, val: reduceNumber(b) },
|
|
5428
|
+
r: { typ: exports.EnumToken.NumberTokenType, val: '1' }
|
|
5429
|
+
} : b;
|
|
5430
|
+
let l2;
|
|
5431
|
+
let r2;
|
|
5432
|
+
switch (op) {
|
|
5433
|
+
case exports.EnumToken.Add:
|
|
5434
|
+
// @ts-ignore
|
|
5435
|
+
l2 = l1.l.val * r1.r.val + l1.r.val * r1.l.val;
|
|
5436
|
+
// @ts-ignore
|
|
5437
|
+
r2 = l1.r.val * r1.r.val;
|
|
5438
|
+
break;
|
|
5439
|
+
case exports.EnumToken.Sub:
|
|
5440
|
+
// @ts-ignore
|
|
5441
|
+
l2 = l1.l.val * r1.r.val - l1.r.val * r1.l.val;
|
|
5442
|
+
// @ts-ignore
|
|
5443
|
+
r2 = l1.r.val * r1.r.val;
|
|
5444
|
+
break;
|
|
5445
|
+
case exports.EnumToken.Mul:
|
|
5446
|
+
// @ts-ignore
|
|
5447
|
+
l2 = l1.l.val * r1.l.val;
|
|
5448
|
+
// @ts-ignore
|
|
5449
|
+
r2 = l1.r.val * r1.r.val;
|
|
5450
|
+
break;
|
|
5451
|
+
case exports.EnumToken.Div:
|
|
5452
|
+
// @ts-ignore
|
|
5453
|
+
l2 = l1.l.val * r1.r.val;
|
|
5454
|
+
// @ts-ignore
|
|
5455
|
+
r2 = l1.r.val * r1.l.val;
|
|
5456
|
+
break;
|
|
5457
|
+
}
|
|
5458
|
+
const a2 = simplify(l2, r2);
|
|
5459
|
+
if (a2[1] == 1) {
|
|
5460
|
+
return a2[0];
|
|
5461
|
+
}
|
|
5462
|
+
const result = a2[0] / a2[1];
|
|
5463
|
+
return reduceNumber(result).length <= reduceNumber(a2[0]).length + 1 + reduceNumber(a2[1]).length ? result : {
|
|
5464
|
+
typ: exports.EnumToken.FractionTokenType,
|
|
5465
|
+
l: { typ: exports.EnumToken.NumberTokenType, val: reduceNumber(a2[0]) },
|
|
5466
|
+
r: { typ: exports.EnumToken.NumberTokenType, val: reduceNumber(a2[1]) }
|
|
5467
|
+
};
|
|
5468
|
+
}
|
|
5469
|
+
function simplify(a, b) {
|
|
5470
|
+
const g = gcd(a, b);
|
|
5471
|
+
return g > 1 ? [a / g, b / g] : [a, b];
|
|
5472
|
+
}
|
|
5473
|
+
|
|
4534
5474
|
class ComputeCalcExpression extends MinifyFeature {
|
|
4535
5475
|
static get ordering() {
|
|
4536
5476
|
return 1;
|
|
@@ -4552,10 +5492,10 @@ class ComputeCalcExpression extends MinifyFeature {
|
|
|
4552
5492
|
}
|
|
4553
5493
|
// @ts-ignore
|
|
4554
5494
|
for (const node of ast.chi) {
|
|
4555
|
-
if (node.typ !=
|
|
5495
|
+
if (node.typ != exports.EnumToken.DeclarationNodeType) {
|
|
4556
5496
|
continue;
|
|
4557
5497
|
}
|
|
4558
|
-
const set = new
|
|
5498
|
+
const set = new IterableWeakSet;
|
|
4559
5499
|
for (const { parent } of walkValues(node.val)) {
|
|
4560
5500
|
if (parent != null && parent.typ == exports.EnumToken.FunctionTokenType && parent.val == 'calc') {
|
|
4561
5501
|
if (!set.has(parent)) {
|
|
@@ -4586,39 +5526,14 @@ function doEvaluate(l, r, op) {
|
|
|
4586
5526
|
}
|
|
4587
5527
|
if ((op == exports.EnumToken.Add || op == exports.EnumToken.Sub)) {
|
|
4588
5528
|
// @ts-ignore
|
|
4589
|
-
if (l.typ != r.typ
|
|
5529
|
+
if (l.typ != r.typ) {
|
|
4590
5530
|
return defaultReturn;
|
|
4591
5531
|
}
|
|
4592
|
-
// @ts-ignore
|
|
4593
|
-
return { ...l, val: reduceNumber(+l.val + (op == exports.EnumToken.Add ? +r.val : -1 * r.val)) };
|
|
4594
|
-
}
|
|
4595
|
-
else {
|
|
4596
|
-
// @ts-ignore
|
|
4597
|
-
let val;
|
|
4598
|
-
if (op == exports.EnumToken.Div) {
|
|
4599
|
-
if (r.typ != exports.EnumToken.NumberTokenType || r.val == '0') {
|
|
4600
|
-
return defaultReturn;
|
|
4601
|
-
}
|
|
4602
|
-
// @ts-ignore
|
|
4603
|
-
val = reduceNumber(l.val / r.val);
|
|
4604
|
-
}
|
|
4605
|
-
else {
|
|
4606
|
-
// @ts-ignore
|
|
4607
|
-
val = reduceNumber(r.val * l.val);
|
|
4608
|
-
}
|
|
4609
|
-
let result;
|
|
4610
|
-
if (r.typ == exports.EnumToken.NumberTokenType || op == exports.EnumToken.Div) {
|
|
4611
|
-
result = { ...l, val };
|
|
4612
|
-
}
|
|
4613
|
-
else {
|
|
4614
|
-
// @ts-ignore
|
|
4615
|
-
result = { ...r, val };
|
|
4616
|
-
}
|
|
4617
|
-
if (renderToken(result).length <= renderToken(defaultReturn).length) {
|
|
4618
|
-
return result;
|
|
4619
|
-
}
|
|
4620
5532
|
}
|
|
4621
|
-
|
|
5533
|
+
const typ = l.typ == exports.EnumToken.NumberTokenType ? r.typ : l.typ;
|
|
5534
|
+
// @ts-ignore
|
|
5535
|
+
const val = compute(typeof l.val == 'string' ? +l.val : l.val, typeof r.val == 'string' ? +r.val : r.val, op);
|
|
5536
|
+
return { ...(l.typ == exports.EnumToken.NumberTokenType ? r : l), typ, val: typeof val == 'number' ? reduceNumber(val) : val };
|
|
4622
5537
|
}
|
|
4623
5538
|
/**
|
|
4624
5539
|
* evaluate an array of tokens
|
|
@@ -4674,7 +5589,10 @@ function evaluate(tokens) {
|
|
|
4674
5589
|
*/
|
|
4675
5590
|
function inlineExpression(token) {
|
|
4676
5591
|
const result = [];
|
|
4677
|
-
if (token.typ == exports.EnumToken.
|
|
5592
|
+
if (token.typ == exports.EnumToken.ParensTokenType && token.chi.length == 1) {
|
|
5593
|
+
result.push(token.chi[0]);
|
|
5594
|
+
}
|
|
5595
|
+
else if (token.typ == exports.EnumToken.BinaryExpressionTokenType) {
|
|
4678
5596
|
if ([exports.EnumToken.Mul, exports.EnumToken.Div].includes(token.op)) {
|
|
4679
5597
|
result.push(token);
|
|
4680
5598
|
}
|
|
@@ -4701,18 +5619,7 @@ function evaluateExpression(token) {
|
|
|
4701
5619
|
if (token.l.typ == exports.EnumToken.BinaryExpressionTokenType) {
|
|
4702
5620
|
token.l = evaluateExpression(token.l);
|
|
4703
5621
|
}
|
|
4704
|
-
|
|
4705
|
-
if (result.typ == exports.EnumToken.BinaryExpressionTokenType &&
|
|
4706
|
-
[exports.EnumToken.Mul, exports.EnumToken.Div].includes(result.op)) {
|
|
4707
|
-
// wrap expression
|
|
4708
|
-
if (result.l.typ == exports.EnumToken.BinaryExpressionTokenType && [exports.EnumToken.Sub, exports.EnumToken.Add].includes(result.l.op)) {
|
|
4709
|
-
result.l = { typ: exports.EnumToken.ParensTokenType, chi: [result.l] };
|
|
4710
|
-
}
|
|
4711
|
-
else if (result.r.typ == exports.EnumToken.BinaryExpressionTokenType && [exports.EnumToken.Sub, exports.EnumToken.Add].includes(result.r.op)) {
|
|
4712
|
-
result.r = { typ: exports.EnumToken.ParensTokenType, chi: [result.r] };
|
|
4713
|
-
}
|
|
4714
|
-
}
|
|
4715
|
-
return result;
|
|
5622
|
+
return doEvaluate(token.l, token.r, token.op);
|
|
4716
5623
|
}
|
|
4717
5624
|
function isScalarToken(token) {
|
|
4718
5625
|
return token.typ != exports.EnumToken.BinaryExpressionTokenType && token.typ != exports.EnumToken.ParensTokenType && token.typ != exports.EnumToken.FunctionTokenType;
|
|
@@ -4760,7 +5667,7 @@ function factorToken(token) {
|
|
|
4760
5667
|
*/
|
|
4761
5668
|
function factor(tokens, ops) {
|
|
4762
5669
|
let isOp;
|
|
4763
|
-
const opList =
|
|
5670
|
+
const opList = ops.map(x => getArithmeticOperation(x));
|
|
4764
5671
|
if (tokens.length == 1) {
|
|
4765
5672
|
return [factorToken(tokens[0])];
|
|
4766
5673
|
}
|
|
@@ -4788,7 +5695,7 @@ var allFeatures = /*#__PURE__*/Object.freeze({
|
|
|
4788
5695
|
InlineCssVariables: InlineCssVariables
|
|
4789
5696
|
});
|
|
4790
5697
|
|
|
4791
|
-
const combinators = ['+', '>', '~'];
|
|
5698
|
+
const combinators = ['+', '>', '~', '||'];
|
|
4792
5699
|
const notEndingWith = ['(', '['].concat(combinators);
|
|
4793
5700
|
const definedPropertySettings = { configurable: true, enumerable: false, writable: true };
|
|
4794
5701
|
// @ts-ignore
|
|
@@ -4804,7 +5711,12 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
4804
5711
|
context.nodes.add(ast);
|
|
4805
5712
|
if (!('features' in options)) {
|
|
4806
5713
|
// @ts-ignore
|
|
4807
|
-
options = {
|
|
5714
|
+
options = {
|
|
5715
|
+
removeDuplicateDeclarations: true,
|
|
5716
|
+
computeShorthand: true,
|
|
5717
|
+
computeCalcExpression: true,
|
|
5718
|
+
features: [], ...options
|
|
5719
|
+
};
|
|
4808
5720
|
// @ts-ignore
|
|
4809
5721
|
for (const feature of features) {
|
|
4810
5722
|
feature.register(options);
|
|
@@ -4823,7 +5735,7 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
4823
5735
|
curr.splice(0, 1);
|
|
4824
5736
|
}
|
|
4825
5737
|
}
|
|
4826
|
-
else if (ast.typ ==
|
|
5738
|
+
else if (ast.typ == exports.EnumToken.RuleNodeType && (isIdent(curr[0]) || isFunction(curr[0]))) {
|
|
4827
5739
|
curr.unshift('&', ' ');
|
|
4828
5740
|
}
|
|
4829
5741
|
acc.push(curr.join(''));
|
|
@@ -4832,7 +5744,7 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
4832
5744
|
// @ts-ignore
|
|
4833
5745
|
if ('chi' in ast && ast.chi.length > 0) {
|
|
4834
5746
|
if (!nestingContent) {
|
|
4835
|
-
nestingContent = options.nestingRules && ast.typ ==
|
|
5747
|
+
nestingContent = options.nestingRules && ast.typ == exports.EnumToken.RuleNodeType;
|
|
4836
5748
|
}
|
|
4837
5749
|
let i = 0;
|
|
4838
5750
|
let previous;
|
|
@@ -4841,7 +5753,7 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
4841
5753
|
// @ts-ignore
|
|
4842
5754
|
for (; i < ast.chi.length; i++) {
|
|
4843
5755
|
// @ts-ignore
|
|
4844
|
-
if (ast.chi[i].typ ==
|
|
5756
|
+
if (ast.chi[i].typ == exports.EnumToken.CommentNodeType) {
|
|
4845
5757
|
continue;
|
|
4846
5758
|
}
|
|
4847
5759
|
// @ts-ignore
|
|
@@ -4853,10 +5765,10 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
4853
5765
|
i--;
|
|
4854
5766
|
continue;
|
|
4855
5767
|
}
|
|
4856
|
-
if (node.typ ==
|
|
5768
|
+
if (node.typ == exports.EnumToken.AtRuleNodeType && node.nam == 'font-face') {
|
|
4857
5769
|
continue;
|
|
4858
5770
|
}
|
|
4859
|
-
if (node.typ ==
|
|
5771
|
+
if (node.typ == exports.EnumToken.AtRuleNodeType) {
|
|
4860
5772
|
if (node.nam == 'media' && node.val == 'all') {
|
|
4861
5773
|
// @ts-ignore
|
|
4862
5774
|
ast.chi?.splice(i, 1, ...node.chi);
|
|
@@ -4864,7 +5776,7 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
4864
5776
|
continue;
|
|
4865
5777
|
}
|
|
4866
5778
|
// @ts-ignore
|
|
4867
|
-
if (previous?.typ ==
|
|
5779
|
+
if (previous?.typ == exports.EnumToken.AtRuleNodeType &&
|
|
4868
5780
|
previous.nam == node.nam &&
|
|
4869
5781
|
previous.val == node.val) {
|
|
4870
5782
|
if ('chi' in node) {
|
|
@@ -4883,14 +5795,14 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
4883
5795
|
continue;
|
|
4884
5796
|
}
|
|
4885
5797
|
// @ts-ignore
|
|
4886
|
-
if (node.typ ==
|
|
5798
|
+
if (node.typ == exports.EnumToken.RuleNodeType) {
|
|
4887
5799
|
reduceRuleSelector(node);
|
|
4888
5800
|
let wrapper;
|
|
4889
5801
|
let match;
|
|
4890
5802
|
// @ts-ignore
|
|
4891
5803
|
if (options.nestingRules) {
|
|
4892
5804
|
// @ts-ignore
|
|
4893
|
-
if (previous?.typ ==
|
|
5805
|
+
if (previous?.typ == exports.EnumToken.RuleNodeType) {
|
|
4894
5806
|
// @ts-ignore
|
|
4895
5807
|
reduceRuleSelector(previous);
|
|
4896
5808
|
// @ts-ignore
|
|
@@ -4911,7 +5823,7 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
4911
5823
|
// @ts-ignore
|
|
4912
5824
|
const nextNode = ast.chi[i];
|
|
4913
5825
|
// @ts-ignore
|
|
4914
|
-
if (nextNode.typ !=
|
|
5826
|
+
if (nextNode.typ != exports.EnumToken.RuleNodeType) {
|
|
4915
5827
|
break;
|
|
4916
5828
|
}
|
|
4917
5829
|
reduceRuleSelector(nextNode);
|
|
@@ -4965,7 +5877,7 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
4965
5877
|
curr.splice(0, 2);
|
|
4966
5878
|
}
|
|
4967
5879
|
else {
|
|
4968
|
-
if (ast.typ !=
|
|
5880
|
+
if (ast.typ != exports.EnumToken.RuleNodeType && combinators.includes(curr[1])) {
|
|
4969
5881
|
wrap = false;
|
|
4970
5882
|
}
|
|
4971
5883
|
else {
|
|
@@ -5013,18 +5925,18 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
5013
5925
|
let k = previous.chi.length;
|
|
5014
5926
|
while (k-- > 0) {
|
|
5015
5927
|
// @ts-ignore
|
|
5016
|
-
if (previous.chi[k].typ ==
|
|
5928
|
+
if (previous.chi[k].typ == exports.EnumToken.CommentNodeType) {
|
|
5017
5929
|
continue;
|
|
5018
5930
|
}
|
|
5019
5931
|
// @ts-ignore
|
|
5020
|
-
shouldMerge = previous.chi[k].typ ==
|
|
5932
|
+
shouldMerge = previous.chi[k].typ == exports.EnumToken.DeclarationNodeType;
|
|
5021
5933
|
break;
|
|
5022
5934
|
}
|
|
5023
5935
|
if (shouldMerge) {
|
|
5024
5936
|
// @ts-ignore
|
|
5025
|
-
if ((node.typ ==
|
|
5937
|
+
if ((node.typ == exports.EnumToken.RuleNodeType && node.sel == previous.sel) ||
|
|
5026
5938
|
// @ts-ignore
|
|
5027
|
-
(node.typ ==
|
|
5939
|
+
(node.typ == exports.EnumToken.AtRuleNodeType) && node.val != 'font-face' && node.val == previous.val) {
|
|
5028
5940
|
// @ts-ignore
|
|
5029
5941
|
node.chi.unshift(...previous.chi);
|
|
5030
5942
|
// @ts-ignore
|
|
@@ -5041,7 +5953,7 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
5041
5953
|
nodeIndex = i;
|
|
5042
5954
|
continue;
|
|
5043
5955
|
}
|
|
5044
|
-
else if (node.typ ==
|
|
5956
|
+
else if (node.typ == exports.EnumToken.RuleNodeType && previous?.typ == exports.EnumToken.RuleNodeType) {
|
|
5045
5957
|
const intersect = diff(previous, node, reducer, options);
|
|
5046
5958
|
if (intersect != null) {
|
|
5047
5959
|
if (intersect.node1.chi.length == 0) {
|
|
@@ -5098,7 +6010,7 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
5098
6010
|
// @ts-ignore
|
|
5099
6011
|
previous != null &&
|
|
5100
6012
|
// previous.optimized != null &&
|
|
5101
|
-
previous.typ ==
|
|
6013
|
+
previous.typ == exports.EnumToken.RuleNodeType &&
|
|
5102
6014
|
previous.sel.includes('&')) {
|
|
5103
6015
|
fixSelector(previous);
|
|
5104
6016
|
}
|
|
@@ -5108,9 +6020,9 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
5108
6020
|
// @ts-ignore
|
|
5109
6021
|
if (recursive && node != null && ('chi' in node)) {
|
|
5110
6022
|
// @ts-ignore
|
|
5111
|
-
if (!node.chi.some(n => n.typ ==
|
|
6023
|
+
if (!node.chi.some(n => n.typ == exports.EnumToken.DeclarationNodeType)) {
|
|
5112
6024
|
// @ts-ignore
|
|
5113
|
-
if (!(node.typ ==
|
|
6025
|
+
if (!(node.typ == exports.EnumToken.AtRuleNodeType && node.nam != 'font-face')) {
|
|
5114
6026
|
minify(node, options, recursive, errors, nestingContent, context);
|
|
5115
6027
|
}
|
|
5116
6028
|
}
|
|
@@ -5119,12 +6031,12 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
5119
6031
|
// @ts-ignore
|
|
5120
6032
|
node != null &&
|
|
5121
6033
|
// previous.optimized != null &&
|
|
5122
|
-
node.typ ==
|
|
6034
|
+
node.typ == exports.EnumToken.RuleNodeType &&
|
|
5123
6035
|
node.sel.includes('&')) {
|
|
5124
6036
|
fixSelector(node);
|
|
5125
6037
|
}
|
|
5126
6038
|
}
|
|
5127
|
-
if (ast.typ ==
|
|
6039
|
+
if (ast.typ == exports.EnumToken.StyleSheetNodeType) {
|
|
5128
6040
|
let parent;
|
|
5129
6041
|
let parents = [ast];
|
|
5130
6042
|
while (parents.length > 0) {
|
|
@@ -5133,7 +6045,7 @@ function minify(ast, options = {}, recursive = false, errors, nestingContent, co
|
|
|
5133
6045
|
for (let k = 0; k < parent.chi.length; k++) {
|
|
5134
6046
|
// @ts-ignore
|
|
5135
6047
|
const node = parent.chi[k];
|
|
5136
|
-
if (!('chi' in node) || node.typ ==
|
|
6048
|
+
if (!('chi' in node) || node.typ == exports.EnumToken.StyleSheetNodeType || (node.typ == exports.EnumToken.AtRuleNodeType && node.nam == 'font-face')) {
|
|
5137
6049
|
continue;
|
|
5138
6050
|
}
|
|
5139
6051
|
// @ts-ignore
|
|
@@ -5244,11 +6156,11 @@ function hasDeclaration(node) {
|
|
|
5244
6156
|
// @ts-ignore
|
|
5245
6157
|
for (let i = 0; i < node.chi?.length; i++) {
|
|
5246
6158
|
// @ts-ignore
|
|
5247
|
-
if (node.chi[i].typ ==
|
|
6159
|
+
if (node.chi[i].typ == exports.EnumToken.CommentNodeType) {
|
|
5248
6160
|
continue;
|
|
5249
6161
|
}
|
|
5250
6162
|
// @ts-ignore
|
|
5251
|
-
return node.chi[i].typ ==
|
|
6163
|
+
return node.chi[i].typ == exports.EnumToken.DeclarationNodeType;
|
|
5252
6164
|
}
|
|
5253
6165
|
return true;
|
|
5254
6166
|
}
|
|
@@ -5394,7 +6306,7 @@ function matchSelectors(selector1, selector2, parentType, errors) {
|
|
|
5394
6306
|
if (matchFunction != 0 || inAttr != 0) {
|
|
5395
6307
|
return null;
|
|
5396
6308
|
}
|
|
5397
|
-
if (parentType !=
|
|
6309
|
+
if (parentType != exports.EnumToken.RuleNodeType) {
|
|
5398
6310
|
for (const part of match) {
|
|
5399
6311
|
if (part.length > 0 && combinators.includes(part[0].charAt(0))) {
|
|
5400
6312
|
return null;
|
|
@@ -5600,7 +6512,7 @@ function diff(n1, n2, reducer, options = {}) {
|
|
|
5600
6512
|
}
|
|
5601
6513
|
const intersect = [];
|
|
5602
6514
|
while (i--) {
|
|
5603
|
-
if (node1.chi[i].typ ==
|
|
6515
|
+
if (node1.chi[i].typ == exports.EnumToken.CommentNodeType) {
|
|
5604
6516
|
continue;
|
|
5605
6517
|
}
|
|
5606
6518
|
j = node2.chi.length;
|
|
@@ -5608,7 +6520,7 @@ function diff(n1, n2, reducer, options = {}) {
|
|
|
5608
6520
|
break;
|
|
5609
6521
|
}
|
|
5610
6522
|
while (j--) {
|
|
5611
|
-
if (node2.chi[j].typ ==
|
|
6523
|
+
if (node2.chi[j].typ == exports.EnumToken.CommentNodeType) {
|
|
5612
6524
|
continue;
|
|
5613
6525
|
}
|
|
5614
6526
|
if (node1.chi[i].nam == node2.chi[j].nam) {
|
|
@@ -5804,53 +6716,16 @@ async function transform(css, options = {}) {
|
|
|
5804
6716
|
});
|
|
5805
6717
|
}
|
|
5806
6718
|
|
|
5807
|
-
exports.colorsFunc = colorsFunc;
|
|
5808
|
-
exports.combinators = combinators;
|
|
5809
6719
|
exports.dirname = dirname;
|
|
5810
|
-
exports.doParse = doParse;
|
|
5811
|
-
exports.doRender = doRender;
|
|
5812
6720
|
exports.expand = expand;
|
|
5813
|
-
exports.funcList = funcList;
|
|
5814
|
-
exports.getConfig = getConfig;
|
|
5815
|
-
exports.hasDeclaration = hasDeclaration;
|
|
5816
|
-
exports.isAngle = isAngle;
|
|
5817
|
-
exports.isAtKeyword = isAtKeyword;
|
|
5818
|
-
exports.isColor = isColor;
|
|
5819
|
-
exports.isDigit = isDigit;
|
|
5820
|
-
exports.isDimension = isDimension;
|
|
5821
|
-
exports.isFrequency = isFrequency;
|
|
5822
|
-
exports.isFunction = isFunction;
|
|
5823
|
-
exports.isHash = isHash;
|
|
5824
|
-
exports.isHexColor = isHexColor;
|
|
5825
|
-
exports.isIdent = isIdent;
|
|
5826
|
-
exports.isIdentCodepoint = isIdentCodepoint;
|
|
5827
|
-
exports.isIdentStart = isIdentStart;
|
|
5828
|
-
exports.isLength = isLength;
|
|
5829
|
-
exports.isNewLine = isNewLine;
|
|
5830
|
-
exports.isNonPrintable = isNonPrintable;
|
|
5831
|
-
exports.isNumber = isNumber;
|
|
5832
|
-
exports.isPercentage = isPercentage;
|
|
5833
|
-
exports.isPseudo = isPseudo;
|
|
5834
|
-
exports.isResolution = isResolution;
|
|
5835
|
-
exports.isTime = isTime;
|
|
5836
|
-
exports.isWhiteSpace = isWhiteSpace;
|
|
5837
6721
|
exports.load = load;
|
|
5838
|
-
exports.matchType = matchType;
|
|
5839
|
-
exports.matchUrl = matchUrl;
|
|
5840
6722
|
exports.minify = minify;
|
|
5841
6723
|
exports.parse = parse;
|
|
5842
|
-
exports.parseDimension = parseDimension;
|
|
5843
6724
|
exports.parseString = parseString;
|
|
5844
6725
|
exports.parseTokens = parseTokens;
|
|
5845
|
-
exports.reduceNumber = reduceNumber;
|
|
5846
|
-
exports.reduceSelector = reduceSelector;
|
|
5847
6726
|
exports.render = render;
|
|
5848
6727
|
exports.renderToken = renderToken;
|
|
5849
|
-
exports.replaceCompound = replaceCompound;
|
|
5850
6728
|
exports.resolve = resolve;
|
|
5851
|
-
exports.splitRule = splitRule;
|
|
5852
|
-
exports.tokenize = tokenize;
|
|
5853
6729
|
exports.transform = transform;
|
|
5854
|
-
exports.urlTokenMatcher = urlTokenMatcher;
|
|
5855
6730
|
exports.walk = walk;
|
|
5856
6731
|
exports.walkValues = walkValues;
|