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,80 +1,36 @@
1
+ import { _ as resolveTailwindV4CssSourceBase, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled, v as source_scan_exports } from "./tailwindcss-kSd0ykiX.js";
1
2
  import { resolveImplicitAppTypeFromViteRoot } from "./framework.js";
2
- import { $ as hasTailwindRootDirectives, At as resolveTailwindV4CssSourceBase, J as splitUserCssLayerBlocks, Nt as parseCssImportSpecifier, O as resolveTailwindcssOptions, Pt as quoteCssImportSpecifier, R as hasMiniProgramCssSpecificityPlaceholders, Rt as getTailwindV4IncrementalGenerateCacheStats, T as omitUndefined, Tt as isFileMatchedByTailwindSourceEntries, V as stripMiniProgramCssSpecificityPlaceholders, W as normalizeEmptyTailwindCustomVariants, Z as hasTailwindApplyDirective, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, at as removeTailwindSourceDirectives, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, dt as hasTailwindGeneratedCssMarkers, et as hasTailwindSourceDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as parseImportRequest, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, q as hasUserCssLayerBlocks, rt as normalizeTailwindSourceForGenerator, s as shouldUseMiniProgramCssBranch, tt as normalizeTailwindConfigDirectives, x as normalizeCssEntries, zt as filterUnsupportedMiniProgramTailwindV4Candidates } from "./generator-CAOx1Sqm.js";
3
- import { g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled } from "./tailwindcss-DTV9MoJT.js";
3
+ import { L as getTailwindV4IncrementalGenerateCacheStats, R as filterUnsupportedMiniProgramTailwindV4Candidates, T as omitUndefined, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, k as resolveTailwindcssOptions, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, s as shouldUseMiniProgramCssBranch, x as normalizeCssEntries } from "./generator-oKZ5mCJ5.js";
4
4
  import "./utils-MVwpU07P.js";
5
- import { A as createCssSourceTraceCacheSignature, B as createSourceCandidateCollector, C as isSourceStyleRequest, D as parseBundlerGeneratedCssMarkerBlocks, E as hasBundlerGeneratedCssMarker, H as isSourceCandidateRequest, I as isPureLocalCssImportWrapper, M as isCssSourceTraceEnabled, O as stripBundlerGeneratedCssMarkers, S as isSourcePreprocessorRequest, T as createBundlerGeneratedCssMarker, U as extractCandidatesFromSource, a as collectGeneratedRawSourceCandidatesFromCss, d as normalizeMiniProgramImportShell, f as scoreTailwindV4CssSourceFileMatch, h as mergeMarkedUserLayerComponentsCss, i as validateCandidatesByGenerator, j as createCssTokenSourceMap, k as annotateCssSourceTrace, l as runWithConcurrency, m as extractMarkedUserLayerComponentsCss, r as generateTailwindV4Css, t as createHmrTimingRecorder, u as normalizeMiniProgramGeneratorCssSource, z as finalizeCompilerShadowRun } from "./hmr-timing-wAt0LavM.js";
6
- import { E as normalizeFrameworkStylePlatform, G as replaceWxml, K as createDebug, L as createCompilationDependencyChanges, N as recordCompilationDependencyChanges, O as AssetEmissionPlan, a as beginCompilerShadowRun, b as logTailwindcssTarget, f as getCompilerContext, g as vitePluginName, i as disposeCompilerOwner, n as createRuntimeAffectingSourceSignature, v as shouldSkipJsTransform, x as logRuntimeTailwindcssVersion, y as toCustomAttributesEntities } from "./compiler-D_vxtEdw.js";
7
- import { i as buildRuntimeCompilationSnapshot, l as updateRuntimeCompilationBuildState, n as hasEmptyCssBlockCandidate, o as createRuntimeCompilationBuildState, r as processCachedTask, t as finalizeMiniProgramCssStructure } from "./final-css-cleanup-B0HUBtiE.js";
8
- import { a as createJsHashSalt, c as hasRuntimeAffectingSourceChanges, d as resolvePluginDisabledState, f as createBuiltinViteStyleInjectorPlugins, g as resolveViteFrameworkProfile, i as createCandidateSignature, l as summarizeStringDiff, m as viteStyleInjectorDelegates, n as createScopedGeneratorRuntime, o as createLinkedImpactSignature, r as createScopedGeneratorSourceTraceMap, s as getSnapshotHash, t as createScopedGeneratorCandidateSignature, u as classifyRuntimeEntry } from "./scoped-generator-BqxVxNp9.js";
9
- import { $ as isMatchingCssSourceFile, A as createGenericWebProductionSourceCandidatesApply, At as resolveViteCssPipelineOutputFileFromSourceFile, B as parseVueRequest, Bt as createViteCssAssetIdentityResolver, C as collectViteProcessedCssSources, Ct as SOURCE_STYLE_OUTPUT_EXT_RE, D as registerGeneratorDependencies$1, Dt as resolveReplayCssOutputFile, E as inferPlatformFromViteOutDir$1, Et as resolveMiniProgramStyleOutputExtension, F as resolveHotSourceModulesByIds, Ft as normalizePath, G as hasSfcStyleSources, Gt as frameworkViteCapabilityProfile, H as shouldApplyViteWebCssCompat, Ht as getActiveViteSourceOutputRelationOwner, I as resolveHotTailwindCssModules, It as resolveViteCssPipelineRequestFile, J as normalizeSfcSourceFileForCompare, K as hasTailwindGenerationSource, L as sendFullReloadForUnresolvedHotUpdate, Lt as slash, M as hasSelfAcceptingNonStyleHotModule, Mt as formatPostcssSourceMap, N as mergeHotModulesByIdentity, Nt as isCSSRequest, O as shouldGenerateCssByGenerator, Ot as resolveViteCssOutputFile, P as resolveHotSourceModules, Pt as isHTMLRequest, Q as hasMatchingStyleFileBase, R as sendSupplementalCssHotUpdates, Rt as createCssHandlerOptionsCache, S as tryFinalizeGenericWebCss, St as CSS_SOURCE_OUTPUT_EXT_RE, T as finalizeWebCss, Tt as normalizeCssSourceForCompare, U as collectChunkModuleIds$3, Ut as withViteSourceOutputRelationOwner, V as resolveViteWebCssCompatOptions, Vt as createViteSourceOutputRelationOwner, W as extractSfcStyleBlocks, Wt as createGenericWebViteCapabilityProfile, X as resolveSfcStyleSourceFromOutputFile, Y as resolveSfcStyleRequestFromKnownSource, Z as resolveSourceStyleSourceFromOutputFile, _ as summarizeStringCache, _t as resolveViteProcessedCssAssetSource, a as createFrameworkProcessedCssRegistry, at as createCssAssetPipelineContext, b as touchMapEntry, bt as isRootStyleOutputFile, c as createViteHmrCssModuleVersionTracker, ct as hasNonCommentCss, d as createViteCssGenerationPlugins, dt as normalizeInjectableCssForTarget, et as appendCss$1, f as createViteRuntimeClassSet, ft as normalizeInjectableCssForTargetWithImports, g as normalizeVitePersistentCacheKey, gt as removeTailwindEntryDirectivesFromCss, h as isMissingInternalCssSource, ht as removeDuplicateUnlinkedRootCssAssetsReferencedByHtml, i as syncFrameworkSourceCandidatesForHotUpdate, it as collectRootStyleBundleCssSources, j as shouldSkipGenericWebProductionSourceCandidates, jt as cleanUrl$1, k as createGenericWebProductionBundleHooks, kt as resolveViteCssPipelineOutputFile, l as createViteHmrCandidateState, lt as isMatchingGeneratedCssMarkerFile, m as hasVitePipelineTailwindGenerationDirective, mt as readAssetSource$2, n as createFrameworkTailwindRootCss, nt as collectImportedStyleFiles, o as createFrameworkPostPlugin, ot as dedupeViteCssResults, p as createRewriteCssImportsPlugins, pt as normalizeMarkerOutputFile, q as isSfcStyleSourceFile, r as createFrameworkSourceScanSession, rt as collectMatchingGeneratedCssMarkerFiles, s as createViteHmrCssModuleVersionFilterPlugin, st as getAssetFile$1, t as createGenericWebVitePlugins, tt as clearAssetSource, u as createFrameworkCssGenerationQueue, ut as isStyleImportRequest, v as createViteCssMemory, vt as isCssOutputFile, w as createCssHandlerOptions, wt as canProcessViteSourceStyleAsCss, x as createViteWebCssFinalizerOutputPlugin, xt as posix, y as shouldCollectTransformedSourceCandidates, yt as isMiniProgramStyleOutputFile, z as resolveViteModuleIdentity, zt as resolveViteCssHandlerExtraOptions } from "./web-CdXkY_VO.js";
10
- import { a as toAbsoluteOutputPath, i as resolveOutputSpecifier, n as resolvePackageDir, r as normalizeOutputPathKey } from "./source-candidate-scan-signature-Lm32zKVA.js";
5
+ import { D as logTailwindcssTarget, E as toCustomAttributesEntities, G as createCompilationDependencyChanges, I as AssetEmissionPlan, N as createDebug, O as logRuntimeTailwindcssVersion, P as normalizeFrameworkStylePlatform, V as recordCompilationDependencyChanges, a as beginCompilerShadowRun, f as getCompilerContext, g as vitePluginName, i as disposeCompilerOwner, n as createRuntimeAffectingSourceSignature, y as shouldSkipJsTransform } from "./compiler-CThodfGH.js";
6
+ import { B as isSourcePreprocessorRequest, C as extractMarkedUserLayerComponentsCss, E as splitUserCssLayerBlocks, K as isPureLocalCssImportWrapper, L as hasTailwindGeneratedCssMarkers, M as normalizeEmptyTailwindCustomVariants$1, Q as extractCandidatesFromSource, T as hasUserCssLayerBlocks, V as isSourceStyleRequest, Y as createSourceCandidateCollector, Z as isSourceCandidateRequest, a as hasBundlerGeneratedCssMarker, at as hasTailwindSourceDirectives, b as normalizeMiniProgramImportShell, c as annotateCssSourceTrace, ct as parseImportRequest, d as isCssSourceTraceEnabled, dt as finalizeCompilerShadowRun, f as generateTailwindV4Css, i as createBundlerGeneratedCssMarker, it as hasTailwindRootDirectives, l as createCssSourceTraceCacheSignature, lt as removeTailwindSourceDirectives, m as collectGeneratedRawSourceCandidatesFromCss, nt as hasTailwindApplyDirective, o as parseBundlerGeneratedCssMarkerBlocks, ot as normalizeTailwindConfigDirectives$1, p as validateCandidatesByGenerator, r as createBundlerGeneratedCssEndMarker, s as stripBundlerGeneratedCssMarkers, st as normalizeTailwindSourceForGenerator, t as createHmrTimingRecorder, u as createCssTokenSourceMap, v as runWithConcurrency, w as mergeMarkedUserLayerComponentsCss, x as scoreTailwindV4CssSourceFileMatch, y as normalizeMiniProgramGeneratorCssSource } from "./hmr-timing-xPpat-km.js";
7
+ import { a as createRuntimeCompilationBuildState, c as updateRuntimeCompilationBuildState, n as processCachedTask, r as buildRuntimeCompilationSnapshot, t as finalizeMiniProgramCssStructure } from "./final-css-cleanup-BOzhuhGz.js";
8
+ import { a as hasMiniProgramCssSpecificityPlaceholders, b as resolveViteFrameworkProfile, c as createCandidateSignature, d as getSnapshotHash, f as hasRuntimeAffectingSourceChanges, g as createBuiltinViteStyleInjectorPlugins, h as resolvePluginDisabledState, l as createJsHashSalt, m as classifyRuntimeEntry, n as createScopedGeneratorRuntime, p as summarizeStringDiff, r as createScopedGeneratorSourceTraceMap, s as stripMiniProgramCssSpecificityPlaceholders, t as createScopedGeneratorCandidateSignature, u as createLinkedImpactSignature, v as viteStyleInjectorDelegates } from "./scoped-generator-DlQrVbuC.js";
9
+ import { $ as resolveSourceStyleSourceFromOutputFile, A as finalizeWebCss, At as formatPostcssSourceMap, B as sendSupplementalCssHotUpdates, Bt as isRootStyleOutputFile, C as tryFinalizeGenericWebCss, Ct as normalizeCssSourceForCompare, D as finalizeWebCssCalc, Dt as resolveViteCssPipelineOutputFile, E as shouldSkipGenericWebProductionSourceCandidates, Et as resolveViteCssOutputFile, F as mergeHotModulesByIdentity, Ft as slash, G as collectChunkModuleIds$3, Gt as createGenericWebViteCapabilityProfile, H as parseVueRequest, Ht as createViteSourceOutputRelationOwner, I as resolveHotSourceModules, It as createCssHandlerOptionsCache, J as hasTailwindGenerationSource, K as extractSfcStyleBlocks, Kt as frameworkViteCapabilityProfile, L as resolveHotSourceModulesByIds, Lt as resolveViteCssHandlerExtraOptions, M as registerGeneratorDependencies$1, Mt as isHTMLRequest, N as shouldGenerateCssByGenerator, Nt as normalizePath, O as collectViteProcessedCssSources, Ot as resolveViteCssPipelineOutputFileFromSourceFile, P as hasSelfAcceptingNonStyleHotModule, Pt as resolveViteCssPipelineRequestFile, Q as resolveSfcStyleSourceFromOutputFile, R as resolveHotTailwindCssModules, Rt as isCssOutputFile, S as createViteWebCssFinalizerOutputPlugin, St as canProcessViteSourceStyleAsCss, T as createGenericWebProductionSourceCandidatesApply, Tt as resolveReplayCssOutputFile, U as resolveViteWebCssCompatOptions, Ut as getActiveViteSourceOutputRelationOwner, V as resolveViteModuleIdentity, Vt as createViteCssAssetIdentityResolver, W as shouldApplyViteWebCssCompat, Wt as withViteSourceOutputRelationOwner, X as normalizeSfcSourceFileForCompare, Y as isSfcStyleSourceFile, Z as resolveSfcStyleRequestFromKnownSource, _ as normalizeVitePersistentCacheKey, _t as removeTailwindEntryDirectivesFromCss, a as readViteHmrSource, at as collectMatchingGeneratedCssMarkerFiles, b as shouldCollectTransformedSourceCandidates, bt as CSS_SOURCE_OUTPUT_EXT_RE, c as createViteHmrCssModuleVersionFilterPlugin, ct as dedupeViteCssResults, d as createFrameworkCssGenerationQueue, dt as isMatchingGeneratedCssMarkerFile, et as hasMatchingStyleFileBase, f as createViteCssGenerationPlugins, ft as normalizeInjectableCssForTarget, g as isMissingInternalCssSource, gt as removeDuplicateUnlinkedRootCssAssetsReferencedByHtml, h as hasVitePipelineTailwindGenerationDirective, ht as readAssetSource$2, i as syncFrameworkSourceCandidatesForHotUpdate, it as collectImportedStyleFiles, j as inferPlatformFromViteOutDir$1, jt as isCSSRequest, k as createCssHandlerOptions, kt as cleanUrl$1, l as createViteHmrCssModuleVersionTracker, lt as getAssetFile$1, m as createRewriteCssImportsPlugins, mt as normalizeMarkerOutputFile, n as createFrameworkTailwindRootCss, nt as appendCss$1, o as createFrameworkProcessedCssRegistry, ot as collectRootStyleBundleCssSources, p as createViteRuntimeClassSet, pt as normalizeInjectableCssForTargetWithImports, q as hasSfcStyleSources, r as createFrameworkSourceScanSession, rt as clearAssetSource, s as createFrameworkPostPlugin, st as createCssAssetPipelineContext, t as createGenericWebVitePlugins, tt as isMatchingCssSourceFile, u as createViteHmrCandidateState, ut as hasNonCommentCss, v as summarizeStringCache, vt as resolveViteProcessedCssAssetSource, w as createGenericWebProductionBundleHooks, wt as resolveMiniProgramStyleOutputExtension, x as touchMapEntry, xt as SOURCE_STYLE_OUTPUT_EXT_RE, y as createViteCssMemory, yt as posix, z as sendFullReloadForUnresolvedHotUpdate, zt as isMiniProgramStyleOutputFile } from "./web--kA4HUTm.js";
10
+ import { a as toAbsoluteOutputPath, i as resolveOutputSpecifier, n as resolvePackageDir, r as normalizeOutputPathKey } from "./source-candidate-scan-signature-BjVQYL-C.js";
11
11
  import { t as logger$1 } from "./logger-BNzxZbZj.js";
12
12
  import fs, { existsSync, readFileSync } from "node:fs";
13
13
  import path from "node:path";
14
14
  import process from "node:process";
15
- import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
16
- import { compileCssMacroConditionalComments, containsCssAfterMinify, createCssRuleMatcher, createInjectPreflight, filterExistingCssRules, isMiniProgramLocalCssImportRequest, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeTailwindcssV4InfinityCalcCss, normalizeUniAppXImportantApplyForSass, parseTailwindCssDirectiveRequest, postcss, restoreUniAppXImportantApplyMarker, transformWebCssCompat, transformWebCssSafeSelectors, unwrapUnsupportedCascadeLayers } from "@weapp-tailwindcss/postcss";
15
+ import { splitCandidateTokens } from "@weapp-tailwindcss/engine";
16
+ import { UNI_APP_X_BORDER_PREFLIGHT_CLASS, analyzeTailwindV4Source, collectCssApplyUtilities, collectCssReferenceDirectives, collectRootScopedComparableCssCoverage, compileCssMacroConditionalComments, containsCssAfterMinify, createCssRuleMatcher, createUniAppXBorderPreflight, createUniAppXHarmonyApplyCssExpander, createUniAppXHarmonyApplyGeneratorSource, cssToClassStyleValue, expandCssApplySourcesToStyleValue, filterExistingCssRules, hasCssLocationDependencies, hasVueScopedAttr, hoistUniAppXBorderPreflight, isCssImportOnly, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeTailwindcssV4InfinityCalcCss, normalizeUniAppXImportantApplyForSass, normalizeUniAppXStyleProperty, normalizeUniAppXStyleValue, parseCssImportSpecifier, parseTailwindCssDirectiveRequest, postcss, quoteCssImportSpecifier, removeCommentOnlyAtRules, removeCssCoveredByRootStyleSources, removeCssRulesCoveredBySources, removeCssRulesCoveredBySources as removeCssRulesCoveredBySources$1, removeScopedTailwindPreflightCss, replaceViteGeneratedCssModule, restoreProcessedCssImports, restoreUniAppXImportantApplyMarker, retainUniAppXAuthorApplyCss, rewriteCssConfigRequests, rewriteUniAppXStyleReferences, transformWebCssCompat, transformWebCssSafeSelectors, unwrapUnsupportedCascadeLayers } from "@weapp-tailwindcss/postcss/transform";
17
17
  import { LRUCache } from "lru-cache";
18
- import { readFile } from "node:fs/promises";
19
- import micromatch from "micromatch";
20
18
  import { cleanUrl, ensurePosix } from "@weapp-tailwindcss/shared";
21
19
  import { Buffer } from "node:buffer";
20
+ import { readFile } from "node:fs/promises";
22
21
  import { logger } from "@weapp-tailwindcss/logger";
23
22
  import { AsyncLocalStorage } from "node:async_hooks";
24
- import scss from "postcss-scss";
23
+ import micromatch from "micromatch";
25
24
  import { NodeTypes } from "@vue/compiler-dom";
26
25
  import { parse as parse$1 } from "comment-json";
27
- //#region src/uni-app-x/style-asset/source-parser.ts
28
- function parseUniAppXStyleSource(source) {
29
- return scss.parse(source, { from: void 0 });
30
- }
31
- function isUniAppXStyleSourceEmpty(source) {
32
- try {
33
- return parseUniAppXStyleSource(source).nodes.every((node) => node.type === "comment");
34
- } catch {
35
- return false;
36
- }
37
- }
38
- //#endregion
39
26
  //#region src/uni-app-x/style-asset/harmony-apply.ts
40
27
  const SFC_STYLE_BLOCK_RE$1 = /(<style\b[^>]*>)([\s\S]*?)(<\/style>)/gi;
41
- function createGeneratedRuleMap(css) {
42
- let root;
43
- try {
44
- root = postcss.parse(css);
45
- } catch {
46
- return;
47
- }
48
- const rules = /* @__PURE__ */ new Map();
49
- root.walkRules((rule) => {
50
- if (rule.nodes && rule.nodes.length > 0) rules.set(rule.selector.trim(), rule.nodes.map((node) => node.clone()));
51
- });
52
- return rules.size > 0 ? rules : void 0;
53
- }
54
28
  function expandUniAppXHarmonyApplyStyles(source, generatedCss) {
55
29
  if (!source.includes("@apply")) return source;
56
- const generatedRules = createGeneratedRuleMap(generatedCss);
57
- if (!generatedRules) return source;
58
- return source.replace(SFC_STYLE_BLOCK_RE$1, (block, open, styleSource, close) => {
59
- if (!styleSource.includes("@apply")) return block;
60
- let root;
61
- try {
62
- root = parseUniAppXStyleSource(styleSource);
63
- } catch {
64
- return block;
65
- }
66
- let changed = false;
67
- root.walkRules((rule) => {
68
- if (!(rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply") === true)) return;
69
- const generatedNodes = generatedRules.get(rule.selector.trim());
70
- if (!generatedNodes) return;
71
- rule.removeAll();
72
- rule.append(generatedNodes.map((node) => node.clone()));
73
- changed = true;
74
- });
75
- if (!changed) return block;
76
- if (!root.toString().includes("@apply")) root.walkAtRules("reference", (rule) => rule.remove());
77
- return `${open}${root.toString()}${close}`;
30
+ const expand = createUniAppXHarmonyApplyCssExpander(generatedCss);
31
+ if (!expand) return source;
32
+ return source.replace(SFC_STYLE_BLOCK_RE$1, (_block, open, styleSource, close) => {
33
+ return `${open}${expand(styleSource)}${close}`;
78
34
  });
79
35
  }
80
36
  //#endregion
@@ -107,8 +63,6 @@ const STYLE_ENTRY_RE = /\[\s*("((?:\\.|[^"\\])+)")\s*,\s*(_pS\(_uM\(\[[\s\S]*?\]
107
63
  const STRING_LITERAL_RE = /(['"`])((?:\\.|(?!\1)[\s\S])*?)\1/g;
108
64
  const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
109
65
  const STYLE_EXPORT_PREFIX_RE = /^\s*export\s+default\s+/;
110
- const CLASS_SELECTOR_PREFIX_RE = /^\.((?:\\[^\n\r\f]|[\w-])+)(?=$|[.:#[])/;
111
- const STRING_STYLE_PROPERTIES = /* @__PURE__ */ new Set(["lineHeight"]);
112
66
  function cloneStyleEntry(entry) {
113
67
  return Object.fromEntries(Object.entries(entry).map(([state, declarations]) => [state, { ...declarations }]));
114
68
  }
@@ -123,21 +77,6 @@ function mergeStyleEntry(local, generated) {
123
77
  function cloneStyleValue(style) {
124
78
  return Object.fromEntries(Object.entries(style).map(([className, entry]) => [className, cloneStyleEntry(entry)]));
125
79
  }
126
- function toCamelCase(prop) {
127
- return prop.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
128
- }
129
- function normalizeValue(prop, value) {
130
- const trimmed = value.trim();
131
- if (!STRING_STYLE_PROPERTIES.has(toCamelCase(prop)) && /^-?\d+(?:\.\d+)?px$/.test(trimmed)) return Number(trimmed.slice(0, -2));
132
- return trimmed.replace(/\s*,\s*/g, ",");
133
- }
134
- function normalizeStyleValue(prop, value) {
135
- if (typeof value === "number") return STRING_STYLE_PROPERTIES.has(toCamelCase(prop)) ? String(value) : value;
136
- return normalizeValue(prop, value);
137
- }
138
- function unescapeCssClassSelector(className) {
139
- return className.replace(/\\([^\n\r\f0-9a-f])/gi, "$1");
140
- }
141
80
  function parseStyleExport(source) {
142
81
  const json = source.replace(STYLE_EXPORT_PREFIX_RE, "").trim();
143
82
  if (!json) return;
@@ -168,7 +107,7 @@ function styleExportToUtsMap(styleExport) {
168
107
  const declarations = styleStates[""];
169
108
  if (!declarations || Object.keys(declarations).length === 0) continue;
170
109
  const declarationEntries = Object.entries(declarations).map(([prop, value]) => {
171
- return `[${JSON.stringify(toCamelCase(prop))}, ${JSON.stringify(normalizeStyleValue(prop, value))}]`;
110
+ return `[${JSON.stringify(normalizeUniAppXStyleProperty(prop))}, ${JSON.stringify(normalizeUniAppXStyleValue(prop, value))}]`;
172
111
  });
173
112
  if (declarationEntries.length === 0) continue;
174
113
  classEntries.push(`[${JSON.stringify(className)}, _pS(_uM([${declarationEntries.join(", ")}]))]`);
@@ -213,35 +152,8 @@ function createUtsStyleArrayFromAppStyles(code, appSource) {
213
152
  if (used.size === 0) return;
214
153
  return createUtsStyleArray([...used].map((className) => entries.get(className)).filter(Boolean));
215
154
  }
216
- function cssToStyleExport(source) {
217
- let root;
218
- try {
219
- root = postcss.parse(source);
220
- } catch {
221
- return;
222
- }
223
- const result = {};
224
- root.walkRules((rule) => {
225
- const selectors = rule.selectors ?? [];
226
- for (const selector of selectors) {
227
- const match = selector.trim().match(CLASS_SELECTOR_PREFIX_RE);
228
- if (!match?.[1]) continue;
229
- const declarations = {};
230
- rule.walkDecls((decl) => {
231
- declarations[toCamelCase(decl.prop)] = normalizeValue(decl.prop, decl.value);
232
- });
233
- if (Object.keys(declarations).length > 0) {
234
- result[match[1]] = { "": declarations };
235
- const className = unescapeCssClassSelector(match[1]);
236
- result[className] = { "": declarations };
237
- result[replaceWxml(className)] = { "": declarations };
238
- }
239
- }
240
- });
241
- return Object.keys(result).length > 0 ? result : void 0;
242
- }
243
155
  function cssSourceToStyleValue(source) {
244
- return STYLE_EXPORT_PREFIX_RE.test(source) ? parseStyleExport(source) : cssToStyleExport(source);
156
+ return STYLE_EXPORT_PREFIX_RE.test(source) ? parseStyleExport(source) : cssToClassStyleValue(source);
245
157
  }
246
158
  function mergeStyleValues(...items) {
247
159
  const result = {};
@@ -257,72 +169,23 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
257
169
  for (const source of sources) {
258
170
  const styleSources = source.includes("<style") ? [...source.matchAll(SFC_STYLE_BLOCK_RE)].map((styleBlock) => styleBlock[1] ?? "") : [source];
259
171
  for (const styleSource of styleSources) {
260
- let root;
261
- try {
262
- root = parseUniAppXStyleSource(styleSource);
263
- } catch {
264
- continue;
265
- }
266
- root.walkRules((rule) => {
267
- const applyRules = rule.nodes?.filter((node) => node.type === "atrule" && node.name === "apply") ?? [];
268
- if (applyRules.length === 0) return;
269
- const selectors = rule.selectors ?? [rule.selector];
270
- for (const selector of selectors) {
271
- const className = selector.trim().match(CLASS_SELECTOR_PREFIX_RE)?.[1];
272
- if (!className) continue;
273
- const declarations = {};
274
- for (const applyRule of applyRules) for (const utility of splitCandidateTokens(applyRule.params)) {
275
- const utilityDeclarations = utilityStyles[utility]?.[""] ?? utilityStyles[replaceWxml(utility)]?.[""];
276
- if (utilityDeclarations) Object.assign(declarations, utilityDeclarations);
277
- }
278
- if (Object.keys(declarations).length > 0) {
279
- const unescapedClassName = unescapeCssClassSelector(className);
280
- result[className] = { "": declarations };
281
- result[unescapedClassName] = { "": declarations };
282
- result[replaceWxml(unescapedClassName)] = { "": declarations };
283
- }
284
- }
285
- });
172
+ const applied = expandCssApplySourcesToStyleValue(styleSource, utilityStyles);
173
+ if (!applied) continue;
174
+ Object.assign(result, applied);
286
175
  }
287
176
  }
288
177
  return Object.keys(result).length > 0 ? result : void 0;
289
178
  }
290
179
  function resolveReferencePaths(styleSource, sourceId) {
291
- let root;
292
- try {
293
- root = parseUniAppXStyleSource(styleSource);
294
- } catch {
295
- return styleSource;
296
- }
297
- if (!sourceId || !styleSource.includes("@reference")) return root.toString();
298
- const cleanSourceId = sourceId.replace(/\?.*$/, "");
299
- root.walkAtRules("reference", (rule) => {
300
- const quote = rule.params[0];
301
- if (quote !== "\"" && quote !== "'") return;
302
- const closingQuoteIndex = rule.params.indexOf(quote, 1);
303
- if (closingQuoteIndex <= 1) return;
304
- const referencePath = rule.params.slice(1, closingQuoteIndex);
305
- if (!referencePath.startsWith(".")) return;
306
- rule.params = `${quote}${resolveStyleReferencePath(cleanSourceId, referencePath)}${quote}${rule.params.slice(closingQuoteIndex + 1)}`;
307
- });
308
- return root.toString();
180
+ const cleanSourceId = sourceId?.replace(/\?.*$/, "");
181
+ return rewriteUniAppXStyleReferences(styleSource, sourceId ? (reference) => resolveStyleReferencePath(cleanSourceId, reference) : void 0);
309
182
  }
310
183
  function collectUniAppXHarmonyApplyStyleSourcesFromSource(source, sourceId) {
311
184
  return (source.includes("<style") ? [...source.matchAll(SFC_STYLE_BLOCK_RE)].map((styleBlock) => styleBlock[1] ?? "") : [source]).map((styleSource) => resolveReferencePaths(styleSource.trim(), sourceId)).filter((styleSource) => styleSource.length > 0 && styleSource.includes("@apply"));
312
185
  }
313
186
  function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
314
187
  const utilities = /* @__PURE__ */ new Set();
315
- for (const source of sources) for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) {
316
- let root;
317
- try {
318
- root = parseUniAppXStyleSource(styleSource);
319
- } catch {
320
- continue;
321
- }
322
- root.walkAtRules("apply", (rule) => {
323
- for (const utility of splitCandidateTokens(rule.params)) utilities.add(utility);
324
- });
325
- }
188
+ for (const source of sources) for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) for (const utility of collectCssApplyUtilities(styleSource)) utilities.add(utility);
326
189
  return utilities;
327
190
  }
328
191
  function createMergedStyleValue(code, localStyle, appStyle) {
@@ -535,19 +398,8 @@ function resolveSourceMapFiles(file) {
535
398
  ].filter((item) => typeof item === "string");
536
399
  }
537
400
  const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v3";
538
- function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
539
- return applyStyleSources.map((source) => {
540
- let root;
541
- try {
542
- root = parseUniAppXStyleSource(source);
543
- } catch {
544
- return source;
545
- }
546
- root.walkAtRules("reference", (rule) => {
547
- if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
548
- });
549
- return root.toString();
550
- }).join("\n");
401
+ function createUniAppXHarmonyApplyGeneratorSource$1(applyStyleSources, _applyUtilities) {
402
+ return createUniAppXHarmonyApplyGeneratorSource(applyStyleSources);
551
403
  }
552
404
  function collectUniAppXHarmonyApplyUtilities(bundle) {
553
405
  const utilities = /* @__PURE__ */ new Set();
@@ -824,57 +676,207 @@ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
824
676
  }
825
677
  }
826
678
  //#endregion
827
- //#region src/bundlers/vite/processed-css-assets/cleanup.ts
828
- function collectCssImportAtRuleCss(css) {
829
- if (!css.includes("@import")) return [];
830
- const fallbackImports = [...css.matchAll(/@import\s[^;]+;?/g)].map((match) => match[0]);
831
- if (fallbackImports.length > 0) return fallbackImports;
832
- try {
833
- const root = postcss.parse(css);
834
- const imports = [];
835
- root.each((node) => {
836
- if (node.type === "atrule" && node.name === "import") imports.push(node.toString());
837
- });
838
- return imports;
839
- } catch {
840
- return [];
679
+ //#region src/bundlers/vite/generate-bundle/asset-emission-plan.ts
680
+ function applyViteAssetEmissionPlan(plan, options) {
681
+ for (const operation of plan.operations()) {
682
+ if (operation.kind === "delete") {
683
+ delete options.bundle[operation.assetId];
684
+ continue;
685
+ }
686
+ const writeTarget = options.writeTargets?.get(operation.assetId);
687
+ const existing = options.bundle[operation.assetId];
688
+ const asset = writeTarget ?? (existing?.type === "asset" ? existing : void 0);
689
+ if (asset) {
690
+ asset.source = operation.source;
691
+ continue;
692
+ }
693
+ const replayAsset = options.emitOrReplayAsset?.(operation.assetId, operation.source);
694
+ if (replayAsset) options.bundle[operation.assetId] = replayAsset;
841
695
  }
842
696
  }
843
- function parseCssImportRequest(importCss) {
844
- const trimmed = importCss.trim();
845
- if (!trimmed.startsWith("@import")) return;
846
- const params = trimmed.slice(7).trim().replace(/;$/, "").trim();
847
- return parseTailwindCssDirectiveRequest(params);
697
+ //#endregion
698
+ //#region src/bundlers/vite/generate-bundle/root-style-output.ts
699
+ function isRootMiniProgramStyleOutputFile$1(file) {
700
+ const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
701
+ return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
848
702
  }
849
- function shouldRestoreCssImportAtRule(importCss, file) {
850
- if (file === void 0 || !isMiniProgramStyleOutputFile(file)) return true;
851
- const request = parseCssImportRequest(importCss);
852
- if (request === void 0) return false;
853
- if (isMiniProgramLocalCssImportRequest(request)) return true;
854
- return isStyleImportRequest(request) && !request.includes("/");
703
+ function createRelativeCssImportRequest$1(targetFile, importedFile) {
704
+ const normalizedTargetFile = normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
705
+ const normalizedImportedFile = normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
706
+ const targetDir = path.posix.dirname(normalizedTargetFile);
707
+ const baseDir = targetDir === "." ? "" : targetDir;
708
+ const relative = path.posix.relative(baseDir, normalizedImportedFile);
709
+ return relative.startsWith(".") ? relative : `./${relative}`;
855
710
  }
856
- function restoreCssImportAtRules(source, filtered, file) {
857
- const imports = collectCssImportAtRuleCss(source).filter((importCss) => shouldRestoreCssImportAtRule(importCss, file));
858
- if (imports.length === 0) return filtered;
859
- const missingImports = imports.filter((importCss) => !filtered.includes(importCss));
860
- if (missingImports.length === 0) return filtered;
861
- return appendCss$1(missingImports.join("\n"), filtered);
862
- }
863
- function removeCommentOnlyAtRules(css) {
864
- if (!hasEmptyCssBlockCandidate(css)) return css;
711
+ function createCssImportShell$1(targetFile, importedFile) {
712
+ return `@import "${createRelativeCssImportRequest$1(targetFile, importedFile)}";\n`;
713
+ }
714
+ function resolveSingleCssImportOutputFile(targetFile, css) {
715
+ let importedFile;
865
716
  try {
866
- const root = postcss.parse(css);
867
- let changed = false;
868
- root.walkAtRules((atRule) => {
869
- if (!atRule.nodes || atRule.nodes.length === 0) return;
870
- if (atRule.nodes.some((node) => node.type !== "comment")) return;
871
- atRule.remove();
872
- changed = true;
717
+ postcss.parse(css).walkAtRules("import", (atRule) => {
718
+ if (importedFile !== void 0) return;
719
+ const request = parseImportRequest(atRule.params);
720
+ if (!request || /^(?:https?:)?\/\//i.test(request) || request.startsWith("data:")) return;
721
+ const cleanRequest = request.replace(/[?#].*$/, "");
722
+ if (!/\.(?:css|wxss|acss|ttss|qss|jxss|tyss)$/i.test(cleanRequest)) return;
723
+ const targetDir = path.posix.dirname(normalizeOutputPathKey(targetFile));
724
+ importedFile = normalizeOutputPathKey(path.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
873
725
  });
874
- return changed ? root.toString() : css;
875
- } catch {
876
- return css;
726
+ } catch {}
727
+ return importedFile;
728
+ }
729
+ function createRootMiniProgramOriginStyleOutputFile(file) {
730
+ const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
731
+ if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return normalized;
732
+ return normalized.replace(/(\.[^.]+)$/, "-origin$1");
733
+ }
734
+ function shouldKeepRootMiniProgramStyleAsImportShell(enabled) {
735
+ return enabled === true;
736
+ }
737
+ function shouldPreserveFrameworkRootMiniProgramImportShell(options) {
738
+ return !options.isWebGeneratorTarget && options.matchesCss && isRootStyleOutputFile(options.file) && isPureLocalCssImportWrapper(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
739
+ }
740
+ function resolveFrameworkRootImportShellPlan(options) {
741
+ const isCurrentImportShell = shouldPreserveFrameworkRootMiniProgramImportShell({
742
+ css: options.rawSource,
743
+ file: options.rootImportShellOutputFile,
744
+ isWebGeneratorTarget: options.isWebGeneratorTarget,
745
+ matchesCss: options.matchesCss,
746
+ shouldKeep: options.shouldKeep
747
+ });
748
+ if (isCurrentImportShell) {
749
+ const importedFile = resolveSingleCssImportOutputFile(options.rootImportShellOutputFile, options.rawSource);
750
+ return {
751
+ isCurrentImportShell,
752
+ reusableTarget: options.rememberedTarget,
753
+ targetToRemember: importedFile && isRootStyleOutputFile(importedFile) ? importedFile : void 0
754
+ };
877
755
  }
756
+ if (options.rememberedTarget) return {
757
+ isCurrentImportShell,
758
+ reusableTarget: options.rememberedTarget,
759
+ targetToRemember: void 0
760
+ };
761
+ if (!(!options.isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(options.rootImportShellOutputFile) && normalizeOutputPathKey(options.assetSourceFile) === normalizeOutputPathKey(options.file) && options.isMainChunk && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep()) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(options.shouldMoveToOrigin()))) return {
762
+ isCurrentImportShell,
763
+ reusableTarget: void 0,
764
+ targetToRemember: void 0
765
+ };
766
+ const targets = new Set([...options.configuredTargetFiles, ...options.processedTargetFiles].filter((file) => typeof file === "string" && isRootMiniProgramStyleOutputFile$1(file) && normalizeOutputPathKey(file) !== normalizeOutputPathKey(options.rootImportShellOutputFile)));
767
+ const target = targets.size === 1 ? [...targets][0] : void 0;
768
+ return {
769
+ isCurrentImportShell,
770
+ reusableTarget: target,
771
+ targetToRemember: target
772
+ };
773
+ }
774
+ function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
775
+ if (options.isWebGeneratorTarget || options.targetByFile.size === 0) return 0;
776
+ const plan = new AssetEmissionPlan();
777
+ const writeTargets = /* @__PURE__ */ new Map();
778
+ let restored = 0;
779
+ for (const [sourceFile, targetFile] of options.targetByFile) {
780
+ if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !isRootStyleOutputFile(sourceFile) || !isRootStyleOutputFile(targetFile) || normalizeOutputPathKey(sourceFile) === normalizeOutputPathKey(targetFile)) continue;
781
+ const output = Object.entries(bundle).find(([bundleFile, candidate]) => candidate.type === "asset" && normalizeOutputPathKey(candidate.fileName || bundleFile) === normalizeOutputPathKey(sourceFile))?.[1];
782
+ if (output?.type !== "asset") continue;
783
+ const rawSource = output.source.toString();
784
+ if (!shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep(sourceFile, rawSource))) continue;
785
+ const nextSource = createCssImportShell$1(sourceFile, targetFile);
786
+ if (rawSource === nextSource) continue;
787
+ plan.write(sourceFile, nextSource);
788
+ writeTargets.set(sourceFile, output);
789
+ options.recordCssAssetResult?.(sourceFile, nextSource);
790
+ options.onUpdate?.(sourceFile, rawSource, nextSource);
791
+ options.debug?.("restore framework root css import shell: %s -> %s", sourceFile, targetFile);
792
+ restored++;
793
+ }
794
+ applyViteAssetEmissionPlan(plan, {
795
+ bundle,
796
+ writeTargets
797
+ });
798
+ return restored;
799
+ }
800
+ function resolveRuntimeRootStyleOutputFile(bundle, matchesCss) {
801
+ const rootChunks = Object.entries(bundle).flatMap(([bundleFile, output]) => {
802
+ if (output.type !== "chunk") return [];
803
+ const file = normalizeOutputPathKey(output.fileName || bundleFile);
804
+ if (file.includes("/")) return [];
805
+ return [{
806
+ file,
807
+ isEntry: output.isEntry === true
808
+ }];
809
+ });
810
+ const entryChunks = rootChunks.filter((chunk) => chunk.isEntry);
811
+ const rootChunkStems = new Set((entryChunks.length > 0 ? entryChunks : rootChunks).map((chunk) => path.posix.parse(chunk.file).name));
812
+ const candidates = Object.entries(bundle).flatMap(([bundleFile, output]) => {
813
+ if (output.type !== "asset") return [];
814
+ const file = normalizeOutputPathKey(output.fileName || bundleFile);
815
+ return isRootMiniProgramStyleOutputFile$1(file) && matchesCss(file) && rootChunkStems.has(path.posix.parse(file).name) ? [file] : [];
816
+ });
817
+ return candidates.length === 1 ? candidates[0] : void 0;
818
+ }
819
+ function linkFrameworkRootStyleToRuntimeEntry(bundle, options) {
820
+ if (options.targetByFile.size === 0) return 0;
821
+ const runtimeRootFile = resolveRuntimeRootStyleOutputFile(bundle, options.matchesCss);
822
+ if (!runtimeRootFile) return 0;
823
+ const frameworkRootFiles = [...options.targetByFile.keys()].filter((file) => normalizeOutputPathKey(file) !== normalizeOutputPathKey(runtimeRootFile) && isRootMiniProgramStyleOutputFile$1(file) && options.matchesCss(file));
824
+ if (frameworkRootFiles.length !== 1) return 0;
825
+ const frameworkRootFile = frameworkRootFiles[0];
826
+ const runtimeOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && normalizeOutputPathKey(output.fileName || bundleFile) === normalizeOutputPathKey(runtimeRootFile))?.[1];
827
+ const frameworkOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && normalizeOutputPathKey(output.fileName || bundleFile) === normalizeOutputPathKey(frameworkRootFile))?.[1];
828
+ if (runtimeOutput?.type !== "asset" || frameworkOutput?.type !== "asset") return 0;
829
+ const runtimeSource = runtimeOutput.source.toString();
830
+ const importedRuntimeFile = resolveSingleCssImportOutputFile(runtimeRootFile, runtimeSource);
831
+ if (importedRuntimeFile && normalizeOutputPathKey(importedRuntimeFile) === normalizeOutputPathKey(frameworkRootFile)) return 0;
832
+ const importedFrameworkFile = resolveSingleCssImportOutputFile(frameworkRootFile, frameworkOutput.source.toString());
833
+ if (importedFrameworkFile && normalizeOutputPathKey(importedFrameworkFile) === normalizeOutputPathKey(runtimeRootFile)) return 0;
834
+ const nextSource = `${createCssImportShell$1(runtimeRootFile, frameworkRootFile)}${runtimeSource}`;
835
+ runtimeOutput.source = nextSource;
836
+ options.recordCssAssetResult?.(runtimeRootFile, nextSource);
837
+ options.onUpdate?.(runtimeRootFile, runtimeSource, nextSource);
838
+ options.debug?.("link framework root css to runtime entry: %s -> %s", runtimeRootFile, frameworkRootFile);
839
+ return 1;
840
+ }
841
+ function shouldMoveRootMiniProgramStyleToImportShellOrigin(enabled) {
842
+ return enabled === true;
843
+ }
844
+ //#endregion
845
+ //#region src/bundlers/vite/generate-bundle/framework-style-memory.ts
846
+ function createFrameworkStyleMemory(targetByFile) {
847
+ const sources = /* @__PURE__ */ new Map();
848
+ return { prepare(bundle, removedFiles) {
849
+ for (const file of removedFiles) {
850
+ const key = normalizeOutputPathKey(file);
851
+ sources.delete(key);
852
+ for (const [source, target] of targetByFile) if (normalizeOutputPathKey(source) === key || normalizeOutputPathKey(target) === key) {
853
+ sources.delete(normalizeOutputPathKey(source));
854
+ targetByFile.delete(source);
855
+ }
856
+ }
857
+ const currentFiles = new Set(Object.entries(bundle).map(([file, asset]) => normalizeOutputPathKey(asset.fileName || file)));
858
+ for (const [file, asset] of sources) if (!currentFiles.has(file)) bundle[file] = { ...asset };
859
+ const inputs = /* @__PURE__ */ new Map();
860
+ for (const [file, asset] of Object.entries(bundle)) {
861
+ if (asset.type !== "asset" || !isRootMiniProgramStyleOutputFile$1(asset.fileName || file)) continue;
862
+ const source = typeof asset.source === "string" ? asset.source : Buffer.from(asset.source).toString();
863
+ if (hasBundlerGeneratedCssMarker(source)) sources.delete(normalizeOutputPathKey(asset.fileName || file));
864
+ else inputs.set(normalizeOutputPathKey(asset.fileName || file), {
865
+ ...asset,
866
+ source
867
+ });
868
+ }
869
+ return () => {
870
+ const mappedFiles = new Set([...targetByFile.keys()].map(normalizeOutputPathKey));
871
+ for (const file of sources.keys()) if (!mappedFiles.has(file)) sources.delete(file);
872
+ for (const [file, asset] of inputs) if (mappedFiles.has(file)) sources.set(file, asset);
873
+ };
874
+ } };
875
+ }
876
+ //#endregion
877
+ //#region src/bundlers/vite/processed-css-assets/cleanup.ts
878
+ function restoreCssImportAtRules(source, filtered, file) {
879
+ return restoreProcessedCssImports(source, filtered, file !== void 0 && isMiniProgramStyleOutputFile(file));
878
880
  }
879
881
  function collectImportedBundleCssSources(bundle, importedStyleFiles) {
880
882
  if (importedStyleFiles.size === 0) return [];
@@ -951,16 +953,7 @@ function findBundleAssetByOutputFile(bundle, file) {
951
953
  function isCssImportOnlyBundleAsset(bundle, file, css) {
952
954
  const importedStyleFiles = collectImportedStyleFiles(css, file);
953
955
  if (importedStyleFiles.size === 0) return false;
954
- let hasNonImportNode = false;
955
- try {
956
- postcss.parse(css).each((node) => {
957
- if (node.type === "comment") return;
958
- if (node.type !== "atrule" || node.name !== "import") hasNonImportNode = true;
959
- });
960
- } catch {
961
- return false;
962
- }
963
- if (hasNonImportNode) return false;
956
+ if (!isCssImportOnly(css)) return false;
964
957
  return collectImportedBundleCssSources(bundle, importedStyleFiles).length > 0;
965
958
  }
966
959
  function isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, resolveViteProcessedCssOutputFile) {
@@ -1055,218 +1048,7 @@ function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, so
1055
1048
  return sourceEntries;
1056
1049
  }
1057
1050
  //#endregion
1058
- //#region src/bundlers/vite/processed-css-assets/scoped-tailwind-noise.ts
1059
- const VUE_SCOPED_ATTR_RE = /\[data-v-[^\]]+\]/gi;
1060
- const VUE_SCOPED_CLASS_RE = /\.data-v-[\w-]+/gi;
1061
- const SCOPED_UNIVERSAL_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
1062
- "*",
1063
- ":after",
1064
- ":before",
1065
- "::after",
1066
- "::before",
1067
- "::backdrop",
1068
- "::file-selector-button"
1069
- ]);
1070
- const MINI_PROGRAM_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
1071
- "view",
1072
- "text",
1073
- "::after",
1074
- "::before"
1075
- ]);
1076
- const UNI_APP_WEB_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
1077
- "uni-view",
1078
- "uni-text",
1079
- ":after",
1080
- ":before",
1081
- "::after",
1082
- "::before"
1083
- ]);
1084
- const MINI_PROGRAM_PREFLIGHT_DECLARATIONS = /* @__PURE__ */ new Set([
1085
- "box-sizing",
1086
- "margin",
1087
- "padding",
1088
- "border"
1089
- ]);
1090
- const TAILWIND_PREFLIGHT_DECLARATIONS = /* @__PURE__ */ new Set([
1091
- "-moz-tab-size:4",
1092
- "-webkit-appearance:none",
1093
- "-webkit-appearance:button",
1094
- "-webkit-tap-highlight-color:transparent",
1095
- "-webkit-text-decoration:inherit",
1096
- "-webkit-text-decoration:underline dotted",
1097
- "-webkit-text-size-adjust:100%",
1098
- "-o-tab-size:4",
1099
- "appearance:button",
1100
- "background-color:transparent",
1101
- "border-collapse:collapse",
1102
- "border-color:inherit",
1103
- "border-radius:0",
1104
- "border-top-width:1px",
1105
- "bottom:-.25em",
1106
- "color:inherit",
1107
- "display:block",
1108
- "display:inline-flex",
1109
- "display:list-item",
1110
- "font:inherit",
1111
- "font-family:inherit",
1112
- "font-feature-settings:inherit",
1113
- "font-size:1em",
1114
- "font-size:75%",
1115
- "font-size:80%",
1116
- "font-size:inherit",
1117
- "font-variation-settings:inherit",
1118
- "font-weight:bolder",
1119
- "font-weight:inherit",
1120
- "height:0",
1121
- "height:auto",
1122
- "letter-spacing:inherit",
1123
- "line-height:1",
1124
- "line-height:1.5",
1125
- "line-height:0",
1126
- "line-height:inherit",
1127
- "list-style:none",
1128
- "margin-inline-end:4px",
1129
- "max-width:100%",
1130
- "min-height:1lh",
1131
- "opacity:1",
1132
- "outline:auto",
1133
- "padding:0",
1134
- "padding-block:0",
1135
- "position:relative",
1136
- "resize:vertical",
1137
- "tab-size:4",
1138
- "text-align:inherit",
1139
- "text-decoration:inherit",
1140
- "text-decoration:underline dotted",
1141
- "text-indent:0",
1142
- "text-transform:none",
1143
- "top:-.5em",
1144
- "vertical-align:baseline",
1145
- "vertical-align:middle"
1146
- ]);
1147
- function hasVueScopedAttr(value) {
1148
- VUE_SCOPED_ATTR_RE.lastIndex = 0;
1149
- VUE_SCOPED_CLASS_RE.lastIndex = 0;
1150
- const matched = VUE_SCOPED_ATTR_RE.test(value) || VUE_SCOPED_CLASS_RE.test(value);
1151
- VUE_SCOPED_ATTR_RE.lastIndex = 0;
1152
- VUE_SCOPED_CLASS_RE.lastIndex = 0;
1153
- return matched;
1154
- }
1155
- function normalizeCssSignatureValue(value) {
1156
- return value.replace(VUE_SCOPED_ATTR_RE, "").replace(VUE_SCOPED_CLASS_RE, "").replace(/\s+/g, " ").replace(/\s*([>+~])\s*/g, "$1").replace(/\(\s+/g, "(").replace(/\s+\)/g, ")").trim();
1157
- }
1158
- function hasClassSelector(selector) {
1159
- return /(?:^|[^\\])\.[_a-z\u00A0-\uFFFF-]/i.test(normalizeCssSignatureValue(selector));
1160
- }
1161
- function isLikelyTailwindGlobalSelector(selector) {
1162
- const normalized = normalizeCssSignatureValue(selector);
1163
- return normalized === "*" || normalized.startsWith("::") || normalized.startsWith(":root") || normalized.startsWith(":host") || /^(?:html|body|hr|abbr|h1|h2|h3|h4|h5|h6|a|b|strong|code|kbd|samp|pre|small|sub|sup|table|button|input|select|optgroup|textarea|summary|blockquote|dl|dd|fieldset|legend|ol|ul|menu|dialog|progress|video|audio|canvas|embed|iframe|img|object|svg|details|template|[uo]ni-progress)(?:$|[:,[\s>+~.#])/.test(normalized);
1164
- }
1165
- function isTailwindPreflightDeclaration(decl) {
1166
- const prop = decl.prop.trim().toLowerCase();
1167
- const value = normalizeCssSignatureValue(decl.value.trim().toLowerCase());
1168
- if (prop.startsWith("--tw-")) return true;
1169
- if (prop === "color" && value.startsWith("color-mix(") && value.includes("currentcolor") && value.includes("transparent")) return true;
1170
- if (prop === "color" && value === "currentcolor") return true;
1171
- if (prop === "font-family" && value.startsWith("var(--default-font-family") || prop === "font-feature-settings" && value.startsWith("var(--default-font-feature-settings") || prop === "font-variation-settings" && value.startsWith("var(--default-font-variation-settings")) return true;
1172
- return TAILWIND_PREFLIGHT_DECLARATIONS.has(`${prop}:${value}`);
1173
- }
1174
- function getRuleDeclarations(rule) {
1175
- return rule.nodes?.filter((node) => node.type === "decl") ?? [];
1176
- }
1177
- function isScopedTailwindThemeCarrierRule(rule) {
1178
- const selectors = rule.selectors ?? [rule.selector];
1179
- const declarations = getRuleDeclarations(rule);
1180
- return selectors.length > 0 && selectors.every((selector) => {
1181
- const normalized = normalizeCssSignatureValue(selector);
1182
- return hasVueScopedAttr(selector) && (normalized.startsWith(":root") || normalized.startsWith(":host"));
1183
- }) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--"));
1184
- }
1185
- function isScopedUniversalTailwindPreflightRule(rule) {
1186
- const selectors = rule.selectors ?? [rule.selector];
1187
- const declarations = getRuleDeclarations(rule);
1188
- return selectors.length > 0 && selectors.every((selector) => hasVueScopedAttr(selector) && SCOPED_UNIVERSAL_PREFLIGHT_SELECTORS.has(normalizeCssSignatureValue(selector))) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--tw-") || MINI_PROGRAM_PREFLIGHT_DECLARATIONS.has(decl.prop));
1189
- }
1190
- function isScopedUniAppWebTailwindPreflightRule(rule) {
1191
- const selectors = rule.selectors ?? [rule.selector];
1192
- const declarations = getRuleDeclarations(rule);
1193
- return selectors.length > 0 && selectors.every((selector) => hasVueScopedAttr(selector) && UNI_APP_WEB_PREFLIGHT_SELECTORS.has(normalizeCssSignatureValue(selector))) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--tw-") || MINI_PROGRAM_PREFLIGHT_DECLARATIONS.has(decl.prop));
1194
- }
1195
- function isLikelyTailwindGlobalRule(rule) {
1196
- const selectors = rule.selectors ?? [rule.selector];
1197
- const declarations = getRuleDeclarations(rule);
1198
- return isScopedTailwindThemeCarrierRule(rule) || isScopedUniversalTailwindPreflightRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || selectors.every((selector) => !hasClassSelector(selector) && isLikelyTailwindGlobalSelector(selector)) && declarations.length > 0 && declarations.every(isTailwindPreflightDeclaration);
1199
- }
1200
- function isLikelyTailwindPropertyAtRule(atRule) {
1201
- return atRule.name.toLowerCase() === "property" && normalizeCssSignatureValue(atRule.params).startsWith("--tw-");
1202
- }
1203
- function isLikelyTailwindLayerOrderAtRule(atRule) {
1204
- if (atRule.name.toLowerCase() !== "layer" || atRule.nodes !== void 0) return false;
1205
- const params = normalizeCssSignatureValue(atRule.params).replace(/\s+/g, "");
1206
- return params === "properties" || params === "theme" || params === "base" || params === "theme,base,components,utilities";
1207
- }
1208
- function isUnscopedMiniProgramTailwindPreflightRule(rule) {
1209
- const selectors = rule.selectors ?? [rule.selector];
1210
- if (selectors.length === 0 || !selectors.every((selector) => {
1211
- const normalized = normalizeCssSignatureValue(selector);
1212
- return !hasVueScopedAttr(selector) && MINI_PROGRAM_PREFLIGHT_SELECTORS.has(normalized);
1213
- })) return false;
1214
- const declarations = getRuleDeclarations(rule);
1215
- return declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--tw-") || MINI_PROGRAM_PREFLIGHT_DECLARATIONS.has(decl.prop));
1216
- }
1217
- function isScopedMiniProgramTailwindContentInitRule(rule) {
1218
- const selectors = rule.selectors ?? [rule.selector];
1219
- if (selectors.length === 0 || !selectors.every((selector) => {
1220
- const normalized = normalizeCssSignatureValue(selector);
1221
- return hasVueScopedAttr(selector) && MINI_PROGRAM_PREFLIGHT_SELECTORS.has(normalized);
1222
- })) return false;
1223
- const declarations = getRuleDeclarations(rule);
1224
- return declarations.length > 0 && declarations.every((decl) => decl.prop === "--tw-content");
1225
- }
1226
- //#endregion
1227
1051
  //#region src/bundlers/vite/processed-css-assets/coverage.ts
1228
- function createDeclarationSignature(rule) {
1229
- return createDeclarationKeys(rule).sort().join(";");
1230
- }
1231
- function createRuleCoverageKey(selector, declarations) {
1232
- return `${normalizeCssSignatureValue(selector)}\0${declarations}`;
1233
- }
1234
- function createDeclarationKeys(rule) {
1235
- return (rule.nodes ?? []).filter((node) => node.type === "decl").map((node) => `${node.prop}:${normalizeCssSignatureValue(node.value)}${node.important ? "!important" : ""}`);
1236
- }
1237
- function createAtRuleCoverageKey(atRule) {
1238
- return `${atRule.name}\0${normalizeCssSignatureValue(atRule.params)}\0${normalizeCssSignatureValue(atRule.toString())}`;
1239
- }
1240
- function collectRootScopedComparableCssCoverage(cssSources) {
1241
- const rules = /* @__PURE__ */ new Set();
1242
- const atRules = /* @__PURE__ */ new Set();
1243
- const declarationsBySelector = /* @__PURE__ */ new Map();
1244
- const normalizedRuleCss = /* @__PURE__ */ new Set();
1245
- for (const source of cssSources) try {
1246
- const root = postcss.parse(source);
1247
- root.walkRules((rule) => {
1248
- normalizedRuleCss.add(normalizeCssSignatureValue(rule.toString()));
1249
- const declarations = createDeclarationSignature(rule);
1250
- if (declarations.length === 0) return;
1251
- for (const selector of rule.selectors ?? [rule.selector]) {
1252
- const normalizedSelector = normalizeCssSignatureValue(selector);
1253
- rules.add(`${normalizedSelector}\0${declarations}`);
1254
- const selectorDeclarations = declarationsBySelector.get(normalizedSelector) ?? /* @__PURE__ */ new Set();
1255
- for (const declaration of createDeclarationKeys(rule)) selectorDeclarations.add(declaration);
1256
- declarationsBySelector.set(normalizedSelector, selectorDeclarations);
1257
- }
1258
- });
1259
- root.walkAtRules((atRule) => {
1260
- atRules.add(createAtRuleCoverageKey(atRule));
1261
- });
1262
- } catch {}
1263
- return {
1264
- rules,
1265
- atRules,
1266
- declarationsBySelector,
1267
- normalizedRuleCss
1268
- };
1269
- }
1270
1052
  function prepareImportedCssCoverage(importedCssSources) {
1271
1053
  const sources = importedCssSources.map((source) => stripBundlerGeneratedCssMarkers(source).trim()).filter(Boolean);
1272
1054
  if (sources.length === 0) return;
@@ -1275,313 +1057,40 @@ function prepareImportedCssCoverage(importedCssSources) {
1275
1057
  sources
1276
1058
  };
1277
1059
  }
1278
- function isRuleCoveredByRootCss(rule, coverage) {
1279
- const declarations = createDeclarationSignature(rule);
1280
- if (declarations.length === 0) return false;
1281
- const selectors = rule.selectors ?? [rule.selector];
1282
- if (selectors.every((selector) => coverage.rules.has(createRuleCoverageKey(selector, declarations)))) return true;
1283
- const declarationKeys = createDeclarationKeys(rule);
1284
- return declarationKeys.length > 0 && selectors.every((selector) => {
1285
- const rootDeclarations = coverage.declarationsBySelector.get(normalizeCssSignatureValue(selector));
1286
- return rootDeclarations != null && declarationKeys.every((declaration) => rootDeclarations.has(declaration));
1287
- });
1288
- }
1289
- function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
1290
- if (!hasVueScopedAttr(css)) return css;
1291
- const hasScopedTailwindGeneratedCss = /tailwindcss v\d/i.test(css);
1292
- const coverage = collectRootScopedComparableCssCoverage(rootSources);
1293
- try {
1294
- const root = postcss.parse(css);
1295
- let changed = false;
1296
- root.walkComments((comment) => {
1297
- if (/tailwindcss v\d/i.test(comment.text)) {
1298
- comment.remove();
1299
- changed = true;
1300
- }
1301
- });
1302
- root.walkRules((rule) => {
1303
- if (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule)) {
1304
- rule.remove();
1305
- changed = true;
1306
- }
1307
- });
1308
- root.walkAtRules((atRule) => {
1309
- if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
1310
- atRule.remove();
1311
- changed = true;
1312
- return;
1313
- }
1314
- if (atRule.nodes !== void 0 && atRule.nodes.length === 0) {
1315
- atRule.remove();
1316
- changed = true;
1317
- }
1318
- });
1319
- return changed ? removeDanglingCssSourceTraceComments(root.toString()).trim() : css;
1320
- } catch {
1321
- return css;
1322
- }
1323
- }
1324
- function removeScopedTailwindPreflightCss(css) {
1325
- return removeScopedCssCoveredByRootStyleSources(css, []);
1326
- }
1327
1060
  function collectSingleViteGeneratedCssMarkerFile(rawSource) {
1328
1061
  const blocks = parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite");
1329
- if (blocks.length !== 1) return;
1330
- const file = blocks[0]?.file;
1331
- return typeof file === "string" && file.length > 0 ? file : void 0;
1332
- }
1333
- function shouldFilterRootGeneratedCssMarkerForScopedAsset(targetFile, markerFile, resolveViteProcessedCssOutputFile) {
1334
- const resolvedTargetFile = normalizeMarkerOutputFile(targetFile, resolveViteProcessedCssOutputFile);
1335
- const resolvedMarkerFile = normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile);
1336
- if (!isRootStyleOutputFile(resolvedMarkerFile) || isRootStyleOutputFile(resolvedTargetFile)) return false;
1337
- return !isMatchingGeneratedCssMarkerFile(targetFile, markerFile, resolveViteProcessedCssOutputFile);
1338
- }
1339
- function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
1340
- const rootSources = collectRootStyleBundleCssSources(bundle, file);
1341
- if (css.trim().length === 0) return css;
1342
- const hasScopedCss = hasVueScopedAttr(css);
1343
- const hasScopedTailwindGeneratedCss = hasScopedCss && /tailwindcss v\d/i.test(css);
1344
- if (rootSources.length === 0 && !hasScopedCss) return css;
1345
- const coverage = collectRootScopedComparableCssCoverage(rootSources);
1346
- let nextCss = css;
1347
- try {
1348
- const root = postcss.parse(css);
1349
- let changed = false;
1350
- root.walkRules((rule) => {
1351
- if (coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) || hasScopedCss && (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule))) {
1352
- rule.remove();
1353
- changed = true;
1354
- }
1355
- });
1356
- if (hasScopedCss) root.walkAtRules((atRule) => {
1357
- if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
1358
- atRule.remove();
1359
- changed = true;
1360
- return;
1361
- }
1362
- if (atRule.nodes !== void 0 && atRule.nodes.length === 0) {
1363
- atRule.remove();
1364
- changed = true;
1365
- }
1366
- });
1367
- root.walkComments((comment) => {
1368
- if (hasScopedCss && /tailwindcss v\d/i.test(comment.text)) {
1369
- comment.remove();
1370
- changed = true;
1371
- return;
1372
- }
1373
- if (!comment.text.trim().startsWith("tokens:")) return;
1374
- const next = comment.next();
1375
- if (next?.type === "rule" || next?.type === "atrule") return;
1376
- comment.remove();
1377
- changed = true;
1378
- });
1379
- if (changed) nextCss = root.toString().trim();
1380
- } catch {}
1381
- return hasNonCommentCss(nextCss) ? nextCss : "";
1382
- }
1383
- function removeDanglingCssSourceTraceComments(css) {
1384
- if (!css.includes("/* tokens:")) return css;
1385
- try {
1386
- const root = postcss.parse(css);
1387
- let changed = false;
1388
- root.each((node) => {
1389
- if (node.type !== "comment" || !node.text.trim().startsWith("tokens:")) return;
1390
- const next = node.next();
1391
- if (next?.type === "rule" || next?.type === "atrule") return;
1392
- node.remove();
1393
- changed = true;
1394
- });
1395
- return changed ? root.toString().trim() : css;
1396
- } catch {
1397
- return css;
1398
- }
1399
- }
1400
- function removeCssCoveredByRootStyleAssets(bundle, options) {
1401
- let updated = 0;
1402
- for (const [bundleFile, output] of Object.entries(bundle)) {
1403
- if (output.type !== "asset") continue;
1404
- const file = getAssetFile$1(bundleFile, output);
1405
- const rawSource = readAssetSource$2(output);
1406
- const hasScopedCss = hasVueScopedAttr(rawSource);
1407
- const hasTailwindGeneratedCss = /tailwindcss v\d/i.test(rawSource);
1408
- const shouldIncludeTailwindGeneratedCssAsset = options.includeTailwindGeneratedCssAssets === true && hasTailwindGeneratedCss && isCssOutputFile(file) && !isMiniProgramStyleOutputFile(file);
1409
- if (!(options.cssMatcher(file) || hasScopedCss && isCssOutputFile(file) || shouldIncludeTailwindGeneratedCssAsset) || isRootStyleOutputFile(file) || options.isViteProcessedCssAsset?.(output, file) === true && !hasScopedCss && !shouldIncludeTailwindGeneratedCssAsset || options.subpackageRoots != null && isSubpackageOutputFile(file, options.subpackageRoots)) continue;
1410
- const nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, rawSource);
1411
- if (nextCss === rawSource) continue;
1412
- output.source = nextCss;
1413
- options.recordCssAssetResult?.(file, nextCss);
1414
- options.onUpdate?.(file, rawSource, nextCss);
1415
- options.debug?.("remove root-covered css rules from scoped asset: %s bytes=%d", file, nextCss.length);
1416
- updated++;
1417
- }
1418
- return updated;
1419
- }
1420
- //#endregion
1421
- //#region src/bundlers/vite/generate-bundle/asset-emission-plan.ts
1422
- function applyViteAssetEmissionPlan(plan, options) {
1423
- for (const operation of plan.operations()) {
1424
- if (operation.kind === "delete") {
1425
- delete options.bundle[operation.assetId];
1426
- continue;
1427
- }
1428
- const writeTarget = options.writeTargets?.get(operation.assetId);
1429
- const existing = options.bundle[operation.assetId];
1430
- const asset = writeTarget ?? (existing?.type === "asset" ? existing : void 0);
1431
- if (asset) {
1432
- asset.source = operation.source;
1433
- continue;
1434
- }
1435
- const replayAsset = options.emitOrReplayAsset?.(operation.assetId, operation.source);
1436
- if (replayAsset) options.bundle[operation.assetId] = replayAsset;
1437
- }
1438
- }
1439
- //#endregion
1440
- //#region src/bundlers/vite/generate-bundle/root-style-output.ts
1441
- function isRootMiniProgramStyleOutputFile$1(file) {
1442
- const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
1443
- return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
1444
- }
1445
- function createRelativeCssImportRequest$1(targetFile, importedFile) {
1446
- const normalizedTargetFile = normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
1447
- const normalizedImportedFile = normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
1448
- const targetDir = path.posix.dirname(normalizedTargetFile);
1449
- const baseDir = targetDir === "." ? "" : targetDir;
1450
- const relative = path.posix.relative(baseDir, normalizedImportedFile);
1451
- return relative.startsWith(".") ? relative : `./${relative}`;
1452
- }
1453
- function createCssImportShell$1(targetFile, importedFile) {
1454
- return `@import "${createRelativeCssImportRequest$1(targetFile, importedFile)}";\n`;
1455
- }
1456
- function resolveSingleCssImportOutputFile(targetFile, css) {
1457
- let importedFile;
1458
- try {
1459
- postcss.parse(css).walkAtRules("import", (atRule) => {
1460
- if (importedFile !== void 0) return;
1461
- const request = parseImportRequest(atRule.params);
1462
- if (!request || /^(?:https?:)?\/\//i.test(request) || request.startsWith("data:")) return;
1463
- const cleanRequest = request.replace(/[?#].*$/, "");
1464
- if (!/\.(?:css|wxss|acss|ttss|qss|jxss|tyss)$/i.test(cleanRequest)) return;
1465
- const targetDir = path.posix.dirname(normalizeOutputPathKey(targetFile));
1466
- importedFile = normalizeOutputPathKey(path.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
1467
- });
1468
- } catch {}
1469
- return importedFile;
1470
- }
1471
- function createRootMiniProgramOriginStyleOutputFile(file) {
1472
- const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
1473
- if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return normalized;
1474
- return normalized.replace(/(\.[^.]+)$/, "-origin$1");
1475
- }
1476
- function shouldKeepRootMiniProgramStyleAsImportShell(enabled) {
1477
- return enabled === true;
1478
- }
1479
- function shouldPreserveFrameworkRootMiniProgramImportShell(options) {
1480
- return !options.isWebGeneratorTarget && options.matchesCss && isRootStyleOutputFile(options.file) && isPureLocalCssImportWrapper(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
1481
- }
1482
- function resolveFrameworkRootImportShellPlan(options) {
1483
- const isCurrentImportShell = shouldPreserveFrameworkRootMiniProgramImportShell({
1484
- css: options.rawSource,
1485
- file: options.rootImportShellOutputFile,
1486
- isWebGeneratorTarget: options.isWebGeneratorTarget,
1487
- matchesCss: options.matchesCss,
1488
- shouldKeep: options.shouldKeep
1489
- });
1490
- if (isCurrentImportShell) {
1491
- const importedFile = resolveSingleCssImportOutputFile(options.rootImportShellOutputFile, options.rawSource);
1492
- return {
1493
- isCurrentImportShell,
1494
- reusableTarget: options.rememberedTarget,
1495
- targetToRemember: importedFile && isRootStyleOutputFile(importedFile) ? importedFile : void 0
1496
- };
1497
- }
1498
- if (options.rememberedTarget) return {
1499
- isCurrentImportShell,
1500
- reusableTarget: options.rememberedTarget,
1501
- targetToRemember: void 0
1502
- };
1503
- if (!(!options.isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(options.rootImportShellOutputFile) && normalizeOutputPathKey(options.assetSourceFile) === normalizeOutputPathKey(options.file) && options.isMainChunk && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep()) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(options.shouldMoveToOrigin()))) return {
1504
- isCurrentImportShell,
1505
- reusableTarget: void 0,
1506
- targetToRemember: void 0
1507
- };
1508
- const targets = new Set([...options.configuredTargetFiles, ...options.processedTargetFiles].filter((file) => typeof file === "string" && isRootMiniProgramStyleOutputFile$1(file) && normalizeOutputPathKey(file) !== normalizeOutputPathKey(options.rootImportShellOutputFile)));
1509
- const target = targets.size === 1 ? [...targets][0] : void 0;
1510
- return {
1511
- isCurrentImportShell,
1512
- reusableTarget: target,
1513
- targetToRemember: target
1514
- };
1515
- }
1516
- function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
1517
- if (options.isWebGeneratorTarget || options.targetByFile.size === 0) return 0;
1518
- const plan = new AssetEmissionPlan();
1519
- const writeTargets = /* @__PURE__ */ new Map();
1520
- let restored = 0;
1521
- for (const [sourceFile, targetFile] of options.targetByFile) {
1522
- if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !isRootStyleOutputFile(sourceFile) || !isRootStyleOutputFile(targetFile) || normalizeOutputPathKey(sourceFile) === normalizeOutputPathKey(targetFile)) continue;
1523
- const output = Object.entries(bundle).find(([bundleFile, candidate]) => candidate.type === "asset" && normalizeOutputPathKey(candidate.fileName || bundleFile) === normalizeOutputPathKey(sourceFile))?.[1];
1524
- if (output?.type !== "asset") continue;
1525
- const rawSource = output.source.toString();
1526
- if (!shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep(sourceFile, rawSource))) continue;
1527
- const nextSource = createCssImportShell$1(sourceFile, targetFile);
1528
- if (rawSource === nextSource) continue;
1529
- plan.write(sourceFile, nextSource);
1530
- writeTargets.set(sourceFile, output);
1531
- options.recordCssAssetResult?.(sourceFile, nextSource);
1532
- options.onUpdate?.(sourceFile, rawSource, nextSource);
1533
- options.debug?.("restore framework root css import shell: %s -> %s", sourceFile, targetFile);
1534
- restored++;
1535
- }
1536
- applyViteAssetEmissionPlan(plan, {
1537
- bundle,
1538
- writeTargets
1539
- });
1540
- return restored;
1541
- }
1542
- function resolveRuntimeRootStyleOutputFile(bundle, matchesCss) {
1543
- const rootChunks = Object.entries(bundle).flatMap(([bundleFile, output]) => {
1544
- if (output.type !== "chunk") return [];
1545
- const file = normalizeOutputPathKey(output.fileName || bundleFile);
1546
- if (file.includes("/")) return [];
1547
- return [{
1548
- file,
1549
- isEntry: output.isEntry === true
1550
- }];
1551
- });
1552
- const entryChunks = rootChunks.filter((chunk) => chunk.isEntry);
1553
- const rootChunkStems = new Set((entryChunks.length > 0 ? entryChunks : rootChunks).map((chunk) => path.posix.parse(chunk.file).name));
1554
- const candidates = Object.entries(bundle).flatMap(([bundleFile, output]) => {
1555
- if (output.type !== "asset") return [];
1556
- const file = normalizeOutputPathKey(output.fileName || bundleFile);
1557
- return isRootMiniProgramStyleOutputFile$1(file) && matchesCss(file) && rootChunkStems.has(path.posix.parse(file).name) ? [file] : [];
1558
- });
1559
- return candidates.length === 1 ? candidates[0] : void 0;
1560
- }
1561
- function linkFrameworkRootStyleToRuntimeEntry(bundle, options) {
1562
- if (options.targetByFile.size === 0) return 0;
1563
- const runtimeRootFile = resolveRuntimeRootStyleOutputFile(bundle, options.matchesCss);
1564
- if (!runtimeRootFile) return 0;
1565
- const frameworkRootFiles = [...options.targetByFile.keys()].filter((file) => normalizeOutputPathKey(file) !== normalizeOutputPathKey(runtimeRootFile) && isRootMiniProgramStyleOutputFile$1(file) && options.matchesCss(file));
1566
- if (frameworkRootFiles.length !== 1) return 0;
1567
- const frameworkRootFile = frameworkRootFiles[0];
1568
- const runtimeOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && normalizeOutputPathKey(output.fileName || bundleFile) === normalizeOutputPathKey(runtimeRootFile))?.[1];
1569
- const frameworkOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && normalizeOutputPathKey(output.fileName || bundleFile) === normalizeOutputPathKey(frameworkRootFile))?.[1];
1570
- if (runtimeOutput?.type !== "asset" || frameworkOutput?.type !== "asset") return 0;
1571
- const runtimeSource = runtimeOutput.source.toString();
1572
- const importedRuntimeFile = resolveSingleCssImportOutputFile(runtimeRootFile, runtimeSource);
1573
- if (importedRuntimeFile && normalizeOutputPathKey(importedRuntimeFile) === normalizeOutputPathKey(frameworkRootFile)) return 0;
1574
- const importedFrameworkFile = resolveSingleCssImportOutputFile(frameworkRootFile, frameworkOutput.source.toString());
1575
- if (importedFrameworkFile && normalizeOutputPathKey(importedFrameworkFile) === normalizeOutputPathKey(runtimeRootFile)) return 0;
1576
- const nextSource = `${createCssImportShell$1(runtimeRootFile, frameworkRootFile)}${runtimeSource}`;
1577
- runtimeOutput.source = nextSource;
1578
- options.recordCssAssetResult?.(runtimeRootFile, nextSource);
1579
- options.onUpdate?.(runtimeRootFile, runtimeSource, nextSource);
1580
- options.debug?.("link framework root css to runtime entry: %s -> %s", runtimeRootFile, frameworkRootFile);
1581
- return 1;
1062
+ if (blocks.length !== 1) return;
1063
+ const file = blocks[0]?.file;
1064
+ return typeof file === "string" && file.length > 0 ? file : void 0;
1582
1065
  }
1583
- function shouldMoveRootMiniProgramStyleToImportShellOrigin(enabled) {
1584
- return enabled === true;
1066
+ function shouldFilterRootGeneratedCssMarkerForScopedAsset(targetFile, markerFile, resolveViteProcessedCssOutputFile) {
1067
+ const resolvedTargetFile = normalizeMarkerOutputFile(targetFile, resolveViteProcessedCssOutputFile);
1068
+ const resolvedMarkerFile = normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile);
1069
+ if (!isRootStyleOutputFile(resolvedMarkerFile) || isRootStyleOutputFile(resolvedTargetFile)) return false;
1070
+ return !isMatchingGeneratedCssMarkerFile(targetFile, markerFile, resolveViteProcessedCssOutputFile);
1071
+ }
1072
+ function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
1073
+ return removeCssCoveredByRootStyleSources(css, collectRootStyleBundleCssSources(bundle, file));
1074
+ }
1075
+ function removeCssCoveredByRootStyleAssets(bundle, options) {
1076
+ let updated = 0;
1077
+ for (const [bundleFile, output] of Object.entries(bundle)) {
1078
+ if (output.type !== "asset") continue;
1079
+ const file = getAssetFile$1(bundleFile, output);
1080
+ const rawSource = readAssetSource$2(output);
1081
+ const hasScopedCss = hasVueScopedAttr(rawSource);
1082
+ const hasTailwindGeneratedCss = /tailwindcss v\d/i.test(rawSource);
1083
+ const shouldIncludeTailwindGeneratedCssAsset = options.includeTailwindGeneratedCssAssets === true && hasTailwindGeneratedCss && isCssOutputFile(file) && !isMiniProgramStyleOutputFile(file);
1084
+ if (!(options.cssMatcher(file) || hasScopedCss && isCssOutputFile(file) || shouldIncludeTailwindGeneratedCssAsset) || isRootStyleOutputFile(file) || options.isViteProcessedCssAsset?.(output, file) === true && !hasScopedCss && !shouldIncludeTailwindGeneratedCssAsset || options.subpackageRoots != null && isSubpackageOutputFile(file, options.subpackageRoots)) continue;
1085
+ const nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, rawSource);
1086
+ if (nextCss === rawSource) continue;
1087
+ output.source = nextCss;
1088
+ options.recordCssAssetResult?.(file, nextCss);
1089
+ options.onUpdate?.(file, rawSource, nextCss);
1090
+ options.debug?.("remove root-covered css rules from scoped asset: %s bytes=%d", file, nextCss.length);
1091
+ updated++;
1092
+ }
1093
+ return updated;
1585
1094
  }
1586
1095
  //#endregion
1587
1096
  //#region src/bundlers/vite/processed-css-assets/injection-plan.ts
@@ -1710,23 +1219,6 @@ function removeCssCoveredByImportedViteResults(css, importedCssSources, prepared
1710
1219
  if (!prepared) return css;
1711
1220
  return restoreCssImportAtRules(css, removeCssRulesCoveredBySources(css, prepared.sources, { exactOnly: true }, prepared.coverage));
1712
1221
  }
1713
- function removeCssRulesCoveredBySources(css, sources, options = {}, preparedCoverage) {
1714
- if (sources.length === 0 || css.trim().length === 0) return css;
1715
- const coverage = preparedCoverage ?? collectRootScopedComparableCssCoverage(sources);
1716
- if (coverage.rules.size === 0 && coverage.declarationsBySelector.size === 0 && coverage.normalizedRuleCss.size === 0) return css;
1717
- try {
1718
- const root = postcss.parse(css);
1719
- let changed = false;
1720
- root.walkRules((rule) => {
1721
- if (!coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) && (options.exactOnly === true || !isRuleCoveredByRootCss(rule, coverage))) return;
1722
- rule.remove();
1723
- changed = true;
1724
- });
1725
- return changed ? root.toString() : css;
1726
- } catch {
1727
- return css;
1728
- }
1729
- }
1730
1222
  //#endregion
1731
1223
  //#region src/bundlers/vite/processed-css-assets/collector.ts
1732
1224
  function collectViteProcessedCssAssetResults(bundle, options) {
@@ -1735,10 +1227,15 @@ function collectViteProcessedCssAssetResults(bundle, options) {
1735
1227
  for (const [bundleFile, output] of Object.entries(bundle)) {
1736
1228
  if (output.type !== "asset") continue;
1737
1229
  const file = getAssetFile$1(bundleFile, output);
1738
- if (!isCssOutputFile(file) || !options.isViteProcessedCssAsset?.(output, file)) continue;
1230
+ if (!isCssOutputFile(file)) continue;
1739
1231
  const rawSource = readAssetSource$2(output);
1740
- let nextCss = resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
1741
1232
  const singleMarkerFile = collectSingleViteGeneratedCssMarkerFile(rawSource);
1233
+ if (singleMarkerFile) {
1234
+ getActiveViteSourceOutputRelationOwner()?.recordOwnedOutput(singleMarkerFile, file);
1235
+ options.debug?.("css marker ownership: %s -> %s", singleMarkerFile, file);
1236
+ }
1237
+ if (!options.isViteProcessedCssAsset?.(output, file)) continue;
1238
+ let nextCss = resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
1742
1239
  if (singleMarkerFile && (options.subpackageRoots == null || !isSubpackageOutputFile(file, options.subpackageRoots)) && shouldFilterRootGeneratedCssMarkerForScopedAsset(file, singleMarkerFile, options.resolveViteProcessedCssOutputFile)) nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, nextCss);
1743
1240
  nextCss = options.transformCss?.(nextCss, file) ?? nextCss;
1744
1241
  if (nextCss !== rawSource) {
@@ -1850,7 +1347,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
1850
1347
  }
1851
1348
  const fileKey = normalizeOutputPathKey(file);
1852
1349
  const mainFileKey = normalizeOutputPathKey(file);
1853
- const normalizedOriginalCss = measure("normalizeTarget", () => normalizeInjectableCssForTargetWithImports(transformCss(removeTailwindEntryDirectivesFromCss(originalSource), file), file));
1350
+ const normalizedOriginalCss = measure("normalizeTarget", () => normalizeInjectableCssForTargetWithImports(transformCss(removeTailwindEntryDirectivesFromCss(originalSource, options.createCssPipelineContext?.(file)?.currentGeneratorBranch?.isWeb === true), file), file));
1854
1351
  let nextCss = normalizedOriginalCss.css;
1855
1352
  const importedStyleFiles = normalizedOriginalCss.importedStyleFiles;
1856
1353
  const importedBundleCssSources = collectImportedBundleCssSources(bundle, importedStyleFiles);
@@ -1904,7 +1401,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
1904
1401
  }
1905
1402
  const finalImportedCssSources = collectImportedBundleCssSources(bundle, collectImportedStyleFiles(originalSource, file));
1906
1403
  const finalImportedCssCoverage = prepareImportedCssCoverage(finalImportedCssSources);
1907
- nextCss = measure("finalizeTarget", () => transformCss(removeCommentOnlyAtRules(restoreCssImportAtRules(originalSource, removeCssRulesCoveredBySources(nextCss, finalImportedCssSources, { exactOnly: true }, finalImportedCssCoverage?.coverage).trim(), file)), file));
1404
+ nextCss = measure("finalizeTarget", () => transformCss(removeCommentOnlyAtRules(restoreCssImportAtRules(originalSource, removeCssRulesCoveredBySources$1(nextCss, finalImportedCssSources, { exactOnly: true }, finalImportedCssCoverage?.coverage).trim(), file)), file));
1908
1405
  if (nextCss.trim() === originalSource.trim()) nextCss = originalSource;
1909
1406
  if (nextCss !== originalSource) {
1910
1407
  output.source = nextCss;
@@ -2100,8 +1597,8 @@ async function collectBundleMarkupCandidates(options) {
2100
1597
  const valuesForEntries = (entries, filterOptions = {}) => {
2101
1598
  const values = /* @__PURE__ */ new Set();
2102
1599
  for (const { sourceFile: file, candidates } of candidatesByFile.values()) {
2103
- if (entries !== void 0 && !isFileMatchedByTailwindSourceEntries(file, entries)) continue;
2104
- if (filterOptions.excludeEntries?.length && isFileMatchedByTailwindSourceEntries(file, filterOptions.excludeEntries)) continue;
1600
+ if (entries !== void 0 && !(0, source_scan_exports.isFileMatchedByTailwindSourceEntries)(file, entries)) continue;
1601
+ if (filterOptions.excludeEntries?.length && (0, source_scan_exports.isFileMatchedByTailwindSourceEntries)(file, filterOptions.excludeEntries)) continue;
2105
1602
  for (const candidate of candidates) values.add(candidate);
2106
1603
  }
2107
1604
  return values;
@@ -2148,7 +1645,7 @@ function createCssAssetEmitter(context, bundle) {
2148
1645
  return (fileName, source) => {
2149
1646
  const fileNameKey = normalizeOutputPathKey(fileName);
2150
1647
  const existing = bundle?.[fileName] ?? Object.entries(bundle ?? {}).find(([bundleFile, output]) => output != null && typeof output === "object" && "type" in output && output.type === "asset" && normalizeOutputPathKey("fileName" in output && typeof output.fileName === "string" ? output.fileName : bundleFile) === fileNameKey)?.[1];
2151
- if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset") {
1648
+ if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset" && "source" in existing) {
2152
1649
  existing.source = source;
2153
1650
  return existing;
2154
1651
  }
@@ -2256,6 +1753,10 @@ function processViteCssCacheTask(options) {
2256
1753
  function createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash) {
2257
1754
  return `${cssRuntimeSignature}:${cssRuntimeAffectingHash}`;
2258
1755
  }
1756
+ /** 入口重放的干净生成结果,避免和已合并框架贡献的产物缓存混用。 */
1757
+ function createGeneratedReplayCacheKey(outputFile) {
1758
+ return `${normalizeOutputPathKey(outputFile)}::__generated_replay__`;
1759
+ }
2259
1760
  function normalizeRememberedSourceIdentity(file) {
2260
1761
  return normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
2261
1762
  }
@@ -2295,9 +1796,23 @@ function mergeRememberedCssSources(sources, outputFile) {
2295
1796
  }
2296
1797
  function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles) {
2297
1798
  const groups = /* @__PURE__ */ new Map();
1799
+ const outputFiles = [...styleOutputFiles ?? []];
1800
+ const currentOutputs = new Set(outputFiles.map(normalizeOutputPathKey));
1801
+ const relationOwner = getActiveViteSourceOutputRelationOwner();
2298
1802
  for (const [key, remembered] of sources ?? []) {
1803
+ const ownedOutputs = [...relationOwner?.getOwnedOutputs(remembered.sourceFile) ?? []].filter((file) => currentOutputs.has(normalizeOutputPathKey(file)) && opts.cssMatcher(file));
1804
+ if (ownedOutputs.length === 1) {
1805
+ const outputKey = normalizeOutputPathKey(ownedOutputs[0]);
1806
+ const group = groups.get(outputKey) ?? [];
1807
+ group.push({
1808
+ key,
1809
+ remembered
1810
+ });
1811
+ groups.set(outputKey, group);
1812
+ continue;
1813
+ }
2299
1814
  const cleanSourceFile = remembered.sourceFile.replace(/[?#].*$/, "");
2300
- const resolvedOutputFile = CSS_SOURCE_OUTPUT_EXT_RE.test(cleanSourceFile) ? resolveViteCssPipelineOutputFileFromSourceFile(remembered.sourceFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles) : resolveViteCssPipelineOutputFileFromSourceFile(remembered.outputFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles);
1815
+ const resolvedOutputFile = CSS_SOURCE_OUTPUT_EXT_RE.test(cleanSourceFile) ? resolveViteCssPipelineOutputFileFromSourceFile(remembered.sourceFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, outputFiles) : resolveViteCssPipelineOutputFileFromSourceFile(remembered.outputFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, outputFiles);
2301
1816
  const rememberedOutputFile = remembered.outputFile.replace(/[?#].*$/, "");
2302
1817
  const outputFile = opts.cssMatcher(rememberedOutputFile) && !normalizeOutputPathKey(rememberedOutputFile).includes("/") && normalizeOutputPathKey(rememberedOutputFile) !== normalizeOutputPathKey(resolvedOutputFile.replace(/[?#].*$/, "")) ? remembered.outputFile : resolvedOutputFile;
2303
1818
  const outputKey = normalizeOutputPathKey(outputFile);
@@ -2483,13 +1998,12 @@ function collectCssConfigBaseCandidates(source, file, outputRoot, opts) {
2483
1998
  function normalizeRelativeCssConfigDirectives(source, file, outputRoot, opts) {
2484
1999
  if (!source.includes("@config")) return source;
2485
2000
  const baseCandidates = collectCssConfigBaseCandidates(source, file, outputRoot, opts);
2486
- return source.replace(/@config\s+(["'])(.+?)\1\s*;?/g, (full, quote, request) => {
2487
- if (path.isAbsolute(request) || isPackageJsonImportRequest(request)) return full;
2001
+ return rewriteCssConfigRequests(source, (request) => {
2002
+ if (path.isAbsolute(request) || isPackageJsonImportRequest(request)) return;
2488
2003
  for (const base of baseCandidates) {
2489
2004
  const configFile = path.resolve(base, request);
2490
- if (existsSync(configFile)) return `@config ${quote}${slash(configFile)}${quote};`;
2005
+ if (existsSync(configFile)) return slash(configFile);
2491
2006
  }
2492
- return full;
2493
2007
  });
2494
2008
  }
2495
2009
  //#endregion
@@ -2893,6 +2407,7 @@ async function processViteCssBundleEntry(options) {
2893
2407
  runtimeAffectingSignatureByFile: snapshot.runtimeAffectingSignatureByFile
2894
2408
  }) : "";
2895
2409
  const { cssCacheKey, cssHashKey, cssSharedCacheKey, cssTaskHash, rememberedCssRuntimeSignature } = resolveViteCssTransformCachePlan({
2410
+ cssBundleSourceHash: isWebGeneratorTarget ? cache.computeHash(rawSource) : void 0,
2896
2411
  cssIsMainChunk: cssHandlerOptions2.isMainChunk === true,
2897
2412
  cssRuntimeAffectingHash,
2898
2413
  cssShareScope,
@@ -3089,24 +2604,8 @@ function applyCssResultToBundle(options) {
3089
2604
  }
3090
2605
  //#endregion
3091
2606
  //#region src/bundlers/vite/generate-bundle/css-share-scope.ts
3092
- const CSS_URL_FUNCTION_RE = /url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)/gi;
3093
- const CSS_PATH_INDEPENDENT_URL_RE = /^(?:[a-z][a-z\d+.-]*:|\/\/|\/|#)/i;
3094
- const CSS_IMPORT_RE = /@import\b/i;
3095
- function isPathIndependentCssUrl(value) {
3096
- const normalized = value.trim();
3097
- return normalized.length > 0 && CSS_PATH_INDEPENDENT_URL_RE.test(normalized);
3098
- }
3099
- function hasPathDependentCssUrl(rawSource) {
3100
- CSS_URL_FUNCTION_RE.lastIndex = 0;
3101
- let match = CSS_URL_FUNCTION_RE.exec(rawSource);
3102
- while (match !== null) {
3103
- if (!isPathIndependentCssUrl(match[1] ?? match[2] ?? match[3] ?? "")) return true;
3104
- match = CSS_URL_FUNCTION_RE.exec(rawSource);
3105
- }
3106
- return false;
3107
- }
3108
2607
  function createCssTransformShareScope(file, rawSource) {
3109
- if (CSS_IMPORT_RE.test(rawSource) || hasPathDependentCssUrl(rawSource)) return `dir:${normalizeOutputPathKey(path.dirname(file))}`;
2608
+ if (hasCssLocationDependencies(rawSource)) return `dir:${normalizeOutputPathKey(path.dirname(file))}`;
3110
2609
  return "global";
3111
2610
  }
3112
2611
  function createCssTransformShareScopeKey(opts, file, rawSource) {
@@ -3180,141 +2679,32 @@ async function resolveRememberedCssSourcePlan(options) {
3180
2679
  }
3181
2680
  //#endregion
3182
2681
  //#region src/bundlers/vite/generate-bundle/tailwind-v4-css-source.ts
3183
- function createStableTextSignature(input) {
3184
- let hash = 2166136261;
3185
- for (let i = 0; i < input.length; i++) {
3186
- hash ^= input.charCodeAt(i);
3187
- hash = Math.imul(hash, 16777619);
3188
- }
3189
- return (hash >>> 0).toString(36);
3190
- }
3191
- function parseQuotedRequest(params) {
3192
- const input = params.trim();
3193
- const quote = input[0];
3194
- if (quote !== "\"" && quote !== "'") return;
3195
- let escaped = false;
3196
- for (let index = 1; index < input.length; index++) {
3197
- const char = input[index];
3198
- if (escaped) {
3199
- escaped = false;
3200
- continue;
3201
- }
3202
- if (char === "\\") {
3203
- escaped = true;
3204
- continue;
3205
- }
3206
- if (char === quote) return input.slice(1, index);
3207
- }
3208
- }
3209
- function parseSourceParams(params) {
3210
- let input = params.trim();
3211
- let negated = false;
3212
- if (input.startsWith("not ")) {
3213
- negated = true;
3214
- input = input.slice(4).trim();
3215
- }
3216
- if (input.startsWith("inline(") && input.endsWith(")")) return {
3217
- prefix: negated ? "source:inline:not" : "source:inline",
3218
- value: input.slice(7, -1).trim()
3219
- };
3220
- const request = parseQuotedRequest(input);
3221
- if (!request) return;
3222
- return {
3223
- prefix: negated ? "source:not" : "source",
3224
- value: request
3225
- };
3226
- }
3227
- function parseTailwindImportSource(params) {
3228
- if (parseQuotedRequest(params) !== "tailwindcss") return;
3229
- return /\bsource\(([^)]*)\)/.exec(params)?.[1]?.trim();
3230
- }
3231
- function hasExplicitTailwindV4Directive(source) {
3232
- try {
3233
- let found = false;
3234
- postcss.parse(source).walkAtRules((rule) => {
3235
- if (rule.name === "config" || rule.name === "source" || rule.name === "plugin" || rule.name === "custom-variant" || rule.name === "theme" || rule.name === "utility" || rule.name === "variant" || rule.name === "apply") {
3236
- found = true;
3237
- return false;
3238
- }
3239
- });
3240
- return found;
3241
- } catch {
3242
- return false;
3243
- }
3244
- }
3245
2682
  function collectTailwindV4SourceFingerprint(source) {
3246
- const tokens = /* @__PURE__ */ new Set();
3247
- const add = (prefix, value) => {
3248
- tokens.add(`${prefix}:${value.trim()}`);
3249
- };
3250
- try {
3251
- const root = postcss.parse(source);
3252
- root.walkAtRules((rule) => {
3253
- if (rule.name === "import") {
3254
- const sourceMode = parseTailwindImportSource(rule.params);
3255
- if (sourceMode) add("import-source", sourceMode);
3256
- return;
3257
- }
3258
- if (rule.name === "config") {
3259
- const configRequest = parseQuotedRequest(rule.params);
3260
- if (configRequest) {
3261
- add("config", path.basename(configRequest));
3262
- add("config-request", configRequest.replace(/\\/g, "/"));
3263
- }
3264
- return;
3265
- }
3266
- if (rule.name === "source") {
3267
- const parsed = parseSourceParams(rule.params);
3268
- if (parsed) add(parsed.prefix, parsed.value);
3269
- return;
3270
- }
3271
- if (rule.name === "plugin") {
3272
- const request = parseQuotedRequest(rule.params);
3273
- if (!request) return;
3274
- add("plugin", request);
3275
- add("plugin-request", request.replace(/\\/g, "/"));
3276
- if (rule.nodes?.length) {
3277
- add("plugin-options", `${request}:${createStableTextSignature(rule.toString())}`);
3278
- rule.walkDecls((decl) => {
3279
- add("plugin-option", `${request}:${decl.prop}:${decl.value}`);
3280
- });
3281
- }
3282
- return;
3283
- }
3284
- if (rule.name === "custom-variant") {
3285
- const [name] = rule.params.trim().split(/\s+/, 1);
3286
- if (name) add("custom-variant", name);
3287
- return;
3288
- }
3289
- if (rule.name === "theme" || rule.name === "utility" || rule.name === "variant" || rule.name === "layer") {
3290
- const [name] = rule.params.trim().split(/\s+/, 1);
3291
- if (name) add("directive", name);
3292
- }
3293
- });
3294
- root.walkDecls((decl) => {
3295
- if (decl.prop.startsWith("--")) add("theme-token", decl.prop);
3296
- });
3297
- root.walkRules((rule) => {
3298
- for (const selector of rule.selectors ?? []) {
3299
- const match = /\.([_a-z][\w-]*)/i.exec(selector);
3300
- if (match?.[1]) add("selector", match[1]);
3301
- }
3302
- });
3303
- } catch {}
3304
- return tokens;
2683
+ return analyzeTailwindV4Source(source, path.basename).getFingerprint();
2684
+ }
2685
+ function scoreSourceFingerprints(rawTokens, entryTokens) {
2686
+ let score = 0;
2687
+ for (const token of entryTokens) if (rawTokens.has(token)) score += token.startsWith("config:") ? 100 : 1;
2688
+ return score;
3305
2689
  }
3306
2690
  function scoreConfiguredTailwindV4SourceForRawSource(rawSource, entrySource) {
3307
2691
  if (!rawSource) return 0;
3308
2692
  const rawTokens = collectTailwindV4SourceFingerprint(rawSource);
3309
2693
  if (rawTokens.size === 0) return 0;
3310
- const entryTokens = collectTailwindV4SourceFingerprint(entrySource);
3311
- let score = 0;
3312
- for (const token of entryTokens) if (rawTokens.has(token)) score += token.startsWith("config:") ? 100 : 1;
3313
- return score;
2694
+ return scoreSourceFingerprints(rawTokens, collectTailwindV4SourceFingerprint(entrySource));
3314
2695
  }
3315
2696
  function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSource, options = {}) {
3316
2697
  const generationSources = entries.filter((entry) => hasTailwindGenerationSource(entry.source));
3317
2698
  if (generationSources.length <= 1) return generationSources[0];
2699
+ const analyses = /* @__PURE__ */ new Map();
2700
+ const analyze = (source) => {
2701
+ let analysis = analyses.get(source);
2702
+ if (!analysis) {
2703
+ analysis = analyzeTailwindV4Source(source, path.basename);
2704
+ analyses.set(source, analysis);
2705
+ }
2706
+ return analysis;
2707
+ };
3318
2708
  const canMatchByOutputPath = Boolean(options.cwd || options.outputRoot || options.projectRoot);
3319
2709
  const selectByOutputPath = (candidates, shouldUseScore = (score) => score > 0) => {
3320
2710
  if (!canMatchByOutputPath) return;
@@ -3331,15 +2721,18 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
3331
2721
  return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
3332
2722
  };
3333
2723
  const selectByRawSourceFingerprint = (candidates) => {
2724
+ if (!rawSource) return;
2725
+ const rawTokens = analyze(rawSource).getFingerprint();
2726
+ if (rawTokens.size === 0) return;
3334
2727
  const scoredSources = candidates.map((entry) => ({
3335
2728
  entry,
3336
- score: scoreConfiguredTailwindV4SourceForRawSource(rawSource, entry.source)
2729
+ score: scoreSourceFingerprints(rawTokens, analyze(entry.source).getFingerprint())
3337
2730
  })).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
3338
2731
  const bestScore = scoredSources[0]?.score;
3339
2732
  const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
3340
2733
  return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
3341
2734
  };
3342
- const explicitSources = generationSources.filter((entry) => hasExplicitTailwindV4Directive(entry.source));
2735
+ const explicitSources = generationSources.filter((entry) => analyze(entry.source).hasExplicitDirectives);
3343
2736
  const candidates = explicitSources.length === 1 ? explicitSources : generationSources;
3344
2737
  const directoryIndexOutputPathMatched = selectByOutputPath(candidates, (score) => score >= 25e3 && score < 5e4);
3345
2738
  if (directoryIndexOutputPathMatched) return directoryIndexOutputPathMatched;
@@ -3498,13 +2891,15 @@ function resolveViteCssTransformCachePlan(options) {
3498
2891
  options.cssIsMainChunk ? "1" : "0",
3499
2892
  options.cssRuntimeAffectingHash,
3500
2893
  options.scopedGeneratorCandidateSignature,
3501
- options.sourceTraceSignature
2894
+ options.sourceTraceSignature,
2895
+ ...options.cssBundleSourceHash ? [options.cssBundleSourceHash] : []
3502
2896
  ].join(":"),
3503
2897
  cssTaskHash: [
3504
2898
  options.cssRuntimeAffectingHash,
3505
2899
  options.scopedGeneratorCandidateSignature,
3506
2900
  options.sourceTraceSignature,
3507
- options.linkedImpactSignature
2901
+ options.linkedImpactSignature,
2902
+ ...options.cssBundleSourceHash ? [options.cssBundleSourceHash] : []
3508
2903
  ].join(":"),
3509
2904
  rememberedCssRuntimeSignature
3510
2905
  };
@@ -3536,6 +2931,12 @@ function applyViteCssTransformTaskResult(options) {
3536
2931
  return result.css;
3537
2932
  }
3538
2933
  //#endregion
2934
+ //#region src/bundlers/vite/generate-bundle/web-css-module.ts
2935
+ function replaceWebCssModule(source, sourceFile, generated) {
2936
+ const sourceKey = normalizeOutputPathKey(sourceFile.replace(/[?#].*$/, ""));
2937
+ return replaceViteGeneratedCssModule(source, generated, (file) => normalizeOutputPathKey(file) === sourceKey);
2938
+ }
2939
+ //#endregion
3539
2940
  //#region src/bundlers/vite/generate-bundle/css-transform-task.ts
3540
2941
  function resolveBundleUserRawSource(options) {
3541
2942
  return options.vitePipelineCssAsset && !hasBundlerGeneratedCssMarker(options.rawSource) && normalizeCssSourceForCompare(options.rawSource) !== normalizeCssSourceForCompare(options.generatorRawSource) ? options.normalizeMiniProgramGeneratorRawSource(options.normalizeGeneratorUserRawSource(options.rawSource, options.generatorSourceFile, options.assetSourceFile), options.outputFile) : void 0;
@@ -3543,7 +2944,7 @@ function resolveBundleUserRawSource(options) {
3543
2944
  async function executeViteCssTransformTask(options) {
3544
2945
  await options.runtimeState.readyPromise;
3545
2946
  const previousGeneratorCss = options.previousCss && !options.isWebGeneratorTarget ? options.normalizeMiniProgramGeneratorRawSource(options.previousCss, options.outputFile) : options.previousCss;
3546
- if (hasTailwindGenerationSource(options.generatorRawSource) || !options.isWebGeneratorTarget && hasBundlerGeneratedCssMarker(options.rawSource)) {
2947
+ if (hasTailwindGenerationSource(options.generatorRawSource) && (!options.isWebGeneratorTarget || !hasBundlerGeneratedCssMarker(options.rawSource) || hasTailwindRootDirectives(options.generatorRawSource, { importFallback: true })) || !options.isWebGeneratorTarget && hasBundlerGeneratedCssMarker(options.rawSource)) {
3547
2948
  const bundleUserRawSource = resolveBundleUserRawSource(options);
3548
2949
  const generatorUserRawSource = [options.generatorUserLayerRawSource, options.isWebGeneratorTarget ? bundleUserRawSource : void 0].filter((source) => typeof source === "string" && source.trim().length > 0).join("\n");
3549
2950
  const generated = await (options.generateCss ?? generateTailwindV4Css)({
@@ -3567,7 +2968,7 @@ async function executeViteCssTransformTask(options) {
3567
2968
  userRawSource: generatorUserRawSource || void 0
3568
2969
  });
3569
2970
  if (generated) {
3570
- const css = options.removeRootCoveredCssFromScopedAsset(options.annotateCss(options.transformWebTargetCss(generated.css)));
2971
+ const css = options.removeRootCoveredCssFromScopedAsset(options.annotateCss(options.transformWebTargetCss(options.isWebGeneratorTarget ? replaceWebCssModule(options.rawSource, options.generatorSourceFile, generated.css) ?? generated.css : generated.css)));
3571
2972
  return {
3572
2973
  classSet: generated.classSet,
3573
2974
  css,
@@ -3860,7 +3261,7 @@ async function handleUniAppXPostCssTasks(options) {
3860
3261
  opts,
3861
3262
  runtimeState,
3862
3263
  runtime: /* @__PURE__ */ new Set(),
3863
- rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
3264
+ rawSource: createUniAppXHarmonyApplyGeneratorSource$1(applyStyleSources, applyUtilities),
3864
3265
  file: outputFile,
3865
3266
  outputFile,
3866
3267
  cssHandlerOptions,
@@ -4008,9 +3409,58 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
4008
3409
  return updated;
4009
3410
  }
4010
3411
  //#endregion
3412
+ //#region src/bundlers/vite/generate-bundle/finalize/sync-processed-css.ts
3413
+ function syncProcessedCss(options) {
3414
+ const { bundle, opts, cssPipelineStrategy, createCssPipelineContext, isViteProcessedCssAsset, markCssAssetProcessed, recordCssAssetResult, recordViteProcessedCssAssetResult, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles, transformWebTargetCss, debug, recordTimingDetail, getViteProcessedCssAssetResults, onUpdate, pendingRememberedCssReplayUpdates } = options;
3415
+ const collectStartedAt = performance.now();
3416
+ collectViteProcessedCssAssetResults(bundle, {
3417
+ opts,
3418
+ cssPipelineStrategy,
3419
+ createCssPipelineContext,
3420
+ isViteProcessedCssAsset,
3421
+ markCssAssetProcessed,
3422
+ recordCssAssetResult,
3423
+ recordViteProcessedCssAssetResult,
3424
+ resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles),
3425
+ subpackageRoots: collectMiniProgramSubpackageRoots(bundle),
3426
+ transformCss: transformWebTargetCss,
3427
+ debug
3428
+ });
3429
+ recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
3430
+ const injectStartedAt = performance.now();
3431
+ const currentResults = new Map([...getViteProcessedCssAssetResults?.() ?? []].map(([file, record]) => [normalizeOutputPathKey(file), [file, record]]));
3432
+ for (const update of pendingRememberedCssReplayUpdates) {
3433
+ recordViteProcessedCssAssetResult?.(update.file, update.css, update);
3434
+ currentResults.set(normalizeOutputPathKey(update.file), [update.file, {
3435
+ css: update.css,
3436
+ injectIntoMain: update.injectIntoMain,
3437
+ outputFile: update.outputFile
3438
+ }]);
3439
+ }
3440
+ const injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
3441
+ opts,
3442
+ cssPipelineStrategy,
3443
+ createCssPipelineContext,
3444
+ getViteProcessedCssAssetResults: () => currentResults.values(),
3445
+ markCssAssetProcessed,
3446
+ recordCssAssetResult,
3447
+ transformCss: transformWebTargetCss,
3448
+ shouldRemoveInjectedSourceAsset: (targetFile, record) => {
3449
+ if (record.injectIntoMain === false) return false;
3450
+ const targetFileKey = normalizeOutputPathKey(targetFile);
3451
+ return normalizeOutputPathKey(record.file) !== targetFileKey;
3452
+ },
3453
+ debug,
3454
+ onUpdate,
3455
+ recordTimingDetail
3456
+ });
3457
+ recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
3458
+ return injected;
3459
+ }
3460
+ //#endregion
4011
3461
  //#region src/bundlers/vite/generate-bundle/finalize/bundle.ts
4012
3462
  async function finalizeGenerateBundle(options) {
4013
- const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, defaultStyleOutputExtension, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, markCssAssetProcessed, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, pendingRememberedCssReplayUpdates, prepareJsTransformRuntime, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
3463
+ const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, prepareJsTransformRuntime, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, runtime, runtimeState, snapshot, sourceCandidates, state, styleHandler, tasks, timingDetails, transformRuntime, useIncrementalMode } = options;
4014
3464
  const tasksStart = performance.now();
4015
3465
  if (cssTaskFactories.length > 0) {
4016
3466
  const cssConcurrency = resolveViteCssTaskConcurrency(useIncrementalMode, runtimeState.tailwindRuntime.majorVersion);
@@ -4041,68 +3491,11 @@ async function finalizeGenerateBundle(options) {
4041
3491
  styleHandler
4042
3492
  });
4043
3493
  recordTimingDetail("finalize.uniAppXPostCss", uniAppXPostCssStartedAt);
4044
- const syncViteProcessedCssIntoMainCssAssets = () => {
4045
- const collectStartedAt = performance.now();
4046
- collectViteProcessedCssAssetResults(bundle, {
4047
- opts,
4048
- cssPipelineStrategy,
4049
- createCssPipelineContext,
4050
- isViteProcessedCssAsset,
4051
- markCssAssetProcessed,
4052
- recordCssAssetResult,
4053
- recordViteProcessedCssAssetResult,
4054
- resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles),
4055
- subpackageRoots: collectMiniProgramSubpackageRoots(bundle),
4056
- transformCss: transformWebTargetCss,
4057
- debug
4058
- });
4059
- recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
4060
- const injectStartedAt = performance.now();
4061
- let injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
4062
- opts,
4063
- cssPipelineStrategy,
4064
- createCssPipelineContext,
4065
- getViteProcessedCssAssetResults,
4066
- markCssAssetProcessed,
4067
- recordCssAssetResult,
4068
- transformCss: transformWebTargetCss,
4069
- shouldRemoveInjectedSourceAsset: (targetFile, record) => {
4070
- if (record.injectIntoMain === false) return false;
4071
- const targetFileKey = normalizeOutputPathKey(targetFile);
4072
- return normalizeOutputPathKey(record.file) !== targetFileKey;
4073
- },
4074
- debug,
4075
- onUpdate,
4076
- recordTimingDetail
4077
- });
4078
- if (pendingRememberedCssReplayUpdates.length > 0) {
4079
- for (const update of pendingRememberedCssReplayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
4080
- injected += injectViteProcessedCssIntoMainCssAssets(bundle, {
4081
- opts,
4082
- cssPipelineStrategy,
4083
- createCssPipelineContext,
4084
- getViteProcessedCssAssetResults: () => pendingRememberedCssReplayUpdates.map((update) => [update.file, {
4085
- css: update.css,
4086
- injectIntoMain: update.injectIntoMain,
4087
- outputFile: update.outputFile
4088
- }]),
4089
- markCssAssetProcessed,
4090
- recordCssAssetResult,
4091
- transformCss: transformWebTargetCss,
4092
- debug,
4093
- onUpdate,
4094
- recordTimingDetail
4095
- });
4096
- debug("inject remembered css replay updates after framework css collection: %d", pendingRememberedCssReplayUpdates.length);
4097
- }
4098
- recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
4099
- return injected;
4100
- };
4101
3494
  const processedCssStartedAt = performance.now();
4102
- syncViteProcessedCssIntoMainCssAssets();
3495
+ syncProcessedCss(options);
4103
3496
  if (isHarmonyAppStyleTarget && applyStyleSources.length > 0) {
4104
3497
  if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css) })) debug("uni-app-x harmony bundle styles inject after css assets");
4105
- syncViteProcessedCssIntoMainCssAssets();
3498
+ syncProcessedCss(options);
4106
3499
  }
4107
3500
  recordTimingDetail("finalize.processedCss", processedCssStartedAt);
4108
3501
  const createFinalizeCssPipelineContext = (file = "") => createCssPipelineContext?.(file);
@@ -4333,6 +3726,16 @@ function createJsEntryResolver(jsEntries) {
4333
3726
  function resolveUniAppXJsTransformEnabled$1(uniAppX) {
4334
3727
  return uniAppX === void 0 ? true : isUniAppXEnabled(uniAppX);
4335
3728
  }
3729
+ /**
3730
+ * generateBundle 里每个 chunk 都会独立转译。
3731
+ * 生产构建再走 moduleGraph 只会把已在产物里的 JS 再 Babel 一遍;增量模式才需要它更新被跳过的 clean chunk。
3732
+ */
3733
+ function resolveGenerateBundleJsFastPath(options) {
3734
+ return {
3735
+ experimentalJsFastPath: options.experimentalJsFastPath ?? "oxc",
3736
+ moduleGraphEnabled: options.useIncrementalMode
3737
+ };
3738
+ }
4336
3739
  function createJsHandlerOptionsFactory(options) {
4337
3740
  return (absoluteFilename, extra) => ({
4338
3741
  ...extra,
@@ -4386,28 +3789,7 @@ function isUniAppXNativeAppOutDir(outDir) {
4386
3789
  }
4387
3790
  //#endregion
4388
3791
  //#region src/uni-app-x/border-preflight.ts
4389
- const BORDER_PREFLIGHT_CLASS = "weapp-tw-border";
4390
- /** 框架回放组件样式后恢复基础规则的顺序,确保作者 class 可以覆盖重置。 */
4391
- function hoistUniAppXBorderPreflight(css) {
4392
- if (!css.includes("weapp-tw-border")) return css;
4393
- const root = postcss.parse(css);
4394
- const resets = root.nodes.filter((node) => node.type === "rule" && node.selector === `.weapp-tw-border`);
4395
- const anchor = root.nodes.find((node) => !resets.includes(node) && node.type !== "comment" && !(node.type === "atrule" && ["charset", "import"].includes(node.name)));
4396
- if (!anchor || resets.length === 0) return css;
4397
- for (const reset of resets) {
4398
- reset.remove();
4399
- root.insertBefore(anchor, reset);
4400
- }
4401
- return root.toString();
4402
- }
4403
- /** uni-app x 移除通配符 preflight 后,用独立基础类承载用户配置的边框默认值。 */
4404
- function createUniAppXBorderPreflight(options) {
4405
- const declarations = createInjectPreflight(options)().filter(({ prop }) => prop === "border" || prop.startsWith("border-"));
4406
- if (declarations.length === 0) return;
4407
- const rule = postcss.rule({ selector: `.${BORDER_PREFLIGHT_CLASS}` });
4408
- for (const declaration of declarations) rule.append(postcss.decl(declaration));
4409
- return rule.toString();
4410
- }
3792
+ const BORDER_PREFLIGHT_CLASS = UNI_APP_X_BORDER_PREFLIGHT_CLASS;
4411
3793
  function resolveUniAppXBorderPreflightOptions(options, isWeb) {
4412
3794
  const borderPreflight = isWeb ? void 0 : createUniAppXBorderPreflight(options.cssPreflight);
4413
3795
  return borderPreflight ? {
@@ -4427,7 +3809,7 @@ function injectBorderPreflightClass(ms, node, offset) {
4427
3809
  const attribute = node.props.find((prop) => prop.type === NodeTypes.ATTRIBUTE && prop.name === "class");
4428
3810
  if (attribute?.type === NodeTypes.ATTRIBUTE) {
4429
3811
  if (attribute.value) {
4430
- if (attribute.value.content.split(/\s+/).includes("weapp-tw-border")) return;
3812
+ if (attribute.value.content.split(/\s+/).includes(BORDER_PREFLIGHT_CLASS)) return;
4431
3813
  const start = offset + attribute.value.loc.start.offset;
4432
3814
  if (/^["']/.test(attribute.value.loc.source)) ms.prependRight(start + 1, `${BORDER_PREFLIGHT_CLASS} `);
4433
3815
  else {
@@ -4460,50 +3842,8 @@ function resolveUniAppXStyleIsolationEnabled(root) {
4460
3842
  }
4461
3843
  //#endregion
4462
3844
  //#region src/uni-app-x/vite/author-apply.ts
4463
- function normalizeSelector(selector) {
4464
- return selector.replace(/\s+/g, " ").trim();
4465
- }
4466
- function atRuleKey(name, params) {
4467
- return `${name.toLowerCase()}\0${params.replace(/\s+/g, " ").trim()}`;
4468
- }
4469
- /**
4470
- * `@apply` 只应把声明带回作者样式,不能把 Tailwind 根入口的 preflight、
4471
- * utilities 和 property 注册复制进 scoped style 模块。
4472
- */
4473
- function retainUniAppXAuthorApplyCss(generatedCss, authorCss) {
4474
- try {
4475
- const authorRoot = postcss.parse(removeTailwindSourceDirectives(authorCss, { importFallback: true }));
4476
- const authorSelectors = /* @__PURE__ */ new Set();
4477
- const authorAtRules = /* @__PURE__ */ new Set();
4478
- authorRoot.walkRules((rule) => {
4479
- for (const selector of rule.selectors ?? [rule.selector]) authorSelectors.add(normalizeSelector(selector));
4480
- });
4481
- authorRoot.walkAtRules((atRule) => {
4482
- if (atRule.name !== "apply" && atRule.name !== "reference") authorAtRules.add(atRuleKey(atRule.name, atRule.params));
4483
- });
4484
- const root = postcss.parse(generatedCss);
4485
- let changed = false;
4486
- root.walkRules((rule) => {
4487
- if ((rule.selectors ?? [rule.selector]).every((selector) => authorSelectors.has(normalizeSelector(selector)))) return;
4488
- rule.remove();
4489
- changed = true;
4490
- });
4491
- root.walkAtRules((atRule) => {
4492
- if (authorAtRules.has(atRuleKey(atRule.name, atRule.params))) return;
4493
- if (atRule.nodes?.some((node) => node.type === "rule" || node.type === "atrule")) return;
4494
- atRule.remove();
4495
- changed = true;
4496
- });
4497
- root.walkComments((comment) => {
4498
- if (/tailwindcss v\d|weapp-tailwindcss (?:vite-generated-css|layer|uni-app-x web preflight reset)/i.test(comment.text)) {
4499
- comment.remove();
4500
- changed = true;
4501
- }
4502
- });
4503
- return changed ? root.toString().trim() : generatedCss;
4504
- } catch {
4505
- return generatedCss;
4506
- }
3845
+ function retainUniAppXAuthorApplyCss$1(generatedCss, authorCss, options) {
3846
+ return retainUniAppXAuthorApplyCss(generatedCss, removeTailwindSourceDirectives(authorCss, { importFallback: true }), options);
4507
3847
  }
4508
3848
  //#endregion
4509
3849
  //#region src/uni-app-x/vite/harmony-apply.ts
@@ -4525,12 +3865,7 @@ function createUniAppXHarmonyApplyExpander(options) {
4525
3865
  const references = authoritative ? /* @__PURE__ */ new Set() : new Set(referenceBySourceId.get(sourceKey));
4526
3866
  for (const source of sources) {
4527
3867
  styleSources.add(source);
4528
- try {
4529
- postcss.parse(source).walkAtRules("reference", (rule) => {
4530
- const reference = rule.toString();
4531
- references.add(reference.endsWith(";") ? reference : `${reference};`);
4532
- });
4533
- } catch {}
3868
+ for (const reference of collectCssReferenceDirectives(source)) references.add(reference);
4534
3869
  for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
4535
3870
  }
4536
3871
  if (references.size > 0) referenceBySourceId.set(sourceKey, references);
@@ -4548,9 +3883,9 @@ function createUniAppXHarmonyApplyExpander(options) {
4548
3883
  const sourceUtilities = collectUniAppXHarmonyApplyUtilitiesFromSources(sources);
4549
3884
  if (sources.length === 0 || sourceUtilities.size === 0) return code;
4550
3885
  const cssFile = path.resolve(options.getResolvedConfig()?.root ?? process.cwd(), `uni-app-x-harmony-apply-${createStableHash(normalizePath(cleanUrl$1(id)))}.css`);
4551
- const generatorSource = createUniAppXHarmonyApplyGeneratorSource(sources, sourceUtilities);
3886
+ const generatorSource = createUniAppXHarmonyApplyGeneratorSource$1(sources, sourceUtilities);
4552
3887
  const generatedCss = await options.generateCss?.(cssFile, generatorSource, {
4553
- addWatchFile: hookContext.addWatchFile?.bind(hookContext),
3888
+ ...hookContext.addWatchFile ? { addWatchFile: hookContext.addWatchFile.bind(hookContext) } : {},
4554
3889
  disableSourceScan: true,
4555
3890
  sourceCandidates: [],
4556
3891
  transient: true
@@ -4653,6 +3988,18 @@ function reportStyleWarnings(result) {
4653
3988
  for (const warning of warnings) logger$1.warn(warning.toString());
4654
3989
  }
4655
3990
  //#endregion
3991
+ //#region src/uni-app-x/vite/style-result.ts
3992
+ /** 将样式处理结果和源码映射统一转换为 Vite 模块结果。 */
3993
+ async function createUniAppXStyleResult(id, result) {
3994
+ reportStyleWarnings(result);
3995
+ const rawPostcssMap = result.map.toJSON();
3996
+ const map = await formatPostcssSourceMap(rawPostcssMap, normalizePath(cleanUrl$1(id)));
3997
+ return {
3998
+ code: result.css,
3999
+ map: JSON.stringify(map)
4000
+ };
4001
+ }
4002
+ //#endregion
4656
4003
  //#region src/uni-app-x/vite/style-source.ts
4657
4004
  const VITE_CSS_HMR_MODULE_RE = /\b(?:const\s+__vite__css\s*=|__vite__updateStyle\s*\()/;
4658
4005
  function createUniAppXSfcStyleSources() {
@@ -4821,7 +4168,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
4821
4168
  //#region src/uni-app-x/vite.ts
4822
4169
  let transformUVuePromise;
4823
4170
  function loadTransformUVue() {
4824
- transformUVuePromise ?? (transformUVuePromise = import("./transform-BbbZvFQq.js").then((mod) => mod.transformUVue));
4171
+ transformUVuePromise ?? (transformUVuePromise = import("./transform-BAon9ykq.js").then((mod) => mod.transformUVue));
4825
4172
  return transformUVuePromise;
4826
4173
  }
4827
4174
  const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
@@ -4913,19 +4260,12 @@ function createUniAppXPlugins(options) {
4913
4260
  const generatedCss = shouldGenerateCss ? await generateCss?.(id, isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? harmonyApply.prepareStyles(sourceCode, id) : sourceCode, {
4914
4261
  ...hookContext,
4915
4262
  disableSourceScan: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot,
4916
- sourceCandidates: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? [] : void 0,
4263
+ ...isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? { sourceCandidates: [] } : {},
4917
4264
  transient: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot
4918
4265
  }) : void 0;
4919
- const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss(generatedCss, sourceCode) : generatedCss : sourceCode;
4266
+ const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss$1(generatedCss, sourceCode, { preserveRuntimeProperties: isWebGeneratorTarget() }) : generatedCss : sourceCode;
4920
4267
  const styleHandlerOptions = getStyleHandlerOptions(id, isNativeStyle && hasTailwindRoot ? "tailwind-root" : isNativeStyle ? "author-apply" : void 0);
4921
- const postcssResult = await styleHandler(styleCode, styleHandlerOptions);
4922
- reportStyleWarnings(postcssResult);
4923
- const rawPostcssMap = postcssResult.map.toJSON();
4924
- const postcssMap = await formatPostcssSourceMap(rawPostcssMap, normalizePath(cleanUrl$1(id)));
4925
- return {
4926
- code: postcssResult.css,
4927
- map: postcssMap
4928
- };
4268
+ return createUniAppXStyleResult(id, isWebGeneratorTarget() && typeof generatedCss === "string" && generatedCss.trim().length > 0 ? await postcss().process(styleCode, styleHandlerOptions.postcssOptions.options) : await styleHandler(styleCode, styleHandlerOptions));
4929
4269
  }
4930
4270
  }
4931
4271
  const harmonyApply = createUniAppXHarmonyApplyExpander({
@@ -5009,6 +4349,7 @@ function createUniAppXPlugins(options) {
5009
4349
  ...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
5010
4350
  ...enablePageLocalStyle ? { enablePageLocalStyle } : {},
5011
4351
  native: true,
4352
+ localStyleVariants: !isNativeAppBuildTarget(id) && !isWebGeneratorTarget() ? true : void 0,
5012
4353
  ...resolveUniAppXBorderPreflightOptions(options, isWebGeneratorTarget()),
5013
4354
  pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
5014
4355
  ...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
@@ -5094,7 +4435,7 @@ function createUniAppXPlugins(options) {
5094
4435
  const applyUtilities = /* @__PURE__ */ new Set([...harmonyApply.utilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
5095
4436
  if (applyStyleSources.length > 0 && applyUtilities.size > 0) {
5096
4437
  const harmonyApplyCssFile = path.resolve(getResolvedConfig()?.root ?? process.cwd(), "uni-app-x-harmony-apply.css");
5097
- const generatedCss = await generateCss?.(harmonyApplyCssFile, createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities), {
4438
+ const generatedCss = await generateCss?.(harmonyApplyCssFile, createUniAppXHarmonyApplyGeneratorSource$1(applyStyleSources, applyUtilities), {
5098
4439
  addWatchFile: this?.addWatchFile?.bind(this),
5099
4440
  disableSourceScan: true,
5100
4441
  sourceCandidates: [],
@@ -5319,6 +4660,7 @@ async function processRememberedCssReplay(options) {
5319
4660
  const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
5320
4661
  if (!rememberedCssSource) continue;
5321
4662
  const { sourceFile } = rememberedCssSource;
4663
+ if (normalizedBundleFiles.has(normalizeOutputPathKey(rememberedOutputFile)) || normalizedBundleFiles.has(normalizeOutputPathKey(sourceFile)) || bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
5322
4664
  const rawSource = isWebGeneratorTarget ? rememberedCssSource.rawSource : normalizeMiniProgramImportShell(rememberedCssSource.rawSource, {
5323
4665
  cssOnly: true,
5324
4666
  outputFile,
@@ -5346,21 +4688,11 @@ async function processRememberedCssReplay(options) {
5346
4688
  const cssSourceChanged = changedCssFiles.has(outputFile) || changedCssFiles.has(sourceFile) || previousRawSourceHash != null && previousRawSourceHash !== rawSourceHash;
5347
4689
  const previousCss = useIncrementalMode && !cssSourceChanged && getLastCssSourceHash(lastCssSourceHashByFile, outputFile) === cssRuntimeAffectingHash ? getLastCssResult(lastCssResultByFile, outputFile) : void 0;
5348
4690
  const allRememberedSignaturesFresh = rememberedKeys.length > 0 && rememberedKeys.every((key) => getRememberedCssSignature?.(key) === rememberedCssRuntimeSignature);
5349
- if (bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
5350
- const shouldMergeReplayIntoFrameworkRootTarget = outputFile !== rememberedOutputFile && normalizedBundleFiles.has(normalizeOutputPathKey(outputFile));
5351
- if (allRememberedSignaturesFresh) {
5352
- if (!shouldMergeReplayIntoFrameworkRootTarget) continue;
5353
- else {
5354
- const cachedCss = getLastCssResult(lastCssResultByFile, outputFile);
5355
- if (cachedCss != null) {
5356
- pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedCss, sourceFile, outputFile, true));
5357
- metrics.css.cacheHits++;
5358
- debug("css replay cached result into framework root target: %s", outputFile);
5359
- continue;
5360
- }
5361
- debug("css replay framework root target cache miss, regenerate: %s", outputFile);
5362
- }
5363
- }
4691
+ const shouldMergeReplayIntoFrameworkRootTarget = [...frameworkRootImportShellTargetByFile ?? []].some(([file, target]) => normalizeOutputPathKey(target) === normalizeOutputPathKey(outputFile) && normalizedBundleFiles.has(normalizeOutputPathKey(file))) || outputFile !== rememberedOutputFile && normalizedBundleFiles.has(normalizeOutputPathKey(outputFile));
4692
+ const generatedReplayKey = createGeneratedReplayCacheKey(outputFile);
4693
+ activeViteCssCacheFiles.add(generatedReplayKey);
4694
+ const cachedGeneratedReplayCss = allRememberedSignaturesFresh && shouldMergeReplayIntoFrameworkRootTarget ? lastCssResultByFile.get(generatedReplayKey) : void 0;
4695
+ if (allRememberedSignaturesFresh && !shouldMergeReplayIntoFrameworkRootTarget) continue;
5364
4696
  const sourceTraceSources = scopedSourceCandidateSourceGetter ? await createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
5365
4697
  const sourceTraceTokenSources = sourceTraceSources ? createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
5366
4698
  const annotateCss = (css) => annotateCssSourceTrace(css, {
@@ -5410,6 +4742,20 @@ async function processRememberedCssReplay(options) {
5410
4742
  }));
5411
4743
  continue;
5412
4744
  }
4745
+ if (cachedGeneratedReplayCss) {
4746
+ cssTaskFactories.push(() => timeTask("css.replay", async () => {
4747
+ const start = performance.now();
4748
+ lastCssRawSourceHashByFile.set(outputFile, rawSourceHash);
4749
+ for (const key of rememberedKeys) setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
4750
+ recordCssAssetResult?.(outputFile, cachedGeneratedReplayCss);
4751
+ pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedGeneratedReplayCss, sourceFile, outputFile, true));
4752
+ metrics.css.elapsed += measureElapsed(start);
4753
+ metrics.css.cacheHits++;
4754
+ onUpdate(outputFile, rememberedCssSource.rawSource, cachedGeneratedReplayCss);
4755
+ debug("css replay reuse generated cache: %s bytes=%d", outputFile, cachedGeneratedReplayCss.length);
4756
+ }));
4757
+ continue;
4758
+ }
5413
4759
  cssTaskFactories.push(() => timeTask("css.replay", async () => {
5414
4760
  const start = performance.now();
5415
4761
  const generated = await generateTailwindV4Css({
@@ -5426,11 +4772,12 @@ async function processRememberedCssReplay(options) {
5426
4772
  generatorPlatform,
5427
4773
  styleHandler,
5428
4774
  debug,
5429
- previousCss
4775
+ previousCss: shouldMergeReplayIntoFrameworkRootTarget ? void 0 : previousCss
5430
4776
  });
5431
4777
  const css = annotateCss(generated?.css ?? (await styleHandler(generatorRawSource, cssHandlerOptions)).css);
5432
4778
  lastCssRawSourceHashByFile.set(outputFile, rawSourceHash);
5433
4779
  rememberLastCssResult(lastCssResultByFile, lastCssSourceHashByFile, outputFile, css, cssRuntimeAffectingHash);
4780
+ rememberLastCssResult(lastCssResultByFile, lastCssSourceHashByFile, generatedReplayKey, css, cssRuntimeAffectingHash);
5434
4781
  for (const key of rememberedKeys) setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
5435
4782
  if (generated) {
5436
4783
  registerGeneratorDependencies({ addWatchFile }, generated.dependencies);
@@ -5490,7 +4837,7 @@ function createConfiguredCssSourceRegistry(options) {
5490
4837
  return {
5491
4838
  explicitCssEntryFiles,
5492
4839
  getSourceEntries,
5493
- normalizeGeneratorUserRawSource: (source, sourceFile, fallbackFile) => normalizeRelativeCssConfigDirectives(source, sourceFile || fallbackFile, options.outDir, options.opts),
4840
+ normalizeGeneratorUserRawSource: (source, sourceFile, fallbackFile) => normalizeRelativeCssConfigDirectives(source, sourceFile || (fallbackFile ?? ""), options.outDir, options.opts),
5494
4841
  resolveMatchedSourceOutputFile: (sourceFile) => resolveOutputFileFromMatchedCssSource({
5495
4842
  bundleFiles: options.bundleFiles,
5496
4843
  defaultStyleOutputExtension: options.defaultStyleOutputExtension,
@@ -6200,7 +5547,11 @@ function createGenerateBundleHook$1(context) {
6200
5547
  const jsEntries = snapshot.jsEntries;
6201
5548
  const getJsEntry = createJsEntryResolver(jsEntries);
6202
5549
  const transformFilterSignature = createTransformFilterSignature(opts.transform);
6203
- const moduleGraphOptions = createBundleModuleGraphOptions(outDir, jsEntries);
5550
+ const jsFastPath = resolveGenerateBundleJsFastPath({
5551
+ experimentalJsFastPath: opts.experimentalJsFastPath,
5552
+ useIncrementalMode
5553
+ });
5554
+ const moduleGraphOptions = jsFastPath.moduleGraphEnabled ? createBundleModuleGraphOptions(outDir, jsEntries) : void 0;
6204
5555
  const hasRuntimeAffectingChanges = hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
6205
5556
  const runtimeStart = performance.now();
6206
5557
  const forceV4RuntimeRefreshBySource = forceRuntimeRefreshBySource;
@@ -6310,7 +5661,7 @@ function createGenerateBundleHook$1(context) {
6310
5661
  debug
6311
5662
  });
6312
5663
  const createBaseHandlerOptions = createJsHandlerOptionsFactory({
6313
- getExperimentalJsFastPath: () => opts.experimentalJsFastPath ?? (resolvedConfig?.build?.watch != null ? "oxc" : false),
5664
+ getExperimentalJsFastPath: () => jsFastPath.experimentalJsFastPath,
6314
5665
  getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
6315
5666
  moduleGraph: moduleGraphOptions
6316
5667
  });
@@ -6683,8 +6034,11 @@ function createGenerateBundleHook(context) {
6683
6034
  const relationOwner = getActiveViteSourceOutputRelationOwner();
6684
6035
  const removalConsumer = relationOwner?.createRemovalConsumer();
6685
6036
  const rememberCssSource = context.rememberCssSource;
6037
+ const frameworkRootImportShellTargetByFile = context.frameworkRootImportShellTargetByFile ?? /* @__PURE__ */ new Map();
6038
+ const frameworkStyleMemory = createFrameworkStyleMemory(frameworkRootImportShellTargetByFile);
6686
6039
  const runtimeHandler = createGenerateBundleHook$1({
6687
6040
  ...context,
6041
+ frameworkRootImportShellTargetByFile,
6688
6042
  rememberCssSource: rememberCssSource ? (entry, cssRuntimeSignature) => {
6689
6043
  relationOwner?.recordOwnedOutput(entry.sourceFile, entry.outputFile);
6690
6044
  rememberCssSource(entry, cssRuntimeSignature);
@@ -6693,9 +6047,11 @@ function createGenerateBundleHook(context) {
6693
6047
  return async function generateBundle(options, bundle) {
6694
6048
  relationOwner?.recordBundle(bundle);
6695
6049
  const removedFiles = removalConsumer?.consume(Object.keys(bundle)) ?? [];
6050
+ const rememberFrameworkStyles = frameworkStyleMemory.prepare(bundle, removedFiles);
6696
6051
  beginCompilerShadowRun(context.runtimeState);
6697
6052
  const runRuntime = () => runWithRemovedBundleFiles(removedFiles, () => runtimeHandler.call(this, options, bundle));
6698
6053
  await (relationOwner ? withViteSourceOutputRelationOwner(relationOwner, runRuntime) : runRuntime());
6054
+ rememberFrameworkStyles();
6699
6055
  };
6700
6056
  }
6701
6057
  //#endregion
@@ -6748,6 +6104,20 @@ function linkEntryChunkStyles(bundle, options) {
6748
6104
  }
6749
6105
  }
6750
6106
  //#endregion
6107
+ //#region src/bundlers/vite/css-finalizer/final-assets.ts
6108
+ /** 按生成目标统一收尾已组装的 CSS 资产,供空资产和常规分支复用。 */
6109
+ function finalizeCssAssets(bundle, context, isWebGeneratorTarget, files) {
6110
+ if (isWebGeneratorTarget) return finalizeWebCssCalc(bundle, context);
6111
+ finalizeMiniProgramCssAssetStructures(bundle, {
6112
+ cssMatcher: context.opts.cssMatcher,
6113
+ debug: context.debug,
6114
+ files,
6115
+ isWebGeneratorTarget,
6116
+ onUpdate: context.opts.onUpdate,
6117
+ recordCssAssetResult: context.recordCssAssetResult
6118
+ });
6119
+ }
6120
+ //#endregion
6751
6121
  //#region src/bundlers/vite/css-finalizer/plugin.ts
6752
6122
  function createViteCssFinalizerOutputPlugin(context) {
6753
6123
  return {
@@ -6825,6 +6195,7 @@ function createViteCssFinalizerOutputPlugin(context) {
6825
6195
  rootDir,
6826
6196
  sourceRoot
6827
6197
  })) {
6198
+ await finalizeWebCssCalc(bundle, context);
6828
6199
  finalizeCompilerShadowRun(runtimeState);
6829
6200
  finishTiming();
6830
6201
  return;
@@ -6917,7 +6288,7 @@ function createViteCssFinalizerOutputPlugin(context) {
6917
6288
  opts,
6918
6289
  runtimeState,
6919
6290
  runtime: /* @__PURE__ */ new Set(),
6920
- rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
6291
+ rawSource: createUniAppXHarmonyApplyGeneratorSource$1(applyStyleSources, applyUtilities),
6921
6292
  file: "uni-app-x-harmony-apply.css",
6922
6293
  outputFile: "uni-app-x-harmony-apply.css",
6923
6294
  cssHandlerOptions: harmonyCssHandlerOptions,
@@ -6948,7 +6319,7 @@ function createViteCssFinalizerOutputPlugin(context) {
6948
6319
  const entries = Object.entries(bundle).filter(isCssOutputAssetEntry);
6949
6320
  recordTiming("assets.enumerate", enumerateStartedAt);
6950
6321
  if (entries.length === 0) {
6951
- await injectHarmonyBundleStyles(getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet());
6322
+ await injectHarmonyBundleStyles();
6952
6323
  collectViteProcessedCssAssets();
6953
6324
  injectViteProcessedCssIntoMainCss();
6954
6325
  linkEntryStyles();
@@ -6959,14 +6330,7 @@ function createViteCssFinalizerOutputPlugin(context) {
6959
6330
  onUpdate: trackFinalCssAssetUpdate,
6960
6331
  recordCssAssetResult
6961
6332
  });
6962
- finalizeMiniProgramCssAssetStructures(bundle, {
6963
- cssMatcher: opts.cssMatcher,
6964
- debug,
6965
- files: finalCssAssetFiles,
6966
- isWebGeneratorTarget,
6967
- onUpdate: opts.onUpdate,
6968
- recordCssAssetResult
6969
- });
6333
+ await finalizeCssAssets(bundle, context, isWebGeneratorTarget, finalCssAssetFiles);
6970
6334
  finalizeCompilerShadowRun(runtimeState);
6971
6335
  finishTiming();
6972
6336
  return;
@@ -7084,14 +6448,7 @@ function createViteCssFinalizerOutputPlugin(context) {
7084
6448
  onUpdate: trackFinalCssAssetUpdate,
7085
6449
  recordCssAssetResult
7086
6450
  });
7087
- finalizeMiniProgramCssAssetStructures(bundle, {
7088
- cssMatcher: opts.cssMatcher,
7089
- debug,
7090
- files: finalCssAssetFiles,
7091
- isWebGeneratorTarget,
7092
- onUpdate: opts.onUpdate,
7093
- recordCssAssetResult
7094
- });
6451
+ await finalizeCssAssets(bundle, context, isWebGeneratorTarget, finalCssAssetFiles);
7095
6452
  finalizeCompilerShadowRun(runtimeState);
7096
6453
  recordTiming("assets.write", writeStartedAt);
7097
6454
  finishTiming();
@@ -7317,7 +6674,7 @@ function isWebOrNativeAppPlatform(platform) {
7317
6674
  return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
7318
6675
  }
7319
6676
  function isInternalUserDefinedOptions(options) {
7320
- return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
6677
+ return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && "tailwindRuntime" in options && typeof options.tailwindRuntime === "object" && "refreshTailwindcssRuntime" in options && typeof options.refreshTailwindcssRuntime === "function";
7321
6678
  }
7322
6679
  function isNuxtPageHotModule(id) {
7323
6680
  if (typeof id !== "string") return false;
@@ -7327,6 +6684,41 @@ function isNuxtPageHotModule(id) {
7327
6684
  return cleanId.includes("/pages/") && /\.(?:vue|tsx?|jsx?)$/.test(cleanId);
7328
6685
  }
7329
6686
  //#endregion
6687
+ //#region src/bundlers/vite/shared/framework-runtime-configuration.ts
6688
+ const ENV_PLATFORM_KEYS = [
6689
+ "UNI_PLATFORM",
6690
+ "UNI_UTS_PLATFORM",
6691
+ "TARO_ENV",
6692
+ "MPX_CURRENT_TARGET_MODE",
6693
+ "MPX_CLI_MODE"
6694
+ ];
6695
+ /** 在配置基准确定后同步显式 CSS 入口,保留运行时与用户选项的一致性。 */
6696
+ function createFrameworkCssEntrySync(opts, rawCssEntries) {
6697
+ return (anchor) => {
6698
+ var _opts$tailwindcss;
6699
+ const entries = normalizeCssEntries(rawCssEntries, anchor ?? process.cwd());
6700
+ if (!entries) return false;
6701
+ const changed = !sameStringList(opts.cssEntries, entries);
6702
+ opts.cssEntries = entries;
6703
+ opts.tailwindcss ?? (opts.tailwindcss = {});
6704
+ (_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
6705
+ opts.tailwindcss.v4.cssEntries = entries;
6706
+ if (opts.tailwindcssRuntimeOptions?.tailwindcss?.v4) opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries = entries;
6707
+ if (opts.tailwindRuntime?.options?.tailwindcss?.v4) opts.tailwindRuntime.options.tailwindcss.v4.cssEntries = entries;
6708
+ return changed;
6709
+ };
6710
+ }
6711
+ /** 按显式配置、框架环境与输出目录顺序解析当前样式平台。 */
6712
+ function resolveFrameworkStylePlatform(opts, outDir) {
6713
+ const explicit = normalizeFrameworkStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
6714
+ if (explicit) return explicit;
6715
+ for (const key of ENV_PLATFORM_KEYS) {
6716
+ const platform = normalizeFrameworkStylePlatform(process.env[key], opts.appType);
6717
+ if (platform) return platform;
6718
+ }
6719
+ return inferPlatformFromOutDir(outDir);
6720
+ }
6721
+ //#endregion
7330
6722
  //#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
7331
6723
  function createFrameworkSourceCandidatesPlugin(options, apply) {
7332
6724
  const shouldSkipSourceCandidateState = () => options.shouldSkipSourceCandidateState?.() === true;
@@ -7360,7 +6752,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
7360
6752
  };
7361
6753
  return {
7362
6754
  name: `${vitePluginName}:source-candidates`,
7363
- apply,
6755
+ ...apply === void 0 ? {} : { apply },
7364
6756
  enforce: "pre",
7365
6757
  async load(id) {
7366
6758
  if (!options.shouldOwnTailwindGeneration || shouldSkipSourceCandidateState() || options.isWebOrNativeAppPlatform(options.resolveViteStylePlatform()) || !isCSSRequest(id) || !shouldCollectTransformedSourceCandidates(id)) return;
@@ -7459,7 +6851,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
7459
6851
  mod.file
7460
6852
  ]) if (typeof id === "string" && id.length > 0) options.rememberTailwindRootCssModule(id);
7461
6853
  }
7462
- const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await ctx.read().catch(() => void 0) : void 0;
6854
+ const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await readViteHmrSource(ctx) : void 0;
7463
6855
  if (typeof hotSource === "string" && isCSSRequest(ctx.file)) {
7464
6856
  options.rememberOriginalCssLayerSource(ctx.file, hotSource);
7465
6857
  await options.refreshTailwindRootCssSource(ctx.file, hotSource);
@@ -7546,13 +6938,6 @@ const debug = createDebug();
7546
6938
  const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
7547
6939
  const weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
7548
6940
  const generatorPlaceholderCssFile = path.join(weappTailwindcssPackageDir, "generator-placeholder.css");
7549
- const ENV_PLATFORM_KEYS = [
7550
- "UNI_PLATFORM",
7551
- "UNI_UTS_PLATFORM",
7552
- "TARO_ENV",
7553
- "MPX_CURRENT_TARGET_MODE",
7554
- "MPX_CLI_MODE"
7555
- ];
7556
6941
  function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
7557
6942
  debug("create vite framework plugins framework=%s", frameworkBranch.frameworkName);
7558
6943
  const capability = options.__internalViteCapabilityProfile ?? frameworkViteCapabilityProfile;
@@ -7560,23 +6945,12 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
7560
6945
  const hasExplicitAppType = typeof options.__internalViteRawExplicitAppType === "boolean" ? options.__internalViteRawExplicitAppType : typeof options.appType === "string" && options.appType.trim().length > 0;
7561
6946
  const hasExplicitTailwindcssBasedir = typeof options.__internalViteRawExplicitTailwindcssBasedir === "boolean" ? options.__internalViteRawExplicitTailwindcssBasedir : typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
7562
6947
  const rawCssEntries = collectConfiguredCssEntries(rawOptions);
7563
- const opts = isInternalUserDefinedOptions(options) ? options : getCompilerContext({
6948
+ const deferredOptions = {
7564
6949
  ...options,
7565
6950
  __internalDeferMissingCssEntriesWarning: true
7566
- });
7567
- const syncCssEntriesFromAnchor = (anchor) => {
7568
- var _opts$tailwindcss;
7569
- const normalizedCssEntries = normalizeCssEntries(rawCssEntries, anchor ?? process.cwd());
7570
- if (!normalizedCssEntries) return false;
7571
- const changed = !sameStringList(opts.cssEntries, normalizedCssEntries);
7572
- opts.cssEntries = normalizedCssEntries;
7573
- opts.tailwindcss ?? (opts.tailwindcss = {});
7574
- (_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
7575
- opts.tailwindcss.v4.cssEntries = normalizedCssEntries;
7576
- if (opts.tailwindcssRuntimeOptions?.tailwindcss?.v4) opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries = normalizedCssEntries;
7577
- if (opts.tailwindRuntime?.options?.tailwindcss?.v4) opts.tailwindRuntime.options.tailwindcss.v4.cssEntries = normalizedCssEntries;
7578
- return changed;
7579
6951
  };
6952
+ const opts = isInternalUserDefinedOptions(options) ? options : getCompilerContext(deferredOptions);
6953
+ const syncCssEntriesFromAnchor = createFrameworkCssEntrySync(opts, rawCssEntries);
7580
6954
  syncCssEntriesFromAnchor(opts.tailwindcssBasedir);
7581
6955
  const { disabled, customAttributes, onLoad, mainCssChunkMatcher, styleHandler, jsHandler, tailwindRuntime, refreshTailwindcssRuntime, uniAppX, disabledDefaultTemplateHandler, styleInjector } = opts;
7582
6956
  const initialTailwindRuntime = tailwindRuntime;
@@ -7595,15 +6969,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
7595
6969
  isWeb: () => resolveCurrentGeneratorBranch().isWeb
7596
6970
  });
7597
6971
  const hmrCssModuleVersions = createViteHmrCssModuleVersionTracker();
7598
- const resolveViteStylePlatform = () => {
7599
- const explicit = normalizeFrameworkStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
7600
- if (explicit) return explicit;
7601
- for (const key of ENV_PLATFORM_KEYS) {
7602
- const envPlatform = normalizeFrameworkStylePlatform(process.env[key], opts.appType);
7603
- if (envPlatform) return envPlatform;
7604
- }
7605
- return inferPlatformFromOutDir(resolvedConfig?.build?.outDir);
7606
- };
6972
+ const resolveViteStylePlatform = () => resolveFrameworkStylePlatform(opts, resolvedConfig?.build?.outDir);
7607
6973
  const resolveGeneratorPlatform = () => opts.cssOptions?.platform ?? opts.platform ?? resolveViteStylePlatform();
7608
6974
  const resolveCurrentGeneratorOptions = () => normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
7609
6975
  appType: opts.appType,
@@ -7631,7 +6997,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
7631
6997
  const platform = resolveViteStylePlatform();
7632
6998
  if (!shouldOwnTailwindGeneration || (platform ? isWebOrNativeAppPlatform(platform) : resolveCurrentGeneratorBranch().isWeb)) return code;
7633
6999
  let transformedCode = code;
7634
- if (transformedCode.includes("#if")) transformedCode = compileCssMacroConditionalComments(transformedCode, { platform: resolveViteStylePlatform() });
7000
+ if (transformedCode.includes("#if")) transformedCode = compileCssMacroConditionalComments(transformedCode, { ...platform ? { platform } : {} });
7635
7001
  if (transformedCode.includes("@layer")) transformedCode = unwrapUnsupportedCascadeLayers(transformedCode);
7636
7002
  return transformedCode;
7637
7003
  };
@@ -7664,7 +7030,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
7664
7030
  if (isMissingInternalCssSource(file, weappTailwindcssPackageDir)) return;
7665
7031
  const sourceFile = path.normalize(file);
7666
7032
  const sourceBase = path.dirname(sourceFile);
7667
- const sourceCss = normalizeTailwindSourceForGenerator(normalizeTailwindConfigDirectives(css, sourceBase), { importFallback: true });
7033
+ const sourceCss = normalizeTailwindSourceForGenerator(normalizeTailwindConfigDirectives$1(css, sourceBase), { importFallback: true });
7668
7034
  if (autoCssSourceContent.get(sourceFile) === sourceCss) return;
7669
7035
  autoCssSourceContent.set(sourceFile, sourceCss);
7670
7036
  await syncTailwindCssSourceCandidates(sourceFile, sourceCss);
@@ -7705,7 +7071,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
7705
7071
  for (const cssEntry of cssEntries) {
7706
7072
  const sourceFile = path.resolve(cssEntry);
7707
7073
  const sourceBase = path.dirname(sourceFile);
7708
- const sourceCss = normalizeTailwindSourceForGenerator(normalizeTailwindConfigDirectives(await readFile(sourceFile, "utf8"), sourceBase), { importFallback: true });
7074
+ const sourceCss = normalizeTailwindSourceForGenerator(normalizeTailwindConfigDirectives$1(await readFile(sourceFile, "utf8"), sourceBase), { importFallback: true });
7709
7075
  if (autoCssSourceContent.get(sourceFile) === sourceCss) continue;
7710
7076
  autoCssSourceContent.set(sourceFile, sourceCss);
7711
7077
  await syncTailwindCssSourceCandidates(sourceFile, sourceCss);
@@ -7898,7 +7264,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
7898
7264
  const inferredSfcStyleRequest = isSfcStyleSourceFile(file) ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), code) : file;
7899
7265
  const requestFile = isCSSRequest(id) ? inferredSfcStyleRequest === file ? resolveViteCssPipelineRequestFile(id) : inferredSfcStyleRequest : inferredSfcStyleRequest;
7900
7266
  if (!isCSSRequest(requestFile) || opts.htmlMatcher(file) || isHTMLRequest(file)) return;
7901
- const generatorCode = normalizeEmptyTailwindCustomVariants(code);
7267
+ const generatorCode = normalizeEmptyTailwindCustomVariants$1(code);
7902
7268
  const rootDir = resolvedConfig?.root ? path.resolve(resolvedConfig.root) : process.cwd();
7903
7269
  const currentGeneratorOptions = resolveCurrentGeneratorOptions();
7904
7270
  const currentGeneratorBranch = resolveCurrentGeneratorBranch();
@@ -8060,7 +7426,7 @@ ${previousTracedCss}`;
8060
7426
  });
8061
7427
  debug("css generated for vite postcss pipeline: %s bytes=%d", requestFile, tracedCss.length);
8062
7428
  return `${createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
8063
- ${tracedCss}`;
7429
+ ${tracedCss}${currentGeneratorBranch.isWeb ? `\n${createBundlerGeneratedCssEndMarker("vite", normalizeViteProcessedCssFile(file))}` : ""}`;
8064
7430
  };
8065
7431
  const generateTailwindCssForVitePipeline = createFrameworkCssGenerationQueue(normalizeGeneratedCssCacheFile, generateTailwindCssForVitePipelineNow);
8066
7432
  const shouldDeferFrameworkPreTransformGeneration = (id, code) => frameworkCssPipelineStrategy?.shouldDeferPreTransformTailwindGeneration?.({
@@ -8328,13 +7694,16 @@ function wrapPluginHook(hook, before) {
8328
7694
  before(...args);
8329
7695
  return hook.apply(this, args);
8330
7696
  };
8331
- if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return {
8332
- ...hook,
8333
- handler(...args) {
8334
- before(...args);
8335
- return hook.handler.apply(this, args);
8336
- }
8337
- };
7697
+ if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") {
7698
+ const handler = hook.handler;
7699
+ return {
7700
+ ...hook,
7701
+ handler(...args) {
7702
+ before(...args);
7703
+ return handler.apply(this, args);
7704
+ }
7705
+ };
7706
+ }
8338
7707
  return hook;
8339
7708
  }
8340
7709
  function wrapPluginCloseBundle(hook, dispose) {
@@ -8345,16 +7714,19 @@ function wrapPluginCloseBundle(hook, dispose) {
8345
7714
  dispose.call(this);
8346
7715
  }
8347
7716
  };
8348
- if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return {
8349
- ...hook,
8350
- async handler(...args) {
8351
- try {
8352
- return await hook.handler.apply(this, args);
8353
- } finally {
8354
- dispose.call(this);
7717
+ if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") {
7718
+ const handler = hook.handler;
7719
+ return {
7720
+ ...hook,
7721
+ async handler(...args) {
7722
+ try {
7723
+ return await handler.apply(this, args);
7724
+ } finally {
7725
+ dispose.call(this);
7726
+ }
8355
7727
  }
8356
- }
8357
- };
7728
+ };
7729
+ }
8358
7730
  return dispose;
8359
7731
  }
8360
7732
  function createViteFrameworkPlugins(options = {}, frameworkBranch) {
@@ -8366,11 +7738,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
8366
7738
  }
8367
7739
  const wrappedPlugins = plugins.map((plugin) => ({
8368
7740
  ...plugin,
8369
- watchChange: wrapPluginHook(plugin.watchChange, (id, change) => {
7741
+ watchChange: wrapPluginHook(plugin["watchChange"], (id, change) => {
8370
7742
  if (change?.event === "delete") relationOwner.removeSource(id);
8371
7743
  else relationOwner.observeSource(id);
8372
7744
  }),
8373
- handleHotUpdate: wrapPluginHook(plugin.handleHotUpdate, (context) => {
7745
+ handleHotUpdate: wrapPluginHook(plugin["handleHotUpdate"], (context) => {
8374
7746
  if (context?.file) relationOwner.observeSource(context.file);
8375
7747
  })
8376
7748
  }));
@@ -8409,12 +7781,8 @@ function createTaroAlipayBrowserslistAssetPlugin() {
8409
7781
  name: "weapp-tailwindcss:taro-alipay-browserslist-asset",
8410
7782
  enforce: "pre",
8411
7783
  generateBundle(_options, bundle) {
8412
- if (process.env.TARO_ENV !== "alipay") return;
8413
- bundle[".browserslistrc"] = {
8414
- type: "asset",
8415
- fileName: ".browserslistrc",
8416
- source: "defaults and fully supports es6-module"
8417
- };
7784
+ if (process.env["TARO_ENV"] !== "alipay") return;
7785
+ bundle[".browserslistrc"] = createReplayCssAsset(".browserslistrc", "defaults and fully supports es6-module");
8418
7786
  }
8419
7787
  };
8420
7788
  }
@@ -8620,7 +7988,7 @@ const uniAppXCssPipelineStrategy = {
8620
7988
  },
8621
7989
  transformGeneratedCss(css, context) {
8622
7990
  const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
8623
- const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
7991
+ const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss, { preserveRuntimeProperties: context.currentGeneratorBranch.isWeb }), context.currentGeneratorBranch.isWeb);
8624
7992
  return context.currentGeneratorBranch.isWeb ? output : hoistUniAppXBorderPreflight(output);
8625
7993
  }
8626
7994
  };
@@ -8744,7 +8112,7 @@ function resolveViteProfile(options, config, environmentName) {
8744
8112
  }
8745
8113
  const family = platformFamily(selectedPlatform ?? (config.build?.outDir ? path.basename(path.normalize(config.build.outDir)) : void 0));
8746
8114
  if (!explicitAppType && !(rawTarget !== "web" && family !== "web")) appType = void 0;
8747
- const isGenericWeb = frameworkName === "generic" && (forceGenericWeb || !explicitAppType) && rawTarget !== "weapp" && rawTarget !== "app" && family !== "mini-program";
8115
+ const isGenericWeb = frameworkName === "generic" && (forceGenericWeb || !explicitAppType) && rawTarget !== "weapp" && family !== "mini-program";
8748
8116
  const cssOnlyGenericWeb = isGenericWeb && (forceGenericWeb || rawTarget === void 0 && explicitAppType === void 0 && selectedPlatform === void 0);
8749
8117
  const capability = isGenericWeb ? {
8750
8118
  ...createGenericWebViteCapabilityProfile(options),
@@ -8769,8 +8137,8 @@ function resolveViteProfile(options, config, environmentName) {
8769
8137
  }
8770
8138
  function invokeHook(plugin, hookName, thisArg, args) {
8771
8139
  const hook = plugin?.[hookName];
8772
- if (typeof hook === "function") return hook.apply(thisArg, args);
8773
- if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return hook.handler.apply(thisArg, args);
8140
+ if (typeof hook === "function") return Reflect.apply(hook, thisArg, args);
8141
+ if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return Reflect.apply(hook.handler, thisArg, args);
8774
8142
  }
8775
8143
  function emitDeferredRuntimeLogs(opts, profile, rawOptions) {
8776
8144
  const hasExplicitLogLevel = Object.hasOwn(rawOptions, "logLevel");
@@ -8879,7 +8247,7 @@ function createDispatcher(options) {
8879
8247
  opts.appType = profile.appType;
8880
8248
  logger.debug("根据 Vite 项目根目录自动推断 appType -> %s", profile.appType);
8881
8249
  }
8882
- if (profile.isGenericWeb && (opts.generator === void 0 || typeof opts.generator === "object" && !Object.hasOwn(opts.generator, "target")) && opts.generator !== false && !options.platform && !options.cssOptions?.platform && !process.env["UNI_PLATFORM"] && !process.env["UNI_UTS_PLATFORM"]) opts.generator = { target: "web" };
8250
+ if (profile.isGenericWeb && (opts.generator === void 0 || typeof opts.generator === "object" && !Object.hasOwn(opts.generator, "target")) && !options.platform && !options.cssOptions?.platform && !process.env["UNI_PLATFORM"] && !process.env["UNI_UTS_PLATFORM"]) opts.generator = { target: "web" };
8883
8251
  const capability = opts.__internalViteCapabilityProfile;
8884
8252
  if (capability) Object.assign(capability, profile.capability);
8885
8253
  else opts.__internalViteCapabilityProfile = profile.capability;
@@ -8915,4 +8283,4 @@ function WeappTailwindcss(options = {}) {
8915
8283
  return createDispatcher(options);
8916
8284
  }
8917
8285
  //#endregion
8918
- export { shouldEnablePageLocalStyle as a, shouldEnableComponentLocalStyle as i, injectBorderPreflightClass as n, isUniAppXStyleSourceEmpty as o, shouldInjectBorderPreflight as r, WeappTailwindcss as t };
8286
+ export { shouldEnablePageLocalStyle as a, shouldEnableComponentLocalStyle as i, injectBorderPreflightClass as n, shouldInjectBorderPreflight as r, WeappTailwindcss as t };