vinext 0.0.51 → 0.0.52
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/dist/build/precompress.d.ts +7 -7
- package/dist/build/precompress.js +18 -17
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +3 -14
- package/dist/build/prerender.js +40 -40
- package/dist/build/prerender.js.map +1 -1
- package/dist/check.js +4 -0
- package/dist/check.js.map +1 -1
- package/dist/cli-args.d.ts +1 -0
- package/dist/cli-args.js +5 -0
- package/dist/cli-args.js.map +1 -1
- package/dist/cli.js +39 -0
- package/dist/cli.js.map +1 -1
- package/dist/client/navigation-runtime.d.ts +47 -0
- package/dist/client/navigation-runtime.js +156 -0
- package/dist/client/navigation-runtime.js.map +1 -0
- package/dist/client/pages-router-link-navigation.d.ts +26 -0
- package/dist/client/pages-router-link-navigation.js +14 -0
- package/dist/client/pages-router-link-navigation.js.map +1 -0
- package/dist/client/vinext-next-data.d.ts +12 -2
- package/dist/client/vinext-next-data.js +50 -1
- package/dist/client/vinext-next-data.js.map +1 -0
- package/dist/cloudflare/kv-cache-handler.js +2 -1
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/config/config-matchers.d.ts +63 -16
- package/dist/config/config-matchers.js +143 -8
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/next-config.d.ts +20 -2
- package/dist/config/next-config.js +11 -1
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.js +101 -39
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.js +9 -3
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.js +53 -13
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +1 -0
- package/dist/entries/app-rsc-manifest.js +53 -6
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/app-ssr-entry.d.ts +3 -3
- package/dist/entries/app-ssr-entry.js +4 -4
- package/dist/entries/app-ssr-entry.js.map +1 -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 +58 -8
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.d.ts +2 -1
- package/dist/entries/runtime-entry-module.js +9 -3
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +132 -40
- package/dist/index.js.map +1 -1
- package/dist/plugins/css-data-url.d.ts +7 -0
- package/dist/plugins/css-data-url.js +81 -0
- package/dist/plugins/css-data-url.js.map +1 -0
- package/dist/plugins/fonts.js +5 -3
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/middleware-server-only.d.ts +54 -0
- package/dist/plugins/middleware-server-only.js +91 -0
- package/dist/plugins/middleware-server-only.js.map +1 -0
- package/dist/plugins/optimize-imports.js +4 -4
- package/dist/plugins/optimize-imports.js.map +1 -1
- package/dist/plugins/strip-server-exports.js +5 -8
- package/dist/plugins/strip-server-exports.js.map +1 -1
- package/dist/routing/app-route-graph.d.ts +20 -1
- package/dist/routing/app-route-graph.js +58 -6
- 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/utils.d.ts +2 -1
- package/dist/routing/utils.js +4 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js +139 -37
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-entry.js +293 -149
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +32 -0
- package/dist/server/app-browser-interception-context.js.map +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +3 -1
- package/dist/server/app-browser-navigation-controller.js +5 -1
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-rsc-redirect.d.ts +2 -1
- package/dist/server/app-browser-rsc-redirect.js +2 -2
- package/dist/server/app-browser-rsc-redirect.js.map +1 -1
- package/dist/server/app-browser-state.d.ts +18 -1
- package/dist/server/app-browser-state.js +19 -1
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +5 -14
- package/dist/server/app-browser-stream.js +13 -7
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +2 -1
- package/dist/server/app-browser-visible-commit.js +1 -0
- package/dist/server/app-browser-visible-commit.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +10 -5
- package/dist/server/app-elements-wire.js +84 -2
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +3 -2
- package/dist/server/app-elements.js +3 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.js +5 -3
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-middleware.d.ts +13 -0
- package/dist/server/app-middleware.js +3 -1
- package/dist/server/app-middleware.js.map +1 -1
- package/dist/server/app-optimistic-routing.d.ts +54 -0
- package/dist/server/app-optimistic-routing.js +200 -0
- package/dist/server/app-optimistic-routing.js.map +1 -0
- package/dist/server/app-page-cache.d.ts +13 -1
- package/dist/server/app-page-cache.js +61 -6
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +2 -0
- package/dist/server/app-page-dispatch.js +28 -1
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.js +2 -1
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +28 -1
- package/dist/server/app-page-execution.js +89 -4
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.js +21 -2
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-probe.js +1 -1
- package/dist/server/app-page-render.d.ts +2 -0
- package/dist/server/app-page-render.js +2 -1
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-response.js +4 -3
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.js +17 -10
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +3 -0
- package/dist/server/app-page-stream.js +1 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-prerender-static-params.d.ts +2 -1
- package/dist/server/app-prerender-static-params.js +44 -8
- package/dist/server/app-prerender-static-params.js.map +1 -1
- package/dist/server/app-route-handler-cache.d.ts +2 -2
- package/dist/server/app-route-handler-cache.js +3 -2
- package/dist/server/app-route-handler-cache.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.d.ts +6 -1
- package/dist/server/app-route-handler-dispatch.js +1 -1
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.d.ts +17 -2
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-response.js +5 -4
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-router-entry.js +6 -2
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +9 -1
- package/dist/server/app-rsc-handler.js +32 -14
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-render-mode.d.ts +4 -3
- package/dist/server/app-rsc-render-mode.js +7 -1
- package/dist/server/app-rsc-render-mode.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.d.ts +4 -1
- package/dist/server/app-rsc-request-normalization.js +4 -1
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-rsc-response-finalizer.d.ts +8 -1
- package/dist/server/app-rsc-response-finalizer.js +10 -3
- package/dist/server/app-rsc-response-finalizer.js.map +1 -1
- package/dist/server/app-rsc-route-matching.js +2 -2
- package/dist/server/app-rsc-route-matching.js.map +1 -1
- package/dist/server/app-server-action-execution.js +1 -1
- package/dist/server/app-ssr-entry.d.ts +2 -0
- package/dist/server/app-ssr-entry.js +56 -55
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +6 -1
- package/dist/server/app-ssr-stream.js +17 -3
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/artifact-compatibility.d.ts +1 -1
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/cache-headers.d.ts +7 -0
- package/dist/server/cache-headers.js +19 -0
- package/dist/server/cache-headers.js.map +1 -0
- package/dist/server/cache-proof.d.ts +49 -3
- package/dist/server/cache-proof.js +78 -22
- package/dist/server/cache-proof.js.map +1 -1
- package/dist/server/client-reuse-manifest.d.ts +99 -0
- package/dist/server/client-reuse-manifest.js +212 -0
- package/dist/server/client-reuse-manifest.js.map +1 -0
- package/dist/server/default-global-error-module.d.ts +20 -0
- package/dist/server/default-global-error-module.js +20 -0
- package/dist/server/default-global-error-module.js.map +1 -0
- package/dist/server/dev-server.d.ts +9 -1
- package/dist/server/dev-server.js +76 -29
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/edge-api-runtime.d.ts +5 -0
- package/dist/server/edge-api-runtime.js +8 -0
- package/dist/server/edge-api-runtime.js.map +1 -0
- package/dist/server/headers.d.ts +18 -1
- package/dist/server/headers.js +18 -1
- package/dist/server/headers.js.map +1 -1
- package/dist/server/http-error-responses.d.ts +16 -1
- package/dist/server/http-error-responses.js +21 -1
- package/dist/server/http-error-responses.js.map +1 -1
- package/dist/server/isr-cache.d.ts +6 -2
- package/dist/server/isr-cache.js +20 -4
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/middleware-runtime.d.ts +15 -0
- package/dist/server/middleware-runtime.js +59 -7
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.js +4 -2
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/navigation-planner.d.ts +9 -3
- package/dist/server/navigation-planner.js +98 -25
- package/dist/server/navigation-planner.js.map +1 -1
- package/dist/server/navigation-trace.d.ts +2 -1
- package/dist/server/navigation-trace.js +1 -0
- package/dist/server/navigation-trace.js.map +1 -1
- package/dist/server/pages-api-route.d.ts +27 -1
- package/dist/server/pages-api-route.js +24 -3
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-data-route.d.ts +77 -0
- package/dist/server/pages-data-route.js +97 -0
- package/dist/server/pages-data-route.js.map +1 -0
- package/dist/server/pages-i18n.d.ts +51 -1
- package/dist/server/pages-i18n.js +61 -1
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +29 -2
- package/dist/server/pages-page-data.js +31 -17
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.d.ts +11 -1
- package/dist/server/pages-page-response.js +5 -3
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prod-server.d.ts +13 -15
- package/dist/server/prod-server.js +109 -56
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +11 -2
- package/dist/server/request-pipeline.js +28 -11
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/seed-cache.d.ts +12 -31
- package/dist/server/seed-cache.js +22 -35
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/server-action-not-found.js +8 -3
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/skip-cache-proof.d.ts +41 -0
- package/dist/server/skip-cache-proof.js +101 -0
- package/dist/server/skip-cache-proof.js.map +1 -0
- package/dist/server/static-file-cache.d.ts +1 -1
- package/dist/server/static-file-cache.js +7 -6
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/shims/client-locale.d.ts +15 -0
- package/dist/shims/client-locale.js +13 -0
- package/dist/shims/client-locale.js.map +1 -0
- package/dist/shims/default-global-error.d.ts +32 -0
- package/dist/shims/default-global-error.js +181 -0
- package/dist/shims/default-global-error.js.map +1 -0
- package/dist/shims/document.d.ts +59 -3
- package/dist/shims/document.js +36 -5
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +2 -2
- package/dist/shims/form.js +13 -6
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/link.d.ts +21 -3
- package/dist/shims/link.js +131 -22
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.js +4 -4
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +8 -2
- package/dist/shims/navigation.js +36 -15
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/og.d.ts +18 -2
- package/dist/shims/og.js +49 -1
- package/dist/shims/og.js.map +1 -0
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/root-params.d.ts +3 -1
- package/dist/shims/root-params.js +11 -3
- package/dist/shims/root-params.js.map +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +12 -5
- package/dist/shims/router.js +172 -22
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/server.d.ts +21 -4
- package/dist/shims/server.js +29 -9
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.js +5 -1
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/url-safety.d.ts +23 -1
- package/dist/shims/url-safety.js +29 -2
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/typegen.d.ts +10 -0
- package/dist/typegen.js +242 -0
- package/dist/typegen.js.map +1 -0
- package/dist/utils/asset-prefix.d.ts +33 -5
- package/dist/utils/asset-prefix.js +39 -6
- package/dist/utils/asset-prefix.js.map +1 -1
- package/dist/utils/cache-control-metadata.d.ts +2 -1
- package/dist/utils/cache-control-metadata.js +1 -3
- package/dist/utils/cache-control-metadata.js.map +1 -1
- package/dist/utils/domain-locale.d.ts +2 -1
- package/dist/utils/domain-locale.js +9 -1
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/lazy-chunks.d.ts +1 -1
- package/dist/utils/lazy-chunks.js +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/dist/utils/prerender-output-paths.d.ts +15 -0
- package/dist/utils/prerender-output-paths.js +24 -0
- package/dist/utils/prerender-output-paths.js.map +1 -0
- package/dist/utils/query.d.ts +17 -1
- package/dist/utils/query.js +36 -1
- package/dist/utils/query.js.map +1 -1
- package/dist/utils/record.d.ts +5 -0
- package/dist/utils/record.js +8 -0
- package/dist/utils/record.js.map +1 -0
- package/package.json +11 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-browser-visible-commit.js","names":["_exhaustive"],"sources":["../../src/server/app-browser-visible-commit.ts"],"sourcesContent":["import type { ClientNavigationRenderSnapshot } from \"vinext/shims/navigation\";\nimport type { RouteManifest } from \"../routing/app-route-graph.js\";\nimport { mergeElements } from \"vinext/shims/slot\";\nimport {\n normalizeAppElementsSlotBindings,\n type AppElements,\n type AppElementsSlotBinding,\n} from \"./app-elements.js\";\nimport {\n createPendingNavigationCommit,\n resolvePendingNavigationCommitDispositionDecision,\n type AppRouterAction,\n type AppRouterState,\n type CommittedOperationRecord,\n type OperationLane,\n type PendingNavigationCommit,\n type PendingOperationRecord,\n} from \"./app-browser-state.js\";\nimport {\n NavigationTraceReasonCodes,\n NavigationTraceTransactionCodes,\n createNavigationTrace,\n prependNavigationTraceEntry,\n type NavigationTrace,\n type NavigationTraceFields,\n type NavigationTraceTransactionCode,\n} from \"./navigation-trace.js\";\n\ntype VisibleCommitDecision = {\n disposition: \"commit\";\n preserveAbsentSlots: boolean;\n preserveElementIds: readonly string[];\n preservePreviousSlotIds: readonly string[];\n trace: NavigationTrace;\n};\ntype HardNavigateCommitDecision = {\n disposition: \"hard-navigate\";\n trace: NavigationTrace;\n};\ntype NoCommitDecision = {\n disposition: \"no-commit\";\n trace: NavigationTrace;\n};\ntype CommitDecision = VisibleCommitDecision | HardNavigateCommitDecision | NoCommitDecision;\nconst approvedVisibleCommitBrand: unique symbol = Symbol(\"ApprovedVisibleCommit\");\nexport type ApprovedVisibleCommit = {\n readonly [approvedVisibleCommitBrand]: true;\n readonly action: AppRouterAction;\n readonly decision: VisibleCommitDecision;\n readonly interception: AppRouterAction[\"interception\"];\n readonly interceptionContext: string | null;\n readonly previousNextUrl: string | null;\n readonly rootLayoutTreePath: string | null;\n readonly routeId: string;\n};\ntype VisibleCommitApproval = {\n approvedCommit: ApprovedVisibleCommit;\n decision: VisibleCommitDecision;\n};\ntype NonVisibleCommitApproval = {\n approvedCommit: null;\n decision: HardNavigateCommitDecision | NoCommitDecision;\n};\ntype CommitApproval = VisibleCommitApproval | NonVisibleCommitApproval;\ntype ClassifiedPendingNavigationCommit = {\n approvedCommit: ApprovedVisibleCommit | null;\n decision: CommitDecision;\n pending: PendingNavigationCommit;\n trace: NavigationTrace;\n};\n\nexport function applyApprovedVisibleCommit(\n state: AppRouterState,\n commit: ApprovedVisibleCommit,\n): AppRouterState {\n assertApprovedVisibleCommit(commit);\n return reduceApprovedVisibleCommitState(state, commit);\n}\n\nfunction assertApprovedVisibleCommit(commit: ApprovedVisibleCommit): void {\n if (commit[approvedVisibleCommitBrand] !== true) {\n throw new Error(\"[vinext] Visible router state mutation requires ApprovedVisibleCommit\");\n }\n}\n\nfunction commitOperationRecord(\n operation: PendingOperationRecord,\n visibleCommitVersion: number,\n): CommittedOperationRecord {\n return {\n id: operation.id,\n lane: operation.lane,\n startedVisibleCommitVersion: operation.startedVisibleCommitVersion,\n state: \"committed\",\n visibleCommitVersion,\n };\n}\n\nfunction commitVisibleRouterState(\n state: AppRouterState,\n nextState: Omit<AppRouterState, \"activeOperation\" | \"visibleCommitVersion\">,\n operation: PendingOperationRecord,\n): AppRouterState {\n // Single owner for visibleCommitVersion: only an ApprovedVisibleCommit may\n // advance it, and every accepted visible mutation advances it exactly once.\n const visibleCommitVersion = state.visibleCommitVersion + 1;\n return {\n ...nextState,\n activeOperation: commitOperationRecord(operation, visibleCommitVersion),\n visibleCommitVersion,\n };\n}\n\nfunction mergeSlotBindings(\n previousBindings: readonly AppElementsSlotBinding[],\n nextBindings: readonly AppElementsSlotBinding[],\n layoutIds: readonly string[],\n preservePreviousSlotIds: readonly string[],\n): readonly AppElementsSlotBinding[] {\n if (preservePreviousSlotIds.length === 0) return nextBindings;\n\n const preservedSlotIds = new Set(preservePreviousSlotIds);\n const previousBindingsBySlotId = new Map<string, AppElementsSlotBinding>();\n for (const binding of previousBindings) {\n if (!preservedSlotIds.has(binding.slotId)) continue;\n previousBindingsBySlotId.set(binding.slotId, binding);\n }\n\n const mergedBindings: AppElementsSlotBinding[] = [];\n const seenSlotIds = new Set<string>();\n for (const binding of nextBindings) {\n const previousBinding = previousBindingsBySlotId.get(binding.slotId);\n mergedBindings.push(previousBinding ?? binding);\n seenSlotIds.add(binding.slotId);\n }\n for (const slotId of preservePreviousSlotIds) {\n if (seenSlotIds.has(slotId)) continue;\n const previousBinding = previousBindingsBySlotId.get(slotId);\n if (previousBinding) mergedBindings.push(previousBinding);\n }\n return normalizeAppElementsSlotBindings(mergedBindings, { layoutIds });\n}\n\nfunction reduceApprovedVisibleCommitState(\n state: AppRouterState,\n commit: ApprovedVisibleCommit,\n): AppRouterState {\n const { action } = commit;\n switch (action.type) {\n case \"traverse\":\n case \"navigate\":\n return commitVisibleRouterState(\n state,\n {\n elements: mergeElements(state.elements, action.elements, {\n clearAbsentSlots: action.type === \"traverse\",\n preserveAbsentSlots: commit.decision.preserveAbsentSlots,\n preserveElementIds: commit.decision.preserveElementIds,\n preservePreviousSlotIds: commit.decision.preservePreviousSlotIds,\n }),\n interception: action.interception,\n interceptionContext: action.interceptionContext,\n layoutFlags: mergeLayoutFlags(\n state.layoutFlags,\n action.layoutFlags,\n commit.decision.preserveElementIds,\n ),\n layoutIds: action.layoutIds,\n navigationSnapshot: action.navigationSnapshot,\n previousNextUrl: action.previousNextUrl,\n renderId: action.renderId,\n rootLayoutTreePath: action.rootLayoutTreePath,\n routeId: action.routeId,\n slotBindings: mergeSlotBindings(\n state.slotBindings,\n action.slotBindings,\n action.layoutIds,\n commit.decision.preservePreviousSlotIds,\n ),\n },\n action.operation,\n );\n case \"replace\":\n return commitVisibleRouterState(\n state,\n {\n elements: action.elements,\n interception: action.interception,\n interceptionContext: action.interceptionContext,\n layoutFlags: action.layoutFlags,\n layoutIds: action.layoutIds,\n navigationSnapshot: action.navigationSnapshot,\n previousNextUrl: action.previousNextUrl,\n renderId: action.renderId,\n rootLayoutTreePath: action.rootLayoutTreePath,\n routeId: action.routeId,\n slotBindings: action.slotBindings,\n },\n action.operation,\n );\n default: {\n const _exhaustive: never = action.type;\n throw new Error(\"[vinext] Unknown router action: \" + String(_exhaustive));\n }\n }\n}\n\nfunction resolvePendingNavigationCommitDecision(options: {\n activeNavigationId: number;\n currentState: AppRouterState;\n pending: PendingNavigationCommit;\n routeManifest?: RouteManifest | null;\n startedNavigationId: number;\n targetHref: string;\n}): CommitDecision {\n const decision = resolvePendingNavigationCommitDispositionDecision(options);\n\n switch (decision.disposition) {\n case \"skip\":\n return { disposition: \"no-commit\", trace: decision.trace };\n case \"hard-navigate\":\n return { disposition: \"hard-navigate\", trace: decision.trace };\n case \"dispatch\":\n return createVisibleCommitDecision(\n decision.trace,\n decision.preserveElementIds,\n decision.preserveAbsentSlots,\n decision.preservePreviousSlotIds,\n );\n default: {\n const _exhaustive: never = decision;\n throw new Error(\"[vinext] Unknown navigation commit disposition: \" + String(_exhaustive));\n }\n }\n}\n\nfunction createVisibleCommitDecision(\n trace: NavigationTrace = createNavigationTrace(NavigationTraceReasonCodes.commitCurrent),\n preserveElementIds: readonly string[] = [],\n preserveAbsentSlots: boolean = false,\n preservePreviousSlotIds: readonly string[] = [],\n): VisibleCommitDecision {\n return {\n disposition: \"commit\",\n preserveAbsentSlots,\n preserveElementIds: [...preserveElementIds],\n preservePreviousSlotIds: [...preservePreviousSlotIds],\n trace,\n };\n}\n\nfunction mergeLayoutFlags(\n previousFlags: AppRouterState[\"layoutFlags\"],\n nextFlags: AppRouterState[\"layoutFlags\"],\n preserveElementIds: readonly string[],\n): AppRouterState[\"layoutFlags\"] {\n const merged: Record<string, \"s\" | \"d\"> = { ...nextFlags };\n for (const id of preserveElementIds) {\n if (Object.hasOwn(merged, id)) continue;\n const value = previousFlags[id];\n if (value) merged[id] = value;\n }\n return merged;\n}\n\nfunction createApprovedVisibleCommit(options: {\n decision: VisibleCommitDecision;\n pending: PendingNavigationCommit;\n}): ApprovedVisibleCommit {\n return {\n [approvedVisibleCommitBrand]: true,\n action: options.pending.action,\n decision: options.decision,\n interception: options.pending.interception,\n interceptionContext: options.pending.interceptionContext,\n previousNextUrl: options.pending.previousNextUrl,\n rootLayoutTreePath: options.pending.rootLayoutTreePath,\n routeId: options.pending.routeId,\n };\n}\n\nfunction createCommitTransactionFields(pending: PendingNavigationCommit): NavigationTraceFields {\n return {\n operationLane: pending.action.operation.lane,\n pendingOperationId: pending.action.operation.id,\n startedVisibleCommitVersion: pending.action.operation.startedVisibleCommitVersion,\n };\n}\n\nfunction prependCommitTransactionTrace(\n trace: NavigationTrace,\n code: NavigationTraceTransactionCode,\n pending: PendingNavigationCommit,\n): NavigationTrace {\n return prependNavigationTraceEntry(trace, code, createCommitTransactionFields(pending));\n}\n\nfunction addCommitTransactionTrace(\n decision: CommitDecision,\n pending: PendingNavigationCommit,\n): CommitDecision {\n switch (decision.disposition) {\n case \"commit\":\n return {\n ...decision,\n trace: prependCommitTransactionTrace(\n decision.trace,\n NavigationTraceTransactionCodes.visibleCommit,\n pending,\n ),\n };\n case \"hard-navigate\":\n return {\n ...decision,\n trace: prependCommitTransactionTrace(\n decision.trace,\n NavigationTraceTransactionCodes.hardNavigate,\n pending,\n ),\n };\n case \"no-commit\":\n return {\n ...decision,\n trace: prependCommitTransactionTrace(\n decision.trace,\n NavigationTraceTransactionCodes.noCommit,\n pending,\n ),\n };\n default: {\n const _exhaustive: never = decision;\n throw new Error(\"[vinext] Unknown commit decision: \" + String(_exhaustive));\n }\n }\n}\n\nexport function approveHmrVisibleCommit(pending: PendingNavigationCommit): ApprovedVisibleCommit {\n if (pending.action.operation.lane !== \"hmr\") {\n throw new Error(\"[vinext] HMR visible commit approval requires an HMR pending operation\");\n }\n\n const decision = addCommitTransactionTrace(createVisibleCommitDecision(), pending);\n // This guard is a type narrowing assertion: createVisibleCommitDecision()\n // structurally produces a commit decision, and addCommitTransactionTrace()\n // must preserve that disposition while adding operator trace context.\n if (decision.disposition !== \"commit\") {\n throw new Error(\"[vinext] HMR visible commit approval did not produce a commit decision\");\n }\n\n return createApprovedVisibleCommit({\n decision,\n pending,\n });\n}\n\nexport function approvePendingNavigationCommit(options: {\n activeNavigationId: number;\n currentState: AppRouterState;\n pending: PendingNavigationCommit;\n routeManifest?: RouteManifest | null;\n startedNavigationId: number;\n targetHref: string;\n}): CommitApproval {\n const decision = addCommitTransactionTrace(\n resolvePendingNavigationCommitDecision({\n activeNavigationId: options.activeNavigationId,\n currentState: options.currentState,\n pending: options.pending,\n routeManifest: options.routeManifest ?? null,\n startedNavigationId: options.startedNavigationId,\n targetHref: options.targetHref,\n }),\n options.pending,\n );\n\n switch (decision.disposition) {\n case \"commit\":\n return {\n approvedCommit: createApprovedVisibleCommit({\n decision,\n pending: options.pending,\n }),\n decision,\n };\n case \"hard-navigate\":\n case \"no-commit\":\n return {\n approvedCommit: null,\n decision,\n };\n default: {\n const _exhaustive: never = decision;\n throw new Error(\"[vinext] Unknown commit decision: \" + String(_exhaustive));\n }\n }\n}\n\nexport async function resolveAndClassifyNavigationCommit(options: {\n activeNavigationId: number;\n currentState: AppRouterState;\n // When provided, these getters are called after awaiting nextElements so\n // approval uses the latest lifecycle authority instead of the call snapshot.\n getActiveNavigationId?: () => number;\n getCurrentStateForApproval?: () => AppRouterState;\n navigationSnapshot: ClientNavigationRenderSnapshot;\n nextElements: Promise<AppElements>;\n operationLane: OperationLane;\n previousNextUrl?: string | null;\n renderId: number;\n routeManifest?: RouteManifest | null;\n startedNavigationId: number;\n targetHref: string;\n type: \"navigate\" | \"replace\" | \"traverse\";\n}): Promise<ClassifiedPendingNavigationCommit> {\n const pending = await createPendingNavigationCommit({\n currentState: options.currentState,\n nextElements: options.nextElements,\n navigationSnapshot: options.navigationSnapshot,\n operationLane: options.operationLane,\n previousNextUrl: options.previousNextUrl,\n renderId: options.renderId,\n type: options.type,\n });\n\n const approvalState = options.getCurrentStateForApproval?.() ?? options.currentState;\n const approval = approvePendingNavigationCommit({\n activeNavigationId: options.getActiveNavigationId?.() ?? options.activeNavigationId,\n currentState: approvalState,\n pending,\n routeManifest: options.routeManifest ?? null,\n startedNavigationId: options.startedNavigationId,\n targetHref: options.targetHref,\n });\n\n return {\n approvedCommit: approval.approvedCommit,\n decision: approval.decision,\n pending,\n trace: approval.decision.trace,\n };\n}\n"],"mappings":";;;;;;AA4CA,MAAM,6BAA4C,OAAO,wBAAwB;AA2BjF,SAAgB,2BACd,OACA,QACgB;CAChB,4BAA4B,OAAO;CACnC,OAAO,iCAAiC,OAAO,OAAO;;AAGxD,SAAS,4BAA4B,QAAqC;CACxE,IAAI,OAAO,gCAAgC,MACzC,MAAM,IAAI,MAAM,wEAAwE;;AAI5F,SAAS,sBACP,WACA,sBAC0B;CAC1B,OAAO;EACL,IAAI,UAAU;EACd,MAAM,UAAU;EAChB,6BAA6B,UAAU;EACvC,OAAO;EACP;EACD;;AAGH,SAAS,yBACP,OACA,WACA,WACgB;CAGhB,MAAM,uBAAuB,MAAM,uBAAuB;CAC1D,OAAO;EACL,GAAG;EACH,iBAAiB,sBAAsB,WAAW,qBAAqB;EACvE;EACD;;AAGH,SAAS,kBACP,kBACA,cACA,WACA,yBACmC;CACnC,IAAI,wBAAwB,WAAW,GAAG,OAAO;CAEjD,MAAM,mBAAmB,IAAI,IAAI,wBAAwB;CACzD,MAAM,2CAA2B,IAAI,KAAqC;CAC1E,KAAK,MAAM,WAAW,kBAAkB;EACtC,IAAI,CAAC,iBAAiB,IAAI,QAAQ,OAAO,EAAE;EAC3C,yBAAyB,IAAI,QAAQ,QAAQ,QAAQ;;CAGvD,MAAM,iBAA2C,EAAE;CACnD,MAAM,8BAAc,IAAI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MAAM,UAAU,MAAM,8BAA8B;EAClD,cAAc,QAAQ;EACtB,cAAc,QAAQ;EACtB,oBAAoB,QAAQ;EAC5B,eAAe,QAAQ;EACvB,iBAAiB,QAAQ;EACzB,UAAU,QAAQ;EAClB,MAAM,QAAQ;EACf,CAAC;CAEF,MAAM,gBAAgB,QAAQ,8BAA8B,IAAI,QAAQ;CACxE,MAAM,WAAW,+BAA+B;EAC9C,oBAAoB,QAAQ,yBAAyB,IAAI,QAAQ;EACjE,cAAc;EACd;EACA,eAAe,QAAQ,iBAAiB;EACxC,qBAAqB,QAAQ;EAC7B,YAAY,QAAQ;EACrB,CAAC;CAEF,OAAO;EACL,gBAAgB,SAAS;EACzB,UAAU,SAAS;EACnB;EACA,OAAO,SAAS,SAAS;EAC1B"}
|
|
1
|
+
{"version":3,"file":"app-browser-visible-commit.js","names":["_exhaustive"],"sources":["../../src/server/app-browser-visible-commit.ts"],"sourcesContent":["import type { ClientNavigationRenderSnapshot } from \"vinext/shims/navigation\";\nimport type { RouteManifest } from \"../routing/app-route-graph.js\";\nimport { mergeElements } from \"vinext/shims/slot\";\nimport {\n normalizeAppElementsSlotBindings,\n type AppElements,\n type AppElementsSlotBinding,\n} from \"./app-elements.js\";\nimport {\n createPendingNavigationCommit,\n resolvePendingNavigationCommitDispositionDecision,\n type AppNavigationPayloadOrigin,\n type AppRouterAction,\n type AppRouterState,\n type CommittedOperationRecord,\n type OperationLane,\n type PendingNavigationCommit,\n type PendingOperationRecord,\n} from \"./app-browser-state.js\";\nimport {\n NavigationTraceReasonCodes,\n NavigationTraceTransactionCodes,\n createNavigationTrace,\n prependNavigationTraceEntry,\n type NavigationTrace,\n type NavigationTraceFields,\n type NavigationTraceTransactionCode,\n} from \"./navigation-trace.js\";\n\ntype VisibleCommitDecision = {\n disposition: \"commit\";\n preserveAbsentSlots: boolean;\n preserveElementIds: readonly string[];\n preservePreviousSlotIds: readonly string[];\n trace: NavigationTrace;\n};\ntype HardNavigateCommitDecision = {\n disposition: \"hard-navigate\";\n trace: NavigationTrace;\n};\ntype NoCommitDecision = {\n disposition: \"no-commit\";\n trace: NavigationTrace;\n};\ntype CommitDecision = VisibleCommitDecision | HardNavigateCommitDecision | NoCommitDecision;\nconst approvedVisibleCommitBrand: unique symbol = Symbol(\"ApprovedVisibleCommit\");\nexport type ApprovedVisibleCommit = {\n readonly [approvedVisibleCommitBrand]: true;\n readonly action: AppRouterAction;\n readonly decision: VisibleCommitDecision;\n readonly interception: AppRouterAction[\"interception\"];\n readonly interceptionContext: string | null;\n readonly previousNextUrl: string | null;\n readonly rootLayoutTreePath: string | null;\n readonly routeId: string;\n};\ntype VisibleCommitApproval = {\n approvedCommit: ApprovedVisibleCommit;\n decision: VisibleCommitDecision;\n};\ntype NonVisibleCommitApproval = {\n approvedCommit: null;\n decision: HardNavigateCommitDecision | NoCommitDecision;\n};\ntype CommitApproval = VisibleCommitApproval | NonVisibleCommitApproval;\ntype ClassifiedPendingNavigationCommit = {\n approvedCommit: ApprovedVisibleCommit | null;\n decision: CommitDecision;\n pending: PendingNavigationCommit;\n trace: NavigationTrace;\n};\n\nexport function applyApprovedVisibleCommit(\n state: AppRouterState,\n commit: ApprovedVisibleCommit,\n): AppRouterState {\n assertApprovedVisibleCommit(commit);\n return reduceApprovedVisibleCommitState(state, commit);\n}\n\nfunction assertApprovedVisibleCommit(commit: ApprovedVisibleCommit): void {\n if (commit[approvedVisibleCommitBrand] !== true) {\n throw new Error(\"[vinext] Visible router state mutation requires ApprovedVisibleCommit\");\n }\n}\n\nfunction commitOperationRecord(\n operation: PendingOperationRecord,\n visibleCommitVersion: number,\n): CommittedOperationRecord {\n return {\n id: operation.id,\n lane: operation.lane,\n startedVisibleCommitVersion: operation.startedVisibleCommitVersion,\n state: \"committed\",\n visibleCommitVersion,\n };\n}\n\nfunction commitVisibleRouterState(\n state: AppRouterState,\n nextState: Omit<AppRouterState, \"activeOperation\" | \"visibleCommitVersion\">,\n operation: PendingOperationRecord,\n): AppRouterState {\n // Single owner for visibleCommitVersion: only an ApprovedVisibleCommit may\n // advance it, and every accepted visible mutation advances it exactly once.\n const visibleCommitVersion = state.visibleCommitVersion + 1;\n return {\n ...nextState,\n activeOperation: commitOperationRecord(operation, visibleCommitVersion),\n visibleCommitVersion,\n };\n}\n\nfunction mergeSlotBindings(\n previousBindings: readonly AppElementsSlotBinding[],\n nextBindings: readonly AppElementsSlotBinding[],\n layoutIds: readonly string[],\n preservePreviousSlotIds: readonly string[],\n): readonly AppElementsSlotBinding[] {\n if (preservePreviousSlotIds.length === 0) return nextBindings;\n\n const preservedSlotIds = new Set(preservePreviousSlotIds);\n const previousBindingsBySlotId = new Map<string, AppElementsSlotBinding>();\n for (const binding of previousBindings) {\n if (!preservedSlotIds.has(binding.slotId)) continue;\n previousBindingsBySlotId.set(binding.slotId, binding);\n }\n\n const mergedBindings: AppElementsSlotBinding[] = [];\n const seenSlotIds = new Set<string>();\n for (const binding of nextBindings) {\n const previousBinding = previousBindingsBySlotId.get(binding.slotId);\n mergedBindings.push(previousBinding ?? binding);\n seenSlotIds.add(binding.slotId);\n }\n for (const slotId of preservePreviousSlotIds) {\n if (seenSlotIds.has(slotId)) continue;\n const previousBinding = previousBindingsBySlotId.get(slotId);\n if (previousBinding) mergedBindings.push(previousBinding);\n }\n return normalizeAppElementsSlotBindings(mergedBindings, { layoutIds });\n}\n\nfunction reduceApprovedVisibleCommitState(\n state: AppRouterState,\n commit: ApprovedVisibleCommit,\n): AppRouterState {\n const { action } = commit;\n switch (action.type) {\n case \"traverse\":\n case \"navigate\":\n return commitVisibleRouterState(\n state,\n {\n elements: mergeElements(state.elements, action.elements, {\n clearAbsentSlots: action.type === \"traverse\",\n preserveAbsentSlots: commit.decision.preserveAbsentSlots,\n preserveElementIds: commit.decision.preserveElementIds,\n preservePreviousSlotIds: commit.decision.preservePreviousSlotIds,\n }),\n interception: action.interception,\n interceptionContext: action.interceptionContext,\n layoutFlags: mergeLayoutFlags(\n state.layoutFlags,\n action.layoutFlags,\n commit.decision.preserveElementIds,\n ),\n layoutIds: action.layoutIds,\n navigationSnapshot: action.navigationSnapshot,\n previousNextUrl: action.previousNextUrl,\n renderId: action.renderId,\n rootLayoutTreePath: action.rootLayoutTreePath,\n routeId: action.routeId,\n slotBindings: mergeSlotBindings(\n state.slotBindings,\n action.slotBindings,\n action.layoutIds,\n commit.decision.preservePreviousSlotIds,\n ),\n },\n action.operation,\n );\n case \"replace\":\n return commitVisibleRouterState(\n state,\n {\n elements: action.elements,\n interception: action.interception,\n interceptionContext: action.interceptionContext,\n layoutFlags: action.layoutFlags,\n layoutIds: action.layoutIds,\n navigationSnapshot: action.navigationSnapshot,\n previousNextUrl: action.previousNextUrl,\n renderId: action.renderId,\n rootLayoutTreePath: action.rootLayoutTreePath,\n routeId: action.routeId,\n slotBindings: action.slotBindings,\n },\n action.operation,\n );\n default: {\n const _exhaustive: never = action.type;\n throw new Error(\"[vinext] Unknown router action: \" + String(_exhaustive));\n }\n }\n}\n\nfunction resolvePendingNavigationCommitDecision(options: {\n activeNavigationId: number;\n currentState: AppRouterState;\n pending: PendingNavigationCommit;\n routeManifest?: RouteManifest | null;\n startedNavigationId: number;\n targetHref: string;\n}): CommitDecision {\n const decision = resolvePendingNavigationCommitDispositionDecision(options);\n\n switch (decision.disposition) {\n case \"skip\":\n return { disposition: \"no-commit\", trace: decision.trace };\n case \"hard-navigate\":\n return { disposition: \"hard-navigate\", trace: decision.trace };\n case \"dispatch\":\n return createVisibleCommitDecision(\n decision.trace,\n decision.preserveElementIds,\n decision.preserveAbsentSlots,\n decision.preservePreviousSlotIds,\n );\n default: {\n const _exhaustive: never = decision;\n throw new Error(\"[vinext] Unknown navigation commit disposition: \" + String(_exhaustive));\n }\n }\n}\n\nfunction createVisibleCommitDecision(\n trace: NavigationTrace = createNavigationTrace(NavigationTraceReasonCodes.commitCurrent),\n preserveElementIds: readonly string[] = [],\n preserveAbsentSlots: boolean = false,\n preservePreviousSlotIds: readonly string[] = [],\n): VisibleCommitDecision {\n return {\n disposition: \"commit\",\n preserveAbsentSlots,\n preserveElementIds: [...preserveElementIds],\n preservePreviousSlotIds: [...preservePreviousSlotIds],\n trace,\n };\n}\n\nfunction mergeLayoutFlags(\n previousFlags: AppRouterState[\"layoutFlags\"],\n nextFlags: AppRouterState[\"layoutFlags\"],\n preserveElementIds: readonly string[],\n): AppRouterState[\"layoutFlags\"] {\n const merged: Record<string, \"s\" | \"d\"> = { ...nextFlags };\n for (const id of preserveElementIds) {\n if (Object.hasOwn(merged, id)) continue;\n const value = previousFlags[id];\n if (value) merged[id] = value;\n }\n return merged;\n}\n\nfunction createApprovedVisibleCommit(options: {\n decision: VisibleCommitDecision;\n pending: PendingNavigationCommit;\n}): ApprovedVisibleCommit {\n return {\n [approvedVisibleCommitBrand]: true,\n action: options.pending.action,\n decision: options.decision,\n interception: options.pending.interception,\n interceptionContext: options.pending.interceptionContext,\n previousNextUrl: options.pending.previousNextUrl,\n rootLayoutTreePath: options.pending.rootLayoutTreePath,\n routeId: options.pending.routeId,\n };\n}\n\nfunction createCommitTransactionFields(pending: PendingNavigationCommit): NavigationTraceFields {\n return {\n operationLane: pending.action.operation.lane,\n pendingOperationId: pending.action.operation.id,\n startedVisibleCommitVersion: pending.action.operation.startedVisibleCommitVersion,\n };\n}\n\nfunction prependCommitTransactionTrace(\n trace: NavigationTrace,\n code: NavigationTraceTransactionCode,\n pending: PendingNavigationCommit,\n): NavigationTrace {\n return prependNavigationTraceEntry(trace, code, createCommitTransactionFields(pending));\n}\n\nfunction addCommitTransactionTrace(\n decision: CommitDecision,\n pending: PendingNavigationCommit,\n): CommitDecision {\n switch (decision.disposition) {\n case \"commit\":\n return {\n ...decision,\n trace: prependCommitTransactionTrace(\n decision.trace,\n NavigationTraceTransactionCodes.visibleCommit,\n pending,\n ),\n };\n case \"hard-navigate\":\n return {\n ...decision,\n trace: prependCommitTransactionTrace(\n decision.trace,\n NavigationTraceTransactionCodes.hardNavigate,\n pending,\n ),\n };\n case \"no-commit\":\n return {\n ...decision,\n trace: prependCommitTransactionTrace(\n decision.trace,\n NavigationTraceTransactionCodes.noCommit,\n pending,\n ),\n };\n default: {\n const _exhaustive: never = decision;\n throw new Error(\"[vinext] Unknown commit decision: \" + String(_exhaustive));\n }\n }\n}\n\nexport function approveHmrVisibleCommit(pending: PendingNavigationCommit): ApprovedVisibleCommit {\n if (pending.action.operation.lane !== \"hmr\") {\n throw new Error(\"[vinext] HMR visible commit approval requires an HMR pending operation\");\n }\n\n const decision = addCommitTransactionTrace(createVisibleCommitDecision(), pending);\n // This guard is a type narrowing assertion: createVisibleCommitDecision()\n // structurally produces a commit decision, and addCommitTransactionTrace()\n // must preserve that disposition while adding operator trace context.\n if (decision.disposition !== \"commit\") {\n throw new Error(\"[vinext] HMR visible commit approval did not produce a commit decision\");\n }\n\n return createApprovedVisibleCommit({\n decision,\n pending,\n });\n}\n\nexport function approvePendingNavigationCommit(options: {\n activeNavigationId: number;\n currentState: AppRouterState;\n pending: PendingNavigationCommit;\n routeManifest?: RouteManifest | null;\n startedNavigationId: number;\n targetHref: string;\n}): CommitApproval {\n const decision = addCommitTransactionTrace(\n resolvePendingNavigationCommitDecision({\n activeNavigationId: options.activeNavigationId,\n currentState: options.currentState,\n pending: options.pending,\n routeManifest: options.routeManifest ?? null,\n startedNavigationId: options.startedNavigationId,\n targetHref: options.targetHref,\n }),\n options.pending,\n );\n\n switch (decision.disposition) {\n case \"commit\":\n return {\n approvedCommit: createApprovedVisibleCommit({\n decision,\n pending: options.pending,\n }),\n decision,\n };\n case \"hard-navigate\":\n case \"no-commit\":\n return {\n approvedCommit: null,\n decision,\n };\n default: {\n const _exhaustive: never = decision;\n throw new Error(\"[vinext] Unknown commit decision: \" + String(_exhaustive));\n }\n }\n}\n\nexport async function resolveAndClassifyNavigationCommit(options: {\n activeNavigationId: number;\n currentState: AppRouterState;\n // When provided, these getters are called after awaiting nextElements so\n // approval uses the latest lifecycle authority instead of the call snapshot.\n getActiveNavigationId?: () => number;\n getCurrentStateForApproval?: () => AppRouterState;\n navigationSnapshot: ClientNavigationRenderSnapshot;\n nextElements: Promise<AppElements>;\n operationLane: OperationLane;\n payloadOrigin: AppNavigationPayloadOrigin;\n previousNextUrl?: string | null;\n renderId: number;\n routeManifest?: RouteManifest | null;\n startedNavigationId: number;\n targetHref: string;\n type: \"navigate\" | \"replace\" | \"traverse\";\n}): Promise<ClassifiedPendingNavigationCommit> {\n const pending = await createPendingNavigationCommit({\n currentState: options.currentState,\n nextElements: options.nextElements,\n navigationSnapshot: options.navigationSnapshot,\n operationLane: options.operationLane,\n payloadOrigin: options.payloadOrigin,\n previousNextUrl: options.previousNextUrl,\n renderId: options.renderId,\n type: options.type,\n });\n\n const approvalState = options.getCurrentStateForApproval?.() ?? options.currentState;\n const approval = approvePendingNavigationCommit({\n activeNavigationId: options.getActiveNavigationId?.() ?? options.activeNavigationId,\n currentState: approvalState,\n pending,\n routeManifest: options.routeManifest ?? null,\n startedNavigationId: options.startedNavigationId,\n targetHref: options.targetHref,\n });\n\n return {\n approvedCommit: approval.approvedCommit,\n decision: approval.decision,\n pending,\n trace: approval.decision.trace,\n };\n}\n"],"mappings":";;;;;;AA6CA,MAAM,6BAA4C,OAAO,wBAAwB;AA2BjF,SAAgB,2BACd,OACA,QACgB;CAChB,4BAA4B,OAAO;CACnC,OAAO,iCAAiC,OAAO,OAAO;;AAGxD,SAAS,4BAA4B,QAAqC;CACxE,IAAI,OAAO,gCAAgC,MACzC,MAAM,IAAI,MAAM,wEAAwE;;AAI5F,SAAS,sBACP,WACA,sBAC0B;CAC1B,OAAO;EACL,IAAI,UAAU;EACd,MAAM,UAAU;EAChB,6BAA6B,UAAU;EACvC,OAAO;EACP;EACD;;AAGH,SAAS,yBACP,OACA,WACA,WACgB;CAGhB,MAAM,uBAAuB,MAAM,uBAAuB;CAC1D,OAAO;EACL,GAAG;EACH,iBAAiB,sBAAsB,WAAW,qBAAqB;EACvE;EACD;;AAGH,SAAS,kBACP,kBACA,cACA,WACA,yBACmC;C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rB,CAAC,EACF,QAAQ,QACT;CAED,QAAQ,SAAS,aAAjB;EACE,KAAK,UACH,OAAO;GACL,gBAAgB,4BAA4B;IAC1C;IACA,SAAS,QAAQ;IAClB,CAAC;GACF;GACD;EACH,KAAK;EACL,KAAK,aACH,OAAO;GACL,gBAAgB;GAChB;GACD;EACH,SAEE,MAAM,IAAI,MAAM,uCAAuC,OAAOA,SAAY,CAAC;;;AAKjF,eAAsB,mCAAmC,SAiBV;CAC7C,MAAM,UAAU,MAAM,8BAA8B;EAClD,cAAc,QAAQ;EACtB,cAAc,QAAQ;EACtB,oBAAoB,QAAQ;EAC5B,eAAe,QAAQ;EACvB,eAAe,QAAQ;EACvB,iBAAiB,QAAQ;EACzB,UAAU,QAAQ;EAClB,MAAM,QAAQ;EACf,CAAC;CAEF,MAAM,gBAAgB,QAAQ,8BAA8B,IAAI,QAAQ;CACxE,MAAM,WAAW,+BAA+B;EAC9C,oBAAoB,QAAQ,yBAAyB,IAAI,QAAQ;EACjE,cAAc;EACd;EACA,eAAe,QAAQ,iBAAiB;EACxC,qBAAqB,QAAQ;EAC7B,YAAY,QAAQ;EACrB,CAAC;CAEF,OAAO;EACL,gBAAgB,SAAS;EACzB,UAAU,SAAS;EACnB;EACA,OAAO,SAAS,SAAS;EAC1B"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { RenderObservation } from "./cache-proof.js";
|
|
2
1
|
import { ArtifactCompatibilityEnvelope } from "./artifact-compatibility.js";
|
|
2
|
+
import { CacheEntryReuseProof, RenderObservation } from "./cache-proof.js";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/server/app-elements-wire.d.ts
|
|
6
6
|
declare const APP_ARTIFACT_COMPATIBILITY_KEY = "__artifactCompatibility";
|
|
7
|
+
declare const APP_CACHE_ENTRY_REUSE_PROOF_KEY = "__cacheEntryReuseProof";
|
|
7
8
|
declare const APP_INTERCEPTION_KEY = "__interception";
|
|
8
9
|
declare const APP_INTERCEPTION_CONTEXT_KEY = "__interceptionContext";
|
|
9
10
|
declare const APP_LAYOUT_IDS_KEY = "__layoutIds";
|
|
@@ -31,8 +32,8 @@ declare function compareAppElementsSlotIds(left: string, right: string): number;
|
|
|
31
32
|
declare function normalizeAppElementsSlotBindings(slotBindings: readonly AppElementsSlotBinding[], options?: {
|
|
32
33
|
layoutIds?: readonly string[];
|
|
33
34
|
}): readonly AppElementsSlotBinding[];
|
|
34
|
-
type AppElementValue = ReactNode | typeof UNMATCHED_SLOT | string | null | LayoutFlags | ArtifactCompatibilityEnvelope | AppElementsInterception | readonly AppElementsSlotBinding[];
|
|
35
|
-
type AppWireElementValue = ReactNode | string | null | LayoutFlags | ArtifactCompatibilityEnvelope | AppElementsInterception | readonly AppElementsSlotBinding[];
|
|
35
|
+
type AppElementValue = ReactNode | typeof UNMATCHED_SLOT | string | null | LayoutFlags | ArtifactCompatibilityEnvelope | CacheEntryReuseProof | AppElementsInterception | readonly AppElementsSlotBinding[];
|
|
36
|
+
type AppWireElementValue = ReactNode | string | null | LayoutFlags | ArtifactCompatibilityEnvelope | CacheEntryReuseProof | AppElementsInterception | readonly AppElementsSlotBinding[];
|
|
36
37
|
type AppElements = Readonly<Record<string, AppElementValue>>;
|
|
37
38
|
type AppWireElements = Readonly<Record<string, AppWireElementValue>>;
|
|
38
39
|
/**
|
|
@@ -55,6 +56,7 @@ type AppWireElements = Readonly<Record<string, AppWireElementValue>>;
|
|
|
55
56
|
type LayoutFlags = Readonly<Record<string, "s" | "d">>;
|
|
56
57
|
type AppElementsMetadata = {
|
|
57
58
|
artifactCompatibility: ArtifactCompatibilityEnvelope;
|
|
59
|
+
cacheEntryReuseProof?: CacheEntryReuseProof;
|
|
58
60
|
interception: AppElementsInterception | null;
|
|
59
61
|
interceptionContext: string | null;
|
|
60
62
|
layoutIds: readonly string[];
|
|
@@ -104,9 +106,10 @@ type AppElementsWireMetadataEntries = Readonly<{
|
|
|
104
106
|
* known keys (e.g. __layoutFlags). Distinct from AppElements / AppWireElements
|
|
105
107
|
* which only carry render-time values.
|
|
106
108
|
*/
|
|
107
|
-
type AppOutgoingElements = Readonly<Record<string, ReactNode | LayoutFlags | ArtifactCompatibilityEnvelope | AppElementsInterception | RenderObservation | readonly AppElementsSlotBinding[]>>;
|
|
109
|
+
type AppOutgoingElements = Readonly<Record<string, ReactNode | LayoutFlags | ArtifactCompatibilityEnvelope | CacheEntryReuseProof | AppElementsInterception | RenderObservation | readonly AppElementsSlotBinding[]>>;
|
|
108
110
|
type AppElementsWireKeys = {
|
|
109
111
|
readonly artifactCompatibility: typeof APP_ARTIFACT_COMPATIBILITY_KEY;
|
|
112
|
+
readonly cacheEntryReuseProof: typeof APP_CACHE_ENTRY_REUSE_PROOF_KEY;
|
|
110
113
|
readonly interception: typeof APP_INTERCEPTION_KEY;
|
|
111
114
|
readonly interceptionContext: typeof APP_INTERCEPTION_CONTEXT_KEY;
|
|
112
115
|
readonly layoutIds: typeof APP_LAYOUT_IDS_KEY;
|
|
@@ -126,6 +129,7 @@ type AppElementsWireCodec = {
|
|
|
126
129
|
encodeOutgoingPayload(input: {
|
|
127
130
|
element: ReactNode | Readonly<Record<string, ReactNode | AppElementsInterception | readonly AppElementsSlotBinding[]>>;
|
|
128
131
|
artifactCompatibility?: ArtifactCompatibilityEnvelope;
|
|
132
|
+
cacheEntryReuseProof?: CacheEntryReuseProof;
|
|
129
133
|
layoutFlags: LayoutFlags;
|
|
130
134
|
renderObservation?: RenderObservation;
|
|
131
135
|
}): ReactNode | AppOutgoingElements;
|
|
@@ -157,11 +161,12 @@ declare function withLayoutFlags<T extends Record<string, unknown>>(elements: T,
|
|
|
157
161
|
declare function buildOutgoingAppPayload(input: {
|
|
158
162
|
element: ReactNode | Readonly<Record<string, ReactNode | AppElementsInterception | readonly AppElementsSlotBinding[]>>;
|
|
159
163
|
artifactCompatibility?: ArtifactCompatibilityEnvelope;
|
|
164
|
+
cacheEntryReuseProof?: CacheEntryReuseProof;
|
|
160
165
|
layoutFlags: LayoutFlags;
|
|
161
166
|
renderObservation?: RenderObservation;
|
|
162
167
|
}): ReactNode | AppOutgoingElements;
|
|
163
168
|
declare function readAppElementsMetadata(elements: Readonly<Record<string, unknown>>): AppElementsMetadata;
|
|
164
169
|
declare const AppElementsWire: AppElementsWireCodec;
|
|
165
170
|
//#endregion
|
|
166
|
-
export { APP_ARTIFACT_COMPATIBILITY_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, AppElementsSlotBindingState, AppElementsWire, AppOutgoingElements, AppWireElements, LayoutFlags, UNMATCHED_SLOT, buildOutgoingAppPayload, compareAppElementsSlotIds, isAppElementsRecord, normalizeAppElements, normalizeAppElementsSlotBindings, readAppElementsMetadata, withLayoutFlags };
|
|
171
|
+
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_RENDER_OBSERVATION_KEY, APP_ROOT_LAYOUT_KEY, APP_ROUTE_KEY, APP_SLOT_BINDINGS_KEY, APP_UNMATCHED_SLOT_WIRE_VALUE, AppElementValue, AppElements, AppElementsInterception, AppElementsSlotBinding, AppElementsSlotBindingState, AppElementsWire, AppOutgoingElements, AppWireElements, LayoutFlags, UNMATCHED_SLOT, buildOutgoingAppPayload, compareAppElementsSlotIds, isAppElementsRecord, normalizeAppElements, normalizeAppElementsSlotBindings, readAppElementsMetadata, withLayoutFlags };
|
|
167
172
|
//# sourceMappingURL=app-elements-wire.d.ts.map
|
|
@@ -4,6 +4,7 @@ import { isValidElement } from "react";
|
|
|
4
4
|
//#region src/server/app-elements-wire.ts
|
|
5
5
|
const APP_INTERCEPTION_SEPARATOR = "\0";
|
|
6
6
|
const APP_ARTIFACT_COMPATIBILITY_KEY = "__artifactCompatibility";
|
|
7
|
+
const APP_CACHE_ENTRY_REUSE_PROOF_KEY = "__cacheEntryReuseProof";
|
|
7
8
|
const APP_INTERCEPTION_KEY = "__interception";
|
|
8
9
|
const APP_INTERCEPTION_CONTEXT_KEY = "__interceptionContext";
|
|
9
10
|
const APP_LAYOUT_IDS_KEY = "__layoutIds";
|
|
@@ -14,6 +15,40 @@ const APP_ROOT_LAYOUT_KEY = "__rootLayout";
|
|
|
14
15
|
const APP_SLOT_BINDINGS_KEY = "__slotBindings";
|
|
15
16
|
const APP_UNMATCHED_SLOT_WIRE_VALUE = "__VINEXT_UNMATCHED_SLOT__";
|
|
16
17
|
const UNMATCHED_SLOT = Symbol.for("vinext.unmatchedSlot");
|
|
18
|
+
function createCacheProofRejectionCodeSet(codes) {
|
|
19
|
+
return new Set(codes);
|
|
20
|
+
}
|
|
21
|
+
const CACHE_PROOF_REJECTION_CODES = createCacheProofRejectionCodeSet([
|
|
22
|
+
"CP_CACHE_ENTRY_PROOF_MISSING",
|
|
23
|
+
"CP_MODEL_DISABLED",
|
|
24
|
+
"CP_ARTIFACT_COMPATIBILITY_INCOMPATIBLE",
|
|
25
|
+
"CP_ARTIFACT_COMPATIBILITY_UNKNOWN",
|
|
26
|
+
"CP_DIMENSION_COUNT_EXCEEDED",
|
|
27
|
+
"CP_DIMENSION_NAME_MISSING",
|
|
28
|
+
"CP_DIMENSION_NAME_TOO_LONG",
|
|
29
|
+
"CP_DIMENSION_VALUE_COUNT_EXCEEDED",
|
|
30
|
+
"CP_DIMENSION_VALUE_TOO_LONG",
|
|
31
|
+
"CP_DIMENSION_VALUES_MISSING",
|
|
32
|
+
"CP_ENCODED_VARIANT_TOO_LONG",
|
|
33
|
+
"CP_INVALID_VARIANT_BUDGET",
|
|
34
|
+
"CP_ROUTE_VARIANT_BUDGET_ROUTE_MISMATCH",
|
|
35
|
+
"CP_ROUTE_VARIANT_CEILING_EXCEEDED",
|
|
36
|
+
"CP_UNSAFE_PUBLIC_DIMENSION",
|
|
37
|
+
"CP_BOUNDARY_OUTCOME_MISMATCH",
|
|
38
|
+
"CP_BOUNDARY_OUTCOME_UNKNOWN",
|
|
39
|
+
"CP_PRIVATE_DYNAMIC_DOWNGRADE",
|
|
40
|
+
"CP_STATIC_LAYOUT_CANDIDATE_OUTPUT_KIND",
|
|
41
|
+
"CP_STATIC_LAYOUT_CURRENT_OUTPUT_KIND",
|
|
42
|
+
"CP_STATIC_LAYOUT_ID_MISMATCH",
|
|
43
|
+
"CP_STATIC_LAYOUT_OBSERVATION_OUTPUT_KIND",
|
|
44
|
+
"CP_STATIC_LAYOUT_OBSERVATION_OUTPUT_MISMATCH",
|
|
45
|
+
"CP_STATIC_LAYOUT_PRIVATE_DYNAMIC_DOWNGRADE",
|
|
46
|
+
"CP_STATIC_LAYOUT_REQUEST_API_OBSERVED",
|
|
47
|
+
"CP_STATIC_LAYOUT_REQUEST_API_UNKNOWN",
|
|
48
|
+
"CP_STATIC_LAYOUT_ROOT_BOUNDARY_MISMATCH",
|
|
49
|
+
"CP_STATIC_LAYOUT_ROOT_BOUNDARY_UNKNOWN",
|
|
50
|
+
"CP_STATIC_LAYOUT_VARIANT_DIMENSION_UNPROVEN"
|
|
51
|
+
]);
|
|
17
52
|
function compareAppElementsSlotIds(left, right) {
|
|
18
53
|
if (left < right) return -1;
|
|
19
54
|
if (left > right) return 1;
|
|
@@ -258,6 +293,7 @@ function buildOutgoingAppPayload(input) {
|
|
|
258
293
|
[APP_LAYOUT_FLAGS_KEY]: input.layoutFlags,
|
|
259
294
|
[APP_ARTIFACT_COMPATIBILITY_KEY]: input.artifactCompatibility ?? createArtifactCompatibilityEnvelope()
|
|
260
295
|
};
|
|
296
|
+
if (input.cacheEntryReuseProof) payload[APP_CACHE_ENTRY_REUSE_PROOF_KEY] = input.cacheEntryReuseProof;
|
|
261
297
|
if (input.renderObservation) payload[APP_RENDER_OBSERVATION_KEY] = input.renderObservation;
|
|
262
298
|
return payload;
|
|
263
299
|
}
|
|
@@ -265,6 +301,48 @@ function readArtifactCompatibilityMetadata(value) {
|
|
|
265
301
|
if (value === void 0) return createArtifactCompatibilityEnvelope();
|
|
266
302
|
return parseArtifactCompatibilityEnvelope(value) ?? createArtifactCompatibilityEnvelope();
|
|
267
303
|
}
|
|
304
|
+
function createMissingCacheEntryReuseProof() {
|
|
305
|
+
return {
|
|
306
|
+
kind: "runtime-cache-entry",
|
|
307
|
+
decision: null
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function isCacheProofRejectionCode(value) {
|
|
311
|
+
return typeof value === "string" && CACHE_PROOF_REJECTION_CODES.has(value);
|
|
312
|
+
}
|
|
313
|
+
function isCacheProofFallbackMode(value) {
|
|
314
|
+
return value === "renderFresh" || value === "privateUncacheable";
|
|
315
|
+
}
|
|
316
|
+
function isCacheProofFallbackScope(value) {
|
|
317
|
+
return value === "affectedOutput" || value === "route";
|
|
318
|
+
}
|
|
319
|
+
function parseCacheEntryReuseProofMetadata(value) {
|
|
320
|
+
if (value === void 0) return null;
|
|
321
|
+
if (!isRecord(value) || value.kind !== "runtime-cache-entry") return createMissingCacheEntryReuseProof();
|
|
322
|
+
const decision = value.decision;
|
|
323
|
+
if (decision === null) return createMissingCacheEntryReuseProof();
|
|
324
|
+
if (!isRecord(decision)) return createMissingCacheEntryReuseProof();
|
|
325
|
+
if (decision.kind === "reuse" && decision.canReuse === true && decision.code === "CP_STATIC_LAYOUT_REUSE_PROVEN" && decision.reuseClass === "static-layout") return {
|
|
326
|
+
kind: "runtime-cache-entry",
|
|
327
|
+
decision: {
|
|
328
|
+
canReuse: true,
|
|
329
|
+
code: decision.code,
|
|
330
|
+
kind: "reuse",
|
|
331
|
+
reuseClass: decision.reuseClass
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
if (decision.kind === "reject" && decision.canReuse === false && isCacheProofRejectionCode(decision.code) && isCacheProofFallbackMode(decision.mode) && isCacheProofFallbackScope(decision.scope)) return {
|
|
335
|
+
kind: "runtime-cache-entry",
|
|
336
|
+
decision: {
|
|
337
|
+
canReuse: false,
|
|
338
|
+
code: decision.code,
|
|
339
|
+
kind: "reject",
|
|
340
|
+
mode: decision.mode,
|
|
341
|
+
scope: decision.scope
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
return createMissingCacheEntryReuseProof();
|
|
345
|
+
}
|
|
268
346
|
function readAppElementsMetadata(elements) {
|
|
269
347
|
const routeId = elements[APP_ROUTE_KEY];
|
|
270
348
|
if (typeof routeId !== "string") throw new Error("[vinext] Missing __route string in App Router payload");
|
|
@@ -277,8 +355,11 @@ function readAppElementsMetadata(elements) {
|
|
|
277
355
|
const layoutIds = parseLayoutIds(elements[APP_LAYOUT_IDS_KEY]);
|
|
278
356
|
const slotBindings = parseSlotBindings(elements[APP_SLOT_BINDINGS_KEY], { layoutIds });
|
|
279
357
|
const interception = parseInterceptionMetadata(elements[APP_INTERCEPTION_KEY]);
|
|
358
|
+
const artifactCompatibility = readArtifactCompatibilityMetadata(elements[APP_ARTIFACT_COMPATIBILITY_KEY]);
|
|
359
|
+
const cacheEntryReuseProof = parseCacheEntryReuseProofMetadata(elements[APP_CACHE_ENTRY_REUSE_PROOF_KEY]);
|
|
280
360
|
return {
|
|
281
|
-
artifactCompatibility
|
|
361
|
+
artifactCompatibility,
|
|
362
|
+
...cacheEntryReuseProof ? { cacheEntryReuseProof } : {},
|
|
282
363
|
interception,
|
|
283
364
|
interceptionContext: interceptionContext ?? null,
|
|
284
365
|
layoutIds,
|
|
@@ -291,6 +372,7 @@ function readAppElementsMetadata(elements) {
|
|
|
291
372
|
const AppElementsWire = {
|
|
292
373
|
keys: {
|
|
293
374
|
artifactCompatibility: APP_ARTIFACT_COMPATIBILITY_KEY,
|
|
375
|
+
cacheEntryReuseProof: APP_CACHE_ENTRY_REUSE_PROOF_KEY,
|
|
294
376
|
interception: APP_INTERCEPTION_KEY,
|
|
295
377
|
interceptionContext: APP_INTERCEPTION_CONTEXT_KEY,
|
|
296
378
|
layoutIds: APP_LAYOUT_IDS_KEY,
|
|
@@ -316,6 +398,6 @@ const AppElementsWire = {
|
|
|
316
398
|
withLayoutFlags
|
|
317
399
|
};
|
|
318
400
|
//#endregion
|
|
319
|
-
export { APP_ARTIFACT_COMPATIBILITY_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 };
|
|
401
|
+
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_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 };
|
|
320
402
|
|
|
321
403
|
//# sourceMappingURL=app-elements-wire.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-elements-wire.js","names":[],"sources":["../../src/server/app-elements-wire.ts"],"sourcesContent":["import { isValidElement, type ReactNode } from \"react\";\nimport {\n createArtifactCompatibilityEnvelope,\n parseArtifactCompatibilityEnvelope,\n type ArtifactCompatibilityEnvelope,\n} from \"./artifact-compatibility.js\";\nimport type { RenderObservation } from \"./cache-proof.js\";\nimport { isInterceptionMatchedUrlPath } from \"./normalize-path.js\";\n\nconst APP_INTERCEPTION_SEPARATOR = \"\\0\";\n\nexport const APP_ARTIFACT_COMPATIBILITY_KEY = \"__artifactCompatibility\";\nexport const APP_INTERCEPTION_KEY = \"__interception\";\nexport const APP_INTERCEPTION_CONTEXT_KEY = \"__interceptionContext\";\nexport const APP_LAYOUT_IDS_KEY = \"__layoutIds\";\nexport const APP_LAYOUT_FLAGS_KEY = \"__layoutFlags\";\nexport const APP_RENDER_OBSERVATION_KEY = \"__renderObservation\";\nexport const APP_ROUTE_KEY = \"__route\";\nexport const APP_ROOT_LAYOUT_KEY = \"__rootLayout\";\nexport const APP_SLOT_BINDINGS_KEY = \"__slotBindings\";\nexport const APP_UNMATCHED_SLOT_WIRE_VALUE = \"__VINEXT_UNMATCHED_SLOT__\";\n\nexport const UNMATCHED_SLOT = Symbol.for(\"vinext.unmatchedSlot\");\n\nexport type AppElementsSlotBindingState = \"active\" | \"default\" | \"unmatched\";\n\nexport type AppElementsSlotBinding = Readonly<{\n ownerLayoutId: string | null;\n slotId: string;\n state: AppElementsSlotBindingState;\n}>;\n\nexport type AppElementsInterception = Readonly<{\n sourceMatchedUrl: string;\n sourceRouteId: string;\n slotId: string;\n targetMatchedUrl: string;\n targetRouteId: string;\n}>;\n\nexport function compareAppElementsSlotIds(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n\nfunction compareAppElementsSlotBindingsBySlotId(\n left: Pick<AppElementsSlotBinding, \"slotId\">,\n right: Pick<AppElementsSlotBinding, \"slotId\">,\n): number {\n return compareAppElementsSlotIds(left.slotId, right.slotId);\n}\n\nexport function normalizeAppElementsSlotBindings(\n slotBindings: readonly AppElementsSlotBinding[],\n options: { layoutIds?: readonly string[] } = {},\n): readonly AppElementsSlotBinding[] {\n const ownerLayoutIds = options.layoutIds ? new Set(options.layoutIds) : null;\n const seenSlotIds = new Set<string>();\n const normalized: AppElementsSlotBinding[] = [];\n\n for (const binding of slotBindings) {\n if (seenSlotIds.has(binding.slotId)) {\n throw new Error(\"[vinext] Invalid __slotBindings in App Router payload: duplicate slot id\");\n }\n seenSlotIds.add(binding.slotId);\n\n if (\n ownerLayoutIds &&\n binding.ownerLayoutId !== null &&\n !ownerLayoutIds.has(binding.ownerLayoutId)\n ) {\n throw new Error(\n \"[vinext] Invalid __slotBindings in App Router payload: owner layout id missing from __layoutIds\",\n );\n }\n\n normalized.push({ ...binding });\n }\n\n return normalized.sort(compareAppElementsSlotBindingsBySlotId);\n}\n\nexport type AppElementValue =\n | ReactNode\n | typeof UNMATCHED_SLOT\n | string\n | null\n | LayoutFlags\n | ArtifactCompatibilityEnvelope\n | AppElementsInterception\n | readonly AppElementsSlotBinding[];\ntype AppWireElementValue =\n | ReactNode\n | string\n | null\n | LayoutFlags\n | ArtifactCompatibilityEnvelope\n | AppElementsInterception\n | readonly AppElementsSlotBinding[];\n\nexport type AppElements = Readonly<Record<string, AppElementValue>>;\nexport type AppWireElements = Readonly<Record<string, AppWireElementValue>>;\n\n/**\n * Per-layout static/dynamic flags. `\"s\"` = static (skippable on next nav);\n * `\"d\"` = dynamic (must always render).\n *\n * Lifecycle (partial — later PRs extend this):\n *\n * 1. PROBE — probeAppPageLayouts (server/app-page-execution.ts) returns\n * LayoutFlags for every layout in the route at render time.\n *\n * 2. ATTACH — AppElementsWire.encodeOutgoingPayload writes `__layoutFlags`\n * into the outgoing App Router payload record.\n *\n * 3. WIRE — renderToReadableStream serializes the record as RSC row 0.\n *\n * 4. PARSE — AppElementsWire.readMetadata extracts layoutFlags from the\n * wire payload on the client side.\n */\nexport type LayoutFlags = Readonly<Record<string, \"s\" | \"d\">>;\n\ntype AppElementsMetadata = {\n artifactCompatibility: ArtifactCompatibilityEnvelope;\n interception: AppElementsInterception | null;\n interceptionContext: string | null;\n layoutIds: readonly string[];\n layoutFlags: LayoutFlags;\n routeId: string;\n rootLayoutTreePath: string | null;\n slotBindings: readonly AppElementsSlotBinding[];\n};\n\ntype AppElementsWireElementKey =\n | { kind: \"layout\"; treePath: string }\n | { interceptionContext: string | null; kind: \"page\"; path: string }\n | { interceptionContext: string | null; kind: \"route\"; path: string }\n | { kind: \"slot\"; name: string; treePath: string }\n | { kind: \"template\"; treePath: string };\n\ntype AppElementsWireMetadataInput = {\n interception?: AppElementsInterception | null;\n interceptionContext: string | null;\n layoutIds?: readonly string[];\n routeId: string;\n rootLayoutTreePath: string | null;\n slotBindings?: readonly AppElementsSlotBinding[];\n};\n\ntype AppElementsWireMetadataEntries = Readonly<{\n [APP_ROUTE_KEY]: string;\n [APP_INTERCEPTION_KEY]?: AppElementsInterception;\n [APP_INTERCEPTION_CONTEXT_KEY]: string | null;\n [APP_LAYOUT_IDS_KEY]: readonly string[];\n [APP_ROOT_LAYOUT_KEY]: string | null;\n [APP_SLOT_BINDINGS_KEY]?: readonly AppElementsSlotBinding[];\n}>;\n\n/**\n * The outgoing wire payload shape. Includes ReactNode values for the\n * rendered tree plus metadata values like LayoutFlags attached under\n * known keys (e.g. __layoutFlags). Distinct from AppElements / AppWireElements\n * which only carry render-time values.\n */\nexport type AppOutgoingElements = Readonly<\n Record<\n string,\n | ReactNode\n | LayoutFlags\n | ArtifactCompatibilityEnvelope\n | AppElementsInterception\n | RenderObservation\n | readonly AppElementsSlotBinding[]\n >\n>;\n\ntype AppElementsWireKeys = {\n readonly artifactCompatibility: typeof APP_ARTIFACT_COMPATIBILITY_KEY;\n readonly interception: typeof APP_INTERCEPTION_KEY;\n readonly interceptionContext: typeof APP_INTERCEPTION_CONTEXT_KEY;\n readonly layoutIds: typeof APP_LAYOUT_IDS_KEY;\n readonly layoutFlags: typeof APP_LAYOUT_FLAGS_KEY;\n readonly renderObservation: typeof APP_RENDER_OBSERVATION_KEY;\n readonly rootLayout: typeof APP_ROOT_LAYOUT_KEY;\n readonly route: typeof APP_ROUTE_KEY;\n readonly slotBindings: typeof APP_SLOT_BINDINGS_KEY;\n};\n\ntype AppElementsWireCodec = {\n readonly keys: AppElementsWireKeys;\n readonly unmatchedSlotValue: typeof APP_UNMATCHED_SLOT_WIRE_VALUE;\n createMetadataEntries(input: AppElementsWireMetadataInput): AppElementsWireMetadataEntries;\n decode(elements: AppWireElements): AppElements;\n encodeCacheKey(rscUrl: string, interceptionContext: string | null): string;\n encodeLayoutId(treePath: string): string;\n encodeOutgoingPayload(input: {\n element:\n | ReactNode\n | Readonly<\n Record<string, ReactNode | AppElementsInterception | readonly AppElementsSlotBinding[]>\n >;\n artifactCompatibility?: ArtifactCompatibilityEnvelope;\n layoutFlags: LayoutFlags;\n renderObservation?: RenderObservation;\n }): ReactNode | AppOutgoingElements;\n encodePageId(routePath: string, interceptionContext: string | null): string;\n encodeRouteId(routePath: string, interceptionContext: string | null): string;\n encodeSlotId(slotName: string, treePath: string): string;\n encodeTemplateId(treePath: string): string;\n isSlotId(key: string): boolean;\n parseElementKey(key: string): AppElementsWireElementKey | null;\n readMetadata(elements: Readonly<Record<string, unknown>>): AppElementsMetadata;\n withLayoutFlags<T extends Record<string, unknown>>(\n elements: T,\n layoutFlags: LayoutFlags,\n ): T & { [APP_LAYOUT_FLAGS_KEY]: LayoutFlags };\n};\n\nfunction appendInterceptionContext(identity: string, interceptionContext: string | null): string {\n return interceptionContext === null\n ? identity\n : `${identity}${APP_INTERCEPTION_SEPARATOR}${interceptionContext}`;\n}\n\nfunction createAppPayloadRouteId(routePath: string, interceptionContext: string | null): string {\n return appendInterceptionContext(`route:${routePath}`, interceptionContext);\n}\n\nfunction createAppPayloadPageId(routePath: string, interceptionContext: string | null): string {\n return appendInterceptionContext(`page:${routePath}`, interceptionContext);\n}\n\nfunction createAppPayloadLayoutId(treePath: string): string {\n return `layout:${treePath}`;\n}\n\nfunction createAppPayloadTemplateId(treePath: string): string {\n return `template:${treePath}`;\n}\n\nfunction createAppPayloadSlotId(slotName: string, treePath: string): string {\n return `slot:${slotName}:${treePath}`;\n}\n\nfunction createAppPayloadCacheKey(rscUrl: string, interceptionContext: string | null): string {\n return appendInterceptionContext(rscUrl, interceptionContext);\n}\n\nfunction parsePathWithInterception(input: string): {\n interceptionContext: string | null;\n path: string;\n} | null {\n const separatorIndex = input.indexOf(APP_INTERCEPTION_SEPARATOR);\n const path = separatorIndex === -1 ? input : input.slice(0, separatorIndex);\n if (!path.startsWith(\"/\")) return null;\n\n return {\n interceptionContext: separatorIndex === -1 ? null : input.slice(separatorIndex + 1),\n path,\n };\n}\n\n/**\n * AppElements tree paths are absolute route-tree paths on the wire.\n * Bare segment names are not valid layout/template/slot tree identities.\n */\nfunction parseTreePath(input: string): string | null {\n return input.startsWith(\"/\") ? input : null;\n}\n\nfunction parseAppElementsWireElementKey(key: string): AppElementsWireElementKey | null {\n if (key.startsWith(\"route:\")) {\n const parsed = parsePathWithInterception(key.slice(\"route:\".length));\n if (!parsed) return null;\n return { interceptionContext: parsed.interceptionContext, kind: \"route\", path: parsed.path };\n }\n\n if (key.startsWith(\"page:\")) {\n const parsed = parsePathWithInterception(key.slice(\"page:\".length));\n if (!parsed) return null;\n return { interceptionContext: parsed.interceptionContext, kind: \"page\", path: parsed.path };\n }\n\n if (key.startsWith(\"layout:\")) {\n const treePath = parseTreePath(key.slice(\"layout:\".length));\n return treePath ? { kind: \"layout\", treePath } : null;\n }\n\n if (key.startsWith(\"template:\")) {\n const treePath = parseTreePath(key.slice(\"template:\".length));\n return treePath ? { kind: \"template\", treePath } : null;\n }\n\n if (key.startsWith(\"slot:\")) {\n const body = key.slice(\"slot:\".length);\n const separatorIndex = body.indexOf(\":\");\n if (separatorIndex <= 0) return null;\n const name = body.slice(0, separatorIndex);\n const treePath = parseTreePath(body.slice(separatorIndex + 1));\n return treePath ? { kind: \"slot\", name, treePath } : null;\n }\n\n return null;\n}\n\nfunction isAppElementsWireSlotId(key: string): boolean {\n if (!key.startsWith(\"slot:\")) return false;\n const body = key.slice(\"slot:\".length);\n const separatorIndex = body.indexOf(\":\");\n return separatorIndex > 0 && body.charCodeAt(separatorIndex + 1) === 0x2f;\n}\n\nfunction createAppElementsWireMetadataEntries(\n input: AppElementsWireMetadataInput,\n): AppElementsWireMetadataEntries {\n const layoutIds = [...(input.layoutIds ?? [])];\n const entries: AppElementsWireMetadataEntries = {\n [APP_ROUTE_KEY]: input.routeId,\n [APP_INTERCEPTION_CONTEXT_KEY]: input.interceptionContext,\n [APP_LAYOUT_IDS_KEY]: layoutIds,\n [APP_ROOT_LAYOUT_KEY]: input.rootLayoutTreePath,\n };\n // Empty slot binding metadata is intentionally omitted. Missing\n // __slotBindings round-trips as [] and means \"no route-state proof\", so\n // default/unmatched slot preservation is not promoted for that payload.\n const entriesWithInterception = input.interception\n ? { ...entries, [APP_INTERCEPTION_KEY]: input.interception }\n : entries;\n if (input.slotBindings && input.slotBindings.length > 0) {\n return {\n ...entriesWithInterception,\n [APP_SLOT_BINDINGS_KEY]: normalizeAppElementsSlotBindings(input.slotBindings, { layoutIds }),\n };\n }\n return entriesWithInterception;\n}\n\nexport function normalizeAppElements(elements: AppWireElements): AppElements {\n let needsNormalization = false;\n for (const [key, value] of Object.entries(elements)) {\n if (isAppElementsWireSlotId(key) && value === APP_UNMATCHED_SLOT_WIRE_VALUE) {\n needsNormalization = true;\n break;\n }\n }\n\n if (!needsNormalization) {\n return elements;\n }\n\n const normalized: Record<string, AppElementValue> = {};\n for (const [key, value] of Object.entries(elements)) {\n normalized[key] =\n isAppElementsWireSlotId(key) && value === APP_UNMATCHED_SLOT_WIRE_VALUE\n ? UNMATCHED_SLOT\n : value;\n }\n\n return normalized;\n}\n\nfunction isLayoutFlagsRecord(value: unknown): value is LayoutFlags {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n for (const v of Object.values(value)) {\n if (v !== \"s\" && v !== \"d\") return false;\n }\n return true;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction parseLayoutFlags(value: unknown): LayoutFlags {\n if (isLayoutFlagsRecord(value)) return value;\n return {};\n}\n\nfunction parseLayoutIds(value: unknown): readonly string[] {\n if (value === undefined) return [];\n if (!Array.isArray(value)) {\n throw new Error(\n \"[vinext] Invalid __layoutIds in App Router payload: expected layout id string[]\",\n );\n }\n\n const layoutIds: string[] = [];\n for (const entry of value) {\n if (typeof entry !== \"string\") {\n throw new Error(\n \"[vinext] Invalid __layoutIds in App Router payload: expected layout id string[]\",\n );\n }\n\n const parsed = parseAppElementsWireElementKey(entry);\n if (parsed?.kind !== \"layout\") {\n throw new Error(\"[vinext] Invalid __layoutIds in App Router payload: expected layout ids\");\n }\n\n layoutIds.push(entry);\n }\n return layoutIds;\n}\n\nfunction isSlotBindingState(value: unknown): value is AppElementsSlotBindingState {\n return value === \"active\" || value === \"default\" || value === \"unmatched\";\n}\n\nfunction parseSlotBindings(\n value: unknown,\n options: { layoutIds?: readonly string[] } = {},\n): readonly AppElementsSlotBinding[] {\n // Missing metadata is compatibility-safe but not semantic proof: callers see\n // an empty binding list, so promoted default/unmatched slot preservation is\n // denied instead of inferred from legacy transport shape.\n if (value === undefined) return [];\n if (!Array.isArray(value)) {\n throw new Error(\"[vinext] Invalid __slotBindings in App Router payload: expected array\");\n }\n\n const slotBindings: AppElementsSlotBinding[] = [];\n for (const entry of value) {\n if (!isRecord(entry)) {\n throw new Error(\"[vinext] Invalid __slotBindings in App Router payload: expected objects\");\n }\n\n const slotId = entry.slotId;\n if (typeof slotId !== \"string\" || parseAppElementsWireElementKey(slotId)?.kind !== \"slot\") {\n throw new Error(\"[vinext] Invalid __slotBindings in App Router payload: expected slot ids\");\n }\n\n const ownerLayoutId = entry.ownerLayoutId;\n if (\n ownerLayoutId !== null &&\n (typeof ownerLayoutId !== \"string\" ||\n parseAppElementsWireElementKey(ownerLayoutId)?.kind !== \"layout\")\n ) {\n throw new Error(\n \"[vinext] Invalid __slotBindings in App Router payload: expected owner layout ids\",\n );\n }\n\n const state = entry.state;\n if (!isSlotBindingState(state)) {\n throw new Error(\"[vinext] Invalid __slotBindings in App Router payload: expected state\");\n }\n\n slotBindings.push({ ownerLayoutId, slotId, state });\n }\n return normalizeAppElementsSlotBindings(slotBindings, options);\n}\n\nfunction readRequiredInterceptionString(\n entry: Record<string, unknown>,\n fieldName: keyof AppElementsInterception,\n): string {\n const value = entry[fieldName];\n if (typeof value !== \"string\") {\n throw new Error(\"[vinext] Invalid __interception in App Router payload: expected strings\");\n }\n return value;\n}\n\nfunction parseInterceptionMatchedUrl(value: string): string {\n if (!isInterceptionMatchedUrlPath(value)) {\n throw new Error(\"[vinext] Invalid __interception in App Router payload: expected path URLs\");\n }\n return value;\n}\n\nfunction parseInterceptionRouteId(value: string, matchedUrl: string): string {\n const parsed = parseAppElementsWireElementKey(value);\n if (\n parsed?.kind !== \"route\" ||\n parsed.path !== matchedUrl ||\n parsed.interceptionContext !== null\n ) {\n throw new Error(\"[vinext] Invalid __interception in App Router payload: expected route ids\");\n }\n return value;\n}\n\nfunction parseInterceptionSlotId(value: string): string {\n if (parseAppElementsWireElementKey(value)?.kind !== \"slot\") {\n throw new Error(\"[vinext] Invalid __interception in App Router payload: expected slot id\");\n }\n return value;\n}\n\nfunction parseInterceptionMetadata(value: unknown): AppElementsInterception | null {\n if (value === undefined || value === null) return null;\n if (!isRecord(value)) {\n throw new Error(\"[vinext] Invalid __interception in App Router payload: expected object\");\n }\n\n const sourceMatchedUrl = parseInterceptionMatchedUrl(\n readRequiredInterceptionString(value, \"sourceMatchedUrl\"),\n );\n const targetMatchedUrl = parseInterceptionMatchedUrl(\n readRequiredInterceptionString(value, \"targetMatchedUrl\"),\n );\n return {\n sourceMatchedUrl,\n sourceRouteId: parseInterceptionRouteId(\n readRequiredInterceptionString(value, \"sourceRouteId\"),\n sourceMatchedUrl,\n ),\n slotId: parseInterceptionSlotId(readRequiredInterceptionString(value, \"slotId\")),\n targetMatchedUrl,\n targetRouteId: parseInterceptionRouteId(\n readRequiredInterceptionString(value, \"targetRouteId\"),\n targetMatchedUrl,\n ),\n };\n}\n\n/**\n * Type predicate for a plain (non-null, non-array) record of app payload values.\n * Used to distinguish the App Router payload object from bare React elements at\n * the render boundary. Narrows to `Readonly<Record<string, unknown>>` because\n * the outgoing payload carries heterogeneous values (ReactNodes for the rendered\n * tree, plus metadata like `__layoutFlags` which is a plain object). Delegates\n * to React's canonical `isValidElement` so we don't depend on React's internal\n * `$$typeof` marker scheme.\n */\nexport function isAppElementsRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n if (typeof value !== \"object\" || value === null) return false;\n if (Array.isArray(value)) return false;\n if (isValidElement(value)) return false;\n return true;\n}\n\nexport function withLayoutFlags<T extends Record<string, unknown>>(\n elements: T,\n layoutFlags: LayoutFlags,\n): T & { [APP_LAYOUT_FLAGS_KEY]: LayoutFlags } {\n return { ...elements, [APP_LAYOUT_FLAGS_KEY]: layoutFlags };\n}\n\nexport function buildOutgoingAppPayload(input: {\n element:\n | ReactNode\n | Readonly<\n Record<string, ReactNode | AppElementsInterception | readonly AppElementsSlotBinding[]>\n >;\n artifactCompatibility?: ArtifactCompatibilityEnvelope;\n layoutFlags: LayoutFlags;\n renderObservation?: RenderObservation;\n}): ReactNode | AppOutgoingElements {\n if (!isAppElementsRecord(input.element)) {\n return input.element;\n }\n const payload: Record<\n string,\n | ReactNode\n | LayoutFlags\n | ArtifactCompatibilityEnvelope\n | AppElementsInterception\n | RenderObservation\n | readonly AppElementsSlotBinding[]\n > = {\n ...input.element,\n [APP_LAYOUT_FLAGS_KEY]: input.layoutFlags,\n [APP_ARTIFACT_COMPATIBILITY_KEY]:\n input.artifactCompatibility ?? createArtifactCompatibilityEnvelope(),\n };\n if (input.renderObservation) {\n payload[APP_RENDER_OBSERVATION_KEY] = input.renderObservation;\n }\n return payload;\n}\n\nfunction readArtifactCompatibilityMetadata(value: unknown): ArtifactCompatibilityEnvelope {\n if (value === undefined) return createArtifactCompatibilityEnvelope();\n\n const artifactCompatibility = parseArtifactCompatibilityEnvelope(value);\n // TODO(#726-COMPAT-04): hard-fail malformed compatibility metadata once\n // cache/skip consumers depend on this proof. During Wave01 the field is\n // emitted as scaffolding, so bad or future-version values degrade like\n // missing __layoutFlags instead of crashing render paths that do not read it.\n return artifactCompatibility ?? createArtifactCompatibilityEnvelope();\n}\n\nexport function readAppElementsMetadata(\n elements: Readonly<Record<string, unknown>>,\n): AppElementsMetadata {\n const routeId = elements[APP_ROUTE_KEY];\n if (typeof routeId !== \"string\") {\n throw new Error(\"[vinext] Missing __route string in App Router payload\");\n }\n\n const interceptionContext = elements[APP_INTERCEPTION_CONTEXT_KEY];\n if (\n interceptionContext !== undefined &&\n interceptionContext !== null &&\n typeof interceptionContext !== \"string\"\n ) {\n throw new Error(\"[vinext] Invalid __interceptionContext in App Router payload\");\n }\n\n const rootLayoutTreePath = elements[APP_ROOT_LAYOUT_KEY];\n if (rootLayoutTreePath === undefined) {\n throw new Error(\"[vinext] Missing __rootLayout key in App Router payload\");\n }\n if (rootLayoutTreePath !== null && typeof rootLayoutTreePath !== \"string\") {\n throw new Error(\"[vinext] Invalid __rootLayout in App Router payload: expected string or null\");\n }\n\n const layoutFlags = parseLayoutFlags(elements[APP_LAYOUT_FLAGS_KEY]);\n const layoutIds = parseLayoutIds(elements[APP_LAYOUT_IDS_KEY]);\n const slotBindings = parseSlotBindings(elements[APP_SLOT_BINDINGS_KEY], { layoutIds });\n const interception = parseInterceptionMetadata(elements[APP_INTERCEPTION_KEY]);\n const artifactCompatibility = readArtifactCompatibilityMetadata(\n elements[APP_ARTIFACT_COMPATIBILITY_KEY],\n );\n\n return {\n artifactCompatibility,\n interception,\n interceptionContext: interceptionContext ?? null,\n layoutIds,\n layoutFlags,\n routeId,\n rootLayoutTreePath,\n slotBindings,\n };\n}\n\nexport const AppElementsWire: AppElementsWireCodec = {\n // WIRE follow-ups use these stable key names when moving payload readers and writers\n // behind the codec boundary.\n keys: {\n artifactCompatibility: APP_ARTIFACT_COMPATIBILITY_KEY,\n interception: APP_INTERCEPTION_KEY,\n interceptionContext: APP_INTERCEPTION_CONTEXT_KEY,\n layoutIds: APP_LAYOUT_IDS_KEY,\n layoutFlags: APP_LAYOUT_FLAGS_KEY,\n renderObservation: APP_RENDER_OBSERVATION_KEY,\n rootLayout: APP_ROOT_LAYOUT_KEY,\n route: APP_ROUTE_KEY,\n slotBindings: APP_SLOT_BINDINGS_KEY,\n },\n unmatchedSlotValue: APP_UNMATCHED_SLOT_WIRE_VALUE,\n createMetadataEntries: createAppElementsWireMetadataEntries,\n decode: normalizeAppElements,\n encodeCacheKey: createAppPayloadCacheKey,\n encodeLayoutId: createAppPayloadLayoutId,\n encodeOutgoingPayload: buildOutgoingAppPayload,\n encodePageId: createAppPayloadPageId,\n encodeRouteId: createAppPayloadRouteId,\n encodeSlotId: createAppPayloadSlotId,\n encodeTemplateId: createAppPayloadTemplateId,\n isSlotId: isAppElementsWireSlotId,\n parseElementKey: parseAppElementsWireElementKey,\n readMetadata: readAppElementsMetadata,\n withLayoutFlags,\n};\n"],"mappings":";;;;AASA,MAAM,6BAA6B;AAEnC,MAAa,iCAAiC;AAC9C,MAAa,uBAAuB;AACpC,MAAa,+BAA+B;AAC5C,MAAa,qBAAqB;AAClC,MAAa,uBAAuB;AACpC,MAAa,6BAA6B;AAC1C,MAAa,gBAAgB;AAC7B,MAAa,sBAAsB;AACnC,MAAa,wBAAwB;AACrC,MAAa,gCAAgC;AAE7C,MAAa,iBAAiB,OAAO,IAAI,uBAAuB;AAkBhE,SAAgB,0BAA0B,MAAc,OAAuB;CAC7E,IAAI,OAAO,OAAO,OAAO;CACzB,IAAI,OAAO,OAAO,OAAO;CACzB,OAAO;;AAGT,SAAS,uCACP,MACA,OACQ;CACR,OAAO,0BAA0B,KAAK,QAAQ,MAAM,OAAO;;AAG7D,SAAgB,iCACd,cACA,UAA6C,EAAE,EACZ;CACnC,MAAM,iBAAiB,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ire.ts"],"sourcesContent":["import { isValidElement, type ReactNode } from \"react\";\nimport {\n createArtifactCompatibilityEnvelope,\n parseArtifactCompatibilityEnvelope,\n type ArtifactCompatibilityEnvelope,\n} from \"./artifact-compatibility.js\";\nimport type {\n CacheEntryReuseProof,\n CacheProofBreakerFallbackMode,\n CacheProofFallbackScope,\n CacheProofRejectionCode,\n RenderObservation,\n} from \"./cache-proof.js\";\nimport { isInterceptionMatchedUrlPath } from \"./normalize-path.js\";\n\nconst APP_INTERCEPTION_SEPARATOR = \"\\0\";\n\nexport const APP_ARTIFACT_COMPATIBILITY_KEY = \"__artifactCompatibility\";\nexport const APP_CACHE_ENTRY_REUSE_PROOF_KEY = \"__cacheEntryReuseProof\";\nexport const APP_INTERCEPTION_KEY = \"__interception\";\nexport const APP_INTERCEPTION_CONTEXT_KEY = \"__interceptionContext\";\nexport const APP_LAYOUT_IDS_KEY = \"__layoutIds\";\nexport const APP_LAYOUT_FLAGS_KEY = \"__layoutFlags\";\nexport const APP_RENDER_OBSERVATION_KEY = \"__renderObservation\";\nexport const APP_ROUTE_KEY = \"__route\";\nexport const APP_ROOT_LAYOUT_KEY = \"__rootLayout\";\nexport const APP_SLOT_BINDINGS_KEY = \"__slotBindings\";\nexport const APP_UNMATCHED_SLOT_WIRE_VALUE = \"__VINEXT_UNMATCHED_SLOT__\";\n\nexport const UNMATCHED_SLOT = Symbol.for(\"vinext.unmatchedSlot\");\n\nfunction createCacheProofRejectionCodeSet<const T extends readonly CacheProofRejectionCode[]>(\n codes: T &\n ([CacheProofRejectionCode] extends [T[number]]\n ? unknown\n : readonly [\n \"Missing cache proof rejection codes\",\n Exclude<CacheProofRejectionCode, T[number]>,\n ]),\n): ReadonlySet<string> {\n return new Set(codes);\n}\n\nconst CACHE_PROOF_REJECTION_CODES = createCacheProofRejectionCodeSet([\n \"CP_CACHE_ENTRY_PROOF_MISSING\",\n \"CP_MODEL_DISABLED\",\n \"CP_ARTIFACT_COMPATIBILITY_INCOMPATIBLE\",\n \"CP_ARTIFACT_COMPATIBILITY_UNKNOWN\",\n \"CP_DIMENSION_COUNT_EXCEEDED\",\n \"CP_DIMENSION_NAME_MISSING\",\n \"CP_DIMENSION_NAME_TOO_LONG\",\n \"CP_DIMENSION_VALUE_COUNT_EXCEEDED\",\n \"CP_DIMENSION_VALUE_TOO_LONG\",\n \"CP_DIMENSION_VALUES_MISSING\",\n \"CP_ENCODED_VARIANT_TOO_LONG\",\n \"CP_INVALID_VARIANT_BUDGET\",\n \"CP_ROUTE_VARIANT_BUDGET_ROUTE_MISMATCH\",\n \"CP_ROUTE_VARIANT_CEILING_EXCEEDED\",\n \"CP_UNSAFE_PUBLIC_DIMENSION\",\n \"CP_BOUNDARY_OUTCOME_MISMATCH\",\n \"CP_BOUNDARY_OUTCOME_UNKNOWN\",\n \"CP_PRIVATE_DYNAMIC_DOWNGRADE\",\n \"CP_STATIC_LAYOUT_CANDIDATE_OUTPUT_KIND\",\n \"CP_STATIC_LAYOUT_CURRENT_OUTPUT_KIND\",\n \"CP_STATIC_LAYOUT_ID_MISMATCH\",\n \"CP_STATIC_LAYOUT_OBSERVATION_OUTPUT_KIND\",\n \"CP_STATIC_LAYOUT_OBSERVATION_OUTPUT_MISMATCH\",\n \"CP_STATIC_LAYOUT_PRIVATE_DYNAMIC_DOWNGRADE\",\n \"CP_STATIC_LAYOUT_REQUEST_API_OBSERVED\",\n \"CP_STATIC_LAYOUT_REQUEST_API_UNKNOWN\",\n \"CP_STATIC_LAYOUT_ROOT_BOUNDARY_MISMATCH\",\n \"CP_STATIC_LAYOUT_ROOT_BOUNDARY_UNKNOWN\",\n \"CP_STATIC_LAYOUT_VARIANT_DIMENSION_UNPROVEN\",\n]);\n\nexport type AppElementsSlotBindingState = \"active\" | \"default\" | \"unmatched\";\n\nexport type AppElementsSlotBinding = Readonly<{\n ownerLayoutId: string | null;\n slotId: string;\n state: AppElementsSlotBindingState;\n}>;\n\nexport type AppElementsInterception = Readonly<{\n sourceMatchedUrl: string;\n sourceRouteId: string;\n slotId: string;\n targetMatchedUrl: string;\n targetRouteId: string;\n}>;\n\nexport function compareAppElementsSlotIds(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n\nfunction compareAppElementsSlotBindingsBySlotId(\n left: Pick<AppElementsSlotBinding, \"slotId\">,\n right: Pick<AppElementsSlotBinding, \"slotId\">,\n): number {\n return compareAppElementsSlotIds(left.slotId, right.slotId);\n}\n\nexport function normalizeAppElementsSlotBindings(\n slotBindings: readonly AppElementsSlotBinding[],\n options: { layoutIds?: readonly string[] } = {},\n): readonly AppElementsSlotBinding[] {\n const ownerLayoutIds = options.layoutIds ? new Set(options.layoutIds) : null;\n const seenSlotIds = new Set<string>();\n const normalized: AppElementsSlotBinding[] = [];\n\n for (const binding of slotBindings) {\n if (seenSlotIds.has(binding.slotId)) {\n throw new Error(\"[vinext] Invalid __slotBindings in App Router payload: duplicate slot id\");\n }\n seenSlotIds.add(binding.slotId);\n\n if (\n ownerLayoutIds &&\n binding.ownerLayoutId !== null &&\n !ownerLayoutIds.has(binding.ownerLayoutId)\n ) {\n throw new Error(\n \"[vinext] Invalid __slotBindings in App Router payload: owner layout id missing from __layoutIds\",\n );\n }\n\n normalized.push({ ...binding });\n }\n\n return normalized.sort(compareAppElementsSlotBindingsBySlotId);\n}\n\nexport type AppElementValue =\n | ReactNode\n | typeof UNMATCHED_SLOT\n | string\n | null\n | LayoutFlags\n | ArtifactCompatibilityEnvelope\n | CacheEntryReuseProof\n | AppElementsInterception\n | readonly AppElementsSlotBinding[];\ntype AppWireElementValue =\n | ReactNode\n | string\n | null\n | LayoutFlags\n | ArtifactCompatibilityEnvelope\n | CacheEntryReuseProof\n | AppElementsInterception\n | readonly AppElementsSlotBinding[];\n\nexport type AppElements = Readonly<Record<string, AppElementValue>>;\nexport type AppWireElements = Readonly<Record<string, AppWireElementValue>>;\n\n/**\n * Per-layout static/dynamic flags. `\"s\"` = static (skippable on next nav);\n * `\"d\"` = dynamic (must always render).\n *\n * Lifecycle (partial — later PRs extend this):\n *\n * 1. PROBE — probeAppPageLayouts (server/app-page-execution.ts) returns\n * LayoutFlags for every layout in the route at render time.\n *\n * 2. ATTACH — AppElementsWire.encodeOutgoingPayload writes `__layoutFlags`\n * into the outgoing App Router payload record.\n *\n * 3. WIRE — renderToReadableStream serializes the record as RSC row 0.\n *\n * 4. PARSE — AppElementsWire.readMetadata extracts layoutFlags from the\n * wire payload on the client side.\n */\nexport type LayoutFlags = Readonly<Record<string, \"s\" | \"d\">>;\n\ntype AppElementsMetadata = {\n artifactCompatibility: ArtifactCompatibilityEnvelope;\n cacheEntryReuseProof?: CacheEntryReuseProof;\n interception: AppElementsInterception | null;\n interceptionContext: string | null;\n layoutIds: readonly string[];\n layoutFlags: LayoutFlags;\n routeId: string;\n rootLayoutTreePath: string | null;\n slotBindings: readonly AppElementsSlotBinding[];\n};\n\ntype AppElementsWireElementKey =\n | { kind: \"layout\"; treePath: string }\n | { interceptionContext: string | null; kind: \"page\"; path: string }\n | { interceptionContext: string | null; kind: \"route\"; path: string }\n | { kind: \"slot\"; name: string; treePath: string }\n | { kind: \"template\"; treePath: string };\n\ntype AppElementsWireMetadataInput = {\n interception?: AppElementsInterception | null;\n interceptionContext: string | null;\n layoutIds?: readonly string[];\n routeId: string;\n rootLayoutTreePath: string | null;\n slotBindings?: readonly AppElementsSlotBinding[];\n};\n\ntype AppElementsWireMetadataEntries = Readonly<{\n [APP_ROUTE_KEY]: string;\n [APP_INTERCEPTION_KEY]?: AppElementsInterception;\n [APP_INTERCEPTION_CONTEXT_KEY]: string | null;\n [APP_LAYOUT_IDS_KEY]: readonly string[];\n [APP_ROOT_LAYOUT_KEY]: string | null;\n [APP_SLOT_BINDINGS_KEY]?: readonly AppElementsSlotBinding[];\n}>;\n\n/**\n * The outgoing wire payload shape. Includes ReactNode values for the\n * rendered tree plus metadata values like LayoutFlags attached under\n * known keys (e.g. __layoutFlags). Distinct from AppElements / AppWireElements\n * which only carry render-time values.\n */\nexport type AppOutgoingElements = Readonly<\n Record<\n string,\n | ReactNode\n | LayoutFlags\n | ArtifactCompatibilityEnvelope\n | CacheEntryReuseProof\n | AppElementsInterception\n | RenderObservation\n | readonly AppElementsSlotBinding[]\n >\n>;\n\ntype AppElementsWireKeys = {\n readonly artifactCompatibility: typeof APP_ARTIFACT_COMPATIBILITY_KEY;\n readonly cacheEntryReuseProof: typeof APP_CACHE_ENTRY_REUSE_PROOF_KEY;\n readonly interception: typeof APP_INTERCEPTION_KEY;\n readonly interceptionContext: typeof APP_INTERCEPTION_CONTEXT_KEY;\n readonly layoutIds: typeof APP_LAYOUT_IDS_KEY;\n readonly layoutFlags: typeof APP_LAYOUT_FLAGS_KEY;\n readonly renderObservation: typeof APP_RENDER_OBSERVATION_KEY;\n readonly rootLayout: typeof APP_ROOT_LAYOUT_KEY;\n readonly route: typeof APP_ROUTE_KEY;\n readonly slotBindings: typeof APP_SLOT_BINDINGS_KEY;\n};\n\ntype AppElementsWireCodec = {\n readonly keys: AppElementsWireKeys;\n readonly unmatchedSlotValue: typeof APP_UNMATCHED_SLOT_WIRE_VALUE;\n createMetadataEntries(input: AppElementsWireMetadataInput): AppElementsWireMetadataEntries;\n decode(elements: AppWireElements): AppElements;\n encodeCacheKey(rscUrl: string, interceptionContext: string | null): string;\n encodeLayoutId(treePath: string): string;\n encodeOutgoingPayload(input: {\n element:\n | ReactNode\n | Readonly<\n Record<string, ReactNode | AppElementsInterception | readonly AppElementsSlotBinding[]>\n >;\n artifactCompatibility?: ArtifactCompatibilityEnvelope;\n cacheEntryReuseProof?: CacheEntryReuseProof;\n layoutFlags: LayoutFlags;\n renderObservation?: RenderObservation;\n }): ReactNode | AppOutgoingElements;\n encodePageId(routePath: string, interceptionContext: string | null): string;\n encodeRouteId(routePath: string, interceptionContext: string | null): string;\n encodeSlotId(slotName: string, treePath: string): string;\n encodeTemplateId(treePath: string): string;\n isSlotId(key: string): boolean;\n parseElementKey(key: string): AppElementsWireElementKey | null;\n readMetadata(elements: Readonly<Record<string, unknown>>): AppElementsMetadata;\n withLayoutFlags<T extends Record<string, unknown>>(\n elements: T,\n layoutFlags: LayoutFlags,\n ): T & { [APP_LAYOUT_FLAGS_KEY]: LayoutFlags };\n};\n\nfunction appendInterceptionContext(identity: string, interceptionContext: string | null): string {\n return interceptionContext === null\n ? identity\n : `${identity}${APP_INTERCEPTION_SEPARATOR}${interceptionContext}`;\n}\n\nfunction createAppPayloadRouteId(routePath: string, interceptionContext: string | null): string {\n return appendInterceptionContext(`route:${routePath}`, interceptionContext);\n}\n\nfunction createAppPayloadPageId(routePath: string, interceptionContext: string | null): string {\n return appendInterceptionContext(`page:${routePath}`, interceptionContext);\n}\n\nfunction createAppPayloadLayoutId(treePath: string): string {\n return `layout:${treePath}`;\n}\n\nfunction createAppPayloadTemplateId(treePath: string): string {\n return `template:${treePath}`;\n}\n\nfunction createAppPayloadSlotId(slotName: string, treePath: string): string {\n return `slot:${slotName}:${treePath}`;\n}\n\nfunction createAppPayloadCacheKey(rscUrl: string, interceptionContext: string | null): string {\n return appendInterceptionContext(rscUrl, interceptionContext);\n}\n\nfunction parsePathWithInterception(input: string): {\n interceptionContext: string | null;\n path: string;\n} | null {\n const separatorIndex = input.indexOf(APP_INTERCEPTION_SEPARATOR);\n const path = separatorIndex === -1 ? input : input.slice(0, separatorIndex);\n if (!path.startsWith(\"/\")) return null;\n\n return {\n interceptionContext: separatorIndex === -1 ? null : input.slice(separatorIndex + 1),\n path,\n };\n}\n\n/**\n * AppElements tree paths are absolute route-tree paths on the wire.\n * Bare segment names are not valid layout/template/slot tree identities.\n */\nfunction parseTreePath(input: string): string | null {\n return input.startsWith(\"/\") ? input : null;\n}\n\nfunction parseAppElementsWireElementKey(key: string): AppElementsWireElementKey | null {\n if (key.startsWith(\"route:\")) {\n const parsed = parsePathWithInterception(key.slice(\"route:\".length));\n if (!parsed) return null;\n return { interceptionContext: parsed.interceptionContext, kind: \"route\", path: parsed.path };\n }\n\n if (key.startsWith(\"page:\")) {\n const parsed = parsePathWithInterception(key.slice(\"page:\".length));\n if (!parsed) return null;\n return { interceptionContext: parsed.interceptionContext, kind: \"page\", path: parsed.path };\n }\n\n if (key.startsWith(\"layout:\")) {\n const treePath = parseTreePath(key.slice(\"layout:\".length));\n return treePath ? { kind: \"layout\", treePath } : null;\n }\n\n if (key.startsWith(\"template:\")) {\n const treePath = parseTreePath(key.slice(\"template:\".length));\n return treePath ? { kind: \"template\", treePath } : null;\n }\n\n if (key.startsWith(\"slot:\")) {\n const body = key.slice(\"slot:\".length);\n const separatorIndex = body.indexOf(\":\");\n if (separatorIndex <= 0) return null;\n const name = body.slice(0, separatorIndex);\n const treePath = parseTreePath(body.slice(separatorIndex + 1));\n return treePath ? { kind: \"slot\", name, treePath } : null;\n }\n\n return null;\n}\n\nfunction isAppElementsWireSlotId(key: string): boolean {\n if (!key.startsWith(\"slot:\")) return false;\n const body = key.slice(\"slot:\".length);\n const separatorIndex = body.indexOf(\":\");\n return separatorIndex > 0 && body.charCodeAt(separatorIndex + 1) === 0x2f;\n}\n\nfunction createAppElementsWireMetadataEntries(\n input: AppElementsWireMetadataInput,\n): AppElementsWireMetadataEntries {\n const layoutIds = [...(input.layoutIds ?? [])];\n const entries: AppElementsWireMetadataEntries = {\n [APP_ROUTE_KEY]: input.routeId,\n [APP_INTERCEPTION_CONTEXT_KEY]: input.interceptionContext,\n [APP_LAYOUT_IDS_KEY]: layoutIds,\n [APP_ROOT_LAYOUT_KEY]: input.rootLayoutTreePath,\n };\n // Empty slot binding metadata is intentionally omitted. Missing\n // __slotBindings round-trips as [] and means \"no route-state proof\", so\n // default/unmatched slot preservation is not promoted for that payload.\n const entriesWithInterception = input.interception\n ? { ...entries, [APP_INTERCEPTION_KEY]: input.interception }\n : entries;\n if (input.slotBindings && input.slotBindings.length > 0) {\n return {\n ...entriesWithInterception,\n [APP_SLOT_BINDINGS_KEY]: normalizeAppElementsSlotBindings(input.slotBindings, { layoutIds }),\n };\n }\n return entriesWithInterception;\n}\n\nexport function normalizeAppElements(elements: AppWireElements): AppElements {\n let needsNormalization = false;\n for (const [key, value] of Object.entries(elements)) {\n if (isAppElementsWireSlotId(key) && value === APP_UNMATCHED_SLOT_WIRE_VALUE) {\n needsNormalization = true;\n break;\n }\n }\n\n if (!needsNormalization) {\n return elements;\n }\n\n const normalized: Record<string, AppElementValue> = {};\n for (const [key, value] of Object.entries(elements)) {\n normalized[key] =\n isAppElementsWireSlotId(key) && value === APP_UNMATCHED_SLOT_WIRE_VALUE\n ? UNMATCHED_SLOT\n : value;\n }\n\n return normalized;\n}\n\nfunction isLayoutFlagsRecord(value: unknown): value is LayoutFlags {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n for (const v of Object.values(value)) {\n if (v !== \"s\" && v !== \"d\") return false;\n }\n return true;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction parseLayoutFlags(value: unknown): LayoutFlags {\n if (isLayoutFlagsRecord(value)) return value;\n return {};\n}\n\nfunction parseLayoutIds(value: unknown): readonly string[] {\n if (value === undefined) return [];\n if (!Array.isArray(value)) {\n throw new Error(\n \"[vinext] Invalid __layoutIds in App Router payload: expected layout id string[]\",\n );\n }\n\n const layoutIds: string[] = [];\n for (const entry of value) {\n if (typeof entry !== \"string\") {\n throw new Error(\n \"[vinext] Invalid __layoutIds in App Router payload: expected layout id string[]\",\n );\n }\n\n const parsed = parseAppElementsWireElementKey(entry);\n if (parsed?.kind !== \"layout\") {\n throw new Error(\"[vinext] Invalid __layoutIds in App Router payload: expected layout ids\");\n }\n\n layoutIds.push(entry);\n }\n return layoutIds;\n}\n\nfunction isSlotBindingState(value: unknown): value is AppElementsSlotBindingState {\n return value === \"active\" || value === \"default\" || value === \"unmatched\";\n}\n\nfunction parseSlotBindings(\n value: unknown,\n options: { layoutIds?: readonly string[] } = {},\n): readonly AppElementsSlotBinding[] {\n // Missing metadata is compatibility-safe but not semantic proof: callers see\n // an empty binding list, so promoted default/unmatched slot preservation is\n // denied instead of inferred from legacy transport shape.\n if (value === undefined) return [];\n if (!Array.isArray(value)) {\n throw new Error(\"[vinext] Invalid __slotBindings in App Router payload: expected array\");\n }\n\n const slotBindings: AppElementsSlotBinding[] = [];\n for (const entry of value) {\n if (!isRecord(entry)) {\n throw new Error(\"[vinext] Invalid __slotBindings in App Router payload: expected objects\");\n }\n\n const slotId = entry.slotId;\n if (typeof slotId !== \"string\" || parseAppElementsWireElementKey(slotId)?.kind !== \"slot\") {\n throw new Error(\"[vinext] Invalid __slotBindings in App Router payload: expected slot ids\");\n }\n\n const ownerLayoutId = entry.ownerLayoutId;\n if (\n ownerLayoutId !== null &&\n (typeof ownerLayoutId !== \"string\" ||\n parseAppElementsWireElementKey(ownerLayoutId)?.kind !== \"layout\")\n ) {\n throw new Error(\n \"[vinext] Invalid __slotBindings in App Router payload: expected owner layout ids\",\n );\n }\n\n const state = entry.state;\n if (!isSlotBindingState(state)) {\n throw new Error(\"[vinext] Invalid __slotBindings in App Router payload: expected state\");\n }\n\n slotBindings.push({ ownerLayoutId, slotId, state });\n }\n return normalizeAppElementsSlotBindings(slotBindings, options);\n}\n\nfunction readRequiredInterceptionString(\n entry: Record<string, unknown>,\n fieldName: keyof AppElementsInterception,\n): string {\n const value = entry[fieldName];\n if (typeof value !== \"string\") {\n throw new Error(\"[vinext] Invalid __interception in App Router payload: expected strings\");\n }\n return value;\n}\n\nfunction parseInterceptionMatchedUrl(value: string): string {\n if (!isInterceptionMatchedUrlPath(value)) {\n throw new Error(\"[vinext] Invalid __interception in App Router payload: expected path URLs\");\n }\n return value;\n}\n\nfunction parseInterceptionRouteId(value: string, matchedUrl: string): string {\n const parsed = parseAppElementsWireElementKey(value);\n if (\n parsed?.kind !== \"route\" ||\n parsed.path !== matchedUrl ||\n parsed.interceptionContext !== null\n ) {\n throw new Error(\"[vinext] Invalid __interception in App Router payload: expected route ids\");\n }\n return value;\n}\n\nfunction parseInterceptionSlotId(value: string): string {\n if (parseAppElementsWireElementKey(value)?.kind !== \"slot\") {\n throw new Error(\"[vinext] Invalid __interception in App Router payload: expected slot id\");\n }\n return value;\n}\n\nfunction parseInterceptionMetadata(value: unknown): AppElementsInterception | null {\n if (value === undefined || value === null) return null;\n if (!isRecord(value)) {\n throw new Error(\"[vinext] Invalid __interception in App Router payload: expected object\");\n }\n\n const sourceMatchedUrl = parseInterceptionMatchedUrl(\n readRequiredInterceptionString(value, \"sourceMatchedUrl\"),\n );\n const targetMatchedUrl = parseInterceptionMatchedUrl(\n readRequiredInterceptionString(value, \"targetMatchedUrl\"),\n );\n return {\n sourceMatchedUrl,\n sourceRouteId: parseInterceptionRouteId(\n readRequiredInterceptionString(value, \"sourceRouteId\"),\n sourceMatchedUrl,\n ),\n slotId: parseInterceptionSlotId(readRequiredInterceptionString(value, \"slotId\")),\n targetMatchedUrl,\n targetRouteId: parseInterceptionRouteId(\n readRequiredInterceptionString(value, \"targetRouteId\"),\n targetMatchedUrl,\n ),\n };\n}\n\n/**\n * Type predicate for a plain (non-null, non-array) record of app payload values.\n * Used to distinguish the App Router payload object from bare React elements at\n * the render boundary. Narrows to `Readonly<Record<string, unknown>>` because\n * the outgoing payload carries heterogeneous values (ReactNodes for the rendered\n * tree, plus metadata like `__layoutFlags` which is a plain object). Delegates\n * to React's canonical `isValidElement` so we don't depend on React's internal\n * `$$typeof` marker scheme.\n */\nexport function isAppElementsRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n if (typeof value !== \"object\" || value === null) return false;\n if (Array.isArray(value)) return false;\n if (isValidElement(value)) return false;\n return true;\n}\n\nexport function withLayoutFlags<T extends Record<string, unknown>>(\n elements: T,\n layoutFlags: LayoutFlags,\n): T & { [APP_LAYOUT_FLAGS_KEY]: LayoutFlags } {\n return { ...elements, [APP_LAYOUT_FLAGS_KEY]: layoutFlags };\n}\n\nexport function buildOutgoingAppPayload(input: {\n element:\n | ReactNode\n | Readonly<\n Record<string, ReactNode | AppElementsInterception | readonly AppElementsSlotBinding[]>\n >;\n artifactCompatibility?: ArtifactCompatibilityEnvelope;\n cacheEntryReuseProof?: CacheEntryReuseProof;\n layoutFlags: LayoutFlags;\n renderObservation?: RenderObservation;\n}): ReactNode | AppOutgoingElements {\n if (!isAppElementsRecord(input.element)) {\n return input.element;\n }\n const payload: Record<\n string,\n | ReactNode\n | LayoutFlags\n | ArtifactCompatibilityEnvelope\n | CacheEntryReuseProof\n | AppElementsInterception\n | RenderObservation\n | readonly AppElementsSlotBinding[]\n > = {\n ...input.element,\n [APP_LAYOUT_FLAGS_KEY]: input.layoutFlags,\n [APP_ARTIFACT_COMPATIBILITY_KEY]:\n input.artifactCompatibility ?? createArtifactCompatibilityEnvelope(),\n };\n if (input.cacheEntryReuseProof) {\n payload[APP_CACHE_ENTRY_REUSE_PROOF_KEY] = input.cacheEntryReuseProof;\n }\n if (input.renderObservation) {\n payload[APP_RENDER_OBSERVATION_KEY] = input.renderObservation;\n }\n return payload;\n}\n\nfunction readArtifactCompatibilityMetadata(value: unknown): ArtifactCompatibilityEnvelope {\n if (value === undefined) return createArtifactCompatibilityEnvelope();\n\n const artifactCompatibility = parseArtifactCompatibilityEnvelope(value);\n // TODO(#726-COMPAT-04): hard-fail malformed compatibility metadata once\n // cache/skip consumers depend on this proof. During Wave01 the field is\n // emitted as scaffolding, so bad or future-version values degrade like\n // missing __layoutFlags instead of crashing render paths that do not read it.\n return artifactCompatibility ?? createArtifactCompatibilityEnvelope();\n}\n\nfunction createMissingCacheEntryReuseProof(): CacheEntryReuseProof {\n return {\n kind: \"runtime-cache-entry\",\n decision: null,\n };\n}\n\nfunction isCacheProofRejectionCode(value: unknown): value is CacheProofRejectionCode {\n return typeof value === \"string\" && CACHE_PROOF_REJECTION_CODES.has(value);\n}\n\nfunction isCacheProofFallbackMode(value: unknown): value is CacheProofBreakerFallbackMode {\n return value === \"renderFresh\" || value === \"privateUncacheable\";\n}\n\nfunction isCacheProofFallbackScope(value: unknown): value is CacheProofFallbackScope {\n return value === \"affectedOutput\" || value === \"route\";\n}\n\n// Three-way wire semantics are intentional:\n// - null means the proof field was absent and no cache authority was claimed.\n// - { decision: null } means a present proof was malformed or unusable.\n// - { decision: ... } means the proof parsed into an explicit reuse decision.\nfunction parseCacheEntryReuseProofMetadata(value: unknown): CacheEntryReuseProof | null {\n if (value === undefined) return null;\n if (!isRecord(value) || value.kind !== \"runtime-cache-entry\") {\n return createMissingCacheEntryReuseProof();\n }\n\n const decision = value.decision;\n if (decision === null) return createMissingCacheEntryReuseProof();\n if (!isRecord(decision)) return createMissingCacheEntryReuseProof();\n\n if (\n decision.kind === \"reuse\" &&\n decision.canReuse === true &&\n decision.code === \"CP_STATIC_LAYOUT_REUSE_PROVEN\" &&\n // Static layout proofs are the only runtime cache-entry reuse class today.\n // Extend this parser alongside any new reuse class before it can restore\n // visited cache entries as commit-capable payloads.\n decision.reuseClass === \"static-layout\"\n ) {\n return {\n kind: \"runtime-cache-entry\",\n decision: {\n canReuse: true,\n code: decision.code,\n kind: \"reuse\",\n reuseClass: decision.reuseClass,\n },\n };\n }\n\n if (\n decision.kind === \"reject\" &&\n decision.canReuse === false &&\n isCacheProofRejectionCode(decision.code) &&\n isCacheProofFallbackMode(decision.mode) &&\n isCacheProofFallbackScope(decision.scope)\n ) {\n return {\n kind: \"runtime-cache-entry\",\n decision: {\n canReuse: false,\n code: decision.code,\n kind: \"reject\",\n mode: decision.mode,\n scope: decision.scope,\n },\n };\n }\n\n return createMissingCacheEntryReuseProof();\n}\n\nexport function readAppElementsMetadata(\n elements: Readonly<Record<string, unknown>>,\n): AppElementsMetadata {\n const routeId = elements[APP_ROUTE_KEY];\n if (typeof routeId !== \"string\") {\n throw new Error(\"[vinext] Missing __route string in App Router payload\");\n }\n\n const interceptionContext = elements[APP_INTERCEPTION_CONTEXT_KEY];\n if (\n interceptionContext !== undefined &&\n interceptionContext !== null &&\n typeof interceptionContext !== \"string\"\n ) {\n throw new Error(\"[vinext] Invalid __interceptionContext in App Router payload\");\n }\n\n const rootLayoutTreePath = elements[APP_ROOT_LAYOUT_KEY];\n if (rootLayoutTreePath === undefined) {\n throw new Error(\"[vinext] Missing __rootLayout key in App Router payload\");\n }\n if (rootLayoutTreePath !== null && typeof rootLayoutTreePath !== \"string\") {\n throw new Error(\"[vinext] Invalid __rootLayout in App Router payload: expected string or null\");\n }\n\n const layoutFlags = parseLayoutFlags(elements[APP_LAYOUT_FLAGS_KEY]);\n const layoutIds = parseLayoutIds(elements[APP_LAYOUT_IDS_KEY]);\n const slotBindings = parseSlotBindings(elements[APP_SLOT_BINDINGS_KEY], { layoutIds });\n const interception = parseInterceptionMetadata(elements[APP_INTERCEPTION_KEY]);\n const artifactCompatibility = readArtifactCompatibilityMetadata(\n elements[APP_ARTIFACT_COMPATIBILITY_KEY],\n );\n const cacheEntryReuseProof = parseCacheEntryReuseProofMetadata(\n elements[APP_CACHE_ENTRY_REUSE_PROOF_KEY],\n );\n\n return {\n artifactCompatibility,\n ...(cacheEntryReuseProof ? { cacheEntryReuseProof } : {}),\n interception,\n interceptionContext: interceptionContext ?? null,\n layoutIds,\n layoutFlags,\n routeId,\n rootLayoutTreePath,\n slotBindings,\n };\n}\n\nexport const AppElementsWire: AppElementsWireCodec = {\n // WIRE follow-ups use these stable key names when moving payload readers and writers\n // behind the codec boundary.\n keys: {\n artifactCompatibility: APP_ARTIFACT_COMPATIBILITY_KEY,\n cacheEntryReuseProof: APP_CACHE_ENTRY_REUSE_PROOF_KEY,\n interception: APP_INTERCEPTION_KEY,\n interceptionContext: APP_INTERCEPTION_CONTEXT_KEY,\n layoutIds: APP_LAYOUT_IDS_KEY,\n layoutFlags: APP_LAYOUT_FLAGS_KEY,\n renderObservation: APP_RENDER_OBSERVATION_KEY,\n rootLayout: APP_ROOT_LAYOUT_KEY,\n route: APP_ROUTE_KEY,\n slotBindings: APP_SLOT_BINDINGS_KEY,\n },\n unmatchedSlotValue: APP_UNMATCHED_SLOT_WIRE_VALUE,\n createMetadataEntries: createAppElementsWireMetadataEntries,\n decode: normalizeAppElements,\n encodeCacheKey: createAppPayloadCacheKey,\n encodeLayoutId: createAppPayloadLayoutId,\n encodeOutgoingPayload: buildOutgoingAppPayload,\n encodePageId: createAppPayloadPageId,\n encodeRouteId: createAppPayloadRouteId,\n encodeSlotId: createAppPayloadSlotId,\n encodeTemplateId: createAppPayloadTemplateId,\n isSlotId: isAppElementsWireSlotId,\n parseElementKey: parseAppElementsWireElementKey,\n readMetadata: readAppElementsMetadata,\n withLayoutFlags,\n};\n"],"mappings":";;;;AAeA,MAAM,6BAA6B;AAEnC,MAAa,iCAAiC;AAC9C,MAAa,kCAAkC;AAC/C,MAAa,uBAAuB;AACpC,MAAa,+BAA+B;AAC5C,MAAa,qBAAqB;AAClC,MAAa,uBAAuB;AACpC,MAAa,6BAA6B;AAC1C,MAAa,gBAAgB;AAC7B,MAAa,sBAAsB;AACnC,MAAa,wBAAwB;AACrC,MAAa,gCAAgC;AAE7C,MAAa,iBAAiB,OAAO,IAAI,uBAAuB;AAEhE,SAAS,iCACP,OAOqB;CACrB,OAAO,IAAI,IAAI,MAAM;;AAGvB,MAAM,8BAA8B,iCAAiC;CACnE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAkBF,SAAgB,0BAA0B,MAAc,OAAuB;CAC7E,IAAI,OAAO,OAAO,OAAO;CACzB,IAAI,OAAO,OAAO,OAAO;CACzB,OAAO;;AAGT,SAAS,uCACP,MACA,OACQ;CACR,OAAO,0BAA0B,KAAK,QAAQ,MAAM,OAAO;;AAG7D,SAAgB,iCACd,cACA,UAA6C,EAAE,EACZ;CACnC,MAAM,iBAAiB,QAAQ,YAAY,IAAI,IAAI,QAAQ,UAAU,GAAG;CACxE,MAAM,8BAAc,IAAI,KAAa;CACrC,MAAM,aAAuC,EAAE;CAE/C,KAAK,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AO,wBAAwB,UAE/B,MAAM,IAAI,MAAM,+DAA+D;CAGjF,MAAM,qBAAqB,SAAS;CACpC,IAAI,uBAAuB,KAAA,GACzB,MAAM,IAAI,MAAM,0DAA0D;CAE5E,IAAI,uBAAuB,QAAQ,OAAO,uBAAuB,UAC/D,MAAM,IAAI,MAAM,+EAA+E;CAGjG,MAAM,cAAc,iBAAiB,SAAS,sBAAsB;CACpE,MAAM,YAAY,eAAe,SAAS,oBAAoB;CAC9D,MAAM,eAAe,kBAAkB,SAAS,wBAAwB,EAAE,WAAW,CAAC;CACtF,MAAM,eAAe,0BAA0B,SAAS,sBAAsB;CAC9E,MAAM,wBAAwB,kCAC5B,SAAS,gCACV;CACD,MAAM,uBAAuB,kCAC3B,SAAS,iCACV;CAED,OAAO;EACL;EACA,GAAI,uBAAuB,EAAE,sBAAsB,GAAG,EAAE;EACxD;EACA,qBAAqB,uBAAuB;EAC5C;EACA;EACA;EACA;EACA;EACD;;AAGH,MAAa,kBAAwC;CAGnD,MAAM;EACJ,uBAAuB;EACvB,sBAAsB;EACtB,cAAc;EACd,qBAAqB;EACrB,WAAW;EACX,aAAa;EACb,mBAAmB;EACnB,YAAY;EACZ,OAAO;EACP,cAAc;EACf;CACD,oBAAoB;CACpB,uBAAuB;CACvB,QAAQ;CACR,gBAAgB;CAChB,gBAAgB;CAChB,uBAAuB;CACvB,cAAc;CACd,eAAe;CACf,cAAc;CACd,kBAAkB;CAClB,UAAU;CACV,iBAAiB;CACjB,cAAc;CACd;CACD"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { APP_ARTIFACT_COMPATIBILITY_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_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
|
+
declare const APP_PREFETCH_LOADING_SHELL_MARKER_KEY = "__prefetchLoadingShell";
|
|
4
5
|
declare function getMountedSlotIds(elements: AppElements): string[];
|
|
5
6
|
declare function getMountedSlotIdsHeader(elements: AppElements): string | null;
|
|
6
7
|
declare function resolveVisitedResponseInterceptionContext(requestInterceptionContext: string | null, payloadInterceptionContext: string | null): string | null;
|
|
7
8
|
//#endregion
|
|
8
|
-
export { APP_ARTIFACT_COMPATIBILITY_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, 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_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
10
|
//# sourceMappingURL=app-elements.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { normalizeMountedSlotsHeader } from "./app-mounted-slots-header.js";
|
|
2
|
-
import { APP_ARTIFACT_COMPATIBILITY_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";
|
|
2
|
+
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";
|
|
3
3
|
//#region src/server/app-elements.ts
|
|
4
|
+
const APP_PREFETCH_LOADING_SHELL_MARKER_KEY = "__prefetchLoadingShell";
|
|
4
5
|
function getMountedSlotIds(elements) {
|
|
5
6
|
return Object.keys(elements).filter((key) => {
|
|
6
7
|
const value = elements[key];
|
|
@@ -14,6 +15,6 @@ function resolveVisitedResponseInterceptionContext(requestInterceptionContext, p
|
|
|
14
15
|
return payloadInterceptionContext ?? requestInterceptionContext;
|
|
15
16
|
}
|
|
16
17
|
//#endregion
|
|
17
|
-
export { APP_ARTIFACT_COMPATIBILITY_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, 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_UNMATCHED_SLOT_WIRE_VALUE, AppElementsWire, UNMATCHED_SLOT, buildOutgoingAppPayload, compareAppElementsSlotIds, getMountedSlotIds, getMountedSlotIdsHeader, isAppElementsRecord, normalizeAppElements, normalizeAppElementsSlotBindings, readAppElementsMetadata, resolveVisitedResponseInterceptionContext, withLayoutFlags };
|
|
18
19
|
|
|
19
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 {\n AppElementsWire,\n APP_ARTIFACT_COMPATIBILITY_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":";;;
|
|
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;AAkCrD,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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { renderAppPageErrorBoundary, renderAppPageHttpAccessFallback } from "./app-page-boundary-render.js";
|
|
2
|
+
import { DEFAULT_GLOBAL_ERROR_MODULE } from "./default-global-error-module.js";
|
|
2
3
|
//#region src/server/app-fallback-renderer.ts
|
|
3
4
|
const EMPTY_MW_CTX = {
|
|
4
5
|
headers: null,
|
|
@@ -7,6 +8,7 @@ const EMPTY_MW_CTX = {
|
|
|
7
8
|
function createAppFallbackRenderer(options) {
|
|
8
9
|
const { basePath = "", clearRequestContext, createRscOnErrorHandler: buildRscOnErrorHandler, fontProviders, getNavigationContext, globalErrorModule, globalNotFoundModule, makeThenableParams, metadataRoutes, resolveChildSegments, rootBoundaries, rscRenderer, sanitizer, ssrLoader } = options;
|
|
9
10
|
const { rootForbiddenModule, rootLayouts, rootNotFoundModule, rootUnauthorizedModule } = rootBoundaries;
|
|
11
|
+
const effectiveGlobalErrorModule = globalErrorModule ?? DEFAULT_GLOBAL_ERROR_MODULE;
|
|
10
12
|
return {
|
|
11
13
|
renderHttpAccessFallback(route, statusCode, isRscRequest, request, opts, scriptNonce, middlewareContext) {
|
|
12
14
|
if (statusCode === 404 && !!globalNotFoundModule && !route && !opts?.boundaryComponent) {
|
|
@@ -22,7 +24,7 @@ function createAppFallbackRenderer(options) {
|
|
|
22
24
|
getFontPreloads: fontProviders.getFontPreloads,
|
|
23
25
|
getFontStyles: fontProviders.getFontStyles,
|
|
24
26
|
getNavigationContext,
|
|
25
|
-
globalErrorModule,
|
|
27
|
+
globalErrorModule: effectiveGlobalErrorModule,
|
|
26
28
|
isRscRequest,
|
|
27
29
|
layoutModules: [],
|
|
28
30
|
loadSsrHandler: ssrLoader,
|
|
@@ -55,7 +57,7 @@ function createAppFallbackRenderer(options) {
|
|
|
55
57
|
getFontPreloads: fontProviders.getFontPreloads,
|
|
56
58
|
getFontStyles: fontProviders.getFontStyles,
|
|
57
59
|
getNavigationContext,
|
|
58
|
-
globalErrorModule,
|
|
60
|
+
globalErrorModule: effectiveGlobalErrorModule,
|
|
59
61
|
isRscRequest,
|
|
60
62
|
layoutModules: opts?.layouts ?? null,
|
|
61
63
|
loadSsrHandler: ssrLoader,
|
|
@@ -91,7 +93,7 @@ function createAppFallbackRenderer(options) {
|
|
|
91
93
|
getFontPreloads: fontProviders.getFontPreloads,
|
|
92
94
|
getFontStyles: fontProviders.getFontStyles,
|
|
93
95
|
getNavigationContext,
|
|
94
|
-
globalErrorModule,
|
|
96
|
+
globalErrorModule: effectiveGlobalErrorModule,
|
|
95
97
|
isRscRequest,
|
|
96
98
|
loadSsrHandler: ssrLoader,
|
|
97
99
|
makeThenableParams,
|