weapp-tailwindcss 5.1.16 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/README.en.md +6 -0
  2. package/README.md +6 -0
  3. package/bin/{weapp-tailwindcss.js → weapp-tailwindcss.cjs} +1 -1
  4. package/dist/bundlers/framework-selector.d.ts +2 -2
  5. package/dist/bundlers/gulp/asset-emission-plan.d.ts +10 -0
  6. package/dist/bundlers/gulp/frameworks/native/index.d.ts +10 -3
  7. package/dist/bundlers/gulp/index.d.ts +10 -3
  8. package/dist/bundlers/gulp/module-graph.d.ts +1 -1
  9. package/dist/bundlers/gulp/runtime-snapshot.d.ts +4 -2
  10. package/dist/bundlers/gulp/shared/create-native-framework-plugins/cache-state.d.ts +4 -4
  11. package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +5 -3
  12. package/dist/bundlers/gulp/shared/create-native-framework-plugins.d.ts +9 -2
  13. package/dist/bundlers/rspack/index.d.ts +2 -2
  14. package/dist/bundlers/shared/cache.d.ts +1 -1
  15. package/dist/bundlers/shared/css-imports.d.ts +1 -1
  16. package/dist/bundlers/shared/css-source-trace.d.ts +2 -2
  17. package/dist/bundlers/shared/framework-postcss.d.ts +9 -2
  18. package/dist/bundlers/shared/generator-css/candidates.d.ts +2 -0
  19. package/dist/bundlers/shared/generator-css/generation-helpers/preflight.d.ts +4 -3
  20. package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +3 -3
  21. package/dist/bundlers/shared/generator-css/generation-helpers/runtime-isolation.d.ts +4 -4
  22. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +4 -4
  23. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +2 -2
  24. package/dist/bundlers/shared/generator-css/pipeline/context.d.ts +58 -0
  25. package/dist/bundlers/shared/generator-css/pipeline/deferred-output.d.ts +3 -14
  26. package/dist/bundlers/shared/generator-css/pipeline/execution.d.ts +3 -12
  27. package/dist/bundlers/shared/generator-css/pipeline/fallback-output.d.ts +3 -12
  28. package/dist/bundlers/shared/generator-css/pipeline/ordered-output.d.ts +3 -25
  29. package/dist/bundlers/shared/generator-css/pipeline.d.ts +1 -1
  30. package/dist/bundlers/shared/generator-css/result-helpers.d.ts +2 -2
  31. package/dist/bundlers/shared/generator-css/source-resolver/configuration.d.ts +3 -4
  32. package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +1 -1
  33. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +13 -5
  34. package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +1 -1
  35. package/dist/bundlers/shared/generator-css/source-resolver/resolve-source.d.ts +3 -3
  36. package/dist/bundlers/shared/generator-css/source-resolver/resolve-sources.d.ts +4 -3
  37. package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +9 -9
  38. package/dist/bundlers/shared/generator-css/source-resolver/source-entries.d.ts +3 -3
  39. package/dist/bundlers/shared/generator-css/source-resolver/source-matching.d.ts +4 -4
  40. package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +4 -4
  41. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +7 -6
  42. package/dist/bundlers/shared/generator-css/types.d.ts +12 -3
  43. package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +1 -1
  44. package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -5
  45. package/dist/bundlers/shared/generator-css/validate.d.ts +1 -1
  46. package/dist/bundlers/shared/generator-css.d.ts +9 -9
  47. package/dist/bundlers/shared/runtime-class-set/entries.d.ts +4 -0
  48. package/dist/bundlers/shared/runtime-class-set/escaped-candidates.d.ts +9 -0
  49. package/dist/bundlers/shared/runtime-class-set.d.ts +30 -0
  50. package/dist/bundlers/shared/runtime-entry-type.d.ts +8 -0
  51. package/dist/bundlers/shared/runtime-signatures.d.ts +8 -0
  52. package/dist/bundlers/shared/source-candidate-scan-signature.d.ts +13 -0
  53. package/dist/bundlers/{vite → shared}/source-candidates/collector.d.ts +1 -1
  54. package/dist/bundlers/shared/source-candidates/scan-root.d.ts +10 -0
  55. package/dist/bundlers/{vite → shared}/source-candidates/script.d.ts +1 -1
  56. package/dist/bundlers/{vite → shared}/source-candidates/store.d.ts +1 -1
  57. package/dist/bundlers/{vite → shared}/source-candidates/types-and-cache.d.ts +3 -3
  58. package/dist/bundlers/shared/source-candidates.d.ts +4 -0
  59. package/dist/bundlers/shared/source-scan/css-entries.d.ts +18 -0
  60. package/dist/bundlers/shared/source-scan.d.ts +16 -0
  61. package/dist/bundlers/shared/static-config-content.d.ts +5 -0
  62. package/dist/bundlers/shared/v4-generation-core.d.ts +8 -3
  63. package/dist/bundlers/vite/bundle-entries.d.ts +1 -1
  64. package/dist/bundlers/vite/bundle-state.d.ts +11 -38
  65. package/dist/bundlers/vite/css-asset-identity.d.ts +11 -0
  66. package/dist/bundlers/vite/css-finalizer/options.d.ts +3 -3
  67. package/dist/bundlers/vite/css-finalizer/plugin.d.ts +1 -1
  68. package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
  69. package/dist/bundlers/vite/css-memory.d.ts +1 -2
  70. package/dist/bundlers/vite/frameworks/generic/index.d.ts +2 -2
  71. package/dist/bundlers/vite/frameworks/taro/index.d.ts +2 -2
  72. package/dist/bundlers/vite/frameworks/uni-app/index.d.ts +3 -3
  73. package/dist/bundlers/vite/frameworks/uni-app-x/index.d.ts +3 -3
  74. package/dist/bundlers/vite/frameworks/weapp-vite/index.d.ts +2 -2
  75. package/dist/bundlers/vite/generate-bundle/asset-emission-plan.d.ts +8 -0
  76. package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +4 -4
  77. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
  78. package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +1 -1
  79. package/dist/bundlers/vite/generate-bundle/css-cache-task.d.ts +34 -0
  80. package/dist/bundlers/vite/generate-bundle/css-composition-plan.d.ts +58 -0
  81. package/dist/bundlers/vite/generate-bundle/css-config-directives.d.ts +1 -1
  82. package/dist/bundlers/vite/generate-bundle/css-entry-processing.d.ts +1 -0
  83. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -1
  84. package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +21 -2
  85. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +1 -1
  86. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -1
  87. package/dist/bundlers/vite/generate-bundle/css-source-plan.d.ts +19 -0
  88. package/dist/bundlers/vite/generate-bundle/css-transform-decision-plan.d.ts +61 -0
  89. package/dist/bundlers/vite/generate-bundle/css-transform-result.d.ts +23 -0
  90. package/dist/bundlers/vite/generate-bundle/css-transform-task.d.ts +42 -0
  91. package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +3 -2
  92. package/dist/bundlers/vite/generate-bundle/finalize/bundle.d.ts +1 -1
  93. package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +5 -5
  94. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +2 -2
  95. package/dist/bundlers/vite/generate-bundle/html-processing.d.ts +2 -2
  96. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +1 -1
  97. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +2 -1
  98. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +2 -2
  99. package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +6 -5
  100. package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +1 -1
  101. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +1 -1
  102. package/dist/bundlers/vite/generate-bundle/remembered-css-plan.d.ts +35 -0
  103. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +5 -6
  104. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +2 -2
  105. package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +20 -0
  106. package/dist/bundlers/vite/generate-bundle/runtime-configured-css.d.ts +54 -0
  107. package/dist/bundlers/vite/generate-bundle/runtime-linked-css.d.ts +1 -1
  108. package/dist/bundlers/vite/generate-bundle/runtime-linked-source-memory.d.ts +3 -3
  109. package/dist/bundlers/vite/{generate-bundle-runtime.d.ts → generate-bundle/runtime.d.ts} +4 -4
  110. package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +2 -2
  111. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -2
  112. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +1 -8
  113. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +3 -3
  114. package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +5 -0
  115. package/dist/bundlers/vite/generate-bundle/subpackages.d.ts +2 -2
  116. package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +14 -1
  117. package/dist/bundlers/vite/generate-bundle/transform-filter.d.ts +1 -1
  118. package/dist/bundlers/vite/generate-bundle/transform-scheduling.d.ts +1 -0
  119. package/dist/bundlers/vite/generate-bundle/types.d.ts +8 -7
  120. package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +3 -2
  121. package/dist/bundlers/vite/generate-bundle/validate-runtime-candidates.d.ts +22 -0
  122. package/dist/bundlers/vite/generate-bundle.d.ts +6 -6
  123. package/dist/bundlers/vite/incremental-runtime-class-set/entries.d.ts +1 -4
  124. package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -3
  125. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +2 -30
  126. package/dist/bundlers/vite/index.d.ts +3 -3
  127. package/dist/bundlers/vite/js-precheck.d.ts +1 -1
  128. package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +2 -1
  129. package/dist/bundlers/vite/processed-css-assets/collector.d.ts +1 -1
  130. package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +1 -1
  131. package/dist/bundlers/vite/processed-css-assets/empty-at-rule.d.ts +1 -0
  132. package/dist/bundlers/vite/processed-css-assets/injection-plan.d.ts +4 -4
  133. package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +5 -5
  134. package/dist/bundlers/vite/processed-css-assets.d.ts +4 -4
  135. package/dist/bundlers/vite/resolve-app-type.d.ts +1 -1
  136. package/dist/bundlers/vite/rewrite-css-imports.d.ts +3 -2
  137. package/dist/bundlers/vite/runtime-affecting-signature.d.ts +1 -2
  138. package/dist/bundlers/vite/runtime-candidate-entry.d.ts +9 -0
  139. package/dist/bundlers/vite/runtime-class-set.d.ts +4 -4
  140. package/dist/bundlers/vite/serve-css-generation.d.ts +2 -1
  141. package/dist/bundlers/vite/serve-js-transform.d.ts +1 -1
  142. package/dist/bundlers/vite/serve-root-import-shell.d.ts +1 -1
  143. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +7 -7
  144. package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +45 -0
  145. package/dist/bundlers/vite/shared/framework-post-plugin.d.ts +2 -0
  146. package/dist/bundlers/vite/shared/framework-processed-css-registry.d.ts +22 -0
  147. package/dist/bundlers/vite/shared/framework-runtime-options.d.ts +1 -0
  148. package/dist/bundlers/vite/shared/framework-source-candidates-plugin.d.ts +2 -0
  149. package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +38 -0
  150. package/dist/bundlers/vite/shared/framework-strategy.d.ts +4 -4
  151. package/dist/bundlers/vite/source-candidate-scan-signature.d.ts +2 -13
  152. package/dist/bundlers/vite/source-candidates/scan-root.d.ts +1 -10
  153. package/dist/bundlers/vite/source-candidates.d.ts +1 -4
  154. package/dist/bundlers/vite/source-output-relations.d.ts +24 -0
  155. package/dist/bundlers/vite/source-scan/css-entries.d.ts +2 -18
  156. package/dist/bundlers/vite/source-scan.d.ts +2 -16
  157. package/dist/bundlers/vite/static-config-content.d.ts +1 -5
  158. package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
  159. package/dist/bundlers/vite/web-css-compat.d.ts +1 -1
  160. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/asset-emission-plan.d.ts +18 -0
  161. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +2 -2
  162. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/finalize-assets.d.ts +1 -1
  163. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-task.d.ts +1 -1
  164. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +11 -41
  165. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/html-js-tasks.d.ts +1 -1
  166. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/js-module-graph.d.ts +4 -10
  167. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.d.ts +4 -4
  168. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/memory-trace.d.ts +3 -3
  169. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/preflight-runtime.d.ts +6 -6
  170. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/resources.d.ts +2 -2
  171. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.d.ts +4 -4
  172. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.d.ts +1 -1
  173. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +9 -9
  174. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +3 -3
  175. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-refresh.d.ts +3 -3
  176. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +2 -2
  177. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -4
  178. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +2 -2
  179. package/dist/bundlers/webpack/frameworks/generic/index.d.ts +2 -2
  180. package/dist/bundlers/webpack/frameworks/index.d.ts +7 -7
  181. package/dist/bundlers/webpack/frameworks/mpx/index.d.ts +2 -2
  182. package/dist/bundlers/webpack/frameworks/taro/index.d.ts +2 -2
  183. package/dist/bundlers/webpack/frameworks/uni-app/index.d.ts +2 -2
  184. package/dist/bundlers/webpack/frameworks/weapp-vite/index.d.ts +2 -2
  185. package/dist/bundlers/webpack/index.d.ts +1 -1
  186. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +2 -2
  187. package/dist/bundlers/webpack/loaders/weapp-tw-css-generation-loader.d.ts +1 -1
  188. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +1 -1
  189. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +1 -1
  190. package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +4 -4
  191. package/dist/bundlers/webpack/shared/create-framework-plugin.d.ts +3 -3
  192. package/dist/cli/context.d.ts +2 -2
  193. package/dist/cli/doctor.d.ts +1 -1
  194. package/dist/cli/helpers/options.d.ts +3 -3
  195. package/dist/cli/helpers.d.ts +1 -1
  196. package/dist/cli.cjs +37012 -0
  197. package/dist/cli.js +141 -168
  198. package/dist/compiler/artifact.d.ts +14 -0
  199. package/dist/compiler/candidate-index.d.ts +10 -0
  200. package/dist/compiler/compilation-change-coordinator.d.ts +28 -0
  201. package/dist/compiler/compilation-dependency-state.d.ts +16 -0
  202. package/dist/compiler/compilation-scope-graph.d.ts +31 -0
  203. package/dist/compiler/compilation-session-pool.d.ts +54 -0
  204. package/dist/compiler/compiler-owner-state.d.ts +3 -0
  205. package/dist/compiler/composition.d.ts +8 -0
  206. package/dist/compiler/emission-plan.d.ts +26 -0
  207. package/dist/compiler/index.d.ts +23 -0
  208. package/dist/compiler/invalidation.d.ts +3 -0
  209. package/dist/compiler/mode.d.ts +3 -0
  210. package/dist/compiler/owner-lifecycle.d.ts +1 -0
  211. package/dist/compiler/platform-adapter.d.ts +9 -0
  212. package/dist/compiler/runtime-affecting-signature.d.ts +2 -0
  213. package/dist/compiler/runtime-build-state.d.ts +6 -0
  214. package/dist/compiler/runtime-snapshot.d.ts +53 -0
  215. package/dist/compiler/scope-planner.d.ts +6 -0
  216. package/dist/compiler/semantic-css.d.ts +66 -0
  217. package/dist/compiler/session.d.ts +13 -0
  218. package/dist/compiler/shadow-gate.d.ts +26 -0
  219. package/dist/compiler/shadow-report-session.d.ts +37 -0
  220. package/dist/compiler/shadow-report.d.ts +15 -0
  221. package/dist/compiler/source-graph.d.ts +32 -0
  222. package/dist/compiler/tailwind-generation-session-pool.d.ts +22 -0
  223. package/dist/compiler/types.d.ts +95 -0
  224. package/dist/constants.d.ts +2 -2
  225. package/dist/context/compiler-context-cache.d.ts +1 -1
  226. package/dist/context/custom-attributes.d.ts +1 -1
  227. package/dist/context/handlers.d.ts +3 -3
  228. package/dist/context/index.d.ts +1 -1
  229. package/dist/context/runtime-package-replacements.d.ts +1 -1
  230. package/dist/context/style-options.d.ts +1 -1
  231. package/dist/context/tailwindcss.d.ts +3 -3
  232. package/dist/{context-BtLIID4m.js → context-PZXBqrAJ.cjs} +31 -93
  233. package/dist/{context-JzwzSX36.mjs → context-oTkxC5aZ.js} +22 -11
  234. package/dist/{core.mjs → core.cjs} +13 -12
  235. package/dist/core.d.ts +2 -2
  236. package/dist/core.js +12 -13
  237. package/dist/css-imports-DfNC3e6a.cjs +43 -0
  238. package/dist/css-loader-runtime-CSv0lKqV.cjs +11 -0
  239. package/dist/css-macro/postcss.cjs +19 -0
  240. package/dist/css-macro/postcss.js +2 -19
  241. package/dist/{css-macro.mjs → css-macro.cjs} +11 -8
  242. package/dist/css-macro.d.ts +2 -2
  243. package/dist/css-macro.js +8 -11
  244. package/dist/{defaults.mjs → defaults.cjs} +16 -11
  245. package/dist/defaults.d.ts +1 -1
  246. package/dist/defaults.js +11 -16
  247. package/dist/{escape.mjs → escape.cjs} +18 -4
  248. package/dist/escape.js +4 -18
  249. package/dist/framework/platform.d.ts +1 -1
  250. package/dist/{framework.mjs → framework.cjs} +47 -25
  251. package/dist/framework.d.ts +1 -1
  252. package/dist/framework.js +25 -47
  253. package/dist/generator/index.d.ts +6 -6
  254. package/dist/generator/options.d.ts +3 -3
  255. package/dist/generator/types.d.ts +2 -2
  256. package/dist/{generator-B91GhUJQ.js → generator-C8D5cnbe.cjs} +164 -33
  257. package/dist/{generator-Bv7myuhY.mjs → generator-CDdzqf1S.js} +155 -30
  258. package/dist/generator.cjs +12 -0
  259. package/dist/generator.d.ts +1 -1
  260. package/dist/generator.js +2 -12
  261. package/dist/{gulp-Q1wITegn.js → gulp-Cjcss8T_.cjs} +157 -103
  262. package/dist/{gulp-CKSklPlH.mjs → gulp-DNXQvDUw.js} +141 -90
  263. package/dist/gulp.cjs +5 -0
  264. package/dist/gulp.d.ts +4 -4
  265. package/dist/gulp.js +2 -5
  266. package/dist/{hmr-timing-BXg7nI8N.mjs → hmr-timing-CuJwQzDc.js} +3824 -1988
  267. package/dist/hmr-timing-DMLfNfGG.cjs +555 -0
  268. package/dist/index.cjs +45 -0
  269. package/dist/index.d.ts +9 -9
  270. package/dist/index.js +9 -45
  271. package/dist/js/JsTokenUpdater.d.ts +1 -1
  272. package/dist/js/ModuleGraph.d.ts +3 -3
  273. package/dist/js/NodePathWalker.d.ts +2 -2
  274. package/dist/js/babel/process.d.ts +2 -2
  275. package/dist/js/babel.d.ts +8 -8
  276. package/dist/js/evalTransforms.d.ts +2 -2
  277. package/dist/js/fast-path/oxc.d.ts +1 -1
  278. package/dist/js/handlers.d.ts +2 -2
  279. package/dist/js/index.d.ts +3 -3
  280. package/dist/js/literal-transform.d.ts +1 -1
  281. package/dist/js/module-graph/ignored-exports.d.ts +4 -4
  282. package/dist/js/module-graph/types.d.ts +2 -2
  283. package/dist/js/node-path-walker/export-handlers.d.ts +1 -1
  284. package/dist/js/precheck.d.ts +1 -1
  285. package/dist/js/replacement-cache.d.ts +1 -1
  286. package/dist/js/sourceAnalysis.d.ts +3 -3
  287. package/dist/js/taggedTemplateIgnore.d.ts +1 -1
  288. package/dist/object-Bvy6-w9r.js +47 -0
  289. package/dist/object-C_Vr6_S5.cjs +58 -0
  290. package/dist/options-DlvhQwWB.cjs +775 -0
  291. package/dist/pipeline-helpers-XtUmUlci.cjs +955 -0
  292. package/dist/postcss-html-transform.cjs +7 -0
  293. package/dist/postcss-html-transform.js +3 -5
  294. package/dist/postcss.cjs +15 -0
  295. package/dist/postcss.js +7 -11
  296. package/dist/presets/hbuilderx.d.ts +2 -2
  297. package/dist/presets/index.d.ts +4 -4
  298. package/dist/presets/shared.d.ts +1 -1
  299. package/dist/presets/taro.d.ts +2 -2
  300. package/dist/presets/uni-app-x.d.ts +1 -1
  301. package/dist/presets/uni-app.d.ts +2 -2
  302. package/dist/{presets.mjs → presets.cjs} +37 -24
  303. package/dist/presets.d.ts +1 -1
  304. package/dist/presets.js +24 -36
  305. package/dist/reset.cjs +19 -0
  306. package/dist/reset.d.ts +2 -2
  307. package/dist/reset.js +2 -19
  308. package/dist/{rolldown-runtime-emK7D4bc.js → rolldown-runtime-CVvi-lCc.cjs} +15 -0
  309. package/dist/{rspack.mjs → rspack.cjs} +10 -4
  310. package/dist/rspack.d.ts +3 -3
  311. package/dist/rspack.js +4 -10
  312. package/dist/runtime-branch/create-branch.d.ts +1 -1
  313. package/dist/runtime-branch/generator-target-env.d.ts +1 -1
  314. package/dist/runtime-branch/index.d.ts +2 -2
  315. package/dist/runtime-branch/mini-program.d.ts +1 -1
  316. package/dist/runtime-branch/native-app.d.ts +1 -1
  317. package/dist/runtime-branch/platform.d.ts +2 -2
  318. package/dist/runtime-branch/tailwind-version.d.ts +1 -1
  319. package/dist/runtime-branch/types.d.ts +2 -2
  320. package/dist/runtime-branch/web.d.ts +1 -1
  321. package/dist/runtime-branch.d.ts +1 -1
  322. package/dist/runtime-registry-Y7NrD2WH.cjs +31 -0
  323. package/dist/shared/classname-transform.d.ts +1 -1
  324. package/dist/shared/mpx.d.ts +1 -1
  325. package/dist/source-candidate-scan-signature-B0S7f5P7.js +421 -0
  326. package/dist/source-candidate-scan-signature-BmSuoxR9.cjs +555 -0
  327. package/dist/style-injector/internal.d.ts +6 -6
  328. package/dist/style-options-CEfXwZzX.cjs +75 -0
  329. package/dist/tailwindcss/candidates.d.ts +2 -2
  330. package/dist/tailwindcss/index.d.ts +1 -1
  331. package/dist/tailwindcss/runtime/cache.d.ts +1 -1
  332. package/dist/tailwindcss/runtime-factory.d.ts +2 -2
  333. package/dist/tailwindcss/runtime-options.d.ts +1 -1
  334. package/dist/tailwindcss/runtime-types.d.ts +2 -2
  335. package/dist/tailwindcss/runtime.d.ts +2 -2
  336. package/dist/tailwindcss/source-scan.d.ts +2 -2
  337. package/dist/tailwindcss/targets.d.ts +1 -1
  338. package/dist/tailwindcss/v4/config.d.ts +1 -1
  339. package/dist/tailwindcss/v4/css-sources.d.ts +2 -1
  340. package/dist/tailwindcss/v4/index.d.ts +2 -2
  341. package/dist/tailwindcss/v4/multi-runtime.d.ts +1 -1
  342. package/dist/tailwindcss/v4/runtime-factory.d.ts +5 -5
  343. package/dist/tailwindcss/v4/runtime-options.d.ts +1 -1
  344. package/dist/tailwindcss/v4-engine/css-macro-source.d.ts +1 -1
  345. package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
  346. package/dist/tailwindcss/v4-engine/generator/engine.d.ts +1 -1
  347. package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +4 -5
  348. package/dist/tailwindcss/v4-engine/generator/native-session.d.ts +17 -0
  349. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +2 -1
  350. package/dist/tailwindcss/v4-engine/generator.d.ts +2 -2
  351. package/dist/tailwindcss/v4-engine/index.d.ts +5 -5
  352. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +2 -2
  353. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  354. package/dist/tailwindcss/v4-engine/types.d.ts +1 -0
  355. package/dist/{tailwindcss-B4phC0kB.js → tailwindcss-Cs94gJgf.cjs} +9 -769
  356. package/dist/{tailwindcss-BTcXX8Ka.mjs → tailwindcss-D7TGiZR2.js} +22 -22
  357. package/dist/transform-BUEyOCT7.cjs +341 -0
  358. package/dist/transform-BbaPIji9.js +342 -0
  359. package/dist/typedoc.export.d.ts +4 -4
  360. package/dist/types/index.d.ts +7 -7
  361. package/dist/types/shared.d.ts +1 -1
  362. package/dist/types/typedoc-tailwindcss-runtime.d.ts +3 -3
  363. package/dist/types/user-defined-options/general.d.ts +5 -5
  364. package/dist/types/user-defined-options/important.d.ts +2 -2
  365. package/dist/types/user-defined-options/index.d.ts +9 -9
  366. package/dist/types/user-defined-options/matcher.d.ts +2 -2
  367. package/dist/types.cjs +0 -0
  368. package/dist/types.d.ts +1 -1
  369. package/dist/types.js +1 -0
  370. package/dist/uni-app-x/harmony.d.ts +1 -0
  371. package/dist/uni-app-x/index.d.ts +2 -2
  372. package/dist/uni-app-x/options.d.ts +1 -1
  373. package/dist/uni-app-x/style-asset/harmony-apply.d.ts +1 -0
  374. package/dist/uni-app-x/style-asset/style-value.d.ts +3 -0
  375. package/dist/uni-app-x/style-asset.d.ts +5 -4
  376. package/dist/uni-app-x/transform.d.ts +1 -1
  377. package/dist/uni-app-x/vite/harmony-apply.d.ts +19 -0
  378. package/dist/uni-app-x/vite/native-target.d.ts +2 -0
  379. package/dist/uni-app-x/vite.d.ts +5 -2
  380. package/dist/unocss/index.d.ts +1 -1
  381. package/dist/utils/disabled.d.ts +1 -1
  382. package/dist/utils/index.d.ts +3 -3
  383. package/dist/{hmr-timing-CMPaWn9P.js → v4-generation-core-D7MuR5ZF.cjs} +3468 -2059
  384. package/dist/{vite-BwQWl9ft.mjs → vite-BI1TeUPO.js} +5968 -4456
  385. package/dist/{vite-DhVnXvAQ.js → vite-CBzmUTu-.cjs} +6159 -4672
  386. package/dist/vite.cjs +4 -0
  387. package/dist/vite.d.ts +3 -3
  388. package/dist/vite.js +2 -4
  389. package/dist/watch-dependencies-BZGubvuJ.cjs +40 -0
  390. package/dist/{weapp-tw-css-generation-loader.js → weapp-tw-css-generation-loader.cjs} +3 -2
  391. package/dist/weapp-tw-css-import-rewrite-loader.cjs +201 -0
  392. package/dist/{weapp-tw-runtime-classset-loader.js → weapp-tw-runtime-classset-loader.cjs} +9 -11
  393. package/dist/{webpack-kh78iMSS.js → webpack-Dao6bWEj.cjs} +208 -954
  394. package/dist/{webpack-Bo1QrFPf.mjs → webpack-dAY9h8r8.js} +105 -101
  395. package/dist/webpack.cjs +5 -0
  396. package/dist/webpack.d.ts +2 -2
  397. package/dist/webpack.js +2 -5
  398. package/dist/wxml/Tokenizer.d.ts +2 -2
  399. package/dist/wxml/custom-attributes.d.ts +1 -1
  400. package/dist/wxml/index.d.ts +2 -2
  401. package/dist/wxml/shared.d.ts +1 -1
  402. package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +1 -1
  403. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -2
  404. package/dist/wxml/utils/codegen.d.ts +1 -1
  405. package/dist/wxml/utils/custom-template.d.ts +2 -2
  406. package/dist/wxml/utils/fragment-helpers.d.ts +2 -2
  407. package/dist/wxml/utils/fragment-updater.d.ts +2 -2
  408. package/dist/wxml/utils/template-fragments.d.ts +2 -2
  409. package/dist/wxml/utils.d.ts +5 -5
  410. package/dist/wxml-DSMNuUaP.cjs +38609 -0
  411. package/dist/{cli.mjs → wxml-IBzZSaQC.js} +237 -714
  412. package/package.json +56 -53
  413. package/dist/css-macro/postcss.mjs +0 -2
  414. package/dist/generator.mjs +0 -2
  415. package/dist/gulp.mjs +0 -2
  416. package/dist/index.mjs +0 -9
  417. package/dist/object-BJSWl-E5.mjs +0 -9
  418. package/dist/object-COs_Mw6p.js +0 -14
  419. package/dist/postcss-html-transform.mjs +0 -5
  420. package/dist/postcss.mjs +0 -11
  421. package/dist/reset.mjs +0 -2
  422. package/dist/source-candidate-scan-signature-BKZZk_e6.js +0 -1078
  423. package/dist/source-candidate-scan-signature-CtK-mB_C.mjs +0 -854
  424. package/dist/transform-B_KM9sLX.mjs +0 -14930
  425. package/dist/transform-CcYptivi.js +0 -14927
  426. package/dist/types.mjs +0 -1
  427. package/dist/vite.mjs +0 -2
  428. package/dist/watch-dependencies-bpG6kmAf.js +0 -80
  429. package/dist/weapp-tw-css-import-rewrite-loader-B0tVkJLH.js +0 -10524
  430. package/dist/weapp-tw-css-import-rewrite-loader.js +0 -10
  431. package/dist/webpack.mjs +0 -2
  432. package/dist/wxml-Ce10eREX.js +0 -3979
  433. package/dist/wxml-DdGdeqaH.mjs +0 -3861
  434. /package/dist/{auto-2dg_uhEJ.mjs → auto-2dg_uhEJ.js} +0 -0
  435. /package/dist/{auto-DtU6f3X6.js → auto-DtU6f3X6.cjs} +0 -0
  436. /package/dist/bundlers/{vite → shared}/source-scan/dependencies.d.ts +0 -0
  437. /package/dist/{cache-options-DavPxrhC.js → cache-options-DavPxrhC.cjs} +0 -0
  438. /package/dist/{cache-options-DwBtLwQe.mjs → cache-options-DwBtLwQe.js} +0 -0
  439. /package/dist/{logger-BNzxZbZj.mjs → logger-BNzxZbZj.js} +0 -0
  440. /package/dist/{logger-TlKT3xmR.js → logger-TlKT3xmR.cjs} +0 -0
  441. /package/dist/{utils-CuKLf1Zv.js → utils-CuKLf1Zv.cjs} +0 -0
  442. /package/dist/{utils-MVwpU07P.mjs → utils-MVwpU07P.js} +0 -0
@@ -1,138 +1,15 @@
1
- import { createRequire } from "node:module";
2
- import process from "node:process";
3
- import semver from "semver";
4
- import path from "node:path";
5
- import { access, mkdir, writeFile } from "node:fs/promises";
6
- import { logger } from "@weapp-tailwindcss/logger";
1
+ import { n as _defineProperty, t as omitUndefined } from "./object-Bvy6-w9r.js";
2
+ import { n as HARD_PARSE_CACHE_MAX_ENTRIES, t as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH } from "./cache-options-DwBtLwQe.js";
3
+ import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
7
4
  import { LRUCache } from "lru-cache";
8
5
  import { md5 as md5Hash } from "@weapp-tailwindcss/shared/node";
9
- import { MappingChars2String, escape } from "@weapp-core/escape";
10
- import "@weapp-tailwindcss/shared";
11
- import { constants, existsSync, readFileSync } from "node:fs";
12
- import _createDebug from "debug";
13
- import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
14
- import { createStyleHandler } from "@weapp-tailwindcss/postcss";
15
- import "micromatch";
16
- import "fast-glob";
17
- import "tailwindcss-config";
6
+ import { Parser } from "htmlparser2";
18
7
  import _babelTraverse from "@babel/traverse";
19
- import { parse } from "@babel/parser";
8
+ import { parse, parseExpression } from "@babel/parser";
20
9
  import MagicString from "magic-string";
21
- import "@babel/types";
22
- //#region src/js/babel/cache-options.ts
23
- const DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH = 5e4;
24
- const HARD_PARSE_CACHE_MAX_ENTRIES = 1024;
25
- //#endregion
26
- //#region src/debug/index.ts
27
- const _debug = _createDebug("weapp-tw");
28
- function createDebug(prefix) {
29
- const debug = ((formatter, ...args) => {
30
- return _debug((prefix ?? "") + formatter, ...args);
31
- });
32
- Object.defineProperty(debug, "enabled", {
33
- enumerable: false,
34
- configurable: false,
35
- get() {
36
- return _debug.enabled;
37
- }
38
- });
39
- return debug;
40
- }
41
- //#endregion
42
- //#region src/tailwindcss/v4-engine/generator/rpx-candidates.ts
43
- const RPX_LENGTH_UTILITY_PATTERN = String.raw`text|border(?:-[trblxyse])?|bg|outline|ring`;
44
- new RegExp(String.raw`(^|:)(!?)(${RPX_LENGTH_UTILITY_PATTERN})-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$`, "u");
45
- new RegExp(String.raw`(?:^|:)!?(${RPX_LENGTH_UTILITY_PATTERN})-\[length:([-+]?(?:\d+|\d*\.\d+)rpx)\].*$`, "u");
46
- new RegExp(String.raw`(${RPX_LENGTH_UTILITY_PATTERN})-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]`, "g");
47
- new LRUCache({ max: 8 });
48
- new LRUCache({ max: 32 });
49
- //#endregion
50
- //#region src/utils/object.ts
51
- function definedEntries(value) {
52
- return Object.entries(value).filter(([, item]) => item !== void 0);
53
- }
54
- function omitUndefined(value) {
55
- return Object.fromEntries(definedEntries(value));
56
- }
57
- createStyleHandler({
58
- cssChildCombinatorReplaceValue: ["view", "text"],
59
- cssRemoveHoverPseudoClass: true,
60
- isMainChunk: true,
61
- majorVersion: 4
62
- });
63
- createRequire(import.meta.url);
64
- //#endregion
65
- //#region src/tailwindcss/source-scan.ts
66
- const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
67
- "html",
68
- "wxml",
69
- "axml",
70
- "jxml",
71
- "ksml",
72
- "ttml",
73
- "qml",
74
- "tyml",
75
- "xhsml",
76
- "swan",
77
- "vue",
78
- "mpx",
79
- "js",
80
- "jsx",
81
- "ts",
82
- "tsx"
83
- ];
84
- const FULL_SOURCE_SCAN_EXTENSIONS = [
85
- "js",
86
- "jsx",
87
- "mjs",
88
- "cjs",
89
- "ts",
90
- "tsx",
91
- "mts",
92
- "cts",
93
- "vue",
94
- "uvue",
95
- "nvue",
96
- "svelte",
97
- "mpx",
98
- "html",
99
- "wxml",
100
- "axml",
101
- "jxml",
102
- "ksml",
103
- "ttml",
104
- "qml",
105
- "tyml",
106
- "xhsml",
107
- "swan",
108
- "css",
109
- "wxss",
110
- "acss",
111
- "jxss",
112
- "ttss",
113
- "qss",
114
- "tyss",
115
- "scss",
116
- "sass",
117
- "less",
118
- "styl",
119
- "stylus"
120
- ];
121
- function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
122
- return `**/*.{${extensions.join(",")}}`;
123
- }
124
- createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
125
- new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
126
- createRequire(import.meta.url);
127
- createDebug("[tailwindcss:runtime] ");
128
- //#endregion
129
- //#region src/tailwindcss/runtime-logs.ts
130
- const runtimeLogDedupeHolder = globalThis;
131
- runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ ?? (runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ = /* @__PURE__ */ new Set());
132
- createRequire(import.meta.url);
133
- const globalCacheHolder = globalThis;
134
- globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ ?? (globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ = /* @__PURE__ */ new Map());
135
- //#endregion
10
+ import _createDebug from "debug";
11
+ import { MappingChars2String, escape } from "@weapp-core/escape";
12
+ import * as t from "@babel/types";
136
13
  //#region src/babel/index.ts
137
14
  function _interopDefaultCompat(e) {
138
15
  return e && typeof e === "object" && "default" in e ? e.default : e;
@@ -244,6 +121,22 @@ function babelParse(code, opts = {}) {
244
121
  return result;
245
122
  }
246
123
  //#endregion
124
+ //#region src/debug/index.ts
125
+ const _debug = _createDebug("weapp-tw");
126
+ function createDebug(prefix) {
127
+ const debug = ((formatter, ...args) => {
128
+ return _debug((prefix ?? "") + formatter, ...args);
129
+ });
130
+ Object.defineProperty(debug, "enabled", {
131
+ enumerable: false,
132
+ configurable: false,
133
+ get() {
134
+ return _debug.enabled;
135
+ }
136
+ });
137
+ return debug;
138
+ }
139
+ //#endregion
247
140
  //#region src/wxml/shared.ts
248
141
  const NEWLINE_RE = /[\n\r]+/g;
249
142
  function replaceWxml(original, options = {
@@ -832,44 +725,6 @@ function walkEvalExpression(path, options, updater, handler) {
832
725
  }
833
726
  }
834
727
  //#endregion
835
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
836
- function _typeof(o) {
837
- "@babel/helpers - typeof";
838
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
839
- return typeof o;
840
- } : function(o) {
841
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
842
- }, _typeof(o);
843
- }
844
- //#endregion
845
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
846
- function toPrimitive(t, r) {
847
- if ("object" != _typeof(t) || !t) return t;
848
- var e = t[Symbol.toPrimitive];
849
- if (void 0 !== e) {
850
- var i = e.call(t, r || "default");
851
- if ("object" != _typeof(i)) return i;
852
- throw new TypeError("@@toPrimitive must return a primitive value.");
853
- }
854
- return ("string" === r ? String : Number)(t);
855
- }
856
- //#endregion
857
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
858
- function toPropertyKey(t) {
859
- var i = toPrimitive(t, "string");
860
- return "symbol" == _typeof(i) ? i : i + "";
861
- }
862
- //#endregion
863
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
864
- function _defineProperty(e, r, t) {
865
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
866
- value: t,
867
- enumerable: !0,
868
- configurable: !0,
869
- writable: !0
870
- }) : e[r] = t, e;
871
- }
872
- //#endregion
873
728
  //#region src/js/JsTokenUpdater.ts
874
729
  /**
875
730
  * Lightweight helper that batches updates to {@link MagicString}.
@@ -1607,8 +1462,91 @@ function jsHandler(rawSource, options) {
1607
1462
  return result;
1608
1463
  }
1609
1464
  defaultEvalHandler = jsHandler;
1610
- createRequire(import.meta.url);
1611
- Object.freeze({ wrapExpression: true });
1465
+ //#endregion
1466
+ //#region src/wxml/custom-attributes.ts
1467
+ function regTest(reg, str) {
1468
+ reg.lastIndex = 0;
1469
+ return reg.test(str);
1470
+ }
1471
+ function isPropsMatch(props, attr) {
1472
+ if (Array.isArray(props)) {
1473
+ let lowerAttr;
1474
+ for (const prop of props) if (typeof prop === "string") {
1475
+ lowerAttr ?? (lowerAttr = attr.toLowerCase());
1476
+ if (prop.toLowerCase() === lowerAttr) return true;
1477
+ } else if (regTest(prop, attr)) return true;
1478
+ return false;
1479
+ } else if (typeof props === "string") return props === attr;
1480
+ else return regTest(props, attr);
1481
+ }
1482
+ function createAttributeMatcher(entities) {
1483
+ if (!entities || entities.length === 0) return;
1484
+ const wildcardAttributeRules = [];
1485
+ const tagAttributeRuleMap = /* @__PURE__ */ new Map();
1486
+ const regexpAttributeRules = [];
1487
+ for (const [selector, props] of entities) if (selector === "*") wildcardAttributeRules.push(props);
1488
+ else if (typeof selector === "string") {
1489
+ const list = tagAttributeRuleMap.get(selector);
1490
+ if (list) list.push(props);
1491
+ else tagAttributeRuleMap.set(selector, [props]);
1492
+ } else regexpAttributeRules.push([selector, props]);
1493
+ return (tag, attr) => {
1494
+ for (const props of wildcardAttributeRules) if (isPropsMatch(props, attr)) return true;
1495
+ const tagRules = tagAttributeRuleMap.get(tag);
1496
+ if (tagRules) {
1497
+ for (const props of tagRules) if (isPropsMatch(props, attr)) return true;
1498
+ }
1499
+ for (const [selector, props] of regexpAttributeRules) if (regTest(selector, tag) && isPropsMatch(props, attr)) return true;
1500
+ return false;
1501
+ };
1502
+ }
1503
+ //#endregion
1504
+ //#region src/wxml/utils/codegen/legacy-visitor.ts
1505
+ function shouldSkipLegacyStringLiteral(path) {
1506
+ if (t.isMemberExpression(path.parent)) return true;
1507
+ return Boolean(t.isBinaryExpression(path.parent) && (t.isConditionalExpression(path.parentPath?.parent) || t.isLogicalExpression(path.parentPath?.parent)));
1508
+ }
1509
+ function createLegacyTraverseOptions(options, jsTokenUpdater) {
1510
+ const legacyReplaceOptions = {
1511
+ escapeMap: options.escapeMap,
1512
+ classNameSet: options.runtimeSet,
1513
+ needEscaped: true,
1514
+ alwaysEscape: true
1515
+ };
1516
+ return {
1517
+ StringLiteral(path) {
1518
+ if (shouldSkipLegacyStringLiteral(path)) return;
1519
+ jsTokenUpdater.addToken(replaceHandleValue(path, legacyReplaceOptions));
1520
+ },
1521
+ noScope: true
1522
+ };
1523
+ }
1524
+ //#endregion
1525
+ //#region src/wxml/utils/codegen/legacy-rewriter.ts
1526
+ function rewriteLegacyExpression(match, options) {
1527
+ const ast = parseExpression(match);
1528
+ const jsTokenUpdater = new JsTokenUpdater();
1529
+ traverse(ast, createLegacyTraverseOptions(options, jsTokenUpdater));
1530
+ if (jsTokenUpdater.length === 0) return match;
1531
+ const ms = new MagicString(match);
1532
+ jsTokenUpdater.updateMagicString(ms);
1533
+ return ms.toString();
1534
+ }
1535
+ //#endregion
1536
+ //#region src/wxml/utils/codegen.ts
1537
+ const WRAP_EXPRESSION_HANDLER_OPTIONS = Object.freeze({ wrapExpression: true });
1538
+ function generateCode(match, options = {}) {
1539
+ try {
1540
+ const { jsHandler, runtimeSet, wrapExpression } = options;
1541
+ if (jsHandler && runtimeSet) {
1542
+ const initial = jsHandler(match, runtimeSet, wrapExpression ? WRAP_EXPRESSION_HANDLER_OPTIONS : void 0);
1543
+ if (!initial.error || wrapExpression) return initial.code;
1544
+ return jsHandler(match, runtimeSet, WRAP_EXPRESSION_HANDLER_OPTIONS).code;
1545
+ } else return rewriteLegacyExpression(match, options);
1546
+ } catch {
1547
+ return match;
1548
+ }
1549
+ }
1612
1550
  //#endregion
1613
1551
  //#region src/wxml/whitespace.ts
1614
1552
  const WHITESPACE_CODES = /* @__PURE__ */ new Set([
@@ -1625,6 +1563,10 @@ function isWhitespace(char) {
1625
1563
  if (char.length === 0) return false;
1626
1564
  return WHITESPACE_CODES.has(char.charCodeAt(0));
1627
1565
  }
1566
+ function isAllWhitespace(value) {
1567
+ for (let i = 0; i < value.length; i++) if (!WHITESPACE_CODES.has(value.charCodeAt(i))) return false;
1568
+ return true;
1569
+ }
1628
1570
  //#endregion
1629
1571
  //#region src/wxml/Tokenizer.ts
1630
1572
  var Tokenizer = class {
@@ -1749,565 +1691,146 @@ var Tokenizer = class {
1749
1691
  this.expressions = [];
1750
1692
  }
1751
1693
  };
1752
- new Tokenizer();
1753
- //#endregion
1754
- //#region src/constants.ts
1755
- const WEAPP_TW_REQUIRED_NODE_VERSION_RANGE = "^20.19.0 || >=22.12.0";
1756
- //#endregion
1757
- //#region src/cli/context.ts
1758
- function formatOutputPath(target, baseDir) {
1759
- const root = baseDir ?? process.cwd();
1760
- const relative = path.relative(root, target);
1761
- if (!relative) return ".";
1762
- if (relative.startsWith("..")) return path.normalize(target);
1763
- return relative.startsWith(".") ? relative : `.${path.sep}${relative}`;
1764
- }
1765
- //#endregion
1766
- //#region src/cli/doctor/constants.ts
1767
- const CONFIG_FILES = {
1768
- tailwind: [
1769
- "tailwind.config.js",
1770
- "tailwind.config.cjs",
1771
- "tailwind.config.mjs",
1772
- "tailwind.config.ts"
1773
- ],
1774
- postcss: [
1775
- "postcss.config.js",
1776
- "postcss.config.cjs",
1777
- "postcss.config.mjs",
1778
- "postcss.config.ts"
1779
- ],
1780
- vite: [
1781
- "vite.config.js",
1782
- "vite.config.mjs",
1783
- "vite.config.ts"
1784
- ],
1785
- webpack: [
1786
- "webpack.config.js",
1787
- "webpack.config.cjs",
1788
- "webpack.config.ts"
1789
- ]
1790
- };
1791
- const FRAMEWORK_DEPS = [
1792
- ["@tarojs/taro", "Taro"],
1793
- ["@dcloudio/uni-app", "uni-app"],
1794
- ["@mpxjs/core", "MPX"],
1795
- ["remax", "Remax"]
1796
- ];
1797
1694
  //#endregion
1798
- //#region src/cli/doctor.ts
1799
- function tryReadJson(file) {
1800
- try {
1801
- return JSON.parse(readFileSync(file, "utf8"));
1802
- } catch {
1803
- return;
1804
- }
1805
- }
1806
- function findFirstExisting(cwd, files) {
1807
- return files.find((file) => existsSync(path.join(cwd, file)));
1808
- }
1809
- function readProjectPackageJson(cwd) {
1810
- return tryReadJson(path.join(cwd, "package.json"));
1811
- }
1812
- function readDependencyVersion(cwd, packageName) {
1813
- try {
1814
- return tryReadJson(createRequire(path.join(cwd, "package.json")).resolve(`${packageName}/package.json`))?.version;
1815
- } catch {
1816
- return;
1817
- }
1818
- }
1819
- function collectDependencySpecs(pkg) {
1820
- return {
1821
- ...pkg?.dependencies ?? {},
1822
- ...pkg?.devDependencies ?? {},
1823
- ...pkg?.optionalDependencies ?? {},
1824
- ...pkg?.peerDependencies ?? {}
1825
- };
1826
- }
1827
- function detectPackageManager(cwd, pkg) {
1828
- if (pkg?.packageManager) return pkg.packageManager;
1829
- if (existsSync(path.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
1830
- if (existsSync(path.join(cwd, "package-lock.json"))) return "npm";
1831
- if (existsSync(path.join(cwd, "yarn.lock"))) return "yarn";
1832
- }
1833
- function detectFrameworks(deps) {
1834
- return FRAMEWORK_DEPS.filter(([dependency]) => dependency in deps).map(([, label]) => label);
1835
- }
1836
- function addCheck(checks, check) {
1837
- checks.push(check);
1838
- }
1839
- function summarizeChecks(checks) {
1840
- return checks.reduce((summary, check) => {
1841
- summary[check.status] += 1;
1842
- return summary;
1843
- }, {
1844
- ok: 0,
1845
- warn: 0,
1846
- error: 0,
1847
- info: 0
1848
- });
1849
- }
1850
- function hasDependency(deps, packageName) {
1851
- return packageName in deps;
1852
- }
1853
- function getMajorVersion(version) {
1854
- if (!version) return;
1855
- return semver.parse(version)?.major;
1856
- }
1857
- function getDependencyMajor(deps, packageName) {
1858
- const spec = deps[packageName];
1859
- return spec ? semver.minVersion(spec)?.major : void 0;
1860
- }
1861
- function createDoctorReport(options = {}) {
1862
- const cwd = path.resolve(options.cwd ?? process.cwd());
1863
- const nodeVersion = options.nodeVersion ?? process.versions.node;
1864
- const pkg = readProjectPackageJson(cwd);
1865
- const deps = collectDependencySpecs(pkg);
1866
- const checks = [];
1867
- const packageManager = detectPackageManager(cwd, pkg);
1868
- const frameworks = detectFrameworks(deps);
1869
- const tailwindcssVersion = readDependencyVersion(cwd, "tailwindcss");
1870
- const weappTailwindcssVersion = readDependencyVersion(cwd, "weapp-tailwindcss");
1871
- const tailwindMajor = getMajorVersion(tailwindcssVersion) ?? getDependencyMajor(deps, "tailwindcss");
1872
- const tailwindConfig = findFirstExisting(cwd, CONFIG_FILES.tailwind);
1873
- const postcssConfig = findFirstExisting(cwd, CONFIG_FILES.postcss);
1874
- const viteConfig = findFirstExisting(cwd, CONFIG_FILES.vite);
1875
- const webpackConfig = findFirstExisting(cwd, CONFIG_FILES.webpack);
1876
- addCheck(checks, pkg ? {
1877
- id: "package-json",
1878
- title: "package.json",
1879
- status: "ok",
1880
- message: "已找到项目 package.json。"
1881
- } : {
1882
- id: "package-json",
1883
- title: "package.json",
1884
- status: "error",
1885
- message: "当前目录没有 package.json。",
1886
- suggestion: "请在项目根目录运行 doctor,或通过 --cwd 指向项目根目录。"
1887
- });
1888
- addCheck(checks, semver.satisfies(nodeVersion, "^20.19.0 || >=22.12.0") ? {
1889
- id: "node-version",
1890
- title: "Node.js",
1891
- status: "ok",
1892
- message: `当前 Node.js ${nodeVersion} 满足版本要求 ${WEAPP_TW_REQUIRED_NODE_VERSION_RANGE}。`
1893
- } : {
1894
- id: "node-version",
1895
- title: "Node.js",
1896
- status: "error",
1897
- message: `当前 Node.js ${nodeVersion} 不满足版本要求 ${WEAPP_TW_REQUIRED_NODE_VERSION_RANGE}。`,
1898
- suggestion: "请升级 Node.js 后再安装或构建 weapp-tailwindcss 项目。"
1899
- });
1900
- addCheck(checks, packageManager ? {
1901
- id: "package-manager",
1902
- title: "包管理器",
1903
- status: packageManager.startsWith("pnpm") ? "ok" : "info",
1904
- message: `检测到 ${packageManager}。`
1905
- } : {
1906
- id: "package-manager",
1907
- title: "包管理器",
1908
- status: "info",
1909
- message: "未检测到 lockfile 或 packageManager 字段。"
1910
- });
1911
- addCheck(checks, hasDependency(deps, "weapp-tailwindcss") || Boolean(weappTailwindcssVersion) ? {
1912
- id: "weapp-tailwindcss",
1913
- title: "weapp-tailwindcss",
1914
- status: "ok",
1915
- message: `检测到 weapp-tailwindcss${weappTailwindcssVersion ? `@${weappTailwindcssVersion}` : ""}。`
1916
- } : {
1917
- id: "weapp-tailwindcss",
1918
- title: "weapp-tailwindcss",
1919
- status: "warn",
1920
- message: "未在当前项目依赖中检测到 weapp-tailwindcss。",
1921
- suggestion: "如果这是业务项目,请安装 weapp-tailwindcss 并确认命令运行在项目根目录。"
1922
- });
1923
- addCheck(checks, hasDependency(deps, "tailwindcss") || Boolean(tailwindcssVersion) ? {
1924
- id: "tailwindcss",
1925
- title: "Tailwind CSS",
1926
- status: "ok",
1927
- message: `检测到 tailwindcss${tailwindcssVersion ? `@${tailwindcssVersion}` : ""}。`
1928
- } : {
1929
- id: "tailwindcss",
1930
- title: "Tailwind CSS",
1931
- status: "error",
1932
- message: "未检测到 tailwindcss。",
1933
- suggestion: "请安装 tailwindcss,并确认依赖可以从当前项目解析。"
1934
- });
1935
- addCheck(checks, tailwindConfig ? {
1936
- id: "tailwind-config",
1937
- title: "Tailwind 配置",
1938
- status: "ok",
1939
- message: `检测到 ${tailwindConfig}。`
1940
- } : {
1941
- id: "tailwind-config",
1942
- title: "Tailwind 配置",
1943
- status: tailwindMajor === 4 ? "info" : "warn",
1944
- message: "未检测到 tailwind.config.*。",
1945
- suggestion: tailwindMajor === 4 ? "Tailwind CSS v4 可以采用 CSS-first 配置;复杂 content/source 场景请补充配置文件。" : "请确认 Tailwind content/source 配置能够覆盖小程序页面、组件和脚本文件。"
1946
- });
1947
- addCheck(checks, postcssConfig ? {
1948
- id: "postcss-config",
1949
- title: "PostCSS 配置",
1950
- status: "ok",
1951
- message: `检测到 ${postcssConfig}。`
1952
- } : {
1953
- id: "postcss-config",
1954
- title: "PostCSS 配置",
1955
- status: viteConfig ? "info" : "warn",
1956
- message: "未检测到 postcss.config.*。",
1957
- suggestion: "如果通过 PostCSS 接入,请补充 postcss.config.*;如果通过 Vite/Taro 插件接入,可忽略此项。"
1958
- });
1959
- if (tailwindMajor === 4 && postcssConfig && !hasDependency(deps, "@tailwindcss/postcss")) addCheck(checks, {
1960
- id: "tailwindcss-v4-postcss",
1961
- title: "Tailwind v4 PostCSS",
1962
- status: "warn",
1963
- message: "Tailwind CSS v4 项目存在 PostCSS 配置,但未检测到 @tailwindcss/postcss。",
1964
- suggestion: "如果 PostCSS 配置中仍直接使用 tailwindcss,请迁移到 @tailwindcss/postcss。"
1965
- });
1966
- addCheck(checks, frameworks.length > 0 ? {
1967
- id: "framework",
1968
- title: "框架识别",
1969
- status: "ok",
1970
- message: `检测到 ${frameworks.join(", ")}。`
1971
- } : {
1972
- id: "framework",
1973
- title: "框架识别",
1974
- status: "info",
1975
- message: "未从依赖中识别出 Taro、uni-app、MPX 或 Remax。"
1976
- });
1977
- addCheck(checks, viteConfig || webpackConfig ? {
1978
- id: "bundler-config",
1979
- title: "构建器配置",
1980
- status: "ok",
1981
- message: `检测到 ${[viteConfig, webpackConfig].filter(Boolean).join(", ")}。`
1982
- } : {
1983
- id: "bundler-config",
1984
- title: "构建器配置",
1985
- status: "info",
1986
- message: "未检测到 vite.config.* 或 webpack.config.*。"
1987
- });
1988
- return {
1989
- cwd,
1990
- nodeVersion,
1991
- detected: {
1992
- packageManager,
1993
- frameworks,
1994
- tailwindcssVersion,
1995
- weappTailwindcssVersion
1996
- },
1997
- summary: summarizeChecks(checks),
1998
- checks
1999
- };
1695
+ //#region src/wxml/utils/fragment-helpers.ts
1696
+ function updateWhitespaceGap(ms, start, end, options) {
1697
+ const gap = ms.slice(start, end);
1698
+ if (isAllWhitespace(gap)) ms.update(start, end, replaceWxml(gap, {
1699
+ keepEOL: false,
1700
+ escapeMap: options.escapeMap,
1701
+ ignoreHead: true
1702
+ }));
2000
1703
  }
2001
- function hasDoctorFailure(report, strict = false) {
2002
- return report.summary.error > 0 || strict && report.summary.warn > 0;
1704
+ function updateWxmlSegment(ms, start, end, options, keepEOL, ignoreHead) {
1705
+ ms.update(start, end, replaceWxml(ms.slice(start, end), {
1706
+ keepEOL,
1707
+ escapeMap: options.escapeMap,
1708
+ ignoreHead
1709
+ }));
2003
1710
  }
2004
- function formatDoctorReport(report) {
2005
- const lines = [
2006
- `weapp-tailwindcss doctor`,
2007
- `cwd: ${report.cwd}`,
2008
- `summary: ${report.summary.error} error, ${report.summary.warn} warn, ${report.summary.ok} ok, ${report.summary.info} info`,
2009
- ""
2010
- ];
2011
- for (const check of report.checks) {
2012
- lines.push(`[${check.status}] ${check.title}: ${check.message}`);
2013
- if (check.suggestion) lines.push(` -> ${check.suggestion}`);
2014
- }
2015
- return lines.join("\n");
1711
+ function updateExpressionSegment(ms, exp, options) {
1712
+ const code = `{{${generateCode(exp.value.slice(2, -2), options)}}}`;
1713
+ ms.update(exp.start, exp.end, code);
2016
1714
  }
2017
1715
  //#endregion
2018
- //#region src/cli/helpers/options/parse.ts
2019
- function readStringOption(flag, value) {
2020
- if (value == null) return;
2021
- if (typeof value !== "string") throw new TypeError(`Option "--${flag}" expects a string value.`);
2022
- const trimmed = value.trim();
2023
- if (trimmed.length === 0) throw new TypeError(`Option "--${flag}" expects a non-empty value.`);
2024
- return trimmed;
2025
- }
2026
- function readStringArrayOption(flag, value) {
2027
- if (value == null) return;
2028
- if (Array.isArray(value)) {
2029
- const normalized = value.filter((entry) => entry != null).map((entry) => {
2030
- if (typeof entry !== "string") throw new TypeError(`Option "--${flag}" expects string values.`);
2031
- const trimmed = entry.trim();
2032
- if (!trimmed) throw new TypeError(`Option "--${flag}" expects non-empty values.`);
2033
- return trimmed;
2034
- });
2035
- return normalized.length > 0 ? normalized : void 0;
1716
+ //#region src/wxml/utils/fragment-updater.ts
1717
+ function handleEachClassFragment(ms, tokens, options = {}) {
1718
+ let previousEnd = 0;
1719
+ for (const token of tokens) {
1720
+ if (token.start > previousEnd) updateWhitespaceGap(ms, previousEnd, token.start, options);
1721
+ let p = token.start;
1722
+ if (token.expressions.length > 0) {
1723
+ for (const exp of token.expressions) {
1724
+ if (exp.start > token.start && p < exp.start) updateWxmlSegment(ms, p, exp.start, options, true, p > 0);
1725
+ updateExpressionSegment(ms, exp, options);
1726
+ p = exp.end;
1727
+ }
1728
+ if (token.end > p) updateWxmlSegment(ms, p, token.end, options, false, true);
1729
+ } else updateWxmlSegment(ms, token.start, token.end, options, false, false);
1730
+ previousEnd = token.end;
2036
1731
  }
2037
- const normalized = readStringOption(flag, value);
2038
- return normalized ? [normalized] : void 0;
2039
- }
2040
- function toBoolean(value, fallback) {
2041
- if (typeof value === "boolean") return value;
2042
- if (typeof value === "string") {
2043
- if (value === "true") return true;
2044
- if (value === "false") return false;
1732
+ if (tokens.length > 0) {
1733
+ const lastToken = tokens[tokens.length - 1];
1734
+ if (!lastToken) return;
1735
+ if (lastToken.end < ms.original.length) updateWhitespaceGap(ms, lastToken.end, ms.original.length, options);
2045
1736
  }
2046
- if (value == null) return fallback;
2047
- return Boolean(value);
2048
1737
  }
2049
1738
  //#endregion
2050
- //#region src/cli/helpers/options/resolve.ts
2051
- function resolveCliCwd(value) {
2052
- const raw = readStringOption("cwd", value);
2053
- if (!raw) return;
2054
- return path.isAbsolute(raw) ? path.normalize(raw) : path.resolve(process.cwd(), raw);
1739
+ //#region src/wxml/utils/template-fragments.ts
1740
+ /**
1741
+ * 模块级共享 Tokenizer 实例,避免每次调用都重新创建。
1742
+ * Tokenizer.run() 末尾已调用 reset(),天然支持复用。
1743
+ */
1744
+ const sharedTokenizer = new Tokenizer();
1745
+ function templateReplacer(original, options = {}, tokenizer) {
1746
+ const ms = new MagicString(original);
1747
+ handleEachClassFragment(ms, (tokenizer ?? sharedTokenizer).run(ms.original), options);
1748
+ return ms.toString();
2055
1749
  }
2056
1750
  //#endregion
2057
- //#region src/cli/helpers.ts
2058
- async function ensureDir(dir) {
2059
- await mkdir(dir, { recursive: true });
2060
- }
2061
- function handleCliError(error) {
2062
- if (error instanceof Error) {
2063
- logger.error(error.message);
2064
- if (error.stack && process.env["WEAPP_TW_DEBUG"] === "1") logger.error(error.stack);
2065
- } else logger.error(String(error));
2066
- }
2067
- function commandAction(handler) {
2068
- return async (...args) => {
2069
- try {
2070
- await handler(...args);
2071
- } catch (error) {
2072
- handleCliError(error);
2073
- process.exitCode = 1;
1751
+ //#region src/wxml/utils/custom-template.ts
1752
+ async function customTemplateHandler(rawSource, options, cachedMatcher) {
1753
+ const { customAttributesEntities = [], disabledDefaultTemplateHandler, inlineWxs, runtimeSet, jsHandler } = options ?? {};
1754
+ const matchCustomAttribute = cachedMatcher ?? createAttributeMatcher(customAttributesEntities);
1755
+ const defaultTemplateHandlerEnabled = !disabledDefaultTemplateHandler;
1756
+ let replaceOptions;
1757
+ let cachedQuote;
1758
+ let s;
1759
+ let tag = "";
1760
+ let wxsArray;
1761
+ function getMagicString() {
1762
+ if (!s) s = new MagicString(rawSource);
1763
+ return s;
1764
+ }
1765
+ function getReplaceOptions(quote) {
1766
+ if (!replaceOptions) {
1767
+ replaceOptions = {
1768
+ ...options,
1769
+ quote
1770
+ };
1771
+ cachedQuote = quote;
1772
+ return replaceOptions;
2074
1773
  }
2075
- };
2076
- }
2077
- //#endregion
2078
- //#region src/cli/mount-options.ts
2079
- const PATCH_COMMAND_OBSOLETE_NOTICE = "提示:weapp-tailwindcss@5 已由构建运行时接管 Tailwind CSS 处理,weapp-tw patch 已无需执行;请移除 package.json 中的 postinstall 钩子。";
2080
- const obsoletePatchCommands = [
2081
- "extract",
2082
- "tokens",
2083
- "init",
2084
- "migrate",
2085
- "restore",
2086
- "validate"
2087
- ];
2088
- function logPatchCommandObsoleteNotice() {
2089
- logger.warn(PATCH_COMMAND_OBSOLETE_NOTICE);
2090
- }
2091
- function logObsoletePatchCommand(command) {
2092
- logPatchCommandObsoleteNotice();
2093
- logger.warn(`命令 "${command}" 来自旧版 tailwindcss-patch 工作流,当前版本无需执行。`);
2094
- }
2095
- const DEFAULT_VSCODE_SOURCES = [
2096
- "not \"./dist\"",
2097
- "not \"./unpackage\"",
2098
- "./src/**/*.{wxml,axml,swan,qml,ttml,ux,uts}",
2099
- "./src/**/*.{js,jsx,ts,tsx,mjs,cjs,wxs,sjs}",
2100
- "./src/**/*.{vue,svelte,mpx,html,md,mdx}"
2101
- ];
2102
- const SINGLE_QUOTE = "'";
2103
- const DOUBLE_QUOTE = "\"";
2104
- const BACKSLASH_RE = /\\/g;
2105
- function toPosixPath(filepath) {
2106
- return filepath.replace(BACKSLASH_RE, "/");
2107
- }
2108
- async function assertFileExists(filepath) {
2109
- try {
2110
- await access(filepath, constants.F_OK);
2111
- } catch (error) {
2112
- const err = error;
2113
- if (err?.code === "ENOENT") throw new Error(`CSS entry file not found: ${filepath}`);
2114
- throw err;
2115
- }
2116
- }
2117
- async function assertCanWrite(filepath, force) {
2118
- try {
2119
- await access(filepath, constants.F_OK);
2120
- if (!force) throw new Error(`VS Code helper already exists at ${filepath}. Re-run with --force to overwrite it.`);
2121
- } catch (error) {
2122
- const err = error;
2123
- if (err?.code === "ENOENT") return;
2124
- throw err;
2125
- }
2126
- }
2127
- function toCssLiteral(value) {
2128
- const normalized = toPosixPath(value);
2129
- return JSON.stringify(normalized);
2130
- }
2131
- function formatSource(pattern) {
2132
- const trimmed = pattern.trim();
2133
- if (!trimmed) return null;
2134
- if (trimmed.startsWith("@source ")) return trimmed.endsWith(";") ? trimmed : `${trimmed};`;
2135
- let body = trimmed;
2136
- let keyword = "";
2137
- if (body.startsWith("not ")) {
2138
- keyword = "not ";
2139
- body = body.slice(4).trim();
2140
- } else if (body.startsWith("!")) {
2141
- keyword = "not ";
2142
- body = body.slice(1).trim();
2143
- }
2144
- if (!body) throw new Error("Invalid @source pattern: empty body.");
2145
- if (!body.startsWith(SINGLE_QUOTE) && !body.startsWith(DOUBLE_QUOTE)) body = toCssLiteral(body);
2146
- return `@source ${keyword}${body};`;
2147
- }
2148
- function resolveOutputPath(baseDir, output) {
2149
- const target = output ?? ".vscode/weapp-tailwindcss.intellisense.css";
2150
- return path.isAbsolute(target) ? path.normalize(target) : path.resolve(baseDir, target);
2151
- }
2152
- function resolveCssEntry(baseDir, entry) {
2153
- return path.isAbsolute(entry) ? path.normalize(entry) : path.resolve(baseDir, entry);
2154
- }
2155
- function toRelativeImport(fromFile, targetFile) {
2156
- const fromDir = path.dirname(fromFile);
2157
- let relative = path.relative(fromDir, targetFile);
2158
- if (!relative) relative = path.basename(targetFile);
2159
- if (!relative.startsWith(".")) relative = `./${relative}`;
2160
- return toPosixPath(relative);
2161
- }
2162
- async function generateVscodeIntellisenseEntry(options) {
2163
- const baseDir = options.baseDir;
2164
- const cssEntryPath = resolveCssEntry(baseDir, options.cssEntry);
2165
- await assertFileExists(cssEntryPath);
2166
- const outputPath = resolveOutputPath(baseDir, options.output);
2167
- await ensureDir(path.dirname(outputPath));
2168
- await assertCanWrite(outputPath, options.force);
2169
- const formattedSources = (options.sources && options.sources.length > 0 ? options.sources : DEFAULT_VSCODE_SOURCES).map(formatSource).filter((statement) => Boolean(statement));
2170
- const cssImport = toRelativeImport(outputPath, cssEntryPath);
2171
- const separator = formattedSources.length > 0 ? [""] : [];
2172
- await writeFile(outputPath, `${[
2173
- "/*",
2174
- " * Auto-generated by weapp-tailwindcss.",
2175
- " * This file exists solely to activate Tailwind CSS IntelliSense in VS Code.",
2176
- " * Do not import it in your actual mini-program bundles.",
2177
- " */",
2178
- "@import 'tailwindcss';",
2179
- "",
2180
- ...formattedSources,
2181
- ...separator,
2182
- `@import '${cssImport}';`,
2183
- ""
2184
- ].filter((line, idx, arr) => !(line === "" && arr[idx - 1] === "")).join("\n")}\n`, "utf8");
2185
- return {
2186
- outputPath,
2187
- cssEntryPath
2188
- };
2189
- }
2190
- //#endregion
2191
- //#region src/cli.ts
2192
- process.title = "node (weapp-tailwindcss)";
2193
- if (!semver.satisfies(process.versions.node, "^20.19.0 || >=22.12.0")) logger.warn(`You are using Node.js ${process.versions.node}. For weapp-tailwindcss, Node.js version ${WEAPP_TW_REQUIRED_NODE_VERSION_RANGE} is required.`);
2194
- function parseArgs(argv) {
2195
- const options = {};
2196
- const positional = [];
2197
- for (let index = 0; index < argv.length; index++) {
2198
- const arg = argv[index];
2199
- if (arg === void 0) continue;
2200
- if (!arg.startsWith("--")) {
2201
- positional.push(arg);
2202
- continue;
1774
+ if (cachedQuote !== quote) {
1775
+ replaceOptions.quote = quote;
1776
+ cachedQuote = quote;
2203
1777
  }
2204
- const [rawKey, inlineValue] = arg.slice(2).split("=", 2);
2205
- if (!rawKey) continue;
2206
- const key = rawKey.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
2207
- const next = argv[index + 1];
2208
- let value = true;
2209
- if (inlineValue !== void 0) value = inlineValue;
2210
- else if (next !== void 0 && !next.startsWith("-")) {
2211
- index++;
2212
- value = next;
1778
+ return replaceOptions;
1779
+ }
1780
+ function isDefaultTemplateAttribute(name) {
1781
+ if (name === "class" || name === "hover-class" || name === "virtualhostclass") return true;
1782
+ const lowerName = name.toLowerCase();
1783
+ return lowerName === "class" || lowerName === "hover-class" || lowerName === "virtualhostclass";
1784
+ }
1785
+ const parser = new Parser({
1786
+ onopentagname(name) {
1787
+ tag = name;
1788
+ },
1789
+ onattribute(name, value, quote) {
1790
+ if (!value) return;
1791
+ const shouldHandleDefault = defaultTemplateHandlerEnabled && isDefaultTemplateAttribute(name);
1792
+ const shouldHandleCustom = matchCustomAttribute?.(tag, name) ?? false;
1793
+ if (!shouldHandleDefault && !shouldHandleCustom) return;
1794
+ getMagicString().update(parser.startIndex + name.length + 2, parser.endIndex - 1, templateReplacer(value, getReplaceOptions(quote)));
1795
+ },
1796
+ ontext(data) {
1797
+ if (inlineWxs && tag === "wxs") (wxsArray ?? (wxsArray = [])).push({
1798
+ data,
1799
+ endIndex: parser.endIndex + 1,
1800
+ startIndex: parser.startIndex
1801
+ });
1802
+ },
1803
+ onclosetag() {
1804
+ tag = "";
2213
1805
  }
2214
- const current = options[key];
2215
- if (current === void 0) options[key] = value;
2216
- else if (Array.isArray(current)) current.push(String(value));
2217
- else options[key] = [String(current), String(value)];
1806
+ }, { xmlMode: true });
1807
+ parser.write(rawSource);
1808
+ parser.end();
1809
+ if (jsHandler) for (const { data, endIndex, startIndex } of wxsArray ?? []) {
1810
+ const { code } = await jsHandler(data, runtimeSet);
1811
+ if (code !== data) getMagicString().update(startIndex, endIndex, code);
2218
1812
  }
2219
- return {
2220
- command: positional[0],
2221
- options
2222
- };
1813
+ return s?.toString() ?? rawSource;
2223
1814
  }
2224
- function printHelp() {
2225
- logger.log(`weapp-tailwindcss
2226
-
2227
- Usage:
2228
- weapp-tw <command> [options]
2229
-
2230
- Commands:
2231
- patch Deprecated no-op: v5 runtime handles Tailwind CSS automatically
2232
- status Deprecated no-op: patch status is no longer required
2233
- vscode-entry Generate a VS Code helper CSS for Tailwind IntelliSense
2234
- doctor Check project setup for weapp-tailwindcss
2235
- `);
2236
- }
2237
- async function runPatch() {
2238
- logPatchCommandObsoleteNotice();
2239
- logger.success("已跳过:当前版本不需要手动执行 Tailwind CSS patch。");
2240
- }
2241
- async function runStatus(options) {
2242
- const payload = {
2243
- required: false,
2244
- status: "unnecessary",
2245
- message: PATCH_COMMAND_OBSOLETE_NOTICE
2246
- };
2247
- if (toBoolean(options["json"], false)) {
2248
- logger.log(JSON.stringify(payload, null, 2));
2249
- return;
2250
- }
2251
- logPatchCommandObsoleteNotice();
2252
- logger.success("无需检查 Tailwind CSS patch 状态。");
2253
- }
2254
- async function runVscodeEntry(options) {
2255
- const resolvedCwd = resolveCliCwd(options.cwd);
2256
- const baseDir = resolvedCwd ?? process.cwd();
2257
- const cssEntry = readStringOption("css", options["css"]);
2258
- if (!cssEntry) throw new Error("Option \"--css\" is required.");
2259
- const result = await generateVscodeIntellisenseEntry({
2260
- baseDir,
2261
- cssEntry,
2262
- output: readStringOption("output", options["output"]),
2263
- sources: readStringArrayOption("source", options["source"]),
2264
- force: toBoolean(options["force"], false)
2265
- });
2266
- logger.success(`VS Code helper generated -> ${formatOutputPath(result.outputPath, resolvedCwd)}`);
2267
- }
2268
- async function runDoctor(options) {
2269
- const report = createDoctorReport({ cwd: resolveCliCwd(options.cwd) });
2270
- if (toBoolean(options["json"], false)) logger.log(JSON.stringify(report, null, 2));
2271
- else logger.log(formatDoctorReport(report));
2272
- if (hasDoctorFailure(report, toBoolean(options["strict"], false))) process.exitCode = 1;
2273
- }
2274
- async function main() {
2275
- const { command, options } = parseArgs(process.argv.slice(2));
2276
- await commandAction(async () => {
2277
- switch (command) {
2278
- case void 0:
2279
- case "-h":
2280
- case "--help":
2281
- case "help":
2282
- printHelp();
2283
- return;
2284
- case "-v":
2285
- case "--version":
2286
- case "version":
2287
- logger.log(process.env["npm_package_version"] ?? "0.0.0");
2288
- return;
2289
- case "patch":
2290
- case "install":
2291
- await runPatch();
2292
- return;
2293
- case "status":
2294
- await runStatus(options);
2295
- return;
2296
- case "vscode-entry":
2297
- await runVscodeEntry(options);
2298
- return;
2299
- case "doctor":
2300
- await runDoctor(options);
2301
- return;
2302
- default:
2303
- if (obsoletePatchCommands.includes(command)) {
2304
- logObsoletePatchCommand(command);
2305
- return;
2306
- }
2307
- throw new Error(`Unknown command: ${command}`);
1815
+ //#endregion
1816
+ //#region src/wxml/utils.ts
1817
+ function createTemplateHandler(options = {}) {
1818
+ const cachedMatcher = createAttributeMatcher(options.customAttributesEntities);
1819
+ const defaultOptions = options;
1820
+ let cachedRuntimeSet;
1821
+ let cachedOptionsWithRuntimeSet;
1822
+ return (rawSource, opt) => {
1823
+ const runtimeSet = opt?.runtimeSet;
1824
+ if (runtimeSet === void 0) return customTemplateHandler(rawSource, defaultOptions, cachedMatcher);
1825
+ if (cachedRuntimeSet !== runtimeSet || !cachedOptionsWithRuntimeSet) {
1826
+ cachedRuntimeSet = runtimeSet;
1827
+ cachedOptionsWithRuntimeSet = {
1828
+ ...defaultOptions,
1829
+ runtimeSet
1830
+ };
2308
1831
  }
2309
- })();
1832
+ return customTemplateHandler(rawSource, cachedOptionsWithRuntimeSet, cachedMatcher);
1833
+ };
2310
1834
  }
2311
- main();
2312
1835
  //#endregion
2313
- export {};
1836
+ export { traverse as _, jsHandler as a, getReplacementCacheStore as c, decodeUnicode2 as d, resolveClassNameTransformWithResult as f, babelParse as g, createDebug as h, analyzeSource as i, jsStringEscape as l, replaceWxml as m, generateCode as n, JsTokenUpdater as o, shouldEnableArbitraryValueFallback as p, createAttributeMatcher as r, getReplacement as s, createTemplateHandler as t, isClassContextLiteralPath as u, md5Hash as v };