@tbela99/css-parser 1.6.0 → 1.6.2

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 (48) hide show
  1. package/CHANGELOG.md +118 -2
  2. package/README.md +4 -3
  3. package/dist/index-umd-web.js +1629 -467
  4. package/dist/index.cjs +1629 -467
  5. package/dist/index.d.ts +72 -7
  6. package/dist/lib/ast/features/prefix.js +9 -1
  7. package/dist/lib/ast/features/shorthand.js +1 -1
  8. package/dist/lib/ast/features/transform.js +1 -1
  9. package/dist/lib/ast/math/expression.js +175 -5
  10. package/dist/lib/ast/minify.js +84 -10
  11. package/dist/lib/ast/transform/compute.js +24 -55
  12. package/dist/lib/ast/transform/minify.js +1 -1
  13. package/dist/lib/ast/types.js +12 -0
  14. package/dist/{config.json.js → lib/data/properties.json.js} +106 -0
  15. package/dist/lib/{validation/config.json.js → data/validation.json.js} +11 -8
  16. package/dist/lib/parser/declaration/list.js +8 -10
  17. package/dist/lib/parser/parse.js +8 -14
  18. package/dist/lib/parser/tokenize.js +89 -58
  19. package/dist/lib/parser/utils/at-rule-font-feature-values.js +1 -1
  20. package/dist/lib/parser/utils/at-rule-media.js +66 -0
  21. package/dist/lib/parser/utils/at-rule-when-else.js +2 -2
  22. package/dist/lib/parser/utils/base64.js +14 -0
  23. package/dist/lib/parser/utils/config.js +1 -1
  24. package/dist/lib/parser/utils/declaration.js +18 -17
  25. package/dist/lib/parser/utils/eq.js +6 -0
  26. package/dist/lib/parser/utils/hash.js +1 -0
  27. package/dist/lib/parser/utils/selector.js +99 -89
  28. package/dist/lib/parser/utils/text.js +16 -0
  29. package/dist/lib/renderer/render.js +20 -6
  30. package/dist/lib/renderer/sourcemap/lib/codec.js +8 -3
  31. package/dist/lib/renderer/sourcemap/sourcemap.js +35 -5
  32. package/dist/lib/syntax/color/alpha.js +57 -22
  33. package/dist/lib/syntax/color/cmyk.js +4 -3
  34. package/dist/lib/syntax/color/color-mix.js +18 -18
  35. package/dist/lib/syntax/color/srgb.js +11 -5
  36. package/dist/lib/syntax/color/utils/components.js +1 -1
  37. package/dist/lib/syntax/color/utils/distance.js +2 -2
  38. package/dist/lib/syntax/color/utils/matrix.js +1 -0
  39. package/dist/lib/syntax/color/xyz.js +5 -0
  40. package/dist/lib/syntax/color/xyzd50.js +17 -0
  41. package/dist/lib/syntax/constants.js +1 -1
  42. package/dist/lib/syntax/syntax.js +549 -13
  43. package/dist/lib/validation/config.js +27 -1
  44. package/dist/lib/validation/match.js +16 -4
  45. package/dist/lib/validation/parser/parse.js +7 -3
  46. package/dist/node.js +8 -14
  47. package/dist/web.js +8 -14
  48. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,10 +1,126 @@
1
1
  # Changelog
2
2
 
3
- # v1.6.0
3
+ # v1.6.2
4
4
 
5
- - [x] added support for math function `tan()`.
5
+ ## Fix
6
+ - [x] fix base64 encoding error when inline sourcemap is enabled
6
7
 
7
8
  ## Improvements
9
+ - [x] handle division by zero in calc()
10
+ - [x] strip escaped new line from string
11
+ - [x] range media query : parse more expression as range query
12
+ - [x] handle NaN and Infinity in computation
13
+ - [x] parse \<url-modifiers\>
14
+
15
+ strip escaped new line from string
16
+ ```css
17
+ a[title="a not s\
18
+ o very long title"] {
19
+
20
+ color: blue;
21
+ ```
22
+
23
+ is escaped as
24
+
25
+ ```css
26
+ a[title="a not so very long title"] {
27
+ color: blue
28
+ }
29
+ ```
30
+ parsing range query is improved
31
+
32
+ ```css
33
+
34
+ @media (min-resolution: 2dppx) {}
35
+ ```
36
+ is parsed as
37
+
38
+ ```css
39
+ @media (resolution>=2x) {}
40
+ ```
41
+
42
+ NaN and Infinity are now handled in calc().
43
+
44
+ ```css
45
+
46
+ @media (min-width: 300px) and (max-width: 768px){
47
+ .s {
48
+
49
+ top: calc(NaN * 1px);
50
+ line-height: calc(NaN * 1);
51
+ color: alpha(from red/calc(0/0));
52
+ background: alpha(from red/calc(pi/0));
53
+ height: calc(1px * (NaN + 1));
54
+ width: calc(NaN + 1 + calc(NaN - 1 + calc(NaN / 1 + calc(NaN * 1))));
55
+ margin-left: calc(infinity + 1 + calc(infinity - 1 + calc(infinity / 1 + calc(infinity * 1))));
56
+ margin-right: calc(infinity + 1px + calc(infinity - 1 + calc(infinity / 1 + calc(infinity * 1))));
57
+
58
+ }
59
+
60
+ ```
61
+ is parsed as
62
+
63
+ ```css
64
+ @media (300px<=width<=768px) {
65
+ .s {
66
+ top: calc(NaN*1px);
67
+ line-height: calc(NaN);
68
+ color: alpha(from red/calc(NaN));
69
+ background: alpha(from red/calc(1/0));
70
+ height: calc(1px*NaN);
71
+ width: calc(NaN);
72
+ margin-left: calc(0/0);
73
+ margin-right: calc(0/0 + 1px)
74
+ }
75
+ }
76
+ ```
77
+ Parsing url() \<url-modifiers\> is supported.
78
+
79
+ ```css
80
+
81
+ .s {
82
+ background: url("star.gif" crossorigin(anonymous));
83
+ }
84
+ ```
85
+ is parsed as
86
+
87
+ ```css
88
+ .s {
89
+ background: url(star.gif crossorigin(anonymous))
90
+ }
91
+ ```
92
+
93
+ # v1.6.1
94
+
95
+ ## Fixes
96
+ - [x] fix bugs when computing math functions.
97
+ - [x] reduce array mutations
98
+ - [x] supporting additional shorthands: scroll-timeline, scroll-padding, scroll-margin.
99
+ - [x] do not minify transform function when the absolute angle is greater or equals to 360deg
100
+
101
+ ```css
102
+
103
+ a:hover {
104
+
105
+ transform: rotate(calc(2.5*pi * 1rad)) }
106
+ .now {
107
+ transform: translate(100px, 100px) rotate(1215deg) skewX(10deg);
108
+ }
109
+ ```
110
+ should be minified to
111
+ ```css
112
+ a:hover {
113
+ transform: rotate(450deg)
114
+ }
115
+ .now {
116
+ transform: translate(100px,100px)rotate(1215deg)skew(10deg)
117
+ }
118
+ ```
119
+
120
+ # v1.6.0
121
+
122
+ ## Improvements
123
+ - [x] added support for math function `tan()`.
8
124
  - [x] faster tokenizer
9
125
  - [x] ensure transform: rotate(360deg) is not minified to transform: none
10
126
  - [x] support input sourcemap from inline sourcemap file. This is only supported by the async parser.
package/README.md CHANGED
@@ -139,6 +139,7 @@ Try it [online](https://tbela99.github.io/css-parser/playground/)
139
139
  ## Sourcemap
140
140
 
141
141
  - [x] Sourcemap generation
142
+ - [x] Input sourcemap: when the input CSS comes from another tool, you can pass the sourcemap content to link the generated CSS positions to the original files.
142
143
 
143
144
  ## Computed shorthands properties
144
145
 
@@ -185,9 +186,9 @@ Try it [online](https://tbela99.github.io/css-parser/playground/)
185
186
  - [ ] place-content
186
187
  - [ ] place-items
187
188
  - [ ] place-self
188
- - [ ] scroll-margin
189
- - [ ] scroll-padding
190
- - [ ] scroll-timeline
189
+ - [x] scroll-margin
190
+ - [x] scroll-padding
191
+ - [x] scroll-timeline
191
192
  - [x] text-decoration
192
193
  - [x] text-emphasis
193
194
  - [x] transition