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