nitro 3.0.260415-beta → 3.0.260522-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 (91) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
  2. package/dist/_build/common.mjs +157 -45
  3. package/dist/_build/rolldown.mjs +6 -6
  4. package/dist/_build/rollup.mjs +11 -11
  5. package/dist/_build/vite.build.mjs +3 -3
  6. package/dist/_build/vite.dev.mjs +149 -0
  7. package/dist/_build/vite.env.mjs +177 -0
  8. package/dist/_chunks/nitro.mjs +241 -14
  9. package/dist/_chunks/nitro2.mjs +117 -90
  10. package/dist/_chunks/utils.mjs +4 -4
  11. package/dist/_common.mjs +2 -2
  12. package/dist/_dev.d.mts +1 -1
  13. package/dist/_dev.mjs +7 -6
  14. package/dist/_libs/c12+rc9.mjs +24 -11
  15. package/dist/_libs/c12+readdirp+chokidar.d.mts +7 -8
  16. package/dist/_libs/citty.mjs +1 -1
  17. package/dist/_libs/common.d.mts +37 -0
  18. package/dist/_libs/commondir+is-reference.mjs +3 -3
  19. package/dist/_libs/compatx.d.mts +1 -1
  20. package/dist/_libs/compatx.mjs +1 -1
  21. package/dist/_libs/estree+pluginutils.d.mts +1 -1
  22. package/dist/_libs/estree-walker.mjs +1 -1
  23. package/dist/_libs/hasown+resolve+deepmerge.mjs +62 -49
  24. package/dist/_libs/httpxy.d.mts +2 -4
  25. package/dist/_libs/httpxy.mjs +13 -9
  26. package/dist/_libs/jsonc-parser+workers-utils.d.mts +1579 -0
  27. package/dist/_libs/klona.mjs +1 -1
  28. package/dist/_libs/magic-string.d.mts +1 -1
  29. package/dist/_libs/mlly.d.mts +1 -1
  30. package/dist/_libs/nypm+tinyexec.mjs +137 -113
  31. package/dist/_libs/openapi-types.d.mts +730 -0
  32. package/dist/_libs/perfect-debounce.mjs +1 -1
  33. package/dist/_libs/pkg-types.d.mts +8 -5
  34. package/dist/_libs/plugin-alias.mjs +2 -2
  35. package/dist/_libs/plugin-inject.mjs +4 -2
  36. package/dist/_libs/plugin-json.mjs +2 -2
  37. package/dist/_libs/pluginutils.mjs +18 -5
  38. package/dist/_libs/readdirp+chokidar.mjs +4 -3
  39. package/dist/_libs/remapping.mjs +2 -2
  40. package/dist/_libs/resolve-uri+gen-mapping.mjs +2 -5
  41. package/dist/_libs/rou3.d.mts +1 -1
  42. package/dist/_libs/rou3.mjs +1 -1
  43. package/dist/_libs/std-env.d.mts +1 -1
  44. package/dist/_libs/tsconfck.mjs +1 -1
  45. package/dist/_libs/ultrahtml.mjs +1 -1
  46. package/dist/_libs/unimport+unplugin.mjs +61 -39
  47. package/dist/_libs/unplugin+unimport.d.mts +4 -4
  48. package/dist/_libs/unwasm.d.mts +1 -1
  49. package/dist/_presets.mjs +118 -91
  50. package/dist/builder.d.mts +1 -1
  51. package/dist/builder.mjs +3 -3
  52. package/dist/cli/_chunks/build.mjs +3 -3
  53. package/dist/cli/_chunks/common.mjs +1 -1
  54. package/dist/cli/_chunks/deploy.mjs +2 -2
  55. package/dist/cli/_chunks/dev.mjs +4 -4
  56. package/dist/cli/_chunks/docs.mjs +1 -1
  57. package/dist/cli/_chunks/list.mjs +2 -2
  58. package/dist/cli/_chunks/prepare.mjs +3 -3
  59. package/dist/cli/_chunks/preview.mjs +4 -4
  60. package/dist/cli/_chunks/run.mjs +2 -2
  61. package/dist/cli/_chunks/task.mjs +1 -1
  62. package/dist/cli/index.mjs +1 -1
  63. package/dist/docs/0.docs/5.cache.md +53 -9
  64. package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +3 -3
  65. package/dist/docs/1.deploy/2.providers/21.vercel.md +6 -0
  66. package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +1 -1
  67. package/dist/node_modules/ufo/dist/index.mjs +2 -2
  68. package/dist/node_modules/ufo/package.json +9 -9
  69. package/dist/presets/azure/runtime/azure-swa.mjs +2 -0
  70. package/dist/presets/vercel/runtime/queue.dev.mjs +41 -0
  71. package/dist/runtime/internal/app.mjs +4 -111
  72. package/dist/runtime/internal/route-rules.d.mts +1 -0
  73. package/dist/runtime/internal/route-rules.mjs +29 -1
  74. package/dist/runtime/internal/routes/scalar.mjs +1 -0
  75. package/dist/runtime/virtual/app.d.mts +4 -0
  76. package/dist/runtime/virtual/app.mjs +32 -0
  77. package/dist/types/index.d.mts +959 -1836
  78. package/dist/vite.d.mts +1 -1
  79. package/dist/vite.mjs +23 -331
  80. package/package.json +43 -44
  81. package/dist/THIRD-PARTY-LICENSES.md +0 -1646
  82. package/dist/_chunks/nitro3.mjs +0 -136
  83. package/dist/_chunks/nitro4.mjs +0 -127
  84. package/dist/_libs/_.mjs +0 -2
  85. package/dist/_libs/_2.mjs +0 -2
  86. package/dist/_libs/_3.mjs +0 -2
  87. package/dist/_libs/_4.mjs +0 -2
  88. package/dist/_libs/_5.mjs +0 -2
  89. package/dist/_libs/_6.mjs +0 -2
  90. package/dist/_libs/_7.mjs +0 -2
  91. package/dist/_libs/escape-string-regexp.mjs +0 -5
@@ -1,100 +1,127 @@
1
- import { M as glob, ct as join, ut as relative } from "../_build/common.mjs";
2
- import { withBase, withLeadingSlash, withoutTrailingSlash } from "ufo";
3
- const GLOB_SCAN_PATTERN = "**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}";
4
- const suffixRegex = /(\.(?<method>connect|delete|get|head|options|patch|post|put|trace))?(\.(?<env>dev|prod|prerender))?$/;
5
- async function scanAndSyncOptions(nitro) {
6
- const scannedPlugins = await scanPlugins(nitro);
7
- for (const plugin of scannedPlugins) if (!nitro.options.plugins.includes(plugin)) nitro.options.plugins.push(plugin);
8
- if (nitro.options.experimental.tasks) {
9
- const scannedTasks = await scanTasks(nitro);
10
- for (const scannedTask of scannedTasks) if (scannedTask.name in nitro.options.tasks) {
11
- if (!nitro.options.tasks[scannedTask.name].handler) nitro.options.tasks[scannedTask.name].handler = scannedTask.handler;
12
- } else nitro.options.tasks[scannedTask.name] = {
13
- handler: scannedTask.handler,
14
- description: ""
1
+ import { getBuildInfo, join, prettyPath, resolve } from "../_build/common.mjs";
2
+ import { proxyFetch, proxyUpgrade } from "../_libs/httpxy.mjs";
3
+ import consola from "consola";
4
+ import { spawn } from "node:child_process";
5
+ async function startPreview(opts) {
6
+ const { outputDir, buildInfo } = await getBuildInfo(opts.rootDir);
7
+ if (!buildInfo) throw new Error("Cannot load nitro build info. Make sure to build first.");
8
+ const info = [
9
+ ["Build Directory:", prettyPath(outputDir)],
10
+ ["Date:", buildInfo.date && new Date(buildInfo.date).toLocaleString()],
11
+ ["Nitro Version:", buildInfo.versions.nitro],
12
+ ["Nitro Preset:", buildInfo.preset],
13
+ buildInfo.framework?.name !== "nitro" && ["Framework:", buildInfo.framework?.name + (buildInfo.framework?.version ? ` (v${buildInfo.framework.version})` : "")]
14
+ ].filter((i) => i && i[1]);
15
+ consola.box({
16
+ title: " [Build Info] ",
17
+ message: info.map((i) => `- ${i[0]} ${i[1]}`).join("\n")
18
+ });
19
+ const dotEnvEntries = await loadPreviewDotEnv(opts.rootDir);
20
+ if (dotEnvEntries.length > 0) consola.box({
21
+ title: " [Environment Variables] ",
22
+ message: [
23
+ "Loaded variables from .env files (preview mode only).",
24
+ "Set platform environment variables for production:",
25
+ ...dotEnvEntries.map(([key, val]) => ` - ${key}`)
26
+ ].join("\n")
27
+ });
28
+ if (buildInfo.preset.includes("cloudflare")) {
29
+ if (!buildInfo.commands?.preview) throw new Error(`No nitro build preview command found for the "${buildInfo.preset}" preset.`);
30
+ return await runPreviewCommand({
31
+ command: buildInfo.commands.preview,
32
+ rootDir: opts.rootDir,
33
+ env: dotEnvEntries
34
+ });
35
+ }
36
+ let fetchHandler = () => Promise.resolve(new Response("Not Found", { status: 404 }));
37
+ if (buildInfo.serverEntry) {
38
+ for (const [key, val] of dotEnvEntries) if (!process.env[key]) process.env[key] = val;
39
+ const { loadServerEntry } = await import("srvx/loader");
40
+ const entry = await loadServerEntry({
41
+ entry: resolve(outputDir, buildInfo.serverEntry),
42
+ ...opts.loader
43
+ });
44
+ if (entry.fetch) fetchHandler = entry.fetch;
45
+ }
46
+ if (buildInfo.publicDir) {
47
+ const { serveStatic } = await import("srvx/static");
48
+ const staticHandler = serveStatic({ dir: join(outputDir, buildInfo.publicDir) });
49
+ const originalFetchHandler = fetchHandler;
50
+ fetchHandler = async (req) => {
51
+ const staticRes = await staticHandler(req, () => void 0);
52
+ if (staticRes) return staticRes;
53
+ return originalFetchHandler(req);
15
54
  };
16
55
  }
17
- const scannedModules = await scanModules(nitro);
18
- nitro.options.modules = nitro.options.modules || [];
19
- for (const modPath of scannedModules) if (!nitro.options.modules.includes(modPath)) nitro.options.modules.push(modPath);
56
+ return {
57
+ fetch: fetchHandler,
58
+ async close() {}
59
+ };
20
60
  }
21
- async function scanHandlers(nitro) {
22
- const middleware = await scanMiddleware(nitro);
23
- const handlers = await Promise.all([scanServerRoutes(nitro, nitro.options.apiDir || "api", nitro.options.apiBaseURL || "/api"), scanServerRoutes(nitro, nitro.options.routesDir || "routes")]).then((r) => r.flat());
24
- const seenHandlers = /* @__PURE__ */ new Set();
25
- nitro.scannedHandlers = [...middleware, ...handlers.filter((h) => {
26
- const key = `${h.route}\0${h.method}\0${h.env}`;
27
- return seenHandlers.has(key) ? false : (seenHandlers.add(key), true);
28
- })];
29
- nitro.routing.sync();
30
- return handlers;
31
- }
32
- async function scanMiddleware(nitro) {
33
- return (await scanFiles(nitro, "middleware")).map((file) => {
34
- return {
35
- route: "/**",
36
- middleware: true,
37
- handler: file.fullPath
38
- };
61
+ async function loadPreviewDotEnv(root) {
62
+ const { loadDotenv } = await import("../_libs/c12+rc9.mjs").then((n) => n.dist_exports);
63
+ const env = await loadDotenv({
64
+ cwd: root,
65
+ fileName: [
66
+ ".env.preview",
67
+ ".env.production",
68
+ ".env"
69
+ ]
39
70
  });
71
+ return Object.entries(env).filter(([_key, val]) => val);
40
72
  }
41
- async function scanServerRoutes(nitro, dir, prefix = "/") {
42
- return (await scanFiles(nitro, dir)).map((file) => {
43
- let route = file.path.replace(/\.[A-Za-z]+$/, "").replace(/\(([^(/\\]+)\)[/\\]/g, "").replace(/\[\.{3}]/g, "**").replace(/\[\.{3}([^\]]+)]/g, (_, p) => "**:" + p.replace(/[^\w-]/g, "_")).replace(/\[([^/\]]+)]/g, (_, p) => ":" + p.replace(/[^\w-]/g, "_"));
44
- route = withLeadingSlash(withoutTrailingSlash(withBase(route, prefix)));
45
- const suffixMatch = route.match(suffixRegex);
46
- let method;
47
- let env;
48
- if (suffixMatch?.index && suffixMatch?.index >= 0) {
49
- route = route.slice(0, suffixMatch.index);
50
- method = suffixMatch.groups?.method;
51
- env = suffixMatch.groups?.env;
73
+ async function runPreviewCommand(opts) {
74
+ const [arg0, ...args] = opts.command.split(" ");
75
+ consola.info(`Spawning preview server...`);
76
+ consola.info(opts.command);
77
+ console.log("");
78
+ const { getRandomPort, waitForPort } = await import("get-port-please");
79
+ const randomPort = await getRandomPort();
80
+ const child = spawn(arg0, [
81
+ ...args,
82
+ "--port",
83
+ String(randomPort),
84
+ "--host",
85
+ "localhost"
86
+ ], {
87
+ stdio: "inherit",
88
+ cwd: opts.rootDir,
89
+ env: {
90
+ ...process.env,
91
+ ...Object.fromEntries(opts.env ?? []),
92
+ PORT: String(randomPort)
52
93
  }
53
- route = route.replace(/\/index$/, "") || "/";
54
- return {
55
- handler: file.fullPath,
56
- lazy: true,
57
- middleware: false,
58
- route,
59
- method,
60
- env
61
- };
62
94
  });
63
- }
64
- async function scanPlugins(nitro) {
65
- return (await scanFiles(nitro, "plugins")).map((f) => f.fullPath);
66
- }
67
- async function scanTasks(nitro) {
68
- return (await scanFiles(nitro, "tasks")).map((f) => {
69
- return {
70
- name: f.path.replace(/\/index$/, "").replace(/\.[A-Za-z]+$/, "").replace(/\//g, ":"),
71
- handler: f.fullPath
72
- };
95
+ const killChild = (signal) => {
96
+ if (child && !child.killed) child.kill(signal);
97
+ };
98
+ for (const sig of ["SIGINT", "SIGHUP"]) process.once(sig, () => {
99
+ killChild(sig);
73
100
  });
74
- }
75
- async function scanModules(nitro) {
76
- return (await scanFiles(nitro, "modules")).map((f) => f.fullPath);
77
- }
78
- async function scanFiles(nitro, name) {
79
- return await Promise.all(nitro.options.scanDirs.map((dir) => scanDir(nitro, dir, name))).then((r) => r.flat());
80
- }
81
- async function scanDir(nitro, dir, name) {
82
- return (await glob(join(name, GLOB_SCAN_PATTERN), {
83
- cwd: dir,
84
- dot: true,
85
- ignore: nitro.options.ignore,
86
- absolute: true
87
- }).catch((error) => {
88
- if (error?.code === "ENOTDIR") {
89
- nitro.logger.warn(`Ignoring \`${join(dir, name)}\`. It must be a directory.`);
90
- return [];
101
+ child.once("exit", (code) => {
102
+ if (code && code !== 0) consola.error(`[nitro] Preview server exited with code ${code}`);
103
+ });
104
+ await waitForPort(randomPort, {
105
+ retries: 20,
106
+ delay: 500,
107
+ host: "localhost"
108
+ });
109
+ return {
110
+ fetch(req) {
111
+ return proxyFetch({
112
+ port: randomPort,
113
+ host: "localhost"
114
+ }, req);
115
+ },
116
+ async upgrade(req, socket, head, opts) {
117
+ await proxyUpgrade({
118
+ port: randomPort,
119
+ host: "localhost"
120
+ }, req, socket, head, opts);
121
+ },
122
+ async close() {
123
+ killChild("SIGTERM");
91
124
  }
92
- throw error;
93
- })).map((fullPath) => {
94
- return {
95
- fullPath,
96
- path: relative(join(dir, name), fullPath)
97
- };
98
- }).sort((a, b) => a.path.localeCompare(b.path));
125
+ };
99
126
  }
100
- export { scanHandlers as n, scanAndSyncOptions as t };
127
+ export { startPreview };
@@ -1,5 +1,5 @@
1
- import { r as __require, t as __commonJSMin } from "../_common.mjs";
2
- import { H as v, M as glob, V as m, at as dirname, dt as resolve, nt as resolveModulePath, p as runParallel, ut as relative } from "../_build/common.mjs";
1
+ import { __commonJSMin, __require } from "../_common.mjs";
2
+ import { dirname, glob, m, relative, resolve, resolveModulePath, runParallel, v } from "../_build/common.mjs";
3
3
  import { consola as consola$1 } from "consola";
4
4
  import { promises } from "node:fs";
5
5
  import { promisify } from "node:util";
@@ -257,9 +257,9 @@ async function importDep(opts, _retry) {
257
257
  if (!shouldInstall) throw new Error(`\`${opts.id}\` is not installed. Please add it to your dependencies for ${opts.reason}.`);
258
258
  const start = Date.now();
259
259
  consola$1.start(`Installing \`${opts.id}\` in \`${opts.dir}\`...`);
260
- const { addDevDependency } = await import("../_libs/_5.mjs");
260
+ const { addDevDependency } = await import("../_libs/nypm+tinyexec.mjs").then((n) => n.dist_exports);
261
261
  await addDevDependency(opts.id, { cwd: opts.dir });
262
262
  consola$1.success(`Installed \`${opts.id}\` in ${opts.dir} (${Date.now() - start}ms).`);
263
263
  return importDep(opts, true);
264
264
  }
265
- export { generateFSTree as n, importDep as t };
265
+ export { generateFSTree, importDep };
package/dist/_common.mjs CHANGED
@@ -5,7 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
9
  var __exportAll = (all, no_symbols) => {
10
10
  let target = {};
11
11
  for (var name in all) __defProp(target, name, {
@@ -30,4 +30,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  enumerable: true
31
31
  }) : target, mod));
32
32
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
33
- export { __toESM as i, __exportAll as n, __require as r, __commonJSMin as t };
33
+ export { __commonJSMin, __exportAll, __require, __toESM };
package/dist/_dev.d.mts CHANGED
@@ -6,4 +6,4 @@ declare class NitroDevApp {
6
6
  fetch: (req: Request) => Response | Promise<Response>;
7
7
  constructor(nitro: Nitro, catchAllHandler?: HTTPHandler);
8
8
  }
9
- export { NitroDevApp as t };
9
+ export { NitroDevApp };
package/dist/_dev.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { A as src_default, H as v, V as m, ct as join$1, dt as resolve$1, g as writeDevBuildInfo, ot as extname$1 } from "./_build/common.mjs";
2
- import { n as watch$1 } from "./_libs/readdirp+chokidar.mjs";
3
- import { t as debounce } from "./_libs/perfect-debounce.mjs";
4
- import { t as createProxyServer } from "./_libs/httpxy.mjs";
1
+ import { extname as extname$1, join as join$1, m, resolve as resolve$1, src_default, v, writeDevBuildInfo } from "./_build/common.mjs";
2
+ import { watch as watch$1 } from "./_libs/readdirp+chokidar.mjs";
3
+ import { debounce } from "./_libs/perfect-debounce.mjs";
4
+ import { createProxyServer } from "./_libs/httpxy.mjs";
5
5
  import consola from "consola";
6
6
  import { createReadStream } from "node:fs";
7
7
  import { readFile, stat as stat$1 } from "node:fs/promises";
@@ -16,7 +16,8 @@ function createVFSHandler(nitro) {
16
16
  return defineHandler(async (event) => {
17
17
  const { socket } = event.runtime?.node?.req || {};
18
18
  const ip = getRequestIP(event, { xForwardedFor: !socket?.remoteAddress && !socket?.localAddress && Object.keys(socket?.address?.() || {}).length === 0 && socket?.readable && socket?.writable && !socket?.remotePort });
19
- if (!(ip && /^::1$|^127\.\d+\.\d+\.\d+$/.test(ip))) throw new HTTPError({
19
+ const v4 = ip?.toLowerCase().startsWith("::ffff:") ? ip.slice(7) : ip;
20
+ if (!(v4 && /^(?:::1|127\.\d+\.\d+\.\d+)$/.test(v4))) throw new HTTPError({
20
21
  statusText: `Forbidden IP: "${ip || "?"}"`,
21
22
  status: 403
22
23
  });
@@ -506,4 +507,4 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
506
507
  });
507
508
  }
508
509
  };
509
- export { createDevServer as n, NitroDevApp as r, NitroDevServer as t };
510
+ export { NitroDevApp, NitroDevServer, createDevServer };
@@ -1,4 +1,5 @@
1
- import { J as readPackageJSON, K as findWorkspaceDir, at as dirname$1, ct as join$1, dt as resolve$1, it as basename$1, lt as normalize$1, nt as resolveModulePath, ot as extname$1 } from "../_build/common.mjs";
1
+ import { __exportAll as __exportAll$1 } from "../_common.mjs";
2
+ import { basename as basename$1, dirname as dirname$1, extname as extname$1, findWorkspaceDir, join as join$1, normalize as normalize$1, readPackageJSON, resolve as resolve$1, resolveModulePath } from "../_build/common.mjs";
2
3
  import { existsSync, readFileSync, statSync } from "node:fs";
3
4
  import * as nodeUtil from "node:util";
4
5
  import { readFile, rm } from "node:fs/promises";
@@ -201,6 +202,13 @@ function readUser(options) {
201
202
  options.dir = process.env.XDG_CONFIG_HOME || homedir();
202
203
  return read(options);
203
204
  }
205
+ var dist_exports$1 = /* @__PURE__ */ __exportAll$1({
206
+ SUPPORTED_EXTENSIONS: () => SUPPORTED_EXTENSIONS,
207
+ loadConfig: () => loadConfig,
208
+ loadDotenv: () => loadDotenv,
209
+ setupDotenv: () => setupDotenv,
210
+ watchConfig: () => watchConfig
211
+ });
204
212
  async function setupDotenv(options) {
205
213
  const targetEnvironment = options.env ?? process.env;
206
214
  const environment = await loadDotenv({
@@ -296,11 +304,11 @@ function getDotEnvVars(targetEnvironment) {
296
304
  const _normalize = (p) => p?.replace(/\\/g, "/");
297
305
  let importCounter = 0;
298
306
  const ASYNC_LOADERS = {
299
- ".yaml": () => import("../_build/common.mjs").then((n) => n.Q).then((r) => r.parseYAML),
300
- ".yml": () => import("../_build/common.mjs").then((n) => n.Q).then((r) => r.parseYAML),
301
- ".jsonc": () => import("../_build/common.mjs").then((n) => n.$).then((r) => r.parseJSONC),
302
- ".json5": () => import("../_build/common.mjs").then((n) => n.tt).then((r) => r.parseJSON5),
303
- ".toml": () => import("../_build/common.mjs").then((n) => n.X).then((r) => r.parseTOML)
307
+ ".yaml": () => import("../_build/common.mjs").then((n) => n.yaml_exports).then((r) => r.parseYAML),
308
+ ".yml": () => import("../_build/common.mjs").then((n) => n.yaml_exports).then((r) => r.parseYAML),
309
+ ".jsonc": () => import("../_build/common.mjs").then((n) => n.jsonc_exports).then((r) => r.parseJSONC),
310
+ ".json5": () => import("../_build/common.mjs").then((n) => n.json5_exports).then((r) => r.parseJSON5),
311
+ ".toml": () => import("../_build/common.mjs").then((n) => n.toml_exports).then((r) => r.parseTOML)
304
312
  };
305
313
  const SUPPORTED_EXTENSIONS = Object.freeze([
306
314
  ".js",
@@ -483,7 +491,7 @@ async function resolveConfig(source, options, sourceOptions = {}) {
483
491
  const { downloadTemplate } = await import("giget").catch((error) => {
484
492
  throw new Error(`Extending config from \`${source}\` requires \`giget\` peer dependency to be installed.\n\nInstall it with: \`npx nypm i giget\``, { cause: error });
485
493
  });
486
- const { digest } = await import("./_4.mjs").then((n) => n.n);
494
+ const { digest } = await Promise.resolve().then(() => ohash_exports).then((n) => n.n);
487
495
  const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
488
496
  let cloneDir;
489
497
  const localNodeModules = resolve$1(options.cwd, "node_modules");
@@ -531,7 +539,8 @@ async function resolveConfig(source, options, sourceOptions = {}) {
531
539
  const jiti = createJiti(join$1(options.cwd || ".", options.configFile || "/"), {
532
540
  interopDefault: true,
533
541
  moduleCache: false,
534
- extensions: [...SUPPORTED_EXTENSIONS]
542
+ extensions: [...SUPPORTED_EXTENSIONS],
543
+ ...options.jitiOptions
535
544
  });
536
545
  options.import = (id) => jiti.import(id);
537
546
  return _resolveModule(await options.import(res.configFile));
@@ -589,8 +598,8 @@ async function watchConfig(options) {
589
598
  options.rcFile && resolve$1(l.cwd, typeof options.rcFile === "string" ? options.rcFile : `.${configName}rc`),
590
599
  options.packageJson && resolve$1(l.cwd, "package.json")
591
600
  ]).filter(Boolean))];
592
- const watch = await import("./readdirp+chokidar.mjs").then((n) => n.t).then((r) => r.watch || r.default || r);
593
- const { diff } = await import("./_4.mjs").then((n) => n.t);
601
+ const watch = await import("./readdirp+chokidar.mjs").then((n) => n.chokidar_exports).then((r) => r.watch || r.default || r);
602
+ const { diff } = await Promise.resolve().then(() => ohash_exports).then((n) => n.t);
594
603
  const _fswatcher = watch(watchingFiles, {
595
604
  ignoreInitial: true,
596
605
  ...options.chokidarOptions
@@ -632,6 +641,10 @@ async function watchConfig(options) {
632
641
  return config[prop];
633
642
  } });
634
643
  }
644
+ var ohash_exports = /* @__PURE__ */ __exportAll$1({
645
+ n: () => dist_exports,
646
+ t: () => utils_exports
647
+ });
635
648
  var __defProp = Object.defineProperty;
636
649
  var __exportAll = (all, no_symbols) => {
637
650
  let target = {};
@@ -811,4 +824,4 @@ var DiffHashedObject = class {
811
824
  return `${k}(${this.value})`;
812
825
  }
813
826
  };
814
- export { loadDotenv as a, loadConfig as i, utils_exports as n, setupDotenv as o, SUPPORTED_EXTENSIONS as r, watchConfig as s, dist_exports as t };
827
+ export { dist_exports$1 as dist_exports, loadConfig, watchConfig };
@@ -1,8 +1,8 @@
1
1
  import { Stats } from "node:fs";
2
2
  import { EventEmitter } from "node:events";
3
3
  import { Readable } from "node:stream";
4
+ import * as _$jiti from "jiti";
4
5
  import { DownloadTemplateOptions } from "giget";
5
- //#region node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/utils/index.d.mts
6
6
  /**
7
7
  * Calculates the difference between two objects and returns a list of differences.
8
8
  *
@@ -29,7 +29,7 @@ declare class DiffHashedObject {
29
29
  constructor(key: string, value: any, hash?: string | undefined, props?: Record<string, DiffHashedObject> | undefined);
30
30
  toString(): string;
31
31
  toJSON(): string;
32
- } //#endregion
32
+ }
33
33
  type AWF = {
34
34
  stabilityThreshold: number;
35
35
  pollInterval: number;
@@ -57,7 +57,6 @@ interface MatcherObject {
57
57
  recursive?: boolean;
58
58
  }
59
59
  type Matcher = string | RegExp | MatchFunction | MatcherObject;
60
- //#region src/dotenv.d.ts
61
60
  interface DotenvOptions {
62
61
  /**
63
62
  * The project root directory (either absolute or relative to the current working directory).
@@ -105,8 +104,8 @@ interface DotenvOptions {
105
104
  }
106
105
  declare global {
107
106
  var __c12_dotenv_vars__: Map<Record<string, any>, Set<string>>;
108
- } //#endregion
109
- //#region src/types.d.ts
107
+ }
108
+ type JitiOptions = NonNullable<Parameters<typeof _$jiti.createJiti>[1]>;
110
109
  interface ConfigLayerMeta {
111
110
  name?: string;
112
111
  [key: string]: any;
@@ -188,6 +187,8 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
188
187
  import?: (id: string) => Promise<unknown>;
189
188
  /** Custom resolver for picking which export to use from the loaded module. Default: `(mod) => mod.default || mod` */
190
189
  resolveModule?: (mod: any) => any;
190
+ /** Options to override defaults when c12 falls back to [jiti](https://github.com/unjs/jiti) for loading config files. */
191
+ jitiOptions?: JitiOptions;
191
192
  giget?: false | DownloadTemplateOptions;
192
193
  merger?: (...sources: Array<T | null | undefined>) => T;
193
194
  extend?: false | {
@@ -195,8 +196,6 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
195
196
  };
196
197
  configFileRequired?: boolean;
197
198
  }
198
- //#endregion
199
- //#region src/watch.d.ts
200
199
  type DiffEntries = ReturnType<typeof diff>;
201
200
  type ConfigWatcher<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> = ResolvedConfig<T, MT> & {
202
201
  watchingFiles: string[];
@@ -220,4 +219,4 @@ interface WatchConfigOptions<T extends UserInputConfig = UserInputConfig, MT ext
220
219
  oldConfig: ResolvedConfig<T, MT>;
221
220
  }) => void | Promise<void>;
222
221
  }
223
- export { WatchConfigOptions as a, ResolvedConfig as i, ConfigWatcher as n, ChokidarOptions as o, DotenvOptions as r, C12InputConfig as t };
222
+ export { C12InputConfig, ChokidarOptions, type ConfigWatcher, type DotenvOptions, ResolvedConfig, type WatchConfigOptions };
@@ -461,4 +461,4 @@ function _getBuiltinFlags(long, short, userNames, userAliases) {
461
461
  if (userNames.has(short) || userAliases.has(short)) return [`--${long}`];
462
462
  return [`--${long}`, `-${short}`];
463
463
  }
464
- export { runMain as n, defineCommand as t };
464
+ export { defineCommand, runMain };
@@ -0,0 +1,37 @@
1
+ interface OutputBundleConfig {
2
+ version: "v1";
3
+ runConfig: RunConfig;
4
+ metadata: Metadata;
5
+ outputFiles?: OutputFiles;
6
+ }
7
+ interface RunConfig {
8
+ runCommand: string;
9
+ environmentVariables?: EnvVarConfig[];
10
+ concurrency?: number;
11
+ cpu?: number;
12
+ memoryMiB?: number;
13
+ minInstances?: number;
14
+ maxInstances?: number;
15
+ }
16
+ interface Metadata {
17
+ adapterPackageName: string;
18
+ adapterVersion: string;
19
+ framework: string;
20
+ frameworkVersion?: string;
21
+ }
22
+ interface OutputFiles {
23
+ serverApp: ServerApp;
24
+ }
25
+ interface ServerApp {
26
+ include: string[];
27
+ }
28
+ interface EnvVarConfig {
29
+ variable: string;
30
+ value: string;
31
+ availability: Availability[];
32
+ }
33
+ declare enum Availability {
34
+ Runtime = "RUNTIME",
35
+ Build = "BUILD"
36
+ }
37
+ export { OutputBundleConfig };
@@ -1,5 +1,5 @@
1
- import { i as __toESM, r as __require, t as __commonJSMin } from "../_common.mjs";
2
- import { P as Builder, S as MagicString, c as walk, i as createFilter, o as extractAssignedNames, r as attachScopes, s as makeLegalIdentifier } from "../_build/common.mjs";
1
+ import { __commonJSMin, __require, __toESM } from "../_common.mjs";
2
+ import { Builder, MagicString, attachScopes, createFilter, extractAssignedNames, makeLegalIdentifier, walk } from "../_build/common.mjs";
3
3
  import { existsSync, readFileSync, statSync } from "fs";
4
4
  import { basename, dirname, extname, join, relative, resolve, sep } from "path";
5
5
  var import_commondir = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -1301,4 +1301,4 @@ function commonjs(options = {}) {
1301
1301
  }
1302
1302
  };
1303
1303
  }
1304
- export { commonjs as t };
1304
+ export { commonjs };
@@ -42,4 +42,4 @@ type CompatibilityDateSpec = DateString | Partial<CompatibilityDates>;
42
42
  /**
43
43
  * Get compatibility updates applicable for the user given platform and date range.
44
44
  */
45
- export { CompatibilityDates as n, DateString as r, CompatibilityDateSpec as t };
45
+ export type { CompatibilityDateSpec, CompatibilityDates, DateString };
@@ -40,4 +40,4 @@ function normalizeDate(date) {
40
40
  if (date === "latest") return /* @__PURE__ */ new Date();
41
41
  return new Date(date);
42
42
  }
43
- export { resolveCompatibilityDates as n, resolveCompatibilityDatesFromEnv as r, formatCompatibilityDate as t };
43
+ export { formatCompatibilityDate, resolveCompatibilityDates, resolveCompatibilityDatesFromEnv };
@@ -233,4 +233,4 @@ interface RollupCommonJSOptions {
233
233
  * Convert CommonJS modules to ES6, so they can be included in a Rollup bundle
234
234
  */
235
235
  declare function commonjs(options?: RollupCommonJSOptions): Plugin;
236
- export { commonjs as t };
236
+ export { commonjs };
@@ -96,4 +96,4 @@ function isNode(value) {
96
96
  function walk(ast, { enter, leave }) {
97
97
  return new SyncWalker(enter, leave).visit(ast, null);
98
98
  }
99
- export { walk as t };
99
+ export { walk };