weapp-tailwindcss 4.12.0 → 5.0.0-next.10

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 (324) hide show
  1. package/README.md +4 -5
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/babel/index.d.ts +3 -0
  4. package/dist/bundle-state-BWqi5ZyX.mjs +343 -0
  5. package/dist/bundle-state-EUbcdKqo.js +410 -0
  6. package/dist/bundlers/gulp/index.d.ts +7 -0
  7. package/dist/bundlers/shared/cache.d.ts +16 -0
  8. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
  9. package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
  10. package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +4 -0
  11. package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
  12. package/dist/bundlers/shared/css-cleanup.d.ts +3 -0
  13. package/dist/bundlers/shared/css-imports.d.ts +8 -0
  14. package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
  15. package/dist/bundlers/shared/generator-css/directives.d.ts +13 -0
  16. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
  17. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
  18. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
  19. package/dist/bundlers/shared/generator-css/markers.d.ts +16 -0
  20. package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -0
  21. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +10 -0
  22. package/dist/bundlers/shared/generator-css.d.ts +33 -0
  23. package/dist/bundlers/shared/module-graph.d.ts +5 -0
  24. package/dist/bundlers/shared/run-tasks.d.ts +2 -0
  25. package/dist/bundlers/vite/bundle-entries.d.ts +14 -0
  26. package/dist/bundlers/vite/bundle-state.d.ts +43 -0
  27. package/dist/bundlers/vite/css-finalizer.d.ts +22 -0
  28. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  29. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +20 -0
  30. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +3 -0
  31. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  32. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  33. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  34. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  35. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  36. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  37. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  38. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  39. package/dist/bundlers/vite/generate-bundle.d.ts +34 -0
  40. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +21 -0
  41. package/dist/bundlers/vite/index.d.ts +3 -0
  42. package/dist/bundlers/vite/js-precheck.d.ts +1 -0
  43. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  44. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  45. package/dist/bundlers/vite/query.d.ts +15 -0
  46. package/dist/bundlers/vite/resolve-app-type.d.ts +2 -0
  47. package/dist/bundlers/vite/rewrite-css-imports.d.ts +13 -0
  48. package/dist/bundlers/vite/runtime-affecting-signature.d.ts +2 -0
  49. package/dist/bundlers/vite/runtime-class-set.d.ts +22 -0
  50. package/dist/bundlers/vite/source-candidates.d.ts +18 -0
  51. package/dist/bundlers/vite/source-scan.d.ts +8 -0
  52. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  53. package/dist/bundlers/vite/utils.d.ts +9 -0
  54. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +21 -0
  55. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +20 -0
  56. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +20 -0
  57. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +10 -0
  58. package/dist/bundlers/webpack/index.d.ts +1 -0
  59. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +14 -0
  60. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +11 -0
  61. package/dist/bundlers/webpack/shared/loader-anchors.d.ts +8 -0
  62. package/dist/cache/index.d.ts +38 -0
  63. package/dist/cache/md5.d.ts +1 -0
  64. package/dist/cache-BVAiJV3J.js +502 -0
  65. package/dist/cache-CHs4DXui.mjs +434 -0
  66. package/dist/chunk-8l464Juk.js +28 -0
  67. package/dist/cli/context.d.ts +13 -0
  68. package/dist/cli/doctor/constants.d.ts +7 -0
  69. package/dist/cli/doctor/types.d.ts +31 -0
  70. package/dist/cli/doctor.d.ts +4 -0
  71. package/dist/cli/helpers/options/format.d.ts +2 -0
  72. package/dist/cli/helpers/options/parse.d.ts +3 -0
  73. package/dist/cli/helpers/options/resolve.d.ts +1 -0
  74. package/dist/cli/helpers/options.d.ts +3 -0
  75. package/dist/cli/helpers.d.ts +4 -0
  76. package/dist/cli/mount-options.d.ts +4 -0
  77. package/dist/cli/types.d.ts +15 -0
  78. package/dist/cli/vscode-entry.d.ts +14 -0
  79. package/dist/cli.d.ts +1 -2
  80. package/dist/cli.js +1985 -3574
  81. package/dist/cli.mjs +1962 -3554
  82. package/dist/constants-BG12WAKw.mjs +44 -0
  83. package/dist/constants-BeeyfJ9k.js +73 -0
  84. package/dist/constants.d.ts +12 -0
  85. package/dist/context/compiler-context-cache.d.ts +3 -0
  86. package/dist/context/custom-attributes.d.ts +2 -0
  87. package/dist/context/handlers.d.ts +6 -0
  88. package/dist/context/index.d.ts +7 -0
  89. package/dist/context/logger.d.ts +4 -0
  90. package/dist/context/tailwindcss/basedir.d.ts +1 -0
  91. package/dist/context/tailwindcss/rax.d.ts +2 -0
  92. package/dist/context/tailwindcss.d.ts +4 -0
  93. package/dist/context/workspace.d.ts +3 -0
  94. package/dist/core.d.ts +5 -21
  95. package/dist/core.js +131 -180
  96. package/dist/core.mjs +129 -180
  97. package/dist/css-macro/constants.d.ts +14 -0
  98. package/dist/css-macro/index.d.ts +15 -0
  99. package/dist/css-macro/postcss.d.ts +3 -7
  100. package/dist/css-macro/postcss.js +44 -58
  101. package/dist/css-macro/postcss.mjs +44 -56
  102. package/dist/css-macro.d.ts +2 -20
  103. package/dist/css-macro.js +37 -50
  104. package/dist/css-macro.mjs +33 -47
  105. package/dist/debug/index.d.ts +5 -0
  106. package/dist/defaults.d.ts +16 -11
  107. package/dist/defaults.js +151 -8
  108. package/dist/defaults.mjs +143 -7
  109. package/dist/escape.js +31 -54
  110. package/dist/escape.mjs +18 -25
  111. package/dist/generator/index.d.ts +11 -0
  112. package/dist/generator/options.d.ts +16 -0
  113. package/dist/generator/types.d.ts +20 -0
  114. package/dist/generator-DKkhJbOg.js +1531 -0
  115. package/dist/generator-UBmfduYg.mjs +1432 -0
  116. package/dist/generator.d.ts +1 -0
  117. package/dist/generator.js +19 -0
  118. package/dist/generator.mjs +2 -0
  119. package/dist/gulp.d.ts +4 -24
  120. package/dist/gulp.js +370 -13
  121. package/dist/gulp.mjs +362 -13
  122. package/dist/incremental-runtime-class-set-BYmzQ-_f.js +1555 -0
  123. package/dist/incremental-runtime-class-set-BgMW6wf2.mjs +1510 -0
  124. package/dist/index.d.ts +8 -15
  125. package/dist/index.js +12 -24
  126. package/dist/index.mjs +6 -24
  127. package/dist/js/JsTokenUpdater.d.ts +14 -0
  128. package/dist/js/ModuleGraph.d.ts +18 -0
  129. package/dist/js/NodePathWalker.d.ts +33 -0
  130. package/dist/js/babel/parse.d.ts +9 -0
  131. package/dist/js/babel/process.d.ts +4 -0
  132. package/dist/js/babel.d.ts +13 -0
  133. package/dist/js/class-context.d.ts +3 -0
  134. package/dist/js/evalTransforms.d.ts +7 -0
  135. package/dist/js/handlers.d.ts +5 -0
  136. package/dist/js/index.d.ts +5 -0
  137. package/dist/js/literal-transform.d.ts +2 -0
  138. package/dist/js/module-graph/ignored-exports.d.ts +18 -0
  139. package/dist/js/module-graph/types.d.ts +17 -0
  140. package/dist/js/node-path-walker/export-handlers.d.ts +12 -0
  141. package/dist/js/node-path-walker/import-tokens.d.ts +24 -0
  142. package/dist/js/precheck.d.ts +2 -0
  143. package/dist/js/sourceAnalysis.d.ts +17 -0
  144. package/dist/js/taggedTemplateIgnore.d.ts +13 -0
  145. package/dist/js/types.d.ts +11 -0
  146. package/dist/lightningcss/index.d.ts +8 -0
  147. package/dist/lightningcss/style-handler/options.d.ts +3 -0
  148. package/dist/lightningcss/style-handler/selector-transform.d.ts +10 -0
  149. package/dist/lightningcss/style-handler/selector-utils.d.ts +10 -0
  150. package/dist/lightningcss/style-handler.d.ts +17 -0
  151. package/dist/logger/index.d.ts +2 -0
  152. package/dist/logger-CZUxvJJD.mjs +2 -0
  153. package/dist/logger-EVNB9z7i.js +1 -0
  154. package/dist/postcss/config-directive.d.ts +1 -0
  155. package/dist/postcss/context.d.ts +9 -0
  156. package/dist/postcss/source-files.d.ts +8 -0
  157. package/dist/postcss/tailwind-version.d.ts +3 -0
  158. package/dist/postcss-C7efq3hr.mjs +231 -0
  159. package/dist/postcss-Dg-_lyHS.js +240 -0
  160. package/dist/postcss-html-transform.d.ts +3 -3
  161. package/dist/postcss-html-transform.js +7 -10
  162. package/dist/postcss-html-transform.mjs +3 -6
  163. package/dist/postcss.d.ts +15 -0
  164. package/dist/postcss.js +7 -0
  165. package/dist/postcss.mjs +2 -0
  166. package/dist/precheck-B32p-gLI.js +2736 -0
  167. package/dist/precheck-B4RH6ZNN.mjs +2622 -0
  168. package/dist/presets/hbuilderx.d.ts +4 -0
  169. package/dist/presets/index.d.ts +3 -0
  170. package/dist/presets/shared.d.ts +10 -0
  171. package/dist/presets/taro.d.ts +4 -0
  172. package/dist/presets/uni-app-x.d.ts +16 -0
  173. package/dist/presets/uni-app.d.ts +4 -0
  174. package/dist/presets.d.ts +1 -76
  175. package/dist/presets.js +117 -163
  176. package/dist/presets.mjs +109 -163
  177. package/dist/reset/index.d.ts +2 -0
  178. package/dist/reset.d.ts +2 -4
  179. package/dist/reset.js +19 -8
  180. package/dist/reset.mjs +2 -8
  181. package/dist/runtime-patch-CwN5ya72.mjs +71 -0
  182. package/dist/runtime-patch-D6mBo_KB.js +85 -0
  183. package/dist/shared/classname-transform.d.ts +14 -0
  184. package/dist/shared/mpx.d.ts +7 -0
  185. package/dist/shared/tailwindcss-css-redirect.d.ts +1 -0
  186. package/dist/source-scan-BaYvNx-k.js +293 -0
  187. package/dist/source-scan-cGZxoJqP.mjs +254 -0
  188. package/dist/tailwindcss/index.d.ts +11 -0
  189. package/dist/tailwindcss/miniprogram.d.ts +5 -0
  190. package/dist/tailwindcss/patcher-options.d.ts +8 -0
  191. package/dist/tailwindcss/patcher-resolve.d.ts +4 -0
  192. package/dist/tailwindcss/patcher.d.ts +12 -0
  193. package/dist/tailwindcss/remove-unsupported-css.d.ts +2 -0
  194. package/dist/tailwindcss/runtime/cache.d.ts +11 -0
  195. package/dist/tailwindcss/runtime-logs.d.ts +3 -0
  196. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  197. package/dist/tailwindcss/runtime.d.ts +28 -0
  198. package/dist/tailwindcss/source-scan.d.ts +25 -0
  199. package/dist/tailwindcss/targets.d.ts +2 -0
  200. package/dist/tailwindcss/v3-engine/generator.d.ts +2 -0
  201. package/dist/tailwindcss/v3-engine/index.d.ts +4 -0
  202. package/dist/tailwindcss/v3-engine/miniprogram.d.ts +4 -0
  203. package/dist/tailwindcss/v3-engine/source.d.ts +5 -0
  204. package/dist/tailwindcss/v3-engine/types.d.ts +55 -0
  205. package/dist/tailwindcss/v4/config.d.ts +5 -0
  206. package/dist/tailwindcss/v4/css-entries.d.ts +7 -0
  207. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  208. package/dist/tailwindcss/v4/index.d.ts +2 -0
  209. package/dist/tailwindcss/v4/multi-patcher.d.ts +2 -0
  210. package/dist/tailwindcss/v4/patcher-options.d.ts +2 -0
  211. package/dist/tailwindcss/v4/patcher.d.ts +15 -0
  212. package/dist/tailwindcss/v4-engine/candidates.d.ts +2 -0
  213. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -0
  214. package/dist/tailwindcss/v4-engine/generator.d.ts +2 -0
  215. package/dist/tailwindcss/v4-engine/index.d.ts +5 -0
  216. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +5 -0
  217. package/dist/tailwindcss/v4-engine/source.d.ts +7 -0
  218. package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +1 -0
  219. package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +1 -0
  220. package/dist/tailwindcss/v4-engine/tailwind-v4-default-colors.d.ts +1 -0
  221. package/dist/tailwindcss/v4-engine/types.d.ts +19 -0
  222. package/dist/tailwindcss/version.d.ts +4 -0
  223. package/dist/tailwindcss-Bu-RWIHx.js +630 -0
  224. package/dist/tailwindcss-C5IgPlQ0.mjs +579 -0
  225. package/dist/typedoc.export.d.ts +3 -0
  226. package/dist/types/base.d.ts +1 -0
  227. package/dist/types/index.d.ts +97 -0
  228. package/dist/types/shared.d.ts +10 -0
  229. package/dist/types/user-defined-options/general.d.ts +29 -0
  230. package/dist/types/user-defined-options/important.d.ts +37 -0
  231. package/dist/types/user-defined-options/index.d.ts +11 -0
  232. package/dist/types/user-defined-options/lifecycle.d.ts +6 -0
  233. package/dist/types/user-defined-options/matcher.d.ts +9 -0
  234. package/dist/types.d.ts +1 -150
  235. package/dist/types.js +0 -1
  236. package/dist/types.mjs +1 -1
  237. package/dist/uni-app-x/component-local-style.d.ts +19 -0
  238. package/dist/uni-app-x/index.d.ts +2 -0
  239. package/dist/uni-app-x/options.d.ts +12 -0
  240. package/dist/uni-app-x/style-isolation.d.ts +2 -0
  241. package/dist/uni-app-x/transform.d.ts +9 -0
  242. package/dist/uni-app-x/vite.d.ts +36 -0
  243. package/dist/utils/decode.d.ts +2 -0
  244. package/dist/utils/disabled.d.ts +5 -0
  245. package/dist/utils/hbuilderx.d.ts +5 -0
  246. package/dist/utils/index.d.ts +7 -0
  247. package/dist/utils/nameMatcher.d.ts +4 -0
  248. package/dist/utils/resolve-package.d.ts +1 -0
  249. package/dist/utils/uni-platform.d.ts +11 -0
  250. package/dist/utils-BiShvil9.js +61 -0
  251. package/dist/utils-Btw1iOVV.mjs +48 -0
  252. package/dist/vite-BU74SkOi.mjs +2246 -0
  253. package/dist/vite-CKjx_5c3.js +2261 -0
  254. package/dist/vite.d.ts +3 -17
  255. package/dist/vite.js +4 -14
  256. package/dist/vite.mjs +2 -14
  257. package/dist/weapp-tw-css-import-rewrite-loader.js +68 -92
  258. package/dist/weapp-tw-runtime-classset-loader.js +31 -50
  259. package/dist/webpack-CAk_ITq7.mjs +713 -0
  260. package/dist/webpack-damWiYqY.js +723 -0
  261. package/dist/webpack.d.ts +4 -25
  262. package/dist/webpack.js +6 -17
  263. package/dist/webpack.mjs +2 -17
  264. package/dist/wxml/Tokenizer.d.ts +15 -0
  265. package/dist/wxml/custom-attributes.d.ts +4 -0
  266. package/dist/wxml/index.d.ts +2 -0
  267. package/dist/wxml/shared.d.ts +2 -0
  268. package/dist/wxml/tokenizer/types.d.ts +18 -0
  269. package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +2 -0
  270. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +8 -0
  271. package/dist/wxml/utils/codegen.d.ts +2 -0
  272. package/dist/wxml/utils/custom-template.d.ts +3 -0
  273. package/dist/wxml/utils/fragment-helpers.d.ts +6 -0
  274. package/dist/wxml/utils/fragment-updater.d.ts +4 -0
  275. package/dist/wxml/utils/template-fragments.d.ts +3 -0
  276. package/dist/wxml/utils.d.ts +8 -0
  277. package/dist/wxml/whitespace.d.ts +2 -0
  278. package/generator-placeholder.css +1 -0
  279. package/package.json +39 -38
  280. package/dist/chunk-24AGZQVR.js +0 -183
  281. package/dist/chunk-3VQKDHGP.mjs +0 -179
  282. package/dist/chunk-4AFQP74Z.js +0 -24
  283. package/dist/chunk-57SOQCAU.mjs +0 -582
  284. package/dist/chunk-5ZYHNDEK.mjs +0 -2439
  285. package/dist/chunk-76S2EME4.mjs +0 -34
  286. package/dist/chunk-A5PB4KZT.js +0 -138
  287. package/dist/chunk-DUHYLR2R.js +0 -276
  288. package/dist/chunk-DYLQ6UOI.js +0 -71
  289. package/dist/chunk-E7I5TW5K.js +0 -52
  290. package/dist/chunk-FS2NOOEB.js +0 -292
  291. package/dist/chunk-HVNGIKLS.js +0 -3930
  292. package/dist/chunk-JZQBZHN5.js +0 -579
  293. package/dist/chunk-KGTVD4EP.mjs +0 -3930
  294. package/dist/chunk-NNOQDMUP.mjs +0 -10
  295. package/dist/chunk-OF6MFURR.js +0 -34
  296. package/dist/chunk-OFB2KBRP.js +0 -2442
  297. package/dist/chunk-OOHJLO5M.mjs +0 -71
  298. package/dist/chunk-PCDYXXSK.mjs +0 -1515
  299. package/dist/chunk-RKISS72P.js +0 -7
  300. package/dist/chunk-RRQZL7FQ.mjs +0 -292
  301. package/dist/chunk-XAKAD2CR.mjs +0 -138
  302. package/dist/chunk-XZP3MREK.mjs +0 -276
  303. package/dist/chunk-ZAA5ZG3D.js +0 -1518
  304. package/dist/chunk-ZCH4YINE.mjs +0 -52
  305. package/dist/cli.d.mts +0 -2
  306. package/dist/core.d.mts +0 -26
  307. package/dist/css-macro/postcss.d.mts +0 -7
  308. package/dist/css-macro.d.mts +0 -18
  309. package/dist/defaults.d.mts +0 -11
  310. package/dist/gulp.d.mts +0 -24
  311. package/dist/index-BXrmQelt.d.mts +0 -672
  312. package/dist/index-BXrmQelt.d.ts +0 -672
  313. package/dist/index.d.mts +0 -15
  314. package/dist/postcss-html-transform.d.mts +0 -2
  315. package/dist/presets.d.mts +0 -76
  316. package/dist/reset.d.mts +0 -1
  317. package/dist/types.d.mts +0 -150
  318. package/dist/vite.d.mts +0 -17
  319. package/dist/webpack.d.mts +0 -25
  320. package/dist/webpack4.d.mts +0 -26
  321. package/dist/webpack4.d.ts +0 -26
  322. package/dist/webpack4.js +0 -493
  323. package/dist/webpack4.mjs +0 -495
  324. package/scripts/postinstall.mjs +0 -59
@@ -0,0 +1,723 @@
1
+ const require_chunk = require("./chunk-8l464Juk.js");
2
+ const require_cache = require("./cache-BVAiJV3J.js");
3
+ const require_runtime_patch = require("./runtime-patch-D6mBo_KB.js");
4
+ const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-BYmzQ-_f.js");
5
+ const require_precheck = require("./precheck-B32p-gLI.js");
6
+ const require_utils = require("./utils-BiShvil9.js");
7
+ const require_tailwindcss = require("./tailwindcss-Bu-RWIHx.js");
8
+ const require_bundle_state = require("./bundle-state-EUbcdKqo.js");
9
+ let node_module = require("node:module");
10
+ node_module = require_chunk.__toESM(node_module);
11
+ let node_path = require("node:path");
12
+ node_path = require_chunk.__toESM(node_path);
13
+ let node_process = require("node:process");
14
+ node_process = require_chunk.__toESM(node_process);
15
+ let node_fs = require("node:fs");
16
+ node_fs = require_chunk.__toESM(node_fs);
17
+ //#region src/shared/tailwindcss-css-redirect.ts
18
+ const moduleWithMutableResolve = node_module.default;
19
+ const patched = /* @__PURE__ */ new WeakSet();
20
+ function installTailwindcssCssRedirect(pkgDir) {
21
+ const target = node_path.default.join(pkgDir, "index.css");
22
+ const original = moduleWithMutableResolve._resolveFilename;
23
+ if (patched.has(original)) return;
24
+ const replacements = new Set(["tailwindcss", "tailwindcss$"]);
25
+ const resolveTailwindcssCss = (request, parent, isMain, options) => {
26
+ if (replacements.has(request)) return target;
27
+ if (request.startsWith("tailwindcss/")) return node_path.default.join(pkgDir, request.slice(12));
28
+ return original(request, parent, isMain, options);
29
+ };
30
+ moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
31
+ patched.add(moduleWithMutableResolve._resolveFilename);
32
+ }
33
+ //#endregion
34
+ //#region src/shared/mpx.ts
35
+ const localRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
36
+ const MPX_STYLE_RESOURCE_QUERY_RE$1 = /(?:^|[?&])type=styles(?:&|$)/;
37
+ function isMpxStyleResourceQuery(query) {
38
+ if (typeof query !== "string") return false;
39
+ return MPX_STYLE_RESOURCE_QUERY_RE$1.test(query);
40
+ }
41
+ function isMpx(appType) {
42
+ return appType === "mpx";
43
+ }
44
+ function getTailwindcssCssEntry(pkgDir) {
45
+ return node_path.default.join(pkgDir, "index.css");
46
+ }
47
+ function resolveMpxWebpackPluginDir(compiler) {
48
+ const candidates = [
49
+ compiler?.context,
50
+ compiler?.options?.context,
51
+ node_process.default.cwd()
52
+ ].filter((item) => typeof item === "string" && item.length > 0);
53
+ for (const candidate of candidates) try {
54
+ const projectRequire = (0, node_module.createRequire)(node_path.default.join(candidate, "package.json"));
55
+ return node_path.default.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
56
+ } catch {}
57
+ return node_path.default.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
58
+ }
59
+ function isMpxWebpackPluginRequest(request) {
60
+ return request === "@mpxjs/webpack-plugin" || Boolean(request?.startsWith("@mpxjs/webpack-plugin/"));
61
+ }
62
+ function addMpxWebpackPluginAlias(alias, pkgDir) {
63
+ if (Array.isArray(alias)) alias.push({
64
+ name: /^@mpxjs\/webpack-plugin\//,
65
+ alias: pkgDir
66
+ });
67
+ else {
68
+ alias["@mpxjs/webpack-plugin"] = pkgDir;
69
+ alias["@mpxjs/webpack-plugin$"] = pkgDir;
70
+ }
71
+ }
72
+ function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
73
+ compiler.options.resolveLoader = compiler.options.resolveLoader || {};
74
+ const alias = compiler.options.resolveLoader.alias ?? {};
75
+ compiler.options.resolveLoader.alias = alias;
76
+ addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
77
+ }
78
+ function ensureMpxTailwindcssAliases(compiler, pkgDir) {
79
+ const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
80
+ compiler.options = compiler.options || {};
81
+ compiler.options.resolve = compiler.options.resolve || {};
82
+ const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(compiler);
83
+ ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir);
84
+ const alias = compiler.options.resolve.alias ?? {};
85
+ compiler.options.resolve.alias = alias;
86
+ if (Array.isArray(alias)) alias.push({
87
+ name: /^@mpxjs\/webpack-plugin\//,
88
+ alias: mpxWebpackPluginDir
89
+ }, {
90
+ name: "tailwindcss",
91
+ alias: tailwindcssCssEntry
92
+ }, {
93
+ name: "tailwindcss$",
94
+ alias: tailwindcssCssEntry
95
+ });
96
+ else {
97
+ alias["@mpxjs/webpack-plugin"] = mpxWebpackPluginDir;
98
+ alias["@mpxjs/webpack-plugin$"] = mpxWebpackPluginDir;
99
+ alias.tailwindcss = tailwindcssCssEntry;
100
+ alias.tailwindcss$ = tailwindcssCssEntry;
101
+ }
102
+ return tailwindcssCssEntry;
103
+ }
104
+ function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
105
+ if (!enabled || typeof loaderContext.resolve !== "function") return;
106
+ const originalResolve = loaderContext.resolve;
107
+ if (originalResolve.__weappTwPatched) return;
108
+ const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
109
+ const wrappedResolve = function(context, request, callback) {
110
+ if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
111
+ if (request?.startsWith("tailwindcss/")) return callback(null, node_path.default.join(pkgDir, request.slice(12)));
112
+ if (isMpxWebpackPluginRequest(request)) return originalResolve.call(this, node_process.default.cwd(), request, callback);
113
+ return originalResolve.call(this, context, request, callback);
114
+ };
115
+ wrappedResolve.__weappTwPatched = true;
116
+ loaderContext.resolve = wrappedResolve;
117
+ }
118
+ function setupMpxTailwindcssRedirect(pkgDir, enabled) {
119
+ if (enabled) installTailwindcssCssRedirect(pkgDir);
120
+ }
121
+ const CSS_EXT_RE = /\.css$/i;
122
+ function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
123
+ var _compiler$options;
124
+ if (!loader) return;
125
+ const moduleOptions = (_compiler$options = compiler.options).module ?? (_compiler$options.module = { rules: [] });
126
+ moduleOptions.rules = moduleOptions.rules || [];
127
+ const createRule = (match) => ({
128
+ ...match,
129
+ enforce: "pre",
130
+ use: [{
131
+ loader,
132
+ options: loaderOptions
133
+ }]
134
+ });
135
+ moduleOptions.rules.unshift(createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }), createRule({
136
+ test: CSS_EXT_RE,
137
+ resourceQuery: (query) => !isMpxStyleResourceQuery(query)
138
+ }));
139
+ }
140
+ //#endregion
141
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/shared.ts
142
+ const MPX_STYLE_RESOURCE_QUERY_RE = /(?:\?|&)type=styles\b/;
143
+ function getCacheKey(filename) {
144
+ return filename;
145
+ }
146
+ function stripResourceQuery(resource) {
147
+ if (typeof resource !== "string") return resource;
148
+ const queryIndex = resource.indexOf("?");
149
+ if (queryIndex !== -1) return resource.slice(0, queryIndex);
150
+ const hashIndex = resource.indexOf("#");
151
+ if (hashIndex !== -1) return resource.slice(0, hashIndex);
152
+ return resource;
153
+ }
154
+ function isCssLikeModuleResource(resource, cssMatcher, appType) {
155
+ if (typeof resource !== "string") return false;
156
+ const normalizedResource = stripResourceQuery(resource);
157
+ if (normalizedResource && cssMatcher(normalizedResource)) return true;
158
+ if (appType === "mpx") return MPX_STYLE_RESOURCE_QUERY_RE.test(resource);
159
+ return false;
160
+ }
161
+ function hasLoaderEntry(entries, target) {
162
+ if (!target) return false;
163
+ return entries.some((entry) => entry.loader?.includes?.(target));
164
+ }
165
+ function toChunkFiles(files) {
166
+ if (!files) return [];
167
+ if (Array.isArray(files)) return files;
168
+ return [...files];
169
+ }
170
+ function createAssetHashByChunkMap(chunks) {
171
+ const partsByFile = /* @__PURE__ */ new Map();
172
+ for (const chunk of chunks) {
173
+ const hash = typeof chunk.hash === "string" ? chunk.hash : void 0;
174
+ if (!hash) continue;
175
+ const chunkId = String(chunk.id ?? chunk.name ?? "");
176
+ for (const file of toChunkFiles(chunk.files)) {
177
+ if (!file) continue;
178
+ let parts = partsByFile.get(file);
179
+ if (!parts) {
180
+ parts = [];
181
+ partsByFile.set(file, parts);
182
+ }
183
+ parts.push(`${chunkId}:${hash}`);
184
+ }
185
+ }
186
+ const hashByFile = /* @__PURE__ */ new Map();
187
+ for (const [file, parts] of partsByFile.entries()) hashByFile.set(file, parts.sort().join("|"));
188
+ return hashByFile;
189
+ }
190
+ function createRuntimeAwareCssHash(assetHash, sourceHash, runtimeSetHash) {
191
+ return `${assetHash ?? sourceHash}:${runtimeSetHash}`;
192
+ }
193
+ function hasWatchChanges(compiler) {
194
+ return (compiler.modifiedFiles?.size ?? 0) > 0 || (compiler.removedFiles?.size ?? 0) > 0;
195
+ }
196
+ //#endregion
197
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets.ts
198
+ function createWebpackSnapshotAssets(assets) {
199
+ return Object.fromEntries(Object.entries(assets).map(([file, asset]) => {
200
+ const source = asset.source();
201
+ return [file, {
202
+ fileName: file,
203
+ source: typeof source === "string" ? source : source?.toString() ?? "",
204
+ type: "asset"
205
+ }];
206
+ }));
207
+ }
208
+ function setupWebpackV5ProcessAssetsHook(options) {
209
+ const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, consumeRuntimeRefreshRequirement, isWatchMode, runtimeClassSetManager, debug } = options;
210
+ const { Compilation, sources } = compiler.webpack;
211
+ const { ConcatSource } = sources;
212
+ const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
213
+ const cssUserHandlerOptionsCache = /* @__PURE__ */ new Map();
214
+ const bundleBuildState = require_bundle_state.createBundleBuildState();
215
+ const bundleRuntimeClassSetManager = runtimeClassSetManager ?? require_incremental_runtime_class_set.createBundleRuntimeClassSetManager();
216
+ let webpackWatchRuntimeScanInitialized = false;
217
+ compiler.hooks.compilation.tap(require_precheck.pluginName, (compilation) => {
218
+ compilation.hooks.processAssets.tapPromise({
219
+ name: require_precheck.pluginName,
220
+ stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
221
+ }, async (assets) => {
222
+ compilerOptions.onStart();
223
+ debug("start");
224
+ await runtimeState.readyPromise;
225
+ for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
226
+ const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
227
+ const entries = Object.entries(assets);
228
+ const compilerOutputPath = compilation.compiler?.outputPath ?? compiler.outputPath;
229
+ const outputDir = compilerOutputPath ? node_path.default.resolve(compilerOutputPath) : compilation.outputOptions?.path ?? node_process.default.cwd();
230
+ const jsAssets = /* @__PURE__ */ new Map();
231
+ for (const [file] of entries) if (compilerOptions.jsMatcher(file) || compilerOptions.wxsMatcher(file)) {
232
+ const absolute = require_bundle_state.toAbsoluteOutputPath(file, outputDir);
233
+ jsAssets.set(absolute, file);
234
+ }
235
+ const moduleGraphOptions = {
236
+ resolve(specifier, importer) {
237
+ return require_bundle_state.resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
238
+ },
239
+ load: (id) => {
240
+ const assetName = jsAssets.get(id);
241
+ if (!assetName) return;
242
+ const asset = compilation.getAsset(assetName);
243
+ if (!asset) return;
244
+ const source = asset.source.source();
245
+ return typeof source === "string" ? source : source.toString();
246
+ },
247
+ filter(id) {
248
+ return jsAssets.has(id);
249
+ }
250
+ };
251
+ const applyLinkedResults = (linked) => {
252
+ if (!linked) return;
253
+ for (const [id, { code }] of Object.entries(linked)) {
254
+ const assetName = jsAssets.get(id);
255
+ if (!assetName) continue;
256
+ const asset = compilation.getAsset(assetName);
257
+ if (!asset) continue;
258
+ const previousSource = asset.source.source();
259
+ const previous = typeof previousSource === "string" ? previousSource : previousSource.toString();
260
+ if (previous === code) continue;
261
+ const source = new ConcatSource(code);
262
+ compilation.updateAsset(assetName, source);
263
+ compilerOptions.onUpdate(assetName, previous, code);
264
+ debug("js linked handle: %s", assetName);
265
+ }
266
+ };
267
+ const groupedEntries = require_utils.getGroupedEntries(entries, compilerOptions);
268
+ const getCssHandlerOptions = (file) => {
269
+ const majorVersion = runtimeState.twPatcher.majorVersion;
270
+ const isMainChunk = compilerOptions.mainCssChunkMatcher(file, appType);
271
+ const cacheKey = `${majorVersion ?? "unknown"}:${isMainChunk ? "1" : "0"}:${file}`;
272
+ const cached = cssHandlerOptionsCache.get(cacheKey);
273
+ if (cached) return cached;
274
+ const created = {
275
+ isMainChunk,
276
+ postcssOptions: { options: { from: file } },
277
+ majorVersion
278
+ };
279
+ cssHandlerOptionsCache.set(cacheKey, created);
280
+ return created;
281
+ };
282
+ const getCssUserHandlerOptions = (file) => {
283
+ const cacheKey = `${runtimeState.twPatcher.majorVersion ?? "unknown"}:${file}`;
284
+ const cached = cssUserHandlerOptionsCache.get(cacheKey);
285
+ if (cached) return cached;
286
+ const created = {
287
+ ...getCssHandlerOptions(file),
288
+ isMainChunk: false
289
+ };
290
+ cssUserHandlerOptionsCache.set(cacheKey, created);
291
+ return created;
292
+ };
293
+ const forceRuntimeRefresh = getRuntimeRefreshRequirement();
294
+ debug("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, runtimeState.twPatcher.majorVersion ?? "unknown");
295
+ let runtimeSet;
296
+ if (isWatchMode?.() === true && runtimeState.twPatcher.majorVersion === 4 && !forceRuntimeRefresh) {
297
+ const snapshot = require_bundle_state.buildBundleSnapshot(createWebpackSnapshotAssets(assets), compilerOptions, outputDir, bundleBuildState);
298
+ if (!webpackWatchRuntimeScanInitialized) {
299
+ for (const entry of snapshot.entries) if (entry.type === "html" || entry.type === "js") snapshot.runtimeAffectingChangedByType[entry.type].add(entry.file);
300
+ }
301
+ try {
302
+ runtimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot);
303
+ } catch (error) {
304
+ debug("webpack incremental runtime set sync failed, fallback to full collect: %O", error);
305
+ await bundleRuntimeClassSetManager.reset();
306
+ runtimeSet = await require_precheck.ensureRuntimeClassSet(runtimeState, {
307
+ forceRefresh: false,
308
+ forceCollect: true,
309
+ clearCache: false,
310
+ allowEmpty: false
311
+ });
312
+ }
313
+ require_bundle_state.updateBundleBuildState(bundleBuildState, snapshot, /* @__PURE__ */ new Map(), { incremental: true });
314
+ webpackWatchRuntimeScanInitialized = true;
315
+ } else {
316
+ if (forceRuntimeRefresh) {
317
+ await bundleRuntimeClassSetManager.reset();
318
+ webpackWatchRuntimeScanInitialized = false;
319
+ }
320
+ runtimeSet = await require_precheck.ensureRuntimeClassSet(runtimeState, {
321
+ forceRefresh: forceRuntimeRefresh,
322
+ forceCollect: true,
323
+ clearCache: forceRuntimeRefresh,
324
+ allowEmpty: false
325
+ });
326
+ if (runtimeSet.size === 0) {
327
+ const syncSet = runtimeState.twPatcher.getClassSetSync?.();
328
+ if (syncSet && syncSet.size > 0) runtimeSet = syncSet;
329
+ }
330
+ }
331
+ await refreshRuntimeMetadata(forceRuntimeRefresh);
332
+ consumeRuntimeRefreshRequirement();
333
+ const runtimeSetHash = compilerOptions.cache.computeHash([require_cache.getRuntimeClassSetSignature(runtimeState.twPatcher), [...runtimeSet].sort().join("\n")].join("\n\n"));
334
+ const defaultTemplateHandlerOptions = { runtimeSet };
335
+ debug("get runtimeSet, class count: %d", runtimeSet.size);
336
+ const tasks = [];
337
+ if (Array.isArray(groupedEntries.html)) for (const element of groupedEntries.html) {
338
+ const [file, originalSource] = element;
339
+ const rawSource = originalSource.source().toString();
340
+ const cacheKey = file;
341
+ const chunkHash = assetHashByChunk.get(file);
342
+ tasks.push(require_incremental_runtime_class_set.processCachedTask({
343
+ cache: compilerOptions.cache,
344
+ cacheKey,
345
+ hashKey: `${file}:asset`,
346
+ rawSource,
347
+ hash: chunkHash,
348
+ applyResult(source) {
349
+ compilation.updateAsset(file, source);
350
+ },
351
+ onCacheHit() {
352
+ debug("html cache hit: %s", file);
353
+ },
354
+ transform: async () => {
355
+ const wxml = await compilerOptions.templateHandler(rawSource, defaultTemplateHandlerOptions);
356
+ const source = new ConcatSource(wxml);
357
+ compilerOptions.onUpdate(file, rawSource, wxml);
358
+ debug("html handle: %s", file);
359
+ return { result: source };
360
+ }
361
+ }));
362
+ }
363
+ const jsTaskFactories = [];
364
+ if (Array.isArray(groupedEntries.js)) for (const [file] of groupedEntries.js) {
365
+ const cacheKey = getCacheKey(file);
366
+ const asset = compilation.getAsset(file);
367
+ if (!asset) continue;
368
+ const absoluteFile = require_bundle_state.toAbsoluteOutputPath(file, outputDir);
369
+ const initialSource = asset.source.source();
370
+ const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
371
+ const chunkHash = assetHashByChunk.get(file);
372
+ jsTaskFactories.push(async () => {
373
+ await require_incremental_runtime_class_set.processCachedTask({
374
+ cache: compilerOptions.cache,
375
+ cacheKey,
376
+ hashKey: `${file}:asset`,
377
+ rawSource: initialRawSource,
378
+ hash: chunkHash,
379
+ applyResult(source) {
380
+ compilation.updateAsset(file, source);
381
+ },
382
+ onCacheHit() {
383
+ debug("js cache hit: %s", file);
384
+ },
385
+ transform: async () => {
386
+ const currentSourceValue = compilation.getAsset(file)?.source.source();
387
+ const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : currentSourceValue?.toString() ?? "";
388
+ const handlerOptions = {
389
+ tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
390
+ filename: absoluteFile,
391
+ moduleGraph: moduleGraphOptions,
392
+ babelParserOptions: { sourceFilename: absoluteFile }
393
+ };
394
+ if (require_precheck.shouldSkipJsTransform(currentSource, {
395
+ ...handlerOptions,
396
+ classNameSet: runtimeSet
397
+ })) return { result: new ConcatSource(currentSource) };
398
+ const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, handlerOptions);
399
+ const source = new ConcatSource(code);
400
+ compilerOptions.onUpdate(file, currentSource, code);
401
+ debug("js handle: %s", file);
402
+ applyLinkedResults(linked);
403
+ return { result: source };
404
+ }
405
+ });
406
+ });
407
+ }
408
+ if (Array.isArray(groupedEntries.css)) for (const element of groupedEntries.css) {
409
+ const [file, originalSource] = element;
410
+ const rawSource = originalSource.source().toString();
411
+ const cacheKey = file;
412
+ const runtimeAwareHash = createRuntimeAwareCssHash(assetHashByChunk.get(file), compilerOptions.cache.computeHash(rawSource), runtimeSetHash);
413
+ tasks.push(require_incremental_runtime_class_set.processCachedTask({
414
+ cache: compilerOptions.cache,
415
+ cacheKey,
416
+ hashKey: `${file}:asset`,
417
+ rawSource,
418
+ hash: runtimeAwareHash,
419
+ applyResult(source) {
420
+ compilation.updateAsset(file, source);
421
+ },
422
+ onCacheHit() {
423
+ debug("css cache hit: %s", file);
424
+ },
425
+ transform: async () => {
426
+ await runtimeState.readyPromise;
427
+ const cssHandlerOptions = getCssHandlerOptions(file);
428
+ const generated = await require_incremental_runtime_class_set.generateCssByGenerator({
429
+ opts: compilerOptions,
430
+ runtimeState,
431
+ runtime: runtimeSet,
432
+ rawSource,
433
+ file,
434
+ cssHandlerOptions,
435
+ cssUserHandlerOptions: getCssUserHandlerOptions(file),
436
+ styleHandler: compilerOptions.styleHandler,
437
+ debug
438
+ });
439
+ const css = generated?.css ?? (await compilerOptions.styleHandler(rawSource, cssHandlerOptions)).css;
440
+ const source = new ConcatSource(css);
441
+ compilerOptions.onUpdate(file, rawSource, css);
442
+ if (generated) debug("css handle via tailwind v%s engine(%s): %s", runtimeState.twPatcher.majorVersion, generated.target, file);
443
+ else debug("css handle: %s", file);
444
+ return { result: source };
445
+ }
446
+ }));
447
+ }
448
+ require_bundle_state.pushConcurrentTaskFactories(tasks, jsTaskFactories);
449
+ await Promise.all(tasks);
450
+ debug("end");
451
+ compilerOptions.onEnd();
452
+ });
453
+ });
454
+ }
455
+ //#endregion
456
+ //#region src/bundlers/webpack/shared/loader-anchors.ts
457
+ const MPX_STRIP_CONDITIONAL_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader";
458
+ const MPX_STYLE_COMPILER_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/index";
459
+ const MPX_REWRITE_PRECEDENCE_LOADERS = [MPX_STYLE_COMPILER_LOADER, MPX_STRIP_CONDITIONAL_LOADER];
460
+ function createFinder(targets) {
461
+ return (entries) => entries.findIndex((entry) => targets.some((target) => entry?.loader?.includes?.(target)));
462
+ }
463
+ function createPrioritizedFinder(targets) {
464
+ return (entries) => {
465
+ for (const target of targets) {
466
+ const idx = entries.findIndex((entry) => entry?.loader?.includes?.(target));
467
+ if (idx !== -1) return idx;
468
+ }
469
+ return -1;
470
+ };
471
+ }
472
+ function createLoaderAnchorFinders(appType) {
473
+ if (isMpx(appType)) return {
474
+ findRewriteAnchor: createPrioritizedFinder(MPX_REWRITE_PRECEDENCE_LOADERS),
475
+ findClassSetAnchor: createFinder([MPX_STYLE_COMPILER_LOADER])
476
+ };
477
+ const fallbackFinder = createFinder(["postcss-loader"]);
478
+ return {
479
+ findRewriteAnchor: fallbackFinder,
480
+ findClassSetAnchor: fallbackFinder
481
+ };
482
+ }
483
+ //#endregion
484
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
485
+ function setupWebpackV5Loaders(options) {
486
+ const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, getClassSetInLoader, getRuntimeWatchDependencies, debug } = options;
487
+ const isMpxApp = isMpx(appType);
488
+ if (shouldRewriteCssImports && isMpxApp) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
489
+ const runtimeClassSetLoader = runtimeLoaderPath ?? node_path.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
490
+ const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? node_path.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js") : void 0;
491
+ const runtimeClassSetLoaderExists = node_fs.default.existsSync(runtimeClassSetLoader);
492
+ const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? node_fs.default.existsSync(runtimeCssImportRewriteLoader) : false;
493
+ const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
494
+ pkgDir: weappTailwindcssPackageDir,
495
+ appType,
496
+ registerCssSource: registerAutoCssSource
497
+ } : void 0;
498
+ const classSetLoaderOptions = {
499
+ getClassSet: getClassSetInLoader,
500
+ getWatchDependencies: getRuntimeWatchDependencies
501
+ };
502
+ const { findRewriteAnchor, findClassSetAnchor } = createLoaderAnchorFinders(appType);
503
+ const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? { tailwindcssImportRewrite: runtimeLoaderRewriteOptions } : void 0;
504
+ if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) injectMpxCssRewritePreRules(compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
505
+ const createRuntimeClassSetLoaderEntry = () => ({
506
+ loader: runtimeClassSetLoader,
507
+ options: classSetLoaderOptions,
508
+ ident: null,
509
+ type: null
510
+ });
511
+ const createCssImportRewriteLoaderEntry = () => {
512
+ if (!runtimeCssImportRewriteLoader) return null;
513
+ return {
514
+ loader: runtimeCssImportRewriteLoader,
515
+ options: cssImportRewriteLoaderOptions,
516
+ ident: null,
517
+ type: null
518
+ };
519
+ };
520
+ const { NormalModule } = compiler.webpack;
521
+ compiler.hooks.compilation.tap(require_precheck.pluginName, (compilation) => {
522
+ NormalModule.getCompilationHooks(compilation).loader.tap(require_precheck.pluginName, (_loaderContext, module) => {
523
+ if (!(runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists)) return;
524
+ patchMpxLoaderResolve(_loaderContext, weappTailwindcssPackageDir, shouldRewriteCssImports && isMpxApp);
525
+ const loaderEntries = module.loaders || [];
526
+ let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
527
+ const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
528
+ const isCssModule = isCssLikeModuleResource(module.resource, compilerOptions.cssMatcher, appType);
529
+ if (node_process.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
530
+ rewriteAnchorIdx,
531
+ classSetAnchorIdx
532
+ });
533
+ if (node_process.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.includes("app.css")) debug("app.css module loaders=%o anchors=%o", loaderEntries.map((x) => x.loader), {
534
+ rewriteAnchorIdx,
535
+ classSetAnchorIdx
536
+ });
537
+ else if (node_process.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.endsWith(".css")) debug("css module seen: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
538
+ rewriteAnchorIdx,
539
+ classSetAnchorIdx
540
+ });
541
+ if (rewriteAnchorIdx === -1 && classSetAnchorIdx === -1 && !isCssModule) return;
542
+ const anchorlessInsert = (entry, position) => {
543
+ if (position === "after") loaderEntries.push(entry);
544
+ else loaderEntries.unshift(entry);
545
+ };
546
+ if (cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoaderExists && runtimeCssImportRewriteLoader) {
547
+ const existingIndex = loaderEntries.findIndex((entry) => entry.loader?.includes?.(runtimeCssImportRewriteLoader));
548
+ const rewriteLoaderEntry = existingIndex !== -1 ? loaderEntries.splice(existingIndex, 1)[0] : createCssImportRewriteLoaderEntry();
549
+ if (rewriteLoaderEntry) {
550
+ const anchorIndex = findRewriteAnchor(loaderEntries);
551
+ if (anchorIndex === -1) anchorlessInsert(rewriteLoaderEntry, "after");
552
+ else loaderEntries.splice(anchorIndex + 1, 0, rewriteLoaderEntry);
553
+ rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
554
+ }
555
+ }
556
+ if (runtimeClassSetLoaderExists && !hasLoaderEntry(loaderEntries, runtimeClassSetLoader)) {
557
+ const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
558
+ const anchorIndex = findClassSetAnchor(loaderEntries);
559
+ if (anchorIndex === -1) anchorlessInsert(classSetLoaderEntry, "before");
560
+ else {
561
+ const insertIndex = anchorIndex === -1 ? rewriteAnchorIdx : anchorIndex;
562
+ loaderEntries.splice(insertIndex, 0, classSetLoaderEntry);
563
+ }
564
+ }
565
+ });
566
+ });
567
+ }
568
+ //#endregion
569
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
570
+ const debug = require_runtime_patch.createDebug();
571
+ const weappTailwindcssPackageDir = require_bundle_state.resolvePackageDir("weapp-tailwindcss");
572
+ /**
573
+ * @name UnifiedWebpackPluginV5
574
+ * @description webpack5 核心转义插件
575
+ * @link https://tw.icebreaker.top/docs/intro
576
+ */
577
+ var UnifiedWebpackPluginV5 = class {
578
+ constructor(options = {}) {
579
+ require_precheck._defineProperty(this, "options", void 0);
580
+ require_precheck._defineProperty(this, "appType", void 0);
581
+ require_precheck._defineProperty(this, "hasInitialTailwindCssRoots", void 0);
582
+ this.hasInitialTailwindCssRoots = require_tailwindcss.hasConfiguredTailwindV4CssRoots(options);
583
+ this.options = require_precheck.getCompilerContext({
584
+ ...options,
585
+ __internalDeferMissingCssEntriesWarning: true
586
+ });
587
+ this.appType = this.options.appType;
588
+ }
589
+ apply(compiler) {
590
+ compiler.options = compiler.options || {};
591
+ const { disabled, onLoad, runtimeLoaderPath, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = this.options;
592
+ const disabledOptions = require_bundle_state.resolvePluginDisabledState(disabled);
593
+ const shouldRewriteCssImports = (initialTwPatcher.majorVersion ?? 0) >= 4;
594
+ const isMpxApp = isMpx(this.appType);
595
+ if (shouldRewriteCssImports) setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
596
+ if (disabledOptions.plugin) return;
597
+ const runtimeState = {
598
+ twPatcher: initialTwPatcher,
599
+ readyPromise: require_precheck.createTailwindRuntimeReadyPromise(initialTwPatcher),
600
+ refreshTailwindcssPatcher
601
+ };
602
+ let runtimeSetPrepared = false;
603
+ let runtimeSetSignature;
604
+ let runtimeRefreshRequiredForCompilation = false;
605
+ let watchRunObserved = false;
606
+ const runtimeWatchDependencyFiles = /* @__PURE__ */ new Set();
607
+ const runtimeWatchDependencyContexts = /* @__PURE__ */ new Set();
608
+ let runtimeMetadataPrepared = false;
609
+ const updateRuntimeWatchDependencies = async () => {
610
+ runtimeWatchDependencyFiles.clear();
611
+ runtimeWatchDependencyContexts.clear();
612
+ const tailwindOptions = require_cache.resolveTailwindcssOptions(runtimeState.twPatcher.options);
613
+ if (tailwindOptions?.config) runtimeWatchDependencyFiles.add(tailwindOptions.config);
614
+ for (const entry of tailwindOptions?.v4?.cssEntries ?? []) runtimeWatchDependencyFiles.add(entry);
615
+ for (const source of tailwindOptions?.v4?.cssSources ?? []) {
616
+ if (source.file) runtimeWatchDependencyFiles.add(source.file);
617
+ for (const dependency of source.dependencies ?? []) runtimeWatchDependencyFiles.add(dependency);
618
+ }
619
+ for (const source of tailwindOptions?.v4?.sources ?? []) if (source?.base) runtimeWatchDependencyContexts.add(source.base);
620
+ if (typeof runtimeState.twPatcher.collectContentTokens !== "function") return;
621
+ try {
622
+ const report = await runtimeState.twPatcher.collectContentTokens();
623
+ for (const entry of report.entries ?? []) if (entry.file) runtimeWatchDependencyFiles.add(entry.file);
624
+ for (const source of report.sources ?? []) if (source?.base) runtimeWatchDependencyContexts.add(source.base);
625
+ } catch (error) {
626
+ debug("collect runtime watch dependencies failed: %O", error);
627
+ }
628
+ };
629
+ const ensureRuntimeMetadata = async (force = false) => {
630
+ if (runtimeMetadataPrepared && !force) return;
631
+ await updateRuntimeWatchDependencies();
632
+ runtimeMetadataPrepared = true;
633
+ };
634
+ const syncRuntimeRefreshRequirement = (markWatchRun = false) => {
635
+ if (markWatchRun) watchRunObserved = true;
636
+ runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || hasWatchChanges(compiler);
637
+ };
638
+ const resetRuntimePreparation = () => {
639
+ runtimeSetPrepared = false;
640
+ runtimeMetadataPrepared = false;
641
+ syncRuntimeRefreshRequirement();
642
+ };
643
+ const registerAutoCssSource = async (source) => {
644
+ if (this.hasInitialTailwindCssRoots || (runtimeState.twPatcher.majorVersion ?? 0) < 4 || !source.file) return;
645
+ if (!require_tailwindcss.upsertTailwindV4CssSource(this.options, source)) return;
646
+ runtimeSetPrepared = false;
647
+ runtimeMetadataPrepared = false;
648
+ runtimeRefreshRequiredForCompilation = true;
649
+ await require_precheck.refreshTailwindRuntimeState(runtimeState, {
650
+ force: true,
651
+ clearCache: true
652
+ });
653
+ debug("detected tailwindcss v4 css source from webpack css module: %s", source.file);
654
+ };
655
+ compiler.hooks.invalid?.tap?.(require_precheck.pluginName, () => {
656
+ runtimeRefreshRequiredForCompilation = true;
657
+ });
658
+ compiler.hooks.watchRun?.tap?.(require_precheck.pluginName, () => syncRuntimeRefreshRequirement(true));
659
+ if (compiler.hooks.thisCompilation?.tap) compiler.hooks.thisCompilation.tap(require_precheck.pluginName, resetRuntimePreparation);
660
+ else if (compiler.hooks.compilation?.tap) compiler.hooks.compilation.tap(require_precheck.pluginName, resetRuntimePreparation);
661
+ async function getClassSetInLoader() {
662
+ if (runtimeSetPrepared) return;
663
+ const signature = require_cache.getRuntimeClassSetSignature(runtimeState.twPatcher);
664
+ const forceRefresh = runtimeRefreshRequiredForCompilation || signature !== runtimeSetSignature;
665
+ debug("runtime loader ensure class set forceRefresh=%s watchDirty=%s signatureChanged=%s", forceRefresh, runtimeRefreshRequiredForCompilation, signature !== runtimeSetSignature);
666
+ runtimeSetPrepared = true;
667
+ await require_precheck.ensureRuntimeClassSet(runtimeState, {
668
+ forceRefresh,
669
+ forceCollect: forceRefresh || !watchRunObserved,
670
+ clearCache: forceRefresh,
671
+ allowEmpty: true
672
+ });
673
+ await ensureRuntimeMetadata(forceRefresh);
674
+ runtimeSetSignature = signature;
675
+ runtimeRefreshRequiredForCompilation = false;
676
+ }
677
+ onLoad();
678
+ setupWebpackV5Loaders({
679
+ compiler,
680
+ options: this.options,
681
+ appType: this.appType,
682
+ weappTailwindcssPackageDir,
683
+ shouldRewriteCssImports,
684
+ runtimeLoaderPath,
685
+ registerAutoCssSource,
686
+ getClassSetInLoader,
687
+ getRuntimeWatchDependencies() {
688
+ return {
689
+ files: runtimeWatchDependencyFiles,
690
+ contexts: runtimeWatchDependencyContexts
691
+ };
692
+ },
693
+ debug
694
+ });
695
+ setupWebpackV5ProcessAssetsHook({
696
+ compiler,
697
+ options: this.options,
698
+ appType: this.appType,
699
+ runtimeState,
700
+ getRuntimeRefreshRequirement: () => runtimeRefreshRequiredForCompilation,
701
+ refreshRuntimeMetadata: ensureRuntimeMetadata,
702
+ consumeRuntimeRefreshRequirement() {
703
+ runtimeRefreshRequiredForCompilation = false;
704
+ },
705
+ isWatchMode: () => watchRunObserved || compiler.options?.watch === true,
706
+ runtimeClassSetManager: this.options.__internalWebpackRuntimeClassSetManager,
707
+ debug
708
+ });
709
+ }
710
+ };
711
+ //#endregion
712
+ Object.defineProperty(exports, "UnifiedWebpackPluginV5", {
713
+ enumerable: true,
714
+ get: function() {
715
+ return UnifiedWebpackPluginV5;
716
+ }
717
+ });
718
+ Object.defineProperty(exports, "weappTailwindcssPackageDir", {
719
+ enumerable: true,
720
+ get: function() {
721
+ return weappTailwindcssPackageDir;
722
+ }
723
+ });