vinext 0.0.49 → 0.0.50
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/client-build-config.js.map +1 -1
- package/dist/build/google-fonts/build-url.js.map +1 -1
- package/dist/build/google-fonts/get-axes.js.map +1 -1
- package/dist/build/google-fonts/sort-variants.js.map +1 -1
- package/dist/build/google-fonts/validate.js.map +1 -1
- package/dist/build/layout-classification.js.map +1 -1
- package/dist/build/nitro-route-rules.js.map +1 -1
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +17 -1
- package/dist/build/prerender.js +77 -16
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/report.js.map +1 -1
- package/dist/build/route-classification-injector.js.map +1 -1
- package/dist/build/route-classification-manifest.js.map +1 -1
- package/dist/build/run-prerender.js.map +1 -1
- package/dist/build/server-manifest.js.map +1 -1
- package/dist/build/ssr-manifest.js.map +1 -1
- package/dist/build/standalone.js.map +1 -1
- package/dist/build/static-export.js.map +1 -1
- package/dist/check.js +1 -1
- package/dist/check.js.map +1 -1
- package/dist/cli-args.js.map +1 -1
- package/dist/cli.js +8 -4
- package/dist/cli.js.map +1 -1
- package/dist/client/instrumentation-client-state.js.map +1 -1
- package/dist/client/validate-module-path.js.map +1 -1
- package/dist/client/vinext-next-data.d.ts +5 -1
- package/dist/client/window-next.d.ts +149 -0
- package/dist/client/window-next.js +48 -0
- package/dist/client/window-next.js.map +1 -0
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/cloudflare/tpr.js +2 -1
- package/dist/cloudflare/tpr.js.map +1 -1
- package/dist/config/config-matchers.d.ts +3 -1
- package/dist/config/config-matchers.js +5 -4
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/dotenv.js.map +1 -1
- package/dist/config/next-config.d.ts +6 -3
- package/dist/config/next-config.js +13 -2
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.js +13 -5
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +3 -1
- package/dist/entries/app-browser-entry.js +11 -2
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.js +11 -0
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.js +4 -0
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/app-ssr-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-entry-helpers.js.map +1 -1
- package/dist/entries/pages-server-entry.js +15 -0
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +76 -18
- package/dist/index.js.map +1 -1
- package/dist/init.js.map +1 -1
- package/dist/plugins/async-hooks-stub.js.map +1 -1
- package/dist/plugins/client-reference-dedup.js.map +1 -1
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/instrumentation-client.js.map +1 -1
- package/dist/plugins/og-assets.js.map +1 -1
- package/dist/plugins/optimize-imports.js.map +1 -1
- package/dist/plugins/postcss.js.map +1 -1
- package/dist/plugins/rsc-client-reference-loaders.d.ts +7 -0
- package/dist/plugins/rsc-client-reference-loaders.js +48 -0
- package/dist/plugins/rsc-client-reference-loaders.js.map +1 -0
- package/dist/plugins/rsc-client-shim-excludes.js.map +1 -1
- package/dist/plugins/server-externals-manifest.js.map +1 -1
- package/dist/plugins/strip-server-exports.js.map +1 -1
- package/dist/routing/app-route-graph.d.ts +48 -5
- package/dist/routing/app-route-graph.js +159 -15
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/file-matcher.js.map +1 -1
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/routing/route-matching.js.map +1 -1
- package/dist/routing/route-pattern.js.map +1 -1
- package/dist/routing/route-trie.js.map +1 -1
- package/dist/routing/route-validation.js.map +1 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-action-result.d.ts +19 -0
- package/dist/server/app-browser-action-result.js +18 -0
- package/dist/server/app-browser-action-result.js.map +1 -0
- package/dist/server/app-browser-entry.js +91 -48
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-error.js.map +1 -1
- package/dist/server/app-browser-hydration.d.ts +19 -0
- package/dist/server/app-browser-hydration.js +22 -0
- package/dist/server/app-browser-hydration.js.map +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +6 -3
- package/dist/server/app-browser-navigation-controller.js +67 -19
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-state.d.ts +17 -17
- package/dist/server/app-browser-state.js +122 -36
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +4 -0
- package/dist/server/app-browser-stream.js +24 -2
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +6 -1
- package/dist/server/app-browser-visible-commit.js +34 -19
- package/dist/server/app-browser-visible-commit.js.map +1 -1
- package/dist/server/app-client-reference-preloader.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +6 -1
- package/dist/server/app-elements-wire.js +17 -1
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-hook-warning-suppression.js.map +1 -1
- package/dist/server/app-middleware.d.ts +1 -1
- package/dist/server/app-middleware.js +4 -9
- package/dist/server/app-middleware.js.map +1 -1
- package/dist/server/app-mounted-slots-header.js.map +1 -1
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +14 -13
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.d.ts +1 -0
- package/dist/server/app-page-boundary.js +7 -5
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +10 -3
- package/dist/server/app-page-cache.js +42 -23
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +6 -1
- package/dist/server/app-page-dispatch.js +21 -7
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.d.ts +3 -1
- package/dist/server/app-page-element-builder.js +6 -2
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.js +4 -0
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-method.js.map +1 -1
- package/dist/server/app-page-params.js.map +1 -1
- package/dist/server/app-page-probe.js.map +1 -1
- package/dist/server/app-page-render.d.ts +7 -1
- package/dist/server/app-page-render.js +11 -4
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.js +2 -1
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.d.ts +2 -0
- package/dist/server/app-page-response.js +15 -5
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +6 -2
- package/dist/server/app-page-route-wiring.js +50 -49
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-segment-state.d.ts +10 -0
- package/dist/server/app-page-segment-state.js +87 -0
- package/dist/server/app-page-segment-state.js.map +1 -0
- package/dist/server/app-page-stream.d.ts +7 -2
- package/dist/server/app-page-stream.js +3 -1
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-post-middleware-context.js.map +1 -1
- package/dist/server/app-prerender-endpoints.js.map +1 -1
- package/dist/server/app-prerender-static-params.js.map +1 -1
- package/dist/server/app-render-dependency.js.map +1 -1
- package/dist/server/app-request-context.js.map +1 -1
- package/dist/server/app-route-handler-cache.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.js +3 -1
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-policy.js +1 -0
- package/dist/server/app-route-handler-policy.js.map +1 -1
- package/dist/server/app-route-handler-response.js +4 -3
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-route-handler-runtime.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-cache-busting.d.ts +5 -2
- package/dist/server/app-rsc-cache-busting.js +40 -19
- package/dist/server/app-rsc-cache-busting.js.map +1 -1
- package/dist/server/app-rsc-error-handler.js.map +1 -1
- package/dist/server/app-rsc-errors.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +10 -1
- package/dist/server/app-rsc-handler.js +51 -17
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-render-mode.d.ts +11 -0
- package/dist/server/app-rsc-render-mode.js +21 -0
- package/dist/server/app-rsc-render-mode.js.map +1 -0
- package/dist/server/app-rsc-request-normalization.d.ts +4 -1
- package/dist/server/app-rsc-request-normalization.js +7 -2
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-rsc-response-finalizer.d.ts +2 -1
- package/dist/server/app-rsc-response-finalizer.js +6 -1
- package/dist/server/app-rsc-response-finalizer.js.map +1 -1
- package/dist/server/app-rsc-route-matching.js.map +1 -1
- package/dist/server/app-segment-config.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +16 -2
- package/dist/server/app-server-action-execution.js +79 -23
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +6 -0
- package/dist/server/app-ssr-entry.js +10 -4
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/app-static-generation.js.map +1 -1
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/cache-control.js +1 -0
- package/dist/server/cache-control.js.map +1 -1
- package/dist/server/cache-proof.js.map +1 -1
- package/dist/server/csp.js.map +1 -1
- package/dist/server/dev-error-overlay-store.js.map +1 -1
- package/dist/server/dev-error-overlay.js +5 -0
- package/dist/server/dev-error-overlay.js.map +1 -1
- package/dist/server/dev-module-runner.js.map +1 -1
- package/dist/server/dev-origin-check.js.map +1 -1
- package/dist/server/dev-route-files.js.map +1 -1
- package/dist/server/dev-server.js +8 -5
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/file-based-metadata.js.map +1 -1
- package/dist/server/headers.d.ts +79 -0
- package/dist/server/headers.js +101 -0
- package/dist/server/headers.js.map +1 -0
- package/dist/server/html.js.map +1 -1
- package/dist/server/http-error-responses.js.map +1 -1
- package/dist/server/image-optimization.d.ts +11 -1
- package/dist/server/image-optimization.js.map +1 -1
- package/dist/server/implicit-tags.js +2 -1
- package/dist/server/implicit-tags.js.map +1 -1
- package/dist/server/instrumentation-runtime.js.map +1 -1
- package/dist/server/instrumentation.js.map +1 -1
- package/dist/server/isr-cache.d.ts +10 -1
- package/dist/server/isr-cache.js +12 -3
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-route-build-data.js.map +1 -1
- package/dist/server/metadata-route-response.js.map +1 -1
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-matcher.js.map +1 -1
- package/dist/server/middleware-request-headers.d.ts +4 -1
- package/dist/server/middleware-request-headers.js +15 -8
- package/dist/server/middleware-request-headers.js.map +1 -1
- package/dist/server/middleware-response-headers.d.ts +2 -1
- package/dist/server/middleware-response-headers.js +1 -1
- package/dist/server/middleware-response-headers.js.map +1 -1
- package/dist/server/middleware-runtime.d.ts +1 -0
- package/dist/server/middleware-runtime.js +6 -3
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/navigation-planner.d.ts +119 -0
- package/dist/server/navigation-planner.js +171 -0
- package/dist/server/navigation-planner.js.map +1 -0
- package/dist/server/navigation-trace.d.ts +12 -2
- package/dist/server/navigation-trace.js +13 -1
- package/dist/server/navigation-trace.js.map +1 -1
- package/dist/server/next-error-digest.d.ts +3 -2
- package/dist/server/next-error-digest.js +4 -2
- package/dist/server/next-error-digest.js.map +1 -1
- package/dist/server/normalize-path.js.map +1 -1
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/pages-media-type.js.map +1 -1
- package/dist/server/pages-node-compat.js.map +1 -1
- package/dist/server/pages-page-data.js +5 -2
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.js +3 -2
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prerender-work-unit-setup.js +1 -1
- package/dist/server/prerender-work-unit-setup.js.map +1 -1
- package/dist/server/prod-server.js +35 -13
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-log.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +1 -13
- package/dist/server/request-pipeline.js +3 -25
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/rsc-stream-hints.js.map +1 -1
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/server-action-not-found.js +3 -3
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/socket-error-backstop.js.map +1 -1
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/server/worker-utils.d.ts +0 -7
- package/dist/server/worker-utils.js +3 -2
- package/dist/server/worker-utils.js.map +1 -1
- package/dist/shims/amp.js.map +1 -1
- package/dist/shims/app.d.ts +37 -4
- package/dist/shims/app.js +50 -1
- package/dist/shims/app.js.map +1 -0
- package/dist/shims/cache-for-request.js.map +1 -1
- package/dist/shims/cache-runtime.js +20 -8
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +15 -3
- package/dist/shims/cache.js +99 -15
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/client-hook-error.js.map +1 -1
- package/dist/shims/compat-router.js.map +1 -1
- package/dist/shims/config.js.map +1 -1
- package/dist/shims/constants.js.map +1 -1
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/dynamic.d.ts +18 -10
- package/dist/shims/dynamic.js +107 -51
- package/dist/shims/dynamic.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +35 -6
- package/dist/shims/error-boundary.js +118 -33
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +22 -1
- package/dist/shims/fetch-cache.js +124 -13
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/form.js +3 -1
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/head-state.js.map +1 -1
- package/dist/shims/head.d.ts +3 -1
- package/dist/shims/head.js +28 -16
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +4 -2
- package/dist/shims/headers.js +24 -7
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/i18n-context.js.map +1 -1
- package/dist/shims/i18n-state.js.map +1 -1
- package/dist/shims/image-config.d.ts +14 -1
- package/dist/shims/image-config.js +24 -1
- package/dist/shims/image-config.js.map +1 -1
- package/dist/shims/image.js +15 -2
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/als-registry.js.map +1 -1
- package/dist/shims/internal/app-router-context.d.ts +1 -0
- package/dist/shims/internal/app-router-context.js.map +1 -1
- package/dist/shims/internal/cookie-serialize.js.map +1 -1
- package/dist/shims/internal/make-hanging-promise.d.ts +1 -1
- package/dist/shims/internal/make-hanging-promise.js +1 -1
- package/dist/shims/internal/make-hanging-promise.js.map +1 -1
- package/dist/shims/internal/parse-cookie-header.js.map +1 -1
- package/dist/shims/internal/utils.js.map +1 -1
- package/dist/shims/internal/work-unit-async-storage.js +2 -2
- package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
- package/dist/shims/layout-segment-context.js.map +1 -1
- package/dist/shims/legacy-image.js.map +1 -1
- package/dist/shims/link-prefetch.d.ts +34 -0
- package/dist/shims/link-prefetch.js +40 -0
- package/dist/shims/link-prefetch.js.map +1 -0
- package/dist/shims/link.d.ts +27 -4
- package/dist/shims/link.js +91 -27
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation-state.js.map +1 -1
- package/dist/shims/navigation.d.ts +22 -1
- package/dist/shims/navigation.js +30 -15
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/navigation.react-server.js.map +1 -1
- package/dist/shims/offline.js.map +1 -1
- package/dist/shims/readonly-url-search-params.js.map +1 -1
- package/dist/shims/request-context.js.map +1 -1
- package/dist/shims/root-params.js.map +1 -1
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +38 -2
- package/dist/shims/router.js +45 -17
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script-nonce-context.js.map +1 -1
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.js +10 -14
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.d.ts +6 -1
- package/dist/shims/slot.js +20 -7
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/thenable-params.js.map +1 -1
- package/dist/shims/unified-request-context.js +3 -0
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/shims/url-utils.d.ts +2 -1
- package/dist/shims/url-utils.js +10 -1
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/shims/use-merged-ref.js.map +1 -1
- package/dist/shims/web-vitals.d.ts +4 -21
- package/dist/shims/web-vitals.js +19 -6
- package/dist/shims/web-vitals.js.map +1 -1
- package/dist/utils/base-path.js.map +1 -1
- package/dist/utils/cache-control-metadata.js.map +1 -1
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/encode-cache-tag.d.ts +31 -0
- package/dist/utils/encode-cache-tag.js +38 -0
- package/dist/utils/encode-cache-tag.js.map +1 -0
- package/dist/utils/error-cause.js.map +1 -1
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/dist/utils/manifest-paths.js.map +1 -1
- package/dist/utils/mdx-scan.js.map +1 -1
- package/dist/utils/navigation-signal.d.ts +6 -0
- package/dist/utils/navigation-signal.js +14 -0
- package/dist/utils/navigation-signal.js.map +1 -0
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/public-routes.js.map +1 -1
- package/dist/utils/query.js.map +1 -1
- package/dist/utils/safe-json-file.js.map +1 -1
- package/dist/utils/text-stream.js.map +1 -1
- package/dist/utils/vinext-root.js.map +1 -1
- package/package.json +6 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-browser-entry.js","names":[],"sources":["../../src/server/app-browser-entry.ts"],"sourcesContent":["/// <reference types=\"vite/client\" />\n\nimport { createElement, use, useLayoutEffect, useRef, useState } from \"react\";\nimport {\n createFromFetch,\n createFromReadableStream,\n createTemporaryReferenceSet,\n encodeReply,\n setServerCallback,\n} from \"@vitejs/plugin-rsc/browser\";\nimport { hydrateRoot } from \"react-dom/client\";\nimport \"../client/instrumentation-client.js\";\nimport { notifyAppRouterTransitionStart } from \"../client/instrumentation-client-state.js\";\nimport {\n __basePath,\n commitClientNavigationState,\n consumePrefetchResponse,\n createClientNavigationRenderSnapshot,\n getCurrentNextUrl,\n getCurrentInterceptionContext,\n getClientNavigationRenderContext,\n getClientNavigationState,\n getPrefetchCache,\n getPrefetchedUrls,\n pushHistoryStateWithoutNotify,\n replaceClientParamsWithoutNotify,\n replaceHistoryStateWithoutNotify,\n restoreRscResponse,\n setClientParams,\n setPendingPathname,\n snapshotRscResponse,\n setMountedSlotsHeader,\n setNavigationContext,\n type CachedRscResponse,\n type ClientNavigationRenderSnapshot,\n} from \"vinext/shims/navigation\";\nimport { stripBasePath } from \"../utils/base-path.js\";\nimport {\n chunksToReadableStream,\n createProgressiveRscStream,\n getVinextBrowserGlobal,\n} from \"./app-browser-stream.js\";\nimport {\n createAppBrowserNavigationController,\n type HistoryUpdateMode,\n type NavigationPayloadOutcome,\n type PendingBrowserRouterState,\n} from \"./app-browser-navigation-controller.js\";\nimport {\n AppElementsWire,\n getMountedSlotIdsHeader,\n resolveVisitedResponseInterceptionContext,\n type AppElements,\n type AppWireElements,\n} from \"./app-elements.js\";\nimport {\n createHistoryStateWithPreviousNextUrl,\n readHistoryStatePreviousNextUrl,\n resolveInterceptionContextFromPreviousNextUrl,\n resolveServerActionRequestState,\n type AppRouterState,\n type OperationLane,\n} from \"./app-browser-state.js\";\nimport { DevRecoveryBoundary } from \"vinext/shims/error-boundary\";\nimport { ElementsContext, Slot } from \"vinext/shims/slot\";\nimport { createOnUncaughtError } from \"./app-browser-error.js\";\nimport {\n devOnCaughtError,\n devOnUncaughtError,\n dismissOverlay,\n installDevErrorOverlay,\n} from \"./dev-error-overlay.js\";\nimport { DANGEROUS_URL_BLOCK_MESSAGE, isDangerousScheme } from \"vinext/shims/url-safety\";\nimport {\n getServerActionNotFoundClientMessage,\n isServerActionNotFoundResponse,\n} from \"./server-action-not-found.js\";\nimport {\n createRscRequestHeaders,\n createRscRequestUrl,\n stripRscCacheBustingSearchParam,\n stripRscSuffix,\n VINEXT_RSC_CONTENT_TYPE,\n VINEXT_RSC_MOUNTED_SLOTS_HEADER,\n} from \"./app-rsc-cache-busting.js\";\n\ntype SearchParamInput = ConstructorParameters<typeof URLSearchParams>[0];\n\ntype ServerActionResult = {\n root: AppWireElements;\n returnValue?: {\n ok: boolean;\n data: unknown;\n };\n};\n\ntype NavigationKind = \"navigate\" | \"traverse\" | \"refresh\";\n\n// Maps NavigationKind to the AppRouterAction type used by the reducer.\n// \"refresh\" is intentionally treated as \"navigate\" (merge, preserve absent slots).\n// Both call sites must stay in sync — update here if NavigationKind gains new values.\nfunction toActionType(kind: NavigationKind): \"navigate\" | \"traverse\" {\n return kind === \"traverse\" ? \"traverse\" : \"navigate\";\n}\n\nfunction toOperationLane(kind: NavigationKind): OperationLane {\n switch (kind) {\n case \"navigate\":\n return \"navigation\";\n case \"refresh\":\n return \"refresh\";\n case \"traverse\":\n return \"traverse\";\n default: {\n const _exhaustive: never = kind;\n throw new Error(\"[vinext] Unknown navigation kind: \" + String(_exhaustive));\n }\n }\n}\n\ntype VisitedResponseCacheEntry = {\n params: Record<string, string | string[]>;\n expiresAt: number;\n response: CachedRscResponse;\n};\n\nconst MAX_VISITED_RESPONSE_CACHE_SIZE = 50;\nconst VISITED_RESPONSE_CACHE_TTL = 5 * 60_000;\nconst MAX_TRAVERSAL_CACHE_TTL = 30 * 60_000;\nconst browserNavigationController = createAppBrowserNavigationController();\nconst NavigationCommitSignal = browserNavigationController.NavigationCommitSignal;\n\n// Parses a URI-encoded JSON value carried in a response header (e.g.\n// `X-Vinext-Params`). Returns `null` on missing or malformed input so callers\n// can fall back to their own defaults. Silent by design — these headers are\n// best-effort hydration data and a parse failure should not break navigation.\nfunction parseEncodedJsonHeader<T>(value: string | null): T | null {\n if (!value) return null;\n try {\n return JSON.parse(decodeURIComponent(value)) as T;\n } catch {\n return null;\n }\n}\n\nfunction isRouterStatePromise(\n value: AppRouterState | Promise<AppRouterState>,\n): value is Promise<AppRouterState> {\n return value instanceof Promise;\n}\n\nlet latestClientParams: Record<string, string | string[]> = {};\nconst visitedResponseCache = new Map<string, VisitedResponseCacheEntry>();\n// Sticky bit: stays true once BrowserRoot has committed at least once. Used by\n// the HMR handler to distinguish \"still hydrating\" (wait) from \"was up, then\n// torn down by a render error\" (full reload to recover).\nlet browserRouterStateHasEverCommitted = false;\n// Most recent navigation target that has been dispatched but not yet committed.\n// Read by the onUncaughtError handler so a render error tearing down the tree\n// can land the browser on the URL the user was actually navigating to, instead\n// of stranding them on the previous URL with a blank page. Cleared once the\n// commit effect runs (URL update succeeded) or the navigation is superseded.\nlet pendingNavigationRecoveryHref: string | null = null;\n\nfunction isServerActionResult(value: unknown): value is ServerActionResult {\n return !!value && typeof value === \"object\" && \"root\" in value;\n}\n\nfunction getBrowserRouterState(): AppRouterState {\n return browserNavigationController.getBrowserRouterState();\n}\n\nfunction hasBrowserRouterState(): boolean {\n return browserNavigationController.hasBrowserRouterState();\n}\n\nfunction waitForBrowserRouterStateReady(): Promise<void> {\n return browserNavigationController.waitForBrowserRouterStateReady();\n}\n\nfunction beginPendingBrowserRouterState(): PendingBrowserRouterState {\n return browserNavigationController.beginPendingBrowserRouterState();\n}\n\nfunction applyClientParams(params: Record<string, string | string[]>): void {\n latestClientParams = params;\n setClientParams(params);\n}\n\nfunction stageClientParams(params: Record<string, string | string[]>): void {\n // NB: latestClientParams diverges from ClientNavigationState.clientParams\n // between staging and commit. Server action snapshots (same-URL\n // commitSameUrlNavigatePayload() calls inside registerServerActionCallback)\n // read latestClientParams, so a\n // server action fired during this window would get the pending (not yet\n // committed) params. This is acceptable because the commit effect fires\n // before hooks observe the new URL state, keeping the window vanishingly small.\n latestClientParams = params;\n replaceClientParamsWithoutNotify(params);\n}\n\nfunction clearVisitedResponseCache(): void {\n visitedResponseCache.clear();\n}\n\nfunction clearPrefetchState(): void {\n getPrefetchCache().clear();\n getPrefetchedUrls().clear();\n}\n\nfunction clearClientNavigationCaches(): void {\n clearVisitedResponseCache();\n clearPrefetchState();\n}\n\nfunction createNavigationCommitEffect(options: {\n href: string;\n historyUpdateMode: HistoryUpdateMode | undefined;\n navId: number;\n params: Record<string, string | string[]>;\n previousNextUrl: string | null;\n}): () => void {\n const { href, historyUpdateMode, navId, params, previousNextUrl } = options;\n\n return () => {\n // Only update URL if this is still the active navigation.\n // A newer navigation would have superseded this navigation id.\n if (!browserNavigationController.isCurrentNavigation(navId)) {\n // This transition was superseded before commit; balance the active\n // snapshot counter without clearing pendingPathname ownership.\n commitClientNavigationState(undefined, { releaseSnapshot: true });\n return;\n }\n\n const targetHref = new URL(href, window.location.origin).href;\n stageClientParams(params);\n const preserveExistingState = historyUpdateMode === \"replace\";\n const historyState = createHistoryStateWithPreviousNextUrl(\n preserveExistingState ? window.history.state : null,\n previousNextUrl,\n );\n\n if (historyUpdateMode === \"replace\" && window.location.href !== targetHref) {\n replaceHistoryStateWithoutNotify(historyState, \"\", href);\n } else if (historyUpdateMode === \"push\" && window.location.href !== targetHref) {\n pushHistoryStateWithoutNotify(historyState, \"\", href);\n }\n\n // URL has been updated; the recovery hard-nav target is no longer needed.\n pendingNavigationRecoveryHref = null;\n commitClientNavigationState(navId);\n };\n}\n\nasync function renderNavigationPayload(\n payload: Promise<AppElements>,\n navigationSnapshot: ClientNavigationRenderSnapshot,\n targetHref: string,\n navId: number,\n historyUpdateMode: HistoryUpdateMode | undefined,\n params: Record<string, string | string[]>,\n previousNextUrl: string | null,\n pendingRouterState: PendingBrowserRouterState | null,\n useTransition = true,\n actionType: \"navigate\" | \"replace\" | \"traverse\" = \"navigate\",\n operationLane: OperationLane = \"navigation\",\n): Promise<NavigationPayloadOutcome> {\n try {\n return await browserNavigationController.renderNavigationPayload({\n actionType,\n createNavigationCommitEffect: (options) => {\n pendingNavigationRecoveryHref = options.href;\n return createNavigationCommitEffect(options);\n },\n historyUpdateMode,\n navigationSnapshot,\n nextElements: payload,\n operationLane,\n params,\n pendingRouterState,\n previousNextUrl,\n targetHref,\n navId,\n useTransition,\n });\n } catch (error) {\n pendingNavigationRecoveryHref = null;\n throw error;\n }\n}\n\nasync function commitSameUrlNavigatePayload(\n nextElements: Promise<AppElements>,\n returnValue?: ServerActionResult[\"returnValue\"],\n actionInitiationState?: AppRouterState,\n): Promise<unknown> {\n const navigationSnapshot = createClientNavigationRenderSnapshot(\n window.location.href,\n latestClientParams,\n );\n return browserNavigationController.commitSameUrlNavigatePayload(\n nextElements,\n navigationSnapshot,\n returnValue,\n actionInitiationState,\n );\n}\n\nfunction evictVisitedResponseCacheIfNeeded(): void {\n while (visitedResponseCache.size >= MAX_VISITED_RESPONSE_CACHE_SIZE) {\n const oldest = visitedResponseCache.keys().next().value;\n if (oldest === undefined) {\n return;\n }\n visitedResponseCache.delete(oldest);\n }\n}\n\nfunction getVisitedResponse(\n rscUrl: string,\n interceptionContext: string | null,\n mountedSlotsHeader: string | null,\n navigationKind: NavigationKind,\n): VisitedResponseCacheEntry | null {\n const cacheKey = AppElementsWire.encodeCacheKey(rscUrl, interceptionContext);\n const cached = visitedResponseCache.get(cacheKey);\n if (!cached) {\n return null;\n }\n\n if ((cached.response.mountedSlotsHeader ?? null) !== mountedSlotsHeader) {\n visitedResponseCache.delete(cacheKey);\n return null;\n }\n\n if (navigationKind === \"refresh\") {\n return null;\n }\n\n if (navigationKind === \"traverse\") {\n const createdAt = cached.expiresAt - VISITED_RESPONSE_CACHE_TTL;\n if (Date.now() - createdAt >= MAX_TRAVERSAL_CACHE_TTL) {\n visitedResponseCache.delete(cacheKey);\n return null;\n }\n // LRU: promote to most-recently-used (delete + re-insert moves to end of Map)\n visitedResponseCache.delete(cacheKey);\n visitedResponseCache.set(cacheKey, cached);\n return cached;\n }\n\n if (cached.expiresAt > Date.now()) {\n // LRU: promote to most-recently-used\n visitedResponseCache.delete(cacheKey);\n visitedResponseCache.set(cacheKey, cached);\n return cached;\n }\n\n visitedResponseCache.delete(cacheKey);\n return null;\n}\n\nfunction storeVisitedResponseSnapshot(\n rscUrl: string,\n interceptionContext: string | null,\n snapshot: CachedRscResponse,\n params: Record<string, string | string[]>,\n): void {\n const cacheKey = AppElementsWire.encodeCacheKey(rscUrl, interceptionContext);\n visitedResponseCache.delete(cacheKey);\n evictVisitedResponseCacheIfNeeded();\n const now = Date.now();\n visitedResponseCache.set(cacheKey, {\n params,\n expiresAt: now + VISITED_RESPONSE_CACHE_TTL,\n response: snapshot,\n });\n}\n\ntype NavigationRequestState = {\n interceptionContext: string | null;\n previousNextUrl: string | null;\n};\n\nfunction getRequestState(\n navigationKind: NavigationKind,\n previousNextUrlOverride?: string | null,\n): NavigationRequestState {\n if (previousNextUrlOverride !== undefined) {\n return {\n interceptionContext: resolveInterceptionContextFromPreviousNextUrl(\n previousNextUrlOverride,\n __basePath,\n ),\n previousNextUrl: previousNextUrlOverride,\n };\n }\n\n switch (navigationKind) {\n case \"navigate\":\n return {\n interceptionContext: getCurrentInterceptionContext(),\n previousNextUrl: getCurrentNextUrl(),\n };\n case \"traverse\": {\n const previousNextUrl = readHistoryStatePreviousNextUrl(window.history.state);\n return {\n interceptionContext: resolveInterceptionContextFromPreviousNextUrl(\n previousNextUrl,\n __basePath,\n ),\n previousNextUrl,\n };\n }\n case \"refresh\": {\n const currentPreviousNextUrl = getBrowserRouterState().previousNextUrl;\n return {\n interceptionContext: resolveInterceptionContextFromPreviousNextUrl(\n currentPreviousNextUrl,\n __basePath,\n ),\n previousNextUrl: currentPreviousNextUrl,\n };\n }\n default: {\n const _exhaustive: never = navigationKind;\n throw new Error(\"[vinext] Unknown navigation kind: \" + String(_exhaustive));\n }\n }\n}\n\n// Dev-only callback invoked when DevRecoveryBoundary catches. The replaced\n// subtree means NavigationCommitSignal's useLayoutEffect never fires, so the\n// URL update for the in-flight navigation would otherwise be lost. Force-drain\n// the queued pre-paint effect for this renderId so the URL still moves to the\n// navigation target, the dev overlay shows which URL is broken, and HMR's\n// rsc:update fetches the right payload after the bug is fixed.\nfunction handleDevRecoveryBoundaryCatch(resetKey: number): void {\n // React's onCaughtError option already routes the error to the dev overlay.\n // Our job here is purely to drive the URL update for the in-flight\n // navigation that this failed render belonged to.\n browserNavigationController.drainPrePaintEffects(resetKey);\n}\n\nfunction decodeAppElementsPromise(payload: Promise<AppWireElements>): Promise<AppElements> {\n // Wrap in Promise.resolve() because createFromReadableStream() returns a\n // React Flight thenable whose .then() returns undefined (not a new Promise).\n // Without the wrap, chaining .then() produces undefined → use() crashes.\n return Promise.resolve(payload).then((elements) => AppElementsWire.decode(elements));\n}\n\nfunction BrowserRoot({\n initialElements,\n initialNavigationSnapshot,\n}: {\n initialElements: Promise<AppElements>;\n initialNavigationSnapshot: ClientNavigationRenderSnapshot;\n}) {\n const resolvedElements = use(initialElements);\n const initialMetadata = AppElementsWire.readMetadata(resolvedElements);\n const [treeStateValue, setTreeStateValue] = useState<AppRouterState | Promise<AppRouterState>>({\n activeOperation: null,\n elements: resolvedElements,\n interceptionContext: initialMetadata.interceptionContext,\n layoutFlags: initialMetadata.layoutFlags,\n navigationSnapshot: initialNavigationSnapshot,\n previousNextUrl: null,\n renderId: 0,\n rootLayoutTreePath: initialMetadata.rootLayoutTreePath,\n routeId: initialMetadata.routeId,\n visibleCommitVersion: 0,\n });\n const treeState = isRouterStatePromise(treeStateValue) ? use(treeStateValue) : treeStateValue;\n\n // Keep the latest router state in a ref so external callers (navigate(),\n // server actions, HMR) always read the current state. Safe: those readers\n // run from events/effects, never from React render itself.\n // Note: stateRef.current is written during render, not in an effect, to\n // avoid a stale-read window between commit and layout effects. This mirrors\n // the same render-phase ref update pattern used by Next.js's own router.\n const stateRef = useRef(treeState);\n stateRef.current = treeState;\n\n // Publish the stable ref object and dispatch during layout commit. This keeps\n // the module-level escape hatches aligned with React's committed tree without\n // performing module writes during render. __VINEXT_RSC_NAVIGATE__ is assigned\n // after hydrateRoot() returns; by then this layout effect has already run for\n // the hydration commit, so getBrowserRouterState() never observes a null ref.\n useLayoutEffect(() => {\n const detach = browserNavigationController.attachBrowserRouterState(\n setTreeStateValue,\n stateRef,\n );\n browserRouterStateHasEverCommitted = true;\n return () => {\n detach();\n setMountedSlotsHeader(null);\n };\n }, [setTreeStateValue]);\n\n useLayoutEffect(() => {\n setMountedSlotsHeader(getMountedSlotIdsHeader(stateRef.current.elements));\n }, [treeState.elements]);\n\n useLayoutEffect(() => {\n if (treeState.renderId !== 0) {\n return;\n }\n\n replaceHistoryStateWithoutNotify(\n createHistoryStateWithPreviousNextUrl(window.history.state, treeState.previousNextUrl),\n \"\",\n window.location.href,\n );\n }, [treeState.previousNextUrl, treeState.renderId]);\n\n const innerTree = createElement(\n NavigationCommitSignal,\n { renderId: treeState.renderId },\n createElement(\n ElementsContext.Provider,\n { value: treeState.elements },\n createElement(Slot, { id: treeState.routeId }),\n ),\n );\n\n // In dev, wrap the route tree in a top-level recovery boundary. A render\n // error (e.g. a slot's RSC reference rejects) is caught here instead of\n // tearing down BrowserRoot, so HMR can dispatch the next payload —\n // identified by an incremented renderId, which doubles as the boundary's\n // reset key — without a full page reload. The dev overlay (a separate\n // React root) shows the error itself.\n //\n // onCatch drains the pending pre-paint effect for the failed render so\n // the URL update bound to that navigation still runs. Without this, a\n // soft-nav whose target throws would leave the browser on the previous\n // URL, hiding which route is broken and mis-targeting the next HMR\n // payload (which fetches RSC for window.location.pathname).\n //\n // This file is .ts, not .tsx — children are passed positionally to satisfy\n // both the createElement overload and eslint's no-children-prop rule.\n const committedTree = import.meta.env.DEV\n ? createElement(\n DevRecoveryBoundary,\n {\n resetKey: treeState.renderId,\n onCatch: handleDevRecoveryBoundaryCatch,\n },\n innerTree,\n )\n : innerTree;\n\n const ClientNavigationRenderContext = getClientNavigationRenderContext();\n if (!ClientNavigationRenderContext) {\n return committedTree;\n }\n\n return createElement(\n ClientNavigationRenderContext.Provider,\n { value: treeState.navigationSnapshot },\n committedTree,\n );\n}\n\nfunction restoreHydrationNavigationContext(\n pathname: string,\n searchParams: SearchParamInput,\n params: Record<string, string | string[]>,\n): void {\n setNavigationContext({\n pathname,\n searchParams: new URLSearchParams(searchParams),\n params,\n });\n}\n\nfunction decodeHashFragment(fragment: string): string {\n try {\n return decodeURIComponent(fragment);\n } catch {\n return fragment;\n }\n}\n\nfunction scrollToHashTarget(hash: string): void {\n const fragment = decodeHashFragment(hash.startsWith(\"#\") ? hash.slice(1) : hash);\n\n requestAnimationFrame(() => {\n if (fragment === \"\" || fragment === \"top\") {\n window.scrollTo(0, 0);\n return;\n }\n\n const idElement = document.getElementById(fragment);\n if (idElement) {\n idElement.scrollIntoView({ behavior: \"auto\" });\n return;\n }\n\n document.getElementsByName(fragment)[0]?.scrollIntoView({ behavior: \"auto\" });\n });\n}\n\nfunction restorePopstateScrollPosition(state: unknown): void {\n if (!(state && typeof state === \"object\" && \"__vinext_scrollY\" in state)) {\n if (window.location.hash) {\n scrollToHashTarget(window.location.hash);\n }\n return;\n }\n\n const y = Number(state.__vinext_scrollY);\n const x = \"__vinext_scrollX\" in state ? Number(state.__vinext_scrollX) : 0;\n\n requestAnimationFrame(() => {\n window.scrollTo(x, y);\n });\n}\n\n// Set on pagehide so the RSC navigation catch block can distinguish expected\n// fetch aborts (triggered by the unload itself) from real errors worth logging.\nlet isPageUnloading = false;\n\nconst RSC_RELOAD_KEY = \"__vinext_rsc_initial_reload__\";\n\n// sessionStorage can throw SecurityError in strict-mode iframes, storage-\n// disabled browsers, and some Safari private-browsing configurations. Wrap\n// every access so a recovery path for one error does not crash hydration.\nfunction readReloadFlag(): string | null {\n try {\n return sessionStorage.getItem(RSC_RELOAD_KEY);\n } catch {\n return null;\n }\n}\nfunction writeReloadFlag(path: string): void {\n try {\n sessionStorage.setItem(RSC_RELOAD_KEY, path);\n } catch {}\n}\nfunction clearReloadFlag(): void {\n try {\n sessionStorage.removeItem(RSC_RELOAD_KEY);\n } catch {}\n}\n\n// A non-ok or wrong-content-type RSC response during initial hydration means\n// the server cannot deliver a valid RSC payload for this URL. Parsing the\n// response as RSC causes an opaque parse failure. On the first attempt,\n// reload once so the server has a chance to render the correct error page\n// as HTML. On the second attempt (detected via the sessionStorage flag), the\n// endpoint is persistently broken. Returns null so main() aborts the\n// hydration bootstrap without registering `__VINEXT_RSC_*` globals —\n// including during the brief window between reload() firing and the page\n// actually unloading — so external probes never see a half-hydrated page.\nfunction recoverFromBadInitialRscResponse(reason: string): null {\n const currentPath = window.location.pathname + window.location.search;\n if (readReloadFlag() === currentPath) {\n clearReloadFlag();\n console.error(\n `[vinext] Initial RSC fetch ${reason} after reload; aborting hydration. ` +\n \"Server-rendered HTML remains visible; client components will not hydrate.\",\n );\n return null;\n }\n writeReloadFlag(currentPath);\n // Verify the write persisted. In storage-denied environments (strict-mode\n // iframes, locked-down enterprise policies), every getItem returns null and\n // every setItem silently no-ops, so the reload-loop guard cannot survive\n // the reload — the page would loop forever. Abort instead so the user at\n // least sees the server-rendered HTML.\n if (readReloadFlag() !== currentPath) {\n console.error(\n `[vinext] Initial RSC fetch ${reason}; sessionStorage unavailable so the ` +\n \"reload-loop guard cannot persist — aborting hydration. \" +\n \"Server-rendered HTML remains visible; client components will not hydrate.\",\n );\n return null;\n }\n // One-shot diagnostic so a production reload is traceable. Only fires once\n // per broken path thanks to the sessionStorage flag above; not noisy.\n console.warn(\n `[vinext] Initial RSC fetch ${reason}; reloading once to let the server render the HTML error page`,\n );\n window.location.reload();\n return null;\n}\n\nasync function readInitialRscStream(): Promise<ReadableStream<Uint8Array> | null> {\n const vinext = getVinextBrowserGlobal();\n\n if (vinext.__VINEXT_RSC__ || vinext.__VINEXT_RSC_CHUNKS__ || vinext.__VINEXT_RSC_DONE__) {\n // Reaching the embedded-RSC branch means the server successfully rendered\n // the page — any prior reload flag for this path is stale and must be\n // cleared so a future failure gets its own fresh recovery attempt.\n clearReloadFlag();\n\n if (vinext.__VINEXT_RSC__) {\n const embedData = vinext.__VINEXT_RSC__;\n delete vinext.__VINEXT_RSC__;\n\n const params = embedData.params ?? {};\n if (embedData.params) {\n applyClientParams(embedData.params);\n }\n if (embedData.nav) {\n restoreHydrationNavigationContext(\n embedData.nav.pathname,\n embedData.nav.searchParams,\n params,\n );\n }\n\n return chunksToReadableStream(embedData.rsc);\n }\n\n const params = vinext.__VINEXT_RSC_PARAMS__ ?? {};\n if (vinext.__VINEXT_RSC_PARAMS__) {\n applyClientParams(vinext.__VINEXT_RSC_PARAMS__);\n }\n if (vinext.__VINEXT_RSC_NAV__) {\n restoreHydrationNavigationContext(\n vinext.__VINEXT_RSC_NAV__.pathname,\n vinext.__VINEXT_RSC_NAV__.searchParams,\n params,\n );\n }\n\n return createProgressiveRscStream();\n }\n\n const rscHeaders = createRscRequestHeaders();\n const rscResponse = await fetch(\n await createRscRequestUrl(window.location.pathname + window.location.search, rscHeaders),\n { credentials: \"include\", headers: rscHeaders },\n );\n\n if (!rscResponse.ok) {\n return recoverFromBadInitialRscResponse(`returned ${rscResponse.status}`);\n }\n // Guard against proxies/CDNs that return 200 with a rewritten Content-Type\n // (e.g. text/html instead of text/x-component). Such responses cannot be\n // parsed as RSC and would throw the same opaque parse error this fallback\n // exists to prevent.\n const contentType = rscResponse.headers.get(\"content-type\") ?? \"\";\n if (!contentType.startsWith(VINEXT_RSC_CONTENT_TYPE)) {\n return recoverFromBadInitialRscResponse(\n `returned non-RSC content-type \"${contentType || \"(missing)\"}\"`,\n );\n }\n // Missing body (e.g. 204 No Content, or an edge worker that returned ok\n // headers without piping the stream) fails the same way downstream.\n // Matches Next.js' `!res.body` branch in fetch-server-response.ts.\n if (!rscResponse.body) {\n return recoverFromBadInitialRscResponse(\"returned empty body\");\n }\n // Successful RSC response clears the guard so a subsequent reload of the\n // same path after a transient failure still gets one recovery attempt.\n clearReloadFlag();\n\n // Ignore malformed param headers and continue with hydration. The original\n // try/catch also swallowed errors from applyClientParams; preserve that.\n const parsedParams = parseEncodedJsonHeader<Record<string, string | string[]>>(\n rscResponse.headers.get(\"X-Vinext-Params\"),\n );\n const params: Record<string, string | string[]> = parsedParams ?? {};\n if (parsedParams) {\n try {\n applyClientParams(parsedParams);\n } catch {\n // Ignore — matches the previous combined try/catch behavior.\n }\n }\n\n restoreHydrationNavigationContext(window.location.pathname, window.location.search, params);\n\n return rscResponse.body;\n}\n\nfunction registerServerActionCallback(): void {\n setServerCallback(async (id, args) => {\n const temporaryReferences = createTemporaryReferenceSet();\n const body = await encodeReply(args, { temporaryReferences });\n\n // Carry the interception context + mounted slots from the current router\n // state so the server-action re-render rebuilds the intercepted tree\n // instead of replacing it with the direct page. Parity with Next.js,\n // which sends `Next-URL` on action POSTs when the current tree contains\n // an interception route.\n const currentState = getBrowserRouterState();\n const { headers } = resolveServerActionRequestState({\n actionId: id,\n basePath: __basePath,\n elements: currentState.elements,\n previousNextUrl: currentState.previousNextUrl,\n });\n\n const fetchResponse = await fetch(\n await createRscRequestUrl(window.location.pathname + window.location.search, headers),\n {\n method: \"POST\",\n headers,\n body,\n },\n );\n\n if (isServerActionNotFoundResponse(fetchResponse)) {\n throw new Error(getServerActionNotFoundClientMessage(id));\n }\n\n const actionRedirect = fetchResponse.headers.get(\"x-action-redirect\");\n if (actionRedirect) {\n if (isDangerousScheme(actionRedirect)) {\n console.error(DANGEROUS_URL_BLOCK_MESSAGE);\n return undefined;\n }\n\n // Check for external URLs that need a hard redirect.\n try {\n const redirectUrl = new URL(actionRedirect, window.location.origin);\n if (redirectUrl.origin !== window.location.origin) {\n window.location.href = actionRedirect;\n return undefined;\n }\n } catch {\n // Fall through to hard redirect below if URL parsing fails.\n }\n\n // Use hard redirect for all action redirects because vinext's server\n // currently returns an empty body for redirect responses. RSC navigation\n // requires a valid RSC payload. This is a known parity gap with Next.js,\n // which pre-renders the redirect target's RSC payload.\n const redirectType = fetchResponse.headers.get(\"x-action-redirect-type\") ?? \"replace\";\n if (redirectType === \"push\") {\n window.location.assign(actionRedirect);\n } else {\n window.location.replace(actionRedirect);\n }\n return undefined;\n }\n\n clearClientNavigationCaches();\n\n const result = await createFromFetch<ServerActionResult | AppWireElements>(\n Promise.resolve(fetchResponse),\n { temporaryReferences },\n );\n\n // Server actions stay on the same URL and use commitSameUrlNavigatePayload()\n // for merge-based dispatch. This path does not call\n // activateNavigationSnapshot() because there is no URL change to commit, so\n // hooks continue reading the live external-store values directly. If server\n // actions ever trigger URL changes via RSC payload (instead of hard\n // redirects), this would need renderNavigationPayload().\n if (isServerActionResult(result)) {\n return commitSameUrlNavigatePayload(\n Promise.resolve(AppElementsWire.decode(result.root)),\n result.returnValue,\n currentState,\n );\n }\n\n return commitSameUrlNavigatePayload(\n Promise.resolve(AppElementsWire.decode(result)),\n undefined,\n currentState,\n );\n });\n}\n\nasync function main(): Promise<void> {\n registerServerActionCallback();\n\n const rscStream = await readInitialRscStream();\n // null signals that readInitialRscStream aborted hydration — either because\n // a reload is in flight (first-attempt recovery) or the endpoint is\n // persistently broken (post-reload). Bootstrap is a separate synchronous\n // helper so the null-branch structurally cannot reach any __VINEXT_RSC_*\n // global assignment, even if a future refactor interposes async work here.\n if (rscStream === null) return;\n bootstrapHydration(rscStream);\n}\n\nfunction bootstrapHydration(rscStream: ReadableStream<Uint8Array>): void {\n if (import.meta.env.DEV) {\n installDevErrorOverlay();\n }\n\n const root = decodeAppElementsPromise(createFromReadableStream<AppWireElements>(rscStream));\n const initialNavigationSnapshot = createClientNavigationRenderSnapshot(\n window.location.href,\n latestClientParams,\n );\n replaceHistoryStateWithoutNotify(\n createHistoryStateWithPreviousNextUrl(window.history.state, null),\n \"\",\n window.location.href,\n );\n\n // In dev we route uncaught errors into the dev overlay rather than the\n // hard-nav recovery: the overlay is what the developer needs to see, and a\n // recovery nav would wipe it. In prod we keep the recovery hard-nav so the\n // user lands on a renderable URL with the actual error UI.\n const onUncaughtError = import.meta.env.DEV\n ? devOnUncaughtError\n : createOnUncaughtError(() => pendingNavigationRecoveryHref);\n window.__VINEXT_RSC_ROOT__ = hydrateRoot(\n document,\n createElement(BrowserRoot, {\n initialElements: root,\n initialNavigationSnapshot,\n }),\n import.meta.env.DEV\n ? { onCaughtError: devOnCaughtError, onUncaughtError }\n : { onUncaughtError },\n );\n window.__VINEXT_HYDRATED_AT = performance.now();\n\n window.__VINEXT_RSC_NAVIGATE__ = async function navigateRsc(\n href: string,\n redirectDepth = 0,\n navigationKind: NavigationKind = \"navigate\",\n historyUpdateMode?: HistoryUpdateMode,\n previousNextUrlOverride?: string | null,\n programmaticTransition = false,\n ): Promise<void> {\n let pendingRouterState: PendingBrowserRouterState | null = null;\n // Hoist navId above try so the catch and finally blocks can reference it.\n const navId = browserNavigationController.beginNavigation();\n\n // Loop variables for inline redirect following. On a redirect, these are\n // updated and the loop continues without returning or re-entering navigateRsc,\n // so a single pendingRouterState spans all hops and isPending never flashes.\n let currentHref = href;\n let currentHistoryMode = historyUpdateMode;\n let currentPrevNextUrl = previousNextUrlOverride;\n let redirectCount = redirectDepth;\n\n try {\n if (programmaticTransition && hasBrowserRouterState()) {\n pendingRouterState = beginPendingBrowserRouterState();\n } else {\n await waitForBrowserRouterStateReady();\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n\n if (programmaticTransition) {\n pendingRouterState = beginPendingBrowserRouterState();\n }\n }\n\n while (true) {\n if (redirectCount > 10) {\n console.error(\n \"[vinext] Too many RSC redirects — aborting navigation to prevent infinite loop.\",\n );\n window.location.href = currentHref;\n return;\n }\n\n const url = new URL(currentHref, window.location.origin);\n const requestState = getRequestState(navigationKind, currentPrevNextUrl);\n const requestInterceptionContext = requestState.interceptionContext;\n const requestPreviousNextUrl = requestState.previousNextUrl;\n\n // Compare against previous pending navigation first, then committed state.\n // This avoids isSameRoute misclassification during rapid back-to-back clicks.\n const navState = getClientNavigationState();\n const currentPath =\n navState?.pendingPathname ??\n navState?.cachedPathname ??\n stripBasePath(window.location.pathname, __basePath);\n\n const targetPath = stripBasePath(url.pathname, __basePath);\n const isSameRoute = targetPath === currentPath;\n\n // Set this navigation as the pending pathname, overwriting any previous.\n // Pass navId so only this navigation (or a newer one) can clear it later.\n setPendingPathname(url.pathname, navId);\n\n const elementsAtNavStart = getBrowserRouterState().elements;\n const mountedSlotsHeader = getMountedSlotIdsHeader(elementsAtNavStart);\n const requestHeaders = createRscRequestHeaders({\n interceptionContext: requestInterceptionContext,\n });\n if (mountedSlotsHeader) {\n requestHeaders.set(VINEXT_RSC_MOUNTED_SLOTS_HEADER, mountedSlotsHeader);\n }\n const rscUrl = await createRscRequestUrl(url.pathname + url.search, requestHeaders);\n const cachedRoute = getVisitedResponse(\n rscUrl,\n requestInterceptionContext,\n mountedSlotsHeader,\n navigationKind,\n );\n if (cachedRoute) {\n // Check stale-navigation before and after createFromFetch. The pre-check\n // avoids wasted parse work; the post-check catches supersessions that\n // occur during the await. createFromFetch on a buffered response is fast\n // but still async, so the window exists. The non-cached path (below) places\n // its heavyweight async steps (fetch, snapshotRscResponse, createFromFetch)\n // between navId checks consistently; the cached path omits the check between\n // createClientNavigationRenderSnapshot (synchronous) and createFromFetch\n // because there is no await in that gap.\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n const cachedParams = cachedRoute.params;\n // createClientNavigationRenderSnapshot is synchronous (URL parsing + param\n // wrapping only) — no stale-navigation recheck needed between here and the\n // next await.\n const cachedNavigationSnapshot = createClientNavigationRenderSnapshot(\n currentHref,\n cachedParams,\n );\n const cachedPayload = decodeAppElementsPromise(\n createFromFetch<AppWireElements>(\n Promise.resolve(restoreRscResponse(cachedRoute.response)),\n ),\n );\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n await renderNavigationPayload(\n cachedPayload,\n cachedNavigationSnapshot,\n currentHref,\n navId,\n currentHistoryMode,\n cachedParams,\n requestPreviousNextUrl,\n pendingRouterState,\n isSameRoute,\n toActionType(navigationKind),\n toOperationLane(navigationKind),\n );\n return;\n }\n\n // Continue using the slot state captured at navigation start for fetches\n // and prefetch compatibility decisions.\n\n let navResponse: Response | undefined;\n let navResponseUrl: string | null = null;\n if (navigationKind !== \"refresh\") {\n const prefetchedResponse = consumePrefetchResponse(\n rscUrl,\n requestInterceptionContext,\n mountedSlotsHeader,\n );\n if (prefetchedResponse) {\n navResponse = restoreRscResponse(prefetchedResponse, false);\n navResponseUrl = prefetchedResponse.url;\n }\n }\n\n if (!navResponse) {\n navResponse = await fetch(rscUrl, {\n headers: requestHeaders,\n credentials: \"include\",\n });\n }\n\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n\n // Any response that isn't a valid RSC payload (non-ok status,\n // missing/rewritten Content-Type, or missing body) means the server\n // returned something we cannot parse — typically an HTML error page\n // or a proxy-rewritten response. Parsing such a body as an RSC stream\n // throws a cryptic \"Connection closed\" error. Match Next.js behavior\n // (fetch-server-response.ts:211, `!isFlightResponse || !res.ok || !res.body`):\n // hard-navigate to the response URL so the server can render the correct\n // error page as HTML. The outer finally handles\n // settlePendingBrowserRouterState and clearPendingPathname on this\n // return path.\n //\n // Prefer the post-redirect response URL over `currentHref`: on a\n // redirect chain like `/old` → 307 → `/new` → 500, the browser's\n // fetch already followed the redirect, so `navResponse.url` is the\n // failing `/new` destination. Hard-navigating there directly avoids\n // bouncing off `/old` just to re-follow the same 307, which would\n // flash the wrong URL in the address bar and mis-key analytics.\n // Matches Next.js' `doMpaNavigation(responseUrl.toString())`. Falls\n // back to `currentHref` when no response URL is available.\n const navContentType = navResponse.headers.get(\"content-type\") ?? \"\";\n const isRscResponse = navContentType.startsWith(\"text/x-component\");\n if (!navResponse.ok || !isRscResponse || !navResponse.body) {\n const responseUrl = navResponseUrl ?? navResponse.url;\n let hardNavTarget = currentHref;\n if (responseUrl) {\n const parsed = new URL(responseUrl, window.location.origin);\n stripRscCacheBustingSearchParam(parsed);\n const origUrl = new URL(currentHref, window.location.origin);\n let pathname = stripRscSuffix(parsed.pathname);\n // createRscRequestUrl strips trailing slash before appending .rsc,\n // so the response URL loses it on the round-trip. Restore it when\n // the original href had one so sites with trailingSlash:true don't\n // incur an extra 308 to the canonical form on the error path.\n if (\n origUrl.pathname.length > 1 &&\n origUrl.pathname.endsWith(\"/\") &&\n !pathname.endsWith(\"/\")\n ) {\n pathname += \"/\";\n }\n hardNavTarget = pathname + parsed.search;\n // Preserve the hash from the user's clicked href — a .rsc response\n // URL never carries a fragment, so dropping it would silently strip\n // `/foo#section` down to `/foo`.\n if (origUrl.hash) hardNavTarget += origUrl.hash;\n }\n window.location.href = hardNavTarget;\n return;\n }\n\n const finalUrl = new URL(navResponseUrl ?? navResponse.url, window.location.origin);\n stripRscCacheBustingSearchParam(finalUrl);\n const requestedUrl = new URL(rscUrl, window.location.origin);\n\n if (finalUrl.pathname !== requestedUrl.pathname) {\n // Server-side redirect: update the URL in history and loop to fetch\n // the destination without settling pendingRouterState. This keeps\n // isPending true across all redirect hops instead of flashing false.\n const destinationPath = stripRscSuffix(finalUrl.pathname) + finalUrl.search;\n replaceHistoryStateWithoutNotify(\n createHistoryStateWithPreviousNextUrl(null, requestPreviousNextUrl),\n \"\",\n destinationPath,\n );\n\n currentHref = destinationPath;\n // URL already written above; the commit effect must not push/replace again.\n currentHistoryMode = undefined;\n currentPrevNextUrl = requestPreviousNextUrl;\n redirectCount += 1;\n continue;\n }\n\n // navParams falls back to {} on a missing or malformed header.\n const navParams: Record<string, string | string[]> =\n parseEncodedJsonHeader<Record<string, string | string[]>>(\n navResponse.headers.get(\"X-Vinext-Params\"),\n ) ?? {};\n // Build snapshot from local params, not latestClientParams\n const navigationSnapshot = createClientNavigationRenderSnapshot(currentHref, navParams);\n\n const responseSnapshot = await snapshotRscResponse(navResponse);\n\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n\n const rscPayload = decodeAppElementsPromise(\n createFromFetch<AppWireElements>(Promise.resolve(restoreRscResponse(responseSnapshot))),\n );\n\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n\n const renderOutcome = await renderNavigationPayload(\n rscPayload,\n navigationSnapshot,\n currentHref,\n navId,\n currentHistoryMode,\n navParams,\n requestPreviousNextUrl,\n pendingRouterState,\n isSameRoute,\n toActionType(navigationKind),\n toOperationLane(navigationKind),\n );\n if (renderOutcome !== \"committed\") return;\n // Don't cache the response if this navigation was superseded during\n // renderNavigationPayload's await — the elements were never dispatched.\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n // Store the visited response only after renderNavigationPayload succeeds.\n // If we stored it before and renderNavigationPayload threw, a future\n // back/forward navigation could replay a snapshot from a navigation that\n // never actually rendered successfully.\n const resolvedElements = await rscPayload;\n const metadata = AppElementsWire.readMetadata(resolvedElements);\n storeVisitedResponseSnapshot(\n rscUrl,\n resolveVisitedResponseInterceptionContext(\n requestInterceptionContext,\n metadata.interceptionContext,\n ),\n responseSnapshot,\n navParams,\n );\n return;\n }\n } catch (error) {\n // Don't hard-navigate to a stale URL if this navigation was superseded by\n // a newer one — the newer navigation is already in flight and would be clobbered.\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n // Suppress the diagnostic when the page is unloading: a hard-nav or anchor\n // click tears down the document and aborts any in-flight RSC fetch, which\n // surfaces here as an error. The page is already going away, so the log\n // is just noise. Mirrors Next.js' isPageUnloading pattern.\n if (!isPageUnloading) {\n console.error(\"[vinext] RSC navigation error:\", error);\n }\n window.location.href = currentHref;\n } finally {\n // Single settlement site: covers normal return, early returns on stale-id\n // checks, and error paths. The finally runs even when the catch returns.\n // settlePendingBrowserRouterState is idempotent via the settled flag.\n browserNavigationController.finalizeNavigation(navId, pendingRouterState);\n }\n };\n\n if (\"scrollRestoration\" in history) {\n history.scrollRestoration = \"manual\";\n }\n\n // Note: This popstate handler runs for App Router (RSC navigation available).\n // It coordinates scroll restoration with the pending RSC navigation.\n // Pages Router scroll restoration is handled in shims/navigation.ts:1289 with\n // microtask-based deferral for compatibility with non-RSC navigation.\n // See: https://github.com/vercel/next.js/discussions/41934#discussioncomment-4602607\n window.addEventListener(\"popstate\", (event) => {\n notifyAppRouterTransitionStart(window.location.href, \"traverse\");\n const pendingNavigation =\n window.__VINEXT_RSC_NAVIGATE__?.(window.location.href, 0, \"traverse\") ?? Promise.resolve();\n window.__VINEXT_RSC_PENDING__ = pendingNavigation;\n void pendingNavigation.finally(() => {\n restorePopstateScrollPosition(event.state);\n if (window.__VINEXT_RSC_PENDING__ === pendingNavigation) {\n window.__VINEXT_RSC_PENDING__ = null;\n }\n });\n });\n\n if (import.meta.hot) {\n import.meta.hot.on(\"rsc:update\", async () => {\n try {\n // If BrowserRoot has been mounted before but isn't now, a render\n // error tore down the tree (e.g. a server route threw). HMR can't\n // dispatch into a missing setter, and waitForBrowserRouterStateReady\n // would block forever — the tree won't remount until the page reloads.\n // Trigger that reload so the user's fix actually lands without a\n // manual refresh. Cleared after a successful mount, so this only\n // fires once per teardown.\n if (\n browserRouterStateHasEverCommitted &&\n !browserNavigationController.hasBrowserRouterState()\n ) {\n window.location.reload();\n return;\n }\n // HMR can also fire before BrowserRoot's layout effect publishes\n // the browser router state (e.g. saving a file while the initial RSC\n // stream is still suspended). Wait for readiness, then re-check the\n // mounted state — readiness can race with cleanup, which nulls it again.\n // Skip silently when the tree is not currently mounted; the next\n // HMR push or full reload will reconcile.\n await waitForBrowserRouterStateReady();\n if (!browserNavigationController.hasBrowserRouterState()) {\n return;\n }\n clearClientNavigationCaches();\n const navigationSnapshot = createClientNavigationRenderSnapshot(\n window.location.href,\n latestClientParams,\n );\n // Clear stale errors from the dev overlay before dispatching the\n // fresh tree. If the new tree renders cleanly, the overlay stays\n // empty; if it throws again, devOnCaughtError/devOnUncaughtError\n // re-populates it. Without this, an old \"DropZone is not defined\"\n // error would linger after the developer fixed the bug.\n dismissOverlay();\n // Interception context on HMR re-renders is intentionally deferred:\n // preserving intercepted modal state across HMR reloads is out of scope\n // for the previousNextUrl mechanism.\n const hmrHeaders = createRscRequestHeaders();\n await browserNavigationController.hmrReplaceTree(\n decodeAppElementsPromise(\n createFromFetch<AppWireElements>(\n fetch(\n await createRscRequestUrl(\n window.location.pathname + window.location.search,\n hmrHeaders,\n ),\n { headers: hmrHeaders },\n ),\n ),\n ),\n navigationSnapshot,\n );\n } catch (error) {\n console.error(\"[vinext] RSC HMR error:\", error);\n }\n });\n }\n}\n\nif (typeof document !== \"undefined\") {\n window.addEventListener(\"pagehide\", () => {\n isPageUnloading = true;\n });\n // Reset on pageshow so a bfcache-restored document does not resume with\n // the flag stuck at true, which would silently swallow every subsequent\n // RSC navigation error for the lifetime of that tab. Matches Next.js'\n // fetch-server-response.ts handler pair.\n window.addEventListener(\"pageshow\", () => {\n isPageUnloading = false;\n });\n void main();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqGA,SAAS,aAAa,MAA+C;AACnE,QAAO,SAAS,aAAa,aAAa;;AAG5C,SAAS,gBAAgB,MAAqC;AAC5D,SAAQ,MAAR;EACE,KAAK,WACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,KAAK,WACH,QAAO;EACT,QAEE,OAAM,IAAI,MAAM,uCAAuC,OAD5B,KAC+C,CAAC;;;AAWjF,MAAM,kCAAkC;AACxC,MAAM,6BAA6B,IAAI;AACvC,MAAM,0BAA0B,KAAK;AACrC,MAAM,8BAA8B,sCAAsC;AAC1E,MAAM,yBAAyB,4BAA4B;AAM3D,SAAS,uBAA0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IhB,MAAM,aAAa,yBAAyB;AAC5C,SAAM,4BAA4B,eAChC,yBACE,gBACE,MACE,MAAM,oBACJ,OAAO,SAAS,WAAW,OAAO,SAAS,QAC3C,WACD,EACD,EAAE,SAAS,YAAY,CACxB,CACF,CACF,EACD,mBACD;WACM,OAAO;AACd,WAAQ,MAAM,2BAA2B,MAAM;;GAEjD;;AAIN,IAAI,OAAO,aAAa,aAAa;AACnC,QAAO,iBAAiB,kBAAkB;AACxC,oBAAkB;GAClB;AAKF,QAAO,iBAAiB,kBAAkB;AACxC,oBAAkB;GAClB;AACG,OAAM"}
|
|
1
|
+
{"version":3,"file":"app-browser-entry.js","names":["_exhaustive"],"sources":["../../src/server/app-browser-entry.ts"],"sourcesContent":["/// <reference types=\"vite/client\" />\n\nimport { createElement, use, useLayoutEffect, useRef, useState } from \"react\";\nimport {\n createFromFetch,\n createFromReadableStream,\n createTemporaryReferenceSet,\n encodeReply,\n setServerCallback,\n} from \"@vitejs/plugin-rsc/browser\";\nimport { hydrateRoot } from \"react-dom/client\";\nimport \"../client/instrumentation-client.js\";\nimport { notifyAppRouterTransitionStart } from \"../client/instrumentation-client-state.js\";\nimport {\n __basePath,\n appRouterInstance,\n commitClientNavigationState,\n consumePrefetchResponse,\n createClientNavigationRenderSnapshot,\n getCurrentNextUrl,\n getCurrentInterceptionContext,\n getClientNavigationRenderContext,\n getPrefetchCache,\n getPrefetchedUrls,\n pushHistoryStateWithoutNotify,\n replaceClientParamsWithoutNotify,\n replaceHistoryStateWithoutNotify,\n restoreRscResponse,\n setClientParams,\n setPendingPathname,\n setMountedSlotsHeader,\n setNavigationContext,\n type CachedRscResponse,\n type ClientNavigationRenderSnapshot,\n} from \"vinext/shims/navigation\";\nimport { installWindowNext } from \"../client/window-next.js\";\nimport {\n chunksToReadableStream,\n createProgressiveRscStream,\n getVinextBrowserGlobal,\n} from \"./app-browser-stream.js\";\nimport {\n createAppBrowserNavigationController,\n clearHardNavigationLoopGuard,\n type HistoryUpdateMode,\n type NavigationPayloadOutcome,\n type PendingBrowserRouterState,\n} from \"./app-browser-navigation-controller.js\";\nimport {\n isServerActionResult,\n shouldClearClientNavigationCachesForServerActionResult,\n type AppBrowserServerActionResult,\n} from \"./app-browser-action-result.js\";\nimport {\n consumeInitialFormState,\n createVinextHydrateRootOptions,\n} from \"./app-browser-hydration.js\";\nimport {\n AppElementsWire,\n getMountedSlotIdsHeader,\n resolveVisitedResponseInterceptionContext,\n type AppElements,\n type AppWireElements,\n} from \"./app-elements.js\";\nimport {\n createHistoryStateWithPreviousNextUrl,\n readHistoryStatePreviousNextUrl,\n resolveInterceptionContextFromPreviousNextUrl,\n resolveServerActionRequestState,\n type AppRouterState,\n type OperationLane,\n} from \"./app-browser-state.js\";\nimport { DevRecoveryBoundary, RedirectBoundary } from \"vinext/shims/error-boundary\";\nimport { ElementsContext, Slot } from \"vinext/shims/slot\";\nimport { createOnUncaughtError } from \"./app-browser-error.js\";\nimport {\n devOnCaughtError,\n devOnUncaughtError,\n dismissOverlay,\n installDevErrorOverlay,\n} from \"./dev-error-overlay.js\";\nimport { DANGEROUS_URL_BLOCK_MESSAGE, isDangerousScheme } from \"vinext/shims/url-safety\";\nimport {\n getServerActionNotFoundClientMessage,\n isServerActionNotFoundResponse,\n} from \"./server-action-not-found.js\";\nimport {\n createRscRequestHeaders,\n createRscRequestUrl,\n stripRscCacheBustingSearchParam,\n stripRscSuffix,\n VINEXT_RSC_CONTENT_TYPE,\n} from \"./app-rsc-cache-busting.js\";\nimport { APP_RSC_RENDER_MODE_REFRESH_PRESERVE_UI } from \"./app-rsc-render-mode.js\";\nimport {\n ACTION_REDIRECT_HEADER,\n ACTION_REDIRECT_TYPE_HEADER,\n VINEXT_MOUNTED_SLOTS_HEADER,\n VINEXT_PARAMS_HEADER,\n} from \"./headers.js\";\n\ntype SearchParamInput = ConstructorParameters<typeof URLSearchParams>[0];\n\ntype ServerActionResult = AppBrowserServerActionResult<AppWireElements>;\n\ntype NavigationKind = \"navigate\" | \"traverse\" | \"refresh\";\n\n// Maps NavigationKind to the AppRouterAction type used by the reducer.\n// \"refresh\" is intentionally treated as \"navigate\" (merge, preserve absent slots).\n// Both call sites must stay in sync — update here if NavigationKind gains new values.\nfunction toActionType(kind: NavigationKind): \"navigate\" | \"traverse\" {\n return kind === \"traverse\" ? \"traverse\" : \"navigate\";\n}\n\nfunction toOperationLane(kind: NavigationKind): OperationLane {\n switch (kind) {\n case \"navigate\":\n return \"navigation\";\n case \"refresh\":\n return \"refresh\";\n case \"traverse\":\n return \"traverse\";\n default: {\n const _exhaustive: never = kind;\n throw new Error(\"[vinext] Unknown navigation kind: \" + String(_exhaustive));\n }\n }\n}\n\ntype VisitedResponseCacheEntry = {\n params: Record<string, string | string[]>;\n expiresAt: number;\n response: CachedRscResponse;\n};\n\nconst MAX_VISITED_RESPONSE_CACHE_SIZE = 50;\nconst VISITED_RESPONSE_CACHE_TTL = 5 * 60_000;\nconst MAX_TRAVERSAL_CACHE_TTL = 30 * 60_000;\nconst browserNavigationController = createAppBrowserNavigationController();\nconst NavigationCommitSignal = browserNavigationController.NavigationCommitSignal;\n\n// Parses a URI-encoded JSON value carried in a response header (e.g.\n// `X-Vinext-Params`). Returns `null` on missing or malformed input so callers\n// can fall back to their own defaults. Silent by design — these headers are\n// best-effort hydration data and a parse failure should not break navigation.\nfunction parseEncodedJsonHeader<T>(value: string | null): T | null {\n if (!value) return null;\n try {\n return JSON.parse(decodeURIComponent(value)) as T;\n } catch {\n return null;\n }\n}\n\nfunction isRouterStatePromise(\n value: AppRouterState | Promise<AppRouterState>,\n): value is Promise<AppRouterState> {\n return value instanceof Promise;\n}\n\nlet latestClientParams: Record<string, string | string[]> = {};\nconst visitedResponseCache = new Map<string, VisitedResponseCacheEntry>();\n// Sticky bit: stays true once BrowserRoot has committed at least once. Used by\n// the HMR handler to distinguish \"still hydrating\" (wait) from \"was up, then\n// torn down by a render error\" (full reload to recover).\nlet browserRouterStateHasEverCommitted = false;\n// Most recent navigation target that has been dispatched but not yet committed.\n// Read by the onUncaughtError handler so a render error tearing down the tree\n// can land the browser on the URL the user was actually navigating to, instead\n// of stranding them on the previous URL with a blank page. Cleared once the\n// commit effect runs (URL update succeeded) or the navigation is superseded.\nlet pendingNavigationRecoveryHref: string | null = null;\n\nfunction getBrowserRouterState(): AppRouterState {\n return browserNavigationController.getBrowserRouterState();\n}\n\nfunction hasBrowserRouterState(): boolean {\n return browserNavigationController.hasBrowserRouterState();\n}\n\nfunction waitForBrowserRouterStateReady(): Promise<void> {\n return browserNavigationController.waitForBrowserRouterStateReady();\n}\n\nfunction beginPendingBrowserRouterState(): PendingBrowserRouterState {\n return browserNavigationController.beginPendingBrowserRouterState();\n}\n\nfunction applyClientParams(params: Record<string, string | string[]>): void {\n latestClientParams = params;\n setClientParams(params);\n}\n\nfunction stageClientParams(params: Record<string, string | string[]>): void {\n // NB: latestClientParams diverges from ClientNavigationState.clientParams\n // between staging and commit. Server action snapshots (same-URL\n // commitSameUrlNavigatePayload() calls inside registerServerActionCallback)\n // read latestClientParams, so a\n // server action fired during this window would get the pending (not yet\n // committed) params. This is acceptable because the commit effect fires\n // before hooks observe the new URL state, keeping the window vanishingly small.\n latestClientParams = params;\n replaceClientParamsWithoutNotify(params);\n}\n\nfunction clearVisitedResponseCache(): void {\n visitedResponseCache.clear();\n}\n\nfunction clearPrefetchState(): void {\n getPrefetchCache().clear();\n getPrefetchedUrls().clear();\n}\n\nfunction clearClientNavigationCaches(): void {\n clearVisitedResponseCache();\n clearPrefetchState();\n}\n\nfunction createNavigationCommitEffect(options: {\n href: string;\n historyUpdateMode: HistoryUpdateMode | undefined;\n navId: number;\n params: Record<string, string | string[]>;\n previousNextUrl: string | null;\n}): () => void {\n const { href, historyUpdateMode, navId, params, previousNextUrl } = options;\n\n return () => {\n // Only update URL if this is still the active navigation.\n // A newer navigation would have superseded this navigation id.\n if (!browserNavigationController.isCurrentNavigation(navId)) {\n // This transition was superseded before commit; balance the active\n // snapshot counter without clearing pendingPathname ownership.\n commitClientNavigationState(undefined, { releaseSnapshot: true });\n return;\n }\n\n const targetHref = new URL(href, window.location.origin).href;\n stageClientParams(params);\n const preserveExistingState = historyUpdateMode === \"replace\";\n const historyState = createHistoryStateWithPreviousNextUrl(\n preserveExistingState ? window.history.state : null,\n previousNextUrl,\n );\n\n if (historyUpdateMode === \"replace\" && window.location.href !== targetHref) {\n replaceHistoryStateWithoutNotify(historyState, \"\", href);\n } else if (historyUpdateMode === \"push\" && window.location.href !== targetHref) {\n pushHistoryStateWithoutNotify(historyState, \"\", href);\n }\n\n // URL has been updated; the recovery hard-nav target is no longer needed.\n pendingNavigationRecoveryHref = null;\n commitClientNavigationState(navId);\n };\n}\n\nasync function renderNavigationPayload(\n payload: Promise<AppElements>,\n navigationSnapshot: ClientNavigationRenderSnapshot,\n targetHref: string,\n navId: number,\n historyUpdateMode: HistoryUpdateMode | undefined,\n params: Record<string, string | string[]>,\n previousNextUrl: string | null,\n pendingRouterState: PendingBrowserRouterState | null,\n actionType: \"navigate\" | \"replace\" | \"traverse\" = \"navigate\",\n operationLane: OperationLane = \"navigation\",\n): Promise<NavigationPayloadOutcome> {\n try {\n return await browserNavigationController.renderNavigationPayload({\n actionType,\n createNavigationCommitEffect: (options) => {\n pendingNavigationRecoveryHref = options.href;\n return createNavigationCommitEffect(options);\n },\n historyUpdateMode,\n navigationSnapshot,\n nextElements: payload,\n operationLane,\n params,\n pendingRouterState,\n previousNextUrl,\n targetHref,\n navId,\n });\n } catch (error) {\n pendingNavigationRecoveryHref = null;\n throw error;\n }\n}\n\nasync function commitSameUrlNavigatePayload(\n nextElements: Promise<AppElements>,\n returnValue?: ServerActionResult[\"returnValue\"],\n actionInitiationState?: AppRouterState,\n): Promise<unknown> {\n const navigationSnapshot = createClientNavigationRenderSnapshot(\n window.location.href,\n latestClientParams,\n );\n return browserNavigationController.commitSameUrlNavigatePayload(\n nextElements,\n navigationSnapshot,\n returnValue,\n actionInitiationState,\n );\n}\n\nfunction evictVisitedResponseCacheIfNeeded(): void {\n while (visitedResponseCache.size >= MAX_VISITED_RESPONSE_CACHE_SIZE) {\n const oldest = visitedResponseCache.keys().next().value;\n if (oldest === undefined) {\n return;\n }\n visitedResponseCache.delete(oldest);\n }\n}\n\nfunction getVisitedResponse(\n rscUrl: string,\n interceptionContext: string | null,\n mountedSlotsHeader: string | null,\n navigationKind: NavigationKind,\n): VisitedResponseCacheEntry | null {\n const cacheKey = AppElementsWire.encodeCacheKey(rscUrl, interceptionContext);\n const cached = visitedResponseCache.get(cacheKey);\n if (!cached) {\n return null;\n }\n\n if ((cached.response.mountedSlotsHeader ?? null) !== mountedSlotsHeader) {\n visitedResponseCache.delete(cacheKey);\n return null;\n }\n\n if (navigationKind === \"refresh\") {\n return null;\n }\n\n if (navigationKind === \"traverse\") {\n const createdAt = cached.expiresAt - VISITED_RESPONSE_CACHE_TTL;\n if (Date.now() - createdAt >= MAX_TRAVERSAL_CACHE_TTL) {\n visitedResponseCache.delete(cacheKey);\n return null;\n }\n // LRU: promote to most-recently-used (delete + re-insert moves to end of Map)\n visitedResponseCache.delete(cacheKey);\n visitedResponseCache.set(cacheKey, cached);\n return cached;\n }\n\n if (cached.expiresAt > Date.now()) {\n // LRU: promote to most-recently-used\n visitedResponseCache.delete(cacheKey);\n visitedResponseCache.set(cacheKey, cached);\n return cached;\n }\n\n visitedResponseCache.delete(cacheKey);\n return null;\n}\n\nfunction storeVisitedResponseSnapshot(\n rscUrl: string,\n interceptionContext: string | null,\n snapshot: CachedRscResponse,\n params: Record<string, string | string[]>,\n): void {\n const cacheKey = AppElementsWire.encodeCacheKey(rscUrl, interceptionContext);\n visitedResponseCache.delete(cacheKey);\n evictVisitedResponseCacheIfNeeded();\n const now = Date.now();\n visitedResponseCache.set(cacheKey, {\n params,\n expiresAt: now + VISITED_RESPONSE_CACHE_TTL,\n response: snapshot,\n });\n}\n\ntype NavigationRequestState = {\n interceptionContext: string | null;\n previousNextUrl: string | null;\n};\n\nfunction getRequestState(\n navigationKind: NavigationKind,\n previousNextUrlOverride?: string | null,\n): NavigationRequestState {\n if (previousNextUrlOverride !== undefined) {\n return {\n interceptionContext: resolveInterceptionContextFromPreviousNextUrl(\n previousNextUrlOverride,\n __basePath,\n ),\n previousNextUrl: previousNextUrlOverride,\n };\n }\n\n switch (navigationKind) {\n case \"navigate\":\n return {\n interceptionContext: getCurrentInterceptionContext(),\n previousNextUrl: getCurrentNextUrl(),\n };\n case \"traverse\": {\n const previousNextUrl = readHistoryStatePreviousNextUrl(window.history.state);\n return {\n interceptionContext: resolveInterceptionContextFromPreviousNextUrl(\n previousNextUrl,\n __basePath,\n ),\n previousNextUrl,\n };\n }\n case \"refresh\": {\n const currentPreviousNextUrl = getBrowserRouterState().previousNextUrl;\n return {\n interceptionContext: resolveInterceptionContextFromPreviousNextUrl(\n currentPreviousNextUrl,\n __basePath,\n ),\n previousNextUrl: currentPreviousNextUrl,\n };\n }\n default: {\n const _exhaustive: never = navigationKind;\n throw new Error(\"[vinext] Unknown navigation kind: \" + String(_exhaustive));\n }\n }\n}\n\n// Dev-only callback invoked when DevRecoveryBoundary catches. The replaced\n// subtree means NavigationCommitSignal's useLayoutEffect never fires, so the\n// URL update for the in-flight navigation would otherwise be lost. Force-drain\n// the queued pre-paint effect for this renderId so the URL still moves to the\n// navigation target, the dev overlay shows which URL is broken, and HMR's\n// rsc:update fetches the right payload after the bug is fixed.\nfunction handleDevRecoveryBoundaryCatch(resetKey: number): void {\n // React's onCaughtError option already routes the error to the dev overlay.\n // Our job here is purely to drive the URL update for the in-flight\n // navigation that this failed render belonged to.\n browserNavigationController.drainPrePaintEffects(resetKey);\n}\n\nfunction decodeAppElementsPromise(payload: Promise<AppWireElements>): Promise<AppElements> {\n // Wrap in Promise.resolve() because createFromReadableStream() returns a\n // React Flight thenable whose .then() returns undefined (not a new Promise).\n // Without the wrap, chaining .then() produces undefined → use() crashes.\n return Promise.resolve(payload).then((elements) => AppElementsWire.decode(elements));\n}\n\nfunction BrowserRoot({\n initialElements,\n initialNavigationSnapshot,\n}: {\n initialElements: Promise<AppElements>;\n initialNavigationSnapshot: ClientNavigationRenderSnapshot;\n}) {\n const resolvedElements = use(initialElements);\n const initialMetadata = AppElementsWire.readMetadata(resolvedElements);\n const [treeStateValue, setTreeStateValue] = useState<AppRouterState | Promise<AppRouterState>>({\n activeOperation: null,\n elements: resolvedElements,\n interceptionContext: initialMetadata.interceptionContext,\n layoutIds: initialMetadata.layoutIds,\n layoutFlags: initialMetadata.layoutFlags,\n navigationSnapshot: initialNavigationSnapshot,\n previousNextUrl: null,\n renderId: 0,\n rootLayoutTreePath: initialMetadata.rootLayoutTreePath,\n routeId: initialMetadata.routeId,\n visibleCommitVersion: 0,\n });\n const treeState = isRouterStatePromise(treeStateValue) ? use(treeStateValue) : treeStateValue;\n\n // Keep the latest router state in a ref so external callers (navigate(),\n // server actions, HMR) always read the current state. Safe: those readers\n // run from events/effects, never from React render itself.\n // Note: stateRef.current is written during render, not in an effect, to\n // avoid a stale-read window between commit and layout effects. This mirrors\n // the same render-phase ref update pattern used by Next.js's own router.\n const stateRef = useRef(treeState);\n stateRef.current = treeState;\n\n // Publish the stable ref object and dispatch during layout commit. This keeps\n // the module-level escape hatches aligned with React's committed tree without\n // performing module writes during render. __VINEXT_RSC_NAVIGATE__ is assigned\n // after hydrateRoot() returns; by then this layout effect has already run for\n // the hydration commit, so getBrowserRouterState() never observes a null ref.\n useLayoutEffect(() => {\n const detach = browserNavigationController.attachBrowserRouterState(\n setTreeStateValue,\n stateRef,\n );\n browserRouterStateHasEverCommitted = true;\n return () => {\n detach();\n setMountedSlotsHeader(null);\n };\n }, [setTreeStateValue]);\n\n useLayoutEffect(() => {\n setMountedSlotsHeader(getMountedSlotIdsHeader(stateRef.current.elements));\n }, [treeState.elements]);\n\n useLayoutEffect(() => {\n if (treeState.renderId !== 0) {\n return;\n }\n\n replaceHistoryStateWithoutNotify(\n createHistoryStateWithPreviousNextUrl(window.history.state, treeState.previousNextUrl),\n \"\",\n window.location.href,\n );\n }, [treeState.previousNextUrl, treeState.renderId]);\n\n const innerTree = createElement(\n RedirectBoundary,\n null,\n createElement(\n NavigationCommitSignal,\n { renderId: treeState.renderId },\n createElement(\n ElementsContext.Provider,\n { value: treeState.elements },\n createElement(Slot, { id: treeState.routeId }),\n ),\n ),\n );\n\n // In dev, wrap the route tree in a top-level recovery boundary. A render\n // error (e.g. a slot's RSC reference rejects) is caught here instead of\n // tearing down BrowserRoot, so HMR can dispatch the next payload —\n // identified by an incremented renderId, which doubles as the boundary's\n // reset key — without a full page reload. The dev overlay (a separate\n // React root) shows the error itself.\n //\n // onCatch drains the pending pre-paint effect for the failed render so\n // the URL update bound to that navigation still runs. Without this, a\n // soft-nav whose target throws would leave the browser on the previous\n // URL, hiding which route is broken and mis-targeting the next HMR\n // payload (which fetches RSC for window.location.pathname).\n //\n // This file is .ts, not .tsx — children are passed positionally to satisfy\n // both the createElement overload and eslint's no-children-prop rule.\n const committedTree = import.meta.env.DEV\n ? createElement(\n DevRecoveryBoundary,\n {\n resetKey: treeState.renderId,\n onCatch: handleDevRecoveryBoundaryCatch,\n },\n innerTree,\n )\n : innerTree;\n\n const ClientNavigationRenderContext = getClientNavigationRenderContext();\n if (!ClientNavigationRenderContext) {\n return committedTree;\n }\n\n return createElement(\n ClientNavigationRenderContext.Provider,\n { value: treeState.navigationSnapshot },\n committedTree,\n );\n}\n\nfunction restoreHydrationNavigationContext(\n pathname: string,\n searchParams: SearchParamInput,\n params: Record<string, string | string[]>,\n): void {\n setNavigationContext({\n pathname,\n searchParams: new URLSearchParams(searchParams),\n params,\n });\n}\n\nfunction decodeHashFragment(fragment: string): string {\n try {\n return decodeURIComponent(fragment);\n } catch {\n return fragment;\n }\n}\n\nfunction scrollToHashTarget(hash: string): void {\n const fragment = decodeHashFragment(hash.startsWith(\"#\") ? hash.slice(1) : hash);\n\n requestAnimationFrame(() => {\n if (fragment === \"\" || fragment === \"top\") {\n window.scrollTo(0, 0);\n return;\n }\n\n const idElement = document.getElementById(fragment);\n if (idElement) {\n idElement.scrollIntoView({ behavior: \"auto\" });\n return;\n }\n\n document.getElementsByName(fragment)[0]?.scrollIntoView({ behavior: \"auto\" });\n });\n}\n\nfunction restorePopstateScrollPosition(state: unknown): void {\n if (!(state && typeof state === \"object\" && \"__vinext_scrollY\" in state)) {\n if (window.location.hash) {\n scrollToHashTarget(window.location.hash);\n }\n return;\n }\n\n const y = Number(state.__vinext_scrollY);\n const x = \"__vinext_scrollX\" in state ? Number(state.__vinext_scrollX) : 0;\n\n requestAnimationFrame(() => {\n window.scrollTo(x, y);\n });\n}\n\n// Set on pagehide so the RSC navigation catch block can distinguish expected\n// fetch aborts (triggered by the unload itself) from real errors worth logging.\nlet isPageUnloading = false;\n\nconst RSC_RELOAD_KEY = \"__vinext_rsc_initial_reload__\";\n\n// sessionStorage can throw SecurityError in strict-mode iframes, storage-\n// disabled browsers, and some Safari private-browsing configurations. Wrap\n// every access so a recovery path for one error does not crash hydration.\nfunction readReloadFlag(): string | null {\n try {\n return sessionStorage.getItem(RSC_RELOAD_KEY);\n } catch {\n return null;\n }\n}\nfunction writeReloadFlag(path: string): void {\n try {\n sessionStorage.setItem(RSC_RELOAD_KEY, path);\n } catch {}\n}\nfunction clearReloadFlag(): void {\n try {\n sessionStorage.removeItem(RSC_RELOAD_KEY);\n } catch {}\n}\n\n// A non-ok or wrong-content-type RSC response during initial hydration means\n// the server cannot deliver a valid RSC payload for this URL. Parsing the\n// response as RSC causes an opaque parse failure. On the first attempt,\n// reload once so the server has a chance to render the correct error page\n// as HTML. On the second attempt (detected via the sessionStorage flag), the\n// endpoint is persistently broken. Returns null so main() aborts the\n// hydration bootstrap without registering `__VINEXT_RSC_*` globals —\n// including during the brief window between reload() firing and the page\n// actually unloading — so external probes never see a half-hydrated page.\nfunction recoverFromBadInitialRscResponse(reason: string): null {\n const currentPath = window.location.pathname + window.location.search;\n if (readReloadFlag() === currentPath) {\n clearReloadFlag();\n console.error(\n `[vinext] Initial RSC fetch ${reason} after reload; aborting hydration. ` +\n \"Server-rendered HTML remains visible; client components will not hydrate.\",\n );\n return null;\n }\n writeReloadFlag(currentPath);\n // Verify the write persisted. In storage-denied environments (strict-mode\n // iframes, locked-down enterprise policies), every getItem returns null and\n // every setItem silently no-ops, so the reload-loop guard cannot survive\n // the reload — the page would loop forever. Abort instead so the user at\n // least sees the server-rendered HTML.\n if (readReloadFlag() !== currentPath) {\n console.error(\n `[vinext] Initial RSC fetch ${reason}; sessionStorage unavailable so the ` +\n \"reload-loop guard cannot persist — aborting hydration. \" +\n \"Server-rendered HTML remains visible; client components will not hydrate.\",\n );\n return null;\n }\n // One-shot diagnostic so a production reload is traceable. Only fires once\n // per broken path thanks to the sessionStorage flag above; not noisy.\n console.warn(\n `[vinext] Initial RSC fetch ${reason}; reloading once to let the server render the HTML error page`,\n );\n window.location.reload();\n return null;\n}\n\nasync function readInitialRscStream(): Promise<ReadableStream<Uint8Array> | null> {\n const vinext = getVinextBrowserGlobal();\n\n if (vinext.__VINEXT_RSC__ || vinext.__VINEXT_RSC_CHUNKS__ || vinext.__VINEXT_RSC_DONE__) {\n // Reaching the embedded-RSC branch means the server successfully rendered\n // the page — any prior reload flag for this path is stale and must be\n // cleared so a future failure gets its own fresh recovery attempt.\n clearReloadFlag();\n clearHardNavigationLoopGuard();\n\n if (vinext.__VINEXT_RSC__) {\n const embedData = vinext.__VINEXT_RSC__;\n delete vinext.__VINEXT_RSC__;\n\n const params = embedData.params ?? {};\n if (embedData.params) {\n applyClientParams(embedData.params);\n }\n if (embedData.nav) {\n restoreHydrationNavigationContext(\n embedData.nav.pathname,\n embedData.nav.searchParams,\n params,\n );\n }\n\n return chunksToReadableStream(embedData.rsc);\n }\n\n const params = vinext.__VINEXT_RSC_PARAMS__ ?? {};\n if (vinext.__VINEXT_RSC_PARAMS__) {\n applyClientParams(vinext.__VINEXT_RSC_PARAMS__);\n }\n if (vinext.__VINEXT_RSC_NAV__) {\n restoreHydrationNavigationContext(\n vinext.__VINEXT_RSC_NAV__.pathname,\n vinext.__VINEXT_RSC_NAV__.searchParams,\n params,\n );\n }\n\n return createProgressiveRscStream();\n }\n\n const rscHeaders = createRscRequestHeaders();\n const rscResponse = await fetch(\n await createRscRequestUrl(window.location.pathname + window.location.search, rscHeaders),\n { credentials: \"include\", headers: rscHeaders },\n );\n\n if (!rscResponse.ok) {\n return recoverFromBadInitialRscResponse(`returned ${rscResponse.status}`);\n }\n // Guard against proxies/CDNs that return 200 with a rewritten Content-Type\n // (e.g. text/html instead of text/x-component). Such responses cannot be\n // parsed as RSC and would throw the same opaque parse error this fallback\n // exists to prevent.\n const contentType = rscResponse.headers.get(\"content-type\") ?? \"\";\n if (!contentType.startsWith(VINEXT_RSC_CONTENT_TYPE)) {\n return recoverFromBadInitialRscResponse(\n `returned non-RSC content-type \"${contentType || \"(missing)\"}\"`,\n );\n }\n // Missing body (e.g. 204 No Content, or an edge worker that returned ok\n // headers without piping the stream) fails the same way downstream.\n // Matches Next.js' `!res.body` branch in fetch-server-response.ts.\n if (!rscResponse.body) {\n return recoverFromBadInitialRscResponse(\"returned empty body\");\n }\n // Successful RSC response clears the guard so a subsequent reload of the\n // same path after a transient failure still gets one recovery attempt.\n clearReloadFlag();\n clearHardNavigationLoopGuard();\n\n // Ignore malformed param headers and continue with hydration. The original\n // try/catch also swallowed errors from applyClientParams; preserve that.\n const parsedParams = parseEncodedJsonHeader<Record<string, string | string[]>>(\n rscResponse.headers.get(VINEXT_PARAMS_HEADER),\n );\n const params: Record<string, string | string[]> = parsedParams ?? {};\n if (parsedParams) {\n try {\n applyClientParams(parsedParams);\n } catch {\n // Ignore — matches the previous combined try/catch behavior.\n }\n }\n\n restoreHydrationNavigationContext(window.location.pathname, window.location.search, params);\n\n return rscResponse.body;\n}\n\nfunction registerServerActionCallback(): void {\n setServerCallback(async (id, args) => {\n const temporaryReferences = createTemporaryReferenceSet();\n const body = await encodeReply(args, { temporaryReferences });\n\n // Carry the interception context + mounted slots from the current router\n // state so the server-action re-render rebuilds the intercepted tree\n // instead of replacing it with the direct page. Parity with Next.js,\n // which sends `Next-URL` on action POSTs when the current tree contains\n // an interception route.\n const currentState = getBrowserRouterState();\n const { headers } = resolveServerActionRequestState({\n actionId: id,\n basePath: __basePath,\n elements: currentState.elements,\n previousNextUrl: currentState.previousNextUrl,\n });\n\n const fetchResponse = await fetch(\n await createRscRequestUrl(window.location.pathname + window.location.search, headers),\n {\n method: \"POST\",\n headers,\n body,\n },\n );\n\n if (isServerActionNotFoundResponse(fetchResponse)) {\n throw new Error(getServerActionNotFoundClientMessage(id));\n }\n\n const actionRedirect = fetchResponse.headers.get(ACTION_REDIRECT_HEADER);\n if (actionRedirect) {\n if (isDangerousScheme(actionRedirect)) {\n console.error(DANGEROUS_URL_BLOCK_MESSAGE);\n return undefined;\n }\n\n // Check for external URLs that need a hard redirect.\n try {\n const redirectUrl = new URL(actionRedirect, window.location.origin);\n if (redirectUrl.origin !== window.location.origin) {\n window.location.href = actionRedirect;\n return undefined;\n }\n } catch {\n // Fall through to hard redirect below if URL parsing fails.\n }\n\n // Use hard redirect for all action redirects because vinext's server\n // currently returns an empty body for redirect responses. RSC navigation\n // requires a valid RSC payload. This is a known parity gap with Next.js,\n // which pre-renders the redirect target's RSC payload.\n clearClientNavigationCaches();\n const redirectType = fetchResponse.headers.get(ACTION_REDIRECT_TYPE_HEADER) ?? \"replace\";\n if (redirectType === \"push\") {\n window.location.assign(actionRedirect);\n } else {\n window.location.replace(actionRedirect);\n }\n return undefined;\n }\n\n const result = await createFromFetch<ServerActionResult | AppWireElements>(\n Promise.resolve(fetchResponse),\n { temporaryReferences },\n );\n if (shouldClearClientNavigationCachesForServerActionResult(result)) {\n clearClientNavigationCaches();\n }\n\n // Server actions stay on the same URL and use commitSameUrlNavigatePayload()\n // for merge-based dispatch. This path does not call\n // activateNavigationSnapshot() because there is no URL change to commit, so\n // hooks continue reading the live external-store values directly. If server\n // actions ever trigger URL changes via RSC payload (instead of hard\n // redirects), this would need renderNavigationPayload().\n if (isServerActionResult(result)) {\n if (result.root !== undefined) {\n return commitSameUrlNavigatePayload(\n Promise.resolve(AppElementsWire.decode(result.root)),\n result.returnValue,\n currentState,\n );\n }\n\n if (result.returnValue) {\n if (!result.returnValue.ok) {\n throw result.returnValue.data;\n }\n return result.returnValue.data;\n }\n\n return undefined;\n }\n\n return commitSameUrlNavigatePayload(\n Promise.resolve(AppElementsWire.decode(result)),\n undefined,\n currentState,\n );\n });\n}\n\nasync function main(): Promise<void> {\n registerServerActionCallback();\n\n const rscStream = await readInitialRscStream();\n // null signals that readInitialRscStream aborted hydration — either because\n // a reload is in flight (first-attempt recovery) or the endpoint is\n // persistently broken (post-reload). Bootstrap is a separate synchronous\n // helper so the null-branch structurally cannot reach any __VINEXT_RSC_*\n // global assignment, even if a future refactor interposes async work here.\n if (rscStream === null) return;\n bootstrapHydration(rscStream);\n}\n\nfunction bootstrapHydration(rscStream: ReadableStream<Uint8Array>): void {\n if (import.meta.env.DEV) {\n installDevErrorOverlay();\n }\n\n const root = decodeAppElementsPromise(createFromReadableStream<AppWireElements>(rscStream));\n const initialNavigationSnapshot = createClientNavigationRenderSnapshot(\n window.location.href,\n latestClientParams,\n );\n replaceHistoryStateWithoutNotify(\n createHistoryStateWithPreviousNextUrl(window.history.state, null),\n \"\",\n window.location.href,\n );\n\n // In dev we route uncaught errors into the dev overlay rather than the\n // hard-nav recovery: the overlay is what the developer needs to see, and a\n // recovery nav would wipe it. In prod we keep the recovery hard-nav so the\n // user lands on a renderable URL with the actual error UI.\n const onUncaughtError = import.meta.env.DEV\n ? devOnUncaughtError\n : createOnUncaughtError(() => pendingNavigationRecoveryHref);\n const formState = consumeInitialFormState(getVinextBrowserGlobal());\n const hydrateRootOptions = import.meta.env.DEV\n ? createVinextHydrateRootOptions({\n formState,\n onCaughtError: devOnCaughtError,\n onUncaughtError,\n })\n : createVinextHydrateRootOptions({\n formState,\n onUncaughtError,\n });\n window.__VINEXT_RSC_ROOT__ = hydrateRoot(\n document,\n createElement(BrowserRoot, {\n initialElements: root,\n initialNavigationSnapshot,\n }),\n hydrateRootOptions,\n );\n window.__VINEXT_HYDRATED_AT = performance.now();\n\n // Exposed so the navigation shim's `router.refresh()` can invalidate the\n // entire client navigation cache (visited-response + prefetch) before\n // re-fetching, matching Next.js refresh semantics — see refresh-reducer.ts\n // header comment: \"the segment cache contains the actual RSC data which\n // needs to be re-fetched.\"\n window.__VINEXT_CLEAR_NAV_CACHES__ = clearClientNavigationCaches;\n\n window.__VINEXT_RSC_NAVIGATE__ = async function navigateRsc(\n href: string,\n redirectDepth = 0,\n navigationKind: NavigationKind = \"navigate\",\n historyUpdateMode?: HistoryUpdateMode,\n previousNextUrlOverride?: string | null,\n programmaticTransition = false,\n ): Promise<void> {\n let pendingRouterState: PendingBrowserRouterState | null = null;\n // Hoist navId above try so the catch and finally blocks can reference it.\n const navId = browserNavigationController.beginNavigation();\n\n // Loop variables for inline redirect following. On a redirect, these are\n // updated and the loop continues without returning or re-entering navigateRsc,\n // so a single pendingRouterState spans all hops and isPending never flashes.\n let currentHref = href;\n let currentHistoryMode = historyUpdateMode;\n let currentPrevNextUrl = previousNextUrlOverride;\n let redirectCount = redirectDepth;\n\n try {\n const shouldUsePendingRouterState = programmaticTransition && navigationKind !== \"refresh\";\n if (shouldUsePendingRouterState && hasBrowserRouterState()) {\n pendingRouterState = beginPendingBrowserRouterState();\n } else {\n await waitForBrowserRouterStateReady();\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n\n if (shouldUsePendingRouterState) {\n pendingRouterState = beginPendingBrowserRouterState();\n }\n }\n\n while (true) {\n if (redirectCount > 10) {\n console.error(\n \"[vinext] Too many RSC redirects — aborting navigation to prevent infinite loop.\",\n );\n window.location.href = currentHref;\n return;\n }\n\n const url = new URL(currentHref, window.location.origin);\n const requestState = getRequestState(navigationKind, currentPrevNextUrl);\n const requestInterceptionContext = requestState.interceptionContext;\n const requestPreviousNextUrl = requestState.previousNextUrl;\n\n // Set this navigation as the pending pathname, overwriting any previous.\n // Pass navId so only this navigation (or a newer one) can clear it later.\n setPendingPathname(url.pathname, navId);\n\n const elementsAtNavStart = getBrowserRouterState().elements;\n const mountedSlotsHeader = getMountedSlotIdsHeader(elementsAtNavStart);\n const requestHeaders = createRscRequestHeaders({\n interceptionContext: requestInterceptionContext,\n renderMode:\n navigationKind === \"refresh\" ? APP_RSC_RENDER_MODE_REFRESH_PRESERVE_UI : undefined,\n });\n if (mountedSlotsHeader) {\n requestHeaders.set(VINEXT_MOUNTED_SLOTS_HEADER, mountedSlotsHeader);\n }\n const rscUrl = await createRscRequestUrl(url.pathname + url.search, requestHeaders);\n const cachedRoute = getVisitedResponse(\n rscUrl,\n requestInterceptionContext,\n mountedSlotsHeader,\n navigationKind,\n );\n if (cachedRoute) {\n // Check stale-navigation before and after createFromFetch. The pre-check\n // avoids wasted parse work; the post-check catches supersessions that\n // occur during the await. createFromFetch on a buffered response is fast\n // but still async, so the window exists. The non-cached path (below) places\n // its heavyweight async steps (fetch, body.tee + createFromFetch on the\n // live RSC branch) between navId checks consistently; the cached path omits\n // the check between createClientNavigationRenderSnapshot (synchronous) and\n // createFromFetch because there is no await in that gap.\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n const cachedParams = cachedRoute.params;\n // createClientNavigationRenderSnapshot is synchronous (URL parsing + param\n // wrapping only) — no stale-navigation recheck needed between here and the\n // next await.\n const cachedNavigationSnapshot = createClientNavigationRenderSnapshot(\n currentHref,\n cachedParams,\n );\n const cachedPayload = decodeAppElementsPromise(\n createFromFetch<AppWireElements>(\n Promise.resolve(restoreRscResponse(cachedRoute.response)),\n ),\n );\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n await renderNavigationPayload(\n cachedPayload,\n cachedNavigationSnapshot,\n currentHref,\n navId,\n currentHistoryMode,\n cachedParams,\n requestPreviousNextUrl,\n pendingRouterState,\n toActionType(navigationKind),\n toOperationLane(navigationKind),\n );\n return;\n }\n\n // Continue using the slot state captured at navigation start for fetches\n // and prefetch compatibility decisions.\n\n let navResponse: Response | undefined;\n let navResponseUrl: string | null = null;\n if (navigationKind !== \"refresh\") {\n const prefetchedResponse = consumePrefetchResponse(\n rscUrl,\n requestInterceptionContext,\n mountedSlotsHeader,\n );\n if (prefetchedResponse) {\n navResponse = restoreRscResponse(prefetchedResponse, false);\n navResponseUrl = prefetchedResponse.url;\n }\n }\n\n if (!navResponse) {\n navResponse = await fetch(rscUrl, {\n headers: requestHeaders,\n credentials: \"include\",\n });\n }\n\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n\n // Any response that isn't a valid RSC payload (non-ok status,\n // missing/rewritten Content-Type, or missing body) means the server\n // returned something we cannot parse — typically an HTML error page\n // or a proxy-rewritten response. Parsing such a body as an RSC stream\n // throws a cryptic \"Connection closed\" error. Match Next.js behavior\n // (fetch-server-response.ts:211, `!isFlightResponse || !res.ok || !res.body`):\n // hard-navigate to the response URL so the server can render the correct\n // error page as HTML. The outer finally handles\n // settlePendingBrowserRouterState and clearPendingPathname on this\n // return path.\n //\n // Prefer the post-redirect response URL over `currentHref`: on a\n // redirect chain like `/old` → 307 → `/new` → 500, the browser's\n // fetch already followed the redirect, so `navResponse.url` is the\n // failing `/new` destination. Hard-navigating there directly avoids\n // bouncing off `/old` just to re-follow the same 307, which would\n // flash the wrong URL in the address bar and mis-key analytics.\n // Matches Next.js' `doMpaNavigation(responseUrl.toString())`. Falls\n // back to `currentHref` when no response URL is available.\n const navContentType = navResponse.headers.get(\"content-type\") ?? \"\";\n const isRscResponse = navContentType.startsWith(\"text/x-component\");\n if (!navResponse.ok || !isRscResponse || !navResponse.body) {\n const responseUrl = navResponseUrl ?? navResponse.url;\n let hardNavTarget = currentHref;\n if (responseUrl) {\n const parsed = new URL(responseUrl, window.location.origin);\n stripRscCacheBustingSearchParam(parsed);\n const origUrl = new URL(currentHref, window.location.origin);\n let pathname = stripRscSuffix(parsed.pathname);\n // createRscRequestUrl strips trailing slash before appending .rsc,\n // so the response URL loses it on the round-trip. Restore it when\n // the original href had one so sites with trailingSlash:true don't\n // incur an extra 308 to the canonical form on the error path.\n if (\n origUrl.pathname.length > 1 &&\n origUrl.pathname.endsWith(\"/\") &&\n !pathname.endsWith(\"/\")\n ) {\n pathname += \"/\";\n }\n hardNavTarget = pathname + parsed.search;\n // Preserve the hash from the user's clicked href — a .rsc response\n // URL never carries a fragment, so dropping it would silently strip\n // `/foo#section` down to `/foo`.\n if (origUrl.hash) hardNavTarget += origUrl.hash;\n }\n window.location.href = hardNavTarget;\n return;\n }\n\n const finalUrl = new URL(navResponseUrl ?? navResponse.url, window.location.origin);\n stripRscCacheBustingSearchParam(finalUrl);\n const requestedUrl = new URL(rscUrl, window.location.origin);\n\n if (finalUrl.pathname !== requestedUrl.pathname) {\n // Server-side redirect: update the URL in history and loop to fetch\n // the destination without settling pendingRouterState. This keeps\n // isPending true across all redirect hops instead of flashing false.\n const destinationPath = stripRscSuffix(finalUrl.pathname) + finalUrl.search;\n replaceHistoryStateWithoutNotify(\n createHistoryStateWithPreviousNextUrl(null, requestPreviousNextUrl),\n \"\",\n destinationPath,\n );\n\n currentHref = destinationPath;\n // URL already written above; the commit effect must not push/replace again.\n currentHistoryMode = undefined;\n currentPrevNextUrl = requestPreviousNextUrl;\n redirectCount += 1;\n continue;\n }\n\n // navParams falls back to {} on a missing or malformed header.\n const navParams: Record<string, string | string[]> =\n parseEncodedJsonHeader<Record<string, string | string[]>>(\n navResponse.headers.get(VINEXT_PARAMS_HEADER),\n ) ?? {};\n // Build snapshot from local params, not latestClientParams\n const navigationSnapshot = createClientNavigationRenderSnapshot(currentHref, navParams);\n\n // Tee the response body so React can consume it incrementally —\n // shell parses fast, and any Suspense boundary inside (e.g. the\n // route's loading.tsx) shows its fallback while the rest of the\n // RSC stream resolves. Buffering with `await response.arrayBuffer()`\n // here would block the commit until the page's slowest server\n // promise resolved, hiding the loading state entirely.\n //\n // The cache branch is read in the background so the visited-\n // response snapshot lands as soon as the full stream completes,\n // without holding up React's commit.\n const navBody = navResponse.body;\n if (!navBody) {\n // Already validated above (`!navResponse.body` triggers a hard\n // navigation), so this branch is unreachable — kept for type\n // narrowing only.\n return;\n }\n const [reactBranch, cacheBranch] = navBody.tee();\n const reactResponse = new Response(reactBranch, {\n status: navResponse.status,\n headers: navResponse.headers,\n });\n const cacheBufferPromise = new Response(cacheBranch).arrayBuffer();\n\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n\n const rscPayload = decodeAppElementsPromise(\n createFromFetch<AppWireElements>(Promise.resolve(reactResponse)),\n );\n\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n\n const renderOutcome = await renderNavigationPayload(\n rscPayload,\n navigationSnapshot,\n currentHref,\n navId,\n currentHistoryMode,\n navParams,\n requestPreviousNextUrl,\n pendingRouterState,\n toActionType(navigationKind),\n toOperationLane(navigationKind),\n );\n if (renderOutcome !== \"committed\") return;\n // Don't cache the response if this navigation was superseded during\n // renderNavigationPayload's await — the elements were never dispatched.\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n // Store the visited response only after renderNavigationPayload succeeds.\n // If we stored it before and renderNavigationPayload threw, a future\n // back/forward navigation could replay a snapshot from a navigation that\n // never actually rendered successfully.\n const resolvedElements = await rscPayload;\n const metadata = AppElementsWire.readMetadata(resolvedElements);\n const cacheBuffer = await cacheBufferPromise;\n storeVisitedResponseSnapshot(\n rscUrl,\n resolveVisitedResponseInterceptionContext(\n requestInterceptionContext,\n metadata.interceptionContext,\n ),\n {\n buffer: cacheBuffer,\n contentType: navResponse.headers.get(\"content-type\") ?? \"text/x-component\",\n mountedSlotsHeader: navResponse.headers.get(VINEXT_MOUNTED_SLOTS_HEADER),\n paramsHeader: navResponse.headers.get(VINEXT_PARAMS_HEADER),\n url: navResponse.url,\n },\n navParams,\n );\n return;\n }\n } catch (error) {\n // Don't hard-navigate to a stale URL if this navigation was superseded by\n // a newer one — the newer navigation is already in flight and would be clobbered.\n if (!browserNavigationController.isCurrentNavigation(navId)) return;\n // Suppress the diagnostic when the page is unloading: a hard-nav or anchor\n // click tears down the document and aborts any in-flight RSC fetch, which\n // surfaces here as an error. The page is already going away, so the log\n // is just noise. Mirrors Next.js' isPageUnloading pattern.\n if (!isPageUnloading) {\n console.error(\"[vinext] RSC navigation error:\", error);\n }\n window.location.href = currentHref;\n } finally {\n // Single settlement site: covers normal return, early returns on stale-id\n // checks, and error paths. The finally runs even when the catch returns.\n // settlePendingBrowserRouterState is idempotent via the settled flag.\n browserNavigationController.finalizeNavigation(navId, pendingRouterState);\n }\n };\n\n if (\"scrollRestoration\" in history) {\n history.scrollRestoration = \"manual\";\n }\n\n // Note: This popstate handler runs for App Router (RSC navigation available).\n // It coordinates scroll restoration with the pending RSC navigation.\n // Pages Router scroll restoration is handled in shims/navigation.ts:1289 with\n // microtask-based deferral for compatibility with non-RSC navigation.\n // See: https://github.com/vercel/next.js/discussions/41934#discussioncomment-4602607\n window.addEventListener(\"popstate\", (event) => {\n notifyAppRouterTransitionStart(window.location.href, \"traverse\");\n const pendingNavigation =\n window.__VINEXT_RSC_NAVIGATE__?.(window.location.href, 0, \"traverse\") ?? Promise.resolve();\n window.__VINEXT_RSC_PENDING__ = pendingNavigation;\n void pendingNavigation.finally(() => {\n restorePopstateScrollPosition(event.state);\n if (window.__VINEXT_RSC_PENDING__ === pendingNavigation) {\n window.__VINEXT_RSC_PENDING__ = null;\n }\n });\n });\n\n if (import.meta.hot) {\n const handleRscUpdate = async (): Promise<void> => {\n try {\n // If BrowserRoot has been mounted before but isn't now, a render\n // error tore down the tree (e.g. a server route threw). HMR can't\n // dispatch into a missing setter, and waitForBrowserRouterStateReady\n // would block forever — the tree won't remount until the page reloads.\n // Trigger that reload so the user's fix actually lands without a\n // manual refresh. Cleared after a successful mount, so this only\n // fires once per teardown.\n if (\n browserRouterStateHasEverCommitted &&\n !browserNavigationController.hasBrowserRouterState()\n ) {\n window.location.reload();\n return;\n }\n // HMR can also fire before BrowserRoot's layout effect publishes\n // the browser router state (e.g. saving a file while the initial RSC\n // stream is still suspended). Wait for readiness, then re-check the\n // mounted state — readiness can race with cleanup, which nulls it again.\n // Skip silently when the tree is not currently mounted; the next\n // HMR push or full reload will reconcile.\n await waitForBrowserRouterStateReady();\n if (!browserNavigationController.hasBrowserRouterState()) {\n return;\n }\n clearClientNavigationCaches();\n const navigationSnapshot = createClientNavigationRenderSnapshot(\n window.location.href,\n latestClientParams,\n );\n // Clear stale errors from the dev overlay before dispatching the\n // fresh tree. If the new tree renders cleanly, the overlay stays\n // empty; if it throws again, devOnCaughtError/devOnUncaughtError\n // re-populates it. Without this, an old \"DropZone is not defined\"\n // error would linger after the developer fixed the bug.\n dismissOverlay();\n // Interception context on HMR re-renders is intentionally deferred:\n // preserving intercepted modal state across HMR reloads is out of scope\n // for the previousNextUrl mechanism.\n const hmrHeaders = createRscRequestHeaders();\n await browserNavigationController.hmrReplaceTree(\n decodeAppElementsPromise(\n createFromFetch<AppWireElements>(\n fetch(\n await createRscRequestUrl(\n window.location.pathname + window.location.search,\n hmrHeaders,\n ),\n { headers: hmrHeaders },\n ),\n ),\n ),\n navigationSnapshot,\n );\n } catch (error) {\n console.error(\"[vinext] RSC HMR error:\", error);\n }\n };\n\n import.meta.hot.on(\"rsc:update\", () => {\n void handleRscUpdate();\n });\n }\n}\n\nif (typeof document !== \"undefined\") {\n // Install `window.next` as early as possible so any client component that\n // synchronously dereferences it during hydration (or any third-party\n // library script tag that loads before the React tree mounts) sees the\n // expected shape. Mirrors Next.js's app-bootstrap.ts (line 13) which sets\n // `window.next = { version, appDir: true }` before the React runtime\n // initializes, and `app-router-instance.ts` (line 510) which assigns\n // `router: publicAppRouterInstance` at module load.\n installWindowNext({ appDir: true, router: appRouterInstance });\n\n window.addEventListener(\"pagehide\", () => {\n isPageUnloading = true;\n });\n // Reset on pageshow so a bfcache-restored document does not resume with\n // the flag stuck at true, which would silently swallow every subsequent\n // RSC navigation error for the lifetime of that tab. Matches Next.js'\n // fetch-server-response.ts handler pair.\n window.addEventListener(\"pageshow\", () => {\n isPageUnlo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,IAAI,GAAG,oBAAoB;GACrC,iBAAsB;IACtB;;;AAIN,IAAI,OAAO,aAAa,aAAa;CAQnC,kBAAkB;EAAE,QAAQ;EAAM,QAAQ;EAAmB,CAAC;CAE9D,OAAO,iBAAiB,kBAAkB;EACxC,kBAAkB;GAClB;CAKF,OAAO,iBAAiB,kBAAkB;EACxC,kBAAkB;GAClB;CACF,MAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-browser-error.js","names":[],"sources":["../../src/server/app-browser-error.ts"],"sourcesContent":["// Build the onUncaughtError handler for hydrateRoot. When a render error\n// tears down the tree without an error boundary catching, the\n// NavigationCommitSignal layout effect never runs, so the URL update for\n// the in-flight navigation is lost — the user sees a blank page on the\n// previous URL. Hard-navigate to the intended target so the server can\n// render its actual error UI for that route. getRecoveryHref reads the\n// in-flight navigation target and returns null when nothing is pending\n// (e.g. an error during initial hydration).\n//\n// This is the *prod* handler. The dev variant lives in dev-error-overlay.tsx\n// alongside the rest of the dev-only overlay code so the entire overlay\n// module — including its React component tree, createRoot import, and inline\n// CSS — is structurally unreachable in production builds.\nexport function createOnUncaughtError(\n getRecoveryHref: () => string | null,\n): (error: unknown, errorInfo: { componentStack?: string }) => void {\n return (error, errorInfo) => {\n console.error(error);\n if (errorInfo?.componentStack) {\n console.error(\"The above error occurred in a React component:\\n\" + errorInfo.componentStack);\n }\n const recoveryHref = getRecoveryHref();\n if (recoveryHref !== null) {\n window.location.assign(recoveryHref);\n }\n };\n}\n"],"mappings":";AAaA,SAAgB,sBACd,iBACkE;
|
|
1
|
+
{"version":3,"file":"app-browser-error.js","names":[],"sources":["../../src/server/app-browser-error.ts"],"sourcesContent":["// Build the onUncaughtError handler for hydrateRoot. When a render error\n// tears down the tree without an error boundary catching, the\n// NavigationCommitSignal layout effect never runs, so the URL update for\n// the in-flight navigation is lost — the user sees a blank page on the\n// previous URL. Hard-navigate to the intended target so the server can\n// render its actual error UI for that route. getRecoveryHref reads the\n// in-flight navigation target and returns null when nothing is pending\n// (e.g. an error during initial hydration).\n//\n// This is the *prod* handler. The dev variant lives in dev-error-overlay.tsx\n// alongside the rest of the dev-only overlay code so the entire overlay\n// module — including its React component tree, createRoot import, and inline\n// CSS — is structurally unreachable in production builds.\nexport function createOnUncaughtError(\n getRecoveryHref: () => string | null,\n): (error: unknown, errorInfo: { componentStack?: string }) => void {\n return (error, errorInfo) => {\n console.error(error);\n if (errorInfo?.componentStack) {\n console.error(\"The above error occurred in a React component:\\n\" + errorInfo.componentStack);\n }\n const recoveryHref = getRecoveryHref();\n if (recoveryHref !== null) {\n window.location.assign(recoveryHref);\n }\n };\n}\n"],"mappings":";AAaA,SAAgB,sBACd,iBACkE;CAClE,QAAQ,OAAO,cAAc;EAC3B,QAAQ,MAAM,MAAM;EACpB,IAAI,WAAW,gBACb,QAAQ,MAAM,qDAAqD,UAAU,eAAe;EAE9F,MAAM,eAAe,iBAAiB;EACtC,IAAI,iBAAiB,MACnB,OAAO,SAAS,OAAO,aAAa"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactFormState, hydrateRoot } from "react-dom/client";
|
|
2
|
+
|
|
3
|
+
//#region src/server/app-browser-hydration.d.ts
|
|
4
|
+
type HydrateRootOptions = NonNullable<Parameters<typeof hydrateRoot>[2]>;
|
|
5
|
+
type HydrateRootCaughtErrorHandler = NonNullable<HydrateRootOptions["onCaughtError"]>;
|
|
6
|
+
type HydrateRootUncaughtErrorHandler = NonNullable<HydrateRootOptions["onUncaughtError"]>;
|
|
7
|
+
declare const RSC_FORM_STATE_GLOBAL = "__VINEXT_RSC_FORM_STATE__";
|
|
8
|
+
type FormStateGlobal = {
|
|
9
|
+
[RSC_FORM_STATE_GLOBAL]?: ReactFormState;
|
|
10
|
+
};
|
|
11
|
+
declare function consumeInitialFormState(global: FormStateGlobal): ReactFormState | null;
|
|
12
|
+
declare function createVinextHydrateRootOptions(options: {
|
|
13
|
+
formState: ReactFormState | null;
|
|
14
|
+
onCaughtError?: HydrateRootCaughtErrorHandler;
|
|
15
|
+
onUncaughtError: HydrateRootUncaughtErrorHandler;
|
|
16
|
+
}): HydrateRootOptions;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { RSC_FORM_STATE_GLOBAL, consumeInitialFormState, createVinextHydrateRootOptions };
|
|
19
|
+
//# sourceMappingURL=app-browser-hydration.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/server/app-browser-hydration.ts
|
|
2
|
+
const RSC_FORM_STATE_GLOBAL = "__VINEXT_RSC_FORM_STATE__";
|
|
3
|
+
function consumeInitialFormState(global) {
|
|
4
|
+
const formState = global["__VINEXT_RSC_FORM_STATE__"] ?? null;
|
|
5
|
+
delete global[RSC_FORM_STATE_GLOBAL];
|
|
6
|
+
return formState;
|
|
7
|
+
}
|
|
8
|
+
function createVinextHydrateRootOptions(options) {
|
|
9
|
+
const hydrateOptions = {
|
|
10
|
+
formState: options.formState,
|
|
11
|
+
onUncaughtError: options.onUncaughtError
|
|
12
|
+
};
|
|
13
|
+
if (options.onCaughtError) return {
|
|
14
|
+
...hydrateOptions,
|
|
15
|
+
onCaughtError: options.onCaughtError
|
|
16
|
+
};
|
|
17
|
+
return hydrateOptions;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { RSC_FORM_STATE_GLOBAL, consumeInitialFormState, createVinextHydrateRootOptions };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=app-browser-hydration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-browser-hydration.js","names":[],"sources":["../../src/server/app-browser-hydration.ts"],"sourcesContent":["import type { hydrateRoot, ReactFormState } from \"react-dom/client\";\n\ntype HydrateRootOptions = NonNullable<Parameters<typeof hydrateRoot>[2]>;\ntype HydrateRootCaughtErrorHandler = NonNullable<HydrateRootOptions[\"onCaughtError\"]>;\ntype HydrateRootUncaughtErrorHandler = NonNullable<HydrateRootOptions[\"onUncaughtError\"]>;\n\nexport const RSC_FORM_STATE_GLOBAL = \"__VINEXT_RSC_FORM_STATE__\";\n\ntype FormStateGlobal = {\n [RSC_FORM_STATE_GLOBAL]?: ReactFormState;\n};\n\nexport function consumeInitialFormState(global: FormStateGlobal): ReactFormState | null {\n const formState = global[RSC_FORM_STATE_GLOBAL] ?? null;\n delete global[RSC_FORM_STATE_GLOBAL];\n return formState;\n}\n\nexport function createVinextHydrateRootOptions(options: {\n formState: ReactFormState | null;\n onCaughtError?: HydrateRootCaughtErrorHandler;\n onUncaughtError: HydrateRootUncaughtErrorHandler;\n}): HydrateRootOptions {\n const hydrateOptions = {\n formState: options.formState,\n onUncaughtError: options.onUncaughtError,\n };\n\n if (options.onCaughtError) {\n return {\n ...hydrateOptions,\n onCaughtError: options.onCaughtError,\n };\n }\n\n return hydrateOptions;\n}\n"],"mappings":";AAMA,MAAa,wBAAwB;AAMrC,SAAgB,wBAAwB,QAAgD;CACtF,MAAM,YAAY,OAAA,gCAAiC;CACnD,OAAO,OAAO;CACd,OAAO;;AAGT,SAAgB,+BAA+B,SAIxB;CACrB,MAAM,iBAAiB;EACrB,WAAW,QAAQ;EACnB,iBAAiB,QAAQ;EAC1B;CAED,IAAI,QAAQ,eACV,OAAO;EACL,GAAG;EACH,eAAe,QAAQ;EACxB;CAGH,OAAO"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ClientNavigationRenderSnapshot, commitClientNavigationState } from "../shims/navigation.js";
|
|
2
2
|
import { AppElements } from "./app-elements-wire.js";
|
|
3
|
-
import {
|
|
3
|
+
import { OperationLane } from "./navigation-planner.js";
|
|
4
|
+
import { AppRouterState } from "./app-browser-state.js";
|
|
4
5
|
import { Dispatch, ReactNode } from "react";
|
|
5
6
|
|
|
6
7
|
//#region src/server/app-browser-navigation-controller.d.ts
|
|
@@ -11,6 +12,7 @@ type PendingBrowserRouterState = {
|
|
|
11
12
|
settled: boolean;
|
|
12
13
|
};
|
|
13
14
|
type NavigationPayloadOutcome = "committed" | "no-commit" | "hard-navigate";
|
|
15
|
+
type HardNavigationMode = "assign" | "replace";
|
|
14
16
|
type BrowserNavigationCommitEffectFactory = (options: {
|
|
15
17
|
href: string;
|
|
16
18
|
historyUpdateMode: HistoryUpdateMode | undefined;
|
|
@@ -23,6 +25,7 @@ type BrowserRouterStateRef = {
|
|
|
23
25
|
};
|
|
24
26
|
type BrowserNavigationControllerDeps = {
|
|
25
27
|
commitClientNavigationState?: typeof commitClientNavigationState;
|
|
28
|
+
performHardNavigation?: (href: string, mode?: HardNavigationMode) => boolean;
|
|
26
29
|
};
|
|
27
30
|
type BrowserNavigationController = {
|
|
28
31
|
beginNavigation(): number;
|
|
@@ -45,7 +48,6 @@ type BrowserNavigationController = {
|
|
|
45
48
|
previousNextUrl: string | null;
|
|
46
49
|
targetHref: string;
|
|
47
50
|
navId: number;
|
|
48
|
-
useTransition?: boolean;
|
|
49
51
|
}): Promise<NavigationPayloadOutcome>;
|
|
50
52
|
commitSameUrlNavigatePayload(nextElements: Promise<AppElements>, navigationSnapshot: ClientNavigationRenderSnapshot, returnValue?: {
|
|
51
53
|
ok: boolean;
|
|
@@ -69,7 +71,8 @@ type BrowserNavigationController = {
|
|
|
69
71
|
children?: ReactNode;
|
|
70
72
|
}): ReactNode;
|
|
71
73
|
};
|
|
74
|
+
declare function clearHardNavigationLoopGuard(): void;
|
|
72
75
|
declare function createAppBrowserNavigationController(deps?: BrowserNavigationControllerDeps): BrowserNavigationController;
|
|
73
76
|
//#endregion
|
|
74
|
-
export { HistoryUpdateMode, NavigationPayloadOutcome, PendingBrowserRouterState, createAppBrowserNavigationController };
|
|
77
|
+
export { HistoryUpdateMode, NavigationPayloadOutcome, PendingBrowserRouterState, clearHardNavigationLoopGuard, createAppBrowserNavigationController };
|
|
75
78
|
//# sourceMappingURL=app-browser-navigation-controller.d.ts.map
|
|
@@ -3,8 +3,53 @@ import { createPendingNavigationCommit } from "./app-browser-state.js";
|
|
|
3
3
|
import { applyApprovedVisibleCommit, approveHmrVisibleCommit, approvePendingNavigationCommit, resolveAndClassifyNavigationCommit } from "./app-browser-visible-commit.js";
|
|
4
4
|
import { startTransition, useLayoutEffect } from "react";
|
|
5
5
|
//#region src/server/app-browser-navigation-controller.ts
|
|
6
|
+
const HARD_NAVIGATION_LOOP_GUARD_KEY = "__vinext_hard_navigation_target__";
|
|
7
|
+
function normalizeBrowserHref(href) {
|
|
8
|
+
try {
|
|
9
|
+
return new URL(href, window.location.href).href;
|
|
10
|
+
} catch {
|
|
11
|
+
return href;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function readHardNavigationLoopGuard() {
|
|
15
|
+
try {
|
|
16
|
+
return window.sessionStorage.getItem(HARD_NAVIGATION_LOOP_GUARD_KEY);
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function writeHardNavigationLoopGuard(targetHref) {
|
|
22
|
+
try {
|
|
23
|
+
window.sessionStorage.setItem(HARD_NAVIGATION_LOOP_GUARD_KEY, targetHref);
|
|
24
|
+
return window.sessionStorage.getItem(HARD_NAVIGATION_LOOP_GUARD_KEY) === targetHref;
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function clearHardNavigationLoopGuard() {
|
|
30
|
+
try {
|
|
31
|
+
window.sessionStorage.removeItem(HARD_NAVIGATION_LOOP_GUARD_KEY);
|
|
32
|
+
} catch {}
|
|
33
|
+
}
|
|
34
|
+
function performHardNavigationWithLoopGuard(href, mode = "assign") {
|
|
35
|
+
const targetHref = normalizeBrowserHref(href);
|
|
36
|
+
const currentHref = normalizeBrowserHref(window.location.href);
|
|
37
|
+
if (readHardNavigationLoopGuard() === targetHref && currentHref === targetHref) {
|
|
38
|
+
clearHardNavigationLoopGuard();
|
|
39
|
+
console.error(`[vinext] Prevented repeated hard navigation to ${targetHref}; leaving the current document in place to avoid a reload loop.`);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (!writeHardNavigationLoopGuard(targetHref) && currentHref === targetHref) {
|
|
43
|
+
console.error(`[vinext] Hard navigation to ${targetHref} requires a reload-loop guard, but sessionStorage is unavailable; leaving the current document in place.`);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (mode === "replace") window.location.replace(href);
|
|
47
|
+
else window.location.assign(href);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
6
50
|
function createAppBrowserNavigationController(deps = {}) {
|
|
7
51
|
const commitClientNavigationStateImpl = deps.commitClientNavigationState ?? commitClientNavigationState;
|
|
52
|
+
const performHardNavigation = deps.performHardNavigation ?? performHardNavigationWithLoopGuard;
|
|
8
53
|
let nextNavigationRenderId = 0;
|
|
9
54
|
let activeNavigationId = 0;
|
|
10
55
|
const pendingNavigationCommits = /* @__PURE__ */ new Map();
|
|
@@ -134,7 +179,7 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
134
179
|
type: "replace"
|
|
135
180
|
});
|
|
136
181
|
if (!hasBrowserRouterState()) return;
|
|
137
|
-
|
|
182
|
+
dispatchSynchronousVisibleCommit(approveHmrVisibleCommit(pending));
|
|
138
183
|
}
|
|
139
184
|
function NavigationCommitSignal({ renderId, children }) {
|
|
140
185
|
useLayoutEffect(() => {
|
|
@@ -149,17 +194,18 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
149
194
|
}, [renderId]);
|
|
150
195
|
return children;
|
|
151
196
|
}
|
|
152
|
-
function dispatchApprovedVisibleCommit(commit, pendingRouterState
|
|
197
|
+
function dispatchApprovedVisibleCommit(commit, pendingRouterState) {
|
|
153
198
|
const setter = getBrowserRouterStateSetter();
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
199
|
+
if (pendingRouterState) {
|
|
200
|
+
resolvePendingBrowserRouterState(pendingRouterState, commit);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
startTransition(() => {
|
|
159
204
|
setter(applyApprovedVisibleCommit(getBrowserRouterState(), commit));
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function dispatchSynchronousVisibleCommit(commit) {
|
|
208
|
+
getBrowserRouterStateSetter()(applyApprovedVisibleCommit(getBrowserRouterState(), commit));
|
|
163
209
|
}
|
|
164
210
|
async function renderNavigationPayload(options) {
|
|
165
211
|
const renderId = allocateRenderId();
|
|
@@ -183,7 +229,8 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
183
229
|
activeNavigationId,
|
|
184
230
|
currentState: getBrowserRouterState(),
|
|
185
231
|
pending,
|
|
186
|
-
startedNavigationId: options.navId
|
|
232
|
+
startedNavigationId: options.navId,
|
|
233
|
+
targetHref: options.targetHref
|
|
187
234
|
});
|
|
188
235
|
if (approval.decision.disposition === "no-commit") {
|
|
189
236
|
settlePendingBrowserRouterState(options.pendingRouterState);
|
|
@@ -194,8 +241,7 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
194
241
|
if (approval.decision.disposition === "hard-navigate") {
|
|
195
242
|
settlePendingBrowserRouterState(options.pendingRouterState);
|
|
196
243
|
pendingNavigationCommits.delete(renderId);
|
|
197
|
-
|
|
198
|
-
return "hard-navigate";
|
|
244
|
+
return performHardNavigation(options.targetHref) ? "hard-navigate" : "no-commit";
|
|
199
245
|
}
|
|
200
246
|
const approvedCommit = approval.approvedCommit;
|
|
201
247
|
if (approvedCommit === null) throw new Error("[vinext] Commit decision did not approve a visible commit");
|
|
@@ -208,7 +254,7 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
208
254
|
}));
|
|
209
255
|
activateNavigationSnapshot();
|
|
210
256
|
snapshotActivated = true;
|
|
211
|
-
dispatchApprovedVisibleCommit(approvedCommit, options.pendingRouterState
|
|
257
|
+
dispatchApprovedVisibleCommit(approvedCommit, options.pendingRouterState);
|
|
212
258
|
} catch (error) {
|
|
213
259
|
pendingNavigationPrePaintEffects.delete(renderId);
|
|
214
260
|
pendingNavigationCommits.delete(renderId);
|
|
@@ -232,10 +278,11 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
232
278
|
renderId: allocateRenderId(),
|
|
233
279
|
operationLane: "server-action",
|
|
234
280
|
startedNavigationId,
|
|
281
|
+
targetHref: window.location.href,
|
|
235
282
|
type: "navigate"
|
|
236
283
|
});
|
|
237
284
|
if (decision.disposition === "hard-navigate") {
|
|
238
|
-
|
|
285
|
+
performHardNavigation(window.location.href);
|
|
239
286
|
return;
|
|
240
287
|
}
|
|
241
288
|
if (approvedCommit) {
|
|
@@ -243,13 +290,14 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
243
290
|
activeNavigationId,
|
|
244
291
|
currentState: getBrowserRouterState(),
|
|
245
292
|
pending,
|
|
246
|
-
startedNavigationId
|
|
293
|
+
startedNavigationId,
|
|
294
|
+
targetHref: window.location.href
|
|
247
295
|
});
|
|
248
296
|
if (latestApproval.decision.disposition === "hard-navigate") {
|
|
249
|
-
|
|
297
|
+
performHardNavigation(window.location.href);
|
|
250
298
|
return;
|
|
251
299
|
}
|
|
252
|
-
if (latestApproval.approvedCommit)
|
|
300
|
+
if (latestApproval.approvedCommit) dispatchSynchronousVisibleCommit(latestApproval.approvedCommit);
|
|
253
301
|
}
|
|
254
302
|
if (returnValue) {
|
|
255
303
|
if (!returnValue.ok) throw returnValue.data;
|
|
@@ -285,6 +333,6 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
285
333
|
};
|
|
286
334
|
}
|
|
287
335
|
//#endregion
|
|
288
|
-
export { createAppBrowserNavigationController };
|
|
336
|
+
export { clearHardNavigationLoopGuard, createAppBrowserNavigationController };
|
|
289
337
|
|
|
290
338
|
//# sourceMappingURL=app-browser-navigation-controller.js.map
|