@weapp-tailwindcss/postcss 1.0.21 → 1.0.22-alpha.0
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/README.md +3 -6
- package/dist/html-transform.js +8 -2
- package/dist/html-transform.mjs +7 -1
- package/dist/index.js +47 -47
- package/dist/index.mjs +47 -47
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
> [!NOTE]
|
|
24
24
|
> 降低开发维护成本,提升开发效率的 `小程序` `tailwindcss` 全方面解决方案
|
|
25
25
|
>
|
|
26
|
-
>
|
|
26
|
+
> `weapp-tailwindcss@4.2.x` 现已支持 `uni-app x` 同时构建 `Web`,`小程序`,`安卓`,`IOS`,`鸿蒙`,详见 [**uni-app x 专题**](https://tw.icebreaker.top/docs/uni-app-x)
|
|
27
27
|
|
|
28
28
|
\[[文档地址](https://tw.icebreaker.top)\] \| \[[备用文档地址](https://ice-tw.netlify.app/)\] \| \[[加入技术交流群](https://tw.icebreaker.top/docs/community/group)\]
|
|
29
29
|
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
- [各个框架的模板](#各个框架的模板)
|
|
36
36
|
- [旧版本迁移指南](#旧版本迁移指南)
|
|
37
37
|
- [配置项参考](#配置项参考)
|
|
38
|
-
- [变更日志](#变更日志)
|
|
39
38
|
- [Contribute](#contribute)
|
|
40
39
|
- [License](#license)
|
|
41
40
|
- [Star History](#star-history)
|
|
@@ -48,9 +47,9 @@
|
|
|
48
47
|
| --------------------------------------------------- | ----------------------------------------------- |
|
|
49
48
|
|  |  |
|
|
50
49
|
|
|
51
|
-
核心插件支持 `webpack`/`vite`/`gulp` 为基底的框架类小程序开发,涵盖了市面上几乎所有的主流的开发框架。
|
|
50
|
+
核心插件支持 `webpack`/`vite`/`rspack`/`rollup`/`rolldown`/`gulp` 为基底的框架类小程序开发,涵盖了市面上几乎所有的主流的开发框架。
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
也支持直接从各个开发者工具中,直接创建的原生小程序应用。
|
|
54
53
|
|
|
55
54
|
这些插件能够自动识别并精确处理所有 `tailwindcss` 的工具类来适配小程序环境。
|
|
56
55
|
|
|
@@ -75,8 +74,6 @@
|
|
|
75
74
|
|
|
76
75
|
## [配置项参考](https://tw.icebreaker.top/docs/api/interfaces/UserDefinedOptions)
|
|
77
76
|
|
|
78
|
-
## [变更日志](./CHANGELOG.md)
|
|
79
|
-
|
|
80
77
|
## Contribute
|
|
81
78
|
|
|
82
79
|
我们邀请你来贡献和帮助改进 `weapp-tailwindcss` 💚💚💚
|
package/dist/html-transform.js
CHANGED
|
@@ -38,10 +38,16 @@ var postcssHtmlTransform = (opts = {}) => {
|
|
|
38
38
|
return {
|
|
39
39
|
postcssPlugin: "postcss-html-transform",
|
|
40
40
|
Rule(rule) {
|
|
41
|
-
|
|
41
|
+
if (typeof walkRules === "function") {
|
|
42
|
+
if (selectorFilter && selectorFilter.test(rule.selector)) {
|
|
43
|
+
walkRules(rule);
|
|
44
|
+
} else {
|
|
45
|
+
walkRules(rule);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
42
48
|
},
|
|
43
49
|
Declaration(decl) {
|
|
44
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
50
|
+
if (_optionalChain([options, 'optionalAccess', _ => _.removeCursorStyle])) {
|
|
45
51
|
if (decl.prop === "cursor") {
|
|
46
52
|
decl.remove();
|
|
47
53
|
}
|
package/dist/html-transform.mjs
CHANGED
|
@@ -38,7 +38,13 @@ var postcssHtmlTransform = (opts = {}) => {
|
|
|
38
38
|
return {
|
|
39
39
|
postcssPlugin: "postcss-html-transform",
|
|
40
40
|
Rule(rule) {
|
|
41
|
-
walkRules
|
|
41
|
+
if (typeof walkRules === "function") {
|
|
42
|
+
if (selectorFilter && selectorFilter.test(rule.selector)) {
|
|
43
|
+
walkRules(rule);
|
|
44
|
+
} else {
|
|
45
|
+
walkRules(rule);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
42
48
|
},
|
|
43
49
|
Declaration(decl) {
|
|
44
50
|
if (options?.removeCursorStyle) {
|
package/dist/index.js
CHANGED
|
@@ -944,12 +944,12 @@ function selectorSpecificity(t, s) {
|
|
|
944
944
|
case ":nth-child":
|
|
945
945
|
case ":nth-last-child":
|
|
946
946
|
if (n2 += 1, t.nodes && t.nodes.length > 0) {
|
|
947
|
-
const i2 = t.nodes[0].nodes.findIndex((e3) => "tag" === e3.type && "of" === e3.value.toLowerCase());
|
|
947
|
+
const i2 = t.nodes[0].nodes.findIndex(((e3) => "tag" === e3.type && "of" === e3.value.toLowerCase()));
|
|
948
948
|
if (i2 > -1) {
|
|
949
949
|
const a = _postcssselectorparser2.default.selector({ nodes: [], value: "" });
|
|
950
|
-
t.nodes[0].nodes.slice(i2 + 1).forEach((e3) => {
|
|
950
|
+
t.nodes[0].nodes.slice(i2 + 1).forEach(((e3) => {
|
|
951
951
|
a.append(e3.clone());
|
|
952
|
-
});
|
|
952
|
+
}));
|
|
953
953
|
const r = [a];
|
|
954
954
|
t.nodes.length > 1 && r.push(...t.nodes.slice(1));
|
|
955
955
|
const l = specificityOfMostSpecificListItem(r, s);
|
|
@@ -959,10 +959,10 @@ function selectorSpecificity(t, s) {
|
|
|
959
959
|
break;
|
|
960
960
|
case ":local":
|
|
961
961
|
case ":global":
|
|
962
|
-
t.nodes && t.nodes.length > 0 && t.nodes.forEach((e3) => {
|
|
962
|
+
t.nodes && t.nodes.length > 0 && t.nodes.forEach(((e3) => {
|
|
963
963
|
const t2 = selectorSpecificity(e3, s);
|
|
964
964
|
c += t2.a, n2 += t2.b, o2 += t2.c;
|
|
965
|
-
});
|
|
965
|
+
}));
|
|
966
966
|
break;
|
|
967
967
|
case ":host":
|
|
968
968
|
case ":host-context":
|
|
@@ -975,18 +975,18 @@ function selectorSpecificity(t, s) {
|
|
|
975
975
|
case ":active-view-transition-type":
|
|
976
976
|
return { a: 0, b: 1, c: 0 };
|
|
977
977
|
}
|
|
978
|
-
else _postcssselectorparser2.default.isContainer(t) && _optionalChain([t, 'access', _38 => _38.nodes, 'optionalAccess', _39 => _39.length]) > 0 && t.nodes.forEach((e3) => {
|
|
978
|
+
else _postcssselectorparser2.default.isContainer(t) && _optionalChain([t, 'access', _38 => _38.nodes, 'optionalAccess', _39 => _39.length]) > 0 && t.nodes.forEach(((e3) => {
|
|
979
979
|
const t2 = selectorSpecificity(e3, s);
|
|
980
980
|
c += t2.a, n2 += t2.b, o2 += t2.c;
|
|
981
|
-
});
|
|
981
|
+
}));
|
|
982
982
|
return { a: c, b: n2, c: o2 };
|
|
983
983
|
}
|
|
984
984
|
function specificityOfMostSpecificListItem(e3, t) {
|
|
985
985
|
let s = { a: 0, b: 0, c: 0 };
|
|
986
|
-
return e3.forEach((e4) => {
|
|
986
|
+
return e3.forEach(((e4) => {
|
|
987
987
|
const i = selectorSpecificity(e4, t);
|
|
988
988
|
compare(i, s) < 0 || (s = i);
|
|
989
|
-
}), s;
|
|
989
|
+
})), s;
|
|
990
990
|
}
|
|
991
991
|
function isPseudoElement(t) {
|
|
992
992
|
return _postcssselectorparser2.default.isPseudoElement(t);
|
|
@@ -994,7 +994,7 @@ function isPseudoElement(t) {
|
|
|
994
994
|
function selectorNodeContainsNothingOrOnlyUniversal(e3) {
|
|
995
995
|
if (!e3) return false;
|
|
996
996
|
if (!e3.nodes) return false;
|
|
997
|
-
const t = e3.nodes.filter((e4) => "comment" !== e4.type);
|
|
997
|
+
const t = e3.nodes.filter(((e4) => "comment" !== e4.type));
|
|
998
998
|
return 0 === t.length || 1 === t.length && "universal" === t[0].type;
|
|
999
999
|
}
|
|
1000
1000
|
|
|
@@ -1002,17 +1002,17 @@ function selectorNodeContainsNothingOrOnlyUniversal(e3) {
|
|
|
1002
1002
|
function alwaysValidSelector(s) {
|
|
1003
1003
|
const o2 = _postcssselectorparser2.default.call(void 0, ).astSync(s);
|
|
1004
1004
|
let n2 = true;
|
|
1005
|
-
return o2.walk((e3) => {
|
|
1005
|
+
return o2.walk(((e3) => {
|
|
1006
1006
|
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())) {
|
|
1007
1007
|
if ("pseudo" === e3.type && 1 === _optionalChain([e3, 'access', _42 => _42.nodes, 'optionalAccess', _43 => _43.length]) && ":not" === e3.value.toLowerCase()) {
|
|
1008
1008
|
let s2 = true;
|
|
1009
|
-
if (e3.nodes[0].walkCombinators(() => {
|
|
1009
|
+
if (e3.nodes[0].walkCombinators((() => {
|
|
1010
1010
|
s2 = false;
|
|
1011
|
-
}), s2) return;
|
|
1011
|
+
})), s2) return;
|
|
1012
1012
|
}
|
|
1013
1013
|
return n2 = false, false;
|
|
1014
1014
|
}
|
|
1015
|
-
}), n2;
|
|
1015
|
+
})), n2;
|
|
1016
1016
|
}
|
|
1017
1017
|
function sortCompoundSelectorsInsideComplexSelector(s) {
|
|
1018
1018
|
if (!s || !s.nodes || 1 === s.nodes.length) return;
|
|
@@ -1023,8 +1023,8 @@ function sortCompoundSelectorsInsideComplexSelector(s) {
|
|
|
1023
1023
|
const t = [];
|
|
1024
1024
|
for (let e3 = 0; e3 < o2.length; e3++) {
|
|
1025
1025
|
const s2 = o2[e3];
|
|
1026
|
-
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));
|
|
1027
|
-
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"));
|
|
1026
|
+
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)));
|
|
1027
|
+
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"));
|
|
1028
1028
|
for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() : t.push(s2[e4]);
|
|
1029
1029
|
}
|
|
1030
1030
|
s.removeAll();
|
|
@@ -1075,15 +1075,15 @@ function isPseudoInFirstCompound(s) {
|
|
|
1075
1075
|
const n2 = s.nodes[o2];
|
|
1076
1076
|
if (!n2 || !_postcssselectorparser2.default.isPseudoClass(n2)) return false;
|
|
1077
1077
|
const t = s.nodes.slice(0, o2), r = s.nodes.slice(o2 + 1);
|
|
1078
|
-
return t.forEach((e3) => {
|
|
1078
|
+
return t.forEach(((e3) => {
|
|
1079
1079
|
n2.nodes[0].append(e3.clone());
|
|
1080
|
-
}), r.forEach((e3) => {
|
|
1080
|
+
})), r.forEach(((e3) => {
|
|
1081
1081
|
n2.nodes[0].append(e3.clone());
|
|
1082
|
-
}), n2.replaceWith(...n2.nodes), t.forEach((e3) => {
|
|
1082
|
+
})), n2.replaceWith(...n2.nodes), t.forEach(((e3) => {
|
|
1083
1083
|
e3.remove();
|
|
1084
|
-
}), r.forEach((e3) => {
|
|
1084
|
+
})), r.forEach(((e3) => {
|
|
1085
1085
|
e3.remove();
|
|
1086
|
-
}), true;
|
|
1086
|
+
})), true;
|
|
1087
1087
|
}
|
|
1088
1088
|
function samePrecedingElement(s) {
|
|
1089
1089
|
if (!s || !s.nodes) return false;
|
|
@@ -1109,50 +1109,50 @@ function samePrecedingElement(s) {
|
|
|
1109
1109
|
const r = s.nodes[n2];
|
|
1110
1110
|
if (!r || !_postcssselectorparser2.default.isPseudoClass(r)) return false;
|
|
1111
1111
|
const d = s.nodes.slice(0, o2), l = s.nodes.slice(n2 + 1);
|
|
1112
|
-
return s.each((e3) => {
|
|
1112
|
+
return s.each(((e3) => {
|
|
1113
1113
|
e3.remove();
|
|
1114
|
-
}), d.forEach((e3) => {
|
|
1114
|
+
})), d.forEach(((e3) => {
|
|
1115
1115
|
s.append(e3);
|
|
1116
|
-
}), r.nodes[0].nodes.forEach((e3) => {
|
|
1116
|
+
})), r.nodes[0].nodes.forEach(((e3) => {
|
|
1117
1117
|
s.append(e3);
|
|
1118
|
-
}), l.forEach((e3) => {
|
|
1118
|
+
})), l.forEach(((e3) => {
|
|
1119
1119
|
s.append(e3);
|
|
1120
|
-
}), true;
|
|
1120
|
+
})), true;
|
|
1121
1121
|
}
|
|
1122
1122
|
function complexSelectors(s, o2, n2, t) {
|
|
1123
|
-
return s.flatMap((s2) => {
|
|
1123
|
+
return s.flatMap(((s2) => {
|
|
1124
1124
|
if (-1 === s2.indexOf(":-csstools-matches") && -1 === s2.toLowerCase().indexOf(":is")) return s2;
|
|
1125
1125
|
const r = _postcssselectorparser2.default.call(void 0, ).astSync(s2);
|
|
1126
|
-
return r.walkPseudos((s3) => {
|
|
1126
|
+
return r.walkPseudos(((s3) => {
|
|
1127
1127
|
if (":is" === s3.value.toLowerCase() && s3.nodes && s3.nodes.length && "selector" === s3.nodes[0].type && 0 === s3.nodes[0].nodes.length) return s3.value = ":not", void s3.nodes[0].append(_postcssselectorparser2.default.universal());
|
|
1128
1128
|
if (":-csstools-matches" === s3.value) if (!s3.nodes || s3.nodes.length) {
|
|
1129
|
-
if (s3.walkPseudos((s4) => {
|
|
1129
|
+
if (s3.walkPseudos(((s4) => {
|
|
1130
1130
|
if (_postcssselectorparser2.default.isPseudoElement(s4)) {
|
|
1131
1131
|
let e3 = s4.value;
|
|
1132
1132
|
if (e3.startsWith("::-csstools-invalid-")) return;
|
|
1133
1133
|
for (; e3.startsWith(":"); ) e3 = e3.slice(1);
|
|
1134
1134
|
s4.value = `::-csstools-invalid-${e3}`, t();
|
|
1135
1135
|
}
|
|
1136
|
-
}), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
|
|
1136
|
+
})), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
|
|
1137
1137
|
if (1 === s3.nodes[0].nodes.length) return void s3.replaceWith(s3.nodes[0].nodes[0]);
|
|
1138
|
-
if (!s3.nodes[0].some((e3) => "combinator" === e3.type)) return void s3.replaceWith(...s3.nodes[0].nodes);
|
|
1138
|
+
if (!s3.nodes[0].some(((e3) => "combinator" === e3.type))) return void s3.replaceWith(...s3.nodes[0].nodes);
|
|
1139
1139
|
}
|
|
1140
1140
|
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);
|
|
1141
1141
|
} else s3.remove();
|
|
1142
|
-
}), r.walk((e3) => {
|
|
1142
|
+
})), r.walk(((e3) => {
|
|
1143
1143
|
"selector" === e3.type && "nodes" in e3 && 1 === e3.nodes.length && "selector" === e3.nodes[0].type && e3.replaceWith(e3.nodes[0]);
|
|
1144
|
-
}), r.walk((e3) => {
|
|
1144
|
+
})), r.walk(((e3) => {
|
|
1145
1145
|
"nodes" in e3 && sortCompoundSelectorsInsideComplexSelector(e3);
|
|
1146
|
-
}), r.toString();
|
|
1147
|
-
}).filter((e3) => !!e3);
|
|
1146
|
+
})), r.toString();
|
|
1147
|
+
})).filter(((e3) => !!e3));
|
|
1148
1148
|
}
|
|
1149
1149
|
function splitSelectors(o2, n2, t = 0) {
|
|
1150
1150
|
const r = ":not(#" + n2.specificityMatchingName + ")", d = ":not(." + n2.specificityMatchingName + ")", l = ":not(" + n2.specificityMatchingName + ")";
|
|
1151
|
-
return o2.flatMap((o3) => {
|
|
1151
|
+
return o2.flatMap(((o3) => {
|
|
1152
1152
|
if (-1 === o3.toLowerCase().indexOf(":is")) return o3;
|
|
1153
1153
|
let i = false;
|
|
1154
1154
|
const a = [];
|
|
1155
|
-
if (_postcssselectorparser2.default.call(void 0, ).astSync(o3).walkPseudos((e3) => {
|
|
1155
|
+
if (_postcssselectorparser2.default.call(void 0, ).astSync(o3).walkPseudos(((e3) => {
|
|
1156
1156
|
if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
|
|
1157
1157
|
if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
|
|
1158
1158
|
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()})` }]);
|
|
@@ -1163,7 +1163,7 @@ function splitSelectors(o2, n2, t = 0) {
|
|
|
1163
1163
|
o4 = o4.parent;
|
|
1164
1164
|
}
|
|
1165
1165
|
const n3 = selectorSpecificity(e3), t2 = e3.sourceIndex, c2 = t2 + e3.toString().length, p = [];
|
|
1166
|
-
e3.nodes.forEach((e4) => {
|
|
1166
|
+
e3.nodes.forEach(((e4) => {
|
|
1167
1167
|
const o5 = { start: t2, end: c2, option: "" }, i2 = selectorSpecificity(e4);
|
|
1168
1168
|
let a2 = e4.toString().trim();
|
|
1169
1169
|
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);
|
|
@@ -1171,27 +1171,27 @@ function splitSelectors(o2, n2, t = 0) {
|
|
|
1171
1171
|
for (let e5 = 0; e5 < h; e5++) a2 += d;
|
|
1172
1172
|
for (let e5 = 0; e5 < f; e5++) a2 += l;
|
|
1173
1173
|
o5.option = a2, p.push(o5);
|
|
1174
|
-
}), a.push(p);
|
|
1175
|
-
}), !a.length) return [o3];
|
|
1174
|
+
})), a.push(p);
|
|
1175
|
+
})), !a.length) return [o3];
|
|
1176
1176
|
let c = [];
|
|
1177
|
-
return cartesianProduct(...a).forEach((e3) => {
|
|
1177
|
+
return cartesianProduct(...a).forEach(((e3) => {
|
|
1178
1178
|
let s = "";
|
|
1179
1179
|
for (let n3 = 0; n3 < e3.length; n3++) {
|
|
1180
1180
|
const t2 = e3[n3];
|
|
1181
1181
|
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));
|
|
1182
1182
|
}
|
|
1183
1183
|
c.push(s);
|
|
1184
|
-
}), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
|
|
1185
|
-
}).filter((e3) => !!e3);
|
|
1184
|
+
})), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
|
|
1185
|
+
})).filter(((e3) => !!e3));
|
|
1186
1186
|
}
|
|
1187
1187
|
function cartesianProduct(...e3) {
|
|
1188
1188
|
const s = [], o2 = e3.length - 1;
|
|
1189
|
-
return function helper(n2, t) {
|
|
1189
|
+
return (function helper(n2, t) {
|
|
1190
1190
|
for (let r = 0, d = e3[t].length; r < d; r++) {
|
|
1191
1191
|
const d2 = n2.slice(0);
|
|
1192
1192
|
d2.push(e3[t][r]), t === o2 ? s.push(d2) : helper(d2, t + 1);
|
|
1193
1193
|
}
|
|
1194
|
-
}([], 0), s;
|
|
1194
|
+
})([], 0), s;
|
|
1195
1195
|
}
|
|
1196
1196
|
var n = /:is\(/i;
|
|
1197
1197
|
var creator = (e3) => {
|
|
@@ -1213,13 +1213,13 @@ var creator = (e3) => {
|
|
|
1213
1213
|
try {
|
|
1214
1214
|
let n2 = false;
|
|
1215
1215
|
const t2 = [], r2 = complexSelectors(splitSelectors(o2.selectors, { specificityMatchingName: s.specificityMatchingName }), { onComplexSelector: s.onComplexSelector }, warnOnComplexSelector, warnOnPseudoElements);
|
|
1216
|
-
if (Array.from(new Set(r2)).forEach((s2) => {
|
|
1216
|
+
if (Array.from(new Set(r2)).forEach(((s2) => {
|
|
1217
1217
|
if (o2.selectors.indexOf(s2) > -1) t2.push(s2);
|
|
1218
1218
|
else {
|
|
1219
1219
|
if (alwaysValidSelector(s2)) return t2.push(s2), void (n2 = true);
|
|
1220
1220
|
e4.add(o2), o2.cloneBefore({ selector: s2 }), n2 = true;
|
|
1221
1221
|
}
|
|
1222
|
-
}), t2.length && n2 && (e4.add(o2), o2.cloneBefore({ selectors: t2 })), !s.preserve) {
|
|
1222
|
+
})), t2.length && n2 && (e4.add(o2), o2.cloneBefore({ selectors: t2 })), !s.preserve) {
|
|
1223
1223
|
if (!n2) return;
|
|
1224
1224
|
o2.remove();
|
|
1225
1225
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -944,12 +944,12 @@ function selectorSpecificity(t, s) {
|
|
|
944
944
|
case ":nth-child":
|
|
945
945
|
case ":nth-last-child":
|
|
946
946
|
if (n2 += 1, t.nodes && t.nodes.length > 0) {
|
|
947
|
-
const i2 = t.nodes[0].nodes.findIndex((e3) => "tag" === e3.type && "of" === e3.value.toLowerCase());
|
|
947
|
+
const i2 = t.nodes[0].nodes.findIndex(((e3) => "tag" === e3.type && "of" === e3.value.toLowerCase()));
|
|
948
948
|
if (i2 > -1) {
|
|
949
949
|
const a = e.selector({ nodes: [], value: "" });
|
|
950
|
-
t.nodes[0].nodes.slice(i2 + 1).forEach((e3) => {
|
|
950
|
+
t.nodes[0].nodes.slice(i2 + 1).forEach(((e3) => {
|
|
951
951
|
a.append(e3.clone());
|
|
952
|
-
});
|
|
952
|
+
}));
|
|
953
953
|
const r = [a];
|
|
954
954
|
t.nodes.length > 1 && r.push(...t.nodes.slice(1));
|
|
955
955
|
const l = specificityOfMostSpecificListItem(r, s);
|
|
@@ -959,10 +959,10 @@ function selectorSpecificity(t, s) {
|
|
|
959
959
|
break;
|
|
960
960
|
case ":local":
|
|
961
961
|
case ":global":
|
|
962
|
-
t.nodes && t.nodes.length > 0 && t.nodes.forEach((e3) => {
|
|
962
|
+
t.nodes && t.nodes.length > 0 && t.nodes.forEach(((e3) => {
|
|
963
963
|
const t2 = selectorSpecificity(e3, s);
|
|
964
964
|
c += t2.a, n2 += t2.b, o2 += t2.c;
|
|
965
|
-
});
|
|
965
|
+
}));
|
|
966
966
|
break;
|
|
967
967
|
case ":host":
|
|
968
968
|
case ":host-context":
|
|
@@ -975,18 +975,18 @@ function selectorSpecificity(t, s) {
|
|
|
975
975
|
case ":active-view-transition-type":
|
|
976
976
|
return { a: 0, b: 1, c: 0 };
|
|
977
977
|
}
|
|
978
|
-
else e.isContainer(t) && t.nodes?.length > 0 && t.nodes.forEach((e3) => {
|
|
978
|
+
else e.isContainer(t) && t.nodes?.length > 0 && t.nodes.forEach(((e3) => {
|
|
979
979
|
const t2 = selectorSpecificity(e3, s);
|
|
980
980
|
c += t2.a, n2 += t2.b, o2 += t2.c;
|
|
981
|
-
});
|
|
981
|
+
}));
|
|
982
982
|
return { a: c, b: n2, c: o2 };
|
|
983
983
|
}
|
|
984
984
|
function specificityOfMostSpecificListItem(e3, t) {
|
|
985
985
|
let s = { a: 0, b: 0, c: 0 };
|
|
986
|
-
return e3.forEach((e4) => {
|
|
986
|
+
return e3.forEach(((e4) => {
|
|
987
987
|
const i = selectorSpecificity(e4, t);
|
|
988
988
|
compare(i, s) < 0 || (s = i);
|
|
989
|
-
}), s;
|
|
989
|
+
})), s;
|
|
990
990
|
}
|
|
991
991
|
function isPseudoElement(t) {
|
|
992
992
|
return e.isPseudoElement(t);
|
|
@@ -994,7 +994,7 @@ function isPseudoElement(t) {
|
|
|
994
994
|
function selectorNodeContainsNothingOrOnlyUniversal(e3) {
|
|
995
995
|
if (!e3) return false;
|
|
996
996
|
if (!e3.nodes) return false;
|
|
997
|
-
const t = e3.nodes.filter((e4) => "comment" !== e4.type);
|
|
997
|
+
const t = e3.nodes.filter(((e4) => "comment" !== e4.type));
|
|
998
998
|
return 0 === t.length || 1 === t.length && "universal" === t[0].type;
|
|
999
999
|
}
|
|
1000
1000
|
|
|
@@ -1002,17 +1002,17 @@ function selectorNodeContainsNothingOrOnlyUniversal(e3) {
|
|
|
1002
1002
|
function alwaysValidSelector(s) {
|
|
1003
1003
|
const o2 = e2().astSync(s);
|
|
1004
1004
|
let n2 = true;
|
|
1005
|
-
return o2.walk((e3) => {
|
|
1005
|
+
return o2.walk(((e3) => {
|
|
1006
1006
|
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())) {
|
|
1007
1007
|
if ("pseudo" === e3.type && 1 === e3.nodes?.length && ":not" === e3.value.toLowerCase()) {
|
|
1008
1008
|
let s2 = true;
|
|
1009
|
-
if (e3.nodes[0].walkCombinators(() => {
|
|
1009
|
+
if (e3.nodes[0].walkCombinators((() => {
|
|
1010
1010
|
s2 = false;
|
|
1011
|
-
}), s2) return;
|
|
1011
|
+
})), s2) return;
|
|
1012
1012
|
}
|
|
1013
1013
|
return n2 = false, false;
|
|
1014
1014
|
}
|
|
1015
|
-
}), n2;
|
|
1015
|
+
})), n2;
|
|
1016
1016
|
}
|
|
1017
1017
|
function sortCompoundSelectorsInsideComplexSelector(s) {
|
|
1018
1018
|
if (!s || !s.nodes || 1 === s.nodes.length) return;
|
|
@@ -1023,8 +1023,8 @@ function sortCompoundSelectorsInsideComplexSelector(s) {
|
|
|
1023
1023
|
const t = [];
|
|
1024
1024
|
for (let e3 = 0; e3 < o2.length; e3++) {
|
|
1025
1025
|
const s2 = o2[e3];
|
|
1026
|
-
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));
|
|
1027
|
-
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"));
|
|
1026
|
+
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)));
|
|
1027
|
+
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"));
|
|
1028
1028
|
for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() : t.push(s2[e4]);
|
|
1029
1029
|
}
|
|
1030
1030
|
s.removeAll();
|
|
@@ -1075,15 +1075,15 @@ function isPseudoInFirstCompound(s) {
|
|
|
1075
1075
|
const n2 = s.nodes[o2];
|
|
1076
1076
|
if (!n2 || !e2.isPseudoClass(n2)) return false;
|
|
1077
1077
|
const t = s.nodes.slice(0, o2), r = s.nodes.slice(o2 + 1);
|
|
1078
|
-
return t.forEach((e3) => {
|
|
1078
|
+
return t.forEach(((e3) => {
|
|
1079
1079
|
n2.nodes[0].append(e3.clone());
|
|
1080
|
-
}), r.forEach((e3) => {
|
|
1080
|
+
})), r.forEach(((e3) => {
|
|
1081
1081
|
n2.nodes[0].append(e3.clone());
|
|
1082
|
-
}), n2.replaceWith(...n2.nodes), t.forEach((e3) => {
|
|
1082
|
+
})), n2.replaceWith(...n2.nodes), t.forEach(((e3) => {
|
|
1083
1083
|
e3.remove();
|
|
1084
|
-
}), r.forEach((e3) => {
|
|
1084
|
+
})), r.forEach(((e3) => {
|
|
1085
1085
|
e3.remove();
|
|
1086
|
-
}), true;
|
|
1086
|
+
})), true;
|
|
1087
1087
|
}
|
|
1088
1088
|
function samePrecedingElement(s) {
|
|
1089
1089
|
if (!s || !s.nodes) return false;
|
|
@@ -1109,50 +1109,50 @@ function samePrecedingElement(s) {
|
|
|
1109
1109
|
const r = s.nodes[n2];
|
|
1110
1110
|
if (!r || !e2.isPseudoClass(r)) return false;
|
|
1111
1111
|
const d = s.nodes.slice(0, o2), l = s.nodes.slice(n2 + 1);
|
|
1112
|
-
return s.each((e3) => {
|
|
1112
|
+
return s.each(((e3) => {
|
|
1113
1113
|
e3.remove();
|
|
1114
|
-
}), d.forEach((e3) => {
|
|
1114
|
+
})), d.forEach(((e3) => {
|
|
1115
1115
|
s.append(e3);
|
|
1116
|
-
}), r.nodes[0].nodes.forEach((e3) => {
|
|
1116
|
+
})), r.nodes[0].nodes.forEach(((e3) => {
|
|
1117
1117
|
s.append(e3);
|
|
1118
|
-
}), l.forEach((e3) => {
|
|
1118
|
+
})), l.forEach(((e3) => {
|
|
1119
1119
|
s.append(e3);
|
|
1120
|
-
}), true;
|
|
1120
|
+
})), true;
|
|
1121
1121
|
}
|
|
1122
1122
|
function complexSelectors(s, o2, n2, t) {
|
|
1123
|
-
return s.flatMap((s2) => {
|
|
1123
|
+
return s.flatMap(((s2) => {
|
|
1124
1124
|
if (-1 === s2.indexOf(":-csstools-matches") && -1 === s2.toLowerCase().indexOf(":is")) return s2;
|
|
1125
1125
|
const r = e2().astSync(s2);
|
|
1126
|
-
return r.walkPseudos((s3) => {
|
|
1126
|
+
return r.walkPseudos(((s3) => {
|
|
1127
1127
|
if (":is" === s3.value.toLowerCase() && s3.nodes && s3.nodes.length && "selector" === s3.nodes[0].type && 0 === s3.nodes[0].nodes.length) return s3.value = ":not", void s3.nodes[0].append(e2.universal());
|
|
1128
1128
|
if (":-csstools-matches" === s3.value) if (!s3.nodes || s3.nodes.length) {
|
|
1129
|
-
if (s3.walkPseudos((s4) => {
|
|
1129
|
+
if (s3.walkPseudos(((s4) => {
|
|
1130
1130
|
if (e2.isPseudoElement(s4)) {
|
|
1131
1131
|
let e3 = s4.value;
|
|
1132
1132
|
if (e3.startsWith("::-csstools-invalid-")) return;
|
|
1133
1133
|
for (; e3.startsWith(":"); ) e3 = e3.slice(1);
|
|
1134
1134
|
s4.value = `::-csstools-invalid-${e3}`, t();
|
|
1135
1135
|
}
|
|
1136
|
-
}), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
|
|
1136
|
+
})), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
|
|
1137
1137
|
if (1 === s3.nodes[0].nodes.length) return void s3.replaceWith(s3.nodes[0].nodes[0]);
|
|
1138
|
-
if (!s3.nodes[0].some((e3) => "combinator" === e3.type)) return void s3.replaceWith(...s3.nodes[0].nodes);
|
|
1138
|
+
if (!s3.nodes[0].some(((e3) => "combinator" === e3.type))) return void s3.replaceWith(...s3.nodes[0].nodes);
|
|
1139
1139
|
}
|
|
1140
1140
|
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);
|
|
1141
1141
|
} else s3.remove();
|
|
1142
|
-
}), r.walk((e3) => {
|
|
1142
|
+
})), r.walk(((e3) => {
|
|
1143
1143
|
"selector" === e3.type && "nodes" in e3 && 1 === e3.nodes.length && "selector" === e3.nodes[0].type && e3.replaceWith(e3.nodes[0]);
|
|
1144
|
-
}), r.walk((e3) => {
|
|
1144
|
+
})), r.walk(((e3) => {
|
|
1145
1145
|
"nodes" in e3 && sortCompoundSelectorsInsideComplexSelector(e3);
|
|
1146
|
-
}), r.toString();
|
|
1147
|
-
}).filter((e3) => !!e3);
|
|
1146
|
+
})), r.toString();
|
|
1147
|
+
})).filter(((e3) => !!e3));
|
|
1148
1148
|
}
|
|
1149
1149
|
function splitSelectors(o2, n2, t = 0) {
|
|
1150
1150
|
const r = ":not(#" + n2.specificityMatchingName + ")", d = ":not(." + n2.specificityMatchingName + ")", l = ":not(" + n2.specificityMatchingName + ")";
|
|
1151
|
-
return o2.flatMap((o3) => {
|
|
1151
|
+
return o2.flatMap(((o3) => {
|
|
1152
1152
|
if (-1 === o3.toLowerCase().indexOf(":is")) return o3;
|
|
1153
1153
|
let i = false;
|
|
1154
1154
|
const a = [];
|
|
1155
|
-
if (e2().astSync(o3).walkPseudos((e3) => {
|
|
1155
|
+
if (e2().astSync(o3).walkPseudos(((e3) => {
|
|
1156
1156
|
if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
|
|
1157
1157
|
if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
|
|
1158
1158
|
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()})` }]);
|
|
@@ -1163,7 +1163,7 @@ function splitSelectors(o2, n2, t = 0) {
|
|
|
1163
1163
|
o4 = o4.parent;
|
|
1164
1164
|
}
|
|
1165
1165
|
const n3 = selectorSpecificity(e3), t2 = e3.sourceIndex, c2 = t2 + e3.toString().length, p = [];
|
|
1166
|
-
e3.nodes.forEach((e4) => {
|
|
1166
|
+
e3.nodes.forEach(((e4) => {
|
|
1167
1167
|
const o5 = { start: t2, end: c2, option: "" }, i2 = selectorSpecificity(e4);
|
|
1168
1168
|
let a2 = e4.toString().trim();
|
|
1169
1169
|
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);
|
|
@@ -1171,27 +1171,27 @@ function splitSelectors(o2, n2, t = 0) {
|
|
|
1171
1171
|
for (let e5 = 0; e5 < h; e5++) a2 += d;
|
|
1172
1172
|
for (let e5 = 0; e5 < f; e5++) a2 += l;
|
|
1173
1173
|
o5.option = a2, p.push(o5);
|
|
1174
|
-
}), a.push(p);
|
|
1175
|
-
}), !a.length) return [o3];
|
|
1174
|
+
})), a.push(p);
|
|
1175
|
+
})), !a.length) return [o3];
|
|
1176
1176
|
let c = [];
|
|
1177
|
-
return cartesianProduct(...a).forEach((e3) => {
|
|
1177
|
+
return cartesianProduct(...a).forEach(((e3) => {
|
|
1178
1178
|
let s = "";
|
|
1179
1179
|
for (let n3 = 0; n3 < e3.length; n3++) {
|
|
1180
1180
|
const t2 = e3[n3];
|
|
1181
1181
|
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));
|
|
1182
1182
|
}
|
|
1183
1183
|
c.push(s);
|
|
1184
|
-
}), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
|
|
1185
|
-
}).filter((e3) => !!e3);
|
|
1184
|
+
})), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
|
|
1185
|
+
})).filter(((e3) => !!e3));
|
|
1186
1186
|
}
|
|
1187
1187
|
function cartesianProduct(...e3) {
|
|
1188
1188
|
const s = [], o2 = e3.length - 1;
|
|
1189
|
-
return function helper(n2, t) {
|
|
1189
|
+
return (function helper(n2, t) {
|
|
1190
1190
|
for (let r = 0, d = e3[t].length; r < d; r++) {
|
|
1191
1191
|
const d2 = n2.slice(0);
|
|
1192
1192
|
d2.push(e3[t][r]), t === o2 ? s.push(d2) : helper(d2, t + 1);
|
|
1193
1193
|
}
|
|
1194
|
-
}([], 0), s;
|
|
1194
|
+
})([], 0), s;
|
|
1195
1195
|
}
|
|
1196
1196
|
var n = /:is\(/i;
|
|
1197
1197
|
var creator = (e3) => {
|
|
@@ -1213,13 +1213,13 @@ var creator = (e3) => {
|
|
|
1213
1213
|
try {
|
|
1214
1214
|
let n2 = false;
|
|
1215
1215
|
const t2 = [], r2 = complexSelectors(splitSelectors(o2.selectors, { specificityMatchingName: s.specificityMatchingName }), { onComplexSelector: s.onComplexSelector }, warnOnComplexSelector, warnOnPseudoElements);
|
|
1216
|
-
if (Array.from(new Set(r2)).forEach((s2) => {
|
|
1216
|
+
if (Array.from(new Set(r2)).forEach(((s2) => {
|
|
1217
1217
|
if (o2.selectors.indexOf(s2) > -1) t2.push(s2);
|
|
1218
1218
|
else {
|
|
1219
1219
|
if (alwaysValidSelector(s2)) return t2.push(s2), void (n2 = true);
|
|
1220
1220
|
e4.add(o2), o2.cloneBefore({ selector: s2 }), n2 = true;
|
|
1221
1221
|
}
|
|
1222
|
-
}), t2.length && n2 && (e4.add(o2), o2.cloneBefore({ selectors: t2 })), !s.preserve) {
|
|
1222
|
+
})), t2.length && n2 && (e4.add(o2), o2.cloneBefore({ selectors: t2 })), !s.preserve) {
|
|
1223
1223
|
if (!n2) return;
|
|
1224
1224
|
o2.remove();
|
|
1225
1225
|
}
|