nitro-nightly 3.0.1-20251106-113615-022389ec → 3.0.1-20251106-132921-80294be0
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.
- package/dist/_build/common.mjs +16 -54
- package/dist/_build/rolldown.mjs +4 -3
- package/dist/_build/rollup.mjs +4 -3
- package/dist/_build/vite.build.mjs +3 -2
- package/dist/_build/vite.plugin.mjs +21 -22
- package/dist/_chunks/B5AdGxPO.mjs +101 -0
- package/dist/_chunks/{Cb5xz0OF.mjs → CsQc45Wt.mjs} +3 -38
- package/dist/_chunks/{DYtA1UcO.mjs → DP4A8L22.mjs} +1 -1
- package/dist/_chunks/{Cj0auL1D.mjs → o9sqmlxd.mjs} +2 -1
- package/dist/_dev.mjs +5 -21
- package/dist/_libs/c12.mjs +1 -1
- package/dist/_libs/httpxy.mjs +1 -1
- package/dist/builder.d.mts +11 -2
- package/dist/builder.mjs +4 -3
- package/dist/cli/_chunks/dev.mjs +2 -0
- package/dist/cli/_chunks/dist3.mjs +2 -3
- package/dist/cli/_chunks/dist4.mjs +4 -0
- package/dist/vite.mjs +3 -2
- package/package.json +1 -1
package/dist/_build/common.mjs
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { i as __toESM } from "../_chunks/Bqks5huO.mjs";
|
|
2
|
-
import { C as join
|
|
2
|
+
import { C as join, D as relative, O as resolve, b as dirname, x as extname } from "../_libs/c12.mjs";
|
|
3
3
|
import { i as unplugin } from "../_libs/unimport.mjs";
|
|
4
4
|
import { t as glob } from "../_libs/tinyglobby.mjs";
|
|
5
|
-
import { u as writeFile$1 } from "../_chunks/Cb5xz0OF.mjs";
|
|
6
5
|
import { t as src_default } from "../_libs/mime.mjs";
|
|
7
6
|
import { i as genSafeVariableName, t as genImport } from "../_libs/knitwork.mjs";
|
|
8
7
|
import { t as replace } from "../_libs/plugin-replace.mjs";
|
|
9
8
|
import { t as rollup } from "../_libs/unwasm.mjs";
|
|
10
9
|
import { t as require_etag } from "../_libs/etag.mjs";
|
|
11
|
-
import { dirname } from "node:path";
|
|
12
10
|
import { camelCase } from "scule";
|
|
13
11
|
import { promises } from "node:fs";
|
|
14
12
|
import { joinURL, withTrailingSlash } from "ufo";
|
|
15
|
-
import {
|
|
13
|
+
import { readFile } from "node:fs/promises";
|
|
16
14
|
import { defu } from "defu";
|
|
17
15
|
import { runtimeDependencies, runtimeDir } from "nitro/runtime/meta";
|
|
18
16
|
import { builtinDrivers, normalizeKey } from "unstorage";
|
|
19
17
|
import { hash } from "ohash";
|
|
20
|
-
import { version } from "nitro/meta";
|
|
21
18
|
import { defineEnv } from "unenv";
|
|
22
19
|
import { connectors } from "db0";
|
|
23
20
|
import { transform } from "esbuild";
|
|
@@ -39,8 +36,8 @@ function replace$1(options) {
|
|
|
39
36
|
//#endregion
|
|
40
37
|
//#region src/build/config.ts
|
|
41
38
|
function baseBuildConfig(nitro) {
|
|
42
|
-
const buildServerDir = join
|
|
43
|
-
const presetsDir$1 = resolve
|
|
39
|
+
const buildServerDir = join(nitro.options.buildDir, "dist/server");
|
|
40
|
+
const presetsDir$1 = resolve(runtimeDir, "../presets");
|
|
44
41
|
const extensions = [
|
|
45
42
|
".ts",
|
|
46
43
|
".mjs",
|
|
@@ -132,7 +129,7 @@ function virtual(modules, cache = {}, opts) {
|
|
|
132
129
|
for (const [id, mod] of Object.entries(modules)) {
|
|
133
130
|
cache[id] = mod;
|
|
134
131
|
_modules.set(id, mod);
|
|
135
|
-
_modules.set(resolve
|
|
132
|
+
_modules.set(resolve(id), mod);
|
|
136
133
|
}
|
|
137
134
|
return {
|
|
138
135
|
name: "virtual",
|
|
@@ -142,7 +139,7 @@ function virtual(modules, cache = {}, opts) {
|
|
|
142
139
|
...opts
|
|
143
140
|
};
|
|
144
141
|
if (importer) {
|
|
145
|
-
const resolved = resolve
|
|
142
|
+
const resolved = resolve(dirname(importer.startsWith(PREFIX) ? importer.slice(9) : importer), id);
|
|
146
143
|
if (_modules.has(resolved)) return PREFIX + resolved;
|
|
147
144
|
}
|
|
148
145
|
return null;
|
|
@@ -304,7 +301,7 @@ function routeMeta(nitro) {
|
|
|
304
301
|
if (!id.startsWith(virtualPrefix)) return;
|
|
305
302
|
let meta = null;
|
|
306
303
|
try {
|
|
307
|
-
const jsCode = await transform(code, { loader: esbuildLoaders[extname
|
|
304
|
+
const jsCode = await transform(code, { loader: esbuildLoaders[extname(id)] }).then((r) => r.code);
|
|
308
305
|
const ast = this.parse(jsCode);
|
|
309
306
|
for (const node of ast.body) if (node.type === "ExpressionStatement" && node.expression.type === "CallExpression" && node.expression.callee.type === "Identifier" && node.expression.callee.name === "defineRouteMeta" && node.expression.arguments.length === 1) {
|
|
310
307
|
meta = astToObject(node.expression.arguments[0]);
|
|
@@ -371,7 +368,7 @@ function publicAssets(nitro) {
|
|
|
371
368
|
for (const id of files) {
|
|
372
369
|
let mimeType = src_default.getType(id.replace(/\.(gz|br)$/, "")) || "text/plain";
|
|
373
370
|
if (mimeType.startsWith("text")) mimeType += "; charset=utf-8";
|
|
374
|
-
const fullPath = resolve
|
|
371
|
+
const fullPath = resolve(nitro.options.output.publicDir, id);
|
|
375
372
|
const assetData = await promises.readFile(fullPath);
|
|
376
373
|
const etag = (0, import_etag$1.default)(assetData);
|
|
377
374
|
const stat$1 = await promises.stat(fullPath);
|
|
@@ -385,7 +382,7 @@ function publicAssets(nitro) {
|
|
|
385
382
|
etag,
|
|
386
383
|
mtime: stat$1.mtime.toJSON(),
|
|
387
384
|
size: stat$1.size,
|
|
388
|
-
path: relative
|
|
385
|
+
path: relative(nitro.options.output.serverDir, fullPath),
|
|
389
386
|
data: nitro.options.serveStatic === "inline" ? assetData.toString("base64") : void 0
|
|
390
387
|
};
|
|
391
388
|
}
|
|
@@ -474,7 +471,7 @@ function serverAssets(nitro) {
|
|
|
474
471
|
ignore: asset.ignore
|
|
475
472
|
});
|
|
476
473
|
for (const _id of files) {
|
|
477
|
-
const fsPath = resolve
|
|
474
|
+
const fsPath = resolve(asset.dir, _id);
|
|
478
475
|
const id = asset.baseName + "/" + _id;
|
|
479
476
|
assets[id] = {
|
|
480
477
|
fsPath,
|
|
@@ -542,10 +539,10 @@ function storage(nitro) {
|
|
|
542
539
|
...nitro.options.storage,
|
|
543
540
|
...nitro.options.devStorage
|
|
544
541
|
} : nitro.options.storage;
|
|
545
|
-
for (const path
|
|
546
|
-
const mount = storageMounts[path
|
|
542
|
+
for (const path in storageMounts) {
|
|
543
|
+
const mount = storageMounts[path];
|
|
547
544
|
mounts.push({
|
|
548
|
-
path
|
|
545
|
+
path,
|
|
549
546
|
driver: builtinDrivers[mount.driver] || mount.driver,
|
|
550
547
|
opts: mount
|
|
551
548
|
});
|
|
@@ -589,7 +586,7 @@ export function initStorage() {
|
|
|
589
586
|
function errorHandler(nitro) {
|
|
590
587
|
return virtual({ "#nitro-internal-virtual/error-handler": () => {
|
|
591
588
|
const errorHandlers = Array.isArray(nitro.options.errorHandler) ? nitro.options.errorHandler : [nitro.options.errorHandler];
|
|
592
|
-
const builtinHandler = join
|
|
589
|
+
const builtinHandler = join(runtimeDir, `internal/error/${nitro.options.dev ? "dev" : "prod"}`);
|
|
593
590
|
return `
|
|
594
591
|
${errorHandlers.map((h, i) => `import errorHandler$${i} from "${h}";`).join("\n")}
|
|
595
592
|
|
|
@@ -713,7 +710,7 @@ function baseBuildPlugins(nitro, base) {
|
|
|
713
710
|
"@@/",
|
|
714
711
|
"virtual:",
|
|
715
712
|
"nitro/runtime",
|
|
716
|
-
dirname
|
|
713
|
+
dirname(nitro.options.entry),
|
|
717
714
|
...nitro.options.experimental.wasm ? [(id) => id?.endsWith(".wasm")] : [],
|
|
718
715
|
runtimeDir,
|
|
719
716
|
nitro.options.serverDir,
|
|
@@ -736,39 +733,4 @@ function baseBuildPlugins(nitro, base) {
|
|
|
736
733
|
}
|
|
737
734
|
|
|
738
735
|
//#endregion
|
|
739
|
-
|
|
740
|
-
const presetsWithConfig = [
|
|
741
|
-
"awsAmplify",
|
|
742
|
-
"awsLambda",
|
|
743
|
-
"azure",
|
|
744
|
-
"cloudflare",
|
|
745
|
-
"firebase",
|
|
746
|
-
"netlify",
|
|
747
|
-
"vercel"
|
|
748
|
-
];
|
|
749
|
-
|
|
750
|
-
//#endregion
|
|
751
|
-
//#region src/build/info.ts
|
|
752
|
-
async function writeBuildInfo(nitro) {
|
|
753
|
-
const buildInfoPath = resolve$1(nitro.options.output.dir, "nitro.json");
|
|
754
|
-
const buildInfo = {
|
|
755
|
-
date: (/* @__PURE__ */ new Date()).toJSON(),
|
|
756
|
-
preset: nitro.options.preset,
|
|
757
|
-
framework: nitro.options.framework,
|
|
758
|
-
versions: { nitro: version },
|
|
759
|
-
commands: {
|
|
760
|
-
preview: nitro.options.commands.preview,
|
|
761
|
-
deploy: nitro.options.commands.deploy
|
|
762
|
-
},
|
|
763
|
-
config: { ...Object.fromEntries(presetsWithConfig.map((key) => [key, nitro.options[key]])) }
|
|
764
|
-
};
|
|
765
|
-
await writeFile$1(buildInfoPath, JSON.stringify(buildInfo, null, 2), true);
|
|
766
|
-
const lastBuild = resolve$1(nitro.options.rootDir, "node_modules/.nitro/last-build");
|
|
767
|
-
await mkdir(dirname(lastBuild), { recursive: true });
|
|
768
|
-
await unlink(lastBuild).catch(() => {});
|
|
769
|
-
await symlink(nitro.options.output.dir, lastBuild).catch(() => symlink(nitro.options.output.dir, lastBuild)).catch(() => {});
|
|
770
|
-
return buildInfo;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
//#endregion
|
|
774
|
-
export { replace$1 as i, baseBuildPlugins as n, baseBuildConfig as r, writeBuildInfo as t };
|
|
736
|
+
export { baseBuildConfig as n, replace$1 as r, baseBuildPlugins as t };
|
package/dist/_build/rolldown.mjs
CHANGED
|
@@ -14,7 +14,8 @@ import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
|
14
14
|
import "../_libs/klona.mjs";
|
|
15
15
|
import "../_libs/std-env.mjs";
|
|
16
16
|
import "../_libs/dot-prop.mjs";
|
|
17
|
-
import { n as
|
|
17
|
+
import { n as writeBuildInfo } from "../_chunks/B5AdGxPO.mjs";
|
|
18
|
+
import { n as writeTypes, o as scanHandlers } from "../_chunks/CsQc45Wt.mjs";
|
|
18
19
|
import "../_libs/mime.mjs";
|
|
19
20
|
import "../_libs/pathe.mjs";
|
|
20
21
|
import "../_libs/untyped.mjs";
|
|
@@ -23,11 +24,11 @@ import { i as watch$1 } from "../_libs/chokidar.mjs";
|
|
|
23
24
|
import "../_libs/estree-walker.mjs";
|
|
24
25
|
import "../_libs/plugin-commonjs.mjs";
|
|
25
26
|
import "../_libs/plugin-replace.mjs";
|
|
26
|
-
import {
|
|
27
|
+
import { n as baseBuildConfig, r as replace, t as baseBuildPlugins } from "./common.mjs";
|
|
27
28
|
import "../_libs/remapping.mjs";
|
|
28
29
|
import "../_libs/unwasm.mjs";
|
|
29
30
|
import "../_libs/etag.mjs";
|
|
30
|
-
import { i as raw, n as generateFSTree, r as nitroServerName, t as snapshot } from "../_chunks/
|
|
31
|
+
import { i as raw, n as generateFSTree, r as nitroServerName, t as snapshot } from "../_chunks/DP4A8L22.mjs";
|
|
31
32
|
import "../_libs/duplexer.mjs";
|
|
32
33
|
import "../_libs/gzip-size.mjs";
|
|
33
34
|
import "../_libs/pretty-bytes.mjs";
|
package/dist/_build/rollup.mjs
CHANGED
|
@@ -14,7 +14,8 @@ import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
|
14
14
|
import "../_libs/klona.mjs";
|
|
15
15
|
import "../_libs/std-env.mjs";
|
|
16
16
|
import "../_libs/dot-prop.mjs";
|
|
17
|
-
import { n as
|
|
17
|
+
import { n as writeBuildInfo } from "../_chunks/B5AdGxPO.mjs";
|
|
18
|
+
import { n as writeTypes, o as scanHandlers } from "../_chunks/CsQc45Wt.mjs";
|
|
18
19
|
import "../_libs/mime.mjs";
|
|
19
20
|
import "../_libs/pathe.mjs";
|
|
20
21
|
import "../_libs/untyped.mjs";
|
|
@@ -25,11 +26,11 @@ import "../_libs/estree-walker.mjs";
|
|
|
25
26
|
import { t as commonjs } from "../_libs/plugin-commonjs.mjs";
|
|
26
27
|
import { t as inject } from "../_libs/plugin-inject.mjs";
|
|
27
28
|
import "../_libs/plugin-replace.mjs";
|
|
28
|
-
import {
|
|
29
|
+
import { n as baseBuildConfig, r as replace, t as baseBuildPlugins } from "./common.mjs";
|
|
29
30
|
import "../_libs/remapping.mjs";
|
|
30
31
|
import "../_libs/unwasm.mjs";
|
|
31
32
|
import "../_libs/etag.mjs";
|
|
32
|
-
import { i as raw, n as generateFSTree, r as nitroServerName, t as snapshot } from "../_chunks/
|
|
33
|
+
import { i as raw, n as generateFSTree, r as nitroServerName, t as snapshot } from "../_chunks/DP4A8L22.mjs";
|
|
33
34
|
import "../_libs/duplexer.mjs";
|
|
34
35
|
import "../_libs/gzip-size.mjs";
|
|
35
36
|
import "../_libs/pretty-bytes.mjs";
|
|
@@ -13,10 +13,11 @@ import "../_libs/tinyglobby.mjs";
|
|
|
13
13
|
import "../_libs/compatx.mjs";
|
|
14
14
|
import "../_libs/klona.mjs";
|
|
15
15
|
import { n as a } from "../_libs/std-env.mjs";
|
|
16
|
-
import "../_chunks/
|
|
16
|
+
import "../_chunks/o9sqmlxd.mjs";
|
|
17
17
|
import "../_libs/escape-string-regexp.mjs";
|
|
18
18
|
import "../_libs/dot-prop.mjs";
|
|
19
|
-
import "../_chunks/
|
|
19
|
+
import "../_chunks/B5AdGxPO.mjs";
|
|
20
|
+
import "../_chunks/CsQc45Wt.mjs";
|
|
20
21
|
import "../_libs/rou3.mjs";
|
|
21
22
|
import "../_libs/mime.mjs";
|
|
22
23
|
import "../_libs/pathe.mjs";
|
|
@@ -2,25 +2,24 @@ import { C as join$1, D as relative$1, O as resolve$1, S as isAbsolute$1, b as d
|
|
|
2
2
|
import { f as sanitizeFilePath } from "../_libs/local-pkg.mjs";
|
|
3
3
|
import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
4
4
|
import { n as a, t as T } from "../_libs/std-env.mjs";
|
|
5
|
-
import { a as createNitro, n as prepare, r as copyPublicAssets } from "../_chunks/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { a as createNitro, n as prepare, r as copyPublicAssets } from "../_chunks/o9sqmlxd.mjs";
|
|
6
|
+
import { a as prettyPath, n as writeBuildInfo, t as getBuildInfo } from "../_chunks/B5AdGxPO.mjs";
|
|
7
|
+
import { o as scanHandlers } from "../_chunks/CsQc45Wt.mjs";
|
|
8
8
|
import { i as NodeDevWorker, r as NitroDevApp } from "../_dev.mjs";
|
|
9
9
|
import { i as watch$1 } from "../_libs/chokidar.mjs";
|
|
10
10
|
import { t as alias } from "../_libs/plugin-alias.mjs";
|
|
11
11
|
import { t as inject } from "../_libs/plugin-inject.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { n as baseBuildConfig, r as replace, t as baseBuildPlugins } from "./common.mjs";
|
|
13
13
|
import { t as assetsPlugin } from "../_libs/vite-plugin-fullstack.mjs";
|
|
14
14
|
import consola$1 from "consola";
|
|
15
15
|
import { join, resolve } from "node:path";
|
|
16
16
|
import { existsSync, watch } from "node:fs";
|
|
17
|
-
import { mkdir, readFile,
|
|
17
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
18
18
|
import { defu } from "defu";
|
|
19
19
|
import { runtimeDependencies, runtimeDir } from "nitro/runtime/meta";
|
|
20
20
|
import { colors } from "consola/utils";
|
|
21
21
|
import { NodeRequest, sendNodeResponse } from "srvx/node";
|
|
22
22
|
import { DevEnvironment } from "vite";
|
|
23
|
-
import { getRandomPort } from "get-port-please";
|
|
24
23
|
import { spawn } from "node:child_process";
|
|
25
24
|
|
|
26
25
|
//#region src/build/vite/rollup.ts
|
|
@@ -439,15 +438,10 @@ function nitroPreviewPlugin(ctx) {
|
|
|
439
438
|
return { preview: { port: config.preview?.port || 3e3 } };
|
|
440
439
|
},
|
|
441
440
|
async configurePreviewServer(server) {
|
|
442
|
-
const
|
|
443
|
-
if (!
|
|
444
|
-
console.warn(`No nitro build found. Please build your project before previewing.`);
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
const realBuildDir = await readlink("node_modules/.nitro/last-build");
|
|
448
|
-
const buildInfo = JSON.parse(await readFile(buildInfoPath, "utf8"));
|
|
441
|
+
const { outputDir, buildInfo } = await getBuildInfo(server.config.root);
|
|
442
|
+
if (!buildInfo) throw this.error("Cannot load nitro build info. Make sure to build first.");
|
|
449
443
|
const info = [
|
|
450
|
-
["Build Directory:", prettyPath(
|
|
444
|
+
["Build Directory:", prettyPath(outputDir)],
|
|
451
445
|
["Date:", buildInfo.date && new Date(buildInfo.date).toLocaleString()],
|
|
452
446
|
["Nitro Version:", buildInfo.versions.nitro],
|
|
453
447
|
["Nitro Preset:", buildInfo.preset],
|
|
@@ -470,27 +464,32 @@ function nitroPreviewPlugin(ctx) {
|
|
|
470
464
|
...dotEnvEntries.map(([key, val]) => ` - ${key}`)
|
|
471
465
|
].join("\n")
|
|
472
466
|
});
|
|
473
|
-
const randomPort = await getRandomPort();
|
|
474
|
-
consola$1.info(`Spawning preview server...`);
|
|
475
467
|
const [command, ...args] = buildInfo.commands.preview.split(" ");
|
|
476
|
-
|
|
468
|
+
consola$1.info(`Spawning preview server...`);
|
|
477
469
|
consola$1.info(buildInfo.commands?.preview);
|
|
478
|
-
|
|
470
|
+
console.log("");
|
|
471
|
+
const { getRandomPort } = await import("get-port-please");
|
|
472
|
+
const randomPort = await getRandomPort();
|
|
473
|
+
const child = spawn(command, args, {
|
|
479
474
|
stdio: "inherit",
|
|
480
|
-
cwd:
|
|
475
|
+
cwd: outputDir,
|
|
481
476
|
env: {
|
|
482
477
|
...process.env,
|
|
483
478
|
...Object.fromEntries(dotEnvEntries),
|
|
484
479
|
PORT: String(randomPort)
|
|
485
480
|
}
|
|
486
481
|
});
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
child
|
|
482
|
+
for (const sig of ["SIGINT", "SIGHUP"]) process.once(sig, () => {
|
|
483
|
+
consola$1.info(`Stopping preview server...`);
|
|
484
|
+
if (child.killed === false) {
|
|
485
|
+
child.kill(sig);
|
|
486
|
+
process.exit();
|
|
487
|
+
}
|
|
490
488
|
});
|
|
491
489
|
child.on("exit", (code) => {
|
|
492
490
|
if (code && code !== 0) consola$1.error(`[nitro] Preview server exited with code ${code}`);
|
|
493
491
|
});
|
|
492
|
+
const { createProxyServer } = await import("../cli/_chunks/dist3.mjs");
|
|
494
493
|
const proxy = createProxyServer({ target: `http://localhost:${randomPort}` });
|
|
495
494
|
server.middlewares.use((req, res, next) => {
|
|
496
495
|
if (child && !child.killed) proxy.web(req, res).catch(next);
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { D as relative$1, O as resolve$1, b as dirname$1 } from "../_libs/c12.mjs";
|
|
2
|
+
import { t as getProperty } from "../_libs/dot-prop.mjs";
|
|
3
|
+
import consola$1 from "consola";
|
|
4
|
+
import { dirname } from "node:path";
|
|
5
|
+
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
6
|
+
import { colors } from "consola/utils";
|
|
7
|
+
import { version } from "nitro/meta";
|
|
8
|
+
|
|
9
|
+
//#region src/utils/fs.ts
|
|
10
|
+
function prettyPath(p, highlight = true) {
|
|
11
|
+
p = relative$1(process.cwd(), p);
|
|
12
|
+
return highlight ? colors.cyan(p) : p;
|
|
13
|
+
}
|
|
14
|
+
function resolveNitroPath(path$1, nitroOptions, base) {
|
|
15
|
+
if (typeof path$1 !== "string") throw new TypeError("Invalid path: " + path$1);
|
|
16
|
+
path$1 = _compilePathTemplate(path$1)(nitroOptions);
|
|
17
|
+
for (const base$1 in nitroOptions.alias) if (path$1.startsWith(base$1)) path$1 = nitroOptions.alias[base$1] + path$1.slice(base$1.length);
|
|
18
|
+
return resolve$1(base || nitroOptions.rootDir, path$1);
|
|
19
|
+
}
|
|
20
|
+
function _compilePathTemplate(contents) {
|
|
21
|
+
return (params) => contents.replace(/{{ ?([\w.]+) ?}}/g, (_, match) => {
|
|
22
|
+
const val = getProperty(params, match);
|
|
23
|
+
if (!val) consola$1.warn(`cannot resolve template param '${match}' in ${contents.slice(0, 20)}`);
|
|
24
|
+
return val || `${match}`;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async function writeFile$1(file, contents, log = false) {
|
|
28
|
+
await mkdir(dirname$1(file), { recursive: true });
|
|
29
|
+
await writeFile(file, contents, typeof contents === "string" ? "utf8" : void 0);
|
|
30
|
+
if (log) consola$1.info("Generated", prettyPath(file));
|
|
31
|
+
}
|
|
32
|
+
async function isDirectory(path$1) {
|
|
33
|
+
try {
|
|
34
|
+
return (await stat(path$1)).isDirectory();
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/presets/_types.gen.ts
|
|
42
|
+
const presetsWithConfig = [
|
|
43
|
+
"awsAmplify",
|
|
44
|
+
"awsLambda",
|
|
45
|
+
"azure",
|
|
46
|
+
"cloudflare",
|
|
47
|
+
"firebase",
|
|
48
|
+
"netlify",
|
|
49
|
+
"vercel"
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/build/info.ts
|
|
54
|
+
async function getBuildInfo(root) {
|
|
55
|
+
const outputDir = await findLastBuildDir(root);
|
|
56
|
+
if (!await stat(outputDir).then((s) => s.isDirectory()).catch(() => false)) return {};
|
|
57
|
+
return {
|
|
58
|
+
outputDir,
|
|
59
|
+
buildInfo: await readFile(resolve$1(outputDir, "nitro.json"), "utf8").then(JSON.parse).catch(() => void 0)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async function findLastBuildDir(root) {
|
|
63
|
+
const lastBuildLink = resolve$1(root, "node_modules/.nitro/last-build.json");
|
|
64
|
+
return await readFile(lastBuildLink, "utf8").then(JSON.parse).then((data) => resolve$1(lastBuildLink, data.outputDir || "../../../.output")).catch(() => resolve$1(root, ".output"));
|
|
65
|
+
}
|
|
66
|
+
async function writeBuildInfo(nitro) {
|
|
67
|
+
const buildInfoPath = resolve$1(nitro.options.output.dir, "nitro.json");
|
|
68
|
+
const buildInfo = {
|
|
69
|
+
date: (/* @__PURE__ */ new Date()).toJSON(),
|
|
70
|
+
preset: nitro.options.preset,
|
|
71
|
+
framework: nitro.options.framework,
|
|
72
|
+
versions: { nitro: version },
|
|
73
|
+
commands: {
|
|
74
|
+
preview: nitro.options.commands.preview,
|
|
75
|
+
deploy: nitro.options.commands.deploy
|
|
76
|
+
},
|
|
77
|
+
config: { ...Object.fromEntries(presetsWithConfig.map((key) => [key, nitro.options[key]])) }
|
|
78
|
+
};
|
|
79
|
+
await writeFile$1(buildInfoPath, JSON.stringify(buildInfo, null, 2), true);
|
|
80
|
+
const lastBuild = resolve$1(nitro.options.rootDir, "node_modules/.nitro/last-build.json");
|
|
81
|
+
await mkdir(dirname(lastBuild), { recursive: true });
|
|
82
|
+
await writeFile$1(lastBuild, JSON.stringify({ outputDir: relative$1(lastBuild, nitro.options.output.dir) }));
|
|
83
|
+
return buildInfo;
|
|
84
|
+
}
|
|
85
|
+
async function writeDevBuildInfo(nitro, addr) {
|
|
86
|
+
const buildInfoPath = resolve$1(nitro.options.buildDir, "nitro.json");
|
|
87
|
+
const buildInfo = {
|
|
88
|
+
date: (/* @__PURE__ */ new Date()).toJSON(),
|
|
89
|
+
preset: nitro.options.preset,
|
|
90
|
+
framework: nitro.options.framework,
|
|
91
|
+
versions: { nitro: version },
|
|
92
|
+
dev: {
|
|
93
|
+
pid: process.pid,
|
|
94
|
+
workerAddress: addr
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
await writeFile$1(buildInfoPath, JSON.stringify(buildInfo, null, 2));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
export { prettyPath as a, isDirectory as i, writeBuildInfo as n, resolveNitroPath as o, writeDevBuildInfo as r, writeFile$1 as s, getBuildInfo as t };
|
|
@@ -4,50 +4,15 @@ import { c as parseNodeModulePath, s as lookupNodeModuleSubpath } from "../_libs
|
|
|
4
4
|
import { s as toExports } from "../_libs/unimport.mjs";
|
|
5
5
|
import { t as glob } from "../_libs/tinyglobby.mjs";
|
|
6
6
|
import { t as klona } from "../_libs/klona.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { i as isDirectory, o as resolveNitroPath, s as writeFile } from "./B5AdGxPO.mjs";
|
|
8
8
|
import { t as resolveAlias } from "../_libs/pathe.mjs";
|
|
9
9
|
import { n as resolveSchema, t as generateTypes } from "../_libs/untyped.mjs";
|
|
10
|
-
import consola$1 from "consola";
|
|
11
10
|
import { existsSync, promises } from "node:fs";
|
|
12
11
|
import { withBase, withLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
13
|
-
import { mkdir, stat, writeFile } from "node:fs/promises";
|
|
14
12
|
import { defu } from "defu";
|
|
15
13
|
import { runtimeDir } from "nitro/runtime/meta";
|
|
16
|
-
import { colors } from "consola/utils";
|
|
17
14
|
import { builtinDrivers, createStorage } from "unstorage";
|
|
18
15
|
|
|
19
|
-
//#region src/utils/fs.ts
|
|
20
|
-
function prettyPath(p, highlight = true) {
|
|
21
|
-
p = relative(process.cwd(), p);
|
|
22
|
-
return highlight ? colors.cyan(p) : p;
|
|
23
|
-
}
|
|
24
|
-
function resolveNitroPath(path, nitroOptions, base) {
|
|
25
|
-
if (typeof path !== "string") throw new TypeError("Invalid path: " + path);
|
|
26
|
-
path = _compilePathTemplate(path)(nitroOptions);
|
|
27
|
-
for (const base$1 in nitroOptions.alias) if (path.startsWith(base$1)) path = nitroOptions.alias[base$1] + path.slice(base$1.length);
|
|
28
|
-
return resolve(base || nitroOptions.rootDir, path);
|
|
29
|
-
}
|
|
30
|
-
function _compilePathTemplate(contents) {
|
|
31
|
-
return (params) => contents.replace(/{{ ?([\w.]+) ?}}/g, (_, match) => {
|
|
32
|
-
const val = getProperty(params, match);
|
|
33
|
-
if (!val) consola$1.warn(`cannot resolve template param '${match}' in ${contents.slice(0, 20)}`);
|
|
34
|
-
return val || `${match}`;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
async function writeFile$1(file, contents, log = false) {
|
|
38
|
-
await mkdir(dirname(file), { recursive: true });
|
|
39
|
-
await writeFile(file, contents, typeof contents === "string" ? "utf8" : void 0);
|
|
40
|
-
if (log) consola$1.info("Generated", prettyPath(file));
|
|
41
|
-
}
|
|
42
|
-
async function isDirectory(path) {
|
|
43
|
-
try {
|
|
44
|
-
return (await stat(path)).isDirectory();
|
|
45
|
-
} catch {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
16
|
//#region src/scan.ts
|
|
52
17
|
const GLOB_SCAN_PATTERN = "**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}";
|
|
53
18
|
const suffixRegex = /(\.(?<method>connect|delete|get|head|options|patch|post|put|trace))?(\.(?<env>dev|prod|prerender))?$/;
|
|
@@ -335,7 +300,7 @@ async function writeTypes(nitro) {
|
|
|
335
300
|
}
|
|
336
301
|
await nitro.hooks.callHook("types:extend", types);
|
|
337
302
|
await Promise.all(buildFiles.map(async (file) => {
|
|
338
|
-
await writeFile
|
|
303
|
+
await writeFile(resolve(nitro.options.buildDir, file.path), typeof file.contents === "string" ? file.contents : file.contents());
|
|
339
304
|
}));
|
|
340
305
|
}
|
|
341
306
|
const RELATIVE_RE = /^\.{1,2}\//;
|
|
@@ -369,4 +334,4 @@ async function runParallel(inputs, cb, opts) {
|
|
|
369
334
|
}
|
|
370
335
|
|
|
371
336
|
//#endregion
|
|
372
|
-
export { scanAndSyncOptions as a,
|
|
337
|
+
export { scanAndSyncOptions as a, snapshotStorage as i, writeTypes as n, scanHandlers as o, createStorage$1 as r, runParallel as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as join, D as relative, O as resolve, b as dirname, x as extname } from "../_libs/c12.mjs";
|
|
2
2
|
import { t as glob } from "../_libs/tinyglobby.mjs";
|
|
3
3
|
import { n as a } from "../_libs/std-env.mjs";
|
|
4
|
-
import { i as snapshotStorage, t as runParallel } from "./
|
|
4
|
+
import { i as snapshotStorage, t as runParallel } from "./CsQc45Wt.mjs";
|
|
5
5
|
import { t as src_default } from "../_libs/mime.mjs";
|
|
6
6
|
import { t as gzipSize } from "../_libs/gzip-size.mjs";
|
|
7
7
|
import { t as prettyBytes } from "../_libs/pretty-bytes.mjs";
|
|
@@ -7,7 +7,8 @@ import { n as resolveCompatibilityDates, r as resolveCompatibilityDatesFromEnv }
|
|
|
7
7
|
import { n as klona } from "../_libs/klona.mjs";
|
|
8
8
|
import { n as a, r as d } from "../_libs/std-env.mjs";
|
|
9
9
|
import { t as escapeStringRegexp } from "../_libs/escape-string-regexp.mjs";
|
|
10
|
-
import { a as
|
|
10
|
+
import { a as prettyPath, i as isDirectory, o as resolveNitroPath, s as writeFile$1 } from "./B5AdGxPO.mjs";
|
|
11
|
+
import { a as scanAndSyncOptions, o as scanHandlers, r as createStorage, t as runParallel } from "./CsQc45Wt.mjs";
|
|
11
12
|
import { a as findRoute, i as findAllRoutes, n as addRoute, r as createRouter, t as compileRouterToString } from "../_libs/rou3.mjs";
|
|
12
13
|
import { t as src_default } from "../_libs/mime.mjs";
|
|
13
14
|
import { n as z, t as P } from "../_libs/ultrahtml.mjs";
|
package/dist/_dev.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { C as join$1, O as resolve$1, n as debounce, x as extname$1 } from "./_libs/c12.mjs";
|
|
2
2
|
import { n as a, t as T } from "./_libs/std-env.mjs";
|
|
3
|
+
import { r as writeDevBuildInfo } from "./_chunks/B5AdGxPO.mjs";
|
|
3
4
|
import { t as src_default } from "./_libs/mime.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { n as createProxyServer } from "./_libs/httpxy.mjs";
|
|
5
6
|
import { i as watch$1 } from "./_libs/chokidar.mjs";
|
|
6
7
|
import consola$1 from "consola";
|
|
7
8
|
import { dirname, resolve } from "node:path";
|
|
8
9
|
import { createReadStream, existsSync } from "node:fs";
|
|
9
10
|
import { joinURL } from "ufo";
|
|
10
|
-
import { readFile, rm, stat
|
|
11
|
+
import { readFile, rm, stat } from "node:fs/promises";
|
|
11
12
|
import { createBrotliCompress, createGzip } from "node:zlib";
|
|
12
13
|
import { Worker } from "node:worker_threads";
|
|
13
14
|
import { H3, HTTPError, defineHandler, fromNodeHandler, getRequestIP, getRequestURL, serveStatic, toEventHandler } from "h3";
|
|
14
15
|
import { Agent } from "undici";
|
|
15
|
-
import { version } from "nitro/meta";
|
|
16
16
|
import { serve } from "srvx/node";
|
|
17
17
|
import { ErrorParser } from "youch-core";
|
|
18
18
|
import { Youch } from "youch";
|
|
@@ -638,8 +638,8 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
638
638
|
const index = this.#workers.indexOf(worker$1);
|
|
639
639
|
if (index !== -1) this.#workers.splice(index, 1);
|
|
640
640
|
},
|
|
641
|
-
onReady: (
|
|
642
|
-
this
|
|
641
|
+
onReady: async (_worker, addr) => {
|
|
642
|
+
writeDevBuildInfo(this.nitro, addr).catch(() => {});
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
645
|
});
|
|
@@ -659,22 +659,6 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
659
659
|
this.#messageListeners.delete(listener);
|
|
660
660
|
for (const worker of this.#workers) worker.offMessage(listener);
|
|
661
661
|
}
|
|
662
|
-
#writeBuildInfo(_worker, addr) {
|
|
663
|
-
const buildInfoPath = resolve$1(this.nitro.options.buildDir, "nitro.json");
|
|
664
|
-
const buildInfo = {
|
|
665
|
-
date: (/* @__PURE__ */ new Date()).toJSON(),
|
|
666
|
-
preset: this.nitro.options.preset,
|
|
667
|
-
framework: this.nitro.options.framework,
|
|
668
|
-
versions: { nitro: version },
|
|
669
|
-
dev: {
|
|
670
|
-
pid: process.pid,
|
|
671
|
-
workerAddress: addr
|
|
672
|
-
}
|
|
673
|
-
};
|
|
674
|
-
writeFile(buildInfoPath, JSON.stringify(buildInfo, null, 2)).catch((error) => {
|
|
675
|
-
consola$1.error(error);
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
662
|
async #getWorker() {
|
|
679
663
|
let retry = 0;
|
|
680
664
|
const maxRetries = a || T ? 100 : 10;
|
package/dist/_libs/c12.mjs
CHANGED
|
@@ -2576,7 +2576,7 @@ async function resolveConfig(source, options, sourceOptions = {}) {
|
|
|
2576
2576
|
const customProviderKeys = Object.keys(sourceOptions.giget?.providers || {}).map((key) => `${key}:`);
|
|
2577
2577
|
const gigetPrefixes = customProviderKeys.length > 0 ? [.../* @__PURE__ */ new Set([...customProviderKeys, ...GIGET_PREFIXES])] : GIGET_PREFIXES;
|
|
2578
2578
|
if (options.giget !== false && gigetPrefixes.some((prefix) => source.startsWith(prefix))) {
|
|
2579
|
-
const { downloadTemplate } = await import("../cli/_chunks/
|
|
2579
|
+
const { downloadTemplate } = await import("../cli/_chunks/dist4.mjs");
|
|
2580
2580
|
const { digest } = await import("ohash");
|
|
2581
2581
|
const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
|
|
2582
2582
|
let cloneDir;
|
package/dist/_libs/httpxy.mjs
CHANGED
package/dist/builder.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { t as NitroDevApp } from "./_dev.mjs";
|
|
|
2
2
|
import { IncomingMessage, OutgoingMessage } from "node:http";
|
|
3
3
|
import { Duplex } from "node:stream";
|
|
4
4
|
import { Server, ServerOptions } from "srvx";
|
|
5
|
-
import { DevMessageListener, DevRPCHooks, LoadConfigOptions, Nitro, NitroConfig, NitroOptions, TaskEvent, TaskRunnerOptions } from "nitro/types";
|
|
5
|
+
import { DevMessageListener, DevRPCHooks, LoadConfigOptions, Nitro, NitroBuildInfo, NitroConfig, NitroOptions, TaskEvent, TaskRunnerOptions } from "nitro/types";
|
|
6
6
|
|
|
7
7
|
//#region src/nitro.d.ts
|
|
8
8
|
declare function createNitro(config?: NitroConfig, opts?: LoadConfigOptions): Promise<Nitro>;
|
|
@@ -22,6 +22,15 @@ declare function prepare(nitro: Nitro): Promise<void>;
|
|
|
22
22
|
//#region src/build/types.d.ts
|
|
23
23
|
declare function writeTypes(nitro: Nitro): Promise<void>;
|
|
24
24
|
//#endregion
|
|
25
|
+
//#region src/build/info.d.ts
|
|
26
|
+
declare function getBuildInfo(root: string): Promise<{
|
|
27
|
+
outputDir?: undefined;
|
|
28
|
+
buildInfo?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
outputDir: string;
|
|
31
|
+
buildInfo?: NitroBuildInfo;
|
|
32
|
+
}>;
|
|
33
|
+
//#endregion
|
|
25
34
|
//#region src/dev/server.d.ts
|
|
26
35
|
declare function createDevServer(nitro: Nitro): NitroDevServer;
|
|
27
36
|
declare class NitroDevServer extends NitroDevApp implements DevRPCHooks {
|
|
@@ -51,4 +60,4 @@ declare function listTasks(opts?: TaskRunnerOptions): Promise<Record<string, {
|
|
|
51
60
|
};
|
|
52
61
|
}>>;
|
|
53
62
|
//#endregion
|
|
54
|
-
export { build, copyPublicAssets, createDevServer, createNitro, listTasks, loadOptions, prepare, prerender, runTask, writeTypes };
|
|
63
|
+
export { build, copyPublicAssets, createDevServer, createNitro, getBuildInfo, listTasks, loadOptions, prepare, prerender, runTask, writeTypes };
|
package/dist/builder.mjs
CHANGED
|
@@ -13,10 +13,11 @@ import "./_libs/tinyglobby.mjs";
|
|
|
13
13
|
import "./_libs/compatx.mjs";
|
|
14
14
|
import "./_libs/klona.mjs";
|
|
15
15
|
import "./_libs/std-env.mjs";
|
|
16
|
-
import { a as createNitro, c as loadOptions, i as build, n as prepare, o as listTasks, r as copyPublicAssets, s as runTask, t as prerender } from "./_chunks/
|
|
16
|
+
import { a as createNitro, c as loadOptions, i as build, n as prepare, o as listTasks, r as copyPublicAssets, s as runTask, t as prerender } from "./_chunks/o9sqmlxd.mjs";
|
|
17
17
|
import "./_libs/escape-string-regexp.mjs";
|
|
18
18
|
import "./_libs/dot-prop.mjs";
|
|
19
|
-
import {
|
|
19
|
+
import { t as getBuildInfo } from "./_chunks/B5AdGxPO.mjs";
|
|
20
|
+
import { n as writeTypes } from "./_chunks/CsQc45Wt.mjs";
|
|
20
21
|
import "./_libs/rou3.mjs";
|
|
21
22
|
import "./_libs/mime.mjs";
|
|
22
23
|
import "./_libs/pathe.mjs";
|
|
@@ -27,4 +28,4 @@ import { n as createDevServer } from "./_dev.mjs";
|
|
|
27
28
|
import "./_libs/chokidar.mjs";
|
|
28
29
|
import "./_libs/ultrahtml.mjs";
|
|
29
30
|
|
|
30
|
-
export { build, copyPublicAssets, createDevServer, createNitro, listTasks, loadOptions, prepare, prerender, runTask, writeTypes };
|
|
31
|
+
export { build, copyPublicAssets, createDevServer, createNitro, getBuildInfo, listTasks, loadOptions, prepare, prerender, runTask, writeTypes };
|
package/dist/cli/_chunks/dev.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { O as resolve } from "../../_libs/c12.mjs";
|
|
2
2
|
import "../../_libs/std-env.mjs";
|
|
3
|
+
import "../../_libs/dot-prop.mjs";
|
|
4
|
+
import "../../_chunks/B5AdGxPO.mjs";
|
|
3
5
|
import "../../_libs/mime.mjs";
|
|
4
6
|
import "../../_libs/httpxy.mjs";
|
|
5
7
|
import { t as NitroDevServer } from "../../_dev.mjs";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../../_libs/
|
|
2
|
-
import { n as registryProvider, t as downloadTemplate } from "../../_libs/giget.mjs";
|
|
1
|
+
import { n as createProxyServer, t as ProxyServer } from "../../_libs/httpxy.mjs";
|
|
3
2
|
|
|
4
|
-
export {
|
|
3
|
+
export { ProxyServer, createProxyServer };
|
package/dist/vite.mjs
CHANGED
|
@@ -13,10 +13,11 @@ import "./_libs/tinyglobby.mjs";
|
|
|
13
13
|
import "./_libs/compatx.mjs";
|
|
14
14
|
import "./_libs/klona.mjs";
|
|
15
15
|
import "./_libs/std-env.mjs";
|
|
16
|
-
import "./_chunks/
|
|
16
|
+
import "./_chunks/o9sqmlxd.mjs";
|
|
17
17
|
import "./_libs/escape-string-regexp.mjs";
|
|
18
18
|
import "./_libs/dot-prop.mjs";
|
|
19
|
-
import "./_chunks/
|
|
19
|
+
import "./_chunks/B5AdGxPO.mjs";
|
|
20
|
+
import "./_chunks/CsQc45Wt.mjs";
|
|
20
21
|
import "./_libs/rou3.mjs";
|
|
21
22
|
import "./_libs/mime.mjs";
|
|
22
23
|
import "./_libs/pathe.mjs";
|
package/package.json
CHANGED