weapp-tailwindcss 5.5.6 → 5.5.7

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 (276) hide show
  1. package/dist/{auto-DtU6f3X6.cjs → auto-B1OyRrE8.cjs} +1 -1
  2. package/dist/{auto-2dg_uhEJ.js → auto-ENr4xzzw.js} +1 -1
  3. package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +1 -1
  4. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -1
  5. package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
  6. package/dist/bundlers/shared/css-source-trace.d.ts +2 -5
  7. package/dist/bundlers/shared/final-css-cleanup.d.ts +1 -1
  8. package/dist/bundlers/shared/framework-css-composition.d.ts +1 -1
  9. package/dist/bundlers/shared/framework-postcss.d.ts +1 -25
  10. package/dist/bundlers/shared/framework-user-css.d.ts +1 -4
  11. package/dist/bundlers/shared/generated-css-marker.d.ts +1 -10
  12. package/dist/bundlers/shared/generator-css/candidates.d.ts +1 -2
  13. package/dist/bundlers/shared/generator-css/class-selectors.d.ts +1 -3
  14. package/dist/bundlers/shared/generator-css/config-directive.d.ts +1 -2
  15. package/dist/bundlers/shared/generator-css/directives/fallback.d.ts +1 -11
  16. package/dist/bundlers/shared/generator-css/directives.d.ts +1 -25
  17. package/dist/bundlers/shared/generator-css/generation-helpers/preflight.d.ts +1 -19
  18. package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +1 -23
  19. package/dist/bundlers/shared/generator-css/generation-helpers/runtime-isolation.d.ts +1 -30
  20. package/dist/bundlers/shared/generator-css/generation-helpers/source-order.d.ts +1 -2
  21. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +1 -4
  22. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +1 -12
  23. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +1 -2
  24. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -1
  25. package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -1
  26. package/dist/bundlers/shared/generator-css/markers.d.ts +1 -28
  27. package/dist/bundlers/shared/generator-css/output-import-shell.d.ts +1 -8
  28. package/dist/bundlers/shared/generator-css/pipeline/context.d.ts +1 -60
  29. package/dist/bundlers/shared/generator-css/pipeline/deferred-output.d.ts +1 -3
  30. package/dist/bundlers/shared/generator-css/pipeline/execution.d.ts +1 -3
  31. package/dist/bundlers/shared/generator-css/pipeline/fallback-output.d.ts +1 -3
  32. package/dist/bundlers/shared/generator-css/pipeline/ordered-output.d.ts +1 -3
  33. package/dist/bundlers/shared/generator-css/pipeline.d.ts +1 -2
  34. package/dist/bundlers/shared/generator-css/result-helpers.d.ts +1 -6
  35. package/dist/bundlers/shared/generator-css/scoped-rules.d.ts +1 -1
  36. package/dist/bundlers/shared/generator-css/source-files.d.ts +1 -21
  37. package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +1 -13
  38. package/dist/bundlers/shared/generator-css/source-resolver/config.d.ts +1 -7
  39. package/dist/bundlers/shared/generator-css/source-resolver/configuration.d.ts +1 -33
  40. package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +1 -3
  41. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +1 -28
  42. package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +1 -14
  43. package/dist/bundlers/shared/generator-css/source-resolver/resolve-source.d.ts +1 -4
  44. package/dist/bundlers/shared/generator-css/source-resolver/resolve-sources.d.ts +1 -5
  45. package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +1 -16
  46. package/dist/bundlers/shared/generator-css/source-resolver/source-entries.d.ts +1 -3
  47. package/dist/bundlers/shared/generator-css/source-resolver/source-matching.d.ts +1 -5
  48. package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +1 -22
  49. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -7
  50. package/dist/bundlers/shared/generator-css/types.d.ts +1 -64
  51. package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +1 -10
  52. package/dist/bundlers/shared/generator-css/user-css/at-rules.d.ts +1 -3
  53. package/dist/bundlers/shared/generator-css/user-css/compile-functions.d.ts +1 -4
  54. package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +1 -6
  55. package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +1 -15
  56. package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +1 -13
  57. package/dist/bundlers/shared/generator-css/user-css/user-layers.d.ts +1 -15
  58. package/dist/bundlers/shared/generator-css/user-css.d.ts +1 -5
  59. package/dist/bundlers/shared/generator-css/user-layer-order.d.ts +1 -10
  60. package/dist/bundlers/shared/generator-css/validate.d.ts +1 -7
  61. package/dist/bundlers/shared/generator-css.d.ts +1 -9
  62. package/dist/bundlers/shared/run-tasks.d.ts +1 -3
  63. package/dist/bundlers/shared/runtime-class-set.d.ts +1 -1
  64. package/dist/bundlers/shared/source-candidates/collector.d.ts +1 -8
  65. package/dist/bundlers/shared/source-candidates/scan-root.d.ts +1 -12
  66. package/dist/bundlers/shared/source-candidates/script.d.ts +1 -1
  67. package/dist/bundlers/shared/source-candidates/snapshot.d.ts +1 -19
  68. package/dist/bundlers/shared/source-candidates/source-priority.d.ts +1 -1
  69. package/dist/bundlers/shared/source-candidates/store.d.ts +1 -2
  70. package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -75
  71. package/dist/bundlers/shared/source-candidates/views.d.ts +1 -12
  72. package/dist/bundlers/shared/source-candidates.d.ts +1 -4
  73. package/dist/bundlers/shared/source-scan/css-entries.d.ts +1 -18
  74. package/dist/bundlers/shared/source-scan/dependencies.d.ts +1 -2
  75. package/dist/bundlers/shared/source-scan.d.ts +1 -16
  76. package/dist/bundlers/shared/static-config-content.d.ts +1 -5
  77. package/dist/bundlers/shared/style-handler-options.d.ts +1 -7
  78. package/dist/bundlers/shared/style-requests.d.ts +1 -5
  79. package/dist/bundlers/shared/v4-generation-core.d.ts +1 -20
  80. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
  81. package/dist/bundlers/vite/generate-bundle/css-transform-task.d.ts +2 -2
  82. package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +1 -1
  83. package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +1 -12
  84. package/dist/bundlers/vite/processed-css-assets/injection-plan.d.ts +1 -4
  85. package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +4 -7
  86. package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +1 -13
  87. package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +2 -2
  88. package/dist/bundlers/vite/source-candidates/scan-root.d.ts +1 -1
  89. package/dist/bundlers/vite/source-candidates.d.ts +1 -1
  90. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.d.ts +1 -1
  91. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.d.ts +2 -7
  92. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/preflight-runtime.d.ts +4 -8
  93. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.d.ts +3 -3
  94. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.d.ts +1 -1
  95. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.d.ts +2 -7
  96. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +1 -1
  97. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +1 -1
  98. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +1 -1
  99. package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +6 -0
  100. package/dist/cache/index.d.ts +4 -4
  101. package/dist/cache/source.d.ts +29 -0
  102. package/dist/{cache-CBJFB1HN.cjs → cache-CzvIGfwS.cjs} +1 -0
  103. package/dist/compiler/composition.d.ts +1 -1
  104. package/dist/compiler/runtime-affecting-signature/js.d.ts +1 -0
  105. package/dist/compiler/semantic-css.d.ts +1 -1
  106. package/dist/compiler/types.d.ts +1 -1
  107. package/dist/{compiler-D3GBwxoa.js → compiler-CThodfGH.js} +3098 -3067
  108. package/dist/{compiler-C8FqI-P3.cjs → compiler-DkGY5Nmh.cjs} +5011 -4980
  109. package/dist/core/compiler/generation-cache.d.ts +4 -2
  110. package/dist/core/compiler/types.d.ts +1 -1
  111. package/dist/core.cjs +7 -7
  112. package/dist/core.d.ts +2 -2
  113. package/dist/core.js +2 -2
  114. package/dist/css-cleanup-B6FUJC3z.cjs +1 -0
  115. package/dist/{css-imports-XvtI1zCY.cjs → css-imports-R_RDMjPz.cjs} +7 -21
  116. package/dist/css-macro/auto.d.ts +1 -1
  117. package/dist/css-macro/postcss.cjs +1 -1
  118. package/dist/css-macro.cjs +2 -2
  119. package/dist/css-macro.js +1 -1
  120. package/dist/final-css-cleanup-B6FUJC3z.cjs +1 -0
  121. package/dist/{final-css-cleanup-u_sI2p56.js → final-css-cleanup-BOzhuhGz.js} +3 -2
  122. package/dist/framework.cjs +1 -1
  123. package/dist/{v4-generation-core-Cz1D7wm1.cjs → generated-css-marker-jMNbQHpy.cjs} +638 -1546
  124. package/dist/generation/candidates.d.ts +1 -0
  125. package/dist/generation/class-selectors.d.ts +4 -0
  126. package/dist/generation/config-directive.d.ts +1 -0
  127. package/dist/generation/directives/fallback.d.ts +1 -0
  128. package/dist/generation/directives.d.ts +1 -0
  129. package/dist/generation/framework-css-composition.d.ts +1 -0
  130. package/dist/generation/framework-postcss.d.ts +25 -0
  131. package/dist/generation/framework-user-css.d.ts +5 -0
  132. package/dist/generation/generation-helpers/preflight.d.ts +19 -0
  133. package/dist/generation/generation-helpers/results.d.ts +23 -0
  134. package/dist/generation/generation-helpers/runtime-isolation.d.ts +30 -0
  135. package/dist/generation/generation-helpers/source-order.d.ts +1 -0
  136. package/dist/generation/generation-helpers.d.ts +4 -0
  137. package/dist/generation/index.d.ts +9 -0
  138. package/dist/generation/legacy-compat.d.ts +12 -0
  139. package/dist/generation/legacy-selectors.d.ts +1 -0
  140. package/dist/generation/legacy-units.d.ts +1 -0
  141. package/dist/generation/local-imports.d.ts +1 -0
  142. package/dist/generation/markers.d.ts +1 -0
  143. package/dist/generation/output-import-shell.d.ts +1 -0
  144. package/dist/generation/pipeline/context.d.ts +60 -0
  145. package/dist/generation/pipeline/deferred-output.d.ts +3 -0
  146. package/dist/generation/pipeline/execution.d.ts +3 -0
  147. package/dist/generation/pipeline/fallback-output.d.ts +3 -0
  148. package/dist/generation/pipeline/ordered-output.d.ts +3 -0
  149. package/dist/generation/pipeline/preparation.d.ts +19 -0
  150. package/dist/generation/pipeline.d.ts +2 -0
  151. package/dist/generation/result-helpers.d.ts +6 -0
  152. package/dist/generation/scoped-rules.d.ts +1 -0
  153. package/dist/generation/service.d.ts +20 -0
  154. package/dist/generation/source-files.d.ts +21 -0
  155. package/dist/generation/source-resolver/apply-reference.d.ts +10 -0
  156. package/dist/generation/source-resolver/config.d.ts +7 -0
  157. package/dist/generation/source-resolver/configuration.d.ts +33 -0
  158. package/dist/generation/source-resolver/matching.d.ts +3 -0
  159. package/dist/generation/source-resolver/metadata.d.ts +28 -0
  160. package/dist/generation/source-resolver/postcss-source.d.ts +14 -0
  161. package/dist/generation/source-resolver/resolve-source.d.ts +4 -0
  162. package/dist/generation/source-resolver/resolve-sources.d.ts +5 -0
  163. package/dist/generation/source-resolver/single-source.d.ts +16 -0
  164. package/dist/generation/source-resolver/source-entries.d.ts +3 -0
  165. package/dist/generation/source-resolver/source-matching.d.ts +5 -0
  166. package/dist/generation/source-resolver/types.d.ts +22 -0
  167. package/dist/generation/source-resolver.d.ts +7 -0
  168. package/dist/generation/style-options.d.ts +8 -0
  169. package/dist/generation/style-requests.d.ts +5 -0
  170. package/dist/generation/types.d.ts +65 -0
  171. package/dist/generation/user-css/apply-only.d.ts +5 -0
  172. package/dist/generation/user-css/at-rules.d.ts +1 -0
  173. package/dist/generation/user-css/compile-functions.d.ts +3 -0
  174. package/dist/generation/user-css/generated-cleanup.d.ts +1 -0
  175. package/dist/generation/user-css/source-fragments.d.ts +1 -0
  176. package/dist/generation/user-css/transform.d.ts +1 -0
  177. package/dist/generation/user-css/user-layers.d.ts +1 -0
  178. package/dist/generation/user-css.d.ts +5 -0
  179. package/dist/generation/user-layer-order.d.ts +1 -0
  180. package/dist/generation/validate.d.ts +7 -0
  181. package/dist/generator-CxauQbx3.cjs +1868 -0
  182. package/dist/generator-oKZ5mCJ5.js +1637 -0
  183. package/dist/generator.cjs +10 -4
  184. package/dist/generator.js +1 -1
  185. package/dist/{gulp-BExe5RBF.cjs → gulp-CVvBpIlq.cjs} +27 -26
  186. package/dist/{gulp-BhkIIk7J.js → gulp-DhddVxGA.js} +6 -5
  187. package/dist/gulp.cjs +1 -1
  188. package/dist/gulp.js +1 -1
  189. package/dist/{hmr-timing-CoiJIqDu.cjs → hmr-timing-DfMbbZ1E.cjs} +13 -13
  190. package/dist/{hmr-timing-B9Yt86-U.js → hmr-timing-xPpat-km.js} +518 -1360
  191. package/dist/index.cjs +7 -7
  192. package/dist/index.d.ts +1 -1
  193. package/dist/index.js +5 -5
  194. package/dist/js/ModuleGraph.d.ts +3 -1
  195. package/dist/js/babel/analyze.d.ts +6 -0
  196. package/dist/js/babel.d.ts +1 -2
  197. package/dist/js/fast-path/analysis.d.ts +14 -0
  198. package/dist/js/fast-path/oxc.d.ts +1 -1
  199. package/dist/js/oxc-parser.d.ts +4 -0
  200. package/dist/pipeline-helpers-zMPmp5F3.cjs +516 -0
  201. package/dist/postcss-html-transform.cjs +1 -1
  202. package/dist/postcss.cjs +3 -2
  203. package/dist/postcss.d.ts +1 -1
  204. package/dist/postcss.js +3 -2
  205. package/dist/presets.cjs +3 -3
  206. package/dist/presets.js +2 -2
  207. package/dist/project-sources/candidates/collector.d.ts +8 -0
  208. package/dist/project-sources/candidates/scan-root.d.ts +12 -0
  209. package/dist/project-sources/candidates/script.d.ts +1 -0
  210. package/dist/project-sources/candidates/snapshot.d.ts +19 -0
  211. package/dist/project-sources/candidates/source-priority.d.ts +1 -0
  212. package/dist/project-sources/candidates/store.d.ts +2 -0
  213. package/dist/project-sources/candidates/types-and-cache.d.ts +75 -0
  214. package/dist/project-sources/candidates/views.d.ts +12 -0
  215. package/dist/project-sources/candidates.d.ts +4 -0
  216. package/dist/project-sources/css-entries.d.ts +18 -0
  217. package/dist/project-sources/dependencies.d.ts +2 -0
  218. package/dist/project-sources/index.d.ts +16 -0
  219. package/dist/project-sources/static-config-content.d.ts +5 -0
  220. package/dist/reset.cjs +1 -1
  221. package/dist/{rolldown-runtime-Ctb5zv51.cjs → rolldown-runtime-fg3euq-1.cjs} +7 -0
  222. package/dist/rspack.cjs +4 -4
  223. package/dist/rspack.js +2 -2
  224. package/dist/{runtime-state-XYSycuGu.cjs → runtime-state-BOzuVoKl.cjs} +1 -1
  225. package/dist/{scoped-generator-BUBls_oM.cjs → scoped-generator-BIZ7N_J-.cjs} +9 -9
  226. package/dist/{scoped-generator-B6Y1bxzM.js → scoped-generator-DlQrVbuC.js} +7 -6
  227. package/dist/{source-candidate-scan-signature-DNuGKTqf.js → source-candidate-scan-signature-BjVQYL-C.js} +3 -3
  228. package/dist/{source-candidate-scan-signature-BtJZp28T.cjs → source-candidate-scan-signature-nG-rg809.cjs} +4 -4
  229. package/dist/style-injector/internal.d.ts +35 -35
  230. package/dist/style-injector/options.d.ts +1 -1
  231. package/dist/tailwindcss/miniprogram.d.ts +1 -1
  232. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -1
  233. package/dist/tailwindcss/source-scan/inline-source.d.ts +1 -7
  234. package/dist/tailwindcss/source-scan.d.ts +3 -32
  235. package/dist/tailwindcss/v4/css-sources.d.ts +1 -1
  236. package/dist/tailwindcss/v4/preflight.d.ts +1 -3
  237. package/dist/tailwindcss/v4/rpx-theme-warning.d.ts +4 -0
  238. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
  239. package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +2 -3
  240. package/dist/tailwindcss/v4-engine/generator/native-session.d.ts +1 -1
  241. package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +1 -6
  242. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +5 -2
  243. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +3 -7
  244. package/dist/tailwindcss/v4-engine/source.d.ts +1 -1
  245. package/dist/tailwindcss/v4-engine/types.d.ts +3 -1
  246. package/dist/{tailwindcss-CBYjzRmV.cjs → tailwindcss-U3KIUegn.cjs} +65 -264
  247. package/dist/{tailwindcss-B_4E52WF.js → tailwindcss-kSd0ykiX.js} +71 -243
  248. package/dist/{transform-CkEnJYIP.js → transform-BAon9ykq.js} +25 -16
  249. package/dist/{transform-FkqbTBJR.cjs → transform-D2KFdA3C.cjs} +32 -23
  250. package/dist/types/index.d.ts +2 -2
  251. package/dist/types/user-defined-options/general.d.ts +1 -1
  252. package/dist/uni-app-x/border-preflight.d.ts +1 -1
  253. package/dist/uni-app-x/component-local-style.d.ts +3 -1
  254. package/dist/uni-app-x/vite/style-result.d.ts +1 -1
  255. package/dist/utils/run-tasks.d.ts +3 -0
  256. package/dist/vite/web.cjs +1 -1
  257. package/dist/vite/web.js +1 -1
  258. package/dist/{vite-DxuKPZlp.cjs → vite-BxW0qd7J.cjs} +217 -828
  259. package/dist/{vite-lP35OguX.js → vite-D-RGkmOE.js} +62 -674
  260. package/dist/vite.cjs +1 -1
  261. package/dist/vite.js +1 -1
  262. package/dist/{watch-dependencies-GbC14Rlt.cjs → watch-dependencies-C1so1whD.cjs} +14 -1
  263. package/dist/weapp-tw-css-generation-loader.cjs +4 -3
  264. package/dist/weapp-tw-css-import-rewrite-loader.cjs +33 -28
  265. package/dist/weapp-tw-runtime-classset-loader.cjs +5 -18
  266. package/dist/{web-Dfz_jpNj.js → web--kA4HUTm.js} +16 -115
  267. package/dist/{web-DhDxhlkq.cjs → web-Y-H6I1k6.cjs} +83 -192
  268. package/dist/{webpack-D6jp1o3m.js → webpack-BB-kw4Qr.js} +27 -440
  269. package/dist/{webpack-R2Sbggiy.cjs → webpack-DxrWatNB.cjs} +87 -87
  270. package/dist/webpack.cjs +1 -1
  271. package/dist/webpack.js +1 -1
  272. package/package.json +10 -5
  273. package/dist/final-css-cleanup-CDTmVAye.cjs +0 -1
  274. package/dist/generator-Bvr4WmuF.cjs +0 -3891
  275. package/dist/generator-C0BJjyLM.js +0 -3343
  276. package/dist/pipeline-helpers-BOjTEmMi.cjs +0 -971
@@ -1,105 +1,246 @@
1
- import { $ as hasTailwindApplyDirective, Ct as FULL_SOURCE_SCAN_EXTENSION_RE, Dt as isFileMatchedByTailwindSourceEntries, Et as isFileExcludedByTailwindSourceEntries, F as removeTailwindV4GeneratorAtRules, G as filterApplyOnlyGeneratedCss, I as stripTailwindSourceMediaFragments, J as extractGeneratedCssForUserLayerSelectors, K as normalizeEmptyTailwindCustomVariants, L as stripUnmatchedTailwindSourceMediaCloseFragments, M as transformGeneratorUserCss, Mt as resolveTailwindV4CssSourceBase, N as isCommentOnlyCss, Nt as toPosixPath, R as finalizeMiniProgramCss$1, T as omitUndefined, U as createGeneratedThemeDeclarationResolver, V as removeUnsupportedMiniProgramAtRules, Vt as loadTailwindV4DesignSystem, W as removeTailwindV4GeneratedUserCssArtifacts, X as splitUserCssLayerBlocks, Y as hasUserCssLayerBlocks, Z as preferScopedGeneratedCssRules, _t as stripGeneratorPlaceholderMarkers, a as resolveGeneratorRuntimeBranch, bt as normalizeConfigDirective, ct as resolveCssEntrySource, d as resolveTailwindV4SourceFromRuntime, dt as createCssAppend, ft as hasTailwindGeneratedCss, gt as splitTailwindV4GeneratedCssBySourceOrder, ht as splitTailwindGeneratedCssByBanner, i as normalizeWeappTailwindcssGeneratorOptions, it as normalizeTailwindSourceDirectives, jt as resolveSourceScanPath, lt as GENERATOR_PLACEHOLDER_MARKER_RE, mt as splitGeneratorPlaceholderCssBySourceOrder, nt as hasTailwindSourceDirectives, ot as parseImportRequest, p as resolveTailwindV4SourceOptionsFromRuntime, pt as hasTailwindGeneratedCssMarkers, q as shouldFilterApplyOnlyGeneratedCss, s as shouldUseMiniProgramCssBranch, st as removeTailwindSourceDirectives, tt as hasTailwindRootDirectives, u as resolveTailwindV4Source$1, ut as VITE_MARKER_RE, vt as stripTailwindBanner, xt as prependConfigDirective, yt as stripTailwindBanners, zt as filterUnsupportedMiniProgramTailwindV4Candidates } from "./generator-C0BJjyLM.js";
2
- import { o as transformCssMacroCss, r as hasCssMacroTailwindV4InternalAtRules, t as hasCssMacroStyleOptions } from "./auto-2dg_uhEJ.js";
3
- import { _ as includesTailwindV4PreflightDirective, h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as collectCssInlineSourceCandidates } from "./tailwindcss-B_4E52WF.js";
4
- import { A as consumeCompilationScopeChanges, B as createGenerationArtifact, F as getCompilationSessionPool, G as replaceWxml, I as runCompilerOwnerActivity, J as traverse, K as createDebug, P as getTailwindGenerationSessionPool, R as mergeCompilationDependencyChanges, V as createAttributeMatcher, Y as md5Hash, k as composeGenerationArtifact, l as recordCompilerShadowReport, m as resolveStyleOptionsFromContext, o as completeCompilerShadowReportRun, q as babelParse, r as createStylePlatformAdapter, s as getCompilerShadowRunRevision, u as getFrameworkCompilerSession, z as createCssFragment } from "./compiler-D3GBwxoa.js";
1
+ import { _ as resolveTailwindV4CssSourceBase, h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as source_scan_exports } from "./tailwindcss-kSd0ykiX.js";
2
+ import { B as loadTailwindV4DesignSystem, R as filterUnsupportedMiniProgramTailwindV4Candidates, T as omitUndefined, a as resolveGeneratorRuntimeBranch, d as resolveTailwindV4SourceFromRuntime, i as normalizeWeappTailwindcssGeneratorOptions, p as resolveTailwindV4SourceOptionsFromRuntime, s as shouldUseMiniProgramCssBranch, u as resolveTailwindV4Source$1 } from "./generator-oKZ5mCJ5.js";
3
+ import { o as transformCssMacroCss, r as hasCssMacroTailwindV4InternalAtRules, t as hasCssMacroStyleOptions } from "./auto-ENr4xzzw.js";
4
+ import { C as babelParse, H as getTailwindGenerationSessionPool, J as createCssFragment, K as mergeCompilationDependencyChanges, L as composeGenerationArtifact, N as createDebug, P as normalizeFrameworkStylePlatform, R as consumeCompilationScopeChanges, S as replaceWxml, T as traverse, U as getCompilationSessionPool, W as runCompilerOwnerActivity, Y as createGenerationArtifact, l as recordCompilerShadowReport, m as resolveStyleOptionsFromContext, o as completeCompilerShadowReportRun, q as md5Hash, r as createStylePlatformAdapter, s as getCompilerShadowRunRevision, u as getFrameworkCompilerSession, v as createAttributeMatcher } from "./compiler-CThodfGH.js";
5
5
  import { existsSync, readFileSync } from "node:fs";
6
6
  import path from "node:path";
7
7
  import process from "node:process";
8
- import { extractRawCandidatesWithPositions, extractSourceCandidates, extractValidCandidates, resolveProjectSourceFiles, resolveValidTailwindV4Candidates, splitCandidateTokens } from "@tailwindcss-mangle/engine";
9
- import { cleanLocalCssImportWrapperTailwindDirectives, cleanLocalCssImportWrapperTailwindDirectivesRoot, collectDedupedPostTransformCompatCss, collectGeneratedSelectors, compileTailwindAuthorFunctions, createTailwindAuthorFunctionProbe, filterExistingCssRules, inheritLegacyUnitConvertedDeclarations, isPureLocalCssImportWrapper, isPureLocalCssImportWrapperRoot, normalizeMiniProgramGeneratedCssForPostcss, parseCssImportSpecifier, postcss, processFrameworkCss, quoteCssImportSpecifier, removeGeneratedSelectorCompatCss, removeMatchingLocalCssImports, removeTailwindApplyRules, removeTailwindPostcssPlugins, restoreLocalCssImports, rewriteLocalCssImportRequestsForOutput, splitLocalCssImports, splitLocalCssImportsRoot, transformWebCssCompat } from "@weapp-tailwindcss/postcss";
8
+ import { extractRawCandidatesWithPositions, extractSourceCandidates, extractValidCandidates, resolveProjectSourceFiles, resolveValidTailwindV4Candidates } from "@weapp-tailwindcss/engine";
9
+ import { GENERATOR_PLACEHOLDER_MARKER_RE, analyzeApplyOnlySource, annotateCssTokenSources, cleanLocalCssImportWrapperTailwindDirectives, cleanLocalCssImportWrapperTailwindDirectivesRoot, collectDedupedPostTransformCompatCss, collectGeneratedSelectors, collectGeneratorCssCandidates, collectRawSourceClassSelectors, collectRpxThemeVariables, compileTailwindAuthorFunctions, composeFrameworkProcessedCss, createBundlerGeneratedCssEndMarker, createBundlerGeneratedCssMarker, createCssAppend, createCssSourceOrderAppend, createGeneratedThemeDeclarationResolver, createTailwindAuthorFunctionProbe, createTailwindV4SourceReferenceSource, createTailwindV4SourceReferenceSource as createTailwindV4SourceReferenceSource$1, deduplicateGeneratedCssRules, extractGeneratedCssForUserLayerSelectors, extractMarkedUserLayerComponentsCss, filterExistingCssRules, filterTailwindV4ApplyOnlyGeneratedCss as filterApplyOnlyGeneratedCss, finalizeMiniProgramCss, hasBundlerGeneratedCssMarker, hasLocalCssImport, hasTailwindApplyContextDirective, hasTailwindApplyDirective, hasTailwindGeneratedCss, hasTailwindGeneratedCssMarkers, hasTailwindNonRootGenerationDirectives, hasTailwindRootDirectives, hasTailwindSourceDirectives, hasUserCssLayerBlocks, includesTailwindV4PreflightDirective, inheritLegacyUnitConvertedDeclarations, inspectRpxCalcUsage, isCommentOnlyCss, isCssAlreadyRepresentedByMarkers, isPureLocalCssImportWrapper, isPureLocalCssImportWrapperRoot, mergeMarkedUserLayerComponentsCss, normalizeConfigDirective as normalizeConfigDirective$1, normalizeCssClassSelector, normalizeEmptyTailwindCustomVariants as normalizeEmptyTailwindCustomVariants$1, normalizeFrameworkProcessedUserCss, normalizeLegacyCompatCssSource, normalizeMiniProgramGeneratedCssForPostcss, normalizeMiniProgramGeneratorCssSource, normalizeMiniProgramImportShell, normalizeTailwindConfigDirectives as normalizeTailwindConfigDirectives$1, normalizeTailwindSourceDirectives, normalizeTailwindSourceForGenerator, parseBundlerGeneratedCssMarkerBlocks, parseImportRequest, postcss, preferScopedGeneratedCssRules, prependConfigDirective, processFrameworkCss, removeDuplicatedViteMarkers, removeGeneratedSelectorCompatCss, removeMatchingLocalCssImports, removeMiniProgramContainerCompatCss, removeMiniProgramInteractiveSelectors, removeMiniProgramOutputImports, removeTailwindPostcssPlugins, removeTailwindSourceDirectives, removeTailwindV4GeneratedUserCssArtifacts, removeTailwindV4GeneratorAtRules, removeUnsupportedMiniProgramAtRules, reorderMarkedUserLayerComponentsCss, resolveCssEntrySource as resolveCssEntrySource$1, restoreLocalCssImports, rewriteLocalCssImportRequestsForOutput, splitGeneratorPlaceholderCssBySourceOrder, splitLocalCssImports, splitLocalCssImportsRoot, splitTailwindGeneratedCssByBanner, splitTailwindV4GeneratedCssBySourceOrder, splitUserCssLayerBlocks, stripBundlerGeneratedCssMarkers, stripGeneratorPlaceholderMarkers, stripTailwindBanner, stripTailwindBanners, stripTailwindSourceMediaFragments, stripUnmatchedTailwindSourceMediaCloseFragments, transformGeneratorUserCss, transformWebCssCompat, wrapUserLayerComponentsCss } from "@weapp-tailwindcss/postcss/transform";
10
10
  import { LRUCache } from "lru-cache";
11
+ import { CANDIDATE_SOURCE_IGNORED_PATTERNS, createSourceScanPlan, sourcePathApi } from "@weapp-tailwindcss/source-scan";
11
12
  import { readFile } from "node:fs/promises";
12
- import { Parser } from "htmlparser2";
13
+ import { logger } from "@weapp-tailwindcss/logger";
13
14
  import { MappingChars2String, unescape } from "@weapp-core/escape";
14
- //#region src/bundlers/shared/source-candidates/scan-root.ts
15
- const TAILWIND_V4_IGNORED_CONTENT_DIRS = [
16
- ".git",
17
- ".hg",
18
- ".jj",
19
- ".next",
20
- ".parcel-cache",
21
- ".pnpm-store",
22
- ".svelte-kit",
23
- ".svn",
24
- ".turbo",
25
- ".venv",
26
- ".vercel",
27
- ".yarn",
28
- "__pycache__",
29
- "node_modules",
30
- "venv"
31
- ];
32
- const TAILWIND_V4_IGNORED_EXTENSIONS = [
33
- "css",
34
- "less",
35
- "postcss",
36
- "pcss",
37
- "lock",
38
- "sass",
39
- "scss",
40
- "styl",
41
- "stylus",
42
- "log",
43
- "wxss",
44
- "acss",
45
- "jxss",
46
- "ttss",
47
- "qss",
48
- "tyss"
49
- ];
50
- const TAILWIND_V4_IGNORED_FILES = [
51
- "package-lock.json",
52
- "pnpm-lock.yaml",
53
- "bun.lockb",
54
- ".gitignore",
55
- ".env",
56
- ".env.*"
57
- ];
15
+ import { Parser } from "htmlparser2";
16
+ //#region src/compiler/mode.ts
17
+ const COMPILER_MODE_ENV = "WEAPP_TAILWINDCSS_COMPILER";
18
+ function resolveCompilerMode(env = process.env) {
19
+ const value = env[COMPILER_MODE_ENV];
20
+ return value === "legacy" || value === "shadow" || value === "graph" ? value : "graph";
21
+ }
22
+ //#endregion
23
+ //#region src/compiler/semantic-css.ts
24
+ const defaultMaxDifferences = 50;
25
+ function isSemanticCssNode(node) {
26
+ return node !== void 0;
27
+ }
28
+ function normalizeNode(node) {
29
+ switch (node.type) {
30
+ case "comment": return;
31
+ case "decl": return {
32
+ type: "declaration",
33
+ property: node.prop,
34
+ value: node.value,
35
+ important: Boolean(node.important)
36
+ };
37
+ case "rule": return {
38
+ type: "rule",
39
+ selector: node.selector,
40
+ nodes: node.nodes.map(normalizeNode).filter(isSemanticCssNode)
41
+ };
42
+ case "atrule": return {
43
+ type: "at-rule",
44
+ name: node.name,
45
+ params: node.params,
46
+ nodes: node.nodes?.map(normalizeNode).filter(isSemanticCssNode) ?? []
47
+ };
48
+ }
49
+ }
50
+ function createArtifactSemanticSummary(snapshot) {
51
+ return {
52
+ present: snapshot.present,
53
+ fragments: snapshot.fragments.length,
54
+ classes: snapshot.classSet.length,
55
+ rawCandidates: snapshot.rawCandidates.length,
56
+ dependencies: snapshot.dependencies.length,
57
+ sourceEntries: snapshot.sourceEntries.length
58
+ };
59
+ }
60
+ function isRecord(value) {
61
+ return typeof value === "object" && value !== null && !Array.isArray(value);
62
+ }
63
+ function appendObjectPath(path, key) {
64
+ return /^[A-Z_$][\w$]*$/i.test(key) ? `${path}.${key}` : `${path}[${JSON.stringify(key)}]`;
65
+ }
66
+ function compareSemanticValues(left, right, path, state) {
67
+ if (state.truncated || Object.is(left, right)) return;
68
+ if (left === void 0 || right === void 0) {
69
+ const value = left === void 0 ? right : left;
70
+ if (Array.isArray(value) && value.length > 0) {
71
+ for (let index = 0; index < value.length; index++) {
72
+ compareSemanticValues(left === void 0 ? void 0 : value[index], right === void 0 ? void 0 : value[index], `${path}[${index}]`, state);
73
+ if (state.truncated) return;
74
+ }
75
+ return;
76
+ }
77
+ if (isRecord(value) && Object.keys(value).length > 0) {
78
+ for (const key of Object.keys(value)) {
79
+ compareSemanticValues(left === void 0 ? void 0 : value[key], right === void 0 ? void 0 : value[key], appendObjectPath(path, key), state);
80
+ if (state.truncated) return;
81
+ }
82
+ return;
83
+ }
84
+ } else if (Array.isArray(left) && Array.isArray(right)) {
85
+ const length = Math.max(left.length, right.length);
86
+ for (let index = 0; index < length; index++) {
87
+ compareSemanticValues(left[index], right[index], `${path}[${index}]`, state);
88
+ if (state.truncated) return;
89
+ }
90
+ return;
91
+ } else if (isRecord(left) && isRecord(right)) {
92
+ const keys = /* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)]);
93
+ for (const key of keys) {
94
+ compareSemanticValues(left[key], right[key], appendObjectPath(path, key), state);
95
+ if (state.truncated) return;
96
+ }
97
+ return;
98
+ }
99
+ state.equal = false;
100
+ if (state.differences.length >= state.maxDifferences) {
101
+ state.truncated = true;
102
+ return;
103
+ }
104
+ state.differences.push({
105
+ kind: left === void 0 ? "added" : right === void 0 ? "removed" : "changed",
106
+ path,
107
+ ...left === void 0 ? {} : { left },
108
+ ...right === void 0 ? {} : { right }
109
+ });
110
+ }
111
+ function normalizeCssRoot(root) {
112
+ return root.nodes.map(normalizeNode).filter(isSemanticCssNode);
113
+ }
114
+ function createArtifactSemanticSnapshot(artifact) {
115
+ if (artifact === void 0) return {
116
+ present: false,
117
+ fragments: [],
118
+ classSet: [],
119
+ rawCandidates: [],
120
+ dependencies: [],
121
+ sourceEntries: []
122
+ };
123
+ return {
124
+ present: true,
125
+ fragments: [...artifact.fragments].sort((left, right) => left.order - right.order || left.id.localeCompare(right.id)).map((fragment) => ({
126
+ id: fragment.id,
127
+ kind: fragment.kind,
128
+ order: fragment.order,
129
+ scope: { ...fragment.scope },
130
+ sourceId: fragment.sourceId,
131
+ stage: fragment.stage,
132
+ root: normalizeCssRoot(fragment.root)
133
+ })),
134
+ classSet: [...artifact.classSet].sort(),
135
+ rawCandidates: [...artifact.rawCandidates].sort(),
136
+ dependencies: [...artifact.dependencies].sort(),
137
+ sourceEntries: [...artifact.sourceEntries].sort()
138
+ };
139
+ }
140
+ function compareArtifactSemantics(left, right, options = {}) {
141
+ const leftSnapshot = createArtifactSemanticSnapshot(left);
142
+ const rightSnapshot = createArtifactSemanticSnapshot(right);
143
+ const state = {
144
+ differences: [],
145
+ equal: true,
146
+ maxDifferences: Math.max(0, Math.floor(options.maxDifferences ?? defaultMaxDifferences)),
147
+ truncated: false
148
+ };
149
+ compareSemanticValues(leftSnapshot, rightSnapshot, "$", state);
150
+ return {
151
+ equal: state.equal,
152
+ differences: state.differences,
153
+ truncated: state.truncated,
154
+ left: createArtifactSemanticSummary(leftSnapshot),
155
+ right: createArtifactSemanticSummary(rightSnapshot)
156
+ };
157
+ }
158
+ //#endregion
159
+ //#region src/compiler/shadow-gate.ts
160
+ const COMPILER_SHADOW_GATE_ENV = "WEAPP_TAILWINDCSS_COMPILER_SHADOW_GATE";
161
+ function resolveCompilerShadowGateMode(env = process.env) {
162
+ const value = env[COMPILER_SHADOW_GATE_ENV]?.trim().toLowerCase();
163
+ return value === "report" || value === "error" ? value : "off";
164
+ }
165
+ function evaluateCompilerShadowGate(snapshot, mode = "off") {
166
+ const issues = [];
167
+ if (snapshot.summary.mismatched > 0) issues.push("semantic-mismatch");
168
+ if (snapshot.summary.truncated > 0) issues.push("truncated-report");
169
+ if (snapshot.summary.dropped > 0) issues.push("dropped-report");
170
+ return {
171
+ mode,
172
+ passed: issues.length === 0,
173
+ issues,
174
+ snapshot
175
+ };
176
+ }
177
+ function emitCompilerShadowGateResult(payload) {
178
+ process.stdout.write(`[weapp-tailwindcss:compiler-shadow] ${JSON.stringify(payload)}\n`);
179
+ }
180
+ function finalizeCompilerShadowRun(owner, options = {}) {
181
+ const env = options.env ?? process.env;
182
+ if (resolveCompilerMode(env) !== "shadow") return;
183
+ const snapshot = completeCompilerShadowReportRun(owner, options.revision);
184
+ if (!snapshot) return;
185
+ const result = evaluateCompilerShadowGate(snapshot, resolveCompilerShadowGateMode(env));
186
+ if (result.mode !== "off") {
187
+ const payload = {
188
+ mode: result.mode,
189
+ passed: result.passed,
190
+ issues: result.issues,
191
+ revision: snapshot.revision,
192
+ summary: snapshot.summary
193
+ };
194
+ if (options.emit) options.emit(payload);
195
+ else emitCompilerShadowGateResult(payload);
196
+ }
197
+ if (result.mode === "error" && !result.passed) throw new Error(`weapp-tailwindcss shadow gate failed: ${result.issues.join(", ")}`);
198
+ return result;
199
+ }
200
+ //#endregion
201
+ //#region src/compiler/shadow-report.ts
202
+ function createCompilerShadowReport(file, legacy, graph, options = {}) {
203
+ const comparison = compareArtifactSemantics(legacy, graph, options);
204
+ return {
205
+ file,
206
+ scopeId: options.scopeId ?? file,
207
+ equal: comparison.equal,
208
+ differences: comparison.differences,
209
+ truncated: comparison.truncated,
210
+ legacy: comparison.left,
211
+ graph: comparison.right
212
+ };
213
+ }
214
+ //#endregion
215
+ //#region src/project-sources/candidates/scan-root.ts
58
216
  function resolveOutDirIgnorePattern(root, outDir) {
59
217
  if (!outDir) return;
218
+ const path = sourcePathApi(root, outDir);
60
219
  const relative = path.relative(root, path.resolve(root, outDir));
61
220
  if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return;
62
- return `${toPosixPath(relative)}/**`;
221
+ return `${(0, source_scan_exports.toPosixPath)(relative)}/**`;
63
222
  }
64
223
  function normalizeScanEntries(root, entries, outDirIgnore) {
65
- const hasPositiveEntry = entries?.some((entry) => !entry.negated) === true;
66
- const scanEntries = entries?.length ? hasPositiveEntry ? entries : [{
67
- base: root,
68
- pattern: "**/*",
69
- negated: false
70
- }, ...entries] : void 0;
71
- if (!outDirIgnore) return scanEntries;
72
- return [...scanEntries ?? [{
73
- base: root,
74
- pattern: "**/*",
75
- negated: false
76
- }], {
224
+ if (!entries?.length && !outDirIgnore) return;
225
+ return createSourceScanPlan({
77
226
  base: root,
78
- pattern: outDirIgnore,
79
- negated: true
80
- }];
227
+ mode: "fallback",
228
+ entries: [...entries ?? [], ...outDirIgnore ? [{
229
+ base: root,
230
+ pattern: outDirIgnore,
231
+ negated: true
232
+ }] : []]
233
+ });
81
234
  }
82
235
  function shouldApplyDefaultIgnoredSources(entries) {
83
236
  return entries?.length === void 0 ? false : entries.length > 0 && entries.every((entry) => entry.negated);
84
237
  }
85
238
  function createDefaultIgnoredSources(root, outDirIgnore, entries, explicit) {
86
- return [...!explicit || shouldApplyDefaultIgnoredSources(entries) ? [
87
- ...TAILWIND_V4_IGNORED_CONTENT_DIRS.map((pattern) => ({
88
- base: root,
89
- pattern: `**/${pattern}/**`,
90
- negated: true
91
- })),
92
- ...TAILWIND_V4_IGNORED_EXTENSIONS.map((extension) => ({
93
- base: root,
94
- pattern: `**/*.${extension}`,
95
- negated: true
96
- })),
97
- ...TAILWIND_V4_IGNORED_FILES.map((pattern) => ({
98
- base: root,
99
- pattern: `**/${pattern}`,
100
- negated: true
101
- }))
102
- ] : [], ...outDirIgnore ? [{
239
+ return [...!explicit || shouldApplyDefaultIgnoredSources(entries) ? CANDIDATE_SOURCE_IGNORED_PATTERNS.map((pattern) => ({
240
+ base: root,
241
+ pattern,
242
+ negated: true
243
+ })) : [], ...outDirIgnore ? [{
103
244
  base: root,
104
245
  pattern: outDirIgnore,
105
246
  negated: true
@@ -107,29 +248,30 @@ function createDefaultIgnoredSources(root, outDirIgnore, entries, explicit) {
107
248
  }
108
249
  /** 创建与文件系统 root scan 一致的增量源码资格判断器。 */
109
250
  function createSourceCandidateEligibilityMatcher(roots, eligibleFiles) {
110
- const eligibleFileSet = eligibleFiles === void 0 ? void 0 : new Set([...eligibleFiles].map(resolveSourceScanPath));
251
+ const eligibleFileSet = eligibleFiles === void 0 ? void 0 : new Set([...eligibleFiles].map(source_scan_exports.resolveSourceScanPath));
111
252
  const matchers = roots.map((options) => {
112
- const root = resolveSourceScanPath(options.root);
253
+ const root = (0, source_scan_exports.resolveSourceScanPath)(options.root);
113
254
  const outDirIgnore = resolveOutDirIgnorePattern(root, options.outDir);
114
255
  const entries = options.entries;
115
256
  const explicit = options.explicit === true;
116
257
  const hasPositiveEntry = entries?.some((entry) => !entry.negated) === true;
117
258
  const ignoredSources = createDefaultIgnoredSources(root, outDirIgnore, entries, explicit);
118
259
  return (resolvedFile) => {
119
- if (explicit) return hasPositiveEntry && isFileMatchedByTailwindSourceEntries(resolvedFile, entries);
260
+ if (explicit) return hasPositiveEntry && (0, source_scan_exports.isFileMatchedByTailwindSourceEntries)(resolvedFile, entries);
261
+ const path = sourcePathApi(root, resolvedFile);
120
262
  const relative = path.relative(root, resolvedFile);
121
263
  if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return false;
122
- return isFileMatchedByTailwindSourceEntries(resolvedFile, entries) && !isFileExcludedByTailwindSourceEntries(resolvedFile, ignoredSources) && (eligibleFileSet?.has(resolvedFile) ?? true);
264
+ return (0, source_scan_exports.isFileMatchedByTailwindSourceEntries)(resolvedFile, entries) && !(0, source_scan_exports.isFileExcludedByTailwindSourceEntries)(resolvedFile, ignoredSources) && (eligibleFileSet?.has(resolvedFile) ?? true);
123
265
  };
124
266
  });
125
267
  return (file) => {
126
- const resolvedFile = resolveSourceScanPath(file);
268
+ const resolvedFile = (0, source_scan_exports.resolveSourceScanPath)(file);
127
269
  return matchers.some((matches) => matches(resolvedFile));
128
270
  };
129
271
  }
130
272
  function resolveSourceCandidateScanFiles(options) {
131
- const resolvedRoot = path.resolve(options.root);
132
- if (options.explicit && options.entries?.length && options.entries.every((entry) => entry.negated)) return Promise.resolve([]);
273
+ const resolvedRoot = (0, source_scan_exports.resolveSourceScanPath)(options.root);
274
+ if (options.explicit && !options.entries?.some((entry) => !entry.negated)) return Promise.resolve([]);
133
275
  const outDirIgnore = resolveOutDirIgnorePattern(resolvedRoot, options.outDir);
134
276
  const scanEntries = normalizeScanEntries(resolvedRoot, options.entries, outDirIgnore);
135
277
  const ignoredSources = createDefaultIgnoredSources(resolvedRoot, outDirIgnore, options.entries, options.explicit);
@@ -141,7 +283,7 @@ function resolveSourceCandidateScanFiles(options) {
141
283
  });
142
284
  }
143
285
  //#endregion
144
- //#region src/bundlers/shared/source-candidates/source-priority.ts
286
+ //#region src/project-sources/candidates/source-priority.ts
145
287
  function mergeSourcesByPriority(moduleSourceById, transformSourceById, cssSourceById, scanSourceById) {
146
288
  const sources = /* @__PURE__ */ new Map();
147
289
  for (const [id, source] of moduleSourceById) sources.set(id, source);
@@ -151,7 +293,7 @@ function mergeSourcesByPriority(moduleSourceById, transformSourceById, cssSource
151
293
  return sources;
152
294
  }
153
295
  //#endregion
154
- //#region src/bundlers/shared/source-candidates/snapshot.ts
296
+ //#region src/project-sources/candidates/snapshot.ts
155
297
  function createCandidateSnapshot(maps) {
156
298
  return {
157
299
  candidatesById: [...maps.candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
@@ -301,11 +443,11 @@ async function extractScriptStringCandidates(source, extension, options) {
301
443
  return candidates;
302
444
  }
303
445
  //#endregion
304
- //#region src/bundlers/shared/source-candidates/types-and-cache.ts
446
+ //#region src/project-sources/candidates/types-and-cache.ts
305
447
  const CLEAN_URL_RE = /[?#].*$/;
306
448
  const sourceCandidateContentCache = new LRUCache({ max: 128 });
307
449
  function cleanUrl(id) {
308
- return resolveSourceScanPath(id.replace(CLEAN_URL_RE, ""));
450
+ return (0, source_scan_exports.resolveSourceScanPath)(id.replace(CLEAN_URL_RE, ""));
309
451
  }
310
452
  function resolveSourceCandidateExtension(id) {
311
453
  const normalized = cleanUrl(id);
@@ -331,7 +473,7 @@ async function extractCandidates(source, extension, options) {
331
473
  return extractCandidatesFromSource(source, extension, options);
332
474
  }
333
475
  function isSourceCandidateRequest(id) {
334
- return FULL_SOURCE_SCAN_EXTENSION_RE.test(cleanUrl(id));
476
+ return source_scan_exports.FULL_SOURCE_SCAN_EXTENSION_RE.test(cleanUrl(id));
335
477
  }
336
478
  function removeCandidateSet$1(candidateCount, candidates) {
337
479
  for (const candidate of candidates) {
@@ -358,10 +500,10 @@ function diffCandidateSets(previous, next) {
358
500
  };
359
501
  }
360
502
  //#endregion
361
- //#region src/bundlers/shared/source-candidates/views.ts
503
+ //#region src/project-sources/candidates/views.ts
362
504
  function isIncludedFile(id, isActiveModule, entries, excludeEntries) {
363
- if (entries !== void 0 && (isActiveModule ? isFileExcludedByTailwindSourceEntries(id, entries) : entries.length === 0 || !isFileMatchedByTailwindSourceEntries(id, entries))) return false;
364
- return !(excludeEntries?.length && isFileMatchedByTailwindSourceEntries(id, excludeEntries));
505
+ if (entries !== void 0 && (isActiveModule ? (0, source_scan_exports.isFileExcludedByTailwindSourceEntries)(id, entries) : entries.length === 0 || !(0, source_scan_exports.isFileMatchedByTailwindSourceEntries)(id, entries))) return false;
506
+ return !(excludeEntries?.length && (0, source_scan_exports.isFileMatchedByTailwindSourceEntries)(id, excludeEntries));
365
507
  }
366
508
  function collectCandidateValues(view, entries, excludeEntries) {
367
509
  if (entries === void 0 && !excludeEntries?.length) {
@@ -398,7 +540,7 @@ function collectCandidateSources(view, entries, excludeEntries) {
398
540
  return sources;
399
541
  }
400
542
  //#endregion
401
- //#region src/bundlers/shared/source-candidates/store.ts
543
+ //#region src/project-sources/candidates/store.ts
402
544
  const SOURCE_CANDIDATE_FILE_MEMO_MAX = 4096;
403
545
  function areSetsEqual(left, right) {
404
546
  if (!left || left.size !== right.size) return false;
@@ -524,7 +666,7 @@ function createSourceCandidateStore(options = {}) {
524
666
  filter: isSourceCandidateRequest,
525
667
  outDir,
526
668
  root
527
- })).map(resolveSourceScanPath);
669
+ })).map(source_scan_exports.resolveSourceScanPath);
528
670
  }
529
671
  async function scanRoot(options) {
530
672
  const resolvedFiles = await resolveScanFiles(options);
@@ -733,209 +875,10 @@ function createSourceCandidateStore(options = {}) {
733
875
  getRevision: () => revision
734
876
  };
735
877
  }
736
- //#endregion
737
- //#region src/bundlers/shared/source-candidates/collector.ts
738
- function createSourceCandidateCollector(options = {}) {
739
- return createSourceCandidateStore(options);
740
- }
741
- //#endregion
742
- //#region src/compiler/mode.ts
743
- const COMPILER_MODE_ENV = "WEAPP_TAILWINDCSS_COMPILER";
744
- function resolveCompilerMode(env = process.env) {
745
- const value = env[COMPILER_MODE_ENV];
746
- return value === "legacy" || value === "shadow" || value === "graph" ? value : "graph";
747
- }
748
- //#endregion
749
- //#region src/compiler/semantic-css.ts
750
- const defaultMaxDifferences = 50;
751
- function isSemanticCssNode(node) {
752
- return node !== void 0;
753
- }
754
- function normalizeNode(node) {
755
- switch (node.type) {
756
- case "comment": return;
757
- case "decl": return {
758
- type: "declaration",
759
- property: node.prop,
760
- value: node.value,
761
- important: Boolean(node.important)
762
- };
763
- case "rule": return {
764
- type: "rule",
765
- selector: node.selector,
766
- nodes: node.nodes.map(normalizeNode).filter(isSemanticCssNode)
767
- };
768
- case "atrule": return {
769
- type: "at-rule",
770
- name: node.name,
771
- params: node.params,
772
- nodes: node.nodes?.map(normalizeNode).filter(isSemanticCssNode) ?? []
773
- };
774
- }
775
- }
776
- function createArtifactSemanticSummary(snapshot) {
777
- return {
778
- present: snapshot.present,
779
- fragments: snapshot.fragments.length,
780
- classes: snapshot.classSet.length,
781
- rawCandidates: snapshot.rawCandidates.length,
782
- dependencies: snapshot.dependencies.length,
783
- sourceEntries: snapshot.sourceEntries.length
784
- };
785
- }
786
- function isRecord(value) {
787
- return typeof value === "object" && value !== null && !Array.isArray(value);
788
- }
789
- function appendObjectPath(path, key) {
790
- return /^[A-Z_$][\w$]*$/i.test(key) ? `${path}.${key}` : `${path}[${JSON.stringify(key)}]`;
791
- }
792
- function compareSemanticValues(left, right, path, state) {
793
- if (state.truncated || Object.is(left, right)) return;
794
- if (left === void 0 || right === void 0) {
795
- const value = left === void 0 ? right : left;
796
- if (Array.isArray(value) && value.length > 0) {
797
- for (let index = 0; index < value.length; index++) {
798
- compareSemanticValues(left === void 0 ? void 0 : value[index], right === void 0 ? void 0 : value[index], `${path}[${index}]`, state);
799
- if (state.truncated) return;
800
- }
801
- return;
802
- }
803
- if (isRecord(value) && Object.keys(value).length > 0) {
804
- for (const key of Object.keys(value)) {
805
- compareSemanticValues(left === void 0 ? void 0 : value[key], right === void 0 ? void 0 : value[key], appendObjectPath(path, key), state);
806
- if (state.truncated) return;
807
- }
808
- return;
809
- }
810
- } else if (Array.isArray(left) && Array.isArray(right)) {
811
- const length = Math.max(left.length, right.length);
812
- for (let index = 0; index < length; index++) {
813
- compareSemanticValues(left[index], right[index], `${path}[${index}]`, state);
814
- if (state.truncated) return;
815
- }
816
- return;
817
- } else if (isRecord(left) && isRecord(right)) {
818
- const keys = /* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)]);
819
- for (const key of keys) {
820
- compareSemanticValues(left[key], right[key], appendObjectPath(path, key), state);
821
- if (state.truncated) return;
822
- }
823
- return;
824
- }
825
- state.equal = false;
826
- if (state.differences.length >= state.maxDifferences) {
827
- state.truncated = true;
828
- return;
829
- }
830
- state.differences.push({
831
- kind: left === void 0 ? "added" : right === void 0 ? "removed" : "changed",
832
- path,
833
- ...left === void 0 ? {} : { left },
834
- ...right === void 0 ? {} : { right }
835
- });
836
- }
837
- function normalizeCssRoot(root) {
838
- return root.nodes.map(normalizeNode).filter(isSemanticCssNode);
839
- }
840
- function createArtifactSemanticSnapshot(artifact) {
841
- if (artifact === void 0) return {
842
- present: false,
843
- fragments: [],
844
- classSet: [],
845
- rawCandidates: [],
846
- dependencies: [],
847
- sourceEntries: []
848
- };
849
- return {
850
- present: true,
851
- fragments: [...artifact.fragments].sort((left, right) => left.order - right.order || left.id.localeCompare(right.id)).map((fragment) => ({
852
- id: fragment.id,
853
- kind: fragment.kind,
854
- order: fragment.order,
855
- scope: { ...fragment.scope },
856
- sourceId: fragment.sourceId,
857
- stage: fragment.stage,
858
- root: normalizeCssRoot(fragment.root)
859
- })),
860
- classSet: [...artifact.classSet].sort(),
861
- rawCandidates: [...artifact.rawCandidates].sort(),
862
- dependencies: [...artifact.dependencies].sort(),
863
- sourceEntries: [...artifact.sourceEntries].sort()
864
- };
865
- }
866
- function compareArtifactSemantics(left, right, options = {}) {
867
- const leftSnapshot = createArtifactSemanticSnapshot(left);
868
- const rightSnapshot = createArtifactSemanticSnapshot(right);
869
- const state = {
870
- differences: [],
871
- equal: true,
872
- maxDifferences: Math.max(0, Math.floor(options.maxDifferences ?? defaultMaxDifferences)),
873
- truncated: false
874
- };
875
- compareSemanticValues(leftSnapshot, rightSnapshot, "$", state);
876
- return {
877
- equal: state.equal,
878
- differences: state.differences,
879
- truncated: state.truncated,
880
- left: createArtifactSemanticSummary(leftSnapshot),
881
- right: createArtifactSemanticSummary(rightSnapshot)
882
- };
883
- }
884
- //#endregion
885
- //#region src/compiler/shadow-gate.ts
886
- const COMPILER_SHADOW_GATE_ENV = "WEAPP_TAILWINDCSS_COMPILER_SHADOW_GATE";
887
- function resolveCompilerShadowGateMode(env = process.env) {
888
- const value = env[COMPILER_SHADOW_GATE_ENV]?.trim().toLowerCase();
889
- return value === "report" || value === "error" ? value : "off";
890
- }
891
- function evaluateCompilerShadowGate(snapshot, mode = "off") {
892
- const issues = [];
893
- if (snapshot.summary.mismatched > 0) issues.push("semantic-mismatch");
894
- if (snapshot.summary.truncated > 0) issues.push("truncated-report");
895
- if (snapshot.summary.dropped > 0) issues.push("dropped-report");
896
- return {
897
- mode,
898
- passed: issues.length === 0,
899
- issues,
900
- snapshot
901
- };
902
- }
903
- function emitCompilerShadowGateResult(payload) {
904
- process.stdout.write(`[weapp-tailwindcss:compiler-shadow] ${JSON.stringify(payload)}\n`);
905
- }
906
- function finalizeCompilerShadowRun(owner, options = {}) {
907
- const env = options.env ?? process.env;
908
- if (resolveCompilerMode(env) !== "shadow") return;
909
- const snapshot = completeCompilerShadowReportRun(owner, options.revision);
910
- if (!snapshot) return;
911
- const result = evaluateCompilerShadowGate(snapshot, resolveCompilerShadowGateMode(env));
912
- if (result.mode !== "off") {
913
- const payload = {
914
- mode: result.mode,
915
- passed: result.passed,
916
- issues: result.issues,
917
- revision: snapshot.revision,
918
- summary: snapshot.summary
919
- };
920
- if (options.emit) options.emit(payload);
921
- else emitCompilerShadowGateResult(payload);
922
- }
923
- if (result.mode === "error" && !result.passed) throw new Error(`weapp-tailwindcss shadow gate failed: ${result.issues.join(", ")}`);
924
- return result;
925
- }
926
- //#endregion
927
- //#region src/compiler/shadow-report.ts
928
- function createCompilerShadowReport(file, legacy, graph, options = {}) {
929
- const comparison = compareArtifactSemantics(legacy, graph, options);
930
- return {
931
- file,
932
- scopeId: options.scopeId ?? file,
933
- equal: comparison.equal,
934
- differences: comparison.differences,
935
- truncated: comparison.truncated,
936
- legacy: comparison.left,
937
- graph: comparison.right
938
- };
878
+ //#endregion
879
+ //#region src/project-sources/candidates/collector.ts
880
+ function createSourceCandidateCollector(options = {}) {
881
+ return createSourceCandidateStore(options);
939
882
  }
940
883
  //#endregion
941
884
  //#region src/bundlers/shared/runtime-class-set/entries.ts
@@ -1280,143 +1223,28 @@ function createRuntimeClassSetManager(options = {}) {
1280
1223
  };
1281
1224
  }
1282
1225
  //#endregion
1283
- //#region src/bundlers/shared/css-source-trace.ts
1284
- const CSS_SOURCE_TRACE_COMMENT_RE = /^\s*tokens:\s/;
1285
- const TAILWIND_GENERATED_CONTAINER_TRACE_COMMENT_RE = /^\s*tokens:\s*container\s*<=\s*<tailwind generated>\s*$/i;
1286
- function normalizeSelectorTokenCandidate(candidate) {
1287
- return candidate.replace(/(?<!\\)\\:/g, ":").replace(/(?<!\\)\\\//g, "/");
1288
- }
1289
- function normalizeSourcePath(source, root) {
1290
- const resolvedRoot = path.resolve(root);
1291
- const resolvedSource = path.resolve(source);
1292
- const relative = path.relative(resolvedRoot, resolvedSource);
1293
- if (relative && !relative.startsWith("..") && !path.isAbsolute(relative)) return relative.split(path.sep).join("/");
1294
- return source.split(path.sep).join("/");
1295
- }
1296
- function getSourceTraceRoot(opts) {
1297
- const configured = opts.cssSourceTrace;
1298
- if (configured && typeof configured === "object" && configured.root) return configured.root;
1299
- return opts.tailwindcssBasedir ?? process.cwd();
1300
- }
1301
- function isCssSourceTraceEnabled(opts) {
1302
- return opts.cssSourceTrace === true || typeof opts.cssSourceTrace === "object" && opts.cssSourceTrace !== null;
1303
- }
1304
- function createCssTokenSourceMap(sourcesByToken, opts) {
1305
- const root = getSourceTraceRoot(opts);
1306
- const tokenSources = /* @__PURE__ */ new Map();
1307
- for (const [token, sources] of [...sourcesByToken.entries()].sort(([a], [b]) => a.localeCompare(b))) {
1308
- const source = {
1309
- token,
1310
- sources: [...sources].map((file) => normalizeSourcePath(file, root)).sort()
1311
- };
1312
- tokenSources.set(token, source);
1313
- const escaped = replaceWxml(token, { escapeMap: opts.escapeMap });
1314
- tokenSources.set(escaped, source);
1315
- tokenSources.set(escaped.replaceAll("\\", ""), source);
1316
- }
1317
- return tokenSources;
1318
- }
1319
- function createCssSourceTraceCacheSignature(tokenSources, opts) {
1320
- if (!isCssSourceTraceEnabled(opts)) return "css-source-trace:0";
1321
- if (!tokenSources?.size) return "css-source-trace:1:empty";
1322
- return `css-source-trace:1:${[...tokenSources.values()].map(({ token, sources }) => `${token}<=${sources.join(",")}`).sort().join("|")}`;
1226
+ //#region src/generation/source-resolver/postcss-source.ts
1227
+ function resolvePostcssFromOption(cssHandlerOptions) {
1228
+ const from = cssHandlerOptions.postcssOptions?.options?.from;
1229
+ return typeof from === "string" && from.length > 0 ? from : void 0;
1323
1230
  }
1324
- function getTokenSource(tokenSources, token) {
1325
- return tokenSources.get(token);
1326
- }
1327
- function collectRuleSourceTokens(rule, tokenSources) {
1328
- const tokens = /* @__PURE__ */ new Map();
1329
- for (const selector of rule.selectors) {
1330
- const classMatches = selector.matchAll(/\.((?:\\.|[^\s.#:[{>,])*)/g);
1331
- for (const match of classMatches) {
1332
- const rawCandidate = match[1];
1333
- if (!rawCandidate) continue;
1334
- const candidates = [normalizeSelectorTokenCandidate(rawCandidate), rawCandidate];
1335
- for (const candidate of candidates) {
1336
- const source = getTokenSource(tokenSources, candidate);
1337
- if (!source) continue;
1338
- tokens.set(source.token, source);
1339
- break;
1340
- }
1341
- }
1342
- }
1343
- return tokens;
1344
- }
1345
- function removeTracedTailwindGeneratedContainerRules(root) {
1346
- root.walkRules((rule) => {
1347
- if (!rule.selectors || rule.selectors.length !== 1 || rule.selectors[0] !== ".container") return;
1348
- const previous = rule.prev();
1349
- if (previous?.type !== "comment" || !TAILWIND_GENERATED_CONTAINER_TRACE_COMMENT_RE.test(previous.text)) return;
1350
- previous.remove();
1351
- rule.remove();
1352
- });
1231
+ function resolvePostcssRequestOption(cssHandlerOptions) {
1232
+ return resolveCssHandlerSourceOptions(cssHandlerOptions)?.requestFile ?? resolvePostcssFromOption(cssHandlerOptions);
1353
1233
  }
1354
- function normalizeTraceCommentBefore(value) {
1355
- return value?.includes("\n") ? value : "\n";
1234
+ function resolvePostcssSourceFile(cssHandlerOptions) {
1235
+ const from = resolvePostcssFromOption(cssHandlerOptions);
1236
+ if (!from || !path.isAbsolute(from)) return;
1237
+ return from.replace(/[?#].*$/, "");
1356
1238
  }
1357
- function annotateCssSourceTrace(css, options) {
1358
- if (!isCssSourceTraceEnabled(options.opts) || !options.tokenSources?.size) return css;
1359
- try {
1360
- const root = postcss.parse(css);
1361
- root.walkComments((comment) => {
1362
- if (CSS_SOURCE_TRACE_COMMENT_RE.test(comment.text)) comment.remove();
1363
- });
1364
- root.walkRules((rule) => {
1365
- const tokens = collectRuleSourceTokens(rule, options.tokenSources);
1366
- if (tokens.size === 0 || !rule.parent) return;
1367
- const lines = [...tokens.values()].map(({ token, sources }) => {
1368
- return `${token} <= ${sources.length > 0 ? sources.join(", ") : "<tailwind generated>"}`;
1369
- });
1370
- const comment = postcss.comment({ text: `tokens: ${lines.join(" | ")}` });
1371
- comment.raws.before = normalizeTraceCommentBefore(rule.raws.before);
1372
- rule.raws.before = "\n";
1373
- rule.parent.insertBefore(rule, comment);
1374
- });
1375
- removeTracedTailwindGeneratedContainerRules(root);
1376
- return root.toString();
1377
- } catch {
1378
- return css;
1379
- }
1239
+ function resolveCssHandlerSourceOptions(cssHandlerOptions) {
1240
+ return cssHandlerOptions.sourceOptions;
1380
1241
  }
1381
- //#endregion
1382
- //#region src/bundlers/shared/generated-css-marker.ts
1383
- const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!?\s*weapp-tailwindcss (?:gulp|vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/i;
1384
- const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!?\s*weapp-tailwindcss (?:gulp|vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/gi;
1385
- const BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE = /\/\*!?\s*weapp-tailwindcss (gulp|vite|webpack)-generated-css(?:\s*:\s*([^\s*]+))?\s*\*\/\s*/gi;
1386
- const BUNDLER_GENERATED_CSS_END_MARKER_GLOBAL_RE = /\/\*!?\s*weapp-tailwindcss (?:gulp|vite|webpack)-generated-css-end\s*:\s*[^\s*]+\s*\*\/\s*/gi;
1387
- const VITE_INTERNAL_CSS_MARKER_GLOBAL_RE = /\/\*\$vite\$:\d+\*\/\s*/g;
1388
- function createBundlerGeneratedCssMarker(bundler, file) {
1389
- return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
1390
- }
1391
- function createBundlerGeneratedCssEndMarker(bundler, file) {
1392
- return `/*! weapp-tailwindcss ${bundler}-generated-css-end:${encodeURIComponent(file)} */`;
1393
- }
1394
- function hasBundlerGeneratedCssMarker(source) {
1395
- return typeof source === "string" && BUNDLER_GENERATED_CSS_MARKER_RE.test(source);
1396
- }
1397
- function stripBundlerGeneratedCssMarkers(source) {
1398
- return source.replace(BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE, "").replace(BUNDLER_GENERATED_CSS_END_MARKER_GLOBAL_RE, "").replace(VITE_INTERNAL_CSS_MARKER_GLOBAL_RE, "");
1399
- }
1400
- function parseBundlerGeneratedCssMarkerBlocks(source) {
1401
- const blocks = [];
1402
- BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.lastIndex = 0;
1403
- let match = BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.exec(source);
1404
- while (match !== null) {
1405
- const cssStart = BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.lastIndex;
1406
- const nextMatch = BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.exec(source);
1407
- const cssEnd = nextMatch?.index ?? source.length;
1408
- const file = match[2] ? decodeURIComponent(match[2]) : void 0;
1409
- blocks.push({
1410
- bundler: match[1],
1411
- file,
1412
- css: source.slice(cssStart, cssEnd)
1413
- });
1414
- match = nextMatch;
1415
- }
1416
- return blocks;
1242
+ function resolveCssSourceBase(file, cssHandlerOptions) {
1243
+ const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
1244
+ return path.dirname(path.resolve(normalized));
1417
1245
  }
1418
1246
  //#endregion
1419
- //#region src/bundlers/shared/style-requests.ts
1247
+ //#region src/generation/style-requests.ts
1420
1248
  const SOURCE_STYLE_EXT_RE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)$/i;
1421
1249
  const SOURCE_PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)$/i;
1422
1250
  const SFC_SOURCE_EXT_RE = /\.(?:vue|uvue|nvue|svelte|mpx)$/i;
@@ -1468,28 +1296,7 @@ function isVueScopedStyleRequest(request) {
1468
1296
  return VUE_STYLE_QUERY_RE.test(query) && /(?:^|&)scoped(?:=[^&]*)?(?:&|$)/.test(query);
1469
1297
  }
1470
1298
  //#endregion
1471
- //#region src/bundlers/shared/generator-css/source-resolver/postcss-source.ts
1472
- function resolvePostcssFromOption(cssHandlerOptions) {
1473
- const from = cssHandlerOptions.postcssOptions?.options?.from;
1474
- return typeof from === "string" && from.length > 0 ? from : void 0;
1475
- }
1476
- function resolvePostcssRequestOption(cssHandlerOptions) {
1477
- return resolveCssHandlerSourceOptions(cssHandlerOptions)?.requestFile ?? resolvePostcssFromOption(cssHandlerOptions);
1478
- }
1479
- function resolvePostcssSourceFile(cssHandlerOptions) {
1480
- const from = resolvePostcssFromOption(cssHandlerOptions);
1481
- if (!from || !path.isAbsolute(from)) return;
1482
- return from.replace(/[?#].*$/, "");
1483
- }
1484
- function resolveCssHandlerSourceOptions(cssHandlerOptions) {
1485
- return cssHandlerOptions.sourceOptions;
1486
- }
1487
- function resolveCssSourceBase(file, cssHandlerOptions) {
1488
- const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
1489
- return path.dirname(path.resolve(normalized));
1490
- }
1491
- //#endregion
1492
- //#region src/bundlers/shared/generator-css/generation-helpers/preflight.ts
1299
+ //#region src/generation/generation-helpers/preflight.ts
1493
1300
  function hasMiniProgramTailwindV4PreflightReset(css) {
1494
1301
  return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\bborder\s*:\s*0\s+solid\b/.test(css);
1495
1302
  }
@@ -1498,7 +1305,7 @@ function isMiniProgramGeneratorTarget(target) {
1498
1305
  }
1499
1306
  function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
1500
1307
  if (!isMiniProgramGeneratorTarget(target)) return css;
1501
- if (options.styleOptions && isVueScopedStyleRequest(resolvePostcssRequestOption(options.styleOptions))) return finalizeMiniProgramCss$1(css, {
1308
+ if (options.styleOptions && isVueScopedStyleRequest(resolvePostcssRequestOption(options.styleOptions))) return finalizeMiniProgramCss(css, {
1502
1309
  cssPreflight: false,
1503
1310
  cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
1504
1311
  isTailwindcssV4: true,
@@ -1508,7 +1315,7 @@ function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPrefligh
1508
1315
  const hasPreflightReset = hasMiniProgramTailwindV4PreflightReset(css);
1509
1316
  const injectPreflight = options.injectPreflight !== false && !hasPreflightReset;
1510
1317
  const preservePreflight = options.preservePreflight !== false;
1511
- return finalizeMiniProgramCss$1(css, {
1318
+ return finalizeMiniProgramCss(css, {
1512
1319
  cssPreflight: cssPreflight === false || options.injectPreflight === false && (!hasPreflightReset || !preservePreflight) ? false : injectPreflight ? cssPreflight : hasPreflightReset && preservePreflight ? cssPreflight : void 0,
1513
1320
  cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
1514
1321
  isTailwindcssV4: true,
@@ -1556,128 +1363,7 @@ function resolveMiniProgramPreflightModeForGeneratorCss(opts, options) {
1556
1363
  };
1557
1364
  }
1558
1365
  //#endregion
1559
- //#region src/bundlers/shared/generator-css/generation-helpers/source-order.ts
1560
- function createCssSourceOrderAppend(base, extra) {
1561
- if (!base) return extra;
1562
- if (!extra) return base;
1563
- if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
1564
- return `${base}\n${extra}`;
1565
- }
1566
- const LEGACY_PSEUDO_ELEMENTS = [
1567
- "before",
1568
- "after",
1569
- "first-letter",
1570
- "first-line"
1571
- ];
1572
- const CSS_STRING_LITERAL_RE = /(["'])((?:\\[\s\S]|(?!\1)[\s\S])*)\1/g;
1573
- function isLegacyPseudoElementAt(selector, index) {
1574
- for (const name of LEGACY_PSEUDO_ELEMENTS) {
1575
- if (!selector.startsWith(name, index)) continue;
1576
- const next = selector[index + name.length];
1577
- if (next === void 0 || !/[\w-]/.test(next)) return name;
1578
- }
1579
- }
1580
- function normalizeLegacyPseudoElements(selector) {
1581
- let result = "";
1582
- let quote;
1583
- let bracketDepth = 0;
1584
- let index = 0;
1585
- while (index < selector.length) {
1586
- const char = selector[index];
1587
- if (char === "\\") {
1588
- result += selector.slice(index, index + 2);
1589
- index += 2;
1590
- continue;
1591
- }
1592
- if (quote !== void 0) {
1593
- result += char;
1594
- if (char === quote) quote = void 0;
1595
- index += 1;
1596
- continue;
1597
- }
1598
- if (char === "\"" || char === "'") {
1599
- quote = char;
1600
- result += char;
1601
- index += 1;
1602
- continue;
1603
- }
1604
- if (char === "[") {
1605
- bracketDepth++;
1606
- result += char;
1607
- index += 1;
1608
- continue;
1609
- }
1610
- if (char === "]") {
1611
- bracketDepth = Math.max(0, bracketDepth - 1);
1612
- result += char;
1613
- index += 1;
1614
- continue;
1615
- }
1616
- if (bracketDepth === 0 && char === ":" && selector[index + 1] === ":") {
1617
- result += "::";
1618
- index += 2;
1619
- continue;
1620
- }
1621
- if (bracketDepth === 0 && char === ":") {
1622
- const name = isLegacyPseudoElementAt(selector, index + 1);
1623
- if (name) {
1624
- result += `::${name}`;
1625
- index += name.length + 1;
1626
- continue;
1627
- }
1628
- }
1629
- result += char;
1630
- index += 1;
1631
- }
1632
- return result;
1633
- }
1634
- function normalizeCssRuleDeduplicationSelector(selector) {
1635
- return normalizeLegacyPseudoElements(selector).replace(/\s+/g, " ").replace(/\s*([>+~])\s*/g, "$1").replace(/\(\s+/g, "(").replace(/\s+\)/g, ")").trim();
1636
- }
1637
- function normalizeCssRuleDeduplicationValue(value) {
1638
- return value.replace(/\s+/g, " ").replace(CSS_STRING_LITERAL_RE, (_match, _quote, content) => {
1639
- return `'${content.replace(/\\(["'])/g, "$1").replace(/'/g, "\\'")}'`;
1640
- }).trim();
1641
- }
1642
- function createRuleDeduplicationKey(rule) {
1643
- const parents = [];
1644
- let parent = rule.parent;
1645
- while (parent && parent.type !== "root") {
1646
- if (parent.type === "atrule") parents.push(`${parent.name}:${parent.params}`);
1647
- parent = parent.parent;
1648
- }
1649
- const declarations = (rule.nodes ?? []).map((node) => {
1650
- if (node.type === "decl") return `${node.prop}:${normalizeCssRuleDeduplicationValue(node.value)}:${node.important ? "1" : "0"}`;
1651
- if (node.type === "comment") return "";
1652
- return normalizeCssRuleDeduplicationValue(node.toString());
1653
- }).filter(Boolean);
1654
- const selectors = (rule.selectors?.length ? rule.selectors : [rule.selector]).map(normalizeCssRuleDeduplicationSelector);
1655
- return [
1656
- parents.reverse().join("|"),
1657
- selectors.join(","),
1658
- declarations.join(";")
1659
- ].join("\n");
1660
- }
1661
- function deduplicateGeneratedCssRules(css) {
1662
- if (!css) return css;
1663
- try {
1664
- const root = postcss.parse(css);
1665
- const seen = /* @__PURE__ */ new Set();
1666
- root.walkRules((rule) => {
1667
- const key = createRuleDeduplicationKey(rule);
1668
- if (seen.has(key)) {
1669
- rule.remove();
1670
- return;
1671
- }
1672
- seen.add(key);
1673
- });
1674
- return root.toString();
1675
- } catch {
1676
- return css;
1677
- }
1678
- }
1679
- //#endregion
1680
- //#region src/bundlers/shared/generator-css/generation-helpers/results.ts
1366
+ //#region src/generation/generation-helpers/results.ts
1681
1367
  function shouldFinalizeMarkedUserLayerComponentsCss(file) {
1682
1368
  return !/\.(?:vue|svelte|astro|scss|sass|less|styl)(?:[?#].*)?$/i.test(file);
1683
1369
  }
@@ -1715,7 +1401,7 @@ function mergeGeneratorResults(generatedResults) {
1715
1401
  };
1716
1402
  }
1717
1403
  //#endregion
1718
- //#region src/bundlers/shared/generator-css/generation-helpers/runtime-isolation.ts
1404
+ //#region src/generation/generation-helpers/runtime-isolation.ts
1719
1405
  function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
1720
1406
  if (options.isolateCssSource) {
1721
1407
  if (options.matchedCssSourceFile) return /* @__PURE__ */ new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
@@ -1764,7 +1450,27 @@ function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOpt
1764
1450
  };
1765
1451
  }
1766
1452
  //#endregion
1767
- //#region src/bundlers/shared/framework-postcss.ts
1453
+ //#region src/tailwindcss/v4/rpx-theme-warning.ts
1454
+ const warnedSessions = /* @__PURE__ */ new WeakSet();
1455
+ function shouldCheckRpxThemeRisk(session, target, opts, platform) {
1456
+ if (target !== "weapp" || warnedSessions.has(session) || opts.logLevel === "silent" || opts.logLevel === "error") return false;
1457
+ const resolved = normalizeFrameworkStylePlatform(platform ?? opts.cssOptions?.platform ?? opts.platform ?? process.env["UNI_UTS_PLATFORM"] ?? process.env["UNI_PLATFORM"] ?? process.env["TARO_ENV"] ?? process.env["MPX_CURRENT_TARGET_MODE"] ?? process.env["MPX_CLI_MODE"], opts.appType);
1458
+ return resolved === "mp-weixin" || resolved === "weapp" || resolved === "wx" || resolved === "weixin";
1459
+ }
1460
+ function collectRpxThemeRiskSources(sources) {
1461
+ const variables = /* @__PURE__ */ new Set();
1462
+ for (const css of new Set(sources)) for (const name of collectRpxThemeVariables(css)) variables.add(name);
1463
+ return [...variables];
1464
+ }
1465
+ function warnRpxThemeRisk(session, variables, outputCss) {
1466
+ if (warnedSessions.has(session) || variables.length === 0) return;
1467
+ const usage = inspectRpxCalcUsage(outputCss, new Set(variables));
1468
+ const runtimeHint = usage === void 0 ? "当前 CSS 无法完成诊断,请检查最终 WXSS。" : usage.variables.length > 0 || usage.inlineRpx ? `当前输出仍含运行时 calc:${[...usage.variables, ...usage.inlineRpx ? ["内联 rpx"] : []].join(", ")}。` : "当前输出未检测到相关运行时 calc;这不代表已验证所有作用域和设备。";
1469
+ warnedSessions.add(session);
1470
+ logger.warn(`[tailwindcss@4][rpx-theme] @theme 中使用 rpx 的主题变量:${variables.join(", ")}。${runtimeHint} 微信 WXSS 可能先独立换算或量化基数再乘法,造成尺寸偏差,具体取整算法尚未确认。固定像素尺寸优先使用 px,需要缩放时在构建期输出最终静态 rpx;偶数或较大 rpx 也不保证准确。请检查最终 WXSS 并在目标设备验证:https://tw.weapp.dev/docs/issues/spacing-rpx`);
1471
+ }
1472
+ //#endregion
1473
+ //#region src/generation/framework-postcss.ts
1768
1474
  const FRAMEWORK_POSTCSS_REGISTRY = Symbol.for("weapp-tailwindcss.framework-postcss-options");
1769
1475
  const registryHost = globalThis;
1770
1476
  const frameworkPostcssOptions = registryHost[FRAMEWORK_POSTCSS_REGISTRY] ?? (registryHost[FRAMEWORK_POSTCSS_REGISTRY] = /* @__PURE__ */ new WeakMap());
@@ -1852,393 +1558,76 @@ function createGeneratedCssHandlerOptions(owner, options, from) {
1852
1558
  ...merged?.options ?? {},
1853
1559
  from
1854
1560
  }
1855
- }
1856
- };
1857
- }
1858
- function createFrameworkReplayArtifact(generated, options) {
1859
- const sourceId = generated.metadata?.file ?? options.file;
1860
- const scope = {
1861
- id: generated.metadata?.outputFile ?? sourceId,
1862
- kind: options.cssHandlerOptions.isMainChunk ? "global" : "component"
1863
- };
1864
- return createGenerationArtifact([createCssFragment({
1865
- id: `${scope.id}:framework-replay`,
1866
- kind: "tailwind",
1867
- css: generated.css,
1868
- sourceId,
1869
- scope,
1870
- stage: "raw"
1871
- })], {
1872
- classSet: new Set(generated.classSet),
1873
- rawCandidates: new Set(options.rawCandidates),
1874
- dependencies: generated.dependencies,
1875
- sourceEntries: options.cssHandlerOptions.sourceOptions?.cssEntries ?? [],
1876
- ...generated.metadata?.revision === void 0 ? {} : { revision: generated.metadata.revision }
1877
- });
1878
- }
1879
- async function adaptGeneratedCssWithFrameworkPipeline(owner, generated, options) {
1880
- const handlerOptions = createGeneratedCssHandlerOptions(owner, options.cssHandlerOptions, options.file);
1881
- if (generated.target === "web") return (await processFrameworkCss(generated.css, handlerOptions.postcssOptions)).css;
1882
- const handled = await options.styleHandler(generated.css, handlerOptions);
1883
- const preflightMode = generated.metadata?.preflightMode;
1884
- const injectPreflight = preflightMode?.inject ?? options.cssHandlerOptions.isMainChunk;
1885
- const preservePreflight = preflightMode?.preserve ?? options.cssHandlerOptions.isMainChunk;
1886
- return finalizeMiniProgramGeneratorCss(handled.css, generated.target, options.majorVersion, owner.cssPreflight, {
1887
- ...injectPreflight === void 0 ? {} : { injectPreflight },
1888
- ...preservePreflight === void 0 ? {} : { preservePreflight },
1889
- styleOptions: options.cssHandlerOptions
1890
- });
1891
- }
1892
- async function adaptGeneratedCssWithFrameworkRootPipeline(owner, generated, options) {
1893
- const handlerOptions = createGeneratedCssHandlerOptions(owner, options.cssHandlerOptions, options.file);
1894
- if (generated.target === "web") return (await processFrameworkCss(generated.css, handlerOptions.postcssOptions)).css;
1895
- const replayArtifact = createFrameworkReplayArtifact(generated, options);
1896
- const handled = options.compiler && options.snapshot ? composeGenerationArtifact(await (async () => {
1897
- for (const fragment of replayArtifact.fragments) {
1898
- fragment.root = (await options.compiler.transformCssRoot(fragment.root, options.snapshot, handlerOptions)).root.clone();
1899
- fragment.stage = "framework-processed";
1900
- }
1901
- return replayArtifact;
1902
- })()) : typeof options.styleHandler.transformRoot === "function" ? composeGenerationArtifact(await createStylePlatformAdapter({
1903
- id: generated.target === "web" ? "web" : "mini-program",
1904
- styleHandler: options.styleHandler,
1905
- styleOptions: handlerOptions
1906
- }).transform(replayArtifact, { stage: "framework-processed" })) : await options.styleHandler(generated.css, handlerOptions);
1907
- const preflightMode = generated.metadata?.preflightMode;
1908
- const injectPreflight = preflightMode?.inject ?? options.cssHandlerOptions.isMainChunk;
1909
- const preservePreflight = preflightMode?.preserve ?? options.cssHandlerOptions.isMainChunk;
1910
- return finalizeMiniProgramGeneratorCss(handled.css, generated.target, options.majorVersion, owner.cssPreflight, {
1911
- ...injectPreflight === void 0 ? {} : { injectPreflight },
1912
- ...preservePreflight === void 0 ? {} : { preservePreflight },
1913
- styleOptions: options.cssHandlerOptions
1914
- });
1915
- }
1916
- //#endregion
1917
- //#region src/bundlers/shared/framework-css-composition.ts
1918
- function nodeContent(node) {
1919
- switch (node.type) {
1920
- case "decl": return `decl\u0000${node.prop}\u0000${node.value}\u0000${node.important ? "1" : "0"}`;
1921
- case "rule": return `rule\u0000${node.selectors.map((selector) => selector.trim()).join("")}\u0000${node.nodes.reduce((parts, child) => {
1922
- if (child.type !== "comment") parts.push(nodeContent(child));
1923
- return parts;
1924
- }, []).join("")}`;
1925
- case "atrule": return `atrule\u0000${node.name}\u0000${node.params}\u0000${node.nodes?.reduce((parts, child) => {
1926
- if (child.type !== "comment") parts.push(nodeContent(child));
1927
- return parts;
1928
- }, []).join("") ?? ""}`;
1929
- default: return `comment\u0000${node.text}`;
1930
- }
1931
- }
1932
- function visitRules(container, context, visit) {
1933
- container.each((node) => {
1934
- if (node.type === "rule" || node.type === "atrule" && /^(?:font-face|(?:-\w+-)?keyframes)$/.test(node.name)) visit(node, `${context}\u0000${nodeContent(node)}`, context);
1935
- else if (node.type === "atrule" && node.nodes && !(node.name === "layer" && !node.params.trim())) visitRules(node, `${context}\u0000${node.name}\u0000${node.params}`, visit);
1936
- });
1937
- }
1938
- function collectRules(root) {
1939
- const rules = [];
1940
- visitRules(root, "", (node, key, context) => rules.push({
1941
- node,
1942
- key,
1943
- context
1944
- }));
1945
- return rules;
1946
- }
1947
- function removeRules(container, removed, ruleKeys) {
1948
- const nodes = container.nodes ?? [];
1949
- const retained = [];
1950
- for (const node of nodes) {
1951
- if (removed.has(node)) continue;
1952
- const key = ruleKeys.get(node);
1953
- const previous = retained.at(-1);
1954
- if (key && previous && key === ruleKeys.get(previous)) continue;
1955
- if (node.type === "atrule" && node.nodes?.length) {
1956
- removeRules(node, removed, ruleKeys);
1957
- if (node.nodes.length === 0 && node.name !== "layer") continue;
1958
- }
1959
- retained.push(node);
1960
- }
1961
- if (retained.length !== nodes.length) {
1962
- container.removeAll();
1963
- container.append(retained);
1964
- }
1965
- }
1966
- function matchOrderedPrefix(rules, positions) {
1967
- const prefix = [];
1968
- let previous = -1;
1969
- for (const rule of rules) {
1970
- const matches = positions.get(rule.key) ?? [];
1971
- let left = 0;
1972
- let right = matches.length;
1973
- while (left < right) {
1974
- const middle = left + right >>> 1;
1975
- if (matches[middle] <= previous) left = middle + 1;
1976
- else right = middle;
1977
- }
1978
- if (left === matches.length) break;
1979
- previous = matches[left];
1980
- prefix.push(previous);
1981
- }
1982
- return prefix;
1983
- }
1984
- /** 保留生成侧已确定的层位置;框架侧重复选择器及其间的覆盖区间按原顺序恢复。 */
1985
- function composeFrameworkProcessedCss(before, generated, after) {
1986
- if (!before.trim() && !after.trim()) return generated;
1987
- const inputs = [
1988
- before,
1989
- generated,
1990
- after
1991
- ];
1992
- try {
1993
- const roots = inputs.map((css) => postcss.parse(css));
1994
- const generatedRules = collectRules(roots[1]);
1995
- const generatedKeys = new Set(generatedRules.map((rule) => rule.key));
1996
- const positions = /* @__PURE__ */ new Map();
1997
- generatedRules.forEach((rule, index) => {
1998
- const matches = positions.get(rule.key) ?? [];
1999
- matches.push(index);
2000
- positions.set(rule.key, matches);
2001
- });
2002
- const frameworkRules = [...collectRules(roots[0]), ...collectRules(roots[2])];
2003
- const ruleKeys = new Map([...generatedRules, ...frameworkRules].map((record) => [record.node, record.key]));
2004
- const scopes = /* @__PURE__ */ new Map();
2005
- for (const record of frameworkRules) {
2006
- const rules = scopes.get(record.context) ?? [];
2007
- rules.push(record);
2008
- scopes.set(record.context, rules);
2009
- }
2010
- const preserve = /* @__PURE__ */ new Set();
2011
- const generatedPrefix = /* @__PURE__ */ new Set();
2012
- for (const rules of scopes.values()) {
2013
- const ranges = /* @__PURE__ */ new Map();
2014
- rules.forEach(({ node }, index) => {
2015
- const selectors = node.type === "rule" ? node.selectors : [JSON.stringify([node.name, node.params])];
2016
- for (const selector of selectors) {
2017
- const range = ranges.get(selector);
2018
- if (range) range[1] = index;
2019
- else ranges.set(selector, [index, index]);
2020
- }
2021
- });
2022
- const boundaries = new Int32Array(rules.length + 1);
2023
- for (const [first, last] of ranges.values()) if (first !== last) {
2024
- boundaries[first] += 1;
2025
- boundaries[last + 1] -= 1;
2026
- }
2027
- let depth = 0;
2028
- let start = 0;
2029
- for (let index = 0; index < rules.length; index++) {
2030
- const previousDepth = depth;
2031
- depth += boundaries[index];
2032
- if (previousDepth === 0 && depth > 0) start = index;
2033
- if (depth > 0 && depth + boundaries[index + 1] === 0) {
2034
- const group = rules.slice(start, index + 1);
2035
- const prefix = matchOrderedPrefix(group, positions);
2036
- if (prefix.length !== group.length) {
2037
- prefix.forEach((position) => generatedPrefix.add(generatedRules[position].node));
2038
- group.slice(prefix.length).forEach((record) => preserve.add(record));
2039
- }
2040
- }
2041
- }
2042
- }
2043
- const restoredKeys = new Set([...preserve].map((record) => record.key));
2044
- const removed = /* @__PURE__ */ new Set();
2045
- for (const record of frameworkRules) if (!preserve.has(record) && generatedKeys.has(record.key)) removed.add(record.node);
2046
- for (const record of generatedRules) if (restoredKeys.has(record.key) && !generatedPrefix.has(record.node)) removed.add(record.node);
2047
- let charset;
2048
- for (const root of roots) {
2049
- removeRules(root, removed, ruleKeys);
2050
- root.walkAtRules("charset", (rule) => {
2051
- charset ?? (charset = rule.clone({ raws: {
2052
- before: "",
2053
- afterName: " "
2054
- } }));
2055
- rule.remove();
2056
- });
2057
- }
2058
- const css = roots.map((root) => root.toString()).filter((value) => value.trim()).join("\n");
2059
- return charset ? `${charset.toString()};\n${css}` : css;
2060
- } catch {
2061
- return inputs.filter((value) => value.trim()).join("\n");
2062
- }
2063
- }
2064
- //#endregion
2065
- //#region src/bundlers/shared/generator-css/user-layer-order.ts
2066
- const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
2067
- const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
2068
- function appendCss(base, extra) {
2069
- if (!base) return extra;
2070
- if (!extra) return base;
2071
- if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
2072
- return `${base}\n${extra}`;
2073
- }
2074
- function removeFirstCssOccurrence(css, chunk) {
2075
- const trimmed = chunk.trim();
2076
- if (!trimmed) return css;
2077
- const index = css.indexOf(trimmed);
2078
- if (index === -1) return css;
2079
- return appendCss(css.slice(0, index).trimEnd(), css.slice(index + trimmed.length).trimStart());
2080
- }
2081
- function collectSelectorsFromCss(css) {
2082
- const selectors = /* @__PURE__ */ new Set();
2083
- try {
2084
- postcss.parse(css).walkRules((rule) => {
2085
- for (const selector of rule.selectors ?? [rule.selector]) {
2086
- const normalized = selector.trim();
2087
- if (normalized) selectors.add(normalized);
2088
- }
2089
- });
2090
- } catch {}
2091
- return selectors;
2092
- }
2093
- function normalizeRuleValue(value) {
2094
- return value.replace(/\s+/g, " ").trim();
2095
- }
2096
- function createRuleKey(rule) {
2097
- const parents = [];
2098
- let parent = rule.parent;
2099
- while (parent && parent.type !== "root") {
2100
- if (parent.type === "atrule") parents.push(`${parent.name}:${normalizeRuleValue(parent.params)}`);
2101
- parent = parent.parent;
2102
- }
2103
- const selectors = (rule.selectors ?? [rule.selector]).map((selector) => normalizeRuleValue(selector)).join(",");
2104
- const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl").map((node) => `${node.prop}:${normalizeRuleValue(node.value)}:${node.important ? "1" : "0"}`).join(";");
2105
- return `${parents.reverse().join("|")}\n${selectors}\n${declarations}`;
2106
- }
2107
- function collectRuleKeysFromCss(css) {
2108
- const keys = /* @__PURE__ */ new Set();
2109
- try {
2110
- postcss.parse(css).walkRules((rule) => {
2111
- keys.add(createRuleKey(rule));
2112
- });
2113
- } catch {}
2114
- return keys;
2115
- }
2116
- function matchesLayerSelector(selector, layerSelector) {
2117
- if (selector === layerSelector) return true;
2118
- if (!selector.startsWith(layerSelector)) return false;
2119
- const next = selector[layerSelector.length];
2120
- return next === ":" || next === "[";
2121
- }
2122
- function removeCssRulesForSelectors(css, layerCss) {
2123
- const selectors = [...collectSelectorsFromCss(layerCss)];
2124
- if (selectors.length === 0) return css;
2125
- try {
2126
- const root = postcss.parse(css);
2127
- root.walkRules((rule) => {
2128
- if ((rule.selectors ?? [rule.selector]).some((selector) => selectors.some((layerSelector) => matchesLayerSelector(selector.trim(), layerSelector)))) rule.remove();
2129
- });
2130
- return root.toString();
2131
- } catch {
2132
- return removeFirstCssOccurrence(css, layerCss);
2133
- }
2134
- }
2135
- function removeExactCssRules(css, duplicateCss) {
2136
- const duplicateKeys = collectRuleKeysFromCss(duplicateCss);
2137
- if (duplicateKeys.size === 0) return css;
2138
- try {
2139
- const root = postcss.parse(css);
2140
- root.walkRules((rule) => {
2141
- if (duplicateKeys.has(createRuleKey(rule))) rule.remove();
2142
- });
2143
- return root.toString();
2144
- } catch {
2145
- return css;
2146
- }
2147
- }
2148
- function wrapUserLayerComponentsCss(css) {
2149
- return css.trim().length > 0 ? `${USER_LAYER_COMPONENTS_START}\n${css}\n${USER_LAYER_COMPONENTS_END}` : css;
2150
- }
2151
- function extractMarkedUserLayerComponentsCss(css) {
2152
- const layers = [];
2153
- let rest = "";
2154
- let cursor = 0;
2155
- while (cursor < css.length) {
2156
- const startIndex = css.indexOf(USER_LAYER_COMPONENTS_START, cursor);
2157
- if (startIndex === -1) {
2158
- rest += css.slice(cursor);
2159
- break;
2160
- }
2161
- rest += css.slice(cursor, startIndex);
2162
- const contentStart = startIndex + 47;
2163
- const endIndex = css.indexOf(USER_LAYER_COMPONENTS_END, contentStart);
2164
- if (endIndex === -1) {
2165
- rest += css.slice(startIndex);
2166
- break;
2167
- }
2168
- const layerCss = css.slice(contentStart, endIndex).trim();
2169
- if (layerCss) layers.push(layerCss);
2170
- cursor = endIndex + 45;
2171
- }
2172
- return {
2173
- layers,
2174
- rest
1561
+ }
2175
1562
  };
2176
1563
  }
2177
- function isGeneratedInfrastructureRule(rule) {
2178
- const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
2179
- if (declarations.length === 0) return false;
2180
- if (declarations.every((declaration) => declaration.prop.startsWith("--"))) return true;
2181
- const selectors = (rule.selectors ?? [rule.selector]).map((selector) => selector.trim());
2182
- if (!(selectors.length > 0 && selectors.every((selector) => selector === "view" || selector === "text" || selector === "::before" || selector === "::after"))) return false;
2183
- const declarationMap = new Map(declarations.map((declaration) => [declaration.prop, declaration.value]));
2184
- return declarationMap.get("box-sizing") === "border-box" && declarationMap.has("border");
1564
+ function createFrameworkReplayArtifact(generated, options) {
1565
+ const sourceId = generated.metadata?.file ?? options.file;
1566
+ const scope = {
1567
+ id: generated.metadata?.outputFile ?? sourceId,
1568
+ kind: options.cssHandlerOptions.isMainChunk ? "global" : "component"
1569
+ };
1570
+ return createGenerationArtifact([createCssFragment({
1571
+ id: `${scope.id}:framework-replay`,
1572
+ kind: "tailwind",
1573
+ css: generated.css,
1574
+ sourceId,
1575
+ scope,
1576
+ stage: "raw"
1577
+ })], {
1578
+ classSet: new Set(generated.classSet),
1579
+ rawCandidates: new Set(options.rawCandidates),
1580
+ dependencies: generated.dependencies,
1581
+ sourceEntries: options.cssHandlerOptions.sourceOptions?.cssEntries ?? [],
1582
+ ...generated.metadata?.revision === void 0 ? {} : { revision: generated.metadata.revision }
1583
+ });
2185
1584
  }
2186
- function findLayerInsertionIndex(css) {
2187
- try {
2188
- const root = postcss.parse(css);
2189
- let insertionIndex = -1;
2190
- root.walkRules((rule) => {
2191
- if (insertionIndex !== -1 || isGeneratedInfrastructureRule(rule)) return;
2192
- let topLevelNode = rule;
2193
- while (topLevelNode.parent && topLevelNode.parent.type !== "root") topLevelNode = topLevelNode.parent;
2194
- const offset = topLevelNode.source?.start?.offset;
2195
- if (typeof offset === "number") insertionIndex = css.lastIndexOf("\n", Math.max(0, offset - 1)) + 1;
2196
- });
2197
- return insertionIndex;
2198
- } catch {
2199
- return -1;
2200
- }
1585
+ async function adaptGeneratedCssWithFrameworkPipeline(owner, generated, options) {
1586
+ const handlerOptions = createGeneratedCssHandlerOptions(owner, options.cssHandlerOptions, options.file);
1587
+ if (generated.target === "web") return (await processFrameworkCss(generated.css, handlerOptions.postcssOptions)).css;
1588
+ const handled = await options.styleHandler(generated.css, handlerOptions);
1589
+ const preflightMode = generated.metadata?.preflightMode;
1590
+ const injectPreflight = preflightMode?.inject ?? options.cssHandlerOptions.isMainChunk;
1591
+ const preservePreflight = preflightMode?.preserve ?? options.cssHandlerOptions.isMainChunk;
1592
+ return finalizeMiniProgramGeneratorCss(handled.css, generated.target, options.majorVersion, owner.cssPreflight, {
1593
+ ...injectPreflight === void 0 ? {} : { injectPreflight },
1594
+ ...preservePreflight === void 0 ? {} : { preservePreflight },
1595
+ styleOptions: options.cssHandlerOptions
1596
+ });
2201
1597
  }
2202
- function reorderMarkedUserLayerComponentsCss(css) {
2203
- if (!css.includes(USER_LAYER_COMPONENTS_START)) return css;
2204
- const { layers, rest } = extractMarkedUserLayerComponentsCss(css);
2205
- if (layers.length === 0) return rest;
2206
- const layerCss = layers.join("\n");
2207
- const restWithoutLayerDuplicates = removeExactCssRules(rest, layerCss);
2208
- const insertionIndex = findLayerInsertionIndex(restWithoutLayerDuplicates);
2209
- if (insertionIndex === -1) return appendCss(restWithoutLayerDuplicates, layerCss);
2210
- return appendCss(appendCss(restWithoutLayerDuplicates.slice(0, insertionIndex), layerCss), restWithoutLayerDuplicates.slice(insertionIndex));
2211
- }
2212
- function mergeMarkedUserLayerComponentsCss(baseCss, markedCss) {
2213
- if (!markedCss.includes(USER_LAYER_COMPONENTS_START)) return {
2214
- css: baseCss,
2215
- merged: false
2216
- };
2217
- const { layers } = extractMarkedUserLayerComponentsCss(markedCss);
2218
- if (layers.length === 0) return {
2219
- css: baseCss,
2220
- merged: false
2221
- };
2222
- const layerCss = layers.join("\n");
2223
- return {
2224
- css: reorderMarkedUserLayerComponentsCss(appendCss(removeCssRulesForSelectors(baseCss, layerCss), wrapUserLayerComponentsCss(layerCss))),
2225
- merged: true
2226
- };
1598
+ async function adaptGeneratedCssWithFrameworkRootPipeline(owner, generated, options) {
1599
+ const handlerOptions = createGeneratedCssHandlerOptions(owner, options.cssHandlerOptions, options.file);
1600
+ if (generated.target === "web") return (await processFrameworkCss(generated.css, handlerOptions.postcssOptions)).css;
1601
+ const replayArtifact = createFrameworkReplayArtifact(generated, options);
1602
+ const handled = options.compiler && options.snapshot ? composeGenerationArtifact(await (async () => {
1603
+ for (const fragment of replayArtifact.fragments) {
1604
+ fragment.root = (await options.compiler.transformCssRoot(fragment.root, options.snapshot, handlerOptions)).root.clone();
1605
+ fragment.stage = "framework-processed";
1606
+ }
1607
+ return replayArtifact;
1608
+ })()) : typeof options.styleHandler.transformRoot === "function" ? composeGenerationArtifact(await createStylePlatformAdapter({
1609
+ id: generated.target === "web" ? "web" : "mini-program",
1610
+ styleHandler: options.styleHandler,
1611
+ styleOptions: handlerOptions
1612
+ }).transform(replayArtifact, { stage: "framework-processed" })) : await options.styleHandler(generated.css, handlerOptions);
1613
+ const preflightMode = generated.metadata?.preflightMode;
1614
+ const injectPreflight = preflightMode?.inject ?? options.cssHandlerOptions.isMainChunk;
1615
+ const preservePreflight = preflightMode?.preserve ?? options.cssHandlerOptions.isMainChunk;
1616
+ return finalizeMiniProgramGeneratorCss(handled.css, generated.target, options.majorVersion, owner.cssPreflight, {
1617
+ ...injectPreflight === void 0 ? {} : { injectPreflight },
1618
+ ...preservePreflight === void 0 ? {} : { preservePreflight },
1619
+ styleOptions: options.cssHandlerOptions
1620
+ });
2227
1621
  }
2228
1622
  //#endregion
2229
- //#region src/bundlers/shared/framework-user-css.ts
2230
- function normalizeFrameworkProcessedUserCss(source) {
2231
- if (!source.includes("source(")) return source;
2232
- try {
2233
- const root = postcss.parse(source);
2234
- root.walkAtRules("media", (rule) => {
2235
- if (/^source\(/.test(rule.params)) rule.replaceWith(...rule.nodes ?? []);
2236
- });
2237
- return root.toString();
2238
- } catch {
2239
- return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source));
2240
- }
1623
+ //#region src/generation/user-css/apply-only.ts
1624
+ function shouldFilterApplyOnlyGeneratedCss(_majorVersion, target, source, options) {
1625
+ if (!((target === "weapp" || target === "web") && hasTailwindApplyDirective(source) && !hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers)) return false;
1626
+ const analysis = analyzeApplyOnlySource(source);
1627
+ return analysis.selectors.size > 0 && analysis.onlyApply;
2241
1628
  }
1629
+ //#endregion
1630
+ //#region src/generation/framework-user-css.ts
2242
1631
  async function restoreFrameworkProcessedUserCss(css, generated, source, options, generatorOptions) {
2243
1632
  const generatedSource = createGeneratedThemeDeclarationResolver([generated.metadata?.rawCss, css].filter(Boolean).join("\n"));
2244
1633
  const userCssOptions = {
@@ -2270,14 +1659,7 @@ async function restoreFrameworkProcessedUserCss(css, generated, source, options,
2270
1659
  return stripTailwindBanners(reorderMarkedUserLayerComponentsCss(composeFrameworkProcessedCss(before, css, after)));
2271
1660
  }
2272
1661
  //#endregion
2273
- //#region src/bundlers/shared/generator-css/legacy-selectors.ts
2274
- function removeDuplicatedViteMarkers(css, baseCss) {
2275
- if (!VITE_MARKER_RE.test(baseCss)) return css;
2276
- VITE_MARKER_RE.lastIndex = 0;
2277
- return css.replace(VITE_MARKER_RE, "");
2278
- }
2279
- //#endregion
2280
- //#region src/bundlers/shared/generator-css/source-resolver/metadata.ts
1662
+ //#region src/generation/source-resolver/metadata.ts
2281
1663
  const generatorSourceMetadataKey = Symbol.for("weapp-tailwindcss.generator-source-metadata");
2282
1664
  function getGeneratorSourceMetadata(source) {
2283
1665
  return source[generatorSourceMetadataKey];
@@ -2305,7 +1687,7 @@ function withMatchedSourceSideMetadata(source, resolvedEntrySource, metadata = {
2305
1687
  }) : source;
2306
1688
  }
2307
1689
  //#endregion
2308
- //#region src/bundlers/shared/generator-css/source-files.ts
1690
+ //#region src/generation/source-files.ts
2309
1691
  const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
2310
1692
  const STYLE_IMPORT_EXTENSIONS = [
2311
1693
  ".css",
@@ -2488,7 +1870,7 @@ function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {
2488
1870
  if (source === void 0) continue;
2489
1871
  const directiveSources = extractStyleDirectiveSourcesDeep(source, sourceFile, /* @__PURE__ */ new Set([path.resolve(sourceFile)]));
2490
1872
  for (const styleSource of directiveSources) {
2491
- const cssEntrySource = resolveCssEntrySource(styleSource.source, path.dirname(styleSource.file), resolveOptions);
1873
+ const cssEntrySource = resolveCssEntrySource$1(styleSource.source, path.dirname(styleSource.file), resolveOptions);
2492
1874
  if (cssEntrySource) return {
2493
1875
  ...cssEntrySource,
2494
1876
  file: styleSource.file
@@ -2499,95 +1881,18 @@ function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {
2499
1881
  }
2500
1882
  }
2501
1883
  //#endregion
2502
- //#region src/bundlers/shared/generator-css/candidates.ts
2503
- function parseGeneratorCss(css) {
2504
- let root;
2505
- try {
2506
- root = postcss.parse(css);
2507
- } catch {
2508
- return;
2509
- }
2510
- return root;
2511
- }
2512
- function collectApplyCandidates(root) {
2513
- const candidates = /* @__PURE__ */ new Set();
2514
- root.walkAtRules("apply", (rule) => {
2515
- for (const candidate of splitCandidateTokens(rule.params)) candidates.add(candidate);
2516
- });
2517
- return candidates;
2518
- }
2519
- function collectCssApplyCandidates(css) {
2520
- const root = parseGeneratorCss(css);
2521
- return root ? [...collectApplyCandidates(root)].sort() : [];
2522
- }
2523
- function collectGeneratorCssCandidates(css) {
2524
- const root = parseGeneratorCss(css);
2525
- if (!root) return [];
2526
- const candidates = collectApplyCandidates(root);
2527
- const inlineCandidates = collectCssInlineSourceCandidates(root);
2528
- for (const candidate of inlineCandidates.included) candidates.add(candidate);
2529
- for (const candidate of inlineCandidates.excluded) candidates.delete(candidate);
2530
- return [...candidates].sort();
2531
- }
2532
- //#endregion
2533
- //#region src/bundlers/shared/generator-css/source-resolver/apply-reference.ts
1884
+ //#region src/generation/source-resolver/apply-reference.ts
2534
1885
  function resolveTailwindV4ApplyReference(options) {
2535
1886
  const references = /* @__PURE__ */ new Set();
2536
1887
  for (const source of options.cssSources ?? []) if (typeof source.file === "string" && source.file.length > 0 && typeof source.css === "string" && hasTailwindRootDirectives(source.css, { importFallback: true }) && hasTailwindApplyContextDirective(source.css)) references.add(source.file);
2537
1888
  return references.size === 1 ? references.values().next().value : void 0;
2538
1889
  }
2539
- function hasTailwindApplyContextDirective(css) {
2540
- try {
2541
- let found = false;
2542
- postcss.parse(css).walkAtRules((rule) => {
2543
- if (rule.name === "theme" || rule.name === "config") {
2544
- found = true;
2545
- return false;
2546
- }
2547
- });
2548
- return found;
2549
- } catch {
2550
- return false;
2551
- }
2552
- }
2553
1890
  function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
2554
1891
  const reference = resolveTailwindV4ApplyReference(sourceOptions);
2555
1892
  return createTailwindV4SourceReferenceSource(css, sourceOptions, reference ? `@reference ${JSON.stringify(reference.replace(/\\/g, "/"))};` : void 0);
2556
1893
  }
2557
- function createTailwindV4SourceReferenceSource(css, sourceOptions, referenceDirective) {
2558
- if (hasTailwindV4RootImport(css, sourceOptions)) return css;
2559
- const hasApplyDirective = hasTailwindApplyDirective(css);
2560
- if (!hasApplyDirective && !hasTailwindSourceDirectives(css, { importFallback: true })) return css;
2561
- const utilities = hasApplyDirective ? collectCssApplyCandidates(css) : [];
2562
- return [
2563
- referenceDirective ?? `@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
2564
- utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
2565
- css
2566
- ].filter(Boolean).join("\n");
2567
- }
2568
- function hasTailwindV4RootImport(css, sourceOptions) {
2569
- try {
2570
- const root = postcss.parse(css);
2571
- let found = false;
2572
- root.walkAtRules((rule) => {
2573
- if (rule.name === "tailwind") {
2574
- found = true;
2575
- return false;
2576
- }
2577
- if (rule.name !== "import" && rule.name !== "use" && rule.name !== "forward") return;
2578
- const request = parseImportRequest(rule.params);
2579
- if (request === (sourceOptions.packageName ?? "tailwindcss") || request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/")) {
2580
- found = true;
2581
- return false;
2582
- }
2583
- });
2584
- return found;
2585
- } catch {
2586
- return /@(?:import|use|forward|tailwind)(?:[\s"'(;]|$)/.test(css) && (css.includes("tailwindcss") || css.includes("tailwindcss4") || css.includes("weapp-tailwindcss"));
2587
- }
2588
- }
2589
1894
  //#endregion
2590
- //#region src/bundlers/shared/generator-css/source-resolver/config.ts
1895
+ //#region src/generation/source-resolver/config.ts
2591
1896
  function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
2592
1897
  if (config && existsSync(config)) return config;
2593
1898
  if (!configRequest || path.isAbsolute(configRequest)) return sourceOptions.config;
@@ -2615,7 +1920,7 @@ function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
2615
1920
  return sourceOptions.config;
2616
1921
  }
2617
1922
  //#endregion
2618
- //#region src/bundlers/shared/generator-css/source-resolver/matching.ts
1923
+ //#region src/generation/source-resolver/matching.ts
2619
1924
  function normalizeCssSourceForCompare(css) {
2620
1925
  return stripGeneratorPlaceholderMarkers(stripTailwindBanners(css)).trim();
2621
1926
  }
@@ -2689,7 +1994,7 @@ function scoreTailwindV4CssSourceFileMatch(file, cssSourceFile, sourceOptions) {
2689
1994
  return bestScore;
2690
1995
  }
2691
1996
  //#endregion
2692
- //#region src/bundlers/shared/generator-css/source-resolver/configuration.ts
1997
+ //#region src/generation/source-resolver/configuration.ts
2693
1998
  function createCssEntrySources(cssEntries) {
2694
1999
  return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && path.isAbsolute(entry)).map((entry) => ({ file: path.resolve(entry) }));
2695
2000
  }
@@ -2716,7 +2021,7 @@ function resolveUniqueTailwindV4CssConfig(sourceOptions) {
2716
2021
  const configs = /* @__PURE__ */ new Set();
2717
2022
  const collect = (css, base) => {
2718
2023
  if (!css || !base || !css.includes("@config")) return;
2719
- const source = resolveCssEntrySource(css, base, { removeConfig: false });
2024
+ const source = resolveCssEntrySource$1(css, base, { removeConfig: false });
2720
2025
  if (source?.config) configs.add(path.resolve(source.config));
2721
2026
  };
2722
2027
  collect(sourceOptions.css, sourceOptions.base ?? sourceOptions.projectRoot);
@@ -2749,7 +2054,7 @@ async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions, options
2749
2054
  });
2750
2055
  const css = readFileSync(cssEntry, "utf8");
2751
2056
  const base = path.dirname(path.resolve(cssEntry));
2752
- const entrySource = resolveCssEntrySource(css, base, { removeConfig: false });
2057
+ const entrySource = resolveCssEntrySource$1(css, base, { removeConfig: false });
2753
2058
  const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, cssEntry, {
2754
2059
  ...sourceOptions,
2755
2060
  sourceFile: sourceOptions.sourceFile ?? cssEntry
@@ -2757,7 +2062,7 @@ async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions, options
2757
2062
  return withGeneratorSourceMetadata(await resolveTailwindV4Source$1({
2758
2063
  ...omitUndefined(singleEntrySourceOptions),
2759
2064
  base,
2760
- css: normalizeConfigDirective(css, config),
2065
+ css: normalizeConfigDirective$1(css, config),
2761
2066
  cssEntries: [cssEntry]
2762
2067
  }), {
2763
2068
  candidateMatchedCssSource: options.candidateMatched,
@@ -2779,20 +2084,20 @@ function shouldResolveSourceSideCssEntry(rawSource) {
2779
2084
  }
2780
2085
  function normalizeTailwindV4CssSourceConfig(cssSource, sourceBase) {
2781
2086
  if (typeof cssSource.css !== "string" || cssSource.css.length === 0 || !cssSource.css.includes("@config")) return cssSource;
2782
- const entrySource = resolveCssEntrySource(cssSource.css, sourceBase, { removeConfig: false });
2087
+ const entrySource = resolveCssEntrySource$1(cssSource.css, sourceBase, { removeConfig: false });
2783
2088
  if (!entrySource?.config) return cssSource;
2784
2089
  return {
2785
2090
  ...cssSource,
2786
- css: normalizeConfigDirective(cssSource.css, entrySource.config)
2091
+ css: normalizeConfigDirective$1(cssSource.css, entrySource.config)
2787
2092
  };
2788
2093
  }
2789
2094
  function normalizeResolvedTailwindV4SourceConfig(source, file, sourceOptions) {
2790
2095
  if (!("css" in source) || typeof source.css !== "string" || !source.css.includes("@config")) return source;
2791
2096
  const sourceFile = typeof file === "string" && file.length > 0 ? file : getGeneratorSourceMetadata(source)?.matchedCssSourceFile;
2792
2097
  if (!sourceFile) return source;
2793
- const entrySource = resolveCssEntrySource(source.css, path.dirname(path.resolve(sourceFile)), { removeConfig: false });
2098
+ const entrySource = resolveCssEntrySource$1(source.css, path.dirname(path.resolve(sourceFile)), { removeConfig: false });
2794
2099
  const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, sourceFile, sourceOptions ?? {});
2795
- const normalizedCss = normalizeConfigDirective(source.css, config);
2100
+ const normalizedCss = normalizeConfigDirective$1(source.css, config);
2796
2101
  return normalizedCss === source.css ? source : {
2797
2102
  ...source,
2798
2103
  css: normalizedCss
@@ -2841,7 +2146,7 @@ function isSameTailwindV4CssSource(a, b) {
2841
2146
  return typeof a.css === "string" && typeof b.css === "string" && normalizeCssSourceForCompare(a.css) === normalizeCssSourceForCompare(b.css);
2842
2147
  }
2843
2148
  //#endregion
2844
- //#region src/bundlers/shared/generator-css/source-resolver/single-source.ts
2149
+ //#region src/generation/source-resolver/single-source.ts
2845
2150
  async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, options = {}) {
2846
2151
  const sourceBaseFallback = sourceOptions.base ?? sourceOptions.projectRoot ?? process.cwd();
2847
2152
  const sourceBase = resolveTailwindV4CssSourceBase(cssSource, sourceBaseFallback);
@@ -2956,7 +2261,7 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
2956
2261
  ...resolvedSourceOptions,
2957
2262
  sourceFile: resolvedEntrySource.file
2958
2263
  });
2959
- const css = createTailwindV4SourceReferenceSource(normalizeConfigDirective(prependConfigDirective(currentCss ?? resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
2264
+ const css = createTailwindV4SourceReferenceSource$1(normalizeConfigDirective$1(prependConfigDirective(currentCss ?? resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
2960
2265
  const source = await resolveTailwindV4Source$1(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
2961
2266
  base: currentCss && config ? path.dirname(config) : resolvedEntrySource.base,
2962
2267
  css,
@@ -2973,7 +2278,7 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
2973
2278
  });
2974
2279
  }
2975
2280
  //#endregion
2976
- //#region src/bundlers/shared/generator-css/source-resolver/source-matching.ts
2281
+ //#region src/generation/source-resolver/source-matching.ts
2977
2282
  async function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
2978
2283
  const cssEntries = sourceOptions.cssEntries;
2979
2284
  if (!cssEntries?.length) return;
@@ -3035,10 +2340,10 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
3035
2340
  });
3036
2341
  }
3037
2342
  //#endregion
3038
- //#region src/bundlers/shared/generator-css/source-resolver/resolve-source.ts
2343
+ //#region src/generation/source-resolver/resolve-source.ts
3039
2344
  async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
3040
2345
  const base = resolveCssSourceBase(file, cssHandlerOptions);
3041
- const cssEntrySource = resolveCssEntrySource(rawSource, base, {
2346
+ const cssEntrySource = resolveCssEntrySource$1(rawSource, base, {
3042
2347
  importFallback: generatorOptions?.importFallback ?? false,
3043
2348
  removeConfig: false
3044
2349
  });
@@ -3057,7 +2362,7 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
3057
2362
  const normalizedSourceOptions = resolvedSourceOptions ? normalizeTailwindV4CssSourceConfigs(resolvedSourceOptions) : void 0;
3058
2363
  if (applyEntrySource && !cssHandlerOptions.isMainChunk && !hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
3059
2364
  const config = generatorOptions?.config ?? (normalizedSourceOptions ? resolveUniqueTailwindV4CssConfig(normalizedSourceOptions) : void 0);
3060
- const css = createTailwindV4ApplyReferenceSource(normalizeConfigDirective(prependConfigDirective(applyEntrySource.css, config), void 0), normalizedSourceOptions ?? {});
2365
+ const css = createTailwindV4ApplyReferenceSource(normalizeConfigDirective$1(prependConfigDirective(applyEntrySource.css, config), void 0), normalizedSourceOptions ?? {});
3061
2366
  return resolveTailwindV4Source$1(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
3062
2367
  base: applyEntrySource.base,
3063
2368
  css
@@ -3101,17 +2406,17 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
3101
2406
  sourceFile: resolvedEntrySource.file ?? resolvedSourceOptions?.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions)
3102
2407
  }));
3103
2408
  const sourceBase = resolvedEntrySource === cssEntrySource && config ? path.dirname(config) : resolvedEntrySource.base;
3104
- const css = createTailwindV4SourceReferenceSource(normalizeConfigDirective(prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), normalizedSourceOptions ?? {});
2409
+ const css = createTailwindV4SourceReferenceSource$1(normalizeConfigDirective$1(prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), normalizedSourceOptions ?? {});
3105
2410
  return resolveTailwindV4Source$1(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
3106
2411
  base: sourceBase,
3107
2412
  css
3108
2413
  }));
3109
2414
  }
3110
2415
  //#endregion
3111
- //#region src/bundlers/shared/generator-css/source-resolver/resolve-sources.ts
2416
+ //#region src/generation/source-resolver/resolve-sources.ts
3112
2417
  async function resolveGeneratorResolvedSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
3113
2418
  const base = resolveCssSourceBase(file, cssHandlerOptions);
3114
- const cssEntrySource = resolveCssEntrySource(rawSource, base, {
2419
+ const cssEntrySource = resolveCssEntrySource$1(rawSource, base, {
3115
2420
  importFallback: generatorOptions?.importFallback ?? false,
3116
2421
  removeConfig: false
3117
2422
  });
@@ -3175,7 +2480,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
3175
2480
  return (await resolveGeneratorResolvedSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions)).map(createGeneratorSourceRecord);
3176
2481
  }
3177
2482
  //#endregion
3178
- //#region src/bundlers/shared/generator-css/source-resolver/source-entries.ts
2483
+ //#region src/generation/source-resolver/source-entries.ts
3179
2484
  async function resolveGeneratorSourceEntries(record, runtimeState) {
3180
2485
  const { metadata: sourceMetadata, source } = record;
3181
2486
  if (sourceMetadata?.sourceEntries) return sourceMetadata.sourceEntries;
@@ -3203,7 +2508,7 @@ async function resolveGeneratorSourceEntries(record, runtimeState) {
3203
2508
  return resolved?.entries;
3204
2509
  }
3205
2510
  //#endregion
3206
- //#region src/bundlers/shared/generator-css/legacy-compat.ts
2511
+ //#region src/generation/legacy-compat.ts
3207
2512
  const LEGACY_CONTAINER_COMPAT_CSS = [
3208
2513
  ".container {",
3209
2514
  " width: 100%;",
@@ -3256,94 +2561,20 @@ function createStableJson(value) {
3256
2561
  function createLegacyCompatTransformCacheKey(source, options) {
3257
2562
  return `${createStableJson(options)}\0${source}`;
3258
2563
  }
3259
- function countUnclosedBlocks(source) {
3260
- let depth = 0;
3261
- let quote;
3262
- let inComment = false;
3263
- let escaped = false;
3264
- for (let index = 0; index < source.length; index += 1) {
3265
- const char = source[index];
3266
- const next = source[index + 1];
3267
- if (inComment) {
3268
- if (char === "*" && next === "/") {
3269
- inComment = false;
3270
- index += 1;
3271
- }
3272
- continue;
3273
- }
3274
- if (quote) {
3275
- if (escaped) {
3276
- escaped = false;
3277
- continue;
3278
- }
3279
- if (char === "\\") {
3280
- escaped = true;
3281
- continue;
3282
- }
3283
- if (char === quote) quote = void 0;
3284
- continue;
3285
- }
3286
- if (char === "/" && next === "*") {
3287
- inComment = true;
3288
- index += 1;
3289
- continue;
3290
- }
3291
- if (char === "\"" || char === "'") {
3292
- quote = char;
3293
- continue;
3294
- }
3295
- if (char === "{") depth += 1;
3296
- else if (char === "}" && depth > 0) depth -= 1;
3297
- }
3298
- return depth;
3299
- }
3300
- function closeTrailingUnclosedBlocks(source) {
3301
- try {
3302
- postcss.parse(source);
3303
- return source;
3304
- } catch (error) {
3305
- if (error.reason !== "Unclosed block") return source;
3306
- const unclosedBlocks = countUnclosedBlocks(source);
3307
- return unclosedBlocks > 0 ? `${source}${"}".repeat(unclosedBlocks)}` : source;
3308
- }
3309
- }
3310
2564
  function resolveLegacyCompatCssSource(rawSource) {
3311
2565
  const cached = legacyCompatSourceCache.get(rawSource);
3312
2566
  if (cached !== void 0) return cached;
3313
- const parseableSource = closeTrailingUnclosedBlocks(stripTailwindBanners(rawSource));
3314
- const source = removeTailwindSourceDirectives(parseableSource);
3315
- const resolved = closeTrailingUnclosedBlocks(removeTailwindV4GeneratedUserCssArtifacts(removeUnsupportedMiniProgramAtRules(removeTailwindApplyRules(source))));
2567
+ const resolved = normalizeLegacyCompatCssSource(rawSource);
3316
2568
  setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
3317
2569
  return resolved;
3318
2570
  }
3319
- function removeMiniProgramContainerCompatCss(css) {
3320
- try {
3321
- const root = postcss.parse(css);
3322
- let removed = false;
3323
- root.walkRules((rule) => {
3324
- if (rule.selectors?.length === 1 && rule.selectors[0] === ".container") {
3325
- rule.remove();
3326
- removed = true;
3327
- }
3328
- });
3329
- root.walkAtRules((atRule) => {
3330
- if (atRule.nodes && atRule.nodes.length === 0) {
3331
- atRule.remove();
3332
- removed = true;
3333
- }
3334
- });
3335
- return removed ? root.toString() : css;
3336
- } catch {
3337
- return css;
3338
- }
3339
- }
3340
2571
  function hasContainerConfigToken(rawSource) {
3341
2572
  return rawSource.includes("@config") && /\bcontainer\b/.test(rawSource);
3342
2573
  }
3343
2574
  function hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) {
3344
2575
  if (hasContainerConfigToken(rawSource)) return true;
3345
2576
  const base = resolveCssSourceBase(file, cssHandlerOptions);
3346
- const cssEntrySource = resolveCssEntrySource(rawSource, base);
2577
+ const cssEntrySource = resolveCssEntrySource$1(rawSource, base);
3347
2578
  if (!cssEntrySource?.config) return false;
3348
2579
  try {
3349
2580
  return /\bcontainer\b/.test(readFileSync(cssEntrySource.config, "utf8"));
@@ -3354,7 +2585,7 @@ function hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) {
3354
2585
  function hasConfiguredContainerCompatSource(source) {
3355
2586
  if (typeof source.css !== "string") return false;
3356
2587
  if (hasContainerConfigToken(source.css)) return true;
3357
- const cssEntrySource = resolveCssEntrySource(source.css, source.base);
2588
+ const cssEntrySource = resolveCssEntrySource$1(source.css, source.base);
3358
2589
  if (cssEntrySource?.config) try {
3359
2590
  if (/\bcontainer\b/.test(readFileSync(cssEntrySource.config, "utf8"))) return true;
3360
2591
  } catch {}
@@ -3408,95 +2639,7 @@ async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, con
3408
2639
  return createCssAppend(css, cleanedCompatCss);
3409
2640
  }
3410
2641
  //#endregion
3411
- //#region src/bundlers/shared/generator-css/output-import-shell.ts
3412
- const MINI_PROGRAM_OUTPUT_IMPORT_RE = /(@import\s+(?:url\(\s*)?)(["'])([^"']+\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:[?#][^"']*)?)\2([^;]*;)/gi;
3413
- const MINI_PROGRAM_OUTPUT_STYLE_RE = /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
3414
- function normalizeMiniProgramOutputImportRequest(request) {
3415
- if (request.startsWith(".") || request.startsWith("/") || /^(?:[a-z][a-z\d+.-]*:|#)/i.test(request)) return request;
3416
- return `./${request}`;
3417
- }
3418
- function normalizeMiniProgramImportShell(css, output) {
3419
- const normalized = output?.cssOnly ? css : css.replace(MINI_PROGRAM_OUTPUT_IMPORT_RE, (_match, prefix, quote, request, suffix) => {
3420
- return `${prefix}${quote}${normalizeMiniProgramOutputImportRequest(request)}${quote}${suffix}`;
3421
- });
3422
- if (!output || !normalized.includes("@import")) return normalized;
3423
- const files = new Set([...output.outputFiles].map(normalizeOutputPath));
3424
- const root = postcss.parse(normalized);
3425
- root.walkAtRules("import", (rule) => {
3426
- const parsed = parseCssImportSpecifier(rule.params);
3427
- if (!parsed || output.cssOnly && !/\.css(?:$|[?#])/i.test(parsed.specifier) || !files.has(resolveOutputImportRequest(output.outputFile, parsed.specifier))) return;
3428
- const request = normalizeMiniProgramOutputImportRequest(parsed.specifier);
3429
- if (request !== parsed.specifier) rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(request, parsed.quote));
3430
- });
3431
- return root.toString();
3432
- }
3433
- function normalizeOutputPath(file) {
3434
- const segments = [];
3435
- for (const segment of file.replace(/\\/g, "/").replace(/^\/+/, "").split("/")) {
3436
- if (!segment || segment === ".") continue;
3437
- if (segment === "..") {
3438
- if (segments.length > 0 && segments[segments.length - 1] !== "..") segments.pop();
3439
- else segments.push(segment);
3440
- continue;
3441
- }
3442
- segments.push(segment);
3443
- }
3444
- return segments.join("/");
3445
- }
3446
- function splitRequestSuffix(request) {
3447
- const suffixIndexCandidates = [request.indexOf("?"), request.indexOf("#")].filter((index) => index >= 0);
3448
- const suffixIndex = suffixIndexCandidates.length > 0 ? Math.min(...suffixIndexCandidates) : -1;
3449
- return suffixIndex < 0 ? request : request.slice(0, suffixIndex);
3450
- }
3451
- function resolveOutputImportRequest(file, request) {
3452
- const cleanRequest = splitRequestSuffix(request.replace(/\\/g, "/"));
3453
- if (cleanRequest.startsWith("/")) return normalizeOutputPath(cleanRequest);
3454
- const normalizedFile = normalizeOutputPath(file);
3455
- const baseDir = normalizedFile.includes("/") ? normalizedFile.slice(0, normalizedFile.lastIndexOf("/")) : "";
3456
- return normalizeOutputPath(baseDir ? `${baseDir}/${cleanRequest}` : cleanRequest);
3457
- }
3458
- function isMiniProgramOutputImport(node) {
3459
- if (node.type !== "atrule" || node.name !== "import") return false;
3460
- const request = parseImportRequest(node.params);
3461
- return request !== void 0 && MINI_PROGRAM_OUTPUT_STYLE_RE.test(request);
3462
- }
3463
- function isSelfMiniProgramOutputImport(outputFile, node) {
3464
- if (node.type !== "atrule" || node.name !== "import") return false;
3465
- const request = parseCssImportSpecifier(node.params)?.specifier;
3466
- return request !== void 0 && /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(request) && resolveOutputImportRequest(outputFile, request) === normalizeOutputPath(outputFile);
3467
- }
3468
- function removeMiniProgramOutputImportsBy(css, predicate) {
3469
- if (!css.includes("@import")) return css;
3470
- try {
3471
- const root = postcss.parse(css);
3472
- let changed = false;
3473
- root.walk((node) => {
3474
- if (predicate(node)) {
3475
- node.remove();
3476
- changed = true;
3477
- }
3478
- });
3479
- return changed ? root.toString() : css;
3480
- } catch {
3481
- return css;
3482
- }
3483
- }
3484
- function removeSelfMiniProgramOutputImports(css, outputFile) {
3485
- return removeMiniProgramOutputImportsBy(css, (node) => isSelfMiniProgramOutputImport(outputFile, node));
3486
- }
3487
- function removeMiniProgramOutputImports(css) {
3488
- return removeMiniProgramOutputImportsBy(css, isMiniProgramOutputImport);
3489
- }
3490
- function normalizeMiniProgramGeneratorCssSource(css, outputFile, outputFiles) {
3491
- const normalized = normalizeMiniProgramImportShell(css, outputFile && outputFiles ? {
3492
- outputFile,
3493
- outputFiles
3494
- } : void 0);
3495
- if (outputFile) return removeSelfMiniProgramOutputImports(normalized, outputFile);
3496
- return isPureLocalCssImportWrapper(normalized) ? normalized : removeMiniProgramOutputImports(normalized);
3497
- }
3498
- //#endregion
3499
- //#region src/bundlers/shared/run-tasks.ts
2642
+ //#region src/utils/run-tasks.ts
3500
2643
  async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
3501
2644
  if (factories.length === 0) return [];
3502
2645
  const results = Array.from({ length: factories.length });
@@ -3533,25 +2676,10 @@ function pushConcurrentTaskFactories(queue, factories, limit) {
3533
2676
  queue.push(runWithConcurrency(factories, limit).then(() => void 0));
3534
2677
  }
3535
2678
  //#endregion
3536
- //#region src/bundlers/shared/generator-css/user-css/compile-functions.ts
3537
- const AUTHOR_THEME_FUNCTION_RE = /(?:^|[^-\w])(?:theme|--theme)\(/;
3538
- const AUTHOR_SPACING_FUNCTION_RE = /(?:--spacing|--alpha)\(/;
3539
- const GENERATED_AUTHOR_FUNCTION_SKIP_MAX_LENGTH = 8192;
3540
- /**
3541
- * 判断这段 CSS 是否还需要走作者函数编译。
3542
- *
3543
- * `theme()` / `--theme()` 一定要编译。`--spacing()` / `--alpha()` 只在短小的作者 CSS 里保留;
3544
- * 大段或带生成标记的样式里它们通常已是 Tailwind 工具输出,再 parse 会拖垮 generateBundle。
3545
- */
3546
- function shouldCompileAuthorCssFunctions(css) {
3547
- if (AUTHOR_THEME_FUNCTION_RE.test(css)) return true;
3548
- if (!AUTHOR_SPACING_FUNCTION_RE.test(css)) return false;
3549
- return css.length <= GENERATED_AUTHOR_FUNCTION_SKIP_MAX_LENGTH && !css.includes("weapp-tailwindcss") && !css.includes("tailwindcss v4");
3550
- }
2679
+ //#region src/generation/user-css/compile-functions.ts
3551
2680
  function createAuthorCssFunctionCompiler(sources, session) {
3552
2681
  const cache = /* @__PURE__ */ new Map();
3553
2682
  return (css) => {
3554
- if (!shouldCompileAuthorCssFunctions(css)) return Promise.resolve(css);
3555
2683
  return compileTailwindAuthorFunctions(css, async (values) => {
3556
2684
  const missing = [...new Set(values.filter((value) => !cache.has(value)))];
3557
2685
  if (missing.length > 0) {
@@ -3581,19 +2709,7 @@ function createAuthorCssFunctionCompiler(sources, session) {
3581
2709
  };
3582
2710
  }
3583
2711
  //#endregion
3584
- //#region src/bundlers/shared/generator-css/class-selectors.ts
3585
- function normalizeCssClassSelector(value) {
3586
- return value.replace(/\\([^\da-f\r\n])/gi, "$1").replace(/\\([\da-f]{1,6})\s?/gi, (_, code) => String.fromCodePoint(Number.parseInt(code, 16)));
3587
- }
3588
- function collectRawSourceClassSelectors(rawSource) {
3589
- const selectors = /* @__PURE__ */ new Set();
3590
- try {
3591
- postcss.parse(rawSource).walkRules((rule) => {
3592
- for (const selector of rule.selectors ?? [rule.selector]) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) if (match[1]) selectors.add(normalizeCssClassSelector(match[1]));
3593
- });
3594
- } catch {}
3595
- return selectors;
3596
- }
2712
+ //#region src/generation/class-selectors.ts
3597
2713
  function collectGeneratedRawSourceCandidates(candidates, rawSource, escapeMap) {
3598
2714
  const selectors = collectRawSourceClassSelectors(rawSource);
3599
2715
  if (selectors.size === 0) return /* @__PURE__ */ new Set();
@@ -3610,27 +2726,7 @@ function collectGeneratedRawSourceCandidatesFromCss(candidates, cssSources, esca
3610
2726
  return matched;
3611
2727
  }
3612
2728
  //#endregion
3613
- //#region src/bundlers/shared/generator-css/result-helpers.ts
3614
- function collectCssRuleIdentityMarkers(source) {
3615
- const markers = /* @__PURE__ */ new Set();
3616
- try {
3617
- const root = postcss.parse(source);
3618
- root.walkRules((rule) => {
3619
- 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]}`);
3620
- });
3621
- root.walkAtRules("keyframes", (rule) => {
3622
- if (rule.params) markers.add(`keyframes:${rule.params}`);
3623
- });
3624
- } catch {}
3625
- return markers;
3626
- }
3627
- function isCssAlreadyRepresentedByMarkers(css, source) {
3628
- const sourceMarkers = collectCssRuleIdentityMarkers(source);
3629
- if (sourceMarkers.size === 0) return false;
3630
- const cssMarkers = collectCssRuleIdentityMarkers(css);
3631
- for (const marker of sourceMarkers) if (!cssMarkers.has(marker)) return false;
3632
- return true;
3633
- }
2729
+ //#region src/generation/result-helpers.ts
3634
2730
  function mergeGeneratedCssClassSet(classSet, candidates, css, escapeMap) {
3635
2731
  const merged = new Set(classSet);
3636
2732
  for (const candidate of collectGeneratedRawSourceCandidates(candidates, css, escapeMap)) merged.add(candidate);
@@ -3649,7 +2745,7 @@ function finalizeIncrementalGeneratorCss(previousCss, incrementalCss, target, ma
3649
2745
  return createCssAppend(previousCss, finalizedIncrementalCss);
3650
2746
  }
3651
2747
  //#endregion
3652
- //#region src/bundlers/shared/generator-css/pipeline/deferred-output.ts
2748
+ //#region src/generation/pipeline/deferred-output.ts
3653
2749
  async function finalizeDeferredGeneratorCss(context) {
3654
2750
  const { cssUserHandlerOptions, file, filterGeneratedApplyOnlyCss, generated, generatedUserCssRawSource, generatorOptions, generatorRawSource, generatorStyleOptions, hasMatchedCssSourceFile, localImports, majorVersion, options, opts, preflightMode, runtimeWithCurrentCss, styleHandler, userCssOrderSource, userRawSourceProcessed } = context;
3655
2751
  if (options.deferCssAdaptation) {
@@ -3684,8 +2780,10 @@ async function finalizeDeferredGeneratorCss(context) {
3684
2780
  if (orderedUserCss) {
3685
2781
  const beforeUserCss = await transformDeferredUserCss(orderedUserCss.before);
3686
2782
  const afterUserCss = await transformDeferredUserCss(orderedUserCss.after);
3687
- const cssWithBeforeUserCss = createCssSourceOrderAppend(filterExistingCssRules(css, beforeUserCss), css);
3688
- return reorderMarkedUserLayerComponentsCss(createCssSourceOrderAppend(cssWithBeforeUserCss, filterExistingCssRules(cssWithBeforeUserCss, afterUserCss)));
2783
+ const missingBeforeUserCss = filterExistingCssRules(css, beforeUserCss);
2784
+ const cssWithBeforeUserCss = createCssSourceOrderAppend(missingBeforeUserCss, css);
2785
+ const missingAfterUserCss = filterExistingCssRules(cssWithBeforeUserCss, afterUserCss);
2786
+ return reorderMarkedUserLayerComponentsCss(createCssSourceOrderAppend(cssWithBeforeUserCss, missingAfterUserCss));
3689
2787
  }
3690
2788
  const userCss = await transformDeferredUserCss(generatedUserCssRawSource);
3691
2789
  return reorderMarkedUserLayerComponentsCss(createCssSourceOrderAppend(css, filterExistingCssRules(css, userCss)));
@@ -3714,23 +2812,26 @@ async function finalizeDeferredGeneratorCss(context) {
3714
2812
  }
3715
2813
  }
3716
2814
  //#endregion
3717
- //#region src/bundlers/shared/generator-css/pipeline/fallback-output.ts
2815
+ //#region src/generation/pipeline/fallback-output.ts
3718
2816
  async function finalizeFallbackGeneratorCss(context) {
3719
2817
  const { configuredContainerCompat, cssHandlerOptions, cssUserHandlerOptions, debug, file, finalizeGeneratorCss, generated, generatedCss, generatedUserCssRawSource, generatorOptions, generatorRawSource, generatorStyleOptions, hasDistinctUserRawSource, hasGeneratedCss, hasGeneratedMarkers, hasMatchedCssSourceFile, hasSourceDirectives, hasWebUserCssFallbackSource, isolateCurrentCssCandidates, legacyCompatUserCssRawSource, majorVersion, options, opts, preflightMode, prepareFinalGeneratorCss, runtime, runtimeWithCurrentCss, shouldFilterApplyOnlyCss, shouldPreserveLegacyCompatSelectorOverrides, styleHandler, userCssRawSource, userRawSourceProcessed } = context;
3720
2818
  debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
3721
2819
  let css = generatedCss;
3722
2820
  const distinctUserLayerParts = hasDistinctUserRawSource && hasUserCssLayerBlocks(generatedUserCssRawSource) ? splitUserCssLayerBlocks(generatedUserCssRawSource) : void 0;
3723
2821
  let restoredDistinctUserLayerCss = false;
3724
- if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend(await transformGeneratorUserCss(generatedUserCssRawSource, {
3725
- generatorTarget: generated.target,
3726
- compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3727
- generatedSource: generated.rawCss,
3728
- generatorStyleOptions,
3729
- cssUserHandlerOptions,
3730
- styleHandler,
3731
- importFallback: generatorOptions.importFallback,
3732
- processed: userRawSourceProcessed
3733
- }), css);
2822
+ if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !hasUserCssLayerBlocks(generatorRawSource)) {
2823
+ const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
2824
+ generatorTarget: generated.target,
2825
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
2826
+ generatedSource: generated.rawCss,
2827
+ generatorStyleOptions,
2828
+ cssUserHandlerOptions,
2829
+ styleHandler,
2830
+ importFallback: generatorOptions.importFallback,
2831
+ processed: userRawSourceProcessed
2832
+ });
2833
+ css = createCssSourceOrderAppend(userCss, css);
2834
+ }
3734
2835
  if (generated.target === "weapp") {
3735
2836
  css = inheritLegacyUnitConvertedDeclarations(css, generatorRawSource);
3736
2837
  if (hasUserCssLayerBlocks(generatorRawSource)) {
@@ -3898,7 +2999,7 @@ async function finalizeFallbackGeneratorCss(context) {
3898
2999
  };
3899
3000
  }
3900
3001
  //#endregion
3901
- //#region src/bundlers/shared/generator-css/pipeline/ordered-output.ts
3002
+ //#region src/generation/pipeline/ordered-output.ts
3902
3003
  async function finalizeOrderedGeneratorCss(context) {
3903
3004
  const { configuredContainerCompat, cssHandlerOptions, cssUserHandlerOptions, file, filterGeneratedApplyOnlyCss, finalizeGeneratorCss, generated, generatedUserCssRawSource, generatorOptions, generatorRawSource, generatorStyleOptions, hasDistinctUserRawSource, hasGeneratedCss, hasGeneratedMarkers, hasMatchedCssSourceFile, hasSourceDirectives, hasWebUserCssFallbackSource, isolateCurrentCssCandidates, legacyCompatUserCssRawSource, localImports, majorVersion, options, opts, preflightMode, prepareFinalGeneratorCss, runtime, runtimeWithCurrentCss, shouldFilterApplyOnlyCss, shouldPreserveLegacyCompatSelectorOverrides, styleHandler, userCssOrderSource, userCssRawSource, userRawSourceProcessed } = context;
3904
3005
  if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
@@ -3947,7 +3048,8 @@ async function finalizeOrderedGeneratorCss(context) {
3947
3048
  const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
3948
3049
  const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
3949
3050
  const fallbackLayerUserCss = generated.target === "weapp" && hasUserCssLayerBlocks(userCssRawSource) ? filterExistingCssRules(afterLayerUserCss, await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions)) : "";
3950
- css = createCssSourceOrderAppend(createCssSourceOrderAppend(createCssSourceOrderAppend(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(createCssSourceOrderAppend(afterLayerUserCss, fallbackLayerUserCss)) : afterLayerUserCss), css), afterUserCss);
3051
+ const orderedAfterLayerUserCss = generated.target === "weapp" ? wrapUserLayerComponentsCss(createCssSourceOrderAppend(afterLayerUserCss, fallbackLayerUserCss)) : afterLayerUserCss;
3052
+ css = createCssSourceOrderAppend(createCssSourceOrderAppend(createCssSourceOrderAppend(beforeUserCss, orderedAfterLayerUserCss), css), afterUserCss);
3951
3053
  if (hasWebUserCssFallbackSource && isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
3952
3054
  hasSourceDirectives,
3953
3055
  hasMatchedCssSourceFile
@@ -3996,7 +3098,7 @@ async function finalizeOrderedGeneratorCss(context) {
3996
3098
  }
3997
3099
  }
3998
3100
  //#endregion
3999
- //#region src/bundlers/shared/generator-css/pipeline/execution.ts
3101
+ //#region src/generation/pipeline/preparation.ts
4000
3102
  function resolveGeneratorSourceConcurrency() {
4001
3103
  const configured = Number.parseInt(process.env["WEAPP_TW_GENERATOR_SOURCE_CONCURRENCY"] ?? "", 10);
4002
3104
  return Number.isFinite(configured) && configured > 0 ? configured : 1;
@@ -4017,13 +3119,8 @@ function resolveCompilationDependencies(dependencies) {
4017
3119
  kind: isSourceStyleRequest(id) ? "css" : "config"
4018
3120
  }));
4019
3121
  }
4020
- async function executeGeneratorPipeline(context) {
4021
- return runCompilerOwnerActivity(context.runtimeState, () => executeGeneratorPipelineWithOwner(context, getCompilationSessionPool(context.runtimeState), getTailwindGenerationSessionPool(context.runtimeState)));
4022
- }
4023
- async function executeGeneratorPipelineWithOwner(context, compilationPool, generationSession) {
3122
+ async function prepareGeneratorInputs(context) {
4024
3123
  const { cssHandlerOptions, debug, file, generatorBranch, generatorOptions, generatorRawSource, getSourceCandidatesForEntries, hasGeneratedCss, hasGeneratedMarkers, localImports, majorVersion, normalizeGeneratorSource, normalizedCssSources, options, opts, runtime, runtimeState, useMiniProgramCssBranch } = context;
4025
- await runtimeState.readyPromise;
4026
- const compilerSession = options.compilation?.enabled ? getFrameworkCompilerSession(runtimeState, opts) : void 0;
4027
3124
  const currentCssCandidates = collectGeneratorCssCandidates(generatorRawSource);
4028
3125
  const isolateCurrentCssCandidates = shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, {
4029
3126
  hasGeneratedCss,
@@ -4044,46 +3141,65 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4044
3141
  const generatorStyleOptions = resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorOptions.styleOptions);
4045
3142
  const configuredContainerCompat = hasConfiguredContainerCompatSources(generatorSourceRecords.map((record) => record.source));
4046
3143
  const sourceConcurrency = resolveGeneratorSourceConcurrency();
4047
- const preparedGenerationInputs = (await runWithConcurrency(generatorSourceRecords.map((record, index) => async () => {
4048
- const { metadata: sourceMetadata, source } = record;
4049
- const sourceCss = options.deferCssAdaptation ? removeMatchingLocalCssImports(source.css, localImports) : source.css;
4050
- const generatorSource = options.disableSourceScan === true ? {
4051
- ...source,
4052
- css: removeTailwindSourceDirectives(sourceCss, {
4053
- importFallback: generatorOptions.importFallback,
4054
- preserveApplyContext: true
4055
- })
4056
- } : sourceCss === source.css ? source : {
4057
- ...source,
4058
- css: sourceCss
4059
- };
4060
- const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(record, runtimeState) : void 0;
4061
- const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
4062
- const scopedRuntime = resolveScopedRuntimeCandidates(options.sourceCandidates, sourceScopedRuntime);
4063
- const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, record, sourceEntries, {
4064
- cssHandlerOptions,
4065
- target: generatorOptions.target
4066
- });
4067
- const matchedCssSourceFile = Boolean(sourceMetadata?.matchedCssSourceFile);
4068
- if (options.deferEmptyScopedCssSource && isolateCssSource && scopedRuntime?.size === 0 && currentCssCandidates.length === 0 && !cssHandlerOptions.isMainChunk) {
4069
- debug("defer empty scoped css source generation: %s", file);
4070
- return;
4071
- }
4072
- const sourceRuntime = scopedRuntime && (scopedRuntime.size > 0 || isolateCssSource) || isolateCssSource ? isolateCurrentCssCandidates ? runtimeWithCurrentCss : mergeScopedRuntimeWithCurrentRuntime(scopedRuntime ?? /* @__PURE__ */ new Set(), runtimeWithCurrentCss, {
4073
- currentCssCandidates,
4074
- cssHandlerOptions,
4075
- isolateCssSource,
4076
- majorVersion,
4077
- matchedCssSourceFile
4078
- }) : runtimeWithCurrentCss;
4079
- return {
4080
- generatorRuntime: shouldUseMiniProgramCssBranch(generatorBranch) ? filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime,
4081
- generatorSource,
4082
- dependencies: resolveCompilationDependencies(record.source.dependencies),
4083
- isolateCssSource,
4084
- sourceId: resolveCompilationSourceId(record, index)
4085
- };
4086
- }), sourceConcurrency)).filter((item) => Boolean(item));
3144
+ return {
3145
+ isolateCurrentCssCandidates,
3146
+ runtimeWithCurrentCss,
3147
+ generatorSourceRecords,
3148
+ generatorStyleOptions,
3149
+ configuredContainerCompat,
3150
+ sourceConcurrency,
3151
+ preparedGenerationInputs: (await runWithConcurrency(generatorSourceRecords.map((record, index) => async () => {
3152
+ const { metadata: sourceMetadata, source } = record;
3153
+ const sourceCss = options.deferCssAdaptation ? removeMatchingLocalCssImports(source.css, localImports) : source.css;
3154
+ const generatorSource = options.disableSourceScan === true ? {
3155
+ ...source,
3156
+ css: removeTailwindSourceDirectives(sourceCss, {
3157
+ importFallback: generatorOptions.importFallback,
3158
+ preserveApplyContext: true
3159
+ })
3160
+ } : sourceCss === source.css ? source : {
3161
+ ...source,
3162
+ css: sourceCss
3163
+ };
3164
+ const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(record, runtimeState) : void 0;
3165
+ const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
3166
+ const scopedRuntime = resolveScopedRuntimeCandidates(options.sourceCandidates, sourceScopedRuntime);
3167
+ const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, record, sourceEntries, {
3168
+ cssHandlerOptions,
3169
+ target: generatorOptions.target
3170
+ });
3171
+ const matchedCssSourceFile = Boolean(sourceMetadata?.matchedCssSourceFile);
3172
+ if (options.deferEmptyScopedCssSource && isolateCssSource && scopedRuntime?.size === 0 && currentCssCandidates.length === 0 && !cssHandlerOptions.isMainChunk) {
3173
+ debug("defer empty scoped css source generation: %s", file);
3174
+ return;
3175
+ }
3176
+ const sourceRuntime = scopedRuntime && (scopedRuntime.size > 0 || isolateCssSource) || isolateCssSource ? isolateCurrentCssCandidates ? runtimeWithCurrentCss : mergeScopedRuntimeWithCurrentRuntime(scopedRuntime ?? /* @__PURE__ */ new Set(), runtimeWithCurrentCss, {
3177
+ currentCssCandidates,
3178
+ cssHandlerOptions,
3179
+ isolateCssSource,
3180
+ majorVersion,
3181
+ matchedCssSourceFile
3182
+ }) : runtimeWithCurrentCss;
3183
+ return {
3184
+ generatorRuntime: shouldUseMiniProgramCssBranch(generatorBranch) ? filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime,
3185
+ generatorSource,
3186
+ dependencies: resolveCompilationDependencies(record.source.dependencies),
3187
+ isolateCssSource,
3188
+ sourceId: resolveCompilationSourceId(record, index)
3189
+ };
3190
+ }), sourceConcurrency)).filter((item) => Boolean(item))
3191
+ };
3192
+ }
3193
+ //#endregion
3194
+ //#region src/generation/pipeline/execution.ts
3195
+ async function executeGeneratorPipeline(context) {
3196
+ return runCompilerOwnerActivity(context.runtimeState, () => executeGeneratorPipelineWithOwner(context, getCompilationSessionPool(context.runtimeState), getTailwindGenerationSessionPool(context.runtimeState)));
3197
+ }
3198
+ async function executeGeneratorPipelineWithOwner(context, compilationPool, generationSession) {
3199
+ const { cssHandlerOptions, debug, file, generatorOptions, generatorRawSource, hasGeneratedCss, hasGeneratedMarkers, localImports, majorVersion, options, opts, runtimeState } = context;
3200
+ await runtimeState.readyPromise;
3201
+ const compilerSession = options.compilation?.enabled ? getFrameworkCompilerSession(runtimeState, opts) : void 0;
3202
+ const { isolateCurrentCssCandidates, runtimeWithCurrentCss, generatorSourceRecords, generatorStyleOptions, configuredContainerCompat, sourceConcurrency, preparedGenerationInputs } = await prepareGeneratorInputs(context);
4087
3203
  const generatePreparedInputs = async (candidateSets) => {
4088
3204
  return runWithConcurrency(preparedGenerationInputs.map((input) => async () => {
4089
3205
  const projectedCandidates = candidateSets?.get(input.sourceId);
@@ -4205,6 +3321,7 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4205
3321
  shouldFilterApplyOnlyCss
4206
3322
  };
4207
3323
  const withCompilationMetadata = (result) => {
3324
+ if (result && shouldCheckRpxThemeRisk(runtimeState, generated.target, opts, options.generatorPlatform)) result.rpxThemeVariables = [.../* @__PURE__ */ new Set([...preparedGenerationInputs.flatMap((input) => input.generatorSource.rpxThemeVariables ?? []), ...collectRpxThemeRiskSources([generatorRawSource, ...preparedGenerationInputs.map((input) => input.generatorSource.css)])])];
4208
3325
  if (result && frameworkProcessedUserCss !== void 0) result = {
4209
3326
  ...result,
4210
3327
  compileAuthorCssFunctions,
@@ -4221,11 +3338,10 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4221
3338
  }
4222
3339
  };
4223
3340
  };
4224
- if (options.deferCssAdaptation) return withCompilationMetadata(await finalizeDeferredGeneratorCss(outputContext));
4225
- return withCompilationMetadata(await finalizeOrderedGeneratorCss(outputContext) ?? await finalizeFallbackGeneratorCss(outputContext));
3341
+ return withCompilationMetadata(options.deferCssAdaptation ? await finalizeDeferredGeneratorCss(outputContext) : await finalizeOrderedGeneratorCss(outputContext) ?? await finalizeFallbackGeneratorCss(outputContext));
4226
3342
  }
4227
3343
  //#endregion
4228
- //#region src/bundlers/shared/generator-css/pipeline.ts
3344
+ //#region src/generation/pipeline.ts
4229
3345
  function hasPostcssUserPlugins(options) {
4230
3346
  const plugins = options.postcssOptions?.plugins;
4231
3347
  if (Array.isArray(plugins)) return plugins.length > 0;
@@ -4302,7 +3418,7 @@ async function generateCssByGenerator(options) {
4302
3418
  }
4303
3419
  return;
4304
3420
  }
4305
- const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeEmptyTailwindCustomVariants(normalizeGeneratorCssSource(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })))));
3421
+ const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeEmptyTailwindCustomVariants$1(normalizeGeneratorCssSource(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })))));
4306
3422
  const effectiveRawSourceRoot = parseCssSourceRoot(effectiveRawSource);
4307
3423
  const cleanedLocalImportWrapper = cleanLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
4308
3424
  if (cleanedLocalImportWrapper !== void 0) return {
@@ -4323,7 +3439,7 @@ async function generateCssByGenerator(options) {
4323
3439
  return finalizeWebGeneratorCss(restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports, { outputFile: file }), target, generatorOptions.webCompat);
4324
3440
  };
4325
3441
  const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
4326
- const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeEmptyTailwindCustomVariants(normalizeGeneratorCssSource(normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })))));
3442
+ const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeEmptyTailwindCustomVariants$1(normalizeGeneratorCssSource(normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })))));
4327
3443
  const userSource = (rawUserSource === generatorRawSource ? void 0 : splitLocalCssImports(rawUserSource))?.source ?? rawUserSource;
4328
3444
  const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
4329
3445
  const hasWebUserCssFallbackSource = userCssRawSource.trim().length > 0 && !isCommentOnlyCss(userCssRawSource);
@@ -4339,7 +3455,7 @@ async function generateCssByGenerator(options) {
4339
3455
  const hasSourceDirectives = hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
4340
3456
  const hasGeneratedMarkers = hasTailwindGeneratedCssMarkers(generatorRawSource);
4341
3457
  const normalizedCssSources = options.cssSources?.map((source) => {
4342
- const css = normalizeGeneratorCssSource(normalizeEmptyTailwindCustomVariants(source.css));
3458
+ const css = normalizeGeneratorCssSource(normalizeEmptyTailwindCustomVariants$1(source.css));
4343
3459
  return css === source.css ? source : {
4344
3460
  ...source,
4345
3461
  css
@@ -4395,7 +3511,7 @@ async function generateCssByGenerator(options) {
4395
3511
  }
4396
3512
  }
4397
3513
  //#endregion
4398
- //#region src/bundlers/shared/generator-css/validate.ts
3514
+ //#region src/generation/validate.ts
4399
3515
  async function validateCandidatesByGenerator(options) {
4400
3516
  return runCompilerOwnerActivity(options.runtimeState, () => validateCandidatesByGeneratorWithOwner(options, getTailwindGenerationSessionPool(options.runtimeState)));
4401
3517
  }
@@ -4427,7 +3543,7 @@ async function validateCandidatesByGeneratorWithOwner(options, generationSession
4427
3543
  return classSet;
4428
3544
  }
4429
3545
  //#endregion
4430
- //#region src/bundlers/shared/v4-generation-core.ts
3546
+ //#region src/generation/service.ts
4431
3547
  function resolveGenerationOptions(options, mode) {
4432
3548
  const physicalFile = stripRequestQuery(options.file);
4433
3549
  const normalizedOptions = physicalFile === options.file ? options : {
@@ -4521,6 +3637,7 @@ async function generateTailwindV4CssWithImplementation(options, implementation)
4521
3637
  const composedCss = shouldReplayFrameworkPostcss && options.frameworkProcessedUserCss ? await restoreFrameworkProcessedUserCss(adaptedCss, generated, generated.frameworkProcessedUserCss ?? options.frameworkProcessedUserCss, options, normalizedGeneratorOptions) : adaptedCss;
4522
3638
  const css = isVueScopedStyleRequest(resolvePostcssRequestOption(options.cssHandlerOptions)) ? preferScopedGeneratedCssRules(composedCss) : composedCss;
4523
3639
  const classSet = options.frameworkProcessedUserCss ? resolveGeneratedCssClassSet(generated.target, generated.classSet, options.runtime, css, options.opts.escapeMap, options.previousClassSet) : new Set(generated.classSet);
3640
+ if (shouldCheckRpxThemeRisk(options.runtimeState, generated.target, options.opts, options.generatorPlatform)) warnRpxThemeRisk(options.runtimeState, generated.rpxThemeVariables ?? [], css);
4524
3641
  const artifact = implementation.emitArtifact ? createCoreArtifact({
4525
3642
  ...generated,
4526
3643
  classSet
@@ -4570,6 +3687,47 @@ async function generateTailwindV4Css(options) {
4570
3687
  return legacy;
4571
3688
  }
4572
3689
  //#endregion
3690
+ //#region src/bundlers/shared/css-source-trace.ts
3691
+ function normalizeSourcePath(source, root) {
3692
+ const resolvedRoot = path.resolve(root);
3693
+ const resolvedSource = path.resolve(source);
3694
+ const relative = path.relative(resolvedRoot, resolvedSource);
3695
+ if (relative && !relative.startsWith("..") && !path.isAbsolute(relative)) return relative.split(path.sep).join("/");
3696
+ return source.split(path.sep).join("/");
3697
+ }
3698
+ function getSourceTraceRoot(opts) {
3699
+ const configured = opts.cssSourceTrace;
3700
+ if (configured && typeof configured === "object" && configured.root) return configured.root;
3701
+ return opts.tailwindcssBasedir ?? process.cwd();
3702
+ }
3703
+ function isCssSourceTraceEnabled(opts) {
3704
+ return opts.cssSourceTrace === true || typeof opts.cssSourceTrace === "object" && opts.cssSourceTrace !== null;
3705
+ }
3706
+ function createCssTokenSourceMap(sourcesByToken, opts) {
3707
+ const root = getSourceTraceRoot(opts);
3708
+ const tokenSources = /* @__PURE__ */ new Map();
3709
+ for (const [token, sources] of [...sourcesByToken.entries()].sort(([a], [b]) => a.localeCompare(b))) {
3710
+ const source = {
3711
+ token,
3712
+ sources: [...sources].map((file) => normalizeSourcePath(file, root)).sort()
3713
+ };
3714
+ tokenSources.set(token, source);
3715
+ const escaped = replaceWxml(token, { escapeMap: opts.escapeMap });
3716
+ tokenSources.set(escaped, source);
3717
+ tokenSources.set(escaped.replaceAll("\\", ""), source);
3718
+ }
3719
+ return tokenSources;
3720
+ }
3721
+ function createCssSourceTraceCacheSignature(tokenSources, opts) {
3722
+ if (!isCssSourceTraceEnabled(opts)) return "css-source-trace:0";
3723
+ if (!tokenSources?.size) return "css-source-trace:1:empty";
3724
+ return `css-source-trace:1:${[...tokenSources.values()].map(({ token, sources }) => `${token}<=${sources.join(",")}`).sort().join("|")}`;
3725
+ }
3726
+ function annotateCssSourceTrace(css, options) {
3727
+ if (!isCssSourceTraceEnabled(options.opts) || !options.tokenSources?.size) return css;
3728
+ return annotateCssTokenSources(css, options.tokenSources);
3729
+ }
3730
+ //#endregion
4573
3731
  //#region src/bundlers/shared/hmr-timing.ts
4574
3732
  function shouldEmitHmrTiming() {
4575
3733
  return process.env["WEAPP_TW_WATCH_REGRESSION"] === "1" || process.env["WEAPP_TW_HMR_TIMING"] === "1";
@@ -4648,4 +3806,4 @@ function createHmrTimingRecorder(bundler) {
4648
3806
  };
4649
3807
  }
4650
3808
  //#endregion
4651
- export { annotateCssSourceTrace as A, finalizeCompilerShadowRun as B, isSourceStyleRequest as C, hasBundlerGeneratedCssMarker as D, createBundlerGeneratedCssMarker as E, collectStrictEscapedRuntimeCandidates as F, createSourceCandidateEligibilityMatcher as G, createSourceCandidateStore as H, createEscapeFragments as I, resolveSourceCandidateScanFiles as K, isPureLocalCssImportWrapper as L, createCssTokenSourceMap as M, isCssSourceTraceEnabled as N, parseBundlerGeneratedCssMarkerBlocks as O, createRuntimeClassSetManager as P, rewriteLocalCssImportRequestsForOutput as R, isSourcePreprocessorRequest as S, createBundlerGeneratedCssEndMarker as T, isSourceCandidateRequest as U, createSourceCandidateCollector as V, extractCandidatesFromSource as W, captureResolvedFrameworkPostcssOptions as _, collectGeneratedRawSourceCandidatesFromCss as a, finalizeMiniProgramGeneratorCss as b, resolveTaskConcurrency as c, normalizeMiniProgramImportShell as d, scoreTailwindV4CssSourceFileMatch as f, captureFrameworkPostcssOptions as g, mergeMarkedUserLayerComponentsCss as h, validateCandidatesByGenerator as i, createCssSourceTraceCacheSignature as j, stripBundlerGeneratedCssMarkers as k, runWithConcurrency as l, extractMarkedUserLayerComponentsCss as m, emitHmrTiming as n, collectRawSourceClassSelectors as o, removeGeneratedSelectorCompatCss as p, generateTailwindV4Css as r, pushConcurrentTaskFactories as s, createHmrTimingRecorder as t, normalizeMiniProgramGeneratorCssSource as u, collectFrameworkPostcssOptionsFromLoaderEntries as v, stripRequestQuery as w, hasMiniProgramTailwindV4PreflightReset as x, createCssSourceOrderAppend as y, splitLocalCssImports as z };
3809
+ export { createSourceCandidateEligibilityMatcher as $, stripTailwindSourceMediaFragments as A, isSourcePreprocessorRequest as B, extractMarkedUserLayerComponentsCss as C, isCommentOnlyCss as D, splitUserCssLayerBlocks as E, collectFrameworkPostcssOptionsFromLoaderEntries as F, createEscapeFragments as G, stripRequestQuery as H, hasTailwindGeneratedCss as I, splitLocalCssImports as J, isPureLocalCssImportWrapper as K, hasTailwindGeneratedCssMarkers as L, normalizeEmptyTailwindCustomVariants$1 as M, captureFrameworkPostcssOptions as N, removeMiniProgramInteractiveSelectors as O, captureResolvedFrameworkPostcssOptions as P, extractCandidatesFromSource as Q, finalizeMiniProgramGeneratorCss as R, removeGeneratedSelectorCompatCss as S, hasUserCssLayerBlocks as T, createRuntimeClassSetManager as U, isSourceStyleRequest as V, collectStrictEscapedRuntimeCandidates as W, createSourceCandidateStore as X, createSourceCandidateCollector as Y, isSourceCandidateRequest as Z, resolveTaskConcurrency as _, hasBundlerGeneratedCssMarker as a, hasTailwindSourceDirectives as at, normalizeMiniProgramImportShell as b, annotateCssSourceTrace as c, parseImportRequest as ct, isCssSourceTraceEnabled as d, finalizeCompilerShadowRun as dt, resolveSourceCandidateScanFiles as et, generateTailwindV4Css as f, pushConcurrentTaskFactories as g, collectRawSourceClassSelectors as h, createBundlerGeneratedCssMarker as i, hasTailwindRootDirectives as it, stripUnmatchedTailwindSourceMediaCloseFragments as j, removeTailwindV4GeneratorAtRules as k, createCssSourceTraceCacheSignature as l, removeTailwindSourceDirectives as lt, collectGeneratedRawSourceCandidatesFromCss as m, emitHmrTiming as n, hasTailwindApplyDirective as nt, parseBundlerGeneratedCssMarkerBlocks as o, normalizeTailwindConfigDirectives$1 as ot, validateCandidatesByGenerator as p, rewriteLocalCssImportRequestsForOutput as q, createBundlerGeneratedCssEndMarker as r, hasTailwindNonRootGenerationDirectives as rt, stripBundlerGeneratedCssMarkers as s, normalizeTailwindSourceForGenerator as st, createHmrTimingRecorder as t, hasLocalCssImport as tt, createCssTokenSourceMap as u, prependConfigDirective as ut, runWithConcurrency as v, mergeMarkedUserLayerComponentsCss as w, scoreTailwindV4CssSourceFileMatch as x, normalizeMiniProgramGeneratorCssSource as y, hasMiniProgramTailwindV4PreflightReset as z };