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
@@ -0,0 +1,1311 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
2
+ const require_framework = require("./framework.js");
3
+ const require_generator = require("./generator-CS10c9g1.js");
4
+ const require_tailwindcss = require("./tailwindcss-z9JMF-qU.js");
5
+ require("./utils-CuKLf1Zv.js");
6
+ const require_wxml = require("./wxml-Ce10eREX.js");
7
+ const require_defaults = require("./defaults.js");
8
+ let node_path = require("node:path");
9
+ node_path = require_rolldown_runtime.__toESM(node_path);
10
+ let node_process = require("node:process");
11
+ node_process = require_rolldown_runtime.__toESM(node_process);
12
+ let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
13
+ let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
14
+ let lru_cache = require("lru-cache");
15
+ let node_module = require("node:module");
16
+ let node_fs_promises = require("node:fs/promises");
17
+ let node_buffer = require("node:buffer");
18
+ let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
19
+ let magic_string = require("magic-string");
20
+ magic_string = require_rolldown_runtime.__toESM(magic_string);
21
+ let _weapp_tailwindcss_shared_node = require("@weapp-tailwindcss/shared/node");
22
+ let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
23
+ //#region src/cache/index.ts
24
+ function isProcessResult(value) {
25
+ return typeof value === "object" && value !== null && "result" in value;
26
+ }
27
+ function createCache(options) {
28
+ const disabled = options === false;
29
+ const hashMap = /* @__PURE__ */ new Map();
30
+ const instance = new lru_cache.LRUCache({
31
+ max: 1024,
32
+ ttl: 0,
33
+ ttlAutopurge: false
34
+ });
35
+ const cache = {
36
+ hashMap,
37
+ instance,
38
+ hasHashKey(key) {
39
+ return hashMap.has(key);
40
+ },
41
+ getHashValue(key) {
42
+ return hashMap.get(key);
43
+ },
44
+ setHashValue(key, value) {
45
+ return hashMap.set(key, value);
46
+ },
47
+ get(key) {
48
+ return instance.get(key);
49
+ },
50
+ set(key, value) {
51
+ return instance.set(key, value);
52
+ },
53
+ computeHash(message) {
54
+ return (0, _weapp_tailwindcss_shared_node.md5)(message);
55
+ },
56
+ calcHashValueChanged(key, hash) {
57
+ const hit = hashMap.get(key);
58
+ if (hit) hashMap.set(key, {
59
+ changed: hash !== hit.hash,
60
+ hash
61
+ });
62
+ else hashMap.set(key, {
63
+ changed: true,
64
+ hash
65
+ });
66
+ return cache;
67
+ },
68
+ pruneHashKeys(hashKeys) {
69
+ const activeHashKeys = new Set(hashKeys);
70
+ for (const key of hashMap.keys()) if (!activeHashKeys.has(key)) hashMap.delete(key);
71
+ },
72
+ prune(options) {
73
+ if (options.cacheKeys) {
74
+ const cacheKeys = new Set(options.cacheKeys);
75
+ for (const key of instance.keys()) if (!cacheKeys.has(key)) instance.delete(key);
76
+ }
77
+ if (options.hashKeys) cache.pruneHashKeys?.(options.hashKeys);
78
+ },
79
+ has(key) {
80
+ return instance.has(key);
81
+ },
82
+ async process({ key, hashKey, rawSource, hash, resolveCache, transform, onCacheHit }) {
83
+ if (disabled) {
84
+ const value = await transform();
85
+ return isProcessResult(value) ? value.result : value;
86
+ }
87
+ const cacheHashKey = hashKey ?? key;
88
+ let hasChanged = true;
89
+ if (hash != null || rawSource != null) {
90
+ const nextHash = hash ?? cache.computeHash(rawSource);
91
+ cache.calcHashValueChanged(cacheHashKey, nextHash);
92
+ hasChanged = cache.getHashValue(cacheHashKey)?.changed ?? true;
93
+ }
94
+ const readCache = resolveCache ?? (() => cache.get(key));
95
+ if (!hasChanged) {
96
+ const cached = readCache();
97
+ if (cached !== void 0) {
98
+ await onCacheHit?.(cached);
99
+ return cached;
100
+ }
101
+ }
102
+ const value = await transform();
103
+ const normalized = isProcessResult(value) ? value : { result: value };
104
+ const stored = normalized.cacheValue ?? normalized.result;
105
+ cache.set(key, stored);
106
+ return normalized.result;
107
+ }
108
+ };
109
+ return cache;
110
+ }
111
+ function initializeCache(cacheConfig) {
112
+ if (typeof cacheConfig === "boolean" || cacheConfig === void 0) return createCache(cacheConfig);
113
+ return cacheConfig;
114
+ }
115
+ //#endregion
116
+ //#region src/framework/platform.ts
117
+ const MPX_TO_UNI_PLATFORM = {
118
+ ali: "mp-alipay",
119
+ dd: "mp-dingtalk",
120
+ jd: "mp-jd",
121
+ qq: "mp-qq",
122
+ swan: "mp-baidu",
123
+ tt: "mp-toutiao",
124
+ wx: "mp-weixin"
125
+ };
126
+ function normalizeFrameworkStylePlatform(platform, appType) {
127
+ const normalized = platform?.trim().toLowerCase();
128
+ if (!normalized) return;
129
+ if (appType === "mpx") return MPX_TO_UNI_PLATFORM[normalized] ?? normalized;
130
+ return normalized;
131
+ }
132
+ //#endregion
133
+ //#region src/tailwindcss/runtime.ts
134
+ const debug = require_wxml.createDebug("[tailwindcss:runtime] ");
135
+ const refreshTailwindcssRuntimeSymbol = Symbol.for("weapp-tailwindcss.refreshTailwindcssRuntime");
136
+ function createTailwindRuntimeReadyPromise(tailwindRuntime) {
137
+ return Promise.resolve().then(async () => {
138
+ require_tailwindcss.invalidateRuntimeClassSet(tailwindRuntime);
139
+ });
140
+ }
141
+ const runtimeClassSetStateCache = /* @__PURE__ */ new WeakMap();
142
+ function getRuntimeClassSetStateEntry(state) {
143
+ let entry = runtimeClassSetStateCache.get(state);
144
+ if (!entry) {
145
+ entry = {};
146
+ runtimeClassSetStateCache.set(state, entry);
147
+ }
148
+ return entry;
149
+ }
150
+ function getTailwindRuntime(state) {
151
+ return state.tailwindRuntime;
152
+ }
153
+ function setTailwindRuntime(state, runtime) {
154
+ state.tailwindRuntime = runtime;
155
+ }
156
+ function getRefreshTailwindRuntime(state) {
157
+ return state.refreshTailwindcssRuntime;
158
+ }
159
+ async function refreshTailwindRuntimeState(state, forceOrOptions) {
160
+ const normalizedOptions = typeof forceOrOptions === "boolean" ? { force: forceOrOptions } : forceOrOptions;
161
+ const force = normalizedOptions.force;
162
+ const clearCache = normalizedOptions.clearCache === true;
163
+ if (!force) return false;
164
+ const currentRuntime = getTailwindRuntime(state);
165
+ debug("refresh runtime state start, clearCache=%s major=%s", clearCache, currentRuntime.majorVersion ?? "unknown");
166
+ await state.readyPromise;
167
+ let refreshed = false;
168
+ const refreshTailwindRuntime = getRefreshTailwindRuntime(state);
169
+ if (typeof refreshTailwindRuntime === "function") {
170
+ const next = await refreshTailwindRuntime({ clearCache });
171
+ if (next !== getTailwindRuntime(state)) setTailwindRuntime(state, next);
172
+ refreshed = true;
173
+ }
174
+ if (refreshed) state.readyPromise = createTailwindRuntimeReadyPromise(getTailwindRuntime(state));
175
+ debug("refresh runtime state end, refreshed=%s major=%s", refreshed, getTailwindRuntime(state).majorVersion ?? "unknown");
176
+ return refreshed;
177
+ }
178
+ async function ensureRuntimeClassSet(state, options = {}) {
179
+ const forceRefresh = options.forceRefresh === true;
180
+ const forceCollect = options.forceCollect === true;
181
+ const clearCache = options.clearCache === true;
182
+ const allowEmpty = options.allowEmpty === true;
183
+ if (forceRefresh) await refreshTailwindRuntimeState(state, {
184
+ force: true,
185
+ clearCache
186
+ });
187
+ await state.readyPromise;
188
+ const entry = getRuntimeClassSetStateEntry(state);
189
+ const signature = await require_tailwindcss.getRuntimeClassSetSignatureWithSources(getTailwindRuntime(state));
190
+ const signatureChanged = entry.signature !== signature;
191
+ const shouldForceCollect = forceCollect || forceRefresh || signatureChanged;
192
+ if (!shouldForceCollect) {
193
+ if (entry.value && (allowEmpty || entry.value.size > 0)) return entry.value;
194
+ if (entry.promise) return entry.promise;
195
+ }
196
+ const task = (async () => {
197
+ const collected = await collectRuntimeClassSet(getTailwindRuntime(state), {
198
+ force: shouldForceCollect,
199
+ skipRefresh: true,
200
+ clearCache
201
+ });
202
+ if (allowEmpty || collected.size > 0) return collected;
203
+ await refreshTailwindRuntimeState(state, {
204
+ force: true,
205
+ clearCache: true
206
+ });
207
+ await state.readyPromise;
208
+ return collectRuntimeClassSet(getTailwindRuntime(state), {
209
+ force: true,
210
+ skipRefresh: true,
211
+ clearCache: true
212
+ });
213
+ })();
214
+ entry.promise = task;
215
+ try {
216
+ const runtimeSet = await task;
217
+ entry.value = runtimeSet;
218
+ entry.signature = await require_tailwindcss.getRuntimeClassSetSignatureWithSources(getTailwindRuntime(state));
219
+ return runtimeSet;
220
+ } finally {
221
+ if (entry.promise === task) entry.promise = void 0;
222
+ }
223
+ }
224
+ function tryGetRuntimeClassSetSync(tailwindRuntime) {
225
+ if (typeof tailwindRuntime.getClassSetSync !== "function") return;
226
+ try {
227
+ const set = tailwindRuntime.getClassSetSync();
228
+ if (set && set.size === 0) return;
229
+ return set;
230
+ } catch (error) {
231
+ debug("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
232
+ return;
233
+ }
234
+ }
235
+ async function collectTailwindV4GeneratorClassSet(tailwindRuntime) {
236
+ if (typeof tailwindRuntime.collectContentTokens !== "function") return;
237
+ try {
238
+ const source = require_generator.resolveCssMacroTailwindV4Source(await require_generator.resolveTailwindV4SourceFromRuntime(tailwindRuntime));
239
+ const generated = await require_generator.createTailwindV4Engine(source).generate({
240
+ scanSources: true,
241
+ target: "web"
242
+ });
243
+ const classSet = (0, _tailwindcss_mangle_engine.resolveValidTailwindV4Candidates)(await (0, _tailwindcss_mangle_engine.loadTailwindV4DesignSystem)(source), generated.classSet, { ...source.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: source.bareArbitraryValues } });
244
+ debug("runtime class set resolved via tailwindcss v4 generator source scan, raw=%d valid=%d", generated.classSet.size, classSet.size);
245
+ return classSet;
246
+ } catch (error) {
247
+ debug("tailwindcss v4 generator source scan failed, continuing fallback chain: %O", error);
248
+ return;
249
+ }
250
+ }
251
+ async function mergeTailwindV4GeneratorClassSet(tailwindRuntime, classSet) {
252
+ const generatorClassSet = await collectTailwindV4GeneratorClassSet(tailwindRuntime).catch(() => void 0);
253
+ if (!generatorClassSet || generatorClassSet.size === 0) return classSet;
254
+ return /* @__PURE__ */ new Set([...classSet, ...generatorClassSet]);
255
+ }
256
+ async function collectRuntimeClassSet(tailwindRuntime, options = {}) {
257
+ let activeRuntime = tailwindRuntime;
258
+ if (options.force && !options.skipRefresh) {
259
+ const refresh = activeRuntime[refreshTailwindcssRuntimeSymbol];
260
+ if (typeof refresh === "function") try {
261
+ const refreshed = await refresh({ clearCache: options.clearCache === true });
262
+ if (refreshed) activeRuntime = refreshed;
263
+ } catch (error) {
264
+ debug("refreshTailwindcssRuntime failed, continuing with existing runtime: %O", error);
265
+ }
266
+ }
267
+ const entry = require_tailwindcss.getRuntimeClassSetCacheEntry(activeRuntime);
268
+ const signature = await require_tailwindcss.getRuntimeClassSetSignatureWithSources(activeRuntime);
269
+ if (!options.force) {
270
+ if (entry.value && entry.signature === signature) return entry.value;
271
+ if (entry.promise) return entry.promise;
272
+ } else entry.value = void 0;
273
+ const task = (async () => {
274
+ const preferExtract = options.force === true;
275
+ try {
276
+ const result = await activeRuntime.extract({ write: false });
277
+ if (result?.classSet) {
278
+ if (result.classSet.size > 0) {
279
+ const merged = await mergeTailwindV4GeneratorClassSet(activeRuntime, result.classSet);
280
+ debug("runtime class set resolved via extract() + tailwindcss v4 source scan, extract=%d merged=%d", result.classSet.size, merged.size);
281
+ return merged;
282
+ }
283
+ if (preferExtract) debug("runtime class set from extract() is empty on force collect, fallback to generator/sync/async class set");
284
+ else debug("runtime class set from extract() is empty, fallback to sync/async class set");
285
+ }
286
+ } catch (error) {
287
+ debug("extract() failed, fallback to getClassSet(): %O", error);
288
+ }
289
+ const generatorClassSet = await collectTailwindV4GeneratorClassSet(activeRuntime);
290
+ if (generatorClassSet && generatorClassSet.size > 0) return generatorClassSet;
291
+ const syncSet = tryGetRuntimeClassSetSync(activeRuntime);
292
+ if (syncSet) {
293
+ debug("runtime class set resolved via getClassSetSync(), size=%d", syncSet.size);
294
+ return syncSet;
295
+ }
296
+ try {
297
+ const fallbackSet = await Promise.resolve(activeRuntime.getClassSet());
298
+ if (fallbackSet) {
299
+ debug("runtime class set resolved via getClassSet(), size=%d", fallbackSet.size);
300
+ return fallbackSet;
301
+ }
302
+ } catch (error) {
303
+ debug("getClassSet() failed, returning empty set: %O", error);
304
+ }
305
+ return /* @__PURE__ */ new Set();
306
+ })();
307
+ entry.promise = task;
308
+ entry.signature = signature;
309
+ try {
310
+ const resolved = await task;
311
+ entry.value = resolved;
312
+ entry.promise = void 0;
313
+ entry.signature = signature;
314
+ return resolved;
315
+ } catch (error) {
316
+ entry.promise = void 0;
317
+ throw error;
318
+ }
319
+ }
320
+ //#endregion
321
+ //#region src/tailwindcss/runtime-logs.ts
322
+ const runtimeLogDedupeHolder = globalThis;
323
+ const runtimeLogDedupe = runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ ?? (runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ = /* @__PURE__ */ new Set());
324
+ function createRuntimeLogKey(category, baseDir, rootPath, version) {
325
+ return JSON.stringify([
326
+ category,
327
+ baseDir ?? node_process.default.cwd(),
328
+ rootPath ?? "",
329
+ version ?? ""
330
+ ]);
331
+ }
332
+ function markRuntimeLog(category, baseDir, rootPath, version) {
333
+ const key = createRuntimeLogKey(category, baseDir, rootPath, version);
334
+ if (runtimeLogDedupe.has(key)) return false;
335
+ runtimeLogDedupe.add(key);
336
+ return true;
337
+ }
338
+ function logRuntimeTailwindcssTarget(baseDir, rootPath, version) {
339
+ if (!markRuntimeLog("target", baseDir, rootPath, version)) return;
340
+ const versionText = version ? ` (v${version})` : "";
341
+ _weapp_tailwindcss_logger.logger.info("%s 使用 Tailwind CSS%s", "Weapp-tailwindcss", versionText);
342
+ }
343
+ function logRuntimeTailwindcssVersion(baseDir, rootPath, version) {
344
+ if (version) {
345
+ if (!markRuntimeLog("version", baseDir, rootPath, version)) return;
346
+ _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)))}`);
347
+ return;
348
+ }
349
+ if (!markRuntimeLog("missing", baseDir, rootPath, version)) return;
350
+ _weapp_tailwindcss_logger.logger.warn(`${_weapp_tailwindcss_logger.pc.cyanBright("Tailwind CSS")} 未安装,已跳过版本检测与运行时初始化。`);
351
+ }
352
+ //#endregion
353
+ //#region src/tailwindcss/targets.ts
354
+ function formatRelativeToBase(targetPath, baseDir) {
355
+ const normalized = node_path.default.normalize(targetPath);
356
+ if (!baseDir) return normalized.replace(/\\/g, "/");
357
+ const relative = node_path.default.relative(baseDir, normalized);
358
+ if (!relative || relative === ".") return ".";
359
+ if (relative.startsWith("..")) return normalized.replace(/\\/g, "/");
360
+ return node_path.default.join(".", relative).replace(/\\/g, "/");
361
+ }
362
+ function logTailwindcssTarget(tailwindRuntime, baseDir) {
363
+ const packageInfo = tailwindRuntime?.packageInfo;
364
+ const label = "Weapp-tailwindcss";
365
+ if (!packageInfo?.rootPath) {
366
+ _weapp_tailwindcss_logger.logger.warn("%s 未找到 Tailwind CSS 依赖,请检查在 %s 是否已安装 tailwindcss", label, baseDir ?? node_process.default.cwd());
367
+ return;
368
+ }
369
+ const displayPath = formatRelativeToBase(packageInfo.rootPath, baseDir);
370
+ const version = packageInfo.version ? ` (v${packageInfo.version})` : "";
371
+ logRuntimeTailwindcssTarget(baseDir, packageInfo.rootPath, packageInfo.version);
372
+ _weapp_tailwindcss_logger.logger.debug("%s 解析 Tailwind CSS -> %s%s", label, displayPath, version);
373
+ }
374
+ //#endregion
375
+ //#region src/unocss/index.ts
376
+ function normalizeUnocssOptions(unocss) {
377
+ return require_generator.resolveBooleanObjectOption(unocss, {});
378
+ }
379
+ function resolveUnocssBareArbitraryValues(arbitraryValues, unocss) {
380
+ const baseArbitraryValues = arbitraryValues ?? {};
381
+ const options = normalizeUnocssOptions(unocss);
382
+ if (!options) return baseArbitraryValues;
383
+ if (baseArbitraryValues.bareArbitraryValues !== void 0 && baseArbitraryValues.bareArbitraryValues !== false) return baseArbitraryValues;
384
+ const bareArbitraryValues = options.bareArbitraryValues ?? true;
385
+ if (bareArbitraryValues === false) return baseArbitraryValues;
386
+ return {
387
+ ...baseArbitraryValues,
388
+ bareArbitraryValues
389
+ };
390
+ }
391
+ //#endregion
392
+ //#region src/context/compiler-context-cache.ts
393
+ const PAREN_CONTENT_RE = /\(([^)]+)\)/u;
394
+ const AT_LOCATION_RE = /at\s+(\S.*)$/u;
395
+ const TRAILING_LINE_COL_RE = /:\d+(?::\d+)?$/u;
396
+ const DEFAULT_COMPILER_CONTEXT_CACHE_MAX = 32;
397
+ const DEFAULT_COMPILER_CONTEXT_KEY_CACHE_MAX = DEFAULT_COMPILER_CONTEXT_CACHE_MAX * 2;
398
+ const globalCacheHolder = globalThis;
399
+ const compilerContextCache = globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ ?? (globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ = /* @__PURE__ */ new Map());
400
+ const compilerContextKeyCacheByOptions = /* @__PURE__ */ new WeakMap();
401
+ const compilerContextKeyCacheWithoutOptions = /* @__PURE__ */ new Map();
402
+ function resolveCompilerContextCacheMax(defaultValue) {
403
+ const raw = Number.parseInt(node_process.default.env["WEAPP_TW_COMPILER_CONTEXT_CACHE_MAX"] ?? "", 10);
404
+ if (!Number.isFinite(raw) || raw <= 0) return defaultValue;
405
+ return Math.floor(raw);
406
+ }
407
+ function touchMapValue(map, key, value) {
408
+ map.delete(key);
409
+ map.set(key, value);
410
+ }
411
+ function pruneMapToMaxSize(map, maxSize) {
412
+ while (map.size > maxSize) {
413
+ const firstKey = map.keys().next().value;
414
+ if (firstKey === void 0) break;
415
+ map.delete(firstKey);
416
+ }
417
+ }
418
+ function withCircularGuard(value, stack, factory) {
419
+ if (stack.has(value)) throw new TypeError("Cannot serialize circular structure in compiler context options");
420
+ stack.add(value);
421
+ try {
422
+ return factory();
423
+ } finally {
424
+ stack.delete(value);
425
+ }
426
+ }
427
+ function encodeTaggedValue(type, value) {
428
+ const record = { __type: type };
429
+ if (value !== void 0) record["value"] = value;
430
+ return record;
431
+ }
432
+ function hasExplicitOptionBasedir(opts) {
433
+ return typeof opts?.tailwindcssBasedir === "string" && opts.tailwindcssBasedir.length > 0;
434
+ }
435
+ function shouldProbeCallerLocation(opts) {
436
+ if (hasExplicitOptionBasedir(opts)) return false;
437
+ 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"]);
438
+ }
439
+ function detectCallerLocation() {
440
+ const stack = (/* @__PURE__ */ new Error("compiler-context-cache stack probe")).stack;
441
+ if (!stack) return;
442
+ const lines = stack.split("\n");
443
+ for (const line of lines) {
444
+ const location = (line.match(PAREN_CONTENT_RE) ?? line.match(AT_LOCATION_RE))?.[1];
445
+ if (!location) continue;
446
+ const candidatePath = location.replace(TRAILING_LINE_COL_RE, "");
447
+ if (!candidatePath || !node_path.default.isAbsolute(candidatePath)) continue;
448
+ 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;
449
+ return candidatePath;
450
+ }
451
+ }
452
+ function getRuntimeCacheScope(opts) {
453
+ if (hasExplicitOptionBasedir(opts)) return { caller: void 0 };
454
+ const runtimeScope = {
455
+ caller: void 0,
456
+ cwd: node_process.default.cwd(),
457
+ init_cwd: node_process.default.env["INIT_CWD"],
458
+ npm_config_local_prefix: node_process.default.env["npm_config_local_prefix"],
459
+ npm_package_json: node_process.default.env["npm_package_json"],
460
+ pnpm_package_name: node_process.default.env["PNPM_PACKAGE_NAME"],
461
+ pwd: node_process.default.env["PWD"],
462
+ tailwindcss_base_dir: node_process.default.env["TAILWINDCSS_BASE_DIR"],
463
+ tailwindcss_basedir: node_process.default.env["TAILWINDCSS_BASEDIR"],
464
+ uni_app_input_dir: node_process.default.env["UNI_APP_INPUT_DIR"],
465
+ uni_cli_root: node_process.default.env["UNI_CLI_ROOT"],
466
+ uni_input_dir: node_process.default.env["UNI_INPUT_DIR"],
467
+ uni_input_root: node_process.default.env["UNI_INPUT_ROOT"],
468
+ weapp_tailwindcss_base_dir: node_process.default.env["WEAPP_TAILWINDCSS_BASE_DIR"],
469
+ weapp_tailwindcss_basedir: node_process.default.env["WEAPP_TAILWINDCSS_BASEDIR"]
470
+ };
471
+ if (shouldProbeCallerLocation(opts)) runtimeScope.caller = detectCallerLocation();
472
+ return runtimeScope;
473
+ }
474
+ function serializeNormalizedValue(value) {
475
+ return JSON.stringify(value);
476
+ }
477
+ function createRuntimeCacheScopeKey(opts) {
478
+ return serializeNormalizedValue(normalizeOptionsValue(getRuntimeCacheScope(opts)));
479
+ }
480
+ function getCompilerContextKeyCacheStore(opts) {
481
+ if (!opts) return compilerContextKeyCacheWithoutOptions;
482
+ let store = compilerContextKeyCacheByOptions.get(opts);
483
+ if (!store) {
484
+ store = /* @__PURE__ */ new Map();
485
+ compilerContextKeyCacheByOptions.set(opts, store);
486
+ }
487
+ return store;
488
+ }
489
+ function createComparableNormalizedValue(rawValue, stack) {
490
+ const normalized = normalizeOptionsValue(rawValue, stack);
491
+ return {
492
+ normalized,
493
+ sortKey: serializeNormalizedValue(normalized)
494
+ };
495
+ }
496
+ function getRuntimeCacheScopeValue(opts) {
497
+ return {
498
+ options: opts ?? {},
499
+ runtime: getRuntimeCacheScope(opts)
500
+ };
501
+ }
502
+ function normalizeOptionsValue(rawValue, stack = /* @__PURE__ */ new WeakSet()) {
503
+ if (rawValue === null) return null;
504
+ if (rawValue === void 0) return encodeTaggedValue("Undefined");
505
+ const type = typeof rawValue;
506
+ if (type === "string") return rawValue;
507
+ if (type === "boolean") return rawValue;
508
+ if (type === "number") {
509
+ const numericValue = rawValue;
510
+ if (Number.isNaN(numericValue)) return encodeTaggedValue("Number", "NaN");
511
+ if (!Number.isFinite(numericValue)) return encodeTaggedValue("Number", numericValue > 0 ? "Infinity" : "-Infinity");
512
+ if (Object.is(numericValue, -0)) return encodeTaggedValue("Number", "-0");
513
+ return numericValue;
514
+ }
515
+ if (type === "bigint") return encodeTaggedValue("BigInt", rawValue.toString());
516
+ if (type === "symbol") {
517
+ const symbolValue = rawValue;
518
+ return encodeTaggedValue("Symbol", symbolValue.description ?? String(symbolValue));
519
+ }
520
+ if (type === "function") return encodeTaggedValue("Function", rawValue.toString());
521
+ if (Array.isArray(rawValue)) return withCircularGuard(rawValue, stack, () => rawValue.map((item) => normalizeOptionsValue(item, stack)));
522
+ if (rawValue instanceof Date) return encodeTaggedValue("Date", rawValue.toISOString());
523
+ if (rawValue instanceof RegExp) return {
524
+ __type: "RegExp",
525
+ source: rawValue.source,
526
+ flags: rawValue.flags
527
+ };
528
+ if (typeof node_buffer.Buffer !== "undefined" && node_buffer.Buffer.isBuffer(rawValue)) return encodeTaggedValue("Buffer", rawValue.toString("base64"));
529
+ if (ArrayBuffer.isView(rawValue)) {
530
+ const view = rawValue;
531
+ const buffer = node_buffer.Buffer.from(view.buffer, view.byteOffset, view.byteLength);
532
+ return encodeTaggedValue(view.constructor?.name ?? "ArrayBufferView", buffer.toString("base64"));
533
+ }
534
+ if (rawValue instanceof ArrayBuffer) return encodeTaggedValue("ArrayBuffer", node_buffer.Buffer.from(rawValue).toString("base64"));
535
+ if (rawValue instanceof Set) return withCircularGuard(rawValue, stack, () => {
536
+ const normalizedEntries = Array.from(rawValue, (element) => createComparableNormalizedValue(element, stack));
537
+ normalizedEntries.sort((a, b) => a.sortKey.localeCompare(b.sortKey));
538
+ return {
539
+ __type: "Set",
540
+ value: normalizedEntries.map((entry) => entry.normalized)
541
+ };
542
+ });
543
+ if (rawValue instanceof Map) return withCircularGuard(rawValue, stack, () => {
544
+ const normalizedEntries = Array.from(rawValue.entries(), ([key, entryValue]) => {
545
+ const normalizedKey = createComparableNormalizedValue(key, stack);
546
+ return {
547
+ key: normalizedKey.normalized,
548
+ sortKey: normalizedKey.sortKey,
549
+ value: normalizeOptionsValue(entryValue, stack)
550
+ };
551
+ });
552
+ normalizedEntries.sort((a, b) => a.sortKey.localeCompare(b.sortKey));
553
+ return {
554
+ __type: "Map",
555
+ value: normalizedEntries.map((entry) => [entry.key, entry.value])
556
+ };
557
+ });
558
+ if (typeof URL !== "undefined" && rawValue instanceof URL) return encodeTaggedValue("URL", rawValue.toString());
559
+ if (rawValue instanceof Error) {
560
+ const errorValue = rawValue;
561
+ return {
562
+ __type: "Error",
563
+ name: errorValue.name,
564
+ message: errorValue.message,
565
+ stack: errorValue.stack ?? ""
566
+ };
567
+ }
568
+ if (rawValue instanceof Promise) return encodeTaggedValue("Promise");
569
+ if (rawValue instanceof WeakMap) return encodeTaggedValue("WeakMap");
570
+ if (rawValue instanceof WeakSet) return encodeTaggedValue("WeakSet");
571
+ if (rawValue && typeof rawValue === "object") return withCircularGuard(rawValue, stack, () => {
572
+ const result = {};
573
+ const entries = Object.entries(rawValue);
574
+ entries.sort(([a], [b]) => a.localeCompare(b));
575
+ for (const [key, entryValue] of entries) result[key] = normalizeOptionsValue(entryValue, stack);
576
+ return result;
577
+ });
578
+ return encodeTaggedValue(typeof rawValue, String(rawValue));
579
+ }
580
+ function createCompilerContextCacheKey(opts) {
581
+ try {
582
+ const runtimeCacheScopeKey = createRuntimeCacheScopeKey(opts);
583
+ const keyStore = getCompilerContextKeyCacheStore(opts);
584
+ const cached = keyStore.get(runtimeCacheScopeKey);
585
+ if (cached !== void 0) return cached;
586
+ const cacheKey = (0, _weapp_tailwindcss_shared_node.md5)(serializeNormalizedValue(normalizeOptionsValue(getRuntimeCacheScopeValue(opts))));
587
+ touchMapValue(keyStore, runtimeCacheScopeKey, cacheKey);
588
+ pruneMapToMaxSize(keyStore, resolveCompilerContextCacheMax(DEFAULT_COMPILER_CONTEXT_KEY_CACHE_MAX));
589
+ return cacheKey;
590
+ } catch (error) {
591
+ _weapp_tailwindcss_logger.logger.debug("skip compiler context cache: %O", error);
592
+ return;
593
+ }
594
+ }
595
+ function withCompilerContextCache(opts, factory) {
596
+ const cacheKey = createCompilerContextCacheKey(opts);
597
+ if (cacheKey) {
598
+ const cached = compilerContextCache.get(cacheKey);
599
+ if (cached) {
600
+ touchMapValue(compilerContextCache, cacheKey, cached);
601
+ return cached;
602
+ }
603
+ }
604
+ const ctx = factory();
605
+ if (cacheKey) {
606
+ touchMapValue(compilerContextCache, cacheKey, ctx);
607
+ pruneMapToMaxSize(compilerContextCache, resolveCompilerContextCacheMax(DEFAULT_COMPILER_CONTEXT_CACHE_MAX));
608
+ }
609
+ return ctx;
610
+ }
611
+ //#endregion
612
+ //#region src/context/custom-attributes.ts
613
+ function toCustomAttributesEntities(customAttributes) {
614
+ if (!customAttributes) return [];
615
+ if ((0, _weapp_tailwindcss_shared.isMap)(customAttributes)) return [...customAttributes.entries()];
616
+ return Object.entries(customAttributes);
617
+ }
618
+ //#endregion
619
+ //#region src/js/literal-transform.ts
620
+ function transformLiteralText(literal, options) {
621
+ const fallbackEnabled = require_wxml.shouldEnableArbitraryValueFallback(options);
622
+ if (!options.alwaysEscape && !fallbackEnabled && (!options.classNameSet || options.classNameSet.size === 0)) return;
623
+ const source = options.unescapeUnicode && literal.includes("\\u") ? require_wxml.decodeUnicode2(literal) : literal;
624
+ const candidates = (0, _tailwindcss_mangle_engine.splitCandidateTokens)(source);
625
+ if (candidates.length === 0) return;
626
+ const transformOptions = {
627
+ ...options,
628
+ classContext: true
629
+ };
630
+ const replacementCache = require_wxml.getReplacementCacheStore(options.escapeMap);
631
+ let transformed = source;
632
+ let mutated = false;
633
+ for (const candidate of candidates) {
634
+ const result = require_wxml.resolveClassNameTransformWithResult(candidate, transformOptions);
635
+ if (result.decision === "skip" || !transformed.includes(candidate)) continue;
636
+ const replacement = result.decision === "escaped" && result.escapedValue ? result.escapedValue : require_wxml.getReplacement(candidate, options.escapeMap, replacementCache);
637
+ const replaced = transformed.replace(candidate, replacement);
638
+ if (replaced !== transformed) {
639
+ transformed = replaced;
640
+ mutated = true;
641
+ }
642
+ }
643
+ return mutated ? transformed : void 0;
644
+ }
645
+ //#endregion
646
+ //#region src/js/fast-path/oxc.ts
647
+ const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
648
+ let oxcParser;
649
+ let oxcWalker;
650
+ function isOxcParserRuntimeSupported(version = node_process.default.versions.node) {
651
+ const match = /^(\d+)\.(\d+)(?:\.|$)/.exec(version);
652
+ if (!match) return false;
653
+ const major = Number(match[1]);
654
+ const minor = Number(match[2]);
655
+ if (major === 20) return minor >= 19;
656
+ if (major === 21) return false;
657
+ if (major === 22) return minor >= 12;
658
+ return major > 22;
659
+ }
660
+ function loadOxcParser() {
661
+ if (!isOxcParserRuntimeSupported()) return;
662
+ if (oxcParser === false) return;
663
+ if (oxcParser) return oxcParser;
664
+ try {
665
+ oxcParser = require$1("oxc-parser");
666
+ } catch {
667
+ oxcParser = false;
668
+ return;
669
+ }
670
+ return oxcParser;
671
+ }
672
+ function loadOxcWalker() {
673
+ if (!isOxcParserRuntimeSupported()) return;
674
+ if (oxcWalker === false) return;
675
+ if (oxcWalker) return oxcWalker;
676
+ try {
677
+ oxcWalker = require$1("oxc-walker");
678
+ } catch {
679
+ oxcWalker = false;
680
+ return;
681
+ }
682
+ return oxcWalker;
683
+ }
684
+ function hasValues(values) {
685
+ return Array.isArray(values) && values.length > 0;
686
+ }
687
+ function hasUnsupportedSourceMarker(rawSource) {
688
+ return rawSource.includes("eval(") || rawSource.includes("weapp-tw") && rawSource.includes("ignore");
689
+ }
690
+ function hasSupportedClassMatchSource(options) {
691
+ return options.alwaysEscape === true || Boolean(options.classNameSet && options.classNameSet.size > 0);
692
+ }
693
+ function canUseOxcJsFastPath(options) {
694
+ if (options.experimentalJsFastPath !== true && options.experimentalJsFastPath !== "oxc") return false;
695
+ return !options.generateMap && !options.wrapExpression && !options.moduleGraph && !options.moduleSpecifierReplacements && hasSupportedClassMatchSource(options) && !require_wxml.shouldEnableArbitraryValueFallback(options) && !hasValues(options.ignoreCallExpressionIdentifiers) && !hasValues(options.ignoreTaggedTemplateExpressionIdentifiers);
696
+ }
697
+ function getParserLang(filename) {
698
+ if (filename?.endsWith(".ts") || filename?.endsWith(".mts") || filename?.endsWith(".cts")) return "ts";
699
+ if (filename?.endsWith(".tsx")) return "tsx";
700
+ if (filename?.endsWith(".jsx")) return "jsx";
701
+ return "js";
702
+ }
703
+ function getParserSourceType(sourceType) {
704
+ return sourceType === "script" || sourceType === "module" ? sourceType : "module";
705
+ }
706
+ function isRangeValid(start, end) {
707
+ return typeof start === "number" && typeof end === "number" && start < end;
708
+ }
709
+ function getMagicString(rawSource, context) {
710
+ if (!context.ms) context.ms = new magic_string.default(rawSource);
711
+ return context.ms;
712
+ }
713
+ function addStringLiteralReplacement(rawSource, node, transformOptions, context) {
714
+ if (typeof node.value !== "string" || typeof node.raw !== "string" || !isRangeValid(node.start, node.end)) return false;
715
+ const transformed = transformLiteralText(node.value, transformOptions);
716
+ if (!transformed) return false;
717
+ const start = node.start + 1;
718
+ const end = node.end - 1;
719
+ if (start >= end || transformed === rawSource.slice(start, end)) return false;
720
+ getMagicString(rawSource, context).update(start, end, require_wxml.jsStringEscape(transformed));
721
+ return true;
722
+ }
723
+ function addTemplateElementReplacement(rawSource, node, transformOptions, context) {
724
+ const raw = node.value?.raw;
725
+ if (typeof raw !== "string" || !isRangeValid(node.start, node.end)) return false;
726
+ const transformed = transformLiteralText(raw, transformOptions);
727
+ if (!transformed || transformed === raw) return false;
728
+ const first = rawSource[node.start];
729
+ const last = rawSource[node.end - 1];
730
+ const start = node.start + (first === "`" || first === "}" ? 1 : 0);
731
+ const end = node.end - (last === "`" ? 1 : last === "{" ? 2 : 0);
732
+ if (start >= end) return false;
733
+ getMagicString(rawSource, context).update(start, end, transformed);
734
+ return true;
735
+ }
736
+ function applyReplacements(rawSource, program, walker, stringLiteralOptions, templateLiteralOptions, context) {
737
+ let changed = false;
738
+ walker.walk(program, { enter(node) {
739
+ if (node.type === "Literal") {
740
+ changed = addStringLiteralReplacement(rawSource, node, stringLiteralOptions, context) || changed;
741
+ return;
742
+ }
743
+ if (node.type === "TemplateElement") {
744
+ changed = addTemplateElementReplacement(rawSource, node, templateLiteralOptions, context) || changed;
745
+ this.skip();
746
+ }
747
+ } });
748
+ return changed;
749
+ }
750
+ function oxcJsHandler(rawSource, options) {
751
+ if (!canUseOxcJsFastPath(options)) return;
752
+ if (hasUnsupportedSourceMarker(rawSource)) return;
753
+ const parser = loadOxcParser();
754
+ const walker = loadOxcWalker();
755
+ if (!parser || !walker) return;
756
+ let result;
757
+ try {
758
+ result = parser.parseSync(options.filename ?? "weapp-tailwindcss.js", rawSource, {
759
+ sourceType: getParserSourceType(options.babelParserOptions?.sourceType),
760
+ lang: getParserLang(options.filename)
761
+ });
762
+ } catch {
763
+ return;
764
+ }
765
+ if (!result.program || Array.isArray(result.errors) && result.errors.length > 0) return;
766
+ const stringLiteralOptions = options.needEscaped === true ? options : {
767
+ ...options,
768
+ needEscaped: true
769
+ };
770
+ const templateLiteralOptions = options.needEscaped === false ? options : {
771
+ ...options,
772
+ needEscaped: false
773
+ };
774
+ const replacementContext = {};
775
+ if (!applyReplacements(rawSource, result.program, walker, stringLiteralOptions, templateLiteralOptions, replacementContext)) return { code: rawSource };
776
+ return { code: replacementContext.ms.toString() };
777
+ }
778
+ //#endregion
779
+ //#region src/js/precheck.ts
780
+ /** 用于检测源码中是否包含类名相关模式的正则表达式 */
781
+ 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)-/;
782
+ /** 用于检测源码中是否包含 import/export/require 语句的正则表达式 */
783
+ const DEPENDENCY_HINT_RE = /\bimport\s*[("'`{*]|\brequire\s*\(|\bexport\s+\*\s+from\s+["'`]|\bexport\s*\{[^}]*\}\s*from\s+["'`]/;
784
+ /**
785
+ * 判断源码是否可能声明跨模块依赖。
786
+ *
787
+ * 该检查只作为性能预筛:返回 `true` 时必须保守走 AST 模块图分析;
788
+ * 返回 `false` 时源码中没有可被当前模块图消费的静态 import/export/require 形态。
789
+ */
790
+ function hasDependencyHint(rawSource) {
791
+ return DEPENDENCY_HINT_RE.test(rawSource);
792
+ }
793
+ /**
794
+ * 判断是否可以跳过 JS 转换。
795
+ * 通过正则快速检测源码内容,避免不必要的 Babel AST 解析。
796
+ *
797
+ * @param rawSource - 原始 JS 源码字符串
798
+ * @param options - 可选的 JS 处理器配置选项
799
+ * @returns 如果可以跳过转换返回 `true`,否则返回 `false`
800
+ */
801
+ function shouldSkipJsTransform(rawSource, options) {
802
+ if (node_process.default.env["WEAPP_TW_DISABLE_JS_PRECHECK"] === "1") return false;
803
+ if (!rawSource) return true;
804
+ if (options?.alwaysEscape) return false;
805
+ if (options?.moduleSpecifierReplacements && Object.keys(options.moduleSpecifierReplacements).length > 0) return false;
806
+ if (options?.wrapExpression) return false;
807
+ if (hasDependencyHint(rawSource)) return false;
808
+ return !FAST_JS_TRANSFORM_HINT_RE.test(rawSource);
809
+ }
810
+ //#endregion
811
+ //#region src/js/index.ts
812
+ /** 默认 LRU 缓存最大条目数 */
813
+ const RESULT_CACHE_MAX = 512;
814
+ /** 仅对短片段做内层结果缓存,避免 bundler 热路径重复 hash 大块 JS。 */
815
+ const CACHEABLE_SOURCE_MAX_LENGTH = 512;
816
+ /** 为每个 ClassNameSet 实例分配递增 ID */
817
+ const classNameSetIds = /* @__PURE__ */ new WeakMap();
818
+ let nextClassNameSetId = 0;
819
+ /**
820
+ * 获取 ClassNameSet 的唯一身份 ID。
821
+ * 每个 Set 引用分配一个递增整数,用于指纹计算。
822
+ */
823
+ function getClassNameSetId(set) {
824
+ if (!set) return "none";
825
+ const existing = classNameSetIds.get(set);
826
+ if (existing !== void 0) return String(existing);
827
+ const id = nextClassNameSetId++;
828
+ classNameSetIds.set(set, id);
829
+ return String(id);
830
+ }
831
+ /** 缓存 IJsHandlerOptions -> fingerprint 的映射 */
832
+ const fingerprintCache = /* @__PURE__ */ new WeakMap();
833
+ /**
834
+ * 计算选项指纹,包含所有影响转译结果的字段。
835
+ * 不包含 filename、moduleGraph、jsPreserveClass。
836
+ */
837
+ function getOptionsFingerprint(options) {
838
+ const cached = fingerprintCache.get(options);
839
+ if (cached) return cached;
840
+ const fingerprint = [
841
+ getClassNameSetId(options.classNameSet),
842
+ JSON.stringify(options.escapeMap ?? null),
843
+ options.needEscaped ? "1" : "0",
844
+ options.alwaysEscape ? "1" : "0",
845
+ options.unescapeUnicode ? "1" : "0",
846
+ options.generateMap ? "1" : "0",
847
+ options.uniAppX ? "1" : "0",
848
+ options.wrapExpression ? "1" : "0",
849
+ String(options.tailwindcssMajorVersion ?? ""),
850
+ String(options.jsArbitraryValueFallback ?? ""),
851
+ JSON.stringify(options.arbitraryValues ?? null),
852
+ JSON.stringify(options.ignoreCallExpressionIdentifiers ?? null),
853
+ JSON.stringify(options.ignoreTaggedTemplateExpressionIdentifiers?.map((v) => v instanceof RegExp ? v.source : v) ?? null),
854
+ JSON.stringify(options.moduleSpecifierReplacements ?? null),
855
+ String(options.experimentalJsFastPath ?? ""),
856
+ JSON.stringify(options.babelParserOptions ?? null)
857
+ ].join("|");
858
+ fingerprintCache.set(options, fingerprint);
859
+ return fingerprint;
860
+ }
861
+ function hasDefinedOverrides(options) {
862
+ if (!options) return false;
863
+ for (const key in options) if (options[key] !== void 0) return true;
864
+ return false;
865
+ }
866
+ function shouldCacheJsResult(rawSource, options) {
867
+ if (rawSource.length === 0 || rawSource.length > CACHEABLE_SOURCE_MAX_LENGTH) return false;
868
+ if (options.moduleGraph || options.filename) return false;
869
+ return true;
870
+ }
871
+ function resolveFastPathOptions(rawSource, options) {
872
+ if (!options.moduleGraph) return options;
873
+ if (options.moduleSpecifierReplacements && Object.keys(options.moduleSpecifierReplacements).length > 0) return options;
874
+ if (hasDependencyHint(rawSource)) return options;
875
+ const { moduleGraph: _moduleGraph, ...fastPathOptions } = options;
876
+ return fastPathOptions;
877
+ }
878
+ function createJsHandler(options) {
879
+ const defaults = {
880
+ escapeMap: options.escapeMap,
881
+ jsArbitraryValueFallback: options.jsArbitraryValueFallback,
882
+ tailwindcssMajorVersion: options.tailwindcssMajorVersion,
883
+ arbitraryValues: options.arbitraryValues,
884
+ jsPreserveClass: options.jsPreserveClass,
885
+ generateMap: options.generateMap,
886
+ needEscaped: options.needEscaped,
887
+ alwaysEscape: options.alwaysEscape,
888
+ unescapeUnicode: options.unescapeUnicode,
889
+ babelParserOptions: options.babelParserOptions,
890
+ experimentalJsFastPath: options.experimentalJsFastPath,
891
+ ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers,
892
+ ignoreTaggedTemplateExpressionIdentifiers: options.ignoreTaggedTemplateExpressionIdentifiers,
893
+ uniAppX: options.uniAppX,
894
+ moduleSpecifierReplacements: options.moduleSpecifierReplacements
895
+ };
896
+ /** 层1: 无 override 时,classNameSet -> resolvedOptions */
897
+ const defaultOptionsCache = /* @__PURE__ */ new WeakMap();
898
+ let resolvedOptionsWithoutClassNameSet;
899
+ /** 层2: 有 override 时,overrideOptions -> { bySet, noSet } */
900
+ const overrideOptionsCache = /* @__PURE__ */ new WeakMap();
901
+ const resultCache = new lru_cache.LRUCache({ max: RESULT_CACHE_MAX });
902
+ function resolveDefaultOptions(classNameSet) {
903
+ if (!classNameSet) {
904
+ if (!resolvedOptionsWithoutClassNameSet) resolvedOptionsWithoutClassNameSet = {
905
+ ...defaults,
906
+ classNameSet
907
+ };
908
+ return resolvedOptionsWithoutClassNameSet;
909
+ }
910
+ const cached = defaultOptionsCache.get(classNameSet);
911
+ if (cached) return cached;
912
+ const created = {
913
+ ...defaults,
914
+ classNameSet
915
+ };
916
+ defaultOptionsCache.set(classNameSet, created);
917
+ return created;
918
+ }
919
+ function getCachedJsResult(rawSource, resolvedOptions) {
920
+ if (!shouldCacheJsResult(rawSource, resolvedOptions)) return;
921
+ const key = `${getOptionsFingerprint(resolvedOptions)}:${(0, _weapp_tailwindcss_shared_node.md5)(rawSource)}`;
922
+ return resultCache.get(key);
923
+ }
924
+ function setCachedJsResult(rawSource, resolvedOptions, result) {
925
+ if (!shouldCacheJsResult(rawSource, resolvedOptions) || result.error || result.linked) return result;
926
+ const key = `${getOptionsFingerprint(resolvedOptions)}:${(0, _weapp_tailwindcss_shared_node.md5)(rawSource)}`;
927
+ resultCache.set(key, result);
928
+ return result;
929
+ }
930
+ function resolveOptions(classNameSet, overrideOptions) {
931
+ if (!hasDefinedOverrides(overrideOptions)) return resolveDefaultOptions(classNameSet);
932
+ let entry = overrideOptionsCache.get(overrideOptions);
933
+ if (!entry) {
934
+ entry = { bySet: /* @__PURE__ */ new WeakMap() };
935
+ overrideOptionsCache.set(overrideOptions, entry);
936
+ }
937
+ if (!classNameSet) {
938
+ if (entry.noSet) return entry.noSet;
939
+ const created = (0, _weapp_tailwindcss_shared.defuOverrideArray)({
940
+ ...overrideOptions,
941
+ classNameSet
942
+ }, defaults);
943
+ entry.noSet = created;
944
+ return created;
945
+ }
946
+ const cached = entry.bySet.get(classNameSet);
947
+ if (cached) return cached;
948
+ const created = (0, _weapp_tailwindcss_shared.defuOverrideArray)({
949
+ ...overrideOptions,
950
+ classNameSet
951
+ }, defaults);
952
+ entry.bySet.set(classNameSet, created);
953
+ return created;
954
+ }
955
+ function handler(rawSource, classNameSet, options) {
956
+ const resolvedOptions = resolveOptions(classNameSet, options);
957
+ const cached = getCachedJsResult(rawSource, resolvedOptions);
958
+ if (cached) return cached;
959
+ return setCachedJsResult(rawSource, resolvedOptions, oxcJsHandler(rawSource, resolveFastPathOptions(rawSource, resolvedOptions)) ?? require_wxml.jsHandler(rawSource, resolvedOptions));
960
+ }
961
+ return handler;
962
+ }
963
+ //#endregion
964
+ //#region src/constants.ts
965
+ const pluginName = "weapp-tailwindcss";
966
+ const vitePluginName = "weapp-tailwindcss:adaptor";
967
+ const DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
968
+ "tailwind-merge": "@weapp-tailwindcss/merge",
969
+ "class-variance-authority": "@weapp-tailwindcss/cva",
970
+ "tailwind-variants": "@weapp-tailwindcss/variants"
971
+ };
972
+ //#endregion
973
+ //#region src/context/runtime-package-replacements.ts
974
+ function resolveRuntimePackageReplacements(option) {
975
+ const mapping = require_generator.resolveBooleanObjectOption(option, DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS);
976
+ if (!mapping) return;
977
+ const normalized = {};
978
+ for (const [from, to] of Object.entries(mapping)) {
979
+ if (!from || typeof to !== "string" || to.length === 0) continue;
980
+ normalized[from] = to;
981
+ }
982
+ return Object.keys(normalized).length > 0 ? normalized : void 0;
983
+ }
984
+ //#endregion
985
+ //#region src/context/style-options.ts
986
+ function normalizeStyleHandlerMajorVersion(majorVersion) {
987
+ return majorVersion === 4 ? 4 : void 0;
988
+ }
989
+ function resolveStyleOptionsFromContext(ctx, tailwindcssMajorVersion) {
990
+ const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(ctx.uniAppX);
991
+ const branch = require_generator.resolveGeneratorRuntimeBranch(require_generator.normalizeWeappTailwindcssGeneratorOptions(ctx.generator, {
992
+ appType: ctx.appType,
993
+ platform: ctx.cssOptions?.platform ?? ctx.platform,
994
+ tailwindcssMajorVersion,
995
+ uniAppX: resolvedUniAppXOptions
996
+ }), {
997
+ appType: ctx.appType,
998
+ platform: ctx.cssOptions?.platform ?? ctx.platform,
999
+ tailwindcssMajorVersion,
1000
+ uniAppX: resolvedUniAppXOptions
1001
+ });
1002
+ const hasCssOptions = ctx.cssOptions !== void 0;
1003
+ const cssOptions = {
1004
+ cssPreflight: ctx.cssOptions?.cssPreflight ?? ctx.cssPreflight,
1005
+ cssPreflightRange: ctx.cssOptions?.cssPreflightRange ?? ctx.cssPreflightRange,
1006
+ cssChildCombinatorReplaceValue: ctx.cssOptions?.cssChildCombinatorReplaceValue ?? ctx.cssChildCombinatorReplaceValue,
1007
+ cssSelectorReplacement: ctx.cssOptions?.cssSelectorReplacement ?? ctx.cssSelectorReplacement,
1008
+ rem2rpx: ctx.cssOptions?.rem2rpx ?? ctx.rem2rpx,
1009
+ cssRemoveProperty: ctx.cssOptions?.cssRemoveProperty ?? ctx.cssRemoveProperty,
1010
+ cssRemoveHoverPseudoClass: ctx.cssOptions?.cssRemoveHoverPseudoClass ?? ctx.cssRemoveHoverPseudoClass,
1011
+ tailwindcssV4GradientFallback: ctx.cssOptions?.tailwindcssV4GradientFallback ?? ctx.tailwindcssV4GradientFallback,
1012
+ cssPresetEnv: ctx.cssOptions?.cssPresetEnv ?? ctx.cssPresetEnv,
1013
+ atRules: ctx.cssOptions?.atRules ?? ctx.atRules,
1014
+ autoprefixer: ctx.cssOptions?.autoprefixer ?? ctx.autoprefixer,
1015
+ cssCalc: ctx.cssOptions?.cssCalc ?? ctx.cssCalc,
1016
+ platform: branch.platform ?? ctx.cssOptions?.platform ?? ctx.platform,
1017
+ px2rpx: ctx.cssOptions?.px2rpx ?? ctx.px2rpx,
1018
+ unitsToPx: ctx.cssOptions?.unitsToPx ?? ctx.unitsToPx,
1019
+ unitConversion: ctx.cssOptions?.unitConversion ?? ctx.unitConversion,
1020
+ injectAdditionalCssVarScope: ctx.cssOptions?.injectAdditionalCssVarScope ?? ctx.injectAdditionalCssVarScope
1021
+ };
1022
+ return {
1023
+ appType: ctx.appType,
1024
+ postcssOptions: ctx.postcssOptions,
1025
+ cssPreflight: cssOptions.cssPreflight,
1026
+ cssPreflightRange: cssOptions.cssPreflightRange,
1027
+ cssChildCombinatorReplaceValue: cssOptions.cssChildCombinatorReplaceValue,
1028
+ cssSelectorReplacement: cssOptions.cssSelectorReplacement,
1029
+ rem2rpx: cssOptions.rem2rpx,
1030
+ ...hasCssOptions ? { cssOptions } : {},
1031
+ cssRemoveProperty: cssOptions.cssRemoveProperty,
1032
+ cssRemoveHoverPseudoClass: cssOptions.cssRemoveHoverPseudoClass,
1033
+ tailwindcssV4GradientFallback: cssOptions.tailwindcssV4GradientFallback,
1034
+ cssPresetEnv: cssOptions.cssPresetEnv,
1035
+ atRules: cssOptions.atRules,
1036
+ autoprefixer: cssOptions.autoprefixer,
1037
+ cssCalc: cssOptions.cssCalc,
1038
+ uniAppX: branch.isNativeApp,
1039
+ platform: cssOptions.platform,
1040
+ px2rpx: cssOptions.px2rpx,
1041
+ unitsToPx: cssOptions.unitsToPx,
1042
+ unitConversion: cssOptions.unitConversion
1043
+ };
1044
+ }
1045
+ //#endregion
1046
+ //#region src/context/handlers.ts
1047
+ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions, tailwindcssMajorVersion) {
1048
+ const { escapeMap, injectAdditionalCssVarScope, postcssOptions, uniAppX, arbitraryValues, jsPreserveClass, jsArbitraryValueFallback, babelParserOptions, experimentalJsFastPath, ignoreCallExpressionIdentifiers, ignoreTaggedTemplateExpressionIdentifiers, inlineWxs, disabledDefaultTemplateHandler, replaceRuntimePackages } = ctx;
1049
+ const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(uniAppX);
1050
+ const styleOptions = resolveStyleOptionsFromContext(ctx, tailwindcssMajorVersion);
1051
+ const resolvedInjectAdditionalCssVarScope = styleOptions.cssOptions?.injectAdditionalCssVarScope ?? injectAdditionalCssVarScope;
1052
+ const uniAppXEnabled = styleOptions.uniAppX === true;
1053
+ const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
1054
+ const styleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
1055
+ ...styleOptions,
1056
+ escapeMap,
1057
+ injectAdditionalCssVarScope: resolvedInjectAdditionalCssVarScope,
1058
+ postcssOptions,
1059
+ uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
1060
+ cssCalc: cssCalcOptions,
1061
+ majorVersion: normalizeStyleHandlerMajorVersion(tailwindcssMajorVersion)
1062
+ });
1063
+ const jsHandler = createJsHandler({
1064
+ escapeMap,
1065
+ arbitraryValues,
1066
+ jsPreserveClass,
1067
+ jsArbitraryValueFallback: jsArbitraryValueFallback ?? "auto",
1068
+ tailwindcssMajorVersion,
1069
+ generateMap: true,
1070
+ babelParserOptions,
1071
+ experimentalJsFastPath,
1072
+ ignoreCallExpressionIdentifiers,
1073
+ ignoreTaggedTemplateExpressionIdentifiers,
1074
+ uniAppX: uniAppXEnabled,
1075
+ moduleSpecifierReplacements
1076
+ });
1077
+ return {
1078
+ styleHandler,
1079
+ jsHandler,
1080
+ templateHandler: require_wxml.createTemplateHandler({
1081
+ customAttributesEntities,
1082
+ escapeMap,
1083
+ inlineWxs,
1084
+ jsHandler,
1085
+ disabledDefaultTemplateHandler
1086
+ })
1087
+ };
1088
+ }
1089
+ //#endregion
1090
+ //#region src/context/logger.ts
1091
+ const loggerLevelMap = {
1092
+ error: 0,
1093
+ warn: 1,
1094
+ info: 3,
1095
+ silent: -999
1096
+ };
1097
+ function applyLoggerLevel(logLevel) {
1098
+ _weapp_tailwindcss_logger.logger.level = loggerLevelMap[logLevel ?? "info"] ?? loggerLevelMap.info;
1099
+ }
1100
+ //#endregion
1101
+ //#region src/context/index.ts
1102
+ function resolveContextCssPreflight(opts, ctx, majorVersion) {
1103
+ const userCssPreflight = opts?.cssOptions?.cssPreflight ?? opts?.cssPreflight;
1104
+ const cssPreflight = require_defaults.resolveDefaultCssPreflight(userCssPreflight, majorVersion);
1105
+ const shouldUseUniAppXPreflight = ctx.appType === "uni-app-x" || require_tailwindcss.resolveUniAppXOptions(ctx.uniAppX).enabled;
1106
+ if (cssPreflight === false || !shouldUseUniAppXPreflight) return cssPreflight;
1107
+ const userCssPreflightObject = userCssPreflight && typeof userCssPreflight === "object" ? userCssPreflight : void 0;
1108
+ return {
1109
+ ...cssPreflight,
1110
+ "border-width": userCssPreflightObject && "border-width" in userCssPreflightObject ? cssPreflight["border-width"] ?? false : "0",
1111
+ "border-style": userCssPreflightObject && "border-style" in userCssPreflightObject ? cssPreflight["border-style"] ?? false : false,
1112
+ "border": userCssPreflightObject && "border" in userCssPreflightObject ? cssPreflight["border"] ?? false : false
1113
+ };
1114
+ }
1115
+ function syncCssOptionsToLegacyFields(ctx) {
1116
+ if (!ctx.cssOptions) return;
1117
+ const cssOptions = ctx.cssOptions;
1118
+ ctx.cssPreflight = cssOptions.cssPreflight ?? ctx.cssPreflight;
1119
+ ctx.cssPreflightRange = cssOptions.cssPreflightRange ?? ctx.cssPreflightRange;
1120
+ ctx.cssChildCombinatorReplaceValue = cssOptions.cssChildCombinatorReplaceValue ?? ctx.cssChildCombinatorReplaceValue;
1121
+ ctx.cssSelectorReplacement = cssOptions.cssSelectorReplacement ?? ctx.cssSelectorReplacement;
1122
+ ctx.rem2rpx = cssOptions.rem2rpx ?? ctx.rem2rpx;
1123
+ ctx.cssRemoveProperty = cssOptions.cssRemoveProperty ?? ctx.cssRemoveProperty;
1124
+ ctx.cssRemoveHoverPseudoClass = cssOptions.cssRemoveHoverPseudoClass ?? ctx.cssRemoveHoverPseudoClass;
1125
+ ctx.tailwindcssV4GradientFallback = cssOptions.tailwindcssV4GradientFallback ?? ctx.tailwindcssV4GradientFallback;
1126
+ ctx.cssPresetEnv = cssOptions.cssPresetEnv ?? ctx.cssPresetEnv;
1127
+ ctx.atRules = cssOptions.atRules ?? ctx.atRules;
1128
+ ctx.autoprefixer = cssOptions.autoprefixer ?? ctx.autoprefixer;
1129
+ ctx.cssCalc = cssOptions.cssCalc ?? ctx.cssCalc;
1130
+ ctx.platform = cssOptions.platform ?? ctx.platform;
1131
+ ctx.px2rpx = cssOptions.px2rpx ?? ctx.px2rpx;
1132
+ ctx.unitsToPx = cssOptions.unitsToPx ?? ctx.unitsToPx;
1133
+ ctx.unitConversion = cssOptions.unitConversion ?? ctx.unitConversion;
1134
+ ctx.injectAdditionalCssVarScope = cssOptions.injectAdditionalCssVarScope ?? ctx.injectAdditionalCssVarScope;
1135
+ }
1136
+ function syncLegacyFieldsToCssOptions(ctx) {
1137
+ if (!ctx.cssOptions) return;
1138
+ ctx.cssOptions = {
1139
+ ...ctx.cssOptions ?? {},
1140
+ cssPreflight: ctx.cssPreflight,
1141
+ cssPreflightRange: ctx.cssPreflightRange,
1142
+ cssChildCombinatorReplaceValue: ctx.cssChildCombinatorReplaceValue,
1143
+ cssSelectorReplacement: ctx.cssSelectorReplacement,
1144
+ rem2rpx: ctx.rem2rpx,
1145
+ cssRemoveProperty: ctx.cssRemoveProperty,
1146
+ cssRemoveHoverPseudoClass: ctx.cssRemoveHoverPseudoClass,
1147
+ tailwindcssV4GradientFallback: ctx.tailwindcssV4GradientFallback,
1148
+ cssPresetEnv: ctx.cssPresetEnv,
1149
+ atRules: ctx.atRules,
1150
+ autoprefixer: ctx.autoprefixer,
1151
+ cssCalc: ctx.cssCalc,
1152
+ platform: ctx.platform,
1153
+ px2rpx: ctx.px2rpx,
1154
+ unitsToPx: ctx.unitsToPx,
1155
+ unitConversion: ctx.unitConversion,
1156
+ injectAdditionalCssVarScope: ctx.injectAdditionalCssVarScope
1157
+ };
1158
+ }
1159
+ function applyFrameworkPlatformDefaults(ctx) {
1160
+ if (ctx.cssOptions?.platform || ctx.platform) {
1161
+ ctx.platform = normalizeFrameworkStylePlatform(ctx.cssOptions?.platform ?? ctx.platform, ctx.appType);
1162
+ return;
1163
+ }
1164
+ if (ctx.appType === "mpx") ctx.platform = normalizeFrameworkStylePlatform(require_framework.resolveMpxPlatform().normalized, ctx.appType);
1165
+ }
1166
+ async function clearTailwindcssRuntimeCache(tailwindRuntime, options) {
1167
+ if (!tailwindRuntime) return;
1168
+ const cacheOptions = tailwindRuntime.options?.cache;
1169
+ if (cacheOptions == null || typeof cacheOptions === "object" && cacheOptions.enabled === false) return;
1170
+ if (typeof tailwindRuntime.clearCache === "function") try {
1171
+ await tailwindRuntime.clearCache({ scope: "all" });
1172
+ } catch (error) {
1173
+ _weapp_tailwindcss_logger.logger.debug("failed to clear tailwindcss runtime cache via clearCache(): %O", error);
1174
+ }
1175
+ if (!options?.removeDirectory) return;
1176
+ const cachePaths = /* @__PURE__ */ new Map();
1177
+ const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
1178
+ const privateCachePath = tailwindRuntime?.cacheStore?.options?.path;
1179
+ if (privateCachePath) cachePaths.set(privateCachePath, false);
1180
+ if (normalizedCacheOptions?.path) cachePaths.set(normalizedCacheOptions.path, false);
1181
+ if (options?.removeDirectory && normalizedCacheOptions?.dir) cachePaths.set(normalizedCacheOptions.dir, true);
1182
+ if (!cachePaths.size) return;
1183
+ for (const [cachePath, recursive] of cachePaths.entries()) try {
1184
+ await (0, node_fs_promises.rm)(cachePath, {
1185
+ force: true,
1186
+ recursive
1187
+ });
1188
+ } catch (error) {
1189
+ const err = error;
1190
+ if (err?.code === "ENOENT") continue;
1191
+ _weapp_tailwindcss_logger.logger.debug("failed to clear tailwindcss runtime cache: %s %O", cachePath, err);
1192
+ }
1193
+ }
1194
+ function createInternalCompilerContext(opts) {
1195
+ const ctx = (0, _weapp_tailwindcss_shared.defuOverrideArray)(opts, require_defaults.getDefaultOptions(), {});
1196
+ ctx.arbitraryValues = resolveUnocssBareArbitraryValues(ctx.arbitraryValues, ctx.unocss);
1197
+ ctx.escapeMap = ctx.customReplaceDictionary;
1198
+ syncCssOptionsToLegacyFields(ctx);
1199
+ applyFrameworkPlatformDefaults(ctx);
1200
+ applyLoggerLevel(ctx.logLevel);
1201
+ const tailwindRuntime = require_tailwindcss.createTailwindcssRuntimeFromContext(ctx);
1202
+ logTailwindcssTarget(tailwindRuntime, ctx.tailwindcssBasedir);
1203
+ logRuntimeTailwindcssVersion(ctx.tailwindcssBasedir, tailwindRuntime.packageInfo?.rootPath, tailwindRuntime.packageInfo?.version);
1204
+ if (opts?.__internalDeferMissingCssEntriesWarning !== true) require_tailwindcss.warnMissingCssEntries(ctx, tailwindRuntime);
1205
+ ctx.cssPreflight = resolveContextCssPreflight(opts, ctx, tailwindRuntime.majorVersion);
1206
+ const cssCalcOptions = require_tailwindcss.applyV4CssCalcDefaults(ctx.cssCalc, tailwindRuntime);
1207
+ ctx.cssCalc = cssCalcOptions;
1208
+ syncLegacyFieldsToCssOptions(ctx);
1209
+ const { styleHandler, jsHandler, templateHandler } = createHandlersFromContext(ctx, toCustomAttributesEntities(ctx.customAttributes), cssCalcOptions, tailwindRuntime.majorVersion);
1210
+ ctx.styleHandler = styleHandler;
1211
+ ctx.jsHandler = jsHandler;
1212
+ ctx.templateHandler = templateHandler;
1213
+ ctx.cache = initializeCache(ctx.cache);
1214
+ ctx.tailwindRuntime = tailwindRuntime;
1215
+ const refreshTailwindcssRuntime = async (options) => {
1216
+ const previousRuntime = ctx.tailwindRuntime;
1217
+ if (options?.clearCache !== false) await clearTailwindcssRuntimeCache(previousRuntime);
1218
+ require_tailwindcss.invalidateRuntimeClassSet(previousRuntime);
1219
+ const nextRuntime = require_tailwindcss.createTailwindcssRuntimeFromContext(ctx);
1220
+ Object.assign(previousRuntime, nextRuntime);
1221
+ ctx.tailwindRuntime = previousRuntime;
1222
+ return previousRuntime;
1223
+ };
1224
+ ctx.refreshTailwindcssRuntime = refreshTailwindcssRuntime;
1225
+ Object.defineProperty(ctx.tailwindRuntime, refreshTailwindcssRuntimeSymbol, {
1226
+ value: refreshTailwindcssRuntime,
1227
+ configurable: true
1228
+ });
1229
+ return ctx;
1230
+ }
1231
+ /**
1232
+ * 获取用户定义选项的内部表示,并初始化相关的处理程序和 Tailwind 运行时。
1233
+ * @param opts - 用户定义的选项,可选。
1234
+ * @returns 返回一个包含内部用户定义选项的对象,包括样式、JS 和模板处理程序,以及 Tailwind CSS 运行时。
1235
+ */
1236
+ function getCompilerContext(opts) {
1237
+ return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
1238
+ }
1239
+ //#endregion
1240
+ Object.defineProperty(exports, "collectRuntimeClassSet", {
1241
+ enumerable: true,
1242
+ get: function() {
1243
+ return collectRuntimeClassSet;
1244
+ }
1245
+ });
1246
+ Object.defineProperty(exports, "createTailwindRuntimeReadyPromise", {
1247
+ enumerable: true,
1248
+ get: function() {
1249
+ return createTailwindRuntimeReadyPromise;
1250
+ }
1251
+ });
1252
+ Object.defineProperty(exports, "ensureRuntimeClassSet", {
1253
+ enumerable: true,
1254
+ get: function() {
1255
+ return ensureRuntimeClassSet;
1256
+ }
1257
+ });
1258
+ Object.defineProperty(exports, "getCompilerContext", {
1259
+ enumerable: true,
1260
+ get: function() {
1261
+ return getCompilerContext;
1262
+ }
1263
+ });
1264
+ Object.defineProperty(exports, "normalizeFrameworkStylePlatform", {
1265
+ enumerable: true,
1266
+ get: function() {
1267
+ return normalizeFrameworkStylePlatform;
1268
+ }
1269
+ });
1270
+ Object.defineProperty(exports, "normalizeStyleHandlerMajorVersion", {
1271
+ enumerable: true,
1272
+ get: function() {
1273
+ return normalizeStyleHandlerMajorVersion;
1274
+ }
1275
+ });
1276
+ Object.defineProperty(exports, "pluginName", {
1277
+ enumerable: true,
1278
+ get: function() {
1279
+ return pluginName;
1280
+ }
1281
+ });
1282
+ Object.defineProperty(exports, "refreshTailwindRuntimeState", {
1283
+ enumerable: true,
1284
+ get: function() {
1285
+ return refreshTailwindRuntimeState;
1286
+ }
1287
+ });
1288
+ Object.defineProperty(exports, "resolveStyleOptionsFromContext", {
1289
+ enumerable: true,
1290
+ get: function() {
1291
+ return resolveStyleOptionsFromContext;
1292
+ }
1293
+ });
1294
+ Object.defineProperty(exports, "shouldSkipJsTransform", {
1295
+ enumerable: true,
1296
+ get: function() {
1297
+ return shouldSkipJsTransform;
1298
+ }
1299
+ });
1300
+ Object.defineProperty(exports, "toCustomAttributesEntities", {
1301
+ enumerable: true,
1302
+ get: function() {
1303
+ return toCustomAttributesEntities;
1304
+ }
1305
+ });
1306
+ Object.defineProperty(exports, "vitePluginName", {
1307
+ enumerable: true,
1308
+ get: function() {
1309
+ return vitePluginName;
1310
+ }
1311
+ });