@tbela99/css-parser 1.6.0 → 1.6.1
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 +26 -0
- package/README.md +3 -3
- package/dist/index-umd-web.js +425 -230
- package/dist/index.cjs +425 -230
- package/dist/index.d.ts +1 -1
- package/dist/lib/ast/features/transform.js +1 -1
- package/dist/lib/ast/math/expression.js +19 -4
- package/dist/lib/ast/minify.js +84 -10
- package/dist/lib/ast/transform/compute.js +28 -55
- package/dist/lib/ast/transform/minify.js +1 -1
- package/dist/{config.json.js → lib/data/properties.json.js} +106 -0
- package/dist/lib/{validation/config.json.js → data/validation.json.js} +11 -8
- package/dist/lib/parser/parse.js +6 -5
- package/dist/lib/parser/tokenize.js +40 -41
- package/dist/lib/parser/utils/config.js +1 -1
- package/dist/lib/parser/utils/declaration.js +11 -3
- package/dist/lib/parser/utils/selector.js +98 -88
- package/dist/lib/renderer/render.js +2 -2
- package/dist/lib/renderer/sourcemap/lib/codec.js +3 -3
- package/dist/lib/syntax/color/cmyk.js +4 -3
- package/dist/lib/syntax/color/srgb.js +4 -3
- package/dist/lib/syntax/constants.js +1 -1
- package/dist/lib/validation/config.js +1 -1
- package/dist/lib/validation/parser/parse.js +7 -3
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -2572,7 +2572,7 @@ var declarations = {
|
|
|
2572
2572
|
syntax: "none | nearest"
|
|
2573
2573
|
},
|
|
2574
2574
|
"scroll-margin": {
|
|
2575
|
-
syntax: "<length>{1,4}"
|
|
2575
|
+
syntax: " <length>{1,4}"
|
|
2576
2576
|
},
|
|
2577
2577
|
"scroll-margin-block": {
|
|
2578
2578
|
syntax: "<length>{1,2}"
|
|
@@ -2584,7 +2584,7 @@ var declarations = {
|
|
|
2584
2584
|
syntax: "<length>"
|
|
2585
2585
|
},
|
|
2586
2586
|
"scroll-margin-bottom": {
|
|
2587
|
-
syntax: "<length>"
|
|
2587
|
+
syntax: " auto | <length-percentage [0,∞]>"
|
|
2588
2588
|
},
|
|
2589
2589
|
"scroll-margin-inline": {
|
|
2590
2590
|
syntax: "<length>{1,2}"
|
|
@@ -2596,13 +2596,13 @@ var declarations = {
|
|
|
2596
2596
|
syntax: "<length>"
|
|
2597
2597
|
},
|
|
2598
2598
|
"scroll-margin-left": {
|
|
2599
|
-
syntax: "<length>"
|
|
2599
|
+
syntax: " auto | <length-percentage [0,∞]>"
|
|
2600
2600
|
},
|
|
2601
2601
|
"scroll-margin-right": {
|
|
2602
|
-
syntax: "<length>"
|
|
2602
|
+
syntax: " auto | <length-percentage [0,∞]>"
|
|
2603
2603
|
},
|
|
2604
2604
|
"scroll-margin-top": {
|
|
2605
|
-
syntax: "<length>"
|
|
2605
|
+
syntax: " auto | <length-percentage [0,∞]>"
|
|
2606
2606
|
},
|
|
2607
2607
|
"scroll-marker-group": {
|
|
2608
2608
|
syntax: "none | before | after"
|
|
@@ -2671,13 +2671,13 @@ var declarations = {
|
|
|
2671
2671
|
syntax: "none | auto"
|
|
2672
2672
|
},
|
|
2673
2673
|
"scroll-timeline": {
|
|
2674
|
-
syntax: "[ <'scroll-timeline-name'> <'scroll-timeline-axis'>? ]#"
|
|
2674
|
+
syntax: " [ <'scroll-timeline-name'> <'scroll-timeline-axis'>? ]#"
|
|
2675
2675
|
},
|
|
2676
2676
|
"scroll-timeline-axis": {
|
|
2677
|
-
syntax: "[ block | inline | x | y ]#"
|
|
2677
|
+
syntax: " [ block | inline | x | y ]#"
|
|
2678
2678
|
},
|
|
2679
2679
|
"scroll-timeline-name": {
|
|
2680
|
-
syntax: "[ none | <dashed-ident> ]#"
|
|
2680
|
+
syntax: " [ none | <dashed-ident> ]#"
|
|
2681
2681
|
},
|
|
2682
2682
|
"scrollbar-color": {
|
|
2683
2683
|
syntax: "auto | <color>{2}"
|
|
@@ -3170,6 +3170,9 @@ var functions = {
|
|
|
3170
3170
|
acos: {
|
|
3171
3171
|
syntax: "acos( <calc-sum> )"
|
|
3172
3172
|
},
|
|
3173
|
+
alpha: {
|
|
3174
|
+
syntax: "alpha( from <color> / [ <alpha-value> | none ] )"
|
|
3175
|
+
},
|
|
3173
3176
|
anchor: {
|
|
3174
3177
|
syntax: "anchor( <anchor-name>? && <anchor-side>, <length-percentage>? )"
|
|
3175
3178
|
},
|
|
@@ -7954,10 +7957,11 @@ function cmyk2srgbvalues(token) {
|
|
|
7954
7957
|
t = components[3];
|
|
7955
7958
|
// @ts-ignore
|
|
7956
7959
|
const k = getNumber(t);
|
|
7960
|
+
const mul = 1 - k;
|
|
7957
7961
|
const rgb = [
|
|
7958
|
-
1 - Math.min(1, c *
|
|
7959
|
-
1 - Math.min(1, m *
|
|
7960
|
-
1 - Math.min(1, y *
|
|
7962
|
+
1 - Math.min(1, c * mul + k),
|
|
7963
|
+
1 - Math.min(1, m * mul + k),
|
|
7964
|
+
1 - Math.min(1, y * mul + k),
|
|
7961
7965
|
];
|
|
7962
7966
|
if (components.length == 5) {
|
|
7963
7967
|
rgb.push(getNumber(components[4]));
|
|
@@ -10265,7 +10269,9 @@ function evaluateFunc(token) {
|
|
|
10265
10269
|
}
|
|
10266
10270
|
const value = evaluate(values);
|
|
10267
10271
|
// @ts-ignore
|
|
10268
|
-
let val = value[0].typ == exports.EnumToken.NumberTokenType ||
|
|
10272
|
+
let val = value[0].typ == exports.EnumToken.NumberTokenType ||
|
|
10273
|
+
value[0].typ == exports.EnumToken.AngleTokenType ||
|
|
10274
|
+
value[0].typ == exports.EnumToken.PercentageTokenType
|
|
10269
10275
|
? +value[0].val
|
|
10270
10276
|
: // @ts-expect-error
|
|
10271
10277
|
value[0].l.val / value[0].r.val;
|
|
@@ -10280,7 +10286,7 @@ function evaluateFunc(token) {
|
|
|
10280
10286
|
[LOCEND]: value[0][LOCEND],
|
|
10281
10287
|
}
|
|
10282
10288
|
: {
|
|
10283
|
-
typ: exports.EnumToken.NumberTokenType,
|
|
10289
|
+
typ: token.val == "sign" ? exports.EnumToken.NumberTokenType : value[0].typ,
|
|
10284
10290
|
val: Math[token.val](val),
|
|
10285
10291
|
[LOCSRCID]: value[0][LOCSRCID],
|
|
10286
10292
|
[LOCSTA]: value[0][LOCSTA],
|
|
@@ -10310,10 +10316,23 @@ function evaluateFunc(token) {
|
|
|
10310
10316
|
},
|
|
10311
10317
|
];
|
|
10312
10318
|
}
|
|
10319
|
+
case "mod":
|
|
10313
10320
|
case "atan2":
|
|
10314
10321
|
case "pow":
|
|
10315
|
-
case "rem":
|
|
10316
|
-
|
|
10322
|
+
case "rem": {
|
|
10323
|
+
{
|
|
10324
|
+
let typ = token.chi[0]?.typ;
|
|
10325
|
+
for (let i = 1; i < token.chi.length; i++) {
|
|
10326
|
+
if (token.chi[i].typ == exports.EnumToken.WhitespaceTokenType ||
|
|
10327
|
+
token.chi[i].typ == exports.EnumToken.CommaTokenType ||
|
|
10328
|
+
token.chi[i].typ == exports.EnumToken.CommentTokenType) {
|
|
10329
|
+
continue;
|
|
10330
|
+
}
|
|
10331
|
+
if (token.chi[i].typ != typ) {
|
|
10332
|
+
return null;
|
|
10333
|
+
}
|
|
10334
|
+
}
|
|
10335
|
+
}
|
|
10317
10336
|
const chi = values.filter((t) => ![exports.EnumToken.WhitespaceTokenType, exports.EnumToken.CommentTokenType].includes(t.typ));
|
|
10318
10337
|
if (token.val == "atan2") {
|
|
10319
10338
|
for (let i = 0; i < chi.length; i++) {
|
|
@@ -10934,9 +10953,10 @@ function color2cmykToken(token) {
|
|
|
10934
10953
|
}
|
|
10935
10954
|
function srgb2cmykvalues(r, g, b, a = null) {
|
|
10936
10955
|
const k = 1 - Math.max(r, g, b);
|
|
10937
|
-
const
|
|
10938
|
-
const
|
|
10939
|
-
const
|
|
10956
|
+
const div = 1 - k;
|
|
10957
|
+
const c = k == 1 ? 0 : (1 - r - k) / div;
|
|
10958
|
+
const m = k == 1 ? 0 : (1 - g - k) / div;
|
|
10959
|
+
const y = k == 1 ? 0 : (1 - b - k) / div;
|
|
10940
10960
|
const result = [c, m, y, k];
|
|
10941
10961
|
if (a != null && a < 1) {
|
|
10942
10962
|
result.push(a);
|
|
@@ -11750,9 +11770,13 @@ function parseSyntax(syntax) {
|
|
|
11750
11770
|
stack.pop();
|
|
11751
11771
|
}
|
|
11752
11772
|
}
|
|
11753
|
-
if (stack.length > 0) {
|
|
11754
|
-
|
|
11755
|
-
}
|
|
11773
|
+
// if (stack.length > 0) {
|
|
11774
|
+
// throw new SyntaxError(
|
|
11775
|
+
// `Unexpected token ${ValidationTokenEnum[stack.at(-1)?.typ as ValidationTokenEnum]} at ${
|
|
11776
|
+
// stack.at(-1)?.[LOC]?.lin
|
|
11777
|
+
// }:${stack.at(-1)?.[LOC]?.col}`,
|
|
11778
|
+
// );
|
|
11779
|
+
// }
|
|
11756
11780
|
return trimSyntaxArray(tokens);
|
|
11757
11781
|
}
|
|
11758
11782
|
|
|
@@ -17215,6 +17239,65 @@ var properties = {
|
|
|
17215
17239
|
"padding-left": {
|
|
17216
17240
|
shorthand: "padding"
|
|
17217
17241
|
},
|
|
17242
|
+
"scroll-margin": {
|
|
17243
|
+
shorthand: "scroll-margin",
|
|
17244
|
+
properties: [
|
|
17245
|
+
"scroll-margin-top",
|
|
17246
|
+
"scroll-margin-right",
|
|
17247
|
+
"scroll-margin-bottom",
|
|
17248
|
+
"scroll-margin-left"
|
|
17249
|
+
],
|
|
17250
|
+
types: [
|
|
17251
|
+
"Length",
|
|
17252
|
+
"Perc"
|
|
17253
|
+
],
|
|
17254
|
+
"default": [
|
|
17255
|
+
"0"
|
|
17256
|
+
],
|
|
17257
|
+
keywords: [
|
|
17258
|
+
"auto"
|
|
17259
|
+
]
|
|
17260
|
+
},
|
|
17261
|
+
"scroll-margin-top": {
|
|
17262
|
+
shorthand: "scroll-margin"
|
|
17263
|
+
},
|
|
17264
|
+
"scroll-margin-right": {
|
|
17265
|
+
shorthand: "scroll-margin"
|
|
17266
|
+
},
|
|
17267
|
+
"scroll-margin-bottom": {
|
|
17268
|
+
shorthand: "scroll-margin"
|
|
17269
|
+
},
|
|
17270
|
+
"scroll-margin-left": {
|
|
17271
|
+
shorthand: "scroll-margin"
|
|
17272
|
+
},
|
|
17273
|
+
"scroll-padding": {
|
|
17274
|
+
shorthand: "scroll-padding",
|
|
17275
|
+
properties: [
|
|
17276
|
+
"scroll-padding-top",
|
|
17277
|
+
"scroll-padding-right",
|
|
17278
|
+
"scroll-padding-bottom",
|
|
17279
|
+
"scroll-padding-left"
|
|
17280
|
+
],
|
|
17281
|
+
types: [
|
|
17282
|
+
"Length",
|
|
17283
|
+
"Perc"
|
|
17284
|
+
],
|
|
17285
|
+
keywords: [
|
|
17286
|
+
"auto"
|
|
17287
|
+
]
|
|
17288
|
+
},
|
|
17289
|
+
"scroll-padding-top": {
|
|
17290
|
+
shorthand: "scroll-padding"
|
|
17291
|
+
},
|
|
17292
|
+
"scroll-padding-right": {
|
|
17293
|
+
shorthand: "scroll-padding"
|
|
17294
|
+
},
|
|
17295
|
+
"scroll-padding-bottom": {
|
|
17296
|
+
shorthand: "scroll-padding"
|
|
17297
|
+
},
|
|
17298
|
+
"scroll-padding-left": {
|
|
17299
|
+
shorthand: "scroll-padding"
|
|
17300
|
+
},
|
|
17218
17301
|
"border-radius": {
|
|
17219
17302
|
shorthand: "border-radius",
|
|
17220
17303
|
properties: [
|
|
@@ -17436,6 +17519,53 @@ var map = {
|
|
|
17436
17519
|
"flex-wrap": {
|
|
17437
17520
|
shorthand: "flex-flow"
|
|
17438
17521
|
},
|
|
17522
|
+
"scroll-timeline": {
|
|
17523
|
+
shorthand: "scroll-timeline",
|
|
17524
|
+
pattern: "scroll-timeline-name scroll-timeline-axis",
|
|
17525
|
+
keywords: [
|
|
17526
|
+
"none",
|
|
17527
|
+
"block",
|
|
17528
|
+
"inline",
|
|
17529
|
+
"x",
|
|
17530
|
+
"y"
|
|
17531
|
+
],
|
|
17532
|
+
"default": [
|
|
17533
|
+
"none",
|
|
17534
|
+
"block"
|
|
17535
|
+
],
|
|
17536
|
+
properties: {
|
|
17537
|
+
"scroll-timeline-name": {
|
|
17538
|
+
keywords: [
|
|
17539
|
+
"none"
|
|
17540
|
+
],
|
|
17541
|
+
"default": [
|
|
17542
|
+
"none"
|
|
17543
|
+
],
|
|
17544
|
+
types: [
|
|
17545
|
+
"DashedIden"
|
|
17546
|
+
]
|
|
17547
|
+
},
|
|
17548
|
+
"scroll-timeline-axis": {
|
|
17549
|
+
keywords: [
|
|
17550
|
+
"block",
|
|
17551
|
+
"inline",
|
|
17552
|
+
"x",
|
|
17553
|
+
"y"
|
|
17554
|
+
],
|
|
17555
|
+
"default": [
|
|
17556
|
+
"block"
|
|
17557
|
+
],
|
|
17558
|
+
types: [
|
|
17559
|
+
]
|
|
17560
|
+
}
|
|
17561
|
+
}
|
|
17562
|
+
},
|
|
17563
|
+
"scroll-timeline-name": {
|
|
17564
|
+
shorthand: "scroll-timeline"
|
|
17565
|
+
},
|
|
17566
|
+
"scroll-timeline-axis": {
|
|
17567
|
+
shorthand: "scroll-timeline"
|
|
17568
|
+
},
|
|
17439
17569
|
container: {
|
|
17440
17570
|
shorthand: "container",
|
|
17441
17571
|
pattern: "container-name container-type",
|
|
@@ -20640,7 +20770,7 @@ function eqMatrix(a, b) {
|
|
|
20640
20770
|
return true;
|
|
20641
20771
|
}
|
|
20642
20772
|
function minifyTransformFunctions(transform) {
|
|
20643
|
-
const name = transform.val
|
|
20773
|
+
const name = transform.val;
|
|
20644
20774
|
if ("skewX" == name) {
|
|
20645
20775
|
transform.val = "skew";
|
|
20646
20776
|
return transform;
|
|
@@ -20775,9 +20905,36 @@ function compute(transformLists) {
|
|
|
20775
20905
|
let matrix = identity();
|
|
20776
20906
|
let mat;
|
|
20777
20907
|
let transforms;
|
|
20908
|
+
let shouldComputeMatrix = true;
|
|
20778
20909
|
const cumulative = [];
|
|
20910
|
+
// all transform function arguments must be 0 or scale(1)
|
|
20911
|
+
for (const transform of transformLists) {
|
|
20912
|
+
switch (transform.val) {
|
|
20913
|
+
case "rotate":
|
|
20914
|
+
case "rotateX":
|
|
20915
|
+
case "rotateY":
|
|
20916
|
+
case "rotateZ":
|
|
20917
|
+
case "rotate3d":
|
|
20918
|
+
for (const child of transform.chi) {
|
|
20919
|
+
if (child.typ == exports.EnumToken.WhitespaceTokenType || child.typ == exports.EnumToken.CommaTokenType) {
|
|
20920
|
+
continue;
|
|
20921
|
+
}
|
|
20922
|
+
if ((child.typ != exports.EnumToken.AngleTokenType &&
|
|
20923
|
+
child.typ != exports.EnumToken.NumberTokenType &&
|
|
20924
|
+
child.typ != exports.EnumToken.PercentageTokenType) ||
|
|
20925
|
+
// angle >= 360deg, do not transform
|
|
20926
|
+
Math.abs(getAngle(child)) >= 1) {
|
|
20927
|
+
shouldComputeMatrix = false;
|
|
20928
|
+
}
|
|
20929
|
+
}
|
|
20930
|
+
break;
|
|
20931
|
+
}
|
|
20932
|
+
if (!shouldComputeMatrix) {
|
|
20933
|
+
break;
|
|
20934
|
+
}
|
|
20935
|
+
}
|
|
20779
20936
|
for (const transformList of splitTransformList(transformLists)) {
|
|
20780
|
-
mat = computeMatrix(transformList, identity());
|
|
20937
|
+
mat = shouldComputeMatrix ? computeMatrix(transformList, identity()) : null;
|
|
20781
20938
|
if (mat == null) {
|
|
20782
20939
|
return null;
|
|
20783
20940
|
}
|
|
@@ -20806,60 +20963,6 @@ function compute(transformLists) {
|
|
|
20806
20963
|
cumulative,
|
|
20807
20964
|
minified: minify$1(matrix) ?? [serialized],
|
|
20808
20965
|
};
|
|
20809
|
-
// valid identity matrix
|
|
20810
|
-
if ((result.minified.length == 1 &&
|
|
20811
|
-
result.minified[0].typ == exports.EnumToken.IdenTokenType &&
|
|
20812
|
-
result.minified[0].val == "none") ||
|
|
20813
|
-
(result.cumulative.length == 1 &&
|
|
20814
|
-
result.cumulative[0].typ == exports.EnumToken.IdenTokenType &&
|
|
20815
|
-
result.cumulative[0].val == "none") ||
|
|
20816
|
-
(result.matrix?.typ == exports.EnumToken.IdenTokenType && result.matrix.val == "none")) {
|
|
20817
|
-
// all transform function arguments must be 0 or scale(1)
|
|
20818
|
-
for (const transform of transformLists) {
|
|
20819
|
-
switch (transform.val) {
|
|
20820
|
-
case "translate":
|
|
20821
|
-
case "translateX":
|
|
20822
|
-
case "translateY":
|
|
20823
|
-
case "translateZ":
|
|
20824
|
-
case "translate3d":
|
|
20825
|
-
case "rotate":
|
|
20826
|
-
case "rotateX":
|
|
20827
|
-
case "rotateY":
|
|
20828
|
-
case "rotateZ":
|
|
20829
|
-
case "rotate3d":
|
|
20830
|
-
case "skew":
|
|
20831
|
-
case "skewX":
|
|
20832
|
-
case "skewY":
|
|
20833
|
-
for (const child of transform.chi) {
|
|
20834
|
-
if (child.typ == exports.EnumToken.WhitespaceTokenType || child.typ == exports.EnumToken.CommaTokenType) {
|
|
20835
|
-
continue;
|
|
20836
|
-
}
|
|
20837
|
-
if ((child.typ != exports.EnumToken.AngleTokenType &&
|
|
20838
|
-
child.typ != exports.EnumToken.NumberTokenType &&
|
|
20839
|
-
child.typ != exports.EnumToken.PercentageTokenType) ||
|
|
20840
|
-
getNumber(child) != 0) {
|
|
20841
|
-
return null;
|
|
20842
|
-
}
|
|
20843
|
-
}
|
|
20844
|
-
break;
|
|
20845
|
-
case "scale":
|
|
20846
|
-
case "scaleX":
|
|
20847
|
-
case "scaleY":
|
|
20848
|
-
case "scaleZ":
|
|
20849
|
-
case "scale3d":
|
|
20850
|
-
for (const child of transform.chi) {
|
|
20851
|
-
if (child.typ == exports.EnumToken.WhitespaceTokenType || child.typ == exports.EnumToken.CommaTokenType) {
|
|
20852
|
-
continue;
|
|
20853
|
-
}
|
|
20854
|
-
if ((child.typ != exports.EnumToken.NumberTokenType && child.typ != exports.EnumToken.PercentageTokenType) ||
|
|
20855
|
-
getNumber(child) != 1) {
|
|
20856
|
-
return null;
|
|
20857
|
-
}
|
|
20858
|
-
}
|
|
20859
|
-
break;
|
|
20860
|
-
}
|
|
20861
|
-
}
|
|
20862
|
-
}
|
|
20863
20966
|
return result;
|
|
20864
20967
|
}
|
|
20865
20968
|
function computeMatrix(transformList, matrixVar) {
|
|
@@ -21187,7 +21290,7 @@ class TransformCssFeature {
|
|
|
21187
21290
|
minified: null,
|
|
21188
21291
|
};
|
|
21189
21292
|
if (matrix == null || cumulative == null || minified == null) {
|
|
21190
|
-
node.val = children;
|
|
21293
|
+
node.val = children.map((t) => t.typ == exports.EnumToken.TransformFunctionTokenType ? minifyTransformFunctions(t) : t);
|
|
21191
21294
|
continue;
|
|
21192
21295
|
}
|
|
21193
21296
|
let r = [filterValues(children)];
|
|
@@ -21871,7 +21974,15 @@ function reduce(acc, curr) {
|
|
|
21871
21974
|
// trim :is()
|
|
21872
21975
|
if (curr[0] == "&") {
|
|
21873
21976
|
if (curr[1] == " " && !isIdent(curr[2]) && !isFunction(curr[2])) {
|
|
21874
|
-
curr.
|
|
21977
|
+
const all = new Array(Math.max(curr.length - 2, 0));
|
|
21978
|
+
let write = 0;
|
|
21979
|
+
for (let read = 2; read < curr.length; read++) {
|
|
21980
|
+
all[write++] = curr[read];
|
|
21981
|
+
}
|
|
21982
|
+
curr.length = 0;
|
|
21983
|
+
for (let index = 0; index < write; index++) {
|
|
21984
|
+
curr[index] = all[index];
|
|
21985
|
+
}
|
|
21875
21986
|
}
|
|
21876
21987
|
}
|
|
21877
21988
|
acc.push(curr.join(""));
|
|
@@ -22149,19 +22260,40 @@ function doMinify(ast, options = {}, recursive = false, errors, nestingContent,
|
|
|
22149
22260
|
if (optimized.length > 1) {
|
|
22150
22261
|
const check = optimized.at(-2);
|
|
22151
22262
|
if (!combinators.includes(check)) {
|
|
22152
|
-
|
|
22263
|
+
const last = optimized[optimized.length - 1];
|
|
22264
|
+
const all = new Array(Math.max(optimized.length - 1, 0));
|
|
22265
|
+
let write = 0;
|
|
22266
|
+
for (let read = 0; read < optimized.length - 1; read++) {
|
|
22267
|
+
all[write++] = optimized[read];
|
|
22268
|
+
}
|
|
22269
|
+
optimized.length = 0;
|
|
22270
|
+
for (let index = 0; index < write; index++) {
|
|
22271
|
+
optimized[index] = all[index];
|
|
22272
|
+
}
|
|
22153
22273
|
wrap = false;
|
|
22154
22274
|
rule =
|
|
22155
22275
|
optimized.join("") +
|
|
22156
22276
|
`:is(${selector
|
|
22157
22277
|
.map((s) => {
|
|
22278
|
+
const next = s[0] == "&" ? new Array(s.length) : new Array(s.length + 1);
|
|
22279
|
+
let write = 0;
|
|
22158
22280
|
if (s[0] == "&") {
|
|
22159
|
-
|
|
22281
|
+
next[write++] = last;
|
|
22282
|
+
for (let read = 1; read < s.length; read++) {
|
|
22283
|
+
next[write++] = s[read];
|
|
22284
|
+
}
|
|
22160
22285
|
}
|
|
22161
22286
|
else {
|
|
22162
|
-
|
|
22287
|
+
next[write++] = last;
|
|
22288
|
+
for (let read = 0; read < s.length; read++) {
|
|
22289
|
+
next[write++] = s[read];
|
|
22290
|
+
}
|
|
22291
|
+
}
|
|
22292
|
+
const rebuilt = new Array(write);
|
|
22293
|
+
for (let index = 0; index < write; index++) {
|
|
22294
|
+
rebuilt[index] = next[index];
|
|
22163
22295
|
}
|
|
22164
|
-
return
|
|
22296
|
+
return rebuilt.join("");
|
|
22165
22297
|
})
|
|
22166
22298
|
.join(",")})`;
|
|
22167
22299
|
}
|
|
@@ -22170,7 +22302,20 @@ function doMinify(ast, options = {}, recursive = false, errors, nestingContent,
|
|
|
22170
22302
|
rule = selector
|
|
22171
22303
|
.map((s) => {
|
|
22172
22304
|
if (s[0] == "&") {
|
|
22173
|
-
|
|
22305
|
+
const replacement = node[OPTIMIZED].optimized;
|
|
22306
|
+
const all = new Array(Math.max(s.length - 1 + replacement.length, 0));
|
|
22307
|
+
let write = 0;
|
|
22308
|
+
for (let read = 0; read < replacement.length; read++) {
|
|
22309
|
+
all[write++] = replacement[read];
|
|
22310
|
+
}
|
|
22311
|
+
for (let read = 1; read < s.length; read++) {
|
|
22312
|
+
all[write++] = s[read];
|
|
22313
|
+
}
|
|
22314
|
+
const rebuilt = new Array(write);
|
|
22315
|
+
for (let index = 0; index < write; index++) {
|
|
22316
|
+
rebuilt[index] = all[index];
|
|
22317
|
+
}
|
|
22318
|
+
return rebuilt.join("");
|
|
22174
22319
|
}
|
|
22175
22320
|
return s.join("");
|
|
22176
22321
|
})
|
|
@@ -22402,18 +22547,42 @@ function optimizeSelector(selector) {
|
|
|
22402
22547
|
while (optimized.length > 0) {
|
|
22403
22548
|
const last = optimized.at(-1);
|
|
22404
22549
|
if (last == " " || combinators.includes(last)) {
|
|
22405
|
-
optimized.
|
|
22550
|
+
const all = new Array(Math.max(optimized.length - 1, 0));
|
|
22551
|
+
let write = 0;
|
|
22552
|
+
for (let read = 0; read < optimized.length - 1; read++) {
|
|
22553
|
+
all[write++] = optimized[read];
|
|
22554
|
+
}
|
|
22555
|
+
optimized.length = 0;
|
|
22556
|
+
for (let index = 0; index < write; index++) {
|
|
22557
|
+
optimized[index] = all[index];
|
|
22558
|
+
}
|
|
22406
22559
|
continue;
|
|
22407
22560
|
}
|
|
22408
22561
|
break;
|
|
22409
22562
|
}
|
|
22410
22563
|
for (let i1 = 0; i1 < selector.length; i1++) {
|
|
22411
|
-
selector[i1].
|
|
22564
|
+
const all = new Array(Math.max(selector[i1].length - optimized.length, 0));
|
|
22565
|
+
let write = 0;
|
|
22566
|
+
for (let read = optimized.length; read < selector[i1].length; read++) {
|
|
22567
|
+
all[write++] = selector[i1][read];
|
|
22568
|
+
}
|
|
22569
|
+
selector[i1].length = 0;
|
|
22570
|
+
for (let index = 0; index < write; index++) {
|
|
22571
|
+
selector[i1][index] = all[index];
|
|
22572
|
+
}
|
|
22412
22573
|
}
|
|
22413
22574
|
let reducible = optimized.length == 1;
|
|
22414
22575
|
if (optimized[0] == "&") {
|
|
22415
22576
|
if (optimized[1] == " ") {
|
|
22416
|
-
optimized.
|
|
22577
|
+
const all = new Array(Math.max(optimized.length - 2, 0));
|
|
22578
|
+
let write = 0;
|
|
22579
|
+
for (let read = 2; read < optimized.length; read++) {
|
|
22580
|
+
all[write++] = optimized[read];
|
|
22581
|
+
}
|
|
22582
|
+
optimized.length = 0;
|
|
22583
|
+
for (let index = 0; index < write; index++) {
|
|
22584
|
+
optimized[index] = all[index];
|
|
22585
|
+
}
|
|
22417
22586
|
}
|
|
22418
22587
|
}
|
|
22419
22588
|
if (optimized.length == 0 || optimized[0].charAt(0) == "&" || selector.length == 1) {
|
|
@@ -23000,7 +23169,15 @@ function reduceRuleSelector(node) {
|
|
|
23000
23169
|
if (selector.length > 1 &&
|
|
23001
23170
|
selector[0] == "&" &&
|
|
23002
23171
|
(combinators.includes(selector[1]) || !/^[a-zA-Z:]/.test(selector[1]))) {
|
|
23003
|
-
selector.
|
|
23172
|
+
const all = new Array(Math.max(selector.length - 1, 0));
|
|
23173
|
+
let write = 0;
|
|
23174
|
+
for (let read = 1; read < selector.length; read++) {
|
|
23175
|
+
all[write++] = selector[read];
|
|
23176
|
+
}
|
|
23177
|
+
selector.length = 0;
|
|
23178
|
+
for (let index = 0; index < write; index++) {
|
|
23179
|
+
selector[index] = all[index];
|
|
23180
|
+
}
|
|
23004
23181
|
}
|
|
23005
23182
|
}
|
|
23006
23183
|
const unique = new Set();
|
|
@@ -23371,9 +23548,9 @@ function decode(str) {
|
|
|
23371
23548
|
* @returns
|
|
23372
23549
|
*/
|
|
23373
23550
|
function encode(value) {
|
|
23374
|
-
if (typeof value === 'number') {
|
|
23375
|
-
|
|
23376
|
-
}
|
|
23551
|
+
// if (typeof value === 'number') {
|
|
23552
|
+
// return encode_integer(value);
|
|
23553
|
+
// }
|
|
23377
23554
|
let result = '';
|
|
23378
23555
|
for (let i = 0; i < value.length; i += 1) {
|
|
23379
23556
|
result += encode_integer(value[i]);
|
|
@@ -24537,8 +24714,8 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
|
|
|
24537
24714
|
return token.val;
|
|
24538
24715
|
}
|
|
24539
24716
|
if (Array.isArray(token.chi)) {
|
|
24540
|
-
const fnName = token.val
|
|
24541
|
-
const isLegacy = ["rgb", "rgba", "hsl", "hsla"].includes(token.val
|
|
24717
|
+
const fnName = token.val;
|
|
24718
|
+
const isLegacy = ["rgb", "rgba", "hsl", "hsla"].includes(token.val);
|
|
24542
24719
|
const hasAlpha = [
|
|
24543
24720
|
"rgb",
|
|
24544
24721
|
"rgba",
|
|
@@ -25716,7 +25893,7 @@ class Tokenizer {
|
|
|
25716
25893
|
* @param parseInfo
|
|
25717
25894
|
* @returns
|
|
25718
25895
|
*/
|
|
25719
|
-
|
|
25896
|
+
consumeStringAsURLToken(parseInfo) {
|
|
25720
25897
|
const quote = this.advance(parseInfo).charCodeAt(0);
|
|
25721
25898
|
let charCode;
|
|
25722
25899
|
let decodeSegments = false;
|
|
@@ -26158,7 +26335,7 @@ class Tokenizer {
|
|
|
26158
26335
|
}
|
|
26159
26336
|
return 0;
|
|
26160
26337
|
}
|
|
26161
|
-
|
|
26338
|
+
consumeURLToken(parseInfo, endPosition) {
|
|
26162
26339
|
let charCode;
|
|
26163
26340
|
// consume an <url>
|
|
26164
26341
|
while (isWhiteSpace(this.peekCharCode(parseInfo))) {
|
|
@@ -26166,7 +26343,7 @@ class Tokenizer {
|
|
|
26166
26343
|
}
|
|
26167
26344
|
charCode = this.peekCharCode(parseInfo);
|
|
26168
26345
|
if (charCode == 34 /* TokenMap.DOUBLE_QUOTE */ || charCode == 39 /* TokenMap.SINGLE_QUOTE */) {
|
|
26169
|
-
return this.
|
|
26346
|
+
return this.consumeStringAsURLToken(parseInfo);
|
|
26170
26347
|
}
|
|
26171
26348
|
do {
|
|
26172
26349
|
this.advance(parseInfo);
|
|
@@ -26430,27 +26607,24 @@ class Tokenizer {
|
|
|
26430
26607
|
* @param end
|
|
26431
26608
|
* @returns
|
|
26432
26609
|
*/
|
|
26433
|
-
isIdentToken(parseInfo, start, end) {
|
|
26610
|
+
isIdentToken(parseInfo /* , start?: number, end?: number */) {
|
|
26434
26611
|
let j = parseInfo.currentPosition - parseInfo.offset;
|
|
26435
26612
|
let i = parseInfo.position - parseInfo.offset;
|
|
26436
|
-
if (start != null) {
|
|
26437
|
-
|
|
26438
|
-
|
|
26439
|
-
|
|
26440
|
-
|
|
26441
|
-
|
|
26442
|
-
|
|
26443
|
-
|
|
26444
|
-
|
|
26445
|
-
|
|
26446
|
-
|
|
26447
|
-
|
|
26448
|
-
|
|
26449
|
-
|
|
26450
|
-
|
|
26451
|
-
}
|
|
26452
|
-
}
|
|
26453
|
-
}
|
|
26613
|
+
// if (start != null) {
|
|
26614
|
+
// if (end == null) {
|
|
26615
|
+
// if (start < 0) {
|
|
26616
|
+
// j += start;
|
|
26617
|
+
// } else {
|
|
26618
|
+
// i += start;
|
|
26619
|
+
// }
|
|
26620
|
+
// } else {
|
|
26621
|
+
// if (end < 0) {
|
|
26622
|
+
// j += end;
|
|
26623
|
+
// } else {
|
|
26624
|
+
// j = parseInfo.position + end;
|
|
26625
|
+
// }
|
|
26626
|
+
// }
|
|
26627
|
+
// }
|
|
26454
26628
|
j--;
|
|
26455
26629
|
let codepoint = parseInfo.stream.charCodeAt(i);
|
|
26456
26630
|
// -
|
|
@@ -26493,18 +26667,18 @@ class Tokenizer {
|
|
|
26493
26667
|
* @param parseInfo
|
|
26494
26668
|
* @returns
|
|
26495
26669
|
*/
|
|
26496
|
-
isPseudo(parseInfo) {
|
|
26497
|
-
|
|
26498
|
-
|
|
26499
|
-
|
|
26500
|
-
|
|
26501
|
-
|
|
26502
|
-
|
|
26503
|
-
|
|
26504
|
-
|
|
26505
|
-
|
|
26506
|
-
|
|
26507
|
-
}
|
|
26670
|
+
// isPseudo(parseInfo: ParseInfo): boolean {
|
|
26671
|
+
// let position: number = parseInfo.currentPosition - parseInfo.offset;
|
|
26672
|
+
// let endPosition: number = parseInfo.currentPosition - parseInfo.offset;
|
|
26673
|
+
// return (parseInfo.stream.charAt(position) == ":" &&
|
|
26674
|
+
// parseInfo.stream.charAt(endPosition - 1) == "(" &&
|
|
26675
|
+
// (parseInfo.stream.charAt(position + 1) == ":"
|
|
26676
|
+
// ? this.isIdentToken(parseInfo, 2, -1)
|
|
26677
|
+
// : this.isIdentToken(parseInfo, 1, -1))) ||
|
|
26678
|
+
// parseInfo.stream.charAt(position + 1) == ":"
|
|
26679
|
+
// ? this.isIdentToken(parseInfo, 2)
|
|
26680
|
+
// : this.isIdentToken(parseInfo, 1);
|
|
26681
|
+
// }
|
|
26508
26682
|
/**
|
|
26509
26683
|
*
|
|
26510
26684
|
* @param parseInfo
|
|
@@ -26577,7 +26751,7 @@ class Tokenizer {
|
|
|
26577
26751
|
while ((charCode = this.peekCharCode(parseInfo)) == charCode) {
|
|
26578
26752
|
if (this.state === exports.EnumToken.UrlFunctionTokenDefType) {
|
|
26579
26753
|
this.state = null;
|
|
26580
|
-
return this.
|
|
26754
|
+
return this.consumeURLToken(parseInfo, endPosition);
|
|
26581
26755
|
}
|
|
26582
26756
|
if (parseInfo.position == parseInfo.currentPosition) {
|
|
26583
26757
|
if (charCode == 45 /* TokenMap.MINUS */ ||
|
|
@@ -26697,12 +26871,14 @@ class Tokenizer {
|
|
|
26697
26871
|
// '('
|
|
26698
26872
|
case 40 /* TokenMap.LEFT_PARENTHESIS */:
|
|
26699
26873
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
26700
|
-
if (
|
|
26701
|
-
|
|
26702
|
-
|
|
26703
|
-
|
|
26704
|
-
|
|
26705
|
-
|
|
26874
|
+
// if (
|
|
26875
|
+
// parseInfo.stream[parseInfo.position - parseInfo.offset] === ":" &&
|
|
26876
|
+
// this.isPseudo(parseInfo)
|
|
26877
|
+
// ) {
|
|
26878
|
+
// this.advance(parseInfo);
|
|
26879
|
+
// return this.makeToken(parseInfo, EnumToken.PseudoClassFunctionTokenDefType);
|
|
26880
|
+
// } else
|
|
26881
|
+
if (this.isIdentToken(parseInfo)) {
|
|
26706
26882
|
const hint = this.startsWith(parseInfo, "--")
|
|
26707
26883
|
? exports.EnumToken.CustomFunctionTokenDefType
|
|
26708
26884
|
: (getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset + 1) ?? exports.EnumToken.FunctionTokenDefType);
|
|
@@ -27065,7 +27241,6 @@ function parseSelector(tokens, context, options, errors) {
|
|
|
27065
27241
|
const stack = [];
|
|
27066
27242
|
const uniq = new Map();
|
|
27067
27243
|
let allowed = true;
|
|
27068
|
-
let i = 0;
|
|
27069
27244
|
let index;
|
|
27070
27245
|
let parent = context;
|
|
27071
27246
|
let nested = false;
|
|
@@ -27099,119 +27274,130 @@ function parseSelector(tokens, context, options, errors) {
|
|
|
27099
27274
|
nested = parent?.typ == exports.EnumToken.RuleNodeType;
|
|
27100
27275
|
parent = parent?.[PARENT];
|
|
27101
27276
|
} while (!nested && parent != null);
|
|
27102
|
-
|
|
27103
|
-
|
|
27104
|
-
|
|
27105
|
-
|
|
27277
|
+
const all = new Array(tokens.length);
|
|
27278
|
+
let write = 0;
|
|
27279
|
+
for (let read = 0; read < tokens.length; read++) {
|
|
27280
|
+
let token = tokens[read];
|
|
27281
|
+
if (token.typ == exports.EnumToken.ColonTokenType) {
|
|
27282
|
+
const next = tokens[read + 1];
|
|
27283
|
+
if (next?.typ == exports.EnumToken.IdenTokenType) {
|
|
27284
|
+
all[write++] = {
|
|
27285
|
+
...token,
|
|
27106
27286
|
typ: exports.EnumToken.PseudoElementTokenType,
|
|
27107
|
-
val: ":" +
|
|
27108
|
-
|
|
27109
|
-
|
|
27110
|
-
|
|
27287
|
+
val: ":" + next.val,
|
|
27288
|
+
[LOCEND]: next[LOCEND],
|
|
27289
|
+
};
|
|
27290
|
+
read++;
|
|
27111
27291
|
continue;
|
|
27112
27292
|
}
|
|
27113
|
-
if (
|
|
27114
|
-
val = ":" +
|
|
27115
|
-
|
|
27293
|
+
if (next?.typ == exports.EnumToken.FunctionTokenDefType) {
|
|
27294
|
+
val = ":" + next.val;
|
|
27295
|
+
all[write++] = {
|
|
27296
|
+
...token,
|
|
27116
27297
|
typ: val + "()" in getSyntaxConfig().selectors
|
|
27117
27298
|
? exports.EnumToken.PseudoClassFunctionTokenDefType
|
|
27118
|
-
:
|
|
27299
|
+
: next.typ,
|
|
27119
27300
|
val,
|
|
27120
|
-
|
|
27121
|
-
|
|
27122
|
-
|
|
27301
|
+
[LOCEND]: next[LOCEND],
|
|
27302
|
+
};
|
|
27303
|
+
read++;
|
|
27123
27304
|
continue;
|
|
27124
27305
|
}
|
|
27125
27306
|
}
|
|
27126
|
-
if (
|
|
27127
|
-
|
|
27128
|
-
|
|
27129
|
-
|
|
27307
|
+
if (token.typ == exports.EnumToken.DoubleColonTokenType) {
|
|
27308
|
+
const next = tokens[read + 1];
|
|
27309
|
+
val = ":" + next.val;
|
|
27310
|
+
if (next?.typ == exports.EnumToken.IdenTokenType) {
|
|
27311
|
+
all[write++] = {
|
|
27312
|
+
...token,
|
|
27130
27313
|
typ: exports.EnumToken.PseudoClassTokenType,
|
|
27131
27314
|
val: (pseudoElements.includes(val) ? "" : ":") + val,
|
|
27132
|
-
|
|
27133
|
-
|
|
27134
|
-
|
|
27315
|
+
[LOCEND]: next[LOCEND],
|
|
27316
|
+
};
|
|
27317
|
+
read++;
|
|
27135
27318
|
continue;
|
|
27136
27319
|
}
|
|
27137
|
-
if (
|
|
27138
|
-
val = "::" +
|
|
27139
|
-
|
|
27320
|
+
if (next?.typ == exports.EnumToken.FunctionTokenDefType) {
|
|
27321
|
+
val = "::" + next.val;
|
|
27322
|
+
all[write++] = {
|
|
27323
|
+
...token,
|
|
27140
27324
|
typ: val + "()" in getSyntaxConfig().selectors
|
|
27141
27325
|
? exports.EnumToken.PseudoClassFunctionTokenDefType
|
|
27142
27326
|
: exports.EnumToken.FunctionTokenDefType,
|
|
27143
27327
|
val,
|
|
27144
|
-
|
|
27145
|
-
|
|
27146
|
-
|
|
27328
|
+
[LOCEND]: next[LOCEND],
|
|
27329
|
+
};
|
|
27330
|
+
read++;
|
|
27147
27331
|
continue;
|
|
27148
27332
|
}
|
|
27149
27333
|
}
|
|
27150
|
-
if (
|
|
27151
|
-
if (isHash(
|
|
27152
|
-
|
|
27153
|
-
|
|
27154
|
-
|
|
27334
|
+
if (token.typ == exports.EnumToken.ColorTokenType) {
|
|
27335
|
+
if (isHash(token.val)) {
|
|
27336
|
+
token.typ = exports.EnumToken.HashTokenType;
|
|
27337
|
+
all[write++] = token;
|
|
27338
|
+
continue;
|
|
27155
27339
|
}
|
|
27156
|
-
|
|
27157
|
-
|
|
27158
|
-
|
|
27159
|
-
|
|
27160
|
-
|
|
27161
|
-
|
|
27162
|
-
|
|
27163
|
-
|
|
27164
|
-
|
|
27165
|
-
|
|
27166
|
-
|
|
27167
|
-
trimWhiteSpace.includes(array[index + 1]?.typ) ||
|
|
27168
|
-
combinators.includes(array[index - 1]?.val) ||
|
|
27169
|
-
combinators.includes(array[index + 1]?.val)) {
|
|
27170
|
-
return acc;
|
|
27171
|
-
}
|
|
27172
|
-
}
|
|
27173
|
-
let t = renderValue(curr, { minify: false });
|
|
27174
|
-
if (t == ",") {
|
|
27175
|
-
acc.push([]);
|
|
27176
|
-
}
|
|
27177
|
-
else {
|
|
27178
|
-
acc[acc.length - 1].push(t);
|
|
27340
|
+
return {
|
|
27341
|
+
typ: exports.EnumToken.RuleNodeType,
|
|
27342
|
+
sel: [
|
|
27343
|
+
...tokens
|
|
27344
|
+
.reduce((acc, curr, index, array) => {
|
|
27345
|
+
if (curr.typ == exports.EnumToken.WhitespaceTokenType) {
|
|
27346
|
+
if (trimWhiteSpace.includes(array[index - 1]?.typ) ||
|
|
27347
|
+
trimWhiteSpace.includes(array[index + 1]?.typ) ||
|
|
27348
|
+
combinators.includes(array[index - 1]?.val) ||
|
|
27349
|
+
combinators.includes(array[index + 1]?.val)) {
|
|
27350
|
+
return acc;
|
|
27179
27351
|
}
|
|
27180
|
-
|
|
27181
|
-
|
|
27182
|
-
|
|
27183
|
-
|
|
27184
|
-
|
|
27185
|
-
|
|
27186
|
-
|
|
27187
|
-
|
|
27188
|
-
|
|
27189
|
-
|
|
27190
|
-
|
|
27352
|
+
}
|
|
27353
|
+
let t = renderValue(curr, { minify: false });
|
|
27354
|
+
if (t == ",") {
|
|
27355
|
+
acc.push([]);
|
|
27356
|
+
}
|
|
27357
|
+
else {
|
|
27358
|
+
acc[acc.length - 1].push(t);
|
|
27359
|
+
}
|
|
27360
|
+
return acc;
|
|
27361
|
+
}, [[]])
|
|
27362
|
+
.reduce((acc, curr) => {
|
|
27363
|
+
let i = 0;
|
|
27364
|
+
for (; i < curr.length; i++) {
|
|
27365
|
+
if (i + 1 < curr.length && curr[i] == "*") {
|
|
27366
|
+
if (curr[i] == "*") {
|
|
27367
|
+
let index = curr[i + 1] == " " ? 2 : 1;
|
|
27368
|
+
if (![">", "~", "+"].includes(curr[index])) {
|
|
27369
|
+
curr.splice(i, index);
|
|
27191
27370
|
}
|
|
27192
27371
|
}
|
|
27193
27372
|
}
|
|
27194
|
-
|
|
27195
|
-
|
|
27196
|
-
|
|
27197
|
-
|
|
27198
|
-
|
|
27199
|
-
|
|
27200
|
-
|
|
27201
|
-
|
|
27202
|
-
|
|
27203
|
-
|
|
27204
|
-
|
|
27205
|
-
|
|
27206
|
-
|
|
27207
|
-
|
|
27208
|
-
|
|
27209
|
-
|
|
27210
|
-
|
|
27211
|
-
|
|
27212
|
-
|
|
27213
|
-
}
|
|
27373
|
+
}
|
|
27374
|
+
acc.set(curr.join(""), curr);
|
|
27375
|
+
return acc;
|
|
27376
|
+
}, uniq)
|
|
27377
|
+
.keys(),
|
|
27378
|
+
].join(","),
|
|
27379
|
+
chi: [],
|
|
27380
|
+
[LOCSRCID]: tokens[0][LOCSRCID],
|
|
27381
|
+
[LOCSTA]: tokens[0][LOCSTA],
|
|
27382
|
+
[LOCEND]: tokens[tokens.length - 1][LOCEND],
|
|
27383
|
+
[TOKENS]: tokens,
|
|
27384
|
+
[STATE]: exports.EnumAstNodeStatus.Invalid,
|
|
27385
|
+
[ERRORS]: [
|
|
27386
|
+
{
|
|
27387
|
+
action: "drop",
|
|
27388
|
+
node: token,
|
|
27389
|
+
message: "invalid hash id",
|
|
27390
|
+
},
|
|
27391
|
+
],
|
|
27392
|
+
};
|
|
27214
27393
|
}
|
|
27394
|
+
all[write++] = token;
|
|
27395
|
+
}
|
|
27396
|
+
if (write !== tokens.length) {
|
|
27397
|
+
for (let index = 0; index < write; index++) {
|
|
27398
|
+
tokens[index] = all[index];
|
|
27399
|
+
}
|
|
27400
|
+
tokens.length = write;
|
|
27215
27401
|
}
|
|
27216
27402
|
const result = matchSelectorSyntax(tokens, errors, options, nested === true);
|
|
27217
27403
|
trimArray(tokens);
|
|
@@ -27530,7 +27716,6 @@ function parseGridTemplate(template) {
|
|
|
27530
27716
|
* @param errors
|
|
27531
27717
|
*/
|
|
27532
27718
|
function parseDeclaration(tokens, parent, options, errors) {
|
|
27533
|
-
// console.error(tokens);
|
|
27534
27719
|
const name = tokens.shift();
|
|
27535
27720
|
let i;
|
|
27536
27721
|
let rules = null;
|
|
@@ -27864,10 +28049,19 @@ function parseDeclaration(tokens, parent, options, errors) {
|
|
|
27864
28049
|
}
|
|
27865
28050
|
if (trimTokenSpace$1.has(token.typ)) {
|
|
27866
28051
|
if (tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
|
|
27867
|
-
|
|
28052
|
+
for (let index = i + 1; index < tokens.length - 1; index++) {
|
|
28053
|
+
tokens[index] = tokens[index + 1];
|
|
28054
|
+
}
|
|
28055
|
+
tokens.length--;
|
|
28056
|
+
i--;
|
|
28057
|
+
continue;
|
|
27868
28058
|
}
|
|
27869
28059
|
if (tokens[i - 1]?.typ == exports.EnumToken.WhitespaceTokenType) {
|
|
27870
|
-
|
|
28060
|
+
for (let index = i - 1; index < tokens.length - 1; index++) {
|
|
28061
|
+
tokens[index] = tokens[index + 1];
|
|
28062
|
+
}
|
|
28063
|
+
tokens.length--;
|
|
28064
|
+
i--;
|
|
27871
28065
|
}
|
|
27872
28066
|
}
|
|
27873
28067
|
}
|
|
@@ -32609,17 +32803,18 @@ function parseAtRule(stream, context, options, errors, parseAsBlock = null) {
|
|
|
32609
32803
|
* console.log(declarations);
|
|
32610
32804
|
* ```
|
|
32611
32805
|
*/
|
|
32612
|
-
|
|
32806
|
+
function parseDeclarations(declaration) {
|
|
32613
32807
|
const stream = `.x{${declaration}}`;
|
|
32614
|
-
|
|
32808
|
+
const result = doParseSync(new Tokenizer({
|
|
32615
32809
|
stream,
|
|
32616
32810
|
offset: 0,
|
|
32617
32811
|
position: 0,
|
|
32618
32812
|
source: new SourceFile(stream, [], ""),
|
|
32619
32813
|
currentPosition: 0,
|
|
32620
|
-
}), { setParent: false, minify: false, validation: false })
|
|
32621
|
-
|
|
32622
|
-
|
|
32814
|
+
}), { setParent: false, minify: false, validation: false });
|
|
32815
|
+
// .then((result) => {
|
|
32816
|
+
return result.ast.chi[0].chi.filter((t) => t.typ == exports.EnumToken.DeclarationNodeType || t.typ == exports.EnumToken.CommentNodeType);
|
|
32817
|
+
// });
|
|
32623
32818
|
}
|
|
32624
32819
|
/**
|
|
32625
32820
|
* Parse css string and return an array of tokens
|