@tbela99/css-parser 1.3.3 → 1.3.4

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 +7 -0
  2. package/README.md +20 -17
  3. package/dist/index-umd-web.js +1031 -571
  4. package/dist/index.cjs +1031 -566
  5. package/dist/index.d.ts +247 -171
  6. package/dist/lib/ast/expand.js +5 -10
  7. package/dist/lib/ast/features/calc.js +3 -2
  8. package/dist/lib/ast/features/inlinecssvariables.js +5 -3
  9. package/dist/lib/ast/features/prefix.js +1 -1
  10. package/dist/lib/ast/features/shorthand.js +1 -0
  11. package/dist/lib/ast/features/transform.js +13 -19
  12. package/dist/lib/ast/minify.js +5 -2
  13. package/dist/lib/ast/transform/compute.js +2 -4
  14. package/dist/lib/ast/transform/matrix.js +20 -20
  15. package/dist/lib/ast/transform/minify.js +105 -12
  16. package/dist/lib/ast/transform/rotate.js +11 -11
  17. package/dist/lib/ast/transform/scale.js +6 -6
  18. package/dist/lib/ast/transform/skew.js +4 -4
  19. package/dist/lib/ast/transform/translate.js +3 -3
  20. package/dist/lib/ast/transform/utils.js +30 -37
  21. package/dist/lib/ast/types.js +14 -2
  22. package/dist/lib/ast/walk.js +61 -49
  23. package/dist/lib/fs/resolve.js +6 -3
  24. package/dist/lib/parser/declaration/list.js +3 -1
  25. package/dist/lib/parser/parse.js +345 -305
  26. package/dist/lib/parser/tokenize.js +11 -13
  27. package/dist/lib/renderer/render.js +2 -2
  28. package/dist/lib/syntax/syntax.js +36 -18
  29. package/dist/lib/validation/at-rules/container.js +11 -0
  30. package/dist/lib/validation/at-rules/counter-style.js +11 -0
  31. package/dist/lib/validation/at-rules/font-feature-values.js +11 -0
  32. package/dist/lib/validation/at-rules/keyframes.js +11 -0
  33. package/dist/lib/validation/at-rules/layer.js +11 -0
  34. package/dist/lib/validation/at-rules/media.js +11 -0
  35. package/dist/lib/validation/at-rules/page-margin-box.js +11 -0
  36. package/dist/lib/validation/at-rules/page.js +11 -0
  37. package/dist/lib/validation/at-rules/supports.js +11 -0
  38. package/dist/lib/validation/at-rules/when.js +11 -0
  39. package/dist/lib/validation/config.js +0 -2
  40. package/dist/lib/validation/config.json.js +21 -1
  41. package/dist/lib/validation/parser/parse.js +53 -2
  42. package/dist/lib/validation/syntax.js +199 -36
  43. package/dist/node.js +17 -12
  44. package/dist/web.js +11 -11
  45. package/package.json +6 -3
  46. package/dist/lib/validation/parser/types.js +0 -54
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.3.4
4
+
5
+ - [x] make streaming optional #109
6
+ - [x] patch at-rule syntax for @font-feature-value #110
7
+ - [x] support percentage in transform() and scale() #111
8
+ - [x] allow arrays in visitor definition #112
9
+
3
10
  ## v1.3.3
4
11
 
5
12
  - [x] relative color computation bug #105
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # css-parser
6
6
 
7
- CSS parser and minifier for node and the browser
7
+ CSS parser, minifier and validator for node and the browser
8
8
 
9
9
  ## Installation
10
10
 
@@ -101,7 +101,7 @@ Javascript module from cdn
101
101
 
102
102
  <script type="module">
103
103
 
104
- import {transform} from 'https://esm.sh/@tbela99/css-parser@1.3.3/web';
104
+ import {transform} from 'https://esm.sh/@tbela99/css-parser@1.3.4/web';
105
105
 
106
106
  const css = `
107
107
  .s {
@@ -126,7 +126,7 @@ Javascript umd module from cdn
126
126
 
127
127
  ```html
128
128
 
129
- <script src="https://unpkg.com/@tbela99/css-parser@1.3.2/dist/index-umd-web.js"></script>
129
+ <script src="https://unpkg.com/@tbela99/css-parser@1.3.4/dist/index-umd-web.js"></script>
130
130
  <script>
131
131
 
132
132
  (async () => {
@@ -764,6 +764,7 @@ result
764
764
  # Node Walker
765
765
 
766
766
  ```javascript
767
+
767
768
  import {walk} from '@tbela99/css-parser';
768
769
 
769
770
  for (const {node, parent, root} of walk(ast)) {
@@ -923,7 +924,8 @@ const css = `
923
924
  }
924
925
  `;
925
926
 
926
- console.debug(await transform(css, options));
927
+ const result = await transform(css, options);
928
+ console.debug(result.code);
927
929
 
928
930
  // .foo{transform:scale(calc(40/3))}
929
931
  ```
@@ -934,9 +936,7 @@ the visitor is called only on 'height' declarations
934
936
 
935
937
  ```typescript
936
938
 
937
- import {AstDeclaration, LengthToken, ParserOptions} from "../src/@types";
938
- import {EnumToken} from "../src/lib";
939
- import {transform} from "../src/node";
939
+ import {AstDeclaration, EnumToken, LengthToken, ParserOptions, transform} from '@tbela99/css-parser';
940
940
 
941
941
  const options: ParserOptions = {
942
942
 
@@ -978,7 +978,8 @@ color: lch(from peru calc(l * 0.8) calc(c * 0.7) calc(h + 180))
978
978
  }
979
979
  `;
980
980
 
981
- console.debug(await transform(css, options));
981
+ const result = await transform(css, options);
982
+ console.debug(result.code);
982
983
 
983
984
  // .foo{height:calc(40px/3);width:3px}.selector{color:#0880b0}
984
985
 
@@ -1019,7 +1020,8 @@ const css = `
1019
1020
  }
1020
1021
  `;
1021
1022
 
1022
- console.debug(await transform(css, options));
1023
+ const result = await transform(css, options);
1024
+ console.debug(result.code);
1023
1025
 
1024
1026
  // .foo{height:calc(40px/3)}
1025
1027
 
@@ -1060,7 +1062,8 @@ const css = `
1060
1062
  }
1061
1063
  `;
1062
1064
 
1063
- console.debug(await transform(css, options));
1065
+ const result = await transform(css, options);
1066
+ console.debug(result.code);
1064
1067
 
1065
1068
  // .foo{height:calc(40px/3)}
1066
1069
 
@@ -1079,10 +1082,10 @@ const options: ParserOptions = {
1079
1082
 
1080
1083
  visitor: {
1081
1084
 
1082
-
1083
1085
  Rule(node: AstRule): AstRule {
1084
1086
 
1085
- return {...node, sel: '.foo,.bar,.fubar'};
1087
+ node.sel = '.foo,.bar,.fubar'
1088
+ return node;
1086
1089
  }
1087
1090
  }
1088
1091
  };
@@ -1095,7 +1098,8 @@ const css = `
1095
1098
  }
1096
1099
  `;
1097
1100
 
1098
- console.debug(await transform(css, options));
1101
+ const result = await transform(css, options);
1102
+ console.debug(result.code);
1099
1103
 
1100
1104
  // .foo,.bar,.fubar{height:calc(40px/3)}
1101
1105
 
@@ -1107,9 +1111,7 @@ Adding declarations to any rule
1107
1111
 
1108
1112
  ```typescript
1109
1113
 
1110
- import {transform} from "../src/node";
1111
- import {AstRule, ParserOptions} from "../src/@types";
1112
- import {parseDeclarations} from "../src/lib";
1114
+ import {AstRule, parseDeclarations, ParserOptions, transform} from '@tbela99/css-parser';
1113
1115
 
1114
1116
  const options: ParserOptions = {
1115
1117
 
@@ -1135,7 +1137,8 @@ const css = `
1135
1137
  }
1136
1138
  `;
1137
1139
 
1138
- console.debug(await transform(css, options));
1140
+ const result = await transform(css, options);
1141
+ console.debug(result.code);
1139
1142
 
1140
1143
  // .foo{width:3px}
1141
1144