weapp-tailwindcss 5.0.0-next.3 → 5.0.0-next.30

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 (243) hide show
  1. package/README.md +6 -7
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/auto-TH1jG2UW.js +115 -0
  4. package/dist/auto-XyKTOP7B.mjs +78 -0
  5. package/dist/bundle-state-Bi-cQua6.mjs +413 -0
  6. package/dist/bundle-state-Ct_8GcSR.js +529 -0
  7. package/dist/bundlers/shared/cache.d.ts +6 -6
  8. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -0
  9. package/dist/bundlers/shared/css-cleanup.d.ts +1 -4
  10. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  11. package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
  12. package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
  13. package/dist/bundlers/shared/generator-css/directives.d.ts +20 -0
  14. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
  15. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
  16. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
  17. package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
  18. package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
  19. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
  20. package/dist/bundlers/shared/generator-css.d.ts +16 -22
  21. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  22. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  23. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  24. package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
  25. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  26. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
  27. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
  28. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  29. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  30. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  31. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  32. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  33. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  34. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  35. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  36. package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
  37. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
  38. package/dist/bundlers/vite/index.d.ts +5 -2
  39. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  40. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  41. package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
  42. package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
  43. package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
  44. package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
  45. package/dist/bundlers/vite/source-candidates.d.ts +19 -1
  46. package/dist/bundlers/vite/source-scan.d.ts +26 -0
  47. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  48. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  49. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
  50. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
  51. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
  52. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +2 -1
  53. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
  54. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
  55. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
  56. package/dist/cache/index.d.ts +6 -6
  57. package/dist/{chunk-8l464Juk.js → chunk-C5U5_Hdc.js} +14 -0
  58. package/dist/cli/context.d.ts +1 -14
  59. package/dist/cli/doctor/types.d.ts +11 -11
  60. package/dist/cli/helpers.d.ts +1 -2
  61. package/dist/cli/mount-options.d.ts +2 -0
  62. package/dist/cli/types.d.ts +0 -2
  63. package/dist/cli/vscode-entry.d.ts +3 -3
  64. package/dist/cli.js +758 -604
  65. package/dist/cli.mjs +766 -612
  66. package/dist/constants.d.ts +1 -2
  67. package/dist/context/runtime-package-replacements.d.ts +2 -0
  68. package/dist/context/style-options.d.ts +3 -0
  69. package/dist/core.js +12 -20
  70. package/dist/core.mjs +8 -14
  71. package/dist/css-macro/auto.d.ts +10 -0
  72. package/dist/css-macro/constants.d.ts +5 -2
  73. package/dist/css-macro/postcss.d.ts +1 -0
  74. package/dist/css-macro/postcss.js +7 -46
  75. package/dist/css-macro/postcss.mjs +2 -46
  76. package/dist/css-macro.d.ts +1 -0
  77. package/dist/css-macro.js +16 -7
  78. package/dist/css-macro.mjs +15 -6
  79. package/dist/defaults-8xrgzxFY.mjs +151 -0
  80. package/dist/defaults-zKUH2mDe.js +193 -0
  81. package/dist/defaults.d.ts +15 -1
  82. package/dist/defaults.js +6 -131
  83. package/dist/defaults.mjs +2 -129
  84. package/dist/escape.js +10 -2
  85. package/dist/escape.mjs +10 -2
  86. package/dist/generator/index.d.ts +1 -1
  87. package/dist/generator/options.d.ts +9 -8
  88. package/dist/generator/types.d.ts +3 -3
  89. package/dist/generator-CrU-Ghc1.js +90 -0
  90. package/dist/generator-Qw-tZ0Z2.mjs +65 -0
  91. package/dist/generator.js +12 -12
  92. package/dist/generator.mjs +2 -1
  93. package/dist/gulp.js +187 -48
  94. package/dist/gulp.mjs +180 -41
  95. package/dist/incremental-runtime-class-set-BdZHkoTs.mjs +1975 -0
  96. package/dist/incremental-runtime-class-set-BxvZONkv.js +2038 -0
  97. package/dist/index.d.ts +3 -2
  98. package/dist/index.js +19 -7
  99. package/dist/index.mjs +6 -5
  100. package/dist/js/babel/cache-options.d.ts +3 -0
  101. package/dist/js/babel/parse.d.ts +7 -4
  102. package/dist/js/index.d.ts +1 -0
  103. package/dist/js/literal-transform.d.ts +2 -0
  104. package/dist/js/precheck.d.ts +2 -2
  105. package/dist/logger-BNzxZbZj.mjs +2 -0
  106. package/dist/logger-TlKT3xmR.js +1 -0
  107. package/dist/postcss/config-directive.d.ts +1 -0
  108. package/dist/postcss/context.d.ts +9 -0
  109. package/dist/postcss/source-files.d.ts +8 -0
  110. package/dist/postcss/tailwind-version.d.ts +3 -0
  111. package/dist/postcss-C6zOQqlL.mjs +228 -0
  112. package/dist/postcss-C7BMYpEF.mjs +169 -0
  113. package/dist/postcss-CiYLsqZn.js +192 -0
  114. package/dist/postcss-DAWf9D3C.js +237 -0
  115. package/dist/postcss-html-transform.js +1 -1
  116. package/dist/postcss.d.ts +2 -2
  117. package/dist/postcss.js +3 -276
  118. package/dist/postcss.mjs +1 -269
  119. package/dist/precheck-D7K12zeX.mjs +4716 -0
  120. package/dist/precheck-D7gJSmJz.js +4842 -0
  121. package/dist/presets/index.d.ts +1 -0
  122. package/dist/presets/uni-app-x.d.ts +1 -0
  123. package/dist/presets.js +29 -13
  124. package/dist/presets.mjs +25 -11
  125. package/dist/reset.d.ts +1 -0
  126. package/dist/reset.js +1 -1
  127. package/dist/runtime-registry-DpcR3IHI.js +5496 -0
  128. package/dist/shared/mpx.d.ts +1 -0
  129. package/dist/source-candidates-CX2ozpKM.mjs +322 -0
  130. package/dist/source-candidates-DNM8iwXW.js +335 -0
  131. package/dist/tailwindcss/miniprogram.d.ts +1 -1
  132. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  133. package/dist/tailwindcss/patcher.d.ts +1 -2
  134. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
  135. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  136. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  137. package/dist/tailwindcss/runtime.d.ts +11 -12
  138. package/dist/tailwindcss/source-scan.d.ts +35 -0
  139. package/dist/tailwindcss/targets.d.ts +1 -5
  140. package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
  141. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  142. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  143. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  144. package/dist/tailwindcss/v4/patcher.d.ts +1 -0
  145. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  146. package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
  147. package/dist/tailwindcss/version.d.ts +4 -0
  148. package/dist/tailwindcss-B-e2RiXr.js +642 -0
  149. package/dist/tailwindcss-C7dJHZ0G.mjs +591 -0
  150. package/dist/typedoc.export.d.ts +0 -2
  151. package/dist/types/index.d.ts +52 -49
  152. package/dist/types/shared.d.ts +6 -0
  153. package/dist/types/user-defined-options/general.d.ts +25 -24
  154. package/dist/types/user-defined-options/important.d.ts +33 -28
  155. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  156. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  157. package/dist/uni-app-x/vite.d.ts +1 -1
  158. package/dist/unocss/index.d.ts +2 -0
  159. package/dist/utils/disabled.d.ts +2 -3
  160. package/dist/utils/object.d.ts +9 -0
  161. package/dist/utils/options.d.ts +2 -0
  162. package/dist/utils/regex.d.ts +1 -0
  163. package/dist/{utils-DmC9_In3.js → utils-D7Ygohep.js} +2 -2
  164. package/dist/{utils-7DUGTFED.mjs → utils-DsaS975I.mjs} +1 -1
  165. package/dist/v3-engine-CHItlVq5.js +3616 -0
  166. package/dist/v3-engine-DcvCCHfs.mjs +3321 -0
  167. package/dist/vite-C65DdWEj.js +24439 -0
  168. package/dist/vite-rmL1rsA_.mjs +24425 -0
  169. package/dist/vite.d.ts +1 -2
  170. package/dist/vite.js +3 -4
  171. package/dist/vite.mjs +2 -2
  172. package/dist/weapp-tw-css-import-rewrite-loader.js +5032 -18
  173. package/dist/weapp-tw-runtime-classset-loader.js +32 -9
  174. package/dist/webpack-BU2Er4qg.mjs +841 -0
  175. package/dist/webpack-CqGvjvSQ.js +851 -0
  176. package/dist/webpack.d.ts +1 -3
  177. package/dist/webpack.js +3 -4
  178. package/dist/webpack.mjs +2 -2
  179. package/package.json +38 -48
  180. package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
  181. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
  182. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
  183. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
  184. package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
  185. package/dist/cli/config.d.ts +0 -5
  186. package/dist/cli/helpers/patch-cwd.d.ts +0 -1
  187. package/dist/cli/mount-options/patch-status.d.ts +0 -2
  188. package/dist/cli/patch-options.d.ts +0 -6
  189. package/dist/cli/tokens.d.ts +0 -4
  190. package/dist/cli/workspace/package-dirs.d.ts +0 -3
  191. package/dist/cli/workspace/patch-package.d.ts +0 -3
  192. package/dist/cli/workspace/patch-utils.d.ts +0 -3
  193. package/dist/cli/workspace/types.d.ts +0 -11
  194. package/dist/cli/workspace/workspace-globs.d.ts +0 -2
  195. package/dist/cli/workspace/workspace-io.d.ts +0 -1
  196. package/dist/cli/workspace/workspace-lock.d.ts +0 -1
  197. package/dist/cli/workspace.d.ts +0 -2
  198. package/dist/constants-B-_T5UnW.mjs +0 -44
  199. package/dist/constants-p1dyh1x1.js +0 -73
  200. package/dist/css-imports-BbrbluP9.js +0 -177
  201. package/dist/css-imports-CSdPq_Sc.mjs +0 -128
  202. package/dist/experimental/index.d.ts +0 -2
  203. package/dist/experimental/oxc/ast-utils.d.ts +0 -30
  204. package/dist/experimental/oxc/index.d.ts +0 -2
  205. package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
  206. package/dist/experimental/shared/cache.d.ts +0 -3
  207. package/dist/experimental/shared/transform.d.ts +0 -3
  208. package/dist/experimental/shared.d.ts +0 -8
  209. package/dist/experimental/swc/ast-utils.d.ts +0 -30
  210. package/dist/experimental/swc/index.d.ts +0 -2
  211. package/dist/experimental/swc/module-specifiers.d.ts +0 -2
  212. package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
  213. package/dist/generator-css-Bwy_Uz89.mjs +0 -1097
  214. package/dist/generator-css-CRLrHW4F.js +0 -1124
  215. package/dist/generator-mmhXzZnv.js +0 -1276
  216. package/dist/js/syntax.d.ts +0 -10
  217. package/dist/lightningcss/index.d.ts +0 -8
  218. package/dist/lightningcss/style-handler/options.d.ts +0 -3
  219. package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
  220. package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
  221. package/dist/lightningcss/style-handler.d.ts +0 -17
  222. package/dist/loader-anchors-1MumTAtA.mjs +0 -205
  223. package/dist/loader-anchors-TrFvT6g1.js +0 -273
  224. package/dist/logger-BZ45DZJT.js +0 -1003
  225. package/dist/logger-BoVx1Dbt.mjs +0 -935
  226. package/dist/patcher-options-6gJN2EXy.js +0 -115
  227. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  228. package/dist/recorder-GdTJ3QqX.js +0 -2878
  229. package/dist/recorder-XdFvVASS.mjs +0 -2763
  230. package/dist/tailwindcss/recorder.d.ts +0 -13
  231. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  232. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  233. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  234. package/dist/tailwindcss/targets/types.d.ts +0 -35
  235. package/dist/types/disabled-options.d.ts +0 -4
  236. package/dist/vite-BDywuCjn.mjs +0 -2186
  237. package/dist/vite-DgRh_GXn.js +0 -2199
  238. package/dist/webpack-CAJR4hhP.js +0 -456
  239. package/dist/webpack-CiHqVZTg.mjs +0 -441
  240. package/dist/webpack4.d.ts +0 -4
  241. package/dist/webpack4.js +0 -387
  242. package/dist/webpack4.mjs +0 -379
  243. package/scripts/postinstall.mjs +0 -59
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,115 @@
1
+ const require_chunk = require("./chunk-C5U5_Hdc.js");
2
+ const require_postcss = require("./postcss-CiYLsqZn.js");
3
+ let postcss = require("postcss");
4
+ postcss = require_chunk.__toESM(postcss);
5
+ //#region src/css-macro/auto.ts
6
+ const CSS_MACRO_PLUGIN_MARKER = "__weappTailwindcssCssMacro";
7
+ const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
8
+ function markCssMacroPlugin(value) {
9
+ Object.defineProperty(value, CSS_MACRO_PLUGIN_MARKER, {
10
+ configurable: false,
11
+ enumerable: false,
12
+ value: true
13
+ });
14
+ return value;
15
+ }
16
+ function isCssMacroTailwindPlugin(value) {
17
+ return Boolean(value && (typeof value === "function" || typeof value === "object") && value["__weappTailwindcssCssMacro"] === true);
18
+ }
19
+ function hasCssMacroTailwindPlugin(plugins) {
20
+ if (!plugins) return false;
21
+ if (Array.isArray(plugins)) return plugins.some(isCssMacroTailwindPlugin);
22
+ if (typeof plugins === "object") return Object.values(plugins).some(isCssMacroTailwindPlugin);
23
+ return false;
24
+ }
25
+ function parseCssPluginRequest(params) {
26
+ const value = params.trim();
27
+ const quoted = /^(['"])(.*?)\1/.exec(value);
28
+ if (quoted) return quoted[2];
29
+ const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
30
+ return url?.[2] ?? url?.[3];
31
+ }
32
+ function isCssMacroPluginRequest(request) {
33
+ return request === "weapp-tailwindcss/css-macro";
34
+ }
35
+ function hasCssMacroTailwindV4Directive(css) {
36
+ if (!css?.includes("css-macro")) return false;
37
+ try {
38
+ let found = false;
39
+ postcss.default.parse(css).walkAtRules("plugin", (rule) => {
40
+ if (isCssMacroPluginRequest(parseCssPluginRequest(rule.params))) found = true;
41
+ });
42
+ return found;
43
+ } catch {
44
+ return /@plugin\s+(?:url\(\s*)?["']weapp-tailwindcss\/css-macro["']/.test(css);
45
+ }
46
+ }
47
+ function isCssMacroPostcssPlugin(plugin) {
48
+ if (plugin === require_postcss.creator) return true;
49
+ return Boolean(plugin && (typeof plugin === "function" || typeof plugin === "object") && plugin.postcssPlugin === "postcss-weapp-tw-css-macro-plugin");
50
+ }
51
+ function withCssMacroPostcssPlugins(plugins) {
52
+ const macroPlugin = require_postcss.creator();
53
+ if (!plugins) return [macroPlugin];
54
+ if (Array.isArray(plugins)) return plugins.some(isCssMacroPostcssPlugin) ? plugins : [...plugins, macroPlugin];
55
+ if (typeof plugins === "object") {
56
+ const values = Object.values(plugins).filter(Boolean);
57
+ if (values.some(isCssMacroPostcssPlugin)) return values;
58
+ return [...values, macroPlugin];
59
+ }
60
+ return [macroPlugin];
61
+ }
62
+ function withCssMacroStyleOptions(options) {
63
+ const postcssOptions = options?.postcssOptions;
64
+ return {
65
+ ...options,
66
+ [CSS_MACRO_STYLE_OPTIONS_MARKER]: true,
67
+ postcssOptions: {
68
+ ...postcssOptions,
69
+ plugins: withCssMacroPostcssPlugins(postcssOptions?.plugins)
70
+ }
71
+ };
72
+ }
73
+ function hasCssMacroStyleOptions(options) {
74
+ return Boolean(options?.[CSS_MACRO_STYLE_OPTIONS_MARKER]);
75
+ }
76
+ async function transformCssMacroCss(css) {
77
+ return (await (0, postcss.default)([require_postcss.creator()]).process(css, { from: void 0 })).css;
78
+ }
79
+ //#endregion
80
+ Object.defineProperty(exports, "hasCssMacroStyleOptions", {
81
+ enumerable: true,
82
+ get: function() {
83
+ return hasCssMacroStyleOptions;
84
+ }
85
+ });
86
+ Object.defineProperty(exports, "hasCssMacroTailwindPlugin", {
87
+ enumerable: true,
88
+ get: function() {
89
+ return hasCssMacroTailwindPlugin;
90
+ }
91
+ });
92
+ Object.defineProperty(exports, "hasCssMacroTailwindV4Directive", {
93
+ enumerable: true,
94
+ get: function() {
95
+ return hasCssMacroTailwindV4Directive;
96
+ }
97
+ });
98
+ Object.defineProperty(exports, "markCssMacroPlugin", {
99
+ enumerable: true,
100
+ get: function() {
101
+ return markCssMacroPlugin;
102
+ }
103
+ });
104
+ Object.defineProperty(exports, "transformCssMacroCss", {
105
+ enumerable: true,
106
+ get: function() {
107
+ return transformCssMacroCss;
108
+ }
109
+ });
110
+ Object.defineProperty(exports, "withCssMacroStyleOptions", {
111
+ enumerable: true,
112
+ get: function() {
113
+ return withCssMacroStyleOptions;
114
+ }
115
+ });
@@ -0,0 +1,78 @@
1
+ import { n as creator } from "./postcss-C7BMYpEF.mjs";
2
+ import postcss from "postcss";
3
+ //#region src/css-macro/auto.ts
4
+ const CSS_MACRO_PLUGIN_MARKER = "__weappTailwindcssCssMacro";
5
+ const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
6
+ function markCssMacroPlugin(value) {
7
+ Object.defineProperty(value, CSS_MACRO_PLUGIN_MARKER, {
8
+ configurable: false,
9
+ enumerable: false,
10
+ value: true
11
+ });
12
+ return value;
13
+ }
14
+ function isCssMacroTailwindPlugin(value) {
15
+ return Boolean(value && (typeof value === "function" || typeof value === "object") && value["__weappTailwindcssCssMacro"] === true);
16
+ }
17
+ function hasCssMacroTailwindPlugin(plugins) {
18
+ if (!plugins) return false;
19
+ if (Array.isArray(plugins)) return plugins.some(isCssMacroTailwindPlugin);
20
+ if (typeof plugins === "object") return Object.values(plugins).some(isCssMacroTailwindPlugin);
21
+ return false;
22
+ }
23
+ function parseCssPluginRequest(params) {
24
+ const value = params.trim();
25
+ const quoted = /^(['"])(.*?)\1/.exec(value);
26
+ if (quoted) return quoted[2];
27
+ const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
28
+ return url?.[2] ?? url?.[3];
29
+ }
30
+ function isCssMacroPluginRequest(request) {
31
+ return request === "weapp-tailwindcss/css-macro";
32
+ }
33
+ function hasCssMacroTailwindV4Directive(css) {
34
+ if (!css?.includes("css-macro")) return false;
35
+ try {
36
+ let found = false;
37
+ postcss.parse(css).walkAtRules("plugin", (rule) => {
38
+ if (isCssMacroPluginRequest(parseCssPluginRequest(rule.params))) found = true;
39
+ });
40
+ return found;
41
+ } catch {
42
+ return /@plugin\s+(?:url\(\s*)?["']weapp-tailwindcss\/css-macro["']/.test(css);
43
+ }
44
+ }
45
+ function isCssMacroPostcssPlugin(plugin) {
46
+ if (plugin === creator) return true;
47
+ return Boolean(plugin && (typeof plugin === "function" || typeof plugin === "object") && plugin.postcssPlugin === "postcss-weapp-tw-css-macro-plugin");
48
+ }
49
+ function withCssMacroPostcssPlugins(plugins) {
50
+ const macroPlugin = creator();
51
+ if (!plugins) return [macroPlugin];
52
+ if (Array.isArray(plugins)) return plugins.some(isCssMacroPostcssPlugin) ? plugins : [...plugins, macroPlugin];
53
+ if (typeof plugins === "object") {
54
+ const values = Object.values(plugins).filter(Boolean);
55
+ if (values.some(isCssMacroPostcssPlugin)) return values;
56
+ return [...values, macroPlugin];
57
+ }
58
+ return [macroPlugin];
59
+ }
60
+ function withCssMacroStyleOptions(options) {
61
+ const postcssOptions = options?.postcssOptions;
62
+ return {
63
+ ...options,
64
+ [CSS_MACRO_STYLE_OPTIONS_MARKER]: true,
65
+ postcssOptions: {
66
+ ...postcssOptions,
67
+ plugins: withCssMacroPostcssPlugins(postcssOptions?.plugins)
68
+ }
69
+ };
70
+ }
71
+ function hasCssMacroStyleOptions(options) {
72
+ return Boolean(options?.[CSS_MACRO_STYLE_OPTIONS_MARKER]);
73
+ }
74
+ async function transformCssMacroCss(css) {
75
+ return (await postcss([creator()]).process(css, { from: void 0 })).css;
76
+ }
77
+ //#endregion
78
+ export { transformCssMacroCss as a, markCssMacroPlugin as i, hasCssMacroTailwindPlugin as n, withCssMacroStyleOptions as o, hasCssMacroTailwindV4Directive as r, hasCssMacroStyleOptions as t };
@@ -0,0 +1,413 @@
1
+ import { g as traverse, h as babelParse, o as Parser } from "./precheck-D7K12zeX.mjs";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ import process from "node:process";
5
+ import { cleanUrl, ensurePosix } from "@weapp-tailwindcss/shared";
6
+ import { Buffer } from "node:buffer";
7
+ //#region src/bundlers/shared/module-graph.ts
8
+ const QUERY_HASH_RE = /[?#].*$/u;
9
+ const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
10
+ const WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
11
+ const VIRTUAL_PREFIX = "\0";
12
+ const JS_EXTENSIONS = [
13
+ ".js",
14
+ ".mjs",
15
+ ".cjs"
16
+ ];
17
+ function normalizeOutputPathKey(value) {
18
+ return path.normalize(value).replace(/\\/g, "/");
19
+ }
20
+ function stripQueryAndHash(specifier) {
21
+ return specifier.replace(QUERY_HASH_RE, "");
22
+ }
23
+ function isResolvableSpecifier(specifier) {
24
+ if (!specifier) return false;
25
+ const normalized = stripQueryAndHash(specifier);
26
+ if (normalized.startsWith(VIRTUAL_PREFIX)) return false;
27
+ if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) return true;
28
+ return !PROTOCOL_RE.test(normalized);
29
+ }
30
+ function toAbsoluteOutputPath(fileName, outDir) {
31
+ if (path.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) return path.normalize(fileName);
32
+ return path.resolve(outDir, fileName);
33
+ }
34
+ function matchWithExtensions(candidate, hasOutput) {
35
+ if (hasOutput(candidate)) return candidate;
36
+ if (!path.extname(candidate)) for (const ext of JS_EXTENSIONS) {
37
+ const extended = `${candidate}${ext}`;
38
+ if (hasOutput(extended)) return extended;
39
+ }
40
+ }
41
+ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
42
+ if (!isResolvableSpecifier(specifier)) return;
43
+ const normalized = stripQueryAndHash(specifier);
44
+ let candidate;
45
+ if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) candidate = path.normalize(normalized);
46
+ else if (normalized.startsWith("/")) candidate = path.resolve(outDir, normalized.slice(1));
47
+ else candidate = path.resolve(path.dirname(importer), normalized);
48
+ return matchWithExtensions(candidate, hasOutput);
49
+ }
50
+ //#endregion
51
+ //#region src/bundlers/shared/style-requests.ts
52
+ const SOURCE_STYLE_EXT_RE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)$/i;
53
+ const STYLE_QUERY_RE = /(?:^|&)type=styles?(?:&|$)/;
54
+ const STYLE_LANG_QUERY_RE = /(?:^|&)lang(?:[.=](?:css|scss|sass|less|styl|stylus|pcss|postcss))?(?:&|$)/;
55
+ function stripHash(request) {
56
+ const hashIndex = request.indexOf("#");
57
+ return hashIndex === -1 ? request : request.slice(0, hashIndex);
58
+ }
59
+ function stripRequestQuery(request) {
60
+ const normalized = stripHash(request);
61
+ const queryIndex = normalized.indexOf("?");
62
+ return queryIndex === -1 ? normalized : normalized.slice(0, queryIndex);
63
+ }
64
+ function isSourceStyleRequest(request) {
65
+ if (typeof request !== "string" || request.length === 0) return false;
66
+ const normalized = stripHash(request);
67
+ const queryIndex = normalized.indexOf("?");
68
+ const pathname = queryIndex === -1 ? normalized : normalized.slice(0, queryIndex);
69
+ if (SOURCE_STYLE_EXT_RE.test(pathname)) return true;
70
+ if (queryIndex === -1) return false;
71
+ const query = normalized.slice(queryIndex + 1);
72
+ return STYLE_QUERY_RE.test(query) || STYLE_LANG_QUERY_RE.test(query);
73
+ }
74
+ //#endregion
75
+ //#region src/bundlers/vite/utils.ts
76
+ function slash(p) {
77
+ return ensurePosix(p);
78
+ }
79
+ const isWindows = process.platform === "win32";
80
+ const cssLangRE = new RegExp(`\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`);
81
+ function isCSSRequest(request) {
82
+ return cssLangRE.test(request) || isSourceStyleRequest(request);
83
+ }
84
+ function normalizePath(id) {
85
+ return path.posix.normalize(isWindows ? ensurePosix(id) : id);
86
+ }
87
+ async function formatPostcssSourceMap(rawMap, file) {
88
+ const inputFileDir = path.dirname(file);
89
+ const sources = rawMap.sources.map((source) => {
90
+ const cleanSource = cleanUrl(decodeURIComponent(source));
91
+ if (cleanSource[0] === "<" && cleanSource.endsWith(">")) return `\0${cleanSource}`;
92
+ return normalizePath(path.resolve(inputFileDir, cleanSource));
93
+ });
94
+ return {
95
+ file,
96
+ mappings: rawMap.mappings,
97
+ names: rawMap.names,
98
+ sources,
99
+ sourcesContent: rawMap.sourcesContent,
100
+ version: rawMap.version
101
+ };
102
+ }
103
+ //#endregion
104
+ //#region src/utils/disabled.ts
105
+ function resolvePluginDisabledState(disabled) {
106
+ if (disabled === true) return { plugin: true };
107
+ if (disabled === false || disabled == null) return { plugin: false };
108
+ return { plugin: disabled.plugin ?? false };
109
+ }
110
+ //#endregion
111
+ //#region src/utils/resolve-package.ts
112
+ const require = createRequire(import.meta.url);
113
+ function resolvePackageDir(name) {
114
+ const pkgPath = require.resolve(`${name}/package.json`);
115
+ return path.dirname(pkgPath);
116
+ }
117
+ //#endregion
118
+ //#region src/bundlers/shared/generated-css-marker.ts
119
+ const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/i;
120
+ const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/gi;
121
+ function createBundlerGeneratedCssMarker(bundler, file) {
122
+ return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
123
+ }
124
+ function hasBundlerGeneratedCssMarker(source) {
125
+ return typeof source === "string" && BUNDLER_GENERATED_CSS_MARKER_RE.test(source);
126
+ }
127
+ function stripBundlerGeneratedCssMarkers(source) {
128
+ return source.replace(BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE, "");
129
+ }
130
+ //#endregion
131
+ //#region src/bundlers/shared/run-tasks.ts
132
+ async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
133
+ if (factories.length === 0) return [];
134
+ const results = Array.from({ length: factories.length });
135
+ const executing = /* @__PURE__ */ new Set();
136
+ let cursor = 0;
137
+ const effectiveLimit = Math.max(1, limit);
138
+ const scheduleNext = () => {
139
+ if (cursor >= factories.length) return;
140
+ const currentIndex = cursor++;
141
+ const factory = factories[currentIndex];
142
+ if (!factory) return;
143
+ const wrapped = Promise.resolve(factory()).then((value) => {
144
+ results[currentIndex] = value;
145
+ }).finally(() => {
146
+ executing.delete(wrapped);
147
+ });
148
+ executing.add(wrapped);
149
+ };
150
+ while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
151
+ while (cursor < factories.length) {
152
+ await Promise.race(executing);
153
+ scheduleNext();
154
+ }
155
+ await Promise.all(executing);
156
+ return results;
157
+ }
158
+ function pushConcurrentTaskFactories(queue, factories, limit) {
159
+ if (factories.length === 0) return;
160
+ queue.push(runWithConcurrency(factories, limit).then(() => void 0));
161
+ }
162
+ //#endregion
163
+ //#region src/bundlers/vite/bundle-entries.ts
164
+ function readOutputEntry(entry) {
165
+ if (entry.output.type === "chunk") return entry.output.code;
166
+ const source = entry.output.source;
167
+ if (typeof source === "string") return source;
168
+ if (source instanceof Uint8Array) return Buffer.from(source).toString();
169
+ const fallbackSource = source;
170
+ if (fallbackSource == null) return;
171
+ if (typeof fallbackSource.toString === "function") return fallbackSource.toString();
172
+ }
173
+ function isJavaScriptEntry(entry) {
174
+ if (entry.output.type === "chunk") return true;
175
+ return entry.fileName.endsWith(".js");
176
+ }
177
+ function createBundleModuleGraphOptions(outputDir, entries) {
178
+ const normalizedEntries = /* @__PURE__ */ new Map();
179
+ for (const [id, entry] of entries) normalizedEntries.set(normalizeOutputPathKey(id), entry);
180
+ const getEntry = (id) => entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
181
+ return {
182
+ resolve(specifier, importer) {
183
+ return resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => Boolean(getEntry(candidate)));
184
+ },
185
+ load(id) {
186
+ const entry = getEntry(id);
187
+ if (!entry) return;
188
+ return readOutputEntry(entry);
189
+ },
190
+ filter(id) {
191
+ return Boolean(getEntry(id));
192
+ }
193
+ };
194
+ }
195
+ function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
196
+ if (!linked) return;
197
+ const normalizedEntries = /* @__PURE__ */ new Map();
198
+ for (const [entryId, entry] of entries) normalizedEntries.set(normalizeOutputPathKey(entryId), entry);
199
+ for (const [id, { code }] of Object.entries(linked)) {
200
+ const entry = entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
201
+ if (!entry) continue;
202
+ const previous = readOutputEntry(entry);
203
+ if (previous == null || previous === code) continue;
204
+ if (entry.output.type === "chunk") entry.output.code = code;
205
+ else entry.output.source = code;
206
+ onApplied?.(entry, code);
207
+ onLinkedUpdate(entry.fileName, previous, code);
208
+ }
209
+ }
210
+ //#endregion
211
+ //#region src/bundlers/vite/runtime-affecting-signature.ts
212
+ const CSS_BLOCK_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
213
+ const CSS_AROUND_PUNCTUATION_RE = /\s*([{}:;,>+~()])\s*/g;
214
+ const CSS_TRAILING_DECLARATION_SEMICOLON_RE = /;\}/g;
215
+ const CSS_WHITESPACE_RE = /\s+/g;
216
+ function createHtmlRuntimeAffectingSignature(source) {
217
+ try {
218
+ const parts = [];
219
+ const parser = new Parser({
220
+ onattribute(name, value) {
221
+ parts.push(`a:${name}=${value}`);
222
+ },
223
+ oncomment(data) {
224
+ parts.push(`c:${data}`);
225
+ },
226
+ ontext(data) {
227
+ const value = data.trim();
228
+ if (value.length > 0) parts.push(`t:${value}`);
229
+ }
230
+ }, { xmlMode: true });
231
+ parser.write(source);
232
+ parser.end();
233
+ return parts.join("\n");
234
+ } catch {
235
+ return source;
236
+ }
237
+ }
238
+ function createJsRuntimeAffectingSignature(source) {
239
+ try {
240
+ const ast = babelParse(source, {
241
+ cache: true,
242
+ cacheKey: "vite-runtime-affecting:unambiguous",
243
+ plugins: ["jsx", "typescript"],
244
+ sourceType: "unambiguous"
245
+ });
246
+ const parts = [];
247
+ traverse(ast, {
248
+ noScope: true,
249
+ StringLiteral(path) {
250
+ parts.push(`s:${path.node.value}`);
251
+ },
252
+ TemplateElement(path) {
253
+ parts.push(`t:${path.node.value.raw}`);
254
+ },
255
+ JSXText(path) {
256
+ const value = path.node.value.trim();
257
+ if (value.length > 0) parts.push(`x:${value}`);
258
+ }
259
+ });
260
+ const comments = ast.comments;
261
+ if (Array.isArray(comments)) {
262
+ for (const comment of comments) if (typeof comment?.value === "string" && comment.value.length > 0) parts.push(`c:${comment.value}`);
263
+ }
264
+ return parts.join("\n");
265
+ } catch {
266
+ return source;
267
+ }
268
+ }
269
+ function createCssRuntimeAffectingSignature(source) {
270
+ return source.replace(CSS_BLOCK_COMMENT_RE, "").replace(CSS_AROUND_PUNCTUATION_RE, "$1").replace(CSS_TRAILING_DECLARATION_SEMICOLON_RE, "}").replace(CSS_WHITESPACE_RE, " ").trim();
271
+ }
272
+ function createRuntimeAffectingSourceSignature(source, type) {
273
+ if (type === "html") return createHtmlRuntimeAffectingSignature(source);
274
+ if (type === "js") return createJsRuntimeAffectingSignature(source);
275
+ if (type === "css") return createCssRuntimeAffectingSignature(source);
276
+ return source;
277
+ }
278
+ //#endregion
279
+ //#region src/bundlers/vite/bundle-state.ts
280
+ function createBundleBuildState() {
281
+ return {
282
+ iteration: 0,
283
+ sourceHashByFile: /* @__PURE__ */ new Map(),
284
+ runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
285
+ runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
286
+ linkedByEntry: /* @__PURE__ */ new Map(),
287
+ dependentsByLinkedFile: /* @__PURE__ */ new Map(),
288
+ generatorCandidateSignature: void 0
289
+ };
290
+ }
291
+ function createChangedByType() {
292
+ return {
293
+ html: /* @__PURE__ */ new Set(),
294
+ js: /* @__PURE__ */ new Set(),
295
+ css: /* @__PURE__ */ new Set(),
296
+ other: /* @__PURE__ */ new Set()
297
+ };
298
+ }
299
+ function createProcessFiles() {
300
+ return {
301
+ html: /* @__PURE__ */ new Set(),
302
+ js: /* @__PURE__ */ new Set(),
303
+ css: /* @__PURE__ */ new Set()
304
+ };
305
+ }
306
+ function readEntrySource(output) {
307
+ if (output.type === "chunk") return output.code;
308
+ return output.source.toString();
309
+ }
310
+ function classifyBundleEntry(file, opts) {
311
+ if (opts.cssMatcher(file) || isCSSRequest(file)) return "css";
312
+ if (opts.htmlMatcher(file)) return "html";
313
+ if (opts.jsMatcher(file) || opts.wxsMatcher(file)) return "js";
314
+ return "other";
315
+ }
316
+ function collectJsEntries(fileName, output, outDir, store) {
317
+ const entry = {
318
+ fileName,
319
+ output
320
+ };
321
+ if (!isJavaScriptEntry(entry)) return;
322
+ const absolute = toAbsoluteOutputPath(fileName, outDir);
323
+ store.set(absolute, entry);
324
+ }
325
+ function markProcessFile(type, file, processFiles) {
326
+ if (type === "html" || type === "js" || type === "css") processFiles[type].add(file);
327
+ }
328
+ function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false) {
329
+ const sourceHashByFile = /* @__PURE__ */ new Map();
330
+ const runtimeAffectingSignatureByFile = /* @__PURE__ */ new Map();
331
+ const runtimeAffectingHashByFile = /* @__PURE__ */ new Map();
332
+ const changedByType = createChangedByType();
333
+ const runtimeAffectingChangedByType = createChangedByType();
334
+ const processFiles = createProcessFiles();
335
+ const linkedImpactsByEntry = /* @__PURE__ */ new Map();
336
+ const jsEntries = /* @__PURE__ */ new Map();
337
+ const entries = [];
338
+ const firstRun = state.linkedByEntry.size === 0;
339
+ for (const [file, output] of Object.entries(bundle)) {
340
+ const type = classifyBundleEntry(file, opts);
341
+ const source = readEntrySource(output);
342
+ const hash = opts.cache.computeHash(source);
343
+ sourceHashByFile.set(file, hash);
344
+ const previousHash = state.sourceHashByFile.get(file);
345
+ const changed = previousHash == null || previousHash !== hash;
346
+ const previousRuntimeAffectingSignature = state.runtimeAffectingSignatureByFile.get(file);
347
+ const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
348
+ const canReuseRuntimeAffectingSignature = !changed && previousRuntimeAffectingSignature != null && previousRuntimeAffectingHash != null;
349
+ const runtimeAffectingSignature = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingSignature : createRuntimeAffectingSourceSignature(source, type);
350
+ const runtimeAffectingHash = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingHash : opts.cache.computeHash(runtimeAffectingSignature);
351
+ runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
352
+ runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
353
+ if (changed) changedByType[type].add(file);
354
+ if (previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash) runtimeAffectingChangedByType[type].add(file);
355
+ if (forceAll || firstRun) markProcessFile(type, file, processFiles);
356
+ else if (type === "html") processFiles.html.add(file);
357
+ else if (changed && (type === "js" || type === "css")) processFiles[type].add(file);
358
+ collectJsEntries(file, output, outDir, jsEntries);
359
+ entries.push({
360
+ file,
361
+ output,
362
+ source,
363
+ type
364
+ });
365
+ }
366
+ if (!forceAll && !firstRun) for (const changedFile of changedByType.js) {
367
+ const dependents = state.dependentsByLinkedFile.get(changedFile);
368
+ if (!dependents) continue;
369
+ for (const entryFile of dependents) {
370
+ processFiles.js.add(entryFile);
371
+ let impacts = linkedImpactsByEntry.get(entryFile);
372
+ if (!impacts) {
373
+ impacts = /* @__PURE__ */ new Set();
374
+ linkedImpactsByEntry.set(entryFile, impacts);
375
+ }
376
+ impacts.add(changedFile);
377
+ }
378
+ }
379
+ return {
380
+ entries,
381
+ jsEntries,
382
+ sourceHashByFile,
383
+ runtimeAffectingSignatureByFile,
384
+ runtimeAffectingHashByFile,
385
+ changedByType,
386
+ runtimeAffectingChangedByType,
387
+ processFiles,
388
+ linkedImpactsByEntry
389
+ };
390
+ }
391
+ function invertLinkedByEntry(linkedByEntry) {
392
+ const dependentsByLinkedFile = /* @__PURE__ */ new Map();
393
+ for (const [entryFile, linkedFiles] of linkedByEntry.entries()) for (const linkedFile of linkedFiles) {
394
+ let dependents = dependentsByLinkedFile.get(linkedFile);
395
+ if (!dependents) {
396
+ dependents = /* @__PURE__ */ new Set();
397
+ dependentsByLinkedFile.set(linkedFile, dependents);
398
+ }
399
+ dependents.add(entryFile);
400
+ }
401
+ return dependentsByLinkedFile;
402
+ }
403
+ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
404
+ const incremental = options.incremental === true;
405
+ state.iteration += 1;
406
+ state.sourceHashByFile = incremental ? new Map([...state.sourceHashByFile, ...snapshot.sourceHashByFile]) : snapshot.sourceHashByFile;
407
+ state.runtimeAffectingSignatureByFile = incremental ? new Map([...state.runtimeAffectingSignatureByFile, ...snapshot.runtimeAffectingSignatureByFile]) : snapshot.runtimeAffectingSignatureByFile;
408
+ state.runtimeAffectingHashByFile = incremental ? new Map([...state.runtimeAffectingHashByFile, ...snapshot.runtimeAffectingHashByFile]) : snapshot.runtimeAffectingHashByFile;
409
+ state.linkedByEntry = incremental ? new Map([...state.linkedByEntry, ...linkedByEntry]) : linkedByEntry;
410
+ state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
411
+ }
412
+ //#endregion
413
+ export { stripRequestQuery as _, createBundleModuleGraphOptions as a, toAbsoluteOutputPath as b, hasBundlerGeneratedCssMarker as c, resolvePluginDisabledState as d, cleanUrl as f, isSourceStyleRequest as g, slash as h, applyLinkedResults as i, stripBundlerGeneratedCssMarkers as l, isCSSRequest as m, createBundleBuildState as n, pushConcurrentTaskFactories as o, formatPostcssSourceMap as p, updateBundleBuildState as r, createBundlerGeneratedCssMarker as s, buildBundleSnapshot as t, resolvePackageDir as u, normalizeOutputPathKey as v, resolveOutputSpecifier as y };