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