@tbela99/css-parser 2.1.0 → 2.3.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.
Files changed (130) hide show
  1. package/CHANGELOG.md +66 -1
  2. package/README.md +14 -7
  3. package/architecture.png +0 -0
  4. package/dist/{src/lib/ast → ast}/arena-node.js +10 -10
  5. package/dist/{src/lib/ast → ast}/arena.js +304 -139
  6. package/dist/{src/lib/ast → ast}/cache.js +40 -24
  7. package/dist/{src/lib/ast → ast}/features/calc.js +11 -9
  8. package/dist/{src/lib/ast → ast}/features/if.js +6 -6
  9. package/dist/ast/features/index.d.ts +7 -0
  10. package/dist/{src/lib/ast → ast}/features/index.js +3 -2
  11. package/dist/{src/lib/ast → ast}/features/inlinecssvariables.js +12 -10
  12. package/dist/ast/features/mixin.js +953 -0
  13. package/dist/{src/lib/ast → ast}/features/prefix.js +39 -39
  14. package/dist/ast/features/shorthand.js +129 -0
  15. package/dist/ast/features/transform.js +188 -0
  16. package/dist/{src/lib/ast → ast}/features/type.js +2 -2
  17. package/dist/{src/lib/ast → ast}/math/expression.js +24 -24
  18. package/dist/{src/lib/ast → ast}/math/math.js +2 -2
  19. package/dist/{src/lib/ast → ast}/minify.js +745 -201
  20. package/dist/ast/mixins/custom-function.js +393 -0
  21. package/dist/ast/mixins/utils.js +53 -0
  22. package/dist/ast/mixins/variables.js +678 -0
  23. package/dist/ast/strings.js +910 -0
  24. package/dist/ast/transform/compute.js +560 -0
  25. package/dist/ast/transform/matrix.js +67 -0
  26. package/dist/ast/transform/minify.js +325 -0
  27. package/dist/ast/transform/perspective.js +24 -0
  28. package/dist/{src/lib/ast → ast}/transform/rotate.js +16 -7
  29. package/dist/ast/transform/scale.js +43 -0
  30. package/dist/ast/transform/skew.js +38 -0
  31. package/dist/ast/transform/translate.js +56 -0
  32. package/dist/ast/transform/utils.js +390 -0
  33. package/dist/{src/lib/ast → ast}/types.js +2 -2
  34. package/dist/{src/lib/ast → ast}/walk.js +2 -2
  35. package/dist/{src/data → data}/properties.json.js +86 -2
  36. package/dist/{src/data → data}/validation.json.js +30 -21
  37. package/dist/{src/lib/fs → fs}/resolve.js +2 -2
  38. package/dist/index-umd-web.js +19727 -10719
  39. package/dist/index.d.ts +738 -100
  40. package/dist/{src/node.js → node.js} +70 -52
  41. package/dist/{src/lib/parser → parser}/declaration/list.js +25 -8
  42. package/dist/{src/lib/parser → parser}/declaration/map.js +15 -15
  43. package/dist/{src/lib/parser → parser}/declaration/set.js +5 -5
  44. package/dist/{src/lib/parser → parser}/input.js +18 -3
  45. package/dist/{src/lib/parser → parser}/linesmap.js +2 -2
  46. package/dist/{src/lib/parser → parser}/parse.js +444 -278
  47. package/dist/{src/lib/parser → parser}/source.js +3 -3
  48. package/dist/{src/lib/parser → parser}/tokenize.js +480 -312
  49. package/dist/{src/lib/parser → parser}/utils/angle.js +3 -3
  50. package/dist/{src/lib/parser → parser}/utils/at-rule-container.js +12 -12
  51. package/dist/{src/lib/parser → parser}/utils/at-rule-font-feature-values.js +3 -3
  52. package/dist/{src/lib/parser → parser}/utils/at-rule-generic.js +7 -7
  53. package/dist/{src/lib/parser → parser}/utils/at-rule-import.js +10 -10
  54. package/dist/{src/lib/parser → parser}/utils/at-rule-media.js +14 -14
  55. package/dist/{src/lib/parser → parser}/utils/at-rule-support.js +9 -14
  56. package/dist/{src/lib/parser → parser}/utils/at-rule-when-else.js +6 -6
  57. package/dist/{src/lib/parser → parser}/utils/at-rule.js +3 -3
  58. package/dist/{src/lib/parser → parser}/utils/base64.js +2 -2
  59. package/dist/parser/utils/cache.js +53 -0
  60. package/dist/parser/utils/canonical.js +78 -0
  61. package/dist/parser/utils/codes.js +93 -0
  62. package/dist/{src/lib/parser → parser}/utils/config.js +3 -3
  63. package/dist/{src/lib/parser → parser}/utils/declaration.js +31 -26
  64. package/dist/{src/lib/parser → parser}/utils/eq.js +2 -2
  65. package/dist/{src/lib/parser → parser}/utils/hash.js +2 -2
  66. package/dist/{src/lib/parser → parser}/utils/selector.js +339 -87
  67. package/dist/{src/lib/parser → parser}/utils/text.js +2 -2
  68. package/dist/{src/lib/parser → parser}/utils/token.js +2 -2
  69. package/dist/{src/lib/parser → parser}/utils/type.js +9 -7
  70. package/dist/{src/lib/printer/sourcemap → printer}/lib/codec.js +2 -2
  71. package/dist/{src/lib/printer → printer}/render.js +582 -153
  72. package/dist/printer/result.js +148 -0
  73. package/dist/{src/lib/printer/sourcemap → printer}/sourcemap.js +4 -3
  74. package/dist/printer/writer.js +252 -0
  75. package/dist/{src/lib/syntax → syntax}/color/a98rgb.js +2 -2
  76. package/dist/{src/lib/syntax → syntax}/color/alpha.js +10 -10
  77. package/dist/{src/lib/syntax → syntax}/color/cmyk.js +2 -2
  78. package/dist/{src/lib/syntax → syntax}/color/color-mix.js +18 -18
  79. package/dist/{src/lib/syntax → syntax}/color/color.js +18 -18
  80. package/dist/{src/lib/syntax → syntax}/color/hex.js +3 -3
  81. package/dist/{src/lib/syntax → syntax}/color/hsl.js +2 -2
  82. package/dist/{src/lib/syntax → syntax}/color/hwb.js +2 -2
  83. package/dist/{src/lib/syntax → syntax}/color/lab.js +2 -2
  84. package/dist/{src/lib/syntax → syntax}/color/lch.js +2 -2
  85. package/dist/{src/lib/syntax → syntax}/color/oklab.js +2 -2
  86. package/dist/{src/lib/syntax → syntax}/color/oklch.js +3 -3
  87. package/dist/{src/lib/syntax → syntax}/color/p3.js +2 -2
  88. package/dist/{src/lib/syntax → syntax}/color/prophotorgb.js +2 -2
  89. package/dist/{src/lib/syntax → syntax}/color/rec2020.js +2 -2
  90. package/dist/{src/lib/syntax → syntax}/color/relative-color.js +14 -14
  91. package/dist/{src/lib/syntax → syntax}/color/rgb.js +4 -4
  92. package/dist/{src/lib/syntax → syntax}/color/srgb.js +5 -5
  93. package/dist/{src/lib/syntax → syntax}/color/utils/color-type.js +4 -4
  94. package/dist/{src/lib/syntax → syntax}/color/utils/colorspace.js +10 -10
  95. package/dist/{src/lib/syntax → syntax}/color/utils/components.js +5 -5
  96. package/dist/{src/lib/syntax → syntax}/color/utils/distance.js +2 -2
  97. package/dist/{src/lib/syntax → syntax}/color/utils/make-color.js +3 -3
  98. package/dist/{src/lib/syntax → syntax}/color/utils/matrix.js +2 -2
  99. package/dist/{src/lib/syntax → syntax}/color/xyz.js +2 -2
  100. package/dist/{src/lib/syntax → syntax}/color/xyzd50.js +2 -2
  101. package/dist/{src/lib/syntax → syntax}/constants.js +27 -4
  102. package/dist/{src/lib/syntax → syntax}/syntax.js +37 -29
  103. package/dist/{src/types.js → types.js} +2 -2
  104. package/dist/{src/utils → utils}/sync.js +12 -7
  105. package/dist/validation/compiled/builtins.js +32 -0
  106. package/dist/validation/compiled/runtime.js +705 -0
  107. package/dist/validation/compiled/syntaxes.js +1620 -0
  108. package/dist/{src/lib/validation → validation}/config.js +63 -16
  109. package/dist/validation/first.js +574 -0
  110. package/dist/{src/lib/validation → validation}/match.js +376 -161
  111. package/dist/{src/lib/validation → validation}/parser/parse.js +2 -2
  112. package/dist/{src/lib/validation → validation}/parser/typedef.js +2 -2
  113. package/dist/{src/lib/validation → validation}/utils/list.js +3 -19
  114. package/dist/version.js +13 -0
  115. package/dist/{src/web.js → web.js} +68 -55
  116. package/package.json +15 -13
  117. package/dist/package.json.js +0 -10
  118. package/dist/src/lib/ast/features/shorthand.js +0 -95
  119. package/dist/src/lib/ast/features/transform.js +0 -90
  120. package/dist/src/lib/ast/transform/compute.js +0 -362
  121. package/dist/src/lib/ast/transform/matrix.js +0 -88
  122. package/dist/src/lib/ast/transform/minify.js +0 -267
  123. package/dist/src/lib/ast/transform/perspective.js +0 -16
  124. package/dist/src/lib/ast/transform/scale.js +0 -39
  125. package/dist/src/lib/ast/transform/skew.js +0 -30
  126. package/dist/src/lib/ast/transform/translate.js +0 -39
  127. package/dist/src/lib/ast/transform/utils.js +0 -287
  128. package/dist/src/lib/parser/utils/cache.js +0 -54
  129. package/dist/types.d.ts +0 -21
  130. package/dist/utils/sync.d.ts +0 -16
@@ -1,8 +1,8 @@
1
1
  /*
2
- CSS parser, minifier and validator for node and the browser
2
+ CSS parser, minifier and validator for node, deno, bun and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 2.1.0
5
+ Version: 2.3.0
6
6
  License: MIT
7
7
  */
8
8
  import { TokenField } from '../ast/arena.js';
@@ -568,7 +568,7 @@ function isFlexUnit(unit) {
568
568
  return flexUnitSet.has(unit.toLowerCase());
569
569
  }
570
570
  function isLength(arena, dimension) {
571
- return arena.unit[dimension] !== 0 && isLengthUnit(arena.strings[arena.unit[dimension]]);
571
+ return arena.unit[dimension] !== 0 && isLengthUnit(arena.resolveString(arena.unit[dimension]));
572
572
  }
573
573
  /**
574
574
  * Reduce color stops
@@ -754,7 +754,7 @@ function reduceConicColorStops(arena, stops) {
754
754
  */
755
755
  function isRectangularOrthogonalColorspace(arena, token) {
756
756
  return (arena.dataTypes[token] === EnumToken.IdenTokenType &&
757
- colorFuncColorSpace.some((t) => equalsIgnoreCase(t, arena.strings[arena.stringValue[token]])));
757
+ colorFuncColorSpace.some((t) => equalsIgnoreCase(t, arena.resolveString(arena.stringValue[token]))));
758
758
  }
759
759
  /**
760
760
  * Is polar colorspace
@@ -764,7 +764,7 @@ function isRectangularOrthogonalColorspace(arena, token) {
764
764
  */
765
765
  function isPolarColorspace(arena, token) {
766
766
  return (arena.dataTypes[token] === EnumToken.IdenTokenType &&
767
- ["hsl", "hwb", "lch", "oklch"].some((t) => equalsIgnoreCase(t, arena.strings[arena.stringValue[token]])));
767
+ ["hsl", "hwb", "lch", "oklch"].some((t) => equalsIgnoreCase(t, arena.resolveString(arena.stringValue[token]))));
768
768
  }
769
769
  /**
770
770
  * Is ident color
@@ -776,7 +776,19 @@ function isIdentColor(arena, token) {
776
776
  return (arena.dataTypes[token] === EnumToken.ColorTokenType &&
777
777
  arena.colorType[token] !== ColorType.NONE &&
778
778
  [ColorType.SYS, ColorType.DPSYS, ColorType.LIT].includes(arena.colorType[token]) &&
779
- isIdent(arena.strings[arena.stringValue[token]]));
779
+ isIdent(arena.resolveString(arena.stringValue[token])));
780
+ }
781
+ /**
782
+ * true if the identifier is a color: a system color, a named color, `currentcolor` or `transparent`, ignoring the case
783
+ * @param str
784
+ */
785
+ function isColorName(str) {
786
+ const val = lowercase(str);
787
+ if (systemColors.has(val) || deprecatedSystemColors.has(val) || nonStandardColors.has(val)) {
788
+ return true;
789
+ }
790
+ // named color
791
+ return val in COLORS_NAMES || "currentcolor" === val || "transparent" === val;
780
792
  }
781
793
  /**
782
794
  * color function arguments without whitespace and comments
@@ -815,16 +827,12 @@ function isColor(arena, token, errors) {
815
827
  }
816
828
  }
817
829
  if (typ === EnumToken.IdenTokenType) {
818
- const val = lowercase(arena.strings[arena.stringValue[token]]);
819
- if (systemColors.has(val) || deprecatedSystemColors.has(val) || nonStandardColors.has(val)) {
820
- return true;
821
- }
822
- // named color
823
- return val in COLORS_NAMES || "currentcolor" === val || "transparent" === val;
830
+ // computed once per string id
831
+ return arena.stringFlag(arena.stringValue[token], 0 /* StringFlag.Color */, isColorName);
824
832
  }
825
833
  if (typ === EnumToken.FunctionTokenType || typ === EnumToken.ColorTokenType) {
826
834
  if (arena.firstToken[token] !== 0) {
827
- const name = arena.strings[arena.stringValue[token]];
835
+ const name = arena.resolveString(arena.stringValue[token]);
828
836
  if (name === "light-dark") {
829
837
  const children = filterChildren(arena, token, [
830
838
  EnumToken.IdenTokenType,
@@ -855,7 +863,7 @@ function isColor(arena, token, errors) {
855
863
  if (colorSpace != null) {
856
864
  for (const value of components) {
857
865
  if (arena.dataTypes[value] === EnumToken.IdenTokenType) {
858
- const val = arena.strings[arena.stringValue[value]].toLowerCase();
866
+ const val = arena.resolveString(arena.stringValue[value]).toLowerCase();
859
867
  if (
860
868
  // @ts-expect-error
861
869
  typeof Math[val.toUpperCase()] !== "number" &&
@@ -872,12 +880,12 @@ function isColor(arena, token, errors) {
872
880
  }
873
881
  }
874
882
  else if (arena.dataTypes[value] === EnumToken.MathFunctionTokenType &&
875
- equalsIgnoreCase("calc", arena.strings[arena.stringValue[value]])) {
883
+ equalsIgnoreCase("calc", arena.resolveString(arena.stringValue[value]))) {
876
884
  let val;
877
885
  // inlined: arena.walkValues(arena.tokens(value))
878
886
  for (const v of new ValueWalker(arena, arena.tokens(value))) {
879
887
  if (arena.dataTypes[v] === EnumToken.IdenTokenType) {
880
- val = arena.strings[arena.stringValue[v]].toLowerCase();
888
+ val = arena.resolveString(arena.stringValue[v]).toLowerCase();
881
889
  if (
882
890
  // @ts-expect-error
883
891
  typeof Math[val.toUpperCase()] !== "number" &&
@@ -915,7 +923,7 @@ function isColor(arena, token, errors) {
915
923
  else if (parent != null &&
916
924
  parent !== token &&
917
925
  arena.dataTypes[parent] === EnumToken.MathFunctionTokenType &&
918
- arena.strings[arena.stringValue[parent]] === "calc") {
926
+ arena.resolveString(arena.stringValue[parent]) === "calc") {
919
927
  const children = arena.tokens(parent);
920
928
  l = k + 1;
921
929
  while (l + 1 < children.length) {
@@ -959,7 +967,7 @@ function isColor(arena, token, errors) {
959
967
  EnumToken.PercentageTokenType,
960
968
  ]);
961
969
  const isRelative = arena.dataTypes[children[0]] === EnumToken.IdenTokenType &&
962
- arena.strings[arena.stringValue[children[0]]] === "from";
970
+ arena.resolveString(arena.stringValue[children[0]]) === "from";
963
971
  let offset = 0;
964
972
  if (isRelative) {
965
973
  offset = 2;
@@ -983,7 +991,7 @@ function isColor(arena, token, errors) {
983
991
  childType === EnumToken.PercentageTokenType ||
984
992
  isColor(arena, children[i]) ||
985
993
  (childType === EnumToken.IdenTokenType &&
986
- equalsIgnoreCase("none", arena.strings[arena.stringValue[children[i]]]))) {
994
+ equalsIgnoreCase("none", arena.resolveString(arena.stringValue[children[i]])))) {
987
995
  continue;
988
996
  }
989
997
  return false;
@@ -1009,7 +1017,7 @@ function isColor(arena, token, errors) {
1009
1017
  let k = 0;
1010
1018
  if (children[j].length > 0 &&
1011
1019
  arena.dataTypes[children[j][0]] === EnumToken.IdenTokenType &&
1012
- equalsIgnoreCase("in", arena.strings[arena.stringValue[children[j][k]]])) {
1020
+ equalsIgnoreCase("in", arena.resolveString(arena.stringValue[children[j][k]]))) {
1013
1021
  k++;
1014
1022
  if (k < children[j].length && arena.dataTypes[children[j][k]] === EnumToken.IdenTokenType) {
1015
1023
  if (!isRectangularOrthogonalColorspace(arena, children[j][k])) {
@@ -1018,11 +1026,11 @@ function isColor(arena, token, errors) {
1018
1026
  else if (arena.dataTypes[children[j][k]] !== EnumToken.IdenTokenType) {
1019
1027
  return false;
1020
1028
  }
1021
- else if (equalsIgnoreCase("hue", arena.strings[arena.stringValue[children[j][k]]])) {
1029
+ else if (equalsIgnoreCase("hue", arena.resolveString(arena.stringValue[children[j][k]]))) {
1022
1030
  k++;
1023
1031
  }
1024
1032
  else {
1025
- switch (arena.strings[arena.stringValue[children[j][k]]]) {
1033
+ switch (arena.resolveString(arena.stringValue[children[j][k]])) {
1026
1034
  case "increasing":
1027
1035
  case "decreasing":
1028
1036
  case "longer":
@@ -1034,7 +1042,7 @@ function isColor(arena, token, errors) {
1034
1042
  }
1035
1043
  if (k >= children[j].length ||
1036
1044
  arena.dataTypes[children[j][k]] !== EnumToken.IdenTokenType ||
1037
- !equalsIgnoreCase("hue", arena.strings[arena.stringValue[children[j][k]]])) {
1045
+ !equalsIgnoreCase("hue", arena.resolveString(arena.stringValue[children[j][k]]))) {
1038
1046
  return false;
1039
1047
  }
1040
1048
  k++;
@@ -1062,7 +1070,7 @@ function isColor(arena, token, errors) {
1062
1070
  function parseColor(arena, token) {
1063
1071
  const typ = arena.dataTypes[token];
1064
1072
  if (typ === EnumToken.IdenTokenType) {
1065
- const val = arena.strings[arena.stringValue[token]].toLowerCase();
1073
+ const val = arena.resolveString(arena.stringValue[token]).toLowerCase();
1066
1074
  if (nonStandardColors.has(val)) {
1067
1075
  arena.dataTypes[token] = EnumToken.ColorTokenType;
1068
1076
  // inlined: arena.setColorType(token, ColorType.NON_STD)
@@ -1091,7 +1099,7 @@ function parseColor(arena, token) {
1091
1099
  }
1092
1100
  }
1093
1101
  if (typ === EnumToken.ColorTokenType) {
1094
- const val = arena.strings[arena.stringValue[token]];
1102
+ const val = arena.resolveString(arena.stringValue[token]);
1095
1103
  if (arena.colorType[token] === ColorType.NONE && arena.stringValue[token] !== 0) {
1096
1104
  // inlined: arena.setColorType(token, ColorType[val.replaceAll("-", "_").toUpperCase()] ?? 0)
1097
1105
  // @ts-expect-error
@@ -1102,11 +1110,11 @@ function parseColor(arena, token) {
1102
1110
  arena.dataTypes[t] !== EnumToken.CommentTokenType);
1103
1111
  if (tk != null &&
1104
1112
  arena.dataTypes[tk] === EnumToken.IdenTokenType &&
1105
- arena.strings[arena.stringValue[tk]] === "from") {
1113
+ arena.resolveString(arena.stringValue[tk]) === "from") {
1106
1114
  // inlined: arena.setUnitString(token, "rel")
1107
1115
  arena.unit[token] = arena.internString("rel");
1108
1116
  }
1109
- else if (val === "color-mix" && tk != null && arena.strings[arena.stringValue[tk]] === "in") {
1117
+ else if (val === "color-mix" && tk != null && arena.resolveString(arena.stringValue[tk]) === "in") {
1110
1118
  // inlined: arena.setUnitString(token, "mix")
1111
1119
  arena.unit[token] = arena.internString("mix");
1112
1120
  }
@@ -1377,7 +1385,7 @@ function length2Px(arena, value) {
1377
1385
  }
1378
1386
  else {
1379
1387
  // the absolute length units: 1in = 2.54cm = 96px. the units are case-insensitive
1380
- switch (arena.strings[arena.unit[value]]?.toLowerCase()) {
1388
+ switch (arena.resolveString(arena.unit[value])?.toLowerCase()) {
1381
1389
  case "cm":
1382
1390
  result = (val * 96) / 2.54;
1383
1391
  break;
@@ -1476,4 +1484,4 @@ function toPrecisionAngle(angle, precision = anglePrecision, correctValue = true
1476
1484
  return angle;
1477
1485
  }
1478
1486
 
1479
- export { angleUnits, dimensionUnits, flexUnits, frequencyUnits, isAngleUnit, isColor, isDigit, isFlexUnit, isFrequencyUnit, isFunction, isHash, isIdent, isIdentCodepoint, isIdentColor, isIdentStart, isLength, isLengthUnit, isLetter, isNewLine, isNonPrintable, isPolarColorspace, isPseudo, isRectangularOrthogonalColorspace, isResolutionUnit, isTimeUnit, isWhiteSpace, length2Px, minifyNumber, parseColor, parseDimension, pseudoAliasMap, reduceColorStops, reduceConicColorStops, reducegradientBackgroundPosition, renamedStandardProperties, resolutionUnits, timeUnits, toPrecisionAngle, toPrecisionValue };
1487
+ export { angleUnits, dimensionUnits, flexUnits, frequencyUnits, isAngleUnit, isColor, isColorName, isDigit, isFlexUnit, isFrequencyUnit, isFunction, isHash, isIdent, isIdentCodepoint, isIdentColor, isIdentStart, isLength, isLengthUnit, isLetter, isNewLine, isNonPrintable, isPolarColorspace, isPseudo, isRectangularOrthogonalColorspace, isResolutionUnit, isTimeUnit, isWhiteSpace, length2Px, minifyNumber, parseColor, parseDimension, pseudoAliasMap, reduceColorStops, reduceConicColorStops, reducegradientBackgroundPosition, renamedStandardProperties, resolutionUnits, timeUnits, toPrecisionAngle, toPrecisionValue };
@@ -1,8 +1,8 @@
1
1
  /*
2
- CSS parser, minifier and validator for node and the browser
2
+ CSS parser, minifier and validator for node, deno, bun and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 2.1.0
5
+ Version: 2.3.0
6
6
  License: MIT
7
7
  */
8
8
  /**
@@ -1,13 +1,12 @@
1
1
  /*
2
- CSS parser, minifier and validator for node and the browser
2
+ CSS parser, minifier and validator for node, deno, bun and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 2.1.0
5
+ Version: 2.3.0
6
6
  License: MIT
7
7
  */
8
- import { EnumToken } from '../lib/ast/types.js';
9
- import { AstArena } from '../lib/ast/arena.js';
10
- import { dirname } from '../lib/fs/resolve.js';
8
+ import { EnumToken } from '../ast/types.js';
9
+ import { dirname } from '../fs/resolve.js';
11
10
  import { ResponseType } from '../types.js';
12
11
 
13
12
  /**
@@ -29,7 +28,7 @@ function parseResult(result, options) {
29
28
  if (token !== 0 &&
30
29
  arena.dataTypes[token] === EnumToken.CommentTokenType &&
31
30
  arena.startsWith(token, "val", "/*# sourceMappingURL=")) {
32
- let data = arena.strings[arena.stringValue[token]].slice(21, -2).trim();
31
+ let data = arena.resolveString(arena.stringValue[token]).slice(21, -2).trim();
33
32
  if (data.endsWith(".map")) {
34
33
  if (options.load == null) {
35
34
  data = "";
@@ -74,7 +73,13 @@ function validateSyncArguments(options, prefix = "options.") {
74
73
  throw new Error(`[${prefix + key}]: Async functions are not supported in sync mode. Use parse() or transform() instead.`);
75
74
  }
76
75
  }
77
- else if (value != null && typeof value === "object" && !(value instanceof AstArena)) {
76
+ else if (value != null &&
77
+ typeof value === "object" &&
78
+ // the plain objects (visitors, ...) and the arrays: the class instances (arenas, source files, maps, typed
79
+ // arrays, ...) are not traversed
80
+ (Array.isArray(value) ||
81
+ Object.getPrototypeOf(value) === Object.prototype ||
82
+ Object.getPrototypeOf(value) === null)) {
78
83
  validateSyncArguments(value, prefix + key + ".");
79
84
  }
80
85
  }
@@ -0,0 +1,32 @@
1
+ /*
2
+ CSS parser, minifier and validator for node, deno, bun and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 2.3.0
6
+ License: MIT
7
+ */
8
+ /**
9
+ * the types validated by the code of matchProperty() (src/validation/match.ts), before their definition (if any): the
10
+ * compiled matchers call matchProperty() for them (see leaf() in ./runtime.ts). the other types are compiled from
11
+ * their definition. keep in sync with the switch of matchProperty() and with its calc() types
12
+ */
13
+ /**
14
+ * the built in types that read the whitespace or the tokens after the value being matched: the compiled matchers
15
+ * skip the whitespace, the interpreter validates the values of these types
16
+ */
17
+ const rawTypes = new Set([
18
+ "type-selector",
19
+ "compound-selector",
20
+ "complex-selector",
21
+ "subclass-selector",
22
+ "attribute-selector",
23
+ "complex-selector-unit",
24
+ "pseudo-compound-selector",
25
+ "forgiving-relative-selector-list",
26
+ "complex-selector-list",
27
+ "size-feature",
28
+ "style-feature",
29
+ "css-type",
30
+ ]);
31
+
32
+ export { rawTypes };