@tbela99/css-parser 2.0.1 → 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.
- package/CHANGELOG.md +86 -1
- package/README.md +15 -7
- package/architecture.png +0 -0
- package/dist/{src/data → data}/properties.json.js +86 -2
- package/dist/{src/data → data}/validation.json.js +4848 -3750
- package/dist/index-umd-web.js +18234 -9498
- package/dist/index.d.ts +1251 -373
- package/dist/{src/lib → lib}/ast/arena-node.js +119 -57
- package/dist/{src/lib → lib}/ast/arena.js +1034 -655
- package/dist/{src/lib → lib}/ast/cache.js +36 -31
- package/dist/{src/lib → lib}/ast/features/calc.js +37 -27
- package/dist/{src/lib → lib}/ast/features/if.js +24 -19
- package/dist/{src/lib → lib}/ast/features/index.js +3 -2
- package/dist/{src/lib → lib}/ast/features/inlinecssvariables.js +42 -23
- package/dist/lib/ast/features/mixin.js +953 -0
- package/dist/{src/lib → lib}/ast/features/prefix.js +82 -69
- package/dist/lib/ast/features/shorthand.js +129 -0
- package/dist/lib/ast/features/transform.js +188 -0
- package/dist/{src/lib → lib}/ast/features/type.js +2 -2
- package/dist/{src/lib → lib}/ast/math/expression.js +150 -150
- package/dist/{src/lib → lib}/ast/math/math.js +8 -8
- package/dist/{src/lib → lib}/ast/minify.js +932 -354
- package/dist/lib/ast/mixins/custom-function.js +393 -0
- package/dist/lib/ast/mixins/utils.js +53 -0
- package/dist/lib/ast/mixins/variables.js +678 -0
- package/dist/lib/ast/strings.js +906 -0
- package/dist/lib/ast/transform/compute.js +560 -0
- package/dist/lib/ast/transform/matrix.js +67 -0
- package/dist/lib/ast/transform/minify.js +325 -0
- package/dist/lib/ast/transform/perspective.js +24 -0
- package/dist/{src/lib → lib}/ast/transform/rotate.js +16 -7
- package/dist/lib/ast/transform/scale.js +43 -0
- package/dist/lib/ast/transform/skew.js +38 -0
- package/dist/lib/ast/transform/translate.js +56 -0
- package/dist/lib/ast/transform/utils.js +390 -0
- package/dist/{src/lib → lib}/ast/types.js +7 -15
- package/dist/{src/lib → lib}/ast/walk.js +19 -19
- package/dist/{src/lib → lib}/fs/resolve.js +15 -15
- package/dist/{src/lib → lib}/parser/declaration/list.js +55 -26
- package/dist/{src/lib → lib}/parser/declaration/map.js +85 -72
- package/dist/{src/lib → lib}/parser/declaration/set.js +32 -27
- package/dist/lib/parser/input.js +85 -0
- package/dist/{src/lib → lib}/parser/linesmap.js +3 -16
- package/dist/{src/lib → lib}/parser/parse.js +852 -619
- package/dist/lib/parser/source.js +71 -0
- package/dist/{src/lib → lib}/parser/tokenize.js +886 -722
- package/dist/{src/lib → lib}/parser/utils/angle.js +3 -3
- package/dist/{src/lib → lib}/parser/utils/at-rule-container.js +68 -35
- package/dist/{src/lib → lib}/parser/utils/at-rule-font-feature-values.js +3 -3
- package/dist/{src/lib → lib}/parser/utils/at-rule-generic.js +31 -13
- package/dist/{src/lib → lib}/parser/utils/at-rule-import.js +29 -16
- package/dist/{src/lib → lib}/parser/utils/at-rule-media.js +77 -58
- package/dist/{src/lib → lib}/parser/utils/at-rule-support.js +18 -20
- package/dist/{src/lib → lib}/parser/utils/at-rule-when-else.js +9 -8
- package/dist/{src/lib → lib}/parser/utils/at-rule.js +3 -3
- package/dist/{src/lib → lib}/parser/utils/base64.js +2 -2
- package/dist/lib/parser/utils/cache.js +53 -0
- package/dist/lib/parser/utils/canonical.js +78 -0
- package/dist/lib/parser/utils/codes.js +93 -0
- package/dist/{src/lib → lib}/parser/utils/config.js +2 -2
- package/dist/{src/lib → lib}/parser/utils/declaration.js +67 -49
- package/dist/{src/lib → lib}/parser/utils/eq.js +14 -14
- package/dist/{src/lib → lib}/parser/utils/hash.js +4 -4
- package/dist/lib/parser/utils/selector.js +720 -0
- package/dist/{src/lib → lib}/parser/utils/text.js +2 -2
- package/dist/{src/lib → lib}/parser/utils/token.js +2 -2
- package/dist/{src/lib → lib}/parser/utils/type.js +11 -9
- package/dist/{src/lib → lib}/printer/render.js +536 -243
- package/dist/lib/printer/result.js +148 -0
- package/dist/{src/lib → lib}/printer/sourcemap/lib/codec.js +5 -8
- package/dist/{src/lib → lib}/printer/sourcemap/sourcemap.js +13 -13
- package/dist/lib/printer/writer.js +252 -0
- package/dist/{src/lib → lib}/syntax/color/a98rgb.js +6 -6
- package/dist/{src/lib → lib}/syntax/color/alpha.js +12 -11
- package/dist/{src/lib → lib}/syntax/color/cmyk.js +11 -6
- package/dist/{src/lib → lib}/syntax/color/color-mix.js +78 -67
- package/dist/{src/lib → lib}/syntax/color/color.js +52 -47
- package/dist/{src/lib → lib}/syntax/color/hex.js +17 -17
- package/dist/{src/lib → lib}/syntax/color/hsl.js +8 -8
- package/dist/{src/lib → lib}/syntax/color/hwb.js +6 -7
- package/dist/{src/lib → lib}/syntax/color/lab.js +8 -8
- package/dist/{src/lib → lib}/syntax/color/lch.js +12 -11
- package/dist/{src/lib → lib}/syntax/color/oklab.js +9 -9
- package/dist/{src/lib → lib}/syntax/color/oklch.js +5 -5
- package/dist/{src/lib → lib}/syntax/color/p3.js +2 -2
- package/dist/{src/lib → lib}/syntax/color/prophotorgb.js +4 -4
- package/dist/{src/lib → lib}/syntax/color/rec2020.js +3 -3
- package/dist/{src/lib → lib}/syntax/color/relative-color.js +41 -34
- package/dist/{src/lib → lib}/syntax/color/rgb.js +17 -17
- package/dist/{src/lib → lib}/syntax/color/srgb.js +20 -20
- package/dist/{src/lib → lib}/syntax/color/utils/color-type.js +6 -4
- package/dist/{src/lib → lib}/syntax/color/utils/colorspace.js +12 -14
- package/dist/{src/lib → lib}/syntax/color/utils/components.js +13 -13
- package/dist/{src/lib → lib}/syntax/color/utils/distance.js +2 -2
- package/dist/{src/lib → lib}/syntax/color/utils/make-color.js +6 -4
- package/dist/{src/lib → lib}/syntax/color/utils/matrix.js +2 -2
- package/dist/{src/lib → lib}/syntax/color/xyz.js +5 -10
- package/dist/{src/lib → lib}/syntax/color/xyzd50.js +3 -3
- package/dist/{src/lib → lib}/syntax/constants.js +30 -3
- package/dist/{src/lib → lib}/syntax/syntax.js +151 -116
- package/dist/lib/validation/config.js +173 -0
- package/dist/lib/validation/first.js +571 -0
- package/dist/{src/lib → lib}/validation/match.js +1256 -579
- package/dist/{src/lib → lib}/validation/parser/parse.js +85 -59
- package/dist/{src/lib → lib}/validation/parser/typedef.js +6 -2
- package/dist/{src/lib → lib}/validation/utils/list.js +3 -19
- package/dist/{src/node.js → node.js} +92 -80
- package/dist/{src/types.js → types.js} +2 -2
- package/dist/{src/utils → utils}/sync.js +13 -8
- package/dist/version.d.ts +4 -0
- package/dist/version.js +13 -0
- package/dist/{src/web.js → web.js} +80 -75
- package/package.json +13 -13
- package/dist/package.json.js +0 -10
- package/dist/src/lib/ast/features/shorthand.js +0 -87
- package/dist/src/lib/ast/features/transform.js +0 -85
- package/dist/src/lib/ast/transform/compute.js +0 -358
- package/dist/src/lib/ast/transform/matrix.js +0 -88
- package/dist/src/lib/ast/transform/minify.js +0 -267
- package/dist/src/lib/ast/transform/perspective.js +0 -16
- package/dist/src/lib/ast/transform/scale.js +0 -39
- package/dist/src/lib/ast/transform/skew.js +0 -30
- package/dist/src/lib/ast/transform/translate.js +0 -39
- package/dist/src/lib/ast/transform/utils.js +0 -287
- package/dist/src/lib/parser/source.js +0 -127
- package/dist/src/lib/parser/utils/cache.js +0 -54
- package/dist/src/lib/parser/utils/selector.js +0 -440
- package/dist/src/lib/validation/config.js +0 -120
|
@@ -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.0
|
|
5
|
+
Version: 2.2.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { ColorType, EnumToken } from '../../ast/types.js';
|
|
@@ -33,6 +33,7 @@ import { equalsIgnoreCase } from '../../parser/utils/text.js';
|
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Converts a color to another color space
|
|
36
|
+
* @param arena
|
|
36
37
|
* @param token
|
|
37
38
|
* @param to
|
|
38
39
|
*
|
|
@@ -44,16 +45,19 @@ import { equalsIgnoreCase } from '../../parser/utils/text.js';
|
|
|
44
45
|
* ```
|
|
45
46
|
*/
|
|
46
47
|
function convertColor(arena, token, to) {
|
|
47
|
-
if (arena.colorType[token]
|
|
48
|
-
arena.colorType[token]
|
|
49
|
-
(isIdentColor(arena, token) && "currentcolor"
|
|
48
|
+
if (arena.colorType[token] === ColorType.SYS ||
|
|
49
|
+
arena.colorType[token] === ColorType.DPSYS ||
|
|
50
|
+
(isIdentColor(arena, token) && "currentcolor" === arena.resolveString(arena.stringValue[token]))) {
|
|
50
51
|
return token;
|
|
51
52
|
}
|
|
52
|
-
if (arena.colorType[token]
|
|
53
|
-
const args = arena
|
|
53
|
+
if (arena.colorType[token] === ColorType.ALPHA) {
|
|
54
|
+
const args = arena
|
|
55
|
+
.tokens(token)
|
|
56
|
+
.filter((token) => arena.dataTypes[token] !== EnumToken.WhitespaceTokenType &&
|
|
57
|
+
arena.dataTypes[token] !== EnumToken.CommentTokenType);
|
|
54
58
|
if (args.length > 1 &&
|
|
55
59
|
arena.dataTypes[args[args.length - 2]] === EnumToken.LiteralTokenType &&
|
|
56
|
-
"/" === arena.
|
|
60
|
+
"/" === arena.resolveString(arena.stringValue[args[args.length - 2]])) {
|
|
57
61
|
args.splice(args.length - 2, 1);
|
|
58
62
|
}
|
|
59
63
|
let values = trimArray(arena, args.slice(1));
|
|
@@ -63,12 +67,13 @@ function convertColor(arena, token, to) {
|
|
|
63
67
|
}
|
|
64
68
|
token = result;
|
|
65
69
|
}
|
|
66
|
-
if (arena.colorType[token]
|
|
70
|
+
if (arena.colorType[token] === ColorType.COLOR_MIX && to !== ColorType.COLOR_MIX) {
|
|
67
71
|
const children = arena.tokens(token).reduce((acc, t) => {
|
|
68
72
|
if (arena.dataTypes[t] === EnumToken.CommaTokenType) {
|
|
69
73
|
acc.push([]);
|
|
70
74
|
}
|
|
71
|
-
else if (arena.dataTypes[t] !== EnumToken.WhitespaceTokenType &&
|
|
75
|
+
else if (arena.dataTypes[t] !== EnumToken.WhitespaceTokenType &&
|
|
76
|
+
arena.dataTypes[t] !== EnumToken.CommentTokenType) {
|
|
72
77
|
acc[acc.length - 1].push(t);
|
|
73
78
|
}
|
|
74
79
|
return acc;
|
|
@@ -79,54 +84,54 @@ function convertColor(arena, token, to) {
|
|
|
79
84
|
}
|
|
80
85
|
token = result;
|
|
81
86
|
}
|
|
82
|
-
if (arena.
|
|
83
|
-
["rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch", "color"].some((t) => equalsIgnoreCase(t, arena.
|
|
87
|
+
if (arena.resolveString(arena.unit[token]) === "rel" &&
|
|
88
|
+
["rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch", "color"].some((t) => equalsIgnoreCase(t, arena.resolveString(arena.stringValue[token])))) {
|
|
84
89
|
const chi = getColorComponents(arena, token);
|
|
85
|
-
const offset = arena.
|
|
90
|
+
const offset = arena.resolveString(arena.stringValue[token]) === "color" ? 2 : 1;
|
|
86
91
|
if (chi != null) {
|
|
87
92
|
// @ts-ignore
|
|
88
93
|
const color = chi[1];
|
|
89
|
-
const components = parseRelativeColorComponents(arena, equalsIgnoreCase(arena.
|
|
90
|
-
? arena.
|
|
91
|
-
: arena.
|
|
94
|
+
const components = parseRelativeColorComponents(arena, equalsIgnoreCase(arena.resolveString(arena.stringValue[token]), "color")
|
|
95
|
+
? arena.resolveString(arena.stringValue[chi[offset]])
|
|
96
|
+
: arena.resolveString(arena.stringValue[token]), color, chi[offset + 1], chi[offset + 2], chi[offset + 3], chi[offset + 4]);
|
|
92
97
|
if (components == null) {
|
|
93
98
|
return null;
|
|
94
99
|
}
|
|
95
|
-
const name = arena.
|
|
96
|
-
const tk = arena.createColor(name, ColorType[name.toUpperCase().replaceAll("-", "_")], name
|
|
100
|
+
const name = arena.resolveString(arena.stringValue[token]);
|
|
101
|
+
const tk = arena.createColor(name, ColorType[name.toUpperCase().replaceAll("-", "_")], name === "color" ? [arena.clone(chi[offset])] : []);
|
|
97
102
|
const seen = new Set();
|
|
98
103
|
for (const t of Object.values(components)) {
|
|
99
104
|
// a component token may be used more than once: rgb(from #ff0 r g r)
|
|
100
105
|
// inlined: arena.take(t)
|
|
101
|
-
arena.appendToken(tk, seen.has(t) ? arena.clone(t, true) :
|
|
106
|
+
arena.appendToken(tk, seen.has(t) ? arena.clone(t, true) : arena.parents[t] === 0 ? t : arena.clone(t, true));
|
|
102
107
|
seen.add(t);
|
|
103
108
|
}
|
|
104
109
|
arena.copyLocation(tk, token);
|
|
105
110
|
token = tk;
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
|
-
if (arena.colorType[token]
|
|
109
|
-
if (arena.colorType[token]
|
|
110
|
-
const val = reduceHexValue(arena.
|
|
113
|
+
if (arena.colorType[token] === to) {
|
|
114
|
+
if (arena.colorType[token] === ColorType.HEX || arena.colorType[token] === ColorType.LIT) {
|
|
115
|
+
const val = reduceHexValue(arena.resolveString(arena.stringValue[token]));
|
|
111
116
|
// inlined: arena.setStr(token, val)
|
|
112
117
|
arena.stringValue[token] = arena.internString(val);
|
|
113
|
-
arena.colorType[token] = val[0]
|
|
118
|
+
arena.colorType[token] = val[0] === "#" ? ColorType.HEX : ColorType.LIT;
|
|
114
119
|
}
|
|
115
120
|
return token;
|
|
116
121
|
}
|
|
117
|
-
if (arena.colorType[token]
|
|
122
|
+
if (arena.colorType[token] === ColorType.COLOR) {
|
|
118
123
|
const colorSpace = arena.findToken(token, (arena, t) => ![EnumToken.WhitespaceTokenType, EnumToken.CommentTokenType].includes(arena.dataTypes[t]));
|
|
119
124
|
if (colorSpace != null &&
|
|
120
|
-
arena.
|
|
125
|
+
arena.resolveString(arena.stringValue[colorSpace]) === ColorType[to].toLowerCase().replaceAll("_", "-")) {
|
|
121
126
|
for (const chi of arena.tokens(token)) {
|
|
122
|
-
if (arena.dataTypes[chi]
|
|
127
|
+
if (arena.dataTypes[chi] === EnumToken.NumberTokenType && !arena.hasFraction(chi)) {
|
|
123
128
|
arena.numericValue[chi] = getNumber(arena, chi);
|
|
124
129
|
}
|
|
125
130
|
}
|
|
126
131
|
return token;
|
|
127
132
|
}
|
|
128
133
|
}
|
|
129
|
-
if (to
|
|
134
|
+
if (to === ColorType.HSL) {
|
|
130
135
|
switch (arena.colorType[token]) {
|
|
131
136
|
case ColorType.RGB:
|
|
132
137
|
case ColorType.RGBA:
|
|
@@ -150,7 +155,7 @@ function convertColor(arena, token, to) {
|
|
|
150
155
|
return color2HslToken(arena, token);
|
|
151
156
|
}
|
|
152
157
|
}
|
|
153
|
-
else if (to
|
|
158
|
+
else if (to === ColorType.HWB) {
|
|
154
159
|
switch (arena.colorType[token]) {
|
|
155
160
|
case ColorType.RGB:
|
|
156
161
|
case ColorType.RGBA:
|
|
@@ -175,7 +180,7 @@ function convertColor(arena, token, to) {
|
|
|
175
180
|
return color2hwbToken(arena, token);
|
|
176
181
|
}
|
|
177
182
|
}
|
|
178
|
-
else if (to
|
|
183
|
+
else if (to === ColorType.DEVICE_CMYK) {
|
|
179
184
|
switch (arena.colorType[token]) {
|
|
180
185
|
case ColorType.RGB:
|
|
181
186
|
case ColorType.RGBA:
|
|
@@ -200,12 +205,12 @@ function convertColor(arena, token, to) {
|
|
|
200
205
|
return color2cmykToken(arena, token);
|
|
201
206
|
}
|
|
202
207
|
}
|
|
203
|
-
else if (to
|
|
208
|
+
else if (to === ColorType.HEX || to === ColorType.LIT) {
|
|
204
209
|
switch (arena.colorType[token]) {
|
|
205
210
|
case ColorType.HEX:
|
|
206
211
|
case ColorType.LIT: {
|
|
207
|
-
const val = reduceHexValue(arena.
|
|
208
|
-
return arena.createColor(val, val[0]
|
|
212
|
+
const val = reduceHexValue(arena.resolveString(arena.stringValue[token]));
|
|
213
|
+
return arena.createColor(val, val[0] === "#" ? ColorType.HEX : ColorType.LIT);
|
|
209
214
|
}
|
|
210
215
|
case ColorType.HSL:
|
|
211
216
|
return hsl2HexToken(arena, token);
|
|
@@ -228,7 +233,7 @@ function convertColor(arena, token, to) {
|
|
|
228
233
|
return rgb2HexToken(arena, token);
|
|
229
234
|
}
|
|
230
235
|
}
|
|
231
|
-
else if (to
|
|
236
|
+
else if (to === ColorType.RGB) {
|
|
232
237
|
switch (arena.colorType[token]) {
|
|
233
238
|
case ColorType.HEX:
|
|
234
239
|
case ColorType.LIT:
|
|
@@ -251,7 +256,7 @@ function convertColor(arena, token, to) {
|
|
|
251
256
|
return color2RgbToken(arena, token);
|
|
252
257
|
}
|
|
253
258
|
}
|
|
254
|
-
else if (to
|
|
259
|
+
else if (to === ColorType.LAB) {
|
|
255
260
|
switch (arena.colorType[token]) {
|
|
256
261
|
case ColorType.HEX:
|
|
257
262
|
case ColorType.LIT:
|
|
@@ -276,7 +281,7 @@ function convertColor(arena, token, to) {
|
|
|
276
281
|
return color2labToken(arena, token);
|
|
277
282
|
}
|
|
278
283
|
}
|
|
279
|
-
else if (to
|
|
284
|
+
else if (to === ColorType.LCH) {
|
|
280
285
|
switch (arena.colorType[token]) {
|
|
281
286
|
case ColorType.HEX:
|
|
282
287
|
case ColorType.LIT:
|
|
@@ -301,7 +306,7 @@ function convertColor(arena, token, to) {
|
|
|
301
306
|
return color2lchToken(arena, token);
|
|
302
307
|
}
|
|
303
308
|
}
|
|
304
|
-
else if (to
|
|
309
|
+
else if (to === ColorType.OKLAB) {
|
|
305
310
|
switch (arena.colorType[token]) {
|
|
306
311
|
case ColorType.HEX:
|
|
307
312
|
case ColorType.LIT:
|
|
@@ -326,7 +331,7 @@ function convertColor(arena, token, to) {
|
|
|
326
331
|
return color2oklabToken(arena, token);
|
|
327
332
|
}
|
|
328
333
|
}
|
|
329
|
-
else if (to
|
|
334
|
+
else if (to === ColorType.OKLCH) {
|
|
330
335
|
switch (arena.colorType[token]) {
|
|
331
336
|
case ColorType.HEX:
|
|
332
337
|
case ColorType.LIT:
|
|
@@ -484,7 +489,7 @@ function color2srgbvalues(arena, token) {
|
|
|
484
489
|
}
|
|
485
490
|
const colorSpace = components.shift();
|
|
486
491
|
let values = components.map((val) => getNumber(arena, val));
|
|
487
|
-
switch (arena.
|
|
492
|
+
switch (arena.resolveString(arena.stringValue[colorSpace])) {
|
|
488
493
|
case "display-p3":
|
|
489
494
|
values = p32srgbvalues(values[0], values[1], values[2], values[3]);
|
|
490
495
|
break;
|
|
@@ -511,7 +516,7 @@ function color2srgbvalues(arena, token) {
|
|
|
511
516
|
values = xyzd502srgb(values[0], values[1], values[2], values[3]);
|
|
512
517
|
break;
|
|
513
518
|
}
|
|
514
|
-
if (values.length
|
|
519
|
+
if (values.length === 4) {
|
|
515
520
|
values[3] = values[3];
|
|
516
521
|
}
|
|
517
522
|
return values;
|
|
@@ -527,7 +532,7 @@ function values2colortoken(arena, values, to) {
|
|
|
527
532
|
arena.createToken(EnumToken.NumberTokenType, values[1]),
|
|
528
533
|
arena.createToken(EnumToken.NumberTokenType, values[2]),
|
|
529
534
|
];
|
|
530
|
-
if (values.length
|
|
535
|
+
if (values.length === 4) {
|
|
531
536
|
chi.push(arena.createToken(EnumToken.LiteralTokenType, "/"), arena.createToken(EnumToken.PercentageTokenType, values[3] * 100));
|
|
532
537
|
}
|
|
533
538
|
const colorSpace = ColorType[to].toLowerCase().replaceAll("_", "-");
|
|
@@ -542,18 +547,18 @@ function values2colortoken(arena, values, to) {
|
|
|
542
547
|
*/
|
|
543
548
|
function getNumber(arena, token) {
|
|
544
549
|
const typ = arena.dataTypes[token];
|
|
545
|
-
if (typ
|
|
550
|
+
if (typ === EnumToken.IdenTokenType && arena.resolveString(arena.stringValue[token]) === "none") {
|
|
546
551
|
return 0;
|
|
547
552
|
}
|
|
548
553
|
let val;
|
|
549
554
|
const fraction = arena.getFraction(token);
|
|
550
|
-
if (fraction
|
|
555
|
+
if (fraction !== 0) {
|
|
551
556
|
val = arena.numericValue[arena.firstChild[fraction]] / arena.numericValue[arena.lastChild[fraction]];
|
|
552
557
|
}
|
|
553
558
|
else {
|
|
554
559
|
val = arena.numericValue[token];
|
|
555
560
|
}
|
|
556
|
-
return typ
|
|
561
|
+
return typ === EnumToken.PercentageTokenType ? val / 100 : val;
|
|
557
562
|
}
|
|
558
563
|
/**
|
|
559
564
|
* convert angle to turn
|
|
@@ -562,14 +567,14 @@ function getNumber(arena, token) {
|
|
|
562
567
|
*/
|
|
563
568
|
function getAngle(arena, token) {
|
|
564
569
|
const typ = arena.dataTypes[token];
|
|
565
|
-
if (typ
|
|
566
|
-
if (arena.
|
|
570
|
+
if (typ === EnumToken.IdenTokenType) {
|
|
571
|
+
if (arena.resolveString(arena.stringValue[token]) === "none") {
|
|
567
572
|
return 0;
|
|
568
573
|
}
|
|
569
574
|
}
|
|
570
575
|
const val = getNumber(arena, token);
|
|
571
|
-
if (typ
|
|
572
|
-
switch (arena.
|
|
576
|
+
if (typ === EnumToken.AngleTokenType) {
|
|
577
|
+
switch (arena.resolveString(arena.unit[token])) {
|
|
573
578
|
case "deg":
|
|
574
579
|
return val / 360;
|
|
575
580
|
case "rad":
|
|
@@ -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.0
|
|
5
|
+
Version: 2.2.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { EnumToken, ColorType } from '../../ast/types.js';
|
|
@@ -16,18 +16,18 @@ function toHexString(acc, value) {
|
|
|
16
16
|
return acc + value.toString(16).padStart(2, "0");
|
|
17
17
|
}
|
|
18
18
|
function reduceHexValue(value) {
|
|
19
|
-
if (value[0]
|
|
19
|
+
if (value[0] !== "#") {
|
|
20
20
|
value = COLORS_NAMES[value.toLowerCase()] ?? value;
|
|
21
21
|
}
|
|
22
22
|
const named_color = NAMES_COLORS[expandHexValue(value)];
|
|
23
|
-
if (value.length
|
|
24
|
-
if (value[1]
|
|
23
|
+
if (value.length === 7) {
|
|
24
|
+
if (value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
|
|
25
25
|
value = `#${value[1]}${value[3]}${value[5]}`;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
else if (value.length
|
|
29
|
-
if (value[1]
|
|
30
|
-
value = `#${value[1]}${value[3]}${value[5]}${value[7]
|
|
28
|
+
else if (value.length === 9) {
|
|
29
|
+
if (value[1] === value[2] && value[3] === value[4] && value[5] === value[6] && value[7] === value[8]) {
|
|
30
|
+
value = `#${value[1]}${value[3]}${value[5]}${value[7] === "f" ? "" : value[7]}`;
|
|
31
31
|
}
|
|
32
32
|
if (value.endsWith("ff")) {
|
|
33
33
|
value = value.slice(0, -2);
|
|
@@ -36,10 +36,10 @@ function reduceHexValue(value) {
|
|
|
36
36
|
return named_color != null && named_color.length <= value.length ? named_color : value;
|
|
37
37
|
}
|
|
38
38
|
function expandHexValue(value) {
|
|
39
|
-
if (value.length
|
|
39
|
+
if (value.length === 4) {
|
|
40
40
|
return `#${value[1]}${value[1]}${value[2]}${value[2]}${value[3]}${value[3]}`;
|
|
41
41
|
}
|
|
42
|
-
if (value.length
|
|
42
|
+
if (value.length === 5) {
|
|
43
43
|
return `#${value[1]}${value[1]}${value[2]}${value[2]}${value[3]}${value[3]}${value[4]}${value[4]}`;
|
|
44
44
|
}
|
|
45
45
|
return value;
|
|
@@ -112,7 +112,7 @@ function lch2HexToken(arena, token) {
|
|
|
112
112
|
}
|
|
113
113
|
function hexToken(arena, value) {
|
|
114
114
|
value = reduceHexValue(value);
|
|
115
|
-
return arena.createColor(value, value[0]
|
|
115
|
+
return arena.createColor(value, value[0] === "#" ? ColorType.HEX : ColorType.LIT);
|
|
116
116
|
}
|
|
117
117
|
function rgb2hexvalues(arena, token) {
|
|
118
118
|
let value = "#";
|
|
@@ -123,13 +123,13 @@ function rgb2hexvalues(arena, token) {
|
|
|
123
123
|
}
|
|
124
124
|
for (let i = 0; i < 3; i++) {
|
|
125
125
|
t = components[i];
|
|
126
|
-
value += (arena.dataTypes[t]
|
|
126
|
+
value += (arena.dataTypes[t] === EnumToken.Iden && arena.resolveString(arena.stringValue[t]) === "none"
|
|
127
127
|
? "0"
|
|
128
|
-
: Math.round(getNumber(arena, t) * (arena.dataTypes[t]
|
|
128
|
+
: Math.round(getNumber(arena, t) * (arena.dataTypes[t] === EnumToken.PercentageTokenType ? 255 : 1)))
|
|
129
129
|
.toString(16)
|
|
130
130
|
.padStart(2, "0");
|
|
131
131
|
}
|
|
132
|
-
if (components.length
|
|
132
|
+
if (components.length === 4) {
|
|
133
133
|
// @ts-ignore
|
|
134
134
|
t = components[3];
|
|
135
135
|
// @ts-ignore
|
|
@@ -149,7 +149,7 @@ function hsl2hexvalues(arena, token) {
|
|
|
149
149
|
if (t == null) {
|
|
150
150
|
return null;
|
|
151
151
|
}
|
|
152
|
-
if (t.length
|
|
152
|
+
if (t.length === 4) {
|
|
153
153
|
t[3] = srgb2rgb(t[3]);
|
|
154
154
|
}
|
|
155
155
|
return `${t.reduce(toHexString, "#")}`;
|
|
@@ -159,7 +159,7 @@ function hwb2hexvalues(arena, token) {
|
|
|
159
159
|
if (t == null) {
|
|
160
160
|
return null;
|
|
161
161
|
}
|
|
162
|
-
if (t.length
|
|
162
|
+
if (t.length === 4) {
|
|
163
163
|
t[3] = srgb2rgb(t[3]);
|
|
164
164
|
}
|
|
165
165
|
return `${t.reduce(toHexString, "#")}`;
|
|
@@ -169,7 +169,7 @@ function cmyk2hexvalues(arena, token) {
|
|
|
169
169
|
if (t == null) {
|
|
170
170
|
return null;
|
|
171
171
|
}
|
|
172
|
-
if (t.length
|
|
172
|
+
if (t.length === 4) {
|
|
173
173
|
t[3] = srgb2rgb(t[3]);
|
|
174
174
|
}
|
|
175
175
|
return `#${t.reduce(toHexString, "")}`;
|
|
@@ -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.0
|
|
5
|
+
Version: 2.2.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { color2srgbvalues, getNumber } from './color.js';
|
|
@@ -76,10 +76,10 @@ function color2HslToken(arena, token) {
|
|
|
76
76
|
return hslToken(arena, srgb2hslvalues(values[0], values[1], values[2], values[3]));
|
|
77
77
|
}
|
|
78
78
|
function hslToken(arena, values) {
|
|
79
|
-
if (values[1]
|
|
79
|
+
if (values[1] === 0) {
|
|
80
80
|
values[0] = 0;
|
|
81
81
|
}
|
|
82
|
-
if (values[2]
|
|
82
|
+
if (values[2] === 1 || values[2] === 0) {
|
|
83
83
|
values[0] = 0;
|
|
84
84
|
values[1] = 0;
|
|
85
85
|
}
|
|
@@ -88,7 +88,7 @@ function hslToken(arena, values) {
|
|
|
88
88
|
arena.createToken(EnumToken.PercentageTokenType, values[1]),
|
|
89
89
|
arena.createToken(EnumToken.PercentageTokenType, values[2]),
|
|
90
90
|
];
|
|
91
|
-
if (values.length
|
|
91
|
+
if (values.length === 4 && values[3] !== 1) {
|
|
92
92
|
chi.push(arena.createToken(EnumToken.LiteralTokenType, "/"), arena.createToken(EnumToken.PercentageTokenType, values[3] * 100));
|
|
93
93
|
}
|
|
94
94
|
return arena.createColor("hsl", ColorType.HSL, chi);
|
|
@@ -112,11 +112,11 @@ function rgb2hslvalues(arena, token) {
|
|
|
112
112
|
let b = getNumber(arena, t);
|
|
113
113
|
// @ts-ignore
|
|
114
114
|
let a = null;
|
|
115
|
-
if (chi.length
|
|
115
|
+
if (chi.length === 4) {
|
|
116
116
|
a = getNumber(arena, chi[3]);
|
|
117
117
|
}
|
|
118
118
|
const values = [r, g, b];
|
|
119
|
-
if (a != null && a
|
|
119
|
+
if (a != null && a !== 1) {
|
|
120
120
|
values.push(a);
|
|
121
121
|
}
|
|
122
122
|
return rgbvalues2hslvalues(values[0], values[1], values[2], values[3]);
|
|
@@ -144,7 +144,7 @@ function hwb2hslvalues(arena, token) {
|
|
|
144
144
|
saturation = chroma / (1 - Math.abs(2 * lightness - 1));
|
|
145
145
|
}
|
|
146
146
|
const hsl = [hue, saturation * 100, lightness * 100];
|
|
147
|
-
if (a != null && a
|
|
147
|
+
if (a != null && a !== 1) {
|
|
148
148
|
hsl.push(a);
|
|
149
149
|
}
|
|
150
150
|
return hsl;
|
|
@@ -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.0
|
|
5
|
+
Version: 2.2.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { getColorComponents } from './utils/components.js';
|
|
@@ -22,7 +22,6 @@ function hsl2hwbToken(arena, token) {
|
|
|
22
22
|
if (values == null) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
// console.error(new Error("hsl2hwbToken"));
|
|
26
25
|
return hwbToken(arena, values);
|
|
27
26
|
}
|
|
28
27
|
function cmyk2hwbToken(arena, token) {
|
|
@@ -73,14 +72,14 @@ function hwbToken(arena, values) {
|
|
|
73
72
|
arena.createToken(EnumToken.PercentageTokenType, values[1]),
|
|
74
73
|
arena.createToken(EnumToken.PercentageTokenType, values[2]),
|
|
75
74
|
];
|
|
76
|
-
if (values.length
|
|
75
|
+
if (values.length === 4) {
|
|
77
76
|
chi.push(arena.createToken(EnumToken.LiteralTokenType, "/"), arena.createToken(EnumToken.PercentageTokenType, values[3] * 100));
|
|
78
77
|
}
|
|
79
78
|
return arena.createColor("hwb", ColorType.HWB, chi);
|
|
80
79
|
}
|
|
81
80
|
function rgb2hwbvalues(arena, token) {
|
|
82
81
|
const values = getColorComponents(arena, token).map((t, index) => {
|
|
83
|
-
if (index
|
|
82
|
+
if (index === 3) {
|
|
84
83
|
return getNumber(arena, t);
|
|
85
84
|
}
|
|
86
85
|
return getNumber(arena, t) / 255;
|
|
@@ -158,7 +157,7 @@ function hwbvalues(arena, token) {
|
|
|
158
157
|
b *= 100;
|
|
159
158
|
// }
|
|
160
159
|
let a = null;
|
|
161
|
-
if (components.length
|
|
160
|
+
if (components.length === 4) {
|
|
162
161
|
// @ts-ignore
|
|
163
162
|
t = components[3];
|
|
164
163
|
// @ts-ignore
|
|
@@ -212,7 +211,7 @@ function hslvalues2hwbvalues(h, s, l, a = null) {
|
|
|
212
211
|
const w = v - chroma;
|
|
213
212
|
const b = 1 - v;
|
|
214
213
|
const hwb = [hue, w * 100, b * 100];
|
|
215
|
-
if (a != null && a
|
|
214
|
+
if (a != null && a !== 1) {
|
|
216
215
|
hwb.push(a);
|
|
217
216
|
}
|
|
218
217
|
return hwb;
|
|
@@ -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.0
|
|
5
|
+
Version: 2.2.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { e, k, D50 } from '../constants.js';
|
|
@@ -81,7 +81,7 @@ function labToken(arena, values) {
|
|
|
81
81
|
arena.createToken(EnumToken.NumberTokenType, values[1]),
|
|
82
82
|
arena.createToken(EnumToken.NumberTokenType, values[2]),
|
|
83
83
|
];
|
|
84
|
-
if (values.length
|
|
84
|
+
if (values.length === 4) {
|
|
85
85
|
chi.push(arena.createToken(EnumToken.LiteralTokenType, "/"), arena.createToken(EnumToken.PercentageTokenType, values[3] * 100));
|
|
86
86
|
}
|
|
87
87
|
return arena.createColor("lab", ColorType.LAB, chi);
|
|
@@ -177,7 +177,7 @@ function xyz2lab(x, y, z, a = null) {
|
|
|
177
177
|
200 * (f[1] - f[2]), // b
|
|
178
178
|
];
|
|
179
179
|
// L in range [0,100]. For use in CSS, add a percent
|
|
180
|
-
if (a != null && a
|
|
180
|
+
if (a != null && a !== 1) {
|
|
181
181
|
result.push(a);
|
|
182
182
|
}
|
|
183
183
|
return result;
|
|
@@ -208,21 +208,21 @@ function getLABComponents(arena, token) {
|
|
|
208
208
|
// @ts-ignore
|
|
209
209
|
let t = components[0];
|
|
210
210
|
// @ts-ignore
|
|
211
|
-
const l = getNumber(arena, t) * (arena.dataTypes[t]
|
|
211
|
+
const l = getNumber(arena, t) * (arena.dataTypes[t] === EnumToken.PercentageTokenType ? 100 : 1);
|
|
212
212
|
// @ts-ignore
|
|
213
213
|
t = components[1];
|
|
214
214
|
// @ts-ignore
|
|
215
|
-
const a = getNumber(arena, t) * (arena.dataTypes[t]
|
|
215
|
+
const a = getNumber(arena, t) * (arena.dataTypes[t] === EnumToken.PercentageTokenType ? 125 : 1);
|
|
216
216
|
// @ts-ignore
|
|
217
217
|
t = components[2];
|
|
218
218
|
// @ts-ignore
|
|
219
|
-
const b = getNumber(arena, t) * (arena.dataTypes[t]
|
|
219
|
+
const b = getNumber(arena, t) * (arena.dataTypes[t] === EnumToken.PercentageTokenType ? 125 : 1);
|
|
220
220
|
// @ts-ignore
|
|
221
221
|
t = components[3];
|
|
222
222
|
// @ts-ignore
|
|
223
223
|
const alpha = t == null ? 1 : getNumber(arena, t);
|
|
224
224
|
const result = [l, a, b];
|
|
225
|
-
if (alpha != null && alpha
|
|
225
|
+
if (alpha != null && alpha !== 1) {
|
|
226
226
|
result.push(alpha);
|
|
227
227
|
}
|
|
228
228
|
return result;
|
|
@@ -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.0
|
|
5
|
+
Version: 2.2.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { getColorComponents } from './utils/components.js';
|
|
@@ -10,6 +10,7 @@ import { color2srgbvalues, getNumber, getAngle } from './color.js';
|
|
|
10
10
|
import { EnumToken, ColorType } from '../../ast/types.js';
|
|
11
11
|
import { srgb2labvalues, xyz2lab, oklch2labvalues, oklab2labvalues, getLABComponents, hwb2labvalues, hsl2labvalues, rgb2labvalues, hex2labvalues } from './lab.js';
|
|
12
12
|
import { cmyk2srgbvalues } from './srgb.js';
|
|
13
|
+
import { epsilon } from '../constants.js';
|
|
13
14
|
|
|
14
15
|
function hex2lchToken(arena, token) {
|
|
15
16
|
const values = hex2lchvalues(arena, token);
|
|
@@ -80,7 +81,7 @@ function lchToken(arena, values) {
|
|
|
80
81
|
arena.createToken(EnumToken.NumberTokenType, values[1]),
|
|
81
82
|
arena.createToken(EnumToken.NumberTokenType, values[2]),
|
|
82
83
|
];
|
|
83
|
-
if (values.length
|
|
84
|
+
if (values.length === 4) {
|
|
84
85
|
chi.push(arena.createToken(EnumToken.LiteralTokenType, "/"), arena.createToken(EnumToken.PercentageTokenType, values[3] * 100));
|
|
85
86
|
}
|
|
86
87
|
return arena.createColor("lch", ColorType.LCH, chi);
|
|
@@ -141,20 +142,20 @@ function color2lchvalues(arena, token) {
|
|
|
141
142
|
return srgb2lch(values[0], values[1], values[2], values[3]);
|
|
142
143
|
}
|
|
143
144
|
function labvalues2lchvalues(l, a, b, alpha = null) {
|
|
144
|
-
|
|
145
|
+
const c = Math.sqrt(a * a + b * b);
|
|
145
146
|
let h = (Math.atan2(b, a) * 180) / Math.PI;
|
|
146
|
-
if (h
|
|
147
|
-
h
|
|
147
|
+
if (h >= -epsilon && h <= epsilon) {
|
|
148
|
+
h = 0;
|
|
148
149
|
}
|
|
149
|
-
if (
|
|
150
|
-
|
|
150
|
+
else if (h < 0) {
|
|
151
|
+
h += 360;
|
|
151
152
|
}
|
|
152
153
|
return alpha == null ? [l, c, h] : [l, c, h, alpha];
|
|
153
154
|
}
|
|
154
155
|
function xyz2lchvalues(x, y, z, alpha) {
|
|
155
156
|
const values = xyz2lab(x, y, z);
|
|
156
157
|
const lch = labvalues2lchvalues(values[0], values[1], values[2]);
|
|
157
|
-
return alpha == null || alpha
|
|
158
|
+
return alpha == null || alpha === 1 ? lch : lch.concat(alpha);
|
|
158
159
|
}
|
|
159
160
|
function getLCHComponents(arena, token) {
|
|
160
161
|
const components = getColorComponents(arena, token);
|
|
@@ -174,11 +175,11 @@ function getLCHComponents(arena, token) {
|
|
|
174
175
|
// @ts-ignore
|
|
175
176
|
let t = components[0];
|
|
176
177
|
// @ts-ignore
|
|
177
|
-
const l = getNumber(arena, t) * (arena.dataTypes[t]
|
|
178
|
+
const l = getNumber(arena, t) * (arena.dataTypes[t] === EnumToken.PercentageTokenType ? 100 : 1);
|
|
178
179
|
// @ts-ignore
|
|
179
180
|
t = components[1];
|
|
180
181
|
// @ts-ignore
|
|
181
|
-
const c = getNumber(arena, t) * (arena.dataTypes[t]
|
|
182
|
+
const c = getNumber(arena, t) * (arena.dataTypes[t] === EnumToken.PercentageTokenType ? 150 : 1);
|
|
182
183
|
// @ts-ignore
|
|
183
184
|
t = components[2];
|
|
184
185
|
// @ts-ignore
|
|
@@ -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.0
|
|
5
|
+
Version: 2.2.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { getColorComponents } from './utils/components.js';
|
|
@@ -82,7 +82,7 @@ function oklabToken(arena, values) {
|
|
|
82
82
|
arena.createToken(EnumToken.NumberTokenType, values[1]),
|
|
83
83
|
arena.createToken(EnumToken.NumberTokenType, values[2]),
|
|
84
84
|
];
|
|
85
|
-
if (values.length
|
|
85
|
+
if (values.length === 4 && values[3] !== 1) {
|
|
86
86
|
chi.push(arena.createToken(EnumToken.LiteralTokenType, "/"), arena.createToken(EnumToken.PercentageTokenType, values[3] * 100));
|
|
87
87
|
}
|
|
88
88
|
return arena.createColor("oklab", ColorType.OKLAB, chi);
|
|
@@ -148,9 +148,9 @@ function srgb2oklab(r, g, blue, alpha) {
|
|
|
148
148
|
let M = Math.cbrt(0.2119034981999999 * r + 0.6806995450999999 * g + 0.1073969566 * blue);
|
|
149
149
|
let S = Math.cbrt(0.08830246189999998 * r + 0.2817188376 * g + 0.6299787005000002 * blue);
|
|
150
150
|
const l = 0.2104542553 * L + 0.793617785 * M - 0.0040720468 * S;
|
|
151
|
-
const a = r
|
|
152
|
-
const b = r
|
|
153
|
-
return alpha == null || alpha
|
|
151
|
+
const a = r === g && g === blue ? 0 : 1.9779984951 * L - 2.428592205 * M + 0.4505937099 * S;
|
|
152
|
+
const b = r === g && g === blue ? 0 : 0.0259040371 * L + 0.7827717662 * M - 0.808675766 * S;
|
|
153
|
+
return alpha == null || alpha === 1 ? [l, a, b] : [l, a, b, alpha];
|
|
154
154
|
}
|
|
155
155
|
function getOKLABComponents(arena, token) {
|
|
156
156
|
const components = getColorComponents(arena, token);
|
|
@@ -164,18 +164,18 @@ function getOKLABComponents(arena, token) {
|
|
|
164
164
|
// @ts-ignore
|
|
165
165
|
t = components[1];
|
|
166
166
|
// @ts-ignore
|
|
167
|
-
const a = getNumber(arena, t) * (arena.dataTypes[t]
|
|
167
|
+
const a = getNumber(arena, t) * (arena.dataTypes[t] === EnumToken.PercentageTokenType ? 0.4 : 1);
|
|
168
168
|
// @ts-ignore
|
|
169
169
|
t = components[2];
|
|
170
170
|
// @ts-ignore
|
|
171
|
-
const b = getNumber(arena, t) * (arena.dataTypes[t]
|
|
171
|
+
const b = getNumber(arena, t) * (arena.dataTypes[t] === EnumToken.PercentageTokenType ? 0.4 : 1);
|
|
172
172
|
// @ts-ignore
|
|
173
173
|
let alpha = null;
|
|
174
174
|
if (components.length > 3) {
|
|
175
175
|
alpha = getNumber(arena, components[3]);
|
|
176
176
|
}
|
|
177
177
|
const rgb = [l, a, b];
|
|
178
|
-
if (alpha
|
|
178
|
+
if (alpha !== 1 && alpha != null) {
|
|
179
179
|
rgb.push(alpha);
|
|
180
180
|
}
|
|
181
181
|
return rgb;
|