weapp-tailwindcss 5.0.0-next.1 → 5.0.0-next.11

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 (215) hide show
  1. package/README.md +4 -5
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/bundle-state-BRkhpjio.js +448 -0
  4. package/dist/bundle-state-BrtFgX-A.mjs +369 -0
  5. package/dist/bundlers/shared/cache.d.ts +6 -6
  6. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
  7. package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
  8. package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +4 -0
  9. package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
  10. package/dist/bundlers/shared/css-cleanup.d.ts +1 -2
  11. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  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 +16 -0
  18. package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -0
  19. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +10 -0
  20. package/dist/bundlers/shared/generator-css.d.ts +12 -20
  21. package/dist/bundlers/shared/hmr-timing.d.ts +5 -0
  22. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  23. package/dist/bundlers/vite/css-finalizer.d.ts +4 -1
  24. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  25. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +20 -0
  26. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +3 -0
  27. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  28. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  29. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  30. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  31. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  32. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  33. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  34. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  35. package/dist/bundlers/vite/generate-bundle.d.ts +16 -2
  36. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +4 -1
  37. package/dist/bundlers/vite/index.d.ts +1 -1
  38. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  39. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  40. package/dist/bundlers/vite/rewrite-css-imports.d.ts +5 -3
  41. package/dist/bundlers/vite/runtime-class-set.d.ts +22 -0
  42. package/dist/bundlers/vite/source-candidates.d.ts +18 -0
  43. package/dist/bundlers/vite/source-scan.d.ts +9 -0
  44. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  45. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +1 -0
  46. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +5 -2
  47. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -3
  48. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
  49. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +3 -1
  50. package/dist/cache/index.d.ts +6 -6
  51. package/dist/cache-B_9E7FxF.js +517 -0
  52. package/dist/cache-DEDxBMIw.mjs +443 -0
  53. package/dist/cli/context.d.ts +1 -14
  54. package/dist/cli/doctor/types.d.ts +11 -11
  55. package/dist/cli/helpers.d.ts +1 -2
  56. package/dist/cli/mount-options.d.ts +2 -0
  57. package/dist/cli/types.d.ts +0 -2
  58. package/dist/cli/vscode-entry.d.ts +3 -3
  59. package/dist/cli.js +126 -602
  60. package/dist/cli.mjs +135 -610
  61. package/dist/constants.d.ts +1 -2
  62. package/dist/core.js +13 -20
  63. package/dist/core.mjs +8 -14
  64. package/dist/css-macro/postcss.js +3 -2
  65. package/dist/css-macro/postcss.mjs +3 -2
  66. package/dist/css-macro.d.ts +1 -0
  67. package/dist/css-macro.js +2 -2
  68. package/dist/css-macro.mjs +2 -2
  69. package/dist/defaults.d.ts +15 -1
  70. package/dist/defaults.js +33 -14
  71. package/dist/defaults.mjs +30 -15
  72. package/dist/escape.js +10 -2
  73. package/dist/escape.mjs +10 -2
  74. package/dist/generator/index.d.ts +1 -1
  75. package/dist/generator/options.d.ts +10 -7
  76. package/dist/generator/types.d.ts +3 -2
  77. package/dist/generator-CahkD2vq.mjs +1469 -0
  78. package/dist/generator-Ck1Dd1V0.js +1568 -0
  79. package/dist/generator.js +1 -1
  80. package/dist/generator.mjs +1 -1
  81. package/dist/gulp.js +149 -47
  82. package/dist/gulp.mjs +144 -42
  83. package/dist/incremental-runtime-class-set-CBMefNHQ.js +1744 -0
  84. package/dist/incremental-runtime-class-set-DaS2yw5c.mjs +1687 -0
  85. package/dist/index.d.ts +1 -1
  86. package/dist/index.js +6 -6
  87. package/dist/index.mjs +5 -5
  88. package/dist/js/index.d.ts +1 -0
  89. package/dist/js/literal-transform.d.ts +2 -0
  90. package/dist/js/precheck.d.ts +2 -2
  91. package/dist/lightningcss/style-handler/selector-transform.d.ts +1 -1
  92. package/dist/lightningcss/style-handler.d.ts +3 -3
  93. package/dist/logger-CZUxvJJD.mjs +2 -0
  94. package/dist/logger-EVNB9z7i.js +1 -0
  95. package/dist/postcss/config-directive.d.ts +1 -0
  96. package/dist/postcss/context.d.ts +9 -0
  97. package/dist/postcss/source-files.d.ts +8 -0
  98. package/dist/postcss/tailwind-version.d.ts +3 -0
  99. package/dist/postcss-BdcRlSpp.js +243 -0
  100. package/dist/postcss-Bs-RbNzK.js +5477 -0
  101. package/dist/postcss-xZDiTRII.mjs +234 -0
  102. package/dist/postcss.d.ts +2 -2
  103. package/dist/postcss.js +3 -274
  104. package/dist/postcss.mjs +1 -267
  105. package/dist/{recorder-rn_2v_nd.js → precheck-D5eEdqeH.js} +168 -304
  106. package/dist/{recorder-B_XyZ576.mjs → precheck-DtBGFS-n.mjs} +134 -269
  107. package/dist/presets.js +13 -11
  108. package/dist/presets.mjs +11 -9
  109. package/dist/reset.d.ts +1 -0
  110. package/dist/runtime-patch-CqB-A4zA.js +85 -0
  111. package/dist/runtime-patch-DGKsVkiG.mjs +71 -0
  112. package/dist/shared/mpx.d.ts +1 -0
  113. package/dist/source-scan-CIVTa3Cj.js +297 -0
  114. package/dist/source-scan-CJ0y0XBj.mjs +258 -0
  115. package/dist/tailwindcss/miniprogram.d.ts +5 -1
  116. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  117. package/dist/tailwindcss/patcher.d.ts +1 -2
  118. package/dist/tailwindcss/runtime/cache.d.ts +3 -3
  119. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  120. package/dist/tailwindcss/runtime.d.ts +11 -12
  121. package/dist/tailwindcss/source-scan.d.ts +25 -0
  122. package/dist/tailwindcss/targets.d.ts +1 -5
  123. package/dist/tailwindcss/v3-engine/types.d.ts +14 -14
  124. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  125. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  126. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  127. package/dist/tailwindcss/v4/patcher.d.ts +1 -0
  128. package/dist/tailwindcss/v4-engine/candidates.d.ts +2 -0
  129. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +1 -0
  130. package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +1 -0
  131. package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +1 -0
  132. package/dist/tailwindcss/v4-engine/tailwind-v4-default-colors.d.ts +1 -0
  133. package/dist/tailwindcss/v4-engine/types.d.ts +6 -3
  134. package/dist/tailwindcss/version.d.ts +4 -0
  135. package/dist/tailwindcss-B78nj6n7.js +644 -0
  136. package/dist/tailwindcss-DGM8lHUj.mjs +593 -0
  137. package/dist/typedoc.export.d.ts +0 -2
  138. package/dist/types/index.d.ts +45 -48
  139. package/dist/types/shared.d.ts +3 -0
  140. package/dist/types/user-defined-options/general.d.ts +21 -23
  141. package/dist/types/user-defined-options/important.d.ts +31 -28
  142. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  143. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  144. package/dist/uni-app-x/vite.d.ts +1 -1
  145. package/dist/utils/disabled.d.ts +2 -3
  146. package/dist/utils/object.d.ts +9 -0
  147. package/dist/{utils-DmC9_In3.js → utils-4ODFyoqD.js} +1 -1
  148. package/dist/{utils-7DUGTFED.mjs → utils-CGBVVNm6.mjs} +1 -1
  149. package/dist/{vite-BHpAqldo.js → vite-BEj9JOOA.js} +1245 -876
  150. package/dist/{vite-C8JlHiyR.mjs → vite-C8S1wfyQ.mjs} +1208 -842
  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 +129 -15
  155. package/dist/weapp-tw-runtime-classset-loader.js +44 -6
  156. package/dist/webpack-Dm1IXTIh.js +778 -0
  157. package/dist/webpack-ZGIKKpFf.mjs +768 -0
  158. package/dist/webpack.js +1 -1
  159. package/dist/webpack.mjs +1 -1
  160. package/package.json +26 -39
  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-CZ-JXw6T.js +0 -492
  192. package/dist/generator-Dwxgra97.mjs +0 -399
  193. package/dist/generator-css-CnYjiMrD.js +0 -1084
  194. package/dist/generator-css-DhPFjSzK.mjs +0 -1057
  195. package/dist/js/syntax.d.ts +0 -10
  196. package/dist/loader-anchors-DvwgIYdA.mjs +0 -205
  197. package/dist/loader-anchors-cprm4Klq.js +0 -273
  198. package/dist/logger-BZ45DZJT.js +0 -1003
  199. package/dist/logger-BoVx1Dbt.mjs +0 -935
  200. package/dist/patcher-options-6gJN2EXy.js +0 -115
  201. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  202. package/dist/tailwindcss/recorder.d.ts +0 -13
  203. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  204. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  205. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  206. package/dist/tailwindcss/targets/types.d.ts +0 -35
  207. package/dist/types/disabled-options.d.ts +0 -4
  208. package/dist/webpack-CABjKGGQ.mjs +0 -441
  209. package/dist/webpack-DNIJ0ysE.js +0 -456
  210. package/dist/webpack4.d.ts +0 -4
  211. package/dist/webpack4.js +0 -387
  212. package/dist/webpack4.mjs +0 -379
  213. package/scripts/postinstall.mjs +0 -59
  214. /package/dist/{constants-B-_T5UnW.mjs → constants-BG12WAKw.mjs} +0 -0
  215. /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
 
@@ -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,448 @@
1
+ const require_chunk = require("./chunk-8l464Juk.js");
2
+ const require_precheck = require("./precheck-D5eEdqeH.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_buffer = require("node:buffer");
7
+ let htmlparser2 = require("htmlparser2");
8
+ //#region src/bundlers/shared/module-graph.ts
9
+ const QUERY_HASH_RE = /[?#].*$/u;
10
+ const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
11
+ const WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
12
+ const VIRTUAL_PREFIX = "\0";
13
+ const JS_EXTENSIONS = [
14
+ ".js",
15
+ ".mjs",
16
+ ".cjs"
17
+ ];
18
+ function normalizeOutputPathKey(value) {
19
+ return node_path.default.normalize(value).replace(/\\/g, "/");
20
+ }
21
+ function stripQueryAndHash(specifier) {
22
+ return specifier.replace(QUERY_HASH_RE, "");
23
+ }
24
+ function isResolvableSpecifier(specifier) {
25
+ if (!specifier) return false;
26
+ const normalized = stripQueryAndHash(specifier);
27
+ if (normalized.startsWith(VIRTUAL_PREFIX)) return false;
28
+ if (node_path.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) return true;
29
+ return !PROTOCOL_RE.test(normalized);
30
+ }
31
+ function toAbsoluteOutputPath(fileName, outDir) {
32
+ if (node_path.default.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) return node_path.default.normalize(fileName);
33
+ return node_path.default.resolve(outDir, fileName);
34
+ }
35
+ function matchWithExtensions(candidate, hasOutput) {
36
+ if (hasOutput(candidate)) return candidate;
37
+ if (!node_path.default.extname(candidate)) for (const ext of JS_EXTENSIONS) {
38
+ const extended = `${candidate}${ext}`;
39
+ if (hasOutput(extended)) return extended;
40
+ }
41
+ }
42
+ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
43
+ if (!isResolvableSpecifier(specifier)) return;
44
+ const normalized = stripQueryAndHash(specifier);
45
+ let candidate;
46
+ if (node_path.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) candidate = node_path.default.normalize(normalized);
47
+ else if (normalized.startsWith("/")) candidate = node_path.default.resolve(outDir, normalized.slice(1));
48
+ else candidate = node_path.default.resolve(node_path.default.dirname(importer), normalized);
49
+ return matchWithExtensions(candidate, hasOutput);
50
+ }
51
+ //#endregion
52
+ //#region src/bundlers/shared/style-requests.ts
53
+ const SOURCE_STYLE_EXT_RE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)$/i;
54
+ const STYLE_QUERY_RE = /(?:^|&)type=styles?(?:&|$)/;
55
+ const STYLE_LANG_QUERY_RE = /(?:^|&)lang(?:[.=](?:css|scss|sass|less|styl|stylus|pcss|postcss))?(?:&|$)/;
56
+ function stripHash(request) {
57
+ const hashIndex = request.indexOf("#");
58
+ return hashIndex === -1 ? request : request.slice(0, hashIndex);
59
+ }
60
+ function stripRequestQuery(request) {
61
+ const normalized = stripHash(request);
62
+ const queryIndex = normalized.indexOf("?");
63
+ return queryIndex === -1 ? normalized : normalized.slice(0, queryIndex);
64
+ }
65
+ function isSourceStyleRequest(request) {
66
+ if (typeof request !== "string" || request.length === 0) return false;
67
+ const normalized = stripHash(request);
68
+ const queryIndex = normalized.indexOf("?");
69
+ const pathname = queryIndex === -1 ? normalized : normalized.slice(0, queryIndex);
70
+ if (SOURCE_STYLE_EXT_RE.test(pathname)) return true;
71
+ if (queryIndex === -1) return false;
72
+ const query = normalized.slice(queryIndex + 1);
73
+ return STYLE_QUERY_RE.test(query) || STYLE_LANG_QUERY_RE.test(query);
74
+ }
75
+ //#endregion
76
+ //#region src/utils/disabled.ts
77
+ function resolvePluginDisabledState(disabled) {
78
+ if (disabled === true) return { plugin: true };
79
+ if (disabled === false || disabled == null) return { plugin: false };
80
+ return { plugin: disabled.plugin ?? false };
81
+ }
82
+ //#endregion
83
+ //#region src/utils/resolve-package.ts
84
+ const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
85
+ function resolvePackageDir(name) {
86
+ const pkgPath = require$1.resolve(`${name}/package.json`);
87
+ return node_path.default.dirname(pkgPath);
88
+ }
89
+ //#endregion
90
+ //#region src/bundlers/shared/run-tasks.ts
91
+ async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
92
+ if (factories.length === 0) return [];
93
+ const results = Array.from({ length: factories.length });
94
+ const executing = /* @__PURE__ */ new Set();
95
+ let cursor = 0;
96
+ const effectiveLimit = Math.max(1, limit);
97
+ const scheduleNext = () => {
98
+ if (cursor >= factories.length) return;
99
+ const currentIndex = cursor++;
100
+ const factory = factories[currentIndex];
101
+ if (!factory) return;
102
+ const wrapped = Promise.resolve(factory()).then((value) => {
103
+ results[currentIndex] = value;
104
+ }).finally(() => {
105
+ executing.delete(wrapped);
106
+ });
107
+ executing.add(wrapped);
108
+ };
109
+ while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
110
+ while (cursor < factories.length) {
111
+ await Promise.race(executing);
112
+ scheduleNext();
113
+ }
114
+ await Promise.all(executing);
115
+ return results;
116
+ }
117
+ function pushConcurrentTaskFactories(queue, factories, limit) {
118
+ if (factories.length === 0) return;
119
+ queue.push(runWithConcurrency(factories, limit).then(() => void 0));
120
+ }
121
+ //#endregion
122
+ //#region src/bundlers/vite/bundle-entries.ts
123
+ function readOutputEntry(entry) {
124
+ if (entry.output.type === "chunk") return entry.output.code;
125
+ const source = entry.output.source;
126
+ if (typeof source === "string") return source;
127
+ if (source instanceof Uint8Array) return node_buffer.Buffer.from(source).toString();
128
+ const fallbackSource = source;
129
+ if (fallbackSource == null) return;
130
+ if (typeof fallbackSource.toString === "function") return fallbackSource.toString();
131
+ }
132
+ function isJavaScriptEntry(entry) {
133
+ if (entry.output.type === "chunk") return true;
134
+ return entry.fileName.endsWith(".js");
135
+ }
136
+ function createBundleModuleGraphOptions(outputDir, entries) {
137
+ const normalizedEntries = /* @__PURE__ */ new Map();
138
+ for (const [id, entry] of entries) normalizedEntries.set(normalizeOutputPathKey(id), entry);
139
+ const getEntry = (id) => entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
140
+ return {
141
+ resolve(specifier, importer) {
142
+ return resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => Boolean(getEntry(candidate)));
143
+ },
144
+ load(id) {
145
+ const entry = getEntry(id);
146
+ if (!entry) return;
147
+ return readOutputEntry(entry);
148
+ },
149
+ filter(id) {
150
+ return Boolean(getEntry(id));
151
+ }
152
+ };
153
+ }
154
+ function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
155
+ if (!linked) return;
156
+ const normalizedEntries = /* @__PURE__ */ new Map();
157
+ for (const [entryId, entry] of entries) normalizedEntries.set(normalizeOutputPathKey(entryId), entry);
158
+ for (const [id, { code }] of Object.entries(linked)) {
159
+ const entry = entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
160
+ if (!entry) continue;
161
+ const previous = readOutputEntry(entry);
162
+ if (previous == null || previous === code) continue;
163
+ if (entry.output.type === "chunk") entry.output.code = code;
164
+ else entry.output.source = code;
165
+ onApplied?.(entry, code);
166
+ onLinkedUpdate(entry.fileName, previous, code);
167
+ }
168
+ }
169
+ //#endregion
170
+ //#region src/bundlers/vite/runtime-affecting-signature.ts
171
+ const CSS_BLOCK_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
172
+ const CSS_AROUND_PUNCTUATION_RE = /\s*([{}:;,>+~()])\s*/g;
173
+ const CSS_TRAILING_DECLARATION_SEMICOLON_RE = /;\}/g;
174
+ const CSS_WHITESPACE_RE = /\s+/g;
175
+ function createHtmlRuntimeAffectingSignature(source) {
176
+ try {
177
+ const parts = [];
178
+ const parser = new htmlparser2.Parser({
179
+ onattribute(name, value) {
180
+ parts.push(`a:${name}=${value}`);
181
+ },
182
+ oncomment(data) {
183
+ parts.push(`c:${data}`);
184
+ },
185
+ ontext(data) {
186
+ const value = data.trim();
187
+ if (value.length > 0) parts.push(`t:${value}`);
188
+ }
189
+ }, { xmlMode: true });
190
+ parser.write(source);
191
+ parser.end();
192
+ return parts.join("\n");
193
+ } catch {
194
+ return source;
195
+ }
196
+ }
197
+ function createJsRuntimeAffectingSignature(source) {
198
+ try {
199
+ const ast = require_precheck.babelParse(source, {
200
+ cache: true,
201
+ cacheKey: "vite-runtime-affecting:unambiguous",
202
+ plugins: ["jsx", "typescript"],
203
+ sourceType: "unambiguous"
204
+ });
205
+ const parts = [];
206
+ require_precheck.traverse(ast, {
207
+ noScope: true,
208
+ StringLiteral(path) {
209
+ parts.push(`s:${path.node.value}`);
210
+ },
211
+ TemplateElement(path) {
212
+ parts.push(`t:${path.node.value.raw}`);
213
+ },
214
+ JSXText(path) {
215
+ const value = path.node.value.trim();
216
+ if (value.length > 0) parts.push(`x:${value}`);
217
+ }
218
+ });
219
+ const comments = ast.comments;
220
+ if (Array.isArray(comments)) {
221
+ for (const comment of comments) if (typeof comment?.value === "string" && comment.value.length > 0) parts.push(`c:${comment.value}`);
222
+ }
223
+ return parts.join("\n");
224
+ } catch {
225
+ return source;
226
+ }
227
+ }
228
+ function createCssRuntimeAffectingSignature(source) {
229
+ return source.replace(CSS_BLOCK_COMMENT_RE, "").replace(CSS_AROUND_PUNCTUATION_RE, "$1").replace(CSS_TRAILING_DECLARATION_SEMICOLON_RE, "}").replace(CSS_WHITESPACE_RE, " ").trim();
230
+ }
231
+ function createRuntimeAffectingSourceSignature(source, type) {
232
+ if (type === "html") return createHtmlRuntimeAffectingSignature(source);
233
+ if (type === "js") return createJsRuntimeAffectingSignature(source);
234
+ if (type === "css") return createCssRuntimeAffectingSignature(source);
235
+ return source;
236
+ }
237
+ //#endregion
238
+ //#region src/bundlers/vite/bundle-state.ts
239
+ function createBundleBuildState() {
240
+ return {
241
+ iteration: 0,
242
+ sourceHashByFile: /* @__PURE__ */ new Map(),
243
+ runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
244
+ runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
245
+ linkedByEntry: /* @__PURE__ */ new Map(),
246
+ dependentsByLinkedFile: /* @__PURE__ */ new Map()
247
+ };
248
+ }
249
+ function createChangedByType() {
250
+ return {
251
+ html: /* @__PURE__ */ new Set(),
252
+ js: /* @__PURE__ */ new Set(),
253
+ css: /* @__PURE__ */ new Set(),
254
+ other: /* @__PURE__ */ new Set()
255
+ };
256
+ }
257
+ function createProcessFiles() {
258
+ return {
259
+ html: /* @__PURE__ */ new Set(),
260
+ js: /* @__PURE__ */ new Set(),
261
+ css: /* @__PURE__ */ new Set()
262
+ };
263
+ }
264
+ function readEntrySource(output) {
265
+ if (output.type === "chunk") return output.code;
266
+ return output.source.toString();
267
+ }
268
+ function classifyBundleEntry(file, opts) {
269
+ if (opts.cssMatcher(file)) return "css";
270
+ if (opts.htmlMatcher(file)) return "html";
271
+ if (opts.jsMatcher(file) || opts.wxsMatcher(file)) return "js";
272
+ return "other";
273
+ }
274
+ function collectJsEntries(fileName, output, outDir, store) {
275
+ const entry = {
276
+ fileName,
277
+ output
278
+ };
279
+ if (!isJavaScriptEntry(entry)) return;
280
+ const absolute = toAbsoluteOutputPath(fileName, outDir);
281
+ store.set(absolute, entry);
282
+ }
283
+ function markProcessFile(type, file, processFiles) {
284
+ if (type === "html" || type === "js" || type === "css") processFiles[type].add(file);
285
+ }
286
+ function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false) {
287
+ const sourceHashByFile = /* @__PURE__ */ new Map();
288
+ const runtimeAffectingSignatureByFile = /* @__PURE__ */ new Map();
289
+ const runtimeAffectingHashByFile = /* @__PURE__ */ new Map();
290
+ const changedByType = createChangedByType();
291
+ const runtimeAffectingChangedByType = createChangedByType();
292
+ const processFiles = createProcessFiles();
293
+ const linkedImpactsByEntry = /* @__PURE__ */ new Map();
294
+ const jsEntries = /* @__PURE__ */ new Map();
295
+ const entries = [];
296
+ const firstRun = state.linkedByEntry.size === 0;
297
+ for (const [file, output] of Object.entries(bundle)) {
298
+ const type = classifyBundleEntry(file, opts);
299
+ const source = readEntrySource(output);
300
+ const hash = opts.cache.computeHash(source);
301
+ sourceHashByFile.set(file, hash);
302
+ const previousHash = state.sourceHashByFile.get(file);
303
+ const changed = previousHash == null || previousHash !== hash;
304
+ const previousRuntimeAffectingSignature = state.runtimeAffectingSignatureByFile.get(file);
305
+ const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
306
+ const canReuseRuntimeAffectingSignature = !changed && previousRuntimeAffectingSignature != null && previousRuntimeAffectingHash != null;
307
+ const runtimeAffectingSignature = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingSignature : createRuntimeAffectingSourceSignature(source, type);
308
+ const runtimeAffectingHash = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingHash : opts.cache.computeHash(runtimeAffectingSignature);
309
+ runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
310
+ runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
311
+ if (changed) changedByType[type].add(file);
312
+ if (previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash) runtimeAffectingChangedByType[type].add(file);
313
+ if (forceAll || firstRun) markProcessFile(type, file, processFiles);
314
+ else if (type === "html") processFiles.html.add(file);
315
+ else if (changed && (type === "js" || type === "css")) processFiles[type].add(file);
316
+ collectJsEntries(file, output, outDir, jsEntries);
317
+ entries.push({
318
+ file,
319
+ output,
320
+ source,
321
+ type
322
+ });
323
+ }
324
+ if (!forceAll && !firstRun) for (const changedFile of changedByType.js) {
325
+ const dependents = state.dependentsByLinkedFile.get(changedFile);
326
+ if (!dependents) continue;
327
+ for (const entryFile of dependents) {
328
+ processFiles.js.add(entryFile);
329
+ let impacts = linkedImpactsByEntry.get(entryFile);
330
+ if (!impacts) {
331
+ impacts = /* @__PURE__ */ new Set();
332
+ linkedImpactsByEntry.set(entryFile, impacts);
333
+ }
334
+ impacts.add(changedFile);
335
+ }
336
+ }
337
+ return {
338
+ entries,
339
+ jsEntries,
340
+ sourceHashByFile,
341
+ runtimeAffectingSignatureByFile,
342
+ runtimeAffectingHashByFile,
343
+ changedByType,
344
+ runtimeAffectingChangedByType,
345
+ processFiles,
346
+ linkedImpactsByEntry
347
+ };
348
+ }
349
+ function invertLinkedByEntry(linkedByEntry) {
350
+ const dependentsByLinkedFile = /* @__PURE__ */ new Map();
351
+ for (const [entryFile, linkedFiles] of linkedByEntry.entries()) for (const linkedFile of linkedFiles) {
352
+ let dependents = dependentsByLinkedFile.get(linkedFile);
353
+ if (!dependents) {
354
+ dependents = /* @__PURE__ */ new Set();
355
+ dependentsByLinkedFile.set(linkedFile, dependents);
356
+ }
357
+ dependents.add(entryFile);
358
+ }
359
+ return dependentsByLinkedFile;
360
+ }
361
+ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
362
+ const incremental = options.incremental === true;
363
+ state.iteration += 1;
364
+ state.sourceHashByFile = incremental ? new Map([...state.sourceHashByFile, ...snapshot.sourceHashByFile]) : snapshot.sourceHashByFile;
365
+ state.runtimeAffectingSignatureByFile = incremental ? new Map([...state.runtimeAffectingSignatureByFile, ...snapshot.runtimeAffectingSignatureByFile]) : snapshot.runtimeAffectingSignatureByFile;
366
+ state.runtimeAffectingHashByFile = incremental ? new Map([...state.runtimeAffectingHashByFile, ...snapshot.runtimeAffectingHashByFile]) : snapshot.runtimeAffectingHashByFile;
367
+ state.linkedByEntry = incremental ? new Map([...state.linkedByEntry, ...linkedByEntry]) : linkedByEntry;
368
+ state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
369
+ }
370
+ //#endregion
371
+ Object.defineProperty(exports, "applyLinkedResults", {
372
+ enumerable: true,
373
+ get: function() {
374
+ return applyLinkedResults;
375
+ }
376
+ });
377
+ Object.defineProperty(exports, "buildBundleSnapshot", {
378
+ enumerable: true,
379
+ get: function() {
380
+ return buildBundleSnapshot;
381
+ }
382
+ });
383
+ Object.defineProperty(exports, "createBundleBuildState", {
384
+ enumerable: true,
385
+ get: function() {
386
+ return createBundleBuildState;
387
+ }
388
+ });
389
+ Object.defineProperty(exports, "createBundleModuleGraphOptions", {
390
+ enumerable: true,
391
+ get: function() {
392
+ return createBundleModuleGraphOptions;
393
+ }
394
+ });
395
+ Object.defineProperty(exports, "isSourceStyleRequest", {
396
+ enumerable: true,
397
+ get: function() {
398
+ return isSourceStyleRequest;
399
+ }
400
+ });
401
+ Object.defineProperty(exports, "normalizeOutputPathKey", {
402
+ enumerable: true,
403
+ get: function() {
404
+ return normalizeOutputPathKey;
405
+ }
406
+ });
407
+ Object.defineProperty(exports, "pushConcurrentTaskFactories", {
408
+ enumerable: true,
409
+ get: function() {
410
+ return pushConcurrentTaskFactories;
411
+ }
412
+ });
413
+ Object.defineProperty(exports, "resolveOutputSpecifier", {
414
+ enumerable: true,
415
+ get: function() {
416
+ return resolveOutputSpecifier;
417
+ }
418
+ });
419
+ Object.defineProperty(exports, "resolvePackageDir", {
420
+ enumerable: true,
421
+ get: function() {
422
+ return resolvePackageDir;
423
+ }
424
+ });
425
+ Object.defineProperty(exports, "resolvePluginDisabledState", {
426
+ enumerable: true,
427
+ get: function() {
428
+ return resolvePluginDisabledState;
429
+ }
430
+ });
431
+ Object.defineProperty(exports, "stripRequestQuery", {
432
+ enumerable: true,
433
+ get: function() {
434
+ return stripRequestQuery;
435
+ }
436
+ });
437
+ Object.defineProperty(exports, "toAbsoluteOutputPath", {
438
+ enumerable: true,
439
+ get: function() {
440
+ return toAbsoluteOutputPath;
441
+ }
442
+ });
443
+ Object.defineProperty(exports, "updateBundleBuildState", {
444
+ enumerable: true,
445
+ get: function() {
446
+ return updateBundleBuildState;
447
+ }
448
+ });