@tbela99/css-parser 1.1.1-alpha4 → 1.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 (101) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/README.md +53 -6
  3. package/dist/index-umd-web.js +4195 -3375
  4. package/dist/index.cjs +5468 -4648
  5. package/dist/index.d.ts +42 -31
  6. package/dist/lib/ast/expand.js +81 -65
  7. package/dist/lib/ast/features/calc.js +37 -35
  8. package/dist/lib/ast/features/inlinecssvariables.js +25 -17
  9. package/dist/lib/ast/features/prefix.js +22 -19
  10. package/dist/lib/ast/features/shorthand.js +1 -1
  11. package/dist/lib/ast/features/transform.js +17 -2
  12. package/dist/lib/ast/math/expression.js +184 -159
  13. package/dist/lib/ast/math/math.js +22 -20
  14. package/dist/lib/ast/minify.js +249 -200
  15. package/dist/lib/ast/transform/compute.js +48 -38
  16. package/dist/lib/ast/transform/matrix.js +6 -5
  17. package/dist/lib/ast/transform/minify.js +31 -34
  18. package/dist/lib/ast/transform/utils.js +76 -16
  19. package/dist/lib/ast/types.js +32 -1
  20. package/dist/lib/fs/resolve.js +1 -14
  21. package/dist/lib/parser/declaration/list.js +1 -1
  22. package/dist/lib/parser/declaration/map.js +1 -1
  23. package/dist/lib/parser/declaration/set.js +1 -1
  24. package/dist/lib/parser/parse.js +19 -95
  25. package/dist/lib/parser/tokenize.js +1 -13
  26. package/dist/lib/parser/utils/declaration.js +1 -1
  27. package/dist/lib/parser/utils/type.js +1 -1
  28. package/dist/lib/renderer/render.js +44 -168
  29. package/dist/lib/{renderer → syntax}/color/a98rgb.js +2 -2
  30. package/dist/lib/syntax/color/cmyk.js +104 -0
  31. package/dist/lib/{renderer → syntax}/color/color-mix.js +20 -21
  32. package/dist/lib/syntax/color/color.js +581 -0
  33. package/dist/lib/syntax/color/hex.js +179 -0
  34. package/dist/lib/syntax/color/hsl.js +201 -0
  35. package/dist/lib/syntax/color/hwb.js +185 -0
  36. package/dist/lib/syntax/color/lab.js +262 -0
  37. package/dist/lib/syntax/color/lch.js +194 -0
  38. package/dist/lib/syntax/color/oklab.js +237 -0
  39. package/dist/lib/syntax/color/oklch.js +166 -0
  40. package/dist/lib/{renderer → syntax}/color/p3.js +3 -3
  41. package/dist/lib/{renderer → syntax}/color/rec2020.js +11 -11
  42. package/dist/lib/{renderer → syntax}/color/relativecolor.js +53 -40
  43. package/dist/lib/syntax/color/rgb.js +140 -0
  44. package/dist/lib/{renderer → syntax}/color/srgb.js +58 -46
  45. package/dist/lib/{renderer → syntax}/color/utils/components.js +7 -7
  46. package/dist/lib/{renderer → syntax}/color/utils/constants.js +7 -34
  47. package/dist/lib/syntax/color/utils/distance.js +30 -0
  48. package/dist/lib/{renderer → syntax}/color/xyz.js +27 -14
  49. package/dist/lib/{renderer → syntax}/color/xyzd50.js +8 -8
  50. package/dist/lib/syntax/syntax.js +77 -67
  51. package/dist/lib/syntax/utils.js +70 -0
  52. package/dist/lib/validation/at-rules/container.js +1 -1
  53. package/dist/lib/validation/at-rules/counter-style.js +1 -1
  54. package/dist/lib/validation/at-rules/custom-media.js +1 -1
  55. package/dist/lib/validation/at-rules/document.js +1 -1
  56. package/dist/lib/validation/at-rules/font-feature-values.js +2 -2
  57. package/dist/lib/validation/at-rules/import.js +1 -1
  58. package/dist/lib/validation/at-rules/keyframes.js +14 -13
  59. package/dist/lib/validation/at-rules/layer.js +1 -1
  60. package/dist/lib/validation/at-rules/media.js +1 -1
  61. package/dist/lib/validation/at-rules/namespace.js +1 -1
  62. package/dist/lib/validation/at-rules/page-margin-box.js +1 -1
  63. package/dist/lib/validation/at-rules/page.js +1 -1
  64. package/dist/lib/validation/at-rules/supports.js +1 -1
  65. package/dist/lib/validation/at-rules/when.js +1 -1
  66. package/dist/lib/validation/atrule.js +2 -2
  67. package/dist/lib/validation/config.js +4 -3
  68. package/dist/lib/validation/config.json.js +1 -1
  69. package/dist/lib/validation/parser/parse.js +12 -7
  70. package/dist/lib/validation/selector.js +9 -8
  71. package/dist/lib/validation/syntax.js +171 -132
  72. package/dist/lib/validation/syntaxes/complex-selector-list.js +13 -19
  73. package/dist/lib/validation/syntaxes/complex-selector.js +1 -1
  74. package/dist/lib/validation/syntaxes/compound-selector.js +5 -24
  75. package/dist/lib/validation/syntaxes/family-name.js +36 -39
  76. package/dist/lib/validation/syntaxes/keyframe-selector.js +14 -22
  77. package/dist/lib/validation/syntaxes/layer-name.js +1 -1
  78. package/dist/lib/validation/syntaxes/relative-selector-list.js +27 -25
  79. package/dist/lib/validation/syntaxes/relative-selector.js +1 -1
  80. package/dist/lib/validation/syntaxes/url.js +35 -33
  81. package/dist/lib/validation/utils/list.js +10 -9
  82. package/dist/lib/validation/utils/whitespace.js +1 -1
  83. package/dist/node/index.js +4 -2
  84. package/dist/web/index.js +4 -2
  85. package/package.json +4 -4
  86. package/.editorconfig +0 -484
  87. package/dist/lib/ast/transform/convert.js +0 -33
  88. package/dist/lib/ast/utils/utils.js +0 -104
  89. package/dist/lib/renderer/color/color.js +0 -654
  90. package/dist/lib/renderer/color/hex.js +0 -105
  91. package/dist/lib/renderer/color/hsl.js +0 -125
  92. package/dist/lib/renderer/color/hwb.js +0 -103
  93. package/dist/lib/renderer/color/lab.js +0 -148
  94. package/dist/lib/renderer/color/lch.js +0 -90
  95. package/dist/lib/renderer/color/oklab.js +0 -131
  96. package/dist/lib/renderer/color/oklch.js +0 -75
  97. package/dist/lib/renderer/color/rgb.js +0 -50
  98. package/dist/lib/validation/syntaxes/keyframe-block-list.js +0 -28
  99. package/dist/lib/{renderer → syntax}/color/hsv.js +0 -0
  100. package/dist/lib/{renderer → syntax}/color/prophotorgb.js +1 -1
  101. /package/dist/lib/{renderer → syntax}/color/utils/matrix.js +0 -0
@@ -1,14 +1,14 @@
1
1
  import { multiply, identity } from './utils.js';
2
2
  import { EnumToken } from '../types.js';
3
- import { length2Px } from './convert.js';
4
3
  import { transformFunctions } from '../../syntax/syntax.js';
4
+ import { length2Px } from '../../syntax/utils.js';
5
5
  import '../minify.js';
6
6
  import '../walk.js';
7
7
  import '../../parser/parse.js';
8
8
  import '../../parser/tokenize.js';
9
9
  import '../../parser/utils/config.js';
10
- import { getNumber, getAngle } from '../../renderer/color/color.js';
11
- import '../../renderer/color/utils/constants.js';
10
+ import { getNumber, getAngle } from '../../syntax/color/color.js';
11
+ import '../../syntax/color/utils/constants.js';
12
12
  import '../../renderer/sourcemap/lib/encode.js';
13
13
  import { stripCommaToken } from '../../validation/utils/list.js';
14
14
  import { translateX, translateY, translateZ, translate, translate3d } from './translate.js';
@@ -22,9 +22,10 @@ import { perspective } from './perspective.js';
22
22
  function compute(transformLists) {
23
23
  transformLists = transformLists.slice();
24
24
  stripCommaToken(transformLists);
25
- if (transformLists.length == 0) {
26
- return null;
27
- }
25
+ // if (transformLists.length == 0) {
26
+ //
27
+ // return null;
28
+ // }
28
29
  let matrix = identity();
29
30
  let mat;
30
31
  const cumulative = [];
@@ -60,9 +61,10 @@ function computeMatrix(transformList, matrixVar) {
60
61
  let val;
61
62
  let i = 0;
62
63
  for (; i < transformList.length; i++) {
63
- if (transformList[i].typ == EnumToken.WhitespaceTokenType) {
64
- continue;
65
- }
64
+ // if (transformList[i].typ == EnumToken.WhitespaceTokenType) {
65
+ //
66
+ // continue;
67
+ // }
66
68
  if (transformList[i].typ != EnumToken.FunctionTokenType || !transformFunctions.includes(transformList[i].val)) {
67
69
  return null;
68
70
  }
@@ -75,25 +77,27 @@ function computeMatrix(transformList, matrixVar) {
75
77
  {
76
78
  values.length = 0;
77
79
  const children = stripCommaToken(transformList[i].chi.slice());
78
- if (children == null || children.length == 0) {
79
- return null;
80
- }
80
+ // if (children == null || children.length == 0) {
81
+ //
82
+ // return null;
83
+ // }
81
84
  const valCount = transformList[i].val == 'translate3d' || transformList[i].val == 'translate' ? 3 : 1;
82
- if (children.length == 1 && children[0].typ == EnumToken.IdenTokenType && children[0].val == 'none') {
83
- values.fill(0, 0, valCount);
84
- }
85
- else {
86
- for (let j = 0; j < children.length; j++) {
87
- if (children[j].typ == EnumToken.WhitespaceTokenType) {
88
- continue;
89
- }
90
- val = length2Px(children[j]);
91
- if (typeof val != 'number' || Number.isNaN(val)) {
92
- return null;
93
- }
94
- values.push(val);
85
+ // if (children.length == 1 && children[0].typ == EnumToken.IdenTokenType && (children[0] as IdentToken).val == 'none') {
86
+ //
87
+ // values.fill(0, 0, valCount);
88
+ //
89
+ // } else {
90
+ for (let j = 0; j < children.length; j++) {
91
+ if (children[j].typ == EnumToken.WhitespaceTokenType) {
92
+ continue;
95
93
  }
94
+ val = length2Px(children[j]);
95
+ if (val == null) {
96
+ return null;
97
+ }
98
+ values.push(val);
96
99
  }
100
+ // }
97
101
  if (values.length == 0 || values.length > valCount) {
98
102
  return null;
99
103
  }
@@ -128,9 +132,10 @@ function computeMatrix(transformList, matrixVar) {
128
132
  let values = [];
129
133
  let valuesCount = transformList[i].val == 'rotate3d' ? 4 : 1;
130
134
  for (const child of stripCommaToken(transformList[i].chi.slice())) {
131
- if (child.typ == EnumToken.WhitespaceTokenType) {
132
- continue;
133
- }
135
+ // if (child.typ == EnumToken.WhitespaceTokenType) {
136
+ //
137
+ // continue;
138
+ // }
134
139
  values.push(child);
135
140
  if (transformList[i].val == 'rotateX') {
136
141
  x = 1;
@@ -173,17 +178,19 @@ function computeMatrix(transformList, matrixVar) {
173
178
  const children = stripCommaToken(transformList[i].chi.slice());
174
179
  for (let k = 0; k < children.length; k++) {
175
180
  child = children[k];
176
- if (child.typ == EnumToken.CommentTokenType || child.typ == EnumToken.WhitespaceTokenType) {
177
- continue;
178
- }
181
+ // if (child.typ == EnumToken.CommentTokenType || child.typ == EnumToken.WhitespaceTokenType) {
182
+ //
183
+ // continue;
184
+ // }
179
185
  if (child.typ != EnumToken.NumberTokenType) {
180
186
  return null;
181
187
  }
182
188
  values.push(getNumber(child));
183
189
  }
184
- if (values.length == 0) {
185
- return null;
186
- }
190
+ // if (values.length == 0) {
191
+ //
192
+ // return null;
193
+ // }
187
194
  if (transformList[i].val == 'scale3d') {
188
195
  if (values.length != 3) {
189
196
  return null;
@@ -221,13 +228,16 @@ function computeMatrix(transformList, matrixVar) {
221
228
  let value;
222
229
  for (let k = 0; k < transformList[i].chi.length; k++) {
223
230
  child = transformList[i].chi[k];
224
- if (child.typ == EnumToken.CommentTokenType || child.typ == EnumToken.WhitespaceTokenType) {
231
+ if (child.typ == EnumToken.CommentTokenType ||
232
+ child.typ == EnumToken.CommaTokenType ||
233
+ child.typ == EnumToken.WhitespaceTokenType) {
225
234
  continue;
226
235
  }
227
236
  value = getAngle(child);
228
- if (value == null) {
229
- return null;
230
- }
237
+ // if (value == null) {
238
+ //
239
+ // return null;
240
+ // }
231
241
  values.push(value * 2 * Math.PI);
232
242
  }
233
243
  if (values.length == 0 || (values.length > (transformList[i].val == 'skew' ? 2 : 1))) {
@@ -1,14 +1,15 @@
1
1
  import { toZero, is2DMatrix, identity } from './utils.js';
2
2
  import { EnumToken } from '../types.js';
3
- import { reduceNumber } from '../../renderer/render.js';
4
3
  import { eq } from '../../parser/utils/eq.js';
5
- import { getNumber } from '../../renderer/color/color.js';
6
- import '../../renderer/color/utils/constants.js';
4
+ import { getNumber } from '../../syntax/color/color.js';
5
+ import '../../syntax/color/utils/constants.js';
7
6
  import '../minify.js';
8
7
  import '../walk.js';
9
8
  import '../../parser/parse.js';
10
9
  import '../../parser/tokenize.js';
11
10
  import '../../parser/utils/config.js';
11
+ import '../../renderer/sourcemap/lib/encode.js';
12
+ import { minifyNumber } from '../../syntax/utils.js';
12
13
 
13
14
  function parseMatrix(mat) {
14
15
  if (mat.typ == EnumToken.IdenTokenType) {
@@ -87,7 +88,7 @@ function serialize(matrix) {
87
88
  }
88
89
  acc.push({
89
90
  typ: EnumToken.NumberTokenType,
90
- val: reduceNumber(t)
91
+ val: minifyNumber(t)
91
92
  });
92
93
  return acc;
93
94
  }, [])
@@ -102,7 +103,7 @@ function serialize(matrix) {
102
103
  }
103
104
  acc.push({
104
105
  typ: EnumToken.NumberTokenType,
105
- val: reduceNumber(curr)
106
+ val: minifyNumber(curr)
106
107
  });
107
108
  return acc;
108
109
  }, [])
@@ -36,20 +36,21 @@ function minify(matrix) {
36
36
  coordinates.delete(i == 0 ? 'x' : i == 1 ? 'y' : 'z');
37
37
  }
38
38
  }
39
- if (coordinates.size == 3) {
40
- result.push({
41
- typ: EnumToken.FunctionTokenType,
42
- val: 'translate3d',
43
- chi: [
44
- { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[0]) + '', unit: 'px' },
45
- { typ: EnumToken.CommaTokenType },
46
- { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[1]) + '', unit: 'px' },
47
- { typ: EnumToken.CommaTokenType },
48
- { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[2]) + '', unit: 'px' }
49
- ]
50
- });
51
- }
52
- else if (coordinates.size == 1) {
39
+ // if (coordinates.size == 3) {
40
+ //
41
+ // result.push({
42
+ // typ: EnumToken.FunctionTokenType,
43
+ // val: 'translate3d',
44
+ // chi: [
45
+ // {typ: EnumToken.LengthTokenType, val: round(decomposed.translate[0]) + '', unit: 'px'},
46
+ // {typ: EnumToken.CommaTokenType},
47
+ // {typ: EnumToken.LengthTokenType, val: round(decomposed.translate[1]) + '', unit: 'px'},
48
+ // {typ: EnumToken.CommaTokenType},
49
+ // {typ: EnumToken.LengthTokenType, val: round(decomposed.translate[2]) + '', unit: 'px'}
50
+ // ]
51
+ // })
52
+ // } else
53
+ if (coordinates.size == 1) {
53
54
  if (coordinates.has('x')) {
54
55
  result.push({
55
56
  typ: EnumToken.FunctionTokenType,
@@ -91,15 +92,9 @@ function minify(matrix) {
91
92
  typ: EnumToken.FunctionTokenType,
92
93
  val: 'translate',
93
94
  chi: [
94
- decomposed.translate[0] == 0 ? {
95
- typ: EnumToken.NumberTokenType,
96
- 'val': '0'
97
- } : { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[0]) + '', unit: 'px' },
95
+ { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[0]) + '', unit: 'px' },
98
96
  { typ: EnumToken.CommaTokenType },
99
- decomposed.translate[1] == 0 ? {
100
- typ: EnumToken.NumberTokenType,
101
- 'val': '0'
102
- } : { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[1]) + '', unit: 'px' }
97
+ { typ: EnumToken.LengthTokenType, val: round(decomposed.translate[1]) + '', unit: 'px' }
103
98
  ]
104
99
  });
105
100
  }
@@ -175,9 +170,10 @@ function minify(matrix) {
175
170
  }
176
171
  }
177
172
  if (transforms.has('skew')) {
178
- if (round(decomposed.skew[0]) == 0) {
179
- skew.delete('x');
180
- }
173
+ // if (round(decomposed.skew[0]) == 0) {
174
+ //
175
+ // skew.delete('x');
176
+ // }
181
177
  if (round(decomposed.skew[1]) == 0) {
182
178
  skew.delete('y');
183
179
  }
@@ -251,15 +247,16 @@ function minify(matrix) {
251
247
  });
252
248
  }
253
249
  }
254
- if (transforms.has('perspective')) {
255
- result.push({
256
- typ: EnumToken.FunctionTokenType,
257
- val: 'perspective',
258
- chi: [
259
- { typ: EnumToken.Length, val: '' + round(1 / decomposed.perspective[2]), unit: 'px' },
260
- ]
261
- });
262
- }
250
+ // if (transforms.has('perspective')) {
251
+ //
252
+ // result.push({
253
+ // typ: EnumToken.FunctionTokenType,
254
+ // val: 'perspective',
255
+ // chi: [
256
+ // {typ: EnumToken.Length, val: '' + round(1 / decomposed.perspective[2]), unit: 'px'},
257
+ // ]
258
+ // });
259
+ // }
263
260
  // identity
264
261
  return result.length == 0 || (result.length == 1 && eqMatrix(identity(), result)) ? [
265
262
  {
@@ -12,10 +12,16 @@ function normalize(point) {
12
12
  return norm === 0 ? [0, 0, 0] : [x / norm, y / norm, z / norm];
13
13
  }
14
14
  function dot(point1, point2) {
15
- if (point1.length === 4 && point2.length === 4) {
16
- return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2] + point1[3] * point2[3];
15
+ // if (point1.length === 4 && point2.length === 4) {
16
+ //
17
+ // return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2] + point1[3] * point2[3];
18
+ // }
19
+ let result = 0;
20
+ for (let i = 0; i < point1.length; i++) {
21
+ result += point1[i] * point2[i];
17
22
  }
18
- return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2];
23
+ return result;
24
+ // return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2];
19
25
  }
20
26
  function multiply(matrixA, matrixB) {
21
27
  let result = Array(4).fill(0).map(() => Array(4).fill(0));
@@ -28,6 +34,69 @@ function multiply(matrixA, matrixB) {
28
34
  }
29
35
  return result;
30
36
  }
37
+ function inverse(matrix) {
38
+ // Create augmented matrix [matrix | identity]
39
+ let augmented = matrix.map((row, i) => [
40
+ ...row,
41
+ ...(i === 0 ? [1, 0, 0, 0] :
42
+ i === 1 ? [0, 1, 0, 0] :
43
+ i === 2 ? [0, 0, 1, 0] :
44
+ [0, 0, 0, 1])
45
+ ]);
46
+ // Gaussian elimination with partial pivoting
47
+ for (let col = 0; col < 4; col++) {
48
+ // Find pivot row with maximum absolute value
49
+ let maxRow = col;
50
+ let maxVal = Math.abs(augmented[col][col]);
51
+ for (let row = col + 1; row < 4; row++) {
52
+ let val = Math.abs(augmented[row][col]);
53
+ if (val > maxVal) {
54
+ maxVal = val;
55
+ maxRow = row;
56
+ }
57
+ }
58
+ // Check for singularity
59
+ if (maxVal < 1e-5) {
60
+ return null;
61
+ }
62
+ // Swap rows if necessary
63
+ if (maxRow !== col) {
64
+ [augmented[col], augmented[maxRow]] = [augmented[maxRow], augmented[col]];
65
+ }
66
+ // Scale pivot row to make pivot element 1
67
+ let pivot = augmented[col][col];
68
+ for (let j = 0; j < 8; j++) {
69
+ augmented[col][j] /= pivot;
70
+ }
71
+ // Eliminate column in other rows
72
+ for (let row = 0; row < 4; row++) {
73
+ if (row !== col) {
74
+ let factor = augmented[row][col];
75
+ for (let j = 0; j < 8; j++) {
76
+ augmented[row][j] -= factor * augmented[col][j];
77
+ }
78
+ }
79
+ }
80
+ }
81
+ // Extract the inverse from the right side of the augmented matrix
82
+ return augmented.map(row => row.slice(4));
83
+ }
84
+ // function transpose(matrix: Matrix): Matrix {
85
+ // // Crée une nouvelle matrice vide 4x4
86
+ // // @ts-ignore
87
+ // let transposed: Matrix = [[], [], [], []] as Matrix;
88
+ //
89
+ // // Parcourt chaque ligne et colonne pour transposer
90
+ // for (let i = 0; i < 4; i++) {
91
+ //
92
+ // for (let j = 0; j < 4; j++) {
93
+ //
94
+ // transposed[j][i] = matrix[i][j];
95
+ // }
96
+ // }
97
+ //
98
+ // return transposed;
99
+ // }
31
100
  function round(number) {
32
101
  return Math.abs(number) < epsilon ? 0 : +number.toPrecision(6);
33
102
  }
@@ -50,11 +119,12 @@ function decompose(original) {
50
119
  perspectiveMatrix[7] = 0;
51
120
  perspectiveMatrix[11] = 0;
52
121
  perspectiveMatrix[15] = 1;
53
- const inverse = invertMatrix4(perspectiveMatrix);
54
- if (!inverse) {
122
+ // @ts-ignore
123
+ const inverted = inverse(original.reduce((acc, row, i) => acc.concat([row.slice()]), []))?.flat?.();
124
+ if (!inverted) {
55
125
  return null;
56
126
  }
57
- const transposedInverse = transposeMatrix4(inverse);
127
+ const transposedInverse = transposeMatrix4(inverted);
58
128
  perspective[0] = dot(rightHandSide, transposedInverse.slice(0, 4));
59
129
  perspective[1] = dot(rightHandSide, transposedInverse.slice(4, 8));
60
130
  perspective[2] = dot(rightHandSide, transposedInverse.slice(8, 12));
@@ -159,16 +229,6 @@ function transposeMatrix4(m) {
159
229
  m[3], m[7], m[11], m[15],
160
230
  ];
161
231
  }
162
- function invertMatrix4(m) {
163
- new Array(16);
164
- const det = m[0] * m[5] * m[10] * m[15] + m[0] * m[9] * m[14] * m[7] + m[0] * m[13] * m[6] * m[11]
165
- - m[0] * m[13] * m[10] * m[7] - m[0] * m[9] * m[6] * m[15] - m[0] * m[5] * m[14] * m[11];
166
- if (det === 0)
167
- return null;
168
- // For brevity, not implementing full inverse here — you'd normally use gl-matrix or similar.
169
- // Just use a trusted library or expand this if needed.
170
- return null; // placeholder
171
- }
172
232
  function toZero(v) {
173
233
  for (let i = 0; i < v.length; i++) {
174
234
  if (Math.abs(v[i]) <= epsilon) {
@@ -154,5 +154,36 @@ var EnumToken;
154
154
  EnumToken[EnumToken["TimingFunction"] = 17] = "TimingFunction";
155
155
  EnumToken[EnumToken["TimelineFunction"] = 16] = "TimelineFunction";
156
156
  })(EnumToken || (EnumToken = {}));
157
+ // xyz-d65 is an alias for xyz
158
+ var ColorType;
159
+ (function (ColorType) {
160
+ ColorType[ColorType["SYS"] = 0] = "SYS";
161
+ ColorType[ColorType["DPSYS"] = 1] = "DPSYS";
162
+ ColorType[ColorType["LIT"] = 2] = "LIT";
163
+ ColorType[ColorType["HEX"] = 3] = "HEX";
164
+ ColorType[ColorType["RGBA"] = 4] = "RGBA";
165
+ ColorType[ColorType["HSLA"] = 5] = "HSLA";
166
+ ColorType[ColorType["HWB"] = 6] = "HWB";
167
+ ColorType[ColorType["CMYK"] = 7] = "CMYK";
168
+ ColorType[ColorType["OKLAB"] = 8] = "OKLAB";
169
+ ColorType[ColorType["OKLCH"] = 9] = "OKLCH";
170
+ ColorType[ColorType["LAB"] = 10] = "LAB";
171
+ ColorType[ColorType["LCH"] = 11] = "LCH";
172
+ ColorType[ColorType["COLOR"] = 12] = "COLOR";
173
+ ColorType[ColorType["SRGB"] = 13] = "SRGB";
174
+ ColorType[ColorType["PROPHOTO_RGB"] = 14] = "PROPHOTO_RGB";
175
+ ColorType[ColorType["A98_RGB"] = 15] = "A98_RGB";
176
+ ColorType[ColorType["REC2020"] = 16] = "REC2020";
177
+ ColorType[ColorType["DISPLAY_P3"] = 17] = "DISPLAY_P3";
178
+ ColorType[ColorType["SRGB_LINEAR"] = 18] = "SRGB_LINEAR";
179
+ ColorType[ColorType["XYZ_D50"] = 19] = "XYZ_D50";
180
+ ColorType[ColorType["XYZ_D65"] = 20] = "XYZ_D65";
181
+ ColorType[ColorType["LIGHT_DARK"] = 21] = "LIGHT_DARK";
182
+ ColorType[ColorType["COLOR_MIX"] = 22] = "COLOR_MIX";
183
+ ColorType[ColorType["RGB"] = 4] = "RGB";
184
+ ColorType[ColorType["HSL"] = 5] = "HSL";
185
+ ColorType[ColorType["XYZ"] = 20] = "XYZ";
186
+ ColorType[ColorType["DEVICE_CMYK"] = 7] = "DEVICE_CMYK";
187
+ })(ColorType || (ColorType = {}));
157
188
 
158
- export { EnumToken, SyntaxValidationResult, ValidationLevel };
189
+ export { ColorType, EnumToken, SyntaxValidationResult, ValidationLevel };
@@ -71,27 +71,14 @@ function resolve(url, currentDirectory, cwd) {
71
71
  relative: path
72
72
  };
73
73
  }
74
- let result;
74
+ let result = '';
75
75
  if (url.charAt(0) == '/') {
76
76
  result = url;
77
77
  }
78
78
  else if (currentDirectory.charAt(0) == '/') {
79
79
  result = dirname(currentDirectory) + '/' + url;
80
80
  }
81
- else if (currentDirectory === '' || dirname(currentDirectory) === '') {
82
- result = url;
83
- }
84
- else {
85
- result = dirname(currentDirectory) + '/' + url;
86
- }
87
81
  let { parts, i } = splitPath(result);
88
- if (parts.length == 0) {
89
- const path = result.charAt(0) == '/' ? '/' : '';
90
- return {
91
- absolute: path,
92
- relative: path
93
- };
94
- }
95
82
  const absolute = parts.join('/');
96
83
  const { parts: dirs } = splitPath(cwd ?? currentDirectory);
97
84
  for (const p of dirs) {
@@ -5,7 +5,7 @@ import '../../ast/minify.js';
5
5
  import '../../ast/walk.js';
6
6
  import { parseString } from '../parse.js';
7
7
  import '../tokenize.js';
8
- import '../../renderer/color/utils/constants.js';
8
+ import '../../syntax/color/utils/constants.js';
9
9
  import '../../renderer/sourcemap/lib/encode.js';
10
10
  import { PropertyMap } from './map.js';
11
11
 
@@ -7,7 +7,7 @@ import '../../ast/walk.js';
7
7
  import { parseString } from '../parse.js';
8
8
  import '../tokenize.js';
9
9
  import { renderToken } from '../../renderer/render.js';
10
- import '../../renderer/color/utils/constants.js';
10
+ import '../../syntax/color/utils/constants.js';
11
11
  import { PropertySet } from './set.js';
12
12
 
13
13
  const propertiesConfig = getConfig();
@@ -6,7 +6,7 @@ import '../parse.js';
6
6
  import '../tokenize.js';
7
7
  import '../utils/config.js';
8
8
  import { isLength } from '../../syntax/syntax.js';
9
- import '../../renderer/color/utils/constants.js';
9
+ import '../../syntax/color/utils/constants.js';
10
10
  import '../../renderer/sourcemap/lib/encode.js';
11
11
 
12
12
  function dedup(values) {