@tbela99/css-parser 1.6.4 → 1.6.5
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 +43 -0
- package/README.md +104 -0
- package/dist/index-umd-web.js +283 -282
- package/dist/index.cjs +282 -282
- package/dist/index.d.ts +15 -2
- package/dist/lib/ast/features/calc.js +16 -4
- 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 +24 -1
- 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 -2
- package/dist/lib/parser/tokenize.js +99 -124
- 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 +2 -1
- package/dist/web.js +1 -0
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -6432,6 +6432,11 @@ const anglePrecision = 3;
|
|
|
6432
6432
|
* Color range definitions
|
|
6433
6433
|
*/
|
|
6434
6434
|
const colorRange = {
|
|
6435
|
+
rgb: {
|
|
6436
|
+
r: [0, 255],
|
|
6437
|
+
g: [0, 255],
|
|
6438
|
+
b: [0, 255],
|
|
6439
|
+
},
|
|
6435
6440
|
lab: {
|
|
6436
6441
|
l: [0, 100],
|
|
6437
6442
|
a: [-125, 125],
|
|
@@ -6901,13 +6906,6 @@ function equalsIgnoreCase(a, b) {
|
|
|
6901
6906
|
}
|
|
6902
6907
|
|
|
6903
6908
|
function getColorComponents(token) {
|
|
6904
|
-
// if (token.typ === EnumToken.IdenTokenType) {
|
|
6905
|
-
// if (isColor(token)) {
|
|
6906
|
-
// parseColor(token);
|
|
6907
|
-
// } else {
|
|
6908
|
-
// return null;
|
|
6909
|
-
// }
|
|
6910
|
-
// }
|
|
6911
6909
|
if (token.kin == exports.ColorType.HEX || token.kin == exports.ColorType.LIT) {
|
|
6912
6910
|
if (equalsIgnoreCase("currentcolor", token.val)) {
|
|
6913
6911
|
return null;
|
|
@@ -6931,25 +6929,12 @@ function getColorComponents(token) {
|
|
|
6931
6929
|
].includes(child.typ)) {
|
|
6932
6930
|
continue;
|
|
6933
6931
|
}
|
|
6934
|
-
// if (child.typ === EnumToken.IdenTokenType && isColor(child)) {
|
|
6935
|
-
// parseColor(child);
|
|
6936
|
-
// }
|
|
6937
6932
|
if (child.typ === exports.EnumToken.FunctionTokenType ||
|
|
6938
6933
|
child.typ === exports.EnumToken.WildCardFunctionTokenType ||
|
|
6939
6934
|
child.typ === exports.EnumToken.MathFunctionTokenType) {
|
|
6940
6935
|
if ("var" == child.val.toLowerCase()) {
|
|
6941
6936
|
return null;
|
|
6942
6937
|
}
|
|
6943
|
-
// else {
|
|
6944
|
-
// for (const { value } of walkValues((child as FunctionToken).chi)) {
|
|
6945
|
-
// if (
|
|
6946
|
-
// value.typ == EnumToken.WildCardFunctionTokenDefType &&
|
|
6947
|
-
// "var" === (value as FunctionToken).val.toLowerCase()
|
|
6948
|
-
// ) {
|
|
6949
|
-
// return null;
|
|
6950
|
-
// }
|
|
6951
|
-
// }
|
|
6952
|
-
// }
|
|
6953
6938
|
}
|
|
6954
6939
|
if (child.typ == exports.EnumToken.ColorTokenType && equalsIgnoreCase("currentcolor", child.val)) {
|
|
6955
6940
|
return null;
|
|
@@ -8245,7 +8230,10 @@ function color2HexToken(token) {
|
|
|
8245
8230
|
if (value == null) {
|
|
8246
8231
|
return null;
|
|
8247
8232
|
}
|
|
8248
|
-
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"), "#"));
|
|
8249
8237
|
}
|
|
8250
8238
|
function oklab2HexToken(token) {
|
|
8251
8239
|
let value = oklab2srgbvalues(token);
|
|
@@ -9094,7 +9082,7 @@ function la98rgb2a98rgb(r, g, b, a = null) {
|
|
|
9094
9082
|
// convert an array of linear-light a98-rgb in the range 0.0-1.0
|
|
9095
9083
|
// to gamma corrected form
|
|
9096
9084
|
// negative values are also now accepted
|
|
9097
|
-
return [r,
|
|
9085
|
+
return [r, g, b]
|
|
9098
9086
|
.map(function (val) {
|
|
9099
9087
|
let sign = val < 0 ? -1 : 1;
|
|
9100
9088
|
let abs = Math.abs(val);
|
|
@@ -9230,6 +9218,9 @@ function colorMix(...args) {
|
|
|
9230
9218
|
if (values == null) {
|
|
9231
9219
|
return null;
|
|
9232
9220
|
}
|
|
9221
|
+
if (colorSpace == "hwb") {
|
|
9222
|
+
colorSpace = "srgb";
|
|
9223
|
+
}
|
|
9233
9224
|
switch (colorSpace) {
|
|
9234
9225
|
case "srgb":
|
|
9235
9226
|
break;
|
|
@@ -9259,17 +9250,17 @@ function colorMix(...args) {
|
|
|
9259
9250
|
values = srgb2xyz_d65(values[0], values[1], values[2], values[3]);
|
|
9260
9251
|
values = XYZ_D65_to_D50(values[0], values[1], values[2], values[3]);
|
|
9261
9252
|
break;
|
|
9262
|
-
case "rgb":
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
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;
|
|
9267
9258
|
case "hsl":
|
|
9268
9259
|
values = srgb2hslvalues(values[0], values[1], values[2], values[3]);
|
|
9269
9260
|
break;
|
|
9270
|
-
case "hwb":
|
|
9271
|
-
|
|
9272
|
-
|
|
9261
|
+
// case "hwb":
|
|
9262
|
+
// values = srgb2hwb(values[0], values[1], values[2], values[3]);
|
|
9263
|
+
// break;
|
|
9273
9264
|
case "lab":
|
|
9274
9265
|
values = srgb2labvalues(values[0], values[1], values[2], values[3]);
|
|
9275
9266
|
break;
|
|
@@ -9468,14 +9459,14 @@ function colorMix(...args) {
|
|
|
9468
9459
|
kin: exports.ColorType.COLOR,
|
|
9469
9460
|
cal: "col",
|
|
9470
9461
|
};
|
|
9471
|
-
case "rgb":
|
|
9462
|
+
// case "rgb":
|
|
9472
9463
|
case "hsl":
|
|
9473
|
-
case "hwb":
|
|
9464
|
+
// case "hwb":
|
|
9474
9465
|
case "lab":
|
|
9475
9466
|
case "lch":
|
|
9476
9467
|
case "oklab":
|
|
9477
9468
|
case "oklch":
|
|
9478
|
-
if (colorSpace == "hsl"
|
|
9469
|
+
if (colorSpace == "hsl") {
|
|
9479
9470
|
// @ts-ignore
|
|
9480
9471
|
if (values[2] < 0) {
|
|
9481
9472
|
// @ts-ignore
|
|
@@ -9505,7 +9496,7 @@ function colorMix(...args) {
|
|
|
9505
9496
|
}),
|
|
9506
9497
|
kin: exports.ColorType[colorSpace.toUpperCase().replaceAll("-", "_")],
|
|
9507
9498
|
};
|
|
9508
|
-
if (colorSpace == "hsl"
|
|
9499
|
+
if (colorSpace == "hsl") {
|
|
9509
9500
|
// @ts-ignore
|
|
9510
9501
|
result.chi[0] = { typ: exports.EnumToken.AngleTokenType, val: result.chi[0].val * 360 };
|
|
9511
9502
|
// @ts-ignore
|
|
@@ -10100,6 +10091,7 @@ function evaluate(tokens) {
|
|
|
10100
10091
|
[LOCSRCID]: nodes[0][LOCSRCID],
|
|
10101
10092
|
[LOCSTA]: nodes[0][LOCSTA],
|
|
10102
10093
|
[LOCEND]: nodes[0][LOCEND],
|
|
10094
|
+
[PARENT]: nodes[0][PARENT],
|
|
10103
10095
|
},
|
|
10104
10096
|
];
|
|
10105
10097
|
}
|
|
@@ -10122,6 +10114,7 @@ function evaluate(tokens) {
|
|
|
10122
10114
|
[LOCSRCID]: nodes[i][LOCSRCID],
|
|
10123
10115
|
[LOCSTA]: nodes[i][LOCSTA],
|
|
10124
10116
|
[LOCEND]: nodes[i + 1][LOCEND],
|
|
10117
|
+
[PARENT]: nodes[i + 1][PARENT],
|
|
10125
10118
|
};
|
|
10126
10119
|
}
|
|
10127
10120
|
else {
|
|
@@ -10131,6 +10124,7 @@ function evaluate(tokens) {
|
|
|
10131
10124
|
[LOCSRCID]: nodes[i + 1][LOCSRCID],
|
|
10132
10125
|
[LOCSTA]: nodes[i + 1][LOCSTA],
|
|
10133
10126
|
[LOCEND]: nodes[i + 1][LOCEND],
|
|
10127
|
+
[PARENT]: nodes[i + 1][PARENT],
|
|
10134
10128
|
}, exports.EnumToken.Mul);
|
|
10135
10129
|
}
|
|
10136
10130
|
i++;
|
|
@@ -10151,12 +10145,14 @@ function evaluate(tokens) {
|
|
|
10151
10145
|
[LOCSRCID]: token[LOCSRCID],
|
|
10152
10146
|
[LOCSTA]: token[LOCSTA],
|
|
10153
10147
|
[LOCEND]: token[LOCEND],
|
|
10148
|
+
[PARENT]: token[PARENT],
|
|
10154
10149
|
}, {
|
|
10155
10150
|
...token,
|
|
10156
10151
|
val: -token.val,
|
|
10157
10152
|
[LOCSRCID]: token[LOCSRCID],
|
|
10158
10153
|
[LOCSTA]: token[LOCSTA],
|
|
10159
10154
|
[LOCEND]: token[LOCEND],
|
|
10155
|
+
[PARENT]: token[PARENT],
|
|
10160
10156
|
});
|
|
10161
10157
|
return acc;
|
|
10162
10158
|
}
|
|
@@ -10167,6 +10163,7 @@ function evaluate(tokens) {
|
|
|
10167
10163
|
[LOCSRCID]: token[LOCSRCID],
|
|
10168
10164
|
[LOCSTA]: token[LOCSTA],
|
|
10169
10165
|
[LOCEND]: token[LOCEND],
|
|
10166
|
+
[PARENT]: token[PARENT],
|
|
10170
10167
|
});
|
|
10171
10168
|
}
|
|
10172
10169
|
acc.push(token);
|
|
@@ -10188,6 +10185,7 @@ function doEvaluate(l, r, op) {
|
|
|
10188
10185
|
[LOCSRCID]: l[LOCSRCID],
|
|
10189
10186
|
[LOCSTA]: l[LOCSTA],
|
|
10190
10187
|
[LOCEND]: r?.[LOCEND] ?? l[LOCEND],
|
|
10188
|
+
[PARENT]: l[PARENT],
|
|
10191
10189
|
};
|
|
10192
10190
|
if (!isScalarToken(l) || !isScalarToken(r) || (l.typ == r.typ && "unit" in l && "unit" in r && l.unit != r.unit)) {
|
|
10193
10191
|
return defaultReturn;
|
|
@@ -10260,6 +10258,7 @@ function doEvaluate(l, r, op) {
|
|
|
10260
10258
|
[LOCSRCID]: l[LOCSRCID],
|
|
10261
10259
|
[LOCSTA]: l[LOCSTA],
|
|
10262
10260
|
[LOCEND]: l[LOCEND],
|
|
10261
|
+
[PARENT]: l[PARENT],
|
|
10263
10262
|
},
|
|
10264
10263
|
r: {
|
|
10265
10264
|
typ: exports.EnumToken.NumberTokenType,
|
|
@@ -10267,6 +10266,7 @@ function doEvaluate(l, r, op) {
|
|
|
10267
10266
|
[LOCSRCID]: r[LOCSRCID],
|
|
10268
10267
|
[LOCSTA]: r[LOCSTA],
|
|
10269
10268
|
[LOCEND]: r[LOCEND],
|
|
10269
|
+
[PARENT]: r[PARENT],
|
|
10270
10270
|
},
|
|
10271
10271
|
};
|
|
10272
10272
|
}
|
|
@@ -10279,6 +10279,7 @@ function doEvaluate(l, r, op) {
|
|
|
10279
10279
|
[LOCSRCID]: l[LOCSRCID],
|
|
10280
10280
|
[LOCSTA]: l[LOCSTA],
|
|
10281
10281
|
[LOCEND]: l[LOCEND],
|
|
10282
|
+
[PARENT]: l[PARENT],
|
|
10282
10283
|
},
|
|
10283
10284
|
r: {
|
|
10284
10285
|
typ: exports.EnumToken.NumberTokenType,
|
|
@@ -10286,6 +10287,7 @@ function doEvaluate(l, r, op) {
|
|
|
10286
10287
|
[LOCSRCID]: r[LOCSRCID],
|
|
10287
10288
|
[LOCSTA]: r[LOCSTA],
|
|
10288
10289
|
[LOCEND]: r[LOCEND],
|
|
10290
|
+
[PARENT]: r[PARENT],
|
|
10289
10291
|
},
|
|
10290
10292
|
};
|
|
10291
10293
|
}
|
|
@@ -10312,6 +10314,7 @@ function doEvaluate(l, r, op) {
|
|
|
10312
10314
|
[LOCSRCID]: l[LOCSRCID],
|
|
10313
10315
|
[LOCSTA]: l[LOCSTA],
|
|
10314
10316
|
[LOCEND]: r?.[LOCEND] ?? l[LOCEND],
|
|
10317
|
+
[PARENT]: l[PARENT],
|
|
10315
10318
|
};
|
|
10316
10319
|
if (token.typ == exports.EnumToken.IdenTokenType) {
|
|
10317
10320
|
// @ts-ignore
|
|
@@ -10492,6 +10495,7 @@ function evaluateFunc(token) {
|
|
|
10492
10495
|
[LOCSRCID]: value[0][LOCSRCID],
|
|
10493
10496
|
[LOCSTA]: value[0][LOCSTA],
|
|
10494
10497
|
[LOCEND]: value[0][LOCEND],
|
|
10498
|
+
[PARENT]: value[0][PARENT],
|
|
10495
10499
|
}
|
|
10496
10500
|
: {
|
|
10497
10501
|
typ: token.val == "sign" ? exports.EnumToken.NumberTokenType : value[0].typ,
|
|
@@ -10499,6 +10503,7 @@ function evaluateFunc(token) {
|
|
|
10499
10503
|
[LOCSRCID]: value[0][LOCSRCID],
|
|
10500
10504
|
[LOCSTA]: value[0][LOCSTA],
|
|
10501
10505
|
[LOCEND]: value[0][LOCEND],
|
|
10506
|
+
[PARENT]: value[0][PARENT],
|
|
10502
10507
|
},
|
|
10503
10508
|
];
|
|
10504
10509
|
}
|
|
@@ -10521,6 +10526,7 @@ function evaluateFunc(token) {
|
|
|
10521
10526
|
[LOCSRCID]: token[LOCSRCID],
|
|
10522
10527
|
[LOCSTA]: token[LOCSTA],
|
|
10523
10528
|
[LOCEND]: token[LOCEND],
|
|
10529
|
+
[PARENT]: token[PARENT],
|
|
10524
10530
|
},
|
|
10525
10531
|
];
|
|
10526
10532
|
}
|
|
@@ -10594,6 +10600,7 @@ function evaluateFunc(token) {
|
|
|
10594
10600
|
[LOCSRCID]: token[LOCSRCID],
|
|
10595
10601
|
[LOCSTA]: token[LOCSTA],
|
|
10596
10602
|
[LOCEND]: token[LOCEND],
|
|
10603
|
+
[PARENT]: token[PARENT],
|
|
10597
10604
|
},
|
|
10598
10605
|
];
|
|
10599
10606
|
}
|
|
@@ -10608,6 +10615,7 @@ function evaluateFunc(token) {
|
|
|
10608
10615
|
[LOCSRCID]: token[LOCSRCID],
|
|
10609
10616
|
[LOCSTA]: token[LOCSTA],
|
|
10610
10617
|
[LOCEND]: token[LOCEND],
|
|
10618
|
+
[PARENT]: token[PARENT],
|
|
10611
10619
|
},
|
|
10612
10620
|
];
|
|
10613
10621
|
}
|
|
@@ -10618,6 +10626,7 @@ function evaluateFunc(token) {
|
|
|
10618
10626
|
[LOCSRCID]: token[LOCSRCID],
|
|
10619
10627
|
[LOCSTA]: token[LOCSTA],
|
|
10620
10628
|
[LOCEND]: token[LOCEND],
|
|
10629
|
+
[PARENT]: token[PARENT],
|
|
10621
10630
|
},
|
|
10622
10631
|
];
|
|
10623
10632
|
}
|
|
@@ -10657,6 +10666,7 @@ function evaluateFunc(token) {
|
|
|
10657
10666
|
[LOCSRCID]: token[LOCSRCID],
|
|
10658
10667
|
[LOCSTA]: token[LOCSTA],
|
|
10659
10668
|
[LOCEND]: token[LOCEND],
|
|
10669
|
+
[PARENT]: token[PARENT],
|
|
10660
10670
|
},
|
|
10661
10671
|
];
|
|
10662
10672
|
}
|
|
@@ -10699,6 +10709,7 @@ function evaluateFunc(token) {
|
|
|
10699
10709
|
[LOCSRCID]: token[LOCSRCID],
|
|
10700
10710
|
[LOCSTA]: token[LOCSTA],
|
|
10701
10711
|
[LOCEND]: token[LOCEND],
|
|
10712
|
+
[PARENT]: token[PARENT],
|
|
10702
10713
|
},
|
|
10703
10714
|
];
|
|
10704
10715
|
}
|
|
@@ -10726,6 +10737,7 @@ function inlineExpression$1(token) {
|
|
|
10726
10737
|
[LOCSRCID]: token[LOCSRCID],
|
|
10727
10738
|
[LOCSTA]: token[LOCSTA],
|
|
10728
10739
|
[LOCEND]: token[LOCEND],
|
|
10740
|
+
[PARENT]: token[PARENT],
|
|
10729
10741
|
});
|
|
10730
10742
|
for (const child of inlineExpression$1(token.r)) {
|
|
10731
10743
|
result.push(child);
|
|
@@ -10805,6 +10817,7 @@ function factorToken(token) {
|
|
|
10805
10817
|
[LOCSRCID]: token[LOCSRCID],
|
|
10806
10818
|
[LOCSTA]: token[LOCSTA],
|
|
10807
10819
|
[LOCEND]: token[LOCEND],
|
|
10820
|
+
[PARENT]: token[PARENT],
|
|
10808
10821
|
};
|
|
10809
10822
|
// @ts-ignore
|
|
10810
10823
|
delete token.val;
|
|
@@ -10846,6 +10859,7 @@ function factor(tokens, ops) {
|
|
|
10846
10859
|
[LOCSRCID]: tokens[i - 1][LOCSRCID],
|
|
10847
10860
|
[LOCSTA]: tokens[i - 1][LOCSTA],
|
|
10848
10861
|
[LOCEND]: tokens[i + 1][LOCEND],
|
|
10862
|
+
[PARENT]: tokens[i + 1][PARENT],
|
|
10849
10863
|
});
|
|
10850
10864
|
i--;
|
|
10851
10865
|
}
|
|
@@ -10891,20 +10905,20 @@ function parseRelativeColorComponents(relativeKeys, original, rExp, gExp, bExp,
|
|
|
10891
10905
|
continue;
|
|
10892
10906
|
}
|
|
10893
10907
|
if (component.typ == exports.EnumToken.IdenTokenType) {
|
|
10894
|
-
val = component.val
|
|
10908
|
+
val = component.val;
|
|
10895
10909
|
if (
|
|
10896
10910
|
// @ts-expect-error
|
|
10897
10911
|
typeof Math[val.toUpperCase()] !== "number" &&
|
|
10898
|
-
val
|
|
10899
|
-
val
|
|
10900
|
-
val
|
|
10901
|
-
val
|
|
10902
|
-
val
|
|
10903
|
-
val
|
|
10904
|
-
val
|
|
10905
|
-
val
|
|
10906
|
-
val
|
|
10907
|
-
!colorsFunc.
|
|
10912
|
+
!equalsIgnoreCase(val, "in") &&
|
|
10913
|
+
!equalsIgnoreCase(val, "hue") &&
|
|
10914
|
+
!equalsIgnoreCase(val, "from") &&
|
|
10915
|
+
!equalsIgnoreCase(val, "alpha") &&
|
|
10916
|
+
!equalsIgnoreCase(val, "none") &&
|
|
10917
|
+
!equalsIgnoreCase(val, "shorter") &&
|
|
10918
|
+
!equalsIgnoreCase(val, "longer") &&
|
|
10919
|
+
!equalsIgnoreCase(val, "increasing") &&
|
|
10920
|
+
!equalsIgnoreCase(val, "decreasing") &&
|
|
10921
|
+
!colorsFunc.some((t) => equalsIgnoreCase(t, val)) &&
|
|
10908
10922
|
!colorFuncColorSpace.includes(val) &&
|
|
10909
10923
|
!validKeys.includes(val)) {
|
|
10910
10924
|
return null;
|
|
@@ -12808,7 +12822,8 @@ function matchAllSyntaxes(syntaxes, context, options) {
|
|
|
12808
12822
|
for (let i = index; i < syntaxes.length; i++) {
|
|
12809
12823
|
if (syntaxes[i].typ == ValidationTokenEnum.Whitespace ||
|
|
12810
12824
|
syntaxes[i].isOptional ||
|
|
12811
|
-
syntaxes[i].isRepeatable
|
|
12825
|
+
syntaxes[i].isRepeatable ||
|
|
12826
|
+
syntaxes[i].match?.min?.val === 0) {
|
|
12812
12827
|
continue;
|
|
12813
12828
|
}
|
|
12814
12829
|
return {
|
|
@@ -14513,7 +14528,6 @@ function alpha(color, alpha) {
|
|
|
14513
14528
|
}
|
|
14514
14529
|
let components = getColorComponents(color);
|
|
14515
14530
|
if (alpha.typ === exports.EnumToken.MathFunctionTokenType) {
|
|
14516
|
-
const originalAlpha = cloneNode(alpha, true);
|
|
14517
14531
|
for (const { value } of walkValues(alpha.chi, alpha)) {
|
|
14518
14532
|
if (value.typ === exports.EnumToken.IdenTokenType) {
|
|
14519
14533
|
if (equalsIgnoreCase(value.val, "alpha")) {
|
|
@@ -14525,22 +14539,22 @@ function alpha(color, alpha) {
|
|
|
14525
14539
|
});
|
|
14526
14540
|
// continue;
|
|
14527
14541
|
}
|
|
14528
|
-
else if (equalsIgnoreCase(value.val, "none")) {
|
|
14529
|
-
|
|
14530
|
-
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
}
|
|
14542
|
+
// else if (equalsIgnoreCase((value as IdentToken).val, "none")) {
|
|
14543
|
+
// Object.assign(value, {
|
|
14544
|
+
// typ: EnumToken.NumberTokenType,
|
|
14545
|
+
// val: 0,
|
|
14546
|
+
// });
|
|
14547
|
+
// }
|
|
14534
14548
|
}
|
|
14535
14549
|
}
|
|
14536
14550
|
const result = evaluate([alpha]);
|
|
14537
14551
|
if (result.length == 1) {
|
|
14538
14552
|
alpha = result[0];
|
|
14539
14553
|
}
|
|
14540
|
-
else {
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
}
|
|
14554
|
+
// else {
|
|
14555
|
+
// // @ts-expect-error
|
|
14556
|
+
// alpha = originalAlpha;
|
|
14557
|
+
// }
|
|
14544
14558
|
}
|
|
14545
14559
|
// console.error({ alpha });
|
|
14546
14560
|
if (alpha.typ !== exports.EnumToken.IdenTokenType &&
|
|
@@ -14566,17 +14580,17 @@ function alpha(color, alpha) {
|
|
|
14566
14580
|
return null;
|
|
14567
14581
|
}
|
|
14568
14582
|
if (alpha?.typ === exports.EnumToken.IdenTokenType) {
|
|
14569
|
-
if (equalsIgnoreCase(alpha.val, "alpha")) {
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
14574
|
-
}
|
|
14575
|
-
|
|
14576
|
-
alpha
|
|
14583
|
+
// if (equalsIgnoreCase((alpha as IdentToken).val, "alpha")) {
|
|
14584
|
+
// alpha = components[3] ?? {
|
|
14585
|
+
// typ: EnumToken.NumberTokenType,
|
|
14586
|
+
// val: 1,
|
|
14587
|
+
// };
|
|
14588
|
+
// } else
|
|
14589
|
+
if (equalsIgnoreCase(alpha.val, "none")) {
|
|
14590
|
+
Object.assign(alpha, {
|
|
14577
14591
|
typ: exports.EnumToken.NumberTokenType,
|
|
14578
14592
|
val: 0,
|
|
14579
|
-
};
|
|
14593
|
+
});
|
|
14580
14594
|
}
|
|
14581
14595
|
}
|
|
14582
14596
|
return makeColor(color.kin, components, alpha);
|
|
@@ -15297,12 +15311,12 @@ function getColorSpace(color) {
|
|
|
15297
15311
|
// '\\'
|
|
15298
15312
|
const REVERSE_SOLIDUS = 0x5c;
|
|
15299
15313
|
const flexUnits = ["fr"];
|
|
15300
|
-
const frequencyUnits = ["
|
|
15314
|
+
const frequencyUnits = ["Hz", "kHz"];
|
|
15301
15315
|
const timeUnits = ["ms", "s"];
|
|
15302
15316
|
const angleUnits = ["rad", "turn", "deg", "grad"];
|
|
15303
15317
|
const resolutionUnits = ["dpi", "dpcm", "dppx", "x"];
|
|
15304
15318
|
const dimensionUnits = [
|
|
15305
|
-
"
|
|
15319
|
+
"Q",
|
|
15306
15320
|
"cap",
|
|
15307
15321
|
"ch",
|
|
15308
15322
|
"cm",
|
|
@@ -16986,7 +17000,7 @@ function replaceAstNodes(tokens, root) {
|
|
|
16986
17000
|
}
|
|
16987
17001
|
class ComputePrefixFeature {
|
|
16988
17002
|
get ordering() {
|
|
16989
|
-
return
|
|
17003
|
+
return 0;
|
|
16990
17004
|
}
|
|
16991
17005
|
get processMode() {
|
|
16992
17006
|
return exports.FeatureWalkMode.Pre;
|
|
@@ -17430,10 +17444,10 @@ function replace(node, variableScope) {
|
|
|
17430
17444
|
class InlineCssVariablesFeature {
|
|
17431
17445
|
accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
|
|
17432
17446
|
get ordering() {
|
|
17433
|
-
return
|
|
17447
|
+
return 2;
|
|
17434
17448
|
}
|
|
17435
17449
|
get processMode() {
|
|
17436
|
-
return exports.FeatureWalkMode.
|
|
17450
|
+
return exports.FeatureWalkMode.Post;
|
|
17437
17451
|
}
|
|
17438
17452
|
static register(options) {
|
|
17439
17453
|
if (options.inlineCssVariables) {
|
|
@@ -19683,8 +19697,8 @@ function matchType(val, properties) {
|
|
|
19683
19697
|
|
|
19684
19698
|
const propertiesConfig = getConfig();
|
|
19685
19699
|
class PropertyMap {
|
|
19686
|
-
config;
|
|
19687
19700
|
declarations;
|
|
19701
|
+
config;
|
|
19688
19702
|
requiredCount;
|
|
19689
19703
|
pattern;
|
|
19690
19704
|
constructor(config) {
|
|
@@ -19698,7 +19712,7 @@ class PropertyMap {
|
|
|
19698
19712
|
}
|
|
19699
19713
|
add(declaration) {
|
|
19700
19714
|
if (declaration.nam == this.config.shorthand) {
|
|
19701
|
-
this.declarations
|
|
19715
|
+
this.declarations.clear();
|
|
19702
19716
|
this.declarations.set(declaration.nam, declaration);
|
|
19703
19717
|
this.matchTypes(declaration);
|
|
19704
19718
|
}
|
|
@@ -19714,23 +19728,17 @@ class PropertyMap {
|
|
|
19714
19728
|
if (this.declarations.has(this.config.shorthand)) {
|
|
19715
19729
|
const tokens = {};
|
|
19716
19730
|
const values = [];
|
|
19717
|
-
|
|
19718
|
-
this.declarations
|
|
19719
|
-
.get(this.config.shorthand)
|
|
19720
|
-
// @ts-ignore
|
|
19721
|
-
.val.slice()
|
|
19722
|
-
.reduce((acc, curr) => {
|
|
19731
|
+
const val = [[]];
|
|
19732
|
+
for (const curr of this.declarations.get(this.config.shorthand).val) { // @ts-ignore
|
|
19723
19733
|
// @ts-ignore
|
|
19724
19734
|
if (separator != null && separator.typ == curr.typ && separator.val == curr.val) {
|
|
19725
|
-
|
|
19726
|
-
|
|
19735
|
+
val.push([]);
|
|
19736
|
+
continue;
|
|
19727
19737
|
}
|
|
19728
19738
|
// @ts-ignore
|
|
19729
|
-
|
|
19730
|
-
|
|
19731
|
-
|
|
19732
|
-
// @ts-ignore
|
|
19733
|
-
.reduce((acc, list, current) => {
|
|
19739
|
+
val.at(-1).push(curr);
|
|
19740
|
+
}
|
|
19741
|
+
for (let current = 0; current < val.length; current++) {
|
|
19734
19742
|
values.push(...this.pattern.reduce((acc, property) => {
|
|
19735
19743
|
// let current: number = 0;
|
|
19736
19744
|
const props = this.config.properties[property];
|
|
@@ -19745,9 +19753,7 @@ class PropertyMap {
|
|
|
19745
19753
|
// @ts-ignore
|
|
19746
19754
|
acc[i][PROPERTYNAME] == property ||
|
|
19747
19755
|
matchType(acc[i], props)) {
|
|
19748
|
-
if ("prefix" in props &&
|
|
19749
|
-
props.previous != null &&
|
|
19750
|
-
!(props.previous in tokens)) {
|
|
19756
|
+
if ("prefix" in props && props.previous != null && !(props.previous in tokens)) {
|
|
19751
19757
|
return acc;
|
|
19752
19758
|
}
|
|
19753
19759
|
if (!(property in tokens)) {
|
|
@@ -19812,9 +19818,8 @@ class PropertyMap {
|
|
|
19812
19818
|
}
|
|
19813
19819
|
}
|
|
19814
19820
|
return acc;
|
|
19815
|
-
},
|
|
19816
|
-
|
|
19817
|
-
}, []);
|
|
19821
|
+
}, val[current]));
|
|
19822
|
+
}
|
|
19818
19823
|
if (values.length == 0) {
|
|
19819
19824
|
this.declarations = Object.entries(tokens).reduce((acc, curr) => {
|
|
19820
19825
|
acc.set(curr[0], {
|
|
@@ -19874,17 +19879,40 @@ class PropertyMap {
|
|
|
19874
19879
|
}
|
|
19875
19880
|
if (hasMapping) {
|
|
19876
19881
|
const mapped = {};
|
|
19877
|
-
|
|
19878
|
-
|
|
19882
|
+
let key;
|
|
19883
|
+
for (const value of declarations.values()) {
|
|
19884
|
+
key = value.nam;
|
|
19879
19885
|
if (value instanceof PropertyMap) {
|
|
19880
19886
|
for (const [k, v] of value.declarations) {
|
|
19881
|
-
|
|
19887
|
+
if (k == value.config.shorthand) {
|
|
19888
|
+
for (const [key, val] of Object.entries(value.config.properties)) {
|
|
19889
|
+
mapped[key] = cloneNode(v);
|
|
19890
|
+
for (let i = 0; i < v.val.length; i++) {
|
|
19891
|
+
// @ts-ignore
|
|
19892
|
+
if (key == v.val[i][PROPERTYNAME]) {
|
|
19893
|
+
if (mapped[key].val.length > 0) {
|
|
19894
|
+
mapped[key].val.push({
|
|
19895
|
+
typ: exports.EnumToken.WhitespaceTokenType,
|
|
19896
|
+
});
|
|
19897
|
+
}
|
|
19898
|
+
mapped[key].val.push(v.val[i]);
|
|
19899
|
+
}
|
|
19900
|
+
}
|
|
19901
|
+
if (mapped[key].val.length == 0) {
|
|
19902
|
+
mapped[key].val.push(...parseString(value.config.properties[key].default[0]));
|
|
19903
|
+
}
|
|
19904
|
+
}
|
|
19905
|
+
}
|
|
19906
|
+
else {
|
|
19907
|
+
mapped[k] = v;
|
|
19908
|
+
}
|
|
19882
19909
|
}
|
|
19883
19910
|
}
|
|
19884
19911
|
else {
|
|
19885
19912
|
mapped[key] = value;
|
|
19886
19913
|
}
|
|
19887
19914
|
}
|
|
19915
|
+
// console.error(mapped);
|
|
19888
19916
|
if (patterns.length === Object.keys(mapped).length) {
|
|
19889
19917
|
declarations = new Map();
|
|
19890
19918
|
for (const key of patterns) {
|
|
@@ -20340,8 +20368,6 @@ class PropertyMap {
|
|
|
20340
20368
|
}
|
|
20341
20369
|
return acc;
|
|
20342
20370
|
}, []);
|
|
20343
|
-
// console.error({hasMapping, shorthand: this.config.shorthand, requiredCount, isShorthand,
|
|
20344
|
-
// declarations: declarations.values(), values});
|
|
20345
20371
|
if (this.config.mapping != null) {
|
|
20346
20372
|
const val = values.reduce((acc, curr) => acc +
|
|
20347
20373
|
renderValue(curr, {
|
|
@@ -20378,6 +20404,7 @@ class PropertyMap {
|
|
|
20378
20404
|
}
|
|
20379
20405
|
}
|
|
20380
20406
|
const iterators = [];
|
|
20407
|
+
// @ts-ignore
|
|
20381
20408
|
return {
|
|
20382
20409
|
// @ts-ignore
|
|
20383
20410
|
next() {
|
|
@@ -20630,6 +20657,9 @@ function syncHash(input, length = 6, algo) {
|
|
|
20630
20657
|
}
|
|
20631
20658
|
|
|
20632
20659
|
const config = getConfig();
|
|
20660
|
+
/**
|
|
20661
|
+
* Represents a list of property declarations, compute shorthand and remove duplicate declarations.
|
|
20662
|
+
*/
|
|
20633
20663
|
class PropertyList {
|
|
20634
20664
|
options = { removeDuplicateDeclarations: true, computeShorthand: true };
|
|
20635
20665
|
declarations;
|
|
@@ -20704,28 +20734,35 @@ class PropertyList {
|
|
|
20704
20734
|
// @ts-ignore
|
|
20705
20735
|
shorthand = config.property[propertyName];
|
|
20706
20736
|
}
|
|
20707
|
-
// console.error({shortHandType, propertyName, config: config.map[propertyName], map: config.map[shorthand].properties[propertyName]});
|
|
20708
20737
|
// @ts-ignore
|
|
20709
20738
|
if (shortHandType == "map") {
|
|
20710
20739
|
let owner = this;
|
|
20740
|
+
const mapName =
|
|
20711
20741
|
// @ts-ignore
|
|
20712
|
-
|
|
20742
|
+
config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
|
|
20713
20743
|
if (typeof mapName === "string") {
|
|
20714
20744
|
if (!this.declarations.has(mapName)) {
|
|
20715
20745
|
// @ts-ignore
|
|
20716
20746
|
this.declarations.set(mapName, new PropertyMap(config.map[mapName]));
|
|
20717
20747
|
}
|
|
20718
20748
|
owner = this.declarations.get(mapName);
|
|
20719
|
-
// console.error({mapName});
|
|
20720
20749
|
}
|
|
20721
|
-
|
|
20722
|
-
if (!owner.declarations.has(shorthand)) {
|
|
20750
|
+
else if (!this.declarations.has(shorthand)) {
|
|
20723
20751
|
// @ts-ignore
|
|
20724
|
-
|
|
20752
|
+
this.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
|
|
20753
|
+
}
|
|
20754
|
+
if (owner == this) {
|
|
20755
|
+
// @ts-ignore
|
|
20756
|
+
owner.declarations.get(shorthand).add(declaration);
|
|
20757
|
+
}
|
|
20758
|
+
else {
|
|
20759
|
+
if (!owner.declarations.has(shorthand)) {
|
|
20760
|
+
// @ts-ignore
|
|
20761
|
+
owner.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
|
|
20762
|
+
}
|
|
20763
|
+
// @ts-ignore
|
|
20764
|
+
owner.declarations.get(shorthand).add(declaration);
|
|
20725
20765
|
}
|
|
20726
|
-
// console.error({propertyName,mapName, owned: owner == this});
|
|
20727
|
-
// @ts-ignore
|
|
20728
|
-
owner.declarations.get(shorthand).add(declaration);
|
|
20729
20766
|
}
|
|
20730
20767
|
// @ts-ignore
|
|
20731
20768
|
else if (shortHandType == "set") {
|
|
@@ -20812,7 +20849,7 @@ class PropertyList {
|
|
|
20812
20849
|
[Symbol.iterator]() {
|
|
20813
20850
|
let iterator = this.declarations.values();
|
|
20814
20851
|
const iterators = [];
|
|
20815
|
-
//
|
|
20852
|
+
// @ts-ignore
|
|
20816
20853
|
return {
|
|
20817
20854
|
next() {
|
|
20818
20855
|
let value = iterator.next();
|
|
@@ -20843,7 +20880,7 @@ class ComputeShorthandFeature {
|
|
|
20843
20880
|
exports.EnumToken.KeyframesRuleNodeType,
|
|
20844
20881
|
]);
|
|
20845
20882
|
get ordering() {
|
|
20846
|
-
return
|
|
20883
|
+
return 5;
|
|
20847
20884
|
}
|
|
20848
20885
|
get processMode() {
|
|
20849
20886
|
return exports.FeatureWalkMode.Post;
|
|
@@ -20862,7 +20899,6 @@ class ComputeShorthandFeature {
|
|
|
20862
20899
|
const j = ast.chi.length;
|
|
20863
20900
|
let k = 0;
|
|
20864
20901
|
let l;
|
|
20865
|
-
// let properties: PropertyList = new PropertyList(options);
|
|
20866
20902
|
const rules = [];
|
|
20867
20903
|
const declarations = [];
|
|
20868
20904
|
// @ts-ignore
|
|
@@ -20883,7 +20919,6 @@ class ComputeShorthandFeature {
|
|
|
20883
20919
|
if (node.typ == exports.EnumToken.DeclarationNodeType) {
|
|
20884
20920
|
for (let m = k; m <= l; m++) {
|
|
20885
20921
|
declarations.push(ast.chi[m]);
|
|
20886
|
-
// properties.add(ast.chi![m]);
|
|
20887
20922
|
}
|
|
20888
20923
|
}
|
|
20889
20924
|
else {
|
|
@@ -20893,7 +20928,6 @@ class ComputeShorthandFeature {
|
|
|
20893
20928
|
}
|
|
20894
20929
|
k = l;
|
|
20895
20930
|
}
|
|
20896
|
-
// console.error([...new PropertyList(options).add(declarations)]);
|
|
20897
20931
|
if (declarations.length > 0) {
|
|
20898
20932
|
ast.chi.length = 0;
|
|
20899
20933
|
// @ts-expect-error
|
|
@@ -21004,7 +21038,7 @@ function trimWhiteSpaceTokens(tokens) {
|
|
|
21004
21038
|
class ComputeCalcExpressionFeature {
|
|
21005
21039
|
accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
|
|
21006
21040
|
get ordering() {
|
|
21007
|
-
return
|
|
21041
|
+
return 3;
|
|
21008
21042
|
}
|
|
21009
21043
|
get processMode() {
|
|
21010
21044
|
return exports.FeatureWalkMode.Post;
|
|
@@ -21029,8 +21063,20 @@ class ComputeCalcExpressionFeature {
|
|
|
21029
21063
|
continue;
|
|
21030
21064
|
}
|
|
21031
21065
|
if (value.typ == exports.EnumToken.BinaryExpressionTokenType) {
|
|
21032
|
-
|
|
21033
|
-
|
|
21066
|
+
const result = evaluate([value]);
|
|
21067
|
+
try {
|
|
21068
|
+
// @ts-ignore
|
|
21069
|
+
replaceNodeOrValue(parent, value, result);
|
|
21070
|
+
}
|
|
21071
|
+
catch (e) {
|
|
21072
|
+
// @ts-ignore
|
|
21073
|
+
if (Array.isArray(parent.chi)) {
|
|
21074
|
+
// @ts-ignore
|
|
21075
|
+
parent.chi.length = 0;
|
|
21076
|
+
// @ts-ignore
|
|
21077
|
+
parent.chi.push(...result);
|
|
21078
|
+
}
|
|
21079
|
+
}
|
|
21034
21080
|
continue;
|
|
21035
21081
|
}
|
|
21036
21082
|
if (value != null && tokensfuncSet.has(value.typ)) {
|
|
@@ -21048,7 +21094,7 @@ class ComputeCalcExpressionFeature {
|
|
|
21048
21094
|
? value.val
|
|
21049
21095
|
: value.chi;
|
|
21050
21096
|
const values = evaluate(cp);
|
|
21051
|
-
// fix a + -b
|
|
21097
|
+
// fix a + -b into a - b
|
|
21052
21098
|
for (const { value, parent: p } of walkValues(values)) {
|
|
21053
21099
|
if (value.typ === exports.EnumToken.BinaryExpressionTokenType) {
|
|
21054
21100
|
if (value.op === exports.EnumToken.Add &&
|
|
@@ -22314,7 +22360,7 @@ class TransformCssFeature {
|
|
|
22314
22360
|
exports.EnumToken.KeyframesRuleNodeType,
|
|
22315
22361
|
]);
|
|
22316
22362
|
get ordering() {
|
|
22317
|
-
return
|
|
22363
|
+
return 4;
|
|
22318
22364
|
}
|
|
22319
22365
|
get processMode() {
|
|
22320
22366
|
return exports.FeatureWalkMode.Post;
|
|
@@ -22717,7 +22763,7 @@ function processNode(declarationNode, cache) {
|
|
|
22717
22763
|
class ExpandIfFeature {
|
|
22718
22764
|
accept = new Set([exports.EnumToken.DeclarationNodeType]);
|
|
22719
22765
|
get ordering() {
|
|
22720
|
-
return
|
|
22766
|
+
return 1;
|
|
22721
22767
|
}
|
|
22722
22768
|
get processMode() {
|
|
22723
22769
|
return exports.FeatureWalkMode.Pre;
|
|
@@ -23519,7 +23565,8 @@ function doMinify(ast, options = {}, recursive = false, errors, nestingContent,
|
|
|
23519
23565
|
previous = node;
|
|
23520
23566
|
nodeIndex = i;
|
|
23521
23567
|
}
|
|
23522
|
-
|
|
23568
|
+
// @ts-ignore
|
|
23569
|
+
if (recursive && node != null && node.chi != null) {
|
|
23523
23570
|
if (node.typ == exports.EnumToken.KeyframesAtRuleNodeType ||
|
|
23524
23571
|
!node.chi.some((n) => n.typ == exports.EnumToken.DeclarationNodeType)) {
|
|
23525
23572
|
if (!(node.typ == exports.EnumToken.AtRuleNodeType && node.nam != "font-face")) {
|
|
@@ -25352,6 +25399,7 @@ function doRender(data, options = {}, mapping) {
|
|
|
25352
25399
|
removeEmpty: false,
|
|
25353
25400
|
removeComments: false,
|
|
25354
25401
|
}),
|
|
25402
|
+
minifyValues: true,
|
|
25355
25403
|
sourcemap: false,
|
|
25356
25404
|
convertColor: true,
|
|
25357
25405
|
expandNestingRules: false,
|
|
@@ -25591,7 +25639,7 @@ function renderAstNode(data, options, sourcemaps, sourceLocation, linesMap, erro
|
|
|
25591
25639
|
const indentSub = indents[level + 1];
|
|
25592
25640
|
switch (data.typ) {
|
|
25593
25641
|
case exports.EnumToken.DeclarationNodeType:
|
|
25594
|
-
return `${data.nam}:${options.indent}${(options.
|
|
25642
|
+
return `${data.nam}:${options.indent}${(options.minifyValues
|
|
25595
25643
|
? filterValues(data.val)
|
|
25596
25644
|
: data.val).reduce(reducer, "")}`;
|
|
25597
25645
|
case exports.EnumToken.CommentNodeType:
|
|
@@ -25646,7 +25694,7 @@ function renderAstNode(data, options, sourcemaps, sourceLocation, linesMap, erro
|
|
|
25646
25694
|
: node.val;
|
|
25647
25695
|
}
|
|
25648
25696
|
else if (node.typ == exports.EnumToken.DeclarationNodeType) {
|
|
25649
|
-
str = `${node.nam}:${options.indent}${(options.
|
|
25697
|
+
str = `${node.nam}:${options.indent}${(options.minifyValues
|
|
25650
25698
|
? filterValues(node.val)
|
|
25651
25699
|
: node.val)
|
|
25652
25700
|
.reduce(reducer, "")
|
|
@@ -25714,9 +25762,10 @@ function renderAstNode(data, options, sourcemaps, sourceLocation, linesMap, erro
|
|
|
25714
25762
|
function renderValue(token, options = {}, cache = Object.create(null), reducer, errors) {
|
|
25715
25763
|
if (token.typ === exports.EnumToken.WhenElseFunctionTokenType &&
|
|
25716
25764
|
equalsIgnoreCase(token.val, "supports")) {
|
|
25717
|
-
options = { ...options, minify: false, convertColor: false };
|
|
25765
|
+
options = { ...options, minifyValues: false, minify: false, convertColor: false };
|
|
25718
25766
|
reducer = null;
|
|
25719
25767
|
}
|
|
25768
|
+
options.minifyValues ??= options.minify;
|
|
25720
25769
|
if (reducer == null) {
|
|
25721
25770
|
reducer = function (acc, curr) {
|
|
25722
25771
|
if (curr.typ == exports.EnumToken.CommentTokenType && options.removeComments) {
|
|
@@ -25873,7 +25922,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
|
|
|
25873
25922
|
")");
|
|
25874
25923
|
}
|
|
25875
25924
|
case exports.EnumToken.UrlFunctionTokenType:
|
|
25876
|
-
if (options.
|
|
25925
|
+
if (options.minifyValues && token.typ === exports.EnumToken.UrlFunctionTokenType) {
|
|
25877
25926
|
if (token.chi[0]?.typ === exports.EnumToken.BadUrlTokenType) {
|
|
25878
25927
|
return "url()";
|
|
25879
25928
|
}
|
|
@@ -25894,7 +25943,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
|
|
|
25894
25943
|
case exports.EnumToken.FunctionTokenType:
|
|
25895
25944
|
case exports.EnumToken.MathFunctionTokenType:
|
|
25896
25945
|
case exports.EnumToken.ImageFunctionTokenType:
|
|
25897
|
-
if (options.
|
|
25946
|
+
if (options.minifyValues && token.typ === exports.EnumToken.ImageFunctionTokenType) {
|
|
25898
25947
|
const slice = token.chi.slice();
|
|
25899
25948
|
switch (token.val) {
|
|
25900
25949
|
case "linear-gradient":
|
|
@@ -26380,37 +26429,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
|
|
|
26380
26429
|
renderValue(curr, token.typ == exports.EnumToken.FunctionTokenType ? { minify: false } : options, cache, reducer), "") +
|
|
26381
26430
|
")");
|
|
26382
26431
|
}
|
|
26383
|
-
return (
|
|
26384
|
-
/* options.minify && 'Pseudo-class-func' == token.typ && token.val.slice(0, 2) == '::' ? token.val.slice(1) :*/ (token.val ?? "") +
|
|
26385
|
-
"(" +
|
|
26386
|
-
token.chi.reduce(reducer, "") +
|
|
26387
|
-
")");
|
|
26388
|
-
// case EnumToken.MatchExpressionTokenType:
|
|
26389
|
-
// return (
|
|
26390
|
-
// renderValue((token as MatchExpressionToken).l as Token, options, cache, reducer, errors) +
|
|
26391
|
-
// renderValue((token as MatchExpressionToken).op, options, cache, reducer, errors) +
|
|
26392
|
-
// renderValue((token as MatchExpressionToken).r, options, cache, reducer, errors) +
|
|
26393
|
-
// ((token as MatchExpressionToken).attr ? " " + (token as MatchExpressionToken).attr : "")
|
|
26394
|
-
// );
|
|
26395
|
-
// case EnumToken.NameSpaceAttributeTokenType:
|
|
26396
|
-
// return (
|
|
26397
|
-
// ((token as NameSpaceAttributeToken).l == null
|
|
26398
|
-
// ? ""
|
|
26399
|
-
// : renderValue((token as NameSpaceAttributeToken).l as Token, options, cache, reducer, errors)) +
|
|
26400
|
-
// "|" +
|
|
26401
|
-
// renderValue((token as NameSpaceAttributeToken).r, options, cache, reducer, errors)
|
|
26402
|
-
// );
|
|
26403
|
-
// case EnumToken.ComposesSelectorNodeType:
|
|
26404
|
-
// return (
|
|
26405
|
-
// (token as ComposesSelectorToken).l.reduce(
|
|
26406
|
-
// (acc: string, curr: Token) => acc + renderValue(curr, options, cache),
|
|
26407
|
-
// "",
|
|
26408
|
-
// ) +
|
|
26409
|
-
// ((token as ComposesSelectorToken).r == null
|
|
26410
|
-
// ? ""
|
|
26411
|
-
// : " from " +
|
|
26412
|
-
// renderValue((token as ComposesSelectorToken).r as Token, options, cache, reducer, errors))
|
|
26413
|
-
// );
|
|
26432
|
+
return (token.val ?? "") + "(" + token.chi.reduce(reducer, "") + ")";
|
|
26414
26433
|
case exports.EnumToken.BlockStartTokenType:
|
|
26415
26434
|
return "{";
|
|
26416
26435
|
case exports.EnumToken.BlockEndTokenType:
|
|
@@ -26559,7 +26578,11 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
|
|
|
26559
26578
|
const perc = token.val.typ == exports.EnumToken.FractionTokenType
|
|
26560
26579
|
? renderValue(token.val, options, cache)
|
|
26561
26580
|
: minifyNumber(token.val);
|
|
26562
|
-
return options.
|
|
26581
|
+
return options.minifyValues && perc == "0"
|
|
26582
|
+
? "0"
|
|
26583
|
+
: perc.includes("/")
|
|
26584
|
+
? perc.replace("/", uni + "/")
|
|
26585
|
+
: perc + uni;
|
|
26563
26586
|
case exports.EnumToken.NumberTokenType:
|
|
26564
26587
|
return token.val.typ == exports.EnumToken.FractionTokenType
|
|
26565
26588
|
? renderValue(token.val, options, cache)
|
|
@@ -26624,7 +26647,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
|
|
|
26624
26647
|
case exports.EnumToken.DeclarationNodeType:
|
|
26625
26648
|
return (token.nam +
|
|
26626
26649
|
":" +
|
|
26627
|
-
(options.
|
|
26650
|
+
(options.minifyValues ? filterValues(token.val) : token.val).reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
|
|
26628
26651
|
case exports.EnumToken.MediaQueryUnaryFeatureTokenType:
|
|
26629
26652
|
return (renderValue(token.l, options, cache, reducer) +
|
|
26630
26653
|
" " +
|
|
@@ -26698,6 +26721,7 @@ function filterValues(values) {
|
|
|
26698
26721
|
}
|
|
26699
26722
|
|
|
26700
26723
|
const SymbolsMapTokens = Object.create(null);
|
|
26724
|
+
const SymbolsMapTokensLower = Object.create(null);
|
|
26701
26725
|
// Regex for escape sequence decoding - compile once, reuse many times
|
|
26702
26726
|
const ESCAPE_SEQUENCE_REGEX = /\\((\n|\r|\f|\v|\u2028|\u2029|([0-9a-fA-F]{1,6})) ?)/gms;
|
|
26703
26727
|
function decodeEscapeSequences(value) {
|
|
@@ -26726,7 +26750,9 @@ function decodeEscapeSequences(value) {
|
|
|
26726
26750
|
}
|
|
26727
26751
|
function assignTokenMap(entries, tokenType, suffix = "", lowercase = false) {
|
|
26728
26752
|
for (const entry of entries) {
|
|
26729
|
-
|
|
26753
|
+
const key = (lowercase ? entry.toLowerCase() : entry) + suffix;
|
|
26754
|
+
SymbolsMapTokens[key] = tokenType;
|
|
26755
|
+
SymbolsMapTokensLower[key.toLowerCase()] = tokenType;
|
|
26730
26756
|
}
|
|
26731
26757
|
}
|
|
26732
26758
|
SymbolsMapTokens[""] = exports.EnumToken.DelimTokenType;
|
|
@@ -26826,20 +26852,24 @@ var TokenMap;
|
|
|
26826
26852
|
})(TokenMap || (TokenMap = {}));
|
|
26827
26853
|
function getSymbolHint(parseInfo, start, end) {
|
|
26828
26854
|
const len = end - start;
|
|
26829
|
-
|
|
26830
|
-
// Early exit for impossible lengths
|
|
26831
|
-
if (len < 0)
|
|
26855
|
+
if (len <= 0)
|
|
26832
26856
|
return null;
|
|
26857
|
+
const value = parseInfo.stream.slice(start, end);
|
|
26858
|
+
// Direct lookup handles the hottest punctuation and keyword cases without
|
|
26859
|
+
// scanning the entire symbol table on every token.
|
|
26860
|
+
const match = SymbolsMapTokens[value] ?? SymbolsMapTokensLower[value.toLowerCase()];
|
|
26861
|
+
if (match != null) {
|
|
26862
|
+
return match;
|
|
26863
|
+
}
|
|
26864
|
+
const keysLength = SymbolsMapTokensKeys.length;
|
|
26833
26865
|
for (let i = 0; i < keysLength; i++) {
|
|
26834
26866
|
const key = SymbolsMapTokensKeys[i];
|
|
26835
26867
|
if (key.length !== len)
|
|
26836
26868
|
continue;
|
|
26837
|
-
// Match character by character
|
|
26838
26869
|
let match = true;
|
|
26839
26870
|
for (let j = 0; j < len; j++) {
|
|
26840
26871
|
let ca = key.charCodeAt(j);
|
|
26841
|
-
let cb =
|
|
26842
|
-
// Normalize A-Z to a-z
|
|
26872
|
+
let cb = value.charCodeAt(j);
|
|
26843
26873
|
if (ca >= 65 && ca <= 90)
|
|
26844
26874
|
ca += 32;
|
|
26845
26875
|
if (cb >= 65 && cb <= 90)
|
|
@@ -26857,32 +26887,29 @@ function getSymbolHint(parseInfo, start, end) {
|
|
|
26857
26887
|
}
|
|
26858
26888
|
function searchArray(array, parseInfo, start, end) {
|
|
26859
26889
|
const len = end - start;
|
|
26860
|
-
|
|
26861
|
-
if (len < 0)
|
|
26890
|
+
if (len <= 0)
|
|
26862
26891
|
return null;
|
|
26863
|
-
|
|
26864
|
-
let
|
|
26865
|
-
|
|
26866
|
-
|
|
26892
|
+
let match;
|
|
26893
|
+
let item;
|
|
26894
|
+
for (let i = 0; i < array.length; i++) {
|
|
26895
|
+
item = array[i];
|
|
26896
|
+
if (item.length !== len)
|
|
26867
26897
|
continue;
|
|
26868
|
-
|
|
26869
|
-
let match = true;
|
|
26870
|
-
const arrayItem = array[i];
|
|
26898
|
+
match = true;
|
|
26871
26899
|
for (let j = 0; j < len; j++) {
|
|
26872
|
-
let ca =
|
|
26873
|
-
let cb =
|
|
26874
|
-
// Normalize A-Z to a-z
|
|
26900
|
+
let ca = parseInfo.stream.charCodeAt(start + j);
|
|
26901
|
+
let cb = item.charCodeAt(j);
|
|
26875
26902
|
if (ca >= 65 && ca <= 90)
|
|
26876
26903
|
ca += 32;
|
|
26877
26904
|
if (cb >= 65 && cb <= 90)
|
|
26878
26905
|
cb += 32;
|
|
26879
|
-
if (ca
|
|
26906
|
+
if (ca !== cb) {
|
|
26880
26907
|
match = false;
|
|
26881
26908
|
break;
|
|
26882
26909
|
}
|
|
26883
26910
|
}
|
|
26884
26911
|
if (match) {
|
|
26885
|
-
return
|
|
26912
|
+
return item;
|
|
26886
26913
|
}
|
|
26887
26914
|
}
|
|
26888
26915
|
return null;
|
|
@@ -27820,23 +27847,6 @@ class Tokenizer {
|
|
|
27820
27847
|
}
|
|
27821
27848
|
return true;
|
|
27822
27849
|
}
|
|
27823
|
-
/**
|
|
27824
|
-
*
|
|
27825
|
-
* @param parseInfo
|
|
27826
|
-
* @returns
|
|
27827
|
-
*/
|
|
27828
|
-
// isPseudo(parseInfo: ParseInfo): boolean {
|
|
27829
|
-
// let position: number = parseInfo.currentPosition - parseInfo.offset;
|
|
27830
|
-
// let endPosition: number = parseInfo.currentPosition - parseInfo.offset;
|
|
27831
|
-
// return (parseInfo.stream.charAt(position) == ":" &&
|
|
27832
|
-
// parseInfo.stream.charAt(endPosition - 1) == "(" &&
|
|
27833
|
-
// (parseInfo.stream.charAt(position + 1) == ":"
|
|
27834
|
-
// ? this.isIdentToken(parseInfo, 2, -1)
|
|
27835
|
-
// : this.isIdentToken(parseInfo, 1, -1))) ||
|
|
27836
|
-
// parseInfo.stream.charAt(position + 1) == ":"
|
|
27837
|
-
// ? this.isIdentToken(parseInfo, 2)
|
|
27838
|
-
// : this.isIdentToken(parseInfo, 1);
|
|
27839
|
-
// }
|
|
27840
27850
|
/**
|
|
27841
27851
|
*
|
|
27842
27852
|
* @param parseInfo
|
|
@@ -27967,28 +27977,28 @@ class Tokenizer {
|
|
|
27967
27977
|
// EOF
|
|
27968
27978
|
switch (charCode) {
|
|
27969
27979
|
case 61 /* TokenMap.EQUALS */:
|
|
27970
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
27971
|
-
|
|
27972
|
-
}
|
|
27980
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
27981
|
+
// return this.makeToken(parseInfo);
|
|
27982
|
+
// }
|
|
27973
27983
|
this.advance(parseInfo);
|
|
27974
27984
|
return this.makeToken(parseInfo, exports.EnumToken.DelimTokenType);
|
|
27975
27985
|
// '+' or '-'
|
|
27976
27986
|
case 43 /* TokenMap.PLUS */:
|
|
27977
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
27978
|
-
|
|
27979
|
-
}
|
|
27987
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
27988
|
+
// return this.makeToken(parseInfo);
|
|
27989
|
+
// }
|
|
27980
27990
|
this.advance(parseInfo);
|
|
27981
27991
|
charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
27982
|
-
if (isDigit(charCode)) {
|
|
27983
|
-
|
|
27984
|
-
|
|
27985
|
-
|
|
27986
|
-
|
|
27987
|
-
|
|
27988
|
-
|
|
27989
|
-
|
|
27990
|
-
|
|
27991
|
-
}
|
|
27992
|
+
// if (isDigit(charCode)) {
|
|
27993
|
+
// tokensCount = this.consumeNumericToken(parseInfo);
|
|
27994
|
+
// if (tokensCount > 0) {
|
|
27995
|
+
// this.advance(parseInfo, tokensCount);
|
|
27996
|
+
// return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, {
|
|
27997
|
+
// slice: this.slice,
|
|
27998
|
+
// sign: "+",
|
|
27999
|
+
// });
|
|
28000
|
+
// }
|
|
28001
|
+
// }
|
|
27992
28002
|
return this.makeToken(parseInfo, exports.EnumToken.Plus);
|
|
27993
28003
|
case 45 /* TokenMap.MINUS */:
|
|
27994
28004
|
if (parseInfo.position == parseInfo.currentPosition) {
|
|
@@ -27998,15 +28008,17 @@ class Tokenizer {
|
|
|
27998
28008
|
this.advance(parseInfo);
|
|
27999
28009
|
return this.makeToken(parseInfo, exports.EnumToken.Sub);
|
|
28000
28010
|
}
|
|
28001
|
-
if (
|
|
28002
|
-
|
|
28003
|
-
|
|
28004
|
-
|
|
28005
|
-
|
|
28006
|
-
|
|
28007
|
-
|
|
28008
|
-
|
|
28009
|
-
|
|
28011
|
+
// if (
|
|
28012
|
+
// charCode == TokenMap.MINUS &&
|
|
28013
|
+
// (nextCharCode == TokenMap.MINUS || isIdentStart(nextCharCode))
|
|
28014
|
+
// ) {
|
|
28015
|
+
// this.advance(parseInfo);
|
|
28016
|
+
// tokensCount = this.consumeIdentToken(parseInfo);
|
|
28017
|
+
// if (tokensCount > 0) {
|
|
28018
|
+
// this.advance(parseInfo, tokensCount);
|
|
28019
|
+
// return this.makeToken(parseInfo, EnumToken.IdenTokenType);
|
|
28020
|
+
// }
|
|
28021
|
+
// }
|
|
28010
28022
|
}
|
|
28011
28023
|
this.advance(parseInfo);
|
|
28012
28024
|
break;
|
|
@@ -28059,28 +28071,28 @@ class Tokenizer {
|
|
|
28059
28071
|
return this.makeToken(parseInfo, exports.EnumToken.EndParensTokenType);
|
|
28060
28072
|
// '['
|
|
28061
28073
|
case 91 /* TokenMap.LEFT_BRACKETS */:
|
|
28062
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28063
|
-
|
|
28064
|
-
}
|
|
28074
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28075
|
+
// return this.makeToken(parseInfo);
|
|
28076
|
+
// }
|
|
28065
28077
|
this.advance(parseInfo);
|
|
28066
28078
|
return this.makeToken(parseInfo, exports.EnumToken.AttrStartTokenType);
|
|
28067
28079
|
// ']'
|
|
28068
28080
|
case 93 /* TokenMap.RIGHT_BRACKETS */:
|
|
28069
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28070
|
-
|
|
28071
|
-
}
|
|
28081
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28082
|
+
// return this.makeToken(parseInfo);
|
|
28083
|
+
// }
|
|
28072
28084
|
this.advance(parseInfo);
|
|
28073
28085
|
return this.makeToken(parseInfo, exports.EnumToken.AttrEndTokenType);
|
|
28074
28086
|
case 59 /* TokenMap.SEMICOLON */:
|
|
28075
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28076
|
-
|
|
28077
|
-
}
|
|
28087
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28088
|
+
// return this.makeToken(parseInfo);
|
|
28089
|
+
// }
|
|
28078
28090
|
this.advance(parseInfo);
|
|
28079
28091
|
return this.makeToken(parseInfo, exports.EnumToken.SemiColonTokenType);
|
|
28080
28092
|
case 58 /* TokenMap.COLON */:
|
|
28081
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28082
|
-
|
|
28083
|
-
}
|
|
28093
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28094
|
+
// return this.makeToken(parseInfo);
|
|
28095
|
+
// }
|
|
28084
28096
|
this.advance(parseInfo);
|
|
28085
28097
|
if (this.peekCharCode(parseInfo) == 58 /* TokenMap.COLON */) {
|
|
28086
28098
|
this.advance(parseInfo);
|
|
@@ -28112,15 +28124,15 @@ class Tokenizer {
|
|
|
28112
28124
|
}
|
|
28113
28125
|
return this.makeToken(parseInfo, exports.EnumToken.WhitespaceTokenType);
|
|
28114
28126
|
case 44 /* TokenMap.COMMA */:
|
|
28115
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28116
|
-
|
|
28117
|
-
}
|
|
28127
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28128
|
+
// return this.makeToken(parseInfo);
|
|
28129
|
+
// }
|
|
28118
28130
|
this.advance(parseInfo);
|
|
28119
28131
|
return this.makeToken(parseInfo, exports.EnumToken.CommaTokenType);
|
|
28120
28132
|
case 36 /* TokenMap.DOLLAR */:
|
|
28121
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28122
|
-
|
|
28123
|
-
}
|
|
28133
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28134
|
+
// return this.makeToken(parseInfo);
|
|
28135
|
+
// }
|
|
28124
28136
|
if (this.match(parseInfo, "$=")) {
|
|
28125
28137
|
this.advance(parseInfo, 2);
|
|
28126
28138
|
return this.makeToken(parseInfo, exports.EnumToken.EndMatchTokenType);
|
|
@@ -28128,9 +28140,9 @@ class Tokenizer {
|
|
|
28128
28140
|
this.advance(parseInfo);
|
|
28129
28141
|
break;
|
|
28130
28142
|
case 126 /* TokenMap.TILDA */:
|
|
28131
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28132
|
-
|
|
28133
|
-
}
|
|
28143
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28144
|
+
// return this.makeToken(parseInfo);
|
|
28145
|
+
// }
|
|
28134
28146
|
if (this.match(parseInfo, "~=")) {
|
|
28135
28147
|
this.advance(parseInfo, 2);
|
|
28136
28148
|
return this.makeToken(parseInfo, exports.EnumToken.IncludeMatchTokenType);
|
|
@@ -28139,9 +28151,9 @@ class Tokenizer {
|
|
|
28139
28151
|
return this.makeToken(parseInfo, exports.EnumToken.Tilda);
|
|
28140
28152
|
// case '^':
|
|
28141
28153
|
case 94 /* TokenMap.CARET */:
|
|
28142
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28143
|
-
|
|
28144
|
-
}
|
|
28154
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28155
|
+
// return this.makeToken(parseInfo);
|
|
28156
|
+
// }
|
|
28145
28157
|
if (this.match(parseInfo, "^=")) {
|
|
28146
28158
|
this.advance(parseInfo, 2);
|
|
28147
28159
|
return this.makeToken(parseInfo, exports.EnumToken.StartMatchTokenType);
|
|
@@ -28149,9 +28161,9 @@ class Tokenizer {
|
|
|
28149
28161
|
this.advance(parseInfo);
|
|
28150
28162
|
break;
|
|
28151
28163
|
case 42 /* TokenMap.STAR */:
|
|
28152
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28153
|
-
|
|
28154
|
-
}
|
|
28164
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28165
|
+
// return this.makeToken(parseInfo);
|
|
28166
|
+
// }
|
|
28155
28167
|
if (this.match(parseInfo, "*=")) {
|
|
28156
28168
|
this.advance(parseInfo, 2);
|
|
28157
28169
|
return this.makeToken(parseInfo, exports.EnumToken.ContainMatchTokenType);
|
|
@@ -28165,9 +28177,9 @@ class Tokenizer {
|
|
|
28165
28177
|
this.advance(parseInfo);
|
|
28166
28178
|
return this.makeToken(parseInfo, exports.EnumToken.NestingSelectorTokenType);
|
|
28167
28179
|
case 124 /* TokenMap.PIPE */:
|
|
28168
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28169
|
-
|
|
28170
|
-
}
|
|
28180
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28181
|
+
// return this.makeToken(parseInfo);
|
|
28182
|
+
// }
|
|
28171
28183
|
// '||'
|
|
28172
28184
|
if (this.match(parseInfo, "||")) {
|
|
28173
28185
|
this.advance(parseInfo, 2);
|
|
@@ -28190,9 +28202,9 @@ class Tokenizer {
|
|
|
28190
28202
|
this.advance(parseInfo);
|
|
28191
28203
|
break;
|
|
28192
28204
|
case 47 /* TokenMap.SLASH */:
|
|
28193
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28194
|
-
|
|
28195
|
-
}
|
|
28205
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28206
|
+
// return this.makeToken(parseInfo);
|
|
28207
|
+
// }
|
|
28196
28208
|
if (!this.match(parseInfo, "/*")) {
|
|
28197
28209
|
this.advance(parseInfo);
|
|
28198
28210
|
return this.makeToken(parseInfo, getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset));
|
|
@@ -28211,9 +28223,9 @@ class Tokenizer {
|
|
|
28211
28223
|
}
|
|
28212
28224
|
break;
|
|
28213
28225
|
case 62 /* TokenMap.GREATERTHAN */:
|
|
28214
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28215
|
-
|
|
28216
|
-
}
|
|
28226
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28227
|
+
// return this.makeToken(parseInfo);
|
|
28228
|
+
// }
|
|
28217
28229
|
if (this.match(parseInfo, ">=")) {
|
|
28218
28230
|
this.advance(parseInfo, 2);
|
|
28219
28231
|
return this.makeToken(parseInfo, exports.EnumToken.GteTokenType);
|
|
@@ -28252,20 +28264,11 @@ class Tokenizer {
|
|
|
28252
28264
|
this.advance(parseInfo);
|
|
28253
28265
|
break;
|
|
28254
28266
|
case 92 /* TokenMap.REVERSE_SOLIDUS */:
|
|
28255
|
-
// if (!yieldEOFToken && parseInfo.stream.length == parseInfo.currentPosition - parseInfo.offset + 1) {
|
|
28256
|
-
// break;
|
|
28257
|
-
// }
|
|
28258
28267
|
this.advance(parseInfo);
|
|
28259
28268
|
// EOF
|
|
28260
|
-
|
|
28261
|
-
|
|
28262
|
-
|
|
28263
|
-
// }
|
|
28264
|
-
// end of stream ignore \\
|
|
28265
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28266
|
-
return this.makeToken(parseInfo);
|
|
28267
|
-
}
|
|
28268
|
-
break;
|
|
28269
|
+
// end of stream ignore \\
|
|
28270
|
+
if (!this.peek(parseInfo) && parseInfo.position < parseInfo.currentPosition) {
|
|
28271
|
+
return this.makeToken(parseInfo);
|
|
28269
28272
|
}
|
|
28270
28273
|
this.advance(parseInfo);
|
|
28271
28274
|
break;
|
|
@@ -28278,9 +28281,9 @@ class Tokenizer {
|
|
|
28278
28281
|
case 46 /* TokenMap.DOT */:
|
|
28279
28282
|
const codepoint = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
|
|
28280
28283
|
if (isIdentStart(codepoint) || codepoint == 45 /* TokenMap.MINUS */) {
|
|
28281
|
-
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28282
|
-
|
|
28283
|
-
}
|
|
28284
|
+
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
28285
|
+
// return this.makeToken(parseInfo);
|
|
28286
|
+
// }
|
|
28284
28287
|
this.advance(parseInfo);
|
|
28285
28288
|
let tokensCount = this.consumeIdentToken(parseInfo);
|
|
28286
28289
|
if (tokensCount > 0) {
|
|
@@ -28288,27 +28291,22 @@ class Tokenizer {
|
|
|
28288
28291
|
return this.makeToken(parseInfo, exports.EnumToken.ClassSelectorTokenType);
|
|
28289
28292
|
}
|
|
28290
28293
|
}
|
|
28291
|
-
if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
|
|
28292
|
-
|
|
28293
|
-
|
|
28294
|
-
|
|
28295
|
-
}
|
|
28294
|
+
// if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
|
|
28295
|
+
// this.makeToken(parseInfo);
|
|
28296
|
+
// this.advance(parseInfo, 2);
|
|
28297
|
+
// return this;
|
|
28298
|
+
// }
|
|
28296
28299
|
this.advance(parseInfo);
|
|
28297
28300
|
break;
|
|
28298
28301
|
default:
|
|
28299
28302
|
this.advance(parseInfo);
|
|
28300
28303
|
break;
|
|
28301
28304
|
}
|
|
28302
|
-
// if (!yieldEOFToken && endPosition <= parseInfo.currentPosition - parseInfo.offset + 1) {
|
|
28303
|
-
// break;
|
|
28304
|
-
// }
|
|
28305
28305
|
}
|
|
28306
|
-
// if (yieldEOFToken) {
|
|
28307
28306
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28308
28307
|
return this.makeToken(parseInfo);
|
|
28309
28308
|
}
|
|
28310
28309
|
return this.makeToken(parseInfo, exports.EnumToken.EOFTokenType);
|
|
28311
|
-
// }
|
|
28312
28310
|
}
|
|
28313
28311
|
/**
|
|
28314
28312
|
* tokenize readable stream
|
|
@@ -31082,6 +31080,7 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
31082
31080
|
if (options.expandNestingRules) {
|
|
31083
31081
|
options.nestingRules = false;
|
|
31084
31082
|
}
|
|
31083
|
+
options.minifyAST ??= options.minify;
|
|
31085
31084
|
const startTime = performance.now();
|
|
31086
31085
|
const errors = [];
|
|
31087
31086
|
const stack = [];
|
|
@@ -31461,7 +31460,7 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
31461
31460
|
}
|
|
31462
31461
|
}
|
|
31463
31462
|
}
|
|
31464
|
-
if (options.
|
|
31463
|
+
if (options.minifyAST) {
|
|
31465
31464
|
if (ast.chi.length > 0) {
|
|
31466
31465
|
let passes = options.pass ?? 1;
|
|
31467
31466
|
while (passes--) {
|
|
@@ -32001,6 +32000,7 @@ async function doParse(iter, options = {}) {
|
|
|
32001
32000
|
lenient: true,
|
|
32002
32001
|
...options,
|
|
32003
32002
|
};
|
|
32003
|
+
options.minifyAST ??= options.minify;
|
|
32004
32004
|
if (typeof options.validation !== "boolean") {
|
|
32005
32005
|
options.validation = !!options.validation;
|
|
32006
32006
|
}
|
|
@@ -32455,7 +32455,7 @@ async function doParse(iter, options = {}) {
|
|
|
32455
32455
|
}
|
|
32456
32456
|
}
|
|
32457
32457
|
}
|
|
32458
|
-
if (options.
|
|
32458
|
+
if (options.minifyAST) {
|
|
32459
32459
|
if (ast.chi.length > 0) {
|
|
32460
32460
|
let passes = options.pass ?? 1;
|
|
32461
32461
|
while (passes--) {
|