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