@tbela99/css-parser 1.6.6 → 1.6.8

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 (104) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/README.md +1 -58
  3. package/architecture.png +0 -0
  4. package/dist/index-umd-web.js +731 -459
  5. package/dist/index.cjs +724 -459
  6. package/dist/index.d.ts +67 -11
  7. package/dist/package.json.js +10 -0
  8. package/dist/{data → src/data}/properties.json.js +7 -0
  9. package/dist/{data → src/data}/validation.json.js +7 -0
  10. package/dist/{lib → src/lib}/ast/clone.js +7 -0
  11. package/dist/{lib → src/lib}/ast/expand.js +19 -10
  12. package/dist/{lib → src/lib}/ast/features/calc.js +7 -0
  13. package/dist/{lib → src/lib}/ast/features/if.js +7 -0
  14. package/dist/{lib → src/lib}/ast/features/index.js +7 -0
  15. package/dist/{lib → src/lib}/ast/features/inlinecssvariables.js +7 -0
  16. package/dist/{lib → src/lib}/ast/features/prefix.js +8 -3
  17. package/dist/{lib → src/lib}/ast/features/shorthand.js +7 -0
  18. package/dist/{lib → src/lib}/ast/features/transform.js +8 -1
  19. package/dist/{lib → src/lib}/ast/features/type.js +7 -0
  20. package/dist/{lib → src/lib}/ast/find.js +7 -0
  21. package/dist/{lib → src/lib}/ast/math/expression.js +7 -0
  22. package/dist/{lib → src/lib}/ast/math/math.js +7 -0
  23. package/dist/{lib → src/lib}/ast/minify.js +7 -0
  24. package/dist/{lib → src/lib}/ast/node.js +7 -0
  25. package/dist/{lib → src/lib}/ast/transform/compute.js +7 -0
  26. package/dist/{lib → src/lib}/ast/transform/matrix.js +7 -0
  27. package/dist/{lib → src/lib}/ast/transform/minify.js +7 -0
  28. package/dist/{lib → src/lib}/ast/transform/perspective.js +7 -0
  29. package/dist/{lib → src/lib}/ast/transform/rotate.js +7 -0
  30. package/dist/{lib → src/lib}/ast/transform/scale.js +7 -0
  31. package/dist/{lib → src/lib}/ast/transform/skew.js +7 -0
  32. package/dist/{lib → src/lib}/ast/transform/translate.js +7 -0
  33. package/dist/{lib → src/lib}/ast/transform/utils.js +7 -0
  34. package/dist/{lib → src/lib}/ast/types.js +28 -9
  35. package/dist/{lib → src/lib}/ast/walk.js +16 -0
  36. package/dist/{lib → src/lib}/fs/resolve.js +7 -0
  37. package/dist/{lib → src/lib}/parser/declaration/list.js +24 -8
  38. package/dist/{lib → src/lib}/parser/declaration/map.js +9 -1
  39. package/dist/{lib → src/lib}/parser/declaration/set.js +7 -0
  40. package/dist/{lib → src/lib}/parser/linesmap.js +7 -0
  41. package/dist/{lib → src/lib}/parser/parse.js +93 -49
  42. package/dist/{lib → src/lib}/parser/source.js +7 -0
  43. package/dist/{lib → src/lib}/parser/tokenize.js +24 -3
  44. package/dist/{lib → src/lib}/parser/utils/angle.js +7 -0
  45. package/dist/{lib → src/lib}/parser/utils/at-rule-container.js +7 -0
  46. package/dist/{lib → src/lib}/parser/utils/at-rule-font-feature-values.js +7 -0
  47. package/dist/{lib → src/lib}/parser/utils/at-rule-generic.js +7 -0
  48. package/dist/{lib → src/lib}/parser/utils/at-rule-import.js +7 -0
  49. package/dist/{lib → src/lib}/parser/utils/at-rule-media.js +7 -0
  50. package/dist/{lib → src/lib}/parser/utils/at-rule-support.js +7 -0
  51. package/dist/{lib → src/lib}/parser/utils/at-rule-when-else.js +7 -0
  52. package/dist/{lib → src/lib}/parser/utils/at-rule.js +7 -0
  53. package/dist/{lib → src/lib}/parser/utils/base64.js +7 -0
  54. package/dist/{lib → src/lib}/parser/utils/cache.js +7 -0
  55. package/dist/{lib → src/lib}/parser/utils/config.js +7 -0
  56. package/dist/{lib → src/lib}/parser/utils/declaration.js +17 -0
  57. package/dist/{lib → src/lib}/parser/utils/eq.js +7 -0
  58. package/dist/{lib → src/lib}/parser/utils/hash.js +7 -0
  59. package/dist/{lib → src/lib}/parser/utils/selector.js +7 -0
  60. package/dist/{lib → src/lib}/parser/utils/text.js +7 -0
  61. package/dist/{lib → src/lib}/parser/utils/token.js +15 -4
  62. package/dist/{lib → src/lib}/parser/utils/type.js +7 -0
  63. package/dist/{lib → src/lib}/printer/render.js +20 -9
  64. package/dist/{lib → src/lib}/printer/sourcemap/lib/codec.js +7 -0
  65. package/dist/{lib → src/lib}/printer/sourcemap/sourcemap.js +7 -0
  66. package/dist/{lib → src/lib}/syntax/color/a98rgb.js +7 -0
  67. package/dist/{lib → src/lib}/syntax/color/alpha.js +7 -0
  68. package/dist/{lib → src/lib}/syntax/color/cmyk.js +7 -0
  69. package/dist/{lib → src/lib}/syntax/color/color-mix.js +139 -48
  70. package/dist/{lib → src/lib}/syntax/color/color.js +7 -1
  71. package/dist/{lib → src/lib}/syntax/color/hex.js +7 -0
  72. package/dist/{lib → src/lib}/syntax/color/hsl.js +52 -38
  73. package/dist/{lib → src/lib}/syntax/color/hwb.js +90 -53
  74. package/dist/{lib → src/lib}/syntax/color/lab.js +7 -0
  75. package/dist/{lib → src/lib}/syntax/color/lch.js +7 -0
  76. package/dist/{lib → src/lib}/syntax/color/oklab.js +8 -1
  77. package/dist/{lib → src/lib}/syntax/color/oklch.js +7 -0
  78. package/dist/{lib → src/lib}/syntax/color/p3.js +7 -0
  79. package/dist/{lib → src/lib}/syntax/color/prophotorgb.js +7 -0
  80. package/dist/{lib → src/lib}/syntax/color/rec2020.js +7 -0
  81. package/dist/{lib → src/lib}/syntax/color/relative-color.js +36 -0
  82. package/dist/{lib → src/lib}/syntax/color/rgb.js +7 -0
  83. package/dist/{lib → src/lib}/syntax/color/srgb.js +88 -58
  84. package/dist/{lib → src/lib}/syntax/color/utils/color-type.js +7 -0
  85. package/dist/{lib → src/lib}/syntax/color/utils/colorspace.js +7 -0
  86. package/dist/{lib → src/lib}/syntax/color/utils/components.js +7 -0
  87. package/dist/{lib → src/lib}/syntax/color/utils/distance.js +7 -0
  88. package/dist/{lib → src/lib}/syntax/color/utils/make-color.js +7 -0
  89. package/dist/{lib → src/lib}/syntax/color/utils/matrix.js +7 -0
  90. package/dist/{lib → src/lib}/syntax/color/xyz.js +7 -0
  91. package/dist/{lib → src/lib}/syntax/color/xyzd50.js +7 -0
  92. package/dist/{lib → src/lib}/syntax/constants.js +7 -0
  93. package/dist/{lib → src/lib}/syntax/syntax.js +7 -0
  94. package/dist/{lib → src/lib}/validation/config.js +7 -0
  95. package/dist/{lib → src/lib}/validation/match.js +37 -19
  96. package/dist/{lib → src/lib}/validation/parser/parse.js +7 -0
  97. package/dist/{lib → src/lib}/validation/parser/typedef.js +7 -0
  98. package/dist/{lib → src/lib}/validation/utils/list.js +7 -0
  99. package/dist/{node.js → src/node.js} +8 -0
  100. package/dist/{types.js → src/types.js} +7 -0
  101. package/dist/{utils → src/utils}/sync.js +7 -0
  102. package/dist/{web.js → src/web.js} +8 -0
  103. package/package.json +7 -6
  104. package/dist/lib/syntax/color/hsv.js +0 -20
@@ -1,9 +1,16 @@
1
- import { hwb2hsv } from './hsv.js';
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
2
8
  import { color2srgbvalues, getNumber } from './color.js';
3
9
  import { lch2rgbvalues, lab2rgbvalues, cmyk2rgbvalues } from './rgb.js';
4
10
  import { getColorComponents } from './utils/components.js';
5
- import { hex2srgbvalues, oklch2srgbvalues, oklab2srgbvalues, hslvalues } from './srgb.js';
11
+ import { hex2srgbvalues, oklch2srgbvalues, oklab2srgbvalues } from './srgb.js';
6
12
  import { EnumToken, ColorType } from '../../ast/types.js';
13
+ import { hwbvalues } from './hwb.js';
7
14
 
8
15
  function hex2HslToken(token) {
9
16
  let values = hex2srgbvalues(token);
@@ -69,11 +76,17 @@ function color2HslToken(token) {
69
76
  return hslToken(srgb2hslvalues(values[0], values[1], values[2], values[3]));
70
77
  }
71
78
  function hslToken(values) {
72
- values[0] = values[0] * 360;
79
+ if (values[1] == 0) {
80
+ values[0] = 0;
81
+ }
82
+ if (values[2] == 1 || values[2] == 0) {
83
+ values[0] = 0;
84
+ values[1] = 0;
85
+ }
73
86
  const chi = [
74
87
  { typ: EnumToken.NumberTokenType, val: values[0] },
75
- { typ: EnumToken.PercentageTokenType, val: values[1] * 100 },
76
- { typ: EnumToken.PercentageTokenType, val: values[2] * 100 },
88
+ { typ: EnumToken.PercentageTokenType, val: values[1] },
89
+ { typ: EnumToken.PercentageTokenType, val: values[2] },
77
90
  ];
78
91
  if (values.length == 4 && values[3] != 1) {
79
92
  chi.push({ typ: EnumToken.LiteralTokenType, val: "/" }, {
@@ -116,32 +129,33 @@ function rgb2hslvalues(token) {
116
129
  }
117
130
  return rgbvalues2hslvalues(values[0], values[1], values[2], values[3]);
118
131
  }
119
- // https://gist.github.com/defims/0ca2ef8832833186ed396a2f8a204117#file-annotated-js
120
- function hsv2hsl(h, s, v, a) {
121
- const result = [
122
- //[hue, saturation, lightness]
123
- //Range should be between 0 - 1
124
- h, //Hue stays the same
125
- //Saturation is very different between the two color spaces
126
- //If (2-sat)*val < 1 set it to sat*val/((2-sat)*val)
127
- //Otherwise sat*val/(2-(2-sat)*val)
128
- //Conditional is not operating with hue, it is reassigned!
129
- (s * v) / ((h = (2 - s) * v) < 1 ? h : 2 - h),
130
- h / 2, //Lightness is (2-sat)*val/2
131
- ];
132
- if (a != null) {
133
- result.push(a);
134
- }
135
- return result;
136
- }
137
132
  function cmyk2hslvalues(token) {
138
133
  const values = cmyk2rgbvalues(token);
139
134
  return values == null ? null : rgbvalues2hslvalues(values[0], values[1], values[2], values[3]);
140
135
  }
141
136
  function hwb2hslvalues(token) {
142
- const hsla = hslvalues(token);
143
- const hwba = hwb2hsv(hsla.h, hsla.s, hsla.l, hsla.a);
144
- return hsv2hsl(hwba[0], hwba[1], hwba[2], hwba[3]);
137
+ const { h, w, b, a } = hwbvalues(token) ?? {};
138
+ if (h == null || w == null || b == null) {
139
+ return null;
140
+ }
141
+ const wNorm = w / 100;
142
+ const bNorm = b / 100;
143
+ const hue = ((h % 360) + 360) % 360;
144
+ if (wNorm + bNorm >= 1) {
145
+ const grayLightness = wNorm / (wNorm + bNorm);
146
+ return [hue, 0, grayLightness * 100];
147
+ }
148
+ const lightness = (1 - bNorm + wNorm) / 2;
149
+ let saturation = 0;
150
+ if (lightness > 0 && lightness < 1) {
151
+ const chroma = 1 - wNorm - bNorm;
152
+ saturation = chroma / (1 - Math.abs(2 * lightness - 1));
153
+ }
154
+ const hsl = [hue, saturation * 100, lightness * 100];
155
+ if (a != null && a != 1) {
156
+ hsl.push(a);
157
+ }
158
+ return hsl;
145
159
  }
146
160
  function lab2hslvalues(token) {
147
161
  const values = lab2rgbvalues(token);
@@ -172,28 +186,28 @@ function rgbvalues2hslvalues(r, g, b, a = null) {
172
186
  return srgb2hslvalues(r / 255, g / 255, b / 255, a);
173
187
  }
174
188
  function srgb2hslvalues(r, g, b, a = null) {
175
- let max = Math.max(r, g, b);
176
- let min = Math.min(r, g, b);
189
+ const max = Math.max(r, g, b);
190
+ const min = Math.min(r, g, b);
191
+ const delta = max - min;
192
+ const l = (max + min) / 2;
177
193
  let h = 0;
178
194
  let s = 0;
179
- let l = (max + min) / 2;
180
- if (max != min) {
181
- let d = max - min;
182
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
195
+ if (delta !== 0) {
196
+ s = delta / (1 - Math.abs(2 * l - 1));
183
197
  switch (max) {
184
198
  case r:
185
- h = (g - b) / d + (g < b ? 6 : 0);
199
+ h = 60 * (((g - b) / delta) % 6);
186
200
  break;
187
201
  case g:
188
- h = (b - r) / d + 2;
202
+ h = 60 * ((b - r) / delta + 2);
189
203
  break;
190
204
  case b:
191
- h = (r - g) / d + 4;
205
+ h = 60 * ((r - g) / delta + 4);
192
206
  break;
193
207
  }
194
- h /= 6;
195
208
  }
196
- const hsl = [h, s, l];
209
+ h = ((h % 360) + 360) % 360;
210
+ const hsl = [h, s * 100, l * 100];
197
211
  if (a != null && a < 1) {
198
212
  // @ts-ignore
199
213
  return hsl.concat([a]);
@@ -202,4 +216,4 @@ function srgb2hslvalues(r, g, b, a = null) {
202
216
  return hsl;
203
217
  }
204
218
 
205
- export { cmyk2HslToken, cmyk2hslvalues, color2HslToken, hex2HslToken, hsv2hsl, hwb2HslToken, hwb2hslvalues, lab2HslToken, lab2hslvalues, lch2HslToken, lch2hslvalues, oklab2HslToken, oklab2hslvalues, oklch2HslToken, oklch2hslvalues, rgb2HslToken, rgb2hslvalues, rgbvalues2hslvalues, srgb2hslvalues };
219
+ export { cmyk2HslToken, cmyk2hslvalues, color2HslToken, hex2HslToken, hwb2HslToken, hwb2hslvalues, lab2HslToken, lab2hslvalues, lch2HslToken, lch2hslvalues, oklab2HslToken, oklab2hslvalues, oklch2HslToken, oklch2hslvalues, rgb2HslToken, rgb2hslvalues, rgbvalues2hslvalues, srgb2hslvalues };
@@ -1,8 +1,14 @@
1
- import { hsl2hsv } from './hsv.js';
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
2
8
  import { getColorComponents } from './utils/components.js';
3
- import { color2srgbvalues, getAngle, getNumber } from './color.js';
9
+ import { color2srgbvalues, getNumber, getAngle } from './color.js';
4
10
  import { EnumToken, ColorType } from '../../ast/types.js';
5
- import { cmyk2srgbvalues, lch2srgbvalues, lab2srgbvalues, oklch2srgbvalues, oklab2srgbvalues } from './srgb.js';
11
+ import { cmyk2srgbvalues, lch2srgbvalues, lab2srgbvalues, oklch2srgbvalues, oklab2srgbvalues, hslvalues } from './srgb.js';
6
12
 
7
13
  function rgb2hwbToken(token) {
8
14
  const values = rgb2hwbvalues(token);
@@ -16,6 +22,7 @@ function hsl2hwbToken(token) {
16
22
  if (values == null) {
17
23
  return null;
18
24
  }
25
+ // console.error(new Error("hsl2hwbToken"));
19
26
  return hwbToken(values);
20
27
  }
21
28
  function cmyk2hwbToken(token) {
@@ -61,11 +68,10 @@ function color2hwbToken(token) {
61
68
  return hwbToken(values);
62
69
  }
63
70
  function hwbToken(values) {
64
- values[0] = values[0] * 360;
65
71
  const chi = [
66
72
  { typ: EnumToken.NumberTokenType, val: values[0] },
67
- { typ: EnumToken.PercentageTokenType, val: values[1] * 100 },
68
- { typ: EnumToken.PercentageTokenType, val: values[2] * 100 },
73
+ { typ: EnumToken.PercentageTokenType, val: values[1] },
74
+ { typ: EnumToken.PercentageTokenType, val: values[2] },
69
75
  ];
70
76
  if (values.length == 4) {
71
77
  chi.push({ typ: EnumToken.LiteralTokenType, val: "/" }, {
@@ -95,17 +101,12 @@ function cmyk2hwbvalues(token) {
95
101
  return values == null ? null : srgb2hwb(values[0], values[1], values[2], values[3]);
96
102
  }
97
103
  function hsl2hwbvalues(token) {
98
- const values = getColorComponents(token).map((t, index) => {
99
- if (index == 3 && t.typ == EnumToken.IdenTokenType && t.val == "none") {
100
- return 1;
101
- }
102
- if (index == 0) {
103
- return getAngle(t);
104
- }
105
- return getNumber(t);
106
- });
104
+ const values = hslvalues(token);
105
+ if (values == null) {
106
+ return null;
107
+ }
107
108
  // @ts-ignore
108
- return hslvalues2hwbvalues(values[0], values[1], values[2], values[3]);
109
+ return hslvalues2hwbvalues(values.h, values.s, values.l, values.a);
109
110
  }
110
111
  function lab2hwbvalues(token) {
111
112
  const values = lab2srgbvalues(token);
@@ -134,26 +135,6 @@ function oklch2hwbvalues(token) {
134
135
  // @ts-ignore
135
136
  return values == null ? null : srgb2hwb(values[0], values[1], values[2], values[3]);
136
137
  }
137
- function rgb2hue(r, g, b, fallback = 0) {
138
- let value = rgb2value(r, g, b);
139
- let whiteness = rgb2whiteness(r, g, b);
140
- let delta = value - whiteness;
141
- if (delta > 0) {
142
- // calculate segment
143
- let segment = value === r ? (g - b) / delta : value === g ? (b - r) / delta : (r - g) / delta;
144
- // calculate shift
145
- let shift = value === r ? (segment < 0 ? 360 / 60 : 0 / 60) : value === g ? 120 / 60 : 240 / 60;
146
- // calculate hue
147
- return (segment + shift) * 60;
148
- }
149
- return fallback;
150
- }
151
- function rgb2value(r, g, b) {
152
- return Math.max(r, g, b);
153
- }
154
- function rgb2whiteness(r, g, b) {
155
- return Math.min(r, g, b);
156
- }
157
138
  function color2hwbvalues(token) {
158
139
  const values = color2srgbvalues(token);
159
140
  if (values == null) {
@@ -162,31 +143,87 @@ function color2hwbvalues(token) {
162
143
  // @ts-ignore
163
144
  return srgb2hwb(values[0], values[1], values[2], values[3]);
164
145
  }
165
- function srgb2hwb(r, g, b, a = null, fallback = 0) {
166
- r *= 100;
167
- g *= 100;
146
+ function hwbvalues(token) {
147
+ const components = getColorComponents(token);
148
+ if (components == null) {
149
+ return null;
150
+ }
151
+ let t;
152
+ // @ts-ignore
153
+ let h = getAngle(components[0]) * 360;
154
+ // @ts-ignore
155
+ t = components[1];
156
+ // @ts-ignore
157
+ let w = getNumber(t);
158
+ // @ts-ignore
159
+ t = components[2];
160
+ // @ts-ignore
161
+ let b = getNumber(t);
162
+ // if (components[1].typ == EnumToken.NumberTokenType) {
163
+ w *= 100;
164
+ // }
165
+ // if (components[2].typ == EnumToken.NumberTokenType) {
168
166
  b *= 100;
169
- let hue = rgb2hue(r, g, b, fallback);
170
- let whiteness = rgb2whiteness(r, g, b);
171
- let value = Math.round(rgb2value(r, g, b));
172
- let blackness = 100 - value;
173
- const result = [hue / 360, whiteness / 100, blackness / 100];
174
- if (a != null) {
175
- result.push(a);
167
+ // }
168
+ let a = null;
169
+ if (components.length == 4) {
170
+ // @ts-ignore
171
+ t = components[3];
172
+ // @ts-ignore
173
+ a = getNumber(t);
176
174
  }
177
- return result;
175
+ return a == null ? { h, w, b } : { h, w, b, a };
178
176
  }
179
- function hsv2hwb(h, s, v, a = null) {
180
- const result = [h, (1 - s) * v, 1 - v];
177
+ function srgb2hwb(r, g, b, a = null, fallback = 0) {
178
+ // 1. Clamp inputs to the standard web-safe sRGB gamut [0.0, 1.0]
179
+ const rClamp = Math.min(1, Math.max(0, r));
180
+ const gClamp = Math.min(1, Math.max(0, g));
181
+ const bClamp = Math.min(1, Math.max(0, b));
182
+ const cMax = Math.max(rClamp, gClamp, bClamp);
183
+ const cMin = Math.min(rClamp, gClamp, bClamp);
184
+ const delta = cMax - cMin;
185
+ // 2. Whiteness and Blackness calculations
186
+ const w = cMin;
187
+ const bl = 1 - cMax;
188
+ // 3. Calculate Hue
189
+ let h = 0;
190
+ if (delta !== 0) {
191
+ if (cMax === rClamp) {
192
+ h = 60 * (((gClamp - bClamp) / delta) % 6);
193
+ }
194
+ else if (cMax === gClamp) {
195
+ h = 60 * ((bClamp - rClamp) / delta + 2);
196
+ }
197
+ else if (cMax === bClamp) {
198
+ h = 60 * ((rClamp - gClamp) / delta + 4);
199
+ }
200
+ if (h < 0) {
201
+ h += 360;
202
+ }
203
+ }
204
+ const result = [h, w * 100, bl * 100];
181
205
  if (a != null) {
182
206
  result.push(a);
183
207
  }
184
208
  return result;
185
209
  }
186
210
  function hslvalues2hwbvalues(h, s, l, a = null) {
187
- let values = hsl2hsv(h, s, l);
188
- // @ts-ignore
189
- return hsv2hwb(values[0], values[1], values[2], a);
211
+ const sNorm = s / 100;
212
+ const lNorm = l / 100;
213
+ // Keep Hue cleanly bound to standard circle loops
214
+ const hue = ((h % 360) + 360) % 360;
215
+ // 1. Compute the intermediate HSV Value component (brightness peak)
216
+ const v = lNorm + sNorm * Math.min(lNorm, 1 - lNorm);
217
+ // 2. Compute Chroma
218
+ const chroma = 2 * (v - lNorm);
219
+ // 3. Extract Whiteness and Blackness
220
+ const w = v - chroma;
221
+ const b = 1 - v;
222
+ const hwb = [hue, w * 100, b * 100];
223
+ if (a != null && a != 1) {
224
+ hwb.push(a);
225
+ }
226
+ return hwb;
190
227
  }
191
228
 
192
- export { cmyk2hwbToken, cmyk2hwbvalues, color2hwbToken, color2hwbvalues, hsl2hwbToken, hsl2hwbvalues, hslvalues2hwbvalues, hsv2hwb, hwbToken, lab2hwbToken, lab2hwbvalues, lch2hwbToken, lch2hwbvalues, oklab2hwbToken, oklab2hwbvalues, oklch2hwbToken, oklch2hwbvalues, rgb2hwbToken, rgb2hwbvalues, srgb2hwb };
229
+ export { cmyk2hwbToken, cmyk2hwbvalues, color2hwbToken, color2hwbvalues, hsl2hwbToken, hsl2hwbvalues, hslvalues2hwbvalues, hwbToken, hwbvalues, lab2hwbToken, lab2hwbvalues, lch2hwbToken, lch2hwbvalues, oklab2hwbToken, oklab2hwbvalues, oklch2hwbToken, oklch2hwbvalues, rgb2hwbToken, rgb2hwbvalues, srgb2hwb };
@@ -1,3 +1,10 @@
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
1
8
  import { e, k, D50 } from '../constants.js';
2
9
  import { getColorComponents } from './utils/components.js';
3
10
  import { srgb2xyz_d65, XYZ_D50_to_D65 } from './xyz.js';
@@ -1,3 +1,10 @@
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
1
8
  import { getColorComponents } from './utils/components.js';
2
9
  import { color2srgbvalues, getNumber, getAngle } from './color.js';
3
10
  import { EnumToken, ColorType } from '../../ast/types.js';
@@ -1,3 +1,10 @@
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
1
8
  import { getColorComponents } from './utils/components.js';
2
9
  import { multiplyMatrices } from './utils/matrix.js';
3
10
  import { srgb2lsrgbvalues, lch2srgbvalues, lab2srgbvalues, cmyk2srgbvalues, hwb2srgbvalues, hsl2srgb, rgb2srgb, hex2srgbvalues, lsrgb2srgbvalues } from './srgb.js';
@@ -75,7 +82,7 @@ function oklabToken(values) {
75
82
  { typ: EnumToken.NumberTokenType, val: values[1] },
76
83
  { typ: EnumToken.NumberTokenType, val: values[2] },
77
84
  ];
78
- if (values.length == 4) {
85
+ if (values.length == 4 && values[3] != 1) {
79
86
  chi.push({ typ: EnumToken.LiteralTokenType, val: "/" }, {
80
87
  typ: EnumToken.PercentageTokenType,
81
88
  val: values[3] * 100,
@@ -1,3 +1,10 @@
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
1
8
  import { getColorComponents } from './utils/components.js';
2
9
  import { color2srgbvalues, getNumber, getAngle } from './color.js';
3
10
  import { EnumToken, ColorType } from '../../ast/types.js';
@@ -1,3 +1,10 @@
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
1
8
  import { lsrgb2srgbvalues, xyz2srgb, srgb2lsrgbvalues } from './srgb.js';
2
9
  import { multiplyMatrices } from './utils/matrix.js';
3
10
  import { srgb2xyz } from './xyz.js';
@@ -1,3 +1,10 @@
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
1
8
  import { XYZ_D65_to_D50, xyzd502srgb } from './xyzd50.js';
2
9
  import { srgb2xyz } from './xyz.js';
3
10
 
@@ -1,3 +1,10 @@
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
1
8
  import { xyz2srgb } from './srgb.js';
2
9
  import { multiplyMatrices } from './utils/matrix.js';
3
10
  import { srgb2xyz } from './xyz.js';
@@ -1,3 +1,10 @@
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
1
8
  import { convertColor, getNumber } from './color.js';
2
9
  import { EnumToken, ColorType } from '../../ast/types.js';
3
10
  import { walkValues } from '../../ast/walk.js';
@@ -151,7 +158,36 @@ function parseRelativeColorComponents(relativeKeys, original, rExp, gExp, bExp,
151
158
  : aExp),
152
159
  };
153
160
  const result = computeComponentValue(keys, values);
161
+ if (result != null) {
162
+ if ("hsl" == relativeKeys) {
163
+ Object.assign(result.s, {
164
+ typ: EnumToken.PercentageTokenType,
165
+ // @ts-ignore
166
+ val: result.s.val * 100,
167
+ });
168
+ Object.assign(result.l, {
169
+ typ: EnumToken.PercentageTokenType,
170
+ // @ts-ignore
171
+ val: result.l.val * 100,
172
+ });
173
+ }
174
+ else if ("hwb" == relativeKeys) {
175
+ // @ts
176
+ Object.assign(result.w, {
177
+ typ: EnumToken.PercentageTokenType,
178
+ // @ts-ignore
179
+ val: result.w.val * 100,
180
+ });
181
+ Object.assign(result.b, {
182
+ typ: EnumToken.PercentageTokenType,
183
+ // @ts-ignore
184
+ val: result.b.val * 100,
185
+ });
186
+ }
187
+ }
188
+ // @ts-ignore
154
189
  if (result?.alpha?.typ == EnumToken.NumberTokenType && result.alpha.val === 1) {
190
+ // @ts-ignore
155
191
  const { alpha, ...components } = result;
156
192
  return components;
157
193
  }
@@ -1,3 +1,10 @@
1
+ /*
2
+ CSS parser, minifier and validator for node and the browser
3
+
4
+ Author(s): Thierry Bela
5
+ Version: 1.6.8
6
+ License: MIT
7
+ */
1
8
  import { color2srgbvalues, minmax } from './color.js';
2
9
  import { expandHexValue } from './hex.js';
3
10
  import { hslvalues, hslvalues2srgbvalues, lch2srgbvalues, lab2srgbvalues, oklch2srgbvalues, oklab2srgbvalues, cmyk2srgbvalues, hwb2srgbvalues } from './srgb.js';