weapp-tailwindcss 4.12.0 → 5.0.0-next.1

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 (308) 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 +41 -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 +19 -0
  13. package/dist/bundlers/vite/generate-bundle.d.ts +20 -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/utils.d.ts +9 -0
  22. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +20 -0
  23. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +14 -0
  24. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +15 -0
  25. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +9 -0
  26. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +17 -0
  27. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +19 -0
  28. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +9 -0
  29. package/dist/bundlers/webpack/index.d.ts +1 -0
  30. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +12 -0
  31. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +11 -0
  32. package/dist/bundlers/webpack/shared/css-imports.d.ts +6 -0
  33. package/dist/bundlers/webpack/shared/loader-anchors.d.ts +8 -0
  34. package/dist/cache/index.d.ts +38 -0
  35. package/dist/cache/md5.d.ts +1 -0
  36. package/dist/chunk-8l464Juk.js +28 -0
  37. package/dist/cli/config.d.ts +5 -0
  38. package/dist/cli/context.d.ts +16 -0
  39. package/dist/cli/doctor/constants.d.ts +7 -0
  40. package/dist/cli/doctor/types.d.ts +31 -0
  41. package/dist/cli/doctor.d.ts +4 -0
  42. package/dist/cli/helpers/options/format.d.ts +2 -0
  43. package/dist/cli/helpers/options/parse.d.ts +3 -0
  44. package/dist/cli/helpers/options/resolve.d.ts +1 -0
  45. package/dist/cli/helpers/options.d.ts +3 -0
  46. package/dist/cli/helpers/patch-cwd.d.ts +1 -0
  47. package/dist/cli/helpers.d.ts +5 -0
  48. package/dist/cli/mount-options/patch-status.d.ts +2 -0
  49. package/dist/cli/mount-options.d.ts +2 -0
  50. package/dist/cli/patch-options.d.ts +6 -0
  51. package/dist/cli/tokens.d.ts +4 -0
  52. package/dist/cli/types.d.ts +17 -0
  53. package/dist/cli/vscode-entry.d.ts +14 -0
  54. package/dist/cli/workspace/package-dirs.d.ts +3 -0
  55. package/dist/cli/workspace/patch-package.d.ts +3 -0
  56. package/dist/cli/workspace/patch-utils.d.ts +3 -0
  57. package/dist/cli/workspace/types.d.ts +11 -0
  58. package/dist/cli/workspace/workspace-globs.d.ts +2 -0
  59. package/dist/cli/workspace/workspace-io.d.ts +1 -0
  60. package/dist/cli/workspace/workspace-lock.d.ts +1 -0
  61. package/dist/cli/workspace.d.ts +2 -0
  62. package/dist/cli.d.ts +1 -2
  63. package/dist/cli.js +2425 -3524
  64. package/dist/cli.mjs +2402 -3505
  65. package/dist/constants-B-_T5UnW.mjs +44 -0
  66. package/dist/constants-p1dyh1x1.js +73 -0
  67. package/dist/constants.d.ts +13 -0
  68. package/dist/context/compiler-context-cache.d.ts +3 -0
  69. package/dist/context/custom-attributes.d.ts +2 -0
  70. package/dist/context/handlers.d.ts +6 -0
  71. package/dist/context/index.d.ts +7 -0
  72. package/dist/context/logger.d.ts +4 -0
  73. package/dist/context/tailwindcss/basedir.d.ts +1 -0
  74. package/dist/context/tailwindcss/rax.d.ts +2 -0
  75. package/dist/context/tailwindcss.d.ts +4 -0
  76. package/dist/context/workspace.d.ts +3 -0
  77. package/dist/core.d.ts +5 -21
  78. package/dist/core.js +138 -180
  79. package/dist/core.mjs +135 -180
  80. package/dist/css-imports-BbrbluP9.js +177 -0
  81. package/dist/css-imports-CSdPq_Sc.mjs +128 -0
  82. package/dist/css-macro/constants.d.ts +14 -0
  83. package/dist/css-macro/index.d.ts +15 -0
  84. package/dist/css-macro/postcss.d.ts +3 -7
  85. package/dist/css-macro/postcss.js +44 -58
  86. package/dist/css-macro/postcss.mjs +44 -56
  87. package/dist/css-macro.d.ts +1 -20
  88. package/dist/css-macro.js +37 -50
  89. package/dist/css-macro.mjs +33 -47
  90. package/dist/debug/index.d.ts +5 -0
  91. package/dist/defaults.d.ts +2 -11
  92. package/dist/defaults.js +132 -8
  93. package/dist/defaults.mjs +128 -7
  94. package/dist/escape.js +31 -54
  95. package/dist/escape.mjs +18 -25
  96. package/dist/experimental/index.d.ts +2 -0
  97. package/dist/experimental/oxc/ast-utils.d.ts +30 -0
  98. package/dist/experimental/oxc/index.d.ts +2 -0
  99. package/dist/experimental/oxc/module-specifiers.d.ts +2 -0
  100. package/dist/experimental/shared/cache.d.ts +3 -0
  101. package/dist/experimental/shared/transform.d.ts +3 -0
  102. package/dist/experimental/shared.d.ts +8 -0
  103. package/dist/experimental/swc/ast-utils.d.ts +30 -0
  104. package/dist/experimental/swc/index.d.ts +2 -0
  105. package/dist/experimental/swc/module-specifiers.d.ts +2 -0
  106. package/dist/generator/index.d.ts +11 -0
  107. package/dist/generator/options.d.ts +15 -0
  108. package/dist/generator/types.d.ts +19 -0
  109. package/dist/generator-CZ-JXw6T.js +492 -0
  110. package/dist/generator-Dwxgra97.mjs +399 -0
  111. package/dist/generator-css-CnYjiMrD.js +1084 -0
  112. package/dist/generator-css-DhPFjSzK.mjs +1057 -0
  113. package/dist/generator.d.ts +1 -0
  114. package/dist/generator.js +19 -0
  115. package/dist/generator.mjs +2 -0
  116. package/dist/gulp.d.ts +4 -24
  117. package/dist/gulp.js +271 -13
  118. package/dist/gulp.mjs +263 -13
  119. package/dist/index.d.ts +8 -15
  120. package/dist/index.js +12 -24
  121. package/dist/index.mjs +6 -24
  122. package/dist/js/JsTokenUpdater.d.ts +14 -0
  123. package/dist/js/ModuleGraph.d.ts +18 -0
  124. package/dist/js/NodePathWalker.d.ts +33 -0
  125. package/dist/js/babel/parse.d.ts +9 -0
  126. package/dist/js/babel/process.d.ts +4 -0
  127. package/dist/js/babel.d.ts +13 -0
  128. package/dist/js/class-context.d.ts +3 -0
  129. package/dist/js/evalTransforms.d.ts +7 -0
  130. package/dist/js/handlers.d.ts +5 -0
  131. package/dist/js/index.d.ts +4 -0
  132. package/dist/js/module-graph/ignored-exports.d.ts +18 -0
  133. package/dist/js/module-graph/types.d.ts +17 -0
  134. package/dist/js/node-path-walker/export-handlers.d.ts +12 -0
  135. package/dist/js/node-path-walker/import-tokens.d.ts +24 -0
  136. package/dist/js/precheck.d.ts +2 -0
  137. package/dist/js/sourceAnalysis.d.ts +17 -0
  138. package/dist/js/syntax.d.ts +10 -0
  139. package/dist/js/taggedTemplateIgnore.d.ts +13 -0
  140. package/dist/js/types.d.ts +11 -0
  141. package/dist/lightningcss/index.d.ts +8 -0
  142. package/dist/lightningcss/style-handler/options.d.ts +3 -0
  143. package/dist/lightningcss/style-handler/selector-transform.d.ts +10 -0
  144. package/dist/lightningcss/style-handler/selector-utils.d.ts +10 -0
  145. package/dist/lightningcss/style-handler.d.ts +17 -0
  146. package/dist/loader-anchors-DvwgIYdA.mjs +205 -0
  147. package/dist/loader-anchors-cprm4Klq.js +273 -0
  148. package/dist/logger/index.d.ts +2 -0
  149. package/dist/logger-BZ45DZJT.js +1003 -0
  150. package/dist/logger-BoVx1Dbt.mjs +935 -0
  151. package/dist/patcher-options-6gJN2EXy.js +115 -0
  152. package/dist/patcher-options-DQfR5xxT.mjs +92 -0
  153. package/dist/postcss-html-transform.d.ts +3 -3
  154. package/dist/postcss-html-transform.js +7 -10
  155. package/dist/postcss-html-transform.mjs +3 -6
  156. package/dist/postcss.d.ts +15 -0
  157. package/dist/postcss.js +278 -0
  158. package/dist/postcss.mjs +268 -0
  159. package/dist/presets/hbuilderx.d.ts +4 -0
  160. package/dist/presets/index.d.ts +3 -0
  161. package/dist/presets/shared.d.ts +10 -0
  162. package/dist/presets/taro.d.ts +4 -0
  163. package/dist/presets/uni-app-x.d.ts +16 -0
  164. package/dist/presets/uni-app.d.ts +4 -0
  165. package/dist/presets.d.ts +1 -76
  166. package/dist/presets.js +115 -163
  167. package/dist/presets.mjs +107 -163
  168. package/dist/recorder-B_XyZ576.mjs +2763 -0
  169. package/dist/recorder-rn_2v_nd.js +2878 -0
  170. package/dist/reset/index.d.ts +2 -0
  171. package/dist/reset.d.ts +1 -4
  172. package/dist/reset.js +19 -8
  173. package/dist/reset.mjs +2 -8
  174. package/dist/shared/classname-transform.d.ts +14 -0
  175. package/dist/shared/mpx.d.ts +7 -0
  176. package/dist/shared/tailwindcss-css-redirect.d.ts +1 -0
  177. package/dist/tailwindcss/index.d.ts +11 -0
  178. package/dist/tailwindcss/miniprogram.d.ts +1 -0
  179. package/dist/tailwindcss/patcher-options.d.ts +56 -0
  180. package/dist/tailwindcss/patcher-resolve.d.ts +4 -0
  181. package/dist/tailwindcss/patcher.d.ts +13 -0
  182. package/dist/tailwindcss/recorder.d.ts +13 -0
  183. package/dist/tailwindcss/remove-unsupported-css.d.ts +2 -0
  184. package/dist/tailwindcss/runtime/cache.d.ts +11 -0
  185. package/dist/tailwindcss/runtime-logs.d.ts +3 -0
  186. package/dist/tailwindcss/runtime.d.ts +29 -0
  187. package/dist/tailwindcss/targets/paths.d.ts +13 -0
  188. package/dist/tailwindcss/targets/record-io.d.ts +5 -0
  189. package/dist/tailwindcss/targets/recorder.d.ts +3 -0
  190. package/dist/tailwindcss/targets/types.d.ts +35 -0
  191. package/dist/tailwindcss/targets.d.ts +6 -0
  192. package/dist/tailwindcss/v3-engine/generator.d.ts +2 -0
  193. package/dist/tailwindcss/v3-engine/index.d.ts +4 -0
  194. package/dist/tailwindcss/v3-engine/miniprogram.d.ts +4 -0
  195. package/dist/tailwindcss/v3-engine/source.d.ts +5 -0
  196. package/dist/tailwindcss/v3-engine/types.d.ts +55 -0
  197. package/dist/tailwindcss/v4/config.d.ts +5 -0
  198. package/dist/tailwindcss/v4/css-entries.d.ts +7 -0
  199. package/dist/tailwindcss/v4/index.d.ts +2 -0
  200. package/dist/tailwindcss/v4/multi-patcher.d.ts +2 -0
  201. package/dist/tailwindcss/v4/patcher-options.d.ts +24 -0
  202. package/dist/tailwindcss/v4/patcher.d.ts +14 -0
  203. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -0
  204. package/dist/tailwindcss/v4-engine/generator.d.ts +2 -0
  205. package/dist/tailwindcss/v4-engine/index.d.ts +5 -0
  206. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +4 -0
  207. package/dist/tailwindcss/v4-engine/source.d.ts +7 -0
  208. package/dist/tailwindcss/v4-engine/types.d.ts +17 -0
  209. package/dist/typedoc.export.d.ts +5 -0
  210. package/dist/types/base.d.ts +1 -0
  211. package/dist/types/disabled-options.d.ts +4 -0
  212. package/dist/types/index.d.ts +104 -0
  213. package/dist/types/shared.d.ts +7 -0
  214. package/dist/types/user-defined-options/general.d.ts +31 -0
  215. package/dist/types/user-defined-options/important.d.ts +37 -0
  216. package/dist/types/user-defined-options/index.d.ts +11 -0
  217. package/dist/types/user-defined-options/lifecycle.d.ts +6 -0
  218. package/dist/types/user-defined-options/matcher.d.ts +9 -0
  219. package/dist/types.d.ts +1 -150
  220. package/dist/types.js +0 -1
  221. package/dist/types.mjs +1 -1
  222. package/dist/uni-app-x/component-local-style.d.ts +19 -0
  223. package/dist/uni-app-x/index.d.ts +2 -0
  224. package/dist/uni-app-x/options.d.ts +12 -0
  225. package/dist/uni-app-x/style-isolation.d.ts +2 -0
  226. package/dist/uni-app-x/transform.d.ts +9 -0
  227. package/dist/uni-app-x/vite.d.ts +36 -0
  228. package/dist/utils/decode.d.ts +2 -0
  229. package/dist/utils/disabled.d.ts +6 -0
  230. package/dist/utils/hbuilderx.d.ts +5 -0
  231. package/dist/utils/index.d.ts +7 -0
  232. package/dist/utils/nameMatcher.d.ts +4 -0
  233. package/dist/utils/resolve-package.d.ts +1 -0
  234. package/dist/utils/uni-platform.d.ts +11 -0
  235. package/dist/utils-7DUGTFED.mjs +48 -0
  236. package/dist/utils-DmC9_In3.js +61 -0
  237. package/dist/vite-BHpAqldo.js +1952 -0
  238. package/dist/vite-C8JlHiyR.mjs +1940 -0
  239. package/dist/vite.d.ts +4 -17
  240. package/dist/vite.js +5 -14
  241. package/dist/vite.mjs +2 -14
  242. package/dist/weapp-tw-css-import-rewrite-loader.js +59 -92
  243. package/dist/weapp-tw-runtime-classset-loader.js +31 -50
  244. package/dist/webpack-CABjKGGQ.mjs +441 -0
  245. package/dist/webpack-DNIJ0ysE.js +456 -0
  246. package/dist/webpack.d.ts +4 -25
  247. package/dist/webpack.js +6 -17
  248. package/dist/webpack.mjs +2 -17
  249. package/dist/webpack4.d.ts +4 -26
  250. package/dist/webpack4.js +375 -481
  251. package/dist/webpack4.mjs +366 -482
  252. package/dist/wxml/Tokenizer.d.ts +15 -0
  253. package/dist/wxml/custom-attributes.d.ts +4 -0
  254. package/dist/wxml/index.d.ts +2 -0
  255. package/dist/wxml/shared.d.ts +2 -0
  256. package/dist/wxml/tokenizer/types.d.ts +18 -0
  257. package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +2 -0
  258. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +8 -0
  259. package/dist/wxml/utils/codegen.d.ts +2 -0
  260. package/dist/wxml/utils/custom-template.d.ts +3 -0
  261. package/dist/wxml/utils/fragment-helpers.d.ts +6 -0
  262. package/dist/wxml/utils/fragment-updater.d.ts +4 -0
  263. package/dist/wxml/utils/template-fragments.d.ts +3 -0
  264. package/dist/wxml/utils.d.ts +8 -0
  265. package/dist/wxml/whitespace.d.ts +2 -0
  266. package/generator-placeholder.css +1 -0
  267. package/package.json +19 -5
  268. package/dist/chunk-24AGZQVR.js +0 -183
  269. package/dist/chunk-3VQKDHGP.mjs +0 -179
  270. package/dist/chunk-4AFQP74Z.js +0 -24
  271. package/dist/chunk-57SOQCAU.mjs +0 -582
  272. package/dist/chunk-5ZYHNDEK.mjs +0 -2439
  273. package/dist/chunk-76S2EME4.mjs +0 -34
  274. package/dist/chunk-A5PB4KZT.js +0 -138
  275. package/dist/chunk-DUHYLR2R.js +0 -276
  276. package/dist/chunk-DYLQ6UOI.js +0 -71
  277. package/dist/chunk-E7I5TW5K.js +0 -52
  278. package/dist/chunk-FS2NOOEB.js +0 -292
  279. package/dist/chunk-HVNGIKLS.js +0 -3930
  280. package/dist/chunk-JZQBZHN5.js +0 -579
  281. package/dist/chunk-KGTVD4EP.mjs +0 -3930
  282. package/dist/chunk-NNOQDMUP.mjs +0 -10
  283. package/dist/chunk-OF6MFURR.js +0 -34
  284. package/dist/chunk-OFB2KBRP.js +0 -2442
  285. package/dist/chunk-OOHJLO5M.mjs +0 -71
  286. package/dist/chunk-PCDYXXSK.mjs +0 -1515
  287. package/dist/chunk-RKISS72P.js +0 -7
  288. package/dist/chunk-RRQZL7FQ.mjs +0 -292
  289. package/dist/chunk-XAKAD2CR.mjs +0 -138
  290. package/dist/chunk-XZP3MREK.mjs +0 -276
  291. package/dist/chunk-ZAA5ZG3D.js +0 -1518
  292. package/dist/chunk-ZCH4YINE.mjs +0 -52
  293. package/dist/cli.d.mts +0 -2
  294. package/dist/core.d.mts +0 -26
  295. package/dist/css-macro/postcss.d.mts +0 -7
  296. package/dist/css-macro.d.mts +0 -18
  297. package/dist/defaults.d.mts +0 -11
  298. package/dist/gulp.d.mts +0 -24
  299. package/dist/index-BXrmQelt.d.mts +0 -672
  300. package/dist/index-BXrmQelt.d.ts +0 -672
  301. package/dist/index.d.mts +0 -15
  302. package/dist/postcss-html-transform.d.mts +0 -2
  303. package/dist/presets.d.mts +0 -76
  304. package/dist/reset.d.mts +0 -1
  305. package/dist/types.d.mts +0 -150
  306. package/dist/vite.d.mts +0 -17
  307. package/dist/webpack.d.mts +0 -25
  308. package/dist/webpack4.d.mts +0 -26
@@ -0,0 +1,492 @@
1
+ const require_chunk = require("./chunk-8l464Juk.js");
2
+ const require_patcher_options = require("./patcher-options-6gJN2EXy.js");
3
+ let node_module = require("node:module");
4
+ let postcss = require("postcss");
5
+ postcss = require_chunk.__toESM(postcss);
6
+ let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
7
+ let node_path = require("node:path");
8
+ node_path = require_chunk.__toESM(node_path);
9
+ let node_process = require("node:process");
10
+ node_process = require_chunk.__toESM(node_process);
11
+ let tailwindcss_config = require("tailwindcss-config");
12
+ let tailwindcss_patch = require("tailwindcss-patch");
13
+ //#region src/tailwindcss/remove-unsupported-css.ts
14
+ /**
15
+ * 移除小程序不支持的 cascade layer 语法,同时保留 layer 内的实际规则。
16
+ */
17
+ function removeUnsupportedCascadeLayers(root) {
18
+ root.walkAtRules("layer", (atRule) => {
19
+ if (!atRule.nodes || atRule.nodes.length === 0) {
20
+ atRule.remove();
21
+ return;
22
+ }
23
+ atRule.replaceWith(...atRule.nodes);
24
+ });
25
+ }
26
+ //#endregion
27
+ //#region src/tailwindcss/miniprogram.ts
28
+ const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
29
+ const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
30
+ const PSEUDO_CONTENT_SELECTOR_RE = /^(?:::before|::after|:before|:after)(?:,(?:::before|::after|:before|:after))*$/;
31
+ function hasClassSelector(selector) {
32
+ return CLASS_SELECTOR_RE.test(selector);
33
+ }
34
+ function isCustomPropertyRule(rule) {
35
+ let hasDeclaration = false;
36
+ let allCustomProperties = true;
37
+ rule.walkDecls((decl) => {
38
+ hasDeclaration = true;
39
+ if (!decl.prop.startsWith("--")) allCustomProperties = false;
40
+ });
41
+ return hasDeclaration && allCustomProperties;
42
+ }
43
+ function isPseudoContentInitRule(rule) {
44
+ const selector = rule.selector.replace(/\s+/g, "");
45
+ if (!PSEUDO_CONTENT_SELECTOR_RE.test(selector)) return false;
46
+ let hasDeclaration = false;
47
+ let onlyContentVariable = true;
48
+ rule.walkDecls((decl) => {
49
+ hasDeclaration = true;
50
+ if (decl.prop !== "--tw-content") onlyContentVariable = false;
51
+ });
52
+ return hasDeclaration && onlyContentVariable;
53
+ }
54
+ /**
55
+ * 裁剪 Tailwind 生成 CSS 中面向浏览器的 classless 规则。
56
+ *
57
+ * 生成模式面向小程序时只需要保留业务 utility 与 Tailwind 变量初始化;
58
+ * 浏览器元素 reset、表单伪元素等 classless 规则不适合直接输出到小程序。
59
+ */
60
+ function pruneMiniProgramGeneratedCss(css) {
61
+ const root = postcss.default.parse(css);
62
+ root.walkComments((comment) => {
63
+ comment.remove();
64
+ });
65
+ removeUnsupportedCascadeLayers(root);
66
+ root.walkAtRules("supports", (atRule) => {
67
+ atRule.remove();
68
+ });
69
+ root.walkRules((rule) => {
70
+ if (hasClassSelector(rule.selector)) return;
71
+ if (isPseudoContentInitRule(rule)) return;
72
+ if (isCustomPropertyRule(rule)) {
73
+ rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
74
+ return;
75
+ }
76
+ rule.remove();
77
+ });
78
+ root.walkAtRules((atRule) => {
79
+ if (!atRule.nodes || atRule.nodes.length === 0) atRule.remove();
80
+ });
81
+ return root.toString();
82
+ }
83
+ //#endregion
84
+ //#region src/tailwindcss/v3-engine/miniprogram.ts
85
+ const defaultStyleHandler$1 = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
86
+ cssChildCombinatorReplaceValue: ["view", "text"],
87
+ cssRemoveHoverPseudoClass: true,
88
+ isMainChunk: true,
89
+ majorVersion: 3
90
+ });
91
+ async function transformTailwindV3CssToWeapp(css, options) {
92
+ return pruneMiniProgramGeneratedCss((await defaultStyleHandler$1(css, {
93
+ cssChildCombinatorReplaceValue: ["view", "text"],
94
+ cssRemoveHoverPseudoClass: true,
95
+ isMainChunk: true,
96
+ majorVersion: 3,
97
+ ...options
98
+ })).css);
99
+ }
100
+ async function transformTailwindV3CssByTarget(css, target, options) {
101
+ return target === "weapp" ? transformTailwindV3CssToWeapp(css, options) : css;
102
+ }
103
+ //#endregion
104
+ //#region src/tailwindcss/v3-engine/generator.ts
105
+ function isLegacyContentObject(value) {
106
+ return typeof value === "object" && value !== null && "files" in value;
107
+ }
108
+ function createRawContentEntries(candidates, sources) {
109
+ const entries = [];
110
+ const candidateContent = [...candidates].join(" ");
111
+ if (candidateContent.length > 0) entries.push({
112
+ raw: candidateContent,
113
+ extension: "html"
114
+ });
115
+ for (const source of sources) entries.push({
116
+ raw: source.content,
117
+ extension: source.extension ?? "html"
118
+ });
119
+ return entries;
120
+ }
121
+ function mergeContent(content, rawEntries) {
122
+ if (isLegacyContentObject(content)) return {
123
+ ...content,
124
+ relative: content.relative ?? true,
125
+ files: [...[].concat(content.files ?? []), ...rawEntries]
126
+ };
127
+ return {
128
+ relative: true,
129
+ files: [...[].concat(content ?? []), ...rawEntries]
130
+ };
131
+ }
132
+ function normalizeConfigObject(config) {
133
+ if (!config || typeof config !== "object") return config;
134
+ const maybeDefault = config.default;
135
+ if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
136
+ return config;
137
+ }
138
+ function createTailwindConfig(source, options) {
139
+ const config = { ...normalizeConfigObject(source.configObject) ?? {} };
140
+ const rawEntries = createRawContentEntries(options.candidates ?? [], options.sources ?? []);
141
+ config.content = mergeContent(config.content, rawEntries);
142
+ return config;
143
+ }
144
+ function loadTailwindcssPlugin(source) {
145
+ const requireFromProject = (0, node_module.createRequire)(`${source.cwd}/package.json`);
146
+ const requireFromRuntime = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
147
+ let plugin;
148
+ try {
149
+ plugin = requireFromProject(source.postcssPlugin);
150
+ } catch {
151
+ plugin = requireFromRuntime(source.postcssPlugin);
152
+ }
153
+ return typeof plugin === "function" ? plugin : plugin.default;
154
+ }
155
+ function collectClassSet(plugin) {
156
+ const classSet = /* @__PURE__ */ new Set();
157
+ for (const context of plugin.contextRef?.value ?? []) for (const candidate of context.classCache?.keys() ?? []) if (candidate !== "*") classSet.add(candidate);
158
+ return classSet;
159
+ }
160
+ function collectDependencyMessages(result) {
161
+ const dependencies = /* @__PURE__ */ new Set();
162
+ for (const message of result.messages) if (message.type === "dependency" && typeof message.file === "string") dependencies.add(message.file);
163
+ return dependencies;
164
+ }
165
+ function createTailwindV3Engine(source) {
166
+ async function generate(options = {}) {
167
+ const { styleOptions, target = "weapp" } = options;
168
+ const tailwindcss = loadTailwindcssPlugin(source);
169
+ const result = await (0, postcss.default)([tailwindcss(createTailwindConfig(source, options))]).process(source.css, { from: void 0 });
170
+ const rawCss = result.css;
171
+ const css = await transformTailwindV3CssByTarget(rawCss, target, styleOptions);
172
+ const dependencies = collectDependencyMessages(result);
173
+ for (const dependency of source.dependencies) dependencies.add(dependency);
174
+ return {
175
+ css,
176
+ rawCss,
177
+ classSet: collectClassSet(tailwindcss),
178
+ rawCandidates: new Set(options.candidates ?? []),
179
+ dependencies: [...dependencies],
180
+ sources: [],
181
+ root: null,
182
+ target,
183
+ version: 3
184
+ };
185
+ }
186
+ return {
187
+ source,
188
+ async validateCandidates(candidates) {
189
+ return (await generate({
190
+ candidates,
191
+ target: "tailwind"
192
+ })).classSet;
193
+ },
194
+ generate
195
+ };
196
+ }
197
+ //#endregion
198
+ //#region src/tailwindcss/v3-engine/source.ts
199
+ const DEFAULT_TAILWIND_V3_CSS = [
200
+ "@tailwind base;",
201
+ "@tailwind components;",
202
+ "@tailwind utilities;"
203
+ ].join("\n");
204
+ function parseConfigParam(params) {
205
+ const value = params.trim();
206
+ return /^(['"])(.+)\1$/.exec(value)?.[2];
207
+ }
208
+ function resolveOptionalPath(value, base) {
209
+ if (!value) return;
210
+ return node_path.default.isAbsolute(value) ? value : node_path.default.resolve(base, value);
211
+ }
212
+ function resolveCssConfig(css, base) {
213
+ if (!css) return {
214
+ css,
215
+ config: void 0
216
+ };
217
+ const root = postcss.default.parse(css);
218
+ let config;
219
+ root.walkAtRules("config", (rule) => {
220
+ const configPath = parseConfigParam(rule.params);
221
+ if (!configPath) return;
222
+ if (!config) config = resolveOptionalPath(configPath, base);
223
+ rule.remove();
224
+ });
225
+ return {
226
+ config,
227
+ css: root.toString()
228
+ };
229
+ }
230
+ function getProjectRoot$1(patcher) {
231
+ return patcher.options?.projectRoot ?? node_process.default.cwd();
232
+ }
233
+ function normalizeLoadedConfig(config) {
234
+ if (!config || typeof config !== "object") return config;
235
+ const maybeDefault = config.default;
236
+ if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
237
+ return config;
238
+ }
239
+ function resolveTailwindCssPackageName(patcher) {
240
+ return require_patcher_options.resolveTailwindcssOptions(patcher.options)?.packageName ?? patcher.packageInfo?.name ?? "tailwindcss";
241
+ }
242
+ async function resolveTailwindV3Source(options = {}) {
243
+ const projectRoot = options.projectRoot ?? node_process.default.cwd();
244
+ const base = options.base ?? options.cwd ?? projectRoot;
245
+ const cssConfig = resolveCssConfig(options.css, base);
246
+ const config = resolveOptionalPath(options.config, base) ?? cssConfig.config;
247
+ const cwd = options.cwd ?? (config ? node_path.default.dirname(config) : projectRoot);
248
+ const loaded = await (0, tailwindcss_config.loadConfig)({
249
+ config,
250
+ cwd
251
+ });
252
+ return {
253
+ version: 3,
254
+ projectRoot,
255
+ cwd,
256
+ base,
257
+ css: cssConfig.css ?? options.css ?? DEFAULT_TAILWIND_V3_CSS,
258
+ config: loaded?.filepath ?? config,
259
+ configObject: normalizeLoadedConfig(loaded?.config),
260
+ dependencies: loaded?.filepath ? [loaded.filepath] : [],
261
+ packageName: options.packageName ?? "tailwindcss",
262
+ postcssPlugin: options.postcssPlugin ?? options.packageName ?? "tailwindcss"
263
+ };
264
+ }
265
+ function resolveTailwindV3SourceOptionsFromPatcher(patcher) {
266
+ const projectRoot = getProjectRoot$1(patcher);
267
+ const tailwindOptions = require_patcher_options.resolveTailwindcssOptions(patcher.options);
268
+ return {
269
+ projectRoot,
270
+ cwd: tailwindOptions?.v3?.cwd ?? tailwindOptions?.cwd ?? projectRoot,
271
+ config: tailwindOptions?.v3?.config ?? tailwindOptions?.config,
272
+ packageName: resolveTailwindCssPackageName(patcher),
273
+ postcssPlugin: tailwindOptions?.v3?.postcssPlugin ?? tailwindOptions?.postcssPlugin
274
+ };
275
+ }
276
+ function resolveTailwindV3SourceFromPatcher(patcher) {
277
+ return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
278
+ }
279
+ //#endregion
280
+ //#region src/tailwindcss/v4-engine/miniprogram.ts
281
+ const defaultStyleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
282
+ cssChildCombinatorReplaceValue: ["view", "text"],
283
+ cssRemoveHoverPseudoClass: true,
284
+ isMainChunk: true,
285
+ majorVersion: 4
286
+ });
287
+ async function transformTailwindV4CssToWeapp(css, options) {
288
+ return pruneMiniProgramGeneratedCss((await defaultStyleHandler(css, {
289
+ cssChildCombinatorReplaceValue: ["view", "text"],
290
+ cssRemoveHoverPseudoClass: true,
291
+ isMainChunk: true,
292
+ majorVersion: 4,
293
+ ...options
294
+ })).css);
295
+ }
296
+ async function transformTailwindV4CssByTarget(css, target, options) {
297
+ return target === "weapp" ? transformTailwindV4CssToWeapp(css, options) : css;
298
+ }
299
+ //#endregion
300
+ //#region src/tailwindcss/v4-engine/generator.ts
301
+ function createTailwindV4Engine(source) {
302
+ const engine = (0, tailwindcss_patch.createTailwindV4Engine)(source);
303
+ async function generate(options = {}) {
304
+ const { styleOptions, target = "weapp", ...patchOptions } = options;
305
+ const result = await engine.generate({
306
+ scanSources: true,
307
+ ...patchOptions
308
+ });
309
+ const rawCss = result.css;
310
+ const css = await transformTailwindV4CssByTarget(rawCss, target, styleOptions);
311
+ return {
312
+ ...result,
313
+ css,
314
+ rawCss,
315
+ target
316
+ };
317
+ }
318
+ return {
319
+ source,
320
+ loadDesignSystem: engine.loadDesignSystem,
321
+ validateCandidates: engine.validateCandidates,
322
+ generate
323
+ };
324
+ }
325
+ //#endregion
326
+ //#region src/tailwindcss/v4-engine/source.ts
327
+ function isPostcssPluginImportTarget(value) {
328
+ if (!value) return false;
329
+ return value === "@tailwindcss/postcss" || value === "@tailwindcss/postcss7-compat" || value.includes("/postcss");
330
+ }
331
+ function uniqueDefined(values) {
332
+ return [...new Set(values.filter((value) => typeof value === "string" && value.length > 0))];
333
+ }
334
+ function getProjectRoot(patcher) {
335
+ return patcher.options?.projectRoot ?? node_process.default.cwd();
336
+ }
337
+ function readConfiguredV4Base(tailwindOptions) {
338
+ const v4 = tailwindOptions?.v4;
339
+ if (typeof v4 !== "object" || v4 === null) return;
340
+ return v4.configuredBase;
341
+ }
342
+ function resolveTailwindCssImportTarget(patcher) {
343
+ const configuredPackageName = require_patcher_options.resolveTailwindcssOptions(patcher.options)?.packageName;
344
+ if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
345
+ const packageName = patcher.packageInfo?.name;
346
+ if (typeof packageName === "string" && packageName.length > 0 && !isPostcssPluginImportTarget(packageName)) return packageName;
347
+ return "tailwindcss";
348
+ }
349
+ function resolveTailwindV4SourceOptionsFromPatcher(patcher) {
350
+ const projectRoot = getProjectRoot(patcher);
351
+ const tailwindOptions = require_patcher_options.resolveTailwindcssOptions(patcher.options);
352
+ const configDir = tailwindOptions?.config ? node_path.default.dirname(tailwindOptions.config) : void 0;
353
+ const configuredBase = readConfiguredV4Base(tailwindOptions);
354
+ const hasCssEntries = Boolean(tailwindOptions?.v4?.cssEntries?.length);
355
+ return {
356
+ projectRoot,
357
+ base: configuredBase ?? (hasCssEntries ? void 0 : tailwindOptions?.v4?.base),
358
+ baseFallbacks: uniqueDefined([tailwindOptions?.cwd, configDir]),
359
+ css: tailwindOptions?.v4?.css,
360
+ cssEntries: tailwindOptions?.v4?.cssEntries,
361
+ sources: tailwindOptions?.v4?.sources,
362
+ packageName: resolveTailwindCssImportTarget(patcher)
363
+ };
364
+ }
365
+ function resolveTailwindV4Source(options) {
366
+ return (0, tailwindcss_patch.resolveTailwindV4Source)(options);
367
+ }
368
+ async function resolveTailwindV4SourceFromPatcher(patcher) {
369
+ return (0, tailwindcss_patch.resolveTailwindV4Source)(resolveTailwindV4SourceOptionsFromPatcher(patcher));
370
+ }
371
+ //#endregion
372
+ //#region src/generator/options.ts
373
+ function normalizeWeappTailwindcssGeneratorOptions(options) {
374
+ if (options === false) return {
375
+ mode: "off",
376
+ target: "weapp"
377
+ };
378
+ if (options === true || options == null) return {
379
+ mode: "auto",
380
+ target: "weapp"
381
+ };
382
+ return {
383
+ mode: options.mode ?? "auto",
384
+ target: options.target ?? "weapp",
385
+ styleOptions: options.styleOptions
386
+ };
387
+ }
388
+ //#endregion
389
+ //#region src/generator/index.ts
390
+ function isTailwindV3Source(source) {
391
+ return "version" in source && source.version === 3;
392
+ }
393
+ function createWeappTailwindcssGenerator(source) {
394
+ return isTailwindV3Source(source) ? createTailwindV3Engine(source) : createTailwindV4Engine(source);
395
+ }
396
+ async function resolveTailwindSourceFromPatcher(patcher) {
397
+ return patcher.majorVersion === 3 ? resolveTailwindV3SourceFromPatcher(patcher) : resolveTailwindV4SourceFromPatcher(patcher);
398
+ }
399
+ async function createWeappTailwindcssGeneratorFromPatcher(patcher) {
400
+ return createWeappTailwindcssGenerator(await resolveTailwindSourceFromPatcher(patcher));
401
+ }
402
+ //#endregion
403
+ Object.defineProperty(exports, "createWeappTailwindcssGenerator", {
404
+ enumerable: true,
405
+ get: function() {
406
+ return createWeappTailwindcssGenerator;
407
+ }
408
+ });
409
+ Object.defineProperty(exports, "createWeappTailwindcssGeneratorFromPatcher", {
410
+ enumerable: true,
411
+ get: function() {
412
+ return createWeappTailwindcssGeneratorFromPatcher;
413
+ }
414
+ });
415
+ Object.defineProperty(exports, "normalizeWeappTailwindcssGeneratorOptions", {
416
+ enumerable: true,
417
+ get: function() {
418
+ return normalizeWeappTailwindcssGeneratorOptions;
419
+ }
420
+ });
421
+ Object.defineProperty(exports, "removeUnsupportedCascadeLayers", {
422
+ enumerable: true,
423
+ get: function() {
424
+ return removeUnsupportedCascadeLayers;
425
+ }
426
+ });
427
+ Object.defineProperty(exports, "resolveTailwindSourceFromPatcher", {
428
+ enumerable: true,
429
+ get: function() {
430
+ return resolveTailwindSourceFromPatcher;
431
+ }
432
+ });
433
+ Object.defineProperty(exports, "resolveTailwindV3Source", {
434
+ enumerable: true,
435
+ get: function() {
436
+ return resolveTailwindV3Source;
437
+ }
438
+ });
439
+ Object.defineProperty(exports, "resolveTailwindV3SourceFromPatcher", {
440
+ enumerable: true,
441
+ get: function() {
442
+ return resolveTailwindV3SourceFromPatcher;
443
+ }
444
+ });
445
+ Object.defineProperty(exports, "resolveTailwindV3SourceOptionsFromPatcher", {
446
+ enumerable: true,
447
+ get: function() {
448
+ return resolveTailwindV3SourceOptionsFromPatcher;
449
+ }
450
+ });
451
+ Object.defineProperty(exports, "resolveTailwindV4Source", {
452
+ enumerable: true,
453
+ get: function() {
454
+ return resolveTailwindV4Source;
455
+ }
456
+ });
457
+ Object.defineProperty(exports, "resolveTailwindV4SourceFromPatcher", {
458
+ enumerable: true,
459
+ get: function() {
460
+ return resolveTailwindV4SourceFromPatcher;
461
+ }
462
+ });
463
+ Object.defineProperty(exports, "resolveTailwindV4SourceOptionsFromPatcher", {
464
+ enumerable: true,
465
+ get: function() {
466
+ return resolveTailwindV4SourceOptionsFromPatcher;
467
+ }
468
+ });
469
+ Object.defineProperty(exports, "transformTailwindV3CssByTarget", {
470
+ enumerable: true,
471
+ get: function() {
472
+ return transformTailwindV3CssByTarget;
473
+ }
474
+ });
475
+ Object.defineProperty(exports, "transformTailwindV3CssToWeapp", {
476
+ enumerable: true,
477
+ get: function() {
478
+ return transformTailwindV3CssToWeapp;
479
+ }
480
+ });
481
+ Object.defineProperty(exports, "transformTailwindV4CssByTarget", {
482
+ enumerable: true,
483
+ get: function() {
484
+ return transformTailwindV4CssByTarget;
485
+ }
486
+ });
487
+ Object.defineProperty(exports, "transformTailwindV4CssToWeapp", {
488
+ enumerable: true,
489
+ get: function() {
490
+ return transformTailwindV4CssToWeapp;
491
+ }
492
+ });