@tbela99/css-parser 1.6.7 → 1.6.8

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 (102) hide show
  1. package/CHANGELOG.md +60 -4
  2. package/dist/index-umd-web.js +126 -49
  3. package/dist/index.cjs +119 -49
  4. package/dist/index.d.ts +51 -3
  5. package/dist/package.json.js +10 -0
  6. package/dist/{data → src/data}/properties.json.js +7 -0
  7. package/dist/{data → src/data}/validation.json.js +7 -0
  8. package/dist/{lib → src/lib}/ast/clone.js +7 -0
  9. package/dist/{lib → src/lib}/ast/expand.js +7 -0
  10. package/dist/{lib → src/lib}/ast/features/calc.js +7 -0
  11. package/dist/{lib → src/lib}/ast/features/if.js +7 -0
  12. package/dist/{lib → src/lib}/ast/features/index.js +7 -0
  13. package/dist/{lib → src/lib}/ast/features/inlinecssvariables.js +7 -0
  14. package/dist/{lib → src/lib}/ast/features/prefix.js +7 -0
  15. package/dist/{lib → src/lib}/ast/features/shorthand.js +7 -0
  16. package/dist/{lib → src/lib}/ast/features/transform.js +7 -0
  17. package/dist/{lib → src/lib}/ast/features/type.js +7 -0
  18. package/dist/{lib → src/lib}/ast/find.js +7 -0
  19. package/dist/{lib → src/lib}/ast/math/expression.js +7 -0
  20. package/dist/{lib → src/lib}/ast/math/math.js +7 -0
  21. package/dist/{lib → src/lib}/ast/minify.js +7 -0
  22. package/dist/{lib → src/lib}/ast/node.js +7 -0
  23. package/dist/{lib → src/lib}/ast/transform/compute.js +7 -0
  24. package/dist/{lib → src/lib}/ast/transform/matrix.js +7 -0
  25. package/dist/{lib → src/lib}/ast/transform/minify.js +7 -0
  26. package/dist/{lib → src/lib}/ast/transform/perspective.js +7 -0
  27. package/dist/{lib → src/lib}/ast/transform/rotate.js +7 -0
  28. package/dist/{lib → src/lib}/ast/transform/scale.js +7 -0
  29. package/dist/{lib → src/lib}/ast/transform/skew.js +7 -0
  30. package/dist/{lib → src/lib}/ast/transform/translate.js +7 -0
  31. package/dist/{lib → src/lib}/ast/transform/utils.js +7 -0
  32. package/dist/{lib → src/lib}/ast/types.js +12 -1
  33. package/dist/{lib → src/lib}/ast/walk.js +7 -0
  34. package/dist/{lib → src/lib}/fs/resolve.js +7 -0
  35. package/dist/{lib → src/lib}/parser/declaration/list.js +7 -0
  36. package/dist/{lib → src/lib}/parser/declaration/map.js +7 -0
  37. package/dist/{lib → src/lib}/parser/declaration/set.js +7 -0
  38. package/dist/{lib → src/lib}/parser/linesmap.js +7 -0
  39. package/dist/{lib → src/lib}/parser/parse.js +61 -21
  40. package/dist/{lib → src/lib}/parser/source.js +7 -0
  41. package/dist/{lib → src/lib}/parser/tokenize.js +24 -3
  42. package/dist/{lib → src/lib}/parser/utils/angle.js +7 -0
  43. package/dist/{lib → src/lib}/parser/utils/at-rule-container.js +7 -0
  44. package/dist/{lib → src/lib}/parser/utils/at-rule-font-feature-values.js +7 -0
  45. package/dist/{lib → src/lib}/parser/utils/at-rule-generic.js +7 -0
  46. package/dist/{lib → src/lib}/parser/utils/at-rule-import.js +7 -0
  47. package/dist/{lib → src/lib}/parser/utils/at-rule-media.js +7 -0
  48. package/dist/{lib → src/lib}/parser/utils/at-rule-support.js +7 -0
  49. package/dist/{lib → src/lib}/parser/utils/at-rule-when-else.js +7 -0
  50. package/dist/{lib → src/lib}/parser/utils/at-rule.js +7 -0
  51. package/dist/{lib → src/lib}/parser/utils/base64.js +7 -0
  52. package/dist/{lib → src/lib}/parser/utils/cache.js +7 -0
  53. package/dist/{lib → src/lib}/parser/utils/config.js +7 -0
  54. package/dist/{lib → src/lib}/parser/utils/declaration.js +7 -0
  55. package/dist/{lib → src/lib}/parser/utils/eq.js +7 -0
  56. package/dist/{lib → src/lib}/parser/utils/hash.js +7 -0
  57. package/dist/{lib → src/lib}/parser/utils/selector.js +7 -0
  58. package/dist/{lib → src/lib}/parser/utils/text.js +7 -0
  59. package/dist/{lib → src/lib}/parser/utils/token.js +15 -4
  60. package/dist/{lib → src/lib}/parser/utils/type.js +7 -0
  61. package/dist/{lib → src/lib}/printer/render.js +9 -1
  62. package/dist/{lib → src/lib}/printer/sourcemap/lib/codec.js +7 -0
  63. package/dist/{lib → src/lib}/printer/sourcemap/sourcemap.js +7 -0
  64. package/dist/{lib → src/lib}/syntax/color/a98rgb.js +7 -0
  65. package/dist/{lib → src/lib}/syntax/color/alpha.js +7 -0
  66. package/dist/{lib → src/lib}/syntax/color/cmyk.js +7 -0
  67. package/dist/{lib → src/lib}/syntax/color/color-mix.js +7 -0
  68. package/dist/{lib → src/lib}/syntax/color/color.js +7 -0
  69. package/dist/{lib → src/lib}/syntax/color/hex.js +7 -0
  70. package/dist/{lib → src/lib}/syntax/color/hsl.js +7 -0
  71. package/dist/{lib → src/lib}/syntax/color/hwb.js +7 -0
  72. package/dist/{lib → src/lib}/syntax/color/lab.js +7 -0
  73. package/dist/{lib → src/lib}/syntax/color/lch.js +7 -0
  74. package/dist/{lib → src/lib}/syntax/color/oklab.js +7 -0
  75. package/dist/{lib → src/lib}/syntax/color/oklch.js +7 -0
  76. package/dist/{lib → src/lib}/syntax/color/p3.js +7 -0
  77. package/dist/{lib → src/lib}/syntax/color/prophotorgb.js +7 -0
  78. package/dist/{lib → src/lib}/syntax/color/rec2020.js +7 -0
  79. package/dist/{lib → src/lib}/syntax/color/relative-color.js +7 -0
  80. package/dist/{lib → src/lib}/syntax/color/rgb.js +7 -0
  81. package/dist/{lib → src/lib}/syntax/color/srgb.js +7 -0
  82. package/dist/{lib → src/lib}/syntax/color/utils/color-type.js +7 -0
  83. package/dist/{lib → src/lib}/syntax/color/utils/colorspace.js +7 -0
  84. package/dist/{lib → src/lib}/syntax/color/utils/components.js +7 -0
  85. package/dist/{lib → src/lib}/syntax/color/utils/distance.js +7 -0
  86. package/dist/{lib → src/lib}/syntax/color/utils/make-color.js +7 -0
  87. package/dist/{lib → src/lib}/syntax/color/utils/matrix.js +7 -0
  88. package/dist/{lib → src/lib}/syntax/color/xyz.js +7 -0
  89. package/dist/{lib → src/lib}/syntax/color/xyzd50.js +7 -0
  90. package/dist/{lib → src/lib}/syntax/constants.js +7 -0
  91. package/dist/{lib → src/lib}/syntax/syntax.js +7 -0
  92. package/dist/{lib → src/lib}/validation/config.js +7 -0
  93. package/dist/{lib → src/lib}/validation/match.js +37 -19
  94. package/dist/{lib → src/lib}/validation/parser/parse.js +7 -0
  95. package/dist/{lib → src/lib}/validation/parser/typedef.js +7 -0
  96. package/dist/{lib → src/lib}/validation/utils/list.js +7 -0
  97. package/dist/{node.js → src/node.js} +8 -0
  98. package/dist/{types.js → src/types.js} +7 -0
  99. package/dist/{utils → src/utils}/sync.js +7 -0
  100. package/dist/{web.js → src/web.js} +8 -0
  101. package/package.json +4 -3
  102. package/dist/lib/syntax/color/hsv.js +0 -6
package/CHANGELOG.md CHANGED
@@ -1,15 +1,71 @@
1
1
  # Changelog
2
2
 
3
+ # v1.6.8
4
+
5
+ - [x] allow a visitor to visit all nodes
6
+
7
+ ```ts
8
+ import {transformSync} from '@tbela99/css-parser';
9
+
10
+ const options = {
11
+ input: `
12
+
13
+ button {
14
+ line-height: 2.5 !important;
15
+ line-height: 1.5;
16
+ }
17
+ `,
18
+ beautify: true,
19
+ // visit all nodes
20
+ visitor (node) {
21
+
22
+ console.error(EnumToken[node.typ]);
23
+ }
24
+ };
25
+
26
+ const result = transformSync(options);
27
+ console.debug(result.code);
28
+ ```
29
+
30
+ - [x] implement CSS [at-rule function](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@function) support
31
+
3
32
  # v1.6.7
4
33
 
5
34
  ## Improvement
6
35
 
7
- - limit the amount of memory used when parsing large files
8
- - use node flags as bitmasks
36
+ - [x] limit the amount of memory used when parsing large files
37
+ - [x] use node flags as bitmasks
38
+ - [x] merging properties now takes into consideration the !important flag
39
+
40
+ ```ts
41
+ import {transformSync} from '@tbela99/css-parser';
42
+
43
+ const options = {
44
+ input: `
45
+
46
+ button {
47
+ line-height: 2.5 !important;
48
+ line-height: 1.5;
49
+ }
50
+ `,
51
+ beautify: true,
52
+ };
53
+
54
+ const result = transformSync(options);
55
+ console.debug(result.code);
56
+ ```
57
+
58
+ result
59
+
60
+ ```css
61
+ button {
62
+ line-height: 2.5!important
63
+ }
64
+ ```
9
65
 
10
66
  ## Fixes
11
67
 
12
- - [x] fix powerless and missing components handling with color-mix(). missing and powerless colors are now [carried forwarded](https://drafts.csswg.org/css-color-5/#rcs-intro)
68
+ - [x] fix powerless and missing components handling with color-mix(). missing and powerless colors are now [carried forward](https://drafts.csswg.org/css-color-5/#rcs-intro)
13
69
 
14
70
  ```ts
15
71
  const css = `
@@ -33,7 +89,7 @@ const result = transformSync({input: css,
33
89
  removeDuplicateDeclarations: false,
34
90
  convertColor: ColorType.SRGB
35
91
  });
36
- // console.debug(result);
92
+
37
93
  console.debug(result.code);
38
94
  ```
39
95
 
@@ -1,3 +1,10 @@
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
1
8
  (function (global, factory) {
2
9
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
10
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -547,7 +554,7 @@
547
554
  /**
548
555
  * '|'
549
556
  */
550
- EnumToken[EnumToken["Pipe"] = 109] = "Pipe";
557
+ EnumToken[EnumToken["PipeTokenType"] = 109] = "PipeTokenType";
551
558
  /**
552
559
  * '::'
553
560
  */
@@ -686,6 +693,10 @@
686
693
  * negative infinity token
687
694
  */
688
695
  EnumToken[EnumToken["NegativeInfinityTokenType"] = 143] = "NegativeInfinityTokenType";
696
+ /**
697
+ * CSS type token
698
+ */
699
+ EnumToken[EnumToken["CssTypeTokenType"] = 144] = "CssTypeTokenType";
689
700
  /* aliases */
690
701
  /**
691
702
  * alias for time token type
@@ -12485,8 +12496,7 @@
12485
12496
  case MediaFeatureType.RatioType:
12486
12497
  return {
12487
12498
  valid: true,
12488
- success: (tokens.length == 1 &&
12489
- tokens[0].typ == exports.EnumToken.NumberTokenType) ||
12499
+ success: (tokens.length == 1 && tokens[0].typ == exports.EnumToken.NumberTokenType) ||
12490
12500
  (tokens.length === 3 &&
12491
12501
  tokens[0].typ == exports.EnumToken.NumberTokenType &&
12492
12502
  typeof tokens[0].val === "number" &&
@@ -12793,7 +12803,7 @@
12793
12803
  }
12794
12804
  stack.push(token);
12795
12805
  break;
12796
- case exports.EnumToken.Pipe:
12806
+ case exports.EnumToken.PipeTokenType:
12797
12807
  case exports.EnumToken.DelimTokenType:
12798
12808
  case exports.EnumToken.StringTokenType:
12799
12809
  case exports.EnumToken.IncludeMatchTokenType:
@@ -12841,10 +12851,10 @@
12841
12851
  }
12842
12852
  slice.push(tokens[n]);
12843
12853
  }
12844
- if (slice[1]?.typ === exports.EnumToken.Pipe) {
12854
+ if (slice[1]?.typ === exports.EnumToken.PipeTokenType) {
12845
12855
  slice.shift();
12846
12856
  }
12847
- if (slice[0].typ === exports.EnumToken.Pipe) {
12857
+ if (slice[0].typ === exports.EnumToken.PipeTokenType) {
12848
12858
  slice.shift();
12849
12859
  }
12850
12860
  if (slice.length === 1) {
@@ -13206,8 +13216,8 @@
13206
13216
  // custom function token
13207
13217
  if (token.typ === exports.EnumToken.CustomFunctionTokenDefType) {
13208
13218
  if (syntaxes[i].typ != ValidationTokenEnum.PropertyType ||
13209
- syntaxes[i + 1].typ != ValidationTokenEnum.OpenParenthesis ||
13210
- syntaxes[i + 2].typ == null) {
13219
+ syntaxes[i + 1]?.typ != ValidationTokenEnum.OpenParenthesis ||
13220
+ syntaxes[i + 2]?.typ == null) {
13211
13221
  if (!isOptional) {
13212
13222
  return {
13213
13223
  success: false,
@@ -14054,17 +14064,15 @@
14054
14064
  case "display-internal":
14055
14065
  case "display-outside":
14056
14066
  case "display-legacy":
14057
- case "content-position":
14058
- {
14059
- let values = propertyKeywordValues.get(property.val);
14060
- if (values == null) {
14061
- values = new Set(config$3.syntaxes[property.val].syntax.split(/[\s|]+/));
14062
- propertyKeywordValues.set(property.val, values);
14063
- }
14064
- success =
14065
- token?.typ == exports.EnumToken.IdenTokenType && values.has(token.val.toLowerCase());
14066
- break;
14067
+ case "content-position": {
14068
+ let values = propertyKeywordValues.get(property.val);
14069
+ if (values == null) {
14070
+ values = new Set(config$3.syntaxes[property.val].syntax.split(/[\s|]+/));
14071
+ propertyKeywordValues.set(property.val, values);
14067
14072
  }
14073
+ success = token?.typ == exports.EnumToken.IdenTokenType && values.has(token.val.toLowerCase());
14074
+ break;
14075
+ }
14068
14076
  case "mf-name":
14069
14077
  {
14070
14078
  const token = context.peek();
@@ -14084,8 +14092,7 @@
14084
14092
  case "custom-ident":
14085
14093
  case "counter-name":
14086
14094
  case "counter-style-name":
14087
- success =
14088
- token?.typ == exports.EnumToken.IdenTokenType || token?.typ == exports.EnumToken.DashedIdenTokenType;
14095
+ success = token?.typ == exports.EnumToken.IdenTokenType || token?.typ == exports.EnumToken.DashedIdenTokenType;
14089
14096
  if (success && token?.typ === exports.EnumToken.IdenTokenType) {
14090
14097
  const val = token.val.toLowerCase();
14091
14098
  success = "none" !== val && !allValues.includes(val);
@@ -14556,6 +14563,21 @@
14556
14563
  }
14557
14564
  break;
14558
14565
  }
14566
+ case "css-type": {
14567
+ success = context.peek()?.typ == exports.EnumToken.CssTypeTokenType;
14568
+ if (success) {
14569
+ context.next();
14570
+ return {
14571
+ success: true,
14572
+ valid: true,
14573
+ token: null,
14574
+ context,
14575
+ syntaxToken: null,
14576
+ errors: [],
14577
+ };
14578
+ }
14579
+ break;
14580
+ }
14559
14581
  default:
14560
14582
  if (!(property.val in config$3.syntaxes)) {
14561
14583
  console.debug("Unknown syntax", context.peek(), property);
@@ -21132,12 +21154,15 @@
21132
21154
  exports.EnumToken.LtTokenType,
21133
21155
  exports.EnumToken.LteTokenType,
21134
21156
  exports.EnumToken.ChildCombinatorTokenType,
21157
+ exports.EnumToken.PipeTokenType,
21135
21158
  ]);
21136
21159
  const trimSpaceAfter = new Set([
21137
21160
  ...tokensfuncSet.values(),
21138
21161
  exports.EnumToken.ChildCombinatorTokenType,
21139
21162
  exports.EnumToken.SupportsQueryConditionTokenType,
21140
21163
  exports.EnumToken.SupportsQueryUnaryConditionTokenType,
21164
+ exports.EnumToken.CommaTokenType,
21165
+ exports.EnumToken.PipeTokenType,
21141
21166
  ]);
21142
21167
  /**
21143
21168
  * Replace token in its parent node
@@ -21207,17 +21232,18 @@
21207
21232
  return tokens;
21208
21233
  }
21209
21234
  for (; i < tokens.length; i++) {
21210
- if (trimSpaceAfter.has(tokens[i].typ) && tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
21211
- tokens.splice(i + 1, 1);
21212
- }
21213
- else if (trimTokenSpace.has(tokens[i].typ)) {
21235
+ if (trimTokenSpace.has(tokens[i].typ)) {
21214
21236
  if (tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
21215
21237
  tokens.splice(i + 1, 1);
21216
21238
  }
21217
21239
  if (i > 0 && tokens[i - 1].typ === exports.EnumToken.Whitespace) {
21218
21240
  tokens.splice(--i, 1);
21241
+ continue;
21219
21242
  }
21220
21243
  }
21244
+ if (trimSpaceAfter.has(tokens[i].typ) && tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
21245
+ tokens.splice(i + 1, 1);
21246
+ }
21221
21247
  }
21222
21248
  return tokens;
21223
21249
  }
@@ -26667,7 +26693,7 @@
26667
26693
  return ",";
26668
26694
  case exports.EnumToken.ImportantTokenType:
26669
26695
  return "!important";
26670
- case exports.EnumToken.Pipe:
26696
+ case exports.EnumToken.PipeTokenType:
26671
26697
  return "|";
26672
26698
  case exports.EnumToken.AttrTokenType:
26673
26699
  case exports.EnumToken.IdenListTokenType:
@@ -26790,6 +26816,7 @@
26790
26816
  pseudoElements.includes(token.val.slice(1))) {
26791
26817
  return token.val.slice(1);
26792
26818
  }
26819
+ case exports.EnumToken.CssTypeTokenType:
26793
26820
  case exports.EnumToken.UrlTokenTokenType:
26794
26821
  case exports.EnumToken.HashTokenType:
26795
26822
  case exports.EnumToken.IdenTokenType:
@@ -26943,7 +26970,7 @@
26943
26970
  SymbolsMapTokens[""] = exports.EnumToken.DelimTokenType;
26944
26971
  SymbolsMapTokens["+"] = exports.EnumToken.Plus;
26945
26972
  SymbolsMapTokens["="] = exports.EnumToken.DelimTokenType;
26946
- SymbolsMapTokens["|"] = exports.EnumToken.Pipe;
26973
+ SymbolsMapTokens["|"] = exports.EnumToken.PipeTokenType;
26947
26974
  SymbolsMapTokens["||"] = exports.EnumToken.ColumnCombinatorTokenType;
26948
26975
  SymbolsMapTokens["|="] = exports.EnumToken.DashMatchTokenType;
26949
26976
  SymbolsMapTokens["&"] = exports.EnumToken.NestingSelectorTokenType;
@@ -27602,7 +27629,6 @@
27602
27629
  if (codepoint == 92 /* TokenMap.REVERSE_SOLIDUS */) {
27603
27630
  // eof
27604
27631
  if ((codepoint = parseInfo.stream.charCodeAt(position + 1)) != codepoint) {
27605
- // this.next(parseInfo, position);
27606
27632
  return 0;
27607
27633
  }
27608
27634
  // \n \r \f \v
@@ -28375,7 +28401,7 @@
28375
28401
  return this.makeToken(parseInfo, exports.EnumToken.DashMatchTokenType);
28376
28402
  }
28377
28403
  this.advance(parseInfo);
28378
- return this.makeToken(parseInfo, exports.EnumToken.Pipe);
28404
+ return this.makeToken(parseInfo, exports.EnumToken.PipeTokenType);
28379
28405
  case 33 /* TokenMap.EXCLAMATION */:
28380
28406
  if (parseInfo.position < parseInfo.currentPosition) {
28381
28407
  return this.makeToken(parseInfo);
@@ -28441,6 +28467,21 @@
28441
28467
  return this.makeToken(parseInfo, exports.EnumToken.CDOCOMMTokenType);
28442
28468
  }
28443
28469
  }
28470
+ {
28471
+ const startPosition = parseInfo.position - parseInfo.offset;
28472
+ let offset = 1;
28473
+ let charCode = parseInfo.stream.charCodeAt(startPosition + offset);
28474
+ if (isLetter(charCode)) {
28475
+ charCode = parseInfo.stream.charCodeAt(++offset + startPosition);
28476
+ while (offset < endPosition && (charCode == 45 /* TokenMap.MINUS */ || isLetter(charCode))) {
28477
+ charCode = parseInfo.stream.charCodeAt(++offset + startPosition);
28478
+ }
28479
+ if (offset > 1 && charCode == 62 /* TokenMap.GREATERTHAN */) {
28480
+ this.advance(parseInfo, offset);
28481
+ return this.makeToken(parseInfo, exports.EnumToken.CssTypeTokenType);
28482
+ }
28483
+ }
28484
+ }
28444
28485
  break;
28445
28486
  case 35 /* TokenMap.HASH */:
28446
28487
  if (parseInfo.position < parseInfo.currentPosition) {
@@ -31170,6 +31211,9 @@
31170
31211
  let key;
31171
31212
  let value;
31172
31213
  let i;
31214
+ const allVisitorsHandlers = new Set();
31215
+ const preAllVisitorsHandlers = new Set();
31216
+ const postAllVisitorsHandlers = new Set();
31173
31217
  const valuesHandlers = new Map();
31174
31218
  const preValuesHandlers = new Map();
31175
31219
  const postValuesHandlers = new Map();
@@ -31270,6 +31314,21 @@
31270
31314
  errors.push({ action: "ignore", message: `doParse: visitor.${key} is not a valid key name` });
31271
31315
  }
31272
31316
  }
31317
+ else if (key == "All" || key == "visitor") {
31318
+ if (typeof value == "function") {
31319
+ allVisitorsHandlers.add(value);
31320
+ }
31321
+ else if (typeof value == "object") {
31322
+ if ("type" in value && "handler" in value && value.type in exports.WalkerEvent) {
31323
+ if (value.type == exports.WalkerEvent.Enter) {
31324
+ preAllVisitorsHandlers.add(value.handler);
31325
+ }
31326
+ else if (value.type == exports.WalkerEvent.Leave) {
31327
+ postAllVisitorsHandlers.add(value.handler);
31328
+ }
31329
+ }
31330
+ }
31331
+ }
31273
31332
  else {
31274
31333
  errors.push({ action: "ignore", message: `doParse: visitor.${key} is not a valid key name` });
31275
31334
  }
@@ -31293,10 +31352,25 @@
31293
31352
  if (postValuesHandlers.size > 0) {
31294
31353
  allHandlers.push(postValuesHandlers);
31295
31354
  }
31296
- return {
31355
+ const result = {
31297
31356
  allHandlers,
31298
- includeTokens: preValuesHandlers.size > 0 || valuesHandlers.size > 0 || postValuesHandlers.size > 0,
31357
+ includeTokens: preValuesHandlers.size > 0 ||
31358
+ valuesHandlers.size > 0 ||
31359
+ postValuesHandlers.size > 0 ||
31360
+ allVisitorsHandlers.size > 0 ||
31361
+ preAllVisitorsHandlers.size > 0 ||
31362
+ postAllVisitorsHandlers.size > 0,
31299
31363
  };
31364
+ if (allVisitorsHandlers.size > 0) {
31365
+ result.allVisitorsHandlers = allVisitorsHandlers;
31366
+ }
31367
+ if (preAllVisitorsHandlers.size > 0) {
31368
+ result.preAllVisitorsHandlers = preAllVisitorsHandlers;
31369
+ }
31370
+ if (postAllVisitorsHandlers.size > 0) {
31371
+ result.postAllVisitorsHandlers = postAllVisitorsHandlers;
31372
+ }
31373
+ return result;
31300
31374
  }
31301
31375
  /**
31302
31376
  * Parse css string
@@ -31369,12 +31443,10 @@
31369
31443
  // @ts-ignore ignore error
31370
31444
  let parensMatch = 0;
31371
31445
  let curlyBracketMatch = 0;
31372
- // let currentItemIndex: number;
31373
31446
  ast[LOCSRCID] = options.source.id;
31374
31447
  ast[LOCSTA] = 0;
31375
31448
  while (!tokenizer.done()) {
31376
31449
  tokenizer.next();
31377
- // item = (iter as Array<TokenizeResult>)[currentItemIndex];
31378
31450
  if (tokenizer.unit != null) {
31379
31451
  item = {
31380
31452
  typ: tokenizer.typ,
@@ -31520,7 +31592,6 @@
31520
31592
  parensMatch = 0;
31521
31593
  curlyBracketMatch = 0;
31522
31594
  }
31523
- // }
31524
31595
  }
31525
31596
  if (tokens.length > 0) {
31526
31597
  node = parseNode(tokens, context, options, errors, stats, invalidNodes);
@@ -31590,6 +31661,9 @@
31590
31661
  }
31591
31662
  parens = null;
31592
31663
  handlers.length = 0;
31664
+ if (visitors.preAllVisitorsHandlers?.size > 0) {
31665
+ handlers.push(...visitors.preAllVisitorsHandlers);
31666
+ }
31593
31667
  genericKey =
31594
31668
  nodes[i].typ == exports.EnumToken.DeclarationNodeType
31595
31669
  ? "Declaration"
@@ -31609,6 +31683,9 @@
31609
31683
  : nodes[i].typ == exports.EnumToken.KeyframesAtRuleNodeType
31610
31684
  ? camelize(nodes[i].val)
31611
31685
  : null;
31686
+ if (visitors.allVisitorsHandlers?.size > 0) {
31687
+ handlers.push(...visitors.allVisitorsHandlers);
31688
+ }
31612
31689
  for (const map of visitors.allHandlers) {
31613
31690
  // @ts-ignore
31614
31691
  if (genericKey != null && map.has(genericKey)) {
@@ -31617,20 +31694,6 @@
31617
31694
  if (typeof handler == "function") {
31618
31695
  handlers.push(handler);
31619
31696
  }
31620
- // else if (Array.isArray(handler)) {
31621
- // for (const h of handler) {
31622
- // if (typeof h == "function") {
31623
- // handlers.push(h);
31624
- // }
31625
- // // @ts-ignore
31626
- // else if (h[keyName] != null) {
31627
- // // @ts-ignore
31628
- // handlers.push(h[keyName]);
31629
- // }
31630
- // }
31631
- // } else if (typeof handler.handler! == "function") {
31632
- // handlers.push(handler.handler);
31633
- // }
31634
31697
  // @ts-ignore
31635
31698
  else if (typeof handler[keyName] == "function") {
31636
31699
  // @ts-ignore
@@ -31663,6 +31726,9 @@
31663
31726
  }
31664
31727
  }
31665
31728
  }
31729
+ if (visitors.postAllVisitorsHandlers?.size > 0) {
31730
+ handlers.push(...visitors.postAllVisitorsHandlers);
31731
+ }
31666
31732
  if (handlers.length == 0) {
31667
31733
  continue;
31668
31734
  }
@@ -32582,6 +32648,9 @@
32582
32648
  }
32583
32649
  parens = null;
32584
32650
  handlers.length = 0;
32651
+ if (visitors.preAllVisitorsHandlers?.size > 0) {
32652
+ handlers.push(...visitors.preAllVisitorsHandlers);
32653
+ }
32585
32654
  genericKey =
32586
32655
  nodes[i].typ == exports.EnumToken.DeclarationNodeType
32587
32656
  ? "Declaration"
@@ -32601,6 +32670,9 @@
32601
32670
  : nodes[i].typ == exports.EnumToken.KeyframesAtRuleNodeType
32602
32671
  ? camelize(nodes[i].val)
32603
32672
  : null;
32673
+ if (visitors.allVisitorsHandlers?.size > 0) {
32674
+ handlers.push(...visitors.allVisitorsHandlers);
32675
+ }
32604
32676
  for (const map of visitors.allHandlers) {
32605
32677
  // @ts-ignore
32606
32678
  if (genericKey != null && map.has(genericKey)) {
@@ -32655,6 +32727,9 @@
32655
32727
  }
32656
32728
  }
32657
32729
  }
32730
+ if (visitors.postAllVisitorsHandlers?.size > 0) {
32731
+ handlers.push(...visitors.postAllVisitorsHandlers);
32732
+ }
32658
32733
  if (handlers.length == 0) {
32659
32734
  continue;
32660
32735
  }
@@ -33515,7 +33590,6 @@
33515
33590
  const syntax = syntaxRules?.getPreludeRules()?.slice?.(1);
33516
33591
  const blockAllowed = syntaxRules?.getBlockRules() != null;
33517
33592
  if (syntaxRules == null) {
33518
- // if (!options.lenient) {
33519
33593
  errors.push({
33520
33594
  action: "drop",
33521
33595
  node: atRule,
@@ -34232,7 +34306,7 @@
34232
34306
  stream[index][LOCEND] = stream[i][LOCEND];
34233
34307
  Object.assign(stream[index], {
34234
34308
  typ: tokensfuncDefMap.get(stream[index].typ),
34235
- chi: stream.splice(index + 1, i - index - 1),
34309
+ chi: trimWhiteSpaceTokens(stream.splice(index + 1, i - index - 1)),
34236
34310
  });
34237
34311
  i = index;
34238
34312
  stream.splice(index + 1, 1);
@@ -34704,6 +34778,8 @@
34704
34778
  }
34705
34779
  }
34706
34780
 
34781
+ var version = "1.6.8";
34782
+
34707
34783
  /**
34708
34784
  * Load file or url
34709
34785
  * @param url
@@ -35137,6 +35213,7 @@
35137
35213
  exports.transform = transform;
35138
35214
  exports.transformFile = transformFile;
35139
35215
  exports.transformSync = transformSync;
35216
+ exports.version = version;
35140
35217
  exports.walk = walk;
35141
35218
  exports.walkValues = walkValues;
35142
35219