nitro 3.0.1-alpha.2 → 3.0.260415-beta

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 (297) hide show
  1. package/LICENSE +6 -0
  2. package/README.md +2 -2
  3. package/dist/THIRD-PARTY-LICENSES.md +1646 -0
  4. package/dist/_build/common.mjs +7261 -3812
  5. package/dist/_build/rolldown.mjs +32 -42
  6. package/dist/_build/rollup.mjs +28 -48
  7. package/dist/_build/vite.build.mjs +10 -10
  8. package/dist/_chunks/nitro.mjs +102 -327
  9. package/dist/_chunks/nitro2.mjs +8 -9
  10. package/dist/_chunks/nitro3.mjs +136 -0
  11. package/dist/_chunks/nitro4.mjs +127 -0
  12. package/dist/_chunks/utils.mjs +40 -29
  13. package/dist/_common.mjs +13 -25
  14. package/dist/_dev.d.mts +0 -3
  15. package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -330
  16. package/dist/_libs/_.mjs +2 -0
  17. package/dist/_libs/_2.mjs +2 -0
  18. package/dist/_libs/_3.mjs +2 -0
  19. package/dist/_libs/_4.mjs +2 -0
  20. package/dist/_libs/_5.mjs +2 -0
  21. package/dist/_libs/_6.mjs +2 -0
  22. package/dist/_libs/_7.mjs +2 -0
  23. package/dist/_libs/c12+rc9.mjs +814 -0
  24. package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +49 -40
  25. package/dist/_libs/citty.mjs +142 -41
  26. package/dist/_libs/commondir+is-reference.mjs +60 -56
  27. package/dist/_libs/compatx.d.mts +0 -2
  28. package/dist/_libs/compatx.mjs +1 -4
  29. package/dist/_libs/esbuild.d.mts +0 -1
  30. package/dist/_libs/escape-string-regexp.mjs +1 -4
  31. package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +0 -5
  32. package/dist/_libs/estree-walker.mjs +4 -92
  33. package/dist/_libs/exsolve.d.mts +1 -0
  34. package/dist/_libs/hasown+resolve+deepmerge.mjs +160 -246
  35. package/dist/_libs/httpxy.d.mts +20 -13
  36. package/dist/_libs/httpxy.mjs +519 -95
  37. package/dist/_libs/js-tokens.d.mts +1 -0
  38. package/dist/_libs/klona.mjs +1 -4
  39. package/dist/_libs/magic-string.d.mts +0 -2
  40. package/dist/_libs/mlly.d.mts +0 -2
  41. package/dist/_libs/nypm+tinyexec.mjs +822 -0
  42. package/dist/_libs/perfect-debounce.mjs +68 -0
  43. package/dist/_libs/pkg-types.d.mts +0 -3
  44. package/dist/_libs/plugin-alias.mjs +1 -5
  45. package/dist/_libs/plugin-inject.mjs +1 -7
  46. package/dist/_libs/plugin-json.mjs +1 -5
  47. package/dist/_libs/pluginutils.mjs +3 -35
  48. package/dist/_libs/readdirp+chokidar.mjs +187 -365
  49. package/dist/_libs/remapping.mjs +1 -5
  50. package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -53
  51. package/dist/_libs/rou3.d.mts +1 -4
  52. package/dist/_libs/rou3.mjs +223 -78
  53. package/dist/_libs/std-env.d.mts +8 -2
  54. package/dist/_libs/strip-literal.d.mts +1 -0
  55. package/dist/_libs/tsconfck.mjs +21 -334
  56. package/dist/_libs/ultrahtml.mjs +3 -16
  57. package/dist/_libs/unimport+unplugin.mjs +244 -388
  58. package/dist/_libs/unplugin+unimport.d.mts +5 -15
  59. package/dist/_libs/unwasm.d.mts +0 -3
  60. package/dist/_presets.mjs +576 -488
  61. package/dist/builder.d.mts +5 -25
  62. package/dist/builder.mjs +3 -8
  63. package/dist/cli/_chunks/build.mjs +22 -25
  64. package/dist/cli/_chunks/common.mjs +1 -4
  65. package/dist/cli/_chunks/deploy.mjs +37 -0
  66. package/dist/cli/_chunks/dev.mjs +6 -11
  67. package/dist/cli/_chunks/docs.mjs +28 -0
  68. package/dist/cli/_chunks/list.mjs +4 -8
  69. package/dist/cli/_chunks/prepare.mjs +2 -6
  70. package/dist/cli/_chunks/preview.mjs +48 -0
  71. package/dist/cli/_chunks/run.mjs +7 -11
  72. package/dist/cli/_chunks/task.mjs +1 -5
  73. package/dist/cli/index.mjs +5 -6
  74. package/dist/docs/0.docs/0.index/index.md +56 -0
  75. package/dist/docs/0.docs/1.quick-start.md +110 -0
  76. package/dist/docs/0.docs/10.lifecycle.md +204 -0
  77. package/dist/docs/0.docs/11.openapi.md +291 -0
  78. package/dist/docs/0.docs/12.plugins.md +164 -0
  79. package/dist/docs/0.docs/13.tasks.md +277 -0
  80. package/dist/docs/0.docs/14.websocket.md +386 -0
  81. package/dist/docs/0.docs/15.migration.md +213 -0
  82. package/dist/docs/0.docs/16.nightly.md +31 -0
  83. package/dist/docs/0.docs/2.renderer.md +322 -0
  84. package/dist/docs/0.docs/3.routing.md +711 -0
  85. package/dist/docs/0.docs/4.server-entry.md +239 -0
  86. package/dist/docs/0.docs/5.cache.md +408 -0
  87. package/dist/docs/0.docs/6.storage.md +261 -0
  88. package/dist/docs/0.docs/7.assets.md +166 -0
  89. package/dist/docs/0.docs/8.configuration.md +256 -0
  90. package/dist/docs/0.docs/9.database.md +185 -0
  91. package/dist/docs/1.deploy/0.index/index.md +64 -0
  92. package/dist/docs/1.deploy/1.runtimes/0.node.md +63 -0
  93. package/dist/docs/1.deploy/1.runtimes/1.bun.md +15 -0
  94. package/dist/docs/1.deploy/1.runtimes/2.deno.md +19 -0
  95. package/dist/docs/1.deploy/2.providers/0.alwaysdata.md +50 -0
  96. package/dist/docs/1.deploy/2.providers/1.aws.md +47 -0
  97. package/dist/docs/1.deploy/2.providers/10.flightcontrol.md +67 -0
  98. package/dist/docs/1.deploy/2.providers/11.genezio.md +67 -0
  99. package/dist/docs/1.deploy/2.providers/12.github-pages.md +68 -0
  100. package/dist/docs/1.deploy/2.providers/13.gitlab-pages.md +37 -0
  101. package/dist/docs/1.deploy/2.providers/14.heroku.md +84 -0
  102. package/dist/docs/1.deploy/2.providers/15.iis.md +38 -0
  103. package/dist/docs/1.deploy/2.providers/16.koyeb.md +109 -0
  104. package/dist/docs/1.deploy/2.providers/17.netlify.md +47 -0
  105. package/dist/docs/1.deploy/2.providers/18.platform-sh.md +37 -0
  106. package/dist/docs/1.deploy/2.providers/19.render.md +37 -0
  107. package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +81 -0
  108. package/dist/docs/1.deploy/2.providers/20.stormkit.md +24 -0
  109. package/dist/docs/1.deploy/2.providers/21.vercel.md +270 -0
  110. package/dist/docs/1.deploy/2.providers/22.zeabur.md +19 -0
  111. package/dist/docs/1.deploy/2.providers/23.zephyr.md +99 -0
  112. package/dist/docs/1.deploy/2.providers/24.zerops.md +102 -0
  113. package/dist/docs/1.deploy/2.providers/3.azure.md +72 -0
  114. package/dist/docs/1.deploy/2.providers/4.cleavr.md +33 -0
  115. package/dist/docs/1.deploy/2.providers/5.cloudflare.md +369 -0
  116. package/dist/docs/1.deploy/2.providers/6.deno-deploy.md +66 -0
  117. package/dist/docs/1.deploy/2.providers/7.digitalocean.md +46 -0
  118. package/dist/docs/1.deploy/2.providers/8.edgeone.md +20 -0
  119. package/dist/docs/1.deploy/2.providers/9.firebase.md +32 -0
  120. package/dist/docs/2.config/0.index/index.md +1221 -0
  121. package/dist/docs/3.examples/0.index/index.md +3 -0
  122. package/dist/docs/3.examples/1.api-routes.md +145 -0
  123. package/dist/docs/3.examples/10.hono.md +74 -0
  124. package/dist/docs/3.examples/11.import-alias.md +97 -0
  125. package/dist/docs/3.examples/12.middleware.md +91 -0
  126. package/dist/docs/3.examples/13.mono-jsx.md +68 -0
  127. package/dist/docs/3.examples/14.nano-jsx.md +70 -0
  128. package/dist/docs/3.examples/15.plugins.md +91 -0
  129. package/dist/docs/3.examples/16.renderer.md +113 -0
  130. package/dist/docs/3.examples/17.runtime-config.md +97 -0
  131. package/dist/docs/3.examples/18.server-fetch.md +87 -0
  132. package/dist/docs/3.examples/19.shiki.md +198 -0
  133. package/dist/docs/3.examples/2.auto-imports.md +92 -0
  134. package/dist/docs/3.examples/20.virtual-routes.md +74 -0
  135. package/dist/docs/3.examples/21.vite-nitro-plugin.md +79 -0
  136. package/dist/docs/3.examples/22.vite-rsc.md +1041 -0
  137. package/dist/docs/3.examples/23.vite-ssr-html.md +217 -0
  138. package/dist/docs/3.examples/24.vite-ssr-preact.md +247 -0
  139. package/dist/docs/3.examples/25.vite-ssr-react.md +226 -0
  140. package/dist/docs/3.examples/26.vite-ssr-solid.md +256 -0
  141. package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +442 -0
  142. package/dist/docs/3.examples/28.vite-ssr-tss-react.md +444 -0
  143. package/dist/docs/3.examples/29.vite-ssr-vue-router.md +617 -0
  144. package/dist/docs/3.examples/3.cached-handler.md +81 -0
  145. package/dist/docs/3.examples/30.vite-trpc.md +335 -0
  146. package/dist/docs/3.examples/31.websocket.md +282 -0
  147. package/dist/docs/3.examples/4.custom-error-handler.md +98 -0
  148. package/dist/docs/3.examples/5.database.md +157 -0
  149. package/dist/docs/3.examples/6.elysia.md +70 -0
  150. package/dist/docs/3.examples/7.express.md +78 -0
  151. package/dist/docs/3.examples/8.fastify.md +79 -0
  152. package/dist/docs/3.examples/9.hello-world.md +68 -0
  153. package/dist/docs/README.md +86 -0
  154. package/dist/docs/index.md +121 -0
  155. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
  156. package/dist/node_modules/@poppinss/dumper/package.json +1 -1
  157. package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -4
  158. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
  159. package/dist/node_modules/@speed-highlight/core/package.json +1 -1
  160. package/dist/node_modules/cookie-es/dist/index.mjs +299 -250
  161. package/dist/node_modules/cookie-es/package.json +26 -23
  162. package/dist/node_modules/croner/dist/croner.js +1 -1
  163. package/dist/node_modules/croner/package.json +11 -1
  164. package/dist/node_modules/defu/dist/defu.mjs +2 -2
  165. package/dist/node_modules/defu/package.json +33 -28
  166. package/dist/node_modules/rendu/dist/_chunks/libs/cookie-es.mjs +151 -0
  167. package/dist/node_modules/rendu/dist/index.mjs +5 -112
  168. package/dist/node_modules/rendu/package.json +25 -24
  169. package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
  170. package/dist/node_modules/youch/build/index.js +204 -351
  171. package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
  172. package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
  173. package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
  174. package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
  175. package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
  176. package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
  177. package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
  178. package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
  179. package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
  180. package/dist/node_modules/youch/package.json +35 -32
  181. package/dist/presets/_nitro/runtime/nitro-dev.mjs +12 -57
  182. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
  183. package/dist/presets/_nitro/runtime/service-worker.mjs +1 -2
  184. package/dist/presets/aws-lambda/runtime/_utils.mjs +6 -6
  185. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
  186. package/dist/presets/azure/runtime/_utils.mjs +5 -5
  187. package/dist/presets/azure/runtime/azure-swa.mjs +5 -5
  188. package/dist/presets/bun/runtime/bun.mjs +9 -6
  189. package/dist/presets/cloudflare/runtime/_module-handler.mjs +1 -1
  190. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +4 -4
  191. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +3 -3
  192. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +2 -2
  193. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +10 -21
  194. package/dist/presets/deno/runtime/deno-deploy.mjs +4 -4
  195. package/dist/presets/deno/runtime/deno-server.mjs +9 -6
  196. package/dist/presets/edgeone/runtime/edgeone.mjs +10 -0
  197. package/dist/presets/netlify/runtime/netlify-edge.mjs +2 -3
  198. package/dist/presets/netlify/runtime/netlify.mjs +1 -1
  199. package/dist/presets/node/runtime/node-cluster.mjs +5 -4
  200. package/dist/presets/node/runtime/node-middleware.mjs +1 -1
  201. package/dist/presets/node/runtime/node-server.mjs +8 -5
  202. package/dist/presets/stormkit/runtime/stormkit.mjs +1 -2
  203. package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
  204. package/dist/presets/vercel/runtime/queue-handler.mjs +21 -0
  205. package/dist/presets/vercel/runtime/vercel.node.mjs +3 -3
  206. package/dist/presets/vercel/runtime/vercel.web.mjs +3 -5
  207. package/dist/presets/winterjs/runtime/winterjs.mjs +10 -10
  208. package/dist/presets/zephyr/runtime/server.mjs +3 -0
  209. package/dist/runtime/internal/app.mjs +12 -11
  210. package/dist/runtime/internal/cache.d.mts +0 -4
  211. package/dist/runtime/internal/cache.mjs +32 -256
  212. package/dist/runtime/internal/context.d.mts +3 -1
  213. package/dist/runtime/internal/context.mjs +1 -9
  214. package/dist/runtime/internal/error/dev.d.mts +5 -4
  215. package/dist/runtime/internal/error/dev.mjs +47 -49
  216. package/dist/runtime/internal/error/hooks.d.mts +1 -1
  217. package/dist/runtime/internal/error/prod.d.mts +2 -5
  218. package/dist/runtime/internal/error/prod.mjs +19 -33
  219. package/dist/runtime/internal/error/utils.d.mts +4 -4
  220. package/dist/runtime/internal/meta.d.mts +1 -1
  221. package/dist/runtime/internal/plugin.d.mts +2 -2
  222. package/dist/runtime/internal/route-rules.d.mts +11 -4
  223. package/dist/runtime/internal/route-rules.mjs +15 -5
  224. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
  225. package/dist/runtime/internal/routes/dev-tasks.mjs +15 -10
  226. package/dist/runtime/internal/routes/openapi.mjs +2 -2
  227. package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
  228. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
  229. package/dist/runtime/internal/routes/scalar.mjs +3 -3
  230. package/dist/runtime/internal/routes/swagger.mjs +7 -4
  231. package/dist/runtime/internal/runtime-config.d.mts +1 -1
  232. package/dist/runtime/internal/runtime-config.mjs +2 -2
  233. package/dist/runtime/internal/static.mjs +5 -4
  234. package/dist/runtime/internal/task.d.mts +3 -1
  235. package/dist/runtime/internal/task.mjs +7 -7
  236. package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
  237. package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
  238. package/dist/runtime/meta.d.mts +1 -0
  239. package/dist/runtime/meta.mjs +2 -0
  240. package/dist/runtime/nitro.d.mts +2 -0
  241. package/dist/runtime/nitro.mjs +4 -2
  242. package/dist/runtime/virtual/error-handler.mjs +1 -1
  243. package/dist/runtime/virtual/renderer-template.mjs +1 -1
  244. package/dist/runtime/virtual/server-assets.d.mts +2 -1
  245. package/dist/runtime/virtual/tracing.d.mts +5 -0
  246. package/dist/runtime/virtual/tracing.mjs +1 -0
  247. package/dist/runtime/vite.d.mts +1 -1
  248. package/dist/types/index.d.mts +215 -195
  249. package/dist/types/index.mjs +1 -11
  250. package/dist/vite.d.mts +3 -8
  251. package/dist/vite.mjs +285 -253
  252. package/lib/tsconfig.json +3 -5
  253. package/package.json +97 -80
  254. package/dist/_libs/confbox.mjs +0 -2509
  255. package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
  256. package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
  257. package/dist/node_modules/hookable/dist/index.mjs +0 -266
  258. package/dist/node_modules/hookable/package.json +0 -52
  259. package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
  260. package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
  261. package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
  262. package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
  263. package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
  264. package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
  265. package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
  266. package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
  267. package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
  268. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
  269. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
  270. package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
  271. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
  272. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
  273. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
  274. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
  275. package/dist/presets/azure/runtime/_utils.d.mts +0 -2
  276. package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
  277. package/dist/presets/bun/runtime/bun.d.mts +0 -3
  278. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
  279. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
  280. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
  281. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
  282. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
  283. package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
  284. package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
  285. package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
  286. package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
  287. package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
  288. package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
  289. package/dist/presets/node/runtime/node-server.d.mts +0 -3
  290. package/dist/presets/standard/runtime/server.d.mts +0 -3
  291. package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
  292. package/dist/presets/vercel/runtime/isr.d.mts +0 -2
  293. package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
  294. package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
  295. package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
  296. package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
  297. package/dist/runtime/internal/vite/node-runner.mjs +0 -359
@@ -1,24 +1,13 @@
1
- import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "../_common.mjs";
2
- import { E as parse$1, P as require_picomatch, S as MagicString, T as Parser, at as join$1, b as getMagicString, ct as resolve$1, it as isAbsolute$2, y as createUnimport } from "../_build/common.mjs";
1
+ import { i as __toESM } from "../_common.mjs";
2
+ import { N as require_picomatch, S as MagicString, T as parse$1, b as getMagicString, ct as join$1, dt as resolve$1, st as isAbsolute$2, y as createUnimport } from "../_build/common.mjs";
3
3
  import { t as walk } from "./estree-walker.mjs";
4
4
  import { t as remapping } from "./remapping.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import fs, { promises } from "node:fs";
7
- import "node:fs/promises";
8
- import { fileURLToPath } from "node:url";
9
- import "node:os";
10
7
  import path, { basename, dirname, extname, isAbsolute, normalize, resolve } from "node:path";
11
8
  import process$1 from "node:process";
12
- import "scule";
13
9
  import { Buffer } from "node:buffer";
14
10
  import * as querystring from "node:querystring";
15
-
16
- //#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/chunks/detect-acorn.mjs
17
- var detect_acorn_exports = /* @__PURE__ */ __exportAll({
18
- createVirtualImportsAcronWalker: () => createVirtualImportsAcronWalker,
19
- detectImportsAcorn: () => detectImportsAcorn,
20
- traveseScopes: () => traveseScopes
21
- });
22
11
  async function detectImportsAcorn(code, ctx, options) {
23
12
  const s = getMagicString(code);
24
13
  const map = await ctx.getImportMap();
@@ -71,7 +60,7 @@ function traveseScopes(ast, additionalWalk) {
71
60
  }
72
61
  function popScope(node) {
73
62
  if (scopesStack.pop()?.node !== node) throw new Error("Scope mismatch");
74
- scopeCurrent = scopesStack[scopesStack.length - 1];
63
+ scopeCurrent = scopesStack.at(-1);
75
64
  }
76
65
  pushScope(void 0);
77
66
  walk(ast, {
@@ -201,9 +190,6 @@ function createVirtualImportsAcronWalker(importMap, virtualImports = []) {
201
190
  } }
202
191
  };
203
192
  }
204
-
205
- //#endregion
206
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-Csj9j3eN.js
207
193
  var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
208
194
  function toArray$2(array) {
209
195
  array = array || [];
@@ -211,16 +197,16 @@ function toArray$2(array) {
211
197
  return [array];
212
198
  }
213
199
  const BACKSLASH_REGEX = /\\/g;
214
- function normalize$1(path$1) {
215
- return path$1.replace(BACKSLASH_REGEX, "/");
200
+ function normalize$1(path) {
201
+ return path.replace(BACKSLASH_REGEX, "/");
216
202
  }
217
203
  const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
218
- function isAbsolute$1(path$1) {
219
- return ABSOLUTE_PATH_REGEX.test(path$1);
204
+ function isAbsolute$1(path) {
205
+ return ABSOLUTE_PATH_REGEX.test(path);
220
206
  }
221
- function getMatcherString$1(glob, cwd$1) {
207
+ function getMatcherString$1(glob, cwd) {
222
208
  if (glob.startsWith("**") || isAbsolute$1(glob)) return normalize$1(glob);
223
- return normalize$1(resolve(cwd$1, glob));
209
+ return normalize$1(resolve(cwd, glob));
224
210
  }
225
211
  function patternToIdFilter(pattern) {
226
212
  if (pattern instanceof RegExp) return (id) => {
@@ -304,16 +290,8 @@ function normalizeObjectHook(name, hook) {
304
290
  };
305
291
  }
306
292
  function parse(code, opts = {}) {
307
- return Parser.parse(code, {
308
- sourceType: "module",
309
- ecmaVersion: "latest",
310
- locations: true,
311
- ...opts
312
- });
293
+ throw new Error("Parse implementation is not set. Please call setParseImpl first.");
313
294
  }
314
-
315
- //#endregion
316
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/webpack-like-DFGTNSuV.js
317
295
  function transformUse(data, plugin, transformLoader) {
318
296
  if (data.resource == null) return [];
319
297
  const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
@@ -326,24 +304,11 @@ function transformUse(data, plugin, transformLoader) {
326
304
  ident: plugin.name
327
305
  }];
328
306
  }
329
- /**
330
- * Normalizes a given path when it's absolute. Normalizing means returning a new path by converting
331
- * the input path to the native os format. This is useful in cases where we want to normalize
332
- * the `id` argument of a hook. Any absolute ids should be in the default format
333
- * of the operating system. Any relative imports or node_module imports should remain
334
- * untouched.
335
- *
336
- * @param path - Path to normalize.
337
- * @returns a new normalized path.
338
- */
339
- function normalizeAbsolutePath(path$1) {
340
- if (isAbsolute(path$1)) return normalize(path$1);
341
- else return path$1;
342
- }
343
-
344
- //#endregion
345
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-DkYlx1xL.js
346
- function createBuildContext$1(compiler, compilation, loaderContext, inputSourceMap) {
307
+ function normalizeAbsolutePath(path) {
308
+ if (isAbsolute(path)) return normalize(path);
309
+ else return path;
310
+ }
311
+ function createBuildContext$3(compiler, compilation, loaderContext, inputSourceMap) {
347
312
  return {
348
313
  getNativeBuildContext() {
349
314
  return {
@@ -355,8 +320,9 @@ function createBuildContext$1(compiler, compilation, loaderContext, inputSourceM
355
320
  };
356
321
  },
357
322
  addWatchFile(file) {
358
- const cwd$1 = process.cwd();
359
- compilation.fileDependencies.add(resolve(cwd$1, file));
323
+ const resolvedPath = resolve(process.cwd(), file);
324
+ compilation.fileDependencies.add(resolvedPath);
325
+ loaderContext?.addDependency(resolvedPath);
360
326
  },
361
327
  getWatchFiles() {
362
328
  return Array.from(compilation.fileDependencies);
@@ -371,7 +337,7 @@ function createBuildContext$1(compiler, compilation, loaderContext, inputSourceM
371
337
  }
372
338
  };
373
339
  }
374
- function normalizeMessage$1(error) {
340
+ function normalizeMessage$2(error) {
375
341
  const err = new Error(typeof error === "string" ? error : error.message);
376
342
  if (typeof error === "object") {
377
343
  err.stack = error.stack;
@@ -379,9 +345,6 @@ function normalizeMessage$1(error) {
379
345
  }
380
346
  return err;
381
347
  }
382
-
383
- //#endregion
384
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/utils-BosfZ0pB.js
385
348
  function encodeVirtualModuleId(id, plugin) {
386
349
  return resolve(plugin.__virtualModulePrefix, encodeURIComponent(id));
387
350
  }
@@ -415,23 +378,20 @@ var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin {
415
378
  const counter = FakeVirtualModulesPlugin.counters.get(dir) ?? 0;
416
379
  FakeVirtualModulesPlugin.counters.set(dir, counter + 1);
417
380
  compiler.hooks.shutdown.tap(this.name, () => {
418
- const counter$1 = (FakeVirtualModulesPlugin.counters.get(dir) ?? 1) - 1;
419
- if (counter$1 === 0) {
381
+ const counter = (FakeVirtualModulesPlugin.counters.get(dir) ?? 1) - 1;
382
+ if (counter === 0) {
420
383
  FakeVirtualModulesPlugin.counters.delete(dir);
421
384
  fs.rmSync(dir, {
422
385
  recursive: true,
423
386
  force: true
424
387
  });
425
- } else FakeVirtualModulesPlugin.counters.set(dir, counter$1);
388
+ } else FakeVirtualModulesPlugin.counters.set(dir, counter);
426
389
  });
427
390
  }
428
391
  async writeModule(file) {
429
392
  return fs.promises.writeFile(file, "");
430
393
  }
431
394
  };
432
-
433
- //#endregion
434
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-OCFO8EW1.js
435
395
  function contextOptionsFromCompilation(compilation) {
436
396
  return {
437
397
  addWatchFile(file) {
@@ -442,11 +402,11 @@ function contextOptionsFromCompilation(compilation) {
442
402
  }
443
403
  };
444
404
  }
445
- const require$1 = createRequire(import.meta.url);
405
+ const require = createRequire(import.meta.url);
446
406
  function getSource(fileSource) {
447
- return new (require$1("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer));
407
+ return new (require("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer));
448
408
  }
449
- function createBuildContext(options, compiler, compilation, loaderContext, inputSourceMap) {
409
+ function createBuildContext$2(options, compiler, compilation, loaderContext, inputSourceMap) {
450
410
  return {
451
411
  parse,
452
412
  addWatchFile(id) {
@@ -473,7 +433,7 @@ function createBuildContext(options, compiler, compilation, loaderContext, input
473
433
  }
474
434
  };
475
435
  }
476
- function normalizeMessage(error) {
436
+ function normalizeMessage$1(error) {
477
437
  const err = new Error(typeof error === "string" ? error : error.message);
478
438
  if (typeof error === "object") {
479
439
  err.stack = error.stack;
@@ -481,279 +441,203 @@ function normalizeMessage(error) {
481
441
  }
482
442
  return err;
483
443
  }
484
-
485
- //#endregion
486
- //#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.js
487
- var require_virtual_stats = /* @__PURE__ */ __commonJSMin(((exports) => {
488
- var __importDefault = exports && exports.__importDefault || function(mod) {
489
- return mod && mod.__esModule ? mod : { "default": mod };
490
- };
491
- Object.defineProperty(exports, "__esModule", { value: true });
492
- exports.VirtualStats = void 0;
493
- const constants_1 = __importDefault(__require("constants"));
494
- var VirtualStats = class {
495
- constructor(config) {
496
- for (const key in config) {
497
- if (!Object.prototype.hasOwnProperty.call(config, key)) continue;
498
- this[key] = config[key];
444
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
445
+ const ExtToLoader$1 = {
446
+ ".js": "js",
447
+ ".mjs": "js",
448
+ ".cjs": "js",
449
+ ".jsx": "jsx",
450
+ ".ts": "ts",
451
+ ".cts": "ts",
452
+ ".mts": "ts",
453
+ ".tsx": "tsx",
454
+ ".css": "css",
455
+ ".less": "css",
456
+ ".stylus": "css",
457
+ ".scss": "css",
458
+ ".sass": "css",
459
+ ".json": "json",
460
+ ".txt": "text"
461
+ };
462
+ function guessLoader$1(id) {
463
+ return ExtToLoader$1[path.extname(id).toLowerCase()] || "js";
464
+ }
465
+ function createBuildContext$1(build) {
466
+ const watchFiles = [];
467
+ return {
468
+ addWatchFile(file) {
469
+ watchFiles.push(file);
470
+ },
471
+ getWatchFiles() {
472
+ return watchFiles;
473
+ },
474
+ emitFile(emittedFile) {
475
+ const outFileName = emittedFile.fileName || emittedFile.name;
476
+ const outdir = build?.config?.outdir;
477
+ if (outdir && emittedFile.source && outFileName) {
478
+ const outPath = path.resolve(outdir, outFileName);
479
+ const outDir = path.dirname(outPath);
480
+ if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
481
+ fs.writeFileSync(outPath, emittedFile.source);
499
482
  }
500
- }
501
- _checkModeProperty(property) {
502
- return (this.mode & constants_1.default.S_IFMT) === property;
503
- }
504
- isDirectory() {
505
- return this._checkModeProperty(constants_1.default.S_IFDIR);
506
- }
507
- isFile() {
508
- return this._checkModeProperty(constants_1.default.S_IFREG);
509
- }
510
- isBlockDevice() {
511
- return this._checkModeProperty(constants_1.default.S_IFBLK);
512
- }
513
- isCharacterDevice() {
514
- return this._checkModeProperty(constants_1.default.S_IFCHR);
515
- }
516
- isSymbolicLink() {
517
- return this._checkModeProperty(constants_1.default.S_IFLNK);
518
- }
519
- isFIFO() {
520
- return this._checkModeProperty(constants_1.default.S_IFIFO);
521
- }
522
- isSocket() {
523
- return this._checkModeProperty(constants_1.default.S_IFSOCK);
483
+ },
484
+ parse,
485
+ getNativeBuildContext() {
486
+ return {
487
+ framework: "bun",
488
+ build
489
+ };
524
490
  }
525
491
  };
526
- exports.VirtualStats = VirtualStats;
527
- }));
528
-
529
- //#endregion
530
- //#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.js
531
- var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
532
- const path_1 = (exports && exports.__importDefault || function(mod) {
533
- return mod && mod.__esModule ? mod : { "default": mod };
534
- })(__require("path"));
535
- const virtual_stats_1 = require_virtual_stats();
536
- let inode = 45e6;
537
- const ALL = "all";
538
- const STATIC = "static";
539
- const DYNAMIC = "dynamic";
540
- function checkActivation(instance) {
541
- if (!instance._compiler) throw new Error("You must use this plugin only after creating webpack instance!");
542
- }
543
- function getModulePath(filePath, compiler) {
544
- return path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(compiler.context, filePath);
545
- }
546
- function createWebpackData(result) {
547
- return (backendOrStorage) => {
548
- if (backendOrStorage._data) {
549
- const curLevelIdx = backendOrStorage._currentLevel;
550
- return {
551
- result,
552
- level: backendOrStorage._levels[curLevelIdx]
553
- };
492
+ }
493
+ function createPluginContext$1(buildContext) {
494
+ const errors = [];
495
+ const warnings = [];
496
+ return {
497
+ errors,
498
+ warnings,
499
+ mixedContext: {
500
+ ...buildContext,
501
+ error(error) {
502
+ errors.push(error);
503
+ },
504
+ warn(warning) {
505
+ warnings.push(warning);
554
506
  }
555
- return [null, result];
556
- };
557
- }
558
- function getData(storage, key) {
559
- if (storage._data instanceof Map) return storage._data.get(key);
560
- else if (storage._data) return storage.data[key];
561
- else if (storage.data instanceof Map) return storage.data.get(key);
562
- else return storage.data[key];
563
- }
564
- function setData(backendOrStorage, key, valueFactory) {
565
- const value = valueFactory(backendOrStorage);
566
- if (backendOrStorage._data instanceof Map) backendOrStorage._data.set(key, value);
567
- else if (backendOrStorage._data) backendOrStorage.data[key] = value;
568
- else if (backendOrStorage.data instanceof Map) backendOrStorage.data.set(key, value);
569
- else backendOrStorage.data[key] = value;
570
- }
571
- function getStatStorage(fileSystem) {
572
- if (fileSystem._statStorage) return fileSystem._statStorage;
573
- else if (fileSystem._statBackend) return fileSystem._statBackend;
574
- else throw new Error("Couldn't find a stat storage");
575
- }
576
- function getFileStorage(fileSystem) {
577
- if (fileSystem._readFileStorage) return fileSystem._readFileStorage;
578
- else if (fileSystem._readFileBackend) return fileSystem._readFileBackend;
579
- else throw new Error("Couldn't find a readFileStorage");
580
- }
581
- function getReadDirBackend(fileSystem) {
582
- if (fileSystem._readdirBackend) return fileSystem._readdirBackend;
583
- else if (fileSystem._readdirStorage) return fileSystem._readdirStorage;
584
- else throw new Error("Couldn't find a readDirStorage from Webpack Internals");
585
- }
586
- function getRealpathBackend(fileSystem) {
587
- if (fileSystem._realpathBackend) return fileSystem._realpathBackend;
588
- }
589
- var VirtualModulesPlugin = class {
590
- constructor(modules) {
591
- this._compiler = null;
592
- this._watcher = null;
593
- this._staticModules = modules || null;
594
507
  }
595
- getModuleList(filter = ALL) {
596
- var _a, _b;
597
- let modules = {};
598
- const shouldGetStaticModules = filter === ALL || filter === STATIC;
599
- const shouldGetDynamicModules = filter === ALL || filter === DYNAMIC;
600
- if (shouldGetStaticModules) modules = Object.assign(Object.assign({}, modules), this._staticModules);
601
- if (shouldGetDynamicModules) {
602
- const finalInputFileSystem = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.inputFileSystem;
603
- const virtualFiles = (_b = finalInputFileSystem === null || finalInputFileSystem === void 0 ? void 0 : finalInputFileSystem._virtualFiles) !== null && _b !== void 0 ? _b : {};
604
- const dynamicModules = {};
605
- Object.keys(virtualFiles).forEach((key) => {
606
- dynamicModules[key] = virtualFiles[key].contents;
508
+ };
509
+ }
510
+ function getBunPlugin(factory) {
511
+ return (userOptions) => {
512
+ if (typeof Bun === "undefined") throw new ReferenceError("Bun is not supported in this environment");
513
+ if (!Bun.semver.satisfies(Bun.version, ">=1.2.22")) throw new Error("Bun 1.2.22 or higher is required, please upgrade Bun");
514
+ const meta = { framework: "bun" };
515
+ const plugins = toArray$2(factory(userOptions, meta));
516
+ return {
517
+ name: (plugins.length === 1 ? plugins[0].name : meta.bunHostName) ?? `unplugin-host:${plugins.map((p) => p.name).join(":")}`,
518
+ async setup(build) {
519
+ const context = createBuildContext$1(build);
520
+ if (plugins.some((plugin) => plugin.buildStart)) build.onStart(async () => {
521
+ for (const plugin of plugins) if (plugin.buildStart) await plugin.buildStart.call(context);
607
522
  });
608
- modules = Object.assign(Object.assign({}, modules), dynamicModules);
609
- }
610
- return modules;
611
- }
612
- writeModule(filePath, contents) {
613
- if (!this._compiler) throw new Error(`Plugin has not been initialized`);
614
- checkActivation(this);
615
- const len = contents ? contents.length : 0;
616
- const time = Date.now();
617
- const date = new Date(time);
618
- const stats = new virtual_stats_1.VirtualStats({
619
- dev: 8675309,
620
- nlink: 0,
621
- uid: 1e3,
622
- gid: 1e3,
623
- rdev: 0,
624
- blksize: 4096,
625
- ino: inode++,
626
- mode: 33188,
627
- size: len,
628
- blocks: Math.floor(len / 4096),
629
- atime: date,
630
- mtime: date,
631
- ctime: date,
632
- birthtime: date
633
- });
634
- const modulePath = getModulePath(filePath, this._compiler);
635
- if (process.env.WVM_DEBUG) console.log(this._compiler.name, "Write virtual module:", modulePath, contents);
636
- let finalWatchFileSystem = this._watcher && this._watcher.watchFileSystem;
637
- while (finalWatchFileSystem && finalWatchFileSystem.wfs) finalWatchFileSystem = finalWatchFileSystem.wfs;
638
- let finalInputFileSystem = this._compiler.inputFileSystem;
639
- while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
640
- finalInputFileSystem._writeVirtualFile(modulePath, stats, contents);
641
- if (finalWatchFileSystem && finalWatchFileSystem.watcher && (finalWatchFileSystem.watcher.fileWatchers.size || finalWatchFileSystem.watcher.fileWatchers.length)) {
642
- const fileWatchers = finalWatchFileSystem.watcher.fileWatchers instanceof Map ? Array.from(finalWatchFileSystem.watcher.fileWatchers.values()) : finalWatchFileSystem.watcher.fileWatchers;
643
- for (let fileWatcher of fileWatchers) {
644
- if ("watcher" in fileWatcher) fileWatcher = fileWatcher.watcher;
645
- if (fileWatcher.path === modulePath) {
646
- if (process.env.DEBUG) console.log(this._compiler.name, "Emit file change:", modulePath, time);
647
- delete fileWatcher.directoryWatcher._cachedTimeInfoEntries;
648
- fileWatcher.emit("change", time, null);
523
+ const resolveIdHooks = plugins.filter((plugin) => plugin.resolveId).map((plugin) => ({
524
+ plugin,
525
+ ...normalizeObjectHook("resolveId", plugin.resolveId)
526
+ }));
527
+ const loadHooks = plugins.filter((plugin) => plugin.load).map((plugin) => ({
528
+ plugin,
529
+ ...normalizeObjectHook("load", plugin.load)
530
+ }));
531
+ const transformHooks = plugins.filter((plugin) => plugin.transform || plugin.transformInclude).map((plugin) => ({
532
+ plugin,
533
+ ...normalizeObjectHook("transform", plugin.transform)
534
+ }));
535
+ const virtualModulePlugins = /* @__PURE__ */ new Set();
536
+ for (const plugin of plugins) if (plugin.resolveId && plugin.load) virtualModulePlugins.add(plugin.name);
537
+ if (resolveIdHooks.length) build.onResolve({ filter: /.*/ }, async (args) => {
538
+ if (build.config?.external?.includes(args.path)) return;
539
+ for (const { plugin, handler, filter } of resolveIdHooks) {
540
+ if (!filter(args.path)) continue;
541
+ const { mixedContext, errors, warnings } = createPluginContext$1(context);
542
+ const isEntry = args.kind === "entry-point-run" || args.kind === "entry-point-build";
543
+ const result = await handler.call(mixedContext, args.path, isEntry ? void 0 : args.importer, { isEntry });
544
+ for (const warning of warnings) console.warn("[unplugin]", typeof warning === "string" ? warning : warning.message);
545
+ if (errors.length > 0) {
546
+ const errorMessage = errors.map((e) => typeof e === "string" ? e : e.message).join("\n");
547
+ throw new Error(`[unplugin] ${plugin.name}: ${errorMessage}`);
548
+ }
549
+ if (typeof result === "string") {
550
+ if (!isAbsolute(result)) return {
551
+ path: result,
552
+ namespace: plugin.name
553
+ };
554
+ return { path: result };
555
+ } else if (typeof result === "object" && result !== null) {
556
+ if (!isAbsolute(result.id)) return {
557
+ path: result.id,
558
+ external: result.external,
559
+ namespace: plugin.name
560
+ };
561
+ return {
562
+ path: result.id,
563
+ external: result.external
564
+ };
565
+ }
649
566
  }
650
- }
651
- }
652
- }
653
- apply(compiler) {
654
- this._compiler = compiler;
655
- const afterEnvironmentHook = () => {
656
- let finalInputFileSystem = compiler.inputFileSystem;
657
- while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
658
- if (!finalInputFileSystem._writeVirtualFile) {
659
- const originalPurge = finalInputFileSystem.purge;
660
- finalInputFileSystem.purge = () => {
661
- originalPurge.apply(finalInputFileSystem, []);
662
- if (finalInputFileSystem._virtualFiles) Object.keys(finalInputFileSystem._virtualFiles).forEach((file) => {
663
- const data = finalInputFileSystem._virtualFiles[file];
664
- finalInputFileSystem._writeVirtualFile(file, data.stats, data.contents);
665
- });
666
- };
667
- finalInputFileSystem._writeVirtualFile = (file, stats, contents) => {
668
- const statStorage = getStatStorage(finalInputFileSystem);
669
- const fileStorage = getFileStorage(finalInputFileSystem);
670
- const readDirStorage = getReadDirBackend(finalInputFileSystem);
671
- const realPathStorage = getRealpathBackend(finalInputFileSystem);
672
- finalInputFileSystem._virtualFiles = finalInputFileSystem._virtualFiles || {};
673
- finalInputFileSystem._virtualFiles[file] = {
674
- stats,
675
- contents
676
- };
677
- setData(statStorage, file, createWebpackData(stats));
678
- setData(fileStorage, file, createWebpackData(contents));
679
- const segments = file.split(/[\\/]/);
680
- let count = segments.length - 1;
681
- const minCount = segments[0] ? 1 : 0;
682
- while (count > minCount) {
683
- const dir = segments.slice(0, count).join(path_1.default.sep) || path_1.default.sep;
684
- try {
685
- finalInputFileSystem.readdirSync(dir);
686
- } catch (e) {
687
- const time = Date.now();
688
- const dirStats = new virtual_stats_1.VirtualStats({
689
- dev: 8675309,
690
- nlink: 0,
691
- uid: 1e3,
692
- gid: 1e3,
693
- rdev: 0,
694
- blksize: 4096,
695
- ino: inode++,
696
- mode: 16877,
697
- size: stats.size,
698
- blocks: Math.floor(stats.size / 4096),
699
- atime: time,
700
- mtime: time,
701
- ctime: time,
702
- birthtime: time
703
- });
704
- setData(readDirStorage, dir, createWebpackData([]));
705
- if (realPathStorage) setData(realPathStorage, dir, createWebpackData(dir));
706
- setData(statStorage, dir, createWebpackData(dirStats));
567
+ });
568
+ async function processLoadTransform(id, namespace, loader) {
569
+ let code;
570
+ let hasResult = false;
571
+ const namespaceLoadHooks = namespace === "file" ? loadHooks : loadHooks.filter((h) => h.plugin.name === namespace);
572
+ for (const { plugin, handler, filter } of namespaceLoadHooks) {
573
+ if (plugin.loadInclude && !plugin.loadInclude(id)) continue;
574
+ if (!filter(id)) continue;
575
+ const { mixedContext, errors, warnings } = createPluginContext$1(context);
576
+ const result = await handler.call(mixedContext, id);
577
+ for (const warning of warnings) console.warn("[unplugin]", typeof warning === "string" ? warning : warning.message);
578
+ if (errors.length > 0) {
579
+ const errorMessage = errors.map((e) => typeof e === "string" ? e : e.message).join("\n");
580
+ throw new Error(`[unplugin] ${plugin.name}: ${errorMessage}`);
581
+ }
582
+ if (typeof result === "string") {
583
+ code = result;
584
+ hasResult = true;
585
+ break;
586
+ } else if (typeof result === "object" && result !== null) {
587
+ code = result.code;
588
+ hasResult = true;
589
+ break;
590
+ }
591
+ }
592
+ if (!hasResult && namespace === "file" && transformHooks.length > 0) code = await Bun.file(id).text();
593
+ if (code !== void 0) {
594
+ const namespaceTransformHooks = namespace === "file" ? transformHooks : transformHooks.filter((h) => h.plugin.name === namespace);
595
+ for (const { plugin, handler, filter } of namespaceTransformHooks) {
596
+ if (plugin.transformInclude && !plugin.transformInclude(id)) continue;
597
+ if (!filter(id, code)) continue;
598
+ const { mixedContext, errors, warnings } = createPluginContext$1(context);
599
+ const result = await handler.call(mixedContext, code, id);
600
+ for (const warning of warnings) console.warn("[unplugin]", typeof warning === "string" ? warning : warning.message);
601
+ if (errors.length > 0) {
602
+ const errorMessage = errors.map((e) => typeof e === "string" ? e : e.message).join("\n");
603
+ throw new Error(`[unplugin] ${plugin.name}: ${errorMessage}`);
604
+ }
605
+ if (typeof result === "string") {
606
+ code = result;
607
+ hasResult = true;
608
+ } else if (typeof result === "object" && result !== null) {
609
+ code = result.code;
610
+ hasResult = true;
707
611
  }
708
- let dirData = getData(getReadDirBackend(finalInputFileSystem), dir);
709
- dirData = dirData[1] || dirData.result;
710
- const filename = segments[count];
711
- if (dirData.indexOf(filename) < 0) {
712
- const files = dirData.concat([filename]).sort();
713
- setData(getReadDirBackend(finalInputFileSystem), dir, createWebpackData(files));
714
- } else break;
715
- count--;
716
612
  }
613
+ }
614
+ if (hasResult && code !== void 0) return {
615
+ contents: code,
616
+ loader: loader ?? guessLoader$1(id)
717
617
  };
718
618
  }
719
- };
720
- const afterResolversHook = () => {
721
- if (this._staticModules) {
722
- for (const [filePath, contents] of Object.entries(this._staticModules)) this.writeModule(filePath, contents);
723
- this._staticModules = null;
724
- }
725
- };
726
- const version = typeof compiler.webpack === "undefined" ? 4 : 5;
727
- const watchRunHook = (watcher, callback) => {
728
- this._watcher = watcher.compiler || watcher;
729
- const virtualFiles = compiler.inputFileSystem._virtualFiles;
730
- const fts = compiler.fileTimestamps;
731
- if (virtualFiles && fts && typeof fts.set === "function") Object.keys(virtualFiles).forEach((file) => {
732
- const mtime = +virtualFiles[file].stats.mtime;
733
- fts.set(file, version === 4 ? mtime : {
734
- safeTime: mtime,
735
- timestamp: mtime
736
- });
619
+ if (loadHooks.length || transformHooks.length) build.onLoad({
620
+ filter: /.*/,
621
+ namespace: "file"
622
+ }, async (args) => {
623
+ return processLoadTransform(args.path, "file", args.loader);
624
+ });
625
+ for (const pluginName of virtualModulePlugins) build.onLoad({
626
+ filter: /.*/,
627
+ namespace: pluginName
628
+ }, async (args) => {
629
+ return processLoadTransform(args.path, pluginName, args.loader);
630
+ });
631
+ if (plugins.some((plugin) => plugin.buildEnd || plugin.writeBundle)) build.onEnd(async () => {
632
+ for (const plugin of plugins) {
633
+ if (plugin.buildEnd) await plugin.buildEnd.call(context);
634
+ if (plugin.writeBundle) await plugin.writeBundle();
635
+ }
737
636
  });
738
- callback();
739
- };
740
- if (compiler.hooks) {
741
- compiler.hooks.afterEnvironment.tap("VirtualModulesPlugin", afterEnvironmentHook);
742
- compiler.hooks.afterResolvers.tap("VirtualModulesPlugin", afterResolversHook);
743
- compiler.hooks.watchRun.tapAsync("VirtualModulesPlugin", watchRunHook);
744
- } else {
745
- compiler.plugin("after-environment", afterEnvironmentHook);
746
- compiler.plugin("after-resolvers", afterResolversHook);
747
- compiler.plugin("watch-run", watchRunHook);
748
637
  }
749
- }
638
+ };
750
639
  };
751
- module.exports = VirtualModulesPlugin;
752
- }));
753
-
754
- //#endregion
755
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/index.js
756
- var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
640
+ }
757
641
  const ExtToLoader = {
758
642
  ".js": "js",
759
643
  ".mjs": "js",
@@ -812,7 +696,7 @@ function combineSourcemaps(filename, sourcemapList) {
812
696
  if (!map.file) delete map.file;
813
697
  return map;
814
698
  }
815
- function createBuildContext$2(build) {
699
+ function createBuildContext(build) {
816
700
  const watchFiles = [];
817
701
  const { initialOptions } = build;
818
702
  return {
@@ -845,10 +729,10 @@ function createPluginContext(context) {
845
729
  const warnings = [];
846
730
  const pluginContext = {
847
731
  error(message) {
848
- errors.push(normalizeMessage$2(message));
732
+ errors.push(normalizeMessage(message));
849
733
  },
850
734
  warn(message) {
851
- warnings.push(normalizeMessage$2(message));
735
+ warnings.push(normalizeMessage(message));
852
736
  }
853
737
  };
854
738
  return {
@@ -863,7 +747,7 @@ function createPluginContext(context) {
863
747
  }
864
748
  };
865
749
  }
866
- function normalizeMessage$2(message) {
750
+ function normalizeMessage(message) {
867
751
  if (typeof message === "string") message = { message };
868
752
  return {
869
753
  id: message.id,
@@ -946,7 +830,7 @@ function getEsbuildPlugin(factory) {
946
830
  function buildSetup() {
947
831
  return (plugin) => {
948
832
  return (build, rawBuild) => {
949
- const context = createBuildContext$2(rawBuild);
833
+ const context = createBuildContext(rawBuild);
950
834
  const { onStart, onEnd, onResolve, onLoad, onTransform, initialOptions } = build;
951
835
  const onResolveFilter = plugin.esbuild?.onResolveFilter ?? /.*/;
952
836
  const onLoadFilter = plugin.esbuild?.onLoadFilter ?? /.*/;
@@ -1125,7 +1009,7 @@ function decodeStr(str) {
1125
1009
  if (firstIndex === -1) return str;
1126
1010
  const result = Array.from({ length: len - countBackslashZeros(str, firstIndex) });
1127
1011
  let pos = 0;
1128
- for (let i$1 = 0; i$1 < firstIndex; i$1++) result[pos++] = str[i$1];
1012
+ for (let i = 0; i < firstIndex; i++) result[pos++] = str[i];
1129
1013
  let i = firstIndex;
1130
1014
  while (i < len) if (str[i] === "\\" && str[i + 1] === "0") {
1131
1015
  result[pos++] = "\0";
@@ -1370,7 +1254,6 @@ function toRollupPlugin(plugin, key) {
1370
1254
  }
1371
1255
  }
1372
1256
  function supportNativeFilter(context, framework) {
1373
- if (framework === "unloader") return false;
1374
1257
  if (framework === "vite") return !!context?.meta?.viteVersion;
1375
1258
  if (framework === "rolldown") return true;
1376
1259
  const rollupVersion = context?.meta?.rollupVersion;
@@ -1386,11 +1269,8 @@ function getRolldownPlugin(factory) {
1386
1269
  return plugins.length === 1 ? plugins[0] : plugins;
1387
1270
  });
1388
1271
  }
1389
- const getFilename = () => fileURLToPath(import.meta.url);
1390
- const getDirname = () => path.dirname(getFilename());
1391
- const __dirname = /* @__PURE__ */ getDirname();
1392
- const TRANSFORM_LOADER$1 = resolve(__dirname, "rspack/loaders/transform");
1393
- const LOAD_LOADER$1 = resolve(__dirname, "rspack/loaders/load");
1272
+ const TRANSFORM_LOADER$1 = resolve(import.meta.dirname, "rspack/loaders/transform.mjs");
1273
+ const LOAD_LOADER$1 = resolve(import.meta.dirname, "rspack/loaders/load.mjs");
1394
1274
  function getRspackPlugin(factory) {
1395
1275
  return (userOptions) => {
1396
1276
  return { apply(compiler) {
@@ -1407,9 +1287,9 @@ function getRspackPlugin(factory) {
1407
1287
  });
1408
1288
  const externalModules = /* @__PURE__ */ new Set();
1409
1289
  if (plugin.resolveId) {
1410
- const createPlugin = (plugin$1) => {
1290
+ const createPlugin = (plugin) => {
1411
1291
  if (compiler.rspack.experiments.VirtualModulesPlugin) return new compiler.rspack.experiments.VirtualModulesPlugin();
1412
- return new FakeVirtualModulesPlugin(plugin$1);
1292
+ return new FakeVirtualModulesPlugin(plugin);
1413
1293
  };
1414
1294
  const vfs = createPlugin(plugin);
1415
1295
  vfs.apply(compiler);
@@ -1423,11 +1303,11 @@ function getRspackPlugin(factory) {
1423
1303
  let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
1424
1304
  const isEntry = requestContext.issuer === "";
1425
1305
  if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
1426
- const context = createBuildContext$1(compiler, compilation);
1306
+ const context = createBuildContext$3(compiler, compilation);
1427
1307
  let error;
1428
1308
  const pluginContext = {
1429
1309
  error(msg) {
1430
- if (error == null) error = normalizeMessage$1(msg);
1310
+ if (error == null) error = normalizeMessage$2(msg);
1431
1311
  else console.error(`unplugin/rspack: multiple errors returned from resolveId hook: ${msg}`);
1432
1312
  },
1433
1313
  warn(msg) {
@@ -1487,17 +1367,17 @@ function getRspackPlugin(factory) {
1487
1367
  });
1488
1368
  if (plugin.rspack) plugin.rspack(compiler);
1489
1369
  if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
1490
- const context = createBuildContext$1(compiler, compilation);
1370
+ const context = createBuildContext$3(compiler, compilation);
1491
1371
  if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
1492
- const promises$1 = [];
1493
- if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
1494
- if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
1495
- await Promise.all(promises$1);
1372
+ const promises = [];
1373
+ if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
1374
+ if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
1375
+ await Promise.all(promises);
1496
1376
  }
1497
1377
  if (plugin.buildStart) return await plugin.buildStart.call(context);
1498
1378
  });
1499
1379
  if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
1500
- await plugin.buildEnd.call(createBuildContext$1(compiler, compilation));
1380
+ await plugin.buildEnd.call(createBuildContext$3(compiler, compilation));
1501
1381
  });
1502
1382
  if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
1503
1383
  await plugin.writeBundle();
@@ -1522,10 +1402,11 @@ function getVitePlugin(factory) {
1522
1402
  return plugins.length === 1 ? plugins[0] : plugins;
1523
1403
  });
1524
1404
  }
1525
- const TRANSFORM_LOADER = resolve(__dirname, "webpack/loaders/transform");
1526
- const LOAD_LOADER = resolve(__dirname, "webpack/loaders/load");
1405
+ const TRANSFORM_LOADER = resolve(import.meta.dirname, "webpack/loaders/transform.mjs");
1406
+ const LOAD_LOADER = resolve(import.meta.dirname, "webpack/loaders/load.mjs");
1527
1407
  function getWebpackPlugin(factory) {
1528
1408
  return (userOptions) => {
1409
+ const VirtualModulesPlugin = __require("webpack-virtual-modules");
1529
1410
  return { apply(compiler) {
1530
1411
  const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process$1.cwd(), "_virtual_");
1531
1412
  const meta = {
@@ -1540,9 +1421,9 @@ function getWebpackPlugin(factory) {
1540
1421
  });
1541
1422
  const externalModules = /* @__PURE__ */ new Set();
1542
1423
  if (plugin.resolveId) {
1543
- let vfs = compiler.options.plugins.find((i) => i instanceof import_lib.default);
1424
+ let vfs = compiler.options.plugins.find((i) => i instanceof VirtualModulesPlugin);
1544
1425
  if (!vfs) {
1545
- vfs = new import_lib.default();
1426
+ vfs = new VirtualModulesPlugin();
1546
1427
  compiler.options.plugins.push(vfs);
1547
1428
  }
1548
1429
  const vfsModules = /* @__PURE__ */ new Set();
@@ -1559,7 +1440,7 @@ function getWebpackPlugin(factory) {
1559
1440
  const isEntry = requestContext.issuer === "";
1560
1441
  if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
1561
1442
  const fileDependencies = /* @__PURE__ */ new Set();
1562
- const context = createBuildContext({
1443
+ const context = createBuildContext$2({
1563
1444
  addWatchFile(file) {
1564
1445
  fileDependencies.add(file);
1565
1446
  resolveContext.fileDependencies?.add(file);
@@ -1571,7 +1452,7 @@ function getWebpackPlugin(factory) {
1571
1452
  let error;
1572
1453
  const pluginContext = {
1573
1454
  error(msg) {
1574
- if (error == null) error = normalizeMessage(msg);
1455
+ if (error == null) error = normalizeMessage$1(msg);
1575
1456
  else console.error(`unplugin/webpack: multiple errors returned from resolveId hook: ${msg}`);
1576
1457
  },
1577
1458
  warn(msg) {
@@ -1624,17 +1505,17 @@ function getWebpackPlugin(factory) {
1624
1505
  });
1625
1506
  if (plugin.webpack) plugin.webpack(compiler);
1626
1507
  if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
1627
- const context = createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation);
1508
+ const context = createBuildContext$2(contextOptionsFromCompilation(compilation), compiler, compilation);
1628
1509
  if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
1629
- const promises$1 = [];
1630
- if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
1631
- if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
1632
- await Promise.all(promises$1);
1510
+ const promises = [];
1511
+ if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
1512
+ if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
1513
+ await Promise.all(promises);
1633
1514
  }
1634
1515
  if (plugin.buildStart) return await plugin.buildStart.call(context);
1635
1516
  });
1636
1517
  if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
1637
- await plugin.buildEnd.call(createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation));
1518
+ await plugin.buildEnd.call(createBuildContext$2(contextOptionsFromCompilation(compilation), compiler, compilation));
1638
1519
  });
1639
1520
  if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
1640
1521
  await plugin.writeBundle();
@@ -1676,17 +1557,14 @@ function createUnplugin(factory) {
1676
1557
  get unloader() {
1677
1558
  return getUnloaderPlugin(factory);
1678
1559
  },
1560
+ get bun() {
1561
+ return getBunPlugin(factory);
1562
+ },
1679
1563
  get raw() {
1680
1564
  return factory;
1681
1565
  }
1682
1566
  };
1683
1567
  }
1684
-
1685
- //#endregion
1686
- //#region node_modules/.pnpm/unplugin-utils@0.3.1/node_modules/unplugin-utils/dist/index.js
1687
- /**
1688
- * Converts path separators to forward slash.
1689
- */
1690
1568
  function normalizePath(filename) {
1691
1569
  return filename.replaceAll("\\", "/");
1692
1570
  }
@@ -1701,18 +1579,6 @@ function getMatcherString(id, resolutionBase) {
1701
1579
  if (resolutionBase === false || isAbsolute$2(id) || id.startsWith("**")) return normalizePath(id);
1702
1580
  return join$1(normalizePath(resolve$1(resolutionBase || "")).replaceAll(/[-^$*+?.()|[\]{}]/g, `${escapeMark}$&`), normalizePath(id)).replaceAll(escapeMark, "\\");
1703
1581
  }
1704
- /**
1705
- * Constructs a filter function which can be used to determine whether or not
1706
- * certain modules should be operated upon.
1707
- * @param include If `include` is omitted or has zero length, filter will return `true` by default.
1708
- * @param exclude ID must not match any of the `exclude` patterns.
1709
- * @param options Additional options.
1710
- * @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`.
1711
- * If a `string` is specified, then the value will be used as the base directory.
1712
- * Relative paths will be resolved against `process.cwd()` first.
1713
- * If `false`, then the patterns will not be resolved against any directory.
1714
- * This can be useful if you want to create a filter for virtual module names.
1715
- */
1716
1582
  function createFilter(include, exclude, options) {
1717
1583
  const resolutionBase = options && options.resolve;
1718
1584
  const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
@@ -1736,14 +1602,6 @@ function createFilter(include, exclude, options) {
1736
1602
  return !includeMatchers.length;
1737
1603
  };
1738
1604
  }
1739
-
1740
- //#endregion
1741
- //#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/unplugin.mjs
1742
- var unplugin_exports = /* @__PURE__ */ __exportAll({
1743
- default: () => unplugin,
1744
- defaultExcludes: () => defaultExcludes,
1745
- defaultIncludes: () => defaultIncludes
1746
- });
1747
1605
  const defaultIncludes = [
1748
1606
  /\.[jt]sx?$/,
1749
1607
  /\.vue$/,
@@ -1780,6 +1638,4 @@ const unplugin = createUnplugin((options = {}) => {
1780
1638
  }
1781
1639
  };
1782
1640
  });
1783
-
1784
- //#endregion
1785
- export { detect_acorn_exports as n, unplugin_exports as t };
1641
+ export { detectImportsAcorn as a, createVirtualImportsAcronWalker as i, defaultIncludes as n, traveseScopes as o, unplugin as r, defaultExcludes as t };