@tbela99/css-parser 1.6.4 → 1.6.6
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 +146 -0
- package/CONTRIBUTING.md +119 -0
- package/README.md +104 -0
- package/dist/data/validation.json.js +4 -1
- package/dist/index-umd-web.js +399 -326
- package/dist/index.cjs +398 -326
- package/dist/index.d.ts +15 -2
- package/dist/lib/ast/features/calc.js +10 -5
- package/dist/lib/ast/features/if.js +1 -1
- package/dist/lib/ast/features/inlinecssvariables.js +2 -2
- package/dist/lib/ast/features/prefix.js +1 -1
- package/dist/lib/ast/features/shorthand.js +1 -4
- package/dist/lib/ast/features/transform.js +1 -1
- package/dist/lib/ast/math/expression.js +70 -36
- package/dist/lib/ast/minify.js +2 -1
- package/dist/lib/parser/declaration/list.js +20 -10
- package/dist/lib/parser/declaration/map.js +39 -26
- package/dist/lib/parser/parse.js +4 -3
- package/dist/lib/parser/tokenize.js +99 -124
- package/dist/lib/parser/utils/at-rule-container.js +70 -1
- package/dist/lib/parser/utils/at-rule-media.js +0 -2
- package/dist/lib/printer/render.js +14 -38
- package/dist/lib/syntax/color/a98rgb.js +1 -1
- package/dist/lib/syntax/color/alpha.js +19 -20
- package/dist/lib/syntax/color/color-mix.js +15 -14
- package/dist/lib/syntax/color/hex.js +4 -1
- package/dist/lib/syntax/color/relative-color.js +11 -11
- package/dist/lib/syntax/color/utils/components.js +0 -20
- package/dist/lib/syntax/constants.js +5 -0
- package/dist/lib/syntax/syntax.js +2 -2
- package/dist/lib/validation/match.js +5 -4
- package/dist/web.js +1 -0
- package/package.json +12 -11
package/dist/index-umd-web.js
CHANGED
|
@@ -3515,7 +3515,7 @@
|
|
|
3515
3515
|
syntax: "<number> | <percentage> | none"
|
|
3516
3516
|
},
|
|
3517
3517
|
"an+b": {
|
|
3518
|
-
syntax: "odd | even | <integer> | <n-dimension> | '+'
|
|
3518
|
+
syntax: "odd | even | <integer> | <n-dimension> | '+'? n | -n | <ndashdigit-dimension> | '+'? <ndashdigit-ident> | <dashndashdigit-ident> | <n-dimension> <signed-integer> | '+'? n <signed-integer> | -n <signed-integer> | <ndash-dimension> <signless-integer> | '+'? n- <signless-integer> | -n- <signless-integer> | <n-dimension> ['+' | '-'] <signless-integer> | '+'? n ['+' | '-'] <signless-integer> | -n ['+' | '-'] <signless-integer>"
|
|
3519
3519
|
},
|
|
3520
3520
|
"anchor()": {
|
|
3521
3521
|
syntax: "anchor( <anchor-name>? && <anchor-side>, <length-percentage>? )"
|
|
@@ -5548,6 +5548,9 @@
|
|
|
5548
5548
|
marks: {
|
|
5549
5549
|
syntax: "none | [ crop || cross ]"
|
|
5550
5550
|
},
|
|
5551
|
+
"page-margin-safety": {
|
|
5552
|
+
syntax: "none | clamp | add"
|
|
5553
|
+
},
|
|
5551
5554
|
"page-orientation": {
|
|
5552
5555
|
syntax: "upright | rotate-left | rotate-right"
|
|
5553
5556
|
},
|
|
@@ -6429,6 +6432,11 @@
|
|
|
6429
6432
|
* Color range definitions
|
|
6430
6433
|
*/
|
|
6431
6434
|
const colorRange = {
|
|
6435
|
+
rgb: {
|
|
6436
|
+
r: [0, 255],
|
|
6437
|
+
g: [0, 255],
|
|
6438
|
+
b: [0, 255],
|
|
6439
|
+
},
|
|
6432
6440
|
lab: {
|
|
6433
6441
|
l: [0, 100],
|
|
6434
6442
|
a: [-125, 125],
|
|
@@ -6898,13 +6906,6 @@
|
|
|
6898
6906
|
}
|
|
6899
6907
|
|
|
6900
6908
|
function getColorComponents(token) {
|
|
6901
|
-
// if (token.typ === EnumToken.IdenTokenType) {
|
|
6902
|
-
// if (isColor(token)) {
|
|
6903
|
-
// parseColor(token);
|
|
6904
|
-
// } else {
|
|
6905
|
-
// return null;
|
|
6906
|
-
// }
|
|
6907
|
-
// }
|
|
6908
6909
|
if (token.kin == exports.ColorType.HEX || token.kin == exports.ColorType.LIT) {
|
|
6909
6910
|
if (equalsIgnoreCase("currentcolor", token.val)) {
|
|
6910
6911
|
return null;
|
|
@@ -6928,25 +6929,12 @@
|
|
|
6928
6929
|
].includes(child.typ)) {
|
|
6929
6930
|
continue;
|
|
6930
6931
|
}
|
|
6931
|
-
// if (child.typ === EnumToken.IdenTokenType && isColor(child)) {
|
|
6932
|
-
// parseColor(child);
|
|
6933
|
-
// }
|
|
6934
6932
|
if (child.typ === exports.EnumToken.FunctionTokenType ||
|
|
6935
6933
|
child.typ === exports.EnumToken.WildCardFunctionTokenType ||
|
|
6936
6934
|
child.typ === exports.EnumToken.MathFunctionTokenType) {
|
|
6937
6935
|
if ("var" == child.val.toLowerCase()) {
|
|
6938
6936
|
return null;
|
|
6939
6937
|
}
|
|
6940
|
-
// else {
|
|
6941
|
-
// for (const { value } of walkValues((child as FunctionToken).chi)) {
|
|
6942
|
-
// if (
|
|
6943
|
-
// value.typ == EnumToken.WildCardFunctionTokenDefType &&
|
|
6944
|
-
// "var" === (value as FunctionToken).val.toLowerCase()
|
|
6945
|
-
// ) {
|
|
6946
|
-
// return null;
|
|
6947
|
-
// }
|
|
6948
|
-
// }
|
|
6949
|
-
// }
|
|
6950
6938
|
}
|
|
6951
6939
|
if (child.typ == exports.EnumToken.ColorTokenType && equalsIgnoreCase("currentcolor", child.val)) {
|
|
6952
6940
|
return null;
|
|
@@ -8242,7 +8230,10 @@
|
|
|
8242
8230
|
if (value == null) {
|
|
8243
8231
|
return null;
|
|
8244
8232
|
}
|
|
8245
|
-
return hexToken(value.reduce((acc, curr) => acc +
|
|
8233
|
+
return hexToken(value.reduce((acc, curr) => acc +
|
|
8234
|
+
srgb2rgb(curr + Number.EPSILON)
|
|
8235
|
+
.toString(16)
|
|
8236
|
+
.padStart(2, "0"), "#"));
|
|
8246
8237
|
}
|
|
8247
8238
|
function oklab2HexToken(token) {
|
|
8248
8239
|
let value = oklab2srgbvalues(token);
|
|
@@ -9091,7 +9082,7 @@
|
|
|
9091
9082
|
// convert an array of linear-light a98-rgb in the range 0.0-1.0
|
|
9092
9083
|
// to gamma corrected form
|
|
9093
9084
|
// negative values are also now accepted
|
|
9094
|
-
return [r,
|
|
9085
|
+
return [r, g, b]
|
|
9095
9086
|
.map(function (val) {
|
|
9096
9087
|
let sign = val < 0 ? -1 : 1;
|
|
9097
9088
|
let abs = Math.abs(val);
|
|
@@ -9227,6 +9218,9 @@
|
|
|
9227
9218
|
if (values == null) {
|
|
9228
9219
|
return null;
|
|
9229
9220
|
}
|
|
9221
|
+
if (colorSpace == "hwb") {
|
|
9222
|
+
colorSpace = "srgb";
|
|
9223
|
+
}
|
|
9230
9224
|
switch (colorSpace) {
|
|
9231
9225
|
case "srgb":
|
|
9232
9226
|
break;
|
|
@@ -9256,17 +9250,17 @@
|
|
|
9256
9250
|
values = srgb2xyz_d65(values[0], values[1], values[2], values[3]);
|
|
9257
9251
|
values = XYZ_D65_to_D50(values[0], values[1], values[2], values[3]);
|
|
9258
9252
|
break;
|
|
9259
|
-
case "rgb":
|
|
9260
|
-
|
|
9261
|
-
|
|
9262
|
-
|
|
9263
|
-
|
|
9253
|
+
// case "rgb":
|
|
9254
|
+
// for (let j = 0; j < values.length; j++) {
|
|
9255
|
+
// values[j] = j == 3 ? values[j] : srgb2rgb(values[j]);
|
|
9256
|
+
// }
|
|
9257
|
+
// break;
|
|
9264
9258
|
case "hsl":
|
|
9265
9259
|
values = srgb2hslvalues(values[0], values[1], values[2], values[3]);
|
|
9266
9260
|
break;
|
|
9267
|
-
case "hwb":
|
|
9268
|
-
|
|
9269
|
-
|
|
9261
|
+
// case "hwb":
|
|
9262
|
+
// values = srgb2hwb(values[0], values[1], values[2], values[3]);
|
|
9263
|
+
// break;
|
|
9270
9264
|
case "lab":
|
|
9271
9265
|
values = srgb2labvalues(values[0], values[1], values[2], values[3]);
|
|
9272
9266
|
break;
|
|
@@ -9465,14 +9459,14 @@
|
|
|
9465
9459
|
kin: exports.ColorType.COLOR,
|
|
9466
9460
|
cal: "col",
|
|
9467
9461
|
};
|
|
9468
|
-
case "rgb":
|
|
9462
|
+
// case "rgb":
|
|
9469
9463
|
case "hsl":
|
|
9470
|
-
case "hwb":
|
|
9464
|
+
// case "hwb":
|
|
9471
9465
|
case "lab":
|
|
9472
9466
|
case "lch":
|
|
9473
9467
|
case "oklab":
|
|
9474
9468
|
case "oklch":
|
|
9475
|
-
if (colorSpace == "hsl"
|
|
9469
|
+
if (colorSpace == "hsl") {
|
|
9476
9470
|
// @ts-ignore
|
|
9477
9471
|
if (values[2] < 0) {
|
|
9478
9472
|
// @ts-ignore
|
|
@@ -9502,7 +9496,7 @@
|
|
|
9502
9496
|
}),
|
|
9503
9497
|
kin: exports.ColorType[colorSpace.toUpperCase().replaceAll("-", "_")],
|
|
9504
9498
|
};
|
|
9505
|
-
if (colorSpace == "hsl"
|
|
9499
|
+
if (colorSpace == "hsl") {
|
|
9506
9500
|
// @ts-ignore
|
|
9507
9501
|
result.chi[0] = { typ: exports.EnumToken.AngleTokenType, val: result.chi[0].val * 360 };
|
|
9508
9502
|
// @ts-ignore
|
|
@@ -10036,6 +10030,7 @@
|
|
|
10036
10030
|
return g > 1 ? [a / g, b / g] : [a, b];
|
|
10037
10031
|
}
|
|
10038
10032
|
|
|
10033
|
+
const numbers = new Set(["sin", "cos", "asin", "acos", "sign", "tan"]);
|
|
10039
10034
|
/**
|
|
10040
10035
|
* evaluate an array of tokens
|
|
10041
10036
|
* @param tokens
|
|
@@ -10097,6 +10092,7 @@
|
|
|
10097
10092
|
[LOCSRCID]: nodes[0][LOCSRCID],
|
|
10098
10093
|
[LOCSTA]: nodes[0][LOCSTA],
|
|
10099
10094
|
[LOCEND]: nodes[0][LOCEND],
|
|
10095
|
+
[PARENT]: nodes[0][PARENT],
|
|
10100
10096
|
},
|
|
10101
10097
|
];
|
|
10102
10098
|
}
|
|
@@ -10119,6 +10115,7 @@
|
|
|
10119
10115
|
[LOCSRCID]: nodes[i][LOCSRCID],
|
|
10120
10116
|
[LOCSTA]: nodes[i][LOCSTA],
|
|
10121
10117
|
[LOCEND]: nodes[i + 1][LOCEND],
|
|
10118
|
+
[PARENT]: nodes[i + 1][PARENT],
|
|
10122
10119
|
};
|
|
10123
10120
|
}
|
|
10124
10121
|
else {
|
|
@@ -10128,6 +10125,7 @@
|
|
|
10128
10125
|
[LOCSRCID]: nodes[i + 1][LOCSRCID],
|
|
10129
10126
|
[LOCSTA]: nodes[i + 1][LOCSTA],
|
|
10130
10127
|
[LOCEND]: nodes[i + 1][LOCEND],
|
|
10128
|
+
[PARENT]: nodes[i + 1][PARENT],
|
|
10131
10129
|
}, exports.EnumToken.Mul);
|
|
10132
10130
|
}
|
|
10133
10131
|
i++;
|
|
@@ -10148,12 +10146,14 @@
|
|
|
10148
10146
|
[LOCSRCID]: token[LOCSRCID],
|
|
10149
10147
|
[LOCSTA]: token[LOCSTA],
|
|
10150
10148
|
[LOCEND]: token[LOCEND],
|
|
10149
|
+
[PARENT]: token[PARENT],
|
|
10151
10150
|
}, {
|
|
10152
10151
|
...token,
|
|
10153
10152
|
val: -token.val,
|
|
10154
10153
|
[LOCSRCID]: token[LOCSRCID],
|
|
10155
10154
|
[LOCSTA]: token[LOCSTA],
|
|
10156
10155
|
[LOCEND]: token[LOCEND],
|
|
10156
|
+
[PARENT]: token[PARENT],
|
|
10157
10157
|
});
|
|
10158
10158
|
return acc;
|
|
10159
10159
|
}
|
|
@@ -10164,6 +10164,7 @@
|
|
|
10164
10164
|
[LOCSRCID]: token[LOCSRCID],
|
|
10165
10165
|
[LOCSTA]: token[LOCSTA],
|
|
10166
10166
|
[LOCEND]: token[LOCEND],
|
|
10167
|
+
[PARENT]: token[PARENT],
|
|
10167
10168
|
});
|
|
10168
10169
|
}
|
|
10169
10170
|
acc.push(token);
|
|
@@ -10185,6 +10186,7 @@
|
|
|
10185
10186
|
[LOCSRCID]: l[LOCSRCID],
|
|
10186
10187
|
[LOCSTA]: l[LOCSTA],
|
|
10187
10188
|
[LOCEND]: r?.[LOCEND] ?? l[LOCEND],
|
|
10189
|
+
[PARENT]: l[PARENT],
|
|
10188
10190
|
};
|
|
10189
10191
|
if (!isScalarToken(l) || !isScalarToken(r) || (l.typ == r.typ && "unit" in l && "unit" in r && l.unit != r.unit)) {
|
|
10190
10192
|
return defaultReturn;
|
|
@@ -10218,9 +10220,22 @@
|
|
|
10218
10220
|
r.typ == exports.EnumToken.NegativeInfinityTokenType) {
|
|
10219
10221
|
return computeInfinity(l, r, op, defaultReturn);
|
|
10220
10222
|
}
|
|
10223
|
+
if (l.typ == exports.EnumToken.FunctionTokenType || l.typ == exports.EnumToken.MathFunctionTokenType) {
|
|
10224
|
+
const val = evaluateFunc(l);
|
|
10225
|
+
if (val == null ||
|
|
10226
|
+
(val.length == 1 &&
|
|
10227
|
+
(val[0].typ == exports.EnumToken.MathFunctionTokenType || val[0].typ == exports.EnumToken.FunctionTokenType))) {
|
|
10228
|
+
return defaultReturn;
|
|
10229
|
+
}
|
|
10230
|
+
if (val.length == 1) {
|
|
10231
|
+
l = val[0];
|
|
10232
|
+
}
|
|
10233
|
+
}
|
|
10221
10234
|
if (r.typ == exports.EnumToken.FunctionTokenType || r.typ == exports.EnumToken.MathFunctionTokenType) {
|
|
10222
10235
|
const val = evaluateFunc(r);
|
|
10223
|
-
if (val == null
|
|
10236
|
+
if (val == null ||
|
|
10237
|
+
(val.length == 1 &&
|
|
10238
|
+
(val[0].typ == exports.EnumToken.MathFunctionTokenType || val[0].typ == exports.EnumToken.FunctionTokenType))) {
|
|
10224
10239
|
return defaultReturn;
|
|
10225
10240
|
}
|
|
10226
10241
|
if (val.length == 1) {
|
|
@@ -10257,6 +10272,7 @@
|
|
|
10257
10272
|
[LOCSRCID]: l[LOCSRCID],
|
|
10258
10273
|
[LOCSTA]: l[LOCSTA],
|
|
10259
10274
|
[LOCEND]: l[LOCEND],
|
|
10275
|
+
[PARENT]: l[PARENT],
|
|
10260
10276
|
},
|
|
10261
10277
|
r: {
|
|
10262
10278
|
typ: exports.EnumToken.NumberTokenType,
|
|
@@ -10264,6 +10280,7 @@
|
|
|
10264
10280
|
[LOCSRCID]: r[LOCSRCID],
|
|
10265
10281
|
[LOCSTA]: r[LOCSTA],
|
|
10266
10282
|
[LOCEND]: r[LOCEND],
|
|
10283
|
+
[PARENT]: r[PARENT],
|
|
10267
10284
|
},
|
|
10268
10285
|
};
|
|
10269
10286
|
}
|
|
@@ -10276,6 +10293,7 @@
|
|
|
10276
10293
|
[LOCSRCID]: l[LOCSRCID],
|
|
10277
10294
|
[LOCSTA]: l[LOCSTA],
|
|
10278
10295
|
[LOCEND]: l[LOCEND],
|
|
10296
|
+
[PARENT]: l[PARENT],
|
|
10279
10297
|
},
|
|
10280
10298
|
r: {
|
|
10281
10299
|
typ: exports.EnumToken.NumberTokenType,
|
|
@@ -10283,6 +10301,7 @@
|
|
|
10283
10301
|
[LOCSRCID]: r[LOCSRCID],
|
|
10284
10302
|
[LOCSTA]: r[LOCSTA],
|
|
10285
10303
|
[LOCEND]: r[LOCEND],
|
|
10304
|
+
[PARENT]: r[PARENT],
|
|
10286
10305
|
},
|
|
10287
10306
|
};
|
|
10288
10307
|
}
|
|
@@ -10309,6 +10328,7 @@
|
|
|
10309
10328
|
[LOCSRCID]: l[LOCSRCID],
|
|
10310
10329
|
[LOCSTA]: l[LOCSTA],
|
|
10311
10330
|
[LOCEND]: r?.[LOCEND] ?? l[LOCEND],
|
|
10331
|
+
[PARENT]: l[PARENT],
|
|
10312
10332
|
};
|
|
10313
10333
|
if (token.typ == exports.EnumToken.IdenTokenType) {
|
|
10314
10334
|
// @ts-ignore
|
|
@@ -10433,45 +10453,43 @@
|
|
|
10433
10453
|
function evaluateFunc(token) {
|
|
10434
10454
|
const values = token.chi.slice();
|
|
10435
10455
|
switch (token.val) {
|
|
10436
|
-
case "abs":
|
|
10437
10456
|
case "sin":
|
|
10438
10457
|
case "cos":
|
|
10439
10458
|
case "tan":
|
|
10459
|
+
for (let i = 0; i < values.length; i++) {
|
|
10460
|
+
if (values[i].typ == exports.EnumToken.NumberTokenType) {
|
|
10461
|
+
values[i] = Object.assign(values[i], { typ: exports.EnumToken.AngleTokenType, unit: "rad" });
|
|
10462
|
+
}
|
|
10463
|
+
else if (values[i].typ == exports.EnumToken.AngleTokenType && values[i].unit != "rad") {
|
|
10464
|
+
switch (values[i].unit) {
|
|
10465
|
+
case "deg":
|
|
10466
|
+
Object.assign(values[i], {
|
|
10467
|
+
unit: "rad",
|
|
10468
|
+
val: values[i].val * (Math.PI / 180),
|
|
10469
|
+
});
|
|
10470
|
+
break;
|
|
10471
|
+
case "grad":
|
|
10472
|
+
Object.assign(values[i], {
|
|
10473
|
+
unit: "rad",
|
|
10474
|
+
val: values[i].val * (Math.PI / 200),
|
|
10475
|
+
});
|
|
10476
|
+
break;
|
|
10477
|
+
case "turn":
|
|
10478
|
+
Object.assign(values[i], {
|
|
10479
|
+
unit: "rad",
|
|
10480
|
+
val: values[i].val * (2 * Math.PI),
|
|
10481
|
+
});
|
|
10482
|
+
break;
|
|
10483
|
+
}
|
|
10484
|
+
}
|
|
10485
|
+
}
|
|
10440
10486
|
case "asin":
|
|
10441
10487
|
case "acos":
|
|
10442
10488
|
case "atan":
|
|
10489
|
+
case "abs":
|
|
10443
10490
|
case "sign":
|
|
10444
10491
|
case "sqrt":
|
|
10445
|
-
case "exp":
|
|
10446
|
-
if (token.val == "tan" || token.val == "atan") {
|
|
10447
|
-
for (let i = 0; i < values.length; i++) {
|
|
10448
|
-
if (values[i].typ == exports.EnumToken.NumberTokenType) {
|
|
10449
|
-
values[i] = Object.assign(values[i], { typ: exports.EnumToken.AngleTokenType, unit: "rad" });
|
|
10450
|
-
}
|
|
10451
|
-
else if (values[i].typ == exports.EnumToken.AngleTokenType && values[i].unit != "rad") {
|
|
10452
|
-
switch (values[i].unit) {
|
|
10453
|
-
case "deg":
|
|
10454
|
-
Object.assign(values[i], {
|
|
10455
|
-
unit: "rad",
|
|
10456
|
-
val: values[i].val * (Math.PI / 180),
|
|
10457
|
-
});
|
|
10458
|
-
break;
|
|
10459
|
-
case "grad":
|
|
10460
|
-
Object.assign(values[i], {
|
|
10461
|
-
unit: "rad",
|
|
10462
|
-
val: values[i].val * (Math.PI / 200),
|
|
10463
|
-
});
|
|
10464
|
-
break;
|
|
10465
|
-
case "turn":
|
|
10466
|
-
Object.assign(values[i], {
|
|
10467
|
-
unit: "rad",
|
|
10468
|
-
val: values[i].val * (2 * Math.PI),
|
|
10469
|
-
});
|
|
10470
|
-
break;
|
|
10471
|
-
}
|
|
10472
|
-
}
|
|
10473
|
-
}
|
|
10474
|
-
}
|
|
10492
|
+
case "exp":
|
|
10475
10493
|
const value = evaluate(values);
|
|
10476
10494
|
// @ts-ignore
|
|
10477
10495
|
let val = value[0].typ == exports.EnumToken.NumberTokenType ||
|
|
@@ -10481,7 +10499,7 @@
|
|
|
10481
10499
|
: // @ts-expect-error
|
|
10482
10500
|
value[0].l.val / value[0].r.val;
|
|
10483
10501
|
return [
|
|
10484
|
-
token.val == "
|
|
10502
|
+
token.val == "asin" || token.val == "acos" || token.val == "atan"
|
|
10485
10503
|
? {
|
|
10486
10504
|
typ: exports.EnumToken.AngleTokenType,
|
|
10487
10505
|
val: Math[token.val](val),
|
|
@@ -10489,16 +10507,17 @@
|
|
|
10489
10507
|
[LOCSRCID]: value[0][LOCSRCID],
|
|
10490
10508
|
[LOCSTA]: value[0][LOCSTA],
|
|
10491
10509
|
[LOCEND]: value[0][LOCEND],
|
|
10510
|
+
[PARENT]: value[0][PARENT],
|
|
10492
10511
|
}
|
|
10493
10512
|
: {
|
|
10494
|
-
typ: token.val
|
|
10513
|
+
typ: numbers.has(token.val) ? exports.EnumToken.NumberTokenType : value[0].typ,
|
|
10495
10514
|
val: Math[token.val](val),
|
|
10496
10515
|
[LOCSRCID]: value[0][LOCSRCID],
|
|
10497
10516
|
[LOCSTA]: value[0][LOCSTA],
|
|
10498
10517
|
[LOCEND]: value[0][LOCEND],
|
|
10518
|
+
[PARENT]: value[0][PARENT],
|
|
10499
10519
|
},
|
|
10500
10520
|
];
|
|
10501
|
-
}
|
|
10502
10521
|
case "hypot": {
|
|
10503
10522
|
const chi = values.filter((t) => ![exports.EnumToken.WhitespaceTokenType, exports.EnumToken.CommentTokenType, exports.EnumToken.CommaTokenType].includes(t.typ));
|
|
10504
10523
|
let all = [];
|
|
@@ -10518,6 +10537,7 @@
|
|
|
10518
10537
|
[LOCSRCID]: token[LOCSRCID],
|
|
10519
10538
|
[LOCSTA]: token[LOCSTA],
|
|
10520
10539
|
[LOCEND]: token[LOCEND],
|
|
10540
|
+
[PARENT]: token[PARENT],
|
|
10521
10541
|
},
|
|
10522
10542
|
];
|
|
10523
10543
|
}
|
|
@@ -10591,6 +10611,7 @@
|
|
|
10591
10611
|
[LOCSRCID]: token[LOCSRCID],
|
|
10592
10612
|
[LOCSTA]: token[LOCSTA],
|
|
10593
10613
|
[LOCEND]: token[LOCEND],
|
|
10614
|
+
[PARENT]: token[PARENT],
|
|
10594
10615
|
},
|
|
10595
10616
|
];
|
|
10596
10617
|
}
|
|
@@ -10605,6 +10626,7 @@
|
|
|
10605
10626
|
[LOCSRCID]: token[LOCSRCID],
|
|
10606
10627
|
[LOCSTA]: token[LOCSTA],
|
|
10607
10628
|
[LOCEND]: token[LOCEND],
|
|
10629
|
+
[PARENT]: token[PARENT],
|
|
10608
10630
|
},
|
|
10609
10631
|
];
|
|
10610
10632
|
}
|
|
@@ -10615,6 +10637,7 @@
|
|
|
10615
10637
|
[LOCSRCID]: token[LOCSRCID],
|
|
10616
10638
|
[LOCSTA]: token[LOCSTA],
|
|
10617
10639
|
[LOCEND]: token[LOCEND],
|
|
10640
|
+
[PARENT]: token[PARENT],
|
|
10618
10641
|
},
|
|
10619
10642
|
];
|
|
10620
10643
|
}
|
|
@@ -10654,6 +10677,7 @@
|
|
|
10654
10677
|
[LOCSRCID]: token[LOCSRCID],
|
|
10655
10678
|
[LOCSTA]: token[LOCSTA],
|
|
10656
10679
|
[LOCEND]: token[LOCEND],
|
|
10680
|
+
[PARENT]: token[PARENT],
|
|
10657
10681
|
},
|
|
10658
10682
|
];
|
|
10659
10683
|
}
|
|
@@ -10696,6 +10720,7 @@
|
|
|
10696
10720
|
[LOCSRCID]: token[LOCSRCID],
|
|
10697
10721
|
[LOCSTA]: token[LOCSTA],
|
|
10698
10722
|
[LOCEND]: token[LOCEND],
|
|
10723
|
+
[PARENT]: token[PARENT],
|
|
10699
10724
|
},
|
|
10700
10725
|
];
|
|
10701
10726
|
}
|
|
@@ -10723,6 +10748,7 @@
|
|
|
10723
10748
|
[LOCSRCID]: token[LOCSRCID],
|
|
10724
10749
|
[LOCSTA]: token[LOCSTA],
|
|
10725
10750
|
[LOCEND]: token[LOCEND],
|
|
10751
|
+
[PARENT]: token[PARENT],
|
|
10726
10752
|
});
|
|
10727
10753
|
for (const child of inlineExpression$1(token.r)) {
|
|
10728
10754
|
result.push(child);
|
|
@@ -10802,6 +10828,7 @@
|
|
|
10802
10828
|
[LOCSRCID]: token[LOCSRCID],
|
|
10803
10829
|
[LOCSTA]: token[LOCSTA],
|
|
10804
10830
|
[LOCEND]: token[LOCEND],
|
|
10831
|
+
[PARENT]: token[PARENT],
|
|
10805
10832
|
};
|
|
10806
10833
|
// @ts-ignore
|
|
10807
10834
|
delete token.val;
|
|
@@ -10843,6 +10870,7 @@
|
|
|
10843
10870
|
[LOCSRCID]: tokens[i - 1][LOCSRCID],
|
|
10844
10871
|
[LOCSTA]: tokens[i - 1][LOCSTA],
|
|
10845
10872
|
[LOCEND]: tokens[i + 1][LOCEND],
|
|
10873
|
+
[PARENT]: tokens[i + 1][PARENT],
|
|
10846
10874
|
});
|
|
10847
10875
|
i--;
|
|
10848
10876
|
}
|
|
@@ -10888,20 +10916,20 @@
|
|
|
10888
10916
|
continue;
|
|
10889
10917
|
}
|
|
10890
10918
|
if (component.typ == exports.EnumToken.IdenTokenType) {
|
|
10891
|
-
val = component.val
|
|
10919
|
+
val = component.val;
|
|
10892
10920
|
if (
|
|
10893
10921
|
// @ts-expect-error
|
|
10894
10922
|
typeof Math[val.toUpperCase()] !== "number" &&
|
|
10895
|
-
val
|
|
10896
|
-
val
|
|
10897
|
-
val
|
|
10898
|
-
val
|
|
10899
|
-
val
|
|
10900
|
-
val
|
|
10901
|
-
val
|
|
10902
|
-
val
|
|
10903
|
-
val
|
|
10904
|
-
!colorsFunc.
|
|
10923
|
+
!equalsIgnoreCase(val, "in") &&
|
|
10924
|
+
!equalsIgnoreCase(val, "hue") &&
|
|
10925
|
+
!equalsIgnoreCase(val, "from") &&
|
|
10926
|
+
!equalsIgnoreCase(val, "alpha") &&
|
|
10927
|
+
!equalsIgnoreCase(val, "none") &&
|
|
10928
|
+
!equalsIgnoreCase(val, "shorter") &&
|
|
10929
|
+
!equalsIgnoreCase(val, "longer") &&
|
|
10930
|
+
!equalsIgnoreCase(val, "increasing") &&
|
|
10931
|
+
!equalsIgnoreCase(val, "decreasing") &&
|
|
10932
|
+
!colorsFunc.some((t) => equalsIgnoreCase(t, val)) &&
|
|
10905
10933
|
!colorFuncColorSpace.includes(val) &&
|
|
10906
10934
|
!validKeys.includes(val)) {
|
|
10907
10935
|
return null;
|
|
@@ -12244,7 +12272,8 @@
|
|
|
12244
12272
|
return { valid: true, success: false, isValueAllowed: false };
|
|
12245
12273
|
}
|
|
12246
12274
|
featureName = featureName.toLowerCase();
|
|
12247
|
-
|
|
12275
|
+
// @ts-expect-error
|
|
12276
|
+
if (config$3.mediaFeatures[featureName] == null) {
|
|
12248
12277
|
return { valid: false, success: false };
|
|
12249
12278
|
}
|
|
12250
12279
|
// @ts-expect-error
|
|
@@ -12288,8 +12317,7 @@
|
|
|
12288
12317
|
return {
|
|
12289
12318
|
valid: true,
|
|
12290
12319
|
success: (tokens.length == 1 &&
|
|
12291
|
-
tokens[0].typ == exports.EnumToken.NumberTokenType
|
|
12292
|
-
tokens[0].val.typ == exports.EnumToken.FractionTokenType) ||
|
|
12320
|
+
tokens[0].typ == exports.EnumToken.NumberTokenType) ||
|
|
12293
12321
|
(tokens.length === 3 &&
|
|
12294
12322
|
tokens[0].typ == exports.EnumToken.NumberTokenType &&
|
|
12295
12323
|
typeof tokens[0].val === "number" &&
|
|
@@ -12805,7 +12833,8 @@
|
|
|
12805
12833
|
for (let i = index; i < syntaxes.length; i++) {
|
|
12806
12834
|
if (syntaxes[i].typ == ValidationTokenEnum.Whitespace ||
|
|
12807
12835
|
syntaxes[i].isOptional ||
|
|
12808
|
-
syntaxes[i].isRepeatable
|
|
12836
|
+
syntaxes[i].isRepeatable ||
|
|
12837
|
+
syntaxes[i].match?.min?.val === 0) {
|
|
12809
12838
|
continue;
|
|
12810
12839
|
}
|
|
12811
12840
|
return {
|
|
@@ -14510,7 +14539,6 @@
|
|
|
14510
14539
|
}
|
|
14511
14540
|
let components = getColorComponents(color);
|
|
14512
14541
|
if (alpha.typ === exports.EnumToken.MathFunctionTokenType) {
|
|
14513
|
-
const originalAlpha = cloneNode(alpha, true);
|
|
14514
14542
|
for (const { value } of walkValues(alpha.chi, alpha)) {
|
|
14515
14543
|
if (value.typ === exports.EnumToken.IdenTokenType) {
|
|
14516
14544
|
if (equalsIgnoreCase(value.val, "alpha")) {
|
|
@@ -14522,22 +14550,22 @@
|
|
|
14522
14550
|
});
|
|
14523
14551
|
// continue;
|
|
14524
14552
|
}
|
|
14525
|
-
else if (equalsIgnoreCase(value.val, "none")) {
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
}
|
|
14553
|
+
// else if (equalsIgnoreCase((value as IdentToken).val, "none")) {
|
|
14554
|
+
// Object.assign(value, {
|
|
14555
|
+
// typ: EnumToken.NumberTokenType,
|
|
14556
|
+
// val: 0,
|
|
14557
|
+
// });
|
|
14558
|
+
// }
|
|
14531
14559
|
}
|
|
14532
14560
|
}
|
|
14533
14561
|
const result = evaluate([alpha]);
|
|
14534
14562
|
if (result.length == 1) {
|
|
14535
14563
|
alpha = result[0];
|
|
14536
14564
|
}
|
|
14537
|
-
else {
|
|
14538
|
-
|
|
14539
|
-
|
|
14540
|
-
}
|
|
14565
|
+
// else {
|
|
14566
|
+
// // @ts-expect-error
|
|
14567
|
+
// alpha = originalAlpha;
|
|
14568
|
+
// }
|
|
14541
14569
|
}
|
|
14542
14570
|
// console.error({ alpha });
|
|
14543
14571
|
if (alpha.typ !== exports.EnumToken.IdenTokenType &&
|
|
@@ -14563,17 +14591,17 @@
|
|
|
14563
14591
|
return null;
|
|
14564
14592
|
}
|
|
14565
14593
|
if (alpha?.typ === exports.EnumToken.IdenTokenType) {
|
|
14566
|
-
if (equalsIgnoreCase(alpha.val, "alpha")) {
|
|
14567
|
-
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
}
|
|
14572
|
-
|
|
14573
|
-
alpha
|
|
14594
|
+
// if (equalsIgnoreCase((alpha as IdentToken).val, "alpha")) {
|
|
14595
|
+
// alpha = components[3] ?? {
|
|
14596
|
+
// typ: EnumToken.NumberTokenType,
|
|
14597
|
+
// val: 1,
|
|
14598
|
+
// };
|
|
14599
|
+
// } else
|
|
14600
|
+
if (equalsIgnoreCase(alpha.val, "none")) {
|
|
14601
|
+
Object.assign(alpha, {
|
|
14574
14602
|
typ: exports.EnumToken.NumberTokenType,
|
|
14575
14603
|
val: 0,
|
|
14576
|
-
};
|
|
14604
|
+
});
|
|
14577
14605
|
}
|
|
14578
14606
|
}
|
|
14579
14607
|
return makeColor(color.kin, components, alpha);
|
|
@@ -15294,12 +15322,12 @@
|
|
|
15294
15322
|
// '\\'
|
|
15295
15323
|
const REVERSE_SOLIDUS = 0x5c;
|
|
15296
15324
|
const flexUnits = ["fr"];
|
|
15297
|
-
const frequencyUnits = ["
|
|
15325
|
+
const frequencyUnits = ["Hz", "kHz"];
|
|
15298
15326
|
const timeUnits = ["ms", "s"];
|
|
15299
15327
|
const angleUnits = ["rad", "turn", "deg", "grad"];
|
|
15300
15328
|
const resolutionUnits = ["dpi", "dpcm", "dppx", "x"];
|
|
15301
15329
|
const dimensionUnits = [
|
|
15302
|
-
"
|
|
15330
|
+
"Q",
|
|
15303
15331
|
"cap",
|
|
15304
15332
|
"ch",
|
|
15305
15333
|
"cm",
|
|
@@ -16983,7 +17011,7 @@
|
|
|
16983
17011
|
}
|
|
16984
17012
|
class ComputePrefixFeature {
|
|
16985
17013
|
get ordering() {
|
|
16986
|
-
return
|
|
17014
|
+
return 0;
|
|
16987
17015
|
}
|
|
16988
17016
|
get processMode() {
|
|
16989
17017
|
return exports.FeatureWalkMode.Pre;
|
|
@@ -17427,10 +17455,10 @@
|
|
|
17427
17455
|
class InlineCssVariablesFeature {
|
|
17428
17456
|
accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
|
|
17429
17457
|
get ordering() {
|
|
17430
|
-
return
|
|
17458
|
+
return 2;
|
|
17431
17459
|
}
|
|
17432
17460
|
get processMode() {
|
|
17433
|
-
return exports.FeatureWalkMode.
|
|
17461
|
+
return exports.FeatureWalkMode.Post;
|
|
17434
17462
|
}
|
|
17435
17463
|
static register(options) {
|
|
17436
17464
|
if (options.inlineCssVariables) {
|
|
@@ -19680,8 +19708,8 @@
|
|
|
19680
19708
|
|
|
19681
19709
|
const propertiesConfig = getConfig();
|
|
19682
19710
|
class PropertyMap {
|
|
19683
|
-
config;
|
|
19684
19711
|
declarations;
|
|
19712
|
+
config;
|
|
19685
19713
|
requiredCount;
|
|
19686
19714
|
pattern;
|
|
19687
19715
|
constructor(config) {
|
|
@@ -19695,7 +19723,7 @@
|
|
|
19695
19723
|
}
|
|
19696
19724
|
add(declaration) {
|
|
19697
19725
|
if (declaration.nam == this.config.shorthand) {
|
|
19698
|
-
this.declarations
|
|
19726
|
+
this.declarations.clear();
|
|
19699
19727
|
this.declarations.set(declaration.nam, declaration);
|
|
19700
19728
|
this.matchTypes(declaration);
|
|
19701
19729
|
}
|
|
@@ -19711,23 +19739,17 @@
|
|
|
19711
19739
|
if (this.declarations.has(this.config.shorthand)) {
|
|
19712
19740
|
const tokens = {};
|
|
19713
19741
|
const values = [];
|
|
19714
|
-
|
|
19715
|
-
this.declarations
|
|
19716
|
-
.get(this.config.shorthand)
|
|
19717
|
-
// @ts-ignore
|
|
19718
|
-
.val.slice()
|
|
19719
|
-
.reduce((acc, curr) => {
|
|
19742
|
+
const val = [[]];
|
|
19743
|
+
for (const curr of this.declarations.get(this.config.shorthand).val) { // @ts-ignore
|
|
19720
19744
|
// @ts-ignore
|
|
19721
19745
|
if (separator != null && separator.typ == curr.typ && separator.val == curr.val) {
|
|
19722
|
-
|
|
19723
|
-
|
|
19746
|
+
val.push([]);
|
|
19747
|
+
continue;
|
|
19724
19748
|
}
|
|
19725
19749
|
// @ts-ignore
|
|
19726
|
-
|
|
19727
|
-
|
|
19728
|
-
|
|
19729
|
-
// @ts-ignore
|
|
19730
|
-
.reduce((acc, list, current) => {
|
|
19750
|
+
val.at(-1).push(curr);
|
|
19751
|
+
}
|
|
19752
|
+
for (let current = 0; current < val.length; current++) {
|
|
19731
19753
|
values.push(...this.pattern.reduce((acc, property) => {
|
|
19732
19754
|
// let current: number = 0;
|
|
19733
19755
|
const props = this.config.properties[property];
|
|
@@ -19742,9 +19764,7 @@
|
|
|
19742
19764
|
// @ts-ignore
|
|
19743
19765
|
acc[i][PROPERTYNAME] == property ||
|
|
19744
19766
|
matchType(acc[i], props)) {
|
|
19745
|
-
if ("prefix" in props &&
|
|
19746
|
-
props.previous != null &&
|
|
19747
|
-
!(props.previous in tokens)) {
|
|
19767
|
+
if ("prefix" in props && props.previous != null && !(props.previous in tokens)) {
|
|
19748
19768
|
return acc;
|
|
19749
19769
|
}
|
|
19750
19770
|
if (!(property in tokens)) {
|
|
@@ -19809,9 +19829,8 @@
|
|
|
19809
19829
|
}
|
|
19810
19830
|
}
|
|
19811
19831
|
return acc;
|
|
19812
|
-
},
|
|
19813
|
-
|
|
19814
|
-
}, []);
|
|
19832
|
+
}, val[current]));
|
|
19833
|
+
}
|
|
19815
19834
|
if (values.length == 0) {
|
|
19816
19835
|
this.declarations = Object.entries(tokens).reduce((acc, curr) => {
|
|
19817
19836
|
acc.set(curr[0], {
|
|
@@ -19871,17 +19890,40 @@
|
|
|
19871
19890
|
}
|
|
19872
19891
|
if (hasMapping) {
|
|
19873
19892
|
const mapped = {};
|
|
19874
|
-
|
|
19875
|
-
|
|
19893
|
+
let key;
|
|
19894
|
+
for (const value of declarations.values()) {
|
|
19895
|
+
key = value.nam;
|
|
19876
19896
|
if (value instanceof PropertyMap) {
|
|
19877
19897
|
for (const [k, v] of value.declarations) {
|
|
19878
|
-
|
|
19898
|
+
if (k == value.config.shorthand) {
|
|
19899
|
+
for (const [key, val] of Object.entries(value.config.properties)) {
|
|
19900
|
+
mapped[key] = cloneNode(v);
|
|
19901
|
+
for (let i = 0; i < v.val.length; i++) {
|
|
19902
|
+
// @ts-ignore
|
|
19903
|
+
if (key == v.val[i][PROPERTYNAME]) {
|
|
19904
|
+
if (mapped[key].val.length > 0) {
|
|
19905
|
+
mapped[key].val.push({
|
|
19906
|
+
typ: exports.EnumToken.WhitespaceTokenType,
|
|
19907
|
+
});
|
|
19908
|
+
}
|
|
19909
|
+
mapped[key].val.push(v.val[i]);
|
|
19910
|
+
}
|
|
19911
|
+
}
|
|
19912
|
+
if (mapped[key].val.length == 0) {
|
|
19913
|
+
mapped[key].val.push(...parseString(value.config.properties[key].default[0]));
|
|
19914
|
+
}
|
|
19915
|
+
}
|
|
19916
|
+
}
|
|
19917
|
+
else {
|
|
19918
|
+
mapped[k] = v;
|
|
19919
|
+
}
|
|
19879
19920
|
}
|
|
19880
19921
|
}
|
|
19881
19922
|
else {
|
|
19882
19923
|
mapped[key] = value;
|
|
19883
19924
|
}
|
|
19884
19925
|
}
|
|
19926
|
+
// console.error(mapped);
|
|
19885
19927
|
if (patterns.length === Object.keys(mapped).length) {
|
|
19886
19928
|
declarations = new Map();
|
|
19887
19929
|
for (const key of patterns) {
|
|
@@ -20337,8 +20379,6 @@
|
|
|
20337
20379
|
}
|
|
20338
20380
|
return acc;
|
|
20339
20381
|
}, []);
|
|
20340
|
-
// console.error({hasMapping, shorthand: this.config.shorthand, requiredCount, isShorthand,
|
|
20341
|
-
// declarations: declarations.values(), values});
|
|
20342
20382
|
if (this.config.mapping != null) {
|
|
20343
20383
|
const val = values.reduce((acc, curr) => acc +
|
|
20344
20384
|
renderValue(curr, {
|
|
@@ -20375,6 +20415,7 @@
|
|
|
20375
20415
|
}
|
|
20376
20416
|
}
|
|
20377
20417
|
const iterators = [];
|
|
20418
|
+
// @ts-ignore
|
|
20378
20419
|
return {
|
|
20379
20420
|
// @ts-ignore
|
|
20380
20421
|
next() {
|
|
@@ -20627,6 +20668,9 @@
|
|
|
20627
20668
|
}
|
|
20628
20669
|
|
|
20629
20670
|
const config = getConfig();
|
|
20671
|
+
/**
|
|
20672
|
+
* Represents a list of property declarations, compute shorthand and remove duplicate declarations.
|
|
20673
|
+
*/
|
|
20630
20674
|
class PropertyList {
|
|
20631
20675
|
options = { removeDuplicateDeclarations: true, computeShorthand: true };
|
|
20632
20676
|
declarations;
|
|
@@ -20701,28 +20745,35 @@
|
|
|
20701
20745
|
// @ts-ignore
|
|
20702
20746
|
shorthand = config.property[propertyName];
|
|
20703
20747
|
}
|
|
20704
|
-
// console.error({shortHandType, propertyName, config: config.map[propertyName], map: config.map[shorthand].properties[propertyName]});
|
|
20705
20748
|
// @ts-ignore
|
|
20706
20749
|
if (shortHandType == "map") {
|
|
20707
20750
|
let owner = this;
|
|
20751
|
+
const mapName =
|
|
20708
20752
|
// @ts-ignore
|
|
20709
|
-
|
|
20753
|
+
config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
|
|
20710
20754
|
if (typeof mapName === "string") {
|
|
20711
20755
|
if (!this.declarations.has(mapName)) {
|
|
20712
20756
|
// @ts-ignore
|
|
20713
20757
|
this.declarations.set(mapName, new PropertyMap(config.map[mapName]));
|
|
20714
20758
|
}
|
|
20715
20759
|
owner = this.declarations.get(mapName);
|
|
20716
|
-
// console.error({mapName});
|
|
20717
20760
|
}
|
|
20718
|
-
|
|
20719
|
-
if (!owner.declarations.has(shorthand)) {
|
|
20761
|
+
else if (!this.declarations.has(shorthand)) {
|
|
20720
20762
|
// @ts-ignore
|
|
20721
|
-
|
|
20763
|
+
this.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
|
|
20764
|
+
}
|
|
20765
|
+
if (owner == this) {
|
|
20766
|
+
// @ts-ignore
|
|
20767
|
+
owner.declarations.get(shorthand).add(declaration);
|
|
20768
|
+
}
|
|
20769
|
+
else {
|
|
20770
|
+
if (!owner.declarations.has(shorthand)) {
|
|
20771
|
+
// @ts-ignore
|
|
20772
|
+
owner.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
|
|
20773
|
+
}
|
|
20774
|
+
// @ts-ignore
|
|
20775
|
+
owner.declarations.get(shorthand).add(declaration);
|
|
20722
20776
|
}
|
|
20723
|
-
// console.error({propertyName,mapName, owned: owner == this});
|
|
20724
|
-
// @ts-ignore
|
|
20725
|
-
owner.declarations.get(shorthand).add(declaration);
|
|
20726
20777
|
}
|
|
20727
20778
|
// @ts-ignore
|
|
20728
20779
|
else if (shortHandType == "set") {
|
|
@@ -20809,7 +20860,7 @@
|
|
|
20809
20860
|
[Symbol.iterator]() {
|
|
20810
20861
|
let iterator = this.declarations.values();
|
|
20811
20862
|
const iterators = [];
|
|
20812
|
-
//
|
|
20863
|
+
// @ts-ignore
|
|
20813
20864
|
return {
|
|
20814
20865
|
next() {
|
|
20815
20866
|
let value = iterator.next();
|
|
@@ -20840,7 +20891,7 @@
|
|
|
20840
20891
|
exports.EnumToken.KeyframesRuleNodeType,
|
|
20841
20892
|
]);
|
|
20842
20893
|
get ordering() {
|
|
20843
|
-
return
|
|
20894
|
+
return 5;
|
|
20844
20895
|
}
|
|
20845
20896
|
get processMode() {
|
|
20846
20897
|
return exports.FeatureWalkMode.Post;
|
|
@@ -20859,7 +20910,6 @@
|
|
|
20859
20910
|
const j = ast.chi.length;
|
|
20860
20911
|
let k = 0;
|
|
20861
20912
|
let l;
|
|
20862
|
-
// let properties: PropertyList = new PropertyList(options);
|
|
20863
20913
|
const rules = [];
|
|
20864
20914
|
const declarations = [];
|
|
20865
20915
|
// @ts-ignore
|
|
@@ -20880,7 +20930,6 @@
|
|
|
20880
20930
|
if (node.typ == exports.EnumToken.DeclarationNodeType) {
|
|
20881
20931
|
for (let m = k; m <= l; m++) {
|
|
20882
20932
|
declarations.push(ast.chi[m]);
|
|
20883
|
-
// properties.add(ast.chi![m]);
|
|
20884
20933
|
}
|
|
20885
20934
|
}
|
|
20886
20935
|
else {
|
|
@@ -20890,7 +20939,6 @@
|
|
|
20890
20939
|
}
|
|
20891
20940
|
k = l;
|
|
20892
20941
|
}
|
|
20893
|
-
// console.error([...new PropertyList(options).add(declarations)]);
|
|
20894
20942
|
if (declarations.length > 0) {
|
|
20895
20943
|
ast.chi.length = 0;
|
|
20896
20944
|
// @ts-expect-error
|
|
@@ -21001,7 +21049,7 @@
|
|
|
21001
21049
|
class ComputeCalcExpressionFeature {
|
|
21002
21050
|
accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
|
|
21003
21051
|
get ordering() {
|
|
21004
|
-
return
|
|
21052
|
+
return 3;
|
|
21005
21053
|
}
|
|
21006
21054
|
get processMode() {
|
|
21007
21055
|
return exports.FeatureWalkMode.Post;
|
|
@@ -21013,7 +21061,8 @@
|
|
|
21013
21061
|
}
|
|
21014
21062
|
}
|
|
21015
21063
|
run(ast) {
|
|
21016
|
-
|
|
21064
|
+
// @ts-ignore
|
|
21065
|
+
if (ast.chi == null) {
|
|
21017
21066
|
return null;
|
|
21018
21067
|
}
|
|
21019
21068
|
for (const node of ast.chi) {
|
|
@@ -21026,8 +21075,12 @@
|
|
|
21026
21075
|
continue;
|
|
21027
21076
|
}
|
|
21028
21077
|
if (value.typ == exports.EnumToken.BinaryExpressionTokenType) {
|
|
21029
|
-
|
|
21030
|
-
|
|
21078
|
+
const result = evaluate([value]);
|
|
21079
|
+
try {
|
|
21080
|
+
// @ts-ignore
|
|
21081
|
+
replaceNodeOrValue(parent, value, result);
|
|
21082
|
+
}
|
|
21083
|
+
catch (e) { }
|
|
21031
21084
|
continue;
|
|
21032
21085
|
}
|
|
21033
21086
|
if (value != null && tokensfuncSet.has(value.typ)) {
|
|
@@ -21045,7 +21098,7 @@
|
|
|
21045
21098
|
? value.val
|
|
21046
21099
|
: value.chi;
|
|
21047
21100
|
const values = evaluate(cp);
|
|
21048
|
-
// fix a + -b
|
|
21101
|
+
// fix a + -b into a - b
|
|
21049
21102
|
for (const { value, parent: p } of walkValues(values)) {
|
|
21050
21103
|
if (value.typ === exports.EnumToken.BinaryExpressionTokenType) {
|
|
21051
21104
|
if (value.op === exports.EnumToken.Add &&
|
|
@@ -22311,7 +22364,7 @@
|
|
|
22311
22364
|
exports.EnumToken.KeyframesRuleNodeType,
|
|
22312
22365
|
]);
|
|
22313
22366
|
get ordering() {
|
|
22314
|
-
return
|
|
22367
|
+
return 4;
|
|
22315
22368
|
}
|
|
22316
22369
|
get processMode() {
|
|
22317
22370
|
return exports.FeatureWalkMode.Post;
|
|
@@ -22714,7 +22767,7 @@
|
|
|
22714
22767
|
class ExpandIfFeature {
|
|
22715
22768
|
accept = new Set([exports.EnumToken.DeclarationNodeType]);
|
|
22716
22769
|
get ordering() {
|
|
22717
|
-
return
|
|
22770
|
+
return 1;
|
|
22718
22771
|
}
|
|
22719
22772
|
get processMode() {
|
|
22720
22773
|
return exports.FeatureWalkMode.Pre;
|
|
@@ -23516,7 +23569,8 @@
|
|
|
23516
23569
|
previous = node;
|
|
23517
23570
|
nodeIndex = i;
|
|
23518
23571
|
}
|
|
23519
|
-
|
|
23572
|
+
// @ts-ignore
|
|
23573
|
+
if (recursive && node != null && node.chi != null) {
|
|
23520
23574
|
if (node.typ == exports.EnumToken.KeyframesAtRuleNodeType ||
|
|
23521
23575
|
!node.chi.some((n) => n.typ == exports.EnumToken.DeclarationNodeType)) {
|
|
23522
23576
|
if (!(node.typ == exports.EnumToken.AtRuleNodeType && node.nam != "font-face")) {
|
|
@@ -25349,6 +25403,7 @@
|
|
|
25349
25403
|
removeEmpty: false,
|
|
25350
25404
|
removeComments: false,
|
|
25351
25405
|
}),
|
|
25406
|
+
minifyValues: true,
|
|
25352
25407
|
sourcemap: false,
|
|
25353
25408
|
convertColor: true,
|
|
25354
25409
|
expandNestingRules: false,
|
|
@@ -25588,7 +25643,7 @@
|
|
|
25588
25643
|
const indentSub = indents[level + 1];
|
|
25589
25644
|
switch (data.typ) {
|
|
25590
25645
|
case exports.EnumToken.DeclarationNodeType:
|
|
25591
|
-
return `${data.nam}:${options.indent}${(options.
|
|
25646
|
+
return `${data.nam}:${options.indent}${(options.minifyValues
|
|
25592
25647
|
? filterValues(data.val)
|
|
25593
25648
|
: data.val).reduce(reducer, "")}`;
|
|
25594
25649
|
case exports.EnumToken.CommentNodeType:
|
|
@@ -25643,7 +25698,7 @@
|
|
|
25643
25698
|
: node.val;
|
|
25644
25699
|
}
|
|
25645
25700
|
else if (node.typ == exports.EnumToken.DeclarationNodeType) {
|
|
25646
|
-
str = `${node.nam}:${options.indent}${(options.
|
|
25701
|
+
str = `${node.nam}:${options.indent}${(options.minifyValues
|
|
25647
25702
|
? filterValues(node.val)
|
|
25648
25703
|
: node.val)
|
|
25649
25704
|
.reduce(reducer, "")
|
|
@@ -25711,9 +25766,10 @@
|
|
|
25711
25766
|
function renderValue(token, options = {}, cache = Object.create(null), reducer, errors) {
|
|
25712
25767
|
if (token.typ === exports.EnumToken.WhenElseFunctionTokenType &&
|
|
25713
25768
|
equalsIgnoreCase(token.val, "supports")) {
|
|
25714
|
-
options = { ...options, minify: false, convertColor: false };
|
|
25769
|
+
options = { ...options, minifyValues: false, minify: false, convertColor: false };
|
|
25715
25770
|
reducer = null;
|
|
25716
25771
|
}
|
|
25772
|
+
options.minifyValues ??= options.minify;
|
|
25717
25773
|
if (reducer == null) {
|
|
25718
25774
|
reducer = function (acc, curr) {
|
|
25719
25775
|
if (curr.typ == exports.EnumToken.CommentTokenType && options.removeComments) {
|
|
@@ -25870,7 +25926,7 @@
|
|
|
25870
25926
|
")");
|
|
25871
25927
|
}
|
|
25872
25928
|
case exports.EnumToken.UrlFunctionTokenType:
|
|
25873
|
-
if (options.
|
|
25929
|
+
if (options.minifyValues && token.typ === exports.EnumToken.UrlFunctionTokenType) {
|
|
25874
25930
|
if (token.chi[0]?.typ === exports.EnumToken.BadUrlTokenType) {
|
|
25875
25931
|
return "url()";
|
|
25876
25932
|
}
|
|
@@ -25891,7 +25947,7 @@
|
|
|
25891
25947
|
case exports.EnumToken.FunctionTokenType:
|
|
25892
25948
|
case exports.EnumToken.MathFunctionTokenType:
|
|
25893
25949
|
case exports.EnumToken.ImageFunctionTokenType:
|
|
25894
|
-
if (options.
|
|
25950
|
+
if (options.minifyValues && token.typ === exports.EnumToken.ImageFunctionTokenType) {
|
|
25895
25951
|
const slice = token.chi.slice();
|
|
25896
25952
|
switch (token.val) {
|
|
25897
25953
|
case "linear-gradient":
|
|
@@ -26377,37 +26433,7 @@
|
|
|
26377
26433
|
renderValue(curr, token.typ == exports.EnumToken.FunctionTokenType ? { minify: false } : options, cache, reducer), "") +
|
|
26378
26434
|
")");
|
|
26379
26435
|
}
|
|
26380
|
-
return (
|
|
26381
|
-
/* options.minify && 'Pseudo-class-func' == token.typ && token.val.slice(0, 2) == '::' ? token.val.slice(1) :*/ (token.val ?? "") +
|
|
26382
|
-
"(" +
|
|
26383
|
-
token.chi.reduce(reducer, "") +
|
|
26384
|
-
")");
|
|
26385
|
-
// case EnumToken.MatchExpressionTokenType:
|
|
26386
|
-
// return (
|
|
26387
|
-
// renderValue((token as MatchExpressionToken).l as Token, options, cache, reducer, errors) +
|
|
26388
|
-
// renderValue((token as MatchExpressionToken).op, options, cache, reducer, errors) +
|
|
26389
|
-
// renderValue((token as MatchExpressionToken).r, options, cache, reducer, errors) +
|
|
26390
|
-
// ((token as MatchExpressionToken).attr ? " " + (token as MatchExpressionToken).attr : "")
|
|
26391
|
-
// );
|
|
26392
|
-
// case EnumToken.NameSpaceAttributeTokenType:
|
|
26393
|
-
// return (
|
|
26394
|
-
// ((token as NameSpaceAttributeToken).l == null
|
|
26395
|
-
// ? ""
|
|
26396
|
-
// : renderValue((token as NameSpaceAttributeToken).l as Token, options, cache, reducer, errors)) +
|
|
26397
|
-
// "|" +
|
|
26398
|
-
// renderValue((token as NameSpaceAttributeToken).r, options, cache, reducer, errors)
|
|
26399
|
-
// );
|
|
26400
|
-
// case EnumToken.ComposesSelectorNodeType:
|
|
26401
|
-
// return (
|
|
26402
|
-
// (token as ComposesSelectorToken).l.reduce(
|
|
26403
|
-
// (acc: string, curr: Token) => acc + renderValue(curr, options, cache),
|
|
26404
|
-
// "",
|
|
26405
|
-
// ) +
|
|
26406
|
-
// ((token as ComposesSelectorToken).r == null
|
|
26407
|
-
// ? ""
|
|
26408
|
-
// : " from " +
|
|
26409
|
-
// renderValue((token as ComposesSelectorToken).r as Token, options, cache, reducer, errors))
|
|
26410
|
-
// );
|
|
26436
|
+
return (token.val ?? "") + "(" + token.chi.reduce(reducer, "") + ")";
|
|
26411
26437
|
case exports.EnumToken.BlockStartTokenType:
|
|
26412
26438
|
return "{";
|
|
26413
26439
|
case exports.EnumToken.BlockEndTokenType:
|
|
@@ -26556,7 +26582,11 @@
|
|
|
26556
26582
|
const perc = token.val.typ == exports.EnumToken.FractionTokenType
|
|
26557
26583
|
? renderValue(token.val, options, cache)
|
|
26558
26584
|
: minifyNumber(token.val);
|
|
26559
|
-
return options.
|
|
26585
|
+
return options.minifyValues && perc == "0"
|
|
26586
|
+
? "0"
|
|
26587
|
+
: perc.includes("/")
|
|
26588
|
+
? perc.replace("/", uni + "/")
|
|
26589
|
+
: perc + uni;
|
|
26560
26590
|
case exports.EnumToken.NumberTokenType:
|
|
26561
26591
|
return token.val.typ == exports.EnumToken.FractionTokenType
|
|
26562
26592
|
? renderValue(token.val, options, cache)
|
|
@@ -26621,7 +26651,7 @@
|
|
|
26621
26651
|
case exports.EnumToken.DeclarationNodeType:
|
|
26622
26652
|
return (token.nam +
|
|
26623
26653
|
":" +
|
|
26624
|
-
(options.
|
|
26654
|
+
(options.minifyValues ? filterValues(token.val) : token.val).reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
|
|
26625
26655
|
case exports.EnumToken.MediaQueryUnaryFeatureTokenType:
|
|
26626
26656
|
return (renderValue(token.l, options, cache, reducer) +
|
|
26627
26657
|
" " +
|
|
@@ -26695,6 +26725,7 @@
|
|
|
26695
26725
|
}
|
|
26696
26726
|
|
|
26697
26727
|
const SymbolsMapTokens = Object.create(null);
|
|
26728
|
+
const SymbolsMapTokensLower = Object.create(null);
|
|
26698
26729
|
// Regex for escape sequence decoding - compile once, reuse many times
|
|
26699
26730
|
const ESCAPE_SEQUENCE_REGEX = /\\((\n|\r|\f|\v|\u2028|\u2029|([0-9a-fA-F]{1,6})) ?)/gms;
|
|
26700
26731
|
function decodeEscapeSequences(value) {
|
|
@@ -26723,7 +26754,9 @@
|
|
|
26723
26754
|
}
|
|
26724
26755
|
function assignTokenMap(entries, tokenType, suffix = "", lowercase = false) {
|
|
26725
26756
|
for (const entry of entries) {
|
|
26726
|
-
|
|
26757
|
+
const key = (lowercase ? entry.toLowerCase() : entry) + suffix;
|
|
26758
|
+
SymbolsMapTokens[key] = tokenType;
|
|
26759
|
+
SymbolsMapTokensLower[key.toLowerCase()] = tokenType;
|
|
26727
26760
|
}
|
|
26728
26761
|
}
|
|
26729
26762
|
SymbolsMapTokens[""] = exports.EnumToken.DelimTokenType;
|
|
@@ -26823,20 +26856,24 @@
|
|
|
26823
26856
|
})(TokenMap || (TokenMap = {}));
|
|
26824
26857
|
function getSymbolHint(parseInfo, start, end) {
|
|
26825
26858
|
const len = end - start;
|
|
26826
|
-
|
|
26827
|
-
// Early exit for impossible lengths
|
|
26828
|
-
if (len < 0)
|
|
26859
|
+
if (len <= 0)
|
|
26829
26860
|
return null;
|
|
26861
|
+
const value = parseInfo.stream.slice(start, end);
|
|
26862
|
+
// Direct lookup handles the hottest punctuation and keyword cases without
|
|
26863
|
+
// scanning the entire symbol table on every token.
|
|
26864
|
+
const match = SymbolsMapTokens[value] ?? SymbolsMapTokensLower[value.toLowerCase()];
|
|
26865
|
+
if (match != null) {
|
|
26866
|
+
return match;
|
|
26867
|
+
}
|
|
26868
|
+
const keysLength = SymbolsMapTokensKeys.length;
|
|
26830
26869
|
for (let i = 0; i < keysLength; i++) {
|
|
26831
26870
|
const key = SymbolsMapTokensKeys[i];
|
|
26832
26871
|
if (key.length !== len)
|
|
26833
26872
|
continue;
|
|
26834
|
-
// Match character by character
|
|
26835
26873
|
let match = true;
|
|
26836
26874
|
for (let j = 0; j < len; j++) {
|
|
26837
26875
|
let ca = key.charCodeAt(j);
|
|
26838
|
-
let cb =
|
|
26839
|
-
// Normalize A-Z to a-z
|
|
26876
|
+
let cb = value.charCodeAt(j);
|
|
26840
26877
|
if (ca >= 65 && ca <= 90)
|
|
26841
26878
|
ca += 32;
|
|
26842
26879
|
if (cb >= 65 && cb <= 90)
|
|
@@ -26854,32 +26891,29 @@
|
|
|
26854
26891
|
}
|
|
26855
26892
|
function searchArray(array, parseInfo, start, end) {
|
|
26856
26893
|
const len = end - start;
|
|
26857
|
-
|
|
26858
|
-
if (len < 0)
|
|
26894
|
+
if (len <= 0)
|
|
26859
26895
|
return null;
|
|
26860
|
-
|
|
26861
|
-
let
|
|
26862
|
-
|
|
26863
|
-
|
|
26896
|
+
let match;
|
|
26897
|
+
let item;
|
|
26898
|
+
for (let i = 0; i < array.length; i++) {
|
|
26899
|
+
item = array[i];
|
|
26900
|
+
if (item.length !== len)
|
|
26864
26901
|
continue;
|
|
26865
|
-
|
|
26866
|
-
let match = true;
|
|
26867
|
-
const arrayItem = array[i];
|
|
26902
|
+
match = true;
|
|
26868
26903
|
for (let j = 0; j < len; j++) {
|
|
26869
|
-
let ca =
|
|
26870
|
-
let cb =
|
|
26871
|
-
// Normalize A-Z to a-z
|
|
26904
|
+
let ca = parseInfo.stream.charCodeAt(start + j);
|
|
26905
|
+
let cb = item.charCodeAt(j);
|
|
26872
26906
|
if (ca >= 65 && ca <= 90)
|
|
26873
26907
|
ca += 32;
|
|
26874
26908
|
if (cb >= 65 && cb <= 90)
|
|
26875
26909
|
cb += 32;
|
|
26876
|
-
if (ca
|
|
26910
|
+
if (ca !== cb) {
|
|
26877
26911
|
match = false;
|
|
26878
26912
|
break;
|
|
26879
26913
|
}
|
|
26880
26914
|
}
|
|
26881
26915
|
if (match) {
|
|
26882
|
-
return
|
|
26916
|
+
return item;
|
|
26883
26917
|
}
|
|
26884
26918
|
}
|
|
26885
26919
|
return null;
|
|
@@ -27817,23 +27851,6 @@
|
|
|
27817
27851
|
}
|
|
27818
27852
|
return true;
|
|
27819
27853
|
}
|
|
27820
|
-
/**
|
|
27821
|
-
*
|
|
27822
|
-
* @param parseInfo
|
|
27823
|
-
* @returns
|
|
27824
|
-
*/
|
|
27825
|
-
// isPseudo(parseInfo: ParseInfo): boolean {
|
|
27826
|
-
// let position: number = parseInfo.currentPosition - parseInfo.offset;
|
|
27827
|
-
// let endPosition: number = parseInfo.currentPosition - parseInfo.offset;
|
|
27828
|
-
// return (parseInfo.stream.charAt(position) == ":" &&
|
|
27829
|
-
// parseInfo.stream.charAt(endPosition - 1) == "(" &&
|
|
27830
|
-
// (parseInfo.stream.charAt(position + 1) == ":"
|
|
27831
|
-
// ? this.isIdentToken(parseInfo, 2, -1)
|
|
27832
|
-
// : this.isIdentToken(parseInfo, 1, -1))) ||
|
|
27833
|
-
// parseInfo.stream.charAt(position + 1) == ":"
|
|
27834
|
-
// ? this.isIdentToken(parseInfo, 2)
|
|
27835
|
-
// : this.isIdentToken(parseInfo, 1);
|
|
27836
|
-
// }
|
|
27837
27854
|
/**
|
|
27838
27855
|
*
|
|
27839
27856
|
* @param parseInfo
|
|
@@ -27964,28 +27981,28 @@
|
|
|
27964
27981
|
// EOF
|
|
27965
27982
|
switch (charCode) {
|
|
27966
27983
|
case 61 /* TokenMap.EQUALS */:
|
|
27967
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
27968
|
-
|
|
27969
|
-
}
|
|
27984
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
27985
|
+
// return this.makeToken(parseInfo);
|
|
27986
|
+
// }
|
|
27970
27987
|
this.advance(parseInfo);
|
|
27971
27988
|
return this.makeToken(parseInfo, exports.EnumToken.DelimTokenType);
|
|
27972
27989
|
// '+' or '-'
|
|
27973
27990
|
case 43 /* TokenMap.PLUS */:
|
|
27974
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
27975
|
-
|
|
27976
|
-
}
|
|
27991
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
27992
|
+
// return this.makeToken(parseInfo);
|
|
27993
|
+
// }
|
|
27977
27994
|
this.advance(parseInfo);
|
|
27978
27995
|
charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
27979
|
-
if (isDigit(charCode)) {
|
|
27980
|
-
|
|
27981
|
-
|
|
27982
|
-
|
|
27983
|
-
|
|
27984
|
-
|
|
27985
|
-
|
|
27986
|
-
|
|
27987
|
-
|
|
27988
|
-
}
|
|
27996
|
+
// if (isDigit(charCode)) {
|
|
27997
|
+
// tokensCount = this.consumeNumericToken(parseInfo);
|
|
27998
|
+
// if (tokensCount > 0) {
|
|
27999
|
+
// this.advance(parseInfo, tokensCount);
|
|
28000
|
+
// return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, {
|
|
28001
|
+
// slice: this.slice,
|
|
28002
|
+
// sign: "+",
|
|
28003
|
+
// });
|
|
28004
|
+
// }
|
|
28005
|
+
// }
|
|
27989
28006
|
return this.makeToken(parseInfo, exports.EnumToken.Plus);
|
|
27990
28007
|
case 45 /* TokenMap.MINUS */:
|
|
27991
28008
|
if (parseInfo.position == parseInfo.currentPosition) {
|
|
@@ -27995,15 +28012,17 @@
|
|
|
27995
28012
|
this.advance(parseInfo);
|
|
27996
28013
|
return this.makeToken(parseInfo, exports.EnumToken.Sub);
|
|
27997
28014
|
}
|
|
27998
|
-
if (
|
|
27999
|
-
|
|
28000
|
-
|
|
28001
|
-
|
|
28002
|
-
|
|
28003
|
-
|
|
28004
|
-
|
|
28005
|
-
|
|
28006
|
-
|
|
28015
|
+
// if (
|
|
28016
|
+
// charCode == TokenMap.MINUS &&
|
|
28017
|
+
// (nextCharCode == TokenMap.MINUS || isIdentStart(nextCharCode))
|
|
28018
|
+
// ) {
|
|
28019
|
+
// this.advance(parseInfo);
|
|
28020
|
+
// tokensCount = this.consumeIdentToken(parseInfo);
|
|
28021
|
+
// if (tokensCount > 0) {
|
|
28022
|
+
// this.advance(parseInfo, tokensCount);
|
|
28023
|
+
// return this.makeToken(parseInfo, EnumToken.IdenTokenType);
|
|
28024
|
+
// }
|
|
28025
|
+
// }
|
|
28007
28026
|
}
|
|
28008
28027
|
this.advance(parseInfo);
|
|
28009
28028
|
break;
|
|
@@ -28056,28 +28075,28 @@
|
|
|
28056
28075
|
return this.makeToken(parseInfo, exports.EnumToken.EndParensTokenType);
|
|
28057
28076
|
// '['
|
|
28058
28077
|
case 91 /* TokenMap.LEFT_BRACKETS */:
|
|
28059
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28060
|
-
|
|
28061
|
-
}
|
|
28078
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28079
|
+
// return this.makeToken(parseInfo);
|
|
28080
|
+
// }
|
|
28062
28081
|
this.advance(parseInfo);
|
|
28063
28082
|
return this.makeToken(parseInfo, exports.EnumToken.AttrStartTokenType);
|
|
28064
28083
|
// ']'
|
|
28065
28084
|
case 93 /* TokenMap.RIGHT_BRACKETS */:
|
|
28066
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28067
|
-
|
|
28068
|
-
}
|
|
28085
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28086
|
+
// return this.makeToken(parseInfo);
|
|
28087
|
+
// }
|
|
28069
28088
|
this.advance(parseInfo);
|
|
28070
28089
|
return this.makeToken(parseInfo, exports.EnumToken.AttrEndTokenType);
|
|
28071
28090
|
case 59 /* TokenMap.SEMICOLON */:
|
|
28072
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28073
|
-
|
|
28074
|
-
}
|
|
28091
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28092
|
+
// return this.makeToken(parseInfo);
|
|
28093
|
+
// }
|
|
28075
28094
|
this.advance(parseInfo);
|
|
28076
28095
|
return this.makeToken(parseInfo, exports.EnumToken.SemiColonTokenType);
|
|
28077
28096
|
case 58 /* TokenMap.COLON */:
|
|
28078
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28079
|
-
|
|
28080
|
-
}
|
|
28097
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28098
|
+
// return this.makeToken(parseInfo);
|
|
28099
|
+
// }
|
|
28081
28100
|
this.advance(parseInfo);
|
|
28082
28101
|
if (this.peekCharCode(parseInfo) == 58 /* TokenMap.COLON */) {
|
|
28083
28102
|
this.advance(parseInfo);
|
|
@@ -28109,15 +28128,15 @@
|
|
|
28109
28128
|
}
|
|
28110
28129
|
return this.makeToken(parseInfo, exports.EnumToken.WhitespaceTokenType);
|
|
28111
28130
|
case 44 /* TokenMap.COMMA */:
|
|
28112
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28113
|
-
|
|
28114
|
-
}
|
|
28131
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28132
|
+
// return this.makeToken(parseInfo);
|
|
28133
|
+
// }
|
|
28115
28134
|
this.advance(parseInfo);
|
|
28116
28135
|
return this.makeToken(parseInfo, exports.EnumToken.CommaTokenType);
|
|
28117
28136
|
case 36 /* TokenMap.DOLLAR */:
|
|
28118
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28119
|
-
|
|
28120
|
-
}
|
|
28137
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28138
|
+
// return this.makeToken(parseInfo);
|
|
28139
|
+
// }
|
|
28121
28140
|
if (this.match(parseInfo, "$=")) {
|
|
28122
28141
|
this.advance(parseInfo, 2);
|
|
28123
28142
|
return this.makeToken(parseInfo, exports.EnumToken.EndMatchTokenType);
|
|
@@ -28125,9 +28144,9 @@
|
|
|
28125
28144
|
this.advance(parseInfo);
|
|
28126
28145
|
break;
|
|
28127
28146
|
case 126 /* TokenMap.TILDA */:
|
|
28128
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28129
|
-
|
|
28130
|
-
}
|
|
28147
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28148
|
+
// return this.makeToken(parseInfo);
|
|
28149
|
+
// }
|
|
28131
28150
|
if (this.match(parseInfo, "~=")) {
|
|
28132
28151
|
this.advance(parseInfo, 2);
|
|
28133
28152
|
return this.makeToken(parseInfo, exports.EnumToken.IncludeMatchTokenType);
|
|
@@ -28136,9 +28155,9 @@
|
|
|
28136
28155
|
return this.makeToken(parseInfo, exports.EnumToken.Tilda);
|
|
28137
28156
|
// case '^':
|
|
28138
28157
|
case 94 /* TokenMap.CARET */:
|
|
28139
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28140
|
-
|
|
28141
|
-
}
|
|
28158
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28159
|
+
// return this.makeToken(parseInfo);
|
|
28160
|
+
// }
|
|
28142
28161
|
if (this.match(parseInfo, "^=")) {
|
|
28143
28162
|
this.advance(parseInfo, 2);
|
|
28144
28163
|
return this.makeToken(parseInfo, exports.EnumToken.StartMatchTokenType);
|
|
@@ -28146,9 +28165,9 @@
|
|
|
28146
28165
|
this.advance(parseInfo);
|
|
28147
28166
|
break;
|
|
28148
28167
|
case 42 /* TokenMap.STAR */:
|
|
28149
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28150
|
-
|
|
28151
|
-
}
|
|
28168
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28169
|
+
// return this.makeToken(parseInfo);
|
|
28170
|
+
// }
|
|
28152
28171
|
if (this.match(parseInfo, "*=")) {
|
|
28153
28172
|
this.advance(parseInfo, 2);
|
|
28154
28173
|
return this.makeToken(parseInfo, exports.EnumToken.ContainMatchTokenType);
|
|
@@ -28162,9 +28181,9 @@
|
|
|
28162
28181
|
this.advance(parseInfo);
|
|
28163
28182
|
return this.makeToken(parseInfo, exports.EnumToken.NestingSelectorTokenType);
|
|
28164
28183
|
case 124 /* TokenMap.PIPE */:
|
|
28165
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28166
|
-
|
|
28167
|
-
}
|
|
28184
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28185
|
+
// return this.makeToken(parseInfo);
|
|
28186
|
+
// }
|
|
28168
28187
|
// '||'
|
|
28169
28188
|
if (this.match(parseInfo, "||")) {
|
|
28170
28189
|
this.advance(parseInfo, 2);
|
|
@@ -28187,9 +28206,9 @@
|
|
|
28187
28206
|
this.advance(parseInfo);
|
|
28188
28207
|
break;
|
|
28189
28208
|
case 47 /* TokenMap.SLASH */:
|
|
28190
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28191
|
-
|
|
28192
|
-
}
|
|
28209
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28210
|
+
// return this.makeToken(parseInfo);
|
|
28211
|
+
// }
|
|
28193
28212
|
if (!this.match(parseInfo, "/*")) {
|
|
28194
28213
|
this.advance(parseInfo);
|
|
28195
28214
|
return this.makeToken(parseInfo, getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset));
|
|
@@ -28208,9 +28227,9 @@
|
|
|
28208
28227
|
}
|
|
28209
28228
|
break;
|
|
28210
28229
|
case 62 /* TokenMap.GREATERTHAN */:
|
|
28211
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28212
|
-
|
|
28213
|
-
}
|
|
28230
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28231
|
+
// return this.makeToken(parseInfo);
|
|
28232
|
+
// }
|
|
28214
28233
|
if (this.match(parseInfo, ">=")) {
|
|
28215
28234
|
this.advance(parseInfo, 2);
|
|
28216
28235
|
return this.makeToken(parseInfo, exports.EnumToken.GteTokenType);
|
|
@@ -28249,20 +28268,11 @@
|
|
|
28249
28268
|
this.advance(parseInfo);
|
|
28250
28269
|
break;
|
|
28251
28270
|
case 92 /* TokenMap.REVERSE_SOLIDUS */:
|
|
28252
|
-
// if (!yieldEOFToken && parseInfo.stream.length == parseInfo.currentPosition - parseInfo.offset + 1) {
|
|
28253
|
-
// break;
|
|
28254
|
-
// }
|
|
28255
28271
|
this.advance(parseInfo);
|
|
28256
28272
|
// EOF
|
|
28257
|
-
|
|
28258
|
-
|
|
28259
|
-
|
|
28260
|
-
// }
|
|
28261
|
-
// end of stream ignore \\
|
|
28262
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28263
|
-
return this.makeToken(parseInfo);
|
|
28264
|
-
}
|
|
28265
|
-
break;
|
|
28273
|
+
// end of stream ignore \\
|
|
28274
|
+
if (!this.peek(parseInfo) && parseInfo.position < parseInfo.currentPosition) {
|
|
28275
|
+
return this.makeToken(parseInfo);
|
|
28266
28276
|
}
|
|
28267
28277
|
this.advance(parseInfo);
|
|
28268
28278
|
break;
|
|
@@ -28275,9 +28285,9 @@
|
|
|
28275
28285
|
case 46 /* TokenMap.DOT */:
|
|
28276
28286
|
const codepoint = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
|
|
28277
28287
|
if (isIdentStart(codepoint) || codepoint == 45 /* TokenMap.MINUS */) {
|
|
28278
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28279
|
-
|
|
28280
|
-
}
|
|
28288
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28289
|
+
// return this.makeToken(parseInfo);
|
|
28290
|
+
// }
|
|
28281
28291
|
this.advance(parseInfo);
|
|
28282
28292
|
let tokensCount = this.consumeIdentToken(parseInfo);
|
|
28283
28293
|
if (tokensCount > 0) {
|
|
@@ -28285,27 +28295,22 @@
|
|
|
28285
28295
|
return this.makeToken(parseInfo, exports.EnumToken.ClassSelectorTokenType);
|
|
28286
28296
|
}
|
|
28287
28297
|
}
|
|
28288
|
-
if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
|
|
28289
|
-
|
|
28290
|
-
|
|
28291
|
-
|
|
28292
|
-
}
|
|
28298
|
+
// if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
|
|
28299
|
+
// this.makeToken(parseInfo);
|
|
28300
|
+
// this.advance(parseInfo, 2);
|
|
28301
|
+
// return this;
|
|
28302
|
+
// }
|
|
28293
28303
|
this.advance(parseInfo);
|
|
28294
28304
|
break;
|
|
28295
28305
|
default:
|
|
28296
28306
|
this.advance(parseInfo);
|
|
28297
28307
|
break;
|
|
28298
28308
|
}
|
|
28299
|
-
// if (!yieldEOFToken && endPosition <= parseInfo.currentPosition - parseInfo.offset + 1) {
|
|
28300
|
-
// break;
|
|
28301
|
-
// }
|
|
28302
28309
|
}
|
|
28303
|
-
// if (yieldEOFToken) {
|
|
28304
28310
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28305
28311
|
return this.makeToken(parseInfo);
|
|
28306
28312
|
}
|
|
28307
28313
|
return this.makeToken(parseInfo, exports.EnumToken.EOFTokenType);
|
|
28308
|
-
// }
|
|
28309
28314
|
}
|
|
28310
28315
|
/**
|
|
28311
28316
|
* tokenize readable stream
|
|
@@ -29470,8 +29475,6 @@
|
|
|
29470
29475
|
}
|
|
29471
29476
|
}
|
|
29472
29477
|
}
|
|
29473
|
-
// let isValidMFValue = isMFValue(name, left, true);
|
|
29474
|
-
// isValidMFValue = isMFValue(name, right, true);
|
|
29475
29478
|
for (const val of [left, right]) {
|
|
29476
29479
|
if (mfInfo?.type === MediaFeatureType.RatioType) {
|
|
29477
29480
|
const filteredValues = val.filter((n) => n.typ !== exports.EnumToken.WhitespaceTokenType &&
|
|
@@ -30267,7 +30270,7 @@
|
|
|
30267
30270
|
};
|
|
30268
30271
|
}
|
|
30269
30272
|
{
|
|
30270
|
-
for (const stream of parts
|
|
30273
|
+
for (const stream of parts) {
|
|
30271
30274
|
let success = true;
|
|
30272
30275
|
let i;
|
|
30273
30276
|
let currentScope = new Set();
|
|
@@ -30386,6 +30389,22 @@
|
|
|
30386
30389
|
[LOCSTA]: names[0][LOCSTA],
|
|
30387
30390
|
[LOCEND]: values.at(-1)[LOCEND],
|
|
30388
30391
|
});
|
|
30392
|
+
const token = tokens[index3 + 1];
|
|
30393
|
+
if (token.op.typ === exports.EnumToken.ColonTokenType) {
|
|
30394
|
+
let name = token.l.find((t) => t.typ === exports.EnumToken.IdenTokenType);
|
|
30395
|
+
if (name != null) {
|
|
30396
|
+
if (name.val.startsWith("min-")) {
|
|
30397
|
+
name.val = name.val.substring(4);
|
|
30398
|
+
// @ts-ignore
|
|
30399
|
+
token.op.typ = exports.EnumToken.GteTokenType;
|
|
30400
|
+
}
|
|
30401
|
+
else if (name.val.startsWith("max-")) {
|
|
30402
|
+
name.val = name.val.substring(4);
|
|
30403
|
+
// @ts-ignore
|
|
30404
|
+
token.op.typ = exports.EnumToken.LteTokenType;
|
|
30405
|
+
}
|
|
30406
|
+
}
|
|
30407
|
+
}
|
|
30389
30408
|
// check <style()> or <scroll-state()>
|
|
30390
30409
|
}
|
|
30391
30410
|
if (tokensfuncDefMap.has(stack.at(-1)?.typ)) {
|
|
@@ -30477,6 +30496,58 @@
|
|
|
30477
30496
|
};
|
|
30478
30497
|
tokens.length = l + 1;
|
|
30479
30498
|
expectAndOr = true;
|
|
30499
|
+
if (tokens[l].op.typ === exports.EnumToken.AndTokenType) {
|
|
30500
|
+
let left = tokens[l].l.find((t) => t.typ != exports.EnumToken.WhitespaceTokenType && t.typ != exports.EnumToken.IdenTokenType);
|
|
30501
|
+
let right = tokens[l].r.find((t) => t.typ != exports.EnumToken.WhitespaceTokenType && t.typ != exports.EnumToken.IdenTokenType);
|
|
30502
|
+
if (left.typ == exports.EnumToken.ParensTokenType && right.typ == exports.EnumToken.ParensTokenType) {
|
|
30503
|
+
left = left.chi.find((t) => t.typ != exports.EnumToken.WhitespaceTokenType && t.typ != exports.EnumToken.IdenTokenType);
|
|
30504
|
+
right = right.chi.find((t) => t.typ != exports.EnumToken.WhitespaceTokenType && t.typ != exports.EnumToken.IdenTokenType);
|
|
30505
|
+
if (left.typ == exports.EnumToken.MediaQueryConditionTokenType &&
|
|
30506
|
+
(mFLT.has(left.op.typ) ||
|
|
30507
|
+
mFGT.has(left.op.typ)) &&
|
|
30508
|
+
right.typ == exports.EnumToken.MediaQueryConditionTokenType &&
|
|
30509
|
+
(mFLT.has(right.op.typ) ||
|
|
30510
|
+
mFGT.has(right.op.typ))) {
|
|
30511
|
+
const name = left.l.find((t) => t.typ == exports.EnumToken.IdenTokenType);
|
|
30512
|
+
const name2 = right.l.find((t) => t.typ == exports.EnumToken.IdenTokenType);
|
|
30513
|
+
if (equalsIgnoreCase(name.val, name2.val)) {
|
|
30514
|
+
switch (left.op.typ) {
|
|
30515
|
+
case exports.EnumToken.LtTokenType:
|
|
30516
|
+
left.op.typ = exports.EnumToken.GtTokenType;
|
|
30517
|
+
break;
|
|
30518
|
+
case exports.EnumToken.LteTokenType:
|
|
30519
|
+
left.op.typ = exports.EnumToken.GteTokenType;
|
|
30520
|
+
break;
|
|
30521
|
+
case exports.EnumToken.GtTokenType:
|
|
30522
|
+
left.op.typ = exports.EnumToken.LtTokenType;
|
|
30523
|
+
break;
|
|
30524
|
+
case exports.EnumToken.GteTokenType:
|
|
30525
|
+
left.op.typ = exports.EnumToken.LteTokenType;
|
|
30526
|
+
break;
|
|
30527
|
+
}
|
|
30528
|
+
tokens[l] = {
|
|
30529
|
+
typ: exports.EnumToken.ParensTokenType,
|
|
30530
|
+
chi: [
|
|
30531
|
+
{
|
|
30532
|
+
typ: exports.EnumToken.MediaRangeQueryTokenType,
|
|
30533
|
+
l: left.r,
|
|
30534
|
+
val: [name],
|
|
30535
|
+
op1: left.op,
|
|
30536
|
+
op2: right.op,
|
|
30537
|
+
r: right.r,
|
|
30538
|
+
[LOCSRCID]: name[LOCSRCID],
|
|
30539
|
+
[LOCSTA]: left[LOCSTA],
|
|
30540
|
+
[LOCEND]: right[LOCEND],
|
|
30541
|
+
},
|
|
30542
|
+
],
|
|
30543
|
+
[LOCSRCID]: name[LOCSRCID],
|
|
30544
|
+
[LOCSTA]: left[LOCSTA],
|
|
30545
|
+
[LOCEND]: right[LOCEND],
|
|
30546
|
+
};
|
|
30547
|
+
}
|
|
30548
|
+
}
|
|
30549
|
+
}
|
|
30550
|
+
}
|
|
30480
30551
|
}
|
|
30481
30552
|
break;
|
|
30482
30553
|
}
|
|
@@ -31079,6 +31150,7 @@
|
|
|
31079
31150
|
if (options.expandNestingRules) {
|
|
31080
31151
|
options.nestingRules = false;
|
|
31081
31152
|
}
|
|
31153
|
+
options.minifyAST ??= options.minify;
|
|
31082
31154
|
const startTime = performance.now();
|
|
31083
31155
|
const errors = [];
|
|
31084
31156
|
const stack = [];
|
|
@@ -31109,7 +31181,6 @@
|
|
|
31109
31181
|
// let currentItemIndex: number;
|
|
31110
31182
|
ast[LOCSRCID] = options.source.id;
|
|
31111
31183
|
ast[LOCSTA] = 0;
|
|
31112
|
-
// let tokenizer: Tokenizer;
|
|
31113
31184
|
while (!tokenizer.done()) {
|
|
31114
31185
|
tokenizer.next();
|
|
31115
31186
|
// item = (iter as Array<TokenizeResult>)[currentItemIndex];
|
|
@@ -31458,7 +31529,7 @@
|
|
|
31458
31529
|
}
|
|
31459
31530
|
}
|
|
31460
31531
|
}
|
|
31461
|
-
if (options.
|
|
31532
|
+
if (options.minifyAST) {
|
|
31462
31533
|
if (ast.chi.length > 0) {
|
|
31463
31534
|
let passes = options.pass ?? 1;
|
|
31464
31535
|
while (passes--) {
|
|
@@ -31998,6 +32069,7 @@
|
|
|
31998
32069
|
lenient: true,
|
|
31999
32070
|
...options,
|
|
32000
32071
|
};
|
|
32072
|
+
options.minifyAST ??= options.minify;
|
|
32001
32073
|
if (typeof options.validation !== "boolean") {
|
|
32002
32074
|
options.validation = !!options.validation;
|
|
32003
32075
|
}
|
|
@@ -32452,7 +32524,7 @@
|
|
|
32452
32524
|
}
|
|
32453
32525
|
}
|
|
32454
32526
|
}
|
|
32455
|
-
if (options.
|
|
32527
|
+
if (options.minifyAST) {
|
|
32456
32528
|
if (ast.chi.length > 0) {
|
|
32457
32529
|
let passes = options.pass ?? 1;
|
|
32458
32530
|
while (passes--) {
|
|
@@ -34842,6 +34914,7 @@
|
|
|
34842
34914
|
});
|
|
34843
34915
|
}
|
|
34844
34916
|
|
|
34917
|
+
exports.PropertyList = PropertyList;
|
|
34845
34918
|
exports.SourceMap = SourceMap;
|
|
34846
34919
|
exports.cloneNode = cloneNode;
|
|
34847
34920
|
exports.convertColor = convertColor;
|