weapp-tailwindcss 5.1.11 → 5.1.13

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 (54) hide show
  1. package/dist/cache-options-DavPxrhC.js +16 -0
  2. package/dist/cache-options-DwBtLwQe.mjs +5 -0
  3. package/dist/cli.js +10 -6
  4. package/dist/cli.mjs +10 -6
  5. package/dist/context-DRRgW7i2.js +1311 -0
  6. package/dist/context-xSJE588m.mjs +1234 -0
  7. package/dist/core.js +1 -1
  8. package/dist/core.mjs +1 -1
  9. package/dist/css-macro.js +1 -1
  10. package/dist/css-macro.mjs +1 -1
  11. package/dist/defaults.js +119 -5
  12. package/dist/defaults.mjs +114 -1
  13. package/dist/{generator-ROzBodj6.mjs → generator-BvPcmqxU.mjs} +9 -139
  14. package/dist/{generator-Bz94KTkH.js → generator-CS10c9g1.js} +18 -154
  15. package/dist/generator.js +1 -1
  16. package/dist/generator.mjs +1 -1
  17. package/dist/{gulp-BKqMb_Ds.mjs → gulp-BEOzXrbp.mjs} +5 -4
  18. package/dist/{gulp-DfOLvYLs.js → gulp-DNZZvUMq.js} +6 -5
  19. package/dist/gulp.js +1 -1
  20. package/dist/gulp.mjs +1 -1
  21. package/dist/{hmr-timing-DOTdH18A.js → hmr-timing-DW1g3zjl.js} +17 -15
  22. package/dist/{hmr-timing-DwtYJdwb.mjs → hmr-timing-hRhRAjYV.mjs} +5 -3
  23. package/dist/index.js +4 -4
  24. package/dist/index.mjs +4 -4
  25. package/dist/object-BJSWl-E5.mjs +9 -0
  26. package/dist/object-COs_Mw6p.js +14 -0
  27. package/dist/postcss.js +1 -1
  28. package/dist/postcss.mjs +1 -1
  29. package/dist/presets.js +5 -5
  30. package/dist/presets.mjs +3 -3
  31. package/dist/rspack.js +1 -1
  32. package/dist/rspack.mjs +1 -1
  33. package/dist/{source-candidate-scan-signature-BrWuBTjY.js → source-candidate-scan-signature-CMgu5bJk.js} +6 -6
  34. package/dist/{source-candidate-scan-signature-CQ04hiox.mjs → source-candidate-scan-signature-t4XKAQ04.mjs} +3 -3
  35. package/dist/{tailwindcss-hzy_WaC9.mjs → tailwindcss-DZT_pWrd.mjs} +132 -2
  36. package/dist/{tailwindcss-Dn5DVlkI.js → tailwindcss-z9JMF-qU.js} +140 -10
  37. package/dist/{transform-DZQETx51.js → transform-COFRlmDF.js} +13 -13
  38. package/dist/{transform-BgnNYkIG.mjs → transform-D5JUgMpE.mjs} +1 -1
  39. package/dist/{utils-D3h8j7Mk.js → utils-CuKLf1Zv.js} +0 -15
  40. package/dist/{utils-DodxWHGz.mjs → utils-MVwpU07P.mjs} +1 -8
  41. package/dist/{vite-DODC15Fr.js → vite-DnkObu2L.js} +60 -45
  42. package/dist/{vite-oI2ReOic.mjs → vite-Tpgi77vE.mjs} +45 -30
  43. package/dist/vite.js +1 -1
  44. package/dist/vite.mjs +1 -1
  45. package/dist/weapp-tw-css-import-rewrite-loader.js +6 -2
  46. package/dist/{webpack-CCapGlNg.mjs → webpack-CTYm19zA.mjs} +22 -16
  47. package/dist/{webpack-XxBCIrBp.js → webpack-CzXjfvYS.js} +28 -22
  48. package/dist/webpack.js +1 -1
  49. package/dist/webpack.mjs +1 -1
  50. package/dist/{context-y2BGCok4.js → wxml-Ce10eREX.js} +37 -1286
  51. package/dist/{context-DzkSFEVL.mjs → wxml-DdGdeqaH.mjs} +13 -1235
  52. package/package.json +2 -2
  53. package/dist/defaults-9B6aMyZb.mjs +0 -118
  54. package/dist/defaults-nsf4VNMX.js +0 -154
@@ -1,20 +1,8 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
2
- const require_framework = require("./framework.js");
3
- const require_generator = require("./generator-Bz94KTkH.js");
4
- require("./utils-D3h8j7Mk.js");
5
- const require_defaults = require("./defaults-nsf4VNMX.js");
6
- const require_tailwindcss = require("./tailwindcss-Dn5DVlkI.js");
7
- let node_path = require("node:path");
8
- node_path = require_rolldown_runtime.__toESM(node_path);
9
- let node_process = require("node:process");
10
- node_process = require_rolldown_runtime.__toESM(node_process);
2
+ const require_object = require("./object-COs_Mw6p.js");
3
+ const require_cache_options = require("./cache-options-DavPxrhC.js");
11
4
  let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
12
- let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
13
5
  let lru_cache = require("lru-cache");
14
- let node_module = require("node:module");
15
- let node_fs_promises = require("node:fs/promises");
16
- let node_buffer = require("node:buffer");
17
- let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
18
6
  let _weapp_tailwindcss_shared_node = require("@weapp-tailwindcss/shared/node");
19
7
  let _weapp_core_escape = require("@weapp-core/escape");
20
8
  let debug = require("debug");
@@ -26,616 +14,20 @@ let magic_string = require("magic-string");
26
14
  magic_string = require_rolldown_runtime.__toESM(magic_string);
27
15
  let _babel_types = require("@babel/types");
28
16
  _babel_types = require_rolldown_runtime.__toESM(_babel_types);
29
- let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
30
- //#region src/cache/index.ts
31
- function isProcessResult(value) {
32
- return typeof value === "object" && value !== null && "result" in value;
33
- }
34
- function createCache(options) {
35
- const disabled = options === false;
36
- const hashMap = /* @__PURE__ */ new Map();
37
- const instance = new lru_cache.LRUCache({
38
- max: 1024,
39
- ttl: 0,
40
- ttlAutopurge: false
41
- });
42
- const cache = {
43
- hashMap,
44
- instance,
45
- hasHashKey(key) {
46
- return hashMap.has(key);
47
- },
48
- getHashValue(key) {
49
- return hashMap.get(key);
50
- },
51
- setHashValue(key, value) {
52
- return hashMap.set(key, value);
53
- },
54
- get(key) {
55
- return instance.get(key);
56
- },
57
- set(key, value) {
58
- return instance.set(key, value);
59
- },
60
- computeHash(message) {
61
- return (0, _weapp_tailwindcss_shared_node.md5)(message);
62
- },
63
- calcHashValueChanged(key, hash) {
64
- const hit = hashMap.get(key);
65
- if (hit) hashMap.set(key, {
66
- changed: hash !== hit.hash,
67
- hash
68
- });
69
- else hashMap.set(key, {
70
- changed: true,
71
- hash
72
- });
73
- return cache;
74
- },
75
- pruneHashKeys(hashKeys) {
76
- const activeHashKeys = new Set(hashKeys);
77
- for (const key of hashMap.keys()) if (!activeHashKeys.has(key)) hashMap.delete(key);
78
- },
79
- prune(options) {
80
- if (options.cacheKeys) {
81
- const cacheKeys = new Set(options.cacheKeys);
82
- for (const key of instance.keys()) if (!cacheKeys.has(key)) instance.delete(key);
83
- }
84
- if (options.hashKeys) cache.pruneHashKeys?.(options.hashKeys);
85
- },
86
- has(key) {
87
- return instance.has(key);
88
- },
89
- async process({ key, hashKey, rawSource, hash, resolveCache, transform, onCacheHit }) {
90
- if (disabled) {
91
- const value = await transform();
92
- return isProcessResult(value) ? value.result : value;
93
- }
94
- const cacheHashKey = hashKey ?? key;
95
- let hasChanged = true;
96
- if (hash != null || rawSource != null) {
97
- const nextHash = hash ?? cache.computeHash(rawSource);
98
- cache.calcHashValueChanged(cacheHashKey, nextHash);
99
- hasChanged = cache.getHashValue(cacheHashKey)?.changed ?? true;
100
- }
101
- const readCache = resolveCache ?? (() => cache.get(key));
102
- if (!hasChanged) {
103
- const cached = readCache();
104
- if (cached !== void 0) {
105
- await onCacheHit?.(cached);
106
- return cached;
107
- }
108
- }
109
- const value = await transform();
110
- const normalized = isProcessResult(value) ? value : { result: value };
111
- const stored = normalized.cacheValue ?? normalized.result;
112
- cache.set(key, stored);
113
- return normalized.result;
114
- }
115
- };
116
- return cache;
117
- }
118
- function initializeCache(cacheConfig) {
119
- if (typeof cacheConfig === "boolean" || cacheConfig === void 0) return createCache(cacheConfig);
120
- return cacheConfig;
121
- }
122
- //#endregion
123
- //#region src/framework/platform.ts
124
- const MPX_TO_UNI_PLATFORM = {
125
- ali: "mp-alipay",
126
- dd: "mp-dingtalk",
127
- jd: "mp-jd",
128
- qq: "mp-qq",
129
- swan: "mp-baidu",
130
- tt: "mp-toutiao",
131
- wx: "mp-weixin"
132
- };
133
- function normalizeFrameworkStylePlatform(platform, appType) {
134
- const normalized = platform?.trim().toLowerCase();
135
- if (!normalized) return;
136
- if (appType === "mpx") return MPX_TO_UNI_PLATFORM[normalized] ?? normalized;
137
- return normalized;
138
- }
139
- //#endregion
140
17
  //#region src/debug/index.ts
141
18
  const _debug = (0, debug.default)("weapp-tw");
142
19
  function createDebug(prefix) {
143
- const debug$3 = ((formatter, ...args) => {
20
+ const debug$2 = ((formatter, ...args) => {
144
21
  return _debug((prefix ?? "") + formatter, ...args);
145
22
  });
146
- Object.defineProperty(debug$3, "enabled", {
23
+ Object.defineProperty(debug$2, "enabled", {
147
24
  enumerable: false,
148
25
  configurable: false,
149
26
  get() {
150
27
  return _debug.enabled;
151
28
  }
152
29
  });
153
- return debug$3;
154
- }
155
- //#endregion
156
- //#region src/tailwindcss/runtime.ts
157
- const debug$2 = createDebug("[tailwindcss:runtime] ");
158
- const refreshTailwindcssRuntimeSymbol = Symbol.for("weapp-tailwindcss.refreshTailwindcssRuntime");
159
- function createTailwindRuntimeReadyPromise(tailwindRuntime) {
160
- return Promise.resolve().then(async () => {
161
- require_tailwindcss.invalidateRuntimeClassSet(tailwindRuntime);
162
- });
163
- }
164
- const runtimeClassSetStateCache = /* @__PURE__ */ new WeakMap();
165
- function getRuntimeClassSetStateEntry(state) {
166
- let entry = runtimeClassSetStateCache.get(state);
167
- if (!entry) {
168
- entry = {};
169
- runtimeClassSetStateCache.set(state, entry);
170
- }
171
- return entry;
172
- }
173
- function getTailwindRuntime(state) {
174
- return state.tailwindRuntime;
175
- }
176
- function setTailwindRuntime(state, runtime) {
177
- state.tailwindRuntime = runtime;
178
- }
179
- function getRefreshTailwindRuntime(state) {
180
- return state.refreshTailwindcssRuntime;
181
- }
182
- async function refreshTailwindRuntimeState(state, forceOrOptions) {
183
- const normalizedOptions = typeof forceOrOptions === "boolean" ? { force: forceOrOptions } : forceOrOptions;
184
- const force = normalizedOptions.force;
185
- const clearCache = normalizedOptions.clearCache === true;
186
- if (!force) return false;
187
- debug$2("refresh runtime state start, clearCache=%s major=%s", clearCache, getTailwindRuntime(state).majorVersion ?? "unknown");
188
- await state.readyPromise;
189
- let refreshed = false;
190
- const refreshTailwindRuntime = getRefreshTailwindRuntime(state);
191
- if (typeof refreshTailwindRuntime === "function") {
192
- const next = await refreshTailwindRuntime({ clearCache });
193
- if (next !== getTailwindRuntime(state)) setTailwindRuntime(state, next);
194
- refreshed = true;
195
- }
196
- if (refreshed) state.readyPromise = createTailwindRuntimeReadyPromise(getTailwindRuntime(state));
197
- debug$2("refresh runtime state end, refreshed=%s major=%s", refreshed, getTailwindRuntime(state).majorVersion ?? "unknown");
198
- return refreshed;
199
- }
200
- async function ensureRuntimeClassSet(state, options = {}) {
201
- const forceRefresh = options.forceRefresh === true;
202
- const forceCollect = options.forceCollect === true;
203
- const clearCache = options.clearCache === true;
204
- const allowEmpty = options.allowEmpty === true;
205
- if (forceRefresh) await refreshTailwindRuntimeState(state, {
206
- force: true,
207
- clearCache
208
- });
209
- await state.readyPromise;
210
- const entry = getRuntimeClassSetStateEntry(state);
211
- const signature = await require_tailwindcss.getRuntimeClassSetSignatureWithSources(getTailwindRuntime(state));
212
- const signatureChanged = entry.signature !== signature;
213
- const shouldForceCollect = forceCollect || forceRefresh || signatureChanged;
214
- if (!shouldForceCollect) {
215
- if (entry.value && (allowEmpty || entry.value.size > 0)) return entry.value;
216
- if (entry.promise) return entry.promise;
217
- }
218
- const task = (async () => {
219
- const collected = await collectRuntimeClassSet(getTailwindRuntime(state), {
220
- force: shouldForceCollect,
221
- skipRefresh: true,
222
- clearCache
223
- });
224
- if (allowEmpty || collected.size > 0) return collected;
225
- await refreshTailwindRuntimeState(state, {
226
- force: true,
227
- clearCache: true
228
- });
229
- await state.readyPromise;
230
- return collectRuntimeClassSet(getTailwindRuntime(state), {
231
- force: true,
232
- skipRefresh: true,
233
- clearCache: true
234
- });
235
- })();
236
- entry.promise = task;
237
- try {
238
- const runtimeSet = await task;
239
- entry.value = runtimeSet;
240
- entry.signature = await require_tailwindcss.getRuntimeClassSetSignatureWithSources(getTailwindRuntime(state));
241
- return runtimeSet;
242
- } finally {
243
- if (entry.promise === task) entry.promise = void 0;
244
- }
245
- }
246
- function tryGetRuntimeClassSetSync(tailwindRuntime) {
247
- if (typeof tailwindRuntime.getClassSetSync !== "function") return;
248
- try {
249
- const set = tailwindRuntime.getClassSetSync();
250
- if (set && set.size === 0) return;
251
- return set;
252
- } catch (error) {
253
- debug$2("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
254
- return;
255
- }
256
- }
257
- async function collectTailwindV4GeneratorClassSet(tailwindRuntime) {
258
- if (typeof tailwindRuntime.collectContentTokens !== "function") return;
259
- try {
260
- const source = require_generator.resolveCssMacroTailwindV4Source(await require_generator.resolveTailwindV4SourceFromRuntime(tailwindRuntime));
261
- const generated = await require_generator.createTailwindV4Engine(source).generate({
262
- scanSources: true,
263
- target: "web"
264
- });
265
- const classSet = (0, _tailwindcss_mangle_engine.resolveValidTailwindV4Candidates)(await (0, _tailwindcss_mangle_engine.loadTailwindV4DesignSystem)(source), generated.classSet, { ...source.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: source.bareArbitraryValues } });
266
- debug$2("runtime class set resolved via tailwindcss v4 generator source scan, raw=%d valid=%d", generated.classSet.size, classSet.size);
267
- return classSet;
268
- } catch (error) {
269
- debug$2("tailwindcss v4 generator source scan failed, continuing fallback chain: %O", error);
270
- return;
271
- }
272
- }
273
- async function mergeTailwindV4GeneratorClassSet(tailwindRuntime, classSet) {
274
- const generatorClassSet = await collectTailwindV4GeneratorClassSet(tailwindRuntime).catch(() => void 0);
275
- if (!generatorClassSet || generatorClassSet.size === 0) return classSet;
276
- return /* @__PURE__ */ new Set([...classSet, ...generatorClassSet]);
277
- }
278
- async function collectRuntimeClassSet(tailwindRuntime, options = {}) {
279
- let activeRuntime = tailwindRuntime;
280
- if (options.force && !options.skipRefresh) {
281
- const refresh = activeRuntime[refreshTailwindcssRuntimeSymbol];
282
- if (typeof refresh === "function") try {
283
- const refreshed = await refresh({ clearCache: options.clearCache === true });
284
- if (refreshed) activeRuntime = refreshed;
285
- } catch (error) {
286
- debug$2("refreshTailwindcssRuntime failed, continuing with existing runtime: %O", error);
287
- }
288
- }
289
- const entry = require_tailwindcss.getRuntimeClassSetCacheEntry(activeRuntime);
290
- const signature = await require_tailwindcss.getRuntimeClassSetSignatureWithSources(activeRuntime);
291
- if (!options.force) {
292
- if (entry.value && entry.signature === signature) return entry.value;
293
- if (entry.promise) return entry.promise;
294
- } else entry.value = void 0;
295
- const task = (async () => {
296
- const preferExtract = options.force === true;
297
- try {
298
- const result = await activeRuntime.extract({ write: false });
299
- if (result?.classSet) {
300
- if (result.classSet.size > 0) {
301
- const merged = await mergeTailwindV4GeneratorClassSet(activeRuntime, result.classSet);
302
- debug$2("runtime class set resolved via extract() + tailwindcss v4 source scan, extract=%d merged=%d", result.classSet.size, merged.size);
303
- return merged;
304
- }
305
- if (preferExtract) debug$2("runtime class set from extract() is empty on force collect, fallback to generator/sync/async class set");
306
- else debug$2("runtime class set from extract() is empty, fallback to sync/async class set");
307
- }
308
- } catch (error) {
309
- debug$2("extract() failed, fallback to getClassSet(): %O", error);
310
- }
311
- const generatorClassSet = await collectTailwindV4GeneratorClassSet(activeRuntime);
312
- if (generatorClassSet && generatorClassSet.size > 0) return generatorClassSet;
313
- const syncSet = tryGetRuntimeClassSetSync(activeRuntime);
314
- if (syncSet) {
315
- debug$2("runtime class set resolved via getClassSetSync(), size=%d", syncSet.size);
316
- return syncSet;
317
- }
318
- try {
319
- const fallbackSet = await Promise.resolve(activeRuntime.getClassSet());
320
- if (fallbackSet) {
321
- debug$2("runtime class set resolved via getClassSet(), size=%d", fallbackSet.size);
322
- return fallbackSet;
323
- }
324
- } catch (error) {
325
- debug$2("getClassSet() failed, returning empty set: %O", error);
326
- }
327
- return /* @__PURE__ */ new Set();
328
- })();
329
- entry.promise = task;
330
- entry.signature = signature;
331
- try {
332
- const resolved = await task;
333
- entry.value = resolved;
334
- entry.promise = void 0;
335
- entry.signature = signature;
336
- return resolved;
337
- } catch (error) {
338
- entry.promise = void 0;
339
- throw error;
340
- }
341
- }
342
- //#endregion
343
- //#region src/tailwindcss/runtime-logs.ts
344
- const runtimeLogDedupeHolder = globalThis;
345
- const runtimeLogDedupe = runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ ?? (runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ = /* @__PURE__ */ new Set());
346
- function createRuntimeLogKey(category, baseDir, rootPath, version) {
347
- return JSON.stringify([
348
- category,
349
- baseDir ?? node_process.default.cwd(),
350
- rootPath ?? "",
351
- version ?? ""
352
- ]);
353
- }
354
- function markRuntimeLog(category, baseDir, rootPath, version) {
355
- const key = createRuntimeLogKey(category, baseDir, rootPath, version);
356
- if (runtimeLogDedupe.has(key)) return false;
357
- runtimeLogDedupe.add(key);
358
- return true;
359
- }
360
- function logRuntimeTailwindcssTarget(baseDir, rootPath, version) {
361
- if (!markRuntimeLog("target", baseDir, rootPath, version)) return;
362
- const versionText = version ? ` (v${version})` : "";
363
- _weapp_tailwindcss_logger.logger.info("%s 使用 Tailwind CSS%s", "Weapp-tailwindcss", versionText);
364
- }
365
- function logRuntimeTailwindcssVersion(baseDir, rootPath, version) {
366
- if (version) {
367
- if (!markRuntimeLog("version", baseDir, rootPath, version)) return;
368
- _weapp_tailwindcss_logger.logger.success(`当前使用 ${_weapp_tailwindcss_logger.pc.cyanBright("Tailwind CSS")} 版本为: ${_weapp_tailwindcss_logger.pc.underline(_weapp_tailwindcss_logger.pc.bold(_weapp_tailwindcss_logger.pc.green(version)))}`);
369
- return;
370
- }
371
- if (!markRuntimeLog("missing", baseDir, rootPath, version)) return;
372
- _weapp_tailwindcss_logger.logger.warn(`${_weapp_tailwindcss_logger.pc.cyanBright("Tailwind CSS")} 未安装,已跳过版本检测与运行时初始化。`);
373
- }
374
- //#endregion
375
- //#region src/tailwindcss/targets.ts
376
- function formatRelativeToBase(targetPath, baseDir) {
377
- const normalized = node_path.default.normalize(targetPath);
378
- if (!baseDir) return normalized.replace(/\\/g, "/");
379
- const relative = node_path.default.relative(baseDir, normalized);
380
- if (!relative || relative === ".") return ".";
381
- if (relative.startsWith("..")) return normalized.replace(/\\/g, "/");
382
- return node_path.default.join(".", relative).replace(/\\/g, "/");
383
- }
384
- function logTailwindcssTarget(tailwindRuntime, baseDir) {
385
- const packageInfo = tailwindRuntime?.packageInfo;
386
- const label = "Weapp-tailwindcss";
387
- if (!packageInfo?.rootPath) {
388
- _weapp_tailwindcss_logger.logger.warn("%s 未找到 Tailwind CSS 依赖,请检查在 %s 是否已安装 tailwindcss", label, baseDir ?? node_process.default.cwd());
389
- return;
390
- }
391
- const displayPath = formatRelativeToBase(packageInfo.rootPath, baseDir);
392
- const version = packageInfo.version ? ` (v${packageInfo.version})` : "";
393
- logRuntimeTailwindcssTarget(baseDir, packageInfo.rootPath, packageInfo.version);
394
- _weapp_tailwindcss_logger.logger.debug("%s 解析 Tailwind CSS -> %s%s", label, displayPath, version);
395
- }
396
- //#endregion
397
- //#region src/unocss/index.ts
398
- function normalizeUnocssOptions(unocss) {
399
- return require_generator.resolveBooleanObjectOption(unocss, {});
400
- }
401
- function resolveUnocssBareArbitraryValues(arbitraryValues, unocss) {
402
- const baseArbitraryValues = arbitraryValues ?? {};
403
- const options = normalizeUnocssOptions(unocss);
404
- if (!options) return baseArbitraryValues;
405
- if (baseArbitraryValues.bareArbitraryValues !== void 0 && baseArbitraryValues.bareArbitraryValues !== false) return baseArbitraryValues;
406
- const bareArbitraryValues = options.bareArbitraryValues ?? true;
407
- if (bareArbitraryValues === false) return baseArbitraryValues;
408
- return {
409
- ...baseArbitraryValues,
410
- bareArbitraryValues
411
- };
412
- }
413
- //#endregion
414
- //#region src/context/compiler-context-cache.ts
415
- const PAREN_CONTENT_RE = /\(([^)]+)\)/u;
416
- const AT_LOCATION_RE = /at\s+(\S.*)$/u;
417
- const TRAILING_LINE_COL_RE = /:\d+(?::\d+)?$/u;
418
- const DEFAULT_COMPILER_CONTEXT_CACHE_MAX = 32;
419
- const DEFAULT_COMPILER_CONTEXT_KEY_CACHE_MAX = DEFAULT_COMPILER_CONTEXT_CACHE_MAX * 2;
420
- const globalCacheHolder = globalThis;
421
- const compilerContextCache = globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ ?? (globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ = /* @__PURE__ */ new Map());
422
- const compilerContextKeyCacheByOptions = /* @__PURE__ */ new WeakMap();
423
- const compilerContextKeyCacheWithoutOptions = /* @__PURE__ */ new Map();
424
- function resolveCompilerContextCacheMax(defaultValue) {
425
- const raw = Number.parseInt(node_process.default.env["WEAPP_TW_COMPILER_CONTEXT_CACHE_MAX"] ?? "", 10);
426
- if (!Number.isFinite(raw) || raw <= 0) return defaultValue;
427
- return Math.floor(raw);
428
- }
429
- function touchMapValue(map, key, value) {
430
- map.delete(key);
431
- map.set(key, value);
432
- }
433
- function pruneMapToMaxSize(map, maxSize) {
434
- while (map.size > maxSize) {
435
- const firstKey = map.keys().next().value;
436
- if (firstKey === void 0) break;
437
- map.delete(firstKey);
438
- }
439
- }
440
- function withCircularGuard(value, stack, factory) {
441
- if (stack.has(value)) throw new TypeError("Cannot serialize circular structure in compiler context options");
442
- stack.add(value);
443
- try {
444
- return factory();
445
- } finally {
446
- stack.delete(value);
447
- }
448
- }
449
- function encodeTaggedValue(type, value) {
450
- const record = { __type: type };
451
- if (value !== void 0) record["value"] = value;
452
- return record;
453
- }
454
- function hasExplicitOptionBasedir(opts) {
455
- return typeof opts?.tailwindcssBasedir === "string" && opts.tailwindcssBasedir.length > 0;
456
- }
457
- function shouldProbeCallerLocation(opts) {
458
- if (hasExplicitOptionBasedir(opts)) return false;
459
- return !(node_process.default.env["WEAPP_TAILWINDCSS_BASEDIR"] || node_process.default.env["WEAPP_TAILWINDCSS_BASE_DIR"] || node_process.default.env["TAILWINDCSS_BASEDIR"] || node_process.default.env["TAILWINDCSS_BASE_DIR"]);
460
- }
461
- function detectCallerLocation() {
462
- const stack = (/* @__PURE__ */ new Error("compiler-context-cache stack probe")).stack;
463
- if (!stack) return;
464
- const lines = stack.split("\n");
465
- for (const line of lines) {
466
- const location = (line.match(PAREN_CONTENT_RE) ?? line.match(AT_LOCATION_RE))?.[1];
467
- if (!location) continue;
468
- const candidatePath = location.replace(TRAILING_LINE_COL_RE, "");
469
- if (!candidatePath || !node_path.default.isAbsolute(candidatePath)) continue;
470
- if (candidatePath.includes(`${node_path.default.sep}weapp-tailwindcss${node_path.default.sep}src${node_path.default.sep}`) || candidatePath.includes(`${node_path.default.sep}weapp-tailwindcss${node_path.default.sep}dist${node_path.default.sep}`) || candidatePath.includes(`${node_path.default.sep}node_modules${node_path.default.sep}weapp-tailwindcss${node_path.default.sep}`)) continue;
471
- return candidatePath;
472
- }
473
- }
474
- function getRuntimeCacheScope(opts) {
475
- if (hasExplicitOptionBasedir(opts)) return { caller: void 0 };
476
- const runtimeScope = {
477
- caller: void 0,
478
- cwd: node_process.default.cwd(),
479
- init_cwd: node_process.default.env["INIT_CWD"],
480
- npm_config_local_prefix: node_process.default.env["npm_config_local_prefix"],
481
- npm_package_json: node_process.default.env["npm_package_json"],
482
- pnpm_package_name: node_process.default.env["PNPM_PACKAGE_NAME"],
483
- pwd: node_process.default.env["PWD"],
484
- tailwindcss_base_dir: node_process.default.env["TAILWINDCSS_BASE_DIR"],
485
- tailwindcss_basedir: node_process.default.env["TAILWINDCSS_BASEDIR"],
486
- uni_app_input_dir: node_process.default.env["UNI_APP_INPUT_DIR"],
487
- uni_cli_root: node_process.default.env["UNI_CLI_ROOT"],
488
- uni_input_dir: node_process.default.env["UNI_INPUT_DIR"],
489
- uni_input_root: node_process.default.env["UNI_INPUT_ROOT"],
490
- weapp_tailwindcss_base_dir: node_process.default.env["WEAPP_TAILWINDCSS_BASE_DIR"],
491
- weapp_tailwindcss_basedir: node_process.default.env["WEAPP_TAILWINDCSS_BASEDIR"]
492
- };
493
- if (shouldProbeCallerLocation(opts)) runtimeScope.caller = detectCallerLocation();
494
- return runtimeScope;
495
- }
496
- function serializeNormalizedValue(value) {
497
- return JSON.stringify(value);
498
- }
499
- function createRuntimeCacheScopeKey(opts) {
500
- return serializeNormalizedValue(normalizeOptionsValue(getRuntimeCacheScope(opts)));
501
- }
502
- function getCompilerContextKeyCacheStore(opts) {
503
- if (!opts) return compilerContextKeyCacheWithoutOptions;
504
- let store = compilerContextKeyCacheByOptions.get(opts);
505
- if (!store) {
506
- store = /* @__PURE__ */ new Map();
507
- compilerContextKeyCacheByOptions.set(opts, store);
508
- }
509
- return store;
510
- }
511
- function createComparableNormalizedValue(rawValue, stack) {
512
- const normalized = normalizeOptionsValue(rawValue, stack);
513
- return {
514
- normalized,
515
- sortKey: serializeNormalizedValue(normalized)
516
- };
517
- }
518
- function getRuntimeCacheScopeValue(opts) {
519
- return {
520
- options: opts ?? {},
521
- runtime: getRuntimeCacheScope(opts)
522
- };
523
- }
524
- function normalizeOptionsValue(rawValue, stack = /* @__PURE__ */ new WeakSet()) {
525
- if (rawValue === null) return null;
526
- if (rawValue === void 0) return encodeTaggedValue("Undefined");
527
- const type = typeof rawValue;
528
- if (type === "string") return rawValue;
529
- if (type === "boolean") return rawValue;
530
- if (type === "number") {
531
- const numericValue = rawValue;
532
- if (Number.isNaN(numericValue)) return encodeTaggedValue("Number", "NaN");
533
- if (!Number.isFinite(numericValue)) return encodeTaggedValue("Number", numericValue > 0 ? "Infinity" : "-Infinity");
534
- if (Object.is(numericValue, -0)) return encodeTaggedValue("Number", "-0");
535
- return numericValue;
536
- }
537
- if (type === "bigint") return encodeTaggedValue("BigInt", rawValue.toString());
538
- if (type === "symbol") {
539
- const symbolValue = rawValue;
540
- return encodeTaggedValue("Symbol", symbolValue.description ?? String(symbolValue));
541
- }
542
- if (type === "function") return encodeTaggedValue("Function", rawValue.toString());
543
- if (Array.isArray(rawValue)) return withCircularGuard(rawValue, stack, () => rawValue.map((item) => normalizeOptionsValue(item, stack)));
544
- if (rawValue instanceof Date) return encodeTaggedValue("Date", rawValue.toISOString());
545
- if (rawValue instanceof RegExp) return {
546
- __type: "RegExp",
547
- source: rawValue.source,
548
- flags: rawValue.flags
549
- };
550
- if (typeof node_buffer.Buffer !== "undefined" && node_buffer.Buffer.isBuffer(rawValue)) return encodeTaggedValue("Buffer", rawValue.toString("base64"));
551
- if (ArrayBuffer.isView(rawValue)) {
552
- const view = rawValue;
553
- const buffer = node_buffer.Buffer.from(view.buffer, view.byteOffset, view.byteLength);
554
- return encodeTaggedValue(view.constructor?.name ?? "ArrayBufferView", buffer.toString("base64"));
555
- }
556
- if (rawValue instanceof ArrayBuffer) return encodeTaggedValue("ArrayBuffer", node_buffer.Buffer.from(rawValue).toString("base64"));
557
- if (rawValue instanceof Set) return withCircularGuard(rawValue, stack, () => {
558
- const normalizedEntries = Array.from(rawValue, (element) => createComparableNormalizedValue(element, stack));
559
- normalizedEntries.sort((a, b) => a.sortKey.localeCompare(b.sortKey));
560
- return {
561
- __type: "Set",
562
- value: normalizedEntries.map((entry) => entry.normalized)
563
- };
564
- });
565
- if (rawValue instanceof Map) return withCircularGuard(rawValue, stack, () => {
566
- const normalizedEntries = Array.from(rawValue.entries(), ([key, entryValue]) => {
567
- const normalizedKey = createComparableNormalizedValue(key, stack);
568
- return {
569
- key: normalizedKey.normalized,
570
- sortKey: normalizedKey.sortKey,
571
- value: normalizeOptionsValue(entryValue, stack)
572
- };
573
- });
574
- normalizedEntries.sort((a, b) => a.sortKey.localeCompare(b.sortKey));
575
- return {
576
- __type: "Map",
577
- value: normalizedEntries.map((entry) => [entry.key, entry.value])
578
- };
579
- });
580
- if (typeof URL !== "undefined" && rawValue instanceof URL) return encodeTaggedValue("URL", rawValue.toString());
581
- if (rawValue instanceof Error) {
582
- const errorValue = rawValue;
583
- return {
584
- __type: "Error",
585
- name: errorValue.name,
586
- message: errorValue.message,
587
- stack: errorValue.stack ?? ""
588
- };
589
- }
590
- if (rawValue instanceof Promise) return encodeTaggedValue("Promise");
591
- if (rawValue instanceof WeakMap) return encodeTaggedValue("WeakMap");
592
- if (rawValue instanceof WeakSet) return encodeTaggedValue("WeakSet");
593
- if (rawValue && typeof rawValue === "object") return withCircularGuard(rawValue, stack, () => {
594
- const result = {};
595
- const entries = Object.entries(rawValue);
596
- entries.sort(([a], [b]) => a.localeCompare(b));
597
- for (const [key, entryValue] of entries) result[key] = normalizeOptionsValue(entryValue, stack);
598
- return result;
599
- });
600
- return encodeTaggedValue(typeof rawValue, String(rawValue));
601
- }
602
- function createCompilerContextCacheKey(opts) {
603
- try {
604
- const runtimeCacheScopeKey = createRuntimeCacheScopeKey(opts);
605
- const keyStore = getCompilerContextKeyCacheStore(opts);
606
- const cached = keyStore.get(runtimeCacheScopeKey);
607
- if (cached !== void 0) return cached;
608
- const cacheKey = (0, _weapp_tailwindcss_shared_node.md5)(serializeNormalizedValue(normalizeOptionsValue(getRuntimeCacheScopeValue(opts))));
609
- touchMapValue(keyStore, runtimeCacheScopeKey, cacheKey);
610
- pruneMapToMaxSize(keyStore, resolveCompilerContextCacheMax(DEFAULT_COMPILER_CONTEXT_KEY_CACHE_MAX));
611
- return cacheKey;
612
- } catch (error) {
613
- _weapp_tailwindcss_logger.logger.debug("skip compiler context cache: %O", error);
614
- return;
615
- }
616
- }
617
- function withCompilerContextCache(opts, factory) {
618
- const cacheKey = createCompilerContextCacheKey(opts);
619
- if (cacheKey) {
620
- const cached = compilerContextCache.get(cacheKey);
621
- if (cached) {
622
- touchMapValue(compilerContextCache, cacheKey, cached);
623
- return cached;
624
- }
625
- }
626
- const ctx = factory();
627
- if (cacheKey) {
628
- touchMapValue(compilerContextCache, cacheKey, ctx);
629
- pruneMapToMaxSize(compilerContextCache, resolveCompilerContextCacheMax(DEFAULT_COMPILER_CONTEXT_CACHE_MAX));
630
- }
631
- return ctx;
632
- }
633
- //#endregion
634
- //#region src/context/custom-attributes.ts
635
- function toCustomAttributesEntities(customAttributes) {
636
- if (!customAttributes) return [];
637
- if ((0, _weapp_tailwindcss_shared.isMap)(customAttributes)) return [...customAttributes.entries()];
638
- return Object.entries(customAttributes);
30
+ return debug$2;
639
31
  }
640
32
  //#endregion
641
33
  //#region src/babel/index.ts
@@ -711,17 +103,17 @@ function createNameMatcher(list, { exact = false } = {}) {
711
103
  }
712
104
  //#endregion
713
105
  //#region src/js/babel/parse.ts
714
- const parseCache = new lru_cache.LRUCache({ max: require_defaults.HARD_PARSE_CACHE_MAX_ENTRIES });
106
+ const parseCache = new lru_cache.LRUCache({ max: require_cache_options.HARD_PARSE_CACHE_MAX_ENTRIES });
715
107
  function genCacheKey(source, options) {
716
108
  if (typeof options === "string") return `${(0, _weapp_tailwindcss_shared_node.md5)(source)}:${options}`;
717
109
  return `${(0, _weapp_tailwindcss_shared_node.md5)(source)}:${JSON.stringify(options, (_, val) => typeof val === "function" ? val.toString() : val)}`;
718
110
  }
719
111
  function normalizeCacheMaxEntries(value) {
720
112
  if (typeof value !== "number" || !Number.isFinite(value)) return 128;
721
- return Math.min(Math.max(Math.floor(value), 0), require_defaults.HARD_PARSE_CACHE_MAX_ENTRIES);
113
+ return Math.min(Math.max(Math.floor(value), 0), require_cache_options.HARD_PARSE_CACHE_MAX_ENTRIES);
722
114
  }
723
115
  function normalizeCacheMaxSourceLength(value) {
724
- if (typeof value !== "number" || !Number.isFinite(value)) return require_defaults.DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH;
116
+ if (typeof value !== "number" || !Number.isFinite(value)) return require_cache_options.DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH;
725
117
  return Math.max(Math.floor(value), 0);
726
118
  }
727
119
  function trimParseCache(maxEntries) {
@@ -758,7 +150,7 @@ function replaceWxml(original, options = {
758
150
  const { keepEOL, escapeMap, ignoreHead } = options;
759
151
  let res = original;
760
152
  if (!keepEOL) res = res.replaceAll(NEWLINE_RE, "");
761
- res = (0, _weapp_core_escape.escape)(res, require_generator.omitUndefined({
153
+ res = (0, _weapp_core_escape.escape)(res, require_object.omitUndefined({
762
154
  map: escapeMap,
763
155
  ignoreHead
764
156
  }));
@@ -1337,7 +729,7 @@ function walkEvalExpression(path, options, updater, handler) {
1337
729
  }
1338
730
  }
1339
731
  //#endregion
1340
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
732
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
1341
733
  function _typeof(o) {
1342
734
  "@babel/helpers - typeof";
1343
735
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -1347,7 +739,7 @@ function _typeof(o) {
1347
739
  }, _typeof(o);
1348
740
  }
1349
741
  //#endregion
1350
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
742
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
1351
743
  function toPrimitive(t, r) {
1352
744
  if ("object" != _typeof(t) || !t) return t;
1353
745
  var e = t[Symbol.toPrimitive];
@@ -1359,13 +751,13 @@ function toPrimitive(t, r) {
1359
751
  return ("string" === r ? String : Number)(t);
1360
752
  }
1361
753
  //#endregion
1362
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
754
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
1363
755
  function toPropertyKey(t) {
1364
756
  var i = toPrimitive(t, "string");
1365
757
  return "symbol" == _typeof(i) ? i : i + "";
1366
758
  }
1367
759
  //#endregion
1368
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
760
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
1369
761
  function _defineProperty(e, r, t) {
1370
762
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1371
763
  value: t,
@@ -1860,7 +1252,8 @@ function createTaggedTemplateIgnore({ matcher, names }) {
1860
1252
  return false;
1861
1253
  };
1862
1254
  const resolvesMemberExpressionToIgnore = (path, seen) => {
1863
- if (propertyMatches(path.get("property"))) return true;
1255
+ const propertyPath = path.get("property");
1256
+ if (propertyMatches(propertyPath)) return true;
1864
1257
  const objectPath = path.get("object");
1865
1258
  if (objectPath.isIdentifier()) {
1866
1259
  const binding = (objectPath?.scope)?.getBinding?.(objectPath.node.name);
@@ -1927,7 +1320,10 @@ function createTaggedTemplateIgnore({ matcher, names }) {
1927
1320
  return current;
1928
1321
  };
1929
1322
  const evaluateTagPath = (tagPath, seen) => {
1930
- if (tagPath.isCallExpression?.() || tagPath.node.type === "CallExpression") return evaluateTagPath(tagPath.get("callee"), seen);
1323
+ if (tagPath.isCallExpression?.() || tagPath.node.type === "CallExpression") {
1324
+ const calleePath = tagPath.get("callee");
1325
+ return evaluateTagPath(calleePath, seen);
1326
+ }
1931
1327
  if (tagPath.isIdentifier()) {
1932
1328
  if (matchesIgnoreName(tagPath.node.name)) return true;
1933
1329
  const binding = tagPath?.scope?.getBinding?.(tagPath.node.name);
@@ -2109,351 +1505,6 @@ function jsHandler(rawSource, options) {
2109
1505
  }
2110
1506
  defaultEvalHandler = jsHandler;
2111
1507
  //#endregion
2112
- //#region src/js/literal-transform.ts
2113
- function transformLiteralText(literal, options) {
2114
- const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
2115
- if (!options.alwaysEscape && !fallbackEnabled && (!options.classNameSet || options.classNameSet.size === 0)) return;
2116
- const source = options.unescapeUnicode && literal.includes("\\u") ? decodeUnicode2(literal) : literal;
2117
- const candidates = (0, _tailwindcss_mangle_engine.splitCandidateTokens)(source);
2118
- if (candidates.length === 0) return;
2119
- const transformOptions = {
2120
- ...options,
2121
- classContext: true
2122
- };
2123
- const replacementCache = getReplacementCacheStore(options.escapeMap);
2124
- let transformed = source;
2125
- let mutated = false;
2126
- for (const candidate of candidates) {
2127
- const result = resolveClassNameTransformWithResult(candidate, transformOptions);
2128
- if (result.decision === "skip" || !transformed.includes(candidate)) continue;
2129
- const replacement = result.decision === "escaped" && result.escapedValue ? result.escapedValue : getReplacement(candidate, options.escapeMap, replacementCache);
2130
- const replaced = transformed.replace(candidate, replacement);
2131
- if (replaced !== transformed) {
2132
- transformed = replaced;
2133
- mutated = true;
2134
- }
2135
- }
2136
- return mutated ? transformed : void 0;
2137
- }
2138
- //#endregion
2139
- //#region src/js/fast-path/oxc.ts
2140
- const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
2141
- let oxcParser;
2142
- let oxcWalker;
2143
- function isOxcParserRuntimeSupported(version = node_process.default.versions.node) {
2144
- const match = /^(\d+)\.(\d+)(?:\.|$)/.exec(version);
2145
- if (!match) return false;
2146
- const major = Number(match[1]);
2147
- const minor = Number(match[2]);
2148
- if (major === 20) return minor >= 19;
2149
- if (major === 21) return false;
2150
- if (major === 22) return minor >= 12;
2151
- return major > 22;
2152
- }
2153
- function loadOxcParser() {
2154
- if (!isOxcParserRuntimeSupported()) return;
2155
- if (oxcParser === false) return;
2156
- if (oxcParser) return oxcParser;
2157
- try {
2158
- oxcParser = require$1("oxc-parser");
2159
- } catch {
2160
- oxcParser = false;
2161
- return;
2162
- }
2163
- return oxcParser;
2164
- }
2165
- function loadOxcWalker() {
2166
- if (!isOxcParserRuntimeSupported()) return;
2167
- if (oxcWalker === false) return;
2168
- if (oxcWalker) return oxcWalker;
2169
- try {
2170
- oxcWalker = require$1("oxc-walker");
2171
- } catch {
2172
- oxcWalker = false;
2173
- return;
2174
- }
2175
- return oxcWalker;
2176
- }
2177
- function hasValues(values) {
2178
- return Array.isArray(values) && values.length > 0;
2179
- }
2180
- function hasUnsupportedSourceMarker(rawSource) {
2181
- return rawSource.includes("eval(") || rawSource.includes("weapp-tw") && rawSource.includes("ignore");
2182
- }
2183
- function hasSupportedClassMatchSource(options) {
2184
- return options.alwaysEscape === true || Boolean(options.classNameSet && options.classNameSet.size > 0);
2185
- }
2186
- function canUseOxcJsFastPath(options) {
2187
- if (options.experimentalJsFastPath !== true && options.experimentalJsFastPath !== "oxc") return false;
2188
- return !options.generateMap && !options.wrapExpression && !options.moduleGraph && !options.moduleSpecifierReplacements && hasSupportedClassMatchSource(options) && !shouldEnableArbitraryValueFallback(options) && !hasValues(options.ignoreCallExpressionIdentifiers) && !hasValues(options.ignoreTaggedTemplateExpressionIdentifiers);
2189
- }
2190
- function getParserLang(filename) {
2191
- if (filename?.endsWith(".ts") || filename?.endsWith(".mts") || filename?.endsWith(".cts")) return "ts";
2192
- if (filename?.endsWith(".tsx")) return "tsx";
2193
- if (filename?.endsWith(".jsx")) return "jsx";
2194
- return "js";
2195
- }
2196
- function getParserSourceType(sourceType) {
2197
- return sourceType === "script" || sourceType === "module" ? sourceType : "module";
2198
- }
2199
- function isRangeValid(start, end) {
2200
- return typeof start === "number" && typeof end === "number" && start < end;
2201
- }
2202
- function getMagicString(rawSource, context) {
2203
- if (!context.ms) context.ms = new magic_string.default(rawSource);
2204
- return context.ms;
2205
- }
2206
- function addStringLiteralReplacement(rawSource, node, transformOptions, context) {
2207
- if (typeof node.value !== "string" || typeof node.raw !== "string" || !isRangeValid(node.start, node.end)) return false;
2208
- const transformed = transformLiteralText(node.value, transformOptions);
2209
- if (!transformed) return false;
2210
- const start = node.start + 1;
2211
- const end = node.end - 1;
2212
- if (start >= end || transformed === rawSource.slice(start, end)) return false;
2213
- getMagicString(rawSource, context).update(start, end, jsStringEscape(transformed));
2214
- return true;
2215
- }
2216
- function addTemplateElementReplacement(rawSource, node, transformOptions, context) {
2217
- const raw = node.value?.raw;
2218
- if (typeof raw !== "string" || !isRangeValid(node.start, node.end)) return false;
2219
- const transformed = transformLiteralText(raw, transformOptions);
2220
- if (!transformed || transformed === raw) return false;
2221
- const first = rawSource[node.start];
2222
- const last = rawSource[node.end - 1];
2223
- const start = node.start + (first === "`" || first === "}" ? 1 : 0);
2224
- const end = node.end - (last === "`" ? 1 : last === "{" ? 2 : 0);
2225
- if (start >= end) return false;
2226
- getMagicString(rawSource, context).update(start, end, transformed);
2227
- return true;
2228
- }
2229
- function applyReplacements(rawSource, program, walker, stringLiteralOptions, templateLiteralOptions, context) {
2230
- let changed = false;
2231
- walker.walk(program, { enter(node) {
2232
- if (node.type === "Literal") {
2233
- changed = addStringLiteralReplacement(rawSource, node, stringLiteralOptions, context) || changed;
2234
- return;
2235
- }
2236
- if (node.type === "TemplateElement") {
2237
- changed = addTemplateElementReplacement(rawSource, node, templateLiteralOptions, context) || changed;
2238
- this.skip();
2239
- }
2240
- } });
2241
- return changed;
2242
- }
2243
- function oxcJsHandler(rawSource, options) {
2244
- if (!canUseOxcJsFastPath(options)) return;
2245
- if (hasUnsupportedSourceMarker(rawSource)) return;
2246
- const parser = loadOxcParser();
2247
- const walker = loadOxcWalker();
2248
- if (!parser || !walker) return;
2249
- let result;
2250
- try {
2251
- result = parser.parseSync(options.filename ?? "weapp-tailwindcss.js", rawSource, {
2252
- sourceType: getParserSourceType(options.babelParserOptions?.sourceType),
2253
- lang: getParserLang(options.filename)
2254
- });
2255
- } catch {
2256
- return;
2257
- }
2258
- if (!result.program || Array.isArray(result.errors) && result.errors.length > 0) return;
2259
- const stringLiteralOptions = options.needEscaped === true ? options : {
2260
- ...options,
2261
- needEscaped: true
2262
- };
2263
- const templateLiteralOptions = options.needEscaped === false ? options : {
2264
- ...options,
2265
- needEscaped: false
2266
- };
2267
- const replacementContext = {};
2268
- if (!applyReplacements(rawSource, result.program, walker, stringLiteralOptions, templateLiteralOptions, replacementContext)) return { code: rawSource };
2269
- return { code: replacementContext.ms.toString() };
2270
- }
2271
- //#endregion
2272
- //#region src/js/precheck.ts
2273
- /** 用于检测源码中是否包含类名相关模式的正则表达式 */
2274
- const FAST_JS_TRANSFORM_HINT_RE = /className\b|class\s*=|classList\.|\b(?:twMerge|clsx|classnames|cn|cva)\b|\[["'`]class["'`]\]|text-\[|bg-\[|\b(?:[whpm]|px|py|mx|my|rounded|flex|grid|gap)-/;
2275
- /** 用于检测源码中是否包含 import/export/require 语句的正则表达式 */
2276
- const DEPENDENCY_HINT_RE = /\bimport\s*[("'`{*]|\brequire\s*\(|\bexport\s+\*\s+from\s+["'`]|\bexport\s*\{[^}]*\}\s*from\s+["'`]/;
2277
- /**
2278
- * 判断源码是否可能声明跨模块依赖。
2279
- *
2280
- * 该检查只作为性能预筛:返回 `true` 时必须保守走 AST 模块图分析;
2281
- * 返回 `false` 时源码中没有可被当前模块图消费的静态 import/export/require 形态。
2282
- */
2283
- function hasDependencyHint(rawSource) {
2284
- return DEPENDENCY_HINT_RE.test(rawSource);
2285
- }
2286
- /**
2287
- * 判断是否可以跳过 JS 转换。
2288
- * 通过正则快速检测源码内容,避免不必要的 Babel AST 解析。
2289
- *
2290
- * @param rawSource - 原始 JS 源码字符串
2291
- * @param options - 可选的 JS 处理器配置选项
2292
- * @returns 如果可以跳过转换返回 `true`,否则返回 `false`
2293
- */
2294
- function shouldSkipJsTransform(rawSource, options) {
2295
- if (node_process.default.env["WEAPP_TW_DISABLE_JS_PRECHECK"] === "1") return false;
2296
- if (!rawSource) return true;
2297
- if (options?.alwaysEscape) return false;
2298
- if (options?.moduleSpecifierReplacements && Object.keys(options.moduleSpecifierReplacements).length > 0) return false;
2299
- if (options?.wrapExpression) return false;
2300
- if (hasDependencyHint(rawSource)) return false;
2301
- return !FAST_JS_TRANSFORM_HINT_RE.test(rawSource);
2302
- }
2303
- //#endregion
2304
- //#region src/js/index.ts
2305
- /** 默认 LRU 缓存最大条目数 */
2306
- const RESULT_CACHE_MAX = 512;
2307
- /** 仅对短片段做内层结果缓存,避免 bundler 热路径重复 hash 大块 JS。 */
2308
- const CACHEABLE_SOURCE_MAX_LENGTH = 512;
2309
- /** 为每个 ClassNameSet 实例分配递增 ID */
2310
- const classNameSetIds = /* @__PURE__ */ new WeakMap();
2311
- let nextClassNameSetId = 0;
2312
- /**
2313
- * 获取 ClassNameSet 的唯一身份 ID。
2314
- * 每个 Set 引用分配一个递增整数,用于指纹计算。
2315
- */
2316
- function getClassNameSetId(set) {
2317
- if (!set) return "none";
2318
- const existing = classNameSetIds.get(set);
2319
- if (existing !== void 0) return String(existing);
2320
- const id = nextClassNameSetId++;
2321
- classNameSetIds.set(set, id);
2322
- return String(id);
2323
- }
2324
- /** 缓存 IJsHandlerOptions -> fingerprint 的映射 */
2325
- const fingerprintCache = /* @__PURE__ */ new WeakMap();
2326
- /**
2327
- * 计算选项指纹,包含所有影响转译结果的字段。
2328
- * 不包含 filename、moduleGraph、jsPreserveClass。
2329
- */
2330
- function getOptionsFingerprint(options) {
2331
- const cached = fingerprintCache.get(options);
2332
- if (cached) return cached;
2333
- const fingerprint = [
2334
- getClassNameSetId(options.classNameSet),
2335
- JSON.stringify(options.escapeMap ?? null),
2336
- options.needEscaped ? "1" : "0",
2337
- options.alwaysEscape ? "1" : "0",
2338
- options.unescapeUnicode ? "1" : "0",
2339
- options.generateMap ? "1" : "0",
2340
- options.uniAppX ? "1" : "0",
2341
- options.wrapExpression ? "1" : "0",
2342
- String(options.tailwindcssMajorVersion ?? ""),
2343
- String(options.jsArbitraryValueFallback ?? ""),
2344
- JSON.stringify(options.arbitraryValues ?? null),
2345
- JSON.stringify(options.ignoreCallExpressionIdentifiers ?? null),
2346
- JSON.stringify(options.ignoreTaggedTemplateExpressionIdentifiers?.map((v) => v instanceof RegExp ? v.source : v) ?? null),
2347
- JSON.stringify(options.moduleSpecifierReplacements ?? null),
2348
- String(options.experimentalJsFastPath ?? ""),
2349
- JSON.stringify(options.babelParserOptions ?? null)
2350
- ].join("|");
2351
- fingerprintCache.set(options, fingerprint);
2352
- return fingerprint;
2353
- }
2354
- function hasDefinedOverrides(options) {
2355
- if (!options) return false;
2356
- for (const key in options) if (options[key] !== void 0) return true;
2357
- return false;
2358
- }
2359
- function shouldCacheJsResult(rawSource, options) {
2360
- if (rawSource.length === 0 || rawSource.length > CACHEABLE_SOURCE_MAX_LENGTH) return false;
2361
- if (options.moduleGraph || options.filename) return false;
2362
- return true;
2363
- }
2364
- function resolveFastPathOptions(rawSource, options) {
2365
- if (!options.moduleGraph) return options;
2366
- if (options.moduleSpecifierReplacements && Object.keys(options.moduleSpecifierReplacements).length > 0) return options;
2367
- if (hasDependencyHint(rawSource)) return options;
2368
- const { moduleGraph: _moduleGraph, ...fastPathOptions } = options;
2369
- return fastPathOptions;
2370
- }
2371
- function createJsHandler(options) {
2372
- const defaults = {
2373
- escapeMap: options.escapeMap,
2374
- jsArbitraryValueFallback: options.jsArbitraryValueFallback,
2375
- tailwindcssMajorVersion: options.tailwindcssMajorVersion,
2376
- arbitraryValues: options.arbitraryValues,
2377
- jsPreserveClass: options.jsPreserveClass,
2378
- generateMap: options.generateMap,
2379
- needEscaped: options.needEscaped,
2380
- alwaysEscape: options.alwaysEscape,
2381
- unescapeUnicode: options.unescapeUnicode,
2382
- babelParserOptions: options.babelParserOptions,
2383
- experimentalJsFastPath: options.experimentalJsFastPath,
2384
- ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers,
2385
- ignoreTaggedTemplateExpressionIdentifiers: options.ignoreTaggedTemplateExpressionIdentifiers,
2386
- uniAppX: options.uniAppX,
2387
- moduleSpecifierReplacements: options.moduleSpecifierReplacements
2388
- };
2389
- /** 层1: 无 override 时,classNameSet -> resolvedOptions */
2390
- const defaultOptionsCache = /* @__PURE__ */ new WeakMap();
2391
- let resolvedOptionsWithoutClassNameSet;
2392
- /** 层2: 有 override 时,overrideOptions -> { bySet, noSet } */
2393
- const overrideOptionsCache = /* @__PURE__ */ new WeakMap();
2394
- const resultCache = new lru_cache.LRUCache({ max: RESULT_CACHE_MAX });
2395
- function resolveDefaultOptions(classNameSet) {
2396
- if (!classNameSet) {
2397
- if (!resolvedOptionsWithoutClassNameSet) resolvedOptionsWithoutClassNameSet = {
2398
- ...defaults,
2399
- classNameSet
2400
- };
2401
- return resolvedOptionsWithoutClassNameSet;
2402
- }
2403
- const cached = defaultOptionsCache.get(classNameSet);
2404
- if (cached) return cached;
2405
- const created = {
2406
- ...defaults,
2407
- classNameSet
2408
- };
2409
- defaultOptionsCache.set(classNameSet, created);
2410
- return created;
2411
- }
2412
- function getCachedJsResult(rawSource, resolvedOptions) {
2413
- if (!shouldCacheJsResult(rawSource, resolvedOptions)) return;
2414
- const key = `${getOptionsFingerprint(resolvedOptions)}:${(0, _weapp_tailwindcss_shared_node.md5)(rawSource)}`;
2415
- return resultCache.get(key);
2416
- }
2417
- function setCachedJsResult(rawSource, resolvedOptions, result) {
2418
- if (!shouldCacheJsResult(rawSource, resolvedOptions) || result.error || result.linked) return result;
2419
- const key = `${getOptionsFingerprint(resolvedOptions)}:${(0, _weapp_tailwindcss_shared_node.md5)(rawSource)}`;
2420
- resultCache.set(key, result);
2421
- return result;
2422
- }
2423
- function resolveOptions(classNameSet, overrideOptions) {
2424
- if (!hasDefinedOverrides(overrideOptions)) return resolveDefaultOptions(classNameSet);
2425
- let entry = overrideOptionsCache.get(overrideOptions);
2426
- if (!entry) {
2427
- entry = { bySet: /* @__PURE__ */ new WeakMap() };
2428
- overrideOptionsCache.set(overrideOptions, entry);
2429
- }
2430
- if (!classNameSet) {
2431
- if (entry.noSet) return entry.noSet;
2432
- const created = (0, _weapp_tailwindcss_shared.defuOverrideArray)({
2433
- ...overrideOptions,
2434
- classNameSet
2435
- }, defaults);
2436
- entry.noSet = created;
2437
- return created;
2438
- }
2439
- const cached = entry.bySet.get(classNameSet);
2440
- if (cached) return cached;
2441
- const created = (0, _weapp_tailwindcss_shared.defuOverrideArray)({
2442
- ...overrideOptions,
2443
- classNameSet
2444
- }, defaults);
2445
- entry.bySet.set(classNameSet, created);
2446
- return created;
2447
- }
2448
- function handler(rawSource, classNameSet, options) {
2449
- const resolvedOptions = resolveOptions(classNameSet, options);
2450
- const cached = getCachedJsResult(rawSource, resolvedOptions);
2451
- if (cached) return cached;
2452
- return setCachedJsResult(rawSource, resolvedOptions, oxcJsHandler(rawSource, resolveFastPathOptions(rawSource, resolvedOptions)) ?? jsHandler(rawSource, resolvedOptions));
2453
- }
2454
- return handler;
2455
- }
2456
- //#endregion
2457
1508
  //#region src/wxml/custom-attributes.ts
2458
1509
  function regTest(reg, str) {
2459
1510
  reg.lastIndex = 0;
@@ -4812,282 +3863,6 @@ function createTemplateHandler(options = {}) {
4812
3863
  };
4813
3864
  }
4814
3865
  //#endregion
4815
- //#region src/constants.ts
4816
- const pluginName = "weapp-tailwindcss";
4817
- const vitePluginName = "weapp-tailwindcss:adaptor";
4818
- const DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
4819
- "tailwind-merge": "@weapp-tailwindcss/merge",
4820
- "class-variance-authority": "@weapp-tailwindcss/cva",
4821
- "tailwind-variants": "@weapp-tailwindcss/variants"
4822
- };
4823
- //#endregion
4824
- //#region src/context/runtime-package-replacements.ts
4825
- function resolveRuntimePackageReplacements(option) {
4826
- const mapping = require_generator.resolveBooleanObjectOption(option, DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS);
4827
- if (!mapping) return;
4828
- const normalized = {};
4829
- for (const [from, to] of Object.entries(mapping)) {
4830
- if (!from || typeof to !== "string" || to.length === 0) continue;
4831
- normalized[from] = to;
4832
- }
4833
- return Object.keys(normalized).length > 0 ? normalized : void 0;
4834
- }
4835
- //#endregion
4836
- //#region src/context/style-options.ts
4837
- function normalizeStyleHandlerMajorVersion(majorVersion) {
4838
- return majorVersion === 4 ? 4 : void 0;
4839
- }
4840
- function resolveStyleOptionsFromContext(ctx, tailwindcssMajorVersion) {
4841
- const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(ctx.uniAppX);
4842
- const branch = require_generator.resolveGeneratorRuntimeBranch(require_generator.normalizeWeappTailwindcssGeneratorOptions(ctx.generator, {
4843
- appType: ctx.appType,
4844
- platform: ctx.cssOptions?.platform ?? ctx.platform,
4845
- tailwindcssMajorVersion,
4846
- uniAppX: resolvedUniAppXOptions
4847
- }), {
4848
- appType: ctx.appType,
4849
- platform: ctx.cssOptions?.platform ?? ctx.platform,
4850
- tailwindcssMajorVersion,
4851
- uniAppX: resolvedUniAppXOptions
4852
- });
4853
- const hasCssOptions = ctx.cssOptions !== void 0;
4854
- const cssOptions = {
4855
- cssPreflight: ctx.cssOptions?.cssPreflight ?? ctx.cssPreflight,
4856
- cssPreflightRange: ctx.cssOptions?.cssPreflightRange ?? ctx.cssPreflightRange,
4857
- cssChildCombinatorReplaceValue: ctx.cssOptions?.cssChildCombinatorReplaceValue ?? ctx.cssChildCombinatorReplaceValue,
4858
- cssSelectorReplacement: ctx.cssOptions?.cssSelectorReplacement ?? ctx.cssSelectorReplacement,
4859
- rem2rpx: ctx.cssOptions?.rem2rpx ?? ctx.rem2rpx,
4860
- cssRemoveProperty: ctx.cssOptions?.cssRemoveProperty ?? ctx.cssRemoveProperty,
4861
- cssRemoveHoverPseudoClass: ctx.cssOptions?.cssRemoveHoverPseudoClass ?? ctx.cssRemoveHoverPseudoClass,
4862
- tailwindcssV4GradientFallback: ctx.cssOptions?.tailwindcssV4GradientFallback ?? ctx.tailwindcssV4GradientFallback,
4863
- cssPresetEnv: ctx.cssOptions?.cssPresetEnv ?? ctx.cssPresetEnv,
4864
- atRules: ctx.cssOptions?.atRules ?? ctx.atRules,
4865
- autoprefixer: ctx.cssOptions?.autoprefixer ?? ctx.autoprefixer,
4866
- cssCalc: ctx.cssOptions?.cssCalc ?? ctx.cssCalc,
4867
- platform: branch.platform ?? ctx.cssOptions?.platform ?? ctx.platform,
4868
- px2rpx: ctx.cssOptions?.px2rpx ?? ctx.px2rpx,
4869
- unitsToPx: ctx.cssOptions?.unitsToPx ?? ctx.unitsToPx,
4870
- unitConversion: ctx.cssOptions?.unitConversion ?? ctx.unitConversion,
4871
- injectAdditionalCssVarScope: ctx.cssOptions?.injectAdditionalCssVarScope ?? ctx.injectAdditionalCssVarScope
4872
- };
4873
- return {
4874
- appType: ctx.appType,
4875
- postcssOptions: ctx.postcssOptions,
4876
- cssPreflight: cssOptions.cssPreflight,
4877
- cssPreflightRange: cssOptions.cssPreflightRange,
4878
- cssChildCombinatorReplaceValue: cssOptions.cssChildCombinatorReplaceValue,
4879
- cssSelectorReplacement: cssOptions.cssSelectorReplacement,
4880
- rem2rpx: cssOptions.rem2rpx,
4881
- ...hasCssOptions ? { cssOptions } : {},
4882
- cssRemoveProperty: cssOptions.cssRemoveProperty,
4883
- cssRemoveHoverPseudoClass: cssOptions.cssRemoveHoverPseudoClass,
4884
- tailwindcssV4GradientFallback: cssOptions.tailwindcssV4GradientFallback,
4885
- cssPresetEnv: cssOptions.cssPresetEnv,
4886
- atRules: cssOptions.atRules,
4887
- autoprefixer: cssOptions.autoprefixer,
4888
- cssCalc: cssOptions.cssCalc,
4889
- uniAppX: branch.isNativeApp,
4890
- platform: cssOptions.platform,
4891
- px2rpx: cssOptions.px2rpx,
4892
- unitsToPx: cssOptions.unitsToPx,
4893
- unitConversion: cssOptions.unitConversion
4894
- };
4895
- }
4896
- //#endregion
4897
- //#region src/context/handlers.ts
4898
- function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions, tailwindcssMajorVersion) {
4899
- const { escapeMap, injectAdditionalCssVarScope, postcssOptions, uniAppX, arbitraryValues, jsPreserveClass, jsArbitraryValueFallback, babelParserOptions, experimentalJsFastPath, ignoreCallExpressionIdentifiers, ignoreTaggedTemplateExpressionIdentifiers, inlineWxs, disabledDefaultTemplateHandler, replaceRuntimePackages } = ctx;
4900
- const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(uniAppX);
4901
- const styleOptions = resolveStyleOptionsFromContext(ctx, tailwindcssMajorVersion);
4902
- const resolvedInjectAdditionalCssVarScope = styleOptions.cssOptions?.injectAdditionalCssVarScope ?? injectAdditionalCssVarScope;
4903
- const uniAppXEnabled = styleOptions.uniAppX === true;
4904
- const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
4905
- const styleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
4906
- ...styleOptions,
4907
- escapeMap,
4908
- injectAdditionalCssVarScope: resolvedInjectAdditionalCssVarScope,
4909
- postcssOptions,
4910
- uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
4911
- cssCalc: cssCalcOptions,
4912
- majorVersion: normalizeStyleHandlerMajorVersion(tailwindcssMajorVersion)
4913
- });
4914
- const jsHandler = createJsHandler({
4915
- escapeMap,
4916
- arbitraryValues,
4917
- jsPreserveClass,
4918
- jsArbitraryValueFallback: jsArbitraryValueFallback ?? "auto",
4919
- tailwindcssMajorVersion,
4920
- generateMap: true,
4921
- babelParserOptions,
4922
- experimentalJsFastPath,
4923
- ignoreCallExpressionIdentifiers,
4924
- ignoreTaggedTemplateExpressionIdentifiers,
4925
- uniAppX: uniAppXEnabled,
4926
- moduleSpecifierReplacements
4927
- });
4928
- return {
4929
- styleHandler,
4930
- jsHandler,
4931
- templateHandler: createTemplateHandler({
4932
- customAttributesEntities,
4933
- escapeMap,
4934
- inlineWxs,
4935
- jsHandler,
4936
- disabledDefaultTemplateHandler
4937
- })
4938
- };
4939
- }
4940
- //#endregion
4941
- //#region src/context/logger.ts
4942
- const loggerLevelMap = {
4943
- error: 0,
4944
- warn: 1,
4945
- info: 3,
4946
- silent: -999
4947
- };
4948
- function applyLoggerLevel(logLevel) {
4949
- _weapp_tailwindcss_logger.logger.level = loggerLevelMap[logLevel ?? "info"] ?? loggerLevelMap.info;
4950
- }
4951
- //#endregion
4952
- //#region src/context/index.ts
4953
- function resolveContextCssPreflight(opts, ctx, majorVersion) {
4954
- const userCssPreflight = opts?.cssOptions?.cssPreflight ?? opts?.cssPreflight;
4955
- const cssPreflight = require_defaults.resolveDefaultCssPreflight(userCssPreflight, majorVersion);
4956
- const shouldUseUniAppXPreflight = ctx.appType === "uni-app-x" || require_tailwindcss.resolveUniAppXOptions(ctx.uniAppX).enabled;
4957
- if (cssPreflight === false || !shouldUseUniAppXPreflight) return cssPreflight;
4958
- const userCssPreflightObject = userCssPreflight && typeof userCssPreflight === "object" ? userCssPreflight : void 0;
4959
- return {
4960
- ...cssPreflight,
4961
- "border-width": userCssPreflightObject && "border-width" in userCssPreflightObject ? cssPreflight["border-width"] ?? false : "0",
4962
- "border-style": userCssPreflightObject && "border-style" in userCssPreflightObject ? cssPreflight["border-style"] ?? false : false,
4963
- "border": userCssPreflightObject && "border" in userCssPreflightObject ? cssPreflight["border"] ?? false : false
4964
- };
4965
- }
4966
- function syncCssOptionsToLegacyFields(ctx) {
4967
- if (!ctx.cssOptions) return;
4968
- const cssOptions = ctx.cssOptions;
4969
- ctx.cssPreflight = cssOptions.cssPreflight ?? ctx.cssPreflight;
4970
- ctx.cssPreflightRange = cssOptions.cssPreflightRange ?? ctx.cssPreflightRange;
4971
- ctx.cssChildCombinatorReplaceValue = cssOptions.cssChildCombinatorReplaceValue ?? ctx.cssChildCombinatorReplaceValue;
4972
- ctx.cssSelectorReplacement = cssOptions.cssSelectorReplacement ?? ctx.cssSelectorReplacement;
4973
- ctx.rem2rpx = cssOptions.rem2rpx ?? ctx.rem2rpx;
4974
- ctx.cssRemoveProperty = cssOptions.cssRemoveProperty ?? ctx.cssRemoveProperty;
4975
- ctx.cssRemoveHoverPseudoClass = cssOptions.cssRemoveHoverPseudoClass ?? ctx.cssRemoveHoverPseudoClass;
4976
- ctx.tailwindcssV4GradientFallback = cssOptions.tailwindcssV4GradientFallback ?? ctx.tailwindcssV4GradientFallback;
4977
- ctx.cssPresetEnv = cssOptions.cssPresetEnv ?? ctx.cssPresetEnv;
4978
- ctx.atRules = cssOptions.atRules ?? ctx.atRules;
4979
- ctx.autoprefixer = cssOptions.autoprefixer ?? ctx.autoprefixer;
4980
- ctx.cssCalc = cssOptions.cssCalc ?? ctx.cssCalc;
4981
- ctx.platform = cssOptions.platform ?? ctx.platform;
4982
- ctx.px2rpx = cssOptions.px2rpx ?? ctx.px2rpx;
4983
- ctx.unitsToPx = cssOptions.unitsToPx ?? ctx.unitsToPx;
4984
- ctx.unitConversion = cssOptions.unitConversion ?? ctx.unitConversion;
4985
- ctx.injectAdditionalCssVarScope = cssOptions.injectAdditionalCssVarScope ?? ctx.injectAdditionalCssVarScope;
4986
- }
4987
- function syncLegacyFieldsToCssOptions(ctx) {
4988
- if (!ctx.cssOptions) return;
4989
- ctx.cssOptions = {
4990
- ...ctx.cssOptions ?? {},
4991
- cssPreflight: ctx.cssPreflight,
4992
- cssPreflightRange: ctx.cssPreflightRange,
4993
- cssChildCombinatorReplaceValue: ctx.cssChildCombinatorReplaceValue,
4994
- cssSelectorReplacement: ctx.cssSelectorReplacement,
4995
- rem2rpx: ctx.rem2rpx,
4996
- cssRemoveProperty: ctx.cssRemoveProperty,
4997
- cssRemoveHoverPseudoClass: ctx.cssRemoveHoverPseudoClass,
4998
- tailwindcssV4GradientFallback: ctx.tailwindcssV4GradientFallback,
4999
- cssPresetEnv: ctx.cssPresetEnv,
5000
- atRules: ctx.atRules,
5001
- autoprefixer: ctx.autoprefixer,
5002
- cssCalc: ctx.cssCalc,
5003
- platform: ctx.platform,
5004
- px2rpx: ctx.px2rpx,
5005
- unitsToPx: ctx.unitsToPx,
5006
- unitConversion: ctx.unitConversion,
5007
- injectAdditionalCssVarScope: ctx.injectAdditionalCssVarScope
5008
- };
5009
- }
5010
- function applyFrameworkPlatformDefaults(ctx) {
5011
- if (ctx.cssOptions?.platform || ctx.platform) {
5012
- ctx.platform = normalizeFrameworkStylePlatform(ctx.cssOptions?.platform ?? ctx.platform, ctx.appType);
5013
- return;
5014
- }
5015
- if (ctx.appType === "mpx") ctx.platform = normalizeFrameworkStylePlatform(require_framework.resolveMpxPlatform().normalized, ctx.appType);
5016
- }
5017
- async function clearTailwindcssRuntimeCache(tailwindRuntime, options) {
5018
- if (!tailwindRuntime) return;
5019
- const cacheOptions = tailwindRuntime.options?.cache;
5020
- if (cacheOptions == null || typeof cacheOptions === "object" && cacheOptions.enabled === false) return;
5021
- if (typeof tailwindRuntime.clearCache === "function") try {
5022
- await tailwindRuntime.clearCache({ scope: "all" });
5023
- } catch (error) {
5024
- _weapp_tailwindcss_logger.logger.debug("failed to clear tailwindcss runtime cache via clearCache(): %O", error);
5025
- }
5026
- if (!options?.removeDirectory) return;
5027
- const cachePaths = /* @__PURE__ */ new Map();
5028
- const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
5029
- const privateCachePath = tailwindRuntime?.cacheStore?.options?.path;
5030
- if (privateCachePath) cachePaths.set(privateCachePath, false);
5031
- if (normalizedCacheOptions?.path) cachePaths.set(normalizedCacheOptions.path, false);
5032
- if (options?.removeDirectory && normalizedCacheOptions?.dir) cachePaths.set(normalizedCacheOptions.dir, true);
5033
- if (!cachePaths.size) return;
5034
- for (const [cachePath, recursive] of cachePaths.entries()) try {
5035
- await (0, node_fs_promises.rm)(cachePath, {
5036
- force: true,
5037
- recursive
5038
- });
5039
- } catch (error) {
5040
- const err = error;
5041
- if (err?.code === "ENOENT") continue;
5042
- _weapp_tailwindcss_logger.logger.debug("failed to clear tailwindcss runtime cache: %s %O", cachePath, err);
5043
- }
5044
- }
5045
- function createInternalCompilerContext(opts) {
5046
- const ctx = (0, _weapp_tailwindcss_shared.defuOverrideArray)(opts, require_defaults.getDefaultOptions(), {});
5047
- ctx.arbitraryValues = resolveUnocssBareArbitraryValues(ctx.arbitraryValues, ctx.unocss);
5048
- ctx.escapeMap = ctx.customReplaceDictionary;
5049
- syncCssOptionsToLegacyFields(ctx);
5050
- applyFrameworkPlatformDefaults(ctx);
5051
- applyLoggerLevel(ctx.logLevel);
5052
- const tailwindRuntime = require_tailwindcss.createTailwindcssRuntimeFromContext(ctx);
5053
- logTailwindcssTarget(tailwindRuntime, ctx.tailwindcssBasedir);
5054
- logRuntimeTailwindcssVersion(ctx.tailwindcssBasedir, tailwindRuntime.packageInfo?.rootPath, tailwindRuntime.packageInfo?.version);
5055
- if (opts?.__internalDeferMissingCssEntriesWarning !== true) require_tailwindcss.warnMissingCssEntries(ctx, tailwindRuntime);
5056
- ctx.cssPreflight = resolveContextCssPreflight(opts, ctx, tailwindRuntime.majorVersion);
5057
- const cssCalcOptions = require_tailwindcss.applyV4CssCalcDefaults(ctx.cssCalc, tailwindRuntime);
5058
- ctx.cssCalc = cssCalcOptions;
5059
- syncLegacyFieldsToCssOptions(ctx);
5060
- const { styleHandler, jsHandler, templateHandler } = createHandlersFromContext(ctx, toCustomAttributesEntities(ctx.customAttributes), cssCalcOptions, tailwindRuntime.majorVersion);
5061
- ctx.styleHandler = styleHandler;
5062
- ctx.jsHandler = jsHandler;
5063
- ctx.templateHandler = templateHandler;
5064
- ctx.cache = initializeCache(ctx.cache);
5065
- ctx.tailwindRuntime = tailwindRuntime;
5066
- const refreshTailwindcssRuntime = async (options) => {
5067
- const previousRuntime = ctx.tailwindRuntime;
5068
- if (options?.clearCache !== false) await clearTailwindcssRuntimeCache(previousRuntime);
5069
- require_tailwindcss.invalidateRuntimeClassSet(previousRuntime);
5070
- const nextRuntime = require_tailwindcss.createTailwindcssRuntimeFromContext(ctx);
5071
- Object.assign(previousRuntime, nextRuntime);
5072
- ctx.tailwindRuntime = previousRuntime;
5073
- return previousRuntime;
5074
- };
5075
- ctx.refreshTailwindcssRuntime = refreshTailwindcssRuntime;
5076
- Object.defineProperty(ctx.tailwindRuntime, refreshTailwindcssRuntimeSymbol, {
5077
- value: refreshTailwindcssRuntime,
5078
- configurable: true
5079
- });
5080
- return ctx;
5081
- }
5082
- /**
5083
- * 获取用户定义选项的内部表示,并初始化相关的处理程序和 Tailwind 运行时。
5084
- * @param opts - 用户定义的选项,可选。
5085
- * @returns 返回一个包含内部用户定义选项的对象,包括样式、JS 和模板处理程序,以及 Tailwind CSS 运行时。
5086
- */
5087
- function getCompilerContext(opts) {
5088
- return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
5089
- }
5090
- //#endregion
5091
3866
  Object.defineProperty(exports, "JsTokenUpdater", {
5092
3867
  enumerable: true,
5093
3868
  get: function() {
@@ -5118,12 +3893,6 @@ Object.defineProperty(exports, "babelParse", {
5118
3893
  return babelParse;
5119
3894
  }
5120
3895
  });
5121
- Object.defineProperty(exports, "collectRuntimeClassSet", {
5122
- enumerable: true,
5123
- get: function() {
5124
- return collectRuntimeClassSet;
5125
- }
5126
- });
5127
3896
  Object.defineProperty(exports, "createAttributeMatcher", {
5128
3897
  enumerable: true,
5129
3898
  get: function() {
@@ -5136,16 +3905,16 @@ Object.defineProperty(exports, "createDebug", {
5136
3905
  return createDebug;
5137
3906
  }
5138
3907
  });
5139
- Object.defineProperty(exports, "createTailwindRuntimeReadyPromise", {
3908
+ Object.defineProperty(exports, "createTemplateHandler", {
5140
3909
  enumerable: true,
5141
3910
  get: function() {
5142
- return createTailwindRuntimeReadyPromise;
3911
+ return createTemplateHandler;
5143
3912
  }
5144
3913
  });
5145
- Object.defineProperty(exports, "ensureRuntimeClassSet", {
3914
+ Object.defineProperty(exports, "decodeUnicode2", {
5146
3915
  enumerable: true,
5147
3916
  get: function() {
5148
- return ensureRuntimeClassSet;
3917
+ return decodeUnicode2;
5149
3918
  }
5150
3919
  });
5151
3920
  Object.defineProperty(exports, "generateCode", {
@@ -5154,40 +3923,34 @@ Object.defineProperty(exports, "generateCode", {
5154
3923
  return generateCode;
5155
3924
  }
5156
3925
  });
5157
- Object.defineProperty(exports, "getCompilerContext", {
3926
+ Object.defineProperty(exports, "getReplacement", {
5158
3927
  enumerable: true,
5159
3928
  get: function() {
5160
- return getCompilerContext;
3929
+ return getReplacement;
5161
3930
  }
5162
3931
  });
5163
- Object.defineProperty(exports, "isClassContextLiteralPath", {
3932
+ Object.defineProperty(exports, "getReplacementCacheStore", {
5164
3933
  enumerable: true,
5165
3934
  get: function() {
5166
- return isClassContextLiteralPath;
3935
+ return getReplacementCacheStore;
5167
3936
  }
5168
3937
  });
5169
- Object.defineProperty(exports, "normalizeFrameworkStylePlatform", {
5170
- enumerable: true,
5171
- get: function() {
5172
- return normalizeFrameworkStylePlatform;
5173
- }
5174
- });
5175
- Object.defineProperty(exports, "normalizeStyleHandlerMajorVersion", {
3938
+ Object.defineProperty(exports, "isClassContextLiteralPath", {
5176
3939
  enumerable: true,
5177
3940
  get: function() {
5178
- return normalizeStyleHandlerMajorVersion;
3941
+ return isClassContextLiteralPath;
5179
3942
  }
5180
3943
  });
5181
- Object.defineProperty(exports, "pluginName", {
3944
+ Object.defineProperty(exports, "jsHandler", {
5182
3945
  enumerable: true,
5183
3946
  get: function() {
5184
- return pluginName;
3947
+ return jsHandler;
5185
3948
  }
5186
3949
  });
5187
- Object.defineProperty(exports, "refreshTailwindRuntimeState", {
3950
+ Object.defineProperty(exports, "jsStringEscape", {
5188
3951
  enumerable: true,
5189
3952
  get: function() {
5190
- return refreshTailwindRuntimeState;
3953
+ return jsStringEscape;
5191
3954
  }
5192
3955
  });
5193
3956
  Object.defineProperty(exports, "replaceWxml", {
@@ -5196,22 +3959,16 @@ Object.defineProperty(exports, "replaceWxml", {
5196
3959
  return replaceWxml;
5197
3960
  }
5198
3961
  });
5199
- Object.defineProperty(exports, "resolveStyleOptionsFromContext", {
5200
- enumerable: true,
5201
- get: function() {
5202
- return resolveStyleOptionsFromContext;
5203
- }
5204
- });
5205
- Object.defineProperty(exports, "shouldSkipJsTransform", {
3962
+ Object.defineProperty(exports, "resolveClassNameTransformWithResult", {
5206
3963
  enumerable: true,
5207
3964
  get: function() {
5208
- return shouldSkipJsTransform;
3965
+ return resolveClassNameTransformWithResult;
5209
3966
  }
5210
3967
  });
5211
- Object.defineProperty(exports, "toCustomAttributesEntities", {
3968
+ Object.defineProperty(exports, "shouldEnableArbitraryValueFallback", {
5212
3969
  enumerable: true,
5213
3970
  get: function() {
5214
- return toCustomAttributesEntities;
3971
+ return shouldEnableArbitraryValueFallback;
5215
3972
  }
5216
3973
  });
5217
3974
  Object.defineProperty(exports, "traverse", {
@@ -5220,9 +3977,3 @@ Object.defineProperty(exports, "traverse", {
5220
3977
  return traverse;
5221
3978
  }
5222
3979
  });
5223
- Object.defineProperty(exports, "vitePluginName", {
5224
- enumerable: true,
5225
- get: function() {
5226
- return vitePluginName;
5227
- }
5228
- });