@tbela99/css-parser 1.8.2 → 2.0.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 (105) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +129 -31
  3. package/dist/index-umd-web.js +27383 -24083
  4. package/dist/index.d.ts +2737 -2200
  5. package/dist/package.json.js +2 -2
  6. package/dist/src/data/properties.json.js +1 -1
  7. package/dist/src/data/validation.json.js +1 -1
  8. package/dist/src/lib/ast/arena-node.js +548 -0
  9. package/dist/src/lib/ast/arena.js +3198 -0
  10. package/dist/src/lib/ast/cache.js +333 -0
  11. package/dist/src/lib/ast/features/calc.js +85 -76
  12. package/dist/src/lib/ast/features/if.js +155 -115
  13. package/dist/src/lib/ast/features/index.js +1 -1
  14. package/dist/src/lib/ast/features/inlinecssvariables.js +77 -84
  15. package/dist/src/lib/ast/features/prefix.js +184 -183
  16. package/dist/src/lib/ast/features/shorthand.js +40 -46
  17. package/dist/src/lib/ast/features/transform.js +24 -24
  18. package/dist/src/lib/ast/features/type.js +1 -1
  19. package/dist/src/lib/ast/math/expression.js +458 -543
  20. package/dist/src/lib/ast/math/math.js +19 -41
  21. package/dist/src/lib/ast/minify.js +590 -647
  22. package/dist/src/lib/ast/transform/compute.js +82 -85
  23. package/dist/src/lib/ast/transform/matrix.js +21 -38
  24. package/dist/src/lib/ast/transform/minify.js +82 -193
  25. package/dist/src/lib/ast/transform/perspective.js +2 -3
  26. package/dist/src/lib/ast/transform/rotate.js +1 -1
  27. package/dist/src/lib/ast/transform/scale.js +1 -1
  28. package/dist/src/lib/ast/transform/skew.js +1 -1
  29. package/dist/src/lib/ast/transform/translate.js +1 -1
  30. package/dist/src/lib/ast/transform/utils.js +2 -2
  31. package/dist/src/lib/ast/types.js +263 -258
  32. package/dist/src/lib/ast/walk.js +246 -610
  33. package/dist/src/lib/fs/resolve.js +1 -1
  34. package/dist/src/lib/parser/declaration/list.js +223 -139
  35. package/dist/src/lib/parser/declaration/map.js +251 -238
  36. package/dist/src/lib/parser/declaration/set.js +74 -66
  37. package/dist/src/lib/parser/linesmap.js +1 -1
  38. package/dist/src/lib/parser/parse.js +1379 -1658
  39. package/dist/src/lib/parser/source.js +7 -4
  40. package/dist/src/lib/parser/tokenize.js +406 -199
  41. package/dist/src/lib/parser/utils/angle.js +11 -13
  42. package/dist/src/lib/parser/utils/at-rule-container.js +183 -168
  43. package/dist/src/lib/parser/utils/at-rule-font-feature-values.js +5 -5
  44. package/dist/src/lib/parser/utils/at-rule-generic.js +31 -24
  45. package/dist/src/lib/parser/utils/at-rule-import.js +44 -44
  46. package/dist/src/lib/parser/utils/at-rule-media.js +216 -205
  47. package/dist/src/lib/parser/utils/at-rule-support.js +83 -88
  48. package/dist/src/lib/parser/utils/at-rule-when-else.js +47 -47
  49. package/dist/src/lib/parser/utils/at-rule.js +5 -5
  50. package/dist/src/lib/parser/utils/base64.js +2 -2
  51. package/dist/src/lib/parser/utils/cache.js +1 -1
  52. package/dist/src/lib/parser/utils/config.js +1 -1
  53. package/dist/src/lib/parser/utils/declaration.js +233 -234
  54. package/dist/src/lib/parser/utils/eq.js +50 -3
  55. package/dist/src/lib/parser/utils/hash.js +2 -35
  56. package/dist/src/lib/parser/utils/selector.js +309 -387
  57. package/dist/src/lib/parser/utils/text.js +18 -4
  58. package/dist/src/lib/parser/utils/token.js +16 -69
  59. package/dist/src/lib/parser/utils/type.js +37 -24
  60. package/dist/src/lib/printer/render.js +965 -511
  61. package/dist/src/lib/printer/sourcemap/lib/codec.js +1 -1
  62. package/dist/src/lib/printer/sourcemap/sourcemap.js +1 -1
  63. package/dist/src/lib/syntax/color/a98rgb.js +1 -1
  64. package/dist/src/lib/syntax/color/alpha.js +36 -37
  65. package/dist/src/lib/syntax/color/cmyk.js +35 -52
  66. package/dist/src/lib/syntax/color/color-mix.js +96 -132
  67. package/dist/src/lib/syntax/color/color.js +222 -231
  68. package/dist/src/lib/syntax/color/hex.js +45 -55
  69. package/dist/src/lib/syntax/color/hsl.js +54 -62
  70. package/dist/src/lib/syntax/color/hwb.js +60 -68
  71. package/dist/src/lib/syntax/color/lab.js +59 -67
  72. package/dist/src/lib/syntax/color/lch.js +59 -67
  73. package/dist/src/lib/syntax/color/oklab.js +60 -68
  74. package/dist/src/lib/syntax/color/oklch.js +60 -67
  75. package/dist/src/lib/syntax/color/p3.js +1 -1
  76. package/dist/src/lib/syntax/color/prophotorgb.js +1 -1
  77. package/dist/src/lib/syntax/color/rec2020.js +1 -1
  78. package/dist/src/lib/syntax/color/relative-color.js +94 -144
  79. package/dist/src/lib/syntax/color/rgb.js +54 -57
  80. package/dist/src/lib/syntax/color/srgb.js +55 -53
  81. package/dist/src/lib/syntax/color/utils/color-type.js +13 -10
  82. package/dist/src/lib/syntax/color/utils/colorspace.js +11 -11
  83. package/dist/src/lib/syntax/color/utils/components.js +19 -20
  84. package/dist/src/lib/syntax/color/utils/distance.js +15 -13
  85. package/dist/src/lib/syntax/color/utils/make-color.js +15 -19
  86. package/dist/src/lib/syntax/color/utils/matrix.js +2 -2
  87. package/dist/src/lib/syntax/color/xyz.js +1 -1
  88. package/dist/src/lib/syntax/color/xyzd50.js +1 -1
  89. package/dist/src/lib/syntax/constants.js +2 -16
  90. package/dist/src/lib/syntax/syntax.js +301 -407
  91. package/dist/src/lib/validation/config.js +1 -1
  92. package/dist/src/lib/validation/match.js +959 -723
  93. package/dist/src/lib/validation/parser/parse.js +230 -112
  94. package/dist/src/lib/validation/parser/typedef.js +1 -1
  95. package/dist/src/lib/validation/utils/list.js +27 -12
  96. package/dist/src/node.js +12 -72
  97. package/dist/src/types.js +1 -1
  98. package/dist/src/utils/sync.js +9 -6
  99. package/dist/src/web.js +11 -73
  100. package/package.json +9 -10
  101. package/dist/index.cjs +0 -35870
  102. package/dist/src/lib/ast/clone.js +0 -51
  103. package/dist/src/lib/ast/expand.js +0 -311
  104. package/dist/src/lib/ast/find.js +0 -192
  105. package/dist/src/lib/ast/node.js +0 -59
@@ -2,7 +2,7 @@
2
2
  CSS parser, minifier and validator for node and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 1.8.2
5
+ Version: 2.0.1
6
6
  License: MIT
7
7
  */
8
8
  import { identity, multiply, decompose, round, toZero } from './utils.js';
@@ -12,7 +12,7 @@ import { computeMatrix } from './compute.js';
12
12
  import { parseMatrix } from './matrix.js';
13
13
 
14
14
  // translate → rotate → skew → scale
15
- function minify(matrix) {
15
+ function minify(arena, matrix) {
16
16
  const decomposed = decompose(matrix);
17
17
  if (decomposed == null) {
18
18
  return null;
@@ -48,125 +48,62 @@ function minify(matrix) {
48
48
  }
49
49
  if (coordinates.size == 1) {
50
50
  if (coordinates.has("x")) {
51
- result.push({
52
- typ: EnumToken.TransformFunctionTokenType,
53
- val: "translate",
54
- chi: [{ typ: EnumToken.LengthTokenType, val: round(decomposed.translate[0]), unit: "px" }],
55
- });
51
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "translate", [arena.createToken(EnumToken.LengthTokenType, round(decomposed.translate[0]), "px")]));
56
52
  }
57
53
  else {
58
54
  let axis = coordinates.has("y") ? "y" : "z";
59
55
  let index = axis == "y" ? 1 : 2;
60
- result.push({
61
- typ: EnumToken.TransformFunctionTokenType,
62
- val: "translate" + axis.toUpperCase(),
63
- chi: [{ typ: EnumToken.LengthTokenType, val: round(decomposed.translate[index]), unit: "px" }],
64
- });
56
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "translate" + axis.toUpperCase(), [arena.createToken(EnumToken.LengthTokenType, round(decomposed.translate[index]), "px")]));
65
57
  }
66
58
  }
67
59
  else if (coordinates.has("z")) {
68
- result.push({
69
- typ: EnumToken.TransformFunctionTokenType,
70
- val: "translate3d",
71
- chi: [
72
- decomposed.translate[0] == 0
73
- ? {
74
- typ: EnumToken.NumberTokenType,
75
- val: 0,
76
- }
77
- : { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[0]), unit: "px" },
78
- { typ: EnumToken.CommaTokenType },
79
- decomposed.translate[1] == 0
80
- ? {
81
- typ: EnumToken.NumberTokenType,
82
- val: 0,
83
- }
84
- : { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[1]), unit: "px" },
85
- { typ: EnumToken.CommaTokenType },
86
- { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[2]), unit: "px" },
87
- ],
88
- });
60
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "translate3d", [
61
+ decomposed.translate[0] == 0
62
+ ? arena.createToken(EnumToken.NumberTokenType, 0)
63
+ : arena.createToken(EnumToken.LengthTokenType, round(decomposed.translate[0]), "px"),
64
+ arena.createToken(EnumToken.CommaTokenType),
65
+ decomposed.translate[1] == 0
66
+ ? arena.createToken(EnumToken.NumberTokenType, 0)
67
+ : arena.createToken(EnumToken.LengthTokenType, round(decomposed.translate[1]), "px"),
68
+ arena.createToken(EnumToken.CommaTokenType),
69
+ arena.createToken(EnumToken.LengthTokenType, round(decomposed.translate[2]), "px"),
70
+ ]));
89
71
  }
90
72
  else {
91
- result.push({
92
- typ: EnumToken.TransformFunctionTokenType,
93
- val: "translate",
94
- chi: [
95
- { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[0]), unit: "px" },
96
- { typ: EnumToken.CommaTokenType },
97
- { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[1]), unit: "px" },
98
- ],
99
- });
73
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "translate", [
74
+ arena.createToken(EnumToken.LengthTokenType, round(decomposed.translate[0]), "px"),
75
+ arena.createToken(EnumToken.CommaTokenType),
76
+ arena.createToken(EnumToken.LengthTokenType, round(decomposed.translate[1]), "px"),
77
+ ]));
100
78
  }
101
79
  }
102
80
  if (transforms.has("rotate")) {
103
81
  const [x, y, z, angle] = decomposed.rotate;
104
82
  if (y == 0 && z == 0) {
105
- result.push({
106
- typ: EnumToken.TransformFunctionTokenType,
107
- val: "rotateX",
108
- chi: [
109
- {
110
- typ: EnumToken.AngleTokenType,
111
- val: round(angle),
112
- unit: "deg",
113
- },
114
- ],
115
- });
83
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "rotateX", [
84
+ arena.createToken(EnumToken.AngleTokenType, round(angle), "deg"),
85
+ ]));
116
86
  }
117
87
  else if (x == 0 && z == 0) {
118
- result.push({
119
- typ: EnumToken.TransformFunctionTokenType,
120
- val: "rotateY",
121
- chi: [
122
- {
123
- typ: EnumToken.AngleTokenType,
124
- val: round(angle),
125
- unit: "deg",
126
- },
127
- ],
128
- });
88
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "rotateY", [
89
+ arena.createToken(EnumToken.AngleTokenType, round(angle), "deg"),
90
+ ]));
129
91
  }
130
92
  else if (x == 0 && y == 0) {
131
- result.push({
132
- typ: EnumToken.TransformFunctionTokenType,
133
- val: "rotate",
134
- chi: [
135
- {
136
- typ: EnumToken.AngleTokenType,
137
- val: round(angle),
138
- unit: "deg",
139
- },
140
- ],
141
- });
93
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "rotate", [
94
+ arena.createToken(EnumToken.AngleTokenType, round(angle), "deg"),
95
+ ]));
142
96
  }
143
97
  else {
144
- result.push({
145
- typ: EnumToken.TransformFunctionTokenType,
146
- val: "rotate3d",
147
- chi: [
148
- {
149
- typ: EnumToken.NumberTokenType,
150
- val: round(x),
151
- },
152
- { typ: EnumToken.CommaTokenType },
153
- {
154
- typ: EnumToken.NumberTokenType,
155
- val: round(y),
156
- },
157
- { typ: EnumToken.CommaTokenType },
158
- {
159
- typ: EnumToken.NumberTokenType,
160
- val: round(z),
161
- },
162
- { typ: EnumToken.CommaTokenType },
163
- {
164
- typ: EnumToken.AngleTokenType,
165
- val: round(angle),
166
- unit: "deg",
167
- },
168
- ],
169
- });
98
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "rotate3d", [
99
+ arena.createToken(EnumToken.NumberTokenType, round(x)),
100
+ arena.createToken(EnumToken.CommaTokenType),
101
+ arena.createToken(EnumToken.NumberTokenType, round(y)),
102
+ arena.createToken(EnumToken.CommaTokenType),
103
+ arena.createToken(EnumToken.NumberTokenType, round(z)),
104
+ arena.createToken(EnumToken.CommaTokenType),
105
+ arena.createToken(EnumToken.AngleTokenType, round(angle), "deg"),
106
+ ]));
170
107
  }
171
108
  }
172
109
  if (transforms.has("skew")) {
@@ -177,22 +114,14 @@ function minify(matrix) {
177
114
  decomposed.skew[i] = round((Math.atan(decomposed.skew[i]) * 180) / Math.PI);
178
115
  }
179
116
  if (skew.size == 1) {
180
- result.push({
181
- typ: EnumToken.TransformFunctionTokenType,
182
- val: "skew" + (skew.has("x") ? "" : "Y"),
183
- chi: [{ typ: EnumToken.AngleTokenType, val: round(decomposed.skew[0]), unit: "deg" }],
184
- });
117
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "skew" + (skew.has("x") ? "" : "Y"), [arena.createToken(EnumToken.AngleTokenType, round(decomposed.skew[0]), "deg")]));
185
118
  }
186
119
  else {
187
- result.push({
188
- typ: EnumToken.TransformFunctionTokenType,
189
- val: "skew",
190
- chi: [
191
- { typ: EnumToken.AngleTokenType, val: round(decomposed.skew[0]), unit: "deg" },
192
- { typ: EnumToken.CommaTokenType },
193
- { typ: EnumToken.AngleTokenType, val: round(decomposed.skew[1]), unit: "deg" },
194
- ],
195
- });
120
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "skew", [
121
+ arena.createToken(EnumToken.AngleTokenType, round(decomposed.skew[0]), "deg"),
122
+ arena.createToken(EnumToken.CommaTokenType),
123
+ arena.createToken(EnumToken.AngleTokenType, round(decomposed.skew[1]), "deg"),
124
+ ]));
196
125
  }
197
126
  }
198
127
  if (transforms.has("scale")) {
@@ -208,53 +137,38 @@ function minify(matrix) {
208
137
  }
209
138
  if (scales.size == 1) {
210
139
  let prefix = scales.has("x") ? "X" : scales.has("y") ? "Y" : "Z";
211
- result.push({
212
- typ: EnumToken.TransformFunctionTokenType,
213
- val: "scale" + prefix,
214
- chi: [{ typ: EnumToken.NumberTokenType, val: round(prefix == "Z" ? sz : prefix == "Y" ? sy : sx) }],
215
- });
140
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "scale" + prefix, [arena.createToken(EnumToken.NumberTokenType, round(prefix == "Z" ? sz : prefix == "Y" ? sy : sx))]));
216
141
  }
217
142
  else if (!scales.has("z")) {
218
- result.push({
219
- typ: EnumToken.TransformFunctionTokenType,
220
- val: "scale",
221
- chi: [
222
- { typ: EnumToken.NumberTokenType, val: round(sx) },
223
- { typ: EnumToken.CommaTokenType },
224
- { typ: EnumToken.NumberTokenType, val: round(sy) },
225
- ],
226
- });
143
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "scale", [
144
+ arena.createToken(EnumToken.NumberTokenType, round(sx)),
145
+ arena.createToken(EnumToken.CommaTokenType),
146
+ arena.createToken(EnumToken.NumberTokenType, round(sy)),
147
+ ]));
227
148
  }
228
149
  else {
229
- result.push({
230
- typ: EnumToken.TransformFunctionTokenType,
231
- val: "scale3d",
232
- chi: [
233
- { typ: EnumToken.NumberTokenType, val: round(sx) },
234
- { typ: EnumToken.CommaTokenType },
235
- { typ: EnumToken.NumberTokenType, val: round(sy) },
236
- { typ: EnumToken.CommaTokenType },
237
- { typ: EnumToken.NumberTokenType, val: round(sz) },
238
- ],
239
- });
150
+ result.push(arena.createFunction(EnumToken.TransformFunctionTokenType, "scale3d", [
151
+ arena.createToken(EnumToken.NumberTokenType, round(sx)),
152
+ arena.createToken(EnumToken.CommaTokenType),
153
+ arena.createToken(EnumToken.NumberTokenType, round(sy)),
154
+ arena.createToken(EnumToken.CommaTokenType),
155
+ arena.createToken(EnumToken.NumberTokenType, round(sz)),
156
+ ]));
240
157
  }
241
158
  }
242
159
  // identity
243
- return result.length == 0 || (result.length == 1 && eqMatrix(identity(), result))
160
+ return result.length == 0 || (result.length == 1 && eqMatrix(arena, identity(), result))
244
161
  ? [
245
- {
246
- typ: EnumToken.IdenTokenType,
247
- val: "none",
248
- },
162
+ arena.createToken(EnumToken.IdenTokenType, "none"),
249
163
  ]
250
164
  : result;
251
165
  }
252
- function eqMatrix(a, b) {
166
+ function eqMatrix(arena, a, b) {
253
167
  let mat = identity();
254
168
  let tmp = identity();
255
- const data = (Array.isArray(a) || ArrayBuffer.isView(a) ? a : parseMatrix(a));
169
+ const data = (Array.isArray(a) || ArrayBuffer.isView(a) ? a : parseMatrix(arena, a));
256
170
  for (const transform of b) {
257
- tmp = computeMatrix([transform], identity());
171
+ tmp = computeMatrix(arena, [transform], identity());
258
172
  if (tmp == null) {
259
173
  return false;
260
174
  }
@@ -272,20 +186,21 @@ function eqMatrix(a, b) {
272
186
  }
273
187
  return true;
274
188
  }
275
- function minifyTransformFunctions(transform) {
276
- const name = transform.val;
189
+ function minifyTransformFunctions(arena, transform) {
190
+ const name = arena.strings[arena.stringValue[transform]];
277
191
  if ("skewX" == name) {
278
- transform.val = "skew";
192
+ // inlined: arena.setStr(transform, "skew")
193
+ arena.stringValue[transform] = arena.internString("skew");
279
194
  return transform;
280
195
  }
281
196
  if (!["translate", "translate3d", "scale", "scale3d"].includes(name)) {
282
197
  return transform;
283
198
  }
284
199
  const values = [];
285
- for (const token of transform.chi) {
286
- if (token.typ == EnumToken.CommentTokenType ||
287
- token.typ == EnumToken.WhitespaceTokenType ||
288
- token.typ == EnumToken.CommaTokenType) {
200
+ for (const token of arena.tokens(transform)) {
201
+ if (arena.dataTypes[token] == EnumToken.CommentTokenType ||
202
+ arena.dataTypes[token] == EnumToken.WhitespaceTokenType ||
203
+ arena.dataTypes[token] == EnumToken.CommaTokenType) {
289
204
  continue;
290
205
  }
291
206
  if (![
@@ -293,16 +208,14 @@ function minifyTransformFunctions(transform) {
293
208
  EnumToken.LengthTokenType,
294
209
  EnumToken.AngleTokenType,
295
210
  EnumToken.PercentageTokenType,
296
- ].includes(token.typ)) {
211
+ ].includes(arena.dataTypes[token])) {
297
212
  return transform;
298
213
  }
299
- if (token.typ == EnumToken.PercentageTokenType &&
300
- typeof token.val == "number" &&
214
+ if (arena.dataTypes[token] == EnumToken.PercentageTokenType &&
215
+ !arena.hasFraction(token) &&
301
216
  name.startsWith("scale")) {
302
- Object.assign(token, {
303
- typ: EnumToken.NumberTokenType,
304
- val: token.val / 100,
305
- });
217
+ arena.dataTypes[token] = EnumToken.NumberTokenType;
218
+ arena.numericValue[token] /= 100;
306
219
  }
307
220
  values.push(token);
308
221
  }
@@ -316,60 +229,36 @@ function minifyTransformFunctions(transform) {
316
229
  const t = new Set(["x", "y", "z"]);
317
230
  for (let i = 0; i < 3; i++) {
318
231
  const axis = i == 0 ? "x" : i == 1 ? "y" : "z";
319
- if (values.length <= i || values[i].val == ignoredValue) {
232
+ if (values.length <= i || arena.numericValue[values[i]] == ignoredValue) {
320
233
  t.delete(axis);
321
234
  }
322
235
  }
323
236
  if (name == "translate3d" || name == "translate") {
324
237
  if (t.size == 0) {
325
- return {
326
- typ: EnumToken.TransformFunctionTokenType,
327
- val: "translate",
328
- chi: [{ typ: EnumToken.NumberTokenType, val: 0 }],
329
- };
238
+ return arena.createFunction(EnumToken.TransformFunctionTokenType, "translate", [arena.createToken(EnumToken.NumberTokenType, 0)]);
330
239
  }
331
240
  if (t.size == 1) {
332
- return {
333
- typ: EnumToken.TransformFunctionTokenType,
334
- val: "translate" + (t.has("x") ? "" : t.has("y") ? "Y" : "Z"),
335
- chi: [values[t.has("x") ? 0 : t.has("y") ? 1 : 2]],
336
- };
241
+ return arena.createFunction(EnumToken.TransformFunctionTokenType, "translate" + (t.has("x") ? "" : t.has("y") ? "Y" : "Z"), [values[t.has("x") ? 0 : t.has("y") ? 1 : 2]]);
337
242
  }
338
243
  if (t.size == 2) {
339
244
  if (t.has("z")) {
340
245
  return transform;
341
246
  }
342
- return {
343
- typ: EnumToken.TransformFunctionTokenType,
344
- val: "translate",
345
- chi: [values[0], { typ: EnumToken.CommaTokenType }, values[1]],
346
- };
247
+ return arena.createFunction(EnumToken.TransformFunctionTokenType, "translate", [values[0], arena.createToken(EnumToken.CommaTokenType), values[1]]);
347
248
  }
348
249
  }
349
250
  if (name == "scale3d" || name == "scale") {
350
251
  if (t.size == 0) {
351
- return {
352
- typ: EnumToken.TransformFunctionTokenType,
353
- val: "scale",
354
- chi: [{ typ: EnumToken.NumberTokenType, val: 1 }],
355
- };
252
+ return arena.createFunction(EnumToken.TransformFunctionTokenType, "scale", [arena.createToken(EnumToken.NumberTokenType, 1)]);
356
253
  }
357
254
  if (t.size == 1) {
358
- return {
359
- typ: EnumToken.TransformFunctionTokenType,
360
- val: "scale" + (t.has("x") ? "X" : t.has("y") ? "Y" : "Z"),
361
- chi: [values[t.has("x") ? 0 : t.has("y") ? 1 : 2]],
362
- };
255
+ return arena.createFunction(EnumToken.TransformFunctionTokenType, "scale" + (t.has("x") ? "X" : t.has("y") ? "Y" : "Z"), [values[t.has("x") ? 0 : t.has("y") ? 1 : 2]]);
363
256
  }
364
257
  if (t.size == 2) {
365
258
  if (t.has("z")) {
366
259
  return transform;
367
260
  }
368
- return {
369
- typ: EnumToken.TransformFunctionTokenType,
370
- val: "scale",
371
- chi: [values[0], { typ: EnumToken.CommaTokenType }, values[1]],
372
- };
261
+ return arena.createFunction(EnumToken.TransformFunctionTokenType, "scale", [values[0], arena.createToken(EnumToken.CommaTokenType), values[1]]);
373
262
  }
374
263
  }
375
264
  return transform;
@@ -2,15 +2,14 @@
2
2
  CSS parser, minifier and validator for node and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 1.8.2
5
+ Version: 2.0.1
6
6
  License: MIT
7
7
  */
8
8
  import { identity, multiply } from './utils.js';
9
9
 
10
10
  function perspective(x, from) {
11
11
  const matrix = identity();
12
- // @ts-ignore
13
- matrix[2 * 4 + 3] = typeof x == "object" && x.val == "none" ? 0 : x == 0 ? Number.NEGATIVE_INFINITY : -1 / x;
12
+ matrix[2 * 4 + 3] = x == "none" ? 0 : x == 0 ? Number.NEGATIVE_INFINITY : -1 / x;
14
13
  return multiply(from, matrix);
15
14
  }
16
15
 
@@ -2,7 +2,7 @@
2
2
  CSS parser, minifier and validator for node and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 1.8.2
5
+ Version: 2.0.1
6
6
  License: MIT
7
7
  */
8
8
  import { identity, multiply } from './utils.js';
@@ -2,7 +2,7 @@
2
2
  CSS parser, minifier and validator for node and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 1.8.2
5
+ Version: 2.0.1
6
6
  License: MIT
7
7
  */
8
8
  import { identity, multiply } from './utils.js';
@@ -2,7 +2,7 @@
2
2
  CSS parser, minifier and validator for node and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 1.8.2
5
+ Version: 2.0.1
6
6
  License: MIT
7
7
  */
8
8
  import { identity, multiply } from './utils.js';
@@ -2,7 +2,7 @@
2
2
  CSS parser, minifier and validator for node and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 1.8.2
5
+ Version: 2.0.1
6
6
  License: MIT
7
7
  */
8
8
  import { identity, multiply } from './utils.js';
@@ -2,7 +2,7 @@
2
2
  CSS parser, minifier and validator for node and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 1.8.2
5
+ Version: 2.0.1
6
6
  License: MIT
7
7
  */
8
8
  import { epsilon } from '../../syntax/constants.js';
@@ -128,7 +128,7 @@ function round(number) {
128
128
  const rounded = Math.round(number);
129
129
  return Math.abs(rounded - number) <= epsilon ? rounded : +number.toPrecision(6);
130
130
  }
131
- // translate3d(25.9808px, 0, 15px ) rotateY(60deg) skewX(49.9999deg) scale(1, 1.2)
131
+ // translate3d(25.9808px, 0, 15px) rotateY(60deg) skewX(49.9999deg) scale(1, 1.2)
132
132
  // translate → rotate → skew → scale
133
133
  function decompose(original) {
134
134
  const matrix = original.slice();