@rangojs/router 0.4.3 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/browser/prefetch/cache.d.ts +31 -2
- package/dist/types/cache/cf/cf-cache-store.d.ts +2 -0
- package/dist/types/cache/types.d.ts +39 -6
- package/dist/types/route-definition/helpers-types.d.ts +5 -4
- package/dist/types/rsc/capture-queue.d.ts +19 -3
- package/dist/types/rsc/shell-build-manifest.d.ts +2 -2
- package/dist/types/rsc/shell-capture.d.ts +22 -2
- package/dist/types/rsc/shell-serve.d.ts +18 -12
- package/dist/types/static-handler.d.ts +15 -1
- package/dist/types/urls/path-helper-types.d.ts +6 -7
- 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 +1 -1
- package/package.json +1 -1
- package/skills/parallel/SKILL.md +1 -1
- package/skills/ppr/SKILL.md +44 -3
- package/src/browser/prefetch/cache.ts +53 -9
- package/src/browser/prefetch/fetch.ts +83 -2
- package/src/cache/cf/cf-cache-store.ts +27 -8
- package/src/cache/types.ts +41 -6
- package/src/cache/vercel/vercel-cache-store.ts +24 -10
- package/src/route-definition/helpers-types.ts +5 -3
- package/src/rsc/capture-queue.ts +120 -47
- package/src/rsc/rsc-rendering.ts +11 -3
- package/src/rsc/shell-build-manifest.ts +20 -7
- package/src/rsc/shell-capture.ts +164 -12
- package/src/rsc/shell-serve.ts +27 -12
- package/src/static-handler.ts +18 -2
- package/src/urls/path-helper-types.ts +9 -10
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { NavigationStore, ResolvedSegment, HandleData } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Clone the handleData CONTAINERS (the handle-name map and each segment map) so
|
|
4
|
+
* a cache entry is decoupled from the live map that eventController mutates — it
|
|
5
|
+
* adds/deletes segment keys and REPLACES bucket arrays in place. The bucket
|
|
6
|
+
* arrays themselves are shared by reference, NOT copied: a bucket array is only
|
|
7
|
+
* ever replaced wholesale (eventController.setHandleData reassigns it,
|
|
8
|
+
* resolveDeferredHandleValues builds a fresh one) and collect functions read it
|
|
9
|
+
* without mutating, so sharing is safe and skips an O(elements) copy on every
|
|
10
|
+
* cache write — the per-yield streaming hot path. This also preserves any
|
|
11
|
+
* non-serializable bucket contents (React elements, functions, etc.).
|
|
12
|
+
*/
|
|
13
|
+
export declare function cloneHandleData(handleData: HandleData): HandleData;
|
|
14
|
+
/**
|
|
15
|
+
* Options for generating a history key
|
|
16
|
+
*/
|
|
17
|
+
export interface HistoryKeyOptions {
|
|
18
|
+
/** If true, append :intercept suffix to differentiate intercept entries */
|
|
19
|
+
intercept?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Generate a cache key from a URL.
|
|
23
|
+
* Uses pathname + search (query params) directly as the key.
|
|
24
|
+
* Hash fragments (#) are excluded since they don't affect server data.
|
|
25
|
+
*
|
|
26
|
+
* For intercept routes, append `:intercept` suffix to cache them separately
|
|
27
|
+
* from non-intercept versions of the same URL.
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateHistoryKey(url?: string, options?: HistoryKeyOptions): string;
|
|
30
|
+
/**
|
|
31
|
+
* Configuration for creating a navigation store
|
|
32
|
+
*/
|
|
33
|
+
export interface NavigationStoreConfig {
|
|
34
|
+
initialLocation?: {
|
|
35
|
+
href: string;
|
|
36
|
+
};
|
|
37
|
+
initialSegmentIds?: string[];
|
|
38
|
+
initialHistoryKey?: string;
|
|
39
|
+
initialSegments?: ResolvedSegment[];
|
|
40
|
+
/**
|
|
41
|
+
* Maximum number of history entries to cache (default: 20)
|
|
42
|
+
* Older entries are evicted when limit is reached
|
|
43
|
+
*/
|
|
44
|
+
cacheSize?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Enable cross-tab cache invalidation via BroadcastChannel (default: true)
|
|
47
|
+
* When cache is cleared (via server actions or invalidateClientCache()),
|
|
48
|
+
* other tabs will also clear their cache
|
|
49
|
+
*/
|
|
50
|
+
crossTabSync?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Auto-refresh when another tab mutates data on the same path (default: true)
|
|
53
|
+
* Triggered when cache is cleared via server actions or invalidateClientCache()
|
|
54
|
+
* Requires crossTabSync to be enabled
|
|
55
|
+
*/
|
|
56
|
+
crossTabAutoRefresh?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Callback to invoke when cross-tab refresh is triggered
|
|
59
|
+
* Called when another tab invalidates the cache for a related route
|
|
60
|
+
*/
|
|
61
|
+
onCrossTabRefresh?: () => void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a navigation store for managing browser-side navigation state
|
|
65
|
+
*
|
|
66
|
+
* The store manages two types of state:
|
|
67
|
+
* - NavigationState: Public state exposed via useNavigation hook
|
|
68
|
+
* - SegmentState: Internal segment management for partial RSC updates
|
|
69
|
+
*
|
|
70
|
+
* @param config - Initial configuration
|
|
71
|
+
* @returns NavigationStore instance
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const store = createNavigationStore({
|
|
76
|
+
* initialLocation: window.location,
|
|
77
|
+
* initialSegmentIds: [],
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Subscribe to state changes (for useNavigation hook)
|
|
81
|
+
* const unsubscribe = store.subscribe(() => {
|
|
82
|
+
* const state = store.getState();
|
|
83
|
+
* console.log('Navigation state:', state);
|
|
84
|
+
* });
|
|
85
|
+
*
|
|
86
|
+
* // Update state
|
|
87
|
+
* store.setState({ state: 'loading' });
|
|
88
|
+
*
|
|
89
|
+
* // Subscribe to UI updates (for re-rendering)
|
|
90
|
+
* store.onUpdate((update) => {
|
|
91
|
+
* console.log('New root:', update.root);
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function createNavigationStore(config?: NavigationStoreConfig): NavigationStore;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { NavigateOptions, NavigationStore, ResolvedSegment, StreamingToken } from "./types.js";
|
|
2
|
+
import type { EventController, NavigationHandle } from "./event-controller.js";
|
|
3
|
+
export { resolveNavigationState } from "./history-state.js";
|
|
4
|
+
/**
|
|
5
|
+
* Options for committing a navigation transaction
|
|
6
|
+
*/
|
|
7
|
+
interface CommitOptions {
|
|
8
|
+
url: string;
|
|
9
|
+
segmentIds: string[];
|
|
10
|
+
segments: ResolvedSegment[];
|
|
11
|
+
replace?: boolean;
|
|
12
|
+
scroll?: boolean;
|
|
13
|
+
/** User-provided state to store in history.state */
|
|
14
|
+
state?: unknown;
|
|
15
|
+
/** If true, only update store without changing URL/history (for server actions) */
|
|
16
|
+
storeOnly?: boolean;
|
|
17
|
+
/** If true, this is an intercept route - store in history.state for popstate handling */
|
|
18
|
+
intercept?: boolean;
|
|
19
|
+
/** Source URL where the intercept was triggered from (stored in history.state) */
|
|
20
|
+
interceptSourceUrl?: string;
|
|
21
|
+
/** If true, only update cache without touching store or history (for background stale revalidation) */
|
|
22
|
+
cacheOnly?: boolean;
|
|
23
|
+
/** Server-set location state to merge into history.pushState */
|
|
24
|
+
serverState?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options that can override the pre-configured commit settings
|
|
28
|
+
*/
|
|
29
|
+
interface BoundCommitOverrides {
|
|
30
|
+
/** Override scroll behavior (e.g., disable for intercepts) */
|
|
31
|
+
scroll?: boolean;
|
|
32
|
+
/** Override replace behavior (e.g., force replace for intercepts) */
|
|
33
|
+
replace?: boolean;
|
|
34
|
+
/** Override user-provided state */
|
|
35
|
+
state?: unknown;
|
|
36
|
+
/** Mark this as an intercept route */
|
|
37
|
+
intercept?: boolean;
|
|
38
|
+
/** Source URL where intercept was triggered from */
|
|
39
|
+
interceptSourceUrl?: string;
|
|
40
|
+
/** If true, only update cache (for stale revalidation) */
|
|
41
|
+
cacheOnly?: boolean;
|
|
42
|
+
/** Server-set location state to merge into history.pushState */
|
|
43
|
+
serverState?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Bound transaction with pre-configured commit options (without segmentIds/segments)
|
|
47
|
+
*/
|
|
48
|
+
export interface BoundTransaction {
|
|
49
|
+
readonly currentUrl: string;
|
|
50
|
+
/** Start streaming and get a token to end it when the stream completes */
|
|
51
|
+
startStreaming(): StreamingToken;
|
|
52
|
+
/** Commit the navigation. Returns the effective scroll option for the caller to handle. */
|
|
53
|
+
commit(segmentIds: string[], segments: ResolvedSegment[], overrides?: BoundCommitOverrides): {
|
|
54
|
+
scroll?: boolean;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Navigation transaction for managing state during navigation
|
|
59
|
+
* Uses the event controller handle for lifecycle management
|
|
60
|
+
*/
|
|
61
|
+
interface NavigationTransaction extends Disposable {
|
|
62
|
+
commit(options: CommitOptions): {
|
|
63
|
+
scroll?: boolean;
|
|
64
|
+
};
|
|
65
|
+
with(options: Omit<CommitOptions, "segmentIds" | "segments">): BoundTransaction;
|
|
66
|
+
/** The navigation handle from the event controller */
|
|
67
|
+
handle: NavigationHandle;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates a navigation transaction that coordinates with the event controller.
|
|
71
|
+
* Handles loading state transitions and cleanup on completion/abort.
|
|
72
|
+
*/
|
|
73
|
+
export declare function createNavigationTransaction(store: NavigationStore, eventController: EventController, url: string, options?: NavigateOptions & {
|
|
74
|
+
skipLoadingState?: boolean;
|
|
75
|
+
}): NavigationTransaction;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { NetworkError } from "../errors.js";
|
|
2
|
+
import type { UpdateSubscriber } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Convert an unknown error to a NetworkError, or return null if not network-related.
|
|
5
|
+
*
|
|
6
|
+
* Pure function: extracts the "is this a network error?" decision from
|
|
7
|
+
* navigation-bridge and server-action-bridge so it can be unit tested.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toNetworkError(error: unknown, context: {
|
|
10
|
+
url: string;
|
|
11
|
+
operation: "action" | "navigation" | "revalidation";
|
|
12
|
+
}): NetworkError | null;
|
|
13
|
+
/**
|
|
14
|
+
* Emit a NetworkError to the nearest error boundary (offline, failed fetch).
|
|
15
|
+
*/
|
|
16
|
+
export declare function emitNetworkError(onUpdate: UpdateSubscriber, error: NetworkError, pathname: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Emit a navigation processing error to the nearest error boundary. Used when a
|
|
19
|
+
* navigation response cannot be processed (an undecodable Flight body, or any
|
|
20
|
+
* unanticipated failure while building the response) -- for both fresh and
|
|
21
|
+
* prefetched responses, since both funnel through the navigation catch. Without
|
|
22
|
+
* this, such a failure becomes an uncaught rejection that silently aborts the
|
|
23
|
+
* navigation instead of surfacing the route's error boundary.
|
|
24
|
+
*/
|
|
25
|
+
export declare function emitNavigationError(onUpdate: UpdateSubscriber, error: unknown, pathname: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Check if an error is safe to suppress in background operations.
|
|
28
|
+
*
|
|
29
|
+
* Background revalidation (SWR, navigated-away refetch) should silently
|
|
30
|
+
* swallow AbortErrors and network errors since the user has already moved
|
|
31
|
+
* on and showing an error would be disruptive.
|
|
32
|
+
*
|
|
33
|
+
* Pure function, easily unit tested.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isBackgroundSuppressible(error: unknown): boolean;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { NavigationStore, NavigationClient, UpdateSubscriber, ResolvedSegment } from "./types.js";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { RenderSegmentsOptions } from "../segment-system.js";
|
|
4
|
+
import type { BoundTransaction } from "./navigation-transaction.js";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for creating a partial updater
|
|
7
|
+
*/
|
|
8
|
+
export interface PartialUpdateConfig {
|
|
9
|
+
store: NavigationStore;
|
|
10
|
+
client: NavigationClient;
|
|
11
|
+
onUpdate: UpdateSubscriber;
|
|
12
|
+
renderSegments: (segments: ResolvedSegment[], options?: RenderSegmentsOptions) => Promise<ReactNode> | ReactNode;
|
|
13
|
+
/** RSC version getter — returns the current version (may change after HMR) */
|
|
14
|
+
getVersion?: () => string | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Options that can override the pre-configured commit settings
|
|
18
|
+
*/
|
|
19
|
+
export interface CommitOverrides {
|
|
20
|
+
/** Override scroll behavior (e.g., disable for intercepts) */
|
|
21
|
+
scroll?: boolean;
|
|
22
|
+
/** Override replace behavior (e.g., force replace for intercepts) */
|
|
23
|
+
replace?: boolean;
|
|
24
|
+
/** Mark this as an intercept route */
|
|
25
|
+
intercept?: boolean;
|
|
26
|
+
/** Source URL where intercept was triggered from */
|
|
27
|
+
interceptSourceUrl?: string;
|
|
28
|
+
/** Server-set location state to merge into history.pushState */
|
|
29
|
+
serverState?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Discriminated update mode for partial updates.
|
|
33
|
+
*/
|
|
34
|
+
export type UpdateMode = {
|
|
35
|
+
type: "navigate";
|
|
36
|
+
/** Cached segments for the target URL. When provided, these are used to build
|
|
37
|
+
* the segment map instead of the current page's segments. This ensures consistency
|
|
38
|
+
* when we send cached segment IDs to the server - if the server returns empty diff,
|
|
39
|
+
* we use the same segments we told the server we have. */
|
|
40
|
+
targetCacheSegments?: ResolvedSegment[];
|
|
41
|
+
/** Cached handle data for the target URL. When server returns empty diff and we're
|
|
42
|
+
* rendering from cache, this is passed to the UI to restore breadcrumbs etc. */
|
|
43
|
+
targetCacheHandleData?: Record<string, Record<string, unknown[]>>;
|
|
44
|
+
/** Source URL for intercept restore (popstate cache miss) */
|
|
45
|
+
interceptSourceUrl?: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: "leave-intercept";
|
|
48
|
+
interceptSourceUrl?: string;
|
|
49
|
+
} | {
|
|
50
|
+
type: "stale-revalidation";
|
|
51
|
+
interceptSourceUrl?: string;
|
|
52
|
+
} | {
|
|
53
|
+
type: "action";
|
|
54
|
+
interceptSourceUrl?: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Type for the fetchPartialUpdate function
|
|
58
|
+
*/
|
|
59
|
+
export type PartialUpdater = (targetUrl: string, segmentIds: string[] | undefined, isRetry: boolean, signal: AbortSignal | undefined, tx: BoundTransaction, mode?: UpdateMode) => Promise<void>;
|
|
60
|
+
export declare function createPartialUpdater(config: PartialUpdateConfig): PartialUpdater;
|
|
61
|
+
export { createPartialUpdater as default };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefetch Cache
|
|
3
|
+
*
|
|
4
|
+
* In-memory cache storing eagerly-decoded prefetch payloads for instant,
|
|
5
|
+
* already-warm cache hits on subsequent navigation. A prefetch fetches the
|
|
6
|
+
* RSC partial AND decodes it (createFromFetch) up front — decoding the Flight
|
|
7
|
+
* stream resolves the route's client references, so the route's JS chunks are
|
|
8
|
+
* imported during prefetch rather than on click. The decoded payload is reused
|
|
9
|
+
* verbatim by navigation, so a prefetched click loads no new code. Two key
|
|
10
|
+
* scopes are in play:
|
|
11
|
+
* - Wildcard (default): built by `buildPrefetchKey(rangoState, target)` —
|
|
12
|
+
* shape `rangoState\0/target?...`. Shared across all source pages and
|
|
13
|
+
* invalidated automatically when Rango state bumps (deploy or
|
|
14
|
+
* server-action invalidation).
|
|
15
|
+
* - Source-scoped: built by `buildSourceKey(rangoState, sourceHref, target)`
|
|
16
|
+
* — shape `rangoState\0sourceHref\0/target?...`. Embeds the Rango state
|
|
17
|
+
* (so rotation invalidates source-scoped entries too) plus the source
|
|
18
|
+
* href (so each originating page gets its own slot). Populated when the
|
|
19
|
+
* server tags a response with `X-RSC-Prefetch-Scope: source` (intercept
|
|
20
|
+
* modals etc.), OR when a Link opts in with `prefetchKey=":source"` — in
|
|
21
|
+
* both cases so source-sensitive responses cannot bleed into navigations
|
|
22
|
+
* from other pages.
|
|
23
|
+
*
|
|
24
|
+
* Also tracks in-flight prefetch promises. Each promise resolves to the
|
|
25
|
+
* decoded prefetch entry (or null), letting navigation adopt a
|
|
26
|
+
* still-downloading prefetch without issuing a duplicate request. A
|
|
27
|
+
* single promise can be registered under multiple alias keys (see
|
|
28
|
+
* `setInflightPromiseWithAliases`) so same-source navigations adopt via
|
|
29
|
+
* their source key while cross-source ones fall through to the wildcard
|
|
30
|
+
* alias — with consume/clear atomically removing every alias.
|
|
31
|
+
*
|
|
32
|
+
* Replaces the previous browser HTTP cache approach which was unreliable
|
|
33
|
+
* due to response draining race conditions and browser inconsistencies.
|
|
34
|
+
*
|
|
35
|
+
* State here lives in module-level singletons (cache, inflight, generation,
|
|
36
|
+
* cacheTTL, etc.) rather than a per-instance factory. This is correct because
|
|
37
|
+
* exactly one router is live per document — an SPA navigation crossing a
|
|
38
|
+
* host-router boundary forces a full document reload — so the singletons are
|
|
39
|
+
* effectively per-document. Unit tests reset them via clearPrefetchCache().
|
|
40
|
+
*/
|
|
41
|
+
import type { RscPayload } from "../types.js";
|
|
42
|
+
/**
|
|
43
|
+
* A prefetch that has been fetched AND eagerly decoded. Storing the decoded
|
|
44
|
+
* payload (not the raw Response) is what makes a prefetched navigation "warm":
|
|
45
|
+
* decoding the Flight stream during prefetch pulls the route's client chunks,
|
|
46
|
+
* so the click reuses ready elements and loads no new JS.
|
|
47
|
+
*/
|
|
48
|
+
export interface DecodedPrefetch {
|
|
49
|
+
/** The eagerly-decoded RSC payload. Reused verbatim by navigation. */
|
|
50
|
+
payload: Promise<RscPayload>;
|
|
51
|
+
/**
|
|
52
|
+
* Resolves when the underlying RSC stream finishes draining. Navigation
|
|
53
|
+
* forwards this as its streamComplete so scroll/revalidation gating is
|
|
54
|
+
* unchanged from the fresh-fetch path.
|
|
55
|
+
*/
|
|
56
|
+
streamComplete: Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Prefetch scope as tagged by the server via `X-RSC-Prefetch-Scope`.
|
|
59
|
+
* `"source"` means the response is source-page-sensitive and must not be
|
|
60
|
+
* reused by a navigation from a different page — navigation enforces this
|
|
61
|
+
* when it adopted an inflight entry through the wildcard key.
|
|
62
|
+
*/
|
|
63
|
+
scope: "source" | "wildcard";
|
|
64
|
+
/**
|
|
65
|
+
* Synchronously-readable flag, flipped to true when `streamComplete` resolves
|
|
66
|
+
* (the entire RSC stream has drained). Navigation reads this at click time to
|
|
67
|
+
* tell a FULLY warmed prefetch (payload commits without suspending → safe to
|
|
68
|
+
* commit in a startTransition, no fallback flash) from a partially-warmed one
|
|
69
|
+
* (still streaming → stream its fallbacks like a cold load). Starts false.
|
|
70
|
+
*/
|
|
71
|
+
complete: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Initialize the prefetch cache with the configured TTL and max size.
|
|
75
|
+
* Called once at app startup with the values from server metadata. Each
|
|
76
|
+
* argument is applied only when provided, so a caller can set just the TTL.
|
|
77
|
+
* A TTL of 0 disables the in-memory cache and all prefetching. A size below 1
|
|
78
|
+
* is ignored (the default is kept) — disabling prefetch is the TTL's job.
|
|
79
|
+
*/
|
|
80
|
+
export declare function initPrefetchCache(ttlMs?: number, maxSize?: number): void;
|
|
81
|
+
/**
|
|
82
|
+
* Check if the prefetch cache is disabled (TTL <= 0).
|
|
83
|
+
* When disabled, no prefetch requests should be issued.
|
|
84
|
+
*/
|
|
85
|
+
export declare function isPrefetchCacheDisabled(): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Build a cache key by combining a scope prefix with the target URL.
|
|
88
|
+
*
|
|
89
|
+
* Low-level primitive — callers that want a specific scope should use
|
|
90
|
+
* one of:
|
|
91
|
+
* - Wildcard (source-agnostic): prefix is the Rango state value from
|
|
92
|
+
* `getRangoState()`. Shared across all source pages. Invalidated
|
|
93
|
+
* automatically when Rango state bumps (deploy or server-action).
|
|
94
|
+
* Key shape: `rangoState\0/target?...`.
|
|
95
|
+
* - Source-scoped: use `buildSourceKey()`. Key shape:
|
|
96
|
+
* `rangoState\0sourceHref\0/target?...` — embeds the Rango state so
|
|
97
|
+
* rotation invalidates source-scoped entries alongside wildcard ones,
|
|
98
|
+
* plus the source page href so the key is unique per originating page.
|
|
99
|
+
* Populated either when the server tags a response with
|
|
100
|
+
* `X-RSC-Prefetch-Scope: source` (intercept modals, etc.) or when a
|
|
101
|
+
* Link opts in via `prefetchKey=":source"`.
|
|
102
|
+
*
|
|
103
|
+
* The `_rsc_segments` query param that travels in the target URL means
|
|
104
|
+
* clients with different mounted segment trees naturally get different
|
|
105
|
+
* keys — so segment-level diffs remain consistent across both scopes.
|
|
106
|
+
*/
|
|
107
|
+
export declare function buildPrefetchKey(prefix: string, targetUrl: URL): string;
|
|
108
|
+
/**
|
|
109
|
+
* Build a source-scoped cache key. Key shape:
|
|
110
|
+
* `rangoState\0sourceHref\0/target?...`.
|
|
111
|
+
*
|
|
112
|
+
* - `rangoState` is included so state rotation invalidates source-scoped
|
|
113
|
+
* entries alongside wildcard ones.
|
|
114
|
+
* - `sourceHref` makes the key unique per originating page.
|
|
115
|
+
*/
|
|
116
|
+
export declare function buildSourceKey(rangoState: string, sourceHref: string, targetUrl: URL): string;
|
|
117
|
+
/**
|
|
118
|
+
* Check if a prefetch is already cached, in-flight, or queued for the given key.
|
|
119
|
+
*/
|
|
120
|
+
export declare function hasPrefetch(key: string): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Consume a cached, eagerly-decoded prefetch. Returns null if not found or
|
|
123
|
+
* expired. One-time consumption: the entry is deleted after retrieval.
|
|
124
|
+
* Returns null when caching is disabled (TTL <= 0).
|
|
125
|
+
*
|
|
126
|
+
* Does NOT check in-flight prefetches — use consumeInflightPrefetch()
|
|
127
|
+
* for that (returns a Promise instead of a resolved entry).
|
|
128
|
+
*/
|
|
129
|
+
export declare function consumePrefetch(key: string): DecodedPrefetch | null;
|
|
130
|
+
/**
|
|
131
|
+
* Consume an in-flight prefetch promise. Returns null if no prefetch is
|
|
132
|
+
* in-flight for this key. The returned Promise resolves to the decoded
|
|
133
|
+
* prefetch entry (or null if the fetch failed/was aborted, or carried a
|
|
134
|
+
* control header the navigation must re-fetch to honor).
|
|
135
|
+
*
|
|
136
|
+
* One-time consumption: the promise entry is removed (along with any
|
|
137
|
+
* sibling aliases registered via `setInflightPromiseWithAliases`) so a
|
|
138
|
+
* second call on any alias returns null — only one caller can adopt the
|
|
139
|
+
* shared Response stream. The `inflight` set entry is intentionally
|
|
140
|
+
* kept so that `hasPrefetch()` continues to return true while the
|
|
141
|
+
* underlying fetch is still downloading — this prevents
|
|
142
|
+
* `prefetchDirect()` or other callers from starting a duplicate request
|
|
143
|
+
* during the handoff window. The inflight flag is cleaned up naturally
|
|
144
|
+
* by `clearPrefetchInflight()` in the fetch's `.finally()`.
|
|
145
|
+
*/
|
|
146
|
+
export declare function consumeInflightPrefetch(key: string): Promise<DecodedPrefetch | null> | null;
|
|
147
|
+
/**
|
|
148
|
+
* Store an eagerly-decoded prefetch in the in-memory cache.
|
|
149
|
+
*
|
|
150
|
+
* Skips storage if the generation has changed since the fetch started
|
|
151
|
+
* (a server action invalidated the cache mid-flight).
|
|
152
|
+
*/
|
|
153
|
+
export declare function storePrefetch(key: string, entry: DecodedPrefetch, fetchGeneration: number): void;
|
|
154
|
+
/**
|
|
155
|
+
* Remove a single stored prefetch entry. Used to evict an entry whose body
|
|
156
|
+
* stream stalled after headers arrived (its payload / streamComplete never
|
|
157
|
+
* settle), so future prefetches and navigation refetch instead of dedupe-ing
|
|
158
|
+
* against — and awaiting — a stuck entry.
|
|
159
|
+
*
|
|
160
|
+
* Identity-guarded: only evicts when the entry CURRENTLY stored under `key` is
|
|
161
|
+
* the exact `entry` we published. A generation check alone is insufficient —
|
|
162
|
+
* after this entry is consumed (consumePrefetch) and a fresh prefetch
|
|
163
|
+
* republishes under the SAME key in the SAME generation, a gen-only guard would
|
|
164
|
+
* delete that valid newer entry. Reference identity drops only our own stalled
|
|
165
|
+
* entry.
|
|
166
|
+
*/
|
|
167
|
+
export declare function removePrefetch(key: string, entry: DecodedPrefetch): void;
|
|
168
|
+
/**
|
|
169
|
+
* Capture the current generation. The returned value is passed to
|
|
170
|
+
* storePrefetch so it can detect stale completions.
|
|
171
|
+
*/
|
|
172
|
+
export declare function currentGeneration(): number;
|
|
173
|
+
export declare function markPrefetchInflight(key: string): void;
|
|
174
|
+
export declare function setInflightPromise(key: string, promise: Promise<DecodedPrefetch | null>): void;
|
|
175
|
+
/**
|
|
176
|
+
* Store the same in-flight Promise under multiple keys, recording them
|
|
177
|
+
* as sibling aliases. Consuming or clearing any one alias atomically
|
|
178
|
+
* removes every entry, guaranteeing the shared Response stream has a
|
|
179
|
+
* single consumer even when navigation looks up either key.
|
|
180
|
+
*/
|
|
181
|
+
export declare function setInflightPromiseWithAliases(keys: string[], promise: Promise<DecodedPrefetch | null>): void;
|
|
182
|
+
export declare function clearPrefetchInflight(key: string): void;
|
|
183
|
+
export declare function clearPrefetchCache(): void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefetch Fetch
|
|
3
|
+
*
|
|
4
|
+
* Fetch-based prefetch logic used by Link (hover/viewport/render strategies)
|
|
5
|
+
* and useRouter().prefetch(). Sends the same headers and segment IDs as a
|
|
6
|
+
* real navigation so the server returns a proper diff. The response is fetched
|
|
7
|
+
* AND eagerly decoded (createFromFetch) up front: decoding the Flight stream
|
|
8
|
+
* resolves the route's client references, so the route's JS chunks are imported
|
|
9
|
+
* during prefetch rather than on click. The decoded payload is stored in an
|
|
10
|
+
* in-memory cache and reused verbatim by navigation, so a prefetched click
|
|
11
|
+
* loads no new code.
|
|
12
|
+
*
|
|
13
|
+
* In-flight promises are tracked in the cache so that navigation can reuse
|
|
14
|
+
* a prefetch that is still downloading/decoding instead of starting a
|
|
15
|
+
* duplicate request.
|
|
16
|
+
*/
|
|
17
|
+
import type { RscPayload } from "../types.js";
|
|
18
|
+
/**
|
|
19
|
+
* Decoder injected at app startup (see setPrefetchDecoder). This is
|
|
20
|
+
* `deps.createFromFetch` — decoupled from the RSC runtime exactly like the
|
|
21
|
+
* navigation client. Prefetch decodes through it so the route's client chunks
|
|
22
|
+
* are pulled during the prefetch, not on click.
|
|
23
|
+
*/
|
|
24
|
+
type PrefetchDecoder = (response: Promise<Response>) => Promise<RscPayload>;
|
|
25
|
+
/**
|
|
26
|
+
* Wire the RSC decoder used to eagerly decode prefetched responses. Called
|
|
27
|
+
* once from initBrowserApp with the same createFromFetch the navigation client
|
|
28
|
+
* uses. Until set, prefetch warming is inert (prefetches are skipped) — the
|
|
29
|
+
* browser app always sets it before any Link can fire.
|
|
30
|
+
*/
|
|
31
|
+
export declare function setPrefetchDecoder(fn: PrefetchDecoder): void;
|
|
32
|
+
/**
|
|
33
|
+
* Prefetch (direct): fetch with low priority and store in in-memory cache.
|
|
34
|
+
* Used by hover strategy -- fires immediately without queueing.
|
|
35
|
+
*
|
|
36
|
+
* By default the wildcard key (Rango-state-keyed) is used for inflight
|
|
37
|
+
* dedup and for responses that are not source-sensitive; source-scoped
|
|
38
|
+
* storage is automatic when the server emits `X-RSC-Prefetch-Scope: source`.
|
|
39
|
+
*
|
|
40
|
+
* Pass `prefetchKey=":source"` to force source-scoped inflight + storage
|
|
41
|
+
* (e.g. when the target uses a custom `revalidate()` that reads
|
|
42
|
+
* `currentUrl` and the wildcard slot would serve the wrong diff).
|
|
43
|
+
*/
|
|
44
|
+
export declare function prefetchDirect(url: string, segmentIds: string[], version?: string, routerId?: string, prefetchKey?: ":source"): void;
|
|
45
|
+
/**
|
|
46
|
+
* Prefetch (queued): goes through the concurrency-limited queue.
|
|
47
|
+
* Used by viewport/render strategies to avoid flooding the server.
|
|
48
|
+
* Returns the inflight key (wildcard by default, source-scoped when
|
|
49
|
+
* `prefetchKey=":source"` is passed).
|
|
50
|
+
*/
|
|
51
|
+
export declare function prefetchQueued(url: string, segmentIds: string[], version?: string, routerId?: string, prefetchKey?: ":source"): string;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefetch Observer
|
|
3
|
+
*
|
|
4
|
+
* Shared singleton IntersectionObserver for viewport-based prefetching.
|
|
5
|
+
* One observer handles all Link components with prefetch="viewport".
|
|
6
|
+
*
|
|
7
|
+
* Lazy-created on first call to avoid issues in SSR or test environments
|
|
8
|
+
* where IntersectionObserver may not exist.
|
|
9
|
+
*
|
|
10
|
+
* Observation is one-shot: once a link enters the viewport and the callback
|
|
11
|
+
* fires, the element is unobserved. This prevents re-prefetching when a link
|
|
12
|
+
* scrolls in and out repeatedly.
|
|
13
|
+
*/
|
|
14
|
+
type PrefetchCallback = () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Observe an element for viewport intersection.
|
|
17
|
+
* When the element becomes visible (within 200px margin), the callback fires
|
|
18
|
+
* and the element is automatically unobserved.
|
|
19
|
+
* No-op in environments without IntersectionObserver (SSR, some test runners).
|
|
20
|
+
*/
|
|
21
|
+
export declare function observeForPrefetch(element: Element, onVisible: PrefetchCallback): void;
|
|
22
|
+
/**
|
|
23
|
+
* Stop observing an element. Used for cleanup when a Link unmounts
|
|
24
|
+
* before entering the viewport.
|
|
25
|
+
*/
|
|
26
|
+
export declare function unobserveForPrefetch(element: Element): void;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefetch Policy
|
|
3
|
+
*
|
|
4
|
+
* Determines whether speculative prefetching should run for the current user.
|
|
5
|
+
* Honors browser reduced-data preferences when available.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Evaluate on every call so runtime changes to Save-Data or
|
|
9
|
+
* prefers-reduced-data are respected immediately.
|
|
10
|
+
*/
|
|
11
|
+
export declare function shouldPrefetch(): boolean;
|
|
12
|
+
/** No-op, kept for test compatibility. */
|
|
13
|
+
export declare function resetPrefetchPolicy(): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefetch Queue
|
|
3
|
+
*
|
|
4
|
+
* Concurrency-limited FIFO queue for speculative prefetches (viewport/render).
|
|
5
|
+
* Hover prefetches bypass this queue — they fire directly for immediate response
|
|
6
|
+
* to user intent.
|
|
7
|
+
*
|
|
8
|
+
* Draining waits for an idle main-thread moment and for viewport images to
|
|
9
|
+
* finish loading, so prefetch fetch() calls never compete with critical
|
|
10
|
+
* resources for the browser's connection pool.
|
|
11
|
+
*
|
|
12
|
+
* When a navigation starts, queued prefetches are cancelled but executing ones
|
|
13
|
+
* are left running. Navigation can reuse their in-flight responses via the
|
|
14
|
+
* prefetch cache's inflight promise map, avoiding duplicate requests.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Set the max number of concurrently-executing speculative prefetches.
|
|
18
|
+
* Called once at app startup with the value from server metadata. A value
|
|
19
|
+
* below 1 (or non-finite) is ignored, keeping the default.
|
|
20
|
+
*/
|
|
21
|
+
export declare function setPrefetchConcurrency(n: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Enqueue a prefetch for concurrency-limited execution.
|
|
24
|
+
* Execution is deferred until the browser is idle and viewport images
|
|
25
|
+
* have finished loading, so prefetches never compete with critical
|
|
26
|
+
* resources. Deduplicates by key — items already queued or executing
|
|
27
|
+
* are skipped.
|
|
28
|
+
*
|
|
29
|
+
* The executor receives an AbortSignal that is aborted when
|
|
30
|
+
* cancelAllPrefetches() is called (e.g. on navigation start).
|
|
31
|
+
*/
|
|
32
|
+
export declare function enqueuePrefetch(key: string, execute: (signal: AbortSignal) => Promise<void>): void;
|
|
33
|
+
/**
|
|
34
|
+
* Cancel queued prefetches and abort in-flight ones that don't match
|
|
35
|
+
* the current navigation target. If `keepUrl` is provided, the
|
|
36
|
+
* executing prefetch whose key targets that URL is kept alive so
|
|
37
|
+
* navigation can reuse its response via consumeInflightPrefetch.
|
|
38
|
+
*
|
|
39
|
+
* Called when a navigation starts via the NavigationProvider's
|
|
40
|
+
* event controller subscription.
|
|
41
|
+
*/
|
|
42
|
+
export declare function cancelAllPrefetches(keepUrl?: string | null): void;
|
|
43
|
+
/**
|
|
44
|
+
* Hard-cancel everything including in-flight prefetches.
|
|
45
|
+
* Used by clearPrefetchCache (server action invalidation) where
|
|
46
|
+
* in-flight responses would be stale.
|
|
47
|
+
*/
|
|
48
|
+
export declare function abortAllPrefetches(): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource Readiness
|
|
3
|
+
*
|
|
4
|
+
* Utilities to defer speculative prefetches until critical resources
|
|
5
|
+
* (viewport images) have finished loading. Prevents prefetch fetch()
|
|
6
|
+
* calls from competing with images for the browser's connection pool.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Resolve when all in-viewport images have finished loading.
|
|
10
|
+
* Returns immediately if no images are pending.
|
|
11
|
+
*
|
|
12
|
+
* Only checks images that exist at call time — does not observe
|
|
13
|
+
* dynamically added images. For SPA navigations where new images
|
|
14
|
+
* appear after render, call this after the navigation settles.
|
|
15
|
+
*/
|
|
16
|
+
export declare function waitForViewportImages(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Resolve after the given number of milliseconds.
|
|
19
|
+
*/
|
|
20
|
+
export declare function wait(ms: number): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve when the browser has an idle main-thread moment.
|
|
23
|
+
* Uses requestIdleCallback where available, falls back to setTimeout.
|
|
24
|
+
*
|
|
25
|
+
* This is a scheduling hint, not an asset-loaded detector — combine
|
|
26
|
+
* with waitForViewportImages() for full resource readiness.
|
|
27
|
+
*/
|
|
28
|
+
export declare function waitForIdle(timeout?: number): Promise<void>;
|