vinext 1.2.0 → 1.3.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 +13 -10
- package/dist/build/client-build-config.d.ts +64 -3
- package/dist/build/client-build-config.js +131 -4
- package/dist/build/client-reference-groups.d.ts +163 -0
- package/dist/build/client-reference-groups.js +534 -0
- package/dist/build/module-dependency-cache.d.ts +31 -0
- package/dist/build/module-dependency-cache.js +51 -1
- package/dist/build/next-client-runtime-manifests.d.ts +10 -1
- package/dist/build/next-client-runtime-manifests.js +19 -4
- package/dist/build/nitro-public-files.d.ts +24 -0
- package/dist/build/nitro-public-files.js +60 -0
- package/dist/build/output-root-externals.d.ts +21 -0
- package/dist/build/output-root-externals.js +40 -0
- package/dist/build/pages-client-assets-module.js +1 -1
- package/dist/build/prerender-paths.js +6 -3
- package/dist/build/prerender.js +1 -1
- package/dist/build/server-actions-encryption-key.d.ts +23 -0
- package/dist/build/server-actions-encryption-key.js +101 -0
- package/dist/build/ssr-manifest.d.ts +3 -0
- package/dist/build/ssr-manifest.js +10 -1
- package/dist/check.js +5 -6
- package/dist/cli-dev-config.js +3 -3
- package/dist/cli.js +1 -1
- package/dist/client/client-rewrite-params.d.ts +9 -0
- package/dist/client/client-rewrite-params.js +20 -0
- package/dist/client/dev-error-overlay.js +2 -1
- package/dist/client/navigation-runtime.d.ts +25 -2
- package/dist/client/navigation-runtime.js +42 -11
- package/dist/client/vinext-next-data.d.ts +0 -1
- package/dist/config/config-matchers.d.ts +15 -40
- package/dist/config/config-matchers.js +195 -262
- package/dist/config/config-source.d.ts +34 -0
- package/dist/config/config-source.js +141 -0
- package/dist/config/header-params.d.ts +29 -0
- package/dist/config/header-params.js +106 -0
- package/dist/config/next-config.d.ts +7 -5
- package/dist/config/next-config.js +120 -7
- package/dist/entries/app-browser-entry.d.ts +14 -1
- package/dist/entries/app-browser-entry.js +26 -36
- package/dist/entries/app-rsc-entry.d.ts +2 -0
- package/dist/entries/app-rsc-entry.js +92 -57
- package/dist/entries/app-rsc-manifest.d.ts +10 -0
- package/dist/entries/app-rsc-manifest.js +20 -1
- package/dist/entries/app-ssr-entry.d.ts +4 -1
- package/dist/entries/app-ssr-entry.js +9 -2
- package/dist/entries/pages-client-entry.d.ts +1 -0
- package/dist/entries/pages-client-entry.js +6 -6
- package/dist/entries/pages-server-entry.js +17 -14
- package/dist/index.d.ts +11 -0
- package/dist/index.js +350 -175
- package/dist/init.d.ts +1 -1
- package/dist/init.js +103 -6
- package/dist/plugins/ast-utils.d.ts +53 -2
- package/dist/plugins/ast-utils.js +90 -2
- package/dist/plugins/cloudflare-dev-module-urls.d.ts +41 -0
- package/dist/plugins/cloudflare-dev-module-urls.js +271 -0
- package/dist/plugins/commonjs-esm-facade.js +2 -2
- package/dist/plugins/css-module-imports.js +13 -20
- package/dist/plugins/dynamic-preload-metadata.js +2 -3
- package/dist/plugins/extensionless-dynamic-import.js +2 -3
- package/dist/plugins/fonts.d.ts +1 -1
- package/dist/plugins/fonts.js +3 -3
- package/dist/plugins/ignore-dynamic-requests.js +2 -3
- package/dist/plugins/import-meta-url.js +3 -4
- package/dist/plugins/instrumentation-client.js +3 -2
- package/dist/plugins/middleware-export-validation.js +2 -3
- package/dist/plugins/og-harfbuzz.js +2 -3
- package/dist/plugins/optimize-imports.d.ts +25 -2
- package/dist/plugins/optimize-imports.js +109 -24
- package/dist/plugins/pages-node-externals.js +2 -3
- package/dist/plugins/remove-console.js +2 -18
- package/dist/plugins/require-condition-resolution.js +3 -3
- package/dist/plugins/require-context.js +2 -3
- package/dist/plugins/rsc-client-reference-loaders.d.ts +45 -1
- package/dist/plugins/rsc-client-reference-loaders.js +336 -18
- package/dist/plugins/strip-server-exports.js +3 -4
- package/dist/plugins/styled-jsx.js +2 -3
- package/dist/plugins/use-cache-callable.d.ts +26 -2
- package/dist/plugins/use-cache-callable.js +101 -36
- package/dist/plugins/worker-image-imports.d.ts +1 -0
- package/dist/plugins/worker-image-imports.js +31 -34
- package/dist/plugins/worker-use-server.js +38 -14
- package/dist/routing/app-route-graph.d.ts +1 -1
- package/dist/routing/browser-route-manifest.d.ts +43 -0
- package/dist/routing/browser-route-manifest.js +195 -0
- package/dist/routing/hashed-route-patterns.d.ts +4 -0
- package/dist/routing/hashed-route-patterns.js +22 -0
- package/dist/routing/optimistic-route-trie.d.ts +27 -0
- package/dist/routing/optimistic-route-trie.js +102 -0
- package/dist/routing/route-validation.d.ts +6 -1
- package/dist/routing/route-validation.js +26 -10
- package/dist/server/api-handler.js +1 -1
- package/dist/server/app-action-forwarding.d.ts +8 -0
- package/dist/server/app-action-forwarding.js +17 -3
- package/dist/server/app-browser-entry.js +149 -62
- package/dist/server/app-browser-error.d.ts +3 -1
- package/dist/server/app-browser-error.js +7 -2
- package/dist/server/app-browser-interception-context.d.ts +2 -2
- package/dist/server/app-browser-interception-context.js +1 -1
- package/dist/server/app-browser-mpa-navigation.d.ts +1 -0
- package/dist/server/app-browser-mpa-navigation.js +6 -5
- package/dist/server/app-browser-navigation-controller.d.ts +17 -6
- package/dist/server/app-browser-navigation-controller.js +88 -26
- package/dist/server/app-browser-prefetch-response.js +2 -2
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-supplemental-refresh.js +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +4 -4
- package/dist/server/app-client-reference-preloader.d.ts +23 -0
- package/dist/server/app-client-reference-preloader.js +30 -7
- package/dist/server/app-fallback-renderer.js +2 -1
- package/dist/server/app-middleware.d.ts +6 -0
- package/dist/server/app-middleware.js +8 -10
- package/dist/server/app-optimistic-routing.d.ts +8 -10
- package/dist/server/app-optimistic-routing.js +4 -95
- package/dist/server/app-page-boundary-render.js +8 -1
- package/dist/server/app-page-cache-render.js +1 -0
- package/dist/server/app-page-dispatch.js +3 -1
- package/dist/server/app-page-render.js +4 -2
- package/dist/server/app-page-rsc-render-status.d.ts +1 -0
- package/dist/server/app-page-rsc-render-status.js +1 -0
- package/dist/server/app-page-search-params-observation.d.ts +1 -4
- package/dist/server/app-page-search-params-observation.js +8 -10
- package/dist/server/app-page-stream.d.ts +7 -0
- package/dist/server/app-page-stream.js +1 -0
- package/dist/server/app-pages-bridge.d.ts +2 -1
- package/dist/server/app-pages-bridge.js +12 -8
- package/dist/server/app-prerender-endpoints.js +1 -1
- package/dist/server/app-prerender-static-params.js +3 -2
- package/dist/server/app-render-abort-error.d.ts +19 -0
- package/dist/server/app-render-abort-error.js +31 -1
- package/dist/server/app-render-dependency.js +42 -2
- package/dist/server/app-request-stage-independent-entry.js +7 -7
- package/dist/server/app-response-stage-entry.js +5 -5
- package/dist/server/app-route-handler-dispatch.js +3 -1
- package/dist/server/app-route-handler-execution.d.ts +2 -0
- package/dist/server/app-route-handler-execution.js +9 -2
- package/dist/server/app-route-handler-middleware-context.d.ts +2 -1
- package/dist/server/app-route-handler-middleware-context.js +3 -3
- package/dist/server/app-route-handler-response.d.ts +2 -1
- package/dist/server/app-route-handler-response.js +2 -2
- package/dist/server/app-route-handler-runtime.d.ts +2 -0
- package/dist/server/app-route-handler-runtime.js +21 -4
- package/dist/server/app-route-module-loader.js +7 -6
- package/dist/server/app-route-tree.d.ts +20 -0
- package/dist/server/app-route-tree.js +18 -0
- package/dist/server/app-router-entry.js +7 -7
- package/dist/server/app-rsc-cache-busting.d.ts +16 -0
- package/dist/server/app-rsc-cache-busting.js +29 -12
- package/dist/server/app-rsc-combined-handler.js +8 -1
- package/dist/server/app-rsc-errors.d.ts +7 -0
- package/dist/server/app-rsc-errors.js +9 -2
- package/dist/server/app-rsc-handler.d.ts +4 -1
- package/dist/server/app-rsc-handler.js +151 -135
- package/dist/server/app-rsc-request-normalization.js +3 -3
- package/dist/server/app-rsc-response-finalizer.d.ts +5 -0
- package/dist/server/app-rsc-response-finalizer.js +4 -1
- package/dist/server/app-rsc-response-stage.js +5 -3
- package/dist/server/app-rsc-route-matching.d.ts +1 -0
- package/dist/server/app-rsc-route-matching.js +1 -1
- package/dist/server/app-server-action-execution.d.ts +23 -6
- package/dist/server/app-server-action-execution.js +51 -57
- package/dist/server/app-ssr-entry.d.ts +6 -0
- package/dist/server/app-ssr-entry.js +21 -11
- package/dist/server/app-ssr-stream.d.ts +7 -0
- package/dist/server/app-ssr-stream.js +13 -1
- package/dist/server/app-visited-response-cache.js +2 -2
- package/dist/server/config-headers.js +13 -4
- package/dist/server/defer-until-stream-consumed.d.ts +2 -1
- package/dist/server/defer-until-stream-consumed.js +3 -1
- package/dist/server/dev-server.js +1 -1
- package/dist/server/image-optimization.js +1 -0
- package/dist/server/isolate-shared-promise.d.ts +10 -0
- package/dist/server/isolate-shared-promise.js +33 -0
- package/dist/server/isr-cache.js +3 -2
- package/dist/server/metadata-route-response.js +2 -2
- package/dist/server/middleware-matcher-pattern.d.ts +0 -1
- package/dist/server/middleware-matcher-pattern.js +11 -140
- package/dist/server/middleware-matcher.js +5 -6
- package/dist/server/middleware-response-headers.d.ts +31 -0
- package/dist/server/middleware-response-headers.js +57 -1
- package/dist/server/middleware-runtime.js +30 -17
- package/dist/server/navigation-planner.d.ts +2 -2
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/nitro-public-files-plugin.d.ts +38 -0
- package/dist/server/nitro-public-files-plugin.js +106 -0
- package/dist/server/nitro-public-files.d.ts +21 -0
- package/dist/server/nitro-public-files.js +39 -0
- package/dist/server/open-redirect.d.ts +11 -4
- package/dist/server/open-redirect.js +11 -4
- package/dist/server/pages-api-route.js +2 -2
- package/dist/server/pages-asset-tags.d.ts +5 -0
- package/dist/server/pages-asset-tags.js +9 -2
- package/dist/server/pages-client-assets.d.ts +4 -1
- package/dist/server/pages-data-route.js +2 -1
- package/dist/server/pages-i18n.d.ts +18 -0
- package/dist/server/pages-i18n.js +18 -2
- package/dist/server/pages-node-compat.d.ts +5 -3
- package/dist/server/pages-node-compat.js +35 -16
- package/dist/server/pages-page-data.js +1 -1
- package/dist/server/pages-page-handler.js +1 -1
- package/dist/server/pages-page-response.js +1 -1
- package/dist/server/pages-request-pipeline.d.ts +6 -1
- package/dist/server/pages-request-pipeline.js +35 -39
- package/dist/server/pages-request-stage-entry.js +20 -10
- package/dist/server/pages-response-stage-entry.js +1 -1
- package/dist/server/pages-revalidate.js +3 -2
- package/dist/server/pages-router-entry.js +2 -2
- package/dist/server/prod-server.d.ts +2 -2
- package/dist/server/prod-server.js +74 -36
- package/dist/server/proxy-trust.d.ts +6 -0
- package/dist/server/proxy-trust.js +12 -6
- package/dist/server/request-pipeline.d.ts +5 -0
- package/dist/server/request-pipeline.js +12 -1
- package/dist/server/rsc-stream-hints.d.ts +1 -1
- package/dist/server/rsc-stream-hints.js +21 -3
- package/dist/server/server-reference-loader.js +10 -1
- package/dist/server/static-file-cache.js +15 -3
- package/dist/server/worker-image-optimization.js +19 -6
- package/dist/server/worker-utils.js +1 -1
- package/dist/shims/cache-handler.js +3 -2
- package/dist/shims/cache-request-state.d.ts +40 -3
- package/dist/shims/cache-request-state.js +70 -5
- package/dist/shims/cache-runtime.js +47 -19
- package/dist/shims/cache.d.ts +2 -2
- package/dist/shims/cache.js +17 -8
- package/dist/shims/cdn-purge-routes.d.ts +24 -0
- package/dist/shims/cdn-purge-routes.js +77 -0
- package/dist/shims/dynamic.js +17 -4
- package/dist/shims/form.js +8 -3
- package/dist/shims/head.js +1 -1
- package/dist/shims/headers.js +2 -2
- package/dist/shims/image-props.d.ts +93 -0
- package/dist/shims/image-props.js +323 -0
- package/dist/shims/image.d.ts +4 -18
- package/dist/shims/image.js +4 -319
- package/dist/shims/internal/headers-state.d.ts +7 -0
- package/dist/shims/internal/headers-state.js +14 -2
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +4 -1
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +32 -15
- package/dist/shims/internal/hybrid-client-route-owner.js +9 -8
- package/dist/shims/link-prefetch.js +5 -4
- package/dist/shims/link.js +7 -5
- package/dist/shims/navigation.d.ts +1 -1
- package/dist/shims/navigation.js +21 -10
- package/dist/shims/og.js +35 -10
- package/dist/shims/request-context.d.ts +13 -0
- package/dist/shims/router.js +28 -52
- package/dist/shims/server.d.ts +42 -8
- package/dist/shims/server.js +99 -15
- package/dist/shims/thenable-params.d.ts +6 -1
- package/dist/shims/thenable-params.js +11 -2
- package/dist/shims/unified-request-context.d.ts +5 -0
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/url-utils.d.ts +7 -0
- package/dist/shims/url-utils.js +12 -3
- package/dist/utils/asset-prefix.d.ts +7 -0
- package/dist/utils/asset-prefix.js +10 -1
- package/dist/utils/client-build-manifest.js +12 -5
- package/dist/utils/client-runtime-metadata.d.ts +1 -0
- package/dist/utils/client-runtime-metadata.js +15 -2
- package/dist/utils/domain-locale.js +1 -1
- package/dist/utils/lazy-chunks.d.ts +4 -0
- package/dist/utils/manifest-paths.d.ts +14 -0
- package/dist/utils/manifest-paths.js +22 -1
- package/dist/utils/path-to-regexp.d.ts +21 -0
- package/dist/{server/middleware-path-to-regexp.js → utils/path-to-regexp.js} +14 -11
- package/dist/utils/plugin-react-version.d.ts +15 -0
- package/dist/utils/plugin-react-version.js +64 -0
- package/dist/utils/plugin-rsc-version.d.ts +2 -0
- package/dist/utils/plugin-rsc-version.js +28 -2
- package/dist/utils/public-routes.d.ts +2 -0
- package/dist/utils/public-routes.js +18 -7
- package/dist/utils/react-version.d.ts +7 -0
- package/dist/utils/react-version.js +39 -16
- package/package.json +6 -6
- package/dist/build/nitro-route-rules.d.ts +0 -47
- package/dist/build/nitro-route-rules.js +0 -79
- package/dist/plugins/cache-flight-codec.d.ts +0 -19
- package/dist/plugins/cache-flight-codec.js +0 -68
- package/dist/server/middleware-path-to-regexp.d.ts +0 -13
- package/dist/utils/regex-safety.d.ts +0 -17
- package/dist/utils/regex-safety.js +0 -789
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequestContext, runWithRequestContext } from "../shims/unified-request-context.js";
|
|
2
|
-
import { runWithExecutionContext } from "../shims/request-context.js";
|
|
3
|
-
import { runInWorkStoreScope } from "../shims/internal/work-store-scope.js";
|
|
4
2
|
import { serializeStaticFileSignalForTransport } from "./static-file-signal.js";
|
|
5
3
|
import { attachRequestCfMetadata } from "./request-pipeline.js";
|
|
4
|
+
import { runWithExecutionContext } from "../shims/request-context.js";
|
|
5
|
+
import { runInWorkStoreScope } from "../shims/internal/work-store-scope.js";
|
|
6
6
|
import { validateCdnRequest } from "./cache-control.js";
|
|
7
7
|
import { ensureFetchPatch } from "../shims/fetch-cache.js";
|
|
8
8
|
import { serializeImageOptimizationSignalForTransport } from "./image-optimization.js";
|
|
@@ -19,7 +19,7 @@ import { registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
|
|
|
19
19
|
/** Cacheable App response stage. This is the only multi-stage App entry that imports user routes. */
|
|
20
20
|
/** Invoke one transformed public cache function without rendering its owning route. */
|
|
21
21
|
async function invokeCacheFunction(invocation, env, platformCtx, dispatchRequestStage) {
|
|
22
|
-
await __ensureInstrumentation();
|
|
22
|
+
await __ensureInstrumentation(platformCtx);
|
|
23
23
|
const [{ loadServerAction }, { invokeCacheFunction: invokeRegisteredCacheFunction }] = await Promise.all([import("@vitejs/plugin-rsc/core/rsc"), import("../shims/cache-callable-runtime.js")]);
|
|
24
24
|
registerConfiguredCacheAdapters(env);
|
|
25
25
|
ensureFetchPatch();
|
|
@@ -37,8 +37,8 @@ async function handleResponseStage(request, env, platformCtx, props, dispatchReq
|
|
|
37
37
|
if (props.requestOrigin !== new URL(request.url).origin) return new Response("Invalid vinext App response stage", { status: 400 });
|
|
38
38
|
const currentBuildId = process.env.__VINEXT_BUILD_ID ?? null;
|
|
39
39
|
if (props.buildId !== currentBuildId) return new Response("Incompatible vinext App response stage", { status: 409 });
|
|
40
|
-
await __ensureInstrumentation();
|
|
41
|
-
if (props.kind === "app-full-request" && props.prerenderDiscovery) await __ensureHybridPagesApplication();
|
|
40
|
+
await __ensureInstrumentation(platformCtx);
|
|
41
|
+
if (props.kind === "app-full-request" && props.prerenderDiscovery) await __ensureHybridPagesApplication(platformCtx);
|
|
42
42
|
registerConfiguredImageOptimizer(env);
|
|
43
43
|
let ctx = createWorkerRevalidationContext(platformCtx, (internalRequest) => dispatchRequestStage(internalRequest), "node");
|
|
44
44
|
if (props.kind === "app-full-request" && props.prerenderDiscovery) ctx = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { closeAfterResponse, createRequestContext, runWithRequestContext } from "../shims/unified-request-context.js";
|
|
1
|
+
import { closeAfterResponse, createRequestContext, getRequestContext, runWithRequestContext } from "../shims/unified-request-context.js";
|
|
2
2
|
import "../utils/protocol-headers.js";
|
|
3
3
|
import { getRequestExecutionContext } from "../shims/request-context.js";
|
|
4
4
|
import { runInWorkStoreScope } from "../shims/internal/work-store-scope.js";
|
|
@@ -40,6 +40,7 @@ async function runInRouteHandlerRevalidationContext(options, renderFn) {
|
|
|
40
40
|
const requestContext = createRequestContext({
|
|
41
41
|
headersContext,
|
|
42
42
|
executionContext: getRequestExecutionContext(),
|
|
43
|
+
phase: "route-handler",
|
|
43
44
|
unstableCacheRevalidation: "foreground"
|
|
44
45
|
});
|
|
45
46
|
const revalidation = runWithRequestContext(requestContext, () => runInWorkStoreScope(async () => {
|
|
@@ -203,6 +204,7 @@ async function dispatchAppRouteHandlerImpl(options) {
|
|
|
203
204
|
return reportRequestError(error, request, context);
|
|
204
205
|
},
|
|
205
206
|
request: options.request,
|
|
207
|
+
requestSignal: getRequestContext().requestSignal ?? void 0,
|
|
206
208
|
expireSeconds: options.expireSeconds,
|
|
207
209
|
revalidateSeconds,
|
|
208
210
|
revalidateReason,
|
|
@@ -56,6 +56,8 @@ type RunAppRouteHandlerOptions = {
|
|
|
56
56
|
*/
|
|
57
57
|
params: AppRouteParams | null;
|
|
58
58
|
request: Request;
|
|
59
|
+
/** Host signal for the client connection; only the foreground request has one. */
|
|
60
|
+
requestSignal?: AbortSignal;
|
|
59
61
|
routePattern?: string;
|
|
60
62
|
setHeadersAccessPhase?: (phase: HeadersAccessPhase) => HeadersAccessPhase;
|
|
61
63
|
};
|
|
@@ -118,6 +118,7 @@ async function runAppRouteHandler(options) {
|
|
|
118
118
|
options.markDynamicUsage();
|
|
119
119
|
},
|
|
120
120
|
requestMode: options.dynamicConfig === "force-static" || options.dynamicConfig === "error" ? options.dynamicConfig : "auto",
|
|
121
|
+
signal: options.requestSignal,
|
|
121
122
|
staticGenerationErrorMessage(expression) {
|
|
122
123
|
return getAppRouteStaticGenerationErrorMessage(options.routePattern, expression);
|
|
123
124
|
}
|
|
@@ -210,10 +211,16 @@ async function executeAppRouteHandlerImpl(options) {
|
|
|
210
211
|
revalidateSeconds: options.revalidateSeconds,
|
|
211
212
|
requiresCompletedResponseAdmission: isRouteCacheabilityEvaluation()
|
|
212
213
|
})) {
|
|
213
|
-
const completed = await completeAppRouteHandlerResponse(response)
|
|
214
|
+
const completed = await completeAppRouteHandlerResponse(response).catch(async (error) => {
|
|
215
|
+
await _drainPendingRevalidations().catch(() => {});
|
|
216
|
+
throw error;
|
|
217
|
+
});
|
|
214
218
|
response = completed.response;
|
|
215
219
|
cleanupDeferredToBody = !completed.completed;
|
|
216
|
-
if (completed.completed)
|
|
220
|
+
if (completed.completed) {
|
|
221
|
+
markRouteCacheabilityResponseBodyComplete();
|
|
222
|
+
await _drainPendingRevalidations();
|
|
223
|
+
}
|
|
217
224
|
const dynamicUsedDuringCompletion = options.consumeDynamicUsage();
|
|
218
225
|
dynamicUsedInHandler = handlerResult.didAccessDynamicRequest() || dynamicUsedDuringCompletion || dynamicUsedInHandler;
|
|
219
226
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { MiddlewareResponseMergeOptions } from "./middleware-response-headers.js";
|
|
1
2
|
//#region src/server/app-route-handler-middleware-context.d.ts
|
|
2
3
|
export type RouteHandlerMiddlewareContext = {
|
|
3
4
|
headers: Headers | null;
|
|
4
5
|
status: number | null;
|
|
5
6
|
};
|
|
6
7
|
/** Apply request-stage middleware response metadata to a route-handler response. */
|
|
7
|
-
export declare function applyRouteHandlerMiddlewareContext(response: Response, middlewareContext: RouteHandlerMiddlewareContext): Response;
|
|
8
|
+
export declare function applyRouteHandlerMiddlewareContext(response: Response, middlewareContext: RouteHandlerMiddlewareContext, options?: MiddlewareResponseMergeOptions): Response;
|
|
8
9
|
//#endregion
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mergeMiddlewareResponseHeadersOntoResponse } from "./middleware-response-headers.js";
|
|
2
2
|
//#region src/server/app-route-handler-middleware-context.ts
|
|
3
3
|
/** Apply request-stage middleware response metadata to a route-handler response. */
|
|
4
|
-
function applyRouteHandlerMiddlewareContext(response, middlewareContext) {
|
|
4
|
+
function applyRouteHandlerMiddlewareContext(response, middlewareContext, options = {}) {
|
|
5
5
|
if (!middlewareContext.headers && middlewareContext.status == null) return response;
|
|
6
6
|
const responseHeaders = new Headers(response.headers);
|
|
7
|
-
|
|
7
|
+
mergeMiddlewareResponseHeadersOntoResponse(responseHeaders, middlewareContext.headers, options);
|
|
8
8
|
return new Response(response.body, {
|
|
9
9
|
status: middlewareContext.status ?? response.status,
|
|
10
10
|
statusText: response.statusText,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MiddlewareResponseMergeOptions } from "./middleware-response-headers.js";
|
|
1
2
|
import { CacheControlMetadata, CachedRouteValue } from "../shims/cache-handler.js";
|
|
2
3
|
//#region src/server/app-route-handler-response.d.ts
|
|
3
4
|
export type RouteHandlerMiddlewareContext = {
|
|
@@ -16,7 +17,7 @@ type FinalizeRouteHandlerResponseOptions = {
|
|
|
16
17
|
draftCookie?: string | null;
|
|
17
18
|
isHead: boolean;
|
|
18
19
|
};
|
|
19
|
-
export declare function applyRouteHandlerMiddlewareContext(response: Response, middlewareContext: RouteHandlerMiddlewareContext, options?: {
|
|
20
|
+
export declare function applyRouteHandlerMiddlewareContext(response: Response, middlewareContext: RouteHandlerMiddlewareContext, options?: MiddlewareResponseMergeOptions & {
|
|
20
21
|
appendResponseLink?: boolean;
|
|
21
22
|
}): Response;
|
|
22
23
|
export declare function assertSupportedAppRouteHandlerResponse(response: Response): void;
|
|
@@ -5,7 +5,7 @@ import { markRouteCacheabilityExplicitResponsePolicy, recordRouteCacheability }
|
|
|
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";
|
|
8
|
-
import {
|
|
8
|
+
import { mergeMiddlewareResponseHeadersOntoResponse } from "./middleware-response-headers.js";
|
|
9
9
|
import { markEdgeRouteHandlerLinkHeaders } from "./app-response-header-provenance.js";
|
|
10
10
|
import { getSetCookieName } from "./cookie-utils.js";
|
|
11
11
|
//#region src/server/app-route-handler-response.ts
|
|
@@ -22,7 +22,7 @@ function applyRouteHandlerMiddlewareContext(response, middlewareContext, options
|
|
|
22
22
|
return response;
|
|
23
23
|
}
|
|
24
24
|
const responseHeaders = new Headers(response.headers);
|
|
25
|
-
|
|
25
|
+
mergeMiddlewareResponseHeadersOntoResponse(responseHeaders, middlewareContext.headers, options);
|
|
26
26
|
if (responseLink && middlewareContext.headers?.get("link")) responseHeaders.append("link", responseLink);
|
|
27
27
|
const result = new Response(response.body, {
|
|
28
28
|
status: middlewareContext.status ?? response.status,
|
|
@@ -30,6 +30,8 @@ type TrackedAppRouteRequestOptions = {
|
|
|
30
30
|
middlewareHeaders?: Headers | null;
|
|
31
31
|
onDynamicAccess?: (access: AppRouteDynamicRequestAccess) => void;
|
|
32
32
|
requestMode?: AppRouteRequestMode;
|
|
33
|
+
/** Host signal for the client connection (UnifiedRequestContext.requestSignal). */
|
|
34
|
+
signal?: AbortSignal;
|
|
33
35
|
staticGenerationErrorMessage?: (expression?: string) => string;
|
|
34
36
|
};
|
|
35
37
|
type TrackedAppRouteRequest = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { buildRequestHeadersFromMiddlewareResponse } from "../utils/middleware-request-headers.js";
|
|
2
2
|
import { addBasePathToPathname } from "../utils/base-path.js";
|
|
3
|
-
import { NextRequest, RequestCookies, sealRequestCookies, sealRequestHeaders } from "../shims/server.js";
|
|
4
3
|
import { cloneRequestWithHeaders, cloneRequestWithUrl } from "./request-pipeline.js";
|
|
4
|
+
import { NextRequest, RequestCookies, sealRequestCookies, sealRequestHeaders } from "../shims/server.js";
|
|
5
5
|
import { BUILT_IN_REQUEST_PROPERTIES } from "./app-route-request-built-ins.js";
|
|
6
6
|
//#region src/server/app-route-handler-runtime.ts
|
|
7
7
|
const BUILT_IN_REQUEST_PROPERTY_MAP = new Map(BUILT_IN_REQUEST_PROPERTIES.map((property) => [property.key, property]));
|
|
@@ -72,7 +72,20 @@ function buildNextConfig(options) {
|
|
|
72
72
|
skipTrailingSlashRedirect: options.skipTrailingSlashRedirect
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Undici's Request follows its input's signal through a WeakRef, and so does
|
|
77
|
+
* every clone between the host signal and the handler's request. A handler
|
|
78
|
+
* that only listens on `request.signal` (e.g. to stop a stream) would miss the
|
|
79
|
+
* abort once GC collects any of them, so the request follows the host signal
|
|
80
|
+
* directly and stays reachable for as long as that signal is.
|
|
81
|
+
*/
|
|
82
|
+
const requestsByHostSignal = /* @__PURE__ */ new WeakMap();
|
|
83
|
+
function retainWhileSignalLives(signal, request) {
|
|
84
|
+
const requests = requestsByHostSignal.get(signal);
|
|
85
|
+
if (requests) requests.push(request);
|
|
86
|
+
else requestsByHostSignal.set(signal, [request]);
|
|
87
|
+
}
|
|
88
|
+
function createForceStaticNextRequest(input, nextConfig, signal) {
|
|
76
89
|
const read = (key) => {
|
|
77
90
|
const descriptor = BUILT_IN_REQUEST_PROPERTY_MAP.get(key)?.descriptor;
|
|
78
91
|
if (descriptor?.get) return descriptor.get.call(input);
|
|
@@ -89,7 +102,7 @@ function createForceStaticNextRequest(input, nextConfig) {
|
|
|
89
102
|
redirect: read("redirect"),
|
|
90
103
|
referrer: read("referrer"),
|
|
91
104
|
referrerPolicy: read("referrerPolicy"),
|
|
92
|
-
signal: read("signal"),
|
|
105
|
+
signal: signal ?? read("signal"),
|
|
93
106
|
nextConfig: nextConfig ?? void 0
|
|
94
107
|
});
|
|
95
108
|
}
|
|
@@ -215,7 +228,11 @@ function createTrackedAppRouteRequest(request, options = {}) {
|
|
|
215
228
|
const sourceCfDescriptor = Reflect.getOwnPropertyDescriptor(requestWithOverrides, "cf");
|
|
216
229
|
const sourceCfAccessor = sourceCfDescriptor?.get;
|
|
217
230
|
const sourceCfMetadata = sourceCfAccessor ? void 0 : Reflect.get(requestWithOverrides, "cf", requestWithOverrides);
|
|
218
|
-
const nextRequest = requestMode === "force-static" ? createForceStaticNextRequest(requestWithOverrides, nextConfig) : requestWithOverrides instanceof NextRequest && sourceCfDescriptor?.configurable !== false ? requestWithOverrides : new NextRequest(requestWithOverrides, {
|
|
231
|
+
const nextRequest = requestMode === "force-static" ? createForceStaticNextRequest(requestWithOverrides, nextConfig, options.signal) : requestWithOverrides instanceof NextRequest && sourceCfDescriptor?.configurable !== false && !options.signal ? requestWithOverrides : new NextRequest(requestWithOverrides, {
|
|
232
|
+
nextConfig: nextConfig ?? void 0,
|
|
233
|
+
signal: options.signal
|
|
234
|
+
});
|
|
235
|
+
if (options.signal) retainWhileSignalLives(options.signal, nextRequest);
|
|
219
236
|
const rawCfMetadata = sourceCfAccessor ? void 0 : sourceCfMetadata === void 0 ? Reflect.get(nextRequest, "cf", nextRequest) : sourceCfMetadata;
|
|
220
237
|
const hasCfMetadata = sourceCfAccessor !== void 0 || rawCfMetadata !== void 0;
|
|
221
238
|
const originalCfDescriptor = sourceCfDescriptor ?? Reflect.getOwnPropertyDescriptor(nextRequest, "cf");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { runOutsideRequestScopes } from "../shims/internal/als-registry.js";
|
|
2
|
+
import { shareIsolatePromise } from "./isolate-shared-promise.js";
|
|
2
3
|
//#region src/server/app-route-module-loader.ts
|
|
3
4
|
/**
|
|
4
5
|
* Lazy route-module hydration for the App Router RSC entry.
|
|
@@ -63,7 +64,7 @@ async function hydrateInterceptModule(intercept, loader, field, loadingField) {
|
|
|
63
64
|
const cached = loadState?.[field];
|
|
64
65
|
if (cached != null) intercept[field] = cached;
|
|
65
66
|
if (!loader || intercept[field] != null) return;
|
|
66
|
-
const loading = loadState?.[loadingField] ?? runOutsideRequestScopes(loader).then((module) => {
|
|
67
|
+
const loading = loadState?.[loadingField] ?? shareIsolatePromise(runOutsideRequestScopes(loader).then((module) => {
|
|
67
68
|
intercept[field] = module;
|
|
68
69
|
if (loadState) {
|
|
69
70
|
loadState[field] = module;
|
|
@@ -73,7 +74,7 @@ async function hydrateInterceptModule(intercept, loader, field, loadingField) {
|
|
|
73
74
|
}).catch((error) => {
|
|
74
75
|
if (loadState) loadState[loadingField] = null;
|
|
75
76
|
throw error;
|
|
76
|
-
});
|
|
77
|
+
}));
|
|
77
78
|
if (loadState) loadState[loadingField] = loading;
|
|
78
79
|
intercept[field] = await loading;
|
|
79
80
|
}
|
|
@@ -92,13 +93,13 @@ function loadAppInterceptLayouts(intercept) {
|
|
|
92
93
|
pushArrayLoads(loads, intercept.interceptLayouts, intercept.__loadInterceptLayouts);
|
|
93
94
|
pushArrayLoads(loads, intercept.interceptLoadings, intercept.__loadInterceptLoadings);
|
|
94
95
|
if (loads.length === 0) return Promise.resolve(intercept.interceptLayouts ?? []);
|
|
95
|
-
const loading = Promise.all(loads).then(() => {
|
|
96
|
+
const loading = shareIsolatePromise(Promise.all(loads).then(() => {
|
|
96
97
|
if (loadState) loadState.interceptLayoutsLoading = null;
|
|
97
98
|
return intercept.interceptLayouts ?? [];
|
|
98
99
|
}).catch((error) => {
|
|
99
100
|
if (loadState) loadState.interceptLayoutsLoading = null;
|
|
100
101
|
throw error;
|
|
101
|
-
});
|
|
102
|
+
}));
|
|
102
103
|
if (loadState) loadState.interceptLayoutsLoading = loading;
|
|
103
104
|
return loading;
|
|
104
105
|
}
|
|
@@ -143,14 +144,14 @@ function ensureAppRouteModulesLoaded(route) {
|
|
|
143
144
|
route.__loaded = true;
|
|
144
145
|
return route;
|
|
145
146
|
}
|
|
146
|
-
const loading = Promise.all(loads).then(() => {
|
|
147
|
+
const loading = shareIsolatePromise(Promise.all(loads).then(() => {
|
|
147
148
|
route.__loaded = true;
|
|
148
149
|
route.__loading = null;
|
|
149
150
|
return route;
|
|
150
151
|
}).catch((error) => {
|
|
151
152
|
route.__loading = null;
|
|
152
153
|
throw error;
|
|
153
|
-
});
|
|
154
|
+
}));
|
|
154
155
|
route.__loading = loading;
|
|
155
156
|
return loading;
|
|
156
157
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AppElements } from "./app-elements-wire.js";
|
|
2
|
+
import "./app-elements.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
//#region src/server/app-route-tree.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Builds the App Router route tree after a sibling that the browser uses to
|
|
7
|
+
* write navigation history. Insertion effects run in tree order, so that
|
|
8
|
+
* sibling's effect runs before React mutates the route tree's DOM, like
|
|
9
|
+
* Next.js' HistoryUpdater.
|
|
10
|
+
*
|
|
11
|
+
* The server and the browser must render this same shape: a second child
|
|
12
|
+
* changes the useId values of everything below it, so SSR passes null in the
|
|
13
|
+
* sibling's place to keep hydrated ids matching.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createAppRouteTree(options: {
|
|
16
|
+
elements: AppElements;
|
|
17
|
+
historyCommit: ReactNode;
|
|
18
|
+
routeId: string;
|
|
19
|
+
}): ReactNode;
|
|
20
|
+
//#endregion
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ElementsContext, Slot } from "../shims/slot.js";
|
|
2
|
+
import { Fragment, createElement } from "react";
|
|
3
|
+
//#region src/server/app-route-tree.ts
|
|
4
|
+
/**
|
|
5
|
+
* Builds the App Router route tree after a sibling that the browser uses to
|
|
6
|
+
* write navigation history. Insertion effects run in tree order, so that
|
|
7
|
+
* sibling's effect runs before React mutates the route tree's DOM, like
|
|
8
|
+
* Next.js' HistoryUpdater.
|
|
9
|
+
*
|
|
10
|
+
* The server and the browser must render this same shape: a second child
|
|
11
|
+
* changes the useId values of everything below it, so SSR passes null in the
|
|
12
|
+
* sibling's place to keep hydrated ids matching.
|
|
13
|
+
*/
|
|
14
|
+
function createAppRouteTree(options) {
|
|
15
|
+
return createElement(Fragment, null, options.historyCommit, createElement(ElementsContext.Provider, { value: options.elements }, createElement(Slot, { id: options.routeId })));
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { createAppRouteTree };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER, VINEXT_REVALIDATE_HOST_HEADER } from "../utils/protocol-headers.js";
|
|
2
|
-
import { assetPrefixPathname, isNextStaticPath } from "../utils/asset-prefix.js";
|
|
3
|
-
import { runWithExecutionContext } from "../shims/request-context.js";
|
|
4
|
-
import "./server-globals.js";
|
|
5
2
|
import "./app-rsc-vary.js";
|
|
6
3
|
import { VINEXT_CACHEABILITY_PROBE_QUERY_PARAM } from "./headers.js";
|
|
7
4
|
import { badRequestResponse, notFoundResponse, notFoundStaticAssetResponse } from "./http-error-responses.js";
|
|
8
|
-
import { cloneRequestWithHeaders, filterInternalHeaders, guardProtocolRelativeUrl } from "./request-pipeline.js";
|
|
5
|
+
import { cloneRequestWithHeaders, cloneRequestWithUrl, filterInternalHeaders, guardProtocolRelativeUrl } from "./request-pipeline.js";
|
|
6
|
+
import { assetPrefixPathname, isNextStaticPath } from "../utils/asset-prefix.js";
|
|
7
|
+
import { runWithExecutionContext } from "../shims/request-context.js";
|
|
8
|
+
import "./server-globals.js";
|
|
9
9
|
import { getCdnCacheAdapter } from "../shims/cdn-cache.js";
|
|
10
10
|
import { applyCdnResponseIdentityHeaders, validateCdnRequest } from "./cache-control.js";
|
|
11
11
|
import { getImageOptimizer, readImageOptimizationSignal } from "./image-optimization.js";
|
|
@@ -31,7 +31,7 @@ var app_router_entry_default = {
|
|
|
31
31
|
__ensureInstrumentation,
|
|
32
32
|
async fetch(request, env, ctx) {
|
|
33
33
|
const handleFetch = async () => {
|
|
34
|
-
await __ensureInstrumentation();
|
|
34
|
+
await __ensureInstrumentation(ctx);
|
|
35
35
|
const url = new URL(request.url);
|
|
36
36
|
return traceFrameworkRequest({
|
|
37
37
|
callback: async () => applyCdnResponseIdentityHeaders(await handleRequest(request, env, ctx), request),
|
|
@@ -53,7 +53,7 @@ async function handleRequest(request, env, platformCtx) {
|
|
|
53
53
|
let ctx = createWorkerPrerenderDiscoveryContext(requestCtx, request, __prerenderSecret);
|
|
54
54
|
const readinessResponse = createWorkerPrerenderReadinessResponse(ctx, request);
|
|
55
55
|
if (readinessResponse) {
|
|
56
|
-
if (readinessResponse.status === 204) await __ensureHybridPagesApplication();
|
|
56
|
+
if (readinessResponse.status === 204) await __ensureHybridPagesApplication(ctx);
|
|
57
57
|
return await validateCdnRequest(request) ?? readinessResponse;
|
|
58
58
|
}
|
|
59
59
|
let finalizeCacheabilityResponse;
|
|
@@ -66,7 +66,7 @@ async function handleRequest(request, env, platformCtx) {
|
|
|
66
66
|
const probeUrl = new URL(request.url);
|
|
67
67
|
if (probeUrl.searchParams.has("__vinext_cacheability_probe")) {
|
|
68
68
|
probeUrl.searchParams.delete(VINEXT_CACHEABILITY_PROBE_QUERY_PARAM);
|
|
69
|
-
request =
|
|
69
|
+
request = cloneRequestWithUrl(request, probeUrl.href);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -89,6 +89,22 @@ export declare function canonicalizePrewarmableRscRequestHeaders(headers: Header
|
|
|
89
89
|
* router state is transport context and must not fragment the shared response.
|
|
90
90
|
*/
|
|
91
91
|
export declare function canonicalizeLoadingShellRscRequestHeaders(headers: Headers): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Callers pass a path (usually a parsed URL's pathname + search) or an
|
|
94
|
+
* absolute URL. A pathname can begin with "//", and resolving that as a
|
|
95
|
+
* relative reference would read its first segment as a host, so a path is
|
|
96
|
+
* appended to the base instead of resolved against it.
|
|
97
|
+
*/
|
|
98
|
+
export declare function parseRscRequestPath(href: string): URL;
|
|
99
|
+
/**
|
|
100
|
+
* Serialize the path-absolute reference callers fetch against the app origin.
|
|
101
|
+
* A pathname that begins with "//" would serialize as a protocol-relative URL
|
|
102
|
+
* and send the request to another host, so it keeps a "/." prefix, as the
|
|
103
|
+
* WHATWG URL serializer does. URL resolution drops the dot segment, so the
|
|
104
|
+
* request still targets the same pathname on the app origin, as Next.js's
|
|
105
|
+
* full-URL fetch does.
|
|
106
|
+
*/
|
|
107
|
+
export declare function formatRscRequestPath(url: URL): string;
|
|
92
108
|
export declare function createRscRequestUrl(href: string, headers: Headers): Promise<string>;
|
|
93
109
|
/** Build the definitive full-route RSC URL shared by prefetch and navigation. */
|
|
94
110
|
export declare function createCanonicalRscRequestUrl(href: string): string;
|
|
@@ -218,33 +218,50 @@ function canonicalizeLoadingShellRscRequestHeaders(headers) {
|
|
|
218
218
|
headers.delete(VINEXT_CLIENT_REUSE_MANIFEST_HEADER);
|
|
219
219
|
return true;
|
|
220
220
|
}
|
|
221
|
-
|
|
221
|
+
const RSC_REQUEST_URL_BASE = "http://vinext.local";
|
|
222
|
+
/**
|
|
223
|
+
* Callers pass a path (usually a parsed URL's pathname + search) or an
|
|
224
|
+
* absolute URL. A pathname can begin with "//", and resolving that as a
|
|
225
|
+
* relative reference would read its first segment as a host, so a path is
|
|
226
|
+
* appended to the base instead of resolved against it.
|
|
227
|
+
*/
|
|
228
|
+
function parseRscRequestPath(href) {
|
|
222
229
|
const hashIndex = href.indexOf("#");
|
|
223
|
-
|
|
230
|
+
const beforeHash = hashIndex === -1 ? href : href.slice(0, hashIndex);
|
|
231
|
+
if (beforeHash.startsWith("/") || beforeHash.startsWith("\\")) return new URL(`${RSC_REQUEST_URL_BASE}${beforeHash}`);
|
|
232
|
+
return new URL(beforeHash, RSC_REQUEST_URL_BASE);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Serialize the path-absolute reference callers fetch against the app origin.
|
|
236
|
+
* A pathname that begins with "//" would serialize as a protocol-relative URL
|
|
237
|
+
* and send the request to another host, so it keeps a "/." prefix, as the
|
|
238
|
+
* WHATWG URL serializer does. URL resolution drops the dot segment, so the
|
|
239
|
+
* request still targets the same pathname on the app origin, as Next.js's
|
|
240
|
+
* full-URL fetch does.
|
|
241
|
+
*/
|
|
242
|
+
function formatRscRequestPath(url) {
|
|
243
|
+
return `${url.pathname.startsWith("//") ? `/.${url.pathname}` : url.pathname}${url.search}`;
|
|
224
244
|
}
|
|
225
245
|
async function createRscRequestUrl(href, headers) {
|
|
226
|
-
const url =
|
|
246
|
+
const url = parseRscRequestPath(href);
|
|
227
247
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "production" && process.env.__NEXT_CONFIG_OUTPUT === "export") {
|
|
228
248
|
const basePath = process.env.__NEXT_ROUTER_BASEPATH ?? "";
|
|
229
249
|
const isBasePathRoot = basePath !== "" && url.pathname === basePath;
|
|
230
250
|
if (url.pathname.endsWith("/")) url.pathname += "index.txt";
|
|
231
251
|
else url.pathname += isBasePathRoot ? "/index.txt" : ".txt";
|
|
232
|
-
return
|
|
252
|
+
return formatRscRequestPath(url);
|
|
233
253
|
}
|
|
234
254
|
setRscCacheBustingSearchParam(url, await computeRscCacheBustingSearchParam(headers));
|
|
235
|
-
return
|
|
255
|
+
return formatRscRequestPath(url);
|
|
236
256
|
}
|
|
237
257
|
/** Build the definitive full-route RSC URL shared by prefetch and navigation. */
|
|
238
258
|
function createCanonicalRscRequestUrl(href) {
|
|
239
|
-
const url =
|
|
259
|
+
const url = parseRscRequestPath(href);
|
|
240
260
|
setRscCacheBustingSearchParam(url, "");
|
|
241
|
-
return
|
|
261
|
+
return formatRscRequestPath(url);
|
|
242
262
|
}
|
|
243
263
|
function createServerActionRequestUrl(href) {
|
|
244
|
-
|
|
245
|
-
const beforeHash = hashIndex === -1 ? href : href.slice(0, hashIndex);
|
|
246
|
-
const url = new URL(beforeHash, "http://vinext.local");
|
|
247
|
-
return `${url.pathname}${url.search}`;
|
|
264
|
+
return formatRscRequestPath(parseRscRequestPath(href));
|
|
248
265
|
}
|
|
249
266
|
async function createRscRedirectLocation(location, request) {
|
|
250
267
|
const requestUrl = new URL(request.url);
|
|
@@ -309,4 +326,4 @@ async function resolveInvalidRscCacheBustingRequest(options) {
|
|
|
309
326
|
});
|
|
310
327
|
}
|
|
311
328
|
//#endregion
|
|
312
|
-
export { VINEXT_RSC_BUILD_ID_HEADER, VINEXT_RSC_CACHE_BUSTING_SEARCH_PARAM, VINEXT_RSC_COMPATIBILITY_ID_HEADER, VINEXT_RSC_CONTENT_TYPE, VINEXT_RSC_RENDER_MODE_HEADER, VINEXT_RSC_VARY_HEADER, applyRscCompatibilityIdHeader, applyRscDeploymentIdHeader, canonicalizeLoadingShellRscRequestHeaders, canonicalizePrewarmableRscRequestHeaders, computeRscCacheBustingSearchParam, createCanonicalLoadingShellRscRequestHeaders, createCanonicalRscRequestHeaders, createCanonicalRscRequestUrl, createRscRedirectLocation, createRscRequestHeaders, createRscRequestUrl, createServerActionRequestUrl, getVinextRscCompatibilityId, hasRscCacheBustingSearchParam, isRscCompatibilityIdCompatible, keepOnlyValidatedRscCacheBustingSearchParam, resolveHardNavigationTargetFromRscResponse, resolveInvalidRscCacheBustingRequest, resolveRscCompatibilityNavigationDecision, setRscCacheBustingSearchParam, stripRscCacheBustingSearchParam, stripRscSuffix };
|
|
329
|
+
export { VINEXT_RSC_BUILD_ID_HEADER, VINEXT_RSC_CACHE_BUSTING_SEARCH_PARAM, VINEXT_RSC_COMPATIBILITY_ID_HEADER, VINEXT_RSC_CONTENT_TYPE, VINEXT_RSC_RENDER_MODE_HEADER, VINEXT_RSC_VARY_HEADER, applyRscCompatibilityIdHeader, applyRscDeploymentIdHeader, canonicalizeLoadingShellRscRequestHeaders, canonicalizePrewarmableRscRequestHeaders, computeRscCacheBustingSearchParam, createCanonicalLoadingShellRscRequestHeaders, createCanonicalRscRequestHeaders, createCanonicalRscRequestUrl, createRscRedirectLocation, createRscRequestHeaders, createRscRequestUrl, createServerActionRequestUrl, formatRscRequestPath, getVinextRscCompatibilityId, hasRscCacheBustingSearchParam, isRscCompatibilityIdCompatible, keepOnlyValidatedRscCacheBustingSearchParam, parseRscRequestPath, resolveHardNavigationTargetFromRscResponse, resolveInvalidRscCacheBustingRequest, resolveRscCompatibilityNavigationDecision, setRscCacheBustingSearchParam, stripRscCacheBustingSearchParam, stripRscSuffix };
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { getRequestExecutionContext, runWithExecutionContext } from "../shims/request-context.js";
|
|
2
|
+
import { createWorkerRevalidationContext } from "./worker-revalidation-context.js";
|
|
1
3
|
import { createAppRscRequestHandler } from "./app-rsc-handler.js";
|
|
2
4
|
//#region src/server/app-rsc-combined-handler.ts
|
|
3
5
|
/** Combined request/response handler used by default single-stage App entries. */
|
|
4
6
|
function createAppRscHandler(options) {
|
|
5
|
-
const
|
|
7
|
+
const appRscRequestHandler = createAppRscRequestHandler(options);
|
|
8
|
+
const appRscHandler = (request, ctx, ...rest) => {
|
|
9
|
+
if (ctx != null || getRequestExecutionContext()) return appRscRequestHandler(request, ctx, ...rest);
|
|
10
|
+
const executionContext = createWorkerRevalidationContext(void 0, (internalRequest, internalCtx) => runWithExecutionContext(internalCtx, () => appRscRequestHandler(internalRequest, internalCtx)), "node");
|
|
11
|
+
return runWithExecutionContext(executionContext, () => appRscRequestHandler(request, ctx, ...rest));
|
|
12
|
+
};
|
|
6
13
|
return Object.assign(appRscHandler, { handleResponseStage(request, ctx, props, stageOptions) {
|
|
7
14
|
return import("./app-rsc-response-stage.js").then(({ renderAppWorkerResponseStage }) => renderAppWorkerResponseStage(options, request, ctx, props, stageOptions));
|
|
8
15
|
} });
|
|
@@ -37,6 +37,13 @@ export declare function getDigestForWellKnownError(error: unknown): string | und
|
|
|
37
37
|
* djb2 hash matching Next.js's string-hash package for RSC error digests.
|
|
38
38
|
*/
|
|
39
39
|
export declare function errorDigest(input: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* The message React 19.3's production Flight client gives a Server Components
|
|
42
|
+
* error in the browser (minified error #441). Sanitized errors that vinext
|
|
43
|
+
* serializes itself, such as the error passed to app/global-error, use the
|
|
44
|
+
* same text so they read the same as errors React reconstructs.
|
|
45
|
+
*/
|
|
46
|
+
export declare const PRODUCTION_SERVER_COMPONENTS_ERROR_MESSAGE = "Minified React error #441; visit https://react.dev/errors/441 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
|
|
40
47
|
export declare function sanitizeErrorForClient(error: unknown, nodeEnv?: "development" | "production" | "test"): unknown;
|
|
41
48
|
export declare function createRscOnErrorHandler(options: CreateRscOnErrorHandlerOptions): (error: unknown) => string | undefined;
|
|
42
49
|
//#endregion
|
|
@@ -41,10 +41,17 @@ function errorDigest(input) {
|
|
|
41
41
|
for (let i = input.length - 1; i >= 0; i--) hash = hash * 33 ^ input.charCodeAt(i);
|
|
42
42
|
return (hash >>> 0).toString();
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* The message React 19.3's production Flight client gives a Server Components
|
|
46
|
+
* error in the browser (minified error #441). Sanitized errors that vinext
|
|
47
|
+
* serializes itself, such as the error passed to app/global-error, use the
|
|
48
|
+
* same text so they read the same as errors React reconstructs.
|
|
49
|
+
*/
|
|
50
|
+
const PRODUCTION_SERVER_COMPONENTS_ERROR_MESSAGE = "Minified React error #441; visit https://react.dev/errors/441 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
|
|
44
51
|
function sanitizeErrorForClient(error, nodeEnv = process.env.NODE_ENV) {
|
|
45
52
|
if (resolveAppPageSpecialError(error)) return error;
|
|
46
53
|
if (nodeEnv !== "production") return error;
|
|
47
|
-
const sanitized = /* @__PURE__ */ new Error(
|
|
54
|
+
const sanitized = /* @__PURE__ */ new Error(PRODUCTION_SERVER_COMPONENTS_ERROR_MESSAGE);
|
|
48
55
|
sanitized.digest = hasDigest(error) ? String(error.digest) : getThrownValueDigest(error);
|
|
49
56
|
Object.defineProperty(sanitized, ORIGINAL_SERVER_ERROR, {
|
|
50
57
|
configurable: false,
|
|
@@ -85,4 +92,4 @@ function createRscOnErrorHandler(options) {
|
|
|
85
92
|
};
|
|
86
93
|
}
|
|
87
94
|
//#endregion
|
|
88
|
-
export { createRscOnErrorHandler, errorDigest, getDigestForWellKnownError, hasDigest, sanitizeErrorForClient };
|
|
95
|
+
export { PRODUCTION_SERVER_COMPONENTS_ERROR_MESSAGE, createRscOnErrorHandler, errorDigest, getDigestForWellKnownError, hasDigest, sanitizeErrorForClient };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { VinextCacheabilityProbeMode } from "./multi-stage.js";
|
|
2
2
|
import { NextHeader, NextI18nConfig, NextRedirect, NextRewrite } from "../config/next-config.js";
|
|
3
3
|
import { ImageConfig } from "./image-optimization.js";
|
|
4
|
+
import { ExecutionContextLike } from "../shims/request-context.js";
|
|
4
5
|
import { AppMiddlewareContext, ApplyAppMiddlewareResult } from "./app-middleware.js";
|
|
5
6
|
import { ClientReuseManifestParseResult } from "./client-reuse-manifest.js";
|
|
6
7
|
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
@@ -217,7 +218,7 @@ export type CreateAppRscHandlerOptions<TRoute extends AppRscHandlerRoute> = {
|
|
|
217
218
|
* dedup'd. Provided by the generated RSC entry; absent in older entries.
|
|
218
219
|
*/
|
|
219
220
|
ensureRouteLoaded?: (route: TRoute) => unknown;
|
|
220
|
-
ensureInstrumentation?: () => Promise<void>;
|
|
221
|
+
ensureInstrumentation?: (ctx: ExecutionContextLike | null) => Promise<void>;
|
|
221
222
|
/**
|
|
222
223
|
* Register cache adapters configured via the vinext() `cache` option. Wired
|
|
223
224
|
* from the generated RSC entry (which can import `virtual:vinext-cache-adapters`)
|
|
@@ -251,6 +252,8 @@ export type CreateAppRscHandlerOptions<TRoute extends AppRscHandlerRoute> = {
|
|
|
251
252
|
renderPagesFallback?: (options: RenderPagesFallbackOptions) => Promise<Response | null>;
|
|
252
253
|
rootParamNamesByPattern?: RootParamNamesMap;
|
|
253
254
|
setNavigationContext: (context: NavigationContextValue) => void;
|
|
255
|
+
/** next.config `skipProxyUrlNormalize`. */
|
|
256
|
+
skipProxyUrlNormalize?: boolean;
|
|
254
257
|
/** next.config `skipTrailingSlashRedirect`: serve both slash forms without a 308. */
|
|
255
258
|
skipTrailingSlashRedirect?: boolean;
|
|
256
259
|
staticParamsMap: StaticParamsMap;
|