@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,64 @@
1
1
  # Changelog
2
2
 
3
+ # v1.6.1
4
+
5
+ - [x] fix bugs when computing math functions.
6
+ - [x] reduce array mutations
7
+ - [x] supporting additional shorthands: scroll-timeline, scroll-padding, scroll-margin.
8
+ - [x] do not minify transform function when the absolute angle is greater or equals to 360deg
9
+
10
+ ```css
11
+
12
+ a:hover {
13
+
14
+ transform: rotate(calc(2.5*pi * 1rad)) }
15
+ .now {
16
+ transform: translate(100px, 100px) rotate(1215deg) skewX(10deg);
17
+ }
18
+ ```
19
+ should be minified to
20
+ ```css
21
+ a:hover {
22
+ transform: rotate(450deg)
23
+ }
24
+ .now {
25
+ transform: translate(100px,100px)rotate(1215deg)skew(10deg)
26
+ }
27
+ ```
28
+
29
+ # v1.6.0
30
+
31
+ - [x] added support for math function `tan()`.
32
+
33
+ ## Improvements
34
+ - [x] faster tokenizer
35
+ - [x] ensure transform: rotate(360deg) is not minified to transform: none
36
+ - [x] support input sourcemap from inline sourcemap file. This is only supported by the async parser.
37
+
38
+ ```css
39
+
40
+ table.colortable {
41
+ width: 100%;
42
+ text-shadow: none;
43
+ border-collapse: collapse
44
+ }
45
+ table.colortable td {
46
+ text-align: center
47
+ }
48
+ table.colortable td.c {
49
+ text-transform: uppercase;
50
+ background: #ff0
51
+ }
52
+ table.colortable th {
53
+ text-align: center;
54
+ color: green;
55
+ font-weight: 400;
56
+ padding: 2px 3px
57
+ }
58
+
59
+ /*# sourceMappingURL=sourcemap.css.map */
60
+ ```
61
+
3
62
  # v1.5.0
4
63
 
5
64
  ## Improvements
package/README.md CHANGED
@@ -99,6 +99,11 @@ Try it [online](https://tbela99.github.io/css-parser/playground/)
99
99
  - typ: number
100
100
  - val: string, the comment
101
101
 
102
+ ### AtRuleStyleSheet
103
+
104
+ - typ: number
105
+ - chi: array of children
106
+
102
107
  ### Declaration
103
108
 
104
109
  - typ: number
@@ -115,7 +120,7 @@ Try it [online](https://tbela99.github.io/css-parser/playground/)
115
120
  - state: EnumAstNodeStatus, validation state
116
121
  - errors: ErrorDescription[], validation errors
117
122
 
118
- ### AtRule
123
+ ### AtRule and KeyframesAtRule
119
124
 
120
125
  - typ: number
121
126
  - nam: string. AtRule name
@@ -123,12 +128,7 @@ Try it [online](https://tbela99.github.io/css-parser/playground/)
123
128
  - state: EnumAstNodeStatus, validation state
124
129
  - errors: ErrorDescription[], validation errors
125
130
 
126
- ### AtRuleStyleSheet
127
-
128
- - typ: number
129
- - chi: array of children
130
-
131
- ### KeyFrameRule
131
+ ### KeyframesRule
132
132
 
133
133
  - typ: number
134
134
  - sel: string, css selector
@@ -185,9 +185,9 @@ Try it [online](https://tbela99.github.io/css-parser/playground/)
185
185
  - [ ] place-content
186
186
  - [ ] place-items
187
187
  - [ ] place-self
188
- - [ ] scroll-margin
189
- - [ ] scroll-padding
190
- - [ ] scroll-timeline
188
+ - [x] scroll-margin
189
+ - [x] scroll-padding
190
+ - [x] scroll-timeline
191
191
  - [x] text-decoration
192
192
  - [x] text-emphasis
193
193
  - [x] transition