Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/vinext/src/entries/app-rsc-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const appPageBoundaryRenderPath = resolveEntryPath(
"../server/app-page-boundary-render.js",
import.meta.url,
);
const appElementsPath = resolveEntryPath("../server/app-elements.js", import.meta.url);
const appPageRouteWiringPath = resolveEntryPath(
"../server/app-page-route-wiring.js",
import.meta.url,
Expand Down Expand Up @@ -385,6 +386,10 @@ import {
renderAppPageErrorBoundary as __renderAppPageErrorBoundary,
renderAppPageHttpAccessFallback as __renderAppPageHttpAccessFallback,
} from ${JSON.stringify(appPageBoundaryRenderPath)};
import {
APP_INTERCEPTION_CONTEXT_KEY as __APP_INTERCEPTION_CONTEXT_KEY,
createAppPayloadRouteId as __createAppPayloadRouteId,
} from ${JSON.stringify(appElementsPath)};
import {
buildAppPageElements as __buildAppPageElements,
createAppPageTreePath as __createAppPageTreePath,
Expand Down Expand Up @@ -928,7 +933,8 @@ function findIntercept(pathname) {
async function buildPageElements(route, params, routePath, opts, searchParams, isRscRequest, request) {
const PageComponent = route.page?.default;
if (!PageComponent) {
const _noExportRouteId = "route:" + routePath;
const _interceptionContext = opts?.interceptionContext ?? null;
const _noExportRouteId = __createAppPayloadRouteId(routePath, _interceptionContext);
let _noExportRootLayout = null;
if (route.layouts?.length > 0) {
// Compute the root layout tree path for this error payload using the
Expand All @@ -937,6 +943,7 @@ async function buildPageElements(route, params, routePath, opts, searchParams, i
_noExportRootLayout = __createAppPageTreePath(route.routeSegments, _tp);
}
return {
[__APP_INTERCEPTION_CONTEXT_KEY]: _interceptionContext,
__route: _noExportRouteId,
__rootLayout: _noExportRootLayout,
[_noExportRouteId]: createElement("div", null, "Page has no default export"),
Expand Down Expand Up @@ -1056,6 +1063,7 @@ async function buildPageElements(route, params, routePath, opts, searchParams, i
matchedParams: params,
resolvedMetadata,
resolvedViewport,
interceptionContext: opts?.interceptionContext ?? null,
routePath,
rootNotFoundModule: ${rootNotFoundVar ? rootNotFoundVar : "null"},
route,
Expand Down Expand Up @@ -1399,6 +1407,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
}

const isRscRequest = pathname.endsWith(".rsc") || request.headers.get("accept")?.includes("text/x-component");
const interceptionContextHeader = request.headers.get("X-Vinext-Interception-Context");
let cleanPathname = pathname.replace(/\\.rsc$/, "");

// Middleware response headers and custom rewrite status are stored in
Expand Down Expand Up @@ -1807,8 +1816,9 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
request,
);
} else {
const _actionRouteId = "route:" + cleanPathname;
const _actionRouteId = __createAppPayloadRouteId(cleanPathname, null);
element = {
[__APP_INTERCEPTION_CONTEXT_KEY]: null,
__route: _actionRouteId,
__rootLayout: null,
[_actionRouteId]: createElement("div", null, "Page not found"),
Expand Down Expand Up @@ -2285,6 +2295,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
setNavigationContext,
toInterceptOpts(intercept) {
return {
interceptionContext: interceptionContextHeader,
interceptSlotKey: intercept.slotKey,
interceptPage: intercept.page,
interceptParams: intercept.matchedParams,
Expand Down
1 change: 1 addition & 0 deletions packages/vinext/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ declare global {
redirectDepth?: number,
navigationKind?: "navigate" | "traverse" | "refresh",
historyUpdateMode?: "push" | "replace",
previousNextUrlOverride?: string | null,
) => Promise<void>)
| undefined;

Expand Down
Loading
Loading