nitro-nightly 3.0.1-20251211-155448-9dc8f6b6 → 3.0.1-20251211-173432-d37caecd

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 (61) hide show
  1. package/dist/_build/shared3.mjs +25 -25
  2. package/dist/_presets.mjs +1 -1
  3. package/dist/presets/_nitro/runtime/nitro-dev.mjs +4 -4
  4. package/dist/presets/_nitro/runtime/service-worker.mjs +1 -1
  5. package/dist/presets/bun/runtime/bun.mjs +4 -4
  6. package/dist/presets/cloudflare/runtime/_module-handler.mjs +1 -1
  7. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +3 -3
  8. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +3 -3
  9. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +4 -4
  10. package/dist/presets/deno/runtime/deno-deploy.mjs +2 -2
  11. package/dist/presets/deno/runtime/deno-server.mjs +4 -4
  12. package/dist/presets/netlify/runtime/netlify-edge.mjs +1 -1
  13. package/dist/presets/node/runtime/node-cluster.mjs +4 -4
  14. package/dist/presets/node/runtime/node-middleware.mjs +3 -3
  15. package/dist/presets/node/runtime/node-server.mjs +4 -4
  16. package/dist/runtime/internal/app.mjs +4 -4
  17. package/dist/runtime/internal/database.mjs +1 -1
  18. package/dist/runtime/internal/routes/dev-tasks.mjs +1 -1
  19. package/dist/runtime/internal/routes/openapi.mjs +1 -1
  20. package/dist/runtime/internal/routes/renderer-template.dev.mjs +1 -1
  21. package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
  22. package/dist/runtime/internal/runtime-config.d.mts +8 -0
  23. package/dist/runtime/internal/runtime-config.mjs +42 -2
  24. package/dist/runtime/internal/static.mjs +1 -1
  25. package/dist/runtime/internal/storage.mjs +1 -1
  26. package/dist/runtime/internal/task.mjs +1 -1
  27. package/dist/runtime/internal/vite/dev-entry.mjs +2 -2
  28. package/dist/runtime/internal/vite/ssr-renderer.mjs +1 -1
  29. package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
  30. package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
  31. package/dist/runtime/virtual/database.d.mts +8 -0
  32. package/dist/runtime/virtual/database.mjs +2 -0
  33. package/dist/runtime/virtual/error-handler.d.mts +6 -0
  34. package/dist/runtime/virtual/error-handler.mjs +9 -0
  35. package/dist/runtime/virtual/feature-flags.d.mts +8 -0
  36. package/dist/runtime/virtual/feature-flags.mjs +8 -0
  37. package/dist/runtime/virtual/plugins.d.mts +3 -0
  38. package/dist/runtime/virtual/plugins.mjs +2 -0
  39. package/dist/runtime/virtual/polyfills.d.mts +3 -0
  40. package/dist/runtime/virtual/polyfills.mjs +2 -0
  41. package/dist/runtime/virtual/public-assets.d.mts +9 -0
  42. package/dist/runtime/virtual/public-assets.mjs +8 -0
  43. package/dist/runtime/virtual/renderer-template.d.mts +5 -0
  44. package/dist/runtime/virtual/renderer-template.mjs +7 -0
  45. package/dist/runtime/virtual/routing-meta.d.mts +7 -0
  46. package/dist/runtime/virtual/routing-meta.mjs +2 -0
  47. package/dist/runtime/virtual/routing.d.mts +8 -0
  48. package/dist/runtime/virtual/routing.mjs +11 -0
  49. package/dist/runtime/virtual/runtime-config.d.mts +3 -0
  50. package/dist/runtime/virtual/runtime-config.mjs +5 -0
  51. package/dist/runtime/virtual/server-assets.d.mts +6 -0
  52. package/dist/runtime/virtual/server-assets.mjs +12 -0
  53. package/dist/runtime/virtual/storage.d.mts +3 -0
  54. package/dist/runtime/virtual/storage.mjs +5 -0
  55. package/dist/runtime/virtual/tasks.d.mts +10 -0
  56. package/dist/runtime/virtual/tasks.mjs +3 -0
  57. package/package.json +5 -4
  58. package/dist/runtime/internal/runtime-config.utils.d.mts +0 -7
  59. package/dist/runtime/internal/runtime-config.utils.mjs +0 -41
  60. /package/dist/runtime/{vite-runtime.d.mts → vite.d.mts} +0 -0
  61. /package/dist/runtime/{vite-runtime.mjs → vite.mjs} +0 -0
@@ -143,7 +143,7 @@ function routeToFsPath(route) {
143
143
  //#region src/build/virtual/database.ts
144
144
  function database(nitro) {
145
145
  return {
146
- id: "#nitro-internal-virtual/database",
146
+ id: "#nitro/virtual/database",
147
147
  template: () => {
148
148
  if (!nitro.options.experimental.database) return `export const connectionConfigs = {};`;
149
149
  const dbConfigs = nitro.options.dev && nitro.options.devDatabase || nitro.options.database;
@@ -167,7 +167,7 @@ export const connectionConfigs = {
167
167
  //#region src/build/virtual/error-handler.ts
168
168
  function errorHandler(nitro) {
169
169
  return {
170
- id: "#nitro-internal-virtual/error-handler",
170
+ id: "#nitro/virtual/error-handler",
171
171
  template: () => {
172
172
  const errorHandlers = Array.isArray(nitro.options.errorHandler) ? nitro.options.errorHandler : [nitro.options.errorHandler];
173
173
  const builtinHandler = join(runtimeDir, `internal/error/${nitro.options.dev ? "dev" : "prod"}`);
@@ -201,7 +201,7 @@ export default async function(error, event) {
201
201
  //#region src/build/virtual/feature-flags.ts
202
202
  function featureFlags(nitro) {
203
203
  return {
204
- id: "#nitro-internal-virtual/feature-flags",
204
+ id: "#nitro/virtual/feature-flags",
205
205
  template: () => {
206
206
  const featureFlags$1 = {
207
207
  hasRoutes: nitro.routing.routes.hasRoutes(),
@@ -221,7 +221,7 @@ function featureFlags(nitro) {
221
221
  //#region src/build/virtual/plugins.ts
222
222
  function plugins(nitro) {
223
223
  return {
224
- id: "#nitro-internal-virtual/plugins",
224
+ id: "#nitro/virtual/plugins",
225
225
  template: () => {
226
226
  const nitroPlugins = [...new Set(nitro.options.plugins)];
227
227
  return `
@@ -260,7 +260,7 @@ const readAssetHandler = {
260
260
  function publicAssets(nitro) {
261
261
  return [
262
262
  {
263
- id: "#nitro-internal-virtual/public-assets-data",
263
+ id: "#nitro/virtual/public-assets-data",
264
264
  template: async () => {
265
265
  const assets = {};
266
266
  const files = await glob("**", {
@@ -293,12 +293,12 @@ function publicAssets(nitro) {
293
293
  }
294
294
  },
295
295
  {
296
- id: "#nitro-internal-virtual/public-assets",
296
+ id: "#nitro/virtual/public-assets",
297
297
  template: () => {
298
298
  const publicAssetBases = Object.fromEntries(nitro.options.publicAssets.filter((dir) => !dir.fallthrough && dir.baseURL !== "/").map((dir) => [withTrailingSlash(joinURL(nitro.options.baseURL, dir.baseURL || "/")), { maxAge: dir.maxAge }]));
299
299
  return `
300
- import assets from '#nitro-internal-virtual/public-assets-data'
301
- export { readAsset } from "${`#nitro-internal-virtual/public-assets-${readAssetHandler[nitro.options.serveStatic] || "null"}`}"
300
+ import assets from '#nitro/virtual/public-assets-data'
301
+ export { readAsset } from "${`#nitro/virtual/public-assets-${readAssetHandler[nitro.options.serveStatic] || "null"}`}"
302
302
  export const publicAssetBases = ${JSON.stringify(publicAssetBases)}
303
303
 
304
304
  export function isPublicAssetURL(id = '') {
@@ -325,13 +325,13 @@ export function getAsset (id) {
325
325
  }
326
326
  },
327
327
  {
328
- id: "#nitro-internal-virtual/public-assets-node",
328
+ id: "#nitro/virtual/public-assets-node",
329
329
  template: () => {
330
330
  return `
331
331
  import { promises as fsp } from 'node:fs'
332
332
  import { fileURLToPath } from 'node:url'
333
333
  import { resolve, dirname } from 'node:path'
334
- import assets from '#nitro-internal-virtual/public-assets-data'
334
+ import assets from '#nitro/virtual/public-assets-data'
335
335
  export function readAsset (id) {
336
336
  const serverDir = dirname(fileURLToPath(globalThis.__nitro_main__))
337
337
  return fsp.readFile(resolve(serverDir, assets[id].path))
@@ -339,10 +339,10 @@ export function readAsset (id) {
339
339
  }
340
340
  },
341
341
  {
342
- id: "#nitro-internal-virtual/public-assets-deno",
342
+ id: "#nitro/virtual/public-assets-deno",
343
343
  template: () => {
344
344
  return `
345
- import assets from '#nitro-internal-virtual/public-assets-data'
345
+ import assets from '#nitro/virtual/public-assets-data'
346
346
  export function readAsset (id) {
347
347
  // https://deno.com/deploy/docs/serve-static-assets
348
348
  const path = '.' + decodeURIComponent(new URL(\`../public\${id}\`, 'file://').pathname)
@@ -351,7 +351,7 @@ export function readAsset (id) {
351
351
  }
352
352
  },
353
353
  {
354
- id: "#nitro-internal-virtual/public-assets-null",
354
+ id: "#nitro/virtual/public-assets-null",
355
355
  template: () => {
356
356
  return `
357
357
  export function readAsset (id) {
@@ -360,10 +360,10 @@ export function readAsset (id) {
360
360
  }
361
361
  },
362
362
  {
363
- id: "#nitro-internal-virtual/public-assets-inline",
363
+ id: "#nitro/virtual/public-assets-inline",
364
364
  template: () => {
365
365
  return `
366
- import assets from '#nitro-internal-virtual/public-assets-data'
366
+ import assets from '#nitro/virtual/public-assets-data'
367
367
  export function readAsset (id) {
368
368
  if (!assets[id]) { return undefined }
369
369
  if (assets[id]._data) { return assets[id]._data }
@@ -380,7 +380,7 @@ export function readAsset (id) {
380
380
  //#region src/build/virtual/renderer-template.ts
381
381
  function rendererTemplate(nitro) {
382
382
  return {
383
- id: "#nitro-internal-virtual/renderer-template",
383
+ id: "#nitro/virtual/renderer-template",
384
384
  template: async () => {
385
385
  const template = nitro.options.renderer?.template;
386
386
  if (typeof template !== "string") return `
@@ -414,7 +414,7 @@ function rendererTemplate(nitro) {
414
414
  //#region src/build/virtual/routing-meta.ts
415
415
  function routingMeta(nitro) {
416
416
  return {
417
- id: "#nitro-internal-virtual/routing-meta",
417
+ id: "#nitro/virtual/routing-meta",
418
418
  template: () => {
419
419
  const routeHandlers = uniqueBy$1(Object.values(nitro.routing.routes.routes).flatMap((h) => h.data), "_importHash");
420
420
  return `
@@ -440,7 +440,7 @@ const RuntimeRouteRules = [
440
440
  ];
441
441
  function routing(nitro) {
442
442
  return {
443
- id: "#nitro-internal-virtual/routing",
443
+ id: "#nitro/virtual/routing",
444
444
  template: () => {
445
445
  const allHandlers = uniqueBy([
446
446
  ...Object.values(nitro.routing.routes.routes).flatMap((h) => h.data),
@@ -448,7 +448,7 @@ function routing(nitro) {
448
448
  ...nitro.routing.globalMiddleware
449
449
  ], "_importHash");
450
450
  return `
451
- import * as __routeRules__ from "#runtime/route-rules";
451
+ import * as __routeRules__ from "#nitro/runtime/route-rules";
452
452
  import * as srvxNode from "srvx/node"
453
453
  import * as h3 from "h3";
454
454
 
@@ -517,7 +517,7 @@ function serializeRouteRule(h) {
517
517
  //#region src/build/virtual/runtime-config.ts
518
518
  function runtimeConfig(nitro) {
519
519
  return {
520
- id: "#nitro-internal-virtual/runtime-config",
520
+ id: "#nitro/virtual/runtime-config",
521
521
  template: () => {
522
522
  return `export const runtimeConfig = ${JSON.stringify(nitro.options.runtimeConfig || {})};`;
523
523
  }
@@ -529,7 +529,7 @@ function runtimeConfig(nitro) {
529
529
  var import_etag = /* @__PURE__ */ __toESM(require_etag(), 1);
530
530
  function serverAssets(nitro) {
531
531
  return {
532
- id: "#nitro-internal-virtual/server-assets",
532
+ id: "#nitro/virtual/server-assets",
533
533
  template: async () => {
534
534
  if (nitro.options.dev || nitro.options.preset === "nitro-prerender") return `
535
535
  import { createStorage } from 'unstorage'
@@ -595,7 +595,7 @@ export const assets = {
595
595
  //#region src/build/virtual/storage.ts
596
596
  function storage(nitro) {
597
597
  return {
598
- id: "#nitro-internal-virtual/storage",
598
+ id: "#nitro/virtual/storage",
599
599
  template: () => {
600
600
  const mounts = [];
601
601
  const storageMounts = nitro.options.dev || nitro.options.preset === "nitro-prerender" ? {
@@ -612,7 +612,7 @@ function storage(nitro) {
612
612
  }
613
613
  return `
614
614
  import { createStorage } from 'unstorage'
615
- import { assets } from '#nitro-internal-virtual/server-assets'
615
+ import { assets } from '#nitro/virtual/server-assets'
616
616
 
617
617
  ${[...new Set(mounts.map((m) => m.driver))].map((i) => genImport(i, genSafeVariableName(i))).join("\n")}
618
618
 
@@ -631,7 +631,7 @@ export function initStorage() {
631
631
  //#region src/build/virtual/tasks.ts
632
632
  function tasks(nitro) {
633
633
  return {
634
- id: "#nitro-internal-virtual/tasks",
634
+ id: "#nitro/virtual/tasks",
635
635
  template: () => {
636
636
  const _scheduledTasks = Object.entries(nitro.options.scheduledTasks || {}).map(([cron, _tasks]) => {
637
637
  return {
@@ -822,7 +822,7 @@ function nitroResolveIds() {
822
822
  resolveId: {
823
823
  order: "pre",
824
824
  handler(id, importer, rOpts) {
825
- if (importer && importer.startsWith("\0nitro:virtual:#nitro-internal-virtual")) return this.resolve(id, runtimeDir, { skipSelf: true });
825
+ if (importer?.includes("#nitro/virtual")) return this.resolve(id, runtimeDir, { ...rOpts });
826
826
  const mappedId = subpathMap[id];
827
827
  if (mappedId) return this.resolve(mappedId, runtimeDir, { skipSelf: true });
828
828
  }
package/dist/_presets.mjs CHANGED
@@ -652,7 +652,7 @@ async function setupEntryExports(nitro) {
652
652
  const exportsEntry = resolveExportsEntry(nitro);
653
653
  if (!exportsEntry) return;
654
654
  const originalEntry = nitro.options.entry;
655
- const virtualEntryId = nitro.options.entry = "#nitro-internal-virtual/cloudflare-server-entry";
655
+ const virtualEntryId = nitro.options.entry = "#nitro/virtual/cloudflare-server-entry";
656
656
  nitro.options.virtual[virtualEntryId] = `
657
657
  export * from "${exportsEntry}";
658
658
  export * from "${originalEntry}";
@@ -5,10 +5,10 @@ import wsAdapter from "crossws/adapters/node";
5
5
  import { toNodeHandler } from "srvx/node";
6
6
  import { getSocketAddress, isSocketSupported } from "get-port-please";
7
7
  import { useNitroApp, useNitroHooks } from "nitro/app";
8
- import { startScheduleRunner } from "#runtime/task";
9
- import { trapUnhandledErrors } from "#runtime/error/hooks";
10
- import { resolveWebsocketHooks } from "#runtime/app";
11
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
8
+ import { startScheduleRunner } from "#nitro/runtime/task";
9
+ import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
10
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
11
+ import { hasWebSocket } from "#nitro/virtual/feature-flags";
12
12
  // Listen for shutdown signal from runner
13
13
  parentPort?.on("message", (msg) => {
14
14
  if (msg && msg.event === "shutdown") {
@@ -1,6 +1,6 @@
1
1
  import "#nitro-internal-polyfills";
2
2
  import { useNitroApp } from "nitro/app";
3
- import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
3
+ import { isPublicAssetURL } from "#nitro/virtual/public-assets";
4
4
  const nitroApp = useNitroApp();
5
5
  // @ts-expect-error
6
6
  addEventListener("fetch", (event) => {
@@ -2,10 +2,10 @@ import "#nitro-internal-polyfills";
2
2
  import { serve } from "srvx/bun";
3
3
  import wsAdapter from "crossws/adapters/bun";
4
4
  import { useNitroApp } from "nitro/app";
5
- import { startScheduleRunner } from "#runtime/task";
6
- import { trapUnhandledErrors } from "#runtime/error/hooks";
7
- import { resolveWebsocketHooks } from "#runtime/app";
8
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
5
+ import { startScheduleRunner } from "#nitro/runtime/task";
6
+ import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
7
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
8
+ import { hasWebSocket } from "#nitro/virtual/feature-flags";
9
9
  const port = Number.parseInt(process.env.NITRO_PORT || process.env.PORT || "") || 3e3;
10
10
  const host = process.env.NITRO_HOST || process.env.HOST;
11
11
  const cert = process.env.NITRO_SSL_CERT;
@@ -1,5 +1,5 @@
1
1
  import "#nitro-internal-polyfills";
2
- import { runCronTasks } from "#runtime/task";
2
+ import { runCronTasks } from "#nitro/runtime/task";
3
3
  import { useNitroApp, useNitroHooks } from "nitro/app";
4
4
  export function createHandler(hooks) {
5
5
  const nitroApp = useNitroApp();
@@ -3,9 +3,9 @@ import { DurableObject } from "cloudflare:workers";
3
3
  import wsAdapter from "crossws/adapters/cloudflare";
4
4
  import { createHandler, fetchHandler } from "./_module-handler.mjs";
5
5
  import { useNitroApp, useNitroHooks } from "nitro/app";
6
- import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
7
- import { resolveWebsocketHooks } from "#runtime/app";
8
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
6
+ import { isPublicAssetURL } from "#nitro/virtual/public-assets";
7
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
8
+ import { hasWebSocket } from "#nitro/virtual/feature-flags";
9
9
  const DURABLE_BINDING = "$DurableObject";
10
10
  const DURABLE_INSTANCE = "server";
11
11
  const nitroApp = useNitroApp();
@@ -1,9 +1,9 @@
1
1
  import "#nitro-internal-polyfills";
2
2
  import wsAdapter from "crossws/adapters/cloudflare";
3
- import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
3
+ import { isPublicAssetURL } from "#nitro/virtual/public-assets";
4
4
  import { createHandler } from "./_module-handler.mjs";
5
- import { resolveWebsocketHooks } from "#runtime/app";
6
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
5
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
6
+ import { hasWebSocket } from "#nitro/virtual/feature-flags";
7
7
  const ws = hasWebSocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
8
8
  export default createHandler({ fetch(request, env, context, url) {
9
9
  // Static assets fallback (optional binding)
@@ -1,10 +1,10 @@
1
1
  import "#nitro-internal-polyfills";
2
2
  import wsAdapter from "crossws/adapters/cloudflare";
3
3
  import { useNitroApp } from "nitro/app";
4
- import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
5
- import { runCronTasks } from "#runtime/task";
6
- import { resolveWebsocketHooks } from "#runtime/app";
7
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
4
+ import { isPublicAssetURL } from "#nitro/virtual/public-assets";
5
+ import { runCronTasks } from "#nitro/runtime/task";
6
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
7
+ import { hasWebSocket } from "#nitro/virtual/feature-flags";
8
8
  const nitroApp = useNitroApp();
9
9
  const ws = hasWebSocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
10
10
  export default {
@@ -1,8 +1,8 @@
1
1
  import "#nitro-internal-polyfills";
2
2
  import wsAdapter from "crossws/adapters/deno";
3
3
  import { useNitroApp } from "nitro/app";
4
- import { resolveWebsocketHooks } from "#runtime/app";
5
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
4
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
5
+ import { hasWebSocket } from "#nitro/virtual/feature-flags";
6
6
  const nitroApp = useNitroApp();
7
7
  const ws = hasWebSocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
8
8
  // TODO: Migrate to srvx to provide request IP
@@ -2,10 +2,10 @@ import "#nitro-internal-polyfills";
2
2
  import { serve } from "srvx/deno";
3
3
  import wsAdapter from "crossws/adapters/deno";
4
4
  import { useNitroApp } from "nitro/app";
5
- import { startScheduleRunner } from "#runtime/task";
6
- import { trapUnhandledErrors } from "#runtime/error/hooks";
7
- import { resolveWebsocketHooks } from "#runtime/app";
8
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
5
+ import { startScheduleRunner } from "#nitro/runtime/task";
6
+ import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
7
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
8
+ import { hasWebSocket } from "#nitro/virtual/feature-flags";
9
9
  const port = Number.parseInt(process.env.NITRO_PORT || process.env.PORT || "") || 3e3;
10
10
  const host = process.env.NITRO_HOST || process.env.HOST;
11
11
  const cert = process.env.NITRO_SSL_CERT;
@@ -1,6 +1,6 @@
1
1
  import "#nitro-internal-polyfills";
2
2
  import { useNitroApp } from "nitro/app";
3
- import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
3
+ import { isPublicAssetURL } from "#nitro/virtual/public-assets";
4
4
  const nitroApp = useNitroApp();
5
5
  // https://docs.netlify.com/edge-functions/api/
6
6
  export default async function netlifyEdge(netlifyReq, context) {
@@ -3,10 +3,10 @@ import cluster from "node:cluster";
3
3
  import { NodeRequest, serve } from "srvx/node";
4
4
  import wsAdapter from "crossws/adapters/node";
5
5
  import { useNitroApp } from "nitro/app";
6
- import { startScheduleRunner } from "#runtime/task";
7
- import { trapUnhandledErrors } from "#runtime/error/hooks";
8
- import { resolveWebsocketHooks } from "#runtime/app";
9
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
6
+ import { startScheduleRunner } from "#nitro/runtime/task";
7
+ import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
8
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
9
+ import { hasWebSocket } from "#nitro/virtual/feature-flags";
10
10
  const port = Number.parseInt(process.env.NITRO_PORT || process.env.PORT || "") || 3e3;
11
11
  const host = process.env.NITRO_HOST || process.env.HOST;
12
12
  const cert = process.env.NITRO_SSL_CERT;
@@ -2,9 +2,9 @@ import "#nitro-internal-polyfills";
2
2
  import { toNodeHandler } from "srvx/node";
3
3
  import wsAdapter from "crossws/adapters/node";
4
4
  import { useNitroApp } from "nitro/app";
5
- import { startScheduleRunner } from "#runtime/task";
6
- import { resolveWebsocketHooks } from "#runtime/app";
7
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
5
+ import { startScheduleRunner } from "#nitro/runtime/task";
6
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
7
+ import { hasWebSocket } from "#nitro/virtual/feature-flags";
8
8
  const nitroApp = useNitroApp();
9
9
  export const middleware = toNodeHandler(nitroApp.fetch);
10
10
  const ws = hasWebSocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
@@ -2,10 +2,10 @@ import "#nitro-internal-polyfills";
2
2
  import { NodeRequest, serve } from "srvx/node";
3
3
  import wsAdapter from "crossws/adapters/node";
4
4
  import { useNitroApp } from "nitro/app";
5
- import { startScheduleRunner } from "#runtime/task";
6
- import { trapUnhandledErrors } from "#runtime/error/hooks";
7
- import { resolveWebsocketHooks } from "#runtime/app";
8
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
5
+ import { startScheduleRunner } from "#nitro/runtime/task";
6
+ import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
7
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
8
+ import { hasWebSocket } from "#nitro/virtual/feature-flags";
9
9
  const port = Number.parseInt(process.env.NITRO_PORT || process.env.PORT || "") || 3e3;
10
10
  const host = process.env.NITRO_HOST || process.env.HOST;
11
11
  const cert = process.env.NITRO_SSL_CERT;
@@ -2,10 +2,10 @@ import { H3Core, toRequest } from "h3";
2
2
  import { HookableCore } from "hookable";
3
3
  import { nitroAsyncContext } from "./context.mjs";
4
4
  // IMPORTANT: virtual imports and user code should be imported last to avoid initialization order issues
5
- import errorHandler from "#nitro-internal-virtual/error-handler";
6
- import { plugins } from "#nitro-internal-virtual/plugins";
7
- import { findRoute, findRouteRules, globalMiddleware, findRoutedMiddleware } from "#nitro-internal-virtual/routing";
8
- import { hasRouteRules, hasRoutedMiddleware, hasGlobalMiddleware, hasRoutes, hasHooks, hasPlugins } from "#nitro-internal-virtual/feature-flags";
5
+ import errorHandler from "#nitro/virtual/error-handler";
6
+ import { plugins } from "#nitro/virtual/plugins";
7
+ import { findRoute, findRouteRules, globalMiddleware, findRoutedMiddleware } from "#nitro/virtual/routing";
8
+ import { hasRouteRules, hasRoutedMiddleware, hasGlobalMiddleware, hasRoutes, hasHooks, hasPlugins } from "#nitro/virtual/feature-flags";
9
9
  export function useNitroApp() {
10
10
  return useNitroApp.__instance__ ??= initNitroApp();
11
11
  }
@@ -1,5 +1,5 @@
1
1
  import { createDatabase } from "db0";
2
- import { connectionConfigs } from "#nitro-internal-virtual/database";
2
+ import { connectionConfigs } from "#nitro/virtual/database";
3
3
  const instances = Object.create(null);
4
4
  export function useDatabase(name = "default") {
5
5
  if (instances[name]) {
@@ -1,6 +1,6 @@
1
1
  import { H3 } from "h3";
2
2
  import { runTask } from "../task.mjs";
3
- import { scheduledTasks, tasks } from "#nitro-internal-virtual/tasks";
3
+ import { scheduledTasks, tasks } from "#nitro/virtual/tasks";
4
4
  export default new H3().get("/_nitro/tasks", async () => {
5
5
  const _tasks = await Promise.all(Object.entries(tasks).map(async ([name, task]) => {
6
6
  const _task = await task.resolve?.();
@@ -1,7 +1,7 @@
1
1
  import { defineHandler, getRequestURL } from "h3";
2
2
  import { joinURL } from "ufo";
3
3
  import { defu } from "defu";
4
- import { handlersMeta } from "#nitro-internal-virtual/routing-meta";
4
+ import { handlersMeta } from "#nitro/virtual/routing-meta";
5
5
  import { useRuntimeConfig } from "../runtime-config.mjs";
6
6
  // Served as /_openapi.json
7
7
  export default defineHandler((event) => {
@@ -1,5 +1,5 @@
1
1
  import { serverFetch } from "../app.mjs";
2
- import { rendererTemplate, rendererTemplateFile, isStaticTemplate } from "#nitro-internal-virtual/renderer-template";
2
+ import { rendererTemplate, rendererTemplateFile, isStaticTemplate } from "#nitro/virtual/renderer-template";
3
3
  import { HTTPResponse } from "h3";
4
4
  import { hasTemplateSyntax, renderToResponse, compileTemplate } from "rendu";
5
5
  export default async function renderIndexHTML(event) {
@@ -1,4 +1,4 @@
1
- import { rendererTemplate } from "#nitro-internal-virtual/renderer-template";
1
+ import { rendererTemplate } from "#nitro/virtual/renderer-template";
2
2
  export default function renderIndexHTML(event) {
3
3
  return rendererTemplate(event.req);
4
4
  }
@@ -1,2 +1,10 @@
1
1
  import type { NitroRuntimeConfig } from "nitro/types";
2
2
  export declare function useRuntimeConfig(): NitroRuntimeConfig;
3
+ // ---- utils ----
4
+ type EnvOptions = {
5
+ prefix?: string;
6
+ altPrefix?: string;
7
+ envExpansion?: boolean;
8
+ };
9
+ export declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string);
10
+ export {};
@@ -1,5 +1,5 @@
1
- import { applyEnv } from "./runtime-config.utils.mjs";
2
- import { runtimeConfig } from "#nitro-internal-virtual/runtime-config";
1
+ import { snakeCase } from "scule";
2
+ import { runtimeConfig } from "#nitro/virtual/runtime-config";
3
3
  export function useRuntimeConfig() {
4
4
  return useRuntimeConfig._cached ||= getRuntimeConfig();
5
5
  }
@@ -12,3 +12,43 @@ function getRuntimeConfig() {
12
12
  });
13
13
  return runtimeConfig;
14
14
  }
15
+ export function applyEnv(obj, opts, parentKey = "") {
16
+ for (const key in obj) {
17
+ const subKey = parentKey ? `${parentKey}_${key}` : key;
18
+ const envValue = getEnv(subKey, opts);
19
+ if (_isObject(obj[key])) {
20
+ // Same as before
21
+ if (_isObject(envValue)) {
22
+ obj[key] = {
23
+ ...obj[key],
24
+ ...envValue
25
+ };
26
+ applyEnv(obj[key], opts, subKey);
27
+ } else if (envValue === undefined) {
28
+ applyEnv(obj[key], opts, subKey);
29
+ } else {
30
+ obj[key] = envValue ?? obj[key];
31
+ }
32
+ } else {
33
+ obj[key] = envValue ?? obj[key];
34
+ }
35
+ // Experimental env expansion
36
+ if (opts.envExpansion && typeof obj[key] === "string") {
37
+ obj[key] = _expandFromEnv(obj[key]);
38
+ }
39
+ }
40
+ return obj;
41
+ }
42
+ const envExpandRx = /\{\{([^{}]*)\}\}/g;
43
+ function _expandFromEnv(value) {
44
+ return value.replace(envExpandRx, (match, key) => {
45
+ return process.env[key] || match;
46
+ });
47
+ }
48
+ function getEnv(key, opts) {
49
+ const envKey = snakeCase(key).toUpperCase();
50
+ return process.env[opts.prefix + envKey] ?? process.env[opts.altPrefix + envKey];
51
+ }
52
+ function _isObject(input) {
53
+ return input !== null && typeof input === "object" && !Array.isArray(input);
54
+ }
@@ -1,6 +1,6 @@
1
1
  import { HTTPError, defineHandler } from "h3";
2
2
  import { decodePath, joinURL, withLeadingSlash, withoutTrailingSlash } from "ufo";
3
- import { getAsset, isPublicAssetURL, readAsset } from "#nitro-internal-virtual/public-assets";
3
+ import { getAsset, isPublicAssetURL, readAsset } from "#nitro/virtual/public-assets";
4
4
  const METHODS = new Set(["HEAD", "GET"]);
5
5
  const EncodingMap = {
6
6
  gzip: ".gz",
@@ -1,5 +1,5 @@
1
1
  import { prefixStorage } from "unstorage";
2
- import { initStorage } from "#nitro-internal-virtual/storage";
2
+ import { initStorage } from "#nitro/virtual/storage";
3
3
  export function useStorage(base = "") {
4
4
  const storage = useStorage._storage ??= initStorage();
5
5
  return base ? prefixStorage(storage, base) : storage;
@@ -1,6 +1,6 @@
1
1
  import { Cron } from "croner";
2
2
  import { HTTPError } from "h3";
3
- import { scheduledTasks, tasks } from "#nitro-internal-virtual/tasks";
3
+ import { scheduledTasks, tasks } from "#nitro/virtual/tasks";
4
4
  /** @experimental */
5
5
  export function defineTask(def) {
6
6
  if (typeof def.run !== "function") {
@@ -2,8 +2,8 @@ import "#nitro-internal-polyfills";
2
2
  import wsAdapter from "crossws/adapters/node";
3
3
 
4
4
  import { useNitroApp } from "nitro/app";
5
- import { resolveWebsocketHooks } from "#runtime/app";
6
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
5
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
6
+ import { hasWebSocket } from "#nitro/virtual/feature-flags";
7
7
 
8
8
  const nitroApp = useNitroApp();
9
9
 
@@ -1,4 +1,4 @@
1
- import { fetchViteEnv } from "#vite-runtime";
1
+ import { fetchViteEnv } from "nitro/vite/runtime";
2
2
 
3
3
  /** @param {{ req: Request }} HTTPEvent */
4
4
  export default function ssrRenderer({ req }) {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import consola from "consola";
2
+ import { isTest } from "std-env";
3
+ if (!isTest) {
4
+ consola.warn("Nitro runtime imports detected without a builder or Nitro plugin. A stub implementation will be used.");
5
+ }
@@ -0,0 +1,8 @@
1
+ import "./_runtime_warn.mjs";
2
+ import type { Connector } from "db0";
3
+ export declare const connectionConfigs: {
4
+ [name: string]: {
5
+ connector: (options: any) => Connector;
6
+ options: any;
7
+ };
8
+ };
@@ -0,0 +1,2 @@
1
+ import "./_runtime_warn.mjs";
2
+ export const connectionConfigs = {};
@@ -0,0 +1,6 @@
1
+ import "./_runtime_warn.mjs";
2
+ import type { NitroErrorHandler } from "nitro/types";
3
+ type EParams = Parameters<NitroErrorHandler>;
4
+ type EReturn = ReturnType<NitroErrorHandler>;
5
+ declare const errorHandler: (error: EParams[0], event: EParams[1]) => EReturn;
6
+ export default errorHandler;
@@ -0,0 +1,9 @@
1
+ import "./_runtime_warn.mjs";
2
+ import { toResponse } from "h3";
3
+ const errorHandler = (error, event) => {
4
+ if (error.status !== 404) {
5
+ console.error(error);
6
+ }
7
+ return toResponse(error, event);
8
+ };
9
+ export default errorHandler;
@@ -0,0 +1,8 @@
1
+ import "./_runtime_warn.mjs";
2
+ export declare const hasRoutes: boolean;
3
+ export declare const hasRouteRules: boolean;
4
+ export declare const hasGlobalMiddleware: boolean;
5
+ export declare const hasRoutedMiddleware: boolean;
6
+ export declare const hasPlugins: boolean;
7
+ export declare const hasHooks: boolean;
8
+ export declare const hasWebSocket: boolean;
@@ -0,0 +1,8 @@
1
+ import "./_runtime_warn.mjs";
2
+ export const hasRoutes = true;
3
+ export const hasRouteRules = true;
4
+ export const hasGlobalMiddleware = true;
5
+ export const hasRoutedMiddleware = true;
6
+ export const hasPlugins = true;
7
+ export const hasHooks = true;
8
+ export const hasWebSocket = true;
@@ -0,0 +1,3 @@
1
+ import "./_runtime_warn.mjs";
2
+ import type { NitroAppPlugin } from "nitro/types";
3
+ export declare const plugins: NitroAppPlugin[];
@@ -0,0 +1,2 @@
1
+ import "./_runtime_warn.mjs";
2
+ export const plugins = [];
@@ -0,0 +1,3 @@
1
+ import "./_runtime_warn.mjs";
2
+ declare const _default: {};
3
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import "./_runtime_warn.mjs";
2
+ export default {};
@@ -0,0 +1,9 @@
1
+ import "./_runtime_warn.mjs";
2
+ import type { PublicAsset } from "nitro/types";
3
+ export declare const publicAssetBases: string[];
4
+ export declare const isPublicAssetURL: (id: string) => boolean;
5
+ export declare const getPublicAssetMeta: (id: string) => {
6
+ maxAge?: number;
7
+ } | null;
8
+ export declare const readAsset: (id: string) => Promise<Buffer>;
9
+ export declare const getAsset: (id: string) => PublicAsset | null;
@@ -0,0 +1,8 @@
1
+ import "./_runtime_warn.mjs";
2
+ export const publicAssetBases = [];
3
+ export const isPublicAssetURL = () => false;
4
+ export const getPublicAssetMeta = () => null;
5
+ export const readAsset = async () => {
6
+ throw new Error("Asset not found");
7
+ };
8
+ export const getAsset = () => null;
@@ -0,0 +1,5 @@
1
+ import "./_runtime_warn.mjs";
2
+ export declare function rendererTemplate(_req: Request): string | Promise<string>;
3
+ // dev only
4
+ export declare const rendererTemplateFile: string | undefined;
5
+ export declare const isStaticTemplate: boolean | undefined;
@@ -0,0 +1,7 @@
1
+ import "./_runtime_warn.mjs";
2
+ export function rendererTemplate(_req) {
3
+ return `<!-- Renderer template not available -->`;
4
+ }
5
+ // dev only
6
+ export const rendererTemplateFile = undefined;
7
+ export const isStaticTemplate = undefined;
@@ -0,0 +1,7 @@
1
+ import "./_runtime_warn.mjs";
2
+ import type { NitroRouteMeta } from "nitro/types";
3
+ export declare const handlersMeta: {
4
+ route?: string;
5
+ method?: string;
6
+ meta?: NitroRouteMeta;
7
+ }[];
@@ -0,0 +1,2 @@
1
+ import "./_runtime_warn.mjs";
2
+ export const handlersMeta = [];
@@ -0,0 +1,8 @@
1
+ import "./_runtime_warn.mjs";
2
+ import type { Middleware, H3Route } from "h3";
3
+ import type { MatchedRoute } from "rou3";
4
+ import type { MatchedRouteRule } from "nitro/types";
5
+ export declare function findRoute(_method: string, _path: string): MatchedRoute<H3Route> | undefined;
6
+ export declare function findRouteRules(_method: string, _path: string): MatchedRoute<MatchedRouteRule[]>[];
7
+ export declare const globalMiddleware: Middleware[];
8
+ export declare function findRoutedMiddleware(_method: string, _path: string): MatchedRoute<Middleware>[];
@@ -0,0 +1,11 @@
1
+ import "./_runtime_warn.mjs";
2
+ export function findRoute(_method, _path) {
3
+ return undefined;
4
+ }
5
+ export function findRouteRules(_method, _path) {
6
+ return [];
7
+ }
8
+ export const globalMiddleware = [];
9
+ export function findRoutedMiddleware(_method, _path) {
10
+ return [];
11
+ }
@@ -0,0 +1,3 @@
1
+ import "./_runtime_warn.mjs";
2
+ import type { NitroRuntimeConfig } from "nitro/types";
3
+ export declare const runtimeConfig: NitroRuntimeConfig;
@@ -0,0 +1,5 @@
1
+ import "./_runtime_warn.mjs";
2
+ export const runtimeConfig = {
3
+ app: {},
4
+ nitro: {}
5
+ };
@@ -0,0 +1,6 @@
1
+ import "./_runtime_warn.mjs";
2
+ import type { AssetMeta } from "nitro/types";
3
+ export declare const assets: unknown;
4
+ export declare function readAsset<T = any>(_id: string): Promise<T>;
5
+ export declare function statAsset(_id: string): Promise<AssetMeta>;
6
+ export declare function getKeys(): Promise<string[]>;
@@ -0,0 +1,12 @@
1
+ import "./_runtime_warn.mjs";
2
+ import { createStorage } from "unstorage";
3
+ export const assets = createStorage();
4
+ export function readAsset(_id) {
5
+ return Promise.resolve({});
6
+ }
7
+ export function statAsset(_id) {
8
+ return Promise.resolve({});
9
+ }
10
+ export function getKeys() {
11
+ return Promise.resolve([]);
12
+ }
@@ -0,0 +1,3 @@
1
+ import "./_runtime_warn.mjs";
2
+ import { type Storage } from "unstorage";
3
+ export declare function initStorage(): Storage;
@@ -0,0 +1,5 @@
1
+ import "./_runtime_warn.mjs";
2
+ import { createStorage } from "unstorage";
3
+ export function initStorage() {
4
+ return createStorage();
5
+ }
@@ -0,0 +1,10 @@
1
+ import "./_runtime_warn.mjs";
2
+ import type { Task, TaskMeta } from "nitro/types";
3
+ export declare const tasks: Record<string, {
4
+ resolve?: () => Promise<Task>;
5
+ meta: TaskMeta;
6
+ }>;
7
+ export declare const scheduledTasks: false | {
8
+ cron: string;
9
+ tasks: string[];
10
+ }[];
@@ -0,0 +1,3 @@
1
+ import "./_runtime_warn.mjs";
2
+ export const tasks = {};
3
+ export const scheduledTasks = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.0.1-20251211-155448-9dc8f6b6",
3
+ "version": "3.0.1-20251211-173432-d37caecd",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",
@@ -24,11 +24,12 @@
24
24
  "./task": "./dist/runtime/task.mjs",
25
25
  "./tsconfig": "./lib/tsconfig.json",
26
26
  "./types": "./dist/types/index.mjs",
27
- "./vite": "./dist/vite.mjs"
27
+ "./vite": "./dist/vite.mjs",
28
+ "./vite/runtime": "./dist/runtime/vite.mjs"
28
29
  },
29
30
  "imports": {
30
- "#runtime/*": "./dist/runtime/internal/*.mjs",
31
- "#vite-runtime": "./dist/runtime/vite-runtime.mjs"
31
+ "#nitro/runtime/*": "./dist/runtime/internal/*.mjs",
32
+ "#nitro/virtual/*": "./dist/runtime/virtual/*.mjs"
32
33
  },
33
34
  "types": "./lib/index.d.mts",
34
35
  "bin": {
@@ -1,7 +0,0 @@
1
- type EnvOptions = {
2
- prefix?: string;
3
- altPrefix?: string;
4
- envExpansion?: boolean;
5
- };
6
- export declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string);
7
- export {};
@@ -1,41 +0,0 @@
1
- import { snakeCase } from "scule";
2
- export function applyEnv(obj, opts, parentKey = "") {
3
- for (const key in obj) {
4
- const subKey = parentKey ? `${parentKey}_${key}` : key;
5
- const envValue = getEnv(subKey, opts);
6
- if (_isObject(obj[key])) {
7
- // Same as before
8
- if (_isObject(envValue)) {
9
- obj[key] = {
10
- ...obj[key],
11
- ...envValue
12
- };
13
- applyEnv(obj[key], opts, subKey);
14
- } else if (envValue === undefined) {
15
- applyEnv(obj[key], opts, subKey);
16
- } else {
17
- obj[key] = envValue ?? obj[key];
18
- }
19
- } else {
20
- obj[key] = envValue ?? obj[key];
21
- }
22
- // Experimental env expansion
23
- if (opts.envExpansion && typeof obj[key] === "string") {
24
- obj[key] = _expandFromEnv(obj[key]);
25
- }
26
- }
27
- return obj;
28
- }
29
- const envExpandRx = /\{\{([^{}]*)\}\}/g;
30
- function _expandFromEnv(value) {
31
- return value.replace(envExpandRx, (match, key) => {
32
- return process.env[key] || match;
33
- });
34
- }
35
- function getEnv(key, opts) {
36
- const envKey = snakeCase(key).toUpperCase();
37
- return process.env[opts.prefix + envKey] ?? process.env[opts.altPrefix + envKey];
38
- }
39
- function _isObject(input) {
40
- return typeof input === "object" && !Array.isArray(input);
41
- }
File without changes
File without changes