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,17 +1,16 @@
1
1
  const require_chunk = require("./chunk-emK7D4bc.js");
2
- const require_v3_engine = require("./v3-engine-CQE5JJNZ.js");
3
- const require_generator = require("./generator-Cb1Zp3Al.js");
4
- const require_precheck = require("./precheck-30zNPRlI.js");
5
- const require_tailwindcss = require("./tailwindcss-Clpkz1oR.js");
6
- let node_module = require("node:module");
7
- let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
8
- let lru_cache = require("lru-cache");
9
- 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
+ const require_context = require("./context-BHxLe743.js");
5
+ const require_tailwindcss = require("./tailwindcss-DHIYcqXT.js");
10
6
  let node_fs = require("node:fs");
11
7
  let node_path = require("node:path");
12
8
  node_path = require_chunk.__toESM(node_path);
13
9
  let node_process = require("node:process");
14
10
  node_process = require_chunk.__toESM(node_process);
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");
15
14
  let node_fs_promises = require("node:fs/promises");
16
15
  let _weapp_core_escape = require("@weapp-core/escape");
17
16
  let _weapp_tailwindcss_shared_node = require("@weapp-tailwindcss/shared/node");
@@ -64,7 +63,7 @@ function createCssTokenSourceMap(sourcesByToken, opts) {
64
63
  sources: [...sources].map((file) => normalizeSourcePath(file, root)).sort()
65
64
  };
66
65
  tokenSources.set(token, source);
67
- const escaped = require_precheck.replaceWxml(token, { escapeMap: opts.escapeMap });
66
+ const escaped = require_context.replaceWxml(token, { escapeMap: opts.escapeMap });
68
67
  tokenSources.set(escaped, source);
69
68
  tokenSources.set(escaped.replaceAll("\\", ""), source);
70
69
  }
@@ -105,6 +104,9 @@ function removeTracedTailwindGeneratedContainerRules(root) {
105
104
  rule.remove();
106
105
  });
107
106
  }
107
+ function normalizeTraceCommentBefore(value) {
108
+ return value?.includes("\n") ? value : "\n";
109
+ }
108
110
  function annotateCssSourceTrace(css, options) {
109
111
  if (!isCssSourceTraceEnabled(options.opts) || !options.tokenSources?.size) return css;
110
112
  try {
@@ -119,7 +121,7 @@ function annotateCssSourceTrace(css, options) {
119
121
  return `${token} <= ${sources.length > 0 ? sources.join(", ") : "<tailwind generated>"}`;
120
122
  });
121
123
  const comment = _weapp_tailwindcss_postcss.postcss.comment({ text: `tokens: ${lines.join(" | ")}` });
122
- if (rule.raws.before !== void 0) comment.raws.before = rule.raws.before;
124
+ comment.raws.before = normalizeTraceCommentBefore(rule.raws.before);
123
125
  rule.raws.before = "\n";
124
126
  rule.parent.insertBefore(rule, comment);
125
127
  });
@@ -131,12 +133,15 @@ function annotateCssSourceTrace(css, options) {
131
133
  }
132
134
  //#endregion
133
135
  //#region src/bundlers/shared/generator-css/generation-helpers.ts
134
- function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight, options = {}) {
136
+ function hasMiniProgramTailwindV4PreflightReset(css) {
137
+ return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\bborder\s*:\s*0\s+solid\b/.test(css);
138
+ }
139
+ function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
135
140
  if (target !== "weapp") return css;
136
141
  return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
137
- cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
138
- isTailwindcssV4: majorVersion === 4,
139
- preservePseudoContentInit: majorVersion === 3
142
+ cssPreflight: options.injectPreflight !== false && !hasMiniProgramTailwindV4PreflightReset(css) ? cssPreflight : void 0,
143
+ isTailwindcssV4: true,
144
+ tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
140
145
  });
141
146
  }
142
147
  function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
@@ -145,36 +150,43 @@ function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
145
150
  return require_tailwindcss.isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
146
151
  }
147
152
  function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
148
- if (options.isolateCssSource && options.currentCssCandidates?.length) return new Set([...scopedRuntime, ...options.currentCssCandidates]);
149
- if (runtime.size === 0 || !options.cssHandlerOptions.isMainChunk || options.matchedCssSourceFile || options.isolateCssSource && scopedRuntime.size === 0) return scopedRuntime;
153
+ if (options.isolateCssSource) {
154
+ if (options.matchedCssSourceFile) return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
155
+ return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
156
+ }
157
+ if (runtime.size === 0 || !options.cssHandlerOptions.isMainChunk) return scopedRuntime;
150
158
  return new Set([...scopedRuntime, ...runtime]);
151
159
  }
152
- function shouldIsolateScopedCssSource(source, sourceEntries) {
153
- return Boolean(source.__weappTailwindcssMeta?.matchedCssSourceFile) || sourceEntries !== void 0 && sourceEntries.length > 0;
160
+ function shouldIsolateScopedCssSource(_majorVersion, source, sourceEntries, options) {
161
+ if (options.target !== "weapp") return false;
162
+ if (source.__weappTailwindcssMeta?.isolateCssSource) return true;
163
+ if (source.__weappTailwindcssMeta?.matchedCssSourceFile && (sourceEntries?.length ?? 0) > 0) return true;
164
+ if (sourceEntries?.length === 0) return false;
165
+ return sourceEntries !== void 0 && options.cssHandlerOptions?.isMainChunk !== true;
154
166
  }
155
- function shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, options) {
156
- return majorVersion === 4 && !cssHandlerOptions.isMainChunk && require_v3_engine.hasTailwindApplyDirective(options.rawSource) && !require_v3_engine.hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
167
+ function shouldIsolateCurrentTailwindV4CssCandidates(_majorVersion, cssHandlerOptions, options) {
168
+ return !cssHandlerOptions.isMainChunk && require_v4_engine.hasTailwindApplyDirective(options.rawSource) && !require_v4_engine.hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
157
169
  }
158
170
  function shouldScanTailwindV4Sources(majorVersion, target, generatorRuntime, isolateCssSource) {
159
- if (majorVersion !== 4) return false;
171
+ if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
160
172
  if (target === "web") return true;
161
173
  if (isolateCssSource) return false;
162
174
  return generatorRuntime.size === 0;
163
175
  }
164
- function shouldAppendWebBundleCssFallback(target, options) {
165
- return target === "web" && !options.hasMatchedCssSourceFile && !options.hasSourceDirectives;
176
+ function shouldAppendWebBundleCssFallback(target, _options) {
177
+ return target === "web";
166
178
  }
167
179
  function isEmptyCssSourceOrderParts(parts) {
168
180
  return parts.before.trim().length === 0 && parts.after.trim().length === 0;
169
181
  }
170
182
  function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
183
+ const resolvedStyleOptions = require_context.resolveStyleOptionsFromContext(opts);
171
184
  const preflightStyleOptions = {
172
- cssPreflight: opts.cssPreflight,
173
- cssPreflightRange: opts.cssPreflightRange
185
+ cssPreflight: resolvedStyleOptions.cssPreflight,
186
+ cssPreflightRange: resolvedStyleOptions.cssPreflightRange
174
187
  };
175
188
  return {
176
- ...require_precheck.resolveStyleOptionsFromContext(opts),
177
- atRules: opts.atRules,
189
+ ...resolvedStyleOptions,
178
190
  uniAppXCssTarget: opts.uniAppXCssTarget,
179
191
  uniAppXUnsupported: opts.uniAppXUnsupported,
180
192
  ...cssHandlerOptions,
@@ -192,15 +204,17 @@ function shouldFinalizeMarkedUserLayerComponentsCss(file) {
192
204
  return !/\.(?:vue|svelte|astro|scss|sass|less|styl)(?:[?#].*)?$/i.test(file);
193
205
  }
194
206
  function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
195
- const placeholderParts = require_v3_engine.splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
207
+ const placeholderParts = require_v4_engine.splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
196
208
  if (placeholderParts) return placeholderParts;
197
- const exactParts = require_v3_engine.splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss);
209
+ const exactParts = require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss);
198
210
  if (exactParts) return exactParts;
199
- return require_v3_engine.splitTailwindGeneratedCssByBanner(rawSource);
211
+ return require_v4_engine.splitTailwindGeneratedCssByBanner(rawSource);
200
212
  }
201
- function shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, options) {
202
- const hasApplyDirectives = require_v3_engine.hasTailwindApplyDirective(options.rawSource);
203
- return options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives || majorVersion === 4 && hasApplyDirectives || cssHandlerOptions.isMainChunk;
213
+ function shouldUseGeneratorForCurrentCss(_majorVersion, cssHandlerOptions, options) {
214
+ const hasApplyDirectives = require_v4_engine.hasTailwindApplyDirective(options.rawSource);
215
+ const sourceCss = cssHandlerOptions.sourceOptions?.sourceCss;
216
+ const hasSourceCssDirectives = typeof sourceCss === "string" && (require_v4_engine.hasTailwindRootDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(sourceCss));
217
+ return options.forceGenerator === true || options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives || hasApplyDirectives || hasSourceCssDirectives;
204
218
  }
205
219
  function createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates) {
206
220
  return isolateCurrentCssCandidates ? new Set(currentCssCandidates) : currentCssCandidates.length > 0 ? new Set([...runtime, ...currentCssCandidates]) : runtime;
@@ -222,10 +236,6 @@ function mergeGeneratorResults(generatedResults) {
222
236
  sources: generatedResults.flatMap((item) => item.sources)
223
237
  };
224
238
  }
225
- const SUPPORTED_GENERATOR_MAJOR_VERSIONS$1 = new Set([3, 4]);
226
- function isSupportedGeneratorMajorVersion(majorVersion) {
227
- return SUPPORTED_GENERATOR_MAJOR_VERSIONS$1.has(majorVersion ?? 0);
228
- }
229
239
  //#endregion
230
240
  //#region src/bundlers/shared/generator-css/legacy-selectors.ts
231
241
  const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
@@ -282,7 +292,7 @@ function escapeCompatSelectorClasses(selector) {
282
292
  end += 1;
283
293
  }
284
294
  if (className.includes("\\")) {
285
- result += `.${require_precheck.replaceWxml(unescapeSimpleCssIdent(className))}`;
295
+ result += `.${require_context.replaceWxml(unescapeSimpleCssIdent(className))}`;
286
296
  changed = true;
287
297
  } else result += `.${className}`;
288
298
  index = end;
@@ -375,6 +385,21 @@ function collectGeneratedDeclarationPropsBySelector(generatedCss, selectors) {
375
385
  }
376
386
  return propsBySelector;
377
387
  }
388
+ function isRuleCoveredByGeneratedProps(rule, generatedDeclarationPropsBySelector) {
389
+ const nodeSelectors = getRuleCompatSelectorKeys(rule);
390
+ if (nodeSelectors.length === 0) return false;
391
+ const props = /* @__PURE__ */ new Set();
392
+ rule.walkDecls((decl) => {
393
+ props.add(decl.prop);
394
+ });
395
+ if (props.size === 0) return false;
396
+ for (const selector of nodeSelectors) {
397
+ const generatedProps = generatedDeclarationPropsBySelector.get(selector);
398
+ if (!generatedProps) continue;
399
+ if ([...props].every((prop) => generatedProps.has(prop))) return true;
400
+ }
401
+ return false;
402
+ }
378
403
  function removeGeneratedSelectorCompatCss(css, generatedCss) {
379
404
  const generatedSelectors = collectGeneratedSelectors(generatedCss);
380
405
  if (generatedSelectors.size === 0) return css;
@@ -415,6 +440,7 @@ function collectDedupedPostTransformCompatCss(css, generatedCss) {
415
440
  preservedNodes.push(node.clone());
416
441
  return;
417
442
  }
443
+ if (isRuleCoveredByGeneratedProps(node, generatedDeclarationPropsBySelector)) return;
418
444
  if (isCustomPropertyOnlyRule(node) && !isPseudoContentInitRule(node) && !hasUtilityClassSelector(node.selector)) {
419
445
  const declarationProps = /* @__PURE__ */ new Set();
420
446
  node.walkDecls((decl) => {
@@ -444,13 +470,23 @@ function collectDedupedPostTransformCompatCss(css, generatedCss) {
444
470
  }
445
471
  }
446
472
  function removeDuplicatedViteMarkers(css, baseCss) {
447
- if (!require_v3_engine.VITE_MARKER_RE.test(baseCss)) return css;
448
- require_v3_engine.VITE_MARKER_RE.lastIndex = 0;
449
- return css.replace(require_v3_engine.VITE_MARKER_RE, "");
473
+ if (!require_v4_engine.VITE_MARKER_RE.test(baseCss)) return css;
474
+ require_v4_engine.VITE_MARKER_RE.lastIndex = 0;
475
+ return css.replace(require_v4_engine.VITE_MARKER_RE, "");
450
476
  }
451
477
  //#endregion
452
478
  //#region src/bundlers/shared/generator-css/source-files.ts
453
479
  const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
480
+ const STYLE_IMPORT_EXTENSIONS = [
481
+ ".css",
482
+ ".scss",
483
+ ".sass",
484
+ ".less",
485
+ ".styl",
486
+ ".stylus",
487
+ ".pcss",
488
+ ".postcss"
489
+ ];
454
490
  function stripStyleExtension(file) {
455
491
  const normalized = file.replace(/[?#].*$/, "");
456
492
  const ext = node_path.default.extname(normalized);
@@ -552,98 +588,135 @@ function extractStyleDirectiveSources(source) {
552
588
  let match = SFC_STYLE_BLOCK_RE.exec(source);
553
589
  while (match !== null) {
554
590
  const styleSource = match[1] ?? "";
555
- if (require_v3_engine.hasTailwindSourceDirectives(styleSource)) styleSources.push(styleSource);
591
+ if (require_v4_engine.hasTailwindSourceDirectives(styleSource, { importFallback: true })) styleSources.push(styleSource);
556
592
  match = SFC_STYLE_BLOCK_RE.exec(source);
557
593
  }
558
594
  if (styleSources.length > 0) return styleSources;
559
- return require_v3_engine.hasTailwindSourceDirectives(source) ? [source] : [];
595
+ return require_v4_engine.hasTailwindSourceDirectives(source, { importFallback: true }) ? [source] : [];
560
596
  }
561
- function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {}) {
562
- for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) {
563
- if (!(0, node_fs.existsSync)(sourceFile)) continue;
597
+ function extractSfcStyleSources(source) {
598
+ const styleSources = [];
599
+ SFC_STYLE_BLOCK_RE.lastIndex = 0;
600
+ let match = SFC_STYLE_BLOCK_RE.exec(source);
601
+ while (match !== null) {
602
+ styleSources.push(match[1] ?? "");
603
+ match = SFC_STYLE_BLOCK_RE.exec(source);
604
+ }
605
+ return styleSources;
606
+ }
607
+ function isLocalStyleImportRequest(request) {
608
+ return typeof request === "string" && request.length > 0 && (request.startsWith(".") || request.startsWith("/"));
609
+ }
610
+ function resolveLocalStyleImportFile(request, base) {
611
+ const normalized = (node_path.default.isAbsolute(request) ? request : node_path.default.resolve(base, request)).replace(/[?#].*$/, "");
612
+ if ((0, node_fs.existsSync)(normalized)) return normalized;
613
+ if (node_path.default.extname(normalized)) return;
614
+ for (const extension of STYLE_IMPORT_EXTENSIONS) {
615
+ const candidate = `${normalized}${extension}`;
616
+ if ((0, node_fs.existsSync)(candidate)) return candidate;
617
+ }
618
+ }
619
+ function collectLocalStyleImportFiles(source, base) {
620
+ const files = [];
621
+ const sources = extractSfcStyleSources(source);
622
+ if (sources.length === 0) sources.push(source);
623
+ for (const styleSource of sources) try {
624
+ _weapp_tailwindcss_postcss.postcss.parse(styleSource).walkAtRules("import", (rule) => {
625
+ const request = require_v4_engine.parseImportRequest(rule.params);
626
+ if (!isLocalStyleImportRequest(request)) return;
627
+ const file = resolveLocalStyleImportFile(request, base);
628
+ if (file) files.push(file);
629
+ });
630
+ } catch {}
631
+ return files;
632
+ }
633
+ function extractStyleDirectiveSourcesDeep(source, sourceFile, seen) {
634
+ const ownSources = extractStyleDirectiveSources(source);
635
+ if (ownSources.length > 0) return ownSources.map((styleSource) => ({
636
+ source: styleSource,
637
+ file: sourceFile
638
+ }));
639
+ const sources = [];
640
+ const base = node_path.default.dirname(sourceFile);
641
+ for (const importedFile of collectLocalStyleImportFiles(source, base)) {
642
+ const normalizedImportedFile = node_path.default.resolve(importedFile);
643
+ if (seen.has(normalizedImportedFile)) continue;
644
+ seen.add(normalizedImportedFile);
564
645
  try {
565
- const source = (0, node_fs.readFileSync)(sourceFile, "utf8");
566
- for (const styleSource of extractStyleDirectiveSources(source)) {
567
- const cssEntrySource = require_v3_engine.resolveCssEntrySource(styleSource, node_path.default.dirname(sourceFile), resolveOptions);
568
- if (cssEntrySource) return {
569
- ...cssEntrySource,
570
- file: sourceFile
571
- };
572
- }
573
- } catch {
574
- continue;
646
+ const importedSource = (0, node_fs.readFileSync)(normalizedImportedFile, "utf8");
647
+ sources.push(...extractStyleDirectiveSourcesDeep(importedSource, normalizedImportedFile, seen));
648
+ } catch {}
649
+ }
650
+ return sources;
651
+ }
652
+ function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {}) {
653
+ for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) try {
654
+ const source = sourceOptions.sourceFile && node_path.default.resolve(sourceOptions.sourceFile) === node_path.default.resolve(sourceFile) && typeof sourceOptions.sourceCss === "string" ? sourceOptions.sourceCss : (0, node_fs.existsSync)(sourceFile) ? (0, node_fs.readFileSync)(sourceFile, "utf8") : void 0;
655
+ if (source === void 0) continue;
656
+ const directiveSources = extractStyleDirectiveSourcesDeep(source, sourceFile, new Set([node_path.default.resolve(sourceFile)]));
657
+ for (const styleSource of directiveSources) {
658
+ const cssEntrySource = require_v4_engine.resolveCssEntrySource(styleSource.source, node_path.default.dirname(styleSource.file), resolveOptions);
659
+ if (cssEntrySource) return {
660
+ ...cssEntrySource,
661
+ file: styleSource.file
662
+ };
575
663
  }
664
+ } catch {
665
+ continue;
576
666
  }
577
667
  }
578
668
  //#endregion
579
- //#region src/bundlers/shared/generator-css/source-resolver.ts
580
- function resolvePostcssFromOption(cssHandlerOptions) {
581
- const from = cssHandlerOptions.postcssOptions?.options?.from;
582
- return typeof from === "string" && from.length > 0 ? from : void 0;
583
- }
584
- function resolvePostcssSourceFile(cssHandlerOptions) {
585
- const from = resolvePostcssFromOption(cssHandlerOptions);
586
- if (!from || !node_path.default.isAbsolute(from)) return;
587
- return from.replace(/[?#].*$/, "");
588
- }
589
- function resolveCssHandlerSourceOptions(cssHandlerOptions) {
590
- return cssHandlerOptions.sourceOptions;
591
- }
592
- function createCssEntrySources(cssEntries) {
593
- return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && node_path.default.isAbsolute(entry)).map((entry) => ({ file: node_path.default.resolve(entry) }));
669
+ //#region src/bundlers/shared/generator-css/source-resolver/apply-reference.ts
670
+ function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
671
+ return createTailwindV4SourceReferenceSource(css, sourceOptions);
594
672
  }
595
- function mergeCssSources(cssSources, cssEntrySources) {
596
- const merged = [];
597
- const seenFiles = /* @__PURE__ */ new Set();
598
- const addSource = (cssSource) => {
599
- const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? node_path.default.resolve(cssSource.file) : void 0;
600
- if (file) {
601
- if (seenFiles.has(file)) return;
602
- seenFiles.add(file);
603
- }
604
- merged.push(cssSource);
605
- };
606
- for (const cssSource of cssSources ?? []) addSource(cssSource);
607
- for (const cssSource of cssEntrySources ?? []) addSource(cssSource);
608
- return merged.length > 0 ? merged : void 0;
673
+ function createTailwindV4SourceReferenceSource(css, sourceOptions) {
674
+ if (hasTailwindV4RootImport(css, sourceOptions)) return css;
675
+ const hasApplyDirective = require_v4_engine.hasTailwindApplyDirective(css);
676
+ if (!hasApplyDirective && !require_v4_engine.hasTailwindSourceDirectives(css, { importFallback: true })) return css;
677
+ const utilities = hasApplyDirective ? collectTailwindApplyUtilities(css) : [];
678
+ return [
679
+ `@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
680
+ utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
681
+ css
682
+ ].filter(Boolean).join("\n");
609
683
  }
610
- function createSingleTailwindV4SourceOptions(sourceOptions, options) {
611
- return require_v3_engine.omitUndefined({
612
- projectRoot: sourceOptions.projectRoot,
613
- baseFallbacks: sourceOptions.baseFallbacks,
614
- packageName: sourceOptions.packageName,
615
- base: options.base,
616
- css: options.css
617
- });
684
+ function hasTailwindV4RootImport(css, sourceOptions) {
685
+ try {
686
+ const root = _weapp_tailwindcss_postcss.postcss.parse(css);
687
+ let found = false;
688
+ root.walkAtRules((rule) => {
689
+ if (rule.name === "tailwind") {
690
+ found = true;
691
+ return false;
692
+ }
693
+ if (rule.name !== "import" && rule.name !== "use" && rule.name !== "forward") return;
694
+ const request = require_v4_engine.parseImportRequest(rule.params);
695
+ if (request === (sourceOptions.packageName ?? "tailwindcss") || request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/")) {
696
+ found = true;
697
+ return false;
698
+ }
699
+ });
700
+ return found;
701
+ } catch {
702
+ return /@(?:import|use|forward|tailwind)(?:[\s"'(;]|$)/.test(css) && (css.includes("tailwindcss") || css.includes("tailwindcss4") || css.includes("weapp-tailwindcss"));
703
+ }
618
704
  }
619
- async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
620
- const { cssEntries: _cssEntries, cssSources: _cssSources, ...singleEntrySourceOptions } = sourceOptions;
621
- if (!(0, node_fs.existsSync)(cssEntry)) return require_v3_engine.resolveTailwindV4Source({
622
- ...require_v3_engine.omitUndefined(singleEntrySourceOptions),
623
- cssEntries: [cssEntry]
624
- });
625
- const css = (0, node_fs.readFileSync)(cssEntry, "utf8");
626
- const base = node_path.default.dirname(node_path.default.resolve(cssEntry));
627
- const entrySource = require_v3_engine.resolveCssEntrySource(css, base, { removeConfig: false });
628
- const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, cssEntry, {
629
- ...sourceOptions,
630
- sourceFile: sourceOptions.sourceFile ?? cssEntry
631
- });
632
- return withGeneratorSourceMetadata(await require_v3_engine.resolveTailwindV4Source({
633
- ...require_v3_engine.omitUndefined(singleEntrySourceOptions),
634
- base,
635
- css: require_v3_engine.normalizeConfigDirective(css, config),
636
- cssEntries: [cssEntry]
637
- }), {
638
- matchedCssSourceFile: cssEntry,
639
- sourceBase: base,
640
- sourceCss: css
705
+ function collectTailwindApplyUtilities(css) {
706
+ let root;
707
+ try {
708
+ root = _weapp_tailwindcss_postcss.postcss.parse(css);
709
+ } catch {
710
+ return [];
711
+ }
712
+ const utilities = /* @__PURE__ */ new Set();
713
+ root.walkAtRules("apply", (rule) => {
714
+ for (const utility of (0, _tailwindcss_mangle_engine.splitCandidateTokens)(rule.params)) utilities.add(utility);
641
715
  });
716
+ return [...utilities].sort();
642
717
  }
643
- function resolveCssSourceBase(file, cssHandlerOptions) {
644
- const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
645
- return node_path.default.dirname(node_path.default.resolve(normalized));
646
- }
718
+ //#endregion
719
+ //#region src/bundlers/shared/generator-css/source-resolver/config.ts
647
720
  function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
648
721
  if (config && (0, node_fs.existsSync)(config)) return config;
649
722
  if (!configRequest || node_path.default.isAbsolute(configRequest)) return sourceOptions.config;
@@ -670,26 +743,10 @@ function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
670
743
  for (const candidate of configCandidates) if ((0, node_fs.existsSync)(candidate)) return candidate;
671
744
  return sourceOptions.config;
672
745
  }
673
- function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
674
- const from = resolvePostcssFromOption(cssHandlerOptions);
675
- if (!from || !node_path.default.isAbsolute(from)) return node_path.default.isAbsolute(file) || Boolean(sourceOptions?.sourceFile) || Boolean(sourceOptions?.cssSources?.length);
676
- return true;
677
- }
678
- function shouldResolveSourceSideCssEntry(rawSource) {
679
- return rawSource.includes("@apply") || require_v3_engine.hasTailwindRootDirectives(rawSource, { importFallback: true }) || require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true }) || require_v3_engine.hasTailwindGeneratedCss(rawSource) || require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource);
680
- }
681
- function shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) {
682
- return Boolean(sourceSideEntrySource) && !require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true });
683
- }
684
- function shouldPreferResolvedSourceSideEntry(cssEntrySource, sourceSideEntrySource) {
685
- return Boolean(sourceSideEntrySource?.config) && Boolean(cssEntrySource?.configRequest) && (!cssEntrySource?.config || !(0, node_fs.existsSync)(cssEntrySource.config));
686
- }
746
+ //#endregion
747
+ //#region src/bundlers/shared/generator-css/source-resolver/matching.ts
687
748
  function normalizeCssSourceForCompare(css) {
688
- return require_v3_engine.stripGeneratorPlaceholderMarkers(require_v3_engine.stripTailwindBanners(css)).trim();
689
- }
690
- function getOutputFileStem(file) {
691
- const normalized = file.replace(/[?#].*$/, "");
692
- return node_path.default.basename(normalized, node_path.default.extname(normalized));
749
+ return require_v4_engine.stripGeneratorPlaceholderMarkers(require_v4_engine.stripTailwindBanners(css)).trim();
693
750
  }
694
751
  function getOutputFileWithoutExtension(file) {
695
752
  const normalized = file.replace(/[?#].*$/, "");
@@ -699,6 +756,12 @@ function getOutputFileWithoutExtension(file) {
699
756
  function normalizeMatchPath(file) {
700
757
  return file.split(node_path.default.sep).join("/");
701
758
  }
759
+ function stripBundlerContentHash(name) {
760
+ return name.replace(/[._-]?[a-f0-9]{6,32}$/i, "");
761
+ }
762
+ function getMatchBasename(file) {
763
+ return stripBundlerContentHash(node_path.default.basename(getOutputFileWithoutExtension(file.replace(/[?#].*$/, ""))));
764
+ }
702
765
  function isPathWithinRoot(file, root) {
703
766
  const relative = node_path.default.relative(root, file);
704
767
  return Boolean(relative) && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
@@ -708,11 +771,7 @@ function collectCssSourceMatchBases(file, roots) {
708
771
  const bases = /* @__PURE__ */ new Set();
709
772
  const addBase = (candidate) => {
710
773
  const base = normalizeMatchPath(getOutputFileWithoutExtension(candidate));
711
- if (base.length > 0) {
712
- bases.add(base);
713
- const withoutWorkspaceSegment = base.replace(/^(?:src|dist)\//, "");
714
- if (withoutWorkspaceSegment !== base && withoutWorkspaceSegment.length > 0) bases.add(withoutWorkspaceSegment);
715
- }
774
+ if (base.length > 0) bases.add(base);
716
775
  };
717
776
  addBase(normalizedFile);
718
777
  const resolvedRoots = roots.filter((root) => typeof root === "string" && root.length > 0).map((root) => node_path.default.resolve(root));
@@ -728,17 +787,121 @@ function scoreTailwindV4CssSourceFileMatch(file, cssSourceFile, sourceOptions) {
728
787
  sourceOptions.cwd
729
788
  ]);
730
789
  const sourceBases = collectCssSourceMatchBases(cssSourceFile, [sourceOptions.projectRoot, sourceOptions.cwd]);
790
+ const outputBasename = getMatchBasename(file);
791
+ const sourceBasename = getMatchBasename(cssSourceFile);
731
792
  let bestScore = 0;
732
793
  for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
733
794
  else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
734
795
  else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
796
+ if (outputBasename && outputBasename === sourceBasename) bestScore = Math.max(bestScore, 100 + outputBasename.length);
735
797
  return bestScore;
736
798
  }
799
+ //#endregion
800
+ //#region src/bundlers/shared/generator-css/source-resolver/metadata.ts
801
+ function withGeneratorSourceMetadata(source, metadata) {
802
+ return {
803
+ ...source,
804
+ __weappTailwindcssMeta: metadata
805
+ };
806
+ }
807
+ function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
808
+ return resolvedEntrySource.file ? withGeneratorSourceMetadata(source, {
809
+ isolateCssSource: true,
810
+ matchedCssSourceFile: resolvedEntrySource.file,
811
+ sourceBase: resolvedEntrySource.base,
812
+ sourceCss: resolvedEntrySource.css
813
+ }) : source;
814
+ }
815
+ //#endregion
816
+ //#region src/bundlers/shared/generator-css/source-resolver/postcss-source.ts
817
+ function resolvePostcssFromOption(cssHandlerOptions) {
818
+ const from = cssHandlerOptions.postcssOptions?.options?.from;
819
+ return typeof from === "string" && from.length > 0 ? from : void 0;
820
+ }
821
+ function resolvePostcssSourceFile(cssHandlerOptions) {
822
+ const from = resolvePostcssFromOption(cssHandlerOptions);
823
+ if (!from || !node_path.default.isAbsolute(from)) return;
824
+ return from.replace(/[?#].*$/, "");
825
+ }
826
+ function resolveCssHandlerSourceOptions(cssHandlerOptions) {
827
+ return cssHandlerOptions.sourceOptions;
828
+ }
829
+ function resolveCssSourceBase(file, cssHandlerOptions) {
830
+ const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
831
+ return node_path.default.dirname(node_path.default.resolve(normalized));
832
+ }
833
+ //#endregion
834
+ //#region src/bundlers/shared/generator-css/source-resolver.ts
835
+ function createCssEntrySources(cssEntries) {
836
+ return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && node_path.default.isAbsolute(entry)).map((entry) => ({ file: node_path.default.resolve(entry) }));
837
+ }
838
+ function mergeCssSources(cssSources, cssEntrySources) {
839
+ const merged = [];
840
+ const fileIndex = /* @__PURE__ */ new Map();
841
+ const addSource = (cssSource) => {
842
+ const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? node_path.default.resolve(cssSource.file) : void 0;
843
+ if (file) {
844
+ const previousIndex = fileIndex.get(file);
845
+ if (previousIndex !== void 0) {
846
+ if (typeof merged[previousIndex]?.css !== "string" && typeof cssSource.css === "string") merged[previousIndex] = cssSource;
847
+ return;
848
+ }
849
+ fileIndex.set(file, merged.length);
850
+ }
851
+ merged.push(cssSource);
852
+ };
853
+ for (const cssSource of cssSources ?? []) addSource(cssSource);
854
+ for (const cssSource of cssEntrySources ?? []) addSource(cssSource);
855
+ return merged.length > 0 ? merged : void 0;
856
+ }
857
+ function createSingleTailwindV4SourceOptions(sourceOptions, options) {
858
+ return require_v4_engine.omitUndefined({
859
+ projectRoot: sourceOptions.projectRoot,
860
+ baseFallbacks: sourceOptions.baseFallbacks,
861
+ packageName: sourceOptions.packageName,
862
+ base: options.base,
863
+ css: options.css
864
+ });
865
+ }
866
+ async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
867
+ const { cssEntries: _cssEntries, cssSources: _cssSources, ...singleEntrySourceOptions } = sourceOptions;
868
+ if (!(0, node_fs.existsSync)(cssEntry)) return require_v4_engine.resolveTailwindV4Source({
869
+ ...require_v4_engine.omitUndefined(singleEntrySourceOptions),
870
+ cssEntries: [cssEntry]
871
+ });
872
+ const css = (0, node_fs.readFileSync)(cssEntry, "utf8");
873
+ const base = node_path.default.dirname(node_path.default.resolve(cssEntry));
874
+ const entrySource = require_v4_engine.resolveCssEntrySource(css, base, { removeConfig: false });
875
+ const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, cssEntry, {
876
+ ...sourceOptions,
877
+ sourceFile: sourceOptions.sourceFile ?? cssEntry
878
+ });
879
+ return withGeneratorSourceMetadata(await require_v4_engine.resolveTailwindV4Source({
880
+ ...require_v4_engine.omitUndefined(singleEntrySourceOptions),
881
+ base,
882
+ css: require_v4_engine.normalizeConfigDirective(css, config),
883
+ cssEntries: [cssEntry]
884
+ }), {
885
+ matchedCssSourceFile: cssEntry,
886
+ sourceBase: base,
887
+ sourceCss: css
888
+ });
889
+ }
890
+ function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
891
+ const from = resolvePostcssFromOption(cssHandlerOptions);
892
+ if (!from || !node_path.default.isAbsolute(from)) return node_path.default.isAbsolute(file) || Boolean(sourceOptions?.sourceFile) || Boolean(sourceOptions?.cssSources?.length);
893
+ return true;
894
+ }
895
+ function shouldResolveSourceSideCssEntry(rawSource) {
896
+ return rawSource.includes("@apply") || require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true }) || require_v4_engine.hasTailwindGeneratedCss(rawSource) || require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource);
897
+ }
737
898
  function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
738
899
  const cssEntries = sourceOptions.cssEntries;
739
900
  if (!cssEntries?.length) return;
901
+ const normalizedFile = node_path.default.resolve(file.replace(/[?#].*$/, ""));
902
+ const pathMatchedEntries = cssEntries.filter((cssEntry) => node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === normalizedFile);
903
+ if (pathMatchedEntries.length === 1) return resolveTailwindV4CssEntrySource(pathMatchedEntries[0], sourceOptions);
740
904
  const normalizedRawSource = normalizeCssSourceForCompare(rawSource);
741
- const outputStem = getOutputFileStem(file);
742
905
  const matches = cssEntries.map((cssEntry) => {
743
906
  if (!(0, node_fs.existsSync)(cssEntry)) return;
744
907
  try {
@@ -748,14 +911,6 @@ function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
748
911
  cssEntry,
749
912
  score: 1e6 + pathScore
750
913
  };
751
- if (pathScore > 0) return {
752
- cssEntry,
753
- score: pathScore
754
- };
755
- if (cssEntries.length === 1 && outputStem.length > 0 && getOutputFileStem(cssEntry) === outputStem) return {
756
- cssEntry,
757
- score: 1
758
- };
759
914
  return;
760
915
  } catch {
761
916
  return;
@@ -768,11 +923,23 @@ function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
768
923
  }
769
924
  function normalizeTailwindV4CssSourceConfig(cssSource, sourceBase) {
770
925
  if (typeof cssSource.css !== "string" || cssSource.css.length === 0 || !cssSource.css.includes("@config")) return cssSource;
771
- const entrySource = require_v3_engine.resolveCssEntrySource(cssSource.css, sourceBase, { removeConfig: false });
926
+ const entrySource = require_v4_engine.resolveCssEntrySource(cssSource.css, sourceBase, { removeConfig: false });
772
927
  if (!entrySource?.config) return cssSource;
773
928
  return {
774
929
  ...cssSource,
775
- css: require_v3_engine.normalizeConfigDirective(cssSource.css, entrySource.config)
930
+ css: require_v4_engine.normalizeConfigDirective(cssSource.css, entrySource.config)
931
+ };
932
+ }
933
+ function normalizeResolvedTailwindV4SourceConfig(source, file, sourceOptions) {
934
+ if (!("css" in source) || typeof source.css !== "string" || !source.css.includes("@config")) return source;
935
+ const sourceFile = typeof file === "string" && file.length > 0 ? file : source.__weappTailwindcssMeta?.matchedCssSourceFile;
936
+ if (!sourceFile) return source;
937
+ const entrySource = require_v4_engine.resolveCssEntrySource(source.css, node_path.default.dirname(node_path.default.resolve(sourceFile)), { removeConfig: false });
938
+ const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, sourceFile, sourceOptions ?? {});
939
+ const normalizedCss = require_v4_engine.normalizeConfigDirective(source.css, config);
940
+ return normalizedCss === source.css ? source : {
941
+ ...source,
942
+ css: normalizedCss
776
943
  };
777
944
  }
778
945
  function hydrateTailwindV4CssSource(cssSource) {
@@ -793,7 +960,7 @@ function normalizeTailwindV4CssSourceConfigs(sourceOptions) {
793
960
  let changed = false;
794
961
  const cssSources = sourceOptions.cssSources.map((cssSource) => {
795
962
  const hydratedCssSource = hydrateTailwindV4CssSource(cssSource);
796
- const normalizedCssSource = normalizeTailwindV4CssSourceConfig(hydratedCssSource, require_v3_engine.resolveTailwindV4CssSourceBase(hydratedCssSource, sourceBaseFallback));
963
+ const normalizedCssSource = normalizeTailwindV4CssSourceConfig(hydratedCssSource, require_v4_engine.resolveTailwindV4CssSourceBase(hydratedCssSource, sourceBaseFallback));
797
964
  changed || (changed = normalizedCssSource !== cssSource);
798
965
  return normalizedCssSource;
799
966
  });
@@ -814,18 +981,10 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
814
981
  index,
815
982
  score: 1e6
816
983
  };
817
- if (typeof cssSource.file === "string") {
818
- const pathScore = scoreTailwindV4CssSourceFileMatch(file, cssSource.file, sourceOptions);
819
- if (pathScore > 0) return {
820
- cssSource,
821
- index,
822
- score: pathScore
823
- };
824
- }
825
984
  if (normalizeCssSourceForCompare(cssSource.css) === normalizedRawSource) return {
826
985
  cssSource,
827
986
  index,
828
- score: 1
987
+ score: 1 + (typeof cssSource.file === "string" ? scoreTailwindV4CssSourceFileMatch(file, cssSource.file, sourceOptions) : 0)
829
988
  };
830
989
  }).filter((match) => Boolean(match)).sort((a, b) => b.score - a.score || a.index - b.index);
831
990
  const bestScore = matches[0]?.score;
@@ -835,7 +994,7 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
835
994
  }
836
995
  function tryResolveTailwindV4SourceOptions(runtimeState) {
837
996
  try {
838
- return require_v3_engine.resolveTailwindV4SourceOptionsFromPatcher(runtimeState.twPatcher);
997
+ return require_v4_engine.resolveTailwindV4SourceOptionsFromRuntime(runtimeState.tailwindRuntime);
839
998
  } catch {
840
999
  return;
841
1000
  }
@@ -844,12 +1003,12 @@ function hasConfiguredTailwindV4CssSource(sourceOptions) {
844
1003
  return Boolean(sourceOptions?.css) || Boolean(sourceOptions?.cssSources?.length);
845
1004
  }
846
1005
  async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, options = {}) {
847
- const sourceBase = require_v3_engine.resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
1006
+ const sourceBase = require_v4_engine.resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
848
1007
  const normalizedCssSource = normalizeTailwindV4CssSourceConfig(cssSource, sourceBase);
849
- return withGeneratorSourceMetadata(await require_v3_engine.resolveTailwindV4Source({
850
- ...require_v3_engine.omitUndefined(sourceOptions),
851
- cssSources: [normalizedCssSource]
852
- }), {
1008
+ return withGeneratorSourceMetadata(await require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(sourceOptions, {
1009
+ base: sourceBase,
1010
+ css: normalizedCssSource.css
1011
+ })), {
853
1012
  matchedCssSourceFile: options.matched && typeof normalizedCssSource.file === "string" ? normalizedCssSource.file : void 0,
854
1013
  sourceBase,
855
1014
  sourceCss: normalizedCssSource.css
@@ -857,8 +1016,8 @@ async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, option
857
1016
  }
858
1017
  async function resolveTailwindV4CssSourceEntries(cssSource, sourceOptions) {
859
1018
  if (typeof cssSource.css !== "string" || cssSource.css.length === 0) return;
860
- const sourceBase = require_v3_engine.resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
861
- return require_v3_engine.resolveTailwindV4EntriesFromCss(cssSource.css, sourceBase);
1019
+ const sourceBase = require_v4_engine.resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
1020
+ return require_tailwindcss.resolveTailwindV4EntriesFromCss(cssSource.css, sourceBase);
862
1021
  }
863
1022
  function countRuntimeCandidateHits(candidates, runtime) {
864
1023
  if (!runtime?.size) return 0;
@@ -895,232 +1054,665 @@ async function resolveCandidateMatchedTailwindV4CssSource(_rawSource, _cssHandle
895
1054
  function createTailwindV4CssSourceResolver(sourceOptions, generatorOptions) {
896
1055
  return (cssSource) => resolveSingleTailwindV4CssSource(cssSource, sourceOptions).then((source) => generatorOptions?.config ? {
897
1056
  ...source,
898
- css: require_v3_engine.prependConfigDirective(source.css, generatorOptions.config)
1057
+ css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
899
1058
  } : source);
900
1059
  }
901
1060
  async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourceOptions, generatorOptions, file) {
902
1061
  if (!resolvedEntrySource) return;
903
- const resolvedSourceOptions = require_v3_engine.omitUndefined(sourceOptions);
1062
+ const resolvedSourceOptions = require_v4_engine.omitUndefined(sourceOptions);
904
1063
  const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, {
905
1064
  ...resolvedSourceOptions,
906
1065
  sourceFile: resolvedEntrySource.file
907
1066
  });
908
- const css = createTailwindV4ApplyReferenceSource(require_v3_engine.normalizeConfigDirective(require_v3_engine.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
909
- return withMatchedSourceSideMetadata(await require_v3_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
1067
+ const css = createTailwindV4SourceReferenceSource(require_v4_engine.normalizeConfigDirective(require_v4_engine.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
1068
+ return withMatchedSourceSideMetadata(await require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
910
1069
  base: resolvedEntrySource.base,
911
1070
  css
912
1071
  })), resolvedEntrySource);
913
1072
  }
914
- function withGeneratorSourceMetadata(source, metadata) {
915
- return {
916
- ...source,
917
- __weappTailwindcssMeta: metadata
918
- };
919
- }
920
- function resolveTailwindV3SourceEntries(source) {
921
- if (!("version" in source) || source.version !== 3) return;
922
- const entries = require_v3_engine.normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? node_path.default.dirname(source.config) : source.cwd });
923
- return entries.length > 0 ? entries : void 0;
924
- }
925
- function withTailwindV3SourceMetadata(source) {
926
- const sourceEntries = resolveTailwindV3SourceEntries(source);
927
- return sourceEntries ? withGeneratorSourceMetadata(source, { sourceEntries }) : source;
928
- }
929
- function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
930
- return resolvedEntrySource.file ? withGeneratorSourceMetadata(source, {
931
- matchedCssSourceFile: resolvedEntrySource.file,
932
- sourceBase: resolvedEntrySource.base,
933
- sourceCss: resolvedEntrySource.css
934
- }) : source;
935
- }
936
- function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
937
- if (!require_v3_engine.hasTailwindApplyDirective(css) || require_v3_engine.hasTailwindRootDirectives(css)) return css;
938
- const utilities = collectTailwindApplyUtilities(css);
939
- return [
940
- `@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
941
- utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
942
- css
943
- ].filter(Boolean).join("\n");
944
- }
945
- function collectTailwindApplyUtilities(css) {
946
- let root;
947
- try {
948
- root = _weapp_tailwindcss_postcss.postcss.parse(css);
949
- } catch {
950
- return [];
951
- }
952
- const utilities = /* @__PURE__ */ new Set();
953
- root.walkAtRules("apply", (rule) => {
954
- for (const utility of (0, tailwindcss_patch.splitCandidateTokens)(rule.params)) utilities.add(utility);
955
- });
956
- return [...utilities].sort();
957
- }
958
- async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
1073
+ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
959
1074
  const base = resolveCssSourceBase(file, cssHandlerOptions);
960
- const cssEntrySource = require_v3_engine.resolveCssEntrySource(rawSource, base, {
1075
+ const cssEntrySource = require_v4_engine.resolveCssEntrySource(rawSource, base, {
961
1076
  importFallback: generatorOptions?.importFallback ?? false,
962
- removeConfig: majorVersion === 3
1077
+ removeConfig: false
963
1078
  });
964
- const applyEntrySource = require_v3_engine.hasTailwindApplyDirective(rawSource) ? {
1079
+ const applyEntrySource = require_v4_engine.hasTailwindApplyDirective(rawSource) ? {
965
1080
  base,
966
1081
  css: rawSource
967
1082
  } : void 0;
968
- if (majorVersion === 3) {
969
- const sourceOptions = require_v3_engine.resolveTailwindV3SourceOptionsFromPatcher(runtimeState.twPatcher);
970
- const mergedSourceOptions = require_v3_engine.omitUndefined({
971
- ...sourceOptions,
972
- config: generatorOptions?.config ?? sourceOptions.config,
973
- sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
974
- ...resolveCssHandlerSourceOptions(cssHandlerOptions),
975
- cssEntries: selectionOptions?.cssEntries,
976
- cssSources: createCssEntrySources(selectionOptions?.cssEntries)
977
- });
978
- const sourceSideEntrySource = canResolveSourceSideCssEntry(file, cssHandlerOptions, mergedSourceOptions) ? resolveSourceSideCssEntrySource(file, mergedSourceOptions, { removeConfig: true }) : void 0;
979
- const shouldPreferSourceSideEntry = shouldPreferResolvedSourceSideEntry(cssEntrySource, sourceSideEntrySource);
980
- const resolvedEntrySource = shouldResolveSourceSideCssEntry(rawSource) ? shouldPreferSourceSideEntry ? sourceSideEntrySource ?? cssEntrySource ?? applyEntrySource : cssEntrySource ?? applyEntrySource ?? sourceSideEntrySource : shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) || shouldPreferSourceSideEntry ? sourceSideEntrySource ?? cssEntrySource ?? applyEntrySource : cssEntrySource ?? applyEntrySource ?? sourceSideEntrySource;
981
- if (!resolvedEntrySource) return withTailwindV3SourceMetadata(await (generatorOptions?.config ? require_v3_engine.resolveTailwindV3Source(mergedSourceOptions) : require_v3_engine.resolveTailwindV3SourceFromPatcher(runtimeState.twPatcher)));
982
- if (cssEntrySource && !sourceSideEntrySource && !applyEntrySource && !require_v3_engine.hasTailwindRootDirectives(rawSource, { importFallback: true })) return withTailwindV3SourceMetadata(await (generatorOptions?.config ? require_v3_engine.resolveTailwindV3Source(mergedSourceOptions) : require_v3_engine.resolveTailwindV3SourceFromPatcher(runtimeState.twPatcher)));
983
- const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, require_v3_engine.omitUndefined(mergedSourceOptions));
984
- const sourceWithMetadata = withTailwindV3SourceMetadata(await require_v3_engine.resolveTailwindV3Source({
985
- ...mergedSourceOptions,
986
- base: resolvedEntrySource.base,
987
- css: require_v3_engine.normalizeTailwindV3CssEntrySource(resolvedEntrySource.css),
988
- ...config ? { config } : {}
989
- }));
990
- return withGeneratorSourceMetadata(sourceWithMetadata, {
991
- ...sourceWithMetadata.__weappTailwindcssMeta,
992
- matchedCssSourceFile: resolvedEntrySource.file
993
- });
994
- }
995
1083
  const sourceOptions = tryResolveTailwindV4SourceOptions(runtimeState);
996
- const resolvedSourceOptions = sourceOptions ? require_v3_engine.omitUndefined({
1084
+ const resolvedSourceOptions = sourceOptions ? require_v4_engine.omitUndefined({
997
1085
  ...sourceOptions,
998
- sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
1086
+ sourceFile: sourceOptions.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions),
999
1087
  ...resolveCssHandlerSourceOptions(cssHandlerOptions),
1000
1088
  cssEntries: selectionOptions?.cssEntries ?? sourceOptions.cssEntries,
1001
1089
  cssSources: mergeCssSources(sourceOptions.cssSources, sourceOptions.cssSources?.length ? void 0 : createCssEntrySources(selectionOptions?.cssEntries ?? sourceOptions.cssEntries))
1002
1090
  }) : void 0;
1003
1091
  const normalizedSourceOptions = resolvedSourceOptions ? normalizeTailwindV4CssSourceConfigs(resolvedSourceOptions) : void 0;
1004
- if (applyEntrySource && !cssHandlerOptions.isMainChunk && !require_v3_engine.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
1005
- const css = createTailwindV4ApplyReferenceSource(require_v3_engine.normalizeConfigDirective(require_v3_engine.prependConfigDirective(applyEntrySource.css, generatorOptions?.config), void 0), normalizedSourceOptions ?? {});
1006
- return require_v3_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
1092
+ if (applyEntrySource && !cssHandlerOptions.isMainChunk && !require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
1093
+ const css = createTailwindV4ApplyReferenceSource(require_v4_engine.normalizeConfigDirective(require_v4_engine.prependConfigDirective(applyEntrySource.css, generatorOptions?.config), void 0), normalizedSourceOptions ?? {});
1094
+ return require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
1007
1095
  base: applyEntrySource.base,
1008
1096
  css
1009
1097
  }));
1010
1098
  }
1011
1099
  const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions?.cssEntries?.length ?? 0) <= 1;
1012
- const sourceSideEntrySource = normalizedSourceOptions && shouldPreferSourceSideEntry && canResolveSourceSideCssEntry(file, cssHandlerOptions, normalizedSourceOptions) ? resolveSourceSideCssEntrySource(file, normalizedSourceOptions, { removeConfig: false }) : void 0;
1100
+ const sourceSideEntrySource = normalizedSourceOptions && (shouldPreferSourceSideEntry || normalizedSourceOptions.sourceFile !== void 0) && canResolveSourceSideCssEntry(file, cssHandlerOptions, normalizedSourceOptions) ? resolveSourceSideCssEntrySource(file, normalizedSourceOptions, { removeConfig: false }) : void 0;
1013
1101
  const matchedCssEntrySource = normalizedSourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, normalizedSourceOptions) : void 0;
1014
1102
  const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions) : void 0;
1015
1103
  const candidateMatchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
1016
- const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) && require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource) ? matchedCssSource ?? candidateMatchedCssSource ?? await require_v3_engine.resolveTailwindV4Source(normalizedSourceOptions) : void 0;
1104
+ const singleConfiguredCssSource = normalizedSourceOptions?.cssSources?.length === 1 ? await resolveSingleTailwindV4CssSource(normalizedSourceOptions.cssSources[0], normalizedSourceOptions, { matched: true }) : void 0;
1105
+ const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) && require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource) ? matchedCssSource ?? candidateMatchedCssSource ?? singleConfiguredCssSource ?? await require_v4_engine.resolveTailwindV4Source(normalizedSourceOptions) : void 0;
1017
1106
  if (configuredCssSource) return generatorOptions?.config ? {
1018
1107
  ...configuredCssSource,
1019
- css: require_v3_engine.prependConfigDirective(configuredCssSource.css, generatorOptions.config)
1108
+ css: require_v4_engine.prependConfigDirective(configuredCssSource.css, generatorOptions.config)
1020
1109
  } : configuredCssSource;
1021
1110
  const mainCssEntrySource = normalizedSourceOptions && cssHandlerOptions.isMainChunk && normalizedSourceOptions.cssEntries?.length === 1 ? await resolveTailwindV4CssEntrySource(normalizedSourceOptions.cssEntries[0], normalizedSourceOptions) : void 0;
1022
- const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource;
1111
+ const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
1023
1112
  if (preferredCssEntrySource) return generatorOptions?.config ? {
1024
1113
  ...preferredCssEntrySource,
1025
- css: require_v3_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
1114
+ css: require_v4_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
1026
1115
  } : preferredCssEntrySource;
1027
1116
  const resolvedEntrySource = sourceSideEntrySource ?? cssEntrySource ?? applyEntrySource;
1028
1117
  if (!resolvedEntrySource) {
1029
- const source = await require_v3_engine.resolveTailwindV4SourceFromPatcher(runtimeState.twPatcher);
1118
+ const source = await require_v4_engine.resolveTailwindV4SourceFromRuntime(runtimeState.tailwindRuntime);
1030
1119
  return generatorOptions?.config ? {
1031
1120
  ...source,
1032
- css: require_v3_engine.prependConfigDirective(source.css, generatorOptions.config)
1121
+ css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
1033
1122
  } : source;
1034
1123
  }
1035
1124
  if (sourceSideEntrySource && normalizedSourceOptions) return resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file);
1036
- const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, resolvedSourceOptions ?? {});
1125
+ const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, require_v4_engine.omitUndefined({
1126
+ ...resolvedSourceOptions ?? {},
1127
+ sourceFile: resolvedEntrySource.file ?? resolvedSourceOptions?.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions)
1128
+ }));
1037
1129
  const sourceBase = resolvedEntrySource === cssEntrySource && config ? node_path.default.dirname(config) : resolvedEntrySource.base;
1038
- const css = createTailwindV4ApplyReferenceSource(require_v3_engine.normalizeConfigDirective(require_v3_engine.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), normalizedSourceOptions ?? {});
1039
- return require_v3_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
1130
+ const css = createTailwindV4SourceReferenceSource(require_v4_engine.normalizeConfigDirective(require_v4_engine.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), normalizedSourceOptions ?? {});
1131
+ return require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
1040
1132
  base: sourceBase,
1041
1133
  css
1042
1134
  }));
1043
1135
  }
1044
1136
  async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
1045
- const cssEntrySource = require_v3_engine.resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), {
1137
+ const cssEntrySource = require_v4_engine.resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), {
1046
1138
  importFallback: generatorOptions?.importFallback ?? false,
1047
- removeConfig: majorVersion === 3
1139
+ removeConfig: false
1048
1140
  });
1049
- if (majorVersion !== 4 || cssEntrySource && !cssHandlerOptions.isMainChunk || !cssHandlerOptions.isMainChunk && require_v3_engine.hasTailwindApplyDirective(rawSource) && !require_v3_engine.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
1141
+ if (cssEntrySource && !cssHandlerOptions.isMainChunk || !cssHandlerOptions.isMainChunk && require_v4_engine.hasTailwindApplyDirective(rawSource) && !require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
1050
1142
  const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
1051
1143
  return resolved ? [resolved] : [];
1052
1144
  }
1053
1145
  let sourceOptions;
1054
1146
  try {
1055
- const sourceOptionsFromPatcher = require_v3_engine.resolveTailwindV4SourceOptionsFromPatcher(runtimeState.twPatcher);
1056
- const cssEntries = selectionOptions?.cssEntries ?? sourceOptionsFromPatcher.cssEntries;
1057
- sourceOptions = require_v3_engine.omitUndefined({
1058
- ...sourceOptionsFromPatcher,
1147
+ const sourceOptionsFromRuntime = require_v4_engine.resolveTailwindV4SourceOptionsFromRuntime(runtimeState.tailwindRuntime);
1148
+ const cssEntries = selectionOptions?.cssEntries ?? sourceOptionsFromRuntime.cssEntries;
1149
+ const runtimeCssSources = selectionOptions?.cssEntries ? void 0 : sourceOptionsFromRuntime.cssSources;
1150
+ sourceOptions = require_v4_engine.omitUndefined({
1151
+ ...sourceOptionsFromRuntime,
1059
1152
  sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
1060
1153
  ...resolveCssHandlerSourceOptions(cssHandlerOptions),
1061
1154
  cssEntries,
1062
- cssSources: mergeCssSources(sourceOptionsFromPatcher.cssSources, sourceOptionsFromPatcher.cssSources?.length ? void 0 : createCssEntrySources(cssEntries))
1155
+ cssSources: mergeCssSources(mergeCssSources(runtimeCssSources, selectionOptions?.cssSources), void 0)
1063
1156
  });
1064
1157
  } catch {
1065
1158
  const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
1066
1159
  return resolved ? [resolved] : [];
1067
1160
  }
1068
1161
  const matchedCssEntrySource = sourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) : void 0;
1069
- if (matchedCssEntrySource) return [generatorOptions?.config ? {
1162
+ if (matchedCssEntrySource) return [normalizeResolvedTailwindV4SourceConfig(generatorOptions?.config ? {
1070
1163
  ...matchedCssEntrySource,
1071
- css: require_v3_engine.prependConfigDirective(matchedCssEntrySource.css, generatorOptions.config)
1072
- } : matchedCssEntrySource];
1073
- const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource((shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions.cssEntries?.length ?? 0) <= 1) && canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
1164
+ css: require_v4_engine.prependConfigDirective(matchedCssEntrySource.css, generatorOptions.config)
1165
+ } : matchedCssEntrySource, matchedCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
1166
+ const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
1074
1167
  if (sourceSideCssSource) return [sourceSideCssSource];
1075
1168
  const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions);
1076
1169
  const candidateMatchedCssSource = await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, sourceOptions, selectionOptions);
1077
1170
  const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource;
1078
- if (preferredCssEntrySource) return [generatorOptions?.config ? {
1171
+ if (preferredCssEntrySource) return [normalizeResolvedTailwindV4SourceConfig(generatorOptions?.config ? {
1079
1172
  ...preferredCssEntrySource,
1080
- css: require_v3_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
1081
- } : preferredCssEntrySource];
1173
+ css: require_v4_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
1174
+ } : preferredCssEntrySource, preferredCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
1082
1175
  if (!sourceOptions.cssEntries || sourceOptions.cssEntries.length <= 1) {
1083
1176
  if (cssHandlerOptions.isMainChunk && sourceOptions.cssEntries?.length === 1) return [await resolveTailwindV4CssEntrySource(sourceOptions.cssEntries[0], normalizeTailwindV4CssSourceConfigs(sourceOptions)).then((source) => generatorOptions?.config ? {
1084
1177
  ...source,
1085
- css: require_v3_engine.prependConfigDirective(source.css, generatorOptions.config)
1178
+ css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
1086
1179
  } : source)];
1087
- if (sourceOptions.cssSources?.length === 1) return [await createTailwindV4CssSourceResolver(sourceOptions, generatorOptions)(sourceOptions.cssSources[0])];
1180
+ if (sourceOptions.cssSources?.length === 1) return [normalizeResolvedTailwindV4SourceConfig(await createTailwindV4CssSourceResolver(sourceOptions, generatorOptions)(sourceOptions.cssSources[0]), sourceOptions.cssSources[0]?.file, sourceOptions)];
1088
1181
  const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
1089
1182
  return resolved ? [resolved] : [];
1090
1183
  }
1091
- if (cssHandlerOptions.isMainChunk && !cssEntrySource && !require_v3_engine.hasTailwindGeneratedCss(rawSource) && !require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource) && !require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false }) && !rawSource.includes("weapp-tailwindcss generator-placeholder") && !hasConfiguredTailwindV4CssSource(sourceOptions)) {
1184
+ if (cssHandlerOptions.isMainChunk && !cssEntrySource && !require_v4_engine.hasTailwindGeneratedCss(rawSource) && !require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource) && !require_v4_engine.hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false }) && !rawSource.includes("weapp-tailwindcss generator-placeholder") && !hasConfiguredTailwindV4CssSource(sourceOptions)) {
1092
1185
  const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
1093
1186
  return resolved ? [resolved] : [];
1094
1187
  }
1095
1188
  const normalizedCssSourceOptions = normalizeTailwindV4CssSourceConfigs(sourceOptions);
1096
1189
  const cssEntrySources = await Promise.all(sourceOptions.cssEntries.map((cssEntry) => resolveTailwindV4CssEntrySource(cssEntry, normalizedCssSourceOptions).then((source) => generatorOptions?.config ? {
1097
1190
  ...source,
1098
- css: require_v3_engine.prependConfigDirective(source.css, generatorOptions.config)
1191
+ css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
1099
1192
  } : source)));
1100
1193
  const cssSources = sourceOptions.cssSources?.length ? await Promise.all(sourceOptions.cssSources.map(createTailwindV4CssSourceResolver(sourceOptions, generatorOptions))) : [];
1101
1194
  return [...cssEntrySources, ...cssSources];
1102
1195
  }
1103
- async function resolveGeneratorSourceEntries(source, runtimeState) {
1104
- const sourceMetadata = source.__weappTailwindcssMeta;
1105
- if (sourceMetadata?.sourceEntries) return sourceMetadata.sourceEntries;
1106
- if (!("css" in source) || !("base" in source) || !("baseFallbacks" in source)) return;
1107
- const resolved = await require_v3_engine.resolveTailwindV4EntriesFromCss(sourceMetadata?.sourceCss ?? source.css, sourceMetadata?.sourceBase ?? source.base);
1108
- if (resolved?.entries.length || !resolved?.explicit && !sourceMetadata?.matchedCssSourceFile || !runtimeState) return resolved?.entries;
1109
- const matchingCssSource = tryResolveTailwindV4SourceOptions(runtimeState)?.cssSources?.find((cssSource) => {
1110
- if (sourceMetadata?.matchedCssSourceFile && typeof cssSource.file === "string" && node_path.default.resolve(cssSource.file) === node_path.default.resolve(sourceMetadata.matchedCssSourceFile)) return true;
1111
- return cssSource.css === source.css;
1196
+ async function resolveGeneratorSourceEntries(source, runtimeState) {
1197
+ const sourceMetadata = source.__weappTailwindcssMeta;
1198
+ if (sourceMetadata?.sourceEntries) return sourceMetadata.sourceEntries;
1199
+ if (!("css" in source) || !("base" in source) || !("baseFallbacks" in source)) return;
1200
+ const resolved = await require_tailwindcss.resolveTailwindV4EntriesFromCss(sourceMetadata?.sourceCss ?? source.css, sourceMetadata?.sourceBase ?? source.base);
1201
+ if (resolved?.entries.length === 0 && !resolved.inlineCandidates.included.size && !resolved.inlineCandidates.excluded.size && !resolved.dependencies.length) {
1202
+ if (sourceMetadata?.matchedCssSourceFile) return [];
1203
+ return;
1204
+ }
1205
+ if (resolved?.entries.length || !resolved?.explicit && !sourceMetadata?.matchedCssSourceFile || !runtimeState) return resolved?.entries;
1206
+ const matchingCssSource = tryResolveTailwindV4SourceOptions(runtimeState)?.cssSources?.find((cssSource) => {
1207
+ if (sourceMetadata?.matchedCssSourceFile && typeof cssSource.file === "string" && node_path.default.resolve(cssSource.file) === node_path.default.resolve(sourceMetadata.matchedCssSourceFile)) return true;
1208
+ return cssSource.css === source.css;
1209
+ });
1210
+ if (!matchingCssSource) return resolved?.entries;
1211
+ const sourceResolved = await require_tailwindcss.resolveTailwindV4EntriesFromCss(matchingCssSource.css, typeof matchingCssSource.base === "string" && matchingCssSource.base.length > 0 ? matchingCssSource.base : typeof matchingCssSource.file === "string" && matchingCssSource.file.length > 0 ? node_path.default.dirname(matchingCssSource.file) : source.base);
1212
+ if (sourceResolved?.entries.length) return sourceResolved.entries;
1213
+ for (const dependency of matchingCssSource.dependencies ?? []) {
1214
+ if (!(0, node_fs.existsSync)(dependency)) continue;
1215
+ try {
1216
+ const dependencyResolved = await require_tailwindcss.resolveTailwindV4EntriesFromCss((0, node_fs.readFileSync)(dependency, "utf8"), node_path.default.dirname(dependency));
1217
+ if (dependencyResolved?.entries.length) return dependencyResolved.entries;
1218
+ } catch {}
1219
+ }
1220
+ return resolved?.entries;
1221
+ }
1222
+ //#endregion
1223
+ //#region src/bundlers/shared/generator-css/user-css.ts
1224
+ const TAILWIND_V4_GENERATOR_AT_RULES = new Set([
1225
+ "config",
1226
+ "custom-variant",
1227
+ "plugin",
1228
+ "source",
1229
+ "theme",
1230
+ "utility",
1231
+ "variant"
1232
+ ]);
1233
+ function removeBalancedAtRuleBlock(source, atRuleStart) {
1234
+ const blockStart = source.indexOf("{", atRuleStart);
1235
+ if (blockStart === -1) {
1236
+ const semicolon = source.indexOf(";", atRuleStart);
1237
+ return semicolon === -1 ? source.slice(0, atRuleStart) : `${source.slice(0, atRuleStart)}${source.slice(semicolon + 1)}`;
1238
+ }
1239
+ let depth = 0;
1240
+ for (let index = blockStart; index < source.length; index++) {
1241
+ const char = source[index];
1242
+ if (char === "{") {
1243
+ depth++;
1244
+ continue;
1245
+ }
1246
+ if (char !== "}") continue;
1247
+ depth--;
1248
+ if (depth === 0) return `${source.slice(0, atRuleStart)}${source.slice(index + 1)}`;
1249
+ }
1250
+ return source.slice(0, atRuleStart);
1251
+ }
1252
+ function removeTailwindV4GeneratorAtRulesFallback(source) {
1253
+ let next = source;
1254
+ let changed = false;
1255
+ const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
1256
+ for (;;) {
1257
+ sourceMediaRE.lastIndex = 0;
1258
+ const match = sourceMediaRE.exec(next);
1259
+ if (!match) break;
1260
+ next = removeBalancedAtRuleBlock(next, match.index);
1261
+ changed = true;
1262
+ }
1263
+ const atRuleRE = /@(?:config|custom-variant|plugin|source|theme|utility|variant)\b/g;
1264
+ for (;;) {
1265
+ atRuleRE.lastIndex = 0;
1266
+ const match = atRuleRE.exec(next);
1267
+ if (!match) break;
1268
+ next = removeBalancedAtRuleBlock(next, match.index);
1269
+ changed = true;
1270
+ }
1271
+ return changed ? next : source;
1272
+ }
1273
+ function isTailwindGeneratedPreflightComment(text) {
1274
+ return text.includes("cssremedy") || text.includes("Use the user's configured") || text.includes("tailwindlabs/tailwindcss") || text.includes("Prevent padding and border from affecting element width") || text.includes("Remove default margins and padding") || text.includes("Deprecated") || text.includes("Reset all borders") || text.includes("Add the correct text decoration") || text.includes("Make elements with the HTML hidden attribute stay hidden") || text.includes("Inherit font styles in all browsers") || text.includes("Add the correct height in Firefox") || text.includes("Remove the default font size and weight for headings") || text.includes("Reset links to optimize for opt-in styling") || text.includes("Add the correct font weight in Edge and Safari") || text.includes("Use the user's configured `mono` font-family") || text.includes("Add the correct font size in all browsers") || text.includes("Prevent `sub` and `sup` elements from affecting the line height") || text.includes("Remove text indentation from table contents") || text.includes("Use the modern Firefox focus style") || text.includes("Add the correct vertical alignment") || text.includes("Add the correct display") || text.includes("Make lists unstyled by default") || text.includes("Make replaced elements `display: block` by default") || text.includes("Constrain images and videos to the parent width") || text.includes("Restore default font weight") || text.includes("Restore indentation") || text.includes("Restore space after button") || text.includes("Prevent resizing textareas horizontally") || text.includes("Remove the inner padding in Chrome and Safari") || text.includes("Ensure date/time inputs have the same height") || text.includes("Prevent height from changing on date/time inputs") || text.includes("Remove excess padding from pseudo-elements") || text.includes("Center dropdown marker shown on inputs") || text.includes("Remove the additional `:invalid` styles") || text.includes("Correct the inability to style the border radius") || text.includes("Correct the cursor style of increment and decrement buttons");
1275
+ }
1276
+ function isTailwindGeneratedThemeRule(selector, node) {
1277
+ if (!/(?:^|,)\s*(?::host|page|\.tw-root|wx-root-portal-content)\b/.test(selector)) return false;
1278
+ return node.nodes?.some((child) => child.type === "decl" && /^--(?:color|spacing|text|font|default|radius|tw-)/.test(child.prop)) ?? false;
1279
+ }
1280
+ function isTailwindGeneratedPreflightRule(selector, node) {
1281
+ if (selector === "view,text,::after,::before" || selector === "view, text, ::after, ::before" || selector === "*" || selector === "::after" || selector === "::before" || selector === "::backdrop" || selector === ":host" || selector === "[hidden]:not([hidden=\"until-found\"])" || selector === "[hidden]:not([hidden='until-found'])" || selector === "button,input[type=\"button\"],input[type=\"reset\"],input[type=\"submit\"]" || selector === "button, input[type=\"button\"], input[type=\"reset\"], input[type=\"submit\"]" || selector === "button,input[type='button'],input[type='reset'],input[type='submit']" || selector === "button, input[type='button'], input[type='reset'], input[type='submit']") return true;
1282
+ if (selector === "abbr[title]") return node.nodes?.some((child) => child.type === "decl" && child.prop === "text-decoration") ?? false;
1283
+ if (selector === ":host") return node.nodes?.some((child) => child.type === "decl" && child.value?.includes("--theme(")) ?? false;
1284
+ return false;
1285
+ }
1286
+ function removeTailwindV4GeneratedUserCssArtifacts(source) {
1287
+ try {
1288
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1289
+ let changed = false;
1290
+ root.walkComments((comment) => {
1291
+ if (!isTailwindGeneratedPreflightComment(comment.text)) return;
1292
+ comment.remove();
1293
+ changed = true;
1294
+ });
1295
+ root.walkRules((rule) => {
1296
+ const selector = rule.selector.replace(/\s+/g, " ").trim();
1297
+ if (isTailwindGeneratedThemeRule(selector, rule) || isTailwindGeneratedPreflightRule(selector, rule)) {
1298
+ rule.remove();
1299
+ changed = true;
1300
+ }
1301
+ });
1302
+ root.walkAtRules((rule) => {
1303
+ if (rule.nodes !== void 0 && rule.nodes.length === 0) {
1304
+ rule.remove();
1305
+ changed = true;
1306
+ }
1307
+ });
1308
+ return changed ? root.toString() : source;
1309
+ } catch {
1310
+ return source;
1311
+ }
1312
+ }
1313
+ function removeTailwindSourceMediaBlocks(source) {
1314
+ let next = source;
1315
+ let changed = false;
1316
+ const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
1317
+ for (;;) {
1318
+ sourceMediaRE.lastIndex = 0;
1319
+ const match = sourceMediaRE.exec(next);
1320
+ if (!match) break;
1321
+ const blockStart = next.indexOf("{", match.index);
1322
+ if (blockStart === -1) break;
1323
+ let depth = 0;
1324
+ let blockEnd = -1;
1325
+ for (let index = blockStart; index < next.length; index++) {
1326
+ const char = next[index];
1327
+ if (char === "{") {
1328
+ depth++;
1329
+ continue;
1330
+ }
1331
+ if (char !== "}") continue;
1332
+ depth--;
1333
+ if (depth === 0) {
1334
+ blockEnd = index;
1335
+ break;
1336
+ }
1337
+ }
1338
+ if (blockEnd === -1) break;
1339
+ next = `${next.slice(0, match.index)}${next.slice(blockEnd + 1)}`;
1340
+ changed = true;
1341
+ }
1342
+ for (;;) {
1343
+ const atRuleStart = findTailwindSourceWrapperBlockStart(next);
1344
+ if (atRuleStart === -1) break;
1345
+ next = removeBalancedAtRuleBlock(next, atRuleStart);
1346
+ changed = true;
1347
+ }
1348
+ return changed ? next : source;
1349
+ }
1350
+ function terminateTailwindSourceAtRulesBeforeNextDirective(source) {
1351
+ if (!source.includes("@source")) return source;
1352
+ let next = "";
1353
+ let searchIndex = 0;
1354
+ for (;;) {
1355
+ const atRuleStart = source.indexOf("@source", searchIndex);
1356
+ if (atRuleStart === -1) {
1357
+ next += source.slice(searchIndex);
1358
+ break;
1359
+ }
1360
+ const nextChar = source[atRuleStart + 7];
1361
+ if (nextChar && /[\w-]/.test(nextChar)) {
1362
+ next += source.slice(searchIndex, atRuleStart + 7);
1363
+ searchIndex = atRuleStart + 7;
1364
+ continue;
1365
+ }
1366
+ next += source.slice(searchIndex, atRuleStart);
1367
+ let quote;
1368
+ let parenDepth = 0;
1369
+ let terminated = false;
1370
+ let index = atRuleStart + 7;
1371
+ for (; index < source.length; index++) {
1372
+ const char = source[index];
1373
+ if (quote) {
1374
+ if (char === "\\") {
1375
+ index++;
1376
+ continue;
1377
+ }
1378
+ if (char === quote) quote = void 0;
1379
+ continue;
1380
+ }
1381
+ if (char === "\"" || char === "'") {
1382
+ quote = char;
1383
+ continue;
1384
+ }
1385
+ if (char === "(") {
1386
+ parenDepth++;
1387
+ continue;
1388
+ }
1389
+ if (char === ")" && parenDepth > 0) {
1390
+ parenDepth--;
1391
+ continue;
1392
+ }
1393
+ if (parenDepth > 0) continue;
1394
+ if (char === ";" || char === "{") {
1395
+ terminated = true;
1396
+ index++;
1397
+ break;
1398
+ }
1399
+ if (char === "@" && /^(?:config|custom-variant|plugin|source|theme|utility|variant)\b/.test(source.slice(index + 1))) break;
1400
+ }
1401
+ const segment = source.slice(atRuleStart, index);
1402
+ const trimmedSegment = segment.trimEnd();
1403
+ next += terminated || trimmedSegment.endsWith(";") || trimmedSegment.endsWith("{") ? segment : `${trimmedSegment};${segment.slice(trimmedSegment.length)}`;
1404
+ searchIndex = index;
1405
+ }
1406
+ return next;
1407
+ }
1408
+ function findTailwindSourceWrapperBlockStart(source) {
1409
+ let searchIndex = 0;
1410
+ for (;;) {
1411
+ const atRuleStart = source.indexOf("@source", searchIndex);
1412
+ if (atRuleStart === -1) return -1;
1413
+ const nextChar = source[atRuleStart + 7];
1414
+ if (nextChar && /[\w-]/.test(nextChar)) {
1415
+ searchIndex = atRuleStart + 7;
1416
+ continue;
1417
+ }
1418
+ let quote;
1419
+ let parenDepth = 0;
1420
+ for (let index = atRuleStart + 7; index < source.length; index++) {
1421
+ const char = source[index];
1422
+ if (quote) {
1423
+ if (char === "\\") {
1424
+ index++;
1425
+ continue;
1426
+ }
1427
+ if (char === quote) quote = void 0;
1428
+ continue;
1429
+ }
1430
+ if (char === "\"" || char === "'") {
1431
+ quote = char;
1432
+ continue;
1433
+ }
1434
+ if (char === "(") {
1435
+ parenDepth++;
1436
+ continue;
1437
+ }
1438
+ if (char === ")" && parenDepth > 0) {
1439
+ parenDepth--;
1440
+ continue;
1441
+ }
1442
+ if (parenDepth > 0) continue;
1443
+ if (char === ";") {
1444
+ searchIndex = index + 1;
1445
+ break;
1446
+ }
1447
+ if (char === "{") return atRuleStart;
1448
+ }
1449
+ if (searchIndex <= atRuleStart) return -1;
1450
+ }
1451
+ }
1452
+ function removeTailwindApplyAtRules(source) {
1453
+ if (!source.includes("@apply")) return source;
1454
+ try {
1455
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1456
+ let changed = false;
1457
+ root.walkAtRules("apply", (rule) => {
1458
+ rule.remove();
1459
+ changed = true;
1460
+ });
1461
+ root.walk((node) => {
1462
+ if ("nodes" in node && node.nodes?.length === 0) node.remove();
1463
+ });
1464
+ return changed ? root.toString() : source;
1465
+ } catch {
1466
+ return source;
1467
+ }
1468
+ }
1469
+ function removeTailwindV4GeneratorAtRules(source) {
1470
+ try {
1471
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1472
+ let changed = false;
1473
+ root.walkAtRules((rule) => {
1474
+ if (rule.name === "media" && /^source\(/.test(rule.params.trim())) {
1475
+ rule.remove();
1476
+ changed = true;
1477
+ return;
1478
+ }
1479
+ if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
1480
+ rule.remove();
1481
+ changed = true;
1482
+ });
1483
+ return changed ? root.toString() : source;
1484
+ } catch {
1485
+ return removeTailwindV4GeneratorAtRulesFallback(source);
1486
+ }
1487
+ }
1488
+ function isCommentOnlyCss(source) {
1489
+ try {
1490
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1491
+ return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
1492
+ } catch {
1493
+ return false;
1494
+ }
1495
+ }
1496
+ function removeMiniProgramHoverSelectors(source, enabled = true) {
1497
+ if (!enabled || !source.includes(":hover")) return source;
1498
+ try {
1499
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1500
+ let changed = false;
1501
+ root.walkRules((rule) => {
1502
+ const selectors = rule.selectors ?? [rule.selector];
1503
+ const keptSelectors = selectors.filter((selector) => !selector.includes(":hover"));
1504
+ if (keptSelectors.length === selectors.length) return;
1505
+ changed = true;
1506
+ if (keptSelectors.length === 0) {
1507
+ rule.remove();
1508
+ return;
1509
+ }
1510
+ rule.selectors = keptSelectors;
1511
+ });
1512
+ root.walk((node) => {
1513
+ if ("nodes" in node && node.nodes?.length === 0) {
1514
+ node.remove();
1515
+ changed = true;
1516
+ }
1517
+ });
1518
+ return changed ? root.toString() : source;
1519
+ } catch {
1520
+ return source;
1521
+ }
1522
+ }
1523
+ function removeProcessedMiniProgramUnsupportedCss(source, options) {
1524
+ return removeMiniProgramHoverSelectors((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(source), options.cssRemoveHoverPseudoClass);
1525
+ }
1526
+ function unwrapMiniProgramCascadeLayers(source) {
1527
+ if (!source.includes("@layer")) return source;
1528
+ try {
1529
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1530
+ (0, _weapp_tailwindcss_postcss.removeUnsupportedCascadeLayers)(root);
1531
+ return root.toString();
1532
+ } catch {
1533
+ return source;
1534
+ }
1535
+ }
1536
+ function stripTailwindSourceMediaFragments(source) {
1537
+ let removedSourceMediaStart = false;
1538
+ return terminateTailwindSourceAtRulesBeforeNextDirective(removeTailwindSourceMediaBlocks(source)).split(/\r?\n/).filter((line) => {
1539
+ if (/^\s*@media\s+source\([^)]*\)\s*\{\s*$/.test(line)) {
1540
+ removedSourceMediaStart = true;
1541
+ return false;
1542
+ }
1543
+ if (/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/.test(line)) return false;
1544
+ if (removedSourceMediaStart && /^\s*\}\s*$/.test(line)) {
1545
+ removedSourceMediaStart = false;
1546
+ return false;
1547
+ }
1548
+ return true;
1549
+ }).join("\n");
1550
+ }
1551
+ function stripLeadingTailwindSourceMediaCloseFragment(source) {
1552
+ return source.replace(/^\s*\}\s*(?:\n|$)/, "");
1553
+ }
1554
+ function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
1555
+ try {
1556
+ _weapp_tailwindcss_postcss.postcss.parse(source);
1557
+ return source;
1558
+ } catch {
1559
+ return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
1560
+ }
1561
+ }
1562
+ function splitUserCssLayerBlocks(source) {
1563
+ if (!source.includes("@layer")) return {
1564
+ layer: "",
1565
+ rest: source
1566
+ };
1567
+ try {
1568
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1569
+ const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
1570
+ const restRoot = _weapp_tailwindcss_postcss.postcss.root();
1571
+ for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
1572
+ return {
1573
+ layer: layerRoot.toString(),
1574
+ rest: restRoot.toString()
1575
+ };
1576
+ } catch {
1577
+ return {
1578
+ layer: source,
1579
+ rest: ""
1580
+ };
1581
+ }
1582
+ }
1583
+ function hasUserCssLayerBlocks(source) {
1584
+ if (!source.includes("@layer")) return false;
1585
+ try {
1586
+ let hasLayerBlock = false;
1587
+ _weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("layer", (node) => {
1588
+ if (node.nodes?.length) hasLayerBlock = true;
1589
+ });
1590
+ return hasLayerBlock;
1591
+ } catch {
1592
+ return true;
1593
+ }
1594
+ }
1595
+ function collectUserLayerSelectors(source) {
1596
+ const selectors = /* @__PURE__ */ new Set();
1597
+ try {
1598
+ _weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
1599
+ for (const selector of rule.selectors ?? [rule.selector]) {
1600
+ const normalized = selector.trim();
1601
+ if (normalized) selectors.add(normalized);
1602
+ }
1603
+ });
1604
+ } catch {}
1605
+ return selectors;
1606
+ }
1607
+ function matchesUserLayerSelector(selector, userLayerSelector) {
1608
+ if (selector === userLayerSelector) return true;
1609
+ if (!selector.startsWith(userLayerSelector)) return false;
1610
+ const next = selector[userLayerSelector.length];
1611
+ return next === ":" || next === "[";
1612
+ }
1613
+ function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
1614
+ const selectors = collectUserLayerSelectors(userLayerSource);
1615
+ if (selectors.size === 0) return {
1616
+ layer: "",
1617
+ rest: css
1618
+ };
1619
+ try {
1620
+ const root = _weapp_tailwindcss_postcss.postcss.parse(css);
1621
+ const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
1622
+ const selectorList = [...selectors];
1623
+ root.walkRules((rule) => {
1624
+ if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
1625
+ layerRoot.append(rule.clone());
1626
+ rule.remove();
1627
+ }
1628
+ });
1629
+ return {
1630
+ layer: layerRoot.toString(),
1631
+ rest: root.toString()
1632
+ };
1633
+ } catch {
1634
+ return {
1635
+ layer: "",
1636
+ rest: css
1637
+ };
1638
+ }
1639
+ }
1640
+ function normalizeGeneratedSelector(selector) {
1641
+ return selector.replace(/:not\(#\\#\)/g, "").trim();
1642
+ }
1643
+ function collectApplyOnlySourceSelectors(source) {
1644
+ const selectors = /* @__PURE__ */ new Set();
1645
+ try {
1646
+ _weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
1647
+ if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
1648
+ for (const selector of rule.selectors ?? [rule.selector]) {
1649
+ const normalized = normalizeGeneratedSelector(selector);
1650
+ if (normalized) selectors.add(normalized);
1651
+ }
1652
+ });
1653
+ } catch {}
1654
+ return selectors;
1655
+ }
1656
+ function hasOnlyApplyBackedSourceRules(source) {
1657
+ let hasApplyRule = false;
1658
+ let hasNonApplyRule = false;
1659
+ try {
1660
+ _weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
1661
+ if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
1662
+ else hasNonApplyRule = true;
1663
+ });
1664
+ } catch {
1665
+ return false;
1666
+ }
1667
+ return hasApplyRule && !hasNonApplyRule;
1668
+ }
1669
+ function filterApplyOnlyGeneratedCss(css, source) {
1670
+ const selectors = collectApplyOnlySourceSelectors(source);
1671
+ if (selectors.size === 0) return css;
1672
+ const selectorList = [...selectors];
1673
+ try {
1674
+ const root = _weapp_tailwindcss_postcss.postcss.parse(css);
1675
+ root.walkRules((rule) => {
1676
+ const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
1677
+ const normalized = normalizeGeneratedSelector(selector);
1678
+ return selectorList.some((sourceSelector) => {
1679
+ if (normalized === sourceSelector) return true;
1680
+ if (!normalized.startsWith(sourceSelector)) return false;
1681
+ const next = normalized[sourceSelector.length];
1682
+ return next === ":" || next === "[" || next === ".";
1683
+ });
1684
+ });
1685
+ const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
1686
+ if (!isApplySelector && !isVariableRule) rule.remove();
1687
+ });
1688
+ root.walkAtRules((rule) => {
1689
+ if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
1690
+ });
1691
+ return root.toString();
1692
+ } catch {
1693
+ return css;
1694
+ }
1695
+ }
1696
+ function shouldFilterApplyOnlyGeneratedCss(_majorVersion, target, source, options) {
1697
+ return target === "weapp" && require_v4_engine.hasTailwindApplyDirective(source) && !require_v4_engine.hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
1698
+ }
1699
+ async function transformGeneratorUserCss(source, options) {
1700
+ if (source.trim().length === 0) return "";
1701
+ if (options.processed) return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(removeProcessedMiniProgramUnsupportedCss(source, {
1702
+ ...options.generatorStyleOptions,
1703
+ ...options.cssUserHandlerOptions
1704
+ })) : source)));
1705
+ const cleanedSource = require_v4_engine.removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
1706
+ if (cleanedSource.trim().length === 0) return "";
1707
+ const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(require_v4_engine.removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(unwrapMiniProgramCascadeLayers(cleanedSource))) : cleanedSource)), { importFallback: options.importFallback })));
1708
+ if (userSource.trim().length === 0) return "";
1709
+ if (isCommentOnlyCss(userSource)) return userSource;
1710
+ if (options.generatorTarget !== "weapp") return userSource;
1711
+ const { css } = await options.styleHandler(userSource, {
1712
+ ...options.generatorStyleOptions,
1713
+ ...options.cssUserHandlerOptions
1112
1714
  });
1113
- if (!matchingCssSource) return resolved?.entries;
1114
- const sourceResolved = await require_v3_engine.resolveTailwindV4EntriesFromCss(matchingCssSource.css, typeof matchingCssSource.base === "string" && matchingCssSource.base.length > 0 ? matchingCssSource.base : typeof matchingCssSource.file === "string" && matchingCssSource.file.length > 0 ? node_path.default.dirname(matchingCssSource.file) : source.base);
1115
- if (sourceResolved?.entries.length) return sourceResolved.entries;
1116
- for (const dependency of matchingCssSource.dependencies ?? []) {
1117
- if (!(0, node_fs.existsSync)(dependency)) continue;
1118
- try {
1119
- const dependencyResolved = await require_v3_engine.resolveTailwindV4EntriesFromCss((0, node_fs.readFileSync)(dependency, "utf8"), node_path.default.dirname(dependency));
1120
- if (dependencyResolved?.entries.length) return dependencyResolved.entries;
1121
- } catch {}
1122
- }
1123
- return resolved?.entries;
1715
+ return removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css));
1124
1716
  }
1125
1717
  //#endregion
1126
1718
  //#region src/bundlers/shared/generator-css/legacy-compat.ts
@@ -1248,7 +1840,7 @@ function removeTailwindApplyRules(rawSource) {
1248
1840
  function resolveLegacyCompatCssSource(rawSource) {
1249
1841
  const cached = legacyCompatSourceCache.get(rawSource);
1250
1842
  if (cached !== void 0) return cached;
1251
- const resolved = closeTrailingUnclosedBlocks((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(removeTailwindApplyRules(require_v3_engine.removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(require_v3_engine.stripTailwindBanners(rawSource))))));
1843
+ const resolved = closeTrailingUnclosedBlocks(removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(removeTailwindApplyRules(require_v4_engine.removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(require_v4_engine.stripTailwindBanners(rawSource)))))));
1252
1844
  setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
1253
1845
  return resolved;
1254
1846
  }
@@ -1278,7 +1870,7 @@ function hasContainerConfigToken(rawSource) {
1278
1870
  }
1279
1871
  function hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) {
1280
1872
  if (hasContainerConfigToken(rawSource)) return true;
1281
- const cssEntrySource = require_v3_engine.resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions));
1873
+ const cssEntrySource = require_v4_engine.resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions));
1282
1874
  if (!cssEntrySource?.config) return false;
1283
1875
  try {
1284
1876
  return /\bcontainer\b/.test((0, node_fs.readFileSync)(cssEntrySource.config, "utf8"));
@@ -1287,8 +1879,9 @@ function hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) {
1287
1879
  }
1288
1880
  }
1289
1881
  function hasConfiguredContainerCompatSource(source) {
1882
+ if (typeof source.css !== "string") return false;
1290
1883
  if (hasContainerConfigToken(source.css)) return true;
1291
- const cssEntrySource = require_v3_engine.resolveCssEntrySource(source.css, source.base);
1884
+ const cssEntrySource = require_v4_engine.resolveCssEntrySource(source.css, source.base);
1292
1885
  if (cssEntrySource?.config) try {
1293
1886
  if (/\bcontainer\b/.test((0, node_fs.readFileSync)(cssEntrySource.config, "utf8"))) return true;
1294
1887
  } catch {}
@@ -1304,7 +1897,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
1304
1897
  const resolvedCompatSource = resolveLegacyCompatCssSource(rawSource);
1305
1898
  const compatSource = removeGeneratedSelectorCompatCss(generatorTarget === "weapp" ? removeMiniProgramContainerCompatCss(resolvedCompatSource) : resolvedCompatSource, css);
1306
1899
  if (compatSource.trim().length === 0) return css;
1307
- if (generatorTarget !== "weapp") return require_v3_engine.createCssAppend(css, compatSource);
1900
+ if (generatorTarget !== "weapp") return require_v4_engine.createCssAppend(css, compatSource);
1308
1901
  const styleOptions = {
1309
1902
  ...cssHandlerOptions,
1310
1903
  ...generatorStyleOptions
@@ -1315,9 +1908,9 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
1315
1908
  compatCss = (await styleHandler(compatSource, styleOptions)).css;
1316
1909
  setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
1317
1910
  }
1318
- const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css), css);
1911
+ const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css)), css);
1319
1912
  if (cleanedCompatCss.trim().length === 0) return css;
1320
- return require_v3_engine.createCssAppend(css, cleanedCompatCss);
1913
+ return require_v4_engine.createCssAppend(css, cleanedCompatCss);
1321
1914
  }
1322
1915
  async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, configuredContainerCompat, generatorTarget, styleHandler, cssHandlerOptions, generatorStyleOptions) {
1323
1916
  if (generatorTarget === "weapp") return css;
@@ -1336,7 +1929,7 @@ async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, con
1336
1929
  }
1337
1930
  const cleanedCompatCss = collectDedupedPostTransformCompatCss((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css);
1338
1931
  if (cleanedCompatCss.trim().length === 0) return css;
1339
- return require_v3_engine.createCssAppend(css, cleanedCompatCss);
1932
+ return require_v4_engine.createCssAppend(css, cleanedCompatCss);
1340
1933
  }
1341
1934
  //#endregion
1342
1935
  //#region src/bundlers/shared/generator-css/legacy-units.ts
@@ -1385,6 +1978,8 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
1385
1978
  //#endregion
1386
1979
  //#region src/bundlers/shared/generator-css/local-imports.ts
1387
1980
  const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
1981
+ const CSS_STYLE_EXTENSION_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss|scss|sass|less|styl|stylus|pcss|postcss)(?:$|[?#])/i;
1982
+ const SOURCE_STYLE_EXTENSION_RE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)(?:$|[?#])/i;
1388
1983
  function createCssSourceOrderAppend(base, extra) {
1389
1984
  if (!base) return extra;
1390
1985
  if (!extra) return base;
@@ -1401,7 +1996,7 @@ function isPureLocalCssImportWrapper(css) {
1401
1996
  for (const node of root.nodes) {
1402
1997
  if (node.type === "comment") continue;
1403
1998
  if (node.type !== "atrule" || node.name !== "import") return false;
1404
- const request = require_v3_engine.parseImportRequest(node.params);
1999
+ const request = require_v4_engine.parseImportRequest(node.params);
1405
2000
  if (!request || !isLocalImportRequest(request)) return false;
1406
2001
  hasImport = true;
1407
2002
  }
@@ -1418,7 +2013,7 @@ function cleanLocalCssImportWrapperTailwindDirectives(css) {
1418
2013
  for (const node of root.nodes) {
1419
2014
  if (node.type === "comment") continue;
1420
2015
  if (node.type === "atrule" && node.name === "import") {
1421
- const request = require_v3_engine.parseImportRequest(node.params);
2016
+ const request = require_v4_engine.parseImportRequest(node.params);
1422
2017
  if (!request || !isLocalImportRequest(request)) return;
1423
2018
  hasLocalImport = true;
1424
2019
  continue;
@@ -1432,13 +2027,13 @@ function cleanLocalCssImportWrapperTailwindDirectives(css) {
1432
2027
  } catch {
1433
2028
  return;
1434
2029
  }
1435
- return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(require_v3_engine.removeTailwindSourceDirectives(css)) : void 0;
2030
+ return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(require_v4_engine.removeTailwindSourceDirectives(css)) : void 0;
1436
2031
  }
1437
2032
  function prefixLocalCssImportsWithWebpackIgnore(css) {
1438
2033
  try {
1439
2034
  const root = _weapp_tailwindcss_postcss.postcss.parse(css);
1440
2035
  root.walkAtRules("import", (atRule) => {
1441
- const request = require_v3_engine.parseImportRequest(atRule.params);
2036
+ const request = require_v4_engine.parseImportRequest(atRule.params);
1442
2037
  if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
1443
2038
  });
1444
2039
  return root.toString();
@@ -1453,7 +2048,7 @@ function splitLocalCssImports(source) {
1453
2048
  let changed = false;
1454
2049
  for (const node of [...root.nodes]) {
1455
2050
  if (node.type !== "atrule" || node.name !== "import") continue;
1456
- const request = require_v3_engine.parseImportRequest(node.params);
2051
+ const request = require_v4_engine.parseImportRequest(node.params);
1457
2052
  if (!request || !isLocalImportRequest(request)) continue;
1458
2053
  importRoot.append(node.clone());
1459
2054
  node.remove();
@@ -1472,238 +2067,40 @@ function restoreLocalCssImports(css, imports) {
1472
2067
  if (!imports?.trim()) return css;
1473
2068
  return createCssSourceOrderAppend(imports, css);
1474
2069
  }
1475
- //#endregion
1476
- //#region src/bundlers/shared/generator-css/user-css.ts
1477
- const TAILWIND_V4_GENERATOR_AT_RULES = new Set([
1478
- "config",
1479
- "custom-variant",
1480
- "plugin",
1481
- "source",
1482
- "theme",
1483
- "utility",
1484
- "variant"
1485
- ]);
1486
- function removeTailwindApplyAtRules(source) {
1487
- if (!source.includes("@apply")) return source;
1488
- try {
1489
- const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1490
- let changed = false;
1491
- root.walkAtRules("apply", (rule) => {
1492
- rule.remove();
1493
- changed = true;
1494
- });
1495
- root.walk((node) => {
1496
- if ("nodes" in node && node.nodes?.length === 0) node.remove();
1497
- });
1498
- return changed ? root.toString() : source;
1499
- } catch {
1500
- return source;
1501
- }
1502
- }
1503
- function removeTailwindV4GeneratorAtRules(source) {
1504
- try {
1505
- const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1506
- let changed = false;
1507
- root.walkAtRules((rule) => {
1508
- if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
1509
- rule.remove();
1510
- changed = true;
1511
- });
1512
- root.walk((node) => {
1513
- if ("nodes" in node && node.nodes?.length === 0) {
1514
- node.remove();
1515
- changed = true;
1516
- }
1517
- });
1518
- return changed ? root.toString() : source;
1519
- } catch {
1520
- return source;
1521
- }
1522
- }
1523
- function isCommentOnlyCss(source) {
1524
- try {
1525
- const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1526
- return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
1527
- } catch {
1528
- return false;
1529
- }
1530
- }
1531
- function stripTailwindSourceMediaFragments(source) {
1532
- let removedSourceMediaStart = false;
1533
- return source.split(/\r?\n/).filter((line) => {
1534
- if (/^\s*@media\s+source\([^)]*\)\s*\{\s*$/.test(line)) {
1535
- removedSourceMediaStart = true;
1536
- return false;
1537
- }
1538
- if (/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/.test(line)) return false;
1539
- if (removedSourceMediaStart && /^\s*\}\s*$/.test(line)) {
1540
- removedSourceMediaStart = false;
1541
- return false;
1542
- }
1543
- return true;
1544
- }).join("\n").replace(/\}[^\S\r\n]*(?=@(?:config|source)\b)/g, "");
1545
- }
1546
- function stripLeadingTailwindSourceMediaCloseFragment(source) {
1547
- return source.replace(/^\s*\}\s*(?:\n|$)/, "");
1548
- }
1549
- function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
1550
- try {
1551
- _weapp_tailwindcss_postcss.postcss.parse(source);
1552
- return source;
1553
- } catch {
1554
- return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
1555
- }
1556
- }
1557
- function splitUserCssLayerBlocks(source) {
1558
- if (!source.includes("@layer")) return {
1559
- layer: "",
1560
- rest: source
2070
+ function splitRequestSuffix(request) {
2071
+ const suffixIndexCandidates = [request.indexOf("?"), request.indexOf("#")].filter((index) => index >= 0);
2072
+ const suffixIndex = suffixIndexCandidates.length > 0 ? Math.min(...suffixIndexCandidates) : -1;
2073
+ if (suffixIndex < 0) return {
2074
+ clean: request,
2075
+ suffix: ""
1561
2076
  };
1562
- try {
1563
- const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1564
- const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
1565
- const restRoot = _weapp_tailwindcss_postcss.postcss.root();
1566
- for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
1567
- return {
1568
- layer: layerRoot.toString(),
1569
- rest: restRoot.toString()
1570
- };
1571
- } catch {
1572
- return {
1573
- layer: source,
1574
- rest: ""
1575
- };
1576
- }
1577
- }
1578
- function hasUserCssLayerBlocks(source) {
1579
- if (!source.includes("@layer")) return false;
1580
- try {
1581
- let hasLayerBlock = false;
1582
- _weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("layer", (node) => {
1583
- if (node.nodes?.length) hasLayerBlock = true;
1584
- });
1585
- return hasLayerBlock;
1586
- } catch {
1587
- return true;
1588
- }
1589
- }
1590
- function collectUserLayerSelectors(source) {
1591
- const selectors = /* @__PURE__ */ new Set();
1592
- try {
1593
- _weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
1594
- for (const selector of rule.selectors ?? [rule.selector]) {
1595
- const normalized = selector.trim();
1596
- if (normalized) selectors.add(normalized);
1597
- }
1598
- });
1599
- } catch {}
1600
- return selectors;
1601
- }
1602
- function matchesUserLayerSelector(selector, userLayerSelector) {
1603
- if (selector === userLayerSelector) return true;
1604
- if (!selector.startsWith(userLayerSelector)) return false;
1605
- const next = selector[userLayerSelector.length];
1606
- return next === ":" || next === "[";
1607
- }
1608
- function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
1609
- const selectors = collectUserLayerSelectors(userLayerSource);
1610
- if (selectors.size === 0) return {
1611
- layer: "",
1612
- rest: css
2077
+ return {
2078
+ clean: request.slice(0, suffixIndex),
2079
+ suffix: request.slice(suffixIndex)
1613
2080
  };
1614
- try {
1615
- const root = _weapp_tailwindcss_postcss.postcss.parse(css);
1616
- const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
1617
- const selectorList = [...selectors];
1618
- root.walkRules((rule) => {
1619
- if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
1620
- layerRoot.append(rule.clone());
1621
- rule.remove();
1622
- }
1623
- });
1624
- return {
1625
- layer: layerRoot.toString(),
1626
- rest: root.toString()
1627
- };
1628
- } catch {
1629
- return {
1630
- layer: "",
1631
- rest: css
1632
- };
1633
- }
1634
- }
1635
- function normalizeGeneratedSelector(selector) {
1636
- return selector.replace(/:not\(#\\#\)/g, "").trim();
1637
- }
1638
- function collectApplyOnlySourceSelectors(source) {
1639
- const selectors = /* @__PURE__ */ new Set();
1640
- try {
1641
- _weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
1642
- if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
1643
- for (const selector of rule.selectors ?? [rule.selector]) {
1644
- const normalized = normalizeGeneratedSelector(selector);
1645
- if (normalized) selectors.add(normalized);
1646
- }
1647
- });
1648
- } catch {}
1649
- return selectors;
1650
2081
  }
1651
- function hasOnlyApplyBackedSourceRules(source) {
1652
- let hasApplyRule = false;
1653
- let hasNonApplyRule = false;
1654
- try {
1655
- _weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
1656
- if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
1657
- else hasNonApplyRule = true;
1658
- });
1659
- } catch {
1660
- return false;
1661
- }
1662
- return hasApplyRule && !hasNonApplyRule;
2082
+ function normalizeOutputImportRequest(request, styleOutputExtension) {
2083
+ const normalizedStyleOutputExtension = styleOutputExtension?.startsWith(".") ? styleOutputExtension : styleOutputExtension ? `.${styleOutputExtension}` : void 0;
2084
+ const { clean, suffix } = splitRequestSuffix(request.replace(/\\/g, "/"));
2085
+ return `${clean.replace(/^(?:\.\/)?src\//, "./").replace(SOURCE_STYLE_EXTENSION_RE, normalizedStyleOutputExtension ?? ".css")}${suffix}`;
1663
2086
  }
1664
- function filterApplyOnlyGeneratedCss(css, source) {
1665
- const selectors = collectApplyOnlySourceSelectors(source);
1666
- if (selectors.size === 0) return css;
1667
- const selectorList = [...selectors];
2087
+ function rewriteLocalCssImportRequestsForOutput(css, options = {}) {
2088
+ if (!css.includes("@import")) return css;
1668
2089
  try {
1669
2090
  const root = _weapp_tailwindcss_postcss.postcss.parse(css);
1670
- root.walkRules((rule) => {
1671
- const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
1672
- const normalized = normalizeGeneratedSelector(selector);
1673
- return selectorList.some((sourceSelector) => {
1674
- if (normalized === sourceSelector) return true;
1675
- if (!normalized.startsWith(sourceSelector)) return false;
1676
- const next = normalized[sourceSelector.length];
1677
- return next === ":" || next === "[" || next === ".";
1678
- });
1679
- });
1680
- const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
1681
- if (!isApplySelector && !isVariableRule) rule.remove();
1682
- });
1683
- root.walkAtRules((rule) => {
1684
- if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
1685
- });
1686
- return root.toString();
1687
- } catch {
1688
- return css;
1689
- }
1690
- }
1691
- function shouldFilterApplyOnlyGeneratedCss(majorVersion, target, source, options) {
1692
- return majorVersion === 4 && target === "weapp" && require_v3_engine.hasTailwindApplyDirective(source) && !require_v3_engine.hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
1693
- }
1694
- async function transformGeneratorUserCss(source, options) {
1695
- if (source.trim().length === 0) return "";
1696
- const cleanedSource = require_v3_engine.removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
1697
- if (cleanedSource.trim().length === 0) return "";
1698
- const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(require_v3_engine.removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedSource) : cleanedSource)), { importFallback: options.importFallback })));
1699
- if (userSource.trim().length === 0) return "";
1700
- if (isCommentOnlyCss(userSource)) return userSource;
1701
- if (options.generatorTarget !== "weapp") return userSource;
1702
- const { css } = await options.styleHandler(userSource, {
1703
- ...options.generatorStyleOptions,
1704
- ...options.cssUserHandlerOptions
1705
- });
1706
- return (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css);
2091
+ let changed = false;
2092
+ root.walkAtRules("import", (atRule) => {
2093
+ const request = require_v4_engine.parseImportRequest(atRule.params);
2094
+ if (!request || !isLocalImportRequest(request) || !CSS_STYLE_EXTENSION_RE.test(request)) return;
2095
+ const rewritten = normalizeOutputImportRequest(request, options.styleOutputExtension);
2096
+ if (rewritten === request) return;
2097
+ atRule.params = atRule.params.replace(request, rewritten);
2098
+ changed = true;
2099
+ });
2100
+ return changed ? root.toString() : css;
2101
+ } catch {
2102
+ return css;
2103
+ }
1707
2104
  }
1708
2105
  //#endregion
1709
2106
  //#region src/bundlers/shared/generator-css/user-layer-order.ts
@@ -1852,17 +2249,21 @@ async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, fac
1852
2249
  await Promise.all(executing);
1853
2250
  return results;
1854
2251
  }
2252
+ function resolveTaskConcurrency(defaultLimit = 1) {
2253
+ const configured = Number.parseInt(node_process.default.env["WEAPP_TW_TASK_CONCURRENCY"] ?? "", 10);
2254
+ if (Number.isFinite(configured) && configured > 0) return configured;
2255
+ return defaultLimit;
2256
+ }
1855
2257
  function pushConcurrentTaskFactories(queue, factories, limit) {
1856
2258
  if (factories.length === 0) return;
1857
2259
  queue.push(runWithConcurrency(factories, limit).then(() => void 0));
1858
2260
  }
1859
2261
  //#endregion
1860
2262
  //#region src/bundlers/shared/generator-css/validate.ts
1861
- const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
1862
2263
  async function validateCandidatesByGenerator(options) {
1863
- const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState } = options;
1864
- const majorVersion = runtimeState.twPatcher.majorVersion;
1865
- if (!SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || candidates.size === 0) return /* @__PURE__ */ new Set();
2264
+ const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState, skipGenerateFallback } = options;
2265
+ const majorVersion = runtimeState.tailwindRuntime.majorVersion;
2266
+ if (majorVersion !== 4 || candidates.size === 0) return /* @__PURE__ */ new Set();
1866
2267
  const generatorOptions = {
1867
2268
  ...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator),
1868
2269
  bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues
@@ -1876,10 +2277,11 @@ async function validateCandidatesByGenerator(options) {
1876
2277
  if (generatorOptions.bareArbitraryValues === void 0 || generatorOptions.bareArbitraryValues === false) {
1877
2278
  if (typeof generator.validateCandidates === "function") return generator.validateCandidates(candidates);
1878
2279
  }
2280
+ if (skipGenerateFallback) return /* @__PURE__ */ new Set();
1879
2281
  return (await generator.generate({
1880
2282
  bareArbitraryValues: generatorOptions.bareArbitraryValues,
1881
2283
  candidates,
1882
- target: "tailwind"
2284
+ target: "web"
1883
2285
  })).classSet;
1884
2286
  }));
1885
2287
  const classSet = new Set(classSets.flatMap((item) => [...item]));
@@ -1893,38 +2295,87 @@ function resolveGeneratorSourceConcurrency() {
1893
2295
  if (Number.isFinite(configured) && configured > 0) return configured;
1894
2296
  return 1;
1895
2297
  }
2298
+ function intersectCandidateSets(left, right) {
2299
+ if (left.size === 0 || right.size === 0) return /* @__PURE__ */ new Set();
2300
+ const [small, large] = left.size <= right.size ? [left, right] : [right, left];
2301
+ const matched = /* @__PURE__ */ new Set();
2302
+ for (const candidate of small) if (large.has(candidate)) matched.add(candidate);
2303
+ return matched;
2304
+ }
2305
+ function collectCssRuleIdentityMarkers(source) {
2306
+ const markers = /* @__PURE__ */ new Set();
2307
+ try {
2308
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
2309
+ root.walkRules((rule) => {
2310
+ for (const selector of rule.selectors ?? [rule.selector]) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
2311
+ });
2312
+ root.walkAtRules("keyframes", (rule) => {
2313
+ if (rule.params) markers.add(`keyframes:${rule.params}`);
2314
+ });
2315
+ } catch {}
2316
+ return markers;
2317
+ }
2318
+ function isCssAlreadyRepresentedByMarkers(css, source) {
2319
+ const sourceMarkers = collectCssRuleIdentityMarkers(source);
2320
+ if (sourceMarkers.size === 0) return false;
2321
+ const cssMarkers = collectCssRuleIdentityMarkers(css);
2322
+ for (const marker of sourceMarkers) if (!cssMarkers.has(marker)) return false;
2323
+ return true;
2324
+ }
1896
2325
  async function generateCssByGenerator(options) {
1897
- const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, debug } = options;
2326
+ const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, userRawSource, userRawSourceProcessed, debug } = options;
1898
2327
  const generatorOptions = {
1899
- ...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator),
2328
+ ...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
2329
+ appType: opts.appType,
2330
+ platform: opts.cssOptions?.platform ?? opts.platform,
2331
+ tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
2332
+ uniAppX: opts.uniAppX
2333
+ }),
1900
2334
  bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues
1901
2335
  };
1902
- const majorVersion = runtimeState.twPatcher.majorVersion;
1903
- const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(require_v3_engine.normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
2336
+ const generatorBranch = require_generator.resolveGeneratorRuntimeBranch(generatorOptions, {
2337
+ appType: opts.appType,
2338
+ platform: opts.cssOptions?.platform ?? opts.platform,
2339
+ tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
2340
+ uniAppX: opts.uniAppX
2341
+ });
2342
+ const majorVersion = runtimeState.tailwindRuntime.majorVersion;
2343
+ if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
2344
+ const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(require_v4_engine.normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
1904
2345
  const localImportParts = splitLocalCssImports(effectiveRawSource);
2346
+ const localImports = options.restoreLocalCssImports === false ? void 0 : localImportParts?.imports;
1905
2347
  const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
1906
- const userCssRawSource = majorVersion === 4 ? removeTailwindV4GeneratorAtRules(generatorRawSource) : generatorRawSource;
2348
+ const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(require_v4_engine.normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
2349
+ const userSource = splitLocalCssImports(rawUserSource)?.source ?? rawUserSource;
2350
+ const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
2351
+ const userCssOrderSource = require_v4_engine.GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : userCssRawSource;
2352
+ const hasDistinctUserRawSource = typeof userRawSource === "string" && normalizeCssSourceForCompare(userCssRawSource) !== normalizeCssSourceForCompare(generatorRawSource);
1907
2353
  const cleanedLocalImportWrapper = cleanLocalCssImportWrapperTailwindDirectives(effectiveRawSource);
1908
2354
  if (cleanedLocalImportWrapper !== void 0) return {
1909
- css: generatorOptions.target === "weapp" ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
2355
+ css: require_generator.shouldUseMiniProgramCssBranch(generatorBranch) ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
2356
+ classSet: /* @__PURE__ */ new Set(),
1910
2357
  target: generatorOptions.target,
1911
2358
  source: "generator",
1912
- dependencies: []
2359
+ dependencies: [],
2360
+ metadata: {
2361
+ file,
2362
+ majorVersion
2363
+ }
1913
2364
  };
1914
2365
  if (isPureLocalCssImportWrapper(effectiveRawSource)) return;
1915
- const hasGeneratedCss = require_v3_engine.hasTailwindGeneratedCss(generatorRawSource);
1916
- const hasSourceDirectives = require_v3_engine.hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
1917
- const hasGeneratedMarkers = require_v3_engine.hasTailwindGeneratedCssMarkers(generatorRawSource);
1918
- const shouldGenerateCurrentCss = shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
2366
+ const hasGeneratedCss = require_v4_engine.hasTailwindGeneratedCss(generatorRawSource);
2367
+ const hasSourceDirectives = require_v4_engine.hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
2368
+ const hasGeneratedMarkers = require_v4_engine.hasTailwindGeneratedCssMarkers(generatorRawSource);
2369
+ if (!shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
2370
+ forceGenerator: options.forceGenerator,
1919
2371
  hasGeneratedCss,
1920
2372
  hasGeneratedMarkers,
1921
2373
  hasSourceDirectives,
1922
2374
  rawSource: generatorRawSource
1923
- });
1924
- if (!isSupportedGeneratorMajorVersion(majorVersion) || !shouldGenerateCurrentCss || majorVersion === 3 && !hasSourceDirectives && !hasGeneratedCss && !hasGeneratedMarkers) return;
2375
+ })) return;
1925
2376
  try {
1926
2377
  await runtimeState.readyPromise;
1927
- const currentCssCandidates = majorVersion === 4 ? await (0, tailwindcss_patch.extractSourceCandidates)(generatorRawSource, "css", { ...generatorOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: generatorOptions.bareArbitraryValues } }) : [];
2378
+ const currentCssCandidates = await (0, _tailwindcss_mangle_engine.extractSourceCandidates)(generatorRawSource, "css", { ...generatorOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: generatorOptions.bareArbitraryValues } });
1928
2379
  const isolateCurrentCssCandidates = shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, {
1929
2380
  hasGeneratedCss,
1930
2381
  hasGeneratedMarkers,
@@ -1933,6 +2384,7 @@ async function generateCssByGenerator(options) {
1933
2384
  const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
1934
2385
  const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
1935
2386
  cssEntries: opts.cssEntries,
2387
+ cssSources: options.cssSources,
1936
2388
  getSourceCandidatesForEntries,
1937
2389
  runtime: runtimeWithCurrentCss
1938
2390
  });
@@ -1941,52 +2393,65 @@ async function generateCssByGenerator(options) {
1941
2393
  const sourceConcurrency = resolveGeneratorSourceConcurrency();
1942
2394
  const generated = mergeGeneratorResults((await runWithConcurrency(sources.map((source) => async () => {
1943
2395
  const generator = require_generator.createWeappTailwindcssGenerator(source);
1944
- const sourceEntries = getSourceCandidatesForEntries && (majorVersion === 3 || majorVersion === 4) ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
1945
- const scopedRuntime = sourceEntries ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
1946
- const isolateCssSource = shouldIsolateScopedCssSource(source, sourceEntries);
2396
+ const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
2397
+ const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
2398
+ const scopedRuntime = options.sourceCandidates && sourceScopedRuntime ? intersectCandidateSets(options.sourceCandidates, sourceScopedRuntime) : options.sourceCandidates ?? sourceScopedRuntime;
2399
+ const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, source, sourceEntries, {
2400
+ cssHandlerOptions,
2401
+ target: generatorOptions.target
2402
+ });
1947
2403
  const sourceMetadata = source.__weappTailwindcssMeta;
1948
2404
  const matchedCssSourceFile = Boolean(sourceMetadata?.matchedCssSourceFile);
1949
2405
  if (options.deferEmptyScopedCssSource && isolateCssSource && scopedRuntime?.size === 0 && currentCssCandidates.length === 0 && !cssHandlerOptions.isMainChunk) {
1950
2406
  debug("defer empty scoped css source generation: %s", file);
1951
2407
  return;
1952
2408
  }
1953
- const sourceRuntime = scopedRuntime && (scopedRuntime.size > 0 || isolateCssSource) ? isolateCurrentCssCandidates ? runtimeWithCurrentCss : mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtimeWithCurrentCss, {
2409
+ const sourceRuntime = scopedRuntime && (scopedRuntime.size > 0 || isolateCssSource) || isolateCssSource ? isolateCurrentCssCandidates ? runtimeWithCurrentCss : mergeScopedRuntimeWithCurrentRuntime(scopedRuntime ?? /* @__PURE__ */ new Set(), runtimeWithCurrentCss, {
1954
2410
  currentCssCandidates,
1955
2411
  cssHandlerOptions,
1956
2412
  isolateCssSource,
2413
+ majorVersion,
1957
2414
  matchedCssSourceFile
1958
2415
  }) : runtimeWithCurrentCss;
1959
- const generatorRuntime = majorVersion === 4 && generatorOptions.target === "weapp" ? require_v3_engine.filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime;
1960
- const useIncrementalCache = (majorVersion === 3 || majorVersion === 4) && !(majorVersion === 3 && isolateCssSource);
2416
+ const generatorRuntime = require_generator.shouldUseMiniProgramCssBranch(generatorBranch) ? require_v4_engine.filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime;
1961
2417
  return generator.generate({
1962
2418
  bareArbitraryValues: generatorOptions.bareArbitraryValues,
1963
2419
  candidates: generatorRuntime,
1964
- incrementalCache: useIncrementalCache,
2420
+ incrementalCache: true,
1965
2421
  scanSources: shouldScanTailwindV4Sources(majorVersion, generatorOptions.target, generatorRuntime, isolateCssSource),
1966
2422
  styleOptions: generatorStyleOptions,
1967
- tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
1968
2423
  target: generatorOptions.target
1969
2424
  });
1970
2425
  }), sourceConcurrency)).filter((item) => Boolean(item)));
1971
2426
  if (!generated) return;
1972
2427
  debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
1973
2428
  if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
1974
- const incrementalCss = require_v3_engine.stripTailwindBanner(generated.incrementalCss);
2429
+ const incrementalCss = require_v4_engine.stripTailwindBanner(generated.incrementalCss);
1975
2430
  return {
1976
- css: restoreLocalCssImports(incrementalCss.trim().length > 0 ? require_v3_engine.createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, { injectPreflight: false })) : options.previousCss, localImportParts?.imports),
2431
+ css: restoreLocalCssImports(incrementalCss.trim().length > 0 ? require_v4_engine.createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
2432
+ injectPreflight: false,
2433
+ styleOptions: generatorStyleOptions
2434
+ })) : options.previousCss, localImports),
2435
+ classSet: generated.classSet,
1977
2436
  target: generated.target,
1978
2437
  source: "generator",
1979
2438
  dependencies: generated.dependencies,
1980
- incremental: true
2439
+ incremental: true,
2440
+ metadata: {
2441
+ file,
2442
+ majorVersion,
2443
+ rawCss: generated.rawCss
2444
+ }
1981
2445
  };
1982
2446
  }
1983
2447
  const shouldFilterApplyOnlyCss = shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
1984
2448
  hasGeneratedCss,
1985
2449
  hasGeneratedMarkers
1986
2450
  });
1987
- const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(require_v3_engine.stripTailwindBanner(generated.css), generatorRawSource) : require_v3_engine.stripTailwindBanner(generated.css);
2451
+ const generatedCssSource = generated.target === "web" ? generated.css : require_v4_engine.stripTailwindBanner(generated.css);
2452
+ const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource) : generatedCssSource;
1988
2453
  const hasMatchedCssSourceFile = sources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
1989
- const orderedExtraCss = hasMatchedCssSourceFile ? require_v3_engine.splitTailwindV4GeneratedCssBySourceOrder(userCssRawSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssRawSource, generated.rawCss);
2454
+ const orderedExtraCss = require_v4_engine.splitGeneratorPlaceholderCssBySourceOrder(userCssOrderSource, generated.rawCss) ?? (hasMatchedCssSourceFile ? require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(userCssOrderSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssOrderSource, generated.rawCss));
1990
2455
  const shouldAppendMatchedCssSourceCompat = !hasMatchedCssSourceFile || orderedExtraCss !== void 0;
1991
2456
  if (orderedExtraCss) {
1992
2457
  let css = generatedCss;
@@ -1996,7 +2461,8 @@ async function generateCssByGenerator(options) {
1996
2461
  generatorStyleOptions,
1997
2462
  cssUserHandlerOptions,
1998
2463
  styleHandler,
1999
- importFallback: generatorOptions.importFallback
2464
+ importFallback: generatorOptions.importFallback,
2465
+ processed: userRawSourceProcessed
2000
2466
  };
2001
2467
  const afterLayerParts = generated.target === "weapp" ? splitUserCssLayerBlocks(orderedExtraCss.after) : {
2002
2468
  layer: "",
@@ -2005,7 +2471,8 @@ async function generateCssByGenerator(options) {
2005
2471
  const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
2006
2472
  const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
2007
2473
  const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
2008
- css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(afterLayerUserCss) : afterLayerUserCss), css), afterUserCss);
2474
+ const fallbackLayerUserCss = generated.target === "weapp" && afterLayerParts.layer.trim().length === 0 && hasUserCssLayerBlocks(userCssRawSource) ? await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions) : "";
2475
+ css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(createCssSourceOrderAppend$1(afterLayerUserCss, fallbackLayerUserCss)) : afterLayerUserCss), css), afterUserCss);
2009
2476
  if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
2010
2477
  hasSourceDirectives,
2011
2478
  hasMatchedCssSourceFile
@@ -2013,26 +2480,53 @@ async function generateCssByGenerator(options) {
2013
2480
  const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
2014
2481
  css = createCssSourceOrderAppend$1(css, userCss);
2015
2482
  }
2483
+ if (generated.target === "web") {
2484
+ const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
2485
+ const missingUserCss = isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
2486
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2487
+ }
2488
+ if (generated.target === "weapp" && isEmptyCssSourceOrderParts(orderedExtraCss) && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(userCssRawSource)) {
2489
+ const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
2490
+ const missingUserCss = isCssAlreadyRepresentedByMarkers(css, userCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
2491
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2492
+ }
2016
2493
  if (generated.target === "weapp" && shouldAppendMatchedCssSourceCompat) {
2017
2494
  if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
2018
- if (!shouldFilterApplyOnlyCss) {
2495
+ if (!shouldFilterApplyOnlyCss && !userRawSourceProcessed) {
2019
2496
  css = await appendLegacyCompatCss(css, userCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2020
2497
  if (!isolateCurrentCssCandidates) css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2021
2498
  }
2022
2499
  } else if (generated.target === "weapp" && shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
2023
2500
  return {
2024
- css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, { injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
2025
- cssHandlerOptions,
2026
- isolateCurrentCssCandidates,
2027
- localImports: localImportParts?.imports
2028
- }) }), localImportParts?.imports),
2501
+ css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
2502
+ injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
2503
+ cssHandlerOptions,
2504
+ isolateCurrentCssCandidates,
2505
+ localImports
2506
+ }),
2507
+ styleOptions: generatorStyleOptions
2508
+ }), localImports),
2509
+ classSet: generated.classSet,
2029
2510
  target: generated.target,
2030
2511
  source: "generator",
2031
- dependencies: generated.dependencies
2512
+ dependencies: generated.dependencies,
2513
+ metadata: {
2514
+ file,
2515
+ majorVersion,
2516
+ rawCss: generated.rawCss
2517
+ }
2032
2518
  };
2033
2519
  }
2034
2520
  debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
2035
2521
  let css = generatedCss;
2522
+ if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend$1(await transformGeneratorUserCss(userCssRawSource, {
2523
+ generatorTarget: generated.target,
2524
+ generatorStyleOptions,
2525
+ cssUserHandlerOptions,
2526
+ styleHandler,
2527
+ importFallback: generatorOptions.importFallback,
2528
+ processed: userRawSourceProcessed
2529
+ }), css);
2036
2530
  if (generated.target === "weapp") {
2037
2531
  css = inheritLegacyUnitConvertedDeclarations(css, generatorRawSource);
2038
2532
  if (hasUserCssLayerBlocks(generatorRawSource)) {
@@ -2042,9 +2536,10 @@ async function generateCssByGenerator(options) {
2042
2536
  generatorStyleOptions,
2043
2537
  cssUserHandlerOptions,
2044
2538
  styleHandler,
2045
- importFallback: generatorOptions.importFallback
2539
+ importFallback: generatorOptions.importFallback,
2540
+ processed: userRawSourceProcessed
2046
2541
  });
2047
- const layerCss = layerUserCss.trim().length > 0 && !require_v3_engine.hasTailwindApplyDirective(layerUserCss) ? {
2542
+ const layerCss = layerUserCss.trim().length > 0 && !require_v4_engine.hasTailwindApplyDirective(layerUserCss) ? {
2048
2543
  layer: layerUserCss,
2049
2544
  rest: css
2050
2545
  } : extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
@@ -2055,18 +2550,44 @@ async function generateCssByGenerator(options) {
2055
2550
  }
2056
2551
  }
2057
2552
  if (hasMatchedCssSourceFile || generated.target === "web") {
2058
- if (hasMatchedCssSourceFile && generated.target === "weapp" && !hasGeneratedCss && !hasGeneratedMarkers) {
2553
+ if (generated.target === "weapp" && !hasGeneratedCss && !hasGeneratedMarkers) {
2059
2554
  const userCss = await transformGeneratorUserCss(userCssRawSource, {
2060
2555
  generatorTarget: generated.target,
2061
2556
  generatorStyleOptions,
2062
2557
  cssUserHandlerOptions,
2063
2558
  styleHandler,
2064
- importFallback: generatorOptions.importFallback
2559
+ importFallback: generatorOptions.importFallback,
2560
+ processed: userRawSourceProcessed
2065
2561
  });
2066
- css = createCssSourceOrderAppend$1(css, userCss);
2562
+ const missingUserCss = isCssAlreadyRepresentedByMarkers(css, userCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
2563
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2564
+ } else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasGeneratedMarkers) {
2565
+ const userCss = await transformGeneratorUserCss(removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource), {
2566
+ generatorTarget: generated.target,
2567
+ generatorStyleOptions,
2568
+ cssUserHandlerOptions,
2569
+ styleHandler,
2570
+ importFallback: generatorOptions.importFallback,
2571
+ processed: userRawSourceProcessed
2572
+ });
2573
+ const missingUserCss = (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
2574
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2575
+ } else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasUserCssLayerBlocks(userCssRawSource)) {
2576
+ const layerUserCss = await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, {
2577
+ generatorTarget: generated.target,
2578
+ generatorStyleOptions,
2579
+ cssUserHandlerOptions,
2580
+ styleHandler,
2581
+ importFallback: generatorOptions.importFallback,
2582
+ processed: userRawSourceProcessed
2583
+ });
2584
+ if (layerUserCss.trim().length > 0) {
2585
+ css = createCssSourceOrderAppend$1(css, wrapUserLayerComponentsCss(layerUserCss));
2586
+ if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
2587
+ }
2067
2588
  }
2068
2589
  if (hasMatchedCssSourceFile && generated.target === "weapp") {
2069
- if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss) css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2590
+ if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss && !userRawSourceProcessed) css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2070
2591
  }
2071
2592
  if (shouldAppendWebBundleCssFallback(generated.target, {
2072
2593
  hasSourceDirectives,
@@ -2077,34 +2598,66 @@ async function generateCssByGenerator(options) {
2077
2598
  generatorStyleOptions,
2078
2599
  cssUserHandlerOptions,
2079
2600
  styleHandler,
2080
- importFallback: generatorOptions.importFallback
2601
+ importFallback: generatorOptions.importFallback,
2602
+ processed: userRawSourceProcessed
2081
2603
  });
2082
- css = createCssSourceOrderAppend$1(css, userCss);
2604
+ const missingUserCss = isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
2605
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2083
2606
  }
2084
2607
  return {
2085
- css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, { injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
2086
- cssHandlerOptions,
2087
- isolateCurrentCssCandidates,
2088
- localImports: localImportParts?.imports
2089
- }) }), localImportParts?.imports),
2608
+ css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
2609
+ injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
2610
+ cssHandlerOptions,
2611
+ isolateCurrentCssCandidates,
2612
+ localImports
2613
+ }),
2614
+ styleOptions: generatorStyleOptions
2615
+ }), localImports),
2616
+ classSet: generated.classSet,
2090
2617
  target: generated.target,
2091
2618
  source: "generator",
2092
- dependencies: generated.dependencies
2619
+ dependencies: generated.dependencies,
2620
+ metadata: {
2621
+ file,
2622
+ majorVersion,
2623
+ rawCss: generated.rawCss
2624
+ }
2093
2625
  };
2094
2626
  }
2095
- if (!shouldFilterApplyOnlyCss) {
2627
+ if (!shouldFilterApplyOnlyCss && !userRawSourceProcessed) {
2096
2628
  css = await appendLegacyCompatCss(css, userCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2097
2629
  css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2098
2630
  }
2631
+ if (generated.target === "weapp" && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(userCssRawSource)) {
2632
+ const userCss = await transformGeneratorUserCss(userCssRawSource, {
2633
+ generatorTarget: generated.target,
2634
+ generatorStyleOptions,
2635
+ cssUserHandlerOptions,
2636
+ styleHandler,
2637
+ importFallback: generatorOptions.importFallback,
2638
+ processed: userRawSourceProcessed
2639
+ });
2640
+ const missingUserCss = isCssAlreadyRepresentedByMarkers(css, userCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
2641
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2642
+ }
2099
2643
  return {
2100
- css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, { injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
2101
- cssHandlerOptions,
2102
- isolateCurrentCssCandidates,
2103
- localImports: localImportParts?.imports
2104
- }) }), localImportParts?.imports),
2644
+ css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
2645
+ injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
2646
+ cssHandlerOptions,
2647
+ isolateCurrentCssCandidates,
2648
+ localImports
2649
+ }),
2650
+ styleOptions: generatorStyleOptions
2651
+ }), localImports),
2652
+ classSet: generated.classSet,
2105
2653
  target: generated.target,
2106
2654
  source: "generator",
2107
- dependencies: generated.dependencies
2655
+ dependencies: generated.dependencies,
2656
+ metadata: {
2657
+ file,
2658
+ majorVersion,
2659
+ rawCss: generated.rawCss
2660
+ }
2108
2661
  };
2109
2662
  } catch (error) {
2110
2663
  debug("tailwind direct css generation failed: %s %O", file, error);
@@ -2205,186 +2758,23 @@ function collectEscapedRuntimeCandidates(source, escapeMap, escapeFragments) {
2205
2758
  }
2206
2759
  return candidates;
2207
2760
  }
2208
- //#endregion
2209
- //#region src/bundlers/vite/incremental-runtime-class-set/v3-candidates.ts
2210
- const TAILWIND_V3_ARBITRARY_UTILITY_PREFIXES = new Set([
2211
- "accent",
2212
- "animate",
2213
- "basis",
2214
- "bg",
2215
- "blur",
2216
- "border",
2217
- "bottom",
2218
- "brightness",
2219
- "caret",
2220
- "col",
2221
- "columns",
2222
- "content",
2223
- "contrast",
2224
- "decoration",
2225
- "delay",
2226
- "divide",
2227
- "drop-shadow",
2228
- "duration",
2229
- "ease",
2230
- "fill",
2231
- "font",
2232
- "gap",
2233
- "gradient",
2234
- "grid",
2235
- "grayscale",
2236
- "grow",
2237
- "h",
2238
- "hue-rotate",
2239
- "indent",
2240
- "inset",
2241
- "invert",
2242
- "leading",
2243
- "left",
2244
- "list",
2245
- "m",
2246
- "max",
2247
- "mb",
2248
- "min",
2249
- "ml",
2250
- "mr",
2251
- "mt",
2252
- "mx",
2253
- "my",
2254
- "object",
2255
- "opacity",
2256
- "order",
2257
- "outline",
2258
- "overflow",
2259
- "p",
2260
- "pb",
2261
- "pl",
2262
- "pr",
2263
- "pt",
2264
- "px",
2265
- "py",
2266
- "right",
2267
- "ring",
2268
- "rotate",
2269
- "rounded",
2270
- "row",
2271
- "saturate",
2272
- "scale",
2273
- "scroll",
2274
- "sepia",
2275
- "shadow",
2276
- "shrink",
2277
- "skew",
2278
- "space",
2279
- "stroke",
2280
- "text",
2281
- "top",
2282
- "tracking",
2283
- "translate",
2284
- "underline",
2285
- "w",
2286
- "z"
2287
- ]);
2288
- function isUrlLikeCandidate(candidate) {
2289
- return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
2290
- }
2291
- function getBaseUtilityCandidate(candidate) {
2292
- let bracketDepth = 0;
2293
- let lastVariantSeparator = -1;
2294
- for (let index = 0; index < candidate.length; index++) {
2295
- const char = candidate[index];
2296
- if (char === "[") bracketDepth += 1;
2297
- else if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
2298
- else if (char === ":" && bracketDepth === 0) lastVariantSeparator = index;
2299
- }
2300
- let utility = lastVariantSeparator >= 0 ? candidate.slice(lastVariantSeparator + 1) : candidate;
2301
- if (utility.startsWith("!")) utility = utility.slice(1);
2302
- if (utility.startsWith("-")) utility = utility.slice(1);
2303
- return utility;
2304
- }
2305
- function getArbitraryUtilityPrefix(utility) {
2306
- const bracketIndex = utility.indexOf("[");
2307
- if (bracketIndex <= 0 || !utility.endsWith("]")) return;
2308
- const prefix = utility.slice(0, bracketIndex).replace(/-$/, "");
2309
- const firstDash = prefix.indexOf("-");
2310
- return firstDash >= 0 ? prefix.slice(0, firstDash) : prefix;
2311
- }
2312
- function isLikelyTailwindV3ArbitraryUtility(candidate) {
2313
- const utility = getBaseUtilityCandidate(candidate);
2314
- if (utility.startsWith("[") && utility.endsWith("]") && utility.includes(":")) return true;
2315
- const prefix = getArbitraryUtilityPrefix(utility);
2316
- return Boolean(prefix && TAILWIND_V3_ARBITRARY_UTILITY_PREFIXES.has(prefix));
2317
- }
2318
- function isLikelyTailwindV3VariantUtility(candidate) {
2319
- if (!candidate.includes(":") || isUrlLikeCandidate(candidate)) return false;
2320
- const utility = getBaseUtilityCandidate(candidate);
2321
- return /^[!-]?[a-z@[]/.test(utility);
2322
- }
2323
- function isLikelyTailwindV3OpacityModifier(candidate) {
2324
- if (!candidate.includes("/") || isUrlLikeCandidate(candidate)) return false;
2325
- const utility = getBaseUtilityCandidate(candidate);
2326
- return /^[!-]?[a-z][\w-]*-\w[\w-]*\/(?:\d+|\[[^\]]+\])$/.test(utility);
2327
- }
2328
- function isHighConfidenceV3Candidate(candidate) {
2329
- return isLikelyTailwindV3ArbitraryUtility(candidate) || isLikelyTailwindV3VariantUtility(candidate) || isLikelyTailwindV3OpacityModifier(candidate);
2330
- }
2331
- function isRawCandidateInClassContext(source, start, extension) {
2332
- if (typeof start !== "number" || start <= 0) return false;
2333
- const before = source.slice(Math.max(0, start - 200), start);
2334
- if (extension === "html") return /\bclass\s*=\s*["'][^"']*$/i.test(before);
2335
- return /\bclass(?:Name)?\s*[:=]\s*["'][^"']*$/i.test(before) || /\.classList\.(?:add|remove|toggle|contains)\([^)]*$/i.test(before);
2336
- }
2337
- function resolveQuotedLiteralRange(source, start) {
2338
- if (typeof start !== "number" || start <= 0) return;
2339
- let quote;
2340
- let literalStart = -1;
2341
- for (let index = start - 1; index >= 0; index--) {
2342
- const char = source[index];
2343
- if (char !== "\"" && char !== "'" && char !== "`") continue;
2344
- quote = char;
2345
- literalStart = index;
2346
- break;
2347
- }
2348
- if (!quote) return;
2349
- let escaped = false;
2350
- for (let index = literalStart + 1; index < source.length; index++) {
2351
- const char = source[index];
2352
- if (escaped) {
2353
- escaped = false;
2354
- continue;
2355
- }
2356
- if (char === "\\") {
2357
- escaped = true;
2358
- continue;
2359
- }
2360
- if (char === quote) {
2361
- if (start < index) return {
2362
- start: literalStart,
2363
- end: index
2364
- };
2365
- return;
2761
+ function collectStrictEscapedRuntimeCandidates(source, escapeMap, escapeFragments) {
2762
+ const candidates = /* @__PURE__ */ new Set();
2763
+ ESCAPED_CLASS_TOKEN_RE.lastIndex = 0;
2764
+ let match = ESCAPED_CLASS_TOKEN_RE.exec(source);
2765
+ while (match) {
2766
+ const token = match[0];
2767
+ if (hasEscapeFragment(token, escapeFragments)) {
2768
+ const restored = (0, _weapp_core_escape.unescape)(token, { map: escapeMap });
2769
+ if (restored !== token && TAILWIND_RESTORED_CANDIDATE_SIGNAL_RE.test(restored) && !/\s/.test(restored)) candidates.add(restored);
2366
2770
  }
2771
+ match = ESCAPED_CLASS_TOKEN_RE.exec(source);
2367
2772
  }
2368
- }
2369
- function createHighConfidenceLiteralRanges(source, matches) {
2370
- const ranges = [];
2371
- for (const match of matches) {
2372
- const candidate = match?.rawCandidate;
2373
- if (typeof candidate !== "string" || !isHighConfidenceV3Candidate(candidate)) continue;
2374
- const range = resolveQuotedLiteralRange(source, match?.start ?? source.indexOf(candidate));
2375
- if (range) ranges.push(range);
2376
- }
2377
- return ranges;
2378
- }
2379
- function isRawCandidateInRanges(start, ranges) {
2380
- return typeof start === "number" && ranges.some((range) => start > range.start && start < range.end);
2381
- }
2382
- function isRawCandidateAllowedForV3(source, candidate, start, extension, knownSourceCandidates, highConfidenceLiteralRanges = []) {
2383
- return isHighConfidenceV3Candidate(candidate) || knownSourceCandidates?.has(candidate) === true || isRawCandidateInClassContext(source, start, extension) || isRawCandidateInRanges(start, highConfidenceLiteralRanges);
2773
+ return candidates;
2384
2774
  }
2385
2775
  //#endregion
2386
2776
  //#region src/bundlers/vite/incremental-runtime-class-set.ts
2387
- const debug = require_v3_engine.createDebug("[vite:runtime-set] ");
2777
+ const debug = require_context.createDebug("[vite:runtime-set] ");
2388
2778
  function createExtractOptions(context, source, bareArbitraryValues) {
2389
2779
  return {
2390
2780
  cwd: context.projectRoot,
@@ -2426,8 +2816,8 @@ function createNonSourceBaseClassSet(baseClassSet, candidateCountByClass) {
2426
2816
  }
2427
2817
  function createBundleRuntimeClassSetManager(options = {}) {
2428
2818
  const customExtractCandidates = options.extractCandidates;
2429
- const extractCandidates = customExtractCandidates ?? tailwindcss_patch.extractValidCandidates;
2430
- const extractRawCandidates = options.extractRawCandidates ?? tailwindcss_patch.extractRawCandidatesWithPositions;
2819
+ const extractCandidates = customExtractCandidates ?? _tailwindcss_mangle_engine.extractValidCandidates;
2820
+ const extractRawCandidates = options.extractRawCandidates ?? _tailwindcss_mangle_engine.extractRawCandidatesWithPositions;
2431
2821
  const escapeMap = options.escapeMap ?? _weapp_core_escape.MappingChars2String;
2432
2822
  const escapeFragments = createEscapeFragments(escapeMap);
2433
2823
  let baseClassSet = /* @__PURE__ */ new Set();
@@ -2446,25 +2836,21 @@ function createBundleRuntimeClassSetManager(options = {}) {
2446
2836
  validationContext = void 0;
2447
2837
  designSystemPromise = void 0;
2448
2838
  }
2449
- async function resolveValidationContextCached(patcher) {
2450
- if (!validationContext) validationContext = await require_v3_engine.resolveTailwindV4SourceFromPatcher(patcher);
2839
+ async function resolveValidationContextCached(runtime) {
2840
+ if (!validationContext) validationContext = await require_v4_engine.resolveTailwindV4SourceFromRuntime(runtime);
2451
2841
  return validationContext;
2452
2842
  }
2453
2843
  async function loadDesignSystem(context) {
2454
- if (!designSystemPromise) designSystemPromise = (0, tailwindcss_patch.loadTailwindV4DesignSystem)(context);
2844
+ if (!designSystemPromise) designSystemPromise = (0, _tailwindcss_mangle_engine.loadTailwindV4DesignSystem)(context);
2455
2845
  return designSystemPromise;
2456
2846
  }
2457
2847
  function populateCandidateValidityCacheFromDesignSystem(designSystem, unknownCandidates) {
2458
- const validCandidates = (0, tailwindcss_patch.resolveValidTailwindV4Candidates)(designSystem, unknownCandidates, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
2848
+ const validCandidates = (0, _tailwindcss_mangle_engine.resolveValidTailwindV4Candidates)(designSystem, unknownCandidates, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
2459
2849
  for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, validCandidates.has(candidate));
2460
2850
  }
2461
- async function validateUnknownCandidates(patcher, unknownCandidates) {
2851
+ async function validateUnknownCandidates(runtime, unknownCandidates) {
2462
2852
  if (unknownCandidates.size === 0) return;
2463
- if (patcher.majorVersion === 3 && !customExtractCandidates) {
2464
- for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, true);
2465
- return;
2466
- }
2467
- const context = await resolveValidationContextCached(patcher);
2853
+ const context = await resolveValidationContextCached(runtime);
2468
2854
  if (!customExtractCandidates) try {
2469
2855
  populateCandidateValidityCacheFromDesignSystem(await loadDesignSystem(context), unknownCandidates);
2470
2856
  return;
@@ -2477,23 +2863,19 @@ function createBundleRuntimeClassSetManager(options = {}) {
2477
2863
  const validCandidates = new Set(await extractCandidates(createExtractOptions(context, source, options.bareArbitraryValues)));
2478
2864
  for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, validCandidates.has(candidate));
2479
2865
  }
2480
- async function extractEntryRawCandidates(entry, patcher, knownSourceCandidates) {
2866
+ async function extractEntryRawCandidates(entry, _runtime, _knownSourceCandidates) {
2481
2867
  const extension = resolveEntryExtension(entry);
2482
2868
  const matches = options.bareArbitraryValues === void 0 || options.bareArbitraryValues === false ? await extractRawCandidates(entry.source, extension) : await extractRawCandidates(entry.source, extension, { bareArbitraryValues: options.bareArbitraryValues });
2483
- const highConfidenceLiteralRanges = patcher.majorVersion === 3 && !customExtractCandidates ? createHighConfidenceLiteralRanges(entry.source, matches) : [];
2484
2869
  const candidates = /* @__PURE__ */ new Set();
2485
2870
  for (const match of matches) {
2486
2871
  const candidate = match?.rawCandidate;
2487
- if (typeof candidate === "string" && candidate.length > 0) {
2488
- if (patcher.majorVersion === 3 && !customExtractCandidates && !isRawCandidateAllowedForV3(entry.source, candidate, match.start, extension, knownSourceCandidates, highConfidenceLiteralRanges)) continue;
2489
- candidates.add(candidate);
2490
- }
2872
+ if (typeof candidate === "string" && candidate.length > 0) candidates.add(candidate);
2491
2873
  }
2492
- if (patcher.majorVersion === 4) for (const candidate of collectEscapedRuntimeCandidates(entry.source, escapeMap, escapeFragments)) candidates.add(candidate);
2874
+ for (const candidate of collectEscapedRuntimeCandidates(entry.source, escapeMap, escapeFragments)) candidates.add(candidate);
2493
2875
  return candidates;
2494
2876
  }
2495
- async function sync(patcher, snapshot, options = {}) {
2496
- const nextSignature = require_v3_engine.getRuntimeClassSetSignature(patcher) ?? "runtime:missing";
2877
+ async function sync(runtime, snapshot, options = {}) {
2878
+ const nextSignature = require_tailwindcss.getRuntimeClassSetSignature(runtime) ?? "runtime:missing";
2497
2879
  const runtimeEntries = createRuntimeEntries(snapshot);
2498
2880
  const runtimeEntriesByFile = new Map(runtimeEntries.map((entry) => [entry.file, entry]));
2499
2881
  const currentRuntimeFiles = new Set(runtimeEntriesByFile.keys());
@@ -2518,14 +2900,14 @@ function createBundleRuntimeClassSetManager(options = {}) {
2518
2900
  }
2519
2901
  const rawCandidatesByFile = /* @__PURE__ */ new Map();
2520
2902
  const unknownCandidates = /* @__PURE__ */ new Set();
2521
- await Promise.all(changedRuntimeFiles.map(async (file) => {
2903
+ for (const file of changedRuntimeFiles) {
2522
2904
  const entry = runtimeEntriesByFile.get(file);
2523
- if (!entry) return;
2524
- const candidates = await extractEntryRawCandidates(entry, patcher, nextBaseClassSet);
2905
+ if (!entry) continue;
2906
+ const candidates = await extractEntryRawCandidates(entry, runtime, nextBaseClassSet);
2525
2907
  rawCandidatesByFile.set(file, candidates);
2526
2908
  for (const candidate of candidates) if (!candidateValidityCache.has(candidate)) unknownCandidates.add(candidate);
2527
- }));
2528
- await validateUnknownCandidates(patcher, unknownCandidates);
2909
+ }
2910
+ await validateUnknownCandidates(runtime, unknownCandidates);
2529
2911
  let rawCandidateCount = 0;
2530
2912
  for (const file of changedRuntimeFiles) {
2531
2913
  const nextRawCandidates = rawCandidatesByFile.get(file);
@@ -2555,6 +2937,52 @@ function createBundleRuntimeClassSetManager(options = {}) {
2555
2937
  };
2556
2938
  }
2557
2939
  //#endregion
2940
+ //#region src/tailwindcss/candidates.ts
2941
+ const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = new Set([
2942
+ "js",
2943
+ "jsx",
2944
+ "mjs",
2945
+ "cjs",
2946
+ "ts",
2947
+ "tsx",
2948
+ "mts",
2949
+ "cts"
2950
+ ]);
2951
+ async function extractCandidatesFromSource(source, extension, options = {}) {
2952
+ const candidates = options.extractor ? new Set(await options.extractor(source, extension)) : new Set(await (0, _tailwindcss_mangle_engine.extractSourceCandidates)(source, extension, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } }));
2953
+ const scriptCandidates = await extractScriptStringCandidates(source, extension, options);
2954
+ for (const candidate of scriptCandidates) candidates.add(candidate);
2955
+ return candidates;
2956
+ }
2957
+ async function extractScriptStringCandidates(source, extension, options) {
2958
+ if (!SCRIPT_SOURCE_CANDIDATE_EXTENSIONS.has(extension)) return [];
2959
+ const values = /* @__PURE__ */ new Set();
2960
+ try {
2961
+ require_context.traverse(require_context.babelParse(source, {
2962
+ cache: true,
2963
+ cacheKey: `source-candidates:${extension}`,
2964
+ plugins: ["jsx", "typescript"],
2965
+ sourceType: "unambiguous"
2966
+ }), {
2967
+ noScope: true,
2968
+ StringLiteral(path) {
2969
+ values.add(path.node.value);
2970
+ },
2971
+ TemplateElement(path) {
2972
+ values.add(path.node.value.raw);
2973
+ }
2974
+ });
2975
+ } catch {
2976
+ return [];
2977
+ }
2978
+ const candidates = /* @__PURE__ */ new Set();
2979
+ for (const value of values) {
2980
+ const extractedCandidates = options.extractor ? await options.extractor(value, "html") : await (0, _tailwindcss_mangle_engine.extractSourceCandidates)(value, "html", { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
2981
+ for (const candidate of extractedCandidates) candidates.add(candidate);
2982
+ }
2983
+ return candidates;
2984
+ }
2985
+ //#endregion
2558
2986
  //#region src/bundlers/vite/source-candidates/scan-root.ts
2559
2987
  const TAILWIND_V4_IGNORED_CONTENT_DIRS = [
2560
2988
  ".git",
@@ -2603,7 +3031,7 @@ function resolveOutDirIgnorePattern(root, outDir) {
2603
3031
  if (!outDir) return;
2604
3032
  const relative = node_path.default.relative(root, node_path.default.resolve(root, outDir));
2605
3033
  if (!relative || relative.startsWith("..") || node_path.default.isAbsolute(relative)) return;
2606
- return `${require_v3_engine.toPosixPath(relative)}/**`;
3034
+ return `${require_v4_engine.toPosixPath(relative)}/**`;
2607
3035
  }
2608
3036
  function normalizeScanEntries(root, entries, outDirIgnore) {
2609
3037
  const hasPositiveEntry = entries?.some((entry) => !entry.negated) === true;
@@ -2654,7 +3082,7 @@ function resolveSourceCandidateScanFiles(options) {
2654
3082
  const outDirIgnore = resolveOutDirIgnorePattern(resolvedRoot, options.outDir);
2655
3083
  const scanEntries = normalizeScanEntries(resolvedRoot, options.entries, outDirIgnore);
2656
3084
  const ignoredSources = createDefaultIgnoredSources(resolvedRoot, outDirIgnore, options.entries, options.explicit);
2657
- return (0, tailwindcss_patch.resolveProjectSourceFiles)({
3085
+ return (0, _tailwindcss_mangle_engine.resolveProjectSourceFiles)({
2658
3086
  cwd: resolvedRoot,
2659
3087
  ...scanEntries === void 0 ? {} : { sources: scanEntries },
2660
3088
  ...ignoredSources.length > 0 ? { ignoredSources } : {},
@@ -2662,114 +3090,11 @@ function resolveSourceCandidateScanFiles(options) {
2662
3090
  });
2663
3091
  }
2664
3092
  //#endregion
2665
- //#region src/bundlers/vite/source-candidates/script.ts
2666
- const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = new Set([
2667
- "js",
2668
- "jsx",
2669
- "mjs",
2670
- "cjs",
2671
- "ts",
2672
- "tsx",
2673
- "mts",
2674
- "cts"
2675
- ]);
2676
- const CLASS_LIKE_NAME_RE = /class/i;
2677
- function getPropertyName(node) {
2678
- if (!node) return;
2679
- if (node.type === "Identifier") return node.name;
2680
- if (node.type === "StringLiteral") return node.value;
2681
- }
2682
- function isClassLikeStringPath(path) {
2683
- const parent = path.parentPath;
2684
- if (!parent) return false;
2685
- if (parent.isVariableDeclarator?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.id) ?? "");
2686
- if (parent.isObjectProperty?.() || parent.isObjectMethod?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.key) ?? "");
2687
- if (parent.isAssignmentExpression?.()) {
2688
- const left = parent.node.left;
2689
- if (left?.type === "Identifier") return CLASS_LIKE_NAME_RE.test(left.name);
2690
- if (left?.type === "MemberExpression") return CLASS_LIKE_NAME_RE.test(getPropertyName(left.property) ?? "");
2691
- }
2692
- if (parent.isJSXAttribute?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.name) ?? "");
2693
- return false;
2694
- }
2695
- function isTemplateElementInClassLikePath(path) {
2696
- const templateLiteralPath = path.parentPath;
2697
- if (!templateLiteralPath?.isTemplateLiteral?.()) return false;
2698
- const parent = templateLiteralPath.parentPath;
2699
- if (!parent) return false;
2700
- if (parent.isVariableDeclarator?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.id) ?? "");
2701
- if (parent.isObjectProperty?.() || parent.isObjectMethod?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.key) ?? "");
2702
- if (parent.isAssignmentExpression?.()) {
2703
- const left = parent.node.left;
2704
- if (left?.type === "Identifier") return CLASS_LIKE_NAME_RE.test(left.name);
2705
- if (left?.type === "MemberExpression") return CLASS_LIKE_NAME_RE.test(getPropertyName(left.property) ?? "");
2706
- }
2707
- return false;
2708
- }
2709
- async function extractScriptStringCandidates(source, extension, options) {
2710
- if (!SCRIPT_SOURCE_CANDIDATE_EXTENSIONS.has(extension)) return [];
2711
- const values = /* @__PURE__ */ new Set();
2712
- try {
2713
- require_precheck.traverse(require_precheck.babelParse(source, {
2714
- cache: true,
2715
- cacheKey: `vite-source-candidates:${extension}`,
2716
- plugins: ["jsx", "typescript"],
2717
- sourceType: "unambiguous"
2718
- }), {
2719
- noScope: true,
2720
- StringLiteral(path) {
2721
- if (isClassLikeStringPath(path)) values.add(path.node.value);
2722
- },
2723
- TemplateElement(path) {
2724
- if (isTemplateElementInClassLikePath(path)) values.add(path.node.value.raw);
2725
- }
2726
- });
2727
- } catch {
2728
- return [];
2729
- }
2730
- const candidates = /* @__PURE__ */ new Set();
2731
- for (const value of values) {
2732
- const extractedCandidates = options.extractor ? await options.extractor(value, "html") : await (0, tailwindcss_patch.extractSourceCandidates)(value, "html", { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
2733
- for (const candidate of extractedCandidates) candidates.add(candidate);
2734
- }
2735
- return candidates;
2736
- }
2737
- //#endregion
2738
- //#region src/bundlers/vite/source-candidates/tailwind-v3-default-extractor.ts
2739
- const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
2740
- const TAILWIND_V3_HTML_TOKEN_CANDIDATES = new Set([
2741
- "/block",
2742
- "/div",
2743
- "/span",
2744
- "/template",
2745
- "/text",
2746
- "/view",
2747
- "class",
2748
- "className",
2749
- "div",
2750
- "hover-class",
2751
- "span",
2752
- "template",
2753
- "text",
2754
- "view"
2755
- ]);
2756
- function createTailwindV3DefaultExtractor() {
2757
- try {
2758
- const defaultExtractorModule = require$1("tailwindcss/lib/lib/defaultExtractor");
2759
- const resolveConfigModule = require$1("tailwindcss/resolveConfig");
2760
- const resolveConfig = resolveConfigModule.default ?? resolveConfigModule;
2761
- const extractor = (defaultExtractorModule.defaultExtractor ?? defaultExtractorModule.default ?? defaultExtractorModule)({ tailwindConfig: resolveConfig({ content: [] }) });
2762
- return (source) => new Set(extractor(source).filter((candidate) => !TAILWIND_V3_HTML_TOKEN_CANDIDATES.has(candidate)));
2763
- } catch {
2764
- return;
2765
- }
2766
- }
2767
- //#endregion
2768
3093
  //#region src/bundlers/vite/source-candidates.ts
2769
3094
  const CLEAN_URL_RE = /[?#].*$/;
2770
3095
  const sourceCandidateContentCache = new lru_cache.LRUCache({ max: 128 });
2771
3096
  function cleanUrl(id) {
2772
- return require_v3_engine.resolveSourceScanPath(id.replace(CLEAN_URL_RE, ""));
3097
+ return require_v4_engine.resolveSourceScanPath(id.replace(CLEAN_URL_RE, ""));
2773
3098
  }
2774
3099
  function resolveSourceCandidateExtension(id) {
2775
3100
  const normalized = cleanUrl(id);
@@ -2779,13 +3104,10 @@ function createSourceCandidateContentCacheKey(extension, source, bareArbitraryVa
2779
3104
  return `${extension}\0${JSON.stringify(bareArbitraryValues ?? false)}\0${extractor ? "custom" : "default"}\0${(0, _weapp_tailwindcss_shared_node.md5)(source)}`;
2780
3105
  }
2781
3106
  async function extractCandidates(source, extension, options) {
2782
- const candidates = options.extractor ? new Set(await options.extractor(source, extension)) : new Set(await (0, tailwindcss_patch.extractSourceCandidates)(source, extension, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } }));
2783
- const scriptCandidates = await extractScriptStringCandidates(source, extension, options);
2784
- for (const candidate of scriptCandidates) candidates.add(candidate);
2785
- return candidates;
3107
+ return extractCandidatesFromSource(source, extension, options);
2786
3108
  }
2787
3109
  function isSourceCandidateRequest(id) {
2788
- return require_v3_engine.FULL_SOURCE_SCAN_EXTENSION_RE.test(cleanUrl(id));
3110
+ return require_v4_engine.FULL_SOURCE_SCAN_EXTENSION_RE.test(cleanUrl(id));
2789
3111
  }
2790
3112
  function removeCandidateSet(candidateCount, candidates) {
2791
3113
  for (const candidate of candidates) {
@@ -2801,18 +3123,20 @@ function removeCandidateSet(candidateCount, candidates) {
2801
3123
  function addCandidateSet(candidateCount, candidates) {
2802
3124
  for (const candidate of candidates) candidateCount.set(candidate, (candidateCount.get(candidate) ?? 0) + 1);
2803
3125
  }
2804
- function createSourceCandidateCollector(options = {}) {
3126
+ function createSourceCandidateStore(options = {}) {
2805
3127
  const candidatesById = /* @__PURE__ */ new Map();
2806
3128
  const scanCandidatesById = /* @__PURE__ */ new Map();
2807
3129
  const transformCandidatesById = /* @__PURE__ */ new Map();
2808
3130
  const cssCandidatesById = /* @__PURE__ */ new Map();
2809
- const sourceById = /* @__PURE__ */ new Map();
3131
+ const scanSourceById = /* @__PURE__ */ new Map();
3132
+ const transformSourceById = /* @__PURE__ */ new Map();
3133
+ const cssSourceById = /* @__PURE__ */ new Map();
2810
3134
  const candidateCount = /* @__PURE__ */ new Map();
2811
3135
  let inlineIncludedCandidates = /* @__PURE__ */ new Set();
2812
3136
  let inlineExcludedCandidates = /* @__PURE__ */ new Set();
2813
3137
  async function sync(id, source) {
2814
3138
  const normalizedId = cleanUrl(id);
2815
- sourceById.set(normalizedId, source);
3139
+ scanSourceById.set(normalizedId, source);
2816
3140
  const extension = resolveSourceCandidateExtension(normalizedId);
2817
3141
  const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
2818
3142
  const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
@@ -2826,6 +3150,7 @@ function createSourceCandidateCollector(options = {}) {
2826
3150
  }
2827
3151
  async function syncCss(id, source) {
2828
3152
  const normalizedId = cleanUrl(id);
3153
+ cssSourceById.set(normalizedId, source);
2829
3154
  const contentCacheKey = createSourceCandidateContentCacheKey("css", source, options.bareArbitraryValues, options.extractor);
2830
3155
  const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
2831
3156
  if (cachedCandidates) {
@@ -2838,6 +3163,7 @@ function createSourceCandidateCollector(options = {}) {
2838
3163
  }
2839
3164
  async function merge(id, source) {
2840
3165
  const normalizedId = cleanUrl(id);
3166
+ transformSourceById.set(normalizedId, source);
2841
3167
  const extension = resolveSourceCandidateExtension(normalizedId);
2842
3168
  const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
2843
3169
  const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
@@ -2847,11 +3173,20 @@ function createSourceCandidateCollector(options = {}) {
2847
3173
  }
2848
3174
  async function syncFile(id) {
2849
3175
  const normalizedId = cleanUrl(id);
2850
- await sync(normalizedId, await (0, node_fs_promises.readFile)(normalizedId, "utf8"));
3176
+ try {
3177
+ await sync(normalizedId, await (0, node_fs_promises.readFile)(normalizedId, "utf8"));
3178
+ } catch (error) {
3179
+ if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) === "ENOENT") {
3180
+ remove(normalizedId);
3181
+ return;
3182
+ }
3183
+ throw error;
3184
+ }
2851
3185
  }
2852
3186
  async function syncCurrentFile(id) {
2853
3187
  const normalizedId = cleanUrl(id);
2854
3188
  transformCandidatesById.delete(normalizedId);
3189
+ cssCandidatesById.delete(normalizedId);
2855
3190
  await syncFile(normalizedId);
2856
3191
  }
2857
3192
  async function scanRoot({ entries, explicit, root, outDir }) {
@@ -2862,7 +3197,7 @@ function createSourceCandidateCollector(options = {}) {
2862
3197
  outDir,
2863
3198
  root
2864
3199
  });
2865
- await Promise.all(files.map((file) => syncFile(require_v3_engine.resolveSourceScanPath(file))));
3200
+ await Promise.all(files.map((file) => syncFile(require_v4_engine.resolveSourceScanPath(file))));
2866
3201
  }
2867
3202
  function replaceFinal(id, nextCandidates) {
2868
3203
  const normalizedId = cleanUrl(id);
@@ -2910,14 +3245,20 @@ function createSourceCandidateCollector(options = {}) {
2910
3245
  scanCandidatesById.delete(normalizedId);
2911
3246
  transformCandidatesById.delete(normalizedId);
2912
3247
  cssCandidatesById.delete(normalizedId);
2913
- sourceById.delete(normalizedId);
3248
+ scanSourceById.delete(normalizedId);
3249
+ transformSourceById.delete(normalizedId);
3250
+ cssSourceById.delete(normalizedId);
2914
3251
  const previousCandidates = candidatesById.get(normalizedId);
2915
3252
  if (!previousCandidates) return;
2916
3253
  removeCandidateSet(candidateCount, previousCandidates);
2917
3254
  candidatesById.delete(normalizedId);
2918
3255
  }
2919
3256
  function source(id) {
2920
- return sourceById.get(cleanUrl(id));
3257
+ const normalizedId = cleanUrl(id);
3258
+ return scanSourceById.get(normalizedId) ?? cssSourceById.get(normalizedId) ?? transformSourceById.get(normalizedId);
3259
+ }
3260
+ function sources() {
3261
+ return mergeSourcesByPriority().entries();
2921
3262
  }
2922
3263
  function values() {
2923
3264
  const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
@@ -2928,10 +3269,11 @@ function createSourceCandidateCollector(options = {}) {
2928
3269
  if (entries === void 0) {
2929
3270
  if (!options.excludeEntries?.length) return values();
2930
3271
  }
3272
+ if (entries?.length === 0) return new Set(inlineIncludedCandidates);
2931
3273
  const filtered = /* @__PURE__ */ new Set();
2932
3274
  for (const [id, candidates] of candidatesById) {
2933
- if (entries !== void 0 && !require_v3_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
2934
- if (options.excludeEntries?.length && require_v3_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
3275
+ if (entries !== void 0 && !require_v4_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
3276
+ if (options.excludeEntries?.length && require_v4_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
2935
3277
  for (const candidate of candidates) filtered.add(candidate);
2936
3278
  }
2937
3279
  for (const candidate of inlineIncludedCandidates) filtered.add(candidate);
@@ -2948,9 +3290,14 @@ function createSourceCandidateCollector(options = {}) {
2948
3290
  }
2949
3291
  if (id) candidateSources.add(id);
2950
3292
  };
3293
+ if (entries?.length === 0) {
3294
+ for (const candidate of inlineIncludedCandidates) addCandidateSource(candidate, void 0);
3295
+ for (const candidate of inlineExcludedCandidates) sources.delete(candidate);
3296
+ return sources;
3297
+ }
2951
3298
  for (const [id, candidates] of candidatesById) {
2952
- if (entries !== void 0 && !require_v3_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
2953
- if (options.excludeEntries?.length && require_v3_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
3299
+ if (entries !== void 0 && !require_v4_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
3300
+ if (options.excludeEntries?.length && require_v4_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
2954
3301
  for (const candidate of candidates) addCandidateSource(candidate, id);
2955
3302
  }
2956
3303
  for (const candidate of inlineIncludedCandidates) addCandidateSource(candidate, void 0);
@@ -2962,18 +3309,35 @@ function createSourceCandidateCollector(options = {}) {
2962
3309
  scanCandidatesById.clear();
2963
3310
  transformCandidatesById.clear();
2964
3311
  cssCandidatesById.clear();
2965
- sourceById.clear();
3312
+ scanSourceById.clear();
3313
+ transformSourceById.clear();
3314
+ cssSourceById.clear();
2966
3315
  candidateCount.clear();
2967
3316
  inlineIncludedCandidates.clear();
2968
3317
  inlineExcludedCandidates.clear();
2969
3318
  }
3319
+ function clearScan() {
3320
+ for (const id of scanCandidatesById.keys()) {
3321
+ scanCandidatesById.delete(id);
3322
+ recompute(id);
3323
+ }
3324
+ inlineIncludedCandidates.clear();
3325
+ inlineExcludedCandidates.clear();
3326
+ }
3327
+ function resetScan() {
3328
+ inlineIncludedCandidates.clear();
3329
+ inlineExcludedCandidates.clear();
3330
+ }
2970
3331
  function snapshot() {
2971
3332
  return {
2972
3333
  candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
2973
3334
  cssCandidatesById: [...cssCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
3335
+ cssSourceById: [...cssSourceById.entries()],
2974
3336
  scanCandidatesById: [...scanCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
2975
- sourceById: [...sourceById.entries()],
3337
+ scanSourceById: [...scanSourceById.entries()],
3338
+ sourceById: [...mergeSourcesByPriority().entries()],
2976
3339
  transformCandidatesById: [...transformCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
3340
+ transformSourceById: [...transformSourceById.entries()],
2977
3341
  inlineExcludedCandidates: [...inlineExcludedCandidates],
2978
3342
  inlineIncludedCandidates: [...inlineIncludedCandidates]
2979
3343
  };
@@ -2998,15 +3362,18 @@ function createSourceCandidateCollector(options = {}) {
2998
3362
  if (candidateSet.size === 0) continue;
2999
3363
  cssCandidatesById.set(id, candidateSet);
3000
3364
  }
3001
- for (const [id, candidates] of snapshot.candidatesById) {
3002
- const candidateSet = new Set(candidates);
3003
- if (candidateSet.size === 0) continue;
3004
- candidatesById.set(id, candidateSet);
3005
- addCandidateSet(candidateCount, candidateSet);
3006
- }
3007
- for (const [id, source] of snapshot.sourceById ?? []) sourceById.set(id, source);
3365
+ for (const [id, source] of snapshot.scanSourceById ?? snapshot.sourceById ?? []) scanSourceById.set(id, source);
3366
+ for (const [id, source] of snapshot.transformSourceById ?? []) transformSourceById.set(id, source);
3367
+ for (const [id, source] of snapshot.cssSourceById ?? []) cssSourceById.set(id, source);
3368
+ const ids = new Set([
3369
+ ...scanCandidatesById.keys(),
3370
+ ...transformCandidatesById.keys(),
3371
+ ...cssCandidatesById.keys()
3372
+ ]);
3373
+ for (const id of ids) recompute(id);
3008
3374
  }
3009
3375
  return {
3376
+ syncSource: sync,
3010
3377
  sync,
3011
3378
  syncCss,
3012
3379
  merge,
@@ -3016,13 +3383,26 @@ function createSourceCandidateCollector(options = {}) {
3016
3383
  syncInline,
3017
3384
  remove,
3018
3385
  source,
3386
+ sources,
3019
3387
  values,
3020
3388
  valuesForEntries,
3021
3389
  sourcesForEntries,
3022
3390
  snapshot,
3023
3391
  restore,
3392
+ clearScan,
3393
+ resetScan,
3024
3394
  clear
3025
3395
  };
3396
+ function mergeSourcesByPriority() {
3397
+ const sources = /* @__PURE__ */ new Map();
3398
+ for (const [id, source] of transformSourceById) sources.set(id, source);
3399
+ for (const [id, source] of cssSourceById) sources.set(id, source);
3400
+ for (const [id, source] of scanSourceById) sources.set(id, source);
3401
+ return sources;
3402
+ }
3403
+ }
3404
+ function createSourceCandidateCollector(options = {}) {
3405
+ return createSourceCandidateStore(options);
3026
3406
  }
3027
3407
  //#endregion
3028
3408
  //#region src/bundlers/shared/hmr-timing.ts
@@ -3109,12 +3489,24 @@ Object.defineProperty(exports, "annotateCssSourceTrace", {
3109
3489
  return annotateCssSourceTrace;
3110
3490
  }
3111
3491
  });
3492
+ Object.defineProperty(exports, "collectStrictEscapedRuntimeCandidates", {
3493
+ enumerable: true,
3494
+ get: function() {
3495
+ return collectStrictEscapedRuntimeCandidates;
3496
+ }
3497
+ });
3112
3498
  Object.defineProperty(exports, "createBundleRuntimeClassSetManager", {
3113
3499
  enumerable: true,
3114
3500
  get: function() {
3115
3501
  return createBundleRuntimeClassSetManager;
3116
3502
  }
3117
3503
  });
3504
+ Object.defineProperty(exports, "createCssSourceOrderAppend", {
3505
+ enumerable: true,
3506
+ get: function() {
3507
+ return createCssSourceOrderAppend$1;
3508
+ }
3509
+ });
3118
3510
  Object.defineProperty(exports, "createCssSourceTraceCacheSignature", {
3119
3511
  enumerable: true,
3120
3512
  get: function() {
@@ -3127,6 +3519,12 @@ Object.defineProperty(exports, "createCssTokenSourceMap", {
3127
3519
  return createCssTokenSourceMap;
3128
3520
  }
3129
3521
  });
3522
+ Object.defineProperty(exports, "createEscapeFragments", {
3523
+ enumerable: true,
3524
+ get: function() {
3525
+ return createEscapeFragments;
3526
+ }
3527
+ });
3130
3528
  Object.defineProperty(exports, "createHmrTimingRecorder", {
3131
3529
  enumerable: true,
3132
3530
  get: function() {
@@ -3139,10 +3537,10 @@ Object.defineProperty(exports, "createSourceCandidateCollector", {
3139
3537
  return createSourceCandidateCollector;
3140
3538
  }
3141
3539
  });
3142
- Object.defineProperty(exports, "createTailwindV3DefaultExtractor", {
3540
+ Object.defineProperty(exports, "createSourceCandidateStore", {
3143
3541
  enumerable: true,
3144
3542
  get: function() {
3145
- return createTailwindV3DefaultExtractor;
3543
+ return createSourceCandidateStore;
3146
3544
  }
3147
3545
  });
3148
3546
  Object.defineProperty(exports, "emitHmrTiming", {
@@ -3163,6 +3561,12 @@ Object.defineProperty(exports, "generateCssByGenerator", {
3163
3561
  return generateCssByGenerator;
3164
3562
  }
3165
3563
  });
3564
+ Object.defineProperty(exports, "hasMiniProgramTailwindV4PreflightReset", {
3565
+ enumerable: true,
3566
+ get: function() {
3567
+ return hasMiniProgramTailwindV4PreflightReset;
3568
+ }
3569
+ });
3166
3570
  Object.defineProperty(exports, "isCssSourceTraceEnabled", {
3167
3571
  enumerable: true,
3168
3572
  get: function() {
@@ -3199,12 +3603,66 @@ Object.defineProperty(exports, "pushConcurrentTaskFactories", {
3199
3603
  return pushConcurrentTaskFactories;
3200
3604
  }
3201
3605
  });
3606
+ Object.defineProperty(exports, "removeMiniProgramHoverSelectors", {
3607
+ enumerable: true,
3608
+ get: function() {
3609
+ return removeMiniProgramHoverSelectors;
3610
+ }
3611
+ });
3612
+ Object.defineProperty(exports, "removeTailwindV4GeneratorAtRules", {
3613
+ enumerable: true,
3614
+ get: function() {
3615
+ return removeTailwindV4GeneratorAtRules;
3616
+ }
3617
+ });
3618
+ Object.defineProperty(exports, "resolveSourceCandidateScanFiles", {
3619
+ enumerable: true,
3620
+ get: function() {
3621
+ return resolveSourceCandidateScanFiles;
3622
+ }
3623
+ });
3624
+ Object.defineProperty(exports, "resolveTaskConcurrency", {
3625
+ enumerable: true,
3626
+ get: function() {
3627
+ return resolveTaskConcurrency;
3628
+ }
3629
+ });
3630
+ Object.defineProperty(exports, "rewriteLocalCssImportRequestsForOutput", {
3631
+ enumerable: true,
3632
+ get: function() {
3633
+ return rewriteLocalCssImportRequestsForOutput;
3634
+ }
3635
+ });
3202
3636
  Object.defineProperty(exports, "runWithConcurrency", {
3203
3637
  enumerable: true,
3204
3638
  get: function() {
3205
3639
  return runWithConcurrency;
3206
3640
  }
3207
3641
  });
3642
+ Object.defineProperty(exports, "scoreTailwindV4CssSourceFileMatch", {
3643
+ enumerable: true,
3644
+ get: function() {
3645
+ return scoreTailwindV4CssSourceFileMatch;
3646
+ }
3647
+ });
3648
+ Object.defineProperty(exports, "splitLocalCssImports", {
3649
+ enumerable: true,
3650
+ get: function() {
3651
+ return splitLocalCssImports;
3652
+ }
3653
+ });
3654
+ Object.defineProperty(exports, "stripTailwindSourceMediaFragments", {
3655
+ enumerable: true,
3656
+ get: function() {
3657
+ return stripTailwindSourceMediaFragments;
3658
+ }
3659
+ });
3660
+ Object.defineProperty(exports, "stripUnmatchedTailwindSourceMediaCloseFragments", {
3661
+ enumerable: true,
3662
+ get: function() {
3663
+ return stripUnmatchedTailwindSourceMediaCloseFragments;
3664
+ }
3665
+ });
3208
3666
  Object.defineProperty(exports, "validateCandidatesByGenerator", {
3209
3667
  enumerable: true,
3210
3668
  get: function() {