weapp-tailwindcss 3.3.7 → 3.4.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 (125) hide show
  1. package/dist/chunk-257YPDSI.mjs +173 -0
  2. package/dist/chunk-75EWCRQW.mjs +13 -0
  3. package/dist/chunk-AB467PG7.mjs +43 -0
  4. package/dist/chunk-E7XGHGC7.mjs +62 -0
  5. package/dist/chunk-GUE4UCRJ.mjs +126 -0
  6. package/dist/chunk-IOYI6MSW.mjs +533 -0
  7. package/dist/chunk-LDWI65M5.mjs +152 -0
  8. package/dist/chunk-NVFWRLOI.mjs +27 -0
  9. package/dist/chunk-ORMKM6ZA.mjs +30 -0
  10. package/dist/chunk-PC4B5JJB.mjs +953 -0
  11. package/dist/chunk-SRLZU2YE.mjs +95 -0
  12. package/dist/chunk-VECXHWWG.mjs +31 -0
  13. package/dist/chunk-VN37QGSM.mjs +216 -0
  14. package/dist/cli.d.mts +2 -0
  15. package/dist/cli.d.ts +2 -1
  16. package/dist/cli.js +1760 -52
  17. package/dist/cli.mjs +34 -46
  18. package/dist/core.d.mts +22 -0
  19. package/dist/core.d.ts +16 -2
  20. package/dist/core.js +1775 -62
  21. package/dist/core.mjs +46 -62
  22. package/dist/css-macro/index.d.mts +18 -0
  23. package/dist/css-macro/index.d.ts +7 -4
  24. package/dist/css-macro/index.js +140 -30
  25. package/dist/css-macro/index.mjs +35 -28
  26. package/dist/css-macro/postcss.d.mts +7 -0
  27. package/dist/css-macro/postcss.d.ts +5 -3
  28. package/dist/css-macro/postcss.js +99 -46
  29. package/dist/css-macro/postcss.mjs +54 -45
  30. package/dist/defaults.d.mts +16 -0
  31. package/dist/defaults.d.ts +16 -2
  32. package/dist/defaults.js +208 -7
  33. package/dist/defaults.mjs +9 -4
  34. package/dist/gulp.d.mts +26 -0
  35. package/dist/gulp.d.ts +26 -1
  36. package/dist/gulp.js +1898 -40
  37. package/dist/gulp.mjs +15 -32
  38. package/dist/index.d.mts +17 -0
  39. package/dist/index.d.ts +17 -4
  40. package/dist/index.js +2291 -44
  41. package/dist/index.mjs +23 -34
  42. package/dist/postcss.d.mts +23 -0
  43. package/dist/postcss.d.ts +23 -1
  44. package/dist/postcss.js +598 -22
  45. package/dist/postcss.mjs +17 -8
  46. package/dist/replace.d.mts +19 -0
  47. package/dist/replace.d.ts +19 -3
  48. package/dist/replace.js +93 -42
  49. package/dist/replace.mjs +30 -26
  50. package/dist/types-DSNuiOhH.d.mts +519 -0
  51. package/dist/types-DSNuiOhH.d.ts +519 -0
  52. package/dist/vite.d.mts +22 -0
  53. package/dist/vite.d.ts +22 -1
  54. package/dist/vite.js +1947 -38
  55. package/dist/vite.mjs +15 -30
  56. package/dist/weapp-tw-runtime-loader.d.mts +7 -0
  57. package/dist/{bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts → weapp-tw-runtime-loader.d.ts} +4 -2
  58. package/dist/weapp-tw-runtime-loader.js +41 -14
  59. package/dist/weapp-tw-runtime-loader.mjs +12 -8
  60. package/dist/webpack.d.mts +26 -0
  61. package/dist/webpack.d.ts +26 -1
  62. package/dist/webpack.js +1994 -38
  63. package/dist/webpack.mjs +15 -30
  64. package/dist/webpack4.d.mts +27 -0
  65. package/dist/webpack4.d.ts +27 -1
  66. package/dist/webpack4.js +1979 -191
  67. package/dist/webpack4.mjs +211 -189
  68. package/package.json +18 -19
  69. package/dist/babel/index.d.ts +0 -16
  70. package/dist/bundlers/gulp/index.d.ts +0 -8
  71. package/dist/bundlers/vite/index.d.ts +0 -3
  72. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -8
  73. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +0 -8
  74. package/dist/bundlers/webpack/index.d.ts +0 -1
  75. package/dist/cache/index.d.ts +0 -32
  76. package/dist/constants-CFM1J-h1.js +0 -42
  77. package/dist/constants-Dy2Dd3Fz.mjs +0 -36
  78. package/dist/constants.d.ts +0 -7
  79. package/dist/css-macro/constants.d.ts +0 -14
  80. package/dist/debug/index.d.ts +0 -2
  81. package/dist/defaults-DUZZvtdg.mjs +0 -149
  82. package/dist/defaults-syv_N3uk.js +0 -156
  83. package/dist/defu-Cdz2PomB.js +0 -60
  84. package/dist/defu-n46TJT6t.mjs +0 -57
  85. package/dist/env.d.ts +0 -2
  86. package/dist/escape.d.ts +0 -4
  87. package/dist/extractors/split.d.ts +0 -3
  88. package/dist/index-B8TOcVAt.js +0 -130
  89. package/dist/index-BEIjgKpF.mjs +0 -11
  90. package/dist/index-BKZH-Gxq.mjs +0 -134
  91. package/dist/index-BPzIdybK.mjs +0 -513
  92. package/dist/index-Bc61v7B0.mjs +0 -124
  93. package/dist/index-DXeB6ex8.js +0 -136
  94. package/dist/index-DwZHOkK3.js +0 -526
  95. package/dist/index-HC-Qkn0i.js +0 -17
  96. package/dist/js/handlers.d.ts +0 -13
  97. package/dist/js/index.d.ts +0 -7
  98. package/dist/mangle/index.d.ts +0 -8
  99. package/dist/options-BHJnjA_a.mjs +0 -981
  100. package/dist/options-DAp5AdGz.js +0 -1014
  101. package/dist/options.d.ts +0 -2
  102. package/dist/postcss/cssVars.d.ts +0 -5
  103. package/dist/postcss/index.d.ts +0 -3
  104. package/dist/postcss/mp.d.ts +0 -8
  105. package/dist/postcss/plugins/ctx.d.ts +0 -6
  106. package/dist/postcss/plugins/index.d.ts +0 -7
  107. package/dist/postcss/plugins/post.d.ts +0 -5
  108. package/dist/postcss/plugins/pre.d.ts +0 -5
  109. package/dist/postcss/preflight.d.ts +0 -3
  110. package/dist/postcss/selectorParser.d.ts +0 -6
  111. package/dist/postcss/shared.d.ts +0 -3
  112. package/dist/postcss/symbols.d.ts +0 -1
  113. package/dist/reg.d.ts +0 -1
  114. package/dist/shared-DbJl6i6a.mjs +0 -25
  115. package/dist/shared-hzYeE1wX.js +0 -28
  116. package/dist/tailwindcss/patcher.d.ts +0 -8
  117. package/dist/tailwindcss/supportCustomUnit.d.ts +0 -6
  118. package/dist/types.d.ts +0 -179
  119. package/dist/utils.d.ts +0 -18
  120. package/dist/v5-B9S3lBOs.mjs +0 -174
  121. package/dist/v5-QURRYPNk.js +0 -181
  122. package/dist/wxml/Tokenizer.d.ts +0 -31
  123. package/dist/wxml/index.d.ts +0 -2
  124. package/dist/wxml/shared.d.ts +0 -2
  125. package/dist/wxml/utils.d.ts +0 -9
package/dist/gulp.js CHANGED
@@ -1,40 +1,1898 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var index = require('./index-B8TOcVAt.js');
6
- require('./options-DAp5AdGz.js');
7
- require('magic-string');
8
- require('./replace.js');
9
- require('@weapp-core/escape');
10
- require('@ast-core/escape');
11
- require('./shared-hzYeE1wX.js');
12
- require('@weapp-core/regex');
13
- require('@babel/generator');
14
- require('@babel/traverse');
15
- require('@babel/parser');
16
- require('./defaults-syv_N3uk.js');
17
- require('./defu-Cdz2PomB.js');
18
- require('@babel/types');
19
- require('htmlparser2');
20
- require('postcss');
21
- require('./index-DwZHOkK3.js');
22
- require('@csstools/postcss-is-pseudo-class');
23
- require('postcss-rem-to-responsive-pixel');
24
- require('postcss-selector-parser');
25
- require('node:path');
26
- require('node:fs');
27
- require('node:process');
28
- require('semver');
29
- require('tailwindcss-patch');
30
- require('@tailwindcss-mangle/shared');
31
- require('lru-cache');
32
- require('md5');
33
- require('node:stream');
34
- require('node:buffer');
35
- require('./index-HC-Qkn0i.js');
36
- require('debug');
37
-
38
-
39
-
40
- exports.createPlugins = index.createPlugins;
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
38
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
39
+ // If the importer is in node compatibility mode or this is not an ESM
40
+ // file that has been converted to a CommonJS file using a Babel-
41
+ // compatible transform (i.e. "__esModule" has not been set), then set
42
+ // "default" to the CommonJS "module.exports" for node compatibility.
43
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
44
+ mod
45
+ ));
46
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
47
+ var __async = (__this, __arguments, generator) => {
48
+ return new Promise((resolve, reject) => {
49
+ var fulfilled = (value) => {
50
+ try {
51
+ step(generator.next(value));
52
+ } catch (e) {
53
+ reject(e);
54
+ }
55
+ };
56
+ var rejected = (value) => {
57
+ try {
58
+ step(generator.throw(value));
59
+ } catch (e) {
60
+ reject(e);
61
+ }
62
+ };
63
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
64
+ step((generator = generator.apply(__this, __arguments)).next());
65
+ });
66
+ };
67
+
68
+ // src/gulp.ts
69
+ var gulp_exports = {};
70
+ __export(gulp_exports, {
71
+ createPlugins: () => createPlugins
72
+ });
73
+ module.exports = __toCommonJS(gulp_exports);
74
+
75
+ // src/bundlers/gulp/index.ts
76
+ var import_node_stream = __toESM(require("stream"));
77
+ var import_node_buffer = require("buffer");
78
+
79
+ // src/js/index.ts
80
+ var import_magic_string = __toESM(require("magic-string"));
81
+
82
+ // src/escape.ts
83
+ var escape_exports = {};
84
+ __export(escape_exports, {
85
+ decodeUnicode: () => decodeUnicode,
86
+ decodeUnicode2: () => decodeUnicode2,
87
+ jsStringEscape: () => import_escape.jsStringEscape
88
+ });
89
+ __reExport(escape_exports, require("@weapp-core/escape"));
90
+ var import_escape = require("@ast-core/escape");
91
+ function decodeUnicode(s) {
92
+ return unescape(s.replaceAll(/\\(u[\dA-Fa-f]{4})/g, "%$1"));
93
+ }
94
+ function decodeUnicode2(input) {
95
+ try {
96
+ return JSON.parse(`"${input}"`);
97
+ } catch (_error) {
98
+ return input;
99
+ }
100
+ }
101
+
102
+ // src/wxml/shared.ts
103
+ function replaceWxml(original, options = {
104
+ keepEOL: false,
105
+ escapeMap: escape_exports.SimpleMappingChars2String
106
+ }) {
107
+ const { keepEOL, escapeMap, mangleContext, ignoreHead } = options;
108
+ let res = original;
109
+ if (!keepEOL) {
110
+ res = res.replaceAll(/[\n\r]+/g, "");
111
+ }
112
+ if (mangleContext) {
113
+ res = mangleContext.wxmlHandler(res);
114
+ }
115
+ res = (0, escape_exports.escape)(res, {
116
+ map: escapeMap,
117
+ ignoreHead
118
+ });
119
+ return res;
120
+ }
121
+
122
+ // src/reg.ts
123
+ var reg_exports = {};
124
+ __reExport(reg_exports, require("@weapp-core/regex"));
125
+
126
+ // src/extractors/split.ts
127
+ var validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
128
+ function isValidSelector(selector = "") {
129
+ return validateFilterRE.test(selector);
130
+ }
131
+ function splitCode(code, allowDoubleQuotes = false) {
132
+ const splitter = allowDoubleQuotes ? /\s+/ : /\s+|"/;
133
+ return code.split(splitter).filter((element) => isValidSelector(element));
134
+ }
135
+
136
+ // src/js/handlers.ts
137
+ function replaceHandleValue(str, node, options, ms, offset = 0) {
138
+ const {
139
+ classNameSet: set,
140
+ escapeMap,
141
+ mangleContext: ctx,
142
+ needEscaped = false,
143
+ jsPreserveClass,
144
+ arbitraryValues,
145
+ always,
146
+ unescapeUnicode
147
+ } = options;
148
+ const allowDoubleQuotes = arbitraryValues == null ? void 0 : arbitraryValues.allowDoubleQuotes;
149
+ let rawStr = str;
150
+ let needUpdate = false;
151
+ if (unescapeUnicode && rawStr.includes("\\u")) {
152
+ rawStr = decodeUnicode2(rawStr);
153
+ }
154
+ const arr = splitCode(rawStr, allowDoubleQuotes);
155
+ for (const v of arr) {
156
+ if (always || set && set.has(v) && !(jsPreserveClass == null ? void 0 : jsPreserveClass(v))) {
157
+ let ignoreFlag = false;
158
+ if (Array.isArray(node.leadingComments)) {
159
+ ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes("weapp-tw") && x.value.includes("ignore")) > -1;
160
+ }
161
+ if (!ignoreFlag) {
162
+ if (ctx) {
163
+ rawStr = ctx.jsHandler(rawStr);
164
+ }
165
+ rawStr = rawStr.replace(
166
+ new RegExp((0, reg_exports.escapeStringRegexp)(v)),
167
+ replaceWxml(v, {
168
+ escapeMap
169
+ })
170
+ );
171
+ needUpdate = true;
172
+ }
173
+ }
174
+ }
175
+ if (needUpdate && typeof node.start === "number" && typeof node.end === "number") {
176
+ const start = node.start + offset;
177
+ const end = node.end - offset;
178
+ if (start < end && str !== rawStr) {
179
+ const content = needEscaped ? (0, import_escape.jsStringEscape)(rawStr) : rawStr;
180
+ ms.update(start, end, content);
181
+ }
182
+ }
183
+ return rawStr;
184
+ }
185
+
186
+ // src/babel/index.ts
187
+ var import_generator = __toESM(require("@babel/generator"));
188
+ var import_traverse = __toESM(require("@babel/traverse"));
189
+ var import_parser = require("@babel/parser");
190
+ function _interopDefaultCompat(e) {
191
+ return e && typeof e === "object" && "default" in e ? e.default : e;
192
+ }
193
+ var generate = _interopDefaultCompat(import_generator.default);
194
+ var traverse = _interopDefaultCompat(import_traverse.default);
195
+
196
+ // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
197
+ function isPlainObject(value) {
198
+ if (value === null || typeof value !== "object") {
199
+ return false;
200
+ }
201
+ const prototype = Object.getPrototypeOf(value);
202
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
203
+ return false;
204
+ }
205
+ if (Symbol.iterator in value) {
206
+ return false;
207
+ }
208
+ if (Symbol.toStringTag in value) {
209
+ return Object.prototype.toString.call(value) === "[object Module]";
210
+ }
211
+ return true;
212
+ }
213
+ function _defu(baseObject, defaults, namespace = ".", merger) {
214
+ if (!isPlainObject(defaults)) {
215
+ return _defu(baseObject, {}, namespace, merger);
216
+ }
217
+ const object = Object.assign({}, defaults);
218
+ for (const key in baseObject) {
219
+ if (key === "__proto__" || key === "constructor") {
220
+ continue;
221
+ }
222
+ const value = baseObject[key];
223
+ if (value === null || value === void 0) {
224
+ continue;
225
+ }
226
+ if (merger && merger(object, key, value, namespace)) {
227
+ continue;
228
+ }
229
+ if (Array.isArray(value) && Array.isArray(object[key])) {
230
+ object[key] = [...value, ...object[key]];
231
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
232
+ object[key] = _defu(
233
+ value,
234
+ object[key],
235
+ (namespace ? `${namespace}.` : "") + key.toString(),
236
+ merger
237
+ );
238
+ } else {
239
+ object[key] = value;
240
+ }
241
+ }
242
+ return object;
243
+ }
244
+ function createDefu(merger) {
245
+ return (...arguments_) => (
246
+ // eslint-disable-next-line unicorn/no-array-reduce
247
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
248
+ );
249
+ }
250
+ var defu = createDefu();
251
+ var defuFn = createDefu((object, key, currentValue) => {
252
+ if (object[key] !== void 0 && typeof currentValue === "function") {
253
+ object[key] = currentValue(object[key]);
254
+ return true;
255
+ }
256
+ });
257
+ var defuArrayFn = createDefu((object, key, currentValue) => {
258
+ if (Array.isArray(object[key]) && typeof currentValue === "function") {
259
+ object[key] = currentValue(object[key]);
260
+ return true;
261
+ }
262
+ });
263
+
264
+ // src/utils.ts
265
+ function isMap(value) {
266
+ return Object.prototype.toString.call(value) === "[object Map]";
267
+ }
268
+ function noop() {
269
+ }
270
+ var defuOverrideArray = createDefu((obj, key, value) => {
271
+ if (Array.isArray(obj[key]) && Array.isArray(value)) {
272
+ obj[key] = value;
273
+ return true;
274
+ }
275
+ });
276
+
277
+ // src/js/index.ts
278
+ function isEvalPath(p) {
279
+ if (p.isCallExpression()) {
280
+ const calleePath = p.get("callee");
281
+ return calleePath.isIdentifier() && calleePath.node.name === "eval";
282
+ }
283
+ return false;
284
+ }
285
+ function getAstGrep() {
286
+ return __async(this, null, function* () {
287
+ try {
288
+ const { js } = yield import("@ast-grep/napi");
289
+ return js;
290
+ } catch (error) {
291
+ console.warn("\u8BF7\u5148\u5B89\u88C5 `@ast-grep/napi` , \u5B89\u88C5\u5B8C\u6210\u540E\u518D\u5C1D\u8BD5\u8FD0\u884C\uFF01");
292
+ throw error;
293
+ }
294
+ });
295
+ }
296
+ function astGrepUpdateString(ast, options, ms) {
297
+ return __async(this, null, function* () {
298
+ const js = yield getAstGrep();
299
+ const nodes = ast.findAll(js.kind("string"));
300
+ for (const node of nodes) {
301
+ const range = node.range();
302
+ const text = node.text();
303
+ replaceHandleValue(
304
+ text.slice(1, -1),
305
+ {
306
+ end: range.end.index - 1,
307
+ start: range.start.index + 1
308
+ },
309
+ __spreadProps(__spreadValues({}, options), {
310
+ unescapeUnicode: true
311
+ }),
312
+ ms,
313
+ 0
314
+ );
315
+ }
316
+ const templateNodes = ast.findAll(js.kind("template_string"));
317
+ for (const node of templateNodes) {
318
+ const fragments = node.findAll(js.kind("string_fragment"));
319
+ for (const fragment of fragments) {
320
+ const range = fragment.range();
321
+ const text = fragment.text();
322
+ replaceHandleValue(
323
+ text,
324
+ {
325
+ end: range.end.index,
326
+ start: range.start.index
327
+ },
328
+ __spreadProps(__spreadValues({}, options), {
329
+ unescapeUnicode: true
330
+ }),
331
+ ms,
332
+ 0
333
+ );
334
+ }
335
+ }
336
+ });
337
+ }
338
+ function jsHandler(rawSource, options) {
339
+ const ms = new import_magic_string.default(rawSource);
340
+ let ast;
341
+ try {
342
+ ast = (0, import_parser.parse)(rawSource, options.babelParserOptions);
343
+ } catch (error) {
344
+ return {
345
+ code: rawSource,
346
+ error
347
+ };
348
+ }
349
+ const traverseOptions = {
350
+ StringLiteral: {
351
+ enter(p) {
352
+ var _a;
353
+ if (isEvalPath(p.parentPath)) {
354
+ return;
355
+ }
356
+ const n = p.node;
357
+ replaceHandleValue(
358
+ n.value,
359
+ n,
360
+ __spreadProps(__spreadValues({}, options), {
361
+ needEscaped: (_a = options.needEscaped) != null ? _a : true
362
+ }),
363
+ ms,
364
+ 1
365
+ );
366
+ }
367
+ // exit(p) {}
368
+ },
369
+ TemplateElement: {
370
+ enter(p) {
371
+ if (p.parentPath.isTemplateLiteral() && isEvalPath(p.parentPath.parentPath)) {
372
+ return;
373
+ }
374
+ const n = p.node;
375
+ replaceHandleValue(
376
+ n.value.raw,
377
+ n,
378
+ __spreadProps(__spreadValues({}, options), {
379
+ needEscaped: false
380
+ }),
381
+ ms,
382
+ 0
383
+ );
384
+ }
385
+ },
386
+ CallExpression: {
387
+ enter(p) {
388
+ if (isEvalPath(p)) {
389
+ p.traverse({
390
+ StringLiteral: {
391
+ enter(s) {
392
+ const res = jsHandler(s.node.value, __spreadProps(__spreadValues({}, options), {
393
+ needEscaped: false,
394
+ generateMap: false
395
+ }));
396
+ if (res.code) {
397
+ const node = s.node;
398
+ if (typeof node.start === "number" && typeof node.end === "number") {
399
+ const start = node.start + 1;
400
+ const end = node.end - 1;
401
+ if (start < end && s.node.value !== res.code) {
402
+ ms.update(start, end, (0, import_escape.jsStringEscape)(res.code));
403
+ node.value = res.code;
404
+ }
405
+ }
406
+ }
407
+ }
408
+ },
409
+ TemplateElement: {
410
+ enter(s) {
411
+ const res = jsHandler(s.node.value.raw, __spreadProps(__spreadValues({}, options), {
412
+ generateMap: false
413
+ }));
414
+ if (res.code) {
415
+ const node = s.node;
416
+ if (typeof node.start === "number" && typeof node.end === "number") {
417
+ const start = node.start;
418
+ const end = node.end;
419
+ if (start < end && s.node.value.raw !== res.code) {
420
+ ms.update(start, end, res.code);
421
+ s.node.value.raw = res.code;
422
+ }
423
+ }
424
+ }
425
+ }
426
+ }
427
+ });
428
+ }
429
+ }
430
+ }
431
+ };
432
+ traverse(ast, traverseOptions);
433
+ return {
434
+ code: ms.toString()
435
+ };
436
+ }
437
+ function jsHandlerAsync(rawSource, options) {
438
+ return __async(this, null, function* () {
439
+ const ms = new import_magic_string.default(rawSource);
440
+ const js = yield getAstGrep();
441
+ let ast;
442
+ try {
443
+ const root = yield js.parseAsync(rawSource);
444
+ ast = root.root();
445
+ } catch (e) {
446
+ return {
447
+ code: rawSource
448
+ };
449
+ }
450
+ yield astGrepUpdateString(ast, options, ms);
451
+ return {
452
+ code: ms.toString()
453
+ };
454
+ });
455
+ }
456
+ function createJsHandler(options) {
457
+ const { mangleContext, arbitraryValues, escapeMap, jsPreserveClass, generateMap, jsAstTool, babelParserOptions } = options;
458
+ function _jsHandler(rawSource, set, options2) {
459
+ const opts = defuOverrideArray(options2, {
460
+ classNameSet: set,
461
+ escapeMap,
462
+ arbitraryValues,
463
+ mangleContext,
464
+ jsPreserveClass,
465
+ generateMap,
466
+ jsAstTool,
467
+ babelParserOptions
468
+ });
469
+ if (opts.jsAstTool === "ast-grep") {
470
+ return jsHandlerAsync(rawSource, opts);
471
+ }
472
+ return jsHandler(rawSource, opts);
473
+ }
474
+ function sync(rawSource, set, options2) {
475
+ const opts = defuOverrideArray(options2, {
476
+ classNameSet: set,
477
+ escapeMap,
478
+ arbitraryValues,
479
+ mangleContext,
480
+ jsPreserveClass,
481
+ generateMap,
482
+ jsAstTool,
483
+ babelParserOptions
484
+ });
485
+ return jsHandler(rawSource, opts);
486
+ }
487
+ _jsHandler.sync = sync;
488
+ return _jsHandler;
489
+ }
490
+
491
+ // src/defaults.ts
492
+ var defaultOptions = {
493
+ cssMatcher: (file) => /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/.test(file),
494
+ htmlMatcher: (file) => /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty)ml|swan)$/.test(file),
495
+ jsMatcher: (file) => {
496
+ if (file.includes("node_modules")) {
497
+ return false;
498
+ }
499
+ return /.+\.[cm]?js?$/.test(file);
500
+ },
501
+ mainCssChunkMatcher: (file, appType) => {
502
+ switch (appType) {
503
+ case "uni-app": {
504
+ return /^common\/main/.test(file);
505
+ }
506
+ case "uni-app-vite": {
507
+ return file.startsWith("app") || /^common\/main/.test(file);
508
+ }
509
+ case "mpx": {
510
+ return file.startsWith("app");
511
+ }
512
+ case "taro": {
513
+ return file.startsWith("app");
514
+ }
515
+ case "remax": {
516
+ return file.startsWith("app");
517
+ }
518
+ case "rax": {
519
+ return file.startsWith("bundle");
520
+ }
521
+ case "native": {
522
+ return file.startsWith("app");
523
+ }
524
+ case "kbone": {
525
+ return /^(?:common\/)?miniprogram-app/.test(file);
526
+ }
527
+ default: {
528
+ return true;
529
+ }
530
+ }
531
+ },
532
+ wxsMatcher: () => {
533
+ return false;
534
+ },
535
+ // https://tailwindcss.com/docs/preflight#border-styles-are-reset-globally
536
+ cssPreflight: {
537
+ "box-sizing": "border-box",
538
+ "border-width": "0",
539
+ "border-style": "solid",
540
+ "border-color": "currentColor"
541
+ },
542
+ disabled: false,
543
+ customRuleCallback: noop,
544
+ onLoad: noop,
545
+ onStart: noop,
546
+ onEnd: noop,
547
+ onUpdate: noop,
548
+ customAttributes: {},
549
+ customReplaceDictionary: escape_exports.SimpleMappingChars2String,
550
+ appType: void 0,
551
+ arbitraryValues: {
552
+ allowDoubleQuotes: false
553
+ },
554
+ cssChildCombinatorReplaceValue: ["view"],
555
+ inlineWxs: false,
556
+ injectAdditionalCssVarScope: false,
557
+ jsPreserveClass: (keyword) => {
558
+ if (keyword === "*") {
559
+ return true;
560
+ }
561
+ return false;
562
+ },
563
+ disabledDefaultTemplateHandler: false,
564
+ cssSelectorReplacement: {
565
+ root: "page",
566
+ universal: ["view", "text"]
567
+ },
568
+ babelParserOptions: {
569
+ sourceType: "unambiguous"
570
+ },
571
+ postcssOptions: {},
572
+ cssRemoveHoverPseudoClass: true
573
+ // jsAstTool: 'ast-grep'
574
+ };
575
+
576
+ // src/wxml/utils.ts
577
+ var t = __toESM(require("@babel/types"));
578
+ var import_htmlparser2 = require("htmlparser2");
579
+ var import_magic_string2 = __toESM(require("magic-string"));
580
+
581
+ // src/wxml/Tokenizer.ts
582
+ var Tokenizer = class {
583
+ constructor() {
584
+ this.reset();
585
+ }
586
+ processChar(char, index) {
587
+ switch (this.state) {
588
+ case 0 /* START */:
589
+ if (char === " ") {
590
+ } else if (char === "{") {
591
+ this.state = 2 /* OPEN_BRACE */;
592
+ this.bufferStartIndex = index;
593
+ this.buffer += char;
594
+ this.expressionBuffer = char;
595
+ this.expressionStartIndex = index;
596
+ } else {
597
+ this.state = 1 /* TEXT */;
598
+ this.bufferStartIndex = index;
599
+ this.buffer += char;
600
+ }
601
+ break;
602
+ case 1 /* TEXT */:
603
+ if (char === " ") {
604
+ this.tokens.push({ start: this.bufferStartIndex, end: index, value: this.buffer, expressions: this.expressions });
605
+ this.buffer = "";
606
+ this.expressions = [];
607
+ this.state = 0 /* START */;
608
+ } else if (char === "{") {
609
+ this.buffer += char;
610
+ this.expressionBuffer = char;
611
+ this.expressionStartIndex = index;
612
+ this.state = 2 /* OPEN_BRACE */;
613
+ } else {
614
+ this.buffer += char;
615
+ }
616
+ break;
617
+ case 2 /* OPEN_BRACE */:
618
+ if (char === "}") {
619
+ this.buffer += char;
620
+ this.expressionBuffer += char;
621
+ this.state = 3 /* POTENTIAL_CLOSE */;
622
+ } else {
623
+ this.buffer += char;
624
+ this.expressionBuffer += char;
625
+ }
626
+ break;
627
+ case 3 /* POTENTIAL_CLOSE */:
628
+ if (char === "}") {
629
+ this.buffer += char;
630
+ this.expressionBuffer += char;
631
+ this.expressions.push({
632
+ start: this.expressionStartIndex,
633
+ end: index + 1,
634
+ value: this.expressionBuffer
635
+ });
636
+ this.expressionBuffer = "";
637
+ this.state = 4 /* BRACES_COMPLETE */;
638
+ } else {
639
+ this.buffer += char;
640
+ this.expressionBuffer += char;
641
+ this.state = 2 /* OPEN_BRACE */;
642
+ }
643
+ break;
644
+ case 4 /* BRACES_COMPLETE */:
645
+ if (char === " ") {
646
+ this.tokens.push({
647
+ start: this.bufferStartIndex,
648
+ end: index,
649
+ value: this.buffer,
650
+ expressions: this.expressions
651
+ });
652
+ this.buffer = "";
653
+ this.expressions = [];
654
+ this.state = 0 /* START */;
655
+ } else if (char === "{") {
656
+ this.expressionStartIndex = index;
657
+ this.expressionBuffer = char;
658
+ this.buffer += char;
659
+ this.state = 2 /* OPEN_BRACE */;
660
+ } else {
661
+ this.buffer += char;
662
+ this.state = 1 /* TEXT */;
663
+ }
664
+ break;
665
+ default:
666
+ throw new Error("Unexpected state");
667
+ }
668
+ }
669
+ run(input) {
670
+ for (let i = 0; i < input.length; i++) {
671
+ const char = input[i];
672
+ this.processChar(char, i);
673
+ }
674
+ if (this.buffer.length > 0) {
675
+ this.tokens.push({
676
+ start: this.bufferStartIndex,
677
+ end: input.length,
678
+ value: this.buffer,
679
+ expressions: this.expressions
680
+ });
681
+ }
682
+ return this.tokens;
683
+ }
684
+ reset() {
685
+ this.state = 0 /* START */;
686
+ this.buffer = "";
687
+ this.tokens = [];
688
+ this.bufferStartIndex = 0;
689
+ this.expressionBuffer = "";
690
+ this.expressionStartIndex = 0;
691
+ this.expressions = [];
692
+ }
693
+ };
694
+
695
+ // src/wxml/utils.ts
696
+ function generateCode(match, options = {}) {
697
+ try {
698
+ const { jsHandler: jsHandler2, runtimeSet } = options;
699
+ if (jsHandler2 && jsHandler2.sync && runtimeSet) {
700
+ const { code } = jsHandler2.sync(match, runtimeSet);
701
+ return code;
702
+ } else {
703
+ const ms = new import_magic_string2.default(match);
704
+ const ast = (0, import_parser.parseExpression)(match);
705
+ traverse(ast, {
706
+ StringLiteral(path2) {
707
+ var _a, _b;
708
+ if (t.isMemberExpression(path2.parent)) {
709
+ return;
710
+ }
711
+ if (t.isBinaryExpression(path2.parent) && (t.isConditionalExpression((_a = path2.parentPath) == null ? void 0 : _a.parent) || t.isLogicalExpression((_b = path2.parentPath) == null ? void 0 : _b.parent))) {
712
+ return;
713
+ }
714
+ const n = path2.node;
715
+ replaceHandleValue(
716
+ n.value,
717
+ n,
718
+ {
719
+ mangleContext: options.mangleContext,
720
+ escapeMap: options.escapeMap,
721
+ classNameSet: options.runtimeSet,
722
+ needEscaped: true,
723
+ always: true
724
+ },
725
+ ms,
726
+ 1
727
+ );
728
+ },
729
+ noScope: true
730
+ });
731
+ return ms.toString();
732
+ }
733
+ } catch (e) {
734
+ return match;
735
+ }
736
+ }
737
+ function extract(original, reg) {
738
+ let match = reg.exec(original);
739
+ const sources = [];
740
+ while (match !== null) {
741
+ const start = match.index;
742
+ const end = reg.lastIndex;
743
+ sources.push({
744
+ start,
745
+ end,
746
+ raw: match[1]
747
+ });
748
+ match = reg.exec(original);
749
+ }
750
+ return sources;
751
+ }
752
+ function extractSource(original) {
753
+ return extract(original, reg_exports.variableRegExp);
754
+ }
755
+ function handleEachClassFragment(original, options = {}) {
756
+ const sources = extractSource(original);
757
+ if (sources.length > 0) {
758
+ const resultArray = [];
759
+ let p = 0;
760
+ for (let i = 0; i < sources.length; i++) {
761
+ const m = sources[i];
762
+ const before = original.slice(p, m.start);
763
+ resultArray.push(
764
+ replaceWxml(before, {
765
+ keepEOL: true,
766
+ escapeMap: options.escapeMap,
767
+ mangleContext: options.mangleContext,
768
+ // 首的str才会被转译
769
+ // example: 2xl:xx 2x{{y}}
770
+ ignoreHead: p > 0
771
+ })
772
+ );
773
+ p = m.start;
774
+ if (m.raw.trim().length > 0) {
775
+ const code = generateCode(m.raw, options);
776
+ const source = `{{${code}}}`;
777
+ m.source = source;
778
+ } else {
779
+ m.source = "";
780
+ }
781
+ resultArray.push(m.source);
782
+ p = m.end;
783
+ if (i === sources.length - 1) {
784
+ const after = original.slice(m.end);
785
+ resultArray.push(
786
+ replaceWxml(after, {
787
+ keepEOL: true,
788
+ escapeMap: options.escapeMap,
789
+ mangleContext: options.mangleContext,
790
+ ignoreHead: true
791
+ })
792
+ );
793
+ }
794
+ }
795
+ return resultArray.filter(Boolean).join("").trim();
796
+ } else {
797
+ return replaceWxml(original, {
798
+ keepEOL: false,
799
+ escapeMap: options.escapeMap,
800
+ mangleContext: options.mangleContext,
801
+ ignoreHead: false
802
+ });
803
+ }
804
+ }
805
+ function templateReplacer(original, options = {}) {
806
+ const ms = new import_magic_string2.default(original);
807
+ const tokenizer = new Tokenizer();
808
+ const tokens = tokenizer.run(ms.original);
809
+ for (const token of tokens) {
810
+ const target = handleEachClassFragment(token.value, options);
811
+ ms.update(token.start, token.end, target);
812
+ }
813
+ return ms.toString();
814
+ }
815
+ function regTest(reg, str) {
816
+ reg.lastIndex = 0;
817
+ return reg.test(str);
818
+ }
819
+ function isPropsMatch(props, attr) {
820
+ if (Array.isArray(props)) {
821
+ for (const prop of props) {
822
+ const res = typeof prop === "string" ? prop.toLowerCase() === attr.toLowerCase() : regTest(prop, attr);
823
+ if (res) {
824
+ return res;
825
+ }
826
+ }
827
+ return false;
828
+ } else if (typeof props === "string") {
829
+ return props === attr;
830
+ } else {
831
+ return regTest(props, attr);
832
+ }
833
+ }
834
+ function customTemplateHandler(rawSource, options) {
835
+ return __async(this, null, function* () {
836
+ const {
837
+ customAttributesEntities = [],
838
+ disabledDefaultTemplateHandler,
839
+ inlineWxs,
840
+ runtimeSet,
841
+ jsHandler: jsHandler2
842
+ } = options != null ? options : {};
843
+ const s = new import_magic_string2.default(rawSource);
844
+ let tag = "";
845
+ const wxsArray = [];
846
+ const parser = new import_htmlparser2.Parser(
847
+ {
848
+ onopentagname(name) {
849
+ tag = name;
850
+ },
851
+ onattribute(name, value, quote) {
852
+ if (value) {
853
+ let update2 = function() {
854
+ s.update(
855
+ parser.startIndex + name.length + 2,
856
+ // !important
857
+ // htmlparser2 9.0.0: parser.endIndex
858
+ // htmlparser2 9.1.0: parser.endIndex - 1
859
+ // https://github.com/sonofmagic/weapp-tailwindcss/issues/269
860
+ parser.endIndex - 1,
861
+ templateReplacer(value, __spreadProps(__spreadValues({}, options), {
862
+ quote
863
+ }))
864
+ );
865
+ };
866
+ var update = update2;
867
+ if (!disabledDefaultTemplateHandler && (name === "class" || name === "hover-class" || name === "virtualHostClass" || name === "virtualhostclass")) {
868
+ update2();
869
+ }
870
+ for (const [t2, props] of customAttributesEntities) {
871
+ if (t2 === "*") {
872
+ if (isPropsMatch(props, name)) {
873
+ update2();
874
+ }
875
+ } else if (typeof t2 === "string") {
876
+ if (t2 === tag && isPropsMatch(props, name)) {
877
+ update2();
878
+ }
879
+ } else if (regTest(t2, tag) && isPropsMatch(props, name)) {
880
+ update2();
881
+ }
882
+ }
883
+ }
884
+ },
885
+ ontext(data) {
886
+ if (inlineWxs && tag === "wxs") {
887
+ wxsArray.push({
888
+ data,
889
+ endIndex: parser.endIndex + 1,
890
+ startIndex: parser.startIndex
891
+ });
892
+ }
893
+ },
894
+ onclosetag() {
895
+ tag = "";
896
+ }
897
+ },
898
+ {
899
+ xmlMode: true
900
+ }
901
+ );
902
+ parser.write(s.original);
903
+ parser.end();
904
+ for (const { data, endIndex, startIndex } of wxsArray) {
905
+ const { code } = yield jsHandler2(data, runtimeSet);
906
+ s.update(startIndex, endIndex, code);
907
+ }
908
+ return s.toString();
909
+ });
910
+ }
911
+ function createTemplateHandler(options = {}) {
912
+ return (rawSource, opt = {}) => {
913
+ return customTemplateHandler(rawSource, defuOverrideArray(opt, options));
914
+ };
915
+ }
916
+
917
+ // src/postcss/index.ts
918
+ var import_postcss2 = __toESM(require("postcss"));
919
+
920
+ // src/postcss/plugins/index.ts
921
+ var import_postcss_is_pseudo_class = __toESM(require("@csstools/postcss-is-pseudo-class"));
922
+ var import_postcss_rem_to_responsive_pixel = __toESM(require("postcss-rem-to-responsive-pixel"));
923
+
924
+ // src/postcss/selectorParser.ts
925
+ var import_postcss_selector_parser = __toESM(require("postcss-selector-parser"));
926
+
927
+ // src/postcss/shared.ts
928
+ function internalCssSelectorReplacer(selectors, options = {
929
+ escapeMap: escape_exports.SimpleMappingChars2String
930
+ }) {
931
+ const { mangleContext, escapeMap } = options;
932
+ if (mangleContext) {
933
+ selectors = mangleContext.cssHandler(selectors);
934
+ }
935
+ return (0, escape_exports.escape)(selectors, {
936
+ map: escapeMap
937
+ });
938
+ }
939
+ function composeIsPseudo(strs) {
940
+ if (typeof strs === "string") {
941
+ return strs;
942
+ }
943
+ if (strs.length > 1) {
944
+ return `:is(${strs.join(",")})`;
945
+ }
946
+ return strs.join("");
947
+ }
948
+
949
+ // src/postcss/selectorParser.ts
950
+ function createRuleTransform(rule, options) {
951
+ const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
952
+ const transform = (selectors) => {
953
+ selectors.walk((selector) => {
954
+ if (selector.type === "universal" && cssSelectorReplacement && cssSelectorReplacement.universal) {
955
+ selector.value = composeIsPseudo(cssSelectorReplacement.universal);
956
+ }
957
+ if (cssRemoveHoverPseudoClass && selector.type === "selector") {
958
+ const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
959
+ node && selector.remove();
960
+ }
961
+ if (selector.type === "pseudo" && selector.value === ":root" && cssSelectorReplacement && cssSelectorReplacement.root) {
962
+ selector.value = composeIsPseudo(cssSelectorReplacement.root);
963
+ }
964
+ if (selector.type === "class") {
965
+ selector.value = internalCssSelectorReplacer(selector.value, {
966
+ escapeMap,
967
+ mangleContext
968
+ });
969
+ }
970
+ });
971
+ if (selectors.length === 0) {
972
+ rule.remove();
973
+ }
974
+ };
975
+ return transform;
976
+ }
977
+ function getRuleTransformer(rule, options) {
978
+ return (0, import_postcss_selector_parser.default)(createRuleTransform(rule, options));
979
+ }
980
+ function ruleTransformSync(rule, options) {
981
+ const transformer = getRuleTransformer(rule, options);
982
+ return transformer.transformSync(rule, {
983
+ lossless: false,
984
+ updateSelector: true
985
+ });
986
+ }
987
+ function isOnlyBeforeAndAfterPseudoElement(node) {
988
+ let b = false;
989
+ let a = false;
990
+ (0, import_postcss_selector_parser.default)((selectors) => {
991
+ selectors.walkPseudos((s) => {
992
+ var _a;
993
+ if (((_a = s.parent) == null ? void 0 : _a.length) === 1) {
994
+ if (/^:?:before$/.test(s.value)) {
995
+ b = true;
996
+ }
997
+ if (/^:?:after$/.test(s.value)) {
998
+ a = true;
999
+ }
1000
+ }
1001
+ });
1002
+ }).astSync(node);
1003
+ return b && a;
1004
+ }
1005
+ var fallbackRemove = (0, import_postcss_selector_parser.default)((selectors) => {
1006
+ selectors.walk((selector) => {
1007
+ var _a, _b;
1008
+ if (selector.type === "universal") {
1009
+ (_a = selector.parent) == null ? void 0 : _a.remove();
1010
+ }
1011
+ if (selector.type === "pseudo" && selector.value === ":is") {
1012
+ (_b = selector.parent) == null ? void 0 : _b.remove();
1013
+ }
1014
+ });
1015
+ });
1016
+
1017
+ // src/postcss/mp.ts
1018
+ var import_postcss = require("postcss");
1019
+
1020
+ // src/postcss/cssVars.ts
1021
+ var cssVars_default = [
1022
+ {
1023
+ prop: "--tw-border-spacing-x",
1024
+ value: "0"
1025
+ },
1026
+ {
1027
+ prop: "--tw-border-spacing-y",
1028
+ value: "0"
1029
+ },
1030
+ {
1031
+ prop: "--tw-translate-x",
1032
+ value: "0"
1033
+ },
1034
+ {
1035
+ prop: "--tw-translate-y",
1036
+ value: "0"
1037
+ },
1038
+ {
1039
+ prop: "--tw-rotate",
1040
+ value: "0"
1041
+ },
1042
+ {
1043
+ prop: "--tw-skew-x",
1044
+ value: "0"
1045
+ },
1046
+ {
1047
+ prop: "--tw-skew-y",
1048
+ value: "0"
1049
+ },
1050
+ {
1051
+ prop: "--tw-scale-x",
1052
+ value: "1"
1053
+ },
1054
+ {
1055
+ prop: "--tw-scale-y",
1056
+ value: "1"
1057
+ },
1058
+ {
1059
+ prop: "--tw-pan-x",
1060
+ value: " "
1061
+ },
1062
+ {
1063
+ prop: "--tw-pan-y",
1064
+ value: " "
1065
+ },
1066
+ {
1067
+ prop: "--tw-pinch-zoom",
1068
+ value: " "
1069
+ },
1070
+ {
1071
+ prop: "--tw-scroll-snap-strictness",
1072
+ value: "proximity"
1073
+ },
1074
+ {
1075
+ prop: "--tw-gradient-from-position",
1076
+ value: " "
1077
+ },
1078
+ {
1079
+ prop: "--tw-gradient-via-position",
1080
+ value: " "
1081
+ },
1082
+ {
1083
+ prop: "--tw-gradient-to-position",
1084
+ value: " "
1085
+ },
1086
+ {
1087
+ prop: "--tw-ordinal",
1088
+ value: " "
1089
+ },
1090
+ {
1091
+ prop: "--tw-slashed-zero",
1092
+ value: " "
1093
+ },
1094
+ {
1095
+ prop: "--tw-numeric-figure",
1096
+ value: " "
1097
+ },
1098
+ {
1099
+ prop: "--tw-numeric-spacing",
1100
+ value: " "
1101
+ },
1102
+ {
1103
+ prop: "--tw-numeric-fraction",
1104
+ value: " "
1105
+ },
1106
+ {
1107
+ prop: "--tw-ring-inset",
1108
+ value: " "
1109
+ },
1110
+ {
1111
+ prop: "--tw-ring-offset-width",
1112
+ value: "0px"
1113
+ },
1114
+ {
1115
+ prop: "--tw-ring-offset-color",
1116
+ value: "#fff"
1117
+ },
1118
+ {
1119
+ prop: "--tw-ring-color",
1120
+ value: "rgb(59 130 246 / 0.5)"
1121
+ },
1122
+ {
1123
+ prop: "--tw-ring-offset-shadow",
1124
+ value: "0 0 #0000"
1125
+ },
1126
+ {
1127
+ prop: "--tw-ring-shadow",
1128
+ value: "0 0 #0000"
1129
+ },
1130
+ {
1131
+ prop: "--tw-shadow",
1132
+ value: "0 0 #0000"
1133
+ },
1134
+ {
1135
+ prop: "--tw-shadow-colored",
1136
+ value: "0 0 #0000"
1137
+ },
1138
+ {
1139
+ prop: "--tw-blur",
1140
+ value: " "
1141
+ },
1142
+ {
1143
+ prop: "--tw-brightness",
1144
+ value: " "
1145
+ },
1146
+ {
1147
+ prop: "--tw-contrast",
1148
+ value: " "
1149
+ },
1150
+ {
1151
+ prop: "--tw-grayscale",
1152
+ value: " "
1153
+ },
1154
+ {
1155
+ prop: "--tw-hue-rotate",
1156
+ value: " "
1157
+ },
1158
+ {
1159
+ prop: "--tw-invert",
1160
+ value: " "
1161
+ },
1162
+ {
1163
+ prop: "--tw-saturate",
1164
+ value: " "
1165
+ },
1166
+ {
1167
+ prop: "--tw-sepia",
1168
+ value: " "
1169
+ },
1170
+ {
1171
+ prop: "--tw-drop-shadow",
1172
+ value: " "
1173
+ },
1174
+ {
1175
+ prop: "--tw-backdrop-blur",
1176
+ value: " "
1177
+ },
1178
+ {
1179
+ prop: "--tw-backdrop-brightness",
1180
+ value: " "
1181
+ },
1182
+ {
1183
+ prop: "--tw-backdrop-contrast",
1184
+ value: " "
1185
+ },
1186
+ {
1187
+ prop: "--tw-backdrop-grayscale",
1188
+ value: " "
1189
+ },
1190
+ {
1191
+ prop: "--tw-backdrop-hue-rotate",
1192
+ value: " "
1193
+ },
1194
+ {
1195
+ prop: "--tw-backdrop-invert",
1196
+ value: " "
1197
+ },
1198
+ {
1199
+ prop: "--tw-backdrop-opacity",
1200
+ value: " "
1201
+ },
1202
+ {
1203
+ prop: "--tw-backdrop-saturate",
1204
+ value: " "
1205
+ },
1206
+ {
1207
+ prop: "--tw-backdrop-sepia",
1208
+ value: " "
1209
+ },
1210
+ {
1211
+ prop: "--tw-contain-size",
1212
+ value: " "
1213
+ },
1214
+ {
1215
+ prop: "--tw-contain-layout",
1216
+ value: " "
1217
+ },
1218
+ {
1219
+ prop: "--tw-contain-paint",
1220
+ value: " "
1221
+ },
1222
+ {
1223
+ prop: "--tw-contain-style",
1224
+ value: " "
1225
+ }
1226
+ ];
1227
+
1228
+ // src/postcss/mp.ts
1229
+ var initialNodes = cssVars_default.map((x) => {
1230
+ return new import_postcss.Declaration({
1231
+ prop: x.prop,
1232
+ value: x.value
1233
+ });
1234
+ });
1235
+ var PATTERNS = [
1236
+ /:not\(template\)\s*[~+]\s*:not\(template\)/.source,
1237
+ /:not\(\[hidden\]\)\s*[~+]\s*:not\(\[hidden\]\)/.source
1238
+ ].join("|");
1239
+ var BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, "g");
1240
+ function testIfVariablesScope(node, count = 2) {
1241
+ if (isOnlyBeforeAndAfterPseudoElement(node)) {
1242
+ const nodes = node.nodes;
1243
+ let c = 0;
1244
+ for (const tryTestDecl of nodes) {
1245
+ if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
1246
+ c++;
1247
+ }
1248
+ if (c >= count) {
1249
+ return true;
1250
+ }
1251
+ }
1252
+ return false;
1253
+ }
1254
+ return false;
1255
+ }
1256
+ function testIfTwBackdrop(node, count = 2) {
1257
+ if (node.type === "rule" && node.selector === "::backdrop") {
1258
+ const nodes = node.nodes;
1259
+ let c = 0;
1260
+ for (const tryTestDecl of nodes) {
1261
+ if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
1262
+ c++;
1263
+ }
1264
+ if (c >= count) {
1265
+ return true;
1266
+ }
1267
+ }
1268
+ return false;
1269
+ }
1270
+ return false;
1271
+ }
1272
+ function makePseudoVarRule() {
1273
+ const pseudoVarRule = new import_postcss.Rule({
1274
+ // selectors: ['::before', '::after'],
1275
+ selector: "::before,::after"
1276
+ });
1277
+ pseudoVarRule.append(
1278
+ new import_postcss.Declaration({
1279
+ prop: "--tw-content",
1280
+ value: '""'
1281
+ })
1282
+ );
1283
+ return pseudoVarRule;
1284
+ }
1285
+ function remakeCssVarSelector(selectors, options) {
1286
+ const { cssPreflightRange, cssSelectorReplacement } = options;
1287
+ if (cssPreflightRange === "all" && !selectors.includes(":not(not)")) {
1288
+ selectors.push(":not(not)");
1289
+ }
1290
+ if (cssSelectorReplacement) {
1291
+ if (Array.isArray(cssSelectorReplacement.universal)) {
1292
+ if (!cssSelectorReplacement.universal.every((x) => {
1293
+ return selectors.includes(x);
1294
+ }) && !selectors.includes("*")) {
1295
+ selectors.unshift("*");
1296
+ }
1297
+ } else if (typeof cssSelectorReplacement.universal === "string" && !selectors.includes(cssSelectorReplacement.universal) && !selectors.includes("*")) {
1298
+ selectors.unshift("*");
1299
+ }
1300
+ }
1301
+ return selectors;
1302
+ }
1303
+ function remakeCombinatorSelector(selector, cssChildCombinatorReplaceValue) {
1304
+ let childCombinatorReplaceValue = "view + view";
1305
+ if (Array.isArray(cssChildCombinatorReplaceValue) && cssChildCombinatorReplaceValue.length > 0) {
1306
+ const x = composeIsPseudo(cssChildCombinatorReplaceValue);
1307
+ childCombinatorReplaceValue = `${x} + ${x}`;
1308
+ } else if (typeof cssChildCombinatorReplaceValue === "string") {
1309
+ childCombinatorReplaceValue = cssChildCombinatorReplaceValue;
1310
+ }
1311
+ return selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
1312
+ }
1313
+ function commonChunkPreflight(node, options) {
1314
+ const { ctx, cssChildCombinatorReplaceValue, cssInjectPreflight, injectAdditionalCssVarScope } = options;
1315
+ node.selector = remakeCombinatorSelector(node.selector, cssChildCombinatorReplaceValue);
1316
+ if (testIfVariablesScope(node)) {
1317
+ ctx == null ? void 0 : ctx.markVariablesScope(node);
1318
+ node.selectors = remakeCssVarSelector(node.selectors, options);
1319
+ node.before(makePseudoVarRule());
1320
+ if (typeof cssInjectPreflight === "function") {
1321
+ node.append(...cssInjectPreflight());
1322
+ }
1323
+ }
1324
+ if (injectAdditionalCssVarScope && testIfTwBackdrop(node)) {
1325
+ const syntheticRule = new import_postcss.Rule({
1326
+ selectors: ["*", "::after", "::before"],
1327
+ nodes: initialNodes
1328
+ });
1329
+ syntheticRule.selectors = remakeCssVarSelector(syntheticRule.selectors, options);
1330
+ node.before(syntheticRule);
1331
+ node.before(makePseudoVarRule());
1332
+ if (typeof cssInjectPreflight === "function") {
1333
+ syntheticRule.append(...cssInjectPreflight());
1334
+ }
1335
+ }
1336
+ }
1337
+
1338
+ // src/constants.ts
1339
+ var postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
1340
+
1341
+ // src/postcss/plugins/pre.ts
1342
+ function isAtMediaHover(atRule) {
1343
+ return /media\(\s*hover\s*:\s*hover\s*\)/.test(atRule.name) || atRule.name === "media" && /\(\s*hover\s*:\s*hover\s*\)/.test(atRule.params);
1344
+ }
1345
+ var postcssWeappTailwindcssPrePlugin = (options = {
1346
+ isMainChunk: true
1347
+ }) => {
1348
+ const { isMainChunk } = options;
1349
+ const p = {
1350
+ postcssPlugin,
1351
+ Rule(rule) {
1352
+ ruleTransformSync(rule, options);
1353
+ },
1354
+ AtRule(atRule) {
1355
+ if (isAtMediaHover(atRule)) {
1356
+ if (atRule.nodes) {
1357
+ atRule.replaceWith(atRule.nodes);
1358
+ } else {
1359
+ atRule.remove();
1360
+ }
1361
+ }
1362
+ }
1363
+ };
1364
+ if (isMainChunk) {
1365
+ p.Once = (root) => {
1366
+ root.walkRules((rule) => {
1367
+ commonChunkPreflight(rule, options);
1368
+ });
1369
+ };
1370
+ }
1371
+ return p;
1372
+ };
1373
+ postcssWeappTailwindcssPrePlugin.postcss = true;
1374
+
1375
+ // src/postcss/plugins/post.ts
1376
+ var postcssWeappTailwindcssPostPlugin = (options = {
1377
+ isMainChunk: true
1378
+ }) => {
1379
+ const { customRuleCallback, isMainChunk, ctx } = options;
1380
+ const p = {
1381
+ postcssPlugin
1382
+ };
1383
+ if (isMainChunk) {
1384
+ p.OnceExit = (root) => {
1385
+ root.walkRules((rule) => {
1386
+ if (ctx) {
1387
+ if (ctx.isVariablesScope(rule)) {
1388
+ fallbackRemove.transformSync(rule, {
1389
+ updateSelector: true,
1390
+ lossless: false
1391
+ });
1392
+ }
1393
+ } else if (testIfVariablesScope(rule)) {
1394
+ fallbackRemove.transformSync(rule, {
1395
+ updateSelector: true,
1396
+ lossless: false
1397
+ });
1398
+ }
1399
+ });
1400
+ };
1401
+ }
1402
+ if (typeof customRuleCallback === "function") {
1403
+ p.Rule = (rule) => {
1404
+ customRuleCallback(rule, options);
1405
+ };
1406
+ }
1407
+ return p;
1408
+ };
1409
+ postcssWeappTailwindcssPostPlugin.postcss = true;
1410
+
1411
+ // src/postcss/symbols.ts
1412
+ var VariablesScopeSymbol = Symbol("VariablesScope");
1413
+
1414
+ // src/postcss/plugins/ctx.ts
1415
+ function createContext() {
1416
+ const variablesScopeWeakMap = /* @__PURE__ */ new WeakMap();
1417
+ function isVariablesScope(rule) {
1418
+ return variablesScopeWeakMap.get(rule) === VariablesScopeSymbol;
1419
+ }
1420
+ function markVariablesScope(rule) {
1421
+ variablesScopeWeakMap.set(rule, VariablesScopeSymbol);
1422
+ }
1423
+ return {
1424
+ variablesScopeWeakMap,
1425
+ isVariablesScope,
1426
+ markVariablesScope
1427
+ };
1428
+ }
1429
+
1430
+ // src/postcss/plugins/index.ts
1431
+ var import_postcss_is_pseudo_class2 = __toESM(require("@csstools/postcss-is-pseudo-class"));
1432
+ var import_postcss_rem_to_responsive_pixel2 = __toESM(require("postcss-rem-to-responsive-pixel"));
1433
+ function getPlugins(options) {
1434
+ var _a, _b;
1435
+ const ctx = createContext();
1436
+ options.ctx = ctx;
1437
+ const plugins = [
1438
+ ...(_b = (_a = options.postcssOptions) == null ? void 0 : _a.plugins) != null ? _b : [],
1439
+ postcssWeappTailwindcssPrePlugin(options),
1440
+ (0, import_postcss_is_pseudo_class.default)({
1441
+ specificityMatchingName: "weapp-tw-ig"
1442
+ })
1443
+ ];
1444
+ if (options.rem2rpx) {
1445
+ plugins.push(
1446
+ (0, import_postcss_rem_to_responsive_pixel.default)(
1447
+ typeof options.rem2rpx === "object" ? options.rem2rpx : {
1448
+ rootValue: 32,
1449
+ propList: ["*"],
1450
+ transformUnit: "rpx"
1451
+ }
1452
+ )
1453
+ );
1454
+ }
1455
+ plugins.push(postcssWeappTailwindcssPostPlugin(options));
1456
+ return plugins;
1457
+ }
1458
+
1459
+ // src/postcss/index.ts
1460
+ function styleHandler(rawSource, options) {
1461
+ return __async(this, null, function* () {
1462
+ var _a, _b;
1463
+ return (yield (0, import_postcss2.default)(getPlugins(options)).process(
1464
+ rawSource,
1465
+ (_b = (_a = options.postcssOptions) == null ? void 0 : _a.options) != null ? _b : {
1466
+ from: void 0
1467
+ }
1468
+ ).async()).css;
1469
+ });
1470
+ }
1471
+ function createStyleHandler(options) {
1472
+ return (rawSource, opt) => {
1473
+ return styleHandler(
1474
+ rawSource,
1475
+ defuOverrideArray(opt, options)
1476
+ );
1477
+ };
1478
+ }
1479
+
1480
+ // src/postcss/preflight.ts
1481
+ function createInjectPreflight(options) {
1482
+ const result = [];
1483
+ if (options && typeof options === "object") {
1484
+ const entries = Object.entries(options);
1485
+ for (const [prop, value] of entries) {
1486
+ if (value !== false) {
1487
+ result.push({
1488
+ prop,
1489
+ value: value.toString()
1490
+ });
1491
+ }
1492
+ }
1493
+ }
1494
+ return () => {
1495
+ return result;
1496
+ };
1497
+ }
1498
+
1499
+ // src/tailwindcss/patcher.ts
1500
+ var import_node_path = __toESM(require("path"));
1501
+ var import_node_process = __toESM(require("process"));
1502
+ var import_tailwindcss_patch = require("tailwindcss-patch");
1503
+ function createTailwindcssPatcher(basedir, cacheDir, supportCustomLengthUnitsPatch) {
1504
+ const cache = {};
1505
+ if (cacheDir) {
1506
+ if (import_node_path.default.isAbsolute(cacheDir)) {
1507
+ cache.dir = cacheDir;
1508
+ } else if (basedir) {
1509
+ cache.dir = import_node_path.default.resolve(basedir, cacheDir);
1510
+ } else {
1511
+ cache.dir = import_node_path.default.resolve(import_node_process.default.cwd(), cacheDir);
1512
+ }
1513
+ }
1514
+ return new import_tailwindcss_patch.TailwindcssPatcher({
1515
+ cache,
1516
+ patch: {
1517
+ basedir,
1518
+ applyPatches: {
1519
+ exportContext: true,
1520
+ extendLengthUnits: supportCustomLengthUnitsPatch
1521
+ }
1522
+ }
1523
+ });
1524
+ }
1525
+
1526
+ // src/mangle/index.ts
1527
+ var import_shared5 = require("@tailwindcss-mangle/shared");
1528
+ function getSelf(x) {
1529
+ return x;
1530
+ }
1531
+ var defaultMangleContext = {
1532
+ rawOptions: false,
1533
+ runtimeSet: /* @__PURE__ */ new Set(),
1534
+ classGenerator: new import_shared5.ClassGenerator(),
1535
+ filter: import_shared5.defaultMangleClassFilter,
1536
+ cssHandler: getSelf,
1537
+ jsHandler: getSelf,
1538
+ wxmlHandler: getSelf
1539
+ };
1540
+ function useMangleStore() {
1541
+ const ctx = Object.assign({}, defaultMangleContext);
1542
+ function resetMangle() {
1543
+ return Object.assign(ctx, defaultMangleContext);
1544
+ }
1545
+ function handleValue(rawSource) {
1546
+ const arr = splitCode(rawSource);
1547
+ for (const x of arr) {
1548
+ if (ctx.runtimeSet.has(x)) {
1549
+ rawSource = rawSource.replace(new RegExp((0, reg_exports.escapeStringRegexp)(x)), ctx.classGenerator.generateClassName(x).name);
1550
+ }
1551
+ }
1552
+ return rawSource;
1553
+ }
1554
+ function initMangle(options) {
1555
+ var _a;
1556
+ ctx.rawOptions = options;
1557
+ if (options) {
1558
+ if (options === true) {
1559
+ options = {
1560
+ classGenerator: {},
1561
+ mangleClassFilter: import_shared5.defaultMangleClassFilter
1562
+ };
1563
+ }
1564
+ ctx.classGenerator = new import_shared5.ClassGenerator(options.classGenerator);
1565
+ ctx.filter = (_a = options.mangleClassFilter) != null ? _a : import_shared5.defaultMangleClassFilter;
1566
+ ctx.jsHandler = (rawSource) => {
1567
+ return handleValue(rawSource);
1568
+ };
1569
+ ctx.cssHandler = (rawSource) => {
1570
+ return handleValue(rawSource);
1571
+ };
1572
+ ctx.wxmlHandler = (rawSource) => {
1573
+ return handleValue(rawSource);
1574
+ };
1575
+ }
1576
+ }
1577
+ function setMangleRuntimeSet(runtimeSet) {
1578
+ const newSet = /* @__PURE__ */ new Set();
1579
+ for (const c of runtimeSet) {
1580
+ if (ctx.filter(c)) {
1581
+ newSet.add(c);
1582
+ }
1583
+ }
1584
+ ctx.runtimeSet = newSet;
1585
+ }
1586
+ return {
1587
+ mangleContext: ctx,
1588
+ resetMangle,
1589
+ initMangle,
1590
+ setMangleRuntimeSet
1591
+ };
1592
+ }
1593
+
1594
+ // src/cache/index.ts
1595
+ var import_lru_cache = require("lru-cache");
1596
+ var import_md5 = __toESM(require("md5"));
1597
+ function createCache(options) {
1598
+ const disabled = options === false;
1599
+ const hashMap = /* @__PURE__ */ new Map();
1600
+ const instance = new import_lru_cache.LRUCache({
1601
+ // 可能会添加和删除一些页面和组件, 先设定 1024 吧
1602
+ max: 1024,
1603
+ ttl: 0,
1604
+ ttlAutopurge: false
1605
+ });
1606
+ return {
1607
+ hashMap,
1608
+ instance,
1609
+ hasHashKey(key) {
1610
+ return hashMap.has(key);
1611
+ },
1612
+ getHashValue(key) {
1613
+ return hashMap.get(key);
1614
+ },
1615
+ setHashValue(key, value) {
1616
+ return hashMap.set(key, value);
1617
+ },
1618
+ get(key) {
1619
+ return instance.get(key);
1620
+ },
1621
+ set(key, value) {
1622
+ return instance.set(key, value);
1623
+ },
1624
+ computeHash(message) {
1625
+ return (0, import_md5.default)(message);
1626
+ },
1627
+ calcHashValueChanged(key, hash) {
1628
+ const hit = this.getHashValue(key);
1629
+ if (hit) {
1630
+ this.setHashValue(key, {
1631
+ // new file should be changed
1632
+ changed: hash !== hit.hash,
1633
+ // new hash
1634
+ hash
1635
+ });
1636
+ } else {
1637
+ this.setHashValue(key, {
1638
+ // new file should be changed
1639
+ changed: true,
1640
+ hash
1641
+ });
1642
+ }
1643
+ return this;
1644
+ },
1645
+ has(key) {
1646
+ return instance.has(key);
1647
+ },
1648
+ process(key, callback, fallback) {
1649
+ return __async(this, null, function* () {
1650
+ if (disabled) {
1651
+ const res = yield fallback();
1652
+ if (res) {
1653
+ this.set(res.key, res.source);
1654
+ }
1655
+ } else {
1656
+ const hit = this.getHashValue(key);
1657
+ if (hit && !hit.changed) {
1658
+ const returnFlag = yield callback();
1659
+ if (returnFlag !== false) {
1660
+ return;
1661
+ }
1662
+ }
1663
+ const res = yield fallback();
1664
+ if (res) {
1665
+ this.set(res.key, res.source);
1666
+ }
1667
+ }
1668
+ });
1669
+ }
1670
+ };
1671
+ }
1672
+
1673
+ // src/options.ts
1674
+ function getOptions(opts) {
1675
+ const result = defuOverrideArray(
1676
+ opts,
1677
+ defaultOptions,
1678
+ {}
1679
+ );
1680
+ result.escapeMap = result.customReplaceDictionary;
1681
+ const {
1682
+ cssPreflight,
1683
+ customRuleCallback,
1684
+ cssPreflightRange,
1685
+ customAttributes,
1686
+ supportCustomLengthUnitsPatch,
1687
+ arbitraryValues,
1688
+ cssChildCombinatorReplaceValue,
1689
+ inlineWxs,
1690
+ injectAdditionalCssVarScope,
1691
+ jsPreserveClass,
1692
+ disabledDefaultTemplateHandler,
1693
+ cssSelectorReplacement,
1694
+ rem2rpx,
1695
+ cache,
1696
+ jsAstTool,
1697
+ babelParserOptions,
1698
+ postcssOptions,
1699
+ cssRemoveHoverPseudoClass,
1700
+ escapeMap,
1701
+ mangle,
1702
+ tailwindcssBasedir,
1703
+ appType
1704
+ } = result;
1705
+ const cssInjectPreflight = createInjectPreflight(cssPreflight);
1706
+ const customAttributesEntities = isMap(customAttributes) ? [...customAttributes.entries()] : Object.entries(customAttributes);
1707
+ const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
1708
+ initMangle(mangle);
1709
+ const styleHandler2 = createStyleHandler({
1710
+ cssInjectPreflight,
1711
+ customRuleCallback,
1712
+ cssPreflightRange,
1713
+ escapeMap,
1714
+ mangleContext,
1715
+ cssChildCombinatorReplaceValue,
1716
+ injectAdditionalCssVarScope,
1717
+ cssSelectorReplacement,
1718
+ rem2rpx,
1719
+ postcssOptions,
1720
+ cssRemoveHoverPseudoClass
1721
+ });
1722
+ const jsHandler2 = createJsHandler({
1723
+ escapeMap,
1724
+ mangleContext,
1725
+ arbitraryValues,
1726
+ jsPreserveClass,
1727
+ generateMap: true,
1728
+ jsAstTool,
1729
+ babelParserOptions
1730
+ });
1731
+ const templateHandler = createTemplateHandler({
1732
+ customAttributesEntities,
1733
+ escapeMap,
1734
+ mangleContext,
1735
+ inlineWxs,
1736
+ jsHandler: jsHandler2,
1737
+ disabledDefaultTemplateHandler
1738
+ });
1739
+ result.styleHandler = styleHandler2;
1740
+ result.jsHandler = jsHandler2;
1741
+ result.templateHandler = templateHandler;
1742
+ const twPatcher = createTailwindcssPatcher(tailwindcssBasedir, appType === "mpx" ? "node_modules/tailwindcss-patch/.cache" : void 0, supportCustomLengthUnitsPatch);
1743
+ result.patch = twPatcher.patch;
1744
+ result.setMangleRuntimeSet = setMangleRuntimeSet;
1745
+ result.cache = cache === void 0 || typeof cache === "boolean" ? createCache(cache) : cache;
1746
+ result.twPatcher = twPatcher;
1747
+ return result;
1748
+ }
1749
+
1750
+ // src/debug/index.ts
1751
+ var import_debug = __toESM(require("debug"));
1752
+ var _debug = (0, import_debug.default)("weapp-tw");
1753
+ function createDebug(prefix) {
1754
+ function debug2(formatter, ...args) {
1755
+ return _debug((prefix != null ? prefix : "") + formatter, ...args);
1756
+ }
1757
+ return debug2;
1758
+ }
1759
+
1760
+ // src/bundlers/gulp/index.ts
1761
+ var debug = createDebug();
1762
+ var Transform = import_node_stream.default.Transform;
1763
+ function createPlugins(options = {}) {
1764
+ const opts = getOptions(options);
1765
+ const { templateHandler, styleHandler: styleHandler2, patch, jsHandler: jsHandler2, setMangleRuntimeSet, cache, twPatcher } = opts;
1766
+ let runtimeSet = /* @__PURE__ */ new Set();
1767
+ patch == null ? void 0 : patch();
1768
+ function transformWxss(options2 = {}) {
1769
+ return new Transform({
1770
+ objectMode: true,
1771
+ transform(file, encoding, callback) {
1772
+ return __async(this, null, function* () {
1773
+ runtimeSet = twPatcher.getClassSet();
1774
+ setMangleRuntimeSet(runtimeSet);
1775
+ const error = null;
1776
+ if (file.contents) {
1777
+ const rawSource = file.contents.toString();
1778
+ const hash = cache.computeHash(rawSource);
1779
+ cache.calcHashValueChanged(file.path, hash);
1780
+ yield cache.process(
1781
+ file.path,
1782
+ () => {
1783
+ const source = cache.get(file.path);
1784
+ if (source) {
1785
+ file.contents = import_node_buffer.Buffer.from(source);
1786
+ debug("css cache hit: %s", file.path);
1787
+ } else {
1788
+ return false;
1789
+ }
1790
+ },
1791
+ () => __async(this, null, function* () {
1792
+ const code = yield styleHandler2(rawSource, __spreadValues({
1793
+ isMainChunk: true
1794
+ }, options2));
1795
+ file.contents = import_node_buffer.Buffer.from(code);
1796
+ debug("css handle: %s", file.path);
1797
+ return {
1798
+ key: file.path,
1799
+ source: code
1800
+ };
1801
+ })
1802
+ );
1803
+ }
1804
+ callback(error, file);
1805
+ });
1806
+ }
1807
+ // construct(callback) {
1808
+ // debug('transformWxss start')
1809
+ // callback()
1810
+ // }
1811
+ });
1812
+ }
1813
+ function transformJs(options2 = {}) {
1814
+ return new Transform({
1815
+ objectMode: true,
1816
+ transform(file, encoding, callback) {
1817
+ return __async(this, null, function* () {
1818
+ const error = null;
1819
+ if (file.contents) {
1820
+ const rawSource = file.contents.toString();
1821
+ const hash = cache.computeHash(rawSource);
1822
+ cache.calcHashValueChanged(file.path, hash);
1823
+ yield cache.process(
1824
+ file.path,
1825
+ () => {
1826
+ const source = cache.get(file.path);
1827
+ if (source) {
1828
+ file.contents = import_node_buffer.Buffer.from(source);
1829
+ debug("js cache hit: %s", file.path);
1830
+ } else {
1831
+ return false;
1832
+ }
1833
+ },
1834
+ () => __async(this, null, function* () {
1835
+ const { code } = yield jsHandler2(rawSource, runtimeSet, options2);
1836
+ file.contents = import_node_buffer.Buffer.from(code);
1837
+ debug("js handle: %s", file.path);
1838
+ return {
1839
+ key: file.path,
1840
+ source: code
1841
+ };
1842
+ })
1843
+ );
1844
+ }
1845
+ callback(error, file);
1846
+ });
1847
+ }
1848
+ });
1849
+ }
1850
+ function transformWxml(options2 = {}) {
1851
+ return new Transform({
1852
+ objectMode: true,
1853
+ transform(file, encoding, callback) {
1854
+ return __async(this, null, function* () {
1855
+ const error = null;
1856
+ if (file.contents) {
1857
+ const rawSource = file.contents.toString();
1858
+ const hash = cache.computeHash(rawSource);
1859
+ cache.calcHashValueChanged(file.path, hash);
1860
+ yield cache.process(
1861
+ file.path,
1862
+ () => {
1863
+ const source = cache.get(file.path);
1864
+ if (source) {
1865
+ file.contents = import_node_buffer.Buffer.from(source);
1866
+ debug("html cache hit: %s", file.path);
1867
+ } else {
1868
+ return false;
1869
+ }
1870
+ },
1871
+ () => __async(this, null, function* () {
1872
+ const code = yield templateHandler(rawSource, __spreadValues({
1873
+ runtimeSet
1874
+ }, options2));
1875
+ file.contents = import_node_buffer.Buffer.from(code);
1876
+ debug("html handle: %s", file.path);
1877
+ return {
1878
+ key: file.path,
1879
+ source: code
1880
+ };
1881
+ })
1882
+ );
1883
+ }
1884
+ callback(error, file);
1885
+ });
1886
+ }
1887
+ });
1888
+ }
1889
+ return {
1890
+ transformWxss,
1891
+ transformWxml,
1892
+ transformJs
1893
+ };
1894
+ }
1895
+ // Annotate the CommonJS export names for ESM import in node:
1896
+ 0 && (module.exports = {
1897
+ createPlugins
1898
+ });