weapp-tailwindcss 5.5.5 → 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 (323) 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 +5 -4
  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 -2
  8. package/dist/bundlers/shared/framework-css-composition.d.ts +1 -0
  9. package/dist/bundlers/shared/framework-postcss.d.ts +1 -24
  10. package/dist/bundlers/shared/framework-user-css.d.ts +1 -3
  11. package/dist/bundlers/shared/generated-css-marker.d.ts +1 -9
  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 -25
  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 -9
  23. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +1 -5
  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 -58
  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 -61
  51. package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +1 -9
  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 -0
  54. package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +1 -4
  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 -10
  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 -0
  78. package/dist/bundlers/shared/style-requests.d.ts +1 -5
  79. package/dist/bundlers/shared/v4-generation-core.d.ts +1 -21
  80. package/dist/bundlers/vite/css-finalizer/css-calc.d.ts +3 -0
  81. package/dist/bundlers/vite/css-finalizer/final-assets.d.ts +3 -0
  82. package/dist/bundlers/vite/css-handler-options.d.ts +1 -1
  83. package/dist/bundlers/vite/frameworks/generic/web.d.ts +2 -1
  84. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
  85. package/dist/bundlers/vite/generate-bundle/css-transform-decision-plan.d.ts +1 -0
  86. package/dist/bundlers/vite/generate-bundle/css-transform-task.d.ts +2 -2
  87. package/dist/bundlers/vite/generate-bundle/finalize/sync-processed-css.d.ts +4 -0
  88. package/dist/bundlers/vite/generate-bundle/framework-style-memory.d.ts +4 -0
  89. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +7 -0
  90. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -0
  91. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +1 -1
  92. package/dist/bundlers/vite/generate-bundle/runtime.d.ts +3 -1
  93. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +1 -1
  94. package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +2 -2
  95. package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -1
  96. package/dist/bundlers/vite/generate-bundle/web-css-module.d.ts +1 -0
  97. package/dist/bundlers/vite/plugin-hook.d.ts +3 -0
  98. package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +1 -1
  99. package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +1 -10
  100. package/dist/bundlers/vite/processed-css-assets/injection-plan.d.ts +1 -4
  101. package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +4 -7
  102. package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +1 -13
  103. package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +3 -1
  104. package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +3 -2
  105. package/dist/bundlers/vite/shared/framework-runtime-configuration.d.ts +3 -0
  106. package/dist/bundlers/vite/shared/framework-runtime-options.d.ts +9 -0
  107. package/dist/bundlers/vite/shared/framework-runtime-utils.d.ts +6 -5
  108. package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +3 -3
  109. package/dist/bundlers/vite/shared/framework-strategy.d.ts +3 -1
  110. package/dist/bundlers/vite/shared/hmr-source.d.ts +2 -0
  111. package/dist/bundlers/vite/source-candidates/scan-root.d.ts +1 -1
  112. package/dist/bundlers/vite/source-candidates.d.ts +1 -1
  113. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.d.ts +1 -1
  114. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.d.ts +2 -7
  115. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/preflight-runtime.d.ts +4 -8
  116. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.d.ts +3 -3
  117. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.d.ts +1 -1
  118. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.d.ts +2 -7
  119. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +2 -1
  120. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +1 -1
  121. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +1 -1
  122. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
  123. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +1 -1
  124. package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +6 -0
  125. package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +1 -1
  126. package/dist/cache/index.d.ts +4 -4
  127. package/dist/cache/source.d.ts +29 -0
  128. package/dist/{cache-CBJFB1HN.cjs → cache-CzvIGfwS.cjs} +1 -0
  129. package/dist/compiler/composition.d.ts +1 -1
  130. package/dist/compiler/index.d.ts +2 -0
  131. package/dist/compiler/runtime-affecting-signature/js.d.ts +1 -0
  132. package/dist/compiler/semantic-css.d.ts +1 -1
  133. package/dist/compiler/types.d.ts +1 -1
  134. package/dist/{compiler-D_vxtEdw.js → compiler-CThodfGH.js} +3105 -3065
  135. package/dist/{compiler-Cc0JXfbw.cjs → compiler-DkGY5Nmh.cjs} +22414 -45557
  136. package/dist/core/compiler/generation-cache.d.ts +4 -2
  137. package/dist/core/compiler/transforms.d.ts +1 -1
  138. package/dist/core/compiler/types.d.ts +1 -1
  139. package/dist/core.cjs +10 -10
  140. package/dist/core.d.ts +2 -2
  141. package/dist/core.js +5 -5
  142. package/dist/css-cleanup-B6FUJC3z.cjs +1 -0
  143. package/dist/{css-imports-FRZwX4P6.cjs → css-imports-R_RDMjPz.cjs} +7 -22
  144. package/dist/css-macro/auto.d.ts +1 -1
  145. package/dist/css-macro/postcss.cjs +1 -1
  146. package/dist/css-macro.cjs +3 -3
  147. package/dist/css-macro.js +2 -2
  148. package/dist/{defaults-CKx-4LcW.js → defaults-AQuvJS-h.js} +4 -2
  149. package/dist/{defaults-CiGsr8Xq.cjs → defaults-CyX5iO9y.cjs} +4 -2
  150. package/dist/defaults.cjs +1 -1
  151. package/dist/defaults.js +1 -1
  152. package/dist/final-css-cleanup-B6FUJC3z.cjs +1 -0
  153. package/dist/{final-css-cleanup-B0HUBtiE.js → final-css-cleanup-BOzhuhGz.js} +3 -127
  154. package/dist/framework/index.d.ts +1 -1
  155. package/dist/framework/platform.d.ts +2 -2
  156. package/dist/framework.cjs +1 -1
  157. package/dist/{v4-generation-core-DJBWZ_D0.cjs → generated-css-marker-jMNbQHpy.cjs} +717 -1730
  158. package/dist/generation/candidates.d.ts +1 -0
  159. package/dist/generation/class-selectors.d.ts +4 -0
  160. package/dist/generation/config-directive.d.ts +1 -0
  161. package/dist/generation/directives/fallback.d.ts +1 -0
  162. package/dist/generation/directives.d.ts +1 -0
  163. package/dist/generation/framework-css-composition.d.ts +1 -0
  164. package/dist/generation/framework-postcss.d.ts +25 -0
  165. package/dist/generation/framework-user-css.d.ts +5 -0
  166. package/dist/generation/generation-helpers/preflight.d.ts +19 -0
  167. package/dist/generation/generation-helpers/results.d.ts +23 -0
  168. package/dist/generation/generation-helpers/runtime-isolation.d.ts +30 -0
  169. package/dist/generation/generation-helpers/source-order.d.ts +1 -0
  170. package/dist/generation/generation-helpers.d.ts +4 -0
  171. package/dist/generation/index.d.ts +9 -0
  172. package/dist/generation/legacy-compat.d.ts +12 -0
  173. package/dist/generation/legacy-selectors.d.ts +1 -0
  174. package/dist/generation/legacy-units.d.ts +1 -0
  175. package/dist/generation/local-imports.d.ts +1 -0
  176. package/dist/generation/markers.d.ts +1 -0
  177. package/dist/generation/output-import-shell.d.ts +1 -0
  178. package/dist/generation/pipeline/context.d.ts +60 -0
  179. package/dist/generation/pipeline/deferred-output.d.ts +3 -0
  180. package/dist/generation/pipeline/execution.d.ts +3 -0
  181. package/dist/generation/pipeline/fallback-output.d.ts +3 -0
  182. package/dist/generation/pipeline/ordered-output.d.ts +3 -0
  183. package/dist/generation/pipeline/preparation.d.ts +19 -0
  184. package/dist/generation/pipeline.d.ts +2 -0
  185. package/dist/generation/result-helpers.d.ts +6 -0
  186. package/dist/generation/scoped-rules.d.ts +1 -0
  187. package/dist/generation/service.d.ts +20 -0
  188. package/dist/generation/source-files.d.ts +21 -0
  189. package/dist/generation/source-resolver/apply-reference.d.ts +10 -0
  190. package/dist/generation/source-resolver/config.d.ts +7 -0
  191. package/dist/generation/source-resolver/configuration.d.ts +33 -0
  192. package/dist/generation/source-resolver/matching.d.ts +3 -0
  193. package/dist/generation/source-resolver/metadata.d.ts +28 -0
  194. package/dist/generation/source-resolver/postcss-source.d.ts +14 -0
  195. package/dist/generation/source-resolver/resolve-source.d.ts +4 -0
  196. package/dist/generation/source-resolver/resolve-sources.d.ts +5 -0
  197. package/dist/generation/source-resolver/single-source.d.ts +16 -0
  198. package/dist/generation/source-resolver/source-entries.d.ts +3 -0
  199. package/dist/generation/source-resolver/source-matching.d.ts +5 -0
  200. package/dist/generation/source-resolver/types.d.ts +22 -0
  201. package/dist/generation/source-resolver.d.ts +7 -0
  202. package/dist/generation/style-options.d.ts +8 -0
  203. package/dist/generation/style-requests.d.ts +5 -0
  204. package/dist/generation/types.d.ts +65 -0
  205. package/dist/generation/user-css/apply-only.d.ts +5 -0
  206. package/dist/generation/user-css/at-rules.d.ts +1 -0
  207. package/dist/generation/user-css/compile-functions.d.ts +3 -0
  208. package/dist/generation/user-css/generated-cleanup.d.ts +1 -0
  209. package/dist/generation/user-css/source-fragments.d.ts +1 -0
  210. package/dist/generation/user-css/transform.d.ts +1 -0
  211. package/dist/generation/user-css/user-layers.d.ts +1 -0
  212. package/dist/generation/user-css.d.ts +5 -0
  213. package/dist/generation/user-layer-order.d.ts +1 -0
  214. package/dist/generation/validate.d.ts +7 -0
  215. package/dist/generator-CxauQbx3.cjs +1868 -0
  216. package/dist/generator-oKZ5mCJ5.js +1637 -0
  217. package/dist/generator.cjs +10 -4
  218. package/dist/generator.js +1 -1
  219. package/dist/{gulp-Dnt8VL8D.cjs → gulp-CVvBpIlq.cjs} +27 -26
  220. package/dist/{gulp-B1mPTMqw.js → gulp-DhddVxGA.js} +6 -5
  221. package/dist/gulp.cjs +1 -1
  222. package/dist/gulp.js +1 -1
  223. package/dist/{hmr-timing-qpX410qU.cjs → hmr-timing-DfMbbZ1E.cjs} +13 -13
  224. package/dist/{hmr-timing-wAt0LavM.js → hmr-timing-xPpat-km.js} +601 -1548
  225. package/dist/index.cjs +7 -7
  226. package/dist/index.d.ts +1 -1
  227. package/dist/index.js +5 -5
  228. package/dist/js/ModuleGraph.d.ts +3 -1
  229. package/dist/js/NodePathWalker.d.ts +1 -1
  230. package/dist/js/babel/analyze.d.ts +6 -0
  231. package/dist/js/babel.d.ts +1 -2
  232. package/dist/js/fast-path/analysis.d.ts +14 -0
  233. package/dist/js/fast-path/oxc.d.ts +1 -1
  234. package/dist/js/node-path-walker/export-handlers.d.ts +1 -1
  235. package/dist/js/node-path-walker/import-tokens.d.ts +1 -1
  236. package/dist/js/oxc-parser.d.ts +4 -0
  237. package/dist/pipeline-helpers-zMPmp5F3.cjs +516 -0
  238. package/dist/postcss-html-transform.cjs +1 -1
  239. package/dist/postcss.cjs +3 -2
  240. package/dist/postcss.d.ts +1 -1
  241. package/dist/postcss.js +3 -2
  242. package/dist/presets.cjs +3 -3
  243. package/dist/presets.js +2 -2
  244. package/dist/project-sources/candidates/collector.d.ts +8 -0
  245. package/dist/project-sources/candidates/scan-root.d.ts +12 -0
  246. package/dist/project-sources/candidates/script.d.ts +1 -0
  247. package/dist/project-sources/candidates/snapshot.d.ts +19 -0
  248. package/dist/project-sources/candidates/source-priority.d.ts +1 -0
  249. package/dist/project-sources/candidates/store.d.ts +2 -0
  250. package/dist/project-sources/candidates/types-and-cache.d.ts +75 -0
  251. package/dist/project-sources/candidates/views.d.ts +12 -0
  252. package/dist/project-sources/candidates.d.ts +4 -0
  253. package/dist/project-sources/css-entries.d.ts +18 -0
  254. package/dist/project-sources/dependencies.d.ts +2 -0
  255. package/dist/project-sources/index.d.ts +16 -0
  256. package/dist/project-sources/static-config-content.d.ts +5 -0
  257. package/dist/reset.cjs +1 -1
  258. package/dist/{rolldown-runtime-Ctb5zv51.cjs → rolldown-runtime-fg3euq-1.cjs} +7 -0
  259. package/dist/rspack.cjs +4 -4
  260. package/dist/rspack.js +2 -2
  261. package/dist/{runtime-state-XYSycuGu.cjs → runtime-state-BOzuVoKl.cjs} +1 -1
  262. package/dist/{scoped-generator-CtetE5rm.cjs → scoped-generator-BIZ7N_J-.cjs} +51 -36
  263. package/dist/{scoped-generator-BqxVxNp9.js → scoped-generator-DlQrVbuC.js} +49 -33
  264. package/dist/{source-candidate-scan-signature-Lm32zKVA.js → source-candidate-scan-signature-BjVQYL-C.js} +22 -5
  265. package/dist/{source-candidate-scan-signature-BDGB9nKZ.cjs → source-candidate-scan-signature-nG-rg809.cjs} +34 -5
  266. package/dist/style-injector/internal.d.ts +118 -8
  267. package/dist/style-injector/options.d.ts +6 -2
  268. package/dist/tailwindcss/miniprogram.d.ts +1 -1
  269. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -1
  270. package/dist/tailwindcss/runtime-options.d.ts +5 -0
  271. package/dist/tailwindcss/source-scan/inline-source.d.ts +1 -7
  272. package/dist/tailwindcss/source-scan.d.ts +3 -32
  273. package/dist/tailwindcss/v4/css-sources.d.ts +1 -1
  274. package/dist/tailwindcss/v4/preflight.d.ts +1 -4
  275. package/dist/tailwindcss/v4/rpx-theme-warning.d.ts +4 -0
  276. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
  277. package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +2 -3
  278. package/dist/tailwindcss/v4-engine/generator/native-session.d.ts +1 -1
  279. package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +1 -6
  280. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +5 -2
  281. package/dist/tailwindcss/v4-engine/generator/style-context.d.ts +1 -3
  282. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +3 -7
  283. package/dist/tailwindcss/v4-engine/source.d.ts +1 -1
  284. package/dist/tailwindcss/v4-engine/types.d.ts +3 -1
  285. package/dist/{tailwindcss-9e6ZuYgS.cjs → tailwindcss-U3KIUegn.cjs} +66 -271
  286. package/dist/{tailwindcss-DTV9MoJT.js → tailwindcss-kSd0ykiX.js} +73 -251
  287. package/dist/{transform-BbbZvFQq.js → transform-BAon9ykq.js} +35 -20
  288. package/dist/{transform-D21f8Dm8.cjs → transform-D2KFdA3C.cjs} +41 -26
  289. package/dist/types/index.d.ts +4 -3
  290. package/dist/types/user-defined-options/general.d.ts +1 -1
  291. package/dist/uni-app-x/border-preflight.d.ts +1 -2
  292. package/dist/uni-app-x/component-local-style.d.ts +4 -1
  293. package/dist/uni-app-x/transform.d.ts +4 -2
  294. package/dist/uni-app-x/vite/author-apply.d.ts +3 -1
  295. package/dist/uni-app-x/vite/native-hmr.d.ts +1 -1
  296. package/dist/uni-app-x/vite/style-result.d.ts +5 -0
  297. package/dist/utils/run-tasks.d.ts +3 -0
  298. package/dist/vite/web.cjs +1 -1
  299. package/dist/vite/web.js +1 -1
  300. package/dist/{vite-CaH7WjX6.cjs → vite-BxW0qd7J.cjs} +677 -1315
  301. package/dist/{vite-CuYntLZP.js → vite-D-RGkmOE.js} +541 -1173
  302. package/dist/vite-web.d.ts +1 -1
  303. package/dist/vite.cjs +1 -1
  304. package/dist/vite.js +1 -1
  305. package/dist/{watch-dependencies-GbC14Rlt.cjs → watch-dependencies-C1so1whD.cjs} +14 -1
  306. package/dist/weapp-tw-css-generation-loader.cjs +4 -3
  307. package/dist/weapp-tw-css-import-rewrite-loader.cjs +34 -29
  308. package/dist/weapp-tw-runtime-classset-loader.cjs +5 -18
  309. package/dist/{web-CdXkY_VO.js → web--kA4HUTm.js} +149 -211
  310. package/dist/{web-CYs2Kcaa.cjs → web-Y-H6I1k6.cjs} +226 -286
  311. package/dist/{webpack-BnCSOUuu.js → webpack-BB-kw4Qr.js} +38 -450
  312. package/dist/{webpack-BQNnpQPC.cjs → webpack-DxrWatNB.cjs} +97 -97
  313. package/dist/webpack.cjs +1 -1
  314. package/dist/webpack.js +1 -1
  315. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -2
  316. package/dist/wxml/utils/custom-template.d.ts +1 -1
  317. package/package.json +16 -13
  318. package/dist/final-css-cleanup-DSjczga3.cjs +0 -138
  319. package/dist/generator-BdSIvFEO.cjs +0 -3905
  320. package/dist/generator-CAOx1Sqm.js +0 -3357
  321. package/dist/pipeline-helpers-BHagysZY.cjs +0 -971
  322. package/dist/tailwindcss/v4-engine/css-import.d.ts +0 -14
  323. package/dist/uni-app-x/style-asset/source-parser.d.ts +0 -2
@@ -1,105 +1,246 @@
1
- import { $ as hasTailwindRootDirectives, At as resolveTailwindV4CssSourceBase, B as removeUnsupportedMiniProgramAtRules, F as stripTailwindSourceMediaFragments, G as shouldFilterApplyOnlyGeneratedCss, H as removeTailwindV4GeneratedUserCssArtifacts, I as stripUnmatchedTailwindSourceMediaCloseFragments, J as splitUserCssLayerBlocks, K as extractGeneratedCssForUserLayerSelectors, L as finalizeMiniProgramCss$1, M as isCommentOnlyCss, Nt as parseCssImportSpecifier, P as removeTailwindV4GeneratorAtRules, Pt as quoteCssImportSpecifier, T as omitUndefined, Tt as isFileMatchedByTailwindSourceEntries, U as filterApplyOnlyGeneratedCss, Vt as loadTailwindV4DesignSystem, W as normalizeEmptyTailwindCustomVariants, Y as preferScopedGeneratedCssRules, Z as hasTailwindApplyDirective, _t as stripTailwindBanners, a as resolveGeneratorRuntimeBranch, at as removeTailwindSourceDirectives, ct as VITE_MARKER_RE, d as resolveTailwindV4SourceFromRuntime, dt as hasTailwindGeneratedCssMarkers, et as hasTailwindSourceDirectives, ft as splitGeneratorPlaceholderCssBySourceOrder, gt as stripTailwindBanner, ht as stripGeneratorPlaceholderMarkers, i as normalizeWeappTailwindcssGeneratorOptions, it as parseImportRequest, j as transformGeneratorUserCss, jt as toPosixPath, kt as resolveSourceScanPath, lt as createCssAppend, mt as splitTailwindV4GeneratedCssBySourceOrder, nt as normalizeTailwindSourceDirectives, ot as resolveCssEntrySource, p as resolveTailwindV4SourceOptionsFromRuntime, pt as splitTailwindGeneratedCssByBanner, q as hasUserCssLayerBlocks, s as shouldUseMiniProgramCssBranch, st as GENERATOR_PLACEHOLDER_MARKER_RE, u as resolveTailwindV4Source$1, ut as hasTailwindGeneratedCss, vt as normalizeConfigDirective, wt as isFileExcludedByTailwindSourceEntries, xt as FULL_SOURCE_SCAN_EXTENSION_RE, yt as prependConfigDirective, zt as filterUnsupportedMiniProgramTailwindV4Candidates } from "./generator-CAOx1Sqm.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-DTV9MoJT.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-D_vxtEdw.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, filterExistingCssRules, isPureLocalCssImportWrapper, isPureLocalCssImportWrapperRoot, normalizeMiniProgramGeneratedCssForPostcss, postcss, removeMatchingLocalCssImports, 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 : [{
224
+ if (!entries?.length && !outDirIgnore) return;
225
+ return createSourceScanPlan({
67
226
  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
- }], {
77
- 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);
@@ -734,217 +876,18 @@ function createSourceCandidateStore(options = {}) {
734
876
  };
735
877
  }
736
878
  //#endregion
737
- //#region src/bundlers/shared/source-candidates/collector.ts
879
+ //#region src/project-sources/candidates/collector.ts
738
880
  function createSourceCandidateCollector(options = {}) {
739
881
  return createSourceCandidateStore(options);
740
882
  }
741
883
  //#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";
884
+ //#region src/bundlers/shared/runtime-class-set/entries.ts
885
+ const EXTENSION_DOT_PREFIX_RE = /^\./;
886
+ function createRuntimeEntries(snapshot) {
887
+ return snapshot.entries.filter((entry) => entry.runtimeCandidate !== false);
747
888
  }
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
- };
939
- }
940
- //#endregion
941
- //#region src/bundlers/shared/runtime-class-set/entries.ts
942
- const EXTENSION_DOT_PREFIX_RE = /^\./;
943
- function createRuntimeEntries(snapshot) {
944
- return snapshot.entries.filter((entry) => entry.runtimeCandidate !== false);
945
- }
946
- function collectChangedRuntimeFiles(snapshot) {
947
- return /* @__PURE__ */ new Set([...snapshot.runtimeAffectingChangedByType.html, ...snapshot.runtimeAffectingChangedByType.js]);
889
+ function collectChangedRuntimeFiles(snapshot) {
890
+ return /* @__PURE__ */ new Set([...snapshot.runtimeAffectingChangedByType.html, ...snapshot.runtimeAffectingChangedByType.js]);
948
891
  }
949
892
  function resolveEntryExtension(entry) {
950
893
  if (entry.type === "html") return "html";
@@ -1280,139 +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 VITE_INTERNAL_CSS_MARKER_GLOBAL_RE = /\/\*\$vite\$:\d+\*\/\s*/g;
1387
- function createBundlerGeneratedCssMarker(bundler, file) {
1388
- return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
1389
- }
1390
- function hasBundlerGeneratedCssMarker(source) {
1391
- return typeof source === "string" && BUNDLER_GENERATED_CSS_MARKER_RE.test(source);
1392
- }
1393
- function stripBundlerGeneratedCssMarkers(source) {
1394
- return source.replace(BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE, "").replace(VITE_INTERNAL_CSS_MARKER_GLOBAL_RE, "");
1395
- }
1396
- function parseBundlerGeneratedCssMarkerBlocks(source) {
1397
- const blocks = [];
1398
- BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.lastIndex = 0;
1399
- let match = BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.exec(source);
1400
- while (match !== null) {
1401
- const cssStart = BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.lastIndex;
1402
- const nextMatch = BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.exec(source);
1403
- const cssEnd = nextMatch?.index ?? source.length;
1404
- const file = match[2] ? decodeURIComponent(match[2]) : void 0;
1405
- blocks.push({
1406
- bundler: match[1],
1407
- file,
1408
- css: source.slice(cssStart, cssEnd)
1409
- });
1410
- match = nextMatch;
1411
- }
1412
- return blocks;
1242
+ function resolveCssSourceBase(file, cssHandlerOptions) {
1243
+ const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
1244
+ return path.dirname(path.resolve(normalized));
1413
1245
  }
1414
1246
  //#endregion
1415
- //#region src/bundlers/shared/style-requests.ts
1247
+ //#region src/generation/style-requests.ts
1416
1248
  const SOURCE_STYLE_EXT_RE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)$/i;
1417
1249
  const SOURCE_PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)$/i;
1418
1250
  const SFC_SOURCE_EXT_RE = /\.(?:vue|uvue|nvue|svelte|mpx)$/i;
@@ -1464,28 +1296,7 @@ function isVueScopedStyleRequest(request) {
1464
1296
  return VUE_STYLE_QUERY_RE.test(query) && /(?:^|&)scoped(?:=[^&]*)?(?:&|$)/.test(query);
1465
1297
  }
1466
1298
  //#endregion
1467
- //#region src/bundlers/shared/generator-css/source-resolver/postcss-source.ts
1468
- function resolvePostcssFromOption(cssHandlerOptions) {
1469
- const from = cssHandlerOptions.postcssOptions?.options?.from;
1470
- return typeof from === "string" && from.length > 0 ? from : void 0;
1471
- }
1472
- function resolvePostcssRequestOption(cssHandlerOptions) {
1473
- return resolveCssHandlerSourceOptions(cssHandlerOptions)?.requestFile ?? resolvePostcssFromOption(cssHandlerOptions);
1474
- }
1475
- function resolvePostcssSourceFile(cssHandlerOptions) {
1476
- const from = resolvePostcssFromOption(cssHandlerOptions);
1477
- if (!from || !path.isAbsolute(from)) return;
1478
- return from.replace(/[?#].*$/, "");
1479
- }
1480
- function resolveCssHandlerSourceOptions(cssHandlerOptions) {
1481
- return cssHandlerOptions.sourceOptions;
1482
- }
1483
- function resolveCssSourceBase(file, cssHandlerOptions) {
1484
- const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
1485
- return path.dirname(path.resolve(normalized));
1486
- }
1487
- //#endregion
1488
- //#region src/bundlers/shared/generator-css/generation-helpers/preflight.ts
1299
+ //#region src/generation/generation-helpers/preflight.ts
1489
1300
  function hasMiniProgramTailwindV4PreflightReset(css) {
1490
1301
  return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\bborder\s*:\s*0\s+solid\b/.test(css);
1491
1302
  }
@@ -1494,7 +1305,7 @@ function isMiniProgramGeneratorTarget(target) {
1494
1305
  }
1495
1306
  function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
1496
1307
  if (!isMiniProgramGeneratorTarget(target)) return css;
1497
- if (options.styleOptions && isVueScopedStyleRequest(resolvePostcssRequestOption(options.styleOptions))) return finalizeMiniProgramCss$1(css, {
1308
+ if (options.styleOptions && isVueScopedStyleRequest(resolvePostcssRequestOption(options.styleOptions))) return finalizeMiniProgramCss(css, {
1498
1309
  cssPreflight: false,
1499
1310
  cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
1500
1311
  isTailwindcssV4: true,
@@ -1504,7 +1315,7 @@ function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPrefligh
1504
1315
  const hasPreflightReset = hasMiniProgramTailwindV4PreflightReset(css);
1505
1316
  const injectPreflight = options.injectPreflight !== false && !hasPreflightReset;
1506
1317
  const preservePreflight = options.preservePreflight !== false;
1507
- return finalizeMiniProgramCss$1(css, {
1318
+ return finalizeMiniProgramCss(css, {
1508
1319
  cssPreflight: cssPreflight === false || options.injectPreflight === false && (!hasPreflightReset || !preservePreflight) ? false : injectPreflight ? cssPreflight : hasPreflightReset && preservePreflight ? cssPreflight : void 0,
1509
1320
  cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
1510
1321
  isTailwindcssV4: true,
@@ -1552,128 +1363,7 @@ function resolveMiniProgramPreflightModeForGeneratorCss(opts, options) {
1552
1363
  };
1553
1364
  }
1554
1365
  //#endregion
1555
- //#region src/bundlers/shared/generator-css/generation-helpers/source-order.ts
1556
- function createCssSourceOrderAppend(base, extra) {
1557
- if (!base) return extra;
1558
- if (!extra) return base;
1559
- if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
1560
- return `${base}\n${extra}`;
1561
- }
1562
- const LEGACY_PSEUDO_ELEMENTS$1 = [
1563
- "before",
1564
- "after",
1565
- "first-letter",
1566
- "first-line"
1567
- ];
1568
- const CSS_STRING_LITERAL_RE = /(["'])((?:\\[\s\S]|(?!\1)[\s\S])*)\1/g;
1569
- function isLegacyPseudoElementAt$1(selector, index) {
1570
- for (const name of LEGACY_PSEUDO_ELEMENTS$1) {
1571
- if (!selector.startsWith(name, index)) continue;
1572
- const next = selector[index + name.length];
1573
- if (next === void 0 || !/[\w-]/.test(next)) return name;
1574
- }
1575
- }
1576
- function normalizeLegacyPseudoElements$1(selector) {
1577
- let result = "";
1578
- let quote;
1579
- let bracketDepth = 0;
1580
- let index = 0;
1581
- while (index < selector.length) {
1582
- const char = selector[index];
1583
- if (char === "\\") {
1584
- result += selector.slice(index, index + 2);
1585
- index += 2;
1586
- continue;
1587
- }
1588
- if (quote !== void 0) {
1589
- result += char;
1590
- if (char === quote) quote = void 0;
1591
- index += 1;
1592
- continue;
1593
- }
1594
- if (char === "\"" || char === "'") {
1595
- quote = char;
1596
- result += char;
1597
- index += 1;
1598
- continue;
1599
- }
1600
- if (char === "[") {
1601
- bracketDepth++;
1602
- result += char;
1603
- index += 1;
1604
- continue;
1605
- }
1606
- if (char === "]") {
1607
- bracketDepth = Math.max(0, bracketDepth - 1);
1608
- result += char;
1609
- index += 1;
1610
- continue;
1611
- }
1612
- if (bracketDepth === 0 && char === ":" && selector[index + 1] === ":") {
1613
- result += "::";
1614
- index += 2;
1615
- continue;
1616
- }
1617
- if (bracketDepth === 0 && char === ":") {
1618
- const name = isLegacyPseudoElementAt$1(selector, index + 1);
1619
- if (name) {
1620
- result += `::${name}`;
1621
- index += name.length + 1;
1622
- continue;
1623
- }
1624
- }
1625
- result += char;
1626
- index += 1;
1627
- }
1628
- return result;
1629
- }
1630
- function normalizeCssRuleDeduplicationSelector(selector) {
1631
- return normalizeLegacyPseudoElements$1(selector).replace(/\s+/g, " ").replace(/\s*([>+~])\s*/g, "$1").replace(/\(\s+/g, "(").replace(/\s+\)/g, ")").trim();
1632
- }
1633
- function normalizeCssRuleDeduplicationValue(value) {
1634
- return value.replace(/\s+/g, " ").replace(CSS_STRING_LITERAL_RE, (_match, _quote, content) => {
1635
- return `'${content.replace(/\\(["'])/g, "$1").replace(/'/g, "\\'")}'`;
1636
- }).trim();
1637
- }
1638
- function createRuleDeduplicationKey(rule) {
1639
- const parents = [];
1640
- let parent = rule.parent;
1641
- while (parent && parent.type !== "root") {
1642
- if (parent.type === "atrule") parents.push(`${parent.name}:${parent.params}`);
1643
- parent = parent.parent;
1644
- }
1645
- const declarations = (rule.nodes ?? []).map((node) => {
1646
- if (node.type === "decl") return `${node.prop}:${normalizeCssRuleDeduplicationValue(node.value)}:${node.important ? "1" : "0"}`;
1647
- if (node.type === "comment") return "";
1648
- return normalizeCssRuleDeduplicationValue(node.toString());
1649
- }).filter(Boolean);
1650
- const selectors = (rule.selectors?.length ? rule.selectors : [rule.selector]).map(normalizeCssRuleDeduplicationSelector);
1651
- return [
1652
- parents.reverse().join("|"),
1653
- selectors.join(","),
1654
- declarations.join(";")
1655
- ].join("\n");
1656
- }
1657
- function deduplicateGeneratedCssRules(css) {
1658
- if (!css) return css;
1659
- try {
1660
- const root = postcss.parse(css);
1661
- const seen = /* @__PURE__ */ new Set();
1662
- root.walkRules((rule) => {
1663
- const key = createRuleDeduplicationKey(rule);
1664
- if (seen.has(key)) {
1665
- rule.remove();
1666
- return;
1667
- }
1668
- seen.add(key);
1669
- });
1670
- return root.toString();
1671
- } catch {
1672
- return css;
1673
- }
1674
- }
1675
- //#endregion
1676
- //#region src/bundlers/shared/generator-css/generation-helpers/results.ts
1366
+ //#region src/generation/generation-helpers/results.ts
1677
1367
  function shouldFinalizeMarkedUserLayerComponentsCss(file) {
1678
1368
  return !/\.(?:vue|svelte|astro|scss|sass|less|styl)(?:[?#].*)?$/i.test(file);
1679
1369
  }
@@ -1711,7 +1401,7 @@ function mergeGeneratorResults(generatedResults) {
1711
1401
  };
1712
1402
  }
1713
1403
  //#endregion
1714
- //#region src/bundlers/shared/generator-css/generation-helpers/runtime-isolation.ts
1404
+ //#region src/generation/generation-helpers/runtime-isolation.ts
1715
1405
  function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
1716
1406
  if (options.isolateCssSource) {
1717
1407
  if (options.matchedCssSourceFile) return /* @__PURE__ */ new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
@@ -1760,7 +1450,27 @@ function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOpt
1760
1450
  };
1761
1451
  }
1762
1452
  //#endregion
1763
- //#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
1764
1474
  const FRAMEWORK_POSTCSS_REGISTRY = Symbol.for("weapp-tailwindcss.framework-postcss-options");
1765
1475
  const registryHost = globalThis;
1766
1476
  const frameworkPostcssOptions = registryHost[FRAMEWORK_POSTCSS_REGISTRY] ?? (registryHost[FRAMEWORK_POSTCSS_REGISTRY] = /* @__PURE__ */ new WeakMap());
@@ -1865,7 +1575,7 @@ function createFrameworkReplayArtifact(generated, options) {
1865
1575
  scope,
1866
1576
  stage: "raw"
1867
1577
  })], {
1868
- classSet: generated.classSet,
1578
+ classSet: new Set(generated.classSet),
1869
1579
  rawCandidates: new Set(options.rawCandidates),
1870
1580
  dependencies: generated.dependencies,
1871
1581
  sourceEntries: options.cssHandlerOptions.sourceOptions?.cssEntries ?? [],
@@ -1873,7 +1583,9 @@ function createFrameworkReplayArtifact(generated, options) {
1873
1583
  });
1874
1584
  }
1875
1585
  async function adaptGeneratedCssWithFrameworkPipeline(owner, generated, options) {
1876
- const handled = await options.styleHandler(generated.css, createGeneratedCssHandlerOptions(owner, options.cssHandlerOptions, options.file));
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);
1877
1589
  const preflightMode = generated.metadata?.preflightMode;
1878
1590
  const injectPreflight = preflightMode?.inject ?? options.cssHandlerOptions.isMainChunk;
1879
1591
  const preservePreflight = preflightMode?.preserve ?? options.cssHandlerOptions.isMainChunk;
@@ -1885,6 +1597,7 @@ async function adaptGeneratedCssWithFrameworkPipeline(owner, generated, options)
1885
1597
  }
1886
1598
  async function adaptGeneratedCssWithFrameworkRootPipeline(owner, generated, options) {
1887
1599
  const handlerOptions = createGeneratedCssHandlerOptions(owner, options.cssHandlerOptions, options.file);
1600
+ if (generated.target === "web") return (await processFrameworkCss(generated.css, handlerOptions.postcssOptions)).css;
1888
1601
  const replayArtifact = createFrameworkReplayArtifact(generated, options);
1889
1602
  const handled = options.compiler && options.snapshot ? composeGenerationArtifact(await (async () => {
1890
1603
  for (const fragment of replayArtifact.fragments) {
@@ -1902,520 +1615,51 @@ async function adaptGeneratedCssWithFrameworkRootPipeline(owner, generated, opti
1902
1615
  const preservePreflight = preflightMode?.preserve ?? options.cssHandlerOptions.isMainChunk;
1903
1616
  return finalizeMiniProgramGeneratorCss(handled.css, generated.target, options.majorVersion, owner.cssPreflight, {
1904
1617
  ...injectPreflight === void 0 ? {} : { injectPreflight },
1905
- ...preservePreflight === void 0 ? {} : { preservePreflight },
1906
- styleOptions: options.cssHandlerOptions
1907
- });
1908
- }
1909
- //#endregion
1910
- //#region src/bundlers/shared/generator-css/user-layer-order.ts
1911
- const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
1912
- const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
1913
- function appendCss(base, extra) {
1914
- if (!base) return extra;
1915
- if (!extra) return base;
1916
- if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
1917
- return `${base}\n${extra}`;
1918
- }
1919
- function removeFirstCssOccurrence(css, chunk) {
1920
- const trimmed = chunk.trim();
1921
- if (!trimmed) return css;
1922
- const index = css.indexOf(trimmed);
1923
- if (index === -1) return css;
1924
- return appendCss(css.slice(0, index).trimEnd(), css.slice(index + trimmed.length).trimStart());
1925
- }
1926
- function collectSelectorsFromCss(css) {
1927
- const selectors = /* @__PURE__ */ new Set();
1928
- try {
1929
- postcss.parse(css).walkRules((rule) => {
1930
- for (const selector of rule.selectors ?? [rule.selector]) {
1931
- const normalized = selector.trim();
1932
- if (normalized) selectors.add(normalized);
1933
- }
1934
- });
1935
- } catch {}
1936
- return selectors;
1937
- }
1938
- function normalizeRuleValue(value) {
1939
- return value.replace(/\s+/g, " ").trim();
1940
- }
1941
- function createRuleKey(rule) {
1942
- const parents = [];
1943
- let parent = rule.parent;
1944
- while (parent && parent.type !== "root") {
1945
- if (parent.type === "atrule") parents.push(`${parent.name}:${normalizeRuleValue(parent.params)}`);
1946
- parent = parent.parent;
1947
- }
1948
- const selectors = (rule.selectors ?? [rule.selector]).map((selector) => normalizeRuleValue(selector)).join(",");
1949
- const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl").map((node) => `${node.prop}:${normalizeRuleValue(node.value)}:${node.important ? "1" : "0"}`).join(";");
1950
- return `${parents.reverse().join("|")}\n${selectors}\n${declarations}`;
1951
- }
1952
- function collectRuleKeysFromCss(css) {
1953
- const keys = /* @__PURE__ */ new Set();
1954
- try {
1955
- postcss.parse(css).walkRules((rule) => {
1956
- keys.add(createRuleKey(rule));
1957
- });
1958
- } catch {}
1959
- return keys;
1960
- }
1961
- function matchesLayerSelector(selector, layerSelector) {
1962
- if (selector === layerSelector) return true;
1963
- if (!selector.startsWith(layerSelector)) return false;
1964
- const next = selector[layerSelector.length];
1965
- return next === ":" || next === "[";
1966
- }
1967
- function removeCssRulesForSelectors(css, layerCss) {
1968
- const selectors = [...collectSelectorsFromCss(layerCss)];
1969
- if (selectors.length === 0) return css;
1970
- try {
1971
- const root = postcss.parse(css);
1972
- root.walkRules((rule) => {
1973
- if ((rule.selectors ?? [rule.selector]).some((selector) => selectors.some((layerSelector) => matchesLayerSelector(selector.trim(), layerSelector)))) rule.remove();
1974
- });
1975
- return root.toString();
1976
- } catch {
1977
- return removeFirstCssOccurrence(css, layerCss);
1978
- }
1979
- }
1980
- function removeExactCssRules(css, duplicateCss) {
1981
- const duplicateKeys = collectRuleKeysFromCss(duplicateCss);
1982
- if (duplicateKeys.size === 0) return css;
1983
- try {
1984
- const root = postcss.parse(css);
1985
- root.walkRules((rule) => {
1986
- if (duplicateKeys.has(createRuleKey(rule))) rule.remove();
1987
- });
1988
- return root.toString();
1989
- } catch {
1990
- return css;
1991
- }
1992
- }
1993
- function wrapUserLayerComponentsCss(css) {
1994
- return css.trim().length > 0 ? `${USER_LAYER_COMPONENTS_START}\n${css}\n${USER_LAYER_COMPONENTS_END}` : css;
1995
- }
1996
- function extractMarkedUserLayerComponentsCss(css) {
1997
- const layers = [];
1998
- let rest = "";
1999
- let cursor = 0;
2000
- while (cursor < css.length) {
2001
- const startIndex = css.indexOf(USER_LAYER_COMPONENTS_START, cursor);
2002
- if (startIndex === -1) {
2003
- rest += css.slice(cursor);
2004
- break;
2005
- }
2006
- rest += css.slice(cursor, startIndex);
2007
- const contentStart = startIndex + 47;
2008
- const endIndex = css.indexOf(USER_LAYER_COMPONENTS_END, contentStart);
2009
- if (endIndex === -1) {
2010
- rest += css.slice(startIndex);
2011
- break;
2012
- }
2013
- const layerCss = css.slice(contentStart, endIndex).trim();
2014
- if (layerCss) layers.push(layerCss);
2015
- cursor = endIndex + 45;
2016
- }
2017
- return {
2018
- layers,
2019
- rest
2020
- };
2021
- }
2022
- function isGeneratedInfrastructureRule(rule) {
2023
- const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
2024
- if (declarations.length === 0) return false;
2025
- if (declarations.every((declaration) => declaration.prop.startsWith("--"))) return true;
2026
- const selectors = (rule.selectors ?? [rule.selector]).map((selector) => selector.trim());
2027
- if (!(selectors.length > 0 && selectors.every((selector) => selector === "view" || selector === "text" || selector === "::before" || selector === "::after"))) return false;
2028
- const declarationMap = new Map(declarations.map((declaration) => [declaration.prop, declaration.value]));
2029
- return declarationMap.get("box-sizing") === "border-box" && declarationMap.has("border");
2030
- }
2031
- function findLayerInsertionIndex(css) {
2032
- try {
2033
- const root = postcss.parse(css);
2034
- let insertionIndex = -1;
2035
- root.walkRules((rule) => {
2036
- if (insertionIndex !== -1 || isGeneratedInfrastructureRule(rule)) return;
2037
- let topLevelNode = rule;
2038
- while (topLevelNode.parent && topLevelNode.parent.type !== "root") topLevelNode = topLevelNode.parent;
2039
- const offset = topLevelNode.source?.start?.offset;
2040
- if (typeof offset === "number") insertionIndex = css.lastIndexOf("\n", Math.max(0, offset - 1)) + 1;
2041
- });
2042
- return insertionIndex;
2043
- } catch {
2044
- return -1;
2045
- }
2046
- }
2047
- function reorderMarkedUserLayerComponentsCss(css) {
2048
- if (!css.includes(USER_LAYER_COMPONENTS_START)) return css;
2049
- const { layers, rest } = extractMarkedUserLayerComponentsCss(css);
2050
- if (layers.length === 0) return rest;
2051
- const layerCss = layers.join("\n");
2052
- const restWithoutLayerDuplicates = removeExactCssRules(rest, layerCss);
2053
- const insertionIndex = findLayerInsertionIndex(restWithoutLayerDuplicates);
2054
- if (insertionIndex === -1) return appendCss(restWithoutLayerDuplicates, layerCss);
2055
- return appendCss(appendCss(restWithoutLayerDuplicates.slice(0, insertionIndex), layerCss), restWithoutLayerDuplicates.slice(insertionIndex));
2056
- }
2057
- function mergeMarkedUserLayerComponentsCss(baseCss, markedCss) {
2058
- if (!markedCss.includes(USER_LAYER_COMPONENTS_START)) return {
2059
- css: baseCss,
2060
- merged: false
2061
- };
2062
- const { layers } = extractMarkedUserLayerComponentsCss(markedCss);
2063
- if (layers.length === 0) return {
2064
- css: baseCss,
2065
- merged: false
2066
- };
2067
- const layerCss = layers.join("\n");
2068
- return {
2069
- css: reorderMarkedUserLayerComponentsCss(appendCss(removeCssRulesForSelectors(baseCss, layerCss), wrapUserLayerComponentsCss(layerCss))),
2070
- merged: true
2071
- };
2072
- }
2073
- //#endregion
2074
- //#region src/bundlers/shared/framework-user-css.ts
2075
- function normalizeUserSource(source) {
2076
- try {
2077
- const root = postcss.parse(source);
2078
- root.walkAtRules("media", (rule) => {
2079
- if (/^source\(/.test(rule.params)) rule.replaceWith(...rule.nodes ?? []);
2080
- });
2081
- return root.toString();
2082
- } catch {
2083
- return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source));
2084
- }
2085
- }
2086
- async function restoreFrameworkProcessedUserCss(css, generated, source, options, generatorOptions) {
2087
- const userCssOptions = {
2088
- generatorTarget: generated.target,
2089
- generatorStyleOptions: resolveGeneratorStyleOptions(options.opts, options.cssHandlerOptions, generatorOptions.styleOptions),
2090
- cssUserHandlerOptions: options.cssUserHandlerOptions,
2091
- styleHandler: options.styleHandler,
2092
- importFallback: generatorOptions.importFallback
2093
- };
2094
- const transform = async (value) => {
2095
- const parts = splitUserCssLayerBlocks(value);
2096
- const layer = await transformGeneratorUserCss(parts.layer, userCssOptions);
2097
- const rest = await transformGeneratorUserCss(parts.rest, userCssOptions);
2098
- return removeTailwindV4GeneratedUserCssArtifacts(finalizeMiniProgramGeneratorCss(createCssSourceOrderAppend(wrapUserLayerComponentsCss(layer), rest), generated.target, options.runtimeState.tailwindRuntime.majorVersion, options.opts.cssPreflight, {
2099
- injectPreflight: false,
2100
- preservePreflight: generated.metadata?.preflightMode?.preserve,
2101
- styleOptions: options.cssHandlerOptions
2102
- }));
2103
- };
2104
- const userSource = normalizeUserSource(source);
2105
- const ordered = splitRawSourceByGeneratedCssOrder(userSource, generated.metadata?.rawCss ?? "") ?? {
2106
- before: "",
2107
- after: userSource
2108
- };
2109
- const withBefore = createCssSourceOrderAppend(filterExistingCssRules(css, await transform(ordered.before)), css);
2110
- return reorderMarkedUserLayerComponentsCss(createCssSourceOrderAppend(withBefore, filterExistingCssRules(withBefore, await transform(ordered.after))));
2111
- }
2112
- //#endregion
2113
- //#region src/bundlers/shared/generator-css/legacy-selectors.ts
2114
- const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
2115
- const MINI_PROGRAM_THEME_SCOPE_SELECTORS = /* @__PURE__ */ new Set([
2116
- ":host",
2117
- "page",
2118
- ".tw-root",
2119
- "wx-root-portal-content"
2120
- ]);
2121
- const SPECIFICITY_PLACEHOLDER_RE = /:not\(#(?:\\#|n)\)/g;
2122
- const SELECTOR_CACHE_LIMIT = 64;
2123
- const LEGACY_PSEUDO_ELEMENTS = [
2124
- "before",
2125
- "after",
2126
- "first-letter",
2127
- "first-line"
2128
- ];
2129
- const generatedSelectorCache = /* @__PURE__ */ new Map();
2130
- function setGeneratedSelectorCache(css, selectors) {
2131
- if (generatedSelectorCache.size >= SELECTOR_CACHE_LIMIT) {
2132
- const firstKey = generatedSelectorCache.keys().next().value;
2133
- if (firstKey !== void 0) generatedSelectorCache.delete(firstKey);
2134
- }
2135
- generatedSelectorCache.set(css, selectors);
2136
- }
2137
- function normalizeCompatSelector(selector) {
2138
- return selector.replace(SPECIFICITY_PLACEHOLDER_RE, "").replace(/\s+/g, " ").trim();
2139
- }
2140
- function isLegacyPseudoElementAt(selector, index) {
2141
- for (const name of LEGACY_PSEUDO_ELEMENTS) {
2142
- if (!selector.startsWith(name, index)) continue;
2143
- const next = selector[index + name.length];
2144
- if (next === void 0 || !/[\w-]/.test(next)) return name;
2145
- }
2146
- }
2147
- function normalizeLegacyPseudoElements(selector) {
2148
- let result = "";
2149
- let quote;
2150
- let bracketDepth = 0;
2151
- let index = 0;
2152
- while (index < selector.length) {
2153
- const char = selector[index];
2154
- if (char === "\\") {
2155
- result += selector.slice(index, index + 2);
2156
- index += 2;
2157
- continue;
2158
- }
2159
- if (quote !== void 0) {
2160
- result += char;
2161
- if (char === quote) quote = void 0;
2162
- index += 1;
2163
- continue;
2164
- }
2165
- if (char === "\"" || char === "'") {
2166
- quote = char;
2167
- result += char;
2168
- index += 1;
2169
- continue;
2170
- }
2171
- if (char === "[") {
2172
- bracketDepth++;
2173
- result += char;
2174
- index += 1;
2175
- continue;
2176
- }
2177
- if (char === "]") {
2178
- bracketDepth = Math.max(0, bracketDepth - 1);
2179
- result += char;
2180
- index += 1;
2181
- continue;
2182
- }
2183
- if (bracketDepth === 0 && char === ":" && selector[index + 1] === ":") {
2184
- result += "::";
2185
- index += 2;
2186
- continue;
2187
- }
2188
- if (bracketDepth === 0 && char === ":") {
2189
- const name = isLegacyPseudoElementAt(selector, index + 1);
2190
- if (name) {
2191
- result += `::${name}`;
2192
- index += name.length + 1;
2193
- continue;
2194
- }
2195
- }
2196
- result += char;
2197
- index += 1;
2198
- }
2199
- return result;
2200
- }
2201
- function isClassSelectorTerminator(char) {
2202
- return /[\s>+~#,.:()[\]]/.test(char);
2203
- }
2204
- function unescapeSimpleCssIdent(value) {
2205
- return value.replaceAll(/\\(.)/g, "$1");
2206
- }
2207
- function escapeCompatSelectorClasses(selector) {
2208
- let result = "";
2209
- let index = 0;
2210
- let changed = false;
2211
- while (index < selector.length) {
2212
- const char = selector[index];
2213
- if (char !== ".") {
2214
- result += char;
2215
- index += 1;
2216
- continue;
2217
- }
2218
- let end = index + 1;
2219
- let className = "";
2220
- while (end < selector.length) {
2221
- const current = selector[end];
2222
- if (current === void 0) break;
2223
- if (current === "\\" && end + 1 < selector.length) {
2224
- const escaped = selector[end + 1];
2225
- if (escaped === void 0) break;
2226
- className += current + escaped;
2227
- end += 2;
2228
- continue;
2229
- }
2230
- if (isClassSelectorTerminator(current)) break;
2231
- className += current;
2232
- end += 1;
2233
- }
2234
- if (className.includes("\\")) {
2235
- result += `.${replaceWxml(unescapeSimpleCssIdent(className))}`;
2236
- changed = true;
2237
- } else result += `.${className}`;
2238
- index = end;
2239
- }
2240
- return changed ? result : selector;
2241
- }
2242
- function normalizeCompatSelectors(selector) {
2243
- const normalized = normalizeCompatSelector(selector);
2244
- if (!normalized) return [];
2245
- const selectors = /* @__PURE__ */ new Set([normalized]);
2246
- const escaped = normalizeCompatSelector(escapeCompatSelectorClasses(normalized));
2247
- if (escaped) selectors.add(escaped);
2248
- return [...selectors];
2249
- }
2250
- function normalizeCssSelector(selector) {
2251
- return normalizeLegacyPseudoElements(selector).trim().replace(/\s+/g, "");
2252
- }
2253
- function getCompatSelectorKeys(selector) {
2254
- return normalizeCompatSelectors(selector).map(normalizeCssSelector);
2255
- }
2256
- function getRuleCompatSelectorKeys(rule) {
2257
- return (rule.selectors?.length ? rule.selectors : [rule.selector]).flatMap((selector) => getCompatSelectorKeys(selector));
2258
- }
2259
- function hasClassSelector(selector) {
2260
- return CLASS_SELECTOR_RE.test(selector);
2261
- }
2262
- function getNormalizedSelectorList(selector) {
2263
- return selector.split(",").map(normalizeCssSelector).filter(Boolean);
2264
- }
2265
- function isMiniProgramThemeScopeSelector(selector) {
2266
- const selectors = getNormalizedSelectorList(selector);
2267
- return selectors.length > 0 && selectors.every((item) => MINI_PROGRAM_THEME_SCOPE_SELECTORS.has(item));
2268
- }
2269
- function hasUtilityClassSelector(selector) {
2270
- return hasClassSelector(selector) && !isMiniProgramThemeScopeSelector(selector);
2271
- }
2272
- function isCustomPropertyOnlyRule(rule) {
2273
- let hasDeclaration = false;
2274
- let allCustomProperties = true;
2275
- rule.each((node) => {
2276
- if (node.type !== "decl") return;
2277
- hasDeclaration = true;
2278
- if (!node.prop.startsWith("--")) allCustomProperties = false;
2279
- });
2280
- return hasDeclaration && allCustomProperties;
2281
- }
2282
- function isPseudoContentInitRule(rule) {
2283
- let hasDeclaration = false;
2284
- let onlyContentVariable = true;
2285
- rule.each((node) => {
2286
- if (node.type !== "decl") return;
2287
- hasDeclaration = true;
2288
- if (node.prop !== "--tw-content") onlyContentVariable = false;
2289
- });
2290
- return hasDeclaration && onlyContentVariable;
2291
- }
2292
- function collectGeneratedSelectors(css) {
2293
- const cached = generatedSelectorCache.get(css);
2294
- if (cached) return cached;
2295
- const selectors = /* @__PURE__ */ new Set();
2296
- try {
2297
- postcss.parse(css).walkRules((rule) => {
2298
- if (isCustomPropertyOnlyRule(rule) && !isPseudoContentInitRule(rule) && !hasUtilityClassSelector(rule.selector)) return;
2299
- for (const selector of getRuleCompatSelectorKeys(rule)) selectors.add(selector);
2300
- });
2301
- } catch {
2302
- return selectors;
2303
- }
2304
- setGeneratedSelectorCache(css, selectors);
2305
- return selectors;
2306
- }
2307
- function collectGeneratedDeclarationPropsBySelector(generatedCss, selectors) {
2308
- const propsBySelector = /* @__PURE__ */ new Map();
2309
- try {
2310
- postcss.parse(generatedCss).walkRules((rule) => {
2311
- const matchedSelectors = getRuleCompatSelectorKeys(rule).filter((selector) => selectors.has(selector));
2312
- if (matchedSelectors.length === 0) return;
2313
- const props = /* @__PURE__ */ new Set();
2314
- rule.walkDecls((decl) => {
2315
- props.add(decl.prop);
2316
- });
2317
- for (const selector of matchedSelectors) {
2318
- const existing = propsBySelector.get(selector);
2319
- if (existing) for (const prop of props) existing.add(prop);
2320
- else propsBySelector.set(selector, new Set(props));
2321
- }
2322
- });
2323
- } catch {
2324
- return propsBySelector;
2325
- }
2326
- return propsBySelector;
2327
- }
2328
- function isRuleCoveredByGeneratedProps(rule, generatedDeclarationPropsBySelector) {
2329
- const nodeSelectors = getRuleCompatSelectorKeys(rule);
2330
- if (nodeSelectors.length === 0) return false;
2331
- const props = /* @__PURE__ */ new Set();
2332
- rule.walkDecls((decl) => {
2333
- props.add(decl.prop);
1618
+ ...preservePreflight === void 0 ? {} : { preservePreflight },
1619
+ styleOptions: options.cssHandlerOptions
2334
1620
  });
2335
- if (props.size === 0) return false;
2336
- for (const selector of nodeSelectors) {
2337
- const generatedProps = generatedDeclarationPropsBySelector.get(selector);
2338
- if (!generatedProps) continue;
2339
- if ([...props].every((prop) => generatedProps.has(prop))) return true;
2340
- }
2341
- return false;
2342
- }
2343
- function removeGeneratedSelectorCompatCss(css, generatedCss) {
2344
- const generatedSelectors = collectGeneratedSelectors(generatedCss);
2345
- if (generatedSelectors.size === 0) return css;
2346
- try {
2347
- const root = postcss.parse(css);
2348
- let removed = false;
2349
- root.walkRules((rule) => {
2350
- if (isPseudoContentInitRule(rule)) {
2351
- rule.remove();
2352
- removed = true;
2353
- return;
2354
- }
2355
- if (isCustomPropertyOnlyRule(rule) && !isPseudoContentInitRule(rule) && !hasUtilityClassSelector(rule.selector)) return;
2356
- if (getRuleCompatSelectorKeys(rule).some((selector) => generatedSelectors.has(selector))) {
2357
- rule.remove();
2358
- removed = true;
2359
- }
2360
- });
2361
- root.walkAtRules((atRule) => {
2362
- if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
2363
- });
2364
- return removed ? root.toString() : css;
2365
- } catch {
2366
- return css;
2367
- }
2368
1621
  }
2369
- function collectDedupedPostTransformCompatCss(css, generatedCss) {
2370
- const generatedSelectors = collectGeneratedSelectors(generatedCss);
2371
- if (generatedSelectors.size === 0) return css;
2372
- const generatedDeclarationPropsBySelector = collectGeneratedDeclarationPropsBySelector(generatedCss, generatedSelectors);
2373
- const preservedNodes = [];
2374
- try {
2375
- const root = postcss.parse(css);
2376
- root.each((node) => {
2377
- if (node.type === "rule") {
2378
- const nodeSelectors = getRuleCompatSelectorKeys(node);
2379
- if (!nodeSelectors.some((selector) => generatedSelectors.has(selector))) {
2380
- preservedNodes.push(node.clone());
2381
- return;
2382
- }
2383
- if (isRuleCoveredByGeneratedProps(node, generatedDeclarationPropsBySelector)) return;
2384
- if (isCustomPropertyOnlyRule(node) && !isPseudoContentInitRule(node) && !hasUtilityClassSelector(node.selector)) {
2385
- const declarationProps = /* @__PURE__ */ new Set();
2386
- node.walkDecls((decl) => {
2387
- declarationProps.add(decl.prop);
2388
- });
2389
- for (const selector of nodeSelectors) {
2390
- const generatedProps = generatedDeclarationPropsBySelector.get(selector);
2391
- if (!generatedProps) continue;
2392
- for (const prop of generatedProps) declarationProps.delete(prop);
2393
- }
2394
- const nextRule = node.clone();
2395
- nextRule.walkDecls((decl) => {
2396
- if (!declarationProps.has(decl.prop)) decl.remove();
2397
- });
2398
- if (nextRule.nodes.length > 0) preservedNodes.push(nextRule);
2399
- }
2400
- return;
2401
- }
2402
- preservedNodes.push(node.clone());
2403
- });
2404
- if (preservedNodes.length === root.nodes.length) return css;
2405
- const nextRoot = postcss.root();
2406
- nextRoot.append(preservedNodes);
2407
- return nextRoot.toString();
2408
- } catch {
2409
- return css;
2410
- }
1622
+ //#endregion
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;
2411
1628
  }
2412
- function removeDuplicatedViteMarkers(css, baseCss) {
2413
- if (!VITE_MARKER_RE.test(baseCss)) return css;
2414
- VITE_MARKER_RE.lastIndex = 0;
2415
- return css.replace(VITE_MARKER_RE, "");
1629
+ //#endregion
1630
+ //#region src/generation/framework-user-css.ts
1631
+ async function restoreFrameworkProcessedUserCss(css, generated, source, options, generatorOptions) {
1632
+ const generatedSource = createGeneratedThemeDeclarationResolver([generated.metadata?.rawCss, css].filter(Boolean).join("\n"));
1633
+ const userCssOptions = {
1634
+ compileAuthorCssFunctions: generated.compileAuthorCssFunctions,
1635
+ generatorTarget: generated.target,
1636
+ generatedSource,
1637
+ generatorStyleOptions: resolveGeneratorStyleOptions(options.opts, options.cssHandlerOptions, generatorOptions.styleOptions),
1638
+ cssUserHandlerOptions: options.cssUserHandlerOptions,
1639
+ styleHandler: options.styleHandler,
1640
+ importFallback: generatorOptions.importFallback
1641
+ };
1642
+ const transform = async (value) => {
1643
+ const parts = splitUserCssLayerBlocks(value);
1644
+ const layer = await transformGeneratorUserCss(parts.layer, userCssOptions);
1645
+ const rest = await transformGeneratorUserCss(parts.rest, userCssOptions);
1646
+ return removeTailwindV4GeneratedUserCssArtifacts(finalizeMiniProgramGeneratorCss(createCssSourceOrderAppend(wrapUserLayerComponentsCss(layer), rest), generated.target, options.runtimeState.tailwindRuntime.majorVersion, options.opts.cssPreflight, {
1647
+ injectPreflight: false,
1648
+ preservePreflight: generated.metadata?.preflightMode?.preserve,
1649
+ styleOptions: options.cssHandlerOptions
1650
+ }), generatedSource);
1651
+ };
1652
+ const userSource = normalizeFrameworkProcessedUserCss(source);
1653
+ const ordered = splitRawSourceByGeneratedCssOrder(userSource, generated.metadata?.rawCss ?? "") ?? {
1654
+ before: "",
1655
+ after: userSource
1656
+ };
1657
+ const before = await transform(ordered.before);
1658
+ const after = await transform(ordered.after);
1659
+ return stripTailwindBanners(reorderMarkedUserLayerComponentsCss(composeFrameworkProcessedCss(before, css, after)));
2416
1660
  }
2417
1661
  //#endregion
2418
- //#region src/bundlers/shared/generator-css/source-resolver/metadata.ts
1662
+ //#region src/generation/source-resolver/metadata.ts
2419
1663
  const generatorSourceMetadataKey = Symbol.for("weapp-tailwindcss.generator-source-metadata");
2420
1664
  function getGeneratorSourceMetadata(source) {
2421
1665
  return source[generatorSourceMetadataKey];
@@ -2443,7 +1687,7 @@ function withMatchedSourceSideMetadata(source, resolvedEntrySource, metadata = {
2443
1687
  }) : source;
2444
1688
  }
2445
1689
  //#endregion
2446
- //#region src/bundlers/shared/generator-css/source-files.ts
1690
+ //#region src/generation/source-files.ts
2447
1691
  const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
2448
1692
  const STYLE_IMPORT_EXTENSIONS = [
2449
1693
  ".css",
@@ -2626,7 +1870,7 @@ function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {
2626
1870
  if (source === void 0) continue;
2627
1871
  const directiveSources = extractStyleDirectiveSourcesDeep(source, sourceFile, /* @__PURE__ */ new Set([path.resolve(sourceFile)]));
2628
1872
  for (const styleSource of directiveSources) {
2629
- const cssEntrySource = resolveCssEntrySource(styleSource.source, path.dirname(styleSource.file), resolveOptions);
1873
+ const cssEntrySource = resolveCssEntrySource$1(styleSource.source, path.dirname(styleSource.file), resolveOptions);
2630
1874
  if (cssEntrySource) return {
2631
1875
  ...cssEntrySource,
2632
1876
  file: styleSource.file
@@ -2637,95 +1881,18 @@ function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {
2637
1881
  }
2638
1882
  }
2639
1883
  //#endregion
2640
- //#region src/bundlers/shared/generator-css/candidates.ts
2641
- function parseGeneratorCss(css) {
2642
- let root;
2643
- try {
2644
- root = postcss.parse(css);
2645
- } catch {
2646
- return;
2647
- }
2648
- return root;
2649
- }
2650
- function collectApplyCandidates(root) {
2651
- const candidates = /* @__PURE__ */ new Set();
2652
- root.walkAtRules("apply", (rule) => {
2653
- for (const candidate of splitCandidateTokens(rule.params)) candidates.add(candidate);
2654
- });
2655
- return candidates;
2656
- }
2657
- function collectCssApplyCandidates(css) {
2658
- const root = parseGeneratorCss(css);
2659
- return root ? [...collectApplyCandidates(root)].sort() : [];
2660
- }
2661
- function collectGeneratorCssCandidates(css) {
2662
- const root = parseGeneratorCss(css);
2663
- if (!root) return [];
2664
- const candidates = collectApplyCandidates(root);
2665
- const inlineCandidates = collectCssInlineSourceCandidates(root);
2666
- for (const candidate of inlineCandidates.included) candidates.add(candidate);
2667
- for (const candidate of inlineCandidates.excluded) candidates.delete(candidate);
2668
- return [...candidates].sort();
2669
- }
2670
- //#endregion
2671
- //#region src/bundlers/shared/generator-css/source-resolver/apply-reference.ts
1884
+ //#region src/generation/source-resolver/apply-reference.ts
2672
1885
  function resolveTailwindV4ApplyReference(options) {
2673
1886
  const references = /* @__PURE__ */ new Set();
2674
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);
2675
1888
  return references.size === 1 ? references.values().next().value : void 0;
2676
1889
  }
2677
- function hasTailwindApplyContextDirective(css) {
2678
- try {
2679
- let found = false;
2680
- postcss.parse(css).walkAtRules((rule) => {
2681
- if (rule.name === "theme" || rule.name === "config") {
2682
- found = true;
2683
- return false;
2684
- }
2685
- });
2686
- return found;
2687
- } catch {
2688
- return false;
2689
- }
2690
- }
2691
1890
  function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
2692
1891
  const reference = resolveTailwindV4ApplyReference(sourceOptions);
2693
1892
  return createTailwindV4SourceReferenceSource(css, sourceOptions, reference ? `@reference ${JSON.stringify(reference.replace(/\\/g, "/"))};` : void 0);
2694
1893
  }
2695
- function createTailwindV4SourceReferenceSource(css, sourceOptions, referenceDirective) {
2696
- if (hasTailwindV4RootImport(css, sourceOptions)) return css;
2697
- const hasApplyDirective = hasTailwindApplyDirective(css);
2698
- if (!hasApplyDirective && !hasTailwindSourceDirectives(css, { importFallback: true })) return css;
2699
- const utilities = hasApplyDirective ? collectCssApplyCandidates(css) : [];
2700
- return [
2701
- referenceDirective ?? `@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
2702
- utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
2703
- css
2704
- ].filter(Boolean).join("\n");
2705
- }
2706
- function hasTailwindV4RootImport(css, sourceOptions) {
2707
- try {
2708
- const root = postcss.parse(css);
2709
- let found = false;
2710
- root.walkAtRules((rule) => {
2711
- if (rule.name === "tailwind") {
2712
- found = true;
2713
- return false;
2714
- }
2715
- if (rule.name !== "import" && rule.name !== "use" && rule.name !== "forward") return;
2716
- const request = parseImportRequest(rule.params);
2717
- if (request === (sourceOptions.packageName ?? "tailwindcss") || request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/")) {
2718
- found = true;
2719
- return false;
2720
- }
2721
- });
2722
- return found;
2723
- } catch {
2724
- return /@(?:import|use|forward|tailwind)(?:[\s"'(;]|$)/.test(css) && (css.includes("tailwindcss") || css.includes("tailwindcss4") || css.includes("weapp-tailwindcss"));
2725
- }
2726
- }
2727
1894
  //#endregion
2728
- //#region src/bundlers/shared/generator-css/source-resolver/config.ts
1895
+ //#region src/generation/source-resolver/config.ts
2729
1896
  function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
2730
1897
  if (config && existsSync(config)) return config;
2731
1898
  if (!configRequest || path.isAbsolute(configRequest)) return sourceOptions.config;
@@ -2753,7 +1920,7 @@ function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
2753
1920
  return sourceOptions.config;
2754
1921
  }
2755
1922
  //#endregion
2756
- //#region src/bundlers/shared/generator-css/source-resolver/matching.ts
1923
+ //#region src/generation/source-resolver/matching.ts
2757
1924
  function normalizeCssSourceForCompare(css) {
2758
1925
  return stripGeneratorPlaceholderMarkers(stripTailwindBanners(css)).trim();
2759
1926
  }
@@ -2827,7 +1994,7 @@ function scoreTailwindV4CssSourceFileMatch(file, cssSourceFile, sourceOptions) {
2827
1994
  return bestScore;
2828
1995
  }
2829
1996
  //#endregion
2830
- //#region src/bundlers/shared/generator-css/source-resolver/configuration.ts
1997
+ //#region src/generation/source-resolver/configuration.ts
2831
1998
  function createCssEntrySources(cssEntries) {
2832
1999
  return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && path.isAbsolute(entry)).map((entry) => ({ file: path.resolve(entry) }));
2833
2000
  }
@@ -2854,7 +2021,7 @@ function resolveUniqueTailwindV4CssConfig(sourceOptions) {
2854
2021
  const configs = /* @__PURE__ */ new Set();
2855
2022
  const collect = (css, base) => {
2856
2023
  if (!css || !base || !css.includes("@config")) return;
2857
- const source = resolveCssEntrySource(css, base, { removeConfig: false });
2024
+ const source = resolveCssEntrySource$1(css, base, { removeConfig: false });
2858
2025
  if (source?.config) configs.add(path.resolve(source.config));
2859
2026
  };
2860
2027
  collect(sourceOptions.css, sourceOptions.base ?? sourceOptions.projectRoot);
@@ -2887,7 +2054,7 @@ async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions, options
2887
2054
  });
2888
2055
  const css = readFileSync(cssEntry, "utf8");
2889
2056
  const base = path.dirname(path.resolve(cssEntry));
2890
- const entrySource = resolveCssEntrySource(css, base, { removeConfig: false });
2057
+ const entrySource = resolveCssEntrySource$1(css, base, { removeConfig: false });
2891
2058
  const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, cssEntry, {
2892
2059
  ...sourceOptions,
2893
2060
  sourceFile: sourceOptions.sourceFile ?? cssEntry
@@ -2895,7 +2062,7 @@ async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions, options
2895
2062
  return withGeneratorSourceMetadata(await resolveTailwindV4Source$1({
2896
2063
  ...omitUndefined(singleEntrySourceOptions),
2897
2064
  base,
2898
- css: normalizeConfigDirective(css, config),
2065
+ css: normalizeConfigDirective$1(css, config),
2899
2066
  cssEntries: [cssEntry]
2900
2067
  }), {
2901
2068
  candidateMatchedCssSource: options.candidateMatched,
@@ -2917,20 +2084,20 @@ function shouldResolveSourceSideCssEntry(rawSource) {
2917
2084
  }
2918
2085
  function normalizeTailwindV4CssSourceConfig(cssSource, sourceBase) {
2919
2086
  if (typeof cssSource.css !== "string" || cssSource.css.length === 0 || !cssSource.css.includes("@config")) return cssSource;
2920
- const entrySource = resolveCssEntrySource(cssSource.css, sourceBase, { removeConfig: false });
2087
+ const entrySource = resolveCssEntrySource$1(cssSource.css, sourceBase, { removeConfig: false });
2921
2088
  if (!entrySource?.config) return cssSource;
2922
2089
  return {
2923
2090
  ...cssSource,
2924
- css: normalizeConfigDirective(cssSource.css, entrySource.config)
2091
+ css: normalizeConfigDirective$1(cssSource.css, entrySource.config)
2925
2092
  };
2926
2093
  }
2927
2094
  function normalizeResolvedTailwindV4SourceConfig(source, file, sourceOptions) {
2928
2095
  if (!("css" in source) || typeof source.css !== "string" || !source.css.includes("@config")) return source;
2929
2096
  const sourceFile = typeof file === "string" && file.length > 0 ? file : getGeneratorSourceMetadata(source)?.matchedCssSourceFile;
2930
2097
  if (!sourceFile) return source;
2931
- 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 });
2932
2099
  const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, sourceFile, sourceOptions ?? {});
2933
- const normalizedCss = normalizeConfigDirective(source.css, config);
2100
+ const normalizedCss = normalizeConfigDirective$1(source.css, config);
2934
2101
  return normalizedCss === source.css ? source : {
2935
2102
  ...source,
2936
2103
  css: normalizedCss
@@ -2979,7 +2146,7 @@ function isSameTailwindV4CssSource(a, b) {
2979
2146
  return typeof a.css === "string" && typeof b.css === "string" && normalizeCssSourceForCompare(a.css) === normalizeCssSourceForCompare(b.css);
2980
2147
  }
2981
2148
  //#endregion
2982
- //#region src/bundlers/shared/generator-css/source-resolver/single-source.ts
2149
+ //#region src/generation/source-resolver/single-source.ts
2983
2150
  async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, options = {}) {
2984
2151
  const sourceBaseFallback = sourceOptions.base ?? sourceOptions.projectRoot ?? process.cwd();
2985
2152
  const sourceBase = resolveTailwindV4CssSourceBase(cssSource, sourceBaseFallback);
@@ -3094,7 +2261,7 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
3094
2261
  ...resolvedSourceOptions,
3095
2262
  sourceFile: resolvedEntrySource.file
3096
2263
  });
3097
- 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);
3098
2265
  const source = await resolveTailwindV4Source$1(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
3099
2266
  base: currentCss && config ? path.dirname(config) : resolvedEntrySource.base,
3100
2267
  css,
@@ -3111,7 +2278,7 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
3111
2278
  });
3112
2279
  }
3113
2280
  //#endregion
3114
- //#region src/bundlers/shared/generator-css/source-resolver/source-matching.ts
2281
+ //#region src/generation/source-resolver/source-matching.ts
3115
2282
  async function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
3116
2283
  const cssEntries = sourceOptions.cssEntries;
3117
2284
  if (!cssEntries?.length) return;
@@ -3173,10 +2340,10 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
3173
2340
  });
3174
2341
  }
3175
2342
  //#endregion
3176
- //#region src/bundlers/shared/generator-css/source-resolver/resolve-source.ts
2343
+ //#region src/generation/source-resolver/resolve-source.ts
3177
2344
  async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
3178
2345
  const base = resolveCssSourceBase(file, cssHandlerOptions);
3179
- const cssEntrySource = resolveCssEntrySource(rawSource, base, {
2346
+ const cssEntrySource = resolveCssEntrySource$1(rawSource, base, {
3180
2347
  importFallback: generatorOptions?.importFallback ?? false,
3181
2348
  removeConfig: false
3182
2349
  });
@@ -3195,7 +2362,7 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
3195
2362
  const normalizedSourceOptions = resolvedSourceOptions ? normalizeTailwindV4CssSourceConfigs(resolvedSourceOptions) : void 0;
3196
2363
  if (applyEntrySource && !cssHandlerOptions.isMainChunk && !hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
3197
2364
  const config = generatorOptions?.config ?? (normalizedSourceOptions ? resolveUniqueTailwindV4CssConfig(normalizedSourceOptions) : void 0);
3198
- const css = createTailwindV4ApplyReferenceSource(normalizeConfigDirective(prependConfigDirective(applyEntrySource.css, config), void 0), normalizedSourceOptions ?? {});
2365
+ const css = createTailwindV4ApplyReferenceSource(normalizeConfigDirective$1(prependConfigDirective(applyEntrySource.css, config), void 0), normalizedSourceOptions ?? {});
3199
2366
  return resolveTailwindV4Source$1(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
3200
2367
  base: applyEntrySource.base,
3201
2368
  css
@@ -3203,7 +2370,8 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
3203
2370
  }
3204
2371
  const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions?.cssEntries?.length ?? 0) <= 1;
3205
2372
  const sourceSideEntrySource = normalizedSourceOptions && (shouldPreferSourceSideEntry || normalizedSourceOptions.sourceFile !== void 0) && canResolveSourceSideCssEntry(file, cssHandlerOptions, normalizedSourceOptions) ? resolveSourceSideCssEntrySource(file, normalizedSourceOptions, { removeConfig: false }) : void 0;
3206
- const sourceSideCssSource = sourceSideEntrySource?.file && (sourceOptions?.cssEntries?.some((cssEntry) => path.resolve(cssEntry.replace(/[?#].*$/, "")) === path.resolve(sourceSideEntrySource.file)) || isSfcStyleSourceRequest(file) && sourceOptions?.cssSources?.some((cssSource) => typeof cssSource.file === "string" && path.resolve(cssSource.file.replace(/[?#].*$/, "")) === path.resolve(sourceSideEntrySource.file))) ? await resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file, rawSource) : void 0;
2373
+ const shouldPreferMatchedSourceSideCssSource = sourceSideEntrySource?.file && (sourceOptions?.cssEntries?.some((cssEntry) => path.resolve(cssEntry.replace(/[?#].*$/, "")) === path.resolve(sourceSideEntrySource.file)) || isSfcStyleSourceRequest(file) && sourceOptions?.cssSources?.some((cssSource) => typeof cssSource.file === "string" && path.resolve(cssSource.file.replace(/[?#].*$/, "")) === path.resolve(sourceSideEntrySource.file)));
2374
+ const sourceSideCssSource = normalizedSourceOptions && shouldPreferMatchedSourceSideCssSource ? await resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file, rawSource) : void 0;
3207
2375
  if (sourceSideCssSource) return sourceSideCssSource;
3208
2376
  const matchedCssEntrySource = normalizedSourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, normalizedSourceOptions) : void 0;
3209
2377
  const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
@@ -3238,17 +2406,17 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
3238
2406
  sourceFile: resolvedEntrySource.file ?? resolvedSourceOptions?.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions)
3239
2407
  }));
3240
2408
  const sourceBase = resolvedEntrySource === cssEntrySource && config ? path.dirname(config) : resolvedEntrySource.base;
3241
- 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 ?? {});
3242
2410
  return resolveTailwindV4Source$1(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
3243
2411
  base: sourceBase,
3244
2412
  css
3245
2413
  }));
3246
2414
  }
3247
2415
  //#endregion
3248
- //#region src/bundlers/shared/generator-css/source-resolver/resolve-sources.ts
2416
+ //#region src/generation/source-resolver/resolve-sources.ts
3249
2417
  async function resolveGeneratorResolvedSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
3250
2418
  const base = resolveCssSourceBase(file, cssHandlerOptions);
3251
- const cssEntrySource = resolveCssEntrySource(rawSource, base, {
2419
+ const cssEntrySource = resolveCssEntrySource$1(rawSource, base, {
3252
2420
  importFallback: generatorOptions?.importFallback ?? false,
3253
2421
  removeConfig: false
3254
2422
  });
@@ -3312,7 +2480,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
3312
2480
  return (await resolveGeneratorResolvedSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions)).map(createGeneratorSourceRecord);
3313
2481
  }
3314
2482
  //#endregion
3315
- //#region src/bundlers/shared/generator-css/source-resolver/source-entries.ts
2483
+ //#region src/generation/source-resolver/source-entries.ts
3316
2484
  async function resolveGeneratorSourceEntries(record, runtimeState) {
3317
2485
  const { metadata: sourceMetadata, source } = record;
3318
2486
  if (sourceMetadata?.sourceEntries) return sourceMetadata.sourceEntries;
@@ -3340,7 +2508,7 @@ async function resolveGeneratorSourceEntries(record, runtimeState) {
3340
2508
  return resolved?.entries;
3341
2509
  }
3342
2510
  //#endregion
3343
- //#region src/bundlers/shared/generator-css/legacy-compat.ts
2511
+ //#region src/generation/legacy-compat.ts
3344
2512
  const LEGACY_CONTAINER_COMPAT_CSS = [
3345
2513
  ".container {",
3346
2514
  " width: 100%;",
@@ -3393,112 +2561,20 @@ function createStableJson(value) {
3393
2561
  function createLegacyCompatTransformCacheKey(source, options) {
3394
2562
  return `${createStableJson(options)}\0${source}`;
3395
2563
  }
3396
- function countUnclosedBlocks(source) {
3397
- let depth = 0;
3398
- let quote;
3399
- let inComment = false;
3400
- let escaped = false;
3401
- for (let index = 0; index < source.length; index += 1) {
3402
- const char = source[index];
3403
- const next = source[index + 1];
3404
- if (inComment) {
3405
- if (char === "*" && next === "/") {
3406
- inComment = false;
3407
- index += 1;
3408
- }
3409
- continue;
3410
- }
3411
- if (quote) {
3412
- if (escaped) {
3413
- escaped = false;
3414
- continue;
3415
- }
3416
- if (char === "\\") {
3417
- escaped = true;
3418
- continue;
3419
- }
3420
- if (char === quote) quote = void 0;
3421
- continue;
3422
- }
3423
- if (char === "/" && next === "*") {
3424
- inComment = true;
3425
- index += 1;
3426
- continue;
3427
- }
3428
- if (char === "\"" || char === "'") {
3429
- quote = char;
3430
- continue;
3431
- }
3432
- if (char === "{") depth += 1;
3433
- else if (char === "}" && depth > 0) depth -= 1;
3434
- }
3435
- return depth;
3436
- }
3437
- function closeTrailingUnclosedBlocks(source) {
3438
- try {
3439
- postcss.parse(source);
3440
- return source;
3441
- } catch (error) {
3442
- if (error.reason !== "Unclosed block") return source;
3443
- const unclosedBlocks = countUnclosedBlocks(source);
3444
- return unclosedBlocks > 0 ? `${source}${"}".repeat(unclosedBlocks)}` : source;
3445
- }
3446
- }
3447
- function removeTailwindApplyRules(rawSource) {
3448
- try {
3449
- const root = postcss.parse(rawSource);
3450
- let removed = false;
3451
- root.walkAtRules("apply", (rule) => {
3452
- const parent = rule.parent;
3453
- if (parent?.type === "rule") parent.remove();
3454
- else rule.remove();
3455
- removed = true;
3456
- });
3457
- root.walkAtRules((rule) => {
3458
- if (rule.nodes && rule.nodes.length === 0) rule.remove();
3459
- });
3460
- return removed ? root.toString() : rawSource;
3461
- } catch {
3462
- return rawSource;
3463
- }
3464
- }
3465
2564
  function resolveLegacyCompatCssSource(rawSource) {
3466
2565
  const cached = legacyCompatSourceCache.get(rawSource);
3467
2566
  if (cached !== void 0) return cached;
3468
- const parseableSource = closeTrailingUnclosedBlocks(stripTailwindBanners(rawSource));
3469
- const source = removeTailwindSourceDirectives(parseableSource);
3470
- const resolved = closeTrailingUnclosedBlocks(removeTailwindV4GeneratedUserCssArtifacts(removeUnsupportedMiniProgramAtRules(removeTailwindApplyRules(source))));
2567
+ const resolved = normalizeLegacyCompatCssSource(rawSource);
3471
2568
  setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
3472
2569
  return resolved;
3473
2570
  }
3474
- function removeMiniProgramContainerCompatCss(css) {
3475
- try {
3476
- const root = postcss.parse(css);
3477
- let removed = false;
3478
- root.walkRules((rule) => {
3479
- if (rule.selectors?.length === 1 && rule.selectors[0] === ".container") {
3480
- rule.remove();
3481
- removed = true;
3482
- }
3483
- });
3484
- root.walkAtRules((atRule) => {
3485
- if (atRule.nodes && atRule.nodes.length === 0) {
3486
- atRule.remove();
3487
- removed = true;
3488
- }
3489
- });
3490
- return removed ? root.toString() : css;
3491
- } catch {
3492
- return css;
3493
- }
3494
- }
3495
2571
  function hasContainerConfigToken(rawSource) {
3496
2572
  return rawSource.includes("@config") && /\bcontainer\b/.test(rawSource);
3497
2573
  }
3498
2574
  function hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) {
3499
2575
  if (hasContainerConfigToken(rawSource)) return true;
3500
2576
  const base = resolveCssSourceBase(file, cssHandlerOptions);
3501
- const cssEntrySource = resolveCssEntrySource(rawSource, base);
2577
+ const cssEntrySource = resolveCssEntrySource$1(rawSource, base);
3502
2578
  if (!cssEntrySource?.config) return false;
3503
2579
  try {
3504
2580
  return /\bcontainer\b/.test(readFileSync(cssEntrySource.config, "utf8"));
@@ -3509,7 +2585,7 @@ function hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) {
3509
2585
  function hasConfiguredContainerCompatSource(source) {
3510
2586
  if (typeof source.css !== "string") return false;
3511
2587
  if (hasContainerConfigToken(source.css)) return true;
3512
- const cssEntrySource = resolveCssEntrySource(source.css, source.base);
2588
+ const cssEntrySource = resolveCssEntrySource$1(source.css, source.base);
3513
2589
  if (cssEntrySource?.config) try {
3514
2590
  if (/\bcontainer\b/.test(readFileSync(cssEntrySource.config, "utf8"))) return true;
3515
2591
  } catch {}
@@ -3524,8 +2600,9 @@ function hasConfiguredContainerCompatSources(sources) {
3524
2600
  async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandler, cssHandlerOptions, generatorStyleOptions, options = {}) {
3525
2601
  const resolvedCompatSource = resolveLegacyCompatCssSource(rawSource);
3526
2602
  const normalizedCompatSource = generatorTarget === "weapp" ? removeMiniProgramContainerCompatCss(resolvedCompatSource) : resolvedCompatSource;
3527
- const compatSource = options.preserveSelectorOverrides ? normalizedCompatSource : removeGeneratedSelectorCompatCss(normalizedCompatSource, css);
3528
- if (compatSource.trim().length === 0) return css;
2603
+ const filteredCompatSource = options.preserveSelectorOverrides ? normalizedCompatSource : removeGeneratedSelectorCompatCss(normalizedCompatSource, css);
2604
+ if (filteredCompatSource.trim().length === 0) return css;
2605
+ const compatSource = await options.compileAuthorCssFunctions?.(filteredCompatSource) ?? filteredCompatSource;
3529
2606
  if (generatorTarget !== "weapp") return createCssAppend(css, compatSource);
3530
2607
  const styleOptions = {
3531
2608
  ...cssHandlerOptions,
@@ -3537,7 +2614,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
3537
2614
  compatCss = (await styleHandler(compatSource, styleOptions)).css;
3538
2615
  setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
3539
2616
  }
3540
- const transformedCompatCss = removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers(removeUnsupportedMiniProgramAtRules(compatCss), css));
2617
+ const transformedCompatCss = removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers(removeUnsupportedMiniProgramAtRules(compatCss), css), options.generatedSource ?? css);
3541
2618
  const cleanedCompatCss = options.preserveSelectorOverrides ? filterExistingCssRules(css, transformedCompatCss) : collectDedupedPostTransformCompatCss(transformedCompatCss, css);
3542
2619
  if (cleanedCompatCss.trim().length === 0) return css;
3543
2620
  return createCssAppend(css, cleanedCompatCss);
@@ -3562,139 +2639,7 @@ async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, con
3562
2639
  return createCssAppend(css, cleanedCompatCss);
3563
2640
  }
3564
2641
  //#endregion
3565
- //#region src/bundlers/shared/generator-css/legacy-units.ts
3566
- const CSS_LENGTH_UNIT_RE = /(?:^|[\s(,])[-+]?(?:\d+|\d*\.\d+)(?:px|rem)\b/i;
3567
- const RPX_UNIT_RE = /(?:^|[\s(,])[-+]?(?:\d+|\d*\.\d+)rpx\b/i;
3568
- function createLegacyDeclarationValueMap(css) {
3569
- const values = /* @__PURE__ */ new Map();
3570
- postcss.parse(css).walkRules((rule) => {
3571
- if (!rule.selectors || rule.selectors.length === 0) return;
3572
- for (const selector of rule.selectors) {
3573
- const normalizedSelectors = normalizeCompatSelectors(selector);
3574
- rule.walkDecls((decl) => {
3575
- if (RPX_UNIT_RE.test(decl.value)) for (const normalizedSelector of normalizedSelectors) values.set(`${normalizedSelector}\n${decl.prop}`, decl.value);
3576
- });
3577
- }
3578
- });
3579
- return values;
3580
- }
3581
- function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
3582
- try {
3583
- const legacyValues = createLegacyDeclarationValueMap(legacyCss);
3584
- if (legacyValues.size === 0) return css;
3585
- const root = postcss.parse(css);
3586
- let changed = false;
3587
- root.walkRules((rule) => {
3588
- if (!rule.selectors || rule.selectors.length === 0) return;
3589
- const selectors = rule.selectors.flatMap((selector) => normalizeCompatSelectors(selector));
3590
- if (selectors.length === 0) return;
3591
- rule.walkDecls((decl) => {
3592
- if (!CSS_LENGTH_UNIT_RE.test(decl.value)) return;
3593
- for (const selector of selectors) {
3594
- const legacyValue = legacyValues.get(`${selector}\n${decl.prop}`);
3595
- if (legacyValue && legacyValue !== decl.value) {
3596
- decl.value = legacyValue;
3597
- changed = true;
3598
- return;
3599
- }
3600
- }
3601
- });
3602
- });
3603
- return changed ? root.toString() : css;
3604
- } catch {
3605
- return css;
3606
- }
3607
- }
3608
- //#endregion
3609
- //#region src/bundlers/shared/generator-css/output-import-shell.ts
3610
- const MINI_PROGRAM_OUTPUT_IMPORT_RE = /(@import\s+(?:url\(\s*)?)(["'])([^"']+\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:[?#][^"']*)?)\2([^;]*;)/gi;
3611
- const MINI_PROGRAM_OUTPUT_STYLE_RE = /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
3612
- function normalizeMiniProgramOutputImportRequest(request) {
3613
- if (request.startsWith(".") || request.startsWith("/") || /^(?:[a-z][a-z\d+.-]*:|#)/i.test(request)) return request;
3614
- return `./${request}`;
3615
- }
3616
- function normalizeMiniProgramImportShell(css, output) {
3617
- const normalized = output?.cssOnly ? css : css.replace(MINI_PROGRAM_OUTPUT_IMPORT_RE, (_match, prefix, quote, request, suffix) => {
3618
- return `${prefix}${quote}${normalizeMiniProgramOutputImportRequest(request)}${quote}${suffix}`;
3619
- });
3620
- if (!output || !normalized.includes("@import")) return normalized;
3621
- const files = new Set([...output.outputFiles].map(normalizeOutputPath));
3622
- const root = postcss.parse(normalized);
3623
- root.walkAtRules("import", (rule) => {
3624
- const parsed = parseCssImportSpecifier(rule.params);
3625
- if (!parsed || output.cssOnly && !/\.css(?:$|[?#])/i.test(parsed.specifier) || !files.has(resolveOutputImportRequest(output.outputFile, parsed.specifier))) return;
3626
- const request = normalizeMiniProgramOutputImportRequest(parsed.specifier);
3627
- if (request !== parsed.specifier) rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(request, parsed.quote));
3628
- });
3629
- return root.toString();
3630
- }
3631
- function normalizeOutputPath(file) {
3632
- const segments = [];
3633
- for (const segment of file.replace(/\\/g, "/").replace(/^\/+/, "").split("/")) {
3634
- if (!segment || segment === ".") continue;
3635
- if (segment === "..") {
3636
- if (segments.length > 0 && segments[segments.length - 1] !== "..") segments.pop();
3637
- else segments.push(segment);
3638
- continue;
3639
- }
3640
- segments.push(segment);
3641
- }
3642
- return segments.join("/");
3643
- }
3644
- function splitRequestSuffix(request) {
3645
- const suffixIndexCandidates = [request.indexOf("?"), request.indexOf("#")].filter((index) => index >= 0);
3646
- const suffixIndex = suffixIndexCandidates.length > 0 ? Math.min(...suffixIndexCandidates) : -1;
3647
- return suffixIndex < 0 ? request : request.slice(0, suffixIndex);
3648
- }
3649
- function resolveOutputImportRequest(file, request) {
3650
- const cleanRequest = splitRequestSuffix(request.replace(/\\/g, "/"));
3651
- if (cleanRequest.startsWith("/")) return normalizeOutputPath(cleanRequest);
3652
- const normalizedFile = normalizeOutputPath(file);
3653
- const baseDir = normalizedFile.includes("/") ? normalizedFile.slice(0, normalizedFile.lastIndexOf("/")) : "";
3654
- return normalizeOutputPath(baseDir ? `${baseDir}/${cleanRequest}` : cleanRequest);
3655
- }
3656
- function isMiniProgramOutputImport(node) {
3657
- if (node.type !== "atrule" || node.name !== "import") return false;
3658
- const request = parseImportRequest(node.params);
3659
- return request !== void 0 && MINI_PROGRAM_OUTPUT_STYLE_RE.test(request);
3660
- }
3661
- function isSelfMiniProgramOutputImport(outputFile, node) {
3662
- if (node.type !== "atrule" || node.name !== "import") return false;
3663
- const request = parseCssImportSpecifier(node.params)?.specifier;
3664
- return request !== void 0 && /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(request) && resolveOutputImportRequest(outputFile, request) === normalizeOutputPath(outputFile);
3665
- }
3666
- function removeMiniProgramOutputImportsBy(css, predicate) {
3667
- if (!css.includes("@import")) return css;
3668
- try {
3669
- const root = postcss.parse(css);
3670
- let changed = false;
3671
- root.walk((node) => {
3672
- if (predicate(node)) {
3673
- node.remove();
3674
- changed = true;
3675
- }
3676
- });
3677
- return changed ? root.toString() : css;
3678
- } catch {
3679
- return css;
3680
- }
3681
- }
3682
- function removeSelfMiniProgramOutputImports(css, outputFile) {
3683
- return removeMiniProgramOutputImportsBy(css, (node) => isSelfMiniProgramOutputImport(outputFile, node));
3684
- }
3685
- function removeMiniProgramOutputImports(css) {
3686
- return removeMiniProgramOutputImportsBy(css, isMiniProgramOutputImport);
3687
- }
3688
- function normalizeMiniProgramGeneratorCssSource(css, outputFile, outputFiles) {
3689
- const normalized = normalizeMiniProgramImportShell(css, outputFile && outputFiles ? {
3690
- outputFile,
3691
- outputFiles
3692
- } : void 0);
3693
- if (outputFile) return removeSelfMiniProgramOutputImports(normalized, outputFile);
3694
- return isPureLocalCssImportWrapper(normalized) ? normalized : removeMiniProgramOutputImports(normalized);
3695
- }
3696
- //#endregion
3697
- //#region src/bundlers/shared/run-tasks.ts
2642
+ //#region src/utils/run-tasks.ts
3698
2643
  async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
3699
2644
  if (factories.length === 0) return [];
3700
2645
  const results = Array.from({ length: factories.length });
@@ -3731,19 +2676,40 @@ function pushConcurrentTaskFactories(queue, factories, limit) {
3731
2676
  queue.push(runWithConcurrency(factories, limit).then(() => void 0));
3732
2677
  }
3733
2678
  //#endregion
3734
- //#region src/bundlers/shared/generator-css/class-selectors.ts
3735
- function normalizeCssClassSelector(value) {
3736
- return value.replace(/\\([^\da-f\r\n])/gi, "$1").replace(/\\([\da-f]{1,6})\s?/gi, (_, code) => String.fromCodePoint(Number.parseInt(code, 16)));
3737
- }
3738
- function collectRawSourceClassSelectors(rawSource) {
3739
- const selectors = /* @__PURE__ */ new Set();
3740
- try {
3741
- postcss.parse(rawSource).walkRules((rule) => {
3742
- for (const selector of rule.selectors ?? [rule.selector]) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) selectors.add(normalizeCssClassSelector(match[1]));
2679
+ //#region src/generation/user-css/compile-functions.ts
2680
+ function createAuthorCssFunctionCompiler(sources, session) {
2681
+ const cache = /* @__PURE__ */ new Map();
2682
+ return (css) => {
2683
+ return compileTailwindAuthorFunctions(css, async (values) => {
2684
+ const missing = [...new Set(values.filter((value) => !cache.has(value)))];
2685
+ if (missing.length > 0) {
2686
+ let selector = `.weapp-author-functions-${md5Hash(missing.join("\0"))}`;
2687
+ while (sources.some((source) => source.css.includes(selector))) selector += "-probe";
2688
+ const probe = createTailwindAuthorFunctionProbe(missing, selector);
2689
+ let resolved;
2690
+ for (const source of sources) {
2691
+ const result = await session.generate({
2692
+ ...source,
2693
+ css: `${source.css}\n${probe.css}`
2694
+ }, {
2695
+ candidates: [],
2696
+ scanSources: false,
2697
+ incrementalCache: false,
2698
+ target: "web"
2699
+ });
2700
+ const current = probe.read(result.rawCss);
2701
+ if (resolved && current.some((value, index) => value !== resolved[index])) throw new Error("作者样式函数匹配到多个不同的 Tailwind 配置上下文,无法安全回填。");
2702
+ resolved = current;
2703
+ }
2704
+ if (!resolved) throw new Error("作者样式函数缺少 Tailwind 编译上下文。");
2705
+ missing.forEach((value, index) => cache.set(value, resolved[index]));
2706
+ }
2707
+ return values.map((value) => cache.get(value));
3743
2708
  });
3744
- } catch {}
3745
- return selectors;
2709
+ };
3746
2710
  }
2711
+ //#endregion
2712
+ //#region src/generation/class-selectors.ts
3747
2713
  function collectGeneratedRawSourceCandidates(candidates, rawSource, escapeMap) {
3748
2714
  const selectors = collectRawSourceClassSelectors(rawSource);
3749
2715
  if (selectors.size === 0) return /* @__PURE__ */ new Set();
@@ -3760,27 +2726,7 @@ function collectGeneratedRawSourceCandidatesFromCss(candidates, cssSources, esca
3760
2726
  return matched;
3761
2727
  }
3762
2728
  //#endregion
3763
- //#region src/bundlers/shared/generator-css/result-helpers.ts
3764
- function collectCssRuleIdentityMarkers(source) {
3765
- const markers = /* @__PURE__ */ new Set();
3766
- try {
3767
- const root = postcss.parse(source);
3768
- root.walkRules((rule) => {
3769
- 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]}`);
3770
- });
3771
- root.walkAtRules("keyframes", (rule) => {
3772
- if (rule.params) markers.add(`keyframes:${rule.params}`);
3773
- });
3774
- } catch {}
3775
- return markers;
3776
- }
3777
- function isCssAlreadyRepresentedByMarkers(css, source) {
3778
- const sourceMarkers = collectCssRuleIdentityMarkers(source);
3779
- if (sourceMarkers.size === 0) return false;
3780
- const cssMarkers = collectCssRuleIdentityMarkers(css);
3781
- for (const marker of sourceMarkers) if (!cssMarkers.has(marker)) return false;
3782
- return true;
3783
- }
2729
+ //#region src/generation/result-helpers.ts
3784
2730
  function mergeGeneratedCssClassSet(classSet, candidates, css, escapeMap) {
3785
2731
  const merged = new Set(classSet);
3786
2732
  for (const candidate of collectGeneratedRawSourceCandidates(candidates, css, escapeMap)) merged.add(candidate);
@@ -3799,7 +2745,7 @@ function finalizeIncrementalGeneratorCss(previousCss, incrementalCss, target, ma
3799
2745
  return createCssAppend(previousCss, finalizedIncrementalCss);
3800
2746
  }
3801
2747
  //#endregion
3802
- //#region src/bundlers/shared/generator-css/pipeline/deferred-output.ts
2748
+ //#region src/generation/pipeline/deferred-output.ts
3803
2749
  async function finalizeDeferredGeneratorCss(context) {
3804
2750
  const { cssUserHandlerOptions, file, filterGeneratedApplyOnlyCss, generated, generatedUserCssRawSource, generatorOptions, generatorRawSource, generatorStyleOptions, hasMatchedCssSourceFile, localImports, majorVersion, options, opts, preflightMode, runtimeWithCurrentCss, styleHandler, userCssOrderSource, userRawSourceProcessed } = context;
3805
2751
  if (options.deferCssAdaptation) {
@@ -3816,6 +2762,8 @@ async function finalizeDeferredGeneratorCss(context) {
3816
2762
  if (generated.target !== "weapp" || generatedUserCssRawSource.trim().length === 0) return css;
3817
2763
  const userCssOptions = {
3818
2764
  generatorTarget: generated.target,
2765
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
2766
+ generatedSource: generated.rawCss,
3819
2767
  generatorStyleOptions,
3820
2768
  cssUserHandlerOptions,
3821
2769
  styleHandler,
@@ -3832,16 +2780,19 @@ async function finalizeDeferredGeneratorCss(context) {
3832
2780
  if (orderedUserCss) {
3833
2781
  const beforeUserCss = await transformDeferredUserCss(orderedUserCss.before);
3834
2782
  const afterUserCss = await transformDeferredUserCss(orderedUserCss.after);
3835
- const cssWithBeforeUserCss = createCssSourceOrderAppend(filterExistingCssRules(css, beforeUserCss), css);
3836
- 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));
3837
2787
  }
3838
2788
  const userCss = await transformDeferredUserCss(generatedUserCssRawSource);
3839
2789
  return reorderMarkedUserLayerComponentsCss(createCssSourceOrderAppend(css, filterExistingCssRules(css, userCss)));
3840
2790
  };
3841
2791
  const canAppendIncrementalCss = generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource);
3842
2792
  const incrementalRawCss = generated.incrementalRawCss ?? generated.incrementalCss;
3843
- const shouldAppendIncrementalCss = canAppendIncrementalCss && typeof options.previousCss === "string" && typeof incrementalRawCss === "string";
3844
- const normalizedCss = shouldAppendIncrementalCss ? incrementalRawCss.trim().length > 0 ? createCssAppend(options.previousCss, await normalizeDeferredGeneratedCss(incrementalRawCss)) : options.previousCss : await normalizeDeferredGeneratedCss(generated.rawCss ?? generated.css);
2793
+ const previousCss = options.previousCss;
2794
+ const shouldAppendIncrementalCss = canAppendIncrementalCss && typeof previousCss === "string" && typeof incrementalRawCss === "string";
2795
+ const normalizedCss = shouldAppendIncrementalCss ? incrementalRawCss.trim().length > 0 ? createCssAppend(previousCss, await normalizeDeferredGeneratedCss(incrementalRawCss)) : previousCss : await normalizeDeferredGeneratedCss(generated.rawCss ?? generated.css);
3845
2796
  const intermediateCss = shouldAppendIncrementalCss ? normalizedCss : await restoreDeferredUserCss(normalizedCss);
3846
2797
  const css = restoreLocalCssImports(intermediateCss, localImports, { outputFile: file });
3847
2798
  return {
@@ -3849,7 +2800,7 @@ async function finalizeDeferredGeneratorCss(context) {
3849
2800
  classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, css, opts.escapeMap, options.previousClassSet),
3850
2801
  target: generated.target,
3851
2802
  source: "generator",
3852
- dependencies: generated.dependencies,
2803
+ dependencies: [...generated.dependencies],
3853
2804
  incremental: shouldAppendIncrementalCss,
3854
2805
  metadata: {
3855
2806
  file,
@@ -3861,27 +2812,34 @@ async function finalizeDeferredGeneratorCss(context) {
3861
2812
  }
3862
2813
  }
3863
2814
  //#endregion
3864
- //#region src/bundlers/shared/generator-css/pipeline/fallback-output.ts
2815
+ //#region src/generation/pipeline/fallback-output.ts
3865
2816
  async function finalizeFallbackGeneratorCss(context) {
3866
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;
3867
2818
  debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
3868
2819
  let css = generatedCss;
3869
2820
  const distinctUserLayerParts = hasDistinctUserRawSource && hasUserCssLayerBlocks(generatedUserCssRawSource) ? splitUserCssLayerBlocks(generatedUserCssRawSource) : void 0;
3870
2821
  let restoredDistinctUserLayerCss = false;
3871
- if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend(await transformGeneratorUserCss(generatedUserCssRawSource, {
3872
- generatorTarget: generated.target,
3873
- generatorStyleOptions,
3874
- cssUserHandlerOptions,
3875
- styleHandler,
3876
- importFallback: generatorOptions.importFallback,
3877
- processed: userRawSourceProcessed
3878
- }), 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
+ }
3879
2835
  if (generated.target === "weapp") {
3880
2836
  css = inheritLegacyUnitConvertedDeclarations(css, generatorRawSource);
3881
2837
  if (hasUserCssLayerBlocks(generatorRawSource)) {
3882
2838
  const layerParts = splitUserCssLayerBlocks(generatorRawSource);
3883
2839
  const layerUserCss = await transformGeneratorUserCss(layerParts.layer, {
3884
2840
  generatorTarget: generated.target,
2841
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
2842
+ generatedSource: generated.rawCss,
3885
2843
  generatorStyleOptions,
3886
2844
  cssUserHandlerOptions,
3887
2845
  styleHandler,
@@ -3900,6 +2858,8 @@ async function finalizeFallbackGeneratorCss(context) {
3900
2858
  if (hasDistinctUserRawSource && distinctUserLayerParts) {
3901
2859
  const layerUserCss = await transformGeneratorUserCss(distinctUserLayerParts.layer, {
3902
2860
  generatorTarget: generated.target,
2861
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
2862
+ generatedSource: generated.rawCss,
3903
2863
  generatorStyleOptions,
3904
2864
  cssUserHandlerOptions,
3905
2865
  styleHandler,
@@ -3918,6 +2878,8 @@ async function finalizeFallbackGeneratorCss(context) {
3918
2878
  const distinctUserCssRawSource = restoredDistinctUserLayerCss ? distinctUserLayerParts?.rest ?? generatedUserCssRawSource : generatedUserCssRawSource;
3919
2879
  const userCss = await transformGeneratorUserCss(distinctUserCssRawSource, {
3920
2880
  generatorTarget: generated.target,
2881
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
2882
+ generatedSource: generated.rawCss,
3921
2883
  generatorStyleOptions,
3922
2884
  cssUserHandlerOptions,
3923
2885
  styleHandler,
@@ -3927,10 +2889,12 @@ async function finalizeFallbackGeneratorCss(context) {
3927
2889
  const missingUserCss = isCssAlreadyRepresentedByMarkers(css, distinctUserCssRawSource) ? filterExistingCssRules(css, userCss) : userCss;
3928
2890
  css = createCssSourceOrderAppend(css, missingUserCss);
3929
2891
  } else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasGeneratedMarkers && !hasGeneratedCss) {
3930
- const cleanedUserCssRawSource = removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource);
2892
+ const cleanedUserCssRawSource = removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource, generated.rawCss);
3931
2893
  const cleanedUserCssRestSource = restoredDistinctUserLayerCss && hasUserCssLayerBlocks(cleanedUserCssRawSource) ? splitUserCssLayerBlocks(cleanedUserCssRawSource).rest : cleanedUserCssRawSource;
3932
2894
  const userCss = await transformGeneratorUserCss(cleanedUserCssRestSource, {
3933
2895
  generatorTarget: generated.target,
2896
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
2897
+ generatedSource: generated.rawCss,
3934
2898
  generatorStyleOptions,
3935
2899
  cssUserHandlerOptions,
3936
2900
  styleHandler,
@@ -3942,6 +2906,8 @@ async function finalizeFallbackGeneratorCss(context) {
3942
2906
  } else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasUserCssLayerBlocks(generatedUserCssRawSource)) {
3943
2907
  const layerUserCss = await transformGeneratorUserCss(splitUserCssLayerBlocks(generatedUserCssRawSource).layer, {
3944
2908
  generatorTarget: generated.target,
2909
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
2910
+ generatedSource: generated.rawCss,
3945
2911
  generatorStyleOptions,
3946
2912
  cssUserHandlerOptions,
3947
2913
  styleHandler,
@@ -3962,6 +2928,8 @@ async function finalizeFallbackGeneratorCss(context) {
3962
2928
  })) {
3963
2929
  const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
3964
2930
  generatorTarget: generated.target,
2931
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
2932
+ generatedSource: generated.rawCss,
3965
2933
  generatorStyleOptions,
3966
2934
  cssUserHandlerOptions,
3967
2935
  styleHandler,
@@ -3981,7 +2949,7 @@ async function finalizeFallbackGeneratorCss(context) {
3981
2949
  classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
3982
2950
  target: generated.target,
3983
2951
  source: "generator",
3984
- dependencies: generated.dependencies,
2952
+ dependencies: [...generated.dependencies],
3985
2953
  metadata: {
3986
2954
  file,
3987
2955
  majorVersion,
@@ -3990,13 +2958,19 @@ async function finalizeFallbackGeneratorCss(context) {
3990
2958
  };
3991
2959
  }
3992
2960
  if (!shouldFilterApplyOnlyCss && !userRawSourceProcessed && !hasGeneratedCss && !hasGeneratedMarkers) {
3993
- css = await appendLegacyCompatCss(css, legacyCompatUserCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions, { preserveSelectorOverrides: shouldPreserveLegacyCompatSelectorOverrides });
2961
+ css = await appendLegacyCompatCss(css, legacyCompatUserCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions, {
2962
+ preserveSelectorOverrides: shouldPreserveLegacyCompatSelectorOverrides,
2963
+ generatedSource: generated.rawCss,
2964
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions
2965
+ });
3994
2966
  css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
3995
2967
  }
3996
2968
  if (generated.target === "weapp" && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !hasTailwindApplyDirective(generatedUserCssRawSource)) {
3997
2969
  const distinctUserCssRawSource = restoredDistinctUserLayerCss ? distinctUserLayerParts?.rest ?? generatedUserCssRawSource : generatedUserCssRawSource;
3998
2970
  const userCss = await transformGeneratorUserCss(distinctUserCssRawSource, {
3999
2971
  generatorTarget: generated.target,
2972
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
2973
+ generatedSource: generated.rawCss,
4000
2974
  generatorStyleOptions,
4001
2975
  cssUserHandlerOptions,
4002
2976
  styleHandler,
@@ -4016,7 +2990,7 @@ async function finalizeFallbackGeneratorCss(context) {
4016
2990
  classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
4017
2991
  target: generated.target,
4018
2992
  source: "generator",
4019
- dependencies: generated.dependencies,
2993
+ dependencies: [...generated.dependencies],
4020
2994
  metadata: {
4021
2995
  file,
4022
2996
  majorVersion,
@@ -4025,7 +2999,7 @@ async function finalizeFallbackGeneratorCss(context) {
4025
2999
  };
4026
3000
  }
4027
3001
  //#endregion
4028
- //#region src/bundlers/shared/generator-css/pipeline/ordered-output.ts
3002
+ //#region src/generation/pipeline/ordered-output.ts
4029
3003
  async function finalizeOrderedGeneratorCss(context) {
4030
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;
4031
3005
  if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
@@ -4041,7 +3015,7 @@ async function finalizeOrderedGeneratorCss(context) {
4041
3015
  classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
4042
3016
  target: generated.target,
4043
3017
  source: "generator",
4044
- dependencies: generated.dependencies,
3018
+ dependencies: [...generated.dependencies],
4045
3019
  incremental: true,
4046
3020
  metadata: {
4047
3021
  file,
@@ -4058,6 +3032,8 @@ async function finalizeOrderedGeneratorCss(context) {
4058
3032
  if (generated.target === "weapp") css = inheritLegacyUnitConvertedDeclarations(css, generatorRawSource);
4059
3033
  const userCssOptions = {
4060
3034
  generatorTarget: generated.target,
3035
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3036
+ generatedSource: generated.rawCss,
4061
3037
  generatorStyleOptions,
4062
3038
  cssUserHandlerOptions,
4063
3039
  styleHandler,
@@ -4072,7 +3048,8 @@ async function finalizeOrderedGeneratorCss(context) {
4072
3048
  const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
4073
3049
  const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
4074
3050
  const fallbackLayerUserCss = generated.target === "weapp" && hasUserCssLayerBlocks(userCssRawSource) ? filterExistingCssRules(afterLayerUserCss, await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions)) : "";
4075
- 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);
4076
3053
  if (hasWebUserCssFallbackSource && isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
4077
3054
  hasSourceDirectives,
4078
3055
  hasMatchedCssSourceFile
@@ -4093,7 +3070,11 @@ async function finalizeOrderedGeneratorCss(context) {
4093
3070
  if (generated.target === "weapp" && shouldAppendMatchedCssSourceCompat) {
4094
3071
  if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
4095
3072
  if (!shouldFilterApplyOnlyCss && !userRawSourceProcessed && !hasGeneratedCss && !hasGeneratedMarkers) {
4096
- css = await appendLegacyCompatCss(css, legacyCompatUserCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions, { preserveSelectorOverrides: shouldPreserveLegacyCompatSelectorOverrides });
3073
+ css = await appendLegacyCompatCss(css, legacyCompatUserCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions, {
3074
+ preserveSelectorOverrides: shouldPreserveLegacyCompatSelectorOverrides,
3075
+ generatedSource: generated.rawCss,
3076
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions
3077
+ });
4097
3078
  if (!isolateCurrentCssCandidates) css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
4098
3079
  }
4099
3080
  } else if (generated.target === "weapp" && shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
@@ -4107,7 +3088,7 @@ async function finalizeOrderedGeneratorCss(context) {
4107
3088
  classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
4108
3089
  target: generated.target,
4109
3090
  source: "generator",
4110
- dependencies: generated.dependencies,
3091
+ dependencies: [...generated.dependencies],
4111
3092
  metadata: {
4112
3093
  file,
4113
3094
  majorVersion,
@@ -4117,7 +3098,7 @@ async function finalizeOrderedGeneratorCss(context) {
4117
3098
  }
4118
3099
  }
4119
3100
  //#endregion
4120
- //#region src/bundlers/shared/generator-css/pipeline/execution.ts
3101
+ //#region src/generation/pipeline/preparation.ts
4121
3102
  function resolveGeneratorSourceConcurrency() {
4122
3103
  const configured = Number.parseInt(process.env["WEAPP_TW_GENERATOR_SOURCE_CONCURRENCY"] ?? "", 10);
4123
3104
  return Number.isFinite(configured) && configured > 0 ? configured : 1;
@@ -4138,13 +3119,8 @@ function resolveCompilationDependencies(dependencies) {
4138
3119
  kind: isSourceStyleRequest(id) ? "css" : "config"
4139
3120
  }));
4140
3121
  }
4141
- async function executeGeneratorPipeline(context) {
4142
- return runCompilerOwnerActivity(context.runtimeState, () => executeGeneratorPipelineWithOwner(context, getCompilationSessionPool(context.runtimeState), getTailwindGenerationSessionPool(context.runtimeState)));
4143
- }
4144
- async function executeGeneratorPipelineWithOwner(context, compilationPool, generationSession) {
3122
+ async function prepareGeneratorInputs(context) {
4145
3123
  const { cssHandlerOptions, debug, file, generatorBranch, generatorOptions, generatorRawSource, getSourceCandidatesForEntries, hasGeneratedCss, hasGeneratedMarkers, localImports, majorVersion, normalizeGeneratorSource, normalizedCssSources, options, opts, runtime, runtimeState, useMiniProgramCssBranch } = context;
4146
- await runtimeState.readyPromise;
4147
- const compilerSession = options.compilation?.enabled ? getFrameworkCompilerSession(runtimeState, opts) : void 0;
4148
3124
  const currentCssCandidates = collectGeneratorCssCandidates(generatorRawSource);
4149
3125
  const isolateCurrentCssCandidates = shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, {
4150
3126
  hasGeneratedCss,
@@ -4165,46 +3141,65 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4165
3141
  const generatorStyleOptions = resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorOptions.styleOptions);
4166
3142
  const configuredContainerCompat = hasConfiguredContainerCompatSources(generatorSourceRecords.map((record) => record.source));
4167
3143
  const sourceConcurrency = resolveGeneratorSourceConcurrency();
4168
- const preparedGenerationInputs = (await runWithConcurrency(generatorSourceRecords.map((record, index) => async () => {
4169
- const { metadata: sourceMetadata, source } = record;
4170
- const sourceCss = options.deferCssAdaptation ? removeMatchingLocalCssImports(source.css, localImports) : source.css;
4171
- const generatorSource = options.disableSourceScan === true ? {
4172
- ...source,
4173
- css: removeTailwindSourceDirectives(sourceCss, {
4174
- importFallback: generatorOptions.importFallback,
4175
- preserveApplyContext: true
4176
- })
4177
- } : sourceCss === source.css ? source : {
4178
- ...source,
4179
- css: sourceCss
4180
- };
4181
- const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(record, runtimeState) : void 0;
4182
- const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
4183
- const scopedRuntime = resolveScopedRuntimeCandidates(options.sourceCandidates, sourceScopedRuntime);
4184
- const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, record, sourceEntries, {
4185
- cssHandlerOptions,
4186
- target: generatorOptions.target
4187
- });
4188
- const matchedCssSourceFile = Boolean(sourceMetadata?.matchedCssSourceFile);
4189
- if (options.deferEmptyScopedCssSource && isolateCssSource && scopedRuntime?.size === 0 && currentCssCandidates.length === 0 && !cssHandlerOptions.isMainChunk) {
4190
- debug("defer empty scoped css source generation: %s", file);
4191
- return;
4192
- }
4193
- const sourceRuntime = scopedRuntime && (scopedRuntime.size > 0 || isolateCssSource) || isolateCssSource ? isolateCurrentCssCandidates ? runtimeWithCurrentCss : mergeScopedRuntimeWithCurrentRuntime(scopedRuntime ?? /* @__PURE__ */ new Set(), runtimeWithCurrentCss, {
4194
- currentCssCandidates,
4195
- cssHandlerOptions,
4196
- isolateCssSource,
4197
- majorVersion,
4198
- matchedCssSourceFile
4199
- }) : runtimeWithCurrentCss;
4200
- return {
4201
- generatorRuntime: shouldUseMiniProgramCssBranch(generatorBranch) ? filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime,
4202
- generatorSource,
4203
- dependencies: resolveCompilationDependencies(record.source.dependencies),
4204
- isolateCssSource,
4205
- sourceId: resolveCompilationSourceId(record, index)
4206
- };
4207
- }), 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);
4208
3203
  const generatePreparedInputs = async (candidateSets) => {
4209
3204
  return runWithConcurrency(preparedGenerationInputs.map((input) => async () => {
4210
3205
  const projectedCandidates = candidateSets?.get(input.sourceId);
@@ -4256,7 +3251,7 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4256
3251
  dependenciesBySource: results.map((result) => [result.sourceId, resolveCompilationDependencies(result.generated.dependencies)]),
4257
3252
  generated: merged,
4258
3253
  ...compilerSession ? (() => {
4259
- const snapshots = results.map((result) => result.generated.snapshot).filter((snapshot) => snapshot !== void 0);
3254
+ const snapshots = results.map((result) => "snapshot" in result.generated ? result.generated.snapshot : void 0).filter((snapshot) => snapshot !== void 0);
4260
3255
  return snapshots.length > 0 ? { snapshot: compilerSession.mergeSnapshots(snapshots) } : {};
4261
3256
  })() : {}
4262
3257
  } : void 0;
@@ -4292,7 +3287,10 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4292
3287
  });
4293
3288
  const filterGeneratedApplyOnlyCss = (css) => {
4294
3289
  if (!shouldFilterApplyOnlyCss) return css;
4295
- return filterApplyOnlyGeneratedCss(css, generatorRawSource, { preserveVariables: generated.target !== "web" });
3290
+ return filterApplyOnlyGeneratedCss(css, generatorRawSource, {
3291
+ preserveVariables: generated.target !== "web",
3292
+ preserveRuntimeProperties: generated.target === "web" && opts.appType === "uni-app-x"
3293
+ });
4296
3294
  };
4297
3295
  const preflightMode = resolveMiniProgramPreflightModeForGeneratorCss(opts, {
4298
3296
  cssHandlerOptions,
@@ -4301,6 +3299,8 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4301
3299
  explicitCssSource: hasExplicitCssSource,
4302
3300
  primaryCssSource: hasOnlyPrimaryCssSource || hasPreflightCssSource || hasPreflightRawSource
4303
3301
  });
3302
+ const compileAuthorCssFunctions = createAuthorCssFunctionCompiler(preparedGenerationInputs.map((input) => input.generatorSource), generationSession);
3303
+ const frameworkProcessedUserCss = options.frameworkProcessedUserCss === void 0 ? void 0 : await compileAuthorCssFunctions(options.frameworkProcessedUserCss);
4304
3304
  const outputContext = {
4305
3305
  ...context,
4306
3306
  ...compilerSession && options.compilation?.preserveDeletedCss !== true ? { options: {
@@ -4308,6 +3308,7 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4308
3308
  previousClassSet: void 0,
4309
3309
  previousCss: void 0
4310
3310
  } } : {},
3311
+ compileAuthorCssFunctions,
4311
3312
  configuredContainerCompat,
4312
3313
  filterGeneratedApplyOnlyCss,
4313
3314
  generated,
@@ -4320,20 +3321,27 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4320
3321
  shouldFilterApplyOnlyCss
4321
3322
  };
4322
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)])])];
3325
+ if (result && frameworkProcessedUserCss !== void 0) result = {
3326
+ ...result,
3327
+ compileAuthorCssFunctions,
3328
+ frameworkProcessedUserCss
3329
+ };
4323
3330
  if (!result || compilationRevision === void 0) return result;
4324
3331
  return {
4325
3332
  ...result,
3333
+ ...generated.snapshot ? { snapshot: generated.snapshot } : {},
4326
3334
  metadata: {
3335
+ file,
4327
3336
  ...result.metadata,
4328
3337
  revision: compilationRevision
4329
3338
  }
4330
3339
  };
4331
3340
  };
4332
- if (options.deferCssAdaptation) return withCompilationMetadata(await finalizeDeferredGeneratorCss(outputContext));
4333
- return withCompilationMetadata(await finalizeOrderedGeneratorCss(outputContext) ?? await finalizeFallbackGeneratorCss(outputContext));
3341
+ return withCompilationMetadata(options.deferCssAdaptation ? await finalizeDeferredGeneratorCss(outputContext) : await finalizeOrderedGeneratorCss(outputContext) ?? await finalizeFallbackGeneratorCss(outputContext));
4334
3342
  }
4335
3343
  //#endregion
4336
- //#region src/bundlers/shared/generator-css/pipeline.ts
3344
+ //#region src/generation/pipeline.ts
4337
3345
  function hasPostcssUserPlugins(options) {
4338
3346
  const plugins = options.postcssOptions?.plugins;
4339
3347
  if (Array.isArray(plugins)) return plugins.length > 0;
@@ -4385,7 +3393,7 @@ async function generateCssByGenerator(options) {
4385
3393
  return useMiniProgramCssBranch ? normalizeMiniProgramGeneratorCssSource(css, file) : css;
4386
3394
  };
4387
3395
  const normalizeGeneratorSource = (source) => {
4388
- const css = normalizeGeneratorCssSource(source.css);
3396
+ const css = useMiniProgramCssBranch ? removeMiniProgramOutputImports(normalizeGeneratorCssSource(source.css)) : source.css;
4389
3397
  return css === source.css ? source : {
4390
3398
  ...source,
4391
3399
  css
@@ -4410,7 +3418,7 @@ async function generateCssByGenerator(options) {
4410
3418
  }
4411
3419
  return;
4412
3420
  }
4413
- const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeEmptyTailwindCustomVariants(normalizeGeneratorCssSource(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })))));
3421
+ const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeEmptyTailwindCustomVariants$1(normalizeGeneratorCssSource(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })))));
4414
3422
  const effectiveRawSourceRoot = parseCssSourceRoot(effectiveRawSource);
4415
3423
  const cleanedLocalImportWrapper = cleanLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
4416
3424
  if (cleanedLocalImportWrapper !== void 0) return {
@@ -4431,7 +3439,7 @@ async function generateCssByGenerator(options) {
4431
3439
  return finalizeWebGeneratorCss(restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports, { outputFile: file }), target, generatorOptions.webCompat);
4432
3440
  };
4433
3441
  const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
4434
- 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 })))));
4435
3443
  const userSource = (rawUserSource === generatorRawSource ? void 0 : splitLocalCssImports(rawUserSource))?.source ?? rawUserSource;
4436
3444
  const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
4437
3445
  const hasWebUserCssFallbackSource = userCssRawSource.trim().length > 0 && !isCommentOnlyCss(userCssRawSource);
@@ -4447,7 +3455,7 @@ async function generateCssByGenerator(options) {
4447
3455
  const hasSourceDirectives = hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
4448
3456
  const hasGeneratedMarkers = hasTailwindGeneratedCssMarkers(generatorRawSource);
4449
3457
  const normalizedCssSources = options.cssSources?.map((source) => {
4450
- const css = normalizeGeneratorCssSource(normalizeEmptyTailwindCustomVariants(source.css));
3458
+ const css = normalizeGeneratorCssSource(normalizeEmptyTailwindCustomVariants$1(source.css));
4451
3459
  return css === source.css ? source : {
4452
3460
  ...source,
4453
3461
  css
@@ -4503,7 +3511,7 @@ async function generateCssByGenerator(options) {
4503
3511
  }
4504
3512
  }
4505
3513
  //#endregion
4506
- //#region src/bundlers/shared/generator-css/validate.ts
3514
+ //#region src/generation/validate.ts
4507
3515
  async function validateCandidatesByGenerator(options) {
4508
3516
  return runCompilerOwnerActivity(options.runtimeState, () => validateCandidatesByGeneratorWithOwner(options, getTailwindGenerationSessionPool(options.runtimeState)));
4509
3517
  }
@@ -4535,7 +3543,7 @@ async function validateCandidatesByGeneratorWithOwner(options, generationSession
4535
3543
  return classSet;
4536
3544
  }
4537
3545
  //#endregion
4538
- //#region src/bundlers/shared/v4-generation-core.ts
3546
+ //#region src/generation/service.ts
4539
3547
  function resolveGenerationOptions(options, mode) {
4540
3548
  const physicalFile = stripRequestQuery(options.file);
4541
3549
  const normalizedOptions = physicalFile === options.file ? options : {
@@ -4568,7 +3576,7 @@ function createCoreArtifact(generated, css, options) {
4568
3576
  scope,
4569
3577
  stage: "adapted"
4570
3578
  })], {
4571
- classSet: generated.classSet,
3579
+ classSet: new Set(generated.classSet),
4572
3580
  rawCandidates: options.runtime,
4573
3581
  dependencies: generated.dependencies,
4574
3582
  sourceEntries: options.cssHandlerOptions.sourceOptions?.cssEntries ?? [],
@@ -4585,10 +3593,11 @@ async function generateTailwindV4CssWithImplementation(options, implementation)
4585
3593
  tailwindcssMajorVersion: majorVersion,
4586
3594
  uniAppX: options.opts.uniAppX
4587
3595
  });
4588
- const shouldReplayFrameworkPostcss = options.cssStage === "framework-processed" && hasFrameworkPostcssOptions(frameworkPostcssOwner) && normalizedGeneratorOptions.target === "weapp";
3596
+ const shouldReplayFrameworkPostcss = options.cssStage === "framework-processed" && hasFrameworkPostcssOptions(frameworkPostcssOwner);
4589
3597
  const generationInput = !shouldReplayFrameworkPostcss && options.frameworkProcessedUserCss ? {
4590
3598
  ...options,
4591
- userRawSource: [options.userRawSource, options.frameworkProcessedUserCss].filter(Boolean).join("\n")
3599
+ userRawSource: [options.userRawSource, options.frameworkProcessedUserCss].filter(Boolean).join("\n"),
3600
+ frameworkProcessedUserCss: void 0
4592
3601
  } : options;
4593
3602
  const scope = options.scope ?? {
4594
3603
  id: options.outputFile ?? options.file,
@@ -4596,13 +3605,14 @@ async function generateTailwindV4CssWithImplementation(options, implementation)
4596
3605
  };
4597
3606
  const generated = await generateCssByGenerator(shouldReplayFrameworkPostcss ? {
4598
3607
  ...generationInput,
3608
+ frameworkProcessedUserCss: options.frameworkProcessedUserCss === void 0 ? void 0 : normalizeFrameworkProcessedUserCss(options.frameworkProcessedUserCss),
4599
3609
  compilation: implementation.frameworkAdapter === "graph" ? {
4600
3610
  enabled: true,
4601
3611
  preserveDeletedCss: normalizedGeneratorOptions.hmr?.preserveDeletedCss ?? true,
4602
3612
  scope,
4603
3613
  ...options.compilationChanges === void 0 ? {} : { changes: options.compilationChanges }
4604
3614
  } : void 0,
4605
- deferCssAdaptation: true
3615
+ deferCssAdaptation: normalizedGeneratorOptions.target === "weapp"
4606
3616
  } : {
4607
3617
  ...generationInput,
4608
3618
  compilation: implementation.frameworkAdapter === "graph" ? {
@@ -4624,15 +3634,17 @@ async function generateTailwindV4CssWithImplementation(options, implementation)
4624
3634
  snapshot: generated.snapshot
4625
3635
  } : {}
4626
3636
  }) : generated.css;
4627
- const composedCss = shouldReplayFrameworkPostcss && options.frameworkProcessedUserCss ? await restoreFrameworkProcessedUserCss(adaptedCss, generated, options.frameworkProcessedUserCss, options, normalizedGeneratorOptions) : adaptedCss;
3637
+ const composedCss = shouldReplayFrameworkPostcss && options.frameworkProcessedUserCss ? await restoreFrameworkProcessedUserCss(adaptedCss, generated, generated.frameworkProcessedUserCss ?? options.frameworkProcessedUserCss, options, normalizedGeneratorOptions) : adaptedCss;
4628
3638
  const css = isVueScopedStyleRequest(resolvePostcssRequestOption(options.cssHandlerOptions)) ? preferScopedGeneratedCssRules(composedCss) : composedCss;
4629
- const classSet = options.frameworkProcessedUserCss ? resolveGeneratedCssClassSet(generated.target, generated.classSet, options.runtime, css, options.opts.escapeMap, options.previousClassSet) : generated.classSet;
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);
4630
3641
  const artifact = implementation.emitArtifact ? createCoreArtifact({
4631
3642
  ...generated,
4632
3643
  classSet
4633
3644
  }, css, options) : void 0;
3645
+ const { compileAuthorCssFunctions: _compileAuthorCssFunctions, ...generatedRest } = generated;
4634
3646
  return {
4635
- ...generated,
3647
+ ...generatedRest,
4636
3648
  ...artifact ? { artifact } : {},
4637
3649
  css,
4638
3650
  classSet,
@@ -4675,6 +3687,47 @@ async function generateTailwindV4Css(options) {
4675
3687
  return legacy;
4676
3688
  }
4677
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
4678
3731
  //#region src/bundlers/shared/hmr-timing.ts
4679
3732
  function shouldEmitHmrTiming() {
4680
3733
  return process.env["WEAPP_TW_WATCH_REGRESSION"] === "1" || process.env["WEAPP_TW_HMR_TIMING"] === "1";
@@ -4753,4 +3806,4 @@ function createHmrTimingRecorder(bundler) {
4753
3806
  };
4754
3807
  }
4755
3808
  //#endregion
4756
- export { createCssSourceTraceCacheSignature as A, createSourceCandidateCollector as B, isSourceStyleRequest as C, parseBundlerGeneratedCssMarkerBlocks as D, hasBundlerGeneratedCssMarker as E, createEscapeFragments as F, resolveSourceCandidateScanFiles as G, isSourceCandidateRequest as H, isPureLocalCssImportWrapper as I, rewriteLocalCssImportRequestsForOutput as L, isCssSourceTraceEnabled as M, createRuntimeClassSetManager as N, stripBundlerGeneratedCssMarkers as O, collectStrictEscapedRuntimeCandidates as P, splitLocalCssImports as R, isSourcePreprocessorRequest as S, createBundlerGeneratedCssMarker as T, extractCandidatesFromSource as U, createSourceCandidateStore as V, createSourceCandidateEligibilityMatcher 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, createCssTokenSourceMap as j, annotateCssSourceTrace 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, finalizeCompilerShadowRun 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 };