@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
|
@@ -10,6 +10,20 @@ import { parseTokens } from '../parser/parse.js';
|
|
|
10
10
|
const config = getSyntaxConfig();
|
|
11
11
|
// @ts-expect-error
|
|
12
12
|
const allValues = config.declarations.all.syntax.split(/[\s|]+/g);
|
|
13
|
+
const selectorNodeTypes = [
|
|
14
|
+
EnumToken.CommaTokenType,
|
|
15
|
+
EnumToken.ColumnCombinatorTokenType,
|
|
16
|
+
EnumToken.ChildCombinatorTokenType,
|
|
17
|
+
EnumToken.NextSiblingCombinatorTokenType,
|
|
18
|
+
EnumToken.SubsequentSiblingCombinatorTokenType,
|
|
19
|
+
];
|
|
20
|
+
const trimWhitespaceBefore = selectorNodeTypes.concat(EnumToken.DelimTokenType, EnumToken.DashMatchTokenType, EnumToken.IncludeMatchTokenType, EnumToken.ContainMatchTokenType, EnumToken.StartMatchTokenType, EnumToken.EndMatchTokenType, EnumToken.AttrEndTokenType);
|
|
21
|
+
const trimWhitespaceAfter = selectorNodeTypes.concat(EnumToken.DelimTokenType, EnumToken.DashMatchTokenType, EnumToken.IncludeMatchTokenType, EnumToken.ContainMatchTokenType, EnumToken.StartMatchTokenType, EnumToken.EndMatchTokenType, EnumToken.AttrStartTokenType);
|
|
22
|
+
const selectorEnumMap = new Map([
|
|
23
|
+
[EnumToken.Tilda, EnumToken.SubsequentSiblingCombinatorTokenType],
|
|
24
|
+
[EnumToken.GtTokenType, EnumToken.ChildCombinatorTokenType],
|
|
25
|
+
]);
|
|
26
|
+
const propertyKeywordValues = new Map();
|
|
13
27
|
/**
|
|
14
28
|
* @type {Array.<EnumToken>}
|
|
15
29
|
*/
|
|
@@ -233,24 +247,6 @@ function createValidationContext(tokens) {
|
|
|
233
247
|
getRemainingTokens() {
|
|
234
248
|
return this.tokens.slice(this.index + 1);
|
|
235
249
|
},
|
|
236
|
-
// last() {
|
|
237
|
-
// let index: number = this.tokens.length - 1;
|
|
238
|
-
// let token: Token = this.tokens[index];
|
|
239
|
-
// while (
|
|
240
|
-
// (this.index >= 0 && token?.typ === EnumToken.WhitespaceTokenType) ||
|
|
241
|
-
// token?.typ === EnumToken.CommentTokenType ||
|
|
242
|
-
// token?.typ === EnumToken.CDOCOMMTokenType ||
|
|
243
|
-
// token?.typ === EnumToken.InvalidCommentTokenType ||
|
|
244
|
-
// token?.typ === EnumToken.BadCommentTokenType ||
|
|
245
|
-
// token?.typ === EnumToken.BadStringTokenType
|
|
246
|
-
// ) {
|
|
247
|
-
// token = this.tokens[--index];
|
|
248
|
-
// if (token == null) {
|
|
249
|
-
// break;
|
|
250
|
-
// }
|
|
251
|
-
// }
|
|
252
|
-
// return token;
|
|
253
|
-
// },
|
|
254
250
|
end() {
|
|
255
251
|
this.index = this.tokens.length + 1;
|
|
256
252
|
return this;
|
|
@@ -310,19 +306,6 @@ function createValidationContext(tokens) {
|
|
|
310
306
|
function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
311
307
|
const stack = [];
|
|
312
308
|
const tokens = [];
|
|
313
|
-
const nodes = [
|
|
314
|
-
EnumToken.CommaTokenType,
|
|
315
|
-
EnumToken.ColumnCombinatorTokenType,
|
|
316
|
-
EnumToken.ChildCombinatorTokenType,
|
|
317
|
-
EnumToken.NextSiblingCombinatorTokenType,
|
|
318
|
-
EnumToken.SubsequentSiblingCombinatorTokenType,
|
|
319
|
-
];
|
|
320
|
-
const trimWhitespaceBefore = nodes.concat(EnumToken.DelimTokenType, EnumToken.DashMatchTokenType, EnumToken.IncludeMatchTokenType, EnumToken.ContainMatchTokenType, EnumToken.StartMatchTokenType, EnumToken.EndMatchTokenType, EnumToken.AttrEndTokenType);
|
|
321
|
-
const trimWhitespaceAfter = nodes.concat(EnumToken.DelimTokenType, EnumToken.DashMatchTokenType, EnumToken.IncludeMatchTokenType, EnumToken.ContainMatchTokenType, EnumToken.StartMatchTokenType, EnumToken.EndMatchTokenType, EnumToken.AttrStartTokenType);
|
|
322
|
-
const enumMap = new Map([
|
|
323
|
-
[EnumToken.Tilda, EnumToken.SubsequentSiblingCombinatorTokenType],
|
|
324
|
-
[EnumToken.GtTokenType, EnumToken.ChildCombinatorTokenType],
|
|
325
|
-
]);
|
|
326
309
|
let token;
|
|
327
310
|
let i = 0;
|
|
328
311
|
let success = true;
|
|
@@ -362,15 +345,15 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
362
345
|
}
|
|
363
346
|
tokens.push(token);
|
|
364
347
|
if (tokensfuncDefMap.has(token.typ)) {
|
|
365
|
-
if (stack.length > 0 &&
|
|
348
|
+
if (stack.length > 0 && selectorNodeTypes.includes(stack.at(-1).typ)) {
|
|
366
349
|
stack.pop();
|
|
367
350
|
}
|
|
368
351
|
stack.push(token);
|
|
369
352
|
continue;
|
|
370
353
|
}
|
|
371
354
|
if (stack.length > 0 &&
|
|
372
|
-
|
|
373
|
-
!
|
|
355
|
+
selectorNodeTypes.includes(stack.at(-1).typ) &&
|
|
356
|
+
!selectorNodeTypes.includes(token.typ) &&
|
|
374
357
|
token.typ !== EnumToken.WhitespaceTokenType &&
|
|
375
358
|
token.typ !== EnumToken.CommentTokenType &&
|
|
376
359
|
token.typ !== EnumToken.CDOCOMMTokenType) {
|
|
@@ -416,7 +399,7 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
416
399
|
break;
|
|
417
400
|
case EnumToken.Tilda:
|
|
418
401
|
case EnumToken.GtTokenType:
|
|
419
|
-
Object.assign(token, { typ:
|
|
402
|
+
Object.assign(token, { typ: selectorEnumMap.get(token.typ) });
|
|
420
403
|
case EnumToken.ColumnCombinatorTokenType:
|
|
421
404
|
case EnumToken.ChildCombinatorTokenType:
|
|
422
405
|
case EnumToken.UniversalSelectorTokenType:
|
|
@@ -429,7 +412,7 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
429
412
|
if (stack.length > 0 && stack.at(-1)?.typ === EnumToken.UniversalSelectorTokenType) {
|
|
430
413
|
stack.pop();
|
|
431
414
|
}
|
|
432
|
-
if (stack.length > 0 &&
|
|
415
|
+
if (stack.length > 0 && selectorNodeTypes.includes(stack.at(-1)?.typ)) {
|
|
433
416
|
return {
|
|
434
417
|
success: false,
|
|
435
418
|
errors: [
|
|
@@ -539,106 +522,10 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
539
522
|
};
|
|
540
523
|
}
|
|
541
524
|
slice.shift();
|
|
542
|
-
// if (slice.length > 0) {
|
|
543
|
-
// return {
|
|
544
|
-
// success: false,
|
|
545
|
-
// errors: [
|
|
546
|
-
// {
|
|
547
|
-
// action: "drop",
|
|
548
|
-
// message: `Unexpected token ${EnumToken[slice[0].typ]} at ${slice[0][LOC]!.src}:${slice[0][LOCSTA].lin}:${
|
|
549
|
-
// slice[0][LOCSTA].col
|
|
550
|
-
// }`,
|
|
551
|
-
// node: slice[0],
|
|
552
|
-
// location: slice[0][LOC],
|
|
553
|
-
// },
|
|
554
|
-
// ],
|
|
555
|
-
// };
|
|
556
|
-
// }
|
|
557
525
|
stack.pop();
|
|
558
526
|
break;
|
|
559
527
|
}
|
|
560
|
-
// case EnumToken.ColonTokenType:
|
|
561
|
-
// if (stream[i + 1]?.typ === EnumToken.IdenTokenType) {
|
|
562
|
-
// Object.assign(token, {
|
|
563
|
-
// typ:
|
|
564
|
-
// (stream[i + 1] as IdentToken).val === "page"
|
|
565
|
-
// ? EnumToken.PseudoPageTokenType
|
|
566
|
-
// : pseudoElements.includes((token as PseudoElementToken).val)
|
|
567
|
-
// ? EnumToken.PseudoElementTokenType
|
|
568
|
-
// : EnumToken.PseudoClassTokenType,
|
|
569
|
-
// val: ":" + (stream[i + 1] as IdentToken).val,
|
|
570
|
-
// });
|
|
571
|
-
// token[LOC]!.end = stream[++i][LOC]!.end;
|
|
572
|
-
// break;
|
|
573
|
-
// } else if (stream[i + 1]?.typ === EnumToken.FunctionTokenDefType) {
|
|
574
|
-
// Object.assign(token, {
|
|
575
|
-
// typ: EnumToken.PseudoClassFunctionTokenDefType,
|
|
576
|
-
// val: ":" + (stream[i + 1] as IdentToken).val,
|
|
577
|
-
// });
|
|
578
|
-
// token[LOC]!.end = stream[++i][LOC]!.end;
|
|
579
|
-
// stack.push(token);
|
|
580
|
-
// break;
|
|
581
|
-
// }
|
|
582
|
-
// return {
|
|
583
|
-
// success: false,
|
|
584
|
-
// errors: [
|
|
585
|
-
// {
|
|
586
|
-
// action: "drop",
|
|
587
|
-
// message: `Unexpected token ${EnumToken[token.typ]} at ${token[LOC]!.src}:${token[LOCSTA].lin}:${
|
|
588
|
-
// token[LOCSTA].col
|
|
589
|
-
// }`,
|
|
590
|
-
// node: token,
|
|
591
|
-
// location: token[LOC],
|
|
592
|
-
// },
|
|
593
|
-
// ],
|
|
594
|
-
// };
|
|
595
|
-
// case EnumToken.DoubleColonTokenType:
|
|
596
|
-
// if (stream[i + 1]?.typ === EnumToken.IdenTokenType) {
|
|
597
|
-
// Object.assign(token, {
|
|
598
|
-
// typ:
|
|
599
|
-
// (stream[i + 1] as IdentToken).val === "page"
|
|
600
|
-
// ? EnumToken.PseudoPageTokenType
|
|
601
|
-
// : EnumToken.PseudoElementTokenType,
|
|
602
|
-
// val: "::" + (stream[i + 1] as IdentToken).val,
|
|
603
|
-
// });
|
|
604
|
-
// token[LOC]!.end = stream[++i][LOC]!.end;
|
|
605
|
-
// break;
|
|
606
|
-
// } else if (stream[i + 1]?.typ === EnumToken.FunctionTokenDefType) {
|
|
607
|
-
// Object.assign(token, {
|
|
608
|
-
// typ: EnumToken.PseudoClassFunctionTokenDefType,
|
|
609
|
-
// val: "::" + (stream[i + 1] as IdentToken).val,
|
|
610
|
-
// });
|
|
611
|
-
// token[LOC]!.end = stream[++i][LOC]!.end;
|
|
612
|
-
// stack.push(token);
|
|
613
|
-
// break;
|
|
614
|
-
// }
|
|
615
|
-
// return {
|
|
616
|
-
// success: false,
|
|
617
|
-
// errors: [
|
|
618
|
-
// {
|
|
619
|
-
// action: "drop",
|
|
620
|
-
// message: `Unexpected token ${EnumToken[token.typ]} at ${token[LOC]!.src}:${token[LOCSTA].lin}:${
|
|
621
|
-
// token[LOCSTA].col
|
|
622
|
-
// }`,
|
|
623
|
-
// node: token,
|
|
624
|
-
// location: token[LOC],
|
|
625
|
-
// },
|
|
626
|
-
// ],
|
|
627
|
-
// };
|
|
628
528
|
case EnumToken.StartParensTokenType:
|
|
629
|
-
// if (
|
|
630
|
-
// tokens.at(-2)?.typ === EnumToken.PseudoClassTokenType ||
|
|
631
|
-
// tokens.at(-2)?.typ === EnumToken.PseudoElementTokenType
|
|
632
|
-
// ) {
|
|
633
|
-
// stack.push(
|
|
634
|
-
// Object.assign(tokens.at(-2) as Token, {
|
|
635
|
-
// typ: EnumToken.PseudoClassFunctionTokenDefType,
|
|
636
|
-
// chi: [],
|
|
637
|
-
// }),
|
|
638
|
-
// );
|
|
639
|
-
// // tokens.pop();
|
|
640
|
-
// break;
|
|
641
|
-
// }
|
|
642
529
|
return {
|
|
643
530
|
success: false,
|
|
644
531
|
errors: [
|
|
@@ -658,19 +545,6 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
658
545
|
if (stack.at(-1)?.typ === EnumToken.PseudoClassFunctionTokenDefType ||
|
|
659
546
|
stack.at(-1)?.typ === EnumToken.PseudoElementTokenType) {
|
|
660
547
|
const token = stack.at(-1);
|
|
661
|
-
// if (!((stack.at(-1) as PseudoClassFunctionToken).val + "()" in config.selectors)) {
|
|
662
|
-
// return {
|
|
663
|
-
// errors: [
|
|
664
|
-
// {
|
|
665
|
-
// action: "drop",
|
|
666
|
-
// message: `Unknown class element ${(token as PseudoElementToken).val}`,
|
|
667
|
-
// node: token,
|
|
668
|
-
// location: token[LOC]!,
|
|
669
|
-
// },
|
|
670
|
-
// ],
|
|
671
|
-
// success: false,
|
|
672
|
-
// };
|
|
673
|
-
// }
|
|
674
548
|
const index = tokens.indexOf(token);
|
|
675
549
|
const result = matchAllSyntaxes(getParsedSyntax(ValidationSyntaxGroupEnum.Selectors, token.val + "()")?.[0]?.chi ?? [], createValidationContext(tokens.slice(index + 1, tokens.length - 1)), options);
|
|
676
550
|
if (!result.success) {
|
|
@@ -769,7 +643,8 @@ function matchAllSyntaxes(syntaxes, context, options) {
|
|
|
769
643
|
for (let i = index; i < syntaxes.length; i++) {
|
|
770
644
|
if (syntaxes[i].typ == ValidationTokenEnum.Whitespace ||
|
|
771
645
|
syntaxes[i].isOptional ||
|
|
772
|
-
syntaxes[i].isRepeatable
|
|
646
|
+
syntaxes[i].isRepeatable ||
|
|
647
|
+
syntaxes[i].match?.min?.val === 0) {
|
|
773
648
|
continue;
|
|
774
649
|
}
|
|
775
650
|
return {
|
|
@@ -810,6 +685,7 @@ function matchListSyntax(syntax, context, options) {
|
|
|
810
685
|
let tmpResult;
|
|
811
686
|
let count = 0;
|
|
812
687
|
let range;
|
|
688
|
+
let done = false;
|
|
813
689
|
success = false;
|
|
814
690
|
do {
|
|
815
691
|
range = context.peekRange(EnumToken.CommaTokenType, EnumToken.CommaTokenType, 1);
|
|
@@ -825,12 +701,9 @@ function matchListSyntax(syntax, context, options) {
|
|
|
825
701
|
else {
|
|
826
702
|
context.update(range.at(-1));
|
|
827
703
|
}
|
|
828
|
-
|
|
829
|
-
// context.end();
|
|
830
|
-
break;
|
|
831
|
-
}
|
|
704
|
+
done = context.done();
|
|
832
705
|
}
|
|
833
|
-
} while (tmpResult.success && !
|
|
706
|
+
} while (tmpResult.success && !done);
|
|
834
707
|
return result == null
|
|
835
708
|
? {
|
|
836
709
|
success: false,
|
|
@@ -868,6 +741,9 @@ function matchOccurenceSyntax(syntax, context, options) {
|
|
|
868
741
|
context.end();
|
|
869
742
|
break;
|
|
870
743
|
}
|
|
744
|
+
if (tmpResult.context.index === context.index) {
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
871
747
|
context.update(tmpResult.context.current());
|
|
872
748
|
if (match?.max?.val != null && Number.isFinite(match?.max?.val) && count === match.max.val) {
|
|
873
749
|
break;
|
|
@@ -913,7 +789,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
913
789
|
errors: [],
|
|
914
790
|
};
|
|
915
791
|
}
|
|
916
|
-
syntaxes = syntaxes.slice();
|
|
917
792
|
let i = -1;
|
|
918
793
|
let success = false;
|
|
919
794
|
let token = null;
|
|
@@ -1245,21 +1120,19 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1245
1120
|
case ValidationTokenEnum.PipeToken:
|
|
1246
1121
|
{
|
|
1247
1122
|
result = null;
|
|
1248
|
-
const results = [];
|
|
1249
1123
|
let tmp = null;
|
|
1250
1124
|
for (const syntax of syntaxes[i].chi) {
|
|
1251
1125
|
tmp = matchSyntax(syntax, context.slice(), options);
|
|
1252
1126
|
if (tmp.success) {
|
|
1253
|
-
|
|
1127
|
+
if (result == null || tmp.context.index >= result.context.index) {
|
|
1128
|
+
result = tmp;
|
|
1129
|
+
}
|
|
1254
1130
|
if (tmp.context.done()) {
|
|
1255
1131
|
context.end();
|
|
1256
1132
|
return { ...tmp, context, syntaxToken: syntaxes[i + 1] };
|
|
1257
1133
|
}
|
|
1258
1134
|
}
|
|
1259
1135
|
}
|
|
1260
|
-
if (results.length > 0) {
|
|
1261
|
-
result = results.reduce((a, b) => (a.context.index > b.context.index ? a : b));
|
|
1262
|
-
}
|
|
1263
1136
|
if (result?.success) {
|
|
1264
1137
|
success = true;
|
|
1265
1138
|
options.visited.get(token).delete(syntaxes[i]);
|
|
@@ -1621,7 +1494,8 @@ function matchAmpersandSyntax(syntax, context, options) {
|
|
|
1621
1494
|
*/
|
|
1622
1495
|
function matchProperty(property, context, options) {
|
|
1623
1496
|
let success = false;
|
|
1624
|
-
|
|
1497
|
+
const token = context.peek();
|
|
1498
|
+
let t = token?.typ;
|
|
1625
1499
|
let checkCalc = (t == EnumToken.MathFunctionTokenDefType || t == EnumToken.MathFunctionTokenType) &&
|
|
1626
1500
|
[
|
|
1627
1501
|
"number",
|
|
@@ -1636,19 +1510,19 @@ function matchProperty(property, context, options) {
|
|
|
1636
1510
|
"calc-product",
|
|
1637
1511
|
].includes(property.val);
|
|
1638
1512
|
if (checkCalc && !["number", "zero", "integer", "percentage", "length-percentage"].includes(property.val)) {
|
|
1639
|
-
checkCalc =
|
|
1513
|
+
checkCalc = token.val === "calc";
|
|
1640
1514
|
}
|
|
1641
1515
|
if (checkCalc) {
|
|
1642
1516
|
let result;
|
|
1643
|
-
const syntax = getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes,
|
|
1517
|
+
const syntax = getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, token.val + "()")?.[0]?.chi;
|
|
1644
1518
|
if (t === EnumToken.MathFunctionTokenType) {
|
|
1645
|
-
result = matchSyntax(syntax, createValidationContext(
|
|
1519
|
+
result = matchSyntax(syntax, createValidationContext(token.chi), options);
|
|
1646
1520
|
if (result.success && result.context.done()) {
|
|
1647
1521
|
context.next();
|
|
1648
1522
|
return {
|
|
1649
1523
|
success: true,
|
|
1650
1524
|
valid: true,
|
|
1651
|
-
token:
|
|
1525
|
+
token: token,
|
|
1652
1526
|
context,
|
|
1653
1527
|
syntaxToken: null,
|
|
1654
1528
|
errors: [],
|
|
@@ -1822,13 +1696,16 @@ function matchProperty(property, context, options) {
|
|
|
1822
1696
|
case "display-outside":
|
|
1823
1697
|
case "display-legacy":
|
|
1824
1698
|
case "content-position":
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
config.syntaxes[property.val].syntax
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1699
|
+
{
|
|
1700
|
+
let values = propertyKeywordValues.get(property.val);
|
|
1701
|
+
if (values == null) {
|
|
1702
|
+
values = new Set(config.syntaxes[property.val].syntax.split(/[\s|]+/));
|
|
1703
|
+
propertyKeywordValues.set(property.val, values);
|
|
1704
|
+
}
|
|
1705
|
+
success =
|
|
1706
|
+
token?.typ == EnumToken.IdenTokenType && values.has(token.val.toLowerCase());
|
|
1707
|
+
break;
|
|
1708
|
+
}
|
|
1832
1709
|
case "mf-name":
|
|
1833
1710
|
{
|
|
1834
1711
|
const token = context.peek();
|
|
@@ -1849,9 +1726,9 @@ function matchProperty(property, context, options) {
|
|
|
1849
1726
|
case "counter-name":
|
|
1850
1727
|
case "counter-style-name":
|
|
1851
1728
|
success =
|
|
1852
|
-
|
|
1853
|
-
if (success &&
|
|
1854
|
-
const val =
|
|
1729
|
+
token?.typ == EnumToken.IdenTokenType || token?.typ == EnumToken.DashedIdenTokenType;
|
|
1730
|
+
if (success && token?.typ === EnumToken.IdenTokenType) {
|
|
1731
|
+
const val = token.val.toLowerCase();
|
|
1855
1732
|
success = "none" !== val && !allValues.includes(val);
|
|
1856
1733
|
}
|
|
1857
1734
|
break;
|
|
@@ -2365,7 +2242,6 @@ function matchRepeatableSyntax(syntax, context, options) {
|
|
|
2365
2242
|
let result = null;
|
|
2366
2243
|
let tmpResult;
|
|
2367
2244
|
let success = !!isRepeatable;
|
|
2368
|
-
// let index: number = context.index;
|
|
2369
2245
|
do {
|
|
2370
2246
|
tmpResult = matchSyntax([rest], context.slice(), options);
|
|
2371
2247
|
if (tmpResult.success) {
|
|
@@ -2375,15 +2251,10 @@ function matchRepeatableSyntax(syntax, context, options) {
|
|
|
2375
2251
|
context.end();
|
|
2376
2252
|
break;
|
|
2377
2253
|
}
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2254
|
+
if (tmpResult.context.index === context.index) {
|
|
2255
|
+
break;
|
|
2256
|
+
}
|
|
2381
2257
|
context.update(result.context.current());
|
|
2382
|
-
// }
|
|
2383
|
-
// if (index === context.index) {
|
|
2384
|
-
// break;
|
|
2385
|
-
// }
|
|
2386
|
-
// index = context.index;
|
|
2387
2258
|
}
|
|
2388
2259
|
} while (tmpResult.success && !context.done());
|
|
2389
2260
|
return {
|
package/dist/node.js
CHANGED
|
@@ -4,8 +4,8 @@ import { createReadStream } from 'node:fs';
|
|
|
4
4
|
import { lstat, readFile } from 'node:fs/promises';
|
|
5
5
|
import { doParse, doParseSync } from './lib/parser/parse.js';
|
|
6
6
|
export { parseDeclarations, parseString } from './lib/parser/parse.js';
|
|
7
|
-
import { doRender } from './lib/
|
|
8
|
-
export { renderValue as renderToken } from './lib/
|
|
7
|
+
import { doRender } from './lib/printer/render.js';
|
|
8
|
+
export { renderValue as renderToken } from './lib/printer/render.js';
|
|
9
9
|
import { ModuleScopeEnumOptions } from './lib/ast/types.js';
|
|
10
10
|
export { ColorType, EnumAstNodeStatus, EnumToken, ModuleCaseTransformEnum, ValidationLevel } from './lib/ast/types.js';
|
|
11
11
|
import { Tokenizer } from './lib/parser/tokenize.js';
|
|
@@ -23,7 +23,7 @@ export { isOkLabClose, okLabDistance } from './lib/syntax/color/utils/distance.j
|
|
|
23
23
|
export { find, findAll, findByValue, findLast } from './lib/ast/find.js';
|
|
24
24
|
export { cloneNode } from './lib/ast/clone.js';
|
|
25
25
|
export { replaceNodeOrValue } from './lib/parser/utils/token.js';
|
|
26
|
-
export { SourceMap } from './lib/
|
|
26
|
+
export { SourceMap } from './lib/printer/sourcemap/sourcemap.js';
|
|
27
27
|
export { FeatureWalkMode } from './lib/ast/features/type.js';
|
|
28
28
|
export { getNodeProperty, setNodeProperty } from './lib/ast/node.js';
|
|
29
29
|
|
package/dist/web.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { doParse, doParseSync } from './lib/parser/parse.js';
|
|
2
2
|
export { parseDeclarations, parseString } from './lib/parser/parse.js';
|
|
3
|
-
import { doRender } from './lib/
|
|
4
|
-
export { renderValue as renderToken } from './lib/
|
|
3
|
+
import { doRender } from './lib/printer/render.js';
|
|
4
|
+
export { renderValue as renderToken } from './lib/printer/render.js';
|
|
5
5
|
import { ModuleScopeEnumOptions } from './lib/ast/types.js';
|
|
6
6
|
export { ColorType, EnumAstNodeStatus, EnumToken, ModuleCaseTransformEnum, ValidationLevel } from './lib/ast/types.js';
|
|
7
7
|
import { Tokenizer } from './lib/parser/tokenize.js';
|
|
@@ -17,7 +17,8 @@ export { isOkLabClose, okLabDistance } from './lib/syntax/color/utils/distance.j
|
|
|
17
17
|
export { find, findAll, findByValue, findLast } from './lib/ast/find.js';
|
|
18
18
|
export { cloneNode } from './lib/ast/clone.js';
|
|
19
19
|
export { replaceNodeOrValue } from './lib/parser/utils/token.js';
|
|
20
|
-
export {
|
|
20
|
+
export { PropertyList } from './lib/parser/declaration/list.js';
|
|
21
|
+
export { SourceMap } from './lib/printer/sourcemap/sourcemap.js';
|
|
21
22
|
export { FeatureWalkMode } from './lib/ast/features/type.js';
|
|
22
23
|
export { getNodeProperty, setNodeProperty } from './lib/ast/node.js';
|
|
23
24
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbela99/css-parser",
|
|
3
3
|
"description": "CSS parser, minifier and validator for node and the browser",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.5",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/node.js",
|
|
7
7
|
"./node": "./dist/node.js",
|
|
@@ -60,17 +60,20 @@
|
|
|
60
60
|
},
|
|
61
61
|
"homepage": "https://github.com/tbela99/css-parser#readme",
|
|
62
62
|
"devDependencies": {
|
|
63
|
+
"@boneskull/typedoc-plugin-mermaid": "^0.2.1",
|
|
63
64
|
"@rollup/plugin-commonjs": "^29.0.3",
|
|
64
65
|
"@rollup/plugin-json": "^6.1.0",
|
|
65
66
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
66
67
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
67
68
|
"@types/chai": "^5.2.3",
|
|
69
|
+
"@types/chai-as-promised": "^8.0.2",
|
|
68
70
|
"@types/mocha": "^10.0.10",
|
|
69
71
|
"@types/node": "^26.4.1",
|
|
70
72
|
"@types/web": "^0.0.354",
|
|
71
73
|
"@web/test-runner": "^1.0.0",
|
|
72
74
|
"@web/test-runner-playwright": "^1.0.0",
|
|
73
75
|
"chai": "^6.2.2",
|
|
76
|
+
"chai-as-promised": "^8.0.2",
|
|
74
77
|
"esno": "^4.8.0",
|
|
75
78
|
"markdown-it-task-lists": "^2.1.1",
|
|
76
79
|
"mocha": "^12.0.0",
|
|
@@ -83,9 +86,7 @@
|
|
|
83
86
|
"typedoc-plugin-coverage": "^4.0.3",
|
|
84
87
|
"typedoc-plugin-llms-txt": "^0.1.2",
|
|
85
88
|
"typedoc-plugin-redirect": "^1.3.0",
|
|
86
|
-
"typedoc-unhoax-theme": "^0.5.3"
|
|
87
|
-
"@types/chai-as-promised": "^8.0.2",
|
|
88
|
-
"chai-as-promised": "^8.0.2"
|
|
89
|
+
"typedoc-unhoax-theme": "^0.5.3"
|
|
89
90
|
},
|
|
90
91
|
"sideEffects": false
|
|
91
|
-
}
|
|
92
|
+
}
|
|
File without changes
|
|
File without changes
|