nitro-nightly 3.0.1-alpha.1 → 3.0.1-alpha.2

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 (246) hide show
  1. package/README.md +2 -0
  2. package/dist/_build/common.mjs +24924 -52
  3. package/dist/_build/rolldown.mjs +29 -63
  4. package/dist/_build/rollup.mjs +22 -110
  5. package/dist/_build/vite.build.mjs +3 -43
  6. package/dist/{_dev.mjs → _chunks/dev.mjs} +45 -43
  7. package/dist/_chunks/{B-D1JOIz.mjs → nitro.mjs} +144 -308
  8. package/dist/_chunks/nitro2.mjs +101 -0
  9. package/dist/_chunks/utils.mjs +254 -0
  10. package/dist/{_chunks/Bqks5huO.mjs → _common.mjs} +24 -10
  11. package/dist/_libs/c12+giget+readdirp+chokidar.d.mts +214 -0
  12. package/dist/_libs/citty.mjs +140 -110
  13. package/dist/_libs/{plugin-commonjs.mjs → commondir+is-reference.mjs} +59 -250
  14. package/dist/_libs/compatx.d.mts +47 -0
  15. package/dist/_libs/confbox.mjs +388 -799
  16. package/dist/_libs/esbuild.d.mts +20 -0
  17. package/dist/_libs/estree-walker.mjs +1 -144
  18. package/dist/_libs/{plugin-node-resolve.mjs → hasown+resolve+deepmerge.mjs} +497 -78
  19. package/dist/_libs/httpxy.d.mts +79 -0
  20. package/dist/_libs/httpxy.mjs +6 -1
  21. package/dist/_libs/magic-string.d.mts +220 -0
  22. package/dist/_libs/mlly.d.mts +57 -0
  23. package/dist/_libs/nypm+giget+tinyexec.mjs +3603 -0
  24. package/dist/_libs/pkg-types.d.mts +23 -0
  25. package/dist/_libs/plugin-alias.mjs +4 -2
  26. package/dist/_libs/plugin-inject.mjs +5 -5
  27. package/dist/_libs/plugin-json.mjs +2 -2
  28. package/dist/_libs/pluginutils+plugin-commonjs.d.mts +241 -0
  29. package/dist/_libs/{vite-plugin-fullstack.mjs → pluginutils.mjs} +244 -153
  30. package/dist/_libs/rc9+c12+dotenv.mjs +972 -0
  31. package/dist/_libs/{chokidar.mjs → readdirp+chokidar.mjs} +237 -187
  32. package/dist/_libs/remapping.mjs +1 -1
  33. package/dist/_libs/{gen-mapping.mjs → resolve-uri+gen-mapping.mjs} +2 -166
  34. package/dist/_libs/rou3.d.mts +43 -0
  35. package/dist/_libs/rou3.mjs +9 -6
  36. package/dist/_libs/std-env.d.mts +4 -0
  37. package/dist/_libs/tsconfck.mjs +3 -3
  38. package/dist/_libs/{unimport.mjs → unimport+unplugin.mjs} +226 -1961
  39. package/dist/_libs/unplugin+unimport.d.mts +426 -0
  40. package/dist/_libs/unwasm.d.mts +29 -0
  41. package/dist/_presets.mjs +130 -80
  42. package/dist/builder.d.mts +4 -4
  43. package/dist/builder.mjs +6 -30
  44. package/dist/cli/_chunks/build.mjs +1 -1
  45. package/dist/cli/_chunks/dev.mjs +5 -11
  46. package/dist/cli/_chunks/list.mjs +1 -1
  47. package/dist/cli/_chunks/prepare.mjs +1 -1
  48. package/dist/cli/_chunks/run.mjs +1 -1
  49. package/dist/node_modules/@poppinss/colors/build/index.js +130 -160
  50. package/dist/node_modules/@poppinss/colors/package.json +20 -18
  51. package/dist/node_modules/@poppinss/exception/build/index.js +36 -55
  52. package/dist/node_modules/@poppinss/exception/package.json +19 -16
  53. package/dist/node_modules/@sindresorhus/is/distribution/index.js +46 -5
  54. package/dist/node_modules/@sindresorhus/is/package.json +1 -1
  55. package/dist/node_modules/@speed-highlight/core/dist/index.js +1 -1
  56. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +1 -1
  57. package/dist/node_modules/@speed-highlight/core/package.json +2 -2
  58. package/dist/node_modules/hookable/dist/index.mjs +5 -6
  59. package/dist/node_modules/hookable/package.json +13 -13
  60. package/dist/node_modules/ufo/dist/index.mjs +16 -9
  61. package/dist/node_modules/ufo/package.json +15 -14
  62. package/dist/node_modules/unctx/package.json +16 -16
  63. package/dist/node_modules/youch/build/{chunk-4XB2BYKC.js → chunk-7QV3D5YX.js} +2 -4
  64. package/dist/node_modules/youch/build/{chunk-PUHGL6HA.js → chunk-AUGPHE32.js} +2 -4
  65. package/dist/node_modules/youch/build/{chunk-F4I6KX4R.js → chunk-CM7DWJNZ.js} +2 -4
  66. package/dist/node_modules/youch/build/{chunk-YYEJ3AGB.js → chunk-EJH674NB.js} +2 -4
  67. package/dist/node_modules/youch/build/{chunk-EUJBVOYB.js → chunk-OIJ3WD7L.js} +2 -4
  68. package/dist/node_modules/youch/build/{chunk-HFSXRSKS.js → chunk-P36L72PL.js} +5 -3
  69. package/dist/node_modules/youch/build/{chunk-4YEN7HVQ.js → chunk-PE3GG3TN.js} +5 -1
  70. package/dist/node_modules/youch/build/{chunk-PINJDICN.js → chunk-X53OIOJH.js} +2 -4
  71. package/dist/node_modules/youch/build/index.js +8 -9
  72. package/dist/node_modules/youch/build/public/error_info/style.css +1 -0
  73. package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
  74. package/dist/node_modules/youch/build/public/error_stack/style.css +2 -3
  75. package/dist/node_modules/youch/package.json +1 -1
  76. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -1
  77. package/dist/presets/_nitro/runtime/nitro-dev.mjs +5 -6
  78. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +1 -1
  79. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -1
  80. package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -1
  81. package/dist/presets/_nitro/runtime/service-worker.mjs +2 -2
  82. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -1
  83. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +1 -1
  84. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -5
  85. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -1
  86. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +9 -11
  87. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +1 -1
  88. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +1 -1
  89. package/dist/presets/azure/runtime/azure-swa.d.mts +1 -1
  90. package/dist/presets/azure/runtime/azure-swa.mjs +1 -1
  91. package/dist/presets/bun/runtime/bun.d.mts +1 -1
  92. package/dist/presets/bun/runtime/bun.mjs +7 -8
  93. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +3 -3
  94. package/dist/presets/cloudflare/runtime/_module-handler.mjs +19 -17
  95. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +1 -1
  96. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +17 -16
  97. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -1
  98. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +8 -9
  99. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +1 -1
  100. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +12 -18
  101. package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -1
  102. package/dist/presets/deno/runtime/deno-deploy.mjs +4 -5
  103. package/dist/presets/deno/runtime/deno-server.d.mts +1 -1
  104. package/dist/presets/deno/runtime/deno-server.mjs +5 -6
  105. package/dist/presets/netlify/runtime/netlify-edge.d.mts +1 -2
  106. package/dist/presets/netlify/runtime/netlify-edge.mjs +3 -2
  107. package/dist/presets/netlify/runtime/netlify.d.mts +3 -2
  108. package/dist/presets/netlify/runtime/netlify.mjs +3 -1
  109. package/dist/presets/node/runtime/node-cluster.d.mts +1 -1
  110. package/dist/presets/node/runtime/node-cluster.mjs +5 -6
  111. package/dist/presets/node/runtime/node-middleware.d.mts +1 -1
  112. package/dist/presets/node/runtime/node-middleware.mjs +4 -5
  113. package/dist/presets/node/runtime/node-server.d.mts +1 -1
  114. package/dist/presets/node/runtime/node-server.mjs +5 -6
  115. package/dist/presets/standard/runtime/server.d.mts +1 -1
  116. package/dist/presets/standard/runtime/server.mjs +1 -1
  117. package/dist/presets/stormkit/runtime/stormkit.d.mts +1 -1
  118. package/dist/presets/stormkit/runtime/stormkit.mjs +1 -1
  119. package/dist/presets/vercel/runtime/isr.d.mts +2 -0
  120. package/dist/presets/vercel/runtime/isr.mjs +19 -0
  121. package/dist/presets/vercel/runtime/vercel.node.d.mts +1 -1
  122. package/dist/presets/vercel/runtime/vercel.node.mjs +16 -7
  123. package/dist/presets/vercel/runtime/vercel.web.d.mts +1 -1
  124. package/dist/presets/vercel/runtime/vercel.web.mjs +18 -13
  125. package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -2
  126. package/dist/presets/winterjs/runtime/winterjs.mjs +1 -1
  127. package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
  128. package/dist/presets/zeabur/runtime/zeabur.mjs +1 -1
  129. package/dist/runtime/app.d.mts +1 -1
  130. package/dist/runtime/app.mjs +1 -1
  131. package/dist/runtime/internal/app.d.mts +7 -3
  132. package/dist/runtime/internal/app.mjs +29 -22
  133. package/dist/runtime/internal/database.mjs +1 -1
  134. package/dist/runtime/internal/error/dev.d.mts +0 -1
  135. package/dist/runtime/internal/error/dev.mjs +1 -1
  136. package/dist/runtime/internal/route-rules.d.mts +0 -4
  137. package/dist/runtime/internal/routes/dev-tasks.mjs +1 -1
  138. package/dist/runtime/internal/routes/openapi.d.mts +0 -1
  139. package/dist/runtime/internal/routes/openapi.mjs +3 -3
  140. package/dist/runtime/internal/routes/renderer-template.dev.mjs +1 -1
  141. package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
  142. package/dist/runtime/internal/routes/scalar.d.mts +0 -1
  143. package/dist/runtime/internal/routes/scalar.mjs +4 -4
  144. package/dist/runtime/internal/routes/swagger.d.mts +0 -1
  145. package/dist/runtime/internal/routes/swagger.mjs +3 -3
  146. package/dist/runtime/internal/runtime-config.mjs +8 -8
  147. package/dist/runtime/internal/static.mjs +1 -1
  148. package/dist/runtime/internal/storage.mjs +1 -1
  149. package/dist/runtime/internal/task.mjs +1 -1
  150. package/dist/runtime/internal/vite/dev-entry.mjs +3 -4
  151. package/dist/runtime/internal/vite/{dev-worker.mjs → node-runner.mjs} +51 -6
  152. package/dist/runtime/meta.d.mts +1 -1
  153. package/dist/runtime/meta.mjs +1 -1
  154. package/dist/runtime/nitro.d.mts +0 -3
  155. package/dist/runtime/nitro.mjs +1 -1
  156. package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
  157. package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
  158. package/dist/runtime/virtual/database.d.mts +8 -0
  159. package/dist/runtime/virtual/database.mjs +2 -0
  160. package/dist/runtime/virtual/error-handler.d.mts +6 -0
  161. package/dist/runtime/virtual/error-handler.mjs +9 -0
  162. package/dist/runtime/virtual/feature-flags.d.mts +7 -0
  163. package/dist/runtime/virtual/feature-flags.mjs +7 -0
  164. package/dist/runtime/virtual/plugins.d.mts +3 -0
  165. package/dist/runtime/virtual/plugins.mjs +2 -0
  166. package/dist/runtime/virtual/polyfills.d.mts +3 -0
  167. package/dist/runtime/virtual/polyfills.mjs +2 -0
  168. package/dist/runtime/virtual/public-assets.d.mts +9 -0
  169. package/dist/runtime/virtual/public-assets.mjs +8 -0
  170. package/dist/runtime/virtual/renderer-template.d.mts +4 -0
  171. package/dist/runtime/virtual/renderer-template.mjs +7 -0
  172. package/dist/runtime/virtual/routing-meta.d.mts +7 -0
  173. package/dist/runtime/virtual/routing-meta.mjs +2 -0
  174. package/dist/runtime/virtual/routing.d.mts +8 -0
  175. package/dist/runtime/virtual/routing.mjs +11 -0
  176. package/dist/runtime/virtual/runtime-config.d.mts +3 -0
  177. package/dist/runtime/virtual/runtime-config.mjs +5 -0
  178. package/dist/runtime/virtual/server-assets.d.mts +6 -0
  179. package/dist/runtime/virtual/server-assets.mjs +12 -0
  180. package/dist/runtime/virtual/storage.d.mts +3 -0
  181. package/dist/runtime/virtual/storage.mjs +5 -0
  182. package/dist/runtime/virtual/tasks.d.mts +10 -0
  183. package/dist/runtime/virtual/tasks.mjs +3 -0
  184. package/dist/types/index.d.mts +292 -371
  185. package/dist/types/index.mjs +10 -0
  186. package/dist/vite.d.mts +7 -12
  187. package/dist/vite.mjs +734 -41
  188. package/lib/vite.types.d.mts +26 -0
  189. package/lib/vite.types.mjs +2 -0
  190. package/package.json +82 -53
  191. package/dist/_build/common2.mjs +0 -772
  192. package/dist/_build/vite.plugin.mjs +0 -768
  193. package/dist/_chunks/ANM1K1bE.mjs +0 -304
  194. package/dist/_chunks/BX9-zVkM.mjs +0 -59
  195. package/dist/_chunks/C7CbzoI1.mjs +0 -39
  196. package/dist/_libs/acorn.mjs +0 -5034
  197. package/dist/_libs/c12.mjs +0 -2858
  198. package/dist/_libs/commondir.mjs +0 -22
  199. package/dist/_libs/deepmerge.mjs +0 -86
  200. package/dist/_libs/dot-prop.mjs +0 -138
  201. package/dist/_libs/duplexer.mjs +0 -71
  202. package/dist/_libs/etag.mjs +0 -80
  203. package/dist/_libs/fdir.mjs +0 -514
  204. package/dist/_libs/function-bind.mjs +0 -63
  205. package/dist/_libs/giget.mjs +0 -19289
  206. package/dist/_libs/gzip-size.mjs +0 -21
  207. package/dist/_libs/hasown.mjs +0 -14
  208. package/dist/_libs/is-core-module.mjs +0 -220
  209. package/dist/_libs/is-module.mjs +0 -13
  210. package/dist/_libs/is-reference.mjs +0 -32
  211. package/dist/_libs/js-tokens.mjs +0 -382
  212. package/dist/_libs/knitwork.mjs +0 -124
  213. package/dist/_libs/local-pkg.mjs +0 -1686
  214. package/dist/_libs/magic-string.mjs +0 -939
  215. package/dist/_libs/mime.mjs +0 -1391
  216. package/dist/_libs/node-fetch-native.mjs +0 -173
  217. package/dist/_libs/path-parse.mjs +0 -47
  218. package/dist/_libs/pathe.mjs +0 -41
  219. package/dist/_libs/picomatch.mjs +0 -1673
  220. package/dist/_libs/plugin-replace.mjs +0 -104
  221. package/dist/_libs/pretty-bytes.mjs +0 -116
  222. package/dist/_libs/std-env.mjs +0 -158
  223. package/dist/_libs/strip-literal.mjs +0 -51
  224. package/dist/_libs/tinyglobby.mjs +0 -292
  225. package/dist/_libs/untyped.mjs +0 -271
  226. package/dist/_libs/unwasm.mjs +0 -5836
  227. package/dist/cli/_chunks/detect-acorn.mjs +0 -12
  228. package/dist/cli/_chunks/dist.mjs +0 -3
  229. package/dist/cli/_chunks/dist2.mjs +0 -3
  230. package/dist/cli/_chunks/dist3.mjs +0 -3
  231. package/dist/cli/_chunks/dist4.mjs +0 -4
  232. package/dist/cli/_chunks/dist5.mjs +0 -4
  233. package/dist/cli/_chunks/esm.mjs +0 -3
  234. package/dist/cli/_chunks/json5.mjs +0 -4
  235. package/dist/cli/_chunks/jsonc.mjs +0 -4
  236. package/dist/cli/_chunks/multipart-parser.mjs +0 -6
  237. package/dist/cli/_chunks/toml.mjs +0 -4
  238. package/dist/cli/_chunks/yaml.mjs +0 -4
  239. package/dist/node_modules/kleur/index.js +0 -110
  240. package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +0 -6
  241. package/lib/deps/ofetch.mjs +0 -1
  242. package/lib/deps/ofetch.mts +0 -1
  243. /package/dist/runtime/{vite-runtime.d.mts → vite.d.mts} +0 -0
  244. /package/dist/runtime/{vite-runtime.mjs → vite.mjs} +0 -0
  245. /package/lib/{deps/h3.d.mts → h3.d.mts} +0 -0
  246. /package/lib/{deps/h3.mjs → h3.mjs} +0 -0
@@ -1,15 +1,44 @@
1
- import { t as MagicString } from "./magic-string.mjs";
2
- import { t as stripLiteral } from "./strip-literal.mjs";
3
- import path from "node:path";
1
+ import { n as __exportAll } from "../_common.mjs";
2
+ import { S as MagicString, x as stripLiteral } from "../_build/common.mjs";
4
3
  import fs from "node:fs";
5
4
  import { fileURLToPath } from "node:url";
5
+ import path from "node:path";
6
6
  import assert from "node:assert";
7
- import "srvx/node";
8
7
  import { createHash } from "node:crypto";
9
8
  import { isCSSRequest, normalizePath } from "vite";
10
9
  import assert$1 from "node:assert/strict";
11
10
 
12
- //#region node_modules/.pnpm/@pi0+vite-plugin-fullstack@0.0.5-pr-1297_vite@7.2.2_@types+node@24.10.0_jiti@2.6.1_ligh_420de11c17db6dc1bb00fb6cc17e9a42/node_modules/@pi0/vite-plugin-fullstack/dist/index.js
11
+ //#region node_modules/.pnpm/@rolldown+pluginutils@1.0.0-beta.55/node_modules/@rolldown/pluginutils/dist/simple-filters.js
12
+ /**
13
+ * Constructs a RegExp that matches the exact string specified.
14
+ *
15
+ * This is useful for plugin hook filters.
16
+ *
17
+ * @param str the string to match.
18
+ * @param flags flags for the RegExp.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { exactRegex } from '@rolldown/pluginutils';
23
+ * const plugin = {
24
+ * name: 'plugin',
25
+ * resolveId: {
26
+ * filter: { id: exactRegex('foo') },
27
+ * handler(id) {} // will only be called for `foo`
28
+ * }
29
+ * }
30
+ * ```
31
+ */
32
+ function exactRegex(str, flags) {
33
+ return new RegExp(`^${escapeRegex(str)}$`, flags);
34
+ }
35
+ const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
36
+ function escapeRegex(str) {
37
+ return str.replace(escapeRegexRE, "\\$&");
38
+ }
39
+
40
+ //#endregion
41
+ //#region node_modules/.pnpm/@hiogawa+vite-plugin-fullstack@0.0.11_vite@8.0.0-beta.8_@types+node@25.0.9_esbuild@0.27_577572ae8fc6296e77b8a4205393d7c0/node_modules/@hiogawa/vite-plugin-fullstack/dist/plugin-B4MlD0Bd.js
13
42
  function parseIdQuery(id) {
14
43
  if (!id.includes("?")) return {
15
44
  filename: id,
@@ -30,13 +59,19 @@ function parseAssetsVirtual(id) {
30
59
  function createVirtualPlugin(name, load) {
31
60
  name = "virtual:" + name;
32
61
  return {
33
- name: `rsc:virtual-${name}`,
34
- resolveId: { handler(source, _importer, _options) {
35
- return source === name ? "\0" + name : void 0;
36
- } },
37
- load: { handler(id, options) {
38
- if (id === "\0" + name) return load.apply(this, [id, options]);
39
- } }
62
+ name: `fullstack:virtual-${name}`,
63
+ resolveId: {
64
+ filter: { id: exactRegex(name) },
65
+ handler(source, _importer, _options) {
66
+ return source === name ? "\0" + name : void 0;
67
+ }
68
+ },
69
+ load: {
70
+ filter: { id: exactRegex("\0" + name) },
71
+ handler(id, options) {
72
+ return load.apply(this, [id, options]);
73
+ }
74
+ }
40
75
  };
41
76
  }
42
77
  function normalizeRelativePath(s) {
@@ -114,11 +149,11 @@ function assetsPlugin(pluginOpts) {
114
149
  };
115
150
  const environment = server.environments[options.environment];
116
151
  assert$1(environment, `Unknown environment: ${options.environment}`);
117
- if (options.environment === "client") result.entry = normalizeViteImportAnalysisUrl(environment, id);
152
+ if (options.environment === "client") result.entry = assetsURLDev(normalizeViteImportAnalysisUrl(environment, id).slice(1), resolvedConfig);
118
153
  if (environment.name !== "client") {
119
154
  const collected = await collectCss(environment, id, { eager: pluginOpts?.experimental?.devEagerTransform ?? true });
120
155
  result.css = collected.hrefs.map((href, i) => ({
121
- href,
156
+ href: assetsURLDev(href.slice(1), resolvedConfig),
122
157
  "data-vite-dev-id": collected.ids[i]
123
158
  }));
124
159
  }
@@ -155,13 +190,13 @@ function assetsPlugin(pluginOpts) {
155
190
  };
156
191
  const { chunk, deps } = found;
157
192
  if (environmentName === "client") {
158
- result.entry = `/${chunk.fileName}`;
159
- result.js = deps.js.map((fileName) => ({ href: `/${fileName}` }));
193
+ result.entry = assetsURL(chunk.fileName, builder.config);
194
+ result.js = deps.js.map((fileName) => ({ href: assetsURL(fileName, builder.config) }));
160
195
  }
161
- result.css = deps.css.map((fileName) => ({ href: `/${fileName}` }));
196
+ result.css = deps.css.map((fileName) => ({ href: assetsURL(fileName, builder.config) }));
162
197
  if (!builder.environments[environmentName].config.build.cssCodeSplit) {
163
198
  const singleCss = Object.values(bundle).find((v) => v.type === "asset" && v.originalFileNames.includes("style.css"));
164
- if (singleCss) result.css.push({ href: `/${singleCss.fileName}` });
199
+ if (singleCss) result.css.push({ href: assetsURL(singleCss.fileName, builder.config) });
165
200
  }
166
201
  (manifest[environmentName] ??= {})[meta.key] = result;
167
202
  }
@@ -169,7 +204,7 @@ function assetsPlugin(pluginOpts) {
169
204
  const importerEnvironments = new Set(Object.values(importAssetsMetaMap).flatMap((metas) => Object.values(metas)).flatMap((meta) => meta.importerEnvironment));
170
205
  for (const environmentName of importerEnvironments) {
171
206
  const outDir = builder.environments[environmentName].config.build.outDir;
172
- fs.writeFileSync(path.join(outDir, BUILD_ASSETS_MANIFEST_NAME), `export default ${JSON.stringify(manifest, null, 2)};`);
207
+ fs.writeFileSync(path.join(outDir, BUILD_ASSETS_MANIFEST_NAME), `export default ${serializeValueWithRuntime(manifest)};`);
173
208
  const clientOutDir = builder.environments["client"].config.build.outDir;
174
209
  for (const asset of Object.values(bundleMap[environmentName])) if (asset.type === "asset") {
175
210
  const srcFile = path.join(outDir, asset.fileName);
@@ -192,85 +227,93 @@ function assetsPlugin(pluginOpts) {
192
227
  configEnvironment(name) {
193
228
  if ((pluginOpts?.serverEnvironments ?? ["ssr"]).includes(name)) return { build: { emitAssets: true } };
194
229
  },
195
- transform: { async handler(code, id, _options) {
196
- if (!code.includes("import.meta.vite.assets")) return;
197
- const output = new MagicString(code);
198
- const strippedCode = stripLiteral(code);
199
- const newImports = /* @__PURE__ */ new Set();
200
- for (const match of code.matchAll(/import\.meta\.vite\.assets\(([\s\S]*?)\)/dg)) {
201
- const [start, end] = match.indices[0];
202
- if (!strippedCode.slice(start, end).includes("import.meta.vite.assets")) continue;
203
- if (this.environment.name === "client") {
204
- const replacement$1 = `(${JSON.stringify(EMPTY_ASSETS)})`;
205
- output.update(start, end, replacement$1);
206
- continue;
230
+ transform: {
231
+ filter: { code: /import\.meta\.vite\.assets\(/ },
232
+ async handler(code, id, _options) {
233
+ const output = new MagicString(code);
234
+ const strippedCode = stripLiteral(code);
235
+ const newImports = /* @__PURE__ */ new Set();
236
+ for (const match of code.matchAll(/import\.meta\.vite\.assets\(([\s\S]*?)\)/dg)) {
237
+ const [start, end] = match.indices[0];
238
+ if (!strippedCode.slice(start, end).includes("import.meta.vite.assets")) continue;
239
+ if (this.environment.name === "client") {
240
+ const replacement$1 = `(${JSON.stringify(EMPTY_ASSETS)})`;
241
+ output.update(start, end, replacement$1);
242
+ continue;
243
+ }
244
+ const argCode = match[1].trim();
245
+ const options = {
246
+ import: id,
247
+ environment: void 0,
248
+ asEntry: false
249
+ };
250
+ if (argCode) {
251
+ const argValue = evalValue(argCode);
252
+ Object.assign(options, argValue);
253
+ }
254
+ const environments = options.environment ? [options.environment] : ["client", this.environment.name];
255
+ const importedNames = [];
256
+ for (const environment of environments) {
257
+ const importSource = toAssetsVirtual({
258
+ import: options.import,
259
+ importer: id,
260
+ environment,
261
+ entry: options.asEntry ? "1" : ""
262
+ });
263
+ const importedName = `__assets_${hashString(importSource)}`;
264
+ newImports.add(`;import ${importedName} from ${JSON.stringify(importSource)};\n`);
265
+ importedNames.push(importedName);
266
+ }
267
+ let replacement = importedNames[0];
268
+ if (importedNames.length > 1) {
269
+ newImports.add(`;import * as __assets_runtime from "virtual:fullstack/runtime";\n`);
270
+ replacement = `__assets_runtime.mergeAssets(${importedNames.join(", ")})`;
271
+ }
272
+ output.update(start, end, `(${replacement})`);
207
273
  }
208
- const argCode = match[1].trim();
209
- const options = {
210
- import: id,
211
- environment: void 0,
212
- asEntry: false
213
- };
214
- if (argCode) {
215
- const argValue = evalValue(argCode);
216
- Object.assign(options, argValue);
217
- }
218
- const environments = options.environment ? [options.environment] : ["client", this.environment.name];
219
- const importedNames = [];
220
- for (const environment of environments) {
221
- const importSource = toAssetsVirtual({
222
- import: options.import,
223
- importer: id,
224
- environment,
225
- entry: options.asEntry ? "1" : ""
226
- });
227
- const importedName = `__assets_${hashString(importSource)}`;
228
- newImports.add(`;import ${importedName} from ${JSON.stringify(importSource)};\n`);
229
- importedNames.push(importedName);
274
+ if (output.hasChanged()) {
275
+ for (const newImport of newImports) output.append(newImport);
276
+ return {
277
+ code: output.toString(),
278
+ map: output.generateMap({ hires: "boundary" })
279
+ };
230
280
  }
231
- let replacement = importedNames[0];
232
- if (importedNames.length > 1) {
233
- newImports.add(`;import * as __assets_runtime from "virtual:fullstack/runtime";\n`);
234
- replacement = `__assets_runtime.mergeAssets(${importedNames.join(", ")})`;
235
- }
236
- output.update(start, end, `(${replacement})`);
237
281
  }
238
- if (output.hasChanged()) {
239
- for (const newImport of newImports) output.append(newImport);
240
- return {
241
- code: output.toString(),
242
- map: output.generateMap({ hires: "boundary" })
243
- };
282
+ },
283
+ resolveId: {
284
+ filter: { id: /^virtual:fullstack\// },
285
+ handler(source) {
286
+ if (source === "virtual:fullstack/runtime") return "\0" + source;
287
+ if (source.startsWith("virtual:fullstack/assets?")) return "\0" + source;
288
+ if (source === "virtual:fullstack/assets-manifest") {
289
+ assert$1.notEqual(this.environment.name, "client");
290
+ assert$1.equal(this.environment.mode, "build");
291
+ return {
292
+ id: source,
293
+ external: true
294
+ };
295
+ }
244
296
  }
245
- } },
246
- resolveId: { handler(source) {
247
- if (source.startsWith("virtual:fullstack/assets?")) return "\0" + source;
248
- if (source === "virtual:fullstack/assets-manifest") {
297
+ },
298
+ load: {
299
+ filter: { id: /^\0virtual:fullstack\// },
300
+ async handler(id) {
301
+ if (id === "\0virtual:fullstack/runtime") return `export const mergeAssets = ${(await Promise.resolve().then(() => runtime_exports)).mergeAssets.toString()};`;
302
+ const parsed = parseAssetsVirtual(id);
303
+ if (!parsed) return;
249
304
  assert$1.notEqual(this.environment.name, "client");
250
- assert$1.equal(this.environment.mode, "build");
251
- return {
252
- id: source,
253
- external: true
254
- };
305
+ const resolved = await this.resolve(parsed.import, parsed.importer);
306
+ assert$1(resolved, `Failed to resolve: ${parsed.import}`);
307
+ const s = new MagicString("");
308
+ const code = await processAssetsImport(this, resolved.id, {
309
+ environment: parsed.environment,
310
+ isEntry: !!parsed.entry
311
+ });
312
+ s.append(`export default ${code};\n`);
313
+ if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
314
+ return s.toString();
255
315
  }
256
- if (source === "virtual:fullstack/runtime") return { id: source };
257
- } },
258
- load: { async handler(id) {
259
- if (id === "virtual:fullstack/runtime") return runtimeUtils();
260
- const parsed = parseAssetsVirtual(id);
261
- if (!parsed) return;
262
- assert$1.notEqual(this.environment.name, "client");
263
- const resolved = await this.resolve(parsed.import, parsed.importer);
264
- assert$1(resolved, `Failed to resolve: ${parsed.import}`);
265
- const s = new MagicString("");
266
- const code = await processAssetsImport(this, resolved.id, {
267
- environment: parsed.environment,
268
- isEntry: !!parsed.entry
269
- });
270
- s.append(`export default ${code};\n`);
271
- if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
272
- return s.toString();
273
- } },
316
+ },
274
317
  renderChunk(code, chunk) {
275
318
  if (code.includes("virtual:fullstack/assets-manifest")) {
276
319
  const replacement = normalizeRelativePath(path.relative(path.join(chunk.fileName, ".."), BUILD_ASSETS_MANIFEST_NAME));
@@ -315,50 +358,52 @@ function assetsPlugin(pluginOpts) {
315
358
  sharedDuringBuild: true,
316
359
  resolveId: {
317
360
  order: "pre",
361
+ filter: { id: /[?&]assets/ },
318
362
  handler(source) {
319
363
  const { query } = parseIdQuery(source);
320
364
  if (typeof query["assets"] !== "undefined") {
321
365
  if (this.environment.name === "client") return `\0virtual:fullstack/empty-assets`;
322
366
  }
323
- if (source === "virtual:fullstack/runtime") return source;
324
367
  }
325
368
  },
326
- load: { async handler(id) {
327
- if (id === "\0virtual:fullstack/empty-assets") return `export default ${JSON.stringify(EMPTY_ASSETS)}`;
328
- if (id === "virtual:fullstack/runtime") return runtimeUtils();
329
- const { filename, query } = parseIdQuery(id);
330
- const value = query["assets"];
331
- if (typeof value !== "undefined") {
332
- const s = new MagicString("");
333
- const codes = [];
334
- if (value) {
335
- const code = await processAssetsImport(this, filename, {
336
- environment: value,
337
- isEntry: value === "client"
338
- });
339
- codes.push(code);
340
- } else {
341
- const code1 = await processAssetsImport(this, filename, {
342
- environment: "client",
343
- isEntry: false
344
- });
345
- const code2 = await processAssetsImport(this, filename, {
346
- environment: this.environment.name,
347
- isEntry: false
348
- });
349
- codes.push(code1, code2);
350
- }
351
- s.append(`
369
+ load: {
370
+ filter: { id: [/^\0virtual:fullstack\/empty-assets$/, /[?&]assets/] },
371
+ async handler(id) {
372
+ if (id === "\0virtual:fullstack/empty-assets") return `export default ${JSON.stringify(EMPTY_ASSETS)}`;
373
+ const { filename, query } = parseIdQuery(id);
374
+ const value = query["assets"];
375
+ if (typeof value !== "undefined") {
376
+ const s = new MagicString("");
377
+ const codes = [];
378
+ if (value) {
379
+ const code = await processAssetsImport(this, filename, {
380
+ environment: value,
381
+ isEntry: value === "client"
382
+ });
383
+ codes.push(code);
384
+ } else {
385
+ const code1 = await processAssetsImport(this, filename, {
386
+ environment: "client",
387
+ isEntry: false
388
+ });
389
+ const code2 = await processAssetsImport(this, filename, {
390
+ environment: this.environment.name,
391
+ isEntry: false
392
+ });
393
+ codes.push(code1, code2);
394
+ }
395
+ s.append(`
352
396
  import * as __assets_runtime from "virtual:fullstack/runtime";\n
353
397
  export default __assets_runtime.mergeAssets(${codes.join(", ")});
354
398
  `);
355
- if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
356
- return {
357
- code: s.toString(),
358
- moduleSideEffects: false
359
- };
399
+ if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
400
+ return {
401
+ code: s.toString(),
402
+ moduleSideEffects: false
403
+ };
404
+ }
360
405
  }
361
- } },
406
+ },
362
407
  hotUpdate(ctx) {
363
408
  if (this.environment.name === "rsc") {
364
409
  const mods = collectModuleDependents(ctx.modules);
@@ -478,11 +523,13 @@ function patchViteClientPlugin() {
478
523
  }
479
524
  return {
480
525
  name: "fullstack:patch-vite-client",
481
- transform: { handler(code, id) {
482
- if (id === viteClientPath) {
483
- if (code.includes("linkSheetsMap")) return;
484
- const s = new MagicString(code);
485
- s.prependLeft(code.indexOf("const sheetsMap"), `\
526
+ transform: {
527
+ filter: { id: exactRegex(viteClientPath) },
528
+ handler(code, id) {
529
+ if (id === viteClientPath) {
530
+ if (code.includes("linkSheetsMap")) return;
531
+ const s = new MagicString(code);
532
+ s.prependLeft(code.indexOf("const sheetsMap"), `\
486
533
  const linkSheetsMap = new Map();
487
534
  document
488
535
  .querySelectorAll('link[rel="stylesheet"][data-vite-dev-id]')
@@ -490,8 +537,8 @@ document
490
537
  linkSheetsMap.set(el.getAttribute('data-vite-dev-id'), el)
491
538
  });
492
539
  `);
493
- s.appendLeft(endIndexOf(code, `function updateStyle(id, content) {`), `if (linkSheetsMap.has(id)) { return }`);
494
- s.appendLeft(endIndexOf(code, `function removeStyle(id) {`), `
540
+ s.appendLeft(endIndexOf(code, `function updateStyle(id, content) {`), `if (linkSheetsMap.has(id)) { return }`);
541
+ s.appendLeft(endIndexOf(code, `function removeStyle(id) {`), `
495
542
  const link = linkSheetsMap.get(id);
496
543
  if (link) {
497
544
  document
@@ -506,9 +553,10 @@ if (link) {
506
553
  linkSheetsMap.delete(id)
507
554
  }
508
555
  `);
509
- return s.toString();
556
+ return s.toString();
557
+ }
510
558
  }
511
- } }
559
+ }
512
560
  };
513
561
  }
514
562
  function patchVueScopeCssHmr() {
@@ -537,25 +585,68 @@ function patchCssLinkSelfAccept() {
537
585
  }
538
586
  };
539
587
  }
540
- function runtimeUtils() {
541
- return `
542
- export function mergeAssets(...args) {
543
- const js = uniqBy(args.flatMap((h) => h.js), (a) => a.href);
544
- const css = uniqBy(args.flatMap((h) => h.css), (a) => a.href);
545
- const entry = args.filter((arg) => arg.entry)?.[0]?.entry;
546
- const raw = { entry, js, css };
547
- return { ...raw, merge: (...args$1) => mergeAssets(raw, ...args$1) };
548
- }
549
- function uniqBy(array, key) {
550
- const seen = new Set();
551
- return array.filter((item) => {
552
- const k = key(item);
553
- if (seen.has(k)) return false;
554
- seen.add(k);
555
- return true;
556
- });
557
- }`;
588
+ var BuildAssetsURLWithRuntime = class {
589
+ constructor(runtime) {
590
+ this.runtime = runtime;
591
+ }
592
+ };
593
+ function serializeValueWithRuntime(value) {
594
+ const replacements = [];
595
+ let result = JSON.stringify(value, (_key, value$1) => {
596
+ if (value$1 instanceof BuildAssetsURLWithRuntime) {
597
+ const placeholder = `__runtime_placeholder_${replacements.length}__`;
598
+ replacements.push([placeholder, value$1.runtime]);
599
+ return placeholder;
600
+ }
601
+ return value$1;
602
+ }, 2);
603
+ for (const [placeholder, runtime] of replacements) result = result.replace(`"${placeholder}"`, runtime);
604
+ return result;
605
+ }
606
+ function assetsURL(url, config) {
607
+ if (config.command === "build" && typeof config.experimental?.renderBuiltUrl === "function") {
608
+ const result = config.experimental.renderBuiltUrl(url, {
609
+ type: "asset",
610
+ hostType: "js",
611
+ ssr: true,
612
+ hostId: ""
613
+ });
614
+ if (typeof result === "object") {
615
+ if (result.runtime) return new BuildAssetsURLWithRuntime(result.runtime);
616
+ assert$1(!result.relative, "\"result.relative\" not supported on renderBuiltUrl() for fullstack plugin");
617
+ } else if (result) return result;
618
+ }
619
+ return config.base + url;
620
+ }
621
+ function assetsURLDev(url, config) {
622
+ return config.base + url;
623
+ }
624
+
625
+ //#endregion
626
+ //#region node_modules/.pnpm/@hiogawa+vite-plugin-fullstack@0.0.11_vite@8.0.0-beta.8_@types+node@25.0.9_esbuild@0.27_577572ae8fc6296e77b8a4205393d7c0/node_modules/@hiogawa/vite-plugin-fullstack/dist/runtime.js
627
+ var runtime_exports = /* @__PURE__ */ __exportAll({ mergeAssets: () => mergeAssets });
628
+ function mergeAssets(...args) {
629
+ const js = uniqBy(args.flatMap((h) => h.js), (a) => a.href);
630
+ const css = uniqBy(args.flatMap((h) => h.css), (a) => a.href);
631
+ const raw = {
632
+ entry: args.filter((arg) => arg.entry)?.[0]?.entry,
633
+ js,
634
+ css
635
+ };
636
+ return {
637
+ ...raw,
638
+ merge: (...args$1) => mergeAssets(raw, ...args$1)
639
+ };
640
+ function uniqBy(array, key) {
641
+ const seen = /* @__PURE__ */ new Set();
642
+ return array.filter((item) => {
643
+ const k = key(item);
644
+ if (seen.has(k)) return false;
645
+ seen.add(k);
646
+ return true;
647
+ });
648
+ }
558
649
  }
559
650
 
560
651
  //#endregion
561
- export { assetsPlugin as t };
652
+ export { assetsPlugin as n, runtime_exports as t };