weapp-tailwindcss 3.7.0 → 3.8.0-alpha.1

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