@tbela99/css-parser 1.6.1 → 1.6.3
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 +119 -2
- package/README.md +1 -0
- package/dist/index-umd-web.js +1214 -247
- package/dist/index.cjs +1214 -247
- package/dist/index.d.ts +71 -6
- package/dist/lib/ast/features/prefix.js +9 -1
- package/dist/lib/ast/features/shorthand.js +1 -1
- package/dist/lib/ast/math/expression.js +156 -1
- package/dist/lib/ast/transform/compute.js +4 -8
- package/dist/lib/ast/types.js +12 -0
- package/dist/lib/parser/declaration/list.js +8 -10
- package/dist/lib/parser/parse.js +2 -9
- package/dist/lib/parser/tokenize.js +50 -18
- package/dist/lib/parser/utils/at-rule-font-feature-values.js +1 -1
- package/dist/lib/parser/utils/at-rule-media.js +66 -0
- package/dist/lib/parser/utils/at-rule-when-else.js +2 -2
- package/dist/lib/parser/utils/base64.js +14 -0
- package/dist/lib/parser/utils/declaration.js +7 -14
- package/dist/lib/parser/utils/eq.js +6 -0
- package/dist/lib/parser/utils/hash.js +1 -0
- package/dist/lib/parser/utils/selector.js +1 -1
- package/dist/lib/parser/utils/text.js +16 -0
- package/dist/lib/renderer/render.js +18 -4
- package/dist/lib/renderer/sourcemap/lib/codec.js +5 -0
- package/dist/lib/renderer/sourcemap/sourcemap.js +35 -5
- package/dist/lib/syntax/color/alpha.js +57 -22
- package/dist/lib/syntax/color/color-mix.js +18 -18
- package/dist/lib/syntax/color/srgb.js +10 -5
- package/dist/lib/syntax/color/utils/components.js +1 -1
- package/dist/lib/syntax/color/utils/distance.js +2 -2
- package/dist/lib/syntax/color/utils/matrix.js +1 -0
- package/dist/lib/syntax/color/xyz.js +5 -0
- package/dist/lib/syntax/color/xyzd50.js +17 -0
- package/dist/lib/syntax/syntax.js +549 -13
- package/dist/lib/validation/config.js +26 -0
- package/dist/lib/validation/match.js +16 -4
- package/dist/node.js +8 -14
- package/dist/web.js +8 -14
- package/package.json +1 -1
package/dist/index-umd-web.js
CHANGED
|
@@ -666,6 +666,18 @@
|
|
|
666
666
|
* wrapped values token type like {Arial, sans-serif}
|
|
667
667
|
*/
|
|
668
668
|
EnumToken[EnumToken["WrappedValuesTokenType"] = 140] = "WrappedValuesTokenType";
|
|
669
|
+
/**
|
|
670
|
+
* infinity token
|
|
671
|
+
*/
|
|
672
|
+
EnumToken[EnumToken["NaNTokenType"] = 141] = "NaNTokenType";
|
|
673
|
+
/**
|
|
674
|
+
* infinity token
|
|
675
|
+
*/
|
|
676
|
+
EnumToken[EnumToken["InfinityTokenType"] = 142] = "InfinityTokenType";
|
|
677
|
+
/**
|
|
678
|
+
* negative infinity token
|
|
679
|
+
*/
|
|
680
|
+
EnumToken[EnumToken["NegativeInfinityTokenType"] = 143] = "NegativeInfinityTokenType";
|
|
669
681
|
/* aliases */
|
|
670
682
|
/**
|
|
671
683
|
* alias for time token type
|
|
@@ -6838,12 +6850,28 @@
|
|
|
6838
6850
|
]);
|
|
6839
6851
|
const combinators = ["+", ">", "~", "||", "|"];
|
|
6840
6852
|
|
|
6853
|
+
/**
|
|
6854
|
+
*
|
|
6855
|
+
* @param value
|
|
6856
|
+
* @returns
|
|
6857
|
+
*/
|
|
6841
6858
|
function dasherize(value) {
|
|
6842
6859
|
return value.replace(/([A-Z])/g, (all, one) => `-${one.toLowerCase()}`);
|
|
6843
6860
|
}
|
|
6861
|
+
/**
|
|
6862
|
+
*
|
|
6863
|
+
* @param value
|
|
6864
|
+
* @returns
|
|
6865
|
+
*/
|
|
6844
6866
|
function camelize(value) {
|
|
6845
6867
|
return value.replace(/-([a-z])/g, (all, one) => one.toUpperCase());
|
|
6846
6868
|
}
|
|
6869
|
+
/**
|
|
6870
|
+
*
|
|
6871
|
+
* @param a
|
|
6872
|
+
* @param b
|
|
6873
|
+
* @returns
|
|
6874
|
+
*/
|
|
6847
6875
|
function equalsIgnoreCase(a, b) {
|
|
6848
6876
|
if (a.length !== b.length)
|
|
6849
6877
|
return false;
|
|
@@ -6872,7 +6900,7 @@
|
|
|
6872
6900
|
// }
|
|
6873
6901
|
// }
|
|
6874
6902
|
if (token.kin == exports.ColorType.HEX || token.kin == exports.ColorType.LIT) {
|
|
6875
|
-
if (equalsIgnoreCase(
|
|
6903
|
+
if (equalsIgnoreCase("currentcolor", token.val)) {
|
|
6876
6904
|
return null;
|
|
6877
6905
|
}
|
|
6878
6906
|
const value = expandHexValue(token.kin == exports.ColorType.LIT ? COLORS_NAMES[token.val.toLowerCase()] : token.val);
|
|
@@ -6930,6 +6958,7 @@
|
|
|
6930
6958
|
*/
|
|
6931
6959
|
// A is m x n. B is n x p. product is m x p.
|
|
6932
6960
|
function multiplyMatrices(A, B) {
|
|
6961
|
+
// let m: number = A.length;
|
|
6933
6962
|
// if (!Array.isArray(A[0])) {
|
|
6934
6963
|
// // A is vector, convert to [[a, b, c, ...]]
|
|
6935
6964
|
// A = <number[][]>[A];
|
|
@@ -7145,6 +7174,23 @@
|
|
|
7145
7174
|
return alpha == null ? [l, c, h] : [l, c, h, alpha];
|
|
7146
7175
|
}
|
|
7147
7176
|
|
|
7177
|
+
// export function srgb2xyzd50values(r: number, g: number, b: number, alpha: number | null = null): number[] {
|
|
7178
|
+
// [r, g, b] = srgb2lsrgbvalues(r, g, b);
|
|
7179
|
+
//
|
|
7180
|
+
// const rgb: number[] = [
|
|
7181
|
+
// 0.436065742824811 * r + 0.3851514688337912 * g + 0.14307845442264197 * b,
|
|
7182
|
+
//
|
|
7183
|
+
// 0.22249319175623702 * r + 0.7168870538238823 * g + 0.06061979053616537 * b,
|
|
7184
|
+
//
|
|
7185
|
+
// 0.013923904500943465 * r + 0.09708128566574634 * g + 0.7140993584005155 * b,
|
|
7186
|
+
// ];
|
|
7187
|
+
//
|
|
7188
|
+
// if (alpha != null && alpha != 1) {
|
|
7189
|
+
// rgb.push(alpha);
|
|
7190
|
+
// }
|
|
7191
|
+
//
|
|
7192
|
+
// return rgb;
|
|
7193
|
+
// }
|
|
7148
7194
|
/*
|
|
7149
7195
|
*/
|
|
7150
7196
|
function xyzd502lch(x, y, z, alpha) {
|
|
@@ -7178,6 +7224,11 @@
|
|
|
7178
7224
|
x * 0.07195537988411677 - y * 0.2289768264158322 + 1.405386058324125 * z, alpha);
|
|
7179
7225
|
}
|
|
7180
7226
|
|
|
7227
|
+
// export function lab2xyz(l: number, a: number, b: number, alpha?: number): number[] {
|
|
7228
|
+
// const [x, y, z] = Lab_to_XYZ(l, a, b);
|
|
7229
|
+
//
|
|
7230
|
+
// return alpha == null || alpha == 1 ? [x, y, z] : [x, y, z, alpha];
|
|
7231
|
+
// }
|
|
7181
7232
|
function XYZ_to_lin_sRGB(x, y, z, alpha = null) {
|
|
7182
7233
|
// convert XYZ to linear-light sRGB
|
|
7183
7234
|
const M = [
|
|
@@ -7894,6 +7945,15 @@
|
|
|
7894
7945
|
? getNumber(t)
|
|
7895
7946
|
: getNumber(t) / 255) ?? null);
|
|
7896
7947
|
}
|
|
7948
|
+
// export function rgbvalues2srgbvalues(r: number, g: number, b: number, a: number | null = null): number[] | null {
|
|
7949
|
+
// const result = [r / 255, g / 255, b / 255];
|
|
7950
|
+
//
|
|
7951
|
+
// if (a != null && a != 1) {
|
|
7952
|
+
// result.push(a);
|
|
7953
|
+
// }
|
|
7954
|
+
//
|
|
7955
|
+
// return result;
|
|
7956
|
+
// }
|
|
7897
7957
|
function hex2srgbvalues(token) {
|
|
7898
7958
|
const value = expandHexValue(token.kin == exports.ColorType.LIT ? COLORS_NAMES[token.val.toLowerCase()] : token.val);
|
|
7899
7959
|
const rgb = [];
|
|
@@ -7955,11 +8015,7 @@
|
|
|
7955
8015
|
// @ts-ignore
|
|
7956
8016
|
const k = getNumber(t);
|
|
7957
8017
|
const mul = 1 - k;
|
|
7958
|
-
const rgb = [
|
|
7959
|
-
1 - Math.min(1, c * mul + k),
|
|
7960
|
-
1 - Math.min(1, m * mul + k),
|
|
7961
|
-
1 - Math.min(1, y * mul + k),
|
|
7962
|
-
];
|
|
8018
|
+
const rgb = [1 - Math.min(1, c * mul + k), 1 - Math.min(1, m * mul + k), 1 - Math.min(1, y * mul + k)];
|
|
7963
8019
|
if (components.length == 5) {
|
|
7964
8020
|
rgb.push(getNumber(components[4]));
|
|
7965
8021
|
}
|
|
@@ -9131,7 +9187,7 @@
|
|
|
9131
9187
|
let colorSpace = "oklab";
|
|
9132
9188
|
let hueInterpolationMethod = "shorter";
|
|
9133
9189
|
let values = null;
|
|
9134
|
-
const colors = [];
|
|
9190
|
+
// const colors: ColorToken[] = [];
|
|
9135
9191
|
const percentages = [];
|
|
9136
9192
|
const srgbComponentValues = [];
|
|
9137
9193
|
const colorComponents = [];
|
|
@@ -9240,7 +9296,8 @@
|
|
|
9240
9296
|
return null;
|
|
9241
9297
|
}
|
|
9242
9298
|
srgbComponentValues.push(values);
|
|
9243
|
-
colors.push(args[i++]);
|
|
9299
|
+
// colors.push(args[i++] as ColorToken);
|
|
9300
|
+
i++;
|
|
9244
9301
|
if (i >= args.length) {
|
|
9245
9302
|
missingPercentageCount++;
|
|
9246
9303
|
percentages.push(null);
|
|
@@ -9282,9 +9339,16 @@
|
|
|
9282
9339
|
for (i = 0; i < percentages.length; i++) {
|
|
9283
9340
|
percentages[i] = percentages[i] / perc;
|
|
9284
9341
|
}
|
|
9285
|
-
totalPercentage = 1;
|
|
9286
9342
|
}
|
|
9287
|
-
|
|
9343
|
+
const stack = [];
|
|
9344
|
+
const lchSpaces = ["lch", "oklch"];
|
|
9345
|
+
i = srgbComponentValues.length;
|
|
9346
|
+
while (i--) {
|
|
9347
|
+
stack.push({
|
|
9348
|
+
color: srgbComponentValues[i],
|
|
9349
|
+
alpha: percentages[i],
|
|
9350
|
+
});
|
|
9351
|
+
}
|
|
9288
9352
|
let currentIndex = 0;
|
|
9289
9353
|
let r1;
|
|
9290
9354
|
let r2;
|
|
@@ -9295,18 +9359,11 @@
|
|
|
9295
9359
|
let premult1;
|
|
9296
9360
|
let premult2;
|
|
9297
9361
|
let mixedPremult;
|
|
9298
|
-
let colorSpace1
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
i = srgbComponentValues.length;
|
|
9302
|
-
while (i--) {
|
|
9303
|
-
stack.push({
|
|
9304
|
-
color: srgbComponentValues[i],
|
|
9305
|
-
alpha: percentages[i],
|
|
9306
|
-
});
|
|
9307
|
-
}
|
|
9362
|
+
let colorSpace1 = exports.ColorType[
|
|
9363
|
+
// @ts-expect-error
|
|
9364
|
+
colorComponents.at(-1).kin
|
|
9308
9365
|
// @ts-expect-error
|
|
9309
|
-
|
|
9366
|
+
]?.toLowerCase?.();
|
|
9310
9367
|
if (colorComponents[0][3] != null &&
|
|
9311
9368
|
colorComponents[0][3].typ == exports.EnumToken.IdenTokenType &&
|
|
9312
9369
|
colorComponents[0][3].val == "none" &&
|
|
@@ -9388,14 +9445,13 @@
|
|
|
9388
9445
|
else {
|
|
9389
9446
|
values = xyz2lchvalues(values[0], values[1], values[2], values[3]);
|
|
9390
9447
|
}
|
|
9391
|
-
// @ts-ignore
|
|
9392
9448
|
return {
|
|
9393
9449
|
typ: exports.EnumToken.ColorTokenType,
|
|
9394
9450
|
val: "lch",
|
|
9395
|
-
chi: values.map((
|
|
9451
|
+
chi: values.map((val) => {
|
|
9396
9452
|
return {
|
|
9397
9453
|
typ: exports.EnumToken.NumberTokenType,
|
|
9398
|
-
val
|
|
9454
|
+
val,
|
|
9399
9455
|
};
|
|
9400
9456
|
}),
|
|
9401
9457
|
kin: exports.ColorType.LCH,
|
|
@@ -10128,6 +10184,35 @@
|
|
|
10128
10184
|
if (!isScalarToken(l) || !isScalarToken(r) || (l.typ == r.typ && "unit" in l && "unit" in r && l.unit != r.unit)) {
|
|
10129
10185
|
return defaultReturn;
|
|
10130
10186
|
}
|
|
10187
|
+
if (l.typ == exports.EnumToken.IdenTokenType) {
|
|
10188
|
+
if (equalsIgnoreCase(l.val, "Infinity")) {
|
|
10189
|
+
Object.assign(l, { typ: exports.EnumToken.InfinityTokenType });
|
|
10190
|
+
}
|
|
10191
|
+
else if (equalsIgnoreCase(l.val, "-Infinity")) {
|
|
10192
|
+
Object.assign(l, { typ: exports.EnumToken.NegativeInfinityTokenType });
|
|
10193
|
+
}
|
|
10194
|
+
else if (equalsIgnoreCase(l.val, "NaN")) {
|
|
10195
|
+
Object.assign(l, { typ: exports.EnumToken.NaNTokenType });
|
|
10196
|
+
}
|
|
10197
|
+
}
|
|
10198
|
+
if (r.typ == exports.EnumToken.IdenTokenType) {
|
|
10199
|
+
if (equalsIgnoreCase(r.val, "Infinity")) {
|
|
10200
|
+
Object.assign(r, { typ: exports.EnumToken.InfinityTokenType });
|
|
10201
|
+
}
|
|
10202
|
+
else if (equalsIgnoreCase(r.val, "-Infinity")) {
|
|
10203
|
+
Object.assign(r, { typ: exports.EnumToken.NegativeInfinityTokenType });
|
|
10204
|
+
}
|
|
10205
|
+
}
|
|
10206
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/calc-keyword#notes
|
|
10207
|
+
if (l.typ == exports.EnumToken.NaNTokenType || r.typ == exports.EnumToken.NaNTokenType) {
|
|
10208
|
+
return computeNaN(l, r, defaultReturn);
|
|
10209
|
+
}
|
|
10210
|
+
if (l.typ == exports.EnumToken.InfinityTokenType ||
|
|
10211
|
+
l.typ == exports.EnumToken.NegativeInfinityTokenType ||
|
|
10212
|
+
r.typ == exports.EnumToken.InfinityTokenType ||
|
|
10213
|
+
r.typ == exports.EnumToken.NegativeInfinityTokenType) {
|
|
10214
|
+
return computeInfinity(l, r, op, defaultReturn);
|
|
10215
|
+
}
|
|
10131
10216
|
if (r.typ == exports.EnumToken.FunctionTokenType || r.typ == exports.EnumToken.MathFunctionTokenType) {
|
|
10132
10217
|
const val = evaluateFunc(r);
|
|
10133
10218
|
if (val == null) {
|
|
@@ -10198,6 +10283,18 @@
|
|
|
10198
10283
|
}
|
|
10199
10284
|
}
|
|
10200
10285
|
}
|
|
10286
|
+
if (op == exports.EnumToken.Div && v2 == 0) {
|
|
10287
|
+
if (v1 == 0) {
|
|
10288
|
+
return Object.assign(l, { typ: exports.EnumToken.IdenTokenType, val: "NaN" });
|
|
10289
|
+
}
|
|
10290
|
+
let sign = Math.sign(v1) * Math.sign(v2);
|
|
10291
|
+
sign = Object.is(sign, -0) ? -1 : 1;
|
|
10292
|
+
Object.assign(l, {
|
|
10293
|
+
typ: l.typ == exports.EnumToken.IdenTokenType ? exports.EnumToken.NumberTokenType : l.typ,
|
|
10294
|
+
val: Object.is(sign, -0) ? -1 : sign,
|
|
10295
|
+
});
|
|
10296
|
+
return defaultReturn;
|
|
10297
|
+
}
|
|
10201
10298
|
// @ts-ignore
|
|
10202
10299
|
const val = compute$1(v1, v2, op);
|
|
10203
10300
|
const token = {
|
|
@@ -10214,6 +10311,112 @@
|
|
|
10214
10311
|
}
|
|
10215
10312
|
return token;
|
|
10216
10313
|
}
|
|
10314
|
+
/**
|
|
10315
|
+
*
|
|
10316
|
+
* @param l
|
|
10317
|
+
* @param r
|
|
10318
|
+
* @param defaultReturn
|
|
10319
|
+
* @returns
|
|
10320
|
+
*/
|
|
10321
|
+
function computeNaN(l, r, defaultReturn) {
|
|
10322
|
+
if (l.typ == exports.EnumToken.NaNTokenType) {
|
|
10323
|
+
if (r.typ == exports.EnumToken.NumberTokenType ||
|
|
10324
|
+
// @ts-expect-error
|
|
10325
|
+
(r.typ == exports.EnumToken.IdenTokenType && typeof Math[r.val.toUpperCase()] == "string")) {
|
|
10326
|
+
return l;
|
|
10327
|
+
}
|
|
10328
|
+
// NaN Infinity e pi ...
|
|
10329
|
+
if (r.typ == exports.EnumToken.IdenTokenType ||
|
|
10330
|
+
r.typ == exports.EnumToken.InfinityTokenType ||
|
|
10331
|
+
r.typ == exports.EnumToken.NegativeInfinityTokenType) {
|
|
10332
|
+
return l;
|
|
10333
|
+
}
|
|
10334
|
+
if (typeof r.val == "number") {
|
|
10335
|
+
Object.assign(r, { val: 1 });
|
|
10336
|
+
}
|
|
10337
|
+
return r.typ == exports.EnumToken.NaNTokenType ? l : defaultReturn;
|
|
10338
|
+
}
|
|
10339
|
+
if (r.typ == exports.EnumToken.NaNTokenType) {
|
|
10340
|
+
// if ((r as IdentToken).val == "NaN") {
|
|
10341
|
+
if (l.typ == exports.EnumToken.NumberTokenType ||
|
|
10342
|
+
// @ts-expect-error
|
|
10343
|
+
(l.typ == exports.EnumToken.IdenTokenType && typeof Math[l.val.toUpperCase()] == "string")) {
|
|
10344
|
+
return r;
|
|
10345
|
+
}
|
|
10346
|
+
if (typeof l.val == "number") {
|
|
10347
|
+
Object.assign(l, { val: 1 });
|
|
10348
|
+
}
|
|
10349
|
+
// return defaultReturn;
|
|
10350
|
+
}
|
|
10351
|
+
// }
|
|
10352
|
+
return defaultReturn;
|
|
10353
|
+
}
|
|
10354
|
+
/**
|
|
10355
|
+
*
|
|
10356
|
+
* @param l
|
|
10357
|
+
* @param r
|
|
10358
|
+
* @param op
|
|
10359
|
+
* @param defaultReturn
|
|
10360
|
+
* @returns
|
|
10361
|
+
*/
|
|
10362
|
+
function computeInfinity(l, r, op, defaultReturn) {
|
|
10363
|
+
if (l.typ == exports.EnumToken.InfinityTokenType || l.typ == exports.EnumToken.NegativeInfinityTokenType) {
|
|
10364
|
+
if (r.typ == exports.EnumToken.InfinityTokenType || r.typ == exports.EnumToken.NegativeInfinityTokenType) {
|
|
10365
|
+
// Infinity / Infinity Infinity - Infinity
|
|
10366
|
+
if (op == exports.EnumToken.Div ||
|
|
10367
|
+
(op == exports.EnumToken.Add && l.typ != r.typ) ||
|
|
10368
|
+
(op == exports.EnumToken.Sub && l.typ == r.typ)) {
|
|
10369
|
+
return Object.assign(l, { typ: exports.EnumToken.NaNTokenType });
|
|
10370
|
+
}
|
|
10371
|
+
if (l.typ != r.typ) {
|
|
10372
|
+
l.typ = exports.EnumToken.NegativeInfinityTokenType;
|
|
10373
|
+
}
|
|
10374
|
+
return l;
|
|
10375
|
+
}
|
|
10376
|
+
const value = getValue$1(r);
|
|
10377
|
+
const sign = Math.sign(value);
|
|
10378
|
+
const isNumber = r.typ == exports.EnumToken.NumberTokenType || r.typ == exports.EnumToken.IdenTokenType;
|
|
10379
|
+
// Infinity * 0
|
|
10380
|
+
if (value == 0 && op == exports.EnumToken.Mul) {
|
|
10381
|
+
l.typ = exports.EnumToken.NaNTokenType;
|
|
10382
|
+
return isNumber ? l : defaultReturn;
|
|
10383
|
+
}
|
|
10384
|
+
if (isNumber) {
|
|
10385
|
+
// @ts-ignore
|
|
10386
|
+
r.val /= r.val * sign;
|
|
10387
|
+
}
|
|
10388
|
+
if (op == exports.EnumToken.Div) {
|
|
10389
|
+
return isNumber
|
|
10390
|
+
? Object.assign(r, { typ: exports.EnumToken.NumberTokenType, val: sign < 0 ? -0 : 0 })
|
|
10391
|
+
: defaultReturn;
|
|
10392
|
+
}
|
|
10393
|
+
if (sign == -1) {
|
|
10394
|
+
l.typ =
|
|
10395
|
+
l.typ == exports.EnumToken.InfinityTokenType
|
|
10396
|
+
? exports.EnumToken.NegativeInfinityTokenType
|
|
10397
|
+
: exports.EnumToken.InfinityTokenType;
|
|
10398
|
+
}
|
|
10399
|
+
return isNumber ? l : defaultReturn;
|
|
10400
|
+
}
|
|
10401
|
+
if (r.typ == exports.EnumToken.InfinityTokenType || r.typ == exports.EnumToken.NegativeInfinityTokenType) {
|
|
10402
|
+
const value = getValue$1(l);
|
|
10403
|
+
let sign = Math.sign(value);
|
|
10404
|
+
const isNumber = l.typ == exports.EnumToken.NumberTokenType || l.typ == exports.EnumToken.IdenTokenType;
|
|
10405
|
+
if (isNumber) {
|
|
10406
|
+
Object.assign(l, { typ: exports.EnumToken.NumberTokenType, val: sign });
|
|
10407
|
+
}
|
|
10408
|
+
if (value == 0 && op == exports.EnumToken.Mul) {
|
|
10409
|
+
return Object.assign(l, { typ: exports.EnumToken.NaNTokenType });
|
|
10410
|
+
}
|
|
10411
|
+
if (op == exports.EnumToken.Div) {
|
|
10412
|
+
return isNumber
|
|
10413
|
+
? Object.assign(l, { typ: exports.EnumToken.NumberTokenType, val: sign < 0 ? -0 : 0 })
|
|
10414
|
+
: defaultReturn;
|
|
10415
|
+
}
|
|
10416
|
+
return l.typ == isNumber || value == 0 ? r : defaultReturn;
|
|
10417
|
+
}
|
|
10418
|
+
return defaultReturn;
|
|
10419
|
+
}
|
|
10217
10420
|
function getValue$1(t) {
|
|
10218
10421
|
if (t.typ == exports.EnumToken.IdenTokenType) {
|
|
10219
10422
|
// @ts-ignore
|
|
@@ -10548,7 +10751,14 @@
|
|
|
10548
10751
|
(token.typ == exports.EnumToken.FunctionTokenType && mathFuncs.includes(token.val)) ||
|
|
10549
10752
|
// @ts-ignore
|
|
10550
10753
|
(token.typ == exports.EnumToken.IdenTokenType && typeof Math[token.val.toUpperCase()] == "number") ||
|
|
10551
|
-
|
|
10754
|
+
(token.typ == exports.EnumToken.IdenTokenType && token.val == "NaN") ||
|
|
10755
|
+
(token.typ == exports.EnumToken.IdenTokenType &&
|
|
10756
|
+
(equalsIgnoreCase(token.val, "Infinity") ||
|
|
10757
|
+
equalsIgnoreCase(token.val, "-Infinity"))) ||
|
|
10758
|
+
[exports.EnumToken.NumberTokenType, exports.EnumToken.FractionTokenType, exports.EnumToken.PercentageTokenType].includes(token.typ) ||
|
|
10759
|
+
token.typ == exports.EnumToken.NaNTokenType ||
|
|
10760
|
+
token.typ == exports.EnumToken.InfinityTokenType ||
|
|
10761
|
+
token.typ == exports.EnumToken.NegativeInfinityTokenType);
|
|
10552
10762
|
}
|
|
10553
10763
|
/**
|
|
10554
10764
|
*
|
|
@@ -11829,6 +12039,32 @@
|
|
|
11829
12039
|
// @ts-expect-error
|
|
11830
12040
|
return config$4;
|
|
11831
12041
|
}
|
|
12042
|
+
// export const getSyntax = memoize((group: ValidationSyntaxGroupEnum, key: string | string[]): null | string => {
|
|
12043
|
+
// // @ts-expect-error
|
|
12044
|
+
// let obj = config[group] as Record<ValidationSyntaxGroupEnum, ValidationSyntaxNode>;
|
|
12045
|
+
//
|
|
12046
|
+
// const keys: string[] = Array.isArray(key) ? key : [key];
|
|
12047
|
+
//
|
|
12048
|
+
// for (let i = 0; i < keys.length; i++) {
|
|
12049
|
+
// key = keys[i];
|
|
12050
|
+
//
|
|
12051
|
+
// if (!(key in obj)) {
|
|
12052
|
+
// if ((i == 0 && key.charAt(0) == "@") || key.charAt(0) == "-") {
|
|
12053
|
+
// const matches: RegExpMatchArray = key.match(/^(@?)(-[a-zA-Z]+)-(.*?)$/) as RegExpMatchArray;
|
|
12054
|
+
//
|
|
12055
|
+
// if (matches != null) {
|
|
12056
|
+
// key = matches[1] + matches[3];
|
|
12057
|
+
// }
|
|
12058
|
+
// }
|
|
12059
|
+
// }
|
|
12060
|
+
//
|
|
12061
|
+
// // @ts-expect-error
|
|
12062
|
+
// obj = obj[key];
|
|
12063
|
+
// }
|
|
12064
|
+
//
|
|
12065
|
+
// // @ts-expect-error
|
|
12066
|
+
// return obj?.syntax ?? null;
|
|
12067
|
+
// }) as (group: ValidationSyntaxGroupEnum, key: string | string[]) => null | string;
|
|
11832
12068
|
function findNode(group, key) {
|
|
11833
12069
|
// @ts-expect-error
|
|
11834
12070
|
let obj = config$4[group];
|
|
@@ -11978,6 +12214,15 @@
|
|
|
11978
12214
|
}
|
|
11979
12215
|
return tokens;
|
|
11980
12216
|
}
|
|
12217
|
+
/**
|
|
12218
|
+
* is a media feature
|
|
12219
|
+
* @param featureName
|
|
12220
|
+
* @returns
|
|
12221
|
+
*/
|
|
12222
|
+
// export function isMFName(featureName: string): boolean {
|
|
12223
|
+
// // @ts-expect-error
|
|
12224
|
+
// return featureName.startsWith("--") || config.mediaFeatures[featureName.toLowerCase()] != null;
|
|
12225
|
+
// }
|
|
11981
12226
|
/**
|
|
11982
12227
|
*
|
|
11983
12228
|
* @param featureName
|
|
@@ -11991,6 +12236,7 @@
|
|
|
11991
12236
|
*
|
|
11992
12237
|
* @param featureName
|
|
11993
12238
|
* @param tokens
|
|
12239
|
+
* @param isMFRange
|
|
11994
12240
|
* @returns object with:
|
|
11995
12241
|
* - valid: boolean. true the media feaure is known or is a custom property. false otherwise
|
|
11996
12242
|
* - success: boolean. validation result
|
|
@@ -12108,9 +12354,10 @@
|
|
|
12108
12354
|
},
|
|
12109
12355
|
/**
|
|
12110
12356
|
*
|
|
12111
|
-
* @param stopCondition
|
|
12112
|
-
* @param matchCount
|
|
12113
12357
|
* @returns
|
|
12358
|
+
* @param open
|
|
12359
|
+
* @param close
|
|
12360
|
+
* @param counter
|
|
12114
12361
|
*/
|
|
12115
12362
|
peekRange(open = exports.EnumToken.StartParensTokenType, close = exports.EnumToken.EndParensTokenType, counter = 0) {
|
|
12116
12363
|
let index = this.index;
|
|
@@ -12333,7 +12580,7 @@
|
|
|
12333
12580
|
case exports.EnumToken.CDOCOMMTokenType:
|
|
12334
12581
|
break;
|
|
12335
12582
|
case exports.EnumToken.NestingSelectorTokenType:
|
|
12336
|
-
if (nested
|
|
12583
|
+
if (!nested && !options.nestedRule) {
|
|
12337
12584
|
return {
|
|
12338
12585
|
success: false,
|
|
12339
12586
|
errors: [
|
|
@@ -13374,7 +13621,8 @@
|
|
|
13374
13621
|
errors: [],
|
|
13375
13622
|
};
|
|
13376
13623
|
case ValidationTokenEnum.FunctionDefinition:
|
|
13377
|
-
if (
|
|
13624
|
+
if (token.val &&
|
|
13625
|
+
equalsIgnoreCase(token.val, syntaxes[i].val)) {
|
|
13378
13626
|
if (tokensfuncDefMap.has(token.typ)) {
|
|
13379
13627
|
const children = trimArray(context.peekRange());
|
|
13380
13628
|
result = matchSyntax((getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, syntaxes[i].val + "()")?.[0]).chi ?? [], createValidationContext(children.slice(1, -1)), options);
|
|
@@ -14399,104 +14647,6 @@
|
|
|
14399
14647
|
return color.kin;
|
|
14400
14648
|
}
|
|
14401
14649
|
|
|
14402
|
-
const trimTokenSpace = new Set([
|
|
14403
|
-
exports.EnumToken.CommaTokenType,
|
|
14404
|
-
exports.EnumToken.DelimTokenType,
|
|
14405
|
-
exports.EnumToken.GtTokenType,
|
|
14406
|
-
exports.EnumToken.GteTokenType,
|
|
14407
|
-
exports.EnumToken.LtTokenType,
|
|
14408
|
-
exports.EnumToken.LteTokenType,
|
|
14409
|
-
exports.EnumToken.ChildCombinatorTokenType,
|
|
14410
|
-
]);
|
|
14411
|
-
const trimSpaceAfter = new Set([
|
|
14412
|
-
...tokensfuncSet.values(),
|
|
14413
|
-
exports.EnumToken.ChildCombinatorTokenType,
|
|
14414
|
-
exports.EnumToken.SupportsQueryConditionTokenType,
|
|
14415
|
-
exports.EnumToken.SupportsQueryUnaryConditionTokenType,
|
|
14416
|
-
]);
|
|
14417
|
-
/**
|
|
14418
|
-
* Replace token in its parent node
|
|
14419
|
-
* @param parent
|
|
14420
|
-
* @param node
|
|
14421
|
-
* @param replacement
|
|
14422
|
-
* @throws TypeError replacement is null
|
|
14423
|
-
* @throws ReferenceError node not found in parent
|
|
14424
|
-
*/
|
|
14425
|
-
function replaceNodeOrValue(parent, node, replacement) {
|
|
14426
|
-
if (replacement == null || (Array.isArray(replacement) && replacement.length === 0)) {
|
|
14427
|
-
throw new TypeError(`replacement is null`);
|
|
14428
|
-
}
|
|
14429
|
-
for (const newNode of Array.isArray(replacement) ? replacement : [replacement]) {
|
|
14430
|
-
if (newNode[PARENT] != node[PARENT]) {
|
|
14431
|
-
newNode[PARENT] = node[PARENT];
|
|
14432
|
-
}
|
|
14433
|
-
}
|
|
14434
|
-
if (parent.typ == exports.EnumToken.BinaryExpressionTokenType) {
|
|
14435
|
-
if (parent.l == node) {
|
|
14436
|
-
parent.l = replacement;
|
|
14437
|
-
}
|
|
14438
|
-
else if (parent.r == node) {
|
|
14439
|
-
parent.r = replacement;
|
|
14440
|
-
}
|
|
14441
|
-
else {
|
|
14442
|
-
throw new ReferenceError("Node not found");
|
|
14443
|
-
}
|
|
14444
|
-
}
|
|
14445
|
-
else {
|
|
14446
|
-
const target = "val" in parent && Array.isArray(parent.val)
|
|
14447
|
-
? parent.val
|
|
14448
|
-
: (parent.chi ?? parent);
|
|
14449
|
-
if (Array.isArray(target)) {
|
|
14450
|
-
// @ts-ignore
|
|
14451
|
-
const index = target.indexOf(node);
|
|
14452
|
-
if (index == -1) {
|
|
14453
|
-
throw new ReferenceError("Node not found");
|
|
14454
|
-
}
|
|
14455
|
-
target.splice(index, 1, ...(Array.isArray(replacement) ? replacement : [replacement]));
|
|
14456
|
-
}
|
|
14457
|
-
else if ("l" in target && target.l == node) {
|
|
14458
|
-
target.l = replacement;
|
|
14459
|
-
}
|
|
14460
|
-
else if ("r" in target && target.r == node) {
|
|
14461
|
-
target.r = replacement;
|
|
14462
|
-
}
|
|
14463
|
-
else {
|
|
14464
|
-
throw new ReferenceError("Node not found");
|
|
14465
|
-
}
|
|
14466
|
-
}
|
|
14467
|
-
node[PARENT] = null;
|
|
14468
|
-
return true;
|
|
14469
|
-
}
|
|
14470
|
-
function trimWhiteSpaceTokens(tokens) {
|
|
14471
|
-
let i = 0;
|
|
14472
|
-
if (tokens[0]?.typ === exports.EnumToken.WhitespaceTokenType) {
|
|
14473
|
-
tokens.shift();
|
|
14474
|
-
}
|
|
14475
|
-
if (tokens[tokens.length - 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
|
|
14476
|
-
tokens.pop();
|
|
14477
|
-
}
|
|
14478
|
-
if (tokens.length === 1) {
|
|
14479
|
-
if (tokens[0].typ === exports.EnumToken.WhitespaceTokenType) {
|
|
14480
|
-
tokens.length = 0;
|
|
14481
|
-
}
|
|
14482
|
-
return tokens;
|
|
14483
|
-
}
|
|
14484
|
-
for (; i < tokens.length; i++) {
|
|
14485
|
-
if (trimSpaceAfter.has(tokens[i].typ) && tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
|
|
14486
|
-
tokens.splice(i + 1, 1);
|
|
14487
|
-
}
|
|
14488
|
-
else if (trimTokenSpace.has(tokens[i].typ)) {
|
|
14489
|
-
if (tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
|
|
14490
|
-
tokens.splice(i + 1, 1);
|
|
14491
|
-
}
|
|
14492
|
-
if (i > 0 && tokens[i - 1].typ === exports.EnumToken.Whitespace) {
|
|
14493
|
-
tokens.splice(--i, 1);
|
|
14494
|
-
}
|
|
14495
|
-
}
|
|
14496
|
-
}
|
|
14497
|
-
return tokens;
|
|
14498
|
-
}
|
|
14499
|
-
|
|
14500
14650
|
/**
|
|
14501
14651
|
* Compute alpha color
|
|
14502
14652
|
* @param color
|
|
@@ -14507,40 +14657,76 @@
|
|
|
14507
14657
|
if (alpha == null) {
|
|
14508
14658
|
return color;
|
|
14509
14659
|
}
|
|
14660
|
+
// https://www.w3.org/TR/css-color-5/#:~:text=There%20is%20no%20relative%20device%2Dcmyk%28%29%20syntax
|
|
14510
14661
|
if (color.kin === exports.ColorType.DEVICE_CMYK) {
|
|
14511
14662
|
return null;
|
|
14512
14663
|
}
|
|
14664
|
+
let components = getColorComponents(color);
|
|
14665
|
+
if (alpha.typ === exports.EnumToken.MathFunctionTokenType) {
|
|
14666
|
+
const originalAlpha = cloneNode(alpha, true);
|
|
14667
|
+
for (const { value } of walkValues(alpha.chi, alpha)) {
|
|
14668
|
+
if (value.typ === exports.EnumToken.IdenTokenType) {
|
|
14669
|
+
if (equalsIgnoreCase(value.val, "alpha")) {
|
|
14670
|
+
Object.assign(value, components?.[3]
|
|
14671
|
+
? cloneNode(components[3], true)
|
|
14672
|
+
: {
|
|
14673
|
+
typ: exports.EnumToken.NumberTokenType,
|
|
14674
|
+
val: 1,
|
|
14675
|
+
});
|
|
14676
|
+
// continue;
|
|
14677
|
+
}
|
|
14678
|
+
else if (equalsIgnoreCase(value.val, "none")) {
|
|
14679
|
+
Object.assign(value, {
|
|
14680
|
+
typ: exports.EnumToken.NumberTokenType,
|
|
14681
|
+
val: 0,
|
|
14682
|
+
});
|
|
14683
|
+
}
|
|
14684
|
+
}
|
|
14685
|
+
}
|
|
14686
|
+
const result = evaluate([alpha]);
|
|
14687
|
+
if (result.length == 1) {
|
|
14688
|
+
alpha = result[0];
|
|
14689
|
+
}
|
|
14690
|
+
else {
|
|
14691
|
+
// @ts-expect-error
|
|
14692
|
+
alpha = originalAlpha;
|
|
14693
|
+
}
|
|
14694
|
+
}
|
|
14695
|
+
// console.error({ alpha });
|
|
14696
|
+
if (alpha.typ !== exports.EnumToken.IdenTokenType &&
|
|
14697
|
+
alpha.typ !== exports.EnumToken.NumberTokenType &&
|
|
14698
|
+
alpha.typ !== exports.EnumToken.PercentageTokenType) {
|
|
14699
|
+
return null;
|
|
14700
|
+
}
|
|
14701
|
+
if (alpha.typ === exports.EnumToken.IdenTokenType) {
|
|
14702
|
+
if (equalsIgnoreCase(alpha.val, "NaN") ||
|
|
14703
|
+
equalsIgnoreCase(alpha.val, "Infinity") ||
|
|
14704
|
+
equalsIgnoreCase(alpha.val, "-Infinity")) {
|
|
14705
|
+
return null;
|
|
14706
|
+
}
|
|
14707
|
+
}
|
|
14513
14708
|
if (color.kin === exports.ColorType.COLOR_MIX || color.cal === "rel") {
|
|
14514
14709
|
color = convertColor(color, getColorType(color));
|
|
14515
14710
|
if (color == null) {
|
|
14516
14711
|
return null;
|
|
14517
14712
|
}
|
|
14713
|
+
components = getColorComponents(color);
|
|
14518
14714
|
}
|
|
14519
|
-
const components = getColorComponents(color);
|
|
14520
14715
|
if (components == null) {
|
|
14521
14716
|
return null;
|
|
14522
14717
|
}
|
|
14523
|
-
if (alpha?.typ === exports.EnumToken.IdenTokenType
|
|
14524
|
-
alpha
|
|
14525
|
-
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
else if (alpha.typ === exports.EnumToken.MathFunctionTokenType &&
|
|
14530
|
-
equalsIgnoreCase(alpha.val, "calc")) {
|
|
14531
|
-
alpha = cloneNode(alpha, true);
|
|
14532
|
-
const alphaValue = components[3] ?? {
|
|
14533
|
-
typ: exports.EnumToken.NumberTokenType,
|
|
14534
|
-
val: 1,
|
|
14535
|
-
};
|
|
14536
|
-
for (const { value, parent } of walkValues(alpha.chi, alpha)) {
|
|
14537
|
-
if (value.typ === exports.EnumToken.IdenTokenType && equalsIgnoreCase(value.val, "alpha")) {
|
|
14538
|
-
replaceNodeOrValue(parent, value, alphaValue);
|
|
14539
|
-
}
|
|
14718
|
+
if (alpha?.typ === exports.EnumToken.IdenTokenType) {
|
|
14719
|
+
if (equalsIgnoreCase(alpha.val, "alpha")) {
|
|
14720
|
+
alpha = components[3] ?? {
|
|
14721
|
+
typ: exports.EnumToken.NumberTokenType,
|
|
14722
|
+
val: 1,
|
|
14723
|
+
};
|
|
14540
14724
|
}
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
14725
|
+
else if (equalsIgnoreCase(alpha.val, "node")) {
|
|
14726
|
+
alpha = {
|
|
14727
|
+
typ: exports.EnumToken.NumberTokenType,
|
|
14728
|
+
val: 0,
|
|
14729
|
+
};
|
|
14544
14730
|
}
|
|
14545
14731
|
}
|
|
14546
14732
|
return makeColor(color.kin, components, alpha);
|
|
@@ -15110,11 +15296,11 @@
|
|
|
15110
15296
|
|
|
15111
15297
|
/**
|
|
15112
15298
|
* Calculate the distance between two okLab colors.
|
|
15113
|
-
* @param okLab1
|
|
15114
|
-
* @param okLab2
|
|
15115
15299
|
*
|
|
15116
15300
|
* @private
|
|
15117
15301
|
* {@link https://drafts.csswg.org/css-color-4/#comparing-color-values}
|
|
15302
|
+
* @param color1
|
|
15303
|
+
* @param color2
|
|
15118
15304
|
*/
|
|
15119
15305
|
function okLabDistance(color1, color2) {
|
|
15120
15306
|
color1 = convertColor(color1, exports.ColorType.OKLAB);
|
|
@@ -15443,6 +15629,300 @@
|
|
|
15443
15629
|
":-moz-ui-valid": ":user-valid",
|
|
15444
15630
|
"::-moz-selection": "::selection",
|
|
15445
15631
|
};
|
|
15632
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/WebKit_Extensions
|
|
15633
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-scrollbar
|
|
15634
|
+
// export const webkitExtensions = new Set([
|
|
15635
|
+
// "-webkit-app-region",
|
|
15636
|
+
// "-webkit-border-horizontal-spacing",
|
|
15637
|
+
// "-webkit-border-vertical-spacing",
|
|
15638
|
+
// "-webkit-box-reflect",
|
|
15639
|
+
// "-webkit-column-axis",
|
|
15640
|
+
// "-webkit-column-progression",
|
|
15641
|
+
// "-webkit-cursor-visibility",
|
|
15642
|
+
// "-webkit-font-smoothing",
|
|
15643
|
+
// "-webkit-hyphenate-limit-after",
|
|
15644
|
+
// "-webkit-hyphenate-limit-before",
|
|
15645
|
+
// "-webkit-hyphenate-limit-lines",
|
|
15646
|
+
// "-webkit-line-align",
|
|
15647
|
+
// "-webkit-line-box-contain",
|
|
15648
|
+
// "-webkit-line-clamp",
|
|
15649
|
+
// "-webkit-line-grid",
|
|
15650
|
+
// "-webkit-line-snap",
|
|
15651
|
+
// "-webkit-locale",
|
|
15652
|
+
// "-webkit-logical-height",
|
|
15653
|
+
// "-webkit-logical-width",
|
|
15654
|
+
// "-webkit-margin-after",
|
|
15655
|
+
// "-webkit-margin-before",
|
|
15656
|
+
// "-webkit-mask-box-image-outset",
|
|
15657
|
+
// "-webkit-mask-box-image-repeat",
|
|
15658
|
+
// "-webkit-mask-box-image-slice",
|
|
15659
|
+
// "-webkit-mask-box-image-source",
|
|
15660
|
+
// "-webkit-mask-box-image-width",
|
|
15661
|
+
// "-webkit-mask-box-image",
|
|
15662
|
+
// "-webkit-mask-composite",
|
|
15663
|
+
// "-webkit-mask-position-x",
|
|
15664
|
+
// "-webkit-mask-position-y",
|
|
15665
|
+
// "-webkit-mask-repeat-x",
|
|
15666
|
+
// "-webkit-mask-repeat-y",
|
|
15667
|
+
// "-webkit-mask-source-type",
|
|
15668
|
+
// "-webkit-max-logical-height",
|
|
15669
|
+
// "-webkit-max-logical-width",
|
|
15670
|
+
// "-webkit-min-logical-height",
|
|
15671
|
+
// "-webkit-min-logical-width",
|
|
15672
|
+
// "-webkit-nbsp-mode",
|
|
15673
|
+
// "-webkit-match-parent",
|
|
15674
|
+
// "-webkit-perspective-origin-x",
|
|
15675
|
+
// "-webkit-perspective-origin-y",
|
|
15676
|
+
// "-webkit-rtl-ordering",
|
|
15677
|
+
// "-webkit-tap-highlight-color",
|
|
15678
|
+
// "-webkit-text-decoration-skip",
|
|
15679
|
+
// "-webkit-text-decorations-in-effect",
|
|
15680
|
+
// "-webkit-text-fill-color",
|
|
15681
|
+
// "-webkit-text-security",
|
|
15682
|
+
// "-webkit-text-stroke-color",
|
|
15683
|
+
// "-webkit-text-stroke-width",
|
|
15684
|
+
// "-webkit-text-stroke",
|
|
15685
|
+
// "-webkit-text-zoom",
|
|
15686
|
+
// "-webkit-touch-callout",
|
|
15687
|
+
// "-webkit-transform-origin-x",
|
|
15688
|
+
// "-webkit-transform-origin-y",
|
|
15689
|
+
// "-webkit-transform-origin-z",
|
|
15690
|
+
// "-webkit-user-drag",
|
|
15691
|
+
// "-webkit-user-modify",
|
|
15692
|
+
// "-webkit-border-after",
|
|
15693
|
+
// "-webkit-border-after-color",
|
|
15694
|
+
// "-webkit-border-after-style",
|
|
15695
|
+
// "-webkit-border-after-width",
|
|
15696
|
+
// "-webkit-border-before",
|
|
15697
|
+
// "-webkit-border-before-color",
|
|
15698
|
+
// "-webkit-border-before-style",
|
|
15699
|
+
// "-webkit-border-before-width",
|
|
15700
|
+
// "-webkit-border-end",
|
|
15701
|
+
// "-webkit-border-end-color",
|
|
15702
|
+
// "-webkit-border-end-style",
|
|
15703
|
+
// "-webkit-border-end-width",
|
|
15704
|
+
// "-webkit-border-start",
|
|
15705
|
+
// "-webkit-border-start-color",
|
|
15706
|
+
// "-webkit-border-start-style",
|
|
15707
|
+
// "-webkit-border-start-width",
|
|
15708
|
+
// "-webkit-box-align",
|
|
15709
|
+
// "-webkit-box-direction",
|
|
15710
|
+
// "-webkit-box-flex-group",
|
|
15711
|
+
// "-webkit-box-flex",
|
|
15712
|
+
// "-webkit-box-lines",
|
|
15713
|
+
// "-webkit-box-ordinal-group",
|
|
15714
|
+
// "-webkit-box-orient",
|
|
15715
|
+
// "-webkit-box-pack",
|
|
15716
|
+
// "-webkit-column-break-after",
|
|
15717
|
+
// "-webkit-column-break-before",
|
|
15718
|
+
// "-webkit-column-break-inside",
|
|
15719
|
+
// "-webkit-font-feature-settings",
|
|
15720
|
+
// "-webkit-hyphenate-character",
|
|
15721
|
+
// "-webkit-initial-letter",
|
|
15722
|
+
// "-webkit-margin-end",
|
|
15723
|
+
// "-webkit-margin-start",
|
|
15724
|
+
// "-webkit-padding-after",
|
|
15725
|
+
// "-webkit-padding-before",
|
|
15726
|
+
// "-webkit-padding-end",
|
|
15727
|
+
// "-webkit-padding-start",
|
|
15728
|
+
// "-webkit-fill-available",
|
|
15729
|
+
// ":-webkit-animating-full-screen-transition",
|
|
15730
|
+
// ":-webkit-any",
|
|
15731
|
+
// ":-webkit-any-link",
|
|
15732
|
+
// ":-webkit-autofill",
|
|
15733
|
+
// ":-webkit-autofill-strong-password",
|
|
15734
|
+
// ":-webkit-drag",
|
|
15735
|
+
// ":-webkit-full-page-media",
|
|
15736
|
+
// ":-webkit-full-screen*",
|
|
15737
|
+
// ":-webkit-full-screen-ancestor",
|
|
15738
|
+
// ":-webkit-full-screen-document",
|
|
15739
|
+
// ":-webkit-full-screen-controls-hidden",
|
|
15740
|
+
// "::-webkit-file-upload-button*",
|
|
15741
|
+
// "::-webkit-inner-spin-button",
|
|
15742
|
+
// "::-webkit-input-placeholder",
|
|
15743
|
+
// "::-webkit-meter-bar",
|
|
15744
|
+
// "::-webkit-meter-even-less-good-value",
|
|
15745
|
+
// "::-webkit-meter-inner-element",
|
|
15746
|
+
// "::-webkit-meter-optimum-value",
|
|
15747
|
+
// "::-webkit-meter-suboptimum-value",
|
|
15748
|
+
// "::-webkit-progress-bar",
|
|
15749
|
+
// "::-webkit-progress-inner-element",
|
|
15750
|
+
// "::-webkit-progress-value",
|
|
15751
|
+
// "::-webkit-search-cancel-button",
|
|
15752
|
+
// "::-webkit-search-results-button",
|
|
15753
|
+
// "::-webkit-slider-runnable-track",
|
|
15754
|
+
// "::-webkit-slider-thumb",
|
|
15755
|
+
// "-webkit-animation",
|
|
15756
|
+
// "-webkit-device-pixel-ratio",
|
|
15757
|
+
// "-webkit-transform-2d",
|
|
15758
|
+
// "-webkit-transform-3d",
|
|
15759
|
+
// "-webkit-transition",
|
|
15760
|
+
// "::-webkit-scrollbar",
|
|
15761
|
+
// "::-webkit-scrollbar-button",
|
|
15762
|
+
// "::-webkit-scrollbar",
|
|
15763
|
+
// "::-webkit-scrollbar-thumb",
|
|
15764
|
+
// "::-webkit-scrollbar-track",
|
|
15765
|
+
// "::-webkit-scrollbar-track-piece",
|
|
15766
|
+
// "::-webkit-scrollbar:vertical",
|
|
15767
|
+
// "::-webkit-scrollbar-corner ",
|
|
15768
|
+
// "::-webkit-resizer",
|
|
15769
|
+
// ":vertical",
|
|
15770
|
+
// ":horizontal",
|
|
15771
|
+
// ]);
|
|
15772
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions
|
|
15773
|
+
// export const mozExtensions = new Set([
|
|
15774
|
+
// "-moz-box-align",
|
|
15775
|
+
// "-moz-box-direction",
|
|
15776
|
+
// "-moz-box-flex",
|
|
15777
|
+
// "-moz-box-ordinal-group",
|
|
15778
|
+
// "-moz-box-orient",
|
|
15779
|
+
// "-moz-box-pack",
|
|
15780
|
+
// "-moz-float-edge",
|
|
15781
|
+
// "-moz-force-broken-image-icon",
|
|
15782
|
+
// "-moz-image-region",
|
|
15783
|
+
// "-moz-orient",
|
|
15784
|
+
// "-moz-osx-font-smoothing",
|
|
15785
|
+
// "-moz-user-focus",
|
|
15786
|
+
// "-moz-user-input",
|
|
15787
|
+
// "-moz-user-modify",
|
|
15788
|
+
// "-moz-animation",
|
|
15789
|
+
// "-moz-animation-delay",
|
|
15790
|
+
// "-moz-animation-direction",
|
|
15791
|
+
// "-moz-animation-duration",
|
|
15792
|
+
// "-moz-animation-fill-mode",
|
|
15793
|
+
// "-moz-animation-iteration-count",
|
|
15794
|
+
// "-moz-animation-name",
|
|
15795
|
+
// "-moz-animation-play-state",
|
|
15796
|
+
// "-moz-animation-timing-function",
|
|
15797
|
+
// "-moz-appearance",
|
|
15798
|
+
// "-moz-backface-visibility",
|
|
15799
|
+
// "-moz-background-clip",
|
|
15800
|
+
// "-moz-background-origin",
|
|
15801
|
+
// "-moz-background-inline-policy",
|
|
15802
|
+
// "-moz-background-size",
|
|
15803
|
+
// "-moz-border-end",
|
|
15804
|
+
// "-moz-border-end-color",
|
|
15805
|
+
// "-moz-border-end-style",
|
|
15806
|
+
// "-moz-border-end-width",
|
|
15807
|
+
// "-moz-border-image",
|
|
15808
|
+
// "-moz-border-start",
|
|
15809
|
+
// "-moz-border-start-color",
|
|
15810
|
+
// "-moz-border-start-style",
|
|
15811
|
+
// "-moz-border-start-width",
|
|
15812
|
+
// "-moz-box-sizing",
|
|
15813
|
+
// "clip-path",
|
|
15814
|
+
// "-moz-column-count",
|
|
15815
|
+
// "-moz-column-fill",
|
|
15816
|
+
// "-moz-column-gap",
|
|
15817
|
+
// "-moz-column-width",
|
|
15818
|
+
// "-moz-column-rule",
|
|
15819
|
+
// "-moz-column-rule-width",
|
|
15820
|
+
// "-moz-column-rule-style",
|
|
15821
|
+
// "-moz-column-rule-color",
|
|
15822
|
+
// "filter",
|
|
15823
|
+
// "-moz-font-feature-settings",
|
|
15824
|
+
// "-moz-font-language-override",
|
|
15825
|
+
// "-moz-hyphens",
|
|
15826
|
+
// "-moz-margin-end",
|
|
15827
|
+
// "-moz-margin-start",
|
|
15828
|
+
// "mask",
|
|
15829
|
+
// "-moz-opacity",
|
|
15830
|
+
// "-moz-outline",
|
|
15831
|
+
// "-moz-outline-color",
|
|
15832
|
+
// "-moz-outline-offset",
|
|
15833
|
+
// "-moz-outline-style",
|
|
15834
|
+
// "-moz-outline-width",
|
|
15835
|
+
// "-moz-padding-end",
|
|
15836
|
+
// "-moz-padding-start",
|
|
15837
|
+
// "-moz-perspective",
|
|
15838
|
+
// "-moz-perspective-origin",
|
|
15839
|
+
// "pointer-events",
|
|
15840
|
+
// "-moz-tab-size",
|
|
15841
|
+
// "-moz-text-align-last",
|
|
15842
|
+
// "-moz-text-decoration-color",
|
|
15843
|
+
// "-moz-text-decoration-line",
|
|
15844
|
+
// "-moz-text-decoration-style",
|
|
15845
|
+
// "-moz-text-size-adjust",
|
|
15846
|
+
// "-moz-transform",
|
|
15847
|
+
// "-moz-transform-origin",
|
|
15848
|
+
// "-moz-transform-style",
|
|
15849
|
+
// "-moz-transition",
|
|
15850
|
+
// "-moz-transition-delay",
|
|
15851
|
+
// "-moz-transition-duration",
|
|
15852
|
+
// "-moz-transition-property",
|
|
15853
|
+
// "-moz-transition-timing-function",
|
|
15854
|
+
// "-moz-user-select",
|
|
15855
|
+
// "-moz-initial",
|
|
15856
|
+
// "-moz-appearance",
|
|
15857
|
+
// "-moz-linear-gradient",
|
|
15858
|
+
// "-moz-radial-gradient",
|
|
15859
|
+
// "-moz-element",
|
|
15860
|
+
// "-moz-image-rect",
|
|
15861
|
+
// "::-moz-anonymous-block",
|
|
15862
|
+
// "::-moz-anonymous-positioned-block",
|
|
15863
|
+
// ":-moz-any",
|
|
15864
|
+
// ":-moz-any-link",
|
|
15865
|
+
// ":-moz-broken",
|
|
15866
|
+
// "::-moz-canvas",
|
|
15867
|
+
// "::-moz-color-swatch",
|
|
15868
|
+
// "::-moz-cell-content",
|
|
15869
|
+
// ":-moz-drag-over",
|
|
15870
|
+
// ":-moz-first-node",
|
|
15871
|
+
// "::-moz-focus-inner",
|
|
15872
|
+
// "::-moz-focus-outer",
|
|
15873
|
+
// ":-moz-full-screen",
|
|
15874
|
+
// ":-moz-full-screen-ancestor",
|
|
15875
|
+
// ":-moz-handler-blocked",
|
|
15876
|
+
// ":-moz-handler-crashed",
|
|
15877
|
+
// ":-moz-handler-disabled",
|
|
15878
|
+
// "::-moz-inline-table",
|
|
15879
|
+
// ":-moz-last-node",
|
|
15880
|
+
// "::-moz-list-bullet",
|
|
15881
|
+
// "::-moz-list-number",
|
|
15882
|
+
// ":-moz-loading",
|
|
15883
|
+
// ":-moz-locale-dir",
|
|
15884
|
+
// ":-moz-locale-dir",
|
|
15885
|
+
// ":-moz-lwtheme",
|
|
15886
|
+
// ":-moz-lwtheme-brighttext",
|
|
15887
|
+
// ":-moz-lwtheme-darktext",
|
|
15888
|
+
// "::-moz-meter-bar",
|
|
15889
|
+
// ":-moz-native-anonymous",
|
|
15890
|
+
// ":-moz-only-whitespace",
|
|
15891
|
+
// "::-moz-pagebreak",
|
|
15892
|
+
// "::-moz-pagecontent",
|
|
15893
|
+
// ":-moz-placeholder",
|
|
15894
|
+
// "::-moz-placeholder",
|
|
15895
|
+
// "::-moz-progress-bar",
|
|
15896
|
+
// "::-moz-range-progress",
|
|
15897
|
+
// "::-moz-range-thumb",
|
|
15898
|
+
// "::-moz-range-track",
|
|
15899
|
+
// ":-moz-read-only",
|
|
15900
|
+
// ":-moz-read-write",
|
|
15901
|
+
// "::-moz-scrolled-canvas",
|
|
15902
|
+
// "::-moz-scrolled-content",
|
|
15903
|
+
// "::-moz-selection",
|
|
15904
|
+
// ":-moz-submit-invalid",
|
|
15905
|
+
// ":-moz-suppressed",
|
|
15906
|
+
// "::-moz-svg-foreign-content",
|
|
15907
|
+
// "::-moz-table",
|
|
15908
|
+
// "::-moz-table-cell",
|
|
15909
|
+
// "::-moz-table-column",
|
|
15910
|
+
// "::-moz-table-column-group",
|
|
15911
|
+
// "::-moz-table-outer",
|
|
15912
|
+
// "::-moz-table-row",
|
|
15913
|
+
// "::-moz-table-row-group",
|
|
15914
|
+
// ":-moz-ui-invalid",
|
|
15915
|
+
// ":-moz-ui-valid",
|
|
15916
|
+
// ":-moz-user-disabled",
|
|
15917
|
+
// "::-moz-viewport",
|
|
15918
|
+
// "::-moz-viewport-scroll",
|
|
15919
|
+
// ":-moz-window-inactive",
|
|
15920
|
+
// "-moz-device-pixel-ratio",
|
|
15921
|
+
// "-moz-os-version",
|
|
15922
|
+
// "-moz-touch-enabled",
|
|
15923
|
+
// "-moz-windows-glass",
|
|
15924
|
+
// "-moz-alt-content",
|
|
15925
|
+
// ]);
|
|
15446
15926
|
// renamed standard properties
|
|
15447
15927
|
const renamedStandardProperties = new Map([["color-adjust", "print-color-adjust"]]);
|
|
15448
15928
|
function isLength(dimension) {
|
|
@@ -15460,6 +15940,34 @@
|
|
|
15460
15940
|
function isFrequency(dimension) {
|
|
15461
15941
|
return "unit" in dimension && frequencyUnits.includes(dimension.unit.toLowerCase());
|
|
15462
15942
|
}
|
|
15943
|
+
/**
|
|
15944
|
+
* Is color space
|
|
15945
|
+
* @param token
|
|
15946
|
+
* @returns
|
|
15947
|
+
*/
|
|
15948
|
+
// export function isColorspace(token: Token): boolean {
|
|
15949
|
+
// return (
|
|
15950
|
+
// token.typ === EnumToken.IdenTokenType &&
|
|
15951
|
+
// [
|
|
15952
|
+
// "srgb",
|
|
15953
|
+
// "srgb-linear",
|
|
15954
|
+
// "lab",
|
|
15955
|
+
// "oklab",
|
|
15956
|
+
// "lch",
|
|
15957
|
+
// "oklch",
|
|
15958
|
+
// "xyz",
|
|
15959
|
+
// "xyz-d50",
|
|
15960
|
+
// "xyz-d65",
|
|
15961
|
+
// "display-p3",
|
|
15962
|
+
// "a98-rgb",
|
|
15963
|
+
// "prophoto-rgb",
|
|
15964
|
+
// "rec2020",
|
|
15965
|
+
// "rgb",
|
|
15966
|
+
// "hsl",
|
|
15967
|
+
// "hwb",
|
|
15968
|
+
// ].includes((token as IdentToken).val.toLowerCase())
|
|
15969
|
+
// );
|
|
15970
|
+
// }
|
|
15463
15971
|
/**
|
|
15464
15972
|
* Reduce color stops
|
|
15465
15973
|
* @param stops
|
|
@@ -15657,6 +16165,26 @@
|
|
|
15657
16165
|
return (token.typ === exports.EnumToken.IdenTokenType &&
|
|
15658
16166
|
["hsl", "hwb", "lch", "oklch"].some((t) => equalsIgnoreCase(t, token.val)));
|
|
15659
16167
|
}
|
|
16168
|
+
/**
|
|
16169
|
+
* Is hue interpolation method
|
|
16170
|
+
* @param token
|
|
16171
|
+
* @returns
|
|
16172
|
+
*/
|
|
16173
|
+
// export function isHueInterpolationMethod(token: Token | Token[]): boolean {
|
|
16174
|
+
// if (!Array.isArray(token)) {
|
|
16175
|
+
// return token.typ == EnumToken.IdenTokenType && "hue" === (token as IdentToken).val?.toLowerCase?.();
|
|
16176
|
+
// }
|
|
16177
|
+
//
|
|
16178
|
+
// if (token.length != 2 || token[0].typ != EnumToken.IdenTokenType || token[1].typ != EnumToken.IdenTokenType) {
|
|
16179
|
+
// return false;
|
|
16180
|
+
// }
|
|
16181
|
+
//
|
|
16182
|
+
// return (
|
|
16183
|
+
// ["shorter", "longer", "increasing", "decreasing"].some((t) =>
|
|
16184
|
+
// equalsIgnoreCase(t, (token[0] as IdentToken).val ?? ""),
|
|
16185
|
+
// ) && "hue" === (token[1] as IdentToken).val?.toLowerCase?.()
|
|
16186
|
+
// );
|
|
16187
|
+
// }
|
|
15660
16188
|
/**
|
|
15661
16189
|
* Is ident color
|
|
15662
16190
|
* @param token
|
|
@@ -15667,6 +16195,12 @@
|
|
|
15667
16195
|
[exports.ColorType.SYS, exports.ColorType.DPSYS, exports.ColorType.LIT].includes(token.kin) &&
|
|
15668
16196
|
isIdent(token.val));
|
|
15669
16197
|
}
|
|
16198
|
+
// export function isPercentageToken(token: Token): boolean {
|
|
16199
|
+
// return (
|
|
16200
|
+
// token.typ == EnumToken.PercentageTokenType ||
|
|
16201
|
+
// (token.typ == EnumToken.NumberTokenType && (token as NumberToken).val == 0)
|
|
16202
|
+
// );
|
|
16203
|
+
// }
|
|
15670
16204
|
function isColor(token, errors) {
|
|
15671
16205
|
if (token.typ == exports.EnumToken.WildCardFunctionTokenType) {
|
|
15672
16206
|
return true;
|
|
@@ -15930,21 +16464,33 @@
|
|
|
15930
16464
|
return true;
|
|
15931
16465
|
}
|
|
15932
16466
|
else {
|
|
15933
|
-
//
|
|
15934
|
-
|
|
15935
|
-
|
|
15936
|
-
|
|
15937
|
-
|
|
16467
|
+
// const keywords: string[] = ["from", "none"];
|
|
16468
|
+
//
|
|
16469
|
+
// // @ts-ignore
|
|
16470
|
+
// if (
|
|
16471
|
+
// ["rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch"].some((t) =>
|
|
16472
|
+
// equalsIgnoreCase(t, (token as ColorToken).val),
|
|
16473
|
+
// )
|
|
16474
|
+
// ) {
|
|
16475
|
+
// // @ts-ignore
|
|
16476
|
+
// keywords.push("alpha");
|
|
16477
|
+
//
|
|
16478
|
+
// for (const keyword of (token as ColorToken).val.slice(-3).split("")) {
|
|
16479
|
+
// keywords.push(keyword);
|
|
16480
|
+
// }
|
|
16481
|
+
// }
|
|
15938
16482
|
// @ts-ignore
|
|
15939
16483
|
for (const v of token.chi) {
|
|
15940
|
-
if (v.typ ==
|
|
15941
|
-
|
|
15942
|
-
}
|
|
15943
|
-
if (
|
|
15944
|
-
|
|
15945
|
-
|
|
15946
|
-
|
|
15947
|
-
|
|
16484
|
+
// if (v.typ == EnumToken.IdenTokenType) {
|
|
16485
|
+
// continue;
|
|
16486
|
+
// }
|
|
16487
|
+
// if (
|
|
16488
|
+
// v.typ === EnumToken.MathFunctionTokenType ||
|
|
16489
|
+
// v.typ === EnumToken.WildCardFunctionTokenType ||
|
|
16490
|
+
// colorsFunc.includes(v.val)
|
|
16491
|
+
// ) {
|
|
16492
|
+
// continue;
|
|
16493
|
+
// }
|
|
15948
16494
|
}
|
|
15949
16495
|
}
|
|
15950
16496
|
return true;
|
|
@@ -16090,6 +16636,44 @@
|
|
|
16090
16636
|
codepoint == 0x7f ||
|
|
16091
16637
|
(codepoint >= 0xe && codepoint <= 0x1f));
|
|
16092
16638
|
}
|
|
16639
|
+
// export function isURLToken(str: string): boolean {
|
|
16640
|
+
// let i: number = -1;
|
|
16641
|
+
// let c: number;
|
|
16642
|
+
//
|
|
16643
|
+
// while (++i < str.length) {
|
|
16644
|
+
// c = str.charCodeAt(i) as number;
|
|
16645
|
+
//
|
|
16646
|
+
// // single quote or double quote or start parenthesis or close parenthesis
|
|
16647
|
+
// if (isNonPrintable(c) || c == 0x27 || c == 0x22 || c == 0x28 || c == 0x29) {
|
|
16648
|
+
// return false;
|
|
16649
|
+
// }
|
|
16650
|
+
//
|
|
16651
|
+
// // valid escape
|
|
16652
|
+
// if (c == REVERSE_SOLIDUS) {
|
|
16653
|
+
// i++;
|
|
16654
|
+
//
|
|
16655
|
+
// if (i >= str.length) {
|
|
16656
|
+
// return false;
|
|
16657
|
+
// }
|
|
16658
|
+
//
|
|
16659
|
+
// c = str.charCodeAt(i) as number;
|
|
16660
|
+
//
|
|
16661
|
+
// // c is not '\n' or '\r' or '\f'
|
|
16662
|
+
// if (c == 0x6e || c == 0x72 || c == 0x66) {
|
|
16663
|
+
// return false;
|
|
16664
|
+
// }
|
|
16665
|
+
//
|
|
16666
|
+
// continue;
|
|
16667
|
+
// }
|
|
16668
|
+
//
|
|
16669
|
+
// // is white space
|
|
16670
|
+
// if (c == 0x20 || c == 0x09) {
|
|
16671
|
+
// break;
|
|
16672
|
+
// }
|
|
16673
|
+
// }
|
|
16674
|
+
//
|
|
16675
|
+
// return i == str.length;
|
|
16676
|
+
// }
|
|
16093
16677
|
function isPseudo(name) {
|
|
16094
16678
|
return (name.charAt(0) == ":" &&
|
|
16095
16679
|
((name.endsWith("(") && isIdent(name.charAt(1) == ":" ? name.slice(2, -1) : name.slice(1, -1))) ||
|
|
@@ -16098,6 +16682,94 @@
|
|
|
16098
16682
|
function isHash(name) {
|
|
16099
16683
|
return name.charAt(0) == "#" && isIdentStart(name.charCodeAt(1));
|
|
16100
16684
|
}
|
|
16685
|
+
// export const isNumber = memoize(function (name: string): boolean {
|
|
16686
|
+
// let codepoint: number = name.charCodeAt(0) as number;
|
|
16687
|
+
// let i: number = 0;
|
|
16688
|
+
// const j: number = name.length;
|
|
16689
|
+
//
|
|
16690
|
+
// if (j == 1 && !isDigit(codepoint)) {
|
|
16691
|
+
// return false;
|
|
16692
|
+
// }
|
|
16693
|
+
//
|
|
16694
|
+
// // '+' '-'
|
|
16695
|
+
// if ([0x2b, 0x2d].includes(codepoint)) {
|
|
16696
|
+
// i++;
|
|
16697
|
+
// }
|
|
16698
|
+
//
|
|
16699
|
+
// // consume digits
|
|
16700
|
+
// while (i < j) {
|
|
16701
|
+
// codepoint = name.charCodeAt(i) as number;
|
|
16702
|
+
//
|
|
16703
|
+
// if (isDigit(codepoint)) {
|
|
16704
|
+
// i++;
|
|
16705
|
+
// continue;
|
|
16706
|
+
// }
|
|
16707
|
+
//
|
|
16708
|
+
// // '.' 'E' 'e'
|
|
16709
|
+
// if (codepoint == 0x2e || codepoint == 0x45 || codepoint == 0x65) {
|
|
16710
|
+
// break;
|
|
16711
|
+
// }
|
|
16712
|
+
//
|
|
16713
|
+
// return false;
|
|
16714
|
+
// }
|
|
16715
|
+
//
|
|
16716
|
+
// // '.'
|
|
16717
|
+
// if (codepoint == 0x2e) {
|
|
16718
|
+
// if (!isDigit(name.charCodeAt(++i) as number)) {
|
|
16719
|
+
// return false;
|
|
16720
|
+
// }
|
|
16721
|
+
// }
|
|
16722
|
+
//
|
|
16723
|
+
// while (i < j) {
|
|
16724
|
+
// codepoint = name.charCodeAt(i) as number;
|
|
16725
|
+
//
|
|
16726
|
+
// if (isDigit(codepoint)) {
|
|
16727
|
+
// i++;
|
|
16728
|
+
// continue;
|
|
16729
|
+
// }
|
|
16730
|
+
//
|
|
16731
|
+
// // 'E' 'e'
|
|
16732
|
+
// if (codepoint == 0x45 || codepoint == 0x65) {
|
|
16733
|
+
// i++;
|
|
16734
|
+
// break;
|
|
16735
|
+
// }
|
|
16736
|
+
//
|
|
16737
|
+
// return false;
|
|
16738
|
+
// }
|
|
16739
|
+
//
|
|
16740
|
+
// // 'E' 'e'
|
|
16741
|
+
// if (codepoint == 0x45 || codepoint == 0x65) {
|
|
16742
|
+
// // if (i == j) {
|
|
16743
|
+
// // return false;
|
|
16744
|
+
// // }
|
|
16745
|
+
//
|
|
16746
|
+
// codepoint = name.charCodeAt(i + 1) as number;
|
|
16747
|
+
//
|
|
16748
|
+
// // '+' '-'
|
|
16749
|
+
// // if ([0x2b, 0x2d].includes(codepoint)) {
|
|
16750
|
+
// // i++;
|
|
16751
|
+
// // }
|
|
16752
|
+
//
|
|
16753
|
+
// codepoint = name.charCodeAt(i + 1) as number;
|
|
16754
|
+
//
|
|
16755
|
+
// if (!isDigit(codepoint)) {
|
|
16756
|
+
// return false;
|
|
16757
|
+
// }
|
|
16758
|
+
// }
|
|
16759
|
+
//
|
|
16760
|
+
// // while (++i < j) {
|
|
16761
|
+
// // codepoint = name.charCodeAt(i) as number;
|
|
16762
|
+
//
|
|
16763
|
+
// // if (!isDigit(codepoint)) {
|
|
16764
|
+
// // return false;
|
|
16765
|
+
// // }
|
|
16766
|
+
// // }
|
|
16767
|
+
//
|
|
16768
|
+
// return true;
|
|
16769
|
+
// }) as (name: string) => boolean;
|
|
16770
|
+
// export function isPercentage(name: string) {
|
|
16771
|
+
// return name.endsWith("%") && isNumber(name.slice(0, -1));
|
|
16772
|
+
// }
|
|
16101
16773
|
function isFlex(dimension) {
|
|
16102
16774
|
return "unit" in dimension && "fr" == dimension.unit.toLowerCase();
|
|
16103
16775
|
}
|
|
@@ -16152,9 +16824,33 @@
|
|
|
16152
16824
|
}
|
|
16153
16825
|
return dimension;
|
|
16154
16826
|
}
|
|
16827
|
+
// export function isHexColor(name: string): boolean {
|
|
16828
|
+
// if (name.charAt(0) != "#" || ![4, 5, 7, 9].includes(name.length)) {
|
|
16829
|
+
// return false;
|
|
16830
|
+
// }
|
|
16831
|
+
//
|
|
16832
|
+
// for (let chr of name.slice(1)) {
|
|
16833
|
+
// let codepoint: number = chr.charCodeAt(0) as number;
|
|
16834
|
+
//
|
|
16835
|
+
// if (
|
|
16836
|
+
// !isDigit(codepoint) &&
|
|
16837
|
+
// // A-F
|
|
16838
|
+
// !(codepoint >= 0x41 && codepoint <= 0x46) &&
|
|
16839
|
+
// // a-f
|
|
16840
|
+
// !(codepoint >= 0x61 && codepoint <= 0x66)
|
|
16841
|
+
// ) {
|
|
16842
|
+
// return false;
|
|
16843
|
+
// }
|
|
16844
|
+
// }
|
|
16845
|
+
//
|
|
16846
|
+
// return true;
|
|
16847
|
+
// }
|
|
16155
16848
|
function isFunction(name) {
|
|
16156
16849
|
return name.endsWith("(") && isIdent(name.slice(0, -1));
|
|
16157
16850
|
}
|
|
16851
|
+
// export function isAtKeyword(name: string): boolean {
|
|
16852
|
+
// return name.charCodeAt(0) == 0x40 && isIdent(name.slice(1));
|
|
16853
|
+
// }
|
|
16158
16854
|
function isNewLine(codepoint) {
|
|
16159
16855
|
// \n \r \f \v
|
|
16160
16856
|
return (codepoint == 0xa ||
|
|
@@ -16175,6 +16871,32 @@
|
|
|
16175
16871
|
codepoint == 0x2028 ||
|
|
16176
16872
|
codepoint == 0x2029);
|
|
16177
16873
|
}
|
|
16874
|
+
// export function isValue(token: Token) {
|
|
16875
|
+
// if (token == null) {
|
|
16876
|
+
// return false;
|
|
16877
|
+
// }
|
|
16878
|
+
//
|
|
16879
|
+
// return (
|
|
16880
|
+
// token.typ === EnumToken.IdenTokenType ||
|
|
16881
|
+
// token.typ === EnumToken.DimensionTokenType ||
|
|
16882
|
+
// token.typ === EnumToken.LengthTokenType ||
|
|
16883
|
+
// token.typ === EnumToken.AngleTokenType ||
|
|
16884
|
+
// token.typ === EnumToken.FlexTokenType ||
|
|
16885
|
+
// token.typ === EnumToken.TimeTokenType ||
|
|
16886
|
+
// token.typ === EnumToken.ResolutionTokenType ||
|
|
16887
|
+
// token.typ === EnumToken.FrequencyTokenType ||
|
|
16888
|
+
// token.typ === EnumToken.NumberTokenType ||
|
|
16889
|
+
// token.typ === EnumToken.ColorTokenType ||
|
|
16890
|
+
// token.typ === EnumToken.FunctionTokenType ||
|
|
16891
|
+
// token.typ === EnumToken.UrlFunctionTokenType ||
|
|
16892
|
+
// token.typ === EnumToken.GridTemplateFuncTokenType ||
|
|
16893
|
+
// token.typ === EnumToken.ImageFunctionTokenType ||
|
|
16894
|
+
// token.typ === EnumToken.TimelineFunctionTokenType ||
|
|
16895
|
+
// token.typ === EnumToken.TimingFunctionTokenType ||
|
|
16896
|
+
// token.typ === EnumToken.MathFunctionTokenType ||
|
|
16897
|
+
// token.typ === EnumToken.TransformFunctionTokenType
|
|
16898
|
+
// );
|
|
16899
|
+
// }
|
|
16178
16900
|
// https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Values_and_units#absolute_length_units
|
|
16179
16901
|
/**
|
|
16180
16902
|
* Convert length to px
|
|
@@ -16257,6 +16979,12 @@
|
|
|
16257
16979
|
return angle;
|
|
16258
16980
|
}
|
|
16259
16981
|
|
|
16982
|
+
/**
|
|
16983
|
+
*
|
|
16984
|
+
* @param a
|
|
16985
|
+
* @param b
|
|
16986
|
+
* @returns
|
|
16987
|
+
*/
|
|
16260
16988
|
function eq(a, b) {
|
|
16261
16989
|
if (a == null || b == null) {
|
|
16262
16990
|
return a == b;
|
|
@@ -16336,7 +17064,6 @@
|
|
|
16336
17064
|
token.val = pseudoAliasMap[token.val];
|
|
16337
17065
|
if ((equalsIgnoreCase(token.val, "min-resolution") ||
|
|
16338
17066
|
equalsIgnoreCase(token.val, "max-resolution")) &&
|
|
16339
|
-
// ["min-resolution", "max-resolution"].includes((token as IdentToken).val) &&
|
|
16340
17067
|
value.r?.[0]?.typ == exports.EnumToken.NumberTokenType) {
|
|
16341
17068
|
Object.assign(value.r?.[0], {
|
|
16342
17069
|
typ: exports.EnumToken.ResolutionTokenType,
|
|
@@ -16344,6 +17071,14 @@
|
|
|
16344
17071
|
});
|
|
16345
17072
|
result = true;
|
|
16346
17073
|
}
|
|
17074
|
+
let isMin = token.val.startsWith("min-");
|
|
17075
|
+
let isMax = token.val.startsWith("max-");
|
|
17076
|
+
if (isMin || isMax) {
|
|
17077
|
+
token.val = token.val.slice(4);
|
|
17078
|
+
value.op.typ = isMax
|
|
17079
|
+
? exports.EnumToken.LteTokenType
|
|
17080
|
+
: exports.EnumToken.GteTokenType;
|
|
17081
|
+
}
|
|
16347
17082
|
}
|
|
16348
17083
|
}
|
|
16349
17084
|
}
|
|
@@ -16376,6 +17111,7 @@
|
|
|
16376
17111
|
}
|
|
16377
17112
|
}
|
|
16378
17113
|
}
|
|
17114
|
+
// remove duplicate tokens
|
|
16379
17115
|
if (tokens.find((t) => t.typ == exports.EnumToken.CommaTokenType) != null) {
|
|
16380
17116
|
const set = new Set();
|
|
16381
17117
|
const split = splitTokenList(tokens, [exports.EnumToken.CommaTokenType]);
|
|
@@ -19581,6 +20317,7 @@
|
|
|
19581
20317
|
/**
|
|
19582
20318
|
* convert input to hex
|
|
19583
20319
|
* @param input
|
|
20320
|
+
* @param length
|
|
19584
20321
|
*/
|
|
19585
20322
|
function toHex(input, length) {
|
|
19586
20323
|
let result = "";
|
|
@@ -19656,18 +20393,17 @@
|
|
|
19656
20393
|
class PropertyList {
|
|
19657
20394
|
options = { removeDuplicateDeclarations: true, computeShorthand: true };
|
|
19658
20395
|
declarations;
|
|
19659
|
-
// ketsey = new Map;
|
|
19660
20396
|
constructor(options = {}) {
|
|
19661
20397
|
this.options = options;
|
|
19662
20398
|
this.declarations = new Map();
|
|
19663
20399
|
}
|
|
19664
|
-
set(nam, value) {
|
|
19665
|
-
|
|
19666
|
-
|
|
19667
|
-
|
|
19668
|
-
|
|
19669
|
-
|
|
19670
|
-
}
|
|
20400
|
+
// set(nam: string, value: string | Token[]) {
|
|
20401
|
+
// return this.add({
|
|
20402
|
+
// typ: EnumToken.DeclarationNodeType,
|
|
20403
|
+
// nam,
|
|
20404
|
+
// val: Array.isArray(value) ? value : parseString(String(value)),
|
|
20405
|
+
// });
|
|
20406
|
+
// }
|
|
19671
20407
|
add(...declarations) {
|
|
19672
20408
|
let name;
|
|
19673
20409
|
let syntaxRules = null;
|
|
@@ -19886,7 +20622,7 @@
|
|
|
19886
20622
|
}
|
|
19887
20623
|
}
|
|
19888
20624
|
run(ast, options) {
|
|
19889
|
-
if (!("chi" in ast)) {
|
|
20625
|
+
if (!("chi" in ast || ast.chi?.length == 0)) {
|
|
19890
20626
|
return null;
|
|
19891
20627
|
}
|
|
19892
20628
|
// @ts-ignore
|
|
@@ -19929,6 +20665,104 @@
|
|
|
19929
20665
|
}
|
|
19930
20666
|
}
|
|
19931
20667
|
|
|
20668
|
+
const trimTokenSpace = new Set([
|
|
20669
|
+
exports.EnumToken.CommaTokenType,
|
|
20670
|
+
exports.EnumToken.DelimTokenType,
|
|
20671
|
+
exports.EnumToken.GtTokenType,
|
|
20672
|
+
exports.EnumToken.GteTokenType,
|
|
20673
|
+
exports.EnumToken.LtTokenType,
|
|
20674
|
+
exports.EnumToken.LteTokenType,
|
|
20675
|
+
exports.EnumToken.ChildCombinatorTokenType,
|
|
20676
|
+
]);
|
|
20677
|
+
const trimSpaceAfter = new Set([
|
|
20678
|
+
...tokensfuncSet.values(),
|
|
20679
|
+
exports.EnumToken.ChildCombinatorTokenType,
|
|
20680
|
+
exports.EnumToken.SupportsQueryConditionTokenType,
|
|
20681
|
+
exports.EnumToken.SupportsQueryUnaryConditionTokenType,
|
|
20682
|
+
]);
|
|
20683
|
+
/**
|
|
20684
|
+
* Replace token in its parent node
|
|
20685
|
+
* @param parent
|
|
20686
|
+
* @param node
|
|
20687
|
+
* @param replacement
|
|
20688
|
+
* @throws TypeError replacement is null
|
|
20689
|
+
* @throws ReferenceError node not found in parent
|
|
20690
|
+
*/
|
|
20691
|
+
function replaceNodeOrValue(parent, node, replacement) {
|
|
20692
|
+
if (replacement == null || (Array.isArray(replacement) && replacement.length === 0)) {
|
|
20693
|
+
throw new TypeError(`replacement is null`);
|
|
20694
|
+
}
|
|
20695
|
+
for (const newNode of Array.isArray(replacement) ? replacement : [replacement]) {
|
|
20696
|
+
if (newNode[PARENT] != node[PARENT]) {
|
|
20697
|
+
newNode[PARENT] = node[PARENT];
|
|
20698
|
+
}
|
|
20699
|
+
}
|
|
20700
|
+
if (parent.typ == exports.EnumToken.BinaryExpressionTokenType) {
|
|
20701
|
+
if (parent.l == node) {
|
|
20702
|
+
parent.l = replacement;
|
|
20703
|
+
}
|
|
20704
|
+
else if (parent.r == node) {
|
|
20705
|
+
parent.r = replacement;
|
|
20706
|
+
}
|
|
20707
|
+
else {
|
|
20708
|
+
throw new ReferenceError("Node not found");
|
|
20709
|
+
}
|
|
20710
|
+
}
|
|
20711
|
+
else {
|
|
20712
|
+
const target = "val" in parent && Array.isArray(parent.val)
|
|
20713
|
+
? parent.val
|
|
20714
|
+
: (parent.chi ?? parent);
|
|
20715
|
+
if (Array.isArray(target)) {
|
|
20716
|
+
// @ts-ignore
|
|
20717
|
+
const index = target.indexOf(node);
|
|
20718
|
+
if (index == -1) {
|
|
20719
|
+
throw new ReferenceError("Node not found");
|
|
20720
|
+
}
|
|
20721
|
+
target.splice(index, 1, ...(Array.isArray(replacement) ? replacement : [replacement]));
|
|
20722
|
+
}
|
|
20723
|
+
else if ("l" in target && target.l == node) {
|
|
20724
|
+
target.l = replacement;
|
|
20725
|
+
}
|
|
20726
|
+
else if ("r" in target && target.r == node) {
|
|
20727
|
+
target.r = replacement;
|
|
20728
|
+
}
|
|
20729
|
+
else {
|
|
20730
|
+
throw new ReferenceError("Node not found");
|
|
20731
|
+
}
|
|
20732
|
+
}
|
|
20733
|
+
node[PARENT] = null;
|
|
20734
|
+
return true;
|
|
20735
|
+
}
|
|
20736
|
+
function trimWhiteSpaceTokens(tokens) {
|
|
20737
|
+
let i = 0;
|
|
20738
|
+
if (tokens[0]?.typ === exports.EnumToken.WhitespaceTokenType) {
|
|
20739
|
+
tokens.shift();
|
|
20740
|
+
}
|
|
20741
|
+
if (tokens[tokens.length - 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
|
|
20742
|
+
tokens.pop();
|
|
20743
|
+
}
|
|
20744
|
+
if (tokens.length === 1) {
|
|
20745
|
+
if (tokens[0].typ === exports.EnumToken.WhitespaceTokenType) {
|
|
20746
|
+
tokens.length = 0;
|
|
20747
|
+
}
|
|
20748
|
+
return tokens;
|
|
20749
|
+
}
|
|
20750
|
+
for (; i < tokens.length; i++) {
|
|
20751
|
+
if (trimSpaceAfter.has(tokens[i].typ) && tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
|
|
20752
|
+
tokens.splice(i + 1, 1);
|
|
20753
|
+
}
|
|
20754
|
+
else if (trimTokenSpace.has(tokens[i].typ)) {
|
|
20755
|
+
if (tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
|
|
20756
|
+
tokens.splice(i + 1, 1);
|
|
20757
|
+
}
|
|
20758
|
+
if (i > 0 && tokens[i - 1].typ === exports.EnumToken.Whitespace) {
|
|
20759
|
+
tokens.splice(--i, 1);
|
|
20760
|
+
}
|
|
20761
|
+
}
|
|
20762
|
+
}
|
|
20763
|
+
return tokens;
|
|
20764
|
+
}
|
|
20765
|
+
|
|
19932
20766
|
class ComputeCalcExpressionFeature {
|
|
19933
20767
|
accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
|
|
19934
20768
|
get ordering() {
|
|
@@ -20902,7 +21736,6 @@
|
|
|
20902
21736
|
let matrix = identity();
|
|
20903
21737
|
let mat;
|
|
20904
21738
|
let transforms;
|
|
20905
|
-
let shouldComputeMatrix = true;
|
|
20906
21739
|
const cumulative = [];
|
|
20907
21740
|
// all transform function arguments must be 0 or scale(1)
|
|
20908
21741
|
for (const transform of transformLists) {
|
|
@@ -20921,17 +21754,14 @@
|
|
|
20921
21754
|
child.typ != exports.EnumToken.PercentageTokenType) ||
|
|
20922
21755
|
// angle >= 360deg, do not transform
|
|
20923
21756
|
Math.abs(getAngle(child)) >= 1) {
|
|
20924
|
-
|
|
21757
|
+
return null;
|
|
20925
21758
|
}
|
|
20926
21759
|
}
|
|
20927
|
-
|
|
20928
|
-
}
|
|
20929
|
-
if (!shouldComputeMatrix) {
|
|
20930
|
-
break;
|
|
21760
|
+
// break;
|
|
20931
21761
|
}
|
|
20932
21762
|
}
|
|
20933
21763
|
for (const transformList of splitTransformList(transformLists)) {
|
|
20934
|
-
mat =
|
|
21764
|
+
mat = computeMatrix(transformList, identity());
|
|
20935
21765
|
if (mat == null) {
|
|
20936
21766
|
return null;
|
|
20937
21767
|
}
|
|
@@ -23496,6 +24326,19 @@
|
|
|
23496
24326
|
.reduce((acc, curr) => acc + (curr == "&" ? replace : curr), "");
|
|
23497
24327
|
}
|
|
23498
24328
|
|
|
24329
|
+
/**
|
|
24330
|
+
*
|
|
24331
|
+
* @param value
|
|
24332
|
+
* @returns
|
|
24333
|
+
*/
|
|
24334
|
+
function toBase64(value) {
|
|
24335
|
+
let result = '';
|
|
24336
|
+
for (const c of new TextEncoder().encode(value)) {
|
|
24337
|
+
result += String.fromCharCode(c);
|
|
24338
|
+
}
|
|
24339
|
+
return btoa(result);
|
|
24340
|
+
}
|
|
24341
|
+
|
|
23499
24342
|
// from https://github.com/Rich-Harris/vlq/tree/master
|
|
23500
24343
|
// credit: Rich Harris
|
|
23501
24344
|
const integer_to_char = {};
|
|
@@ -23554,6 +24397,11 @@
|
|
|
23554
24397
|
}
|
|
23555
24398
|
return result;
|
|
23556
24399
|
}
|
|
24400
|
+
/**
|
|
24401
|
+
*
|
|
24402
|
+
* @param num
|
|
24403
|
+
* @returns
|
|
24404
|
+
*/
|
|
23557
24405
|
function encode_integer(num) {
|
|
23558
24406
|
let result = '';
|
|
23559
24407
|
if (num < 0) {
|
|
@@ -23575,6 +24423,35 @@
|
|
|
23575
24423
|
|
|
23576
24424
|
/**
|
|
23577
24425
|
* Generate and parse source map
|
|
24426
|
+
*
|
|
24427
|
+
* ```ts
|
|
24428
|
+
* const sourcemap = new SourceMap();
|
|
24429
|
+
*
|
|
24430
|
+
* // you can also pass an input sourcemap
|
|
24431
|
+
* // const sourcemap = new SourceMap(sourcemapObjectOrJSONString);
|
|
24432
|
+
*
|
|
24433
|
+
* sourcemap.addSourceContent(0, '/css/styles.css', null);
|
|
24434
|
+
* sourcemap.addSourceContent(1, '/css/typography.css', null);
|
|
24435
|
+
*
|
|
24436
|
+
* const maps = [];
|
|
24437
|
+
*
|
|
24438
|
+
* maps.add([
|
|
24439
|
+
1, 1, 0, 1, 1]);
|
|
24440
|
+
* maps.add([
|
|
24441
|
+
2, 1, 1, 1, 1
|
|
24442
|
+
]);
|
|
24443
|
+
|
|
24444
|
+
sourcemap.add(maps);
|
|
24445
|
+
|
|
24446
|
+
// convert to inline sourcemap
|
|
24447
|
+
sourcemap.toUrl();
|
|
24448
|
+
|
|
24449
|
+
// convert to JSON
|
|
24450
|
+
sourcemap.toJSON();
|
|
24451
|
+
|
|
24452
|
+
// find the original file, line and column
|
|
24453
|
+
sourcemap.find(2, 1);
|
|
24454
|
+
```
|
|
23578
24455
|
*/
|
|
23579
24456
|
class SourceMap {
|
|
23580
24457
|
/**
|
|
@@ -23625,7 +24502,7 @@
|
|
|
23625
24502
|
line = -1;
|
|
23626
24503
|
/**
|
|
23627
24504
|
*
|
|
23628
|
-
* @param sourcemaps
|
|
24505
|
+
* @param sourcemaps input sourcemap
|
|
23629
24506
|
*/
|
|
23630
24507
|
constructor(sourcemaps) {
|
|
23631
24508
|
if (typeof sourcemaps === "string") {
|
|
@@ -23666,9 +24543,9 @@
|
|
|
23666
24543
|
}
|
|
23667
24544
|
/**
|
|
23668
24545
|
* add source
|
|
23669
|
-
* @param id
|
|
23670
|
-
* @param fileName
|
|
23671
|
-
* @param content
|
|
24546
|
+
* @param id source id
|
|
24547
|
+
* @param fileName source file
|
|
24548
|
+
* @param content source content
|
|
23672
24549
|
* @returns
|
|
23673
24550
|
*/
|
|
23674
24551
|
addSourceContent(id, fileName, content) {
|
|
@@ -23804,7 +24681,7 @@
|
|
|
23804
24681
|
*/
|
|
23805
24682
|
toUrl() {
|
|
23806
24683
|
// /*# sourceMappingURL = ${url} */
|
|
23807
|
-
return `data:application/json;charset=utf-8;base64,${
|
|
24684
|
+
return `data:application/json;charset=utf-8;base64,${toBase64(JSON.stringify(this.toJSON()))}`;
|
|
23808
24685
|
}
|
|
23809
24686
|
/**
|
|
23810
24687
|
* Convert to JSON object
|
|
@@ -24244,11 +25121,13 @@
|
|
|
24244
25121
|
...options,
|
|
24245
25122
|
};
|
|
24246
25123
|
if (options.withParents) {
|
|
24247
|
-
|
|
24248
|
-
let parent = data[PARENT];
|
|
25124
|
+
let parent;
|
|
24249
25125
|
while (data[PARENT] != null) {
|
|
24250
25126
|
// @ts-ignore
|
|
24251
|
-
parent = { ...data[PARENT], chi: [
|
|
25127
|
+
// parent = { ...data[PARENT], chi: [data] };
|
|
25128
|
+
parent = cloneNode(data[PARENT]);
|
|
25129
|
+
// @ts-ignore
|
|
25130
|
+
parent.chi = [data];
|
|
24252
25131
|
// @ts-ignore
|
|
24253
25132
|
parent[PARENT] = data[PARENT][PARENT];
|
|
24254
25133
|
// @ts-ignore
|
|
@@ -24418,6 +25297,8 @@
|
|
|
24418
25297
|
* @param sourceLocation
|
|
24419
25298
|
* @param linesMap
|
|
24420
25299
|
* @param str
|
|
25300
|
+
* @param start
|
|
25301
|
+
* @param end
|
|
24421
25302
|
*/
|
|
24422
25303
|
function move(sourceLocation, linesMap, str, start, end) {
|
|
24423
25304
|
let i = start ?? 0;
|
|
@@ -24610,8 +25491,8 @@
|
|
|
24610
25491
|
};
|
|
24611
25492
|
}
|
|
24612
25493
|
switch (token.typ) {
|
|
24613
|
-
case exports.EnumToken.FunctionTokenDefType:
|
|
24614
25494
|
case exports.EnumToken.UrlFunctionTokenDefType:
|
|
25495
|
+
case exports.EnumToken.FunctionTokenDefType:
|
|
24615
25496
|
case exports.EnumToken.MathFunctionTokenDefType:
|
|
24616
25497
|
case exports.EnumToken.ImageFunctionTokenDefType:
|
|
24617
25498
|
case exports.EnumToken.ColorFunctionTokenDefType:
|
|
@@ -24755,6 +25636,9 @@
|
|
|
24755
25636
|
}
|
|
24756
25637
|
case exports.EnumToken.UrlFunctionTokenType:
|
|
24757
25638
|
if (options.minify && token.typ === exports.EnumToken.UrlFunctionTokenType) {
|
|
25639
|
+
if (token.chi[0]?.typ === exports.EnumToken.BadUrlTokenType) {
|
|
25640
|
+
return "url()";
|
|
25641
|
+
}
|
|
24758
25642
|
for (const child of token.chi) {
|
|
24759
25643
|
if (child.typ === exports.EnumToken.StringTokenType) {
|
|
24760
25644
|
if (child.val.slice(1, 5) !== "data:" &&
|
|
@@ -25442,6 +26326,12 @@
|
|
|
25442
26326
|
return token.val.typ == exports.EnumToken.FractionTokenType
|
|
25443
26327
|
? renderValue(token.val, options, cache)
|
|
25444
26328
|
: minifyNumber(token.val);
|
|
26329
|
+
case exports.EnumToken.InfinityTokenType:
|
|
26330
|
+
return "1/0";
|
|
26331
|
+
case exports.EnumToken.NegativeInfinityTokenType:
|
|
26332
|
+
return "-1/0";
|
|
26333
|
+
case exports.EnumToken.NaNTokenType:
|
|
26334
|
+
return "NaN";
|
|
25445
26335
|
case exports.EnumToken.AtRuleTokenType:
|
|
25446
26336
|
return "@" + token.nam;
|
|
25447
26337
|
case exports.EnumToken.CommentTokenType:
|
|
@@ -25571,9 +26461,19 @@
|
|
|
25571
26461
|
|
|
25572
26462
|
const SymbolsMapTokens = Object.create(null);
|
|
25573
26463
|
// Regex for escape sequence decoding - compile once, reuse many times
|
|
25574
|
-
const ESCAPE_SEQUENCE_REGEX = /\\([0-9a-fA-F]{1,6})
|
|
26464
|
+
const ESCAPE_SEQUENCE_REGEX = /\\((\n|\r|\f|\v|\u2028|\u2029|([0-9a-fA-F]{1,6})) ?)/gms;
|
|
25575
26465
|
function decodeEscapeSequences(value) {
|
|
25576
26466
|
return value.replace(ESCAPE_SEQUENCE_REGEX, (_, sequence) => {
|
|
26467
|
+
// \n \r \f \v
|
|
26468
|
+
switch (sequence.charCodeAt(0)) {
|
|
26469
|
+
case 0xa:
|
|
26470
|
+
case 0xb:
|
|
26471
|
+
case 0xc:
|
|
26472
|
+
case 0xd:
|
|
26473
|
+
case 0x2028:
|
|
26474
|
+
case 0x2029:
|
|
26475
|
+
return "";
|
|
26476
|
+
}
|
|
25577
26477
|
const codepoint = parseInt(sequence, 16);
|
|
25578
26478
|
if (codepoint == 0 ||
|
|
25579
26479
|
// leading surrogate
|
|
@@ -25811,18 +26711,17 @@
|
|
|
25811
26711
|
constructor(parseInfo, input = null) {
|
|
25812
26712
|
this.parseInfo = parseInfo;
|
|
25813
26713
|
this.input = input;
|
|
25814
|
-
|
|
25815
|
-
|
|
25816
|
-
|
|
26714
|
+
this.parseInfo =
|
|
26715
|
+
typeof parseInfo == "string"
|
|
26716
|
+
? {
|
|
25817
26717
|
stream: parseInfo,
|
|
25818
26718
|
source: new SourceFile(parseInfo, [], ""),
|
|
25819
26719
|
offset: 0,
|
|
25820
26720
|
time: 0,
|
|
25821
26721
|
position: 0,
|
|
25822
26722
|
currentPosition: 0,
|
|
25823
|
-
}
|
|
25824
|
-
|
|
25825
|
-
}
|
|
26723
|
+
}
|
|
26724
|
+
: parseInfo;
|
|
25826
26725
|
}
|
|
25827
26726
|
/**
|
|
25828
26727
|
*
|
|
@@ -25839,6 +26738,18 @@
|
|
|
25839
26738
|
this.advance(parseInfo, 2);
|
|
25840
26739
|
continue;
|
|
25841
26740
|
}
|
|
26741
|
+
charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
|
|
26742
|
+
// \n \r \f \v
|
|
26743
|
+
if (charCode == 0xa ||
|
|
26744
|
+
charCode == 0xb ||
|
|
26745
|
+
charCode == 0xc ||
|
|
26746
|
+
charCode == 0xd ||
|
|
26747
|
+
charCode == 0x2028 ||
|
|
26748
|
+
charCode == 0x2029) {
|
|
26749
|
+
this.advance(parseInfo, 2);
|
|
26750
|
+
decodeSegments = true;
|
|
26751
|
+
continue;
|
|
26752
|
+
}
|
|
25842
26753
|
const sequence = this.peek(parseInfo, 7);
|
|
25843
26754
|
let escapeSequence = "";
|
|
25844
26755
|
let codepoint;
|
|
@@ -25882,7 +26793,7 @@
|
|
|
25882
26793
|
this.advance(parseInfo);
|
|
25883
26794
|
}
|
|
25884
26795
|
// EOF - 'Unclosed-string' fixed
|
|
25885
|
-
return this.makeToken(parseInfo, exports.EnumToken.StringTokenType);
|
|
26796
|
+
return this.makeToken(parseInfo, exports.EnumToken.StringTokenType, decodeSegments ? { decodeSegments } : null);
|
|
25886
26797
|
// return result;
|
|
25887
26798
|
}
|
|
25888
26799
|
/**
|
|
@@ -25944,7 +26855,7 @@
|
|
|
25944
26855
|
return this.makeToken(parseInfo, exports.EnumToken.BadUrlTokenType);
|
|
25945
26856
|
}
|
|
25946
26857
|
if (isWhiteSpace(charCode)) {
|
|
25947
|
-
this.advance(parseInfo, k);
|
|
26858
|
+
// this.advance(parseInfo, k);
|
|
25948
26859
|
k++;
|
|
25949
26860
|
continue;
|
|
25950
26861
|
}
|
|
@@ -26348,14 +27259,28 @@
|
|
|
26348
27259
|
} while (
|
|
26349
27260
|
// !(value === "/" && this.match(parseInfo, "/*") &&
|
|
26350
27261
|
charCode !== 41 /* TokenMap.RIGHT_PARENTHESIS */ &&
|
|
27262
|
+
!isWhiteSpace(charCode) &&
|
|
26351
27263
|
parseInfo.currentPosition < endPosition);
|
|
26352
|
-
|
|
27264
|
+
if (charCode !== 41 /* TokenMap.RIGHT_PARENTHESIS */) {
|
|
27265
|
+
let k = 1;
|
|
27266
|
+
while (k < endPosition) {
|
|
27267
|
+
charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + k);
|
|
27268
|
+
if (isWhiteSpace(charCode)) {
|
|
27269
|
+
k++;
|
|
27270
|
+
continue;
|
|
27271
|
+
}
|
|
27272
|
+
break;
|
|
27273
|
+
}
|
|
27274
|
+
if (charCode != charCode || (charCode != 41 /* TokenMap.RIGHT_PARENTHESIS */ && !isIdentStart(charCode))) {
|
|
27275
|
+
this.advance(parseInfo, k);
|
|
27276
|
+
return this.makeToken(parseInfo, exports.EnumToken.BadUrlTokenType);
|
|
27277
|
+
}
|
|
27278
|
+
}
|
|
26353
27279
|
return this.makeToken(parseInfo,
|
|
26354
27280
|
// parseInfo.position < parseInfo.currentPosition
|
|
26355
27281
|
(charCode = this.peekCharCode(parseInfo)) != charCode || !this.isURLToken(parseInfo)
|
|
26356
27282
|
? exports.EnumToken.BadUrlTokenType
|
|
26357
27283
|
: exports.EnumToken.UrlTokenTokenType);
|
|
26358
|
-
// }
|
|
26359
27284
|
}
|
|
26360
27285
|
/**
|
|
26361
27286
|
*
|
|
@@ -26600,8 +27525,6 @@
|
|
|
26600
27525
|
/**
|
|
26601
27526
|
*
|
|
26602
27527
|
* @param parseInfo
|
|
26603
|
-
* @param start
|
|
26604
|
-
* @param end
|
|
26605
27528
|
* @returns
|
|
26606
27529
|
*/
|
|
26607
27530
|
isIdentToken(parseInfo /* , start?: number, end?: number */) {
|
|
@@ -26732,8 +27655,6 @@
|
|
|
26732
27655
|
}
|
|
26733
27656
|
/**
|
|
26734
27657
|
* Tokenize CSS string
|
|
26735
|
-
* @param parseInfo
|
|
26736
|
-
* @param yieldEOFToken
|
|
26737
27658
|
*/
|
|
26738
27659
|
next( /* parseInfo: ParseInfo | string, yieldEOFToken: boolean = true */) {
|
|
26739
27660
|
const parseInfo = this.parseInfo;
|
|
@@ -26874,7 +27795,7 @@
|
|
|
26874
27795
|
// ) {
|
|
26875
27796
|
// this.advance(parseInfo);
|
|
26876
27797
|
// return this.makeToken(parseInfo, EnumToken.PseudoClassFunctionTokenDefType);
|
|
26877
|
-
// } else
|
|
27798
|
+
// } else
|
|
26878
27799
|
if (this.isIdentToken(parseInfo)) {
|
|
26879
27800
|
const hint = this.startsWith(parseInfo, "--")
|
|
26880
27801
|
? exports.EnumToken.CustomFunctionTokenDefType
|
|
@@ -27119,6 +28040,9 @@
|
|
|
27119
28040
|
case 46 /* TokenMap.DOT */:
|
|
27120
28041
|
const codepoint = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
|
|
27121
28042
|
if (isIdentStart(codepoint) || codepoint == 45 /* TokenMap.MINUS */) {
|
|
28043
|
+
if (parseInfo.position < parseInfo.currentPosition) {
|
|
28044
|
+
return this.makeToken(parseInfo);
|
|
28045
|
+
}
|
|
27122
28046
|
this.advance(parseInfo);
|
|
27123
28047
|
let tokensCount = this.consumeIdentToken(parseInfo);
|
|
27124
28048
|
if (tokensCount > 0) {
|
|
@@ -27150,8 +28074,6 @@
|
|
|
27150
28074
|
}
|
|
27151
28075
|
/**
|
|
27152
28076
|
* tokenize readable stream
|
|
27153
|
-
* @param input
|
|
27154
|
-
* @param parseInfo
|
|
27155
28077
|
*/
|
|
27156
28078
|
async tokenizeStream() {
|
|
27157
28079
|
const decoder = new TextDecoder("utf-8");
|
|
@@ -27396,7 +28318,7 @@
|
|
|
27396
28318
|
}
|
|
27397
28319
|
tokens.length = write;
|
|
27398
28320
|
}
|
|
27399
|
-
const result = matchSelectorSyntax(tokens, errors, options, nested
|
|
28321
|
+
const result = matchSelectorSyntax(tokens, errors, options, nested);
|
|
27400
28322
|
trimArray(tokens);
|
|
27401
28323
|
if (result.success) {
|
|
27402
28324
|
for (let i = 0; i < tokens.length; i++) {
|
|
@@ -27827,7 +28749,7 @@
|
|
|
27827
28749
|
let token;
|
|
27828
28750
|
let index;
|
|
27829
28751
|
if (syntaxRules != null) {
|
|
27830
|
-
const doNotValidate = options.validation === false
|
|
28752
|
+
const doNotValidate = options.validation === false;
|
|
27831
28753
|
result = doNotValidate ? null : matchAllSyntaxes(syntaxRules, createValidationContext(tokens), options);
|
|
27832
28754
|
if (doNotValidate || result != null) {
|
|
27833
28755
|
success = doNotValidate || result?.success;
|
|
@@ -27858,17 +28780,11 @@
|
|
|
27858
28780
|
stack.push(token);
|
|
27859
28781
|
continue;
|
|
27860
28782
|
}
|
|
28783
|
+
if (token.typ === exports.EnumToken.ColonTokenType && stack.length == 0) {
|
|
28784
|
+
stack.push(token);
|
|
28785
|
+
continue;
|
|
28786
|
+
}
|
|
27861
28787
|
switch (token.typ) {
|
|
27862
|
-
// case EnumToken.IdenTokenType:
|
|
27863
|
-
// if (tokens[i + 1]?.typ == EnumToken.StartParensTokenType) {
|
|
27864
|
-
// Object.assign(token, {
|
|
27865
|
-
// typ: EnumToken.FunctionTokenDefType,
|
|
27866
|
-
// });
|
|
27867
|
-
// token[LOCEND] = tokens[i + 1][LOCEND];
|
|
27868
|
-
// tokens.splice(i + 1, 1);
|
|
27869
|
-
// stack.push(token);
|
|
27870
|
-
// }
|
|
27871
|
-
// break;
|
|
27872
28788
|
case exports.EnumToken.Literal:
|
|
27873
28789
|
if (token.val === "/" && stack.at(-1)?.typ == exports.EnumToken.MathFunctionTokenDefType) {
|
|
27874
28790
|
Object.assign(token, {
|
|
@@ -28110,12 +29026,11 @@
|
|
|
28110
29026
|
name[STATE] = exports.EnumAstNodeStatus.Unknown;
|
|
28111
29027
|
name[ERRORS] = result?.errors ?? [];
|
|
28112
29028
|
// @ts-expect-error
|
|
28113
|
-
|
|
29029
|
+
return Object.assign(name, {
|
|
28114
29030
|
typ: exports.EnumToken.DeclarationNodeType,
|
|
28115
29031
|
nam: name.val,
|
|
28116
29032
|
val: tokens,
|
|
28117
29033
|
});
|
|
28118
|
-
return node;
|
|
28119
29034
|
}
|
|
28120
29035
|
if (equalsIgnoreCase("composes", name.val)) {
|
|
28121
29036
|
let index = -1;
|
|
@@ -28434,6 +29349,16 @@
|
|
|
28434
29349
|
val.splice(0, val.length, ...filteredValues);
|
|
28435
29350
|
}
|
|
28436
29351
|
}
|
|
29352
|
+
if (stack.at(-1)?.typ === exports.EnumToken.ColonTokenType) {
|
|
29353
|
+
if (name.startsWith("min-")) {
|
|
29354
|
+
filteredNames[0].val = name.substring(4);
|
|
29355
|
+
stack.at(-1).typ = exports.EnumToken.GteTokenType;
|
|
29356
|
+
}
|
|
29357
|
+
else if (name.startsWith("max-")) {
|
|
29358
|
+
filteredNames[0].val = name.substring(4);
|
|
29359
|
+
stack.at(-1).typ = exports.EnumToken.LteTokenType;
|
|
29360
|
+
}
|
|
29361
|
+
}
|
|
28437
29362
|
// @ts-expect-error
|
|
28438
29363
|
tokens.splice(index3 + 1, tokens.length - index3 - 2, {
|
|
28439
29364
|
typ: exports.EnumToken.MediaQueryConditionTokenType,
|
|
@@ -28489,6 +29414,61 @@
|
|
|
28489
29414
|
[LOCEND]: right.at(-1)[LOCEND],
|
|
28490
29415
|
};
|
|
28491
29416
|
tokens.length = l + 1;
|
|
29417
|
+
// media range query
|
|
29418
|
+
if (options.minify &&
|
|
29419
|
+
tokens[l].op.typ === exports.EnumToken.AndTokenType) {
|
|
29420
|
+
if (left.length === 1 &&
|
|
29421
|
+
left[0].typ == exports.EnumToken.ParensTokenType &&
|
|
29422
|
+
left[0].chi.length == 1 &&
|
|
29423
|
+
left[0].chi[0].typ == exports.EnumToken.MediaQueryConditionTokenType &&
|
|
29424
|
+
left[0].chi[0].l.length == 1 &&
|
|
29425
|
+
left[0].chi[0].l[0].typ ==
|
|
29426
|
+
exports.EnumToken.IdenTokenType &&
|
|
29427
|
+
(left[0].chi[0].op.typ ==
|
|
29428
|
+
exports.EnumToken.GtTokenType ||
|
|
29429
|
+
left[0].chi[0].op.typ ==
|
|
29430
|
+
exports.EnumToken.GteTokenType) &&
|
|
29431
|
+
right.length === 1 &&
|
|
29432
|
+
left[0].typ == exports.EnumToken.ParensTokenType &&
|
|
29433
|
+
right[0].chi.length == 1 &&
|
|
29434
|
+
right[0].chi[0].typ ==
|
|
29435
|
+
exports.EnumToken.MediaQueryConditionTokenType &&
|
|
29436
|
+
right[0].chi[0].l.length == 1 &&
|
|
29437
|
+
right[0].chi[0].l[0].typ ==
|
|
29438
|
+
exports.EnumToken.IdenTokenType &&
|
|
29439
|
+
(right[0].chi[0].op.typ ==
|
|
29440
|
+
exports.EnumToken.LtTokenType ||
|
|
29441
|
+
right[0].chi[0].op.typ ==
|
|
29442
|
+
exports.EnumToken.LteTokenType) &&
|
|
29443
|
+
equalsIgnoreCase(left[0].chi[0]
|
|
29444
|
+
.l[0].val, right[0].chi[0]
|
|
29445
|
+
.l[0].val)) {
|
|
29446
|
+
tokens[l] = {
|
|
29447
|
+
typ: exports.EnumToken.ParensTokenType,
|
|
29448
|
+
chi: [
|
|
29449
|
+
{
|
|
29450
|
+
typ: exports.EnumToken.MediaRangeQueryTokenType,
|
|
29451
|
+
op1: Object.assign(left[0].chi[0]
|
|
29452
|
+
.op, {
|
|
29453
|
+
typ: left[0]
|
|
29454
|
+
.chi[0].op.typ == exports.EnumToken.GteTokenType
|
|
29455
|
+
? exports.EnumToken.LteTokenType
|
|
29456
|
+
: exports.EnumToken.LtTokenType,
|
|
29457
|
+
}),
|
|
29458
|
+
op2: right[0].chi[0]
|
|
29459
|
+
.op,
|
|
29460
|
+
l: left[0].chi[0].r,
|
|
29461
|
+
val: left[0].chi[0]
|
|
29462
|
+
.l,
|
|
29463
|
+
r: right[0].chi[0].r,
|
|
29464
|
+
[LOCSRCID]: left[0][LOCSRCID],
|
|
29465
|
+
[LOCSTA]: left[0][LOCSTA],
|
|
29466
|
+
[LOCEND]: right.at(-1)[LOCEND],
|
|
29467
|
+
},
|
|
29468
|
+
],
|
|
29469
|
+
};
|
|
29470
|
+
}
|
|
29471
|
+
}
|
|
28492
29472
|
expectAndOrComma = true;
|
|
28493
29473
|
}
|
|
28494
29474
|
}
|
|
@@ -28927,7 +29907,7 @@
|
|
|
28927
29907
|
let i = 0;
|
|
28928
29908
|
let success = true;
|
|
28929
29909
|
let expectAndOr = false;
|
|
28930
|
-
let scope = new Set();
|
|
29910
|
+
// let scope: Set<EnumToken> = new Set();
|
|
28931
29911
|
const errors = [];
|
|
28932
29912
|
// const scopes: Array<Set<EnumToken>> = [scope];
|
|
28933
29913
|
for (; i < stream.length; i++) {
|
|
@@ -28949,7 +29929,7 @@
|
|
|
28949
29929
|
Object.assign(stream[i], {
|
|
28950
29930
|
typ: "or" === val ? exports.EnumToken.OrTokenType : exports.EnumToken.AndTokenType,
|
|
28951
29931
|
});
|
|
28952
|
-
scope.add(stream[i].typ);
|
|
29932
|
+
// scope.add(stream[i].typ);
|
|
28953
29933
|
stack.push(stream[i]);
|
|
28954
29934
|
// break;
|
|
28955
29935
|
}
|
|
@@ -29329,7 +30309,7 @@
|
|
|
29329
30309
|
const syntaxRules = getSyntaxRule(ValidationSyntaxGroupEnum.AtRules, "@" + context.nam);
|
|
29330
30310
|
const syntax = syntaxRules?.getPreludeRules()?.slice?.(1);
|
|
29331
30311
|
trimArray(stream);
|
|
29332
|
-
const { success, errors} = matchAllSyntaxes(syntax, createValidationContext(stream), options);
|
|
30312
|
+
const { success, errors /* , ...all */ } = matchAllSyntaxes(syntax, createValidationContext(stream), options);
|
|
29333
30313
|
return { success, errors };
|
|
29334
30314
|
}
|
|
29335
30315
|
|
|
@@ -29841,7 +30821,7 @@
|
|
|
29841
30821
|
}
|
|
29842
30822
|
/**
|
|
29843
30823
|
* Parse css string
|
|
29844
|
-
* @param
|
|
30824
|
+
* @param tokenizer
|
|
29845
30825
|
* @param options
|
|
29846
30826
|
*
|
|
29847
30827
|
* @throws Error
|
|
@@ -30838,6 +31818,7 @@
|
|
|
30838
31818
|
const imports = [];
|
|
30839
31819
|
let item;
|
|
30840
31820
|
let node;
|
|
31821
|
+
// @ts-ignore ignore error
|
|
30841
31822
|
let parensMatch = 0;
|
|
30842
31823
|
let curlyBracketMatch = 0;
|
|
30843
31824
|
let tokenizer = iter instanceof Promise ? await iter : iter;
|
|
@@ -32836,14 +33817,6 @@
|
|
|
32836
33817
|
* ```
|
|
32837
33818
|
*/
|
|
32838
33819
|
function parseString(src, options = { parseColor: true }, errors) {
|
|
32839
|
-
// const parseInfo: ParseInfo = {
|
|
32840
|
-
// stream: src,
|
|
32841
|
-
// offset: 0,
|
|
32842
|
-
// time: 0,
|
|
32843
|
-
// source: new SourceFile(src, [], ""),
|
|
32844
|
-
// position: 0,
|
|
32845
|
-
// currentPosition: 0,
|
|
32846
|
-
// };
|
|
32847
33820
|
const tokenizer = new Tokenizer({
|
|
32848
33821
|
stream: src,
|
|
32849
33822
|
buffer: "",
|
|
@@ -33451,13 +34424,10 @@
|
|
|
33451
34424
|
const parseResult = parseSync(stream, options);
|
|
33452
34425
|
let mapping = null;
|
|
33453
34426
|
let importMapping = null;
|
|
33454
|
-
if (typeof options.module == "number" && options.module & exports.ModuleScopeEnumOptions.ICSS)
|
|
33455
|
-
|
|
33456
|
-
|
|
33457
|
-
|
|
33458
|
-
else if (typeof options.module == "object" &&
|
|
33459
|
-
typeof options.module.scoped == "number" &&
|
|
33460
|
-
options.module.scoped & exports.ModuleScopeEnumOptions.ICSS) {
|
|
34427
|
+
if ((typeof options.module == "number" && options.module & exports.ModuleScopeEnumOptions.ICSS) ||
|
|
34428
|
+
(typeof options.module == "object" &&
|
|
34429
|
+
typeof options.module.scoped == "number" &&
|
|
34430
|
+
options.module.scoped & exports.ModuleScopeEnumOptions.ICSS)) {
|
|
33461
34431
|
mapping = parseResult.mapping;
|
|
33462
34432
|
importMapping = parseResult.importMapping;
|
|
33463
34433
|
}
|
|
@@ -33629,13 +34599,10 @@
|
|
|
33629
34599
|
return parse(stream, options).then((parseResult) => {
|
|
33630
34600
|
let mapping = null;
|
|
33631
34601
|
let importMapping = null;
|
|
33632
|
-
if (typeof options.module == "number" && options.module & exports.ModuleScopeEnumOptions.ICSS)
|
|
33633
|
-
|
|
33634
|
-
|
|
33635
|
-
|
|
33636
|
-
else if (typeof options.module == "object" &&
|
|
33637
|
-
typeof options.module.scoped == "number" &&
|
|
33638
|
-
options.module.scoped & exports.ModuleScopeEnumOptions.ICSS) {
|
|
34602
|
+
if ((typeof options.module == "number" && options.module & exports.ModuleScopeEnumOptions.ICSS) ||
|
|
34603
|
+
(typeof options.module == "object" &&
|
|
34604
|
+
typeof options.module.scoped == "number" &&
|
|
34605
|
+
options.module.scoped & exports.ModuleScopeEnumOptions.ICSS)) {
|
|
33639
34606
|
mapping = parseResult.mapping;
|
|
33640
34607
|
importMapping = parseResult.importMapping;
|
|
33641
34608
|
}
|