@tbela99/css-parser 2.3.1 → 2.3.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 (115) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +56 -26
  3. package/architecture.png +0 -0
  4. package/dist/ast/arena-node.js +32 -3
  5. package/dist/ast/arena.js +88 -10
  6. package/dist/ast/cache.js +1 -1
  7. package/dist/ast/features/calc.js +1 -1
  8. package/dist/ast/features/if.js +1 -1
  9. package/dist/ast/features/index.js +1 -1
  10. package/dist/ast/features/inlinecssvariables.js +1 -1
  11. package/dist/ast/features/mixin.js +1 -1
  12. package/dist/ast/features/prefix.js +1 -1
  13. package/dist/ast/features/shorthand.js +1 -1
  14. package/dist/ast/features/transform.js +1 -1
  15. package/dist/ast/features/type.js +1 -1
  16. package/dist/ast/math/expression.js +1 -1
  17. package/dist/ast/math/math.js +1 -1
  18. package/dist/ast/minify.js +131 -36
  19. package/dist/ast/mixins/custom-function.js +1 -1
  20. package/dist/ast/mixins/utils.js +1 -1
  21. package/dist/ast/mixins/variables.js +1 -1
  22. package/dist/ast/strings.js +26 -1
  23. package/dist/ast/transform/compute.js +6 -2
  24. package/dist/ast/transform/matrix.js +1 -1
  25. package/dist/ast/transform/minify.js +1 -1
  26. package/dist/ast/transform/perspective.js +1 -1
  27. package/dist/ast/transform/rotate.js +1 -1
  28. package/dist/ast/transform/scale.js +1 -1
  29. package/dist/ast/transform/skew.js +1 -1
  30. package/dist/ast/transform/translate.js +1 -1
  31. package/dist/ast/transform/utils.js +1 -1
  32. package/dist/ast/types.js +22 -2
  33. package/dist/ast/walk.js +1 -1
  34. package/dist/data/properties.json.js +1 -1
  35. package/dist/data/validation.json.js +1 -1
  36. package/dist/fs/resolve.js +1 -1
  37. package/dist/index-umd-web.js +1084 -293
  38. package/dist/index.d.ts +597 -686
  39. package/dist/node.js +14 -8
  40. package/dist/parser/declaration/list.js +8 -5
  41. package/dist/parser/declaration/map.js +1 -1
  42. package/dist/parser/declaration/set.js +1 -1
  43. package/dist/parser/input.js +62 -4
  44. package/dist/parser/linesmap.js +1 -1
  45. package/dist/parser/parse.js +121 -13
  46. package/dist/parser/source.js +1 -1
  47. package/dist/parser/tokenize.js +161 -19
  48. package/dist/parser/utils/angle.js +1 -1
  49. package/dist/parser/utils/at-rule-container.js +1 -1
  50. package/dist/parser/utils/at-rule-font-feature-values.js +1 -1
  51. package/dist/parser/utils/at-rule-generic.js +1 -1
  52. package/dist/parser/utils/at-rule-import.js +1 -1
  53. package/dist/parser/utils/at-rule-media.js +42 -2
  54. package/dist/parser/utils/at-rule-support.js +1 -1
  55. package/dist/parser/utils/at-rule-when-else.js +1 -1
  56. package/dist/parser/utils/at-rule.js +1 -1
  57. package/dist/parser/utils/base64.js +1 -1
  58. package/dist/parser/utils/cache.js +1 -1
  59. package/dist/parser/utils/canonical.js +1 -1
  60. package/dist/parser/utils/codes.js +1 -1
  61. package/dist/parser/utils/config.js +1 -1
  62. package/dist/parser/utils/declaration.js +1 -1
  63. package/dist/parser/utils/eq.js +1 -1
  64. package/dist/parser/utils/hash.js +1 -1
  65. package/dist/parser/utils/selector.js +98 -6
  66. package/dist/parser/utils/text.js +1 -1
  67. package/dist/parser/utils/token.js +1 -1
  68. package/dist/parser/utils/type.js +1 -1
  69. package/dist/printer/lib/codec.js +1 -1
  70. package/dist/printer/render.js +5 -7
  71. package/dist/printer/result.js +3 -1
  72. package/dist/printer/sourcemap.js +1 -1
  73. package/dist/printer/writer.js +1 -1
  74. package/dist/syntax/color/a98rgb.js +1 -1
  75. package/dist/syntax/color/alpha.js +1 -1
  76. package/dist/syntax/color/cmyk.js +1 -1
  77. package/dist/syntax/color/color-mix.js +1 -1
  78. package/dist/syntax/color/color.js +1 -1
  79. package/dist/syntax/color/hex.js +1 -1
  80. package/dist/syntax/color/hsl.js +12 -4
  81. package/dist/syntax/color/hwb.js +9 -3
  82. package/dist/syntax/color/lab.js +1 -1
  83. package/dist/syntax/color/lch.js +1 -1
  84. package/dist/syntax/color/oklab.js +1 -1
  85. package/dist/syntax/color/oklch.js +2 -2
  86. package/dist/syntax/color/p3.js +1 -1
  87. package/dist/syntax/color/prophotorgb.js +1 -1
  88. package/dist/syntax/color/rec2020.js +1 -1
  89. package/dist/syntax/color/relative-color.js +1 -1
  90. package/dist/syntax/color/rgb.js +1 -1
  91. package/dist/syntax/color/srgb.js +3 -2
  92. package/dist/syntax/color/utils/color-type.js +1 -1
  93. package/dist/syntax/color/utils/colorspace.js +1 -1
  94. package/dist/syntax/color/utils/components.js +1 -1
  95. package/dist/syntax/color/utils/distance.js +1 -1
  96. package/dist/syntax/color/utils/make-color.js +1 -1
  97. package/dist/syntax/color/utils/matrix.js +1 -1
  98. package/dist/syntax/color/xyz.js +1 -1
  99. package/dist/syntax/color/xyzd50.js +1 -1
  100. package/dist/syntax/constants.js +2 -2
  101. package/dist/syntax/syntax.js +1 -1
  102. package/dist/types.js +1 -1
  103. package/dist/utils/sync.js +1 -1
  104. package/dist/validation/compiled/builtins.js +1 -1
  105. package/dist/validation/compiled/runtime.js +1 -1
  106. package/dist/validation/compiled/syntaxes.js +1 -1
  107. package/dist/validation/config.js +1 -1
  108. package/dist/validation/first.js +1 -1
  109. package/dist/validation/match.js +77 -4
  110. package/dist/validation/parser/parse.js +1 -1
  111. package/dist/validation/parser/typedef.js +4 -1
  112. package/dist/validation/utils/list.js +1 -1
  113. package/dist/version.js +2 -2
  114. package/dist/web.js +13 -6
  115. package/package.json +15 -6
@@ -2,7 +2,7 @@
2
2
  CSS parser, minifier and validator for node, deno, bun and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 2.3.1
5
+ Version: 2.3.2
6
6
  License: MIT
7
7
  */
8
8
  import { EnumToken } from '../../ast/types.js';
package/dist/version.js CHANGED
@@ -2,12 +2,12 @@
2
2
  CSS parser, minifier and validator for node, deno, bun and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 2.3.1
5
+ Version: 2.3.2
6
6
  License: MIT
7
7
  */
8
8
  /**
9
9
  * Version number
10
10
  */
11
- const version = "2.3.1";
11
+ const version = "2.3.2";
12
12
 
13
13
  export { version };
package/dist/web.js CHANGED
@@ -2,7 +2,7 @@
2
2
  CSS parser, minifier and validator for node, deno, bun and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 2.3.1
5
+ Version: 2.3.2
6
6
  License: MIT
7
7
  */
8
8
  import { doParse, doParseSync } from './parser/parse.js';
@@ -11,9 +11,9 @@ import { doRender } from './printer/render.js';
11
11
  export { renderValue } from './printer/render.js';
12
12
  import { TransformResult, RenderResult } from './printer/result.js';
13
13
  import { ModuleScopeEnumOptions } from './ast/types.js';
14
- export { ColorType, EnumAstNodeStatus, EnumToken, ModuleCaseTransformEnum, WalkerEvent, WalkerOptionEnum } from './ast/types.js';
14
+ export { ColorType, EnumAstNodeStatus, EnumToken, MergeRulesEnum, ModuleCaseTransformEnum, WalkerEvent, WalkerOptionEnum } from './ast/types.js';
15
15
  import { createParseInfo, Tokenizer } from './parser/tokenize.js';
16
- import { isCssInput } from './parser/input.js';
16
+ import { setStreamSize, responseSize, isCssInput } from './parser/input.js';
17
17
  import { matchUrl, resolve, dirname } from './fs/resolve.js';
18
18
  import { ResponseType } from './types.js';
19
19
  import { SourceFile } from './parser/source.js';
@@ -25,6 +25,8 @@ export { Arena, AstArena, TokenField, arenaColumns } from './ast/arena.js';
25
25
  export { ARENA, ARENAID, AstArenaNode } from './ast/arena-node.js';
26
26
  export { PropertyList } from './parser/declaration/list.js';
27
27
  export { SourceMap } from './printer/sourcemap.js';
28
+ export { ValidationTokenEnum } from './validation/parser/typedef.js';
29
+ export { LOC } from './syntax/constants.js';
28
30
  export { FeatureWalkMode } from './ast/features/type.js';
29
31
  export { parseSyntax } from './validation/parser/parse.js';
30
32
  export { version } from './version.js';
@@ -69,7 +71,10 @@ async function load(url, currentDirectory = ".", responseType = false) {
69
71
  if (responseType === ResponseType.JSON) {
70
72
  return response.json();
71
73
  }
72
- return responseType === ResponseType.ReadableStream ? response.body : response.text();
74
+ // the size of the body: the parser allocates its buffers once
75
+ return responseType === ResponseType.ReadableStream
76
+ ? setStreamSize(response.body, responseSize(response))
77
+ : response.text();
73
78
  });
74
79
  }
75
80
  /**
@@ -206,7 +211,8 @@ function transformSync(...args) {
206
211
  validateSyncArguments(options);
207
212
  }
208
213
  // the options of the caller are not modified: they may be reused
209
- options = { minify: true, removeEmpty: true, removeCharset: true, ...options };
214
+ // the fast mode sets the default value of minify (see fastModeOptions)
215
+ options = { ...(options?.fastMode ? null : { minify: true }), removeEmpty: true, removeCharset: true, ...options };
210
216
  const startTime = performance.now();
211
217
  const parseResult = parseSyncInput(stream, options);
212
218
  let mapping = null;
@@ -353,7 +359,8 @@ async function transform(...args) {
353
359
  stream = input;
354
360
  }
355
361
  }
356
- options = { minify: true, removeEmpty: true, removeCharset: true, ...options };
362
+ // the fast mode sets the default value of minify (see fastModeOptions)
363
+ options = { ...(options?.fastMode ? null : { minify: true }), removeEmpty: true, removeCharset: true, ...options };
357
364
  const startTime = performance.now();
358
365
  return parseInput(stream, options).then((parseResult) => {
359
366
  let mapping = null;
package/package.json CHANGED
@@ -1,11 +1,20 @@
1
1
  {
2
2
  "name": "@tbela99/css-parser",
3
3
  "description": "CSS parser, minifier and validator for node, deno, bun and the browser",
4
- "version": "2.3.1",
4
+ "version": "2.3.2",
5
5
  "exports": {
6
- ".": "./dist/node.js",
7
- "./node": "./dist/node.js",
8
- "./web": "./dist/web.js"
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "default": "./dist/node.js"
9
+ },
10
+ "./node": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/node.js"
13
+ },
14
+ "./web": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/web.js"
17
+ }
9
18
  },
10
19
  "type": "module",
11
20
  "typings": "dist/index.d.ts",
@@ -69,7 +78,7 @@
69
78
  "@types/chai": "^5.2.3",
70
79
  "@types/chai-as-promised": "^8.0.2",
71
80
  "@types/mocha": "^10.0.10",
72
- "@types/node": "^26.6.6",
81
+ "@types/node": "^26.6.11",
73
82
  "@types/web": "^0.0.367",
74
83
  "@typescript/typescript6": "^6.0.2",
75
84
  "@web/test-runner": "^1.0.1",
@@ -80,7 +89,7 @@
80
89
  "markdown-it-task-lists": "^2.1.1",
81
90
  "mocha": "^12.0.3",
82
91
  "playwright": "^1.65.1",
83
- "rollup": "^4.68.5",
92
+ "rollup": "^4.68.8",
84
93
  "rollup-plugin-dts": "^6.5.1",
85
94
  "rollup-plugin-version-injector": "^1.3.3",
86
95
  "superc8": "^12.7.0",