@qzsy/vinext 0.1.12 → 0.1.81
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 +19 -5
- package/dist/build/inject-pregenerated-paths.d.ts +4 -0
- package/dist/build/inject-pregenerated-paths.js +18 -0
- 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 +11 -4
- package/dist/build/report.d.ts +2 -1
- package/dist/build/report.js +2 -1
- package/dist/build/run-prerender.d.ts +7 -0
- package/dist/build/run-prerender.js +9 -0
- package/dist/build/standalone.js +2 -0
- package/dist/check.d.ts +18 -0
- package/dist/check.js +77 -19
- package/dist/cli-dev-config.d.ts +12 -0
- package/dist/cli-dev-config.js +23 -0
- package/dist/cli.js +64 -28
- 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/cloudflare/deploy-config.d.ts +51 -0
- package/dist/cloudflare/deploy-config.js +153 -0
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.js +1 -1
- package/dist/cloudflare/project.d.ts +41 -0
- package/dist/cloudflare/project.js +243 -0
- package/dist/cloudflare/tpr.js +1 -1
- package/dist/config/config-matchers.js +14 -10
- package/dist/config/next-config.d.ts +6 -3
- package/dist/config/next-config.js +47 -1
- package/dist/config/server-external-packages.d.ts +4 -0
- package/dist/config/server-external-packages.js +91 -0
- package/dist/deploy.d.ts +2 -122
- package/dist/deploy.js +20 -793
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +70 -12
- package/dist/entries/app-rsc-manifest.js +8 -0
- package/dist/entries/pages-client-entry.d.ts +1 -0
- package/dist/entries/pages-client-entry.js +2 -1
- package/dist/entries/pages-server-entry.js +6 -2
- package/dist/image/image-adapters-virtual.d.ts +59 -0
- package/dist/image/image-adapters-virtual.js +50 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +160 -160
- package/dist/init-cloudflare.d.ts +43 -0
- package/dist/init-cloudflare.js +1000 -0
- package/dist/init-platform.d.ts +38 -0
- package/dist/init-platform.js +150 -0
- package/dist/init.d.ts +14 -37
- package/dist/init.js +205 -95
- 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/plugins/ast-scope.d.ts +16 -0
- package/dist/plugins/ast-scope.js +62 -0
- package/dist/plugins/ast-utils.js +3 -0
- package/dist/plugins/css-module-imports.d.ts +14 -0
- package/dist/plugins/css-module-imports.js +59 -0
- package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
- package/dist/plugins/ignore-dynamic-requests.js +530 -0
- package/dist/plugins/middleware-server-only.d.ts +8 -6
- package/dist/plugins/middleware-server-only.js +8 -7
- package/dist/plugins/optimize-imports.js +1 -1
- 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 +13 -2
- package/dist/routing/app-route-graph.js +116 -32
- package/dist/routing/app-router.d.ts +5 -0
- package/dist/routing/app-router.js +5 -0
- package/dist/routing/file-matcher.d.ts +8 -0
- package/dist/routing/file-matcher.js +10 -1
- package/dist/routing/pages-router.js +2 -2
- package/dist/server/app-browser-action-result.d.ts +2 -1
- package/dist/server/app-browser-action-result.js +5 -1
- package/dist/server/app-browser-entry.js +17 -12
- package/dist/server/app-browser-history-controller.d.ts +2 -1
- package/dist/server/app-browser-history-controller.js +6 -2
- 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.js +1 -0
- package/dist/server/app-browser-server-action-client.js +2 -3
- package/dist/server/app-browser-state.d.ts +1 -0
- package/dist/server/app-browser-state.js +3 -2
- package/dist/server/app-fallback-renderer.d.ts +3 -2
- package/dist/server/app-fallback-renderer.js +12 -7
- package/dist/server/app-middleware.d.ts +2 -3
- package/dist/server/app-middleware.js +3 -2
- package/dist/server/app-optimistic-routing.js +1 -1
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +12 -3
- package/dist/server/app-page-cache-finalizer.d.ts +1 -0
- package/dist/server/app-page-cache-finalizer.js +10 -3
- 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 +4 -1
- package/dist/server/app-page-dispatch.d.ts +11 -3
- package/dist/server/app-page-dispatch.js +55 -15
- package/dist/server/app-page-element-builder.d.ts +5 -1
- package/dist/server/app-page-element-builder.js +57 -20
- package/dist/server/app-page-head.d.ts +12 -0
- package/dist/server/app-page-head.js +42 -19
- package/dist/server/app-page-params.d.ts +2 -1
- package/dist/server/app-page-params.js +8 -1
- package/dist/server/app-page-probe.d.ts +1 -0
- package/dist/server/app-page-probe.js +6 -1
- 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.d.ts +4 -1
- package/dist/server/app-page-render.js +8 -3
- package/dist/server/app-page-request.d.ts +22 -1
- package/dist/server/app-page-request.js +89 -13
- package/dist/server/app-page-route-wiring.d.ts +6 -1
- package/dist/server/app-page-route-wiring.js +31 -15
- package/dist/server/app-page-search-params-observation.d.ts +4 -2
- package/dist/server/app-page-search-params-observation.js +11 -7
- package/dist/server/app-page-segment-state.js +2 -0
- package/dist/server/app-route-handler-dispatch.js +1 -0
- package/dist/server/app-route-handler-execution.js +7 -2
- package/dist/server/app-route-handler-response.js +1 -0
- package/dist/server/app-route-handler-runtime.js +1 -1
- package/dist/server/app-route-module-loader.d.ts +2 -0
- package/dist/server/app-route-module-loader.js +1 -0
- package/dist/server/app-router-entry.d.ts +12 -0
- package/dist/server/app-router-entry.js +22 -8
- package/dist/server/app-router-image-optimization.d.ts +37 -0
- package/dist/server/app-router-image-optimization.js +40 -0
- package/dist/server/app-rsc-errors.js +7 -1
- package/dist/server/app-rsc-handler.js +27 -14
- package/dist/server/app-rsc-route-matching.d.ts +7 -0
- package/dist/server/app-rsc-route-matching.js +36 -3
- package/dist/server/app-segment-config.d.ts +12 -0
- package/dist/server/app-segment-config.js +91 -5
- package/dist/server/app-server-action-execution.d.ts +5 -0
- package/dist/server/app-server-action-execution.js +106 -33
- package/dist/server/app-ssr-entry.js +12 -1
- package/dist/server/app-static-generation.d.ts +1 -0
- package/dist/server/app-static-generation.js +1 -0
- 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-response-headers.d.ts +19 -0
- package/dist/server/dev-response-headers.js +78 -0
- package/dist/server/dev-server.js +8 -15
- package/dist/server/dev-stack-sourcemap.d.ts +1 -1
- package/dist/server/dev-stack-sourcemap.js +1 -1
- package/dist/server/headers.d.ts +7 -15
- package/dist/server/headers.js +6 -15
- package/dist/server/image-optimization.d.ts +51 -1
- package/dist/server/image-optimization.js +52 -2
- package/dist/server/isr-cache.d.ts +1 -1
- package/dist/server/isr-cache.js +2 -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-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-page-data.d.ts +23 -1
- package/dist/server/pages-page-data.js +43 -24
- package/dist/server/pages-page-handler.d.ts +2 -1
- package/dist/server/pages-page-handler.js +10 -4
- package/dist/server/pages-request-pipeline.d.ts +2 -0
- package/dist/server/pages-request-pipeline.js +25 -1
- 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 +47 -25
- package/dist/server/request-log.d.ts +5 -14
- package/dist/server/request-log.js +7 -1
- package/dist/server/request-pipeline.js +1 -0
- package/dist/server/seed-cache.js +4 -4
- package/dist/server/server-action-logger.d.ts +39 -0
- package/dist/server/server-action-logger.js +104 -0
- package/dist/server/worker-utils.d.ts +2 -1
- package/dist/server/worker-utils.js +7 -1
- 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/error-boundary.d.ts +19 -1
- package/dist/shims/error-boundary.js +11 -1
- package/dist/shims/form.d.ts +3 -1
- package/dist/shims/form.js +37 -43
- package/dist/shims/headers.d.ts +9 -1
- package/dist/shims/headers.js +31 -6
- package/dist/shims/image-optimization-url.d.ts +4 -0
- package/dist/shims/image-optimization-url.js +33 -1
- package/dist/shims/image.js +46 -13
- 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 -5
- package/dist/shims/internal/hybrid-client-route-owner.js +9 -60
- package/dist/shims/internal/pages-router-components.d.ts +7 -0
- package/dist/shims/internal/pages-router-components.js +13 -0
- package/dist/shims/link.js +23 -16
- package/dist/shims/metadata.d.ts +3 -2
- package/dist/shims/metadata.js +8 -4
- package/dist/shims/navigation.js +4 -2
- package/dist/shims/root-params.d.ts +15 -1
- package/dist/shims/root-params.js +21 -1
- package/dist/shims/router.d.ts +2 -5
- package/dist/shims/router.js +41 -22
- package/dist/shims/server.js +3 -2
- package/dist/typegen.js +6 -5
- 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/path.d.ts +2 -1
- package/dist/utils/path.js +1 -1
- package/dist/utils/project.d.ts +9 -1
- package/dist/utils/project.js +21 -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 +29 -23
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +0 -4
- /package/dist/{cloudflare → packages/cloudflare}/src/utils/cache-control-metadata.js +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ImageConfig } from "./image-optimization.js";
|
|
2
|
+
|
|
3
|
+
//#region src/server/app-router-image-optimization.d.ts
|
|
4
|
+
type AssetFetcher = {
|
|
5
|
+
fetch(request: Request): Promise<Response> | Response;
|
|
6
|
+
};
|
|
7
|
+
type ImagesBinding = {
|
|
8
|
+
input(stream: ReadableStream): {
|
|
9
|
+
transform(options: Record<string, unknown>): {
|
|
10
|
+
output(options: {
|
|
11
|
+
format: string;
|
|
12
|
+
quality: number;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
response(): Response;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
type AppRouterImageOptimizationEnv = {
|
|
20
|
+
ASSETS?: AssetFetcher;
|
|
21
|
+
IMAGES?: ImagesBinding;
|
|
22
|
+
};
|
|
23
|
+
/** Build image security/size config from Vite `define` env vars baked at build time. */
|
|
24
|
+
declare function createImageConfigFromEnv(): ImageConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Serve `/_next/image` from the Worker ASSETS binding when available.
|
|
27
|
+
*
|
|
28
|
+
* The default App Router worker entry delegates here before the RSC handler so
|
|
29
|
+
* production requests do not fall through to the dev-style redirect path (which
|
|
30
|
+
* can emit http:// Locations behind TLS-terminating proxies).
|
|
31
|
+
*/
|
|
32
|
+
declare function handleAppRouterImageOptimizationRequest(request: Request, options: {
|
|
33
|
+
basePath: string;
|
|
34
|
+
env: AppRouterImageOptimizationEnv;
|
|
35
|
+
}): Promise<Response | null>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { AppRouterImageOptimizationEnv, createImageConfigFromEnv, handleAppRouterImageOptimizationRequest };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { stripBasePath } from "../utils/base-path.js";
|
|
2
|
+
import { cloneRequestWithUrl } from "./request-pipeline.js";
|
|
3
|
+
import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, handleImageOptimization, isImageOptimizationPath } from "./image-optimization.js";
|
|
4
|
+
//#region src/server/app-router-image-optimization.ts
|
|
5
|
+
/** Build image security/size config from Vite `define` env vars baked at build time. */
|
|
6
|
+
function createImageConfigFromEnv() {
|
|
7
|
+
return {
|
|
8
|
+
deviceSizes: JSON.parse(process.env.__VINEXT_IMAGE_DEVICE_SIZES ?? JSON.stringify(DEFAULT_DEVICE_SIZES)),
|
|
9
|
+
imageSizes: JSON.parse(process.env.__VINEXT_IMAGE_SIZES ?? JSON.stringify(DEFAULT_IMAGE_SIZES)),
|
|
10
|
+
qualities: JSON.parse(process.env.__VINEXT_IMAGE_QUALITIES ?? "null") ?? void 0,
|
|
11
|
+
dangerouslyAllowSVG: process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_SVG === "true",
|
|
12
|
+
dangerouslyAllowLocalIP: process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP === "true"
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Serve `/_next/image` from the Worker ASSETS binding when available.
|
|
17
|
+
*
|
|
18
|
+
* The default App Router worker entry delegates here before the RSC handler so
|
|
19
|
+
* production requests do not fall through to the dev-style redirect path (which
|
|
20
|
+
* can emit http:// Locations behind TLS-terminating proxies).
|
|
21
|
+
*/
|
|
22
|
+
async function handleAppRouterImageOptimizationRequest(request, options) {
|
|
23
|
+
const url = new URL(request.url);
|
|
24
|
+
const strippedPathname = stripBasePath(url.pathname, options.basePath);
|
|
25
|
+
if (!isImageOptimizationPath(strippedPathname) || !options.env.ASSETS) return null;
|
|
26
|
+
const imageRequest = strippedPathname === url.pathname ? request : cloneRequestWithUrl(request, new URL(`${strippedPathname}${url.search}`, url).href);
|
|
27
|
+
const imageConfig = createImageConfigFromEnv();
|
|
28
|
+
const allowedWidths = [...imageConfig.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...imageConfig.imageSizes ?? DEFAULT_IMAGE_SIZES];
|
|
29
|
+
const handlers = { fetchAsset: (path) => Promise.resolve(options.env.ASSETS.fetch(new Request(new URL(path, request.url)))) };
|
|
30
|
+
const imagesBinding = options.env.IMAGES;
|
|
31
|
+
if (imagesBinding) handlers.transformImage = async (body, { width, format, quality }) => {
|
|
32
|
+
return (await imagesBinding.input(body).transform(width > 0 ? { width } : {}).output({
|
|
33
|
+
format,
|
|
34
|
+
quality
|
|
35
|
+
})).response();
|
|
36
|
+
};
|
|
37
|
+
return handleImageOptimization(imageRequest, handlers, allowedWidths, imageConfig);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { createImageConfigFromEnv, handleAppRouterImageOptimizationRequest };
|
|
@@ -53,7 +53,13 @@ function createRscOnErrorHandler(options) {
|
|
|
53
53
|
}
|
|
54
54
|
if (options.requestInfo && options.errorContext && error) options.reportRequestError(error instanceof Error ? error : new Error(getThrownValueMessage(error)), options.requestInfo, options.errorContext);
|
|
55
55
|
if (hasDigest(error)) return String(error.digest);
|
|
56
|
-
if (
|
|
56
|
+
if (error) {
|
|
57
|
+
const digest = errorDigest(getThrownValueMessage(error) + getThrownValueStack(error));
|
|
58
|
+
if (error instanceof Error) try {
|
|
59
|
+
Object.assign(error, { digest });
|
|
60
|
+
} catch {}
|
|
61
|
+
return digest;
|
|
62
|
+
}
|
|
57
63
|
};
|
|
58
64
|
}
|
|
59
65
|
//#endregion
|
|
@@ -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, bufferRequestBodyForHeaderClone, cloneRequestWithHeaders, cloneRequestWithUrl, filterInternalHeaders, normalizeTrailingSlash, resolvePublicFileRoute } from "./request-pipeline.js";
|
|
@@ -10,15 +11,16 @@ 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
22
|
import { flattenErrorCauses } from "../utils/error-cause.js";
|
|
23
|
+
import { pickRootParams, setRootParams } from "../shims/root-params.js";
|
|
22
24
|
import { createServerActionNotFoundResponse, getServerActionNotFoundMessage } from "./server-action-not-found.js";
|
|
23
25
|
import { buildPageCacheTags } from "./implicit-tags.js";
|
|
24
26
|
import { buildPostMwRequestContext } from "./app-post-middleware-context.js";
|
|
@@ -111,7 +113,7 @@ 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);
|
|
@@ -149,10 +151,6 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
149
151
|
if (redirect) {
|
|
150
152
|
const destination = sanitizeDestination(redirectDestinationWithBasePath(redirect.destination, options.basePath));
|
|
151
153
|
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
154
|
return new Response(null, {
|
|
157
155
|
status: redirect.permanent ? 308 : 307,
|
|
158
156
|
headers: { Location: location }
|
|
@@ -175,7 +173,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
175
173
|
const middlewareResult = await options.runMiddleware({
|
|
176
174
|
cleanPathname,
|
|
177
175
|
context: middlewareContext,
|
|
178
|
-
isDataRequest,
|
|
176
|
+
isDataRequest: isMiddlewareDataRequest,
|
|
179
177
|
request: userlandRequest
|
|
180
178
|
});
|
|
181
179
|
if (middlewareResult.kind === "response") return applyConfigHeadersToMiddlewareRedirect(middlewareResult.response, {
|
|
@@ -208,7 +206,10 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
208
206
|
if (isImageOptimizationPath(cleanPathname)) {
|
|
209
207
|
const imageRedirect = resolveDevImageRedirect(url, [...options.imageConfig?.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...options.imageConfig?.imageSizes ?? DEFAULT_IMAGE_SIZES], options.imageConfig?.qualities, { isDev: options.isDev });
|
|
210
208
|
if (!imageRedirect) return new Response("Invalid image optimization parameters", { status: 400 });
|
|
211
|
-
return
|
|
209
|
+
return new Response(null, {
|
|
210
|
+
status: 302,
|
|
211
|
+
headers: { Location: imageRedirect }
|
|
212
|
+
});
|
|
212
213
|
}
|
|
213
214
|
if (options.handleMetadataRouteRequest) {
|
|
214
215
|
const metadataRouteResponse = await options.handleMetadataRouteRequest(cleanPathname);
|
|
@@ -266,6 +267,10 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
266
267
|
const failedProgressiveActionResult = progressiveActionFormState && "actionError" in progressiveActionFormState ? progressiveActionFormState : null;
|
|
267
268
|
const actionFailed = failedProgressiveActionResult !== null;
|
|
268
269
|
const actionError = failedProgressiveActionResult?.actionError;
|
|
270
|
+
const actionErrorDigest = actionError && typeof actionError === "object" && "digest" in actionError ? String(actionError.digest) : null;
|
|
271
|
+
const actionHttpFallbackStatus = actionErrorDigest ? parseNextHttpErrorDigest(actionErrorDigest)?.status ?? null : null;
|
|
272
|
+
const normalizedProgressiveActionError = actionHttpFallbackStatus === null || actionHttpFallbackStatus === 404 ? actionError : { digest: "NEXT_NOT_FOUND" };
|
|
273
|
+
if (actionFailed && middlewareContext.status === null && actionHttpFallbackStatus === null) middlewareContext.status = 500;
|
|
269
274
|
const serverActionResponse = isPostRequest && actionId && options.handleServerActionRequest ? await options.handleServerActionRequest({
|
|
270
275
|
actionId,
|
|
271
276
|
cleanPathname,
|
|
@@ -364,6 +369,15 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
364
369
|
}
|
|
365
370
|
if (pagesDataRequest) {
|
|
366
371
|
options.clearRequestContext();
|
|
372
|
+
if (options.runMiddleware && (middlewareContext.status === null || middlewareContext.status === 200 || middlewareContext.status === 404)) {
|
|
373
|
+
const response = buildNextDataNotFoundResponse();
|
|
374
|
+
const headers = new Headers(response.headers);
|
|
375
|
+
headers.set("x-nextjs-matched-path", matchPathname(canonicalPathname));
|
|
376
|
+
return new Response("{}", {
|
|
377
|
+
status: 200,
|
|
378
|
+
headers
|
|
379
|
+
});
|
|
380
|
+
}
|
|
367
381
|
return buildNextDataNotFoundResponse();
|
|
368
382
|
}
|
|
369
383
|
if (!match) {
|
|
@@ -425,7 +439,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
425
439
|
cleanPathname,
|
|
426
440
|
displayPathname: canonicalPathname,
|
|
427
441
|
formState,
|
|
428
|
-
actionError,
|
|
442
|
+
actionError: normalizedProgressiveActionError,
|
|
429
443
|
actionFailed,
|
|
430
444
|
handlerStart,
|
|
431
445
|
interceptionContext: interceptionContextHeader,
|
|
@@ -490,14 +504,13 @@ function createAppRscHandler(options) {
|
|
|
490
504
|
await options.ensureInstrumentation?.();
|
|
491
505
|
rawRequest = await bufferRequestBodyForHeaderClone(rawRequest);
|
|
492
506
|
const mwCtx = rawRequest.headers.get(VINEXT_MW_CTX_HEADER);
|
|
493
|
-
const hasDataRequestHeader = rawRequest.headers.get("x-nextjs-data") === "1";
|
|
494
507
|
const pagesDataUrl = new URL(rawRequest.url);
|
|
495
508
|
const pagesDataInScope = !options.basePath || hasBasePath(pagesDataUrl.pathname, options.basePath);
|
|
496
509
|
if (pagesDataInScope) pagesDataUrl.pathname = stripBasePath(pagesDataUrl.pathname, options.basePath);
|
|
497
510
|
const pagesDataCandidate = pagesDataInScope ? cloneRequestWithUrl(rawRequest, pagesDataUrl.toString()) : null;
|
|
498
511
|
const pagesDataNormalization = options.renderPagesFallback && pagesDataCandidate ? normalizePagesDataRequest(pagesDataCandidate, options.buildId) : null;
|
|
499
512
|
if (pagesDataNormalization?.notFoundResponse) return pagesDataNormalization.notFoundResponse;
|
|
500
|
-
const
|
|
513
|
+
const isPagesDataRequest = pagesDataNormalization?.isDataReq === true;
|
|
501
514
|
const prerenderRouteParamsPayload = readTrustedPrerenderRouteParams(rawRequest);
|
|
502
515
|
const filteredHeaders = filterInternalHeaders(rawRequest.headers);
|
|
503
516
|
if (mwCtx !== null) filteredHeaders.set(VINEXT_MW_CTX_HEADER, mwCtx);
|
|
@@ -521,7 +534,7 @@ function createAppRscHandler(options) {
|
|
|
521
534
|
const preMiddlewareRequestContext = requestContextFromRequest(request);
|
|
522
535
|
let response;
|
|
523
536
|
try {
|
|
524
|
-
response = await handleAppRscRequest(options, request, preMiddlewareRequestContext,
|
|
537
|
+
response = await handleAppRscRequest(options, request, preMiddlewareRequestContext, isPagesDataRequest, isPagesDataRequest, pagesDataRequest);
|
|
525
538
|
} catch (error) {
|
|
526
539
|
if (process.env.NODE_ENV !== "production") flattenErrorCauses(error);
|
|
527
540
|
throw error;
|
|
@@ -31,6 +31,8 @@ type AppRscInterceptForMatching = {
|
|
|
31
31
|
sourceMatchPattern?: string;
|
|
32
32
|
sourcePageSegments?: readonly string[];
|
|
33
33
|
interceptLayouts: readonly unknown[];
|
|
34
|
+
interceptLayoutSegments?: readonly (readonly string[])[];
|
|
35
|
+
interceptBranchSegments?: readonly string[];
|
|
34
36
|
__loadInterceptLayouts?: readonly (() => Promise<unknown>)[] | null;
|
|
35
37
|
page: unknown;
|
|
36
38
|
__pageLoader?: (() => Promise<unknown>) | null;
|
|
@@ -46,6 +48,8 @@ type AppRscSiblingInterceptForMatching = {
|
|
|
46
48
|
sourcePageSegments?: readonly string[];
|
|
47
49
|
slotId: string | null;
|
|
48
50
|
interceptLayouts: readonly unknown[];
|
|
51
|
+
interceptLayoutSegments?: readonly (readonly string[])[];
|
|
52
|
+
interceptBranchSegments?: readonly string[];
|
|
49
53
|
__loadInterceptLayouts?: readonly (() => Promise<unknown>)[] | null;
|
|
50
54
|
page: unknown;
|
|
51
55
|
__pageLoader?: (() => Promise<unknown>) | null;
|
|
@@ -59,6 +63,7 @@ type AppRscRouteForMatching = {
|
|
|
59
63
|
};
|
|
60
64
|
type AppRscInterceptMatch = AppRscInterceptLookupEntry & {
|
|
61
65
|
matchedParams: AppRscRouteParams;
|
|
66
|
+
sourceMatchedParams: AppRscRouteParams;
|
|
62
67
|
};
|
|
63
68
|
type AppRscInterceptLoadState = {
|
|
64
69
|
page: unknown;
|
|
@@ -74,6 +79,8 @@ type AppRscInterceptLookupEntry = {
|
|
|
74
79
|
sourceMatchPatternParts: string[] | null;
|
|
75
80
|
sourcePageSegments: readonly string[] | null;
|
|
76
81
|
interceptLayouts: readonly unknown[];
|
|
82
|
+
interceptLayoutSegments?: readonly (readonly string[])[];
|
|
83
|
+
interceptBranchSegments?: readonly string[];
|
|
77
84
|
__loadInterceptLayouts?: readonly (() => Promise<unknown>)[] | null;
|
|
78
85
|
page: unknown;
|
|
79
86
|
__pageLoader?: (() => Promise<unknown>) | null;
|
|
@@ -36,12 +36,13 @@ function createAppRscRouteMatcher(routes) {
|
|
|
36
36
|
const sourceRoute = routes[concreteSourceRouteIndex];
|
|
37
37
|
const matchedSourceParams = matchedSourceRoute && entry.sourceMatchPatternParts !== null ? matchedSourceRoute.params : sourceRoute ? matchAppRscRoutePattern(sourceParts, sourceRoute.patternParts) : null;
|
|
38
38
|
if (matchedSourceParams === null && entry.sourceMatchPatternParts === null) continue;
|
|
39
|
-
const sourceParams = matchedSourceParams ?? createRouteParams();
|
|
39
|
+
const sourceParams = matchedSourceParams && entry.sourceMatchPatternParts !== null ? pickPatternParams(matchedSourceParams, entry.sourceMatchPatternParts) : matchedSourceParams ?? createRouteParams();
|
|
40
40
|
return {
|
|
41
41
|
...entry,
|
|
42
42
|
page: entry.__loadState.page,
|
|
43
43
|
sourceRouteIndex: concreteSourceRouteIndex,
|
|
44
|
-
matchedParams: mergeMatchedParams(sourceParams, params)
|
|
44
|
+
matchedParams: mergeMatchedParams(sourceParams, params),
|
|
45
|
+
sourceMatchedParams: matchedSourceParams ?? createRouteParams()
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
return null;
|
|
@@ -64,6 +65,24 @@ function matchInterceptSource(sourceParts, entry) {
|
|
|
64
65
|
if (patternParts.length === 0) return true;
|
|
65
66
|
return matchRoutePatternPrefix(sourceParts, patternParts);
|
|
66
67
|
}
|
|
68
|
+
function interceptSegmentPrecedence(segment) {
|
|
69
|
+
if (!segment.startsWith(":")) return 0;
|
|
70
|
+
if (segment.endsWith("*")) return 3;
|
|
71
|
+
if (segment.endsWith("+")) return 2;
|
|
72
|
+
return 1;
|
|
73
|
+
}
|
|
74
|
+
function compareInterceptTargetPatterns(a, b) {
|
|
75
|
+
const sharedLength = Math.min(a.targetPatternParts.length, b.targetPatternParts.length);
|
|
76
|
+
for (let index = 0; index < sharedLength; index++) {
|
|
77
|
+
const aSegment = a.targetPatternParts[index];
|
|
78
|
+
const bSegment = b.targetPatternParts[index];
|
|
79
|
+
const precedence = interceptSegmentPrecedence(aSegment) - interceptSegmentPrecedence(bSegment);
|
|
80
|
+
if (precedence !== 0) return precedence;
|
|
81
|
+
if (aSegment !== bSegment) return aSegment.localeCompare(bSegment);
|
|
82
|
+
}
|
|
83
|
+
const lengthDifference = a.targetPatternParts.length - b.targetPatternParts.length;
|
|
84
|
+
return lengthDifference !== 0 ? lengthDifference : a.targetPattern.localeCompare(b.targetPattern);
|
|
85
|
+
}
|
|
67
86
|
function createInterceptLookup(routes) {
|
|
68
87
|
const patternToIndex = new Map(routes.map((r, i) => [r.pattern, i]));
|
|
69
88
|
const interceptLookup = [];
|
|
@@ -85,6 +104,8 @@ function createInterceptLookup(routes) {
|
|
|
85
104
|
sourceMatchPatternParts,
|
|
86
105
|
sourcePageSegments: intercept.sourcePageSegments ?? null,
|
|
87
106
|
interceptLayouts: intercept.interceptLayouts,
|
|
107
|
+
interceptLayoutSegments: intercept.interceptLayoutSegments,
|
|
108
|
+
interceptBranchSegments: intercept.interceptBranchSegments,
|
|
88
109
|
__loadInterceptLayouts: intercept.__loadInterceptLayouts,
|
|
89
110
|
page: intercept.page,
|
|
90
111
|
__pageLoader: intercept.__pageLoader,
|
|
@@ -110,6 +131,8 @@ function createInterceptLookup(routes) {
|
|
|
110
131
|
sourceMatchPatternParts,
|
|
111
132
|
sourcePageSegments: intercept.sourcePageSegments ?? null,
|
|
112
133
|
interceptLayouts: intercept.interceptLayouts,
|
|
134
|
+
interceptLayoutSegments: intercept.interceptLayoutSegments,
|
|
135
|
+
interceptBranchSegments: intercept.interceptBranchSegments,
|
|
113
136
|
__loadInterceptLayouts: intercept.__loadInterceptLayouts,
|
|
114
137
|
page: intercept.page,
|
|
115
138
|
__pageLoader: intercept.__pageLoader,
|
|
@@ -122,7 +145,7 @@ function createInterceptLookup(routes) {
|
|
|
122
145
|
});
|
|
123
146
|
}
|
|
124
147
|
}
|
|
125
|
-
return interceptLookup;
|
|
148
|
+
return interceptLookup.sort(compareInterceptTargetPatterns);
|
|
126
149
|
}
|
|
127
150
|
function matchAppRscRoutePattern(urlParts, patternParts) {
|
|
128
151
|
return matchRoutePattern(urlParts, patternParts);
|
|
@@ -130,5 +153,15 @@ function matchAppRscRoutePattern(urlParts, patternParts) {
|
|
|
130
153
|
function mergeMatchedParams(sourceParams, targetParams) {
|
|
131
154
|
return Object.assign(createRouteParams(), sourceParams, targetParams);
|
|
132
155
|
}
|
|
156
|
+
function pickPatternParams(params, patternParts) {
|
|
157
|
+
const picked = createRouteParams();
|
|
158
|
+
for (const patternPart of patternParts) {
|
|
159
|
+
if (!patternPart.startsWith(":")) continue;
|
|
160
|
+
const paramName = patternPart.endsWith("+") || patternPart.endsWith("*") ? patternPart.slice(1, -1) : patternPart.slice(1);
|
|
161
|
+
const value = params[paramName];
|
|
162
|
+
if (value !== void 0) picked[paramName] = value;
|
|
163
|
+
}
|
|
164
|
+
return picked;
|
|
165
|
+
}
|
|
133
166
|
//#endregion
|
|
134
167
|
export { SIBLING_PAGE_INTERCEPT_SLOT_KEY, createAppRscRouteMatcher, matchAppRscRoutePattern };
|
|
@@ -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,10 +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)[];
|
|
35
|
+
parallelSegments?: readonly (AppRouteSegmentConfigModule | null | undefined)[];
|
|
36
|
+
routeSegments?: readonly string[];
|
|
25
37
|
};
|
|
26
38
|
/**
|
|
27
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,18 +112,22 @@ 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;
|
|
60
121
|
let hasOnlyNoStore = false;
|
|
61
122
|
let hasParentDefaultNoStore = false;
|
|
123
|
+
let hasForceDynamic = false;
|
|
62
124
|
for (const segment of segments) {
|
|
63
125
|
if (!segment) continue;
|
|
64
|
-
if (isRouteSegmentDynamic(segment.dynamic))
|
|
126
|
+
if (isRouteSegmentDynamic(segment.dynamic)) {
|
|
127
|
+
if (segment.dynamic === "force-dynamic") hasForceDynamic = true;
|
|
128
|
+
config.dynamicConfig = hasForceDynamic ? "force-dynamic" : segment.dynamic;
|
|
129
|
+
}
|
|
65
130
|
if (isRouteSegmentRuntime(segment.runtime)) config.runtime = segment.runtime;
|
|
66
|
-
if (segment.dynamicParams === false) config.dynamicParamsConfig = false;
|
|
67
|
-
else if (segment.dynamicParams === true && config.dynamicParamsConfig !== false) config.dynamicParamsConfig = true;
|
|
68
131
|
if (isRouteSegmentFetchCache(segment.fetchCache)) {
|
|
69
132
|
const fetchCache = segment.fetchCache;
|
|
70
133
|
if (hasParentDefaultNoStore && (fetchCache === "auto" || isCacheFetchCacheMode(fetchCache))) throw new Error(describeFetchCacheConflict(fetchCache));
|
|
@@ -72,7 +135,7 @@ function resolveAppPageSegmentConfig(options) {
|
|
|
72
135
|
if (fetchCache === "force-no-store") hasForceNoStore = true;
|
|
73
136
|
if (fetchCache === "only-cache") hasOnlyCache = true;
|
|
74
137
|
if (fetchCache === "only-no-store") hasOnlyNoStore = true;
|
|
75
|
-
if (
|
|
138
|
+
if (hasForceCache && hasForceNoStore || !hasForceCache && !hasForceNoStore && hasOnlyCache && hasOnlyNoStore) throw new Error(describeFetchCacheConflict(fetchCache));
|
|
76
139
|
if (fetchCache === "default-no-store") hasParentDefaultNoStore = true;
|
|
77
140
|
if (hasForceCache) config.fetchCache = "force-cache";
|
|
78
141
|
else if (hasForceNoStore) config.fetchCache = "force-no-store";
|
|
@@ -82,6 +145,30 @@ function resolveAppPageSegmentConfig(options) {
|
|
|
82
145
|
}
|
|
83
146
|
config.revalidateSeconds = resolveRevalidateSeconds(config.revalidateSeconds, segment.revalidate);
|
|
84
147
|
}
|
|
148
|
+
for (const segment of parallelSegments) {
|
|
149
|
+
if (!segment) continue;
|
|
150
|
+
if (segment.dynamic === "force-dynamic") {
|
|
151
|
+
hasForceDynamic = true;
|
|
152
|
+
config.dynamicConfig = "force-dynamic";
|
|
153
|
+
} else if (config.dynamicConfig === void 0 && isRouteSegmentDynamic(segment.dynamic)) config.dynamicConfig = segment.dynamic;
|
|
154
|
+
if (config.runtime === void 0 && isRouteSegmentRuntime(segment.runtime)) config.runtime = segment.runtime;
|
|
155
|
+
if (isRouteSegmentFetchCache(segment.fetchCache)) {
|
|
156
|
+
const fetchCache = segment.fetchCache;
|
|
157
|
+
if (hasParentDefaultNoStore && (fetchCache === "auto" || isCacheFetchCacheMode(fetchCache))) throw new Error(describeFetchCacheConflict(fetchCache));
|
|
158
|
+
if (fetchCache === "force-cache") hasForceCache = true;
|
|
159
|
+
if (fetchCache === "force-no-store") hasForceNoStore = true;
|
|
160
|
+
if (fetchCache === "only-cache") hasOnlyCache = true;
|
|
161
|
+
if (fetchCache === "only-no-store") hasOnlyNoStore = true;
|
|
162
|
+
if (hasForceCache && hasForceNoStore || !hasForceCache && !hasForceNoStore && hasOnlyCache && hasOnlyNoStore) throw new Error(describeFetchCacheConflict(fetchCache));
|
|
163
|
+
if (fetchCache === "default-no-store") hasParentDefaultNoStore = true;
|
|
164
|
+
if (hasForceCache) config.fetchCache = "force-cache";
|
|
165
|
+
else if (hasForceNoStore) config.fetchCache = "force-no-store";
|
|
166
|
+
else if (hasOnlyCache) config.fetchCache = "only-cache";
|
|
167
|
+
else if (hasOnlyNoStore) config.fetchCache = "only-no-store";
|
|
168
|
+
else if (config.fetchCache === void 0) config.fetchCache = fetchCache;
|
|
169
|
+
}
|
|
170
|
+
config.revalidateSeconds = resolveRevalidateSeconds(config.revalidateSeconds, segment.revalidate);
|
|
171
|
+
}
|
|
85
172
|
for (const segment of [options.page, ...options.parallelPages ?? []]) {
|
|
86
173
|
if (!segment) continue;
|
|
87
174
|
config.dynamicStaleTimeSeconds = resolveDynamicStaleTimeSeconds(config.dynamicStaleTimeSeconds, segment.unstable_dynamicStaleTime);
|
|
@@ -90,7 +177,6 @@ function resolveAppPageSegmentConfig(options) {
|
|
|
90
177
|
if (config.fetchCache === void 0) {
|
|
91
178
|
if (config.dynamicConfig === "error") config.fetchCache = "only-cache";
|
|
92
179
|
}
|
|
93
|
-
if (config.dynamicParamsConfig === void 0 && (config.dynamicConfig === "error" || config.dynamicConfig === "force-static")) config.dynamicParamsConfig = false;
|
|
94
180
|
return config;
|
|
95
181
|
}
|
|
96
182
|
function resolveAppPageFetchCacheMode(options) {
|
|
@@ -29,6 +29,7 @@ type AppServerActionReturnValue = {
|
|
|
29
29
|
type AppServerActionRoute = {
|
|
30
30
|
page?: unknown;
|
|
31
31
|
pattern: string;
|
|
32
|
+
rootParamNames?: readonly string[];
|
|
32
33
|
routeHandler?: unknown;
|
|
33
34
|
routeSegments?: readonly string[];
|
|
34
35
|
params?: readonly string[] | null;
|
|
@@ -76,6 +77,7 @@ type AppServerActionMatch<TRoute extends AppServerActionRoute> = {
|
|
|
76
77
|
};
|
|
77
78
|
type AppServerActionIntercept<TPage = unknown> = {
|
|
78
79
|
matchedParams: AppPageParams;
|
|
80
|
+
sourceMatchedParams?: AppPageParams;
|
|
79
81
|
page: TPage;
|
|
80
82
|
slotId?: string | null;
|
|
81
83
|
slotKey: string;
|
|
@@ -91,6 +93,8 @@ type BuildServerActionPageElementOptions<TRoute extends AppServerActionRoute, TI
|
|
|
91
93
|
route: TRoute;
|
|
92
94
|
searchParams: URLSearchParams;
|
|
93
95
|
renderMode: AppRscRenderMode;
|
|
96
|
+
observeMetadataSearchParamsAccess?: boolean;
|
|
97
|
+
observePageSearchParamsAccess?: boolean;
|
|
94
98
|
};
|
|
95
99
|
type AppServerActionRscModel<TElement> = {
|
|
96
100
|
/**
|
|
@@ -148,6 +152,7 @@ type HandleServerActionRscRequestOptions<TElement, TRoute extends AppServerActio
|
|
|
148
152
|
createRscOnErrorHandler: (request: Request, pathname: string, pattern: string) => (error: unknown) => unknown;
|
|
149
153
|
createTemporaryReferenceSet: () => TTemporaryReferences;
|
|
150
154
|
decodeReply: (body: string | FormData, options: DecodeServerActionReplyOptions<TTemporaryReferences>) => Promise<unknown[]> | unknown[];
|
|
155
|
+
draftModeSecret: string;
|
|
151
156
|
/**
|
|
152
157
|
* Hydrate a route's lazy page/route-handler modules before reading
|
|
153
158
|
* `route.page` / `route.routeHandler` on action redirect targets and
|