@tbela99/css-parser 1.4.11 → 1.6.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 +39 -0
- package/README.md +18 -11
- package/dist/index-umd-web.js +6558 -5310
- package/dist/index.cjs +6576 -5313
- package/dist/index.d.ts +805 -279
- package/dist/lib/ast/clone.js +13 -8
- package/dist/lib/ast/expand.js +65 -15
- package/dist/lib/ast/features/calc.js +19 -56
- package/dist/lib/ast/features/if.js +28 -4
- package/dist/lib/ast/features/inlinecssvariables.js +6 -5
- package/dist/lib/ast/features/prefix.js +52 -73
- package/dist/lib/ast/features/shorthand.js +11 -6
- package/dist/lib/ast/features/transform.js +6 -3
- package/dist/lib/ast/find.js +7 -5
- package/dist/lib/ast/math/expression.js +190 -32
- package/dist/lib/ast/minify.js +117 -49
- package/dist/lib/ast/node.js +52 -0
- package/dist/lib/ast/transform/compute.js +63 -4
- package/dist/lib/ast/transform/minify.js +6 -6
- package/dist/lib/ast/transform/perspective.js +1 -1
- package/dist/lib/ast/transform/rotate.js +1 -1
- package/dist/lib/ast/transform/scale.js +1 -1
- package/dist/lib/ast/transform/skew.js +1 -1
- package/dist/lib/ast/transform/translate.js +1 -1
- package/dist/lib/ast/transform/utils.js +46 -18
- package/dist/lib/ast/types.js +1 -1
- package/dist/lib/ast/walk.js +55 -11
- package/dist/lib/fs/resolve.js +68 -27
- package/dist/lib/parser/declaration/list.js +22 -7
- package/dist/lib/parser/declaration/map.js +40 -13
- package/dist/lib/parser/declaration/set.js +3 -1
- package/dist/lib/parser/linesmap.js +2 -12
- package/dist/lib/parser/parse.js +843 -912
- package/dist/lib/parser/source.js +16 -2
- package/dist/lib/parser/tokenize.js +1489 -725
- package/dist/lib/parser/utils/at-rule-container.js +29 -196
- package/dist/lib/parser/utils/at-rule-generic.js +6 -7
- package/dist/lib/parser/utils/at-rule-import.js +17 -13
- package/dist/lib/parser/utils/at-rule-media.js +36 -19
- package/dist/lib/parser/utils/at-rule-support.js +19 -9
- package/dist/lib/parser/utils/at-rule-when-else.js +11 -38
- package/dist/lib/parser/utils/at-rule.js +0 -18
- package/dist/lib/parser/utils/declaration.js +30 -95
- package/dist/lib/parser/utils/hash.js +4 -4
- package/dist/lib/parser/utils/selector.js +164 -141
- package/dist/lib/parser/utils/text.js +4 -2
- package/dist/lib/renderer/render.js +230 -125
- package/dist/lib/renderer/sourcemap/lib/codec.js +78 -0
- package/dist/lib/renderer/sourcemap/sourcemap.js +187 -34
- package/dist/lib/syntax/color/a98rgb.js +14 -4
- package/dist/lib/syntax/color/cmyk.js +10 -18
- package/dist/lib/syntax/color/color-mix.js +21 -34
- package/dist/lib/syntax/color/color.js +32 -49
- package/dist/lib/syntax/color/hsl.js +15 -15
- package/dist/lib/syntax/color/hwb.js +18 -17
- package/dist/lib/syntax/color/lab.js +17 -17
- package/dist/lib/syntax/color/lch.js +13 -13
- package/dist/lib/syntax/color/oklab.js +10 -11
- package/dist/lib/syntax/color/oklch.js +15 -18
- package/dist/lib/syntax/color/p3.js +18 -12
- package/dist/lib/syntax/color/prophotorgb.js +26 -28
- package/dist/lib/syntax/color/rec2020.js +8 -4
- package/dist/lib/syntax/color/relative-color.js +26 -10
- package/dist/lib/syntax/color/srgb.js +5 -4
- package/dist/lib/syntax/color/utils/distance.js +1 -1
- package/dist/lib/syntax/color/xyz.js +2 -2
- package/dist/lib/syntax/color/xyzd50.js +2 -2
- package/dist/lib/syntax/constants.js +12 -2
- package/dist/lib/syntax/syntax.js +45 -258
- package/dist/lib/validation/config.json.js +3 -0
- package/dist/lib/validation/match.js +110 -27
- package/dist/node.js +55 -33
- package/dist/types.d.ts +5 -1
- package/dist/types.js +4 -0
- package/dist/utils/sync.d.ts +16 -0
- package/dist/utils/sync.js +73 -0
- package/dist/web.js +37 -30
- package/package.json +1 -1
- package/dist/lib/renderer/sourcemap/lib/encode.js +0 -37
- package/llms.txt +0 -73
|
@@ -1,97 +1,81 @@
|
|
|
1
1
|
import { EnumToken, ColorType } from '../ast/types.js';
|
|
2
|
-
import {
|
|
3
|
-
import { isDigit,
|
|
2
|
+
import { wildCardFuncs, whenElseFunc, mathFuncs, timingFunc, supportFunc, timelineFunc, imageFunc, gridTemplateFunc, urlFunc, containerFunc, colorsFunc, transformFunctions, pseudoElements } from '../syntax/constants.js';
|
|
3
|
+
import { isWhiteSpace, isNewLine, isDigit, isLetter, isIdentStart, isIdentCodepoint, isNonPrintable, timeUnits, angleUnits, flexUnits, dimensionUnits, resolutionUnits, frequencyUnits } from '../syntax/syntax.js';
|
|
4
4
|
import { SourceFile } from './source.js';
|
|
5
|
-
import { equalsIgnoreCase } from './utils/text.js';
|
|
6
5
|
|
|
7
|
-
const SymbolsMapTokens =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return acc;
|
|
81
|
-
}, Object.create(null)),
|
|
82
|
-
...transformFunctions.reduce((acc, curr) => {
|
|
83
|
-
acc[curr.toLowerCase() + "("] = EnumToken.TransformFunctionTokenDefType;
|
|
84
|
-
return acc;
|
|
85
|
-
}, Object.create(null)),
|
|
86
|
-
...whenElseFunc.reduce((acc, curr) => {
|
|
87
|
-
acc[curr + "("] = EnumToken.WhenElseFunctionTokenDefType;
|
|
88
|
-
return acc;
|
|
89
|
-
}, Object.create(null)),
|
|
90
|
-
...wildCardFuncs.reduce((acc, curr) => {
|
|
91
|
-
acc[curr + "("] = EnumToken.WildCardFunctionTokenDefType;
|
|
92
|
-
return acc;
|
|
93
|
-
}, Object.create(null)),
|
|
94
|
-
};
|
|
6
|
+
const SymbolsMapTokens = Object.create(null);
|
|
7
|
+
// Regex for escape sequence decoding - compile once, reuse many times
|
|
8
|
+
const ESCAPE_SEQUENCE_REGEX = /\\([0-9a-fA-F]{1,6})(?:\s)?/g;
|
|
9
|
+
function decodeEscapeSequences(value) {
|
|
10
|
+
return value.replace(ESCAPE_SEQUENCE_REGEX, (_, sequence) => {
|
|
11
|
+
const codepoint = parseInt(sequence, 16);
|
|
12
|
+
if (codepoint == 0 ||
|
|
13
|
+
// leading surrogate
|
|
14
|
+
(0xd800 <= codepoint && codepoint <= 0xdbff) ||
|
|
15
|
+
// trailing surrogate
|
|
16
|
+
(0xdc00 <= codepoint && codepoint <= 0xdfff) ||
|
|
17
|
+
codepoint > 0x10ffff) {
|
|
18
|
+
return "\uFFFD";
|
|
19
|
+
}
|
|
20
|
+
return String.fromCodePoint(codepoint);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function assignTokenMap(entries, tokenType, suffix = "", lowercase = false) {
|
|
24
|
+
for (const entry of entries) {
|
|
25
|
+
SymbolsMapTokens[(lowercase ? entry.toLowerCase() : entry) + suffix] = tokenType;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
SymbolsMapTokens[""] = EnumToken.DelimTokenType;
|
|
29
|
+
SymbolsMapTokens["+"] = EnumToken.Plus;
|
|
30
|
+
SymbolsMapTokens["="] = EnumToken.DelimTokenType;
|
|
31
|
+
SymbolsMapTokens["|"] = EnumToken.Pipe;
|
|
32
|
+
SymbolsMapTokens["||"] = EnumToken.ColumnCombinatorTokenType;
|
|
33
|
+
SymbolsMapTokens["|="] = EnumToken.DashMatchTokenType;
|
|
34
|
+
SymbolsMapTokens["&"] = EnumToken.NestingSelectorTokenType;
|
|
35
|
+
SymbolsMapTokens["*"] = EnumToken.Star;
|
|
36
|
+
SymbolsMapTokens["*="] = EnumToken.ContainMatchTokenType;
|
|
37
|
+
SymbolsMapTokens["~"] = EnumToken.Tilda;
|
|
38
|
+
SymbolsMapTokens["~="] = EnumToken.IncludeMatchTokenType;
|
|
39
|
+
SymbolsMapTokens["^="] = EnumToken.StartMatchTokenType;
|
|
40
|
+
SymbolsMapTokens["$="] = EnumToken.EndMatchTokenType;
|
|
41
|
+
SymbolsMapTokens[","] = EnumToken.Comma;
|
|
42
|
+
SymbolsMapTokens[":"] = EnumToken.ColonTokenType;
|
|
43
|
+
SymbolsMapTokens["::"] = EnumToken.DoubleColonTokenType;
|
|
44
|
+
SymbolsMapTokens[";"] = EnumToken.SemiColonTokenType;
|
|
45
|
+
SymbolsMapTokens["("] = EnumToken.StartParensTokenType;
|
|
46
|
+
SymbolsMapTokens[")"] = EnumToken.EndParensTokenType;
|
|
47
|
+
SymbolsMapTokens["["] = EnumToken.AttrStartTokenType;
|
|
48
|
+
SymbolsMapTokens["]"] = EnumToken.AttrEndTokenType;
|
|
49
|
+
SymbolsMapTokens["{"] = EnumToken.BlockStartTokenType;
|
|
50
|
+
SymbolsMapTokens["}"] = EnumToken.BlockEndTokenType;
|
|
51
|
+
SymbolsMapTokens["<="] = EnumToken.LteTokenType;
|
|
52
|
+
SymbolsMapTokens[">"] = EnumToken.GtTokenType;
|
|
53
|
+
SymbolsMapTokens[">="] = EnumToken.GteTokenType;
|
|
54
|
+
SymbolsMapTokens[" "] = EnumToken.Whitespace;
|
|
55
|
+
SymbolsMapTokens["\t"] = EnumToken.Whitespace;
|
|
56
|
+
SymbolsMapTokens["\r"] = EnumToken.Whitespace;
|
|
57
|
+
SymbolsMapTokens["\n"] = EnumToken.Whitespace;
|
|
58
|
+
SymbolsMapTokens["\f"] = EnumToken.Whitespace;
|
|
59
|
+
assignTokenMap(flexUnits, EnumToken.FlexTokenType);
|
|
60
|
+
assignTokenMap(dimensionUnits, EnumToken.LengthTokenType);
|
|
61
|
+
assignTokenMap(resolutionUnits, EnumToken.ResolutionTokenType);
|
|
62
|
+
assignTokenMap(angleUnits, EnumToken.AngleTokenType);
|
|
63
|
+
assignTokenMap(timeUnits, EnumToken.TimeTokenType);
|
|
64
|
+
assignTokenMap(frequencyUnits, EnumToken.FrequencyTokenType);
|
|
65
|
+
assignTokenMap(pseudoElements, EnumToken.PseudoElementTokenType);
|
|
66
|
+
assignTokenMap(containerFunc, EnumToken.ContainerFunctionTokenDefType, "(");
|
|
67
|
+
assignTokenMap(urlFunc, EnumToken.UrlFunctionTokenDefType, "(");
|
|
68
|
+
assignTokenMap(gridTemplateFunc, EnumToken.GridTemplateFuncTokenDefType, "(");
|
|
69
|
+
assignTokenMap(imageFunc, EnumToken.ImageFunctionTokenDefType, "(");
|
|
70
|
+
assignTokenMap(timelineFunc, EnumToken.TimelineFunctionTokenDefType, "(");
|
|
71
|
+
assignTokenMap(supportFunc, EnumToken.SupportsFunctionTokenDefType, "(");
|
|
72
|
+
assignTokenMap(timingFunc, EnumToken.TimingFunctionTokenDefType, "(");
|
|
73
|
+
assignTokenMap(colorsFunc, EnumToken.ColorFunctionTokenDefType, "(");
|
|
74
|
+
assignTokenMap(mathFuncs, EnumToken.MathFunctionTokenDefType, "(");
|
|
75
|
+
assignTokenMap(transformFunctions, EnumToken.TransformFunctionTokenDefType, "(", true);
|
|
76
|
+
assignTokenMap(whenElseFunc, EnumToken.WhenElseFunctionTokenDefType, "(");
|
|
77
|
+
assignTokenMap(wildCardFuncs, EnumToken.WildCardFunctionTokenDefType, "(");
|
|
78
|
+
const SymbolsMapTokensKeys = Object.keys(SymbolsMapTokens);
|
|
95
79
|
// do not capture the value
|
|
96
80
|
const hintsEnum = new Set([
|
|
97
81
|
EnumToken.CommaTokenType,
|
|
@@ -134,714 +118,1494 @@ var TokenMap;
|
|
|
134
118
|
TokenMap[TokenMap["PLUS"] = 43] = "PLUS";
|
|
135
119
|
TokenMap[TokenMap["MINUS"] = 45] = "MINUS";
|
|
136
120
|
TokenMap[TokenMap["GREATERTHAN"] = 62] = "GREATERTHAN";
|
|
121
|
+
TokenMap[TokenMap["PERCENTAGE"] = 37] = "PERCENTAGE";
|
|
137
122
|
})(TokenMap || (TokenMap = {}));
|
|
138
|
-
function
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
let
|
|
152
|
-
let
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (codepoint == 0x20) {
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
123
|
+
function getSymbolHint(parseInfo, start, end) {
|
|
124
|
+
const len = end - start;
|
|
125
|
+
const keysLength = SymbolsMapTokensKeys.length;
|
|
126
|
+
// Early exit for impossible lengths
|
|
127
|
+
if (len < 0)
|
|
128
|
+
return null;
|
|
129
|
+
for (let i = 0; i < keysLength; i++) {
|
|
130
|
+
const key = SymbolsMapTokensKeys[i];
|
|
131
|
+
if (key.length !== len)
|
|
132
|
+
continue;
|
|
133
|
+
// Match character by character
|
|
134
|
+
let match = true;
|
|
135
|
+
for (let j = 0; j < len; j++) {
|
|
136
|
+
let ca = key.charCodeAt(j);
|
|
137
|
+
let cb = parseInfo.stream.charCodeAt(start + j);
|
|
138
|
+
// Normalize A-Z to a-z
|
|
139
|
+
if (ca >= 65 && ca <= 90)
|
|
140
|
+
ca += 32;
|
|
141
|
+
if (cb >= 65 && cb <= 90)
|
|
142
|
+
cb += 32;
|
|
143
|
+
if (ca !== cb) {
|
|
144
|
+
match = false;
|
|
165
145
|
break;
|
|
166
146
|
}
|
|
167
|
-
if (escapeSequence.trimEnd().length > 0) {
|
|
168
|
-
const codepoint = parseInt(escapeSequence, 16);
|
|
169
|
-
if (codepoint == 0 ||
|
|
170
|
-
// leading surrogate
|
|
171
|
-
(0xd800 <= codepoint && codepoint <= 0xdbff) ||
|
|
172
|
-
// trailing surrogate
|
|
173
|
-
(0xdc00 <= codepoint && codepoint <= 0xdfff)) {
|
|
174
|
-
buffer += String.fromCodePoint(0xfffd);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
buffer += String.fromCodePoint(codepoint);
|
|
178
|
-
}
|
|
179
|
-
next(parseInfo, escapeSequence.length +
|
|
180
|
-
1 +
|
|
181
|
-
(isWhiteSpace(parseInfo.stream.charAt(parseInfo.currentPosition - parseInfo.offset + 1)?.charCodeAt(0))
|
|
182
|
-
? 1
|
|
183
|
-
: 0));
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
buffer += next(parseInfo, 2);
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
if (value == quote) {
|
|
190
|
-
buffer += value;
|
|
191
|
-
result.push(yieldResult(buffer, parseInfo,
|
|
192
|
-
/* hasNewLine ? EnumToken.BadStringTokenType : */ EnumToken.StringTokenType));
|
|
193
|
-
next(parseInfo);
|
|
194
|
-
buffer = "";
|
|
195
|
-
return result;
|
|
196
147
|
}
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
return result;
|
|
148
|
+
if (match) {
|
|
149
|
+
return SymbolsMapTokens[key];
|
|
200
150
|
}
|
|
201
|
-
buffer += value;
|
|
202
|
-
next(parseInfo);
|
|
203
151
|
}
|
|
204
|
-
|
|
205
|
-
result.push(yieldResult(buffer + quote, parseInfo, EnumToken.StringTokenType));
|
|
206
|
-
return result;
|
|
152
|
+
return null;
|
|
207
153
|
}
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
searchArray = imageFunc;
|
|
232
|
-
break;
|
|
233
|
-
case EnumToken.TimelineFunctionTokenDefType:
|
|
234
|
-
searchArray = timelineFunc;
|
|
235
|
-
break;
|
|
236
|
-
// case EnumToken.GeneralEnclosedFunctionTokenDefType:
|
|
237
|
-
// searchArray = generalEnclosedFunc;
|
|
238
|
-
// break;
|
|
239
|
-
case EnumToken.SupportsFunctionTokenDefType:
|
|
240
|
-
searchArray = supportFunc;
|
|
241
|
-
break;
|
|
242
|
-
case EnumToken.TimingFunctionTokenDefType:
|
|
243
|
-
searchArray = timingFunc;
|
|
244
|
-
break;
|
|
245
|
-
case EnumToken.MathFunctionTokenDefType:
|
|
246
|
-
searchArray = mathFuncs;
|
|
247
|
-
break;
|
|
248
|
-
case EnumToken.WhenElseFunctionTokenDefType:
|
|
249
|
-
searchArray = whenElseFunc;
|
|
250
|
-
break;
|
|
251
|
-
case EnumToken.WildCardFunctionTokenDefType:
|
|
252
|
-
searchArray = wildCardFuncs;
|
|
154
|
+
function searchArray(array, parseInfo, start, end) {
|
|
155
|
+
const len = end - start;
|
|
156
|
+
// Early exit for impossible lengths
|
|
157
|
+
if (len < 0)
|
|
158
|
+
return null;
|
|
159
|
+
// Use a simple linear search optimized with length pre-filtering
|
|
160
|
+
let i = array.length;
|
|
161
|
+
while (i--) {
|
|
162
|
+
if (array[i].length !== len)
|
|
163
|
+
continue;
|
|
164
|
+
// Match character by character
|
|
165
|
+
let match = true;
|
|
166
|
+
const arrayItem = array[i];
|
|
167
|
+
for (let j = 0; j < len; j++) {
|
|
168
|
+
let ca = arrayItem.charCodeAt(j);
|
|
169
|
+
let cb = parseInfo.stream.charCodeAt(start + j);
|
|
170
|
+
// Normalize A-Z to a-z
|
|
171
|
+
if (ca >= 65 && ca <= 90)
|
|
172
|
+
ca += 32;
|
|
173
|
+
if (cb >= 65 && cb <= 90)
|
|
174
|
+
cb += 32;
|
|
175
|
+
if (ca != cb) {
|
|
176
|
+
match = false;
|
|
253
177
|
break;
|
|
254
|
-
}
|
|
255
|
-
if (searchArray != null) {
|
|
256
|
-
val = searchArray.find((v) => equalsIgnoreCase(v, val));
|
|
257
|
-
}
|
|
258
|
-
token = hintsEnum.has(hint) ? { typ: hint } : { typ: hint, val };
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
let slice = val.slice(1);
|
|
262
|
-
const chr = val.charAt(0);
|
|
263
|
-
if (chr == "@" && isIdent(slice)) {
|
|
264
|
-
token = {
|
|
265
|
-
typ: EnumToken.AtRuleTokenType,
|
|
266
|
-
nam: slice,
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
else if (chr == "." && isIdent(slice)) {
|
|
270
|
-
token = {
|
|
271
|
-
typ: EnumToken.ClassSelectorTokenType,
|
|
272
|
-
val,
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
else if (chr == "#") {
|
|
276
|
-
if (isHexColor(val)) {
|
|
277
|
-
token = {
|
|
278
|
-
typ: EnumToken.ColorTokenType,
|
|
279
|
-
val: val,
|
|
280
|
-
kin: ColorType.HEX,
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
else if (isHash(val)) {
|
|
284
|
-
token = {
|
|
285
|
-
typ: EnumToken.HashTokenType,
|
|
286
|
-
val: val,
|
|
287
|
-
};
|
|
288
178
|
}
|
|
289
179
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
typ: EnumToken.UnclosedStringTokenType,
|
|
293
|
-
val: val,
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
else if (isNumber(val)) {
|
|
297
|
-
token =
|
|
298
|
-
val[0] === "-" || val[0] === "+"
|
|
299
|
-
? {
|
|
300
|
-
typ: EnumToken.NumberTokenType,
|
|
301
|
-
sign: val[0],
|
|
302
|
-
val: +val,
|
|
303
|
-
}
|
|
304
|
-
: {
|
|
305
|
-
typ: EnumToken.NumberTokenType,
|
|
306
|
-
val: +val,
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
else if (isPercentage(val)) {
|
|
310
|
-
token = {
|
|
311
|
-
typ: EnumToken.PercentageTokenType,
|
|
312
|
-
val: +val.slice(0, -1),
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
else if ((dimension = parseDimension(val))) {
|
|
316
|
-
token = dimension;
|
|
317
|
-
}
|
|
318
|
-
else if (isIdent(val)) {
|
|
319
|
-
token = {
|
|
320
|
-
typ: val.startsWith("--") ? EnumToken.DashedIdenTokenType : EnumToken.IdenTokenType,
|
|
321
|
-
val,
|
|
322
|
-
};
|
|
180
|
+
if (match) {
|
|
181
|
+
return arrayItem;
|
|
323
182
|
}
|
|
324
183
|
}
|
|
325
|
-
|
|
326
|
-
token = {
|
|
327
|
-
typ: EnumToken.LiteralTokenType,
|
|
328
|
-
val,
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
// return token;
|
|
332
|
-
token[LOC] = {
|
|
333
|
-
srcId: parseInfo.source.id,
|
|
334
|
-
sta: parseInfo.position,
|
|
335
|
-
end: parseInfo.currentPosition,
|
|
336
|
-
};
|
|
337
|
-
parseInfo.position = parseInfo.currentPosition;
|
|
338
|
-
return { token, bytesIn: parseInfo.currentPosition + 1 };
|
|
184
|
+
return null;
|
|
339
185
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
186
|
+
/**
|
|
187
|
+
* tokenizer class
|
|
188
|
+
*/
|
|
189
|
+
class Tokenizer {
|
|
190
|
+
parseInfo;
|
|
191
|
+
input;
|
|
192
|
+
/**
|
|
193
|
+
* token type
|
|
194
|
+
*/
|
|
195
|
+
typ = null;
|
|
196
|
+
/**
|
|
197
|
+
* token kind
|
|
198
|
+
*/
|
|
199
|
+
kin = null;
|
|
200
|
+
/**
|
|
201
|
+
* token name
|
|
202
|
+
*/
|
|
203
|
+
nam = null;
|
|
204
|
+
/**
|
|
205
|
+
* token value
|
|
206
|
+
*/
|
|
207
|
+
val = null;
|
|
208
|
+
/**
|
|
209
|
+
* token unit
|
|
210
|
+
*/
|
|
211
|
+
unit = null;
|
|
212
|
+
/**
|
|
213
|
+
* source id
|
|
214
|
+
*/
|
|
215
|
+
srcId = null;
|
|
216
|
+
/**
|
|
217
|
+
* token start
|
|
218
|
+
*/
|
|
219
|
+
sta = null;
|
|
220
|
+
/**
|
|
221
|
+
* token end
|
|
222
|
+
*/
|
|
223
|
+
end = null;
|
|
224
|
+
/**
|
|
225
|
+
* bytes in
|
|
226
|
+
*/
|
|
227
|
+
bytesIn = null;
|
|
228
|
+
/**
|
|
229
|
+
* decode string
|
|
230
|
+
*/
|
|
231
|
+
decodeString = null;
|
|
232
|
+
/**
|
|
233
|
+
* token slice
|
|
234
|
+
*/
|
|
235
|
+
slice = null;
|
|
236
|
+
/**
|
|
237
|
+
* source file
|
|
238
|
+
*/
|
|
239
|
+
source = null;
|
|
240
|
+
/**
|
|
241
|
+
* token hint
|
|
242
|
+
*/
|
|
243
|
+
hint = null;
|
|
244
|
+
state = null;
|
|
245
|
+
constructor(parseInfo, input = null) {
|
|
246
|
+
this.parseInfo = parseInfo;
|
|
247
|
+
this.input = input;
|
|
248
|
+
if (typeof this.parseInfo == "string") {
|
|
249
|
+
if (typeof parseInfo == "string") {
|
|
250
|
+
this.parseInfo = {
|
|
251
|
+
stream: parseInfo,
|
|
252
|
+
source: new SourceFile(parseInfo, [], ""),
|
|
253
|
+
offset: 0,
|
|
254
|
+
time: 0,
|
|
255
|
+
position: 0,
|
|
256
|
+
currentPosition: 0,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
345
259
|
}
|
|
346
260
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
261
|
+
/**
|
|
262
|
+
*
|
|
263
|
+
* @param parseInfo
|
|
264
|
+
* @returns
|
|
265
|
+
*/
|
|
266
|
+
consumeString(parseInfo) {
|
|
267
|
+
const quote = this.advance(parseInfo).charCodeAt(0);
|
|
268
|
+
let charCode;
|
|
269
|
+
let decodeSegments = false;
|
|
270
|
+
while ((charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset)) == charCode) {
|
|
271
|
+
if (charCode == 92 /* TokenMap.REVERSE_SOLIDUS */) {
|
|
272
|
+
if (charCode == parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1)) {
|
|
273
|
+
this.advance(parseInfo, 2);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
const sequence = this.peek(parseInfo, 7);
|
|
277
|
+
let escapeSequence = "";
|
|
278
|
+
let codepoint;
|
|
279
|
+
let i;
|
|
280
|
+
for (i = 1; i < sequence.length; i++) {
|
|
281
|
+
codepoint = sequence.charCodeAt(i);
|
|
282
|
+
if (codepoint == 0x20 ||
|
|
283
|
+
(codepoint >= 0x61 && codepoint <= 0x66) ||
|
|
284
|
+
(codepoint >= 0x41 && codepoint <= 0x46) ||
|
|
285
|
+
(codepoint >= 0x30 && codepoint <= 0x39)) {
|
|
286
|
+
escapeSequence += sequence[i];
|
|
287
|
+
if (codepoint == 0x20) {
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
if (escapeSequence.trimEnd().length > 0) {
|
|
295
|
+
const length = escapeSequence.length +
|
|
296
|
+
1 +
|
|
297
|
+
(isWhiteSpace(parseInfo.stream.charAt(parseInfo.currentPosition - parseInfo.offset)?.charCodeAt(0))
|
|
298
|
+
? 1
|
|
299
|
+
: 0);
|
|
300
|
+
decodeSegments = true;
|
|
301
|
+
this.advance(parseInfo, length);
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
this.advance(parseInfo, 2);
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
if (charCode == quote) {
|
|
308
|
+
this.advance(parseInfo);
|
|
309
|
+
return this.makeToken(parseInfo,
|
|
310
|
+
/* hasNewLine ? EnumToken.BadStringTokenType : */ EnumToken.StringTokenType, decodeSegments ? { decodeSegments } : null);
|
|
374
311
|
}
|
|
312
|
+
if (isNewLine(charCode)) {
|
|
313
|
+
this.advance(parseInfo);
|
|
314
|
+
return this.makeToken(parseInfo, EnumToken.BadStringTokenType);
|
|
315
|
+
}
|
|
316
|
+
this.advance(parseInfo);
|
|
375
317
|
}
|
|
318
|
+
// EOF - 'Unclosed-string' fixed
|
|
319
|
+
return this.makeToken(parseInfo, EnumToken.StringTokenType);
|
|
320
|
+
// return result;
|
|
376
321
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
charCode = value.charCodeAt(0);
|
|
408
|
-
// nextCharCode = nextValue.charCodeAt(0);
|
|
409
|
-
// console.debug({value, buffer});
|
|
410
|
-
switch (charCode) {
|
|
411
|
-
case 61 /* TokenMap.EQUALS */:
|
|
412
|
-
if (buffer.length > 0) {
|
|
413
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
414
|
-
buffer = "";
|
|
415
|
-
}
|
|
416
|
-
result.push(yieldResult(next(parseInfo), parseInfo, EnumToken.DelimTokenType));
|
|
417
|
-
break;
|
|
418
|
-
// '+' or '-'
|
|
419
|
-
case 43 /* TokenMap.PLUS */:
|
|
420
|
-
case 45 /* TokenMap.MINUS */:
|
|
421
|
-
next(parseInfo);
|
|
422
|
-
if (charCode === 43 /* TokenMap.PLUS */ && !isNumber(peek(parseInfo))) {
|
|
423
|
-
if (buffer.length > 0) {
|
|
424
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
425
|
-
buffer = "";
|
|
322
|
+
/**
|
|
323
|
+
*
|
|
324
|
+
* @param parseInfo
|
|
325
|
+
* @returns
|
|
326
|
+
*/
|
|
327
|
+
consumeURLToken(parseInfo) {
|
|
328
|
+
const quote = this.advance(parseInfo).charCodeAt(0);
|
|
329
|
+
let charCode;
|
|
330
|
+
let decodeSegments = false;
|
|
331
|
+
while ((charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset)) == charCode) {
|
|
332
|
+
if (charCode == 92 /* TokenMap.REVERSE_SOLIDUS */) {
|
|
333
|
+
if (charCode == parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1)) {
|
|
334
|
+
this.advance(parseInfo, 2);
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
const sequence = this.peek(parseInfo, 7);
|
|
338
|
+
let escapeSequence = "";
|
|
339
|
+
let codepoint;
|
|
340
|
+
let i;
|
|
341
|
+
for (i = 1; i < sequence.length; i++) {
|
|
342
|
+
codepoint = sequence.charCodeAt(i);
|
|
343
|
+
if (codepoint == 0x20 ||
|
|
344
|
+
(codepoint >= 0x61 && codepoint <= 0x66) ||
|
|
345
|
+
(codepoint >= 0x41 && codepoint <= 0x46) ||
|
|
346
|
+
(codepoint >= 0x30 && codepoint <= 0x39)) {
|
|
347
|
+
escapeSequence += sequence[i];
|
|
348
|
+
if (codepoint == 0x20) {
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
continue;
|
|
426
352
|
}
|
|
427
|
-
result.push(yieldResult(value, parseInfo, SymbolsMapTokens[value]));
|
|
428
353
|
break;
|
|
429
354
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
355
|
+
if (escapeSequence.trimEnd().length > 0) {
|
|
356
|
+
const length = escapeSequence.length +
|
|
357
|
+
1 +
|
|
358
|
+
(isWhiteSpace(parseInfo.stream.charAt(parseInfo.currentPosition - parseInfo.offset)?.charCodeAt(0))
|
|
359
|
+
? 1
|
|
360
|
+
: 0);
|
|
361
|
+
decodeSegments = true;
|
|
362
|
+
this.advance(parseInfo, length);
|
|
363
|
+
continue;
|
|
437
364
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
365
|
+
this.advance(parseInfo, 2);
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
if (charCode == quote) {
|
|
369
|
+
this.advance(parseInfo);
|
|
370
|
+
let k = 1;
|
|
371
|
+
let end = parseInfo.stream.length - parseInfo.offset;
|
|
372
|
+
let position = parseInfo.currentPosition - parseInfo.offset;
|
|
373
|
+
while (position + k < end) {
|
|
374
|
+
charCode = parseInfo.stream.charCodeAt(position);
|
|
375
|
+
// NaN != NaN
|
|
376
|
+
if (charCode != charCode) {
|
|
377
|
+
this.advance(parseInfo, k);
|
|
378
|
+
return this.makeToken(parseInfo, EnumToken.BadUrlTokenType);
|
|
379
|
+
}
|
|
380
|
+
if (isWhiteSpace(charCode)) {
|
|
381
|
+
this.advance(parseInfo, k);
|
|
382
|
+
k++;
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
if (charCode != 41 /* TokenMap.RIGHT_PARENTHESIS */) {
|
|
386
|
+
this.advance(parseInfo, k);
|
|
387
|
+
return this.makeToken(parseInfo, EnumToken.BadUrlTokenType);
|
|
388
|
+
}
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
// consume until the ')'
|
|
392
|
+
return this.makeToken(parseInfo,
|
|
393
|
+
/* hasNewLine ? EnumToken.BadStringTokenType : */ EnumToken.StringTokenType, decodeSegments ? { decodeSegments } : null);
|
|
394
|
+
// return result;
|
|
395
|
+
}
|
|
396
|
+
if (isNewLine(charCode)) {
|
|
397
|
+
// bad string
|
|
398
|
+
this.advance(parseInfo);
|
|
399
|
+
while ((charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset)) == charCode) {
|
|
400
|
+
if (charCode == 92 /* TokenMap.REVERSE_SOLIDUS */) {
|
|
401
|
+
this.advance(parseInfo, 2);
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
if (charCode == 41 /* TokenMap.RIGHT_PARENTHESIS */) {
|
|
405
|
+
return this.makeToken(parseInfo, EnumToken.BadUrlTokenType);
|
|
406
|
+
}
|
|
407
|
+
this.advance(parseInfo);
|
|
445
408
|
}
|
|
446
|
-
|
|
409
|
+
return this.makeToken(parseInfo, EnumToken.BadStringTokenType);
|
|
410
|
+
}
|
|
411
|
+
this.advance(parseInfo);
|
|
412
|
+
}
|
|
413
|
+
// EOF - bad url token
|
|
414
|
+
return this.makeToken(parseInfo, EnumToken.BadUrlTokenType);
|
|
415
|
+
// return result;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* consume number, dimension, or percentage
|
|
419
|
+
* @param parseInfo
|
|
420
|
+
* @returns
|
|
421
|
+
*/
|
|
422
|
+
consumeNumericToken(parseInfo) {
|
|
423
|
+
let position = parseInfo.currentPosition - parseInfo.offset;
|
|
424
|
+
let offset = position;
|
|
425
|
+
let hasDigits = false;
|
|
426
|
+
let hasLetter = false;
|
|
427
|
+
let hasPercent = false;
|
|
428
|
+
let codepoint = parseInfo.stream.charCodeAt(position);
|
|
429
|
+
this.slice = null;
|
|
430
|
+
this.hint = null;
|
|
431
|
+
// '+' '-'
|
|
432
|
+
if (codepoint == 0x2b || codepoint == 0x2d) {
|
|
433
|
+
position++;
|
|
434
|
+
}
|
|
435
|
+
// consume digits
|
|
436
|
+
while (position < parseInfo.stream.length) {
|
|
437
|
+
codepoint = parseInfo.stream.charCodeAt(position);
|
|
438
|
+
if (isDigit(codepoint)) {
|
|
439
|
+
hasDigits = true;
|
|
440
|
+
position++;
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
// '.' 'E' 'e'
|
|
444
|
+
if (codepoint == 0x2e || codepoint == 0x45 || codepoint == 0x65) {
|
|
445
|
+
position++;
|
|
447
446
|
break;
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
447
|
+
}
|
|
448
|
+
if (isWhiteSpace(codepoint) ||
|
|
449
|
+
codepoint == 41 /* TokenMap.RIGHT_PARENTHESIS */ ||
|
|
450
|
+
codepoint == 59 /* TokenMap.SEMICOLON */ ||
|
|
451
|
+
codepoint == 125 /* TokenMap.RIGHT_BRACE */ ||
|
|
452
|
+
codepoint == 47 /* TokenMap.SLASH */ ||
|
|
453
|
+
codepoint == 42 /* TokenMap.STAR */ ||
|
|
454
|
+
codepoint == 44 /* TokenMap.COMMA */) {
|
|
455
|
+
return !hasDigits ? 0 : position - offset;
|
|
456
|
+
}
|
|
457
|
+
if (codepoint == 37 /* TokenMap.PERCENTAGE */) {
|
|
458
|
+
hasPercent = true;
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
if (isLetter(codepoint)) {
|
|
462
|
+
hasLetter = true;
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
return 0;
|
|
466
|
+
}
|
|
467
|
+
if (!hasLetter && !hasPercent) {
|
|
468
|
+
// '.'
|
|
469
|
+
if (codepoint == 0x2e) {
|
|
470
|
+
codepoint = parseInfo.stream.charCodeAt(position);
|
|
471
|
+
if (codepoint != codepoint) {
|
|
472
|
+
return !hasDigits ? 0 : position - offset;
|
|
473
|
+
}
|
|
474
|
+
if (isWhiteSpace(codepoint) ||
|
|
475
|
+
codepoint == 41 /* TokenMap.RIGHT_PARENTHESIS */ ||
|
|
476
|
+
codepoint == 59 /* TokenMap.SEMICOLON */ ||
|
|
477
|
+
codepoint == 125 /* TokenMap.RIGHT_BRACE */ ||
|
|
478
|
+
codepoint == 47 /* TokenMap.SLASH */ ||
|
|
479
|
+
codepoint == 42 /* TokenMap.STAR */ ||
|
|
480
|
+
codepoint == 44 /* TokenMap.COMMA */) {
|
|
481
|
+
return !hasDigits ? 0 : position - offset;
|
|
482
|
+
}
|
|
483
|
+
if (!isDigit(codepoint)) {
|
|
484
|
+
if (!hasDigits) {
|
|
485
|
+
return 0;
|
|
486
|
+
}
|
|
487
|
+
if (codepoint == 37 /* TokenMap.PERCENTAGE */) {
|
|
488
|
+
hasPercent = true;
|
|
489
|
+
}
|
|
490
|
+
else if (isLetter(codepoint)) {
|
|
491
|
+
hasLetter = true;
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
return 0;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
position++;
|
|
499
|
+
hasDigits = true;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
if (!hasLetter && !hasPercent) {
|
|
503
|
+
while (position + 1 <= parseInfo.stream.length) {
|
|
504
|
+
codepoint = parseInfo.stream.charCodeAt(position);
|
|
505
|
+
if (isDigit(codepoint)) {
|
|
506
|
+
position++;
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
if (!hasDigits) {
|
|
510
|
+
return 0;
|
|
511
|
+
}
|
|
512
|
+
// 'E' 'e'
|
|
513
|
+
if (codepoint == 0x45 || codepoint == 0x65) {
|
|
514
|
+
position++;
|
|
455
515
|
break;
|
|
456
516
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
517
|
+
if (isWhiteSpace(codepoint) ||
|
|
518
|
+
codepoint == 41 /* TokenMap.RIGHT_PARENTHESIS */ ||
|
|
519
|
+
codepoint == 59 /* TokenMap.SEMICOLON */ ||
|
|
520
|
+
codepoint == 125 /* TokenMap.RIGHT_BRACE */ ||
|
|
521
|
+
codepoint == 47 /* TokenMap.SLASH */ ||
|
|
522
|
+
codepoint == 42 /* TokenMap.STAR */ ||
|
|
523
|
+
codepoint == 44 /* TokenMap.COMMA */) {
|
|
524
|
+
return position - offset;
|
|
525
|
+
}
|
|
526
|
+
if (isLetter(codepoint)) {
|
|
527
|
+
hasLetter = true;
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
if (codepoint == 37 /* TokenMap.PERCENTAGE */) {
|
|
531
|
+
hasPercent = true;
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
534
|
+
return 0;
|
|
535
|
+
}
|
|
536
|
+
// 'E' 'e' - 'em'
|
|
537
|
+
if ((codepoint == 0x45 || codepoint == 0x65) && hasDigits && !hasLetter && !hasPercent) {
|
|
538
|
+
if (isLetter(parseInfo.stream.charCodeAt(position))) {
|
|
539
|
+
hasLetter = true;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (!hasLetter && !hasPercent) {
|
|
543
|
+
// 'E' 'e'
|
|
544
|
+
if (codepoint == 0x45 || codepoint == 0x65) {
|
|
545
|
+
codepoint = parseInfo.stream.charCodeAt(position + 1);
|
|
546
|
+
// '+' '-'
|
|
547
|
+
if (codepoint == 0x2b || codepoint == 0x2d) {
|
|
548
|
+
position++;
|
|
549
|
+
}
|
|
550
|
+
codepoint = position = parseInfo.stream.charCodeAt(position + 1);
|
|
551
|
+
if (!isDigit(codepoint)) {
|
|
552
|
+
if (!hasDigits) {
|
|
553
|
+
return 0;
|
|
554
|
+
}
|
|
555
|
+
if (isLetter(codepoint)) {
|
|
556
|
+
hasLetter = true;
|
|
557
|
+
}
|
|
558
|
+
else if (codepoint == 37 /* TokenMap.PERCENTAGE */) {
|
|
559
|
+
hasPercent = true;
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
return 0;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (!hasLetter && !hasPercent) {
|
|
567
|
+
while (++position < parseInfo.stream.length) {
|
|
568
|
+
codepoint = parseInfo.stream.charCodeAt(position);
|
|
569
|
+
// eof
|
|
570
|
+
if (codepoint != codepoint) {
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
if (isDigit(codepoint)) {
|
|
574
|
+
position++;
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
577
|
+
if (!hasDigits) {
|
|
578
|
+
return 0;
|
|
498
579
|
}
|
|
499
|
-
if (
|
|
500
|
-
|
|
501
|
-
|
|
580
|
+
if (isWhiteSpace(codepoint) ||
|
|
581
|
+
codepoint == 41 /* TokenMap.RIGHT_PARENTHESIS */ ||
|
|
582
|
+
codepoint == 59 /* TokenMap.SEMICOLON */ ||
|
|
583
|
+
codepoint == 125 /* TokenMap.RIGHT_BRACE */ ||
|
|
584
|
+
codepoint == 47 /* TokenMap.SLASH */ ||
|
|
585
|
+
codepoint == 42 /* TokenMap.STAR */ ||
|
|
586
|
+
codepoint == 44 /* TokenMap.COMMA */) {
|
|
587
|
+
return position - offset;
|
|
502
588
|
}
|
|
503
|
-
if (
|
|
589
|
+
else if (isLetter(codepoint)) {
|
|
590
|
+
hasLetter = true;
|
|
504
591
|
break;
|
|
505
592
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
!(value === "/" && match(parseInfo, "/*")));
|
|
513
|
-
if (buffer.length > 0) {
|
|
514
|
-
result.push(yieldResult(buffer, parseInfo, peek(parseInfo) === ""
|
|
515
|
-
? EnumToken.BadUrlTokenType
|
|
516
|
-
: EnumToken.UrlTokenTokenType));
|
|
517
|
-
buffer = "";
|
|
593
|
+
else if (codepoint == 37 /* TokenMap.PERCENTAGE */) {
|
|
594
|
+
hasPercent = true;
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
else {
|
|
598
|
+
return 0;
|
|
518
599
|
}
|
|
519
600
|
}
|
|
520
|
-
|
|
521
|
-
|
|
601
|
+
if (!hasLetter && !hasPercent) {
|
|
602
|
+
return position - offset;
|
|
603
|
+
}
|
|
522
604
|
}
|
|
523
605
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
if (!hasDigits) {
|
|
609
|
+
return 0;
|
|
610
|
+
}
|
|
611
|
+
if (hasPercent) {
|
|
612
|
+
const slice = position;
|
|
613
|
+
codepoint = parseInfo.stream.charCodeAt(++position);
|
|
614
|
+
if (codepoint != codepoint ||
|
|
615
|
+
isWhiteSpace(codepoint) ||
|
|
616
|
+
codepoint == 41 /* TokenMap.RIGHT_PARENTHESIS */ ||
|
|
617
|
+
codepoint == 59 /* TokenMap.SEMICOLON */ ||
|
|
618
|
+
codepoint == 125 /* TokenMap.RIGHT_BRACE */ ||
|
|
619
|
+
codepoint == 47 /* TokenMap.SLASH */ ||
|
|
620
|
+
codepoint == 42 /* TokenMap.STAR */ ||
|
|
621
|
+
codepoint == 44 /* TokenMap.COMMA */) {
|
|
622
|
+
this.slice = slice;
|
|
623
|
+
this.hint = EnumToken.PercentageTokenType;
|
|
624
|
+
return position - offset;
|
|
625
|
+
}
|
|
626
|
+
return 0;
|
|
627
|
+
}
|
|
628
|
+
if (hasLetter) {
|
|
629
|
+
codepoint = parseInfo.stream.charCodeAt(position - 1);
|
|
630
|
+
// 'E' 'e'
|
|
631
|
+
const slice = codepoint == 0x45 || codepoint == 0x65 ? position - 1 : position;
|
|
632
|
+
while (position + 1 <= parseInfo.stream.length) {
|
|
633
|
+
codepoint = parseInfo.stream.charCodeAt(++position);
|
|
634
|
+
if (!isLetter(codepoint)) {
|
|
635
|
+
break;
|
|
532
636
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
637
|
+
}
|
|
638
|
+
if (codepoint != codepoint ||
|
|
639
|
+
isWhiteSpace(codepoint) ||
|
|
640
|
+
codepoint == 41 /* TokenMap.RIGHT_PARENTHESIS */ ||
|
|
641
|
+
codepoint == 59 /* TokenMap.SEMICOLON */ ||
|
|
642
|
+
codepoint == 125 /* TokenMap.RIGHT_BRACE */ ||
|
|
643
|
+
codepoint == 43 /* TokenMap.PLUS */ ||
|
|
644
|
+
codepoint == 47 /* TokenMap.SLASH */ ||
|
|
645
|
+
codepoint == 42 /* TokenMap.STAR */ ||
|
|
646
|
+
codepoint == 44 /* TokenMap.COMMA */) {
|
|
647
|
+
this.slice = slice;
|
|
648
|
+
this.hint = getSymbolHint(parseInfo, slice, position) ?? EnumToken.DimensionTokenType;
|
|
649
|
+
return position - offset;
|
|
650
|
+
}
|
|
651
|
+
return 0;
|
|
652
|
+
}
|
|
653
|
+
return 0;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
*
|
|
657
|
+
* @param parseInfo
|
|
658
|
+
* @returns
|
|
659
|
+
*/
|
|
660
|
+
consumeIdentToken(parseInfo) {
|
|
661
|
+
let position = parseInfo.currentPosition - parseInfo.offset;
|
|
662
|
+
let offset = position;
|
|
663
|
+
let codepoint = parseInfo.stream.charCodeAt(position);
|
|
664
|
+
if (!isIdentStart(codepoint) && codepoint != 45 /* TokenMap.MINUS */) {
|
|
665
|
+
return 0;
|
|
666
|
+
}
|
|
667
|
+
if (codepoint == 45 /* TokenMap.MINUS */) {
|
|
668
|
+
position++;
|
|
669
|
+
codepoint = parseInfo.stream.charCodeAt(position);
|
|
670
|
+
if (!isIdentStart(codepoint) && codepoint != 45 /* TokenMap.MINUS */) {
|
|
671
|
+
return 0;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
while ((codepoint = parseInfo.stream.charCodeAt(position)) == codepoint) {
|
|
675
|
+
if (codepoint == 92 /* TokenMap.REVERSE_SOLIDUS */) {
|
|
676
|
+
// eof
|
|
677
|
+
if ((codepoint = parseInfo.stream.charCodeAt(position + 1)) != codepoint) {
|
|
678
|
+
// this.next(parseInfo, position);
|
|
679
|
+
return 0;
|
|
540
680
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
681
|
+
// \n \r \f \v
|
|
682
|
+
if (codepoint == 0xa ||
|
|
683
|
+
codepoint == 0xb ||
|
|
684
|
+
codepoint == 0xc ||
|
|
685
|
+
codepoint == 0xd ||
|
|
686
|
+
codepoint == 0x2028 ||
|
|
687
|
+
codepoint == 0x2029) {
|
|
688
|
+
return 0;
|
|
548
689
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
690
|
+
position += 2;
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
if (codepoint == 0x2d || isIdentCodepoint(codepoint)) {
|
|
694
|
+
position++;
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
switch (codepoint) {
|
|
698
|
+
case 58 /* TokenMap.COLON */:
|
|
699
|
+
case 123 /* TokenMap.LEFT_BRACE */:
|
|
700
|
+
case 125 /* TokenMap.RIGHT_BRACE */:
|
|
701
|
+
case 40 /* TokenMap.LEFT_PARENTHESIS */:
|
|
702
|
+
case 41 /* TokenMap.RIGHT_PARENTHESIS */:
|
|
703
|
+
case 91 /* TokenMap.LEFT_BRACKETS */:
|
|
704
|
+
case 93 /* TokenMap.RIGHT_BRACKETS */:
|
|
705
|
+
case 59 /* TokenMap.SEMICOLON */:
|
|
706
|
+
case 33 /* TokenMap.EXCLAMATION */:
|
|
707
|
+
case 47 /* TokenMap.SLASH */:
|
|
708
|
+
case 35 /* TokenMap.HASH */:
|
|
709
|
+
case 42 /* TokenMap.STAR */:
|
|
710
|
+
case 61 /* TokenMap.EQUALS */:
|
|
711
|
+
case 126 /* TokenMap.TILDA */:
|
|
712
|
+
case 124 /* TokenMap.PIPE */:
|
|
713
|
+
case 94 /* TokenMap.CARET */:
|
|
714
|
+
case 36 /* TokenMap.DOLLAR */:
|
|
715
|
+
case 44 /* TokenMap.COMMA */:
|
|
716
|
+
case 62 /* TokenMap.GREATERTHAN */:
|
|
717
|
+
case 46 /* TokenMap.DOT */:
|
|
718
|
+
case 43 /* TokenMap.PLUS */:
|
|
719
|
+
return position - offset;
|
|
555
720
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
case 58 /* TokenMap.COLON */:
|
|
559
|
-
if (buffer.length > 0) {
|
|
560
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
561
|
-
buffer = "";
|
|
721
|
+
if (codepoint != codepoint || isWhiteSpace(codepoint)) {
|
|
722
|
+
return position - offset;
|
|
562
723
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
724
|
+
return 0;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
return position - offset;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
*
|
|
731
|
+
* @param parseInfo
|
|
732
|
+
* @returns
|
|
733
|
+
*/
|
|
734
|
+
consumeColor(parseInfo) {
|
|
735
|
+
let position = parseInfo.currentPosition - parseInfo.offset;
|
|
736
|
+
let offset = position;
|
|
737
|
+
let codepoint = parseInfo.stream.charCodeAt(position);
|
|
738
|
+
if (codepoint != 35 /* TokenMap.HASH */) {
|
|
739
|
+
return 0;
|
|
740
|
+
}
|
|
741
|
+
position++;
|
|
742
|
+
let count = 0;
|
|
743
|
+
while (true) {
|
|
744
|
+
codepoint = parseInfo.stream.charCodeAt(position);
|
|
745
|
+
// 'a-f0-9' 'A-F0-9'
|
|
746
|
+
if ((codepoint >= 0x30 && codepoint <= 0x39) ||
|
|
747
|
+
(codepoint >= 0x61 && codepoint <= 0x66) ||
|
|
748
|
+
(codepoint >= 0x41 && codepoint <= 0x46)) {
|
|
749
|
+
position++;
|
|
750
|
+
count++;
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
753
|
+
break;
|
|
754
|
+
}
|
|
755
|
+
if (count != 3 && count != 4 && count != 6 && count != 8) {
|
|
756
|
+
return 0;
|
|
757
|
+
}
|
|
758
|
+
codepoint = parseInfo.stream.charCodeAt(position);
|
|
759
|
+
if (codepoint != codepoint ||
|
|
760
|
+
isWhiteSpace(codepoint) ||
|
|
761
|
+
codepoint == 41 /* TokenMap.RIGHT_PARENTHESIS */ ||
|
|
762
|
+
codepoint == 59 /* TokenMap.SEMICOLON */ ||
|
|
763
|
+
codepoint == 125 /* TokenMap.RIGHT_BRACE */ ||
|
|
764
|
+
codepoint == 44 /* TokenMap.COMMA */) {
|
|
765
|
+
return position - offset;
|
|
766
|
+
}
|
|
767
|
+
return 0;
|
|
768
|
+
}
|
|
769
|
+
parseURLToken(parseInfo, endPosition) {
|
|
770
|
+
let charCode;
|
|
771
|
+
// consume an <url>
|
|
772
|
+
while (isWhiteSpace(this.peekCharCode(parseInfo))) {
|
|
773
|
+
this.advance(parseInfo);
|
|
774
|
+
}
|
|
775
|
+
charCode = this.peekCharCode(parseInfo);
|
|
776
|
+
if (charCode == 34 /* TokenMap.DOUBLE_QUOTE */ || charCode == 39 /* TokenMap.SINGLE_QUOTE */) {
|
|
777
|
+
return this.consumeURLToken(parseInfo);
|
|
778
|
+
}
|
|
779
|
+
do {
|
|
780
|
+
this.advance(parseInfo);
|
|
781
|
+
charCode = this.peekCharCode(parseInfo);
|
|
782
|
+
} while (
|
|
783
|
+
// !(value === "/" && this.match(parseInfo, "/*") &&
|
|
784
|
+
charCode !== 41 /* TokenMap.RIGHT_PARENTHESIS */ &&
|
|
785
|
+
parseInfo.currentPosition < endPosition);
|
|
786
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
787
|
+
return this.makeToken(parseInfo,
|
|
788
|
+
// parseInfo.position < parseInfo.currentPosition
|
|
789
|
+
(charCode = this.peekCharCode(parseInfo)) != charCode || !this.isURLToken(parseInfo)
|
|
790
|
+
? EnumToken.BadUrlTokenType
|
|
791
|
+
: EnumToken.UrlTokenTokenType);
|
|
792
|
+
// }
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
*
|
|
796
|
+
* @param parseInfo
|
|
797
|
+
* @param hint
|
|
798
|
+
* @param options
|
|
799
|
+
* @returns
|
|
800
|
+
*/
|
|
801
|
+
makeToken(parseInfo, hint, options) {
|
|
802
|
+
let val = null;
|
|
803
|
+
this.typ = null;
|
|
804
|
+
this.nam = null;
|
|
805
|
+
this.val = null;
|
|
806
|
+
this.unit = null;
|
|
807
|
+
this.kin = null;
|
|
808
|
+
this.decodeString = null;
|
|
809
|
+
this.slice = null;
|
|
810
|
+
this.hint = null;
|
|
811
|
+
if (options?.slice) {
|
|
812
|
+
this.slice = options.slice;
|
|
813
|
+
}
|
|
814
|
+
if (options?.decodeSegments) {
|
|
815
|
+
this.decodeString = true;
|
|
816
|
+
}
|
|
817
|
+
if (hint != null) {
|
|
818
|
+
let array = null;
|
|
819
|
+
let hasUnit = false;
|
|
820
|
+
switch (hint) {
|
|
821
|
+
case EnumToken.TransformFunctionTokenDefType:
|
|
822
|
+
array = transformFunctions;
|
|
823
|
+
break;
|
|
824
|
+
case EnumToken.ColorFunctionTokenDefType:
|
|
825
|
+
array = colorsFunc;
|
|
826
|
+
break;
|
|
827
|
+
case EnumToken.ContainerFunctionTokenDefType:
|
|
828
|
+
array = containerFunc;
|
|
829
|
+
break;
|
|
830
|
+
case EnumToken.UrlFunctionTokenDefType:
|
|
831
|
+
array = urlFunc;
|
|
832
|
+
break;
|
|
833
|
+
case EnumToken.GridTemplateFuncTokenDefType:
|
|
834
|
+
array = gridTemplateFunc;
|
|
835
|
+
break;
|
|
836
|
+
case EnumToken.ImageFunctionTokenDefType:
|
|
837
|
+
array = imageFunc;
|
|
838
|
+
break;
|
|
839
|
+
case EnumToken.TimelineFunctionTokenDefType:
|
|
840
|
+
array = timelineFunc;
|
|
841
|
+
break;
|
|
842
|
+
// case EnumToken.GeneralEnclosedFunctionTokenDefType:
|
|
843
|
+
// searchArray = generalEnclosedFunc;
|
|
844
|
+
// break;
|
|
845
|
+
case EnumToken.SupportsFunctionTokenDefType:
|
|
846
|
+
array = supportFunc;
|
|
847
|
+
break;
|
|
848
|
+
case EnumToken.TimingFunctionTokenDefType:
|
|
849
|
+
array = timingFunc;
|
|
850
|
+
break;
|
|
851
|
+
case EnumToken.MathFunctionTokenDefType:
|
|
852
|
+
array = mathFuncs;
|
|
853
|
+
break;
|
|
854
|
+
case EnumToken.WhenElseFunctionTokenDefType:
|
|
855
|
+
array = whenElseFunc;
|
|
856
|
+
break;
|
|
857
|
+
case EnumToken.WildCardFunctionTokenDefType:
|
|
858
|
+
array = wildCardFuncs;
|
|
859
|
+
break;
|
|
860
|
+
case EnumToken.FrequencyTokenType:
|
|
861
|
+
array = frequencyUnits;
|
|
862
|
+
hasUnit = true;
|
|
863
|
+
break;
|
|
864
|
+
case EnumToken.ResolutionTokenType:
|
|
865
|
+
array = resolutionUnits;
|
|
866
|
+
hasUnit = true;
|
|
867
|
+
break;
|
|
868
|
+
case EnumToken.LengthTokenType:
|
|
869
|
+
array = dimensionUnits;
|
|
870
|
+
hasUnit = true;
|
|
566
871
|
break;
|
|
872
|
+
case EnumToken.FlexTokenType:
|
|
873
|
+
array = flexUnits;
|
|
874
|
+
hasUnit = true;
|
|
875
|
+
break;
|
|
876
|
+
case EnumToken.AngleTokenType:
|
|
877
|
+
array = angleUnits;
|
|
878
|
+
hasUnit = true;
|
|
879
|
+
break;
|
|
880
|
+
case EnumToken.TimeTokenType:
|
|
881
|
+
array = timeUnits;
|
|
882
|
+
hasUnit = true;
|
|
883
|
+
break;
|
|
884
|
+
case EnumToken.DimensionTokenType:
|
|
885
|
+
hasUnit = true;
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
888
|
+
if (array != null) {
|
|
889
|
+
val = searchArray(array, parseInfo, hasUnit ? options?.slice : parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset);
|
|
890
|
+
}
|
|
891
|
+
else if (!hintsEnum.has(hint)) {
|
|
892
|
+
val = parseInfo.stream.slice(options?.slice ?? parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset);
|
|
893
|
+
}
|
|
894
|
+
if (this.decodeString) {
|
|
895
|
+
val = decodeEscapeSequences(val);
|
|
896
|
+
}
|
|
897
|
+
if (hintsEnum.has(hint)) {
|
|
898
|
+
this.typ = hint;
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
this.typ = hint;
|
|
902
|
+
if (hasUnit || hint == EnumToken.PercentageTokenType || hint == EnumToken.DimensionTokenType) {
|
|
903
|
+
this.val = parseFloat(parseInfo.stream.slice(parseInfo.position - parseInfo.offset, options?.slice));
|
|
904
|
+
if (hint != EnumToken.PercentageTokenType) {
|
|
905
|
+
this.unit = val;
|
|
906
|
+
}
|
|
567
907
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
// \n \r \f \v \t space
|
|
571
|
-
case 0x9:
|
|
572
|
-
case 0x20:
|
|
573
|
-
case 0xa:
|
|
574
|
-
case 0xb:
|
|
575
|
-
case 0xc:
|
|
576
|
-
case 0xd:
|
|
577
|
-
case 0x2028:
|
|
578
|
-
case 0x2029:
|
|
579
|
-
if (buffer.length > 0) {
|
|
580
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
581
|
-
buffer = "";
|
|
582
|
-
}
|
|
583
|
-
buffer += next(parseInfo);
|
|
584
|
-
nextCharCode = parseInfo.stream.charAt(parseInfo.currentPosition - parseInfo.offset + 1).charCodeAt(0);
|
|
585
|
-
while (nextCharCode == 0x20 ||
|
|
586
|
-
(nextCharCode >= 0x9 && nextCharCode <= 0xd) ||
|
|
587
|
-
nextCharCode == 0x2028 ||
|
|
588
|
-
nextCharCode == 0x2029) {
|
|
589
|
-
value += next(parseInfo);
|
|
590
|
-
nextCharCode = parseInfo.stream
|
|
591
|
-
.charAt(parseInfo.currentPosition - parseInfo.offset + 1)
|
|
592
|
-
.charCodeAt(0);
|
|
593
|
-
}
|
|
594
|
-
result.push(yieldResult(value, parseInfo, EnumToken.WhitespaceTokenType));
|
|
595
|
-
buffer = "";
|
|
596
|
-
break;
|
|
597
|
-
case 44 /* TokenMap.COMMA */:
|
|
598
|
-
if (buffer.length > 0) {
|
|
599
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
600
|
-
buffer = "";
|
|
908
|
+
else if (hint == EnumToken.NumberTokenType) {
|
|
909
|
+
this.val = parseFloat(val);
|
|
601
910
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
case 36 /* TokenMap.DOLLAR */:
|
|
605
|
-
if (buffer.length > 0) {
|
|
606
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
607
|
-
buffer = "";
|
|
911
|
+
else if (hint == EnumToken.AtRuleTokenType) {
|
|
912
|
+
this.nam = val;
|
|
608
913
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
914
|
+
else {
|
|
915
|
+
this.val = val;
|
|
916
|
+
if (hint == EnumToken.ColorTokenType) {
|
|
917
|
+
this.kin = ColorType.HEX;
|
|
918
|
+
}
|
|
612
919
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
else {
|
|
923
|
+
if (this.equalsIgnoreCase(parseInfo, "!important")) {
|
|
924
|
+
this.typ = EnumToken.ImportantTokenType;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
if (this.typ == null) {
|
|
928
|
+
val = parseInfo.stream.slice(parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset);
|
|
929
|
+
if (options?.decodeSegments) {
|
|
930
|
+
val = decodeEscapeSequences(val);
|
|
931
|
+
this.decodeString = true;
|
|
932
|
+
}
|
|
933
|
+
this.typ = EnumToken.LiteralTokenType;
|
|
934
|
+
this.val = val;
|
|
935
|
+
}
|
|
936
|
+
this.srcId = parseInfo.source.id;
|
|
937
|
+
this.sta = parseInfo.position;
|
|
938
|
+
this.end = parseInfo.currentPosition;
|
|
939
|
+
this.bytesIn = parseInfo.currentPosition;
|
|
940
|
+
parseInfo.position = parseInfo.currentPosition;
|
|
941
|
+
return this;
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
*
|
|
945
|
+
* @param parseInfo
|
|
946
|
+
* @param input
|
|
947
|
+
* @returns
|
|
948
|
+
*/
|
|
949
|
+
equalsIgnoreCase(parseInfo, input) {
|
|
950
|
+
let position = parseInfo.currentPosition - parseInfo.offset;
|
|
951
|
+
let ca;
|
|
952
|
+
let cb;
|
|
953
|
+
for (let i = 0; i < input.length; i++) {
|
|
954
|
+
ca = parseInfo.stream.charCodeAt(position + i);
|
|
955
|
+
cb = input.charCodeAt(i);
|
|
956
|
+
// Normalize A-Z to a-z
|
|
957
|
+
if (ca >= 65 && ca <= 90)
|
|
958
|
+
ca += 32;
|
|
959
|
+
if (cb >= 65 && cb <= 90)
|
|
960
|
+
cb += 32;
|
|
961
|
+
if (ca != cb) {
|
|
962
|
+
return false;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
*
|
|
969
|
+
* @param parseInfo
|
|
970
|
+
* @param input
|
|
971
|
+
* @returns
|
|
972
|
+
*/
|
|
973
|
+
match(parseInfo, input) {
|
|
974
|
+
let position = parseInfo.currentPosition - parseInfo.offset;
|
|
975
|
+
for (let i = 0; i < input.length; i++) {
|
|
976
|
+
if (parseInfo.stream[position + i] != input.charAt(i)) {
|
|
977
|
+
return false;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
return true;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Get the current character code without creating a string
|
|
984
|
+
* @param parseInfo
|
|
985
|
+
* @returns charCode at current position
|
|
986
|
+
*/
|
|
987
|
+
peekCharCode(parseInfo) {
|
|
988
|
+
return parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
*
|
|
992
|
+
* @param parseInfo
|
|
993
|
+
* @param count
|
|
994
|
+
* @returns
|
|
995
|
+
*/
|
|
996
|
+
peek(parseInfo, count = 1) {
|
|
997
|
+
if (count == 1) {
|
|
998
|
+
return parseInfo.stream.charAt(parseInfo.currentPosition - parseInfo.offset);
|
|
999
|
+
}
|
|
1000
|
+
const position = parseInfo.currentPosition - parseInfo.offset;
|
|
1001
|
+
return parseInfo.stream.slice(position, position + count);
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
*
|
|
1005
|
+
* @param parseInfo
|
|
1006
|
+
* @param count
|
|
1007
|
+
* @returns
|
|
1008
|
+
*/
|
|
1009
|
+
advance(parseInfo, count = 1) {
|
|
1010
|
+
let position = parseInfo.currentPosition - parseInfo.offset;
|
|
1011
|
+
let char = count == 1 ? parseInfo.stream.charAt(position) : parseInfo.stream.slice(position, position + count);
|
|
1012
|
+
let i = 0;
|
|
1013
|
+
let codepoint;
|
|
1014
|
+
const lineStarts = parseInfo.source.lineStarts.lineStarts;
|
|
1015
|
+
for (; i < char.length; i++) {
|
|
1016
|
+
codepoint = char.charCodeAt(i);
|
|
1017
|
+
if (codepoint == 0xa || // \n
|
|
1018
|
+
codepoint == 0xb || // \v
|
|
1019
|
+
codepoint == 0xc || // \f
|
|
1020
|
+
codepoint == 0xd || // \r
|
|
1021
|
+
codepoint == 0x2028 || // \u2028
|
|
1022
|
+
codepoint == 0x2029 // \u2029
|
|
1023
|
+
) {
|
|
1024
|
+
// \r\n
|
|
1025
|
+
if (codepoint == 0xa && i > 0 && char.charCodeAt(i - 1) == 0xd) ;
|
|
1026
|
+
else {
|
|
1027
|
+
lineStarts.push(position + parseInfo.offset + i);
|
|
619
1028
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
parseInfo.currentPosition += char.length;
|
|
1032
|
+
return char;
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
*
|
|
1036
|
+
* @param parseInfo
|
|
1037
|
+
* @param start
|
|
1038
|
+
* @param end
|
|
1039
|
+
* @returns
|
|
1040
|
+
*/
|
|
1041
|
+
isIdentToken(parseInfo, start, end) {
|
|
1042
|
+
let j = parseInfo.currentPosition - parseInfo.offset;
|
|
1043
|
+
let i = parseInfo.position - parseInfo.offset;
|
|
1044
|
+
if (start != null) {
|
|
1045
|
+
if (end == null) {
|
|
1046
|
+
if (start < 0) {
|
|
1047
|
+
j += start;
|
|
623
1048
|
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
break;
|
|
627
|
-
// case '^':
|
|
628
|
-
case 94 /* TokenMap.CARET */:
|
|
629
|
-
if (buffer.length > 0) {
|
|
630
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
631
|
-
buffer = "";
|
|
1049
|
+
else {
|
|
1050
|
+
i += start;
|
|
632
1051
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
1052
|
+
}
|
|
1053
|
+
else {
|
|
1054
|
+
if (end < 0) {
|
|
1055
|
+
j += end;
|
|
636
1056
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
case 42 /* TokenMap.STAR */:
|
|
640
|
-
if (buffer.length > 0) {
|
|
641
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
642
|
-
buffer = "";
|
|
1057
|
+
else {
|
|
1058
|
+
j = parseInfo.position + end;
|
|
643
1059
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
j--;
|
|
1063
|
+
let codepoint = parseInfo.stream.charCodeAt(i);
|
|
1064
|
+
// -
|
|
1065
|
+
if (codepoint == 0x2d) {
|
|
1066
|
+
let nextCodepoint;
|
|
1067
|
+
// NaN != NaN
|
|
1068
|
+
if ((nextCodepoint = parseInfo.stream.charCodeAt(i + 1)) != nextCodepoint) {
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
if (!isIdentStart(nextCodepoint) && nextCodepoint != 0x2d) {
|
|
1072
|
+
return false;
|
|
1073
|
+
}
|
|
1074
|
+
codepoint = nextCodepoint;
|
|
1075
|
+
i++;
|
|
1076
|
+
}
|
|
1077
|
+
if (codepoint !== 0x2d && !isIdentStart(codepoint)) {
|
|
1078
|
+
return false;
|
|
1079
|
+
}
|
|
1080
|
+
if (codepoint == 92 /* TokenMap.REVERSE_SOLIDUS */) {
|
|
1081
|
+
codepoint = parseInfo.stream.charCodeAt(i + 1);
|
|
1082
|
+
i += String.fromCodePoint(codepoint).length;
|
|
1083
|
+
}
|
|
1084
|
+
while (i < j) {
|
|
1085
|
+
i += codepoint < 0x80 ? 1 : String.fromCodePoint(codepoint).length;
|
|
1086
|
+
codepoint = parseInfo.stream.charCodeAt(i);
|
|
1087
|
+
if (codepoint == 92 /* TokenMap.REVERSE_SOLIDUS */) {
|
|
1088
|
+
i += codepoint < 0x80 ? 1 : String.fromCodePoint(codepoint).length;
|
|
1089
|
+
codepoint = parseInfo.stream.charCodeAt(i);
|
|
1090
|
+
i += codepoint < 0x80 ? 1 : String.fromCodePoint(codepoint).length;
|
|
1091
|
+
continue;
|
|
1092
|
+
}
|
|
1093
|
+
if (codepoint !== 0x2d && !isIdentCodepoint(codepoint)) {
|
|
1094
|
+
return false;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
return true;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
*
|
|
1101
|
+
* @param parseInfo
|
|
1102
|
+
* @returns
|
|
1103
|
+
*/
|
|
1104
|
+
isPseudo(parseInfo) {
|
|
1105
|
+
let position = parseInfo.currentPosition - parseInfo.offset;
|
|
1106
|
+
let endPosition = parseInfo.currentPosition - parseInfo.offset;
|
|
1107
|
+
return (parseInfo.stream.charAt(position) == ":" &&
|
|
1108
|
+
parseInfo.stream.charAt(endPosition - 1) == "(" &&
|
|
1109
|
+
(parseInfo.stream.charAt(position + 1) == ":"
|
|
1110
|
+
? this.isIdentToken(parseInfo, 2, -1)
|
|
1111
|
+
: this.isIdentToken(parseInfo, 1, -1))) ||
|
|
1112
|
+
parseInfo.stream.charAt(position + 1) == ":"
|
|
1113
|
+
? this.isIdentToken(parseInfo, 2)
|
|
1114
|
+
: this.isIdentToken(parseInfo, 1);
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
*
|
|
1118
|
+
* @param parseInfo
|
|
1119
|
+
* @param input
|
|
1120
|
+
* @returns
|
|
1121
|
+
*/
|
|
1122
|
+
startsWith(parseInfo, input) {
|
|
1123
|
+
let i = 0;
|
|
1124
|
+
let j = input.length;
|
|
1125
|
+
while (i < j) {
|
|
1126
|
+
if (parseInfo.stream.charAt(parseInfo.position - parseInfo.offset + i) != input.charAt(i)) {
|
|
1127
|
+
return false;
|
|
1128
|
+
}
|
|
1129
|
+
i++;
|
|
1130
|
+
}
|
|
1131
|
+
return true;
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
*
|
|
1135
|
+
* @param parseInfo
|
|
1136
|
+
* @returns
|
|
1137
|
+
*/
|
|
1138
|
+
isURLToken(parseInfo) {
|
|
1139
|
+
let i = parseInfo.position - parseInfo.offset;
|
|
1140
|
+
let c;
|
|
1141
|
+
while (++i < parseInfo.currentPosition) {
|
|
1142
|
+
c = parseInfo.stream.charCodeAt(i);
|
|
1143
|
+
// single quote or double quote or start parenthesis or close parenthesis
|
|
1144
|
+
if (isNonPrintable(c) || c == 0x27 || c == 0x22 || c == 0x28 || c == 0x29) {
|
|
1145
|
+
return false;
|
|
1146
|
+
}
|
|
1147
|
+
// valid escape
|
|
1148
|
+
if (c == 92 /* TokenMap.REVERSE_SOLIDUS */) {
|
|
1149
|
+
i++;
|
|
1150
|
+
if (i >= parseInfo.currentPosition) {
|
|
1151
|
+
return false;
|
|
647
1152
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
if (buffer.length > 0) {
|
|
653
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
654
|
-
buffer = "";
|
|
1153
|
+
c = parseInfo.stream.charCodeAt(i);
|
|
1154
|
+
// c is not '\n' or '\r' or '\f'
|
|
1155
|
+
if (c == 0x6e || c == 0x72 || c == 0x66) {
|
|
1156
|
+
return false;
|
|
655
1157
|
}
|
|
656
|
-
|
|
657
|
-
|
|
1158
|
+
continue;
|
|
1159
|
+
}
|
|
1160
|
+
// is white space
|
|
1161
|
+
if (c == 0x20 || c == 0x09) {
|
|
658
1162
|
break;
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
return i == parseInfo.currentPosition;
|
|
1166
|
+
}
|
|
1167
|
+
done() {
|
|
1168
|
+
return this.typ === EnumToken.EOF;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Tokenize CSS string
|
|
1172
|
+
* @param parseInfo
|
|
1173
|
+
* @param yieldEOFToken
|
|
1174
|
+
*/
|
|
1175
|
+
next( /* parseInfo: ParseInfo | string, yieldEOFToken: boolean = true */) {
|
|
1176
|
+
const parseInfo = this.parseInfo;
|
|
1177
|
+
this.source = parseInfo.source;
|
|
1178
|
+
let charCode;
|
|
1179
|
+
let nextCharCode;
|
|
1180
|
+
// const result: TokenizeResult[] = [];
|
|
1181
|
+
// allow 10 characters buffer for the streaming parser to avoid incomplete tokens
|
|
1182
|
+
const endPosition = parseInfo.stream.length - 1; // yieldEOFToken ? parseInfo.stream.length - 1 : parseInfo.stream.length - 10;
|
|
1183
|
+
let tokensCount;
|
|
1184
|
+
// NaN is not equal to NaN
|
|
1185
|
+
while ((charCode = this.peekCharCode(parseInfo)) == charCode) {
|
|
1186
|
+
if (this.state === EnumToken.UrlFunctionTokenDefType) {
|
|
1187
|
+
this.state = null;
|
|
1188
|
+
return this.parseURLToken(parseInfo, endPosition);
|
|
1189
|
+
}
|
|
1190
|
+
if (parseInfo.position == parseInfo.currentPosition) {
|
|
1191
|
+
if (charCode == 45 /* TokenMap.MINUS */ ||
|
|
1192
|
+
charCode == 43 /* TokenMap.PLUS */ ||
|
|
1193
|
+
charCode == 46 /* TokenMap.DOT */ ||
|
|
1194
|
+
isDigit(charCode)) {
|
|
1195
|
+
tokensCount = this.consumeNumericToken(parseInfo);
|
|
1196
|
+
if (tokensCount > 0) {
|
|
1197
|
+
this.advance(parseInfo, tokensCount);
|
|
1198
|
+
return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, {
|
|
1199
|
+
slice: this.slice,
|
|
1200
|
+
sign: charCode == 45 /* TokenMap.MINUS */ ? "-" : charCode == 43 /* TokenMap.PLUS */ ? "+" : null,
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
663
1203
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
1204
|
+
if (isIdentStart(charCode) || charCode == 45 /* TokenMap.MINUS */) {
|
|
1205
|
+
tokensCount = this.consumeIdentToken(parseInfo);
|
|
1206
|
+
if (tokensCount > 0) {
|
|
1207
|
+
this.advance(parseInfo, tokensCount);
|
|
1208
|
+
charCode = this.peekCharCode(parseInfo);
|
|
1209
|
+
// do not match function
|
|
1210
|
+
if (40 /* TokenMap.LEFT_PARENTHESIS */ != charCode) {
|
|
1211
|
+
return this.makeToken(parseInfo, this.startsWith(parseInfo, "--")
|
|
1212
|
+
? EnumToken.DashedIdenTokenType
|
|
1213
|
+
: EnumToken.IdenTokenType);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
668
1216
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
1217
|
+
if (charCode == 64 /* TokenMap.AT */) {
|
|
1218
|
+
this.advance(parseInfo);
|
|
1219
|
+
charCode = this.peekCharCode(parseInfo);
|
|
1220
|
+
// match at-rule
|
|
1221
|
+
if (charCode == 45 /* TokenMap.MINUS */ || isIdentStart(this.peekCharCode(parseInfo))) {
|
|
1222
|
+
// consume '@'
|
|
1223
|
+
parseInfo.position = parseInfo.currentPosition;
|
|
1224
|
+
tokensCount = this.consumeIdentToken(parseInfo);
|
|
1225
|
+
if (tokensCount > 0) {
|
|
1226
|
+
this.advance(parseInfo, tokensCount);
|
|
1227
|
+
return this.makeToken(parseInfo, EnumToken.AtRuleTokenType);
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
672
1230
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
1231
|
+
if (charCode == 35 /* TokenMap.HASH */) {
|
|
1232
|
+
tokensCount = this.consumeColor(parseInfo);
|
|
1233
|
+
if (tokensCount > 0) {
|
|
1234
|
+
this.advance(parseInfo, tokensCount);
|
|
1235
|
+
return this.makeToken(parseInfo, EnumToken.ColorTokenType);
|
|
1236
|
+
}
|
|
1237
|
+
this.advance(parseInfo);
|
|
1238
|
+
tokensCount = this.consumeIdentToken(parseInfo);
|
|
1239
|
+
if (tokensCount > 0) {
|
|
1240
|
+
this.advance(parseInfo, tokensCount);
|
|
1241
|
+
return this.makeToken(parseInfo, EnumToken.HashTokenType);
|
|
1242
|
+
}
|
|
680
1243
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
1244
|
+
}
|
|
1245
|
+
// EOF
|
|
1246
|
+
switch (charCode) {
|
|
1247
|
+
case 61 /* TokenMap.EQUALS */:
|
|
1248
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1249
|
+
return this.makeToken(parseInfo);
|
|
1250
|
+
}
|
|
1251
|
+
this.advance(parseInfo);
|
|
1252
|
+
return this.makeToken(parseInfo, EnumToken.DelimTokenType);
|
|
1253
|
+
// '+' or '-'
|
|
1254
|
+
case 43 /* TokenMap.PLUS */:
|
|
1255
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1256
|
+
return this.makeToken(parseInfo);
|
|
1257
|
+
}
|
|
1258
|
+
this.advance(parseInfo);
|
|
1259
|
+
charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
1260
|
+
if (isDigit(charCode)) {
|
|
1261
|
+
tokensCount = this.consumeNumericToken(parseInfo);
|
|
1262
|
+
if (tokensCount > 0) {
|
|
1263
|
+
this.advance(parseInfo, tokensCount);
|
|
1264
|
+
return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, {
|
|
1265
|
+
slice: this.slice,
|
|
1266
|
+
sign: "+",
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
return this.makeToken(parseInfo, EnumToken.Plus);
|
|
1271
|
+
case 45 /* TokenMap.MINUS */:
|
|
1272
|
+
if (parseInfo.position == parseInfo.currentPosition) {
|
|
1273
|
+
nextCharCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
|
|
1274
|
+
// not a number
|
|
1275
|
+
if (isWhiteSpace(nextCharCode)) {
|
|
1276
|
+
this.advance(parseInfo);
|
|
1277
|
+
return this.makeToken(parseInfo, EnumToken.Sub);
|
|
1278
|
+
}
|
|
1279
|
+
if (charCode == 45 /* TokenMap.MINUS */ &&
|
|
1280
|
+
(nextCharCode == 45 /* TokenMap.MINUS */ || isIdentStart(nextCharCode))) {
|
|
1281
|
+
this.advance(parseInfo);
|
|
1282
|
+
tokensCount = this.consumeIdentToken(parseInfo);
|
|
1283
|
+
if (tokensCount > 0) {
|
|
1284
|
+
this.advance(parseInfo, tokensCount);
|
|
1285
|
+
return this.makeToken(parseInfo, EnumToken.IdenTokenType);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
this.advance(parseInfo);
|
|
684
1290
|
break;
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
1291
|
+
// '{'
|
|
1292
|
+
case 123 /* TokenMap.LEFT_BRACE */:
|
|
1293
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1294
|
+
return this.makeToken(parseInfo);
|
|
1295
|
+
}
|
|
1296
|
+
this.advance(parseInfo);
|
|
1297
|
+
return this.makeToken(parseInfo, EnumToken.BlockStartTokenType);
|
|
1298
|
+
// '}'
|
|
1299
|
+
case 125 /* TokenMap.RIGHT_BRACE */:
|
|
1300
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1301
|
+
return this.makeToken(parseInfo);
|
|
1302
|
+
}
|
|
1303
|
+
this.advance(parseInfo);
|
|
1304
|
+
return this.makeToken(parseInfo, EnumToken.BlockEndTokenType);
|
|
1305
|
+
// '('
|
|
1306
|
+
case 40 /* TokenMap.LEFT_PARENTHESIS */:
|
|
1307
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1308
|
+
if (parseInfo.stream[parseInfo.position - parseInfo.offset] === ":" &&
|
|
1309
|
+
this.isPseudo(parseInfo)) {
|
|
1310
|
+
this.advance(parseInfo);
|
|
1311
|
+
return this.makeToken(parseInfo, EnumToken.PseudoClassFunctionTokenDefType);
|
|
1312
|
+
}
|
|
1313
|
+
else if (this.isIdentToken(parseInfo)) {
|
|
1314
|
+
const hint = this.startsWith(parseInfo, "--")
|
|
1315
|
+
? EnumToken.CustomFunctionTokenDefType
|
|
1316
|
+
: (getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset + 1) ?? EnumToken.FunctionTokenDefType);
|
|
1317
|
+
this.makeToken(parseInfo, hint);
|
|
1318
|
+
this.advance(parseInfo);
|
|
1319
|
+
// consume '('
|
|
1320
|
+
parseInfo.position = parseInfo.currentPosition;
|
|
1321
|
+
if (hint === EnumToken.UrlFunctionTokenDefType) {
|
|
1322
|
+
this.state = hint;
|
|
1323
|
+
}
|
|
1324
|
+
return this;
|
|
705
1325
|
}
|
|
706
1326
|
}
|
|
707
|
-
|
|
708
|
-
|
|
1327
|
+
this.advance(parseInfo);
|
|
1328
|
+
return this.makeToken(parseInfo, EnumToken.StartParensTokenType);
|
|
1329
|
+
// ')'
|
|
1330
|
+
case 41 /* TokenMap.RIGHT_PARENTHESIS */:
|
|
1331
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1332
|
+
return this.makeToken(parseInfo);
|
|
709
1333
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
1334
|
+
this.advance(parseInfo);
|
|
1335
|
+
return this.makeToken(parseInfo, EnumToken.EndParensTokenType);
|
|
1336
|
+
// '['
|
|
1337
|
+
case 91 /* TokenMap.LEFT_BRACKETS */:
|
|
1338
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1339
|
+
return this.makeToken(parseInfo);
|
|
1340
|
+
}
|
|
1341
|
+
this.advance(parseInfo);
|
|
1342
|
+
return this.makeToken(parseInfo, EnumToken.AttrStartTokenType);
|
|
1343
|
+
// ']'
|
|
1344
|
+
case 93 /* TokenMap.RIGHT_BRACKETS */:
|
|
1345
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1346
|
+
return this.makeToken(parseInfo);
|
|
1347
|
+
}
|
|
1348
|
+
this.advance(parseInfo);
|
|
1349
|
+
return this.makeToken(parseInfo, EnumToken.AttrEndTokenType);
|
|
1350
|
+
case 59 /* TokenMap.SEMICOLON */:
|
|
1351
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1352
|
+
return this.makeToken(parseInfo);
|
|
1353
|
+
}
|
|
1354
|
+
this.advance(parseInfo);
|
|
1355
|
+
return this.makeToken(parseInfo, EnumToken.SemiColonTokenType);
|
|
1356
|
+
case 58 /* TokenMap.COLON */:
|
|
1357
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1358
|
+
return this.makeToken(parseInfo);
|
|
1359
|
+
}
|
|
1360
|
+
this.advance(parseInfo);
|
|
1361
|
+
if (this.peekCharCode(parseInfo) == 58 /* TokenMap.COLON */) {
|
|
1362
|
+
this.advance(parseInfo);
|
|
1363
|
+
return this.makeToken(parseInfo, EnumToken.DoubleColonTokenType);
|
|
1364
|
+
}
|
|
1365
|
+
return this.makeToken(parseInfo, EnumToken.ColonTokenType);
|
|
1366
|
+
// \n \r \f \v \t space
|
|
1367
|
+
case 0x9:
|
|
1368
|
+
case 0x20:
|
|
1369
|
+
case 0xa:
|
|
1370
|
+
case 0xb:
|
|
1371
|
+
case 0xc:
|
|
1372
|
+
case 0xd:
|
|
1373
|
+
case 0x2028:
|
|
1374
|
+
case 0x2029:
|
|
1375
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1376
|
+
return this.makeToken(parseInfo);
|
|
1377
|
+
}
|
|
1378
|
+
this.advance(parseInfo);
|
|
1379
|
+
nextCharCode = parseInfo.stream.charAt(parseInfo.currentPosition - parseInfo.offset).charCodeAt(0);
|
|
1380
|
+
while (nextCharCode == 0x20 ||
|
|
1381
|
+
(nextCharCode >= 0x9 && nextCharCode <= 0xd) ||
|
|
1382
|
+
nextCharCode == 0x2028 ||
|
|
1383
|
+
nextCharCode == 0x2029) {
|
|
1384
|
+
this.advance(parseInfo);
|
|
1385
|
+
nextCharCode = parseInfo.stream
|
|
1386
|
+
.charAt(parseInfo.currentPosition - parseInfo.offset)
|
|
1387
|
+
.charCodeAt(0);
|
|
1388
|
+
}
|
|
1389
|
+
return this.makeToken(parseInfo, EnumToken.WhitespaceTokenType);
|
|
1390
|
+
case 44 /* TokenMap.COMMA */:
|
|
1391
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1392
|
+
return this.makeToken(parseInfo);
|
|
1393
|
+
}
|
|
1394
|
+
this.advance(parseInfo);
|
|
1395
|
+
return this.makeToken(parseInfo, EnumToken.CommaTokenType);
|
|
1396
|
+
case 36 /* TokenMap.DOLLAR */:
|
|
1397
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1398
|
+
return this.makeToken(parseInfo);
|
|
1399
|
+
}
|
|
1400
|
+
if (this.match(parseInfo, "$=")) {
|
|
1401
|
+
this.advance(parseInfo, 2);
|
|
1402
|
+
return this.makeToken(parseInfo, EnumToken.EndMatchTokenType);
|
|
1403
|
+
}
|
|
1404
|
+
this.advance(parseInfo);
|
|
723
1405
|
break;
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
1406
|
+
case 126 /* TokenMap.TILDA */:
|
|
1407
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1408
|
+
return this.makeToken(parseInfo);
|
|
1409
|
+
}
|
|
1410
|
+
if (this.match(parseInfo, "~=")) {
|
|
1411
|
+
this.advance(parseInfo, 2);
|
|
1412
|
+
return this.makeToken(parseInfo, EnumToken.IncludeMatchTokenType);
|
|
1413
|
+
}
|
|
1414
|
+
this.advance(parseInfo);
|
|
1415
|
+
return this.makeToken(parseInfo, EnumToken.Tilda);
|
|
1416
|
+
// case '^':
|
|
1417
|
+
case 94 /* TokenMap.CARET */:
|
|
1418
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1419
|
+
return this.makeToken(parseInfo);
|
|
1420
|
+
}
|
|
1421
|
+
if (this.match(parseInfo, "^=")) {
|
|
1422
|
+
this.advance(parseInfo, 2);
|
|
1423
|
+
return this.makeToken(parseInfo, EnumToken.StartMatchTokenType);
|
|
1424
|
+
}
|
|
1425
|
+
this.advance(parseInfo);
|
|
735
1426
|
break;
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
1427
|
+
case 42 /* TokenMap.STAR */:
|
|
1428
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1429
|
+
return this.makeToken(parseInfo);
|
|
1430
|
+
}
|
|
1431
|
+
if (this.match(parseInfo, "*=")) {
|
|
1432
|
+
this.advance(parseInfo, 2);
|
|
1433
|
+
return this.makeToken(parseInfo, EnumToken.ContainMatchTokenType);
|
|
1434
|
+
}
|
|
1435
|
+
this.advance(parseInfo);
|
|
1436
|
+
return this.makeToken(parseInfo, EnumToken.Star);
|
|
1437
|
+
case 38 /* TokenMap.AMPERSAND */:
|
|
1438
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1439
|
+
return this.makeToken(parseInfo);
|
|
1440
|
+
}
|
|
1441
|
+
this.advance(parseInfo);
|
|
1442
|
+
return this.makeToken(parseInfo, EnumToken.NestingSelectorTokenType);
|
|
1443
|
+
case 124 /* TokenMap.PIPE */:
|
|
1444
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1445
|
+
return this.makeToken(parseInfo);
|
|
1446
|
+
}
|
|
1447
|
+
// '||'
|
|
1448
|
+
if (this.match(parseInfo, "||")) {
|
|
1449
|
+
this.advance(parseInfo, 2);
|
|
1450
|
+
return this.makeToken(parseInfo, EnumToken.ColumnCombinatorTokenType);
|
|
1451
|
+
}
|
|
1452
|
+
else if (this.match(parseInfo, "|=")) {
|
|
1453
|
+
this.advance(parseInfo, 2);
|
|
1454
|
+
return this.makeToken(parseInfo, EnumToken.DashMatchTokenType);
|
|
1455
|
+
}
|
|
1456
|
+
this.advance(parseInfo);
|
|
1457
|
+
return this.makeToken(parseInfo, EnumToken.Pipe);
|
|
1458
|
+
case 33 /* TokenMap.EXCLAMATION */:
|
|
1459
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1460
|
+
return this.makeToken(parseInfo);
|
|
1461
|
+
}
|
|
1462
|
+
if (this.match(parseInfo, "!important")) {
|
|
1463
|
+
this.advance(parseInfo, 10);
|
|
1464
|
+
return this.makeToken(parseInfo, EnumToken.ImportantTokenType);
|
|
1465
|
+
}
|
|
1466
|
+
this.advance(parseInfo);
|
|
1467
|
+
break;
|
|
1468
|
+
case 47 /* TokenMap.SLASH */:
|
|
1469
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1470
|
+
return this.makeToken(parseInfo);
|
|
1471
|
+
}
|
|
1472
|
+
if (!this.match(parseInfo, "/*")) {
|
|
1473
|
+
this.advance(parseInfo);
|
|
1474
|
+
return this.makeToken(parseInfo, getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset));
|
|
1475
|
+
}
|
|
1476
|
+
this.advance(parseInfo, 2);
|
|
1477
|
+
while ((charCode = this.advance(parseInfo).charCodeAt(0)) == charCode) {
|
|
1478
|
+
if (charCode == 42 /* TokenMap.STAR */) {
|
|
1479
|
+
if (this.match(parseInfo, "/")) {
|
|
1480
|
+
this.advance(parseInfo);
|
|
1481
|
+
return this.makeToken(parseInfo, EnumToken.CommentTokenType);
|
|
1482
|
+
}
|
|
744
1483
|
}
|
|
745
1484
|
}
|
|
746
|
-
if (
|
|
747
|
-
|
|
1485
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1486
|
+
return this.makeToken(parseInfo, EnumToken.BadCommentTokenType);
|
|
748
1487
|
}
|
|
749
|
-
|
|
750
|
-
|
|
1488
|
+
break;
|
|
1489
|
+
case 62 /* TokenMap.GREATERTHAN */:
|
|
1490
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1491
|
+
return this.makeToken(parseInfo);
|
|
1492
|
+
}
|
|
1493
|
+
if (this.match(parseInfo, ">=")) {
|
|
1494
|
+
this.advance(parseInfo, 2);
|
|
1495
|
+
return this.makeToken(parseInfo, EnumToken.GteTokenType);
|
|
1496
|
+
}
|
|
1497
|
+
this.advance(parseInfo);
|
|
1498
|
+
return this.makeToken(parseInfo, EnumToken.GtTokenType);
|
|
1499
|
+
case 60 /* TokenMap.LOWERTHAN */:
|
|
1500
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1501
|
+
return this.makeToken(parseInfo);
|
|
1502
|
+
}
|
|
1503
|
+
if (this.match(parseInfo, "<=")) {
|
|
1504
|
+
this.advance(parseInfo, 2);
|
|
1505
|
+
return this.makeToken(parseInfo, EnumToken.LteTokenType);
|
|
1506
|
+
}
|
|
1507
|
+
this.advance(parseInfo);
|
|
1508
|
+
if (this.match(parseInfo, "!--")) {
|
|
1509
|
+
this.advance(parseInfo, 3);
|
|
1510
|
+
while ((charCode = this.advance(parseInfo).charCodeAt(0)) == charCode) {
|
|
1511
|
+
if (charCode == 45 /* TokenMap.MINUS */ && this.match(parseInfo, "->")) {
|
|
1512
|
+
break;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
if (parseInfo.currentPosition >= endPosition) {
|
|
1516
|
+
return this.makeToken(parseInfo, EnumToken.BadCdoTokenType);
|
|
1517
|
+
}
|
|
1518
|
+
else {
|
|
1519
|
+
this.advance(parseInfo, 2);
|
|
1520
|
+
return this.makeToken(parseInfo, EnumToken.CDOCOMMTokenType);
|
|
1521
|
+
}
|
|
751
1522
|
}
|
|
752
|
-
buffer = "";
|
|
753
|
-
}
|
|
754
|
-
break;
|
|
755
|
-
case 35 /* TokenMap.HASH */:
|
|
756
|
-
if (buffer.length > 0) {
|
|
757
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
758
|
-
buffer = "";
|
|
759
|
-
}
|
|
760
|
-
buffer += next(parseInfo);
|
|
761
|
-
break;
|
|
762
|
-
case 92 /* TokenMap.REVERSE_SOLIDUS */:
|
|
763
|
-
next(parseInfo);
|
|
764
|
-
// EOF
|
|
765
|
-
if (!(peek(parseInfo))) {
|
|
766
|
-
// end of stream ignore \\
|
|
767
|
-
if (buffer.length > 0) {
|
|
768
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
769
|
-
buffer = "";
|
|
770
|
-
}
|
|
771
|
-
break;
|
|
772
|
-
}
|
|
773
|
-
buffer += value + next(parseInfo);
|
|
774
|
-
// buffer +=
|
|
775
|
-
// (parseInfo.offset == parseInfo.currentPosition
|
|
776
|
-
// ? parseInfo.buffer.slice(-1)
|
|
777
|
-
// : parseInfo.stream.charAt(parseInfo.currentPosition - parseInfo.offset - 1)) + value;
|
|
778
|
-
break;
|
|
779
|
-
case 39 /* TokenMap.SINGLE_QUOTE */:
|
|
780
|
-
case 34 /* TokenMap.DOUBLE_QUOTE */:
|
|
781
|
-
if (buffer.length > 0) {
|
|
782
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
783
|
-
buffer = "";
|
|
784
|
-
}
|
|
785
|
-
result.push(...consumeString(parseInfo));
|
|
786
|
-
break;
|
|
787
|
-
case 46 /* TokenMap.DOT */:
|
|
788
|
-
const codepoint = parseInfo.stream
|
|
789
|
-
.charAt(parseInfo.currentPosition - parseInfo.offset + 2)
|
|
790
|
-
.charCodeAt(0);
|
|
791
|
-
if (!isDigit(codepoint) && buffer !== "") {
|
|
792
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
793
|
-
buffer = next(parseInfo, 2);
|
|
794
1523
|
break;
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
1524
|
+
case 35 /* TokenMap.HASH */:
|
|
1525
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1526
|
+
return this.makeToken(parseInfo);
|
|
1527
|
+
}
|
|
1528
|
+
this.advance(parseInfo);
|
|
1529
|
+
break;
|
|
1530
|
+
case 92 /* TokenMap.REVERSE_SOLIDUS */:
|
|
1531
|
+
// if (!yieldEOFToken && parseInfo.stream.length == parseInfo.currentPosition - parseInfo.offset + 1) {
|
|
1532
|
+
// break;
|
|
1533
|
+
// }
|
|
1534
|
+
this.advance(parseInfo);
|
|
1535
|
+
// EOF
|
|
1536
|
+
if (!this.peek(parseInfo)) {
|
|
1537
|
+
// if (!yieldEOFToken) {
|
|
1538
|
+
// break;
|
|
1539
|
+
// }
|
|
1540
|
+
// end of stream ignore \\
|
|
1541
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1542
|
+
return this.makeToken(parseInfo);
|
|
1543
|
+
}
|
|
1544
|
+
break;
|
|
1545
|
+
}
|
|
1546
|
+
this.advance(parseInfo);
|
|
1547
|
+
break;
|
|
1548
|
+
case 39 /* TokenMap.SINGLE_QUOTE */:
|
|
1549
|
+
case 34 /* TokenMap.DOUBLE_QUOTE */:
|
|
1550
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1551
|
+
return this.makeToken(parseInfo);
|
|
1552
|
+
}
|
|
1553
|
+
return this.consumeString(parseInfo);
|
|
1554
|
+
case 46 /* TokenMap.DOT */:
|
|
1555
|
+
const codepoint = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
|
|
1556
|
+
if (isIdentStart(codepoint) || codepoint == 45 /* TokenMap.MINUS */) {
|
|
1557
|
+
this.advance(parseInfo);
|
|
1558
|
+
let tokensCount = this.consumeIdentToken(parseInfo);
|
|
1559
|
+
if (tokensCount > 0) {
|
|
1560
|
+
this.advance(parseInfo, tokensCount);
|
|
1561
|
+
return this.makeToken(parseInfo, EnumToken.ClassSelectorTokenType);
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
|
|
1565
|
+
this.makeToken(parseInfo);
|
|
1566
|
+
this.advance(parseInfo, 2);
|
|
1567
|
+
return this;
|
|
1568
|
+
}
|
|
1569
|
+
this.advance(parseInfo);
|
|
1570
|
+
break;
|
|
1571
|
+
default:
|
|
1572
|
+
this.advance(parseInfo);
|
|
1573
|
+
break;
|
|
1574
|
+
}
|
|
1575
|
+
// if (!yieldEOFToken && endPosition <= parseInfo.currentPosition - parseInfo.offset + 1) {
|
|
1576
|
+
// break;
|
|
1577
|
+
// }
|
|
804
1578
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
result.push(yieldResult(buffer, parseInfo));
|
|
1579
|
+
// if (yieldEOFToken) {
|
|
1580
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1581
|
+
return this.makeToken(parseInfo);
|
|
809
1582
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
else {
|
|
813
|
-
parseInfo.buffer = buffer;
|
|
1583
|
+
return this.makeToken(parseInfo, EnumToken.EOFTokenType);
|
|
1584
|
+
// }
|
|
814
1585
|
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
parseInfo.source.append(stream);
|
|
831
|
-
if (typeof parseInfo.stream != "string") {
|
|
832
|
-
parseInfo.stream = stream;
|
|
1586
|
+
/**
|
|
1587
|
+
* tokenize readable stream
|
|
1588
|
+
* @param input
|
|
1589
|
+
* @param parseInfo
|
|
1590
|
+
*/
|
|
1591
|
+
async tokenizeStream() {
|
|
1592
|
+
const decoder = new TextDecoder("utf-8");
|
|
1593
|
+
const reader = this.input.getReader();
|
|
1594
|
+
let parseInfo = this.parseInfo;
|
|
1595
|
+
parseInfo.stream = "";
|
|
1596
|
+
while (true) {
|
|
1597
|
+
const { done, value } = await reader.read();
|
|
1598
|
+
const stream = ArrayBuffer.isView(value) ? decoder.decode(value, { stream: true }) : value;
|
|
1599
|
+
if (!done) {
|
|
1600
|
+
parseInfo.source.append(stream);
|
|
833
1601
|
}
|
|
834
1602
|
else {
|
|
835
|
-
|
|
836
|
-
stream);
|
|
1603
|
+
break;
|
|
837
1604
|
}
|
|
838
|
-
parseInfo.offset = parseInfo.currentPosition + 1;
|
|
839
|
-
}
|
|
840
|
-
yield* tokenize(parseInfo, done);
|
|
841
|
-
if (done) {
|
|
842
|
-
break;
|
|
843
1605
|
}
|
|
1606
|
+
parseInfo.stream = parseInfo.source.getContent();
|
|
1607
|
+
return this; // .next();
|
|
844
1608
|
}
|
|
845
1609
|
}
|
|
846
1610
|
|
|
847
|
-
export {
|
|
1611
|
+
export { TokenMap, Tokenizer, hintsEnum };
|