@weapp-tailwindcss/postcss 1.0.20 → 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 CHANGED
@@ -23,7 +23,7 @@
23
23
  > [!NOTE]
24
24
  > 降低开发维护成本,提升开发效率的 `小程序` `tailwindcss` 全方面解决方案
25
25
  >
26
- > 小程序原生工具链 `weapp-vite` 已经发布,使用它改善你的原生小程序开发体验吧,更多详见 [官方文档](https://vite.icebreaker.top/)
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
  | ![wepback+vite+gulp](./assets/weapp-tw-plugins.png) | ![frameworks](./assets/weapp-tw-frameworks.png) |
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` 💚💚💚
@@ -38,10 +38,16 @@ var postcssHtmlTransform = (opts = {}) => {
38
38
  return {
39
39
  postcssPlugin: "postcss-html-transform",
40
40
  Rule(rule) {
41
- _optionalChain([walkRules, 'optionalCall', _ => _(rule)]);
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', _2 => _2.removeCursorStyle])) {
50
+ if (_optionalChain([options, 'optionalAccess', _ => _.removeCursorStyle])) {
45
51
  if (decl.prop === "cursor") {
46
52
  decl.remove();
47
53
  }
@@ -38,7 +38,13 @@ var postcssHtmlTransform = (opts = {}) => {
38
38
  return {
39
39
  postcssPlugin: "postcss-html-transform",
40
40
  Rule(rule) {
41
- walkRules?.(rule);
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
@@ -191,9 +191,7 @@ function createRuleTransform(rule, options) {
191
191
  }
192
192
  }
193
193
  if (uniAppX) {
194
- if (selector.value === "::before" || selector.value === "::after" || selector.value === "::backdrop" || selector.value === "::file-selector-button") {
195
- selector.remove();
196
- }
194
+ selector.remove();
197
195
  }
198
196
  } else if (selector.type === "combinator") {
199
197
  if (selector.value === ">") {
@@ -216,6 +214,14 @@ function createRuleTransform(rule, options) {
216
214
  }
217
215
  }
218
216
  }
217
+ } else if (selector.type === "tag") {
218
+ if (uniAppX) {
219
+ selector.remove();
220
+ }
221
+ } else if (selector.type === "attribute") {
222
+ if (uniAppX) {
223
+ selector.remove();
224
+ }
219
225
  }
220
226
  });
221
227
  selectors.walk((selector) => {
@@ -938,12 +944,12 @@ function selectorSpecificity(t, s) {
938
944
  case ":nth-child":
939
945
  case ":nth-last-child":
940
946
  if (n2 += 1, t.nodes && t.nodes.length > 0) {
941
- 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()));
942
948
  if (i2 > -1) {
943
949
  const a = _postcssselectorparser2.default.selector({ nodes: [], value: "" });
944
- t.nodes[0].nodes.slice(i2 + 1).forEach((e3) => {
950
+ t.nodes[0].nodes.slice(i2 + 1).forEach(((e3) => {
945
951
  a.append(e3.clone());
946
- });
952
+ }));
947
953
  const r = [a];
948
954
  t.nodes.length > 1 && r.push(...t.nodes.slice(1));
949
955
  const l = specificityOfMostSpecificListItem(r, s);
@@ -953,10 +959,10 @@ function selectorSpecificity(t, s) {
953
959
  break;
954
960
  case ":local":
955
961
  case ":global":
956
- t.nodes && t.nodes.length > 0 && t.nodes.forEach((e3) => {
962
+ t.nodes && t.nodes.length > 0 && t.nodes.forEach(((e3) => {
957
963
  const t2 = selectorSpecificity(e3, s);
958
964
  c += t2.a, n2 += t2.b, o2 += t2.c;
959
- });
965
+ }));
960
966
  break;
961
967
  case ":host":
962
968
  case ":host-context":
@@ -969,18 +975,18 @@ function selectorSpecificity(t, s) {
969
975
  case ":active-view-transition-type":
970
976
  return { a: 0, b: 1, c: 0 };
971
977
  }
972
- 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) => {
973
979
  const t2 = selectorSpecificity(e3, s);
974
980
  c += t2.a, n2 += t2.b, o2 += t2.c;
975
- });
981
+ }));
976
982
  return { a: c, b: n2, c: o2 };
977
983
  }
978
984
  function specificityOfMostSpecificListItem(e3, t) {
979
985
  let s = { a: 0, b: 0, c: 0 };
980
- return e3.forEach((e4) => {
986
+ return e3.forEach(((e4) => {
981
987
  const i = selectorSpecificity(e4, t);
982
988
  compare(i, s) < 0 || (s = i);
983
- }), s;
989
+ })), s;
984
990
  }
985
991
  function isPseudoElement(t) {
986
992
  return _postcssselectorparser2.default.isPseudoElement(t);
@@ -988,7 +994,7 @@ function isPseudoElement(t) {
988
994
  function selectorNodeContainsNothingOrOnlyUniversal(e3) {
989
995
  if (!e3) return false;
990
996
  if (!e3.nodes) return false;
991
- const t = e3.nodes.filter((e4) => "comment" !== e4.type);
997
+ const t = e3.nodes.filter(((e4) => "comment" !== e4.type));
992
998
  return 0 === t.length || 1 === t.length && "universal" === t[0].type;
993
999
  }
994
1000
 
@@ -996,17 +1002,17 @@ function selectorNodeContainsNothingOrOnlyUniversal(e3) {
996
1002
  function alwaysValidSelector(s) {
997
1003
  const o2 = _postcssselectorparser2.default.call(void 0, ).astSync(s);
998
1004
  let n2 = true;
999
- return o2.walk((e3) => {
1005
+ return o2.walk(((e3) => {
1000
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())) {
1001
1007
  if ("pseudo" === e3.type && 1 === _optionalChain([e3, 'access', _42 => _42.nodes, 'optionalAccess', _43 => _43.length]) && ":not" === e3.value.toLowerCase()) {
1002
1008
  let s2 = true;
1003
- if (e3.nodes[0].walkCombinators(() => {
1009
+ if (e3.nodes[0].walkCombinators((() => {
1004
1010
  s2 = false;
1005
- }), s2) return;
1011
+ })), s2) return;
1006
1012
  }
1007
1013
  return n2 = false, false;
1008
1014
  }
1009
- }), n2;
1015
+ })), n2;
1010
1016
  }
1011
1017
  function sortCompoundSelectorsInsideComplexSelector(s) {
1012
1018
  if (!s || !s.nodes || 1 === s.nodes.length) return;
@@ -1017,8 +1023,8 @@ function sortCompoundSelectorsInsideComplexSelector(s) {
1017
1023
  const t = [];
1018
1024
  for (let e3 = 0; e3 < o2.length; e3++) {
1019
1025
  const s2 = o2[e3];
1020
- 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));
1021
- 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"));
1022
1028
  for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() : t.push(s2[e4]);
1023
1029
  }
1024
1030
  s.removeAll();
@@ -1069,15 +1075,15 @@ function isPseudoInFirstCompound(s) {
1069
1075
  const n2 = s.nodes[o2];
1070
1076
  if (!n2 || !_postcssselectorparser2.default.isPseudoClass(n2)) return false;
1071
1077
  const t = s.nodes.slice(0, o2), r = s.nodes.slice(o2 + 1);
1072
- return t.forEach((e3) => {
1078
+ return t.forEach(((e3) => {
1073
1079
  n2.nodes[0].append(e3.clone());
1074
- }), r.forEach((e3) => {
1080
+ })), r.forEach(((e3) => {
1075
1081
  n2.nodes[0].append(e3.clone());
1076
- }), n2.replaceWith(...n2.nodes), t.forEach((e3) => {
1082
+ })), n2.replaceWith(...n2.nodes), t.forEach(((e3) => {
1077
1083
  e3.remove();
1078
- }), r.forEach((e3) => {
1084
+ })), r.forEach(((e3) => {
1079
1085
  e3.remove();
1080
- }), true;
1086
+ })), true;
1081
1087
  }
1082
1088
  function samePrecedingElement(s) {
1083
1089
  if (!s || !s.nodes) return false;
@@ -1103,50 +1109,50 @@ function samePrecedingElement(s) {
1103
1109
  const r = s.nodes[n2];
1104
1110
  if (!r || !_postcssselectorparser2.default.isPseudoClass(r)) return false;
1105
1111
  const d = s.nodes.slice(0, o2), l = s.nodes.slice(n2 + 1);
1106
- return s.each((e3) => {
1112
+ return s.each(((e3) => {
1107
1113
  e3.remove();
1108
- }), d.forEach((e3) => {
1114
+ })), d.forEach(((e3) => {
1109
1115
  s.append(e3);
1110
- }), r.nodes[0].nodes.forEach((e3) => {
1116
+ })), r.nodes[0].nodes.forEach(((e3) => {
1111
1117
  s.append(e3);
1112
- }), l.forEach((e3) => {
1118
+ })), l.forEach(((e3) => {
1113
1119
  s.append(e3);
1114
- }), true;
1120
+ })), true;
1115
1121
  }
1116
1122
  function complexSelectors(s, o2, n2, t) {
1117
- return s.flatMap((s2) => {
1123
+ return s.flatMap(((s2) => {
1118
1124
  if (-1 === s2.indexOf(":-csstools-matches") && -1 === s2.toLowerCase().indexOf(":is")) return s2;
1119
1125
  const r = _postcssselectorparser2.default.call(void 0, ).astSync(s2);
1120
- return r.walkPseudos((s3) => {
1126
+ return r.walkPseudos(((s3) => {
1121
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());
1122
1128
  if (":-csstools-matches" === s3.value) if (!s3.nodes || s3.nodes.length) {
1123
- if (s3.walkPseudos((s4) => {
1129
+ if (s3.walkPseudos(((s4) => {
1124
1130
  if (_postcssselectorparser2.default.isPseudoElement(s4)) {
1125
1131
  let e3 = s4.value;
1126
1132
  if (e3.startsWith("::-csstools-invalid-")) return;
1127
1133
  for (; e3.startsWith(":"); ) e3 = e3.slice(1);
1128
1134
  s4.value = `::-csstools-invalid-${e3}`, t();
1129
1135
  }
1130
- }), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
1136
+ })), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
1131
1137
  if (1 === s3.nodes[0].nodes.length) return void s3.replaceWith(s3.nodes[0].nodes[0]);
1132
- 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);
1133
1139
  }
1134
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);
1135
1141
  } else s3.remove();
1136
- }), r.walk((e3) => {
1142
+ })), r.walk(((e3) => {
1137
1143
  "selector" === e3.type && "nodes" in e3 && 1 === e3.nodes.length && "selector" === e3.nodes[0].type && e3.replaceWith(e3.nodes[0]);
1138
- }), r.walk((e3) => {
1144
+ })), r.walk(((e3) => {
1139
1145
  "nodes" in e3 && sortCompoundSelectorsInsideComplexSelector(e3);
1140
- }), r.toString();
1141
- }).filter((e3) => !!e3);
1146
+ })), r.toString();
1147
+ })).filter(((e3) => !!e3));
1142
1148
  }
1143
1149
  function splitSelectors(o2, n2, t = 0) {
1144
1150
  const r = ":not(#" + n2.specificityMatchingName + ")", d = ":not(." + n2.specificityMatchingName + ")", l = ":not(" + n2.specificityMatchingName + ")";
1145
- return o2.flatMap((o3) => {
1151
+ return o2.flatMap(((o3) => {
1146
1152
  if (-1 === o3.toLowerCase().indexOf(":is")) return o3;
1147
1153
  let i = false;
1148
1154
  const a = [];
1149
- if (_postcssselectorparser2.default.call(void 0, ).astSync(o3).walkPseudos((e3) => {
1155
+ if (_postcssselectorparser2.default.call(void 0, ).astSync(o3).walkPseudos(((e3) => {
1150
1156
  if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
1151
1157
  if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
1152
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()})` }]);
@@ -1157,7 +1163,7 @@ function splitSelectors(o2, n2, t = 0) {
1157
1163
  o4 = o4.parent;
1158
1164
  }
1159
1165
  const n3 = selectorSpecificity(e3), t2 = e3.sourceIndex, c2 = t2 + e3.toString().length, p = [];
1160
- e3.nodes.forEach((e4) => {
1166
+ e3.nodes.forEach(((e4) => {
1161
1167
  const o5 = { start: t2, end: c2, option: "" }, i2 = selectorSpecificity(e4);
1162
1168
  let a2 = e4.toString().trim();
1163
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);
@@ -1165,27 +1171,27 @@ function splitSelectors(o2, n2, t = 0) {
1165
1171
  for (let e5 = 0; e5 < h; e5++) a2 += d;
1166
1172
  for (let e5 = 0; e5 < f; e5++) a2 += l;
1167
1173
  o5.option = a2, p.push(o5);
1168
- }), a.push(p);
1169
- }), !a.length) return [o3];
1174
+ })), a.push(p);
1175
+ })), !a.length) return [o3];
1170
1176
  let c = [];
1171
- return cartesianProduct(...a).forEach((e3) => {
1177
+ return cartesianProduct(...a).forEach(((e3) => {
1172
1178
  let s = "";
1173
1179
  for (let n3 = 0; n3 < e3.length; n3++) {
1174
1180
  const t2 = e3[n3];
1175
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));
1176
1182
  }
1177
1183
  c.push(s);
1178
- }), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
1179
- }).filter((e3) => !!e3);
1184
+ })), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
1185
+ })).filter(((e3) => !!e3));
1180
1186
  }
1181
1187
  function cartesianProduct(...e3) {
1182
1188
  const s = [], o2 = e3.length - 1;
1183
- return function helper(n2, t) {
1189
+ return (function helper(n2, t) {
1184
1190
  for (let r = 0, d = e3[t].length; r < d; r++) {
1185
1191
  const d2 = n2.slice(0);
1186
1192
  d2.push(e3[t][r]), t === o2 ? s.push(d2) : helper(d2, t + 1);
1187
1193
  }
1188
- }([], 0), s;
1194
+ })([], 0), s;
1189
1195
  }
1190
1196
  var n = /:is\(/i;
1191
1197
  var creator = (e3) => {
@@ -1207,13 +1213,13 @@ var creator = (e3) => {
1207
1213
  try {
1208
1214
  let n2 = false;
1209
1215
  const t2 = [], r2 = complexSelectors(splitSelectors(o2.selectors, { specificityMatchingName: s.specificityMatchingName }), { onComplexSelector: s.onComplexSelector }, warnOnComplexSelector, warnOnPseudoElements);
1210
- if (Array.from(new Set(r2)).forEach((s2) => {
1216
+ if (Array.from(new Set(r2)).forEach(((s2) => {
1211
1217
  if (o2.selectors.indexOf(s2) > -1) t2.push(s2);
1212
1218
  else {
1213
1219
  if (alwaysValidSelector(s2)) return t2.push(s2), void (n2 = true);
1214
1220
  e4.add(o2), o2.cloneBefore({ selector: s2 }), n2 = true;
1215
1221
  }
1216
- }), 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) {
1217
1223
  if (!n2) return;
1218
1224
  o2.remove();
1219
1225
  }
package/dist/index.mjs CHANGED
@@ -191,9 +191,7 @@ function createRuleTransform(rule, options) {
191
191
  }
192
192
  }
193
193
  if (uniAppX) {
194
- if (selector.value === "::before" || selector.value === "::after" || selector.value === "::backdrop" || selector.value === "::file-selector-button") {
195
- selector.remove();
196
- }
194
+ selector.remove();
197
195
  }
198
196
  } else if (selector.type === "combinator") {
199
197
  if (selector.value === ">") {
@@ -216,6 +214,14 @@ function createRuleTransform(rule, options) {
216
214
  }
217
215
  }
218
216
  }
217
+ } else if (selector.type === "tag") {
218
+ if (uniAppX) {
219
+ selector.remove();
220
+ }
221
+ } else if (selector.type === "attribute") {
222
+ if (uniAppX) {
223
+ selector.remove();
224
+ }
219
225
  }
220
226
  });
221
227
  selectors.walk((selector) => {
@@ -938,12 +944,12 @@ function selectorSpecificity(t, s) {
938
944
  case ":nth-child":
939
945
  case ":nth-last-child":
940
946
  if (n2 += 1, t.nodes && t.nodes.length > 0) {
941
- 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()));
942
948
  if (i2 > -1) {
943
949
  const a = e.selector({ nodes: [], value: "" });
944
- t.nodes[0].nodes.slice(i2 + 1).forEach((e3) => {
950
+ t.nodes[0].nodes.slice(i2 + 1).forEach(((e3) => {
945
951
  a.append(e3.clone());
946
- });
952
+ }));
947
953
  const r = [a];
948
954
  t.nodes.length > 1 && r.push(...t.nodes.slice(1));
949
955
  const l = specificityOfMostSpecificListItem(r, s);
@@ -953,10 +959,10 @@ function selectorSpecificity(t, s) {
953
959
  break;
954
960
  case ":local":
955
961
  case ":global":
956
- t.nodes && t.nodes.length > 0 && t.nodes.forEach((e3) => {
962
+ t.nodes && t.nodes.length > 0 && t.nodes.forEach(((e3) => {
957
963
  const t2 = selectorSpecificity(e3, s);
958
964
  c += t2.a, n2 += t2.b, o2 += t2.c;
959
- });
965
+ }));
960
966
  break;
961
967
  case ":host":
962
968
  case ":host-context":
@@ -969,18 +975,18 @@ function selectorSpecificity(t, s) {
969
975
  case ":active-view-transition-type":
970
976
  return { a: 0, b: 1, c: 0 };
971
977
  }
972
- 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) => {
973
979
  const t2 = selectorSpecificity(e3, s);
974
980
  c += t2.a, n2 += t2.b, o2 += t2.c;
975
- });
981
+ }));
976
982
  return { a: c, b: n2, c: o2 };
977
983
  }
978
984
  function specificityOfMostSpecificListItem(e3, t) {
979
985
  let s = { a: 0, b: 0, c: 0 };
980
- return e3.forEach((e4) => {
986
+ return e3.forEach(((e4) => {
981
987
  const i = selectorSpecificity(e4, t);
982
988
  compare(i, s) < 0 || (s = i);
983
- }), s;
989
+ })), s;
984
990
  }
985
991
  function isPseudoElement(t) {
986
992
  return e.isPseudoElement(t);
@@ -988,7 +994,7 @@ function isPseudoElement(t) {
988
994
  function selectorNodeContainsNothingOrOnlyUniversal(e3) {
989
995
  if (!e3) return false;
990
996
  if (!e3.nodes) return false;
991
- const t = e3.nodes.filter((e4) => "comment" !== e4.type);
997
+ const t = e3.nodes.filter(((e4) => "comment" !== e4.type));
992
998
  return 0 === t.length || 1 === t.length && "universal" === t[0].type;
993
999
  }
994
1000
 
@@ -996,17 +1002,17 @@ function selectorNodeContainsNothingOrOnlyUniversal(e3) {
996
1002
  function alwaysValidSelector(s) {
997
1003
  const o2 = e2().astSync(s);
998
1004
  let n2 = true;
999
- return o2.walk((e3) => {
1005
+ return o2.walk(((e3) => {
1000
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())) {
1001
1007
  if ("pseudo" === e3.type && 1 === e3.nodes?.length && ":not" === e3.value.toLowerCase()) {
1002
1008
  let s2 = true;
1003
- if (e3.nodes[0].walkCombinators(() => {
1009
+ if (e3.nodes[0].walkCombinators((() => {
1004
1010
  s2 = false;
1005
- }), s2) return;
1011
+ })), s2) return;
1006
1012
  }
1007
1013
  return n2 = false, false;
1008
1014
  }
1009
- }), n2;
1015
+ })), n2;
1010
1016
  }
1011
1017
  function sortCompoundSelectorsInsideComplexSelector(s) {
1012
1018
  if (!s || !s.nodes || 1 === s.nodes.length) return;
@@ -1017,8 +1023,8 @@ function sortCompoundSelectorsInsideComplexSelector(s) {
1017
1023
  const t = [];
1018
1024
  for (let e3 = 0; e3 < o2.length; e3++) {
1019
1025
  const s2 = o2[e3];
1020
- 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));
1021
- 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"));
1022
1028
  for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() : t.push(s2[e4]);
1023
1029
  }
1024
1030
  s.removeAll();
@@ -1069,15 +1075,15 @@ function isPseudoInFirstCompound(s) {
1069
1075
  const n2 = s.nodes[o2];
1070
1076
  if (!n2 || !e2.isPseudoClass(n2)) return false;
1071
1077
  const t = s.nodes.slice(0, o2), r = s.nodes.slice(o2 + 1);
1072
- return t.forEach((e3) => {
1078
+ return t.forEach(((e3) => {
1073
1079
  n2.nodes[0].append(e3.clone());
1074
- }), r.forEach((e3) => {
1080
+ })), r.forEach(((e3) => {
1075
1081
  n2.nodes[0].append(e3.clone());
1076
- }), n2.replaceWith(...n2.nodes), t.forEach((e3) => {
1082
+ })), n2.replaceWith(...n2.nodes), t.forEach(((e3) => {
1077
1083
  e3.remove();
1078
- }), r.forEach((e3) => {
1084
+ })), r.forEach(((e3) => {
1079
1085
  e3.remove();
1080
- }), true;
1086
+ })), true;
1081
1087
  }
1082
1088
  function samePrecedingElement(s) {
1083
1089
  if (!s || !s.nodes) return false;
@@ -1103,50 +1109,50 @@ function samePrecedingElement(s) {
1103
1109
  const r = s.nodes[n2];
1104
1110
  if (!r || !e2.isPseudoClass(r)) return false;
1105
1111
  const d = s.nodes.slice(0, o2), l = s.nodes.slice(n2 + 1);
1106
- return s.each((e3) => {
1112
+ return s.each(((e3) => {
1107
1113
  e3.remove();
1108
- }), d.forEach((e3) => {
1114
+ })), d.forEach(((e3) => {
1109
1115
  s.append(e3);
1110
- }), r.nodes[0].nodes.forEach((e3) => {
1116
+ })), r.nodes[0].nodes.forEach(((e3) => {
1111
1117
  s.append(e3);
1112
- }), l.forEach((e3) => {
1118
+ })), l.forEach(((e3) => {
1113
1119
  s.append(e3);
1114
- }), true;
1120
+ })), true;
1115
1121
  }
1116
1122
  function complexSelectors(s, o2, n2, t) {
1117
- return s.flatMap((s2) => {
1123
+ return s.flatMap(((s2) => {
1118
1124
  if (-1 === s2.indexOf(":-csstools-matches") && -1 === s2.toLowerCase().indexOf(":is")) return s2;
1119
1125
  const r = e2().astSync(s2);
1120
- return r.walkPseudos((s3) => {
1126
+ return r.walkPseudos(((s3) => {
1121
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());
1122
1128
  if (":-csstools-matches" === s3.value) if (!s3.nodes || s3.nodes.length) {
1123
- if (s3.walkPseudos((s4) => {
1129
+ if (s3.walkPseudos(((s4) => {
1124
1130
  if (e2.isPseudoElement(s4)) {
1125
1131
  let e3 = s4.value;
1126
1132
  if (e3.startsWith("::-csstools-invalid-")) return;
1127
1133
  for (; e3.startsWith(":"); ) e3 = e3.slice(1);
1128
1134
  s4.value = `::-csstools-invalid-${e3}`, t();
1129
1135
  }
1130
- }), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
1136
+ })), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
1131
1137
  if (1 === s3.nodes[0].nodes.length) return void s3.replaceWith(s3.nodes[0].nodes[0]);
1132
- 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);
1133
1139
  }
1134
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);
1135
1141
  } else s3.remove();
1136
- }), r.walk((e3) => {
1142
+ })), r.walk(((e3) => {
1137
1143
  "selector" === e3.type && "nodes" in e3 && 1 === e3.nodes.length && "selector" === e3.nodes[0].type && e3.replaceWith(e3.nodes[0]);
1138
- }), r.walk((e3) => {
1144
+ })), r.walk(((e3) => {
1139
1145
  "nodes" in e3 && sortCompoundSelectorsInsideComplexSelector(e3);
1140
- }), r.toString();
1141
- }).filter((e3) => !!e3);
1146
+ })), r.toString();
1147
+ })).filter(((e3) => !!e3));
1142
1148
  }
1143
1149
  function splitSelectors(o2, n2, t = 0) {
1144
1150
  const r = ":not(#" + n2.specificityMatchingName + ")", d = ":not(." + n2.specificityMatchingName + ")", l = ":not(" + n2.specificityMatchingName + ")";
1145
- return o2.flatMap((o3) => {
1151
+ return o2.flatMap(((o3) => {
1146
1152
  if (-1 === o3.toLowerCase().indexOf(":is")) return o3;
1147
1153
  let i = false;
1148
1154
  const a = [];
1149
- if (e2().astSync(o3).walkPseudos((e3) => {
1155
+ if (e2().astSync(o3).walkPseudos(((e3) => {
1150
1156
  if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
1151
1157
  if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
1152
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()})` }]);
@@ -1157,7 +1163,7 @@ function splitSelectors(o2, n2, t = 0) {
1157
1163
  o4 = o4.parent;
1158
1164
  }
1159
1165
  const n3 = selectorSpecificity(e3), t2 = e3.sourceIndex, c2 = t2 + e3.toString().length, p = [];
1160
- e3.nodes.forEach((e4) => {
1166
+ e3.nodes.forEach(((e4) => {
1161
1167
  const o5 = { start: t2, end: c2, option: "" }, i2 = selectorSpecificity(e4);
1162
1168
  let a2 = e4.toString().trim();
1163
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);
@@ -1165,27 +1171,27 @@ function splitSelectors(o2, n2, t = 0) {
1165
1171
  for (let e5 = 0; e5 < h; e5++) a2 += d;
1166
1172
  for (let e5 = 0; e5 < f; e5++) a2 += l;
1167
1173
  o5.option = a2, p.push(o5);
1168
- }), a.push(p);
1169
- }), !a.length) return [o3];
1174
+ })), a.push(p);
1175
+ })), !a.length) return [o3];
1170
1176
  let c = [];
1171
- return cartesianProduct(...a).forEach((e3) => {
1177
+ return cartesianProduct(...a).forEach(((e3) => {
1172
1178
  let s = "";
1173
1179
  for (let n3 = 0; n3 < e3.length; n3++) {
1174
1180
  const t2 = e3[n3];
1175
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));
1176
1182
  }
1177
1183
  c.push(s);
1178
- }), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
1179
- }).filter((e3) => !!e3);
1184
+ })), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
1185
+ })).filter(((e3) => !!e3));
1180
1186
  }
1181
1187
  function cartesianProduct(...e3) {
1182
1188
  const s = [], o2 = e3.length - 1;
1183
- return function helper(n2, t) {
1189
+ return (function helper(n2, t) {
1184
1190
  for (let r = 0, d = e3[t].length; r < d; r++) {
1185
1191
  const d2 = n2.slice(0);
1186
1192
  d2.push(e3[t][r]), t === o2 ? s.push(d2) : helper(d2, t + 1);
1187
1193
  }
1188
- }([], 0), s;
1194
+ })([], 0), s;
1189
1195
  }
1190
1196
  var n = /:is\(/i;
1191
1197
  var creator = (e3) => {
@@ -1207,13 +1213,13 @@ var creator = (e3) => {
1207
1213
  try {
1208
1214
  let n2 = false;
1209
1215
  const t2 = [], r2 = complexSelectors(splitSelectors(o2.selectors, { specificityMatchingName: s.specificityMatchingName }), { onComplexSelector: s.onComplexSelector }, warnOnComplexSelector, warnOnPseudoElements);
1210
- if (Array.from(new Set(r2)).forEach((s2) => {
1216
+ if (Array.from(new Set(r2)).forEach(((s2) => {
1211
1217
  if (o2.selectors.indexOf(s2) > -1) t2.push(s2);
1212
1218
  else {
1213
1219
  if (alwaysValidSelector(s2)) return t2.push(s2), void (n2 = true);
1214
1220
  e4.add(o2), o2.cloneBefore({ selector: s2 }), n2 = true;
1215
1221
  }
1216
- }), 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) {
1217
1223
  if (!n2) return;
1218
1224
  o2.remove();
1219
1225
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/postcss",
3
- "version": "1.0.20",
3
+ "version": "1.0.22-alpha.0",
4
4
  "description": "@weapp-tailwindcss/postcss",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",