@rangojs/router 0.0.0-experimental.f2d1a2f1 → 0.0.0-experimental.f4a8e8de
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/AGENTS.md +8 -4
- package/README.md +318 -821
- package/dist/bin/rango.js +925 -271
- package/dist/testing/vitest.js +82 -0
- package/dist/types/__internal.d.ts +127 -0
- package/dist/types/bin/rango.d.ts +1 -0
- package/dist/types/browser/action-coordinator.d.ts +57 -0
- package/dist/types/browser/action-fence.d.ts +33 -0
- package/dist/types/browser/app-shell.d.ts +34 -0
- package/dist/types/browser/app-version.d.ts +6 -0
- package/dist/types/browser/connection-warmup.d.ts +31 -0
- package/dist/types/browser/cookie-name.d.ts +66 -0
- package/dist/types/browser/dev-discovery.d.ts +11 -0
- package/dist/types/browser/event-controller.d.ts +231 -0
- package/dist/types/browser/history-state.d.ts +26 -0
- package/dist/types/browser/index.d.ts +1 -0
- package/dist/types/browser/intercept-utils.d.ts +30 -0
- package/dist/types/browser/invalidate-client-cache.d.ts +17 -0
- package/dist/types/browser/link-interceptor.d.ts +53 -0
- package/dist/types/browser/logging.d.ts +33 -0
- package/dist/types/browser/merge-segment-loaders.d.ts +38 -0
- package/dist/types/browser/navigation-bridge.d.ts +39 -0
- package/dist/types/browser/navigation-client.d.ts +17 -0
- package/dist/types/browser/navigation-store-handle.d.ts +25 -0
- package/dist/types/browser/navigation-store.d.ts +85 -0
- package/dist/types/browser/navigation-transaction.d.ts +75 -0
- package/dist/types/browser/network-error-handler.d.ts +35 -0
- package/dist/types/browser/notify-listeners.d.ts +2 -0
- package/dist/types/browser/partial-update.d.ts +61 -0
- package/dist/types/browser/prefetch/cache.d.ts +224 -0
- package/dist/types/browser/prefetch/default-strategy.d.ts +31 -0
- package/dist/types/browser/prefetch/fetch.d.ts +52 -0
- package/dist/types/browser/prefetch/invalidation.d.ts +6 -0
- package/dist/types/browser/prefetch/loader.d.ts +12 -0
- package/dist/types/browser/prefetch/observer.d.ts +24 -0
- package/dist/types/browser/prefetch/policy.d.ts +13 -0
- package/dist/types/browser/prefetch/queue.d.ts +48 -0
- package/dist/types/browser/prefetch/resource-ready.d.ts +28 -0
- package/dist/types/browser/prefetch/runtime.d.ts +2 -0
- package/dist/types/browser/rango-state.d.ts +56 -0
- package/dist/types/browser/react/Link.d.ts +132 -0
- package/dist/types/browser/react/NavigationProvider.d.ts +88 -0
- package/dist/types/browser/react/ScrollRestoration.d.ts +78 -0
- package/dist/types/browser/react/context.d.ts +57 -0
- package/dist/types/browser/react/filter-segment-order.d.ts +35 -0
- package/dist/types/browser/react/index.d.ts +1 -0
- package/dist/types/browser/react/location-state-shared.d.ts +162 -0
- package/dist/types/browser/react/location-state.d.ts +29 -0
- package/dist/types/browser/react/mount-context.d.ts +23 -0
- package/dist/types/browser/react/nonce-context.d.ts +14 -0
- package/dist/types/browser/react/shallow-equal.d.ts +5 -0
- package/dist/types/browser/react/use-action.d.ts +61 -0
- package/dist/types/browser/react/use-handle.d.ts +21 -0
- package/dist/types/browser/react/use-href.d.ts +32 -0
- package/dist/types/browser/react/use-link-status.d.ts +36 -0
- package/dist/types/browser/react/use-mount.d.ts +24 -0
- package/dist/types/browser/react/use-navigation.d.ts +15 -0
- package/dist/types/browser/react/use-params.d.ts +21 -0
- package/dist/types/browser/react/use-pathname.d.ts +13 -0
- package/dist/types/browser/react/use-reverse.d.ts +40 -0
- package/dist/types/browser/react/use-router.d.ts +23 -0
- package/dist/types/browser/react/use-search-params.d.ts +19 -0
- package/dist/types/browser/react/use-segments.d.ts +29 -0
- package/dist/types/browser/response-adapter.d.ts +58 -0
- package/dist/types/browser/rsc-router.d.ts +146 -0
- package/dist/types/browser/scroll-restoration.d.ts +103 -0
- package/dist/types/browser/segment-reconciler.d.ts +74 -0
- package/dist/types/browser/segment-structure-assert.d.ts +16 -0
- package/dist/types/browser/server-action-bridge.d.ts +29 -0
- package/dist/types/browser/types.d.ts +546 -0
- package/dist/types/browser/validate-redirect-origin.d.ts +28 -0
- package/dist/types/build/collect-fallback-refs.d.ts +5 -0
- package/dist/types/build/generate-manifest.d.ts +106 -0
- package/dist/types/build/generate-route-types.d.ts +8 -0
- package/dist/types/build/index.d.ts +21 -0
- package/dist/types/build/merge-full-manifests.d.ts +3 -0
- package/dist/types/build/prefix-tree-utils.d.ts +56 -0
- package/dist/types/build/route-trie.d.ts +20 -0
- package/dist/types/build/route-types/ast-helpers.d.ts +3 -0
- package/dist/types/build/route-types/ast-route-extraction.d.ts +13 -0
- package/dist/types/build/route-types/codegen.d.ts +16 -0
- package/dist/types/build/route-types/include-resolution.d.ts +74 -0
- package/dist/types/build/route-types/param-extraction.d.ts +13 -0
- package/dist/types/build/route-types/per-module-writer.d.ts +20 -0
- package/dist/types/build/route-types/router-processing.d.ts +81 -0
- package/dist/types/build/route-types/scan-filter.d.ts +17 -0
- package/dist/types/build/route-types/source-scan.d.ts +13 -0
- package/dist/types/build/runtime-discovery.d.ts +24 -0
- package/dist/types/cache/background-task.d.ts +21 -0
- package/dist/types/cache/cache-error.d.ts +71 -0
- package/dist/types/cache/cache-exec-scope.d.ts +31 -0
- package/dist/types/cache/cache-key-utils.d.ts +43 -0
- package/dist/types/cache/cache-policy.d.ts +59 -0
- package/dist/types/cache/cache-runtime.d.ts +51 -0
- package/dist/types/cache/cache-scope.d.ts +215 -0
- package/dist/types/cache/cache-tag.d.ts +79 -0
- package/dist/types/cache/cf/cf-base64.d.ts +4 -0
- package/dist/types/cache/cf/cf-cache-constants.d.ts +112 -0
- package/dist/types/cache/cf/cf-cache-store.d.ts +616 -0
- package/dist/types/cache/cf/cf-cache-types.d.ts +365 -0
- package/dist/types/cache/cf/cf-kv-utils.d.ts +43 -0
- package/dist/types/cache/cf/cf-tag-marker-memo.d.ts +15 -0
- package/dist/types/cache/cf/cf-zone-purge.d.ts +31 -0
- package/dist/types/cache/cf/index.d.ts +4 -0
- package/dist/types/cache/document-cache.d.ts +71 -0
- package/dist/types/cache/handle-capture.d.ts +23 -0
- package/dist/types/cache/handle-snapshot.d.ts +39 -0
- package/dist/types/cache/index.d.ts +9 -0
- package/dist/types/cache/memory-segment-store.d.ts +163 -0
- package/dist/types/cache/profile-registry.d.ts +40 -0
- package/dist/types/cache/read-through-swr.d.ts +61 -0
- package/dist/types/cache/search-params-filter.d.ts +64 -0
- package/dist/types/cache/segment-codec.d.ts +78 -0
- package/dist/types/cache/shell-snapshot.d.ts +186 -0
- package/dist/types/cache/tag-invalidation.d.ts +74 -0
- package/dist/types/cache/taint.d.ts +77 -0
- package/dist/types/cache/types.d.ts +503 -0
- package/dist/types/cache/vercel/index.d.ts +1 -0
- package/dist/types/cache/vercel/vercel-cache-store.d.ts +268 -0
- package/dist/types/client-urls/client-root.d.ts +38 -0
- package/dist/types/client-urls/client-urls.d.ts +5 -0
- package/dist/types/client-urls/navigation.d.ts +38 -0
- package/dist/types/client-urls/revalidation-protocol.d.ts +25 -0
- package/dist/types/client-urls/server-projection.d.ts +57 -0
- package/dist/types/client-urls/types.d.ts +132 -0
- package/dist/types/client.d.ts +191 -0
- package/dist/types/client.rsc.d.ts +41 -0
- package/dist/types/cloudflare/index.d.ts +7 -0
- package/dist/types/cloudflare/tracing.d.ts +57 -0
- package/dist/types/component-utils.d.ts +46 -0
- package/dist/types/components/DefaultDocument.d.ts +13 -0
- package/dist/types/context-var.d.ts +84 -0
- package/dist/types/debug.d.ts +57 -0
- package/dist/types/decode-loader-results.d.ts +42 -0
- package/dist/types/default-error-boundary.d.ts +10 -0
- package/dist/types/defer.d.ts +89 -0
- package/dist/types/deps/browser.d.ts +1 -0
- package/dist/types/deps/html-stream-client.d.ts +1 -0
- package/dist/types/deps/html-stream-server.d.ts +1 -0
- package/dist/types/deps/rsc.d.ts +1 -0
- package/dist/types/deps/ssr.d.ts +1 -0
- package/dist/types/dev-discovery-protocol.d.ts +5 -0
- package/dist/types/encode-kv.d.ts +35 -0
- package/dist/types/errors.d.ts +227 -0
- package/dist/types/escape-script.d.ts +44 -0
- package/dist/types/handle.d.ts +93 -0
- package/dist/types/handles/MetaTags.d.ts +17 -0
- package/dist/types/handles/Scripts.d.ts +38 -0
- package/dist/types/handles/breadcrumbs.d.ts +43 -0
- package/dist/types/handles/deferred-resolution.d.ts +53 -0
- package/dist/types/handles/is-thenable.d.ts +10 -0
- package/dist/types/handles/meta.d.ts +43 -0
- package/dist/types/handles/script.d.ts +139 -0
- package/dist/types/host/cookie-handler.d.ts +8 -0
- package/dist/types/host/errors.d.ts +40 -0
- package/dist/types/host/index.d.ts +33 -0
- package/dist/types/host/pattern-matcher.d.ts +30 -0
- package/dist/types/host/router.d.ts +12 -0
- package/dist/types/host/testing.d.ts +41 -0
- package/dist/types/host/types.d.ts +148 -0
- package/dist/types/host/utils.d.ts +20 -0
- package/dist/types/href-client.d.ts +214 -0
- package/dist/types/index.d.ts +113 -0
- package/dist/types/index.rsc.d.ts +52 -0
- package/dist/types/internal-debug.d.ts +1 -0
- package/dist/types/loader-redirect.d.ts +18 -0
- package/dist/types/loader-store.d.ts +193 -0
- package/dist/types/loader.d.ts +18 -0
- package/dist/types/loader.rsc.d.ts +18 -0
- package/dist/types/missing-id-error.d.ts +1 -0
- package/dist/types/outlet-context.d.ts +24 -0
- package/dist/types/outlet-provider.d.ts +14 -0
- package/dist/types/prerender/build-shell-capture.d.ts +104 -0
- package/dist/types/prerender/param-hash.d.ts +6 -0
- package/dist/types/prerender/shell-manifest-key.d.ts +18 -0
- package/dist/types/prerender/store.d.ts +63 -0
- package/dist/types/prerender.d.ts +292 -0
- package/dist/types/redirect-origin.d.ts +67 -0
- package/dist/types/regex-escape.d.ts +6 -0
- package/dist/types/render-error-thrower.d.ts +13 -0
- package/dist/types/response-utils.d.ts +35 -0
- package/dist/types/reverse.d.ts +206 -0
- package/dist/types/root-error-boundary.d.ts +32 -0
- package/dist/types/route-content-wrapper.d.ts +81 -0
- package/dist/types/route-definition/dsl-helpers.d.ts +130 -0
- package/dist/types/route-definition/helper-factories.d.ts +22 -0
- package/dist/types/route-definition/helpers-types.d.ts +393 -0
- package/dist/types/route-definition/index.d.ts +7 -0
- package/dist/types/route-definition/redirect.d.ts +48 -0
- package/dist/types/route-definition/resolve-handler-use.d.ts +19 -0
- package/dist/types/route-definition/use-item-types.d.ts +1 -0
- package/dist/types/route-definition.d.ts +1 -0
- package/dist/types/route-map-builder.d.ts +102 -0
- package/dist/types/route-name.d.ts +27 -0
- package/dist/types/route-types.d.ts +172 -0
- package/dist/types/router/basename.d.ts +10 -0
- package/dist/types/router/content-negotiation.d.ts +91 -0
- package/dist/types/router/debug-manifest.d.ts +7 -0
- package/dist/types/router/error-handling.d.ts +110 -0
- package/dist/types/router/find-match.d.ts +19 -0
- package/dist/types/router/handler-context.d.ts +41 -0
- package/dist/types/router/instrument.d.ts +191 -0
- package/dist/types/router/intercept-resolution.d.ts +91 -0
- package/dist/types/router/lazy-includes.d.ts +26 -0
- package/dist/types/router/loader-resolution.d.ts +85 -0
- package/dist/types/router/logging.d.ts +41 -0
- package/dist/types/router/manifest.d.ts +8 -0
- package/dist/types/router/match-api.d.ts +19 -0
- package/dist/types/router/match-context.d.ts +184 -0
- package/dist/types/router/match-handlers.d.ts +48 -0
- package/dist/types/router/match-middleware/background-revalidation.d.ts +113 -0
- package/dist/types/router/match-middleware/cache-lookup.d.ts +126 -0
- package/dist/types/router/match-middleware/cache-store.d.ts +112 -0
- package/dist/types/router/match-middleware/index.d.ts +80 -0
- package/dist/types/router/match-middleware/intercept-resolution.d.ts +116 -0
- package/dist/types/router/match-middleware/segment-resolution.d.ts +94 -0
- package/dist/types/router/match-pipelines.d.ts +103 -0
- package/dist/types/router/match-result.d.ts +114 -0
- package/dist/types/router/metrics.d.ts +6 -0
- package/dist/types/router/middleware-types.d.ts +74 -0
- package/dist/types/router/middleware.d.ts +116 -0
- package/dist/types/router/navigation-snapshot.d.ts +51 -0
- package/dist/types/router/params-util.d.ts +8 -0
- package/dist/types/router/parse-pattern.d.ts +38 -0
- package/dist/types/router/pattern-matching.d.ts +169 -0
- package/dist/types/router/prefetch-cache-ttl.d.ts +27 -0
- package/dist/types/router/prefetch-default.d.ts +28 -0
- package/dist/types/router/prefetch-limits.d.ts +20 -0
- package/dist/types/router/prerender-match.d.ts +53 -0
- package/dist/types/router/preview-match.d.ts +22 -0
- package/dist/types/router/request-classification.d.ts +104 -0
- package/dist/types/router/revalidation.d.ts +64 -0
- package/dist/types/router/route-snapshot.d.ts +112 -0
- package/dist/types/router/route-trie-builder.d.ts +77 -0
- package/dist/types/router/router-context.d.ts +137 -0
- package/dist/types/router/router-interfaces.d.ts +461 -0
- package/dist/types/router/router-options.d.ts +792 -0
- package/dist/types/router/router-registry.d.ts +15 -0
- package/dist/types/router/segment-resolution/fresh.d.ts +55 -0
- package/dist/types/router/segment-resolution/helpers.d.ts +93 -0
- package/dist/types/router/segment-resolution/loader-cache.d.ts +33 -0
- package/dist/types/router/segment-resolution/loader-mask.d.ts +44 -0
- package/dist/types/router/segment-resolution/loader-snapshot.d.ts +90 -0
- package/dist/types/router/segment-resolution/mask-nested.d.ts +53 -0
- package/dist/types/router/segment-resolution/revalidation.d.ts +85 -0
- package/dist/types/router/segment-resolution/static-store.d.ts +17 -0
- package/dist/types/router/segment-resolution/streamed-handler-telemetry.d.ts +16 -0
- package/dist/types/router/segment-resolution/view-transition-default.d.ts +27 -0
- package/dist/types/router/segment-resolution.d.ts +3 -0
- package/dist/types/router/segment-wrappers.d.ts +53 -0
- package/dist/types/router/state-cookie-name.d.ts +1 -0
- package/dist/types/router/substitute-pattern-params.d.ts +23 -0
- package/dist/types/router/telemetry-otel.d.ts +113 -0
- package/dist/types/router/telemetry.d.ts +216 -0
- package/dist/types/router/timeout.d.ts +107 -0
- package/dist/types/router/tracing.d.ts +139 -0
- package/dist/types/router/transition-when.d.ts +13 -0
- package/dist/types/router/trie-matching.d.ts +32 -0
- package/dist/types/router/types.d.ts +98 -0
- package/dist/types/router/url-params.d.ts +26 -0
- package/dist/types/router.d.ts +7 -0
- package/dist/types/rsc/capture-queue.d.ts +49 -0
- package/dist/types/rsc/full-payload.d.ts +22 -0
- package/dist/types/rsc/handler-context.d.ts +32 -0
- package/dist/types/rsc/handler.d.ts +9 -0
- package/dist/types/rsc/helpers.d.ts +127 -0
- package/dist/types/rsc/index.d.ts +17 -0
- package/dist/types/rsc/json-route-result.d.ts +20 -0
- package/dist/types/rsc/loader-fetch.d.ts +14 -0
- package/dist/types/rsc/manifest-init.d.ts +18 -0
- package/dist/types/rsc/nonce.d.ts +28 -0
- package/dist/types/rsc/origin-guard.d.ts +50 -0
- package/dist/types/rsc/progressive-enhancement.d.ts +19 -0
- package/dist/types/rsc/redirect-guard.d.ts +37 -0
- package/dist/types/rsc/render-pipeline.d.ts +148 -0
- package/dist/types/rsc/response-cache-serve.d.ts +46 -0
- package/dist/types/rsc/response-error.d.ts +19 -0
- package/dist/types/rsc/response-route-handler.d.ts +29 -0
- package/dist/types/rsc/routine-plan.d.ts +124 -0
- package/dist/types/rsc/rsc-rendering.d.ts +18 -0
- package/dist/types/rsc/runtime-warnings.d.ts +22 -0
- package/dist/types/rsc/server-action.d.ts +68 -0
- package/dist/types/rsc/shell-build-manifest.d.ts +90 -0
- package/dist/types/rsc/shell-capture-constants.d.ts +44 -0
- package/dist/types/rsc/shell-capture.d.ts +406 -0
- package/dist/types/rsc/shell-serve.d.ts +189 -0
- package/dist/types/rsc/ssr-setup.d.ts +73 -0
- package/dist/types/rsc/stream-idle.d.ts +60 -0
- package/dist/types/rsc/transition-gate.d.ts +23 -0
- package/dist/types/rsc/types.d.ts +328 -0
- package/dist/types/runtime-env.d.ts +1 -0
- package/dist/types/search-params.d.ts +125 -0
- package/dist/types/segment-content-promise.d.ts +13 -0
- package/dist/types/segment-fragments.d.ts +79 -0
- package/dist/types/segment-loader-promise.d.ts +22 -0
- package/dist/types/segment-system.d.ts +86 -0
- package/dist/types/serialize.d.ts +164 -0
- package/dist/types/server/context.d.ts +510 -0
- package/dist/types/server/cookie-parse.d.ts +10 -0
- package/dist/types/server/cookie-store.d.ts +107 -0
- package/dist/types/server/fetchable-loader-store.d.ts +20 -0
- package/dist/types/server/handle-store.d.ts +131 -0
- package/dist/types/server/loader-registry.d.ts +32 -0
- package/dist/types/server/request-context.d.ts +707 -0
- package/dist/types/server/root-layout.d.ts +3 -0
- package/dist/types/server.d.ts +16 -0
- package/dist/types/ssr/index.d.ts +233 -0
- package/dist/types/ssr/inject-rsc-eager.d.ts +3 -0
- package/dist/types/ssr/preinit-client-references.d.ts +71 -0
- package/dist/types/ssr/ssr-root.d.ts +69 -0
- package/dist/types/static-handler.d.ts +71 -0
- package/dist/types/testing/cache-status.d.ts +63 -0
- package/dist/types/testing/collect-handle.d.ts +20 -0
- package/dist/types/testing/dispatch.d.ts +127 -0
- package/dist/types/testing/dom.entry.d.ts +15 -0
- package/dist/types/testing/e2e/fixture.d.ts +37 -0
- package/dist/types/testing/e2e/index.d.ts +31 -0
- package/dist/types/testing/e2e/matchers.d.ts +17 -0
- package/dist/types/testing/e2e/page-helpers.d.ts +86 -0
- package/dist/types/testing/e2e/parity.d.ts +111 -0
- package/dist/types/testing/e2e/server.d.ts +35 -0
- package/dist/types/testing/flight-matchers.d.ts +55 -0
- package/dist/types/testing/flight-normalize.d.ts +1 -0
- package/dist/types/testing/flight-tree.d.ts +192 -0
- package/dist/types/testing/flight.d.ts +115 -0
- package/dist/types/testing/flight.entry.d.ts +27 -0
- package/dist/types/testing/generated-routes.d.ts +66 -0
- package/dist/types/testing/index.d.ts +54 -0
- package/dist/types/testing/internal/context.d.ts +225 -0
- package/dist/types/testing/internal/flight-client-globals.d.ts +1 -0
- package/dist/types/testing/internal/seed-vars.d.ts +30 -0
- package/dist/types/testing/render-handler.d.ts +160 -0
- package/dist/types/testing/render-route.d.ts +265 -0
- package/dist/types/testing/run-loader.d.ts +195 -0
- package/dist/types/testing/run-middleware.d.ts +132 -0
- package/dist/types/testing/run-transition-when.d.ts +78 -0
- package/dist/types/testing/shell-status.d.ts +81 -0
- package/dist/types/testing/vitest-stubs/cloudflare-email.d.ts +6 -0
- package/dist/types/testing/vitest-stubs/cloudflare-workers.d.ts +13 -0
- package/dist/types/testing/vitest-stubs/plugin-rsc.d.ts +7 -0
- package/dist/types/testing/vitest-stubs/version.d.ts +1 -0
- package/dist/types/testing/vitest.d.ts +205 -0
- package/dist/types/theme/ThemeProvider.d.ts +13 -0
- package/dist/types/theme/ThemeScript.d.ts +45 -0
- package/dist/types/theme/constants.d.ts +39 -0
- package/dist/types/theme/index.d.ts +29 -0
- package/dist/types/theme/theme-context.d.ts +21 -0
- package/dist/types/theme/theme-script.d.ts +26 -0
- package/dist/types/theme/types.d.ts +162 -0
- package/dist/types/theme/use-theme.d.ts +8 -0
- package/dist/types/types/boundaries.d.ts +110 -0
- package/dist/types/types/cache-types.d.ts +191 -0
- package/dist/types/types/error-types.d.ts +114 -0
- package/dist/types/types/global-namespace.d.ts +90 -0
- package/dist/types/types/handler-context.d.ts +658 -0
- package/dist/types/types/index.d.ts +11 -0
- package/dist/types/types/loader-types.d.ts +208 -0
- package/dist/types/types/request-scope.d.ts +93 -0
- package/dist/types/types/route-config.d.ts +105 -0
- package/dist/types/types/route-entry.d.ts +98 -0
- package/dist/types/types/segments.d.ts +246 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/urls/include-helper.d.ts +17 -0
- package/dist/types/urls/include-provider.d.ts +27 -0
- package/dist/types/urls/index.d.ts +6 -0
- package/dist/types/urls/path-helper-types.d.ts +198 -0
- package/dist/types/urls/path-helper.d.ts +12 -0
- package/dist/types/urls/pattern-types.d.ts +166 -0
- package/dist/types/urls/response-types.d.ts +67 -0
- package/dist/types/urls/type-extraction.d.ts +157 -0
- package/dist/types/urls/urls-function.d.ts +24 -0
- package/dist/types/urls.d.ts +1 -0
- package/dist/types/use-loader.d.ts +150 -0
- package/dist/types/vercel/index.d.ts +10 -0
- package/dist/types/vercel/tracing.d.ts +71 -0
- package/dist/types/vite/debug.d.ts +80 -0
- package/dist/types/vite/discovery/bundle-postprocess.d.ts +12 -0
- package/dist/types/vite/discovery/client-urls-projection.d.ts +53 -0
- package/dist/types/vite/discovery/dev-prerender-cache.d.ts +65 -0
- package/dist/types/vite/discovery/discover-routers.d.ts +17 -0
- package/dist/types/vite/discovery/discovery-errors.d.ts +113 -0
- package/dist/types/vite/discovery/gate-state.d.ts +79 -0
- package/dist/types/vite/discovery/prerender-collection.d.ts +24 -0
- package/dist/types/vite/discovery/route-types-writer.d.ts +32 -0
- package/dist/types/vite/discovery/self-gen-tracking.d.ts +22 -0
- package/dist/types/vite/discovery/shell-prerender-phase.d.ts +40 -0
- package/dist/types/vite/discovery/state.d.ts +170 -0
- package/dist/types/vite/discovery/virtual-module-codegen.d.ts +15 -0
- package/dist/types/vite/encryption-key.d.ts +2 -0
- package/dist/types/vite/index.d.ts +11 -0
- package/dist/types/vite/inject-client-debug.d.ts +56 -0
- package/dist/types/vite/plugin-types.d.ts +298 -0
- package/dist/types/vite/plugins/cjs-to-esm.d.ts +6 -0
- package/dist/types/vite/plugins/client-ref-dedup.d.ts +40 -0
- package/dist/types/vite/plugins/client-ref-hashing.d.ts +35 -0
- package/dist/types/vite/plugins/cloudflare-protocol-stub.d.ts +64 -0
- package/dist/types/vite/plugins/expose-action-id.d.ts +18 -0
- package/dist/types/vite/plugins/expose-id-utils.d.ts +37 -0
- package/dist/types/vite/plugins/expose-ids/export-analysis.d.ts +19 -0
- package/dist/types/vite/plugins/expose-ids/handler-transform.d.ts +10 -0
- package/dist/types/vite/plugins/expose-ids/loader-transform.d.ts +8 -0
- package/dist/types/vite/plugins/expose-ids/router-transform.d.ts +13 -0
- package/dist/types/vite/plugins/expose-ids/types.d.ts +29 -0
- package/dist/types/vite/plugins/expose-internal-ids.d.ts +16 -0
- package/dist/types/vite/plugins/performance-tracks.d.ts +25 -0
- package/dist/types/vite/plugins/refresh-cmd.d.ts +20 -0
- package/dist/types/vite/plugins/server-ref-hashing.d.ts +24 -0
- package/dist/types/vite/plugins/server-reference-pattern.d.ts +1 -0
- package/dist/types/vite/plugins/use-cache-transform.d.ts +20 -0
- package/dist/types/vite/plugins/vercel-output.d.ts +85 -0
- package/dist/types/vite/plugins/version-injector.d.ts +21 -0
- package/dist/types/vite/plugins/version-plugin.d.ts +19 -0
- package/dist/types/vite/plugins/virtual-entries.d.ts +36 -0
- package/dist/types/vite/plugins/virtual-stub-plugin.d.ts +7 -0
- package/dist/types/vite/rango.d.ts +29 -0
- package/dist/types/vite/router-discovery.d.ts +23 -0
- package/dist/types/vite/utils/ast-handler-extract.d.ts +64 -0
- package/dist/types/vite/utils/banner.d.ts +2 -0
- package/dist/types/vite/utils/bundle-analysis.d.ts +28 -0
- package/dist/types/vite/utils/client-chunks.d.ts +55 -0
- package/dist/types/vite/utils/directive-prologue.d.ts +16 -0
- package/dist/types/vite/utils/forward-user-plugins.d.ts +37 -0
- package/dist/types/vite/utils/manifest-utils.d.ts +7 -0
- package/dist/types/vite/utils/package-resolution.d.ts +6 -0
- package/dist/types/vite/utils/prerender-utils.d.ts +32 -0
- package/dist/types/vite/utils/shared-utils.d.ts +67 -0
- package/dist/types.backup/__internal.d.ts +127 -0
- package/dist/types.backup/bin/rango.d.ts +1 -0
- package/dist/types.backup/browser/action-coordinator.d.ts +57 -0
- package/dist/types.backup/browser/action-fence.d.ts +33 -0
- package/dist/types.backup/browser/app-shell.d.ts +34 -0
- package/dist/types.backup/browser/app-version.d.ts +6 -0
- package/dist/types.backup/browser/connection-warmup.d.ts +31 -0
- package/dist/types.backup/browser/cookie-name.d.ts +66 -0
- package/dist/types.backup/browser/event-controller.d.ts +221 -0
- package/dist/types.backup/browser/history-state.d.ts +26 -0
- package/dist/types.backup/browser/index.d.ts +1 -0
- package/dist/types.backup/browser/intercept-utils.d.ts +30 -0
- package/dist/types.backup/browser/invalidate-client-cache.d.ts +17 -0
- package/dist/types.backup/browser/link-interceptor.d.ts +43 -0
- package/dist/types.backup/browser/logging.d.ts +33 -0
- package/dist/types.backup/browser/merge-segment-loaders.d.ts +38 -0
- package/dist/types.backup/browser/navigation-bridge.d.ts +27 -0
- package/dist/types.backup/browser/navigation-client.d.ts +17 -0
- package/dist/types.backup/browser/navigation-store-handle.d.ts +25 -0
- package/dist/types.backup/browser/navigation-store.d.ts +95 -0
- package/dist/types.backup/browser/navigation-transaction.d.ts +75 -0
- package/dist/types.backup/browser/network-error-handler.d.ts +35 -0
- package/dist/types.backup/browser/partial-update.d.ts +61 -0
- package/dist/types.backup/browser/prefetch/cache.d.ts +183 -0
- package/dist/types.backup/browser/prefetch/fetch.d.ts +52 -0
- package/dist/types.backup/browser/prefetch/observer.d.ts +27 -0
- package/dist/types.backup/browser/prefetch/policy.d.ts +13 -0
- package/dist/types.backup/browser/prefetch/queue.d.ts +48 -0
- package/dist/types.backup/browser/prefetch/resource-ready.d.ts +28 -0
- package/dist/types.backup/browser/rango-state.d.ts +52 -0
- package/dist/types.backup/browser/react/Link.d.ts +140 -0
- package/dist/types.backup/browser/react/NavigationProvider.d.ts +88 -0
- package/dist/types.backup/browser/react/ScrollRestoration.d.ts +78 -0
- package/dist/types.backup/browser/react/context.d.ts +54 -0
- package/dist/types.backup/browser/react/filter-segment-order.d.ts +35 -0
- package/dist/types.backup/browser/react/index.d.ts +1 -0
- package/dist/types.backup/browser/react/location-state-shared.d.ts +162 -0
- package/dist/types.backup/browser/react/location-state.d.ts +29 -0
- package/dist/types.backup/browser/react/mount-context.d.ts +23 -0
- package/dist/types.backup/browser/react/nonce-context.d.ts +14 -0
- package/dist/types.backup/browser/react/shallow-equal.d.ts +5 -0
- package/dist/types.backup/browser/react/use-action.d.ts +61 -0
- package/dist/types.backup/browser/react/use-handle.d.ts +21 -0
- package/dist/types.backup/browser/react/use-href.d.ts +32 -0
- package/dist/types.backup/browser/react/use-link-status.d.ts +36 -0
- package/dist/types.backup/browser/react/use-mount.d.ts +24 -0
- package/dist/types.backup/browser/react/use-navigation.d.ts +15 -0
- package/dist/types.backup/browser/react/use-params.d.ts +21 -0
- package/dist/types.backup/browser/react/use-pathname.d.ts +13 -0
- package/dist/types.backup/browser/react/use-reverse.d.ts +40 -0
- package/dist/types.backup/browser/react/use-router.d.ts +23 -0
- package/dist/types.backup/browser/react/use-search-params.d.ts +19 -0
- package/dist/types.backup/browser/react/use-segments.d.ts +29 -0
- package/dist/types.backup/browser/response-adapter.d.ts +58 -0
- package/dist/types.backup/browser/rsc-router.d.ts +141 -0
- package/dist/types.backup/browser/scroll-restoration.d.ts +103 -0
- package/dist/types.backup/browser/segment-reconciler.d.ts +74 -0
- package/dist/types.backup/browser/segment-structure-assert.d.ts +16 -0
- package/dist/types.backup/browser/server-action-bridge.d.ts +29 -0
- package/dist/types.backup/browser/types.d.ts +530 -0
- package/dist/types.backup/browser/validate-redirect-origin.d.ts +28 -0
- package/dist/types.backup/build/collect-fallback-refs.d.ts +5 -0
- package/dist/types.backup/build/generate-manifest.d.ts +100 -0
- package/dist/types.backup/build/generate-route-types.d.ts +8 -0
- package/dist/types.backup/build/index.d.ts +21 -0
- package/dist/types.backup/build/prefix-tree-utils.d.ts +56 -0
- package/dist/types.backup/build/route-trie.d.ts +89 -0
- package/dist/types.backup/build/route-types/ast-helpers.d.ts +3 -0
- package/dist/types.backup/build/route-types/ast-route-extraction.d.ts +13 -0
- package/dist/types.backup/build/route-types/codegen.d.ts +16 -0
- package/dist/types.backup/build/route-types/include-resolution.d.ts +74 -0
- package/dist/types.backup/build/route-types/param-extraction.d.ts +13 -0
- package/dist/types.backup/build/route-types/per-module-writer.d.ts +18 -0
- package/dist/types.backup/build/route-types/router-processing.d.ts +82 -0
- package/dist/types.backup/build/route-types/scan-filter.d.ts +17 -0
- package/dist/types.backup/build/route-types/source-scan.d.ts +13 -0
- package/dist/types.backup/build/runtime-discovery.d.ts +24 -0
- package/dist/types.backup/cache/background-task.d.ts +21 -0
- package/dist/types.backup/cache/cache-error.d.ts +71 -0
- package/dist/types.backup/cache/cache-key-utils.d.ts +35 -0
- package/dist/types.backup/cache/cache-policy.d.ts +59 -0
- package/dist/types.backup/cache/cache-runtime.d.ts +51 -0
- package/dist/types.backup/cache/cache-scope.d.ts +134 -0
- package/dist/types.backup/cache/cache-tag.d.ts +79 -0
- package/dist/types.backup/cache/cf/cf-base64.d.ts +4 -0
- package/dist/types.backup/cache/cf/cf-cache-constants.d.ts +105 -0
- package/dist/types.backup/cache/cf/cf-cache-store.d.ts +481 -0
- package/dist/types.backup/cache/cf/cf-cache-types.d.ts +300 -0
- package/dist/types.backup/cache/cf/cf-kv-utils.d.ts +22 -0
- package/dist/types.backup/cache/cf/cf-tag-marker-memo.d.ts +15 -0
- package/dist/types.backup/cache/cf/index.d.ts +3 -0
- package/dist/types.backup/cache/document-cache.d.ts +69 -0
- package/dist/types.backup/cache/handle-capture.d.ts +23 -0
- package/dist/types.backup/cache/handle-snapshot.d.ts +39 -0
- package/dist/types.backup/cache/index.d.ts +7 -0
- package/dist/types.backup/cache/memory-segment-store.d.ts +163 -0
- package/dist/types.backup/cache/profile-registry.d.ts +40 -0
- package/dist/types.backup/cache/read-through-swr.d.ts +60 -0
- package/dist/types.backup/cache/segment-codec.d.ts +78 -0
- package/dist/types.backup/cache/shell-snapshot.d.ts +162 -0
- package/dist/types.backup/cache/tag-invalidation.d.ts +74 -0
- package/dist/types.backup/cache/taint.d.ts +71 -0
- package/dist/types.backup/cache/types.d.ts +407 -0
- package/dist/types.backup/cache/vercel/index.d.ts +1 -0
- package/dist/types.backup/cache/vercel/vercel-cache-store.d.ts +267 -0
- package/dist/types.backup/client.d.ts +184 -0
- package/dist/types.backup/client.rsc.d.ts +39 -0
- package/dist/types.backup/cloudflare/index.d.ts +7 -0
- package/dist/types.backup/cloudflare/tracing.d.ts +53 -0
- package/dist/types.backup/component-utils.d.ts +46 -0
- package/dist/types.backup/components/DefaultDocument.d.ts +13 -0
- package/dist/types.backup/context-var.d.ts +84 -0
- package/dist/types.backup/debug.d.ts +57 -0
- package/dist/types.backup/decode-loader-results.d.ts +5 -0
- package/dist/types.backup/default-error-boundary.d.ts +10 -0
- package/dist/types.backup/defer.d.ts +89 -0
- package/dist/types.backup/deps/browser.d.ts +1 -0
- package/dist/types.backup/deps/html-stream-client.d.ts +1 -0
- package/dist/types.backup/deps/html-stream-server.d.ts +1 -0
- package/dist/types.backup/deps/rsc.d.ts +1 -0
- package/dist/types.backup/deps/ssr.d.ts +1 -0
- package/dist/types.backup/encode-kv.d.ts +35 -0
- package/dist/types.backup/errors.d.ts +226 -0
- package/dist/types.backup/escape-script.d.ts +44 -0
- package/dist/types.backup/handle.d.ts +93 -0
- package/dist/types.backup/handles/MetaTags.d.ts +17 -0
- package/dist/types.backup/handles/Scripts.d.ts +38 -0
- package/dist/types.backup/handles/breadcrumbs.d.ts +43 -0
- package/dist/types.backup/handles/deferred-resolution.d.ts +53 -0
- package/dist/types.backup/handles/is-thenable.d.ts +12 -0
- package/dist/types.backup/handles/meta.d.ts +43 -0
- package/dist/types.backup/handles/script.d.ts +139 -0
- package/dist/types.backup/host/cookie-handler.d.ts +8 -0
- package/dist/types.backup/host/errors.d.ts +40 -0
- package/dist/types.backup/host/index.d.ts +33 -0
- package/dist/types.backup/host/pattern-matcher.d.ts +30 -0
- package/dist/types.backup/host/router.d.ts +12 -0
- package/dist/types.backup/host/testing.d.ts +41 -0
- package/dist/types.backup/host/types.d.ts +148 -0
- package/dist/types.backup/host/utils.d.ts +20 -0
- package/dist/types.backup/href-client.d.ts +214 -0
- package/dist/types.backup/index.d.ts +112 -0
- package/dist/types.backup/index.rsc.d.ts +51 -0
- package/dist/types.backup/internal-debug.d.ts +1 -0
- package/dist/types.backup/loader-store.d.ts +193 -0
- package/dist/types.backup/loader.d.ts +18 -0
- package/dist/types.backup/loader.rsc.d.ts +18 -0
- package/dist/types.backup/missing-id-error.d.ts +1 -0
- package/dist/types.backup/outlet-context.d.ts +12 -0
- package/dist/types.backup/outlet-provider.d.ts +12 -0
- package/dist/types.backup/prerender/build-shell-capture.d.ts +104 -0
- package/dist/types.backup/prerender/param-hash.d.ts +6 -0
- package/dist/types.backup/prerender/shell-manifest-key.d.ts +18 -0
- package/dist/types.backup/prerender/store.d.ts +62 -0
- package/dist/types.backup/prerender.d.ts +292 -0
- package/dist/types.backup/redirect-origin.d.ts +55 -0
- package/dist/types.backup/regex-escape.d.ts +6 -0
- package/dist/types.backup/render-error-thrower.d.ts +13 -0
- package/dist/types.backup/response-utils.d.ts +35 -0
- package/dist/types.backup/reverse.d.ts +206 -0
- package/dist/types.backup/root-error-boundary.d.ts +32 -0
- package/dist/types.backup/route-content-wrapper.d.ts +40 -0
- package/dist/types.backup/route-definition/dsl-helpers.d.ts +130 -0
- package/dist/types.backup/route-definition/helper-factories.d.ts +22 -0
- package/dist/types.backup/route-definition/helpers-types.d.ts +392 -0
- package/dist/types.backup/route-definition/index.d.ts +7 -0
- package/dist/types.backup/route-definition/redirect.d.ts +48 -0
- package/dist/types.backup/route-definition/resolve-handler-use.d.ts +19 -0
- package/dist/types.backup/route-definition/use-item-types.d.ts +1 -0
- package/dist/types.backup/route-definition.d.ts +1 -0
- package/dist/types.backup/route-map-builder.d.ts +127 -0
- package/dist/types.backup/route-name.d.ts +27 -0
- package/dist/types.backup/route-types.d.ts +172 -0
- package/dist/types.backup/router/basename.d.ts +10 -0
- package/dist/types.backup/router/content-negotiation.d.ts +91 -0
- package/dist/types.backup/router/debug-manifest.d.ts +7 -0
- package/dist/types.backup/router/error-handling.d.ts +76 -0
- package/dist/types.backup/router/find-match.d.ts +19 -0
- package/dist/types.backup/router/handler-context.d.ts +41 -0
- package/dist/types.backup/router/instrument.d.ts +161 -0
- package/dist/types.backup/router/intercept-resolution.d.ts +79 -0
- package/dist/types.backup/router/lazy-includes.d.ts +26 -0
- package/dist/types.backup/router/loader-resolution.d.ts +63 -0
- package/dist/types.backup/router/logging.d.ts +41 -0
- package/dist/types.backup/router/manifest.d.ts +8 -0
- package/dist/types.backup/router/match-api.d.ts +19 -0
- package/dist/types.backup/router/match-context.d.ts +184 -0
- package/dist/types.backup/router/match-handlers.d.ts +49 -0
- package/dist/types.backup/router/match-middleware/background-revalidation.d.ts +113 -0
- package/dist/types.backup/router/match-middleware/cache-lookup.d.ts +113 -0
- package/dist/types.backup/router/match-middleware/cache-store.d.ts +112 -0
- package/dist/types.backup/router/match-middleware/index.d.ts +80 -0
- package/dist/types.backup/router/match-middleware/intercept-resolution.d.ts +116 -0
- package/dist/types.backup/router/match-middleware/segment-resolution.d.ts +94 -0
- package/dist/types.backup/router/match-pipelines.d.ts +103 -0
- package/dist/types.backup/router/match-result.d.ts +114 -0
- package/dist/types.backup/router/metrics.d.ts +6 -0
- package/dist/types.backup/router/middleware-types.d.ts +74 -0
- package/dist/types.backup/router/middleware.d.ts +116 -0
- package/dist/types.backup/router/navigation-snapshot.d.ts +22 -0
- package/dist/types.backup/router/params-util.d.ts +8 -0
- package/dist/types.backup/router/parse-pattern.d.ts +38 -0
- package/dist/types.backup/router/pattern-matching.d.ts +169 -0
- package/dist/types.backup/router/prefetch-cache-ttl.d.ts +27 -0
- package/dist/types.backup/router/prefetch-limits.d.ts +20 -0
- package/dist/types.backup/router/prerender-match.d.ts +50 -0
- package/dist/types.backup/router/preview-match.d.ts +22 -0
- package/dist/types.backup/router/request-classification.d.ts +104 -0
- package/dist/types.backup/router/revalidation.d.ts +57 -0
- package/dist/types.backup/router/route-snapshot.d.ts +112 -0
- package/dist/types.backup/router/router-context.d.ts +137 -0
- package/dist/types.backup/router/router-interfaces.d.ts +432 -0
- package/dist/types.backup/router/router-options.d.ts +738 -0
- package/dist/types.backup/router/router-registry.d.ts +15 -0
- package/dist/types.backup/router/segment-resolution/fresh.d.ts +55 -0
- package/dist/types.backup/router/segment-resolution/helpers.d.ts +93 -0
- package/dist/types.backup/router/segment-resolution/loader-cache.d.ts +33 -0
- package/dist/types.backup/router/segment-resolution/loader-mask.d.ts +44 -0
- package/dist/types.backup/router/segment-resolution/loader-snapshot.d.ts +90 -0
- package/dist/types.backup/router/segment-resolution/mask-nested.d.ts +53 -0
- package/dist/types.backup/router/segment-resolution/revalidation.d.ts +85 -0
- package/dist/types.backup/router/segment-resolution/static-store.d.ts +17 -0
- package/dist/types.backup/router/segment-resolution/streamed-handler-telemetry.d.ts +16 -0
- package/dist/types.backup/router/segment-resolution/view-transition-default.d.ts +28 -0
- package/dist/types.backup/router/segment-resolution.d.ts +3 -0
- package/dist/types.backup/router/segment-wrappers.d.ts +53 -0
- package/dist/types.backup/router/state-cookie-name.d.ts +1 -0
- package/dist/types.backup/router/substitute-pattern-params.d.ts +23 -0
- package/dist/types.backup/router/telemetry-otel.d.ts +113 -0
- package/dist/types.backup/router/telemetry.d.ts +215 -0
- package/dist/types.backup/router/timeout.d.ts +68 -0
- package/dist/types.backup/router/tracing.d.ts +125 -0
- package/dist/types.backup/router/trie-matching.d.ts +32 -0
- package/dist/types.backup/router/types.d.ts +98 -0
- package/dist/types.backup/router/url-params.d.ts +26 -0
- package/dist/types.backup/router.d.ts +7 -0
- package/dist/types.backup/rsc/capture-queue.d.ts +6 -0
- package/dist/types.backup/rsc/full-payload.d.ts +22 -0
- package/dist/types.backup/rsc/handler-context.d.ts +31 -0
- package/dist/types.backup/rsc/handler.d.ts +9 -0
- package/dist/types.backup/rsc/helpers.d.ts +213 -0
- package/dist/types.backup/rsc/index.d.ts +17 -0
- package/dist/types.backup/rsc/json-route-result.d.ts +20 -0
- package/dist/types.backup/rsc/loader-fetch.d.ts +14 -0
- package/dist/types.backup/rsc/manifest-init.d.ts +18 -0
- package/dist/types.backup/rsc/nonce.d.ts +28 -0
- package/dist/types.backup/rsc/origin-guard.d.ts +50 -0
- package/dist/types.backup/rsc/progressive-enhancement.d.ts +19 -0
- package/dist/types.backup/rsc/redirect-guard.d.ts +35 -0
- package/dist/types.backup/rsc/response-cache-serve.d.ts +46 -0
- package/dist/types.backup/rsc/response-error.d.ts +19 -0
- package/dist/types.backup/rsc/response-route-handler.d.ts +29 -0
- package/dist/types.backup/rsc/rsc-rendering.d.ts +23 -0
- package/dist/types.backup/rsc/runtime-warnings.d.ts +22 -0
- package/dist/types.backup/rsc/server-action.d.ts +68 -0
- package/dist/types.backup/rsc/shell-build-manifest.d.ts +84 -0
- package/dist/types.backup/rsc/shell-capture-constants.d.ts +27 -0
- package/dist/types.backup/rsc/shell-capture.d.ts +374 -0
- package/dist/types.backup/rsc/shell-serve.d.ts +136 -0
- package/dist/types.backup/rsc/ssr-setup.d.ts +48 -0
- package/dist/types.backup/rsc/transition-gate.d.ts +27 -0
- package/dist/types.backup/rsc/types.d.ts +290 -0
- package/dist/types.backup/runtime-env.d.ts +1 -0
- package/dist/types.backup/search-params.d.ts +125 -0
- package/dist/types.backup/segment-content-promise.d.ts +13 -0
- package/dist/types.backup/segment-fragments.d.ts +56 -0
- package/dist/types.backup/segment-loader-promise.d.ts +22 -0
- package/dist/types.backup/segment-system.d.ts +84 -0
- package/dist/types.backup/serialize.d.ts +164 -0
- package/dist/types.backup/server/context.d.ts +494 -0
- package/dist/types.backup/server/cookie-parse.d.ts +10 -0
- package/dist/types.backup/server/cookie-store.d.ts +107 -0
- package/dist/types.backup/server/fetchable-loader-store.d.ts +20 -0
- package/dist/types.backup/server/handle-store.d.ts +100 -0
- package/dist/types.backup/server/loader-registry.d.ts +32 -0
- package/dist/types.backup/server/request-context.d.ts +596 -0
- package/dist/types.backup/server/root-layout.d.ts +3 -0
- package/dist/types.backup/server.d.ts +15 -0
- package/dist/types.backup/ssr/index.d.ts +233 -0
- package/dist/types.backup/ssr/inject-rsc-eager.d.ts +3 -0
- package/dist/types.backup/ssr/preinit-client-references.d.ts +71 -0
- package/dist/types.backup/ssr/ssr-root.d.ts +69 -0
- package/dist/types.backup/static-handler.d.ts +57 -0
- package/dist/types.backup/testing/cache-status.d.ts +63 -0
- package/dist/types.backup/testing/collect-handle.d.ts +20 -0
- package/dist/types.backup/testing/dispatch.d.ts +123 -0
- package/dist/types.backup/testing/dom.entry.d.ts +15 -0
- package/dist/types.backup/testing/e2e/fixture.d.ts +37 -0
- package/dist/types.backup/testing/e2e/index.d.ts +30 -0
- package/dist/types.backup/testing/e2e/matchers.d.ts +17 -0
- package/dist/types.backup/testing/e2e/page-helpers.d.ts +62 -0
- package/dist/types.backup/testing/e2e/parity.d.ts +111 -0
- package/dist/types.backup/testing/e2e/server.d.ts +35 -0
- package/dist/types.backup/testing/flight-matchers.d.ts +55 -0
- package/dist/types.backup/testing/flight-normalize.d.ts +1 -0
- package/dist/types.backup/testing/flight-tree.d.ts +192 -0
- package/dist/types.backup/testing/flight.d.ts +115 -0
- package/dist/types.backup/testing/flight.entry.d.ts +27 -0
- package/dist/types.backup/testing/generated-routes.d.ts +66 -0
- package/dist/types.backup/testing/index.d.ts +52 -0
- package/dist/types.backup/testing/internal/context.d.ts +225 -0
- package/dist/types.backup/testing/internal/flight-client-globals.d.ts +1 -0
- package/dist/types.backup/testing/internal/seed-vars.d.ts +30 -0
- package/dist/types.backup/testing/render-handler.d.ts +160 -0
- package/dist/types.backup/testing/render-route.d.ts +246 -0
- package/dist/types.backup/testing/run-loader.d.ts +186 -0
- package/dist/types.backup/testing/run-middleware.d.ts +132 -0
- package/dist/types.backup/testing/run-transition-when.d.ts +77 -0
- package/dist/types.backup/testing/vitest-stubs/cloudflare-email.d.ts +6 -0
- package/dist/types.backup/testing/vitest-stubs/cloudflare-workers.d.ts +13 -0
- package/dist/types.backup/testing/vitest-stubs/plugin-rsc.d.ts +7 -0
- package/dist/types.backup/testing/vitest-stubs/version.d.ts +1 -0
- package/dist/types.backup/testing/vitest.d.ts +205 -0
- package/dist/types.backup/theme/ThemeProvider.d.ts +13 -0
- package/dist/types.backup/theme/ThemeScript.d.ts +45 -0
- package/dist/types.backup/theme/constants.d.ts +39 -0
- package/dist/types.backup/theme/index.d.ts +29 -0
- package/dist/types.backup/theme/theme-context.d.ts +21 -0
- package/dist/types.backup/theme/theme-script.d.ts +26 -0
- package/dist/types.backup/theme/types.d.ts +162 -0
- package/dist/types.backup/theme/use-theme.d.ts +8 -0
- package/dist/types.backup/types/boundaries.d.ts +93 -0
- package/dist/types.backup/types/cache-types.d.ts +191 -0
- package/dist/types.backup/types/error-types.d.ts +114 -0
- package/dist/types.backup/types/global-namespace.d.ts +90 -0
- package/dist/types.backup/types/handler-context.d.ts +658 -0
- package/dist/types.backup/types/index.d.ts +11 -0
- package/dist/types.backup/types/loader-types.d.ts +182 -0
- package/dist/types.backup/types/request-scope.d.ts +93 -0
- package/dist/types.backup/types/route-config.d.ts +105 -0
- package/dist/types.backup/types/route-entry.d.ts +95 -0
- package/dist/types.backup/types/segments.d.ts +234 -0
- package/dist/types.backup/types.d.ts +1 -0
- package/dist/types.backup/urls/include-helper.d.ts +17 -0
- package/dist/types.backup/urls/include-provider.d.ts +27 -0
- package/dist/types.backup/urls/index.d.ts +6 -0
- package/dist/types.backup/urls/path-helper-types.d.ts +197 -0
- package/dist/types.backup/urls/path-helper.d.ts +12 -0
- package/dist/types.backup/urls/pattern-types.d.ts +166 -0
- package/dist/types.backup/urls/response-types.d.ts +67 -0
- package/dist/types.backup/urls/type-extraction.d.ts +157 -0
- package/dist/types.backup/urls/urls-function.d.ts +24 -0
- package/dist/types.backup/urls.d.ts +1 -0
- package/dist/types.backup/use-loader.d.ts +150 -0
- package/dist/types.backup/vercel/index.d.ts +10 -0
- package/dist/types.backup/vercel/tracing.d.ts +70 -0
- package/dist/types.backup/vite/debug.d.ts +80 -0
- package/dist/types.backup/vite/discovery/bundle-postprocess.d.ts +12 -0
- package/dist/types.backup/vite/discovery/dev-prerender-cache.d.ts +65 -0
- package/dist/types.backup/vite/discovery/discover-routers.d.ts +17 -0
- package/dist/types.backup/vite/discovery/discovery-errors.d.ts +113 -0
- package/dist/types.backup/vite/discovery/gate-state.d.ts +79 -0
- package/dist/types.backup/vite/discovery/prerender-collection.d.ts +24 -0
- package/dist/types.backup/vite/discovery/route-types-writer.d.ts +32 -0
- package/dist/types.backup/vite/discovery/self-gen-tracking.d.ts +22 -0
- package/dist/types.backup/vite/discovery/shell-prerender-phase.d.ts +40 -0
- package/dist/types.backup/vite/discovery/state.d.ts +162 -0
- package/dist/types.backup/vite/discovery/virtual-module-codegen.d.ts +15 -0
- package/dist/types.backup/vite/index.d.ts +11 -0
- package/dist/types.backup/vite/inject-client-debug.d.ts +56 -0
- package/dist/types.backup/vite/plugin-types.d.ts +298 -0
- package/dist/types.backup/vite/plugins/cjs-to-esm.d.ts +6 -0
- package/dist/types.backup/vite/plugins/client-ref-dedup.d.ts +40 -0
- package/dist/types.backup/vite/plugins/client-ref-hashing.d.ts +35 -0
- package/dist/types.backup/vite/plugins/cloudflare-protocol-stub.d.ts +64 -0
- package/dist/types.backup/vite/plugins/expose-action-id.d.ts +18 -0
- package/dist/types.backup/vite/plugins/expose-id-utils.d.ts +37 -0
- package/dist/types.backup/vite/plugins/expose-ids/export-analysis.d.ts +19 -0
- package/dist/types.backup/vite/plugins/expose-ids/handler-transform.d.ts +10 -0
- package/dist/types.backup/vite/plugins/expose-ids/loader-transform.d.ts +8 -0
- package/dist/types.backup/vite/plugins/expose-ids/router-transform.d.ts +13 -0
- package/dist/types.backup/vite/plugins/expose-ids/types.d.ts +29 -0
- package/dist/types.backup/vite/plugins/expose-internal-ids.d.ts +6 -0
- package/dist/types.backup/vite/plugins/performance-tracks.d.ts +25 -0
- package/dist/types.backup/vite/plugins/refresh-cmd.d.ts +20 -0
- package/dist/types.backup/vite/plugins/use-cache-transform.d.ts +20 -0
- package/dist/types.backup/vite/plugins/vercel-output.d.ts +85 -0
- package/dist/types.backup/vite/plugins/version-injector.d.ts +21 -0
- package/dist/types.backup/vite/plugins/version-plugin.d.ts +19 -0
- package/dist/types.backup/vite/plugins/virtual-entries.d.ts +36 -0
- package/dist/types.backup/vite/plugins/virtual-stub-plugin.d.ts +7 -0
- package/dist/types.backup/vite/rango.d.ts +29 -0
- package/dist/types.backup/vite/router-discovery.d.ts +23 -0
- package/dist/types.backup/vite/utils/ast-handler-extract.d.ts +64 -0
- package/dist/types.backup/vite/utils/banner.d.ts +2 -0
- package/dist/types.backup/vite/utils/bundle-analysis.d.ts +28 -0
- package/dist/types.backup/vite/utils/client-chunks.d.ts +55 -0
- package/dist/types.backup/vite/utils/directive-prologue.d.ts +16 -0
- package/dist/types.backup/vite/utils/forward-user-plugins.d.ts +37 -0
- package/dist/types.backup/vite/utils/manifest-utils.d.ts +7 -0
- package/dist/types.backup/vite/utils/package-resolution.d.ts +6 -0
- package/dist/types.backup/vite/utils/prerender-utils.d.ts +32 -0
- package/dist/types.backup/vite/utils/shared-utils.d.ts +55 -0
- package/dist/vite/index.js +9695 -3592
- package/package.json +119 -39
- package/skills/api-client/SKILL.md +211 -0
- package/skills/breadcrumbs/SKILL.md +82 -5
- package/skills/bundle-analysis/SKILL.md +159 -0
- package/skills/cache-guide/SKILL.md +232 -34
- package/skills/caching/SKILL.md +375 -19
- package/skills/catalog.json +283 -0
- package/skills/cloudflare/SKILL.md +151 -0
- package/skills/cloudflare/agents/openai.yaml +4 -0
- package/skills/cloudflare/references/d1-and-local-dev.md +131 -0
- package/skills/cloudflare/references/streaming-and-deploy.md +107 -0
- package/skills/cloudflare/references/webhooks-and-crypto.md +147 -0
- package/skills/comparison/SKILL.md +50 -0
- package/skills/comparison/agents/openai.yaml +4 -0
- package/skills/comparison/references/framework-comparison.md +844 -0
- package/skills/composability/SKILL.md +124 -4
- package/skills/css/SKILL.md +76 -0
- package/skills/debug-manifest/SKILL.md +5 -11
- package/skills/defer-hydration/SKILL.md +235 -0
- package/skills/deployment-caching/SKILL.md +176 -0
- package/skills/document-cache/SKILL.md +116 -58
- package/skills/fonts/SKILL.md +1 -1
- package/skills/handler-use/SKILL.md +12 -10
- package/skills/hooks/SKILL.md +73 -699
- package/skills/hooks/data.md +273 -0
- package/skills/hooks/handle-and-actions.md +103 -0
- package/skills/hooks/navigation.md +110 -0
- package/skills/hooks/outlets.md +62 -0
- package/skills/hooks/state.md +228 -0
- package/skills/hooks/urls.md +135 -0
- package/skills/host-router/SKILL.md +129 -27
- package/skills/i18n/SKILL.md +276 -0
- package/skills/intercept/SKILL.md +75 -19
- package/skills/layout/SKILL.md +40 -19
- package/skills/links/SKILL.md +211 -17
- package/skills/loader/SKILL.md +230 -25
- package/skills/middleware/SKILL.md +58 -13
- package/skills/migrate-nextjs/SKILL.md +267 -33
- package/skills/migrate-nextjs/backend-host-swap.md +120 -0
- package/skills/migrate-react-router/SKILL.md +59 -671
- package/skills/migrate-react-router/component-migration.md +196 -0
- package/skills/migrate-react-router/data-and-actions.md +225 -0
- package/skills/migrate-react-router/route-mapping.md +271 -0
- package/skills/mime-routes/SKILL.md +55 -18
- package/skills/observability/SKILL.md +231 -0
- package/skills/parallel/SKILL.md +50 -10
- package/skills/ppr/SKILL.md +904 -0
- package/skills/prerender/SKILL.md +130 -68
- package/skills/rango/SKILL.md +321 -26
- package/skills/react-compiler/SKILL.md +168 -0
- package/skills/response-routes/SKILL.md +172 -52
- package/skills/route/SKILL.md +123 -9
- package/skills/router-setup/SKILL.md +53 -9
- package/skills/scripts/SKILL.md +179 -0
- package/skills/server-actions/SKILL.md +776 -0
- package/skills/shell-manifest/SKILL.md +185 -0
- package/skills/streams-and-websockets/SKILL.md +1 -1
- package/skills/tailwind/SKILL.md +28 -4
- package/skills/testing/SKILL.md +131 -0
- package/skills/testing/bindings.md +103 -0
- package/skills/testing/cache-prerender.md +172 -0
- package/skills/testing/client-components.md +131 -0
- package/skills/testing/e2e-parity.md +125 -0
- package/skills/testing/flight.md +91 -0
- package/skills/testing/handles.md +131 -0
- package/skills/testing/loader.md +128 -0
- package/skills/testing/middleware.md +99 -0
- package/skills/testing/render-handler.md +122 -0
- package/skills/testing/response-routes.md +95 -0
- package/skills/testing/reverse-and-types.md +85 -0
- package/skills/testing/server-actions.md +107 -0
- package/skills/testing/server-tree.md +128 -0
- package/skills/testing/setup.md +123 -0
- package/skills/theme/SKILL.md +1 -1
- package/skills/typesafety/SKILL.md +45 -628
- package/skills/typesafety/env-and-bindings.md +254 -0
- package/skills/typesafety/generated-files-and-cli.md +342 -0
- package/skills/typesafety/params-and-search.md +153 -0
- package/skills/typesafety/route-types.md +213 -0
- package/skills/use-cache/SKILL.md +121 -15
- package/skills/vercel/SKILL.md +149 -0
- package/skills/view-transitions/SKILL.md +341 -0
- package/src/__augment-tests__/augment.ts +81 -0
- package/src/__augment-tests__/augmented.check.ts +116 -0
- package/src/__internal.ts +0 -65
- package/src/browser/action-coordinator.ts +53 -36
- package/src/browser/action-fence.ts +47 -0
- package/src/browser/app-shell.ts +14 -27
- package/src/browser/connection-warmup.ts +134 -0
- package/src/browser/cookie-name.ts +140 -0
- package/src/browser/dev-discovery.ts +66 -0
- package/src/browser/event-controller.ts +400 -168
- package/src/browser/history-state.ts +21 -0
- package/src/browser/index.ts +3 -3
- package/src/browser/invalidate-client-cache.ts +52 -0
- package/src/browser/link-interceptor.ts +469 -20
- package/src/browser/logging.ts +28 -0
- package/src/browser/merge-segment-loaders.ts +6 -4
- package/src/browser/navigation-bridge.ts +164 -69
- package/src/browser/navigation-client.ts +199 -96
- package/src/browser/navigation-store-handle.ts +38 -0
- package/src/browser/navigation-store.ts +165 -345
- package/src/browser/navigation-transaction.ts +9 -59
- package/src/browser/network-error-handler.ts +34 -7
- package/src/browser/notify-listeners.ts +22 -0
- package/src/browser/partial-update.ts +219 -163
- package/src/browser/prefetch/cache.ts +240 -97
- package/src/browser/prefetch/default-strategy.ts +74 -0
- package/src/browser/prefetch/fetch.ts +317 -51
- package/src/browser/prefetch/invalidation.ts +30 -0
- package/src/browser/prefetch/loader.ts +111 -0
- package/src/browser/prefetch/observer.ts +50 -22
- package/src/browser/prefetch/queue.ts +25 -7
- package/src/browser/prefetch/runtime.ts +6 -0
- package/src/browser/rango-state.ts +177 -114
- package/src/browser/react/Link.tsx +115 -75
- package/src/browser/react/NavigationProvider.tsx +194 -143
- package/src/browser/react/ScrollRestoration.tsx +10 -6
- package/src/browser/react/context.ts +4 -0
- package/src/browser/react/filter-segment-order.ts +66 -7
- package/src/browser/react/index.ts +0 -48
- package/src/browser/react/location-state-shared.ts +178 -8
- package/src/browser/react/location-state.ts +39 -14
- package/src/browser/react/use-action.ts +6 -15
- package/src/browser/react/use-handle.ts +17 -14
- package/src/browser/react/use-href.tsx +8 -1
- package/src/browser/react/use-link-status.ts +33 -8
- package/src/browser/react/use-navigation.ts +10 -5
- package/src/browser/react/use-params.ts +11 -11
- package/src/browser/react/use-reverse.ts +106 -0
- package/src/browser/react/use-router.ts +21 -6
- package/src/browser/react/use-search-params.ts +0 -5
- package/src/browser/react/use-segments.ts +11 -21
- package/src/browser/response-adapter.ts +99 -8
- package/src/browser/rsc-router.tsx +230 -42
- package/src/browser/scroll-restoration.ts +37 -22
- package/src/browser/segment-reconciler.ts +31 -21
- package/src/browser/segment-structure-assert.ts +2 -2
- package/src/browser/server-action-bridge.ts +262 -65
- package/src/browser/types.ts +132 -47
- package/src/browser/validate-redirect-origin.ts +43 -16
- package/src/build/collect-fallback-refs.ts +107 -0
- package/src/build/generate-manifest.ts +213 -184
- package/src/build/generate-route-types.ts +3 -1
- package/src/build/index.ts +11 -3
- package/src/build/merge-full-manifests.ts +161 -0
- package/src/build/prefix-tree-utils.ts +123 -0
- package/src/build/route-trie.ts +43 -280
- package/src/build/route-types/ast-route-extraction.ts +15 -8
- package/src/build/route-types/codegen.ts +16 -5
- package/src/build/route-types/include-resolution.ts +513 -64
- package/src/build/route-types/param-extraction.ts +6 -3
- package/src/build/route-types/per-module-writer.ts +33 -12
- package/src/build/route-types/router-processing.ts +312 -204
- package/src/build/route-types/scan-filter.ts +1 -1
- package/src/build/route-types/source-scan.ts +216 -0
- package/src/build/runtime-discovery.ts +32 -29
- package/src/cache/cache-error.ts +104 -0
- package/src/cache/cache-exec-scope.ts +47 -0
- package/src/cache/cache-key-utils.ts +73 -15
- package/src/cache/cache-policy.ts +108 -34
- package/src/cache/cache-runtime.ts +566 -121
- package/src/cache/cache-scope.ts +383 -105
- package/src/cache/cache-tag.ts +149 -0
- package/src/cache/cf/cf-base64.ts +33 -0
- package/src/cache/cf/cf-cache-constants.ts +134 -0
- package/src/cache/cf/cf-cache-store.ts +3028 -391
- package/src/cache/cf/cf-cache-types.ts +417 -0
- package/src/cache/cf/cf-kv-utils.ts +84 -0
- package/src/cache/cf/cf-tag-marker-memo.ts +108 -0
- package/src/cache/cf/cf-zone-purge.ts +101 -0
- package/src/cache/cf/index.ts +11 -16
- package/src/cache/document-cache.ts +184 -53
- package/src/cache/handle-snapshot.ts +92 -1
- package/src/cache/index.ts +32 -20
- package/src/cache/memory-segment-store.ts +286 -37
- package/src/cache/profile-registry.ts +46 -31
- package/src/cache/read-through-swr.ts +66 -16
- package/src/cache/search-params-filter.ts +118 -0
- package/src/cache/segment-codec.ts +80 -25
- package/src/cache/shell-snapshot.ts +516 -0
- package/src/cache/tag-invalidation.ts +230 -0
- package/src/cache/taint.ts +28 -9
- package/src/cache/types.ts +323 -100
- package/src/cache/vercel/index.ts +11 -0
- package/src/cache/vercel/vercel-cache-store.ts +1264 -0
- package/src/client-urls/client-root.tsx +161 -0
- package/src/client-urls/client-urls.ts +665 -0
- package/src/client-urls/navigation.ts +237 -0
- package/src/client-urls/revalidation-protocol.ts +56 -0
- package/src/client-urls/server-projection.ts +563 -0
- package/src/client-urls/types.ts +178 -0
- package/src/client.rsc.tsx +48 -21
- package/src/client.tsx +77 -67
- package/src/cloudflare/index.ts +11 -0
- package/src/cloudflare/tracing.ts +112 -0
- package/src/component-utils.ts +19 -0
- package/src/components/DefaultDocument.tsx +8 -2
- package/src/context-var.ts +18 -6
- package/src/decode-loader-results.ts +160 -0
- package/src/defer.ts +185 -0
- package/src/deps/ssr.ts +4 -2
- package/src/dev-discovery-protocol.ts +11 -0
- package/src/encode-kv.ts +49 -0
- package/src/errors.ts +44 -4
- package/src/escape-script.ts +52 -0
- package/src/handle.ts +67 -37
- package/src/handles/MetaTags.tsx +24 -53
- package/src/handles/Scripts.tsx +183 -0
- package/src/handles/breadcrumbs.ts +35 -8
- package/src/handles/deferred-resolution.ts +134 -0
- package/src/handles/is-thenable.ts +16 -0
- package/src/handles/meta.ts +14 -40
- package/src/handles/script.ts +244 -0
- package/src/host/cookie-handler.ts +9 -60
- package/src/host/errors.ts +13 -22
- package/src/host/index.ts +9 -2
- package/src/host/pattern-matcher.ts +23 -52
- package/src/host/router.ts +107 -99
- package/src/host/testing.ts +40 -27
- package/src/host/types.ts +37 -4
- package/src/host/utils.ts +1 -1
- package/src/href-client.ts +137 -22
- package/src/index.rsc.ts +105 -12
- package/src/index.ts +102 -14
- package/src/internal-debug.ts +11 -10
- package/src/loader-redirect.tsx +47 -0
- package/src/loader-store.ts +500 -0
- package/src/loader.rsc.ts +20 -13
- package/src/loader.ts +12 -11
- package/src/missing-id-error.ts +68 -0
- package/src/outlet-context.ts +12 -0
- package/src/outlet-provider.tsx +16 -6
- package/src/prerender/build-shell-capture.ts +453 -0
- package/src/prerender/param-hash.ts +16 -16
- package/src/prerender/shell-manifest-key.ts +20 -0
- package/src/prerender/store.ts +47 -38
- package/src/prerender.ts +81 -13
- package/src/redirect-origin.ts +143 -0
- package/src/regex-escape.ts +8 -0
- package/src/render-error-thrower.tsx +20 -0
- package/src/response-utils.ts +34 -0
- package/src/reverse.ts +65 -40
- package/src/root-error-boundary.tsx +1 -19
- package/src/route-content-wrapper.tsx +112 -78
- package/src/route-definition/dsl-helpers.ts +300 -313
- package/src/route-definition/helper-factories.ts +28 -140
- package/src/route-definition/helpers-types.ts +92 -62
- package/src/route-definition/index.ts +1 -2
- package/src/route-definition/redirect.ts +44 -11
- package/src/route-definition/resolve-handler-use.ts +6 -1
- package/src/route-definition/use-item-types.ts +29 -0
- package/src/route-map-builder.ts +102 -74
- package/src/route-types.ts +19 -46
- package/src/router/basename.ts +14 -0
- package/src/router/content-negotiation.ts +120 -30
- package/src/router/error-handling.ts +110 -29
- package/src/router/find-match.ts +129 -30
- package/src/router/handler-context.ts +41 -57
- package/src/router/instrument.ts +401 -0
- package/src/router/intercept-resolution.ts +98 -21
- package/src/router/lazy-includes.ts +82 -58
- package/src/router/loader-resolution.ts +401 -85
- package/src/router/logging.ts +0 -6
- package/src/router/manifest.ts +74 -40
- package/src/router/match-api.ts +91 -55
- package/src/router/match-context.ts +0 -22
- package/src/router/match-handlers.ts +268 -171
- package/src/router/match-middleware/background-revalidation.ts +40 -24
- package/src/router/match-middleware/cache-lookup.ts +316 -302
- package/src/router/match-middleware/cache-store.ts +134 -52
- package/src/router/match-middleware/intercept-resolution.ts +0 -22
- package/src/router/match-middleware/segment-resolution.ts +0 -22
- package/src/router/match-pipelines.ts +1 -42
- package/src/router/match-result.ts +76 -79
- package/src/router/metrics.ts +17 -36
- package/src/router/middleware-types.ts +20 -110
- package/src/router/middleware.ts +275 -173
- package/src/router/navigation-snapshot.ts +51 -60
- package/src/router/params-util.ts +23 -0
- package/src/router/parse-pattern.ts +115 -0
- package/src/router/pattern-matching.ts +134 -154
- package/src/router/prefetch-cache-ttl.ts +51 -0
- package/src/router/prefetch-default.ts +59 -0
- package/src/router/prefetch-limits.ts +37 -0
- package/src/router/prerender-match.ts +159 -69
- package/src/router/preview-match.ts +6 -2
- package/src/router/request-classification.ts +50 -69
- package/src/router/revalidation.ts +146 -83
- package/src/router/route-snapshot.ts +14 -3
- package/src/router/route-trie-builder.ts +334 -0
- package/src/router/router-context.ts +6 -29
- package/src/router/router-interfaces.ts +168 -38
- package/src/router/router-options.ts +235 -11
- package/src/router/router-registry.ts +2 -5
- package/src/router/segment-resolution/fresh.ts +163 -88
- package/src/router/segment-resolution/helpers.ts +96 -18
- package/src/router/segment-resolution/loader-cache.ts +187 -39
- package/src/router/segment-resolution/loader-mask.ts +60 -0
- package/src/router/segment-resolution/loader-snapshot.ts +259 -0
- package/src/router/segment-resolution/mask-nested.ts +99 -0
- package/src/router/segment-resolution/revalidation.ts +316 -321
- package/src/router/segment-resolution/static-store.ts +55 -15
- package/src/router/segment-resolution/streamed-handler-telemetry.ts +52 -0
- package/src/router/segment-resolution/view-transition-default.ts +60 -0
- package/src/router/segment-resolution.ts +5 -1
- package/src/router/segment-wrappers.ts +6 -5
- package/src/router/state-cookie-name.ts +33 -0
- package/src/router/substitute-pattern-params.ts +75 -0
- package/src/router/telemetry-otel.ts +171 -200
- package/src/router/telemetry.ts +106 -20
- package/src/router/timeout.ts +53 -22
- package/src/router/tracing.ts +235 -0
- package/src/router/transition-when.ts +76 -0
- package/src/router/trie-matching.ts +170 -64
- package/src/router/types.ts +9 -63
- package/src/router/url-params.ts +13 -5
- package/src/router.ts +248 -77
- package/src/rsc/capture-queue.ts +218 -0
- package/src/rsc/full-payload.ts +77 -0
- package/src/rsc/handler-context.ts +4 -2
- package/src/rsc/handler.ts +562 -284
- package/src/rsc/helpers.ts +179 -9
- package/src/rsc/index.ts +2 -5
- package/src/rsc/json-route-result.ts +38 -0
- package/src/rsc/loader-fetch.ts +116 -40
- package/src/rsc/manifest-init.ts +55 -56
- package/src/rsc/nonce.ts +10 -1
- package/src/rsc/origin-guard.ts +39 -25
- package/src/rsc/progressive-enhancement.ts +377 -84
- package/src/rsc/redirect-guard.ts +102 -0
- package/src/rsc/render-pipeline.ts +611 -0
- package/src/rsc/response-cache-serve.ts +259 -0
- package/src/rsc/response-error.ts +79 -12
- package/src/rsc/response-route-handler.ts +73 -212
- package/src/rsc/routine-plan.ts +359 -0
- package/src/rsc/rsc-rendering.ts +1624 -171
- package/src/rsc/runtime-warnings.ts +23 -10
- package/src/rsc/server-action.ts +420 -139
- package/src/rsc/shell-build-manifest.ts +336 -0
- package/src/rsc/shell-capture-constants.ts +45 -0
- package/src/rsc/shell-capture.ts +2063 -0
- package/src/rsc/shell-serve.ts +337 -0
- package/src/rsc/ssr-setup.ts +111 -16
- package/src/rsc/stream-idle.ts +137 -0
- package/src/rsc/transition-gate.ts +86 -0
- package/src/rsc/types.ts +91 -5
- package/src/runtime-env.ts +18 -0
- package/src/search-params.ts +35 -30
- package/src/segment-fragments.ts +165 -0
- package/src/segment-loader-promise.ts +49 -4
- package/src/segment-system.tsx +441 -153
- package/src/serialize.ts +243 -0
- package/src/server/context.ts +416 -55
- package/src/server/cookie-parse.ts +32 -0
- package/src/server/cookie-store.ts +162 -15
- package/src/server/handle-store.ts +190 -70
- package/src/server/loader-registry.ts +33 -42
- package/src/server/request-context.ts +805 -177
- package/src/server.ts +7 -2
- package/src/ssr/index.tsx +631 -183
- package/src/ssr/inject-rsc-eager.ts +167 -0
- package/src/ssr/preinit-client-references.ts +106 -0
- package/src/ssr/ssr-root.tsx +262 -0
- package/src/static-handler.ts +28 -15
- package/src/testing/cache-status.ts +162 -0
- package/src/testing/collect-handle.ts +46 -0
- package/src/testing/dispatch.ts +951 -0
- package/src/testing/dom.entry.ts +22 -0
- package/src/testing/e2e/fixture.ts +188 -0
- package/src/testing/e2e/index.ts +147 -0
- package/src/testing/e2e/matchers.ts +35 -0
- package/src/testing/e2e/page-helpers.ts +319 -0
- package/src/testing/e2e/parity.ts +400 -0
- package/src/testing/e2e/server.ts +195 -0
- package/src/testing/flight-matchers.ts +97 -0
- package/src/testing/flight-normalize.ts +11 -0
- package/src/testing/flight-runtime.d.ts +57 -0
- package/src/testing/flight-tree.ts +682 -0
- package/src/testing/flight.entry.ts +52 -0
- package/src/testing/flight.ts +257 -0
- package/src/testing/generated-routes.ts +199 -0
- package/src/testing/index.ts +121 -0
- package/src/testing/internal/context.ts +380 -0
- package/src/testing/internal/flight-client-globals.ts +30 -0
- package/src/testing/internal/seed-vars.ts +54 -0
- package/src/testing/render-handler.ts +371 -0
- package/src/testing/render-route.tsx +667 -0
- package/src/testing/run-loader.ts +423 -0
- package/src/testing/run-middleware.ts +219 -0
- package/src/testing/run-transition-when.ts +197 -0
- package/src/testing/shell-status.ts +206 -0
- package/src/testing/vitest-stubs/cloudflare-email.ts +9 -0
- package/src/testing/vitest-stubs/cloudflare-workers.ts +21 -0
- package/src/testing/vitest-stubs/plugin-rsc.ts +16 -0
- package/src/testing/vitest-stubs/version.ts +5 -0
- package/src/testing/vitest.ts +305 -0
- package/src/theme/ThemeProvider.tsx +56 -84
- package/src/theme/ThemeScript.tsx +7 -9
- package/src/theme/constants.ts +52 -13
- package/src/theme/index.ts +0 -7
- package/src/theme/theme-context.ts +1 -5
- package/src/theme/theme-script.ts +22 -21
- package/src/theme/use-theme.ts +0 -3
- package/src/types/boundaries.ts +15 -35
- package/src/types/cache-types.ts +13 -4
- package/src/types/error-types.ts +30 -90
- package/src/types/global-namespace.ts +54 -41
- package/src/types/handler-context.ts +121 -30
- package/src/types/index.ts +3 -10
- package/src/types/loader-types.ts +38 -7
- package/src/types/request-scope.ts +8 -22
- package/src/types/route-config.ts +20 -52
- package/src/types/route-entry.ts +3 -6
- package/src/types/segments.ts +147 -14
- package/src/urls/include-helper.ts +38 -64
- package/src/urls/include-provider.ts +71 -0
- package/src/urls/index.ts +2 -11
- package/src/urls/path-helper-types.ts +76 -24
- package/src/urls/path-helper.ts +30 -110
- package/src/urls/pattern-types.ts +101 -19
- package/src/urls/response-types.ts +20 -19
- package/src/urls/type-extraction.ts +98 -154
- package/src/urls/urls-function.ts +1 -19
- package/src/use-loader.tsx +355 -109
- package/src/vercel/index.ts +11 -0
- package/src/vercel/tracing.ts +89 -0
- package/src/vite/debug.ts +102 -3
- package/src/vite/discovery/bundle-postprocess.ts +18 -14
- package/src/vite/discovery/client-urls-projection.ts +322 -0
- package/src/vite/discovery/dev-prerender-cache.ts +117 -0
- package/src/vite/discovery/discover-routers.ts +178 -151
- package/src/vite/discovery/discovery-errors.ts +255 -0
- package/src/vite/discovery/gate-state.ts +171 -0
- package/src/vite/discovery/prerender-collection.ts +125 -70
- package/src/vite/discovery/route-types-writer.ts +40 -84
- package/src/vite/discovery/self-gen-tracking.ts +27 -1
- package/src/vite/discovery/shell-prerender-phase.ts +397 -0
- package/src/vite/discovery/state.ts +104 -6
- package/src/vite/discovery/virtual-module-codegen.ts +226 -87
- package/src/vite/encryption-key.ts +29 -0
- package/src/vite/index.ts +12 -0
- package/src/vite/inject-client-debug.ts +88 -0
- package/src/vite/plugin-types.ts +243 -10
- package/src/vite/plugins/cjs-to-esm.ts +16 -19
- package/src/vite/plugins/client-ref-dedup.ts +16 -11
- package/src/vite/plugins/client-ref-hashing.ts +28 -15
- package/src/vite/plugins/cloudflare-protocol-stub.ts +1 -21
- package/src/vite/plugins/expose-action-id.ts +50 -97
- package/src/vite/plugins/expose-id-utils.ts +88 -55
- package/src/vite/plugins/expose-ids/export-analysis.ts +101 -34
- package/src/vite/plugins/expose-ids/handler-transform.ts +11 -90
- package/src/vite/plugins/expose-ids/loader-transform.ts +14 -24
- package/src/vite/plugins/expose-ids/router-transform.ts +118 -29
- package/src/vite/plugins/expose-internal-ids.ts +551 -486
- package/src/vite/plugins/performance-tracks.ts +25 -22
- package/src/vite/plugins/refresh-cmd.ts +1 -1
- package/src/vite/plugins/server-ref-hashing.ts +74 -0
- package/src/vite/plugins/server-reference-pattern.ts +10 -0
- package/src/vite/plugins/use-cache-transform.ts +73 -83
- package/src/vite/plugins/vercel-output.ts +384 -0
- package/src/vite/plugins/version-injector.ts +39 -29
- package/src/vite/plugins/version-plugin.ts +45 -40
- package/src/vite/plugins/virtual-entries.ts +193 -30
- package/src/vite/rango.ts +240 -128
- package/src/vite/router-discovery.ts +1518 -174
- package/src/vite/utils/ast-handler-extract.ts +26 -35
- package/src/vite/utils/bundle-analysis.ts +10 -15
- package/src/vite/utils/client-chunks.ts +184 -0
- package/src/vite/utils/directive-prologue.ts +40 -0
- package/src/vite/utils/forward-user-plugins.ts +171 -0
- package/src/vite/utils/manifest-utils.ts +1 -59
- package/src/vite/utils/package-resolution.ts +2 -73
- package/src/vite/utils/prerender-utils.ts +96 -49
- package/src/vite/utils/shared-utils.ts +156 -43
- package/src/browser/action-response-classifier.ts +0 -99
- package/src/browser/react/use-client-cache.ts +0 -58
- package/src/browser/shallow.ts +0 -40
- package/src/handles/index.ts +0 -7
- package/src/network-error-thrower.tsx +0 -23
- package/src/router/middleware-cookies.ts +0 -55
|
@@ -11,7 +11,15 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
14
|
+
import { parseCookiesFromHeader } from "./cookie-parse.js";
|
|
15
|
+
import type { CacheErrorCategory } from "../cache/cache-error.js";
|
|
14
16
|
import type { CookieOptions } from "../router/middleware.js";
|
|
17
|
+
import {
|
|
18
|
+
KEEP_CACHE_HEADER,
|
|
19
|
+
getRawCookieValue,
|
|
20
|
+
mintStateValue,
|
|
21
|
+
serializeStateCookie,
|
|
22
|
+
} from "../browser/cookie-name.js";
|
|
15
23
|
import type { LoaderDefinition, LoaderContext } from "../types.js";
|
|
16
24
|
import type { ScopedReverseFunction } from "../reverse.js";
|
|
17
25
|
import type {
|
|
@@ -33,24 +41,54 @@ import {
|
|
|
33
41
|
type HandleData,
|
|
34
42
|
} from "./handle-store.js";
|
|
35
43
|
import { isHandle } from "../handle.js";
|
|
36
|
-
import {
|
|
44
|
+
import { withDefer } from "../defer.js";
|
|
45
|
+
import { type MetricsStore } from "./context.js";
|
|
46
|
+
import { observePhase, PHASES } from "../router/instrument.js";
|
|
37
47
|
import { getFetchableLoader } from "./fetchable-loader-store.js";
|
|
38
48
|
import type { SegmentCacheStore } from "../cache/types.js";
|
|
39
49
|
import type { Theme, ResolvedThemeConfig } from "../theme/types.js";
|
|
40
50
|
import type { ExecutionContext, RequestScope } from "../types/request-scope.js";
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
51
|
+
import type { TransitionWhenFn } from "../types/segments.js";
|
|
52
|
+
import type { ResolvedTracing } from "../router/tracing.js";
|
|
53
|
+
import type { RenderMode, RenderPhase } from "../router/timeout.js";
|
|
54
|
+
import {
|
|
55
|
+
THEME_COOKIE,
|
|
56
|
+
isValidTheme,
|
|
57
|
+
warnInvalidTheme,
|
|
58
|
+
} from "../theme/constants.js";
|
|
43
59
|
import type { LocationStateEntry } from "../browser/react/location-state-shared.js";
|
|
60
|
+
import type { RoutineTrace } from "../rsc/routine-plan.js";
|
|
44
61
|
import { NOCACHE_SYMBOL, assertNotInsideCacheExec } from "../cache/taint.js";
|
|
45
|
-
import {
|
|
62
|
+
import {
|
|
63
|
+
assertCachedHeaderWriteAllowed,
|
|
64
|
+
clearPprHeaderScope,
|
|
65
|
+
isInsideCacheScope,
|
|
66
|
+
} from "./context.js";
|
|
46
67
|
import {
|
|
47
68
|
createReverseFunction,
|
|
48
69
|
stripInternalParams,
|
|
49
70
|
} from "../router/handler-context.js";
|
|
50
|
-
import {
|
|
71
|
+
import {
|
|
72
|
+
getGlobalRouteMap,
|
|
73
|
+
isRouteRootScoped,
|
|
74
|
+
getSearchSchema,
|
|
75
|
+
} from "../route-map-builder.js";
|
|
76
|
+
import { parseSearchParams } from "../search-params.js";
|
|
51
77
|
import { invariant } from "../errors.js";
|
|
52
78
|
import { isAutoGeneratedRouteName } from "../route-name.js";
|
|
53
79
|
|
|
80
|
+
export interface RenderForegroundCursor {
|
|
81
|
+
mode: RenderMode;
|
|
82
|
+
phase: RenderPhase;
|
|
83
|
+
state: "paused" | "running";
|
|
84
|
+
completed: number;
|
|
85
|
+
total: number;
|
|
86
|
+
pipelineStartedAt: number;
|
|
87
|
+
phaseStartedAt?: number;
|
|
88
|
+
routeKey?: string;
|
|
89
|
+
actionId?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
54
92
|
/**
|
|
55
93
|
* Unified request context available via getRequestContext()
|
|
56
94
|
*
|
|
@@ -85,6 +123,27 @@ export interface RequestContext<
|
|
|
85
123
|
/** @internal Stub response for collecting headers/cookies. Use ctx.headers or ctx.header() instead. */
|
|
86
124
|
readonly res: Response;
|
|
87
125
|
|
|
126
|
+
/**
|
|
127
|
+
* True for build-time render/capture requests. Live requests use false.
|
|
128
|
+
* Build-time shell capture sets this while replaying middleware so apps can
|
|
129
|
+
* skip side-effectful runtime work.
|
|
130
|
+
*/
|
|
131
|
+
readonly build: boolean;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Opt this request out of PPR shell serving/capture.
|
|
135
|
+
* Runtime middleware can call this before the PPR commit point; handlers can
|
|
136
|
+
* call it on a MISS to prevent the follow-up capture.
|
|
137
|
+
*
|
|
138
|
+
* Scope: the PPR SHELL axis only. It does NOT disable prerender B-segment
|
|
139
|
+
* (Prerender/Static) serving, and it is inert in the prerender-collect /
|
|
140
|
+
* static-render contexts (no live shell decision to influence there).
|
|
141
|
+
*/
|
|
142
|
+
dynamic(): void;
|
|
143
|
+
|
|
144
|
+
/** @internal Request-local PPR opt-out marker set by ctx.dynamic(). */
|
|
145
|
+
_dynamic?: boolean;
|
|
146
|
+
|
|
88
147
|
/** @internal Get a cookie value (effective: request + response mutations). Use cookies().get() instead. */
|
|
89
148
|
cookie(name: string): string | undefined;
|
|
90
149
|
/** @internal Get all cookies (effective merged view). Use cookies().getAll() instead. */
|
|
@@ -102,6 +161,10 @@ export interface RequestContext<
|
|
|
102
161
|
setStatus(status: number): void;
|
|
103
162
|
/** @internal Set status bypassing cache-exec guard (for framework error handling) */
|
|
104
163
|
_setStatus(status: number): void;
|
|
164
|
+
/** @internal Rotate the rango state cookie (server seat of invalidateClientCache). */
|
|
165
|
+
_rotateStateCookie(): void;
|
|
166
|
+
/** @internal Set the keepClientCache() directive header on the response. */
|
|
167
|
+
_setKeepCacheDirective(): void;
|
|
105
168
|
|
|
106
169
|
/**
|
|
107
170
|
* Access loader data or push handle data.
|
|
@@ -137,9 +200,234 @@ export interface RequestContext<
|
|
|
137
200
|
/** @internal Handle store for tracking handle data across segments */
|
|
138
201
|
_handleStore: HandleStore;
|
|
139
202
|
|
|
203
|
+
/**
|
|
204
|
+
* @internal transition({ when }) predicates for segments matched this request,
|
|
205
|
+
* keyed by segment id. Collected during resolution (the function is stripped
|
|
206
|
+
* from the serialized segment config), then evaluated post-handler in
|
|
207
|
+
* rsc-rendering — outside any cache scope — to drop the transition of any
|
|
208
|
+
* segment whose predicate returns false.
|
|
209
|
+
*/
|
|
210
|
+
_transitionWhen?: Array<{ id: string; when: TransitionWhenFn }>;
|
|
211
|
+
|
|
212
|
+
/** @internal PPR transition decisions evaluated before cache lookup/handlers. */
|
|
213
|
+
_pprTransitionDecisions?: Map<string, boolean>;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @internal Post-match serve-source truth for the PPR replay reporter.
|
|
217
|
+
* Stamped from the match context as `intercept`, then overwritten as
|
|
218
|
+
* `prerender-store` if that lookup actually serves. The latter wins because
|
|
219
|
+
* it identifies the response source. matchPartialWithPprReplay reads this
|
|
220
|
+
* AFTER matching to reclassify its pre-match guess and suppress pointless
|
|
221
|
+
* heal captures.
|
|
222
|
+
*/
|
|
223
|
+
_pprReplayPostMatchReason?: "prerender-store" | "intercept";
|
|
224
|
+
|
|
140
225
|
/** @internal Cache store for segment caching (optional, used by CacheScope) */
|
|
141
226
|
_cacheStore?: SegmentCacheStore;
|
|
142
227
|
|
|
228
|
+
/**
|
|
229
|
+
* @internal Compiled `cache.searchParams` filter for default cache-key
|
|
230
|
+
* generation (undefined = "all", the byte-stable unfiltered format). Set
|
|
231
|
+
* once per request by handler.ts; every URL-keyed tier (segment, document,
|
|
232
|
+
* response, shell, "use cache") reads it so the tiers cannot drift.
|
|
233
|
+
*/
|
|
234
|
+
_searchParamsFilter?: import("../cache/search-params-filter.js").SearchParamsFilter;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @internal PPR shell-capture ACTIVE marker. True ONLY inside the background
|
|
238
|
+
* capture task's derived request context (built by shell-capture.ts). This is
|
|
239
|
+
* the switch every capture-specific behavior reads: loader masking
|
|
240
|
+
* (loader-mask.ts isShellCaptureActive / fresh.ts emitStreaming) and the
|
|
241
|
+
* cookies()/headers() capture guard (cookie-store.ts
|
|
242
|
+
* assertNotInsideShellCapture). The foreground render never sets it, so the
|
|
243
|
+
* served response is byte-identical to axis 1. The capture descriptor itself
|
|
244
|
+
* (key/ttl/swr/tags/store) is NOT threaded through the request context — the
|
|
245
|
+
* integrated PPR serve path (rsc/shell-serve.ts + rsc-rendering.ts) builds it
|
|
246
|
+
* locally and passes it to scheduleShellCapture directly.
|
|
247
|
+
*/
|
|
248
|
+
_shellCaptureRun?: boolean;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* @internal Bake-lane loader containers collected DURING a shell capture:
|
|
252
|
+
* segment-key -> the loader's (pre-wrap) result promise. Populated by
|
|
253
|
+
* resolveLoaderData for loaders on entries with no renderable loading() (the
|
|
254
|
+
* bake lane — they execute at capture instead of being masked; see
|
|
255
|
+
* docs/design/loader-container-bake.md). Drained by captureAndStoreShell
|
|
256
|
+
* after the shell quiesces: settled containers are promise-elided,
|
|
257
|
+
* Flight-serialized, and pinned into the snapshot's loader family; a
|
|
258
|
+
* REJECTED container refuses the capture (error UI must never bake into the
|
|
259
|
+
* shared shell). Own property of the capture's derived context only.
|
|
260
|
+
*/
|
|
261
|
+
_shellCaptureLoaderRecords?: Map<string, Promise<unknown>>;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @internal Loader-family snapshot seed for a shell HIT's tail render:
|
|
265
|
+
* segment-key -> the capture's elided container (already Flight-deserialized
|
|
266
|
+
* by serveShellHit) plus its capture-computed hole bit. resolveLoaderData
|
|
267
|
+
* overlays it onto the fresh run's container (recorded paths pinned,
|
|
268
|
+
* hole-marker paths keep the fresh nested promises) so the payload's baked
|
|
269
|
+
* bytes match the frozen prelude; a hole-free entry resolves pin-first
|
|
270
|
+
* without gating on the fresh run. Own property of the HIT tail's derived
|
|
271
|
+
* context only.
|
|
272
|
+
*/
|
|
273
|
+
_shellLoaderSeed?: Map<
|
|
274
|
+
string,
|
|
275
|
+
import("../cache/shell-snapshot.js").ShellLoaderSeedEntry
|
|
276
|
+
>;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* @internal Shell fast-path marker: makes the next eligible match treat the
|
|
280
|
+
* whole matched route as an implicit doc-level cache() boundary (see
|
|
281
|
+
* resolveShellImplicitCacheScope in cache/cache-scope.ts). Set ONLY on
|
|
282
|
+
* (a) the capture's derived context — with a record-only store so the
|
|
283
|
+
* capture's cacheRoute write lands in the snapshot, never the real store —
|
|
284
|
+
* (b) a HIT tail's seeded context, and (c) an eligible normal-route partial
|
|
285
|
+
* replay, where `store` is a request-local segment overlay. Handler-live holes
|
|
286
|
+
* and conditional transitions decline replay.
|
|
287
|
+
* Routes with their own cache() config are never overridden — their scope's
|
|
288
|
+
* store/key/ttl/swr/condition semantics stay authoritative. On the
|
|
289
|
+
* navigation-replay serve path (`onExplicitHit` set) the marker COMPOSES with
|
|
290
|
+
* such a scope instead of being ignored: the seeded doc record supplies the match
|
|
291
|
+
* only when the explicit tier misses (withCacheLookup). cache(false) and a
|
|
292
|
+
* false condition() stay absolute opt-outs — replay bypasses before any
|
|
293
|
+
* shell read (`cache-disabled`).
|
|
294
|
+
*/
|
|
295
|
+
_shellImplicitCache?: {
|
|
296
|
+
ttl?: number;
|
|
297
|
+
swr?: number;
|
|
298
|
+
store?: SegmentCacheStore;
|
|
299
|
+
/**
|
|
300
|
+
* @internal Override the implicit scope's default cache namespace. Shell
|
|
301
|
+
* captures and navigation replay both consume the canonical document
|
|
302
|
+
* segment record even when the triggering request is partial.
|
|
303
|
+
*/
|
|
304
|
+
keyPrefix?: "doc";
|
|
305
|
+
/** @internal Called only after the implicit cache hit decodes successfully. */
|
|
306
|
+
onHit?: () => void;
|
|
307
|
+
/**
|
|
308
|
+
* @internal Called when the seeded document record fails server-side
|
|
309
|
+
* deserialization. Partial replay uses it to replace the enclosing shell
|
|
310
|
+
* snapshot after serving the fresh fallback.
|
|
311
|
+
*/
|
|
312
|
+
onCorrupt?: () => void;
|
|
313
|
+
/**
|
|
314
|
+
* @internal The resolved key of the canonical document segment record.
|
|
315
|
+
* Written during a CAPTURE render by CacheScope.cacheRoute when a
|
|
316
|
+
* doc-namespaced scope records the matched segments; captureAndStoreShell
|
|
317
|
+
* stamps it onto the ShellCacheEntry (`docKey`) so replay eligibility can
|
|
318
|
+
* require the exact consumable record instead of "any segment record".
|
|
319
|
+
*/
|
|
320
|
+
docKey?: string;
|
|
321
|
+
/**
|
|
322
|
+
* @internal Set ONLY by matchPartialWithPprReplay on the navigation-replay
|
|
323
|
+
* serve path. Its presence arms the explicit-scope composition in
|
|
324
|
+
* withCacheLookup: a route-derived cache() scope stays authoritative, and
|
|
325
|
+
* only when its lookup MISSes does the seeded doc record supply the match.
|
|
326
|
+
* A capture render must never set this (its match must re-run handlers so
|
|
327
|
+
* SWR recapture stays fresh), which is why the fallback keys off this
|
|
328
|
+
* field and not off the marker itself. Fired when the route-derived
|
|
329
|
+
* scope's own lookup supplied the match — the header then reports
|
|
330
|
+
* `BYPASS; reason=explicit-cache-hit`, never a false replay HIT.
|
|
331
|
+
*/
|
|
332
|
+
onExplicitHit?: () => void;
|
|
333
|
+
/**
|
|
334
|
+
* @internal Companion to onExplicitHit, same lifecycle: fired when the
|
|
335
|
+
* route-derived scope's lookup REFUSED the read (`bypass` outcome — a
|
|
336
|
+
* false condition() or no store). The gate only pre-decides the static
|
|
337
|
+
* cache(false) case; a predicate refusal is known only at lookup time and
|
|
338
|
+
* reports `BYPASS; reason=cache-disabled` post-match.
|
|
339
|
+
*/
|
|
340
|
+
onExplicitBypass?: () => void;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @internal Fragment-passthrough marker: cache/prerender-store hits during
|
|
345
|
+
* THIS render emit stored segment fragments VERBATIM into the payload
|
|
346
|
+
* (segment-codec fragmentSegments) instead of deserialize -> re-serialize
|
|
347
|
+
* per request; the payload consumers (SSR resume, browser hydration, and
|
|
348
|
+
* the client partial-navigation decode chokepoints) expand them
|
|
349
|
+
* (segment-fragments.ts, issue #700). Partial requests arm only after the
|
|
350
|
+
* browser advertises `X-Rango-Fragment-Passthrough: 1`; a decode failure
|
|
351
|
+
* retries without it so CacheScope can evict the bad record. Two arming sites,
|
|
352
|
+
* both scoped to a
|
|
353
|
+
* render/match window: serveShellHit's derived tail context (document
|
|
354
|
+
* HIT), and matchPartialWithPprReplay's mutate-restore around the partial
|
|
355
|
+
* match (matchPartialForReplay). It must never be visible to a capture
|
|
356
|
+
* render: the capture SSR-prerenders the payload AND serializes segments
|
|
357
|
+
* into records (cacheRoute), and an envelope reaching serializeSegments
|
|
358
|
+
* would store a double-encoded fragment — deriveShellCaptureContext resets
|
|
359
|
+
* it as an own property for exactly that reason.
|
|
360
|
+
*/
|
|
361
|
+
_shellFragmentPayload?: boolean;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* @internal Handler-layer liveness observed DURING a shell capture, from
|
|
365
|
+
* three sources: (a) the capture handle-store push wrapper (shell-capture.ts)
|
|
366
|
+
* when a push made OUTSIDE a DSL loader scope carries a nested thenable
|
|
367
|
+
* (masked to a never-filling hole); (b) still-pending top-level handler
|
|
368
|
+
* pushes (liveness unknowable at the barrier); (c) a handler-invoked loader
|
|
369
|
+
* executing during the capture (loader-resolution.ts — its consumption-lane
|
|
370
|
+
* value would freeze on a handler-free HIT). captureAndStoreShell folds it
|
|
371
|
+
* into ShellCacheEntry.handlerLiveHoles at the putShell barrier. Own
|
|
372
|
+
* property of the capture's derived context only.
|
|
373
|
+
*/
|
|
374
|
+
_shellCaptureHandleLiveness?: {
|
|
375
|
+
holes: boolean;
|
|
376
|
+
pendingPushes: number;
|
|
377
|
+
handlerInvokedLoader: boolean;
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* @internal Handle values pushed from a DSL loader scope DURING a shell
|
|
382
|
+
* capture (identity set; populated by the capture push wrapper in
|
|
383
|
+
* shell-capture.ts). cacheRoute threads it into captureHandles so those
|
|
384
|
+
* values stay out of cache-write handle records — loaders re-run fresh on
|
|
385
|
+
* every HIT, so replaying their captured (masked) values would duplicate
|
|
386
|
+
* the fresh push and stall the Flight handle encode. Own property of the
|
|
387
|
+
* capture's derived context only; render-time handle consumers are
|
|
388
|
+
* unaffected (the exclusion applies only at the captureHandles call site).
|
|
389
|
+
*/
|
|
390
|
+
_shellCaptureLoaderHandleValues?: WeakSet<object>;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* @internal Set (to the offending fn name) by the cookies()/headers()
|
|
394
|
+
* capture guard when it throws DURING a capture render. Load-bearing for the
|
|
395
|
+
* bake lane: a guard throw inside an executing loader is swallowed by
|
|
396
|
+
* wrapLoaderPromise into per-loader error UI, which would otherwise bake
|
|
397
|
+
* silently into the shared shell — the capture checks this flag after the
|
|
398
|
+
* render and refuses instead. Deterministic, so the capture does not retry.
|
|
399
|
+
*/
|
|
400
|
+
_shellCaptureGuardTripped?: string;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* @internal The loader $$id whose BODY was executing when the capture guard
|
|
404
|
+
* tripped (read off the loader-body ALS scope at trip time), or undefined
|
|
405
|
+
* when the read came from handler/render code. Only used to make the
|
|
406
|
+
* once-per-key refusal warning name the real source — the old text
|
|
407
|
+
* hardcoded "a bake-lane loader", which misattributed handler-land reads
|
|
408
|
+
* and sent users debugging the wrong lane (issue #672, secondary).
|
|
409
|
+
*/
|
|
410
|
+
_shellCaptureGuardTrippedLoaderId?: string;
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* @internal Handler-owned registry of explicit per-scope stores from
|
|
414
|
+
* cache({ store }). Created once per createRSCHandler() and threaded into
|
|
415
|
+
* every request context, so it accumulates every explicit store the handler
|
|
416
|
+
* resolves. updateTag()/revalidateTag() iterate this set plus _cacheStore to
|
|
417
|
+
* reach every store that may hold tagged entries. The app-level store is not
|
|
418
|
+
* added here (it is always reachable via _cacheStore).
|
|
419
|
+
*/
|
|
420
|
+
_explicitTaggedStores?: Set<SegmentCacheStore>;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* @internal Union of every cache tag resolved while producing this request's
|
|
424
|
+
* response (from cache({ tags }), runtime cacheTag(), and loader cache tags).
|
|
425
|
+
* Populated at the tag-resolution sites via recordRequestTags(). Read by the
|
|
426
|
+
* document cache middleware so a full-page entry is tagged with everything its
|
|
427
|
+
* content used and can therefore be invalidated by updateTag()/revalidateTag().
|
|
428
|
+
*/
|
|
429
|
+
_requestTags: Set<string>;
|
|
430
|
+
|
|
143
431
|
/** @internal Cache profiles for "use cache" profile resolution (per-router) */
|
|
144
432
|
_cacheProfiles?: Record<
|
|
145
433
|
string,
|
|
@@ -168,6 +456,19 @@ export interface RequestContext<
|
|
|
168
456
|
/** @internal Registered onResponse callbacks */
|
|
169
457
|
_onResponseCallbacks: Array<(response: Response) => Response>;
|
|
170
458
|
|
|
459
|
+
/**
|
|
460
|
+
* @internal Promises of the background tasks scheduled via this context's
|
|
461
|
+
* waitUntil (deferred cache writes, revalidations, consumer tasks). The PPR
|
|
462
|
+
* shell capture drains this list BEFORE its match/render as an ORDERING EDGE:
|
|
463
|
+
* every foreground deferred cache write is scheduled here before the capture
|
|
464
|
+
* task is, so settling the list first guarantees the capture's cache reads
|
|
465
|
+
* observe the foreground's generation instead of racing it (see
|
|
466
|
+
* shell-capture.ts). Tasks whose scheduling fn carries
|
|
467
|
+
* UNTRACKED_BACKGROUND_TASK are not tracked (the capture task itself —
|
|
468
|
+
* tracking it would make that drain await its own promise).
|
|
469
|
+
*/
|
|
470
|
+
_pendingBackgroundTasks?: Array<Promise<unknown>>;
|
|
471
|
+
|
|
171
472
|
/**
|
|
172
473
|
* Current theme setting (only available when theme is enabled in router config)
|
|
173
474
|
*
|
|
@@ -249,6 +550,30 @@ export interface RequestContext<
|
|
|
249
550
|
/** @internal Previous route key (from the navigation source), used for revalidation */
|
|
250
551
|
_prevRouteKey?: string;
|
|
251
552
|
|
|
553
|
+
/**
|
|
554
|
+
* @internal Navigation/action source data the transition({ when }) gate reads
|
|
555
|
+
* to build its ShouldRevalidateFn-shaped predicate context. currentUrl/Params
|
|
556
|
+
* come from the navigation snapshot (set at match time); action* are stashed
|
|
557
|
+
* at the action-bearing gate call sites. All undefined when there is no source
|
|
558
|
+
* (initial full load) or no action (plain navigation).
|
|
559
|
+
*/
|
|
560
|
+
_gateCurrentUrl?: URL;
|
|
561
|
+
_gateCurrentParams?: Record<string, string>;
|
|
562
|
+
_gateActionId?: string;
|
|
563
|
+
_gateActionUrl?: URL;
|
|
564
|
+
_gateActionResult?: unknown;
|
|
565
|
+
_gateFormData?: FormData;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* @internal True while the post-action revalidation render is running (set by
|
|
569
|
+
* revalidateAfterAction). The "use cache" runtime reads this to prefer
|
|
570
|
+
* freshness over a fast stale response during an action: a stale entry
|
|
571
|
+
* re-executes in the foreground (so the action response reflects the refreshed
|
|
572
|
+
* value) with only the store write deferred, instead of serving stale and
|
|
573
|
+
* revalidating in the background. A plain navigation (flag unset) keeps SWR.
|
|
574
|
+
*/
|
|
575
|
+
_inActionRevalidation?: boolean;
|
|
576
|
+
|
|
252
577
|
/**
|
|
253
578
|
* @internal Render barrier for experimental `rendered()` API.
|
|
254
579
|
* Resolves when all non-loader segments have settled and handle data
|
|
@@ -273,7 +598,9 @@ export interface RequestContext<
|
|
|
273
598
|
|
|
274
599
|
/**
|
|
275
600
|
* @internal Set to true when the matched entry tree contains any `loading()`
|
|
276
|
-
* entries (streaming).
|
|
601
|
+
* entries (streaming). On a streaming tree rendered() waits for the streaming
|
|
602
|
+
* handlers to settle (via handleStore.settled) before resolving, and the
|
|
603
|
+
* deadlock guard state is kept live until that wait completes.
|
|
277
604
|
*/
|
|
278
605
|
_treeHasStreaming?: boolean;
|
|
279
606
|
|
|
@@ -297,6 +624,18 @@ export interface RequestContext<
|
|
|
297
624
|
*/
|
|
298
625
|
_renderBarrierHandleSnapshot?: HandleData;
|
|
299
626
|
|
|
627
|
+
/**
|
|
628
|
+
* @internal The deadlock guard window is closed (no further handler-awaits-
|
|
629
|
+
* loader cycle is possible). For non-streaming trees this is set when the
|
|
630
|
+
* barrier resolves. For streaming trees the window stays open until
|
|
631
|
+
* handleStore.settled — rendered() keeps waiting past the barrier and a
|
|
632
|
+
* loading() handler can still resume and await a still-waiting loader — so it
|
|
633
|
+
* is set only after settled. The guard (loader-resolution `setupLoaderAccess`)
|
|
634
|
+
* reads this instead of `_renderBarrierSegmentOrder` so it does not go blind
|
|
635
|
+
* during the streaming settle wait.
|
|
636
|
+
*/
|
|
637
|
+
_renderBarrierGuardClosed?: boolean;
|
|
638
|
+
|
|
300
639
|
/** @internal Per-request error dedup set for onError reporting */
|
|
301
640
|
_reportedErrors: WeakSet<object>;
|
|
302
641
|
|
|
@@ -304,9 +643,13 @@ export interface RequestContext<
|
|
|
304
643
|
* @internal Report a non-fatal background error through the router's
|
|
305
644
|
* onError callback. Wired by the RSC handler / router during request
|
|
306
645
|
* creation. Cache-runtime and other subsystems call this to surface
|
|
307
|
-
* errors without failing the response.
|
|
646
|
+
* errors without failing the response. `category` is surfaced to consumers as
|
|
647
|
+
* `metadata.category` on the onError context (phase `cache`).
|
|
308
648
|
*/
|
|
309
|
-
_reportBackgroundError?: (
|
|
649
|
+
_reportBackgroundError?: (
|
|
650
|
+
error: unknown,
|
|
651
|
+
category: CacheErrorCategory,
|
|
652
|
+
) => void;
|
|
310
653
|
|
|
311
654
|
/** @internal Per-request debug performance override (set via ctx.debugPerformance()) */
|
|
312
655
|
_debugPerformance?: boolean;
|
|
@@ -314,14 +657,59 @@ export interface RequestContext<
|
|
|
314
657
|
/** @internal Request-scoped performance metrics store */
|
|
315
658
|
_metricsStore?: MetricsStore;
|
|
316
659
|
|
|
660
|
+
/**
|
|
661
|
+
* @internal Foreground response-construction cursor. It reports only the
|
|
662
|
+
* generator driver's current Flight/HTML/response operation; concurrent
|
|
663
|
+
* loaders and post-commit stream work have separate lifetimes.
|
|
664
|
+
*/
|
|
665
|
+
_renderForeground?: RenderForegroundCursor;
|
|
666
|
+
|
|
667
|
+
/** @internal Request routine currently executing, used by timeout diagnostics. */
|
|
668
|
+
_activeRoutine?: RoutineTrace;
|
|
669
|
+
|
|
670
|
+
/** @internal Keep the render cursor active for timeout support. */
|
|
671
|
+
_renderDiagnosticsEnabled?: boolean;
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* @internal True request entry timestamp (performance.now() at handler entry).
|
|
675
|
+
* Set once at request-context creation (rsc/handler.ts) so a metrics store
|
|
676
|
+
* created MID-request — ctx.debugPerformance() or the getMetricsStore wrapper —
|
|
677
|
+
* anchors its timeline to the real request start instead of the opt-in moment,
|
|
678
|
+
* keeping phases that began before the opt-in at their true (non-negative) offset.
|
|
679
|
+
*/
|
|
680
|
+
_handlerStart?: number;
|
|
681
|
+
|
|
682
|
+
/** @internal Resolved platform phase-span tracing for this request (Cloudflare or OTel) */
|
|
683
|
+
_tracing?: ResolvedTracing;
|
|
684
|
+
|
|
317
685
|
/** @internal Router basename for this request (used by redirect()) */
|
|
318
686
|
_basename?: string;
|
|
319
687
|
|
|
688
|
+
/** @internal Owning router id; scopes the search-schema/root-scope registry
|
|
689
|
+
* lookups per router (route-map-builder.ts) */
|
|
690
|
+
_routerId?: string;
|
|
691
|
+
|
|
320
692
|
/**
|
|
321
693
|
* @internal RouteSnapshot from classifyRequest, reused by match/matchPartial
|
|
322
694
|
* to avoid a second resolveRoute call. Cleared on HMR invalidation.
|
|
323
695
|
*/
|
|
324
696
|
_classifiedRoute?: import("../router/route-snapshot.js").RouteSnapshot;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* @internal Classified request mode from classifyRequest, read by the
|
|
700
|
+
* rango.response span tail (rsc/handler.ts) for the rango.response.mode
|
|
701
|
+
* attribute. Unset when middleware short-circuits before core execution.
|
|
702
|
+
*/
|
|
703
|
+
_requestMode?: import("../router/request-classification.js").RequestPlan["mode"];
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* @internal Coarse route-level cache signal for the X-Rango-Cache debug
|
|
707
|
+
* header. Populated by match/matchPartial only when the debug cache signal
|
|
708
|
+
* gate is enabled (debugCacheSignal option or RANGO_TEST_SIGNALS=1). Read by
|
|
709
|
+
* the response-finalization path (createResponseWithMergedHeaders). Undefined
|
|
710
|
+
* when the gate is off, so no header is emitted.
|
|
711
|
+
*/
|
|
712
|
+
_cacheSignal?: import("../router/telemetry.js").CacheSegmentSignal[];
|
|
325
713
|
}
|
|
326
714
|
|
|
327
715
|
/**
|
|
@@ -340,13 +728,36 @@ export type PublicRequestContext<
|
|
|
340
728
|
| "setCookie"
|
|
341
729
|
| "deleteCookie"
|
|
342
730
|
| "_handleStore"
|
|
731
|
+
| "_transitionWhen"
|
|
732
|
+
| "_pprTransitionDecisions"
|
|
733
|
+
| "_pprReplayPostMatchReason"
|
|
343
734
|
| "_cacheStore"
|
|
735
|
+
| "_searchParamsFilter"
|
|
736
|
+
| "_shellCaptureRun"
|
|
737
|
+
| "_shellImplicitCache"
|
|
738
|
+
| "_shellLoaderSeed"
|
|
739
|
+
| "_shellCaptureLoaderRecords"
|
|
740
|
+
| "_shellCaptureHandleLiveness"
|
|
741
|
+
| "_shellCaptureLoaderHandleValues"
|
|
742
|
+
| "_shellFragmentPayload"
|
|
743
|
+
| "_shellCaptureGuardTripped"
|
|
744
|
+
| "_shellCaptureGuardTrippedLoaderId"
|
|
745
|
+
| "_explicitTaggedStores"
|
|
746
|
+
| "_requestTags"
|
|
344
747
|
| "_cacheProfiles"
|
|
345
748
|
| "_onResponseCallbacks"
|
|
749
|
+
| "_pendingBackgroundTasks"
|
|
346
750
|
| "_themeConfig"
|
|
347
751
|
| "_locationState"
|
|
348
752
|
| "_routeName"
|
|
349
753
|
| "_prevRouteKey"
|
|
754
|
+
| "_gateCurrentUrl"
|
|
755
|
+
| "_gateCurrentParams"
|
|
756
|
+
| "_gateActionId"
|
|
757
|
+
| "_gateActionUrl"
|
|
758
|
+
| "_gateActionResult"
|
|
759
|
+
| "_gateFormData"
|
|
760
|
+
| "_inActionRevalidation"
|
|
350
761
|
| "_reportedErrors"
|
|
351
762
|
| "_renderBarrier"
|
|
352
763
|
| "_resolveRenderBarrier"
|
|
@@ -355,16 +766,39 @@ export type PublicRequestContext<
|
|
|
355
766
|
| "_renderBarrierWaiters"
|
|
356
767
|
| "_handlerLoaderDeps"
|
|
357
768
|
| "_renderBarrierHandleSnapshot"
|
|
769
|
+
| "_renderBarrierGuardClosed"
|
|
358
770
|
| "_reportBackgroundError"
|
|
359
771
|
| "_debugPerformance"
|
|
360
772
|
| "_metricsStore"
|
|
773
|
+
| "_renderForeground"
|
|
774
|
+
| "_activeRoutine"
|
|
775
|
+
| "_renderDiagnosticsEnabled"
|
|
776
|
+
| "_handlerStart"
|
|
777
|
+
| "_tracing"
|
|
361
778
|
| "_basename"
|
|
779
|
+
| "_routerId"
|
|
362
780
|
| "_setStatus"
|
|
781
|
+
| "_rotateStateCookie"
|
|
782
|
+
| "_setKeepCacheDirective"
|
|
363
783
|
| "_variables"
|
|
364
784
|
| "_classifiedRoute"
|
|
785
|
+
| "_requestMode"
|
|
786
|
+
| "_cacheSignal"
|
|
787
|
+
| "_dynamic"
|
|
365
788
|
| "res"
|
|
366
789
|
>;
|
|
367
790
|
|
|
791
|
+
/**
|
|
792
|
+
* Marker for a waitUntil-scheduled fn whose task promise must NOT enter
|
|
793
|
+
* _pendingBackgroundTasks. Used by the PPR shell capture for its own task:
|
|
794
|
+
* the capture's pre-render write barrier settles that list, so tracking the
|
|
795
|
+
* capture itself would make the drain wait on its own (still-running) promise.
|
|
796
|
+
* @internal
|
|
797
|
+
*/
|
|
798
|
+
export const UNTRACKED_BACKGROUND_TASK: unique symbol = Symbol.for(
|
|
799
|
+
"rango.untrackedBackgroundTask",
|
|
800
|
+
);
|
|
801
|
+
|
|
368
802
|
// AsyncLocalStorage instance for request context
|
|
369
803
|
const requestContextStorage = new AsyncLocalStorage<RequestContext<any>>();
|
|
370
804
|
|
|
@@ -413,6 +847,7 @@ export function _getRequestContext<TEnv = DefaultEnv>():
|
|
|
413
847
|
export function setRequestContextParams(
|
|
414
848
|
params: Record<string, string>,
|
|
415
849
|
routeName?: string,
|
|
850
|
+
routeMap?: Record<string, string>,
|
|
416
851
|
): void {
|
|
417
852
|
const ctx = requestContextStorage.getStore();
|
|
418
853
|
if (ctx) {
|
|
@@ -425,12 +860,16 @@ export function setRequestContextParams(
|
|
|
425
860
|
: undefined
|
|
426
861
|
) as DefaultRouteName | undefined;
|
|
427
862
|
}
|
|
428
|
-
// Update reverse with scoped resolution now that route is known
|
|
863
|
+
// Update reverse with scoped resolution now that route is known. Production
|
|
864
|
+
// omits routeMap and uses the global map (routes are registered globally);
|
|
865
|
+
// the testing primitives (renderToFlightString/renderServerTree) pass a
|
|
866
|
+
// scoped routeMap so `ctx.reverse` is not order-dependent on whatever router
|
|
867
|
+
// registered last.
|
|
429
868
|
ctx.reverse = createReverseFunction(
|
|
430
|
-
getGlobalRouteMap(),
|
|
869
|
+
routeMap ?? getGlobalRouteMap(),
|
|
431
870
|
routeName,
|
|
432
871
|
params,
|
|
433
|
-
routeName ? isRouteRootScoped(routeName) : undefined,
|
|
872
|
+
routeName ? isRouteRootScoped(routeName, ctx._routerId) : undefined,
|
|
434
873
|
);
|
|
435
874
|
}
|
|
436
875
|
}
|
|
@@ -443,11 +882,17 @@ export function setRequestContextParams(
|
|
|
443
882
|
*/
|
|
444
883
|
export function setRequestContextPrevRouteKey(
|
|
445
884
|
prevRouteKey: string | undefined,
|
|
885
|
+
currentUrl?: URL,
|
|
886
|
+
currentParams?: Record<string, string>,
|
|
446
887
|
): void {
|
|
447
888
|
const ctx = requestContextStorage.getStore();
|
|
448
|
-
if (ctx
|
|
449
|
-
|
|
450
|
-
}
|
|
889
|
+
if (!ctx) return;
|
|
890
|
+
if (prevRouteKey !== undefined) ctx._prevRouteKey = prevRouteKey;
|
|
891
|
+
// Source URL/params for the transition({ when }) gate (effectiveFromUrl /
|
|
892
|
+
// effectiveFromMatch.params from the navigation snapshot). Same write point as
|
|
893
|
+
// _prevRouteKey, which doubles as fromRouteName.
|
|
894
|
+
if (currentUrl !== undefined) ctx._gateCurrentUrl = currentUrl;
|
|
895
|
+
if (currentParams !== undefined) ctx._gateCurrentParams = currentParams;
|
|
451
896
|
}
|
|
452
897
|
|
|
453
898
|
/**
|
|
@@ -461,16 +906,6 @@ export function getLocationState(): LocationStateEntry[] | undefined {
|
|
|
461
906
|
return ctx?._locationState;
|
|
462
907
|
}
|
|
463
908
|
|
|
464
|
-
/**
|
|
465
|
-
* Get the current request context, throwing if not available
|
|
466
|
-
* @deprecated Use getRequestContext() directly — it now throws if outside context
|
|
467
|
-
*/
|
|
468
|
-
export function requireRequestContext<
|
|
469
|
-
TEnv = DefaultEnv,
|
|
470
|
-
>(): RequestContext<TEnv> {
|
|
471
|
-
return getRequestContext<TEnv>();
|
|
472
|
-
}
|
|
473
|
-
|
|
474
909
|
export type { ExecutionContext };
|
|
475
910
|
|
|
476
911
|
/**
|
|
@@ -485,6 +920,16 @@ export interface CreateRequestContextOptions<TEnv> {
|
|
|
485
920
|
initialResponse?: Response;
|
|
486
921
|
/** Optional cache store for segment caching (used by CacheScope) */
|
|
487
922
|
cacheStore?: SegmentCacheStore;
|
|
923
|
+
/**
|
|
924
|
+
* Compiled `cache.searchParams` filter from the resolved handler cache
|
|
925
|
+
* config (handler.ts). Stored as _searchParamsFilter.
|
|
926
|
+
*/
|
|
927
|
+
searchParamsFilter?: import("../cache/search-params-filter.js").SearchParamsFilter;
|
|
928
|
+
/**
|
|
929
|
+
* Handler-owned registry of explicit per-scope stores for cross-store tag
|
|
930
|
+
* invalidation. Created once per handler, reused across requests.
|
|
931
|
+
*/
|
|
932
|
+
explicitTaggedStores?: Set<SegmentCacheStore>;
|
|
488
933
|
/** Optional cache profiles for "use cache" resolution (per-router) */
|
|
489
934
|
cacheProfiles?: Record<
|
|
490
935
|
string,
|
|
@@ -492,8 +937,14 @@ export interface CreateRequestContextOptions<TEnv> {
|
|
|
492
937
|
>;
|
|
493
938
|
/** Optional Cloudflare execution context for waitUntil support */
|
|
494
939
|
executionContext?: ExecutionContext;
|
|
940
|
+
/** Build-time render/capture request marker. Defaults to false. */
|
|
941
|
+
build?: boolean;
|
|
495
942
|
/** Optional theme configuration (enables ctx.theme and ctx.setTheme) */
|
|
496
943
|
themeConfig?: ResolvedThemeConfig | null;
|
|
944
|
+
/** Resolved rango state cookie name, for the server seat of invalidateClientCache(). */
|
|
945
|
+
stateCookieName?: string;
|
|
946
|
+
/** Build version, used as the prefix of a server-rotated rango state value. */
|
|
947
|
+
version?: string;
|
|
497
948
|
}
|
|
498
949
|
|
|
499
950
|
/**
|
|
@@ -514,15 +965,19 @@ export function createRequestContext<TEnv>(
|
|
|
514
965
|
variables,
|
|
515
966
|
initialResponse,
|
|
516
967
|
cacheStore,
|
|
968
|
+
searchParamsFilter,
|
|
969
|
+
explicitTaggedStores,
|
|
517
970
|
cacheProfiles,
|
|
518
971
|
executionContext,
|
|
972
|
+
build = false,
|
|
519
973
|
themeConfig,
|
|
974
|
+
stateCookieName,
|
|
975
|
+
version: stateVersion,
|
|
520
976
|
} = options;
|
|
521
977
|
const cookieHeader = request.headers.get("Cookie");
|
|
978
|
+
let rangoStateRotated = false;
|
|
522
979
|
let parsedCookies: Record<string, string> | null = null;
|
|
523
980
|
|
|
524
|
-
// Create stub response for collecting headers/cookies.
|
|
525
|
-
// All cookie/header mutations go here; cookie reads derive from it.
|
|
526
981
|
let stubResponse = initialResponse
|
|
527
982
|
? new Response(null, {
|
|
528
983
|
status: initialResponse.status,
|
|
@@ -531,11 +986,53 @@ export function createRequestContext<TEnv>(
|
|
|
531
986
|
})
|
|
532
987
|
: new Response(null, { status: 200 });
|
|
533
988
|
|
|
534
|
-
//
|
|
989
|
+
// The #713 choke point: `rawStubHeaders` is the stub's REAL Headers; the
|
|
990
|
+
// proxy below is the only view reachable from consumer code, and its
|
|
991
|
+
// mutating methods consult the cached-scope guard first. shadowStubHeaders
|
|
992
|
+
// shadows `headers` on the stub Response INSTANCE (a real Response, not a
|
|
993
|
+
// facade — safe to hand to the platform), so every surface that ends in a
|
|
994
|
+
// stub-header mutation — ctx.header/setCookie/deleteCookie, ctx.setTheme,
|
|
995
|
+
// the handler ctx.headers proxy, and raw `ctx.res.headers.set(...)` — is
|
|
996
|
+
// guarded at the mutation itself, not per enumerated wrapper. Guard-exempt
|
|
997
|
+
// internal writers (_rotateStateCookie, _setKeepCacheDirective — serve
|
|
998
|
+
// machinery, documented callable from loaders/during capture) write to
|
|
999
|
+
// rawStubHeaders directly. The serve/commit path's stub reads and its
|
|
1000
|
+
// Set-Cookie drain (rsc/helpers.ts) run outside any latched funnel scope,
|
|
1001
|
+
// where assertCachedHeaderWriteAllowed is a no-op.
|
|
1002
|
+
let rawStubHeaders = stubResponse.headers;
|
|
1003
|
+
const guardedStubHeaders: Headers = new Proxy(new Headers(), {
|
|
1004
|
+
get(_target, prop) {
|
|
1005
|
+
const raw = rawStubHeaders;
|
|
1006
|
+
const value = Reflect.get(raw, prop) as unknown;
|
|
1007
|
+
if (typeof value !== "function") return value;
|
|
1008
|
+
if (prop === "set" || prop === "append" || prop === "delete") {
|
|
1009
|
+
return (...args: unknown[]) => {
|
|
1010
|
+
assertCachedHeaderWriteAllowed("response headers", prop);
|
|
1011
|
+
return (value as (...a: unknown[]) => unknown).apply(raw, args);
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
return (value as (...a: unknown[]) => unknown).bind(raw);
|
|
1015
|
+
},
|
|
1016
|
+
});
|
|
1017
|
+
const shadowStubHeaders = (res: Response): void => {
|
|
1018
|
+
Object.defineProperty(res, "headers", {
|
|
1019
|
+
value: guardedStubHeaders,
|
|
1020
|
+
enumerable: true,
|
|
1021
|
+
configurable: true,
|
|
1022
|
+
});
|
|
1023
|
+
};
|
|
1024
|
+
shadowStubHeaders(stubResponse);
|
|
1025
|
+
// Rebuild the stub with a new status, re-shadowing the fresh instance
|
|
1026
|
+
// (the Response constructor copies rawStubHeaders into new raw Headers).
|
|
1027
|
+
const replaceStubStatus = (status: number): void => {
|
|
1028
|
+
stubResponse = new Response(null, { status, headers: rawStubHeaders });
|
|
1029
|
+
rawStubHeaders = stubResponse.headers;
|
|
1030
|
+
shadowStubHeaders(stubResponse);
|
|
1031
|
+
};
|
|
1032
|
+
|
|
535
1033
|
const handleStore = createHandleStore();
|
|
536
1034
|
const loaderPromises = new Map<string, Promise<any>>();
|
|
537
1035
|
|
|
538
|
-
// Lazy parse cookies from the original Cookie header
|
|
539
1036
|
const getParsedCookies = (): Record<string, string> => {
|
|
540
1037
|
if (!parsedCookies) {
|
|
541
1038
|
parsedCookies = parseCookiesFromHeader(cookieHeader);
|
|
@@ -543,7 +1040,6 @@ export function createRequestContext<TEnv>(
|
|
|
543
1040
|
return parsedCookies;
|
|
544
1041
|
};
|
|
545
1042
|
|
|
546
|
-
// Cached response cookie mutations — invalidated on setCookie/deleteCookie/setTheme
|
|
547
1043
|
let responseCookieCache: Map<string, string | null> | null = null;
|
|
548
1044
|
const getResponseCookies = (): Map<string, string | null> => {
|
|
549
1045
|
if (!responseCookieCache) {
|
|
@@ -555,20 +1051,15 @@ export function createRequestContext<TEnv>(
|
|
|
555
1051
|
responseCookieCache = null;
|
|
556
1052
|
};
|
|
557
1053
|
|
|
558
|
-
// Guard
|
|
559
|
-
//
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
`On cache hit the handler is skipped, so this side effect would be lost. ` +
|
|
565
|
-
`Move ctx.${methodName}() to a middleware or layout outside the cache() scope.`,
|
|
566
|
-
);
|
|
567
|
-
}
|
|
1054
|
+
// Guard for the two response-write surfaces that are NOT Headers mutations
|
|
1055
|
+
// (setStatus rebuilds the stub Response, onResponse registers a callback) —
|
|
1056
|
+
// these can't ride the guarded-headers choke point above, so they stay
|
|
1057
|
+
// enumerated. Same unified #713 guard, same message family.
|
|
1058
|
+
function assertResponseWriteAllowed(methodName: string): void {
|
|
1059
|
+
assertCachedHeaderWriteAllowed("ctx", methodName);
|
|
568
1060
|
}
|
|
569
1061
|
|
|
570
|
-
//
|
|
571
|
-
// The stub IS the source of truth for same-request mutations.
|
|
1062
|
+
// Response stub Set-Cookie wins, then original header (source of truth for mutations).
|
|
572
1063
|
const effectiveCookie = (name: string): string | undefined => {
|
|
573
1064
|
const mutations = getResponseCookies();
|
|
574
1065
|
if (mutations.has(name)) {
|
|
@@ -578,14 +1069,11 @@ export function createRequestContext<TEnv>(
|
|
|
578
1069
|
return getParsedCookies()[name];
|
|
579
1070
|
};
|
|
580
1071
|
|
|
581
|
-
// Theme helpers (only used when themeConfig is provided)
|
|
582
1072
|
const getTheme = (): Theme | undefined => {
|
|
583
1073
|
if (!themeConfig) return undefined;
|
|
584
1074
|
|
|
585
|
-
// Use overlay-aware read so setTheme() in the same request is reflected
|
|
586
1075
|
const stored = effectiveCookie(themeConfig.storageKey);
|
|
587
1076
|
if (stored) {
|
|
588
|
-
// Validate stored value
|
|
589
1077
|
if (stored === "system" && themeConfig.enableSystem) {
|
|
590
1078
|
return "system";
|
|
591
1079
|
}
|
|
@@ -599,15 +1087,15 @@ export function createRequestContext<TEnv>(
|
|
|
599
1087
|
const setTheme = (theme: Theme): void => {
|
|
600
1088
|
if (!themeConfig) return;
|
|
601
1089
|
|
|
602
|
-
//
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
1090
|
+
// Shared guard (isValidTheme): reject any value not in the configured theme
|
|
1091
|
+
// set, AND reject "system" when system detection is off — a cookie of
|
|
1092
|
+
// theme=system with enableSystem:false would re-apply a bogus class="system"
|
|
1093
|
+
// on the next SSR.
|
|
1094
|
+
if (!isValidTheme(theme, themeConfig)) {
|
|
1095
|
+
warnInvalidTheme(theme, themeConfig);
|
|
607
1096
|
return;
|
|
608
1097
|
}
|
|
609
1098
|
|
|
610
|
-
// Write to stub — effectiveCookie() will pick it up on next read
|
|
611
1099
|
stubResponse.headers.append(
|
|
612
1100
|
"Set-Cookie",
|
|
613
1101
|
serializeCookieValue(themeConfig.storageKey, theme, {
|
|
@@ -619,10 +1107,8 @@ export function createRequestContext<TEnv>(
|
|
|
619
1107
|
invalidateResponseCookieCache();
|
|
620
1108
|
};
|
|
621
1109
|
|
|
622
|
-
// Strip internal _rsc* params so userland sees a clean URL.
|
|
623
1110
|
const cleanUrl = stripInternalParams(url);
|
|
624
1111
|
|
|
625
|
-
// Build the context object first (without use), then add use
|
|
626
1112
|
const ctx: RequestContext<TEnv> = {
|
|
627
1113
|
env,
|
|
628
1114
|
request,
|
|
@@ -631,6 +1117,16 @@ export function createRequestContext<TEnv>(
|
|
|
631
1117
|
pathname: url.pathname,
|
|
632
1118
|
searchParams: cleanUrl.searchParams,
|
|
633
1119
|
_variables: variables,
|
|
1120
|
+
build,
|
|
1121
|
+
dynamic(): void {
|
|
1122
|
+
ctx._dynamic = true;
|
|
1123
|
+
// A dynamic() render is always live (never a shell HIT), so its handler
|
|
1124
|
+
// header writes are deterministic — clear the ppr latch to re-permit them
|
|
1125
|
+
// (#735). No-op from middleware (outside the funnel scope) or on non-ppr
|
|
1126
|
+
// routes; cache() latches are left alone.
|
|
1127
|
+
clearPprHeaderScope();
|
|
1128
|
+
},
|
|
1129
|
+
_dynamic: false,
|
|
634
1130
|
get: ((keyOrVar: any) => {
|
|
635
1131
|
if (isNonCacheable(variables, keyOrVar) && isInsideCacheScope()) {
|
|
636
1132
|
throw new Error(
|
|
@@ -681,7 +1177,6 @@ export function createRequestContext<TEnv>(
|
|
|
681
1177
|
|
|
682
1178
|
setCookie(name: string, value: string, options?: CookieOptions): void {
|
|
683
1179
|
assertNotInsideCacheExec(ctx, "setCookie");
|
|
684
|
-
assertNotInsideCacheScopeALS("setCookie");
|
|
685
1180
|
stubResponse.headers.append(
|
|
686
1181
|
"Set-Cookie",
|
|
687
1182
|
serializeCookieValue(name, value, options),
|
|
@@ -694,7 +1189,6 @@ export function createRequestContext<TEnv>(
|
|
|
694
1189
|
options?: Pick<CookieOptions, "domain" | "path">,
|
|
695
1190
|
): void {
|
|
696
1191
|
assertNotInsideCacheExec(ctx, "deleteCookie");
|
|
697
|
-
assertNotInsideCacheScopeALS("deleteCookie");
|
|
698
1192
|
stubResponse.headers.append(
|
|
699
1193
|
"Set-Cookie",
|
|
700
1194
|
serializeCookieValue(name, "", { ...options, maxAge: 0 }),
|
|
@@ -704,54 +1198,113 @@ export function createRequestContext<TEnv>(
|
|
|
704
1198
|
|
|
705
1199
|
header(name: string, value: string): void {
|
|
706
1200
|
assertNotInsideCacheExec(ctx, "header");
|
|
707
|
-
assertNotInsideCacheScopeALS("header");
|
|
708
1201
|
stubResponse.headers.set(name, value);
|
|
709
1202
|
},
|
|
710
1203
|
|
|
1204
|
+
// Rotate the rango state cookie for the responding client (the server seat
|
|
1205
|
+
// of invalidateClientCache). Writes ONE Set-Cookie per request with the
|
|
1206
|
+
// value {version}:{timestamp}; the `:` stays raw (the cookie-name.ts
|
|
1207
|
+
// serializer), not the URL-encoded form serializeCookieValue would produce.
|
|
1208
|
+
// The timestamp is strictly greater than the client's current one (inbound
|
|
1209
|
+
// X-Rango-State), so a same-millisecond server rotation still differs from
|
|
1210
|
+
// the client value and the divergence observer fires.
|
|
1211
|
+
_rotateStateCookie(): void {
|
|
1212
|
+
if (rangoStateRotated) return;
|
|
1213
|
+
rangoStateRotated = true;
|
|
1214
|
+
if (!stateCookieName) return;
|
|
1215
|
+
// The client's current value, for the monotonic guard: prefer the
|
|
1216
|
+
// X-Rango-State header (router navigation/prefetch fetches send it), but
|
|
1217
|
+
// fall back to the request's rango state cookie — action POSTs / plain
|
|
1218
|
+
// app fetch()s carry no router header yet DO send the cookie. Without the
|
|
1219
|
+
// fallback, prevTs stays 0 and a same-ms mint can equal the client value,
|
|
1220
|
+
// leaving the divergence observer silent. `|| null` so an empty header
|
|
1221
|
+
// ('' from proxy normalization) falls through instead of short-circuiting.
|
|
1222
|
+
// getRawCookieValue reads the cookie undecoded (the wire value
|
|
1223
|
+
// decodeStateValue decodes exactly once) AND is the same parser the client
|
|
1224
|
+
// mirror uses, so both seats read the same jar entry.
|
|
1225
|
+
const prevRaw =
|
|
1226
|
+
(request.headers.get("x-rango-state") || null) ??
|
|
1227
|
+
getRawCookieValue(cookieHeader, stateCookieName);
|
|
1228
|
+
const value = mintStateValue(stateVersion ?? "0", prevRaw);
|
|
1229
|
+
// rawStubHeaders: guard-exempt internal writer — invalidateClientCache()
|
|
1230
|
+
// is documented callable from loaders and during shell capture.
|
|
1231
|
+
rawStubHeaders.append(
|
|
1232
|
+
"Set-Cookie",
|
|
1233
|
+
serializeStateCookie(stateCookieName, value, url.protocol === "https:"),
|
|
1234
|
+
);
|
|
1235
|
+
invalidateResponseCookieCache();
|
|
1236
|
+
},
|
|
1237
|
+
|
|
1238
|
+
// Set the keepClientCache() directive header. The action bridge reads it on
|
|
1239
|
+
// the response and suppresses its automatic invalidation. `.set` makes this
|
|
1240
|
+
// idempotent (one header regardless of call count). rawStubHeaders:
|
|
1241
|
+
// guard-exempt internal writer.
|
|
1242
|
+
_setKeepCacheDirective(): void {
|
|
1243
|
+
rawStubHeaders.set(KEEP_CACHE_HEADER, "1");
|
|
1244
|
+
},
|
|
1245
|
+
|
|
711
1246
|
setStatus(status: number): void {
|
|
712
1247
|
assertNotInsideCacheExec(ctx, "setStatus");
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
status,
|
|
716
|
-
headers: stubResponse.headers,
|
|
717
|
-
});
|
|
1248
|
+
assertResponseWriteAllowed("setStatus");
|
|
1249
|
+
replaceStubStatus(status);
|
|
718
1250
|
},
|
|
719
1251
|
|
|
720
1252
|
_setStatus(status: number): void {
|
|
721
|
-
|
|
722
|
-
status,
|
|
723
|
-
headers: stubResponse.headers,
|
|
724
|
-
});
|
|
1253
|
+
replaceStubStatus(status);
|
|
725
1254
|
},
|
|
726
1255
|
|
|
727
|
-
// Placeholder - will be replaced below
|
|
728
1256
|
use: null as any,
|
|
729
1257
|
|
|
730
1258
|
method: request.method,
|
|
731
1259
|
|
|
732
1260
|
_handleStore: handleStore,
|
|
1261
|
+
_transitionWhen: [],
|
|
733
1262
|
_cacheStore: cacheStore,
|
|
1263
|
+
_searchParamsFilter: searchParamsFilter,
|
|
1264
|
+
_explicitTaggedStores: explicitTaggedStores,
|
|
1265
|
+
_requestTags: new Set<string>(),
|
|
734
1266
|
_cacheProfiles: cacheProfiles,
|
|
735
1267
|
|
|
736
1268
|
waitUntil(fn: () => Promise<void>): void {
|
|
1269
|
+
if (ctx.build) return;
|
|
1270
|
+
// Wrap in Promise.resolve().then(fn) so a SYNCHRONOUS throw in a
|
|
1271
|
+
// non-async callback becomes a rejected promise handed to the host's
|
|
1272
|
+
// waitUntil (logged as a background failure), instead of escaping into
|
|
1273
|
+
// the request flow. Mirrors fireAndForgetWaitUntil's deferral.
|
|
1274
|
+
const task = Promise.resolve().then(fn);
|
|
1275
|
+
// Track the task promise so the PPR shell capture can settle the
|
|
1276
|
+
// foreground's deferred cache writes before its own match/render (the
|
|
1277
|
+
// ordering edge; see _pendingBackgroundTasks). The capture task itself
|
|
1278
|
+
// opts out via the marker — the drain must never await its own promise.
|
|
1279
|
+
if (
|
|
1280
|
+
!(fn as { [UNTRACKED_BACKGROUND_TASK]?: boolean })[
|
|
1281
|
+
UNTRACKED_BACKGROUND_TASK
|
|
1282
|
+
]
|
|
1283
|
+
) {
|
|
1284
|
+
ctx._pendingBackgroundTasks?.push(task);
|
|
1285
|
+
}
|
|
737
1286
|
if (executionContext?.waitUntil) {
|
|
738
|
-
executionContext.waitUntil(
|
|
1287
|
+
executionContext.waitUntil(task);
|
|
739
1288
|
} else {
|
|
740
|
-
|
|
1289
|
+
// Node/dev fallback: fire-and-forget with error logging (the same
|
|
1290
|
+
// policy fireAndForgetWaitUntil applies).
|
|
1291
|
+
task.catch((err) =>
|
|
1292
|
+
console.error("[waitUntil] Background task failed:", err),
|
|
1293
|
+
);
|
|
741
1294
|
}
|
|
742
1295
|
},
|
|
743
1296
|
|
|
744
1297
|
executionContext,
|
|
745
1298
|
|
|
746
1299
|
_onResponseCallbacks: [],
|
|
1300
|
+
_pendingBackgroundTasks: [],
|
|
747
1301
|
|
|
748
1302
|
onResponse(callback: (response: Response) => Response): void {
|
|
749
1303
|
assertNotInsideCacheExec(ctx, "onResponse");
|
|
750
|
-
|
|
1304
|
+
assertResponseWriteAllowed("onResponse");
|
|
751
1305
|
this._onResponseCallbacks.push(callback);
|
|
752
1306
|
},
|
|
753
1307
|
|
|
754
|
-
// Theme properties (only set when themeConfig is provided)
|
|
755
1308
|
get theme() {
|
|
756
1309
|
return themeConfig ? getTheme() : undefined;
|
|
757
1310
|
},
|
|
@@ -774,20 +1327,68 @@ export function createRequestContext<TEnv>(
|
|
|
774
1327
|
|
|
775
1328
|
_reportedErrors: new WeakSet<object>(),
|
|
776
1329
|
_metricsStore: undefined,
|
|
1330
|
+
_renderForeground: undefined,
|
|
1331
|
+
_activeRoutine: undefined,
|
|
1332
|
+
_renderDiagnosticsEnabled: undefined,
|
|
1333
|
+
_handlerStart: undefined,
|
|
777
1334
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
_resolveRenderBarrier: null as any, // set below
|
|
1335
|
+
_renderBarrier: null as any,
|
|
1336
|
+
_resolveRenderBarrier: null as any,
|
|
781
1337
|
_renderBarrierSegmentOrder: undefined,
|
|
782
1338
|
|
|
783
1339
|
reverse: createReverseFunction(getGlobalRouteMap(), undefined, {}),
|
|
784
1340
|
};
|
|
785
1341
|
|
|
786
|
-
|
|
787
|
-
|
|
1342
|
+
wireRenderBarrier(ctx, handleStore);
|
|
1343
|
+
|
|
1344
|
+
ctx.use = createUseFunction({
|
|
1345
|
+
handleStore,
|
|
1346
|
+
loaderPromises,
|
|
1347
|
+
getContext: () => ctx,
|
|
1348
|
+
});
|
|
1349
|
+
|
|
1350
|
+
(ctx as any)[NOCACHE_SYMBOL] = true;
|
|
1351
|
+
return ctx;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* Wire a fresh render barrier onto `ctx`, closure-bound to THIS ctx and THIS
|
|
1356
|
+
* handle store. Called by createRequestContext for every fresh context, and by
|
|
1357
|
+
* deriveShellCaptureContext (rsc/shell-capture.ts) for the PPR capture's
|
|
1358
|
+
* derived context.
|
|
1359
|
+
*
|
|
1360
|
+
* The derived-context call is load-bearing (issue #684, plan 009): the capture
|
|
1361
|
+
* context is `Object.create(reqCtx)`, so without its own wiring every
|
|
1362
|
+
* `_renderBarrier*` read fell through the prototype to the FOREGROUND
|
|
1363
|
+
* request's barrier — whose getter and resolver are closure-bound to the
|
|
1364
|
+
* foreground ctx and its handle store, and whose resolver no-ops once
|
|
1365
|
+
* resolved. A bake-lane loader's `await ctx.rendered()` during capture then
|
|
1366
|
+
* resolved instantly against the foreground's barrier and `ctx.use(handle)`
|
|
1367
|
+
* read the foreground's handle snapshot; the capture's fresh `_handleStore`
|
|
1368
|
+
* was invisible, so foreground per-request handle data could bake into the
|
|
1369
|
+
* shared shell.
|
|
1370
|
+
*/
|
|
1371
|
+
export function wireRenderBarrier(
|
|
1372
|
+
ctx: RequestContext<any, any>,
|
|
1373
|
+
handleStore: HandleStore,
|
|
1374
|
+
): void {
|
|
1375
|
+
// Reset the whole barrier family as OWN properties. No-op for a fresh
|
|
1376
|
+
// context; for the derived capture context this shadows the foreground's
|
|
1377
|
+
// resolved state so the capture runs its own barrier lifecycle. In
|
|
1378
|
+
// particular _treeHasStreaming must be recomputed for the CAPTURE's tree
|
|
1379
|
+
// (cache-lookup/segment-resolution only set it when undefined): an
|
|
1380
|
+
// inherited `true` made a capture-lane rendered() seal the capture's fresh
|
|
1381
|
+
// store at loader start and pair it with the foreground's segment order.
|
|
1382
|
+
ctx._renderBarrierSegmentOrder = undefined;
|
|
1383
|
+
ctx._renderBarrierWaiters = undefined;
|
|
1384
|
+
ctx._renderBarrierHandleSnapshot = undefined;
|
|
1385
|
+
ctx._renderBarrierGuardClosed = undefined;
|
|
1386
|
+
ctx._handlerLoaderDeps = undefined;
|
|
1387
|
+
ctx._treeHasStreaming = undefined;
|
|
1388
|
+
|
|
1389
|
+
// Lazy allocation: only create the Promise when a loader calls rendered().
|
|
788
1390
|
let barrierResolved = false;
|
|
789
1391
|
let resolveBarrier: (() => void) | undefined;
|
|
790
|
-
ctx._renderBarrier = null as any; // lazy — created on first access
|
|
791
1392
|
ctx._resolveRenderBarrier = (
|
|
792
1393
|
segments: Array<{ type: string; id: string }>,
|
|
793
1394
|
) => {
|
|
@@ -797,21 +1398,29 @@ export function createRequestContext<TEnv>(
|
|
|
797
1398
|
.filter((s) => s.type !== "loader")
|
|
798
1399
|
.map((s) => s.id);
|
|
799
1400
|
ctx._renderBarrierSegmentOrder = segOrder;
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
ctx.
|
|
1401
|
+
|
|
1402
|
+
const closeGuard = () => {
|
|
1403
|
+
ctx._renderBarrierWaiters = undefined;
|
|
1404
|
+
ctx._handlerLoaderDeps = undefined;
|
|
1405
|
+
ctx._renderBarrierGuardClosed = true;
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1408
|
+
if (ctx._treeHasStreaming) {
|
|
1409
|
+
handleStore.settled.then(closeGuard);
|
|
1410
|
+
} else {
|
|
1411
|
+
ctx._renderBarrierHandleSnapshot = buildHandleSnapshot(
|
|
1412
|
+
handleStore,
|
|
1413
|
+
segOrder,
|
|
1414
|
+
);
|
|
1415
|
+
closeGuard();
|
|
1416
|
+
}
|
|
808
1417
|
if (resolveBarrier) resolveBarrier();
|
|
809
1418
|
};
|
|
1419
|
+
// defineProperty, not assignment: on a derived context the prototype's
|
|
1420
|
+
// _renderBarrier may already be a non-writable data property (the getter
|
|
1421
|
+
// pins it after first access), which would reject a plain assignment.
|
|
810
1422
|
Object.defineProperty(ctx, "_renderBarrier", {
|
|
811
1423
|
get() {
|
|
812
|
-
// Barrier already resolved (cache/prerender hit) or first lazy access.
|
|
813
|
-
// Either way, replace the getter with a concrete value to avoid
|
|
814
|
-
// repeated Promise.resolve() allocations on subsequent reads.
|
|
815
1424
|
const p = barrierResolved
|
|
816
1425
|
? Promise.resolve()
|
|
817
1426
|
: new Promise<void>((resolve) => {
|
|
@@ -826,33 +1435,25 @@ export function createRequestContext<TEnv>(
|
|
|
826
1435
|
},
|
|
827
1436
|
configurable: true,
|
|
828
1437
|
});
|
|
1438
|
+
}
|
|
829
1439
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
});
|
|
1440
|
+
// Capture the Max-Age value so it can be parsed numerically. A leading zero
|
|
1441
|
+
// (Max-Age=05) is a non-zero lifetime, not a deletion; only a value that parses
|
|
1442
|
+
// to <= 0 marks a cookie for deletion. Pattern-matching a leading "0" misread
|
|
1443
|
+
// zero-prefixed values like 05 / 010 as deletions.
|
|
1444
|
+
const MAX_AGE_RE = /;\s*Max-Age\s*=\s*(-?\d+)/i;
|
|
836
1445
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
return
|
|
1446
|
+
function isCookieDeletion(header: string): boolean {
|
|
1447
|
+
const m = MAX_AGE_RE.exec(header);
|
|
1448
|
+
if (!m) return false;
|
|
1449
|
+
return Number(m[1]) <= 0;
|
|
840
1450
|
}
|
|
841
1451
|
|
|
842
|
-
/**
|
|
843
|
-
* Parse Set-Cookie headers from a response into effective cookie state.
|
|
844
|
-
* Returns a map of cookie name -> value (string) or name -> null (deleted).
|
|
845
|
-
* Last-write-wins: later Set-Cookie entries for the same name overwrite earlier ones.
|
|
846
|
-
* Max-Age=0 is treated as a delete.
|
|
847
|
-
*/
|
|
848
|
-
const MAX_AGE_ZERO_RE = /;\s*Max-Age\s*=\s*0/i;
|
|
849
|
-
|
|
850
1452
|
function parseResponseCookies(response: Response): Map<string, string | null> {
|
|
851
1453
|
const result = new Map<string, string | null>();
|
|
852
1454
|
const setCookies = response.headers.getSetCookie();
|
|
853
1455
|
|
|
854
1456
|
for (const header of setCookies) {
|
|
855
|
-
// First segment before ';' is the name=value pair
|
|
856
1457
|
const semiIdx = header.indexOf(";");
|
|
857
1458
|
const pair = semiIdx === -1 ? header : header.substring(0, semiIdx);
|
|
858
1459
|
const eqIdx = pair.indexOf("=");
|
|
@@ -864,62 +1465,78 @@ function parseResponseCookies(response: Response): Map<string, string | null> {
|
|
|
864
1465
|
name = decodeURIComponent(pair.substring(0, eqIdx).trim());
|
|
865
1466
|
value = decodeURIComponent(pair.substring(eqIdx + 1).trim());
|
|
866
1467
|
} catch {
|
|
867
|
-
// Malformed encoding — skip this entry
|
|
868
1468
|
continue;
|
|
869
1469
|
}
|
|
870
1470
|
|
|
871
|
-
|
|
872
|
-
const isDeleted = MAX_AGE_ZERO_RE.test(header);
|
|
1471
|
+
const isDeleted = isCookieDeletion(header);
|
|
873
1472
|
result.set(name, isDeleted ? null : value);
|
|
874
1473
|
}
|
|
875
1474
|
|
|
876
1475
|
return result;
|
|
877
1476
|
}
|
|
878
1477
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
cookies[name] = decodeURIComponent(raw);
|
|
896
|
-
} catch {
|
|
897
|
-
// Malformed percent-encoded value (e.g. %zz, %2) - fall back to raw value
|
|
898
|
-
cookies[name] = raw;
|
|
899
|
-
}
|
|
1478
|
+
// Re-exported for unit tests and the existing import path. The implementation
|
|
1479
|
+
// lives in the dependency-free ./cookie-parse leaf so consumers (e.g. the host
|
|
1480
|
+
// dispatcher) can share it without pulling this module's request-context graph.
|
|
1481
|
+
export { parseCookiesFromHeader };
|
|
1482
|
+
|
|
1483
|
+
/** Reject CR/LF/;/,/whitespace/control so raw attribute interpolation cannot inject. */
|
|
1484
|
+
function assertSafeCookieAttribute(
|
|
1485
|
+
value: string,
|
|
1486
|
+
label: "domain" | "path",
|
|
1487
|
+
): void {
|
|
1488
|
+
for (let i = 0; i < value.length; i++) {
|
|
1489
|
+
const code = value.charCodeAt(i);
|
|
1490
|
+
if (code <= 0x20 || code === 0x7f || value[i] === ";" || value[i] === ",") {
|
|
1491
|
+
throw new Error(
|
|
1492
|
+
label === "domain" ? "invalid cookie domain" : "invalid cookie path",
|
|
1493
|
+
);
|
|
900
1494
|
}
|
|
901
1495
|
}
|
|
902
|
-
|
|
903
|
-
return cookies;
|
|
904
1496
|
}
|
|
905
1497
|
|
|
906
|
-
|
|
907
|
-
* Serialize a cookie for Set-Cookie header
|
|
908
|
-
*/
|
|
909
|
-
function serializeCookieValue(
|
|
1498
|
+
export function serializeCookieValue(
|
|
910
1499
|
name: string,
|
|
911
1500
|
value: string,
|
|
912
1501
|
options: CookieOptions = {},
|
|
913
1502
|
): string {
|
|
914
1503
|
let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
|
|
915
1504
|
|
|
916
|
-
if (options.domain)
|
|
917
|
-
|
|
918
|
-
|
|
1505
|
+
if (options.domain) {
|
|
1506
|
+
assertSafeCookieAttribute(options.domain, "domain");
|
|
1507
|
+
cookie += `; Domain=${options.domain}`;
|
|
1508
|
+
}
|
|
1509
|
+
if (options.path) {
|
|
1510
|
+
if (!options.path.startsWith("/")) {
|
|
1511
|
+
throw new Error("invalid cookie path");
|
|
1512
|
+
}
|
|
1513
|
+
assertSafeCookieAttribute(options.path, "path");
|
|
1514
|
+
cookie += `; Path=${options.path}`;
|
|
1515
|
+
}
|
|
1516
|
+
if (options.maxAge !== undefined) {
|
|
1517
|
+
// Safe integer: Number.isInteger(1e21) is true but stringifies as "1e+21",
|
|
1518
|
+
// which is invalid Max-Age wire syntax. Number.isSafeInteger rejects that.
|
|
1519
|
+
if (
|
|
1520
|
+
typeof options.maxAge !== "number" ||
|
|
1521
|
+
!Number.isSafeInteger(options.maxAge)
|
|
1522
|
+
) {
|
|
1523
|
+
throw new Error("invalid cookie maxAge");
|
|
1524
|
+
}
|
|
1525
|
+
cookie += `; Max-Age=${options.maxAge}`;
|
|
1526
|
+
}
|
|
919
1527
|
if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
920
1528
|
if (options.httpOnly) cookie += "; HttpOnly";
|
|
921
1529
|
if (options.secure) cookie += "; Secure";
|
|
922
|
-
if (options.sameSite)
|
|
1530
|
+
if (options.sameSite) {
|
|
1531
|
+
if (
|
|
1532
|
+
options.sameSite !== "strict" &&
|
|
1533
|
+
options.sameSite !== "lax" &&
|
|
1534
|
+
options.sameSite !== "none"
|
|
1535
|
+
) {
|
|
1536
|
+
throw new Error("invalid cookie sameSite");
|
|
1537
|
+
}
|
|
1538
|
+
cookie += `; SameSite=${options.sameSite}`;
|
|
1539
|
+
}
|
|
923
1540
|
|
|
924
1541
|
return cookie;
|
|
925
1542
|
}
|
|
@@ -933,20 +1550,12 @@ export interface CreateUseFunctionOptions<TEnv> {
|
|
|
933
1550
|
getContext: () => RequestContext<TEnv>;
|
|
934
1551
|
}
|
|
935
1552
|
|
|
936
|
-
/**
|
|
937
|
-
* Create the use() function for loader and handle composition.
|
|
938
|
-
*
|
|
939
|
-
* This is the unified implementation used by both RequestContext and HandlerContext.
|
|
940
|
-
* - For loaders: executes and memoizes loader functions
|
|
941
|
-
* - For handles: returns a push function to add handle data
|
|
942
|
-
*/
|
|
943
1553
|
export function createUseFunction<TEnv>(
|
|
944
1554
|
options: CreateUseFunctionOptions<TEnv>,
|
|
945
1555
|
): RequestContext["use"] {
|
|
946
1556
|
const { handleStore, loaderPromises, getContext } = options;
|
|
947
1557
|
|
|
948
1558
|
return ((item: LoaderDefinition<any, any> | Handle<any, any>) => {
|
|
949
|
-
// Handle case: return a push function
|
|
950
1559
|
if (isHandle(item)) {
|
|
951
1560
|
const handle = item;
|
|
952
1561
|
const ctx = getContext();
|
|
@@ -959,30 +1568,24 @@ export function createUseFunction<TEnv>(
|
|
|
959
1568
|
);
|
|
960
1569
|
}
|
|
961
1570
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
// Push directly - promises will be serialized by RSC and streamed
|
|
973
|
-
handleStore.push(handle.$$id, segmentId, valueOrPromise);
|
|
974
|
-
};
|
|
1571
|
+
return withDefer(
|
|
1572
|
+
(dataOrFn: unknown | Promise<unknown> | (() => Promise<unknown>)) => {
|
|
1573
|
+
const valueOrPromise =
|
|
1574
|
+
typeof dataOrFn === "function"
|
|
1575
|
+
? (dataOrFn as () => Promise<unknown>)()
|
|
1576
|
+
: dataOrFn;
|
|
1577
|
+
|
|
1578
|
+
handleStore.push(handle.$$id, segmentId, valueOrPromise);
|
|
1579
|
+
},
|
|
1580
|
+
);
|
|
975
1581
|
}
|
|
976
1582
|
|
|
977
|
-
// Loader case
|
|
978
1583
|
const loader = item as LoaderDefinition<any, any>;
|
|
979
1584
|
|
|
980
|
-
// Return cached promise if already started
|
|
981
1585
|
if (loaderPromises.has(loader.$$id)) {
|
|
982
1586
|
return loaderPromises.get(loader.$$id);
|
|
983
1587
|
}
|
|
984
1588
|
|
|
985
|
-
// Get loader function - either from loader object or fetchable registry
|
|
986
1589
|
let loaderFn = loader.fn;
|
|
987
1590
|
if (!loaderFn) {
|
|
988
1591
|
const fetchable = getFetchableLoader(loader.$$id);
|
|
@@ -999,33 +1602,56 @@ export function createUseFunction<TEnv>(
|
|
|
999
1602
|
|
|
1000
1603
|
const ctx = getContext();
|
|
1001
1604
|
|
|
1002
|
-
//
|
|
1605
|
+
// Build the typed ctx.search the same way the render path
|
|
1606
|
+
// (createHandlerContext) and the fetchable-loader path (loader-fetch.ts) do:
|
|
1607
|
+
// parse the route's search schema over the cleaned searchParams. The base
|
|
1608
|
+
// RequestContext carries no `search` field, so reading `(ctx as any).search`
|
|
1609
|
+
// here always yielded {} — dropping typed search for action/dispatch loaders.
|
|
1610
|
+
const searchSchema = ctx._routeName
|
|
1611
|
+
? getSearchSchema(ctx._routeName, ctx._routerId)
|
|
1612
|
+
: undefined;
|
|
1613
|
+
const loaderSearch = searchSchema
|
|
1614
|
+
? parseSearchParams(ctx.searchParams, searchSchema)
|
|
1615
|
+
: {};
|
|
1616
|
+
|
|
1003
1617
|
const loaderCtx: LoaderContext<Record<string, string | undefined>, TEnv> = {
|
|
1004
1618
|
params: ctx.params,
|
|
1005
1619
|
routeParams: (ctx.params ?? {}) as Record<string, string>,
|
|
1006
1620
|
request: ctx.request,
|
|
1007
1621
|
searchParams: ctx.searchParams,
|
|
1008
|
-
search:
|
|
1622
|
+
search: loaderSearch,
|
|
1009
1623
|
pathname: ctx.pathname,
|
|
1010
1624
|
url: ctx.url,
|
|
1011
1625
|
originalUrl: ctx.originalUrl,
|
|
1012
1626
|
env: ctx.env as any,
|
|
1013
1627
|
waitUntil: ctx.waitUntil.bind(ctx),
|
|
1014
1628
|
executionContext: ctx.executionContext,
|
|
1015
|
-
get:
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1629
|
+
get: ((keyOrVar: any) => {
|
|
1630
|
+
// Handle READS need the rendered() barrier, which this lane
|
|
1631
|
+
// (action/dispatch-invoked loaders) does not run. Fail with guidance
|
|
1632
|
+
// instead of returning a misleading empty collect.
|
|
1633
|
+
if (isHandle(keyOrVar)) {
|
|
1634
|
+
throw new Error(
|
|
1635
|
+
`ctx.get(handle) is only available in DSL loaders after ` +
|
|
1636
|
+
`"await ctx.rendered()". It cannot be used from request-context ` +
|
|
1637
|
+
`loaders or server actions.`,
|
|
1638
|
+
);
|
|
1639
|
+
}
|
|
1640
|
+
return (ctx.get as any)(keyOrVar);
|
|
1641
|
+
}) as any,
|
|
1642
|
+
// Pass items through: loaders delegate to the request ctx's loader
|
|
1643
|
+
// executor; a handle yields the ctx's push function (write parity —
|
|
1644
|
+
// ctx.use(Meta)({...}) works in this lane exactly like in a handler).
|
|
1645
|
+
use: ((item: any) => ctx.use(item)) as LoaderContext["use"],
|
|
1022
1646
|
method: "GET",
|
|
1023
1647
|
body: undefined,
|
|
1024
1648
|
reverse: createReverseFunction(
|
|
1025
1649
|
getGlobalRouteMap(),
|
|
1026
1650
|
ctx._routeName,
|
|
1027
1651
|
ctx.params as Record<string, string>,
|
|
1028
|
-
ctx._routeName
|
|
1652
|
+
ctx._routeName
|
|
1653
|
+
? isRouteRootScoped(ctx._routeName, ctx._routerId)
|
|
1654
|
+
: undefined,
|
|
1029
1655
|
),
|
|
1030
1656
|
rendered: () => {
|
|
1031
1657
|
throw new Error(
|
|
@@ -1035,12 +1661,14 @@ export function createUseFunction<TEnv>(
|
|
|
1035
1661
|
},
|
|
1036
1662
|
};
|
|
1037
1663
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1664
|
+
// Meter through the same unified phase API as the loader-resolution funnel
|
|
1665
|
+
// (observePhase), so a loader resolved via this base request-context ctx.use
|
|
1666
|
+
// co-emits the "loader:<id>" perf metric AND the "rango.loader" span — no
|
|
1667
|
+
// drift between the two ctx.use implementations.
|
|
1668
|
+
const promise = observePhase(PHASES.loader(loader.$$id), () =>
|
|
1669
|
+
Promise.resolve(loaderFn(loaderCtx)),
|
|
1670
|
+
);
|
|
1042
1671
|
|
|
1043
|
-
// Memoize for subsequent calls
|
|
1044
1672
|
loaderPromises.set(loader.$$id, promise);
|
|
1045
1673
|
|
|
1046
1674
|
return promise;
|