vinext 0.0.21 → 0.0.22
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/deploy.d.ts.map +1 -1
- package/dist/deploy.js +6 -3
- package/dist/deploy.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +179 -10
- package/dist/index.js.map +1 -1
- package/dist/routing/app-router.d.ts.map +1 -1
- package/dist/routing/app-router.js +1 -41
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/pages-router.d.ts.map +1 -1
- package/dist/routing/pages-router.js +1 -27
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/routing/utils.d.ts +25 -0
- package/dist/routing/utils.d.ts.map +1 -0
- package/dist/routing/utils.js +70 -0
- package/dist/routing/utils.js.map +1 -0
- package/dist/server/app-dev-server.d.ts.map +1 -1
- package/dist/server/app-dev-server.js +70 -3
- package/dist/server/app-dev-server.js.map +1 -1
- package/dist/server/dev-server.d.ts.map +1 -1
- package/dist/server/dev-server.js +77 -4
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/prod-server.d.ts.map +1 -1
- package/dist/server/prod-server.js +7 -0
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-log.d.ts +34 -0
- package/dist/server/request-log.d.ts.map +1 -0
- package/dist/server/request-log.js +65 -0
- package/dist/server/request-log.js.map +1 -0
- package/dist/shims/cache-runtime.d.ts.map +1 -1
- package/dist/shims/cache-runtime.js +5 -1
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +6 -0
- package/dist/shims/cache.d.ts.map +1 -1
- package/dist/shims/cache.js +22 -2
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/head.d.ts +11 -0
- package/dist/shims/head.d.ts.map +1 -1
- package/dist/shims/head.js +21 -0
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +8 -0
- package/dist/shims/headers.d.ts.map +1 -1
- package/dist/shims/headers.js +41 -0
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/script.d.ts.map +1 -1
- package/dist/shims/script.js +7 -1
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.d.ts.map +1 -1
- package/dist/shims/server.js +2 -1
- package/dist/shims/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -1254,6 +1254,12 @@ export default async function handler(request) {
|
|
|
1254
1254
|
}
|
|
1255
1255
|
|
|
1256
1256
|
async function _handleRequest(request, __reqCtx) {
|
|
1257
|
+
const __reqStart = process.env.NODE_ENV !== "production" ? performance.now() : 0;
|
|
1258
|
+
let __compileEnd;
|
|
1259
|
+
let __renderEnd;
|
|
1260
|
+
// __reqStart is included in the timing header so the Node logging middleware
|
|
1261
|
+
// can compute true compile time as: handlerStart - middlewareStart.
|
|
1262
|
+
// Format: "handlerStart,compileMs,renderMs" - all as integers (ms). Dev-only.
|
|
1257
1263
|
const url = new URL(request.url);
|
|
1258
1264
|
|
|
1259
1265
|
// ── Cross-origin request protection ─────────────────────────────────
|
|
@@ -1300,7 +1306,11 @@ async function _handleRequest(request, __reqCtx) {
|
|
|
1300
1306
|
|
|
1301
1307
|
// ── Apply redirects from next.config.js ───────────────────────────────
|
|
1302
1308
|
if (__configRedirects.length) {
|
|
1303
|
-
|
|
1309
|
+
// Strip .rsc suffix before matching redirect rules - RSC (client-side nav) requests
|
|
1310
|
+
// arrive as /some/path.rsc but redirect patterns are defined without it (e.g.
|
|
1311
|
+
// /some/path). Without this, soft-nav fetches bypass all config redirects.
|
|
1312
|
+
const __redirPathname = pathname.endsWith(".rsc") ? pathname.slice(0, -4) : pathname;
|
|
1313
|
+
const __redir = __applyConfigRedirects(__redirPathname, __reqCtx);
|
|
1304
1314
|
if (__redir) {
|
|
1305
1315
|
const __redirDest = __sanitizeDestination(
|
|
1306
1316
|
__basePath && !__redir.destination.startsWith(__basePath)
|
|
@@ -1316,7 +1326,9 @@ async function _handleRequest(request, __reqCtx) {
|
|
|
1316
1326
|
|
|
1317
1327
|
// ── Apply beforeFiles rewrites from next.config.js ────────────────────
|
|
1318
1328
|
if (__configRewrites.beforeFiles && __configRewrites.beforeFiles.length) {
|
|
1319
|
-
|
|
1329
|
+
// Strip .rsc suffix before matching rewrite rules — same reason as redirects above.
|
|
1330
|
+
const __rewritePathname = pathname.endsWith(".rsc") ? pathname.slice(0, -4) : pathname;
|
|
1331
|
+
const __rewritten = __applyConfigRewrites(__rewritePathname, __configRewrites.beforeFiles, __reqCtx);
|
|
1320
1332
|
if (__rewritten) {
|
|
1321
1333
|
if (__isExternalUrl(__rewritten)) {
|
|
1322
1334
|
setHeadersContext(null);
|
|
@@ -2098,6 +2110,9 @@ async function _handleRequest(request, __reqCtx) {
|
|
|
2098
2110
|
console.error = _origConsoleError;
|
|
2099
2111
|
}
|
|
2100
2112
|
|
|
2113
|
+
// Mark end of compile phase: route matching, middleware, tree building are done.
|
|
2114
|
+
if (process.env.NODE_ENV !== "production") __compileEnd = performance.now();
|
|
2115
|
+
|
|
2101
2116
|
// Render to RSC stream
|
|
2102
2117
|
const rscStream = renderToReadableStream(element, { onError: rscOnError });
|
|
2103
2118
|
|
|
@@ -2126,6 +2141,21 @@ async function _handleRequest(request, __reqCtx) {
|
|
|
2126
2141
|
responseHeaders[key] = value;
|
|
2127
2142
|
}
|
|
2128
2143
|
}
|
|
2144
|
+
// Attach internal timing header so the dev server middleware can log it.
|
|
2145
|
+
// Format: "handlerStart,compileMs,renderMs"
|
|
2146
|
+
// handlerStart - absolute performance.now() when _handleRequest began,
|
|
2147
|
+
// used by the logging middleware to compute true compile
|
|
2148
|
+
// time as (handlerStart - middlewareReqStart).
|
|
2149
|
+
// compileMs - time inside the handler before renderToReadableStream.
|
|
2150
|
+
// -1 sentinel means compile time is not measured.
|
|
2151
|
+
// renderMs - -1 sentinel for RSC-only (soft-nav) responses, since
|
|
2152
|
+
// rendering is handled asynchronously by the client. The
|
|
2153
|
+
// logging middleware computes render time as totalMs - compileMs.
|
|
2154
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2155
|
+
const handlerStart = Math.round(__reqStart);
|
|
2156
|
+
const compileMs = __compileEnd !== undefined ? Math.round(__compileEnd - __reqStart) : -1;
|
|
2157
|
+
responseHeaders["x-vinext-timing"] = handlerStart + "," + compileMs + ",-1";
|
|
2158
|
+
}
|
|
2129
2159
|
return new Response(rscStream, { status: _middlewareRewriteStatus || 200, headers: responseHeaders });
|
|
2130
2160
|
}
|
|
2131
2161
|
|
|
@@ -2152,6 +2182,8 @@ async function _handleRequest(request, __reqCtx) {
|
|
|
2152
2182
|
try {
|
|
2153
2183
|
const ssrEntry = await import.meta.viteRsc.loadModule("ssr", "index");
|
|
2154
2184
|
htmlStream = await ssrEntry.handleSsr(rscStream, _getNavigationContext(), fontData);
|
|
2185
|
+
// Shell render complete; Suspense boundaries stream asynchronously
|
|
2186
|
+
if (process.env.NODE_ENV !== "production") __renderEnd = performance.now();
|
|
2155
2187
|
} catch (ssrErr) {
|
|
2156
2188
|
const specialResponse = await handleRenderError(ssrErr);
|
|
2157
2189
|
if (specialResponse) return specialResponse;
|
|
@@ -2182,6 +2214,22 @@ async function _handleRequest(request, __reqCtx) {
|
|
|
2182
2214
|
response.headers.append(key, value);
|
|
2183
2215
|
}
|
|
2184
2216
|
}
|
|
2217
|
+
// Attach internal timing header so the dev server middleware can log it.
|
|
2218
|
+
// Format: "handlerStart,compileMs,renderMs"
|
|
2219
|
+
// handlerStart - absolute performance.now() when _handleRequest began,
|
|
2220
|
+
// used by the logging middleware to compute true compile
|
|
2221
|
+
// time as (handlerStart - middlewareReqStart).
|
|
2222
|
+
// compileMs - time inside the handler before renderToReadableStream.
|
|
2223
|
+
// renderMs - time from renderToReadableStream to handleSsr completion,
|
|
2224
|
+
// or -1 sentinel if not measured (falls back to totalMs - compileMs).
|
|
2225
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2226
|
+
const handlerStart = Math.round(__reqStart);
|
|
2227
|
+
const compileMs = __compileEnd !== undefined ? Math.round(__compileEnd - __reqStart) : -1;
|
|
2228
|
+
const renderMs = __renderEnd !== undefined && __compileEnd !== undefined
|
|
2229
|
+
? Math.round(__renderEnd - __compileEnd)
|
|
2230
|
+
: -1;
|
|
2231
|
+
response.headers.set("x-vinext-timing", handlerStart + "," + compileMs + "," + renderMs);
|
|
2232
|
+
}
|
|
2185
2233
|
// Apply custom status code from middleware rewrite
|
|
2186
2234
|
if (_middlewareRewriteStatus) {
|
|
2187
2235
|
return new Response(response.body, {
|
|
@@ -2932,7 +2980,12 @@ async function main() {
|
|
|
2932
2980
|
// Checks the prefetch cache (populated by <Link> IntersectionObserver and
|
|
2933
2981
|
// router.prefetch()) before making a network request. This makes navigation
|
|
2934
2982
|
// near-instant for prefetched routes.
|
|
2935
|
-
window.__VINEXT_RSC_NAVIGATE__ = async function navigateRsc(href) {
|
|
2983
|
+
window.__VINEXT_RSC_NAVIGATE__ = async function navigateRsc(href, __redirectDepth) {
|
|
2984
|
+
if ((__redirectDepth || 0) > 10) {
|
|
2985
|
+
console.error("[vinext] Too many RSC redirects — aborting navigation to prevent infinite loop.");
|
|
2986
|
+
window.location.href = href;
|
|
2987
|
+
return;
|
|
2988
|
+
}
|
|
2936
2989
|
try {
|
|
2937
2990
|
const url = new URL(href, window.location.origin);
|
|
2938
2991
|
const rscUrl = toRscUrl(url.pathname + url.search);
|
|
@@ -2958,6 +3011,20 @@ async function main() {
|
|
|
2958
3011
|
});
|
|
2959
3012
|
}
|
|
2960
3013
|
|
|
3014
|
+
// Detect if fetch followed a redirect: compare the final response URL to
|
|
3015
|
+
// what we requested. If they differ, the server issued a 3xx — push the
|
|
3016
|
+
// canonical destination URL into history before rendering.
|
|
3017
|
+
const __finalUrl = new URL(navResponse.url);
|
|
3018
|
+
const __requestedUrl = new URL(rscUrl, window.location.origin);
|
|
3019
|
+
if (__finalUrl.pathname !== __requestedUrl.pathname) {
|
|
3020
|
+
// Strip .rsc suffix from the final URL to get the page path for history.
|
|
3021
|
+
// Use replaceState instead of pushState: the caller (navigateImpl) already
|
|
3022
|
+
// pushed the pre-redirect URL; replacing it avoids a stale history entry.
|
|
3023
|
+
const __destPath = __finalUrl.pathname.replace(/\\.rsc$/, "") + __finalUrl.search;
|
|
3024
|
+
window.history.replaceState(null, "", __destPath);
|
|
3025
|
+
return window.__VINEXT_RSC_NAVIGATE__(__destPath, (__redirectDepth || 0) + 1);
|
|
3026
|
+
}
|
|
3027
|
+
|
|
2961
3028
|
// Update useParams() with route params from the server before re-rendering
|
|
2962
3029
|
const navParamsHeader = navResponse.headers.get("X-Vinext-Params");
|
|
2963
3030
|
if (navParamsHeader) {
|