vinext 1.0.0 → 1.1.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 +72 -1
- package/THIRD_PARTY_LICENSES.md +26 -0
- package/dist/build/app-page-static-eligibility.d.ts +15 -0
- package/dist/build/app-page-static-eligibility.js +82 -0
- package/dist/build/lifecycle.js +10 -10
- package/dist/build/pages-client-assets-module.js +6 -1
- package/dist/build/precompress.js +1 -1
- package/dist/build/prerender-paths.js +6 -85
- package/dist/build/prerender.d.ts +8 -1
- package/dist/build/prerender.js +167 -46
- package/dist/build/run-prerender.js +4 -3
- package/dist/build/server-entry.d.ts +2 -0
- package/dist/build/server-entry.js +7 -1
- package/dist/build/server-manifest.d.ts +7 -0
- package/dist/build/server-manifest.js +11 -1
- package/dist/cache/cache-adapters-virtual.d.ts +7 -1
- package/dist/cache/cache-adapters-virtual.js +3 -3
- package/dist/client/browser-globals.d.ts +4 -0
- package/dist/client/browser-globals.js +5 -0
- package/dist/client/navigation-runtime.d.ts +11 -1
- package/dist/client/navigation-runtime.js +3 -3
- package/dist/config/config-matchers.js +3 -1
- package/dist/config/dotenv.js +14 -3
- package/dist/config/next-config.d.ts +7 -0
- package/dist/config/next-config.js +18 -3
- package/dist/entries/app-rsc-entry.d.ts +2 -0
- package/dist/entries/app-rsc-entry.js +67 -45
- package/dist/index.d.ts +4 -1
- package/dist/index.js +200 -100
- package/dist/init-cloudflare.d.ts +1 -1
- package/dist/init-cloudflare.js +6 -6
- package/dist/init-platform.js +1 -1
- package/dist/init.js +4 -2
- package/dist/plugins/cache-flight-codec.d.ts +19 -0
- package/dist/plugins/cache-flight-codec.js +68 -0
- package/dist/plugins/commonjs-esm-facade.d.ts +35 -0
- package/dist/plugins/commonjs-esm-facade.js +80 -0
- package/dist/plugins/commonjs-syntax.d.ts +16 -0
- package/dist/plugins/commonjs-syntax.js +22 -0
- package/dist/plugins/fonts.d.ts +8 -11
- package/dist/plugins/fonts.js +71 -34
- package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
- package/dist/plugins/ignore-dynamic-requests.js +54 -3
- package/dist/plugins/import-meta-url.js +6 -6
- package/dist/plugins/og-asset-ownership.d.ts +2 -0
- package/dist/plugins/og-asset-ownership.js +24 -13
- package/dist/plugins/og-assets.d.ts +18 -0
- package/dist/plugins/og-assets.js +50 -8
- package/dist/plugins/og-harfbuzz.js +38 -27
- package/dist/plugins/optimize-imports.js +2 -1
- package/dist/plugins/require-context.d.ts +1 -0
- package/dist/plugins/require-context.js +28 -1
- package/dist/plugins/scan-build-css.d.ts +12 -0
- package/dist/plugins/scan-build-css.js +39 -0
- package/dist/plugins/strip-server-exports.d.ts +2 -0
- package/dist/plugins/strip-server-exports.js +3 -1
- package/dist/plugins/transform-result.d.ts +18 -0
- package/dist/plugins/transform-result.js +23 -2
- package/dist/plugins/typeof-window.d.ts +10 -0
- package/dist/plugins/typeof-window.js +33 -9
- package/dist/routing/app-route-graph.d.ts +0 -1
- package/dist/routing/app-route-graph.js +2 -4
- package/dist/routing/app-route-ids.d.ts +3 -0
- package/dist/routing/app-route-ids.js +6 -0
- package/dist/routing/file-matcher.d.ts +1 -0
- package/dist/routing/file-matcher.js +1 -1
- package/dist/server/api-handler.js +17 -7
- package/dist/server/app-bfcache-id.d.ts +1 -0
- package/dist/server/app-bfcache-id.js +7 -1
- package/dist/server/app-bfcache-identity.js +1 -2
- package/dist/server/app-browser-entry.js +15 -9
- package/dist/server/app-browser-history-controller.d.ts +2 -0
- package/dist/server/app-browser-history-controller.js +8 -0
- package/dist/server/app-browser-hydration.d.ts +1 -1
- package/dist/server/app-browser-hydration.js +2 -2
- package/dist/server/app-browser-interception-context.js +26 -2
- package/dist/server/app-browser-navigation-controller.d.ts +7 -1
- package/dist/server/app-browser-navigation-controller.js +94 -11
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-stream.d.ts +1 -1
- package/dist/server/app-fallback-renderer.d.ts +2 -0
- package/dist/server/app-fallback-renderer.js +1 -0
- package/dist/server/app-history-state.d.ts +3 -1
- package/dist/server/app-history-state.js +9 -5
- package/dist/server/app-middleware.js +2 -1
- package/dist/server/app-optimistic-routing.js +1 -1
- package/dist/server/app-page-boundary-render.d.ts +5 -0
- package/dist/server/app-page-boundary-render.js +6 -4
- package/dist/server/app-page-cache-finalizer.d.ts +11 -0
- package/dist/server/app-page-cache-finalizer.js +41 -7
- package/dist/server/app-page-cache-render.d.ts +18 -0
- package/dist/server/app-page-cache-render.js +65 -44
- package/dist/server/app-page-cache.d.ts +5 -0
- package/dist/server/app-page-cache.js +27 -7
- package/dist/server/app-page-dispatch.d.ts +9 -1
- package/dist/server/app-page-dispatch.js +47 -30
- package/dist/server/app-page-element-builder.d.ts +7 -0
- package/dist/server/app-page-element-builder.js +27 -42
- package/dist/server/app-page-execution.d.ts +15 -12
- package/dist/server/app-page-execution.js +30 -40
- package/dist/server/app-page-head.d.ts +5 -0
- package/dist/server/app-page-head.js +9 -3
- package/dist/server/app-page-probe.d.ts +0 -109
- package/dist/server/app-page-probe.js +3 -136
- package/dist/server/app-page-render-identity.d.ts +0 -1
- package/dist/server/app-page-render-identity.js +1 -1
- package/dist/server/app-page-render-observation.js +2 -2
- package/dist/server/app-page-render.d.ts +13 -5
- package/dist/server/app-page-render.js +219 -118
- package/dist/server/app-page-request.d.ts +0 -1
- package/dist/server/app-page-request.js +1 -2
- package/dist/server/app-page-response.d.ts +4 -3
- package/dist/server/app-page-response.js +4 -3
- package/dist/server/app-page-route-wiring.d.ts +17 -5
- package/dist/server/app-page-route-wiring.js +55 -33
- package/dist/server/app-page-rsc-render-status.d.ts +48 -0
- package/dist/server/app-page-rsc-render-status.js +54 -0
- package/dist/server/app-page-search-params-observation.js +1 -1
- package/dist/server/app-page-stream.d.ts +15 -8
- package/dist/server/app-page-stream.js +7 -1
- package/dist/server/app-page-tracing.js +2 -1
- package/dist/server/app-pages-bridge.js +3 -2
- package/dist/server/app-render-abort-error.d.ts +3 -0
- package/dist/server/app-render-abort-error.js +8 -0
- package/dist/server/app-request-stage-dispatch.js +1 -1
- package/dist/server/app-request-stage-independent-entry.js +8 -11
- package/dist/server/app-response-header-provenance.d.ts +2 -0
- package/dist/server/app-response-header-provenance.js +10 -4
- package/dist/server/app-route-handler-cache.d.ts +2 -1
- package/dist/server/app-route-handler-cache.js +11 -7
- package/dist/server/app-route-handler-dispatch.js +11 -4
- package/dist/server/app-route-handler-execution.d.ts +9 -1
- package/dist/server/app-route-handler-execution.js +28 -13
- package/dist/server/app-route-handler-policy.js +2 -2
- package/dist/server/app-route-handler-response.d.ts +1 -1
- package/dist/server/app-route-handler-response.js +14 -5
- package/dist/server/app-router-entry.d.ts +2 -1
- package/dist/server/app-router-entry.js +8 -12
- package/dist/server/app-rsc-errors.d.ts +0 -1
- package/dist/server/app-rsc-errors.js +2 -6
- package/dist/server/app-rsc-handler.d.ts +5 -0
- package/dist/server/app-rsc-handler.js +229 -102
- package/dist/server/app-rsc-request-normalization.d.ts +4 -2
- package/dist/server/app-rsc-request-normalization.js +7 -4
- package/dist/server/app-rsc-response-finalizer.js +4 -1
- package/dist/server/app-rsc-response-stage.d.ts +1 -1
- package/dist/server/app-rsc-response-stage.js +6 -4
- package/dist/server/app-rsc-route-matching.d.ts +9 -1
- package/dist/server/app-rsc-route-matching.js +37 -20
- package/dist/server/app-server-action-execution.d.ts +2 -1
- package/dist/server/app-server-action-execution.js +1 -1
- package/dist/server/app-ssr-entry.d.ts +3 -2
- package/dist/server/app-ssr-entry.js +9 -7
- package/dist/server/app-ssr-search-params-gate.js +1 -1
- package/dist/server/app-ssr-stream.d.ts +6 -1
- package/dist/server/app-ssr-stream.js +35 -16
- package/dist/server/app-worker-stages.d.ts +2 -2
- package/dist/server/app-worker-stages.js +3 -3
- package/dist/server/cache-control.js +3 -11
- package/dist/server/cacheability-request.js +56 -52
- package/dist/server/config-headers.js +3 -1
- package/dist/server/dev-server.js +23 -5
- package/dist/server/headers.d.ts +16 -0
- package/dist/server/headers.js +19 -1
- package/dist/server/http-error-responses.js +1 -0
- package/dist/server/image-optimization.d.ts +16 -0
- package/dist/server/image-optimization.js +26 -6
- package/dist/server/isr-cache.d.ts +2 -0
- package/dist/server/isr-cache.js +8 -3
- package/dist/server/metadata-route-response.js +94 -37
- package/dist/server/middleware-matcher-pattern.js +8 -4
- package/dist/server/middleware-response-headers.js +2 -0
- package/dist/server/multi-stage.d.ts +8 -0
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/node-response-signal.d.ts +16 -0
- package/dist/server/node-response-signal.js +26 -0
- package/dist/server/open-redirect.d.ts +47 -0
- package/dist/server/open-redirect.js +74 -1
- package/dist/server/pages-api-route.js +8 -2
- package/dist/server/pages-asset-tags.d.ts +1 -0
- package/dist/server/pages-asset-tags.js +73 -22
- package/dist/server/pages-client-assets.d.ts +2 -0
- package/dist/server/pages-page-data.d.ts +6 -1
- package/dist/server/pages-page-data.js +71 -65
- package/dist/server/pages-page-handler.js +50 -15
- package/dist/server/pages-page-response.js +3 -1
- package/dist/server/pages-request-pipeline.d.ts +2 -1
- package/dist/server/pages-request-pipeline.js +20 -5
- package/dist/server/pages-request-stage-entry.js +14 -8
- package/dist/server/prerender-manifest.d.ts +6 -0
- package/dist/server/prerender-manifest.js +1 -1
- package/dist/server/prod-server.d.ts +8 -7
- package/dist/server/prod-server.js +152 -78
- package/dist/server/request-pipeline.d.ts +20 -8
- package/dist/server/request-pipeline.js +21 -7
- package/dist/server/response-compression.d.ts +43 -0
- package/dist/server/response-compression.js +111 -0
- package/dist/server/response-stage-cacheability.js +1 -1
- package/dist/server/seed-cache.js +10 -7
- package/dist/server/socket-error-backstop.d.ts +14 -0
- package/dist/server/socket-error-backstop.js +27 -4
- package/dist/server/worker-revalidation-context.d.ts +2 -1
- package/dist/server/worker-revalidation-context.js +1 -0
- package/dist/server/workers-tracing.d.ts +17 -0
- package/dist/server/workers-tracing.js +48 -8
- package/dist/shims/cache-adapter-instantiate.d.ts +50 -0
- package/dist/shims/cache-adapter-instantiate.js +118 -0
- package/dist/shims/cache-callable-runtime.d.ts +2 -40
- package/dist/shims/cache-callable-runtime.js +50 -168
- package/dist/shims/cache-flight-arguments.d.ts +22 -0
- package/dist/shims/cache-flight-arguments.js +56 -0
- package/dist/shims/cache-request-state.d.ts +18 -14
- package/dist/shims/cache-request-state.js +33 -21
- package/dist/shims/cache-runtime.d.ts +6 -19
- package/dist/shims/cache-runtime.js +168 -226
- package/dist/shims/cache.d.ts +3 -2
- package/dist/shims/cache.js +8 -5
- package/dist/shims/cacheability-classification.d.ts +8 -1
- package/dist/shims/cacheability-classification.js +2 -2
- package/dist/shims/cdn-cache.d.ts +10 -1
- package/dist/shims/cdn-cache.js +16 -9
- package/dist/shims/error-boundary-navigation.d.ts +7 -0
- package/dist/shims/error-boundary-navigation.js +19 -1
- package/dist/shims/error-boundary.d.ts +10 -10
- package/dist/shims/error-boundary.js +26 -7
- package/dist/shims/error.d.ts +4 -18
- package/dist/shims/error.js +17 -10
- package/dist/shims/error.react-server.d.ts +4 -6
- package/dist/shims/error.react-server.js +4 -1
- package/dist/shims/fetch-cache.d.ts +6 -0
- package/dist/shims/fetch-cache.js +23 -4
- package/dist/shims/form.js +1 -1
- package/dist/shims/headers.d.ts +19 -69
- package/dist/shims/headers.js +82 -183
- package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -2
- package/dist/shims/internal/app-page-props-cache-key.js +24 -15
- package/dist/shims/internal/cache-context-accessor.d.ts +16 -0
- package/dist/shims/internal/cache-context-accessor.js +15 -0
- package/dist/shims/internal/headers-state.d.ts +73 -0
- package/dist/shims/internal/headers-state.js +157 -0
- package/dist/shims/metadata.js +3 -3
- package/dist/shims/navigation-errors.d.ts +6 -0
- package/dist/shims/navigation-errors.js +11 -1
- package/dist/shims/navigation.d.ts +7 -0
- package/dist/shims/navigation.js +16 -6
- package/dist/shims/request-context.d.ts +9 -0
- package/dist/shims/request-state-types.d.ts +2 -1
- package/dist/shims/root-params.js +1 -1
- package/dist/shims/server.js +52 -2
- package/dist/shims/thenable-params.d.ts +4 -0
- package/dist/shims/thenable-params.js +25 -3
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/utils/encode-cache-tag.d.ts +1 -0
- package/dist/utils/encode-cache-tag.js +11 -1
- package/dist/utils/mdx-scan.d.ts +5 -0
- package/dist/utils/mdx-scan.js +8 -1
- package/dist/utils/regex-safety.d.ts +10 -0
- package/dist/utils/regex-safety.js +70 -18
- package/dist/utils/vite-cli-invocation.js +8 -1
- package/package.json +8 -4
- package/dist/server/metadata-route-cache-policy.d.ts +0 -5
- package/dist/server/metadata-route-cache-policy.js +0 -6
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { isrCacheControl } from "./isr-cache.js";
|
|
1
|
+
import { isrCacheControl, resolveRouteExpireSeconds } from "./isr-cache.js";
|
|
2
2
|
import { makeThenableParams } from "../shims/thenable-params.js";
|
|
3
3
|
import { applyRouteHandlerMiddlewareContext, assertSupportedAppRouteHandlerResponse, buildAppRouteCacheValue, buildRouteHandlerCachedResponse } from "./app-route-handler-response.js";
|
|
4
4
|
import { markKnownDynamicAppRoute } from "./app-route-handler-runtime.js";
|
|
5
5
|
import { resolveAppRouteHandlerSpecialError } from "./app-route-handler-policy.js";
|
|
6
|
-
import { runAppRouteHandler, traceAppRouteHandlerExecution } from "./app-route-handler-execution.js";
|
|
6
|
+
import { completeAppRouteHandlerResponse, runAppRouteHandler, traceAppRouteHandlerExecution } from "./app-route-handler-execution.js";
|
|
7
7
|
//#region src/server/app-route-handler-cache.ts
|
|
8
8
|
const EMPTY_PARAMS = Object.freeze({});
|
|
9
9
|
function getCachedAppRouteValue(entry) {
|
|
@@ -64,17 +64,21 @@ async function readAppRouteHandlerCacheResponse(options) {
|
|
|
64
64
|
options.setNavigationContext(null);
|
|
65
65
|
}
|
|
66
66
|
if ("specialError" in tracedResult) return;
|
|
67
|
-
const { dynamicUsedInHandler, response } = tracedResult.handlerResult;
|
|
67
|
+
const { dynamicUsedInHandler, response, didAccessDynamicRequest } = tracedResult.handlerResult;
|
|
68
68
|
assertSupportedAppRouteHandlerResponse(response);
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
const completed = await completeAppRouteHandlerResponse(response);
|
|
70
|
+
const lateDynamicUsage = options.consumeDynamicUsage();
|
|
71
|
+
const becameDynamic = dynamicUsedInHandler || lateDynamicUsage || didAccessDynamicRequest();
|
|
72
|
+
if (!completed.completed || becameDynamic || response.headers.has("set-cookie")) {
|
|
73
|
+
completed.response.body?.cancel().catch(() => {});
|
|
74
|
+
if (becameDynamic) markKnownDynamicAppRoute(options.routePattern);
|
|
71
75
|
options.isrDebug?.("route regen skipped (dynamic usage)", options.cleanPathname);
|
|
72
76
|
return;
|
|
73
77
|
}
|
|
74
78
|
const routeTags = options.buildPageCacheTags(options.cleanPathname, options.getCollectedFetchTags());
|
|
75
|
-
const routeCacheValue = await buildAppRouteCacheValue(response);
|
|
79
|
+
const routeCacheValue = await buildAppRouteCacheValue(completed.response, response.headers.get("Cache-Control") ?? void 0);
|
|
76
80
|
await options.isrSet(routeKey, routeCacheValue, {
|
|
77
|
-
cacheControl: isrCacheControl(options.revalidateSeconds, { expireSeconds: options.expireSeconds }),
|
|
81
|
+
cacheControl: isrCacheControl(options.revalidateSeconds === Infinity ? false : options.revalidateSeconds, { expireSeconds: resolveRouteExpireSeconds(options.revalidateSeconds, options.expireSeconds) }),
|
|
78
82
|
tags: routeTags
|
|
79
83
|
});
|
|
80
84
|
options.isrDebug?.("route regen complete", routeKey);
|
|
@@ -5,15 +5,16 @@ import { reportRequestError } from "./instrumentation.js";
|
|
|
5
5
|
import { beginRouteCacheability, getRouteCacheabilityDynamicReason } from "../shims/cacheability-classification.js";
|
|
6
6
|
import { applyCdnResponseBuildIdentityHeaders } from "./cache-control.js";
|
|
7
7
|
import { isOnDemandRevalidateRequest } from "./revalidation-request.js";
|
|
8
|
-
import {
|
|
8
|
+
import { markDynamicUsage } from "../shims/internal/headers-state.js";
|
|
9
|
+
import { consumeDynamicUsage, getActiveDraftModeState, getAndClearPendingCookies, getDraftModeCookieHeader, isDraftModeRequest, setHeadersAccessPhase } from "../shims/headers.js";
|
|
9
10
|
import { _drainPendingRevalidations } from "../shims/cache-request-state.js";
|
|
10
11
|
import { ensureFetchPatch, getCollectedFetchTags, setCurrentFetchCacheMode, setCurrentFetchRevalidate, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault } from "../shims/fetch-cache.js";
|
|
12
|
+
import { resolveAppRouteHandlerFetchCacheMode } from "./app-segment-config.js";
|
|
11
13
|
import { setNavigationContext } from "../shims/navigation-context-state.js";
|
|
12
14
|
import { makeThenableParams } from "../shims/thenable-params.js";
|
|
13
15
|
import { traceResponseStart } from "./response-start-tracing.js";
|
|
14
16
|
import { buildPageCacheTags } from "./implicit-tags.js";
|
|
15
17
|
import { applyRouteHandlerMiddlewareContext, finalizeRouteHandlerResponse } from "./app-route-handler-response.js";
|
|
16
|
-
import { resolveAppRouteHandlerFetchCacheMode } from "./app-segment-config.js";
|
|
17
18
|
import "../shims/navigation.js";
|
|
18
19
|
import { isKnownDynamicAppRoute, isValidHTTPMethod } from "./app-route-handler-runtime.js";
|
|
19
20
|
import { getAppRouteHandlerRevalidateSeconds, hasAppRouteHandlerDefaultExport, hasNonStaticAppRouteHandlerMethods, resolveAppRouteHandlerMethod, shouldReadAppRouteHandlerCache } from "./app-route-handler-policy.js";
|
|
@@ -101,11 +102,12 @@ async function dispatchAppRouteHandlerImpl(options) {
|
|
|
101
102
|
method,
|
|
102
103
|
revalidateSeconds
|
|
103
104
|
});
|
|
104
|
-
const revalidateReason = isOnDemandRevalidateRequest(options.request.headers.get("x-prerender-revalidate")) ? "on-demand" : shouldReadRouteCache ? "stale" : void 0;
|
|
105
|
+
const revalidateReason = isOnDemandRevalidateRequest(options.request.headers.get("x-prerender-revalidate")) ? "on-demand" : shouldReadRouteCache && revalidateSeconds !== Infinity ? "stale" : void 0;
|
|
105
106
|
const fetchCacheMode = resolveAppRouteHandlerFetchCacheMode(handler);
|
|
106
107
|
setCurrentFetchCacheMode(fetchCacheMode);
|
|
107
108
|
setCurrentFetchRevalidate(configuredRevalidateSeconds);
|
|
108
109
|
setCurrentForceDynamicFetchDefault(handler.dynamic === "force-dynamic");
|
|
110
|
+
let isRevalidation = false;
|
|
109
111
|
if (shouldReadRouteCache && resolvedHandlerFn) {
|
|
110
112
|
const cachedRouteResponse = await readAppRouteHandlerCacheResponse({
|
|
111
113
|
basePath: options.basePath,
|
|
@@ -123,7 +125,11 @@ async function dispatchAppRouteHandlerImpl(options) {
|
|
|
123
125
|
isAutoHead,
|
|
124
126
|
appendResponseLink,
|
|
125
127
|
isrDebug: options.isrDebug,
|
|
126
|
-
isrGet
|
|
128
|
+
async isrGet(key) {
|
|
129
|
+
const entry = await options.isrGet(key);
|
|
130
|
+
isRevalidation = entry?.value.value?.kind === "APP_ROUTE";
|
|
131
|
+
return entry;
|
|
132
|
+
},
|
|
127
133
|
isrRouteKey: options.isrRouteKey,
|
|
128
134
|
isrSet: options.isrSet,
|
|
129
135
|
markDynamicUsage,
|
|
@@ -159,6 +165,7 @@ async function dispatchAppRouteHandlerImpl(options) {
|
|
|
159
165
|
}
|
|
160
166
|
if (resolvedHandlerFn) {
|
|
161
167
|
const response = await executeAppRouteHandler({
|
|
168
|
+
isRevalidation,
|
|
162
169
|
basePath: options.basePath,
|
|
163
170
|
bypassSharedCache: options.bypassSharedCache,
|
|
164
171
|
buildPageCacheTags(pathname, extraTags) {
|
|
@@ -4,7 +4,8 @@ import { NextRequest } from "../shims/server.js";
|
|
|
4
4
|
import { FrameworkSpan } from "./framework-tracer.js";
|
|
5
5
|
import { CachedRouteValue } from "../shims/cache-handler.js";
|
|
6
6
|
import { IsrWritePolicy } from "./isr-cache.js";
|
|
7
|
-
import { HeadersAccessPhase } from "../shims/headers.js";
|
|
7
|
+
import { HeadersAccessPhase } from "../shims/internal/headers-state.js";
|
|
8
|
+
import "../shims/headers.js";
|
|
8
9
|
import { RouteHandlerMiddlewareContext } from "./app-route-handler-response.js";
|
|
9
10
|
import { AppRouteHandlerModule } from "./app-route-handler-policy.js";
|
|
10
11
|
//#region src/server/app-route-handler-execution.d.ts
|
|
@@ -62,6 +63,11 @@ type RunAppRouteHandlerResult = {
|
|
|
62
63
|
dynamicUsedInHandler: boolean;
|
|
63
64
|
response: Response;
|
|
64
65
|
};
|
|
66
|
+
type CompletedAppRouteHandlerResponse = {
|
|
67
|
+
completed: boolean;
|
|
68
|
+
response: Response;
|
|
69
|
+
};
|
|
70
|
+
export declare function completeAppRouteHandlerResponse(response: Response): Promise<CompletedAppRouteHandlerResponse>;
|
|
65
71
|
export declare function applyDraftModeCachePolicy(response: Response, isDraftMode: boolean): Response;
|
|
66
72
|
type ExecuteAppRouteHandlerOptions = {
|
|
67
73
|
buildPageCacheTags: (pathname: string, extraTags: string[]) => string[];
|
|
@@ -78,6 +84,8 @@ type ExecuteAppRouteHandlerOptions = {
|
|
|
78
84
|
initialDraftModeCookie?: string | null;
|
|
79
85
|
isDraftMode?: boolean;
|
|
80
86
|
isProduction: boolean;
|
|
87
|
+
/** An existing entry may require foreground regeneration after hard expiry. */
|
|
88
|
+
isRevalidation?: boolean;
|
|
81
89
|
isrDebug?: AppRouteDebugLogger;
|
|
82
90
|
isrRouteKey: (pathname: string) => string;
|
|
83
91
|
isrSet: RouteHandlerCacheSetter;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { isFullyBufferedBody } from "./fully-buffered-response.js";
|
|
1
2
|
import { patternToNextFormat } from "../routing/route-validation.js";
|
|
2
3
|
import { frameworkTracer } from "./tracer.js";
|
|
3
|
-
import { getRouteCacheabilityCaptureOptions, getRouteCacheabilityDynamicReason, isRouteCacheabilityEvaluation, markRouteCacheabilityExplicitResponsePolicy, markRouteCacheabilityResponseBodyComplete } from "../shims/cacheability-classification.js";
|
|
4
|
+
import { getRouteCacheabilityCaptureOptions, getRouteCacheabilityDynamicReason, isRouteCacheabilityEvaluation, markRouteCacheabilityExplicitResponsePolicy, markRouteCacheabilityResponseBodyComplete, recordRouteCacheability } from "../shims/cacheability-classification.js";
|
|
4
5
|
import { NEVER_CACHE_CONTROL, applyCdnResponseHeaders, hasCdnResponsePolicy, hasExplicitNonCacheableResponsePolicy } from "./cache-control.js";
|
|
5
|
-
import {
|
|
6
|
+
import { buildAppRouteMissIsrCacheControl } from "./isr-decision.js";
|
|
7
|
+
import { isrCacheControl, resolveRouteExpireSeconds } from "./isr-cache.js";
|
|
6
8
|
import { isDraftModeRequest, setHeadersContext } from "../shims/headers.js";
|
|
7
9
|
import { _drainPendingRevalidations } from "../shims/cache-request-state.js";
|
|
8
10
|
import { copyLinkHeaderProvenance } from "./app-response-header-provenance.js";
|
|
@@ -18,6 +20,10 @@ function hasExplicitCacheableResponsePolicy(headers) {
|
|
|
18
20
|
return !hasExplicitNonCacheableResponsePolicy(headers) && hasCdnResponsePolicy(headers);
|
|
19
21
|
}
|
|
20
22
|
async function completeAppRouteHandlerResponse(response) {
|
|
23
|
+
if (isFullyBufferedBody(response)) return {
|
|
24
|
+
completed: true,
|
|
25
|
+
response
|
|
26
|
+
};
|
|
21
27
|
const { captureCacheabilityAdmissionBody } = await import("./cacheability-request.js");
|
|
22
28
|
const captureOptions = getRouteCacheabilityCaptureOptions();
|
|
23
29
|
const captured = await captureCacheabilityAdmissionBody(response.body, captureOptions?.captureDeadlineAt ?? Date.now() + 2e4, CACHEABILITY_ADMISSION_RESPONSE_BODY_LIMIT, captureOptions?.captureBudget);
|
|
@@ -189,16 +195,13 @@ async function executeAppRouteHandlerImpl(options) {
|
|
|
189
195
|
const handlerResult = tracedResult.handlerResult;
|
|
190
196
|
let { dynamicUsedInHandler, response } = handlerResult;
|
|
191
197
|
assertSupportedAppRouteHandlerResponse(response);
|
|
192
|
-
const handlerSetCachePolicy = hasCdnResponsePolicy(response.headers);
|
|
193
|
-
const hasExplicitCacheablePolicy = hasExplicitCacheableResponsePolicy(response.headers);
|
|
194
|
-
if (hasExplicitCacheablePolicy) markRouteCacheabilityExplicitResponsePolicy();
|
|
195
198
|
const draftModeBeforeCompletion = options.getActiveDraftModeState?.() ?? options.isDraftMode === true;
|
|
196
199
|
const handlerDraftCookieBeforeCompletion = options.getDraftModeCookieHeader() ?? options.initialDraftModeCookie;
|
|
197
200
|
if (shouldCompleteAppRouteHandlerResponse({
|
|
198
201
|
dynamicConfig: options.handler.dynamic,
|
|
199
202
|
dynamicUsedInHandler,
|
|
200
|
-
hasExplicitCacheablePolicy,
|
|
201
|
-
handlerSetCachePolicy,
|
|
203
|
+
hasExplicitCacheablePolicy: hasExplicitCacheableResponsePolicy(response.headers),
|
|
204
|
+
handlerSetCachePolicy: hasCdnResponsePolicy(response.headers),
|
|
202
205
|
isAutoHead: options.isAutoHead,
|
|
203
206
|
isDraftMode: draftModeBeforeCompletion || handlerDraftCookieBeforeCompletion != null,
|
|
204
207
|
isProduction: options.isProduction,
|
|
@@ -213,6 +216,9 @@ async function executeAppRouteHandlerImpl(options) {
|
|
|
213
216
|
const dynamicUsedDuringCompletion = options.consumeDynamicUsage();
|
|
214
217
|
dynamicUsedInHandler = handlerResult.didAccessDynamicRequest() || dynamicUsedDuringCompletion || dynamicUsedInHandler;
|
|
215
218
|
}
|
|
219
|
+
const browserCacheControl = response.headers.get("Cache-Control") ?? void 0;
|
|
220
|
+
const handlerSetCachePolicy = hasCdnResponsePolicy(response.headers);
|
|
221
|
+
if (handlerSetCachePolicy) markRouteCacheabilityExplicitResponsePolicy();
|
|
216
222
|
const requestCacheabilityVeto = getRouteCacheabilityDynamicReason();
|
|
217
223
|
const responseMustStayPrivate = Boolean(options.bypassSharedCache === true || options.handler.dynamic === "force-dynamic" || dynamicUsedInHandler || requestCacheabilityVeto || cleanupDeferredToBody);
|
|
218
224
|
if (dynamicUsedInHandler) markKnownDynamicAppRoute(options.routePattern);
|
|
@@ -222,6 +228,15 @@ async function executeAppRouteHandlerImpl(options) {
|
|
|
222
228
|
const shouldApplyDraftPolicy = (options.getActiveDraftModeState?.() ?? options.isDraftMode === true) || draftCookie != null;
|
|
223
229
|
if (handlerDraftCookie != null) markKnownDynamicAppRoute(options.routePattern);
|
|
224
230
|
const routeTags = options.buildPageCacheTags(options.cleanPathname, options.getCollectedFetchTags());
|
|
231
|
+
const frameworkCacheable = (options.isRevalidation === true || response.status < 400 || response.status === 404) && options.revalidateSeconds !== null && options.revalidateSeconds > 0 && !responseMustStayPrivate && !shouldApplyDraftPolicy && pendingCookies.length === 0 && !response.headers.has("set-cookie") && (options.method === "GET" || options.isAutoHead);
|
|
232
|
+
recordRouteCacheability(frameworkCacheable ? {
|
|
233
|
+
cacheable: true,
|
|
234
|
+
cacheControl: buildAppRouteMissIsrCacheControl(options.revalidateSeconds, options.expireSeconds),
|
|
235
|
+
tags: routeTags
|
|
236
|
+
} : {
|
|
237
|
+
cacheable: false,
|
|
238
|
+
dynamicUsage: responseMustStayPrivate || shouldApplyDraftPolicy || options.revalidateSeconds === 0
|
|
239
|
+
});
|
|
225
240
|
if (shouldApplyAppRouteHandlerRevalidateHeader({
|
|
226
241
|
dynamicUsedInHandler: responseMustStayPrivate,
|
|
227
242
|
handlerSetCachePolicy,
|
|
@@ -234,9 +249,9 @@ async function executeAppRouteHandlerImpl(options) {
|
|
|
234
249
|
if (revalidateSeconds == null) throw new Error("Expected route handler revalidate seconds");
|
|
235
250
|
applyRouteHandlerRevalidateHeader(response, revalidateSeconds, options.expireSeconds, routeTags);
|
|
236
251
|
}
|
|
237
|
-
if (shouldWriteAppRouteHandlerCache({
|
|
252
|
+
if (frameworkCacheable && shouldWriteAppRouteHandlerCache({
|
|
238
253
|
dynamicConfig: options.handler.dynamic,
|
|
239
|
-
dynamicUsedInHandler: responseMustStayPrivate,
|
|
254
|
+
dynamicUsedInHandler: responseMustStayPrivate || pendingCookies.length > 0 || response.headers.has("set-cookie"),
|
|
240
255
|
handlerSetCachePolicy,
|
|
241
256
|
isAutoHead: options.isAutoHead,
|
|
242
257
|
isDraftMode: shouldApplyDraftPolicy,
|
|
@@ -251,9 +266,9 @@ async function executeAppRouteHandlerImpl(options) {
|
|
|
251
266
|
if (revalidateSeconds == null) throw new Error("Expected route handler cache revalidate seconds");
|
|
252
267
|
const routeWritePromise = (async () => {
|
|
253
268
|
try {
|
|
254
|
-
const routeCacheValue = await buildAppRouteCacheValue(routeClone);
|
|
269
|
+
const routeCacheValue = await buildAppRouteCacheValue(routeClone, browserCacheControl);
|
|
255
270
|
await options.isrSet(routeKey, routeCacheValue, {
|
|
256
|
-
cacheControl: isrCacheControl(revalidateSeconds, { expireSeconds: options.expireSeconds }),
|
|
271
|
+
cacheControl: isrCacheControl(revalidateSeconds === Infinity ? false : revalidateSeconds, { expireSeconds: resolveRouteExpireSeconds(options.revalidateSeconds, options.expireSeconds) }),
|
|
257
272
|
tags: routeTags
|
|
258
273
|
});
|
|
259
274
|
options.isrDebug?.("route cache written", routeKey);
|
|
@@ -268,7 +283,7 @@ async function executeAppRouteHandlerImpl(options) {
|
|
|
268
283
|
draftCookie,
|
|
269
284
|
isHead: options.isAutoHead
|
|
270
285
|
}), options.middlewareContext, middlewareMergeOptions), shouldApplyDraftPolicy);
|
|
271
|
-
const preserveHandlerPolicy =
|
|
286
|
+
const preserveHandlerPolicy = handlerSetCachePolicy;
|
|
272
287
|
if (options.bypassSharedCache === true || responseMustStayPrivate && !preserveHandlerPolicy) {
|
|
273
288
|
const headers = new Headers(finalized.headers);
|
|
274
289
|
applyCdnResponseHeaders(headers, { cacheControl: NEVER_CACHE_CONTROL });
|
|
@@ -328,4 +343,4 @@ async function executeAppRouteHandlerImpl(options) {
|
|
|
328
343
|
}
|
|
329
344
|
}
|
|
330
345
|
//#endregion
|
|
331
|
-
export { applyDraftModeCachePolicy, executeAppRouteHandler, runAppRouteHandler, traceAppRouteHandlerExecution };
|
|
346
|
+
export { applyDraftModeCachePolicy, completeAppRouteHandlerResponse, executeAppRouteHandler, runAppRouteHandler, traceAppRouteHandlerExecution };
|
|
@@ -36,7 +36,7 @@ function resolveAppRouteHandlerMethod(handler, method) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
function shouldReadAppRouteHandlerCache(options) {
|
|
39
|
-
return options.isProduction && options.revalidateSeconds !== null && options.revalidateSeconds > 0 && options.
|
|
39
|
+
return options.isProduction && options.revalidateSeconds !== null && options.revalidateSeconds > 0 && options.dynamicConfig !== "force-dynamic" && !options.isDraftMode && !options.isKnownDynamic && (options.method === "GET" || options.isAutoHead) && typeof options.handlerFn === "function";
|
|
40
40
|
}
|
|
41
41
|
function shouldApplyAppRouteHandlerRevalidateHeader(options) {
|
|
42
42
|
return options.revalidateSeconds !== null && !options.isDraftMode && !options.dynamicUsedInHandler && (options.method === "GET" || options.isAutoHead) && !options.handlerSetCachePolicy;
|
|
@@ -51,7 +51,7 @@ function shouldCompleteAppRouteHandlerResponse(options) {
|
|
|
51
51
|
return options.isProduction && (options.revalidateSeconds !== null && options.revalidateSeconds > 0 || options.requiresCompletedResponseAdmission === true || options.hasExplicitCacheablePolicy === true) && options.dynamicConfig !== "force-dynamic" && !options.isDraftMode && !options.dynamicUsedInHandler && (options.method === "GET" || options.isAutoHead);
|
|
52
52
|
}
|
|
53
53
|
function shouldWriteAppRouteHandlerCache(options) {
|
|
54
|
-
return options.isProduction && options.revalidateSeconds !== null && options.revalidateSeconds > 0 && options.
|
|
54
|
+
return options.isProduction && options.revalidateSeconds !== null && options.revalidateSeconds > 0 && options.dynamicConfig !== "force-dynamic" && !options.isDraftMode && !options.dynamicUsedInHandler && (options.method === "GET" || options.isAutoHead);
|
|
55
55
|
}
|
|
56
56
|
function resolveAppRouteHandlerSpecialError(error, requestUrl, options) {
|
|
57
57
|
if (!(error && typeof error === "object" && "digest" in error)) return null;
|
|
@@ -23,6 +23,6 @@ export declare function assertSupportedAppRouteHandlerResponse(response: Respons
|
|
|
23
23
|
export declare function buildRouteHandlerCachedResponse(cachedValue: CachedRouteValue, options: BuildRouteHandlerCachedResponseOptions): Response;
|
|
24
24
|
export declare function applyRouteHandlerRevalidateHeader(response: Response, revalidateSeconds: number, expireSeconds?: number, tags?: readonly string[]): void;
|
|
25
25
|
export declare function markRouteHandlerCacheMiss(response: Response): void;
|
|
26
|
-
export declare function buildAppRouteCacheValue(response: Response): Promise<CachedRouteValue>;
|
|
26
|
+
export declare function buildAppRouteCacheValue(response: Response, browserCacheControl?: string): Promise<CachedRouteValue>;
|
|
27
27
|
export declare function finalizeRouteHandlerResponse(response: Response, options: FinalizeRouteHandlerResponseOptions): Response;
|
|
28
28
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../utils/protocol-headers.js";
|
|
2
2
|
import { NEXT_CACHE_TAGS_HEADER, VINEXT_METADATA_ROUTE_CACHE_HEADER } from "./headers.js";
|
|
3
3
|
import { processMiddlewareHeaders } from "./request-pipeline.js";
|
|
4
|
-
import {
|
|
4
|
+
import { markRouteCacheabilityExplicitResponsePolicy, recordRouteCacheability } from "../shims/cacheability-classification.js";
|
|
5
5
|
import { applyCdnResponseHeaders } from "./cache-control.js";
|
|
6
6
|
import { buildAppRouteMissIsrCacheControl, decideIsr } from "./isr-decision.js";
|
|
7
7
|
import { setCacheStateHeaders } from "./cache-headers.js";
|
|
@@ -50,14 +50,22 @@ function buildRouteHandlerCachedResponse(cachedValue, options) {
|
|
|
50
50
|
expireSeconds: options.expireSeconds,
|
|
51
51
|
cacheControlMeta: options.cacheControl
|
|
52
52
|
});
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
recordRouteCacheability({
|
|
54
|
+
cacheable: true,
|
|
55
|
+
cacheControl
|
|
56
|
+
});
|
|
57
|
+
if (headers.has("Cache-Control")) markRouteCacheabilityExplicitResponsePolicy();
|
|
58
|
+
applyCdnResponseHeaders(headers, {
|
|
59
|
+
cacheControl,
|
|
60
|
+
browserCacheControl: headers.get("Cache-Control") ?? void 0
|
|
61
|
+
});
|
|
62
|
+
const hasNoBody = options.isHead || cachedValue.status === 204 || cachedValue.status === 205 || cachedValue.status === 304;
|
|
63
|
+
return new Response(hasNoBody ? null : cachedValue.body, {
|
|
55
64
|
status: cachedValue.status,
|
|
56
65
|
headers
|
|
57
66
|
});
|
|
58
67
|
}
|
|
59
68
|
function applyRouteHandlerRevalidateHeader(response, revalidateSeconds, expireSeconds, tags) {
|
|
60
|
-
markRouteCacheabilityExplicitConfigPolicy();
|
|
61
69
|
applyCdnResponseHeaders(response.headers, {
|
|
62
70
|
cacheControl: buildAppRouteMissIsrCacheControl(revalidateSeconds, expireSeconds),
|
|
63
71
|
tags
|
|
@@ -125,13 +133,14 @@ function applyMutableCookieFallbacks(headers, pendingCookies) {
|
|
|
125
133
|
for (const cookie of fallbackCookies.values()) headers.append("Set-Cookie", cookie);
|
|
126
134
|
for (const cookie of returnedCookies) headers.append("Set-Cookie", normalizeReturnedCookie(cookie));
|
|
127
135
|
}
|
|
128
|
-
async function buildAppRouteCacheValue(response) {
|
|
136
|
+
async function buildAppRouteCacheValue(response, browserCacheControl) {
|
|
129
137
|
const body = await response.arrayBuffer();
|
|
130
138
|
const headers = {};
|
|
131
139
|
response.headers.forEach((value, key) => {
|
|
132
140
|
if (key === "set-cookie" || key === "connection" || key === "content-length" || key === "date" || key === "keep-alive" || key === "transfer-encoding" || key === "x-next-cache-tags" || key === "x-vinext-metadata-route-cache" || key === "x-vinext-prerender-cache-life" || key === "X-Vinext-Cache".toLowerCase() || key === "x-nextjs-cache".toLowerCase() || key === "cache-control" || key.startsWith("x-middleware-")) return;
|
|
133
141
|
headers[key] = value;
|
|
134
142
|
});
|
|
143
|
+
if (browserCacheControl !== void 0) headers["cache-control"] = browserCacheControl;
|
|
135
144
|
const setCookies = response.headers.getSetCookie?.() ?? [];
|
|
136
145
|
if (setCookies.length > 0) headers["set-cookie"] = setCookies;
|
|
137
146
|
return {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { VinextRequestStageContext } from "./multi-stage.js";
|
|
1
2
|
import { ExecutionContextLike } from "../shims/request-context.js";
|
|
2
3
|
import { __ensureInstrumentation } from "virtual:vinext-rsc-entry";
|
|
3
4
|
//#region src/server/app-router-entry.d.ts
|
|
@@ -8,7 +9,7 @@ type WorkerAssetEnv = {
|
|
|
8
9
|
};
|
|
9
10
|
declare const _default: {
|
|
10
11
|
__ensureInstrumentation: typeof __ensureInstrumentation;
|
|
11
|
-
fetch(request: Request, env?: WorkerAssetEnv, ctx?: ExecutionContextLike): Promise<Response>;
|
|
12
|
+
fetch(request: Request, env?: WorkerAssetEnv, ctx?: ExecutionContextLike & VinextRequestStageContext): Promise<Response>;
|
|
12
13
|
};
|
|
13
14
|
//#endregion
|
|
14
15
|
export { _default as default };
|
|
@@ -5,13 +5,12 @@ import "./server-globals.js";
|
|
|
5
5
|
import "./app-rsc-vary.js";
|
|
6
6
|
import { VINEXT_CACHEABILITY_PROBE_QUERY_PARAM } from "./headers.js";
|
|
7
7
|
import { badRequestResponse, notFoundResponse, notFoundStaticAssetResponse } from "./http-error-responses.js";
|
|
8
|
-
import {
|
|
9
|
-
import { cloneRequestWithHeaders, filterInternalHeaders } from "./request-pipeline.js";
|
|
8
|
+
import { cloneRequestWithHeaders, filterInternalHeaders, guardProtocolRelativeUrl } from "./request-pipeline.js";
|
|
10
9
|
import { getCdnCacheAdapter } from "../shims/cdn-cache.js";
|
|
11
10
|
import { applyCdnResponseIdentityHeaders, validateCdnRequest } from "./cache-control.js";
|
|
12
11
|
import { getImageOptimizer, handleConfiguredImageOptimization, isImageOptimizationPath } from "./image-optimization.js";
|
|
13
12
|
import { traceFrameworkRequest } from "./request-tracing.js";
|
|
14
|
-
import { createStaticAssetRequest,
|
|
13
|
+
import { createStaticAssetRequest, resolveStaticAssetSignal } from "./worker-utils.js";
|
|
15
14
|
import { readTrustedPrerenderRouteParams, serializePrerenderRouteParamsHeader } from "./prerender-route-params.js";
|
|
16
15
|
import { createWorkerRevalidationContext } from "./worker-revalidation-context.js";
|
|
17
16
|
import { createWorkerPrerenderDiscoveryContext, createWorkerPrerenderReadinessResponse } from "./worker-prerender-discovery.js";
|
|
@@ -48,6 +47,7 @@ async function handleRequest(request, env, platformCtx) {
|
|
|
48
47
|
const requestCtx = platformCtx?.trustedRevalidateOrigin ? platformCtx : createWorkerRevalidationContext(platformCtx, (internalRequest, internalCtx) => handleRequest(internalRequest, env, internalCtx));
|
|
49
48
|
registerConfiguredCacheAdapters(env);
|
|
50
49
|
const cdnCacheAdapter = getCdnCacheAdapter();
|
|
50
|
+
const assets = platformCtx?.assets ?? cdnCacheAdapter.assets ?? env?.ASSETS;
|
|
51
51
|
let ctx = createWorkerPrerenderDiscoveryContext(requestCtx, request, __prerenderSecret);
|
|
52
52
|
const readinessResponse = createWorkerPrerenderReadinessResponse(ctx, request);
|
|
53
53
|
if (readinessResponse) {
|
|
@@ -81,11 +81,9 @@ async function handleRequest(request, env, platformCtx) {
|
|
|
81
81
|
const cdnValidationResponse = await validateCdnRequest(request);
|
|
82
82
|
if (cdnValidationResponse) return cdnValidationResponse;
|
|
83
83
|
const url = new URL(request.url);
|
|
84
|
-
if (isImageOptimizationPath(url.pathname) &&
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
if (isOpenRedirectShaped(url.pathname)) return notFoundResponse();
|
|
84
|
+
if (isImageOptimizationPath(url.pathname) && assets && getImageOptimizer()) return handleConfiguredImageOptimization(request, (assetPath) => Promise.resolve(assets.fetch(new Request(new URL(assetPath, request.url)))), __imageAllowedWidths, __imageConfig);
|
|
85
|
+
const protocolRelativeGuard = guardProtocolRelativeUrl(url.pathname, url.search);
|
|
86
|
+
if (protocolRelativeGuard) return protocolRelativeGuard;
|
|
89
87
|
try {
|
|
90
88
|
decodeURIComponent(url.pathname);
|
|
91
89
|
} catch {
|
|
@@ -105,12 +103,10 @@ async function handleRequest(request, env, platformCtx) {
|
|
|
105
103
|
const result = await (ctx ? runWithExecutionContext(ctx, handleFn) : handleFn());
|
|
106
104
|
if (result instanceof Response) {
|
|
107
105
|
let response = result;
|
|
108
|
-
if (
|
|
109
|
-
const
|
|
110
|
-
const assetResponse = await resolveStaticAssetSignal(response, { fetchAsset: (path) => Promise.resolve(assetFetcher.fetch(createStaticAssetRequest(path, request))) });
|
|
106
|
+
if (assets) {
|
|
107
|
+
const assetResponse = await resolveStaticAssetSignal(response, { fetchAsset: (path) => Promise.resolve(assets.fetch(createStaticAssetRequest(path, request))) });
|
|
111
108
|
if (assetResponse) response = assetResponse;
|
|
112
109
|
}
|
|
113
|
-
response = finalizeMissingStaticAssetResponse(response, missingBuildAsset);
|
|
114
110
|
return finalizeCacheabilityResponse ? finalizeCacheabilityResponse(response, ctx) : response;
|
|
115
111
|
}
|
|
116
112
|
if (result === null || result === void 0) {
|
|
@@ -22,7 +22,6 @@ type CreateRscOnErrorHandlerOptions = {
|
|
|
22
22
|
export declare function hasDigest(error: unknown): error is {
|
|
23
23
|
digest: unknown;
|
|
24
24
|
};
|
|
25
|
-
export declare function isAppRenderAbortError(error: unknown): boolean;
|
|
26
25
|
/**
|
|
27
26
|
* vinext's mirror of Next.js's `getDigestForWellKnownError`: returns the digest
|
|
28
27
|
* string only when the error is a genuine control-flow signal — a redirect,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isNavigationSignalError } from "../utils/navigation-signal.js";
|
|
2
2
|
import { resolveAppPageSpecialError } from "./app-page-execution.js";
|
|
3
|
+
import { isAppRenderAbortError } from "./app-render-abort-error.js";
|
|
3
4
|
//#region src/server/app-rsc-errors.ts
|
|
4
5
|
const ORIGINAL_SERVER_ERROR = Symbol.for("vinext.originalServerError");
|
|
5
6
|
function hasDigest(error) {
|
|
@@ -7,11 +8,6 @@ function hasDigest(error) {
|
|
|
7
8
|
}
|
|
8
9
|
const BAILOUT_TO_CSR_DIGEST = "BAILOUT_TO_CLIENT_SIDE_RENDERING";
|
|
9
10
|
const DYNAMIC_SERVER_USAGE_DIGEST = "DYNAMIC_SERVER_USAGE";
|
|
10
|
-
function isAppRenderAbortError(error) {
|
|
11
|
-
if (!error || typeof error !== "object") return false;
|
|
12
|
-
const name = Reflect.get(error, "name");
|
|
13
|
-
return name === "AbortError" || name === "ResponseAborted";
|
|
14
|
-
}
|
|
15
11
|
/**
|
|
16
12
|
* vinext's mirror of Next.js's `getDigestForWellKnownError`: returns the digest
|
|
17
13
|
* string only when the error is a genuine control-flow signal — a redirect,
|
|
@@ -85,4 +81,4 @@ function createRscOnErrorHandler(options) {
|
|
|
85
81
|
};
|
|
86
82
|
}
|
|
87
83
|
//#endregion
|
|
88
|
-
export { createRscOnErrorHandler, errorDigest, getDigestForWellKnownError, hasDigest,
|
|
84
|
+
export { createRscOnErrorHandler, errorDigest, getDigestForWellKnownError, hasDigest, sanitizeErrorForClient };
|
|
@@ -85,6 +85,8 @@ type DispatchMatchedPageOptions<TRoute> = {
|
|
|
85
85
|
scriptNonce?: string;
|
|
86
86
|
searchParams: URLSearchParams;
|
|
87
87
|
renderMode: AppRscRenderMode;
|
|
88
|
+
/** Render the document whole before its first byte (a regeneration or warm-up). */
|
|
89
|
+
renderWholeDocument?: boolean;
|
|
88
90
|
};
|
|
89
91
|
type DispatchMatchedRouteHandlerOptions<TRoute> = {
|
|
90
92
|
/**
|
|
@@ -184,6 +186,7 @@ type NavigationContextValue = {
|
|
|
184
186
|
searchParams: URLSearchParams;
|
|
185
187
|
};
|
|
186
188
|
export type CreateAppRscHandlerOptions<TRoute extends AppRscHandlerRoute> = {
|
|
189
|
+
assetPrefix?: string;
|
|
187
190
|
basePath: string;
|
|
188
191
|
buildId: string | null;
|
|
189
192
|
/**
|
|
@@ -234,6 +237,8 @@ export type CreateAppRscHandlerOptions<TRoute extends AppRscHandlerRoute> = {
|
|
|
234
237
|
matchInterceptRoute?: (pathname: string, sourcePathname: string, interceptionId?: string | null) => AppRscRouteMatch<TRoute> | null;
|
|
235
238
|
matchRoute: (pathname: string) => AppRscRouteMatch<TRoute> | null;
|
|
236
239
|
matchRequestRoute?: (pathname: string) => AppRscRouteMatch<TRoute> | null;
|
|
240
|
+
/** `matchRequestRoute` without its decoded static page substitution. */
|
|
241
|
+
matchRawRequestRoute?: (pathname: string) => AppRscRouteMatch<TRoute> | null;
|
|
237
242
|
runMiddleware?: (options: RunAppMiddlewareOptions) => Promise<ApplyAppMiddlewareResult>;
|
|
238
243
|
publicFiles: ReadonlySet<string>;
|
|
239
244
|
prefetchInlining?: PrefetchInliningConfig;
|