weapp-tailwindcss 4.12.0 → 5.0.0-next.2

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 (313) hide show
  1. package/dist/babel/index.d.ts +3 -0
  2. package/dist/bundlers/gulp/index.d.ts +7 -0
  3. package/dist/bundlers/shared/cache.d.ts +16 -0
  4. package/dist/bundlers/shared/css-cleanup.d.ts +4 -0
  5. package/dist/bundlers/shared/css-imports.d.ts +8 -0
  6. package/dist/bundlers/shared/generator-candidates.d.ts +5 -0
  7. package/dist/bundlers/shared/generator-css.d.ts +43 -0
  8. package/dist/bundlers/shared/module-graph.d.ts +5 -0
  9. package/dist/bundlers/shared/run-tasks.d.ts +2 -0
  10. package/dist/bundlers/vite/bundle-entries.d.ts +14 -0
  11. package/dist/bundlers/vite/bundle-state.d.ts +43 -0
  12. package/dist/bundlers/vite/css-finalizer.d.ts +22 -0
  13. package/dist/bundlers/vite/generate-bundle.d.ts +33 -0
  14. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +21 -0
  15. package/dist/bundlers/vite/index.d.ts +3 -0
  16. package/dist/bundlers/vite/js-precheck.d.ts +1 -0
  17. package/dist/bundlers/vite/query.d.ts +15 -0
  18. package/dist/bundlers/vite/resolve-app-type.d.ts +2 -0
  19. package/dist/bundlers/vite/rewrite-css-imports.d.ts +11 -0
  20. package/dist/bundlers/vite/runtime-affecting-signature.d.ts +2 -0
  21. package/dist/bundlers/vite/source-candidates.d.ts +15 -0
  22. package/dist/bundlers/vite/utils.d.ts +9 -0
  23. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +20 -0
  24. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +14 -0
  25. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +15 -0
  26. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +9 -0
  27. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +17 -0
  28. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +19 -0
  29. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +9 -0
  30. package/dist/bundlers/webpack/index.d.ts +1 -0
  31. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +12 -0
  32. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +11 -0
  33. package/dist/bundlers/webpack/shared/css-imports.d.ts +6 -0
  34. package/dist/bundlers/webpack/shared/loader-anchors.d.ts +8 -0
  35. package/dist/cache/index.d.ts +38 -0
  36. package/dist/cache/md5.d.ts +1 -0
  37. package/dist/chunk-8l464Juk.js +28 -0
  38. package/dist/cli/config.d.ts +5 -0
  39. package/dist/cli/context.d.ts +16 -0
  40. package/dist/cli/doctor/constants.d.ts +7 -0
  41. package/dist/cli/doctor/types.d.ts +31 -0
  42. package/dist/cli/doctor.d.ts +4 -0
  43. package/dist/cli/helpers/options/format.d.ts +2 -0
  44. package/dist/cli/helpers/options/parse.d.ts +3 -0
  45. package/dist/cli/helpers/options/resolve.d.ts +1 -0
  46. package/dist/cli/helpers/options.d.ts +3 -0
  47. package/dist/cli/helpers/patch-cwd.d.ts +1 -0
  48. package/dist/cli/helpers.d.ts +5 -0
  49. package/dist/cli/mount-options/patch-status.d.ts +2 -0
  50. package/dist/cli/mount-options.d.ts +2 -0
  51. package/dist/cli/patch-options.d.ts +6 -0
  52. package/dist/cli/tokens.d.ts +4 -0
  53. package/dist/cli/types.d.ts +17 -0
  54. package/dist/cli/vscode-entry.d.ts +14 -0
  55. package/dist/cli/workspace/package-dirs.d.ts +3 -0
  56. package/dist/cli/workspace/patch-package.d.ts +3 -0
  57. package/dist/cli/workspace/patch-utils.d.ts +3 -0
  58. package/dist/cli/workspace/types.d.ts +11 -0
  59. package/dist/cli/workspace/workspace-globs.d.ts +2 -0
  60. package/dist/cli/workspace/workspace-io.d.ts +1 -0
  61. package/dist/cli/workspace/workspace-lock.d.ts +1 -0
  62. package/dist/cli/workspace.d.ts +2 -0
  63. package/dist/cli.d.ts +1 -2
  64. package/dist/cli.js +2425 -3524
  65. package/dist/cli.mjs +2402 -3505
  66. package/dist/constants-B-_T5UnW.mjs +44 -0
  67. package/dist/constants-p1dyh1x1.js +73 -0
  68. package/dist/constants.d.ts +13 -0
  69. package/dist/context/compiler-context-cache.d.ts +3 -0
  70. package/dist/context/custom-attributes.d.ts +2 -0
  71. package/dist/context/handlers.d.ts +6 -0
  72. package/dist/context/index.d.ts +7 -0
  73. package/dist/context/logger.d.ts +4 -0
  74. package/dist/context/tailwindcss/basedir.d.ts +1 -0
  75. package/dist/context/tailwindcss/rax.d.ts +2 -0
  76. package/dist/context/tailwindcss.d.ts +4 -0
  77. package/dist/context/workspace.d.ts +3 -0
  78. package/dist/core.d.ts +5 -21
  79. package/dist/core.js +138 -180
  80. package/dist/core.mjs +135 -180
  81. package/dist/css-imports-BbrbluP9.js +177 -0
  82. package/dist/css-imports-CSdPq_Sc.mjs +128 -0
  83. package/dist/css-macro/constants.d.ts +14 -0
  84. package/dist/css-macro/index.d.ts +15 -0
  85. package/dist/css-macro/postcss.d.ts +3 -7
  86. package/dist/css-macro/postcss.js +44 -58
  87. package/dist/css-macro/postcss.mjs +44 -56
  88. package/dist/css-macro.d.ts +1 -20
  89. package/dist/css-macro.js +37 -50
  90. package/dist/css-macro.mjs +33 -47
  91. package/dist/debug/index.d.ts +5 -0
  92. package/dist/defaults.d.ts +2 -11
  93. package/dist/defaults.js +132 -8
  94. package/dist/defaults.mjs +128 -7
  95. package/dist/escape.js +31 -54
  96. package/dist/escape.mjs +18 -25
  97. package/dist/experimental/index.d.ts +2 -0
  98. package/dist/experimental/oxc/ast-utils.d.ts +30 -0
  99. package/dist/experimental/oxc/index.d.ts +2 -0
  100. package/dist/experimental/oxc/module-specifiers.d.ts +2 -0
  101. package/dist/experimental/shared/cache.d.ts +3 -0
  102. package/dist/experimental/shared/transform.d.ts +3 -0
  103. package/dist/experimental/shared.d.ts +8 -0
  104. package/dist/experimental/swc/ast-utils.d.ts +30 -0
  105. package/dist/experimental/swc/index.d.ts +2 -0
  106. package/dist/experimental/swc/module-specifiers.d.ts +2 -0
  107. package/dist/generator/index.d.ts +11 -0
  108. package/dist/generator/options.d.ts +17 -0
  109. package/dist/generator/types.d.ts +20 -0
  110. package/dist/generator-Y-Ikv4Fu.mjs +1177 -0
  111. package/dist/generator-css-B5ejWUMv.mjs +1098 -0
  112. package/dist/generator-css-D3OdPRiS.js +1125 -0
  113. package/dist/generator-mmhXzZnv.js +1276 -0
  114. package/dist/generator.d.ts +1 -0
  115. package/dist/generator.js +19 -0
  116. package/dist/generator.mjs +2 -0
  117. package/dist/gulp.d.ts +4 -24
  118. package/dist/gulp.js +271 -13
  119. package/dist/gulp.mjs +263 -13
  120. package/dist/index.d.ts +8 -15
  121. package/dist/index.js +12 -24
  122. package/dist/index.mjs +6 -24
  123. package/dist/js/JsTokenUpdater.d.ts +14 -0
  124. package/dist/js/ModuleGraph.d.ts +18 -0
  125. package/dist/js/NodePathWalker.d.ts +33 -0
  126. package/dist/js/babel/parse.d.ts +9 -0
  127. package/dist/js/babel/process.d.ts +4 -0
  128. package/dist/js/babel.d.ts +13 -0
  129. package/dist/js/class-context.d.ts +3 -0
  130. package/dist/js/evalTransforms.d.ts +7 -0
  131. package/dist/js/handlers.d.ts +5 -0
  132. package/dist/js/index.d.ts +4 -0
  133. package/dist/js/module-graph/ignored-exports.d.ts +18 -0
  134. package/dist/js/module-graph/types.d.ts +17 -0
  135. package/dist/js/node-path-walker/export-handlers.d.ts +12 -0
  136. package/dist/js/node-path-walker/import-tokens.d.ts +24 -0
  137. package/dist/js/precheck.d.ts +2 -0
  138. package/dist/js/sourceAnalysis.d.ts +17 -0
  139. package/dist/js/syntax.d.ts +10 -0
  140. package/dist/js/taggedTemplateIgnore.d.ts +13 -0
  141. package/dist/js/types.d.ts +11 -0
  142. package/dist/lightningcss/index.d.ts +8 -0
  143. package/dist/lightningcss/style-handler/options.d.ts +3 -0
  144. package/dist/lightningcss/style-handler/selector-transform.d.ts +10 -0
  145. package/dist/lightningcss/style-handler/selector-utils.d.ts +10 -0
  146. package/dist/lightningcss/style-handler.d.ts +17 -0
  147. package/dist/loader-anchors-CNkWT8hx.js +273 -0
  148. package/dist/loader-anchors-TrU7EUr7.mjs +205 -0
  149. package/dist/logger/index.d.ts +2 -0
  150. package/dist/logger-BZ45DZJT.js +1003 -0
  151. package/dist/logger-BoVx1Dbt.mjs +935 -0
  152. package/dist/patcher-options-6gJN2EXy.js +115 -0
  153. package/dist/patcher-options-DQfR5xxT.mjs +92 -0
  154. package/dist/postcss-html-transform.d.ts +3 -3
  155. package/dist/postcss-html-transform.js +7 -10
  156. package/dist/postcss-html-transform.mjs +3 -6
  157. package/dist/postcss.d.ts +15 -0
  158. package/dist/postcss.js +280 -0
  159. package/dist/postcss.mjs +270 -0
  160. package/dist/presets/hbuilderx.d.ts +4 -0
  161. package/dist/presets/index.d.ts +3 -0
  162. package/dist/presets/shared.d.ts +10 -0
  163. package/dist/presets/taro.d.ts +4 -0
  164. package/dist/presets/uni-app-x.d.ts +16 -0
  165. package/dist/presets/uni-app.d.ts +4 -0
  166. package/dist/presets.d.ts +1 -76
  167. package/dist/presets.js +115 -163
  168. package/dist/presets.mjs +107 -163
  169. package/dist/recorder-gYSNLfOP.js +2878 -0
  170. package/dist/recorder-zsgatmkB.mjs +2763 -0
  171. package/dist/reset/index.d.ts +2 -0
  172. package/dist/reset.d.ts +1 -4
  173. package/dist/reset.js +19 -8
  174. package/dist/reset.mjs +2 -8
  175. package/dist/shared/classname-transform.d.ts +14 -0
  176. package/dist/shared/mpx.d.ts +7 -0
  177. package/dist/shared/tailwindcss-css-redirect.d.ts +1 -0
  178. package/dist/tailwindcss/index.d.ts +11 -0
  179. package/dist/tailwindcss/miniprogram.d.ts +1 -0
  180. package/dist/tailwindcss/patcher-options.d.ts +56 -0
  181. package/dist/tailwindcss/patcher-resolve.d.ts +4 -0
  182. package/dist/tailwindcss/patcher.d.ts +13 -0
  183. package/dist/tailwindcss/recorder.d.ts +13 -0
  184. package/dist/tailwindcss/remove-unsupported-css.d.ts +2 -0
  185. package/dist/tailwindcss/runtime/cache.d.ts +11 -0
  186. package/dist/tailwindcss/runtime-logs.d.ts +3 -0
  187. package/dist/tailwindcss/runtime.d.ts +29 -0
  188. package/dist/tailwindcss/targets/paths.d.ts +13 -0
  189. package/dist/tailwindcss/targets/record-io.d.ts +5 -0
  190. package/dist/tailwindcss/targets/recorder.d.ts +3 -0
  191. package/dist/tailwindcss/targets/types.d.ts +35 -0
  192. package/dist/tailwindcss/targets.d.ts +6 -0
  193. package/dist/tailwindcss/v3-engine/generator.d.ts +2 -0
  194. package/dist/tailwindcss/v3-engine/index.d.ts +4 -0
  195. package/dist/tailwindcss/v3-engine/miniprogram.d.ts +4 -0
  196. package/dist/tailwindcss/v3-engine/source.d.ts +5 -0
  197. package/dist/tailwindcss/v3-engine/types.d.ts +55 -0
  198. package/dist/tailwindcss/v4/config.d.ts +5 -0
  199. package/dist/tailwindcss/v4/css-entries.d.ts +7 -0
  200. package/dist/tailwindcss/v4/index.d.ts +2 -0
  201. package/dist/tailwindcss/v4/multi-patcher.d.ts +2 -0
  202. package/dist/tailwindcss/v4/patcher-options.d.ts +24 -0
  203. package/dist/tailwindcss/v4/patcher.d.ts +14 -0
  204. package/dist/tailwindcss/v4-engine/candidates.d.ts +2 -0
  205. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -0
  206. package/dist/tailwindcss/v4-engine/generator.d.ts +2 -0
  207. package/dist/tailwindcss/v4-engine/index.d.ts +5 -0
  208. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +5 -0
  209. package/dist/tailwindcss/v4-engine/source.d.ts +7 -0
  210. package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +1 -0
  211. package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +1 -0
  212. package/dist/tailwindcss/v4-engine/tailwind-v4-default-colors.d.ts +1 -0
  213. package/dist/tailwindcss/v4-engine/types.d.ts +19 -0
  214. package/dist/typedoc.export.d.ts +5 -0
  215. package/dist/types/base.d.ts +1 -0
  216. package/dist/types/disabled-options.d.ts +4 -0
  217. package/dist/types/index.d.ts +104 -0
  218. package/dist/types/shared.d.ts +7 -0
  219. package/dist/types/user-defined-options/general.d.ts +31 -0
  220. package/dist/types/user-defined-options/important.d.ts +37 -0
  221. package/dist/types/user-defined-options/index.d.ts +11 -0
  222. package/dist/types/user-defined-options/lifecycle.d.ts +6 -0
  223. package/dist/types/user-defined-options/matcher.d.ts +9 -0
  224. package/dist/types.d.ts +1 -150
  225. package/dist/types.js +0 -1
  226. package/dist/types.mjs +1 -1
  227. package/dist/uni-app-x/component-local-style.d.ts +19 -0
  228. package/dist/uni-app-x/index.d.ts +2 -0
  229. package/dist/uni-app-x/options.d.ts +12 -0
  230. package/dist/uni-app-x/style-isolation.d.ts +2 -0
  231. package/dist/uni-app-x/transform.d.ts +9 -0
  232. package/dist/uni-app-x/vite.d.ts +36 -0
  233. package/dist/utils/decode.d.ts +2 -0
  234. package/dist/utils/disabled.d.ts +6 -0
  235. package/dist/utils/hbuilderx.d.ts +5 -0
  236. package/dist/utils/index.d.ts +7 -0
  237. package/dist/utils/nameMatcher.d.ts +4 -0
  238. package/dist/utils/resolve-package.d.ts +1 -0
  239. package/dist/utils/uni-platform.d.ts +11 -0
  240. package/dist/utils-7DUGTFED.mjs +48 -0
  241. package/dist/utils-DmC9_In3.js +61 -0
  242. package/dist/vite-BC9U7ahn.js +2199 -0
  243. package/dist/vite-CrlzCNqz.mjs +2186 -0
  244. package/dist/vite.d.ts +4 -17
  245. package/dist/vite.js +5 -14
  246. package/dist/vite.mjs +2 -14
  247. package/dist/weapp-tw-css-import-rewrite-loader.js +59 -92
  248. package/dist/weapp-tw-runtime-classset-loader.js +31 -50
  249. package/dist/webpack-Bu6M-Hbw.mjs +441 -0
  250. package/dist/webpack-DD7A6V0u.js +456 -0
  251. package/dist/webpack.d.ts +4 -25
  252. package/dist/webpack.js +6 -17
  253. package/dist/webpack.mjs +2 -17
  254. package/dist/webpack4.d.ts +4 -26
  255. package/dist/webpack4.js +375 -481
  256. package/dist/webpack4.mjs +366 -482
  257. package/dist/wxml/Tokenizer.d.ts +15 -0
  258. package/dist/wxml/custom-attributes.d.ts +4 -0
  259. package/dist/wxml/index.d.ts +2 -0
  260. package/dist/wxml/shared.d.ts +2 -0
  261. package/dist/wxml/tokenizer/types.d.ts +18 -0
  262. package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +2 -0
  263. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +8 -0
  264. package/dist/wxml/utils/codegen.d.ts +2 -0
  265. package/dist/wxml/utils/custom-template.d.ts +3 -0
  266. package/dist/wxml/utils/fragment-helpers.d.ts +6 -0
  267. package/dist/wxml/utils/fragment-updater.d.ts +4 -0
  268. package/dist/wxml/utils/template-fragments.d.ts +3 -0
  269. package/dist/wxml/utils.d.ts +8 -0
  270. package/dist/wxml/whitespace.d.ts +2 -0
  271. package/generator-placeholder.css +1 -0
  272. package/package.json +19 -8
  273. package/dist/chunk-24AGZQVR.js +0 -183
  274. package/dist/chunk-3VQKDHGP.mjs +0 -179
  275. package/dist/chunk-4AFQP74Z.js +0 -24
  276. package/dist/chunk-57SOQCAU.mjs +0 -582
  277. package/dist/chunk-5ZYHNDEK.mjs +0 -2439
  278. package/dist/chunk-76S2EME4.mjs +0 -34
  279. package/dist/chunk-A5PB4KZT.js +0 -138
  280. package/dist/chunk-DUHYLR2R.js +0 -276
  281. package/dist/chunk-DYLQ6UOI.js +0 -71
  282. package/dist/chunk-E7I5TW5K.js +0 -52
  283. package/dist/chunk-FS2NOOEB.js +0 -292
  284. package/dist/chunk-HVNGIKLS.js +0 -3930
  285. package/dist/chunk-JZQBZHN5.js +0 -579
  286. package/dist/chunk-KGTVD4EP.mjs +0 -3930
  287. package/dist/chunk-NNOQDMUP.mjs +0 -10
  288. package/dist/chunk-OF6MFURR.js +0 -34
  289. package/dist/chunk-OFB2KBRP.js +0 -2442
  290. package/dist/chunk-OOHJLO5M.mjs +0 -71
  291. package/dist/chunk-PCDYXXSK.mjs +0 -1515
  292. package/dist/chunk-RKISS72P.js +0 -7
  293. package/dist/chunk-RRQZL7FQ.mjs +0 -292
  294. package/dist/chunk-XAKAD2CR.mjs +0 -138
  295. package/dist/chunk-XZP3MREK.mjs +0 -276
  296. package/dist/chunk-ZAA5ZG3D.js +0 -1518
  297. package/dist/chunk-ZCH4YINE.mjs +0 -52
  298. package/dist/cli.d.mts +0 -2
  299. package/dist/core.d.mts +0 -26
  300. package/dist/css-macro/postcss.d.mts +0 -7
  301. package/dist/css-macro.d.mts +0 -18
  302. package/dist/defaults.d.mts +0 -11
  303. package/dist/gulp.d.mts +0 -24
  304. package/dist/index-BXrmQelt.d.mts +0 -672
  305. package/dist/index-BXrmQelt.d.ts +0 -672
  306. package/dist/index.d.mts +0 -15
  307. package/dist/postcss-html-transform.d.mts +0 -2
  308. package/dist/presets.d.mts +0 -76
  309. package/dist/reset.d.mts +0 -1
  310. package/dist/types.d.mts +0 -150
  311. package/dist/vite.d.mts +0 -17
  312. package/dist/webpack.d.mts +0 -25
  313. package/dist/webpack4.d.mts +0 -26
@@ -1,1515 +0,0 @@
1
- import {
2
- defuOverrideArray
3
- } from "./chunk-OOHJLO5M.mjs";
4
-
5
- // src/tailwindcss/patcher-options.ts
6
- function resolveTailwindcssOptions(options) {
7
- if (!options) {
8
- return void 0;
9
- }
10
- const compatOptions = options;
11
- return compatOptions.tailwindcss ?? compatOptions.tailwind;
12
- }
13
- function normalizeExtendLengthUnits(value) {
14
- if (value === false) {
15
- return false;
16
- }
17
- if (value === true) {
18
- return { enabled: true };
19
- }
20
- if (value && typeof value === "object") {
21
- return {
22
- enabled: true,
23
- ...value
24
- };
25
- }
26
- return void 0;
27
- }
28
- function normalizeTailwindcssPatcherOptions(options) {
29
- if (!options) {
30
- return void 0;
31
- }
32
- if ("patch" in options) {
33
- const { cache, patch } = options;
34
- const normalized = {};
35
- if (cache !== void 0) {
36
- normalized.cache = cache;
37
- }
38
- const apply = {};
39
- const extract = {};
40
- if (patch?.overwrite !== void 0) {
41
- apply.overwrite = patch.overwrite;
42
- }
43
- if (patch?.filter) {
44
- normalized.filter = patch.filter;
45
- }
46
- const extendLengthUnits = normalizeExtendLengthUnits(patch?.applyPatches?.extendLengthUnits);
47
- const exposeContext = patch?.applyPatches?.exportContext;
48
- if (extendLengthUnits !== void 0 || exposeContext !== void 0) {
49
- apply.exposeContext = exposeContext;
50
- apply.extendLengthUnits = extendLengthUnits;
51
- }
52
- const cwd = patch?.cwd ?? patch?.basedir;
53
- if (cwd) {
54
- normalized.projectRoot = cwd;
55
- }
56
- const tailwindOptions = patch?.tailwindcss ? { ...patch.tailwindcss } : void 0;
57
- const legacyResolve = patch?.resolve;
58
- let nextTailwindOptions = tailwindOptions;
59
- if (nextTailwindOptions?.version === 2 && !nextTailwindOptions.packageName) {
60
- nextTailwindOptions = {
61
- ...nextTailwindOptions,
62
- packageName: "@tailwindcss/postcss7-compat",
63
- postcssPlugin: nextTailwindOptions.postcssPlugin
64
- };
65
- if (!nextTailwindOptions.postcssPlugin) {
66
- nextTailwindOptions.postcssPlugin = "@tailwindcss/postcss7-compat";
67
- }
68
- }
69
- if (nextTailwindOptions || legacyResolve) {
70
- const resolveOptions = nextTailwindOptions?.resolve;
71
- const mergedResolve = legacyResolve || resolveOptions ? {
72
- ...resolveOptions ?? {},
73
- ...legacyResolve ?? {}
74
- } : void 0;
75
- normalized.tailwindcss = {
76
- ...nextTailwindOptions ?? {},
77
- ...mergedResolve ? { resolve: mergedResolve } : {}
78
- };
79
- }
80
- if (patch?.output) {
81
- if (patch.output.filename !== void 0) {
82
- extract.file = patch.output.filename;
83
- }
84
- if (patch.output.loose !== void 0) {
85
- extract.pretty = patch.output.loose ? 2 : false;
86
- }
87
- if (patch.output.removeUniversalSelector !== void 0) {
88
- extract.removeUniversalSelector = patch.output.removeUniversalSelector;
89
- }
90
- }
91
- if (Object.keys(apply).length > 0) {
92
- normalized.apply = apply;
93
- }
94
- if (Object.keys(extract).length > 0) {
95
- normalized.extract = extract;
96
- }
97
- return toModernTailwindcssPatchOptions(normalized);
98
- }
99
- return toModernTailwindcssPatchOptions(options);
100
- }
101
- function toModernTailwindcssPatchOptions(options) {
102
- if (!options) {
103
- return void 0;
104
- }
105
- const normalized = {};
106
- if (options.cache !== void 0) {
107
- normalized.cache = options.cache;
108
- }
109
- if (options.filter) {
110
- normalized.filter = options.filter;
111
- }
112
- const projectRoot = options.projectRoot ?? options.cwd;
113
- if (projectRoot) {
114
- normalized.projectRoot = projectRoot;
115
- }
116
- const tailwindcss = resolveTailwindcssOptions(options);
117
- if (tailwindcss) {
118
- normalized.tailwindcss = {
119
- ...tailwindcss
120
- };
121
- }
122
- const apply = {
123
- ...options.apply ?? {}
124
- };
125
- if (apply.overwrite === void 0 && options.overwrite !== void 0) {
126
- apply.overwrite = options.overwrite;
127
- }
128
- if (apply.exposeContext === void 0 && options.features?.exposeContext !== void 0) {
129
- apply.exposeContext = options.features.exposeContext;
130
- }
131
- if (apply.extendLengthUnits === void 0 && options.features?.extendLengthUnits !== void 0) {
132
- apply.extendLengthUnits = options.features.extendLengthUnits;
133
- }
134
- if (Object.keys(apply).length > 0) {
135
- normalized.apply = apply;
136
- }
137
- const extract = {
138
- ...options.extract ?? {}
139
- };
140
- if (options.output) {
141
- if (extract.write === void 0 && options.output.enabled !== void 0) {
142
- extract.write = options.output.enabled;
143
- }
144
- if (extract.file === void 0 && options.output.file !== void 0) {
145
- extract.file = options.output.file;
146
- }
147
- if (extract.format === void 0 && options.output.format !== void 0) {
148
- extract.format = options.output.format;
149
- }
150
- if (extract.pretty === void 0 && options.output.pretty !== void 0) {
151
- extract.pretty = options.output.pretty;
152
- }
153
- if (extract.removeUniversalSelector === void 0 && options.output.removeUniversalSelector !== void 0) {
154
- extract.removeUniversalSelector = options.output.removeUniversalSelector;
155
- }
156
- }
157
- if (Object.keys(extract).length > 0) {
158
- normalized.extract = extract;
159
- }
160
- return normalized;
161
- }
162
-
163
- // src/tailwindcss/runtime/cache.ts
164
- import { statSync } from "fs";
165
- var runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
166
- var runtimeFileSignatureCache = /* @__PURE__ */ new Map();
167
- var runtimeFileSignatureCacheClearTimer;
168
- var runtimeSignaturePatchersSymbol = /* @__PURE__ */ Symbol.for("weapp-tailwindcss.runtimeSignaturePatchers");
169
- function getCacheEntry(twPatcher) {
170
- let entry = runtimeClassSetCache.get(twPatcher);
171
- if (!entry) {
172
- entry = {};
173
- runtimeClassSetCache.set(twPatcher, entry);
174
- }
175
- return entry;
176
- }
177
- function scheduleRuntimeConfigSignatureCacheClear() {
178
- if (runtimeFileSignatureCacheClearTimer) {
179
- return;
180
- }
181
- runtimeFileSignatureCacheClearTimer = setTimeout(() => {
182
- runtimeFileSignatureCache.clear();
183
- runtimeFileSignatureCacheClearTimer = void 0;
184
- }, 0);
185
- runtimeFileSignatureCacheClearTimer.unref?.();
186
- }
187
- function getFileSignature(filePath) {
188
- const cached = runtimeFileSignatureCache.get(filePath);
189
- if (cached !== void 0) {
190
- return cached;
191
- }
192
- let signature;
193
- try {
194
- const stats = statSync(filePath);
195
- signature = `${filePath}:${stats.size}:${stats.mtimeMs}`;
196
- } catch {
197
- signature = `${filePath}:missing`;
198
- }
199
- runtimeFileSignatureCache.set(filePath, signature);
200
- scheduleRuntimeConfigSignatureCacheClear();
201
- return signature;
202
- }
203
- function getTailwindTrackedFiles(twPatcher) {
204
- const tailwindOptions = resolveTailwindcssOptions(twPatcher.options);
205
- const tracked = /* @__PURE__ */ new Set();
206
- const configPath = tailwindOptions?.config;
207
- if (typeof configPath === "string" && configPath.length > 0) {
208
- tracked.add(configPath);
209
- }
210
- for (const entry of tailwindOptions?.v4?.cssEntries ?? []) {
211
- if (typeof entry === "string" && entry.length > 0) {
212
- tracked.add(entry);
213
- }
214
- }
215
- return tracked;
216
- }
217
- function normalizeSignatureValue(value) {
218
- if (value == null) {
219
- return "null";
220
- }
221
- if (typeof value === "string") {
222
- return value;
223
- }
224
- if (typeof value === "number" || typeof value === "boolean") {
225
- return String(value);
226
- }
227
- if (Array.isArray(value)) {
228
- return `[${value.map((item) => normalizeSignatureValue(item)).join(",")}]`;
229
- }
230
- if (typeof value === "object") {
231
- const entries = Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a.localeCompare(b));
232
- return `{${entries.map(([key, item]) => `${key}:${normalizeSignatureValue(item)}`).join(",")}}`;
233
- }
234
- return String(value);
235
- }
236
- function readOptionalProperty(value, key) {
237
- if (typeof value !== "object" || value === null || !(key in value)) {
238
- return void 0;
239
- }
240
- return value[key];
241
- }
242
- function getTailwindOptionsSignature(twPatcher) {
243
- const options = twPatcher.options;
244
- const tailwindOptions = resolveTailwindcssOptions(options);
245
- return normalizeSignatureValue({
246
- projectRoot: options?.projectRoot,
247
- packageName: tailwindOptions?.packageName,
248
- versionHint: readOptionalProperty(tailwindOptions, "versionHint"),
249
- cwd: tailwindOptions?.cwd,
250
- config: tailwindOptions?.config,
251
- v2: tailwindOptions?.v2,
252
- v3: tailwindOptions?.v3,
253
- v4: {
254
- base: tailwindOptions?.v4?.base,
255
- configuredBase: readOptionalProperty(tailwindOptions?.v4, "configuredBase"),
256
- css: tailwindOptions?.v4?.css,
257
- cssEntries: tailwindOptions?.v4?.cssEntries,
258
- hasUserDefinedSources: readOptionalProperty(tailwindOptions?.v4, "hasUserDefinedSources"),
259
- sources: tailwindOptions?.v4?.sources
260
- }
261
- });
262
- }
263
- function getPatchTargetSignature(twPatcher) {
264
- const packageInfo = twPatcher.packageInfo;
265
- return [
266
- packageInfo?.name ?? "missing",
267
- packageInfo?.rootPath ?? "missing",
268
- packageInfo?.version ?? "unknown",
269
- twPatcher.majorVersion ?? "unknown",
270
- getTailwindOptionsSignature(twPatcher)
271
- ].join(":");
272
- }
273
- function getNestedPatchers(twPatcher) {
274
- const nested = twPatcher[runtimeSignaturePatchersSymbol];
275
- return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
276
- }
277
- function getOwnRuntimeClassSetSignature(twPatcher) {
278
- const trackedFiles = [...getTailwindTrackedFiles(twPatcher)].sort((a, b) => a.localeCompare(b)).map(getFileSignature);
279
- const configSignature = trackedFiles.length > 0 ? trackedFiles.join("|") : "files:missing";
280
- const patchTargetSignature = getPatchTargetSignature(twPatcher);
281
- return `${configSignature}|patch:${patchTargetSignature}`;
282
- }
283
- function invalidateRuntimeClassSet(twPatcher) {
284
- if (!twPatcher) {
285
- return;
286
- }
287
- const nestedPatchers = getNestedPatchers(twPatcher);
288
- if (nestedPatchers) {
289
- for (const patcher of nestedPatchers) {
290
- invalidateRuntimeClassSet(patcher);
291
- }
292
- }
293
- for (const trackedFile of getTailwindTrackedFiles(twPatcher)) {
294
- runtimeFileSignatureCache.delete(trackedFile);
295
- }
296
- runtimeClassSetCache.delete(twPatcher);
297
- }
298
- function getRuntimeClassSetCacheEntry(twPatcher) {
299
- return getCacheEntry(twPatcher);
300
- }
301
- function getRuntimeClassSetSignature(twPatcher) {
302
- const nestedPatchers = getNestedPatchers(twPatcher);
303
- if (nestedPatchers) {
304
- return nestedPatchers.map(getOwnRuntimeClassSetSignature).sort((a, b) => a.localeCompare(b)).join("||");
305
- }
306
- return getOwnRuntimeClassSetSignature(twPatcher);
307
- }
308
-
309
- // src/context/workspace.ts
310
- import { existsSync, readdirSync, readFileSync } from "fs";
311
- import path from "path";
312
- var IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
313
- "node_modules",
314
- ".git",
315
- ".hg",
316
- ".svn",
317
- ".turbo",
318
- ".output",
319
- ".next",
320
- "dist",
321
- "build"
322
- ]);
323
- function findWorkspaceRoot(startDir) {
324
- if (!startDir) {
325
- return void 0;
326
- }
327
- let current = path.resolve(startDir);
328
- while (true) {
329
- const workspaceFile = path.join(current, "pnpm-workspace.yaml");
330
- if (existsSync(workspaceFile)) {
331
- return current;
332
- }
333
- const parent = path.dirname(current);
334
- if (parent === current) {
335
- return void 0;
336
- }
337
- current = parent;
338
- }
339
- }
340
- function findNearestPackageRoot(startDir) {
341
- if (!startDir) {
342
- return void 0;
343
- }
344
- let current = path.resolve(startDir);
345
- while (true) {
346
- const pkgPath = path.join(current, "package.json");
347
- if (existsSync(pkgPath)) {
348
- return current;
349
- }
350
- const parent = path.dirname(current);
351
- if (parent === current) {
352
- return void 0;
353
- }
354
- current = parent;
355
- }
356
- }
357
- function findWorkspacePackageDir(rootDir, packageName) {
358
- const visited = /* @__PURE__ */ new Set();
359
- const queue = [path.resolve(rootDir)];
360
- while (queue.length > 0) {
361
- const current = queue.shift();
362
- const normalized = path.normalize(current);
363
- if (visited.has(normalized)) {
364
- continue;
365
- }
366
- visited.add(normalized);
367
- try {
368
- const pkgPath = path.join(normalized, "package.json");
369
- if (existsSync(pkgPath)) {
370
- const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
371
- if (pkg?.name === packageName) {
372
- return normalized;
373
- }
374
- }
375
- } catch {
376
- }
377
- let entries;
378
- try {
379
- entries = readdirSync(normalized, { withFileTypes: true });
380
- } catch {
381
- continue;
382
- }
383
- for (const entry of entries) {
384
- if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) {
385
- continue;
386
- }
387
- queue.push(path.join(normalized, entry.name));
388
- }
389
- }
390
- return void 0;
391
- }
392
-
393
- // src/tailwindcss/v4/config.ts
394
- import { logger } from "@weapp-tailwindcss/logger";
395
- var DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
396
- function includesToken(list, token) {
397
- return list.some((candidate) => {
398
- if (typeof token === "string") {
399
- if (typeof candidate === "string") {
400
- return candidate === token;
401
- }
402
- candidate.lastIndex = 0;
403
- return candidate.test(token);
404
- }
405
- if (typeof candidate === "string") {
406
- token.lastIndex = 0;
407
- return token.test(candidate);
408
- }
409
- return candidate.source === token.source && candidate.flags === token.flags;
410
- });
411
- }
412
- function ensureDefaultsIncluded(value) {
413
- if (value === true) {
414
- return {
415
- includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
416
- };
417
- }
418
- if (Array.isArray(value)) {
419
- if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) {
420
- return value;
421
- }
422
- const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(value, token));
423
- return missing.length > 0 ? [...value, ...missing] : value;
424
- }
425
- if (value && typeof value === "object") {
426
- const include = value.includeCustomProperties;
427
- if (!Array.isArray(include)) {
428
- return {
429
- ...value,
430
- includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
431
- };
432
- }
433
- if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) {
434
- return value;
435
- }
436
- const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(include, token));
437
- return missing.length > 0 ? {
438
- ...value,
439
- includeCustomProperties: [...include, ...missing]
440
- } : value;
441
- }
442
- return value;
443
- }
444
- function normalizeCssEntriesConfig(entries) {
445
- if (!entries) {
446
- return void 0;
447
- }
448
- if (typeof entries === "string") {
449
- const trimmed = entries.trim();
450
- return trimmed ? [trimmed] : void 0;
451
- }
452
- if (!Array.isArray(entries)) {
453
- return void 0;
454
- }
455
- const normalized = entries.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
456
- return normalized.length > 0 ? normalized : void 0;
457
- }
458
- function hasConfiguredCssEntries(ctx) {
459
- if (normalizeCssEntriesConfig(ctx.cssEntries)) {
460
- return true;
461
- }
462
- if (normalizeCssEntriesConfig(ctx.tailwindcss?.v4?.cssEntries)) {
463
- return true;
464
- }
465
- const patcherOptions = ctx.tailwindcssPatcherOptions;
466
- if (patcherOptions) {
467
- if (normalizeCssEntriesConfig(patcherOptions.tailwindcss?.v4?.cssEntries)) {
468
- return true;
469
- }
470
- if (normalizeCssEntriesConfig(patcherOptions.tailwind?.v4?.cssEntries)) {
471
- return true;
472
- }
473
- if (normalizeCssEntriesConfig(patcherOptions.patch?.tailwindcss?.v4?.cssEntries)) {
474
- return true;
475
- }
476
- }
477
- return false;
478
- }
479
- var hasWarnedMissingCssEntries = false;
480
- function warnMissingCssEntries(ctx, patcher) {
481
- if (hasWarnedMissingCssEntries) {
482
- return;
483
- }
484
- if (patcher?.majorVersion !== 4) {
485
- return;
486
- }
487
- if (hasConfiguredCssEntries(ctx)) {
488
- return;
489
- }
490
- hasWarnedMissingCssEntries = true;
491
- logger.warn(
492
- '[tailwindcss@4] \u672A\u68C0\u6D4B\u5230 cssEntries \u914D\u7F6E\u3002\u8BF7\u4F20\u5165\u5305\u542B tailwindcss \u5F15\u7528\u7684 CSS \u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4F8B\u5982 cssEntries: ["/absolute/path/to/src/app.css"]\uFF0C\u5426\u5219 tailwindcss \u751F\u6210\u7684\u7C7B\u540D\u4E0D\u4F1A\u53C2\u4E0E\u8F6C\u8BD1\u3002'
493
- );
494
- }
495
- function applyV4CssCalcDefaults(cssCalc, patcher) {
496
- const cssCalcOptions = cssCalc ?? patcher?.majorVersion === 4;
497
- if (patcher?.majorVersion === 4 && cssCalcOptions) {
498
- return ensureDefaultsIncluded(cssCalcOptions);
499
- }
500
- return cssCalcOptions;
501
- }
502
-
503
- // src/tailwindcss/patcher-resolve.ts
504
- import { existsSync as existsSync2 } from "fs";
505
- import { createRequire } from "module";
506
- import path2 from "path";
507
- import process from "process";
508
- import { fileURLToPath } from "url";
509
- var GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
510
- var DEFAULT_TAILWIND_CONFIG_SPECIFIERS = [
511
- "stubs/config.full.js",
512
- "defaultConfig.js"
513
- ];
514
- var TAILWIND_CONFIG_FILES = [
515
- "tailwind.config.js",
516
- "tailwind.config.cjs",
517
- "tailwind.config.mjs",
518
- "tailwind.config.ts",
519
- "tailwind.config.cts",
520
- "tailwind.config.mts"
521
- ];
522
- function isPathSpecifier(specifier) {
523
- if (!specifier) {
524
- return false;
525
- }
526
- if (specifier.startsWith("file://")) {
527
- return true;
528
- }
529
- if (path2.isAbsolute(specifier)) {
530
- return true;
531
- }
532
- return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
533
- }
534
- function resolveModuleFromPaths(specifier, paths) {
535
- if (!specifier || isPathSpecifier(specifier) || paths.length === 0) {
536
- return void 0;
537
- }
538
- try {
539
- const req = createRequire(import.meta.url);
540
- return req.resolve(specifier, { paths });
541
- } catch {
542
- return void 0;
543
- }
544
- }
545
- function resolveTailwindConfigFallback(packageName, paths) {
546
- if (!packageName) {
547
- return void 0;
548
- }
549
- for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
550
- const candidate = `${packageName}/${suffix}`;
551
- const resolved = resolveModuleFromPaths(candidate, paths);
552
- if (resolved) {
553
- return resolved;
554
- }
555
- }
556
- return void 0;
557
- }
558
- function appendNodeModules(paths, dir) {
559
- if (!dir) {
560
- return;
561
- }
562
- const nodeModulesDir = path2.join(dir, "node_modules");
563
- if (existsSync2(nodeModulesDir)) {
564
- paths.add(nodeModulesDir);
565
- }
566
- }
567
- function findTailwindConfig(searchRoots) {
568
- for (const root of searchRoots) {
569
- for (const file of TAILWIND_CONFIG_FILES) {
570
- const candidate = path2.resolve(root, file);
571
- if (existsSync2(candidate)) {
572
- return candidate;
573
- }
574
- }
575
- }
576
- return void 0;
577
- }
578
- function createDefaultResolvePaths(basedir) {
579
- const paths = /* @__PURE__ */ new Set();
580
- let fallbackCandidates = [];
581
- if (basedir) {
582
- const resolvedBase = path2.resolve(basedir);
583
- appendNodeModules(paths, resolvedBase);
584
- fallbackCandidates.push(resolvedBase);
585
- const packageRoot = findNearestPackageRoot(resolvedBase);
586
- if (packageRoot) {
587
- appendNodeModules(paths, packageRoot);
588
- fallbackCandidates.push(packageRoot);
589
- }
590
- }
591
- const cwd = process.cwd();
592
- appendNodeModules(paths, cwd);
593
- try {
594
- const modulePath = fileURLToPath(import.meta.url);
595
- const candidate = existsSync2(modulePath) && !path2.extname(modulePath) ? modulePath : path2.dirname(modulePath);
596
- paths.add(candidate);
597
- } catch {
598
- paths.add(import.meta.url);
599
- }
600
- if (paths.size === 0) {
601
- fallbackCandidates = fallbackCandidates.filter(Boolean);
602
- if (fallbackCandidates.length === 0) {
603
- fallbackCandidates.push(cwd);
604
- }
605
- for (const candidate of fallbackCandidates) {
606
- paths.add(candidate);
607
- }
608
- }
609
- return [...paths];
610
- }
611
-
612
- // src/tailwindcss/v4/patcher.ts
613
- import { logger as logger3 } from "@weapp-tailwindcss/logger";
614
-
615
- // src/tailwindcss/patcher.ts
616
- import path3 from "path";
617
- import process2 from "process";
618
- import { logger as logger2 } from "@weapp-tailwindcss/logger";
619
- import { defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
620
- import { TailwindcssPatcher } from "tailwindcss-patch";
621
- function createFallbackTailwindcssPatcher() {
622
- const packageInfo = {
623
- name: "tailwindcss",
624
- version: void 0,
625
- rootPath: "",
626
- packageJsonPath: "",
627
- packageJson: {}
628
- };
629
- return {
630
- packageInfo,
631
- async patch() {
632
- return {
633
- exposeContext: void 0,
634
- extendLengthUnits: void 0
635
- };
636
- },
637
- async getClassSet() {
638
- return /* @__PURE__ */ new Set();
639
- },
640
- async extract(_options) {
641
- const classSet = /* @__PURE__ */ new Set();
642
- return {
643
- classList: [],
644
- classSet
645
- };
646
- },
647
- async collectContentTokens() {
648
- return {
649
- entries: [],
650
- filesScanned: 0,
651
- sources: [],
652
- skippedFiles: []
653
- };
654
- }
655
- };
656
- }
657
- var hasLoggedMissingTailwind = false;
658
- var TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
659
- var UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
660
- function isTailwindcssV4PackageName(packageName) {
661
- return packageName === "@tailwindcss/postcss" || packageName === "tailwindcss4" || Boolean(packageName && packageName.includes("tailwindcss4"));
662
- }
663
- function createTailwindcssPatcher(options) {
664
- const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
665
- const cache = {
666
- driver: "memory"
667
- };
668
- const normalizedBasedir = basedir ? path3.resolve(basedir) : void 0;
669
- const cacheRoot = findNearestPackageRoot(normalizedBasedir) ?? normalizedBasedir ?? process2.cwd();
670
- if (cacheDir) {
671
- if (path3.isAbsolute(cacheDir)) {
672
- cache.dir = cacheDir;
673
- } else if (normalizedBasedir) {
674
- cache.dir = path3.resolve(normalizedBasedir, cacheDir);
675
- } else {
676
- cache.dir = path3.resolve(process2.cwd(), cacheDir);
677
- }
678
- } else {
679
- cache.dir = path3.join(cacheRoot, "node_modules", ".cache", "tailwindcss-patch");
680
- }
681
- if (normalizedBasedir) {
682
- cache.cwd = normalizedBasedir;
683
- }
684
- const resolvePaths = createDefaultResolvePaths(cache.cwd ?? normalizedBasedir ?? process2.cwd());
685
- const normalizedUserOptions = normalizeTailwindcssPatcherOptions(tailwindcssPatcherOptions);
686
- const extendLengthUnits = normalizeExtendLengthUnits(supportCustomLengthUnitsPatch ?? true);
687
- const baseTailwindOptions = defuOverrideArray2(
688
- tailwindcss ?? {},
689
- {
690
- cwd: normalizedBasedir,
691
- resolve: {
692
- paths: resolvePaths
693
- }
694
- }
695
- );
696
- if (baseTailwindOptions.version === 2) {
697
- if (!baseTailwindOptions.packageName) {
698
- baseTailwindOptions.packageName = "@tailwindcss/postcss7-compat";
699
- }
700
- if (!baseTailwindOptions.postcssPlugin) {
701
- baseTailwindOptions.postcssPlugin = "@tailwindcss/postcss7-compat";
702
- }
703
- } else if (!baseTailwindOptions.packageName) {
704
- baseTailwindOptions.packageName = "tailwindcss";
705
- }
706
- if (!baseTailwindOptions.postcssPlugin) {
707
- baseTailwindOptions.postcssPlugin = baseTailwindOptions.version === 4 || isTailwindcssV4PackageName(baseTailwindOptions.packageName) ? "@tailwindcss/postcss" : "tailwindcss";
708
- }
709
- if (typeof baseTailwindOptions.postcssPlugin === "string") {
710
- const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
711
- if (resolvedPlugin) {
712
- baseTailwindOptions.postcssPlugin = resolvedPlugin;
713
- }
714
- }
715
- const baseOptions = {
716
- projectRoot: normalizedBasedir,
717
- cache,
718
- tailwindcss: baseTailwindOptions,
719
- apply: {
720
- exposeContext: true,
721
- extendLengthUnits
722
- }
723
- };
724
- const mergedOptions = defuOverrideArray2(
725
- normalizedUserOptions ?? {},
726
- baseOptions
727
- );
728
- const resolvedOptions = toModernTailwindcssPatchOptions(mergedOptions) ?? {};
729
- const resolvedTailwindOptions = resolvedOptions.tailwindcss;
730
- if (resolvedTailwindOptions) {
731
- const existingResolve = resolvedTailwindOptions.resolve ?? {};
732
- const customPaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0;
733
- const sourcePaths = customPaths ? existingResolve.paths : resolvePaths;
734
- resolvedTailwindOptions.resolve = {
735
- ...existingResolve,
736
- paths: [...new Set(sourcePaths)]
737
- };
738
- logger2.debug("Tailwind resolve config %O", {
739
- packageName: resolvedTailwindOptions.packageName,
740
- version: resolvedTailwindOptions.version,
741
- resolve: resolvedTailwindOptions.resolve,
742
- cwd: resolvedTailwindOptions.cwd
743
- });
744
- if (typeof resolvedTailwindOptions.postcssPlugin === "string") {
745
- const resolvedPlugin = resolveModuleFromPaths(
746
- resolvedTailwindOptions.postcssPlugin,
747
- resolvedTailwindOptions.resolve?.paths ?? resolvePaths
748
- );
749
- if (resolvedPlugin) {
750
- resolvedTailwindOptions.postcssPlugin = resolvedPlugin;
751
- }
752
- }
753
- const searchRoots = /* @__PURE__ */ new Set();
754
- if (resolvedTailwindOptions.cwd) {
755
- searchRoots.add(resolvedTailwindOptions.cwd);
756
- }
757
- for (const resolvePath of resolvedTailwindOptions.resolve?.paths ?? []) {
758
- const parentDir = path3.dirname(resolvePath);
759
- searchRoots.add(parentDir);
760
- }
761
- const configPath = findTailwindConfig(searchRoots);
762
- if (!resolvedTailwindOptions.config) {
763
- if (configPath) {
764
- resolvedTailwindOptions.config = configPath;
765
- } else {
766
- const fallbackConfig = resolveTailwindConfigFallback(
767
- resolvedTailwindOptions.packageName,
768
- resolvedTailwindOptions.resolve.paths ?? resolvePaths
769
- );
770
- if (fallbackConfig) {
771
- resolvedTailwindOptions.config = fallbackConfig;
772
- }
773
- }
774
- }
775
- if (!resolvedTailwindOptions.cwd && configPath) {
776
- resolvedTailwindOptions.cwd = path3.dirname(configPath);
777
- }
778
- resolvedOptions.tailwindcss = resolvedTailwindOptions;
779
- }
780
- try {
781
- return new TailwindcssPatcher(resolvedOptions);
782
- } catch (error) {
783
- const searchPaths = resolvedOptions.tailwindcss?.resolve?.paths;
784
- if (error instanceof Error && TAILWINDCSS_NOT_FOUND_RE.test(error.message)) {
785
- if (!hasLoggedMissingTailwind) {
786
- logger2.warn("Tailwind CSS \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7 Tailwind \u76F8\u5173\u8865\u4E01\u3002\u82E5\u9700\u4F7F\u7528 Tailwind \u80FD\u529B\uFF0C\u8BF7\u5B89\u88C5 tailwindcss\u3002");
787
- hasLoggedMissingTailwind = true;
788
- }
789
- return createFallbackTailwindcssPatcher();
790
- }
791
- if (error instanceof Error && UNABLE_TO_LOCATE_TAILWINDCSS_RE.test(error.message)) {
792
- logger2.error('\u65E0\u6CD5\u5B9A\u4F4D Tailwind CSS \u5305 "%s"\uFF0C\u5DF2\u5C1D\u8BD5\u8DEF\u5F84: %O', resolvedOptions.tailwindcss?.packageName, searchPaths);
793
- }
794
- throw error;
795
- }
796
- }
797
-
798
- // src/tailwindcss/v4/multi-patcher.ts
799
- function createMultiTailwindcssPatcher(patchers) {
800
- if (patchers.length <= 1) {
801
- return patchers[0];
802
- }
803
- const [first] = patchers;
804
- const multiPatcher = {
805
- ...first,
806
- packageInfo: first?.packageInfo,
807
- majorVersion: first?.majorVersion,
808
- options: first?.options,
809
- async patch() {
810
- let exposeContext;
811
- let extendLengthUnits;
812
- for (const patcher of patchers) {
813
- const result = await patcher.patch();
814
- if (result?.exposeContext && exposeContext == null) {
815
- exposeContext = result.exposeContext;
816
- }
817
- if (result?.extendLengthUnits && extendLengthUnits == null) {
818
- extendLengthUnits = result.extendLengthUnits;
819
- }
820
- }
821
- return {
822
- exposeContext,
823
- extendLengthUnits
824
- };
825
- },
826
- async getClassSet() {
827
- const aggregated = /* @__PURE__ */ new Set();
828
- for (const patcher of patchers) {
829
- const current = await patcher.getClassSet();
830
- for (const className of current) {
831
- aggregated.add(className);
832
- }
833
- }
834
- return aggregated;
835
- },
836
- async extract(options) {
837
- const aggregatedSet = /* @__PURE__ */ new Set();
838
- const aggregatedList = [];
839
- let filename;
840
- for (const patcher of patchers) {
841
- const result = await patcher.extract(options);
842
- if (!result) {
843
- continue;
844
- }
845
- if (filename === void 0 && result.filename) {
846
- filename = result.filename;
847
- }
848
- if (result.classList) {
849
- for (const className of result.classList) {
850
- if (!aggregatedSet.has(className)) {
851
- aggregatedList.push(className);
852
- }
853
- aggregatedSet.add(className);
854
- }
855
- }
856
- if (result.classSet) {
857
- for (const className of result.classSet) {
858
- aggregatedSet.add(className);
859
- }
860
- }
861
- }
862
- return {
863
- classList: aggregatedList,
864
- classSet: aggregatedSet,
865
- filename
866
- };
867
- }
868
- };
869
- if (patchers.every((patcher) => typeof patcher.getClassSetSync === "function")) {
870
- multiPatcher.getClassSetSync = () => {
871
- const aggregated = /* @__PURE__ */ new Set();
872
- for (const patcher of patchers) {
873
- const current = patcher.getClassSetSync?.();
874
- if (!current) {
875
- continue;
876
- }
877
- for (const className of current) {
878
- aggregated.add(className);
879
- }
880
- }
881
- return aggregated;
882
- };
883
- }
884
- Object.defineProperty(multiPatcher, runtimeSignaturePatchersSymbol, {
885
- value: [...patchers],
886
- configurable: true
887
- });
888
- return multiPatcher;
889
- }
890
-
891
- // src/tailwindcss/v4/patcher-options.ts
892
- function isLegacyTailwindcssPatcherOptions(options) {
893
- return typeof options === "object" && options !== null && "patch" in options;
894
- }
895
- function isModernTailwindcssPatchOptions(options) {
896
- return typeof options === "object" && options !== null && !("patch" in options);
897
- }
898
- function overrideTailwindcssPatcherOptionsForBase(options, baseDir, cssEntries) {
899
- const hasCssEntries = cssEntries.length > 0;
900
- if (!options) {
901
- return options;
902
- }
903
- if (isLegacyTailwindcssPatcherOptions(options)) {
904
- const patchOptions = options.patch;
905
- if (!patchOptions) {
906
- return options;
907
- }
908
- const nextPatch = {
909
- ...patchOptions,
910
- basedir: baseDir,
911
- cwd: patchOptions.cwd ?? baseDir
912
- };
913
- if (patchOptions.tailwindcss) {
914
- const nextV4 = {
915
- ...patchOptions.tailwindcss.v4 ?? {}
916
- };
917
- if (hasCssEntries) {
918
- nextV4.cssEntries = cssEntries;
919
- } else {
920
- nextV4.cssEntries = nextV4.cssEntries ?? cssEntries;
921
- if (nextV4.base === void 0) {
922
- nextV4.base = baseDir;
923
- }
924
- }
925
- nextPatch.tailwindcss = {
926
- ...patchOptions.tailwindcss,
927
- v4: nextV4
928
- };
929
- }
930
- return {
931
- ...options,
932
- patch: nextPatch
933
- };
934
- }
935
- if (!isModernTailwindcssPatchOptions(options)) {
936
- return options;
937
- }
938
- const modernTailwind = options.tailwindcss ?? options.tailwind;
939
- if (!modernTailwind) {
940
- return options;
941
- }
942
- const { tailwind: _legacyTailwind, ...rest } = options;
943
- return {
944
- ...rest,
945
- tailwindcss: {
946
- ...modernTailwind,
947
- v4: {
948
- ...modernTailwind.v4 ?? {},
949
- ...hasCssEntries ? {} : { base: modernTailwind.v4?.base ?? baseDir },
950
- cssEntries: hasCssEntries ? cssEntries : modernTailwind.v4?.cssEntries ?? cssEntries
951
- }
952
- }
953
- };
954
- }
955
-
956
- // src/tailwindcss/v4/css-entries.ts
957
- import path4 from "path";
958
- function guessBasedirFromEntries(entries) {
959
- if (!entries) {
960
- return void 0;
961
- }
962
- for (const entry of entries) {
963
- if (typeof entry !== "string") {
964
- continue;
965
- }
966
- const trimmed = entry.trim();
967
- if (!trimmed || !path4.isAbsolute(trimmed)) {
968
- continue;
969
- }
970
- const entryDir = path4.dirname(trimmed);
971
- const resolved = findNearestPackageRoot(entryDir) ?? entryDir;
972
- if (resolved) {
973
- return resolved;
974
- }
975
- }
976
- return void 0;
977
- }
978
- function normalizeCssEntries(entries, anchor) {
979
- if (!entries || entries.length === 0) {
980
- return void 0;
981
- }
982
- const normalized = /* @__PURE__ */ new Set();
983
- for (const entry of entries) {
984
- if (typeof entry !== "string") {
985
- continue;
986
- }
987
- const trimmed = entry.trim();
988
- if (trimmed.length === 0) {
989
- continue;
990
- }
991
- const resolved = path4.isAbsolute(trimmed) ? path4.normalize(trimmed) : path4.normalize(path4.resolve(anchor, trimmed));
992
- normalized.add(resolved);
993
- }
994
- return normalized.size > 0 ? [...normalized] : void 0;
995
- }
996
- function isSubPath(parent, child) {
997
- if (!parent || !child) {
998
- return false;
999
- }
1000
- const relative = path4.relative(parent, child);
1001
- return relative === "" || !relative.startsWith("..") && !path4.isAbsolute(relative);
1002
- }
1003
- function resolveCssEntryBase(entryDir, options) {
1004
- const normalizedDir = path4.normalize(entryDir);
1005
- const { preferredBaseDir, workspaceRoot } = options;
1006
- if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) {
1007
- return preferredBaseDir;
1008
- }
1009
- if (workspaceRoot && isSubPath(workspaceRoot, normalizedDir)) {
1010
- return workspaceRoot;
1011
- }
1012
- const packageRoot = findNearestPackageRoot(normalizedDir);
1013
- if (packageRoot) {
1014
- return path4.normalize(packageRoot);
1015
- }
1016
- return normalizedDir;
1017
- }
1018
- function groupCssEntriesByBase(entries, options = {}) {
1019
- const normalizedOptions = {
1020
- preferredBaseDir: options.preferredBaseDir ? path4.normalize(options.preferredBaseDir) : void 0,
1021
- workspaceRoot: options.workspaceRoot ? path4.normalize(options.workspaceRoot) : void 0
1022
- };
1023
- const groups = /* @__PURE__ */ new Map();
1024
- for (const entry of entries) {
1025
- const entryDir = path4.dirname(entry);
1026
- const baseDir = resolveCssEntryBase(entryDir, normalizedOptions);
1027
- const bucket = groups.get(baseDir);
1028
- if (bucket) {
1029
- bucket.push(entry);
1030
- } else {
1031
- groups.set(baseDir, [entry]);
1032
- }
1033
- }
1034
- return groups;
1035
- }
1036
-
1037
- // src/tailwindcss/v4/patcher.ts
1038
- var CONFIGURED_TAILWIND_VERSION_RE = /Configured tailwindcss\.version=\d+/u;
1039
- var RESOLVED_TAILWIND_VERSION_RE = /resolved package ".+" is version /u;
1040
- function isTailwindcss4Package(packageName) {
1041
- return Boolean(
1042
- packageName && (packageName === "tailwindcss4" || packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4"))
1043
- );
1044
- }
1045
- function resolveExplicitTailwindVersion(configuredVersion, configuredPackageName) {
1046
- if (typeof configuredVersion === "number") {
1047
- return configuredVersion;
1048
- }
1049
- if (configuredPackageName === "tailwindcss") {
1050
- return 3;
1051
- }
1052
- if (isTailwindcss4Package(configuredPackageName)) {
1053
- return 4;
1054
- }
1055
- return void 0;
1056
- }
1057
- function hasOwnV4Signal(value) {
1058
- return typeof value === "object" && value !== null && "v4" in value;
1059
- }
1060
- function isTailwindVersionMismatchError(error) {
1061
- return error instanceof Error && CONFIGURED_TAILWIND_VERSION_RE.test(error.message) && RESOLVED_TAILWIND_VERSION_RE.test(error.message);
1062
- }
1063
- function createPatcherForBase(baseDir, cssEntries, options) {
1064
- const {
1065
- tailwindcss,
1066
- tailwindcssPatcherOptions,
1067
- supportCustomLengthUnitsPatch
1068
- } = options;
1069
- const hasCssEntries = Boolean(cssEntries?.length);
1070
- const defaultTailwindcssConfig = {
1071
- cwd: baseDir,
1072
- v2: {
1073
- cwd: baseDir
1074
- },
1075
- v3: {
1076
- cwd: baseDir
1077
- },
1078
- v4: hasCssEntries ? { cssEntries } : {
1079
- base: baseDir,
1080
- cssEntries
1081
- }
1082
- };
1083
- const mergedTailwindOptions = defuOverrideArray(
1084
- tailwindcss ?? {},
1085
- defaultTailwindcssConfig
1086
- );
1087
- if (!mergedTailwindOptions.v4) {
1088
- mergedTailwindOptions.v4 = hasCssEntries ? { cssEntries: cssEntries ?? [] } : {
1089
- base: baseDir,
1090
- cssEntries: cssEntries ?? []
1091
- };
1092
- } else {
1093
- if (!hasCssEntries && !mergedTailwindOptions.v4.base) {
1094
- mergedTailwindOptions.v4.base = baseDir;
1095
- }
1096
- if (hasCssEntries) {
1097
- if (cssEntries?.length) {
1098
- mergedTailwindOptions.v4.cssEntries = cssEntries;
1099
- } else if (!mergedTailwindOptions.v4.cssEntries) {
1100
- mergedTailwindOptions.v4.cssEntries = [];
1101
- }
1102
- } else if (!mergedTailwindOptions.v4.cssEntries) {
1103
- mergedTailwindOptions.v4.cssEntries = cssEntries ?? [];
1104
- }
1105
- }
1106
- const patchedOptions = overrideTailwindcssPatcherOptionsForBase(
1107
- tailwindcssPatcherOptions,
1108
- baseDir,
1109
- cssEntries ?? []
1110
- );
1111
- const configuredPackageName = tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwind?.packageName || tailwindcssPatcherOptions?.patch?.tailwindcss?.packageName;
1112
- const configuredVersion = tailwindcss?.version || tailwindcssPatcherOptions?.tailwindcss?.version || tailwindcssPatcherOptions?.tailwind?.version || tailwindcssPatcherOptions?.patch?.tailwindcss?.version || mergedTailwindOptions.version;
1113
- const explicitTailwindVersion = resolveExplicitTailwindVersion(configuredVersion, configuredPackageName);
1114
- const hasExplicitV4Signals = hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwind) || hasOwnV4Signal(tailwindcssPatcherOptions?.patch?.tailwindcss);
1115
- const isV4 = explicitTailwindVersion === 3 ? false : explicitTailwindVersion === 4 || explicitTailwindVersion === void 0 && (mergedTailwindOptions.version === 4 || isTailwindcss4Package(configuredPackageName ?? mergedTailwindOptions.packageName) || hasExplicitV4Signals);
1116
- const tailwindPackageConfigured = Boolean(configuredPackageName);
1117
- const shouldPatchV4PostcssPackage = isV4 && !tailwindPackageConfigured;
1118
- const packageCandidates = /* @__PURE__ */ new Set();
1119
- if (shouldPatchV4PostcssPackage) {
1120
- packageCandidates.add("@tailwindcss/postcss");
1121
- }
1122
- packageCandidates.add(
1123
- mergedTailwindOptions.packageName ?? configuredPackageName ?? "tailwindcss"
1124
- );
1125
- const patchers = [];
1126
- const packageCandidateList = [...packageCandidates];
1127
- let firstVersionMismatchError;
1128
- for (const packageName of packageCandidateList) {
1129
- const tailwindOptionsForPackage = {
1130
- ...mergedTailwindOptions,
1131
- packageName
1132
- };
1133
- try {
1134
- patchers.push(createTailwindcssPatcher({
1135
- basedir: baseDir,
1136
- supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch ?? true,
1137
- tailwindcss: tailwindOptionsForPackage,
1138
- tailwindcssPatcherOptions: patchedOptions
1139
- }));
1140
- } catch (error) {
1141
- if (packageCandidateList.length > 1 && isTailwindVersionMismatchError(error)) {
1142
- firstVersionMismatchError ?? (firstVersionMismatchError = error);
1143
- logger3.warn('skip incompatible Tailwind package candidate "%s" for v4 patcher: %s', packageName, error.message);
1144
- continue;
1145
- }
1146
- throw error;
1147
- }
1148
- }
1149
- if (patchers.length === 0 && firstVersionMismatchError) {
1150
- throw firstVersionMismatchError;
1151
- }
1152
- return patchers.length === 1 ? patchers[0] : createMultiTailwindcssPatcher(patchers);
1153
- }
1154
- function tryCreateMultiTailwindcssPatcher(groups, options) {
1155
- if (groups.size <= 1) {
1156
- return void 0;
1157
- }
1158
- logger3.debug("detected multiple Tailwind CSS entry bases: %O", [...groups.keys()]);
1159
- const patchers = [];
1160
- for (const [baseDir, entries] of groups) {
1161
- patchers.push(createPatcherForBase(baseDir, entries, options));
1162
- }
1163
- return createMultiTailwindcssPatcher(patchers);
1164
- }
1165
-
1166
- // src/uni-app-x/options.ts
1167
- function resolveComponentLocalStyles(option) {
1168
- if (option === false) {
1169
- return {
1170
- enabled: false,
1171
- onlyWhenStyleIsolationVersion2: true
1172
- };
1173
- }
1174
- if (option === true || option === void 0) {
1175
- return {
1176
- enabled: false,
1177
- onlyWhenStyleIsolationVersion2: true
1178
- };
1179
- }
1180
- const componentLocalStyles = option.componentLocalStyles;
1181
- if (componentLocalStyles === false) {
1182
- return {
1183
- enabled: false,
1184
- onlyWhenStyleIsolationVersion2: true
1185
- };
1186
- }
1187
- if (componentLocalStyles === true || componentLocalStyles === void 0) {
1188
- return {
1189
- enabled: true,
1190
- onlyWhenStyleIsolationVersion2: true
1191
- };
1192
- }
1193
- return {
1194
- enabled: componentLocalStyles.enabled !== false,
1195
- onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
1196
- };
1197
- }
1198
- function resolveUniAppXOptions(option) {
1199
- if (typeof option === "object" && option) {
1200
- return {
1201
- enabled: option.enabled !== false,
1202
- componentLocalStyles: resolveComponentLocalStyles(option),
1203
- uvueUnsupported: option.uvueUnsupported ?? "warn"
1204
- };
1205
- }
1206
- return {
1207
- enabled: Boolean(option),
1208
- componentLocalStyles: resolveComponentLocalStyles(option),
1209
- uvueUnsupported: "warn"
1210
- };
1211
- }
1212
- function isUniAppXEnabled(option) {
1213
- return resolveUniAppXOptions(option).enabled;
1214
- }
1215
-
1216
- // src/context/tailwindcss/basedir.ts
1217
- import { createRequire as createRequire2 } from "module";
1218
- import path5 from "path";
1219
- import process3 from "process";
1220
- import { fileURLToPath as fileURLToPath2 } from "url";
1221
- import { logger as logger4 } from "@weapp-tailwindcss/logger";
1222
- var ENV_BASEDIR_KEYS = [
1223
- "WEAPP_TAILWINDCSS_BASEDIR",
1224
- "WEAPP_TAILWINDCSS_BASE_DIR",
1225
- "TAILWINDCSS_BASEDIR",
1226
- "TAILWINDCSS_BASE_DIR",
1227
- "UNI_INPUT_DIR",
1228
- "UNI_INPUT_ROOT",
1229
- "UNI_CLI_ROOT",
1230
- "UNI_APP_INPUT_DIR",
1231
- "INIT_CWD",
1232
- "PWD"
1233
- ];
1234
- var GENERIC_ENV_BASEDIR_KEYS = /* @__PURE__ */ new Set(["INIT_CWD", "PWD"]);
1235
- function pickEnvBasedir() {
1236
- for (const key of ENV_BASEDIR_KEYS) {
1237
- const value = process3.env[key];
1238
- if (value && path5.isAbsolute(value)) {
1239
- return { key, value };
1240
- }
1241
- }
1242
- return void 0;
1243
- }
1244
- function pickPackageEnvBasedir() {
1245
- const packageJsonPath = process3.env.npm_package_json;
1246
- if (packageJsonPath) {
1247
- const packageDir = path5.dirname(packageJsonPath);
1248
- if (packageDir && path5.isAbsolute(packageDir)) {
1249
- return packageDir;
1250
- }
1251
- }
1252
- const localPrefix = process3.env.npm_config_local_prefix;
1253
- if (localPrefix && path5.isAbsolute(localPrefix)) {
1254
- return localPrefix;
1255
- }
1256
- return void 0;
1257
- }
1258
- var STACK_PAREN_RE = /\(([^)]+)\)/u;
1259
- var STACK_AT_RE = /at\s+(\S.*)$/u;
1260
- function detectCallerBasedir() {
1261
- const stack = new Error("resolveTailwindcssBasedir stack probe").stack;
1262
- if (!stack) {
1263
- return void 0;
1264
- }
1265
- if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
1266
- logger4.debug("caller stack: %s", stack);
1267
- }
1268
- const lines = stack.split("\n");
1269
- for (const line of lines) {
1270
- const match = line.match(STACK_PAREN_RE) ?? line.match(STACK_AT_RE);
1271
- const location = match?.[1];
1272
- if (!location) {
1273
- continue;
1274
- }
1275
- let filePath = location;
1276
- if (filePath.startsWith("file://")) {
1277
- try {
1278
- filePath = fileURLToPath2(filePath);
1279
- } catch {
1280
- continue;
1281
- }
1282
- }
1283
- const [candidate] = filePath.split(":");
1284
- const resolvedPath = path5.isAbsolute(filePath) ? filePath : candidate;
1285
- if (!path5.isAbsolute(resolvedPath)) {
1286
- continue;
1287
- }
1288
- if (resolvedPath.includes("node_modules") && resolvedPath.includes("weapp-tailwindcss")) {
1289
- continue;
1290
- }
1291
- try {
1292
- return path5.dirname(resolvedPath);
1293
- } catch {
1294
- continue;
1295
- }
1296
- }
1297
- return void 0;
1298
- }
1299
- function resolveTailwindcssBasedir(basedir, fallback) {
1300
- const envBasedirResult = pickEnvBasedir();
1301
- const envBasedir = envBasedirResult?.value;
1302
- const envBasedirKey = envBasedirResult?.key;
1303
- const envBasedirIsGeneric = envBasedirKey ? GENERIC_ENV_BASEDIR_KEYS.has(envBasedirKey) : false;
1304
- const packageEnvBasedir = pickPackageEnvBasedir();
1305
- const shouldDetectCaller = !envBasedir || envBasedirIsGeneric;
1306
- const callerBasedir = shouldDetectCaller ? detectCallerBasedir() : void 0;
1307
- const cwd = process3.cwd();
1308
- const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? cwd;
1309
- const resolveRelative = (value) => path5.isAbsolute(value) ? path5.normalize(value) : path5.normalize(path5.resolve(anchor, value));
1310
- if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
1311
- logger4.debug("resolveTailwindcssBasedir anchor %O", {
1312
- basedir,
1313
- envBasedir,
1314
- envBasedirKey,
1315
- envBasedirIsGeneric,
1316
- packageEnvBasedir,
1317
- fallback,
1318
- callerBasedir,
1319
- npm_package_json: process3.env.npm_package_json,
1320
- cwd,
1321
- anchor
1322
- });
1323
- }
1324
- if (basedir && basedir.trim().length > 0) {
1325
- return resolveRelative(basedir);
1326
- }
1327
- if (envBasedir && !envBasedirIsGeneric) {
1328
- return path5.normalize(envBasedir);
1329
- }
1330
- if (fallback && fallback.trim().length > 0) {
1331
- return resolveRelative(fallback);
1332
- }
1333
- if (packageEnvBasedir) {
1334
- return path5.normalize(packageEnvBasedir);
1335
- }
1336
- if (callerBasedir) {
1337
- const normalizedCaller = path5.normalize(callerBasedir);
1338
- const librarySegment = `${path5.sep}weapp-tailwindcss${path5.sep}`;
1339
- if (!normalizedCaller.includes(librarySegment)) {
1340
- return normalizedCaller;
1341
- }
1342
- }
1343
- const packageName = process3.env.PNPM_PACKAGE_NAME;
1344
- if (packageName) {
1345
- try {
1346
- const anchorRequire = createRequire2(path5.join(anchor, "__resolve_tailwindcss_basedir__.cjs"));
1347
- const packageJsonPath = anchorRequire.resolve(`${packageName}/package.json`);
1348
- if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
1349
- logger4.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
1350
- }
1351
- return path5.normalize(path5.dirname(packageJsonPath));
1352
- } catch {
1353
- if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
1354
- logger4.debug("failed to resolve package json for %s", packageName);
1355
- }
1356
- const workspaceRoot = findWorkspaceRoot(anchor);
1357
- if (workspaceRoot) {
1358
- const packageDir = findWorkspacePackageDir(workspaceRoot, packageName);
1359
- if (packageDir) {
1360
- return packageDir;
1361
- }
1362
- }
1363
- }
1364
- }
1365
- if (envBasedir) {
1366
- return path5.normalize(envBasedir);
1367
- }
1368
- return path5.normalize(cwd);
1369
- }
1370
-
1371
- // src/context/tailwindcss.ts
1372
- import { logger as logger5 } from "@weapp-tailwindcss/logger";
1373
-
1374
- // src/context/tailwindcss/rax.ts
1375
- import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
1376
- import path6 from "path";
1377
- import process4 from "process";
1378
- function isRaxWorkspace(appType, baseDir) {
1379
- if (appType === "rax") {
1380
- return true;
1381
- }
1382
- try {
1383
- const pkgPath = path6.join(baseDir, "package.json");
1384
- if (!existsSync3(pkgPath)) {
1385
- return false;
1386
- }
1387
- const pkg = JSON.parse(readFileSync2(pkgPath, "utf8"));
1388
- const deps = {
1389
- ...pkg.dependencies ?? {},
1390
- ...pkg.devDependencies ?? {}
1391
- };
1392
- if (deps["rax-app"] || deps.rax) {
1393
- return true;
1394
- }
1395
- } catch {
1396
- return false;
1397
- }
1398
- return false;
1399
- }
1400
- function collectRaxStyleEntries(baseDir) {
1401
- const STYLE_CANDIDATES = [
1402
- "src/global.css",
1403
- "src/global.scss",
1404
- "src/global.less",
1405
- "src/global.sass",
1406
- "src/global.styl",
1407
- "src/global.stylus"
1408
- ];
1409
- const discovered = [];
1410
- for (const relative of STYLE_CANDIDATES) {
1411
- const candidate = path6.resolve(baseDir, relative);
1412
- if (existsSync3(candidate)) {
1413
- discovered.push(path6.normalize(candidate));
1414
- }
1415
- }
1416
- return discovered;
1417
- }
1418
- function detectImplicitCssEntries(appType, baseDir) {
1419
- const baseCandidates = /* @__PURE__ */ new Set();
1420
- baseCandidates.add(path6.normalize(baseDir));
1421
- const envCandidates = [process4.cwd(), process4.env.INIT_CWD, process4.env.PWD];
1422
- for (const candidate of envCandidates) {
1423
- if (candidate) {
1424
- baseCandidates.add(path6.normalize(candidate));
1425
- }
1426
- }
1427
- for (const candidateBase of baseCandidates) {
1428
- if (!isRaxWorkspace(appType, candidateBase)) {
1429
- continue;
1430
- }
1431
- const entries = collectRaxStyleEntries(candidateBase);
1432
- if (entries.length) {
1433
- return entries;
1434
- }
1435
- }
1436
- return void 0;
1437
- }
1438
-
1439
- // src/context/tailwindcss.ts
1440
- function createTailwindcssPatcherFromContext(ctx) {
1441
- const {
1442
- tailwindcssBasedir,
1443
- supportCustomLengthUnitsPatch,
1444
- tailwindcss,
1445
- tailwindcssPatcherOptions,
1446
- cssEntries: rawCssEntries,
1447
- appType
1448
- } = ctx;
1449
- const absoluteCssEntryBasedir = guessBasedirFromEntries(rawCssEntries);
1450
- const resolvedTailwindcssBasedir = resolveTailwindcssBasedir(tailwindcssBasedir, absoluteCssEntryBasedir);
1451
- ctx.tailwindcssBasedir = resolvedTailwindcssBasedir;
1452
- logger5.debug("tailwindcss basedir resolved: %s", resolvedTailwindcssBasedir);
1453
- let normalizedCssEntries = normalizeCssEntries(rawCssEntries, resolvedTailwindcssBasedir);
1454
- if (!normalizedCssEntries) {
1455
- normalizedCssEntries = detectImplicitCssEntries(ctx.appType, resolvedTailwindcssBasedir);
1456
- }
1457
- if (normalizedCssEntries) {
1458
- ctx.cssEntries = normalizedCssEntries;
1459
- }
1460
- const shouldAttachBase = Boolean(ctx.tailwindcssBasedir && normalizedCssEntries?.length);
1461
- const tailwindcssWithBase = shouldAttachBase && tailwindcss?.v4 !== null ? {
1462
- ...tailwindcss ?? {},
1463
- v4: {
1464
- ...tailwindcss?.v4 ?? {},
1465
- base: tailwindcss?.v4?.base ?? resolvedTailwindcssBasedir
1466
- }
1467
- } : tailwindcss;
1468
- const patcherOptions = {
1469
- tailwindcss: tailwindcssWithBase,
1470
- tailwindcssPatcherOptions,
1471
- supportCustomLengthUnitsPatch,
1472
- appType
1473
- };
1474
- const workspaceRoot = findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
1475
- const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries, {
1476
- preferredBaseDir: resolvedTailwindcssBasedir,
1477
- workspaceRoot
1478
- }) : void 0;
1479
- const multiPatcher = groupedCssEntries ? tryCreateMultiTailwindcssPatcher(groupedCssEntries, patcherOptions) : void 0;
1480
- if (multiPatcher) {
1481
- return multiPatcher;
1482
- }
1483
- if (groupedCssEntries?.size === 1) {
1484
- const firstGroup = groupedCssEntries.entries().next().value;
1485
- if (firstGroup) {
1486
- const [baseDir, entries] = firstGroup;
1487
- return createPatcherForBase(baseDir, entries, patcherOptions);
1488
- }
1489
- }
1490
- const effectiveCssEntries = normalizedCssEntries ?? rawCssEntries;
1491
- return createPatcherForBase(
1492
- resolvedTailwindcssBasedir,
1493
- effectiveCssEntries,
1494
- patcherOptions
1495
- );
1496
- }
1497
-
1498
- // src/logger/index.ts
1499
- import { logger as logger6 } from "@weapp-tailwindcss/logger";
1500
-
1501
- export {
1502
- resolveTailwindcssOptions,
1503
- invalidateRuntimeClassSet,
1504
- getRuntimeClassSetCacheEntry,
1505
- getRuntimeClassSetSignature,
1506
- findNearestPackageRoot,
1507
- warnMissingCssEntries,
1508
- applyV4CssCalcDefaults,
1509
- findTailwindConfig,
1510
- resolveUniAppXOptions,
1511
- isUniAppXEnabled,
1512
- resolveTailwindcssBasedir,
1513
- createTailwindcssPatcherFromContext,
1514
- logger6 as logger
1515
- };