vinext 1.3.1 → 1.4.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 +5 -2
- package/THIRD_PARTY_LICENSES.md +47 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -2
- package/dist/build/prerender.js +1 -1
- package/dist/build/report.d.ts +0 -14
- package/dist/build/report.js +1 -51
- package/dist/check.js +1 -1
- package/dist/cli.js +3 -0
- package/dist/client/dev-error-overlay.js +1 -1
- package/dist/client/navigation-runtime.d.ts +13 -1
- package/dist/client/navigation-runtime.js +1 -1
- package/dist/config/next-config.d.ts +19 -0
- package/dist/config/next-config.js +64 -1
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-codec.js +327 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-data.js +123 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/index.js +29 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/internal.js +134 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-codec.js +50 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data-generated.js +455 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data.js +147 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/big5-added.json.js +169 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp936.json.js +2584 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp949.json.js +2220 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp950.json.js +227 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/eucjp.json.js +425 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gb18030-ranges.json.js +427 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gbk-added.json.js +229 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/shiftjis.json.js +292 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf16.js +106 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf7.js +182 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/bom-handling.js +42 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/extend-node.js +147 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/index.js +94 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/streams.js +95 -0
- package/dist/deps/.pnpm/safer-buffer@2.1.2/deps/safer-buffer/safer.js +45 -0
- package/dist/entries/app-rsc-entry.js +17 -48
- package/dist/entries/app-rsc-manifest.js +3 -4
- package/dist/entries/app-ssr-entry.js +1 -0
- package/dist/entries/pages-server-entry.js +33 -8
- package/dist/index.js +83 -70
- package/dist/init-cloudflare.d.ts +1 -3
- package/dist/init-cloudflare.js +10 -48
- package/dist/init-platform.d.ts +2 -0
- package/dist/init-platform.js +4 -0
- package/dist/plugins/extensionless-dynamic-import.js +6 -2
- package/dist/plugins/next-intl-catalog.d.ts +12 -0
- package/dist/plugins/next-intl-catalog.js +85 -0
- package/dist/plugins/pages-node-externals.d.ts +1 -0
- package/dist/plugins/pages-node-externals.js +1 -1
- package/dist/plugins/use-cache-callable.d.ts +1 -1
- package/dist/plugins/use-cache-callable.js +136 -94
- package/dist/routing/app-route-graph.d.ts +6 -0
- package/dist/routing/app-route-graph.js +9 -1
- package/dist/server/api-handler.js +19 -4
- package/dist/server/app-bfcache-identity.js +1 -1
- package/dist/server/app-browser-entry.js +79 -63
- package/dist/server/app-browser-history-controller.d.ts +5 -4
- package/dist/server/app-browser-history-controller.js +93 -15
- package/dist/server/app-browser-navigation-controller.d.ts +2 -2
- package/dist/server/app-browser-navigation-controller.js +1 -2
- package/dist/server/app-browser-rsc-redirect.js +4 -4
- package/dist/server/app-browser-server-action-client.d.ts +2 -0
- package/dist/server/app-browser-server-action-client.js +4 -3
- package/dist/server/app-browser-state.d.ts +2 -4
- package/dist/server/app-browser-state.js +9 -4
- package/dist/server/app-browser-supplemental-refresh.js +16 -1
- package/dist/server/app-browser-visible-commit.d.ts +1 -1
- package/dist/server/app-browser-visible-commit.js +2 -12
- package/dist/server/app-elements-wire.d.ts +6 -38
- package/dist/server/app-elements-wire.js +4 -41
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-history-state.d.ts +2 -2
- package/dist/server/app-history-state.js +5 -2
- package/dist/server/app-mounted-layouts.d.ts +21 -0
- package/dist/server/app-mounted-layouts.js +67 -0
- package/dist/server/app-optimistic-routing.d.ts +19 -1
- package/dist/server/app-optimistic-routing.js +42 -2
- package/dist/server/app-page-boundary-render.js +7 -6
- package/dist/server/app-page-boundary.js +2 -2
- package/dist/server/app-page-cache-finalizer.d.ts +12 -1
- package/dist/server/app-page-cache-finalizer.js +70 -29
- package/dist/server/app-page-cache.d.ts +13 -1
- package/dist/server/app-page-cache.js +31 -9
- package/dist/server/app-page-dispatch.d.ts +5 -10
- package/dist/server/app-page-dispatch.js +84 -154
- package/dist/server/app-page-element-builder.d.ts +2 -2
- package/dist/server/app-page-element-builder.js +10 -9
- package/dist/server/app-page-execution.d.ts +17 -52
- package/dist/server/app-page-execution.js +99 -95
- package/dist/server/app-page-head.d.ts +13 -0
- package/dist/server/app-page-head.js +44 -16
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +1 -0
- package/dist/server/app-page-http-access-fallback-metadata.js +2 -2
- package/dist/server/app-page-layout-gate.d.ts +35 -0
- package/dist/server/app-page-layout-gate.js +50 -0
- package/dist/server/app-page-params.d.ts +0 -1
- package/dist/server/app-page-params.js +1 -14
- package/dist/server/app-page-probe.d.ts +3 -21
- package/dist/server/app-page-probe.js +4 -37
- package/dist/server/app-page-render.d.ts +2 -12
- package/dist/server/app-page-render.js +89 -220
- package/dist/server/app-page-request.d.ts +1 -3
- package/dist/server/app-page-request.js +1 -1
- package/dist/server/app-page-response.js +3 -3
- package/dist/server/app-page-route-wiring.d.ts +13 -6
- package/dist/server/app-page-route-wiring.js +67 -61
- package/dist/server/app-page-rsc-render-status.d.ts +27 -1
- package/dist/server/app-page-rsc-render-status.js +121 -13
- package/dist/server/app-page-stream.d.ts +2 -0
- package/dist/server/app-page-stream.js +2 -2
- package/dist/server/app-pages-bridge.d.ts +4 -0
- package/dist/server/app-pages-bridge.js +7 -3
- package/dist/server/app-render-dependency.d.ts +11 -4
- package/dist/server/app-render-dependency.js +86 -38
- package/dist/server/app-request-stage-dispatch.js +1 -1
- package/dist/server/app-route-handler-cache.js +2 -2
- package/dist/server/app-route-handler-dispatch.js +14 -9
- package/dist/server/app-route-handler-execution.js +8 -3
- package/dist/server/app-route-handler-policy.d.ts +1 -1
- package/dist/server/app-route-handler-policy.js +3 -3
- package/dist/server/app-route-handler-response.js +1 -1
- package/dist/server/app-route-handler-runtime.js +17 -4
- package/dist/server/app-rsc-cache-busting.d.ts +2 -2
- package/dist/server/app-rsc-cache-busting.js +4 -4
- package/dist/server/app-rsc-error-handler.d.ts +2 -1
- package/dist/server/app-rsc-error-handler.js +9 -1
- package/dist/server/app-rsc-errors.d.ts +8 -0
- package/dist/server/app-rsc-errors.js +8 -1
- package/dist/server/app-rsc-handler.d.ts +5 -5
- package/dist/server/app-rsc-handler.js +30 -24
- package/dist/server/app-rsc-request-normalization.d.ts +0 -4
- package/dist/server/app-rsc-request-normalization.js +1 -4
- package/dist/server/app-rsc-response-finalizer.js +2 -2
- package/dist/server/app-rsc-response-stage.js +5 -3
- package/dist/server/app-server-action-execution.d.ts +3 -1
- package/dist/server/app-server-action-execution.js +7 -4
- package/dist/server/app-ssr-entry.d.ts +2 -0
- package/dist/server/app-ssr-entry.js +9 -8
- package/dist/server/app-ssr-stream.js +1 -1
- package/dist/server/app-visited-response-cache.d.ts +36 -1
- package/dist/server/app-visited-response-cache.js +46 -5
- package/dist/server/app-worker-stages.d.ts +25 -3
- package/dist/server/app-worker-stages.js +45 -6
- package/dist/server/artifact-compatibility.d.ts +0 -1
- package/dist/server/artifact-compatibility.js +1 -10
- package/dist/server/cache-proof.d.ts +1 -115
- package/dist/server/cache-proof.js +1 -544
- package/dist/server/cacheability-request.js +13 -8
- package/dist/server/dev-server.js +4 -3
- package/dist/server/headers.d.ts +6 -3
- package/dist/server/headers.js +9 -5
- package/dist/server/isr-cache.d.ts +8 -2
- package/dist/server/isr-cache.js +26 -1
- package/dist/server/metadata-route-response.js +32 -15
- package/dist/server/multi-stage.d.ts +52 -11
- package/dist/server/multi-stage.js +13 -1
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/pages-api-route.js +28 -19
- package/dist/server/pages-media-type.d.ts +21 -1
- package/dist/server/pages-media-type.js +69 -5
- package/dist/server/pages-node-compat.js +52 -27
- package/dist/server/pages-page-handler.js +11 -20
- package/dist/server/pages-request-pipeline.d.ts +8 -0
- package/dist/server/pages-request-pipeline.js +2 -2
- package/dist/server/pages-request-stage-entry.js +14 -12
- package/dist/server/pages-response-stage-entry.js +9 -3
- package/dist/server/prod-server.js +5 -1
- package/dist/server/request-pipeline.d.ts +6 -0
- package/dist/server/request-pipeline.js +21 -1
- package/dist/server/shared-cache-identity.d.ts +23 -0
- package/dist/server/shared-cache-identity.js +36 -0
- package/dist/server/worker-stages.d.ts +16 -3
- package/dist/server/worker-stages.js +23 -4
- package/dist/shims/cache-handler.js +2 -2
- package/dist/shims/cache-request-state.d.ts +17 -20
- package/dist/shims/cache-request-state.js +16 -21
- package/dist/shims/cache-runtime.js +27 -11
- package/dist/shims/cache.d.ts +8 -7
- package/dist/shims/cache.js +17 -19
- package/dist/shims/cacheability-classification.d.ts +2 -0
- package/dist/shims/cdn-cache.d.ts +22 -5
- package/dist/shims/client-page-root.js +2 -2
- package/dist/shims/dynamic.js +9 -6
- package/dist/shims/error-boundary.js +2 -2
- package/dist/shims/fetch-cache-state.d.ts +5 -1
- package/dist/shims/fetch-cache-state.js +1 -3
- package/dist/shims/fetch-cache.d.ts +2 -1
- package/dist/shims/fetch-cache.js +34 -24
- package/dist/shims/form.js +2 -2
- package/dist/shims/headers.d.ts +8 -23
- package/dist/shims/headers.js +17 -67
- package/dist/shims/internal/navigation-untracked.js +1 -1
- package/dist/shims/link.js +3 -1
- package/dist/shims/metadata.d.ts +23 -21
- package/dist/shims/metadata.js +62 -24
- package/dist/shims/navigation-server.js +1 -1
- package/dist/shims/navigation.d.ts +74 -7
- package/dist/shims/navigation.js +183 -29
- package/dist/shims/navigation.react-server.js +2 -2
- package/dist/shims/request-state-types.d.ts +2 -2
- package/dist/shims/slot.d.ts +12 -0
- package/dist/shims/slot.js +37 -9
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +2 -3
- package/dist/utils/cache-control-metadata.d.ts +5 -0
- package/dist/utils/cache-control-metadata.js +9 -1
- package/dist/utils/project.d.ts +2 -2
- package/dist/utils/project.js +3 -16
- package/dist/utils/regex.d.ts +5 -0
- package/dist/utils/regex.js +11 -1
- package/dist/utils/text-stream.d.ts +10 -5
- package/dist/utils/text-stream.js +6 -6
- package/package.json +2 -1
- package/dist/build/layout-classification-types.d.ts +0 -60
- package/dist/build/layout-classification-types.js +0 -1
- package/dist/build/layout-classification.d.ts +0 -62
- package/dist/build/layout-classification.js +0 -98
- package/dist/build/route-classification-injector.d.ts +0 -33
- package/dist/build/route-classification-injector.js +0 -59
- package/dist/build/route-classification-manifest.d.ts +0 -54
- package/dist/build/route-classification-manifest.js +0 -143
- package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -11
- package/dist/server/app-browser-client-reuse-manifest.js +0 -101
- package/dist/server/app-layout-param-observation.d.ts +0 -42
- package/dist/server/app-layout-param-observation.js +0 -168
- package/dist/server/client-reuse-manifest.d.ts +0 -103
- package/dist/server/client-reuse-manifest.js +0 -209
- package/dist/server/skip-cache-proof.d.ts +0 -60
- package/dist/server/skip-cache-proof.js +0 -168
- package/dist/server/static-layout-client-reuse-proof.d.ts +0 -14
- package/dist/server/static-layout-client-reuse-proof.js +0 -33
- package/dist/utils/sorted-array.d.ts +0 -8
- package/dist/utils/sorted-array.js +0 -20
|
@@ -17,7 +17,6 @@ import { runOutsideWorkStoreScope } from "../shims/internal/work-store-scope.js"
|
|
|
17
17
|
import { isInterceptionMatchedUrlPath, normalizePath } from "./normalize-path.js";
|
|
18
18
|
import { normalizeDefaultLocalePathname, shouldRestoreLocaleRootTrailingSlash } from "./pages-i18n.js";
|
|
19
19
|
import { buildNextDataNotFoundResponse, normalizePagesDataRequest } from "./pages-data-route.js";
|
|
20
|
-
import { getCdnCacheAdapter } from "../shims/cdn-cache.js";
|
|
21
20
|
import { markRouteCacheabilityDynamic, preserveRouteCacheabilityResponsePolicy } from "../shims/cacheability-classification.js";
|
|
22
21
|
import { NEVER_CACHE_CONTROL, applyCdnResponseHeaders, captureCdnResponsePolicyOverrides, isCdnResponsePolicyHeader, reconcileCdnResponseHeadersAfterOuterPolicy } from "./cache-control.js";
|
|
23
22
|
import { isOnDemandRevalidateRequest } from "./revalidation-request.js";
|
|
@@ -28,29 +27,30 @@ import { traceFindPageComponents } from "./pages-execution-tracing.js";
|
|
|
28
27
|
import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, markImageOptimizationSignal, resolveDevImageRedirect } from "./image-optimization.js";
|
|
29
28
|
import { parseCacheabilityManifest } from "./cacheability-manifest.js";
|
|
30
29
|
import { getRenderedConcreteUrlPathsForRoute } from "./pregenerated-concrete-paths.js";
|
|
31
|
-
import { VINEXT_RSC_CACHE_BUSTING_SEARCH_PARAM, canonicalizeLoadingShellRscRequestHeaders, canonicalizePrewarmableRscRequestHeaders, createCanonicalRscRequestUrl, createRscRedirectLocation, createRscRequestUrl, hasRscCacheBustingSearchParam, resolveInvalidRscCacheBustingRequest, stripRscCacheBustingSearchParam, stripRscSuffix } from "./app-rsc-cache-busting.js";
|
|
32
|
-
import { mergeMiddlewareResponseHeaders, mergeMiddlewareResponseHeadersOntoResponse, withExternalRewriteResponseHeaders } from "./middleware-response-headers.js";
|
|
33
|
-
import { consumeResponseStageLinkProvenance, copyLinkHeaderProvenance } from "./app-response-header-provenance.js";
|
|
34
|
-
import "./app-page-response.js";
|
|
35
|
-
import { parseNextHttpErrorDigest } from "./next-error-digest.js";
|
|
36
|
-
import { traceAppPageRender } from "./app-page-tracing.js";
|
|
37
30
|
import { openForwardedMiddlewareContext } from "./forwarded-middleware-context.js";
|
|
31
|
+
import { consumeResponseStageLinkProvenance, copyLinkHeaderProvenance } from "./app-response-header-provenance.js";
|
|
38
32
|
import { setFrameworkRequestRoute, traceFrameworkRequest } from "./request-tracing.js";
|
|
33
|
+
import { mergeMiddlewareResponseHeaders, mergeMiddlewareResponseHeadersOntoResponse, withExternalRewriteResponseHeaders } from "./middleware-response-headers.js";
|
|
34
|
+
import { VINEXT_RSC_CACHE_BUSTING_SEARCH_PARAM, canonicalizeLoadingShellRscRequestHeaders, canonicalizePrewarmableRscRequestHeaders, createCanonicalRscRequestUrl, createRscRedirectLocation, createRscRequestUrl, hasRscCacheBustingSearchParam, resolveInvalidRscCacheBustingRequest, stripRscCacheBustingSearchParam, stripRscSuffix } from "./app-rsc-cache-busting.js";
|
|
39
35
|
import { matchPrerenderRouteParamsPayload, readTrustedPrerenderRouteParams, serializePrerenderRouteParamsHeader } from "./prerender-route-params.js";
|
|
40
36
|
import { createServerActionNotFoundResponse, getServerActionNotFoundMessage } from "./server-action-not-found.js";
|
|
41
37
|
import { isPossibleAppRouteActionRequest } from "./app-action-request.js";
|
|
38
|
+
import "./app-page-response.js";
|
|
39
|
+
import { parseNextHttpErrorDigest } from "./next-error-digest.js";
|
|
42
40
|
import { isAppRouteHandlerRoute } from "./app-rsc-route-matching.js";
|
|
41
|
+
import { traceAppPageRender } from "./app-page-tracing.js";
|
|
43
42
|
import { normalizeInterceptionContextHeader } from "./app-interception-context-header.js";
|
|
44
43
|
import { buildPageCacheTags } from "./implicit-tags.js";
|
|
45
44
|
import { buildPostMwRequestContext } from "./app-post-middleware-context.js";
|
|
46
45
|
import { pickRootParams, setRootParams } from "../shims/root-params.js";
|
|
47
46
|
import { createRouteTreePrefetchResponse, isRouteTreePrefetchRequest } from "./app-route-tree-prefetch.js";
|
|
48
|
-
import { createSharedAppPageCacheIdentity, isStaticCandidateAppPageDispatch, prepareSharedAppPageDispatch, withoutAppPageDispatchQuery } from "./app-worker-stages.js";
|
|
47
|
+
import { createSharedAppCacheIdentity, createSharedAppPageCacheIdentity, createSharedHybridPagesCacheIdentity, isStaticCandidateAppPageDispatch, prepareSharedAppPageDispatch, withoutAppPageDispatchQuery } from "./app-worker-stages.js";
|
|
49
48
|
import { flattenErrorCauses } from "../utils/error-cause.js";
|
|
50
49
|
import { applyAppRscConfigHeaders, finalizeAppRscResponse, markAppRscResponseConfigHeadersApplied } from "./app-rsc-response-finalizer.js";
|
|
51
50
|
import { normalizeRscRequest } from "./app-rsc-request-normalization.js";
|
|
52
51
|
import { hasPagesPreviewCookie } from "./pages-response-stage.js";
|
|
53
52
|
import { runWithPrerenderWorkUnit } from "./prerender-work-unit-setup.js";
|
|
53
|
+
import { adapterSharedCacheIdentity, adapterUsesSharedCacheIdentity, pagesCacheIdentityOrigin, pagesPageSharesAcrossHosts } from "./shared-cache-identity.js";
|
|
54
54
|
import { consumePagesResponseStagePolicyOwner, withoutResponseStageVary } from "./response-stage-policy.js";
|
|
55
55
|
//#region src/server/app-rsc-handler.ts
|
|
56
56
|
const HAS_CONFIG_HEADERS = process.env.__VINEXT_HAS_CONFIG_HEADERS !== "false";
|
|
@@ -132,10 +132,6 @@ function readCacheabilityRequestProjection(options) {
|
|
|
132
132
|
};
|
|
133
133
|
return parsedCacheabilityRequestProjection.manifest;
|
|
134
134
|
}
|
|
135
|
-
function adapterUsesQueryFreeCacheIdentity() {
|
|
136
|
-
const adapter = getCdnCacheAdapter();
|
|
137
|
-
return adapter.requiresCompletedResponseAdmission === true && adapter.responseStageCacheIdentity === "query-free";
|
|
138
|
-
}
|
|
139
135
|
function hasUrlParserDotSegment(pathname) {
|
|
140
136
|
return pathname.split("/").some((segment) => {
|
|
141
137
|
const decodedDots = segment.replaceAll(/%2e/gi, ".");
|
|
@@ -312,7 +308,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
312
308
|
if (request.headers.has("X-Vinext-Interception-Context") || request.headers.has("X-Vinext-Interception-Id")) setInterceptionResponseUncacheable(true);
|
|
313
309
|
return normalized;
|
|
314
310
|
}
|
|
315
|
-
const { url, isRscRequest, interceptionContextHeader, interceptionIdHeader, mountedSlotsHeader, renderMode,
|
|
311
|
+
const { url, isRscRequest, interceptionContextHeader, interceptionIdHeader, mountedSlotsHeader, renderMode, hadBasePath } = normalized;
|
|
316
312
|
setFrameworkRequestRoute(void 0, isRscRequest);
|
|
317
313
|
const hasRawInterceptionContext = isRscRequest && request.headers.has("X-Vinext-Interception-Context");
|
|
318
314
|
if (hasRawInterceptionContext) setInterceptionResponseUncacheable(true);
|
|
@@ -509,7 +505,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
509
505
|
const rscPath = canonicalRsc.navigation ? createCanonicalRscRequestUrl(dispatchRequest.url) : await createRscRequestUrl(dispatchRequest.url, canonicalRsc.headers);
|
|
510
506
|
dispatchRequest = cloneRequestWithUrl(dispatchRequest, new URL(rscPath, dispatchRequest.url).toString());
|
|
511
507
|
}
|
|
512
|
-
const cacheIdentity = cache
|
|
508
|
+
const cacheIdentity = cache !== "shared" || stageProps.kind === "app-full-request" || stageProps.kind === "hybrid-pages" || !adapterUsesSharedCacheIdentity() ? void 0 : stageProps.kind === "app-page" && adapterSharedCacheIdentity() === "query-free" && responseStagePolicy === null && stageProps.matchKind !== "interception" && stageProps.interceptionContext === null && stageProps.interceptionId === null && stageProps.mountedSlotsHeader === null ? createSharedAppPageCacheIdentity(dispatchRequest, stageProps) : createSharedAppCacheIdentity(dispatchRequest, stageProps);
|
|
513
509
|
let response = await dispatchResponseStage(dispatchRequest, stageProps, cacheIdentity ? {
|
|
514
510
|
cache,
|
|
515
511
|
cacheIdentity
|
|
@@ -553,7 +549,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
553
549
|
isRscRequest,
|
|
554
550
|
middlewareCookieOverlay,
|
|
555
551
|
mountedSlotsHeader,
|
|
556
|
-
protocolVersion:
|
|
552
|
+
protocolVersion: 13,
|
|
557
553
|
requestOrigin: url.origin,
|
|
558
554
|
renderMode,
|
|
559
555
|
resolvedUrl,
|
|
@@ -921,10 +917,15 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
921
917
|
if (!filesystemRouteEligible) return null;
|
|
922
918
|
const pagesRouteUrl = cleanPathnameIsRequestPathname ? requestCleanPathname + resolvedUrl.slice(pathnameForResolvedUrl(resolvedUrl).length) : resolvedUrl;
|
|
923
919
|
let sharedOuterPolicyNeedsReconciliation = false;
|
|
924
|
-
const dispatchPagesResponseStage = dispatchResponseStage ? async (stageRequest, resourceKind, dataKind, hasRequestAwareDocument) => {
|
|
920
|
+
const dispatchPagesResponseStage = dispatchResponseStage ? async (stageRequest, resourceKind, dataKind, hasRequestAwareDocument, runsInitialProps) => {
|
|
925
921
|
const pagesOnDemandRevalidate = resourceKind === "page" && isOnDemandRevalidateRequest(stageRequest.headers.get("x-prerender-revalidate"));
|
|
926
922
|
const cache = responseStageProbeMode || pagesOnDemandRevalidate || hasPagesPreviewCookie(stageRequest.headers.get("cookie")) || resourceKind === "page" && dataKind === "static" && hasRequestAwareDocument ? "bypass" : canUseSharedWorkerResponseStage ? "shared" : "bypass";
|
|
927
|
-
|
|
923
|
+
const renderRequest = responseStageRequest(stageRequest);
|
|
924
|
+
const sharedAcrossHosts = (cache === "shared" || responseStageProbeMode !== null) && resourceKind === "page" && pagesPageSharesAcrossHosts({
|
|
925
|
+
dataKind,
|
|
926
|
+
runsInitialProps
|
|
927
|
+
}) && adapterUsesSharedCacheIdentity();
|
|
928
|
+
const hybridProps = {
|
|
928
929
|
kind: "hybrid-pages",
|
|
929
930
|
buildId: options.buildId,
|
|
930
931
|
cacheability: {
|
|
@@ -945,13 +946,18 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
945
946
|
matchKind,
|
|
946
947
|
middlewareCookieOverlay,
|
|
947
948
|
preHandlerHeaders: cache === "shared" && resourceKind === "page" && dataKind === "static" ? null : [...await loadPreHandlerResponseHeaders()],
|
|
948
|
-
protocolVersion:
|
|
949
|
+
protocolVersion: 13,
|
|
949
950
|
requestOrigin: url.origin,
|
|
950
951
|
resourceKind,
|
|
951
952
|
requestUrl: request.url,
|
|
952
953
|
resolvedUrl: pagesRouteUrl,
|
|
953
|
-
scriptNonce: scriptNonce ?? null
|
|
954
|
-
|
|
954
|
+
scriptNonce: scriptNonce ?? null,
|
|
955
|
+
sharedAcrossHosts
|
|
956
|
+
};
|
|
957
|
+
let response = await dispatchResponseStage(renderRequest, hybridProps, cache === "shared" && sharedAcrossHosts ? {
|
|
958
|
+
cache,
|
|
959
|
+
cacheIdentity: createSharedHybridPagesCacheIdentity(renderRequest, hybridProps, pagesCacheIdentityOrigin(request.url, options.i18nConfig))
|
|
960
|
+
} : { cache });
|
|
955
961
|
const policyOwner = resourceKind === "page" ? consumePagesResponseStagePolicyOwner(response) : {
|
|
956
962
|
owner: null,
|
|
957
963
|
response
|
|
@@ -1159,7 +1165,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
1159
1165
|
isRscRequest,
|
|
1160
1166
|
middlewareCookieOverlay,
|
|
1161
1167
|
mountedSlotsHeader,
|
|
1162
|
-
protocolVersion:
|
|
1168
|
+
protocolVersion: 13,
|
|
1163
1169
|
requestOrigin: url.origin,
|
|
1164
1170
|
renderMode,
|
|
1165
1171
|
resolvedUrl,
|
|
@@ -1246,7 +1252,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
1246
1252
|
middlewareCookieOverlay,
|
|
1247
1253
|
mountedSlotsHeader,
|
|
1248
1254
|
params,
|
|
1249
|
-
protocolVersion:
|
|
1255
|
+
protocolVersion: 13,
|
|
1250
1256
|
requestOrigin: url.origin,
|
|
1251
1257
|
renderMode,
|
|
1252
1258
|
resolvedUrl,
|
|
@@ -1288,7 +1294,7 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
1288
1294
|
middlewareCookieOverlay,
|
|
1289
1295
|
mountedSlotsHeader,
|
|
1290
1296
|
params,
|
|
1291
|
-
protocolVersion:
|
|
1297
|
+
protocolVersion: 13,
|
|
1292
1298
|
requestOrigin: url.origin,
|
|
1293
1299
|
renderMode,
|
|
1294
1300
|
resolvedUrl,
|
|
@@ -1298,7 +1304,6 @@ async function handleAppRscRequest(options, request, preMiddlewareRequestContext
|
|
|
1298
1304
|
}).then(composeResponseStageResponse) : await options.dispatchMatchedPage({
|
|
1299
1305
|
bypassInterceptionContextCache,
|
|
1300
1306
|
cachePathname,
|
|
1301
|
-
clientReuseManifest,
|
|
1302
1307
|
cleanPathname,
|
|
1303
1308
|
displayPathname: canonicalPathname,
|
|
1304
1309
|
formState: progressiveActionFormState?.formState ?? null,
|
|
@@ -1406,6 +1411,7 @@ function createAppRscRequestHandler(options) {
|
|
|
1406
1411
|
const requestContext = createRequestContext({
|
|
1407
1412
|
headersContext,
|
|
1408
1413
|
executionContext,
|
|
1414
|
+
isOnDemandRevalidate: isOnDemandRevalidateRequest(request.headers.get(PRERENDER_REVALIDATE_HEADER)),
|
|
1409
1415
|
requestSignal: executionContext?.requestSignal ?? rawRequestSignal,
|
|
1410
1416
|
unstableCacheRevalidation: "background"
|
|
1411
1417
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ClientReuseManifestParseResult } from "./client-reuse-manifest.js";
|
|
2
1
|
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
3
2
|
import { normalizeMountedSlotsHeader } from "./app-mounted-slots-header.js";
|
|
4
3
|
//#region src/server/app-rsc-request-normalization.d.ts
|
|
@@ -21,8 +20,6 @@ export type NormalizedRscRequest = {
|
|
|
21
20
|
mountedSlotsHeader: string | null;
|
|
22
21
|
/** Semantic RSC payload mode. HTML requests always normalize to "navigation". */
|
|
23
22
|
renderMode: AppRscRenderMode;
|
|
24
|
-
/** Parsed ClientReuseManifest hint. Verification and skip authorization happen later. */
|
|
25
|
-
clientReuseManifest: ClientReuseManifestParseResult;
|
|
26
23
|
/** Whether the incoming pathname included the configured basePath. */
|
|
27
24
|
hadBasePath: boolean;
|
|
28
25
|
};
|
|
@@ -52,7 +49,6 @@ export type NormalizedRscRequest = {
|
|
|
52
49
|
* 8. Sanitize X-Vinext-Interception-Context — strip null bytes (header injection)
|
|
53
50
|
* 9. Normalize x-vinext-mounted-slots — dedup and sort for canonical cache keys
|
|
54
51
|
* 10. Read semantic render mode for refresh/action payload rendering
|
|
55
|
-
* 11. Parse ClientReuseManifest hints on canonical RSC payload requests
|
|
56
52
|
*
|
|
57
53
|
* @returns A 400 or 404 Response for invalid or out-of-scope inputs,
|
|
58
54
|
* or a NormalizedRscRequest for valid requests.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hasBasePath, stripBasePath } from "../utils/base-path.js";
|
|
2
2
|
import { NEXT_ROUTER_STATE_TREE_HEADER, NEXT_URL_HEADER, VINEXT_INTERCEPTION_CONTEXT_HEADER, VINEXT_INTERCEPTION_ID_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_RSC_RENDER_MODE_HEADER } from "./app-rsc-vary.js";
|
|
3
|
-
import
|
|
3
|
+
import "./headers.js";
|
|
4
4
|
import { badRequestResponse, notFoundResponse } from "./http-error-responses.js";
|
|
5
5
|
import { guardProtocolRelativeUrl } from "./request-pipeline.js";
|
|
6
6
|
import { assetPrefixPathname, isNextStaticPath } from "../utils/asset-prefix.js";
|
|
@@ -9,7 +9,6 @@ import { normalizePath } from "./normalize-path.js";
|
|
|
9
9
|
import { normalizeMountedSlotsHeader } from "./app-mounted-slots-header.js";
|
|
10
10
|
import { APP_RSC_RENDER_MODE_NAVIGATION, APP_RSC_RENDER_MODE_PREFETCH_EMPTY, APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL, parseAppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
11
11
|
import { VINEXT_RSC_CACHE_BUSTING_SEARCH_PARAM, stripRscSuffix } from "./app-rsc-cache-busting.js";
|
|
12
|
-
import { parseClientReuseManifestHeader } from "./client-reuse-manifest.js";
|
|
13
12
|
import { normalizeInterceptionContextHeader } from "./app-interception-context-header.js";
|
|
14
13
|
//#region src/server/app-rsc-request-normalization.ts
|
|
15
14
|
function extractFlightRouterStatePath(value, depth = 0) {
|
|
@@ -86,7 +85,6 @@ function tryNormalizeComparablePathAndSearch(value, basePath, baseUrl) {
|
|
|
86
85
|
* 8. Sanitize X-Vinext-Interception-Context — strip null bytes (header injection)
|
|
87
86
|
* 9. Normalize x-vinext-mounted-slots — dedup and sort for canonical cache keys
|
|
88
87
|
* 10. Read semantic render mode for refresh/action payload rendering
|
|
89
|
-
* 11. Parse ClientReuseManifest hints on canonical RSC payload requests
|
|
90
88
|
*
|
|
91
89
|
* @returns A 400 or 404 Response for invalid or out-of-scope inputs,
|
|
92
90
|
* or a NormalizedRscRequest for valid requests.
|
|
@@ -135,7 +133,6 @@ function normalizeRscRequest(request, basePath, allowOutsideBasePath = false, as
|
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
135
|
return {
|
|
138
|
-
clientReuseManifest: isRscRequest ? parseClientReuseManifestHeader(request.headers.get(VINEXT_CLIENT_REUSE_MANIFEST_HEADER)) : { kind: "absent" },
|
|
139
136
|
hadBasePath,
|
|
140
137
|
url,
|
|
141
138
|
pathname,
|
|
@@ -6,9 +6,9 @@ import { normalizeDefaultLocalePathname } from "./pages-i18n.js";
|
|
|
6
6
|
import { isNonCacheableCacheControl } from "../shims/cdn-cache.js";
|
|
7
7
|
import { captureRouteCacheabilityResponsePolicy } from "../shims/cacheability-classification.js";
|
|
8
8
|
import { NO_STORE_CACHE_CONTROL, applyCdnResponseHeaders, captureCdnResponsePolicyHeaders, hasExplicitNonCacheableResponsePolicy, isCdnResponsePolicyHeader } from "./cache-control.js";
|
|
9
|
-
import "./app-rsc-cache-busting.js";
|
|
10
|
-
import { mergeVaryHeader } from "./middleware-response-headers.js";
|
|
11
9
|
import { hasPostConfigLinkHeaders } from "./app-response-header-provenance.js";
|
|
10
|
+
import { mergeVaryHeader } from "./middleware-response-headers.js";
|
|
11
|
+
import "./app-rsc-cache-busting.js";
|
|
12
12
|
//#region src/server/app-rsc-response-finalizer.ts
|
|
13
13
|
const HAS_CONFIG_HEADERS = process.env.__VINEXT_HAS_CONFIG_HEADERS !== "false";
|
|
14
14
|
const configHeadersAlreadyApplied = /* @__PURE__ */ new WeakSet();
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { preserveFullyBufferedBodyMetadata } from "./fully-buffered-response.js";
|
|
2
2
|
import { closeAfterResponse, closeAfterResponseWithBody, createRequestContext, runWithRequestContext } from "../shims/unified-request-context.js";
|
|
3
|
-
import { VINEXT_REVALIDATE_HOST_HEADER } from "../utils/protocol-headers.js";
|
|
3
|
+
import { PRERENDER_REVALIDATE_HEADER, VINEXT_REVALIDATE_HOST_HEADER } from "../utils/protocol-headers.js";
|
|
4
4
|
import "./headers.js";
|
|
5
5
|
import { cloneRequestWithHeaders, cloneRequestWithUrl, filterInternalHeaders } from "./request-pipeline.js";
|
|
6
6
|
import { getRequestExecutionContext } from "../shims/request-context.js";
|
|
7
7
|
import { runOutsideWorkStoreScope } from "../shims/internal/work-store-scope.js";
|
|
8
|
+
import { isOnDemandRevalidateRequest } from "./revalidation-request.js";
|
|
8
9
|
import { applyEffectiveRequestCookieHeader, getDraftModeCookieHeader, headersContextFromRequest, restoreDraftModeTransition } from "../shims/headers.js";
|
|
9
10
|
import { ensureFetchPatch, setCurrentFetchSoftTags } from "../shims/fetch-cache.js";
|
|
10
11
|
import { traceFindPageComponents } from "./pages-execution-tracing.js";
|
|
@@ -69,7 +70,7 @@ function rematchAppWorkerResponseStageRoute(options, normalized, props) {
|
|
|
69
70
|
return match;
|
|
70
71
|
}
|
|
71
72
|
async function renderAppWorkerResponseStage(options, rawRequest, ctx, props, stageOptions) {
|
|
72
|
-
if (props.protocolVersion !==
|
|
73
|
+
if (props.protocolVersion !== 13 || props.buildId !== options.buildId) return new Response("Incompatible vinext App response stage", { status: 409 });
|
|
73
74
|
if (props.kind === "app-full-request") return new Response("Invalid vinext App response stage", { status: 400 });
|
|
74
75
|
const rawRequestSignal = rawRequest.signal;
|
|
75
76
|
options.registerCacheAdapters();
|
|
@@ -104,6 +105,7 @@ async function renderAppWorkerResponseStage(options, rawRequest, ctx, props, sta
|
|
|
104
105
|
const requestContext = createRequestContext({
|
|
105
106
|
headersContext,
|
|
106
107
|
executionContext,
|
|
108
|
+
isOnDemandRevalidate: isOnDemandRevalidateRequest(request.headers.get(PRERENDER_REVALIDATE_HEADER)),
|
|
107
109
|
requestSignal: executionContext?.requestSignal ?? rawRequestSignal,
|
|
108
110
|
unstableCacheRevalidation: "background"
|
|
109
111
|
});
|
|
@@ -171,6 +173,7 @@ async function renderAppWorkerResponseStage(options, rawRequest, ctx, props, sta
|
|
|
171
173
|
pathname: props.resolvedUrl,
|
|
172
174
|
pagesDataRequest: props.isDataRequest ? request : null,
|
|
173
175
|
request: pageRequest,
|
|
176
|
+
sharedAcrossHosts: props.sharedAcrossHosts,
|
|
174
177
|
url: new URL(props.requestUrl)
|
|
175
178
|
}));
|
|
176
179
|
if (!pagesResponse) return new Response("Invalid vinext App response stage", { status: 404 });
|
|
@@ -216,7 +219,6 @@ async function renderAppWorkerResponseStage(options, rawRequest, ctx, props, sta
|
|
|
216
219
|
return options.dispatchMatchedPage({
|
|
217
220
|
bypassInterceptionContextCache: props.bypassInterceptionContextCache,
|
|
218
221
|
cachePathname: props.cachePathname,
|
|
219
|
-
clientReuseManifest: normalized.clientReuseManifest,
|
|
220
222
|
cleanPathname: props.cleanPathname,
|
|
221
223
|
displayPathname: props.canonicalPathname,
|
|
222
224
|
formState: null,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
2
|
-
import { ActionRevalidationKind } from "../shims/cache-request-state.js";
|
|
3
2
|
import { AppRenderErrorContextOverrides } from "./app-rsc-error-handler.js";
|
|
4
3
|
import { FetchCacheMode } from "../shims/fetch-cache-state.js";
|
|
5
4
|
import "../shims/fetch-cache.js";
|
|
6
5
|
import { HeadersAccessPhase } from "../shims/internal/headers-state.js";
|
|
7
6
|
import "../shims/headers.js";
|
|
7
|
+
import { ActionRevalidationKind } from "../shims/cache-request-state.js";
|
|
8
8
|
import { ReactFormState } from "react-dom/client";
|
|
9
9
|
//#region src/server/app-server-action-execution.d.ts
|
|
10
10
|
type AppPageParams = Record<string, string | string[]>;
|
|
@@ -156,6 +156,8 @@ export type HandleProgressiveServerActionRequestOptions = {
|
|
|
156
156
|
* routes fall through. See issue #1340.
|
|
157
157
|
*/
|
|
158
158
|
hasPageRoute: boolean;
|
|
159
|
+
/** The App Router route the form posted to, whose implicit tags the action runs with. */
|
|
160
|
+
currentRoute?: AppServerActionRoute | null;
|
|
159
161
|
maxActionBodySize: number;
|
|
160
162
|
middlewareHeaders: Headers | null;
|
|
161
163
|
readFormDataWithLimit: ReadFormDataWithLimit;
|
|
@@ -6,7 +6,7 @@ import { parseEdgeRequestCookieHeader } from "../utils/parse-cookie.js";
|
|
|
6
6
|
import { isExternalUrl } from "../utils/external-url.js";
|
|
7
7
|
import { addBasePathToPathname, hasBasePath, stripBasePath } from "../utils/base-path.js";
|
|
8
8
|
import { NEXT_ROUTER_STATE_TREE_HEADER, VINEXT_RSC_VARY_HEADER } from "./app-rsc-vary.js";
|
|
9
|
-
import { ACTION_FORWARDED_HEADER, ACTION_REDIRECT_HEADER, ACTION_REDIRECT_STATUS_HEADER, ACTION_REDIRECT_TYPE_HEADER, ACTION_REVALIDATED_HEADER, VINEXT_RENDERED_PATH_AND_SEARCH_HEADER } from "./headers.js";
|
|
9
|
+
import { ACTION_FORWARDED_HEADER, ACTION_REDIRECT_HEADER, ACTION_REDIRECT_STATUS_HEADER, ACTION_REDIRECT_TYPE_HEADER, ACTION_REVALIDATED_HEADER, VINEXT_MOUNTED_LAYOUTS_HEADER, VINEXT_RENDERED_PATH_AND_SEARCH_HEADER } from "./headers.js";
|
|
10
10
|
import { internalServerErrorResponse, payloadTooLargeResponse } from "./http-error-responses.js";
|
|
11
11
|
import { attachRequestCfMetadata, validateCsrfOrigin, validateServerActionPayload } from "./request-pipeline.js";
|
|
12
12
|
import { splitPathSegments } from "../routing/utils.js";
|
|
@@ -17,13 +17,13 @@ import { isDraftModeRequest, setHeadersContext } from "../shims/headers.js";
|
|
|
17
17
|
import { _drainPendingRevalidations, getAndClearActionRevalidationKind } from "../shims/cache-request-state.js";
|
|
18
18
|
import { setCurrentFetchCacheMode, setCurrentFetchRevalidate, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault } from "../shims/fetch-cache.js";
|
|
19
19
|
import { readStreamAsTextWithLimit } from "../utils/text-stream.js";
|
|
20
|
-
import { VINEXT_RSC_CONTENT_TYPE, applyRscCompatibilityIdHeader, createRscRequestUrl, stripRscCacheBustingSearchParam } from "./app-rsc-cache-busting.js";
|
|
21
20
|
import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
|
|
21
|
+
import { VINEXT_RSC_CONTENT_TYPE, applyRscCompatibilityIdHeader, createRscRequestUrl, stripRscCacheBustingSearchParam } from "./app-rsc-cache-busting.js";
|
|
22
|
+
import { getSetCookieName } from "./cookie-utils.js";
|
|
23
|
+
import { createServerActionNotFoundResponse, getServerActionNotFoundMessage, isServerActionNotFoundError } from "./server-action-not-found.js";
|
|
22
24
|
import { applyEdgeRuntimeHeader } from "./app-page-response.js";
|
|
23
25
|
import { getNextErrorDigest, parseNextHttpErrorDigest, parseNextRedirectDigest } from "./next-error-digest.js";
|
|
24
26
|
import { hasDigest } from "./app-rsc-errors.js";
|
|
25
|
-
import { getSetCookieName } from "./cookie-utils.js";
|
|
26
|
-
import { createServerActionNotFoundResponse, getServerActionNotFoundMessage, isServerActionNotFoundError } from "./server-action-not-found.js";
|
|
27
27
|
import { resolveAppPageNavigationParams } from "./app-page-element-builder.js";
|
|
28
28
|
import "./app-page-stream.js";
|
|
29
29
|
import { buildAppPageTags } from "./implicit-tags.js";
|
|
@@ -211,6 +211,7 @@ async function createActionRedirectTargetRequest(options) {
|
|
|
211
211
|
headers.set("cookie", cookieHeader ?? "");
|
|
212
212
|
headers.set("RSC", "1");
|
|
213
213
|
headers.delete(NEXT_ROUTER_STATE_TREE_HEADER);
|
|
214
|
+
headers.delete(VINEXT_MOUNTED_LAYOUTS_HEADER);
|
|
214
215
|
stripRscCacheBustingSearchParam(options.url);
|
|
215
216
|
const requestPath = await createRscRequestUrl(`${options.url.pathname}${options.url.search}`, headers);
|
|
216
217
|
const requestUrl = new URL(requestPath, options.url.origin);
|
|
@@ -614,6 +615,7 @@ async function handleProgressiveServerActionRequest(options) {
|
|
|
614
615
|
let actionThrew = false;
|
|
615
616
|
let actionResult;
|
|
616
617
|
const rootParamsUsage = createRootParamsUsageController();
|
|
618
|
+
if (options.currentRoute) setCurrentFetchSoftTags(buildServerActionPageTags(options.currentRoute, options.cleanPathname));
|
|
617
619
|
const previousHeadersPhase = options.setHeadersAccessPhase("action");
|
|
618
620
|
try {
|
|
619
621
|
actionResult = await runWithRootParamsUsage({ kind: "server-action" }, action, rootParamsUsage);
|
|
@@ -823,6 +825,7 @@ async function handleServerActionRscRequest(options) {
|
|
|
823
825
|
let actionThrew = false;
|
|
824
826
|
const actionWasForwarded = Boolean(options.request.headers.get(ACTION_FORWARDED_HEADER));
|
|
825
827
|
const rootParamsUsage = createRootParamsUsageController();
|
|
828
|
+
if (options.currentRouteMatch) setCurrentFetchSoftTags(buildServerActionPageTags(options.currentRouteMatch.route, options.cleanPathname));
|
|
826
829
|
const previousHeadersPhase = options.setHeadersAccessPhase("action");
|
|
827
830
|
try {
|
|
828
831
|
try {
|
|
@@ -25,6 +25,8 @@ export declare function handleSsr(rscStream: ReadableStream<Uint8Array>, navCont
|
|
|
25
25
|
value: Promise<ArrayBuffer> | null;
|
|
26
26
|
};
|
|
27
27
|
pprFallbackShellSignal?: AbortSignal;
|
|
28
|
+
/** Aborts a streaming render whose document is given up. */
|
|
29
|
+
signal?: AbortSignal;
|
|
28
30
|
/**
|
|
29
31
|
* Pattern of the route this render shows, whose client references load
|
|
30
32
|
* before it starts, or null for a render without a route (a route-miss
|
|
@@ -10,23 +10,23 @@ import { withScriptNonce } from "../shims/script-nonce-context.js";
|
|
|
10
10
|
import { createInlineScriptTag, createNonceAttribute, escapeHtmlAttr, safeJsonStringify } from "./html.js";
|
|
11
11
|
import { getClientTraceMetadataHTML, markClientTraceMetadataBlock } from "./client-trace-metadata.js";
|
|
12
12
|
import { setPagesClientAssets } from "./pages-client-assets.js";
|
|
13
|
+
import { RSC_FORM_STATE_GLOBAL } from "../client/browser-globals.js";
|
|
14
|
+
import { createNavigationRuntimeRenderedSearchScript, createNavigationRuntimeRscCompatibilityScript, createNavigationRuntimeRscMetadataScript, createRscEmbedTransform, createTickBufferedTransform, rewriteInlineCssStylesheetLinks, waitAtLeastOneReactRenderTask } from "./app-ssr-stream.js";
|
|
13
15
|
import { AppElementsWire } from "./app-elements-wire.js";
|
|
14
16
|
import "./app-elements.js";
|
|
17
|
+
import { createInitialBfcacheMaps } from "./app-bfcache-identity.js";
|
|
15
18
|
import { ServerInsertedHTMLContext, clearServerInsertedHTML, getBfcacheIdMapContext, registerServerInsertedHTMLCallback, renderServerInsertedHTML, setNavigationContext } from "../shims/navigation-context-state.js";
|
|
16
19
|
import "../shims/navigation-server.js";
|
|
17
|
-
import DefaultGlobalError from "../shims/default-global-error.js";
|
|
18
|
-
import { CAUGHT_NOT_FOUND_BOUNDARIES_GLOBAL, withCaughtNotFoundBoundaries } from "../shims/caught-not-found-boundaries.js";
|
|
19
20
|
import { BfcacheIdentityMapContext } from "../shims/slot.js";
|
|
20
|
-
import { getNextErrorDigest } from "./next-error-digest.js";
|
|
21
|
-
import { createSsrErrorMetaRenderer } from "./app-ssr-error-meta.js";
|
|
22
|
-
import { createRenderStreamCancellation, isAppRenderAbortError } from "./app-render-abort-error.js";
|
|
23
|
-
import { RSC_FORM_STATE_GLOBAL } from "../client/browser-globals.js";
|
|
24
|
-
import { createNavigationRuntimeRenderedSearchScript, createNavigationRuntimeRscCompatibilityScript, createNavigationRuntimeRscMetadataScript, createRscEmbedTransform, createTickBufferedTransform, rewriteInlineCssStylesheetLinks, waitAtLeastOneReactRenderTask } from "./app-ssr-stream.js";
|
|
25
|
-
import { createInitialBfcacheMaps } from "./app-bfcache-identity.js";
|
|
26
21
|
import { createAppRouteTree } from "./app-route-tree.js";
|
|
22
|
+
import DefaultGlobalError from "../shims/default-global-error.js";
|
|
23
|
+
import { CAUGHT_NOT_FOUND_BOUNDARIES_GLOBAL, withCaughtNotFoundBoundaries } from "../shims/caught-not-found-boundaries.js";
|
|
27
24
|
import { ssrServerConsumerManifest } from "./app-client-reference-manifest.js";
|
|
28
25
|
import { createClientReferencePreloader, resolveRouteClientReferences } from "./app-client-reference-preloader.js";
|
|
26
|
+
import { getNextErrorDigest } from "./next-error-digest.js";
|
|
27
|
+
import { createSsrErrorMetaRenderer } from "./app-ssr-error-meta.js";
|
|
29
28
|
import { createClientPageSsrSearchParamsSource } from "./app-page-search-params-observation.js";
|
|
29
|
+
import { createRenderStreamCancellation, isAppRenderAbortError } from "./app-render-abort-error.js";
|
|
30
30
|
import { runWithRootParamsScope } from "../shims/root-params.js";
|
|
31
31
|
import { runWithNavigationContext } from "../shims/navigation-state.js";
|
|
32
32
|
import { startCandidateSearchParamsGate } from "./app-ssr-search-params-gate.js";
|
|
@@ -277,6 +277,7 @@ async function handleSsr(rscStream, navContext, fontData, options) {
|
|
|
277
277
|
if (link) reactLinkHeader = link;
|
|
278
278
|
} : void 0,
|
|
279
279
|
maxHeadersLength: captureHeaders ? maxHeadersLength : void 0,
|
|
280
|
+
signal: options?.signal,
|
|
280
281
|
onError(error) {
|
|
281
282
|
if (pprFallbackShellSignal && isPprFallbackShellAbortError(error)) return;
|
|
282
283
|
if (isAppRenderAbortError(error) || htmlCancellation.isReason(error)) return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createNonceAttribute, escapeHtmlAttr, htmlTokenListContains, safeJsonStringify, scriptSafeJsonStringify } from "./html.js";
|
|
2
|
-
import { getVinextRscCompatibilityId } from "./app-rsc-cache-busting.js";
|
|
3
2
|
import { bytesToBase64, concatUint8Arrays } from "./app-rsc-embedded-chunks.js";
|
|
4
3
|
import { NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION } from "../client/browser-globals.js";
|
|
4
|
+
import { getVinextRscCompatibilityId } from "./app-rsc-cache-busting.js";
|
|
5
5
|
import { Buffer, isUtf8 } from "node:buffer";
|
|
6
6
|
//#region src/server/app-ssr-stream.ts
|
|
7
7
|
const RSC_EMBED_TEXT_BATCH_MAX_BYTES = 65536;
|
|
@@ -7,7 +7,17 @@ export type VisitedResponseCacheEntry = {
|
|
|
7
7
|
createdAt: number;
|
|
8
8
|
elements?: AppElements;
|
|
9
9
|
expiresAt: number;
|
|
10
|
+
/**
|
|
11
|
+
* Stored by initial hydration, which Next.js keeps out of its route cache
|
|
12
|
+
* (outside Cache Components), so a visible Link still prefetches the URL.
|
|
13
|
+
*/
|
|
14
|
+
fromHydration?: true;
|
|
10
15
|
mountedSlotsHeader: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* A history restore revoked navigation reuse. The entry stays only as the
|
|
18
|
+
* BFCache that a full prefetch reads (see `findVisitedResponseForFullPrefetch`).
|
|
19
|
+
*/
|
|
20
|
+
navigationReuseRevoked?: true;
|
|
11
21
|
params: Record<string, string | string[]>;
|
|
12
22
|
response: CachedRscResponse;
|
|
13
23
|
reuseAfterHistoryRestore: boolean;
|
|
@@ -18,6 +28,7 @@ export declare function hasNavigationResponseHistoryLifetime(snapshot: CachedRsc
|
|
|
18
28
|
export declare function createVisitedResponseCacheEntry(options: {
|
|
19
29
|
elements?: AppElements;
|
|
20
30
|
fallbackTtlMs?: number;
|
|
31
|
+
fromHydration?: boolean;
|
|
21
32
|
now: number;
|
|
22
33
|
mountedSlotsHeader?: string | null;
|
|
23
34
|
params: Record<string, string | string[]>;
|
|
@@ -34,6 +45,30 @@ export declare function findVisitedResponseCacheEntry(cache: Map<string, Visited
|
|
|
34
45
|
} | null;
|
|
35
46
|
export declare function deleteVisitedResponseCacheEntry(cache: Map<string, VisitedResponseCacheEntry>, rscUrl: string, interceptionContext: string | null): boolean;
|
|
36
47
|
export declare function deleteAllVisitedResponseCacheEntries(cache: Map<string, VisitedResponseCacheEntry>, rscUrl: string, interceptionContext: string | null): number;
|
|
37
|
-
export declare function
|
|
48
|
+
export declare function revokeHistoryRestoreNavigationReuse(cache: Map<string, VisitedResponseCacheEntry>): void;
|
|
49
|
+
/**
|
|
50
|
+
* Next.js fulfills a full prefetch from the BFCache, which holds the data of
|
|
51
|
+
* every navigation, while it is within the static stale time of that
|
|
52
|
+
* navigation (`attemptToFulfillDynamicSegmentFromBFCache`). Navigation reuse
|
|
53
|
+
* that a history restore revoked does not matter here.
|
|
54
|
+
*
|
|
55
|
+
* Next.js dates a BFCache entry from its navigation, even one that committed an
|
|
56
|
+
* older prefetched payload. Its re-prefetch of an expired route still waits for
|
|
57
|
+
* a fresh route tree first, so a navigation made then fetches fresh data
|
|
58
|
+
* (`client-cache.experimental.test.ts`, "re-use the cache for 5 minutes").
|
|
59
|
+
* vinext seeds the full prefetch synchronously, so dating it from the
|
|
60
|
+
* navigation would replay that expired payload. It dates from when the payload
|
|
61
|
+
* arrived instead, which only costs a request Next.js might have saved.
|
|
62
|
+
*
|
|
63
|
+
* The match follows direct visited reuse: an entry with committed elements
|
|
64
|
+
* replays them, because its raw response may be skip-pruned against the tree
|
|
65
|
+
* it was requested from; otherwise the request-time or response-declared slot
|
|
66
|
+
* context must match.
|
|
67
|
+
*/
|
|
68
|
+
export declare function findVisitedResponseForFullPrefetch(cache: Map<string, VisitedResponseCacheEntry>, rscUrls: readonly string[], interceptionContext: string | null, mountedSlotsHeader: string | null): {
|
|
69
|
+
navigatedAt: number;
|
|
70
|
+
navigationFreshUntil: number | null;
|
|
71
|
+
response: CachedRscResponse;
|
|
72
|
+
} | null;
|
|
38
73
|
//#endregion
|
|
39
74
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { parseRscRequestPath, stripRscCacheBustingSearchParam } from "./app-rsc-cache-busting.js";
|
|
1
2
|
import { AppElementsWire } from "./app-elements-wire.js";
|
|
2
3
|
import "./app-elements.js";
|
|
3
|
-
import { parseRscRequestPath, stripRscCacheBustingSearchParam } from "./app-rsc-cache-busting.js";
|
|
4
4
|
import { resolveCachedRscResponseExpiresAt } from "../shims/navigation.js";
|
|
5
5
|
//#region src/server/app-visited-response-cache.ts
|
|
6
6
|
const VISITED_RESPONSE_CACHE_TTL = 3e5;
|
|
@@ -14,6 +14,7 @@ function createVisitedResponseCacheEntry(options) {
|
|
|
14
14
|
createdAt: options.now,
|
|
15
15
|
...options.elements ? { elements: options.elements } : {},
|
|
16
16
|
expiresAt: resolveCachedRscResponseExpiresAt(options.now, options.response, options.fallbackTtlMs ?? 3e5),
|
|
17
|
+
...options.fromHydration === true ? { fromHydration: true } : {},
|
|
17
18
|
mountedSlotsHeader: options.mountedSlotsHeader ?? null,
|
|
18
19
|
params: options.params,
|
|
19
20
|
response: options.response,
|
|
@@ -75,11 +76,51 @@ function deleteAllVisitedResponseCacheEntries(cache, rscUrl, interceptionContext
|
|
|
75
76
|
while (deleteVisitedResponseCacheEntry(cache, rscUrl, interceptionContext)) deleted++;
|
|
76
77
|
return deleted;
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
-
for (const
|
|
79
|
+
function revokeHistoryRestoreNavigationReuse(cache) {
|
|
80
|
+
for (const entry of cache.values()) {
|
|
80
81
|
if (entry.reuseAfterHistoryRestore) continue;
|
|
81
|
-
|
|
82
|
+
entry.navigationReuseRevoked = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Next.js fulfills a full prefetch from the BFCache, which holds the data of
|
|
87
|
+
* every navigation, while it is within the static stale time of that
|
|
88
|
+
* navigation (`attemptToFulfillDynamicSegmentFromBFCache`). Navigation reuse
|
|
89
|
+
* that a history restore revoked does not matter here.
|
|
90
|
+
*
|
|
91
|
+
* Next.js dates a BFCache entry from its navigation, even one that committed an
|
|
92
|
+
* older prefetched payload. Its re-prefetch of an expired route still waits for
|
|
93
|
+
* a fresh route tree first, so a navigation made then fetches fresh data
|
|
94
|
+
* (`client-cache.experimental.test.ts`, "re-use the cache for 5 minutes").
|
|
95
|
+
* vinext seeds the full prefetch synchronously, so dating it from the
|
|
96
|
+
* navigation would replay that expired payload. It dates from when the payload
|
|
97
|
+
* arrived instead, which only costs a request Next.js might have saved.
|
|
98
|
+
*
|
|
99
|
+
* The match follows direct visited reuse: an entry with committed elements
|
|
100
|
+
* replays them, because its raw response may be skip-pruned against the tree
|
|
101
|
+
* it was requested from; otherwise the request-time or response-declared slot
|
|
102
|
+
* context must match.
|
|
103
|
+
*/
|
|
104
|
+
function findVisitedResponseForFullPrefetch(cache, rscUrls, interceptionContext, mountedSlotsHeader) {
|
|
105
|
+
for (const rscUrl of rscUrls) {
|
|
106
|
+
const match = findVisitedResponseCacheEntry(cache, rscUrl, interceptionContext);
|
|
107
|
+
if (match === null) continue;
|
|
108
|
+
const { entry } = match;
|
|
109
|
+
if (entry.elements === void 0 && entry.mountedSlotsHeader !== mountedSlotsHeader && (entry.response.mountedSlotsHeader ?? null) !== mountedSlotsHeader) continue;
|
|
110
|
+
const navigationFresh = entry.fromHydration !== true && entry.navigationReuseRevoked !== true && (entry.elements !== void 0 || entry.mountedSlotsHeader === mountedSlotsHeader) && isVisitedResponseCacheEntryFresh(entry, {
|
|
111
|
+
navigationKind: "navigate",
|
|
112
|
+
now: Date.now()
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
navigatedAt: entry.response.receivedAt ?? entry.createdAt,
|
|
116
|
+
navigationFreshUntil: navigationFresh ? entry.expiresAt : null,
|
|
117
|
+
response: entry.elements === void 0 ? entry.response : {
|
|
118
|
+
...entry.response,
|
|
119
|
+
preparedElements: entry.elements
|
|
120
|
+
}
|
|
121
|
+
};
|
|
82
122
|
}
|
|
123
|
+
return null;
|
|
83
124
|
}
|
|
84
125
|
//#endregion
|
|
85
|
-
export { MAX_TRAVERSAL_CACHE_TTL, VISITED_RESPONSE_CACHE_TTL, createVisitedResponseCacheEntry, deleteAllVisitedResponseCacheEntries,
|
|
126
|
+
export { MAX_TRAVERSAL_CACHE_TTL, VISITED_RESPONSE_CACHE_TTL, createVisitedResponseCacheEntry, deleteAllVisitedResponseCacheEntries, deleteVisitedResponseCacheEntry, findVisitedResponseCacheEntry, findVisitedResponseForFullPrefetch, hasNavigationResponseHistoryLifetime, isVisitedResponseCacheEntryFresh, revokeHistoryRestoreNavigationReuse };
|
|
@@ -3,7 +3,7 @@ import { VinextResponseStageCacheability, VinextResponseStageDispatchOptions, Vi
|
|
|
3
3
|
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
4
4
|
import { TrustedPrerenderState } from "./prerender-route-params.js";
|
|
5
5
|
//#region src/server/app-worker-stages.d.ts
|
|
6
|
-
export declare const APP_WORKER_RESPONSE_STAGE_PROTOCOL_VERSION =
|
|
6
|
+
export declare const APP_WORKER_RESPONSE_STAGE_PROTOCOL_VERSION = 13;
|
|
7
7
|
export declare const APP_METADATA_RESPONSE_STAGE_NO_MATCH_HEADER = "x-vinext-app-metadata-stage-no-match";
|
|
8
8
|
type AppPageParams = Record<string, string | string[]>;
|
|
9
9
|
type AppWorkerResponseStageEnvelope = {
|
|
@@ -66,7 +66,7 @@ type AppMetadataWorkerResponseStageProps = AppWorkerResponseStageEnvelope & {
|
|
|
66
66
|
resolvedUrl: string;
|
|
67
67
|
routePathname: string;
|
|
68
68
|
};
|
|
69
|
-
type HybridPagesWorkerResponseStageProps = AppWorkerResponseStageEnvelope & {
|
|
69
|
+
export type HybridPagesWorkerResponseStageProps = AppWorkerResponseStageEnvelope & {
|
|
70
70
|
kind: "hybrid-pages";
|
|
71
71
|
allowRscDocumentFallback: boolean;
|
|
72
72
|
appRouteMatch: {
|
|
@@ -83,19 +83,41 @@ type HybridPagesWorkerResponseStageProps = AppWorkerResponseStageEnvelope & {
|
|
|
83
83
|
resourceKind: "api" | "page";
|
|
84
84
|
requestUrl: string;
|
|
85
85
|
resolvedUrl: string;
|
|
86
|
+
/**
|
|
87
|
+
* The shared cache entry answers every host, as Next.js keys a static page
|
|
88
|
+
* by its path, so a getInitialProps render of a page without
|
|
89
|
+
* getStaticProps, which reads the request, is not stored.
|
|
90
|
+
*/
|
|
91
|
+
sharedAcrossHosts: boolean;
|
|
86
92
|
};
|
|
87
93
|
export type AppWorkerResponseStageProps = AppFullRequestWorkerResponseStageProps | AppMatchedWorkerResponseStageProps | AppMetadataWorkerResponseStageProps | AppNotFoundWorkerResponseStageProps | HybridPagesWorkerResponseStageProps;
|
|
88
94
|
export type DispatchAppWorkerResponseStage = VinextResponseStageTransport<AppWorkerResponseStageProps>;
|
|
89
95
|
export type RenderAppWorkerResponseStageLocally = (request: Request, props: AppWorkerResponseStageProps) => Promise<Response>;
|
|
90
96
|
/** Normalize a shared App page HEAD request onto its method-invariant GET representation. */
|
|
91
97
|
export declare function prepareSharedAppPageDispatch(request: Request, cache: VinextResponseStageDispatchOptions["cache"]): Request;
|
|
98
|
+
type SharedAppCacheIdentity = NonNullable<VinextResponseStageDispatchOptions["cacheIdentity"]>;
|
|
99
|
+
/** App Router dispatches whose shared cache entry every host can reuse. */
|
|
100
|
+
export type SharedAppCacheIdentityProps = Exclude<AppWorkerResponseStageProps, {
|
|
101
|
+
kind: "app-full-request" | "hybrid-pages";
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Build the cache identity of a shared App Router dispatch: the dispatched
|
|
105
|
+
* request and props under the cache identity origin.
|
|
106
|
+
*/
|
|
107
|
+
export declare function createSharedAppCacheIdentity(request: Request, props: SharedAppCacheIdentityProps): SharedAppCacheIdentity;
|
|
92
108
|
/**
|
|
93
109
|
* Build the query-free cache identity of a shared App page dispatch. The user
|
|
94
110
|
* query leaves both the URL and `resolvedUrl`; the `.rsc` suffix, an RSC
|
|
95
111
|
* request's validated `_rsc`, and the render mode stay because they select the
|
|
96
112
|
* representation. HTML identities also drop the RSC selector headers.
|
|
97
113
|
*/
|
|
98
|
-
export declare function createSharedAppPageCacheIdentity(request: Request, props: AppMatchedWorkerResponseStageProps):
|
|
114
|
+
export declare function createSharedAppPageCacheIdentity(request: Request, props: AppMatchedWorkerResponseStageProps): SharedAppCacheIdentity;
|
|
115
|
+
/**
|
|
116
|
+
* Build the cache identity of a shared hybrid Pages page dispatch: the
|
|
117
|
+
* dispatched request and props under `origin`, so every host that names it
|
|
118
|
+
* shares one entry.
|
|
119
|
+
*/
|
|
120
|
+
export declare function createSharedHybridPagesCacheIdentity(request: Request, props: HybridPagesWorkerResponseStageProps, origin: string): SharedAppCacheIdentity;
|
|
99
121
|
/**
|
|
100
122
|
* Drop the user query from an App page dispatch URL and its `resolvedUrl`,
|
|
101
123
|
* keeping an RSC request's validated `_rsc`, the rule the query-free cache
|