@tbela99/css-parser 1.8.2 → 2.0.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/CHANGELOG.md +62 -0
- package/README.md +129 -31
- package/dist/index-umd-web.js +27383 -24083
- package/dist/index.d.ts +2737 -2200
- package/dist/package.json.js +2 -2
- package/dist/src/data/properties.json.js +1 -1
- package/dist/src/data/validation.json.js +1 -1
- package/dist/src/lib/ast/arena-node.js +548 -0
- package/dist/src/lib/ast/arena.js +3198 -0
- package/dist/src/lib/ast/features/calc.js +85 -76
- package/dist/src/lib/ast/features/if.js +155 -115
- package/dist/src/lib/ast/features/index.js +1 -1
- package/dist/src/lib/ast/features/inlinecssvariables.js +77 -84
- package/dist/src/lib/ast/features/prefix.js +184 -183
- package/dist/src/lib/ast/features/shorthand.js +40 -46
- package/dist/src/lib/ast/features/transform.js +24 -24
- package/dist/src/lib/ast/features/type.js +1 -1
- package/dist/src/lib/ast/fingerprint.js +333 -0
- package/dist/src/lib/ast/math/expression.js +458 -543
- package/dist/src/lib/ast/math/math.js +19 -41
- package/dist/src/lib/ast/minify.js +590 -647
- package/dist/src/lib/ast/transform/compute.js +82 -85
- package/dist/src/lib/ast/transform/matrix.js +21 -38
- package/dist/src/lib/ast/transform/minify.js +82 -193
- package/dist/src/lib/ast/transform/perspective.js +2 -3
- package/dist/src/lib/ast/transform/rotate.js +1 -1
- package/dist/src/lib/ast/transform/scale.js +1 -1
- package/dist/src/lib/ast/transform/skew.js +1 -1
- package/dist/src/lib/ast/transform/translate.js +1 -1
- package/dist/src/lib/ast/transform/utils.js +2 -2
- package/dist/src/lib/ast/types.js +263 -258
- package/dist/src/lib/ast/walk.js +246 -610
- package/dist/src/lib/fs/resolve.js +1 -1
- package/dist/src/lib/parser/declaration/list.js +223 -139
- package/dist/src/lib/parser/declaration/map.js +251 -238
- package/dist/src/lib/parser/declaration/set.js +74 -66
- package/dist/src/lib/parser/linesmap.js +1 -1
- package/dist/src/lib/parser/parse.js +1379 -1658
- package/dist/src/lib/parser/source.js +7 -4
- package/dist/src/lib/parser/tokenize.js +406 -199
- package/dist/src/lib/parser/utils/angle.js +11 -13
- package/dist/src/lib/parser/utils/at-rule-container.js +183 -168
- package/dist/src/lib/parser/utils/at-rule-font-feature-values.js +5 -5
- package/dist/src/lib/parser/utils/at-rule-generic.js +31 -24
- package/dist/src/lib/parser/utils/at-rule-import.js +44 -44
- package/dist/src/lib/parser/utils/at-rule-media.js +216 -205
- package/dist/src/lib/parser/utils/at-rule-support.js +83 -88
- package/dist/src/lib/parser/utils/at-rule-when-else.js +47 -47
- package/dist/src/lib/parser/utils/at-rule.js +5 -5
- package/dist/src/lib/parser/utils/base64.js +2 -2
- package/dist/src/lib/parser/utils/cache.js +1 -1
- package/dist/src/lib/parser/utils/config.js +1 -1
- package/dist/src/lib/parser/utils/declaration.js +233 -234
- package/dist/src/lib/parser/utils/eq.js +50 -3
- package/dist/src/lib/parser/utils/hash.js +2 -35
- package/dist/src/lib/parser/utils/selector.js +309 -387
- package/dist/src/lib/parser/utils/text.js +18 -4
- package/dist/src/lib/parser/utils/token.js +16 -69
- package/dist/src/lib/parser/utils/type.js +37 -24
- package/dist/src/lib/printer/render.js +965 -511
- package/dist/src/lib/printer/sourcemap/lib/codec.js +1 -1
- package/dist/src/lib/printer/sourcemap/sourcemap.js +1 -1
- package/dist/src/lib/syntax/color/a98rgb.js +1 -1
- package/dist/src/lib/syntax/color/alpha.js +36 -37
- package/dist/src/lib/syntax/color/cmyk.js +35 -52
- package/dist/src/lib/syntax/color/color-mix.js +96 -132
- package/dist/src/lib/syntax/color/color.js +222 -231
- package/dist/src/lib/syntax/color/hex.js +45 -55
- package/dist/src/lib/syntax/color/hsl.js +54 -62
- package/dist/src/lib/syntax/color/hwb.js +60 -68
- package/dist/src/lib/syntax/color/lab.js +59 -67
- package/dist/src/lib/syntax/color/lch.js +59 -67
- package/dist/src/lib/syntax/color/oklab.js +60 -68
- package/dist/src/lib/syntax/color/oklch.js +60 -67
- package/dist/src/lib/syntax/color/p3.js +1 -1
- package/dist/src/lib/syntax/color/prophotorgb.js +1 -1
- package/dist/src/lib/syntax/color/rec2020.js +1 -1
- package/dist/src/lib/syntax/color/relative-color.js +94 -144
- package/dist/src/lib/syntax/color/rgb.js +54 -57
- package/dist/src/lib/syntax/color/srgb.js +55 -53
- package/dist/src/lib/syntax/color/utils/color-type.js +13 -10
- package/dist/src/lib/syntax/color/utils/colorspace.js +11 -11
- package/dist/src/lib/syntax/color/utils/components.js +19 -20
- package/dist/src/lib/syntax/color/utils/distance.js +15 -13
- package/dist/src/lib/syntax/color/utils/make-color.js +15 -19
- package/dist/src/lib/syntax/color/utils/matrix.js +2 -2
- package/dist/src/lib/syntax/color/xyz.js +1 -1
- package/dist/src/lib/syntax/color/xyzd50.js +1 -1
- package/dist/src/lib/syntax/constants.js +2 -16
- package/dist/src/lib/syntax/syntax.js +301 -407
- package/dist/src/lib/validation/config.js +1 -1
- package/dist/src/lib/validation/match.js +959 -723
- package/dist/src/lib/validation/parser/parse.js +230 -112
- package/dist/src/lib/validation/parser/typedef.js +1 -1
- package/dist/src/lib/validation/utils/list.js +27 -12
- package/dist/src/node.js +12 -72
- package/dist/src/types.js +1 -1
- package/dist/src/utils/sync.js +9 -6
- package/dist/src/web.js +11 -73
- package/package.json +9 -10
- package/dist/index.cjs +0 -35870
- package/dist/src/lib/ast/clone.js +0 -51
- package/dist/src/lib/ast/expand.js +0 -311
- package/dist/src/lib/ast/find.js +0 -192
- package/dist/src/lib/ast/node.js +0 -59
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version:
|
|
5
|
+
Version: 2.0.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { EnumToken } from '../../ast/types.js';
|
|
9
|
-
import { tokensfuncDefMap
|
|
9
|
+
import { tokensfuncDefMap } from '../../syntax/constants.js';
|
|
10
10
|
import { equalsIgnoreCase } from './text.js';
|
|
11
11
|
|
|
12
|
-
function matchGenericSyntax(stream, options) {
|
|
12
|
+
function matchGenericSyntax(arena, stream, options) {
|
|
13
13
|
const stack = [];
|
|
14
14
|
let i = 0;
|
|
15
15
|
let success = true;
|
|
@@ -19,23 +19,25 @@ function matchGenericSyntax(stream, options) {
|
|
|
19
19
|
const scopes = [new Set()];
|
|
20
20
|
for (; i < stream.length; i++) {
|
|
21
21
|
const token = stream[i];
|
|
22
|
-
if (token
|
|
22
|
+
if (arena.dataTypes[token] === EnumToken.WhitespaceTokenType || arena.dataTypes[token] === EnumToken.CommentTokenType) {
|
|
23
23
|
continue;
|
|
24
24
|
}
|
|
25
|
-
if (token
|
|
25
|
+
if (arena.dataTypes[token] === EnumToken.StartParensTokenType || tokensfuncDefMap.has(arena.dataTypes[token])) {
|
|
26
26
|
stack.push(token);
|
|
27
27
|
scopes.push(new Set());
|
|
28
28
|
expectAndOr = false;
|
|
29
29
|
continue;
|
|
30
30
|
}
|
|
31
|
-
if (token
|
|
31
|
+
if (arena.dataTypes[token] === EnumToken.EndParensTokenType) {
|
|
32
32
|
if (stack.length === 0 ||
|
|
33
|
-
(stack.
|
|
33
|
+
(arena.dataTypes[stack[stack.length - 1]] !== EnumToken.StartParensTokenType &&
|
|
34
|
+
!tokensfuncDefMap.has(arena.dataTypes[stack[stack.length - 1]]))) {
|
|
34
35
|
errors.push({
|
|
35
36
|
action: "drop",
|
|
36
|
-
message: `unexpected token ${EnumToken[token
|
|
37
|
+
message: `unexpected token ${EnumToken[arena.dataTypes[token]]}`,
|
|
37
38
|
node: token,
|
|
38
|
-
|
|
39
|
+
// inlined: options.source!.getSourceLocation(arena.getSpanStart(token))
|
|
40
|
+
location: [options.source.file, ...options.source.lineStarts.getOffsets(arena.getSpanStart(token))],
|
|
39
41
|
});
|
|
40
42
|
success = false;
|
|
41
43
|
break;
|
|
@@ -44,45 +46,48 @@ function matchGenericSyntax(stream, options) {
|
|
|
44
46
|
scopes.pop();
|
|
45
47
|
continue;
|
|
46
48
|
}
|
|
47
|
-
if (token
|
|
49
|
+
if (arena.dataTypes[token] === EnumToken.IdenTokenType && equalsIgnoreCase("and", arena.strings[arena.stringValue[token]])) {
|
|
48
50
|
if (!expectAndOr || scopes.at(-1)?.has(EnumToken.OrTokenType)) {
|
|
49
51
|
errors.push({
|
|
50
52
|
action: "drop",
|
|
51
|
-
message: `unexpected token ${EnumToken[token
|
|
53
|
+
message: `unexpected token ${EnumToken[arena.dataTypes[token]]}`,
|
|
52
54
|
node: token,
|
|
53
|
-
|
|
55
|
+
// inlined: options.source!.getSourceLocation(arena.getSpanStart(token))
|
|
56
|
+
location: [options.source.file, ...options.source.lineStarts.getOffsets(arena.getSpanStart(token))],
|
|
54
57
|
});
|
|
55
58
|
success = false;
|
|
56
59
|
break;
|
|
57
60
|
}
|
|
58
|
-
|
|
61
|
+
arena.dataTypes[token] = EnumToken.AndTokenType;
|
|
59
62
|
scopes.at(-1).add(EnumToken.AndTokenType);
|
|
60
63
|
expectComma = false;
|
|
61
64
|
continue;
|
|
62
65
|
}
|
|
63
|
-
if (token
|
|
66
|
+
if (arena.dataTypes[token] === EnumToken.IdenTokenType && equalsIgnoreCase("or", arena.strings[arena.stringValue[token]])) {
|
|
64
67
|
if (!expectAndOr || scopes.at(-1)?.has(EnumToken.AndTokenType)) {
|
|
65
68
|
errors.push({
|
|
66
69
|
action: "drop",
|
|
67
|
-
message: `unexpected token ${EnumToken[token
|
|
70
|
+
message: `unexpected token ${EnumToken[arena.dataTypes[token]]}`,
|
|
68
71
|
node: token,
|
|
69
|
-
|
|
72
|
+
// inlined: options.source!.getSourceLocation(arena.getSpanStart(token))
|
|
73
|
+
location: [options.source.file, ...options.source.lineStarts.getOffsets(arena.getSpanStart(token))],
|
|
70
74
|
});
|
|
71
75
|
success = false;
|
|
72
76
|
break;
|
|
73
77
|
}
|
|
74
78
|
expectComma = false;
|
|
75
|
-
|
|
79
|
+
arena.dataTypes[token] = EnumToken.OrTokenType;
|
|
76
80
|
scopes.at(-1).add(EnumToken.OrTokenType);
|
|
77
81
|
continue;
|
|
78
82
|
}
|
|
79
|
-
if (token
|
|
83
|
+
if (arena.dataTypes[token] === EnumToken.CommaTokenType) {
|
|
80
84
|
if (!expectComma) {
|
|
81
85
|
errors.push({
|
|
82
86
|
action: "drop",
|
|
83
|
-
message: `unexpected token ${EnumToken[token
|
|
87
|
+
message: `unexpected token ${EnumToken[arena.dataTypes[token]]}`,
|
|
84
88
|
node: token,
|
|
85
|
-
|
|
89
|
+
// inlined: options.source!.getSourceLocation(arena.getSpanStart(token))
|
|
90
|
+
location: [options.source.file, ...options.source.lineStarts.getOffsets(arena.getSpanStart(token))],
|
|
86
91
|
});
|
|
87
92
|
success = false;
|
|
88
93
|
break;
|
|
@@ -93,16 +98,18 @@ function matchGenericSyntax(stream, options) {
|
|
|
93
98
|
}
|
|
94
99
|
expectAndOr = true;
|
|
95
100
|
expectComma = true;
|
|
96
|
-
|
|
101
|
+
// inlined: arena.typeOf(stack.at(-1))
|
|
102
|
+
if (stack.length > 0 && arena.dataTypes[stack.at(-1)] === EnumToken.CommaTokenType) {
|
|
97
103
|
stack.pop();
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
106
|
if (stack.length > 0) {
|
|
101
107
|
errors.push({
|
|
102
108
|
action: "drop",
|
|
103
|
-
message: `unexpected token ${EnumToken[stack.
|
|
104
|
-
node: stack.
|
|
105
|
-
|
|
109
|
+
message: `unexpected token ${EnumToken[arena.dataTypes[stack[stack.length - 1]]]}`,
|
|
110
|
+
node: stack[stack.length - 1],
|
|
111
|
+
// inlined: options.source!.getSourceLocation(arena.getSpanStart(stack[stack.length - 1]))
|
|
112
|
+
location: [options.source.file, ...options.source.lineStarts.getOffsets(arena.getSpanStart(stack[stack.length - 1]))],
|
|
106
113
|
});
|
|
107
114
|
success = false;
|
|
108
115
|
}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version:
|
|
5
|
+
Version: 2.0.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { EnumToken } from '../../ast/types.js';
|
|
9
9
|
import { getSyntaxRule } from '../../validation/config.js';
|
|
10
10
|
import { trimArray } from '../../validation/match.js';
|
|
11
11
|
import { ValidationSyntaxGroupEnum } from '../../validation/parser/typedef.js';
|
|
12
|
-
import { tokensfuncDefMap
|
|
12
|
+
import { tokensfuncDefMap } from '../../syntax/constants.js';
|
|
13
13
|
import { parseMediaqueryList } from './at-rule-media.js';
|
|
14
14
|
import { parseAtRuleSupportSyntax } from './at-rule-support.js';
|
|
15
15
|
|
|
16
|
-
function matchAtRuleImportSyntax(atRule, stream,
|
|
16
|
+
function matchAtRuleImportSyntax(arena, atRule, stream, options) {
|
|
17
17
|
let success = true;
|
|
18
18
|
let index = 0;
|
|
19
19
|
let i = 0;
|
|
@@ -24,20 +24,20 @@ function matchAtRuleImportSyntax(atRule, stream, context, options) {
|
|
|
24
24
|
const prelude = getSyntaxRule(ValidationSyntaxGroupEnum.AtRules, "@import")
|
|
25
25
|
.getPreludeRules()
|
|
26
26
|
.slice(1);
|
|
27
|
-
trimArray(stream);
|
|
27
|
+
trimArray(arena, stream);
|
|
28
28
|
// <string> | <url>
|
|
29
|
-
if (stream[index]
|
|
29
|
+
if (arena.dataTypes[stream[index]] === EnumToken.StringTokenType) {
|
|
30
30
|
tokens.push(stream[index++]);
|
|
31
31
|
}
|
|
32
|
-
else if (stream[index]
|
|
32
|
+
else if (arena.dataTypes[stream[index]] === EnumToken.UrlFunctionTokenDefType) {
|
|
33
33
|
// match ending ')'
|
|
34
34
|
let matchCount = 0;
|
|
35
35
|
let k = 0;
|
|
36
36
|
for (; k < stream.length; k++) {
|
|
37
|
-
if (stream[k]
|
|
37
|
+
if (arena.dataTypes[stream[k]] === EnumToken.EndParensTokenType) {
|
|
38
38
|
matchCount--;
|
|
39
39
|
}
|
|
40
|
-
else if (stream[k]
|
|
40
|
+
else if (arena.dataTypes[stream[k]] === EnumToken.StartParensTokenType || tokensfuncDefMap.has(arena.dataTypes[stream[k]])) {
|
|
41
41
|
matchCount++;
|
|
42
42
|
}
|
|
43
43
|
if (matchCount === 0) {
|
|
@@ -45,11 +45,10 @@ function matchAtRuleImportSyntax(atRule, stream, context, options) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
const slice = stream.slice(index + 1, k);
|
|
48
|
-
stream[0][
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}));
|
|
48
|
+
arena.spanLocation(stream[0], stream[0], stream[1]);
|
|
49
|
+
arena.dataTypes[stream[0]] = tokensfuncDefMap.get(arena.dataTypes[stream[0]]);
|
|
50
|
+
arena.setTokenList(stream[0], trimArray(arena, slice));
|
|
51
|
+
tokens.push(stream[0]);
|
|
53
52
|
index = k + 1;
|
|
54
53
|
}
|
|
55
54
|
else {
|
|
@@ -61,27 +60,27 @@ function matchAtRuleImportSyntax(atRule, stream, context, options) {
|
|
|
61
60
|
message: "Expected string or url()",
|
|
62
61
|
syntax: "@import",
|
|
63
62
|
node: stream[0],
|
|
64
|
-
|
|
63
|
+
// inlined: options.source!.getSourceLocation(arena.getSpanStart(stream[0]))
|
|
64
|
+
location: [options.source.file, ...options.source.lineStarts.getOffsets(arena.getSpanStart(stream[0]))],
|
|
65
65
|
},
|
|
66
66
|
],
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
while (index + 1 < prelude.length &&
|
|
70
|
-
(stream[index]
|
|
70
|
+
(arena.dataTypes[stream[index]] == EnumToken.WhitespaceTokenType || arena.dataTypes[stream[index]] == EnumToken.CommentTokenType)) {
|
|
71
71
|
tokens.push(stream[index++]);
|
|
72
72
|
}
|
|
73
73
|
// layer | layer(<layer-name>)
|
|
74
|
-
if (stream[index]
|
|
75
|
-
"layer".localeCompare(stream[index]
|
|
74
|
+
if (arena.dataTypes[stream[index]] === EnumToken.IdenTokenType &&
|
|
75
|
+
"layer".localeCompare(arena.strings[arena.stringValue[stream[index]]]) === 0) {
|
|
76
76
|
tokens.push(stream[index++]);
|
|
77
77
|
}
|
|
78
|
-
else if (tokensfuncDefMap.has(stream[index]
|
|
79
|
-
"layer".localeCompare(stream[index]
|
|
78
|
+
else if (tokensfuncDefMap.has(arena.dataTypes[stream[index]]) &&
|
|
79
|
+
"layer".localeCompare(arena.strings[arena.stringValue[stream[index]]]) === 0) {
|
|
80
80
|
stack.push(stream[index]);
|
|
81
81
|
tokens.push(stream[index++]);
|
|
82
82
|
// <layer-name">
|
|
83
|
-
if (stream[index]
|
|
84
|
-
i = tokens.indexOf(stack.at(-1));
|
|
83
|
+
if (arena.dataTypes[stream[index]] === EnumToken.EndParensTokenType) {
|
|
85
84
|
tokens.splice(index, 1);
|
|
86
85
|
return {
|
|
87
86
|
success: false,
|
|
@@ -91,22 +90,21 @@ function matchAtRuleImportSyntax(atRule, stream, context, options) {
|
|
|
91
90
|
message: `Expected <layer-name>`,
|
|
92
91
|
syntax: "@import",
|
|
93
92
|
node: stream[index],
|
|
94
|
-
|
|
93
|
+
// inlined: options.source!.getSourceLocation(arena.getSpanStart(stream[index]))
|
|
94
|
+
location: [options.source.file, ...options.source.lineStarts.getOffsets(arena.getSpanStart(stream[index]))],
|
|
95
95
|
},
|
|
96
96
|
],
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
else if (stream[index]
|
|
99
|
+
else if (arena.dataTypes[stream[index]] === EnumToken.IdenTokenType) {
|
|
100
100
|
tokens.push(stream[index++]);
|
|
101
|
-
while (stream[index]
|
|
101
|
+
while (arena.dataTypes[stream[index]] == EnumToken.ClassSelectorTokenType) {
|
|
102
102
|
tokens.push(stream[index++]);
|
|
103
103
|
}
|
|
104
|
-
i = tokens.indexOf(stack.
|
|
104
|
+
i = tokens.indexOf(stack[stack.length - 1]);
|
|
105
105
|
tokens.splice(index, 1);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
chi: trimArray(tokens.splice(i + 1, index++ - i - 1)),
|
|
109
|
-
});
|
|
106
|
+
arena.dataTypes[stack[stack.length - 1]] = EnumToken.FunctionTokenType;
|
|
107
|
+
arena.setTokenList(stack[stack.length - 1], trimArray(arena, tokens.splice(i + 1, index++ - i - 1)));
|
|
110
108
|
stack.pop();
|
|
111
109
|
}
|
|
112
110
|
else {
|
|
@@ -118,19 +116,20 @@ function matchAtRuleImportSyntax(atRule, stream, context, options) {
|
|
|
118
116
|
message: `Expected <layer-name>`,
|
|
119
117
|
syntax: "@import",
|
|
120
118
|
node: stream[index],
|
|
121
|
-
|
|
119
|
+
// inlined: options.source!.getSourceLocation(arena.getSpanStart(stream[index]))
|
|
120
|
+
location: [options.source.file, ...options.source.lineStarts.getOffsets(arena.getSpanStart(stream[index]))],
|
|
122
121
|
},
|
|
123
122
|
],
|
|
124
123
|
};
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
|
-
while (stream[index]
|
|
126
|
+
while (arena.dataTypes[stream[index]] === EnumToken.WhitespaceTokenType || arena.dataTypes[stream[index]] === EnumToken.CommentTokenType) {
|
|
128
127
|
tokens.push(stream[index++]);
|
|
129
128
|
}
|
|
130
|
-
// supports([ <supports-condition> | <declaration> ]
|
|
129
|
+
// supports([ <supports-condition> | <declaration> ])
|
|
131
130
|
if (index < stream.length &&
|
|
132
|
-
tokensfuncDefMap.has(stream[index]
|
|
133
|
-
"supports".localeCompare(stream[index]
|
|
131
|
+
tokensfuncDefMap.has(arena.dataTypes[stream[index]]) &&
|
|
132
|
+
"supports".localeCompare(arena.strings[arena.stringValue[stream[index]]]) === 0) {
|
|
134
133
|
stack.push(stream[index]);
|
|
135
134
|
tokens.push(stream[index++]);
|
|
136
135
|
matchCount = 1;
|
|
@@ -138,18 +137,16 @@ function matchAtRuleImportSyntax(atRule, stream, context, options) {
|
|
|
138
137
|
// else {
|
|
139
138
|
// match the next ')'
|
|
140
139
|
while (index < stream.length && matchCount > 0) {
|
|
141
|
-
if (stream[index]
|
|
140
|
+
if (arena.dataTypes[stream[index]] === EnumToken.StartParensTokenType || tokensfuncDefMap.has(arena.dataTypes[stream[index]])) {
|
|
142
141
|
matchCount++;
|
|
143
142
|
}
|
|
144
|
-
else if (stream[index]
|
|
143
|
+
else if (arena.dataTypes[stream[index]] === EnumToken.EndParensTokenType) {
|
|
145
144
|
matchCount--;
|
|
146
145
|
if (matchCount === 0) {
|
|
147
146
|
tokens.splice(index, 1);
|
|
148
|
-
i = tokens.indexOf(stack.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
chi: trimArray(tokens.splice(i + 1, index++ - i - 1)),
|
|
152
|
-
});
|
|
147
|
+
i = tokens.indexOf(stack[stack.length - 1]);
|
|
148
|
+
arena.dataTypes[stack[stack.length - 1]] = tokensfuncDefMap.get(arena.dataTypes[stack[stack.length - 1]]);
|
|
149
|
+
arena.setTokenList(stack[stack.length - 1], trimArray(arena, tokens.splice(i + 1, index++ - i - 1)));
|
|
153
150
|
stack.pop();
|
|
154
151
|
break;
|
|
155
152
|
}
|
|
@@ -158,7 +155,10 @@ function matchAtRuleImportSyntax(atRule, stream, context, options) {
|
|
|
158
155
|
}
|
|
159
156
|
// support() is the last item in tokens array
|
|
160
157
|
{
|
|
161
|
-
const
|
|
158
|
+
const supports = tokens[tokens.length - 1];
|
|
159
|
+
const chi = arena.tokens(supports);
|
|
160
|
+
const result = parseAtRuleSupportSyntax(arena, chi, atRule, options);
|
|
161
|
+
arena.setTokenList(supports, chi);
|
|
162
162
|
if (!result.success && result.errors.length > 0) {
|
|
163
163
|
for (const error of result.errors) {
|
|
164
164
|
errors.push(error);
|
|
@@ -171,7 +171,7 @@ function matchAtRuleImportSyntax(atRule, stream, context, options) {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
const splice = stream.splice(index, stream.length - index);
|
|
174
|
-
const sliced = parseMediaqueryList(splice, options);
|
|
174
|
+
const sliced = parseMediaqueryList(arena, splice, options);
|
|
175
175
|
for (const sp of splice) {
|
|
176
176
|
tokens.push(sp);
|
|
177
177
|
}
|
|
@@ -184,7 +184,7 @@ function matchAtRuleImportSyntax(atRule, stream, context, options) {
|
|
|
184
184
|
success = false;
|
|
185
185
|
}
|
|
186
186
|
stream.length = 0;
|
|
187
|
-
for (const token of trimArray(tokens)) {
|
|
187
|
+
for (const token of trimArray(arena, tokens)) {
|
|
188
188
|
stream.push(token);
|
|
189
189
|
}
|
|
190
190
|
return {
|