vinext 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -30
- package/dist/build/inject-pregenerated-paths.d.ts +4 -0
- package/dist/build/inject-pregenerated-paths.js +18 -0
- package/dist/build/layout-classification.js +1 -1
- package/dist/build/nitro-route-rules.js +1 -1
- package/dist/build/pages-client-assets-module.d.ts +11 -0
- package/dist/build/pages-client-assets-module.js +27 -0
- package/dist/build/prerender.d.ts +2 -1
- package/dist/build/prerender.js +13 -6
- package/dist/build/report.d.ts +13 -2
- package/dist/build/report.js +99 -2
- package/dist/build/run-prerender.d.ts +7 -0
- package/dist/build/run-prerender.js +10 -1
- package/dist/build/standalone.js +2 -0
- package/dist/cache/cache-adapters-virtual.js +3 -3
- package/dist/check.js +40 -2
- package/dist/cli-args.d.ts +1 -2
- package/dist/cli-args.js +1 -1
- package/dist/cli-dev-config.d.ts +12 -0
- package/dist/cli-dev-config.js +23 -0
- package/dist/cli.js +111 -95
- package/dist/{server → client}/dev-error-overlay-store.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay-store.js +1 -1
- package/dist/{server → client}/dev-error-overlay.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay.js +2 -2
- package/dist/client/navigation-runtime.d.ts +2 -0
- package/dist/client/navigation-runtime.js +3 -1
- package/dist/client/window-next.d.ts +2 -1
- package/dist/cloudflare/index.d.ts +2 -2
- package/dist/cloudflare/index.js +2 -2
- package/dist/config/config-matchers.js +14 -10
- package/dist/config/next-config.d.ts +5 -3
- package/dist/config/next-config.js +44 -1
- package/dist/config/prerender.d.ts +34 -0
- package/dist/config/prerender.js +55 -0
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +40 -10
- package/dist/entries/app-rsc-manifest.js +2 -0
- package/dist/entries/pages-client-entry.d.ts +3 -0
- package/dist/entries/pages-client-entry.js +15 -1
- package/dist/entries/pages-server-entry.js +5 -2
- package/dist/image/image-adapters-virtual.d.ts +59 -0
- package/dist/image/image-adapters-virtual.js +59 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +167 -100
- package/dist/init-cloudflare.d.ts +43 -0
- package/dist/init-cloudflare.js +839 -0
- package/dist/init-platform.d.ts +40 -0
- package/dist/init-platform.js +195 -0
- package/dist/init.d.ts +16 -38
- package/dist/init.js +209 -99
- package/dist/node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.js +294 -0
- package/dist/node_modules/.pnpm/process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js +94 -0
- package/dist/{cloudflare → packages/cloudflare}/src/cache/cdn-adapter.runtime.js +1 -1
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.d.ts +2 -2
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.js +1 -1
- package/dist/packages/cloudflare/src/deploy-config.js +150 -0
- package/dist/packages/cloudflare/src/deploy-help.js +55 -0
- package/dist/packages/cloudflare/src/deploy.js +276 -0
- package/dist/{cloudflare → packages/cloudflare/src}/tpr.d.ts +4 -41
- package/dist/{cloudflare → packages/cloudflare/src}/tpr.js +18 -15
- package/dist/plugins/ast-scope.d.ts +16 -0
- package/dist/plugins/ast-scope.js +62 -0
- package/dist/plugins/ast-utils.d.ts +27 -1
- package/dist/plugins/ast-utils.js +32 -1
- package/dist/plugins/css-module-imports.d.ts +14 -0
- package/dist/plugins/css-module-imports.js +59 -0
- package/dist/plugins/extensionless-dynamic-import.js +2 -2
- package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
- package/dist/plugins/ignore-dynamic-requests.js +530 -0
- package/dist/plugins/typeof-window.d.ts +1 -1
- package/dist/plugins/typeof-window.js +28 -56
- package/dist/routing/app-route-graph.d.ts +23 -2
- package/dist/routing/app-route-graph.js +126 -32
- package/dist/routing/file-matcher.d.ts +3 -0
- package/dist/routing/file-matcher.js +3 -0
- package/dist/routing/pages-router.js +2 -2
- package/dist/server/api-handler.js +9 -14
- package/dist/server/app-browser-action-result.d.ts +4 -1
- package/dist/server/app-browser-action-result.js +8 -1
- package/dist/server/app-browser-entry.js +161 -52
- package/dist/server/app-browser-interception-context.d.ts +1 -0
- package/dist/server/app-browser-interception-context.js +4 -2
- package/dist/server/app-browser-navigation-controller.d.ts +2 -0
- package/dist/server/app-browser-navigation-controller.js +60 -31
- package/dist/server/app-browser-server-action-client.d.ts +1 -1
- package/dist/server/app-browser-server-action-client.js +3 -4
- package/dist/server/app-browser-state.d.ts +11 -1
- package/dist/server/app-browser-state.js +25 -8
- package/dist/server/app-browser-visible-commit.d.ts +6 -1
- package/dist/server/app-browser-visible-commit.js +43 -25
- package/dist/server/app-elements-wire.d.ts +9 -2
- package/dist/server/app-elements-wire.js +8 -1
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +4 -3
- package/dist/server/app-fallback-renderer.d.ts +2 -1
- package/dist/server/app-fallback-renderer.js +10 -6
- package/dist/server/app-hydration-cache-publication.d.ts +11 -0
- package/dist/server/app-hydration-cache-publication.js +43 -0
- package/dist/server/app-middleware.d.ts +4 -3
- package/dist/server/app-middleware.js +8 -3
- package/dist/server/app-optimistic-routing.js +11 -4
- package/dist/server/app-page-cache-finalizer.js +2 -1
- package/dist/server/app-page-cache-render.d.ts +1 -0
- package/dist/server/app-page-cache-render.js +8 -4
- package/dist/server/app-page-cache.d.ts +1 -0
- package/dist/server/app-page-cache.js +5 -2
- package/dist/server/app-page-dispatch.js +1 -0
- package/dist/server/app-page-element-builder.d.ts +2 -1
- package/dist/server/app-page-element-builder.js +58 -4
- package/dist/server/app-page-probe.js +5 -0
- package/dist/server/app-page-render-identity.d.ts +1 -0
- package/dist/server/app-page-render-identity.js +1 -1
- package/dist/server/app-page-render.js +18 -0
- package/dist/server/app-page-request.d.ts +14 -0
- package/dist/server/app-page-request.js +69 -4
- package/dist/server/app-page-route-wiring.d.ts +8 -1
- package/dist/server/app-page-route-wiring.js +32 -18
- package/dist/server/app-page-segment-state.d.ts +2 -1
- package/dist/server/app-page-segment-state.js +3 -1
- package/dist/server/app-page-stream.d.ts +5 -0
- package/dist/server/app-page-stream.js +3 -1
- package/dist/server/app-route-handler-execution.js +5 -1
- package/dist/server/app-route-handler-response.js +1 -0
- package/dist/server/app-route-handler-runtime.js +1 -1
- package/dist/server/app-router-entry.js +9 -2
- package/dist/server/app-rsc-handler.d.ts +1 -0
- package/dist/server/app-rsc-handler.js +62 -31
- package/dist/server/app-rsc-request-normalization.d.ts +3 -2
- package/dist/server/app-rsc-request-normalization.js +6 -3
- package/dist/server/app-segment-config.d.ts +11 -0
- package/dist/server/app-segment-config.js +62 -6
- package/dist/server/app-server-action-execution.d.ts +1 -0
- package/dist/server/app-server-action-execution.js +58 -28
- package/dist/server/app-ssr-entry.d.ts +3 -0
- package/dist/server/app-ssr-entry.js +15 -7
- package/dist/server/app-ssr-stream.d.ts +7 -3
- package/dist/server/app-ssr-stream.js +10 -6
- package/dist/server/app-visited-response-cache.d.ts +6 -0
- package/dist/server/app-visited-response-cache.js +3 -1
- package/dist/server/client-trace-metadata.js +26 -0
- package/dist/server/default-global-not-found-module.d.ts +14 -0
- package/dist/server/default-global-not-found-module.js +14 -0
- package/dist/server/dev-route-files.js +4 -0
- package/dist/server/dev-server.js +19 -18
- package/dist/server/dev-stack-sourcemap.d.ts +1 -1
- package/dist/server/dev-stack-sourcemap.js +1 -1
- package/dist/server/fetch-handler.d.ts +2 -0
- package/dist/server/fetch-handler.js +18 -0
- package/dist/server/headers.d.ts +3 -15
- package/dist/server/headers.js +2 -15
- package/dist/server/image-optimization.d.ts +51 -1
- package/dist/server/image-optimization.js +52 -2
- package/dist/server/implicit-tags.js +1 -1
- package/dist/server/isr-cache.d.ts +1 -1
- package/dist/server/isr-cache.js +2 -2
- package/dist/server/metadata-routes.d.ts +3 -1
- package/dist/server/metadata-routes.js +12 -2
- package/dist/server/middleware-runtime.js +6 -1
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +14 -3
- package/dist/server/pages-api-route.js +2 -2
- package/dist/server/pages-asset-tags.d.ts +4 -6
- package/dist/server/pages-asset-tags.js +12 -12
- package/dist/server/pages-client-assets.d.ts +12 -0
- package/dist/server/pages-client-assets.js +10 -0
- package/dist/server/pages-node-compat.d.ts +8 -1
- package/dist/server/pages-node-compat.js +32 -4
- package/dist/server/pages-page-data.d.ts +24 -1
- package/dist/server/pages-page-data.js +45 -24
- package/dist/server/pages-page-handler.d.ts +2 -1
- package/dist/server/pages-page-handler.js +19 -12
- package/dist/server/pages-page-response.d.ts +7 -0
- package/dist/server/pages-page-response.js +4 -1
- package/dist/server/pages-request-pipeline.d.ts +2 -0
- package/dist/server/pages-request-pipeline.js +25 -1
- package/dist/server/pages-router-entry.d.ts +30 -0
- package/dist/server/pages-router-entry.js +108 -0
- package/dist/server/prerender-manifest.d.ts +3 -1
- package/dist/server/prerender-route-params.js +1 -1
- package/dist/server/prod-server.d.ts +1 -1
- package/dist/server/prod-server.js +33 -20
- package/dist/server/request-pipeline.js +1 -0
- package/dist/server/seed-cache.js +4 -4
- package/dist/shims/app-router-scroll-state.d.ts +1 -0
- package/dist/shims/app-router-scroll-state.js +1 -0
- package/dist/shims/app-router-scroll.js +2 -1
- package/dist/shims/cache.js +19 -15
- package/dist/shims/cdn-cache.js +1 -1
- package/dist/shims/dynamic-preload-chunks.js +2 -1
- package/dist/shims/form.d.ts +3 -1
- package/dist/shims/form.js +37 -43
- package/dist/shims/headers.d.ts +7 -1
- package/dist/shims/headers.js +17 -3
- package/dist/shims/image.js +75 -14
- package/dist/shims/internal/app-route-detection.d.ts +2 -17
- package/dist/shims/internal/app-route-detection.js +4 -17
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +23 -0
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +51 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +2 -15
- package/dist/shims/internal/hybrid-client-route-owner.js +9 -60
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +9 -5
- package/dist/shims/internal/pages-data-fetch-dedup.js +73 -14
- package/dist/shims/internal/pages-data-target.d.ts +10 -9
- package/dist/shims/internal/pages-data-target.js +91 -12
- package/dist/shims/internal/pages-router-components.d.ts +7 -0
- package/dist/shims/internal/pages-router-components.js +13 -0
- package/dist/shims/layout-segment-context.d.ts +4 -1
- package/dist/shims/layout-segment-context.js +18 -4
- package/dist/shims/link.js +55 -26
- package/dist/shims/navigation.d.ts +5 -1
- package/dist/shims/navigation.js +45 -10
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/root-params.d.ts +15 -1
- package/dist/shims/root-params.js +21 -1
- package/dist/shims/router.d.ts +5 -7
- package/dist/shims/router.js +362 -93
- package/dist/shims/server.js +3 -2
- package/dist/shims/slot.js +3 -6
- package/dist/utils/client-runtime-metadata.d.ts +2 -18
- package/dist/utils/client-runtime-metadata.js +31 -22
- package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +4 -0
- package/dist/{server → utils}/dev-stack-sourcemap-endpoint.js +1 -1
- package/dist/utils/domain-locale.d.ts +6 -3
- package/dist/{server → utils}/middleware-request-headers.d.ts +1 -1
- package/dist/{server → utils}/middleware-request-headers.js +2 -2
- package/dist/utils/project.d.ts +48 -2
- package/dist/utils/project.js +225 -4
- package/dist/utils/protocol-headers.d.ts +17 -0
- package/dist/utils/protocol-headers.js +17 -0
- package/dist/utils/react-version.d.ts +4 -0
- package/dist/utils/react-version.js +44 -0
- package/package.json +47 -2
- package/dist/deploy.d.ts +0 -197
- package/dist/deploy.js +0 -1040
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +0 -4
- /package/dist/{cloudflare → packages/cloudflare}/src/utils/cache-control-metadata.js +0 -0
|
@@ -2,6 +2,7 @@ import { NEVER_CACHE_CONTROL, NO_STORE_CACHE_CONTROL, applyCdnResponseHeaders }
|
|
|
2
2
|
import { createArtifactCompatibilityEnvelope, createArtifactCompatibilityGraphVersion } from "./artifact-compatibility.js";
|
|
3
3
|
import { AppElementsWire, isAppElementsRecord } from "./app-elements-wire.js";
|
|
4
4
|
import "./app-elements.js";
|
|
5
|
+
import { peekDynamicUsage } from "../shims/headers.js";
|
|
5
6
|
import { runWithFetchDedupe } from "../shims/fetch-cache.js";
|
|
6
7
|
import { buildAppPageHtmlResponse, buildAppPageRscResponse, resolveAppPageHtmlResponsePolicy, resolveAppPageRscResponsePolicy } from "./app-page-response.js";
|
|
7
8
|
import { buildAppPageFontLinkHeader, readAppPageBinaryStream, resolveAppPageSpecialError, teeAppPageRscStreamForCapture } from "./app-page-execution.js";
|
|
@@ -314,6 +315,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
314
315
|
const outgoingElement = AppElementsWire.encodeOutgoingPayload({
|
|
315
316
|
element: options.element,
|
|
316
317
|
layoutFlags,
|
|
318
|
+
...options.dynamicStaleTimeSeconds !== void 0 && options.isPrerender !== true && !options.isForceStatic ? { dynamicStaleTimeSeconds: options.dynamicStaleTimeSeconds } : {},
|
|
317
319
|
...artifactCompatibility ? { artifactCompatibility } : {},
|
|
318
320
|
renderObservation: payloadRenderObservation,
|
|
319
321
|
skipDisposition: options.isRscRequest ? skipDisposition : void 0
|
|
@@ -427,6 +429,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
427
429
|
getStyles: options.getFontStyles
|
|
428
430
|
});
|
|
429
431
|
const fontLinkHeader = buildAppPageFontLinkHeader(fontData.preloads);
|
|
432
|
+
let dynamicUsedDuringHtmlRender = false;
|
|
430
433
|
let renderEnd;
|
|
431
434
|
const htmlRender = await renderAppPageHtmlStreamWithRecovery({
|
|
432
435
|
onShellRendered() {
|
|
@@ -440,6 +443,19 @@ async function renderAppPageLifecycle(options) {
|
|
|
440
443
|
const ssrHandler = await options.loadSsrHandler();
|
|
441
444
|
return renderAppPageHtmlStream({
|
|
442
445
|
capturedRscDataRef,
|
|
446
|
+
getInitialNavigationCacheMetadata: () => {
|
|
447
|
+
let kind;
|
|
448
|
+
if (options.isForceStatic) kind = "static";
|
|
449
|
+
else if (options.isForceDynamic || dynamicUsedDuringHtmlRender || peekDynamicUsage()) kind = "dynamic";
|
|
450
|
+
else {
|
|
451
|
+
const observation = options.peekRenderObservationState?.();
|
|
452
|
+
kind = observation && (observation.dynamicFetches.length > 0 || observation.requestApis.length > 0) ? "dynamic" : "static";
|
|
453
|
+
}
|
|
454
|
+
return {
|
|
455
|
+
kind,
|
|
456
|
+
...kind === "dynamic" && options.dynamicStaleTimeSeconds !== void 0 && options.isPrerender !== true && !shouldCaptureRscForCacheMetadata ? { dynamicStaleTimeSeconds: options.dynamicStaleTimeSeconds } : {}
|
|
457
|
+
};
|
|
458
|
+
},
|
|
443
459
|
fontData,
|
|
444
460
|
hasCustomGlobalError: options.hasCustomGlobalError,
|
|
445
461
|
navigationContext: options.getNavigationContext(),
|
|
@@ -485,10 +501,12 @@ async function renderAppPageLifecycle(options) {
|
|
|
485
501
|
}));
|
|
486
502
|
}
|
|
487
503
|
let dynamicUsedDuringRender = options.consumeDynamicUsage();
|
|
504
|
+
dynamicUsedDuringHtmlRender = dynamicUsedDuringRender;
|
|
488
505
|
const draftCookie = options.getDraftModeCookieHeader();
|
|
489
506
|
let dynamicUsedBeforeContextCleanup = dynamicUsedDuringRender;
|
|
490
507
|
const safeHtmlStream = deferUntilStreamConsumed(htmlStream, () => {
|
|
491
508
|
dynamicUsedBeforeContextCleanup = dynamicUsedBeforeContextCleanup || options.consumeDynamicUsage();
|
|
509
|
+
dynamicUsedDuringHtmlRender = dynamicUsedBeforeContextCleanup;
|
|
492
510
|
options.clearRequestContext();
|
|
493
511
|
});
|
|
494
512
|
const htmlResponsePolicy = resolveAppPageHtmlResponsePolicy({
|
|
@@ -12,8 +12,20 @@ type GenerateStaticParamsModule = {
|
|
|
12
12
|
};
|
|
13
13
|
type GenerateStaticParamsSource = {
|
|
14
14
|
generateStaticParams: GenerateStaticParams;
|
|
15
|
+
paramAliases?: Readonly<Record<string, string>>;
|
|
16
|
+
paramPatternParts?: readonly string[];
|
|
17
|
+
routePatternParts?: readonly string[];
|
|
15
18
|
parentParamNames: readonly string[];
|
|
16
19
|
};
|
|
20
|
+
type ParallelGenerateStaticParamsBranch = {
|
|
21
|
+
configLayouts?: readonly (GenerateStaticParamsModule | null | undefined)[] | null;
|
|
22
|
+
configLayoutTreePositions?: readonly number[] | null;
|
|
23
|
+
layout?: GenerateStaticParamsModule | null;
|
|
24
|
+
page?: GenerateStaticParamsModule | null;
|
|
25
|
+
paramNames?: readonly string[] | null;
|
|
26
|
+
patternParts?: readonly string[] | null;
|
|
27
|
+
routeSegments?: readonly string[] | null;
|
|
28
|
+
};
|
|
17
29
|
type ValidateAppPageDynamicParamsOptions = {
|
|
18
30
|
clearRequestContext: () => void;
|
|
19
31
|
enforceStaticParamsOnly: boolean;
|
|
@@ -25,6 +37,8 @@ type ResolveAppPageGenerateStaticParamsSourcesOptions = {
|
|
|
25
37
|
layouts?: readonly (GenerateStaticParamsModule | null | undefined)[];
|
|
26
38
|
layoutTreePositions?: readonly number[];
|
|
27
39
|
page?: GenerateStaticParamsModule | null;
|
|
40
|
+
parallelBranches?: readonly (ParallelGenerateStaticParamsBranch | null | undefined)[];
|
|
41
|
+
routePatternParts?: readonly string[];
|
|
28
42
|
routeSegments: readonly string[];
|
|
29
43
|
};
|
|
30
44
|
type BuildAppPageElementOptions<TElement> = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { notFoundResponse } from "./http-error-responses.js";
|
|
2
2
|
import { runWithFetchDedupe } from "../shims/fetch-cache.js";
|
|
3
|
+
import { matchRoutePattern } from "../routing/route-pattern.js";
|
|
3
4
|
import { getAppPageSegmentParamName } from "./app-page-params.js";
|
|
4
5
|
import { loadAppInterceptLayouts } from "./app-route-module-loader.js";
|
|
5
6
|
//#region src/server/app-page-request.ts
|
|
@@ -11,6 +12,31 @@ function pickRouteParams(matchedParams, routeParamNames) {
|
|
|
11
12
|
}
|
|
12
13
|
return params;
|
|
13
14
|
}
|
|
15
|
+
function remapRouteParams(matchedParams, source) {
|
|
16
|
+
if (source.paramPatternParts && source.routePatternParts) {
|
|
17
|
+
const urlParts = [];
|
|
18
|
+
for (const part of source.routePatternParts) {
|
|
19
|
+
if (!part.startsWith(":")) {
|
|
20
|
+
urlParts.push(part);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const value = matchedParams[part.slice(1).replace(/[+*]$/, "")];
|
|
24
|
+
if (Array.isArray(value)) urlParts.push(...value.map(encodeURIComponent));
|
|
25
|
+
else if (value !== void 0) urlParts.push(encodeURIComponent(value));
|
|
26
|
+
}
|
|
27
|
+
const slotParams = matchRoutePattern(urlParts, source.paramPatternParts);
|
|
28
|
+
if (slotParams) return slotParams;
|
|
29
|
+
}
|
|
30
|
+
if (!source.paramAliases) return matchedParams;
|
|
31
|
+
const params = { ...matchedParams };
|
|
32
|
+
for (const [routeParamName, sourceParamName] of Object.entries(source.paramAliases)) {
|
|
33
|
+
const value = matchedParams[routeParamName];
|
|
34
|
+
if (value === void 0) continue;
|
|
35
|
+
delete params[routeParamName];
|
|
36
|
+
params[sourceParamName] = value;
|
|
37
|
+
}
|
|
38
|
+
return params;
|
|
39
|
+
}
|
|
14
40
|
function collectParentParamNames(routeSegments, boundaryPosition) {
|
|
15
41
|
const limit = Math.max(0, Math.min(boundaryPosition, routeSegments.length));
|
|
16
42
|
const names = [];
|
|
@@ -23,6 +49,16 @@ function collectParentParamNames(routeSegments, boundaryPosition) {
|
|
|
23
49
|
function getLayoutGenerateStaticParamsBoundary(layoutTreePosition) {
|
|
24
50
|
return (layoutTreePosition ?? 0) - 1;
|
|
25
51
|
}
|
|
52
|
+
function getParallelParentParamNames(routeParamNames, branch, boundaryPosition) {
|
|
53
|
+
const slotParamNames = branch.paramNames ?? routeParamNames;
|
|
54
|
+
const branchParamNames = collectParentParamNames(branch.routeSegments ?? [], boundaryPosition);
|
|
55
|
+
const branchParamNameSet = new Set((branch.routeSegments ?? []).flatMap((segment) => {
|
|
56
|
+
const name = getAppPageSegmentParamName(segment);
|
|
57
|
+
return name ? [name] : [];
|
|
58
|
+
}));
|
|
59
|
+
const ownerParamNames = slotParamNames.filter((name) => !branchParamNameSet.has(name));
|
|
60
|
+
return [...new Set([...ownerParamNames, ...branchParamNames])];
|
|
61
|
+
}
|
|
26
62
|
function resolveAppPageGenerateStaticParamsSources(options) {
|
|
27
63
|
const sources = [];
|
|
28
64
|
options.layouts?.forEach((layout, index) => {
|
|
@@ -36,6 +72,33 @@ function resolveAppPageGenerateStaticParamsSources(options) {
|
|
|
36
72
|
generateStaticParams: options.page.generateStaticParams,
|
|
37
73
|
parentParamNames: collectParentParamNames(options.routeSegments, Math.max(0, options.routeSegments.length - 1))
|
|
38
74
|
});
|
|
75
|
+
const routeParamNames = options.routeSegments.flatMap((segment) => {
|
|
76
|
+
const name = getAppPageSegmentParamName(segment);
|
|
77
|
+
return name ? [name] : [];
|
|
78
|
+
});
|
|
79
|
+
for (const parallelBranch of options.parallelBranches ?? []) {
|
|
80
|
+
if (!parallelBranch) continue;
|
|
81
|
+
const slotParamNames = parallelBranch.paramNames ?? routeParamNames;
|
|
82
|
+
const paramAliases = Object.fromEntries(routeParamNames.flatMap((routeParamName, index) => {
|
|
83
|
+
const slotParamName = slotParamNames[index];
|
|
84
|
+
return slotParamName && slotParamName !== routeParamName ? [[routeParamName, slotParamName]] : [];
|
|
85
|
+
}));
|
|
86
|
+
const addParallelSource = (module, boundaryPosition) => {
|
|
87
|
+
if (typeof module?.generateStaticParams !== "function") return;
|
|
88
|
+
sources.push({
|
|
89
|
+
generateStaticParams: module.generateStaticParams,
|
|
90
|
+
...Object.keys(paramAliases).length > 0 ? { paramAliases } : {},
|
|
91
|
+
...parallelBranch.patternParts ? { paramPatternParts: parallelBranch.patternParts } : {},
|
|
92
|
+
...options.routePatternParts ? { routePatternParts: options.routePatternParts } : {},
|
|
93
|
+
parentParamNames: getParallelParentParamNames(routeParamNames, parallelBranch, boundaryPosition)
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
addParallelSource(parallelBranch.layout, -1);
|
|
97
|
+
parallelBranch.configLayouts?.forEach((layout, index) => {
|
|
98
|
+
addParallelSource(layout, getLayoutGenerateStaticParamsBoundary(parallelBranch.configLayoutTreePositions?.[index]));
|
|
99
|
+
});
|
|
100
|
+
addParallelSource(parallelBranch.page, Math.max(0, (parallelBranch.routeSegments?.length ?? 0) - 1));
|
|
101
|
+
}
|
|
39
102
|
return sources;
|
|
40
103
|
}
|
|
41
104
|
function areStaticParamsAllowed(params, staticParams) {
|
|
@@ -44,8 +107,9 @@ function areStaticParamsAllowed(params, staticParams) {
|
|
|
44
107
|
const value = params[key];
|
|
45
108
|
const staticValue = staticParamSet[key];
|
|
46
109
|
if (staticValue === void 0) return true;
|
|
47
|
-
if (Array.isArray(value)) return
|
|
48
|
-
if (typeof staticValue === "string"
|
|
110
|
+
if (Array.isArray(value)) return Array.isArray(staticValue) && value.length === staticValue.length && value.every((part, index) => typeof staticValue[index] === "string" ? part.toLowerCase() === staticValue[index].toLowerCase() : part === staticValue[index]);
|
|
111
|
+
if (typeof staticValue === "string") return value.toLowerCase() === staticValue.toLowerCase();
|
|
112
|
+
if (typeof staticValue === "number" || typeof staticValue === "boolean") return String(value) === String(staticValue);
|
|
49
113
|
return JSON.stringify(value) === JSON.stringify(staticValue);
|
|
50
114
|
}));
|
|
51
115
|
}
|
|
@@ -67,8 +131,9 @@ async function validateAppPageDynamicParams(options) {
|
|
|
67
131
|
return notFoundResponse();
|
|
68
132
|
}
|
|
69
133
|
for (const source of generateStaticParamsSources) {
|
|
70
|
-
const
|
|
71
|
-
|
|
134
|
+
const sourceParams = remapRouteParams(options.params, source);
|
|
135
|
+
const staticParams = await runWithFetchDedupe(() => source.generateStaticParams({ params: pickRouteParams(sourceParams, source.parentParamNames) }));
|
|
136
|
+
if (Array.isArray(staticParams) && !areStaticParamsAllowed(sourceParams, staticParams)) {
|
|
72
137
|
options.clearRequestContext();
|
|
73
138
|
return notFoundResponse();
|
|
74
139
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AppRouteSemanticIds } from "../routing/app-route-graph.js";
|
|
2
|
-
import { AppElements, AppElementsInterception } from "./app-elements-wire.js";
|
|
2
|
+
import { AppElements, AppElementsInterception, AppElementsSlotBinding } from "./app-elements-wire.js";
|
|
3
3
|
import { AppPageParams } from "./app-page-boundary.js";
|
|
4
4
|
import { ThenableParamsObserver } from "../shims/thenable-params.js";
|
|
5
5
|
import { Metadata, Viewport } from "../shims/metadata.js";
|
|
@@ -64,10 +64,16 @@ type AppPageRouteWiringRoute<TModule extends AppPageModule = AppPageModule, TErr
|
|
|
64
64
|
unauthorized?: TModule | null;
|
|
65
65
|
unauthorizeds?: readonly (TModule | null | undefined)[] | null;
|
|
66
66
|
routeSegments?: readonly string[];
|
|
67
|
+
childrenRouteSegments?: readonly string[] | null;
|
|
67
68
|
/**
|
|
68
69
|
* Keyed by stable slot id (name + owner path), not necessarily the slot prop name.
|
|
69
70
|
*/
|
|
70
71
|
slots?: Readonly<Record<string, AppPageRouteWiringSlot<TModule, TErrorModule>>> | null;
|
|
72
|
+
childrenSlot?: {
|
|
73
|
+
id: string;
|
|
74
|
+
ownerTreePath: string;
|
|
75
|
+
state: AppElementsSlotBinding["state"];
|
|
76
|
+
} | null;
|
|
71
77
|
/**
|
|
72
78
|
* Static sibling segment names at each dynamic URL level for this route. Used
|
|
73
79
|
* by the client router to determine if a cached prefetch of the dynamic
|
|
@@ -96,6 +102,7 @@ type AppPageSlotOverride<TModule extends AppPageModule = AppPageModule> = {
|
|
|
96
102
|
pageModule?: TModule | null;
|
|
97
103
|
params?: AppPageParams;
|
|
98
104
|
props?: Readonly<Record<string, unknown>>;
|
|
105
|
+
routeSegments?: readonly string[] | null;
|
|
99
106
|
};
|
|
100
107
|
type AppPageLayoutEntry<TModule extends AppPageModule = AppPageModule, TErrorModule extends AppPageErrorModule = AppPageErrorModule> = {
|
|
101
108
|
errorModule?: TErrorModule | null | undefined;
|
|
@@ -10,7 +10,7 @@ import { MetadataHead, ViewportHead, renderMetadataToHtml } from "../shims/metad
|
|
|
10
10
|
import { Children as Children$1, ParallelSlot, Slot } from "../shims/slot.js";
|
|
11
11
|
import { resolveAppPageBranchParams, resolveAppPageSegmentParamScopeKeys, resolveAppPageSegmentParams } from "./app-page-params.js";
|
|
12
12
|
import { probeReactServerSubtree } from "./app-page-probe.js";
|
|
13
|
-
import { resolveAppPageChildSegments, resolveAppPageRouteStateKey, resolveAppPageSegmentStateKey } from "./app-page-segment-state.js";
|
|
13
|
+
import { APP_PAGE_SEGMENT_KEY, resolveAppPageChildSegments, resolveAppPageRouteStateKey, resolveAppPageSegmentStateKey } from "./app-page-segment-state.js";
|
|
14
14
|
import { Fragment, Suspense } from "react";
|
|
15
15
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
16
16
|
//#region src/server/app-page-route-wiring.tsx
|
|
@@ -93,6 +93,10 @@ function createAppPageTemplateEntries(route) {
|
|
|
93
93
|
function createAppPageSourcePage(routeSegments) {
|
|
94
94
|
return `/${[...routeSegments ?? [], "page"].join("/")}`;
|
|
95
95
|
}
|
|
96
|
+
function resolveAppPageLayoutSegmentProviderSegments(routeSegments, treePosition, params) {
|
|
97
|
+
const segments = resolveAppPageChildSegments(routeSegments, treePosition, params);
|
|
98
|
+
return segments.at(-1) === "__PAGE__" ? segments.slice(0, -1) : segments;
|
|
99
|
+
}
|
|
96
100
|
function createAppPageErrorEntries(route) {
|
|
97
101
|
return (route.errorPaths ?? route.errors ?? []).flatMap((errorModule, index) => {
|
|
98
102
|
if (!errorModule) return [];
|
|
@@ -104,7 +108,7 @@ function createAppPageErrorEntries(route) {
|
|
|
104
108
|
}];
|
|
105
109
|
});
|
|
106
110
|
}
|
|
107
|
-
function createAppPageParallelSlotEntries(layoutIndex, layoutEntries, route, getEffectiveSlotParams) {
|
|
111
|
+
function createAppPageParallelSlotEntries(layoutIndex, layoutEntries, route, getEffectiveSlotParams, resolveSlotOverride) {
|
|
108
112
|
const parallelSlots = {};
|
|
109
113
|
for (const [slotKey, slot] of Object.entries(route.slots ?? {})) {
|
|
110
114
|
const slotName = slot.name;
|
|
@@ -112,8 +116,10 @@ function createAppPageParallelSlotEntries(layoutIndex, layoutEntries, route, get
|
|
|
112
116
|
if (targetIndex !== layoutIndex) continue;
|
|
113
117
|
const slotId = resolveAppPageSlotId(slot, layoutEntries[targetIndex]?.treePath ?? "/");
|
|
114
118
|
const slotParams = getEffectiveSlotParams(slotKey, slotName);
|
|
119
|
+
const routeSegments = resolveSlotOverride(slotKey, slotName)?.routeSegments ?? slot.routeSegments;
|
|
115
120
|
parallelSlots[slotName] = /* @__PURE__ */ jsx(LayoutSegmentProvider, {
|
|
116
|
-
|
|
121
|
+
providerId: slotId,
|
|
122
|
+
segmentMap: { children: routeSegments ? resolveAppPageLayoutSegmentProviderSegments(routeSegments, 0, slotParams) : [] },
|
|
117
123
|
children: /* @__PURE__ */ jsx(Slot, { id: slotId })
|
|
118
124
|
});
|
|
119
125
|
}
|
|
@@ -131,6 +137,14 @@ function resolveAppPageSlotBindingState(slot, override) {
|
|
|
131
137
|
}
|
|
132
138
|
function createAppPageSlotBindings(route, layoutEntries, resolveSlotOverride, options) {
|
|
133
139
|
const bindings = [];
|
|
140
|
+
if (route.childrenSlot) {
|
|
141
|
+
const ownerLayoutId = layoutEntries.find((layoutEntry) => layoutEntry.treePath === route.childrenSlot?.ownerTreePath)?.id;
|
|
142
|
+
bindings.push({
|
|
143
|
+
ownerLayoutId: ownerLayoutId ?? null,
|
|
144
|
+
slotId: route.childrenSlot.id,
|
|
145
|
+
state: route.childrenSlot.state
|
|
146
|
+
});
|
|
147
|
+
}
|
|
134
148
|
for (const [slotKey, slot] of Object.entries(route.slots ?? {})) {
|
|
135
149
|
const layoutEntry = layoutEntries[slot.layoutIndex >= 0 ? slot.layoutIndex : layoutEntries.length - 1] ?? null;
|
|
136
150
|
const ownerLayoutId = layoutEntry?.id ?? null;
|
|
@@ -173,6 +187,7 @@ function buildAppPageElements(options) {
|
|
|
173
187
|
const routeResetKey = resolveAppPageRouteStateKey(routeSegments, options.matchedParams);
|
|
174
188
|
const routeId = renderIdentity?.routeId ?? AppElementsWire.encodeRouteId(options.routePath, interceptionContext);
|
|
175
189
|
const pageId = renderIdentity?.pageId ?? AppElementsWire.encodePageId(options.routePath, interceptionContext);
|
|
190
|
+
const pageElementId = options.route.childrenSlot?.id ?? pageId;
|
|
176
191
|
const layoutEntries = createAppPageLayoutEntries(options.route);
|
|
177
192
|
const templateEntries = createAppPageTemplateEntries(options.route);
|
|
178
193
|
const errorEntries = createAppPageErrorEntries(options.route);
|
|
@@ -246,19 +261,13 @@ function buildAppPageElements(options) {
|
|
|
246
261
|
const routeLoadingComponent = getDefaultExport(options.route.loading);
|
|
247
262
|
const isPrefetchLoadingShell = renderMode === APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL;
|
|
248
263
|
if (isPrefetchLoadingShell && routeLoadingComponent !== null) elements[APP_PREFETCH_LOADING_SHELL_MARKER_KEY] = "LoadingBoundary";
|
|
249
|
-
elements[
|
|
264
|
+
elements[pageElementId] = isPrefetchLoadingShell ? null : renderAfterAppDependencies(options.element, pageDependencies);
|
|
250
265
|
for (const templateEntry of templateEntries) {
|
|
251
266
|
const templateComponent = getDefaultExport(templateEntry.templateModule);
|
|
252
267
|
if (!templateComponent) continue;
|
|
253
268
|
const TemplateComponent = templateComponent;
|
|
254
269
|
const templateDependency = templateDependenciesById.get(templateEntry.id);
|
|
255
|
-
const templateElement = templateDependency ? renderWithAppDependencyBarrier(/* @__PURE__ */ jsx(TemplateComponent, {
|
|
256
|
-
params: options.matchedParams,
|
|
257
|
-
children: /* @__PURE__ */ jsx(Children$1, {})
|
|
258
|
-
}), templateDependency) : /* @__PURE__ */ jsx(TemplateComponent, {
|
|
259
|
-
params: options.matchedParams,
|
|
260
|
-
children: /* @__PURE__ */ jsx(Children$1, {})
|
|
261
|
-
});
|
|
270
|
+
const templateElement = templateDependency ? renderWithAppDependencyBarrier(/* @__PURE__ */ jsx(TemplateComponent, { children: /* @__PURE__ */ jsx(Children$1, {}) }), templateDependency) : /* @__PURE__ */ jsx(TemplateComponent, { children: /* @__PURE__ */ jsx(Children$1, {}) });
|
|
262
271
|
elements[templateEntry.id] = renderAfterAppDependencies(templateElement, templateDependenciesBeforeById.get(templateEntry.id) ?? []);
|
|
263
272
|
}
|
|
264
273
|
for (let index = 0; index < layoutEntries.length; index++) {
|
|
@@ -296,7 +305,7 @@ function buildAppPageElements(options) {
|
|
|
296
305
|
const slotId = resolveAppPageSlotId(slot, layoutEntries[targetIndex]?.treePath ?? "/");
|
|
297
306
|
const slotOverride = resolveSlotOverride(slotKey, slotName);
|
|
298
307
|
const slotParams = getEffectiveSlotParams(slotKey, slotName);
|
|
299
|
-
const slotRouteSegments = slot.routeSegments ?? [];
|
|
308
|
+
const slotRouteSegments = slotOverride?.routeSegments ?? slot.routeSegments ?? [];
|
|
300
309
|
const slotOwnerParams = resolveAppPageSegmentParams(options.route.routeSegments, layoutEntries[targetIndex]?.treePosition ?? 0, options.matchedParams);
|
|
301
310
|
const slotResetKey = resolveAppPageRouteStateKey(slotRouteSegments, slotParams);
|
|
302
311
|
const overrideOrPageComponent = getDefaultExport(slotOverride?.pageModule) ?? getDefaultExport(slot.page);
|
|
@@ -338,7 +347,7 @@ function buildAppPageElements(options) {
|
|
|
338
347
|
children: slotElement
|
|
339
348
|
});
|
|
340
349
|
}
|
|
341
|
-
const slotLayoutComponent = getDefaultExport(slot.layout);
|
|
350
|
+
const slotLayoutComponent = overrideOrPageComponent ? getDefaultExport(slot.layout) : null;
|
|
342
351
|
if (slotLayoutComponent) slotElement = /* @__PURE__ */ jsx(slotLayoutComponent, {
|
|
343
352
|
params: options.makeThenableParams(slotOwnerParams),
|
|
344
353
|
children: slotElement
|
|
@@ -357,8 +366,9 @@ function buildAppPageElements(options) {
|
|
|
357
366
|
elements[slotId] = renderAfterAppDependencies(slotElement, targetIndex >= 0 ? slotDependenciesByLayoutIndex[targetIndex] ?? [] : []);
|
|
358
367
|
}
|
|
359
368
|
let routeChildren = /* @__PURE__ */ jsx(LayoutSegmentProvider, {
|
|
360
|
-
|
|
361
|
-
|
|
369
|
+
providerId: pageElementId,
|
|
370
|
+
segmentMap: { children: [APP_PAGE_SEGMENT_KEY] },
|
|
371
|
+
children: /* @__PURE__ */ jsx(Slot, { id: pageElementId })
|
|
362
372
|
});
|
|
363
373
|
if (isPrefetchLoadingShell) if (routeLoadingComponent === null) routeChildren = null;
|
|
364
374
|
else routeChildren = /* @__PURE__ */ jsx(routeLoadingComponent, {});
|
|
@@ -438,18 +448,22 @@ function buildAppPageElements(options) {
|
|
|
438
448
|
}
|
|
439
449
|
const layoutHasElement = getDefaultExport(layoutEntry.layoutModule) !== null;
|
|
440
450
|
const layoutIndex = layoutIndicesByTreePosition.get(treePosition) ?? -1;
|
|
441
|
-
const segmentMap = { children:
|
|
451
|
+
const segmentMap = { children: resolveAppPageLayoutSegmentProviderSegments(options.route.childrenRouteSegments ?? routeSegments, layoutEntry.treePosition, options.matchedParams) };
|
|
442
452
|
for (const [slotKey, slot] of Object.entries(options.route.slots ?? {})) {
|
|
443
453
|
const slotName = slot.name;
|
|
444
454
|
if ((slot.layoutIndex >= 0 ? slot.layoutIndex : layoutEntries.length - 1) !== layoutIndex) continue;
|
|
445
455
|
const slotParams = getEffectiveSlotParams(slotKey, slotName);
|
|
446
|
-
|
|
456
|
+
const slotOverride = resolveSlotOverride(slotKey, slotName);
|
|
457
|
+
if (!(getDefaultExport(slotOverride?.pageModule) !== null || getDefaultExport(slot.page) !== null) && options.isRscRequest && options.mountedSlotIds?.has(resolveAppPageSlotId(slot, layoutEntry.treePath))) continue;
|
|
458
|
+
const slotRouteSegments = slotOverride?.routeSegments ?? slot.routeSegments;
|
|
459
|
+
segmentMap[slotName] = slotRouteSegments ? resolveAppPageLayoutSegmentProviderSegments(slotRouteSegments, 0, slotParams) : [];
|
|
447
460
|
}
|
|
448
461
|
routeChildren = /* @__PURE__ */ jsx(LayoutSegmentProvider, {
|
|
462
|
+
providerId: layoutEntry.id,
|
|
449
463
|
segmentMap,
|
|
450
464
|
children: layoutHasElement ? /* @__PURE__ */ jsx(Slot, {
|
|
451
465
|
id: layoutEntry.id,
|
|
452
|
-
parallelSlots: createAppPageParallelSlotEntries(layoutIndex, layoutEntries, options.route, getEffectiveSlotParams),
|
|
466
|
+
parallelSlots: createAppPageParallelSlotEntries(layoutIndex, layoutEntries, options.route, getEffectiveSlotParams, resolveSlotOverride),
|
|
453
467
|
children: segmentChildren
|
|
454
468
|
}) : segmentChildren
|
|
455
469
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AppPageParams } from "./app-page-boundary.js";
|
|
2
2
|
|
|
3
3
|
//#region src/server/app-page-segment-state.d.ts
|
|
4
|
+
declare const APP_PAGE_SEGMENT_KEY = "__PAGE__";
|
|
4
5
|
declare function resolveAppPageChildSegments(routeSegments: readonly string[], treePosition: number, params: AppPageParams): string[];
|
|
5
6
|
declare function resolveAppPageSegmentStateKey(routeSegments: readonly string[], treePosition: number, params: AppPageParams): string;
|
|
6
7
|
declare function resolveAppPageRouteStateKey(routeSegments: readonly string[], params: AppPageParams): string;
|
|
7
8
|
declare function resolveAppPageLeafSegmentStateKey(routeSegments: readonly string[], params: AppPageParams): string;
|
|
8
9
|
//#endregion
|
|
9
|
-
export { resolveAppPageChildSegments, resolveAppPageLeafSegmentStateKey, resolveAppPageRouteStateKey, resolveAppPageSegmentStateKey };
|
|
10
|
+
export { APP_PAGE_SEGMENT_KEY, resolveAppPageChildSegments, resolveAppPageLeafSegmentStateKey, resolveAppPageRouteStateKey, resolveAppPageSegmentStateKey };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isCatchAllSegment, isOptionalCatchAllSegment } from "../routing/utils.js";
|
|
2
2
|
//#region src/server/app-page-segment-state.ts
|
|
3
|
+
const APP_PAGE_SEGMENT_KEY = "__PAGE__";
|
|
3
4
|
function isDynamicSegment(segment) {
|
|
4
5
|
return segment.startsWith("[") && segment.endsWith("]") && !segment.includes(".");
|
|
5
6
|
}
|
|
@@ -58,6 +59,7 @@ function resolveAppPageChildSegments(routeSegments, treePosition, params) {
|
|
|
58
59
|
}
|
|
59
60
|
resolvedSegments.push(segment);
|
|
60
61
|
}
|
|
62
|
+
resolvedSegments.push(APP_PAGE_SEGMENT_KEY);
|
|
61
63
|
return resolvedSegments;
|
|
62
64
|
}
|
|
63
65
|
function resolveAppPageSegmentStateKey(routeSegments, treePosition, params) {
|
|
@@ -77,4 +79,4 @@ function resolveAppPageLeafSegmentStateKey(routeSegments, params) {
|
|
|
77
79
|
return "";
|
|
78
80
|
}
|
|
79
81
|
//#endregion
|
|
80
|
-
export { resolveAppPageChildSegments, resolveAppPageLeafSegmentStateKey, resolveAppPageRouteStateKey, resolveAppPageSegmentStateKey };
|
|
82
|
+
export { APP_PAGE_SEGMENT_KEY, resolveAppPageChildSegments, resolveAppPageLeafSegmentStateKey, resolveAppPageRouteStateKey, resolveAppPageSegmentStateKey };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NavigationContext } from "../shims/navigation-context-state.js";
|
|
2
2
|
import { AppPageFontPreload } from "./app-page-execution.js";
|
|
3
3
|
import { RootParams } from "../shims/root-params.js";
|
|
4
|
+
import { InitialNavigationCacheMetadata } from "./app-ssr-stream.js";
|
|
4
5
|
import { deferUntilStreamConsumed } from "./defer-until-stream-consumed.js";
|
|
5
6
|
import { ReactFormState } from "react-dom/client";
|
|
6
7
|
|
|
@@ -72,9 +73,13 @@ type AppPageSsrHandler = {
|
|
|
72
73
|
* default `__next_error__` error-document shell (with the original
|
|
73
74
|
* flight payload and bootstrap) instead of rejecting. See handleSsr. */
|
|
74
75
|
fallbackToErrorDocumentOnShellError?: boolean;
|
|
76
|
+
dynamicStaleTimeSeconds?: number;
|
|
77
|
+
getInitialNavigationCacheMetadata?: () => InitialNavigationCacheMetadata;
|
|
75
78
|
}) => Promise<ReadableStream<Uint8Array> | AppSsrRenderResult>;
|
|
76
79
|
};
|
|
77
80
|
type RenderAppPageHtmlStreamOptions = {
|
|
81
|
+
dynamicStaleTimeSeconds?: number;
|
|
82
|
+
getInitialNavigationCacheMetadata?: () => InitialNavigationCacheMetadata;
|
|
78
83
|
fontData: AppPageFontData;
|
|
79
84
|
formState?: ReactFormState | null;
|
|
80
85
|
navigationContext: NavigationContext | null;
|
|
@@ -68,7 +68,9 @@ async function renderAppPageHtmlStream(options) {
|
|
|
68
68
|
pprFallbackShellSignal: options.pprFallbackShellSignal,
|
|
69
69
|
waitForAllReady: options.waitForAllReady,
|
|
70
70
|
initialDevServerError: options.initialDevServerError,
|
|
71
|
-
fallbackToErrorDocumentOnShellError: options.waitForAllReady !== true && options.hasCustomGlobalError === false
|
|
71
|
+
fallbackToErrorDocumentOnShellError: options.waitForAllReady !== true && options.hasCustomGlobalError === false,
|
|
72
|
+
dynamicStaleTimeSeconds: options.dynamicStaleTimeSeconds,
|
|
73
|
+
getInitialNavigationCacheMetadata: options.getInitialNavigationCacheMetadata
|
|
72
74
|
};
|
|
73
75
|
return normalizeAppSsrRenderResult(await options.ssrHandler.handleSsr(options.rscStream, options.navigationContext, options.fontData, ssrOptions), options.capturedRscDataRef?.value ?? null);
|
|
74
76
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isDraftModeRequest, setHeadersContext } from "../shims/headers.js";
|
|
2
2
|
import { isPossibleAppRouteActionRequest } from "./app-action-request.js";
|
|
3
|
+
import { runWithRootParamsUsage } from "../shims/root-params.js";
|
|
3
4
|
import { applyRouteHandlerMiddlewareContext, applyRouteHandlerRevalidateHeader, assertSupportedAppRouteHandlerResponse, buildAppRouteCacheValue, finalizeRouteHandlerResponse, markRouteHandlerCacheMiss } from "./app-route-handler-response.js";
|
|
4
5
|
import { createTrackedAppRouteRequest, markKnownDynamicAppRoute } from "./app-route-handler-runtime.js";
|
|
5
6
|
import { createStaticGenerationHeadersContext, getAppRouteStaticGenerationErrorMessage } from "./app-static-generation.js";
|
|
@@ -33,7 +34,10 @@ async function runAppRouteHandler(options) {
|
|
|
33
34
|
return getAppRouteStaticGenerationErrorMessage(options.routePattern, expression);
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
|
-
const response = await
|
|
37
|
+
const response = await runWithRootParamsUsage({
|
|
38
|
+
kind: "route-handler",
|
|
39
|
+
routePattern: options.routePattern ?? new URL(options.request.url).pathname
|
|
40
|
+
}, () => options.handlerFn(trackedRequest.request, { params: options.params }));
|
|
37
41
|
return {
|
|
38
42
|
dynamicUsedInHandler: options.consumeDynamicUsage(),
|
|
39
43
|
response
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { addBasePathToPathname } from "../utils/base-path.js";
|
|
2
|
-
import { buildRequestHeadersFromMiddlewareResponse } from "
|
|
2
|
+
import { buildRequestHeadersFromMiddlewareResponse } from "../utils/middleware-request-headers.js";
|
|
3
3
|
import { NextRequest, RequestCookies, sealRequestCookies, sealRequestHeaders } from "../shims/server.js";
|
|
4
4
|
//#region src/server/app-route-handler-runtime.ts
|
|
5
5
|
const ROUTE_HANDLER_HTTP_METHODS = [
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import "./server-globals.js";
|
|
2
2
|
import { runWithExecutionContext } from "../shims/request-context.js";
|
|
3
|
-
import { VINEXT_PRERENDER_ROUTE_PARAMS_HEADER } from "
|
|
3
|
+
import { VINEXT_PRERENDER_ROUTE_PARAMS_HEADER } from "../utils/protocol-headers.js";
|
|
4
4
|
import { badRequestResponse, notFoundResponse, notFoundStaticAssetResponse } from "./http-error-responses.js";
|
|
5
5
|
import { isOpenRedirectShaped } from "./open-redirect.js";
|
|
6
6
|
import { cloneRequestWithHeaders, filterInternalHeaders } from "./request-pipeline.js";
|
|
7
|
+
import { getImageOptimizer, handleConfiguredImageOptimization, isImageOptimizationPath } from "./image-optimization.js";
|
|
7
8
|
import { assetPrefixPathname, isNextStaticPath } from "../utils/asset-prefix.js";
|
|
8
9
|
import { finalizeMissingStaticAssetResponse, resolveStaticAssetSignal } from "./worker-utils.js";
|
|
9
10
|
import { readTrustedPrerenderRouteParams, serializePrerenderRouteParamsHeader } from "./prerender-route-params.js";
|
|
10
|
-
import rscHandler, { __assetPrefix, __basePath } from "virtual:vinext-rsc-entry";
|
|
11
|
+
import rscHandler, { __assetPrefix, __basePath, __imageAllowedWidths, __imageConfig } from "virtual:vinext-rsc-entry";
|
|
11
12
|
import { registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
|
|
13
|
+
import { registerConfiguredImageOptimizer } from "virtual:vinext-image-adapters";
|
|
12
14
|
//#region src/server/app-router-entry.ts
|
|
13
15
|
const __workerBasePath = typeof __basePath === "string" ? __basePath : "";
|
|
14
16
|
const __workerAssetPathPrefix = assetPrefixPathname(typeof __assetPrefix === "string" ? __assetPrefix : "");
|
|
@@ -17,7 +19,12 @@ var app_router_entry_default = { async fetch(request, env, ctx) {
|
|
|
17
19
|
} };
|
|
18
20
|
async function handleRequest(request, env, ctx) {
|
|
19
21
|
registerConfiguredCacheAdapters(env);
|
|
22
|
+
registerConfiguredImageOptimizer(env);
|
|
20
23
|
const url = new URL(request.url);
|
|
24
|
+
if (isImageOptimizationPath(url.pathname) && env?.ASSETS && getImageOptimizer()) {
|
|
25
|
+
const assetFetcher = env.ASSETS;
|
|
26
|
+
return handleConfiguredImageOptimization(request, (assetPath) => Promise.resolve(assetFetcher.fetch(new Request(new URL(assetPath, request.url)))), __imageAllowedWidths, __imageConfig);
|
|
27
|
+
}
|
|
21
28
|
if (isOpenRedirectShaped(url.pathname)) return notFoundResponse();
|
|
22
29
|
try {
|
|
23
30
|
decodeURIComponent(url.pathname);
|