vinext 0.1.8 → 0.2.1
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/css-url-assets.d.ts +3 -1
- package/dist/build/css-url-assets.js +18 -1
- package/dist/build/inject-pregenerated-paths.d.ts +7 -0
- package/dist/build/inject-pregenerated-paths.js +21 -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-server-entry.d.ts +1 -0
- package/dist/build/prerender-server-entry.js +49 -0
- package/dist/build/prerender-server-pool.d.ts +44 -0
- package/dist/build/prerender-server-pool.js +194 -0
- package/dist/build/prerender.d.ts +2 -1
- package/dist/build/prerender.js +98 -27
- 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 +12 -2
- package/dist/build/standalone.js +2 -0
- package/dist/cache/cache-adapters-virtual.js +3 -3
- package/dist/check.d.ts +4 -6
- package/dist/check.js +48 -11
- 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 +112 -96
- 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/vinext-next-data.d.ts +4 -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 +45 -19
- package/dist/config/next-config.d.ts +41 -9
- package/dist/config/next-config.js +60 -3
- package/dist/config/prerender.d.ts +34 -0
- package/dist/config/prerender.js +55 -0
- package/dist/entries/app-browser-entry.js +5 -1
- package/dist/entries/app-rsc-entry.d.ts +5 -3
- package/dist/entries/app-rsc-entry.js +44 -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 +28 -3
- package/dist/entries/pages-server-entry.js +23 -6
- 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 +482 -120
- 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 +9 -2
- 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 +272 -0
- package/dist/{cloudflare → packages/cloudflare/src}/tpr.d.ts +4 -41
- package/dist/{cloudflare → packages/cloudflare/src}/tpr.js +44 -20
- 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/fonts.js +1 -1
- package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
- package/dist/plugins/ignore-dynamic-requests.js +530 -0
- package/dist/plugins/og-assets.js +2 -1
- package/dist/plugins/optimize-imports.js +1 -1
- package/dist/plugins/rsc-reference-validation-normalizer.d.ts +12 -0
- package/dist/plugins/rsc-reference-validation-normalizer.js +48 -0
- package/dist/plugins/sass.d.ts +17 -1
- package/dist/plugins/sass.js +74 -1
- package/dist/plugins/styled-jsx.d.ts +16 -0
- package/dist/plugins/styled-jsx.js +149 -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 +138 -38
- package/dist/routing/file-matcher.d.ts +11 -1
- package/dist/routing/file-matcher.js +18 -3
- 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 +198 -57
- 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 +8 -7
- package/dist/server/app-browser-state.d.ts +12 -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 +42 -24
- 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-boundary.js +2 -1
- package/dist/server/app-page-cache-finalizer.d.ts +1 -0
- package/dist/server/app-page-cache-finalizer.js +5 -4
- 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 +27 -7
- package/dist/server/app-page-dispatch.d.ts +1 -0
- package/dist/server/app-page-dispatch.js +26 -8
- package/dist/server/app-page-element-builder.d.ts +2 -1
- package/dist/server/app-page-element-builder.js +59 -4
- package/dist/server/app-page-execution.js +2 -1
- package/dist/server/app-page-probe.js +5 -0
- package/dist/server/app-page-render-identity.d.ts +2 -0
- package/dist/server/app-page-render-identity.js +3 -2
- package/dist/server/app-page-render.d.ts +2 -0
- package/dist/server/app-page-render.js +85 -16
- package/dist/server/app-page-request.d.ts +14 -0
- package/dist/server/app-page-request.js +69 -4
- package/dist/server/app-page-response.d.ts +7 -0
- package/dist/server/app-page-response.js +16 -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 +7 -1
- 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-route-tree-prefetch.d.ts +43 -0
- package/dist/server/app-route-tree-prefetch.js +187 -0
- package/dist/server/app-router-entry.js +9 -2
- package/dist/server/app-rsc-cache-busting.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.js +9 -4
- package/dist/server/app-rsc-handler.d.ts +7 -0
- package/dist/server/app-rsc-handler.js +148 -39
- package/dist/server/app-rsc-render-mode.d.ts +3 -2
- package/dist/server/app-rsc-render-mode.js +4 -1
- package/dist/server/app-rsc-request-normalization.d.ts +6 -6
- package/dist/server/app-rsc-request-normalization.js +10 -8
- 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 +61 -30
- package/dist/server/app-ssr-entry.d.ts +3 -0
- package/dist/server/app-ssr-entry.js +13 -5
- 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/cache-control.d.ts +3 -1
- package/dist/server/cache-control.js +13 -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.d.ts +11 -1
- package/dist/server/dev-server.js +94 -35
- 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 +7 -15
- package/dist/server/headers.js +11 -18
- 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 +3 -2
- package/dist/server/isr-cache.js +9 -5
- 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-data-route.d.ts +4 -2
- package/dist/server/pages-data-route.js +18 -4
- package/dist/server/pages-dev-module-url.d.ts +2 -1
- package/dist/server/pages-dev-module-url.js +6 -3
- package/dist/server/pages-node-compat.d.ts +19 -1
- package/dist/server/pages-node-compat.js +81 -4
- package/dist/server/pages-page-data.d.ts +33 -1
- package/dist/server/pages-page-data.js +62 -33
- package/dist/server/pages-page-handler.d.ts +2 -1
- package/dist/server/pages-page-handler.js +38 -19
- package/dist/server/pages-page-response.d.ts +8 -0
- package/dist/server/pages-page-response.js +7 -3
- package/dist/server/pages-request-pipeline.d.ts +9 -5
- package/dist/server/pages-request-pipeline.js +55 -7
- 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 +5 -3
- package/dist/server/prod-server.js +68 -39
- package/dist/server/request-pipeline.js +2 -1
- 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-handler.js +8 -1
- package/dist/shims/cache.js +22 -15
- package/dist/shims/cdn-cache.js +1 -1
- package/dist/shims/dynamic-preload-chunks.js +2 -1
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +77 -52
- package/dist/shims/form.d.ts +4 -2
- 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-prefetch-fetch-queue.d.ts +10 -0
- package/dist/shims/internal/app-prefetch-fetch-queue.js +61 -0
- 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 +3 -15
- package/dist/shims/internal/hybrid-client-route-owner.js +40 -58
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +10 -5
- package/dist/shims/internal/pages-data-fetch-dedup.js +84 -14
- package/dist/shims/internal/pages-data-target.d.ts +18 -12
- package/dist/shims/internal/pages-data-target.js +97 -13
- 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.d.ts +1 -1
- package/dist/shims/link.js +224 -58
- package/dist/shims/navigation.d.ts +19 -3
- package/dist/shims/navigation.js +245 -47
- package/dist/shims/request-context.js +18 -0
- 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 +387 -102
- package/dist/shims/server.js +3 -2
- package/dist/shims/slot.js +3 -6
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/typegen.js +1 -1
- 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 +3 -3
- package/dist/utils/project.d.ts +48 -2
- package/dist/utils/project.js +225 -4
- package/dist/utils/protocol-headers.d.ts +23 -0
- package/dist/utils/protocol-headers.js +23 -0
- package/dist/utils/react-version.d.ts +4 -0
- package/dist/utils/react-version.js +44 -0
- package/dist/utils/vite-version.d.ts +2 -0
- package/dist/utils/vite-version.js +11 -1
- 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
|
@@ -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
|
}
|
|
@@ -15,6 +15,10 @@ type AppPageResponsePolicy = {
|
|
|
15
15
|
cacheControl?: string;
|
|
16
16
|
cacheState?: "MISS" | "STATIC";
|
|
17
17
|
};
|
|
18
|
+
type AppPagePrerenderCacheLife = {
|
|
19
|
+
expire?: number;
|
|
20
|
+
revalidate?: number;
|
|
21
|
+
};
|
|
18
22
|
type ResolveAppPageResponsePolicyBaseOptions = {
|
|
19
23
|
isDraftMode: boolean;
|
|
20
24
|
isDynamicError: boolean;
|
|
@@ -42,6 +46,8 @@ type BuildAppPageRscResponseOptions = {
|
|
|
42
46
|
mountedSlotsHeader?: string | null;
|
|
43
47
|
params?: Record<string, unknown>;
|
|
44
48
|
policy: AppPageResponsePolicy;
|
|
49
|
+
renderedPathAndSearch?: string | null;
|
|
50
|
+
requestCacheLife?: AppPagePrerenderCacheLife | null;
|
|
45
51
|
timing?: AppPageResponseTiming;
|
|
46
52
|
};
|
|
47
53
|
type BuildAppPageHtmlResponseOptions = {
|
|
@@ -50,6 +56,7 @@ type BuildAppPageHtmlResponseOptions = {
|
|
|
50
56
|
isEdgeRuntime?: boolean;
|
|
51
57
|
middlewareContext: AppPageMiddlewareContext;
|
|
52
58
|
policy: AppPageResponsePolicy;
|
|
59
|
+
requestCacheLife?: AppPagePrerenderCacheLife | null;
|
|
53
60
|
timing?: AppPageResponseTiming;
|
|
54
61
|
};
|
|
55
62
|
declare function resolveAppPageRscResponsePolicy(options: ResolveAppPageRscResponsePolicyOptions): AppPageResponsePolicy;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_PARAMS_HEADER, VINEXT_TIMING_HEADER } from "./headers.js";
|
|
1
|
+
import { VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_PARAMS_HEADER, VINEXT_PRERENDER_CACHE_LIFE_HEADER, VINEXT_RENDERED_PATH_AND_SEARCH_HEADER, VINEXT_TIMING_HEADER } from "./headers.js";
|
|
2
2
|
import { setCacheStateHeaders } from "./cache-headers.js";
|
|
3
3
|
import { NO_STORE_CACHE_CONTROL, STATIC_CACHE_CONTROL, buildRevalidateCacheControl } from "./cache-control.js";
|
|
4
|
-
import { VINEXT_RSC_CONTENT_TYPE, VINEXT_RSC_VARY_HEADER, applyRscCompatibilityIdHeader } from "./app-rsc-cache-busting.js";
|
|
4
|
+
import { VINEXT_RSC_CONTENT_TYPE, VINEXT_RSC_VARY_HEADER, applyRscCompatibilityIdHeader, applyRscDeploymentIdHeader } from "./app-rsc-cache-busting.js";
|
|
5
5
|
import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
|
|
6
6
|
//#region src/server/app-page-response.ts
|
|
7
7
|
function applyTimingHeader(headers, timing) {
|
|
@@ -14,6 +14,14 @@ function applyTimingHeader(headers, timing) {
|
|
|
14
14
|
function applyDynamicStaleTimeHeader(headers, dynamicStaleTimeSeconds) {
|
|
15
15
|
if (dynamicStaleTimeSeconds !== void 0 && Number.isInteger(dynamicStaleTimeSeconds) && dynamicStaleTimeSeconds >= 0) headers.set(VINEXT_DYNAMIC_STALE_TIME_HEADER, String(dynamicStaleTimeSeconds));
|
|
16
16
|
}
|
|
17
|
+
function applyPrerenderCacheLifeHeader(headers, requestCacheLife) {
|
|
18
|
+
if (!requestCacheLife) return;
|
|
19
|
+
const payload = {};
|
|
20
|
+
if (typeof requestCacheLife.revalidate === "number" && Number.isFinite(requestCacheLife.revalidate)) payload.revalidate = requestCacheLife.revalidate;
|
|
21
|
+
if (typeof requestCacheLife.expire === "number" && Number.isFinite(requestCacheLife.expire)) payload.expire = requestCacheLife.expire;
|
|
22
|
+
if (payload.revalidate === void 0 && payload.expire === void 0) return;
|
|
23
|
+
headers.set(VINEXT_PRERENDER_CACHE_LIFE_HEADER, JSON.stringify(payload));
|
|
24
|
+
}
|
|
17
25
|
function resolveAppPageRscResponsePolicy(options) {
|
|
18
26
|
if (options.isDraftMode) return { cacheControl: NO_STORE_CACHE_CONTROL };
|
|
19
27
|
if (options.isForceDynamic || options.dynamicUsedDuringBuild) return { cacheControl: NO_STORE_CACHE_CONTROL };
|
|
@@ -51,8 +59,8 @@ function resolveAppPageHtmlResponsePolicy(options) {
|
|
|
51
59
|
};
|
|
52
60
|
if ((options.isForceStatic || options.isDynamicError) && options.revalidateSeconds === null) return {
|
|
53
61
|
cacheControl: STATIC_CACHE_CONTROL,
|
|
54
|
-
cacheState: "STATIC",
|
|
55
|
-
shouldWriteToCache:
|
|
62
|
+
cacheState: options.isProduction ? "MISS" : "STATIC",
|
|
63
|
+
shouldWriteToCache: options.isProduction
|
|
56
64
|
};
|
|
57
65
|
if (options.dynamicUsedDuringRender) return {
|
|
58
66
|
cacheControl: NO_STORE_CACHE_CONTROL,
|
|
@@ -92,7 +100,10 @@ function buildAppPageRscResponse(body, options) {
|
|
|
92
100
|
if (options.policy.cacheControl) headers.set("Cache-Control", options.policy.cacheControl);
|
|
93
101
|
if (options.policy.cacheState) setCacheStateHeaders(headers, options.policy.cacheState);
|
|
94
102
|
mergeMiddlewareResponseHeaders(headers, options.middlewareContext.headers);
|
|
103
|
+
if (options.renderedPathAndSearch) headers.set(VINEXT_RENDERED_PATH_AND_SEARCH_HEADER, encodeURIComponent(options.renderedPathAndSearch));
|
|
95
104
|
applyRscCompatibilityIdHeader(headers);
|
|
105
|
+
applyRscDeploymentIdHeader(headers);
|
|
106
|
+
applyPrerenderCacheLifeHeader(headers, options.requestCacheLife);
|
|
96
107
|
applyTimingHeader(headers, options.timing);
|
|
97
108
|
return new Response(body, {
|
|
98
109
|
status: options.middlewareContext.status ?? 200,
|
|
@@ -110,6 +121,7 @@ function buildAppPageHtmlResponse(body, options) {
|
|
|
110
121
|
if (options.draftCookie) headers.append("Set-Cookie", options.draftCookie);
|
|
111
122
|
if (options.linkHeader) headers.set("Link", options.linkHeader);
|
|
112
123
|
mergeMiddlewareResponseHeaders(headers, options.middlewareContext.headers);
|
|
124
|
+
applyPrerenderCacheLifeHeader(headers, options.requestCacheLife);
|
|
113
125
|
applyTimingHeader(headers, options.timing);
|
|
114
126
|
return new Response(body, {
|
|
115
127
|
status: options.middlewareContext.status ?? 200,
|
|
@@ -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;
|
|
@@ -102,7 +107,8 @@ type RenderAppPageHtmlStreamOptions = {
|
|
|
102
107
|
value: Promise<ArrayBuffer> | null;
|
|
103
108
|
}; /** Abort signal for a build-time PPR fallback-shell static render. */
|
|
104
109
|
pprFallbackShellSignal?: AbortSignal; /** When true, wait for the full React tree before emitting bytes. */
|
|
105
|
-
waitForAllReady?: boolean; /**
|
|
110
|
+
waitForAllReady?: boolean; /** Override the default shell-error recovery decision passed to handleSsr. */
|
|
111
|
+
fallbackToErrorDocumentOnShellError?: boolean; /** Dev-only: original server error to surface in the browser overlay. */
|
|
106
112
|
initialDevServerError?: unknown;
|
|
107
113
|
/** True when the app supplies a custom global-error.tsx. Disables the
|
|
108
114
|
* default error-document shell fallback so SSR shell errors keep driving
|
|
@@ -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.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,4 +1,5 @@
|
|
|
1
1
|
import { isDraftModeRequest, setHeadersContext } from "../shims/headers.js";
|
|
2
|
+
import { runWithRootParamsUsage } from "../shims/root-params.js";
|
|
2
3
|
import { isPossibleAppRouteActionRequest } from "./app-action-request.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";
|
|
@@ -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 = [
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/server/app-route-tree-prefetch.d.ts
|
|
2
|
+
type DynamicParamTypeShort = "d" | "c" | "oc";
|
|
3
|
+
type TreePrefetchParam = {
|
|
4
|
+
type: DynamicParamTypeShort;
|
|
5
|
+
key: null;
|
|
6
|
+
siblings: readonly string[] | null;
|
|
7
|
+
};
|
|
8
|
+
type AppRouteTreePrefetchSlot = {
|
|
9
|
+
configLayouts?: readonly unknown[] | null;
|
|
10
|
+
configLayoutTreePositions?: readonly number[] | null;
|
|
11
|
+
default?: unknown;
|
|
12
|
+
layout?: unknown;
|
|
13
|
+
layoutIndex?: number;
|
|
14
|
+
name: string;
|
|
15
|
+
page?: unknown;
|
|
16
|
+
routeSegments?: readonly string[] | null;
|
|
17
|
+
};
|
|
18
|
+
type AppRouteTreePrefetchRoute = {
|
|
19
|
+
layoutTreePositions?: readonly number[];
|
|
20
|
+
layouts?: readonly unknown[];
|
|
21
|
+
page?: unknown;
|
|
22
|
+
routeSegments: readonly string[];
|
|
23
|
+
slots?: Readonly<Record<string, AppRouteTreePrefetchSlot>> | null;
|
|
24
|
+
};
|
|
25
|
+
type TreePrefetch = {
|
|
26
|
+
name: string;
|
|
27
|
+
param: TreePrefetchParam | null;
|
|
28
|
+
prefetchHints: number;
|
|
29
|
+
slots: null | Record<string, TreePrefetch>;
|
|
30
|
+
};
|
|
31
|
+
type RouteTreePrefetchResponseOptions = {
|
|
32
|
+
buildId?: string | null;
|
|
33
|
+
deploymentId?: string;
|
|
34
|
+
prefetchInlining?: PrefetchInliningConfig;
|
|
35
|
+
};
|
|
36
|
+
type PrefetchInliningConfig = false | {
|
|
37
|
+
maxBundleSize: number;
|
|
38
|
+
maxSize: number;
|
|
39
|
+
};
|
|
40
|
+
declare function isRouteTreePrefetchRequest(request: Request): boolean;
|
|
41
|
+
declare function createRouteTreePrefetchResponse(route: AppRouteTreePrefetchRoute, options?: RouteTreePrefetchResponseOptions): Promise<Response>;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { AppRouteTreePrefetchRoute, PrefetchInliningConfig, TreePrefetch, createRouteTreePrefetchResponse, isRouteTreePrefetchRequest };
|