@tbela99/css-parser 1.7.0 → 1.8.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 +30 -0
- package/README.md +1 -0
- package/dist/index-umd-web.js +926 -293
- package/dist/index.cjs +925 -292
- package/dist/index.d.ts +251 -7
- package/dist/package.json.js +2 -2
- package/dist/src/data/properties.json.js +1 -1
- package/dist/src/data/validation.json.js +4 -1
- package/dist/src/lib/ast/clone.js +1 -1
- package/dist/src/lib/ast/expand.js +1 -1
- package/dist/src/lib/ast/features/calc.js +1 -1
- package/dist/src/lib/ast/features/if.js +1 -1
- package/dist/src/lib/ast/features/index.js +1 -1
- package/dist/src/lib/ast/features/inlinecssvariables.js +6 -5
- package/dist/src/lib/ast/features/prefix.js +1 -1
- package/dist/src/lib/ast/features/shorthand.js +1 -1
- package/dist/src/lib/ast/features/transform.js +1 -1
- package/dist/src/lib/ast/features/type.js +1 -1
- package/dist/src/lib/ast/find.js +26 -21
- package/dist/src/lib/ast/math/expression.js +4 -1
- package/dist/src/lib/ast/math/math.js +1 -1
- package/dist/src/lib/ast/minify.js +1 -1
- package/dist/src/lib/ast/node.js +1 -1
- package/dist/src/lib/ast/transform/compute.js +1 -1
- package/dist/src/lib/ast/transform/matrix.js +1 -1
- package/dist/src/lib/ast/transform/minify.js +1 -1
- package/dist/src/lib/ast/transform/perspective.js +1 -1
- package/dist/src/lib/ast/transform/rotate.js +1 -1
- package/dist/src/lib/ast/transform/scale.js +1 -1
- package/dist/src/lib/ast/transform/skew.js +1 -1
- package/dist/src/lib/ast/transform/translate.js +1 -1
- package/dist/src/lib/ast/transform/utils.js +1 -1
- package/dist/src/lib/ast/types.js +5 -1
- package/dist/src/lib/ast/walk.js +319 -94
- package/dist/src/lib/fs/resolve.js +1 -1
- package/dist/src/lib/parser/declaration/list.js +25 -1
- package/dist/src/lib/parser/declaration/map.js +1 -1
- package/dist/src/lib/parser/declaration/set.js +1 -1
- package/dist/src/lib/parser/linesmap.js +1 -1
- package/dist/src/lib/parser/parse.js +501 -165
- package/dist/src/lib/parser/source.js +1 -1
- package/dist/src/lib/parser/tokenize.js +23 -3
- package/dist/src/lib/parser/utils/angle.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-container.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-font-feature-values.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-generic.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-import.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-media.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-support.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-when-else.js +1 -1
- package/dist/src/lib/parser/utils/at-rule.js +1 -1
- package/dist/src/lib/parser/utils/base64.js +1 -1
- package/dist/src/lib/parser/utils/cache.js +1 -1
- package/dist/src/lib/parser/utils/config.js +1 -1
- package/dist/src/lib/parser/utils/declaration.js +1 -1
- package/dist/src/lib/parser/utils/eq.js +1 -1
- package/dist/src/lib/parser/utils/hash.js +1 -1
- package/dist/src/lib/parser/utils/selector.js +1 -1
- package/dist/src/lib/parser/utils/text.js +1 -1
- package/dist/src/lib/parser/utils/token.js +12 -5
- package/dist/src/lib/parser/utils/type.js +1 -1
- package/dist/src/lib/printer/render.js +5 -2
- package/dist/src/lib/printer/sourcemap/lib/codec.js +1 -1
- package/dist/src/lib/printer/sourcemap/sourcemap.js +1 -1
- package/dist/src/lib/syntax/color/a98rgb.js +1 -1
- package/dist/src/lib/syntax/color/alpha.js +1 -1
- package/dist/src/lib/syntax/color/cmyk.js +1 -1
- package/dist/src/lib/syntax/color/color-mix.js +1 -1
- package/dist/src/lib/syntax/color/color.js +1 -1
- package/dist/src/lib/syntax/color/hex.js +1 -1
- package/dist/src/lib/syntax/color/hsl.js +1 -1
- package/dist/src/lib/syntax/color/hwb.js +1 -1
- package/dist/src/lib/syntax/color/lab.js +1 -1
- package/dist/src/lib/syntax/color/lch.js +1 -1
- package/dist/src/lib/syntax/color/oklab.js +1 -1
- package/dist/src/lib/syntax/color/oklch.js +1 -1
- package/dist/src/lib/syntax/color/p3.js +1 -1
- package/dist/src/lib/syntax/color/prophotorgb.js +1 -1
- package/dist/src/lib/syntax/color/rec2020.js +1 -1
- package/dist/src/lib/syntax/color/relative-color.js +1 -1
- package/dist/src/lib/syntax/color/rgb.js +1 -1
- package/dist/src/lib/syntax/color/srgb.js +1 -1
- package/dist/src/lib/syntax/color/utils/color-type.js +1 -1
- package/dist/src/lib/syntax/color/utils/colorspace.js +1 -1
- package/dist/src/lib/syntax/color/utils/components.js +1 -1
- package/dist/src/lib/syntax/color/utils/distance.js +1 -1
- package/dist/src/lib/syntax/color/utils/make-color.js +1 -1
- package/dist/src/lib/syntax/color/utils/matrix.js +1 -1
- package/dist/src/lib/syntax/color/xyz.js +1 -1
- package/dist/src/lib/syntax/color/xyzd50.js +1 -1
- package/dist/src/lib/syntax/constants.js +1 -1
- package/dist/src/lib/syntax/syntax.js +1 -1
- package/dist/src/lib/validation/config.js +1 -1
- package/dist/src/lib/validation/match.js +8 -5
- package/dist/src/lib/validation/parser/parse.js +1 -1
- package/dist/src/lib/validation/parser/typedef.js +1 -1
- package/dist/src/lib/validation/utils/list.js +1 -1
- package/dist/src/node.js +1 -1
- package/dist/src/types.js +1 -1
- package/dist/src/utils/sync.js +1 -1
- package/dist/src/web.js +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -693,6 +693,10 @@ exports.EnumToken = void 0;
|
|
|
693
693
|
* CSS type token
|
|
694
694
|
*/
|
|
695
695
|
EnumToken[EnumToken["CssTypeTokenType"] = 144] = "CssTypeTokenType";
|
|
696
|
+
/**
|
|
697
|
+
* user defined dimension token type
|
|
698
|
+
*/
|
|
699
|
+
EnumToken[EnumToken["UserDefinedDimensionTokenType"] = 145] = "UserDefinedDimensionTokenType";
|
|
696
700
|
/* aliases */
|
|
697
701
|
/**
|
|
698
702
|
* alias for time token type
|
|
@@ -5725,6 +5729,9 @@ var atRules = {
|
|
|
5725
5729
|
"@apply": {
|
|
5726
5730
|
syntax: " @apply [ <dashed-ident> | <dashed-function> ] [ { <declaration-list> } ]?;"
|
|
5727
5731
|
},
|
|
5732
|
+
"@contents": {
|
|
5733
|
+
syntax: " @contents [ { <declaration-list> } ]?;"
|
|
5734
|
+
},
|
|
5728
5735
|
"@left-top": {
|
|
5729
5736
|
syntax: " @left-top { <declaration-list> }"
|
|
5730
5737
|
},
|
|
@@ -9689,7 +9696,6 @@ exports.WalkerEvent = void 0;
|
|
|
9689
9696
|
*/
|
|
9690
9697
|
WalkerEvent[WalkerEvent["Leave"] = 2] = "Leave";
|
|
9691
9698
|
})(exports.WalkerEvent || (exports.WalkerEvent = {}));
|
|
9692
|
-
const maxQueueLength = 25000;
|
|
9693
9699
|
/**
|
|
9694
9700
|
* Walk ast nodes
|
|
9695
9701
|
* @param node initial node
|
|
@@ -9772,7 +9778,6 @@ function* walk(node, filter, reverse) {
|
|
|
9772
9778
|
let isNumeric = false;
|
|
9773
9779
|
let children = true;
|
|
9774
9780
|
let attributes = false;
|
|
9775
|
-
let i = 0;
|
|
9776
9781
|
if (options != null && typeof options == "object") {
|
|
9777
9782
|
filter = options.filter;
|
|
9778
9783
|
reverse = options.reverse;
|
|
@@ -9792,12 +9797,11 @@ function* walk(node, filter, reverse) {
|
|
|
9792
9797
|
}
|
|
9793
9798
|
},
|
|
9794
9799
|
};
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
let option = null;
|
|
9800
|
+
let option = null;
|
|
9801
|
+
let source = [];
|
|
9802
|
+
while (parents.length > 0) {
|
|
9803
|
+
node = parents.pop();
|
|
9804
|
+
// enter node
|
|
9801
9805
|
if (filter != null) {
|
|
9802
9806
|
// @ts-expect-error
|
|
9803
9807
|
option = filter(node);
|
|
@@ -9818,36 +9822,175 @@ function* walk(node, filter, reverse) {
|
|
|
9818
9822
|
yield result;
|
|
9819
9823
|
}
|
|
9820
9824
|
if (attributes) {
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9825
|
+
source.length = 0;
|
|
9826
|
+
if (Array.isArray(node[TOKENS])) {
|
|
9827
|
+
if (reverse) {
|
|
9828
|
+
for (const token of node[TOKENS]) {
|
|
9829
|
+
parents.push(token);
|
|
9830
|
+
token[PARENT] = node;
|
|
9831
|
+
}
|
|
9832
|
+
}
|
|
9833
|
+
else {
|
|
9834
|
+
for (let i = node[TOKENS].length - 1; i >= 0; i--) {
|
|
9835
|
+
parents.push(node[TOKENS][i]);
|
|
9836
|
+
node[TOKENS][i][PARENT] = node;
|
|
9827
9837
|
}
|
|
9828
9838
|
}
|
|
9829
|
-
// @ts-expect-error
|
|
9830
9839
|
}
|
|
9831
|
-
else if (
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9840
|
+
else if (node.typ == exports.EnumToken.DeclarationNodeType) {
|
|
9841
|
+
if (reverse) {
|
|
9842
|
+
for (const token of node.val) {
|
|
9843
|
+
parents.push(token);
|
|
9844
|
+
token[PARENT] = node;
|
|
9845
|
+
}
|
|
9846
|
+
}
|
|
9847
|
+
else {
|
|
9848
|
+
for (let i = node.val.length - 1; i >= 0; i--) {
|
|
9849
|
+
parents.push(node.val[i]);
|
|
9850
|
+
node.val[i][PARENT] = node;
|
|
9851
|
+
}
|
|
9852
|
+
}
|
|
9853
|
+
}
|
|
9854
|
+
else {
|
|
9855
|
+
source.length = 0;
|
|
9856
|
+
switch (node.typ) {
|
|
9857
|
+
case exports.EnumToken.BinaryExpressionTokenType:
|
|
9858
|
+
case exports.EnumToken.IfElseConditionTokenType:
|
|
9859
|
+
source.push(node.l);
|
|
9860
|
+
node.l[PARENT] = node;
|
|
9861
|
+
source.push(node.r);
|
|
9862
|
+
node.r[PARENT] = node;
|
|
9863
|
+
break;
|
|
9864
|
+
case exports.EnumToken.MatchExpressionTokenType:
|
|
9865
|
+
source.push(node.l);
|
|
9866
|
+
node.l[PARENT] = node;
|
|
9867
|
+
source.push(node.op);
|
|
9868
|
+
node.op[PARENT] = node;
|
|
9869
|
+
source.push(node.r);
|
|
9870
|
+
node.r[PARENT] = node;
|
|
9871
|
+
break;
|
|
9872
|
+
case exports.EnumToken.SupportsQueryConditionTokenType:
|
|
9873
|
+
case exports.EnumToken.MediaQueryConditionTokenType:
|
|
9874
|
+
for (let i = 0; i < node.l.length; i++) {
|
|
9875
|
+
const element = node.l[i];
|
|
9876
|
+
source.push(element);
|
|
9877
|
+
element[PARENT] = node;
|
|
9878
|
+
}
|
|
9879
|
+
source.push(node.op);
|
|
9880
|
+
node.op[PARENT] = node;
|
|
9881
|
+
for (let i = 0; i < node.r.length; i++) {
|
|
9882
|
+
const element = node.r[i];
|
|
9883
|
+
source.push(element);
|
|
9884
|
+
element[PARENT] = node;
|
|
9885
|
+
}
|
|
9886
|
+
break;
|
|
9887
|
+
case exports.EnumToken.WhenElseQueryConditionTokenType:
|
|
9888
|
+
source.push(node.l);
|
|
9889
|
+
node.l[PARENT] = node;
|
|
9890
|
+
for (let i = 0; i < node.r.length; i++) {
|
|
9891
|
+
const element = node.r[i];
|
|
9892
|
+
source.push(element);
|
|
9893
|
+
element[PARENT] = node;
|
|
9894
|
+
}
|
|
9895
|
+
break;
|
|
9896
|
+
case exports.EnumToken.ComposesSelectorNodeType:
|
|
9897
|
+
for (let i = 0; i < node.l.length; i++) {
|
|
9898
|
+
const element = node.l[i];
|
|
9899
|
+
source.push(element);
|
|
9900
|
+
element[PARENT] = node;
|
|
9901
|
+
}
|
|
9902
|
+
if (node.r != null) {
|
|
9903
|
+
source.push(node.r);
|
|
9904
|
+
node.r[PARENT] = node;
|
|
9905
|
+
}
|
|
9906
|
+
break;
|
|
9907
|
+
case exports.EnumToken.IfConditionTokenType:
|
|
9908
|
+
for (let i = 0; i < node.l.length; i++) {
|
|
9909
|
+
const element = node.l[i];
|
|
9910
|
+
source.push(element);
|
|
9911
|
+
element[PARENT] = node;
|
|
9912
|
+
}
|
|
9913
|
+
for (let i = 0; i < node.r.length; i++) {
|
|
9914
|
+
const element = node.r[i];
|
|
9915
|
+
source.push(element);
|
|
9916
|
+
element[PARENT] = node;
|
|
9917
|
+
}
|
|
9918
|
+
break;
|
|
9919
|
+
case exports.EnumToken.ContainerStyleRangeTokenType:
|
|
9920
|
+
for (let i = 0; i < node.l.length; i++) {
|
|
9921
|
+
const element = node.l[i];
|
|
9922
|
+
source.push(element);
|
|
9923
|
+
element[PARENT] = node;
|
|
9924
|
+
}
|
|
9925
|
+
for (let i = 0; i < node.op.length; i++) {
|
|
9926
|
+
const element = node.op[i];
|
|
9927
|
+
source.push(element);
|
|
9928
|
+
element[PARENT] = node;
|
|
9929
|
+
}
|
|
9930
|
+
for (let i = 0; i < node.r.length; i++) {
|
|
9931
|
+
const element = node.r[i];
|
|
9932
|
+
source.push(element);
|
|
9933
|
+
element[PARENT] = node;
|
|
9934
|
+
}
|
|
9935
|
+
break;
|
|
9936
|
+
case exports.EnumToken.MediaRangeQueryTokenType:
|
|
9937
|
+
for (let i = 0; i < node.l.length; i++) {
|
|
9938
|
+
const element = node.l[i];
|
|
9939
|
+
source.push(element);
|
|
9940
|
+
element[PARENT] = node;
|
|
9941
|
+
}
|
|
9942
|
+
source.push(node.op1);
|
|
9943
|
+
node.op1[PARENT] = node;
|
|
9944
|
+
for (let i = 0; i < node.val.length; i++) {
|
|
9945
|
+
const element = node.val[i];
|
|
9946
|
+
source.push(element);
|
|
9947
|
+
element[PARENT] = node;
|
|
9948
|
+
}
|
|
9949
|
+
source.push(node.op2);
|
|
9950
|
+
node.op2[PARENT] = node;
|
|
9951
|
+
for (let i = 0; i < node.r.length; i++) {
|
|
9952
|
+
const element = node.r[i];
|
|
9953
|
+
source.push(element);
|
|
9954
|
+
element[PARENT] = node;
|
|
9955
|
+
}
|
|
9956
|
+
break;
|
|
9957
|
+
}
|
|
9958
|
+
if (source.length > 0) {
|
|
9959
|
+
if (reverse) {
|
|
9960
|
+
for (let i = 0; i < source.length; i++) {
|
|
9961
|
+
parents.push(source[i]);
|
|
9962
|
+
source[i][PARENT] = node;
|
|
9963
|
+
}
|
|
9964
|
+
}
|
|
9965
|
+
else {
|
|
9966
|
+
for (let i = source.length - 1; i >= 0; i--) {
|
|
9967
|
+
parents.push(source[i]);
|
|
9968
|
+
source[i][PARENT] = node;
|
|
9969
|
+
}
|
|
9836
9970
|
}
|
|
9837
9971
|
}
|
|
9838
|
-
// @ts-expect-error
|
|
9839
|
-
parents.splice(i, 0, ...(reverse ? node.val.toReversed() : node.val));
|
|
9840
9972
|
}
|
|
9841
9973
|
}
|
|
9842
9974
|
if (children &&
|
|
9843
9975
|
// @ts-expect-error
|
|
9844
9976
|
node["chi"] != null &&
|
|
9845
9977
|
(!isNumeric || (option & exports.WalkerOptionEnum.IgnoreChildren) === 0)) {
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9978
|
+
if (reverse) {
|
|
9979
|
+
// @ts-expect-error
|
|
9980
|
+
for (let i = 0; i < node.chi.length; i++) {
|
|
9981
|
+
// @ts-expect-error
|
|
9982
|
+
parents.push(node.chi[i]);
|
|
9983
|
+
// @ts-expect-error
|
|
9984
|
+
node.chi[i][PARENT] = node;
|
|
9985
|
+
}
|
|
9986
|
+
}
|
|
9987
|
+
else {
|
|
9988
|
+
// @ts-expect-error
|
|
9989
|
+
for (let i = node.chi.length - 1; i >= 0; i--) {
|
|
9990
|
+
// @ts-expect-error
|
|
9991
|
+
parents.push(node.chi[i]);
|
|
9992
|
+
// @ts-expect-error
|
|
9993
|
+
node.chi[i][PARENT] = node;
|
|
9851
9994
|
}
|
|
9852
9995
|
}
|
|
9853
9996
|
}
|
|
@@ -9900,9 +10043,19 @@ function* walk(node, filter, reverse) {
|
|
|
9900
10043
|
* // [ "Iden", "from" ]
|
|
9901
10044
|
* ```
|
|
9902
10045
|
*/
|
|
9903
|
-
function* walkValues(
|
|
9904
|
-
const
|
|
10046
|
+
function* walkValues(tokens, root = null, filter, reverse) {
|
|
10047
|
+
const nodes = [];
|
|
9905
10048
|
let previous = null;
|
|
10049
|
+
if (reverse) {
|
|
10050
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
10051
|
+
nodes.push(tokens[i]);
|
|
10052
|
+
}
|
|
10053
|
+
}
|
|
10054
|
+
else {
|
|
10055
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
10056
|
+
nodes.push(tokens[i]);
|
|
10057
|
+
}
|
|
10058
|
+
}
|
|
9906
10059
|
if (filter != null && typeof filter == "function") {
|
|
9907
10060
|
filter = {
|
|
9908
10061
|
event: exports.WalkerEvent.Enter,
|
|
@@ -9918,7 +10071,7 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
9918
10071
|
let value;
|
|
9919
10072
|
let option;
|
|
9920
10073
|
let node;
|
|
9921
|
-
|
|
10074
|
+
const values = [];
|
|
9922
10075
|
const eventType = filter.event ?? exports.WalkerEvent.Enter;
|
|
9923
10076
|
// @ts-ignore
|
|
9924
10077
|
const result = {
|
|
@@ -9937,13 +10090,9 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
9937
10090
|
}
|
|
9938
10091
|
},
|
|
9939
10092
|
};
|
|
9940
|
-
while (
|
|
9941
|
-
value =
|
|
10093
|
+
while (nodes.length > 0) {
|
|
10094
|
+
value = nodes.pop();
|
|
9942
10095
|
option = null;
|
|
9943
|
-
if (i > maxQueueLength) {
|
|
9944
|
-
stack.splice(0, maxQueueLength);
|
|
9945
|
-
i -= maxQueueLength;
|
|
9946
|
-
}
|
|
9947
10096
|
if (filter.fn != null && eventType & exports.WalkerEvent.Enter) {
|
|
9948
10097
|
const isValid = filter.type == null ||
|
|
9949
10098
|
value.typ == filter.type ||
|
|
@@ -9971,10 +10120,16 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
9971
10120
|
//
|
|
9972
10121
|
if (option != null && typeof option == "object" && ("typ" in option || Array.isArray(option))) {
|
|
9973
10122
|
const op = Array.isArray(option) ? option : [option];
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
10123
|
+
if (reverse) {
|
|
10124
|
+
for (let i = 0; i < op.length; i++) {
|
|
10125
|
+
nodes.push(op[i]);
|
|
10126
|
+
op[i][PARENT] = value;
|
|
10127
|
+
}
|
|
10128
|
+
}
|
|
10129
|
+
else {
|
|
10130
|
+
for (let i = op.length - 1; i >= 0; i--) {
|
|
10131
|
+
nodes.push(op[i]);
|
|
10132
|
+
op[i][PARENT] = value;
|
|
9978
10133
|
}
|
|
9979
10134
|
}
|
|
9980
10135
|
}
|
|
@@ -9983,70 +10138,140 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
9983
10138
|
result.value = value;
|
|
9984
10139
|
result.parent = value[PARENT] ?? root;
|
|
9985
10140
|
result.previousValue = previous;
|
|
9986
|
-
result.nextValue =
|
|
10141
|
+
result.nextValue = nodes[nodes.length - 1] ?? null;
|
|
9987
10142
|
yield result;
|
|
9988
10143
|
if (!isNumeric || (option & exports.WalkerOptionEnum.IgnoreChildren) === 0) {
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
stack.unshift(child);
|
|
10144
|
+
//
|
|
10145
|
+
if (value.chi != null) {
|
|
10146
|
+
const source = value.chi;
|
|
10147
|
+
if (reverse) {
|
|
10148
|
+
for (let i = 0; i < source.length; i++) {
|
|
10149
|
+
nodes.push(source[i]);
|
|
10150
|
+
source[i][PARENT] = value;
|
|
9997
10151
|
}
|
|
9998
|
-
|
|
9999
|
-
|
|
10152
|
+
}
|
|
10153
|
+
else {
|
|
10154
|
+
for (let i = source.length - 1; i >= 0; i--) {
|
|
10155
|
+
nodes.push(source[i]);
|
|
10156
|
+
source[i][PARENT] = value;
|
|
10000
10157
|
}
|
|
10001
10158
|
}
|
|
10002
10159
|
}
|
|
10003
10160
|
else {
|
|
10004
|
-
|
|
10005
|
-
|
|
10006
|
-
|
|
10007
|
-
|
|
10008
|
-
|
|
10009
|
-
if (value.l[PARENT] != value) {
|
|
10010
|
-
// @ts-expect-error
|
|
10161
|
+
values.length = 0;
|
|
10162
|
+
switch (value.typ) {
|
|
10163
|
+
case exports.EnumToken.BinaryExpressionTokenType:
|
|
10164
|
+
case exports.EnumToken.IfElseConditionTokenType:
|
|
10165
|
+
values.push(value.l);
|
|
10011
10166
|
value.l[PARENT] = value;
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
// @ts-expect-error
|
|
10167
|
+
values.push(value.r);
|
|
10168
|
+
value.r[PARENT] = value;
|
|
10169
|
+
break;
|
|
10170
|
+
case exports.EnumToken.MatchExpressionTokenType:
|
|
10171
|
+
values.push(value.l);
|
|
10172
|
+
value.l[PARENT] = value;
|
|
10173
|
+
values.push(value.op);
|
|
10020
10174
|
value.op[PARENT] = value;
|
|
10021
|
-
}
|
|
10022
|
-
}
|
|
10023
|
-
if ("r" in value && value.r != null) {
|
|
10024
|
-
if (Array.isArray(value.r)) {
|
|
10025
|
-
for (const r of value.r) {
|
|
10026
|
-
//
|
|
10027
|
-
values.push(r);
|
|
10028
|
-
if (r[PARENT] != value) {
|
|
10029
|
-
//
|
|
10030
|
-
r[PARENT] = value;
|
|
10031
|
-
}
|
|
10032
|
-
}
|
|
10033
|
-
}
|
|
10034
|
-
else {
|
|
10035
|
-
//
|
|
10036
10175
|
values.push(value.r);
|
|
10037
|
-
|
|
10038
|
-
|
|
10176
|
+
value.r[PARENT] = value;
|
|
10177
|
+
break;
|
|
10178
|
+
case exports.EnumToken.SupportsQueryConditionTokenType:
|
|
10179
|
+
case exports.EnumToken.MediaQueryConditionTokenType:
|
|
10180
|
+
for (let i = 0; i < value.l.length; i++) {
|
|
10181
|
+
const element = value.l[i];
|
|
10182
|
+
values.push(element);
|
|
10183
|
+
element[PARENT] = value;
|
|
10184
|
+
}
|
|
10185
|
+
values.push(value.op);
|
|
10186
|
+
value.op[PARENT] = value;
|
|
10187
|
+
for (let i = 0; i < value.r.length; i++) {
|
|
10188
|
+
const element = value.r[i];
|
|
10189
|
+
values.push(element);
|
|
10190
|
+
element[PARENT] = value;
|
|
10191
|
+
}
|
|
10192
|
+
break;
|
|
10193
|
+
case exports.EnumToken.ComposesSelectorNodeType:
|
|
10194
|
+
for (let i = 0; i < value.l.length; i++) {
|
|
10195
|
+
const element = value.l[i];
|
|
10196
|
+
values.push(element);
|
|
10197
|
+
element[PARENT] = value;
|
|
10198
|
+
}
|
|
10199
|
+
if (value.r != null) {
|
|
10200
|
+
values.push(value.r);
|
|
10039
10201
|
value.r[PARENT] = value;
|
|
10040
10202
|
}
|
|
10041
|
-
|
|
10203
|
+
break;
|
|
10204
|
+
case exports.EnumToken.WhenElseQueryConditionTokenType:
|
|
10205
|
+
values.push(value.l);
|
|
10206
|
+
value.l[PARENT] = value;
|
|
10207
|
+
for (let i = 0; i < value.r.length; i++) {
|
|
10208
|
+
const element = value.r[i];
|
|
10209
|
+
values.push(element);
|
|
10210
|
+
element[PARENT] = value;
|
|
10211
|
+
}
|
|
10212
|
+
break;
|
|
10213
|
+
case exports.EnumToken.IfConditionTokenType:
|
|
10214
|
+
for (let i = 0; i < value.l.length; i++) {
|
|
10215
|
+
const element = value.l[i];
|
|
10216
|
+
values.push(element);
|
|
10217
|
+
element[PARENT] = value;
|
|
10218
|
+
}
|
|
10219
|
+
for (let i = 0; i < value.r.length; i++) {
|
|
10220
|
+
const element = value.r[i];
|
|
10221
|
+
values.push(element);
|
|
10222
|
+
element[PARENT] = value;
|
|
10223
|
+
}
|
|
10224
|
+
break;
|
|
10225
|
+
case exports.EnumToken.ContainerStyleRangeTokenType:
|
|
10226
|
+
for (let i = 0; i < value.l.length; i++) {
|
|
10227
|
+
const element = value.l[i];
|
|
10228
|
+
values.push(element);
|
|
10229
|
+
element[PARENT] = value;
|
|
10230
|
+
}
|
|
10231
|
+
for (let i = 0; i < value.op.length; i++) {
|
|
10232
|
+
const element = value.op[i];
|
|
10233
|
+
values.push(element);
|
|
10234
|
+
element[PARENT] = value;
|
|
10235
|
+
}
|
|
10236
|
+
for (let i = 0; i < value.r.length; i++) {
|
|
10237
|
+
const element = value.r[i];
|
|
10238
|
+
values.push(element);
|
|
10239
|
+
element[PARENT] = value;
|
|
10240
|
+
}
|
|
10241
|
+
break;
|
|
10242
|
+
case exports.EnumToken.MediaRangeQueryTokenType:
|
|
10243
|
+
for (let i = 0; i < value.l.length; i++) {
|
|
10244
|
+
const element = value.l[i];
|
|
10245
|
+
values.push(element);
|
|
10246
|
+
element[PARENT] = value;
|
|
10247
|
+
}
|
|
10248
|
+
values.push(value.op1);
|
|
10249
|
+
value.op1[PARENT] = value;
|
|
10250
|
+
for (let i = 0; i < value.val.length; i++) {
|
|
10251
|
+
const element = value.val[i];
|
|
10252
|
+
values.push(element);
|
|
10253
|
+
element[PARENT] = value;
|
|
10254
|
+
}
|
|
10255
|
+
values.push(value.op2);
|
|
10256
|
+
value.op2[PARENT] = value;
|
|
10257
|
+
for (let i = 0; i < value.r.length; i++) {
|
|
10258
|
+
const element = value.r[i];
|
|
10259
|
+
values.push(element);
|
|
10260
|
+
element[PARENT] = value;
|
|
10261
|
+
}
|
|
10262
|
+
break;
|
|
10042
10263
|
}
|
|
10043
10264
|
if (values.length > 0) {
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10265
|
+
if (reverse) {
|
|
10266
|
+
for (let i = 0; i < values.length; i++) {
|
|
10267
|
+
nodes.push(values[i]);
|
|
10268
|
+
values[i][PARENT] = value;
|
|
10047
10269
|
}
|
|
10048
|
-
|
|
10049
|
-
|
|
10270
|
+
}
|
|
10271
|
+
else {
|
|
10272
|
+
for (let i = values.length - 1; i >= 0; i--) {
|
|
10273
|
+
nodes.push(values[i]);
|
|
10274
|
+
values[i][PARENT] = value;
|
|
10050
10275
|
}
|
|
10051
10276
|
}
|
|
10052
10277
|
}
|
|
@@ -10063,10 +10288,16 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
10063
10288
|
// @ts-ignore
|
|
10064
10289
|
if (option != null && ("typ" in option || Array.isArray(option))) {
|
|
10065
10290
|
const op = Array.isArray(option) ? option : [option];
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
|
|
10291
|
+
if (reverse) {
|
|
10292
|
+
for (let i = 0; i < op.length; i++) {
|
|
10293
|
+
nodes.push(op[i]);
|
|
10294
|
+
op[i][PARENT] = value;
|
|
10295
|
+
}
|
|
10296
|
+
}
|
|
10297
|
+
else {
|
|
10298
|
+
for (let i = op.length - 1; i >= 0; i--) {
|
|
10299
|
+
nodes.push(op[i]);
|
|
10300
|
+
op[i][PARENT] = value;
|
|
10070
10301
|
}
|
|
10071
10302
|
}
|
|
10072
10303
|
}
|
|
@@ -10312,6 +10543,9 @@ function evaluate(tokens) {
|
|
|
10312
10543
|
}
|
|
10313
10544
|
}
|
|
10314
10545
|
if (acc.length > 0 && curr[0] != exports.EnumToken.ListToken) {
|
|
10546
|
+
if ("val" in token && +token.val == 0) {
|
|
10547
|
+
return acc;
|
|
10548
|
+
}
|
|
10315
10549
|
acc.push({
|
|
10316
10550
|
typ: exports.EnumToken.Add,
|
|
10317
10551
|
[LOCSRCID]: token[LOCSRCID],
|
|
@@ -14182,19 +14416,20 @@ function matchProperty(property, context, options) {
|
|
|
14182
14416
|
token?.typ == exports.EnumToken.ResolutionTokenType ||
|
|
14183
14417
|
token?.typ == exports.EnumToken.TimeTokenType ||
|
|
14184
14418
|
token?.typ == exports.EnumToken.FrequencyTokenType ||
|
|
14419
|
+
token?.typ == exports.EnumToken.UserDefinedDimensionTokenType ||
|
|
14185
14420
|
token?.typ == exports.EnumToken.FlexTokenType;
|
|
14186
14421
|
break;
|
|
14187
14422
|
}
|
|
14188
14423
|
case "angle":
|
|
14189
14424
|
{
|
|
14190
14425
|
const token = context.peek();
|
|
14191
|
-
success = token?.typ === exports.EnumToken.AngleTokenType;
|
|
14426
|
+
success = token?.typ === exports.EnumToken.AngleTokenType || token?.typ === exports.EnumToken.UserDefinedDimensionTokenType;
|
|
14192
14427
|
}
|
|
14193
14428
|
break;
|
|
14194
14429
|
case "angle-percentage":
|
|
14195
14430
|
{
|
|
14196
14431
|
const token = context.peek();
|
|
14197
|
-
success = token?.typ === exports.EnumToken.AngleTokenType || token?.typ === exports.EnumToken.PercentageTokenType;
|
|
14432
|
+
success = token?.typ === exports.EnumToken.AngleTokenType || token?.typ === exports.EnumToken.UserDefinedDimensionTokenType || token?.typ === exports.EnumToken.PercentageTokenType;
|
|
14198
14433
|
}
|
|
14199
14434
|
break;
|
|
14200
14435
|
case "percentage":
|
|
@@ -14212,16 +14447,18 @@ function matchProperty(property, context, options) {
|
|
|
14212
14447
|
success =
|
|
14213
14448
|
token?.typ == exports.EnumToken.PercentageTokenType ||
|
|
14214
14449
|
token?.typ == exports.EnumToken.LengthTokenType ||
|
|
14450
|
+
token?.typ == exports.EnumToken.UserDefinedDimensionTokenType ||
|
|
14215
14451
|
(token?.typ == exports.EnumToken.NumberTokenType && token?.val === 0);
|
|
14216
14452
|
}
|
|
14217
14453
|
break;
|
|
14218
14454
|
case "flex":
|
|
14219
|
-
success = context.peek()?.typ == exports.EnumToken.FlexTokenType;
|
|
14455
|
+
success = context.peek()?.typ == exports.EnumToken.FlexTokenType || context.peek()?.typ == exports.EnumToken.UserDefinedDimensionTokenType;
|
|
14220
14456
|
break;
|
|
14221
14457
|
case "length": {
|
|
14222
14458
|
const token = context.peek();
|
|
14223
14459
|
success =
|
|
14224
14460
|
token?.typ == exports.EnumToken.LengthTokenType ||
|
|
14461
|
+
token?.typ == exports.EnumToken.UserDefinedDimensionTokenType ||
|
|
14225
14462
|
(token?.typ == exports.EnumToken.NumberTokenType && token?.val === 0);
|
|
14226
14463
|
break;
|
|
14227
14464
|
}
|
|
@@ -14231,7 +14468,7 @@ function matchProperty(property, context, options) {
|
|
|
14231
14468
|
if (token == null) {
|
|
14232
14469
|
break;
|
|
14233
14470
|
}
|
|
14234
|
-
success = token.typ == exports.EnumToken.TimeTokenType;
|
|
14471
|
+
success = token.typ == exports.EnumToken.TimeTokenType || token.typ == exports.EnumToken.UserDefinedDimensionTokenType;
|
|
14235
14472
|
}
|
|
14236
14473
|
break;
|
|
14237
14474
|
case "color":
|
|
@@ -17543,7 +17780,7 @@ function replace(node, variableScope) {
|
|
|
17543
17780
|
}
|
|
17544
17781
|
}
|
|
17545
17782
|
for (const { value, parent: parentValue } of walkValues(node.val)) {
|
|
17546
|
-
if (value.typ == exports.EnumToken.
|
|
17783
|
+
if (value.typ == exports.EnumToken.MathFunctionTokenType ||
|
|
17547
17784
|
(value.typ == exports.EnumToken.WildCardFunctionTokenType && value.val == "var")) {
|
|
17548
17785
|
if (value.chi.length == 1 &&
|
|
17549
17786
|
value.chi[0].typ == exports.EnumToken.DashedIdenTokenType) {
|
|
@@ -17551,9 +17788,10 @@ function replace(node, variableScope) {
|
|
|
17551
17788
|
if (info?.replaceable) {
|
|
17552
17789
|
if (parentValue != null) {
|
|
17553
17790
|
let i = 0;
|
|
17554
|
-
|
|
17555
|
-
|
|
17556
|
-
|
|
17791
|
+
const source = parentValue.typ == exports.EnumToken.DeclarationNodeType ? parentValue.val : parentValue.chi;
|
|
17792
|
+
for (; i < source.length; i++) {
|
|
17793
|
+
if (source[i] == value) {
|
|
17794
|
+
source.splice(i, 1, ...info.node.val);
|
|
17557
17795
|
break;
|
|
17558
17796
|
}
|
|
17559
17797
|
}
|
|
@@ -20787,12 +21025,27 @@ const config = getConfig();
|
|
|
20787
21025
|
* Represents a list of property declarations, compute shorthand and remove duplicate declarations.
|
|
20788
21026
|
*/
|
|
20789
21027
|
class PropertyList {
|
|
21028
|
+
/**
|
|
21029
|
+
* options
|
|
21030
|
+
*/
|
|
20790
21031
|
options = { removeDuplicateDeclarations: true, computeShorthand: true };
|
|
21032
|
+
/**
|
|
21033
|
+
* declarations
|
|
21034
|
+
*/
|
|
20791
21035
|
declarations;
|
|
21036
|
+
/**
|
|
21037
|
+
*
|
|
21038
|
+
* @param options
|
|
21039
|
+
*/
|
|
20792
21040
|
constructor(options = {}) {
|
|
20793
21041
|
this.options = options;
|
|
20794
21042
|
this.declarations = new Map();
|
|
20795
21043
|
}
|
|
21044
|
+
/**
|
|
21045
|
+
* add declarations
|
|
21046
|
+
* @param declarations
|
|
21047
|
+
* @returns
|
|
21048
|
+
*/
|
|
20796
21049
|
add(declarations) {
|
|
20797
21050
|
let name;
|
|
20798
21051
|
let syntaxRules = null;
|
|
@@ -20932,6 +21185,11 @@ class PropertyList {
|
|
|
20932
21185
|
}
|
|
20933
21186
|
return this;
|
|
20934
21187
|
}
|
|
21188
|
+
/**
|
|
21189
|
+
*
|
|
21190
|
+
* @param declaration
|
|
21191
|
+
* @param mapping
|
|
21192
|
+
*/
|
|
20935
21193
|
mapValues(declaration, mapping) {
|
|
20936
21194
|
let name;
|
|
20937
21195
|
let values = declaration.val;
|
|
@@ -20991,6 +21249,10 @@ class PropertyList {
|
|
|
20991
21249
|
}
|
|
20992
21250
|
}
|
|
20993
21251
|
}
|
|
21252
|
+
/**
|
|
21253
|
+
*
|
|
21254
|
+
* @returns
|
|
21255
|
+
*/
|
|
20994
21256
|
[Symbol.iterator]() {
|
|
20995
21257
|
let iterator = this.declarations.values();
|
|
20996
21258
|
const iterators = [];
|
|
@@ -21108,7 +21370,7 @@ const trimTokenSpace = new Set([
|
|
|
21108
21370
|
exports.EnumToken.LteTokenType,
|
|
21109
21371
|
exports.EnumToken.ChildCombinatorTokenType,
|
|
21110
21372
|
exports.EnumToken.PipeTokenType,
|
|
21111
|
-
exports.EnumToken.ColonTokenType
|
|
21373
|
+
exports.EnumToken.ColonTokenType,
|
|
21112
21374
|
]);
|
|
21113
21375
|
const trimSpaceAfter = new Set([
|
|
21114
21376
|
...tokensfuncSet.values(),
|
|
@@ -21130,9 +21392,16 @@ function replaceNodeOrValue(parent, node, replacement) {
|
|
|
21130
21392
|
if (replacement == null || (Array.isArray(replacement) && replacement.length === 0)) {
|
|
21131
21393
|
throw new TypeError(`replacement is null`);
|
|
21132
21394
|
}
|
|
21133
|
-
|
|
21134
|
-
if (
|
|
21135
|
-
|
|
21395
|
+
if (!Array.isArray(replacement)) {
|
|
21396
|
+
if (replacement[PARENT] != parent) {
|
|
21397
|
+
replacement[PARENT] = parent;
|
|
21398
|
+
}
|
|
21399
|
+
}
|
|
21400
|
+
else {
|
|
21401
|
+
for (const newNode of replacement) {
|
|
21402
|
+
if (newNode[PARENT] != parent) {
|
|
21403
|
+
newNode[PARENT] = parent;
|
|
21404
|
+
}
|
|
21136
21405
|
}
|
|
21137
21406
|
}
|
|
21138
21407
|
if (parent.typ == exports.EnumToken.BinaryExpressionTokenType) {
|
|
@@ -22615,9 +22884,9 @@ button {
|
|
|
22615
22884
|
* @returns
|
|
22616
22885
|
*/
|
|
22617
22886
|
function find(ast, matcher) {
|
|
22618
|
-
for (const
|
|
22619
|
-
if (matcher(node, parent)) {
|
|
22620
|
-
return node;
|
|
22887
|
+
for (const r of walk(ast)) {
|
|
22888
|
+
if (matcher(r.node, r.parent)) {
|
|
22889
|
+
return r.node;
|
|
22621
22890
|
}
|
|
22622
22891
|
}
|
|
22623
22892
|
return null;
|
|
@@ -22656,21 +22925,25 @@ button {
|
|
|
22656
22925
|
*/
|
|
22657
22926
|
function findByValue(ast, matcher) {
|
|
22658
22927
|
let source;
|
|
22659
|
-
for (const
|
|
22928
|
+
for (const r1 of walk(ast)) {
|
|
22660
22929
|
source = null;
|
|
22661
|
-
if (node.typ === exports.EnumToken.DeclarationNodeType) {
|
|
22662
|
-
source = node.val;
|
|
22930
|
+
if (r1.node.typ === exports.EnumToken.DeclarationNodeType) {
|
|
22931
|
+
source = r1.node.val;
|
|
22663
22932
|
}
|
|
22664
|
-
else if (Array.isArray(node[TOKENS])) {
|
|
22665
|
-
source = node[TOKENS];
|
|
22933
|
+
else if (Array.isArray(r1.node[TOKENS])) {
|
|
22934
|
+
source = r1.node[TOKENS];
|
|
22666
22935
|
}
|
|
22667
22936
|
if (source == null) {
|
|
22668
22937
|
continue;
|
|
22669
22938
|
}
|
|
22670
|
-
for (const
|
|
22671
|
-
if (matcher(value, node)) {
|
|
22672
|
-
|
|
22673
|
-
|
|
22939
|
+
for (const r2 of walkValues(source, r1.node)) {
|
|
22940
|
+
if (matcher(r2.value, r1.node)) {
|
|
22941
|
+
return {
|
|
22942
|
+
// @ts-ignore
|
|
22943
|
+
node: r1.node,
|
|
22944
|
+
// @ts-ignore
|
|
22945
|
+
value: { node: r2.value, parent: r2.parent, root: r2.root, parents: r2.parents },
|
|
22946
|
+
};
|
|
22674
22947
|
}
|
|
22675
22948
|
}
|
|
22676
22949
|
}
|
|
@@ -22712,9 +22985,9 @@ button-small {
|
|
|
22712
22985
|
*/
|
|
22713
22986
|
function findAll(ast, matcher) {
|
|
22714
22987
|
const result = [];
|
|
22715
|
-
for (const
|
|
22716
|
-
if (matcher(node,
|
|
22717
|
-
result.push(node);
|
|
22988
|
+
for (const r of walk(ast)) {
|
|
22989
|
+
if (matcher(r.node, r.node[PARENT])) {
|
|
22990
|
+
result.push(r.node);
|
|
22718
22991
|
}
|
|
22719
22992
|
}
|
|
22720
22993
|
return result;
|
|
@@ -22750,11 +23023,12 @@ button {
|
|
|
22750
23023
|
* @returns
|
|
22751
23024
|
*/
|
|
22752
23025
|
function findLast(ast, matcher) {
|
|
22753
|
-
for (const
|
|
22754
|
-
|
|
22755
|
-
|
|
23026
|
+
for (const result of walk(ast, null, true))
|
|
23027
|
+
// for (const { node, parent } of walk(ast as AstNode, null, true)) {
|
|
23028
|
+
if (matcher(result.node, result.parent)) {
|
|
23029
|
+
return result.node;
|
|
22756
23030
|
}
|
|
22757
|
-
}
|
|
23031
|
+
// }
|
|
22758
23032
|
return null;
|
|
22759
23033
|
}
|
|
22760
23034
|
|
|
@@ -26685,6 +26959,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
|
|
|
26685
26959
|
case exports.EnumToken.DimensionTokenType:
|
|
26686
26960
|
case exports.EnumToken.FrequencyTokenType:
|
|
26687
26961
|
case exports.EnumToken.ResolutionTokenType:
|
|
26962
|
+
case exports.EnumToken.UserDefinedDimensionTokenType:
|
|
26688
26963
|
let val = token.val.typ == exports.EnumToken.FractionTokenType
|
|
26689
26964
|
? renderValue(token.val, options, cache)
|
|
26690
26965
|
: minifyNumber(token.val);
|
|
@@ -26884,8 +27159,10 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
|
|
|
26884
27159
|
case exports.EnumToken.BadUrlTokenType:
|
|
26885
27160
|
case exports.EnumToken.EOFTokenType:
|
|
26886
27161
|
return "";
|
|
27162
|
+
case exports.EnumToken.ComposesSelectorNodeType:
|
|
27163
|
+
return `${token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "")}${token.r == null ? "" : " from " + renderValue(token.r, options, cache, reducer)}`;
|
|
26887
27164
|
default:
|
|
26888
|
-
console.
|
|
27165
|
+
console.error({ token });
|
|
26889
27166
|
throw new Error(`Unsupported token type for ${exports.EnumToken[token.typ]}`);
|
|
26890
27167
|
}
|
|
26891
27168
|
// errors?.push({ action: "ignore", message: `render: unexpected token ${JSON.stringify(token, null, 1)}` });
|
|
@@ -26948,7 +27225,6 @@ function assignTokenMap(entries, tokenType, suffix = "", lowercase = false) {
|
|
|
26948
27225
|
SymbolsMapTokensLower[key.toLowerCase()] = tokenType;
|
|
26949
27226
|
}
|
|
26950
27227
|
}
|
|
26951
|
-
SymbolsMapTokens[""] = exports.EnumToken.DelimTokenType;
|
|
26952
27228
|
SymbolsMapTokens["+"] = exports.EnumToken.Plus;
|
|
26953
27229
|
SymbolsMapTokens["="] = exports.EnumToken.DelimTokenType;
|
|
26954
27230
|
SymbolsMapTokens["|"] = exports.EnumToken.PipeTokenType;
|
|
@@ -27397,6 +27673,11 @@ class Tokenizer {
|
|
|
27397
27673
|
hasLetter = true;
|
|
27398
27674
|
break;
|
|
27399
27675
|
}
|
|
27676
|
+
// dashed ident as unit
|
|
27677
|
+
if (codepoint == 0x2d && parseInfo.stream.charCodeAt(position + 1) == 0x2d) {
|
|
27678
|
+
hasLetter = true;
|
|
27679
|
+
break;
|
|
27680
|
+
}
|
|
27400
27681
|
return 0;
|
|
27401
27682
|
}
|
|
27402
27683
|
if (!hasLetter && !hasPercent) {
|
|
@@ -27425,6 +27706,10 @@ class Tokenizer {
|
|
|
27425
27706
|
else if (isLetter(codepoint)) {
|
|
27426
27707
|
hasLetter = true;
|
|
27427
27708
|
}
|
|
27709
|
+
// custom ident as unit
|
|
27710
|
+
else if (codepoint == 0x2d && parseInfo.stream.charCodeAt(position + 1) == 0x2d) {
|
|
27711
|
+
hasLetter = true;
|
|
27712
|
+
}
|
|
27428
27713
|
else {
|
|
27429
27714
|
return 0;
|
|
27430
27715
|
}
|
|
@@ -27462,6 +27747,10 @@ class Tokenizer {
|
|
|
27462
27747
|
hasLetter = true;
|
|
27463
27748
|
break;
|
|
27464
27749
|
}
|
|
27750
|
+
else if (codepoint == 0x2d && parseInfo.stream.charCodeAt(position + 1) == 0x2d) {
|
|
27751
|
+
hasLetter = true;
|
|
27752
|
+
break;
|
|
27753
|
+
}
|
|
27465
27754
|
if (codepoint == 37 /* TokenMap.PERCENTAGE */) {
|
|
27466
27755
|
hasPercent = true;
|
|
27467
27756
|
break;
|
|
@@ -27525,6 +27814,11 @@ class Tokenizer {
|
|
|
27525
27814
|
hasLetter = true;
|
|
27526
27815
|
break;
|
|
27527
27816
|
}
|
|
27817
|
+
// custom ident as unit
|
|
27818
|
+
else if (codepoint == 0x2d && parseInfo.stream.charCodeAt(position + 1) == 0x2d) {
|
|
27819
|
+
hasLetter = true;
|
|
27820
|
+
break;
|
|
27821
|
+
}
|
|
27528
27822
|
else if (codepoint == 37 /* TokenMap.PERCENTAGE */) {
|
|
27529
27823
|
hasPercent = true;
|
|
27530
27824
|
break;
|
|
@@ -27566,7 +27860,7 @@ class Tokenizer {
|
|
|
27566
27860
|
const slice = codepoint == 0x45 || codepoint == 0x65 ? position - 1 : position;
|
|
27567
27861
|
while (position + 1 <= parseInfo.stream.length) {
|
|
27568
27862
|
codepoint = parseInfo.stream.charCodeAt(++position);
|
|
27569
|
-
if (!isLetter(codepoint)) {
|
|
27863
|
+
if (!isLetter(codepoint) && codepoint != 0x2d) {
|
|
27570
27864
|
break;
|
|
27571
27865
|
}
|
|
27572
27866
|
}
|
|
@@ -27851,6 +28145,9 @@ class Tokenizer {
|
|
|
27851
28145
|
this.val = parseFloat(parseInfo.stream.slice(parseInfo.position - parseInfo.offset, options?.slice));
|
|
27852
28146
|
if (hint != exports.EnumToken.PercentageTokenType) {
|
|
27853
28147
|
this.unit = val;
|
|
28148
|
+
if (val.startsWith("--")) {
|
|
28149
|
+
this.typ = exports.EnumToken.UserDefinedDimensionTokenType;
|
|
28150
|
+
}
|
|
27854
28151
|
}
|
|
27855
28152
|
}
|
|
27856
28153
|
else if (hint == exports.EnumToken.NumberTokenType) {
|
|
@@ -31582,54 +31879,208 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
31582
31879
|
if (options.visitor != null) {
|
|
31583
31880
|
const handlers = [];
|
|
31584
31881
|
const visitors = parseVisitors(options.visitor, errors);
|
|
31585
|
-
const subNodes = [];
|
|
31586
31882
|
let parens;
|
|
31587
31883
|
let genericKey;
|
|
31588
|
-
let nodes =
|
|
31589
|
-
let
|
|
31590
|
-
|
|
31591
|
-
|
|
31592
|
-
let freeBlock = 1;
|
|
31593
|
-
nodes[0] = ast;
|
|
31594
|
-
for (i = 0; i < nodes.length; i++) {
|
|
31595
|
-
if (nodes[i] == null) {
|
|
31596
|
-
break;
|
|
31597
|
-
}
|
|
31598
|
-
subNodes.length = 0;
|
|
31884
|
+
let nodes = [ast];
|
|
31885
|
+
let node;
|
|
31886
|
+
while (nodes.length > 0) {
|
|
31887
|
+
node = nodes.pop();
|
|
31599
31888
|
if (visitors.includeTokens) {
|
|
31600
|
-
switch (
|
|
31889
|
+
switch (node.typ) {
|
|
31601
31890
|
case exports.EnumToken.RuleNodeType:
|
|
31602
31891
|
case exports.EnumToken.AtRuleNodeType:
|
|
31603
31892
|
case exports.EnumToken.KeyframesRuleNodeType:
|
|
31604
31893
|
case exports.EnumToken.KeyframesAtRuleNodeType:
|
|
31605
|
-
for (
|
|
31606
|
-
|
|
31894
|
+
for (let i =
|
|
31895
|
+
// @ts-ignore
|
|
31896
|
+
node[TOKENS].length -
|
|
31897
|
+
1; i >= 0; i--) {
|
|
31898
|
+
// @ts-ignore
|
|
31899
|
+
node[TOKENS][i][PARENT] =
|
|
31900
|
+
node;
|
|
31901
|
+
nodes.push(
|
|
31902
|
+
// @ts-ignore
|
|
31903
|
+
node[TOKENS][i]);
|
|
31607
31904
|
}
|
|
31608
31905
|
break;
|
|
31609
31906
|
case exports.EnumToken.DeclarationNodeType:
|
|
31610
|
-
for (
|
|
31611
|
-
|
|
31907
|
+
for (let i =
|
|
31908
|
+
// @ts-ignore
|
|
31909
|
+
node.val.length - 1; i >= 0; i--) {
|
|
31910
|
+
node.val[i][PARENT] = node;
|
|
31911
|
+
// @ts-ignore
|
|
31912
|
+
nodes.push(node.val[i]);
|
|
31612
31913
|
}
|
|
31613
31914
|
break;
|
|
31614
31915
|
}
|
|
31916
|
+
// @ts-ignore
|
|
31917
|
+
// if (node.l != null) {
|
|
31918
|
+
// // @ts-ignore
|
|
31919
|
+
// if (node.op2 != null) {
|
|
31920
|
+
// // @ts-ignore
|
|
31921
|
+
// nodes.push(node.op2);
|
|
31922
|
+
// // @ts-ignore
|
|
31923
|
+
// node.op2[PARENT] = node;
|
|
31924
|
+
// }
|
|
31925
|
+
// // @ts-ignore
|
|
31926
|
+
// if (node.op1 != null) {
|
|
31927
|
+
// // @ts-ignore
|
|
31928
|
+
// nodes.push(node.op1);
|
|
31929
|
+
// // @ts-ignore
|
|
31930
|
+
// node.op1[PARENT] = node;
|
|
31931
|
+
// }
|
|
31932
|
+
// // @ts-ignore
|
|
31933
|
+
// if (nodes.op != null && node.op.typ != null) {
|
|
31934
|
+
// // @ts-ignore
|
|
31935
|
+
// nodes.push(node.op);
|
|
31936
|
+
// // @ts-ignore
|
|
31937
|
+
// node.op[PARENT] = node;
|
|
31938
|
+
// }
|
|
31939
|
+
// // @ts-ignore
|
|
31940
|
+
// if (node.r != null) {
|
|
31941
|
+
// // @ts-ignore
|
|
31942
|
+
// if (Array.isArray(node.r)) {
|
|
31943
|
+
// // @ts-ignore
|
|
31944
|
+
// for (let i = node.r.length - 1; i >= 0; i--) {
|
|
31945
|
+
// // @ts-ignore
|
|
31946
|
+
// nodes.push(node.r[i]);
|
|
31947
|
+
// // @ts-ignore
|
|
31948
|
+
// node.r[i][PARENT] = node;
|
|
31949
|
+
// }
|
|
31950
|
+
// } else {
|
|
31951
|
+
// // @ts-ignore
|
|
31952
|
+
// nodes.push(node.r);
|
|
31953
|
+
// // @ts-ignore
|
|
31954
|
+
// node.r[PARENT] = node;
|
|
31955
|
+
// }
|
|
31956
|
+
// }
|
|
31957
|
+
// // @ts-ignore
|
|
31958
|
+
// if (Array.isArray(node.l)) {
|
|
31959
|
+
// // @ts-ignore
|
|
31960
|
+
// for (let i = node.l.length - 1; i >= 0; i--) {
|
|
31961
|
+
// // @ts-ignore
|
|
31962
|
+
// nodes.push(node.l[i]);
|
|
31963
|
+
// // @ts-ignore
|
|
31964
|
+
// node.l[i][PARENT] = node;
|
|
31965
|
+
// }
|
|
31966
|
+
// } else {
|
|
31967
|
+
// // @ts-ignore
|
|
31968
|
+
// nodes.push(node.l);
|
|
31969
|
+
// // @ts-ignore
|
|
31970
|
+
// node.l[PARENT] = node;
|
|
31971
|
+
// }
|
|
31972
|
+
// }
|
|
31973
|
+
}
|
|
31974
|
+
switch (node.typ) {
|
|
31975
|
+
case exports.EnumToken.BinaryExpressionTokenType:
|
|
31976
|
+
case exports.EnumToken.IfElseConditionTokenType:
|
|
31977
|
+
nodes.push(node.r);
|
|
31978
|
+
node.r[PARENT] = node;
|
|
31979
|
+
nodes.push(node.l);
|
|
31980
|
+
node.l[PARENT] = node;
|
|
31981
|
+
break;
|
|
31982
|
+
case exports.EnumToken.MatchExpressionTokenType:
|
|
31983
|
+
nodes.push(node.r);
|
|
31984
|
+
node.r[PARENT] = node;
|
|
31985
|
+
nodes.push(node.op);
|
|
31986
|
+
node.op[PARENT] = node;
|
|
31987
|
+
nodes.push(node.l);
|
|
31988
|
+
node.l[PARENT] = node;
|
|
31989
|
+
break;
|
|
31990
|
+
case exports.EnumToken.SupportsQueryConditionTokenType:
|
|
31991
|
+
case exports.EnumToken.MediaQueryConditionTokenType:
|
|
31992
|
+
for (let i = node.r.length - 1; i >= 0; i--) {
|
|
31993
|
+
const element = node.r[i];
|
|
31994
|
+
nodes.push(element);
|
|
31995
|
+
element[PARENT] = node;
|
|
31996
|
+
}
|
|
31997
|
+
nodes.push(node.op);
|
|
31998
|
+
node.op[PARENT] = node;
|
|
31999
|
+
for (let i = node.l.length - 1; i >= 0; i--) {
|
|
32000
|
+
const element = node.l[i];
|
|
32001
|
+
nodes.push(element);
|
|
32002
|
+
element[PARENT] = node;
|
|
32003
|
+
}
|
|
32004
|
+
break;
|
|
32005
|
+
case exports.EnumToken.WhenElseQueryConditionTokenType:
|
|
32006
|
+
for (let i = node.r.length - 1; i >= 0; i--) {
|
|
32007
|
+
const element = node.r[i];
|
|
32008
|
+
nodes.push(element);
|
|
32009
|
+
element[PARENT] = node;
|
|
32010
|
+
}
|
|
32011
|
+
nodes.push(node.l);
|
|
32012
|
+
node.l[PARENT] = node;
|
|
32013
|
+
break;
|
|
32014
|
+
case exports.EnumToken.IfConditionTokenType:
|
|
32015
|
+
for (let i = node.r.length - 1; i >= 0; i--) {
|
|
32016
|
+
const element = node.r[i];
|
|
32017
|
+
nodes.push(element);
|
|
32018
|
+
element[PARENT] = node;
|
|
32019
|
+
}
|
|
32020
|
+
for (let i = node.l.length - 1; i >= 0; i--) {
|
|
32021
|
+
const element = node.l[i];
|
|
32022
|
+
nodes.push(element);
|
|
32023
|
+
element[PARENT] = node;
|
|
32024
|
+
}
|
|
32025
|
+
break;
|
|
32026
|
+
case exports.EnumToken.ComposesSelectorNodeType:
|
|
32027
|
+
if (node.r != null) {
|
|
32028
|
+
nodes.push(node.r);
|
|
32029
|
+
node.r[PARENT] = node;
|
|
32030
|
+
}
|
|
32031
|
+
for (let i = node.l.length - 1; i >= 0; i--) {
|
|
32032
|
+
const element = node.l[i];
|
|
32033
|
+
nodes.push(element);
|
|
32034
|
+
element[PARENT] = node;
|
|
32035
|
+
}
|
|
32036
|
+
break;
|
|
32037
|
+
case exports.EnumToken.ContainerStyleRangeTokenType:
|
|
32038
|
+
for (let i = node.r.length - 1; i >= 0; i--) {
|
|
32039
|
+
const element = node.r[i];
|
|
32040
|
+
nodes.push(element);
|
|
32041
|
+
element[PARENT] = node;
|
|
32042
|
+
}
|
|
32043
|
+
for (let i = node.op.length - 1; i >= 0; i--) {
|
|
32044
|
+
const element = node.op[i];
|
|
32045
|
+
nodes.push(element);
|
|
32046
|
+
element[PARENT] = node;
|
|
32047
|
+
}
|
|
32048
|
+
for (let i = node.l.length - 1; i >= 0; i--) {
|
|
32049
|
+
const element = node.l[i];
|
|
32050
|
+
nodes.push(element);
|
|
32051
|
+
element[PARENT] = node;
|
|
32052
|
+
}
|
|
32053
|
+
break;
|
|
32054
|
+
case exports.EnumToken.MediaRangeQueryTokenType:
|
|
32055
|
+
for (let i = node.r.length - 1; i >= 0; i--) {
|
|
32056
|
+
const element = node.r[i];
|
|
32057
|
+
nodes.push(element);
|
|
32058
|
+
element[PARENT] = node;
|
|
32059
|
+
}
|
|
32060
|
+
nodes.push(node.op2);
|
|
32061
|
+
node.op2[PARENT] = node;
|
|
32062
|
+
for (let i = node.val.length - 1; i >= 0; i--) {
|
|
32063
|
+
const element = node.val[i];
|
|
32064
|
+
nodes.push(element);
|
|
32065
|
+
element[PARENT] = node;
|
|
32066
|
+
}
|
|
32067
|
+
nodes.push(node.op1);
|
|
32068
|
+
node.op1[PARENT] = node;
|
|
32069
|
+
for (let i = node.l.length - 1; i >= 0; i--) {
|
|
32070
|
+
const element = node.l[i];
|
|
32071
|
+
nodes.push(element);
|
|
32072
|
+
element[PARENT] = node;
|
|
32073
|
+
}
|
|
32074
|
+
break;
|
|
31615
32075
|
}
|
|
31616
32076
|
// @ts-ignore
|
|
31617
|
-
if (
|
|
32077
|
+
if (node.chi != null) {
|
|
32078
|
+
for (
|
|
31618
32079
|
// @ts-ignore
|
|
31619
|
-
|
|
31620
|
-
|
|
31621
|
-
|
|
31622
|
-
}
|
|
31623
|
-
if (subNodes.length > 0) {
|
|
31624
|
-
if (freeBlock <= i) {
|
|
31625
|
-
freeBlock = i + 1;
|
|
31626
|
-
}
|
|
31627
|
-
for (k = 0; k < subNodes.length; k++) {
|
|
31628
|
-
j = k + freeBlock;
|
|
31629
|
-
nodes[j] = subNodes[k];
|
|
31630
|
-
nodes[j][PARENT] = nodes[i];
|
|
32080
|
+
let i = node.chi.length - 1; i >= 0; i--) {
|
|
32081
|
+
// @ts-ignore
|
|
32082
|
+
nodes.push(node.chi[i]);
|
|
31631
32083
|
}
|
|
31632
|
-
freeBlock += subNodes.length;
|
|
31633
32084
|
}
|
|
31634
32085
|
parens = null;
|
|
31635
32086
|
handlers.length = 0;
|
|
@@ -31637,23 +32088,23 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
31637
32088
|
handlers.push(...visitors.preAllVisitorsHandlers);
|
|
31638
32089
|
}
|
|
31639
32090
|
genericKey =
|
|
31640
|
-
|
|
32091
|
+
node.typ == exports.EnumToken.DeclarationNodeType
|
|
31641
32092
|
? "Declaration"
|
|
31642
|
-
:
|
|
32093
|
+
: node.typ == exports.EnumToken.AtRuleNodeType
|
|
31643
32094
|
? "AtRule"
|
|
31644
|
-
:
|
|
32095
|
+
: node.typ == exports.EnumToken.KeyframesAtRuleNodeType
|
|
31645
32096
|
? "KeyframesAtRule"
|
|
31646
|
-
:
|
|
32097
|
+
: node.typ === exports.EnumToken.KeyframesRuleNodeType
|
|
31647
32098
|
? "KeyframesRule"
|
|
31648
|
-
:
|
|
32099
|
+
: node.typ == exports.EnumToken.RuleNodeType
|
|
31649
32100
|
? "Rule"
|
|
31650
|
-
:
|
|
32101
|
+
: node.typ == exports.EnumToken.KeyframesRuleNodeType
|
|
31651
32102
|
? "KeyframesRule"
|
|
31652
32103
|
: null;
|
|
31653
|
-
let keyName =
|
|
31654
|
-
? camelize(
|
|
31655
|
-
:
|
|
31656
|
-
? camelize(
|
|
32104
|
+
let keyName = node.typ == exports.EnumToken.DeclarationNodeType || node.typ == exports.EnumToken.AtRuleNodeType
|
|
32105
|
+
? camelize(node.nam)
|
|
32106
|
+
: node.typ == exports.EnumToken.KeyframesAtRuleNodeType
|
|
32107
|
+
? camelize(node.val)
|
|
31657
32108
|
: null;
|
|
31658
32109
|
if (visitors.allVisitorsHandlers?.size > 0) {
|
|
31659
32110
|
handlers.push(...visitors.allVisitorsHandlers);
|
|
@@ -31673,10 +32124,9 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
31673
32124
|
}
|
|
31674
32125
|
}
|
|
31675
32126
|
}
|
|
31676
|
-
|
|
31677
|
-
if (map.has(nodes[i].typ)) {
|
|
32127
|
+
if (map.has(node.typ)) {
|
|
31678
32128
|
// @ts-ignore
|
|
31679
|
-
for (const handler of map.get(
|
|
32129
|
+
for (const handler of map.get(node.typ)) {
|
|
31680
32130
|
if (typeof handler == "function") {
|
|
31681
32131
|
handlers.push(handler);
|
|
31682
32132
|
}
|
|
@@ -31704,16 +32154,15 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
31704
32154
|
if (handlers.length == 0) {
|
|
31705
32155
|
continue;
|
|
31706
32156
|
}
|
|
31707
|
-
let node = nodes[i];
|
|
31708
32157
|
for (const callable of handlers) {
|
|
31709
|
-
replacement = callable(node,
|
|
32158
|
+
replacement = callable(node, node[PARENT], ast,
|
|
31710
32159
|
// @ts-expect-error
|
|
31711
32160
|
function* () {
|
|
31712
32161
|
if (parens == null) {
|
|
31713
|
-
let
|
|
31714
|
-
while (
|
|
31715
|
-
yield
|
|
31716
|
-
|
|
32162
|
+
let parent = node[PARENT];
|
|
32163
|
+
while (parent != null) {
|
|
32164
|
+
yield parent;
|
|
32165
|
+
parent = parent[PARENT];
|
|
31717
32166
|
}
|
|
31718
32167
|
}
|
|
31719
32168
|
});
|
|
@@ -31724,37 +32173,33 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
31724
32173
|
continue;
|
|
31725
32174
|
}
|
|
31726
32175
|
// @ts-ignore
|
|
31727
|
-
node = replacement;
|
|
32176
|
+
// node = replacement as AstNode;
|
|
31728
32177
|
//
|
|
31729
|
-
if (Array.isArray(
|
|
32178
|
+
if (Array.isArray(replacement)) {
|
|
31730
32179
|
break;
|
|
31731
32180
|
}
|
|
31732
32181
|
}
|
|
31733
|
-
|
|
32182
|
+
// @ts-ignore
|
|
32183
|
+
if (replacement != null && node != replacement) {
|
|
31734
32184
|
// @ts-ignore
|
|
31735
|
-
replaceNodeOrValue(
|
|
32185
|
+
replaceNodeOrValue(node[PARENT], node, replacement);
|
|
31736
32186
|
}
|
|
31737
32187
|
}
|
|
31738
32188
|
nodes = null;
|
|
31739
32189
|
}
|
|
31740
32190
|
if (invalidNodes.length > 0) {
|
|
31741
|
-
|
|
31742
|
-
for (const { node, parent } of walk(ast)) {
|
|
32191
|
+
for (const node of invalidNodes) {
|
|
31743
32192
|
if (options.lenient && node[STATE] & exports.EnumAstNodeStatus.Unknown) {
|
|
31744
32193
|
continue;
|
|
31745
32194
|
}
|
|
31746
|
-
if (node[STATE] &
|
|
31747
|
-
|
|
31748
|
-
|
|
31749
|
-
|
|
31750
|
-
|
|
32195
|
+
if (node[STATE] &
|
|
32196
|
+
(exports.EnumAstNodeStatus.Invalid |
|
|
32197
|
+
exports.EnumAstNodeStatus.Unknown |
|
|
32198
|
+
exports.EnumAstNodeStatus.Unparsed |
|
|
32199
|
+
exports.EnumAstNodeStatus.Malformed |
|
|
32200
|
+
exports.EnumAstNodeStatus.Disallowed)) {
|
|
31751
32201
|
// @ts-ignore
|
|
31752
|
-
|
|
31753
|
-
node[PARENT] = null;
|
|
31754
|
-
count--;
|
|
31755
|
-
if (count == 0) {
|
|
31756
|
-
break;
|
|
31757
|
-
}
|
|
32202
|
+
node[PARENT].chi.splice(node[PARENT].chi.indexOf(node), 1);
|
|
31758
32203
|
}
|
|
31759
32204
|
}
|
|
31760
32205
|
}
|
|
@@ -31775,7 +32220,6 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
31775
32220
|
...stats,
|
|
31776
32221
|
parse: `${(endParseTime - startTime).toFixed(2)}ms`,
|
|
31777
32222
|
minify: `${(endTime - endParseTime).toFixed(2)}ms`,
|
|
31778
|
-
// tokenize: `${(options?.parseInfo?.time ?? 0).toFixed(2)}ms`,
|
|
31779
32223
|
total: `${(endTime - startTime).toFixed(2)}ms`,
|
|
31780
32224
|
},
|
|
31781
32225
|
};
|
|
@@ -31853,6 +32297,7 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
31853
32297
|
}
|
|
31854
32298
|
// @ts-ignore
|
|
31855
32299
|
if (node.typ == exports.EnumToken.CssVariableDeclarationMapTokenType) {
|
|
32300
|
+
// @ts-ignore
|
|
31856
32301
|
const from = node.from.find((t) => t.typ == exports.EnumToken.IdenTokenType || isIdentColor(t));
|
|
31857
32302
|
if (!(from.val in cssVariablesMap)) {
|
|
31858
32303
|
errors.push({
|
|
@@ -31862,6 +32307,7 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
31862
32307
|
});
|
|
31863
32308
|
}
|
|
31864
32309
|
else {
|
|
32310
|
+
// @ts-ignore
|
|
31865
32311
|
for (const token of node.vars) {
|
|
31866
32312
|
if (token.typ == exports.EnumToken.IdenTokenType || isIdentColor(token)) {
|
|
31867
32313
|
if (!(token.val in cssVariablesMap[from.val])) {
|
|
@@ -31885,6 +32331,7 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
31885
32331
|
if (result.cssModuleVariables == null) {
|
|
31886
32332
|
result.cssModuleVariables = {};
|
|
31887
32333
|
}
|
|
32334
|
+
// @ts-ignore
|
|
31888
32335
|
result.cssModuleVariables[node.nam] = node;
|
|
31889
32336
|
}
|
|
31890
32337
|
parent.chi.splice(parent.chi.indexOf(node), 1);
|
|
@@ -32050,7 +32497,8 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
32050
32497
|
value.val = mapping[idenToken];
|
|
32051
32498
|
}
|
|
32052
32499
|
}
|
|
32053
|
-
else if (node.nam == "grid-template-areas" ||
|
|
32500
|
+
else if (node.nam == "grid-template-areas" ||
|
|
32501
|
+
node.nam == "grid-template") {
|
|
32054
32502
|
for (let i = 0; i < node.val.length; i++) {
|
|
32055
32503
|
if (node.val[i].typ == exports.EnumToken.String) {
|
|
32056
32504
|
const tokens = parseString(node.val[i].val.slice(1, -1));
|
|
@@ -32077,7 +32525,8 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
32077
32525
|
}
|
|
32078
32526
|
}
|
|
32079
32527
|
}
|
|
32080
|
-
else if (node.nam == "animation" ||
|
|
32528
|
+
else if (node.nam == "animation" ||
|
|
32529
|
+
node.nam == "animation-name") {
|
|
32081
32530
|
for (const { value } of walkValues(node.val, node)) {
|
|
32082
32531
|
if (value.typ == exports.EnumToken.IdenTokenType &&
|
|
32083
32532
|
![
|
|
@@ -32120,14 +32569,14 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
32120
32569
|
}
|
|
32121
32570
|
}
|
|
32122
32571
|
}
|
|
32123
|
-
for (const
|
|
32124
|
-
if (value.typ == exports.EnumToken.DashedIdenTokenType) {
|
|
32125
|
-
value.val = mapping[value.val];
|
|
32572
|
+
for (const r of walkValues(node.val, node)) {
|
|
32573
|
+
if (r.value.typ == exports.EnumToken.DashedIdenTokenType) {
|
|
32574
|
+
r.value.val = mapping[r.value.val];
|
|
32126
32575
|
}
|
|
32127
|
-
else if ((value.typ == exports.EnumToken.IdenTokenType || isIdentColor(value)) &&
|
|
32128
|
-
value.val in importedCssVariables) {
|
|
32576
|
+
else if ((r.value.typ == exports.EnumToken.IdenTokenType || isIdentColor(r.value)) &&
|
|
32577
|
+
r.value.val in importedCssVariables) {
|
|
32129
32578
|
// @ts-ignore
|
|
32130
|
-
replaceNodeOrValue(parent, value, importedCssVariables[value.val].val);
|
|
32579
|
+
replaceNodeOrValue(r.parent, r.value, importedCssVariables[value.val].val);
|
|
32131
32580
|
}
|
|
32132
32581
|
}
|
|
32133
32582
|
}
|
|
@@ -32565,58 +33014,208 @@ async function doParse(iter, options = {}) {
|
|
|
32565
33014
|
let genericKey;
|
|
32566
33015
|
const handlers = [];
|
|
32567
33016
|
const visitors = parseVisitors(options.visitor, errors);
|
|
32568
|
-
let nodes =
|
|
32569
|
-
|
|
32570
|
-
|
|
32571
|
-
|
|
32572
|
-
|
|
32573
|
-
let freeblock = 1;
|
|
32574
|
-
nodes[0] = ast;
|
|
32575
|
-
for (i = 0; i < nodes.length; i++) {
|
|
32576
|
-
if (nodes[i] == null) {
|
|
32577
|
-
break;
|
|
32578
|
-
}
|
|
32579
|
-
subNodes.length = 0;
|
|
33017
|
+
let nodes = [ast];
|
|
33018
|
+
let node;
|
|
33019
|
+
// nodes[0] = ast;
|
|
33020
|
+
while (nodes.length > 0) {
|
|
33021
|
+
node = nodes.pop();
|
|
32580
33022
|
if (visitors.includeTokens) {
|
|
32581
|
-
switch (
|
|
33023
|
+
switch (node.typ) {
|
|
32582
33024
|
case exports.EnumToken.RuleNodeType:
|
|
32583
33025
|
case exports.EnumToken.AtRuleNodeType:
|
|
32584
33026
|
case exports.EnumToken.KeyframesRuleNodeType:
|
|
32585
33027
|
case exports.EnumToken.KeyframesAtRuleNodeType:
|
|
32586
|
-
|
|
32587
|
-
|
|
32588
|
-
|
|
32589
|
-
|
|
32590
|
-
|
|
32591
|
-
|
|
32592
|
-
|
|
33028
|
+
for (let i =
|
|
33029
|
+
// @ts-ignore
|
|
33030
|
+
node[TOKENS].length -
|
|
33031
|
+
1; i >= 0; i--) {
|
|
33032
|
+
// @ts-ignore
|
|
33033
|
+
node[TOKENS][i][PARENT] =
|
|
33034
|
+
node;
|
|
33035
|
+
nodes.push(
|
|
33036
|
+
// @ts-ignore
|
|
33037
|
+
node[TOKENS][i]);
|
|
32593
33038
|
}
|
|
32594
33039
|
break;
|
|
32595
33040
|
case exports.EnumToken.DeclarationNodeType:
|
|
32596
|
-
for (
|
|
32597
|
-
|
|
33041
|
+
for (let i =
|
|
33042
|
+
// @ts-ignore
|
|
33043
|
+
node.val.length - 1; i >= 0; i--) {
|
|
33044
|
+
// @ts-ignore
|
|
33045
|
+
node.val[i][PARENT] = node;
|
|
33046
|
+
// @ts-ignore
|
|
33047
|
+
nodes.push(node.val[i]);
|
|
32598
33048
|
}
|
|
32599
33049
|
break;
|
|
32600
33050
|
}
|
|
33051
|
+
// @ts-ignore
|
|
33052
|
+
// if (node.l != null) {
|
|
33053
|
+
// // @ts-ignore
|
|
33054
|
+
// if (node.op2 != null) {
|
|
33055
|
+
// // @ts-ignore
|
|
33056
|
+
// nodes.push(node.op2);
|
|
33057
|
+
// // @ts-ignore
|
|
33058
|
+
// nodes.op2[PARENT] = node;
|
|
33059
|
+
// }
|
|
33060
|
+
// // @ts-ignore
|
|
33061
|
+
// if (node.op1 != null) {
|
|
33062
|
+
// // @ts-ignore
|
|
33063
|
+
// nodes.push(node.op1);
|
|
33064
|
+
// // @ts-ignore
|
|
33065
|
+
// nodes.op1[PARENT] = node;
|
|
33066
|
+
// }
|
|
33067
|
+
// // @ts-ignore
|
|
33068
|
+
// if (nodes.op != null && node.op.typ != null) {
|
|
33069
|
+
// // @ts-ignore
|
|
33070
|
+
// nodes.push(node.op);
|
|
33071
|
+
// // @ts-ignore
|
|
33072
|
+
// nodes.op[PARENT] = node;
|
|
33073
|
+
// }
|
|
33074
|
+
// // @ts-ignore
|
|
33075
|
+
// if (node.r != null) {
|
|
33076
|
+
// // @ts-ignore
|
|
33077
|
+
// if (Array.isArray(node.r)) {
|
|
33078
|
+
// // @ts-ignore
|
|
33079
|
+
// for (let i = node.r.length - 1; i >= 0; i--) {
|
|
33080
|
+
// // @ts-ignore
|
|
33081
|
+
// nodes.push(node.r[i]);
|
|
33082
|
+
// // @ts-ignore
|
|
33083
|
+
// node.r[i][PARENT] = node;
|
|
33084
|
+
// }
|
|
33085
|
+
// } else {
|
|
33086
|
+
// // @ts-ignore
|
|
33087
|
+
// nodes.push(node.r);
|
|
33088
|
+
// // @ts-ignore
|
|
33089
|
+
// node.r[PARENT] = node;
|
|
33090
|
+
// }
|
|
33091
|
+
// }
|
|
33092
|
+
// // @ts-ignore
|
|
33093
|
+
// if (Array.isArray(node.l)) {
|
|
33094
|
+
// // @ts-ignore
|
|
33095
|
+
// for (let i = node.l.length - 1; i >= 0; i--) {
|
|
33096
|
+
// // @ts-ignore
|
|
33097
|
+
// node.l[i][PARENT] = node;
|
|
33098
|
+
// // @ts-ignore
|
|
33099
|
+
// nodes.push(node.l[i]);
|
|
33100
|
+
// }
|
|
33101
|
+
// } else {
|
|
33102
|
+
// // @ts-ignore
|
|
33103
|
+
// nodes.push(node.l);
|
|
33104
|
+
// // @ts-ignore
|
|
33105
|
+
// node.l[PARENT] = node;
|
|
33106
|
+
// }
|
|
33107
|
+
// }
|
|
33108
|
+
}
|
|
33109
|
+
switch (node.typ) {
|
|
33110
|
+
case exports.EnumToken.BinaryExpressionTokenType:
|
|
33111
|
+
case exports.EnumToken.IfElseConditionTokenType:
|
|
33112
|
+
nodes.push(node.r);
|
|
33113
|
+
node.r[PARENT] = node;
|
|
33114
|
+
nodes.push(node.l);
|
|
33115
|
+
node.l[PARENT] = node;
|
|
33116
|
+
break;
|
|
33117
|
+
case exports.EnumToken.MatchExpressionTokenType:
|
|
33118
|
+
nodes.push(node.r);
|
|
33119
|
+
node.r[PARENT] = node;
|
|
33120
|
+
nodes.push(node.op);
|
|
33121
|
+
node.op[PARENT] = node;
|
|
33122
|
+
nodes.push(node.l);
|
|
33123
|
+
node.l[PARENT] = node;
|
|
33124
|
+
break;
|
|
33125
|
+
case exports.EnumToken.SupportsQueryConditionTokenType:
|
|
33126
|
+
case exports.EnumToken.MediaQueryConditionTokenType:
|
|
33127
|
+
for (let i = node.r.length - 1; i >= 0; i--) {
|
|
33128
|
+
const element = node.r[i];
|
|
33129
|
+
nodes.push(element);
|
|
33130
|
+
element[PARENT] = node;
|
|
33131
|
+
}
|
|
33132
|
+
nodes.push(node.op);
|
|
33133
|
+
node.op[PARENT] = node;
|
|
33134
|
+
for (let i = node.l.length - 1; i >= 0; i--) {
|
|
33135
|
+
const element = node.l[i];
|
|
33136
|
+
nodes.push(element);
|
|
33137
|
+
element[PARENT] = node;
|
|
33138
|
+
}
|
|
33139
|
+
break;
|
|
33140
|
+
case exports.EnumToken.WhenElseQueryConditionTokenType:
|
|
33141
|
+
for (let i = node.r.length - 1; i >= 0; i--) {
|
|
33142
|
+
const element = node.r[i];
|
|
33143
|
+
nodes.push(element);
|
|
33144
|
+
element[PARENT] = node;
|
|
33145
|
+
}
|
|
33146
|
+
nodes.push(node.l);
|
|
33147
|
+
node.l[PARENT] = node;
|
|
33148
|
+
break;
|
|
33149
|
+
case exports.EnumToken.IfConditionTokenType:
|
|
33150
|
+
for (let i = node.r.length - 1; i >= 0; i--) {
|
|
33151
|
+
const element = node.r[i];
|
|
33152
|
+
nodes.push(element);
|
|
33153
|
+
element[PARENT] = node;
|
|
33154
|
+
}
|
|
33155
|
+
for (let i = node.l.length - 1; i >= 0; i--) {
|
|
33156
|
+
const element = node.l[i];
|
|
33157
|
+
nodes.push(element);
|
|
33158
|
+
element[PARENT] = node;
|
|
33159
|
+
}
|
|
33160
|
+
break;
|
|
33161
|
+
case exports.EnumToken.ComposesSelectorNodeType:
|
|
33162
|
+
if (node.r != null) {
|
|
33163
|
+
nodes.push(node.r);
|
|
33164
|
+
node.r[PARENT] = node;
|
|
33165
|
+
}
|
|
33166
|
+
for (let i = node.l.length - 1; i >= 0; i--) {
|
|
33167
|
+
const element = node.l[i];
|
|
33168
|
+
nodes.push(element);
|
|
33169
|
+
element[PARENT] = node;
|
|
33170
|
+
}
|
|
33171
|
+
break;
|
|
33172
|
+
case exports.EnumToken.ContainerStyleRangeTokenType:
|
|
33173
|
+
for (let i = node.r.length - 1; i >= 0; i--) {
|
|
33174
|
+
const element = node.r[i];
|
|
33175
|
+
nodes.push(element);
|
|
33176
|
+
element[PARENT] = node;
|
|
33177
|
+
}
|
|
33178
|
+
for (let i = node.op.length - 1; i >= 0; i--) {
|
|
33179
|
+
const element = node.op[i];
|
|
33180
|
+
nodes.push(element);
|
|
33181
|
+
element[PARENT] = node;
|
|
33182
|
+
}
|
|
33183
|
+
for (let i = node.l.length - 1; i >= 0; i--) {
|
|
33184
|
+
const element = node.l[i];
|
|
33185
|
+
nodes.push(element);
|
|
33186
|
+
element[PARENT] = node;
|
|
33187
|
+
}
|
|
33188
|
+
break;
|
|
33189
|
+
case exports.EnumToken.MediaRangeQueryTokenType:
|
|
33190
|
+
for (let i = node.r.length - 1; i >= 0; i--) {
|
|
33191
|
+
const element = node.r[i];
|
|
33192
|
+
nodes.push(element);
|
|
33193
|
+
element[PARENT] = node;
|
|
33194
|
+
}
|
|
33195
|
+
nodes.push(node.op2);
|
|
33196
|
+
node.op2[PARENT] = node;
|
|
33197
|
+
for (let i = node.val.length - 1; i >= 0; i--) {
|
|
33198
|
+
const element = node.val[i];
|
|
33199
|
+
nodes.push(element);
|
|
33200
|
+
element[PARENT] = node;
|
|
33201
|
+
}
|
|
33202
|
+
nodes.push(node.op1);
|
|
33203
|
+
node.op1[PARENT] = node;
|
|
33204
|
+
for (let i = node.l.length - 1; i >= 0; i--) {
|
|
33205
|
+
const element = node.l[i];
|
|
33206
|
+
nodes.push(element);
|
|
33207
|
+
element[PARENT] = node;
|
|
33208
|
+
}
|
|
33209
|
+
break;
|
|
32601
33210
|
}
|
|
32602
33211
|
// @ts-ignore
|
|
32603
|
-
if (
|
|
33212
|
+
if (node.chi != null) {
|
|
33213
|
+
for (
|
|
32604
33214
|
// @ts-ignore
|
|
32605
|
-
|
|
33215
|
+
let i = node.chi.length - 1; i >= 0; i--) {
|
|
32606
33216
|
// @ts-ignore
|
|
32607
|
-
|
|
32608
|
-
}
|
|
32609
|
-
}
|
|
32610
|
-
if (subNodes.length > 0) {
|
|
32611
|
-
if (freeblock <= i) {
|
|
32612
|
-
freeblock = i + 1;
|
|
33217
|
+
nodes.push(node.chi[i]);
|
|
32613
33218
|
}
|
|
32614
|
-
for (k = 0; k < subNodes.length; k++) {
|
|
32615
|
-
j = k + freeblock;
|
|
32616
|
-
nodes[j] = subNodes[k];
|
|
32617
|
-
nodes[j][PARENT] = nodes[i];
|
|
32618
|
-
}
|
|
32619
|
-
freeblock += subNodes.length;
|
|
32620
33219
|
}
|
|
32621
33220
|
parens = null;
|
|
32622
33221
|
handlers.length = 0;
|
|
@@ -32624,23 +33223,23 @@ async function doParse(iter, options = {}) {
|
|
|
32624
33223
|
handlers.push(...visitors.preAllVisitorsHandlers);
|
|
32625
33224
|
}
|
|
32626
33225
|
genericKey =
|
|
32627
|
-
|
|
33226
|
+
node.typ == exports.EnumToken.DeclarationNodeType
|
|
32628
33227
|
? "Declaration"
|
|
32629
|
-
:
|
|
33228
|
+
: node.typ == exports.EnumToken.AtRuleNodeType
|
|
32630
33229
|
? "AtRule"
|
|
32631
|
-
:
|
|
33230
|
+
: node.typ == exports.EnumToken.KeyframesAtRuleNodeType
|
|
32632
33231
|
? "KeyframesAtRule"
|
|
32633
|
-
:
|
|
33232
|
+
: node.typ === exports.EnumToken.KeyframesRuleNodeType
|
|
32634
33233
|
? "KeyframesRule"
|
|
32635
|
-
:
|
|
33234
|
+
: node.typ == exports.EnumToken.RuleNodeType
|
|
32636
33235
|
? "Rule"
|
|
32637
|
-
:
|
|
33236
|
+
: node.typ == exports.EnumToken.KeyframesRuleNodeType
|
|
32638
33237
|
? "KeyframesRule"
|
|
32639
33238
|
: null;
|
|
32640
|
-
let keyName =
|
|
32641
|
-
? camelize(
|
|
32642
|
-
:
|
|
32643
|
-
? camelize(
|
|
33239
|
+
let keyName = node.typ == exports.EnumToken.DeclarationNodeType || node.typ == exports.EnumToken.AtRuleNodeType
|
|
33240
|
+
? camelize(node.nam)
|
|
33241
|
+
: node.typ == exports.EnumToken.KeyframesAtRuleNodeType
|
|
33242
|
+
? camelize(node.val)
|
|
32644
33243
|
: null;
|
|
32645
33244
|
if (visitors.allVisitorsHandlers?.size > 0) {
|
|
32646
33245
|
handlers.push(...visitors.allVisitorsHandlers);
|
|
@@ -32653,20 +33252,6 @@ async function doParse(iter, options = {}) {
|
|
|
32653
33252
|
if (typeof handler == "function") {
|
|
32654
33253
|
handlers.push(handler);
|
|
32655
33254
|
}
|
|
32656
|
-
// else if (Array.isArray(handler)) {
|
|
32657
|
-
// for (const h of handler) {
|
|
32658
|
-
// if (typeof h == "function") {
|
|
32659
|
-
// handlers.push(h);
|
|
32660
|
-
// }
|
|
32661
|
-
// // @ts-ignore
|
|
32662
|
-
// else if (h[keyName] != null) {
|
|
32663
|
-
// // @ts-ignore
|
|
32664
|
-
// handlers.push(h[keyName]);
|
|
32665
|
-
// }
|
|
32666
|
-
// }
|
|
32667
|
-
// } else if (typeof handler.handler! == "function") {
|
|
32668
|
-
// handlers.push(handler.handler);
|
|
32669
|
-
// }
|
|
32670
33255
|
// @ts-ignore
|
|
32671
33256
|
else if (typeof handler[keyName] == "function") {
|
|
32672
33257
|
// @ts-ignore
|
|
@@ -32674,10 +33259,9 @@ async function doParse(iter, options = {}) {
|
|
|
32674
33259
|
}
|
|
32675
33260
|
}
|
|
32676
33261
|
}
|
|
32677
|
-
|
|
32678
|
-
if (map.has(nodes[i].typ)) {
|
|
33262
|
+
if (map.has(node.typ)) {
|
|
32679
33263
|
// @ts-ignore
|
|
32680
|
-
for (const handler of map.get(
|
|
33264
|
+
for (const handler of map.get(node.typ)) {
|
|
32681
33265
|
if (typeof handler == "function") {
|
|
32682
33266
|
handlers.push(handler);
|
|
32683
33267
|
}
|
|
@@ -32705,16 +33289,16 @@ async function doParse(iter, options = {}) {
|
|
|
32705
33289
|
if (handlers.length == 0) {
|
|
32706
33290
|
continue;
|
|
32707
33291
|
}
|
|
32708
|
-
let node = nodes[i];
|
|
32709
33292
|
for (const callable of handlers) {
|
|
32710
|
-
replacement = callable(node,
|
|
33293
|
+
replacement = callable(node, node[PARENT], ast,
|
|
32711
33294
|
// @ts-expect-error
|
|
32712
33295
|
function* () {
|
|
32713
33296
|
if (parens == null) {
|
|
32714
|
-
let
|
|
32715
|
-
|
|
32716
|
-
|
|
32717
|
-
|
|
33297
|
+
let parent = node[PARENT];
|
|
33298
|
+
// let node = node[PARENT] as AstNode;
|
|
33299
|
+
while (parent != null) {
|
|
33300
|
+
yield parent;
|
|
33301
|
+
parent = parent[PARENT];
|
|
32718
33302
|
}
|
|
32719
33303
|
}
|
|
32720
33304
|
});
|
|
@@ -32728,37 +33312,37 @@ async function doParse(iter, options = {}) {
|
|
|
32728
33312
|
continue;
|
|
32729
33313
|
}
|
|
32730
33314
|
// @ts-ignore
|
|
32731
|
-
node = replacement;
|
|
33315
|
+
// node = replacement as AstNode;
|
|
32732
33316
|
//
|
|
32733
|
-
if (Array.isArray(
|
|
33317
|
+
if (Array.isArray(replacement)) {
|
|
32734
33318
|
break;
|
|
32735
33319
|
}
|
|
32736
33320
|
}
|
|
32737
|
-
|
|
33321
|
+
// @ts-ignore
|
|
33322
|
+
if (replacement != null && node != replacement) {
|
|
33323
|
+
console.error({
|
|
33324
|
+
node,
|
|
33325
|
+
replacement,
|
|
33326
|
+
});
|
|
32738
33327
|
// @ts-ignore
|
|
32739
|
-
replaceNodeOrValue(
|
|
33328
|
+
replaceNodeOrValue(node[PARENT], node, replacement);
|
|
32740
33329
|
}
|
|
32741
33330
|
}
|
|
32742
33331
|
nodes = null;
|
|
32743
33332
|
}
|
|
32744
33333
|
if (invalidNodes.length > 0) {
|
|
32745
|
-
|
|
32746
|
-
for (const { node, parent } of walk(ast)) {
|
|
33334
|
+
for (const node of invalidNodes) {
|
|
32747
33335
|
if (options.lenient && node[STATE] & exports.EnumAstNodeStatus.Unknown) {
|
|
32748
33336
|
continue;
|
|
32749
33337
|
}
|
|
32750
|
-
if (node[STATE] &
|
|
32751
|
-
|
|
32752
|
-
|
|
32753
|
-
|
|
32754
|
-
|
|
33338
|
+
if (node[STATE] &
|
|
33339
|
+
(exports.EnumAstNodeStatus.Invalid |
|
|
33340
|
+
exports.EnumAstNodeStatus.Unknown |
|
|
33341
|
+
exports.EnumAstNodeStatus.Unparsed |
|
|
33342
|
+
exports.EnumAstNodeStatus.Malformed |
|
|
33343
|
+
exports.EnumAstNodeStatus.Disallowed)) {
|
|
32755
33344
|
// @ts-ignore
|
|
32756
|
-
|
|
32757
|
-
node[PARENT] = null;
|
|
32758
|
-
count--;
|
|
32759
|
-
if (count == 0) {
|
|
32760
|
-
break;
|
|
32761
|
-
}
|
|
33345
|
+
node[PARENT].chi.splice(node[PARENT].chi.indexOf(node), 1);
|
|
32762
33346
|
}
|
|
32763
33347
|
}
|
|
32764
33348
|
}
|
|
@@ -32884,6 +33468,7 @@ async function doParse(iter, options = {}) {
|
|
|
32884
33468
|
}
|
|
32885
33469
|
// @ts-ignore
|
|
32886
33470
|
if (node.typ == exports.EnumToken.CssVariableDeclarationMapTokenType) {
|
|
33471
|
+
// @ts-ignore
|
|
32887
33472
|
const from = node.from.find((t) => t.typ == exports.EnumToken.IdenTokenType || isIdentColor(t));
|
|
32888
33473
|
if (!(from.val in cssVariablesMap)) {
|
|
32889
33474
|
errors.push({
|
|
@@ -32893,6 +33478,7 @@ async function doParse(iter, options = {}) {
|
|
|
32893
33478
|
});
|
|
32894
33479
|
}
|
|
32895
33480
|
else {
|
|
33481
|
+
// @ts-ignore
|
|
32896
33482
|
for (const token of node.vars) {
|
|
32897
33483
|
if (token.typ == exports.EnumToken.IdenTokenType || isIdentColor(token)) {
|
|
32898
33484
|
if (!(token.val in cssVariablesMap[from.val])) {
|
|
@@ -32916,6 +33502,7 @@ async function doParse(iter, options = {}) {
|
|
|
32916
33502
|
if (result.cssModuleVariables == null) {
|
|
32917
33503
|
result.cssModuleVariables = {};
|
|
32918
33504
|
}
|
|
33505
|
+
// @ts-ignore
|
|
32919
33506
|
result.cssModuleVariables[node.nam] = node;
|
|
32920
33507
|
}
|
|
32921
33508
|
parent.chi.splice(parent.chi.indexOf(node), 1);
|
|
@@ -33156,7 +33743,8 @@ async function doParse(iter, options = {}) {
|
|
|
33156
33743
|
value.val = mapping[idenToken];
|
|
33157
33744
|
}
|
|
33158
33745
|
}
|
|
33159
|
-
else if (node.nam == "grid-template-areas" ||
|
|
33746
|
+
else if (node.nam == "grid-template-areas" ||
|
|
33747
|
+
node.nam == "grid-template") {
|
|
33160
33748
|
for (let i = 0; i < node.val.length; i++) {
|
|
33161
33749
|
if (node.val[i].typ == exports.EnumToken.String) {
|
|
33162
33750
|
const tokens = parseString(node.val[i].val.slice(1, -1));
|
|
@@ -33187,7 +33775,8 @@ async function doParse(iter, options = {}) {
|
|
|
33187
33775
|
}
|
|
33188
33776
|
}
|
|
33189
33777
|
}
|
|
33190
|
-
else if (node.nam == "animation" ||
|
|
33778
|
+
else if (node.nam == "animation" ||
|
|
33779
|
+
node.nam == "animation-name") {
|
|
33191
33780
|
for (const { value } of walkValues(node.val, node)) {
|
|
33192
33781
|
if (value.typ == exports.EnumToken.IdenTokenType &&
|
|
33193
33782
|
![
|
|
@@ -34291,6 +34880,50 @@ function parseAtRule(stream, context, options, errors, parseAsBlock = null) {
|
|
|
34291
34880
|
atRule[TOKENS] = stream.slice();
|
|
34292
34881
|
atRule[STATE] = result.success ? exports.EnumAstNodeStatus.Validated : exports.EnumAstNodeStatus.Invalid;
|
|
34293
34882
|
atRule[ERRORS] = result.errors;
|
|
34883
|
+
switch (atRule.nam) {
|
|
34884
|
+
case "mixin":
|
|
34885
|
+
if (context != null && context.typ != exports.EnumToken.StyleSheetNodeType) {
|
|
34886
|
+
atRule[STATE] |= exports.EnumAstNodeStatus.Disallowed;
|
|
34887
|
+
atRule[ERRORS].push({
|
|
34888
|
+
message: "mixin rule cannot be a nested group rule or rule style body",
|
|
34889
|
+
location: atRule[LOCSTA],
|
|
34890
|
+
});
|
|
34891
|
+
}
|
|
34892
|
+
break;
|
|
34893
|
+
case "contents":
|
|
34894
|
+
let parent = context;
|
|
34895
|
+
let valid = parent == null;
|
|
34896
|
+
while (parent != null) {
|
|
34897
|
+
if (parent.typ == exports.EnumToken.AtRuleNodeType && "mixin" == parent.nam) {
|
|
34898
|
+
valid = true;
|
|
34899
|
+
break;
|
|
34900
|
+
}
|
|
34901
|
+
parent = parent[PARENT];
|
|
34902
|
+
}
|
|
34903
|
+
if (!valid) {
|
|
34904
|
+
atRule[STATE] |= exports.EnumAstNodeStatus.Disallowed;
|
|
34905
|
+
atRule[ERRORS].push({
|
|
34906
|
+
message: "contents rule cannot be used outside mixin rule",
|
|
34907
|
+
location: atRule[LOCSTA],
|
|
34908
|
+
});
|
|
34909
|
+
}
|
|
34910
|
+
break;
|
|
34911
|
+
case "layer":
|
|
34912
|
+
if (context != null && context.typ != exports.EnumToken.StyleSheetNodeType) {
|
|
34913
|
+
let parent = context;
|
|
34914
|
+
while (parent != null) {
|
|
34915
|
+
if (parent.typ == exports.EnumToken.AtRuleNodeType && parent.nam == "mixin") {
|
|
34916
|
+
atRule[STATE] |= exports.EnumAstNodeStatus.Disallowed;
|
|
34917
|
+
atRule[ERRORS].push({
|
|
34918
|
+
message: "at-rule layeris not allowed inside mixin rule",
|
|
34919
|
+
location: atRule[LOCSTA],
|
|
34920
|
+
});
|
|
34921
|
+
break;
|
|
34922
|
+
}
|
|
34923
|
+
parent = parent[PARENT];
|
|
34924
|
+
}
|
|
34925
|
+
}
|
|
34926
|
+
}
|
|
34294
34927
|
// @ts-expect-error
|
|
34295
34928
|
return Object.assign(atRule, {
|
|
34296
34929
|
typ: exports.EnumToken.AtRuleNodeType,
|
|
@@ -34750,7 +35383,7 @@ function setNodeProperty(node, key, value) {
|
|
|
34750
35383
|
}
|
|
34751
35384
|
}
|
|
34752
35385
|
|
|
34753
|
-
var version = "1.
|
|
35386
|
+
var version = "1.8.1";
|
|
34754
35387
|
|
|
34755
35388
|
/**
|
|
34756
35389
|
* Load file or url
|