weapp-tailwindcss 3.7.0 → 3.8.0-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 +1 -23
- package/dist/chunk-35CYTBPM.js +26 -0
- package/dist/chunk-6FNC3XMI.js +45 -0
- package/dist/chunk-6Z776ZWK.js +43 -0
- package/dist/chunk-75EWCRQW.mjs +13 -0
- package/dist/chunk-7J6ZENMS.js +216 -0
- package/dist/chunk-A2EDVNQK.mjs +173 -0
- package/dist/chunk-AB467PG7.mjs +43 -0
- package/dist/chunk-AXBFBHS2.mjs +45 -0
- package/dist/chunk-C7DFN4K3.js +152 -0
- package/dist/chunk-FYOOMUKL.js +115 -0
- package/dist/chunk-HBQASQKY.js +13 -0
- package/dist/chunk-JVPRWRPJ.mjs +115 -0
- package/dist/chunk-K7CL4YBQ.mjs +216 -0
- package/dist/chunk-KE7J6XFD.mjs +537 -0
- package/dist/chunk-LQN2VTMU.js +537 -0
- package/dist/chunk-MUJ65IQ3.mjs +26 -0
- package/dist/chunk-QJPVKPQS.js +1003 -0
- package/dist/chunk-RFNUATFD.js +24 -0
- package/dist/chunk-T4A3DCFN.mjs +152 -0
- package/dist/chunk-U7O2XXYR.mjs +24 -0
- package/dist/chunk-VFCTLSC3.mjs +1003 -0
- package/dist/chunk-VKSQ6BRD.mjs +27 -0
- package/dist/chunk-WMQLIT4T.js +173 -0
- package/dist/chunk-XSZXPWWL.js +27 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +23 -3400
- package/dist/cli.mjs +28 -3392
- package/dist/core.d.mts +27 -0
- package/dist/core.d.ts +23 -4
- package/dist/core.js +34 -56
- package/dist/core.mjs +36 -54
- package/dist/css-macro/postcss.d.mts +7 -0
- package/dist/css-macro/postcss.d.ts +5 -3
- package/dist/css-macro/postcss.js +54 -45
- package/dist/css-macro/postcss.mjs +54 -45
- package/dist/css-macro.d.mts +18 -0
- package/dist/css-macro.d.ts +18 -0
- package/dist/css-macro.js +40 -0
- package/dist/css-macro.mjs +38 -0
- package/dist/defaults.d.mts +16 -0
- package/dist/defaults.d.ts +16 -2
- package/dist/defaults.js +5 -9
- package/dist/defaults.mjs +8 -4
- package/dist/escape.d.mts +19 -0
- package/dist/escape.d.ts +19 -4
- package/dist/escape.js +11 -0
- package/dist/escape.mjs +11 -0
- package/dist/gulp.d.mts +26 -0
- package/dist/gulp.d.ts +26 -1
- package/dist/gulp.js +11 -36
- package/dist/gulp.mjs +14 -31
- package/dist/index-g4epDIUu.d.mts +534 -0
- package/dist/index-g4epDIUu.d.ts +534 -0
- package/dist/index.d.mts +17 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.js +22 -44
- package/dist/index.mjs +22 -34
- package/dist/postcss.d.mts +28 -0
- package/dist/postcss.d.ts +28 -1
- package/dist/postcss.js +9 -24
- package/dist/postcss.mjs +16 -8
- package/dist/replace.d.mts +22 -0
- package/dist/replace.d.ts +22 -3
- package/dist/replace.js +33 -50
- package/dist/replace.mjs +32 -25
- package/dist/shared-5ArEo9kL.d.mts +5 -0
- package/dist/shared-DI2Qz1ou.d.ts +5 -0
- package/dist/vite.d.mts +22 -0
- package/dist/vite.d.ts +22 -1
- package/dist/vite.js +11 -34
- package/dist/vite.mjs +14 -29
- package/dist/weapp-tw-runtime-loader.d.mts +7 -0
- package/dist/{bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts → weapp-tw-runtime-loader.d.ts} +4 -2
- package/dist/weapp-tw-runtime-loader.js +12 -12
- package/dist/weapp-tw-runtime-loader.mjs +12 -8
- package/dist/webpack.d.mts +26 -0
- package/dist/webpack.d.ts +26 -1
- package/dist/webpack.js +11 -35
- package/dist/webpack.mjs +14 -30
- package/dist/webpack4.d.mts +27 -0
- package/dist/webpack4.d.ts +27 -1
- package/dist/webpack4.js +204 -192
- package/dist/webpack4.mjs +210 -189
- package/package.json +26 -19
- package/dist/babel/index.d.ts +0 -5
- package/dist/bundlers/gulp/index.d.ts +0 -7
- package/dist/bundlers/vite/index.d.ts +0 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -8
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +0 -8
- package/dist/bundlers/webpack/index.d.ts +0 -1
- package/dist/cache/index.d.ts +0 -31
- package/dist/constants-CFM1J-h1.js +0 -42
- package/dist/constants-Dy2Dd3Fz.mjs +0 -36
- package/dist/constants.d.ts +0 -7
- package/dist/css-macro/constants.d.ts +0 -14
- package/dist/css-macro/index.d.ts +0 -15
- package/dist/css-macro/index.js +0 -36
- package/dist/css-macro/index.mjs +0 -30
- package/dist/debug/index.d.ts +0 -2
- package/dist/defaults-5A8JI2hW.mjs +0 -139
- package/dist/defaults-CdqzSWsR.js +0 -145
- package/dist/defu-Cdz2PomB.js +0 -60
- package/dist/defu-n46TJT6t.mjs +0 -57
- package/dist/env.d.ts +0 -2
- package/dist/extractors/split.d.ts +0 -3
- package/dist/index-BEIjgKpF.mjs +0 -11
- package/dist/index-BF8k8rHr.mjs +0 -517
- package/dist/index-BTXkyxen.js +0 -136
- package/dist/index-C0QsyqD6.mjs +0 -134
- package/dist/index-ClSBbhnm.js +0 -130
- package/dist/index-DoMb0-xW.mjs +0 -124
- package/dist/index-HC-Qkn0i.js +0 -17
- package/dist/index-h2-ZMO3S.js +0 -530
- package/dist/init.d.ts +0 -34
- package/dist/js/ast-grep.d.ts +0 -1
- package/dist/js/babel.d.ts +0 -3
- package/dist/js/handlers.d.ts +0 -11
- package/dist/js/index.d.ts +0 -7
- package/dist/logger.d.ts +0 -1
- package/dist/mangle/index.d.ts +0 -8
- package/dist/npm.d.ts +0 -22
- package/dist/options-Bv-1GQJY.js +0 -891
- package/dist/options-yXyCFCtr.mjs +0 -858
- package/dist/options.d.ts +0 -2
- package/dist/postcss/cssVars.d.ts +0 -5
- package/dist/postcss/index.d.ts +0 -4
- package/dist/postcss/mp.d.ts +0 -8
- package/dist/postcss/plugins/ctx.d.ts +0 -6
- package/dist/postcss/plugins/index.d.ts +0 -7
- package/dist/postcss/plugins/post.d.ts +0 -5
- package/dist/postcss/plugins/pre.d.ts +0 -5
- package/dist/postcss/preflight.d.ts +0 -3
- package/dist/postcss/selectorParser.d.ts +0 -6
- package/dist/postcss/shared.d.ts +0 -3
- package/dist/postcss/symbols.d.ts +0 -1
- package/dist/reg.d.ts +0 -1
- package/dist/shared-COWjpokr.mjs +0 -25
- package/dist/shared-r_GpWheO.js +0 -28
- package/dist/tailwindcss/patcher.d.ts +0 -3
- package/dist/types.d.ts +0 -165
- package/dist/utils.d.ts +0 -18
- package/dist/v5-DwFXG7m_.js +0 -181
- package/dist/v5-N5BYJ5JY.mjs +0 -174
- package/dist/wxml/Tokenizer.d.ts +0 -31
- package/dist/wxml/index.d.ts +0 -2
- package/dist/wxml/shared.d.ts +0 -2
- package/dist/wxml/utils.d.ts +0 -10
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
import {
|
|
2
|
+
composeIsPseudo,
|
|
3
|
+
internalCssSelectorReplacer
|
|
4
|
+
} from "./chunk-VKSQ6BRD.mjs";
|
|
5
|
+
|
|
6
|
+
// src/constants.ts
|
|
7
|
+
var postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
|
|
8
|
+
var pluginName = "weapp-tailwindcss-webpack-plugin";
|
|
9
|
+
var vitePluginName = "vite-plugin-uni-app-weapp-tailwindcss-adaptor";
|
|
10
|
+
var WEAPP_TW_REQUIRED_NODE_VERSION = "18.17.0";
|
|
11
|
+
|
|
12
|
+
// src/postcss/selectorParser.ts
|
|
13
|
+
import selectorParser from "postcss-selector-parser";
|
|
14
|
+
function createRuleTransform(rule, options) {
|
|
15
|
+
const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
|
|
16
|
+
const transform = (selectors) => {
|
|
17
|
+
selectors.walk((selector) => {
|
|
18
|
+
if (selector.type === "universal" && (cssSelectorReplacement == null ? void 0 : cssSelectorReplacement.universal)) {
|
|
19
|
+
selector.value = composeIsPseudo(cssSelectorReplacement.universal);
|
|
20
|
+
}
|
|
21
|
+
if (cssRemoveHoverPseudoClass && selector.type === "selector") {
|
|
22
|
+
const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
|
|
23
|
+
if (node) {
|
|
24
|
+
selector.remove();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (selector.type === "pseudo" && selector.value === ":root" && (cssSelectorReplacement == null ? void 0 : cssSelectorReplacement.root)) {
|
|
28
|
+
selector.value = composeIsPseudo(cssSelectorReplacement.root);
|
|
29
|
+
}
|
|
30
|
+
if (selector.type === "class") {
|
|
31
|
+
selector.value = internalCssSelectorReplacer(selector.value, {
|
|
32
|
+
escapeMap,
|
|
33
|
+
mangleContext
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (selectors.length === 0) {
|
|
38
|
+
rule.remove();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return transform;
|
|
42
|
+
}
|
|
43
|
+
function getRuleTransformer(rule, options) {
|
|
44
|
+
return selectorParser(createRuleTransform(rule, options));
|
|
45
|
+
}
|
|
46
|
+
function ruleTransformSync(rule, options) {
|
|
47
|
+
const transformer = getRuleTransformer(rule, options);
|
|
48
|
+
return transformer.transformSync(rule, {
|
|
49
|
+
lossless: false,
|
|
50
|
+
updateSelector: true
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function isOnlyBeforeAndAfterPseudoElement(node) {
|
|
54
|
+
let b = false;
|
|
55
|
+
let a = false;
|
|
56
|
+
selectorParser((selectors) => {
|
|
57
|
+
selectors.walkPseudos((s) => {
|
|
58
|
+
var _a;
|
|
59
|
+
if (((_a = s.parent) == null ? void 0 : _a.length) === 1) {
|
|
60
|
+
if (/^:?:before$/.test(s.value)) {
|
|
61
|
+
b = true;
|
|
62
|
+
}
|
|
63
|
+
if (/^:?:after$/.test(s.value)) {
|
|
64
|
+
a = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}).astSync(node);
|
|
69
|
+
return b && a;
|
|
70
|
+
}
|
|
71
|
+
var fallbackRemove = selectorParser((selectors) => {
|
|
72
|
+
let maybeImportantId = false;
|
|
73
|
+
selectors.walk((selector, idx) => {
|
|
74
|
+
var _a, _b, _c;
|
|
75
|
+
if (idx === 0 && (selector.type === "id" || selector.type === "class" || selector.type === "attribute")) {
|
|
76
|
+
maybeImportantId = true;
|
|
77
|
+
}
|
|
78
|
+
if (selector.type === "universal") {
|
|
79
|
+
(_a = selector.parent) == null ? void 0 : _a.remove();
|
|
80
|
+
}
|
|
81
|
+
if (selector.type === "pseudo" && selector.value === ":is") {
|
|
82
|
+
if (maybeImportantId && ((_b = selector.nodes[0]) == null ? void 0 : _b.type) === "selector") {
|
|
83
|
+
selector.replaceWith(selector.nodes[0]);
|
|
84
|
+
} else {
|
|
85
|
+
(_c = selector.parent) == null ? void 0 : _c.remove();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// src/postcss/plugins/post.ts
|
|
92
|
+
var postcssWeappTailwindcssPostPlugin = (options = {
|
|
93
|
+
isMainChunk: true
|
|
94
|
+
}) => {
|
|
95
|
+
const { customRuleCallback, isMainChunk } = options;
|
|
96
|
+
const p = {
|
|
97
|
+
postcssPlugin
|
|
98
|
+
};
|
|
99
|
+
if (isMainChunk) {
|
|
100
|
+
p.OnceExit = (root) => {
|
|
101
|
+
root.walkRules((rule) => {
|
|
102
|
+
fallbackRemove.transformSync(rule, {
|
|
103
|
+
updateSelector: true,
|
|
104
|
+
lossless: false
|
|
105
|
+
});
|
|
106
|
+
if (rule.selectors.length === 0 || rule.selectors.length === 1 && rule.selector.trim() === "") {
|
|
107
|
+
rule.remove();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (typeof customRuleCallback === "function") {
|
|
113
|
+
p.Rule = (rule) => {
|
|
114
|
+
customRuleCallback(rule, options);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return p;
|
|
118
|
+
};
|
|
119
|
+
postcssWeappTailwindcssPostPlugin.postcss = true;
|
|
120
|
+
|
|
121
|
+
// src/postcss/mp.ts
|
|
122
|
+
import { Declaration, Rule } from "postcss";
|
|
123
|
+
|
|
124
|
+
// src/postcss/cssVars.ts
|
|
125
|
+
var cssVars_default = [
|
|
126
|
+
{
|
|
127
|
+
prop: "--tw-border-spacing-x",
|
|
128
|
+
value: "0"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
prop: "--tw-border-spacing-y",
|
|
132
|
+
value: "0"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
prop: "--tw-translate-x",
|
|
136
|
+
value: "0"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
prop: "--tw-translate-y",
|
|
140
|
+
value: "0"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
prop: "--tw-rotate",
|
|
144
|
+
value: "0"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
prop: "--tw-skew-x",
|
|
148
|
+
value: "0"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
prop: "--tw-skew-y",
|
|
152
|
+
value: "0"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
prop: "--tw-scale-x",
|
|
156
|
+
value: "1"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
prop: "--tw-scale-y",
|
|
160
|
+
value: "1"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
prop: "--tw-pan-x",
|
|
164
|
+
value: " "
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
prop: "--tw-pan-y",
|
|
168
|
+
value: " "
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
prop: "--tw-pinch-zoom",
|
|
172
|
+
value: " "
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
prop: "--tw-scroll-snap-strictness",
|
|
176
|
+
value: "proximity"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
prop: "--tw-gradient-from-position",
|
|
180
|
+
value: " "
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
prop: "--tw-gradient-via-position",
|
|
184
|
+
value: " "
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
prop: "--tw-gradient-to-position",
|
|
188
|
+
value: " "
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
prop: "--tw-ordinal",
|
|
192
|
+
value: " "
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
prop: "--tw-slashed-zero",
|
|
196
|
+
value: " "
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
prop: "--tw-numeric-figure",
|
|
200
|
+
value: " "
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
prop: "--tw-numeric-spacing",
|
|
204
|
+
value: " "
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
prop: "--tw-numeric-fraction",
|
|
208
|
+
value: " "
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
prop: "--tw-ring-inset",
|
|
212
|
+
value: " "
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
prop: "--tw-ring-offset-width",
|
|
216
|
+
value: "0px"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
prop: "--tw-ring-offset-color",
|
|
220
|
+
value: "#fff"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
prop: "--tw-ring-color",
|
|
224
|
+
value: "rgb(59 130 246 / 0.5)"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
prop: "--tw-ring-offset-shadow",
|
|
228
|
+
value: "0 0 #0000"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
prop: "--tw-ring-shadow",
|
|
232
|
+
value: "0 0 #0000"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
prop: "--tw-shadow",
|
|
236
|
+
value: "0 0 #0000"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
prop: "--tw-shadow-colored",
|
|
240
|
+
value: "0 0 #0000"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
prop: "--tw-blur",
|
|
244
|
+
value: " "
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
prop: "--tw-brightness",
|
|
248
|
+
value: " "
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
prop: "--tw-contrast",
|
|
252
|
+
value: " "
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
prop: "--tw-grayscale",
|
|
256
|
+
value: " "
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
prop: "--tw-hue-rotate",
|
|
260
|
+
value: " "
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
prop: "--tw-invert",
|
|
264
|
+
value: " "
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
prop: "--tw-saturate",
|
|
268
|
+
value: " "
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
prop: "--tw-sepia",
|
|
272
|
+
value: " "
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
prop: "--tw-drop-shadow",
|
|
276
|
+
value: " "
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
prop: "--tw-backdrop-blur",
|
|
280
|
+
value: " "
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
prop: "--tw-backdrop-brightness",
|
|
284
|
+
value: " "
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
prop: "--tw-backdrop-contrast",
|
|
288
|
+
value: " "
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
prop: "--tw-backdrop-grayscale",
|
|
292
|
+
value: " "
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
prop: "--tw-backdrop-hue-rotate",
|
|
296
|
+
value: " "
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
prop: "--tw-backdrop-invert",
|
|
300
|
+
value: " "
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
prop: "--tw-backdrop-opacity",
|
|
304
|
+
value: " "
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
prop: "--tw-backdrop-saturate",
|
|
308
|
+
value: " "
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
prop: "--tw-backdrop-sepia",
|
|
312
|
+
value: " "
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
prop: "--tw-contain-size",
|
|
316
|
+
value: " "
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
prop: "--tw-contain-layout",
|
|
320
|
+
value: " "
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
prop: "--tw-contain-paint",
|
|
324
|
+
value: " "
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
prop: "--tw-contain-style",
|
|
328
|
+
value: " "
|
|
329
|
+
}
|
|
330
|
+
];
|
|
331
|
+
|
|
332
|
+
// src/postcss/mp.ts
|
|
333
|
+
var initialNodes = cssVars_default.map((x) => {
|
|
334
|
+
return new Declaration({
|
|
335
|
+
prop: x.prop,
|
|
336
|
+
value: x.value
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
var PATTERNS = [
|
|
340
|
+
/:not\(template\)\s*[~+]\s*:not\(template\)/.source,
|
|
341
|
+
/:not\(\[hidden\]\)\s*[~+]\s*:not\(\[hidden\]\)/.source
|
|
342
|
+
].join("|");
|
|
343
|
+
var BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, "g");
|
|
344
|
+
function testIfVariablesScope(node, count = 2) {
|
|
345
|
+
if (isOnlyBeforeAndAfterPseudoElement(node)) {
|
|
346
|
+
const nodes = node.nodes;
|
|
347
|
+
let c = 0;
|
|
348
|
+
for (const tryTestDecl of nodes) {
|
|
349
|
+
if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
|
|
350
|
+
c++;
|
|
351
|
+
}
|
|
352
|
+
if (c >= count) {
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
function testIfTwBackdrop(node, count = 2) {
|
|
361
|
+
if (node.type === "rule" && node.selector === "::backdrop") {
|
|
362
|
+
const nodes = node.nodes;
|
|
363
|
+
let c = 0;
|
|
364
|
+
for (const tryTestDecl of nodes) {
|
|
365
|
+
if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
|
|
366
|
+
c++;
|
|
367
|
+
}
|
|
368
|
+
if (c >= count) {
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
function makePseudoVarRule() {
|
|
377
|
+
const pseudoVarRule = new Rule({
|
|
378
|
+
// selectors: ['::before', '::after'],
|
|
379
|
+
selector: "::before,::after"
|
|
380
|
+
});
|
|
381
|
+
pseudoVarRule.append(
|
|
382
|
+
new Declaration({
|
|
383
|
+
prop: "--tw-content",
|
|
384
|
+
value: '""'
|
|
385
|
+
})
|
|
386
|
+
);
|
|
387
|
+
return pseudoVarRule;
|
|
388
|
+
}
|
|
389
|
+
function remakeCssVarSelector(selectors, options) {
|
|
390
|
+
const { cssPreflightRange, cssSelectorReplacement } = options;
|
|
391
|
+
if (cssPreflightRange === "all" && !selectors.includes(":not(not)")) {
|
|
392
|
+
selectors.push(":not(not)");
|
|
393
|
+
}
|
|
394
|
+
if (cssSelectorReplacement) {
|
|
395
|
+
if (Array.isArray(cssSelectorReplacement.universal)) {
|
|
396
|
+
if (!cssSelectorReplacement.universal.every((x) => {
|
|
397
|
+
return selectors.includes(x);
|
|
398
|
+
}) && !selectors.includes("*")) {
|
|
399
|
+
selectors.unshift("*");
|
|
400
|
+
}
|
|
401
|
+
} else if (typeof cssSelectorReplacement.universal === "string" && !selectors.includes(cssSelectorReplacement.universal) && !selectors.includes("*")) {
|
|
402
|
+
selectors.unshift("*");
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return selectors;
|
|
406
|
+
}
|
|
407
|
+
function remakeCombinatorSelector(selector, cssChildCombinatorReplaceValue) {
|
|
408
|
+
let childCombinatorReplaceValue = "view + view";
|
|
409
|
+
if (Array.isArray(cssChildCombinatorReplaceValue) && cssChildCombinatorReplaceValue.length > 0) {
|
|
410
|
+
const x = composeIsPseudo(cssChildCombinatorReplaceValue);
|
|
411
|
+
childCombinatorReplaceValue = `${x} + ${x}`;
|
|
412
|
+
} else if (typeof cssChildCombinatorReplaceValue === "string") {
|
|
413
|
+
childCombinatorReplaceValue = cssChildCombinatorReplaceValue;
|
|
414
|
+
}
|
|
415
|
+
return selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
|
|
416
|
+
}
|
|
417
|
+
function commonChunkPreflight(node, options) {
|
|
418
|
+
const { ctx, cssChildCombinatorReplaceValue, cssInjectPreflight, injectAdditionalCssVarScope } = options;
|
|
419
|
+
node.selector = remakeCombinatorSelector(node.selector, cssChildCombinatorReplaceValue);
|
|
420
|
+
if (testIfVariablesScope(node)) {
|
|
421
|
+
ctx == null ? void 0 : ctx.markVariablesScope(node);
|
|
422
|
+
node.selectors = remakeCssVarSelector(node.selectors, options);
|
|
423
|
+
node.before(makePseudoVarRule());
|
|
424
|
+
if (typeof cssInjectPreflight === "function") {
|
|
425
|
+
node.append(...cssInjectPreflight());
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (injectAdditionalCssVarScope && testIfTwBackdrop(node)) {
|
|
429
|
+
const syntheticRule = new Rule({
|
|
430
|
+
selectors: ["*", "::after", "::before"],
|
|
431
|
+
nodes: initialNodes
|
|
432
|
+
});
|
|
433
|
+
syntheticRule.selectors = remakeCssVarSelector(syntheticRule.selectors, options);
|
|
434
|
+
node.before(syntheticRule);
|
|
435
|
+
node.before(makePseudoVarRule());
|
|
436
|
+
if (typeof cssInjectPreflight === "function") {
|
|
437
|
+
syntheticRule.append(...cssInjectPreflight());
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// src/postcss/plugins/pre.ts
|
|
443
|
+
function isAtMediaHover(atRule) {
|
|
444
|
+
return /media\(\s*hover\s*:\s*hover\s*\)/.test(atRule.name) || atRule.name === "media" && /\(\s*hover\s*:\s*hover\s*\)/.test(atRule.params);
|
|
445
|
+
}
|
|
446
|
+
var postcssWeappTailwindcssPrePlugin = (options = {
|
|
447
|
+
isMainChunk: true
|
|
448
|
+
}) => {
|
|
449
|
+
const { isMainChunk } = options;
|
|
450
|
+
const p = {
|
|
451
|
+
postcssPlugin,
|
|
452
|
+
Rule(rule) {
|
|
453
|
+
ruleTransformSync(rule, options);
|
|
454
|
+
},
|
|
455
|
+
AtRule(atRule) {
|
|
456
|
+
if (isAtMediaHover(atRule)) {
|
|
457
|
+
if (atRule.nodes) {
|
|
458
|
+
atRule.replaceWith(atRule.nodes);
|
|
459
|
+
} else {
|
|
460
|
+
atRule.remove();
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
if (isMainChunk) {
|
|
466
|
+
p.Once = (root) => {
|
|
467
|
+
root.walkRules((rule) => {
|
|
468
|
+
commonChunkPreflight(rule, options);
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
return p;
|
|
473
|
+
};
|
|
474
|
+
postcssWeappTailwindcssPrePlugin.postcss = true;
|
|
475
|
+
|
|
476
|
+
// src/postcss/plugins/index.ts
|
|
477
|
+
import postcssIsPseudoClass from "@csstools/postcss-is-pseudo-class";
|
|
478
|
+
import postcssRem2rpx from "postcss-rem-to-responsive-pixel";
|
|
479
|
+
|
|
480
|
+
// src/postcss/symbols.ts
|
|
481
|
+
var VariablesScopeSymbol = Symbol("VariablesScope");
|
|
482
|
+
|
|
483
|
+
// src/postcss/plugins/ctx.ts
|
|
484
|
+
function createContext() {
|
|
485
|
+
const variablesScopeWeakMap = /* @__PURE__ */ new WeakMap();
|
|
486
|
+
function isVariablesScope(rule) {
|
|
487
|
+
return variablesScopeWeakMap.get(rule) === VariablesScopeSymbol;
|
|
488
|
+
}
|
|
489
|
+
function markVariablesScope(rule) {
|
|
490
|
+
variablesScopeWeakMap.set(rule, VariablesScopeSymbol);
|
|
491
|
+
}
|
|
492
|
+
return {
|
|
493
|
+
variablesScopeWeakMap,
|
|
494
|
+
isVariablesScope,
|
|
495
|
+
markVariablesScope
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// src/postcss/plugins/index.ts
|
|
500
|
+
import { default as default2 } from "@csstools/postcss-is-pseudo-class";
|
|
501
|
+
import { default as default3 } from "postcss-rem-to-responsive-pixel";
|
|
502
|
+
function getPlugins(options) {
|
|
503
|
+
var _a, _b;
|
|
504
|
+
const ctx = createContext();
|
|
505
|
+
options.ctx = ctx;
|
|
506
|
+
const plugins = [
|
|
507
|
+
...(_b = (_a = options.postcssOptions) == null ? void 0 : _a.plugins) != null ? _b : [],
|
|
508
|
+
postcssWeappTailwindcssPrePlugin(options),
|
|
509
|
+
postcssIsPseudoClass({
|
|
510
|
+
specificityMatchingName: "weapp-tw-ig"
|
|
511
|
+
})
|
|
512
|
+
];
|
|
513
|
+
if (options.rem2rpx) {
|
|
514
|
+
plugins.push(
|
|
515
|
+
postcssRem2rpx(
|
|
516
|
+
typeof options.rem2rpx === "object" ? options.rem2rpx : {
|
|
517
|
+
rootValue: 32,
|
|
518
|
+
propList: ["*"],
|
|
519
|
+
transformUnit: "rpx"
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
plugins.push(postcssWeappTailwindcssPostPlugin(options));
|
|
525
|
+
return plugins;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
export {
|
|
529
|
+
pluginName,
|
|
530
|
+
vitePluginName,
|
|
531
|
+
WEAPP_TW_REQUIRED_NODE_VERSION,
|
|
532
|
+
postcssWeappTailwindcssPostPlugin,
|
|
533
|
+
postcssWeappTailwindcssPrePlugin,
|
|
534
|
+
getPlugins,
|
|
535
|
+
default2 as default,
|
|
536
|
+
default3 as default2
|
|
537
|
+
};
|