@weapp-tailwindcss/postcss 0.0.1-alpha.0 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13 -315
- package/dist/index.mjs +4 -306
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -2,311 +2,8 @@
|
|
|
2
2
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
3
3
|
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
4
4
|
|
|
5
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.4.49/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
6
|
-
var _postcssselectorparser = require('postcss-selector-parser'); var _postcssselectorparser2 = _interopRequireDefault(_postcssselectorparser);
|
|
7
|
-
|
|
8
|
-
// ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.0.0/node_modules/@csstools/selector-specificity/dist/index.mjs
|
|
9
|
-
|
|
10
|
-
function compare(e3, t2) {
|
|
11
|
-
return e3.a === t2.a ? e3.b === t2.b ? e3.c - t2.c : e3.b - t2.b : e3.a - t2.a;
|
|
12
|
-
}
|
|
13
|
-
function selectorSpecificity(t2, s) {
|
|
14
|
-
const i = _optionalChain([s, 'optionalAccess', _ => _.customSpecificity, 'optionalCall', _2 => _2(t2)]);
|
|
15
|
-
if (i) return i;
|
|
16
|
-
if (!t2) return { a: 0, b: 0, c: 0 };
|
|
17
|
-
let c = 0, n = 0, o2 = 0;
|
|
18
|
-
if ("universal" == t2.type) return { a: 0, b: 0, c: 0 };
|
|
19
|
-
if ("id" === t2.type) c += 1;
|
|
20
|
-
else if ("tag" === t2.type) o2 += 1;
|
|
21
|
-
else if ("class" === t2.type) n += 1;
|
|
22
|
-
else if ("attribute" === t2.type) n += 1;
|
|
23
|
-
else if (isPseudoElement(t2)) switch (t2.value.toLowerCase()) {
|
|
24
|
-
case "::slotted":
|
|
25
|
-
if (o2 += 1, t2.nodes && t2.nodes.length > 0) {
|
|
26
|
-
const e3 = specificityOfMostSpecificListItem(t2.nodes, s);
|
|
27
|
-
c += e3.a, n += e3.b, o2 += e3.c;
|
|
28
|
-
}
|
|
29
|
-
break;
|
|
30
|
-
case "::view-transition-group":
|
|
31
|
-
case "::view-transition-image-pair":
|
|
32
|
-
case "::view-transition-old":
|
|
33
|
-
case "::view-transition-new":
|
|
34
|
-
return t2.nodes && 1 === t2.nodes.length && "selector" === t2.nodes[0].type && selectorNodeContainsNothingOrOnlyUniversal(t2.nodes[0]) ? { a: 0, b: 0, c: 0 } : { a: 0, b: 0, c: 1 };
|
|
35
|
-
default:
|
|
36
|
-
o2 += 1;
|
|
37
|
-
}
|
|
38
|
-
else if (_postcssselectorparser2.default.isPseudoClass(t2)) switch (t2.value.toLowerCase()) {
|
|
39
|
-
case ":-webkit-any":
|
|
40
|
-
case ":any":
|
|
41
|
-
default:
|
|
42
|
-
n += 1;
|
|
43
|
-
break;
|
|
44
|
-
case ":-moz-any":
|
|
45
|
-
case ":has":
|
|
46
|
-
case ":is":
|
|
47
|
-
case ":matches":
|
|
48
|
-
case ":not":
|
|
49
|
-
if (t2.nodes && t2.nodes.length > 0) {
|
|
50
|
-
const e3 = specificityOfMostSpecificListItem(t2.nodes, s);
|
|
51
|
-
c += e3.a, n += e3.b, o2 += e3.c;
|
|
52
|
-
}
|
|
53
|
-
break;
|
|
54
|
-
case ":where":
|
|
55
|
-
break;
|
|
56
|
-
case ":nth-child":
|
|
57
|
-
case ":nth-last-child":
|
|
58
|
-
if (n += 1, t2.nodes && t2.nodes.length > 0) {
|
|
59
|
-
const i2 = t2.nodes[0].nodes.findIndex((e3) => "tag" === e3.type && "of" === e3.value.toLowerCase());
|
|
60
|
-
if (i2 > -1) {
|
|
61
|
-
const a = _postcssselectorparser2.default.selector({ nodes: [], value: "" });
|
|
62
|
-
t2.nodes[0].nodes.slice(i2 + 1).forEach((e3) => {
|
|
63
|
-
a.append(e3.clone());
|
|
64
|
-
});
|
|
65
|
-
const r = [a];
|
|
66
|
-
t2.nodes.length > 1 && r.push(...t2.nodes.slice(1));
|
|
67
|
-
const l = specificityOfMostSpecificListItem(r, s);
|
|
68
|
-
c += l.a, n += l.b, o2 += l.c;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
case ":local":
|
|
73
|
-
case ":global":
|
|
74
|
-
t2.nodes && t2.nodes.length > 0 && t2.nodes.forEach((e3) => {
|
|
75
|
-
const t3 = selectorSpecificity(e3, s);
|
|
76
|
-
c += t3.a, n += t3.b, o2 += t3.c;
|
|
77
|
-
});
|
|
78
|
-
break;
|
|
79
|
-
case ":host":
|
|
80
|
-
case ":host-context":
|
|
81
|
-
if (n += 1, t2.nodes && t2.nodes.length > 0) {
|
|
82
|
-
const e3 = specificityOfMostSpecificListItem(t2.nodes, s);
|
|
83
|
-
c += e3.a, n += e3.b, o2 += e3.c;
|
|
84
|
-
}
|
|
85
|
-
break;
|
|
86
|
-
case ":active-view-transition":
|
|
87
|
-
case ":active-view-transition-type":
|
|
88
|
-
return { a: 0, b: 1, c: 0 };
|
|
89
|
-
}
|
|
90
|
-
else _postcssselectorparser2.default.isContainer(t2) && _optionalChain([t2, 'access', _3 => _3.nodes, 'optionalAccess', _4 => _4.length]) > 0 && t2.nodes.forEach((e3) => {
|
|
91
|
-
const t3 = selectorSpecificity(e3, s);
|
|
92
|
-
c += t3.a, n += t3.b, o2 += t3.c;
|
|
93
|
-
});
|
|
94
|
-
return { a: c, b: n, c: o2 };
|
|
95
|
-
}
|
|
96
|
-
function specificityOfMostSpecificListItem(e3, t2) {
|
|
97
|
-
let s = { a: 0, b: 0, c: 0 };
|
|
98
|
-
return e3.forEach((e4) => {
|
|
99
|
-
const i = selectorSpecificity(e4, t2);
|
|
100
|
-
compare(i, s) < 0 || (s = i);
|
|
101
|
-
}), s;
|
|
102
|
-
}
|
|
103
|
-
function isPseudoElement(t2) {
|
|
104
|
-
return _postcssselectorparser2.default.isPseudoElement(t2);
|
|
105
|
-
}
|
|
106
|
-
function selectorNodeContainsNothingOrOnlyUniversal(e3) {
|
|
107
|
-
if (!e3) return false;
|
|
108
|
-
if (!e3.nodes) return false;
|
|
109
|
-
const t2 = e3.nodes.filter((e4) => "comment" !== e4.type);
|
|
110
|
-
return 0 === t2.length || 1 === t2.length && "universal" === t2[0].type;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.4.49/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
114
|
-
function alwaysValidSelector(s) {
|
|
115
|
-
const o2 = _postcssselectorparser2.default.call(void 0, ).astSync(s);
|
|
116
|
-
let t2 = true;
|
|
117
|
-
return o2.walk((e3) => {
|
|
118
|
-
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', _5 => _5.nodes, 'optionalAccess', _6 => _6.length]) || ":hover" !== e3.value.toLowerCase() && ":focus" !== e3.value.toLowerCase())) {
|
|
119
|
-
if ("pseudo" === e3.type && 1 === _optionalChain([e3, 'access', _7 => _7.nodes, 'optionalAccess', _8 => _8.length]) && ":not" === e3.value.toLowerCase()) {
|
|
120
|
-
let s2 = true;
|
|
121
|
-
if (e3.nodes[0].walkCombinators(() => {
|
|
122
|
-
s2 = false;
|
|
123
|
-
}), s2) return;
|
|
124
|
-
}
|
|
125
|
-
return t2 = false, false;
|
|
126
|
-
}
|
|
127
|
-
}), t2;
|
|
128
|
-
}
|
|
129
|
-
function sortCompoundSelectorsInsideComplexSelector(s) {
|
|
130
|
-
if (!s || !s.nodes || 1 === s.nodes.length) return;
|
|
131
|
-
const o2 = [];
|
|
132
|
-
let t2 = [];
|
|
133
|
-
for (let n2 = 0; n2 < s.nodes.length; n2++) "combinator" !== s.nodes[n2].type ? _postcssselectorparser2.default.isPseudoElement(s.nodes[n2]) ? (o2.push(t2), t2 = [s.nodes[n2]]) : t2.push(s.nodes[n2]) : (o2.push(t2), o2.push([s.nodes[n2]]), t2 = []);
|
|
134
|
-
o2.push(t2);
|
|
135
|
-
const n = [];
|
|
136
|
-
for (let e3 = 0; e3 < o2.length; e3++) {
|
|
137
|
-
const s2 = o2[e3];
|
|
138
|
-
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));
|
|
139
|
-
const t3 = new Set(s2.map((e4) => e4.type)), r = t3.has("universal") && (t3.has("tag") || t3.has("attribute") || t3.has("class") || t3.has("id") || t3.has("pseudo"));
|
|
140
|
-
for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() : n.push(s2[e4]);
|
|
141
|
-
}
|
|
142
|
-
s.removeAll();
|
|
143
|
-
for (let o3 = n.length - 1; o3 >= 0; o3--) {
|
|
144
|
-
const t3 = n[o3 - 1];
|
|
145
|
-
if (n[o3].remove(), t3 && "tag" === t3.type && "tag" === n[o3].type) {
|
|
146
|
-
const t4 = _postcssselectorparser2.default.pseudo({ value: ":is", nodes: [_postcssselectorparser2.default.selector({ value: "", nodes: [n[o3]] })] });
|
|
147
|
-
t4.parent = s, s.nodes.unshift(t4);
|
|
148
|
-
} else n[o3].parent = s, s.nodes.unshift(n[o3]);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
function selectorTypeOrder(s, t2) {
|
|
152
|
-
return _postcssselectorparser2.default.isPseudoElement(s) ? o.pseudoElement : o[t2];
|
|
153
|
-
}
|
|
154
|
-
var o = { universal: 0, tag: 1, pseudoElement: 2, id: 3, class: 4, attribute: 5, pseudo: 6, selector: 7, string: 8, root: 9, comment: 10 };
|
|
155
|
-
function childAdjacentChild(e3) {
|
|
156
|
-
return !(!e3 || !e3.nodes) && ("selector" === e3.type && (3 === e3.nodes.length && (!(!e3.nodes[0] || "pseudo" !== e3.nodes[0].type || ":-csstools-matches" !== e3.nodes[0].value) && (!(!e3.nodes[1] || "combinator" !== e3.nodes[1].type || "+" !== e3.nodes[1].value && "~" !== e3.nodes[1].value) && (!(!e3.nodes[2] || "pseudo" !== e3.nodes[2].type || ":-csstools-matches" !== e3.nodes[2].value) && (!(!e3.nodes[0].nodes || 1 !== e3.nodes[0].nodes.length) && ("selector" === e3.nodes[0].nodes[0].type && (!(!e3.nodes[0].nodes[0].nodes || 3 !== e3.nodes[0].nodes[0].nodes.length) && (!(!e3.nodes[0].nodes[0].nodes || "combinator" !== e3.nodes[0].nodes[0].nodes[1].type || ">" !== e3.nodes[0].nodes[0].nodes[1].value) && (!(!e3.nodes[2].nodes || 1 !== e3.nodes[2].nodes.length) && ("selector" === e3.nodes[2].nodes[0].type && (!(!e3.nodes[2].nodes[0].nodes || 3 !== e3.nodes[2].nodes[0].nodes.length) && (!(!e3.nodes[2].nodes[0].nodes || "combinator" !== e3.nodes[2].nodes[0].nodes[1].type || ">" !== e3.nodes[2].nodes[0].nodes[1].value) && (e3.nodes[0].nodes[0].insertAfter(e3.nodes[0].nodes[0].nodes[0], e3.nodes[2].nodes[0].nodes[0].clone()), e3.nodes[2].nodes[0].nodes[1].remove(), e3.nodes[2].nodes[0].nodes[0].remove(), e3.nodes[0].replaceWith(e3.nodes[0].nodes[0]), e3.nodes[2].replaceWith(e3.nodes[2].nodes[0]), true))))))))))))));
|
|
157
|
-
}
|
|
158
|
-
function isInCompoundWithOneOtherElement(s) {
|
|
159
|
-
if (!s || !s.nodes) return false;
|
|
160
|
-
if (!_postcssselectorparser2.default.isSelector(s)) return false;
|
|
161
|
-
if (2 !== s.nodes.length) return false;
|
|
162
|
-
let o2 = -1, t2 = -1;
|
|
163
|
-
s.nodes[0] && _postcssselectorparser2.default.isPseudoClass(s.nodes[0]) && ":-csstools-matches" === s.nodes[0].value ? (o2 = 0, t2 = 1) : s.nodes[1] && _postcssselectorparser2.default.isPseudoClass(s.nodes[1]) && ":-csstools-matches" === s.nodes[1].value && (o2 = 1, t2 = 0);
|
|
164
|
-
const n = s.nodes[o2];
|
|
165
|
-
if (!n || !_postcssselectorparser2.default.isPseudoClass(n) || 1 !== n.nodes.length) return false;
|
|
166
|
-
const r = s.nodes[t2];
|
|
167
|
-
return !!r && (!_postcssselectorparser2.default.isCombinator(r) && (n.nodes[0].append(r.clone()), n.replaceWith(...n.nodes[0].nodes), r.remove(), true));
|
|
168
|
-
}
|
|
169
|
-
function isPseudoInFirstCompound(s) {
|
|
170
|
-
if (!s || !s.nodes) return false;
|
|
171
|
-
if (!_postcssselectorparser2.default.isSelector(s)) return false;
|
|
172
|
-
let o2 = -1;
|
|
173
|
-
for (let t3 = 0; t3 < s.nodes.length; t3++) {
|
|
174
|
-
const n2 = s.nodes[t3];
|
|
175
|
-
if (_postcssselectorparser2.default.isCombinator(n2)) return false;
|
|
176
|
-
if (_postcssselectorparser2.default.isPseudoClass(n2) && ":-csstools-matches" === n2.value) {
|
|
177
|
-
if (!n2.nodes || 1 !== n2.nodes.length) return false;
|
|
178
|
-
o2 = t3;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
const t2 = s.nodes[o2];
|
|
183
|
-
if (!t2 || !_postcssselectorparser2.default.isPseudoClass(t2)) return false;
|
|
184
|
-
const n = s.nodes.slice(0, o2), r = s.nodes.slice(o2 + 1);
|
|
185
|
-
return n.forEach((e3) => {
|
|
186
|
-
t2.nodes[0].append(e3.clone());
|
|
187
|
-
}), r.forEach((e3) => {
|
|
188
|
-
t2.nodes[0].append(e3.clone());
|
|
189
|
-
}), t2.replaceWith(...t2.nodes), n.forEach((e3) => {
|
|
190
|
-
e3.remove();
|
|
191
|
-
}), r.forEach((e3) => {
|
|
192
|
-
e3.remove();
|
|
193
|
-
}), true;
|
|
194
|
-
}
|
|
195
|
-
function complexSelectors(s, o2, t2, n) {
|
|
196
|
-
return s.flatMap((s2) => {
|
|
197
|
-
if (-1 === s2.indexOf(":-csstools-matches") && -1 === s2.toLowerCase().indexOf(":is")) return s2;
|
|
198
|
-
const r = _postcssselectorparser2.default.call(void 0, ).astSync(s2);
|
|
199
|
-
return r.walkPseudos((s3) => {
|
|
200
|
-
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());
|
|
201
|
-
if (":-csstools-matches" === s3.value) if (!s3.nodes || s3.nodes.length) {
|
|
202
|
-
if (s3.walkPseudos((s4) => {
|
|
203
|
-
if (_postcssselectorparser2.default.isPseudoElement(s4)) {
|
|
204
|
-
let e3 = s4.value;
|
|
205
|
-
if (e3.startsWith("::-csstools-invalid-")) return;
|
|
206
|
-
for (; e3.startsWith(":"); ) e3 = e3.slice(1);
|
|
207
|
-
s4.value = `::-csstools-invalid-${e3}`, n();
|
|
208
|
-
}
|
|
209
|
-
}), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
|
|
210
|
-
if (1 === s3.nodes[0].nodes.length) return void s3.replaceWith(s3.nodes[0].nodes[0]);
|
|
211
|
-
if (!s3.nodes[0].some((e3) => "combinator" === e3.type)) return void s3.replaceWith(...s3.nodes[0].nodes);
|
|
212
|
-
}
|
|
213
|
-
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 && t2(), s3.value = ":is") : s3.replaceWith(...s3.nodes[0].nodes);
|
|
214
|
-
} else s3.remove();
|
|
215
|
-
}), r.walk((e3) => {
|
|
216
|
-
"selector" === e3.type && "nodes" in e3 && 1 === e3.nodes.length && "selector" === e3.nodes[0].type && e3.replaceWith(e3.nodes[0]);
|
|
217
|
-
}), r.walk((e3) => {
|
|
218
|
-
"nodes" in e3 && sortCompoundSelectorsInsideComplexSelector(e3);
|
|
219
|
-
}), r.toString();
|
|
220
|
-
}).filter((e3) => !!e3);
|
|
221
|
-
}
|
|
222
|
-
function splitSelectors(o2, t2, n = 0) {
|
|
223
|
-
const r = ":not(#" + t2.specificityMatchingName + ")", d = ":not(." + t2.specificityMatchingName + ")", l = ":not(" + t2.specificityMatchingName + ")";
|
|
224
|
-
return o2.flatMap((o3) => {
|
|
225
|
-
if (-1 === o3.toLowerCase().indexOf(":is")) return o3;
|
|
226
|
-
let a = false;
|
|
227
|
-
const i = [];
|
|
228
|
-
if (_postcssselectorparser2.default.call(void 0, ).astSync(o3).walkPseudos((e3) => {
|
|
229
|
-
if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
|
|
230
|
-
if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
|
|
231
|
-
if ("pseudo" === _optionalChain([e3, 'access', _9 => _9.parent, 'optionalAccess', _10 => _10.parent, 'optionalAccess', _11 => _11.type]) && ":not" === _optionalChain([e3, 'access', _12 => _12.parent, 'optionalAccess', _13 => _13.parent, 'optionalAccess', _14 => _14.value, 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16()])) return void i.push([{ start: e3.parent.parent.sourceIndex, end: e3.parent.parent.sourceIndex + e3.parent.parent.toString().length, option: `:not(${e3.nodes.toString()})` }]);
|
|
232
|
-
if ("pseudo" === _optionalChain([e3, 'access', _17 => _17.parent, 'optionalAccess', _18 => _18.parent, 'optionalAccess', _19 => _19.type]) && ":has" === _optionalChain([e3, 'access', _20 => _20.parent, 'optionalAccess', _21 => _21.parent, 'optionalAccess', _22 => _22.value, 'optionalAccess', _23 => _23.toLowerCase, 'call', _24 => _24()])) return void (e3.value = ":-csstools-matches");
|
|
233
|
-
let o4 = e3.parent;
|
|
234
|
-
for (; o4; ) {
|
|
235
|
-
if (o4.value && ":is" === o4.value.toLowerCase() && "pseudo" === o4.type) return void (a = true);
|
|
236
|
-
o4 = o4.parent;
|
|
237
|
-
}
|
|
238
|
-
const t3 = selectorSpecificity(e3), n2 = e3.sourceIndex, c2 = n2 + e3.toString().length, p = [];
|
|
239
|
-
e3.nodes.forEach((e4) => {
|
|
240
|
-
const o5 = { start: n2, end: c2, option: "" }, a2 = selectorSpecificity(e4);
|
|
241
|
-
let i2 = e4.toString().trim();
|
|
242
|
-
const u = Math.max(0, t3.a - a2.a), h = Math.max(0, t3.b - a2.b), f = Math.max(0, t3.c - a2.c);
|
|
243
|
-
for (let e5 = 0; e5 < u; e5++) i2 += r;
|
|
244
|
-
for (let e5 = 0; e5 < h; e5++) i2 += d;
|
|
245
|
-
for (let e5 = 0; e5 < f; e5++) i2 += l;
|
|
246
|
-
o5.option = i2, p.push(o5);
|
|
247
|
-
}), i.push(p);
|
|
248
|
-
}), !i.length) return [o3];
|
|
249
|
-
let c = [];
|
|
250
|
-
return cartesianProduct(...i).forEach((e3) => {
|
|
251
|
-
let s = "";
|
|
252
|
-
for (let t3 = 0; t3 < e3.length; t3++) {
|
|
253
|
-
const n2 = e3[t3];
|
|
254
|
-
s += o3.substring(_optionalChain([e3, 'access', _25 => _25[t3 - 1], 'optionalAccess', _26 => _26.end]) || 0, e3[t3].start), s += ":-csstools-matches(" + n2.option + ")", t3 === e3.length - 1 && (s += o3.substring(e3[t3].end));
|
|
255
|
-
}
|
|
256
|
-
c.push(s);
|
|
257
|
-
}), a && n < 10 && (c = splitSelectors(c, t2, n + 1)), c;
|
|
258
|
-
}).filter((e3) => !!e3);
|
|
259
|
-
}
|
|
260
|
-
function cartesianProduct(...e3) {
|
|
261
|
-
const s = [], o2 = e3.length - 1;
|
|
262
|
-
return function helper(t2, n) {
|
|
263
|
-
for (let r = 0, d = e3[n].length; r < d; r++) {
|
|
264
|
-
const d2 = t2.slice(0);
|
|
265
|
-
d2.push(e3[n][r]), n === o2 ? s.push(d2) : helper(d2, n + 1);
|
|
266
|
-
}
|
|
267
|
-
}([], 0), s;
|
|
268
|
-
}
|
|
269
|
-
var t = /:is\(/i;
|
|
270
|
-
var creator = (e3) => {
|
|
271
|
-
const s = { specificityMatchingName: "does-not-exist", ...e3 || {} };
|
|
272
|
-
return { postcssPlugin: "postcss-is-pseudo-class", prepare() {
|
|
273
|
-
const e4 = /* @__PURE__ */ new WeakSet();
|
|
274
|
-
return { postcssPlugin: "postcss-is-pseudo-class", Rule(o2, { result: n }) {
|
|
275
|
-
if (!o2.selector) return;
|
|
276
|
-
if (!t.test(o2.selector)) return;
|
|
277
|
-
if (e4.has(o2)) return;
|
|
278
|
-
let r = false;
|
|
279
|
-
const warnOnComplexSelector = () => {
|
|
280
|
-
"warning" === s.onComplexSelector && (r || (r = true, o2.warn(n, `Complex selectors in '${o2.selector}' can not be transformed to an equivalent selector without ':is()'.`)));
|
|
281
|
-
};
|
|
282
|
-
let d = false;
|
|
283
|
-
const warnOnPseudoElements = () => {
|
|
284
|
-
"warning" === s.onPseudoElement && (d || (d = true, o2.warn(n, `Pseudo elements are not allowed in ':is()', unable to transform '${o2.selector}'`)));
|
|
285
|
-
};
|
|
286
|
-
try {
|
|
287
|
-
let t2 = false;
|
|
288
|
-
const n2 = [], r2 = complexSelectors(splitSelectors(o2.selectors, { specificityMatchingName: s.specificityMatchingName }), { onComplexSelector: s.onComplexSelector }, warnOnComplexSelector, warnOnPseudoElements);
|
|
289
|
-
if (Array.from(new Set(r2)).forEach((s2) => {
|
|
290
|
-
if (o2.selectors.indexOf(s2) > -1) n2.push(s2);
|
|
291
|
-
else {
|
|
292
|
-
if (alwaysValidSelector(s2)) return n2.push(s2), void (t2 = true);
|
|
293
|
-
e4.add(o2), o2.cloneBefore({ selector: s2 }), t2 = true;
|
|
294
|
-
}
|
|
295
|
-
}), n2.length && t2 && (e4.add(o2), o2.cloneBefore({ selectors: n2 })), !s.preserve) {
|
|
296
|
-
if (!t2) return;
|
|
297
|
-
o2.remove();
|
|
298
|
-
}
|
|
299
|
-
} catch (e5) {
|
|
300
|
-
if (!(e5 instanceof Error)) throw e5;
|
|
301
|
-
if (e5.message.indexOf("call stack size exceeded") > -1) throw e5;
|
|
302
|
-
o2.warn(n, `Failed to parse selector "${o2.selector}" with error: ${e5.message}`);
|
|
303
|
-
}
|
|
304
|
-
} };
|
|
305
|
-
} };
|
|
306
|
-
};
|
|
307
|
-
creator.postcss = true;
|
|
308
|
-
|
|
309
5
|
// src/plugins/index.ts
|
|
6
|
+
var _postcssispseudoclass = require('@csstools/postcss-is-pseudo-class'); var _postcssispseudoclass2 = _interopRequireDefault(_postcssispseudoclass);
|
|
310
7
|
var _postcssremtoresponsivepixel = require('postcss-rem-to-responsive-pixel'); var _postcssremtoresponsivepixel2 = _interopRequireDefault(_postcssremtoresponsivepixel);
|
|
311
8
|
|
|
312
9
|
// src/symbols.ts
|
|
@@ -332,7 +29,7 @@ function createContext() {
|
|
|
332
29
|
var postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
|
|
333
30
|
|
|
334
31
|
// src/selectorParser.ts
|
|
335
|
-
|
|
32
|
+
var _postcssselectorparser = require('postcss-selector-parser'); var _postcssselectorparser2 = _interopRequireDefault(_postcssselectorparser);
|
|
336
33
|
|
|
337
34
|
// src/shared.ts
|
|
338
35
|
var _escape = require('@weapp-core/escape');
|
|
@@ -362,7 +59,7 @@ function createRuleTransform(rule, options) {
|
|
|
362
59
|
const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
|
|
363
60
|
const transform = (selectors) => {
|
|
364
61
|
selectors.walk((selector) => {
|
|
365
|
-
if (selector.type === "universal" && _optionalChain([cssSelectorReplacement, 'optionalAccess',
|
|
62
|
+
if (selector.type === "universal" && _optionalChain([cssSelectorReplacement, 'optionalAccess', _ => _.universal])) {
|
|
366
63
|
selector.value = composeIsPseudo(cssSelectorReplacement.universal);
|
|
367
64
|
}
|
|
368
65
|
if (cssRemoveHoverPseudoClass && selector.type === "selector") {
|
|
@@ -371,7 +68,7 @@ function createRuleTransform(rule, options) {
|
|
|
371
68
|
selector.remove();
|
|
372
69
|
}
|
|
373
70
|
}
|
|
374
|
-
if (selector.type === "pseudo" && selector.value === ":root" && _optionalChain([cssSelectorReplacement, 'optionalAccess',
|
|
71
|
+
if (selector.type === "pseudo" && selector.value === ":root" && _optionalChain([cssSelectorReplacement, 'optionalAccess', _2 => _2.root])) {
|
|
375
72
|
selector.value = composeIsPseudo(cssSelectorReplacement.root);
|
|
376
73
|
}
|
|
377
74
|
if (selector.type === "class") {
|
|
@@ -402,7 +99,7 @@ function isOnlyBeforeAndAfterPseudoElement(node) {
|
|
|
402
99
|
let a = false;
|
|
403
100
|
_postcssselectorparser2.default.call(void 0, (selectors) => {
|
|
404
101
|
selectors.walkPseudos((s) => {
|
|
405
|
-
if (_optionalChain([s, 'access',
|
|
102
|
+
if (_optionalChain([s, 'access', _3 => _3.parent, 'optionalAccess', _4 => _4.length]) === 1) {
|
|
406
103
|
if (/^:?:before$/.test(s.value)) {
|
|
407
104
|
b = true;
|
|
408
105
|
}
|
|
@@ -421,13 +118,13 @@ var fallbackRemove = _postcssselectorparser2.default.call(void 0, (selectors) =>
|
|
|
421
118
|
maybeImportantId = true;
|
|
422
119
|
}
|
|
423
120
|
if (selector.type === "universal") {
|
|
424
|
-
_optionalChain([selector, 'access',
|
|
121
|
+
_optionalChain([selector, 'access', _5 => _5.parent, 'optionalAccess', _6 => _6.remove, 'call', _7 => _7()]);
|
|
425
122
|
}
|
|
426
123
|
if (selector.type === "pseudo" && selector.value === ":is") {
|
|
427
|
-
if (maybeImportantId && _optionalChain([selector, 'access',
|
|
124
|
+
if (maybeImportantId && _optionalChain([selector, 'access', _8 => _8.nodes, 'access', _9 => _9[0], 'optionalAccess', _10 => _10.type]) === "selector") {
|
|
428
125
|
selector.replaceWith(selector.nodes[0]);
|
|
429
126
|
} else {
|
|
430
|
-
_optionalChain([selector, 'access',
|
|
127
|
+
_optionalChain([selector, 'access', _11 => _11.parent, 'optionalAccess', _12 => _12.remove, 'call', _13 => _13()]);
|
|
431
128
|
}
|
|
432
129
|
}
|
|
433
130
|
});
|
|
@@ -763,7 +460,7 @@ function commonChunkPreflight(node, options) {
|
|
|
763
460
|
const { ctx, cssChildCombinatorReplaceValue, cssInjectPreflight, injectAdditionalCssVarScope } = options;
|
|
764
461
|
node.selector = remakeCombinatorSelector(node.selector, cssChildCombinatorReplaceValue);
|
|
765
462
|
if (testIfVariablesScope(node)) {
|
|
766
|
-
_optionalChain([ctx, 'optionalAccess',
|
|
463
|
+
_optionalChain([ctx, 'optionalAccess', _14 => _14.markVariablesScope, 'call', _15 => _15(node)]);
|
|
767
464
|
node.selectors = remakeCssVarSelector(node.selectors, options);
|
|
768
465
|
node.before(makePseudoVarRule());
|
|
769
466
|
if (typeof cssInjectPreflight === "function") {
|
|
@@ -820,13 +517,14 @@ postcssWeappTailwindcssPrePlugin.postcss = true;
|
|
|
820
517
|
|
|
821
518
|
// src/plugins/index.ts
|
|
822
519
|
|
|
520
|
+
|
|
823
521
|
function getPlugins(options) {
|
|
824
522
|
const ctx = createContext();
|
|
825
523
|
options.ctx = ctx;
|
|
826
524
|
const plugins = [
|
|
827
|
-
..._nullishCoalesce(_optionalChain([options, 'access',
|
|
525
|
+
..._nullishCoalesce(_optionalChain([options, 'access', _16 => _16.postcssOptions, 'optionalAccess', _17 => _17.plugins]), () => ( [])),
|
|
828
526
|
postcssWeappTailwindcssPrePlugin(options),
|
|
829
|
-
|
|
527
|
+
_postcssispseudoclass2.default.call(void 0, {
|
|
830
528
|
specificityMatchingName: "weapp-tw-ig"
|
|
831
529
|
})
|
|
832
530
|
];
|
|
@@ -868,7 +566,7 @@ function createInjectPreflight(options) {
|
|
|
868
566
|
function styleHandler(rawSource, options) {
|
|
869
567
|
return _postcss2.default.call(void 0, getPlugins(options)).process(
|
|
870
568
|
rawSource,
|
|
871
|
-
_nullishCoalesce(_optionalChain([options, 'access',
|
|
569
|
+
_nullishCoalesce(_optionalChain([options, 'access', _18 => _18.postcssOptions, 'optionalAccess', _19 => _19.options]), () => ( {
|
|
872
570
|
from: void 0
|
|
873
571
|
}))
|
|
874
572
|
).async();
|
package/dist/index.mjs
CHANGED
|
@@ -2,311 +2,8 @@
|
|
|
2
2
|
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
3
3
|
import postcss from "postcss";
|
|
4
4
|
|
|
5
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.4.49/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
6
|
-
import e2 from "postcss-selector-parser";
|
|
7
|
-
|
|
8
|
-
// ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.0.0/node_modules/@csstools/selector-specificity/dist/index.mjs
|
|
9
|
-
import e from "postcss-selector-parser";
|
|
10
|
-
function compare(e3, t2) {
|
|
11
|
-
return e3.a === t2.a ? e3.b === t2.b ? e3.c - t2.c : e3.b - t2.b : e3.a - t2.a;
|
|
12
|
-
}
|
|
13
|
-
function selectorSpecificity(t2, s) {
|
|
14
|
-
const i = s?.customSpecificity?.(t2);
|
|
15
|
-
if (i) return i;
|
|
16
|
-
if (!t2) return { a: 0, b: 0, c: 0 };
|
|
17
|
-
let c = 0, n = 0, o2 = 0;
|
|
18
|
-
if ("universal" == t2.type) return { a: 0, b: 0, c: 0 };
|
|
19
|
-
if ("id" === t2.type) c += 1;
|
|
20
|
-
else if ("tag" === t2.type) o2 += 1;
|
|
21
|
-
else if ("class" === t2.type) n += 1;
|
|
22
|
-
else if ("attribute" === t2.type) n += 1;
|
|
23
|
-
else if (isPseudoElement(t2)) switch (t2.value.toLowerCase()) {
|
|
24
|
-
case "::slotted":
|
|
25
|
-
if (o2 += 1, t2.nodes && t2.nodes.length > 0) {
|
|
26
|
-
const e3 = specificityOfMostSpecificListItem(t2.nodes, s);
|
|
27
|
-
c += e3.a, n += e3.b, o2 += e3.c;
|
|
28
|
-
}
|
|
29
|
-
break;
|
|
30
|
-
case "::view-transition-group":
|
|
31
|
-
case "::view-transition-image-pair":
|
|
32
|
-
case "::view-transition-old":
|
|
33
|
-
case "::view-transition-new":
|
|
34
|
-
return t2.nodes && 1 === t2.nodes.length && "selector" === t2.nodes[0].type && selectorNodeContainsNothingOrOnlyUniversal(t2.nodes[0]) ? { a: 0, b: 0, c: 0 } : { a: 0, b: 0, c: 1 };
|
|
35
|
-
default:
|
|
36
|
-
o2 += 1;
|
|
37
|
-
}
|
|
38
|
-
else if (e.isPseudoClass(t2)) switch (t2.value.toLowerCase()) {
|
|
39
|
-
case ":-webkit-any":
|
|
40
|
-
case ":any":
|
|
41
|
-
default:
|
|
42
|
-
n += 1;
|
|
43
|
-
break;
|
|
44
|
-
case ":-moz-any":
|
|
45
|
-
case ":has":
|
|
46
|
-
case ":is":
|
|
47
|
-
case ":matches":
|
|
48
|
-
case ":not":
|
|
49
|
-
if (t2.nodes && t2.nodes.length > 0) {
|
|
50
|
-
const e3 = specificityOfMostSpecificListItem(t2.nodes, s);
|
|
51
|
-
c += e3.a, n += e3.b, o2 += e3.c;
|
|
52
|
-
}
|
|
53
|
-
break;
|
|
54
|
-
case ":where":
|
|
55
|
-
break;
|
|
56
|
-
case ":nth-child":
|
|
57
|
-
case ":nth-last-child":
|
|
58
|
-
if (n += 1, t2.nodes && t2.nodes.length > 0) {
|
|
59
|
-
const i2 = t2.nodes[0].nodes.findIndex((e3) => "tag" === e3.type && "of" === e3.value.toLowerCase());
|
|
60
|
-
if (i2 > -1) {
|
|
61
|
-
const a = e.selector({ nodes: [], value: "" });
|
|
62
|
-
t2.nodes[0].nodes.slice(i2 + 1).forEach((e3) => {
|
|
63
|
-
a.append(e3.clone());
|
|
64
|
-
});
|
|
65
|
-
const r = [a];
|
|
66
|
-
t2.nodes.length > 1 && r.push(...t2.nodes.slice(1));
|
|
67
|
-
const l = specificityOfMostSpecificListItem(r, s);
|
|
68
|
-
c += l.a, n += l.b, o2 += l.c;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
case ":local":
|
|
73
|
-
case ":global":
|
|
74
|
-
t2.nodes && t2.nodes.length > 0 && t2.nodes.forEach((e3) => {
|
|
75
|
-
const t3 = selectorSpecificity(e3, s);
|
|
76
|
-
c += t3.a, n += t3.b, o2 += t3.c;
|
|
77
|
-
});
|
|
78
|
-
break;
|
|
79
|
-
case ":host":
|
|
80
|
-
case ":host-context":
|
|
81
|
-
if (n += 1, t2.nodes && t2.nodes.length > 0) {
|
|
82
|
-
const e3 = specificityOfMostSpecificListItem(t2.nodes, s);
|
|
83
|
-
c += e3.a, n += e3.b, o2 += e3.c;
|
|
84
|
-
}
|
|
85
|
-
break;
|
|
86
|
-
case ":active-view-transition":
|
|
87
|
-
case ":active-view-transition-type":
|
|
88
|
-
return { a: 0, b: 1, c: 0 };
|
|
89
|
-
}
|
|
90
|
-
else e.isContainer(t2) && t2.nodes?.length > 0 && t2.nodes.forEach((e3) => {
|
|
91
|
-
const t3 = selectorSpecificity(e3, s);
|
|
92
|
-
c += t3.a, n += t3.b, o2 += t3.c;
|
|
93
|
-
});
|
|
94
|
-
return { a: c, b: n, c: o2 };
|
|
95
|
-
}
|
|
96
|
-
function specificityOfMostSpecificListItem(e3, t2) {
|
|
97
|
-
let s = { a: 0, b: 0, c: 0 };
|
|
98
|
-
return e3.forEach((e4) => {
|
|
99
|
-
const i = selectorSpecificity(e4, t2);
|
|
100
|
-
compare(i, s) < 0 || (s = i);
|
|
101
|
-
}), s;
|
|
102
|
-
}
|
|
103
|
-
function isPseudoElement(t2) {
|
|
104
|
-
return e.isPseudoElement(t2);
|
|
105
|
-
}
|
|
106
|
-
function selectorNodeContainsNothingOrOnlyUniversal(e3) {
|
|
107
|
-
if (!e3) return false;
|
|
108
|
-
if (!e3.nodes) return false;
|
|
109
|
-
const t2 = e3.nodes.filter((e4) => "comment" !== e4.type);
|
|
110
|
-
return 0 === t2.length || 1 === t2.length && "universal" === t2[0].type;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.4.49/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
114
|
-
function alwaysValidSelector(s) {
|
|
115
|
-
const o2 = e2().astSync(s);
|
|
116
|
-
let t2 = true;
|
|
117
|
-
return o2.walk((e3) => {
|
|
118
|
-
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())) {
|
|
119
|
-
if ("pseudo" === e3.type && 1 === e3.nodes?.length && ":not" === e3.value.toLowerCase()) {
|
|
120
|
-
let s2 = true;
|
|
121
|
-
if (e3.nodes[0].walkCombinators(() => {
|
|
122
|
-
s2 = false;
|
|
123
|
-
}), s2) return;
|
|
124
|
-
}
|
|
125
|
-
return t2 = false, false;
|
|
126
|
-
}
|
|
127
|
-
}), t2;
|
|
128
|
-
}
|
|
129
|
-
function sortCompoundSelectorsInsideComplexSelector(s) {
|
|
130
|
-
if (!s || !s.nodes || 1 === s.nodes.length) return;
|
|
131
|
-
const o2 = [];
|
|
132
|
-
let t2 = [];
|
|
133
|
-
for (let n2 = 0; n2 < s.nodes.length; n2++) "combinator" !== s.nodes[n2].type ? e2.isPseudoElement(s.nodes[n2]) ? (o2.push(t2), t2 = [s.nodes[n2]]) : t2.push(s.nodes[n2]) : (o2.push(t2), o2.push([s.nodes[n2]]), t2 = []);
|
|
134
|
-
o2.push(t2);
|
|
135
|
-
const n = [];
|
|
136
|
-
for (let e3 = 0; e3 < o2.length; e3++) {
|
|
137
|
-
const s2 = o2[e3];
|
|
138
|
-
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));
|
|
139
|
-
const t3 = new Set(s2.map((e4) => e4.type)), r = t3.has("universal") && (t3.has("tag") || t3.has("attribute") || t3.has("class") || t3.has("id") || t3.has("pseudo"));
|
|
140
|
-
for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() : n.push(s2[e4]);
|
|
141
|
-
}
|
|
142
|
-
s.removeAll();
|
|
143
|
-
for (let o3 = n.length - 1; o3 >= 0; o3--) {
|
|
144
|
-
const t3 = n[o3 - 1];
|
|
145
|
-
if (n[o3].remove(), t3 && "tag" === t3.type && "tag" === n[o3].type) {
|
|
146
|
-
const t4 = e2.pseudo({ value: ":is", nodes: [e2.selector({ value: "", nodes: [n[o3]] })] });
|
|
147
|
-
t4.parent = s, s.nodes.unshift(t4);
|
|
148
|
-
} else n[o3].parent = s, s.nodes.unshift(n[o3]);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
function selectorTypeOrder(s, t2) {
|
|
152
|
-
return e2.isPseudoElement(s) ? o.pseudoElement : o[t2];
|
|
153
|
-
}
|
|
154
|
-
var o = { universal: 0, tag: 1, pseudoElement: 2, id: 3, class: 4, attribute: 5, pseudo: 6, selector: 7, string: 8, root: 9, comment: 10 };
|
|
155
|
-
function childAdjacentChild(e3) {
|
|
156
|
-
return !(!e3 || !e3.nodes) && ("selector" === e3.type && (3 === e3.nodes.length && (!(!e3.nodes[0] || "pseudo" !== e3.nodes[0].type || ":-csstools-matches" !== e3.nodes[0].value) && (!(!e3.nodes[1] || "combinator" !== e3.nodes[1].type || "+" !== e3.nodes[1].value && "~" !== e3.nodes[1].value) && (!(!e3.nodes[2] || "pseudo" !== e3.nodes[2].type || ":-csstools-matches" !== e3.nodes[2].value) && (!(!e3.nodes[0].nodes || 1 !== e3.nodes[0].nodes.length) && ("selector" === e3.nodes[0].nodes[0].type && (!(!e3.nodes[0].nodes[0].nodes || 3 !== e3.nodes[0].nodes[0].nodes.length) && (!(!e3.nodes[0].nodes[0].nodes || "combinator" !== e3.nodes[0].nodes[0].nodes[1].type || ">" !== e3.nodes[0].nodes[0].nodes[1].value) && (!(!e3.nodes[2].nodes || 1 !== e3.nodes[2].nodes.length) && ("selector" === e3.nodes[2].nodes[0].type && (!(!e3.nodes[2].nodes[0].nodes || 3 !== e3.nodes[2].nodes[0].nodes.length) && (!(!e3.nodes[2].nodes[0].nodes || "combinator" !== e3.nodes[2].nodes[0].nodes[1].type || ">" !== e3.nodes[2].nodes[0].nodes[1].value) && (e3.nodes[0].nodes[0].insertAfter(e3.nodes[0].nodes[0].nodes[0], e3.nodes[2].nodes[0].nodes[0].clone()), e3.nodes[2].nodes[0].nodes[1].remove(), e3.nodes[2].nodes[0].nodes[0].remove(), e3.nodes[0].replaceWith(e3.nodes[0].nodes[0]), e3.nodes[2].replaceWith(e3.nodes[2].nodes[0]), true))))))))))))));
|
|
157
|
-
}
|
|
158
|
-
function isInCompoundWithOneOtherElement(s) {
|
|
159
|
-
if (!s || !s.nodes) return false;
|
|
160
|
-
if (!e2.isSelector(s)) return false;
|
|
161
|
-
if (2 !== s.nodes.length) return false;
|
|
162
|
-
let o2 = -1, t2 = -1;
|
|
163
|
-
s.nodes[0] && e2.isPseudoClass(s.nodes[0]) && ":-csstools-matches" === s.nodes[0].value ? (o2 = 0, t2 = 1) : s.nodes[1] && e2.isPseudoClass(s.nodes[1]) && ":-csstools-matches" === s.nodes[1].value && (o2 = 1, t2 = 0);
|
|
164
|
-
const n = s.nodes[o2];
|
|
165
|
-
if (!n || !e2.isPseudoClass(n) || 1 !== n.nodes.length) return false;
|
|
166
|
-
const r = s.nodes[t2];
|
|
167
|
-
return !!r && (!e2.isCombinator(r) && (n.nodes[0].append(r.clone()), n.replaceWith(...n.nodes[0].nodes), r.remove(), true));
|
|
168
|
-
}
|
|
169
|
-
function isPseudoInFirstCompound(s) {
|
|
170
|
-
if (!s || !s.nodes) return false;
|
|
171
|
-
if (!e2.isSelector(s)) return false;
|
|
172
|
-
let o2 = -1;
|
|
173
|
-
for (let t3 = 0; t3 < s.nodes.length; t3++) {
|
|
174
|
-
const n2 = s.nodes[t3];
|
|
175
|
-
if (e2.isCombinator(n2)) return false;
|
|
176
|
-
if (e2.isPseudoClass(n2) && ":-csstools-matches" === n2.value) {
|
|
177
|
-
if (!n2.nodes || 1 !== n2.nodes.length) return false;
|
|
178
|
-
o2 = t3;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
const t2 = s.nodes[o2];
|
|
183
|
-
if (!t2 || !e2.isPseudoClass(t2)) return false;
|
|
184
|
-
const n = s.nodes.slice(0, o2), r = s.nodes.slice(o2 + 1);
|
|
185
|
-
return n.forEach((e3) => {
|
|
186
|
-
t2.nodes[0].append(e3.clone());
|
|
187
|
-
}), r.forEach((e3) => {
|
|
188
|
-
t2.nodes[0].append(e3.clone());
|
|
189
|
-
}), t2.replaceWith(...t2.nodes), n.forEach((e3) => {
|
|
190
|
-
e3.remove();
|
|
191
|
-
}), r.forEach((e3) => {
|
|
192
|
-
e3.remove();
|
|
193
|
-
}), true;
|
|
194
|
-
}
|
|
195
|
-
function complexSelectors(s, o2, t2, n) {
|
|
196
|
-
return s.flatMap((s2) => {
|
|
197
|
-
if (-1 === s2.indexOf(":-csstools-matches") && -1 === s2.toLowerCase().indexOf(":is")) return s2;
|
|
198
|
-
const r = e2().astSync(s2);
|
|
199
|
-
return r.walkPseudos((s3) => {
|
|
200
|
-
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());
|
|
201
|
-
if (":-csstools-matches" === s3.value) if (!s3.nodes || s3.nodes.length) {
|
|
202
|
-
if (s3.walkPseudos((s4) => {
|
|
203
|
-
if (e2.isPseudoElement(s4)) {
|
|
204
|
-
let e3 = s4.value;
|
|
205
|
-
if (e3.startsWith("::-csstools-invalid-")) return;
|
|
206
|
-
for (; e3.startsWith(":"); ) e3 = e3.slice(1);
|
|
207
|
-
s4.value = `::-csstools-invalid-${e3}`, n();
|
|
208
|
-
}
|
|
209
|
-
}), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
|
|
210
|
-
if (1 === s3.nodes[0].nodes.length) return void s3.replaceWith(s3.nodes[0].nodes[0]);
|
|
211
|
-
if (!s3.nodes[0].some((e3) => "combinator" === e3.type)) return void s3.replaceWith(...s3.nodes[0].nodes);
|
|
212
|
-
}
|
|
213
|
-
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 && t2(), s3.value = ":is") : s3.replaceWith(...s3.nodes[0].nodes);
|
|
214
|
-
} else s3.remove();
|
|
215
|
-
}), r.walk((e3) => {
|
|
216
|
-
"selector" === e3.type && "nodes" in e3 && 1 === e3.nodes.length && "selector" === e3.nodes[0].type && e3.replaceWith(e3.nodes[0]);
|
|
217
|
-
}), r.walk((e3) => {
|
|
218
|
-
"nodes" in e3 && sortCompoundSelectorsInsideComplexSelector(e3);
|
|
219
|
-
}), r.toString();
|
|
220
|
-
}).filter((e3) => !!e3);
|
|
221
|
-
}
|
|
222
|
-
function splitSelectors(o2, t2, n = 0) {
|
|
223
|
-
const r = ":not(#" + t2.specificityMatchingName + ")", d = ":not(." + t2.specificityMatchingName + ")", l = ":not(" + t2.specificityMatchingName + ")";
|
|
224
|
-
return o2.flatMap((o3) => {
|
|
225
|
-
if (-1 === o3.toLowerCase().indexOf(":is")) return o3;
|
|
226
|
-
let a = false;
|
|
227
|
-
const i = [];
|
|
228
|
-
if (e2().astSync(o3).walkPseudos((e3) => {
|
|
229
|
-
if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
|
|
230
|
-
if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
|
|
231
|
-
if ("pseudo" === e3.parent?.parent?.type && ":not" === e3.parent?.parent?.value?.toLowerCase()) return void i.push([{ start: e3.parent.parent.sourceIndex, end: e3.parent.parent.sourceIndex + e3.parent.parent.toString().length, option: `:not(${e3.nodes.toString()})` }]);
|
|
232
|
-
if ("pseudo" === e3.parent?.parent?.type && ":has" === e3.parent?.parent?.value?.toLowerCase()) return void (e3.value = ":-csstools-matches");
|
|
233
|
-
let o4 = e3.parent;
|
|
234
|
-
for (; o4; ) {
|
|
235
|
-
if (o4.value && ":is" === o4.value.toLowerCase() && "pseudo" === o4.type) return void (a = true);
|
|
236
|
-
o4 = o4.parent;
|
|
237
|
-
}
|
|
238
|
-
const t3 = selectorSpecificity(e3), n2 = e3.sourceIndex, c2 = n2 + e3.toString().length, p = [];
|
|
239
|
-
e3.nodes.forEach((e4) => {
|
|
240
|
-
const o5 = { start: n2, end: c2, option: "" }, a2 = selectorSpecificity(e4);
|
|
241
|
-
let i2 = e4.toString().trim();
|
|
242
|
-
const u = Math.max(0, t3.a - a2.a), h = Math.max(0, t3.b - a2.b), f = Math.max(0, t3.c - a2.c);
|
|
243
|
-
for (let e5 = 0; e5 < u; e5++) i2 += r;
|
|
244
|
-
for (let e5 = 0; e5 < h; e5++) i2 += d;
|
|
245
|
-
for (let e5 = 0; e5 < f; e5++) i2 += l;
|
|
246
|
-
o5.option = i2, p.push(o5);
|
|
247
|
-
}), i.push(p);
|
|
248
|
-
}), !i.length) return [o3];
|
|
249
|
-
let c = [];
|
|
250
|
-
return cartesianProduct(...i).forEach((e3) => {
|
|
251
|
-
let s = "";
|
|
252
|
-
for (let t3 = 0; t3 < e3.length; t3++) {
|
|
253
|
-
const n2 = e3[t3];
|
|
254
|
-
s += o3.substring(e3[t3 - 1]?.end || 0, e3[t3].start), s += ":-csstools-matches(" + n2.option + ")", t3 === e3.length - 1 && (s += o3.substring(e3[t3].end));
|
|
255
|
-
}
|
|
256
|
-
c.push(s);
|
|
257
|
-
}), a && n < 10 && (c = splitSelectors(c, t2, n + 1)), c;
|
|
258
|
-
}).filter((e3) => !!e3);
|
|
259
|
-
}
|
|
260
|
-
function cartesianProduct(...e3) {
|
|
261
|
-
const s = [], o2 = e3.length - 1;
|
|
262
|
-
return function helper(t2, n) {
|
|
263
|
-
for (let r = 0, d = e3[n].length; r < d; r++) {
|
|
264
|
-
const d2 = t2.slice(0);
|
|
265
|
-
d2.push(e3[n][r]), n === o2 ? s.push(d2) : helper(d2, n + 1);
|
|
266
|
-
}
|
|
267
|
-
}([], 0), s;
|
|
268
|
-
}
|
|
269
|
-
var t = /:is\(/i;
|
|
270
|
-
var creator = (e3) => {
|
|
271
|
-
const s = { specificityMatchingName: "does-not-exist", ...e3 || {} };
|
|
272
|
-
return { postcssPlugin: "postcss-is-pseudo-class", prepare() {
|
|
273
|
-
const e4 = /* @__PURE__ */ new WeakSet();
|
|
274
|
-
return { postcssPlugin: "postcss-is-pseudo-class", Rule(o2, { result: n }) {
|
|
275
|
-
if (!o2.selector) return;
|
|
276
|
-
if (!t.test(o2.selector)) return;
|
|
277
|
-
if (e4.has(o2)) return;
|
|
278
|
-
let r = false;
|
|
279
|
-
const warnOnComplexSelector = () => {
|
|
280
|
-
"warning" === s.onComplexSelector && (r || (r = true, o2.warn(n, `Complex selectors in '${o2.selector}' can not be transformed to an equivalent selector without ':is()'.`)));
|
|
281
|
-
};
|
|
282
|
-
let d = false;
|
|
283
|
-
const warnOnPseudoElements = () => {
|
|
284
|
-
"warning" === s.onPseudoElement && (d || (d = true, o2.warn(n, `Pseudo elements are not allowed in ':is()', unable to transform '${o2.selector}'`)));
|
|
285
|
-
};
|
|
286
|
-
try {
|
|
287
|
-
let t2 = false;
|
|
288
|
-
const n2 = [], r2 = complexSelectors(splitSelectors(o2.selectors, { specificityMatchingName: s.specificityMatchingName }), { onComplexSelector: s.onComplexSelector }, warnOnComplexSelector, warnOnPseudoElements);
|
|
289
|
-
if (Array.from(new Set(r2)).forEach((s2) => {
|
|
290
|
-
if (o2.selectors.indexOf(s2) > -1) n2.push(s2);
|
|
291
|
-
else {
|
|
292
|
-
if (alwaysValidSelector(s2)) return n2.push(s2), void (t2 = true);
|
|
293
|
-
e4.add(o2), o2.cloneBefore({ selector: s2 }), t2 = true;
|
|
294
|
-
}
|
|
295
|
-
}), n2.length && t2 && (e4.add(o2), o2.cloneBefore({ selectors: n2 })), !s.preserve) {
|
|
296
|
-
if (!t2) return;
|
|
297
|
-
o2.remove();
|
|
298
|
-
}
|
|
299
|
-
} catch (e5) {
|
|
300
|
-
if (!(e5 instanceof Error)) throw e5;
|
|
301
|
-
if (e5.message.indexOf("call stack size exceeded") > -1) throw e5;
|
|
302
|
-
o2.warn(n, `Failed to parse selector "${o2.selector}" with error: ${e5.message}`);
|
|
303
|
-
}
|
|
304
|
-
} };
|
|
305
|
-
} };
|
|
306
|
-
};
|
|
307
|
-
creator.postcss = true;
|
|
308
|
-
|
|
309
5
|
// src/plugins/index.ts
|
|
6
|
+
import postcssIsPseudoClass from "@csstools/postcss-is-pseudo-class";
|
|
310
7
|
import postcssRem2rpx from "postcss-rem-to-responsive-pixel";
|
|
311
8
|
|
|
312
9
|
// src/symbols.ts
|
|
@@ -819,14 +516,15 @@ var postcssWeappTailwindcssPrePlugin = (options = {
|
|
|
819
516
|
postcssWeappTailwindcssPrePlugin.postcss = true;
|
|
820
517
|
|
|
821
518
|
// src/plugins/index.ts
|
|
822
|
-
import { default as default2 } from "postcss-
|
|
519
|
+
import { default as default2 } from "@csstools/postcss-is-pseudo-class";
|
|
520
|
+
import { default as default3 } from "postcss-rem-to-responsive-pixel";
|
|
823
521
|
function getPlugins(options) {
|
|
824
522
|
const ctx = createContext();
|
|
825
523
|
options.ctx = ctx;
|
|
826
524
|
const plugins = [
|
|
827
525
|
...options.postcssOptions?.plugins ?? [],
|
|
828
526
|
postcssWeappTailwindcssPrePlugin(options),
|
|
829
|
-
|
|
527
|
+
postcssIsPseudoClass({
|
|
830
528
|
specificityMatchingName: "weapp-tw-ig"
|
|
831
529
|
})
|
|
832
530
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/postcss",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"description": "@weapp-tailwindcss/postcss",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,14 +33,15 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@csstools/postcss-is-pseudo-class": "^5.0.1",
|
|
36
37
|
"@weapp-core/escape": "~3.0.2",
|
|
37
38
|
"postcss": "~8.4.49",
|
|
38
39
|
"postcss-rem-to-responsive-pixel": "~6.0.2",
|
|
39
40
|
"postcss-selector-parser": "~7.0.0",
|
|
40
|
-
"@weapp-tailwindcss/shared": "0.0
|
|
41
|
+
"@weapp-tailwindcss/shared": "1.0.0-alpha.1"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@weapp-tailwindcss/mangle": "0.0
|
|
44
|
+
"@weapp-tailwindcss/mangle": "1.0.0-alpha.1"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
47
|
"dev": "tsup --watch --sourcemap",
|