weapp-tailwindcss 3.2.1 → 3.3.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/dist/bundlers/vite/index.d.ts +1 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +1 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
- package/dist/cli.js +12 -11
- package/dist/cli.mjs +6 -6
- package/dist/{constants-D-YMDg7M.js → constants-CFM1J-h1.js} +3 -3
- package/dist/{constants-CcqTvLgQ.mjs → constants-Dy2Dd3Fz.mjs} +3 -3
- package/dist/core.d.ts +1 -1
- package/dist/core.js +12 -13
- package/dist/core.mjs +12 -13
- package/dist/css-macro/index.js +2 -2
- package/dist/css-macro/index.mjs +2 -2
- package/dist/css-macro/postcss.js +8 -8
- package/dist/css-macro/postcss.mjs +8 -8
- package/dist/{defaults-DOGbAFEj.mjs → defaults-BDivGN-J.mjs} +10 -10
- package/dist/{defaults-CGBcgdIr.js → defaults-z7wUEh47.js} +10 -10
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/extractors/split.d.ts +1 -1
- package/dist/gulp.js +7 -5
- package/dist/gulp.mjs +7 -5
- package/dist/{index-UGtfFwsf.mjs → index-BMv1aBKz.mjs} +13 -16
- package/dist/{index-DC60ES8u.mjs → index-BPzIdybK.mjs} +91 -91
- package/dist/{index-EnQF5WiI.mjs → index-Bm-88xa7.mjs} +14 -16
- package/dist/{index-iiM-deHl.js → index-CeRMFNvT.js} +13 -16
- package/dist/{index-6BUjj8Rl.js → index-DwZHOkK3.js} +91 -91
- package/dist/{index-BpY7tq3j.js → index-oneQz6yy.js} +20 -22
- package/dist/index.js +9 -7
- package/dist/index.mjs +9 -7
- package/dist/js/handlers.d.ts +1 -1
- package/dist/mangle/index.d.ts +1 -1
- package/dist/{options-BjZGMFOk.js → options-DCor-e5I.js} +80 -74
- package/dist/{options-D1IYbX_E.mjs → options-SmfRHxH0.mjs} +82 -75
- package/dist/postcss/plugins/index.d.ts +2 -2
- package/dist/postcss/preflight.d.ts +1 -1
- package/dist/postcss/selectorParser.d.ts +1 -1
- package/dist/postcss/shared.d.ts +1 -1
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/replace.d.ts +1 -1
- package/dist/replace.js +3 -3
- package/dist/replace.mjs +3 -3
- package/dist/{shared-BX0VV-pr.mjs → shared-DbJl6i6a.mjs} +2 -2
- package/dist/{shared-BDew1Ric.js → shared-hzYeE1wX.js} +2 -2
- package/dist/tailwindcss/patcher.d.ts +4 -3
- package/dist/types.d.ts +7 -5
- package/dist/utils.d.ts +1 -1
- package/dist/{v5-C6FTqEeL.mjs → v5-CQUeTJ2W.mjs} +16 -19
- package/dist/{v5-DA4DSMKO.js → v5-ea_QoULz.js} +16 -19
- package/dist/vite.js +6 -5
- package/dist/vite.mjs +6 -5
- package/dist/webpack.js +6 -5
- package/dist/webpack.mjs +6 -5
- package/dist/webpack4.js +17 -19
- package/dist/webpack4.mjs +17 -19
- package/dist/wxml/shared.d.ts +1 -1
- package/dist/wxml/utils.d.ts +2 -2
- package/package.json +80 -78
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { g as getOptions,
|
|
2
|
-
import { v as vitePluginName } from './index-
|
|
3
|
-
import { g as getGroupedEntries } from './defaults-
|
|
1
|
+
import { g as getOptions, _ as __awaiter } from './options-SmfRHxH0.mjs';
|
|
2
|
+
import { v as vitePluginName } from './index-BPzIdybK.mjs';
|
|
3
|
+
import { g as getGroupedEntries } from './defaults-BDivGN-J.mjs';
|
|
4
4
|
import { c as createDebug } from './index-BEIjgKpF.mjs';
|
|
5
5
|
|
|
6
6
|
const debug = createDebug();
|
|
7
7
|
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
8
8
|
const opts = getOptions(options);
|
|
9
|
-
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache,
|
|
9
|
+
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, twPatcher, } = opts;
|
|
10
10
|
if (disabled) {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
14
|
-
const twPatcher = createTailwindcssPatcher();
|
|
15
14
|
onLoad();
|
|
16
15
|
return {
|
|
17
16
|
name: vitePluginName,
|
|
@@ -22,9 +21,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
22
21
|
onStart();
|
|
23
22
|
const entries = Object.entries(bundle);
|
|
24
23
|
const groupedEntries = getGroupedEntries(entries, opts);
|
|
25
|
-
const runtimeSet = twPatcher.getClassSet(
|
|
26
|
-
basedir: tailwindcssBasedir
|
|
27
|
-
});
|
|
24
|
+
const runtimeSet = twPatcher.getClassSet();
|
|
28
25
|
setMangleRuntimeSet(runtimeSet);
|
|
29
26
|
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
30
27
|
if (Array.isArray(groupedEntries.html)) {
|
|
@@ -45,14 +42,14 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
45
42
|
}
|
|
46
43
|
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
47
44
|
originalSource.source = yield templateHandler(oldVal, {
|
|
48
|
-
runtimeSet
|
|
45
|
+
runtimeSet,
|
|
49
46
|
});
|
|
50
47
|
onUpdate(file, oldVal, originalSource.source);
|
|
51
48
|
debug('html handle: %s', file);
|
|
52
49
|
noCachedCount++;
|
|
53
50
|
return {
|
|
54
51
|
key: file,
|
|
55
|
-
source: originalSource.source
|
|
52
|
+
source: originalSource.source,
|
|
56
53
|
};
|
|
57
54
|
}));
|
|
58
55
|
}
|
|
@@ -75,10 +72,10 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
75
72
|
return false;
|
|
76
73
|
}
|
|
77
74
|
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
const mapFilename = file
|
|
75
|
+
const mapFilename = `${file}.map`;
|
|
79
76
|
const hasMap = Boolean(bundle[mapFilename]);
|
|
80
77
|
const { code, map } = yield jsHandler(rawSource, runtimeSet, {
|
|
81
|
-
generateMap: hasMap
|
|
78
|
+
generateMap: hasMap,
|
|
82
79
|
});
|
|
83
80
|
originalSource.code = code;
|
|
84
81
|
onUpdate(file, rawSource, code);
|
|
@@ -89,7 +86,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
89
86
|
}
|
|
90
87
|
return {
|
|
91
88
|
key: file,
|
|
92
|
-
source: code
|
|
89
|
+
source: code,
|
|
93
90
|
};
|
|
94
91
|
}));
|
|
95
92
|
}
|
|
@@ -113,7 +110,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
113
110
|
}
|
|
114
111
|
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
115
112
|
const css = yield styleHandler(rawSource, {
|
|
116
|
-
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
|
|
113
|
+
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType),
|
|
117
114
|
});
|
|
118
115
|
originalSource.source = css;
|
|
119
116
|
onUpdate(file, rawSource, css);
|
|
@@ -121,7 +118,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
121
118
|
noCachedCount++;
|
|
122
119
|
return {
|
|
123
120
|
key: file,
|
|
124
|
-
source: css
|
|
121
|
+
source: css,
|
|
125
122
|
};
|
|
126
123
|
}));
|
|
127
124
|
}
|
|
@@ -130,7 +127,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
130
127
|
onEnd();
|
|
131
128
|
debug('end');
|
|
132
129
|
});
|
|
133
|
-
}
|
|
130
|
+
},
|
|
134
131
|
};
|
|
135
132
|
}
|
|
136
133
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import postcssIsPseudoClass from '@csstools/postcss-is-pseudo-class';
|
|
2
2
|
import postcssRem2rpx from 'postcss-rem-to-responsive-pixel';
|
|
3
3
|
import selectorParser from 'postcss-selector-parser';
|
|
4
|
-
import { c as composeIsPseudo, i as internalCssSelectorReplacer } from './shared-
|
|
4
|
+
import { c as composeIsPseudo, i as internalCssSelectorReplacer } from './shared-DbJl6i6a.mjs';
|
|
5
5
|
import { Declaration, Rule } from 'postcss';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function createRuleTransform(rule, options) {
|
|
8
8
|
const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
|
|
9
9
|
const transform = (selectors) => {
|
|
10
10
|
selectors.walk((selector) => {
|
|
@@ -12,19 +12,19 @@ const createRuleTransform = (rule, options) => {
|
|
|
12
12
|
selector.value = composeIsPseudo(cssSelectorReplacement.universal);
|
|
13
13
|
}
|
|
14
14
|
if (cssRemoveHoverPseudoClass && selector.type === 'selector') {
|
|
15
|
-
const node = selector.nodes.find(
|
|
15
|
+
const node = selector.nodes.find(x => x.type === 'pseudo' && x.value === ':hover');
|
|
16
16
|
node && selector.remove();
|
|
17
17
|
}
|
|
18
|
-
if (selector.type === 'pseudo'
|
|
19
|
-
selector.value === ':root'
|
|
20
|
-
cssSelectorReplacement
|
|
21
|
-
cssSelectorReplacement.root) {
|
|
18
|
+
if (selector.type === 'pseudo'
|
|
19
|
+
&& selector.value === ':root'
|
|
20
|
+
&& cssSelectorReplacement
|
|
21
|
+
&& cssSelectorReplacement.root) {
|
|
22
22
|
selector.value = composeIsPseudo(cssSelectorReplacement.root);
|
|
23
23
|
}
|
|
24
24
|
if (selector.type === 'class') {
|
|
25
25
|
selector.value = internalCssSelectorReplacer(selector.value, {
|
|
26
26
|
escapeMap,
|
|
27
|
-
mangleContext
|
|
27
|
+
mangleContext,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
});
|
|
@@ -33,17 +33,17 @@ const createRuleTransform = (rule, options) => {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
return transform;
|
|
36
|
-
}
|
|
37
|
-
|
|
36
|
+
}
|
|
37
|
+
function getRuleTransformer(rule, options) {
|
|
38
38
|
return selectorParser(createRuleTransform(rule, options));
|
|
39
|
-
}
|
|
40
|
-
|
|
39
|
+
}
|
|
40
|
+
function ruleTransformSync(rule, options) {
|
|
41
41
|
const transformer = getRuleTransformer(rule, options);
|
|
42
42
|
return transformer.transformSync(rule, {
|
|
43
43
|
lossless: false,
|
|
44
|
-
updateSelector: true
|
|
44
|
+
updateSelector: true,
|
|
45
45
|
});
|
|
46
|
-
}
|
|
46
|
+
}
|
|
47
47
|
function isOnlyBeforeAndAfterPseudoElement(node) {
|
|
48
48
|
let b = false;
|
|
49
49
|
let a = false;
|
|
@@ -77,219 +77,219 @@ const fallbackRemove = selectorParser((selectors) => {
|
|
|
77
77
|
var cssVars = [
|
|
78
78
|
{
|
|
79
79
|
prop: '--tw-border-spacing-x',
|
|
80
|
-
value: '0'
|
|
80
|
+
value: '0',
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
prop: '--tw-border-spacing-y',
|
|
84
|
-
value: '0'
|
|
84
|
+
value: '0',
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
prop: '--tw-translate-x',
|
|
88
|
-
value: '0'
|
|
88
|
+
value: '0',
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
prop: '--tw-translate-y',
|
|
92
|
-
value: '0'
|
|
92
|
+
value: '0',
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
prop: '--tw-rotate',
|
|
96
|
-
value: '0'
|
|
96
|
+
value: '0',
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
prop: '--tw-skew-x',
|
|
100
|
-
value: '0'
|
|
100
|
+
value: '0',
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
103
|
prop: '--tw-skew-y',
|
|
104
|
-
value: '0'
|
|
104
|
+
value: '0',
|
|
105
105
|
},
|
|
106
106
|
{
|
|
107
107
|
prop: '--tw-scale-x',
|
|
108
|
-
value: '1'
|
|
108
|
+
value: '1',
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
111
|
prop: '--tw-scale-y',
|
|
112
|
-
value: '1'
|
|
112
|
+
value: '1',
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
prop: '--tw-pan-x',
|
|
116
|
-
value: ' '
|
|
116
|
+
value: ' ',
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
prop: '--tw-pan-y',
|
|
120
|
-
value: ' '
|
|
120
|
+
value: ' ',
|
|
121
121
|
},
|
|
122
122
|
{
|
|
123
123
|
prop: '--tw-pinch-zoom',
|
|
124
|
-
value: ' '
|
|
124
|
+
value: ' ',
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
127
|
prop: '--tw-scroll-snap-strictness',
|
|
128
|
-
value: 'proximity'
|
|
128
|
+
value: 'proximity',
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
prop: '--tw-gradient-from-position',
|
|
132
|
-
value: ' '
|
|
132
|
+
value: ' ',
|
|
133
133
|
},
|
|
134
134
|
{
|
|
135
135
|
prop: '--tw-gradient-via-position',
|
|
136
|
-
value: ' '
|
|
136
|
+
value: ' ',
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
139
|
prop: '--tw-gradient-to-position',
|
|
140
|
-
value: ' '
|
|
140
|
+
value: ' ',
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
prop: '--tw-ordinal',
|
|
144
|
-
value: ' '
|
|
144
|
+
value: ' ',
|
|
145
145
|
},
|
|
146
146
|
{
|
|
147
147
|
prop: '--tw-slashed-zero',
|
|
148
|
-
value: ' '
|
|
148
|
+
value: ' ',
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
151
|
prop: '--tw-numeric-figure',
|
|
152
|
-
value: ' '
|
|
152
|
+
value: ' ',
|
|
153
153
|
},
|
|
154
154
|
{
|
|
155
155
|
prop: '--tw-numeric-spacing',
|
|
156
|
-
value: ' '
|
|
156
|
+
value: ' ',
|
|
157
157
|
},
|
|
158
158
|
{
|
|
159
159
|
prop: '--tw-numeric-fraction',
|
|
160
|
-
value: ' '
|
|
160
|
+
value: ' ',
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
prop: '--tw-ring-inset',
|
|
164
|
-
value: ' '
|
|
164
|
+
value: ' ',
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
167
|
prop: '--tw-ring-offset-width',
|
|
168
|
-
value: '0px'
|
|
168
|
+
value: '0px',
|
|
169
169
|
},
|
|
170
170
|
{
|
|
171
171
|
prop: '--tw-ring-offset-color',
|
|
172
|
-
value: '#fff'
|
|
172
|
+
value: '#fff',
|
|
173
173
|
},
|
|
174
174
|
{
|
|
175
175
|
prop: '--tw-ring-color',
|
|
176
|
-
value: 'rgb(59 130 246 / 0.5)'
|
|
176
|
+
value: 'rgb(59 130 246 / 0.5)',
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
prop: '--tw-ring-offset-shadow',
|
|
180
|
-
value: '0 0 #0000'
|
|
180
|
+
value: '0 0 #0000',
|
|
181
181
|
},
|
|
182
182
|
{
|
|
183
183
|
prop: '--tw-ring-shadow',
|
|
184
|
-
value: '0 0 #0000'
|
|
184
|
+
value: '0 0 #0000',
|
|
185
185
|
},
|
|
186
186
|
{
|
|
187
187
|
prop: '--tw-shadow',
|
|
188
|
-
value: '0 0 #0000'
|
|
188
|
+
value: '0 0 #0000',
|
|
189
189
|
},
|
|
190
190
|
{
|
|
191
191
|
prop: '--tw-shadow-colored',
|
|
192
|
-
value: '0 0 #0000'
|
|
192
|
+
value: '0 0 #0000',
|
|
193
193
|
},
|
|
194
194
|
{
|
|
195
195
|
prop: '--tw-blur',
|
|
196
|
-
value: ' '
|
|
196
|
+
value: ' ',
|
|
197
197
|
},
|
|
198
198
|
{
|
|
199
199
|
prop: '--tw-brightness',
|
|
200
|
-
value: ' '
|
|
200
|
+
value: ' ',
|
|
201
201
|
},
|
|
202
202
|
{
|
|
203
203
|
prop: '--tw-contrast',
|
|
204
|
-
value: ' '
|
|
204
|
+
value: ' ',
|
|
205
205
|
},
|
|
206
206
|
{
|
|
207
207
|
prop: '--tw-grayscale',
|
|
208
|
-
value: ' '
|
|
208
|
+
value: ' ',
|
|
209
209
|
},
|
|
210
210
|
{
|
|
211
211
|
prop: '--tw-hue-rotate',
|
|
212
|
-
value: ' '
|
|
212
|
+
value: ' ',
|
|
213
213
|
},
|
|
214
214
|
{
|
|
215
215
|
prop: '--tw-invert',
|
|
216
|
-
value: ' '
|
|
216
|
+
value: ' ',
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
prop: '--tw-saturate',
|
|
220
|
-
value: ' '
|
|
220
|
+
value: ' ',
|
|
221
221
|
},
|
|
222
222
|
{
|
|
223
223
|
prop: '--tw-sepia',
|
|
224
|
-
value: ' '
|
|
224
|
+
value: ' ',
|
|
225
225
|
},
|
|
226
226
|
{
|
|
227
227
|
prop: '--tw-drop-shadow',
|
|
228
|
-
value: ' '
|
|
228
|
+
value: ' ',
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
231
|
prop: '--tw-backdrop-blur',
|
|
232
|
-
value: ' '
|
|
232
|
+
value: ' ',
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
235
|
prop: '--tw-backdrop-brightness',
|
|
236
|
-
value: ' '
|
|
236
|
+
value: ' ',
|
|
237
237
|
},
|
|
238
238
|
{
|
|
239
239
|
prop: '--tw-backdrop-contrast',
|
|
240
|
-
value: ' '
|
|
240
|
+
value: ' ',
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
prop: '--tw-backdrop-grayscale',
|
|
244
|
-
value: ' '
|
|
244
|
+
value: ' ',
|
|
245
245
|
},
|
|
246
246
|
{
|
|
247
247
|
prop: '--tw-backdrop-hue-rotate',
|
|
248
|
-
value: ' '
|
|
248
|
+
value: ' ',
|
|
249
249
|
},
|
|
250
250
|
{
|
|
251
251
|
prop: '--tw-backdrop-invert',
|
|
252
|
-
value: ' '
|
|
252
|
+
value: ' ',
|
|
253
253
|
},
|
|
254
254
|
{
|
|
255
255
|
prop: '--tw-backdrop-opacity',
|
|
256
|
-
value: ' '
|
|
256
|
+
value: ' ',
|
|
257
257
|
},
|
|
258
258
|
{
|
|
259
259
|
prop: '--tw-backdrop-saturate',
|
|
260
|
-
value: ' '
|
|
260
|
+
value: ' ',
|
|
261
261
|
},
|
|
262
262
|
{
|
|
263
263
|
prop: '--tw-backdrop-sepia',
|
|
264
|
-
value: ' '
|
|
264
|
+
value: ' ',
|
|
265
265
|
},
|
|
266
266
|
{
|
|
267
267
|
prop: '--tw-contain-size',
|
|
268
|
-
value: ' '
|
|
268
|
+
value: ' ',
|
|
269
269
|
},
|
|
270
270
|
{
|
|
271
271
|
prop: '--tw-contain-layout',
|
|
272
|
-
value: ' '
|
|
272
|
+
value: ' ',
|
|
273
273
|
},
|
|
274
274
|
{
|
|
275
275
|
prop: '--tw-contain-paint',
|
|
276
|
-
value: ' '
|
|
276
|
+
value: ' ',
|
|
277
277
|
},
|
|
278
278
|
{
|
|
279
279
|
prop: '--tw-contain-style',
|
|
280
|
-
value: ' '
|
|
281
|
-
}
|
|
280
|
+
value: ' ',
|
|
281
|
+
},
|
|
282
282
|
];
|
|
283
283
|
|
|
284
284
|
const initialNodes = cssVars.map((x) => {
|
|
285
285
|
return new Declaration({
|
|
286
286
|
prop: x.prop,
|
|
287
|
-
value: x.value
|
|
287
|
+
value: x.value,
|
|
288
288
|
});
|
|
289
289
|
});
|
|
290
290
|
const PATTERNS = [
|
|
291
291
|
/:not\(template\)\s*[~+]\s*:not\(template\)/.source,
|
|
292
|
-
/:not\(\[hidden\]\)\s*[~+]\s*:not\(\[hidden\]\)/.source
|
|
292
|
+
/:not\(\[hidden\]\)\s*[~+]\s*:not\(\[hidden\]\)/.source,
|
|
293
293
|
].join('|');
|
|
294
294
|
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
295
295
|
function testIfVariablesScope(node, count = 2) {
|
|
@@ -326,32 +326,32 @@ function testIfTwBackdrop(node, count = 2) {
|
|
|
326
326
|
}
|
|
327
327
|
function makePseudoVarRule() {
|
|
328
328
|
const pseudoVarRule = new Rule({
|
|
329
|
-
selector: '::before,::after'
|
|
329
|
+
selector: '::before,::after',
|
|
330
330
|
});
|
|
331
331
|
pseudoVarRule.append(new Declaration({
|
|
332
332
|
prop: '--tw-content',
|
|
333
|
-
value: '""'
|
|
333
|
+
value: '""',
|
|
334
334
|
}));
|
|
335
335
|
return pseudoVarRule;
|
|
336
336
|
}
|
|
337
337
|
function remakeCssVarSelector(selectors, options) {
|
|
338
338
|
const { cssPreflightRange, cssSelectorReplacement } = options;
|
|
339
|
-
if (cssPreflightRange === 'all'
|
|
340
|
-
!selectors.includes(':not(not)')) {
|
|
339
|
+
if (cssPreflightRange === 'all'
|
|
340
|
+
&& !selectors.includes(':not(not)')) {
|
|
341
341
|
selectors.push(':not(not)');
|
|
342
342
|
}
|
|
343
343
|
if (cssSelectorReplacement) {
|
|
344
344
|
if (Array.isArray(cssSelectorReplacement.universal)) {
|
|
345
345
|
if (!cssSelectorReplacement.universal.every((x) => {
|
|
346
346
|
return selectors.includes(x);
|
|
347
|
-
})
|
|
348
|
-
!selectors.includes('*')) {
|
|
347
|
+
})
|
|
348
|
+
&& !selectors.includes('*')) {
|
|
349
349
|
selectors.unshift('*');
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
-
else if (typeof cssSelectorReplacement.universal === 'string'
|
|
353
|
-
!selectors.includes(cssSelectorReplacement.universal)
|
|
354
|
-
!selectors.includes('*')) {
|
|
352
|
+
else if (typeof cssSelectorReplacement.universal === 'string'
|
|
353
|
+
&& !selectors.includes(cssSelectorReplacement.universal)
|
|
354
|
+
&& !selectors.includes('*')) {
|
|
355
355
|
selectors.unshift('*');
|
|
356
356
|
}
|
|
357
357
|
}
|
|
@@ -361,7 +361,7 @@ function remakeCombinatorSelector(selector, cssChildCombinatorReplaceValue) {
|
|
|
361
361
|
let childCombinatorReplaceValue = 'view + view';
|
|
362
362
|
if (Array.isArray(cssChildCombinatorReplaceValue) && cssChildCombinatorReplaceValue.length > 0) {
|
|
363
363
|
const x = composeIsPseudo(cssChildCombinatorReplaceValue);
|
|
364
|
-
childCombinatorReplaceValue = x +
|
|
364
|
+
childCombinatorReplaceValue = `${x} + ${x}`;
|
|
365
365
|
}
|
|
366
366
|
else if (typeof cssChildCombinatorReplaceValue === 'string') {
|
|
367
367
|
childCombinatorReplaceValue = cssChildCombinatorReplaceValue;
|
|
@@ -382,7 +382,7 @@ function commonChunkPreflight(node, options) {
|
|
|
382
382
|
if (injectAdditionalCssVarScope && testIfTwBackdrop(node)) {
|
|
383
383
|
const syntheticRule = new Rule({
|
|
384
384
|
selectors: ['*', '::after', '::before'],
|
|
385
|
-
nodes: initialNodes
|
|
385
|
+
nodes: initialNodes,
|
|
386
386
|
});
|
|
387
387
|
syntheticRule.selectors = remakeCssVarSelector(syntheticRule.selectors, options);
|
|
388
388
|
node.before(syntheticRule);
|
|
@@ -399,11 +399,11 @@ const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
|
399
399
|
const WEAPP_TW_REQUIRED_NODE_VERSION = '16.6.0';
|
|
400
400
|
|
|
401
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)));
|
|
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
404
|
}
|
|
405
405
|
const postcssWeappTailwindcssPrePlugin = (options = {
|
|
406
|
-
isMainChunk: true
|
|
406
|
+
isMainChunk: true,
|
|
407
407
|
}) => {
|
|
408
408
|
const { isMainChunk } = options;
|
|
409
409
|
const p = {
|
|
@@ -420,7 +420,7 @@ const postcssWeappTailwindcssPrePlugin = (options = {
|
|
|
420
420
|
atRule.remove();
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
|
-
}
|
|
423
|
+
},
|
|
424
424
|
};
|
|
425
425
|
if (isMainChunk) {
|
|
426
426
|
p.Once = (root) => {
|
|
@@ -434,11 +434,11 @@ const postcssWeappTailwindcssPrePlugin = (options = {
|
|
|
434
434
|
postcssWeappTailwindcssPrePlugin.postcss = true;
|
|
435
435
|
|
|
436
436
|
const postcssWeappTailwindcssPostPlugin = (options = {
|
|
437
|
-
isMainChunk: true
|
|
437
|
+
isMainChunk: true,
|
|
438
438
|
}) => {
|
|
439
439
|
const { customRuleCallback, isMainChunk, ctx } = options;
|
|
440
440
|
const p = {
|
|
441
|
-
postcssPlugin
|
|
441
|
+
postcssPlugin,
|
|
442
442
|
};
|
|
443
443
|
if (isMainChunk) {
|
|
444
444
|
p.OnceExit = (root) => {
|
|
@@ -447,14 +447,14 @@ const postcssWeappTailwindcssPostPlugin = (options = {
|
|
|
447
447
|
if (ctx.isVariablesScope(rule)) {
|
|
448
448
|
fallbackRemove.transformSync(rule, {
|
|
449
449
|
updateSelector: true,
|
|
450
|
-
lossless: false
|
|
450
|
+
lossless: false,
|
|
451
451
|
});
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
else if (testIfVariablesScope(rule)) {
|
|
455
455
|
fallbackRemove.transformSync(rule, {
|
|
456
456
|
updateSelector: true,
|
|
457
|
-
lossless: false
|
|
457
|
+
lossless: false,
|
|
458
458
|
});
|
|
459
459
|
}
|
|
460
460
|
});
|
|
@@ -482,7 +482,7 @@ function createContext() {
|
|
|
482
482
|
return {
|
|
483
483
|
variablesScopeWeakMap,
|
|
484
484
|
isVariablesScope,
|
|
485
|
-
markVariablesScope
|
|
485
|
+
markVariablesScope,
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
488
|
|
|
@@ -494,8 +494,8 @@ function getPlugins(options) {
|
|
|
494
494
|
...((_b = (_a = options.postcssOptions) === null || _a === void 0 ? void 0 : _a.plugins) !== null && _b !== void 0 ? _b : []),
|
|
495
495
|
postcssWeappTailwindcssPrePlugin(options),
|
|
496
496
|
postcssIsPseudoClass({
|
|
497
|
-
specificityMatchingName: 'weapp-tw-ig'
|
|
498
|
-
})
|
|
497
|
+
specificityMatchingName: 'weapp-tw-ig',
|
|
498
|
+
}),
|
|
499
499
|
];
|
|
500
500
|
if (options.rem2rpx) {
|
|
501
501
|
plugins.push(postcssRem2rpx(typeof options.rem2rpx === 'object'
|
|
@@ -503,7 +503,7 @@ function getPlugins(options) {
|
|
|
503
503
|
: {
|
|
504
504
|
rootValue: 32,
|
|
505
505
|
propList: ['*'],
|
|
506
|
-
transformUnit: 'rpx'
|
|
506
|
+
transformUnit: 'rpx',
|
|
507
507
|
}));
|
|
508
508
|
}
|
|
509
509
|
plugins.push(postcssWeappTailwindcssPostPlugin(options));
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { g as getOptions,
|
|
1
|
+
import { g as getOptions, _ as __awaiter } from './options-SmfRHxH0.mjs';
|
|
2
2
|
import stream from 'node:stream';
|
|
3
|
+
import { Buffer } from 'node:buffer';
|
|
3
4
|
import { c as createDebug } from './index-BEIjgKpF.mjs';
|
|
4
5
|
|
|
5
6
|
const debug = createDebug();
|
|
6
7
|
const Transform = stream.Transform;
|
|
7
8
|
function createPlugins(options = {}) {
|
|
8
9
|
const opts = getOptions(options);
|
|
9
|
-
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet,
|
|
10
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
|
|
10
11
|
let runtimeSet = new Set();
|
|
11
12
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
12
|
-
const twPatcher = createTailwindcssPatcher();
|
|
13
13
|
function transformWxss(options = {}) {
|
|
14
14
|
return new Transform({
|
|
15
15
|
objectMode: true,
|
|
16
|
-
transform
|
|
16
|
+
transform(file, encoding, callback) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
runtimeSet = twPatcher.getClassSet(
|
|
19
|
-
basedir: tailwindcssBasedir
|
|
20
|
-
});
|
|
18
|
+
runtimeSet = twPatcher.getClassSet();
|
|
21
19
|
setMangleRuntimeSet(runtimeSet);
|
|
22
20
|
const error = null;
|
|
23
21
|
if (file.contents) {
|
|
@@ -39,19 +37,19 @@ function createPlugins(options = {}) {
|
|
|
39
37
|
debug('css handle: %s', file.path);
|
|
40
38
|
return {
|
|
41
39
|
key: file.path,
|
|
42
|
-
source: code
|
|
40
|
+
source: code,
|
|
43
41
|
};
|
|
44
42
|
}));
|
|
45
43
|
}
|
|
46
44
|
callback(error, file);
|
|
47
45
|
});
|
|
48
|
-
}
|
|
46
|
+
},
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
49
|
function transformJs(options = {}) {
|
|
52
50
|
return new Transform({
|
|
53
51
|
objectMode: true,
|
|
54
|
-
transform
|
|
52
|
+
transform(file, encoding, callback) {
|
|
55
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
54
|
const error = null;
|
|
57
55
|
if (file.contents) {
|
|
@@ -73,19 +71,19 @@ function createPlugins(options = {}) {
|
|
|
73
71
|
debug('js handle: %s', file.path);
|
|
74
72
|
return {
|
|
75
73
|
key: file.path,
|
|
76
|
-
source: code
|
|
74
|
+
source: code,
|
|
77
75
|
};
|
|
78
76
|
}));
|
|
79
77
|
}
|
|
80
78
|
callback(error, file);
|
|
81
79
|
});
|
|
82
|
-
}
|
|
80
|
+
},
|
|
83
81
|
});
|
|
84
82
|
}
|
|
85
83
|
function transformWxml(options = {}) {
|
|
86
84
|
return new Transform({
|
|
87
85
|
objectMode: true,
|
|
88
|
-
transform
|
|
86
|
+
transform(file, encoding, callback) {
|
|
89
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
88
|
const error = null;
|
|
91
89
|
if (file.contents) {
|
|
@@ -107,19 +105,19 @@ function createPlugins(options = {}) {
|
|
|
107
105
|
debug('html handle: %s', file.path);
|
|
108
106
|
return {
|
|
109
107
|
key: file.path,
|
|
110
|
-
source: code
|
|
108
|
+
source: code,
|
|
111
109
|
};
|
|
112
110
|
}));
|
|
113
111
|
}
|
|
114
112
|
callback(error, file);
|
|
115
113
|
});
|
|
116
|
-
}
|
|
114
|
+
},
|
|
117
115
|
});
|
|
118
116
|
}
|
|
119
117
|
return {
|
|
120
118
|
transformWxss,
|
|
121
119
|
transformWxml,
|
|
122
|
-
transformJs
|
|
120
|
+
transformJs,
|
|
123
121
|
};
|
|
124
122
|
}
|
|
125
123
|
|