@tbela99/css-parser 2.1.0 → 2.2.0

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 (125) hide show
  1. package/CHANGELOG.md +42 -1
  2. package/README.md +14 -7
  3. package/architecture.png +0 -0
  4. package/dist/{src/data → data}/properties.json.js +86 -2
  5. package/dist/{src/data → data}/validation.json.js +5 -2
  6. package/dist/index-umd-web.js +10738 -4359
  7. package/dist/index.d.ts +734 -100
  8. package/dist/{src/lib → lib}/ast/arena-node.js +10 -10
  9. package/dist/{src/lib → lib}/ast/arena.js +304 -139
  10. package/dist/{src/lib → lib}/ast/cache.js +2 -2
  11. package/dist/{src/lib → lib}/ast/features/calc.js +11 -9
  12. package/dist/{src/lib → lib}/ast/features/if.js +6 -6
  13. package/dist/{src/lib → lib}/ast/features/index.js +3 -2
  14. package/dist/{src/lib → lib}/ast/features/inlinecssvariables.js +12 -10
  15. package/dist/lib/ast/features/mixin.js +953 -0
  16. package/dist/{src/lib → lib}/ast/features/prefix.js +39 -39
  17. package/dist/lib/ast/features/shorthand.js +129 -0
  18. package/dist/lib/ast/features/transform.js +188 -0
  19. package/dist/{src/lib → lib}/ast/features/type.js +2 -2
  20. package/dist/{src/lib → lib}/ast/math/expression.js +24 -24
  21. package/dist/{src/lib → lib}/ast/math/math.js +2 -2
  22. package/dist/{src/lib → lib}/ast/minify.js +745 -201
  23. package/dist/lib/ast/mixins/custom-function.js +393 -0
  24. package/dist/lib/ast/mixins/utils.js +53 -0
  25. package/dist/lib/ast/mixins/variables.js +678 -0
  26. package/dist/lib/ast/strings.js +906 -0
  27. package/dist/lib/ast/transform/compute.js +560 -0
  28. package/dist/lib/ast/transform/matrix.js +67 -0
  29. package/dist/lib/ast/transform/minify.js +325 -0
  30. package/dist/lib/ast/transform/perspective.js +24 -0
  31. package/dist/{src/lib → lib}/ast/transform/rotate.js +16 -7
  32. package/dist/lib/ast/transform/scale.js +43 -0
  33. package/dist/lib/ast/transform/skew.js +38 -0
  34. package/dist/lib/ast/transform/translate.js +56 -0
  35. package/dist/lib/ast/transform/utils.js +390 -0
  36. package/dist/{src/lib → lib}/ast/types.js +2 -2
  37. package/dist/{src/lib → lib}/ast/walk.js +2 -2
  38. package/dist/{src/lib → lib}/fs/resolve.js +2 -2
  39. package/dist/{src/lib → lib}/parser/declaration/list.js +25 -8
  40. package/dist/{src/lib → lib}/parser/declaration/map.js +15 -15
  41. package/dist/{src/lib → lib}/parser/declaration/set.js +5 -5
  42. package/dist/{src/lib → lib}/parser/input.js +18 -3
  43. package/dist/{src/lib → lib}/parser/linesmap.js +2 -2
  44. package/dist/{src/lib → lib}/parser/parse.js +425 -258
  45. package/dist/{src/lib → lib}/parser/source.js +2 -2
  46. package/dist/{src/lib → lib}/parser/tokenize.js +480 -312
  47. package/dist/{src/lib → lib}/parser/utils/angle.js +3 -3
  48. package/dist/{src/lib → lib}/parser/utils/at-rule-container.js +12 -12
  49. package/dist/{src/lib → lib}/parser/utils/at-rule-font-feature-values.js +3 -3
  50. package/dist/{src/lib → lib}/parser/utils/at-rule-generic.js +7 -7
  51. package/dist/{src/lib → lib}/parser/utils/at-rule-import.js +10 -10
  52. package/dist/{src/lib → lib}/parser/utils/at-rule-media.js +14 -14
  53. package/dist/{src/lib → lib}/parser/utils/at-rule-support.js +9 -14
  54. package/dist/{src/lib → lib}/parser/utils/at-rule-when-else.js +6 -6
  55. package/dist/{src/lib → lib}/parser/utils/at-rule.js +3 -3
  56. package/dist/{src/lib → lib}/parser/utils/base64.js +2 -2
  57. package/dist/lib/parser/utils/cache.js +53 -0
  58. package/dist/lib/parser/utils/canonical.js +78 -0
  59. package/dist/lib/parser/utils/codes.js +93 -0
  60. package/dist/{src/lib → lib}/parser/utils/config.js +2 -2
  61. package/dist/{src/lib → lib}/parser/utils/declaration.js +31 -26
  62. package/dist/{src/lib → lib}/parser/utils/eq.js +2 -2
  63. package/dist/{src/lib → lib}/parser/utils/hash.js +2 -2
  64. package/dist/{src/lib → lib}/parser/utils/selector.js +305 -63
  65. package/dist/{src/lib → lib}/parser/utils/text.js +2 -2
  66. package/dist/{src/lib → lib}/parser/utils/token.js +2 -2
  67. package/dist/{src/lib → lib}/parser/utils/type.js +9 -7
  68. package/dist/{src/lib → lib}/printer/render.js +420 -152
  69. package/dist/lib/printer/result.js +148 -0
  70. package/dist/{src/lib → lib}/printer/sourcemap/lib/codec.js +2 -2
  71. package/dist/{src/lib → lib}/printer/sourcemap/sourcemap.js +2 -2
  72. package/dist/lib/printer/writer.js +252 -0
  73. package/dist/{src/lib → lib}/syntax/color/a98rgb.js +2 -2
  74. package/dist/{src/lib → lib}/syntax/color/alpha.js +10 -10
  75. package/dist/{src/lib → lib}/syntax/color/cmyk.js +2 -2
  76. package/dist/{src/lib → lib}/syntax/color/color-mix.js +18 -18
  77. package/dist/{src/lib → lib}/syntax/color/color.js +18 -18
  78. package/dist/{src/lib → lib}/syntax/color/hex.js +3 -3
  79. package/dist/{src/lib → lib}/syntax/color/hsl.js +2 -2
  80. package/dist/{src/lib → lib}/syntax/color/hwb.js +2 -2
  81. package/dist/{src/lib → lib}/syntax/color/lab.js +2 -2
  82. package/dist/{src/lib → lib}/syntax/color/lch.js +2 -2
  83. package/dist/{src/lib → lib}/syntax/color/oklab.js +2 -2
  84. package/dist/{src/lib → lib}/syntax/color/oklch.js +3 -3
  85. package/dist/{src/lib → lib}/syntax/color/p3.js +2 -2
  86. package/dist/{src/lib → lib}/syntax/color/prophotorgb.js +2 -2
  87. package/dist/{src/lib → lib}/syntax/color/rec2020.js +2 -2
  88. package/dist/{src/lib → lib}/syntax/color/relative-color.js +14 -14
  89. package/dist/{src/lib → lib}/syntax/color/rgb.js +4 -4
  90. package/dist/{src/lib → lib}/syntax/color/srgb.js +5 -5
  91. package/dist/{src/lib → lib}/syntax/color/utils/color-type.js +4 -4
  92. package/dist/{src/lib → lib}/syntax/color/utils/colorspace.js +10 -10
  93. package/dist/{src/lib → lib}/syntax/color/utils/components.js +5 -5
  94. package/dist/{src/lib → lib}/syntax/color/utils/distance.js +2 -2
  95. package/dist/{src/lib → lib}/syntax/color/utils/make-color.js +3 -3
  96. package/dist/{src/lib → lib}/syntax/color/utils/matrix.js +2 -2
  97. package/dist/{src/lib → lib}/syntax/color/xyz.js +2 -2
  98. package/dist/{src/lib → lib}/syntax/color/xyzd50.js +2 -2
  99. package/dist/{src/lib → lib}/syntax/constants.js +26 -3
  100. package/dist/{src/lib → lib}/syntax/syntax.js +37 -29
  101. package/dist/{src/lib → lib}/validation/config.js +23 -10
  102. package/dist/lib/validation/first.js +571 -0
  103. package/dist/{src/lib → lib}/validation/match.js +292 -150
  104. package/dist/{src/lib → lib}/validation/parser/parse.js +2 -2
  105. package/dist/{src/lib → lib}/validation/parser/typedef.js +2 -2
  106. package/dist/{src/lib → lib}/validation/utils/list.js +3 -19
  107. package/dist/{src/node.js → node.js} +52 -34
  108. package/dist/{src/types.js → types.js} +2 -2
  109. package/dist/{src/utils → utils}/sync.js +10 -5
  110. package/dist/version.d.ts +4 -0
  111. package/dist/version.js +13 -0
  112. package/dist/{src/web.js → web.js} +47 -34
  113. package/package.json +12 -12
  114. package/dist/package.json.js +0 -10
  115. package/dist/src/lib/ast/features/shorthand.js +0 -95
  116. package/dist/src/lib/ast/features/transform.js +0 -90
  117. package/dist/src/lib/ast/transform/compute.js +0 -362
  118. package/dist/src/lib/ast/transform/matrix.js +0 -88
  119. package/dist/src/lib/ast/transform/minify.js +0 -267
  120. package/dist/src/lib/ast/transform/perspective.js +0 -16
  121. package/dist/src/lib/ast/transform/scale.js +0 -39
  122. package/dist/src/lib/ast/transform/skew.js +0 -30
  123. package/dist/src/lib/ast/transform/translate.js +0 -39
  124. package/dist/src/lib/ast/transform/utils.js +0 -287
  125. package/dist/src/lib/parser/utils/cache.js +0 -54
@@ -0,0 +1,78 @@
1
+ /*
2
+ CSS parser, minifier and validator for node, deno, bun and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 2.2.0
6
+ License: MIT
7
+ */
8
+ /**
9
+ * Canonical strings: the spellings of the known units and function names (`dB`, `translateX`, ...).
10
+ *
11
+ * The canonical strings are registered once, when the tables of the tokenizer are built: they are stored in a single
12
+ * text. A canonical string is a range of this text: the string table of the arena references the range
13
+ * (see `StringSource.Canonical`), no string is created when a token is interned with its canonical spelling.
14
+ *
15
+ * @module
16
+ * @internal
17
+ */
18
+ /**
19
+ * offset of the registered strings in {@link text}
20
+ */
21
+ const offsets = new Map();
22
+ /**
23
+ * registered strings, concatenated
24
+ */
25
+ let text = "";
26
+ /**
27
+ * code units of {@link text}
28
+ */
29
+ let codes = new Uint16Array(0);
30
+ /**
31
+ * register a canonical string
32
+ * @param str
33
+ * @returns the range of the string in the canonical text, packed: `start << 8 | length` (see {@link canonicalStart}
34
+ * and {@link canonicalEnd})
35
+ */
36
+ function registerCanonical(str) {
37
+ let start = offsets.get(str);
38
+ if (start === undefined) {
39
+ start = text.length;
40
+ offsets.set(str, start);
41
+ text += str;
42
+ }
43
+ return (start << 8) | str.length;
44
+ }
45
+ /**
46
+ * start of a packed range
47
+ * @param range
48
+ */
49
+ function canonicalStart(range) {
50
+ return range >>> 8;
51
+ }
52
+ /**
53
+ * end of a packed range
54
+ * @param range
55
+ */
56
+ function canonicalEnd(range) {
57
+ return (range >>> 8) + (range & 0xff);
58
+ }
59
+ /**
60
+ * the canonical text
61
+ */
62
+ function canonicalText() {
63
+ return text;
64
+ }
65
+ /**
66
+ * the code units of the canonical text
67
+ */
68
+ function canonicalCodes() {
69
+ if (codes.length !== text.length) {
70
+ codes = new Uint16Array(text.length);
71
+ for (let i = 0; i < text.length; i++) {
72
+ codes[i] = text.charCodeAt(i);
73
+ }
74
+ }
75
+ return codes;
76
+ }
77
+
78
+ export { canonicalCodes, canonicalEnd, canonicalStart, canonicalText, registerCanonical };
@@ -0,0 +1,93 @@
1
+ /*
2
+ CSS parser, minifier and validator for node, deno, bun and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 2.2.0
6
+ License: MIT
7
+ */
8
+ /**
9
+ * Hashing and comparison of strings and of ranges of code units, without creating strings.
10
+ *
11
+ * The tokenizer reads the code units of the css source (see `toCodeUnits()`): the values of the tokens are ranges of
12
+ * the code units. The tables of the tokenizer and the string table of the arena are keyed by the hash of the code units:
13
+ * a string and a range of code units with the same content have the same hash. When the hashes are equal, the code
14
+ * units are compared: the hash is 30 bits, different strings may have the same hash.
15
+ *
16
+ * @module
17
+ * @internal
18
+ */
19
+ /**
20
+ * FNV-1a offset basis
21
+ */
22
+ const FNV_OFFSET = 0x811c9dc5 | 0;
23
+ /**
24
+ * FNV-1a prime
25
+ */
26
+ const FNV_PRIME = 0x01000193;
27
+ /**
28
+ * the hashes are 30 bits integers: small integers are not boxed
29
+ */
30
+ const HASH_MASK = 0x3fffffff;
31
+ /**
32
+ * KELVIN SIGN: the only code unit, other than the ascii uppercase letters, lowercased to an ascii letter by
33
+ * `toLowerCase()` (`k`)
34
+ */
35
+ const KELVIN_SIGN = 0x212a;
36
+ /**
37
+ * hash of a string (case sensitive). same value as {@link hashRange} for the same code units
38
+ * @param str
39
+ */
40
+ function hashString(str) {
41
+ let hash = FNV_OFFSET;
42
+ for (let i = 0; i < str.length; i++) {
43
+ hash = Math.imul(hash ^ str.charCodeAt(i), FNV_PRIME);
44
+ }
45
+ return hash & HASH_MASK;
46
+ }
47
+ /**
48
+ * hash of a range of code units (case sensitive). same value as {@link hashString} for the same code units
49
+ * @param codes
50
+ * @param start
51
+ * @param end
52
+ */
53
+ function hashRange(codes, start, end) {
54
+ let hash = FNV_OFFSET;
55
+ for (let i = start; i < end; i++) {
56
+ hash = Math.imul(hash ^ codes[i], FNV_PRIME);
57
+ }
58
+ return hash & HASH_MASK;
59
+ }
60
+ /**
61
+ * lowercase ascii code of a code unit, like `toLowerCase()` for the keys of the tokenizer tables: the ascii uppercase
62
+ * letters and the kelvin sign are lowercased. -1 for the other non ascii code units: they do not match an ascii key
63
+ * @param code
64
+ */
65
+ function lowerAscii(code) {
66
+ if (code >= 0x41 && code <= 0x5a) {
67
+ return code + 32;
68
+ }
69
+ if (code > 0x7f) {
70
+ return code === KELVIN_SIGN ? 0x6b : -1;
71
+ }
72
+ return code;
73
+ }
74
+ /**
75
+ * hash of a range of code units, ignoring the case (see {@link lowerAscii}). -1 when the range contains a non ascii
76
+ * character that cannot match an ascii key
77
+ * @param codes
78
+ * @param start
79
+ * @param end
80
+ */
81
+ function hashRangeLower(codes, start, end) {
82
+ let hash = FNV_OFFSET;
83
+ for (let i = start; i < end; i++) {
84
+ const code = lowerAscii(codes[i]);
85
+ if (code === -1) {
86
+ return -1;
87
+ }
88
+ hash = Math.imul(hash ^ code, FNV_PRIME);
89
+ }
90
+ return hash & HASH_MASK;
91
+ }
92
+
93
+ export { hashRange, hashRangeLower, hashString, lowerAscii };
@@ -1,8 +1,8 @@
1
1
  /*
2
- CSS parser, minifier and validator for node and the browser
2
+ CSS parser, minifier and validator for node, deno, bun and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 2.1.0
5
+ Version: 2.2.0
6
6
  License: MIT
7
7
  */
8
8
  import config from '../../../data/properties.json.js';
@@ -1,14 +1,14 @@
1
1
  /*
2
- CSS parser, minifier and validator for node and the browser
2
+ CSS parser, minifier and validator for node, deno, bun and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 2.1.0
5
+ Version: 2.2.0
6
6
  License: MIT
7
7
  */
8
8
  import { EnumToken, ColorType, EnumAstNodeStatus } from '../../ast/types.js';
9
9
  import { TokenField } from '../../ast/arena.js';
10
- import { tokensfuncDefMap, COLORS_NAMES, nonStandardColors, systemColors, deprecatedSystemColors, tokensMap, trimTokenSpace } from '../../syntax/constants.js';
11
- import { renamedStandardProperties, isColor, parseColor, isWhiteSpace } from '../../syntax/syntax.js';
10
+ import { isFunctionDefType, COLORS_NAMES, nonStandardColors, systemColors, deprecatedSystemColors, tokensfuncDefMap, tokensMap, trimTokenSpace } from '../../syntax/constants.js';
11
+ import { renamedStandardProperties, isColorName, isColor, parseColor, isWhiteSpace } from '../../syntax/syntax.js';
12
12
  import { getSyntaxRule, getParsedSyntax } from '../../validation/config.js';
13
13
  import { matchDeclarationSyntax, trimArray } from '../../validation/match.js';
14
14
  import { ValidationSyntaxGroupEnum, ValidationTokenEnum } from '../../validation/parser/typedef.js';
@@ -83,7 +83,8 @@ function parseColorIdent(arena, value) {
83
83
  * @param errors
84
84
  */
85
85
  function createDeclarationNode(arena, name, tokens, state, errors) {
86
- const node = arena.createDeclaration(EnumToken.DeclarationNodeType, arena.strings[arena.stringValue[name]], tokens, state, errors);
86
+ // the name is an interned string id: the string is not created
87
+ const node = arena.createDeclaration(EnumToken.DeclarationNodeType, arena.stringValue[name], tokens, state, errors);
87
88
  arena.copyLocation(node, name);
88
89
  return node;
89
90
  }
@@ -98,10 +99,10 @@ function createDeclarationNode(arena, name, tokens, state, errors) {
98
99
  function parseDeclaration(arena, tokens, parent, options, errors) {
99
100
  const name = tokens.shift();
100
101
  let i;
101
- let nam = arena.strings[arena.stringValue[name]];
102
+ let nam = arena.resolveString(arena.stringValue[name]);
102
103
  // parent at-rule name
103
104
  const isAtRule = parent != null && typeof parent === "number" && arena.dataTypes[parent] === EnumToken.AtRuleNodeType;
104
- const parentNam = isAtRule ? arena.strings[arena.name[parent]] : null;
105
+ const parentNam = isAtRule ? arena.resolveString(arena.name[parent]) : null;
105
106
  let rules = null;
106
107
  let syntaxRules = null;
107
108
  let success = true;
@@ -195,7 +196,10 @@ function parseDeclaration(arena, tokens, parent, options, errors) {
195
196
  }
196
197
  }
197
198
  // inlined: arena.typeOf(name)
198
- if (tokens.length === 0 && arena.dataTypes[name] !== EnumToken.DashedIdenTokenType) {
199
+ if (tokens.length === 0 &&
200
+ arena.dataTypes[name] !== EnumToken.DashedIdenTokenType &&
201
+ // the result of a custom function may be empty: `result: <declaration-value>?`
202
+ !(parentNam === "function" && equalsIgnoreCase(arena.resolveString(arena.stringValue[name]), "result"))) {
199
203
  errors.push({
200
204
  action: "drop",
201
205
  message: "declaration value missing",
@@ -226,7 +230,7 @@ function parseDeclaration(arena, tokens, parent, options, errors) {
226
230
  }
227
231
  for (i = 0; i < tokens.length; i++) {
228
232
  token = tokens[i];
229
- if (tokensfuncDefMap.has(arena.dataTypes[token]) ||
233
+ if (isFunctionDefType(arena.dataTypes[token]) ||
230
234
  arena.dataTypes[token] === EnumToken.StartParensTokenType ||
231
235
  arena.dataTypes[token] === EnumToken.BlockStartTokenType) {
232
236
  stack.push(token);
@@ -239,11 +243,11 @@ function parseDeclaration(arena, tokens, parent, options, errors) {
239
243
  switch (arena.dataTypes[token]) {
240
244
  case EnumToken.Literal:
241
245
  // inlined: arena.typeOf(stack.at(-1))
242
- if (arena.strings[arena.stringValue[token]] === "/" &&
246
+ if (arena.resolveString(arena.stringValue[token]) === "/" &&
243
247
  arena.dataTypes[stack.at(-1)] === EnumToken.MathFunctionTokenDefType) {
244
248
  arena.dataTypes[token] = EnumToken.Div;
245
249
  }
246
- else if (arena.strings[arena.stringValue[token]] === "-" &&
250
+ else if (arena.resolveString(arena.stringValue[token]) === "-" &&
247
251
  // inlined: arena.typeOf(stack.at(-1))
248
252
  arena.dataTypes[stack.at(-1)] === EnumToken.MathFunctionTokenDefType) {
249
253
  arena.dataTypes[token] = EnumToken.Sub;
@@ -268,7 +272,7 @@ function parseDeclaration(arena, tokens, parent, options, errors) {
268
272
  case EnumToken.EndParensTokenType:
269
273
  if (stack.length > 0 &&
270
274
  (arena.dataTypes[stack[stack.length - 1]] === EnumToken.StartParensTokenType ||
271
- tokensfuncDefMap.has(arena.dataTypes[stack[stack.length - 1]]))) {
275
+ isFunctionDefType(arena.dataTypes[stack[stack.length - 1]]))) {
272
276
  index = tokens.indexOf(stack.at(-1));
273
277
  tokens.splice(i, 1);
274
278
  arena.dataTypes[tokens[index]] =
@@ -277,7 +281,7 @@ function parseDeclaration(arena, tokens, parent, options, errors) {
277
281
  : tokensfuncDefMap.get(arena.dataTypes[stack[stack.length - 1]]);
278
282
  arena.setTokenList(tokens[index], trimArray(arena, tokens.splice(index + 1, i - index - 1)));
279
283
  if (arena.dataTypes[tokens[index]] === EnumToken.WildCardFunctionTokenType &&
280
- equalsIgnoreCase(arena.strings[arena.stringValue[tokens[index]]], "if")) {
284
+ equalsIgnoreCase(arena.resolveString(arena.stringValue[tokens[index]]), "if")) {
281
285
  const last = arena.lastToken[tokens[index]];
282
286
  if (last !== 0 && arena.dataTypes[last] === EnumToken.SemiColonTokenType) {
283
287
  arena.detach(last);
@@ -294,7 +298,7 @@ function parseDeclaration(arena, tokens, parent, options, errors) {
294
298
  let index = -1;
295
299
  while (++index < curr.length) {
296
300
  if (arena.dataTypes[curr[index]] === EnumToken.IdenTokenType &&
297
- equalsIgnoreCase("else", arena.strings[arena.stringValue[curr[index]]])) {
301
+ equalsIgnoreCase("else", arena.resolveString(arena.stringValue[curr[index]]))) {
298
302
  foundElse = true;
299
303
  }
300
304
  if (arena.dataTypes[curr[index]] === EnumToken.ColonTokenType) {
@@ -330,15 +334,15 @@ function parseDeclaration(arena, tokens, parent, options, errors) {
330
334
  else if (arena.dataTypes[tokens[index]] === EnumToken.UrlFunctionTokenType) {
331
335
  const url = arena.findToken(tokens[index], (arena, t) => arena.dataTypes[t] === EnumToken.StringTokenType);
332
336
  if (url != null &&
333
- /^[a-zA-Z0-9/_.-]+$/.test(arena.strings[arena.stringValue[url]].slice(1, -1))) {
337
+ /^[a-zA-Z0-9/_.-]+$/.test(arena.resolveString(arena.stringValue[url]).slice(1, -1))) {
334
338
  arena.dataTypes[url] = EnumToken.UrlTokenTokenType;
335
- // inlined: arena.setStr(url, arena.strings[arena.stringValue[url]].slice(1, -1))
336
- arena.stringValue[url] = arena.internString(arena.strings[arena.stringValue[url]].slice(1, -1));
339
+ // inlined: arena.setStr(url, arena.resolveString(arena.stringValue[url]).slice(1, -1))
340
+ arena.stringValue[url] = arena.internString(arena.resolveString(arena.stringValue[url]).slice(1, -1));
337
341
  }
338
342
  }
339
343
  i = index;
340
344
  if (arena.dataTypes[tokens[index]] === EnumToken.MathFunctionTokenType &&
341
- equalsIgnoreCase("calc", arena.strings[arena.stringValue[tokens[index]]])) {
345
+ equalsIgnoreCase("calc", arena.resolveString(arena.stringValue[tokens[index]]))) {
342
346
  // inlined: arena.setTokens(tokens[index], buildExpression(arena, arena.tokens(tokens[index])))
343
347
  arena.setTokenList(tokens[index], [buildExpression(arena, arena.tokens(tokens[index]))]);
344
348
  }
@@ -365,11 +369,12 @@ function parseDeclaration(arena, tokens, parent, options, errors) {
365
369
  }
366
370
  break;
367
371
  case EnumToken.IdenTokenType:
368
- {
369
- const val = lowercase(arena.strings[arena.stringValue[token]]);
372
+ // the identifiers that are not colors are skipped without reading the string (computed once per id)
373
+ if (arena.stringFlag(arena.stringValue[token], 0 /* StringFlag.Color */, isColorName)) {
374
+ const val = lowercase(arena.resolveString(arena.stringValue[token]));
370
375
  if (val in COLORS_NAMES || val === "currentcolor") {
371
- // inlined: arena.setStr(token, val)
372
- arena.stringValue[token] = arena.internString(val);
376
+ // the lowercase string id: no string is created
377
+ arena.stringValue[token] = arena.lowerStringId(arena.stringValue[token]);
373
378
  arena.dataTypes[token] = EnumToken.ColorTokenType;
374
379
  // inlined: arena.setColorType(token, ColorType.LIT)
375
380
  arena.colorType[token] = ColorType.LIT;
@@ -437,9 +442,9 @@ function parseDeclaration(arena, tokens, parent, options, errors) {
437
442
  let i = 0;
438
443
  for (; i < tokens.length; i++) {
439
444
  if (arena.dataTypes[tokens[i]] === EnumToken.StringTokenType) {
440
- if (/[\s.]/.test(arena.strings[arena.stringValue[tokens[i]]])) {
441
- // inlined: arena.setStr(tokens[i], parseGridTemplate(arena.strings[arena.stringValue[tokens[i]]]))
442
- arena.stringValue[tokens[i]] = arena.internString(parseGridTemplate(arena.strings[arena.stringValue[tokens[i]]]));
445
+ if (/[\s.]/.test(arena.resolveString(arena.stringValue[tokens[i]]))) {
446
+ // inlined: arena.setStr(tokens[i], parseGridTemplate(arena.resolveString(arena.stringValue[tokens[i]])))
447
+ arena.stringValue[tokens[i]] = arena.internString(parseGridTemplate(arena.resolveString(arena.stringValue[tokens[i]])));
443
448
  }
444
449
  if (arena.dataTypes[tokens[i + 1]] === EnumToken.WhitespaceTokenType &&
445
450
  arena.dataTypes[tokens[i + 2]] === EnumToken.StringTokenType) {
@@ -461,7 +466,7 @@ function parseDeclaration(arena, tokens, parent, options, errors) {
461
466
  let index = -1;
462
467
  for (let i = 0; i < tokens.length; i++) {
463
468
  if (arena.dataTypes[tokens[i]] === EnumToken.IdenTokenType &&
464
- equalsIgnoreCase("from", arena.strings[arena.stringValue[tokens[i]]])) {
469
+ equalsIgnoreCase("from", arena.resolveString(arena.stringValue[tokens[i]]))) {
465
470
  index = i;
466
471
  break;
467
472
  }
@@ -1,8 +1,8 @@
1
1
  /*
2
- CSS parser, minifier and validator for node and the browser
2
+ CSS parser, minifier and validator for node, deno, bun and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 2.1.0
5
+ Version: 2.2.0
6
6
  License: MIT
7
7
  */
8
8
  /**
@@ -1,8 +1,8 @@
1
1
  /*
2
- CSS parser, minifier and validator for node and the browser
2
+ CSS parser, minifier and validator for node, deno, bun and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 2.1.0
5
+ Version: 2.2.0
6
6
  License: MIT
7
7
  */
8
8
  // Alphabet: a-z, A-Z, 0-9, _, -