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,3357 +0,0 @@
1
- import { resolveUniUtsPlatform as resolveUniUtsPlatform$1 } from "./framework.js";
2
- import { c as withCssMacroStyleOptions, i as hasCssMacroTailwindV4Source, o as transformCssMacroCss, s as transformCssMacroTailwindV4Source, t as hasCssMacroStyleOptions } from "./auto-2dg_uhEJ.js";
3
- import "./utils-MVwpU07P.js";
4
- import { createRequire } from "node:module";
5
- import fs, { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
6
- import path from "node:path";
7
- import process from "node:process";
8
- import { createTailwindGenerationSession, createTailwindV4Engine, extractRawCandidates, loadTailwindV4DesignSystem, resolveProjectSourceFiles, resolveTailwindV4Source, resolveValidTailwindV4Candidates as resolveValidTailwindV4Candidates$1 } from "@tailwindcss-mangle/engine";
9
- import { analyzeTailwindCssDirectives, createStyleHandler, filterExistingCssRules, finalizeMiniProgramCss as finalizeMiniProgramCss$1, hasMiniProgramCssSpecificityPlaceholders, isTailwindCssGenerationDirective, isTailwindCssImportAtRule, isTailwindCssPackageJsonImportRequest, normalizeTailwindCssImportRequest, normalizeTailwindcssWebRpxDeclarations, parseTailwindCssConfigRequest, parseTailwindCssDirectiveRequest, postcss, protectDynamicColorMixAlpha, pruneMiniProgramGeneratedCss, pruneMiniProgramGeneratedCss as pruneMiniProgramGeneratedCss$1, removeUnsupportedCascadeLayers, removeUnsupportedMiniProgramAtRules, selectorContainsPseudoClass, stripMiniProgramCssSpecificityPlaceholders } from "@weapp-tailwindcss/postcss";
10
- import { LRUCache } from "lru-cache";
11
- import { TokenType, tokenize } from "@csstools/css-tokenizer";
12
- import { stat } from "node:fs/promises";
13
- import micromatch from "micromatch";
14
- //#region src/runtime-branch/generator-target-env.ts
15
- const explicitGeneratorTargetEnvKeys = ["WEAPP_TW_TARGET", "WEAPP_TAILWINDCSS_TARGET"];
16
- const uniWebPlatformEnvKeys = ["UNI_PLATFORM", "UNI_UTS_PLATFORM"];
17
- const mpxWebPlatformEnvKeys = ["MPX_CLI_MODE", "MPX_CURRENT_TARGET_MODE"];
18
- function getEnvValue(key) {
19
- return typeof process === "undefined" ? void 0 : process.env[key];
20
- }
21
- function normalizeGeneratorTargetValue(value) {
22
- return value === "weapp" || value === "web" ? value : void 0;
23
- }
24
- function isUniWebPlatform(value) {
25
- const normalized = value?.trim().toLowerCase();
26
- return normalized === "h5" || normalized?.startsWith("web") === true;
27
- }
28
- function isUniAppWebViewPlatform(value) {
29
- const normalized = value?.trim().toLowerCase();
30
- return normalized === "app" || normalized === "app-plus";
31
- }
32
- function isUniNativeAppPlatform(value) {
33
- return (value?.trim().toLowerCase())?.startsWith("app-") === true;
34
- }
35
- function isMpxWebPlatform(value) {
36
- return value?.trim().toLowerCase() === "web";
37
- }
38
- function inferGeneratorTargetFromExplicitEnv() {
39
- for (const key of explicitGeneratorTargetEnvKeys) {
40
- const target = normalizeGeneratorTargetValue(getEnvValue(key));
41
- if (target !== void 0) return target;
42
- }
43
- }
44
- function shouldUseWebGeneratorTargetFromEnv() {
45
- return uniWebPlatformEnvKeys.some((key) => isUniWebPlatform(getEnvValue(key))) || isUniAppWebViewPlatform(getEnvValue("UNI_PLATFORM")) && !isUniNativeAppPlatform(getEnvValue("UNI_UTS_PLATFORM")) || mpxWebPlatformEnvKeys.some((key) => isMpxWebPlatform(getEnvValue(key))) || getEnvValue("TARO_ENV") === "h5";
46
- }
47
- function shouldUseUniAppWebRpxCompatibility(appType) {
48
- return appType === "uni-app-vite" || appType === "uni-app-x" || shouldUseWebGeneratorTargetFromEnv();
49
- }
50
- function shouldUseUniAppViteWebViewGeneratorTarget(appType, platform = getEnvValue("UNI_PLATFORM")) {
51
- return appType === "uni-app-vite" && isUniAppWebViewPlatform(platform);
52
- }
53
- function inferGeneratorTargetFromEnv() {
54
- return inferGeneratorTargetFromExplicitEnv() ?? (shouldUseWebGeneratorTargetFromEnv() ? "web" : "weapp");
55
- }
56
- //#endregion
57
- //#region src/tailwindcss/v4-engine/candidates.ts
58
- const UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE = /(?:^|:)(?:has-)?(?:group|peer|in|not-in)-[^\s:]*\/|(?:^|:)(?:has-)?(?:in|not-in)-\[/;
59
- function isUnsupportedMiniProgramTailwindV4Candidate(candidate) {
60
- return UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE.test(candidate);
61
- }
62
- function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
63
- if (!candidates) return;
64
- return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
65
- }
66
- //#endregion
67
- //#region src/tailwindcss/v4-engine/generator/rpx-candidates.ts
68
- const RPX_LENGTH_UTILITY_PATTERN = String.raw`text|border(?:-[trblxyse])?|bg|outline|ring`;
69
- const BARE_RPX_LENGTH_CANDIDATE_RE = new RegExp(String.raw`(^|:)(!?)(${RPX_LENGTH_UTILITY_PATTERN})-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$`, "u");
70
- const BARE_RPX_LENGTH_HINT_CANDIDATE_RE = new RegExp(String.raw`(?:^|:)!?(${RPX_LENGTH_UTILITY_PATTERN})-\[length:([-+]?(?:\d+|\d*\.\d+)rpx)\].*$`, "u");
71
- const RPX_LENGTH_SELECTOR_RE = new RegExp(String.raw`(${RPX_LENGTH_UTILITY_PATTERN})-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]`, "g");
72
- function normalizeRpxLengthCandidate(candidate) {
73
- return candidate.replace(BARE_RPX_LENGTH_CANDIDATE_RE, (_match, prefix, important, utility, value, suffix) => {
74
- return `${prefix}${important}${utility}-[length:${value}]${suffix}`;
75
- });
76
- }
77
- function normalizeRpxLengthCandidates(candidates) {
78
- const normalized = /* @__PURE__ */ new Set();
79
- const restoreCandidates = /* @__PURE__ */ new Map();
80
- for (const candidate of candidates) {
81
- const normalizedCandidate = normalizeRpxLengthCandidate(candidate);
82
- normalized.add(normalizedCandidate);
83
- if (normalizedCandidate !== candidate) restoreCandidates.set(normalizedCandidate, candidate);
84
- }
85
- return {
86
- candidates: normalized,
87
- restoreCandidates
88
- };
89
- }
90
- function restoreRpxLengthCandidates(candidates, restoreCandidates) {
91
- if (restoreCandidates.size === 0) return new Set(candidates);
92
- return new Set([...candidates].map((candidate) => restoreCandidates.get(candidate) ?? candidate));
93
- }
94
- function normalizeCssEscapedRpxSelectorValue(value) {
95
- return value.replace(/\\([.+-])/g, "$1");
96
- }
97
- function restoreRpxLengthCssSelectors(css, restoreCandidates) {
98
- if (restoreCandidates.size === 0 || !css.includes("\\[length\\:")) return css;
99
- const restoredUtilities = new Set([...restoreCandidates.keys()].map((candidate) => {
100
- const match = BARE_RPX_LENGTH_HINT_CANDIDATE_RE.exec(candidate);
101
- return match ? `${match[1]}:${match[2]}` : void 0;
102
- }).filter((value) => Boolean(value)));
103
- return css.replace(RPX_LENGTH_SELECTOR_RE, (match, utility, value) => {
104
- return restoredUtilities.has(`${utility}:${normalizeCssEscapedRpxSelectorValue(value)}`) ? `${utility}-\\[${value}\\]` : match;
105
- });
106
- }
107
- const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX = 12e3;
108
- const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX = 2097152;
109
- const incrementalGenerateCache = new LRUCache({ max: 8 });
110
- const incrementalGenerateTaskCache = new LRUCache({ max: 32 });
111
- function collectCandidates(candidates) {
112
- return new Set(candidates ?? []);
113
- }
114
- function hasRemovedCandidates(previousCandidates, nextCandidates) {
115
- for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
116
- return false;
117
- }
118
- function createStableJson(value) {
119
- if (value === void 0) return "undefined";
120
- if (value === null || typeof value !== "object") return JSON.stringify(value);
121
- if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
122
- return `{${Object.keys(value).sort().map((key) => {
123
- const record = value;
124
- return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
125
- }).join(",")}}`;
126
- }
127
- function createDependencyFingerprint(files) {
128
- return files.map((file) => {
129
- try {
130
- const stat = fs.statSync(file);
131
- return `${file}:${stat.size}:${stat.mtimeMs}`;
132
- } catch {
133
- return `${file}:missing`;
134
- }
135
- }).join("|");
136
- }
137
- function createTailwindV4SourceCacheKey(source) {
138
- return [
139
- source.projectRoot,
140
- source.base,
141
- createStableJson(source.baseFallbacks),
142
- source.css,
143
- createDependencyFingerprint(source.dependencies)
144
- ].join("\0");
145
- }
146
- function createIncrementalGenerateCacheKey(source, target, styleOptions) {
147
- return [
148
- createTailwindV4SourceCacheKey(source),
149
- target,
150
- createStableJson(styleOptions)
151
- ].join("\0");
152
- }
153
- function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
154
- return [
155
- cacheKey,
156
- scanSources === true ? "scan:1" : "scan:0",
157
- [...requestedCandidates].sort().join("\n")
158
- ].join("\0");
159
- }
160
- function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
161
- const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
162
- const cachedTask = incrementalGenerateTaskCache.get(taskKey);
163
- if (cachedTask) return cachedTask;
164
- const promise = task();
165
- incrementalGenerateTaskCache.set(taskKey, promise);
166
- promise.finally(() => {
167
- if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
168
- });
169
- return promise;
170
- }
171
- function createIncrementalDesignSystemPromise(source, cacheKey) {
172
- const promise = loadTailwindV4DesignSystem(source);
173
- promise.catch(() => {
174
- if (incrementalGenerateCache.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache.delete(cacheKey);
175
- });
176
- return promise;
177
- }
178
- function resolveTargetCandidates(candidates, target) {
179
- const collected = collectCandidates(candidates);
180
- return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
181
- }
182
- function collectSeenCandidates(generated) {
183
- return new Set(generated.classSet);
184
- }
185
- function createIncrementalStyleOptions(styleOptions) {
186
- return {
187
- ...styleOptions,
188
- isMainChunk: false
189
- };
190
- }
191
- function resolveStyleOptions(source, options) {
192
- return hasCssMacroTailwindV4Source(source.css) ? withCssMacroStyleOptions(options) : options;
193
- }
194
- function collectCustomPropertyValues(css) {
195
- const values = /* @__PURE__ */ new Map();
196
- try {
197
- postcss.parse(css).walkDecls((decl) => {
198
- if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
199
- });
200
- } catch {}
201
- return values;
202
- }
203
- function mergeCustomPropertyValues(target, css) {
204
- for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
205
- }
206
- function createStableTextSignature(input) {
207
- let hash = 2166136261;
208
- for (let i = 0; i < input.length; i++) {
209
- hash ^= input.charCodeAt(i);
210
- hash = Math.imul(hash, 16777619);
211
- }
212
- return (hash >>> 0).toString(36);
213
- }
214
- function summarizeIncrementalCacheKey(key) {
215
- return {
216
- keyHash: createStableTextSignature(key),
217
- keyBytes: key.length
218
- };
219
- }
220
- function shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates) {
221
- return cached.seenCandidates.size + missingCandidates.length > 12e3 || cached.css.length > 2097152 || cached.rawCss.length > 2097152 || requestedCandidates.size > 12e3;
222
- }
223
- function shouldAdmitIncrementalEntry(requestedCandidates, generated) {
224
- return requestedCandidates.size <= 12e3 && generated.css.length <= 2097152 && generated.rawCss.length <= 2097152;
225
- }
226
- function seedIncrementalGenerateCache(options) {
227
- if (!shouldAdmitIncrementalEntry(options.requestedCandidates, options.generated)) return false;
228
- const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions);
229
- const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
230
- mergeCustomPropertyValues(customPropertyValues, options.generated.css);
231
- incrementalGenerateCache.set(cacheKey, {
232
- seenCandidates: collectSeenCandidates(options.generated),
233
- classSet: new Set(options.generated.classSet),
234
- css: options.generated.css,
235
- rawCss: options.generated.rawCss,
236
- customPropertyValues,
237
- designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
238
- dependencies: options.generated.dependencies,
239
- sources: options.generated.sources,
240
- root: options.generated.root,
241
- target: options.generated.target
242
- });
243
- return true;
244
- }
245
- function shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) {
246
- if (target !== "web") return true;
247
- return shouldUseUniAppWebRpxCompatibility(styleOptions?.appType);
248
- }
249
- function normalizeTargetRpxLengthCandidates(candidates, target, styleOptions) {
250
- return shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) ? normalizeRpxLengthCandidates(candidates) : {
251
- candidates: new Set(candidates),
252
- restoreCandidates: /* @__PURE__ */ new Map()
253
- };
254
- }
255
- //#endregion
256
- //#region src/tailwindcss/v4-engine/generator/cache-stats.ts
257
- function getTailwindV4IncrementalGenerateCacheStats() {
258
- return {
259
- max: 8,
260
- entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX,
261
- entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX,
262
- size: incrementalGenerateCache.size,
263
- taskMax: 32,
264
- taskSize: incrementalGenerateTaskCache.size,
265
- entries: [...incrementalGenerateCache.entries()].map(([key, entry]) => ({
266
- ...summarizeIncrementalCacheKey(key),
267
- candidates: entry.seenCandidates.size,
268
- classSet: entry.classSet.size,
269
- cssBytes: entry.css.length,
270
- rawCssBytes: entry.rawCss.length
271
- })),
272
- keys: [...incrementalGenerateCache.keys()].map(summarizeIncrementalCacheKey),
273
- taskKeys: [...incrementalGenerateTaskCache.keys()].map(summarizeIncrementalCacheKey)
274
- };
275
- }
276
- //#endregion
277
- //#region src/tailwindcss/v4-engine/css-macro-source.ts
278
- function resolveCssMacroTailwindV4Source(source) {
279
- const css = transformCssMacroTailwindV4Source(source.css);
280
- return css === source.css ? source : {
281
- ...source,
282
- css
283
- };
284
- }
285
- //#endregion
286
- //#region src/tailwindcss/v4-engine/miniprogram.ts
287
- const defaultStyleHandler = createStyleHandler({
288
- cssChildCombinatorReplaceValue: ["view", "text"],
289
- cssRemoveActivePseudoClass: true,
290
- cssRemoveHoverPseudoClass: true,
291
- cssRemoveFocusPseudoClass: true,
292
- isMainChunk: true,
293
- majorVersion: 4
294
- });
295
- const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
296
- function normalizeTailwindV4GeneratedUrlValues(css) {
297
- return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
298
- try {
299
- return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
300
- } catch {
301
- return match;
302
- }
303
- });
304
- }
305
- async function transformTailwindV4CssToWeapp(css, options) {
306
- const compatibleCss = normalizeTailwindV4GeneratedUrlValues(hasCssMacroStyleOptions(options) ? await transformCssMacroCss(css, options) : css);
307
- const customPropertyValues = options?.customPropertyValues;
308
- const protectedCss = protectDynamicColorMixAlpha(compatibleCss, { customPropertyValues });
309
- const result = await defaultStyleHandler(protectedCss.css, {
310
- cssChildCombinatorReplaceValue: ["view", "text"],
311
- cssRemoveActivePseudoClass: true,
312
- cssRemoveHoverPseudoClass: true,
313
- cssRemoveFocusPseudoClass: true,
314
- isMainChunk: true,
315
- majorVersion: 4,
316
- ...options
317
- });
318
- const pruneOptions = {
319
- preserveContentInit: options?.uniAppX === true && options.uniAppXCssTarget === "uvue" ? false : void 0,
320
- preservePreflight: true,
321
- preserveConditionalComments: hasCssMacroStyleOptions(options)
322
- };
323
- return pruneMiniProgramGeneratedCss$1(protectedCss.restore(result.css), pruneOptions);
324
- }
325
- function transformTailwindV4WebRpxCss(css) {
326
- if (!css.includes("rpx")) return css;
327
- try {
328
- const root = postcss.parse(css);
329
- return normalizeTailwindcssWebRpxDeclarations(root, { majorVersion: 4 }) ? root.toString() : css;
330
- } catch {
331
- return css;
332
- }
333
- }
334
- async function transformTailwindV4CssByTarget(css, target, options) {
335
- if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
336
- const resolvedWebCss = await (hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css);
337
- return shouldUseUniAppWebRpxCompatibility(options?.appType) ? transformTailwindV4WebRpxCss(resolvedWebCss) : resolvedWebCss;
338
- }
339
- //#endregion
340
- //#region src/tailwindcss/v4-engine/css-import.ts
341
- function parseCssImportSpecifier(params) {
342
- const tokens = tokenize({ css: params }).filter((token) => token[0] !== TokenType.Whitespace && token[0] !== TokenType.Comment);
343
- const first = tokens[0];
344
- if (!first) return;
345
- if (first[0] === TokenType.String || first[0] === TokenType.URL) return {
346
- specifier: first[4].value,
347
- raw: first[1],
348
- quote: first[0] === TokenType.String ? first[1][0] : void 0
349
- };
350
- if (first[0] === TokenType.Function && first[4].value.toLowerCase() === "url" && tokens[1]?.[0] === TokenType.String && tokens[2]?.[0] === TokenType.CloseParen) return {
351
- specifier: tokens[1][4].value,
352
- raw: params.slice(first[2], tokens[2][3] + 1),
353
- quote: tokens[1][1][0]
354
- };
355
- }
356
- function quoteCssImportSpecifier(file, quote = "\"") {
357
- return `${quote}${(path.sep === "\\" || /^[a-z]:[\\/]|^\\\\/i.test(file) ? file.replaceAll("\\", "/") : file).replaceAll("\\", "\\\\").replaceAll(quote, `\\${quote}`).replaceAll("\n", "\\a ").replaceAll("\r", "\\d ")}${quote}`;
358
- }
359
- function isTailwindCssImport(params) {
360
- const specifier = parseCssImportSpecifier(params)?.specifier;
361
- if (!specifier) return false;
362
- if (specifier === "tailwindcss" || specifier.startsWith("tailwindcss/")) return true;
363
- const paths = specifier.includes("\\") ? path.win32 : path.posix;
364
- return paths.basename(specifier) === "index.css" && paths.basename(paths.dirname(specifier)) === "tailwindcss";
365
- }
366
- function parseImportSourceParam(params) {
367
- const tokens = tokenize({ css: params }).filter((token) => token[0] !== TokenType.Whitespace && token[0] !== TokenType.Comment);
368
- const index = tokens.findIndex((token) => token[0] === TokenType.Function && token[4].value === "source");
369
- const value = tokens[index + 1];
370
- if (index < 0 || tokens[index + 2]?.[0] !== TokenType.CloseParen) return;
371
- if (value?.[0] === TokenType.Ident && value[4].value === "none") return {
372
- none: true,
373
- sourcePath: void 0
374
- };
375
- return value?.[0] === TokenType.String ? {
376
- none: false,
377
- sourcePath: value[4].value
378
- } : void 0;
379
- }
380
- //#endregion
381
- //#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
382
- const TAILWIND_V4_COLOR_STEPS = [
383
- "50",
384
- "100",
385
- "200",
386
- "300",
387
- "400",
388
- "500",
389
- "600",
390
- "700",
391
- "800",
392
- "900",
393
- "950"
394
- ];
395
- const TAILWIND_V4_COLOR_PALETTE = {
396
- slate: [
397
- "#f8fafc",
398
- "#f1f5f9",
399
- "#e2e8f0",
400
- "#cad5e2",
401
- "#90a1b9",
402
- "#62748e",
403
- "#45556c",
404
- "#314158",
405
- "#1d293d",
406
- "#0f172b",
407
- "#020618"
408
- ],
409
- gray: [
410
- "#f9fafb",
411
- "#f3f4f6",
412
- "#e5e7eb",
413
- "#d1d5dc",
414
- "#99a1af",
415
- "#6a7282",
416
- "#4a5565",
417
- "#364153",
418
- "#1e2939",
419
- "#101828",
420
- "#030712"
421
- ],
422
- zinc: [
423
- "#fafafa",
424
- "#f4f4f5",
425
- "#e4e4e7",
426
- "#d4d4d8",
427
- "#9f9fa9",
428
- "#71717b",
429
- "#52525c",
430
- "#3f3f46",
431
- "#27272a",
432
- "#18181b",
433
- "#09090b"
434
- ],
435
- neutral: [
436
- "#fafafa",
437
- "#f5f5f5",
438
- "#e5e5e5",
439
- "#d4d4d4",
440
- "#a1a1a1",
441
- "#737373",
442
- "#525252",
443
- "#404040",
444
- "#262626",
445
- "#171717",
446
- "#0a0a0a"
447
- ],
448
- stone: [
449
- "#fafaf9",
450
- "#f5f5f4",
451
- "#e7e5e4",
452
- "#d6d3d1",
453
- "#a6a09b",
454
- "#79716b",
455
- "#57534d",
456
- "#44403b",
457
- "#292524",
458
- "#1c1917",
459
- "#0c0a09"
460
- ],
461
- mauve: [
462
- "#fafafa",
463
- "#f3f1f3",
464
- "#e7e4e7",
465
- "#d7d0d7",
466
- "#a89ea9",
467
- "#79697b",
468
- "#594c5b",
469
- "#463947",
470
- "#2a212c",
471
- "#1d161e",
472
- "#0c090c"
473
- ],
474
- olive: [
475
- "#fbfbf9",
476
- "#f4f4f0",
477
- "#e8e8e3",
478
- "#d8d8d0",
479
- "#abab9c",
480
- "#7c7c67",
481
- "#5b5b4b",
482
- "#474739",
483
- "#2b2b22",
484
- "#1d1d16",
485
- "#0c0c09"
486
- ],
487
- mist: [
488
- "#f9fbfb",
489
- "#f1f3f3",
490
- "#e3e7e8",
491
- "#d0d6d8",
492
- "#9ca8ab",
493
- "#67787c",
494
- "#4b585b",
495
- "#394447",
496
- "#22292b",
497
- "#161b1d",
498
- "#090b0c"
499
- ],
500
- taupe: [
501
- "#fbfaf9",
502
- "#f3f1f1",
503
- "#e8e4e3",
504
- "#d8d2d0",
505
- "#aba09c",
506
- "#7c6d67",
507
- "#5b4f4b",
508
- "#473c39",
509
- "#2b2422",
510
- "#1d1816",
511
- "#0c0a09"
512
- ],
513
- red: [
514
- "#fef2f2",
515
- "#ffe2e2",
516
- "#ffc9c9",
517
- "#ffa2a2",
518
- "#ff6467",
519
- "#fb2c36",
520
- "#e7000b",
521
- "#c10007",
522
- "#9f0712",
523
- "#82181a",
524
- "#460809"
525
- ],
526
- orange: [
527
- "#fff7ed",
528
- "#ffedd4",
529
- "#ffd6a7",
530
- "#ffb86a",
531
- "#ff8904",
532
- "#ff6900",
533
- "#f54900",
534
- "#ca3500",
535
- "#9f2d00",
536
- "#7e2a0c",
537
- "#441306"
538
- ],
539
- amber: [
540
- "#fffbeb",
541
- "#fef3c6",
542
- "#fee685",
543
- "#ffd230",
544
- "#ffb900",
545
- "#fe9a00",
546
- "#e17100",
547
- "#bb4d00",
548
- "#973c00",
549
- "#7b3306",
550
- "#461901"
551
- ],
552
- yellow: [
553
- "#fefce8",
554
- "#fef9c2",
555
- "#fff085",
556
- "#ffdf20",
557
- "#fdc700",
558
- "#f0b100",
559
- "#d08700",
560
- "#a65f00",
561
- "#894b00",
562
- "#733e0a",
563
- "#432004"
564
- ],
565
- lime: [
566
- "#f7fee7",
567
- "#ecfcca",
568
- "#d8f999",
569
- "#bbf451",
570
- "#9ae600",
571
- "#7ccf00",
572
- "#5ea500",
573
- "#497d00",
574
- "#3c6300",
575
- "#35530e",
576
- "#192e03"
577
- ],
578
- green: [
579
- "#f0fdf4",
580
- "#dcfce7",
581
- "#b9f8cf",
582
- "#7bf1a8",
583
- "#05df72",
584
- "#00c950",
585
- "#00a63e",
586
- "#008236",
587
- "#016630",
588
- "#0d542b",
589
- "#032e15"
590
- ],
591
- emerald: [
592
- "#ecfdf5",
593
- "#d0fae5",
594
- "#a4f4cf",
595
- "#5ee9b5",
596
- "#00d492",
597
- "#00bc7d",
598
- "#009966",
599
- "#007a55",
600
- "#006045",
601
- "#004f3b",
602
- "#002c22"
603
- ],
604
- teal: [
605
- "#f0fdfa",
606
- "#cbfbf1",
607
- "#96f7e4",
608
- "#46ecd5",
609
- "#00d5be",
610
- "#00bba7",
611
- "#009689",
612
- "#00786f",
613
- "#005f5a",
614
- "#0b4f4a",
615
- "#022f2e"
616
- ],
617
- cyan: [
618
- "#ecfeff",
619
- "#cefafe",
620
- "#a2f4fd",
621
- "#53eafd",
622
- "#00d3f2",
623
- "#00b8db",
624
- "#0092b8",
625
- "#007595",
626
- "#005f78",
627
- "#104e64",
628
- "#053345"
629
- ],
630
- sky: [
631
- "#f0f9ff",
632
- "#dff2fe",
633
- "#b8e6fe",
634
- "#74d4ff",
635
- "#00bcff",
636
- "#00a6f4",
637
- "#0084d1",
638
- "#0069a8",
639
- "#00598a",
640
- "#024a70",
641
- "#052f4a"
642
- ],
643
- blue: [
644
- "#eff6ff",
645
- "#dbeafe",
646
- "#bedbff",
647
- "#8ec5ff",
648
- "#51a2ff",
649
- "#2b7fff",
650
- "#155dfc",
651
- "#1447e6",
652
- "#193cb8",
653
- "#1c398e",
654
- "#162456"
655
- ],
656
- indigo: [
657
- "#eef2ff",
658
- "#e0e7ff",
659
- "#c6d2ff",
660
- "#a3b3ff",
661
- "#7c86ff",
662
- "#615fff",
663
- "#4f39f6",
664
- "#432dd7",
665
- "#372aac",
666
- "#312c85",
667
- "#1e1a4d"
668
- ],
669
- violet: [
670
- "#f5f3ff",
671
- "#ede9fe",
672
- "#ddd6ff",
673
- "#c4b4ff",
674
- "#a684ff",
675
- "#8e51ff",
676
- "#7f22fe",
677
- "#7008e7",
678
- "#5d0ec0",
679
- "#4d179a",
680
- "#2f0d68"
681
- ],
682
- purple: [
683
- "#faf5ff",
684
- "#f3e8ff",
685
- "#e9d4ff",
686
- "#dab2ff",
687
- "#c27aff",
688
- "#ad46ff",
689
- "#9810fa",
690
- "#8200db",
691
- "#6e11b0",
692
- "#59168b",
693
- "#3c0366"
694
- ],
695
- fuchsia: [
696
- "#fdf4ff",
697
- "#fae8ff",
698
- "#f6cfff",
699
- "#f4a8ff",
700
- "#ed6aff",
701
- "#e12afb",
702
- "#c800de",
703
- "#a800b7",
704
- "#8a0194",
705
- "#721378",
706
- "#4b004f"
707
- ],
708
- pink: [
709
- "#fdf2f8",
710
- "#fce7f3",
711
- "#fccee8",
712
- "#fda5d5",
713
- "#fb64b6",
714
- "#f6339a",
715
- "#e60076",
716
- "#c6005c",
717
- "#a3004c",
718
- "#861043",
719
- "#510424"
720
- ],
721
- rose: [
722
- "#fff1f2",
723
- "#ffe4e6",
724
- "#ffccd3",
725
- "#ffa1ad",
726
- "#ff637e",
727
- "#ff2056",
728
- "#ec003f",
729
- "#c70036",
730
- "#a50036",
731
- "#8b0836",
732
- "#4d0218"
733
- ]
734
- };
735
- function createTailwindV4DefaultColorThemeCss() {
736
- const declarations = [" --color-black: #000;", " --color-white: #fff;"];
737
- for (const [color, values] of Object.entries(TAILWIND_V4_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V4_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V4_COLOR_STEPS[index]}: ${values[index]};`);
738
- return [
739
- "@theme {",
740
- ...declarations,
741
- "}"
742
- ].join("\n");
743
- }
744
- //#endregion
745
- //#region src/tailwindcss/v4-engine/generator/css-compat.ts
746
- const require$1 = createRequire(import.meta.url);
747
- const tailwindThemeCssCache = /* @__PURE__ */ new Map();
748
- function findLeadingImportInsertionIndex(css) {
749
- const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
750
- let insertionIndex = 0;
751
- let match = importPattern.exec(css);
752
- while (match !== null) {
753
- insertionIndex = match.index + match[0].length;
754
- match = importPattern.exec(css);
755
- }
756
- return insertionIndex;
757
- }
758
- function readCachedCss(file) {
759
- const cached = tailwindThemeCssCache.get(file);
760
- if (cached !== void 0) return cached;
761
- const css = readFileSync(file, "utf8");
762
- tailwindThemeCssCache.set(file, css);
763
- return css;
764
- }
765
- function resolveTailwindV4ThemeCssFromImport(css) {
766
- const root = postcss.parse(css);
767
- let resolved;
768
- root.walkAtRules("import", (rule) => {
769
- if (resolved) return;
770
- const specifier = parseCssImportSpecifier(rule.params)?.specifier;
771
- if (!specifier || !path.isAbsolute(specifier) || path.basename(specifier) !== "index.css") return;
772
- const themeCss = path.join(path.dirname(specifier), "theme.css");
773
- if (existsSync(themeCss)) resolved = themeCss;
774
- });
775
- return resolved;
776
- }
777
- function resolveTailwindV4ThemeCssFromBase(base) {
778
- try {
779
- return createRequire(path.join(base, "package.json")).resolve("tailwindcss/theme.css");
780
- } catch {
781
- try {
782
- return require$1.resolve("tailwindcss/theme.css");
783
- } catch {
784
- return;
785
- }
786
- }
787
- }
788
- function resolveTailwindV4DefaultThemeCss(source) {
789
- try {
790
- const themeCss = resolveTailwindV4ThemeCssFromImport(source.css) ?? resolveTailwindV4ThemeCssFromBase(source.base);
791
- return themeCss ? readCachedCss(themeCss) : createTailwindV4DefaultColorThemeCss();
792
- } catch {
793
- return createTailwindV4DefaultColorThemeCss();
794
- }
795
- }
796
- function applyMiniProgramTailwindV4DefaultColorCss(css, source) {
797
- const themeCss = resolveTailwindV4DefaultThemeCss(source);
798
- const insertionIndex = findLeadingImportInsertionIndex(css);
799
- if (insertionIndex === 0) return `${themeCss}\n${css}`;
800
- return `${css.slice(0, insertionIndex)}\n${themeCss}\n${css.slice(insertionIndex)}`;
801
- }
802
- function isTailwindCssPreflightImport(params) {
803
- const specifier = parseCssImportSpecifier(params)?.specifier;
804
- return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
805
- }
806
- function removeTailwindV4PreflightImports(css) {
807
- if (!css.includes("preflight")) return css;
808
- let root;
809
- try {
810
- root = postcss.parse(css);
811
- } catch {
812
- return css;
813
- }
814
- let changed = false;
815
- root.walkAtRules("import", (rule) => {
816
- if (isTailwindCssPreflightImport(rule.params)) {
817
- rule.remove();
818
- changed = true;
819
- }
820
- });
821
- return changed ? root.toString() : css;
822
- }
823
- function hasThemeParent(rule) {
824
- let parent = rule.parent;
825
- while (parent) {
826
- if (parent.type === "atrule" && parent.name === "theme") return true;
827
- parent = parent.parent;
828
- }
829
- return false;
830
- }
831
- function isVendorPrefixedKeyframes(rule) {
832
- return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
833
- }
834
- function removeUnsupportedThemeVendorKeyframes(css) {
835
- if (!css.includes("@theme") || !css.includes("@-")) return css;
836
- let root;
837
- try {
838
- root = postcss.parse(css);
839
- } catch {
840
- return css;
841
- }
842
- let changed = false;
843
- root.walkAtRules((rule) => {
844
- if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
845
- rule.remove();
846
- changed = true;
847
- }
848
- });
849
- return changed ? root.toString() : css;
850
- }
851
- function createCompatibleSource(source, target) {
852
- const filteredSourceCss = target === "weapp" ? removeTailwindV4PreflightImports(source.css) : source.css;
853
- const compatibleSourceCss = removeUnsupportedThemeVendorKeyframes(target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(filteredSourceCss, source) : filteredSourceCss);
854
- return compatibleSourceCss === source.css ? source : {
855
- ...source,
856
- css: compatibleSourceCss
857
- };
858
- }
859
- //#endregion
860
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/typeof.js
861
- function _typeof(o) {
862
- "@babel/helpers - typeof";
863
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
864
- return typeof o;
865
- } : function(o) {
866
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
867
- }, _typeof(o);
868
- }
869
- //#endregion
870
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/toPrimitive.js
871
- function toPrimitive(t, r) {
872
- if ("object" != _typeof(t) || !t) return t;
873
- var e = t[Symbol.toPrimitive];
874
- if (void 0 !== e) {
875
- var i = e.call(t, r || "default");
876
- if ("object" != _typeof(i)) return i;
877
- throw new TypeError("@@toPrimitive must return a primitive value.");
878
- }
879
- return ("string" === r ? String : Number)(t);
880
- }
881
- //#endregion
882
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/toPropertyKey.js
883
- function toPropertyKey(t) {
884
- var i = toPrimitive(t, "string");
885
- return "symbol" == _typeof(i) ? i : i + "";
886
- }
887
- //#endregion
888
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/defineProperty.js
889
- function _defineProperty(e, r, t) {
890
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
891
- value: t,
892
- enumerable: !0,
893
- configurable: !0,
894
- writable: !0
895
- }) : e[r] = t, e;
896
- }
897
- //#endregion
898
- //#region src/tailwindcss/v4-engine/generator/native-session.ts
899
- var TailwindV4NativeSessionPool = class {
900
- constructor(createSession = createTailwindGenerationSession) {
901
- this.createSession = createSession;
902
- _defineProperty(this, "sessions", /* @__PURE__ */ new Map());
903
- _defineProperty(this, "disposed", false);
904
- }
905
- generate(target, sourceKey, source, request) {
906
- const entry = this.getSession(target, sourceKey, source);
907
- const generated = entry.pending.then(() => entry.session.generate(request));
908
- entry.pending = generated.then(() => void 0, () => void 0);
909
- return generated;
910
- }
911
- dispose() {
912
- for (const entry of this.sessions.values()) this.disposeEntry(entry);
913
- this.sessions.clear();
914
- this.disposed = true;
915
- }
916
- get size() {
917
- return this.sessions.size;
918
- }
919
- getSession(target, sourceKey, source) {
920
- if (this.disposed) throw new Error("TailwindV4NativeSessionPool 已释放。");
921
- const cached = this.sessions.get(target);
922
- if (cached?.sourceKey === sourceKey) return cached;
923
- if (cached) this.disposeEntry(cached);
924
- const session = this.createSession(source);
925
- const entry = {
926
- pending: Promise.resolve(),
927
- session,
928
- sourceKey
929
- };
930
- this.sessions.set(target, entry);
931
- return entry;
932
- }
933
- disposeEntry(entry) {
934
- entry.pending.then(() => entry.session.dispose());
935
- }
936
- };
937
- function createEngineSourceEntries(sources, sourceId) {
938
- return sources.map((source, index) => ({
939
- id: `${sourceId}:candidate-source:${index}`,
940
- ...source
941
- }));
942
- }
943
- function serializeTailwindGenerationArtifact(artifact) {
944
- return [...artifact.fragments].sort((left, right) => left.order - right.order).map((fragment) => fragment.root.toString()).join("\n");
945
- }
946
- //#endregion
947
- //#region src/tailwindcss/source-scan.ts
948
- const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
949
- "html",
950
- "wxml",
951
- "axml",
952
- "jxml",
953
- "ksml",
954
- "ttml",
955
- "qml",
956
- "qxml",
957
- "tyml",
958
- "xhsml",
959
- "swan",
960
- "vue",
961
- "mpx",
962
- "js",
963
- "jsx",
964
- "ts",
965
- "tsx"
966
- ];
967
- const FULL_SOURCE_SCAN_EXTENSIONS = [
968
- "js",
969
- "jsx",
970
- "mjs",
971
- "cjs",
972
- "ts",
973
- "tsx",
974
- "mts",
975
- "cts",
976
- "vue",
977
- "uvue",
978
- "nvue",
979
- "svelte",
980
- "mpx",
981
- "html",
982
- "wxml",
983
- "axml",
984
- "jxml",
985
- "ksml",
986
- "ttml",
987
- "qml",
988
- "qxml",
989
- "tyml",
990
- "xhsml",
991
- "swan",
992
- "css",
993
- "wxss",
994
- "acss",
995
- "jxss",
996
- "ttss",
997
- "qss",
998
- "tyss",
999
- "scss",
1000
- "sass",
1001
- "less",
1002
- "styl",
1003
- "stylus"
1004
- ];
1005
- function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
1006
- return `**/*.{${extensions.join(",")}}`;
1007
- }
1008
- const FULL_SOURCE_SCAN_PATTERN = createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
1009
- const FULL_SOURCE_SCAN_EXTENSION_RE = new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
1010
- function toPosixPath(value) {
1011
- return value.split(path.sep).join("/").split(path.win32.sep).join("/");
1012
- }
1013
- function resolveSourceScanPath(value) {
1014
- return resolveSourceScanPathWithApi(value, path);
1015
- }
1016
- function resolveSourceScanPathWithApi(value, pathApi) {
1017
- const resolved = pathApi.resolve(value);
1018
- let current = resolved;
1019
- const missing = [];
1020
- while (true) try {
1021
- return pathApi.join(realpathSync.native(current), ...missing.reverse());
1022
- } catch (error) {
1023
- const parent = pathApi.dirname(current);
1024
- if (error.code !== "ENOENT" || parent === current) return resolved;
1025
- missing.push(pathApi.basename(current));
1026
- current = parent;
1027
- }
1028
- }
1029
- function normalizeEntryPattern(entry) {
1030
- const pathApi = isWindowsPath(entry.base) || isWindowsPath(entry.pattern) ? path.win32 : path;
1031
- return pathApi.isAbsolute(entry.pattern) ? toPosixPath(pathApi.relative(pathApi.resolve(entry.base), entry.pattern)) : entry.pattern;
1032
- }
1033
- function isFileMatchedByTailwindSourceEntry(file, entry) {
1034
- const pathApi = isWindowsPath(entry.base) || isWindowsPath(file) ? path.win32 : path;
1035
- const base = resolveSourceScanPathWithApi(entry.base, pathApi);
1036
- const relative = toPosixPath(pathApi.relative(base, file));
1037
- return relative && !relative.startsWith("../") && !pathApi.isAbsolute(relative) && micromatch.isMatch(relative, normalizeEntryPattern(entry));
1038
- }
1039
- function isWindowsPath(value) {
1040
- return /^[A-Z]:[\\/]/i.test(value) || value.includes("\\");
1041
- }
1042
- function isFileExcludedByTailwindSourceEntries(file, entries) {
1043
- if (!entries?.length) return false;
1044
- const resolvedFile = resolveSourceScanMatcherFile(file, entries);
1045
- return entries.some((entry) => entry.negated && isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
1046
- }
1047
- function isFileMatchedByTailwindSourceEntries(file, entries) {
1048
- if (!entries?.length) return true;
1049
- const resolvedFile = resolveSourceScanMatcherFile(file, entries);
1050
- const positiveEntries = entries.filter((entry) => !entry.negated);
1051
- const negativeEntries = entries.filter((entry) => entry.negated);
1052
- if (positiveEntries.length === 0) return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
1053
- if (!positiveEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry))) return false;
1054
- return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
1055
- }
1056
- function resolveSourceScanMatcherFile(file, entries) {
1057
- return isWindowsPath(file) || entries.some((entry) => isWindowsPath(entry.base) || isWindowsPath(entry.pattern)) ? resolveSourceScanPathWithApi(file, path.win32) : resolveSourceScanPath(file);
1058
- }
1059
- function resolveTailwindV4CssSourceBase(source, fallbackBase) {
1060
- if (typeof source.base === "string" && source.base.length > 0) return source.base;
1061
- if (typeof source.file === "string" && source.file.length > 0) return path.dirname(source.file);
1062
- return fallbackBase;
1063
- }
1064
- function parseConfigParam(params) {
1065
- const value = params.trim();
1066
- return /^(['"])(.+)\1$/.exec(value)?.[2];
1067
- }
1068
- function isLegacyContentObject(value) {
1069
- return typeof value === "object" && value !== null && "files" in value;
1070
- }
1071
- function normalizeGlobPattern(pattern) {
1072
- return pattern.startsWith("./") ? pattern.slice(2) : pattern;
1073
- }
1074
- function hasGlobMagic(value) {
1075
- return /[*?[\]{}()!+@]/.test(value);
1076
- }
1077
- function splitStaticGlobPrefix(pattern) {
1078
- const segments = normalizeGlobPattern(pattern).split(/[\\/]+/);
1079
- const prefix = [];
1080
- const rest = [];
1081
- let reachedGlob = false;
1082
- for (const segment of segments) {
1083
- if (!reachedGlob && segment && !hasGlobMagic(segment)) {
1084
- prefix.push(segment);
1085
- continue;
1086
- }
1087
- reachedGlob = true;
1088
- rest.push(segment);
1089
- }
1090
- return {
1091
- prefix,
1092
- rest
1093
- };
1094
- }
1095
- function normalizeLegacyContentEntries(content, base, options = {}) {
1096
- if (typeof content === "string") {
1097
- const negated = content.startsWith("!");
1098
- return [{
1099
- base,
1100
- negated,
1101
- pattern: normalizeGlobPattern(negated ? content.slice(1) : content)
1102
- }];
1103
- }
1104
- if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base, options));
1105
- if (isLegacyContentObject(content)) return normalizeLegacyContentEntries(content.files, content.relative && options.relativeBase ? options.relativeBase : base, options);
1106
- return [];
1107
- }
1108
- async function pathExistsAsDirectory(file) {
1109
- try {
1110
- return (await stat(file)).isDirectory();
1111
- } catch {
1112
- return false;
1113
- }
1114
- }
1115
- async function resolveTailwindSourceEntry(sourcePath, base, negated, defaultPattern = createSourceScanPattern()) {
1116
- const absoluteSource = path.isAbsolute(sourcePath) ? path.resolve(sourcePath) : path.resolve(base, sourcePath);
1117
- if (await pathExistsAsDirectory(absoluteSource)) return {
1118
- base: absoluteSource,
1119
- negated,
1120
- pattern: normalizeGlobPattern(defaultPattern)
1121
- };
1122
- if (path.isAbsolute(sourcePath) && hasGlobMagic(sourcePath)) {
1123
- const { prefix, rest } = splitStaticGlobPrefix(sourcePath);
1124
- const root = path.parse(sourcePath).root;
1125
- const normalizedPrefix = prefix[0] === "" ? prefix.slice(1) : prefix;
1126
- if (rest.length > 0) return {
1127
- base: path.resolve(root, ...normalizedPrefix),
1128
- negated,
1129
- pattern: normalizeGlobPattern(rest.join("/"))
1130
- };
1131
- }
1132
- if (path.isAbsolute(sourcePath)) return {
1133
- base: path.dirname(absoluteSource),
1134
- negated,
1135
- pattern: normalizeGlobPattern(path.basename(absoluteSource))
1136
- };
1137
- const { prefix, rest } = splitStaticGlobPrefix(sourcePath);
1138
- if (prefix.length > 0 && rest.length > 0) return {
1139
- base: path.resolve(base, ...prefix),
1140
- negated,
1141
- pattern: normalizeGlobPattern(rest.join("/"))
1142
- };
1143
- return {
1144
- base,
1145
- negated,
1146
- pattern: normalizeGlobPattern(sourcePath)
1147
- };
1148
- }
1149
- function parseSourceFileParam(params) {
1150
- const value = params.trim();
1151
- if (!value || value === "none" || value.startsWith("inline(")) return;
1152
- const negated = value.startsWith("not ");
1153
- const sourceValue = negated ? value.slice(4).trim() : value;
1154
- if (sourceValue.startsWith("inline(")) return;
1155
- const match = /^(['"])(.+)\1$/.exec(sourceValue);
1156
- return match?.[2] ? {
1157
- negated,
1158
- sourcePath: match[2]
1159
- } : void 0;
1160
- }
1161
- async function resolveCssSourceEntries(root, base, defaultPattern = createSourceScanPattern()) {
1162
- const entries = [];
1163
- const tasks = [];
1164
- root.walkAtRules("source", (rule) => {
1165
- const parsed = parseSourceFileParam(rule.params);
1166
- if (!parsed) return;
1167
- tasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated, defaultPattern));
1168
- });
1169
- entries.push(...await Promise.all(tasks));
1170
- return entries;
1171
- }
1172
- async function expandTailwindSourceEntries(entries, options = {}) {
1173
- if (entries.length === 0) return [];
1174
- const files = /* @__PURE__ */ new Set();
1175
- const entriesByBase = /* @__PURE__ */ new Map();
1176
- for (const entry of entries) {
1177
- const base = path.resolve(entry.base);
1178
- const group = entriesByBase.get(base) ?? [];
1179
- group.push({
1180
- ...entry,
1181
- base
1182
- });
1183
- entriesByBase.set(base, group);
1184
- }
1185
- await Promise.all([...entriesByBase.entries()].map(async ([base, group]) => {
1186
- const ignoredSources = options.ignore?.map((pattern) => ({
1187
- base,
1188
- pattern: normalizeGlobPattern(pattern),
1189
- negated: true
1190
- }));
1191
- const matched = await resolveProjectSourceFiles({
1192
- cwd: base,
1193
- sources: group,
1194
- ...ignoredSources === void 0 ? {} : { ignoredSources }
1195
- });
1196
- for (const file of matched) files.add(path.resolve(file));
1197
- }));
1198
- return [...files].filter((file) => !isFileExcludedByTailwindSourceEntries(file, entries));
1199
- }
1200
- //#endregion
1201
- //#region src/tailwindcss/v4-engine/generator/scan-sources.ts
1202
- const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
1203
- "**/.git/**",
1204
- "**/.hg/**",
1205
- "**/.jj/**",
1206
- "**/.next/**",
1207
- "**/.parcel-cache/**",
1208
- "**/.pnpm-store/**",
1209
- "**/.svelte-kit/**",
1210
- "**/.svn/**",
1211
- "**/.turbo/**",
1212
- "**/.venv/**",
1213
- "**/.vercel/**",
1214
- "**/.yarn/**",
1215
- "**/__pycache__/**",
1216
- "**/node_modules/**",
1217
- "**/venv/**",
1218
- "**/*.less",
1219
- "**/*.lock",
1220
- "**/*.sass",
1221
- "**/*.scss",
1222
- "**/*.styl",
1223
- "**/*.log",
1224
- "**/tailwind.config.js",
1225
- "**/tailwind.config.cjs",
1226
- "**/tailwind.config.mjs",
1227
- "**/tailwind.config.ts",
1228
- "**/tailwind.config.cts",
1229
- "**/tailwind.config.mts",
1230
- "**/tailwind.config.*.js",
1231
- "**/tailwind.config.*.cjs",
1232
- "**/tailwind.config.*.mjs",
1233
- "**/tailwind.config.*.ts",
1234
- "**/tailwind.config.*.cts",
1235
- "**/tailwind.config.*.mts",
1236
- "**/package-lock.json",
1237
- "**/pnpm-lock.yaml",
1238
- "**/bun.lockb",
1239
- "**/.gitignore",
1240
- "**/.env",
1241
- "**/.env.*"
1242
- ];
1243
- function resolveSourceBase(base, sourcePath) {
1244
- return path.isAbsolute(sourcePath) ? sourcePath : path.resolve(base, sourcePath);
1245
- }
1246
- function createDefaultIgnoredScanSources(base) {
1247
- return TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS.map((pattern) => ({
1248
- base,
1249
- pattern,
1250
- negated: true
1251
- }));
1252
- }
1253
- function normalizeCssDefinedScanSources(base, entries) {
1254
- return entries.length > 0 && entries.every((entry) => entry.negated) ? [{
1255
- base,
1256
- pattern: "**/*",
1257
- negated: false
1258
- }, ...entries] : entries;
1259
- }
1260
- function resolveDefaultSourceBase(source) {
1261
- return source.projectRoot ?? source.cwd ?? source.base;
1262
- }
1263
- async function resolveCssDefinedScanSources(source) {
1264
- let importSourceBase;
1265
- let hasSourceNone = false;
1266
- let hasTailwindImport = false;
1267
- const sourcePatterns = [];
1268
- const definitions = [{
1269
- css: source.css,
1270
- base: source.base,
1271
- from: source.dependencies[0]
1272
- }];
1273
- for (const dependency of source.dependencies.slice(1)) {
1274
- if (!existsSync(dependency)) continue;
1275
- try {
1276
- definitions.push({
1277
- css: readFileSync(dependency, "utf8"),
1278
- base: path.dirname(dependency),
1279
- from: dependency
1280
- });
1281
- } catch {}
1282
- }
1283
- for (const definition of definitions) {
1284
- let root;
1285
- try {
1286
- root = postcss.parse(definition.css, { from: definition.from });
1287
- } catch {
1288
- continue;
1289
- }
1290
- root.walkAtRules((rule) => {
1291
- if (rule.name !== "import" || !isTailwindCssImport(rule.params)) return;
1292
- hasTailwindImport = true;
1293
- const sourceParam = parseImportSourceParam(rule.params);
1294
- if (sourceParam?.none) hasSourceNone = true;
1295
- if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(definition.base, sourceParam.sourcePath);
1296
- });
1297
- sourcePatterns.push(...await resolveCssSourceEntries(root, definition.base, "**/*"));
1298
- }
1299
- if (!importSourceBase) {
1300
- if (sourcePatterns.length > 0) return [...normalizeCssDefinedScanSources(source.base, sourcePatterns), ...createDefaultIgnoredScanSources(source.base)];
1301
- if (hasSourceNone) return false;
1302
- if (hasTailwindImport) {
1303
- const defaultBase = resolveDefaultSourceBase(source);
1304
- return [await resolveTailwindSourceEntry(".", defaultBase, false, "**/*"), ...createDefaultIgnoredScanSources(defaultBase)];
1305
- }
1306
- return;
1307
- }
1308
- return [
1309
- await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"),
1310
- ...sourcePatterns,
1311
- ...createDefaultIgnoredScanSources(importSourceBase)
1312
- ];
1313
- }
1314
- async function resolveScanSources(source, scanSources) {
1315
- if (scanSources !== true) return scanSources;
1316
- return await resolveCssDefinedScanSources(source) ?? false;
1317
- }
1318
- function resolveCompiledSourceRoot(source) {
1319
- let root = null;
1320
- try {
1321
- postcss.parse(source.css).walkAtRules("import", (rule) => {
1322
- if (!isTailwindCssImport(rule.params)) return;
1323
- const sourceParam = parseImportSourceParam(rule.params);
1324
- if (sourceParam?.none) {
1325
- root = "none";
1326
- return false;
1327
- }
1328
- if (sourceParam?.sourcePath) {
1329
- root = {
1330
- base: source.base,
1331
- pattern: sourceParam.sourcePath
1332
- };
1333
- return false;
1334
- }
1335
- });
1336
- } catch {}
1337
- return root;
1338
- }
1339
- //#endregion
1340
- //#region src/tailwindcss/v4-engine/generator/style-context.ts
1341
- function resolveGenerationStyleContext(sourceCss, generatedCss, options) {
1342
- const calc = options?.cssOptions?.cssCalc ?? options?.cssCalc;
1343
- const include = Array.isArray(calc) ? calc : calc && typeof calc === "object" ? calc.includeCustomProperties : void 0;
1344
- if (calc !== true && !include?.length) return options;
1345
- const customPropertyValues = collectCustomPropertyValues(sourceCss);
1346
- mergeCustomPropertyValues(customPropertyValues, generatedCss);
1347
- for (const [name, value] of options?.customPropertyValues ?? []) customPropertyValues.set(name, value);
1348
- return {
1349
- ...options,
1350
- customPropertyValues
1351
- };
1352
- }
1353
- //#endregion
1354
- //#region src/tailwindcss/v4-engine/generator/engine.ts
1355
- function isCssSyntaxError(error) {
1356
- return error instanceof Error && error.name === "CssSyntaxError";
1357
- }
1358
- function createTailwindV4Engine$1(source) {
1359
- const generationSessions = new TailwindV4NativeSessionPool();
1360
- const incrementalCacheKeys = /* @__PURE__ */ new Set();
1361
- const validationEngine = createTailwindV4Engine(source);
1362
- async function generateOnce(generateSource, options = {}) {
1363
- const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
1364
- const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
1365
- const compatibleSource = createCompatibleSource(resolveCssMacroTailwindV4Source(generateSource), target);
1366
- const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
1367
- const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await extractRawCandidates(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
1368
- const normalizedCandidates = normalizeTargetRpxLengthCandidates(resolveTargetCandidates(/* @__PURE__ */ new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target), target, resolvedStyleOptions);
1369
- const sourceId = compatibleSource.dependencies[0] ?? compatibleSource.base;
1370
- const generationRequest = {
1371
- ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues },
1372
- ...patchOptions.sources === void 0 ? {} : { sourceEntries: createEngineSourceEntries(patchOptions.sources, sourceId) },
1373
- candidates: normalizedCandidates.candidates
1374
- };
1375
- let generatedCss;
1376
- let classSet;
1377
- let rawCandidates;
1378
- let dependencies;
1379
- try {
1380
- const artifact = await generationSessions.generate(target, createTailwindV4SourceCacheKey(compatibleSource), compatibleSource, generationRequest);
1381
- generatedCss = serializeTailwindGenerationArtifact(artifact);
1382
- classSet = artifact.classSet;
1383
- rawCandidates = artifact.rawCandidates;
1384
- dependencies = artifact.dependencies;
1385
- } catch (error) {
1386
- if (!isCssSyntaxError(error)) throw error;
1387
- const legacyResult = await createTailwindV4Engine(compatibleSource).generate({
1388
- ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues },
1389
- ...patchOptions.sources === void 0 ? {} : { sources: patchOptions.sources },
1390
- candidates: normalizedCandidates.candidates,
1391
- scanSources: false
1392
- });
1393
- generatedCss = legacyResult.css;
1394
- classSet = legacyResult.classSet;
1395
- rawCandidates = legacyResult.rawCandidates;
1396
- dependencies = legacyResult.dependencies;
1397
- }
1398
- const sources = Array.isArray(resolvedScanSources) ? resolvedScanSources : [];
1399
- const rawCss = restoreRpxLengthCssSelectors(generatedCss, normalizedCandidates.restoreCandidates);
1400
- const css = await transformTailwindV4CssByTarget(rawCss, target, resolveGenerationStyleContext(compatibleSource.css, rawCss, resolvedStyleOptions));
1401
- return {
1402
- classSet: restoreRpxLengthCandidates(classSet, normalizedCandidates.restoreCandidates),
1403
- rawCandidates: restoreRpxLengthCandidates(rawCandidates, normalizedCandidates.restoreCandidates),
1404
- dependencies,
1405
- root: resolveCompiledSourceRoot(compatibleSource),
1406
- sources,
1407
- css,
1408
- rawCss,
1409
- target
1410
- };
1411
- }
1412
- async function generateWithIncrementalCache(options = {}) {
1413
- const target = options.target ?? "weapp";
1414
- const cssMacroSource = resolveCssMacroTailwindV4Source(source);
1415
- const compatibleSource = createCompatibleSource(cssMacroSource, target);
1416
- const requestedCandidates = resolveTargetCandidates(options.candidates, target);
1417
- const styleOptions = resolveStyleOptions(source, options.styleOptions);
1418
- if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(cssMacroSource, options);
1419
- const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions);
1420
- incrementalCacheKeys.add(cacheKey);
1421
- if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1422
- const generated = await generateOnce(cssMacroSource, options);
1423
- if (!seedIncrementalGenerateCache({
1424
- compatibleSource,
1425
- generated,
1426
- requestedCandidates,
1427
- styleOptions,
1428
- target
1429
- })) incrementalGenerateCache.delete(cacheKey);
1430
- return generated;
1431
- });
1432
- const cached = incrementalGenerateCache.get(cacheKey);
1433
- if (cached) {
1434
- if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1435
- const generated = await generateOnce(cssMacroSource, options);
1436
- if (!seedIncrementalGenerateCache({
1437
- compatibleSource,
1438
- generated,
1439
- requestedCandidates,
1440
- styleOptions,
1441
- target
1442
- })) incrementalGenerateCache.delete(cacheKey);
1443
- return generated;
1444
- });
1445
- const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
1446
- if (missingCandidates.length === 0) return {
1447
- css: cached.css,
1448
- rawCss: cached.rawCss,
1449
- incrementalCss: "",
1450
- incrementalRawCss: "",
1451
- classSet: new Set(cached.classSet),
1452
- rawCandidates: new Set(cached.seenCandidates),
1453
- dependencies: cached.dependencies,
1454
- sources: cached.sources,
1455
- root: cached.root,
1456
- target: cached.target
1457
- };
1458
- if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1459
- const generated = await generateOnce(cssMacroSource, options);
1460
- if (!seedIncrementalGenerateCache({
1461
- compatibleSource,
1462
- generated,
1463
- requestedCandidates,
1464
- styleOptions,
1465
- target
1466
- })) incrementalGenerateCache.delete(cacheKey);
1467
- return generated;
1468
- });
1469
- return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1470
- const designSystem = await cached.designSystemPromise;
1471
- const normalizedMissing = normalizeTargetRpxLengthCandidates(missingCandidates, target, styleOptions);
1472
- const normalizedMissingCandidates = [...normalizedMissing.candidates];
1473
- const cssByCandidate = designSystem.candidatesToCss(normalizedMissingCandidates);
1474
- const rawCssParts = [];
1475
- const classSet = /* @__PURE__ */ new Set();
1476
- for (let index = 0; index < normalizedMissingCandidates.length; index += 1) {
1477
- const candidate = normalizedMissingCandidates[index];
1478
- const css = cssByCandidate[index];
1479
- if (candidate && typeof css === "string" && css.trim().length > 0) {
1480
- rawCssParts.push(restoreRpxLengthCssSelectors(css, normalizedMissing.restoreCandidates));
1481
- classSet.add(normalizedMissing.restoreCandidates.get(candidate) ?? candidate);
1482
- }
1483
- }
1484
- const rawCss = rawCssParts.join("\n");
1485
- const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
1486
- ...createIncrementalStyleOptions(styleOptions),
1487
- customPropertyValues: cached.customPropertyValues
1488
- }) : "";
1489
- for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
1490
- for (const className of classSet) cached.classSet.add(className);
1491
- cached.css = [cached.css, incrementalCss].filter(Boolean).join("\n");
1492
- cached.rawCss = [cached.rawCss, rawCss].filter(Boolean).join("\n");
1493
- mergeCustomPropertyValues(cached.customPropertyValues, incrementalCss);
1494
- return {
1495
- css: cached.css,
1496
- rawCss: cached.rawCss,
1497
- incrementalCss,
1498
- incrementalRawCss: rawCss,
1499
- classSet: new Set(cached.classSet),
1500
- rawCandidates: new Set(cached.seenCandidates),
1501
- dependencies: cached.dependencies,
1502
- sources: cached.sources,
1503
- root: cached.root,
1504
- target: cached.target
1505
- };
1506
- });
1507
- }
1508
- return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1509
- const generated = await generateOnce(cssMacroSource, options);
1510
- seedIncrementalGenerateCache({
1511
- compatibleSource,
1512
- generated,
1513
- requestedCandidates,
1514
- styleOptions,
1515
- target
1516
- });
1517
- return generated;
1518
- });
1519
- }
1520
- async function generate(options = {}) {
1521
- return options.incrementalCache ? generateWithIncrementalCache(options) : generateOnce(source, options);
1522
- }
1523
- return {
1524
- source,
1525
- loadDesignSystem: validationEngine.loadDesignSystem,
1526
- validateCandidates: validationEngine.validateCandidates,
1527
- generate,
1528
- dispose() {
1529
- generationSessions.dispose();
1530
- for (const cacheKey of incrementalCacheKeys) incrementalGenerateCache.delete(cacheKey);
1531
- incrementalCacheKeys.clear();
1532
- }
1533
- };
1534
- }
1535
- //#endregion
1536
- //#region src/bundlers/shared/generator-css/config-directive.ts
1537
- function quoteCssString(value) {
1538
- return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
1539
- }
1540
- function toCssPath(value) {
1541
- return value.replaceAll("\\", "/");
1542
- }
1543
- function prependConfigDirective(css, config) {
1544
- if (!config || /@config\s+/.test(css)) return css;
1545
- return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
1546
- }
1547
- function normalizeConfigDirective(css, config) {
1548
- if (!config || !/@config\s+/.test(css)) return css;
1549
- return css.replace(/@config\s+(["'])(.+?)\1\s*;?/, `@config "${quoteCssString(toCssPath(config))}";`);
1550
- }
1551
- //#endregion
1552
- //#region src/bundlers/shared/generator-css/markers.ts
1553
- const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
1554
- const TAILWIND_ESCAPED_UTILITY_MARKER_RE = /\.[^,{]{0,512}(?:\\:|\\\[|\\#)/;
1555
- const TAILWIND_ROOT_THEME_MARKER_RE = /(?::root\s*,\s*:host|:host\s*,\s*page\s*,\s*\.tw-root\s*,\s*wx-root-portal-content)[^{]{0,256}\{[^}]{0,4096}(?:--spacing\b|--(?:color|text|font|default|radius)-)/;
1556
- const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
1557
- const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
1558
- const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
1559
- const TAILWIND_BANNER_RE = /\/\*!\s*tailwindcss v[^*]*\*\//i;
1560
- const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
1561
- const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
1562
- function createCssAppend(base, extra) {
1563
- if (!base) return extra;
1564
- if (!extra) return base;
1565
- return `${base}\n${extra}`;
1566
- }
1567
- function splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss) {
1568
- const trimmedRaw = rawSource.trim();
1569
- const trimmedTailwind = rawTailwindCss.trim();
1570
- if (trimmedRaw === trimmedTailwind) return {
1571
- before: "",
1572
- after: ""
1573
- };
1574
- if (trimmedTailwind.startsWith(trimmedRaw)) return {
1575
- before: "",
1576
- after: ""
1577
- };
1578
- const start = rawSource.indexOf(rawTailwindCss);
1579
- if (start === -1) return;
1580
- return {
1581
- before: rawSource.slice(0, start),
1582
- after: rawSource.slice(start + rawTailwindCss.length)
1583
- };
1584
- }
1585
- function splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss) {
1586
- const match = GENERATOR_PLACEHOLDER_MARKER_RE.exec(rawSource);
1587
- if (!match || match.index === void 0) return;
1588
- let afterStart = match.index + match[0].length;
1589
- while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
1590
- if (rawTailwindCss && rawSource.slice(afterStart).startsWith(rawTailwindCss)) {
1591
- afterStart += rawTailwindCss.length;
1592
- while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
1593
- }
1594
- return {
1595
- before: rawSource.slice(0, match.index),
1596
- after: rawSource.slice(afterStart)
1597
- };
1598
- }
1599
- function splitTailwindGeneratedCssByBanner(rawSource, start) {
1600
- const match = start === void 0 ? TAILWIND_BANNER_RE.exec(rawSource) : { index: start };
1601
- if (!match || match.index === void 0) return;
1602
- return {
1603
- before: rawSource.slice(0, match.index),
1604
- after: [...rawSource.slice(match.index).matchAll(VITE_MARKER_RE)].map((item) => item[0]).join("\n")
1605
- };
1606
- }
1607
- function stripTailwindBanner(css) {
1608
- return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
1609
- }
1610
- function stripTailwindBanners(css) {
1611
- return css.replace(TAILWIND_BANNER_GLOBAL_RE, "");
1612
- }
1613
- function stripGeneratorPlaceholderMarkers(css) {
1614
- return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
1615
- }
1616
- function hasTailwindGeneratedCss(rawSource) {
1617
- return TAILWIND_V4_BANNER_RE.test(rawSource);
1618
- }
1619
- function hasTailwindGeneratedCssMarkers(rawSource) {
1620
- if (rawSource.includes("--tw-") || rawSource.includes("tailwindcss v") || rawSource.includes(":not(#\\#)") || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
1621
- if (!rawSource.includes("\\:") && !rawSource.includes("\\[") && !rawSource.includes("\\#") && !rawSource.includes("--color-") && !rawSource.includes("--spacing") && !rawSource.includes("--text-") && !rawSource.includes("--font-") && !rawSource.includes("--font-weight-") && !rawSource.includes("--default-") && !rawSource.includes("--radius-")) return false;
1622
- return TAILWIND_ESCAPED_UTILITY_MARKER_RE.test(rawSource) || TAILWIND_ROOT_THEME_MARKER_RE.test(rawSource);
1623
- }
1624
- //#endregion
1625
- //#region src/bundlers/shared/generator-css/directives/fallback.ts
1626
- const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|use|forward|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
1627
- const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
1628
- const TAILWIND_EXTRACTABLE_BLOCK_START_RE = /^\s*@(?:layer|theme|utility|variant|custom-variant|plugin)\b[\s\S]*\{/;
1629
- function parseImportRequest$1(params) {
1630
- return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
1631
- }
1632
- function parseConfigRequest$1(params) {
1633
- return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
1634
- }
1635
- function isPackageJsonImportRequest$1(request) {
1636
- return typeof request === "string" && request.startsWith("#");
1637
- }
1638
- function isWeappTailwindcssImportRequest(request) {
1639
- return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
1640
- }
1641
- function isTailwindImportRequest$1(request) {
1642
- return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
1643
- }
1644
- function normalizeTailwindImportRequest$1(request, options = {}) {
1645
- if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
1646
- return request;
1647
- }
1648
- function replaceImportRequest$1(params, request, replacement) {
1649
- const index = params.indexOf(request);
1650
- if (index === -1) return params;
1651
- return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
1652
- }
1653
- function normalizeTailwindDirectiveLine(line, options = {}) {
1654
- const trimmed = line.trimStart();
1655
- if (/^@(?:use|forward)\b/.test(trimmed)) {
1656
- const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
1657
- if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest(request)) {
1658
- const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
1659
- return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
1660
- }
1661
- return line;
1662
- }
1663
- if (!options.importFallback || !trimmed.startsWith("@import")) return line;
1664
- const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
1665
- if (!request || !isWeappTailwindcssImportRequest(request)) return line;
1666
- return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
1667
- }
1668
- function extractTailwindDirectiveLines(rawSource, options = {}) {
1669
- const directives = [];
1670
- const seenImports = /* @__PURE__ */ new Set();
1671
- for (const line of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
1672
- const trimmed = line.trim();
1673
- if (!trimmed || trimmed.startsWith("//")) continue;
1674
- const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE.exec(line)?.[0];
1675
- if (!directive) continue;
1676
- if (TAILWIND_EXTRACTABLE_BLOCK_START_RE.test(directive)) continue;
1677
- const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
1678
- const normalizedTrimmed = normalized.trim();
1679
- if (options.removeConfig && normalizedTrimmed.startsWith("@config")) continue;
1680
- const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest$1(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
1681
- if (request && !isTailwindImportRequest$1(request) && !isPackageJsonImportRequest$1(request)) continue;
1682
- if (/^@(?:import|use|forward)\b/.test(normalizedTrimmed) && !request) continue;
1683
- if (request && isTailwindImportRequest$1(request)) {
1684
- const key = normalizedTrimmed;
1685
- if (seenImports.has(key)) continue;
1686
- seenImports.add(key);
1687
- }
1688
- directives.push(normalized);
1689
- }
1690
- return directives;
1691
- }
1692
- function stripPreprocessorLineComment(line) {
1693
- let quote;
1694
- let escaped = false;
1695
- for (let index = 0; index < line.length; index++) {
1696
- const char = line[index];
1697
- if (escaped) {
1698
- escaped = false;
1699
- continue;
1700
- }
1701
- if (char === "\\") {
1702
- escaped = true;
1703
- continue;
1704
- }
1705
- if (quote) {
1706
- if (char === quote) quote = void 0;
1707
- continue;
1708
- }
1709
- if (char === "\"" || char === "'") {
1710
- quote = char;
1711
- continue;
1712
- }
1713
- if (char === "/" && line[index + 1] === "/" && (index === 0 || /\s/.test(line[index - 1]))) return line.slice(0, index).trimEnd();
1714
- }
1715
- return line;
1716
- }
1717
- function countBlockBraceDelta(line) {
1718
- let quote;
1719
- let escaped = false;
1720
- let delta = 0;
1721
- for (let index = 0; index < line.length; index++) {
1722
- const char = line[index];
1723
- if (escaped) {
1724
- escaped = false;
1725
- continue;
1726
- }
1727
- if (char === "\\") {
1728
- escaped = true;
1729
- continue;
1730
- }
1731
- if (quote) {
1732
- if (char === quote) quote = void 0;
1733
- continue;
1734
- }
1735
- if (char === "\"" || char === "'") {
1736
- quote = char;
1737
- continue;
1738
- }
1739
- if (char === "{") delta++;
1740
- else if (char === "}") delta--;
1741
- }
1742
- return delta;
1743
- }
1744
- function extractTailwindFallbackBlocks(rawSource) {
1745
- const blocks = [];
1746
- let current;
1747
- let depth = 0;
1748
- for (const rawLine of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
1749
- const line = stripPreprocessorLineComment(rawLine);
1750
- if (!line.trim()) continue;
1751
- if (!current) {
1752
- if (!TAILWIND_EXTRACTABLE_BLOCK_START_RE.test(line)) continue;
1753
- current = [line];
1754
- depth = countBlockBraceDelta(line);
1755
- if (depth <= 0) {
1756
- blocks.push(current.join("\n"));
1757
- current = void 0;
1758
- depth = 0;
1759
- }
1760
- continue;
1761
- }
1762
- current.push(line);
1763
- depth += countBlockBraceDelta(line);
1764
- if (depth <= 0) {
1765
- blocks.push(current.join("\n"));
1766
- current = void 0;
1767
- depth = 0;
1768
- }
1769
- }
1770
- return blocks;
1771
- }
1772
- function extractTailwindSourceForPostcssFallback(rawSource, options = {}) {
1773
- const directives = [...extractTailwindDirectiveLines(rawSource, options), ...extractTailwindFallbackBlocks(rawSource)];
1774
- return directives.length > 0 ? directives.join("\n") : void 0;
1775
- }
1776
- function extractConfigRequestFromSource(rawSource) {
1777
- for (const line of rawSource.split(/\r?\n/)) {
1778
- const match = /^\s*@config\b([\s\S]*?)(?:;|$)/.exec(line);
1779
- const request = match ? parseConfigRequest$1(match[1] ?? "") : void 0;
1780
- if (request) return request;
1781
- }
1782
- }
1783
- //#endregion
1784
- //#region src/bundlers/shared/generator-css/directives.ts
1785
- const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
1786
- "config",
1787
- "custom-variant",
1788
- "layer",
1789
- "plugin",
1790
- "reference",
1791
- "source",
1792
- "tailwind",
1793
- "theme",
1794
- "utility",
1795
- "variant"
1796
- ]);
1797
- const TAILWIND_APPLY_CONTEXT_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
1798
- "config",
1799
- "custom-variant",
1800
- "plugin",
1801
- "reference",
1802
- "theme",
1803
- "utility",
1804
- "variant"
1805
- ]);
1806
- const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
1807
- function parseImportRequest(params) {
1808
- return parseTailwindCssDirectiveRequest(params);
1809
- }
1810
- function hasLocalCssImport(rawSource) {
1811
- return analyzeParseableTailwindDirectives(rawSource)?.hasLocalCssImport ?? false;
1812
- }
1813
- function parseConfigRequest(params) {
1814
- return parseTailwindCssConfigRequest(params);
1815
- }
1816
- function isPackageJsonImportRequest(request) {
1817
- return isTailwindCssPackageJsonImportRequest(request);
1818
- }
1819
- function normalizeTailwindImportRequest(request, options = {}) {
1820
- return normalizeTailwindCssImportRequest(request, options);
1821
- }
1822
- function replaceImportRequest(params, request, replacement) {
1823
- const index = params.indexOf(request);
1824
- if (index === -1) return params;
1825
- return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
1826
- }
1827
- function normalizeTailwindImportAtRules(root, options = {}) {
1828
- if (!options.importFallback) return false;
1829
- let changed = false;
1830
- const seenCanonicalImports = /* @__PURE__ */ new Set();
1831
- root.walkAtRules("import", (node) => {
1832
- const request = parseImportRequest(node.params);
1833
- const normalizedRequest = normalizeTailwindImportRequest(request, options);
1834
- if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
1835
- const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
1836
- const normalizedKey = normalizedParams.trim();
1837
- if (seenCanonicalImports.has(normalizedKey)) {
1838
- node.remove();
1839
- changed = true;
1840
- return;
1841
- }
1842
- seenCanonicalImports.add(normalizedKey);
1843
- if (normalizedParams !== node.params) {
1844
- node.params = normalizedParams;
1845
- changed = true;
1846
- }
1847
- });
1848
- return changed;
1849
- }
1850
- function resolveConfigPath(base, configPath) {
1851
- if (path.isAbsolute(configPath) || isPackageJsonImportRequest(configPath)) return path.isAbsolute(configPath) ? configPath : void 0;
1852
- return path.resolve(base, configPath);
1853
- }
1854
- function normalizeTailwindConfigDirectives(rawSource, base) {
1855
- return rawSource.replace(/@config\s+(["'])(.+?)\1\s*;?/g, (full, quote, request) => {
1856
- if (path.isAbsolute(request) || isPackageJsonImportRequest(request)) return full;
1857
- return `@config ${quote}${path.resolve(base, request).replace(/\\/g, "/")}${quote};`;
1858
- });
1859
- }
1860
- function hasPreprocessorOnlySyntax(rawSource) {
1861
- return /(?:^|\n)\s*(?:\/\/|\$[\w-]+\s*:|@[\w-]+\s*:|@(?:mixin|include|function|use|forward)\b)/.test(rawSource);
1862
- }
1863
- function normalizeTailwindSourceForGenerator(rawSource, options = {}) {
1864
- return hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource : rawSource;
1865
- }
1866
- function normalizeTailwindSourceDirectives(rawSource, options = {}) {
1867
- if (!options.importFallback) return rawSource;
1868
- try {
1869
- const root = postcss.parse(rawSource);
1870
- return normalizeTailwindImportAtRules(root, options) ? root.toString() : rawSource;
1871
- } catch {
1872
- return extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource;
1873
- }
1874
- }
1875
- function isTailwindImportRequest(request) {
1876
- const normalized = normalizeTailwindImportRequest(request);
1877
- return normalized === "tailwindcss" || normalized === "tailwindcss4" || normalized?.startsWith("tailwindcss/") === true || normalized?.startsWith("tailwindcss4/") === true;
1878
- }
1879
- function isTailwindImportAtRule(node, options = {}) {
1880
- return isTailwindCssImportAtRule(node, options);
1881
- }
1882
- function isTailwindSourceDirective(node, options = {}) {
1883
- if (node.type !== "atrule") return false;
1884
- const atRule = node;
1885
- if (isTailwindImportAtRule(atRule, options)) return true;
1886
- if (atRule.name === "import" && isPackageJsonImportRequest(parseImportRequest(atRule.params))) return true;
1887
- if (atRule.name === "layer") return !atRule.nodes || atRule.nodes.length === 0;
1888
- if (options.preserveApplyContext && TAILWIND_APPLY_CONTEXT_DIRECTIVE_NAMES.has(atRule.name)) return false;
1889
- return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(atRule.name);
1890
- }
1891
- function hasGeneratedCssArtifacts(rawSource) {
1892
- return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
1893
- }
1894
- function isTailwindGenerationDirective(node, options = {}) {
1895
- return isTailwindCssGenerationDirective(node, options);
1896
- }
1897
- function analyzeParseableTailwindDirectives(rawSource, options = {}) {
1898
- try {
1899
- const ignoreLayer = options.ignoreLayer ?? hasGeneratedCssArtifacts(rawSource);
1900
- return analyzeTailwindCssDirectives(postcss.parse(rawSource), {
1901
- ...options,
1902
- ignoreLayer
1903
- });
1904
- } catch {
1905
- return;
1906
- }
1907
- }
1908
- function removeTailwindSourceDirectives(rawSource, options = {}) {
1909
- try {
1910
- const source = hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) : stripGeneratorPlaceholderMarkers(rawSource);
1911
- if (!source) return "";
1912
- const root = postcss.parse(source);
1913
- let removed = false;
1914
- root.walk((node) => {
1915
- if (isTailwindSourceDirective(node, options)) {
1916
- node.remove();
1917
- removed = true;
1918
- }
1919
- });
1920
- return removed ? root.toString() : source;
1921
- } catch {
1922
- return stripGeneratorPlaceholderMarkers(rawSource);
1923
- }
1924
- }
1925
- function hasTailwindSourceDirectives(rawSource, options = {}) {
1926
- if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
1927
- return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindSourceDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
1928
- }
1929
- function hasTailwindNonRootGenerationDirectives(rawSource, options = {}) {
1930
- if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
1931
- return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindNonRootGenerationDirectives ?? /@(?:apply|config|custom-variant|plugin|source|theme|utility|variant)\b/.test(rawSource);
1932
- }
1933
- function hasTailwindRootDirectives(rawSource, options = {}) {
1934
- if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
1935
- return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindRootDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
1936
- }
1937
- function hasTailwindApplyDirective(rawSource) {
1938
- if (!rawSource.includes("@apply")) return false;
1939
- const analysis = analyzeParseableTailwindDirectives(rawSource);
1940
- if (analysis) return analysis.hasTailwindApplyDirective;
1941
- const fallback = extractTailwindSourceForPostcssFallback(rawSource);
1942
- return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
1943
- }
1944
- function resolveCssEntrySource(rawSource, base, options = {}) {
1945
- try {
1946
- const root = postcss.parse(rawSource);
1947
- const normalizedImports = normalizeTailwindImportAtRules(root, options);
1948
- let found = false;
1949
- let config;
1950
- let configRequest;
1951
- let removedConfig = false;
1952
- const removeConfig = options.removeConfig ?? true;
1953
- const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
1954
- root.walk((node) => {
1955
- if (isTailwindGenerationDirective(node, {
1956
- ...options,
1957
- ignoreLayer
1958
- })) found = true;
1959
- if (node.type === "atrule" && node.name === "config") {
1960
- const configPath = parseConfigRequest(node.params);
1961
- if (configPath && !config) {
1962
- configRequest = configPath;
1963
- config = resolveConfigPath(base, configPath);
1964
- }
1965
- if (removeConfig) {
1966
- node.remove();
1967
- removedConfig = true;
1968
- }
1969
- }
1970
- });
1971
- if (!found) return;
1972
- if (hasPreprocessorOnlySyntax(rawSource)) {
1973
- const css = extractTailwindSourceForPostcssFallback(rawSource, {
1974
- ...options,
1975
- removeConfig
1976
- });
1977
- if (css) return {
1978
- css,
1979
- config,
1980
- configRequest,
1981
- base
1982
- };
1983
- }
1984
- return {
1985
- css: removedConfig || normalizedImports ? root.toString() : rawSource,
1986
- config,
1987
- configRequest,
1988
- base
1989
- };
1990
- } catch {
1991
- const css = extractTailwindSourceForPostcssFallback(rawSource, options);
1992
- const configRequest = extractConfigRequestFromSource(rawSource);
1993
- const config = configRequest ? resolveConfigPath(base, configRequest) : void 0;
1994
- return css ? {
1995
- css,
1996
- config,
1997
- configRequest,
1998
- base
1999
- } : void 0;
2000
- }
2001
- }
2002
- //#endregion
2003
- //#region src/bundlers/shared/generator-css/scoped-rules.ts
2004
- const VUE_SCOPED_SELECTOR_RE = /\.data-v-[\w-]+|\[data-v-[^\]]+\]/g;
2005
- function normalizeGeneratedSelector$1(selector) {
2006
- return selector.replace(/:not\(#\\#\)/g, "").trim();
2007
- }
2008
- function normalizeVueScopedSelector(selector) {
2009
- let scoped = false;
2010
- return {
2011
- normalized: normalizeGeneratedSelector$1(selector).replace(VUE_SCOPED_SELECTOR_RE, () => {
2012
- scoped = true;
2013
- return "";
2014
- }).trim(),
2015
- scoped
2016
- };
2017
- }
2018
- function normalizeCssComparableValue(value) {
2019
- const normalizeUnquotedSegment = (segment) => segment.replace(/(^|[^\w.-])(-?)0+\.(\d+)/g, "$1$2.$3");
2020
- let result = "";
2021
- let segmentStart = 0;
2022
- let index = 0;
2023
- while (index < value.length) {
2024
- const quote = value[index];
2025
- if (quote !== "\"" && quote !== "'") {
2026
- index++;
2027
- continue;
2028
- }
2029
- result += normalizeUnquotedSegment(value.slice(segmentStart, index));
2030
- const stringStart = index;
2031
- index++;
2032
- while (index < value.length) {
2033
- if (value[index] === "\\") {
2034
- index += 2;
2035
- continue;
2036
- }
2037
- if (value[index] === quote) {
2038
- index++;
2039
- break;
2040
- }
2041
- index++;
2042
- }
2043
- result += value.slice(stringStart, index);
2044
- segmentStart = index;
2045
- }
2046
- return result + normalizeUnquotedSegment(value.slice(segmentStart));
2047
- }
2048
- function createCssNodeSignature(node) {
2049
- if (node.type === "decl") return JSON.stringify([
2050
- "decl",
2051
- node.prop,
2052
- normalizeCssComparableValue(node.value),
2053
- node.important
2054
- ]);
2055
- if (node.type === "atrule") return JSON.stringify([
2056
- "atrule",
2057
- node.name,
2058
- normalizeCssComparableValue(node.params),
2059
- node.nodes?.map(createCssNodeSignature) ?? null
2060
- ]);
2061
- if (node.type === "rule") return JSON.stringify([
2062
- "rule",
2063
- node.selector,
2064
- node.nodes?.map(createCssNodeSignature) ?? null
2065
- ]);
2066
- if (node.type === "comment") return JSON.stringify(["comment", node.text]);
2067
- return node.toString();
2068
- }
2069
- function createRuleBodySignature(rule) {
2070
- return JSON.stringify(rule.nodes?.map(createCssNodeSignature) ?? []);
2071
- }
2072
- function createRuleAtRuleContextSignature(rule) {
2073
- const context = [];
2074
- let parent = rule.parent;
2075
- while (parent && parent.type !== "root" && parent.type !== "document") {
2076
- if (parent.type === "atrule") context.unshift(JSON.stringify([parent.name, parent.params]));
2077
- parent = parent.parent;
2078
- }
2079
- return JSON.stringify(context);
2080
- }
2081
- function createScopedRuleCoverageKey(rule, selector) {
2082
- return JSON.stringify([
2083
- createRuleAtRuleContextSignature(rule),
2084
- createRuleBodySignature(rule),
2085
- selector
2086
- ]);
2087
- }
2088
- function removeUnscopedRulesCoveredByScopedRules(root) {
2089
- const scopedCoverage = /* @__PURE__ */ new Set();
2090
- root.walkRules((rule) => {
2091
- for (const selector of rule.selectors ?? [rule.selector]) {
2092
- const normalized = normalizeVueScopedSelector(selector);
2093
- if (normalized.scoped && normalized.normalized) scopedCoverage.add(createScopedRuleCoverageKey(rule, normalized.normalized));
2094
- }
2095
- });
2096
- if (scopedCoverage.size === 0) return;
2097
- root.walkRules((rule) => {
2098
- const normalizedSelectors = (rule.selectors ?? [rule.selector]).map(normalizeVueScopedSelector);
2099
- if (normalizedSelectors.some((selector) => selector.scoped || !selector.normalized) || !normalizedSelectors.every((selector) => scopedCoverage.has(createScopedRuleCoverageKey(rule, selector.normalized)))) return;
2100
- rule.remove();
2101
- });
2102
- }
2103
- function preferScopedGeneratedCssRules(css) {
2104
- if (!css.includes("data-v-")) return css;
2105
- try {
2106
- const root = postcss.parse(css);
2107
- removeUnscopedRulesCoveredByScopedRules(root);
2108
- root.walkAtRules((rule) => {
2109
- if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
2110
- });
2111
- return root.toString();
2112
- } catch {
2113
- return css;
2114
- }
2115
- }
2116
- //#endregion
2117
- //#region src/bundlers/shared/generator-css/user-css/user-layers.ts
2118
- function splitUserCssLayerBlocks(source) {
2119
- if (!source.includes("@layer")) return {
2120
- layer: "",
2121
- rest: source
2122
- };
2123
- try {
2124
- const root = postcss.parse(source);
2125
- const layerRoot = postcss.root();
2126
- const restRoot = postcss.root();
2127
- for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
2128
- return {
2129
- layer: layerRoot.toString(),
2130
- rest: restRoot.toString()
2131
- };
2132
- } catch {
2133
- return {
2134
- layer: source,
2135
- rest: ""
2136
- };
2137
- }
2138
- }
2139
- function hasUserCssLayerBlocks(source) {
2140
- if (!source.includes("@layer")) return false;
2141
- try {
2142
- let hasLayerBlock = false;
2143
- postcss.parse(source).walkAtRules("layer", (node) => {
2144
- if (node.nodes?.length) hasLayerBlock = true;
2145
- });
2146
- return hasLayerBlock;
2147
- } catch {
2148
- return true;
2149
- }
2150
- }
2151
- function collectUserLayerSelectors(source) {
2152
- const selectors = /* @__PURE__ */ new Set();
2153
- try {
2154
- postcss.parse(source).walkRules((rule) => {
2155
- for (const selector of rule.selectors ?? [rule.selector]) {
2156
- const normalized = selector.trim();
2157
- if (normalized) selectors.add(normalized);
2158
- }
2159
- });
2160
- } catch {}
2161
- return selectors;
2162
- }
2163
- function matchesUserLayerSelector(selector, userLayerSelector) {
2164
- if (selector === userLayerSelector) return true;
2165
- if (!selector.startsWith(userLayerSelector)) return false;
2166
- const next = selector[userLayerSelector.length];
2167
- return next === ":" || next === "[";
2168
- }
2169
- function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
2170
- const selectors = collectUserLayerSelectors(userLayerSource);
2171
- if (selectors.size === 0) return {
2172
- layer: "",
2173
- rest: css
2174
- };
2175
- try {
2176
- const root = postcss.parse(css);
2177
- const layerRoot = postcss.root();
2178
- const selectorList = [...selectors];
2179
- root.walkRules((rule) => {
2180
- if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
2181
- layerRoot.append(rule.clone());
2182
- rule.remove();
2183
- }
2184
- });
2185
- return {
2186
- layer: layerRoot.toString(),
2187
- rest: root.toString()
2188
- };
2189
- } catch {
2190
- return {
2191
- layer: "",
2192
- rest: css
2193
- };
2194
- }
2195
- }
2196
- function normalizeGeneratedSelector(selector) {
2197
- return selector.replace(/:not\(#\\#\)/g, "").trim();
2198
- }
2199
- function collectApplyOnlySourceSelectors(source) {
2200
- const selectors = /* @__PURE__ */ new Set();
2201
- try {
2202
- postcss.parse(source).walkRules((rule) => {
2203
- if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
2204
- for (const selector of rule.selectors ?? [rule.selector]) {
2205
- const normalized = normalizeGeneratedSelector(selector);
2206
- if (normalized) selectors.add(normalized);
2207
- }
2208
- });
2209
- } catch {}
2210
- return selectors;
2211
- }
2212
- function hasOnlyApplyBackedSourceRules(source) {
2213
- let hasApplyRule = false;
2214
- let hasNonApplyRule = false;
2215
- try {
2216
- postcss.parse(source).walkRules((rule) => {
2217
- if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
2218
- else hasNonApplyRule = true;
2219
- });
2220
- } catch {
2221
- return false;
2222
- }
2223
- return hasApplyRule && !hasNonApplyRule;
2224
- }
2225
- function removeCssComments(css) {
2226
- return css.replace(/\/\*[\s\S]*?\*\//g, "");
2227
- }
2228
- function isEmptyCustomVariantBlock(rule) {
2229
- if (rule.name !== "custom-variant") return false;
2230
- if (!/^[\w-]+$/.test(rule.params.trim())) return false;
2231
- if (rule.nodes === void 0) return true;
2232
- return rule.nodes.every((node) => node.type === "comment");
2233
- }
2234
- //#endregion
2235
- //#region src/bundlers/shared/generator-css/user-css/apply-only.ts
2236
- function normalizeEmptyTailwindCustomVariants(css) {
2237
- if (!css.includes("@custom-variant")) return css;
2238
- try {
2239
- const root = postcss.parse(css);
2240
- let changed = false;
2241
- root.walkAtRules("custom-variant", (rule) => {
2242
- if (!isEmptyCustomVariantBlock(rule)) return;
2243
- rule.remove();
2244
- changed = true;
2245
- });
2246
- return changed ? root.toString() : css;
2247
- } catch {
2248
- return css;
2249
- }
2250
- }
2251
- function filterApplyOnlyGeneratedCss(css, source, options = {}) {
2252
- const selectors = collectApplyOnlySourceSelectors(source);
2253
- if (selectors.size === 0) return css;
2254
- const selectorList = [...selectors];
2255
- const preserveVariables = options.preserveVariables !== false;
2256
- try {
2257
- const root = postcss.parse(css);
2258
- root.walkRules((rule) => {
2259
- const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
2260
- const normalized = normalizeGeneratedSelector(selector);
2261
- return selectorList.some((sourceSelector) => {
2262
- if (normalized === sourceSelector) return true;
2263
- if (!normalized.startsWith(sourceSelector)) return false;
2264
- const next = normalized[sourceSelector.length];
2265
- return next === ":" || next === "[" || next === ".";
2266
- });
2267
- });
2268
- const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
2269
- if (!isApplySelector && (!preserveVariables || !isVariableRule)) rule.remove();
2270
- });
2271
- root.walkAtRules((rule) => {
2272
- if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
2273
- });
2274
- const filteredCss = root.toString();
2275
- return removeCssComments(options.preferScopedRules ? preferScopedGeneratedCssRules(filteredCss) : filteredCss).trim();
2276
- } catch {
2277
- return css;
2278
- }
2279
- }
2280
- function shouldFilterApplyOnlyGeneratedCss(_majorVersion, target, source, options) {
2281
- return (target === "weapp" || target === "web") && hasTailwindApplyDirective(source) && !hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
2282
- }
2283
- //#endregion
2284
- //#region src/bundlers/shared/generator-css/user-css/generated-cleanup.ts
2285
- const TAILWIND_V4_GENERATOR_AT_RULES = /* @__PURE__ */ new Set([
2286
- "config",
2287
- "custom-variant",
2288
- "plugin",
2289
- "source",
2290
- "theme",
2291
- "utility",
2292
- "variant"
2293
- ]);
2294
- function removeBalancedAtRuleBlock(source, atRuleStart) {
2295
- const blockStart = source.indexOf("{", atRuleStart);
2296
- if (blockStart === -1) {
2297
- const semicolon = source.indexOf(";", atRuleStart);
2298
- return semicolon === -1 ? source.slice(0, atRuleStart) : `${source.slice(0, atRuleStart)}${source.slice(semicolon + 1)}`;
2299
- }
2300
- let depth = 0;
2301
- for (let index = blockStart; index < source.length; index++) {
2302
- const char = source[index];
2303
- if (char === "{") {
2304
- depth++;
2305
- continue;
2306
- }
2307
- if (char !== "}") continue;
2308
- depth--;
2309
- if (depth === 0) return `${source.slice(0, atRuleStart)}${source.slice(index + 1)}`;
2310
- }
2311
- return source.slice(0, atRuleStart);
2312
- }
2313
- function removeTailwindV4GeneratorAtRulesFallback(source) {
2314
- let next = source;
2315
- let changed = false;
2316
- const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
2317
- for (;;) {
2318
- sourceMediaRE.lastIndex = 0;
2319
- const match = sourceMediaRE.exec(next);
2320
- if (!match) break;
2321
- next = removeBalancedAtRuleBlock(next, match.index);
2322
- changed = true;
2323
- }
2324
- const atRuleRE = /@(?:config|custom-variant|plugin|source|theme|utility|variant)\b/g;
2325
- for (;;) {
2326
- atRuleRE.lastIndex = 0;
2327
- const match = atRuleRE.exec(next);
2328
- if (!match) break;
2329
- next = removeBalancedAtRuleBlock(next, match.index);
2330
- changed = true;
2331
- }
2332
- return changed ? next : source;
2333
- }
2334
- function isTailwindGeneratedPreflightComment(text) {
2335
- return text.includes("cssremedy") || text.includes("Use the user's configured") || text.includes("tailwindlabs/tailwindcss") || text.includes("Prevent padding and border from affecting element width") || text.includes("Remove default margins and padding") || text.includes("Deprecated") || text.includes("Reset all borders") || text.includes("Add the correct text decoration") || text.includes("Make elements with the HTML hidden attribute stay hidden") || text.includes("Inherit font styles in all browsers") || text.includes("Add the correct height in Firefox") || text.includes("Remove the default font size and weight for headings") || text.includes("Reset links to optimize for opt-in styling") || text.includes("Add the correct font weight in Edge and Safari") || text.includes("Use the user's configured `mono` font-family") || text.includes("Add the correct font size in all browsers") || text.includes("Prevent `sub` and `sup` elements from affecting the line height") || text.includes("Remove text indentation from table contents") || text.includes("Use the modern Firefox focus style") || text.includes("Add the correct vertical alignment") || text.includes("Add the correct display") || text.includes("Make lists unstyled by default") || text.includes("Make replaced elements `display: block` by default") || text.includes("Constrain images and videos to the parent width") || text.includes("Restore default font weight") || text.includes("Restore indentation") || text.includes("Restore space after button") || text.includes("Prevent resizing textareas horizontally") || text.includes("Remove the inner padding in Chrome and Safari") || text.includes("Ensure date/time inputs have the same height") || text.includes("Prevent height from changing on date/time inputs") || text.includes("Remove excess padding from pseudo-elements") || text.includes("Center dropdown marker shown on inputs") || text.includes("Remove the additional `:invalid` styles") || text.includes("Correct the inability to style the border radius") || text.includes("Correct the cursor style of increment and decrement buttons");
2336
- }
2337
- const TAILWIND_GENERATED_THEME_SCOPE_SELECTORS = /* @__PURE__ */ new Set([
2338
- ":host",
2339
- ":root",
2340
- "page",
2341
- ".tw-root",
2342
- "wx-root-portal-content"
2343
- ]);
2344
- function isTailwindGeneratedThemeScopeSelector(selector) {
2345
- const selectors = selector.split(",").map((item) => item.trim()).filter(Boolean);
2346
- const selectorSet = new Set(selectors);
2347
- if (selectorSet.size !== selectors.length) return false;
2348
- if (!selectors.every((item) => TAILWIND_GENERATED_THEME_SCOPE_SELECTORS.has(item))) return false;
2349
- return selectorSet.size === 2 && selectorSet.has(":root") && selectorSet.has(":host") || selectorSet.size === 4 && selectorSet.has(":host") && selectorSet.has("page") && selectorSet.has(".tw-root") && selectorSet.has("wx-root-portal-content");
2350
- }
2351
- function isTailwindGeneratedThemeRule(selector, node) {
2352
- if (!isTailwindGeneratedThemeScopeSelector(selector)) return false;
2353
- return node.nodes?.some((child) => child.type === "decl" && /^--(?:color|spacing|text|font|default|radius|tw-)/.test(child.prop)) ?? false;
2354
- }
2355
- function isTailwindGeneratedPreflightRule(selector, node) {
2356
- if (selector === "view,text,::after,::before" || selector === "view, text, ::after, ::before" || selector === "*" || selector === "::after" || selector === "::before" || selector === "::backdrop" || selector === ":host" || selector === "[hidden]:not([hidden=\"until-found\"])" || selector === "[hidden]:not([hidden='until-found'])" || selector === "button,input[type=\"button\"],input[type=\"reset\"],input[type=\"submit\"]" || selector === "button, input[type=\"button\"], input[type=\"reset\"], input[type=\"submit\"]" || selector === "button,input[type='button'],input[type='reset'],input[type='submit']" || selector === "button, input[type='button'], input[type='reset'], input[type='submit']") return true;
2357
- if (selector === "abbr[title]") return node.nodes?.some((child) => child.type === "decl" && child.prop === "text-decoration") ?? false;
2358
- if (selector === ":host") return node.nodes?.some((child) => child.type === "decl" && child.value?.includes("--theme(")) ?? false;
2359
- return false;
2360
- }
2361
- function removeTailwindV4GeneratedUserCssArtifacts(source) {
2362
- try {
2363
- const root = postcss.parse(source);
2364
- let changed = false;
2365
- root.walkComments((comment) => {
2366
- if (!isTailwindGeneratedPreflightComment(comment.text)) return;
2367
- comment.remove();
2368
- changed = true;
2369
- });
2370
- root.walkRules((rule) => {
2371
- const selector = rule.selector.replace(/\s+/g, " ").trim();
2372
- if (isTailwindGeneratedThemeRule(selector, rule) || isTailwindGeneratedPreflightRule(selector, rule)) {
2373
- rule.remove();
2374
- changed = true;
2375
- }
2376
- });
2377
- root.walkAtRules((rule) => {
2378
- if (rule.nodes !== void 0 && rule.nodes.length === 0) {
2379
- rule.remove();
2380
- changed = true;
2381
- }
2382
- });
2383
- return changed ? root.toString() : source;
2384
- } catch {
2385
- return source;
2386
- }
2387
- }
2388
- //#endregion
2389
- //#region src/bundlers/shared/generator-css/user-css/at-rules.ts
2390
- function removeTailwindSourceMediaBlocks(source) {
2391
- let next = source;
2392
- let changed = false;
2393
- const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
2394
- for (;;) {
2395
- sourceMediaRE.lastIndex = 0;
2396
- const match = sourceMediaRE.exec(next);
2397
- if (!match) break;
2398
- const blockStart = next.indexOf("{", match.index);
2399
- if (blockStart === -1) break;
2400
- let depth = 0;
2401
- let blockEnd = -1;
2402
- for (let index = blockStart; index < next.length; index++) {
2403
- const char = next[index];
2404
- if (char === "{") {
2405
- depth++;
2406
- continue;
2407
- }
2408
- if (char !== "}") continue;
2409
- depth--;
2410
- if (depth === 0) {
2411
- blockEnd = index;
2412
- break;
2413
- }
2414
- }
2415
- if (blockEnd === -1) break;
2416
- next = `${next.slice(0, match.index)}${next.slice(blockEnd + 1)}`;
2417
- changed = true;
2418
- }
2419
- for (;;) {
2420
- const atRuleStart = findTailwindSourceWrapperBlockStart(next);
2421
- if (atRuleStart === -1) break;
2422
- next = removeBalancedAtRuleBlock(next, atRuleStart);
2423
- changed = true;
2424
- }
2425
- return changed ? next : source;
2426
- }
2427
- function terminateTailwindSourceAtRulesBeforeNextDirective(source) {
2428
- if (!source.includes("@source")) return source;
2429
- let next = "";
2430
- let searchIndex = 0;
2431
- for (;;) {
2432
- const atRuleStart = source.indexOf("@source", searchIndex);
2433
- if (atRuleStart === -1) {
2434
- next += source.slice(searchIndex);
2435
- break;
2436
- }
2437
- const nextChar = source[atRuleStart + 7];
2438
- if (nextChar && /[\w-]/.test(nextChar)) {
2439
- next += source.slice(searchIndex, atRuleStart + 7);
2440
- searchIndex = atRuleStart + 7;
2441
- continue;
2442
- }
2443
- next += source.slice(searchIndex, atRuleStart);
2444
- let quote;
2445
- let parenDepth = 0;
2446
- let terminated = false;
2447
- let index = atRuleStart + 7;
2448
- for (; index < source.length; index++) {
2449
- const char = source[index];
2450
- if (quote) {
2451
- if (char === "\\") {
2452
- index++;
2453
- continue;
2454
- }
2455
- if (char === quote) quote = void 0;
2456
- continue;
2457
- }
2458
- if (char === "\"" || char === "'") {
2459
- quote = char;
2460
- continue;
2461
- }
2462
- if (char === "(") {
2463
- parenDepth++;
2464
- continue;
2465
- }
2466
- if (char === ")" && parenDepth > 0) {
2467
- parenDepth--;
2468
- continue;
2469
- }
2470
- if (parenDepth > 0) continue;
2471
- if (char === ";" || char === "{") {
2472
- terminated = true;
2473
- index++;
2474
- break;
2475
- }
2476
- if (char === "@" && /^(?:config|custom-variant|plugin|source|theme|utility|variant)\b/.test(source.slice(index + 1))) break;
2477
- }
2478
- const segment = source.slice(atRuleStart, index);
2479
- const trimmedSegment = segment.trimEnd();
2480
- next += terminated || trimmedSegment.endsWith(";") || trimmedSegment.endsWith("{") ? segment : `${trimmedSegment};${segment.slice(trimmedSegment.length)}`;
2481
- searchIndex = index;
2482
- }
2483
- return next;
2484
- }
2485
- function findTailwindSourceWrapperBlockStart(source) {
2486
- let searchIndex = 0;
2487
- for (;;) {
2488
- const atRuleStart = source.indexOf("@source", searchIndex);
2489
- if (atRuleStart === -1) return -1;
2490
- const nextChar = source[atRuleStart + 7];
2491
- if (nextChar && /[\w-]/.test(nextChar)) {
2492
- searchIndex = atRuleStart + 7;
2493
- continue;
2494
- }
2495
- let quote;
2496
- let parenDepth = 0;
2497
- for (let index = atRuleStart + 7; index < source.length; index++) {
2498
- const char = source[index];
2499
- if (quote) {
2500
- if (char === "\\") {
2501
- index++;
2502
- continue;
2503
- }
2504
- if (char === quote) quote = void 0;
2505
- continue;
2506
- }
2507
- if (char === "\"" || char === "'") {
2508
- quote = char;
2509
- continue;
2510
- }
2511
- if (char === "(") {
2512
- parenDepth++;
2513
- continue;
2514
- }
2515
- if (char === ")" && parenDepth > 0) {
2516
- parenDepth--;
2517
- continue;
2518
- }
2519
- if (parenDepth > 0) continue;
2520
- if (char === ";") {
2521
- searchIndex = index + 1;
2522
- break;
2523
- }
2524
- if (char === "{") return atRuleStart;
2525
- }
2526
- if (searchIndex <= atRuleStart) return -1;
2527
- }
2528
- }
2529
- function removeTailwindApplyAtRules(source) {
2530
- if (!source.includes("@apply")) return source;
2531
- try {
2532
- const root = postcss.parse(source);
2533
- let changed = false;
2534
- root.walkAtRules("apply", (rule) => {
2535
- rule.remove();
2536
- changed = true;
2537
- });
2538
- root.walk((node) => {
2539
- if ("nodes" in node && node.nodes?.length === 0) node.remove();
2540
- });
2541
- return changed ? root.toString() : source;
2542
- } catch {
2543
- return source;
2544
- }
2545
- }
2546
- //#endregion
2547
- //#region src/bundlers/shared/generator-css/user-css/source-fragments.ts
2548
- function removeTailwindV4GeneratorAtRules(source) {
2549
- try {
2550
- const root = postcss.parse(source);
2551
- let changed = false;
2552
- root.walkAtRules((rule) => {
2553
- if (rule.name === "media" && /^source\(/.test(rule.params.trim())) {
2554
- rule.remove();
2555
- changed = true;
2556
- return;
2557
- }
2558
- if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
2559
- rule.remove();
2560
- changed = true;
2561
- });
2562
- return changed ? root.toString() : source;
2563
- } catch {
2564
- return removeTailwindV4GeneratorAtRulesFallback(source);
2565
- }
2566
- }
2567
- function isCommentOnlyCss(source) {
2568
- try {
2569
- const root = postcss.parse(source);
2570
- return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
2571
- } catch {
2572
- return false;
2573
- }
2574
- }
2575
- function removeMiniProgramInteractiveSelectors(source, options = {
2576
- active: true,
2577
- hover: true
2578
- }) {
2579
- const removeActive = options.active === true;
2580
- const removeHover = options.hover === true;
2581
- const removeFocus = options.focus === true;
2582
- const unsupportedPseudoClasses = [
2583
- ...removeActive ? [":active"] : [],
2584
- ...removeHover ? [":hover"] : [],
2585
- ...removeFocus ? [":focus"] : []
2586
- ];
2587
- if (unsupportedPseudoClasses.length === 0 || !source.includes(":active") && !source.includes(":hover") && !source.includes(":focus")) return source;
2588
- try {
2589
- const root = postcss.parse(source);
2590
- let changed = false;
2591
- root.walkRules((rule) => {
2592
- const selectors = rule.selectors ?? [rule.selector];
2593
- const keptSelectors = selectors.filter((selector) => {
2594
- if (!unsupportedPseudoClasses.some((pseudoClass) => selector.includes(pseudoClass))) return true;
2595
- return !selectorContainsPseudoClass(selector, unsupportedPseudoClasses);
2596
- });
2597
- if (keptSelectors.length === selectors.length) return;
2598
- changed = true;
2599
- if (keptSelectors.length === 0) {
2600
- rule.remove();
2601
- return;
2602
- }
2603
- rule.selectors = keptSelectors;
2604
- });
2605
- root.walk((node) => {
2606
- if ("nodes" in node && node.nodes?.length === 0) {
2607
- node.remove();
2608
- changed = true;
2609
- }
2610
- });
2611
- return changed ? root.toString() : source;
2612
- } catch {
2613
- return source;
2614
- }
2615
- }
2616
- function removeProcessedMiniProgramUnsupportedCss(source, options) {
2617
- return removeMiniProgramInteractiveSelectors(removeUnsupportedMiniProgramAtRules(source), {
2618
- active: options.cssRemoveActivePseudoClass ?? true,
2619
- hover: options.cssRemoveHoverPseudoClass ?? true,
2620
- focus: options.cssRemoveFocusPseudoClass ?? true
2621
- });
2622
- }
2623
- function unwrapMiniProgramCascadeLayers(source) {
2624
- if (!source.includes("@layer")) return source;
2625
- try {
2626
- const root = postcss.parse(source);
2627
- removeUnsupportedCascadeLayers(root);
2628
- return root.toString();
2629
- } catch {
2630
- return source;
2631
- }
2632
- }
2633
- function hasClassSelector(selector) {
2634
- return /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector);
2635
- }
2636
- function collectBareSelectorUserCss(source) {
2637
- try {
2638
- const root = postcss.parse(source);
2639
- let changed = false;
2640
- root.walkAtRules("import", (rule) => {
2641
- rule.remove();
2642
- changed = true;
2643
- });
2644
- root.walkRules((rule) => {
2645
- if ((rule.selectors?.length ? rule.selectors : [rule.selector]).some((selector) => hasClassSelector(selector))) {
2646
- rule.remove();
2647
- changed = true;
2648
- }
2649
- });
2650
- root.walkAtRules((rule) => {
2651
- if (rule.nodes !== void 0 && rule.nodes.length === 0) {
2652
- rule.remove();
2653
- changed = true;
2654
- }
2655
- });
2656
- return changed ? root.toString() : source;
2657
- } catch {
2658
- return "";
2659
- }
2660
- }
2661
- function stripTailwindSourceMediaFragments(source) {
2662
- let removedSourceMediaStart = false;
2663
- return terminateTailwindSourceAtRulesBeforeNextDirective(removeTailwindSourceMediaBlocks(source)).split(/\r?\n/).filter((line) => {
2664
- if (/^\s*@media\s+source\([^)]*\)\s*\{\s*$/.test(line)) {
2665
- removedSourceMediaStart = true;
2666
- return false;
2667
- }
2668
- if (/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/.test(line)) return false;
2669
- if (removedSourceMediaStart && /^\s*\}\s*$/.test(line)) {
2670
- removedSourceMediaStart = false;
2671
- return false;
2672
- }
2673
- return true;
2674
- }).join("\n");
2675
- }
2676
- function stripLeadingTailwindSourceMediaCloseFragment(source) {
2677
- return source.replace(/^\s*\}\s*(?:\n|$)/, "");
2678
- }
2679
- function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
2680
- try {
2681
- postcss.parse(source);
2682
- return source;
2683
- } catch {
2684
- return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
2685
- }
2686
- }
2687
- //#endregion
2688
- //#region src/bundlers/shared/generator-css/user-css/transform.ts
2689
- async function transformGeneratorUserCss(source, options) {
2690
- if (source.trim().length === 0) return "";
2691
- if (options.processed) return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(unwrapMiniProgramCascadeLayers(removeProcessedMiniProgramUnsupportedCss(source, {
2692
- ...options.generatorStyleOptions,
2693
- ...options.cssUserHandlerOptions
2694
- }))) : source)));
2695
- const cleanedSource = removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
2696
- if (cleanedSource.trim().length === 0) return "";
2697
- const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(removeUnsupportedMiniProgramAtRules(unwrapMiniProgramCascadeLayers(cleanedSource))) : cleanedSource)), { importFallback: options.importFallback })));
2698
- if (userSource.trim().length === 0) return "";
2699
- if (isCommentOnlyCss(userSource)) return userSource;
2700
- if (options.generatorTarget !== "weapp") return userSource;
2701
- const { css } = await options.styleHandler(userSource, {
2702
- ...options.generatorStyleOptions,
2703
- ...options.cssUserHandlerOptions
2704
- });
2705
- const transformedCss = removeTailwindV4GeneratedUserCssArtifacts(removeUnsupportedMiniProgramAtRules(css));
2706
- const bareSelectorUserCss = collectBareSelectorUserCss(userSource);
2707
- const missingBareSelectorUserCss = bareSelectorUserCss.trim().length > 0 ? filterExistingCssRules(transformedCss, bareSelectorUserCss) : "";
2708
- return missingBareSelectorUserCss.trim().length > 0 ? `${transformedCss}\n${missingBareSelectorUserCss}` : transformedCss;
2709
- }
2710
- //#endregion
2711
- //#region src/utils/options.ts
2712
- function resolveBooleanObjectOption(value, enabledValue) {
2713
- if (!value) return false;
2714
- if (value === true) return enabledValue;
2715
- return value;
2716
- }
2717
- function normalizeStringListOption(value) {
2718
- if (!value) return;
2719
- const values = typeof value === "string" ? [value] : Array.isArray(value) ? value : void 0;
2720
- if (!values) return;
2721
- const normalized = values.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
2722
- return normalized.length > 0 ? normalized : void 0;
2723
- }
2724
- //#endregion
2725
- //#region src/tailwindcss/runtime-options.ts
2726
- function resolveTailwindcssOptions(options) {
2727
- return options?.tailwindcss ?? options?.tailwind;
2728
- }
2729
- function normalizeExtendLengthUnits(value) {
2730
- if (value === void 0) return;
2731
- const resolved = resolveBooleanObjectOption(value, { enabled: true });
2732
- return resolved && typeof resolved === "object" ? {
2733
- enabled: true,
2734
- ...resolved
2735
- } : resolved;
2736
- }
2737
- function normalizeTailwindcssRuntimeOptions(options) {
2738
- return options;
2739
- }
2740
- //#endregion
2741
- //#region src/utils/object.ts
2742
- function definedEntries(value) {
2743
- return Object.entries(value).filter(([, item]) => item !== void 0);
2744
- }
2745
- function omitUndefined(value) {
2746
- return Object.fromEntries(definedEntries(value));
2747
- }
2748
- //#endregion
2749
- //#region src/context/workspace.ts
2750
- const IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
2751
- "node_modules",
2752
- ".git",
2753
- ".hg",
2754
- ".svn",
2755
- ".turbo",
2756
- ".output",
2757
- ".next",
2758
- "dist",
2759
- "build"
2760
- ]);
2761
- function findWorkspaceRoot(startDir) {
2762
- if (!startDir) return;
2763
- let current = path.resolve(startDir);
2764
- while (true) {
2765
- const workspaceFile = path.join(current, "pnpm-workspace.yaml");
2766
- if (existsSync(workspaceFile)) return current;
2767
- const parent = path.dirname(current);
2768
- if (parent === current) return;
2769
- current = parent;
2770
- }
2771
- }
2772
- function findNearestPackageRoot(startDir) {
2773
- if (!startDir) return;
2774
- let current = path.resolve(startDir);
2775
- while (true) {
2776
- const pkgPath = path.join(current, "package.json");
2777
- if (existsSync(pkgPath)) return current;
2778
- const parent = path.dirname(current);
2779
- if (parent === current) return;
2780
- current = parent;
2781
- }
2782
- }
2783
- function findWorkspacePackageDir(rootDir, packageName) {
2784
- const visited = /* @__PURE__ */ new Set();
2785
- const queue = [path.resolve(rootDir)];
2786
- while (queue.length > 0) {
2787
- const current = queue.shift();
2788
- const normalized = path.normalize(current);
2789
- if (visited.has(normalized)) continue;
2790
- visited.add(normalized);
2791
- try {
2792
- const pkgPath = path.join(normalized, "package.json");
2793
- if (existsSync(pkgPath)) {
2794
- if (JSON.parse(readFileSync(pkgPath, "utf8"))?.name === packageName) return normalized;
2795
- }
2796
- } catch {}
2797
- let entries;
2798
- try {
2799
- entries = readdirSync(normalized, { withFileTypes: true });
2800
- } catch {
2801
- continue;
2802
- }
2803
- for (const entry of entries) {
2804
- if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) continue;
2805
- queue.push(path.join(normalized, entry.name));
2806
- }
2807
- }
2808
- }
2809
- //#endregion
2810
- //#region src/tailwindcss/v4/css-entries.ts
2811
- const TAILWIND_V4_CSS_ENTRY_RE = /\.css(?:[?#].*)?$/i;
2812
- function isTailwindV4CssEntry(entry) {
2813
- return typeof entry === "string" && TAILWIND_V4_CSS_ENTRY_RE.test(entry.trim());
2814
- }
2815
- function guessBasedirFromEntries(entries) {
2816
- if (!entries) return;
2817
- for (const entry of entries) {
2818
- if (typeof entry !== "string") continue;
2819
- const trimmed = entry.trim();
2820
- if (!trimmed || !path.isAbsolute(trimmed)) continue;
2821
- if (!isTailwindV4CssEntry(trimmed)) continue;
2822
- const entryDir = path.dirname(trimmed);
2823
- const resolved = findNearestPackageRoot(entryDir) ?? entryDir;
2824
- if (resolved) return resolved;
2825
- }
2826
- }
2827
- function normalizeCssEntries(entries, anchor) {
2828
- if (!entries || entries.length === 0) return;
2829
- const normalized = /* @__PURE__ */ new Set();
2830
- for (const entry of entries) {
2831
- if (typeof entry !== "string") continue;
2832
- const trimmed = entry.trim();
2833
- if (trimmed.length === 0) continue;
2834
- if (!isTailwindV4CssEntry(trimmed)) continue;
2835
- const resolved = path.isAbsolute(trimmed) ? path.normalize(trimmed) : path.normalize(path.resolve(anchor, trimmed));
2836
- normalized.add(resolved);
2837
- }
2838
- return normalized.size > 0 ? [...normalized] : void 0;
2839
- }
2840
- function isSubPath(parent, child) {
2841
- if (!parent || !child) return false;
2842
- const relative = path.relative(parent, child);
2843
- return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
2844
- }
2845
- function resolveCssEntryBase(entryDir, options) {
2846
- const normalizedDir = path.normalize(entryDir);
2847
- const { preferredBaseDir, workspaceRoot } = options;
2848
- if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) return preferredBaseDir;
2849
- if (workspaceRoot && isSubPath(workspaceRoot, normalizedDir)) return workspaceRoot;
2850
- const packageRoot = findNearestPackageRoot(normalizedDir);
2851
- if (packageRoot) return path.normalize(packageRoot);
2852
- return normalizedDir;
2853
- }
2854
- function groupCssEntriesByBase(entries, options = {}) {
2855
- const normalizedOptions = {
2856
- preferredBaseDir: options.preferredBaseDir ? path.normalize(options.preferredBaseDir) : void 0,
2857
- workspaceRoot: options.workspaceRoot ? path.normalize(options.workspaceRoot) : void 0
2858
- };
2859
- const groups = /* @__PURE__ */ new Map();
2860
- for (const entry of entries) {
2861
- const baseDir = resolveCssEntryBase(path.dirname(entry), normalizedOptions);
2862
- const bucket = groups.get(baseDir);
2863
- if (bucket) bucket.push(entry);
2864
- else groups.set(baseDir, [entry]);
2865
- }
2866
- return groups;
2867
- }
2868
- //#endregion
2869
- //#region src/tailwindcss/v4/css-sources.ts
2870
- function hasCssEntriesValue(value) {
2871
- if (typeof value === "string") return isTailwindV4CssEntry(value);
2872
- return Array.isArray(value) && value.some(isTailwindV4CssEntry);
2873
- }
2874
- function hasCssSourcesValue(value) {
2875
- return Array.isArray(value) && value.some((source) => {
2876
- const file = source?.file;
2877
- return typeof source === "object" && source !== null && typeof file === "string" && isTailwindV4CssEntry(file) && typeof source.css === "string" && source.css.trim().length > 0;
2878
- });
2879
- }
2880
- function isTailwindV4CssSourceRoot(source) {
2881
- return typeof source === "object" && source !== null && typeof source.file === "string" && isTailwindV4CssEntry(source.file);
2882
- }
2883
- function filterTailwindV4CssSourceRoots(sources) {
2884
- const filtered = sources?.filter(isTailwindV4CssSourceRoot);
2885
- return filtered && filtered.length > 0 ? filtered : void 0;
2886
- }
2887
- function hasConfiguredTailwindV4CssRoots(options) {
2888
- return hasCssEntriesValue(options.cssEntries) || hasCssEntriesValue(options.tailwindcss?.v4?.cssEntries) || hasCssEntriesValue(options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries) || hasCssSourcesValue(options.tailwindcss?.v4?.cssSources) || hasCssSourcesValue(options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources);
2889
- }
2890
- function normalizeCssSourceFile(file) {
2891
- if (!file) return;
2892
- return path.isAbsolute(file) ? path.normalize(file) : file;
2893
- }
2894
- function normalizeCssSourceBase(base) {
2895
- if (!base) return;
2896
- return path.resolve(base);
2897
- }
2898
- function normalizeDependencies(dependencies) {
2899
- return dependencies?.map(normalizeCssSourceFile).filter((dependency) => typeof dependency === "string" && dependency.length > 0);
2900
- }
2901
- function isSameCssSource(a, b) {
2902
- return a.css === b.css && normalizeCssSourceBase(a.base) === normalizeCssSourceBase(b.base) && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
2903
- }
2904
- function upsertTailwindV4CssSource(opts, source) {
2905
- if (!isTailwindV4CssEntry(source.file)) return false;
2906
- const normalizedSource = omitUndefined({
2907
- ...source,
2908
- ...source.base === void 0 ? {} : { base: normalizeCssSourceBase(source.base) },
2909
- ...source.file === void 0 ? {} : { file: normalizeCssSourceFile(source.file) },
2910
- ...source.dependencies === void 0 ? {} : { dependencies: normalizeDependencies(source.dependencies) }
2911
- });
2912
- const tailwindcss = opts.tailwindcss ?? {};
2913
- const v4 = tailwindcss.v4 ?? {};
2914
- const cssSources = [...v4.cssSources ?? []];
2915
- const sourceFile = normalizeCssSourceFile(normalizedSource.file);
2916
- const existingIndex = cssSources.findIndex((candidate) => normalizeCssSourceFile(candidate.file) === sourceFile);
2917
- if (existingIndex >= 0) {
2918
- const existing = cssSources[existingIndex];
2919
- if (!existing) {
2920
- cssSources[existingIndex] = normalizedSource;
2921
- return true;
2922
- }
2923
- const nextSource = {
2924
- ...existing,
2925
- ...normalizedSource
2926
- };
2927
- if (isSameCssSource(existing, nextSource)) return false;
2928
- cssSources[existingIndex] = nextSource;
2929
- } else cssSources.push(normalizedSource);
2930
- opts.tailwindcss = {
2931
- ...tailwindcss,
2932
- v4: {
2933
- ...v4,
2934
- cssSources
2935
- }
2936
- };
2937
- return true;
2938
- }
2939
- function removeTailwindV4CssSource(opts, file) {
2940
- const tailwindcss = opts.tailwindcss;
2941
- const v4 = tailwindcss?.v4;
2942
- const cssSources = v4?.cssSources;
2943
- if (!cssSources || cssSources.length === 0) return false;
2944
- const sourceFile = normalizeCssSourceFile(file);
2945
- const nextCssSources = cssSources.filter((source) => normalizeCssSourceFile(source.file) !== sourceFile);
2946
- if (nextCssSources.length === cssSources.length) return false;
2947
- opts.tailwindcss = {
2948
- ...tailwindcss,
2949
- v4: {
2950
- ...v4,
2951
- cssSources: nextCssSources
2952
- }
2953
- };
2954
- return true;
2955
- }
2956
- //#endregion
2957
- //#region src/tailwindcss/v4-engine/source.ts
2958
- const require = createRequire(import.meta.url);
2959
- function isCssEntryPoint(file) {
2960
- return typeof file === "string" && path.basename(file) === "index.css" && existsSync(file);
2961
- }
2962
- function resolvePackageCssEntryPoint(specifier) {
2963
- try {
2964
- const resolved = require.resolve(specifier);
2965
- if (isCssEntryPoint(resolved)) return resolved;
2966
- } catch {}
2967
- const packageName = specifier.replace(/\/index\.css$/, "");
2968
- if (packageName !== "tailwindcss") return;
2969
- try {
2970
- const packageJson = require.resolve(`${packageName}/package.json`);
2971
- const cssEntry = path.resolve(path.dirname(packageJson), "index.css");
2972
- if (isCssEntryPoint(cssEntry)) return cssEntry;
2973
- } catch {}
2974
- try {
2975
- let current = path.dirname(require.resolve("@tailwindcss-mangle/engine"));
2976
- while (true) {
2977
- const cssEntry = path.resolve(current, "..", "tailwindcss", "index.css");
2978
- if (isCssEntryPoint(cssEntry)) return cssEntry;
2979
- const parent = path.dirname(current);
2980
- if (parent === current) break;
2981
- current = parent;
2982
- }
2983
- } catch {}
2984
- }
2985
- function isPostcssPluginImportTarget(value) {
2986
- if (!value) return false;
2987
- return value === "@tailwindcss/postcss" || value.includes("/postcss");
2988
- }
2989
- function uniqueDefined(values) {
2990
- return [...new Set(values.filter((value) => typeof value === "string" && value.length > 0))];
2991
- }
2992
- function resolveCssImportFile(base, specifier) {
2993
- const normalizedSpecifier = path.sep === "\\" ? specifier.replaceAll("/", "\\") : specifier.replaceAll("\\", "/");
2994
- return path.resolve(base, normalizedSpecifier);
2995
- }
2996
- function getProjectRoot(runtime) {
2997
- return runtime.options?.projectRoot ?? process.cwd();
2998
- }
2999
- function resolveBase(value, fallback) {
3000
- return value === void 0 ? fallback : path.isAbsolute(value) ? path.resolve(value) : path.resolve(fallback, value);
3001
- }
3002
- function resolveConfigDir(config, projectRoot) {
3003
- if (!config) return;
3004
- const configPath = path.isAbsolute(config) ? config : path.resolve(projectRoot, config);
3005
- return path.dirname(configPath);
3006
- }
3007
- function isBarePackageSpecifier(specifier) {
3008
- return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.startsWith("#") && !specifier.includes("\\") && !/^[a-z][a-z\d+.-]*:/i.test(specifier);
3009
- }
3010
- function isPackageJsonImportSpecifier(specifier) {
3011
- return typeof specifier === "string" && specifier.startsWith("#");
3012
- }
3013
- function createTailwindV4CssImportSpecifierSet(packageName) {
3014
- const specifiers = /* @__PURE__ */ new Set(["tailwindcss"]);
3015
- if (packageName && isBarePackageSpecifier(packageName)) specifiers.add(packageName);
3016
- return specifiers;
3017
- }
3018
- function normalizeTailwindV4CssPackageImports(css, packageName) {
3019
- if (!css.includes("tailwindcss")) return css;
3020
- let root;
3021
- try {
3022
- root = postcss.parse(css);
3023
- } catch {
3024
- return css;
3025
- }
3026
- const importSpecifiers = createTailwindV4CssImportSpecifierSet(packageName);
3027
- let changed = false;
3028
- root.walkAtRules((rule) => {
3029
- if (rule.name !== "import" && rule.name !== "reference") return;
3030
- const parsed = parseCssImportSpecifier(rule.params);
3031
- if (!parsed || !importSpecifiers.has(parsed.specifier)) return;
3032
- const cssEntryPoint = resolvePackageCssEntryPoint(`${parsed.specifier}/index.css`);
3033
- if (!cssEntryPoint) return;
3034
- rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(cssEntryPoint, parsed.quote));
3035
- changed = true;
3036
- });
3037
- return changed ? root.toString() : css;
3038
- }
3039
- function normalizeTailwindV4CssSources(cssSources, packageName, projectRoot) {
3040
- if (!cssSources?.length) return cssSources;
3041
- let changed = false;
3042
- const normalizedCssSources = cssSources.map((cssSource) => {
3043
- const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? path.isAbsolute(cssSource.file) ? path.resolve(cssSource.file) : path.resolve(projectRoot ?? process.cwd(), cssSource.file) : void 0;
3044
- const base = typeof cssSource.base === "string" && cssSource.base.length > 0 ? path.isAbsolute(cssSource.base) ? path.resolve(cssSource.base) : path.resolve(projectRoot ?? process.cwd(), cssSource.base) : file ? path.dirname(file) : void 0;
3045
- if (typeof cssSource.css !== "string") {
3046
- if (file === cssSource.file && base === cssSource.base) return cssSource;
3047
- changed = true;
3048
- return {
3049
- ...cssSource,
3050
- ...base === void 0 ? {} : { base },
3051
- ...file === void 0 ? {} : { file }
3052
- };
3053
- }
3054
- const configBase = base ?? projectRoot ?? process.cwd();
3055
- const css = normalizeTailwindV4CssPackageImports(normalizeEmptyTailwindCustomVariants(normalizeTailwindConfigDirectives(cssSource.css, configBase)), packageName);
3056
- if (css === cssSource.css && file === cssSource.file && base === cssSource.base) return cssSource;
3057
- changed = true;
3058
- return {
3059
- ...cssSource,
3060
- css,
3061
- ...base === void 0 ? {} : { base },
3062
- ...file === void 0 ? {} : { file }
3063
- };
3064
- });
3065
- return changed ? normalizedCssSources : cssSources;
3066
- }
3067
- function normalizeTailwindV4CssEntrySources(cssEntries, packageName) {
3068
- if (!cssEntries?.length) return;
3069
- const remainingCssEntries = [];
3070
- const cssSources = [];
3071
- const graphs = /* @__PURE__ */ new Map();
3072
- const collectCssGraph = (file, visiting = /* @__PURE__ */ new Set()) => {
3073
- const normalizedFile = path.resolve(file);
3074
- const cached = graphs.get(normalizedFile);
3075
- if (cached) return cached;
3076
- const graph = /* @__PURE__ */ new Set([normalizedFile]);
3077
- graphs.set(normalizedFile, graph);
3078
- if (visiting.has(normalizedFile) || !existsSync(normalizedFile)) return graph;
3079
- const nextVisiting = new Set(visiting).add(normalizedFile);
3080
- let root;
3081
- try {
3082
- root = postcss.parse(readFileSync(normalizedFile, "utf8"));
3083
- } catch {
3084
- return graph;
3085
- }
3086
- const base = path.dirname(normalizedFile);
3087
- root.walkAtRules("import", (rule) => {
3088
- const parsed = parseCssImportSpecifier(rule.params);
3089
- if (!parsed || !parsed.specifier.startsWith(".")) return;
3090
- const importedFile = resolveCssImportFile(base, parsed.specifier);
3091
- const resolved = (path.extname(importedFile) ? [importedFile] : [
3092
- importedFile,
3093
- `${importedFile}.css`,
3094
- `${importedFile}.pcss`,
3095
- `${importedFile}.scss`,
3096
- `${importedFile}.sass`
3097
- ]).find((candidate) => existsSync(candidate));
3098
- if (!resolved) return;
3099
- for (const dependency of collectCssGraph(resolved, nextVisiting)) graph.add(dependency);
3100
- });
3101
- return graph;
3102
- };
3103
- const createCssSource = (file, dependencies) => {
3104
- const normalizedFile = path.resolve(file);
3105
- const base = path.dirname(normalizedFile);
3106
- const rawCss = readFileSync(normalizedFile, "utf8");
3107
- const entrySource = resolveCssEntrySource(rawCss, base, { removeConfig: false });
3108
- return {
3109
- file: normalizedFile,
3110
- base,
3111
- css: normalizeTailwindV4CssPackageImports(normalizeEmptyTailwindCustomVariants(normalizeConfigDirective(rawCss, entrySource?.config && existsSync(entrySource.config) ? entrySource.config : entrySource?.configRequest && !path.isAbsolute(entrySource.configRequest) && !isPackageJsonImportSpecifier(entrySource.configRequest) ? path.resolve(base, entrySource.configRequest) : entrySource?.config)), packageName),
3112
- dependencies: [...dependencies]
3113
- };
3114
- };
3115
- const rootEntries = [];
3116
- for (const cssEntry of cssEntries) {
3117
- const normalizedCssEntry = cssEntry.replace(/[?#].*$/, "");
3118
- const file = path.resolve(normalizedCssEntry);
3119
- if (!existsSync(file)) {
3120
- remainingCssEntries.push(normalizedCssEntry);
3121
- continue;
3122
- }
3123
- rootEntries.push(file);
3124
- }
3125
- const entryGraphs = rootEntries.map((entry) => [entry, collectCssGraph(entry)]);
3126
- const nestedEntries = /* @__PURE__ */ new Set();
3127
- for (const [entry] of entryGraphs) for (const [otherEntry, otherGraph] of entryGraphs) if (entry !== otherEntry && otherGraph.has(entry)) {
3128
- nestedEntries.add(entry);
3129
- break;
3130
- }
3131
- const selectedEntries = entryGraphs.filter(([entry]) => !nestedEntries.has(entry));
3132
- const roots = selectedEntries.length > 0 ? selectedEntries : entryGraphs.slice(0, 1);
3133
- for (const [rootEntry, dependencies] of roots) cssSources.push(createCssSource(rootEntry, dependencies));
3134
- return {
3135
- cssEntries: remainingCssEntries,
3136
- cssSources
3137
- };
3138
- }
3139
- function normalizeTailwindV4SourceOptions(options) {
3140
- if (!options) return options;
3141
- const cssBase = resolveBase(options.base, options.projectRoot ?? options.cwd ?? process.cwd());
3142
- const css = options.css === void 0 ? void 0 : normalizeTailwindV4CssPackageImports(normalizeEmptyTailwindCustomVariants(normalizeTailwindConfigDirectives(options.css, cssBase)), options.packageName);
3143
- const entrySources = normalizeTailwindV4CssEntrySources(options.cssEntries, options.packageName);
3144
- const configuredCssSources = filterTailwindV4CssSourceRoots(options.cssSources);
3145
- const cssSources = normalizeTailwindV4CssSources(configuredCssSources || entrySources?.cssSources ? [...configuredCssSources ?? [], ...entrySources?.cssSources ?? []] : void 0, options.packageName, options.projectRoot);
3146
- const cssEntries = entrySources?.cssEntries ?? options.cssEntries;
3147
- if (css === options.css && cssSources === options.cssSources && cssEntries === options.cssEntries) return options;
3148
- return {
3149
- ...options,
3150
- ...css === void 0 ? {} : { css },
3151
- ...cssEntries === void 0 ? {} : { cssEntries },
3152
- ...cssSources === void 0 ? {} : { cssSources }
3153
- };
3154
- }
3155
- function resolveTailwindCssImportTarget(runtime) {
3156
- const configuredPackageName = resolveTailwindcssOptions(runtime.options)?.packageName;
3157
- if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
3158
- const packageName = runtime.packageInfo?.name;
3159
- if (typeof packageName === "string" && packageName.length > 0 && !isPostcssPluginImportTarget(packageName)) return packageName;
3160
- return "tailwindcss";
3161
- }
3162
- function readTailwindV4Options(runtime) {
3163
- return resolveTailwindcssOptions(runtime.options)?.v4 ?? runtime.options?.tailwind?.v4;
3164
- }
3165
- function isRawTailwindcssPatchOptions(options) {
3166
- return Boolean(options && "tailwindcss" in options);
3167
- }
3168
- function resolveEngineTailwindV4SourceOptions(runtime) {
3169
- if (runtime.options) {
3170
- const projectRoot = getProjectRoot(runtime);
3171
- const tailwindOptions = resolveTailwindcssOptions(runtime.options);
3172
- const tailwindV4Options = readTailwindV4Options(runtime);
3173
- const cwd = resolveBase(tailwindOptions?.cwd, projectRoot);
3174
- const configuredBase = tailwindV4Options?.configuredBase ?? (isRawTailwindcssPatchOptions(runtime.options) ? tailwindV4Options?.base : void 0);
3175
- const baseFallbacks = uniqueDefined([
3176
- configuredBase,
3177
- cwd,
3178
- projectRoot,
3179
- resolveConfigDir(tailwindOptions?.config, projectRoot)
3180
- ]);
3181
- return {
3182
- projectRoot,
3183
- cwd,
3184
- ...configuredBase === void 0 ? {} : { base: configuredBase },
3185
- baseFallbacks,
3186
- ...tailwindV4Options?.cssSources === void 0 ? {} : { cssSources: tailwindV4Options.cssSources },
3187
- ...tailwindV4Options?.cssEntries === void 0 ? {} : { cssEntries: tailwindV4Options.cssEntries },
3188
- packageName: resolveTailwindCssImportTarget(runtime)
3189
- };
3190
- }
3191
- return {
3192
- projectRoot: getProjectRoot(runtime),
3193
- packageName: resolveTailwindCssImportTarget(runtime)
3194
- };
3195
- }
3196
- function resolveTailwindV4SourceOptionsFromRuntime(runtime) {
3197
- const tailwindV4Options = readTailwindV4Options(runtime);
3198
- return normalizeTailwindV4SourceOptions(omitUndefined({
3199
- ...resolveEngineTailwindV4SourceOptions(runtime),
3200
- sources: tailwindV4Options?.sources
3201
- }));
3202
- }
3203
- function resolveTailwindV4Source$1(options) {
3204
- const normalizedOptions = normalizeTailwindV4SourceOptions(options);
3205
- return resolveTailwindV4Source(normalizedOptions);
3206
- }
3207
- function resolveTailwindV4SourceFromRuntimeOptions(options) {
3208
- const projectRoot = options?.projectRoot ?? process.cwd();
3209
- const tailwindOptions = options?.tailwindcss;
3210
- const v4Options = tailwindOptions?.v4;
3211
- return resolveTailwindV4Source$1({
3212
- projectRoot,
3213
- cwd: resolveBase(tailwindOptions?.cwd, projectRoot),
3214
- packageName: tailwindOptions?.packageName ?? "tailwindcss",
3215
- ...v4Options ?? {}
3216
- });
3217
- }
3218
- async function resolveTailwindV4SourceFromRuntime(runtime) {
3219
- return resolveTailwindV4Source$1(resolveTailwindV4SourceOptionsFromRuntime(runtime));
3220
- }
3221
- //#endregion
3222
- //#region src/runtime-branch/create-branch.ts
3223
- function createRuntimeBranch(base, platformFamily, options) {
3224
- const { context, tailwindcssVersion } = base;
3225
- return {
3226
- tailwindcssVersion,
3227
- generatorTarget: context.generatorTarget,
3228
- platformFamily,
3229
- platform: options.platform,
3230
- nativeAppPlatform: options.nativeAppPlatform,
3231
- isTailwindV4: tailwindcssVersion === 4,
3232
- isWeb: platformFamily === "web",
3233
- isMiniProgram: platformFamily === "mini-program",
3234
- isNativeApp: platformFamily === "native-app"
3235
- };
3236
- }
3237
- //#endregion
3238
- //#region src/runtime-branch/mini-program.ts
3239
- function createMiniProgramRuntimeBranch(base) {
3240
- const { context, uniUtsPlatform } = base;
3241
- return createRuntimeBranch(base, "mini-program", { platform: typeof context.platform === "string" && context.platform.length > 0 ? context.platform : uniUtsPlatform.isMp ? uniUtsPlatform.normalized : context.platform });
3242
- }
3243
- //#endregion
3244
- //#region src/utils/uni-platform.ts
3245
- function resolveUniUtsPlatform(value = process.env["UNI_UTS_PLATFORM"]) {
3246
- return resolveUniUtsPlatform$1(value);
3247
- }
3248
- //#endregion
3249
- //#region src/runtime-branch/platform.ts
3250
- function isRuntimeUniAppXEnabled(value) {
3251
- return value === true || typeof value === "object" && value?.enabled !== false;
3252
- }
3253
- function normalizeRuntimeUniUtsPlatform(value) {
3254
- return typeof value === "object" && value !== null ? value : resolveUniUtsPlatform(value);
3255
- }
3256
- function resolveNativeAppPlatform(platform) {
3257
- if (platform.isAppAndroid) return "android";
3258
- if (platform.isAppIos) return "ios";
3259
- if (platform.isAppHarmony) return "harmony";
3260
- return "unknown";
3261
- }
3262
- function resolveExplicitOrEnvPlatform(context, uniUtsPlatform) {
3263
- if (typeof context.platform === "string" && context.platform.length > 0) return context.platform;
3264
- return uniUtsPlatform.normalized;
3265
- }
3266
- //#endregion
3267
- //#region src/runtime-branch/native-app.ts
3268
- function createNativeAppRuntimeBranch(base) {
3269
- return createRuntimeBranch(base, "native-app", {
3270
- platform: resolveExplicitOrEnvPlatform(base.context, base.uniUtsPlatform),
3271
- nativeAppPlatform: resolveNativeAppPlatform(base.uniUtsPlatform)
3272
- });
3273
- }
3274
- //#endregion
3275
- //#region src/runtime-branch/tailwind-version.ts
3276
- function resolveTailwindcssBranchVersion(_majorVersion) {
3277
- return 4;
3278
- }
3279
- //#endregion
3280
- //#region src/runtime-branch/web.ts
3281
- function createWebRuntimeBranch(base) {
3282
- return createRuntimeBranch(base, "web", { platform: resolveExplicitOrEnvPlatform(base.context, base.uniUtsPlatform) });
3283
- }
3284
- //#endregion
3285
- //#region src/runtime-branch/index.ts
3286
- function shouldUseNativeAppBranch(base, uniUtsPlatform) {
3287
- return base.appType === "uni-app-x" && isRuntimeUniAppXEnabled(base.uniAppX) && uniUtsPlatform.isApp;
3288
- }
3289
- function resolveRuntimeBranch(context) {
3290
- const uniUtsPlatform = normalizeRuntimeUniUtsPlatform(context.uniUtsPlatform);
3291
- const base = {
3292
- context,
3293
- tailwindcssVersion: resolveTailwindcssBranchVersion(context.tailwindcssMajorVersion),
3294
- uniUtsPlatform
3295
- };
3296
- if (context.generatorTarget === "web") return createWebRuntimeBranch(base);
3297
- if (shouldUseNativeAppBranch(context, uniUtsPlatform)) return createNativeAppRuntimeBranch(base);
3298
- return createMiniProgramRuntimeBranch(base);
3299
- }
3300
- function resolveGeneratorRuntimeBranch(options, context = {}) {
3301
- return options.branch ?? resolveRuntimeBranch({
3302
- ...context,
3303
- generatorTarget: options.target
3304
- });
3305
- }
3306
- function shouldUseMiniProgramCssBranch(branch) {
3307
- return branch.platformFamily === "mini-program" || branch.platformFamily === "native-app";
3308
- }
3309
- function shouldUseNativeAppCssBranch(branch) {
3310
- return branch.platformFamily === "native-app";
3311
- }
3312
- //#endregion
3313
- //#region src/generator/options.ts
3314
- function normalizeWeappTailwindcssGeneratorOptions(options, context = {}) {
3315
- const enabled = options !== false;
3316
- const objectOptions = enabled ? options : void 0;
3317
- const target = objectOptions?.target ?? (shouldUseUniAppViteWebViewGeneratorTarget(context.appType, context.platform) ? "web" : inferGeneratorTargetFromEnv());
3318
- const branch = resolveRuntimeBranch({
3319
- ...context,
3320
- generatorTarget: target
3321
- });
3322
- const hasExplicitTarget = objectOptions !== void 0 && Object.hasOwn(objectOptions, "target");
3323
- const webCompat = objectOptions?.webCompat ?? (!hasExplicitTarget && branch.isWeb ? true : void 0);
3324
- if (objectOptions == null) return {
3325
- enabled,
3326
- target,
3327
- branch,
3328
- webCompat,
3329
- hmr: { preserveDeletedCss: true },
3330
- importFallback: false,
3331
- bareArbitraryValues: void 0
3332
- };
3333
- return {
3334
- enabled,
3335
- target,
3336
- branch,
3337
- config: objectOptions.config,
3338
- styleOptions: objectOptions.styleOptions,
3339
- webCompat,
3340
- hmr: { preserveDeletedCss: objectOptions.hmr?.preserveDeletedCss ?? true },
3341
- importFallback: objectOptions.importFallback ?? false,
3342
- bareArbitraryValues: objectOptions.bareArbitraryValues
3343
- };
3344
- }
3345
- //#endregion
3346
- //#region src/generator/index.ts
3347
- function createWeappTailwindcssGenerator(source) {
3348
- return createTailwindV4Engine$1(source);
3349
- }
3350
- async function resolveTailwindSourceFromRuntime(tailwindRuntime) {
3351
- return resolveTailwindV4SourceFromRuntime(tailwindRuntime);
3352
- }
3353
- async function createWeappTailwindcssGeneratorFromRuntime(tailwindRuntime) {
3354
- return createWeappTailwindcssGenerator(await resolveTailwindSourceFromRuntime(tailwindRuntime));
3355
- }
3356
- //#endregion
3357
- export { hasTailwindRootDirectives as $, resolveBooleanObjectOption as A, resolveTailwindV4CssSourceBase as At, removeUnsupportedMiniProgramAtRules as B, shouldUseUniAppWebRpxCompatibility as Bt, findWorkspacePackageDir as C, expandTailwindSourceEntries as Ct, normalizeTailwindcssRuntimeOptions as D, parseConfigParam as Dt, normalizeExtendLengthUnits as E, normalizeLegacyContentEntries as Et, stripTailwindSourceMediaFragments as F, transformTailwindV4CssByTarget as Ft, shouldFilterApplyOnlyGeneratedCss as G, removeTailwindV4GeneratedUserCssArtifacts as H, resolveValidTailwindV4Candidates$1 as Ht, stripUnmatchedTailwindSourceMediaCloseFragments as I, transformTailwindV4CssToWeapp as It, splitUserCssLayerBlocks as J, extractGeneratedCssForUserLayerSelectors as K, finalizeMiniProgramCss$1 as L, resolveCssMacroTailwindV4Source as Lt, isCommentOnlyCss as M, _defineProperty as Mt, removeMiniProgramInteractiveSelectors as N, parseCssImportSpecifier as Nt, resolveTailwindcssOptions as O, resolveCssSourceEntries as Ot, removeTailwindV4GeneratorAtRules as P, quoteCssImportSpecifier as Pt, hasTailwindNonRootGenerationDirectives as Q, hasMiniProgramCssSpecificityPlaceholders as R, getTailwindV4IncrementalGenerateCacheStats as Rt, findNearestPackageRoot as S, FULL_SOURCE_SCAN_PATTERN as St, omitUndefined as T, isFileMatchedByTailwindSourceEntries as Tt, filterApplyOnlyGeneratedCss as U, stripMiniProgramCssSpecificityPlaceholders as V, loadTailwindV4DesignSystem as Vt, normalizeEmptyTailwindCustomVariants as W, hasLocalCssImport as X, preferScopedGeneratedCssRules as Y, hasTailwindApplyDirective as Z, upsertTailwindV4CssSource as _, stripTailwindBanners as _t, resolveGeneratorRuntimeBranch as a, removeTailwindSourceDirectives as at, isTailwindV4CssEntry as b, createTailwindV4Engine$1 as bt, shouldUseNativeAppCssBranch as c, VITE_MARKER_RE as ct, resolveTailwindV4SourceFromRuntime as d, hasTailwindGeneratedCssMarkers as dt, hasTailwindSourceDirectives as et, resolveTailwindV4SourceFromRuntimeOptions as f, splitGeneratorPlaceholderCssBySourceOrder as ft, removeTailwindV4CssSource as g, stripTailwindBanner as gt, hasConfiguredTailwindV4CssRoots as h, stripGeneratorPlaceholderMarkers as ht, normalizeWeappTailwindcssGeneratorOptions as i, parseImportRequest as it, transformGeneratorUserCss as j, toPosixPath as jt, normalizeStringListOption as k, resolveSourceScanPath as kt, resolveUniUtsPlatform as l, createCssAppend as lt, filterTailwindV4CssSourceRoots as m, splitTailwindV4GeneratedCssBySourceOrder as mt, createWeappTailwindcssGeneratorFromRuntime as n, normalizeTailwindSourceDirectives as nt, resolveRuntimeBranch as o, resolveCssEntrySource as ot, resolveTailwindV4SourceOptionsFromRuntime as p, splitTailwindGeneratedCssByBanner as pt, hasUserCssLayerBlocks as q, resolveTailwindSourceFromRuntime as r, normalizeTailwindSourceForGenerator as rt, shouldUseMiniProgramCssBranch as s, GENERATOR_PLACEHOLDER_MARKER_RE as st, createWeappTailwindcssGenerator as t, normalizeTailwindConfigDirectives as tt, resolveTailwindV4Source$1 as u, hasTailwindGeneratedCss as ut, groupCssEntriesByBase as v, normalizeConfigDirective as vt, findWorkspaceRoot as w, isFileExcludedByTailwindSourceEntries as wt, normalizeCssEntries as x, FULL_SOURCE_SCAN_EXTENSION_RE as xt, guessBasedirFromEntries as y, prependConfigDirective as yt, pruneMiniProgramGeneratedCss as z, filterUnsupportedMiniProgramTailwindV4Candidates as zt };