nitro 3.0.1-alpha.2 → 3.0.260311-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 (255) 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 +6977 -2556
  5. package/dist/_build/rolldown.mjs +32 -31
  6. package/dist/_build/rollup.mjs +28 -35
  7. package/dist/_build/vite.build.mjs +10 -8
  8. package/dist/_chunks/nitro.mjs +80 -112
  9. package/dist/_chunks/nitro2.mjs +8 -7
  10. package/dist/_chunks/nitro3.mjs +129 -0
  11. package/dist/_chunks/utils.mjs +42 -24
  12. package/dist/_common.mjs +14 -24
  13. package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -320
  14. package/dist/_libs/_.mjs +3 -0
  15. package/dist/_libs/_2.mjs +2 -0
  16. package/dist/_libs/_3.mjs +3 -0
  17. package/dist/_libs/_4.mjs +2 -0
  18. package/dist/_libs/_5.mjs +3 -0
  19. package/dist/_libs/_6.mjs +4 -0
  20. package/dist/_libs/_7.mjs +5 -0
  21. package/dist/_libs/c12+rc9.mjs +812 -0
  22. package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +52 -36
  23. package/dist/_libs/citty.mjs +10 -12
  24. package/dist/_libs/commondir+is-reference.mjs +60 -49
  25. package/dist/_libs/compatx.mjs +1 -2
  26. package/dist/_libs/esbuild.d.mts +1 -1
  27. package/dist/_libs/escape-string-regexp.mjs +1 -2
  28. package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +2 -2
  29. package/dist/_libs/estree-walker.mjs +1 -4
  30. package/dist/_libs/exsolve.d.mts +1 -0
  31. package/dist/_libs/hasown+resolve+deepmerge.mjs +146 -169
  32. package/dist/_libs/httpxy.d.mts +12 -9
  33. package/dist/_libs/httpxy.mjs +299 -43
  34. package/dist/_libs/js-tokens.d.mts +1 -0
  35. package/dist/_libs/klona.mjs +1 -2
  36. package/dist/_libs/mlly.d.mts +1 -1
  37. package/dist/_libs/nypm+tinyexec.mjs +845 -0
  38. package/dist/_libs/perfect-debounce.mjs +88 -0
  39. package/dist/_libs/plugin-alias.mjs +2 -4
  40. package/dist/_libs/plugin-inject.mjs +2 -6
  41. package/dist/_libs/plugin-json.mjs +2 -4
  42. package/dist/_libs/pluginutils.mjs +5 -11
  43. package/dist/_libs/readdirp+chokidar.mjs +187 -192
  44. package/dist/_libs/remapping.mjs +1 -3
  45. package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -21
  46. package/dist/_libs/rou3.d.mts +3 -2
  47. package/dist/_libs/rou3.mjs +225 -51
  48. package/dist/_libs/std-env.d.mts +10 -2
  49. package/dist/_libs/strip-literal.d.mts +1 -0
  50. package/dist/_libs/tsconfck.mjs +21 -40
  51. package/dist/_libs/ultrahtml.mjs +3 -14
  52. package/dist/_libs/unimport+unplugin.mjs +250 -351
  53. package/dist/_libs/unplugin+unimport.d.mts +7 -10
  54. package/dist/_presets.mjs +389 -432
  55. package/dist/builder.d.mts +5 -4
  56. package/dist/builder.mjs +12 -6
  57. package/dist/cli/_chunks/build.mjs +22 -23
  58. package/dist/cli/_chunks/common.mjs +1 -2
  59. package/dist/cli/_chunks/deploy.mjs +40 -0
  60. package/dist/cli/_chunks/dev.mjs +9 -9
  61. package/dist/cli/_chunks/docs.mjs +30 -0
  62. package/dist/cli/_chunks/list.mjs +4 -6
  63. package/dist/cli/_chunks/prepare.mjs +2 -4
  64. package/dist/cli/_chunks/preview.mjs +51 -0
  65. package/dist/cli/_chunks/run.mjs +7 -9
  66. package/dist/cli/_chunks/task.mjs +1 -3
  67. package/dist/cli/index.mjs +5 -4
  68. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
  69. package/dist/node_modules/@poppinss/dumper/package.json +1 -1
  70. package/dist/node_modules/croner/dist/croner.js +1 -1
  71. package/dist/node_modules/croner/package.json +11 -1
  72. package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
  73. package/dist/node_modules/youch/build/index.js +204 -351
  74. package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
  75. package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
  76. package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
  77. package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
  78. package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
  79. package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
  80. package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
  81. package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
  82. package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
  83. package/dist/node_modules/youch/package.json +34 -31
  84. package/dist/presets/_nitro/runtime/nitro-dev.mjs +9 -56
  85. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
  86. package/dist/presets/_nitro/runtime/service-worker.mjs +0 -1
  87. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
  88. package/dist/presets/bun/runtime/bun.mjs +4 -3
  89. package/dist/presets/deno/runtime/deno-server.mjs +4 -3
  90. package/dist/presets/netlify/runtime/netlify-edge.mjs +0 -1
  91. package/dist/presets/netlify/runtime/netlify.mjs +1 -1
  92. package/dist/presets/node/runtime/node-cluster.mjs +3 -2
  93. package/dist/presets/node/runtime/node-server.mjs +3 -2
  94. package/dist/presets/stormkit/runtime/stormkit.mjs +0 -1
  95. package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
  96. package/dist/presets/vercel/runtime/vercel.web.mjs +2 -4
  97. package/dist/presets/zephyr/runtime/server.mjs +3 -0
  98. package/dist/runtime/internal/cache.d.mts +0 -4
  99. package/dist/runtime/internal/cache.mjs +32 -256
  100. package/dist/runtime/internal/context.d.mts +3 -1
  101. package/dist/runtime/internal/error/dev.d.mts +5 -4
  102. package/dist/runtime/internal/error/dev.mjs +38 -40
  103. package/dist/runtime/internal/error/hooks.d.mts +1 -1
  104. package/dist/runtime/internal/error/prod.d.mts +2 -5
  105. package/dist/runtime/internal/error/prod.mjs +19 -33
  106. package/dist/runtime/internal/error/utils.d.mts +4 -4
  107. package/dist/runtime/internal/meta.d.mts +1 -1
  108. package/dist/runtime/internal/plugin.d.mts +2 -2
  109. package/dist/runtime/internal/route-rules.d.mts +9 -4
  110. package/dist/runtime/internal/route-rules.mjs +9 -1
  111. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
  112. package/dist/runtime/internal/routes/dev-tasks.mjs +6 -2
  113. package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
  114. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
  115. package/dist/runtime/internal/runtime-config.d.mts +1 -1
  116. package/dist/runtime/internal/static.mjs +5 -4
  117. package/dist/runtime/internal/task.d.mts +3 -1
  118. package/dist/runtime/internal/task.mjs +2 -2
  119. package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
  120. package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
  121. package/dist/runtime/meta.mjs +1 -0
  122. package/dist/runtime/nitro.d.mts +2 -0
  123. package/dist/runtime/nitro.mjs +2 -0
  124. package/dist/runtime/virtual/error-handler.mjs +1 -1
  125. package/dist/runtime/virtual/server-assets.d.mts +2 -1
  126. package/dist/runtime/vite.d.mts +1 -1
  127. package/dist/types/index.d.mts +68 -117
  128. package/dist/types/index.mjs +1 -11
  129. package/dist/vite.d.mts +3 -3
  130. package/dist/vite.mjs +236 -233
  131. package/package.json +83 -68
  132. package/skills/nitro/SKILL.md +10 -0
  133. package/skills/nitro/docs/TOC.md +83 -0
  134. package/skills/nitro/docs/_navigation.json +679 -0
  135. package/skills/nitro/docs/config/index.md +1147 -0
  136. package/skills/nitro/docs/deploy/index.md +64 -0
  137. package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
  138. package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
  139. package/skills/nitro/docs/deploy/providers/aws.md +47 -0
  140. package/skills/nitro/docs/deploy/providers/azure.md +72 -0
  141. package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
  142. package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
  143. package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
  144. package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
  145. package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
  146. package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
  147. package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
  148. package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
  149. package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
  150. package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
  151. package/skills/nitro/docs/deploy/providers/iis.md +38 -0
  152. package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
  153. package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
  154. package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
  155. package/skills/nitro/docs/deploy/providers/render.md +37 -0
  156. package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
  157. package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
  158. package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
  159. package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
  160. package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
  161. package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
  162. package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
  163. package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
  164. package/skills/nitro/docs/docs/assets.md +166 -0
  165. package/skills/nitro/docs/docs/cache.md +408 -0
  166. package/skills/nitro/docs/docs/configuration.md +256 -0
  167. package/skills/nitro/docs/docs/database.md +185 -0
  168. package/skills/nitro/docs/docs/index.md +56 -0
  169. package/skills/nitro/docs/docs/lifecycle.md +204 -0
  170. package/skills/nitro/docs/docs/migration.md +215 -0
  171. package/skills/nitro/docs/docs/nightly.md +31 -0
  172. package/skills/nitro/docs/docs/plugins.md +164 -0
  173. package/skills/nitro/docs/docs/quick-start.md +110 -0
  174. package/skills/nitro/docs/docs/renderer.md +322 -0
  175. package/skills/nitro/docs/docs/routing.md +711 -0
  176. package/skills/nitro/docs/docs/server-entry.md +239 -0
  177. package/skills/nitro/docs/docs/storage.md +261 -0
  178. package/skills/nitro/docs/docs/tasks.md +277 -0
  179. package/skills/nitro/docs/examples/api-routes.md +145 -0
  180. package/skills/nitro/docs/examples/auto-imports.md +93 -0
  181. package/skills/nitro/docs/examples/cached-handler.md +81 -0
  182. package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
  183. package/skills/nitro/docs/examples/database.md +157 -0
  184. package/skills/nitro/docs/examples/elysia.md +70 -0
  185. package/skills/nitro/docs/examples/express.md +78 -0
  186. package/skills/nitro/docs/examples/fastify.md +79 -0
  187. package/skills/nitro/docs/examples/hello-world.md +68 -0
  188. package/skills/nitro/docs/examples/hono.md +74 -0
  189. package/skills/nitro/docs/examples/import-alias.md +100 -0
  190. package/skills/nitro/docs/examples/index.md +3 -0
  191. package/skills/nitro/docs/examples/middleware.md +91 -0
  192. package/skills/nitro/docs/examples/mono-jsx.md +68 -0
  193. package/skills/nitro/docs/examples/nano-jsx.md +70 -0
  194. package/skills/nitro/docs/examples/plugins.md +91 -0
  195. package/skills/nitro/docs/examples/renderer.md +113 -0
  196. package/skills/nitro/docs/examples/runtime-config.md +97 -0
  197. package/skills/nitro/docs/examples/server-fetch.md +87 -0
  198. package/skills/nitro/docs/examples/shiki.md +198 -0
  199. package/skills/nitro/docs/examples/virtual-routes.md +74 -0
  200. package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
  201. package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
  202. package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
  203. package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
  204. package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
  205. package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
  206. package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
  207. package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
  208. package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
  209. package/skills/nitro/docs/examples/vite-trpc.md +335 -0
  210. package/skills/nitro/docs/examples/websocket.md +282 -0
  211. package/skills/nitro/docs/index.md +121 -0
  212. package/dist/_libs/confbox.mjs +0 -2509
  213. package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
  214. package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
  215. package/dist/node_modules/hookable/dist/index.mjs +0 -266
  216. package/dist/node_modules/hookable/package.json +0 -52
  217. package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
  218. package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
  219. package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
  220. package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
  221. package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
  222. package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
  223. package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
  224. package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
  225. package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
  226. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
  227. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
  228. package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
  229. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
  230. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
  231. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
  232. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
  233. package/dist/presets/azure/runtime/_utils.d.mts +0 -2
  234. package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
  235. package/dist/presets/bun/runtime/bun.d.mts +0 -3
  236. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
  237. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
  238. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
  239. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
  240. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
  241. package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
  242. package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
  243. package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
  244. package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
  245. package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
  246. package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
  247. package/dist/presets/node/runtime/node-server.d.mts +0 -3
  248. package/dist/presets/standard/runtime/server.d.mts +0 -3
  249. package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
  250. package/dist/presets/vercel/runtime/isr.d.mts +0 -2
  251. package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
  252. package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
  253. package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
  254. package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
  255. package/dist/runtime/internal/vite/node-runner.mjs +0 -359
@@ -1,24 +1,14 @@
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
- });
11
+ //#region node_modules/.pnpm/unimport@6.0.1/node_modules/unimport/dist/chunks/detect-acorn.mjs
22
12
  async function detectImportsAcorn(code, ctx, options) {
23
13
  const s = getMagicString(code);
24
14
  const map = await ctx.getImportMap();
@@ -201,9 +191,8 @@ function createVirtualImportsAcronWalker(importMap, virtualImports = []) {
201
191
  } }
202
192
  };
203
193
  }
204
-
205
194
  //#endregion
206
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-Csj9j3eN.js
195
+ //#region node_modules/.pnpm/unplugin@3.0.0/node_modules/unplugin/dist/parse-DN2jPtpt.mjs
207
196
  var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
208
197
  function toArray$2(array) {
209
198
  array = array || [];
@@ -211,16 +200,16 @@ function toArray$2(array) {
211
200
  return [array];
212
201
  }
213
202
  const BACKSLASH_REGEX = /\\/g;
214
- function normalize$1(path$1) {
215
- return path$1.replace(BACKSLASH_REGEX, "/");
203
+ function normalize$1(path) {
204
+ return path.replace(BACKSLASH_REGEX, "/");
216
205
  }
217
206
  const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
218
- function isAbsolute$1(path$1) {
219
- return ABSOLUTE_PATH_REGEX.test(path$1);
207
+ function isAbsolute$1(path) {
208
+ return ABSOLUTE_PATH_REGEX.test(path);
220
209
  }
221
- function getMatcherString$1(glob, cwd$1) {
210
+ function getMatcherString$1(glob, cwd) {
222
211
  if (glob.startsWith("**") || isAbsolute$1(glob)) return normalize$1(glob);
223
- return normalize$1(resolve(cwd$1, glob));
212
+ return normalize$1(resolve(cwd, glob));
224
213
  }
225
214
  function patternToIdFilter(pattern) {
226
215
  if (pattern instanceof RegExp) return (id) => {
@@ -304,16 +293,10 @@ function normalizeObjectHook(name, hook) {
304
293
  };
305
294
  }
306
295
  function parse(code, opts = {}) {
307
- return Parser.parse(code, {
308
- sourceType: "module",
309
- ecmaVersion: "latest",
310
- locations: true,
311
- ...opts
312
- });
296
+ throw new Error("Parse implementation is not set. Please call setParseImpl first.");
313
297
  }
314
-
315
298
  //#endregion
316
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/webpack-like-DFGTNSuV.js
299
+ //#region node_modules/.pnpm/unplugin@3.0.0/node_modules/unplugin/dist/webpack-like-Djrmy9eu.mjs
317
300
  function transformUse(data, plugin, transformLoader) {
318
301
  if (data.resource == null) return [];
319
302
  const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
@@ -336,14 +319,13 @@ function transformUse(data, plugin, transformLoader) {
336
319
  * @param path - Path to normalize.
337
320
  * @returns a new normalized path.
338
321
  */
339
- function normalizeAbsolutePath(path$1) {
340
- if (isAbsolute(path$1)) return normalize(path$1);
341
- else return path$1;
322
+ function normalizeAbsolutePath(path) {
323
+ if (isAbsolute(path)) return normalize(path);
324
+ else return path;
342
325
  }
343
-
344
326
  //#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) {
327
+ //#region node_modules/.pnpm/unplugin@3.0.0/node_modules/unplugin/dist/context-CKhLGGrj.mjs
328
+ function createBuildContext$3(compiler, compilation, loaderContext, inputSourceMap) {
347
329
  return {
348
330
  getNativeBuildContext() {
349
331
  return {
@@ -355,8 +337,9 @@ function createBuildContext$1(compiler, compilation, loaderContext, inputSourceM
355
337
  };
356
338
  },
357
339
  addWatchFile(file) {
358
- const cwd$1 = process.cwd();
359
- compilation.fileDependencies.add(resolve(cwd$1, file));
340
+ const resolvedPath = resolve(process.cwd(), file);
341
+ compilation.fileDependencies.add(resolvedPath);
342
+ loaderContext?.addDependency(resolvedPath);
360
343
  },
361
344
  getWatchFiles() {
362
345
  return Array.from(compilation.fileDependencies);
@@ -371,7 +354,7 @@ function createBuildContext$1(compiler, compilation, loaderContext, inputSourceM
371
354
  }
372
355
  };
373
356
  }
374
- function normalizeMessage$1(error) {
357
+ function normalizeMessage$2(error) {
375
358
  const err = new Error(typeof error === "string" ? error : error.message);
376
359
  if (typeof error === "object") {
377
360
  err.stack = error.stack;
@@ -379,9 +362,8 @@ function normalizeMessage$1(error) {
379
362
  }
380
363
  return err;
381
364
  }
382
-
383
365
  //#endregion
384
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/utils-BosfZ0pB.js
366
+ //#region node_modules/.pnpm/unplugin@3.0.0/node_modules/unplugin/dist/utils-BMHLEWml.mjs
385
367
  function encodeVirtualModuleId(id, plugin) {
386
368
  return resolve(plugin.__virtualModulePrefix, encodeURIComponent(id));
387
369
  }
@@ -415,23 +397,22 @@ var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin {
415
397
  const counter = FakeVirtualModulesPlugin.counters.get(dir) ?? 0;
416
398
  FakeVirtualModulesPlugin.counters.set(dir, counter + 1);
417
399
  compiler.hooks.shutdown.tap(this.name, () => {
418
- const counter$1 = (FakeVirtualModulesPlugin.counters.get(dir) ?? 1) - 1;
419
- if (counter$1 === 0) {
400
+ const counter = (FakeVirtualModulesPlugin.counters.get(dir) ?? 1) - 1;
401
+ if (counter === 0) {
420
402
  FakeVirtualModulesPlugin.counters.delete(dir);
421
403
  fs.rmSync(dir, {
422
404
  recursive: true,
423
405
  force: true
424
406
  });
425
- } else FakeVirtualModulesPlugin.counters.set(dir, counter$1);
407
+ } else FakeVirtualModulesPlugin.counters.set(dir, counter);
426
408
  });
427
409
  }
428
410
  async writeModule(file) {
429
411
  return fs.promises.writeFile(file, "");
430
412
  }
431
413
  };
432
-
433
414
  //#endregion
434
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-OCFO8EW1.js
415
+ //#region node_modules/.pnpm/unplugin@3.0.0/node_modules/unplugin/dist/context-MD-xQmYI.mjs
435
416
  function contextOptionsFromCompilation(compilation) {
436
417
  return {
437
418
  addWatchFile(file) {
@@ -442,11 +423,11 @@ function contextOptionsFromCompilation(compilation) {
442
423
  }
443
424
  };
444
425
  }
445
- const require$1 = createRequire(import.meta.url);
426
+ const require = createRequire(import.meta.url);
446
427
  function getSource(fileSource) {
447
- return new (require$1("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer));
428
+ return new (require("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer));
448
429
  }
449
- function createBuildContext(options, compiler, compilation, loaderContext, inputSourceMap) {
430
+ function createBuildContext$2(options, compiler, compilation, loaderContext, inputSourceMap) {
450
431
  return {
451
432
  parse,
452
433
  addWatchFile(id) {
@@ -473,7 +454,7 @@ function createBuildContext(options, compiler, compilation, loaderContext, input
473
454
  }
474
455
  };
475
456
  }
476
- function normalizeMessage(error) {
457
+ function normalizeMessage$1(error) {
477
458
  const err = new Error(typeof error === "string" ? error : error.message);
478
459
  if (typeof error === "object") {
479
460
  err.stack = error.stack;
@@ -481,279 +462,205 @@ function normalizeMessage(error) {
481
462
  }
482
463
  return err;
483
464
  }
484
-
485
465
  //#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];
466
+ //#region node_modules/.pnpm/unplugin@3.0.0/node_modules/unplugin/dist/index.mjs
467
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
468
+ const ExtToLoader$1 = {
469
+ ".js": "js",
470
+ ".mjs": "js",
471
+ ".cjs": "js",
472
+ ".jsx": "jsx",
473
+ ".ts": "ts",
474
+ ".cts": "ts",
475
+ ".mts": "ts",
476
+ ".tsx": "tsx",
477
+ ".css": "css",
478
+ ".less": "css",
479
+ ".stylus": "css",
480
+ ".scss": "css",
481
+ ".sass": "css",
482
+ ".json": "json",
483
+ ".txt": "text"
484
+ };
485
+ function guessLoader$1(id) {
486
+ return ExtToLoader$1[path.extname(id).toLowerCase()] || "js";
487
+ }
488
+ function createBuildContext$1(build) {
489
+ const watchFiles = [];
490
+ return {
491
+ addWatchFile(file) {
492
+ watchFiles.push(file);
493
+ },
494
+ getWatchFiles() {
495
+ return watchFiles;
496
+ },
497
+ emitFile(emittedFile) {
498
+ const outFileName = emittedFile.fileName || emittedFile.name;
499
+ const outdir = build?.config?.outdir;
500
+ if (outdir && emittedFile.source && outFileName) {
501
+ const outPath = path.resolve(outdir, outFileName);
502
+ const outDir = path.dirname(outPath);
503
+ if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
504
+ fs.writeFileSync(outPath, emittedFile.source);
499
505
  }
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);
506
+ },
507
+ parse,
508
+ getNativeBuildContext() {
509
+ return {
510
+ framework: "bun",
511
+ build
512
+ };
524
513
  }
525
514
  };
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
- };
515
+ }
516
+ function createPluginContext$1(buildContext) {
517
+ const errors = [];
518
+ const warnings = [];
519
+ return {
520
+ errors,
521
+ warnings,
522
+ mixedContext: {
523
+ ...buildContext,
524
+ error(error) {
525
+ errors.push(error);
526
+ },
527
+ warn(warning) {
528
+ warnings.push(warning);
554
529
  }
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
530
  }
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;
531
+ };
532
+ }
533
+ function getBunPlugin(factory) {
534
+ return (userOptions) => {
535
+ if (typeof Bun === "undefined") throw new ReferenceError("Bun is not supported in this environment");
536
+ if (!Bun.semver.satisfies(Bun.version, ">=1.2.22")) throw new Error("Bun 1.2.22 or higher is required, please upgrade Bun");
537
+ const meta = { framework: "bun" };
538
+ const plugins = toArray$2(factory(userOptions, meta));
539
+ return {
540
+ name: (plugins.length === 1 ? plugins[0].name : meta.bunHostName) ?? `unplugin-host:${plugins.map((p) => p.name).join(":")}`,
541
+ async setup(build) {
542
+ const context = createBuildContext$1(build);
543
+ if (plugins.some((plugin) => plugin.buildStart)) build.onStart(async () => {
544
+ for (const plugin of plugins) if (plugin.buildStart) await plugin.buildStart.call(context);
607
545
  });
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);
546
+ const resolveIdHooks = plugins.filter((plugin) => plugin.resolveId).map((plugin) => ({
547
+ plugin,
548
+ ...normalizeObjectHook("resolveId", plugin.resolveId)
549
+ }));
550
+ const loadHooks = plugins.filter((plugin) => plugin.load).map((plugin) => ({
551
+ plugin,
552
+ ...normalizeObjectHook("load", plugin.load)
553
+ }));
554
+ const transformHooks = plugins.filter((plugin) => plugin.transform || plugin.transformInclude).map((plugin) => ({
555
+ plugin,
556
+ ...normalizeObjectHook("transform", plugin.transform)
557
+ }));
558
+ const virtualModulePlugins = /* @__PURE__ */ new Set();
559
+ for (const plugin of plugins) if (plugin.resolveId && plugin.load) virtualModulePlugins.add(plugin.name);
560
+ if (resolveIdHooks.length) build.onResolve({ filter: /.*/ }, async (args) => {
561
+ if (build.config?.external?.includes(args.path)) return;
562
+ for (const { plugin, handler, filter } of resolveIdHooks) {
563
+ if (!filter(args.path)) continue;
564
+ const { mixedContext, errors, warnings } = createPluginContext$1(context);
565
+ const isEntry = args.kind === "entry-point-run" || args.kind === "entry-point-build";
566
+ const result = await handler.call(mixedContext, args.path, isEntry ? void 0 : args.importer, { isEntry });
567
+ for (const warning of warnings) console.warn("[unplugin]", typeof warning === "string" ? warning : warning.message);
568
+ if (errors.length > 0) {
569
+ const errorMessage = errors.map((e) => typeof e === "string" ? e : e.message).join("\n");
570
+ throw new Error(`[unplugin] ${plugin.name}: ${errorMessage}`);
571
+ }
572
+ if (typeof result === "string") {
573
+ if (!isAbsolute(result)) return {
574
+ path: result,
575
+ namespace: plugin.name
576
+ };
577
+ return { path: result };
578
+ } else if (typeof result === "object" && result !== null) {
579
+ if (!isAbsolute(result.id)) return {
580
+ path: result.id,
581
+ external: result.external,
582
+ namespace: plugin.name
583
+ };
584
+ return {
585
+ path: result.id,
586
+ external: result.external
587
+ };
588
+ }
649
589
  }
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));
590
+ });
591
+ async function processLoadTransform(id, namespace, loader) {
592
+ let code;
593
+ let hasResult = false;
594
+ const namespaceLoadHooks = namespace === "file" ? loadHooks : loadHooks.filter((h) => h.plugin.name === namespace);
595
+ for (const { plugin, handler, filter } of namespaceLoadHooks) {
596
+ if (plugin.loadInclude && !plugin.loadInclude(id)) continue;
597
+ if (!filter(id)) continue;
598
+ const { mixedContext, errors, warnings } = createPluginContext$1(context);
599
+ const result = await handler.call(mixedContext, 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
+ break;
609
+ } else if (typeof result === "object" && result !== null) {
610
+ code = result.code;
611
+ hasResult = true;
612
+ break;
613
+ }
614
+ }
615
+ if (!hasResult && namespace === "file" && transformHooks.length > 0) code = await Bun.file(id).text();
616
+ if (code !== void 0) {
617
+ const namespaceTransformHooks = namespace === "file" ? transformHooks : transformHooks.filter((h) => h.plugin.name === namespace);
618
+ for (const { plugin, handler, filter } of namespaceTransformHooks) {
619
+ if (plugin.transformInclude && !plugin.transformInclude(id)) continue;
620
+ if (!filter(id, code)) continue;
621
+ const { mixedContext, errors, warnings } = createPluginContext$1(context);
622
+ const result = await handler.call(mixedContext, code, id);
623
+ for (const warning of warnings) console.warn("[unplugin]", typeof warning === "string" ? warning : warning.message);
624
+ if (errors.length > 0) {
625
+ const errorMessage = errors.map((e) => typeof e === "string" ? e : e.message).join("\n");
626
+ throw new Error(`[unplugin] ${plugin.name}: ${errorMessage}`);
627
+ }
628
+ if (typeof result === "string") {
629
+ code = result;
630
+ hasResult = true;
631
+ } else if (typeof result === "object" && result !== null) {
632
+ code = result.code;
633
+ hasResult = true;
707
634
  }
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
635
  }
636
+ }
637
+ if (hasResult && code !== void 0) return {
638
+ contents: code,
639
+ loader: loader ?? guessLoader$1(id)
717
640
  };
718
641
  }
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
- });
642
+ if (loadHooks.length || transformHooks.length) build.onLoad({
643
+ filter: /.*/,
644
+ namespace: "file"
645
+ }, async (args) => {
646
+ return processLoadTransform(args.path, "file", args.loader);
647
+ });
648
+ for (const pluginName of virtualModulePlugins) build.onLoad({
649
+ filter: /.*/,
650
+ namespace: pluginName
651
+ }, async (args) => {
652
+ return processLoadTransform(args.path, pluginName, args.loader);
653
+ });
654
+ if (plugins.some((plugin) => plugin.buildEnd || plugin.writeBundle)) build.onEnd(async () => {
655
+ for (const plugin of plugins) {
656
+ if (plugin.buildEnd) await plugin.buildEnd.call(context);
657
+ if (plugin.writeBundle) await plugin.writeBundle();
658
+ }
737
659
  });
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
660
  }
749
- }
661
+ };
750
662
  };
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);
663
+ }
757
664
  const ExtToLoader = {
758
665
  ".js": "js",
759
666
  ".mjs": "js",
@@ -812,7 +719,7 @@ function combineSourcemaps(filename, sourcemapList) {
812
719
  if (!map.file) delete map.file;
813
720
  return map;
814
721
  }
815
- function createBuildContext$2(build) {
722
+ function createBuildContext(build) {
816
723
  const watchFiles = [];
817
724
  const { initialOptions } = build;
818
725
  return {
@@ -845,10 +752,10 @@ function createPluginContext(context) {
845
752
  const warnings = [];
846
753
  const pluginContext = {
847
754
  error(message) {
848
- errors.push(normalizeMessage$2(message));
755
+ errors.push(normalizeMessage(message));
849
756
  },
850
757
  warn(message) {
851
- warnings.push(normalizeMessage$2(message));
758
+ warnings.push(normalizeMessage(message));
852
759
  }
853
760
  };
854
761
  return {
@@ -863,7 +770,7 @@ function createPluginContext(context) {
863
770
  }
864
771
  };
865
772
  }
866
- function normalizeMessage$2(message) {
773
+ function normalizeMessage(message) {
867
774
  if (typeof message === "string") message = { message };
868
775
  return {
869
776
  id: message.id,
@@ -946,7 +853,7 @@ function getEsbuildPlugin(factory) {
946
853
  function buildSetup() {
947
854
  return (plugin) => {
948
855
  return (build, rawBuild) => {
949
- const context = createBuildContext$2(rawBuild);
856
+ const context = createBuildContext(rawBuild);
950
857
  const { onStart, onEnd, onResolve, onLoad, onTransform, initialOptions } = build;
951
858
  const onResolveFilter = plugin.esbuild?.onResolveFilter ?? /.*/;
952
859
  const onLoadFilter = plugin.esbuild?.onLoadFilter ?? /.*/;
@@ -1125,7 +1032,7 @@ function decodeStr(str) {
1125
1032
  if (firstIndex === -1) return str;
1126
1033
  const result = Array.from({ length: len - countBackslashZeros(str, firstIndex) });
1127
1034
  let pos = 0;
1128
- for (let i$1 = 0; i$1 < firstIndex; i$1++) result[pos++] = str[i$1];
1035
+ for (let i = 0; i < firstIndex; i++) result[pos++] = str[i];
1129
1036
  let i = firstIndex;
1130
1037
  while (i < len) if (str[i] === "\\" && str[i + 1] === "0") {
1131
1038
  result[pos++] = "\0";
@@ -1370,7 +1277,6 @@ function toRollupPlugin(plugin, key) {
1370
1277
  }
1371
1278
  }
1372
1279
  function supportNativeFilter(context, framework) {
1373
- if (framework === "unloader") return false;
1374
1280
  if (framework === "vite") return !!context?.meta?.viteVersion;
1375
1281
  if (framework === "rolldown") return true;
1376
1282
  const rollupVersion = context?.meta?.rollupVersion;
@@ -1386,11 +1292,8 @@ function getRolldownPlugin(factory) {
1386
1292
  return plugins.length === 1 ? plugins[0] : plugins;
1387
1293
  });
1388
1294
  }
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");
1295
+ const TRANSFORM_LOADER$1 = resolve(import.meta.dirname, "rspack/loaders/transform.mjs");
1296
+ const LOAD_LOADER$1 = resolve(import.meta.dirname, "rspack/loaders/load.mjs");
1394
1297
  function getRspackPlugin(factory) {
1395
1298
  return (userOptions) => {
1396
1299
  return { apply(compiler) {
@@ -1407,9 +1310,9 @@ function getRspackPlugin(factory) {
1407
1310
  });
1408
1311
  const externalModules = /* @__PURE__ */ new Set();
1409
1312
  if (plugin.resolveId) {
1410
- const createPlugin = (plugin$1) => {
1313
+ const createPlugin = (plugin) => {
1411
1314
  if (compiler.rspack.experiments.VirtualModulesPlugin) return new compiler.rspack.experiments.VirtualModulesPlugin();
1412
- return new FakeVirtualModulesPlugin(plugin$1);
1315
+ return new FakeVirtualModulesPlugin(plugin);
1413
1316
  };
1414
1317
  const vfs = createPlugin(plugin);
1415
1318
  vfs.apply(compiler);
@@ -1423,11 +1326,11 @@ function getRspackPlugin(factory) {
1423
1326
  let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
1424
1327
  const isEntry = requestContext.issuer === "";
1425
1328
  if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
1426
- const context = createBuildContext$1(compiler, compilation);
1329
+ const context = createBuildContext$3(compiler, compilation);
1427
1330
  let error;
1428
1331
  const pluginContext = {
1429
1332
  error(msg) {
1430
- if (error == null) error = normalizeMessage$1(msg);
1333
+ if (error == null) error = normalizeMessage$2(msg);
1431
1334
  else console.error(`unplugin/rspack: multiple errors returned from resolveId hook: ${msg}`);
1432
1335
  },
1433
1336
  warn(msg) {
@@ -1487,17 +1390,17 @@ function getRspackPlugin(factory) {
1487
1390
  });
1488
1391
  if (plugin.rspack) plugin.rspack(compiler);
1489
1392
  if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
1490
- const context = createBuildContext$1(compiler, compilation);
1393
+ const context = createBuildContext$3(compiler, compilation);
1491
1394
  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);
1395
+ const promises = [];
1396
+ if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
1397
+ if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
1398
+ await Promise.all(promises);
1496
1399
  }
1497
1400
  if (plugin.buildStart) return await plugin.buildStart.call(context);
1498
1401
  });
1499
1402
  if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
1500
- await plugin.buildEnd.call(createBuildContext$1(compiler, compilation));
1403
+ await plugin.buildEnd.call(createBuildContext$3(compiler, compilation));
1501
1404
  });
1502
1405
  if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
1503
1406
  await plugin.writeBundle();
@@ -1522,10 +1425,11 @@ function getVitePlugin(factory) {
1522
1425
  return plugins.length === 1 ? plugins[0] : plugins;
1523
1426
  });
1524
1427
  }
1525
- const TRANSFORM_LOADER = resolve(__dirname, "webpack/loaders/transform");
1526
- const LOAD_LOADER = resolve(__dirname, "webpack/loaders/load");
1428
+ const TRANSFORM_LOADER = resolve(import.meta.dirname, "webpack/loaders/transform.mjs");
1429
+ const LOAD_LOADER = resolve(import.meta.dirname, "webpack/loaders/load.mjs");
1527
1430
  function getWebpackPlugin(factory) {
1528
1431
  return (userOptions) => {
1432
+ const VirtualModulesPlugin = __require("webpack-virtual-modules");
1529
1433
  return { apply(compiler) {
1530
1434
  const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process$1.cwd(), "_virtual_");
1531
1435
  const meta = {
@@ -1540,9 +1444,9 @@ function getWebpackPlugin(factory) {
1540
1444
  });
1541
1445
  const externalModules = /* @__PURE__ */ new Set();
1542
1446
  if (plugin.resolveId) {
1543
- let vfs = compiler.options.plugins.find((i) => i instanceof import_lib.default);
1447
+ let vfs = compiler.options.plugins.find((i) => i instanceof VirtualModulesPlugin);
1544
1448
  if (!vfs) {
1545
- vfs = new import_lib.default();
1449
+ vfs = new VirtualModulesPlugin();
1546
1450
  compiler.options.plugins.push(vfs);
1547
1451
  }
1548
1452
  const vfsModules = /* @__PURE__ */ new Set();
@@ -1559,7 +1463,7 @@ function getWebpackPlugin(factory) {
1559
1463
  const isEntry = requestContext.issuer === "";
1560
1464
  if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
1561
1465
  const fileDependencies = /* @__PURE__ */ new Set();
1562
- const context = createBuildContext({
1466
+ const context = createBuildContext$2({
1563
1467
  addWatchFile(file) {
1564
1468
  fileDependencies.add(file);
1565
1469
  resolveContext.fileDependencies?.add(file);
@@ -1571,7 +1475,7 @@ function getWebpackPlugin(factory) {
1571
1475
  let error;
1572
1476
  const pluginContext = {
1573
1477
  error(msg) {
1574
- if (error == null) error = normalizeMessage(msg);
1478
+ if (error == null) error = normalizeMessage$1(msg);
1575
1479
  else console.error(`unplugin/webpack: multiple errors returned from resolveId hook: ${msg}`);
1576
1480
  },
1577
1481
  warn(msg) {
@@ -1624,17 +1528,17 @@ function getWebpackPlugin(factory) {
1624
1528
  });
1625
1529
  if (plugin.webpack) plugin.webpack(compiler);
1626
1530
  if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
1627
- const context = createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation);
1531
+ const context = createBuildContext$2(contextOptionsFromCompilation(compilation), compiler, compilation);
1628
1532
  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);
1533
+ const promises = [];
1534
+ if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
1535
+ if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
1536
+ await Promise.all(promises);
1633
1537
  }
1634
1538
  if (plugin.buildStart) return await plugin.buildStart.call(context);
1635
1539
  });
1636
1540
  if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
1637
- await plugin.buildEnd.call(createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation));
1541
+ await plugin.buildEnd.call(createBuildContext$2(contextOptionsFromCompilation(compilation), compiler, compilation));
1638
1542
  });
1639
1543
  if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
1640
1544
  await plugin.writeBundle();
@@ -1676,12 +1580,14 @@ function createUnplugin(factory) {
1676
1580
  get unloader() {
1677
1581
  return getUnloaderPlugin(factory);
1678
1582
  },
1583
+ get bun() {
1584
+ return getBunPlugin(factory);
1585
+ },
1679
1586
  get raw() {
1680
1587
  return factory;
1681
1588
  }
1682
1589
  };
1683
1590
  }
1684
-
1685
1591
  //#endregion
1686
1592
  //#region node_modules/.pnpm/unplugin-utils@0.3.1/node_modules/unplugin-utils/dist/index.js
1687
1593
  /**
@@ -1736,14 +1642,8 @@ function createFilter(include, exclude, options) {
1736
1642
  return !includeMatchers.length;
1737
1643
  };
1738
1644
  }
1739
-
1740
1645
  //#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
- });
1646
+ //#region node_modules/.pnpm/unimport@6.0.1/node_modules/unimport/dist/unplugin.mjs
1747
1647
  const defaultIncludes = [
1748
1648
  /\.[jt]sx?$/,
1749
1649
  /\.vue$/,
@@ -1780,6 +1680,5 @@ const unplugin = createUnplugin((options = {}) => {
1780
1680
  }
1781
1681
  };
1782
1682
  });
1783
-
1784
1683
  //#endregion
1785
- export { detect_acorn_exports as n, unplugin_exports as t };
1684
+ export { detectImportsAcorn as a, createVirtualImportsAcronWalker as i, defaultIncludes as n, traveseScopes as o, unplugin as r, defaultExcludes as t };