vinext 0.0.53 → 0.0.55
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 +1 -0
- package/dist/build/inline-css.d.ts +7 -0
- package/dist/build/inline-css.js +50 -0
- package/dist/build/inline-css.js.map +1 -0
- package/dist/build/prerender.js +2 -1
- package/dist/build/prerender.js.map +1 -1
- package/dist/check.js +19 -3
- package/dist/check.js.map +1 -1
- package/dist/client/navigation-runtime.d.ts +3 -1
- package/dist/client/navigation-runtime.js +1 -1
- package/dist/client/navigation-runtime.js.map +1 -1
- package/dist/client/window-next.d.ts +7 -0
- package/dist/client/window-next.js.map +1 -1
- package/dist/config/next-config.d.ts +97 -2
- package/dist/config/next-config.js +155 -6
- package/dist/config/next-config.js.map +1 -1
- package/dist/config/tsconfig-paths.d.ts +12 -3
- package/dist/config/tsconfig-paths.js +55 -24
- package/dist/config/tsconfig-paths.js.map +1 -1
- package/dist/deploy.js +13 -0
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +11 -1
- package/dist/entries/app-browser-entry.js +16 -6
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +9 -1
- package/dist/entries/app-rsc-entry.js +30 -5
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +21 -1
- package/dist/entries/app-rsc-manifest.js +28 -9
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/pages-client-entry.d.ts +4 -1
- package/dist/entries/pages-client-entry.js +18 -2
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +123 -8
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.d.ts +1 -10
- package/dist/entries/runtime-entry-module.js +2 -12
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +144 -44
- package/dist/index.js.map +1 -1
- package/dist/plugins/import-meta-url.d.ts +16 -0
- package/dist/plugins/import-meta-url.js +193 -0
- package/dist/plugins/import-meta-url.js.map +1 -0
- package/dist/plugins/remove-console.d.ts +16 -0
- package/dist/plugins/remove-console.js +176 -0
- package/dist/plugins/remove-console.js.map +1 -0
- package/dist/routing/app-route-graph.d.ts +24 -1
- package/dist/routing/app-route-graph.js +52 -4
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/app-router.d.ts +2 -2
- package/dist/routing/app-router.js +2 -2
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/file-matcher.d.ts +21 -1
- package/dist/routing/file-matcher.js +39 -1
- package/dist/routing/file-matcher.js.map +1 -1
- package/dist/routing/pages-router.d.ts +1 -1
- package/dist/routing/pages-router.js +10 -3
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/server/api-handler.js +1 -1
- package/dist/server/app-browser-action-result.d.ts +9 -16
- package/dist/server/app-browser-action-result.js +25 -14
- package/dist/server/app-browser-action-result.js.map +1 -1
- package/dist/server/app-browser-entry.js +195 -60
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-mpa-navigation.d.ts +16 -0
- package/dist/server/app-browser-mpa-navigation.js +36 -0
- package/dist/server/app-browser-mpa-navigation.js.map +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +2 -0
- package/dist/server/app-browser-navigation-controller.js +4 -0
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-popstate.d.ts +3 -1
- package/dist/server/app-browser-popstate.js +15 -1
- package/dist/server/app-browser-popstate.js.map +1 -1
- package/dist/server/app-browser-state.js +2 -1
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +13 -4
- package/dist/server/app-elements-wire.js +10 -1
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.d.ts +15 -5
- package/dist/server/app-fallback-renderer.js +10 -4
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-inline-css-client.d.ts +7 -0
- package/dist/server/app-inline-css-client.js +37 -0
- package/dist/server/app-inline-css-client.js.map +1 -0
- package/dist/server/app-layout-param-observation.d.ts +30 -0
- package/dist/server/app-layout-param-observation.js +130 -0
- package/dist/server/app-layout-param-observation.js.map +1 -0
- package/dist/server/app-page-boundary-render.js +2 -2
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.d.ts +21 -1
- package/dist/server/app-page-boundary.js +28 -3
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +7 -3
- package/dist/server/app-page-cache.js +7 -7
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +10 -1
- package/dist/server/app-page-dispatch.js +126 -79
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.js +12 -28
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-params.d.ts +2 -1
- package/dist/server/app-page-params.js +14 -1
- package/dist/server/app-page-params.js.map +1 -1
- package/dist/server/app-page-probe.d.ts +12 -1
- package/dist/server/app-page-probe.js +116 -1
- package/dist/server/app-page-probe.js.map +1 -1
- package/dist/server/app-page-render-identity.d.ts +22 -0
- package/dist/server/app-page-render-identity.js +42 -0
- package/dist/server/app-page-render-identity.js.map +1 -0
- package/dist/server/app-page-render.d.ts +8 -1
- package/dist/server/app-page-render.js +4 -1
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +6 -3
- package/dist/server/app-page-request.js +5 -2
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.js +2 -2
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +15 -0
- package/dist/server/app-page-route-wiring.js +7 -5
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +11 -0
- package/dist/server/app-page-stream.js +1 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-route-handler-response.js +37 -5
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +3 -2
- package/dist/server/app-rsc-cache-busting.js +9 -7
- package/dist/server/app-rsc-cache-busting.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +14 -3
- package/dist/server/app-rsc-handler.js +56 -6
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.d.ts +2 -1
- package/dist/server/app-rsc-request-normalization.js +3 -2
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-segment-config.d.ts +1 -1
- package/dist/server/app-segment-config.js +4 -1
- package/dist/server/app-segment-config.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +26 -3
- package/dist/server/app-server-action-execution.js +240 -29
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +6 -0
- package/dist/server/app-ssr-entry.js +22 -7
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-error-meta.js +3 -3
- package/dist/server/app-ssr-error-meta.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +2 -1
- package/dist/server/app-ssr-stream.js +176 -31
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/artifact-compatibility.d.ts +2 -1
- package/dist/server/artifact-compatibility.js +10 -1
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/client-reuse-manifest.d.ts +9 -4
- package/dist/server/client-reuse-manifest.js +2 -1
- package/dist/server/client-reuse-manifest.js.map +1 -1
- package/dist/server/client-trace-metadata.d.ts +31 -0
- package/dist/server/client-trace-metadata.js +83 -0
- package/dist/server/client-trace-metadata.js.map +1 -0
- package/dist/server/cookie-utils.d.ts +13 -0
- package/dist/server/cookie-utils.js +20 -0
- package/dist/server/cookie-utils.js.map +1 -0
- package/dist/server/dev-server.d.ts +8 -1
- package/dist/server/dev-server.js +83 -12
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/document-initial-head.d.ts +7 -0
- package/dist/server/document-initial-head.js +35 -0
- package/dist/server/document-initial-head.js.map +1 -0
- package/dist/server/html.d.ts +2 -1
- package/dist/server/html.js +6 -1
- package/dist/server/html.js.map +1 -1
- package/dist/server/isr-cache.d.ts +7 -5
- package/dist/server/isr-cache.js +17 -6
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/middleware-runtime.js +1 -2
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/pages-document-initial-props.d.ts +89 -0
- package/dist/server/pages-document-initial-props.js +140 -0
- package/dist/server/pages-document-initial-props.js.map +1 -0
- package/dist/server/pages-node-compat.js +1 -1
- package/dist/server/pages-page-data.js +3 -0
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-method.d.ts +48 -0
- package/dist/server/pages-page-method.js +19 -0
- package/dist/server/pages-page-method.js.map +1 -0
- package/dist/server/pages-page-response.d.ts +20 -0
- package/dist/server/pages-page-response.js +37 -7
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/pages-serializable-props.d.ts +25 -0
- package/dist/server/pages-serializable-props.js +69 -0
- package/dist/server/pages-serializable-props.js.map +1 -0
- package/dist/server/prod-server.js +16 -6
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/server-action-not-found.js +3 -2
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/skip-cache-proof.d.ts +23 -2
- package/dist/server/skip-cache-proof.js +81 -12
- package/dist/server/skip-cache-proof.js.map +1 -1
- package/dist/server/static-file-cache.js +2 -1
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/server/static-layout-client-reuse-proof.d.ts +16 -0
- package/dist/server/static-layout-client-reuse-proof.js +35 -0
- package/dist/server/static-layout-client-reuse-proof.js.map +1 -0
- package/dist/shims/app-router-scroll-state.d.ts +4 -2
- package/dist/shims/app-router-scroll-state.js +16 -3
- package/dist/shims/app-router-scroll-state.js.map +1 -1
- package/dist/shims/app-router-scroll.d.ts +16 -2
- package/dist/shims/app-router-scroll.js +18 -3
- package/dist/shims/app-router-scroll.js.map +1 -1
- package/dist/shims/cache.d.ts +27 -1
- package/dist/shims/cache.js +108 -6
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/document.d.ts +6 -0
- package/dist/shims/document.js +7 -8
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +4 -4
- package/dist/shims/error-boundary.js +27 -28
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.js +3 -0
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +16 -5
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/hash-scroll.d.ts +4 -1
- package/dist/shims/hash-scroll.js +13 -1
- package/dist/shims/hash-scroll.js.map +1 -1
- package/dist/shims/head-state.d.ts +1 -0
- package/dist/shims/head-state.js +18 -3
- package/dist/shims/head-state.js.map +1 -1
- package/dist/shims/head.d.ts +35 -1
- package/dist/shims/head.js +113 -14
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +7 -0
- package/dist/shims/headers.js +9 -1
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/internal/app-route-detection.d.ts +37 -0
- package/dist/shims/internal/app-route-detection.js +69 -0
- package/dist/shims/internal/app-route-detection.js.map +1 -0
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +56 -0
- package/dist/shims/internal/pages-data-fetch-dedup.js +70 -0
- package/dist/shims/internal/pages-data-fetch-dedup.js.map +1 -0
- package/dist/shims/link.d.ts +18 -2
- package/dist/shims/link.js +98 -8
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +7 -6
- package/dist/shims/metadata.js +9 -5
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +40 -3
- package/dist/shims/navigation.js +124 -25
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/router.d.ts +5 -0
- package/dist/shims/router.js +51 -21
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.d.ts +11 -1
- package/dist/shims/script.js +75 -6
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/thenable-params.d.ts +5 -2
- package/dist/shims/thenable-params.js +25 -1
- package/dist/shims/thenable-params.js.map +1 -1
- package/dist/shims/unified-request-context.js +3 -0
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/utils/client-build-manifest.d.ts +15 -0
- package/dist/utils/client-build-manifest.js +54 -0
- package/dist/utils/client-build-manifest.js.map +1 -0
- package/dist/utils/hash.js +1 -1
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/lazy-chunks.d.ts +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/dist/utils/path.d.ts +13 -0
- package/dist/utils/path.js +16 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/vite-version.d.ts +11 -0
- package/dist/utils/vite-version.js +36 -0
- package/dist/utils/vite-version.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APP_ARTIFACT_COMPATIBILITY_KEY, APP_CACHE_ENTRY_REUSE_PROOF_KEY, APP_INTERCEPTION_CONTEXT_KEY, APP_INTERCEPTION_KEY, APP_LAYOUT_FLAGS_KEY, APP_LAYOUT_IDS_KEY, APP_RENDER_OBSERVATION_KEY, APP_ROOT_LAYOUT_KEY, APP_ROUTE_KEY, APP_SLOT_BINDINGS_KEY, APP_UNMATCHED_SLOT_WIRE_VALUE, AppElementValue, AppElements, AppElementsInterception, AppElementsSlotBinding, AppElementsWire, AppOutgoingElements, AppWireElements, LayoutFlags, UNMATCHED_SLOT, buildOutgoingAppPayload, compareAppElementsSlotIds, isAppElementsRecord, normalizeAppElements, normalizeAppElementsSlotBindings, readAppElementsMetadata, withLayoutFlags } from "./app-elements-wire.js";
|
|
1
|
+
import { APP_ARTIFACT_COMPATIBILITY_KEY, APP_CACHE_ENTRY_REUSE_PROOF_KEY, APP_INTERCEPTION_CONTEXT_KEY, APP_INTERCEPTION_KEY, APP_LAYOUT_FLAGS_KEY, APP_LAYOUT_IDS_KEY, APP_RENDER_OBSERVATION_KEY, APP_ROOT_LAYOUT_KEY, APP_ROUTE_KEY, APP_SLOT_BINDINGS_KEY, APP_STATIC_SIBLINGS_KEY, APP_UNMATCHED_SLOT_WIRE_VALUE, AppElementValue, AppElements, AppElementsInterception, AppElementsSlotBinding, AppElementsWire, AppOutgoingElements, AppWireElements, LayoutFlags, UNMATCHED_SLOT, buildOutgoingAppPayload, compareAppElementsSlotIds, isAppElementsRecord, normalizeAppElements, normalizeAppElementsSlotBindings, readAppElementsMetadata, withLayoutFlags } from "./app-elements-wire.js";
|
|
2
2
|
|
|
3
3
|
//#region src/server/app-elements.d.ts
|
|
4
4
|
declare const APP_PREFETCH_LOADING_SHELL_MARKER_KEY = "__prefetchLoadingShell";
|
|
@@ -6,5 +6,5 @@ declare function getMountedSlotIds(elements: AppElements): string[];
|
|
|
6
6
|
declare function getMountedSlotIdsHeader(elements: AppElements): string | null;
|
|
7
7
|
declare function resolveVisitedResponseInterceptionContext(requestInterceptionContext: string | null, payloadInterceptionContext: string | null): string | null;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { APP_ARTIFACT_COMPATIBILITY_KEY, APP_CACHE_ENTRY_REUSE_PROOF_KEY, APP_INTERCEPTION_CONTEXT_KEY, APP_INTERCEPTION_KEY, APP_LAYOUT_FLAGS_KEY, APP_LAYOUT_IDS_KEY, APP_PREFETCH_LOADING_SHELL_MARKER_KEY, APP_RENDER_OBSERVATION_KEY, APP_ROOT_LAYOUT_KEY, APP_ROUTE_KEY, APP_SLOT_BINDINGS_KEY, APP_UNMATCHED_SLOT_WIRE_VALUE, type AppElementValue, type AppElements, type AppElementsInterception, type AppElementsSlotBinding, AppElementsWire, type AppOutgoingElements, type AppWireElements, type LayoutFlags, UNMATCHED_SLOT, buildOutgoingAppPayload, compareAppElementsSlotIds, getMountedSlotIds, getMountedSlotIdsHeader, isAppElementsRecord, normalizeAppElements, normalizeAppElementsSlotBindings, readAppElementsMetadata, resolveVisitedResponseInterceptionContext, withLayoutFlags };
|
|
9
|
+
export { APP_ARTIFACT_COMPATIBILITY_KEY, APP_CACHE_ENTRY_REUSE_PROOF_KEY, APP_INTERCEPTION_CONTEXT_KEY, APP_INTERCEPTION_KEY, APP_LAYOUT_FLAGS_KEY, APP_LAYOUT_IDS_KEY, APP_PREFETCH_LOADING_SHELL_MARKER_KEY, APP_RENDER_OBSERVATION_KEY, APP_ROOT_LAYOUT_KEY, APP_ROUTE_KEY, APP_SLOT_BINDINGS_KEY, APP_STATIC_SIBLINGS_KEY, APP_UNMATCHED_SLOT_WIRE_VALUE, type AppElementValue, type AppElements, type AppElementsInterception, type AppElementsSlotBinding, AppElementsWire, type AppOutgoingElements, type AppWireElements, type LayoutFlags, UNMATCHED_SLOT, buildOutgoingAppPayload, compareAppElementsSlotIds, getMountedSlotIds, getMountedSlotIdsHeader, isAppElementsRecord, normalizeAppElements, normalizeAppElementsSlotBindings, readAppElementsMetadata, resolveVisitedResponseInterceptionContext, withLayoutFlags };
|
|
10
10
|
//# sourceMappingURL=app-elements.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APP_ARTIFACT_COMPATIBILITY_KEY, APP_CACHE_ENTRY_REUSE_PROOF_KEY, APP_INTERCEPTION_CONTEXT_KEY, APP_INTERCEPTION_KEY, APP_LAYOUT_FLAGS_KEY, APP_LAYOUT_IDS_KEY, APP_RENDER_OBSERVATION_KEY, APP_ROOT_LAYOUT_KEY, APP_ROUTE_KEY, APP_SLOT_BINDINGS_KEY, APP_UNMATCHED_SLOT_WIRE_VALUE, AppElementsWire, UNMATCHED_SLOT, buildOutgoingAppPayload, compareAppElementsSlotIds, isAppElementsRecord, normalizeAppElements, normalizeAppElementsSlotBindings, readAppElementsMetadata, withLayoutFlags } from "./app-elements-wire.js";
|
|
1
|
+
import { APP_ARTIFACT_COMPATIBILITY_KEY, APP_CACHE_ENTRY_REUSE_PROOF_KEY, APP_INTERCEPTION_CONTEXT_KEY, APP_INTERCEPTION_KEY, APP_LAYOUT_FLAGS_KEY, APP_LAYOUT_IDS_KEY, APP_RENDER_OBSERVATION_KEY, APP_ROOT_LAYOUT_KEY, APP_ROUTE_KEY, APP_SLOT_BINDINGS_KEY, APP_STATIC_SIBLINGS_KEY, APP_UNMATCHED_SLOT_WIRE_VALUE, AppElementsWire, UNMATCHED_SLOT, buildOutgoingAppPayload, compareAppElementsSlotIds, isAppElementsRecord, normalizeAppElements, normalizeAppElementsSlotBindings, readAppElementsMetadata, withLayoutFlags } from "./app-elements-wire.js";
|
|
2
2
|
import { normalizeMountedSlotsHeader } from "./app-mounted-slots-header.js";
|
|
3
3
|
//#region src/server/app-elements.ts
|
|
4
4
|
const APP_PREFETCH_LOADING_SHELL_MARKER_KEY = "__prefetchLoadingShell";
|
|
@@ -15,6 +15,6 @@ function resolveVisitedResponseInterceptionContext(requestInterceptionContext, p
|
|
|
15
15
|
return payloadInterceptionContext ?? requestInterceptionContext;
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
18
|
-
export { APP_ARTIFACT_COMPATIBILITY_KEY, APP_CACHE_ENTRY_REUSE_PROOF_KEY, APP_INTERCEPTION_CONTEXT_KEY, APP_INTERCEPTION_KEY, APP_LAYOUT_FLAGS_KEY, APP_LAYOUT_IDS_KEY, APP_PREFETCH_LOADING_SHELL_MARKER_KEY, APP_RENDER_OBSERVATION_KEY, APP_ROOT_LAYOUT_KEY, APP_ROUTE_KEY, APP_SLOT_BINDINGS_KEY, APP_UNMATCHED_SLOT_WIRE_VALUE, AppElementsWire, UNMATCHED_SLOT, buildOutgoingAppPayload, compareAppElementsSlotIds, getMountedSlotIds, getMountedSlotIdsHeader, isAppElementsRecord, normalizeAppElements, normalizeAppElementsSlotBindings, readAppElementsMetadata, resolveVisitedResponseInterceptionContext, withLayoutFlags };
|
|
18
|
+
export { APP_ARTIFACT_COMPATIBILITY_KEY, APP_CACHE_ENTRY_REUSE_PROOF_KEY, APP_INTERCEPTION_CONTEXT_KEY, APP_INTERCEPTION_KEY, APP_LAYOUT_FLAGS_KEY, APP_LAYOUT_IDS_KEY, APP_PREFETCH_LOADING_SHELL_MARKER_KEY, APP_RENDER_OBSERVATION_KEY, APP_ROOT_LAYOUT_KEY, APP_ROUTE_KEY, APP_SLOT_BINDINGS_KEY, APP_STATIC_SIBLINGS_KEY, APP_UNMATCHED_SLOT_WIRE_VALUE, AppElementsWire, UNMATCHED_SLOT, buildOutgoingAppPayload, compareAppElementsSlotIds, getMountedSlotIds, getMountedSlotIdsHeader, isAppElementsRecord, normalizeAppElements, normalizeAppElementsSlotBindings, readAppElementsMetadata, resolveVisitedResponseInterceptionContext, withLayoutFlags };
|
|
19
19
|
|
|
20
20
|
//# sourceMappingURL=app-elements.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-elements.js","names":[],"sources":["../../src/server/app-elements.ts"],"sourcesContent":["import { normalizeMountedSlotsHeader } from \"./app-mounted-slots-header.js\";\nimport { AppElementsWire, UNMATCHED_SLOT, type AppElements } from \"./app-elements-wire.js\";\n\nexport const APP_PREFETCH_LOADING_SHELL_MARKER_KEY = \"__prefetchLoadingShell\";\n\nexport {\n AppElementsWire,\n APP_ARTIFACT_COMPATIBILITY_KEY,\n APP_CACHE_ENTRY_REUSE_PROOF_KEY,\n APP_INTERCEPTION_KEY,\n APP_INTERCEPTION_CONTEXT_KEY,\n APP_LAYOUT_IDS_KEY,\n APP_LAYOUT_FLAGS_KEY,\n APP_RENDER_OBSERVATION_KEY,\n APP_ROOT_LAYOUT_KEY,\n APP_ROUTE_KEY,\n APP_SLOT_BINDINGS_KEY,\n APP_UNMATCHED_SLOT_WIRE_VALUE,\n UNMATCHED_SLOT,\n buildOutgoingAppPayload,\n compareAppElementsSlotIds,\n isAppElementsRecord,\n normalizeAppElementsSlotBindings,\n normalizeAppElements,\n readAppElementsMetadata,\n withLayoutFlags,\n type AppElementValue,\n type AppElementsInterception,\n type AppElementsSlotBinding,\n type AppElements,\n type AppOutgoingElements,\n type AppWireElements,\n type LayoutFlags,\n} from \"./app-elements-wire.js\";\n\n// Raw constructor helpers stay private because callers use AppElementsWire codecs.\n\nexport function getMountedSlotIds(elements: AppElements): string[] {\n return Object.keys(elements)\n .filter((key) => {\n const value = elements[key];\n return (\n AppElementsWire.isSlotId(key) &&\n value !== null &&\n value !== undefined &&\n value !== UNMATCHED_SLOT\n );\n })\n .sort();\n}\n\nexport function getMountedSlotIdsHeader(elements: AppElements): string | null {\n return normalizeMountedSlotsHeader(getMountedSlotIds(elements).join(\" \"));\n}\n\nexport function resolveVisitedResponseInterceptionContext(\n requestInterceptionContext: string | null,\n payloadInterceptionContext: string | null,\n): string | null {\n return payloadInterceptionContext ?? requestInterceptionContext;\n}\n"],"mappings":";;;AAGA,MAAa,wCAAwC;
|
|
1
|
+
{"version":3,"file":"app-elements.js","names":[],"sources":["../../src/server/app-elements.ts"],"sourcesContent":["import { normalizeMountedSlotsHeader } from \"./app-mounted-slots-header.js\";\nimport { AppElementsWire, UNMATCHED_SLOT, type AppElements } from \"./app-elements-wire.js\";\n\nexport const APP_PREFETCH_LOADING_SHELL_MARKER_KEY = \"__prefetchLoadingShell\";\n\nexport {\n AppElementsWire,\n APP_ARTIFACT_COMPATIBILITY_KEY,\n APP_CACHE_ENTRY_REUSE_PROOF_KEY,\n APP_INTERCEPTION_KEY,\n APP_INTERCEPTION_CONTEXT_KEY,\n APP_LAYOUT_IDS_KEY,\n APP_LAYOUT_FLAGS_KEY,\n APP_RENDER_OBSERVATION_KEY,\n APP_ROOT_LAYOUT_KEY,\n APP_ROUTE_KEY,\n APP_SLOT_BINDINGS_KEY,\n APP_STATIC_SIBLINGS_KEY,\n APP_UNMATCHED_SLOT_WIRE_VALUE,\n UNMATCHED_SLOT,\n buildOutgoingAppPayload,\n compareAppElementsSlotIds,\n isAppElementsRecord,\n normalizeAppElementsSlotBindings,\n normalizeAppElements,\n readAppElementsMetadata,\n withLayoutFlags,\n type AppElementValue,\n type AppElementsInterception,\n type AppElementsSlotBinding,\n type AppElements,\n type AppOutgoingElements,\n type AppWireElements,\n type LayoutFlags,\n} from \"./app-elements-wire.js\";\n\n// Raw constructor helpers stay private because callers use AppElementsWire codecs.\n\nexport function getMountedSlotIds(elements: AppElements): string[] {\n return Object.keys(elements)\n .filter((key) => {\n const value = elements[key];\n return (\n AppElementsWire.isSlotId(key) &&\n value !== null &&\n value !== undefined &&\n value !== UNMATCHED_SLOT\n );\n })\n .sort();\n}\n\nexport function getMountedSlotIdsHeader(elements: AppElements): string | null {\n return normalizeMountedSlotsHeader(getMountedSlotIds(elements).join(\" \"));\n}\n\nexport function resolveVisitedResponseInterceptionContext(\n requestInterceptionContext: string | null,\n payloadInterceptionContext: string | null,\n): string | null {\n return payloadInterceptionContext ?? requestInterceptionContext;\n}\n"],"mappings":";;;AAGA,MAAa,wCAAwC;AAmCrD,SAAgB,kBAAkB,UAAiC;CACjE,OAAO,OAAO,KAAK,SAAS,CACzB,QAAQ,QAAQ;EACf,MAAM,QAAQ,SAAS;EACvB,OACE,gBAAgB,SAAS,IAAI,IAC7B,UAAU,QACV,UAAU,KAAA,KACV,UAAU;GAEZ,CACD,MAAM;;AAGX,SAAgB,wBAAwB,UAAsC;CAC5E,OAAO,4BAA4B,kBAAkB,SAAS,CAAC,KAAK,IAAI,CAAC;;AAG3E,SAAgB,0CACd,4BACA,4BACe;CACf,OAAO,8BAA8B"}
|
|
@@ -33,13 +33,23 @@ type AppFallbackRendererOptions<TModule extends AppPageModule = AppPageModule> =
|
|
|
33
33
|
getNavigationContext: () => unknown;
|
|
34
34
|
globalErrorModule?: TModule | null;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* render this module as a standalone document (skipping the
|
|
38
|
-
* because it ships its own `<html>` and `<body>`. Page-triggered
|
|
39
|
-
* calls continue to use the regular `not-found.tsx` boundary
|
|
36
|
+
* Loader for the user's `app/global-not-found.tsx` module. When provided,
|
|
37
|
+
* route-miss 404s render this module as a standalone document (skipping the
|
|
38
|
+
* root layout) because it ships its own `<html>` and `<body>`. Page-triggered
|
|
39
|
+
* `notFound()` calls continue to use the regular `not-found.tsx` boundary
|
|
40
|
+
* inside layouts.
|
|
41
|
+
*
|
|
42
|
+
* Passed as a deferred loader (rather than the resolved module) so the
|
|
43
|
+
* generated RSC entry can use `() => import(...)` for chunk isolation.
|
|
44
|
+
* Without that isolation, the bundler co-locates global-not-found's CSS
|
|
45
|
+
* with the root layout's CSS in a single chunk and the CSS minifier
|
|
46
|
+
* (lightningcss) drops overlapping declarations as dead code — breaking
|
|
47
|
+
* the cascade for route-miss 404s where only global-not-found is rendered.
|
|
48
|
+
*
|
|
40
49
|
* @see https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx
|
|
50
|
+
* @see Next.js test: test/e2e/app-dir/initial-css-order/initial-css-order.test.ts
|
|
41
51
|
*/
|
|
42
|
-
|
|
52
|
+
loadGlobalNotFoundModule?: (() => Promise<TModule | null | undefined>) | null;
|
|
43
53
|
makeThenableParams: (params: AppPageParams) => unknown;
|
|
44
54
|
metadataRoutes: MetadataFileRoute[]; /** Configured next.config `basePath`, threaded into file-based metadata href emission. */
|
|
45
55
|
basePath?: string;
|
|
@@ -7,14 +7,20 @@ const EMPTY_MW_CTX = {
|
|
|
7
7
|
status: null
|
|
8
8
|
};
|
|
9
9
|
function createAppFallbackRenderer(options) {
|
|
10
|
-
const { basePath = "", clearRequestContext, createRscOnErrorHandler: buildRscOnErrorHandler, fontProviders, getNavigationContext, globalErrorModule,
|
|
10
|
+
const { basePath = "", clearRequestContext, createRscOnErrorHandler: buildRscOnErrorHandler, fontProviders, getNavigationContext, globalErrorModule, loadGlobalNotFoundModule, makeThenableParams, metadataRoutes, resolveChildSegments, rootBoundaries, rscRenderer, sanitizer, ssrLoader } = options;
|
|
11
11
|
const { rootForbiddenModule, rootLayouts, rootNotFoundModule, rootUnauthorizedModule } = rootBoundaries;
|
|
12
12
|
const effectiveGlobalErrorModule = globalErrorModule ?? DEFAULT_GLOBAL_ERROR_MODULE;
|
|
13
13
|
const effectiveRootNotFoundModule = rootNotFoundModule ?? DEFAULT_NOT_FOUND_MODULE;
|
|
14
|
+
let globalNotFoundModulePromise = null;
|
|
15
|
+
function resolveGlobalNotFoundModule() {
|
|
16
|
+
if (!loadGlobalNotFoundModule) return null;
|
|
17
|
+
if (globalNotFoundModulePromise === null) globalNotFoundModulePromise = Promise.resolve().then(loadGlobalNotFoundModule);
|
|
18
|
+
return globalNotFoundModulePromise;
|
|
19
|
+
}
|
|
14
20
|
return {
|
|
15
|
-
renderHttpAccessFallback(route, statusCode, isRscRequest, request, opts, scriptNonce, middlewareContext, callContext) {
|
|
16
|
-
if (statusCode === 404 && !!
|
|
17
|
-
const globalNotFoundComponent =
|
|
21
|
+
async renderHttpAccessFallback(route, statusCode, isRscRequest, request, opts, scriptNonce, middlewareContext, callContext) {
|
|
22
|
+
if (statusCode === 404 && !!loadGlobalNotFoundModule && !route && !opts?.boundaryComponent) {
|
|
23
|
+
const globalNotFoundComponent = (await resolveGlobalNotFoundModule())?.default ?? null;
|
|
18
24
|
if (globalNotFoundComponent) return renderAppPageHttpAccessFallback({
|
|
19
25
|
boundaryComponent: globalNotFoundComponent,
|
|
20
26
|
buildFontLinkHeader: fontProviders.buildFontLinkHeader,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-fallback-renderer.js","names":[],"sources":["../../src/server/app-fallback-renderer.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { AppPageParams } from \"./app-page-boundary.js\";\nimport {\n renderAppPageErrorBoundary,\n renderAppPageHttpAccessFallback,\n type AppPageBoundaryRoute,\n} from \"./app-page-boundary-render.js\";\nimport { DEFAULT_GLOBAL_ERROR_MODULE } from \"./default-global-error-module.js\";\nimport { DEFAULT_NOT_FOUND_MODULE } from \"./default-not-found-module.js\";\nimport type { AppPageFontPreload } from \"./app-page-execution.js\";\nimport type { AppPageMiddlewareContext } from \"./app-page-response.js\";\nimport type { AppPageSsrHandler } from \"./app-page-stream.js\";\nimport type { MetadataFileRoute } from \"./metadata-routes.js\";\nimport type { AppElements } from \"./app-elements.js\";\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype AppPageComponent = import(\"react\").ComponentType<any>;\ntype AppPageModule = Record<string, unknown> & {\n default?: AppPageComponent | null | undefined;\n};\ntype AppPageBoundaryOnError = (\n error: unknown,\n requestInfo: unknown,\n errorContext: unknown,\n) => unknown;\n\ntype AppFallbackRendererRootBoundaries<TModule extends AppPageModule = AppPageModule> = {\n rootForbiddenModule?: TModule | null;\n rootLayouts: readonly (TModule | null | undefined)[];\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n};\n\ntype AppFallbackRendererFontProviders = {\n buildFontLinkHeader: (preloads: readonly AppPageFontPreload[] | null | undefined) => string;\n getFontLinks: () => string[];\n getFontPreloads: () => AppPageFontPreload[];\n getFontStyles: () => string[];\n};\n\ntype AppFallbackRendererOptions<TModule extends AppPageModule = AppPageModule> = {\n clearRequestContext: () => void;\n createRscOnErrorHandler: (\n request: Request,\n pathname: string,\n routePath: string,\n ) => AppPageBoundaryOnError;\n fontProviders: AppFallbackRendererFontProviders;\n getNavigationContext: () => unknown;\n globalErrorModule?: TModule | null;\n /**\n * Optional `app/global-not-found.tsx` module. When provided, route-miss 404s\n * render this module as a standalone document (skipping the root layout)\n * because it ships its own `<html>` and `<body>`. Page-triggered `notFound()`\n * calls continue to use the regular `not-found.tsx` boundary inside layouts.\n * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx\n */\n globalNotFoundModule?: TModule | null;\n makeThenableParams: (params: AppPageParams) => unknown;\n metadataRoutes: MetadataFileRoute[];\n /** Configured next.config `basePath`, threaded into file-based metadata href emission. */\n basePath?: string;\n resolveChildSegments: (\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n ) => string[];\n rootBoundaries: AppFallbackRendererRootBoundaries<TModule>;\n rscRenderer: (\n element: ReactNode | AppElements,\n options: { onError: AppPageBoundaryOnError },\n ) => ReadableStream<Uint8Array>;\n sanitizer: (error: Error) => Error;\n ssrLoader: () => Promise<AppPageSsrHandler>;\n};\n\ntype AppFallbackRendererCallContext = {\n /**\n * Whether the matched (or invoking) route opts into Next.js' edge runtime via\n * `export const runtime = \"edge\"`. Propagated so boundary/error/not-found\n * responses carry `x-edge-runtime: 1` for edge routes, matching the page\n * render path. Defaults to `false` when no route is matched.\n */\n isEdgeRuntime?: boolean;\n};\n\ntype AppFallbackRenderer<TModule extends AppPageModule = AppPageModule> = {\n renderErrorBoundary: (\n route: AppPageBoundaryRoute<TModule> | null,\n error: unknown,\n isRscRequest: boolean,\n request: Request,\n matchedParams: AppPageParams | undefined,\n scriptNonce: string | undefined,\n middlewareContext: AppPageMiddlewareContext,\n callContext?: AppFallbackRendererCallContext,\n ) => Promise<Response | null>;\n renderHttpAccessFallback: (\n route: AppPageBoundaryRoute<TModule> | null,\n statusCode: number,\n isRscRequest: boolean,\n request: Request,\n opts: {\n boundaryComponent?: AppPageComponent | null;\n layouts?: readonly (TModule | null | undefined)[] | null;\n matchedParams?: AppPageParams;\n },\n scriptNonce: string | undefined,\n middlewareContext: AppPageMiddlewareContext,\n callContext?: AppFallbackRendererCallContext,\n ) => Promise<Response | null>;\n renderNotFound: (\n route: AppPageBoundaryRoute<TModule> | null,\n isRscRequest: boolean,\n request: Request,\n matchedParams: AppPageParams | undefined,\n scriptNonce: string | undefined,\n middlewareContext: AppPageMiddlewareContext,\n callContext?: AppFallbackRendererCallContext,\n ) => Promise<Response | null>;\n};\n\nconst EMPTY_MW_CTX: AppPageMiddlewareContext = { headers: null, status: null };\n\nexport function createAppFallbackRenderer<TModule extends AppPageModule>(\n options: AppFallbackRendererOptions<TModule>,\n): AppFallbackRenderer<TModule> {\n const {\n basePath = \"\",\n clearRequestContext,\n createRscOnErrorHandler: buildRscOnErrorHandler,\n fontProviders,\n getNavigationContext,\n globalErrorModule,\n globalNotFoundModule,\n makeThenableParams,\n metadataRoutes,\n resolveChildSegments,\n rootBoundaries,\n rscRenderer,\n sanitizer,\n ssrLoader,\n } = options;\n\n const { rootForbiddenModule, rootLayouts, rootNotFoundModule, rootUnauthorizedModule } =\n rootBoundaries;\n\n // When the app does not define `app/global-error.tsx`, fall back to vinext's\n // built-in default global error component so that uncaught render errors\n // produce the same UI Next.js ships out of the box (matching markup, inline\n // styles, theme CSS, and the \"ERROR <digest>\" footer for server errors).\n // See packages/vinext/src/shims/default-global-error.tsx and\n // packages/vinext/src/server/default-global-error-module.ts.\n const effectiveGlobalErrorModule: TModule | null =\n globalErrorModule ?? (DEFAULT_GLOBAL_ERROR_MODULE as unknown as TModule);\n\n // When the app does not define `app/not-found.tsx` (and has not opted into\n // `app/global-not-found.tsx`), fall back to vinext's built-in default\n // not-found component so route-miss 404s render the canonical Next.js\n // markup (status + \"This page could not be found.\" message). Matches the\n // default not-found UI shipped with Next.js's app loader.\n // See packages/vinext/src/shims/default-not-found.tsx and\n // packages/vinext/src/server/default-not-found-module.ts.\n const effectiveRootNotFoundModule: TModule | null =\n rootNotFoundModule ?? (DEFAULT_NOT_FOUND_MODULE as unknown as TModule);\n\n return {\n renderHttpAccessFallback(\n route,\n statusCode,\n isRscRequest,\n request,\n opts,\n scriptNonce,\n middlewareContext,\n callContext,\n ) {\n // global-not-found.tsx replaces the root layout for route-miss 404s.\n // Only applies when:\n // - The user defined app/global-not-found.tsx\n // - The 404 originates from a route miss (no matched route)\n // - The caller did not already pick a specific boundary component\n // Page-triggered notFound() calls (route is non-null) keep using the\n // regular not-found.tsx boundary inside the route's layouts.\n // See https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx#L495-L520\n const useGlobalNotFound =\n statusCode === 404 && !!globalNotFoundModule && !route && !opts?.boundaryComponent;\n\n if (useGlobalNotFound) {\n const globalNotFoundComponent = globalNotFoundModule?.default ?? null;\n if (globalNotFoundComponent) {\n return renderAppPageHttpAccessFallback({\n boundaryComponent: globalNotFoundComponent,\n buildFontLinkHeader: fontProviders.buildFontLinkHeader,\n clearRequestContext,\n createRscOnErrorHandler(pathname, routePath) {\n return buildRscOnErrorHandler(request, pathname, routePath);\n },\n getFontLinks: fontProviders.getFontLinks,\n getFontPreloads: fontProviders.getFontPreloads,\n getFontStyles: fontProviders.getFontStyles,\n getNavigationContext,\n globalErrorModule: effectiveGlobalErrorModule,\n isEdgeRuntime: callContext?.isEdgeRuntime,\n isRscRequest,\n layoutModules: [],\n loadSsrHandler: ssrLoader,\n makeThenableParams,\n matchedParams: opts?.matchedParams ?? {},\n middlewareContext: middlewareContext ?? EMPTY_MW_CTX,\n metadataRoutes,\n requestUrl: request.url,\n resolveChildSegments,\n rootForbiddenModule: null,\n rootLayouts: [],\n rootNotFoundModule: null,\n rootUnauthorizedModule: null,\n route: null,\n renderToReadableStream: rscRenderer,\n scriptNonce,\n skipLayoutWrapping: true,\n statusCode,\n });\n }\n }\n\n return renderAppPageHttpAccessFallback({\n basePath,\n boundaryComponent: opts?.boundaryComponent ?? null,\n buildFontLinkHeader: fontProviders.buildFontLinkHeader,\n clearRequestContext,\n createRscOnErrorHandler(pathname, routePath) {\n return buildRscOnErrorHandler(request, pathname, routePath);\n },\n getFontLinks: fontProviders.getFontLinks,\n getFontPreloads: fontProviders.getFontPreloads,\n getFontStyles: fontProviders.getFontStyles,\n getNavigationContext,\n globalErrorModule: effectiveGlobalErrorModule,\n isEdgeRuntime: callContext?.isEdgeRuntime,\n isRscRequest,\n layoutModules: opts?.layouts ?? null,\n loadSsrHandler: ssrLoader,\n makeThenableParams,\n matchedParams: opts?.matchedParams ?? route?.params ?? {},\n middlewareContext: middlewareContext ?? EMPTY_MW_CTX,\n metadataRoutes,\n requestUrl: request.url,\n resolveChildSegments,\n rootForbiddenModule,\n rootLayouts,\n rootNotFoundModule: effectiveRootNotFoundModule,\n rootUnauthorizedModule,\n route,\n renderToReadableStream: rscRenderer,\n scriptNonce,\n statusCode,\n });\n },\n\n renderNotFound(\n route,\n isRscRequest,\n request,\n matchedParams,\n scriptNonce,\n middlewareContext,\n callContext,\n ) {\n return this.renderHttpAccessFallback(\n route,\n 404,\n isRscRequest,\n request,\n { matchedParams },\n scriptNonce,\n middlewareContext,\n callContext,\n );\n },\n\n renderErrorBoundary(\n route,\n error,\n isRscRequest,\n request,\n matchedParams,\n scriptNonce,\n middlewareContext,\n callContext,\n ) {\n return renderAppPageErrorBoundary({\n basePath,\n buildFontLinkHeader: fontProviders.buildFontLinkHeader,\n clearRequestContext,\n createRscOnErrorHandler(pathname, routePath) {\n return buildRscOnErrorHandler(request, pathname, routePath);\n },\n error,\n getFontLinks: fontProviders.getFontLinks,\n getFontPreloads: fontProviders.getFontPreloads,\n getFontStyles: fontProviders.getFontStyles,\n getNavigationContext,\n globalErrorModule: effectiveGlobalErrorModule,\n isEdgeRuntime: callContext?.isEdgeRuntime,\n isRscRequest,\n loadSsrHandler: ssrLoader,\n makeThenableParams,\n matchedParams: matchedParams ?? route?.params ?? {},\n middlewareContext: middlewareContext ?? EMPTY_MW_CTX,\n metadataRoutes,\n requestUrl: request.url,\n resolveChildSegments,\n rootLayouts,\n route,\n renderToReadableStream: rscRenderer,\n sanitizeErrorForClient: sanitizer,\n scriptNonce,\n });\n },\n };\n}\n"],"mappings":";;;;AA0HA,MAAM,eAAyC;CAAE,SAAS;CAAM,QAAQ;CAAM;AAE9E,SAAgB,0BACd,SAC8B;CAC9B,MAAM,EACJ,WAAW,IACX,qBACA,yBAAyB,wBACzB,eACA,sBACA,mBACA,sBACA,oBACA,gBACA,sBACA,gBACA,aACA,WACA,cACE;CAEJ,MAAM,EAAE,qBAAqB,aAAa,oBAAoB,2BAC5D;CAQF,MAAM,6BACJ,qBAAsB;CASxB,MAAM,8BACJ,sBAAuB;CAEzB,OAAO;EACL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;;EAGH,oBACE,OACA,OACA,cACA,SACA,eACA,aACA,mBACA,aACA;GACA,OAAO,2BAA2B;IAChC;IACA,qBAAqB,cAAc;IACnC;IACA,wBAAwB,UAAU,WAAW;KAC3C,OAAO,uBAAuB,SAAS,UAAU,UAAU;;IAE7D;IACA,cAAc,cAAc;IAC5B,iBAAiB,cAAc;IAC/B,eAAe,cAAc;IAC7B;IACA,mBAAmB;IACnB,eAAe,aAAa;IAC5B;IACA,gBAAgB;IAChB;IACA,eAAe,iBAAiB,OAAO,UAAU,EAAE;IACnD,mBAAmB,qBAAqB;IACxC;IACA,YAAY,QAAQ;IACpB;IACA;IACA;IACA,wBAAwB;IACxB,wBAAwB;IACxB;IACD,CAAC;;EAEL"}
|
|
1
|
+
{"version":3,"file":"app-fallback-renderer.js","names":[],"sources":["../../src/server/app-fallback-renderer.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { AppPageParams } from \"./app-page-boundary.js\";\nimport {\n renderAppPageErrorBoundary,\n renderAppPageHttpAccessFallback,\n type AppPageBoundaryRoute,\n} from \"./app-page-boundary-render.js\";\nimport { DEFAULT_GLOBAL_ERROR_MODULE } from \"./default-global-error-module.js\";\nimport { DEFAULT_NOT_FOUND_MODULE } from \"./default-not-found-module.js\";\nimport type { AppPageFontPreload } from \"./app-page-execution.js\";\nimport type { AppPageMiddlewareContext } from \"./app-page-response.js\";\nimport type { AppPageSsrHandler } from \"./app-page-stream.js\";\nimport type { MetadataFileRoute } from \"./metadata-routes.js\";\nimport type { AppElements } from \"./app-elements.js\";\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype AppPageComponent = import(\"react\").ComponentType<any>;\ntype AppPageModule = Record<string, unknown> & {\n default?: AppPageComponent | null | undefined;\n};\ntype AppPageBoundaryOnError = (\n error: unknown,\n requestInfo: unknown,\n errorContext: unknown,\n) => unknown;\n\ntype AppFallbackRendererRootBoundaries<TModule extends AppPageModule = AppPageModule> = {\n rootForbiddenModule?: TModule | null;\n rootLayouts: readonly (TModule | null | undefined)[];\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n};\n\ntype AppFallbackRendererFontProviders = {\n buildFontLinkHeader: (preloads: readonly AppPageFontPreload[] | null | undefined) => string;\n getFontLinks: () => string[];\n getFontPreloads: () => AppPageFontPreload[];\n getFontStyles: () => string[];\n};\n\ntype AppFallbackRendererOptions<TModule extends AppPageModule = AppPageModule> = {\n clearRequestContext: () => void;\n createRscOnErrorHandler: (\n request: Request,\n pathname: string,\n routePath: string,\n ) => AppPageBoundaryOnError;\n fontProviders: AppFallbackRendererFontProviders;\n getNavigationContext: () => unknown;\n globalErrorModule?: TModule | null;\n /**\n * Loader for the user's `app/global-not-found.tsx` module. When provided,\n * route-miss 404s render this module as a standalone document (skipping the\n * root layout) because it ships its own `<html>` and `<body>`. Page-triggered\n * `notFound()` calls continue to use the regular `not-found.tsx` boundary\n * inside layouts.\n *\n * Passed as a deferred loader (rather than the resolved module) so the\n * generated RSC entry can use `() => import(...)` for chunk isolation.\n * Without that isolation, the bundler co-locates global-not-found's CSS\n * with the root layout's CSS in a single chunk and the CSS minifier\n * (lightningcss) drops overlapping declarations as dead code — breaking\n * the cascade for route-miss 404s where only global-not-found is rendered.\n *\n * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx\n * @see Next.js test: test/e2e/app-dir/initial-css-order/initial-css-order.test.ts\n */\n loadGlobalNotFoundModule?: (() => Promise<TModule | null | undefined>) | null;\n makeThenableParams: (params: AppPageParams) => unknown;\n metadataRoutes: MetadataFileRoute[];\n /** Configured next.config `basePath`, threaded into file-based metadata href emission. */\n basePath?: string;\n resolveChildSegments: (\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n ) => string[];\n rootBoundaries: AppFallbackRendererRootBoundaries<TModule>;\n rscRenderer: (\n element: ReactNode | AppElements,\n options: { onError: AppPageBoundaryOnError },\n ) => ReadableStream<Uint8Array>;\n sanitizer: (error: Error) => Error;\n ssrLoader: () => Promise<AppPageSsrHandler>;\n};\n\ntype AppFallbackRendererCallContext = {\n /**\n * Whether the matched (or invoking) route opts into Next.js' edge runtime via\n * `export const runtime = \"edge\"`. Propagated so boundary/error/not-found\n * responses carry `x-edge-runtime: 1` for edge routes, matching the page\n * render path. Defaults to `false` when no route is matched.\n */\n isEdgeRuntime?: boolean;\n};\n\ntype AppFallbackRenderer<TModule extends AppPageModule = AppPageModule> = {\n renderErrorBoundary: (\n route: AppPageBoundaryRoute<TModule> | null,\n error: unknown,\n isRscRequest: boolean,\n request: Request,\n matchedParams: AppPageParams | undefined,\n scriptNonce: string | undefined,\n middlewareContext: AppPageMiddlewareContext,\n callContext?: AppFallbackRendererCallContext,\n ) => Promise<Response | null>;\n renderHttpAccessFallback: (\n route: AppPageBoundaryRoute<TModule> | null,\n statusCode: number,\n isRscRequest: boolean,\n request: Request,\n opts: {\n boundaryComponent?: AppPageComponent | null;\n layouts?: readonly (TModule | null | undefined)[] | null;\n matchedParams?: AppPageParams;\n },\n scriptNonce: string | undefined,\n middlewareContext: AppPageMiddlewareContext,\n callContext?: AppFallbackRendererCallContext,\n ) => Promise<Response | null>;\n renderNotFound: (\n route: AppPageBoundaryRoute<TModule> | null,\n isRscRequest: boolean,\n request: Request,\n matchedParams: AppPageParams | undefined,\n scriptNonce: string | undefined,\n middlewareContext: AppPageMiddlewareContext,\n callContext?: AppFallbackRendererCallContext,\n ) => Promise<Response | null>;\n};\n\nconst EMPTY_MW_CTX: AppPageMiddlewareContext = { headers: null, status: null };\n\nexport function createAppFallbackRenderer<TModule extends AppPageModule>(\n options: AppFallbackRendererOptions<TModule>,\n): AppFallbackRenderer<TModule> {\n const {\n basePath = \"\",\n clearRequestContext,\n createRscOnErrorHandler: buildRscOnErrorHandler,\n fontProviders,\n getNavigationContext,\n globalErrorModule,\n loadGlobalNotFoundModule,\n makeThenableParams,\n metadataRoutes,\n resolveChildSegments,\n rootBoundaries,\n rscRenderer,\n sanitizer,\n ssrLoader,\n } = options;\n\n const { rootForbiddenModule, rootLayouts, rootNotFoundModule, rootUnauthorizedModule } =\n rootBoundaries;\n\n // When the app does not define `app/global-error.tsx`, fall back to vinext's\n // built-in default global error component so that uncaught render errors\n // produce the same UI Next.js ships out of the box (matching markup, inline\n // styles, theme CSS, and the \"ERROR <digest>\" footer for server errors).\n // See packages/vinext/src/shims/default-global-error.tsx and\n // packages/vinext/src/server/default-global-error-module.ts.\n const effectiveGlobalErrorModule: TModule | null =\n globalErrorModule ?? (DEFAULT_GLOBAL_ERROR_MODULE as unknown as TModule);\n\n // When the app does not define `app/not-found.tsx` (and has not opted into\n // `app/global-not-found.tsx`), fall back to vinext's built-in default\n // not-found component so route-miss 404s render the canonical Next.js\n // markup (status + \"This page could not be found.\" message). Matches the\n // default not-found UI shipped with Next.js's app loader.\n // See packages/vinext/src/shims/default-not-found.tsx and\n // packages/vinext/src/server/default-not-found-module.ts.\n const effectiveRootNotFoundModule: TModule | null =\n rootNotFoundModule ?? (DEFAULT_NOT_FOUND_MODULE as unknown as TModule);\n\n // Cache the result of `loadGlobalNotFoundModule()` so subsequent route-miss\n // 404s in the same worker hit a warm import instead of re-resolving the\n // dynamic chunk. The loader itself is invoked at most once per worker;\n // failures are surfaced on every call so they don't get swallowed.\n let globalNotFoundModulePromise: Promise<TModule | null | undefined> | null = null;\n function resolveGlobalNotFoundModule(): Promise<TModule | null | undefined> | null {\n if (!loadGlobalNotFoundModule) return null;\n if (globalNotFoundModulePromise === null) {\n globalNotFoundModulePromise = Promise.resolve().then(loadGlobalNotFoundModule);\n }\n return globalNotFoundModulePromise;\n }\n\n return {\n async renderHttpAccessFallback(\n route,\n statusCode,\n isRscRequest,\n request,\n opts,\n scriptNonce,\n middlewareContext,\n callContext,\n ) {\n // global-not-found.tsx replaces the root layout for route-miss 404s.\n // Only applies when:\n // - The user defined app/global-not-found.tsx\n // - The 404 originates from a route miss (no matched route)\n // - The caller did not already pick a specific boundary component\n // Page-triggered notFound() calls (route is non-null) keep using the\n // regular not-found.tsx boundary inside the route's layouts.\n // See https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx#L495-L520\n const useGlobalNotFound =\n statusCode === 404 && !!loadGlobalNotFoundModule && !route && !opts?.boundaryComponent;\n\n if (useGlobalNotFound) {\n const globalNotFoundModule = await resolveGlobalNotFoundModule();\n const globalNotFoundComponent = globalNotFoundModule?.default ?? null;\n if (globalNotFoundComponent) {\n return renderAppPageHttpAccessFallback({\n boundaryComponent: globalNotFoundComponent,\n buildFontLinkHeader: fontProviders.buildFontLinkHeader,\n clearRequestContext,\n createRscOnErrorHandler(pathname, routePath) {\n return buildRscOnErrorHandler(request, pathname, routePath);\n },\n getFontLinks: fontProviders.getFontLinks,\n getFontPreloads: fontProviders.getFontPreloads,\n getFontStyles: fontProviders.getFontStyles,\n getNavigationContext,\n globalErrorModule: effectiveGlobalErrorModule,\n isEdgeRuntime: callContext?.isEdgeRuntime,\n isRscRequest,\n layoutModules: [],\n loadSsrHandler: ssrLoader,\n makeThenableParams,\n matchedParams: opts?.matchedParams ?? {},\n middlewareContext: middlewareContext ?? EMPTY_MW_CTX,\n metadataRoutes,\n requestUrl: request.url,\n resolveChildSegments,\n rootForbiddenModule: null,\n rootLayouts: [],\n rootNotFoundModule: null,\n rootUnauthorizedModule: null,\n route: null,\n renderToReadableStream: rscRenderer,\n scriptNonce,\n skipLayoutWrapping: true,\n statusCode,\n });\n }\n }\n\n return renderAppPageHttpAccessFallback({\n basePath,\n boundaryComponent: opts?.boundaryComponent ?? null,\n buildFontLinkHeader: fontProviders.buildFontLinkHeader,\n clearRequestContext,\n createRscOnErrorHandler(pathname, routePath) {\n return buildRscOnErrorHandler(request, pathname, routePath);\n },\n getFontLinks: fontProviders.getFontLinks,\n getFontPreloads: fontProviders.getFontPreloads,\n getFontStyles: fontProviders.getFontStyles,\n getNavigationContext,\n globalErrorModule: effectiveGlobalErrorModule,\n isEdgeRuntime: callContext?.isEdgeRuntime,\n isRscRequest,\n layoutModules: opts?.layouts ?? null,\n loadSsrHandler: ssrLoader,\n makeThenableParams,\n matchedParams: opts?.matchedParams ?? route?.params ?? {},\n middlewareContext: middlewareContext ?? EMPTY_MW_CTX,\n metadataRoutes,\n requestUrl: request.url,\n resolveChildSegments,\n rootForbiddenModule,\n rootLayouts,\n rootNotFoundModule: effectiveRootNotFoundModule,\n rootUnauthorizedModule,\n route,\n renderToReadableStream: rscRenderer,\n scriptNonce,\n statusCode,\n });\n },\n\n renderNotFound(\n route,\n isRscRequest,\n request,\n matchedParams,\n scriptNonce,\n middlewareContext,\n callContext,\n ) {\n return this.renderHttpAccessFallback(\n route,\n 404,\n isRscRequest,\n request,\n { matchedParams },\n scriptNonce,\n middlewareContext,\n callContext,\n );\n },\n\n renderErrorBoundary(\n route,\n error,\n isRscRequest,\n request,\n matchedParams,\n scriptNonce,\n middlewareContext,\n callContext,\n ) {\n return renderAppPageErrorBoundary({\n basePath,\n buildFontLinkHeader: fontProviders.buildFontLinkHeader,\n clearRequestContext,\n createRscOnErrorHandler(pathname, routePath) {\n return buildRscOnErrorHandler(request, pathname, routePath);\n },\n error,\n getFontLinks: fontProviders.getFontLinks,\n getFontPreloads: fontProviders.getFontPreloads,\n getFontStyles: fontProviders.getFontStyles,\n getNavigationContext,\n globalErrorModule: effectiveGlobalErrorModule,\n isEdgeRuntime: callContext?.isEdgeRuntime,\n isRscRequest,\n loadSsrHandler: ssrLoader,\n makeThenableParams,\n matchedParams: matchedParams ?? route?.params ?? {},\n middlewareContext: middlewareContext ?? EMPTY_MW_CTX,\n metadataRoutes,\n requestUrl: request.url,\n resolveChildSegments,\n rootLayouts,\n route,\n renderToReadableStream: rscRenderer,\n sanitizeErrorForClient: sanitizer,\n scriptNonce,\n });\n },\n };\n}\n"],"mappings":";;;;AAoIA,MAAM,eAAyC;CAAE,SAAS;CAAM,QAAQ;CAAM;AAE9E,SAAgB,0BACd,SAC8B;CAC9B,MAAM,EACJ,WAAW,IACX,qBACA,yBAAyB,wBACz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AmB;IACnB,eAAe,aAAa;IAC5B;IACA,eAAe,MAAM,WAAW;IAChC,gBAAgB;IAChB;IACA,eAAe,MAAM,iBAAiB,OAAO,UAAU,EAAE;IACzD,mBAAmB,qBAAqB;IACxC;IACA,YAAY,QAAQ;IACpB;IACA;IACA;IACA,oBAAoB;IACpB;IACA;IACA,wBAAwB;IACxB;IACA;IACD,CAAC;;EAGJ,eACE,OACA,cACA,SACA,eACA,aACA,mBACA,aACA;GACA,OAAO,KAAK,yBACV,OACA,KACA,cACA,SACA,EAAE,eAAe,EACjB,aACA,mBACA,YACD;;EAGH,oBACE,OACA,OACA,cACA,SACA,eACA,aACA,mBACA,aACA;GACA,OAAO,2BAA2B;IAChC;IACA,qBAAqB,cAAc;IACnC;IACA,wBAAwB,UAAU,WAAW;KAC3C,OAAO,uBAAuB,SAAS,UAAU,UAAU;;IAE7D;IACA,cAAc,cAAc;IAC5B,iBAAiB,cAAc;IAC/B,eAAe,cAAc;IAC7B;IACA,mBAAmB;IACnB,eAAe,aAAa;IAC5B;IACA,gBAAgB;IAChB;IACA,eAAe,iBAAiB,OAAO,UAAU,EAAE;IACnD,mBAAmB,qBAAqB;IACxC;IACA,YAAY,QAAQ;IACpB;IACA;IACA;IACA,wBAAwB;IACxB,wBAAwB;IACxB;IACD,CAAC;;EAEL"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/server/app-inline-css-client.d.ts
|
|
2
|
+
type InlineCssStylesheetLinkElement = Pick<HTMLLinkElement, "getAttribute" | "hasAttribute">;
|
|
3
|
+
declare function isInlineCssStylesheetLinkElement(link: InlineCssStylesheetLinkElement): boolean;
|
|
4
|
+
declare function removeStylesheetLinksCoveredByInlineCss(): void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { isInlineCssStylesheetLinkElement, removeStylesheetLinksCoveredByInlineCss };
|
|
7
|
+
//# sourceMappingURL=app-inline-css-client.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { htmlTokenListContains } from "./html.js";
|
|
2
|
+
//#region src/server/app-inline-css-client.ts
|
|
3
|
+
function inlineStyleCoversStylesheetHref(styleHref, linkHref) {
|
|
4
|
+
for (const candidate of styleHref.split(/\s+/)) {
|
|
5
|
+
if (candidate === linkHref) return true;
|
|
6
|
+
try {
|
|
7
|
+
const candidateUrl = new URL(candidate, window.location.href);
|
|
8
|
+
const linkUrl = new URL(linkHref, window.location.href);
|
|
9
|
+
if (candidateUrl.href === linkUrl.href) return true;
|
|
10
|
+
} catch {}
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
function isInlineCssStylesheetLinkElement(link) {
|
|
15
|
+
return htmlTokenListContains(link.getAttribute("rel"), "stylesheet") && link.hasAttribute("href") && (link.hasAttribute("data-precedence") || link.hasAttribute("precedence"));
|
|
16
|
+
}
|
|
17
|
+
function removeStylesheetLinksCoveredByInlineCss() {
|
|
18
|
+
const inlineStyles = document.head.querySelectorAll("style[data-vinext-inline-css][data-href]");
|
|
19
|
+
if (inlineStyles.length === 0) return;
|
|
20
|
+
const links = document.head.querySelectorAll("link[rel][href]");
|
|
21
|
+
for (const link of links) {
|
|
22
|
+
if (!isInlineCssStylesheetLinkElement(link)) continue;
|
|
23
|
+
const href = link.getAttribute("href");
|
|
24
|
+
if (!href) continue;
|
|
25
|
+
for (const style of inlineStyles) {
|
|
26
|
+
const styleHref = style.getAttribute("data-href");
|
|
27
|
+
if (styleHref && inlineStyleCoversStylesheetHref(styleHref, href)) {
|
|
28
|
+
link.remove();
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { isInlineCssStylesheetLinkElement, removeStylesheetLinksCoveredByInlineCss };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=app-inline-css-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-inline-css-client.js","names":[],"sources":["../../src/server/app-inline-css-client.ts"],"sourcesContent":["import { htmlTokenListContains } from \"./html.js\";\n\ntype InlineCssStylesheetLinkElement = Pick<HTMLLinkElement, \"getAttribute\" | \"hasAttribute\">;\n\nfunction inlineStyleCoversStylesheetHref(styleHref: string, linkHref: string): boolean {\n for (const candidate of styleHref.split(/\\s+/)) {\n if (candidate === linkHref) return true;\n try {\n const candidateUrl = new URL(candidate, window.location.href);\n const linkUrl = new URL(linkHref, window.location.href);\n if (candidateUrl.href === linkUrl.href) return true;\n } catch {\n // If either value is not parseable, exact string comparison above is the\n // only safe comparison.\n }\n }\n\n return false;\n}\n\nexport function isInlineCssStylesheetLinkElement(link: InlineCssStylesheetLinkElement): boolean {\n return (\n htmlTokenListContains(link.getAttribute(\"rel\"), \"stylesheet\") &&\n link.hasAttribute(\"href\") &&\n (link.hasAttribute(\"data-precedence\") || link.hasAttribute(\"precedence\"))\n );\n}\n\nexport function removeStylesheetLinksCoveredByInlineCss(): void {\n const inlineStyles = document.head.querySelectorAll<HTMLStyleElement>(\n \"style[data-vinext-inline-css][data-href]\",\n );\n if (inlineStyles.length === 0) return;\n\n const links = document.head.querySelectorAll<HTMLLinkElement>(\"link[rel][href]\");\n for (const link of links) {\n if (!isInlineCssStylesheetLinkElement(link)) continue;\n\n const href = link.getAttribute(\"href\");\n if (!href) continue;\n\n for (const style of inlineStyles) {\n const styleHref = style.getAttribute(\"data-href\");\n if (styleHref && inlineStyleCoversStylesheetHref(styleHref, href)) {\n link.remove();\n break;\n }\n }\n }\n}\n"],"mappings":";;AAIA,SAAS,gCAAgC,WAAmB,UAA2B;CACrF,KAAK,MAAM,aAAa,UAAU,MAAM,MAAM,EAAE;EAC9C,IAAI,cAAc,UAAU,OAAO;EACnC,IAAI;GACF,MAAM,eAAe,IAAI,IAAI,WAAW,OAAO,SAAS,KAAK;GAC7D,MAAM,UAAU,IAAI,IAAI,UAAU,OAAO,SAAS,KAAK;GACvD,IAAI,aAAa,SAAS,QAAQ,MAAM,OAAO;UACzC;;CAMV,OAAO;;AAGT,SAAgB,iCAAiC,MAA+C;CAC9F,OACE,sBAAsB,KAAK,aAAa,MAAM,EAAE,aAAa,IAC7D,KAAK,aAAa,OAAO,KACxB,KAAK,aAAa,kBAAkB,IAAI,KAAK,aAAa,aAAa;;AAI5E,SAAgB,0CAAgD;CAC9D,MAAM,eAAe,SAAS,KAAK,iBACjC,2CACD;CACD,IAAI,aAAa,WAAW,GAAG;CAE/B,MAAM,QAAQ,SAAS,KAAK,iBAAkC,kBAAkB;CAChF,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,CAAC,iCAAiC,KAAK,EAAE;EAE7C,MAAM,OAAO,KAAK,aAAa,OAAO;EACtC,IAAI,CAAC,MAAM;EAEX,KAAK,MAAM,SAAS,cAAc;GAChC,MAAM,YAAY,MAAM,aAAa,YAAY;GACjD,IAAI,aAAa,gCAAgC,WAAW,KAAK,EAAE;IACjE,KAAK,QAAQ;IACb"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RenderRequestApiKind } from "./cache-proof.js";
|
|
2
|
+
import { UnstableCacheObservation } from "../shims/cache.js";
|
|
3
|
+
import { ThenableParamsObserver } from "../shims/thenable-params.js";
|
|
4
|
+
|
|
5
|
+
//#region src/server/app-layout-param-observation.d.ts
|
|
6
|
+
type AppLayoutParamAccessObservation = Readonly<{
|
|
7
|
+
cacheLifeObserved: boolean;
|
|
8
|
+
cacheTags: readonly string[];
|
|
9
|
+
cacheableFetchCount: number;
|
|
10
|
+
completeness: "complete" | "unknown";
|
|
11
|
+
dynamicFetchCount: number;
|
|
12
|
+
finiteRevalidateSeconds: number | null;
|
|
13
|
+
keys: readonly string[];
|
|
14
|
+
observed: boolean;
|
|
15
|
+
paramScopeKeys: readonly string[];
|
|
16
|
+
requestApis: readonly RenderRequestApiKind[];
|
|
17
|
+
unstableCaches: readonly UnstableCacheObservation[];
|
|
18
|
+
}>;
|
|
19
|
+
type AppLayoutParamAccessTracker = Readonly<{
|
|
20
|
+
createThenableParamsObserver: (layoutId: string) => ThenableParamsObserver;
|
|
21
|
+
getLayoutObservation: (layoutId: string) => AppLayoutParamAccessObservation;
|
|
22
|
+
recordLayoutFiniteRevalidate: (layoutId: string, revalidateSeconds: number) => void;
|
|
23
|
+
recordLayoutParamScope: (layoutId: string, paramScopeKeys: readonly string[]) => void;
|
|
24
|
+
runLayoutProbe: (layoutId: string, probe: () => unknown) => unknown;
|
|
25
|
+
}>;
|
|
26
|
+
declare function isAppLayoutObservationUnsafeForStaticReuse(observation: AppLayoutParamAccessObservation): boolean;
|
|
27
|
+
declare function createAppLayoutParamAccessTracker(): AppLayoutParamAccessTracker;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { AppLayoutParamAccessObservation, AppLayoutParamAccessTracker, createAppLayoutParamAccessTracker, isAppLayoutObservationUnsafeForStaticReuse };
|
|
30
|
+
//# sourceMappingURL=app-layout-param-observation.d.ts.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { isInsideUnifiedScope, runWithUnifiedStateMutation } from "../shims/unified-request-context.js";
|
|
2
|
+
import { peekRenderRequestApiUsage } from "../shims/headers.js";
|
|
3
|
+
import { _peekRequestScopedCacheLife, _peekUnstableCacheObservations } from "../shims/cache.js";
|
|
4
|
+
import { getCollectedFetchTags, peekCacheableFetchObservations, peekDynamicFetchObservations } from "../shims/fetch-cache.js";
|
|
5
|
+
//#region src/server/app-layout-param-observation.ts
|
|
6
|
+
function isAppLayoutObservationUnsafeForStaticReuse(observation) {
|
|
7
|
+
return observation.completeness !== "complete" || observation.paramScopeKeys.length > 0 || observation.observed || observation.requestApis.length > 0 || observation.finiteRevalidateSeconds !== null || observation.cacheLifeObserved || observation.cacheTags.length > 0 || observation.cacheableFetchCount > 0 || observation.dynamicFetchCount > 0 || observation.unstableCaches.length > 0;
|
|
8
|
+
}
|
|
9
|
+
function isPromiseLike(value) {
|
|
10
|
+
return Boolean(value && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function");
|
|
11
|
+
}
|
|
12
|
+
function createAppLayoutParamAccessTracker() {
|
|
13
|
+
const observations = /* @__PURE__ */ new Map();
|
|
14
|
+
const ensureObservation = (layoutId) => {
|
|
15
|
+
const existing = observations.get(layoutId);
|
|
16
|
+
if (existing) return existing;
|
|
17
|
+
const created = {
|
|
18
|
+
cacheLifeObserved: false,
|
|
19
|
+
cacheTags: /* @__PURE__ */ new Set(),
|
|
20
|
+
cacheableFetches: /* @__PURE__ */ new Set(),
|
|
21
|
+
dynamicFetches: /* @__PURE__ */ new Set(),
|
|
22
|
+
finiteRevalidateSeconds: null,
|
|
23
|
+
keys: /* @__PURE__ */ new Set(),
|
|
24
|
+
observed: false,
|
|
25
|
+
paramScopeKeys: /* @__PURE__ */ new Set(),
|
|
26
|
+
probeComplete: false,
|
|
27
|
+
requestApis: /* @__PURE__ */ new Set(),
|
|
28
|
+
unstableCaches: /* @__PURE__ */ new Map()
|
|
29
|
+
};
|
|
30
|
+
observations.set(layoutId, created);
|
|
31
|
+
return created;
|
|
32
|
+
};
|
|
33
|
+
const markObserved = (layoutId, keys) => {
|
|
34
|
+
const observation = ensureObservation(layoutId);
|
|
35
|
+
observation.observed = true;
|
|
36
|
+
for (const key of keys) observation.keys.add(key);
|
|
37
|
+
};
|
|
38
|
+
const markProbeComplete = (layoutId) => {
|
|
39
|
+
ensureObservation(layoutId).probeComplete = true;
|
|
40
|
+
};
|
|
41
|
+
const runWithIsolatedProbeDependencies = (probe) => {
|
|
42
|
+
if (!isInsideUnifiedScope()) return probe();
|
|
43
|
+
return runWithUnifiedStateMutation((ctx) => {
|
|
44
|
+
ctx.cacheableFetchUrls = /* @__PURE__ */ new Set();
|
|
45
|
+
ctx.currentRequestTags = [];
|
|
46
|
+
ctx.currentFetchSoftTags = [];
|
|
47
|
+
ctx.dynamicFetchUrls = /* @__PURE__ */ new Set();
|
|
48
|
+
ctx.dynamicUsageDetected = false;
|
|
49
|
+
ctx.renderRequestApiUsage = /* @__PURE__ */ new Set();
|
|
50
|
+
ctx.requestScopedCacheLife = null;
|
|
51
|
+
ctx.unstableCacheObservations = /* @__PURE__ */ new Map();
|
|
52
|
+
}, probe);
|
|
53
|
+
};
|
|
54
|
+
const recordProbeDependencies = (layoutId) => {
|
|
55
|
+
const observation = ensureObservation(layoutId);
|
|
56
|
+
if (_peekRequestScopedCacheLife() !== null) observation.cacheLifeObserved = true;
|
|
57
|
+
for (const tag of getCollectedFetchTags()) observation.cacheTags.add(tag);
|
|
58
|
+
for (const url of peekCacheableFetchObservations()) observation.cacheableFetches.add(url);
|
|
59
|
+
for (const url of peekDynamicFetchObservations()) observation.dynamicFetches.add(url);
|
|
60
|
+
for (const requestApi of peekRenderRequestApiUsage()) observation.requestApis.add(requestApi);
|
|
61
|
+
for (const unstableCache of _peekUnstableCacheObservations()) observation.unstableCaches.set(unstableCache.keyHash, unstableCache);
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
createThenableParamsObserver(layoutId) {
|
|
65
|
+
return { observeParamAccess(keys) {
|
|
66
|
+
markObserved(layoutId, keys);
|
|
67
|
+
} };
|
|
68
|
+
},
|
|
69
|
+
getLayoutObservation(layoutId) {
|
|
70
|
+
const observation = observations.get(layoutId);
|
|
71
|
+
if (!observation) return {
|
|
72
|
+
cacheLifeObserved: false,
|
|
73
|
+
cacheTags: [],
|
|
74
|
+
cacheableFetchCount: 0,
|
|
75
|
+
completeness: "unknown",
|
|
76
|
+
dynamicFetchCount: 0,
|
|
77
|
+
finiteRevalidateSeconds: null,
|
|
78
|
+
keys: [],
|
|
79
|
+
observed: false,
|
|
80
|
+
paramScopeKeys: [],
|
|
81
|
+
requestApis: [],
|
|
82
|
+
unstableCaches: []
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
cacheLifeObserved: observation.cacheLifeObserved,
|
|
86
|
+
cacheTags: [...observation.cacheTags].sort(),
|
|
87
|
+
cacheableFetchCount: observation.cacheableFetches.size,
|
|
88
|
+
completeness: observation.probeComplete ? "complete" : "unknown",
|
|
89
|
+
dynamicFetchCount: observation.dynamicFetches.size,
|
|
90
|
+
finiteRevalidateSeconds: observation.finiteRevalidateSeconds,
|
|
91
|
+
keys: [...observation.keys].sort(),
|
|
92
|
+
observed: observation.observed,
|
|
93
|
+
paramScopeKeys: [...observation.paramScopeKeys].sort(),
|
|
94
|
+
requestApis: [...observation.requestApis].sort(),
|
|
95
|
+
unstableCaches: [...observation.unstableCaches.values()].sort((a, b) => a.keyHash.localeCompare(b.keyHash))
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
recordLayoutFiniteRevalidate(layoutId, revalidateSeconds) {
|
|
99
|
+
if (!Number.isFinite(revalidateSeconds) || revalidateSeconds <= 0) return;
|
|
100
|
+
const observation = ensureObservation(layoutId);
|
|
101
|
+
observation.finiteRevalidateSeconds = observation.finiteRevalidateSeconds === null ? revalidateSeconds : Math.min(observation.finiteRevalidateSeconds, revalidateSeconds);
|
|
102
|
+
},
|
|
103
|
+
recordLayoutParamScope(layoutId, paramScopeKeys) {
|
|
104
|
+
const observation = ensureObservation(layoutId);
|
|
105
|
+
for (const key of paramScopeKeys) observation.paramScopeKeys.add(key);
|
|
106
|
+
},
|
|
107
|
+
runLayoutProbe(layoutId, probe) {
|
|
108
|
+
return runWithIsolatedProbeDependencies(() => {
|
|
109
|
+
const result = probe();
|
|
110
|
+
if (!isPromiseLike(result)) {
|
|
111
|
+
recordProbeDependencies(layoutId);
|
|
112
|
+
markProbeComplete(layoutId);
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
return Promise.resolve(result).then((resolved) => {
|
|
116
|
+
recordProbeDependencies(layoutId);
|
|
117
|
+
markProbeComplete(layoutId);
|
|
118
|
+
return resolved;
|
|
119
|
+
}, (error) => {
|
|
120
|
+
recordProbeDependencies(layoutId);
|
|
121
|
+
throw error;
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { createAppLayoutParamAccessTracker, isAppLayoutObservationUnsafeForStaticReuse };
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=app-layout-param-observation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-layout-param-observation.js","names":[],"sources":["../../src/server/app-layout-param-observation.ts"],"sourcesContent":["import type { ThenableParamsObserver } from \"vinext/shims/thenable-params\";\nimport {\n _peekRequestScopedCacheLife,\n _peekUnstableCacheObservations,\n type UnstableCacheObservation,\n} from \"vinext/shims/cache\";\nimport {\n getCollectedFetchTags,\n peekCacheableFetchObservations,\n peekDynamicFetchObservations,\n} from \"vinext/shims/fetch-cache\";\nimport { peekRenderRequestApiUsage } from \"vinext/shims/headers\";\nimport {\n isInsideUnifiedScope,\n runWithUnifiedStateMutation,\n} from \"vinext/shims/unified-request-context\";\nimport type { RenderRequestApiKind } from \"./cache-proof.js\";\n\nexport type AppLayoutParamAccessObservation = Readonly<{\n cacheLifeObserved: boolean;\n cacheTags: readonly string[];\n cacheableFetchCount: number;\n completeness: \"complete\" | \"unknown\";\n dynamicFetchCount: number;\n finiteRevalidateSeconds: number | null;\n keys: readonly string[];\n observed: boolean;\n paramScopeKeys: readonly string[];\n requestApis: readonly RenderRequestApiKind[];\n unstableCaches: readonly UnstableCacheObservation[];\n}>;\n\nexport type AppLayoutParamAccessTracker = Readonly<{\n createThenableParamsObserver: (layoutId: string) => ThenableParamsObserver;\n getLayoutObservation: (layoutId: string) => AppLayoutParamAccessObservation;\n recordLayoutFiniteRevalidate: (layoutId: string, revalidateSeconds: number) => void;\n recordLayoutParamScope: (layoutId: string, paramScopeKeys: readonly string[]) => void;\n runLayoutProbe: (layoutId: string, probe: () => unknown) => unknown;\n}>;\n\nexport function isAppLayoutObservationUnsafeForStaticReuse(\n observation: AppLayoutParamAccessObservation,\n): boolean {\n return (\n observation.completeness !== \"complete\" ||\n observation.paramScopeKeys.length > 0 ||\n observation.observed ||\n observation.requestApis.length > 0 ||\n observation.finiteRevalidateSeconds !== null ||\n observation.cacheLifeObserved ||\n observation.cacheTags.length > 0 ||\n observation.cacheableFetchCount > 0 ||\n observation.dynamicFetchCount > 0 ||\n observation.unstableCaches.length > 0\n );\n}\n\ntype MutableLayoutParamAccessObservation = {\n cacheLifeObserved: boolean;\n cacheTags: Set<string>;\n cacheableFetches: Set<string>;\n dynamicFetches: Set<string>;\n finiteRevalidateSeconds: number | null;\n keys: Set<string>;\n observed: boolean;\n paramScopeKeys: Set<string>;\n probeComplete: boolean;\n requestApis: Set<RenderRequestApiKind>;\n unstableCaches: Map<string, UnstableCacheObservation>;\n};\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return Boolean(\n value &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n \"then\" in value &&\n typeof value.then === \"function\",\n );\n}\n\nexport function createAppLayoutParamAccessTracker(): AppLayoutParamAccessTracker {\n const observations = new Map<string, MutableLayoutParamAccessObservation>();\n\n const ensureObservation = (layoutId: string): MutableLayoutParamAccessObservation => {\n const existing = observations.get(layoutId);\n if (existing) return existing;\n\n const created: MutableLayoutParamAccessObservation = {\n cacheLifeObserved: false,\n cacheTags: new Set(),\n cacheableFetches: new Set(),\n dynamicFetches: new Set(),\n finiteRevalidateSeconds: null,\n keys: new Set(),\n observed: false,\n paramScopeKeys: new Set(),\n probeComplete: false,\n requestApis: new Set(),\n unstableCaches: new Map(),\n };\n observations.set(layoutId, created);\n return created;\n };\n\n const markObserved = (layoutId: string, keys: readonly string[]) => {\n const observation = ensureObservation(layoutId);\n observation.observed = true;\n for (const key of keys) {\n observation.keys.add(key);\n }\n };\n\n const markProbeComplete = (layoutId: string) => {\n ensureObservation(layoutId).probeComplete = true;\n };\n\n const runWithIsolatedProbeDependencies = (probe: () => unknown): unknown => {\n if (!isInsideUnifiedScope()) {\n return probe();\n }\n return runWithUnifiedStateMutation((ctx) => {\n ctx.cacheableFetchUrls = new Set();\n ctx.currentRequestTags = [];\n ctx.currentFetchSoftTags = [];\n ctx.dynamicFetchUrls = new Set();\n ctx.dynamicUsageDetected = false;\n ctx.renderRequestApiUsage = new Set();\n ctx.requestScopedCacheLife = null;\n ctx.unstableCacheObservations = new Map();\n }, probe);\n };\n\n const recordProbeDependencies = (layoutId: string) => {\n const observation = ensureObservation(layoutId);\n if (_peekRequestScopedCacheLife() !== null) {\n observation.cacheLifeObserved = true;\n }\n for (const tag of getCollectedFetchTags()) {\n observation.cacheTags.add(tag);\n }\n for (const url of peekCacheableFetchObservations()) {\n observation.cacheableFetches.add(url);\n }\n for (const url of peekDynamicFetchObservations()) {\n observation.dynamicFetches.add(url);\n }\n for (const requestApi of peekRenderRequestApiUsage()) {\n observation.requestApis.add(requestApi);\n }\n for (const unstableCache of _peekUnstableCacheObservations()) {\n observation.unstableCaches.set(unstableCache.keyHash, unstableCache);\n }\n };\n\n return {\n createThenableParamsObserver(layoutId) {\n return {\n observeParamAccess(keys) {\n markObserved(layoutId, keys);\n },\n };\n },\n getLayoutObservation(layoutId) {\n const observation = observations.get(layoutId);\n if (!observation) {\n return {\n cacheLifeObserved: false,\n cacheTags: [],\n cacheableFetchCount: 0,\n completeness: \"unknown\",\n dynamicFetchCount: 0,\n finiteRevalidateSeconds: null,\n keys: [],\n observed: false,\n paramScopeKeys: [],\n requestApis: [],\n unstableCaches: [],\n };\n }\n\n return {\n cacheLifeObserved: observation.cacheLifeObserved,\n cacheTags: [...observation.cacheTags].sort(),\n cacheableFetchCount: observation.cacheableFetches.size,\n completeness: observation.probeComplete ? \"complete\" : \"unknown\",\n dynamicFetchCount: observation.dynamicFetches.size,\n finiteRevalidateSeconds: observation.finiteRevalidateSeconds,\n keys: [...observation.keys].sort(),\n observed: observation.observed,\n paramScopeKeys: [...observation.paramScopeKeys].sort(),\n requestApis: [...observation.requestApis].sort(),\n unstableCaches: [...observation.unstableCaches.values()].sort((a, b) =>\n a.keyHash.localeCompare(b.keyHash),\n ),\n };\n },\n recordLayoutFiniteRevalidate(layoutId, revalidateSeconds) {\n if (!Number.isFinite(revalidateSeconds) || revalidateSeconds <= 0) return;\n const observation = ensureObservation(layoutId);\n observation.finiteRevalidateSeconds =\n observation.finiteRevalidateSeconds === null\n ? revalidateSeconds\n : Math.min(observation.finiteRevalidateSeconds, revalidateSeconds);\n },\n recordLayoutParamScope(layoutId, paramScopeKeys) {\n const observation = ensureObservation(layoutId);\n for (const key of paramScopeKeys) {\n observation.paramScopeKeys.add(key);\n }\n },\n runLayoutProbe(layoutId, probe) {\n return runWithIsolatedProbeDependencies(() => {\n const result = probe();\n if (!isPromiseLike(result)) {\n recordProbeDependencies(layoutId);\n markProbeComplete(layoutId);\n return result;\n }\n\n return Promise.resolve(result).then(\n (resolved) => {\n recordProbeDependencies(layoutId);\n markProbeComplete(layoutId);\n return resolved;\n },\n (error: unknown) => {\n // Record whatever dependencies we observed before the failure\n // so the layout's dependency snapshot is as complete as possible.\n // Deliberately do NOT call markProbeComplete here: a failed probe\n // leaves completeness as \"unknown\", which makes the planner fall\n // back to render-and-send — the safe default for any probe error.\n recordProbeDependencies(layoutId);\n throw error;\n },\n );\n });\n },\n };\n}\n"],"mappings":";;;;;AAwCA,SAAgB,2CACd,aACS;CACT,OACE,YAAY,iBAAiB,cAC7B,YAAY,eAAe,SAAS,KACpC,YAAY,YACZ,YAAY,YAAY,SAAS,KACjC,YAAY,4BAA4B,QACxC,YAAY,qBACZ,YAAY,UAAU,SAAS,KAC/B,YAAY,sBAAsB,KAClC,YAAY,oBAAoB,KAChC,YAAY,eAAe,SAAS;;AAkBxC,SAAS,cAAc,OAA+C;CACpE,OAAO,QACL,UACC,OAAO,UAAU,YAAY,OAAO,UAAU,eAC/C,UAAU,SACV,OAAO,MAAM,SAAS,WACvB;;AAGH,SAAgB,oCAAiE;CAC/E,MAAM,+BAAe,IAAI,KAAkD;CAE3E,MAAM,qBAAqB,aAA0D;EACnF,MAAM,WAAW,aAAa,IAAI,SAAS;EAC3C,IAAI,UAAU,OAAO;EAErB,MAAM,UAA+C;GAC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GAC9B,OAAO,uCAAuC;IAC5C,MAAM,SAAS,OAAO;IACtB,IAAI,CAAC,cAAc,OAAO,EAAE;KAC1B,wBAAwB,SAAS;KACjC,kBAAkB,SAAS;KAC3B,OAAO;;IAGT,OAAO,QAAQ,QAAQ,OAAO,CAAC,MAC5B,aAAa;KACZ,wBAAwB,SAAS;KACjC,kBAAkB,SAAS;KAC3B,OAAO;QAER,UAAmB;KAMlB,wBAAwB,SAAS;KACjC,MAAM;MAET;KACD;;EAEL"}
|
|
@@ -146,9 +146,9 @@ async function renderAppPageHttpAccessFallback(options) {
|
|
|
146
146
|
charSet: "utf-8",
|
|
147
147
|
key: "charset"
|
|
148
148
|
}), createElement("meta", {
|
|
149
|
-
content: "noindex",
|
|
150
149
|
key: "robots",
|
|
151
|
-
name: "robots"
|
|
150
|
+
name: "robots",
|
|
151
|
+
content: "noindex"
|
|
152
152
|
})];
|
|
153
153
|
if (metadata) headElements.push(createElement(MetadataHead, {
|
|
154
154
|
key: "metadata",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-page-boundary-render.js","names":[],"sources":["../../src/server/app-page-boundary-render.ts"],"sourcesContent":["import { Fragment, createElement, type ComponentType, type ReactNode } from \"react\";\nimport { buildClientHookErrorMessage } from \"vinext/shims/client-hook-error\";\nimport { ErrorBoundary } from \"vinext/shims/error-boundary\";\nimport { LayoutSegmentProvider } from \"vinext/shims/layout-segment-context\";\nimport { MetadataHead, ViewportHead } from \"vinext/shims/metadata\";\nimport type { AppPageFontPreload } from \"./app-page-execution.js\";\nimport type { AppPageMiddlewareContext } from \"./app-page-response.js\";\nimport type { MetadataFileRoute } from \"./metadata-routes.js\";\nimport { resolveAppPageHead } from \"./app-page-head.js\";\nimport {\n renderAppPageBoundaryResponse,\n resolveAppPageErrorBoundary,\n resolveAppPageHttpAccessBoundaryComponent,\n wrapAppPageBoundaryElement,\n type AppPageParams,\n} from \"./app-page-boundary.js\";\nimport {\n createAppPageFontData,\n renderAppPageHtmlResponse,\n type AppPageSsrHandler,\n} from \"./app-page-stream.js\";\nimport { AppElementsWire, type AppElements } from \"./app-elements.js\";\nimport { createAppPageLayoutEntries } from \"./app-page-route-wiring.js\";\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype AppPageComponent = ComponentType<any>;\ntype AppPageModule = Record<string, unknown> & {\n default?: AppPageComponent | null | undefined;\n};\ntype AppPageBoundaryOnError = (\n error: unknown,\n requestInfo: unknown,\n errorContext: unknown,\n) => unknown;\n\ntype AppPageBoundaryRscPayloadOptions<TModule extends AppPageModule = AppPageModule> = {\n element: ReactNode;\n layoutModules: readonly (TModule | null | undefined)[];\n pathname: string;\n route?: AppPageBoundaryRoute<TModule> | null;\n};\n\ntype AppPageBoundaryLayoutEntry = {\n id: string;\n treePath: string;\n};\n\nexport type AppPageBoundaryRoute<TModule extends AppPageModule = AppPageModule> = {\n error?: TModule | null;\n errorPaths?: readonly TModule[] | null;\n errors?: readonly (TModule | null | undefined)[] | null;\n forbidden?: TModule | null;\n layoutTreePositions?: readonly number[] | null;\n layouts?: readonly (TModule | null | undefined)[];\n notFound?: TModule | null;\n params?: AppPageParams;\n pattern?: string;\n routeSegments?: readonly string[];\n unauthorized?: TModule | null;\n};\n\ntype AppPageBoundaryRenderCommonOptions<TModule extends AppPageModule = AppPageModule> = {\n buildFontLinkHeader: (preloads: readonly AppPageFontPreload[] | null | undefined) => string;\n clearRequestContext: () => void;\n createRscOnErrorHandler: (pathname: string, routePath: string) => AppPageBoundaryOnError;\n getFontLinks: () => string[];\n getFontPreloads: () => AppPageFontPreload[];\n getFontStyles: () => string[];\n getNavigationContext: () => unknown;\n globalErrorModule?: TModule | null;\n isEdgeRuntime?: boolean;\n isRscRequest: boolean;\n loadSsrHandler: () => Promise<AppPageSsrHandler>;\n makeThenableParams: (params: AppPageParams) => unknown;\n middlewareContext: AppPageMiddlewareContext;\n metadataRoutes: MetadataFileRoute[];\n /** Configured next.config `basePath`, threaded into file-based metadata href emission. */\n basePath?: string;\n renderToReadableStream: (\n element: ReactNode | AppElements,\n options: { onError: AppPageBoundaryOnError },\n ) => ReadableStream<Uint8Array>;\n requestUrl: string;\n resolveChildSegments: (\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n ) => string[];\n rootLayouts: readonly (TModule | null | undefined)[];\n scriptNonce?: string;\n};\n\ntype RenderAppPageHttpAccessFallbackOptions<TModule extends AppPageModule = AppPageModule> = {\n boundaryComponent?: AppPageComponent | null;\n layoutModules?: readonly (TModule | null | undefined)[] | null;\n matchedParams: AppPageParams;\n rootForbiddenModule?: TModule | null;\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n route?: AppPageBoundaryRoute<TModule> | null;\n /**\n * When true, the resolved boundary is rendered without wrapping it in the\n * route's layouts. Used by `global-not-found.tsx`, which provides its own\n * `<html>`/`<body>` and intentionally replaces the root layout.\n * Mirrors Next.js's `createNotFoundLoaderTree` behavior for `hasGlobalNotFound`.\n * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx#L495-L520\n */\n skipLayoutWrapping?: boolean;\n statusCode: number;\n} & AppPageBoundaryRenderCommonOptions<TModule>;\n\ntype RenderAppPageErrorBoundaryOptions<TModule extends AppPageModule = AppPageModule> = {\n error: unknown;\n matchedParams?: AppPageParams | null;\n route?: AppPageBoundaryRoute<TModule> | null;\n sanitizeErrorForClient: (error: Error) => Error;\n} & AppPageBoundaryRenderCommonOptions<TModule>;\n\nfunction getDefaultExport<TModule extends AppPageModule>(\n module: TModule | null | undefined,\n): AppPageComponent | null {\n return module?.default ?? null;\n}\n\nfunction wrapRenderedBoundaryElement<TModule extends AppPageModule>(\n options: Pick<\n AppPageBoundaryRenderCommonOptions<TModule>,\n \"globalErrorModule\" | \"isRscRequest\" | \"makeThenableParams\" | \"resolveChildSegments\"\n > & {\n element: ReactNode;\n includeGlobalErrorBoundary: boolean;\n layoutModules: readonly (TModule | null | undefined)[];\n layoutTreePositions?: readonly number[] | null;\n matchedParams: AppPageParams;\n routeSegments?: readonly string[];\n skipLayoutWrapping?: boolean;\n },\n): ReactNode {\n return wrapAppPageBoundaryElement({\n element: options.element,\n getDefaultExport,\n globalErrorComponent: getDefaultExport(options.globalErrorModule),\n includeGlobalErrorBoundary: options.includeGlobalErrorBoundary,\n isRscRequest: options.isRscRequest,\n layoutModules: options.layoutModules,\n layoutTreePositions: options.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams: options.matchedParams,\n renderErrorBoundary(GlobalErrorComponent, children) {\n return createElement(ErrorBoundary, {\n fallback: GlobalErrorComponent,\n // oxlint-disable-next-line react/no-children-prop\n children,\n });\n },\n renderLayout(LayoutComponent, children, asyncParams) {\n return createElement(LayoutComponent as AppPageComponent, {\n // oxlint-disable-next-line react/no-children-prop\n children,\n params: asyncParams,\n });\n },\n renderLayoutSegmentProvider(segmentMap, children) {\n return createElement(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n LayoutSegmentProvider as ComponentType<any>,\n { segmentMap },\n children,\n );\n },\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.routeSegments ?? [],\n skipLayoutWrapping: options.skipLayoutWrapping,\n });\n}\n\nfunction createAppPageBoundaryLayoutEntries<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly AppPageBoundaryLayoutEntry[] {\n if (!route || layoutModules.length === 0) return [];\n\n return createAppPageLayoutEntries({\n errors: route.errors,\n layoutTreePositions: route.layoutTreePositions,\n layouts: layoutModules,\n notFounds: null,\n routeSegments: route.routeSegments,\n });\n}\n\nfunction resolveHttpAccessFallbackHeadRouteSegments<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly string[] | undefined {\n if (!route?.routeSegments) {\n return undefined;\n }\n\n if (!route.layouts || layoutModules.length >= route.layouts.length) {\n return route.routeSegments;\n }\n\n const lastIncludedLayoutIndex = layoutModules.length - 1;\n if (lastIncludedLayoutIndex < 0) {\n return [];\n }\n\n const segmentCount = route.layoutTreePositions?.[lastIncludedLayoutIndex] ?? 0;\n return route.routeSegments.slice(0, segmentCount);\n}\n\nfunction resolveHttpAccessFallbackHeadLayoutTreePositions<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly number[] | null | undefined {\n if (!route?.layouts || layoutModules.length >= route.layouts.length) {\n return route?.layoutTreePositions;\n }\n\n return route.layoutTreePositions?.slice(0, layoutModules.length);\n}\n\nfunction createAppPageBoundaryRscPayload<TModule extends AppPageModule>(\n options: AppPageBoundaryRscPayloadOptions<TModule>,\n): AppElements {\n const routeId = AppElementsWire.encodeRouteId(options.pathname, null);\n const layoutEntries = createAppPageBoundaryLayoutEntries(options.route, options.layoutModules);\n\n return {\n ...AppElementsWire.createMetadataEntries({\n interceptionContext: null,\n layoutIds: layoutEntries.map((entry) => entry.id),\n rootLayoutTreePath: layoutEntries[0]?.treePath ?? null,\n routeId,\n }),\n [routeId]: options.element,\n };\n}\n\nasync function renderAppPageBoundaryElementResponse<TModule extends AppPageModule>(\n options: AppPageBoundaryRenderCommonOptions<TModule> & {\n element: ReactNode;\n layoutModules: readonly (TModule | null | undefined)[];\n route?: AppPageBoundaryRoute<TModule> | null;\n routePattern?: string;\n status: number;\n },\n): Promise<Response> {\n const pathname = new URL(options.requestUrl).pathname;\n const payload = createAppPageBoundaryRscPayload({\n element: options.element,\n layoutModules: options.layoutModules,\n pathname,\n route: options.route,\n });\n\n return renderAppPageBoundaryResponse({\n async createHtmlResponse(rscStream, responseStatus) {\n const fontData = createAppPageFontData({\n getLinks: options.getFontLinks,\n getPreloads: options.getFontPreloads,\n getStyles: options.getFontStyles,\n });\n const ssrHandler = await options.loadSsrHandler();\n return renderAppPageHtmlResponse({\n clearRequestContext: options.clearRequestContext,\n fontData,\n fontLinkHeader: options.buildFontLinkHeader(fontData.preloads),\n isEdgeRuntime: options.isEdgeRuntime,\n middlewareHeaders: options.middlewareContext.headers,\n navigationContext: options.getNavigationContext(),\n rscStream,\n scriptNonce: options.scriptNonce,\n ssrHandler,\n status: responseStatus,\n });\n },\n createRscOnErrorHandler() {\n return options.createRscOnErrorHandler(pathname, options.routePattern ?? pathname);\n },\n element: payload,\n isEdgeRuntime: options.isEdgeRuntime,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareContext.headers,\n renderToReadableStream: options.renderToReadableStream,\n status: options.status,\n });\n}\n\nexport async function renderAppPageHttpAccessFallback<TModule extends AppPageModule>(\n options: RenderAppPageHttpAccessFallbackOptions<TModule>,\n): Promise<Response | null> {\n const boundaryComponent =\n options.boundaryComponent ??\n resolveAppPageHttpAccessBoundaryComponent({\n getDefaultExport,\n rootForbiddenModule: options.rootForbiddenModule,\n rootNotFoundModule: options.rootNotFoundModule,\n rootUnauthorizedModule: options.rootUnauthorizedModule,\n routeForbiddenModule: options.route?.forbidden,\n routeNotFoundModule: options.route?.notFound,\n routeUnauthorizedModule: options.route?.unauthorized,\n statusCode: options.statusCode,\n });\n if (!boundaryComponent) {\n return null;\n }\n\n const layoutModules = options.layoutModules ?? options.route?.layouts ?? options.rootLayouts;\n const pathname = new URL(options.requestUrl).pathname;\n const routeSegments = resolveHttpAccessFallbackHeadRouteSegments(options.route, layoutModules);\n const { metadata, viewport } = await resolveAppPageHead({\n basePath: options.basePath ?? \"\",\n layoutModules,\n layoutTreePositions: resolveHttpAccessFallbackHeadLayoutTreePositions(\n options.route,\n layoutModules,\n ),\n metadataRoutes: options.metadataRoutes,\n params: options.matchedParams,\n routePath: options.route?.pattern ?? pathname,\n routeSegments,\n });\n\n const headElements: ReactNode[] = [\n createElement(\"meta\", { charSet: \"utf-8\", key: \"charset\" }),\n createElement(\"meta\", { content: \"noindex\", key: \"robots\", name: \"robots\" }),\n ];\n if (metadata) {\n headElements.push(createElement(MetadataHead, { key: \"metadata\", metadata, pathname }));\n }\n headElements.push(createElement(ViewportHead, { key: \"viewport\", viewport }));\n\n const skipLayoutWrapping = options.skipLayoutWrapping ?? false;\n const element = wrapRenderedBoundaryElement({\n element: createElement(Fragment, null, ...headElements, createElement(boundaryComponent)),\n globalErrorModule: options.globalErrorModule,\n includeGlobalErrorBoundary: true,\n isRscRequest: options.isRscRequest,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams: options.matchedParams,\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.route?.routeSegments,\n skipLayoutWrapping,\n });\n\n return renderAppPageBoundaryElementResponse({\n ...options,\n // When global-not-found owns the document, no layouts should contribute to\n // the RSC payload's layout entries either — otherwise the SSR pipeline\n // would expect a root-layout tree path that doesn't exist in the markup.\n element,\n layoutModules: skipLayoutWrapping ? [] : layoutModules,\n route: skipLayoutWrapping ? null : options.route,\n routePattern: options.route?.pattern,\n status: options.statusCode,\n });\n}\n\nexport async function renderAppPageErrorBoundary<TModule extends AppPageModule>(\n options: RenderAppPageErrorBoundaryOptions<TModule>,\n): Promise<Response | null> {\n const errorBoundary = resolveAppPageErrorBoundary({\n getDefaultExport,\n errorModules: options.route?.errorPaths,\n globalErrorModule: options.globalErrorModule,\n layoutErrorModules: options.route?.errors,\n pageErrorModule: options.route?.error,\n });\n if (!errorBoundary.component) {\n return null;\n }\n\n const rawError =\n options.error instanceof Error ? options.error : new Error(String(options.error));\n rewriteClientHookError(rawError);\n const errorObject = options.sanitizeErrorForClient(rawError);\n const matchedParams = options.matchedParams ?? options.route?.params ?? {};\n const layoutModules = options.route?.layouts ?? options.rootLayouts;\n const pathname = new URL(options.requestUrl).pathname;\n\n const headElements: ReactNode[] = [createElement(\"meta\", { charSet: \"utf-8\", key: \"charset\" })];\n if (!errorBoundary.isGlobalError) {\n try {\n const { metadata, viewport } = await resolveAppPageHead({\n basePath: options.basePath ?? \"\",\n fallbackOnFileMetadataError: true,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n metadataRoutes: options.metadataRoutes,\n params: matchedParams,\n routePath: options.route?.pattern ?? pathname,\n routeSegments: options.route?.routeSegments,\n });\n if (metadata) {\n headElements.push(createElement(MetadataHead, { key: \"metadata\", metadata, pathname }));\n }\n headElements.push(createElement(ViewportHead, { key: \"viewport\", viewport }));\n } catch (error) {\n console.error(\n `[vinext] App page error boundary head resolution failed for ${options.route?.pattern ?? pathname}:`,\n error,\n );\n }\n }\n\n const element = wrapRenderedBoundaryElement({\n element: createElement(\n Fragment,\n null,\n ...headElements,\n createElement(errorBoundary.component, {\n error: errorObject,\n }),\n ),\n globalErrorModule: options.globalErrorModule,\n includeGlobalErrorBoundary: !errorBoundary.isGlobalError,\n isRscRequest: options.isRscRequest,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams,\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.route?.routeSegments,\n skipLayoutWrapping: errorBoundary.isGlobalError,\n });\n\n return renderAppPageBoundaryElementResponse({\n ...options,\n element,\n layoutModules,\n route: options.route,\n routePattern: options.route?.pattern,\n status: 200,\n });\n}\n\n// React client-only hooks that are absent from the `react-server` export\n// condition. When called in a Server Component they produce a TypeError like\n// \"useState is not a function\". Rewrite into an actionable message matching\n// the format used by the next/navigation shims (see client-hook-error.ts).\nconst _clientHookPattern =\n /\\b(useState|useEffect|useReducer|useRef|useContext|useLayoutEffect|useInsertionEffect|useSyncExternalStore|useTransition|useImperativeHandle|useDeferredValue|useActionState|useOptimistic|useEffectEvent)\\b.*is not a function/;\n\nfunction rewriteClientHookError(error: Error): void {\n const match = error.message.match(_clientHookPattern);\n if (match) {\n error.message = buildClientHookErrorMessage(`${match[1]}()`);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAsHA,SAAS,iBACP,QACyB;CACzB,OAAO,QAAQ,WAAW;;AAG5B,SAAS,4BACP,SAYW;CACX,OAAO,2BAA2B;EAChC,S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,QAAQ;EAC3B,4BAA4B,CAAC,cAAc;EAC3C,cAAc,QAAQ;EACtB;EACA,qBAAqB,QAAQ,OAAO;EACpC,oBAAoB,QAAQ;EAC5B;EACA,sBAAsB,QAAQ;EAC9B,eAAe,QAAQ,OAAO;EAC9B,oBAAoB,cAAc;EACnC,CAAC;CAEF,OAAO,qCAAqC;EAC1C,GAAG;EACH;EACA;EACA,OAAO,QAAQ;EACf,cAAc,QAAQ,OAAO;EAC7B,QAAQ;EACT,CAAC;;AAOJ,MAAM,qBACJ;AAEF,SAAS,uBAAuB,OAAoB;CAClD,MAAM,QAAQ,MAAM,QAAQ,MAAM,mBAAmB;CACrD,IAAI,OACF,MAAM,UAAU,4BAA4B,GAAG,MAAM,GAAG,IAAI"}
|
|
1
|
+
{"version":3,"file":"app-page-boundary-render.js","names":[],"sources":["../../src/server/app-page-boundary-render.ts"],"sourcesContent":["import { Fragment, createElement, type ComponentType, type ReactNode } from \"react\";\nimport { buildClientHookErrorMessage } from \"vinext/shims/client-hook-error\";\nimport { ErrorBoundary } from \"vinext/shims/error-boundary\";\nimport { LayoutSegmentProvider } from \"vinext/shims/layout-segment-context\";\nimport { MetadataHead, ViewportHead } from \"vinext/shims/metadata\";\nimport type { AppPageFontPreload } from \"./app-page-execution.js\";\nimport type { AppPageMiddlewareContext } from \"./app-page-response.js\";\nimport type { MetadataFileRoute } from \"./metadata-routes.js\";\nimport { resolveAppPageHead } from \"./app-page-head.js\";\nimport {\n renderAppPageBoundaryResponse,\n resolveAppPageErrorBoundary,\n resolveAppPageHttpAccessBoundaryComponent,\n wrapAppPageBoundaryElement,\n type AppPageParams,\n} from \"./app-page-boundary.js\";\nimport {\n createAppPageFontData,\n renderAppPageHtmlResponse,\n type AppPageSsrHandler,\n} from \"./app-page-stream.js\";\nimport { AppElementsWire, type AppElements } from \"./app-elements.js\";\nimport { createAppPageLayoutEntries } from \"./app-page-route-wiring.js\";\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype AppPageComponent = ComponentType<any>;\ntype AppPageModule = Record<string, unknown> & {\n default?: AppPageComponent | null | undefined;\n};\ntype AppPageBoundaryOnError = (\n error: unknown,\n requestInfo: unknown,\n errorContext: unknown,\n) => unknown;\n\ntype AppPageBoundaryRscPayloadOptions<TModule extends AppPageModule = AppPageModule> = {\n element: ReactNode;\n layoutModules: readonly (TModule | null | undefined)[];\n pathname: string;\n route?: AppPageBoundaryRoute<TModule> | null;\n};\n\ntype AppPageBoundaryLayoutEntry = {\n id: string;\n treePath: string;\n};\n\nexport type AppPageBoundaryRoute<TModule extends AppPageModule = AppPageModule> = {\n error?: TModule | null;\n errorPaths?: readonly TModule[] | null;\n errors?: readonly (TModule | null | undefined)[] | null;\n forbidden?: TModule | null;\n layoutTreePositions?: readonly number[] | null;\n layouts?: readonly (TModule | null | undefined)[];\n notFound?: TModule | null;\n params?: AppPageParams;\n pattern?: string;\n routeSegments?: readonly string[];\n unauthorized?: TModule | null;\n};\n\ntype AppPageBoundaryRenderCommonOptions<TModule extends AppPageModule = AppPageModule> = {\n buildFontLinkHeader: (preloads: readonly AppPageFontPreload[] | null | undefined) => string;\n clearRequestContext: () => void;\n createRscOnErrorHandler: (pathname: string, routePath: string) => AppPageBoundaryOnError;\n getFontLinks: () => string[];\n getFontPreloads: () => AppPageFontPreload[];\n getFontStyles: () => string[];\n getNavigationContext: () => unknown;\n globalErrorModule?: TModule | null;\n isEdgeRuntime?: boolean;\n isRscRequest: boolean;\n loadSsrHandler: () => Promise<AppPageSsrHandler>;\n makeThenableParams: (params: AppPageParams) => unknown;\n middlewareContext: AppPageMiddlewareContext;\n metadataRoutes: MetadataFileRoute[];\n /** Configured next.config `basePath`, threaded into file-based metadata href emission. */\n basePath?: string;\n renderToReadableStream: (\n element: ReactNode | AppElements,\n options: { onError: AppPageBoundaryOnError },\n ) => ReadableStream<Uint8Array>;\n requestUrl: string;\n resolveChildSegments: (\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n ) => string[];\n rootLayouts: readonly (TModule | null | undefined)[];\n scriptNonce?: string;\n};\n\ntype RenderAppPageHttpAccessFallbackOptions<TModule extends AppPageModule = AppPageModule> = {\n boundaryComponent?: AppPageComponent | null;\n layoutModules?: readonly (TModule | null | undefined)[] | null;\n matchedParams: AppPageParams;\n rootForbiddenModule?: TModule | null;\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n route?: AppPageBoundaryRoute<TModule> | null;\n /**\n * When true, the resolved boundary is rendered without wrapping it in the\n * route's layouts. Used by `global-not-found.tsx`, which provides its own\n * `<html>`/`<body>` and intentionally replaces the root layout.\n * Mirrors Next.js's `createNotFoundLoaderTree` behavior for `hasGlobalNotFound`.\n * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx#L495-L520\n */\n skipLayoutWrapping?: boolean;\n statusCode: number;\n} & AppPageBoundaryRenderCommonOptions<TModule>;\n\ntype RenderAppPageErrorBoundaryOptions<TModule extends AppPageModule = AppPageModule> = {\n error: unknown;\n matchedParams?: AppPageParams | null;\n route?: AppPageBoundaryRoute<TModule> | null;\n sanitizeErrorForClient: (error: Error) => Error;\n} & AppPageBoundaryRenderCommonOptions<TModule>;\n\nfunction getDefaultExport<TModule extends AppPageModule>(\n module: TModule | null | undefined,\n): AppPageComponent | null {\n return module?.default ?? null;\n}\n\nfunction wrapRenderedBoundaryElement<TModule extends AppPageModule>(\n options: Pick<\n AppPageBoundaryRenderCommonOptions<TModule>,\n \"globalErrorModule\" | \"isRscRequest\" | \"makeThenableParams\" | \"resolveChildSegments\"\n > & {\n element: ReactNode;\n includeGlobalErrorBoundary: boolean;\n layoutModules: readonly (TModule | null | undefined)[];\n layoutTreePositions?: readonly number[] | null;\n matchedParams: AppPageParams;\n routeSegments?: readonly string[];\n skipLayoutWrapping?: boolean;\n },\n): ReactNode {\n return wrapAppPageBoundaryElement({\n element: options.element,\n getDefaultExport,\n globalErrorComponent: getDefaultExport(options.globalErrorModule),\n includeGlobalErrorBoundary: options.includeGlobalErrorBoundary,\n isRscRequest: options.isRscRequest,\n layoutModules: options.layoutModules,\n layoutTreePositions: options.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams: options.matchedParams,\n renderErrorBoundary(GlobalErrorComponent, children) {\n return createElement(ErrorBoundary, {\n fallback: GlobalErrorComponent,\n // oxlint-disable-next-line react/no-children-prop\n children,\n });\n },\n renderLayout(LayoutComponent, children, asyncParams) {\n return createElement(LayoutComponent as AppPageComponent, {\n // oxlint-disable-next-line react/no-children-prop\n children,\n params: asyncParams,\n });\n },\n renderLayoutSegmentProvider(segmentMap, children) {\n return createElement(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n LayoutSegmentProvider as ComponentType<any>,\n { segmentMap },\n children,\n );\n },\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.routeSegments ?? [],\n skipLayoutWrapping: options.skipLayoutWrapping,\n });\n}\n\nfunction createAppPageBoundaryLayoutEntries<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly AppPageBoundaryLayoutEntry[] {\n if (!route || layoutModules.length === 0) return [];\n\n return createAppPageLayoutEntries({\n errors: route.errors,\n layoutTreePositions: route.layoutTreePositions,\n layouts: layoutModules,\n notFounds: null,\n routeSegments: route.routeSegments,\n });\n}\n\nfunction resolveHttpAccessFallbackHeadRouteSegments<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly string[] | undefined {\n if (!route?.routeSegments) {\n return undefined;\n }\n\n if (!route.layouts || layoutModules.length >= route.layouts.length) {\n return route.routeSegments;\n }\n\n const lastIncludedLayoutIndex = layoutModules.length - 1;\n if (lastIncludedLayoutIndex < 0) {\n return [];\n }\n\n const segmentCount = route.layoutTreePositions?.[lastIncludedLayoutIndex] ?? 0;\n return route.routeSegments.slice(0, segmentCount);\n}\n\nfunction resolveHttpAccessFallbackHeadLayoutTreePositions<TModule extends AppPageModule>(\n route: AppPageBoundaryRoute<TModule> | null | undefined,\n layoutModules: readonly (TModule | null | undefined)[],\n): readonly number[] | null | undefined {\n if (!route?.layouts || layoutModules.length >= route.layouts.length) {\n return route?.layoutTreePositions;\n }\n\n return route.layoutTreePositions?.slice(0, layoutModules.length);\n}\n\nfunction createAppPageBoundaryRscPayload<TModule extends AppPageModule>(\n options: AppPageBoundaryRscPayloadOptions<TModule>,\n): AppElements {\n const routeId = AppElementsWire.encodeRouteId(options.pathname, null);\n const layoutEntries = createAppPageBoundaryLayoutEntries(options.route, options.layoutModules);\n\n return {\n ...AppElementsWire.createMetadataEntries({\n interceptionContext: null,\n layoutIds: layoutEntries.map((entry) => entry.id),\n rootLayoutTreePath: layoutEntries[0]?.treePath ?? null,\n routeId,\n }),\n [routeId]: options.element,\n };\n}\n\nasync function renderAppPageBoundaryElementResponse<TModule extends AppPageModule>(\n options: AppPageBoundaryRenderCommonOptions<TModule> & {\n element: ReactNode;\n layoutModules: readonly (TModule | null | undefined)[];\n route?: AppPageBoundaryRoute<TModule> | null;\n routePattern?: string;\n status: number;\n },\n): Promise<Response> {\n const pathname = new URL(options.requestUrl).pathname;\n const payload = createAppPageBoundaryRscPayload({\n element: options.element,\n layoutModules: options.layoutModules,\n pathname,\n route: options.route,\n });\n\n return renderAppPageBoundaryResponse({\n async createHtmlResponse(rscStream, responseStatus) {\n const fontData = createAppPageFontData({\n getLinks: options.getFontLinks,\n getPreloads: options.getFontPreloads,\n getStyles: options.getFontStyles,\n });\n const ssrHandler = await options.loadSsrHandler();\n return renderAppPageHtmlResponse({\n clearRequestContext: options.clearRequestContext,\n fontData,\n fontLinkHeader: options.buildFontLinkHeader(fontData.preloads),\n isEdgeRuntime: options.isEdgeRuntime,\n middlewareHeaders: options.middlewareContext.headers,\n navigationContext: options.getNavigationContext(),\n rscStream,\n scriptNonce: options.scriptNonce,\n ssrHandler,\n status: responseStatus,\n });\n },\n createRscOnErrorHandler() {\n return options.createRscOnErrorHandler(pathname, options.routePattern ?? pathname);\n },\n element: payload,\n isEdgeRuntime: options.isEdgeRuntime,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareContext.headers,\n renderToReadableStream: options.renderToReadableStream,\n status: options.status,\n });\n}\n\nexport async function renderAppPageHttpAccessFallback<TModule extends AppPageModule>(\n options: RenderAppPageHttpAccessFallbackOptions<TModule>,\n): Promise<Response | null> {\n const boundaryComponent =\n options.boundaryComponent ??\n resolveAppPageHttpAccessBoundaryComponent({\n getDefaultExport,\n rootForbiddenModule: options.rootForbiddenModule,\n rootNotFoundModule: options.rootNotFoundModule,\n rootUnauthorizedModule: options.rootUnauthorizedModule,\n routeForbiddenModule: options.route?.forbidden,\n routeNotFoundModule: options.route?.notFound,\n routeUnauthorizedModule: options.route?.unauthorized,\n statusCode: options.statusCode,\n });\n if (!boundaryComponent) {\n return null;\n }\n\n const layoutModules = options.layoutModules ?? options.route?.layouts ?? options.rootLayouts;\n const pathname = new URL(options.requestUrl).pathname;\n const routeSegments = resolveHttpAccessFallbackHeadRouteSegments(options.route, layoutModules);\n const { metadata, viewport } = await resolveAppPageHead({\n basePath: options.basePath ?? \"\",\n layoutModules,\n layoutTreePositions: resolveHttpAccessFallbackHeadLayoutTreePositions(\n options.route,\n layoutModules,\n ),\n metadataRoutes: options.metadataRoutes,\n params: options.matchedParams,\n routePath: options.route?.pattern ?? pathname,\n routeSegments,\n });\n\n const headElements: ReactNode[] = [\n createElement(\"meta\", { charSet: \"utf-8\", key: \"charset\" }),\n createElement(\"meta\", { key: \"robots\", name: \"robots\", content: \"noindex\" }),\n ];\n if (metadata) {\n headElements.push(createElement(MetadataHead, { key: \"metadata\", metadata, pathname }));\n }\n headElements.push(createElement(ViewportHead, { key: \"viewport\", viewport }));\n\n const skipLayoutWrapping = options.skipLayoutWrapping ?? false;\n const element = wrapRenderedBoundaryElement({\n element: createElement(Fragment, null, ...headElements, createElement(boundaryComponent)),\n globalErrorModule: options.globalErrorModule,\n includeGlobalErrorBoundary: true,\n isRscRequest: options.isRscRequest,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams: options.matchedParams,\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.route?.routeSegments,\n skipLayoutWrapping,\n });\n\n return renderAppPageBoundaryElementResponse({\n ...options,\n // When global-not-found owns the document, no layouts should contribute to\n // the RSC payload's layout entries either — otherwise the SSR pipeline\n // would expect a root-layout tree path that doesn't exist in the markup.\n element,\n layoutModules: skipLayoutWrapping ? [] : layoutModules,\n route: skipLayoutWrapping ? null : options.route,\n routePattern: options.route?.pattern,\n status: options.statusCode,\n });\n}\n\nexport async function renderAppPageErrorBoundary<TModule extends AppPageModule>(\n options: RenderAppPageErrorBoundaryOptions<TModule>,\n): Promise<Response | null> {\n const errorBoundary = resolveAppPageErrorBoundary({\n getDefaultExport,\n errorModules: options.route?.errorPaths,\n globalErrorModule: options.globalErrorModule,\n layoutErrorModules: options.route?.errors,\n pageErrorModule: options.route?.error,\n });\n if (!errorBoundary.component) {\n return null;\n }\n\n const rawError =\n options.error instanceof Error ? options.error : new Error(String(options.error));\n rewriteClientHookError(rawError);\n const errorObject = options.sanitizeErrorForClient(rawError);\n const matchedParams = options.matchedParams ?? options.route?.params ?? {};\n const layoutModules = options.route?.layouts ?? options.rootLayouts;\n const pathname = new URL(options.requestUrl).pathname;\n\n const headElements: ReactNode[] = [createElement(\"meta\", { charSet: \"utf-8\", key: \"charset\" })];\n if (!errorBoundary.isGlobalError) {\n try {\n const { metadata, viewport } = await resolveAppPageHead({\n basePath: options.basePath ?? \"\",\n fallbackOnFileMetadataError: true,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n metadataRoutes: options.metadataRoutes,\n params: matchedParams,\n routePath: options.route?.pattern ?? pathname,\n routeSegments: options.route?.routeSegments,\n });\n if (metadata) {\n headElements.push(createElement(MetadataHead, { key: \"metadata\", metadata, pathname }));\n }\n headElements.push(createElement(ViewportHead, { key: \"viewport\", viewport }));\n } catch (error) {\n console.error(\n `[vinext] App page error boundary head resolution failed for ${options.route?.pattern ?? pathname}:`,\n error,\n );\n }\n }\n\n const element = wrapRenderedBoundaryElement({\n element: createElement(\n Fragment,\n null,\n ...headElements,\n createElement(errorBoundary.component, {\n error: errorObject,\n }),\n ),\n globalErrorModule: options.globalErrorModule,\n includeGlobalErrorBoundary: !errorBoundary.isGlobalError,\n isRscRequest: options.isRscRequest,\n layoutModules,\n layoutTreePositions: options.route?.layoutTreePositions,\n makeThenableParams: options.makeThenableParams,\n matchedParams,\n resolveChildSegments: options.resolveChildSegments,\n routeSegments: options.route?.routeSegments,\n skipLayoutWrapping: errorBoundary.isGlobalError,\n });\n\n return renderAppPageBoundaryElementResponse({\n ...options,\n element,\n layoutModules,\n route: options.route,\n routePattern: options.route?.pattern,\n status: 200,\n });\n}\n\n// React client-only hooks that are absent from the `react-server` export\n// condition. When called in a Server Component they produce a TypeError like\n// \"useState is not a function\". Rewrite into an actionable message matching\n// the format used by the next/navigation shims (see client-hook-error.ts).\nconst _clientHookPattern =\n /\\b(useState|useEffect|useReducer|useRef|useContext|useLayoutEffect|useInsertionEffect|useSyncExternalStore|useTransition|useImperativeHandle|useDeferredValue|useActionState|useOptimistic|useEffectEvent)\\b.*is not a function/;\n\nfunction rewriteClientHookError(error: Error): void {\n const match = error.message.match(_clientHookPattern);\n if (match) {\n error.message = buildClientHookErrorMessage(`${match[1]}()`);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAsHA,SAAS,iBACP,QACyB;CACzB,OAAO,QAAQ,WAAW;;AAG5B,SAAS,4BACP,SAYW;CACX,OAAO,2BAA2B;EAChC,SAAS,QAAQ;EACjB;EACA,sBAAsB,iBAAiB,QAAQ,kBAAkB;EACjE,4BAA4B,QAAQ;EACpC,cAAc,QAAQ;EACtB,eAAe,QAAQ;EACvB,qBAAqB,QAAQ;EAC7B,oBAAoB,QAAQ;EAC5B,eAA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,oBAAoB,cAAc;EACnC,CAAC;CAEF,OAAO,qCAAqC;EAC1C,GAAG;EACH;EACA;EACA,OAAO,QAAQ;EACf,cAAc,QAAQ,OAAO;EAC7B,QAAQ;EACT,CAAC;;AAOJ,MAAM,qBACJ;AAEF,SAAS,uBAAuB,OAAoB;CAClD,MAAM,QAAQ,MAAM,QAAQ,MAAM,mBAAmB;CACrD,IAAI,OACF,MAAM,UAAU,4BAA4B,GAAG,MAAM,GAAG,IAAI"}
|
|
@@ -65,9 +65,29 @@ type RenderAppPageBoundaryResponseOptions<TElement> = {
|
|
|
65
65
|
};
|
|
66
66
|
declare function resolveAppPageHttpAccessBoundaryComponent<TModule, TComponent>(options: ResolveAppPageHttpAccessBoundaryComponentOptions<TModule, TComponent>): TComponent | null;
|
|
67
67
|
declare function resolveAppPageParentHttpAccessBoundaryModule<TModule>(options: ResolveAppPageParentHttpAccessBoundaryModuleOptions<TModule>): TModule | null;
|
|
68
|
+
/**
|
|
69
|
+
* Like {@link resolveAppPageParentHttpAccessBoundaryModule}, but also returns
|
|
70
|
+
* the layout index that owns the resolved boundary so callers can slice the
|
|
71
|
+
* layouts array to skip rendering layouts below the boundary owner.
|
|
72
|
+
*
|
|
73
|
+
* `layoutIndex` is the per-layout index where the boundary lives, or `null` if
|
|
74
|
+
* the resolved boundary is the root module (which conceptually sits above all
|
|
75
|
+
* layouts when no layout-level boundary is present).
|
|
76
|
+
*
|
|
77
|
+
* Used by the page-error fast path to make `forbidden()` / `unauthorized()` /
|
|
78
|
+
* `notFound()` escalate past intermediate layouts that lack a boundary file,
|
|
79
|
+
* matching Next.js's `create-component-tree.tsx` behavior where the nearest
|
|
80
|
+
* ancestor boundary owns the fallback subtree.
|
|
81
|
+
*
|
|
82
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/create-component-tree.tsx
|
|
83
|
+
*/
|
|
84
|
+
declare function resolveAppPageParentHttpAccessBoundary<TModule>(options: ResolveAppPageParentHttpAccessBoundaryModuleOptions<TModule>): {
|
|
85
|
+
module: TModule | null;
|
|
86
|
+
layoutIndex: number | null;
|
|
87
|
+
};
|
|
68
88
|
declare function resolveAppPageErrorBoundary<TModule, TComponent>(options: ResolveAppPageErrorBoundaryOptions<TModule, TComponent>): ResolveAppPageErrorBoundaryResult<TComponent>;
|
|
69
89
|
declare function wrapAppPageBoundaryElement<TElement, TLayoutModule, TLayoutComponent, TChildSegments, TGlobalErrorComponent>(options: WrapAppPageBoundaryElementOptions<TElement, TLayoutModule, TLayoutComponent, TChildSegments, TGlobalErrorComponent>): TElement;
|
|
70
90
|
declare function renderAppPageBoundaryResponse<TElement>(options: RenderAppPageBoundaryResponseOptions<TElement>): Promise<Response>;
|
|
71
91
|
//#endregion
|
|
72
|
-
export { AppPageParams, renderAppPageBoundaryResponse, resolveAppPageErrorBoundary, resolveAppPageHttpAccessBoundaryComponent, resolveAppPageParentHttpAccessBoundaryModule, wrapAppPageBoundaryElement };
|
|
92
|
+
export { AppPageParams, renderAppPageBoundaryResponse, resolveAppPageErrorBoundary, resolveAppPageHttpAccessBoundaryComponent, resolveAppPageParentHttpAccessBoundary, resolveAppPageParentHttpAccessBoundaryModule, wrapAppPageBoundaryElement };
|
|
73
93
|
//# sourceMappingURL=app-page-boundary.d.ts.map
|