vinext 1.0.0-beta.6 → 1.0.0-beta.8
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/README.md +47 -3
- package/dist/build/action-owner-manifest.d.ts +42 -0
- package/dist/build/action-owner-manifest.js +110 -0
- package/dist/build/clean-output.js +1 -4
- package/dist/build/client-build-config.js +10 -11
- package/dist/build/prerender.d.ts +1 -1
- package/dist/build/prerender.js +12 -6
- package/dist/build/report.d.ts +1 -1
- package/dist/build/route-classification-manifest.d.ts +1 -1
- package/dist/build/static-export.d.ts +1 -1
- package/dist/client/app-nav-failure-handler.js +1 -0
- package/dist/client/navigation-runtime.d.ts +5 -3
- package/dist/client/navigation-runtime.js +4 -8
- package/dist/entries/app-browser-entry.d.ts +1 -1
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +111 -8
- package/dist/entries/pages-client-entry.d.ts +1 -1
- package/dist/entries/pages-server-entry.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +119 -26
- package/dist/plugins/action-owner-manifest.d.ts +14 -0
- package/dist/plugins/action-owner-manifest.js +84 -0
- package/dist/plugins/ast-utils.d.ts +30 -1
- package/dist/plugins/ast-utils.js +76 -1
- package/dist/plugins/css-module-imports.d.ts +2 -2
- package/dist/plugins/css-module-imports.js +5 -13
- package/dist/plugins/dynamic-preload-metadata.js +13 -34
- package/dist/plugins/environment.d.ts +11 -0
- package/dist/plugins/environment.js +7 -0
- package/dist/plugins/extensionless-dynamic-import.js +11 -35
- package/dist/plugins/fonts.js +8 -12
- package/dist/plugins/ignore-dynamic-requests.d.ts +2 -4
- package/dist/plugins/ignore-dynamic-requests.js +29 -59
- package/dist/plugins/import-meta-url.d.ts +15 -9
- package/dist/plugins/import-meta-url.js +310 -85
- package/dist/plugins/instrumentation-client.js +4 -5
- package/dist/plugins/middleware-export-validation.js +5 -17
- package/dist/plugins/middleware-server-only.js +2 -2
- package/dist/plugins/og-asset-ownership.js +18 -26
- package/dist/plugins/og-assets.js +2 -4
- package/dist/plugins/optimize-imports.js +2 -4
- package/dist/plugins/pages-node-externals.js +13 -40
- package/dist/plugins/remove-console.js +2 -4
- package/dist/plugins/require-condition-resolution.d.ts +16 -0
- package/dist/plugins/require-condition-resolution.js +167 -0
- package/dist/plugins/require-context.js +11 -46
- package/dist/plugins/sass.js +1 -1
- package/dist/plugins/server-externals-manifest.js +1 -23
- package/dist/plugins/strip-server-exports.js +13 -19
- package/dist/plugins/styled-jsx.js +17 -19
- package/dist/plugins/transform-result.d.ts +10 -0
- package/dist/plugins/transform-result.js +10 -0
- package/dist/plugins/transitive-externals.js +7 -21
- package/dist/plugins/typeof-window.d.ts +3 -8
- package/dist/plugins/typeof-window.js +5 -15
- package/dist/plugins/use-cache-callable.js +12 -22
- package/dist/plugins/wasm-module-import.js +1 -1
- package/dist/plugins/worker-image-imports.d.ts +12 -0
- package/dist/plugins/worker-image-imports.js +136 -0
- package/dist/routing/app-route-graph.d.ts +3 -2
- package/dist/routing/app-route-graph.js +1 -1
- package/dist/routing/route-pattern.d.ts +8 -1
- package/dist/routing/route-pattern.js +28 -1
- package/dist/routing/route-validation.js +7 -1
- package/dist/server/accept-encoding.d.ts +1 -2
- package/dist/server/accept-encoding.js +1 -4
- package/dist/server/app-action-forwarding.d.ts +18 -0
- package/dist/server/app-action-forwarding.js +140 -0
- package/dist/server/app-browser-entry.js +231 -50
- package/dist/server/app-browser-error.d.ts +1 -2
- package/dist/server/app-browser-error.js +1 -5
- package/dist/server/app-browser-history-controller.d.ts +16 -1
- package/dist/server/app-browser-history-controller.js +135 -18
- package/dist/server/app-browser-navigation-abort.d.ts +16 -0
- package/dist/server/app-browser-navigation-abort.js +29 -0
- package/dist/server/app-browser-navigation-controller.d.ts +4 -0
- package/dist/server/app-browser-navigation-controller.js +22 -6
- package/dist/server/app-browser-navigation-response.d.ts +11 -0
- package/dist/server/app-browser-navigation-response.js +8 -0
- package/dist/server/app-browser-popstate.d.ts +6 -1
- package/dist/server/app-browser-popstate.js +6 -2
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +3 -3
- package/dist/server/app-browser-stream.d.ts +0 -2
- package/dist/server/app-browser-supplemental-refresh.d.ts +49 -0
- package/dist/server/app-browser-supplemental-refresh.js +190 -0
- package/dist/server/app-browser-visible-commit.js +23 -12
- package/dist/server/app-elements-wire.d.ts +2 -0
- package/dist/server/app-elements-wire.js +7 -0
- package/dist/server/app-history-state.d.ts +22 -1
- package/dist/server/app-history-state.js +93 -9
- package/dist/server/app-optimistic-routing.d.ts +22 -1
- package/dist/server/app-optimistic-routing.js +137 -12
- package/dist/server/app-page-cache-finalizer.d.ts +3 -1
- package/dist/server/app-page-cache-finalizer.js +6 -6
- package/dist/server/app-page-cache.d.ts +2 -1
- package/dist/server/app-page-cache.js +2 -2
- package/dist/server/app-page-dispatch.d.ts +4 -1
- package/dist/server/app-page-dispatch.js +10 -1
- package/dist/server/app-page-element-builder.d.ts +1 -0
- package/dist/server/app-page-element-builder.js +1 -0
- package/dist/server/app-page-ppr-runtime.js +3 -2
- package/dist/server/app-page-render.d.ts +2 -1
- package/dist/server/app-page-render.js +6 -3
- package/dist/server/app-page-request.d.ts +2 -33
- package/dist/server/app-page-request.js +1 -27
- package/dist/server/app-page-route-wiring.d.ts +1 -0
- package/dist/server/app-page-route-wiring.js +4 -0
- package/dist/server/app-page-segment-state.d.ts +2 -2
- package/dist/server/app-page-segment-state.js +14 -8
- package/dist/server/app-ppr-fallback-shell.d.ts +2 -2
- package/dist/server/app-ppr-fallback-shell.js +3 -6
- package/dist/server/app-route-handler-dispatch.js +4 -1
- package/dist/server/app-route-handler-execution.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.js +34 -8
- package/dist/server/app-rsc-handler.d.ts +4 -2
- package/dist/server/app-rsc-handler.js +57 -9
- package/dist/server/app-rsc-request-normalization.d.ts +2 -0
- package/dist/server/app-rsc-request-normalization.js +5 -1
- package/dist/server/app-rsc-route-matching.d.ts +4 -3
- package/dist/server/app-rsc-route-matching.js +14 -42
- package/dist/server/app-server-action-execution.d.ts +3 -0
- package/dist/server/app-server-action-execution.js +77 -2
- package/dist/server/app-ssr-entry.js +6 -6
- package/dist/server/app-ssr-stream.d.ts +1 -1
- package/dist/server/app-ssr-stream.js +2 -2
- package/dist/server/app-visited-response-cache.d.ts +6 -1
- package/dist/server/app-visited-response-cache.js +18 -2
- package/dist/server/dev-route-files.js +2 -5
- package/dist/server/dev-server.d.ts +5 -13
- package/dist/server/dev-server.js +22 -22
- package/dist/server/dev-stack-sourcemap.d.ts +1 -2
- package/dist/server/dev-stack-sourcemap.js +1 -4
- package/dist/server/headers.d.ts +5 -1
- package/dist/server/headers.js +5 -1
- package/dist/server/isr-cache.d.ts +6 -14
- package/dist/server/isr-cache.js +6 -27
- package/dist/server/middleware.d.ts +3 -16
- package/dist/server/middleware.js +2 -19
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +57 -9
- package/dist/server/navigation-trace.d.ts +1 -0
- package/dist/server/navigation-trace.js +1 -0
- package/dist/server/pages-data-route.d.ts +1 -10
- package/dist/server/pages-data-route.js +1 -12
- package/dist/server/pages-node-compat.d.ts +1 -4
- package/dist/server/pages-node-compat.js +1 -7
- package/dist/server/pages-readiness.js +4 -4
- package/dist/server/prerender-route-params.d.ts +1 -2
- package/dist/server/prerender-route-params.js +1 -4
- package/dist/server/prod-server.js +3 -1
- package/dist/shims/cache-runtime.js +39 -22
- package/dist/shims/cache.d.ts +1 -1
- package/dist/shims/dynamic.d.ts +3 -3
- package/dist/shims/dynamic.js +4 -6
- package/dist/shims/error.js +1 -1
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +23 -4
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +6 -7
- package/dist/shims/internal/app-route-prefetch-policy.js +5 -4
- package/dist/shims/link.js +1 -1
- package/dist/shims/navigation.d.ts +12 -3
- package/dist/shims/navigation.js +46 -11
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/router.js +75 -4
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/utils/built-asset-url.d.ts +1 -1
- package/dist/utils/built-asset-url.js +4 -2
- package/dist/utils/package-name.d.ts +11 -0
- package/dist/utils/package-name.js +18 -0
- package/dist/utils/path.d.ts +8 -1
- package/dist/utils/path.js +21 -1
- package/dist/utils/react-compiler-support.d.ts +20 -0
- package/dist/utils/react-compiler-support.js +29 -0
- package/package.json +3 -2
|
@@ -226,8 +226,11 @@ function createAppPageSlotBindings(route, layoutEntries, resolveSlotOverride, op
|
|
|
226
226
|
const slotId = resolveAppPageSlotId(slot, layoutEntry?.treePath ?? "/");
|
|
227
227
|
const state = resolveAppPageSlotBindingState(slot, override);
|
|
228
228
|
const activeRouteId = state === "active" ? options.interception?.slotId === slotId ? options.interception.targetRouteId : AppElementsWire.encodeRouteId(options.routePath, null) : null;
|
|
229
|
+
const isInterceptedSlot = options.interception?.slotId === slotId;
|
|
229
230
|
bindings.push({
|
|
230
231
|
...activeRouteId !== null ? { activeRouteId } : {},
|
|
232
|
+
...isInterceptedSlot && options.interceptionId !== null ? { interceptionId: options.interceptionId } : {},
|
|
233
|
+
...isInterceptedSlot ? { interceptionSourceMatchedUrl: options.interception.sourceMatchedUrl } : {},
|
|
231
234
|
ownerLayoutId,
|
|
232
235
|
slotId,
|
|
233
236
|
state
|
|
@@ -372,6 +375,7 @@ function buildAppPageElements(options) {
|
|
|
372
375
|
const interception = renderIdentity?.interception ?? options.interception ?? null;
|
|
373
376
|
const slotBindings = createAppPageSlotBindings(options.route, layoutEntries, resolveSlotOverride, {
|
|
374
377
|
interception,
|
|
378
|
+
interceptionId: options.interceptionId ?? null,
|
|
375
379
|
routeId,
|
|
376
380
|
routePath: options.routePath
|
|
377
381
|
});
|
|
@@ -2,6 +2,7 @@ import { AppPageParams } from "./app-page-boundary.js";
|
|
|
2
2
|
//#region src/server/app-page-segment-state.d.ts
|
|
3
3
|
declare const APP_PAGE_SEGMENT_KEY = "__PAGE__";
|
|
4
4
|
declare function isAppPageRouteGroupSegment(segment: string): boolean;
|
|
5
|
+
declare function canonicalizeAppPageParams(params: AppPageParams): void;
|
|
5
6
|
declare function resolveAppPageChildSegments(routeSegments: readonly string[], treePosition: number, params: AppPageParams): string[];
|
|
6
7
|
declare function resolveAppPageSegmentStateKey(routeSegments: readonly string[], treePosition: number, params: AppPageParams): string;
|
|
7
8
|
/**
|
|
@@ -20,7 +21,6 @@ type AppPageSemanticSegment = Readonly<{
|
|
|
20
21
|
declare function resolveAppPageSemanticSegmentStateKey(semanticSegment: AppPageSemanticSegment, params: AppPageParams): string;
|
|
21
22
|
declare function resolveAppPageRouteStateKey(routeSegments: readonly string[], params: AppPageParams): string;
|
|
22
23
|
declare function resolveAppPagePatternStateKey(patternParts: readonly string[], params: AppPageParams): string;
|
|
23
|
-
declare function resolveAppPageLeafSegmentStateKey(routeSegments: readonly string[], params: AppPageParams): string;
|
|
24
24
|
declare function resolveAppPageTemplateStateKey(routeSegments: readonly string[], treePosition: number, params: AppPageParams): string;
|
|
25
25
|
//#endregion
|
|
26
|
-
export { APP_PAGE_SEGMENT_KEY, AppPageSemanticSegment, isAppPageRouteGroupSegment, resolveAppPageChildSegments,
|
|
26
|
+
export { APP_PAGE_SEGMENT_KEY, AppPageSemanticSegment, canonicalizeAppPageParams, isAppPageRouteGroupSegment, resolveAppPageChildSegments, resolveAppPagePatternStateKey, resolveAppPageRouteStateKey, resolveAppPageSegmentStateKey, resolveAppPageSemanticSegmentStateKey, resolveAppPageTemplateStateKey };
|
|
@@ -7,6 +7,19 @@ function isDynamicSegment(segment) {
|
|
|
7
7
|
function isAppPageRouteGroupSegment(segment) {
|
|
8
8
|
return segment.startsWith("(") && segment.endsWith(")");
|
|
9
9
|
}
|
|
10
|
+
function canonicalizeAppPageParam(value) {
|
|
11
|
+
try {
|
|
12
|
+
return encodeURIComponent(decodeURIComponent(value));
|
|
13
|
+
} catch {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function canonicalizeAppPageParams(params) {
|
|
18
|
+
for (const key of Object.keys(params)) {
|
|
19
|
+
const value = params[key];
|
|
20
|
+
params[key] = Array.isArray(value) ? value.map(canonicalizeAppPageParam) : canonicalizeAppPageParam(value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
10
23
|
function formatParamSegmentValue(value) {
|
|
11
24
|
if (Array.isArray(value)) return value.join("/");
|
|
12
25
|
return value;
|
|
@@ -85,17 +98,10 @@ function resolveAppPagePatternStateKey(patternParts, params) {
|
|
|
85
98
|
return `[${part.slice(1)}]`;
|
|
86
99
|
}), params);
|
|
87
100
|
}
|
|
88
|
-
function resolveAppPageLeafSegmentStateKey(routeSegments, params) {
|
|
89
|
-
for (let treePosition = routeSegments.length - 1; treePosition >= 0; treePosition--) {
|
|
90
|
-
const segmentStateKey = resolveAppPageSegmentStateKey(routeSegments, treePosition, params);
|
|
91
|
-
if (segmentStateKey) return segmentStateKey;
|
|
92
|
-
}
|
|
93
|
-
return "";
|
|
94
|
-
}
|
|
95
101
|
function resolveAppPageTemplateStateKey(routeSegments, treePosition, params) {
|
|
96
102
|
const end = treePosition < routeSegments.length ? treePosition + 1 : routeSegments.length;
|
|
97
103
|
const statePath = routeSegments.slice(0, end).map((segment) => resolveSingleSegmentStateKey(segment, params));
|
|
98
104
|
return statePath.length > 0 ? JSON.stringify(statePath) : "";
|
|
99
105
|
}
|
|
100
106
|
//#endregion
|
|
101
|
-
export { APP_PAGE_SEGMENT_KEY, isAppPageRouteGroupSegment, resolveAppPageChildSegments,
|
|
107
|
+
export { APP_PAGE_SEGMENT_KEY, canonicalizeAppPageParams, isAppPageRouteGroupSegment, resolveAppPageChildSegments, resolveAppPagePatternStateKey, resolveAppPageRouteStateKey, resolveAppPageSegmentStateKey, resolveAppPageSemanticSegmentStateKey, resolveAppPageTemplateStateKey };
|
|
@@ -21,13 +21,13 @@ type AppPagePprFallbackCacheShell = {
|
|
|
21
21
|
};
|
|
22
22
|
declare function markAppPprDynamicFallbackShellHtml(html: string): string;
|
|
23
23
|
declare function isAppPprDynamicFallbackShellHtml(html: string): boolean;
|
|
24
|
-
declare function createAppPprFallbackShell(route: AppPprFallbackShellRoute, matchedParams: Record<string, string | string[]>): AppPprFallbackShell | null;
|
|
25
24
|
declare function createAppPprFallbackShells(route: AppPprFallbackShellRoute, matchedParams: Record<string, string | string[]>): AppPprFallbackShell[];
|
|
26
25
|
declare function rewriteAppPprFallbackShellHtmlNavigation(options: {
|
|
27
26
|
html: string;
|
|
27
|
+
isForceStatic?: boolean;
|
|
28
28
|
params: Record<string, string | string[]>;
|
|
29
29
|
pathname: string;
|
|
30
30
|
searchParams: URLSearchParams;
|
|
31
31
|
}): string;
|
|
32
32
|
//#endregion
|
|
33
|
-
export { AppPagePprFallbackCacheShell,
|
|
33
|
+
export { AppPagePprFallbackCacheShell, createAppPprFallbackShells, isAppPprDynamicFallbackShellHtml, markAppPprDynamicFallbackShellHtml, rewriteAppPprFallbackShellHtmlNavigation };
|
|
@@ -26,9 +26,6 @@ function pushParamValue(segments, value) {
|
|
|
26
26
|
segments.push(encodeURIComponent(value));
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
29
|
-
function createAppPprFallbackShell(route, matchedParams) {
|
|
30
|
-
return createAppPprFallbackShells(route, matchedParams).at(-1) ?? null;
|
|
31
|
-
}
|
|
32
29
|
function createAppPprFallbackShells(route, matchedParams) {
|
|
33
30
|
const rootParamNames = routeRootParamNames(route);
|
|
34
31
|
if (rootParamNames.size === 0) return [];
|
|
@@ -79,11 +76,11 @@ function createAppPprFallbackShells(route, matchedParams) {
|
|
|
79
76
|
function rewriteAppPprFallbackShellHtmlNavigation(options) {
|
|
80
77
|
const metadataScript = createInlineScriptTag(createNavigationRuntimeRscMetadataScript(options.params, {
|
|
81
78
|
pathname: options.pathname,
|
|
82
|
-
searchParams: [...options.searchParams.entries()]
|
|
83
|
-
}));
|
|
79
|
+
searchParams: options.isForceStatic ? [] : [...options.searchParams.entries()]
|
|
80
|
+
}, void 0, options.isForceStatic !== true));
|
|
84
81
|
const headCloseIndex = options.html.indexOf("</head>");
|
|
85
82
|
if (headCloseIndex !== -1) return options.html.slice(0, headCloseIndex) + metadataScript + options.html.slice(headCloseIndex);
|
|
86
83
|
return metadataScript + options.html;
|
|
87
84
|
}
|
|
88
85
|
//#endregion
|
|
89
|
-
export {
|
|
86
|
+
export { createAppPprFallbackShells, isAppPprDynamicFallbackShellHtml, markAppPprDynamicFallbackShellHtml, rewriteAppPprFallbackShellHtmlNavigation };
|
|
@@ -3,7 +3,7 @@ import { getRequestExecutionContext } from "../shims/request-context.js";
|
|
|
3
3
|
import { reportRequestError } from "./instrumentation.js";
|
|
4
4
|
import { consumeDynamicUsage, getActiveDraftModeState, getAndClearPendingCookies, getDraftModeCookieHeader, isDraftModeRequest, markDynamicUsage, setHeadersAccessPhase } from "../shims/headers.js";
|
|
5
5
|
import { _drainPendingRevalidations } from "../shims/cache-request-state.js";
|
|
6
|
-
import { ensureFetchPatch, getCollectedFetchTags, setCurrentFetchCacheMode, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault } from "../shims/fetch-cache.js";
|
|
6
|
+
import { ensureFetchPatch, getCollectedFetchTags, setCurrentFetchCacheMode, setCurrentFetchRevalidate, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault } from "../shims/fetch-cache.js";
|
|
7
7
|
import { setNavigationContext } from "../shims/navigation-context-state.js";
|
|
8
8
|
import { makeThenableParams } from "../shims/thenable-params.js";
|
|
9
9
|
import { buildPageCacheTags } from "./implicit-tags.js";
|
|
@@ -38,6 +38,7 @@ async function runInRouteHandlerRevalidationContext(options, renderFn) {
|
|
|
38
38
|
ensureFetchPatch();
|
|
39
39
|
setCurrentFetchSoftTags(buildRouteHandlerPageCacheTags(options.cleanPathname, [], options.routeSegments));
|
|
40
40
|
setCurrentFetchCacheMode(options.fetchCacheMode);
|
|
41
|
+
setCurrentFetchRevalidate(options.revalidateSeconds);
|
|
41
42
|
setCurrentForceDynamicFetchDefault(options.dynamicConfig === "force-dynamic");
|
|
42
43
|
try {
|
|
43
44
|
await renderFn();
|
|
@@ -81,6 +82,7 @@ async function dispatchAppRouteHandler(options) {
|
|
|
81
82
|
const resolvedHandlerFn = isAppRouteHandlerFunction(handlerFn) ? handlerFn : void 0;
|
|
82
83
|
const fetchCacheMode = resolveAppRouteHandlerFetchCacheMode(handler);
|
|
83
84
|
setCurrentFetchCacheMode(fetchCacheMode);
|
|
85
|
+
setCurrentFetchRevalidate(revalidateSeconds);
|
|
84
86
|
setCurrentForceDynamicFetchDefault(handler.dynamic === "force-dynamic");
|
|
85
87
|
if (revalidateSeconds !== null && shouldReadAppRouteHandlerCache({
|
|
86
88
|
dynamicConfig: handler.dynamic,
|
|
@@ -125,6 +127,7 @@ async function dispatchAppRouteHandler(options) {
|
|
|
125
127
|
draftModeSecret: options.draftModeSecret,
|
|
126
128
|
dynamicConfig: handler.dynamic,
|
|
127
129
|
fetchCacheMode,
|
|
130
|
+
revalidateSeconds,
|
|
128
131
|
routePattern: route.pattern,
|
|
129
132
|
routeSegments: route.routeSegments
|
|
130
133
|
}, renderFn);
|
|
@@ -4,8 +4,8 @@ import { isDraftModeRequest, setHeadersContext } from "../shims/headers.js";
|
|
|
4
4
|
import { _drainPendingRevalidations } from "../shims/cache-request-state.js";
|
|
5
5
|
import { copyLinkHeaderProvenance } from "./app-response-header-provenance.js";
|
|
6
6
|
import { applyRouteHandlerMiddlewareContext, applyRouteHandlerRevalidateHeader, assertSupportedAppRouteHandlerResponse, buildAppRouteCacheValue, finalizeRouteHandlerResponse, markRouteHandlerCacheMiss } from "./app-route-handler-response.js";
|
|
7
|
-
import { isPossibleAppRouteActionRequest } from "./app-action-request.js";
|
|
8
7
|
import { runWithRootParamsUsage } from "../shims/root-params.js";
|
|
8
|
+
import { isPossibleAppRouteActionRequest } from "./app-action-request.js";
|
|
9
9
|
import { createTrackedAppRouteRequest, markKnownDynamicAppRoute } from "./app-route-handler-runtime.js";
|
|
10
10
|
import { createStaticGenerationHeadersContext, getAppRouteStaticGenerationErrorMessage } from "./app-static-generation.js";
|
|
11
11
|
import { resolveAppRouteHandlerSpecialError, shouldApplyAppRouteHandlerRevalidateHeader, shouldWriteAppRouteHandlerCache } from "./app-route-handler-policy.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
2
1
|
import { VINEXT_RSC_RENDER_MODE_HEADER } from "./headers.js";
|
|
2
|
+
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
3
3
|
import { AppRscStateFingerprintInput } from "./app-rsc-state-fingerprint.js";
|
|
4
4
|
//#region src/server/app-rsc-cache-busting.d.ts
|
|
5
5
|
/**
|
|
@@ -15,6 +15,7 @@ declare const VINEXT_RSC_VARY_HEADER: string;
|
|
|
15
15
|
type CreateRscRequestHeadersOptions = {
|
|
16
16
|
clientReuseManifestHeader?: string | null;
|
|
17
17
|
interceptionContext?: string | null;
|
|
18
|
+
interceptionId?: string | null;
|
|
18
19
|
mountedSlotsHeader?: string | null;
|
|
19
20
|
includePrefetchHeader?: boolean;
|
|
20
21
|
renderMode?: AppRscRenderMode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NEXTJS_DEPLOYMENT_ID_HEADER, NEXT_ROUTER_PREFETCH_HEADER, NEXT_ROUTER_SEGMENT_PREFETCH_HEADER, NEXT_ROUTER_STATE_TREE_HEADER, NEXT_URL_HEADER, VINEXT_CLIENT_REUSE_MANIFEST_HEADER, VINEXT_INTERCEPTION_CONTEXT_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_RSC_RENDER_MODE_HEADER, VINEXT_RSC_STATE_FINGERPRINT_HEADER } from "./headers.js";
|
|
1
|
+
import { NEXTJS_DEPLOYMENT_ID_HEADER, NEXT_ROUTER_PREFETCH_HEADER, NEXT_ROUTER_SEGMENT_PREFETCH_HEADER, NEXT_ROUTER_STATE_TREE_HEADER, NEXT_URL_HEADER, VINEXT_CLIENT_REUSE_MANIFEST_HEADER, VINEXT_INTERCEPTION_CONTEXT_HEADER, VINEXT_INTERCEPTION_ID_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_RSC_RENDER_MODE_HEADER, VINEXT_RSC_STATE_FINGERPRINT_HEADER } from "./headers.js";
|
|
2
2
|
import { fnv1a64 } from "../utils/hash.js";
|
|
3
3
|
import { parseAppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
4
4
|
import { applyDeploymentIdHeader, getDeploymentId } from "../utils/deployment-id.js";
|
|
@@ -20,6 +20,7 @@ const VINEXT_RSC_VARY_HEADER = [
|
|
|
20
20
|
NEXT_ROUTER_SEGMENT_PREFETCH_HEADER,
|
|
21
21
|
NEXT_URL_HEADER,
|
|
22
22
|
VINEXT_INTERCEPTION_CONTEXT_HEADER,
|
|
23
|
+
VINEXT_INTERCEPTION_ID_HEADER,
|
|
23
24
|
VINEXT_MOUNTED_SLOTS_HEADER,
|
|
24
25
|
VINEXT_RSC_RENDER_MODE_HEADER,
|
|
25
26
|
VINEXT_RSC_STATE_FINGERPRINT_HEADER
|
|
@@ -84,6 +85,7 @@ function createCacheBustingInput(headers, options = {}) {
|
|
|
84
85
|
headers.get(NEXT_ROUTER_STATE_TREE_HEADER),
|
|
85
86
|
headers.get(NEXT_URL_HEADER),
|
|
86
87
|
headers.get(VINEXT_INTERCEPTION_CONTEXT_HEADER),
|
|
88
|
+
...options.includeInterceptionIdHeader === false ? [] : [headers.get(VINEXT_INTERCEPTION_ID_HEADER)],
|
|
87
89
|
headers.get(VINEXT_MOUNTED_SLOTS_HEADER),
|
|
88
90
|
...options.includeRenderModeHeader === false ? [] : [normalizeRenderModeHeaderValue(headers.get(VINEXT_RSC_RENDER_MODE_HEADER))]
|
|
89
91
|
];
|
|
@@ -93,7 +95,9 @@ function createCacheBustingInput(headers, options = {}) {
|
|
|
93
95
|
return values.map(normalizeHeaderValue).join(",");
|
|
94
96
|
}
|
|
95
97
|
async function sha256CacheBustingHash(input) {
|
|
96
|
-
const
|
|
98
|
+
const subtle = globalThis.crypto?.subtle;
|
|
99
|
+
if (!subtle) return fnv1a64(input);
|
|
100
|
+
const digest = await subtle.digest("SHA-256", textEncoder.encode(input));
|
|
97
101
|
return encodeBase64Url(new Uint8Array(digest).subarray(0, CACHE_BUSTING_DIGEST_BYTES));
|
|
98
102
|
}
|
|
99
103
|
function computeLegacyRscCacheBustingSearchParam(headers) {
|
|
@@ -158,6 +162,7 @@ function createRscRequestHeaders(options = {}) {
|
|
|
158
162
|
if (options.nextUrl) headers.set(NEXT_URL_HEADER, options.nextUrl);
|
|
159
163
|
if (process.env.__NEXT_TEST_MODE && options.fetchPriority) headers.set("Next-Test-Fetch-Priority", options.fetchPriority);
|
|
160
164
|
if (options.interceptionContext !== void 0 && options.interceptionContext !== null) headers.set(VINEXT_INTERCEPTION_CONTEXT_HEADER, options.interceptionContext);
|
|
165
|
+
if (options.interceptionId !== void 0 && options.interceptionId !== null) headers.set(VINEXT_INTERCEPTION_ID_HEADER, options.interceptionId);
|
|
161
166
|
if (options.mountedSlotsHeader !== void 0 && options.mountedSlotsHeader !== null) headers.set(VINEXT_MOUNTED_SLOTS_HEADER, options.mountedSlotsHeader);
|
|
162
167
|
if (options.clientReuseManifestHeader !== void 0 && options.clientReuseManifestHeader !== null) headers.set(VINEXT_CLIENT_REUSE_MANIFEST_HEADER, options.clientReuseManifestHeader);
|
|
163
168
|
const renderMode = options.renderMode ?? "navigation";
|
|
@@ -196,14 +201,35 @@ async function resolveInvalidRscCacheBustingRequest(options) {
|
|
|
196
201
|
if (actualHash !== null && actualHash !== expectedHash) {
|
|
197
202
|
acceptedHashes.add(computeLegacyRscCacheBustingSearchParam(options.request.headers));
|
|
198
203
|
const compatibilityInputs = [];
|
|
204
|
+
const hasInterceptionId = options.request.headers.has(VINEXT_INTERCEPTION_ID_HEADER);
|
|
199
205
|
const hasStateFingerprint = options.request.headers.has(VINEXT_RSC_STATE_FINGERPRINT_HEADER);
|
|
200
206
|
const hasNormalRenderMode = normalizeRenderModeHeaderValue(options.request.headers.get(VINEXT_RSC_RENDER_MODE_HEADER)) === null;
|
|
201
|
-
if (
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
+
if (!hasInterceptionId) compatibilityInputs.push({ includeInterceptionIdHeader: false });
|
|
208
|
+
if (hasStateFingerprint) {
|
|
209
|
+
compatibilityInputs.push({ includeStateFingerprintHeader: false });
|
|
210
|
+
if (!hasInterceptionId) compatibilityInputs.push({
|
|
211
|
+
includeInterceptionIdHeader: false,
|
|
212
|
+
includeStateFingerprintHeader: false
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
if (hasNormalRenderMode) {
|
|
216
|
+
compatibilityInputs.push({ includeRenderModeHeader: false });
|
|
217
|
+
if (!hasInterceptionId) compatibilityInputs.push({
|
|
218
|
+
includeInterceptionIdHeader: false,
|
|
219
|
+
includeRenderModeHeader: false
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
if (hasStateFingerprint && hasNormalRenderMode) {
|
|
223
|
+
compatibilityInputs.push({
|
|
224
|
+
includeRenderModeHeader: false,
|
|
225
|
+
includeStateFingerprintHeader: false
|
|
226
|
+
});
|
|
227
|
+
if (!hasInterceptionId) compatibilityInputs.push({
|
|
228
|
+
includeInterceptionIdHeader: false,
|
|
229
|
+
includeRenderModeHeader: false,
|
|
230
|
+
includeStateFingerprintHeader: false
|
|
231
|
+
});
|
|
232
|
+
}
|
|
207
233
|
for (const compatibilityOptions of compatibilityInputs) {
|
|
208
234
|
const input = createCacheBustingInput(options.request.headers, compatibilityOptions);
|
|
209
235
|
if (input === null) acceptedHashes.add("");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NextHeader, NextI18nConfig, NextRedirect, NextRewrite } from "../config/next-config.js";
|
|
2
2
|
import { ImageConfig } from "./image-optimization.js";
|
|
3
|
+
import { AppMiddlewareContext, ApplyAppMiddlewareResult } from "./app-middleware.js";
|
|
3
4
|
import { ClientReuseManifestParseResult } from "./client-reuse-manifest.js";
|
|
4
5
|
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
5
6
|
import { RootParams } from "../shims/root-params.js";
|
|
6
|
-
import { AppMiddlewareContext, ApplyAppMiddlewareResult } from "./app-middleware.js";
|
|
7
7
|
import { AppPagePprFallbackCacheShell } from "./app-ppr-fallback-shell.js";
|
|
8
8
|
import { AppPrerenderRootParamNamesMap, AppPrerenderStaticParamsMap } from "./app-prerender-endpoints.js";
|
|
9
9
|
import { AppRouteTreePrefetchRoute, PrefetchInliningConfig } from "./app-route-tree-prefetch.js";
|
|
@@ -50,6 +50,7 @@ type DispatchMatchedPageOptions<TRoute> = {
|
|
|
50
50
|
actionFailed?: boolean;
|
|
51
51
|
handlerStart: number;
|
|
52
52
|
interceptionContext: string | null;
|
|
53
|
+
interceptionId: string | null;
|
|
53
54
|
interceptionPathname: string;
|
|
54
55
|
isProgressiveActionRender: boolean;
|
|
55
56
|
isRscRequest: boolean;
|
|
@@ -202,8 +203,9 @@ type CreateAppRscHandlerOptions<TRoute extends AppRscHandlerRoute> = {
|
|
|
202
203
|
i18nConfig: NextI18nConfig | null;
|
|
203
204
|
imageConfig?: ImageConfig;
|
|
204
205
|
isDev: boolean;
|
|
206
|
+
hasInterceptionId: (interceptionId: string) => boolean;
|
|
205
207
|
loadPrerenderPagesRoutes?: () => Promise<unknown>;
|
|
206
|
-
matchInterceptRoute?: (pathname: string, sourcePathname: string) => AppRscRouteMatch<TRoute> | null;
|
|
208
|
+
matchInterceptRoute?: (pathname: string, sourcePathname: string, interceptionId?: string | null) => AppRscRouteMatch<TRoute> | null;
|
|
207
209
|
matchRoute: (pathname: string) => AppRscRouteMatch<TRoute> | null;
|
|
208
210
|
matchRequestRoute?: (pathname: string) => AppRscRouteMatch<TRoute> | null;
|
|
209
211
|
runMiddleware?: (options: RunAppMiddlewareOptions) => Promise<ApplyAppMiddlewareResult>;
|
|
@@ -10,6 +10,7 @@ import { isExternalUrl } from "../utils/external-url.js";
|
|
|
10
10
|
import { badRequestResponse, notFoundResponse } from "./http-error-responses.js";
|
|
11
11
|
import { cloneRequestWithHeaders, cloneRequestWithUrl, filterInternalHeaders, normalizeTrailingSlash, resolvePublicFileRoute } from "./request-pipeline.js";
|
|
12
12
|
import { normalizeDefaultLocalePathname } from "./pages-i18n.js";
|
|
13
|
+
import { NEVER_CACHE_CONTROL, applyCdnResponseHeaders } from "./cache-control.js";
|
|
13
14
|
import { isOnDemandRevalidateRequest } from "./isr-cache.js";
|
|
14
15
|
import { getHeadersContext, headersContextFromRequest, runWithHeadersContext } from "../shims/headers.js";
|
|
15
16
|
import { ensureFetchPatch, setCurrentFetchSoftTags } from "../shims/fetch-cache.js";
|
|
@@ -24,11 +25,11 @@ import { parseNextHttpErrorDigest } from "./next-error-digest.js";
|
|
|
24
25
|
import { matchPrerenderRouteParamsPayload, readTrustedPrerenderRouteParams, serializePrerenderRouteParamsHeader } from "./prerender-route-params.js";
|
|
25
26
|
import { buildPageCacheTags } from "./implicit-tags.js";
|
|
26
27
|
import { getRenderedConcreteUrlPathsForRoute } from "./pregenerated-concrete-paths.js";
|
|
28
|
+
import { pickRootParams, setRootParams } from "../shims/root-params.js";
|
|
29
|
+
import { flattenErrorCauses } from "../utils/error-cause.js";
|
|
27
30
|
import { createServerActionNotFoundResponse, getServerActionNotFoundMessage } from "./server-action-not-found.js";
|
|
28
31
|
import { buildPostMwRequestContext } from "./app-post-middleware-context.js";
|
|
29
|
-
import { pickRootParams, setRootParams } from "../shims/root-params.js";
|
|
30
32
|
import { createRouteTreePrefetchResponse, isRouteTreePrefetchRequest } from "./app-route-tree-prefetch.js";
|
|
31
|
-
import { flattenErrorCauses } from "../utils/error-cause.js";
|
|
32
33
|
import { applyAppRscConfigHeaders, finalizeAppRscResponse } from "./app-rsc-response-finalizer.js";
|
|
33
34
|
import { normalizeRscRequest } from "./app-rsc-request-normalization.js";
|
|
34
35
|
import { runWithPrerenderWorkUnit } from "./prerender-work-unit-setup.js";
|
|
@@ -76,6 +77,9 @@ function isExecutionContextLike(value) {
|
|
|
76
77
|
if (!value || typeof value !== "object") return false;
|
|
77
78
|
return hasProperty(value, "waitUntil") && typeof value.waitUntil === "function";
|
|
78
79
|
}
|
|
80
|
+
function isForwardedActionContext(value) {
|
|
81
|
+
return value !== null && typeof value === "object" && hasProperty(value, "actionForwarded") && value.actionForwarded === true;
|
|
82
|
+
}
|
|
79
83
|
function createMissingServerActionResponse(options, actionId) {
|
|
80
84
|
console.warn(getServerActionNotFoundMessage(actionId));
|
|
81
85
|
options.clearRequestContext();
|
|
@@ -144,7 +148,25 @@ function requestWithoutRscSuffix(request) {
|
|
|
144
148
|
url.pathname = pathname;
|
|
145
149
|
return cloneRequestWithUrl(request, url.toString());
|
|
146
150
|
}
|
|
147
|
-
|
|
151
|
+
function markInvalidInterceptionIdResponseUncacheable(response) {
|
|
152
|
+
const applyNoStore = (headers) => {
|
|
153
|
+
applyCdnResponseHeaders(headers, { cacheControl: NEVER_CACHE_CONTROL });
|
|
154
|
+
};
|
|
155
|
+
let markedResponse = response;
|
|
156
|
+
try {
|
|
157
|
+
applyNoStore(markedResponse.headers);
|
|
158
|
+
} catch {
|
|
159
|
+
const headers = new Headers(response.headers);
|
|
160
|
+
applyNoStore(headers);
|
|
161
|
+
markedResponse = new Response(response.body, {
|
|
162
|
+
headers,
|
|
163
|
+
status: response.status,
|
|
164
|
+
statusText: response.statusText
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return markedResponse;
|
|
168
|
+
}
|
|
169
|
+
async function handleAppRscRequest(options, request, preMiddlewareRequestContext, middlewareContext, isDataRequest, isMiddlewareDataRequest, pagesDataRequest, dispatchInternalRequest, allowInternalRscDocumentFallback, markInterceptionIdRejected) {
|
|
148
170
|
const handlerStart = process.env.NODE_ENV !== "production" ? performance.now() : 0;
|
|
149
171
|
if (process.env.NODE_ENV !== "production") {
|
|
150
172
|
const originBlock = options.validateDevRequestOrigin?.(request);
|
|
@@ -158,8 +180,11 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
158
180
|
...options.configHeaders
|
|
159
181
|
].some((rule) => rule.basePath === false);
|
|
160
182
|
const normalized = normalizeRscRequest(request, options.basePath, canHandleOutsideBasePath);
|
|
161
|
-
if (normalized instanceof Response)
|
|
162
|
-
|
|
183
|
+
if (normalized instanceof Response) {
|
|
184
|
+
if (request.headers.has("X-Vinext-Interception-Id")) markInterceptionIdRejected();
|
|
185
|
+
return normalized;
|
|
186
|
+
}
|
|
187
|
+
const { url, isRscRequest, interceptionContextHeader, interceptionIdHeader, mountedSlotsHeader, renderMode, clientReuseManifest, hadBasePath } = normalized;
|
|
163
188
|
const { requestCleanPathname } = normalized;
|
|
164
189
|
let { pathname, cleanPathname } = normalized;
|
|
165
190
|
let resolvedUrl = cleanPathname + url.search;
|
|
@@ -172,6 +197,17 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
172
197
|
};
|
|
173
198
|
let cleanPathnameIsRequestPathname = true;
|
|
174
199
|
const matchCleanPathname = () => cleanPathnameIsRequestPathname && options.matchRequestRoute ? options.matchRequestRoute(requestCleanPathname) : options.matchRoute(cleanPathname);
|
|
200
|
+
if (interceptionIdHeader !== null && (!isRscRequest || interceptionContextHeader === null || !options.hasInterceptionId(interceptionIdHeader))) {
|
|
201
|
+
markInterceptionIdRejected();
|
|
202
|
+
return badRequestResponse();
|
|
203
|
+
}
|
|
204
|
+
if (interceptionIdHeader !== null) {
|
|
205
|
+
const selectorCacheBustingRedirect = await resolveInvalidRscCacheBustingRequest({
|
|
206
|
+
isRscRequest,
|
|
207
|
+
request
|
|
208
|
+
});
|
|
209
|
+
if (selectorCacheBustingRedirect) return selectorCacheBustingRedirect;
|
|
210
|
+
}
|
|
175
211
|
if (pathname === "/__vinext/prerender/static-params" || pathname === "/__vinext/prerender/pages-static-paths" || pathname === "/__vinext/prerender/metadata-routes") {
|
|
176
212
|
const { handleAppPrerenderEndpoint } = await import("./app-prerender-endpoints.js");
|
|
177
213
|
const prerenderEndpointResponse = await handleAppPrerenderEndpoint(request, {
|
|
@@ -200,7 +236,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
200
236
|
headers: { Location: location }
|
|
201
237
|
});
|
|
202
238
|
}
|
|
203
|
-
const rscCacheBustingRedirect = hadBasePath ? await resolveInvalidRscCacheBustingRequest({
|
|
239
|
+
const rscCacheBustingRedirect = hadBasePath && interceptionIdHeader === null ? await resolveInvalidRscCacheBustingRequest({
|
|
204
240
|
isRscRequest,
|
|
205
241
|
request
|
|
206
242
|
}) : null;
|
|
@@ -366,9 +402,15 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
366
402
|
interceptionSourcePathname = normalizePath(normalizePathnameForRouteMatchStrict(interceptionContextHeader));
|
|
367
403
|
} catch {
|
|
368
404
|
options.clearRequestContext();
|
|
405
|
+
if (interceptionIdHeader !== null) markInterceptionIdRejected();
|
|
406
|
+
return badRequestResponse();
|
|
407
|
+
}
|
|
408
|
+
const interceptionSourceMatch = interceptionSourcePathname !== null && interceptionContextHeader !== null ? options.matchInterceptRoute?.(preActionRoutePathname, interceptionContextHeader, interceptionIdHeader) ?? null : null;
|
|
409
|
+
if (interceptionIdHeader !== null && interceptionSourceMatch === null) {
|
|
410
|
+
options.clearRequestContext();
|
|
411
|
+
markInterceptionIdRejected();
|
|
369
412
|
return badRequestResponse();
|
|
370
413
|
}
|
|
371
|
-
const interceptionSourceMatch = interceptionSourcePathname !== null && interceptionContextHeader !== null ? options.matchInterceptRoute?.(preActionRoutePathname, interceptionContextHeader) ?? null : null;
|
|
372
414
|
if (interceptionSourceMatch !== null && interceptionSourcePathname !== null && runMiddleware && interceptionSourceMatch.route !== directPreActionMatch?.route) {
|
|
373
415
|
const sourceUrl = new URL(userlandRequest.url);
|
|
374
416
|
sourceUrl.search = new URL(resolvedUrl, url).search;
|
|
@@ -693,6 +735,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
693
735
|
actionFailed,
|
|
694
736
|
handlerStart,
|
|
695
737
|
interceptionContext: interceptionContextHeader,
|
|
738
|
+
interceptionId: interceptionIdHeader,
|
|
696
739
|
interceptionPathname: cleanPathnameIsRequestPathname ? requestCleanPathname : cleanPathname,
|
|
697
740
|
isProgressiveActionRender,
|
|
698
741
|
isRscRequest,
|
|
@@ -767,6 +810,7 @@ function createAppRscHandler(options) {
|
|
|
767
810
|
const isTrustedSpeculativePrerender = process.env.VINEXT_PRERENDER === "1" && rawRequest.headers.get("x-vinext-prerender-secret") !== null && rawRequest.headers.get("x-vinext-prerender-speculative") === "1";
|
|
768
811
|
const filteredHeaders = executionContext?.isInternalPagesRevalidation ? new Headers(rawRequest.headers) : filterInternalHeaders(rawRequest.headers);
|
|
769
812
|
filteredHeaders.delete(VINEXT_REVALIDATE_HOST_HEADER);
|
|
813
|
+
if (isForwardedActionContext(ctx)) filteredHeaders.set("x-action-forwarded", "1");
|
|
770
814
|
if (mwCtx !== null) filteredHeaders.set(VINEXT_MW_CTX_HEADER, mwCtx);
|
|
771
815
|
const prerenderRouteParamsHeader = serializePrerenderRouteParamsHeader(prerenderRouteParamsPayload);
|
|
772
816
|
if (prerenderRouteParamsHeader !== null) filteredHeaders.set(VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, prerenderRouteParamsHeader);
|
|
@@ -784,6 +828,7 @@ function createAppRscHandler(options) {
|
|
|
784
828
|
executionContext,
|
|
785
829
|
unstableCacheRevalidation: "background"
|
|
786
830
|
});
|
|
831
|
+
let interceptionIdRejected = false;
|
|
787
832
|
const responsePromise = runWithRequestContext(requestContext, () => runWithPrerenderWorkUnit(async () => {
|
|
788
833
|
ensureFetchPatch();
|
|
789
834
|
const preMiddlewareRequestContext = requestContextFromRequest(request);
|
|
@@ -794,18 +839,21 @@ function createAppRscHandler(options) {
|
|
|
794
839
|
};
|
|
795
840
|
let response;
|
|
796
841
|
try {
|
|
797
|
-
response = await handleAppRscRequest(options, request, preMiddlewareRequestContext, middlewareContext, isPagesDataRequest, isPagesDataRequest, pagesDataRequest, (internalRequest) => appRscHandler(internalRequest, ctx, true), allowInternalRscDocumentFallback)
|
|
842
|
+
response = await handleAppRscRequest(options, request, preMiddlewareRequestContext, middlewareContext, isPagesDataRequest, isPagesDataRequest, pagesDataRequest, (internalRequest) => appRscHandler(internalRequest, ctx, true), allowInternalRscDocumentFallback, () => {
|
|
843
|
+
interceptionIdRejected = true;
|
|
844
|
+
});
|
|
798
845
|
} catch (error) {
|
|
799
846
|
if (process.env.NODE_ENV !== "production") flattenErrorCauses(error);
|
|
800
847
|
throw error;
|
|
801
848
|
}
|
|
802
|
-
|
|
849
|
+
response = await finalizeAppRscResponse(response, request, {
|
|
803
850
|
basePath: options.basePath,
|
|
804
851
|
configHeaders: options.configHeaders,
|
|
805
852
|
i18nConfig: options.i18nConfig,
|
|
806
853
|
middlewareHeaders: middlewareContext.headers,
|
|
807
854
|
requestContext: preMiddlewareRequestContext
|
|
808
855
|
});
|
|
856
|
+
return interceptionIdRejected ? markInvalidInterceptionIdResponseUncacheable(response) : response;
|
|
809
857
|
}, { route: () => new URL(request.url).pathname }));
|
|
810
858
|
let response;
|
|
811
859
|
try {
|
|
@@ -15,6 +15,8 @@ type NormalizedRscRequest = {
|
|
|
15
15
|
isRscRequest: boolean;
|
|
16
16
|
/** Sanitized X-Vinext-Interception-Context header (null bytes stripped). null when absent. */
|
|
17
17
|
interceptionContextHeader: string | null;
|
|
18
|
+
/** Exact graph-owned interception identity for supplemental slot refreshes. */
|
|
19
|
+
interceptionIdHeader: string | null;
|
|
18
20
|
/** Normalized x-vinext-mounted-slots header (deduplicated, sorted). null when absent or blank. */
|
|
19
21
|
mountedSlotsHeader: string | null;
|
|
20
22
|
/** Semantic RSC payload mode. HTML requests always normalize to "navigation". */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { normalizePathnameForRouteMatchStrict } from "../routing/utils.js";
|
|
2
2
|
import { hasBasePath, stripBasePath } from "../utils/base-path.js";
|
|
3
|
-
import { NEXT_ROUTER_STATE_TREE_HEADER, NEXT_URL_HEADER, VINEXT_CLIENT_REUSE_MANIFEST_HEADER, VINEXT_INTERCEPTION_CONTEXT_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_RSC_RENDER_MODE_HEADER } from "./headers.js";
|
|
3
|
+
import { NEXT_ROUTER_STATE_TREE_HEADER, NEXT_URL_HEADER, VINEXT_CLIENT_REUSE_MANIFEST_HEADER, VINEXT_INTERCEPTION_CONTEXT_HEADER, VINEXT_INTERCEPTION_ID_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_RSC_RENDER_MODE_HEADER } from "./headers.js";
|
|
4
4
|
import { normalizePath } from "./normalize-path.js";
|
|
5
5
|
import { badRequestResponse, notFoundResponse } from "./http-error-responses.js";
|
|
6
6
|
import { guardProtocolRelativeUrl } from "./request-pipeline.js";
|
|
@@ -112,6 +112,9 @@ function normalizeRscRequest(request, basePath, allowOutsideBasePath = false) {
|
|
|
112
112
|
const cleanPathname = stripRscSuffix(pathname);
|
|
113
113
|
const requestCleanPathname = stripRscSuffix(requestPathname);
|
|
114
114
|
const interceptionContextHeader = normalizeInterceptionContextHeader(request.headers.get(VINEXT_INTERCEPTION_CONTEXT_HEADER));
|
|
115
|
+
const rawInterceptionId = request.headers.get(VINEXT_INTERCEPTION_ID_HEADER);
|
|
116
|
+
if (rawInterceptionId !== null && (rawInterceptionId.length > 4096 || !rawInterceptionId.startsWith("interception:"))) return badRequestResponse();
|
|
117
|
+
const interceptionIdHeader = rawInterceptionId;
|
|
115
118
|
const mountedSlotsHeader = normalizeMountedSlotsHeader(request.headers.get(VINEXT_MOUNTED_SLOTS_HEADER));
|
|
116
119
|
let renderMode = isRscRequest ? parseAppRscRenderMode(request.headers.get(VINEXT_RSC_RENDER_MODE_HEADER)) : APP_RSC_RENDER_MODE_NAVIGATION;
|
|
117
120
|
if (isRscRequest && renderMode === "navigation" && request.headers.get("Next-Router-Prefetch") === "1" && request.headers.get("Next-Router-Segment-Prefetch") === null) {
|
|
@@ -136,6 +139,7 @@ function normalizeRscRequest(request, basePath, allowOutsideBasePath = false) {
|
|
|
136
139
|
requestCleanPathname,
|
|
137
140
|
isRscRequest,
|
|
138
141
|
interceptionContextHeader,
|
|
142
|
+
interceptionIdHeader,
|
|
139
143
|
mountedSlotsHeader,
|
|
140
144
|
renderMode
|
|
141
145
|
};
|
|
@@ -92,6 +92,7 @@ type AppRscInterceptLoadState = {
|
|
|
92
92
|
interceptLayoutsLoading: Promise<readonly unknown[]> | null;
|
|
93
93
|
};
|
|
94
94
|
type AppRscInterceptLookupEntry = {
|
|
95
|
+
interceptionId: string | null;
|
|
95
96
|
interceptionGraphId: string | null;
|
|
96
97
|
sourceRouteIndex: number;
|
|
97
98
|
slotKey: string;
|
|
@@ -119,6 +120,7 @@ type AppRscInterceptLookupEntry = {
|
|
|
119
120
|
targetRouteGraphId: string | null;
|
|
120
121
|
};
|
|
121
122
|
declare function createAppRscRouteMatcher<Route extends AppRscRouteForMatching>(routes: Route[]): {
|
|
123
|
+
hasInterceptionId(interceptionId: string): boolean;
|
|
122
124
|
matchRoute(url: string): {
|
|
123
125
|
route: Route;
|
|
124
126
|
params: AppRscRouteParams;
|
|
@@ -127,8 +129,7 @@ declare function createAppRscRouteMatcher<Route extends AppRscRouteForMatching>(
|
|
|
127
129
|
route: Route;
|
|
128
130
|
params: AppRscRouteParams;
|
|
129
131
|
} | null;
|
|
130
|
-
findIntercept(pathname: string, sourcePathname?: string | null): AppRscInterceptMatch | null;
|
|
132
|
+
findIntercept(pathname: string, sourcePathname?: string | null, interceptionId?: string | null): AppRscInterceptMatch | null;
|
|
131
133
|
};
|
|
132
|
-
declare function matchAppRscRoutePattern(urlParts: string[], patternParts: string[]): AppRscRouteParams | null;
|
|
133
134
|
//#endregion
|
|
134
|
-
export { SIBLING_PAGE_INTERCEPT_SLOT_KEY, createAppRscRouteMatcher
|
|
135
|
+
export { SIBLING_PAGE_INTERCEPT_SLOT_KEY, createAppRscRouteMatcher };
|