@weapp-tailwindcss/postcss 1.0.13 → 1.0.14
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/dist/index.js +167 -124
- package/dist/index.mjs +167 -124
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -280,8 +280,8 @@ function getFallbackRemove(rule) {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
} else if (selector.value === ":where") {
|
|
283
|
-
for (const
|
|
284
|
-
for (const node of
|
|
283
|
+
for (const n2 of selector.nodes) {
|
|
284
|
+
for (const node of n2.nodes) {
|
|
285
285
|
if (node.type === "attribute") {
|
|
286
286
|
node.remove();
|
|
287
287
|
}
|
|
@@ -846,6 +846,10 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
846
846
|
if (/color-mix/.test(atRule.params)) {
|
|
847
847
|
atRule.remove();
|
|
848
848
|
}
|
|
849
|
+
} else if (atRule.name === "layer") {
|
|
850
|
+
if (atRule.nodes === void 0 || Array.isArray(atRule.nodes) && atRule.nodes.length === 0) {
|
|
851
|
+
atRule.remove();
|
|
852
|
+
}
|
|
849
853
|
}
|
|
850
854
|
}
|
|
851
855
|
};
|
|
@@ -879,118 +883,118 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
879
883
|
};
|
|
880
884
|
postcssWeappTailwindcssPrePlugin.postcss = true;
|
|
881
885
|
|
|
882
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.
|
|
886
|
+
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.3_postcss@8.5.6/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
883
887
|
|
|
884
888
|
|
|
885
889
|
// ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.1.0/node_modules/@csstools/selector-specificity/dist/index.mjs
|
|
886
890
|
|
|
887
|
-
function compare(e3,
|
|
888
|
-
return e3.a ===
|
|
891
|
+
function compare(e3, t) {
|
|
892
|
+
return e3.a === t.a ? e3.b === t.b ? e3.c - t.c : e3.b - t.b : e3.a - t.a;
|
|
889
893
|
}
|
|
890
|
-
function selectorSpecificity(
|
|
891
|
-
const i = _optionalChain([s, 'optionalAccess', _36 => _36.customSpecificity, 'optionalCall', _37 => _37(
|
|
894
|
+
function selectorSpecificity(t, s) {
|
|
895
|
+
const i = _optionalChain([s, 'optionalAccess', _36 => _36.customSpecificity, 'optionalCall', _37 => _37(t)]);
|
|
892
896
|
if (i) return i;
|
|
893
|
-
if (!
|
|
894
|
-
let c = 0,
|
|
895
|
-
if ("universal" ==
|
|
896
|
-
if ("id" ===
|
|
897
|
-
else if ("tag" ===
|
|
898
|
-
else if ("class" ===
|
|
899
|
-
else if ("attribute" ===
|
|
900
|
-
else if (isPseudoElement(
|
|
897
|
+
if (!t) return { a: 0, b: 0, c: 0 };
|
|
898
|
+
let c = 0, n2 = 0, o2 = 0;
|
|
899
|
+
if ("universal" == t.type) return { a: 0, b: 0, c: 0 };
|
|
900
|
+
if ("id" === t.type) c += 1;
|
|
901
|
+
else if ("tag" === t.type) o2 += 1;
|
|
902
|
+
else if ("class" === t.type) n2 += 1;
|
|
903
|
+
else if ("attribute" === t.type) n2 += 1;
|
|
904
|
+
else if (isPseudoElement(t)) switch (t.value.toLowerCase()) {
|
|
901
905
|
case "::slotted":
|
|
902
|
-
if (o2 += 1,
|
|
903
|
-
const e3 = specificityOfMostSpecificListItem(
|
|
904
|
-
c += e3.a,
|
|
906
|
+
if (o2 += 1, t.nodes && t.nodes.length > 0) {
|
|
907
|
+
const e3 = specificityOfMostSpecificListItem(t.nodes, s);
|
|
908
|
+
c += e3.a, n2 += e3.b, o2 += e3.c;
|
|
905
909
|
}
|
|
906
910
|
break;
|
|
907
911
|
case "::view-transition-group":
|
|
908
912
|
case "::view-transition-image-pair":
|
|
909
913
|
case "::view-transition-old":
|
|
910
914
|
case "::view-transition-new":
|
|
911
|
-
return
|
|
915
|
+
return t.nodes && 1 === t.nodes.length && "selector" === t.nodes[0].type && selectorNodeContainsNothingOrOnlyUniversal(t.nodes[0]) ? { a: 0, b: 0, c: 0 } : { a: 0, b: 0, c: 1 };
|
|
912
916
|
default:
|
|
913
917
|
o2 += 1;
|
|
914
918
|
}
|
|
915
|
-
else if (_postcssselectorparser2.default.isPseudoClass(
|
|
919
|
+
else if (_postcssselectorparser2.default.isPseudoClass(t)) switch (t.value.toLowerCase()) {
|
|
916
920
|
case ":-webkit-any":
|
|
917
921
|
case ":any":
|
|
918
922
|
default:
|
|
919
|
-
|
|
923
|
+
n2 += 1;
|
|
920
924
|
break;
|
|
921
925
|
case ":-moz-any":
|
|
922
926
|
case ":has":
|
|
923
927
|
case ":is":
|
|
924
928
|
case ":matches":
|
|
925
929
|
case ":not":
|
|
926
|
-
if (
|
|
927
|
-
const e3 = specificityOfMostSpecificListItem(
|
|
928
|
-
c += e3.a,
|
|
930
|
+
if (t.nodes && t.nodes.length > 0) {
|
|
931
|
+
const e3 = specificityOfMostSpecificListItem(t.nodes, s);
|
|
932
|
+
c += e3.a, n2 += e3.b, o2 += e3.c;
|
|
929
933
|
}
|
|
930
934
|
break;
|
|
931
935
|
case ":where":
|
|
932
936
|
break;
|
|
933
937
|
case ":nth-child":
|
|
934
938
|
case ":nth-last-child":
|
|
935
|
-
if (
|
|
936
|
-
const i2 =
|
|
939
|
+
if (n2 += 1, t.nodes && t.nodes.length > 0) {
|
|
940
|
+
const i2 = t.nodes[0].nodes.findIndex((e3) => "tag" === e3.type && "of" === e3.value.toLowerCase());
|
|
937
941
|
if (i2 > -1) {
|
|
938
942
|
const a = _postcssselectorparser2.default.selector({ nodes: [], value: "" });
|
|
939
|
-
|
|
943
|
+
t.nodes[0].nodes.slice(i2 + 1).forEach((e3) => {
|
|
940
944
|
a.append(e3.clone());
|
|
941
945
|
});
|
|
942
946
|
const r = [a];
|
|
943
|
-
|
|
947
|
+
t.nodes.length > 1 && r.push(...t.nodes.slice(1));
|
|
944
948
|
const l = specificityOfMostSpecificListItem(r, s);
|
|
945
|
-
c += l.a,
|
|
949
|
+
c += l.a, n2 += l.b, o2 += l.c;
|
|
946
950
|
}
|
|
947
951
|
}
|
|
948
952
|
break;
|
|
949
953
|
case ":local":
|
|
950
954
|
case ":global":
|
|
951
|
-
|
|
952
|
-
const
|
|
953
|
-
c +=
|
|
955
|
+
t.nodes && t.nodes.length > 0 && t.nodes.forEach((e3) => {
|
|
956
|
+
const t2 = selectorSpecificity(e3, s);
|
|
957
|
+
c += t2.a, n2 += t2.b, o2 += t2.c;
|
|
954
958
|
});
|
|
955
959
|
break;
|
|
956
960
|
case ":host":
|
|
957
961
|
case ":host-context":
|
|
958
|
-
if (
|
|
959
|
-
const e3 = specificityOfMostSpecificListItem(
|
|
960
|
-
c += e3.a,
|
|
962
|
+
if (n2 += 1, t.nodes && t.nodes.length > 0) {
|
|
963
|
+
const e3 = specificityOfMostSpecificListItem(t.nodes, s);
|
|
964
|
+
c += e3.a, n2 += e3.b, o2 += e3.c;
|
|
961
965
|
}
|
|
962
966
|
break;
|
|
963
967
|
case ":active-view-transition":
|
|
964
968
|
case ":active-view-transition-type":
|
|
965
969
|
return { a: 0, b: 1, c: 0 };
|
|
966
970
|
}
|
|
967
|
-
else _postcssselectorparser2.default.isContainer(
|
|
968
|
-
const
|
|
969
|
-
c +=
|
|
971
|
+
else _postcssselectorparser2.default.isContainer(t) && _optionalChain([t, 'access', _38 => _38.nodes, 'optionalAccess', _39 => _39.length]) > 0 && t.nodes.forEach((e3) => {
|
|
972
|
+
const t2 = selectorSpecificity(e3, s);
|
|
973
|
+
c += t2.a, n2 += t2.b, o2 += t2.c;
|
|
970
974
|
});
|
|
971
|
-
return { a: c, b:
|
|
975
|
+
return { a: c, b: n2, c: o2 };
|
|
972
976
|
}
|
|
973
|
-
function specificityOfMostSpecificListItem(e3,
|
|
977
|
+
function specificityOfMostSpecificListItem(e3, t) {
|
|
974
978
|
let s = { a: 0, b: 0, c: 0 };
|
|
975
979
|
return e3.forEach((e4) => {
|
|
976
|
-
const i = selectorSpecificity(e4,
|
|
980
|
+
const i = selectorSpecificity(e4, t);
|
|
977
981
|
compare(i, s) < 0 || (s = i);
|
|
978
982
|
}), s;
|
|
979
983
|
}
|
|
980
|
-
function isPseudoElement(
|
|
981
|
-
return _postcssselectorparser2.default.isPseudoElement(
|
|
984
|
+
function isPseudoElement(t) {
|
|
985
|
+
return _postcssselectorparser2.default.isPseudoElement(t);
|
|
982
986
|
}
|
|
983
987
|
function selectorNodeContainsNothingOrOnlyUniversal(e3) {
|
|
984
988
|
if (!e3) return false;
|
|
985
989
|
if (!e3.nodes) return false;
|
|
986
|
-
const
|
|
987
|
-
return 0 ===
|
|
990
|
+
const t = e3.nodes.filter((e4) => "comment" !== e4.type);
|
|
991
|
+
return 0 === t.length || 1 === t.length && "universal" === t[0].type;
|
|
988
992
|
}
|
|
989
993
|
|
|
990
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.
|
|
994
|
+
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.3_postcss@8.5.6/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
991
995
|
function alwaysValidSelector(s) {
|
|
992
996
|
const o2 = _postcssselectorparser2.default.call(void 0, ).astSync(s);
|
|
993
|
-
let
|
|
997
|
+
let n2 = true;
|
|
994
998
|
return o2.walk((e3) => {
|
|
995
999
|
if ("class" !== e3.type && "comment" !== e3.type && "id" !== e3.type && "root" !== e3.type && "selector" !== e3.type && "string" !== e3.type && "tag" !== e3.type && "universal" !== e3.type && ("attribute" !== e3.type || e3.insensitive) && ("combinator" !== e3.type || "+" !== e3.value && ">" !== e3.value && "~" !== e3.value && " " !== e3.value) && ("pseudo" !== e3.type || _optionalChain([e3, 'access', _40 => _40.nodes, 'optionalAccess', _41 => _41.length]) || ":hover" !== e3.value.toLowerCase() && ":focus" !== e3.value.toLowerCase())) {
|
|
996
1000
|
if ("pseudo" === e3.type && 1 === _optionalChain([e3, 'access', _42 => _42.nodes, 'optionalAccess', _43 => _43.length]) && ":not" === e3.value.toLowerCase()) {
|
|
@@ -999,34 +1003,34 @@ function alwaysValidSelector(s) {
|
|
|
999
1003
|
s2 = false;
|
|
1000
1004
|
}), s2) return;
|
|
1001
1005
|
}
|
|
1002
|
-
return
|
|
1006
|
+
return n2 = false, false;
|
|
1003
1007
|
}
|
|
1004
|
-
}),
|
|
1008
|
+
}), n2;
|
|
1005
1009
|
}
|
|
1006
1010
|
function sortCompoundSelectorsInsideComplexSelector(s) {
|
|
1007
1011
|
if (!s || !s.nodes || 1 === s.nodes.length) return;
|
|
1008
1012
|
const o2 = [];
|
|
1009
|
-
let
|
|
1010
|
-
for (let
|
|
1011
|
-
o2.push(
|
|
1012
|
-
const
|
|
1013
|
+
let n2 = [];
|
|
1014
|
+
for (let t2 = 0; t2 < s.nodes.length; t2++) "combinator" !== s.nodes[t2].type ? _postcssselectorparser2.default.isPseudoElement(s.nodes[t2]) ? (o2.push(n2), n2 = [s.nodes[t2]]) : n2.push(s.nodes[t2]) : (o2.push(n2), o2.push([s.nodes[t2]]), n2 = []);
|
|
1015
|
+
o2.push(n2);
|
|
1016
|
+
const t = [];
|
|
1013
1017
|
for (let e3 = 0; e3 < o2.length; e3++) {
|
|
1014
1018
|
const s2 = o2[e3];
|
|
1015
1019
|
s2.sort((e4, s3) => "selector" === e4.type && "selector" === s3.type && e4.nodes.length && s3.nodes.length ? selectorTypeOrder(e4.nodes[0], e4.nodes[0].type) - selectorTypeOrder(s3.nodes[0], s3.nodes[0].type) : "selector" === e4.type && e4.nodes.length ? selectorTypeOrder(e4.nodes[0], e4.nodes[0].type) - selectorTypeOrder(s3, s3.type) : "selector" === s3.type && s3.nodes.length ? selectorTypeOrder(e4, e4.type) - selectorTypeOrder(s3.nodes[0], s3.nodes[0].type) : selectorTypeOrder(e4, e4.type) - selectorTypeOrder(s3, s3.type));
|
|
1016
|
-
const
|
|
1017
|
-
for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() :
|
|
1020
|
+
const n3 = new Set(s2.map((e4) => e4.type)), r = n3.has("universal") && (n3.has("tag") || n3.has("attribute") || n3.has("class") || n3.has("id") || n3.has("pseudo"));
|
|
1021
|
+
for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() : t.push(s2[e4]);
|
|
1018
1022
|
}
|
|
1019
1023
|
s.removeAll();
|
|
1020
|
-
for (let o3 =
|
|
1021
|
-
const
|
|
1022
|
-
if (
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1025
|
-
} else
|
|
1024
|
+
for (let o3 = t.length - 1; o3 >= 0; o3--) {
|
|
1025
|
+
const n3 = t[o3 - 1];
|
|
1026
|
+
if (t[o3].remove(), n3 && "tag" === n3.type && "tag" === t[o3].type) {
|
|
1027
|
+
const n4 = _postcssselectorparser2.default.pseudo({ value: ":is", nodes: [_postcssselectorparser2.default.selector({ value: "", nodes: [t[o3]] })] });
|
|
1028
|
+
n4.parent = s, s.nodes.unshift(n4);
|
|
1029
|
+
} else t[o3].parent = s, s.nodes.unshift(t[o3]);
|
|
1026
1030
|
}
|
|
1027
1031
|
}
|
|
1028
|
-
function selectorTypeOrder(s,
|
|
1029
|
-
return _postcssselectorparser2.default.isPseudoElement(s) ? o.pseudoElement : o[
|
|
1032
|
+
function selectorTypeOrder(s, n2) {
|
|
1033
|
+
return _postcssselectorparser2.default.isPseudoElement(s) ? o.pseudoElement : o[n2];
|
|
1030
1034
|
}
|
|
1031
1035
|
var o = { universal: 0, tag: 1, pseudoElement: 2, id: 3, class: 4, attribute: 5, pseudo: 6, selector: 7, string: 8, root: 9, comment: 10 };
|
|
1032
1036
|
function childAdjacentChild(e3) {
|
|
@@ -1036,40 +1040,79 @@ function isInCompoundWithOneOtherElement(s) {
|
|
|
1036
1040
|
if (!s || !s.nodes) return false;
|
|
1037
1041
|
if (!_postcssselectorparser2.default.isSelector(s)) return false;
|
|
1038
1042
|
if (2 !== s.nodes.length) return false;
|
|
1039
|
-
let o2 = -1,
|
|
1040
|
-
s.nodes[0] && _postcssselectorparser2.default.isPseudoClass(s.nodes[0]) && ":-csstools-matches" === s.nodes[0].value ? (o2 = 0,
|
|
1041
|
-
const
|
|
1042
|
-
if (!
|
|
1043
|
-
const r = s.nodes[
|
|
1044
|
-
return !!r && (!_postcssselectorparser2.default.isCombinator(r) && (
|
|
1043
|
+
let o2 = -1, n2 = -1;
|
|
1044
|
+
s.nodes[0] && _postcssselectorparser2.default.isPseudoClass(s.nodes[0]) && ":-csstools-matches" === s.nodes[0].value ? (o2 = 0, n2 = 1) : s.nodes[1] && _postcssselectorparser2.default.isPseudoClass(s.nodes[1]) && ":-csstools-matches" === s.nodes[1].value && (o2 = 1, n2 = 0);
|
|
1045
|
+
const t = s.nodes[o2];
|
|
1046
|
+
if (!t || !_postcssselectorparser2.default.isPseudoClass(t) || 1 !== t.nodes.length) return false;
|
|
1047
|
+
const r = s.nodes[n2];
|
|
1048
|
+
return !!r && (!_postcssselectorparser2.default.isCombinator(r) && (!_postcssselectorparser2.default.isPseudoElement(r) && (t.nodes[0].append(r.clone()), t.replaceWith(...t.nodes[0].nodes), r.remove(), true)));
|
|
1045
1049
|
}
|
|
1046
1050
|
function isPseudoInFirstCompound(s) {
|
|
1047
1051
|
if (!s || !s.nodes) return false;
|
|
1048
1052
|
if (!_postcssselectorparser2.default.isSelector(s)) return false;
|
|
1049
1053
|
let o2 = -1;
|
|
1050
|
-
for (let
|
|
1051
|
-
const
|
|
1052
|
-
if (_postcssselectorparser2.default.isCombinator(
|
|
1053
|
-
if (_postcssselectorparser2.default.
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1054
|
+
for (let n3 = 0; n3 < s.nodes.length; n3++) {
|
|
1055
|
+
const t2 = s.nodes[n3];
|
|
1056
|
+
if (_postcssselectorparser2.default.isCombinator(t2)) return false;
|
|
1057
|
+
if (_postcssselectorparser2.default.isPseudoElement(t2)) return false;
|
|
1058
|
+
if (_postcssselectorparser2.default.isPseudoClass(t2)) {
|
|
1059
|
+
const e3 = t2;
|
|
1060
|
+
if (":-csstools-matches" === e3.value) {
|
|
1061
|
+
if (!e3.nodes || 1 !== e3.nodes.length) return false;
|
|
1062
|
+
o2 = n3;
|
|
1063
|
+
break;
|
|
1064
|
+
}
|
|
1057
1065
|
}
|
|
1058
1066
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1067
|
+
if (-1 === o2) return false;
|
|
1068
|
+
const n2 = s.nodes[o2];
|
|
1069
|
+
if (!n2 || !_postcssselectorparser2.default.isPseudoClass(n2)) return false;
|
|
1070
|
+
const t = s.nodes.slice(0, o2), r = s.nodes.slice(o2 + 1);
|
|
1071
|
+
return t.forEach((e3) => {
|
|
1072
|
+
n2.nodes[0].append(e3.clone());
|
|
1064
1073
|
}), r.forEach((e3) => {
|
|
1065
|
-
|
|
1066
|
-
}),
|
|
1074
|
+
n2.nodes[0].append(e3.clone());
|
|
1075
|
+
}), n2.replaceWith(...n2.nodes), t.forEach((e3) => {
|
|
1067
1076
|
e3.remove();
|
|
1068
1077
|
}), r.forEach((e3) => {
|
|
1069
1078
|
e3.remove();
|
|
1070
1079
|
}), true;
|
|
1071
1080
|
}
|
|
1072
|
-
function
|
|
1081
|
+
function samePrecedingElement(s) {
|
|
1082
|
+
if (!s || !s.nodes) return false;
|
|
1083
|
+
if ("selector" !== s.type) return false;
|
|
1084
|
+
let o2 = -1;
|
|
1085
|
+
for (let n3 = 0; n3 < s.nodes.length; n3++) {
|
|
1086
|
+
const t2 = s.nodes[n3];
|
|
1087
|
+
if (_postcssselectorparser2.default.isCombinator(t2)) {
|
|
1088
|
+
o2 = n3;
|
|
1089
|
+
break;
|
|
1090
|
+
}
|
|
1091
|
+
if (_postcssselectorparser2.default.isPseudoElement(t2)) return false;
|
|
1092
|
+
}
|
|
1093
|
+
if (-1 === o2) return false;
|
|
1094
|
+
const n2 = o2 + 1;
|
|
1095
|
+
if (!s.nodes[o2] || "combinator" !== s.nodes[o2].type || ">" !== s.nodes[o2].value && "+" !== s.nodes[o2].value) return false;
|
|
1096
|
+
const t = s.nodes[o2].value;
|
|
1097
|
+
if (!s.nodes[n2] || "pseudo" !== s.nodes[n2].type || ":-csstools-matches" !== s.nodes[n2].value) return false;
|
|
1098
|
+
if (!s.nodes[n2].nodes || 1 !== s.nodes[n2].nodes.length) return false;
|
|
1099
|
+
if ("selector" !== s.nodes[n2].nodes[0].type) return false;
|
|
1100
|
+
if (!s.nodes[n2].nodes[0].nodes || 3 !== s.nodes[n2].nodes[0].nodes.length) return false;
|
|
1101
|
+
if (!s.nodes[n2].nodes[0].nodes || "combinator" !== s.nodes[n2].nodes[0].nodes[1].type || s.nodes[n2].nodes[0].nodes[1].value !== t) return false;
|
|
1102
|
+
const r = s.nodes[n2];
|
|
1103
|
+
if (!r || !_postcssselectorparser2.default.isPseudoClass(r)) return false;
|
|
1104
|
+
const d = s.nodes.slice(0, o2), l = s.nodes.slice(n2 + 1);
|
|
1105
|
+
return s.each((e3) => {
|
|
1106
|
+
e3.remove();
|
|
1107
|
+
}), d.forEach((e3) => {
|
|
1108
|
+
s.append(e3);
|
|
1109
|
+
}), r.nodes[0].nodes.forEach((e3) => {
|
|
1110
|
+
s.append(e3);
|
|
1111
|
+
}), l.forEach((e3) => {
|
|
1112
|
+
s.append(e3);
|
|
1113
|
+
}), true;
|
|
1114
|
+
}
|
|
1115
|
+
function complexSelectors(s, o2, n2, t) {
|
|
1073
1116
|
return s.flatMap((s2) => {
|
|
1074
1117
|
if (-1 === s2.indexOf(":-csstools-matches") && -1 === s2.toLowerCase().indexOf(":is")) return s2;
|
|
1075
1118
|
const r = _postcssselectorparser2.default.call(void 0, ).astSync(s2);
|
|
@@ -1081,13 +1124,13 @@ function complexSelectors(s, o2, t2, n) {
|
|
|
1081
1124
|
let e3 = s4.value;
|
|
1082
1125
|
if (e3.startsWith("::-csstools-invalid-")) return;
|
|
1083
1126
|
for (; e3.startsWith(":"); ) e3 = e3.slice(1);
|
|
1084
|
-
s4.value = `::-csstools-invalid-${e3}`,
|
|
1127
|
+
s4.value = `::-csstools-invalid-${e3}`, t();
|
|
1085
1128
|
}
|
|
1086
1129
|
}), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
|
|
1087
1130
|
if (1 === s3.nodes[0].nodes.length) return void s3.replaceWith(s3.nodes[0].nodes[0]);
|
|
1088
1131
|
if (!s3.nodes[0].some((e3) => "combinator" === e3.type)) return void s3.replaceWith(...s3.nodes[0].nodes);
|
|
1089
1132
|
}
|
|
1090
|
-
1 !== r.nodes.length || "selector" !== r.nodes[0].type || 1 !== r.nodes[0].nodes.length || r.nodes[0].nodes[0] !== s3 ? childAdjacentChild(s3.parent) || isInCompoundWithOneOtherElement(s3.parent) || isPseudoInFirstCompound(s3.parent) || ("warning" === o2.onComplexSelector &&
|
|
1133
|
+
1 !== r.nodes.length || "selector" !== r.nodes[0].type || 1 !== r.nodes[0].nodes.length || r.nodes[0].nodes[0] !== s3 ? childAdjacentChild(s3.parent) || isInCompoundWithOneOtherElement(s3.parent) || isPseudoInFirstCompound(s3.parent) || samePrecedingElement(s3.parent) || ("warning" === o2.onComplexSelector && n2(), s3.value = ":is") : s3.replaceWith(...s3.nodes[0].nodes);
|
|
1091
1134
|
} else s3.remove();
|
|
1092
1135
|
}), r.walk((e3) => {
|
|
1093
1136
|
"selector" === e3.type && "nodes" in e3 && 1 === e3.nodes.length && "selector" === e3.nodes[0].type && e3.replaceWith(e3.nodes[0]);
|
|
@@ -1096,87 +1139,87 @@ function complexSelectors(s, o2, t2, n) {
|
|
|
1096
1139
|
}), r.toString();
|
|
1097
1140
|
}).filter((e3) => !!e3);
|
|
1098
1141
|
}
|
|
1099
|
-
function splitSelectors(o2,
|
|
1100
|
-
const r = ":not(#" +
|
|
1142
|
+
function splitSelectors(o2, n2, t = 0) {
|
|
1143
|
+
const r = ":not(#" + n2.specificityMatchingName + ")", d = ":not(." + n2.specificityMatchingName + ")", l = ":not(" + n2.specificityMatchingName + ")";
|
|
1101
1144
|
return o2.flatMap((o3) => {
|
|
1102
1145
|
if (-1 === o3.toLowerCase().indexOf(":is")) return o3;
|
|
1103
|
-
let
|
|
1104
|
-
const
|
|
1146
|
+
let i = false;
|
|
1147
|
+
const a = [];
|
|
1105
1148
|
if (_postcssselectorparser2.default.call(void 0, ).astSync(o3).walkPseudos((e3) => {
|
|
1106
1149
|
if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
|
|
1107
1150
|
if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
|
|
1108
|
-
if ("pseudo" === _optionalChain([e3, 'access', _44 => _44.parent, 'optionalAccess', _45 => _45.parent, 'optionalAccess', _46 => _46.type]) && ":not" === _optionalChain([e3, 'access', _47 => _47.parent, 'optionalAccess', _48 => _48.parent, 'optionalAccess', _49 => _49.value, 'optionalAccess', _50 => _50.toLowerCase, 'call', _51 => _51()])) return void
|
|
1151
|
+
if ("pseudo" === _optionalChain([e3, 'access', _44 => _44.parent, 'optionalAccess', _45 => _45.parent, 'optionalAccess', _46 => _46.type]) && ":not" === _optionalChain([e3, 'access', _47 => _47.parent, 'optionalAccess', _48 => _48.parent, 'optionalAccess', _49 => _49.value, 'optionalAccess', _50 => _50.toLowerCase, 'call', _51 => _51()])) return void a.push([{ start: e3.parent.parent.sourceIndex, end: e3.parent.parent.sourceIndex + e3.parent.parent.toString().length, option: `:not(${e3.nodes.toString()})` }]);
|
|
1109
1152
|
if ("pseudo" === _optionalChain([e3, 'access', _52 => _52.parent, 'optionalAccess', _53 => _53.parent, 'optionalAccess', _54 => _54.type]) && ":has" === _optionalChain([e3, 'access', _55 => _55.parent, 'optionalAccess', _56 => _56.parent, 'optionalAccess', _57 => _57.value, 'optionalAccess', _58 => _58.toLowerCase, 'call', _59 => _59()])) return void (e3.value = ":-csstools-matches");
|
|
1110
1153
|
let o4 = e3.parent;
|
|
1111
1154
|
for (; o4; ) {
|
|
1112
|
-
if (o4.value && ":is" === o4.value.toLowerCase() && "pseudo" === o4.type) return void (
|
|
1155
|
+
if (o4.value && ":is" === o4.value.toLowerCase() && "pseudo" === o4.type) return void (i = true);
|
|
1113
1156
|
o4 = o4.parent;
|
|
1114
1157
|
}
|
|
1115
|
-
const
|
|
1158
|
+
const n3 = selectorSpecificity(e3), t2 = e3.sourceIndex, c2 = t2 + e3.toString().length, p = [];
|
|
1116
1159
|
e3.nodes.forEach((e4) => {
|
|
1117
|
-
const o5 = { start:
|
|
1118
|
-
let
|
|
1119
|
-
const u = Math.max(0,
|
|
1120
|
-
for (let e5 = 0; e5 < u; e5++)
|
|
1121
|
-
for (let e5 = 0; e5 < h; e5++)
|
|
1122
|
-
for (let e5 = 0; e5 < f; e5++)
|
|
1123
|
-
o5.option =
|
|
1124
|
-
}),
|
|
1125
|
-
}), !
|
|
1160
|
+
const o5 = { start: t2, end: c2, option: "" }, i2 = selectorSpecificity(e4);
|
|
1161
|
+
let a2 = e4.toString().trim();
|
|
1162
|
+
const u = Math.max(0, n3.a - i2.a), h = Math.max(0, n3.b - i2.b), f = Math.max(0, n3.c - i2.c);
|
|
1163
|
+
for (let e5 = 0; e5 < u; e5++) a2 += r;
|
|
1164
|
+
for (let e5 = 0; e5 < h; e5++) a2 += d;
|
|
1165
|
+
for (let e5 = 0; e5 < f; e5++) a2 += l;
|
|
1166
|
+
o5.option = a2, p.push(o5);
|
|
1167
|
+
}), a.push(p);
|
|
1168
|
+
}), !a.length) return [o3];
|
|
1126
1169
|
let c = [];
|
|
1127
|
-
return cartesianProduct(...
|
|
1170
|
+
return cartesianProduct(...a).forEach((e3) => {
|
|
1128
1171
|
let s = "";
|
|
1129
|
-
for (let
|
|
1130
|
-
const
|
|
1131
|
-
s += o3.substring(_optionalChain([e3, 'access', _60 => _60[
|
|
1172
|
+
for (let n3 = 0; n3 < e3.length; n3++) {
|
|
1173
|
+
const t2 = e3[n3];
|
|
1174
|
+
s += o3.substring(_optionalChain([e3, 'access', _60 => _60[n3 - 1], 'optionalAccess', _61 => _61.end]) || 0, e3[n3].start), s += ":-csstools-matches(" + t2.option + ")", n3 === e3.length - 1 && (s += o3.substring(e3[n3].end));
|
|
1132
1175
|
}
|
|
1133
1176
|
c.push(s);
|
|
1134
|
-
}),
|
|
1177
|
+
}), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
|
|
1135
1178
|
}).filter((e3) => !!e3);
|
|
1136
1179
|
}
|
|
1137
1180
|
function cartesianProduct(...e3) {
|
|
1138
1181
|
const s = [], o2 = e3.length - 1;
|
|
1139
|
-
return function helper(
|
|
1140
|
-
for (let r = 0, d = e3[
|
|
1141
|
-
const d2 =
|
|
1142
|
-
d2.push(e3[
|
|
1182
|
+
return function helper(n2, t) {
|
|
1183
|
+
for (let r = 0, d = e3[t].length; r < d; r++) {
|
|
1184
|
+
const d2 = n2.slice(0);
|
|
1185
|
+
d2.push(e3[t][r]), t === o2 ? s.push(d2) : helper(d2, t + 1);
|
|
1143
1186
|
}
|
|
1144
1187
|
}([], 0), s;
|
|
1145
1188
|
}
|
|
1146
|
-
var
|
|
1189
|
+
var n = /:is\(/i;
|
|
1147
1190
|
var creator = (e3) => {
|
|
1148
1191
|
const s = { specificityMatchingName: "does-not-exist", ...e3 || {} };
|
|
1149
1192
|
return { postcssPlugin: "postcss-is-pseudo-class", prepare() {
|
|
1150
1193
|
const e4 = /* @__PURE__ */ new WeakSet();
|
|
1151
|
-
return { postcssPlugin: "postcss-is-pseudo-class", Rule(o2, { result:
|
|
1194
|
+
return { postcssPlugin: "postcss-is-pseudo-class", Rule(o2, { result: t }) {
|
|
1152
1195
|
if (!o2.selector) return;
|
|
1153
|
-
if (!
|
|
1196
|
+
if (!n.test(o2.selector)) return;
|
|
1154
1197
|
if (e4.has(o2)) return;
|
|
1155
1198
|
let r = false;
|
|
1156
1199
|
const warnOnComplexSelector = () => {
|
|
1157
|
-
"warning" === s.onComplexSelector && (r || (r = true, o2.warn(
|
|
1200
|
+
"warning" === s.onComplexSelector && (r || (r = true, o2.warn(t, `Complex selectors in '${o2.selector}' can not be transformed to an equivalent selector without ':is()'.`)));
|
|
1158
1201
|
};
|
|
1159
1202
|
let d = false;
|
|
1160
1203
|
const warnOnPseudoElements = () => {
|
|
1161
|
-
"warning" === s.onPseudoElement && (d || (d = true, o2.warn(
|
|
1204
|
+
"warning" === s.onPseudoElement && (d || (d = true, o2.warn(t, `Pseudo elements are not allowed in ':is()', unable to transform '${o2.selector}'`)));
|
|
1162
1205
|
};
|
|
1163
1206
|
try {
|
|
1164
|
-
let
|
|
1165
|
-
const
|
|
1207
|
+
let n2 = false;
|
|
1208
|
+
const t2 = [], r2 = complexSelectors(splitSelectors(o2.selectors, { specificityMatchingName: s.specificityMatchingName }), { onComplexSelector: s.onComplexSelector }, warnOnComplexSelector, warnOnPseudoElements);
|
|
1166
1209
|
if (Array.from(new Set(r2)).forEach((s2) => {
|
|
1167
|
-
if (o2.selectors.indexOf(s2) > -1)
|
|
1210
|
+
if (o2.selectors.indexOf(s2) > -1) t2.push(s2);
|
|
1168
1211
|
else {
|
|
1169
|
-
if (alwaysValidSelector(s2)) return
|
|
1170
|
-
e4.add(o2), o2.cloneBefore({ selector: s2 }),
|
|
1212
|
+
if (alwaysValidSelector(s2)) return t2.push(s2), void (n2 = true);
|
|
1213
|
+
e4.add(o2), o2.cloneBefore({ selector: s2 }), n2 = true;
|
|
1171
1214
|
}
|
|
1172
|
-
}),
|
|
1173
|
-
if (!
|
|
1215
|
+
}), t2.length && n2 && (e4.add(o2), o2.cloneBefore({ selectors: t2 })), !s.preserve) {
|
|
1216
|
+
if (!n2) return;
|
|
1174
1217
|
o2.remove();
|
|
1175
1218
|
}
|
|
1176
1219
|
} catch (e5) {
|
|
1177
1220
|
if (!(e5 instanceof Error)) throw e5;
|
|
1178
1221
|
if (e5.message.indexOf("call stack size exceeded") > -1) throw e5;
|
|
1179
|
-
o2.warn(
|
|
1222
|
+
o2.warn(t, `Failed to parse selector "${o2.selector}" with error: ${e5.message}`);
|
|
1180
1223
|
}
|
|
1181
1224
|
} };
|
|
1182
1225
|
} };
|
package/dist/index.mjs
CHANGED
|
@@ -280,8 +280,8 @@ function getFallbackRemove(rule) {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
} else if (selector.value === ":where") {
|
|
283
|
-
for (const
|
|
284
|
-
for (const node of
|
|
283
|
+
for (const n2 of selector.nodes) {
|
|
284
|
+
for (const node of n2.nodes) {
|
|
285
285
|
if (node.type === "attribute") {
|
|
286
286
|
node.remove();
|
|
287
287
|
}
|
|
@@ -846,6 +846,10 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
846
846
|
if (/color-mix/.test(atRule.params)) {
|
|
847
847
|
atRule.remove();
|
|
848
848
|
}
|
|
849
|
+
} else if (atRule.name === "layer") {
|
|
850
|
+
if (atRule.nodes === void 0 || Array.isArray(atRule.nodes) && atRule.nodes.length === 0) {
|
|
851
|
+
atRule.remove();
|
|
852
|
+
}
|
|
849
853
|
}
|
|
850
854
|
}
|
|
851
855
|
};
|
|
@@ -879,118 +883,118 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
879
883
|
};
|
|
880
884
|
postcssWeappTailwindcssPrePlugin.postcss = true;
|
|
881
885
|
|
|
882
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.
|
|
886
|
+
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.3_postcss@8.5.6/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
883
887
|
import e2 from "postcss-selector-parser";
|
|
884
888
|
|
|
885
889
|
// ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.1.0/node_modules/@csstools/selector-specificity/dist/index.mjs
|
|
886
890
|
import e from "postcss-selector-parser";
|
|
887
|
-
function compare(e3,
|
|
888
|
-
return e3.a ===
|
|
891
|
+
function compare(e3, t) {
|
|
892
|
+
return e3.a === t.a ? e3.b === t.b ? e3.c - t.c : e3.b - t.b : e3.a - t.a;
|
|
889
893
|
}
|
|
890
|
-
function selectorSpecificity(
|
|
891
|
-
const i = s?.customSpecificity?.(
|
|
894
|
+
function selectorSpecificity(t, s) {
|
|
895
|
+
const i = s?.customSpecificity?.(t);
|
|
892
896
|
if (i) return i;
|
|
893
|
-
if (!
|
|
894
|
-
let c = 0,
|
|
895
|
-
if ("universal" ==
|
|
896
|
-
if ("id" ===
|
|
897
|
-
else if ("tag" ===
|
|
898
|
-
else if ("class" ===
|
|
899
|
-
else if ("attribute" ===
|
|
900
|
-
else if (isPseudoElement(
|
|
897
|
+
if (!t) return { a: 0, b: 0, c: 0 };
|
|
898
|
+
let c = 0, n2 = 0, o2 = 0;
|
|
899
|
+
if ("universal" == t.type) return { a: 0, b: 0, c: 0 };
|
|
900
|
+
if ("id" === t.type) c += 1;
|
|
901
|
+
else if ("tag" === t.type) o2 += 1;
|
|
902
|
+
else if ("class" === t.type) n2 += 1;
|
|
903
|
+
else if ("attribute" === t.type) n2 += 1;
|
|
904
|
+
else if (isPseudoElement(t)) switch (t.value.toLowerCase()) {
|
|
901
905
|
case "::slotted":
|
|
902
|
-
if (o2 += 1,
|
|
903
|
-
const e3 = specificityOfMostSpecificListItem(
|
|
904
|
-
c += e3.a,
|
|
906
|
+
if (o2 += 1, t.nodes && t.nodes.length > 0) {
|
|
907
|
+
const e3 = specificityOfMostSpecificListItem(t.nodes, s);
|
|
908
|
+
c += e3.a, n2 += e3.b, o2 += e3.c;
|
|
905
909
|
}
|
|
906
910
|
break;
|
|
907
911
|
case "::view-transition-group":
|
|
908
912
|
case "::view-transition-image-pair":
|
|
909
913
|
case "::view-transition-old":
|
|
910
914
|
case "::view-transition-new":
|
|
911
|
-
return
|
|
915
|
+
return t.nodes && 1 === t.nodes.length && "selector" === t.nodes[0].type && selectorNodeContainsNothingOrOnlyUniversal(t.nodes[0]) ? { a: 0, b: 0, c: 0 } : { a: 0, b: 0, c: 1 };
|
|
912
916
|
default:
|
|
913
917
|
o2 += 1;
|
|
914
918
|
}
|
|
915
|
-
else if (e.isPseudoClass(
|
|
919
|
+
else if (e.isPseudoClass(t)) switch (t.value.toLowerCase()) {
|
|
916
920
|
case ":-webkit-any":
|
|
917
921
|
case ":any":
|
|
918
922
|
default:
|
|
919
|
-
|
|
923
|
+
n2 += 1;
|
|
920
924
|
break;
|
|
921
925
|
case ":-moz-any":
|
|
922
926
|
case ":has":
|
|
923
927
|
case ":is":
|
|
924
928
|
case ":matches":
|
|
925
929
|
case ":not":
|
|
926
|
-
if (
|
|
927
|
-
const e3 = specificityOfMostSpecificListItem(
|
|
928
|
-
c += e3.a,
|
|
930
|
+
if (t.nodes && t.nodes.length > 0) {
|
|
931
|
+
const e3 = specificityOfMostSpecificListItem(t.nodes, s);
|
|
932
|
+
c += e3.a, n2 += e3.b, o2 += e3.c;
|
|
929
933
|
}
|
|
930
934
|
break;
|
|
931
935
|
case ":where":
|
|
932
936
|
break;
|
|
933
937
|
case ":nth-child":
|
|
934
938
|
case ":nth-last-child":
|
|
935
|
-
if (
|
|
936
|
-
const i2 =
|
|
939
|
+
if (n2 += 1, t.nodes && t.nodes.length > 0) {
|
|
940
|
+
const i2 = t.nodes[0].nodes.findIndex((e3) => "tag" === e3.type && "of" === e3.value.toLowerCase());
|
|
937
941
|
if (i2 > -1) {
|
|
938
942
|
const a = e.selector({ nodes: [], value: "" });
|
|
939
|
-
|
|
943
|
+
t.nodes[0].nodes.slice(i2 + 1).forEach((e3) => {
|
|
940
944
|
a.append(e3.clone());
|
|
941
945
|
});
|
|
942
946
|
const r = [a];
|
|
943
|
-
|
|
947
|
+
t.nodes.length > 1 && r.push(...t.nodes.slice(1));
|
|
944
948
|
const l = specificityOfMostSpecificListItem(r, s);
|
|
945
|
-
c += l.a,
|
|
949
|
+
c += l.a, n2 += l.b, o2 += l.c;
|
|
946
950
|
}
|
|
947
951
|
}
|
|
948
952
|
break;
|
|
949
953
|
case ":local":
|
|
950
954
|
case ":global":
|
|
951
|
-
|
|
952
|
-
const
|
|
953
|
-
c +=
|
|
955
|
+
t.nodes && t.nodes.length > 0 && t.nodes.forEach((e3) => {
|
|
956
|
+
const t2 = selectorSpecificity(e3, s);
|
|
957
|
+
c += t2.a, n2 += t2.b, o2 += t2.c;
|
|
954
958
|
});
|
|
955
959
|
break;
|
|
956
960
|
case ":host":
|
|
957
961
|
case ":host-context":
|
|
958
|
-
if (
|
|
959
|
-
const e3 = specificityOfMostSpecificListItem(
|
|
960
|
-
c += e3.a,
|
|
962
|
+
if (n2 += 1, t.nodes && t.nodes.length > 0) {
|
|
963
|
+
const e3 = specificityOfMostSpecificListItem(t.nodes, s);
|
|
964
|
+
c += e3.a, n2 += e3.b, o2 += e3.c;
|
|
961
965
|
}
|
|
962
966
|
break;
|
|
963
967
|
case ":active-view-transition":
|
|
964
968
|
case ":active-view-transition-type":
|
|
965
969
|
return { a: 0, b: 1, c: 0 };
|
|
966
970
|
}
|
|
967
|
-
else e.isContainer(
|
|
968
|
-
const
|
|
969
|
-
c +=
|
|
971
|
+
else e.isContainer(t) && t.nodes?.length > 0 && t.nodes.forEach((e3) => {
|
|
972
|
+
const t2 = selectorSpecificity(e3, s);
|
|
973
|
+
c += t2.a, n2 += t2.b, o2 += t2.c;
|
|
970
974
|
});
|
|
971
|
-
return { a: c, b:
|
|
975
|
+
return { a: c, b: n2, c: o2 };
|
|
972
976
|
}
|
|
973
|
-
function specificityOfMostSpecificListItem(e3,
|
|
977
|
+
function specificityOfMostSpecificListItem(e3, t) {
|
|
974
978
|
let s = { a: 0, b: 0, c: 0 };
|
|
975
979
|
return e3.forEach((e4) => {
|
|
976
|
-
const i = selectorSpecificity(e4,
|
|
980
|
+
const i = selectorSpecificity(e4, t);
|
|
977
981
|
compare(i, s) < 0 || (s = i);
|
|
978
982
|
}), s;
|
|
979
983
|
}
|
|
980
|
-
function isPseudoElement(
|
|
981
|
-
return e.isPseudoElement(
|
|
984
|
+
function isPseudoElement(t) {
|
|
985
|
+
return e.isPseudoElement(t);
|
|
982
986
|
}
|
|
983
987
|
function selectorNodeContainsNothingOrOnlyUniversal(e3) {
|
|
984
988
|
if (!e3) return false;
|
|
985
989
|
if (!e3.nodes) return false;
|
|
986
|
-
const
|
|
987
|
-
return 0 ===
|
|
990
|
+
const t = e3.nodes.filter((e4) => "comment" !== e4.type);
|
|
991
|
+
return 0 === t.length || 1 === t.length && "universal" === t[0].type;
|
|
988
992
|
}
|
|
989
993
|
|
|
990
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.
|
|
994
|
+
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.3_postcss@8.5.6/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
991
995
|
function alwaysValidSelector(s) {
|
|
992
996
|
const o2 = e2().astSync(s);
|
|
993
|
-
let
|
|
997
|
+
let n2 = true;
|
|
994
998
|
return o2.walk((e3) => {
|
|
995
999
|
if ("class" !== e3.type && "comment" !== e3.type && "id" !== e3.type && "root" !== e3.type && "selector" !== e3.type && "string" !== e3.type && "tag" !== e3.type && "universal" !== e3.type && ("attribute" !== e3.type || e3.insensitive) && ("combinator" !== e3.type || "+" !== e3.value && ">" !== e3.value && "~" !== e3.value && " " !== e3.value) && ("pseudo" !== e3.type || e3.nodes?.length || ":hover" !== e3.value.toLowerCase() && ":focus" !== e3.value.toLowerCase())) {
|
|
996
1000
|
if ("pseudo" === e3.type && 1 === e3.nodes?.length && ":not" === e3.value.toLowerCase()) {
|
|
@@ -999,34 +1003,34 @@ function alwaysValidSelector(s) {
|
|
|
999
1003
|
s2 = false;
|
|
1000
1004
|
}), s2) return;
|
|
1001
1005
|
}
|
|
1002
|
-
return
|
|
1006
|
+
return n2 = false, false;
|
|
1003
1007
|
}
|
|
1004
|
-
}),
|
|
1008
|
+
}), n2;
|
|
1005
1009
|
}
|
|
1006
1010
|
function sortCompoundSelectorsInsideComplexSelector(s) {
|
|
1007
1011
|
if (!s || !s.nodes || 1 === s.nodes.length) return;
|
|
1008
1012
|
const o2 = [];
|
|
1009
|
-
let
|
|
1010
|
-
for (let
|
|
1011
|
-
o2.push(
|
|
1012
|
-
const
|
|
1013
|
+
let n2 = [];
|
|
1014
|
+
for (let t2 = 0; t2 < s.nodes.length; t2++) "combinator" !== s.nodes[t2].type ? e2.isPseudoElement(s.nodes[t2]) ? (o2.push(n2), n2 = [s.nodes[t2]]) : n2.push(s.nodes[t2]) : (o2.push(n2), o2.push([s.nodes[t2]]), n2 = []);
|
|
1015
|
+
o2.push(n2);
|
|
1016
|
+
const t = [];
|
|
1013
1017
|
for (let e3 = 0; e3 < o2.length; e3++) {
|
|
1014
1018
|
const s2 = o2[e3];
|
|
1015
1019
|
s2.sort((e4, s3) => "selector" === e4.type && "selector" === s3.type && e4.nodes.length && s3.nodes.length ? selectorTypeOrder(e4.nodes[0], e4.nodes[0].type) - selectorTypeOrder(s3.nodes[0], s3.nodes[0].type) : "selector" === e4.type && e4.nodes.length ? selectorTypeOrder(e4.nodes[0], e4.nodes[0].type) - selectorTypeOrder(s3, s3.type) : "selector" === s3.type && s3.nodes.length ? selectorTypeOrder(e4, e4.type) - selectorTypeOrder(s3.nodes[0], s3.nodes[0].type) : selectorTypeOrder(e4, e4.type) - selectorTypeOrder(s3, s3.type));
|
|
1016
|
-
const
|
|
1017
|
-
for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() :
|
|
1020
|
+
const n3 = new Set(s2.map((e4) => e4.type)), r = n3.has("universal") && (n3.has("tag") || n3.has("attribute") || n3.has("class") || n3.has("id") || n3.has("pseudo"));
|
|
1021
|
+
for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() : t.push(s2[e4]);
|
|
1018
1022
|
}
|
|
1019
1023
|
s.removeAll();
|
|
1020
|
-
for (let o3 =
|
|
1021
|
-
const
|
|
1022
|
-
if (
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1025
|
-
} else
|
|
1024
|
+
for (let o3 = t.length - 1; o3 >= 0; o3--) {
|
|
1025
|
+
const n3 = t[o3 - 1];
|
|
1026
|
+
if (t[o3].remove(), n3 && "tag" === n3.type && "tag" === t[o3].type) {
|
|
1027
|
+
const n4 = e2.pseudo({ value: ":is", nodes: [e2.selector({ value: "", nodes: [t[o3]] })] });
|
|
1028
|
+
n4.parent = s, s.nodes.unshift(n4);
|
|
1029
|
+
} else t[o3].parent = s, s.nodes.unshift(t[o3]);
|
|
1026
1030
|
}
|
|
1027
1031
|
}
|
|
1028
|
-
function selectorTypeOrder(s,
|
|
1029
|
-
return e2.isPseudoElement(s) ? o.pseudoElement : o[
|
|
1032
|
+
function selectorTypeOrder(s, n2) {
|
|
1033
|
+
return e2.isPseudoElement(s) ? o.pseudoElement : o[n2];
|
|
1030
1034
|
}
|
|
1031
1035
|
var o = { universal: 0, tag: 1, pseudoElement: 2, id: 3, class: 4, attribute: 5, pseudo: 6, selector: 7, string: 8, root: 9, comment: 10 };
|
|
1032
1036
|
function childAdjacentChild(e3) {
|
|
@@ -1036,40 +1040,79 @@ function isInCompoundWithOneOtherElement(s) {
|
|
|
1036
1040
|
if (!s || !s.nodes) return false;
|
|
1037
1041
|
if (!e2.isSelector(s)) return false;
|
|
1038
1042
|
if (2 !== s.nodes.length) return false;
|
|
1039
|
-
let o2 = -1,
|
|
1040
|
-
s.nodes[0] && e2.isPseudoClass(s.nodes[0]) && ":-csstools-matches" === s.nodes[0].value ? (o2 = 0,
|
|
1041
|
-
const
|
|
1042
|
-
if (!
|
|
1043
|
-
const r = s.nodes[
|
|
1044
|
-
return !!r && (!e2.isCombinator(r) && (
|
|
1043
|
+
let o2 = -1, n2 = -1;
|
|
1044
|
+
s.nodes[0] && e2.isPseudoClass(s.nodes[0]) && ":-csstools-matches" === s.nodes[0].value ? (o2 = 0, n2 = 1) : s.nodes[1] && e2.isPseudoClass(s.nodes[1]) && ":-csstools-matches" === s.nodes[1].value && (o2 = 1, n2 = 0);
|
|
1045
|
+
const t = s.nodes[o2];
|
|
1046
|
+
if (!t || !e2.isPseudoClass(t) || 1 !== t.nodes.length) return false;
|
|
1047
|
+
const r = s.nodes[n2];
|
|
1048
|
+
return !!r && (!e2.isCombinator(r) && (!e2.isPseudoElement(r) && (t.nodes[0].append(r.clone()), t.replaceWith(...t.nodes[0].nodes), r.remove(), true)));
|
|
1045
1049
|
}
|
|
1046
1050
|
function isPseudoInFirstCompound(s) {
|
|
1047
1051
|
if (!s || !s.nodes) return false;
|
|
1048
1052
|
if (!e2.isSelector(s)) return false;
|
|
1049
1053
|
let o2 = -1;
|
|
1050
|
-
for (let
|
|
1051
|
-
const
|
|
1052
|
-
if (e2.isCombinator(
|
|
1053
|
-
if (e2.
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1054
|
+
for (let n3 = 0; n3 < s.nodes.length; n3++) {
|
|
1055
|
+
const t2 = s.nodes[n3];
|
|
1056
|
+
if (e2.isCombinator(t2)) return false;
|
|
1057
|
+
if (e2.isPseudoElement(t2)) return false;
|
|
1058
|
+
if (e2.isPseudoClass(t2)) {
|
|
1059
|
+
const e3 = t2;
|
|
1060
|
+
if (":-csstools-matches" === e3.value) {
|
|
1061
|
+
if (!e3.nodes || 1 !== e3.nodes.length) return false;
|
|
1062
|
+
o2 = n3;
|
|
1063
|
+
break;
|
|
1064
|
+
}
|
|
1057
1065
|
}
|
|
1058
1066
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1067
|
+
if (-1 === o2) return false;
|
|
1068
|
+
const n2 = s.nodes[o2];
|
|
1069
|
+
if (!n2 || !e2.isPseudoClass(n2)) return false;
|
|
1070
|
+
const t = s.nodes.slice(0, o2), r = s.nodes.slice(o2 + 1);
|
|
1071
|
+
return t.forEach((e3) => {
|
|
1072
|
+
n2.nodes[0].append(e3.clone());
|
|
1064
1073
|
}), r.forEach((e3) => {
|
|
1065
|
-
|
|
1066
|
-
}),
|
|
1074
|
+
n2.nodes[0].append(e3.clone());
|
|
1075
|
+
}), n2.replaceWith(...n2.nodes), t.forEach((e3) => {
|
|
1067
1076
|
e3.remove();
|
|
1068
1077
|
}), r.forEach((e3) => {
|
|
1069
1078
|
e3.remove();
|
|
1070
1079
|
}), true;
|
|
1071
1080
|
}
|
|
1072
|
-
function
|
|
1081
|
+
function samePrecedingElement(s) {
|
|
1082
|
+
if (!s || !s.nodes) return false;
|
|
1083
|
+
if ("selector" !== s.type) return false;
|
|
1084
|
+
let o2 = -1;
|
|
1085
|
+
for (let n3 = 0; n3 < s.nodes.length; n3++) {
|
|
1086
|
+
const t2 = s.nodes[n3];
|
|
1087
|
+
if (e2.isCombinator(t2)) {
|
|
1088
|
+
o2 = n3;
|
|
1089
|
+
break;
|
|
1090
|
+
}
|
|
1091
|
+
if (e2.isPseudoElement(t2)) return false;
|
|
1092
|
+
}
|
|
1093
|
+
if (-1 === o2) return false;
|
|
1094
|
+
const n2 = o2 + 1;
|
|
1095
|
+
if (!s.nodes[o2] || "combinator" !== s.nodes[o2].type || ">" !== s.nodes[o2].value && "+" !== s.nodes[o2].value) return false;
|
|
1096
|
+
const t = s.nodes[o2].value;
|
|
1097
|
+
if (!s.nodes[n2] || "pseudo" !== s.nodes[n2].type || ":-csstools-matches" !== s.nodes[n2].value) return false;
|
|
1098
|
+
if (!s.nodes[n2].nodes || 1 !== s.nodes[n2].nodes.length) return false;
|
|
1099
|
+
if ("selector" !== s.nodes[n2].nodes[0].type) return false;
|
|
1100
|
+
if (!s.nodes[n2].nodes[0].nodes || 3 !== s.nodes[n2].nodes[0].nodes.length) return false;
|
|
1101
|
+
if (!s.nodes[n2].nodes[0].nodes || "combinator" !== s.nodes[n2].nodes[0].nodes[1].type || s.nodes[n2].nodes[0].nodes[1].value !== t) return false;
|
|
1102
|
+
const r = s.nodes[n2];
|
|
1103
|
+
if (!r || !e2.isPseudoClass(r)) return false;
|
|
1104
|
+
const d = s.nodes.slice(0, o2), l = s.nodes.slice(n2 + 1);
|
|
1105
|
+
return s.each((e3) => {
|
|
1106
|
+
e3.remove();
|
|
1107
|
+
}), d.forEach((e3) => {
|
|
1108
|
+
s.append(e3);
|
|
1109
|
+
}), r.nodes[0].nodes.forEach((e3) => {
|
|
1110
|
+
s.append(e3);
|
|
1111
|
+
}), l.forEach((e3) => {
|
|
1112
|
+
s.append(e3);
|
|
1113
|
+
}), true;
|
|
1114
|
+
}
|
|
1115
|
+
function complexSelectors(s, o2, n2, t) {
|
|
1073
1116
|
return s.flatMap((s2) => {
|
|
1074
1117
|
if (-1 === s2.indexOf(":-csstools-matches") && -1 === s2.toLowerCase().indexOf(":is")) return s2;
|
|
1075
1118
|
const r = e2().astSync(s2);
|
|
@@ -1081,13 +1124,13 @@ function complexSelectors(s, o2, t2, n) {
|
|
|
1081
1124
|
let e3 = s4.value;
|
|
1082
1125
|
if (e3.startsWith("::-csstools-invalid-")) return;
|
|
1083
1126
|
for (; e3.startsWith(":"); ) e3 = e3.slice(1);
|
|
1084
|
-
s4.value = `::-csstools-invalid-${e3}`,
|
|
1127
|
+
s4.value = `::-csstools-invalid-${e3}`, t();
|
|
1085
1128
|
}
|
|
1086
1129
|
}), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
|
|
1087
1130
|
if (1 === s3.nodes[0].nodes.length) return void s3.replaceWith(s3.nodes[0].nodes[0]);
|
|
1088
1131
|
if (!s3.nodes[0].some((e3) => "combinator" === e3.type)) return void s3.replaceWith(...s3.nodes[0].nodes);
|
|
1089
1132
|
}
|
|
1090
|
-
1 !== r.nodes.length || "selector" !== r.nodes[0].type || 1 !== r.nodes[0].nodes.length || r.nodes[0].nodes[0] !== s3 ? childAdjacentChild(s3.parent) || isInCompoundWithOneOtherElement(s3.parent) || isPseudoInFirstCompound(s3.parent) || ("warning" === o2.onComplexSelector &&
|
|
1133
|
+
1 !== r.nodes.length || "selector" !== r.nodes[0].type || 1 !== r.nodes[0].nodes.length || r.nodes[0].nodes[0] !== s3 ? childAdjacentChild(s3.parent) || isInCompoundWithOneOtherElement(s3.parent) || isPseudoInFirstCompound(s3.parent) || samePrecedingElement(s3.parent) || ("warning" === o2.onComplexSelector && n2(), s3.value = ":is") : s3.replaceWith(...s3.nodes[0].nodes);
|
|
1091
1134
|
} else s3.remove();
|
|
1092
1135
|
}), r.walk((e3) => {
|
|
1093
1136
|
"selector" === e3.type && "nodes" in e3 && 1 === e3.nodes.length && "selector" === e3.nodes[0].type && e3.replaceWith(e3.nodes[0]);
|
|
@@ -1096,87 +1139,87 @@ function complexSelectors(s, o2, t2, n) {
|
|
|
1096
1139
|
}), r.toString();
|
|
1097
1140
|
}).filter((e3) => !!e3);
|
|
1098
1141
|
}
|
|
1099
|
-
function splitSelectors(o2,
|
|
1100
|
-
const r = ":not(#" +
|
|
1142
|
+
function splitSelectors(o2, n2, t = 0) {
|
|
1143
|
+
const r = ":not(#" + n2.specificityMatchingName + ")", d = ":not(." + n2.specificityMatchingName + ")", l = ":not(" + n2.specificityMatchingName + ")";
|
|
1101
1144
|
return o2.flatMap((o3) => {
|
|
1102
1145
|
if (-1 === o3.toLowerCase().indexOf(":is")) return o3;
|
|
1103
|
-
let
|
|
1104
|
-
const
|
|
1146
|
+
let i = false;
|
|
1147
|
+
const a = [];
|
|
1105
1148
|
if (e2().astSync(o3).walkPseudos((e3) => {
|
|
1106
1149
|
if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
|
|
1107
1150
|
if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
|
|
1108
|
-
if ("pseudo" === e3.parent?.parent?.type && ":not" === e3.parent?.parent?.value?.toLowerCase()) return void
|
|
1151
|
+
if ("pseudo" === e3.parent?.parent?.type && ":not" === e3.parent?.parent?.value?.toLowerCase()) return void a.push([{ start: e3.parent.parent.sourceIndex, end: e3.parent.parent.sourceIndex + e3.parent.parent.toString().length, option: `:not(${e3.nodes.toString()})` }]);
|
|
1109
1152
|
if ("pseudo" === e3.parent?.parent?.type && ":has" === e3.parent?.parent?.value?.toLowerCase()) return void (e3.value = ":-csstools-matches");
|
|
1110
1153
|
let o4 = e3.parent;
|
|
1111
1154
|
for (; o4; ) {
|
|
1112
|
-
if (o4.value && ":is" === o4.value.toLowerCase() && "pseudo" === o4.type) return void (
|
|
1155
|
+
if (o4.value && ":is" === o4.value.toLowerCase() && "pseudo" === o4.type) return void (i = true);
|
|
1113
1156
|
o4 = o4.parent;
|
|
1114
1157
|
}
|
|
1115
|
-
const
|
|
1158
|
+
const n3 = selectorSpecificity(e3), t2 = e3.sourceIndex, c2 = t2 + e3.toString().length, p = [];
|
|
1116
1159
|
e3.nodes.forEach((e4) => {
|
|
1117
|
-
const o5 = { start:
|
|
1118
|
-
let
|
|
1119
|
-
const u = Math.max(0,
|
|
1120
|
-
for (let e5 = 0; e5 < u; e5++)
|
|
1121
|
-
for (let e5 = 0; e5 < h; e5++)
|
|
1122
|
-
for (let e5 = 0; e5 < f; e5++)
|
|
1123
|
-
o5.option =
|
|
1124
|
-
}),
|
|
1125
|
-
}), !
|
|
1160
|
+
const o5 = { start: t2, end: c2, option: "" }, i2 = selectorSpecificity(e4);
|
|
1161
|
+
let a2 = e4.toString().trim();
|
|
1162
|
+
const u = Math.max(0, n3.a - i2.a), h = Math.max(0, n3.b - i2.b), f = Math.max(0, n3.c - i2.c);
|
|
1163
|
+
for (let e5 = 0; e5 < u; e5++) a2 += r;
|
|
1164
|
+
for (let e5 = 0; e5 < h; e5++) a2 += d;
|
|
1165
|
+
for (let e5 = 0; e5 < f; e5++) a2 += l;
|
|
1166
|
+
o5.option = a2, p.push(o5);
|
|
1167
|
+
}), a.push(p);
|
|
1168
|
+
}), !a.length) return [o3];
|
|
1126
1169
|
let c = [];
|
|
1127
|
-
return cartesianProduct(...
|
|
1170
|
+
return cartesianProduct(...a).forEach((e3) => {
|
|
1128
1171
|
let s = "";
|
|
1129
|
-
for (let
|
|
1130
|
-
const
|
|
1131
|
-
s += o3.substring(e3[
|
|
1172
|
+
for (let n3 = 0; n3 < e3.length; n3++) {
|
|
1173
|
+
const t2 = e3[n3];
|
|
1174
|
+
s += o3.substring(e3[n3 - 1]?.end || 0, e3[n3].start), s += ":-csstools-matches(" + t2.option + ")", n3 === e3.length - 1 && (s += o3.substring(e3[n3].end));
|
|
1132
1175
|
}
|
|
1133
1176
|
c.push(s);
|
|
1134
|
-
}),
|
|
1177
|
+
}), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
|
|
1135
1178
|
}).filter((e3) => !!e3);
|
|
1136
1179
|
}
|
|
1137
1180
|
function cartesianProduct(...e3) {
|
|
1138
1181
|
const s = [], o2 = e3.length - 1;
|
|
1139
|
-
return function helper(
|
|
1140
|
-
for (let r = 0, d = e3[
|
|
1141
|
-
const d2 =
|
|
1142
|
-
d2.push(e3[
|
|
1182
|
+
return function helper(n2, t) {
|
|
1183
|
+
for (let r = 0, d = e3[t].length; r < d; r++) {
|
|
1184
|
+
const d2 = n2.slice(0);
|
|
1185
|
+
d2.push(e3[t][r]), t === o2 ? s.push(d2) : helper(d2, t + 1);
|
|
1143
1186
|
}
|
|
1144
1187
|
}([], 0), s;
|
|
1145
1188
|
}
|
|
1146
|
-
var
|
|
1189
|
+
var n = /:is\(/i;
|
|
1147
1190
|
var creator = (e3) => {
|
|
1148
1191
|
const s = { specificityMatchingName: "does-not-exist", ...e3 || {} };
|
|
1149
1192
|
return { postcssPlugin: "postcss-is-pseudo-class", prepare() {
|
|
1150
1193
|
const e4 = /* @__PURE__ */ new WeakSet();
|
|
1151
|
-
return { postcssPlugin: "postcss-is-pseudo-class", Rule(o2, { result:
|
|
1194
|
+
return { postcssPlugin: "postcss-is-pseudo-class", Rule(o2, { result: t }) {
|
|
1152
1195
|
if (!o2.selector) return;
|
|
1153
|
-
if (!
|
|
1196
|
+
if (!n.test(o2.selector)) return;
|
|
1154
1197
|
if (e4.has(o2)) return;
|
|
1155
1198
|
let r = false;
|
|
1156
1199
|
const warnOnComplexSelector = () => {
|
|
1157
|
-
"warning" === s.onComplexSelector && (r || (r = true, o2.warn(
|
|
1200
|
+
"warning" === s.onComplexSelector && (r || (r = true, o2.warn(t, `Complex selectors in '${o2.selector}' can not be transformed to an equivalent selector without ':is()'.`)));
|
|
1158
1201
|
};
|
|
1159
1202
|
let d = false;
|
|
1160
1203
|
const warnOnPseudoElements = () => {
|
|
1161
|
-
"warning" === s.onPseudoElement && (d || (d = true, o2.warn(
|
|
1204
|
+
"warning" === s.onPseudoElement && (d || (d = true, o2.warn(t, `Pseudo elements are not allowed in ':is()', unable to transform '${o2.selector}'`)));
|
|
1162
1205
|
};
|
|
1163
1206
|
try {
|
|
1164
|
-
let
|
|
1165
|
-
const
|
|
1207
|
+
let n2 = false;
|
|
1208
|
+
const t2 = [], r2 = complexSelectors(splitSelectors(o2.selectors, { specificityMatchingName: s.specificityMatchingName }), { onComplexSelector: s.onComplexSelector }, warnOnComplexSelector, warnOnPseudoElements);
|
|
1166
1209
|
if (Array.from(new Set(r2)).forEach((s2) => {
|
|
1167
|
-
if (o2.selectors.indexOf(s2) > -1)
|
|
1210
|
+
if (o2.selectors.indexOf(s2) > -1) t2.push(s2);
|
|
1168
1211
|
else {
|
|
1169
|
-
if (alwaysValidSelector(s2)) return
|
|
1170
|
-
e4.add(o2), o2.cloneBefore({ selector: s2 }),
|
|
1212
|
+
if (alwaysValidSelector(s2)) return t2.push(s2), void (n2 = true);
|
|
1213
|
+
e4.add(o2), o2.cloneBefore({ selector: s2 }), n2 = true;
|
|
1171
1214
|
}
|
|
1172
|
-
}),
|
|
1173
|
-
if (!
|
|
1215
|
+
}), t2.length && n2 && (e4.add(o2), o2.cloneBefore({ selectors: t2 })), !s.preserve) {
|
|
1216
|
+
if (!n2) return;
|
|
1174
1217
|
o2.remove();
|
|
1175
1218
|
}
|
|
1176
1219
|
} catch (e5) {
|
|
1177
1220
|
if (!(e5 instanceof Error)) throw e5;
|
|
1178
1221
|
if (e5.message.indexOf("call stack size exceeded") > -1) throw e5;
|
|
1179
|
-
o2.warn(
|
|
1222
|
+
o2.warn(t, `Failed to parse selector "${o2.selector}" with error: ${e5.message}`);
|
|
1180
1223
|
}
|
|
1181
1224
|
} };
|
|
1182
1225
|
} };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/postcss",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "@weapp-tailwindcss/postcss",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@weapp-core/escape": "~4.0.1",
|
|
43
|
-
"postcss": "~8.5.
|
|
44
|
-
"postcss-preset-env": "^10.2.
|
|
43
|
+
"postcss": "~8.5.6",
|
|
44
|
+
"postcss-preset-env": "^10.2.3",
|
|
45
45
|
"postcss-rem-to-responsive-pixel": "~6.0.2",
|
|
46
46
|
"postcss-selector-parser": "~7.1.0",
|
|
47
47
|
"@weapp-tailwindcss/shared": "1.0.2"
|