weapp-tailwindcss 5.0.0-next.2 → 5.0.0-next.21

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 (221) hide show
  1. package/README.md +6 -7
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/bundle-state-BnV8o2Yn.js +530 -0
  4. package/dist/bundle-state-CLnuf2CW.mjs +414 -0
  5. package/dist/bundlers/shared/cache.d.ts +6 -6
  6. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -0
  7. package/dist/bundlers/shared/css-cleanup.d.ts +1 -4
  8. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  9. package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
  10. package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
  11. package/dist/bundlers/shared/generator-css/directives.d.ts +20 -0
  12. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
  13. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
  14. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
  15. package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
  16. package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
  17. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
  18. package/dist/bundlers/shared/generator-css.d.ts +16 -22
  19. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  20. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  21. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  22. package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
  23. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  24. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
  25. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
  26. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  27. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  28. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  29. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  30. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  31. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  32. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  33. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  34. package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
  35. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
  36. package/dist/bundlers/vite/index.d.ts +1 -1
  37. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  38. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  39. package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
  40. package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
  41. package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
  42. package/dist/bundlers/vite/source-candidates.d.ts +16 -1
  43. package/dist/bundlers/vite/source-scan.d.ts +26 -0
  44. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  45. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  46. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
  47. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
  48. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
  49. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
  50. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
  51. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
  52. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
  53. package/dist/cache/index.d.ts +6 -6
  54. package/dist/cli/context.d.ts +1 -14
  55. package/dist/cli/doctor/types.d.ts +11 -11
  56. package/dist/cli/helpers.d.ts +1 -2
  57. package/dist/cli/mount-options.d.ts +2 -0
  58. package/dist/cli/types.d.ts +0 -2
  59. package/dist/cli/vscode-entry.d.ts +3 -3
  60. package/dist/cli.js +605 -611
  61. package/dist/cli.mjs +614 -620
  62. package/dist/constants.d.ts +1 -2
  63. package/dist/core.js +13 -20
  64. package/dist/core.mjs +8 -14
  65. package/dist/css-macro/postcss.js +3 -2
  66. package/dist/css-macro/postcss.mjs +3 -2
  67. package/dist/css-macro.d.ts +1 -0
  68. package/dist/css-macro.js +2 -2
  69. package/dist/css-macro.mjs +2 -2
  70. package/dist/defaults-B1igPF_e.mjs +150 -0
  71. package/dist/defaults-IHhYxNeU.js +193 -0
  72. package/dist/defaults.d.ts +15 -1
  73. package/dist/defaults.js +6 -131
  74. package/dist/defaults.mjs +2 -129
  75. package/dist/escape.js +10 -2
  76. package/dist/escape.mjs +10 -2
  77. package/dist/generator/index.d.ts +1 -1
  78. package/dist/generator/options.d.ts +9 -8
  79. package/dist/generator/types.d.ts +3 -3
  80. package/dist/generator-B4RNgMLx.js +55 -0
  81. package/dist/generator-DvyhmC76.mjs +32 -0
  82. package/dist/generator.js +12 -11
  83. package/dist/generator.mjs +2 -1
  84. package/dist/gulp.js +185 -47
  85. package/dist/gulp.mjs +179 -41
  86. package/dist/incremental-runtime-class-set-C7Q7fC5u.mjs +1863 -0
  87. package/dist/incremental-runtime-class-set-DZsbM0-a.js +1926 -0
  88. package/dist/index.d.ts +1 -1
  89. package/dist/index.js +6 -6
  90. package/dist/index.mjs +5 -5
  91. package/dist/js/babel/cache-options.d.ts +3 -0
  92. package/dist/js/babel/parse.d.ts +7 -4
  93. package/dist/js/index.d.ts +1 -0
  94. package/dist/js/literal-transform.d.ts +2 -0
  95. package/dist/js/precheck.d.ts +2 -2
  96. package/dist/logger-CZUxvJJD.mjs +2 -0
  97. package/dist/logger-EVNB9z7i.js +1 -0
  98. package/dist/postcss/config-directive.d.ts +1 -0
  99. package/dist/postcss/context.d.ts +9 -0
  100. package/dist/postcss/source-files.d.ts +8 -0
  101. package/dist/postcss/tailwind-version.d.ts +3 -0
  102. package/dist/postcss-CFa6-qO9.js +237 -0
  103. package/dist/postcss-Drpy7j-g.mjs +228 -0
  104. package/dist/postcss.d.ts +2 -2
  105. package/dist/postcss.js +3 -276
  106. package/dist/postcss.mjs +1 -269
  107. package/dist/{recorder-gYSNLfOP.js → precheck-8pQbjqpq.js} +218 -314
  108. package/dist/{recorder-zsgatmkB.mjs → precheck-D1O5AWzy.mjs} +186 -281
  109. package/dist/presets.js +13 -11
  110. package/dist/presets.mjs +11 -9
  111. package/dist/reset.d.ts +1 -0
  112. package/dist/runtime-registry-CdCV3Opt.js +5496 -0
  113. package/dist/shared/mpx.d.ts +1 -0
  114. package/dist/source-candidates-CUTNdsiz.js +222 -0
  115. package/dist/source-candidates-CnD4vyic.mjs +209 -0
  116. package/dist/tailwindcss/miniprogram.d.ts +1 -1
  117. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  118. package/dist/tailwindcss/patcher.d.ts +1 -2
  119. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
  120. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  121. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  122. package/dist/tailwindcss/runtime.d.ts +11 -12
  123. package/dist/tailwindcss/source-scan.d.ts +35 -0
  124. package/dist/tailwindcss/targets.d.ts +1 -5
  125. package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
  126. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  127. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  128. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  129. package/dist/tailwindcss/v4/patcher.d.ts +1 -0
  130. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  131. package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
  132. package/dist/tailwindcss/version.d.ts +4 -0
  133. package/dist/tailwindcss-B_JAdOQf.mjs +600 -0
  134. package/dist/tailwindcss-whZE3HpL.js +651 -0
  135. package/dist/typedoc.export.d.ts +0 -2
  136. package/dist/types/index.d.ts +51 -48
  137. package/dist/types/shared.d.ts +3 -0
  138. package/dist/types/user-defined-options/general.d.ts +23 -23
  139. package/dist/types/user-defined-options/important.d.ts +31 -28
  140. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  141. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  142. package/dist/uni-app-x/vite.d.ts +1 -1
  143. package/dist/utils/disabled.d.ts +2 -3
  144. package/dist/utils/object.d.ts +9 -0
  145. package/dist/{utils-DmC9_In3.js → utils-4ODFyoqD.js} +1 -1
  146. package/dist/{utils-7DUGTFED.mjs → utils-CGBVVNm6.mjs} +1 -1
  147. package/dist/v3-engine-CCwvhRrQ.js +3473 -0
  148. package/dist/v3-engine-DyIcbpZm.mjs +3190 -0
  149. package/dist/{vite-CrlzCNqz.mjs → vite-B8IiXgVD.mjs} +1256 -1088
  150. package/dist/vite-BcnwgJMt.js +2368 -0
  151. package/dist/vite.d.ts +1 -2
  152. package/dist/vite.js +3 -4
  153. package/dist/vite.mjs +2 -2
  154. package/dist/weapp-tw-css-import-rewrite-loader.js +4533 -16
  155. package/dist/weapp-tw-runtime-classset-loader.js +33 -7
  156. package/dist/webpack-C4zI624R.js +846 -0
  157. package/dist/webpack-DTkshAtp.mjs +836 -0
  158. package/dist/webpack.js +1 -1
  159. package/dist/webpack.mjs +1 -1
  160. package/package.json +27 -37
  161. package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
  162. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
  163. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
  164. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
  165. package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
  166. package/dist/cli/config.d.ts +0 -5
  167. package/dist/cli/helpers/patch-cwd.d.ts +0 -1
  168. package/dist/cli/mount-options/patch-status.d.ts +0 -2
  169. package/dist/cli/patch-options.d.ts +0 -6
  170. package/dist/cli/tokens.d.ts +0 -4
  171. package/dist/cli/workspace/package-dirs.d.ts +0 -3
  172. package/dist/cli/workspace/patch-package.d.ts +0 -3
  173. package/dist/cli/workspace/patch-utils.d.ts +0 -3
  174. package/dist/cli/workspace/types.d.ts +0 -11
  175. package/dist/cli/workspace/workspace-globs.d.ts +0 -2
  176. package/dist/cli/workspace/workspace-io.d.ts +0 -1
  177. package/dist/cli/workspace/workspace-lock.d.ts +0 -1
  178. package/dist/cli/workspace.d.ts +0 -2
  179. package/dist/css-imports-BbrbluP9.js +0 -177
  180. package/dist/css-imports-CSdPq_Sc.mjs +0 -128
  181. package/dist/experimental/index.d.ts +0 -2
  182. package/dist/experimental/oxc/ast-utils.d.ts +0 -30
  183. package/dist/experimental/oxc/index.d.ts +0 -2
  184. package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
  185. package/dist/experimental/shared/cache.d.ts +0 -3
  186. package/dist/experimental/shared/transform.d.ts +0 -3
  187. package/dist/experimental/shared.d.ts +0 -8
  188. package/dist/experimental/swc/ast-utils.d.ts +0 -30
  189. package/dist/experimental/swc/index.d.ts +0 -2
  190. package/dist/experimental/swc/module-specifiers.d.ts +0 -2
  191. package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
  192. package/dist/generator-css-B5ejWUMv.mjs +0 -1098
  193. package/dist/generator-css-D3OdPRiS.js +0 -1125
  194. package/dist/generator-mmhXzZnv.js +0 -1276
  195. package/dist/js/syntax.d.ts +0 -10
  196. package/dist/lightningcss/index.d.ts +0 -8
  197. package/dist/lightningcss/style-handler/options.d.ts +0 -3
  198. package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
  199. package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
  200. package/dist/lightningcss/style-handler.d.ts +0 -17
  201. package/dist/loader-anchors-CNkWT8hx.js +0 -273
  202. package/dist/loader-anchors-TrU7EUr7.mjs +0 -205
  203. package/dist/logger-BZ45DZJT.js +0 -1003
  204. package/dist/logger-BoVx1Dbt.mjs +0 -935
  205. package/dist/patcher-options-6gJN2EXy.js +0 -115
  206. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  207. package/dist/tailwindcss/recorder.d.ts +0 -13
  208. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  209. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  210. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  211. package/dist/tailwindcss/targets/types.d.ts +0 -35
  212. package/dist/types/disabled-options.d.ts +0 -4
  213. package/dist/vite-BC9U7ahn.js +0 -2199
  214. package/dist/webpack-Bu6M-Hbw.mjs +0 -441
  215. package/dist/webpack-DD7A6V0u.js +0 -456
  216. package/dist/webpack4.d.ts +0 -4
  217. package/dist/webpack4.js +0 -387
  218. package/dist/webpack4.mjs +0 -379
  219. package/scripts/postinstall.mjs +0 -59
  220. /package/dist/{constants-B-_T5UnW.mjs → constants-BG12WAKw.mjs} +0 -0
  221. /package/dist/{constants-p1dyh1x1.js → constants-BeeyfJ9k.js} +0 -0
package/README.md CHANGED
@@ -15,7 +15,6 @@
15
15
 
16
16
  ![star](https://badgen.net/github/stars/sonofmagic/weapp-tailwindcss)
17
17
  ![dm0](https://badgen.net/npm/dm/weapp-tailwindcss)
18
- ![dm1](https://badgen.net/npm/dm/weapp-tailwindcss-webpack-plugin)
19
18
  ![license](https://badgen.net/npm/license/weapp-tailwindcss)
20
19
  [![test](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml)
21
20
  [![codecov](https://codecov.io/gh/sonofmagic/weapp-tailwindcss/branch/main/graph/badge.svg?token=zn05qXYznt)](https://codecov.io/gh/sonofmagic/weapp-tailwindcss)
@@ -55,12 +54,12 @@
55
54
 
56
55
  ## 版本对应
57
56
 
58
- 目前,`weapp-tailwindcss` 的 `4.x` 版本
57
+ 目前,`weapp-tailwindcss` 的 `5.x` 版本
59
58
 
60
- - 支持最新版本的 `tailwindcss v4` 和 `v3` 还有 `v2 jit` 版本。
61
- - 支持 `webpack5`,`webpack4`, `vite` 和 `gulp` 这些打包工具,也支持纯 `Nodejs` API 的方式,集成到你自己的构建工具中。
59
+ - 支持最新版本的 `tailwindcss v4` 和 `v3`。
60
+ - 支持 `webpack5`、`vite`、`rspack`、`rollup`、`rolldown` 和 `gulp` 这些打包工具,也支持纯 `Nodejs` API 的方式,集成到你自己的构建工具中。
62
61
 
63
- > 如果你还在使用 `tailwindcss@2` 版本,那你应该使用从 `weapp-tailwindcss/webpack4` 导出的本插件的 `postcss7` `webpack4` 版本。另外请确保你的 `nodejs` 版本 `>=16.6.0`。目前低于 `16` 的长期维护版本(`偶数版本`) 都已经结束了生命周期,建议安装 `nodejs` 的 `LTS` 版本,详见 [nodejs/release](https://github.com/nodejs/release)
62
+ > `weapp-tailwindcss@5` 面向 Tailwind CSS v3/v4 和现代构建链路,不再内置 Webpack4、PostCSS7、Tailwind CSS v2 兼容入口。`weapp-tailwindcss@5` 需要 `nodejs` 版本 `^20.19.0 || >=22.12.0`,建议安装 `nodejs` 的 `LTS` 版本,详见 [nodejs/release](https://github.com/nodejs/release)
64
63
 
65
64
  ## [安装与使用方式](https://tw.icebreaker.top/docs/quick-start/install)
66
65
 
@@ -74,9 +73,9 @@
74
73
 
75
74
  ## [配置项参考](https://tw.icebreaker.top/docs/api/interfaces/UserDefinedOptions)
76
75
 
77
- ### Tailwind CSS v4 自动前缀
76
+ ### Tailwind CSS 自动前缀
78
77
 
79
- 在 Tailwind CSS v4 场景下,`weapp-tailwindcss` 会默认对生成后的小程序 CSS 执行内置 `autoprefixer` 后处理,用于补齐小程序 WebView 需要的兼容前缀。例如 `bg-clip-text` 会输出 `-webkit-background-clip: text`,从而支持渐变文字。
78
+ 在 Tailwind CSS v3 / v4 场景下,`weapp-tailwindcss` 会默认对生成后的小程序 CSS 执行内置 `autoprefixer` 后处理,用于补齐小程序 WebView 需要的兼容前缀。例如 `bg-clip-text` 会输出 `-webkit-background-clip: text`,从而支持渐变文字。
80
79
 
81
80
  通常不再需要在业务项目的 `postcss.config.js` 中手动配置 `autoprefixer`。如果项目已经显式配置了 `autoprefixer`,内置后处理会避免重复追加。需要关闭时可配置:
82
81
 
@@ -1,28 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require('node:fs')
3
3
  const path = require('node:path')
4
- const process = require('node:process')
5
-
6
- function isInstallLifecycle() {
7
- return process.env.npm_lifecycle_event === 'postinstall' || process.env.npm_lifecycle_event === 'prepare'
8
- }
9
-
10
- function isMissingRuntimeModuleError(error) {
11
- return error && error.code === 'MODULE_NOT_FOUND'
12
- }
13
4
 
14
5
  const cliPath = path.resolve(__dirname, '../dist/cli.js')
15
6
  if (fs.existsSync(cliPath)) {
16
- try {
17
- require(cliPath)
18
- }
19
- catch (error) {
20
- if (isInstallLifecycle() && isMissingRuntimeModuleError(error)) {
21
- console.error('[weapp-tailwindcss] install lifecycle patch skipped because a runtime module is missing.')
22
- console.error('Run `pnpm --filter weapp-tailwindcss build` before strict CLI validation.')
23
- }
24
- else {
25
- throw error
26
- }
27
- }
7
+ require(cliPath)
28
8
  }
@@ -0,0 +1,530 @@
1
+ const require_chunk = require("./chunk-8l464Juk.js");
2
+ const require_precheck = require("./precheck-8pQbjqpq.js");
3
+ let node_module = require("node:module");
4
+ let node_path = require("node:path");
5
+ node_path = require_chunk.__toESM(node_path);
6
+ let node_process = require("node:process");
7
+ node_process = require_chunk.__toESM(node_process);
8
+ let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
9
+ let node_buffer = require("node:buffer");
10
+ let htmlparser2 = require("htmlparser2");
11
+ //#region src/bundlers/shared/module-graph.ts
12
+ const QUERY_HASH_RE = /[?#].*$/u;
13
+ const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
14
+ const WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
15
+ const VIRTUAL_PREFIX = "\0";
16
+ const JS_EXTENSIONS = [
17
+ ".js",
18
+ ".mjs",
19
+ ".cjs"
20
+ ];
21
+ function normalizeOutputPathKey(value) {
22
+ return node_path.default.normalize(value).replace(/\\/g, "/");
23
+ }
24
+ function stripQueryAndHash(specifier) {
25
+ return specifier.replace(QUERY_HASH_RE, "");
26
+ }
27
+ function isResolvableSpecifier(specifier) {
28
+ if (!specifier) return false;
29
+ const normalized = stripQueryAndHash(specifier);
30
+ if (normalized.startsWith(VIRTUAL_PREFIX)) return false;
31
+ if (node_path.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) return true;
32
+ return !PROTOCOL_RE.test(normalized);
33
+ }
34
+ function toAbsoluteOutputPath(fileName, outDir) {
35
+ if (node_path.default.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) return node_path.default.normalize(fileName);
36
+ return node_path.default.resolve(outDir, fileName);
37
+ }
38
+ function matchWithExtensions(candidate, hasOutput) {
39
+ if (hasOutput(candidate)) return candidate;
40
+ if (!node_path.default.extname(candidate)) for (const ext of JS_EXTENSIONS) {
41
+ const extended = `${candidate}${ext}`;
42
+ if (hasOutput(extended)) return extended;
43
+ }
44
+ }
45
+ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
46
+ if (!isResolvableSpecifier(specifier)) return;
47
+ const normalized = stripQueryAndHash(specifier);
48
+ let candidate;
49
+ if (node_path.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) candidate = node_path.default.normalize(normalized);
50
+ else if (normalized.startsWith("/")) candidate = node_path.default.resolve(outDir, normalized.slice(1));
51
+ else candidate = node_path.default.resolve(node_path.default.dirname(importer), normalized);
52
+ return matchWithExtensions(candidate, hasOutput);
53
+ }
54
+ //#endregion
55
+ //#region src/bundlers/shared/style-requests.ts
56
+ const SOURCE_STYLE_EXT_RE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)$/i;
57
+ const STYLE_QUERY_RE = /(?:^|&)type=styles?(?:&|$)/;
58
+ const STYLE_LANG_QUERY_RE = /(?:^|&)lang(?:[.=](?:css|scss|sass|less|styl|stylus|pcss|postcss))?(?:&|$)/;
59
+ function stripHash(request) {
60
+ const hashIndex = request.indexOf("#");
61
+ return hashIndex === -1 ? request : request.slice(0, hashIndex);
62
+ }
63
+ function stripRequestQuery(request) {
64
+ const normalized = stripHash(request);
65
+ const queryIndex = normalized.indexOf("?");
66
+ return queryIndex === -1 ? normalized : normalized.slice(0, queryIndex);
67
+ }
68
+ function isSourceStyleRequest(request) {
69
+ if (typeof request !== "string" || request.length === 0) return false;
70
+ const normalized = stripHash(request);
71
+ const queryIndex = normalized.indexOf("?");
72
+ const pathname = queryIndex === -1 ? normalized : normalized.slice(0, queryIndex);
73
+ if (SOURCE_STYLE_EXT_RE.test(pathname)) return true;
74
+ if (queryIndex === -1) return false;
75
+ const query = normalized.slice(queryIndex + 1);
76
+ return STYLE_QUERY_RE.test(query) || STYLE_LANG_QUERY_RE.test(query);
77
+ }
78
+ //#endregion
79
+ //#region src/bundlers/vite/utils.ts
80
+ function slash(p) {
81
+ return (0, _weapp_tailwindcss_shared.ensurePosix)(p);
82
+ }
83
+ const isWindows = node_process.default.platform === "win32";
84
+ const cssLangRE = new RegExp(`\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`);
85
+ function isCSSRequest(request) {
86
+ return cssLangRE.test(request) || isSourceStyleRequest(request);
87
+ }
88
+ function normalizePath(id) {
89
+ return node_path.default.posix.normalize(isWindows ? (0, _weapp_tailwindcss_shared.ensurePosix)(id) : id);
90
+ }
91
+ async function formatPostcssSourceMap(rawMap, file) {
92
+ const inputFileDir = node_path.default.dirname(file);
93
+ const sources = rawMap.sources.map((source) => {
94
+ const cleanSource = (0, _weapp_tailwindcss_shared.cleanUrl)(decodeURIComponent(source));
95
+ if (cleanSource[0] === "<" && cleanSource.endsWith(">")) return `\0${cleanSource}`;
96
+ return normalizePath(node_path.default.resolve(inputFileDir, cleanSource));
97
+ });
98
+ return {
99
+ file,
100
+ mappings: rawMap.mappings,
101
+ names: rawMap.names,
102
+ sources,
103
+ sourcesContent: rawMap.sourcesContent,
104
+ version: rawMap.version
105
+ };
106
+ }
107
+ //#endregion
108
+ //#region src/utils/disabled.ts
109
+ function resolvePluginDisabledState(disabled) {
110
+ if (disabled === true) return { plugin: true };
111
+ if (disabled === false || disabled == null) return { plugin: false };
112
+ return { plugin: disabled.plugin ?? false };
113
+ }
114
+ //#endregion
115
+ //#region src/utils/resolve-package.ts
116
+ const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
117
+ function resolvePackageDir(name) {
118
+ const pkgPath = require$1.resolve(`${name}/package.json`);
119
+ return node_path.default.dirname(pkgPath);
120
+ }
121
+ //#endregion
122
+ //#region src/bundlers/shared/generated-css-marker.ts
123
+ const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/i;
124
+ const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/gi;
125
+ function createBundlerGeneratedCssMarker(bundler, file) {
126
+ return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
127
+ }
128
+ function hasBundlerGeneratedCssMarker(source) {
129
+ return typeof source === "string" && BUNDLER_GENERATED_CSS_MARKER_RE.test(source);
130
+ }
131
+ function stripBundlerGeneratedCssMarkers(source) {
132
+ return source.replace(BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE, "");
133
+ }
134
+ //#endregion
135
+ //#region src/bundlers/shared/run-tasks.ts
136
+ async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
137
+ if (factories.length === 0) return [];
138
+ const results = Array.from({ length: factories.length });
139
+ const executing = /* @__PURE__ */ new Set();
140
+ let cursor = 0;
141
+ const effectiveLimit = Math.max(1, limit);
142
+ const scheduleNext = () => {
143
+ if (cursor >= factories.length) return;
144
+ const currentIndex = cursor++;
145
+ const factory = factories[currentIndex];
146
+ if (!factory) return;
147
+ const wrapped = Promise.resolve(factory()).then((value) => {
148
+ results[currentIndex] = value;
149
+ }).finally(() => {
150
+ executing.delete(wrapped);
151
+ });
152
+ executing.add(wrapped);
153
+ };
154
+ while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
155
+ while (cursor < factories.length) {
156
+ await Promise.race(executing);
157
+ scheduleNext();
158
+ }
159
+ await Promise.all(executing);
160
+ return results;
161
+ }
162
+ function pushConcurrentTaskFactories(queue, factories, limit) {
163
+ if (factories.length === 0) return;
164
+ queue.push(runWithConcurrency(factories, limit).then(() => void 0));
165
+ }
166
+ //#endregion
167
+ //#region src/bundlers/vite/bundle-entries.ts
168
+ function readOutputEntry(entry) {
169
+ if (entry.output.type === "chunk") return entry.output.code;
170
+ const source = entry.output.source;
171
+ if (typeof source === "string") return source;
172
+ if (source instanceof Uint8Array) return node_buffer.Buffer.from(source).toString();
173
+ const fallbackSource = source;
174
+ if (fallbackSource == null) return;
175
+ if (typeof fallbackSource.toString === "function") return fallbackSource.toString();
176
+ }
177
+ function isJavaScriptEntry(entry) {
178
+ if (entry.output.type === "chunk") return true;
179
+ return entry.fileName.endsWith(".js");
180
+ }
181
+ function createBundleModuleGraphOptions(outputDir, entries) {
182
+ const normalizedEntries = /* @__PURE__ */ new Map();
183
+ for (const [id, entry] of entries) normalizedEntries.set(normalizeOutputPathKey(id), entry);
184
+ const getEntry = (id) => entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
185
+ return {
186
+ resolve(specifier, importer) {
187
+ return resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => Boolean(getEntry(candidate)));
188
+ },
189
+ load(id) {
190
+ const entry = getEntry(id);
191
+ if (!entry) return;
192
+ return readOutputEntry(entry);
193
+ },
194
+ filter(id) {
195
+ return Boolean(getEntry(id));
196
+ }
197
+ };
198
+ }
199
+ function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
200
+ if (!linked) return;
201
+ const normalizedEntries = /* @__PURE__ */ new Map();
202
+ for (const [entryId, entry] of entries) normalizedEntries.set(normalizeOutputPathKey(entryId), entry);
203
+ for (const [id, { code }] of Object.entries(linked)) {
204
+ const entry = entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
205
+ if (!entry) continue;
206
+ const previous = readOutputEntry(entry);
207
+ if (previous == null || previous === code) continue;
208
+ if (entry.output.type === "chunk") entry.output.code = code;
209
+ else entry.output.source = code;
210
+ onApplied?.(entry, code);
211
+ onLinkedUpdate(entry.fileName, previous, code);
212
+ }
213
+ }
214
+ //#endregion
215
+ //#region src/bundlers/vite/runtime-affecting-signature.ts
216
+ const CSS_BLOCK_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
217
+ const CSS_AROUND_PUNCTUATION_RE = /\s*([{}:;,>+~()])\s*/g;
218
+ const CSS_TRAILING_DECLARATION_SEMICOLON_RE = /;\}/g;
219
+ const CSS_WHITESPACE_RE = /\s+/g;
220
+ function createHtmlRuntimeAffectingSignature(source) {
221
+ try {
222
+ const parts = [];
223
+ const parser = new htmlparser2.Parser({
224
+ onattribute(name, value) {
225
+ parts.push(`a:${name}=${value}`);
226
+ },
227
+ oncomment(data) {
228
+ parts.push(`c:${data}`);
229
+ },
230
+ ontext(data) {
231
+ const value = data.trim();
232
+ if (value.length > 0) parts.push(`t:${value}`);
233
+ }
234
+ }, { xmlMode: true });
235
+ parser.write(source);
236
+ parser.end();
237
+ return parts.join("\n");
238
+ } catch {
239
+ return source;
240
+ }
241
+ }
242
+ function createJsRuntimeAffectingSignature(source) {
243
+ try {
244
+ const ast = require_precheck.babelParse(source, {
245
+ cache: true,
246
+ cacheKey: "vite-runtime-affecting:unambiguous",
247
+ plugins: ["jsx", "typescript"],
248
+ sourceType: "unambiguous"
249
+ });
250
+ const parts = [];
251
+ require_precheck.traverse(ast, {
252
+ noScope: true,
253
+ StringLiteral(path) {
254
+ parts.push(`s:${path.node.value}`);
255
+ },
256
+ TemplateElement(path) {
257
+ parts.push(`t:${path.node.value.raw}`);
258
+ },
259
+ JSXText(path) {
260
+ const value = path.node.value.trim();
261
+ if (value.length > 0) parts.push(`x:${value}`);
262
+ }
263
+ });
264
+ const comments = ast.comments;
265
+ if (Array.isArray(comments)) {
266
+ for (const comment of comments) if (typeof comment?.value === "string" && comment.value.length > 0) parts.push(`c:${comment.value}`);
267
+ }
268
+ return parts.join("\n");
269
+ } catch {
270
+ return source;
271
+ }
272
+ }
273
+ function createCssRuntimeAffectingSignature(source) {
274
+ return source.replace(CSS_BLOCK_COMMENT_RE, "").replace(CSS_AROUND_PUNCTUATION_RE, "$1").replace(CSS_TRAILING_DECLARATION_SEMICOLON_RE, "}").replace(CSS_WHITESPACE_RE, " ").trim();
275
+ }
276
+ function createRuntimeAffectingSourceSignature(source, type) {
277
+ if (type === "html") return createHtmlRuntimeAffectingSignature(source);
278
+ if (type === "js") return createJsRuntimeAffectingSignature(source);
279
+ if (type === "css") return createCssRuntimeAffectingSignature(source);
280
+ return source;
281
+ }
282
+ //#endregion
283
+ //#region src/bundlers/vite/bundle-state.ts
284
+ function createBundleBuildState() {
285
+ return {
286
+ iteration: 0,
287
+ sourceHashByFile: /* @__PURE__ */ new Map(),
288
+ runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
289
+ runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
290
+ linkedByEntry: /* @__PURE__ */ new Map(),
291
+ dependentsByLinkedFile: /* @__PURE__ */ new Map(),
292
+ generatorCandidateSignature: void 0
293
+ };
294
+ }
295
+ function createChangedByType() {
296
+ return {
297
+ html: /* @__PURE__ */ new Set(),
298
+ js: /* @__PURE__ */ new Set(),
299
+ css: /* @__PURE__ */ new Set(),
300
+ other: /* @__PURE__ */ new Set()
301
+ };
302
+ }
303
+ function createProcessFiles() {
304
+ return {
305
+ html: /* @__PURE__ */ new Set(),
306
+ js: /* @__PURE__ */ new Set(),
307
+ css: /* @__PURE__ */ new Set()
308
+ };
309
+ }
310
+ function readEntrySource(output) {
311
+ if (output.type === "chunk") return output.code;
312
+ return output.source.toString();
313
+ }
314
+ function classifyBundleEntry(file, opts) {
315
+ if (opts.cssMatcher(file) || isCSSRequest(file)) return "css";
316
+ if (opts.htmlMatcher(file)) return "html";
317
+ if (opts.jsMatcher(file) || opts.wxsMatcher(file)) return "js";
318
+ return "other";
319
+ }
320
+ function collectJsEntries(fileName, output, outDir, store) {
321
+ const entry = {
322
+ fileName,
323
+ output
324
+ };
325
+ if (!isJavaScriptEntry(entry)) return;
326
+ const absolute = toAbsoluteOutputPath(fileName, outDir);
327
+ store.set(absolute, entry);
328
+ }
329
+ function markProcessFile(type, file, processFiles) {
330
+ if (type === "html" || type === "js" || type === "css") processFiles[type].add(file);
331
+ }
332
+ function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false) {
333
+ const sourceHashByFile = /* @__PURE__ */ new Map();
334
+ const runtimeAffectingSignatureByFile = /* @__PURE__ */ new Map();
335
+ const runtimeAffectingHashByFile = /* @__PURE__ */ new Map();
336
+ const changedByType = createChangedByType();
337
+ const runtimeAffectingChangedByType = createChangedByType();
338
+ const processFiles = createProcessFiles();
339
+ const linkedImpactsByEntry = /* @__PURE__ */ new Map();
340
+ const jsEntries = /* @__PURE__ */ new Map();
341
+ const entries = [];
342
+ const firstRun = state.linkedByEntry.size === 0;
343
+ for (const [file, output] of Object.entries(bundle)) {
344
+ const type = classifyBundleEntry(file, opts);
345
+ const source = readEntrySource(output);
346
+ const hash = opts.cache.computeHash(source);
347
+ sourceHashByFile.set(file, hash);
348
+ const previousHash = state.sourceHashByFile.get(file);
349
+ const changed = previousHash == null || previousHash !== hash;
350
+ const previousRuntimeAffectingSignature = state.runtimeAffectingSignatureByFile.get(file);
351
+ const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
352
+ const canReuseRuntimeAffectingSignature = !changed && previousRuntimeAffectingSignature != null && previousRuntimeAffectingHash != null;
353
+ const runtimeAffectingSignature = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingSignature : createRuntimeAffectingSourceSignature(source, type);
354
+ const runtimeAffectingHash = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingHash : opts.cache.computeHash(runtimeAffectingSignature);
355
+ runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
356
+ runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
357
+ if (changed) changedByType[type].add(file);
358
+ if (previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash) runtimeAffectingChangedByType[type].add(file);
359
+ if (forceAll || firstRun) markProcessFile(type, file, processFiles);
360
+ else if (type === "html") processFiles.html.add(file);
361
+ else if (changed && (type === "js" || type === "css")) processFiles[type].add(file);
362
+ collectJsEntries(file, output, outDir, jsEntries);
363
+ entries.push({
364
+ file,
365
+ output,
366
+ source,
367
+ type
368
+ });
369
+ }
370
+ if (!forceAll && !firstRun) for (const changedFile of changedByType.js) {
371
+ const dependents = state.dependentsByLinkedFile.get(changedFile);
372
+ if (!dependents) continue;
373
+ for (const entryFile of dependents) {
374
+ processFiles.js.add(entryFile);
375
+ let impacts = linkedImpactsByEntry.get(entryFile);
376
+ if (!impacts) {
377
+ impacts = /* @__PURE__ */ new Set();
378
+ linkedImpactsByEntry.set(entryFile, impacts);
379
+ }
380
+ impacts.add(changedFile);
381
+ }
382
+ }
383
+ return {
384
+ entries,
385
+ jsEntries,
386
+ sourceHashByFile,
387
+ runtimeAffectingSignatureByFile,
388
+ runtimeAffectingHashByFile,
389
+ changedByType,
390
+ runtimeAffectingChangedByType,
391
+ processFiles,
392
+ linkedImpactsByEntry
393
+ };
394
+ }
395
+ function invertLinkedByEntry(linkedByEntry) {
396
+ const dependentsByLinkedFile = /* @__PURE__ */ new Map();
397
+ for (const [entryFile, linkedFiles] of linkedByEntry.entries()) for (const linkedFile of linkedFiles) {
398
+ let dependents = dependentsByLinkedFile.get(linkedFile);
399
+ if (!dependents) {
400
+ dependents = /* @__PURE__ */ new Set();
401
+ dependentsByLinkedFile.set(linkedFile, dependents);
402
+ }
403
+ dependents.add(entryFile);
404
+ }
405
+ return dependentsByLinkedFile;
406
+ }
407
+ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
408
+ const incremental = options.incremental === true;
409
+ state.iteration += 1;
410
+ state.sourceHashByFile = incremental ? new Map([...state.sourceHashByFile, ...snapshot.sourceHashByFile]) : snapshot.sourceHashByFile;
411
+ state.runtimeAffectingSignatureByFile = incremental ? new Map([...state.runtimeAffectingSignatureByFile, ...snapshot.runtimeAffectingSignatureByFile]) : snapshot.runtimeAffectingSignatureByFile;
412
+ state.runtimeAffectingHashByFile = incremental ? new Map([...state.runtimeAffectingHashByFile, ...snapshot.runtimeAffectingHashByFile]) : snapshot.runtimeAffectingHashByFile;
413
+ state.linkedByEntry = incremental ? new Map([...state.linkedByEntry, ...linkedByEntry]) : linkedByEntry;
414
+ state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
415
+ }
416
+ //#endregion
417
+ Object.defineProperty(exports, "applyLinkedResults", {
418
+ enumerable: true,
419
+ get: function() {
420
+ return applyLinkedResults;
421
+ }
422
+ });
423
+ Object.defineProperty(exports, "buildBundleSnapshot", {
424
+ enumerable: true,
425
+ get: function() {
426
+ return buildBundleSnapshot;
427
+ }
428
+ });
429
+ Object.defineProperty(exports, "createBundleBuildState", {
430
+ enumerable: true,
431
+ get: function() {
432
+ return createBundleBuildState;
433
+ }
434
+ });
435
+ Object.defineProperty(exports, "createBundleModuleGraphOptions", {
436
+ enumerable: true,
437
+ get: function() {
438
+ return createBundleModuleGraphOptions;
439
+ }
440
+ });
441
+ Object.defineProperty(exports, "createBundlerGeneratedCssMarker", {
442
+ enumerable: true,
443
+ get: function() {
444
+ return createBundlerGeneratedCssMarker;
445
+ }
446
+ });
447
+ Object.defineProperty(exports, "formatPostcssSourceMap", {
448
+ enumerable: true,
449
+ get: function() {
450
+ return formatPostcssSourceMap;
451
+ }
452
+ });
453
+ Object.defineProperty(exports, "hasBundlerGeneratedCssMarker", {
454
+ enumerable: true,
455
+ get: function() {
456
+ return hasBundlerGeneratedCssMarker;
457
+ }
458
+ });
459
+ Object.defineProperty(exports, "isCSSRequest", {
460
+ enumerable: true,
461
+ get: function() {
462
+ return isCSSRequest;
463
+ }
464
+ });
465
+ Object.defineProperty(exports, "isSourceStyleRequest", {
466
+ enumerable: true,
467
+ get: function() {
468
+ return isSourceStyleRequest;
469
+ }
470
+ });
471
+ Object.defineProperty(exports, "normalizeOutputPathKey", {
472
+ enumerable: true,
473
+ get: function() {
474
+ return normalizeOutputPathKey;
475
+ }
476
+ });
477
+ Object.defineProperty(exports, "pushConcurrentTaskFactories", {
478
+ enumerable: true,
479
+ get: function() {
480
+ return pushConcurrentTaskFactories;
481
+ }
482
+ });
483
+ Object.defineProperty(exports, "resolveOutputSpecifier", {
484
+ enumerable: true,
485
+ get: function() {
486
+ return resolveOutputSpecifier;
487
+ }
488
+ });
489
+ Object.defineProperty(exports, "resolvePackageDir", {
490
+ enumerable: true,
491
+ get: function() {
492
+ return resolvePackageDir;
493
+ }
494
+ });
495
+ Object.defineProperty(exports, "resolvePluginDisabledState", {
496
+ enumerable: true,
497
+ get: function() {
498
+ return resolvePluginDisabledState;
499
+ }
500
+ });
501
+ Object.defineProperty(exports, "slash", {
502
+ enumerable: true,
503
+ get: function() {
504
+ return slash;
505
+ }
506
+ });
507
+ Object.defineProperty(exports, "stripBundlerGeneratedCssMarkers", {
508
+ enumerable: true,
509
+ get: function() {
510
+ return stripBundlerGeneratedCssMarkers;
511
+ }
512
+ });
513
+ Object.defineProperty(exports, "stripRequestQuery", {
514
+ enumerable: true,
515
+ get: function() {
516
+ return stripRequestQuery;
517
+ }
518
+ });
519
+ Object.defineProperty(exports, "toAbsoluteOutputPath", {
520
+ enumerable: true,
521
+ get: function() {
522
+ return toAbsoluteOutputPath;
523
+ }
524
+ });
525
+ Object.defineProperty(exports, "updateBundleBuildState", {
526
+ enumerable: true,
527
+ get: function() {
528
+ return updateBundleBuildState;
529
+ }
530
+ });