weapp-tailwindcss 2.4.4 → 2.6.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 +2 -8
- package/dist/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/constants.d.ts +1 -1
- package/dist/gulp.js +9 -7
- package/dist/gulp.mjs +9 -7
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{options-887b74ca.js → options-487394fa.js} +50 -36
- package/dist/{options-879de0a2.mjs → options-f7b71f03.mjs} +50 -36
- package/dist/postcss/cssVars.d.ts +5 -0
- package/dist/postcss/mp.d.ts +4 -0
- package/dist/postcss-760298ba.mjs +351 -0
- package/dist/postcss-b53e9504.js +359 -0
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/reg.d.ts +1 -1
- package/dist/types.d.ts +8 -3
- package/dist/vite.js +8 -6
- package/dist/vite.mjs +8 -6
- package/dist/weapp-tw-runtime-loader.js +16 -0
- package/dist/weapp-tw-runtime-loader.mjs +10 -0
- package/dist/webpack/BaseUnifiedPlugin/v5.d.ts +0 -1
- package/dist/webpack/loaders/weapp-tw-runtime-loader.d.ts +5 -0
- package/dist/webpack.js +36 -19
- package/dist/webpack.mjs +31 -19
- package/dist/wxml/index.d.ts +1 -1
- package/dist/wxml/utils.d.ts +2 -2
- package/package.json +39 -32
- package/dist/postcss-33ef0bd0.js +0 -125
- package/dist/postcss-ea625621.mjs +0 -116
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import selectorParser from 'postcss-selector-parser';
|
|
2
|
+
import { i as internalCssSelectorReplacer } from './shared-7c88fb94.mjs';
|
|
3
|
+
import { Declaration, Rule } from 'postcss';
|
|
4
|
+
import '@csstools/postcss-is-pseudo-class';
|
|
5
|
+
|
|
6
|
+
const createTransform = (rule, options) => {
|
|
7
|
+
const { replaceUniversalSelectorWith, escapeMap, mangleContext } = options;
|
|
8
|
+
const replaceFlag = replaceUniversalSelectorWith !== false;
|
|
9
|
+
const transform = (selectors) => {
|
|
10
|
+
selectors.walk((selector) => {
|
|
11
|
+
if (selector.type === 'universal' && replaceFlag) {
|
|
12
|
+
selector.value = replaceUniversalSelectorWith;
|
|
13
|
+
}
|
|
14
|
+
if (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 === 'class') {
|
|
19
|
+
selector.value = internalCssSelectorReplacer(selector.value, {
|
|
20
|
+
escapeMap,
|
|
21
|
+
mangleContext
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (selectors.length === 0) {
|
|
26
|
+
rule.remove();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return transform;
|
|
30
|
+
};
|
|
31
|
+
const getTransformer = (rule, options) => {
|
|
32
|
+
return selectorParser(createTransform(rule, options));
|
|
33
|
+
};
|
|
34
|
+
const transformSync = (rule, options) => {
|
|
35
|
+
const transformer = getTransformer(rule, options);
|
|
36
|
+
return transformer.transformSync(rule, {
|
|
37
|
+
lossless: false,
|
|
38
|
+
updateSelector: true
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var cssVars = [
|
|
43
|
+
{
|
|
44
|
+
prop: '--tw-border-spacing-x',
|
|
45
|
+
value: '0'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
prop: '--tw-border-spacing-y',
|
|
49
|
+
value: '0'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
prop: '--tw-translate-x',
|
|
53
|
+
value: '0'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
prop: '--tw-translate-y',
|
|
57
|
+
value: '0'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
prop: '--tw-rotate',
|
|
61
|
+
value: '0'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
prop: '--tw-skew-x',
|
|
65
|
+
value: '0'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
prop: '--tw-skew-y',
|
|
69
|
+
value: '0'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
prop: '--tw-scale-x',
|
|
73
|
+
value: '1'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
prop: '--tw-scale-y',
|
|
77
|
+
value: '1'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
prop: '--tw-pan-x',
|
|
81
|
+
value: ' '
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
prop: '--tw-pan-y',
|
|
85
|
+
value: ' '
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
prop: '--tw-pinch-zoom',
|
|
89
|
+
value: ' '
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
prop: '--tw-scroll-snap-strictness',
|
|
93
|
+
value: 'proximity'
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
prop: '--tw-gradient-from-position',
|
|
97
|
+
value: ' '
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
prop: '--tw-gradient-via-position',
|
|
101
|
+
value: ' '
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
prop: '--tw-gradient-to-position',
|
|
105
|
+
value: ' '
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
prop: '--tw-ordinal',
|
|
109
|
+
value: ' '
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
prop: '--tw-slashed-zero',
|
|
113
|
+
value: ' '
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
prop: '--tw-numeric-figure',
|
|
117
|
+
value: ' '
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
prop: '--tw-numeric-spacing',
|
|
121
|
+
value: ' '
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
prop: '--tw-numeric-fraction',
|
|
125
|
+
value: ' '
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
prop: '--tw-ring-inset',
|
|
129
|
+
value: ' '
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
prop: '--tw-ring-offset-width',
|
|
133
|
+
value: '0rpx'
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
prop: '--tw-ring-offset-color',
|
|
137
|
+
value: '#fff'
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
prop: '--tw-ring-color',
|
|
141
|
+
value: 'rgba(59, 130, 246, 0.5)'
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
prop: '--tw-ring-offset-shadow',
|
|
145
|
+
value: '0 0 #0000'
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
prop: '--tw-ring-shadow',
|
|
149
|
+
value: '0 0 #0000'
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
prop: '--tw-shadow',
|
|
153
|
+
value: '0 0 #0000'
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
prop: '--tw-shadow-colored',
|
|
157
|
+
value: '0 0 #0000'
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
prop: '--tw-blur',
|
|
161
|
+
value: ' '
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
prop: '--tw-brightness',
|
|
165
|
+
value: ' '
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
prop: '--tw-contrast',
|
|
169
|
+
value: ' '
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
prop: '--tw-grayscale',
|
|
173
|
+
value: ' '
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
prop: '--tw-hue-rotate',
|
|
177
|
+
value: ' '
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
prop: '--tw-invert',
|
|
181
|
+
value: ' '
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
prop: '--tw-saturate',
|
|
185
|
+
value: ' '
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
prop: '--tw-sepia',
|
|
189
|
+
value: ' '
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
prop: '--tw-drop-shadow',
|
|
193
|
+
value: ' '
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
prop: '--tw-backdrop-blur',
|
|
197
|
+
value: ' '
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
prop: '--tw-backdrop-brightness',
|
|
201
|
+
value: ' '
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
prop: '--tw-backdrop-contrast',
|
|
205
|
+
value: ' '
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
prop: '--tw-backdrop-grayscale',
|
|
209
|
+
value: ' '
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
prop: '--tw-backdrop-hue-rotate',
|
|
213
|
+
value: ' '
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
prop: '--tw-backdrop-invert',
|
|
217
|
+
value: ' '
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
prop: '--tw-backdrop-opacity',
|
|
221
|
+
value: ' '
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
prop: '--tw-backdrop-saturate',
|
|
225
|
+
value: ' '
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
prop: '--tw-backdrop-sepia',
|
|
229
|
+
value: ' '
|
|
230
|
+
}
|
|
231
|
+
];
|
|
232
|
+
|
|
233
|
+
const initialNodes = cssVars.map((x) => {
|
|
234
|
+
return new Declaration({
|
|
235
|
+
prop: x.prop,
|
|
236
|
+
value: x.value
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
const PATTERNS = [/:not\(template\)\s*~\s*:not\(template\)/.source, /:not\(\[hidden\]\)\s*~\s*:not\(\[hidden\]\)/.source].join('|');
|
|
240
|
+
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
241
|
+
function testIfVariablesScope(node, count = 1) {
|
|
242
|
+
if (/:?:before/.test(node.selector) && /:?:after/.test(node.selector)) {
|
|
243
|
+
for (let i = 0; i < count; i++) {
|
|
244
|
+
const tryTestDecl = node.nodes[i];
|
|
245
|
+
if (tryTestDecl && tryTestDecl.type === 'decl' && tryTestDecl.prop.startsWith('--tw-')) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
function testIfTwBackdrop(node, count = 1) {
|
|
257
|
+
if (node.type === 'rule' && node.selector === '::backdrop') {
|
|
258
|
+
for (let i = 0; i < count; i++) {
|
|
259
|
+
const tryTestDecl = node.nodes[i];
|
|
260
|
+
if (tryTestDecl && tryTestDecl.type === 'decl' && tryTestDecl.prop.startsWith('--tw-')) {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
function makePseudoVarRule() {
|
|
272
|
+
const pseudoVarRule = new Rule({
|
|
273
|
+
selector: '::before,::after'
|
|
274
|
+
});
|
|
275
|
+
pseudoVarRule.append(new Declaration({
|
|
276
|
+
prop: '--tw-content',
|
|
277
|
+
value: '""'
|
|
278
|
+
}));
|
|
279
|
+
return pseudoVarRule;
|
|
280
|
+
}
|
|
281
|
+
function remakeCssVarSelector(selectors, cssPreflightRange) {
|
|
282
|
+
const idx = selectors.indexOf('*');
|
|
283
|
+
if (idx > -1) {
|
|
284
|
+
selectors.splice(idx, 1);
|
|
285
|
+
}
|
|
286
|
+
if (!selectors.includes('view')) {
|
|
287
|
+
selectors.push('view');
|
|
288
|
+
}
|
|
289
|
+
if (cssPreflightRange === 'all' &&
|
|
290
|
+
!selectors.includes(':not(not)')) {
|
|
291
|
+
selectors.push(':not(not)');
|
|
292
|
+
}
|
|
293
|
+
return selectors;
|
|
294
|
+
}
|
|
295
|
+
function remakeCombinatorSelector(selector, cssChildCombinatorReplaceValue) {
|
|
296
|
+
let childCombinatorReplaceValue = 'view + view';
|
|
297
|
+
if (Array.isArray(cssChildCombinatorReplaceValue)) {
|
|
298
|
+
const part = cssChildCombinatorReplaceValue.join(',');
|
|
299
|
+
childCombinatorReplaceValue = [part, ' + ', part].join('');
|
|
300
|
+
}
|
|
301
|
+
else if (typeof cssChildCombinatorReplaceValue === 'string') {
|
|
302
|
+
childCombinatorReplaceValue = cssChildCombinatorReplaceValue;
|
|
303
|
+
}
|
|
304
|
+
return selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
|
|
305
|
+
}
|
|
306
|
+
function commonChunkPreflight(node, options) {
|
|
307
|
+
node.selector = remakeCombinatorSelector(node.selector, options.cssChildCombinatorReplaceValue);
|
|
308
|
+
if (testIfVariablesScope(node)) {
|
|
309
|
+
node.selectors = remakeCssVarSelector(node.selectors, options.cssPreflightRange);
|
|
310
|
+
node.before(makePseudoVarRule());
|
|
311
|
+
if (typeof options.cssInjectPreflight === 'function') {
|
|
312
|
+
node.append(...options.cssInjectPreflight());
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (options.injectAdditionalCssVarScope && testIfTwBackdrop(node)) {
|
|
316
|
+
const syntheticRule = new Rule({
|
|
317
|
+
selectors: ['::after', '::before'],
|
|
318
|
+
nodes: initialNodes
|
|
319
|
+
});
|
|
320
|
+
syntheticRule.selectors = remakeCssVarSelector(syntheticRule.selectors, options.cssPreflightRange);
|
|
321
|
+
node.before(syntheticRule);
|
|
322
|
+
node.before(makePseudoVarRule());
|
|
323
|
+
if (typeof options.cssInjectPreflight === 'function') {
|
|
324
|
+
syntheticRule.append(...options.cssInjectPreflight());
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
330
|
+
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
331
|
+
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
332
|
+
|
|
333
|
+
const postcssWeappTailwindcss = (options = {
|
|
334
|
+
isMainChunk: true
|
|
335
|
+
}) => {
|
|
336
|
+
const { customRuleCallback, isMainChunk } = options;
|
|
337
|
+
const flag = typeof customRuleCallback === 'function';
|
|
338
|
+
return {
|
|
339
|
+
postcssPlugin,
|
|
340
|
+
Once(css) {
|
|
341
|
+
css.walkRules((rule) => {
|
|
342
|
+
transformSync(rule, options);
|
|
343
|
+
isMainChunk && commonChunkPreflight(rule, options);
|
|
344
|
+
flag && customRuleCallback(rule, options);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
postcssWeappTailwindcss.postcss = true;
|
|
350
|
+
|
|
351
|
+
export { pluginName as a, postcssWeappTailwindcss as p, vitePluginName as v };
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var selectorParser = require('postcss-selector-parser');
|
|
4
|
+
var shared = require('./shared-ae7dd073.js');
|
|
5
|
+
var postcss = require('postcss');
|
|
6
|
+
require('@csstools/postcss-is-pseudo-class');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var selectorParser__default = /*#__PURE__*/_interopDefaultCompat(selectorParser);
|
|
11
|
+
|
|
12
|
+
const createTransform = (rule, options) => {
|
|
13
|
+
const { replaceUniversalSelectorWith, escapeMap, mangleContext } = options;
|
|
14
|
+
const replaceFlag = replaceUniversalSelectorWith !== false;
|
|
15
|
+
const transform = (selectors) => {
|
|
16
|
+
selectors.walk((selector) => {
|
|
17
|
+
if (selector.type === 'universal' && replaceFlag) {
|
|
18
|
+
selector.value = replaceUniversalSelectorWith;
|
|
19
|
+
}
|
|
20
|
+
if (selector.type === 'selector') {
|
|
21
|
+
const node = selector.nodes.find((x) => x.type === 'pseudo' && x.value === ':hover');
|
|
22
|
+
node && selector.remove();
|
|
23
|
+
}
|
|
24
|
+
if (selector.type === 'class') {
|
|
25
|
+
selector.value = shared.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
|
+
const getTransformer = (rule, options) => {
|
|
38
|
+
return selectorParser__default["default"](createTransform(rule, options));
|
|
39
|
+
};
|
|
40
|
+
const transformSync = (rule, options) => {
|
|
41
|
+
const transformer = getTransformer(rule, options);
|
|
42
|
+
return transformer.transformSync(rule, {
|
|
43
|
+
lossless: false,
|
|
44
|
+
updateSelector: true
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var cssVars = [
|
|
49
|
+
{
|
|
50
|
+
prop: '--tw-border-spacing-x',
|
|
51
|
+
value: '0'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
prop: '--tw-border-spacing-y',
|
|
55
|
+
value: '0'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
prop: '--tw-translate-x',
|
|
59
|
+
value: '0'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
prop: '--tw-translate-y',
|
|
63
|
+
value: '0'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
prop: '--tw-rotate',
|
|
67
|
+
value: '0'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
prop: '--tw-skew-x',
|
|
71
|
+
value: '0'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
prop: '--tw-skew-y',
|
|
75
|
+
value: '0'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
prop: '--tw-scale-x',
|
|
79
|
+
value: '1'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
prop: '--tw-scale-y',
|
|
83
|
+
value: '1'
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
prop: '--tw-pan-x',
|
|
87
|
+
value: ' '
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
prop: '--tw-pan-y',
|
|
91
|
+
value: ' '
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
prop: '--tw-pinch-zoom',
|
|
95
|
+
value: ' '
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
prop: '--tw-scroll-snap-strictness',
|
|
99
|
+
value: 'proximity'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
prop: '--tw-gradient-from-position',
|
|
103
|
+
value: ' '
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
prop: '--tw-gradient-via-position',
|
|
107
|
+
value: ' '
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
prop: '--tw-gradient-to-position',
|
|
111
|
+
value: ' '
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
prop: '--tw-ordinal',
|
|
115
|
+
value: ' '
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
prop: '--tw-slashed-zero',
|
|
119
|
+
value: ' '
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
prop: '--tw-numeric-figure',
|
|
123
|
+
value: ' '
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
prop: '--tw-numeric-spacing',
|
|
127
|
+
value: ' '
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
prop: '--tw-numeric-fraction',
|
|
131
|
+
value: ' '
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
prop: '--tw-ring-inset',
|
|
135
|
+
value: ' '
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
prop: '--tw-ring-offset-width',
|
|
139
|
+
value: '0rpx'
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
prop: '--tw-ring-offset-color',
|
|
143
|
+
value: '#fff'
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
prop: '--tw-ring-color',
|
|
147
|
+
value: 'rgba(59, 130, 246, 0.5)'
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
prop: '--tw-ring-offset-shadow',
|
|
151
|
+
value: '0 0 #0000'
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
prop: '--tw-ring-shadow',
|
|
155
|
+
value: '0 0 #0000'
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
prop: '--tw-shadow',
|
|
159
|
+
value: '0 0 #0000'
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
prop: '--tw-shadow-colored',
|
|
163
|
+
value: '0 0 #0000'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
prop: '--tw-blur',
|
|
167
|
+
value: ' '
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
prop: '--tw-brightness',
|
|
171
|
+
value: ' '
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
prop: '--tw-contrast',
|
|
175
|
+
value: ' '
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
prop: '--tw-grayscale',
|
|
179
|
+
value: ' '
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
prop: '--tw-hue-rotate',
|
|
183
|
+
value: ' '
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
prop: '--tw-invert',
|
|
187
|
+
value: ' '
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
prop: '--tw-saturate',
|
|
191
|
+
value: ' '
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
prop: '--tw-sepia',
|
|
195
|
+
value: ' '
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
prop: '--tw-drop-shadow',
|
|
199
|
+
value: ' '
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
prop: '--tw-backdrop-blur',
|
|
203
|
+
value: ' '
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
prop: '--tw-backdrop-brightness',
|
|
207
|
+
value: ' '
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
prop: '--tw-backdrop-contrast',
|
|
211
|
+
value: ' '
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
prop: '--tw-backdrop-grayscale',
|
|
215
|
+
value: ' '
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
prop: '--tw-backdrop-hue-rotate',
|
|
219
|
+
value: ' '
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
prop: '--tw-backdrop-invert',
|
|
223
|
+
value: ' '
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
prop: '--tw-backdrop-opacity',
|
|
227
|
+
value: ' '
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
prop: '--tw-backdrop-saturate',
|
|
231
|
+
value: ' '
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
prop: '--tw-backdrop-sepia',
|
|
235
|
+
value: ' '
|
|
236
|
+
}
|
|
237
|
+
];
|
|
238
|
+
|
|
239
|
+
const initialNodes = cssVars.map((x) => {
|
|
240
|
+
return new postcss.Declaration({
|
|
241
|
+
prop: x.prop,
|
|
242
|
+
value: x.value
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
const PATTERNS = [/:not\(template\)\s*~\s*:not\(template\)/.source, /:not\(\[hidden\]\)\s*~\s*:not\(\[hidden\]\)/.source].join('|');
|
|
246
|
+
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
247
|
+
function testIfVariablesScope(node, count = 1) {
|
|
248
|
+
if (/:?:before/.test(node.selector) && /:?:after/.test(node.selector)) {
|
|
249
|
+
for (let i = 0; i < count; i++) {
|
|
250
|
+
const tryTestDecl = node.nodes[i];
|
|
251
|
+
if (tryTestDecl && tryTestDecl.type === 'decl' && tryTestDecl.prop.startsWith('--tw-')) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
function testIfTwBackdrop(node, count = 1) {
|
|
263
|
+
if (node.type === 'rule' && node.selector === '::backdrop') {
|
|
264
|
+
for (let i = 0; i < count; i++) {
|
|
265
|
+
const tryTestDecl = node.nodes[i];
|
|
266
|
+
if (tryTestDecl && tryTestDecl.type === 'decl' && tryTestDecl.prop.startsWith('--tw-')) {
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
function makePseudoVarRule() {
|
|
278
|
+
const pseudoVarRule = new postcss.Rule({
|
|
279
|
+
selector: '::before,::after'
|
|
280
|
+
});
|
|
281
|
+
pseudoVarRule.append(new postcss.Declaration({
|
|
282
|
+
prop: '--tw-content',
|
|
283
|
+
value: '""'
|
|
284
|
+
}));
|
|
285
|
+
return pseudoVarRule;
|
|
286
|
+
}
|
|
287
|
+
function remakeCssVarSelector(selectors, cssPreflightRange) {
|
|
288
|
+
const idx = selectors.indexOf('*');
|
|
289
|
+
if (idx > -1) {
|
|
290
|
+
selectors.splice(idx, 1);
|
|
291
|
+
}
|
|
292
|
+
if (!selectors.includes('view')) {
|
|
293
|
+
selectors.push('view');
|
|
294
|
+
}
|
|
295
|
+
if (cssPreflightRange === 'all' &&
|
|
296
|
+
!selectors.includes(':not(not)')) {
|
|
297
|
+
selectors.push(':not(not)');
|
|
298
|
+
}
|
|
299
|
+
return selectors;
|
|
300
|
+
}
|
|
301
|
+
function remakeCombinatorSelector(selector, cssChildCombinatorReplaceValue) {
|
|
302
|
+
let childCombinatorReplaceValue = 'view + view';
|
|
303
|
+
if (Array.isArray(cssChildCombinatorReplaceValue)) {
|
|
304
|
+
const part = cssChildCombinatorReplaceValue.join(',');
|
|
305
|
+
childCombinatorReplaceValue = [part, ' + ', part].join('');
|
|
306
|
+
}
|
|
307
|
+
else if (typeof cssChildCombinatorReplaceValue === 'string') {
|
|
308
|
+
childCombinatorReplaceValue = cssChildCombinatorReplaceValue;
|
|
309
|
+
}
|
|
310
|
+
return selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
|
|
311
|
+
}
|
|
312
|
+
function commonChunkPreflight(node, options) {
|
|
313
|
+
node.selector = remakeCombinatorSelector(node.selector, options.cssChildCombinatorReplaceValue);
|
|
314
|
+
if (testIfVariablesScope(node)) {
|
|
315
|
+
node.selectors = remakeCssVarSelector(node.selectors, options.cssPreflightRange);
|
|
316
|
+
node.before(makePseudoVarRule());
|
|
317
|
+
if (typeof options.cssInjectPreflight === 'function') {
|
|
318
|
+
node.append(...options.cssInjectPreflight());
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (options.injectAdditionalCssVarScope && testIfTwBackdrop(node)) {
|
|
322
|
+
const syntheticRule = new postcss.Rule({
|
|
323
|
+
selectors: ['::after', '::before'],
|
|
324
|
+
nodes: initialNodes
|
|
325
|
+
});
|
|
326
|
+
syntheticRule.selectors = remakeCssVarSelector(syntheticRule.selectors, options.cssPreflightRange);
|
|
327
|
+
node.before(syntheticRule);
|
|
328
|
+
node.before(makePseudoVarRule());
|
|
329
|
+
if (typeof options.cssInjectPreflight === 'function') {
|
|
330
|
+
syntheticRule.append(...options.cssInjectPreflight());
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
336
|
+
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
337
|
+
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
338
|
+
|
|
339
|
+
const postcssWeappTailwindcss = (options = {
|
|
340
|
+
isMainChunk: true
|
|
341
|
+
}) => {
|
|
342
|
+
const { customRuleCallback, isMainChunk } = options;
|
|
343
|
+
const flag = typeof customRuleCallback === 'function';
|
|
344
|
+
return {
|
|
345
|
+
postcssPlugin,
|
|
346
|
+
Once(css) {
|
|
347
|
+
css.walkRules((rule) => {
|
|
348
|
+
transformSync(rule, options);
|
|
349
|
+
isMainChunk && commonChunkPreflight(rule, options);
|
|
350
|
+
flag && customRuleCallback(rule, options);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
postcssWeappTailwindcss.postcss = true;
|
|
356
|
+
|
|
357
|
+
exports.pluginName = pluginName;
|
|
358
|
+
exports.postcssWeappTailwindcss = postcssWeappTailwindcss;
|
|
359
|
+
exports.vitePluginName = vitePluginName;
|
package/dist/postcss.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var postcss = require('./postcss-
|
|
5
|
+
var postcss = require('./postcss-b53e9504.js');
|
|
6
6
|
var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
|
|
7
7
|
require('postcss-selector-parser');
|
|
8
8
|
require('./shared-ae7dd073.js');
|