@tbela99/css-parser 1.5.0 → 1.6.1

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 (78) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +10 -10
  3. package/dist/index-umd-web.js +5998 -4972
  4. package/dist/index.cjs +6001 -4977
  5. package/dist/index.d.ts +52 -38
  6. package/dist/lib/ast/expand.js +21 -7
  7. package/dist/lib/ast/features/calc.js +17 -55
  8. package/dist/lib/ast/features/if.js +7 -3
  9. package/dist/lib/ast/features/inlinecssvariables.js +6 -5
  10. package/dist/lib/ast/features/prefix.js +41 -44
  11. package/dist/lib/ast/features/shorthand.js +10 -5
  12. package/dist/lib/ast/features/transform.js +2 -2
  13. package/dist/lib/ast/math/expression.js +207 -34
  14. package/dist/lib/ast/minify.js +121 -24
  15. package/dist/lib/ast/node.js +5 -3
  16. package/dist/lib/ast/transform/compute.js +37 -5
  17. package/dist/lib/ast/transform/minify.js +7 -7
  18. package/dist/lib/ast/transform/perspective.js +1 -1
  19. package/dist/lib/ast/transform/rotate.js +1 -1
  20. package/dist/lib/ast/transform/scale.js +1 -1
  21. package/dist/lib/ast/transform/skew.js +1 -1
  22. package/dist/lib/ast/transform/translate.js +1 -1
  23. package/dist/lib/ast/transform/utils.js +46 -18
  24. package/dist/lib/ast/walk.js +28 -4
  25. package/dist/{config.json.js → lib/data/properties.json.js} +106 -0
  26. package/dist/lib/{validation/config.json.js → data/validation.json.js} +14 -8
  27. package/dist/lib/fs/resolve.js +11 -2
  28. package/dist/lib/parser/declaration/list.js +22 -7
  29. package/dist/lib/parser/declaration/map.js +26 -8
  30. package/dist/lib/parser/declaration/set.js +3 -1
  31. package/dist/lib/parser/linesmap.js +2 -4
  32. package/dist/lib/parser/parse.js +393 -231
  33. package/dist/lib/parser/tokenize.js +1478 -819
  34. package/dist/lib/parser/utils/at-rule-container.js +28 -196
  35. package/dist/lib/parser/utils/at-rule-generic.js +6 -7
  36. package/dist/lib/parser/utils/at-rule-import.js +17 -13
  37. package/dist/lib/parser/utils/at-rule-media.js +36 -19
  38. package/dist/lib/parser/utils/at-rule-support.js +19 -9
  39. package/dist/lib/parser/utils/at-rule-when-else.js +11 -38
  40. package/dist/lib/parser/utils/at-rule.js +0 -18
  41. package/dist/lib/parser/utils/config.js +1 -1
  42. package/dist/lib/parser/utils/declaration.js +40 -97
  43. package/dist/lib/parser/utils/hash.js +4 -4
  44. package/dist/lib/parser/utils/selector.js +179 -224
  45. package/dist/lib/parser/utils/text.js +4 -2
  46. package/dist/lib/renderer/render.js +104 -74
  47. package/dist/lib/renderer/sourcemap/lib/codec.js +3 -3
  48. package/dist/lib/renderer/sourcemap/sourcemap.js +2 -5
  49. package/dist/lib/syntax/color/a98rgb.js +14 -4
  50. package/dist/lib/syntax/color/cmyk.js +14 -21
  51. package/dist/lib/syntax/color/color-mix.js +21 -34
  52. package/dist/lib/syntax/color/color.js +32 -49
  53. package/dist/lib/syntax/color/hsl.js +15 -15
  54. package/dist/lib/syntax/color/hwb.js +18 -17
  55. package/dist/lib/syntax/color/lab.js +17 -17
  56. package/dist/lib/syntax/color/lch.js +13 -13
  57. package/dist/lib/syntax/color/oklab.js +10 -11
  58. package/dist/lib/syntax/color/oklch.js +15 -18
  59. package/dist/lib/syntax/color/p3.js +18 -12
  60. package/dist/lib/syntax/color/prophotorgb.js +26 -28
  61. package/dist/lib/syntax/color/rec2020.js +8 -4
  62. package/dist/lib/syntax/color/relative-color.js +26 -10
  63. package/dist/lib/syntax/color/srgb.js +9 -7
  64. package/dist/lib/syntax/color/utils/distance.js +1 -1
  65. package/dist/lib/syntax/color/xyz.js +2 -2
  66. package/dist/lib/syntax/color/xyzd50.js +2 -2
  67. package/dist/lib/syntax/constants.js +13 -3
  68. package/dist/lib/syntax/syntax.js +32 -108
  69. package/dist/lib/validation/config.js +1 -1
  70. package/dist/lib/validation/match.js +29 -26
  71. package/dist/lib/validation/parser/parse.js +7 -3
  72. package/dist/node.js +16 -9
  73. package/dist/types.d.ts +5 -1
  74. package/dist/types.js +4 -0
  75. package/dist/utils/sync.js +22 -1
  76. package/dist/web.js +13 -4
  77. package/package.json +4 -4
  78. package/llms.txt +0 -80
@@ -123,10 +123,17 @@ class PropertyMap {
123
123
  else {
124
124
  if (current == tokens[property].length) {
125
125
  tokens[property].push([]);
126
- tokens[property][current].push(...defaults);
126
+ for (let i = 0; i < defaults.length; i++) {
127
+ tokens[property][current].push(defaults[i]);
128
+ }
127
129
  }
128
130
  else {
129
- tokens[property][current].push({ typ: EnumToken.WhitespaceTokenType }, ...defaults);
131
+ tokens[property][current].push({
132
+ typ: EnumToken.WhitespaceTokenType,
133
+ });
134
+ for (let i = 0; i < defaults.length; i++) {
135
+ tokens[property][current].push(defaults[i]);
136
+ }
130
137
  }
131
138
  }
132
139
  }
@@ -143,7 +150,9 @@ class PropertyMap {
143
150
  if (acc.length > 0) {
144
151
  acc.push({ ...separator });
145
152
  }
146
- acc.push(...curr);
153
+ for (let i = 0; i < curr.length; i++) {
154
+ acc.push(curr[i]);
155
+ }
147
156
  return acc;
148
157
  }, []),
149
158
  });
@@ -278,7 +287,9 @@ class PropertyMap {
278
287
  };
279
288
  const values = [...this.declarations.values()].reduce((acc, curr) => {
280
289
  if (curr instanceof PropertySet) {
281
- acc.push(...curr);
290
+ for (const declaration of curr) {
291
+ acc.push(declaration);
292
+ }
282
293
  }
283
294
  else {
284
295
  acc.push(curr);
@@ -500,7 +511,7 @@ class PropertyMap {
500
511
  else if (acc[i].length > 0) {
501
512
  acc[i].push({ typ: EnumToken.WhitespaceTokenType });
502
513
  }
503
- acc[i].push(...values.reduce((acc, curr) => {
514
+ for (const v of values.reduce((acc, curr) => {
504
515
  if (acc.length > 0) {
505
516
  // @ts-ignore
506
517
  acc.push({
@@ -514,7 +525,9 @@ class PropertyMap {
514
525
  // @ts-ignore
515
526
  acc.push(curr);
516
527
  return acc;
517
- }, []));
528
+ }, [])) {
529
+ acc[i].push(v);
530
+ }
518
531
  }
519
532
  }
520
533
  return acc;
@@ -532,7 +545,9 @@ class PropertyMap {
532
545
  return acc;
533
546
  }, []));
534
547
  }
535
- acc.push(...curr);
548
+ for (const c of curr) {
549
+ acc.push(c);
550
+ }
536
551
  return acc;
537
552
  }, []);
538
553
  if (this.config.mapping != null) {
@@ -600,10 +615,13 @@ class PropertyMap {
600
615
  }
601
616
  matchTypes(declaration) {
602
617
  const patterns = this.pattern.slice();
603
- const values = [...declaration.val];
618
+ const values = [];
604
619
  let i;
605
620
  let j;
606
621
  const map = new Map();
622
+ for (i = 0; i < declaration.val.length; i++) {
623
+ values.push(declaration.val[i]);
624
+ }
607
625
  for (i = 0; i < patterns.length; i++) {
608
626
  for (j = 0; j < values.length; j++) {
609
627
  if (!map.has(patterns[i])) {
@@ -182,7 +182,9 @@ class PropertySet {
182
182
  // @ts-ignore
183
183
  acc.push({ ...this.config.separator, typ: EnumToken.LiteralTokenType });
184
184
  }
185
- acc.push(...curr);
185
+ for (const token of curr) {
186
+ acc.push(token);
187
+ }
186
188
  return acc;
187
189
  }, []),
188
190
  },
@@ -23,11 +23,9 @@ class LineMap {
23
23
  */
24
24
  getOffsets(offset) {
25
25
  const line = this.search(offset);
26
- // if (offset < 0 || line < 0) {
27
- // return [1, 1];
28
- // }
26
+ const column = offset - this.lineStarts[line];
29
27
  // [line, column]
30
- return [line + 1, offset - this.lineStarts[line] + 1];
28
+ return [line + 1, line == 0 ? column + 1 : column];
31
29
  }
32
30
  /**
33
31
  * search the greatest index of the value less than or equal to offset