@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.
Files changed (46) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +112 -8
  3. package/dist/{lib/data → data}/properties.json.js +296 -29
  4. package/dist/{lib/data → data}/validation.json.js +6 -0
  5. package/dist/index-umd-web.js +962 -744
  6. package/dist/index.cjs +961 -744
  7. package/dist/index.d.ts +24 -6
  8. package/dist/lib/ast/expand.js +1 -1
  9. package/dist/lib/ast/features/calc.js +16 -4
  10. package/dist/lib/ast/features/if.js +2 -2
  11. package/dist/lib/ast/features/inlinecssvariables.js +3 -3
  12. package/dist/lib/ast/features/prefix.js +2 -2
  13. package/dist/lib/ast/features/shorthand.js +8 -6
  14. package/dist/lib/ast/features/transform.js +2 -2
  15. package/dist/lib/ast/math/expression.js +24 -1
  16. package/dist/lib/ast/minify.js +3 -2
  17. package/dist/lib/ast/transform/utils.js +2 -2
  18. package/dist/lib/ast/walk.js +108 -90
  19. package/dist/lib/parser/declaration/list.js +29 -26
  20. package/dist/lib/parser/declaration/map.js +186 -54
  21. package/dist/lib/parser/parse.js +11 -9
  22. package/dist/lib/parser/source.js +2 -2
  23. package/dist/lib/parser/tokenize.js +99 -124
  24. package/dist/lib/parser/utils/config.js +1 -1
  25. package/dist/lib/parser/utils/declaration.js +0 -18
  26. package/dist/lib/parser/utils/hash.js +10 -5
  27. package/dist/lib/parser/utils/selector.js +1 -1
  28. package/dist/lib/{renderer → printer}/render.js +29 -53
  29. package/dist/lib/syntax/color/a98rgb.js +1 -1
  30. package/dist/lib/syntax/color/alpha.js +19 -20
  31. package/dist/lib/syntax/color/color-mix.js +15 -14
  32. package/dist/lib/syntax/color/hex.js +4 -1
  33. package/dist/lib/syntax/color/lch.js +0 -1
  34. package/dist/lib/syntax/color/oklch.js +0 -1
  35. package/dist/lib/syntax/color/relative-color.js +11 -11
  36. package/dist/lib/syntax/color/utils/components.js +0 -20
  37. package/dist/lib/syntax/color/xyzd50.js +0 -17
  38. package/dist/lib/syntax/constants.js +6 -1
  39. package/dist/lib/syntax/syntax.js +2 -2
  40. package/dist/lib/validation/config.js +5 -33
  41. package/dist/lib/validation/match.js +52 -181
  42. package/dist/node.js +3 -3
  43. package/dist/web.js +4 -3
  44. package/package.json +6 -5
  45. /package/dist/lib/{renderer → printer}/sourcemap/lib/codec.js +0 -0
  46. /package/dist/lib/{renderer → printer}/sourcemap/sourcemap.js +0 -0
package/dist/index.cjs CHANGED
@@ -2577,6 +2577,9 @@ var declarations = {
2577
2577
  scale: {
2578
2578
  syntax: "none | [ <number> | <percentage> ]{1,3}"
2579
2579
  },
2580
+ "scroll-axis-lock": {
2581
+ syntax: "auto | none"
2582
+ },
2580
2583
  "scroll-behavior": {
2581
2584
  syntax: "auto | smooth"
2582
2585
  },
@@ -2982,6 +2985,9 @@ var declarations = {
2982
2985
  "will-change": {
2983
2986
  syntax: "auto | <animateable-feature>#"
2984
2987
  },
2988
+ "window-drag": {
2989
+ syntax: "none | move"
2990
+ },
2985
2991
  "word-break": {
2986
2992
  syntax: "normal | break-all | keep-all | break-word | auto-phrase"
2987
2993
  },
@@ -6426,6 +6432,11 @@ const anglePrecision = 3;
6426
6432
  * Color range definitions
6427
6433
  */
6428
6434
  const colorRange = {
6435
+ rgb: {
6436
+ r: [0, 255],
6437
+ g: [0, 255],
6438
+ b: [0, 255],
6439
+ },
6429
6440
  lab: {
6430
6441
  l: [0, 100],
6431
6442
  a: [-125, 125],
@@ -6895,13 +6906,6 @@ function equalsIgnoreCase(a, b) {
6895
6906
  }
6896
6907
 
6897
6908
  function getColorComponents(token) {
6898
- // if (token.typ === EnumToken.IdenTokenType) {
6899
- // if (isColor(token)) {
6900
- // parseColor(token);
6901
- // } else {
6902
- // return null;
6903
- // }
6904
- // }
6905
6909
  if (token.kin == exports.ColorType.HEX || token.kin == exports.ColorType.LIT) {
6906
6910
  if (equalsIgnoreCase("currentcolor", token.val)) {
6907
6911
  return null;
@@ -6925,25 +6929,12 @@ function getColorComponents(token) {
6925
6929
  ].includes(child.typ)) {
6926
6930
  continue;
6927
6931
  }
6928
- // if (child.typ === EnumToken.IdenTokenType && isColor(child)) {
6929
- // parseColor(child);
6930
- // }
6931
6932
  if (child.typ === exports.EnumToken.FunctionTokenType ||
6932
6933
  child.typ === exports.EnumToken.WildCardFunctionTokenType ||
6933
6934
  child.typ === exports.EnumToken.MathFunctionTokenType) {
6934
6935
  if ("var" == child.val.toLowerCase()) {
6935
6936
  return null;
6936
6937
  }
6937
- // else {
6938
- // for (const { value } of walkValues((child as FunctionToken).chi)) {
6939
- // if (
6940
- // value.typ == EnumToken.WildCardFunctionTokenDefType &&
6941
- // "var" === (value as FunctionToken).val.toLowerCase()
6942
- // ) {
6943
- // return null;
6944
- // }
6945
- // }
6946
- // }
6947
6938
  }
6948
6939
  if (child.typ == exports.EnumToken.ColorTokenType && equalsIgnoreCase("currentcolor", child.val)) {
6949
6940
  return null;
@@ -7053,7 +7044,6 @@ function color2lchToken(token) {
7053
7044
  return lchToken(values);
7054
7045
  }
7055
7046
  function lchToken(values) {
7056
- values[2] = values[2];
7057
7047
  const chi = [
7058
7048
  { typ: exports.EnumToken.NumberTokenType, val: values[0] },
7059
7049
  { typ: exports.EnumToken.NumberTokenType, val: values[1] },
@@ -7177,23 +7167,6 @@ function getLCHComponents(token) {
7177
7167
  return alpha == null ? [l, c, h] : [l, c, h, alpha];
7178
7168
  }
7179
7169
 
7180
- // export function srgb2xyzd50values(r: number, g: number, b: number, alpha: number | null = null): number[] {
7181
- // [r, g, b] = srgb2lsrgbvalues(r, g, b);
7182
- //
7183
- // const rgb: number[] = [
7184
- // 0.436065742824811 * r + 0.3851514688337912 * g + 0.14307845442264197 * b,
7185
- //
7186
- // 0.22249319175623702 * r + 0.7168870538238823 * g + 0.06061979053616537 * b,
7187
- //
7188
- // 0.013923904500943465 * r + 0.09708128566574634 * g + 0.7140993584005155 * b,
7189
- // ];
7190
- //
7191
- // if (alpha != null && alpha != 1) {
7192
- // rgb.push(alpha);
7193
- // }
7194
- //
7195
- // return rgb;
7196
- // }
7197
7170
  /*
7198
7171
  */
7199
7172
  function xyzd502lch(x, y, z, alpha) {
@@ -7340,7 +7313,6 @@ function color2oklchToken(token) {
7340
7313
  return oklchToken(srgb2oklch(values[0], values[1], values[2], values[3]));
7341
7314
  }
7342
7315
  function oklchToken(values) {
7343
- values[2] = values[2];
7344
7316
  const chi = [
7345
7317
  { typ: exports.EnumToken.NumberTokenType, val: values[0] },
7346
7318
  { typ: exports.EnumToken.NumberTokenType, val: values[1] },
@@ -8258,7 +8230,10 @@ function color2HexToken(token) {
8258
8230
  if (value == null) {
8259
8231
  return null;
8260
8232
  }
8261
- return hexToken(value.reduce((acc, curr) => acc + srgb2rgb(curr + Number.EPSILON).toString(16).padStart(2, "0"), "#"));
8233
+ return hexToken(value.reduce((acc, curr) => acc +
8234
+ srgb2rgb(curr + Number.EPSILON)
8235
+ .toString(16)
8236
+ .padStart(2, "0"), "#"));
8262
8237
  }
8263
8238
  function oklab2HexToken(token) {
8264
8239
  let value = oklab2srgbvalues(token);
@@ -9107,7 +9082,7 @@ function la98rgb2a98rgb(r, g, b, a = null) {
9107
9082
  // convert an array of linear-light a98-rgb in the range 0.0-1.0
9108
9083
  // to gamma corrected form
9109
9084
  // negative values are also now accepted
9110
- return [r, b, g]
9085
+ return [r, g, b]
9111
9086
  .map(function (val) {
9112
9087
  let sign = val < 0 ? -1 : 1;
9113
9088
  let abs = Math.abs(val);
@@ -9243,6 +9218,9 @@ function colorMix(...args) {
9243
9218
  if (values == null) {
9244
9219
  return null;
9245
9220
  }
9221
+ if (colorSpace == "hwb") {
9222
+ colorSpace = "srgb";
9223
+ }
9246
9224
  switch (colorSpace) {
9247
9225
  case "srgb":
9248
9226
  break;
@@ -9272,17 +9250,17 @@ function colorMix(...args) {
9272
9250
  values = srgb2xyz_d65(values[0], values[1], values[2], values[3]);
9273
9251
  values = XYZ_D65_to_D50(values[0], values[1], values[2], values[3]);
9274
9252
  break;
9275
- case "rgb":
9276
- for (let j = 0; j < values.length; j++) {
9277
- values[j] = j == 3 ? values[j] : srgb2rgb(values[j]);
9278
- }
9279
- break;
9253
+ // case "rgb":
9254
+ // for (let j = 0; j < values.length; j++) {
9255
+ // values[j] = j == 3 ? values[j] : srgb2rgb(values[j]);
9256
+ // }
9257
+ // break;
9280
9258
  case "hsl":
9281
9259
  values = srgb2hslvalues(values[0], values[1], values[2], values[3]);
9282
9260
  break;
9283
- case "hwb":
9284
- values = srgb2hwb(values[0], values[1], values[2], values[3]);
9285
- break;
9261
+ // case "hwb":
9262
+ // values = srgb2hwb(values[0], values[1], values[2], values[3]);
9263
+ // break;
9286
9264
  case "lab":
9287
9265
  values = srgb2labvalues(values[0], values[1], values[2], values[3]);
9288
9266
  break;
@@ -9481,14 +9459,14 @@ function colorMix(...args) {
9481
9459
  kin: exports.ColorType.COLOR,
9482
9460
  cal: "col",
9483
9461
  };
9484
- case "rgb":
9462
+ // case "rgb":
9485
9463
  case "hsl":
9486
- case "hwb":
9464
+ // case "hwb":
9487
9465
  case "lab":
9488
9466
  case "lch":
9489
9467
  case "oklab":
9490
9468
  case "oklch":
9491
- if (colorSpace == "hsl" || colorSpace == "hwb") {
9469
+ if (colorSpace == "hsl") {
9492
9470
  // @ts-ignore
9493
9471
  if (values[2] < 0) {
9494
9472
  // @ts-ignore
@@ -9518,7 +9496,7 @@ function colorMix(...args) {
9518
9496
  }),
9519
9497
  kin: exports.ColorType[colorSpace.toUpperCase().replaceAll("-", "_")],
9520
9498
  };
9521
- if (colorSpace == "hsl" || colorSpace == "hwb") {
9499
+ if (colorSpace == "hsl") {
9522
9500
  // @ts-ignore
9523
9501
  result.chi[0] = { typ: exports.EnumToken.AngleTokenType, val: result.chi[0].val * 360 };
9524
9502
  // @ts-ignore
@@ -9645,20 +9623,34 @@ exports.WalkerEvent = void 0;
9645
9623
  function* walk(node, filter, reverse) {
9646
9624
  const parents = [node];
9647
9625
  const root = node;
9648
- const map = new Map();
9649
9626
  let options = filter;
9650
9627
  let isNumeric = false;
9651
- let includeValues = false;
9628
+ let children = true;
9629
+ let attributes = false;
9652
9630
  let i = 0;
9653
9631
  if (options != null && typeof options == "object") {
9654
9632
  filter = options.filter;
9655
9633
  reverse = options.reverse;
9656
- includeValues = options.inludeValues;
9634
+ attributes = options.attributes;
9635
+ children = options.children ?? true;
9657
9636
  }
9637
+ // @ts-expect-error
9638
+ const result = {
9639
+ node: null,
9640
+ parent: null,
9641
+ root,
9642
+ parents: function* () {
9643
+ let parent = node[PARENT];
9644
+ while (parent != null) {
9645
+ yield parent;
9646
+ parent = parent[PARENT];
9647
+ }
9648
+ },
9649
+ };
9658
9650
  while ((node = parents[i++])) {
9659
9651
  let option = null;
9660
9652
  if (filter != null) {
9661
- // @ts-ignore
9653
+ // @ts-expect-error
9662
9654
  option = filter(node);
9663
9655
  isNumeric = typeof option == "number";
9664
9656
  if (isNumeric) {
@@ -9671,38 +9663,43 @@ function* walk(node, filter, reverse) {
9671
9663
  }
9672
9664
  }
9673
9665
  if (!isNumeric || (option & exports.WalkerOptionEnum.Children) === 0) {
9674
- // @ts-ignore
9675
- yield {
9676
- node,
9677
- parent: map.get(node),
9678
- root,
9679
- // @ts-expect-error
9680
- parents: function* () {
9681
- let parent = map.get(node);
9682
- while (parent != null) {
9683
- yield parent;
9684
- parent = map.get(parent);
9685
- }
9686
- },
9687
- };
9666
+ result.node = node;
9667
+ // @ts-expect-error
9668
+ result.parent = node[PARENT];
9669
+ yield result;
9688
9670
  }
9689
- if (includeValues) {
9671
+ if (attributes) {
9690
9672
  if (node[TOKENS] != null) {
9691
- // @ts-ignore
9673
+ // @ts-expect-error
9692
9674
  parents.splice(i, 0, ...(reverse ? node[TOKENS].toReversed() : node[TOKENS]));
9693
- // @ts-ignore
9675
+ for (const child of node[TOKENS]) {
9676
+ if (child[PARENT] != node) {
9677
+ child[PARENT] = node;
9678
+ }
9679
+ }
9680
+ // @ts-expect-error
9694
9681
  }
9695
9682
  else if (Array.isArray(node.val)) {
9696
- // @ts-ignore
9683
+ // @ts-expect-error
9684
+ for (const val of node.val) {
9685
+ if (val[PARENT] != node) {
9686
+ val[PARENT] = node;
9687
+ }
9688
+ }
9689
+ // @ts-expect-error
9697
9690
  parents.splice(i, 0, ...(reverse ? node.val.toReversed() : node.val));
9698
9691
  }
9699
9692
  }
9700
- // @ts-ignore
9701
- if (node["chi"] != null && (!isNumeric || (option & exports.WalkerOptionEnum.IgnoreChildren) === 0)) {
9702
- // @ts-ignore
9693
+ if (children &&
9694
+ // @ts-expect-error
9695
+ node["chi"] != null &&
9696
+ (!isNumeric || (option & exports.WalkerOptionEnum.IgnoreChildren) === 0)) {
9697
+ // @ts-expect-error
9703
9698
  parents.splice(i, 0, ...(reverse ? node.chi.toReversed() : node.chi));
9704
9699
  for (const child of node.chi) {
9705
- map.set(child, node);
9700
+ if (child[PARENT] != node) {
9701
+ child[PARENT] = node;
9702
+ }
9706
9703
  }
9707
9704
  }
9708
9705
  }
@@ -9756,8 +9753,6 @@ function* walk(node, filter, reverse) {
9756
9753
  */
9757
9754
  function* walkValues(values, root = null, filter, reverse) {
9758
9755
  const stack = values.slice();
9759
- const map = new Map();
9760
- const used = new Set();
9761
9756
  let previous = null;
9762
9757
  if (filter != null && typeof filter == "function") {
9763
9758
  filter = {
@@ -9774,31 +9769,43 @@ function* walkValues(values, root = null, filter, reverse) {
9774
9769
  let value;
9775
9770
  let option;
9776
9771
  let node;
9777
- // const parents: Token[] = [];
9772
+ let i = -1;
9778
9773
  const eventType = filter.event ?? exports.WalkerEvent.Enter;
9779
- while (stack.length > 0) {
9780
- value = reverse ? stack.pop() : stack.shift();
9774
+ // @ts-ignore
9775
+ const result = {
9776
+ value: null,
9777
+ parent: null,
9778
+ previousValue: null,
9779
+ nextValue: null,
9780
+ //
9781
+ root: root ?? null,
9782
+ parents: function* () {
9783
+ // @ts-ignore
9784
+ let result = root;
9785
+ while (result != null) {
9786
+ yield result;
9787
+ result = result[PARENT] ?? null;
9788
+ }
9789
+ },
9790
+ };
9791
+ while (++i < stack.length) {
9792
+ value = stack[i];
9781
9793
  option = null;
9782
- node = map.get(value) ?? null;
9783
- if (used.has(value)) {
9784
- continue;
9785
- }
9786
- used.add(value);
9787
9794
  if (filter.fn != null && eventType & exports.WalkerEvent.Enter) {
9788
9795
  const isValid = filter.type == null ||
9789
9796
  value.typ == filter.type ||
9790
9797
  (Array.isArray(filter.type) && filter.type.includes(value.typ)) ||
9791
9798
  (typeof filter.type == "function" && filter.type(value));
9792
9799
  if (isValid) {
9793
- // @ts-ignore
9794
- option = filter.fn(value, map.get(value) ?? root, exports.WalkerEvent.Enter,
9800
+ // @ts-expect-error
9801
+ option = filter.fn(value, value[PARENT] ?? root, exports.WalkerEvent.Enter,
9795
9802
  // @ts-expect-error
9796
9803
  function* () {
9797
9804
  // @ts-expect-error
9798
- let parent = map.get(node);
9805
+ let parent = node[PARENT];
9799
9806
  while (parent != null) {
9800
9807
  yield parent;
9801
- parent = map.get(parent);
9808
+ parent = parent[PARENT] ?? null;
9802
9809
  }
9803
9810
  });
9804
9811
  isNumeric = typeof option == "number";
@@ -9808,48 +9815,30 @@ function* walkValues(values, root = null, filter, reverse) {
9808
9815
  if (isNumeric && option & exports.WalkerOptionEnum.Ignore) {
9809
9816
  continue;
9810
9817
  }
9811
- // @ts-ignore
9818
+ //
9812
9819
  if (option != null && typeof option == "object" && ("typ" in option || Array.isArray(option))) {
9813
9820
  const op = Array.isArray(option) ? option : [option];
9821
+ stack.splice(i, 0, ...(reverse ? op.toReversed() : op));
9814
9822
  for (const o of op) {
9815
- map.set(o, map.get(value) ?? root);
9816
- if (reverse) {
9817
- stack.unshift(o);
9818
- }
9819
- else {
9820
- stack.push(o);
9823
+ if (o[PARENT] != value) {
9824
+ o[PARENT] = value;
9821
9825
  }
9822
9826
  }
9823
9827
  }
9824
9828
  }
9825
9829
  }
9826
- yield {
9827
- value,
9828
- parent: map.get(value) ?? root,
9829
- previousValue: previous,
9830
- nextValue: stack[0] ?? null,
9831
- // @ts-ignore
9832
- root: root ?? null,
9833
- // @ts-expect-error
9834
- parents: function* () {
9835
- // @ts-expect-error
9836
- let result = map.get(node) ?? root;
9837
- let next;
9838
- do {
9839
- yield result;
9840
- next = map.get(result) ?? root;
9841
- if (next == result) {
9842
- break;
9843
- }
9844
- result = next;
9845
- } while (result != null);
9846
- },
9847
- };
9830
+ result.value = value;
9831
+ result.parent = value[PARENT] ?? root;
9832
+ result.previousValue = previous;
9833
+ result.nextValue = stack[0] ?? null;
9834
+ yield result;
9848
9835
  if (!isNumeric || (option & exports.WalkerOptionEnum.IgnoreChildren) === 0) {
9849
9836
  if ("chi" in value) {
9850
9837
  const sliced = value.chi.slice();
9851
9838
  for (const child of sliced) {
9852
- map.set(child, value);
9839
+ if (child[PARENT] != value) {
9840
+ child[PARENT] = value;
9841
+ }
9853
9842
  if (reverse) {
9854
9843
  stack.unshift(child);
9855
9844
  }
@@ -9861,31 +9850,41 @@ function* walkValues(values, root = null, filter, reverse) {
9861
9850
  else {
9862
9851
  const values = [];
9863
9852
  if ("l" in value && value.l != null) {
9864
- // @ts-ignore
9853
+ // @ts-expect-error
9865
9854
  values.push(value.l);
9866
- // @ts-ignore
9867
- map.set(value.l, value);
9855
+ // @ts-expect-error
9856
+ if (value.l[PARENT] != value) {
9857
+ // @ts-expect-error
9858
+ value.l[PARENT] = value;
9859
+ }
9868
9860
  }
9869
9861
  if ("op" in value && typeof value.op == "object") {
9870
- // @ts-ignore
9862
+ // @ts-expect-error
9871
9863
  values.push(value.op);
9872
- // @ts-ignore
9873
- map.set(value.op, value);
9864
+ // @ts-expect-error
9865
+ if (value.op[PARENT] != value) {
9866
+ // @ts-expect-error
9867
+ value.op[PARENT] = value;
9868
+ }
9874
9869
  }
9875
9870
  if ("r" in value && value.r != null) {
9876
9871
  if (Array.isArray(value.r)) {
9877
9872
  for (const r of value.r) {
9878
- // @ts-ignore
9873
+ //
9879
9874
  values.push(r);
9880
- // @ts-ignore
9881
- map.set(r, value);
9875
+ if (r[PARENT] != value) {
9876
+ //
9877
+ r[PARENT] = value;
9878
+ }
9882
9879
  }
9883
9880
  }
9884
9881
  else {
9885
- // @ts-ignore
9882
+ //
9886
9883
  values.push(value.r);
9887
- // @ts-ignore
9888
- map.set(value.r, value);
9884
+ if (value.r[PARENT] != value) {
9885
+ //
9886
+ value.r[PARENT] = value;
9887
+ }
9889
9888
  }
9890
9889
  }
9891
9890
  if (values.length > 0) {
@@ -9907,17 +9906,14 @@ function* walkValues(values, root = null, filter, reverse) {
9907
9906
  (typeof filter.type == "function" && filter.type(value));
9908
9907
  if (isValid) {
9909
9908
  // @ts-ignore
9910
- option = filter.fn(value, map.get(value), exports.WalkerEvent.Leave);
9909
+ option = filter.fn(value, value[PARENT], exports.WalkerEvent.Leave);
9911
9910
  // @ts-ignore
9912
9911
  if (option != null && ("typ" in option || Array.isArray(option))) {
9913
9912
  const op = Array.isArray(option) ? option : [option];
9913
+ stack.splice(i, 0, ...(reverse ? op.toReversed() : op));
9914
9914
  for (const o of op) {
9915
- map.set(o, map.get(value) ?? root);
9916
- if (reverse) {
9917
- stack.unshift(o);
9918
- }
9919
- else {
9920
- stack.push(o);
9915
+ if (o[PARENT] != value) {
9916
+ o[PARENT] = value;
9921
9917
  }
9922
9918
  }
9923
9919
  }
@@ -10095,6 +10091,7 @@ function evaluate(tokens) {
10095
10091
  [LOCSRCID]: nodes[0][LOCSRCID],
10096
10092
  [LOCSTA]: nodes[0][LOCSTA],
10097
10093
  [LOCEND]: nodes[0][LOCEND],
10094
+ [PARENT]: nodes[0][PARENT],
10098
10095
  },
10099
10096
  ];
10100
10097
  }
@@ -10117,6 +10114,7 @@ function evaluate(tokens) {
10117
10114
  [LOCSRCID]: nodes[i][LOCSRCID],
10118
10115
  [LOCSTA]: nodes[i][LOCSTA],
10119
10116
  [LOCEND]: nodes[i + 1][LOCEND],
10117
+ [PARENT]: nodes[i + 1][PARENT],
10120
10118
  };
10121
10119
  }
10122
10120
  else {
@@ -10126,6 +10124,7 @@ function evaluate(tokens) {
10126
10124
  [LOCSRCID]: nodes[i + 1][LOCSRCID],
10127
10125
  [LOCSTA]: nodes[i + 1][LOCSTA],
10128
10126
  [LOCEND]: nodes[i + 1][LOCEND],
10127
+ [PARENT]: nodes[i + 1][PARENT],
10129
10128
  }, exports.EnumToken.Mul);
10130
10129
  }
10131
10130
  i++;
@@ -10146,12 +10145,14 @@ function evaluate(tokens) {
10146
10145
  [LOCSRCID]: token[LOCSRCID],
10147
10146
  [LOCSTA]: token[LOCSTA],
10148
10147
  [LOCEND]: token[LOCEND],
10148
+ [PARENT]: token[PARENT],
10149
10149
  }, {
10150
10150
  ...token,
10151
10151
  val: -token.val,
10152
10152
  [LOCSRCID]: token[LOCSRCID],
10153
10153
  [LOCSTA]: token[LOCSTA],
10154
10154
  [LOCEND]: token[LOCEND],
10155
+ [PARENT]: token[PARENT],
10155
10156
  });
10156
10157
  return acc;
10157
10158
  }
@@ -10162,6 +10163,7 @@ function evaluate(tokens) {
10162
10163
  [LOCSRCID]: token[LOCSRCID],
10163
10164
  [LOCSTA]: token[LOCSTA],
10164
10165
  [LOCEND]: token[LOCEND],
10166
+ [PARENT]: token[PARENT],
10165
10167
  });
10166
10168
  }
10167
10169
  acc.push(token);
@@ -10183,6 +10185,7 @@ function doEvaluate(l, r, op) {
10183
10185
  [LOCSRCID]: l[LOCSRCID],
10184
10186
  [LOCSTA]: l[LOCSTA],
10185
10187
  [LOCEND]: r?.[LOCEND] ?? l[LOCEND],
10188
+ [PARENT]: l[PARENT],
10186
10189
  };
10187
10190
  if (!isScalarToken(l) || !isScalarToken(r) || (l.typ == r.typ && "unit" in l && "unit" in r && l.unit != r.unit)) {
10188
10191
  return defaultReturn;
@@ -10255,6 +10258,7 @@ function doEvaluate(l, r, op) {
10255
10258
  [LOCSRCID]: l[LOCSRCID],
10256
10259
  [LOCSTA]: l[LOCSTA],
10257
10260
  [LOCEND]: l[LOCEND],
10261
+ [PARENT]: l[PARENT],
10258
10262
  },
10259
10263
  r: {
10260
10264
  typ: exports.EnumToken.NumberTokenType,
@@ -10262,6 +10266,7 @@ function doEvaluate(l, r, op) {
10262
10266
  [LOCSRCID]: r[LOCSRCID],
10263
10267
  [LOCSTA]: r[LOCSTA],
10264
10268
  [LOCEND]: r[LOCEND],
10269
+ [PARENT]: r[PARENT],
10265
10270
  },
10266
10271
  };
10267
10272
  }
@@ -10274,6 +10279,7 @@ function doEvaluate(l, r, op) {
10274
10279
  [LOCSRCID]: l[LOCSRCID],
10275
10280
  [LOCSTA]: l[LOCSTA],
10276
10281
  [LOCEND]: l[LOCEND],
10282
+ [PARENT]: l[PARENT],
10277
10283
  },
10278
10284
  r: {
10279
10285
  typ: exports.EnumToken.NumberTokenType,
@@ -10281,6 +10287,7 @@ function doEvaluate(l, r, op) {
10281
10287
  [LOCSRCID]: r[LOCSRCID],
10282
10288
  [LOCSTA]: r[LOCSTA],
10283
10289
  [LOCEND]: r[LOCEND],
10290
+ [PARENT]: r[PARENT],
10284
10291
  },
10285
10292
  };
10286
10293
  }
@@ -10307,6 +10314,7 @@ function doEvaluate(l, r, op) {
10307
10314
  [LOCSRCID]: l[LOCSRCID],
10308
10315
  [LOCSTA]: l[LOCSTA],
10309
10316
  [LOCEND]: r?.[LOCEND] ?? l[LOCEND],
10317
+ [PARENT]: l[PARENT],
10310
10318
  };
10311
10319
  if (token.typ == exports.EnumToken.IdenTokenType) {
10312
10320
  // @ts-ignore
@@ -10487,6 +10495,7 @@ function evaluateFunc(token) {
10487
10495
  [LOCSRCID]: value[0][LOCSRCID],
10488
10496
  [LOCSTA]: value[0][LOCSTA],
10489
10497
  [LOCEND]: value[0][LOCEND],
10498
+ [PARENT]: value[0][PARENT],
10490
10499
  }
10491
10500
  : {
10492
10501
  typ: token.val == "sign" ? exports.EnumToken.NumberTokenType : value[0].typ,
@@ -10494,6 +10503,7 @@ function evaluateFunc(token) {
10494
10503
  [LOCSRCID]: value[0][LOCSRCID],
10495
10504
  [LOCSTA]: value[0][LOCSTA],
10496
10505
  [LOCEND]: value[0][LOCEND],
10506
+ [PARENT]: value[0][PARENT],
10497
10507
  },
10498
10508
  ];
10499
10509
  }
@@ -10516,6 +10526,7 @@ function evaluateFunc(token) {
10516
10526
  [LOCSRCID]: token[LOCSRCID],
10517
10527
  [LOCSTA]: token[LOCSTA],
10518
10528
  [LOCEND]: token[LOCEND],
10529
+ [PARENT]: token[PARENT],
10519
10530
  },
10520
10531
  ];
10521
10532
  }
@@ -10589,6 +10600,7 @@ function evaluateFunc(token) {
10589
10600
  [LOCSRCID]: token[LOCSRCID],
10590
10601
  [LOCSTA]: token[LOCSTA],
10591
10602
  [LOCEND]: token[LOCEND],
10603
+ [PARENT]: token[PARENT],
10592
10604
  },
10593
10605
  ];
10594
10606
  }
@@ -10603,6 +10615,7 @@ function evaluateFunc(token) {
10603
10615
  [LOCSRCID]: token[LOCSRCID],
10604
10616
  [LOCSTA]: token[LOCSTA],
10605
10617
  [LOCEND]: token[LOCEND],
10618
+ [PARENT]: token[PARENT],
10606
10619
  },
10607
10620
  ];
10608
10621
  }
@@ -10613,6 +10626,7 @@ function evaluateFunc(token) {
10613
10626
  [LOCSRCID]: token[LOCSRCID],
10614
10627
  [LOCSTA]: token[LOCSTA],
10615
10628
  [LOCEND]: token[LOCEND],
10629
+ [PARENT]: token[PARENT],
10616
10630
  },
10617
10631
  ];
10618
10632
  }
@@ -10652,6 +10666,7 @@ function evaluateFunc(token) {
10652
10666
  [LOCSRCID]: token[LOCSRCID],
10653
10667
  [LOCSTA]: token[LOCSTA],
10654
10668
  [LOCEND]: token[LOCEND],
10669
+ [PARENT]: token[PARENT],
10655
10670
  },
10656
10671
  ];
10657
10672
  }
@@ -10694,6 +10709,7 @@ function evaluateFunc(token) {
10694
10709
  [LOCSRCID]: token[LOCSRCID],
10695
10710
  [LOCSTA]: token[LOCSTA],
10696
10711
  [LOCEND]: token[LOCEND],
10712
+ [PARENT]: token[PARENT],
10697
10713
  },
10698
10714
  ];
10699
10715
  }
@@ -10721,6 +10737,7 @@ function inlineExpression$1(token) {
10721
10737
  [LOCSRCID]: token[LOCSRCID],
10722
10738
  [LOCSTA]: token[LOCSTA],
10723
10739
  [LOCEND]: token[LOCEND],
10740
+ [PARENT]: token[PARENT],
10724
10741
  });
10725
10742
  for (const child of inlineExpression$1(token.r)) {
10726
10743
  result.push(child);
@@ -10800,6 +10817,7 @@ function factorToken(token) {
10800
10817
  [LOCSRCID]: token[LOCSRCID],
10801
10818
  [LOCSTA]: token[LOCSTA],
10802
10819
  [LOCEND]: token[LOCEND],
10820
+ [PARENT]: token[PARENT],
10803
10821
  };
10804
10822
  // @ts-ignore
10805
10823
  delete token.val;
@@ -10841,6 +10859,7 @@ function factor(tokens, ops) {
10841
10859
  [LOCSRCID]: tokens[i - 1][LOCSRCID],
10842
10860
  [LOCSTA]: tokens[i - 1][LOCSTA],
10843
10861
  [LOCEND]: tokens[i + 1][LOCEND],
10862
+ [PARENT]: tokens[i + 1][PARENT],
10844
10863
  });
10845
10864
  i--;
10846
10865
  }
@@ -10886,20 +10905,20 @@ function parseRelativeColorComponents(relativeKeys, original, rExp, gExp, bExp,
10886
10905
  continue;
10887
10906
  }
10888
10907
  if (component.typ == exports.EnumToken.IdenTokenType) {
10889
- val = component.val.toLowerCase();
10908
+ val = component.val;
10890
10909
  if (
10891
10910
  // @ts-expect-error
10892
10911
  typeof Math[val.toUpperCase()] !== "number" &&
10893
- val != "in" &&
10894
- val != "hue" &&
10895
- val != "from" &&
10896
- val != "alpha" &&
10897
- val != "none" &&
10898
- val != "shorter" &&
10899
- val != "longer" &&
10900
- val != "increasing" &&
10901
- val != "decreasing" &&
10902
- !colorsFunc.includes(val) &&
10912
+ !equalsIgnoreCase(val, "in") &&
10913
+ !equalsIgnoreCase(val, "hue") &&
10914
+ !equalsIgnoreCase(val, "from") &&
10915
+ !equalsIgnoreCase(val, "alpha") &&
10916
+ !equalsIgnoreCase(val, "none") &&
10917
+ !equalsIgnoreCase(val, "shorter") &&
10918
+ !equalsIgnoreCase(val, "longer") &&
10919
+ !equalsIgnoreCase(val, "increasing") &&
10920
+ !equalsIgnoreCase(val, "decreasing") &&
10921
+ !colorsFunc.some((t) => equalsIgnoreCase(t, val)) &&
10903
10922
  !colorFuncColorSpace.includes(val) &&
10904
10923
  !validKeys.includes(val)) {
10905
10924
  return null;
@@ -12042,52 +12061,24 @@ function getSyntaxConfig() {
12042
12061
  // @ts-expect-error
12043
12062
  return config$4;
12044
12063
  }
12045
- // export const getSyntax = memoize((group: ValidationSyntaxGroupEnum, key: string | string[]): null | string => {
12046
- // // @ts-expect-error
12047
- // let obj = config[group] as Record<ValidationSyntaxGroupEnum, ValidationSyntaxNode>;
12048
- //
12049
- // const keys: string[] = Array.isArray(key) ? key : [key];
12050
- //
12051
- // for (let i = 0; i < keys.length; i++) {
12052
- // key = keys[i];
12053
- //
12054
- // if (!(key in obj)) {
12055
- // if ((i == 0 && key.charAt(0) == "@") || key.charAt(0) == "-") {
12056
- // const matches: RegExpMatchArray = key.match(/^(@?)(-[a-zA-Z]+)-(.*?)$/) as RegExpMatchArray;
12057
- //
12058
- // if (matches != null) {
12059
- // key = matches[1] + matches[3];
12060
- // }
12061
- // }
12062
- // }
12063
- //
12064
- // // @ts-expect-error
12065
- // obj = obj[key];
12066
- // }
12067
- //
12068
- // // @ts-expect-error
12069
- // return obj?.syntax ?? null;
12070
- // }) as (group: ValidationSyntaxGroupEnum, key: string | string[]) => null | string;
12071
12064
  function findNode(group, key) {
12072
12065
  // @ts-expect-error
12073
12066
  let obj = config$4[group];
12074
- // const keys: string[] = Array.isArray(key) ? key : [key];
12075
- // for (let i = 0; i < keys.length; i++) {
12076
- // key = keys[i];
12077
- if (!(key in obj)) {
12067
+ // @ts-expect-error
12068
+ if (obj[key] == null) {
12078
12069
  if (key.charAt(0) == "@" || key.charAt(0) == "-") {
12079
12070
  const matches = key.match(/^(@?)(-[a-zA-Z]+)-(.*?)$/);
12080
12071
  if (matches != null) {
12081
12072
  key = matches[1] + matches[3];
12082
12073
  }
12083
12074
  }
12084
- if (!(key in obj)) {
12075
+ // @ts-expect-error
12076
+ if (obj[key] == null) {
12085
12077
  return null;
12086
12078
  }
12087
12079
  }
12088
12080
  // @ts-expect-error
12089
12081
  obj = obj[key];
12090
- // }
12091
12082
  return obj;
12092
12083
  }
12093
12084
  const getParsedSyntax = memoize((group, key) => {
@@ -12198,6 +12189,20 @@ function cloneNode(node, cloneChildren = false, cloneMap = null) {
12198
12189
  const config$3 = getSyntaxConfig();
12199
12190
  // @ts-expect-error
12200
12191
  const allValues = config$3.declarations.all.syntax.split(/[\s|]+/g);
12192
+ const selectorNodeTypes = [
12193
+ exports.EnumToken.CommaTokenType,
12194
+ exports.EnumToken.ColumnCombinatorTokenType,
12195
+ exports.EnumToken.ChildCombinatorTokenType,
12196
+ exports.EnumToken.NextSiblingCombinatorTokenType,
12197
+ exports.EnumToken.SubsequentSiblingCombinatorTokenType,
12198
+ ];
12199
+ const trimWhitespaceBefore = selectorNodeTypes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrEndTokenType);
12200
+ const trimWhitespaceAfter = selectorNodeTypes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrStartTokenType);
12201
+ const selectorEnumMap = new Map([
12202
+ [exports.EnumToken.Tilda, exports.EnumToken.SubsequentSiblingCombinatorTokenType],
12203
+ [exports.EnumToken.GtTokenType, exports.EnumToken.ChildCombinatorTokenType],
12204
+ ]);
12205
+ const propertyKeywordValues = new Map();
12201
12206
  /**
12202
12207
  * @type {Array.<EnumToken>}
12203
12208
  */
@@ -12421,24 +12426,6 @@ function createValidationContext(tokens) {
12421
12426
  getRemainingTokens() {
12422
12427
  return this.tokens.slice(this.index + 1);
12423
12428
  },
12424
- // last() {
12425
- // let index: number = this.tokens.length - 1;
12426
- // let token: Token = this.tokens[index];
12427
- // while (
12428
- // (this.index >= 0 && token?.typ === EnumToken.WhitespaceTokenType) ||
12429
- // token?.typ === EnumToken.CommentTokenType ||
12430
- // token?.typ === EnumToken.CDOCOMMTokenType ||
12431
- // token?.typ === EnumToken.InvalidCommentTokenType ||
12432
- // token?.typ === EnumToken.BadCommentTokenType ||
12433
- // token?.typ === EnumToken.BadStringTokenType
12434
- // ) {
12435
- // token = this.tokens[--index];
12436
- // if (token == null) {
12437
- // break;
12438
- // }
12439
- // }
12440
- // return token;
12441
- // },
12442
12429
  end() {
12443
12430
  this.index = this.tokens.length + 1;
12444
12431
  return this;
@@ -12498,19 +12485,6 @@ function createValidationContext(tokens) {
12498
12485
  function matchSelectorSyntax(stream, errors, options, nested = true) {
12499
12486
  const stack = [];
12500
12487
  const tokens = [];
12501
- const nodes = [
12502
- exports.EnumToken.CommaTokenType,
12503
- exports.EnumToken.ColumnCombinatorTokenType,
12504
- exports.EnumToken.ChildCombinatorTokenType,
12505
- exports.EnumToken.NextSiblingCombinatorTokenType,
12506
- exports.EnumToken.SubsequentSiblingCombinatorTokenType,
12507
- ];
12508
- const trimWhitespaceBefore = nodes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrEndTokenType);
12509
- const trimWhitespaceAfter = nodes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrStartTokenType);
12510
- const enumMap = new Map([
12511
- [exports.EnumToken.Tilda, exports.EnumToken.SubsequentSiblingCombinatorTokenType],
12512
- [exports.EnumToken.GtTokenType, exports.EnumToken.ChildCombinatorTokenType],
12513
- ]);
12514
12488
  let token;
12515
12489
  let i = 0;
12516
12490
  let success = true;
@@ -12550,15 +12524,15 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
12550
12524
  }
12551
12525
  tokens.push(token);
12552
12526
  if (tokensfuncDefMap.has(token.typ)) {
12553
- if (stack.length > 0 && nodes.includes(stack.at(-1).typ)) {
12527
+ if (stack.length > 0 && selectorNodeTypes.includes(stack.at(-1).typ)) {
12554
12528
  stack.pop();
12555
12529
  }
12556
12530
  stack.push(token);
12557
12531
  continue;
12558
12532
  }
12559
12533
  if (stack.length > 0 &&
12560
- nodes.includes(stack.at(-1).typ) &&
12561
- !nodes.includes(token.typ) &&
12534
+ selectorNodeTypes.includes(stack.at(-1).typ) &&
12535
+ !selectorNodeTypes.includes(token.typ) &&
12562
12536
  token.typ !== exports.EnumToken.WhitespaceTokenType &&
12563
12537
  token.typ !== exports.EnumToken.CommentTokenType &&
12564
12538
  token.typ !== exports.EnumToken.CDOCOMMTokenType) {
@@ -12604,7 +12578,7 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
12604
12578
  break;
12605
12579
  case exports.EnumToken.Tilda:
12606
12580
  case exports.EnumToken.GtTokenType:
12607
- Object.assign(token, { typ: enumMap.get(token.typ) });
12581
+ Object.assign(token, { typ: selectorEnumMap.get(token.typ) });
12608
12582
  case exports.EnumToken.ColumnCombinatorTokenType:
12609
12583
  case exports.EnumToken.ChildCombinatorTokenType:
12610
12584
  case exports.EnumToken.UniversalSelectorTokenType:
@@ -12617,7 +12591,7 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
12617
12591
  if (stack.length > 0 && stack.at(-1)?.typ === exports.EnumToken.UniversalSelectorTokenType) {
12618
12592
  stack.pop();
12619
12593
  }
12620
- if (stack.length > 0 && nodes.includes(stack.at(-1)?.typ)) {
12594
+ if (stack.length > 0 && selectorNodeTypes.includes(stack.at(-1)?.typ)) {
12621
12595
  return {
12622
12596
  success: false,
12623
12597
  errors: [
@@ -12727,106 +12701,10 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
12727
12701
  };
12728
12702
  }
12729
12703
  slice.shift();
12730
- // if (slice.length > 0) {
12731
- // return {
12732
- // success: false,
12733
- // errors: [
12734
- // {
12735
- // action: "drop",
12736
- // message: `Unexpected token ${EnumToken[slice[0].typ]} at ${slice[0][LOC]!.src}:${slice[0][LOCSTA].lin}:${
12737
- // slice[0][LOCSTA].col
12738
- // }`,
12739
- // node: slice[0],
12740
- // location: slice[0][LOC],
12741
- // },
12742
- // ],
12743
- // };
12744
- // }
12745
12704
  stack.pop();
12746
12705
  break;
12747
12706
  }
12748
- // case EnumToken.ColonTokenType:
12749
- // if (stream[i + 1]?.typ === EnumToken.IdenTokenType) {
12750
- // Object.assign(token, {
12751
- // typ:
12752
- // (stream[i + 1] as IdentToken).val === "page"
12753
- // ? EnumToken.PseudoPageTokenType
12754
- // : pseudoElements.includes((token as PseudoElementToken).val)
12755
- // ? EnumToken.PseudoElementTokenType
12756
- // : EnumToken.PseudoClassTokenType,
12757
- // val: ":" + (stream[i + 1] as IdentToken).val,
12758
- // });
12759
- // token[LOC]!.end = stream[++i][LOC]!.end;
12760
- // break;
12761
- // } else if (stream[i + 1]?.typ === EnumToken.FunctionTokenDefType) {
12762
- // Object.assign(token, {
12763
- // typ: EnumToken.PseudoClassFunctionTokenDefType,
12764
- // val: ":" + (stream[i + 1] as IdentToken).val,
12765
- // });
12766
- // token[LOC]!.end = stream[++i][LOC]!.end;
12767
- // stack.push(token);
12768
- // break;
12769
- // }
12770
- // return {
12771
- // success: false,
12772
- // errors: [
12773
- // {
12774
- // action: "drop",
12775
- // message: `Unexpected token ${EnumToken[token.typ]} at ${token[LOC]!.src}:${token[LOCSTA].lin}:${
12776
- // token[LOCSTA].col
12777
- // }`,
12778
- // node: token,
12779
- // location: token[LOC],
12780
- // },
12781
- // ],
12782
- // };
12783
- // case EnumToken.DoubleColonTokenType:
12784
- // if (stream[i + 1]?.typ === EnumToken.IdenTokenType) {
12785
- // Object.assign(token, {
12786
- // typ:
12787
- // (stream[i + 1] as IdentToken).val === "page"
12788
- // ? EnumToken.PseudoPageTokenType
12789
- // : EnumToken.PseudoElementTokenType,
12790
- // val: "::" + (stream[i + 1] as IdentToken).val,
12791
- // });
12792
- // token[LOC]!.end = stream[++i][LOC]!.end;
12793
- // break;
12794
- // } else if (stream[i + 1]?.typ === EnumToken.FunctionTokenDefType) {
12795
- // Object.assign(token, {
12796
- // typ: EnumToken.PseudoClassFunctionTokenDefType,
12797
- // val: "::" + (stream[i + 1] as IdentToken).val,
12798
- // });
12799
- // token[LOC]!.end = stream[++i][LOC]!.end;
12800
- // stack.push(token);
12801
- // break;
12802
- // }
12803
- // return {
12804
- // success: false,
12805
- // errors: [
12806
- // {
12807
- // action: "drop",
12808
- // message: `Unexpected token ${EnumToken[token.typ]} at ${token[LOC]!.src}:${token[LOCSTA].lin}:${
12809
- // token[LOCSTA].col
12810
- // }`,
12811
- // node: token,
12812
- // location: token[LOC],
12813
- // },
12814
- // ],
12815
- // };
12816
12707
  case exports.EnumToken.StartParensTokenType:
12817
- // if (
12818
- // tokens.at(-2)?.typ === EnumToken.PseudoClassTokenType ||
12819
- // tokens.at(-2)?.typ === EnumToken.PseudoElementTokenType
12820
- // ) {
12821
- // stack.push(
12822
- // Object.assign(tokens.at(-2) as Token, {
12823
- // typ: EnumToken.PseudoClassFunctionTokenDefType,
12824
- // chi: [],
12825
- // }),
12826
- // );
12827
- // // tokens.pop();
12828
- // break;
12829
- // }
12830
12708
  return {
12831
12709
  success: false,
12832
12710
  errors: [
@@ -12846,19 +12724,6 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
12846
12724
  if (stack.at(-1)?.typ === exports.EnumToken.PseudoClassFunctionTokenDefType ||
12847
12725
  stack.at(-1)?.typ === exports.EnumToken.PseudoElementTokenType) {
12848
12726
  const token = stack.at(-1);
12849
- // if (!((stack.at(-1) as PseudoClassFunctionToken).val + "()" in config.selectors)) {
12850
- // return {
12851
- // errors: [
12852
- // {
12853
- // action: "drop",
12854
- // message: `Unknown class element ${(token as PseudoElementToken).val}`,
12855
- // node: token,
12856
- // location: token[LOC]!,
12857
- // },
12858
- // ],
12859
- // success: false,
12860
- // };
12861
- // }
12862
12727
  const index = tokens.indexOf(token);
12863
12728
  const result = matchAllSyntaxes(getParsedSyntax(ValidationSyntaxGroupEnum.Selectors, token.val + "()")?.[0]?.chi ?? [], createValidationContext(tokens.slice(index + 1, tokens.length - 1)), options);
12864
12729
  if (!result.success) {
@@ -12957,7 +12822,8 @@ function matchAllSyntaxes(syntaxes, context, options) {
12957
12822
  for (let i = index; i < syntaxes.length; i++) {
12958
12823
  if (syntaxes[i].typ == ValidationTokenEnum.Whitespace ||
12959
12824
  syntaxes[i].isOptional ||
12960
- syntaxes[i].isRepeatable) {
12825
+ syntaxes[i].isRepeatable ||
12826
+ syntaxes[i].match?.min?.val === 0) {
12961
12827
  continue;
12962
12828
  }
12963
12829
  return {
@@ -12998,6 +12864,7 @@ function matchListSyntax(syntax, context, options) {
12998
12864
  let tmpResult;
12999
12865
  let count = 0;
13000
12866
  let range;
12867
+ let done = false;
13001
12868
  success = false;
13002
12869
  do {
13003
12870
  range = context.peekRange(exports.EnumToken.CommaTokenType, exports.EnumToken.CommaTokenType, 1);
@@ -13013,12 +12880,9 @@ function matchListSyntax(syntax, context, options) {
13013
12880
  else {
13014
12881
  context.update(range.at(-1));
13015
12882
  }
13016
- if (context.done()) {
13017
- // context.end();
13018
- break;
13019
- }
12883
+ done = context.done();
13020
12884
  }
13021
- } while (tmpResult.success && !context.done());
12885
+ } while (tmpResult.success && !done);
13022
12886
  return result == null
13023
12887
  ? {
13024
12888
  success: false,
@@ -13056,6 +12920,9 @@ function matchOccurenceSyntax(syntax, context, options) {
13056
12920
  context.end();
13057
12921
  break;
13058
12922
  }
12923
+ if (tmpResult.context.index === context.index) {
12924
+ break;
12925
+ }
13059
12926
  context.update(tmpResult.context.current());
13060
12927
  if (match?.max?.val != null && Number.isFinite(match?.max?.val) && count === match.max.val) {
13061
12928
  break;
@@ -13101,7 +12968,6 @@ function matchSyntax(syntaxes, context, options) {
13101
12968
  errors: [],
13102
12969
  };
13103
12970
  }
13104
- syntaxes = syntaxes.slice();
13105
12971
  let i = -1;
13106
12972
  let success = false;
13107
12973
  let token = null;
@@ -13433,21 +13299,19 @@ function matchSyntax(syntaxes, context, options) {
13433
13299
  case ValidationTokenEnum.PipeToken:
13434
13300
  {
13435
13301
  result = null;
13436
- const results = [];
13437
13302
  let tmp = null;
13438
13303
  for (const syntax of syntaxes[i].chi) {
13439
13304
  tmp = matchSyntax(syntax, context.slice(), options);
13440
13305
  if (tmp.success) {
13441
- results.push(tmp);
13306
+ if (result == null || tmp.context.index >= result.context.index) {
13307
+ result = tmp;
13308
+ }
13442
13309
  if (tmp.context.done()) {
13443
13310
  context.end();
13444
13311
  return { ...tmp, context, syntaxToken: syntaxes[i + 1] };
13445
13312
  }
13446
13313
  }
13447
13314
  }
13448
- if (results.length > 0) {
13449
- result = results.reduce((a, b) => (a.context.index > b.context.index ? a : b));
13450
- }
13451
13315
  if (result?.success) {
13452
13316
  success = true;
13453
13317
  options.visited.get(token).delete(syntaxes[i]);
@@ -13809,7 +13673,8 @@ function matchAmpersandSyntax(syntax, context, options) {
13809
13673
  */
13810
13674
  function matchProperty(property, context, options) {
13811
13675
  let success = false;
13812
- let t = context.peek()?.typ;
13676
+ const token = context.peek();
13677
+ let t = token?.typ;
13813
13678
  let checkCalc = (t == exports.EnumToken.MathFunctionTokenDefType || t == exports.EnumToken.MathFunctionTokenType) &&
13814
13679
  [
13815
13680
  "number",
@@ -13824,19 +13689,19 @@ function matchProperty(property, context, options) {
13824
13689
  "calc-product",
13825
13690
  ].includes(property.val);
13826
13691
  if (checkCalc && !["number", "zero", "integer", "percentage", "length-percentage"].includes(property.val)) {
13827
- checkCalc = context.peek().val === "calc";
13692
+ checkCalc = token.val === "calc";
13828
13693
  }
13829
13694
  if (checkCalc) {
13830
13695
  let result;
13831
- const syntax = getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, context.peek().val + "()")?.[0]?.chi;
13696
+ const syntax = getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, token.val + "()")?.[0]?.chi;
13832
13697
  if (t === exports.EnumToken.MathFunctionTokenType) {
13833
- result = matchSyntax(syntax, createValidationContext(context.peek().chi), options);
13698
+ result = matchSyntax(syntax, createValidationContext(token.chi), options);
13834
13699
  if (result.success && result.context.done()) {
13835
13700
  context.next();
13836
13701
  return {
13837
13702
  success: true,
13838
13703
  valid: true,
13839
- token: context.peek(),
13704
+ token: token,
13840
13705
  context,
13841
13706
  syntaxToken: null,
13842
13707
  errors: [],
@@ -14010,13 +13875,16 @@ function matchProperty(property, context, options) {
14010
13875
  case "display-outside":
14011
13876
  case "display-legacy":
14012
13877
  case "content-position":
14013
- success =
14014
- context.peek()?.typ == exports.EnumToken.IdenTokenType &&
14015
- // @ts-expect-error
14016
- config$3.syntaxes[property.val].syntax
14017
- .split(/[\s|]+/)
14018
- .includes(context.peek().val.toLowerCase());
14019
- break;
13878
+ {
13879
+ let values = propertyKeywordValues.get(property.val);
13880
+ if (values == null) {
13881
+ values = new Set(config$3.syntaxes[property.val].syntax.split(/[\s|]+/));
13882
+ propertyKeywordValues.set(property.val, values);
13883
+ }
13884
+ success =
13885
+ token?.typ == exports.EnumToken.IdenTokenType && values.has(token.val.toLowerCase());
13886
+ break;
13887
+ }
14020
13888
  case "mf-name":
14021
13889
  {
14022
13890
  const token = context.peek();
@@ -14037,9 +13905,9 @@ function matchProperty(property, context, options) {
14037
13905
  case "counter-name":
14038
13906
  case "counter-style-name":
14039
13907
  success =
14040
- context.peek()?.typ == exports.EnumToken.IdenTokenType || context.peek()?.typ == exports.EnumToken.DashedIdenTokenType;
14041
- if (success && context.peek()?.typ === exports.EnumToken.IdenTokenType) {
14042
- const val = context.peek().val.toLowerCase();
13908
+ token?.typ == exports.EnumToken.IdenTokenType || token?.typ == exports.EnumToken.DashedIdenTokenType;
13909
+ if (success && token?.typ === exports.EnumToken.IdenTokenType) {
13910
+ const val = token.val.toLowerCase();
14043
13911
  success = "none" !== val && !allValues.includes(val);
14044
13912
  }
14045
13913
  break;
@@ -14553,7 +14421,6 @@ function matchRepeatableSyntax(syntax, context, options) {
14553
14421
  let result = null;
14554
14422
  let tmpResult;
14555
14423
  let success = !!isRepeatable;
14556
- // let index: number = context.index;
14557
14424
  do {
14558
14425
  tmpResult = matchSyntax([rest], context.slice(), options);
14559
14426
  if (tmpResult.success) {
@@ -14563,15 +14430,10 @@ function matchRepeatableSyntax(syntax, context, options) {
14563
14430
  context.end();
14564
14431
  break;
14565
14432
  }
14566
- // if (context.current() === tmpResult.context.current()) {
14567
- // context.next();
14568
- // } else {
14433
+ if (tmpResult.context.index === context.index) {
14434
+ break;
14435
+ }
14569
14436
  context.update(result.context.current());
14570
- // }
14571
- // if (index === context.index) {
14572
- // break;
14573
- // }
14574
- // index = context.index;
14575
14437
  }
14576
14438
  } while (tmpResult.success && !context.done());
14577
14439
  return {
@@ -14666,7 +14528,6 @@ function alpha(color, alpha) {
14666
14528
  }
14667
14529
  let components = getColorComponents(color);
14668
14530
  if (alpha.typ === exports.EnumToken.MathFunctionTokenType) {
14669
- const originalAlpha = cloneNode(alpha, true);
14670
14531
  for (const { value } of walkValues(alpha.chi, alpha)) {
14671
14532
  if (value.typ === exports.EnumToken.IdenTokenType) {
14672
14533
  if (equalsIgnoreCase(value.val, "alpha")) {
@@ -14678,22 +14539,22 @@ function alpha(color, alpha) {
14678
14539
  });
14679
14540
  // continue;
14680
14541
  }
14681
- else if (equalsIgnoreCase(value.val, "none")) {
14682
- Object.assign(value, {
14683
- typ: exports.EnumToken.NumberTokenType,
14684
- val: 0,
14685
- });
14686
- }
14542
+ // else if (equalsIgnoreCase((value as IdentToken).val, "none")) {
14543
+ // Object.assign(value, {
14544
+ // typ: EnumToken.NumberTokenType,
14545
+ // val: 0,
14546
+ // });
14547
+ // }
14687
14548
  }
14688
14549
  }
14689
14550
  const result = evaluate([alpha]);
14690
14551
  if (result.length == 1) {
14691
14552
  alpha = result[0];
14692
14553
  }
14693
- else {
14694
- // @ts-expect-error
14695
- alpha = originalAlpha;
14696
- }
14554
+ // else {
14555
+ // // @ts-expect-error
14556
+ // alpha = originalAlpha;
14557
+ // }
14697
14558
  }
14698
14559
  // console.error({ alpha });
14699
14560
  if (alpha.typ !== exports.EnumToken.IdenTokenType &&
@@ -14719,17 +14580,17 @@ function alpha(color, alpha) {
14719
14580
  return null;
14720
14581
  }
14721
14582
  if (alpha?.typ === exports.EnumToken.IdenTokenType) {
14722
- if (equalsIgnoreCase(alpha.val, "alpha")) {
14723
- alpha = components[3] ?? {
14724
- typ: exports.EnumToken.NumberTokenType,
14725
- val: 1,
14726
- };
14727
- }
14728
- else if (equalsIgnoreCase(alpha.val, "node")) {
14729
- alpha = {
14583
+ // if (equalsIgnoreCase((alpha as IdentToken).val, "alpha")) {
14584
+ // alpha = components[3] ?? {
14585
+ // typ: EnumToken.NumberTokenType,
14586
+ // val: 1,
14587
+ // };
14588
+ // } else
14589
+ if (equalsIgnoreCase(alpha.val, "none")) {
14590
+ Object.assign(alpha, {
14730
14591
  typ: exports.EnumToken.NumberTokenType,
14731
14592
  val: 0,
14732
- };
14593
+ });
14733
14594
  }
14734
14595
  }
14735
14596
  return makeColor(color.kin, components, alpha);
@@ -15450,12 +15311,12 @@ function getColorSpace(color) {
15450
15311
  // '\\'
15451
15312
  const REVERSE_SOLIDUS = 0x5c;
15452
15313
  const flexUnits = ["fr"];
15453
- const frequencyUnits = ["hz", "khz"];
15314
+ const frequencyUnits = ["Hz", "kHz"];
15454
15315
  const timeUnits = ["ms", "s"];
15455
15316
  const angleUnits = ["rad", "turn", "deg", "grad"];
15456
15317
  const resolutionUnits = ["dpi", "dpcm", "dppx", "x"];
15457
15318
  const dimensionUnits = [
15458
- "q",
15319
+ "Q",
15459
15320
  "cap",
15460
15321
  "ch",
15461
15322
  "cm",
@@ -17139,7 +17000,7 @@ function replaceAstNodes(tokens, root) {
17139
17000
  }
17140
17001
  class ComputePrefixFeature {
17141
17002
  get ordering() {
17142
- return 2;
17003
+ return 0;
17143
17004
  }
17144
17005
  get processMode() {
17145
17006
  return exports.FeatureWalkMode.Pre;
@@ -17583,10 +17444,10 @@ function replace(node, variableScope) {
17583
17444
  class InlineCssVariablesFeature {
17584
17445
  accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
17585
17446
  get ordering() {
17586
- return 0;
17447
+ return 2;
17587
17448
  }
17588
17449
  get processMode() {
17589
- return exports.FeatureWalkMode.Pre;
17450
+ return exports.FeatureWalkMode.Post;
17590
17451
  }
17591
17452
  static register(options) {
17592
17453
  if (options.inlineCssVariables) {
@@ -18180,35 +18041,6 @@ var properties = {
18180
18041
  "border-left-color": {
18181
18042
  map: "border",
18182
18043
  shorthand: "border-color"
18183
- },
18184
- "grid-row": {
18185
- shorthand: "grid-row",
18186
- properties: [
18187
- "grid-row-start",
18188
- "grid-row-end"
18189
- ],
18190
- types: [
18191
- "Iden",
18192
- "Number"
18193
- ],
18194
- multiple: true,
18195
- valueSeparator: {
18196
- typ: "Literal",
18197
- val: "/"
18198
- },
18199
- "default": [
18200
- "auto"
18201
- ],
18202
- keywords: [
18203
- "auto",
18204
- "span"
18205
- ]
18206
- },
18207
- "grid-row-start": {
18208
- shorthand: "grid-row"
18209
- },
18210
- "grid-row-end": {
18211
- shorthand: "grid-row"
18212
18044
  }
18213
18045
  };
18214
18046
  var map = {
@@ -19474,29 +19306,325 @@ var map = {
19474
19306
  },
19475
19307
  "background-size": {
19476
19308
  shorthand: "background"
19477
- }
19478
- };
19479
- var property = {
19480
- "transform-origin": {
19481
- pattern: [
19482
- [
19483
- "left|center|right",
19484
- "top|center|bottom",
19485
- "<length>"
19486
- ],
19487
- [
19488
- "left|center|right",
19489
- "top|center|bottom"
19490
- ],
19491
- [
19492
- "center|left|right|center|top|bottom|<length>"
19493
- ]
19309
+ },
19310
+ "grid-area": {
19311
+ shorthand: "grid-area",
19312
+ pattern: "grid-row-start grid-column-start grid-row-end grid-column-end",
19313
+ keywords: [
19314
+ "auto"
19494
19315
  ],
19316
+ "default": [
19317
+ "auto"
19318
+ ],
19319
+ multiple: false,
19320
+ expandShorthands: true,
19321
+ separator: {
19322
+ typ: "Literal",
19323
+ val: "/"
19324
+ },
19495
19325
  mapping: {
19496
- center: {
19497
- typ: "Perc",
19498
- val: 50
19499
- },
19326
+ "auto/auto": "auto",
19327
+ "auto/auto/auto": "auto",
19328
+ "auto/auto/auto/auto": "auto"
19329
+ },
19330
+ expandedProperties: {
19331
+ "grid-row": [
19332
+ "grid-row-start",
19333
+ "grid-row-end"
19334
+ ],
19335
+ "grid-column": [
19336
+ "grid-column-start",
19337
+ "grid-column-end"
19338
+ ]
19339
+ },
19340
+ properties: {
19341
+ "grid-row-start": {
19342
+ map: "grid-area",
19343
+ shorthand: "grid-row",
19344
+ types: [
19345
+ "Iden",
19346
+ "Number"
19347
+ ],
19348
+ "default": [
19349
+ "auto"
19350
+ ],
19351
+ keywords: [
19352
+ "auto"
19353
+ ]
19354
+ },
19355
+ "grid-column-start": {
19356
+ map: "grid-area",
19357
+ shorthand: "grid-column",
19358
+ types: [
19359
+ "Iden",
19360
+ "Number"
19361
+ ],
19362
+ prefix: {
19363
+ typ: "Literal",
19364
+ val: "/"
19365
+ },
19366
+ "default": [
19367
+ "auto"
19368
+ ],
19369
+ keywords: [
19370
+ "auto"
19371
+ ]
19372
+ },
19373
+ "grid-row-end": {
19374
+ map: "grid-area",
19375
+ shorthand: "grid-row",
19376
+ types: [
19377
+ "Iden",
19378
+ "Number"
19379
+ ],
19380
+ prefix: {
19381
+ typ: "Literal",
19382
+ val: "/"
19383
+ },
19384
+ "default": [
19385
+ "auto"
19386
+ ],
19387
+ keywords: [
19388
+ "auto"
19389
+ ]
19390
+ },
19391
+ "grid-column-end": {
19392
+ map: "grid-area",
19393
+ shorthand: "grid-column",
19394
+ types: [
19395
+ "Iden",
19396
+ "Number"
19397
+ ],
19398
+ prefix: {
19399
+ typ: "Literal",
19400
+ val: "/"
19401
+ },
19402
+ "default": [
19403
+ "auto"
19404
+ ],
19405
+ keywords: [
19406
+ "auto"
19407
+ ]
19408
+ }
19409
+ }
19410
+ },
19411
+ "grid-row-start": {
19412
+ shorthand: "grid-row"
19413
+ },
19414
+ "grid-column-start": {
19415
+ shorthand: "grid-column"
19416
+ },
19417
+ "grid-row-end": {
19418
+ shorthand: "grid-row"
19419
+ },
19420
+ "grid-column-end": {
19421
+ shorthand: "grid-column"
19422
+ },
19423
+ "grid-row": {
19424
+ shorthand: "grid-row",
19425
+ map: "grid-area",
19426
+ pattern: "grid-row-start grid-row-end",
19427
+ types: [
19428
+ "Iden",
19429
+ "Number"
19430
+ ],
19431
+ keywords: [
19432
+ "auto"
19433
+ ],
19434
+ "default": [
19435
+ "auto"
19436
+ ],
19437
+ multiple: false,
19438
+ mapping: {
19439
+ "auto auto": "auto",
19440
+ "auto/auto": "auto"
19441
+ },
19442
+ properties: {
19443
+ "grid-row-start": {
19444
+ map: "grid-area",
19445
+ types: [
19446
+ "Iden",
19447
+ "Number"
19448
+ ],
19449
+ "default": [
19450
+ "auto"
19451
+ ],
19452
+ multiple: true,
19453
+ keywords: [
19454
+ "auto"
19455
+ ]
19456
+ },
19457
+ "grid-row-end": {
19458
+ map: "grid-area",
19459
+ types: [
19460
+ "Iden",
19461
+ "Number"
19462
+ ],
19463
+ "default": [
19464
+ "auto"
19465
+ ],
19466
+ prefix: {
19467
+ typ: "Literal",
19468
+ val: "/"
19469
+ },
19470
+ multiple: true,
19471
+ keywords: [
19472
+ "auto"
19473
+ ]
19474
+ }
19475
+ }
19476
+ },
19477
+ "grid-column": {
19478
+ shorthand: "grid-column",
19479
+ map: "grid-area",
19480
+ pattern: "grid-column-start grid-column-end",
19481
+ types: [
19482
+ "Iden",
19483
+ "Number"
19484
+ ],
19485
+ keywords: [
19486
+ "auto"
19487
+ ],
19488
+ "default": [
19489
+ "auto"
19490
+ ],
19491
+ multiple: false,
19492
+ mapping: {
19493
+ "auto/auto": "auto"
19494
+ },
19495
+ properties: {
19496
+ "grid-column-start": {
19497
+ map: "grid-area",
19498
+ types: [
19499
+ "Iden",
19500
+ "Number"
19501
+ ],
19502
+ "default": [
19503
+ "auto"
19504
+ ],
19505
+ multiple: true,
19506
+ keywords: [
19507
+ "auto"
19508
+ ]
19509
+ },
19510
+ "grid-column-end": {
19511
+ map: "grid-area",
19512
+ types: [
19513
+ "Iden",
19514
+ "Number"
19515
+ ],
19516
+ "default": [
19517
+ "auto"
19518
+ ],
19519
+ multiple: true,
19520
+ prefix: {
19521
+ typ: "Literal",
19522
+ val: "/"
19523
+ },
19524
+ keywords: [
19525
+ "auto"
19526
+ ]
19527
+ }
19528
+ }
19529
+ },
19530
+ "grid-template": {
19531
+ shorthand: "grid-template",
19532
+ pattern: "grid-template-areas grid-template-rows grid-template-columns",
19533
+ keywords: [
19534
+ "none"
19535
+ ],
19536
+ "default": [
19537
+ "none"
19538
+ ],
19539
+ multiple: false,
19540
+ mapping: {
19541
+ "none none": "none",
19542
+ "none/none": "none",
19543
+ "none none/none": "none"
19544
+ },
19545
+ properties: {
19546
+ "grid-template-areas": {
19547
+ types: [
19548
+ "String"
19549
+ ],
19550
+ "default": [
19551
+ "none"
19552
+ ],
19553
+ multiple: true,
19554
+ keywords: [
19555
+ "none",
19556
+ "auto"
19557
+ ],
19558
+ mapping: {
19559
+ }
19560
+ },
19561
+ "grid-template-rows": {
19562
+ types: [
19563
+ "Perc",
19564
+ "Iden",
19565
+ "Length",
19566
+ "Flex"
19567
+ ],
19568
+ "default": [
19569
+ "none"
19570
+ ],
19571
+ multiple: true,
19572
+ keywords: [
19573
+ "none"
19574
+ ]
19575
+ },
19576
+ "grid-template-columns": {
19577
+ types: [
19578
+ "Perc",
19579
+ "Iden",
19580
+ "Length",
19581
+ "Flex"
19582
+ ],
19583
+ "default": [
19584
+ "none"
19585
+ ],
19586
+ prefix: {
19587
+ typ: "Literal",
19588
+ val: "/"
19589
+ },
19590
+ multiple: true,
19591
+ keywords: [
19592
+ "none"
19593
+ ]
19594
+ }
19595
+ }
19596
+ },
19597
+ "grid-template-areas": {
19598
+ shorthand: "grid-template"
19599
+ },
19600
+ "grid-template-rows": {
19601
+ shorthand: "grid-template"
19602
+ },
19603
+ "grid-template-columns": {
19604
+ shorthand: "grid-template"
19605
+ }
19606
+ };
19607
+ var property = {
19608
+ "transform-origin": {
19609
+ pattern: [
19610
+ [
19611
+ "left|center|right",
19612
+ "top|center|bottom",
19613
+ "<length>"
19614
+ ],
19615
+ [
19616
+ "left|center|right",
19617
+ "top|center|bottom"
19618
+ ],
19619
+ [
19620
+ "center|left|right|center|top|bottom|<length>"
19621
+ ]
19622
+ ],
19623
+ mapping: {
19624
+ center: {
19625
+ typ: "Perc",
19626
+ val: 50
19627
+ },
19500
19628
  left: {
19501
19629
  typ: "Perc",
19502
19630
  val: 0
@@ -19569,8 +19697,8 @@ function matchType(val, properties) {
19569
19697
 
19570
19698
  const propertiesConfig = getConfig();
19571
19699
  class PropertyMap {
19572
- config;
19573
19700
  declarations;
19701
+ config;
19574
19702
  requiredCount;
19575
19703
  pattern;
19576
19704
  constructor(config) {
@@ -19584,7 +19712,7 @@ class PropertyMap {
19584
19712
  }
19585
19713
  add(declaration) {
19586
19714
  if (declaration.nam == this.config.shorthand) {
19587
- this.declarations = new Map();
19715
+ this.declarations.clear();
19588
19716
  this.declarations.set(declaration.nam, declaration);
19589
19717
  this.matchTypes(declaration);
19590
19718
  }
@@ -19600,23 +19728,17 @@ class PropertyMap {
19600
19728
  if (this.declarations.has(this.config.shorthand)) {
19601
19729
  const tokens = {};
19602
19730
  const values = [];
19603
- // @ts-ignore
19604
- this.declarations
19605
- .get(this.config.shorthand)
19606
- // @ts-ignore
19607
- .val.slice()
19608
- .reduce((acc, curr) => {
19731
+ const val = [[]];
19732
+ for (const curr of this.declarations.get(this.config.shorthand).val) { // @ts-ignore
19609
19733
  // @ts-ignore
19610
19734
  if (separator != null && separator.typ == curr.typ && separator.val == curr.val) {
19611
- acc.push([]);
19612
- return acc;
19735
+ val.push([]);
19736
+ continue;
19613
19737
  }
19614
19738
  // @ts-ignore
19615
- acc.at(-1).push(curr);
19616
- return acc;
19617
- }, [[]])
19618
- // @ts-ignore
19619
- .reduce((acc, list, current) => {
19739
+ val.at(-1).push(curr);
19740
+ }
19741
+ for (let current = 0; current < val.length; current++) {
19620
19742
  values.push(...this.pattern.reduce((acc, property) => {
19621
19743
  // let current: number = 0;
19622
19744
  const props = this.config.properties[property];
@@ -19631,9 +19753,7 @@ class PropertyMap {
19631
19753
  // @ts-ignore
19632
19754
  acc[i][PROPERTYNAME] == property ||
19633
19755
  matchType(acc[i], props)) {
19634
- if ("prefix" in props &&
19635
- props.previous != null &&
19636
- !(props.previous in tokens)) {
19756
+ if ("prefix" in props && props.previous != null && !(props.previous in tokens)) {
19637
19757
  return acc;
19638
19758
  }
19639
19759
  if (!(property in tokens)) {
@@ -19698,9 +19818,8 @@ class PropertyMap {
19698
19818
  }
19699
19819
  }
19700
19820
  return acc;
19701
- }, list));
19702
- return values;
19703
- }, []);
19821
+ }, val[current]));
19822
+ }
19704
19823
  if (values.length == 0) {
19705
19824
  this.declarations = Object.entries(tokens).reduce((acc, curr) => {
19706
19825
  acc.set(curr[0], {
@@ -19744,18 +19863,73 @@ class PropertyMap {
19744
19863
  return this;
19745
19864
  }
19746
19865
  [Symbol.iterator]() {
19866
+ const propertiesMapping = { ...this.config.properties };
19867
+ const patterns = this.config.pattern.split(" ");
19868
+ let hasMapping = false;
19747
19869
  let iterable;
19748
19870
  let requiredCount = 0;
19749
19871
  let property;
19750
19872
  let isShorthand = true;
19751
- for (property of Object.keys(this.config.properties)) {
19752
- if (this.config.properties[property].required) {
19753
- if (!this.declarations.has(property)) {
19873
+ let declarations = this.declarations;
19874
+ for (const key of declarations.keys()) {
19875
+ if (declarations.has(key) && declarations.get(key) instanceof PropertyMap) {
19876
+ hasMapping = true;
19877
+ break;
19878
+ }
19879
+ }
19880
+ if (hasMapping) {
19881
+ const mapped = {};
19882
+ let key;
19883
+ for (const value of declarations.values()) {
19884
+ key = value.nam;
19885
+ if (value instanceof PropertyMap) {
19886
+ for (const [k, v] of value.declarations) {
19887
+ if (k == value.config.shorthand) {
19888
+ for (const [key, val] of Object.entries(value.config.properties)) {
19889
+ mapped[key] = cloneNode(v);
19890
+ for (let i = 0; i < v.val.length; i++) {
19891
+ // @ts-ignore
19892
+ if (key == v.val[i][PROPERTYNAME]) {
19893
+ if (mapped[key].val.length > 0) {
19894
+ mapped[key].val.push({
19895
+ typ: exports.EnumToken.WhitespaceTokenType,
19896
+ });
19897
+ }
19898
+ mapped[key].val.push(v.val[i]);
19899
+ }
19900
+ }
19901
+ if (mapped[key].val.length == 0) {
19902
+ mapped[key].val.push(...parseString(value.config.properties[key].default[0]));
19903
+ }
19904
+ }
19905
+ }
19906
+ else {
19907
+ mapped[k] = v;
19908
+ }
19909
+ }
19910
+ }
19911
+ else {
19912
+ mapped[key] = value;
19913
+ }
19914
+ }
19915
+ // console.error(mapped);
19916
+ if (patterns.length === Object.keys(mapped).length) {
19917
+ declarations = new Map();
19918
+ for (const key of patterns) {
19919
+ if (mapped[key] != null) {
19920
+ declarations.set(key, mapped[key]);
19921
+ }
19922
+ }
19923
+ }
19924
+ }
19925
+ for (property of Object.keys(propertiesMapping)) {
19926
+ if (propertiesMapping[property].required) {
19927
+ if (!declarations.has(property)) {
19754
19928
  isShorthand = false;
19755
19929
  break;
19756
19930
  }
19757
19931
  else {
19758
- const val = (this.declarations.get(property));
19932
+ const val = declarations.get(property);
19759
19933
  if (val instanceof PropertySet && !val.isShortHand()) {
19760
19934
  isShorthand = false;
19761
19935
  break;
@@ -19767,10 +19941,10 @@ class PropertyMap {
19767
19941
  }
19768
19942
  }
19769
19943
  if (requiredCount === 0) {
19770
- requiredCount = this.declarations.size;
19944
+ requiredCount = declarations.size;
19771
19945
  }
19772
19946
  if (!isShorthand || requiredCount < this.requiredCount) {
19773
- if (isShorthand && this.declarations.has(this.config.shorthand)) {
19947
+ if (isShorthand && declarations.has(this.config.shorthand)) {
19774
19948
  const cache = new Map();
19775
19949
  const removeDefaults = (declaration) => {
19776
19950
  let i;
@@ -19845,8 +20019,8 @@ class PropertyMap {
19845
20019
  }
19846
20020
  return declaration;
19847
20021
  };
19848
- const values = [...this.declarations.values()].reduce((acc, curr) => {
19849
- if (curr instanceof PropertySet) {
20022
+ const values = [...declarations.values()].reduce((acc, curr) => {
20023
+ if (curr instanceof PropertySet || curr instanceof PropertyMap) {
19850
20024
  for (const declaration of curr) {
19851
20025
  acc.push(declaration);
19852
20026
  }
@@ -19886,13 +20060,13 @@ class PropertyMap {
19886
20060
  }
19887
20061
  return (filtered.length > 0 ? filtered : values)[Symbol.iterator]();
19888
20062
  }
19889
- for (const declaration of this.declarations.values()) {
19890
- if (declaration instanceof PropertySet) {
20063
+ for (const declaration of declarations.values()) {
20064
+ if (declaration instanceof PropertySet || declaration instanceof PropertyMap) {
19891
20065
  continue;
19892
20066
  }
19893
20067
  const config = declaration.nam == this.config.shorthand
19894
20068
  ? this.config
19895
- : (this.config.properties[declaration.nam] ?? this.config);
20069
+ : (propertiesMapping[declaration.nam] ?? this.config);
19896
20070
  if (!("mapping" in config)) {
19897
20071
  continue;
19898
20072
  }
@@ -19909,7 +20083,7 @@ class PropertyMap {
19909
20083
  }
19910
20084
  }
19911
20085
  // @ts-ignore
19912
- iterable = this.declarations.values();
20086
+ iterable = declarations.values();
19913
20087
  }
19914
20088
  else {
19915
20089
  let count = 0;
@@ -19923,19 +20097,19 @@ class PropertyMap {
19923
20097
  : null;
19924
20098
  const tokens = {};
19925
20099
  // @ts-ignore
19926
- Object.entries(this.config.properties).reduce((acc, curr) => {
19927
- if (!this.declarations.has(curr[0])) {
20100
+ Object.entries(propertiesMapping).reduce((acc, curr) => {
20101
+ if (!declarations.has(curr[0])) {
19928
20102
  if (curr[1].required) {
19929
20103
  acc.push(curr[0]);
19930
20104
  }
19931
20105
  return acc;
19932
20106
  }
19933
20107
  let current = 0;
19934
- const props = this.config.properties[curr[0]];
19935
- const properties = (this.declarations.get(curr[0]));
19936
- for (const declaration of [
19937
- properties instanceof PropertySet ? [...properties][0] : properties,
19938
- ]) {
20108
+ const props = propertiesMapping[curr[0]];
20109
+ const properties = (declarations.get(curr[0]));
20110
+ for (const declaration of properties instanceof PropertySet || properties instanceof PropertyMap
20111
+ ? [...properties].flat()
20112
+ : [properties]) {
19939
20113
  // @ts-ignore
19940
20114
  for (const val of declaration.val) {
19941
20115
  // @ts-ignore
@@ -19982,9 +20156,45 @@ class PropertyMap {
19982
20156
  }
19983
20157
  return acc;
19984
20158
  }, []);
20159
+ // grid-template
20160
+ if (this.config.shorthand == "grid-template" && patterns.length == Object.keys(tokens).length) {
20161
+ const k = tokens[patterns[0]][0].length;
20162
+ const l = tokens[patterns[1]][0].length;
20163
+ const j = k < l ? k : l;
20164
+ const result = [];
20165
+ let i;
20166
+ for (i = 0; i < j; i++) {
20167
+ if (i < k) {
20168
+ result.push(tokens[patterns[0]][0][i]);
20169
+ }
20170
+ if (i < l) {
20171
+ result.push(tokens[patterns[1]][0][i]);
20172
+ }
20173
+ }
20174
+ if (j < k) {
20175
+ result.push(...tokens[patterns[0]][0].slice(j));
20176
+ }
20177
+ if (j < l) {
20178
+ result.push(...tokens[patterns[1]][0].slice(j));
20179
+ }
20180
+ const separator = this.config.properties[patterns[2]]?.prefix;
20181
+ result.push(
20182
+ // @ts-ignore
20183
+ { ...separator, typ: exports.EnumToken[separator.typ] }, ...tokens[patterns[2]][0].reduce((acc, curr) => {
20184
+ if (acc.length > 0) {
20185
+ acc.push({ typ: exports.EnumToken.WhitespaceTokenType });
20186
+ }
20187
+ acc.push(curr);
20188
+ return acc;
20189
+ }, []));
20190
+ const declaration = cloneNode(declarations.get(patterns[0]));
20191
+ declaration.nam = this.config.shorthand;
20192
+ declaration.val = result;
20193
+ return [declaration][Symbol.iterator]();
20194
+ }
19985
20195
  count++;
19986
20196
  if (!isShorthand ||
19987
- Object.entries(this.config.properties).some((entry) => {
20197
+ Object.entries(propertiesMapping).some((entry) => {
19988
20198
  // missing required property
19989
20199
  return entry[1].required && !(entry[0] in tokens);
19990
20200
  }) ||
@@ -19993,27 +20203,74 @@ class PropertyMap {
19993
20203
  // @ts-expect-error
19994
20204
  v.filter((t) => t.typ != exports.EnumToken.CommentTokenType).length === count)) {
19995
20205
  // @ts-ignore
19996
- iterable = this.declarations.values();
20206
+ iterable = declarations.values();
20207
+ }
20208
+ else if (hasMapping) {
20209
+ if (patterns.length == Object.keys(tokens).length) {
20210
+ const declaration = cloneNode(declarations.get(patterns[0]));
20211
+ declaration.nam = this.config.shorthand;
20212
+ for (let i = 0; i < patterns.length; i++) {
20213
+ if (declaration.val.length > 0) {
20214
+ declaration.val.push(
20215
+ // @ts-ignore
20216
+ this.config.separator != null
20217
+ ? {
20218
+ ...this.config.separator,
20219
+ typ: exports.EnumToken[this.config.separator.typ],
20220
+ }
20221
+ : { typ: exports.EnumToken.WhitespaceTokenType });
20222
+ }
20223
+ declaration.val.push(...tokens[patterns[i]].reduce((acc, curr) => {
20224
+ if (acc.length > 0) {
20225
+ acc.push({ typ: exports.EnumToken.WhitespaceTokenType });
20226
+ }
20227
+ acc.push(...curr.reduce((acc, curr) => {
20228
+ if (acc.length > 0) {
20229
+ acc.push({ typ: exports.EnumToken.WhitespaceTokenType });
20230
+ }
20231
+ acc.push(curr);
20232
+ return acc;
20233
+ }, []));
20234
+ return acc;
20235
+ }, []));
20236
+ }
20237
+ return [declaration][Symbol.iterator]();
20238
+ }
20239
+ iterable = declarations.values();
19997
20240
  }
19998
20241
  else {
19999
20242
  let values = Object.entries(tokens)
20000
20243
  .reduce((acc, curr) => {
20001
- const props = this.config.properties[curr[0]];
20244
+ const props = propertiesMapping[curr[0]];
20002
20245
  for (let i = 0; i < curr[1].length; i++) {
20003
20246
  if (acc.length == i) {
20004
20247
  acc.push([]);
20005
20248
  }
20006
- let values = curr[1][i].reduce((acc, curr) => {
20007
- if (acc.length > 0) {
20008
- acc.push({ typ: exports.EnumToken.WhitespaceTokenType });
20009
- }
20010
- acc.push(curr);
20011
- return acc;
20012
- }, []);
20249
+ // if (acc[acc.length - 1].length > 0) {
20250
+ // acc[acc.length - 1].push(
20251
+ // // @ts-ignore
20252
+ // this.config.separator != null ?
20253
+ // {
20254
+ // ...this.config.separator,
20255
+ // typ: EnumToken[this.config.separator.typ as keyof typeof EnumToken],
20256
+ // } : <Token>{ typ: EnumToken.WhitespaceTokenType },
20257
+ // )
20258
+ // }
20259
+ let values = curr[1][i];
20260
+ // .reduce(
20261
+ // (acc, curr) => {
20262
+ // // if (acc.length > 0) {
20263
+ // // acc.push(<Token>{ typ: EnumToken.WhitespaceTokenType });
20264
+ // // }
20265
+ // acc.push(curr);
20266
+ // return acc;
20267
+ // },
20268
+ // <Token[]>[],
20269
+ // );
20013
20270
  if (props.default.includes(curr[1][i]
20014
20271
  .reduce((acc, curr) => acc + renderValue(curr) + " ", "")
20015
20272
  .trimEnd())) {
20016
- if (!this.config.properties[curr[0]].required) {
20273
+ if (!propertiesMapping[curr[0]].required) {
20017
20274
  continue;
20018
20275
  }
20019
20276
  }
@@ -20027,7 +20284,7 @@ class PropertyMap {
20027
20284
  exports.EnumToken.IdenTokenType,
20028
20285
  ].includes(v.typ) ||
20029
20286
  (v.typ == exports.EnumToken.IdenTokenType &&
20030
- !this.config.properties[curr[0]].default.includes(v.val))) {
20287
+ !propertiesMapping[curr[0]].default.includes(v.val))) {
20031
20288
  doFilterDefault = false;
20032
20289
  break;
20033
20290
  }
@@ -20044,7 +20301,7 @@ class PropertyMap {
20044
20301
  props.default.includes(val.val)));
20045
20302
  });
20046
20303
  if (filtered.length > 0 ||
20047
- !(this.requiredCount == requiredCount && this.config.properties[curr[0]].required)) {
20304
+ !(this.requiredCount == requiredCount && propertiesMapping[curr[0]].required)) {
20048
20305
  values = filtered;
20049
20306
  }
20050
20307
  if (values.length > 0) {
@@ -20069,6 +20326,7 @@ class PropertyMap {
20069
20326
  acc[i].push({ ...props.prefix, typ: exports.EnumToken[props.prefix.typ] });
20070
20327
  }
20071
20328
  else if (acc[i].length > 0) {
20329
+ // @ts-ignore
20072
20330
  acc[i].push({ typ: exports.EnumToken.WhitespaceTokenType });
20073
20331
  }
20074
20332
  for (const v of values.reduce((acc, curr) => {
@@ -20146,6 +20404,7 @@ class PropertyMap {
20146
20404
  }
20147
20405
  }
20148
20406
  const iterators = [];
20407
+ // @ts-ignore
20149
20408
  return {
20150
20409
  // @ts-ignore
20151
20410
  next() {
@@ -20302,12 +20561,17 @@ function toSortedString(input) {
20302
20561
  return String(input);
20303
20562
  }
20304
20563
  if (Array.isArray(input)) {
20305
- return JSON.stringify(input.map(toSortedString));
20564
+ const result = new Array(input.length);
20565
+ for (const value of input) {
20566
+ result.push(toSortedString(value));
20567
+ }
20568
+ return JSON.stringify(result);
20569
+ }
20570
+ const keys = Object.keys(input).sort();
20571
+ for (let i = 0; i < keys.length; i++) {
20572
+ keys[i] = `${keys[i]}:${toSortedString(input[keys[i]])}`;
20306
20573
  }
20307
- return `{${Object.keys(input)
20308
- .sort()
20309
- .map((k) => `${k}:${toSortedString(input[k])}`)
20310
- .join(",")}}`;
20574
+ return `{${keys.join(",")}}`;
20311
20575
  }
20312
20576
  /**
20313
20577
  * Object hash
@@ -20393,6 +20657,9 @@ function syncHash(input, length = 6, algo) {
20393
20657
  }
20394
20658
 
20395
20659
  const config = getConfig();
20660
+ /**
20661
+ * Represents a list of property declarations, compute shorthand and remove duplicate declarations.
20662
+ */
20396
20663
  class PropertyList {
20397
20664
  options = { removeDuplicateDeclarations: true, computeShorthand: true };
20398
20665
  declarations;
@@ -20400,14 +20667,7 @@ class PropertyList {
20400
20667
  this.options = options;
20401
20668
  this.declarations = new Map();
20402
20669
  }
20403
- // set(nam: string, value: string | Token[]) {
20404
- // return this.add({
20405
- // typ: EnumToken.DeclarationNodeType,
20406
- // nam,
20407
- // val: Array.isArray(value) ? value : parseString(String(value)),
20408
- // });
20409
- // }
20410
- add(...declarations) {
20670
+ add(declarations) {
20411
20671
  let name;
20412
20672
  let syntaxRules = null;
20413
20673
  let result;
@@ -20445,22 +20705,8 @@ class PropertyList {
20445
20705
  }
20446
20706
  // do not compute shorthand for invalid declarations
20447
20707
  if (declaration[STATE] !== exports.EnumAstNodeStatus.Validated) {
20448
- // const key = objectHash(declaration);
20449
- // if (!this.ketsey.has(key)) {
20450
- // this.ketsey.set(key, [declaration.nam]);
20451
- // console.error(
20452
- // `Adding declaration : ${(<AstDeclaration>declaration).nam} with key : ${key}`
20453
- // )
20454
- // }
20455
- // else {
20456
- // console.error(
20457
- // `Duplicate declaration found: ${(<AstDeclaration>declaration).nam} with key : [ ${key} => ${this.ketsey.get(key)} ]`
20458
- // )
20459
- // console.error(JSON.stringify(toSortedString(declaration)))
20460
- // this.ketsey.get(key).push(declaration.nam);
20461
- // }
20462
20708
  this.declarations.set(objectHash(declaration), declaration);
20463
- return this;
20709
+ continue;
20464
20710
  }
20465
20711
  let propertyName = declaration.nam;
20466
20712
  let shortHandType;
@@ -20490,13 +20736,33 @@ class PropertyList {
20490
20736
  }
20491
20737
  // @ts-ignore
20492
20738
  if (shortHandType == "map") {
20739
+ let owner = this;
20740
+ const mapName =
20493
20741
  // @ts-ignore
20494
- if (!this.declarations.has(shorthand)) {
20742
+ config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
20743
+ if (typeof mapName === "string") {
20744
+ if (!this.declarations.has(mapName)) {
20745
+ // @ts-ignore
20746
+ this.declarations.set(mapName, new PropertyMap(config.map[mapName]));
20747
+ }
20748
+ owner = this.declarations.get(mapName);
20749
+ }
20750
+ else if (!this.declarations.has(shorthand)) {
20495
20751
  // @ts-ignore
20496
20752
  this.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
20497
20753
  }
20498
- // @ts-ignore
20499
- this.declarations.get(shorthand).add(declaration);
20754
+ if (owner == this) {
20755
+ // @ts-ignore
20756
+ owner.declarations.get(shorthand).add(declaration);
20757
+ }
20758
+ else {
20759
+ if (!owner.declarations.has(shorthand)) {
20760
+ // @ts-ignore
20761
+ owner.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
20762
+ }
20763
+ // @ts-ignore
20764
+ owner.declarations.get(shorthand).add(declaration);
20765
+ }
20500
20766
  }
20501
20767
  // @ts-ignore
20502
20768
  else if (shortHandType == "set") {
@@ -20583,6 +20849,7 @@ class PropertyList {
20583
20849
  [Symbol.iterator]() {
20584
20850
  let iterator = this.declarations.values();
20585
20851
  const iterators = [];
20852
+ // @ts-ignore
20586
20853
  return {
20587
20854
  next() {
20588
20855
  let value = iterator.next();
@@ -20613,7 +20880,7 @@ class ComputeShorthandFeature {
20613
20880
  exports.EnumToken.KeyframesRuleNodeType,
20614
20881
  ]);
20615
20882
  get ordering() {
20616
- return 10;
20883
+ return 5;
20617
20884
  }
20618
20885
  get processMode() {
20619
20886
  return exports.FeatureWalkMode.Post;
@@ -20632,8 +20899,8 @@ class ComputeShorthandFeature {
20632
20899
  const j = ast.chi.length;
20633
20900
  let k = 0;
20634
20901
  let l;
20635
- let properties = new PropertyList(options);
20636
20902
  const rules = [];
20903
+ const declarations = [];
20637
20904
  // @ts-ignore
20638
20905
  for (; k < j; k++) {
20639
20906
  l = k;
@@ -20651,7 +20918,7 @@ class ComputeShorthandFeature {
20651
20918
  const node = ast.chi[l];
20652
20919
  if (node.typ == exports.EnumToken.DeclarationNodeType) {
20653
20920
  for (let m = k; m <= l; m++) {
20654
- properties.add(ast.chi[m]);
20921
+ declarations.push(ast.chi[m]);
20655
20922
  }
20656
20923
  }
20657
20924
  else {
@@ -20661,9 +20928,11 @@ class ComputeShorthandFeature {
20661
20928
  }
20662
20929
  k = l;
20663
20930
  }
20664
- ast.chi.length = 0;
20665
- // @ts-expect-error
20666
- ast.chi.push(...properties, ...rules);
20931
+ if (declarations.length > 0) {
20932
+ ast.chi.length = 0;
20933
+ // @ts-expect-error
20934
+ ast.chi.push(...new PropertyList(options).add(declarations), ...rules);
20935
+ }
20667
20936
  return ast;
20668
20937
  }
20669
20938
  }
@@ -20769,7 +21038,7 @@ function trimWhiteSpaceTokens(tokens) {
20769
21038
  class ComputeCalcExpressionFeature {
20770
21039
  accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
20771
21040
  get ordering() {
20772
- return 1;
21041
+ return 3;
20773
21042
  }
20774
21043
  get processMode() {
20775
21044
  return exports.FeatureWalkMode.Post;
@@ -20794,8 +21063,20 @@ class ComputeCalcExpressionFeature {
20794
21063
  continue;
20795
21064
  }
20796
21065
  if (value.typ == exports.EnumToken.BinaryExpressionTokenType) {
20797
- // @ts-ignore
20798
- replaceNodeOrValue(parent, value, evaluate([value]));
21066
+ const result = evaluate([value]);
21067
+ try {
21068
+ // @ts-ignore
21069
+ replaceNodeOrValue(parent, value, result);
21070
+ }
21071
+ catch (e) {
21072
+ // @ts-ignore
21073
+ if (Array.isArray(parent.chi)) {
21074
+ // @ts-ignore
21075
+ parent.chi.length = 0;
21076
+ // @ts-ignore
21077
+ parent.chi.push(...result);
21078
+ }
21079
+ }
20799
21080
  continue;
20800
21081
  }
20801
21082
  if (value != null && tokensfuncSet.has(value.typ)) {
@@ -20813,7 +21094,7 @@ class ComputeCalcExpressionFeature {
20813
21094
  ? value.val
20814
21095
  : value.chi;
20815
21096
  const values = evaluate(cp);
20816
- // fix a + -b to a - b
21097
+ // fix a + -b into a - b
20817
21098
  for (const { value, parent: p } of walkValues(values)) {
20818
21099
  if (value.typ === exports.EnumToken.BinaryExpressionTokenType) {
20819
21100
  if (value.op === exports.EnumToken.Add &&
@@ -20878,7 +21159,7 @@ class ComputeCalcExpressionFeature {
20878
21159
  }
20879
21160
  }
20880
21161
 
20881
- const identityMatrix = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
21162
+ const identityMatrix = new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
20882
21163
  function identity() {
20883
21164
  return identityMatrix.slice();
20884
21165
  }
@@ -20894,7 +21175,7 @@ function dot(point1, point2) {
20894
21175
  return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2];
20895
21176
  }
20896
21177
  function multiply(matrixA, matrixB) {
20897
- const result = new Float32Array(16);
21178
+ const result = new Float64Array(16);
20898
21179
  result[0] = matrixA[0] * matrixB[0] + matrixA[4] * matrixB[1] + matrixA[8] * matrixB[2] + matrixA[12] * matrixB[3];
20899
21180
  result[1] = matrixA[1] * matrixB[0] + matrixA[5] * matrixB[1] + matrixA[9] * matrixB[2] + matrixA[13] * matrixB[3];
20900
21181
  result[2] = matrixA[2] * matrixB[0] + matrixA[6] * matrixB[1] + matrixA[10] * matrixB[2] + matrixA[14] * matrixB[3];
@@ -22079,7 +22360,7 @@ class TransformCssFeature {
22079
22360
  exports.EnumToken.KeyframesRuleNodeType,
22080
22361
  ]);
22081
22362
  get ordering() {
22082
- return 3;
22363
+ return 4;
22083
22364
  }
22084
22365
  get processMode() {
22085
22366
  return exports.FeatureWalkMode.Post;
@@ -22482,7 +22763,7 @@ function processNode(declarationNode, cache) {
22482
22763
  class ExpandIfFeature {
22483
22764
  accept = new Set([exports.EnumToken.DeclarationNodeType]);
22484
22765
  get ordering() {
22485
- return 4;
22766
+ return 1;
22486
22767
  }
22487
22768
  get processMode() {
22488
22769
  return exports.FeatureWalkMode.Pre;
@@ -23284,7 +23565,8 @@ function doMinify(ast, options = {}, recursive = false, errors, nestingContent,
23284
23565
  previous = node;
23285
23566
  nodeIndex = i;
23286
23567
  }
23287
- if (recursive && node != null && "chi" in node) {
23568
+ // @ts-ignore
23569
+ if (recursive && node != null && node.chi != null) {
23288
23570
  if (node.typ == exports.EnumToken.KeyframesAtRuleNodeType ||
23289
23571
  !node.chi.some((n) => n.typ == exports.EnumToken.DeclarationNodeType)) {
23290
23572
  if (!(node.typ == exports.EnumToken.AtRuleNodeType && node.nam != "font-face")) {
@@ -24982,7 +25264,6 @@ let sourceId = 0;
24982
25264
  * Source file helper class
24983
25265
  */
24984
25266
  class SourceFile {
24985
- inputSourceMap = null;
24986
25267
  /**
24987
25268
  * Source file ID
24988
25269
  */
@@ -24999,6 +25280,7 @@ class SourceFile {
24999
25280
  * Source file content
25000
25281
  */
25001
25282
  content;
25283
+ inputSourceMap = null;
25002
25284
  /**
25003
25285
  * Constructor
25004
25286
  * @param content
@@ -25117,6 +25399,7 @@ function doRender(data, options = {}, mapping) {
25117
25399
  removeEmpty: false,
25118
25400
  removeComments: false,
25119
25401
  }),
25402
+ minifyValues: true,
25120
25403
  sourcemap: false,
25121
25404
  convertColor: true,
25122
25405
  expandNestingRules: false,
@@ -25180,7 +25463,7 @@ function doRender(data, options = {}, mapping) {
25180
25463
  }
25181
25464
  return acc + curr.val;
25182
25465
  }
25183
- return acc + renderValue(curr, options, cache, reducer, errors);
25466
+ return acc + renderValue(curr, options, cache, reducer);
25184
25467
  }, cache),
25185
25468
  errors,
25186
25469
  stats: {
@@ -25356,7 +25639,7 @@ function renderAstNode(data, options, sourcemaps, sourceLocation, linesMap, erro
25356
25639
  const indentSub = indents[level + 1];
25357
25640
  switch (data.typ) {
25358
25641
  case exports.EnumToken.DeclarationNodeType:
25359
- return `${data.nam}:${options.indent}${(options.minify
25642
+ return `${data.nam}:${options.indent}${(options.minifyValues
25360
25643
  ? filterValues(data.val)
25361
25644
  : data.val).reduce(reducer, "")}`;
25362
25645
  case exports.EnumToken.CommentNodeType:
@@ -25411,7 +25694,7 @@ function renderAstNode(data, options, sourcemaps, sourceLocation, linesMap, erro
25411
25694
  : node.val;
25412
25695
  }
25413
25696
  else if (node.typ == exports.EnumToken.DeclarationNodeType) {
25414
- str = `${node.nam}:${options.indent}${(options.minify
25697
+ str = `${node.nam}:${options.indent}${(options.minifyValues
25415
25698
  ? filterValues(node.val)
25416
25699
  : node.val)
25417
25700
  .reduce(reducer, "")
@@ -25479,9 +25762,10 @@ function renderAstNode(data, options, sourcemaps, sourceLocation, linesMap, erro
25479
25762
  function renderValue(token, options = {}, cache = Object.create(null), reducer, errors) {
25480
25763
  if (token.typ === exports.EnumToken.WhenElseFunctionTokenType &&
25481
25764
  equalsIgnoreCase(token.val, "supports")) {
25482
- options = { ...options, minify: false, convertColor: false };
25765
+ options = { ...options, minifyValues: false, minify: false, convertColor: false };
25483
25766
  reducer = null;
25484
25767
  }
25768
+ options.minifyValues ??= options.minify;
25485
25769
  if (reducer == null) {
25486
25770
  reducer = function (acc, curr) {
25487
25771
  if (curr.typ == exports.EnumToken.CommentTokenType && options.removeComments) {
@@ -25490,7 +25774,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
25490
25774
  }
25491
25775
  return acc + curr.val;
25492
25776
  }
25493
- return acc + renderValue(curr, options, cache, reducer, errors);
25777
+ return acc + renderValue(curr, options, cache, reducer);
25494
25778
  };
25495
25779
  }
25496
25780
  switch (token.typ) {
@@ -25638,7 +25922,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
25638
25922
  ")");
25639
25923
  }
25640
25924
  case exports.EnumToken.UrlFunctionTokenType:
25641
- if (options.minify && token.typ === exports.EnumToken.UrlFunctionTokenType) {
25925
+ if (options.minifyValues && token.typ === exports.EnumToken.UrlFunctionTokenType) {
25642
25926
  if (token.chi[0]?.typ === exports.EnumToken.BadUrlTokenType) {
25643
25927
  return "url()";
25644
25928
  }
@@ -25659,7 +25943,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
25659
25943
  case exports.EnumToken.FunctionTokenType:
25660
25944
  case exports.EnumToken.MathFunctionTokenType:
25661
25945
  case exports.EnumToken.ImageFunctionTokenType:
25662
- if (options.minify && token.typ === exports.EnumToken.ImageFunctionTokenType) {
25946
+ if (options.minifyValues && token.typ === exports.EnumToken.ImageFunctionTokenType) {
25663
25947
  const slice = token.chi.slice();
25664
25948
  switch (token.val) {
25665
25949
  case "linear-gradient":
@@ -26145,37 +26429,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
26145
26429
  renderValue(curr, token.typ == exports.EnumToken.FunctionTokenType ? { minify: false } : options, cache, reducer), "") +
26146
26430
  ")");
26147
26431
  }
26148
- return (
26149
- /* options.minify && 'Pseudo-class-func' == token.typ && token.val.slice(0, 2) == '::' ? token.val.slice(1) :*/ (token.val ?? "") +
26150
- "(" +
26151
- token.chi.reduce(reducer, "") +
26152
- ")");
26153
- // case EnumToken.MatchExpressionTokenType:
26154
- // return (
26155
- // renderValue((token as MatchExpressionToken).l as Token, options, cache, reducer, errors) +
26156
- // renderValue((token as MatchExpressionToken).op, options, cache, reducer, errors) +
26157
- // renderValue((token as MatchExpressionToken).r, options, cache, reducer, errors) +
26158
- // ((token as MatchExpressionToken).attr ? " " + (token as MatchExpressionToken).attr : "")
26159
- // );
26160
- // case EnumToken.NameSpaceAttributeTokenType:
26161
- // return (
26162
- // ((token as NameSpaceAttributeToken).l == null
26163
- // ? ""
26164
- // : renderValue((token as NameSpaceAttributeToken).l as Token, options, cache, reducer, errors)) +
26165
- // "|" +
26166
- // renderValue((token as NameSpaceAttributeToken).r, options, cache, reducer, errors)
26167
- // );
26168
- // case EnumToken.ComposesSelectorNodeType:
26169
- // return (
26170
- // (token as ComposesSelectorToken).l.reduce(
26171
- // (acc: string, curr: Token) => acc + renderValue(curr, options, cache),
26172
- // "",
26173
- // ) +
26174
- // ((token as ComposesSelectorToken).r == null
26175
- // ? ""
26176
- // : " from " +
26177
- // renderValue((token as ComposesSelectorToken).r as Token, options, cache, reducer, errors))
26178
- // );
26432
+ return (token.val ?? "") + "(" + token.chi.reduce(reducer, "") + ")";
26179
26433
  case exports.EnumToken.BlockStartTokenType:
26180
26434
  return "{";
26181
26435
  case exports.EnumToken.BlockEndTokenType:
@@ -26324,7 +26578,11 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
26324
26578
  const perc = token.val.typ == exports.EnumToken.FractionTokenType
26325
26579
  ? renderValue(token.val, options, cache)
26326
26580
  : minifyNumber(token.val);
26327
- return options.minify && perc == "0" ? "0" : perc.includes("/") ? perc.replace("/", uni + "/") : perc + uni;
26581
+ return options.minifyValues && perc == "0"
26582
+ ? "0"
26583
+ : perc.includes("/")
26584
+ ? perc.replace("/", uni + "/")
26585
+ : perc + uni;
26328
26586
  case exports.EnumToken.NumberTokenType:
26329
26587
  return token.val.typ == exports.EnumToken.FractionTokenType
26330
26588
  ? renderValue(token.val, options, cache)
@@ -26368,30 +26626,30 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
26368
26626
  return token.val;
26369
26627
  case exports.EnumToken.SupportsQueryUnaryConditionTokenType:
26370
26628
  case exports.EnumToken.WhenElseUnaryConditionTokenType:
26371
- return (renderValue(token.l, options, cache, reducer, errors) +
26629
+ return (renderValue(token.l, options, cache, reducer) +
26372
26630
  " " +
26373
- token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), ""));
26631
+ token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), ""));
26374
26632
  case exports.EnumToken.SupportsQueryConditionTokenType:
26375
26633
  case exports.EnumToken.WhenElseQueryConditionTokenType:
26376
- return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), "") +
26634
+ return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
26377
26635
  " " +
26378
- renderValue(token.op, options, cache, reducer, errors) +
26636
+ renderValue(token.op, options, cache, reducer) +
26379
26637
  " " +
26380
- token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), ""));
26638
+ token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), ""));
26381
26639
  case exports.EnumToken.IfConditionTokenType:
26382
26640
  return token.l.length == 0
26383
26641
  ? ""
26384
- : token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), "") +
26642
+ : token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
26385
26643
  ":" +
26386
- token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), "");
26644
+ token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "");
26387
26645
  case exports.EnumToken.IfElseConditionTokenType:
26388
26646
  return renderValue(token.l) + renderValue(token.r);
26389
26647
  case exports.EnumToken.DeclarationNodeType:
26390
26648
  return (token.nam +
26391
26649
  ":" +
26392
- (options.minify ? filterValues(token.val) : token.val).reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26650
+ (options.minifyValues ? filterValues(token.val) : token.val).reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26393
26651
  case exports.EnumToken.MediaQueryUnaryFeatureTokenType:
26394
- return (renderValue(token.l, options, cache, reducer, errors) +
26652
+ return (renderValue(token.l, options, cache, reducer) +
26395
26653
  " " +
26396
26654
  token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26397
26655
  case exports.EnumToken.MediaQueryConditionTokenType: {
@@ -26403,16 +26661,16 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
26403
26661
  token.op.typ == exports.EnumToken.GteTokenType
26404
26662
  ? ""
26405
26663
  : " ";
26406
- return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), "") +
26664
+ return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
26407
26665
  indent +
26408
- renderValue(token.op, options, cache, reducer, errors) +
26666
+ renderValue(token.op, options, cache, reducer) +
26409
26667
  indent +
26410
26668
  token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26411
26669
  }
26412
26670
  case exports.EnumToken.MediaRangeQueryTokenType:
26413
26671
  return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache), "") +
26414
26672
  renderValue(token.op1) +
26415
- token.val.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), "") +
26673
+ token.val.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
26416
26674
  renderValue(token.op2) +
26417
26675
  token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26418
26676
  case exports.EnumToken.MediaFeatureTokenType:
@@ -26437,8 +26695,8 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
26437
26695
  console.debug({ token });
26438
26696
  throw new Error(`Unsupported token type for ${exports.EnumToken[token.typ]}`);
26439
26697
  }
26440
- errors?.push({ action: "ignore", message: `render: unexpected token ${JSON.stringify(token, null, 1)}` });
26441
- return "";
26698
+ // errors?.push({ action: "ignore", message: `render: unexpected token ${JSON.stringify(token, null, 1)}` });
26699
+ // return "";
26442
26700
  }
26443
26701
  /**
26444
26702
  * Remove whitespace tokens that are not needed
@@ -26463,6 +26721,7 @@ function filterValues(values) {
26463
26721
  }
26464
26722
 
26465
26723
  const SymbolsMapTokens = Object.create(null);
26724
+ const SymbolsMapTokensLower = Object.create(null);
26466
26725
  // Regex for escape sequence decoding - compile once, reuse many times
26467
26726
  const ESCAPE_SEQUENCE_REGEX = /\\((\n|\r|\f|\v|\u2028|\u2029|([0-9a-fA-F]{1,6})) ?)/gms;
26468
26727
  function decodeEscapeSequences(value) {
@@ -26491,7 +26750,9 @@ function decodeEscapeSequences(value) {
26491
26750
  }
26492
26751
  function assignTokenMap(entries, tokenType, suffix = "", lowercase = false) {
26493
26752
  for (const entry of entries) {
26494
- SymbolsMapTokens[(lowercase ? entry.toLowerCase() : entry) + suffix] = tokenType;
26753
+ const key = (lowercase ? entry.toLowerCase() : entry) + suffix;
26754
+ SymbolsMapTokens[key] = tokenType;
26755
+ SymbolsMapTokensLower[key.toLowerCase()] = tokenType;
26495
26756
  }
26496
26757
  }
26497
26758
  SymbolsMapTokens[""] = exports.EnumToken.DelimTokenType;
@@ -26591,20 +26852,24 @@ var TokenMap;
26591
26852
  })(TokenMap || (TokenMap = {}));
26592
26853
  function getSymbolHint(parseInfo, start, end) {
26593
26854
  const len = end - start;
26594
- const keysLength = SymbolsMapTokensKeys.length;
26595
- // Early exit for impossible lengths
26596
- if (len < 0)
26855
+ if (len <= 0)
26597
26856
  return null;
26857
+ const value = parseInfo.stream.slice(start, end);
26858
+ // Direct lookup handles the hottest punctuation and keyword cases without
26859
+ // scanning the entire symbol table on every token.
26860
+ const match = SymbolsMapTokens[value] ?? SymbolsMapTokensLower[value.toLowerCase()];
26861
+ if (match != null) {
26862
+ return match;
26863
+ }
26864
+ const keysLength = SymbolsMapTokensKeys.length;
26598
26865
  for (let i = 0; i < keysLength; i++) {
26599
26866
  const key = SymbolsMapTokensKeys[i];
26600
26867
  if (key.length !== len)
26601
26868
  continue;
26602
- // Match character by character
26603
26869
  let match = true;
26604
26870
  for (let j = 0; j < len; j++) {
26605
26871
  let ca = key.charCodeAt(j);
26606
- let cb = parseInfo.stream.charCodeAt(start + j);
26607
- // Normalize A-Z to a-z
26872
+ let cb = value.charCodeAt(j);
26608
26873
  if (ca >= 65 && ca <= 90)
26609
26874
  ca += 32;
26610
26875
  if (cb >= 65 && cb <= 90)
@@ -26622,32 +26887,29 @@ function getSymbolHint(parseInfo, start, end) {
26622
26887
  }
26623
26888
  function searchArray(array, parseInfo, start, end) {
26624
26889
  const len = end - start;
26625
- // Early exit for impossible lengths
26626
- if (len < 0)
26890
+ if (len <= 0)
26627
26891
  return null;
26628
- // Use a simple linear search optimized with length pre-filtering
26629
- let i = array.length;
26630
- while (i--) {
26631
- if (array[i].length !== len)
26892
+ let match;
26893
+ let item;
26894
+ for (let i = 0; i < array.length; i++) {
26895
+ item = array[i];
26896
+ if (item.length !== len)
26632
26897
  continue;
26633
- // Match character by character
26634
- let match = true;
26635
- const arrayItem = array[i];
26898
+ match = true;
26636
26899
  for (let j = 0; j < len; j++) {
26637
- let ca = arrayItem.charCodeAt(j);
26638
- let cb = parseInfo.stream.charCodeAt(start + j);
26639
- // Normalize A-Z to a-z
26900
+ let ca = parseInfo.stream.charCodeAt(start + j);
26901
+ let cb = item.charCodeAt(j);
26640
26902
  if (ca >= 65 && ca <= 90)
26641
26903
  ca += 32;
26642
26904
  if (cb >= 65 && cb <= 90)
26643
26905
  cb += 32;
26644
- if (ca != cb) {
26906
+ if (ca !== cb) {
26645
26907
  match = false;
26646
26908
  break;
26647
26909
  }
26648
26910
  }
26649
26911
  if (match) {
26650
- return arrayItem;
26912
+ return item;
26651
26913
  }
26652
26914
  }
26653
26915
  return null;
@@ -27585,23 +27847,6 @@ class Tokenizer {
27585
27847
  }
27586
27848
  return true;
27587
27849
  }
27588
- /**
27589
- *
27590
- * @param parseInfo
27591
- * @returns
27592
- */
27593
- // isPseudo(parseInfo: ParseInfo): boolean {
27594
- // let position: number = parseInfo.currentPosition - parseInfo.offset;
27595
- // let endPosition: number = parseInfo.currentPosition - parseInfo.offset;
27596
- // return (parseInfo.stream.charAt(position) == ":" &&
27597
- // parseInfo.stream.charAt(endPosition - 1) == "(" &&
27598
- // (parseInfo.stream.charAt(position + 1) == ":"
27599
- // ? this.isIdentToken(parseInfo, 2, -1)
27600
- // : this.isIdentToken(parseInfo, 1, -1))) ||
27601
- // parseInfo.stream.charAt(position + 1) == ":"
27602
- // ? this.isIdentToken(parseInfo, 2)
27603
- // : this.isIdentToken(parseInfo, 1);
27604
- // }
27605
27850
  /**
27606
27851
  *
27607
27852
  * @param parseInfo
@@ -27732,28 +27977,28 @@ class Tokenizer {
27732
27977
  // EOF
27733
27978
  switch (charCode) {
27734
27979
  case 61 /* TokenMap.EQUALS */:
27735
- if (parseInfo.position < parseInfo.currentPosition) {
27736
- return this.makeToken(parseInfo);
27737
- }
27980
+ // if (parseInfo.position < parseInfo.currentPosition) {
27981
+ // return this.makeToken(parseInfo);
27982
+ // }
27738
27983
  this.advance(parseInfo);
27739
27984
  return this.makeToken(parseInfo, exports.EnumToken.DelimTokenType);
27740
27985
  // '+' or '-'
27741
27986
  case 43 /* TokenMap.PLUS */:
27742
- if (parseInfo.position < parseInfo.currentPosition) {
27743
- return this.makeToken(parseInfo);
27744
- }
27987
+ // if (parseInfo.position < parseInfo.currentPosition) {
27988
+ // return this.makeToken(parseInfo);
27989
+ // }
27745
27990
  this.advance(parseInfo);
27746
27991
  charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
27747
- if (isDigit(charCode)) {
27748
- tokensCount = this.consumeNumericToken(parseInfo);
27749
- if (tokensCount > 0) {
27750
- this.advance(parseInfo, tokensCount);
27751
- return this.makeToken(parseInfo, this.hint ?? exports.EnumToken.NumberTokenType, {
27752
- slice: this.slice,
27753
- sign: "+",
27754
- });
27755
- }
27756
- }
27992
+ // if (isDigit(charCode)) {
27993
+ // tokensCount = this.consumeNumericToken(parseInfo);
27994
+ // if (tokensCount > 0) {
27995
+ // this.advance(parseInfo, tokensCount);
27996
+ // return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, {
27997
+ // slice: this.slice,
27998
+ // sign: "+",
27999
+ // });
28000
+ // }
28001
+ // }
27757
28002
  return this.makeToken(parseInfo, exports.EnumToken.Plus);
27758
28003
  case 45 /* TokenMap.MINUS */:
27759
28004
  if (parseInfo.position == parseInfo.currentPosition) {
@@ -27763,15 +28008,17 @@ class Tokenizer {
27763
28008
  this.advance(parseInfo);
27764
28009
  return this.makeToken(parseInfo, exports.EnumToken.Sub);
27765
28010
  }
27766
- if (charCode == 45 /* TokenMap.MINUS */ &&
27767
- (nextCharCode == 45 /* TokenMap.MINUS */ || isIdentStart(nextCharCode))) {
27768
- this.advance(parseInfo);
27769
- tokensCount = this.consumeIdentToken(parseInfo);
27770
- if (tokensCount > 0) {
27771
- this.advance(parseInfo, tokensCount);
27772
- return this.makeToken(parseInfo, exports.EnumToken.IdenTokenType);
27773
- }
27774
- }
28011
+ // if (
28012
+ // charCode == TokenMap.MINUS &&
28013
+ // (nextCharCode == TokenMap.MINUS || isIdentStart(nextCharCode))
28014
+ // ) {
28015
+ // this.advance(parseInfo);
28016
+ // tokensCount = this.consumeIdentToken(parseInfo);
28017
+ // if (tokensCount > 0) {
28018
+ // this.advance(parseInfo, tokensCount);
28019
+ // return this.makeToken(parseInfo, EnumToken.IdenTokenType);
28020
+ // }
28021
+ // }
27775
28022
  }
27776
28023
  this.advance(parseInfo);
27777
28024
  break;
@@ -27824,28 +28071,28 @@ class Tokenizer {
27824
28071
  return this.makeToken(parseInfo, exports.EnumToken.EndParensTokenType);
27825
28072
  // '['
27826
28073
  case 91 /* TokenMap.LEFT_BRACKETS */:
27827
- if (parseInfo.position < parseInfo.currentPosition) {
27828
- return this.makeToken(parseInfo);
27829
- }
28074
+ // if (parseInfo.position < parseInfo.currentPosition) {
28075
+ // return this.makeToken(parseInfo);
28076
+ // }
27830
28077
  this.advance(parseInfo);
27831
28078
  return this.makeToken(parseInfo, exports.EnumToken.AttrStartTokenType);
27832
28079
  // ']'
27833
28080
  case 93 /* TokenMap.RIGHT_BRACKETS */:
27834
- if (parseInfo.position < parseInfo.currentPosition) {
27835
- return this.makeToken(parseInfo);
27836
- }
28081
+ // if (parseInfo.position < parseInfo.currentPosition) {
28082
+ // return this.makeToken(parseInfo);
28083
+ // }
27837
28084
  this.advance(parseInfo);
27838
28085
  return this.makeToken(parseInfo, exports.EnumToken.AttrEndTokenType);
27839
28086
  case 59 /* TokenMap.SEMICOLON */:
27840
- if (parseInfo.position < parseInfo.currentPosition) {
27841
- return this.makeToken(parseInfo);
27842
- }
28087
+ // if (parseInfo.position < parseInfo.currentPosition) {
28088
+ // return this.makeToken(parseInfo);
28089
+ // }
27843
28090
  this.advance(parseInfo);
27844
28091
  return this.makeToken(parseInfo, exports.EnumToken.SemiColonTokenType);
27845
28092
  case 58 /* TokenMap.COLON */:
27846
- if (parseInfo.position < parseInfo.currentPosition) {
27847
- return this.makeToken(parseInfo);
27848
- }
28093
+ // if (parseInfo.position < parseInfo.currentPosition) {
28094
+ // return this.makeToken(parseInfo);
28095
+ // }
27849
28096
  this.advance(parseInfo);
27850
28097
  if (this.peekCharCode(parseInfo) == 58 /* TokenMap.COLON */) {
27851
28098
  this.advance(parseInfo);
@@ -27877,15 +28124,15 @@ class Tokenizer {
27877
28124
  }
27878
28125
  return this.makeToken(parseInfo, exports.EnumToken.WhitespaceTokenType);
27879
28126
  case 44 /* TokenMap.COMMA */:
27880
- if (parseInfo.position < parseInfo.currentPosition) {
27881
- return this.makeToken(parseInfo);
27882
- }
28127
+ // if (parseInfo.position < parseInfo.currentPosition) {
28128
+ // return this.makeToken(parseInfo);
28129
+ // }
27883
28130
  this.advance(parseInfo);
27884
28131
  return this.makeToken(parseInfo, exports.EnumToken.CommaTokenType);
27885
28132
  case 36 /* TokenMap.DOLLAR */:
27886
- if (parseInfo.position < parseInfo.currentPosition) {
27887
- return this.makeToken(parseInfo);
27888
- }
28133
+ // if (parseInfo.position < parseInfo.currentPosition) {
28134
+ // return this.makeToken(parseInfo);
28135
+ // }
27889
28136
  if (this.match(parseInfo, "$=")) {
27890
28137
  this.advance(parseInfo, 2);
27891
28138
  return this.makeToken(parseInfo, exports.EnumToken.EndMatchTokenType);
@@ -27893,9 +28140,9 @@ class Tokenizer {
27893
28140
  this.advance(parseInfo);
27894
28141
  break;
27895
28142
  case 126 /* TokenMap.TILDA */:
27896
- if (parseInfo.position < parseInfo.currentPosition) {
27897
- return this.makeToken(parseInfo);
27898
- }
28143
+ // if (parseInfo.position < parseInfo.currentPosition) {
28144
+ // return this.makeToken(parseInfo);
28145
+ // }
27899
28146
  if (this.match(parseInfo, "~=")) {
27900
28147
  this.advance(parseInfo, 2);
27901
28148
  return this.makeToken(parseInfo, exports.EnumToken.IncludeMatchTokenType);
@@ -27904,9 +28151,9 @@ class Tokenizer {
27904
28151
  return this.makeToken(parseInfo, exports.EnumToken.Tilda);
27905
28152
  // case '^':
27906
28153
  case 94 /* TokenMap.CARET */:
27907
- if (parseInfo.position < parseInfo.currentPosition) {
27908
- return this.makeToken(parseInfo);
27909
- }
28154
+ // if (parseInfo.position < parseInfo.currentPosition) {
28155
+ // return this.makeToken(parseInfo);
28156
+ // }
27910
28157
  if (this.match(parseInfo, "^=")) {
27911
28158
  this.advance(parseInfo, 2);
27912
28159
  return this.makeToken(parseInfo, exports.EnumToken.StartMatchTokenType);
@@ -27914,9 +28161,9 @@ class Tokenizer {
27914
28161
  this.advance(parseInfo);
27915
28162
  break;
27916
28163
  case 42 /* TokenMap.STAR */:
27917
- if (parseInfo.position < parseInfo.currentPosition) {
27918
- return this.makeToken(parseInfo);
27919
- }
28164
+ // if (parseInfo.position < parseInfo.currentPosition) {
28165
+ // return this.makeToken(parseInfo);
28166
+ // }
27920
28167
  if (this.match(parseInfo, "*=")) {
27921
28168
  this.advance(parseInfo, 2);
27922
28169
  return this.makeToken(parseInfo, exports.EnumToken.ContainMatchTokenType);
@@ -27930,9 +28177,9 @@ class Tokenizer {
27930
28177
  this.advance(parseInfo);
27931
28178
  return this.makeToken(parseInfo, exports.EnumToken.NestingSelectorTokenType);
27932
28179
  case 124 /* TokenMap.PIPE */:
27933
- if (parseInfo.position < parseInfo.currentPosition) {
27934
- return this.makeToken(parseInfo);
27935
- }
28180
+ // if (parseInfo.position < parseInfo.currentPosition) {
28181
+ // return this.makeToken(parseInfo);
28182
+ // }
27936
28183
  // '||'
27937
28184
  if (this.match(parseInfo, "||")) {
27938
28185
  this.advance(parseInfo, 2);
@@ -27955,9 +28202,9 @@ class Tokenizer {
27955
28202
  this.advance(parseInfo);
27956
28203
  break;
27957
28204
  case 47 /* TokenMap.SLASH */:
27958
- if (parseInfo.position < parseInfo.currentPosition) {
27959
- return this.makeToken(parseInfo);
27960
- }
28205
+ // if (parseInfo.position < parseInfo.currentPosition) {
28206
+ // return this.makeToken(parseInfo);
28207
+ // }
27961
28208
  if (!this.match(parseInfo, "/*")) {
27962
28209
  this.advance(parseInfo);
27963
28210
  return this.makeToken(parseInfo, getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset));
@@ -27976,9 +28223,9 @@ class Tokenizer {
27976
28223
  }
27977
28224
  break;
27978
28225
  case 62 /* TokenMap.GREATERTHAN */:
27979
- if (parseInfo.position < parseInfo.currentPosition) {
27980
- return this.makeToken(parseInfo);
27981
- }
28226
+ // if (parseInfo.position < parseInfo.currentPosition) {
28227
+ // return this.makeToken(parseInfo);
28228
+ // }
27982
28229
  if (this.match(parseInfo, ">=")) {
27983
28230
  this.advance(parseInfo, 2);
27984
28231
  return this.makeToken(parseInfo, exports.EnumToken.GteTokenType);
@@ -28017,20 +28264,11 @@ class Tokenizer {
28017
28264
  this.advance(parseInfo);
28018
28265
  break;
28019
28266
  case 92 /* TokenMap.REVERSE_SOLIDUS */:
28020
- // if (!yieldEOFToken && parseInfo.stream.length == parseInfo.currentPosition - parseInfo.offset + 1) {
28021
- // break;
28022
- // }
28023
28267
  this.advance(parseInfo);
28024
28268
  // EOF
28025
- if (!this.peek(parseInfo)) {
28026
- // if (!yieldEOFToken) {
28027
- // break;
28028
- // }
28029
- // end of stream ignore \\
28030
- if (parseInfo.position < parseInfo.currentPosition) {
28031
- return this.makeToken(parseInfo);
28032
- }
28033
- break;
28269
+ // end of stream ignore \\
28270
+ if (!this.peek(parseInfo) && parseInfo.position < parseInfo.currentPosition) {
28271
+ return this.makeToken(parseInfo);
28034
28272
  }
28035
28273
  this.advance(parseInfo);
28036
28274
  break;
@@ -28043,9 +28281,9 @@ class Tokenizer {
28043
28281
  case 46 /* TokenMap.DOT */:
28044
28282
  const codepoint = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
28045
28283
  if (isIdentStart(codepoint) || codepoint == 45 /* TokenMap.MINUS */) {
28046
- if (parseInfo.position < parseInfo.currentPosition) {
28047
- return this.makeToken(parseInfo);
28048
- }
28284
+ // if (parseInfo.position < parseInfo.currentPosition) {
28285
+ // return this.makeToken(parseInfo);
28286
+ // }
28049
28287
  this.advance(parseInfo);
28050
28288
  let tokensCount = this.consumeIdentToken(parseInfo);
28051
28289
  if (tokensCount > 0) {
@@ -28053,27 +28291,22 @@ class Tokenizer {
28053
28291
  return this.makeToken(parseInfo, exports.EnumToken.ClassSelectorTokenType);
28054
28292
  }
28055
28293
  }
28056
- if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
28057
- this.makeToken(parseInfo);
28058
- this.advance(parseInfo, 2);
28059
- return this;
28060
- }
28294
+ // if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
28295
+ // this.makeToken(parseInfo);
28296
+ // this.advance(parseInfo, 2);
28297
+ // return this;
28298
+ // }
28061
28299
  this.advance(parseInfo);
28062
28300
  break;
28063
28301
  default:
28064
28302
  this.advance(parseInfo);
28065
28303
  break;
28066
28304
  }
28067
- // if (!yieldEOFToken && endPosition <= parseInfo.currentPosition - parseInfo.offset + 1) {
28068
- // break;
28069
- // }
28070
28305
  }
28071
- // if (yieldEOFToken) {
28072
28306
  if (parseInfo.position < parseInfo.currentPosition) {
28073
28307
  return this.makeToken(parseInfo);
28074
28308
  }
28075
28309
  return this.makeToken(parseInfo, exports.EnumToken.EOFTokenType);
28076
- // }
28077
28310
  }
28078
28311
  /**
28079
28312
  * tokenize readable stream
@@ -28882,24 +29115,6 @@ function parseDeclaration(tokens, parent, options, errors) {
28882
29115
  if (tokens[index].chi[l].typ === exports.EnumToken.StringTokenType) {
28883
29116
  break;
28884
29117
  }
28885
- // else if ((tokens[index] as FunctionToken).chi[l].typ === EnumToken.IdenTokenType) {
28886
- // let m: number = l + 1;
28887
- // while (
28888
- // (tokens[index] as FunctionToken).chi[m]?.typ === EnumToken.ClassSelectorTokenType
28889
- // ) {
28890
- // Object.assign((tokens[index] as FunctionToken).chi[l], {
28891
- // typ: EnumToken.UrlTokenTokenType,
28892
- // val:
28893
- // ((tokens[index] as FunctionToken).chi[l] as IdentToken | UrlToken).val +
28894
- // ((tokens[index] as FunctionToken).chi[m] as ClassSelectorToken).val,
28895
- // });
28896
- // (tokens[index] as FunctionToken).chi[l][LOCEND] = (
28897
- // tokens[index] as FunctionToken
28898
- // ).chi[m][LOCEND];
28899
- // (tokens[index] as FunctionToken).chi.splice(m, 1);
28900
- // }
28901
- // break;
28902
- // }
28903
29118
  }
28904
29119
  if (tokens[index].chi[l]?.typ === exports.EnumToken.StringTokenType &&
28905
29120
  /^[a-zA-Z0-0/_.-]+$/.test(tokens[index].chi[l].val.slice(1, -1))) {
@@ -30865,6 +31080,7 @@ function doParseSync(tokenizer, options = {}) {
30865
31080
  if (options.expandNestingRules) {
30866
31081
  options.nestingRules = false;
30867
31082
  }
31083
+ options.minifyAST ??= options.minify;
30868
31084
  const startTime = performance.now();
30869
31085
  const errors = [];
30870
31086
  const stack = [];
@@ -31244,7 +31460,7 @@ function doParseSync(tokenizer, options = {}) {
31244
31460
  }
31245
31461
  }
31246
31462
  }
31247
- if (options.minify) {
31463
+ if (options.minifyAST) {
31248
31464
  if (ast.chi.length > 0) {
31249
31465
  let passes = options.pass ?? 1;
31250
31466
  while (passes--) {
@@ -31784,6 +32000,7 @@ async function doParse(iter, options = {}) {
31784
32000
  lenient: true,
31785
32001
  ...options,
31786
32002
  };
32003
+ options.minifyAST ??= options.minify;
31787
32004
  if (typeof options.validation !== "boolean") {
31788
32005
  options.validation = !!options.validation;
31789
32006
  }
@@ -32238,7 +32455,7 @@ async function doParse(iter, options = {}) {
32238
32455
  }
32239
32456
  }
32240
32457
  }
32241
- if (options.minify) {
32458
+ if (options.minifyAST) {
32242
32459
  if (ast.chi.length > 0) {
32243
32460
  let passes = options.pass ?? 1;
32244
32461
  while (passes--) {
@@ -33150,7 +33367,7 @@ function parseAtRule(stream, context, options, errors, parseAsBlock = null) {
33150
33367
  atRule[LOCEND] = (stream.at(-1) ?? atRule)[LOCEND];
33151
33368
  // @ts-expect-error
33152
33369
  return Object.assign(atRule, {
33153
- typ: success ? exports.EnumToken.AtRuleNodeType : exports.EnumToken.InvalidRuleNodeType,
33370
+ typ: exports.EnumToken.AtRuleNodeType,
33154
33371
  val: renderTokens(trimArray(stream), options),
33155
33372
  });
33156
33373
  }
@@ -33158,12 +33375,12 @@ function parseAtRule(stream, context, options, errors, parseAsBlock = null) {
33158
33375
  return null;
33159
33376
  }
33160
33377
  atRule[TOKENS] = stream;
33161
- atRule[STATE] = exports.EnumAstNodeStatus.Validated;
33378
+ atRule[STATE] = success ? exports.EnumAstNodeStatus.Validated : exports.EnumAstNodeStatus.Invalid;
33162
33379
  atRule[ERRORS] = [];
33163
33380
  atRule[LOCEND] = (stream.at(-1) ?? atRule)[LOCEND];
33164
33381
  // @ts-expect-error
33165
33382
  return Object.assign(atRule, {
33166
- typ: success ? exports.EnumToken.AtRuleNodeType : exports.EnumToken.InvalidRuleNodeType,
33383
+ typ: exports.EnumToken.AtRuleNodeType,
33167
33384
  val: renderTokens(trimArray(stream), options),
33168
33385
  });
33169
33386
  }
@@ -33721,9 +33938,9 @@ function parseAtRule(stream, context, options, errors, parseAsBlock = null) {
33721
33938
  let result = null;
33722
33939
  if (syntax == null) {
33723
33940
  // check matching '(' and ')'
33724
- // check commas , or ,,
33725
- // check colon :
33726
- // check or and and
33941
+ // check commas ',' or ',,'
33942
+ // check colon ':'
33943
+ // check 'or' and 'and'
33727
33944
  result = matchGenericSyntax(stream, options);
33728
33945
  if (result.errors.length > 0) {
33729
33946
  for (const error of result.errors) {