weapp-tailwindcss 5.0.12 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/auto-Ba6hDrse.mjs +13 -0
  4. package/dist/auto-DtU6f3X6.js +18 -0
  5. package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
  6. package/dist/bundlers/shared/generator-css/directives.d.ts +2 -1
  7. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +27 -10
  8. package/dist/bundlers/shared/generator-css/local-imports.d.ts +3 -0
  9. package/dist/bundlers/shared/generator-css/source-files.d.ts +1 -0
  10. package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +6 -0
  11. package/dist/bundlers/shared/generator-css/source-resolver/config.d.ts +7 -0
  12. package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +3 -0
  13. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +15 -0
  14. package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +12 -0
  15. package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +22 -0
  16. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +6 -23
  17. package/dist/bundlers/shared/generator-css/types.d.ts +15 -1
  18. package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -1
  19. package/dist/bundlers/shared/generator-css/validate.d.ts +1 -0
  20. package/dist/bundlers/shared/run-tasks.d.ts +1 -0
  21. package/dist/bundlers/shared/v4-generation-core.d.ts +11 -0
  22. package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
  23. package/dist/bundlers/vite/css-memory.d.ts +37 -0
  24. package/dist/bundlers/vite/generate-bundle/bundle-file-names.d.ts +2 -0
  25. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +0 -1
  26. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +8 -0
  27. package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +4 -0
  28. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -0
  29. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +9 -7
  30. package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +6 -0
  31. package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +12 -0
  32. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +63 -0
  33. package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +31 -0
  34. package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +80 -0
  35. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +53 -0
  36. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
  37. package/dist/bundlers/vite/generate-bundle/runtime-linked-css.d.ts +4 -0
  38. package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +21 -0
  39. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +5 -2
  40. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +30 -0
  41. package/dist/bundlers/vite/generate-bundle/timing.d.ts +1 -0
  42. package/dist/bundlers/vite/generate-bundle/types.d.ts +3 -1
  43. package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +20 -0
  44. package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +6 -0
  45. package/dist/bundlers/vite/generate-bundle.d.ts +4 -1
  46. package/dist/bundlers/vite/hot-css-modules.d.ts +5 -0
  47. package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -0
  48. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +3 -3
  49. package/dist/bundlers/vite/map-cache.d.ts +2 -0
  50. package/dist/bundlers/vite/processed-css-assets.d.ts +16 -0
  51. package/dist/bundlers/vite/resolve-app-type.d.ts +1 -2
  52. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  53. package/dist/bundlers/vite/runtime-class-set.d.ts +5 -5
  54. package/dist/bundlers/vite/source-candidate-scan-signature.d.ts +13 -0
  55. package/dist/bundlers/vite/source-candidates/script.d.ts +1 -7
  56. package/dist/bundlers/vite/source-candidates.d.ts +12 -2
  57. package/dist/bundlers/vite/source-scan/css-entries.d.ts +3 -6
  58. package/dist/bundlers/vite/source-scan.d.ts +3 -3
  59. package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
  60. package/dist/bundlers/vite/utils.d.ts +1 -0
  61. package/dist/bundlers/vite/weapp-vite-config.d.ts +3 -1
  62. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +24 -0
  63. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -10
  64. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +28 -0
  65. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +5 -1
  66. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +15 -1
  67. package/dist/bundlers/webpack/shared/css-loader-runtime.d.ts +1 -0
  68. package/dist/cache/index.d.ts +1 -0
  69. package/dist/cli/mount-options.d.ts +2 -2
  70. package/dist/cli.js +126 -439
  71. package/dist/cli.mjs +121 -434
  72. package/dist/context/index.d.ts +3 -3
  73. package/dist/context/style-options.d.ts +4 -1
  74. package/dist/context/tailwindcss.d.ts +1 -1
  75. package/dist/{precheck-30zNPRlI.js → context-BHxLe743.js} +484 -175
  76. package/dist/{precheck-CsFr1q2l.mjs → context-Mbzkek1q.mjs} +461 -159
  77. package/dist/core.js +15 -12
  78. package/dist/core.mjs +10 -7
  79. package/dist/css-macro.js +2 -2
  80. package/dist/css-macro.mjs +2 -2
  81. package/dist/{defaults-Boc26eel.js → defaults-CVcKbXBG.js} +6 -50
  82. package/dist/{defaults-DH0ZQRhy.mjs → defaults-ZElj1zKc.mjs} +7 -45
  83. package/dist/defaults.d.ts +1 -7
  84. package/dist/defaults.js +1 -2
  85. package/dist/defaults.mjs +2 -2
  86. package/dist/framework/index.d.ts +59 -0
  87. package/dist/framework.d.ts +1 -0
  88. package/dist/framework.js +198 -0
  89. package/dist/framework.mjs +180 -0
  90. package/dist/generator/index.d.ts +6 -7
  91. package/dist/generator/options.d.ts +3 -3
  92. package/dist/generator/types.d.ts +9 -10
  93. package/dist/generator-9rUz4Hcb.js +170 -0
  94. package/dist/generator-Dc4qaPmT.mjs +123 -0
  95. package/dist/generator.js +10 -16
  96. package/dist/generator.mjs +3 -3
  97. package/dist/{gulp-CxGZU0-v.js → gulp-B_sdP6dx.js} +80 -92
  98. package/dist/{gulp-BfZpaYSQ.mjs → gulp-uM36oIJs.mjs} +73 -85
  99. package/dist/gulp.js +1 -1
  100. package/dist/gulp.mjs +1 -1
  101. package/dist/{hmr-timing-DNjF8bWA.mjs → hmr-timing-BXMLsF4b.mjs} +1289 -909
  102. package/dist/{hmr-timing-DFR51wgo.js → hmr-timing-CogqkFaF.js} +1397 -939
  103. package/dist/index.d.ts +1 -0
  104. package/dist/index.js +20 -4
  105. package/dist/index.mjs +6 -5
  106. package/dist/js/fast-path/oxc.d.ts +4 -0
  107. package/dist/js/precheck.d.ts +1 -0
  108. package/dist/postcss.js +3 -4
  109. package/dist/postcss.mjs +2 -3
  110. package/dist/presets.js +10 -20
  111. package/dist/presets.mjs +9 -19
  112. package/dist/runtime-branch/create-branch.d.ts +2 -0
  113. package/dist/runtime-branch/generator-target-env.d.ts +4 -0
  114. package/dist/runtime-branch/index.d.ts +6 -0
  115. package/dist/runtime-branch/mini-program.d.ts +2 -0
  116. package/dist/runtime-branch/native-app.d.ts +2 -0
  117. package/dist/runtime-branch/platform.d.ts +6 -0
  118. package/dist/runtime-branch/tailwind-version.d.ts +2 -0
  119. package/dist/runtime-branch/types.d.ts +37 -0
  120. package/dist/runtime-branch/web.d.ts +2 -0
  121. package/dist/runtime-branch.d.ts +1 -0
  122. package/dist/{bundle-state-DU2ATDhw.js → source-candidate-scan-signature-2ybpptAK.js} +262 -20
  123. package/dist/{bundle-state-BxMNKjBV.mjs → source-candidate-scan-signature-Cvb5z1ha.mjs} +187 -17
  124. package/dist/tailwindcss/candidates.d.ts +7 -0
  125. package/dist/tailwindcss/index.d.ts +2 -2
  126. package/dist/tailwindcss/runtime/cache.d.ts +6 -6
  127. package/dist/tailwindcss/runtime-factory.d.ts +12 -0
  128. package/dist/tailwindcss/runtime-options.d.ts +8 -0
  129. package/dist/tailwindcss/runtime-types.d.ts +86 -0
  130. package/dist/tailwindcss/runtime.d.ts +6 -6
  131. package/dist/tailwindcss/source-scan.d.ts +1 -1
  132. package/dist/tailwindcss/targets.d.ts +2 -2
  133. package/dist/tailwindcss/v4/config.d.ts +3 -3
  134. package/dist/tailwindcss/v4/css-entries.d.ts +1 -0
  135. package/dist/tailwindcss/v4/css-sources.d.ts +4 -2
  136. package/dist/tailwindcss/v4/index.d.ts +1 -1
  137. package/dist/tailwindcss/v4/multi-runtime.d.ts +2 -0
  138. package/dist/tailwindcss/v4/runtime-factory.d.ts +15 -0
  139. package/dist/tailwindcss/v4/runtime-options.d.ts +2 -0
  140. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
  141. package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
  142. package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +3 -3
  143. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +1 -1
  144. package/dist/tailwindcss/v4-engine/generator.d.ts +10 -3
  145. package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
  146. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +7 -1
  147. package/dist/tailwindcss/v4-engine/source.d.ts +23 -6
  148. package/dist/tailwindcss/v4-engine/types.d.ts +8 -9
  149. package/dist/tailwindcss/version.d.ts +1 -1
  150. package/dist/tailwindcss-DHIYcqXT.js +1523 -0
  151. package/dist/tailwindcss-wyUHrfil.mjs +1418 -0
  152. package/dist/{transform-CaVEBOuR.js → transform-CQVOgmzM.js} +45 -37
  153. package/dist/{transform-Cju08-aJ.mjs → transform-tExdt40m.mjs} +30 -22
  154. package/dist/typedoc.export.d.ts +1 -1
  155. package/dist/types/index.d.ts +16 -17
  156. package/dist/types/shared.d.ts +1 -1
  157. package/dist/types/{typedoc-tailwindcss-patch.d.ts → typedoc-tailwindcss-runtime.d.ts} +4 -10
  158. package/dist/types/user-defined-options/general.d.ts +8 -4
  159. package/dist/types/user-defined-options/important.d.ts +2 -2
  160. package/dist/uni-app-x/style-asset.d.ts +1 -0
  161. package/dist/{utils-Dolmt8EO.js → utils-BCa37Wqj.js} +2 -17
  162. package/dist/{utils-DsaS975I.mjs → utils-DodxWHGz.mjs} +2 -17
  163. package/dist/v4-engine-CF9zt4Cw.mjs +2396 -0
  164. package/dist/v4-engine-D4ubP7N5.js +2778 -0
  165. package/dist/{vite-BBGOjh9e.js → vite-CP0ylSxZ.js} +2887 -1683
  166. package/dist/{vite-CS5DE-HD.mjs → vite-CPO83EhA.mjs} +2753 -1548
  167. package/dist/vite.js +1 -1
  168. package/dist/vite.mjs +1 -1
  169. package/dist/weapp-tw-css-import-rewrite-loader.js +5741 -4396
  170. package/dist/weapp-tw-runtime-classset-loader.js +36 -0
  171. package/dist/webpack-Bsek8VhR.js +2094 -0
  172. package/dist/webpack-BzqhJ8yK.mjs +2082 -0
  173. package/dist/webpack.js +1 -1
  174. package/dist/webpack.mjs +1 -1
  175. package/package.json +11 -7
  176. package/dist/auto-CTp6wE5a.js +0 -33
  177. package/dist/auto-Cl8_hsG6.mjs +0 -22
  178. package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +0 -13
  179. package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +0 -1
  180. package/dist/context/tailwindcss/rax.d.ts +0 -2
  181. package/dist/generator-Cb1Zp3Al.js +0 -92
  182. package/dist/generator-mvNFUvns.mjs +0 -67
  183. package/dist/tailwindcss/patcher-options.d.ts +0 -8
  184. package/dist/tailwindcss/patcher.d.ts +0 -12
  185. package/dist/tailwindcss/runtime-patch.d.ts +0 -5
  186. package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +0 -3
  187. package/dist/tailwindcss/v3-engine/generator/content.d.ts +0 -10
  188. package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +0 -2
  189. package/dist/tailwindcss/v3-engine/generator.d.ts +0 -19
  190. package/dist/tailwindcss/v3-engine/index.d.ts +0 -4
  191. package/dist/tailwindcss/v3-engine/miniprogram.d.ts +0 -4
  192. package/dist/tailwindcss/v3-engine/source.d.ts +0 -5
  193. package/dist/tailwindcss/v3-engine/types.d.ts +0 -61
  194. package/dist/tailwindcss/v4/multi-patcher.d.ts +0 -2
  195. package/dist/tailwindcss/v4/patcher-options.d.ts +0 -2
  196. package/dist/tailwindcss/v4/patcher.d.ts +0 -15
  197. package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +0 -1
  198. package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +0 -1
  199. package/dist/tailwindcss-CK84uGBp.mjs +0 -556
  200. package/dist/tailwindcss-Clpkz1oR.js +0 -613
  201. package/dist/v3-engine-CQE5JJNZ.js +0 -4639
  202. package/dist/v3-engine-DKBaKWGL.mjs +0 -4231
  203. package/dist/webpack-DIWrcpRo.js +0 -1066
  204. package/dist/webpack-SPcri_D8.mjs +0 -1054
  205. /package/dist/tailwindcss/{patcher-resolve.d.ts → runtime-resolve.d.ts} +0 -0
@@ -1,20 +1,24 @@
1
1
  const require_chunk = require("./chunk-emK7D4bc.js");
2
- const require_v3_engine = require("./v3-engine-CQE5JJNZ.js");
3
- const require_defaults = require("./defaults-Boc26eel.js");
4
- require("./utils-Dolmt8EO.js");
5
- const require_tailwindcss = require("./tailwindcss-Clpkz1oR.js");
6
- let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
7
- let lru_cache = require("lru-cache");
8
- let tailwindcss_patch = require("tailwindcss-patch");
2
+ const require_v4_engine = require("./v4-engine-D4ubP7N5.js");
3
+ const require_generator = require("./generator-9rUz4Hcb.js");
4
+ require("./utils-BCa37Wqj.js");
5
+ const require_defaults = require("./defaults-CVcKbXBG.js");
6
+ const require_tailwindcss = require("./tailwindcss-DHIYcqXT.js");
9
7
  let node_path = require("node:path");
10
8
  node_path = require_chunk.__toESM(node_path);
11
9
  let node_process = require("node:process");
12
10
  node_process = require_chunk.__toESM(node_process);
13
- let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
11
+ let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
12
+ let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
13
+ let lru_cache = require("lru-cache");
14
14
  let node_fs_promises = require("node:fs/promises");
15
+ let node_module = require("node:module");
15
16
  let node_buffer = require("node:buffer");
17
+ let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
16
18
  let _weapp_tailwindcss_shared_node = require("@weapp-tailwindcss/shared/node");
17
19
  let _weapp_core_escape = require("@weapp-core/escape");
20
+ let debug = require("debug");
21
+ debug = require_chunk.__toESM(debug);
18
22
  let _babel_traverse = require("@babel/traverse");
19
23
  _babel_traverse = require_chunk.__toESM(_babel_traverse);
20
24
  let _babel_parser = require("@babel/parser");
@@ -69,15 +73,16 @@ function createCache(options) {
69
73
  });
70
74
  return cache;
71
75
  },
76
+ pruneHashKeys(hashKeys) {
77
+ const activeHashKeys = new Set(hashKeys);
78
+ for (const key of hashMap.keys()) if (!activeHashKeys.has(key)) hashMap.delete(key);
79
+ },
72
80
  prune(options) {
73
81
  if (options.cacheKeys) {
74
82
  const cacheKeys = new Set(options.cacheKeys);
75
83
  for (const key of instance.keys()) if (!cacheKeys.has(key)) instance.delete(key);
76
84
  }
77
- if (options.hashKeys) {
78
- const hashKeys = new Set(options.hashKeys);
79
- for (const key of hashMap.keys()) if (!hashKeys.has(key)) hashMap.delete(key);
80
- }
85
+ if (options.hashKeys) cache.pruneHashKeys?.(options.hashKeys);
81
86
  },
82
87
  has(key) {
83
88
  return instance.has(key);
@@ -116,13 +121,28 @@ function initializeCache(cacheConfig) {
116
121
  return cacheConfig;
117
122
  }
118
123
  //#endregion
124
+ //#region src/debug/index.ts
125
+ const _debug = (0, debug.default)("weapp-tw");
126
+ function createDebug(prefix) {
127
+ const debug$3 = ((formatter, ...args) => {
128
+ return _debug((prefix ?? "") + formatter, ...args);
129
+ });
130
+ Object.defineProperty(debug$3, "enabled", {
131
+ enumerable: false,
132
+ configurable: false,
133
+ get() {
134
+ return _debug.enabled;
135
+ }
136
+ });
137
+ return debug$3;
138
+ }
139
+ //#endregion
119
140
  //#region src/tailwindcss/runtime.ts
120
- const debug$1 = require_v3_engine.createDebug("[tailwindcss:runtime] ");
121
- const refreshTailwindcssPatcherSymbol = Symbol.for("weapp-tailwindcss.refreshTailwindcssPatcher");
122
- function createTailwindRuntimeReadyPromise(twPatcher) {
141
+ const debug$2 = createDebug("[tailwindcss:runtime] ");
142
+ const refreshTailwindcssRuntimeSymbol = Symbol.for("weapp-tailwindcss.refreshTailwindcssRuntime");
143
+ function createTailwindRuntimeReadyPromise(tailwindRuntime) {
123
144
  return Promise.resolve().then(async () => {
124
- await require_v3_engine.ensureTailwindcssRuntimePatch(twPatcher);
125
- require_v3_engine.invalidateRuntimeClassSet(twPatcher);
145
+ require_tailwindcss.invalidateRuntimeClassSet(tailwindRuntime);
126
146
  });
127
147
  }
128
148
  const runtimeClassSetStateCache = /* @__PURE__ */ new WeakMap();
@@ -134,21 +154,31 @@ function getRuntimeClassSetStateEntry(state) {
134
154
  }
135
155
  return entry;
136
156
  }
157
+ function getTailwindRuntime(state) {
158
+ return state.tailwindRuntime;
159
+ }
160
+ function setTailwindRuntime(state, runtime) {
161
+ state.tailwindRuntime = runtime;
162
+ }
163
+ function getRefreshTailwindRuntime(state) {
164
+ return state.refreshTailwindcssRuntime;
165
+ }
137
166
  async function refreshTailwindRuntimeState(state, forceOrOptions) {
138
167
  const normalizedOptions = typeof forceOrOptions === "boolean" ? { force: forceOrOptions } : forceOrOptions;
139
168
  const force = normalizedOptions.force;
140
169
  const clearCache = normalizedOptions.clearCache === true;
141
170
  if (!force) return false;
142
- debug$1("refresh runtime state start, clearCache=%s major=%s", clearCache, state.twPatcher.majorVersion ?? "unknown");
171
+ debug$2("refresh runtime state start, clearCache=%s major=%s", clearCache, getTailwindRuntime(state).majorVersion ?? "unknown");
143
172
  await state.readyPromise;
144
173
  let refreshed = false;
145
- if (typeof state.refreshTailwindcssPatcher === "function") {
146
- const next = await state.refreshTailwindcssPatcher({ clearCache });
147
- if (next !== state.twPatcher) state.twPatcher = next;
174
+ const refreshTailwindRuntime = getRefreshTailwindRuntime(state);
175
+ if (typeof refreshTailwindRuntime === "function") {
176
+ const next = await refreshTailwindRuntime({ clearCache });
177
+ if (next !== getTailwindRuntime(state)) setTailwindRuntime(state, next);
148
178
  refreshed = true;
149
179
  }
150
- if (refreshed) state.readyPromise = createTailwindRuntimeReadyPromise(state.twPatcher);
151
- debug$1("refresh runtime state end, refreshed=%s major=%s", refreshed, state.twPatcher.majorVersion ?? "unknown");
180
+ if (refreshed) state.readyPromise = createTailwindRuntimeReadyPromise(getTailwindRuntime(state));
181
+ debug$2("refresh runtime state end, refreshed=%s major=%s", refreshed, getTailwindRuntime(state).majorVersion ?? "unknown");
152
182
  return refreshed;
153
183
  }
154
184
  async function ensureRuntimeClassSet(state, options = {}) {
@@ -162,7 +192,7 @@ async function ensureRuntimeClassSet(state, options = {}) {
162
192
  });
163
193
  await state.readyPromise;
164
194
  const entry = getRuntimeClassSetStateEntry(state);
165
- const signature = await require_v3_engine.getRuntimeClassSetSignatureWithSources(state.twPatcher);
195
+ const signature = await require_tailwindcss.getRuntimeClassSetSignatureWithSources(getTailwindRuntime(state));
166
196
  const signatureChanged = entry.signature !== signature;
167
197
  const shouldForceCollect = forceCollect || forceRefresh || signatureChanged;
168
198
  if (!shouldForceCollect) {
@@ -170,7 +200,7 @@ async function ensureRuntimeClassSet(state, options = {}) {
170
200
  if (entry.promise) return entry.promise;
171
201
  }
172
202
  const task = (async () => {
173
- const collected = await collectRuntimeClassSet(state.twPatcher, {
203
+ const collected = await collectRuntimeClassSet(getTailwindRuntime(state), {
174
204
  force: shouldForceCollect,
175
205
  skipRefresh: true,
176
206
  clearCache
@@ -181,7 +211,7 @@ async function ensureRuntimeClassSet(state, options = {}) {
181
211
  clearCache: true
182
212
  });
183
213
  await state.readyPromise;
184
- return collectRuntimeClassSet(state.twPatcher, {
214
+ return collectRuntimeClassSet(getTailwindRuntime(state), {
185
215
  force: true,
186
216
  skipRefresh: true,
187
217
  clearCache: true
@@ -191,118 +221,90 @@ async function ensureRuntimeClassSet(state, options = {}) {
191
221
  try {
192
222
  const runtimeSet = await task;
193
223
  entry.value = runtimeSet;
194
- entry.signature = await require_v3_engine.getRuntimeClassSetSignatureWithSources(state.twPatcher);
224
+ entry.signature = await require_tailwindcss.getRuntimeClassSetSignatureWithSources(getTailwindRuntime(state));
195
225
  return runtimeSet;
196
226
  } finally {
197
227
  if (entry.promise === task) entry.promise = void 0;
198
228
  }
199
229
  }
200
- function shouldPreferSync(majorVersion) {
201
- if (majorVersion == null) return true;
202
- if (majorVersion === 3) return true;
203
- if (majorVersion === 4) return true;
204
- return false;
205
- }
206
- function tryGetRuntimeClassSetSync(twPatcher) {
207
- if (typeof twPatcher.getClassSetSync !== "function") return;
208
- if (!shouldPreferSync(twPatcher.majorVersion)) return;
230
+ function tryGetRuntimeClassSetSync(tailwindRuntime) {
231
+ if (typeof tailwindRuntime.getClassSetSync !== "function") return;
209
232
  try {
210
- const set = twPatcher.getClassSetSync();
233
+ const set = tailwindRuntime.getClassSetSync();
211
234
  if (set && set.size === 0) return;
212
235
  return set;
213
236
  } catch (error) {
214
- if (twPatcher.majorVersion === 4) debug$1("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
215
- else debug$1("getClassSetSync() failed, fallback to async getClassSet(): %O", error);
237
+ debug$2("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
216
238
  return;
217
239
  }
218
240
  }
219
- async function collectTailwindV4GeneratorClassSet(twPatcher) {
241
+ async function collectTailwindV4GeneratorClassSet(tailwindRuntime) {
242
+ if (typeof tailwindRuntime.collectContentTokens !== "function") return;
220
243
  try {
221
- const generated = await require_v3_engine.createTailwindV4Engine(await require_v3_engine.resolveTailwindV4SourceFromPatcher(twPatcher)).generate({
244
+ const generated = await require_v4_engine.createTailwindV4Engine(await require_v4_engine.resolveTailwindV4SourceFromRuntime(tailwindRuntime)).generate({
222
245
  scanSources: true,
223
- target: "tailwind"
246
+ target: "web"
224
247
  });
225
- debug$1("runtime class set resolved via tailwindcss v4 generator source scan, size=%d", generated.classSet.size);
248
+ debug$2("runtime class set resolved via tailwindcss v4 generator source scan, size=%d", generated.classSet.size);
226
249
  return generated.classSet;
227
250
  } catch (error) {
228
- debug$1("tailwindcss v4 generator source scan failed, continuing fallback chain: %O", error);
251
+ debug$2("tailwindcss v4 generator source scan failed, continuing fallback chain: %O", error);
229
252
  return;
230
253
  }
231
254
  }
232
- async function mergeTailwindV4GeneratorClassSet(twPatcher, classSet) {
233
- if (twPatcher.majorVersion !== 4) return classSet;
234
- const generatorClassSet = await collectTailwindV4GeneratorClassSet(twPatcher);
255
+ async function mergeTailwindV4GeneratorClassSet(tailwindRuntime, classSet) {
256
+ const generatorClassSet = await collectTailwindV4GeneratorClassSet(tailwindRuntime).catch(() => void 0);
235
257
  if (!generatorClassSet || generatorClassSet.size === 0) return classSet;
236
258
  return new Set([...classSet, ...generatorClassSet]);
237
259
  }
238
- function canReturnExtractClassSetImmediately(twPatcher) {
239
- return twPatcher.majorVersion !== 4;
240
- }
241
- async function collectRuntimeClassSet(twPatcher, options = {}) {
242
- let activePatcher = twPatcher;
260
+ async function collectRuntimeClassSet(tailwindRuntime, options = {}) {
261
+ let activeRuntime = tailwindRuntime;
243
262
  if (options.force && !options.skipRefresh) {
244
- const refresh = activePatcher[refreshTailwindcssPatcherSymbol];
263
+ const refresh = activeRuntime[refreshTailwindcssRuntimeSymbol];
245
264
  if (typeof refresh === "function") try {
246
265
  const refreshed = await refresh({ clearCache: options.clearCache === true });
247
- if (refreshed) activePatcher = refreshed;
266
+ if (refreshed) activeRuntime = refreshed;
248
267
  } catch (error) {
249
- debug$1("refreshTailwindcssPatcher failed, continuing with existing patcher: %O", error);
268
+ debug$2("refreshTailwindcssRuntime failed, continuing with existing runtime: %O", error);
250
269
  }
251
270
  }
252
- const entry = require_v3_engine.getRuntimeClassSetCacheEntry(activePatcher);
253
- const signature = await require_v3_engine.getRuntimeClassSetSignatureWithSources(activePatcher);
271
+ const entry = require_tailwindcss.getRuntimeClassSetCacheEntry(activeRuntime);
272
+ const signature = await require_tailwindcss.getRuntimeClassSetSignatureWithSources(activeRuntime);
254
273
  if (!options.force) {
255
274
  if (entry.value && entry.signature === signature) return entry.value;
256
275
  if (entry.promise) return entry.promise;
257
276
  } else entry.value = void 0;
258
277
  const task = (async () => {
259
- await require_v3_engine.ensureTailwindcssRuntimePatch(activePatcher);
260
- const preExtractSyncSet = options.force ? tryGetRuntimeClassSetSync(activePatcher) : void 0;
261
- if (preExtractSyncSet) debug$1("runtime class set snapshot via getClassSetSync() before extract(), size=%d", preExtractSyncSet.size);
262
278
  const preferExtract = options.force === true;
263
279
  try {
264
- const result = await activePatcher.extract({ write: false });
280
+ const result = await activeRuntime.extract({ write: false });
265
281
  if (result?.classSet) {
266
282
  if (result.classSet.size > 0) {
267
- if (canReturnExtractClassSetImmediately(activePatcher)) {
268
- debug$1("runtime class set resolved via extract(), size=%d", result.classSet.size);
269
- return result.classSet;
270
- }
271
- const merged = await mergeTailwindV4GeneratorClassSet(activePatcher, result.classSet);
272
- debug$1("runtime class set resolved via extract() + tailwindcss v4 source scan, extract=%d merged=%d", result.classSet.size, merged.size);
283
+ const merged = await mergeTailwindV4GeneratorClassSet(activeRuntime, result.classSet);
284
+ debug$2("runtime class set resolved via extract() + tailwindcss v4 source scan, extract=%d merged=%d", result.classSet.size, merged.size);
273
285
  return merged;
274
286
  }
275
- if (preferExtract && activePatcher.majorVersion !== 4) {
276
- debug$1("runtime class set resolved via empty extract() on force collect, size=0");
277
- return result.classSet;
278
- }
279
- if (preferExtract) debug$1("runtime class set from extract() is empty on force collect, fallback to generator/sync/async class set");
280
- else debug$1("runtime class set from extract() is empty, fallback to sync/async class set");
287
+ if (preferExtract) debug$2("runtime class set from extract() is empty on force collect, fallback to generator/sync/async class set");
288
+ else debug$2("runtime class set from extract() is empty, fallback to sync/async class set");
281
289
  }
282
290
  } catch (error) {
283
- debug$1("extract() failed, fallback to getClassSet(): %O", error);
284
- }
285
- if (activePatcher.majorVersion === 4) {
286
- const generatorClassSet = await collectTailwindV4GeneratorClassSet(activePatcher);
287
- if (generatorClassSet && generatorClassSet.size > 0) return generatorClassSet;
291
+ debug$2("extract() failed, fallback to getClassSet(): %O", error);
288
292
  }
289
- if (preExtractSyncSet) {
290
- debug$1("runtime class set fallback to pre-extract sync snapshot, size=%d", preExtractSyncSet.size);
291
- return preExtractSyncSet;
292
- }
293
- const syncSet = tryGetRuntimeClassSetSync(activePatcher);
293
+ const generatorClassSet = await collectTailwindV4GeneratorClassSet(activeRuntime);
294
+ if (generatorClassSet && generatorClassSet.size > 0) return generatorClassSet;
295
+ const syncSet = tryGetRuntimeClassSetSync(activeRuntime);
294
296
  if (syncSet) {
295
- debug$1("runtime class set resolved via getClassSetSync(), size=%d", syncSet.size);
297
+ debug$2("runtime class set resolved via getClassSetSync(), size=%d", syncSet.size);
296
298
  return syncSet;
297
299
  }
298
300
  try {
299
- const fallbackSet = await Promise.resolve(activePatcher.getClassSet());
301
+ const fallbackSet = await Promise.resolve(activeRuntime.getClassSet());
300
302
  if (fallbackSet) {
301
- debug$1("runtime class set resolved via getClassSet(), size=%d", fallbackSet.size);
303
+ debug$2("runtime class set resolved via getClassSet(), size=%d", fallbackSet.size);
302
304
  return fallbackSet;
303
305
  }
304
306
  } catch (error) {
305
- debug$1("getClassSet() failed, returning empty set: %O", error);
307
+ debug$2("getClassSet() failed, returning empty set: %O", error);
306
308
  }
307
309
  return /* @__PURE__ */ new Set();
308
310
  })();
@@ -361,8 +363,8 @@ function formatRelativeToBase(targetPath, baseDir) {
361
363
  if (relative.startsWith("..")) return normalized.replace(/\\/g, "/");
362
364
  return node_path.default.join(".", relative).replace(/\\/g, "/");
363
365
  }
364
- function logTailwindcssTarget(patcher, baseDir) {
365
- const packageInfo = patcher?.packageInfo;
366
+ function logTailwindcssTarget(tailwindRuntime, baseDir) {
367
+ const packageInfo = tailwindRuntime?.packageInfo;
366
368
  const label = "Weapp-tailwindcss";
367
369
  if (!packageInfo?.rootPath) {
368
370
  _weapp_tailwindcss_logger.logger.warn("%s 未找到 Tailwind CSS 依赖,请检查在 %s 是否已安装 tailwindcss", label, baseDir ?? node_process.default.cwd());
@@ -376,7 +378,7 @@ function logTailwindcssTarget(patcher, baseDir) {
376
378
  //#endregion
377
379
  //#region src/unocss/index.ts
378
380
  function normalizeUnocssOptions(unocss) {
379
- return require_v3_engine.resolveBooleanObjectOption(unocss, {});
381
+ return require_v4_engine.resolveBooleanObjectOption(unocss, {});
380
382
  }
381
383
  function resolveUnocssBareArbitraryValues(arbitraryValues, unocss) {
382
384
  const baseArbitraryValues = arbitraryValues ?? {};
@@ -395,10 +397,28 @@ function resolveUnocssBareArbitraryValues(arbitraryValues, unocss) {
395
397
  const PAREN_CONTENT_RE = /\(([^)]+)\)/u;
396
398
  const AT_LOCATION_RE = /at\s+(\S.*)$/u;
397
399
  const TRAILING_LINE_COL_RE = /:\d+(?::\d+)?$/u;
400
+ const DEFAULT_COMPILER_CONTEXT_CACHE_MAX = 32;
401
+ const DEFAULT_COMPILER_CONTEXT_KEY_CACHE_MAX = DEFAULT_COMPILER_CONTEXT_CACHE_MAX * 2;
398
402
  const globalCacheHolder = globalThis;
399
403
  const compilerContextCache = globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ ?? (globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ = /* @__PURE__ */ new Map());
400
404
  const compilerContextKeyCacheByOptions = /* @__PURE__ */ new WeakMap();
401
405
  const compilerContextKeyCacheWithoutOptions = /* @__PURE__ */ new Map();
406
+ function resolveCompilerContextCacheMax(defaultValue) {
407
+ const raw = Number.parseInt(node_process.default.env["WEAPP_TW_COMPILER_CONTEXT_CACHE_MAX"] ?? "", 10);
408
+ if (!Number.isFinite(raw) || raw <= 0) return defaultValue;
409
+ return Math.floor(raw);
410
+ }
411
+ function touchMapValue(map, key, value) {
412
+ map.delete(key);
413
+ map.set(key, value);
414
+ }
415
+ function pruneMapToMaxSize(map, maxSize) {
416
+ while (map.size > maxSize) {
417
+ const firstKey = map.keys().next().value;
418
+ if (firstKey === void 0) break;
419
+ map.delete(firstKey);
420
+ }
421
+ }
402
422
  function withCircularGuard(value, stack, factory) {
403
423
  if (stack.has(value)) throw new TypeError("Cannot serialize circular structure in compiler context options");
404
424
  stack.add(value);
@@ -568,7 +588,8 @@ function createCompilerContextCacheKey(opts) {
568
588
  const cached = keyStore.get(runtimeCacheScopeKey);
569
589
  if (cached !== void 0) return cached;
570
590
  const cacheKey = (0, _weapp_tailwindcss_shared_node.md5)(serializeNormalizedValue(normalizeOptionsValue(getRuntimeCacheScopeValue(opts))));
571
- keyStore.set(runtimeCacheScopeKey, cacheKey);
591
+ touchMapValue(keyStore, runtimeCacheScopeKey, cacheKey);
592
+ pruneMapToMaxSize(keyStore, resolveCompilerContextCacheMax(DEFAULT_COMPILER_CONTEXT_KEY_CACHE_MAX));
572
593
  return cacheKey;
573
594
  } catch (error) {
574
595
  _weapp_tailwindcss_logger.logger.debug("skip compiler context cache: %O", error);
@@ -579,10 +600,16 @@ function withCompilerContextCache(opts, factory) {
579
600
  const cacheKey = createCompilerContextCacheKey(opts);
580
601
  if (cacheKey) {
581
602
  const cached = compilerContextCache.get(cacheKey);
582
- if (cached) return cached;
603
+ if (cached) {
604
+ touchMapValue(compilerContextCache, cacheKey, cached);
605
+ return cached;
606
+ }
583
607
  }
584
608
  const ctx = factory();
585
- if (cacheKey) compilerContextCache.set(cacheKey, ctx);
609
+ if (cacheKey) {
610
+ touchMapValue(compilerContextCache, cacheKey, ctx);
611
+ pruneMapToMaxSize(compilerContextCache, resolveCompilerContextCacheMax(DEFAULT_COMPILER_CONTEXT_CACHE_MAX));
612
+ }
586
613
  return ctx;
587
614
  }
588
615
  //#endregion
@@ -713,7 +740,7 @@ function replaceWxml(original, options = {
713
740
  const { keepEOL, escapeMap, ignoreHead } = options;
714
741
  let res = original;
715
742
  if (!keepEOL) res = res.replaceAll(NEWLINE_RE, "");
716
- res = (0, _weapp_core_escape.escape)(res, require_v3_engine.omitUndefined({
743
+ res = (0, _weapp_core_escape.escape)(res, require_v4_engine.omitUndefined({
717
744
  map: escapeMap,
718
745
  ignoreHead
719
746
  }));
@@ -934,7 +961,7 @@ function getReplacement(candidate, escapeMap, store = getReplacementCacheStore(e
934
961
  }
935
962
  //#endregion
936
963
  //#region src/js/handlers.ts
937
- const debug = require_v3_engine.createDebug("[js:handlers] ");
964
+ const debug$1 = createDebug("[js:handlers] ");
938
965
  const WEAPP_TW_IGNORE_MARKER = "weapp-tw";
939
966
  const IGNORE_MARKER = "ignore";
940
967
  function hasIgnoreComment(node) {
@@ -946,6 +973,19 @@ function hasIgnoreComment(node) {
946
973
  }
947
974
  return false;
948
975
  }
976
+ function isConditionTestLiteral(path) {
977
+ let current = path;
978
+ while (current?.parentPath) {
979
+ const parent = current.parentPath;
980
+ if (parent.isConditionalExpression()) return parent.node.test === current.node;
981
+ if (parent.isBinaryExpression() || parent.isCallExpression() || parent.isLogicalExpression() || parent.isMemberExpression() || parent.isUnaryExpression()) {
982
+ current = parent;
983
+ continue;
984
+ }
985
+ return false;
986
+ }
987
+ return false;
988
+ }
949
989
  function extractLiteralValue(path, { unescapeUnicode }) {
950
990
  const { node } = path;
951
991
  let offset = 0;
@@ -1011,10 +1051,11 @@ function replaceHandleValue(path, options) {
1011
1051
  const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
1012
1052
  if (!alwaysEscape && !fallbackEnabled && (!classNameSet || classNameSet.size === 0)) return;
1013
1053
  if (hasIgnoreComment(path.node)) return;
1054
+ if (isConditionTestLiteral(path)) return;
1014
1055
  const { literal, original, offset } = extractLiteralValue(path, options);
1015
- const candidates = (0, tailwindcss_patch.splitCandidateTokens)(literal);
1056
+ const candidates = (0, _tailwindcss_mangle_engine.splitCandidateTokens)(literal);
1016
1057
  if (candidates.length === 0) return;
1017
- const debugEnabled = debug.enabled;
1058
+ const debugEnabled = debug$1.enabled;
1018
1059
  const classContext = options.wrapExpression || isClassContextLiteralPath(path);
1019
1060
  let transformed = literal;
1020
1061
  let mutated = false;
@@ -1050,7 +1091,7 @@ function replaceHandleValue(path, options) {
1050
1091
  }
1051
1092
  const node = path.node;
1052
1093
  if (!mutated || typeof node.start !== "number" || typeof node.end !== "number") return;
1053
- if (debugEnabled) debug("runtimeSet size=%d fallbackTriggered=%s candidates=%d matched=%d escapedHits=%d skipped=%d file=%s escapedSamples=%s skippedSamples=%s", classNameSet?.size ?? 0, fallbackDecisionCount > 0, candidates.length, matchedCandidateCount, escapedDecisionCount, skippedSamples?.length ?? 0, options.filename ?? "unknown", escapedSamples?.join(",") || "-", skippedSamples?.join(",") || "-");
1094
+ if (debugEnabled) debug$1("runtimeSet size=%d fallbackTriggered=%s candidates=%d matched=%d escapedHits=%d skipped=%d file=%s escapedSamples=%s skippedSamples=%s", classNameSet?.size ?? 0, fallbackDecisionCount > 0, candidates.length, matchedCandidateCount, escapedDecisionCount, skippedSamples?.length ?? 0, options.filename ?? "unknown", escapedSamples?.join(",") || "-", skippedSamples?.join(",") || "-");
1054
1095
  const start = node.start + offset;
1055
1096
  const end = node.end - offset;
1056
1097
  if (start >= end || transformed === original) return;
@@ -2026,6 +2067,198 @@ function jsHandler(rawSource, options) {
2026
2067
  }
2027
2068
  defaultEvalHandler = jsHandler;
2028
2069
  //#endregion
2070
+ //#region src/js/literal-transform.ts
2071
+ function transformLiteralText(literal, options) {
2072
+ const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
2073
+ if (!options.alwaysEscape && !fallbackEnabled && (!options.classNameSet || options.classNameSet.size === 0)) return;
2074
+ const source = options.unescapeUnicode && literal.includes("\\u") ? decodeUnicode2(literal) : literal;
2075
+ const candidates = (0, _tailwindcss_mangle_engine.splitCandidateTokens)(source);
2076
+ if (candidates.length === 0) return;
2077
+ const transformOptions = {
2078
+ ...options,
2079
+ classContext: true
2080
+ };
2081
+ const replacementCache = getReplacementCacheStore(options.escapeMap);
2082
+ let transformed = source;
2083
+ let mutated = false;
2084
+ for (const candidate of candidates) {
2085
+ const result = resolveClassNameTransformWithResult(candidate, transformOptions);
2086
+ if (result.decision === "skip" || !transformed.includes(candidate)) continue;
2087
+ const replacement = result.decision === "escaped" && result.escapedValue ? result.escapedValue : getReplacement(candidate, options.escapeMap, replacementCache);
2088
+ const replaced = transformed.replace(candidate, replacement);
2089
+ if (replaced !== transformed) {
2090
+ transformed = replaced;
2091
+ mutated = true;
2092
+ }
2093
+ }
2094
+ return mutated ? transformed : void 0;
2095
+ }
2096
+ //#endregion
2097
+ //#region src/js/fast-path/oxc.ts
2098
+ const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
2099
+ let oxcParser;
2100
+ let oxcWalker;
2101
+ function isOxcParserRuntimeSupported(version = node_process.default.versions.node) {
2102
+ const match = /^(\d+)\.(\d+)(?:\.|$)/.exec(version);
2103
+ if (!match) return false;
2104
+ const major = Number(match[1]);
2105
+ const minor = Number(match[2]);
2106
+ if (major === 20) return minor >= 19;
2107
+ if (major === 21) return false;
2108
+ if (major === 22) return minor >= 12;
2109
+ return major > 22;
2110
+ }
2111
+ function loadOxcParser() {
2112
+ if (!isOxcParserRuntimeSupported()) return;
2113
+ if (oxcParser === false) return;
2114
+ if (oxcParser) return oxcParser;
2115
+ try {
2116
+ oxcParser = require$1("oxc-parser");
2117
+ } catch {
2118
+ oxcParser = false;
2119
+ return;
2120
+ }
2121
+ return oxcParser;
2122
+ }
2123
+ function loadOxcWalker() {
2124
+ if (!isOxcParserRuntimeSupported()) return;
2125
+ if (oxcWalker === false) return;
2126
+ if (oxcWalker) return oxcWalker;
2127
+ try {
2128
+ oxcWalker = require$1("oxc-walker");
2129
+ } catch {
2130
+ oxcWalker = false;
2131
+ return;
2132
+ }
2133
+ return oxcWalker;
2134
+ }
2135
+ function hasValues(values) {
2136
+ return Array.isArray(values) && values.length > 0;
2137
+ }
2138
+ function hasUnsupportedSourceMarker(rawSource) {
2139
+ return rawSource.includes("eval(") || rawSource.includes("weapp-tw") && rawSource.includes("ignore");
2140
+ }
2141
+ function hasSupportedClassMatchSource(options) {
2142
+ return options.alwaysEscape === true || Boolean(options.classNameSet && options.classNameSet.size > 0);
2143
+ }
2144
+ function canUseOxcJsFastPath(options) {
2145
+ if (options.experimentalJsFastPath !== true && options.experimentalJsFastPath !== "oxc") return false;
2146
+ return !options.generateMap && !options.wrapExpression && !options.moduleGraph && !options.moduleSpecifierReplacements && hasSupportedClassMatchSource(options) && !shouldEnableArbitraryValueFallback(options) && !hasValues(options.ignoreCallExpressionIdentifiers) && !hasValues(options.ignoreTaggedTemplateExpressionIdentifiers);
2147
+ }
2148
+ function getParserLang(filename) {
2149
+ if (filename?.endsWith(".ts") || filename?.endsWith(".mts") || filename?.endsWith(".cts")) return "ts";
2150
+ if (filename?.endsWith(".tsx")) return "tsx";
2151
+ if (filename?.endsWith(".jsx")) return "jsx";
2152
+ return "js";
2153
+ }
2154
+ function getParserSourceType(sourceType) {
2155
+ return sourceType === "script" || sourceType === "module" ? sourceType : "module";
2156
+ }
2157
+ function isRangeValid(start, end) {
2158
+ return typeof start === "number" && typeof end === "number" && start < end;
2159
+ }
2160
+ function getMagicString(rawSource, context) {
2161
+ if (!context.ms) context.ms = new magic_string.default(rawSource);
2162
+ return context.ms;
2163
+ }
2164
+ function addStringLiteralReplacement(rawSource, node, transformOptions, context) {
2165
+ if (typeof node.value !== "string" || typeof node.raw !== "string" || !isRangeValid(node.start, node.end)) return false;
2166
+ const transformed = transformLiteralText(node.value, transformOptions);
2167
+ if (!transformed) return false;
2168
+ const start = node.start + 1;
2169
+ const end = node.end - 1;
2170
+ if (start >= end || transformed === rawSource.slice(start, end)) return false;
2171
+ getMagicString(rawSource, context).update(start, end, (0, _ast_core_escape.jsStringEscape)(transformed));
2172
+ return true;
2173
+ }
2174
+ function addTemplateElementReplacement(rawSource, node, transformOptions, context) {
2175
+ const raw = node.value?.raw;
2176
+ if (typeof raw !== "string" || !isRangeValid(node.start, node.end)) return false;
2177
+ const transformed = transformLiteralText(raw, transformOptions);
2178
+ if (!transformed || transformed === raw) return false;
2179
+ const first = rawSource[node.start];
2180
+ const last = rawSource[node.end - 1];
2181
+ const start = node.start + (first === "`" || first === "}" ? 1 : 0);
2182
+ const end = node.end - (last === "`" ? 1 : last === "{" ? 2 : 0);
2183
+ if (start >= end) return false;
2184
+ getMagicString(rawSource, context).update(start, end, transformed);
2185
+ return true;
2186
+ }
2187
+ function applyReplacements(rawSource, program, walker, stringLiteralOptions, templateLiteralOptions, context) {
2188
+ let changed = false;
2189
+ walker.walk(program, { enter(node) {
2190
+ if (node.type === "Literal") {
2191
+ changed = addStringLiteralReplacement(rawSource, node, stringLiteralOptions, context) || changed;
2192
+ return;
2193
+ }
2194
+ if (node.type === "TemplateElement") {
2195
+ changed = addTemplateElementReplacement(rawSource, node, templateLiteralOptions, context) || changed;
2196
+ this.skip();
2197
+ }
2198
+ } });
2199
+ return changed;
2200
+ }
2201
+ function oxcJsHandler(rawSource, options) {
2202
+ if (!canUseOxcJsFastPath(options)) return;
2203
+ if (hasUnsupportedSourceMarker(rawSource)) return;
2204
+ const parser = loadOxcParser();
2205
+ const walker = loadOxcWalker();
2206
+ if (!parser || !walker) return;
2207
+ let result;
2208
+ try {
2209
+ result = parser.parseSync(options.filename ?? "weapp-tailwindcss.js", rawSource, {
2210
+ sourceType: getParserSourceType(options.babelParserOptions?.sourceType),
2211
+ lang: getParserLang(options.filename)
2212
+ });
2213
+ } catch {
2214
+ return;
2215
+ }
2216
+ if (!result.program || Array.isArray(result.errors) && result.errors.length > 0) return;
2217
+ const stringLiteralOptions = options.needEscaped === true ? options : {
2218
+ ...options,
2219
+ needEscaped: true
2220
+ };
2221
+ const templateLiteralOptions = options.needEscaped === false ? options : {
2222
+ ...options,
2223
+ needEscaped: false
2224
+ };
2225
+ const replacementContext = {};
2226
+ if (!applyReplacements(rawSource, result.program, walker, stringLiteralOptions, templateLiteralOptions, replacementContext)) return { code: rawSource };
2227
+ return { code: replacementContext.ms.toString() };
2228
+ }
2229
+ //#endregion
2230
+ //#region src/js/precheck.ts
2231
+ /** 用于检测源码中是否包含类名相关模式的正则表达式 */
2232
+ 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)-/;
2233
+ /** 用于检测源码中是否包含 import/export/require 语句的正则表达式 */
2234
+ const DEPENDENCY_HINT_RE = /\bimport\s*[("'`{*]|\brequire\s*\(|\bexport\s+\*\s+from\s+["'`]|\bexport\s*\{[^}]*\}\s*from\s+["'`]/;
2235
+ /**
2236
+ * 判断源码是否可能声明跨模块依赖。
2237
+ *
2238
+ * 该检查只作为性能预筛:返回 `true` 时必须保守走 AST 模块图分析;
2239
+ * 返回 `false` 时源码中没有可被当前模块图消费的静态 import/export/require 形态。
2240
+ */
2241
+ function hasDependencyHint(rawSource) {
2242
+ return DEPENDENCY_HINT_RE.test(rawSource);
2243
+ }
2244
+ /**
2245
+ * 判断是否可以跳过 JS 转换。
2246
+ * 通过正则快速检测源码内容,避免不必要的 Babel AST 解析。
2247
+ *
2248
+ * @param rawSource - 原始 JS 源码字符串
2249
+ * @param options - 可选的 JS 处理器配置选项
2250
+ * @returns 如果可以跳过转换返回 `true`,否则返回 `false`
2251
+ */
2252
+ function shouldSkipJsTransform(rawSource, options) {
2253
+ if (node_process.default.env["WEAPP_TW_DISABLE_JS_PRECHECK"] === "1") return false;
2254
+ if (!rawSource) return true;
2255
+ if (options?.alwaysEscape) return false;
2256
+ if (options?.moduleSpecifierReplacements && Object.keys(options.moduleSpecifierReplacements).length > 0) return false;
2257
+ if (options?.wrapExpression) return false;
2258
+ if (hasDependencyHint(rawSource)) return false;
2259
+ return !FAST_JS_TRANSFORM_HINT_RE.test(rawSource);
2260
+ }
2261
+ //#endregion
2029
2262
  //#region src/js/index.ts
2030
2263
  /** 默认 LRU 缓存最大条目数 */
2031
2264
  const RESULT_CACHE_MAX = 512;
@@ -2070,6 +2303,7 @@ function getOptionsFingerprint(options) {
2070
2303
  JSON.stringify(options.ignoreCallExpressionIdentifiers ?? null),
2071
2304
  JSON.stringify(options.ignoreTaggedTemplateExpressionIdentifiers?.map((v) => v instanceof RegExp ? v.source : v) ?? null),
2072
2305
  JSON.stringify(options.moduleSpecifierReplacements ?? null),
2306
+ String(options.experimentalJsFastPath ?? ""),
2073
2307
  JSON.stringify(options.babelParserOptions ?? null)
2074
2308
  ].join("|");
2075
2309
  fingerprintCache.set(options, fingerprint);
@@ -2085,6 +2319,13 @@ function shouldCacheJsResult(rawSource, options) {
2085
2319
  if (options.moduleGraph || options.filename) return false;
2086
2320
  return true;
2087
2321
  }
2322
+ function resolveFastPathOptions(rawSource, options) {
2323
+ if (!options.moduleGraph) return options;
2324
+ if (options.moduleSpecifierReplacements && Object.keys(options.moduleSpecifierReplacements).length > 0) return options;
2325
+ if (hasDependencyHint(rawSource)) return options;
2326
+ const { moduleGraph: _moduleGraph, ...fastPathOptions } = options;
2327
+ return fastPathOptions;
2328
+ }
2088
2329
  function createJsHandler(options) {
2089
2330
  const defaults = {
2090
2331
  escapeMap: options.escapeMap,
@@ -2097,6 +2338,7 @@ function createJsHandler(options) {
2097
2338
  alwaysEscape: options.alwaysEscape,
2098
2339
  unescapeUnicode: options.unescapeUnicode,
2099
2340
  babelParserOptions: options.babelParserOptions,
2341
+ experimentalJsFastPath: options.experimentalJsFastPath,
2100
2342
  ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers,
2101
2343
  ignoreTaggedTemplateExpressionIdentifiers: options.ignoreTaggedTemplateExpressionIdentifiers,
2102
2344
  uniAppX: options.uniAppX,
@@ -2165,7 +2407,7 @@ function createJsHandler(options) {
2165
2407
  const resolvedOptions = resolveOptions(classNameSet, options);
2166
2408
  const cached = getCachedJsResult(rawSource, resolvedOptions);
2167
2409
  if (cached) return cached;
2168
- return setCachedJsResult(rawSource, resolvedOptions, jsHandler(rawSource, resolvedOptions));
2410
+ return setCachedJsResult(rawSource, resolvedOptions, oxcJsHandler(rawSource, resolveFastPathOptions(rawSource, resolvedOptions)) ?? jsHandler(rawSource, resolvedOptions));
2169
2411
  }
2170
2412
  return handler;
2171
2413
  }
@@ -4539,7 +4781,7 @@ const DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
4539
4781
  //#endregion
4540
4782
  //#region src/context/runtime-package-replacements.ts
4541
4783
  function resolveRuntimePackageReplacements(option) {
4542
- const mapping = require_v3_engine.resolveBooleanObjectOption(option, DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS);
4784
+ const mapping = require_v4_engine.resolveBooleanObjectOption(option, DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS);
4543
4785
  if (!mapping) return;
4544
4786
  const normalized = {};
4545
4787
  for (const [from, to] of Object.entries(mapping)) {
@@ -4550,38 +4792,74 @@ function resolveRuntimePackageReplacements(option) {
4550
4792
  }
4551
4793
  //#endregion
4552
4794
  //#region src/context/style-options.ts
4553
- function resolveStyleOptionsFromContext(ctx) {
4795
+ function resolveStyleOptionsFromContext(ctx, tailwindcssMajorVersion) {
4554
4796
  const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(ctx.uniAppX);
4797
+ const branch = require_generator.resolveGeneratorRuntimeBranch(require_generator.normalizeWeappTailwindcssGeneratorOptions(ctx.generator, {
4798
+ appType: ctx.appType,
4799
+ platform: ctx.cssOptions?.platform ?? ctx.platform,
4800
+ tailwindcssMajorVersion,
4801
+ uniAppX: resolvedUniAppXOptions
4802
+ }), {
4803
+ appType: ctx.appType,
4804
+ platform: ctx.cssOptions?.platform ?? ctx.platform,
4805
+ tailwindcssMajorVersion,
4806
+ uniAppX: resolvedUniAppXOptions
4807
+ });
4808
+ const hasCssOptions = ctx.cssOptions !== void 0;
4809
+ const cssOptions = {
4810
+ cssPreflight: ctx.cssOptions?.cssPreflight ?? ctx.cssPreflight,
4811
+ cssPreflightRange: ctx.cssOptions?.cssPreflightRange ?? ctx.cssPreflightRange,
4812
+ cssChildCombinatorReplaceValue: ctx.cssOptions?.cssChildCombinatorReplaceValue ?? ctx.cssChildCombinatorReplaceValue,
4813
+ cssSelectorReplacement: ctx.cssOptions?.cssSelectorReplacement ?? ctx.cssSelectorReplacement,
4814
+ rem2rpx: ctx.cssOptions?.rem2rpx ?? ctx.rem2rpx,
4815
+ cssRemoveProperty: ctx.cssOptions?.cssRemoveProperty ?? ctx.cssRemoveProperty,
4816
+ cssRemoveHoverPseudoClass: ctx.cssOptions?.cssRemoveHoverPseudoClass ?? ctx.cssRemoveHoverPseudoClass,
4817
+ tailwindcssV4GradientFallback: ctx.cssOptions?.tailwindcssV4GradientFallback ?? ctx.tailwindcssV4GradientFallback,
4818
+ cssPresetEnv: ctx.cssOptions?.cssPresetEnv ?? ctx.cssPresetEnv,
4819
+ atRules: ctx.cssOptions?.atRules ?? ctx.atRules,
4820
+ autoprefixer: ctx.cssOptions?.autoprefixer ?? ctx.autoprefixer,
4821
+ cssCalc: ctx.cssOptions?.cssCalc ?? ctx.cssCalc,
4822
+ platform: branch.platform ?? ctx.cssOptions?.platform ?? ctx.platform,
4823
+ px2rpx: ctx.cssOptions?.px2rpx ?? ctx.px2rpx,
4824
+ unitsToPx: ctx.cssOptions?.unitsToPx ?? ctx.unitsToPx,
4825
+ unitConversion: ctx.cssOptions?.unitConversion ?? ctx.unitConversion,
4826
+ injectAdditionalCssVarScope: ctx.cssOptions?.injectAdditionalCssVarScope ?? ctx.injectAdditionalCssVarScope
4827
+ };
4555
4828
  return {
4556
- cssPreflight: ctx.cssPreflight,
4557
- cssPreflightRange: ctx.cssPreflightRange,
4558
- cssChildCombinatorReplaceValue: ctx.cssChildCombinatorReplaceValue,
4559
- cssSelectorReplacement: ctx.cssSelectorReplacement,
4560
- rem2rpx: ctx.rem2rpx,
4561
- cssRemoveProperty: ctx.cssRemoveProperty,
4562
- cssRemoveHoverPseudoClass: ctx.cssRemoveHoverPseudoClass,
4563
- cssPresetEnv: ctx.cssPresetEnv,
4564
- autoprefixer: ctx.autoprefixer,
4565
- cssCalc: ctx.cssCalc,
4566
- uniAppX: resolvedUniAppXOptions.enabled,
4567
- platform: ctx.platform,
4568
- px2rpx: ctx.px2rpx,
4569
- unitsToPx: ctx.unitsToPx,
4570
- unitConversion: ctx.unitConversion
4829
+ appType: ctx.appType,
4830
+ cssPreflight: cssOptions.cssPreflight,
4831
+ cssPreflightRange: cssOptions.cssPreflightRange,
4832
+ cssChildCombinatorReplaceValue: cssOptions.cssChildCombinatorReplaceValue,
4833
+ cssSelectorReplacement: cssOptions.cssSelectorReplacement,
4834
+ rem2rpx: cssOptions.rem2rpx,
4835
+ ...hasCssOptions ? { cssOptions } : {},
4836
+ cssRemoveProperty: cssOptions.cssRemoveProperty,
4837
+ cssRemoveHoverPseudoClass: cssOptions.cssRemoveHoverPseudoClass,
4838
+ tailwindcssV4GradientFallback: cssOptions.tailwindcssV4GradientFallback,
4839
+ cssPresetEnv: cssOptions.cssPresetEnv,
4840
+ atRules: cssOptions.atRules,
4841
+ autoprefixer: cssOptions.autoprefixer,
4842
+ cssCalc: cssOptions.cssCalc,
4843
+ uniAppX: branch.isNativeApp,
4844
+ platform: cssOptions.platform,
4845
+ px2rpx: cssOptions.px2rpx,
4846
+ unitsToPx: cssOptions.unitsToPx,
4847
+ unitConversion: cssOptions.unitConversion
4571
4848
  };
4572
4849
  }
4573
4850
  //#endregion
4574
4851
  //#region src/context/handlers.ts
4575
4852
  function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions, tailwindcssMajorVersion) {
4576
- const { escapeMap, injectAdditionalCssVarScope, postcssOptions, uniAppX, arbitraryValues, jsPreserveClass, jsArbitraryValueFallback, babelParserOptions, ignoreCallExpressionIdentifiers, ignoreTaggedTemplateExpressionIdentifiers, inlineWxs, disabledDefaultTemplateHandler, replaceRuntimePackages } = ctx;
4853
+ const { escapeMap, injectAdditionalCssVarScope, postcssOptions, uniAppX, arbitraryValues, jsPreserveClass, jsArbitraryValueFallback, babelParserOptions, experimentalJsFastPath, ignoreCallExpressionIdentifiers, ignoreTaggedTemplateExpressionIdentifiers, inlineWxs, disabledDefaultTemplateHandler, replaceRuntimePackages } = ctx;
4577
4854
  const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(uniAppX);
4578
- const styleOptions = resolveStyleOptionsFromContext(ctx);
4855
+ const styleOptions = resolveStyleOptionsFromContext(ctx, tailwindcssMajorVersion);
4856
+ const resolvedInjectAdditionalCssVarScope = styleOptions.cssOptions?.injectAdditionalCssVarScope ?? injectAdditionalCssVarScope;
4579
4857
  const uniAppXEnabled = styleOptions.uniAppX === true;
4580
4858
  const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
4581
4859
  const styleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
4582
4860
  ...styleOptions,
4583
4861
  escapeMap,
4584
- injectAdditionalCssVarScope,
4862
+ injectAdditionalCssVarScope: resolvedInjectAdditionalCssVarScope,
4585
4863
  postcssOptions,
4586
4864
  uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
4587
4865
  cssCalc: cssCalcOptions,
@@ -4595,6 +4873,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
4595
4873
  tailwindcssMajorVersion,
4596
4874
  generateMap: true,
4597
4875
  babelParserOptions,
4876
+ experimentalJsFastPath,
4598
4877
  ignoreCallExpressionIdentifiers,
4599
4878
  ignoreTaggedTemplateExpressionIdentifiers,
4600
4879
  uniAppX: uniAppXEnabled,
@@ -4626,30 +4905,75 @@ function applyLoggerLevel(logLevel) {
4626
4905
  //#endregion
4627
4906
  //#region src/context/index.ts
4628
4907
  function resolveContextCssPreflight(opts, ctx, majorVersion) {
4629
- const cssPreflight = require_defaults.resolveDefaultCssPreflight(opts?.cssPreflight, majorVersion);
4630
- if (majorVersion !== 4 || cssPreflight === false || !require_tailwindcss.resolveUniAppXOptions(ctx.uniAppX).enabled) return cssPreflight;
4631
- const userCssPreflight = opts?.cssPreflight && typeof opts.cssPreflight === "object" ? opts.cssPreflight : void 0;
4908
+ const userCssPreflight = opts?.cssOptions?.cssPreflight ?? opts?.cssPreflight;
4909
+ const cssPreflight = require_defaults.resolveDefaultCssPreflight(userCssPreflight, majorVersion);
4910
+ if (cssPreflight === false || !require_tailwindcss.resolveUniAppXOptions(ctx.uniAppX).enabled) return cssPreflight;
4911
+ const userCssPreflightObject = userCssPreflight && typeof userCssPreflight === "object" ? userCssPreflight : void 0;
4632
4912
  return {
4633
4913
  ...cssPreflight,
4634
- "border-width": userCssPreflight && "border-width" in userCssPreflight ? cssPreflight["border-width"] ?? false : "0",
4635
- "border-style": userCssPreflight && "border-style" in userCssPreflight ? cssPreflight["border-style"] ?? false : false,
4636
- "border": userCssPreflight && "border" in userCssPreflight ? cssPreflight["border"] ?? false : false
4914
+ "border-width": userCssPreflightObject && "border-width" in userCssPreflightObject ? cssPreflight["border-width"] ?? false : "0",
4915
+ "border-style": userCssPreflightObject && "border-style" in userCssPreflightObject ? cssPreflight["border-style"] ?? false : false,
4916
+ "border": userCssPreflightObject && "border" in userCssPreflightObject ? cssPreflight["border"] ?? false : false
4917
+ };
4918
+ }
4919
+ function syncCssOptionsToLegacyFields(ctx) {
4920
+ if (!ctx.cssOptions) return;
4921
+ const cssOptions = ctx.cssOptions;
4922
+ ctx.cssPreflight = cssOptions.cssPreflight ?? ctx.cssPreflight;
4923
+ ctx.cssPreflightRange = cssOptions.cssPreflightRange ?? ctx.cssPreflightRange;
4924
+ ctx.cssChildCombinatorReplaceValue = cssOptions.cssChildCombinatorReplaceValue ?? ctx.cssChildCombinatorReplaceValue;
4925
+ ctx.cssSelectorReplacement = cssOptions.cssSelectorReplacement ?? ctx.cssSelectorReplacement;
4926
+ ctx.rem2rpx = cssOptions.rem2rpx ?? ctx.rem2rpx;
4927
+ ctx.cssRemoveProperty = cssOptions.cssRemoveProperty ?? ctx.cssRemoveProperty;
4928
+ ctx.cssRemoveHoverPseudoClass = cssOptions.cssRemoveHoverPseudoClass ?? ctx.cssRemoveHoverPseudoClass;
4929
+ ctx.tailwindcssV4GradientFallback = cssOptions.tailwindcssV4GradientFallback ?? ctx.tailwindcssV4GradientFallback;
4930
+ ctx.cssPresetEnv = cssOptions.cssPresetEnv ?? ctx.cssPresetEnv;
4931
+ ctx.atRules = cssOptions.atRules ?? ctx.atRules;
4932
+ ctx.autoprefixer = cssOptions.autoprefixer ?? ctx.autoprefixer;
4933
+ ctx.cssCalc = cssOptions.cssCalc ?? ctx.cssCalc;
4934
+ ctx.platform = cssOptions.platform ?? ctx.platform;
4935
+ ctx.px2rpx = cssOptions.px2rpx ?? ctx.px2rpx;
4936
+ ctx.unitsToPx = cssOptions.unitsToPx ?? ctx.unitsToPx;
4937
+ ctx.unitConversion = cssOptions.unitConversion ?? ctx.unitConversion;
4938
+ ctx.injectAdditionalCssVarScope = cssOptions.injectAdditionalCssVarScope ?? ctx.injectAdditionalCssVarScope;
4939
+ }
4940
+ function syncLegacyFieldsToCssOptions(ctx) {
4941
+ if (!ctx.cssOptions) return;
4942
+ ctx.cssOptions = {
4943
+ ...ctx.cssOptions ?? {},
4944
+ cssPreflight: ctx.cssPreflight,
4945
+ cssPreflightRange: ctx.cssPreflightRange,
4946
+ cssChildCombinatorReplaceValue: ctx.cssChildCombinatorReplaceValue,
4947
+ cssSelectorReplacement: ctx.cssSelectorReplacement,
4948
+ rem2rpx: ctx.rem2rpx,
4949
+ cssRemoveProperty: ctx.cssRemoveProperty,
4950
+ cssRemoveHoverPseudoClass: ctx.cssRemoveHoverPseudoClass,
4951
+ tailwindcssV4GradientFallback: ctx.tailwindcssV4GradientFallback,
4952
+ cssPresetEnv: ctx.cssPresetEnv,
4953
+ atRules: ctx.atRules,
4954
+ autoprefixer: ctx.autoprefixer,
4955
+ cssCalc: ctx.cssCalc,
4956
+ platform: ctx.platform,
4957
+ px2rpx: ctx.px2rpx,
4958
+ unitsToPx: ctx.unitsToPx,
4959
+ unitConversion: ctx.unitConversion,
4960
+ injectAdditionalCssVarScope: ctx.injectAdditionalCssVarScope
4637
4961
  };
4638
4962
  }
4639
- async function clearTailwindcssPatcherCache(patcher, options) {
4640
- if (!patcher) return;
4641
- const cacheOptions = patcher.options?.cache;
4963
+ async function clearTailwindcssRuntimeCache(tailwindRuntime, options) {
4964
+ if (!tailwindRuntime) return;
4965
+ const cacheOptions = tailwindRuntime.options?.cache;
4642
4966
  if (cacheOptions == null || typeof cacheOptions === "object" && cacheOptions.enabled === false) return;
4643
- if (typeof patcher.clearCache === "function") try {
4644
- await patcher.clearCache({ scope: "all" });
4967
+ if (typeof tailwindRuntime.clearCache === "function") try {
4968
+ await tailwindRuntime.clearCache({ scope: "all" });
4645
4969
  } catch (error) {
4646
- _weapp_tailwindcss_logger.logger.debug("failed to clear tailwindcss patcher cache via clearCache(): %O", error);
4970
+ _weapp_tailwindcss_logger.logger.debug("failed to clear tailwindcss runtime cache via clearCache(): %O", error);
4647
4971
  }
4648
4972
  if (!options?.removeDirectory) return;
4649
4973
  const cachePaths = /* @__PURE__ */ new Map();
4650
4974
  const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
4651
4975
  if (normalizedCacheOptions?.path) cachePaths.set(normalizedCacheOptions.path, false);
4652
- const privateCachePath = patcher?.cacheStore?.options?.path;
4976
+ const privateCachePath = tailwindRuntime?.cacheStore?.options?.path;
4653
4977
  if (privateCachePath) cachePaths.set(privateCachePath, false);
4654
4978
  if (options?.removeDirectory && normalizedCacheOptions?.dir) cachePaths.set(normalizedCacheOptions.dir, true);
4655
4979
  if (!cachePaths.size) return;
@@ -4661,39 +4985,41 @@ async function clearTailwindcssPatcherCache(patcher, options) {
4661
4985
  } catch (error) {
4662
4986
  const err = error;
4663
4987
  if (err?.code === "ENOENT") continue;
4664
- _weapp_tailwindcss_logger.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
4988
+ _weapp_tailwindcss_logger.logger.debug("failed to clear tailwindcss runtime cache: %s %O", cachePath, err);
4665
4989
  }
4666
4990
  }
4667
4991
  function createInternalCompilerContext(opts) {
4668
4992
  const ctx = (0, _weapp_tailwindcss_shared.defuOverrideArray)(opts, require_defaults.getDefaultOptions(), {});
4669
4993
  ctx.arbitraryValues = resolveUnocssBareArbitraryValues(ctx.arbitraryValues, ctx.unocss);
4670
4994
  ctx.escapeMap = ctx.customReplaceDictionary;
4995
+ syncCssOptionsToLegacyFields(ctx);
4671
4996
  applyLoggerLevel(ctx.logLevel);
4672
- const twPatcher = require_tailwindcss.createTailwindcssPatcherFromContext(ctx);
4673
- logTailwindcssTarget(twPatcher, ctx.tailwindcssBasedir);
4674
- logRuntimeTailwindcssVersion(ctx.tailwindcssBasedir, twPatcher.packageInfo?.rootPath, twPatcher.packageInfo?.version);
4675
- if (opts?.__internalDeferMissingCssEntriesWarning !== true) require_tailwindcss.warnMissingCssEntries(ctx, twPatcher);
4676
- ctx.cssPreflight = resolveContextCssPreflight(opts, ctx, twPatcher.majorVersion);
4677
- const cssCalcOptions = require_tailwindcss.applyV4CssCalcDefaults(ctx.cssCalc, twPatcher);
4997
+ const tailwindRuntime = require_tailwindcss.createTailwindcssRuntimeFromContext(ctx);
4998
+ logTailwindcssTarget(tailwindRuntime, ctx.tailwindcssBasedir);
4999
+ logRuntimeTailwindcssVersion(ctx.tailwindcssBasedir, tailwindRuntime.packageInfo?.rootPath, tailwindRuntime.packageInfo?.version);
5000
+ if (opts?.__internalDeferMissingCssEntriesWarning !== true) require_tailwindcss.warnMissingCssEntries(ctx, tailwindRuntime);
5001
+ ctx.cssPreflight = resolveContextCssPreflight(opts, ctx, tailwindRuntime.majorVersion);
5002
+ const cssCalcOptions = require_tailwindcss.applyV4CssCalcDefaults(ctx.cssCalc, tailwindRuntime);
4678
5003
  ctx.cssCalc = cssCalcOptions;
4679
- const { styleHandler, jsHandler, templateHandler } = createHandlersFromContext(ctx, toCustomAttributesEntities(ctx.customAttributes), cssCalcOptions, twPatcher.majorVersion);
5004
+ syncLegacyFieldsToCssOptions(ctx);
5005
+ const { styleHandler, jsHandler, templateHandler } = createHandlersFromContext(ctx, toCustomAttributesEntities(ctx.customAttributes), cssCalcOptions, tailwindRuntime.majorVersion);
4680
5006
  ctx.styleHandler = styleHandler;
4681
5007
  ctx.jsHandler = jsHandler;
4682
5008
  ctx.templateHandler = templateHandler;
4683
5009
  ctx.cache = initializeCache(ctx.cache);
4684
- ctx.twPatcher = twPatcher;
4685
- const refreshTailwindcssPatcher = async (options) => {
4686
- const previousPatcher = ctx.twPatcher;
4687
- if (options?.clearCache !== false) await clearTailwindcssPatcherCache(previousPatcher);
4688
- require_v3_engine.invalidateRuntimeClassSet(previousPatcher);
4689
- const nextPatcher = require_tailwindcss.createTailwindcssPatcherFromContext(ctx);
4690
- Object.assign(previousPatcher, nextPatcher);
4691
- ctx.twPatcher = previousPatcher;
4692
- return previousPatcher;
5010
+ ctx.tailwindRuntime = tailwindRuntime;
5011
+ const refreshTailwindcssRuntime = async (options) => {
5012
+ const previousRuntime = ctx.tailwindRuntime;
5013
+ if (options?.clearCache !== false) await clearTailwindcssRuntimeCache(previousRuntime);
5014
+ require_tailwindcss.invalidateRuntimeClassSet(previousRuntime);
5015
+ const nextRuntime = require_tailwindcss.createTailwindcssRuntimeFromContext(ctx);
5016
+ Object.assign(previousRuntime, nextRuntime);
5017
+ ctx.tailwindRuntime = previousRuntime;
5018
+ return previousRuntime;
4693
5019
  };
4694
- ctx.refreshTailwindcssPatcher = refreshTailwindcssPatcher;
4695
- Object.defineProperty(ctx.twPatcher, refreshTailwindcssPatcherSymbol, {
4696
- value: refreshTailwindcssPatcher,
5020
+ ctx.refreshTailwindcssRuntime = refreshTailwindcssRuntime;
5021
+ Object.defineProperty(ctx.tailwindRuntime, refreshTailwindcssRuntimeSymbol, {
5022
+ value: refreshTailwindcssRuntime,
4697
5023
  configurable: true
4698
5024
  });
4699
5025
  return ctx;
@@ -4707,29 +5033,6 @@ function getCompilerContext(opts) {
4707
5033
  return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
4708
5034
  }
4709
5035
  //#endregion
4710
- //#region src/js/precheck.ts
4711
- /** 用于检测源码中是否包含类名相关模式的正则表达式 */
4712
- 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)-/;
4713
- /** 用于检测源码中是否包含 import/export/require 语句的正则表达式 */
4714
- const DEPENDENCY_HINT_RE = /\bimport\s*[("'`{*]|\brequire\s*\(|\bexport\s+\*\s+from\s+["'`]|\bexport\s*\{[^}]*\}\s*from\s+["'`]/;
4715
- /**
4716
- * 判断是否可以跳过 JS 转换。
4717
- * 通过正则快速检测源码内容,避免不必要的 Babel AST 解析。
4718
- *
4719
- * @param rawSource - 原始 JS 源码字符串
4720
- * @param options - 可选的 JS 处理器配置选项
4721
- * @returns 如果可以跳过转换返回 `true`,否则返回 `false`
4722
- */
4723
- function shouldSkipJsTransform(rawSource, options) {
4724
- if (node_process.default.env["WEAPP_TW_DISABLE_JS_PRECHECK"] === "1") return false;
4725
- if (!rawSource) return true;
4726
- if (options?.alwaysEscape) return false;
4727
- if (options?.moduleSpecifierReplacements && Object.keys(options.moduleSpecifierReplacements).length > 0) return false;
4728
- if (options?.wrapExpression) return false;
4729
- if (DEPENDENCY_HINT_RE.test(rawSource)) return false;
4730
- return !FAST_JS_TRANSFORM_HINT_RE.test(rawSource);
4731
- }
4732
- //#endregion
4733
5036
  Object.defineProperty(exports, "JsTokenUpdater", {
4734
5037
  enumerable: true,
4735
5038
  get: function() {
@@ -4772,6 +5075,12 @@ Object.defineProperty(exports, "createAttributeMatcher", {
4772
5075
  return createAttributeMatcher;
4773
5076
  }
4774
5077
  });
5078
+ Object.defineProperty(exports, "createDebug", {
5079
+ enumerable: true,
5080
+ get: function() {
5081
+ return createDebug;
5082
+ }
5083
+ });
4775
5084
  Object.defineProperty(exports, "createTailwindRuntimeReadyPromise", {
4776
5085
  enumerable: true,
4777
5086
  get: function() {