@tbela99/css-parser 1.6.3 → 1.6.5
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 +56 -0
- package/README.md +112 -8
- package/dist/{lib/data → data}/properties.json.js +296 -29
- package/dist/{lib/data → data}/validation.json.js +6 -0
- package/dist/index-umd-web.js +962 -744
- package/dist/index.cjs +961 -744
- package/dist/index.d.ts +24 -6
- package/dist/lib/ast/expand.js +1 -1
- package/dist/lib/ast/features/calc.js +16 -4
- package/dist/lib/ast/features/if.js +2 -2
- package/dist/lib/ast/features/inlinecssvariables.js +3 -3
- package/dist/lib/ast/features/prefix.js +2 -2
- package/dist/lib/ast/features/shorthand.js +8 -6
- package/dist/lib/ast/features/transform.js +2 -2
- package/dist/lib/ast/math/expression.js +24 -1
- package/dist/lib/ast/minify.js +3 -2
- package/dist/lib/ast/transform/utils.js +2 -2
- package/dist/lib/ast/walk.js +108 -90
- package/dist/lib/parser/declaration/list.js +29 -26
- package/dist/lib/parser/declaration/map.js +186 -54
- package/dist/lib/parser/parse.js +11 -9
- package/dist/lib/parser/source.js +2 -2
- package/dist/lib/parser/tokenize.js +99 -124
- package/dist/lib/parser/utils/config.js +1 -1
- package/dist/lib/parser/utils/declaration.js +0 -18
- package/dist/lib/parser/utils/hash.js +10 -5
- package/dist/lib/parser/utils/selector.js +1 -1
- package/dist/lib/{renderer → printer}/render.js +29 -53
- package/dist/lib/syntax/color/a98rgb.js +1 -1
- package/dist/lib/syntax/color/alpha.js +19 -20
- package/dist/lib/syntax/color/color-mix.js +15 -14
- package/dist/lib/syntax/color/hex.js +4 -1
- package/dist/lib/syntax/color/lch.js +0 -1
- package/dist/lib/syntax/color/oklch.js +0 -1
- package/dist/lib/syntax/color/relative-color.js +11 -11
- package/dist/lib/syntax/color/utils/components.js +0 -20
- package/dist/lib/syntax/color/xyzd50.js +0 -17
- package/dist/lib/syntax/constants.js +6 -1
- package/dist/lib/syntax/syntax.js +2 -2
- package/dist/lib/validation/config.js +5 -33
- package/dist/lib/validation/match.js +52 -181
- package/dist/node.js +3 -3
- package/dist/web.js +4 -3
- package/package.json +6 -5
- /package/dist/lib/{renderer → printer}/sourcemap/lib/codec.js +0 -0
- /package/dist/lib/{renderer → printer}/sourcemap/sourcemap.js +0 -0
|
@@ -4,6 +4,7 @@ import { isWhiteSpace, isNewLine, isDigit, isLetter, isIdentStart, isIdentCodepo
|
|
|
4
4
|
import { SourceFile } from './source.js';
|
|
5
5
|
|
|
6
6
|
const SymbolsMapTokens = Object.create(null);
|
|
7
|
+
const SymbolsMapTokensLower = Object.create(null);
|
|
7
8
|
// Regex for escape sequence decoding - compile once, reuse many times
|
|
8
9
|
const ESCAPE_SEQUENCE_REGEX = /\\((\n|\r|\f|\v|\u2028|\u2029|([0-9a-fA-F]{1,6})) ?)/gms;
|
|
9
10
|
function decodeEscapeSequences(value) {
|
|
@@ -32,7 +33,9 @@ function decodeEscapeSequences(value) {
|
|
|
32
33
|
}
|
|
33
34
|
function assignTokenMap(entries, tokenType, suffix = "", lowercase = false) {
|
|
34
35
|
for (const entry of entries) {
|
|
35
|
-
|
|
36
|
+
const key = (lowercase ? entry.toLowerCase() : entry) + suffix;
|
|
37
|
+
SymbolsMapTokens[key] = tokenType;
|
|
38
|
+
SymbolsMapTokensLower[key.toLowerCase()] = tokenType;
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
SymbolsMapTokens[""] = EnumToken.DelimTokenType;
|
|
@@ -132,20 +135,24 @@ var TokenMap;
|
|
|
132
135
|
})(TokenMap || (TokenMap = {}));
|
|
133
136
|
function getSymbolHint(parseInfo, start, end) {
|
|
134
137
|
const len = end - start;
|
|
135
|
-
|
|
136
|
-
// Early exit for impossible lengths
|
|
137
|
-
if (len < 0)
|
|
138
|
+
if (len <= 0)
|
|
138
139
|
return null;
|
|
140
|
+
const value = parseInfo.stream.slice(start, end);
|
|
141
|
+
// Direct lookup handles the hottest punctuation and keyword cases without
|
|
142
|
+
// scanning the entire symbol table on every token.
|
|
143
|
+
const match = SymbolsMapTokens[value] ?? SymbolsMapTokensLower[value.toLowerCase()];
|
|
144
|
+
if (match != null) {
|
|
145
|
+
return match;
|
|
146
|
+
}
|
|
147
|
+
const keysLength = SymbolsMapTokensKeys.length;
|
|
139
148
|
for (let i = 0; i < keysLength; i++) {
|
|
140
149
|
const key = SymbolsMapTokensKeys[i];
|
|
141
150
|
if (key.length !== len)
|
|
142
151
|
continue;
|
|
143
|
-
// Match character by character
|
|
144
152
|
let match = true;
|
|
145
153
|
for (let j = 0; j < len; j++) {
|
|
146
154
|
let ca = key.charCodeAt(j);
|
|
147
|
-
let cb =
|
|
148
|
-
// Normalize A-Z to a-z
|
|
155
|
+
let cb = value.charCodeAt(j);
|
|
149
156
|
if (ca >= 65 && ca <= 90)
|
|
150
157
|
ca += 32;
|
|
151
158
|
if (cb >= 65 && cb <= 90)
|
|
@@ -163,32 +170,29 @@ function getSymbolHint(parseInfo, start, end) {
|
|
|
163
170
|
}
|
|
164
171
|
function searchArray(array, parseInfo, start, end) {
|
|
165
172
|
const len = end - start;
|
|
166
|
-
|
|
167
|
-
if (len < 0)
|
|
173
|
+
if (len <= 0)
|
|
168
174
|
return null;
|
|
169
|
-
|
|
170
|
-
let
|
|
171
|
-
|
|
172
|
-
|
|
175
|
+
let match;
|
|
176
|
+
let item;
|
|
177
|
+
for (let i = 0; i < array.length; i++) {
|
|
178
|
+
item = array[i];
|
|
179
|
+
if (item.length !== len)
|
|
173
180
|
continue;
|
|
174
|
-
|
|
175
|
-
let match = true;
|
|
176
|
-
const arrayItem = array[i];
|
|
181
|
+
match = true;
|
|
177
182
|
for (let j = 0; j < len; j++) {
|
|
178
|
-
let ca =
|
|
179
|
-
let cb =
|
|
180
|
-
// Normalize A-Z to a-z
|
|
183
|
+
let ca = parseInfo.stream.charCodeAt(start + j);
|
|
184
|
+
let cb = item.charCodeAt(j);
|
|
181
185
|
if (ca >= 65 && ca <= 90)
|
|
182
186
|
ca += 32;
|
|
183
187
|
if (cb >= 65 && cb <= 90)
|
|
184
188
|
cb += 32;
|
|
185
|
-
if (ca
|
|
189
|
+
if (ca !== cb) {
|
|
186
190
|
match = false;
|
|
187
191
|
break;
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
194
|
if (match) {
|
|
191
|
-
return
|
|
195
|
+
return item;
|
|
192
196
|
}
|
|
193
197
|
}
|
|
194
198
|
return null;
|
|
@@ -1126,23 +1130,6 @@ class Tokenizer {
|
|
|
1126
1130
|
}
|
|
1127
1131
|
return true;
|
|
1128
1132
|
}
|
|
1129
|
-
/**
|
|
1130
|
-
*
|
|
1131
|
-
* @param parseInfo
|
|
1132
|
-
* @returns
|
|
1133
|
-
*/
|
|
1134
|
-
// isPseudo(parseInfo: ParseInfo): boolean {
|
|
1135
|
-
// let position: number = parseInfo.currentPosition - parseInfo.offset;
|
|
1136
|
-
// let endPosition: number = parseInfo.currentPosition - parseInfo.offset;
|
|
1137
|
-
// return (parseInfo.stream.charAt(position) == ":" &&
|
|
1138
|
-
// parseInfo.stream.charAt(endPosition - 1) == "(" &&
|
|
1139
|
-
// (parseInfo.stream.charAt(position + 1) == ":"
|
|
1140
|
-
// ? this.isIdentToken(parseInfo, 2, -1)
|
|
1141
|
-
// : this.isIdentToken(parseInfo, 1, -1))) ||
|
|
1142
|
-
// parseInfo.stream.charAt(position + 1) == ":"
|
|
1143
|
-
// ? this.isIdentToken(parseInfo, 2)
|
|
1144
|
-
// : this.isIdentToken(parseInfo, 1);
|
|
1145
|
-
// }
|
|
1146
1133
|
/**
|
|
1147
1134
|
*
|
|
1148
1135
|
* @param parseInfo
|
|
@@ -1273,28 +1260,28 @@ class Tokenizer {
|
|
|
1273
1260
|
// EOF
|
|
1274
1261
|
switch (charCode) {
|
|
1275
1262
|
case 61 /* TokenMap.EQUALS */:
|
|
1276
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1277
|
-
|
|
1278
|
-
}
|
|
1263
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1264
|
+
// return this.makeToken(parseInfo);
|
|
1265
|
+
// }
|
|
1279
1266
|
this.advance(parseInfo);
|
|
1280
1267
|
return this.makeToken(parseInfo, EnumToken.DelimTokenType);
|
|
1281
1268
|
// '+' or '-'
|
|
1282
1269
|
case 43 /* TokenMap.PLUS */:
|
|
1283
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1284
|
-
|
|
1285
|
-
}
|
|
1270
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1271
|
+
// return this.makeToken(parseInfo);
|
|
1272
|
+
// }
|
|
1286
1273
|
this.advance(parseInfo);
|
|
1287
1274
|
charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
1288
|
-
if (isDigit(charCode)) {
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
}
|
|
1275
|
+
// if (isDigit(charCode)) {
|
|
1276
|
+
// tokensCount = this.consumeNumericToken(parseInfo);
|
|
1277
|
+
// if (tokensCount > 0) {
|
|
1278
|
+
// this.advance(parseInfo, tokensCount);
|
|
1279
|
+
// return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, {
|
|
1280
|
+
// slice: this.slice,
|
|
1281
|
+
// sign: "+",
|
|
1282
|
+
// });
|
|
1283
|
+
// }
|
|
1284
|
+
// }
|
|
1298
1285
|
return this.makeToken(parseInfo, EnumToken.Plus);
|
|
1299
1286
|
case 45 /* TokenMap.MINUS */:
|
|
1300
1287
|
if (parseInfo.position == parseInfo.currentPosition) {
|
|
@@ -1304,15 +1291,17 @@ class Tokenizer {
|
|
|
1304
1291
|
this.advance(parseInfo);
|
|
1305
1292
|
return this.makeToken(parseInfo, EnumToken.Sub);
|
|
1306
1293
|
}
|
|
1307
|
-
if (
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1294
|
+
// if (
|
|
1295
|
+
// charCode == TokenMap.MINUS &&
|
|
1296
|
+
// (nextCharCode == TokenMap.MINUS || isIdentStart(nextCharCode))
|
|
1297
|
+
// ) {
|
|
1298
|
+
// this.advance(parseInfo);
|
|
1299
|
+
// tokensCount = this.consumeIdentToken(parseInfo);
|
|
1300
|
+
// if (tokensCount > 0) {
|
|
1301
|
+
// this.advance(parseInfo, tokensCount);
|
|
1302
|
+
// return this.makeToken(parseInfo, EnumToken.IdenTokenType);
|
|
1303
|
+
// }
|
|
1304
|
+
// }
|
|
1316
1305
|
}
|
|
1317
1306
|
this.advance(parseInfo);
|
|
1318
1307
|
break;
|
|
@@ -1365,28 +1354,28 @@ class Tokenizer {
|
|
|
1365
1354
|
return this.makeToken(parseInfo, EnumToken.EndParensTokenType);
|
|
1366
1355
|
// '['
|
|
1367
1356
|
case 91 /* TokenMap.LEFT_BRACKETS */:
|
|
1368
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1369
|
-
|
|
1370
|
-
}
|
|
1357
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1358
|
+
// return this.makeToken(parseInfo);
|
|
1359
|
+
// }
|
|
1371
1360
|
this.advance(parseInfo);
|
|
1372
1361
|
return this.makeToken(parseInfo, EnumToken.AttrStartTokenType);
|
|
1373
1362
|
// ']'
|
|
1374
1363
|
case 93 /* TokenMap.RIGHT_BRACKETS */:
|
|
1375
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1376
|
-
|
|
1377
|
-
}
|
|
1364
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1365
|
+
// return this.makeToken(parseInfo);
|
|
1366
|
+
// }
|
|
1378
1367
|
this.advance(parseInfo);
|
|
1379
1368
|
return this.makeToken(parseInfo, EnumToken.AttrEndTokenType);
|
|
1380
1369
|
case 59 /* TokenMap.SEMICOLON */:
|
|
1381
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1382
|
-
|
|
1383
|
-
}
|
|
1370
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1371
|
+
// return this.makeToken(parseInfo);
|
|
1372
|
+
// }
|
|
1384
1373
|
this.advance(parseInfo);
|
|
1385
1374
|
return this.makeToken(parseInfo, EnumToken.SemiColonTokenType);
|
|
1386
1375
|
case 58 /* TokenMap.COLON */:
|
|
1387
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1388
|
-
|
|
1389
|
-
}
|
|
1376
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1377
|
+
// return this.makeToken(parseInfo);
|
|
1378
|
+
// }
|
|
1390
1379
|
this.advance(parseInfo);
|
|
1391
1380
|
if (this.peekCharCode(parseInfo) == 58 /* TokenMap.COLON */) {
|
|
1392
1381
|
this.advance(parseInfo);
|
|
@@ -1418,15 +1407,15 @@ class Tokenizer {
|
|
|
1418
1407
|
}
|
|
1419
1408
|
return this.makeToken(parseInfo, EnumToken.WhitespaceTokenType);
|
|
1420
1409
|
case 44 /* TokenMap.COMMA */:
|
|
1421
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1422
|
-
|
|
1423
|
-
}
|
|
1410
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1411
|
+
// return this.makeToken(parseInfo);
|
|
1412
|
+
// }
|
|
1424
1413
|
this.advance(parseInfo);
|
|
1425
1414
|
return this.makeToken(parseInfo, EnumToken.CommaTokenType);
|
|
1426
1415
|
case 36 /* TokenMap.DOLLAR */:
|
|
1427
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1428
|
-
|
|
1429
|
-
}
|
|
1416
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1417
|
+
// return this.makeToken(parseInfo);
|
|
1418
|
+
// }
|
|
1430
1419
|
if (this.match(parseInfo, "$=")) {
|
|
1431
1420
|
this.advance(parseInfo, 2);
|
|
1432
1421
|
return this.makeToken(parseInfo, EnumToken.EndMatchTokenType);
|
|
@@ -1434,9 +1423,9 @@ class Tokenizer {
|
|
|
1434
1423
|
this.advance(parseInfo);
|
|
1435
1424
|
break;
|
|
1436
1425
|
case 126 /* TokenMap.TILDA */:
|
|
1437
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1438
|
-
|
|
1439
|
-
}
|
|
1426
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1427
|
+
// return this.makeToken(parseInfo);
|
|
1428
|
+
// }
|
|
1440
1429
|
if (this.match(parseInfo, "~=")) {
|
|
1441
1430
|
this.advance(parseInfo, 2);
|
|
1442
1431
|
return this.makeToken(parseInfo, EnumToken.IncludeMatchTokenType);
|
|
@@ -1445,9 +1434,9 @@ class Tokenizer {
|
|
|
1445
1434
|
return this.makeToken(parseInfo, EnumToken.Tilda);
|
|
1446
1435
|
// case '^':
|
|
1447
1436
|
case 94 /* TokenMap.CARET */:
|
|
1448
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1449
|
-
|
|
1450
|
-
}
|
|
1437
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1438
|
+
// return this.makeToken(parseInfo);
|
|
1439
|
+
// }
|
|
1451
1440
|
if (this.match(parseInfo, "^=")) {
|
|
1452
1441
|
this.advance(parseInfo, 2);
|
|
1453
1442
|
return this.makeToken(parseInfo, EnumToken.StartMatchTokenType);
|
|
@@ -1455,9 +1444,9 @@ class Tokenizer {
|
|
|
1455
1444
|
this.advance(parseInfo);
|
|
1456
1445
|
break;
|
|
1457
1446
|
case 42 /* TokenMap.STAR */:
|
|
1458
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1459
|
-
|
|
1460
|
-
}
|
|
1447
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1448
|
+
// return this.makeToken(parseInfo);
|
|
1449
|
+
// }
|
|
1461
1450
|
if (this.match(parseInfo, "*=")) {
|
|
1462
1451
|
this.advance(parseInfo, 2);
|
|
1463
1452
|
return this.makeToken(parseInfo, EnumToken.ContainMatchTokenType);
|
|
@@ -1471,9 +1460,9 @@ class Tokenizer {
|
|
|
1471
1460
|
this.advance(parseInfo);
|
|
1472
1461
|
return this.makeToken(parseInfo, EnumToken.NestingSelectorTokenType);
|
|
1473
1462
|
case 124 /* TokenMap.PIPE */:
|
|
1474
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1475
|
-
|
|
1476
|
-
}
|
|
1463
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1464
|
+
// return this.makeToken(parseInfo);
|
|
1465
|
+
// }
|
|
1477
1466
|
// '||'
|
|
1478
1467
|
if (this.match(parseInfo, "||")) {
|
|
1479
1468
|
this.advance(parseInfo, 2);
|
|
@@ -1496,9 +1485,9 @@ class Tokenizer {
|
|
|
1496
1485
|
this.advance(parseInfo);
|
|
1497
1486
|
break;
|
|
1498
1487
|
case 47 /* TokenMap.SLASH */:
|
|
1499
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1500
|
-
|
|
1501
|
-
}
|
|
1488
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1489
|
+
// return this.makeToken(parseInfo);
|
|
1490
|
+
// }
|
|
1502
1491
|
if (!this.match(parseInfo, "/*")) {
|
|
1503
1492
|
this.advance(parseInfo);
|
|
1504
1493
|
return this.makeToken(parseInfo, getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset));
|
|
@@ -1517,9 +1506,9 @@ class Tokenizer {
|
|
|
1517
1506
|
}
|
|
1518
1507
|
break;
|
|
1519
1508
|
case 62 /* TokenMap.GREATERTHAN */:
|
|
1520
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1521
|
-
|
|
1522
|
-
}
|
|
1509
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1510
|
+
// return this.makeToken(parseInfo);
|
|
1511
|
+
// }
|
|
1523
1512
|
if (this.match(parseInfo, ">=")) {
|
|
1524
1513
|
this.advance(parseInfo, 2);
|
|
1525
1514
|
return this.makeToken(parseInfo, EnumToken.GteTokenType);
|
|
@@ -1558,20 +1547,11 @@ class Tokenizer {
|
|
|
1558
1547
|
this.advance(parseInfo);
|
|
1559
1548
|
break;
|
|
1560
1549
|
case 92 /* TokenMap.REVERSE_SOLIDUS */:
|
|
1561
|
-
// if (!yieldEOFToken && parseInfo.stream.length == parseInfo.currentPosition - parseInfo.offset + 1) {
|
|
1562
|
-
// break;
|
|
1563
|
-
// }
|
|
1564
1550
|
this.advance(parseInfo);
|
|
1565
1551
|
// EOF
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
// }
|
|
1570
|
-
// end of stream ignore \\
|
|
1571
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1572
|
-
return this.makeToken(parseInfo);
|
|
1573
|
-
}
|
|
1574
|
-
break;
|
|
1552
|
+
// end of stream ignore \\
|
|
1553
|
+
if (!this.peek(parseInfo) && parseInfo.position < parseInfo.currentPosition) {
|
|
1554
|
+
return this.makeToken(parseInfo);
|
|
1575
1555
|
}
|
|
1576
1556
|
this.advance(parseInfo);
|
|
1577
1557
|
break;
|
|
@@ -1584,9 +1564,9 @@ class Tokenizer {
|
|
|
1584
1564
|
case 46 /* TokenMap.DOT */:
|
|
1585
1565
|
const codepoint = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
|
|
1586
1566
|
if (isIdentStart(codepoint) || codepoint == 45 /* TokenMap.MINUS */) {
|
|
1587
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1588
|
-
|
|
1589
|
-
}
|
|
1567
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1568
|
+
// return this.makeToken(parseInfo);
|
|
1569
|
+
// }
|
|
1590
1570
|
this.advance(parseInfo);
|
|
1591
1571
|
let tokensCount = this.consumeIdentToken(parseInfo);
|
|
1592
1572
|
if (tokensCount > 0) {
|
|
@@ -1594,27 +1574,22 @@ class Tokenizer {
|
|
|
1594
1574
|
return this.makeToken(parseInfo, EnumToken.ClassSelectorTokenType);
|
|
1595
1575
|
}
|
|
1596
1576
|
}
|
|
1597
|
-
if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
}
|
|
1577
|
+
// if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
|
|
1578
|
+
// this.makeToken(parseInfo);
|
|
1579
|
+
// this.advance(parseInfo, 2);
|
|
1580
|
+
// return this;
|
|
1581
|
+
// }
|
|
1602
1582
|
this.advance(parseInfo);
|
|
1603
1583
|
break;
|
|
1604
1584
|
default:
|
|
1605
1585
|
this.advance(parseInfo);
|
|
1606
1586
|
break;
|
|
1607
1587
|
}
|
|
1608
|
-
// if (!yieldEOFToken && endPosition <= parseInfo.currentPosition - parseInfo.offset + 1) {
|
|
1609
|
-
// break;
|
|
1610
|
-
// }
|
|
1611
1588
|
}
|
|
1612
|
-
// if (yieldEOFToken) {
|
|
1613
1589
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1614
1590
|
return this.makeToken(parseInfo);
|
|
1615
1591
|
}
|
|
1616
1592
|
return this.makeToken(parseInfo, EnumToken.EOFTokenType);
|
|
1617
|
-
// }
|
|
1618
1593
|
}
|
|
1619
1594
|
/**
|
|
1620
1595
|
* tokenize readable stream
|
|
@@ -294,24 +294,6 @@ function parseDeclaration(tokens, parent, options, errors) {
|
|
|
294
294
|
if (tokens[index].chi[l].typ === EnumToken.StringTokenType) {
|
|
295
295
|
break;
|
|
296
296
|
}
|
|
297
|
-
// else if ((tokens[index] as FunctionToken).chi[l].typ === EnumToken.IdenTokenType) {
|
|
298
|
-
// let m: number = l + 1;
|
|
299
|
-
// while (
|
|
300
|
-
// (tokens[index] as FunctionToken).chi[m]?.typ === EnumToken.ClassSelectorTokenType
|
|
301
|
-
// ) {
|
|
302
|
-
// Object.assign((tokens[index] as FunctionToken).chi[l], {
|
|
303
|
-
// typ: EnumToken.UrlTokenTokenType,
|
|
304
|
-
// val:
|
|
305
|
-
// ((tokens[index] as FunctionToken).chi[l] as IdentToken | UrlToken).val +
|
|
306
|
-
// ((tokens[index] as FunctionToken).chi[m] as ClassSelectorToken).val,
|
|
307
|
-
// });
|
|
308
|
-
// (tokens[index] as FunctionToken).chi[l][LOCEND] = (
|
|
309
|
-
// tokens[index] as FunctionToken
|
|
310
|
-
// ).chi[m][LOCEND];
|
|
311
|
-
// (tokens[index] as FunctionToken).chi.splice(m, 1);
|
|
312
|
-
// }
|
|
313
|
-
// break;
|
|
314
|
-
// }
|
|
315
297
|
}
|
|
316
298
|
if (tokens[index].chi[l]?.typ === EnumToken.StringTokenType &&
|
|
317
299
|
/^[a-zA-Z0-0/_.-]+$/.test(tokens[index].chi[l].val.slice(1, -1))) {
|
|
@@ -47,12 +47,17 @@ function toSortedString(input) {
|
|
|
47
47
|
return String(input);
|
|
48
48
|
}
|
|
49
49
|
if (Array.isArray(input)) {
|
|
50
|
-
|
|
50
|
+
const result = new Array(input.length);
|
|
51
|
+
for (const value of input) {
|
|
52
|
+
result.push(toSortedString(value));
|
|
53
|
+
}
|
|
54
|
+
return JSON.stringify(result);
|
|
55
|
+
}
|
|
56
|
+
const keys = Object.keys(input).sort();
|
|
57
|
+
for (let i = 0; i < keys.length; i++) {
|
|
58
|
+
keys[i] = `${keys[i]}:${toSortedString(input[keys[i]])}`;
|
|
51
59
|
}
|
|
52
|
-
return `{${
|
|
53
|
-
.sort()
|
|
54
|
-
.map((k) => `${k}:${toSortedString(input[k])}`)
|
|
55
|
-
.join(",")}}`;
|
|
60
|
+
return `{${keys.join(",")}}`;
|
|
56
61
|
}
|
|
57
62
|
/**
|
|
58
63
|
* Object hash
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnumToken, EnumAstNodeStatus } from '../../ast/types.js';
|
|
2
|
-
import { renderValue } from '../../
|
|
2
|
+
import { renderValue } from '../../printer/render.js';
|
|
3
3
|
import { LOCEND, LOCSTA, LOCSRCID, ERRORS, STATE, TOKENS, pseudoElements, combinators, tokensfuncDefMap, PARENT } from '../../syntax/constants.js';
|
|
4
4
|
import { isHash } from '../../syntax/syntax.js';
|
|
5
5
|
import { getParsedSyntax, getSyntaxRule, getSyntaxConfig } from '../../validation/config.js';
|