nitro-nightly 3.0.1-20251209-203952-cd9c2915 → 3.0.1-20251210-103926-22a293c5
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/vite.build.mjs +1 -1
- package/dist/_build/vite.plugin.mjs +1 -1
- package/dist/_chunks/{vCTaGRPD.mjs → C0jn5-Q_.mjs} +6 -1
- package/dist/_libs/rou3.mjs +4 -4
- package/dist/_presets.mjs +9 -4
- package/dist/builder.mjs +1 -1
- package/dist/presets/vercel/runtime/isr.d.mts +2 -0
- package/dist/presets/vercel/runtime/isr.mjs +19 -0
- package/dist/presets/vercel/runtime/vercel.node.mjs +8 -6
- package/dist/presets/vercel/runtime/vercel.web.mjs +8 -8
- package/dist/runtime/app.d.mts +1 -1
- package/dist/runtime/app.mjs +1 -1
- package/dist/runtime/internal/app.d.mts +6 -2
- package/dist/runtime/internal/app.mjs +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +2 -2
|
@@ -6,7 +6,7 @@ import "../_libs/acorn.mjs";
|
|
|
6
6
|
import "../_libs/unimport.mjs";
|
|
7
7
|
import "../_libs/@rollup/plugin-commonjs.mjs";
|
|
8
8
|
import { i as a } from "../_libs/std-env.mjs";
|
|
9
|
-
import "../_chunks/
|
|
9
|
+
import "../_chunks/C0jn5-Q_.mjs";
|
|
10
10
|
import "../_libs/tsconfck.mjs";
|
|
11
11
|
import "../_chunks/Df3_4Pam.mjs";
|
|
12
12
|
import "../_chunks/CycPUgTQ.mjs";
|
|
@@ -3,7 +3,7 @@ import { t as assetsPlugin } from "../_libs/@pi0/vite-plugin-fullstack.mjs";
|
|
|
3
3
|
import { d as sanitizeFilePath } from "../_libs/local-pkg.mjs";
|
|
4
4
|
import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
5
5
|
import { i as a, r as T } from "../_libs/std-env.mjs";
|
|
6
|
-
import { a as copyPublicAssets, i as prepare, s as createNitro } from "../_chunks/
|
|
6
|
+
import { a as copyPublicAssets, i as prepare, s as createNitro } from "../_chunks/C0jn5-Q_.mjs";
|
|
7
7
|
import { n as prettyPath } from "../_chunks/Df3_4Pam.mjs";
|
|
8
8
|
import { i as scanHandlers } from "../_chunks/CycPUgTQ.mjs";
|
|
9
9
|
import { n as writeBuildInfo, t as getBuildInfo } from "./common.mjs";
|
|
@@ -818,7 +818,12 @@ var Router = class {
|
|
|
818
818
|
compileToString(opts) {
|
|
819
819
|
if (this._compiled) return this._compiled;
|
|
820
820
|
this._compiled = compileRouterToString(this._router, void 0, opts);
|
|
821
|
-
if (this.routes.length === 1 && this.routes[0].route === "/**" && this.routes[0].method === "")
|
|
821
|
+
if (this.routes.length === 1 && this.routes[0].route === "/**" && this.routes[0].method === "") {
|
|
822
|
+
const data = (opts?.serialize || JSON.stringify)(this.routes[0].data);
|
|
823
|
+
let retCode = `{data,params:{"_":p.slice(1)}}`;
|
|
824
|
+
if (opts?.matchAll) retCode = `[${retCode}]`;
|
|
825
|
+
this._compiled = `/* @__PURE__ */ (() => {const data=${data};return ((_m, p)=>{return ${retCode};})})()`;
|
|
826
|
+
}
|
|
822
827
|
return this._compiled;
|
|
823
828
|
}
|
|
824
829
|
match(method, path) {
|
package/dist/_libs/rou3.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region node_modules/.pnpm/rou3@0.7.
|
|
1
|
+
//#region node_modules/.pnpm/rou3@0.7.11/node_modules/rou3/dist/index.mjs
|
|
2
2
|
const NullProtoObj = /* @__PURE__ */ (() => {
|
|
3
3
|
const e = function() {};
|
|
4
4
|
return e.prototype = Object.create(null), Object.freeze(e.prototype), e;
|
|
@@ -19,7 +19,7 @@ function splitPath(path) {
|
|
|
19
19
|
function getMatchParams(segments, paramsMap) {
|
|
20
20
|
const params = new NullProtoObj();
|
|
21
21
|
for (const [index, name] of paramsMap) {
|
|
22
|
-
const segment = index < 0 ? segments.slice(-
|
|
22
|
+
const segment = index < 0 ? segments.slice(-(index + 1)).join("/") : segments[index];
|
|
23
23
|
if (typeof name === "string") params[name] = segment;
|
|
24
24
|
else {
|
|
25
25
|
const match = segment.match(name);
|
|
@@ -45,7 +45,7 @@ function addRoute(ctx, method = "", path, data) {
|
|
|
45
45
|
if (!node.wildcard) node.wildcard = { key: "**" };
|
|
46
46
|
node = node.wildcard;
|
|
47
47
|
paramsMap.push([
|
|
48
|
-
-i,
|
|
48
|
+
-(i + 1),
|
|
49
49
|
segment.split(":")[1] || "_",
|
|
50
50
|
segment.length === 2
|
|
51
51
|
]);
|
|
@@ -200,7 +200,7 @@ function _findAll(ctx, node, method, segments, index, matches = []) {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
//#endregion
|
|
203
|
-
//#region node_modules/.pnpm/rou3@0.7.
|
|
203
|
+
//#region node_modules/.pnpm/rou3@0.7.11/node_modules/rou3/dist/compiler.mjs
|
|
204
204
|
/**
|
|
205
205
|
* Compile the router instance into a compact runnable code.
|
|
206
206
|
*
|
package/dist/_presets.mjs
CHANGED
|
@@ -1359,6 +1359,10 @@ const stormkit = defineNitroPreset({
|
|
|
1359
1359
|
});
|
|
1360
1360
|
var preset_default$22 = [stormkit];
|
|
1361
1361
|
|
|
1362
|
+
//#endregion
|
|
1363
|
+
//#region src/presets/vercel/runtime/isr.ts
|
|
1364
|
+
const ISR_URL_PARAM = "__isr_route";
|
|
1365
|
+
|
|
1362
1366
|
//#endregion
|
|
1363
1367
|
//#region src/presets/vercel/utils.ts
|
|
1364
1368
|
const SUPPORTED_NODE_VERSIONS = [20, 22];
|
|
@@ -1439,17 +1443,17 @@ function generateBuildConfig(nitro, o11Routes) {
|
|
|
1439
1443
|
});
|
|
1440
1444
|
if (nitro.options.static) return config;
|
|
1441
1445
|
config.routes.push(...nitro.options.routeRules["/"]?.isr ? [{
|
|
1442
|
-
src:
|
|
1443
|
-
dest: `/index${ISR_SUFFIX}
|
|
1446
|
+
src: `(?<${ISR_URL_PARAM}>/)`,
|
|
1447
|
+
dest: `/index${ISR_SUFFIX}?${ISR_URL_PARAM}=$${ISR_URL_PARAM}`
|
|
1444
1448
|
}] : [], ...rules.filter(([key, value]) => value.isr !== void 0 && key !== "/").map(([key, value]) => {
|
|
1445
|
-
const src =
|
|
1449
|
+
const src = `(?<${ISR_URL_PARAM}>${normalizeRouteSrc(key)})`;
|
|
1446
1450
|
if (value.isr === false) return {
|
|
1447
1451
|
src,
|
|
1448
1452
|
dest: FALLBACK_ROUTE
|
|
1449
1453
|
};
|
|
1450
1454
|
return {
|
|
1451
1455
|
src,
|
|
1452
|
-
dest: withLeadingSlash(normalizeRouteDest(key) + ISR_SUFFIX +
|
|
1456
|
+
dest: withLeadingSlash(normalizeRouteDest(key) + ISR_SUFFIX + `?${ISR_URL_PARAM}=$${ISR_URL_PARAM}`)
|
|
1453
1457
|
};
|
|
1454
1458
|
}), ...(o11Routes || []).map((route) => ({
|
|
1455
1459
|
src: joinURL(nitro.options.baseURL, route.src),
|
|
@@ -1549,6 +1553,7 @@ async function writePrerenderConfig(filename, isrConfig, bypassToken) {
|
|
|
1549
1553
|
bypassToken,
|
|
1550
1554
|
...isrConfig
|
|
1551
1555
|
};
|
|
1556
|
+
if (prerenderConfig.allowQuery && !prerenderConfig.allowQuery.includes(ISR_URL_PARAM)) prerenderConfig.allowQuery.push(ISR_URL_PARAM);
|
|
1552
1557
|
await writeFile$1(filename, JSON.stringify(prerenderConfig, null, 2));
|
|
1553
1558
|
}
|
|
1554
1559
|
|
package/dist/builder.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import "./_libs/@pi0/vite-plugin-fullstack.mjs";
|
|
|
5
5
|
import "./_libs/acorn.mjs";
|
|
6
6
|
import "./_libs/unimport.mjs";
|
|
7
7
|
import "./_libs/@rollup/plugin-commonjs.mjs";
|
|
8
|
-
import { a as copyPublicAssets, c as loadOptions, i as prepare, n as runTask, o as build, r as prerender, s as createNitro, t as listTasks } from "./_chunks/
|
|
8
|
+
import { a as copyPublicAssets, c as loadOptions, i as prepare, n as runTask, o as build, r as prerender, s as createNitro, t as listTasks } from "./_chunks/C0jn5-Q_.mjs";
|
|
9
9
|
import "./_libs/tsconfck.mjs";
|
|
10
10
|
import "./_chunks/Df3_4Pam.mjs";
|
|
11
11
|
import { n as writeTypes } from "./_chunks/CycPUgTQ.mjs";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const ISR_URL_PARAM = "__isr_route";
|
|
2
|
+
export function isrRouteRewrite(reqUrl, xNowRouteMatches) {
|
|
3
|
+
if (xNowRouteMatches) {
|
|
4
|
+
const isrURL = new URLSearchParams(xNowRouteMatches).get(ISR_URL_PARAM);
|
|
5
|
+
if (isrURL) {
|
|
6
|
+
return [decodeURIComponent(isrURL), ""];
|
|
7
|
+
}
|
|
8
|
+
} else {
|
|
9
|
+
const queryIndex = reqUrl.indexOf("?");
|
|
10
|
+
if (queryIndex !== -1) {
|
|
11
|
+
const params = new URLSearchParams(reqUrl.slice(queryIndex + 1));
|
|
12
|
+
const isrURL = params.get(ISR_URL_PARAM);
|
|
13
|
+
if (isrURL) {
|
|
14
|
+
params.delete(ISR_URL_PARAM);
|
|
15
|
+
return [decodeURIComponent(isrURL), params.toString()];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import "#nitro-internal-polyfills";
|
|
2
2
|
import { toNodeHandler } from "srvx/node";
|
|
3
|
-
import { useNitroApp } from "nitro/app";
|
|
3
|
+
import { useNitroApp, getRouteRules } from "nitro/app";
|
|
4
|
+
import { isrRouteRewrite } from "./isr.mjs";
|
|
4
5
|
const nitroApp = useNitroApp();
|
|
5
6
|
const handler = toNodeHandler(nitroApp.fetch);
|
|
6
7
|
export default function nodeHandler(req, res) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
// ISR route rewrite
|
|
9
|
+
const isrURL = isrRouteRewrite(req.url, req.headers["x-now-route-matches"]);
|
|
10
|
+
if (isrURL) {
|
|
11
|
+
const { routeRules } = getRouteRules("", isrURL[0]);
|
|
12
|
+
if (routeRules?.isr) {
|
|
13
|
+
req.url = isrURL[0] + (isrURL[1] ? `?${isrURL[1]}` : "");
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
return handler(req, res);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import "#nitro-internal-polyfills";
|
|
2
|
-
import { useNitroApp } from "nitro/app";
|
|
2
|
+
import { useNitroApp, getRouteRules } from "nitro/app";
|
|
3
|
+
import { isrRouteRewrite } from "./isr.mjs";
|
|
3
4
|
const nitroApp = useNitroApp();
|
|
4
5
|
export default { fetch(req, context) {
|
|
5
|
-
//
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
req = new Request(url, req);
|
|
6
|
+
// ISR route rewrite
|
|
7
|
+
const isrURL = isrRouteRewrite(req.url, req.headers.get("x-now-route-matches"));
|
|
8
|
+
if (isrURL) {
|
|
9
|
+
const { routeRules } = getRouteRules("", isrURL[0]);
|
|
10
|
+
if (routeRules?.isr) {
|
|
11
|
+
req = new Request(new URL(isrURL[0] + (isrURL[1] ? `?${isrURL[1]}` : ""), req.url).href, req);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
// srvx compatibility
|
package/dist/runtime/app.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { useNitroApp, useNitroHooks, serverFetch, fetch } from "./internal/app.mjs";
|
|
1
|
+
export { useNitroApp, useNitroHooks, serverFetch, getRouteRules, fetch } from "./internal/app.mjs";
|
package/dist/runtime/app.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { useNitroApp, useNitroHooks, serverFetch, fetch } from "./internal/app.mjs";
|
|
1
|
+
export { useNitroApp, useNitroHooks, serverFetch, getRouteRules, fetch } from "./internal/app.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { NitroApp, NitroRuntimeHooks } from "nitro/types";
|
|
1
|
+
import type { MatchedRouteRules, NitroApp, NitroRuntimeHooks } from "nitro/types";
|
|
2
2
|
import type { ServerRequest, ServerRequestContext } from "srvx";
|
|
3
|
-
import type { H3EventContext, WebSocketHooks } from "h3";
|
|
3
|
+
import type { H3EventContext, Middleware, WebSocketHooks } from "h3";
|
|
4
4
|
import { HookableCore } from "hookable";
|
|
5
5
|
declare global {
|
|
6
6
|
var __nitro__: NitroApp | undefined;
|
|
@@ -10,3 +10,7 @@ export declare function useNitroHooks(): HookableCore<NitroRuntimeHooks>;
|
|
|
10
10
|
export declare function serverFetch(resource: string | URL | Request, init?: RequestInit, context?: ServerRequestContext | H3EventContext): Promise<Response>;
|
|
11
11
|
export declare function resolveWebsocketHooks(req: ServerRequest): Promise<Partial<WebSocketHooks>>;
|
|
12
12
|
export declare function fetch(resource: string | URL | Request, init?: RequestInit, context?: ServerRequestContext | H3EventContext): Promise<Response>;
|
|
13
|
+
export declare function getRouteRules(method: string, pathname: string): {
|
|
14
|
+
routeRules?: MatchedRouteRules;
|
|
15
|
+
routeRuleMiddleware: Middleware[];
|
|
16
|
+
};
|
|
@@ -148,7 +148,7 @@ function createH3App(config) {
|
|
|
148
148
|
}
|
|
149
149
|
return h3App;
|
|
150
150
|
}
|
|
151
|
-
function getRouteRules(method, pathname) {
|
|
151
|
+
export function getRouteRules(method, pathname) {
|
|
152
152
|
const m = findRouteRules(method, pathname);
|
|
153
153
|
if (!m?.length) {
|
|
154
154
|
return { routeRuleMiddleware: [] };
|
package/dist/vite.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import "./_libs/@pi0/vite-plugin-fullstack.mjs";
|
|
|
5
5
|
import "./_libs/acorn.mjs";
|
|
6
6
|
import "./_libs/unimport.mjs";
|
|
7
7
|
import "./_libs/@rollup/plugin-commonjs.mjs";
|
|
8
|
-
import "./_chunks/
|
|
8
|
+
import "./_chunks/C0jn5-Q_.mjs";
|
|
9
9
|
import "./_libs/tsconfck.mjs";
|
|
10
10
|
import "./_chunks/Df3_4Pam.mjs";
|
|
11
11
|
import "./_chunks/CycPUgTQ.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-nightly",
|
|
3
|
-
"version": "3.0.1-
|
|
3
|
+
"version": "3.0.1-20251210-103926-22a293c5",
|
|
4
4
|
"description": "Build and Deploy Universal JavaScript Servers",
|
|
5
5
|
"homepage": "https://nitro.build",
|
|
6
6
|
"repository": "nitrojs/nitro",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"rolldown": "1.0.0-beta.53",
|
|
142
142
|
"rolldown-vite": "^7.2.10",
|
|
143
143
|
"rollup": "^4.53.3",
|
|
144
|
-
"rou3": "^0.7.
|
|
144
|
+
"rou3": "^0.7.11",
|
|
145
145
|
"scule": "^1.3.0",
|
|
146
146
|
"semver": "^7.7.3",
|
|
147
147
|
"serve-placeholder": "^2.0.2",
|