vinext 0.1.8 → 0.2.0
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 +51 -30
- package/dist/build/inject-pregenerated-paths.d.ts +4 -0
- package/dist/build/inject-pregenerated-paths.js +18 -0
- package/dist/build/layout-classification.js +1 -1
- package/dist/build/nitro-route-rules.js +1 -1
- package/dist/build/pages-client-assets-module.d.ts +11 -0
- package/dist/build/pages-client-assets-module.js +27 -0
- package/dist/build/prerender.d.ts +2 -1
- package/dist/build/prerender.js +13 -6
- package/dist/build/report.d.ts +13 -2
- package/dist/build/report.js +99 -2
- package/dist/build/run-prerender.d.ts +7 -0
- package/dist/build/run-prerender.js +10 -1
- package/dist/build/standalone.js +2 -0
- package/dist/cache/cache-adapters-virtual.js +3 -3
- package/dist/check.js +40 -2
- package/dist/cli-args.d.ts +1 -2
- package/dist/cli-args.js +1 -1
- package/dist/cli-dev-config.d.ts +12 -0
- package/dist/cli-dev-config.js +23 -0
- package/dist/cli.js +111 -95
- package/dist/{server → client}/dev-error-overlay-store.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay-store.js +1 -1
- package/dist/{server → client}/dev-error-overlay.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay.js +2 -2
- package/dist/client/navigation-runtime.d.ts +2 -0
- package/dist/client/navigation-runtime.js +3 -1
- package/dist/client/window-next.d.ts +2 -1
- package/dist/cloudflare/index.d.ts +2 -2
- package/dist/cloudflare/index.js +2 -2
- package/dist/config/config-matchers.js +14 -10
- package/dist/config/next-config.d.ts +5 -3
- package/dist/config/next-config.js +44 -1
- package/dist/config/prerender.d.ts +34 -0
- package/dist/config/prerender.js +55 -0
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +40 -10
- package/dist/entries/app-rsc-manifest.js +2 -0
- package/dist/entries/pages-client-entry.d.ts +3 -0
- package/dist/entries/pages-client-entry.js +15 -1
- package/dist/entries/pages-server-entry.js +5 -2
- package/dist/image/image-adapters-virtual.d.ts +59 -0
- package/dist/image/image-adapters-virtual.js +59 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +167 -100
- package/dist/init-cloudflare.d.ts +43 -0
- package/dist/init-cloudflare.js +839 -0
- package/dist/init-platform.d.ts +40 -0
- package/dist/init-platform.js +195 -0
- package/dist/init.d.ts +16 -38
- package/dist/init.js +209 -99
- package/dist/node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.js +294 -0
- package/dist/node_modules/.pnpm/process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js +94 -0
- package/dist/{cloudflare → packages/cloudflare}/src/cache/cdn-adapter.runtime.js +1 -1
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.d.ts +2 -2
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.js +1 -1
- package/dist/packages/cloudflare/src/deploy-config.js +150 -0
- package/dist/packages/cloudflare/src/deploy-help.js +55 -0
- package/dist/packages/cloudflare/src/deploy.js +276 -0
- package/dist/{cloudflare → packages/cloudflare/src}/tpr.d.ts +4 -41
- package/dist/{cloudflare → packages/cloudflare/src}/tpr.js +18 -15
- package/dist/plugins/ast-scope.d.ts +16 -0
- package/dist/plugins/ast-scope.js +62 -0
- package/dist/plugins/ast-utils.d.ts +27 -1
- package/dist/plugins/ast-utils.js +32 -1
- package/dist/plugins/css-module-imports.d.ts +14 -0
- package/dist/plugins/css-module-imports.js +59 -0
- package/dist/plugins/extensionless-dynamic-import.js +2 -2
- package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
- package/dist/plugins/ignore-dynamic-requests.js +530 -0
- package/dist/plugins/typeof-window.d.ts +1 -1
- package/dist/plugins/typeof-window.js +28 -56
- package/dist/routing/app-route-graph.d.ts +23 -2
- package/dist/routing/app-route-graph.js +126 -32
- package/dist/routing/file-matcher.d.ts +3 -0
- package/dist/routing/file-matcher.js +3 -0
- package/dist/routing/pages-router.js +2 -2
- package/dist/server/api-handler.js +9 -14
- package/dist/server/app-browser-action-result.d.ts +4 -1
- package/dist/server/app-browser-action-result.js +8 -1
- package/dist/server/app-browser-entry.js +161 -52
- package/dist/server/app-browser-interception-context.d.ts +1 -0
- package/dist/server/app-browser-interception-context.js +4 -2
- package/dist/server/app-browser-navigation-controller.d.ts +2 -0
- package/dist/server/app-browser-navigation-controller.js +60 -31
- package/dist/server/app-browser-server-action-client.d.ts +1 -1
- package/dist/server/app-browser-server-action-client.js +3 -4
- package/dist/server/app-browser-state.d.ts +11 -1
- package/dist/server/app-browser-state.js +25 -8
- package/dist/server/app-browser-visible-commit.d.ts +6 -1
- package/dist/server/app-browser-visible-commit.js +43 -25
- package/dist/server/app-elements-wire.d.ts +9 -2
- package/dist/server/app-elements-wire.js +8 -1
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +4 -3
- package/dist/server/app-fallback-renderer.d.ts +2 -1
- package/dist/server/app-fallback-renderer.js +10 -6
- package/dist/server/app-hydration-cache-publication.d.ts +11 -0
- package/dist/server/app-hydration-cache-publication.js +43 -0
- package/dist/server/app-middleware.d.ts +4 -3
- package/dist/server/app-middleware.js +8 -3
- package/dist/server/app-optimistic-routing.js +11 -4
- package/dist/server/app-page-cache-finalizer.js +2 -1
- package/dist/server/app-page-cache-render.d.ts +1 -0
- package/dist/server/app-page-cache-render.js +8 -4
- package/dist/server/app-page-cache.d.ts +1 -0
- package/dist/server/app-page-cache.js +5 -2
- package/dist/server/app-page-dispatch.js +1 -0
- package/dist/server/app-page-element-builder.d.ts +2 -1
- package/dist/server/app-page-element-builder.js +58 -4
- package/dist/server/app-page-probe.js +5 -0
- package/dist/server/app-page-render-identity.d.ts +1 -0
- package/dist/server/app-page-render-identity.js +1 -1
- package/dist/server/app-page-render.js +18 -0
- package/dist/server/app-page-request.d.ts +14 -0
- package/dist/server/app-page-request.js +69 -4
- package/dist/server/app-page-route-wiring.d.ts +8 -1
- package/dist/server/app-page-route-wiring.js +32 -18
- package/dist/server/app-page-segment-state.d.ts +2 -1
- package/dist/server/app-page-segment-state.js +3 -1
- package/dist/server/app-page-stream.d.ts +5 -0
- package/dist/server/app-page-stream.js +3 -1
- package/dist/server/app-route-handler-execution.js +5 -1
- package/dist/server/app-route-handler-response.js +1 -0
- package/dist/server/app-route-handler-runtime.js +1 -1
- package/dist/server/app-router-entry.js +9 -2
- package/dist/server/app-rsc-handler.d.ts +1 -0
- package/dist/server/app-rsc-handler.js +62 -31
- package/dist/server/app-rsc-request-normalization.d.ts +3 -2
- package/dist/server/app-rsc-request-normalization.js +6 -3
- package/dist/server/app-segment-config.d.ts +11 -0
- package/dist/server/app-segment-config.js +62 -6
- package/dist/server/app-server-action-execution.d.ts +1 -0
- package/dist/server/app-server-action-execution.js +58 -28
- package/dist/server/app-ssr-entry.d.ts +3 -0
- package/dist/server/app-ssr-entry.js +15 -7
- package/dist/server/app-ssr-stream.d.ts +7 -3
- package/dist/server/app-ssr-stream.js +10 -6
- package/dist/server/app-visited-response-cache.d.ts +6 -0
- package/dist/server/app-visited-response-cache.js +3 -1
- package/dist/server/client-trace-metadata.js +26 -0
- package/dist/server/default-global-not-found-module.d.ts +14 -0
- package/dist/server/default-global-not-found-module.js +14 -0
- package/dist/server/dev-route-files.js +4 -0
- package/dist/server/dev-server.js +19 -18
- package/dist/server/dev-stack-sourcemap.d.ts +1 -1
- package/dist/server/dev-stack-sourcemap.js +1 -1
- package/dist/server/fetch-handler.d.ts +2 -0
- package/dist/server/fetch-handler.js +18 -0
- package/dist/server/headers.d.ts +3 -15
- package/dist/server/headers.js +2 -15
- package/dist/server/image-optimization.d.ts +51 -1
- package/dist/server/image-optimization.js +52 -2
- package/dist/server/implicit-tags.js +1 -1
- package/dist/server/isr-cache.d.ts +1 -1
- package/dist/server/isr-cache.js +2 -2
- package/dist/server/metadata-routes.d.ts +3 -1
- package/dist/server/metadata-routes.js +12 -2
- package/dist/server/middleware-runtime.js +6 -1
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +14 -3
- package/dist/server/pages-api-route.js +2 -2
- package/dist/server/pages-asset-tags.d.ts +4 -6
- package/dist/server/pages-asset-tags.js +12 -12
- package/dist/server/pages-client-assets.d.ts +12 -0
- package/dist/server/pages-client-assets.js +10 -0
- package/dist/server/pages-node-compat.d.ts +8 -1
- package/dist/server/pages-node-compat.js +32 -4
- package/dist/server/pages-page-data.d.ts +24 -1
- package/dist/server/pages-page-data.js +45 -24
- package/dist/server/pages-page-handler.d.ts +2 -1
- package/dist/server/pages-page-handler.js +19 -12
- package/dist/server/pages-page-response.d.ts +7 -0
- package/dist/server/pages-page-response.js +4 -1
- package/dist/server/pages-request-pipeline.d.ts +2 -0
- package/dist/server/pages-request-pipeline.js +25 -1
- package/dist/server/pages-router-entry.d.ts +30 -0
- package/dist/server/pages-router-entry.js +108 -0
- package/dist/server/prerender-manifest.d.ts +3 -1
- package/dist/server/prerender-route-params.js +1 -1
- package/dist/server/prod-server.d.ts +1 -1
- package/dist/server/prod-server.js +33 -20
- package/dist/server/request-pipeline.js +1 -0
- package/dist/server/seed-cache.js +4 -4
- package/dist/shims/app-router-scroll-state.d.ts +1 -0
- package/dist/shims/app-router-scroll-state.js +1 -0
- package/dist/shims/app-router-scroll.js +2 -1
- package/dist/shims/cache.js +19 -15
- package/dist/shims/cdn-cache.js +1 -1
- package/dist/shims/dynamic-preload-chunks.js +2 -1
- package/dist/shims/form.d.ts +3 -1
- package/dist/shims/form.js +37 -43
- package/dist/shims/headers.d.ts +7 -1
- package/dist/shims/headers.js +17 -3
- package/dist/shims/image.js +75 -14
- package/dist/shims/internal/app-route-detection.d.ts +2 -17
- package/dist/shims/internal/app-route-detection.js +4 -17
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +23 -0
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +51 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +2 -15
- package/dist/shims/internal/hybrid-client-route-owner.js +9 -60
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +9 -5
- package/dist/shims/internal/pages-data-fetch-dedup.js +73 -14
- package/dist/shims/internal/pages-data-target.d.ts +10 -9
- package/dist/shims/internal/pages-data-target.js +91 -12
- package/dist/shims/internal/pages-router-components.d.ts +7 -0
- package/dist/shims/internal/pages-router-components.js +13 -0
- package/dist/shims/layout-segment-context.d.ts +4 -1
- package/dist/shims/layout-segment-context.js +18 -4
- package/dist/shims/link.js +55 -26
- package/dist/shims/navigation.d.ts +5 -1
- package/dist/shims/navigation.js +45 -10
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/root-params.d.ts +15 -1
- package/dist/shims/root-params.js +21 -1
- package/dist/shims/router.d.ts +5 -7
- package/dist/shims/router.js +362 -93
- package/dist/shims/server.js +3 -2
- package/dist/shims/slot.js +3 -6
- package/dist/utils/client-runtime-metadata.d.ts +2 -18
- package/dist/utils/client-runtime-metadata.js +31 -22
- package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +4 -0
- package/dist/{server → utils}/dev-stack-sourcemap-endpoint.js +1 -1
- package/dist/utils/domain-locale.d.ts +6 -3
- package/dist/{server → utils}/middleware-request-headers.d.ts +1 -1
- package/dist/{server → utils}/middleware-request-headers.js +2 -2
- package/dist/utils/project.d.ts +48 -2
- package/dist/utils/project.js +225 -4
- package/dist/utils/protocol-headers.d.ts +17 -0
- package/dist/utils/protocol-headers.js +17 -0
- package/dist/utils/react-version.d.ts +4 -0
- package/dist/utils/react-version.js +44 -0
- package/package.json +47 -2
- package/dist/deploy.d.ts +0 -197
- package/dist/deploy.js +0 -1040
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +0 -4
- /package/dist/{cloudflare → packages/cloudflare}/src/utils/cache-control-metadata.js +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createRequestContext, runWithRequestContext } from "../shims/unified-request-context.js";
|
|
2
2
|
import { addBasePathToPathname, hasBasePath, stripBasePath } from "../utils/base-path.js";
|
|
3
3
|
import { getRequestExecutionContext } from "../shims/request-context.js";
|
|
4
|
-
import {
|
|
4
|
+
import { VINEXT_MW_CTX_HEADER, VINEXT_PRERENDER_ROUTE_PARAMS_HEADER } from "../utils/protocol-headers.js";
|
|
5
|
+
import { ACTION_REVALIDATED_HEADER } from "./headers.js";
|
|
5
6
|
import { isExternalUrl, matchRedirect, matchRewrite, preserveRedirectDestinationQuery, proxyExternalRequest, requestContextFromRequest, sanitizeDestination } from "../config/config-matchers.js";
|
|
6
7
|
import { notFoundResponse } from "./http-error-responses.js";
|
|
7
8
|
import { applyConfigHeadersToResponse, cloneRequestWithHeaders, cloneRequestWithUrl, filterInternalHeaders, normalizeTrailingSlash, resolvePublicFileRoute } from "./request-pipeline.js";
|
|
@@ -10,18 +11,19 @@ import { ensureFetchPatch, setCurrentFetchSoftTags } from "../shims/fetch-cache.
|
|
|
10
11
|
import { mergeRewriteQuery } from "../utils/query.js";
|
|
11
12
|
import { getScriptNonceFromHeaderSources } from "./csp.js";
|
|
12
13
|
import { normalizeDefaultLocalePathname } from "./pages-i18n.js";
|
|
14
|
+
import { buildNextDataNotFoundResponse, normalizePagesDataRequest } from "./pages-data-route.js";
|
|
13
15
|
import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, resolveDevImageRedirect } from "./image-optimization.js";
|
|
14
16
|
import { VINEXT_RSC_CACHE_BUSTING_SEARCH_PARAM, createRscRedirectLocation, hasRscCacheBustingSearchParam, resolveInvalidRscCacheBustingRequest, stripRscCacheBustingSearchParam, stripRscSuffix } from "./app-rsc-cache-busting.js";
|
|
15
17
|
import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
|
|
16
18
|
import "./app-page-response.js";
|
|
17
|
-
import {
|
|
19
|
+
import { parseNextHttpErrorDigest } from "./next-error-digest.js";
|
|
18
20
|
import { matchPrerenderRouteParamsPayload, readTrustedPrerenderRouteParams, serializePrerenderRouteParamsHeader } from "./prerender-route-params.js";
|
|
19
21
|
import { getRenderedConcreteUrlPathsForRoute } from "./pregenerated-concrete-paths.js";
|
|
20
|
-
import { pickRootParams, setRootParams } from "../shims/root-params.js";
|
|
21
|
-
import { flattenErrorCauses } from "../utils/error-cause.js";
|
|
22
22
|
import { createServerActionNotFoundResponse, getServerActionNotFoundMessage } from "./server-action-not-found.js";
|
|
23
23
|
import { buildPageCacheTags } from "./implicit-tags.js";
|
|
24
24
|
import { buildPostMwRequestContext } from "./app-post-middleware-context.js";
|
|
25
|
+
import { pickRootParams, setRootParams } from "../shims/root-params.js";
|
|
26
|
+
import { flattenErrorCauses } from "../utils/error-cause.js";
|
|
25
27
|
import { finalizeAppRscResponse } from "./app-rsc-response-finalizer.js";
|
|
26
28
|
import { normalizeRscRequest } from "./app-rsc-request-normalization.js";
|
|
27
29
|
import { runWithPrerenderWorkUnit } from "./prerender-work-unit-setup.js";
|
|
@@ -53,8 +55,8 @@ function createMissingServerActionResponse(options, actionId) {
|
|
|
53
55
|
options.clearRequestContext();
|
|
54
56
|
return createServerActionNotFoundResponse();
|
|
55
57
|
}
|
|
56
|
-
function redirectDestinationWithBasePath(destination, basePath) {
|
|
57
|
-
if (!basePath || isExternalUrl(destination) || hasBasePath(destination, basePath)) return destination;
|
|
58
|
+
function redirectDestinationWithBasePath(destination, basePath, hadBasePath) {
|
|
59
|
+
if (!basePath || !hadBasePath || isExternalUrl(destination) || hasBasePath(destination, basePath)) return destination;
|
|
58
60
|
return basePath + destination;
|
|
59
61
|
}
|
|
60
62
|
async function applyRewrite(options, cleanPathname) {
|
|
@@ -111,15 +113,22 @@ function requestWithoutRscSuffix(request) {
|
|
|
111
113
|
url.pathname = pathname;
|
|
112
114
|
return cloneRequestWithUrl(request.body ? request.clone() : request, url.toString());
|
|
113
115
|
}
|
|
114
|
-
async function handleAppRscRequest(options, request, preMiddlewareRequestContext, isDataRequest, pagesDataRequest) {
|
|
116
|
+
async function handleAppRscRequest(options, request, preMiddlewareRequestContext, isDataRequest, isMiddlewareDataRequest, pagesDataRequest) {
|
|
115
117
|
const handlerStart = process.env.NODE_ENV !== "production" ? performance.now() : 0;
|
|
116
118
|
if (process.env.NODE_ENV !== "production") {
|
|
117
119
|
const originBlock = options.validateDevRequestOrigin?.(request);
|
|
118
120
|
if (originBlock) return originBlock;
|
|
119
121
|
}
|
|
120
|
-
const
|
|
122
|
+
const canHandleOutsideBasePath = Boolean(options.runMiddleware) || [
|
|
123
|
+
...options.configRedirects,
|
|
124
|
+
...options.configRewrites.beforeFiles,
|
|
125
|
+
...options.configRewrites.afterFiles,
|
|
126
|
+
...options.configRewrites.fallback,
|
|
127
|
+
...options.configHeaders
|
|
128
|
+
].some((rule) => rule.basePath === false);
|
|
129
|
+
const normalized = normalizeRscRequest(request, options.basePath, canHandleOutsideBasePath);
|
|
121
130
|
if (normalized instanceof Response) return normalized;
|
|
122
|
-
const { url, isRscRequest, interceptionContextHeader, mountedSlotsHeader, renderMode, clientReuseManifest } = normalized;
|
|
131
|
+
const { url, isRscRequest, interceptionContextHeader, mountedSlotsHeader, renderMode, clientReuseManifest, hadBasePath } = normalized;
|
|
123
132
|
let { pathname, cleanPathname } = normalized;
|
|
124
133
|
let resolvedUrl = cleanPathname + url.search;
|
|
125
134
|
const originalResolvedUrl = resolvedUrl;
|
|
@@ -127,7 +136,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
127
136
|
const canonicalPathname = cleanPathname;
|
|
128
137
|
const basePathState = {
|
|
129
138
|
basePath: options.basePath,
|
|
130
|
-
hadBasePath
|
|
139
|
+
hadBasePath
|
|
131
140
|
};
|
|
132
141
|
if (pathname === "/__vinext/prerender/static-params" || pathname === "/__vinext/prerender/pages-static-paths") {
|
|
133
142
|
const { handleAppPrerenderEndpoint } = await import("./app-prerender-endpoints.js");
|
|
@@ -142,17 +151,13 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
142
151
|
});
|
|
143
152
|
if (prerenderEndpointResponse) return prerenderEndpointResponse;
|
|
144
153
|
}
|
|
145
|
-
const trailingSlashRedirect = normalizeTrailingSlash(pathname, options.basePath, options.trailingSlash, url.search);
|
|
154
|
+
const trailingSlashRedirect = normalizeTrailingSlash(pathname, hadBasePath ? options.basePath : "", options.trailingSlash, url.search);
|
|
146
155
|
if (trailingSlashRedirect) return trailingSlashRedirect;
|
|
147
156
|
const matchPathname = (p) => normalizeDefaultLocalePathname(p, options.i18nConfig, { hostname: url.hostname });
|
|
148
157
|
const redirect = matchRedirect(matchPathname(stripRscSuffix(pathname)), options.configRedirects, preMiddlewareRequestContext, basePathState);
|
|
149
158
|
if (redirect) {
|
|
150
|
-
const destination = sanitizeDestination(redirectDestinationWithBasePath(redirect.destination, options.basePath));
|
|
159
|
+
const destination = sanitizeDestination(redirectDestinationWithBasePath(redirect.destination, options.basePath, hadBasePath));
|
|
151
160
|
const location = isRscRequest && request.headers.get("RSC") === "1" ? await createRscRedirectLocation(destination, request) : preserveRedirectDestinationQuery(destination, url.search);
|
|
152
|
-
if (isDataRequest) return new Response(null, {
|
|
153
|
-
status: 200,
|
|
154
|
-
headers: { "x-nextjs-redirect": location }
|
|
155
|
-
});
|
|
156
161
|
return new Response(null, {
|
|
157
162
|
status: redirect.permanent ? 308 : 307,
|
|
158
163
|
headers: { Location: location }
|
|
@@ -171,11 +176,13 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
171
176
|
status: null
|
|
172
177
|
};
|
|
173
178
|
let didMiddlewareRewrite = false;
|
|
179
|
+
let didMiddlewareRewritePathname = false;
|
|
174
180
|
if (options.runMiddleware) {
|
|
175
181
|
const middlewareResult = await options.runMiddleware({
|
|
176
182
|
cleanPathname,
|
|
177
183
|
context: middlewareContext,
|
|
178
|
-
|
|
184
|
+
hadBasePath,
|
|
185
|
+
isDataRequest: isMiddlewareDataRequest,
|
|
179
186
|
request: userlandRequest
|
|
180
187
|
});
|
|
181
188
|
if (middlewareResult.kind === "response") return applyConfigHeadersToMiddlewareRedirect(middlewareResult.response, {
|
|
@@ -185,12 +192,14 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
185
192
|
requestContext: preMiddlewareRequestContext
|
|
186
193
|
});
|
|
187
194
|
cleanPathname = middlewareResult.cleanPathname;
|
|
188
|
-
didMiddlewareRewrite =
|
|
195
|
+
didMiddlewareRewrite = middlewareResult.rewritten;
|
|
196
|
+
didMiddlewareRewritePathname = cleanPathname !== normalized.cleanPathname;
|
|
189
197
|
if (middlewareResult.search !== null) url.search = middlewareResult.search;
|
|
190
198
|
resolvedUrl = cleanPathname + url.search;
|
|
191
199
|
}
|
|
192
200
|
const scriptNonce = getScriptNonceFromHeaderSources(request.headers, middlewareContext.headers);
|
|
193
201
|
const postMiddlewareRequestContext = buildPostMwRequestContext(userlandRequest);
|
|
202
|
+
let filesystemRouteEligible = hadBasePath || didMiddlewareRewrite;
|
|
194
203
|
for (const rewrite of options.configRewrites.beforeFiles) {
|
|
195
204
|
const beforeFilesRewrite = await applyRewrite({
|
|
196
205
|
basePathState,
|
|
@@ -203,14 +212,15 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
203
212
|
if (beforeFilesRewrite) {
|
|
204
213
|
resolvedUrl = mergeRewriteQuery(resolvedUrl, beforeFilesRewrite);
|
|
205
214
|
cleanPathname = pathnameForResolvedUrl(resolvedUrl);
|
|
215
|
+
filesystemRouteEligible = true;
|
|
206
216
|
}
|
|
207
217
|
}
|
|
208
|
-
if (isImageOptimizationPath(cleanPathname)) {
|
|
218
|
+
if (filesystemRouteEligible && isImageOptimizationPath(cleanPathname)) {
|
|
209
219
|
const imageRedirect = resolveDevImageRedirect(url, [...options.imageConfig?.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...options.imageConfig?.imageSizes ?? DEFAULT_IMAGE_SIZES], options.imageConfig?.qualities, { isDev: options.isDev });
|
|
210
220
|
if (!imageRedirect) return new Response("Invalid image optimization parameters", { status: 400 });
|
|
211
221
|
return Response.redirect(new URL(imageRedirect, url.origin).href, 302);
|
|
212
222
|
}
|
|
213
|
-
if (options.handleMetadataRouteRequest) {
|
|
223
|
+
if (filesystemRouteEligible && options.handleMetadataRouteRequest) {
|
|
214
224
|
const metadataRouteResponse = await options.handleMetadataRouteRequest(cleanPathname);
|
|
215
225
|
if (metadataRouteResponse) {
|
|
216
226
|
applyConfigHeadersToResponse(metadataRouteResponse.headers, {
|
|
@@ -223,13 +233,13 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
223
233
|
return applyMiddlewareContextToResponse(metadataRouteResponse, middlewareContext);
|
|
224
234
|
}
|
|
225
235
|
}
|
|
226
|
-
const publicFileResponse = resolvePublicFileRoute({
|
|
236
|
+
const publicFileResponse = filesystemRouteEligible ? resolvePublicFileRoute({
|
|
227
237
|
cleanPathname,
|
|
228
238
|
middlewareContext,
|
|
229
239
|
pathname,
|
|
230
240
|
publicFiles: options.publicFiles,
|
|
231
241
|
request
|
|
232
|
-
});
|
|
242
|
+
}) : null;
|
|
233
243
|
if (publicFileResponse) {
|
|
234
244
|
options.clearRequestContext();
|
|
235
245
|
return publicFileResponse;
|
|
@@ -243,13 +253,13 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
243
253
|
searchParams: getResolvedSearchParams(),
|
|
244
254
|
params: {}
|
|
245
255
|
});
|
|
246
|
-
const preActionMatch = options.matchRoute(cleanPathname);
|
|
256
|
+
const preActionMatch = filesystemRouteEligible ? options.matchRoute(cleanPathname) : null;
|
|
247
257
|
if (preActionMatch) setRootParams(pickRootParams(preActionMatch.params, preActionMatch.route.rootParamNames));
|
|
248
258
|
const actionId = request.headers.get("x-rsc-action") ?? request.headers.get("next-action");
|
|
249
259
|
const contentType = request.headers.get("content-type") || "";
|
|
250
260
|
const isPostRequest = request.method.toUpperCase() === "POST";
|
|
251
261
|
let progressiveActionResult = null;
|
|
252
|
-
if (isPostRequest && contentType.startsWith("multipart/form-data") && !actionId) {
|
|
262
|
+
if (filesystemRouteEligible && isPostRequest && contentType.startsWith("multipart/form-data") && !actionId) {
|
|
253
263
|
if (options.handleProgressiveActionRequest) progressiveActionResult = await options.handleProgressiveActionRequest({
|
|
254
264
|
actionId,
|
|
255
265
|
cleanPathname,
|
|
@@ -266,7 +276,11 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
266
276
|
const failedProgressiveActionResult = progressiveActionFormState && "actionError" in progressiveActionFormState ? progressiveActionFormState : null;
|
|
267
277
|
const actionFailed = failedProgressiveActionResult !== null;
|
|
268
278
|
const actionError = failedProgressiveActionResult?.actionError;
|
|
269
|
-
const
|
|
279
|
+
const actionErrorDigest = actionError && typeof actionError === "object" && "digest" in actionError ? String(actionError.digest) : null;
|
|
280
|
+
const actionHttpFallbackStatus = actionErrorDigest ? parseNextHttpErrorDigest(actionErrorDigest)?.status ?? null : null;
|
|
281
|
+
const normalizedProgressiveActionError = actionHttpFallbackStatus === null || actionHttpFallbackStatus === 404 ? actionError : { digest: "NEXT_NOT_FOUND" };
|
|
282
|
+
if (actionFailed && middlewareContext.status === null && actionHttpFallbackStatus === null) middlewareContext.status = 500;
|
|
283
|
+
const serverActionResponse = filesystemRouteEligible && isPostRequest && actionId && options.handleServerActionRequest ? await options.handleServerActionRequest({
|
|
270
284
|
actionId,
|
|
271
285
|
cleanPathname,
|
|
272
286
|
contentType,
|
|
@@ -278,12 +292,13 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
278
292
|
searchParams: getResolvedSearchParams()
|
|
279
293
|
}) : null;
|
|
280
294
|
if (serverActionResponse) return serverActionResponse;
|
|
281
|
-
if (isPostRequest && actionId && !options.handleServerActionRequest) return createMissingServerActionResponse(options, actionId);
|
|
295
|
+
if (filesystemRouteEligible && isPostRequest && actionId && !options.handleServerActionRequest) return createMissingServerActionResponse(options, actionId);
|
|
282
296
|
let match = preActionMatch;
|
|
283
297
|
const renderPagesForMatchKind = async (matchKind) => {
|
|
298
|
+
if (!filesystemRouteEligible) return null;
|
|
284
299
|
const response = match === null || match.route.isDynamic ? await options.renderPagesFallback?.({
|
|
285
300
|
appRouteMatch: match ?? null,
|
|
286
|
-
allowRscDocumentFallback:
|
|
301
|
+
allowRscDocumentFallback: didMiddlewareRewritePathname,
|
|
287
302
|
isDataRequest,
|
|
288
303
|
isRscRequest,
|
|
289
304
|
matchKind,
|
|
@@ -319,6 +334,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
319
334
|
if (!afterFilesRewrite) continue;
|
|
320
335
|
resolvedUrl = mergeRewriteQuery(resolvedUrl, afterFilesRewrite);
|
|
321
336
|
cleanPathname = pathnameForResolvedUrl(resolvedUrl);
|
|
337
|
+
filesystemRouteEligible = true;
|
|
322
338
|
match = options.matchRoute(cleanPathname);
|
|
323
339
|
const rewrittenStaticPagesResponse = await renderPagesForMatchKind("static");
|
|
324
340
|
if (rewrittenStaticPagesResponse) {
|
|
@@ -349,6 +365,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
349
365
|
if (!fallbackRewrite) continue;
|
|
350
366
|
resolvedUrl = mergeRewriteQuery(resolvedUrl, fallbackRewrite);
|
|
351
367
|
cleanPathname = pathnameForResolvedUrl(resolvedUrl);
|
|
368
|
+
filesystemRouteEligible = true;
|
|
352
369
|
match = options.matchRoute(cleanPathname);
|
|
353
370
|
const rewrittenStaticPagesResponse = await renderPagesForMatchKind("static");
|
|
354
371
|
if (rewrittenStaticPagesResponse) {
|
|
@@ -362,8 +379,23 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
362
379
|
}
|
|
363
380
|
if (match) break;
|
|
364
381
|
}
|
|
382
|
+
if (!filesystemRouteEligible) {
|
|
383
|
+
options.clearRequestContext();
|
|
384
|
+
const headers = new Headers();
|
|
385
|
+
mergeMiddlewareResponseHeaders(headers, middlewareContext.headers);
|
|
386
|
+
return notFoundResponse({ headers });
|
|
387
|
+
}
|
|
365
388
|
if (pagesDataRequest) {
|
|
366
389
|
options.clearRequestContext();
|
|
390
|
+
if (options.runMiddleware && (middlewareContext.status === null || middlewareContext.status === 200 || middlewareContext.status === 404)) {
|
|
391
|
+
const response = buildNextDataNotFoundResponse();
|
|
392
|
+
const headers = new Headers(response.headers);
|
|
393
|
+
headers.set("x-nextjs-matched-path", matchPathname(canonicalPathname));
|
|
394
|
+
return new Response("{}", {
|
|
395
|
+
status: 200,
|
|
396
|
+
headers
|
|
397
|
+
});
|
|
398
|
+
}
|
|
367
399
|
return buildNextDataNotFoundResponse();
|
|
368
400
|
}
|
|
369
401
|
if (!match) {
|
|
@@ -425,7 +457,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
425
457
|
cleanPathname,
|
|
426
458
|
displayPathname: canonicalPathname,
|
|
427
459
|
formState,
|
|
428
|
-
actionError,
|
|
460
|
+
actionError: normalizedProgressiveActionError,
|
|
429
461
|
actionFailed,
|
|
430
462
|
handlerStart,
|
|
431
463
|
interceptionContext: interceptionContextHeader,
|
|
@@ -489,14 +521,13 @@ function createAppRscHandler(options) {
|
|
|
489
521
|
options.registerCacheAdapters();
|
|
490
522
|
await options.ensureInstrumentation?.();
|
|
491
523
|
const mwCtx = rawRequest.headers.get(VINEXT_MW_CTX_HEADER);
|
|
492
|
-
const hasDataRequestHeader = rawRequest.headers.get("x-nextjs-data") === "1";
|
|
493
524
|
const pagesDataUrl = new URL(rawRequest.url);
|
|
494
525
|
const pagesDataInScope = !options.basePath || hasBasePath(pagesDataUrl.pathname, options.basePath);
|
|
495
526
|
if (pagesDataInScope) pagesDataUrl.pathname = stripBasePath(pagesDataUrl.pathname, options.basePath);
|
|
496
527
|
const pagesDataCandidate = pagesDataInScope ? cloneRequestWithUrl(rawRequest, pagesDataUrl.toString()) : null;
|
|
497
528
|
const pagesDataNormalization = options.renderPagesFallback && pagesDataCandidate ? normalizePagesDataRequest(pagesDataCandidate, options.buildId) : null;
|
|
498
529
|
if (pagesDataNormalization?.notFoundResponse) return pagesDataNormalization.notFoundResponse;
|
|
499
|
-
const
|
|
530
|
+
const isPagesDataRequest = pagesDataNormalization?.isDataReq === true;
|
|
500
531
|
const prerenderRouteParamsPayload = readTrustedPrerenderRouteParams(rawRequest);
|
|
501
532
|
const filteredHeaders = filterInternalHeaders(rawRequest.headers);
|
|
502
533
|
if (mwCtx !== null) filteredHeaders.set(VINEXT_MW_CTX_HEADER, mwCtx);
|
|
@@ -520,7 +551,7 @@ function createAppRscHandler(options) {
|
|
|
520
551
|
const preMiddlewareRequestContext = requestContextFromRequest(request);
|
|
521
552
|
let response;
|
|
522
553
|
try {
|
|
523
|
-
response = await handleAppRscRequest(options, request, preMiddlewareRequestContext,
|
|
554
|
+
response = await handleAppRscRequest(options, request, preMiddlewareRequestContext, isPagesDataRequest, isPagesDataRequest, pagesDataRequest);
|
|
524
555
|
} catch (error) {
|
|
525
556
|
if (process.env.NODE_ENV !== "production") flattenErrorCauses(error);
|
|
526
557
|
throw error;
|
|
@@ -11,7 +11,8 @@ type NormalizedRscRequest = {
|
|
|
11
11
|
interceptionContextHeader: string | null; /** Normalized x-vinext-mounted-slots header (deduplicated, sorted). null when absent or blank. */
|
|
12
12
|
mountedSlotsHeader: string | null; /** Semantic RSC payload mode. HTML requests always normalize to "navigation". */
|
|
13
13
|
renderMode: AppRscRenderMode; /** Parsed ClientReuseManifest hint. Verification and skip authorization happen later. */
|
|
14
|
-
clientReuseManifest: ClientReuseManifestParseResult;
|
|
14
|
+
clientReuseManifest: ClientReuseManifestParseResult; /** Whether the incoming pathname included the configured basePath. */
|
|
15
|
+
hadBasePath: boolean;
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
17
18
|
* Normalize an App Router RSC request.
|
|
@@ -43,6 +44,6 @@ type NormalizedRscRequest = {
|
|
|
43
44
|
* @returns A 400 or 404 Response for invalid or out-of-scope inputs,
|
|
44
45
|
* or a NormalizedRscRequest for valid requests.
|
|
45
46
|
*/
|
|
46
|
-
declare function normalizeRscRequest(request: Request, basePath: string): Response | NormalizedRscRequest;
|
|
47
|
+
declare function normalizeRscRequest(request: Request, basePath: string, allowOutsideBasePath?: boolean): Response | NormalizedRscRequest;
|
|
47
48
|
//#endregion
|
|
48
49
|
export { NormalizedRscRequest, normalizeMountedSlotsHeader, normalizeRscRequest };
|
|
@@ -40,7 +40,7 @@ import { normalizeInterceptionContextHeader } from "./app-interception-context-h
|
|
|
40
40
|
* @returns A 400 or 404 Response for invalid or out-of-scope inputs,
|
|
41
41
|
* or a NormalizedRscRequest for valid requests.
|
|
42
42
|
*/
|
|
43
|
-
function normalizeRscRequest(request, basePath) {
|
|
43
|
+
function normalizeRscRequest(request, basePath, allowOutsideBasePath = false) {
|
|
44
44
|
const url = new URL(request.url);
|
|
45
45
|
const protoGuard = guardProtocolRelativeUrl(url.pathname);
|
|
46
46
|
if (protoGuard) return protoGuard;
|
|
@@ -51,9 +51,11 @@ function normalizeRscRequest(request, basePath) {
|
|
|
51
51
|
return badRequestResponse();
|
|
52
52
|
}
|
|
53
53
|
let pathname = normalizePath(decoded);
|
|
54
|
+
let hadBasePath = true;
|
|
54
55
|
if (basePath) {
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
hadBasePath = hasBasePath(pathname, basePath);
|
|
57
|
+
if (!hadBasePath && !pathname.startsWith("/__vinext/") && !allowOutsideBasePath) return notFoundResponse();
|
|
58
|
+
if (hadBasePath) pathname = stripBasePath(pathname, basePath);
|
|
57
59
|
}
|
|
58
60
|
const isRscRequest = pathname.endsWith(".rsc") || request.headers.get("RSC") === "1" && url.searchParams.has("_rsc");
|
|
59
61
|
const cleanPathname = stripRscSuffix(pathname);
|
|
@@ -62,6 +64,7 @@ function normalizeRscRequest(request, basePath) {
|
|
|
62
64
|
const renderMode = isRscRequest ? parseAppRscRenderMode(request.headers.get(VINEXT_RSC_RENDER_MODE_HEADER)) : APP_RSC_RENDER_MODE_NAVIGATION;
|
|
63
65
|
return {
|
|
64
66
|
clientReuseManifest: isRscRequest ? parseClientReuseManifestHeader(request.headers.get(VINEXT_CLIENT_REUSE_MANIFEST_HEADER)) : { kind: "absent" },
|
|
67
|
+
hadBasePath,
|
|
65
68
|
url,
|
|
66
69
|
pathname,
|
|
67
70
|
cleanPathname,
|
|
@@ -6,6 +6,7 @@ type AppRouteSegmentConfigModule = {
|
|
|
6
6
|
dynamic?: unknown;
|
|
7
7
|
dynamicParams?: unknown;
|
|
8
8
|
fetchCache?: unknown;
|
|
9
|
+
generateStaticParams?: unknown;
|
|
9
10
|
revalidate?: unknown;
|
|
10
11
|
runtime?: unknown;
|
|
11
12
|
unstable_dynamicStaleTime?: unknown;
|
|
@@ -18,11 +19,21 @@ type EffectiveAppPageSegmentConfig = {
|
|
|
18
19
|
revalidateSeconds: number | null;
|
|
19
20
|
runtime?: "edge" | "experimental-edge" | "nodejs";
|
|
20
21
|
};
|
|
22
|
+
type ParallelAppPageSegmentConfigBranch = {
|
|
23
|
+
configLayouts?: readonly (AppRouteSegmentConfigModule | null | undefined)[] | null;
|
|
24
|
+
configLayoutTreePositions?: readonly number[] | null;
|
|
25
|
+
layout?: AppRouteSegmentConfigModule | null;
|
|
26
|
+
page?: AppRouteSegmentConfigModule | null;
|
|
27
|
+
routeSegments?: readonly string[] | null;
|
|
28
|
+
};
|
|
21
29
|
type ResolveAppPageSegmentConfigOptions = {
|
|
22
30
|
layouts?: readonly (AppRouteSegmentConfigModule | null | undefined)[];
|
|
31
|
+
layoutTreePositions?: readonly number[];
|
|
23
32
|
page?: AppRouteSegmentConfigModule | null;
|
|
33
|
+
parallelBranches?: readonly (ParallelAppPageSegmentConfigBranch | null | undefined)[];
|
|
24
34
|
parallelPages?: readonly (AppRouteSegmentConfigModule | null | undefined)[];
|
|
25
35
|
parallelSegments?: readonly (AppRouteSegmentConfigModule | null | undefined)[];
|
|
36
|
+
routeSegments?: readonly string[];
|
|
26
37
|
};
|
|
27
38
|
/**
|
|
28
39
|
* Resolve the route segment config that applies to an App page route.
|
|
@@ -37,6 +37,65 @@ function resolveDynamicStaleTimeSeconds(current, value) {
|
|
|
37
37
|
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) return current;
|
|
38
38
|
return current === void 0 ? value : Math.min(current, value);
|
|
39
39
|
}
|
|
40
|
+
function isDynamicSegment(segment) {
|
|
41
|
+
return segment.startsWith("[") && segment.endsWith("]");
|
|
42
|
+
}
|
|
43
|
+
function getParallelSegments(options) {
|
|
44
|
+
if (!options.parallelBranches) return options.parallelSegments ?? [];
|
|
45
|
+
return options.parallelBranches.flatMap((branch) => branch ? [
|
|
46
|
+
branch.layout,
|
|
47
|
+
...branch.configLayouts ?? [],
|
|
48
|
+
branch.page
|
|
49
|
+
] : []);
|
|
50
|
+
}
|
|
51
|
+
function resolveDynamicParamsConfig(options) {
|
|
52
|
+
const parallelSegments = getParallelSegments(options);
|
|
53
|
+
const segments = [
|
|
54
|
+
...options.layouts ?? [],
|
|
55
|
+
options.page,
|
|
56
|
+
...parallelSegments
|
|
57
|
+
];
|
|
58
|
+
let dynamicParamsConfig;
|
|
59
|
+
for (const segment of segments) if (segment?.dynamicParams === false) dynamicParamsConfig = false;
|
|
60
|
+
else if (segment?.dynamicParams === true && dynamicParamsConfig !== false) dynamicParamsConfig = true;
|
|
61
|
+
if (dynamicParamsConfig !== false || !options.routeSegments) return dynamicParamsConfig;
|
|
62
|
+
let lastDynamicPosition = -1;
|
|
63
|
+
for (let index = options.routeSegments.length - 1; index >= 0; index--) if (isDynamicSegment(options.routeSegments[index])) {
|
|
64
|
+
lastDynamicPosition = index;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
if (lastDynamicPosition < 0) return dynamicParamsConfig;
|
|
68
|
+
const layouts = options.layouts ?? [];
|
|
69
|
+
const layoutPositions = options.layoutTreePositions ?? [];
|
|
70
|
+
let lastDynamicSegmentIsStaticOnly = false;
|
|
71
|
+
let lastDynamicSegmentHasStaticParams = false;
|
|
72
|
+
layouts.forEach((layout, index) => {
|
|
73
|
+
if ((layoutPositions[index] ?? 0) - 1 !== lastDynamicPosition) return;
|
|
74
|
+
if (layout?.dynamicParams === false) lastDynamicSegmentIsStaticOnly = true;
|
|
75
|
+
if (typeof layout?.generateStaticParams === "function") lastDynamicSegmentHasStaticParams = true;
|
|
76
|
+
});
|
|
77
|
+
if (options.page?.dynamicParams === false) lastDynamicSegmentIsStaticOnly = true;
|
|
78
|
+
if (typeof options.page?.generateStaticParams === "function") lastDynamicSegmentHasStaticParams = true;
|
|
79
|
+
for (const branch of options.parallelBranches ?? []) {
|
|
80
|
+
if (!branch) continue;
|
|
81
|
+
const branchStartPosition = options.routeSegments.length - (branch.routeSegments?.length ?? 0);
|
|
82
|
+
const checkSegment = (segment, ownerPosition) => {
|
|
83
|
+
if (ownerPosition !== lastDynamicPosition) return;
|
|
84
|
+
if (segment?.dynamicParams === false) lastDynamicSegmentIsStaticOnly = true;
|
|
85
|
+
if (typeof segment?.generateStaticParams === "function") lastDynamicSegmentHasStaticParams = true;
|
|
86
|
+
};
|
|
87
|
+
checkSegment(branch.layout, branchStartPosition - 1);
|
|
88
|
+
branch.configLayouts?.forEach((layout, index) => {
|
|
89
|
+
checkSegment(layout, branchStartPosition + (branch.configLayoutTreePositions?.[index] ?? 0) - 1);
|
|
90
|
+
});
|
|
91
|
+
checkSegment(branch.page, branchStartPosition + (branch.routeSegments?.length ?? 0) - 1);
|
|
92
|
+
}
|
|
93
|
+
if (!options.parallelBranches) for (const segment of parallelSegments) {
|
|
94
|
+
if (segment?.dynamicParams === false) lastDynamicSegmentIsStaticOnly = true;
|
|
95
|
+
if (typeof segment?.generateStaticParams === "function") lastDynamicSegmentHasStaticParams = true;
|
|
96
|
+
}
|
|
97
|
+
return lastDynamicSegmentIsStaticOnly || lastDynamicSegmentHasStaticParams ? false : void 0;
|
|
98
|
+
}
|
|
40
99
|
function isCacheFetchCacheMode(value) {
|
|
41
100
|
return value === "default-cache" || value === "force-cache" || value === "only-cache";
|
|
42
101
|
}
|
|
@@ -53,7 +112,9 @@ function describeFetchCacheConflict(value) {
|
|
|
53
112
|
*/
|
|
54
113
|
function resolveAppPageSegmentConfig(options) {
|
|
55
114
|
const segments = [...options.layouts ?? [], options.page];
|
|
115
|
+
const parallelSegments = getParallelSegments(options);
|
|
56
116
|
const config = { revalidateSeconds: null };
|
|
117
|
+
config.dynamicParamsConfig = resolveDynamicParamsConfig(options);
|
|
57
118
|
let hasForceCache = false;
|
|
58
119
|
let hasForceNoStore = false;
|
|
59
120
|
let hasOnlyCache = false;
|
|
@@ -67,8 +128,6 @@ function resolveAppPageSegmentConfig(options) {
|
|
|
67
128
|
config.dynamicConfig = hasForceDynamic ? "force-dynamic" : segment.dynamic;
|
|
68
129
|
}
|
|
69
130
|
if (isRouteSegmentRuntime(segment.runtime)) config.runtime = segment.runtime;
|
|
70
|
-
if (segment.dynamicParams === false) config.dynamicParamsConfig = false;
|
|
71
|
-
else if (segment.dynamicParams === true && config.dynamicParamsConfig !== false) config.dynamicParamsConfig = true;
|
|
72
131
|
if (isRouteSegmentFetchCache(segment.fetchCache)) {
|
|
73
132
|
const fetchCache = segment.fetchCache;
|
|
74
133
|
if (hasParentDefaultNoStore && (fetchCache === "auto" || isCacheFetchCacheMode(fetchCache))) throw new Error(describeFetchCacheConflict(fetchCache));
|
|
@@ -86,14 +145,12 @@ function resolveAppPageSegmentConfig(options) {
|
|
|
86
145
|
}
|
|
87
146
|
config.revalidateSeconds = resolveRevalidateSeconds(config.revalidateSeconds, segment.revalidate);
|
|
88
147
|
}
|
|
89
|
-
for (const segment of
|
|
148
|
+
for (const segment of parallelSegments) {
|
|
90
149
|
if (!segment) continue;
|
|
91
150
|
if (segment.dynamic === "force-dynamic") {
|
|
92
151
|
hasForceDynamic = true;
|
|
93
152
|
config.dynamicConfig = "force-dynamic";
|
|
94
153
|
} else if (config.dynamicConfig === void 0 && isRouteSegmentDynamic(segment.dynamic)) config.dynamicConfig = segment.dynamic;
|
|
95
|
-
if (segment.dynamicParams === false) config.dynamicParamsConfig = false;
|
|
96
|
-
else if (segment.dynamicParams === true && config.dynamicParamsConfig === void 0) config.dynamicParamsConfig = true;
|
|
97
154
|
if (config.runtime === void 0 && isRouteSegmentRuntime(segment.runtime)) config.runtime = segment.runtime;
|
|
98
155
|
if (isRouteSegmentFetchCache(segment.fetchCache)) {
|
|
99
156
|
const fetchCache = segment.fetchCache;
|
|
@@ -120,7 +177,6 @@ function resolveAppPageSegmentConfig(options) {
|
|
|
120
177
|
if (config.fetchCache === void 0) {
|
|
121
178
|
if (config.dynamicConfig === "error") config.fetchCache = "only-cache";
|
|
122
179
|
}
|
|
123
|
-
if (config.dynamicParamsConfig === void 0 && (config.dynamicConfig === "error" || config.dynamicConfig === "force-static")) config.dynamicParamsConfig = false;
|
|
124
180
|
return config;
|
|
125
181
|
}
|
|
126
182
|
function resolveAppPageFetchCacheMode(options) {
|