@rangojs/router 0.1.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/types/browser/prefetch/default-strategy.d.ts +22 -0
- package/dist/types/browser/prefetch/runtime.d.ts +0 -1
- package/dist/types/browser/react/Link.d.ts +8 -11
- package/dist/types/browser/types.d.ts +5 -0
- package/dist/types/cache/document-cache.d.ts +3 -1
- package/dist/types/cache/types.d.ts +10 -3
- package/dist/types/route-definition/helpers-types.d.ts +6 -6
- package/dist/types/router/match-handlers.d.ts +2 -3
- package/dist/types/router/prefetch-default.d.ts +28 -0
- package/dist/types/router/router-interfaces.d.ts +7 -0
- package/dist/types/router/router-options.d.ts +30 -0
- package/dist/types/router/segment-resolution/view-transition-default.d.ts +3 -4
- package/dist/types/router/transition-when.d.ts +13 -0
- package/dist/types/rsc/capture-queue.d.ts +6 -0
- package/dist/types/rsc/shell-capture.d.ts +15 -7
- package/dist/types/rsc/shell-serve.d.ts +6 -3
- package/dist/types/rsc/transition-gate.d.ts +10 -14
- package/dist/types/rsc/types.d.ts +2 -0
- package/dist/types/server/request-context.d.ts +5 -1
- package/dist/types/testing/e2e/index.d.ts +3 -3
- package/dist/types/testing/e2e/page-helpers.d.ts +24 -0
- package/dist/types/testing/index.d.ts +2 -2
- package/dist/types/testing/run-transition-when.d.ts +6 -5
- package/dist/types/testing/shell-status.d.ts +23 -3
- package/dist/types/types/segments.d.ts +27 -22
- package/dist/types/urls/path-helper-types.d.ts +4 -3
- 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 +5 -2
- package/package.json +20 -21
- package/skills/cache-guide/SKILL.md +6 -3
- package/skills/catalog.json +7 -1
- package/skills/comparison/references/framework-comparison.md +2 -1
- package/skills/deployment-caching/SKILL.md +176 -0
- package/skills/document-cache/SKILL.md +30 -3
- package/skills/ppr/SKILL.md +81 -34
- package/skills/prerender/SKILL.md +15 -8
- package/skills/rango/SKILL.md +20 -17
- package/skills/router-setup/SKILL.md +4 -0
- package/skills/testing/SKILL.md +1 -1
- package/skills/testing/cache-prerender.md +5 -1
- package/skills/vercel/SKILL.md +22 -1
- package/skills/view-transitions/SKILL.md +12 -8
- package/src/browser/prefetch/default-strategy.ts +34 -0
- package/src/browser/prefetch/loader.ts +6 -12
- package/src/browser/prefetch/runtime.ts +0 -1
- package/src/browser/react/Link.tsx +22 -21
- package/src/browser/rsc-router.tsx +8 -0
- package/src/browser/types.ts +5 -0
- package/src/cache/cache-scope.ts +6 -1
- package/src/cache/cf/cf-cache-store.ts +4 -0
- package/src/cache/document-cache.ts +4 -2
- package/src/cache/types.ts +10 -3
- package/src/cache/vercel/vercel-cache-store.ts +6 -1
- package/src/route-definition/helpers-types.ts +6 -6
- package/src/router/match-handlers.ts +44 -6
- package/src/router/match-middleware/cache-lookup.ts +10 -3
- package/src/router/prefetch-default.ts +59 -0
- package/src/router/router-interfaces.ts +8 -0
- package/src/router/router-options.ts +31 -0
- package/src/router/segment-resolution/view-transition-default.ts +9 -5
- package/src/router/transition-when.ts +76 -0
- package/src/router.ts +7 -0
- package/src/rsc/capture-queue.ts +24 -1
- package/src/rsc/full-payload.ts +1 -0
- package/src/rsc/handler.ts +1 -0
- package/src/rsc/progressive-enhancement.ts +9 -14
- package/src/rsc/rsc-rendering.ts +261 -48
- package/src/rsc/shell-capture.ts +94 -50
- package/src/rsc/shell-serve.ts +9 -4
- package/src/rsc/transition-gate.ts +37 -40
- package/src/rsc/types.ts +2 -0
- package/src/server/request-context.ts +6 -0
- package/src/testing/e2e/index.ts +11 -0
- package/src/testing/e2e/page-helpers.ts +47 -0
- package/src/testing/e2e/parity.ts +13 -0
- package/src/testing/index.ts +9 -1
- package/src/testing/run-transition-when.ts +42 -9
- package/src/testing/shell-status.ts +92 -3
- package/src/types/segments.ts +27 -22
- package/src/urls/path-helper-types.ts +4 -3
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import type { ExecutionContext } from "../../types/request-scope.js";
|
|
2
|
+
import type { CacheDefaults } from "../types.js";
|
|
3
|
+
import type { RequestContext } from "../../server/request-context.js";
|
|
4
|
+
/**
|
|
5
|
+
* Minimal Cloudflare KV Namespace interface.
|
|
6
|
+
* Avoids hard dependency on @cloudflare/workers-types.
|
|
7
|
+
*/
|
|
8
|
+
export interface KVNamespace {
|
|
9
|
+
get(key: string, options?: {
|
|
10
|
+
type?: string;
|
|
11
|
+
}): Promise<any>;
|
|
12
|
+
put(key: string, value: string, options?: {
|
|
13
|
+
expirationTtl?: number;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
delete(key: string): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* One L1 read decision, surfaced when `debug` is enabled. Lets an operator
|
|
19
|
+
* confirm on a real deployment (e.g. via `wrangler tail`) that the store's
|
|
20
|
+
* observed inputs match its decision: which tier answered, the entry's status,
|
|
21
|
+
* the stale/revalidating timestamps, the raw CF `Age` header (so its
|
|
22
|
+
* unreliability can be seen next to the explicit revalidating-at stamp), and
|
|
23
|
+
* the measured match/body-read durations (where the latency tail shows up).
|
|
24
|
+
*/
|
|
25
|
+
export interface CFCacheReadDebugEvent {
|
|
26
|
+
/**
|
|
27
|
+
* Which read method produced this event. Only the JSON read paths (segment
|
|
28
|
+
* `get` and function `getItem`) participate in debug; the document
|
|
29
|
+
* `getResponse` path streams its body and is intentionally out of scope.
|
|
30
|
+
*/
|
|
31
|
+
op: "get" | "getItem";
|
|
32
|
+
/** Cache key (without the internal fn:/doc: prefix or version path). */
|
|
33
|
+
key: string;
|
|
34
|
+
/**
|
|
35
|
+
* What the read resolved to:
|
|
36
|
+
* - l1-fresh / l1-stale-revalidate / l1-revalidating-guarded: L1 hit outcomes
|
|
37
|
+
* - match-timeout / body-timeout: the L1 latency budgets fired
|
|
38
|
+
* - match-error: the L1 match() itself rejected (a transient Cache API infra
|
|
39
|
+
* error) -- a miss that falls through to L2/KV and is reported cache-read,
|
|
40
|
+
* distinct from a genuine l1-miss (absence) so the two are separable
|
|
41
|
+
* - body-error: the L1 body read failed fast (corrupt/non-JSON body) -- a miss
|
|
42
|
+
* that falls through to L2/KV, distinct from a body-timeout
|
|
43
|
+
* - non-200: L1 returned a non-200 (treated as a miss)
|
|
44
|
+
* - l1-miss: no L1 entry
|
|
45
|
+
* - kv-fresh / kv-stale / kv-miss: L2 fallback outcomes
|
|
46
|
+
* - kv-stale-suppressed: a stale L2 hit served WITHOUT revalidation because
|
|
47
|
+
* the L1 fall-through was degraded (body-timeout / non-200) -- the herd
|
|
48
|
+
* mitigation, distinct from kv-stale so the suppression is visible
|
|
49
|
+
* - kv-timeout: the L2/KV read budget fired (read abandoned, NOT a genuine
|
|
50
|
+
* absence -- distinct from kv-miss so a degradation signal is separable)
|
|
51
|
+
* - tag-invalidated: a live L1/KV entry whose cache tags were invalidated
|
|
52
|
+
* after it was written -- treated as a miss so the next render re-populates
|
|
53
|
+
* it (the tag-invalidation read path, distinct from a plain miss)
|
|
54
|
+
* - error: the read threw
|
|
55
|
+
*/
|
|
56
|
+
outcome: "l1-fresh" | "l1-stale-revalidate" | "l1-revalidating-guarded" | "match-timeout" | "match-error" | "body-timeout" | "body-error" | "non-200" | "tag-invalidated" | "l1-miss" | "kv-fresh" | "kv-stale" | "kv-stale-suppressed" | "kv-miss" | "kv-timeout" | "error";
|
|
57
|
+
/** HTTP status of the matched L1 response, when one was returned. */
|
|
58
|
+
status?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Stored cache status header (CACHE_STATUS_HEADER): "HIT" or "REVALIDATING".
|
|
61
|
+
* Distinct from `isRevalidating`, which also factors in stamp recency -- this
|
|
62
|
+
* is the raw stored value, so a REVALIDATING entry whose stamp aged out (so
|
|
63
|
+
* `isRevalidating` is false) is still distinguishable from a plain HIT.
|
|
64
|
+
*/
|
|
65
|
+
cacheStatus?: string | null;
|
|
66
|
+
/** Epoch-ms when the entry goes stale (from CACHE_STALE_AT_HEADER). */
|
|
67
|
+
staleAt?: number;
|
|
68
|
+
/** Epoch-ms the entry was marked REVALIDATING (from the explicit stamp). */
|
|
69
|
+
revalidatingAt?: number;
|
|
70
|
+
/** Raw CF `Age` header, for comparison against revalidatingAt (may be null). */
|
|
71
|
+
ageHeader?: string | null;
|
|
72
|
+
isStale?: boolean;
|
|
73
|
+
isRevalidating?: boolean;
|
|
74
|
+
shouldRevalidate?: boolean;
|
|
75
|
+
/** Wall-clock ms spent in cache.match (bounded by edgeLookupTimeoutMs). */
|
|
76
|
+
matchMs?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Wall-clock ms spent resolving the entry's tag-invalidation markers (the
|
|
79
|
+
* per-request memo -> optional per-colo L1 marker cache -> KV cascade), for a
|
|
80
|
+
* tagged entry. 0/absent for an untagged entry or a memo hit; a non-trivial
|
|
81
|
+
* value is the serial marker-read tail that sits between matchMs and
|
|
82
|
+
* bodyReadMs. Only measured when debug is enabled.
|
|
83
|
+
*/
|
|
84
|
+
markerMs?: number;
|
|
85
|
+
/** Wall-clock ms spent reading the body (bounded by edgeReadTimeoutMs). */
|
|
86
|
+
bodyReadMs?: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Debug sink. `true` logs each {@link CFCacheReadDebugEvent} to console; a
|
|
90
|
+
* function receives the events for programmatic capture.
|
|
91
|
+
*/
|
|
92
|
+
export type CFCacheDebug = boolean | ((event: CFCacheReadDebugEvent) => void);
|
|
93
|
+
export interface CFCacheStoreOptions<TEnv = unknown> {
|
|
94
|
+
/**
|
|
95
|
+
* Cache namespace. If not provided, uses caches.default (recommended).
|
|
96
|
+
* Only set this if you need isolated cache storage.
|
|
97
|
+
*/
|
|
98
|
+
namespace?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Base URL for cache keys.
|
|
101
|
+
*
|
|
102
|
+
* If not provided, derives from request hostname via requestContext:
|
|
103
|
+
* - Production domains → uses `https://{hostname}/`
|
|
104
|
+
* - Dev/preview (localhost, workers.dev, pages.dev) → uses internal fallback URL
|
|
105
|
+
*/
|
|
106
|
+
baseUrl?: string;
|
|
107
|
+
/** Default cache options */
|
|
108
|
+
defaults?: CacheDefaults;
|
|
109
|
+
/**
|
|
110
|
+
* Cloudflare ExecutionContext for non-blocking cache writes.
|
|
111
|
+
* Pass the `ctx` from your worker's fetch handler.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* new CFCacheStore({ ctx: env.ctx })
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
ctx: ExecutionContext;
|
|
119
|
+
/**
|
|
120
|
+
* Optional KV namespace for L2 cache persistence.
|
|
121
|
+
*
|
|
122
|
+
* When provided, KV acts as a global fallback behind the per-colo Cache API.
|
|
123
|
+
* On L1 miss, KV is checked and hits are promoted back to L1.
|
|
124
|
+
* On writes, data is persisted to both L1 and KV.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* new CFCacheStore({ ctx: env.ctx, kv: env.CACHE_KV })
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* Tag-based invalidation (updateTag/revalidateTag) requires KV: the
|
|
132
|
+
* tag-invalidation markers are stored in this same namespace. There is no
|
|
133
|
+
* separate tag-invalidation store to configure.
|
|
134
|
+
*/
|
|
135
|
+
kv?: KVNamespace;
|
|
136
|
+
/**
|
|
137
|
+
* Optional eager-purge hook, called ONCE per updateTag()/revalidateTag() with
|
|
138
|
+
* the namespaced Cloudflare Cache-Tags to purge (one batched call for the
|
|
139
|
+
* whole invalidation, not one per tag). These exactly match the `Cache-Tag`
|
|
140
|
+
* header this store writes on its tag-lookup marker entries
|
|
141
|
+
* (`rg:{namespace}:lk:{encodedTag}`), so forwarding them to Cloudflare's
|
|
142
|
+
* purge-by-tag API evicts the cached lookups in every colo - making
|
|
143
|
+
* cross-colo invalidation prompt instead of waiting out `tagCacheTtl`.
|
|
144
|
+
*
|
|
145
|
+
* Only meaningful with `tagCacheTtl > 0` (otherwise there are no cached
|
|
146
|
+
* lookups to purge). The values are pre-encoded, so commas in tag names are
|
|
147
|
+
* safe to pass straight to the purge API.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* onRevalidateTag: async (cacheTags) => {
|
|
152
|
+
* await fetch(`https://api.cloudflare.com/client/v4/zones/${ZONE}/purge_cache`, {
|
|
153
|
+
* method: "POST",
|
|
154
|
+
* headers: { Authorization: `Bearer ${TOKEN}`, "Content-Type": "application/json" },
|
|
155
|
+
* body: JSON.stringify({ tags: cacheTags }),
|
|
156
|
+
* });
|
|
157
|
+
* }
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
onRevalidateTag?: (cacheTags: string[]) => Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Optional expiration (seconds) for tag-invalidation markers in KV. A marker
|
|
163
|
+
* must outlive every entry tagged before the invalidation, so this MUST
|
|
164
|
+
* exceed your largest entry TTL+SWR. Defaults to no expiration (markers
|
|
165
|
+
* persist; they are tiny - one timestamp per distinct invalidated tag).
|
|
166
|
+
*
|
|
167
|
+
* Note the opposite sizing from `tagCacheTtl` below: `tagInvalidationTtl` must
|
|
168
|
+
* be LARGE (outlive data); `tagCacheTtl` should be SMALL (a staleness ceiling).
|
|
169
|
+
*
|
|
170
|
+
* Cardinality matters: each DISTINCT invalidated tag writes one permanent KV
|
|
171
|
+
* marker (with the no-expiry default). Keep tags LOW-cardinality and never
|
|
172
|
+
* derive an invalidation tag from untrusted input (e.g.
|
|
173
|
+
* `revalidateTag(req.query.tag)`) - an attacker could otherwise grow your KV
|
|
174
|
+
* namespace without bound. Set a `tagInvalidationTtl` only if your tags are
|
|
175
|
+
* unavoidably high-cardinality AND it can still safely exceed your max entry
|
|
176
|
+
* TTL+SWR.
|
|
177
|
+
*/
|
|
178
|
+
tagInvalidationTtl?: number;
|
|
179
|
+
/**
|
|
180
|
+
* Optional TTL (seconds) for caching tag-invalidation markers in the per-colo
|
|
181
|
+
* Cache API (L1), to avoid a KV marker read on every tagged cache read.
|
|
182
|
+
*
|
|
183
|
+
* Default `0` = disabled: the marker is read from KV on every tagged read
|
|
184
|
+
* (today's behavior), giving the strongest cross-colo invalidation latency
|
|
185
|
+
* (~KV consistency). A positive value caches each marker (including the
|
|
186
|
+
* "no marker yet" state) in L1 for that many seconds, so within the window a
|
|
187
|
+
* colo answers from L1 with no KV read.
|
|
188
|
+
*
|
|
189
|
+
* The colo that runs `updateTag`/`revalidateTag` writes the fresh marker
|
|
190
|
+
* straight into its own L1 (write-through), so the invalidating request and
|
|
191
|
+
* later reads in that colo observe the invalidation immediately. One caveat: a
|
|
192
|
+
* read already in flight when the invalidation lands (one that began its KV
|
|
193
|
+
* marker fetch first) can re-cache the PRIOR marker into L1 after the
|
|
194
|
+
* write-through, so a racing concurrent reader in the same colo may miss the
|
|
195
|
+
* invalidation for up to `tagCacheTtl` -- the Cache API exposes no
|
|
196
|
+
* compare-and-set to close this fully. `tagCacheTtl` is therefore a staleness
|
|
197
|
+
* CEILING, not a promise of zero same-colo latency; keep it small (or wire
|
|
198
|
+
* `onRevalidateTag`) when that matters. By default OTHER colos only converge
|
|
199
|
+
* when their cached marker expires, so `tagCacheTtl` is the MAXIMUM extra
|
|
200
|
+
* cross-colo invalidation latency for them. Recommended 30-60 for high-read,
|
|
201
|
+
* low-mutation tags; leave at 0 when prompt global invalidation matters and
|
|
202
|
+
* you cannot wire a purge.
|
|
203
|
+
*
|
|
204
|
+
* To make other colos prompt WITHOUT a short TTL, wire `onRevalidateTag` to a
|
|
205
|
+
* Cloudflare purge-by-tag call: each marker entry carries a namespaced
|
|
206
|
+
* `Cache-Tag`, and `onRevalidateTag` is handed exactly those tags to purge, so
|
|
207
|
+
* the cached lookups are evicted everywhere on invalidation. With a purge
|
|
208
|
+
* wired, `tagCacheTtl` becomes purely a read-cost reducer + fallback window
|
|
209
|
+
* (safe to set large) rather than the invalidation-latency ceiling.
|
|
210
|
+
*/
|
|
211
|
+
tagCacheTtl?: number;
|
|
212
|
+
/**
|
|
213
|
+
* Cache version string override. When this changes, all cached entries are
|
|
214
|
+
* effectively invalidated (new keys won't match old entries).
|
|
215
|
+
*
|
|
216
|
+
* Defaults to the auto-generated VERSION from the `@rangojs/router:version` virtual module.
|
|
217
|
+
* Only set this if you need a custom versioning strategy.
|
|
218
|
+
*/
|
|
219
|
+
version?: string;
|
|
220
|
+
/**
|
|
221
|
+
* Latency budget (ms) for an L1 edge cache (CF Cache API) read. A `match`
|
|
222
|
+
* slower than this is abandoned and treated as a miss, so a degraded colo
|
|
223
|
+
* cannot stall the request; the read then falls through to its normal miss
|
|
224
|
+
* path (L2/KV or render).
|
|
225
|
+
*
|
|
226
|
+
* Defaults to {@link EDGE_LOOKUP_TIMEOUT_MS} (10). Set to 0 (or any value
|
|
227
|
+
* <= 0) to disable the budget and always await `match`.
|
|
228
|
+
*/
|
|
229
|
+
edgeLookupTimeoutMs?: number;
|
|
230
|
+
/**
|
|
231
|
+
* Latency budget (ms) for reading the BODY of a matched L1 entry
|
|
232
|
+
* (response.json()). CF streams the cache body lazily, so the multi-second
|
|
233
|
+
* tail can appear after `match` already resolved; this bounds it. On timeout
|
|
234
|
+
* the read is treated as a miss and falls through to L2/KV or render.
|
|
235
|
+
*
|
|
236
|
+
* Separate from {@link edgeLookupTimeoutMs} because a healthy body read
|
|
237
|
+
* (fetch + JSON parse of a potentially large Flight payload) takes a little
|
|
238
|
+
* longer than a `match`. Defaults to {@link EDGE_READ_TIMEOUT_MS} (20), which
|
|
239
|
+
* clears a healthy per-colo read yet fails fast on a degraded one. Set to 0
|
|
240
|
+
* (or any value <= 0) to disable and always await the body.
|
|
241
|
+
*/
|
|
242
|
+
edgeReadTimeoutMs?: number;
|
|
243
|
+
/**
|
|
244
|
+
* Latency budget (ms) for an L2 (KV) read. KV is the last cache tier before a
|
|
245
|
+
* full render and is a global store (~50ms healthy, seconds when degraded);
|
|
246
|
+
* this bounds it so a slow namespace cannot pin the request. On timeout the
|
|
247
|
+
* read is treated as a miss (no L1 promote) and falls through to render.
|
|
248
|
+
*
|
|
249
|
+
* Defaults to {@link KV_READ_TIMEOUT_MS} (170) -- a few multiples above the
|
|
250
|
+
* ~50ms healthy read, with headroom for legitimate tails (large payloads / far
|
|
251
|
+
* regions) yet still well under a degraded namespace's multi-second tail.
|
|
252
|
+
* Lower it for a tighter SLA, raise it if your healthy KV p99 runs higher; it
|
|
253
|
+
* is a degradation guard-rail, not a tuning lever. Set to 0 (or any value
|
|
254
|
+
* <= 0) to disable and always await KV.
|
|
255
|
+
*/
|
|
256
|
+
kvReadTimeoutMs?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Emit a {@link CFCacheReadDebugEvent} per L1 read. `true` logs to console
|
|
259
|
+
* (visible via `wrangler tail`); pass a function to capture events directly.
|
|
260
|
+
* Off by default. Intended for validating cache behavior on a real
|
|
261
|
+
* deployment before relying on it; not for steady-state production.
|
|
262
|
+
*/
|
|
263
|
+
debug?: CFCacheDebug;
|
|
264
|
+
/**
|
|
265
|
+
* Custom key generator applied to all cache operations.
|
|
266
|
+
* Receives the full RequestContext (including env) and the default-generated key.
|
|
267
|
+
* Return value becomes the final cache key (unless route overrides with `key` option).
|
|
268
|
+
*
|
|
269
|
+
* Reserved prefixes: tag-invalidation markers live in the SAME KV namespace as
|
|
270
|
+
* data, keyed `__tag__/<tag>` (and `__tagmarker__/<tag>` for the L1 cache). A
|
|
271
|
+
* returned key must NOT begin with `__tag__/` or `__tagmarker__/`, or it can
|
|
272
|
+
* collide with a tag marker and corrupt invalidation. The documented
|
|
273
|
+
* prepend-style generators below are safe.
|
|
274
|
+
*
|
|
275
|
+
* @example Using headers for user segmentation
|
|
276
|
+
* ```typescript
|
|
277
|
+
* keyGenerator: (ctx, defaultKey) => {
|
|
278
|
+
* const segment = ctx.request.headers.get('x-user-segment') || 'default';
|
|
279
|
+
* return `${segment}:${defaultKey}`;
|
|
280
|
+
* }
|
|
281
|
+
* ```
|
|
282
|
+
*
|
|
283
|
+
* @example Using env bindings for multi-region
|
|
284
|
+
* ```typescript
|
|
285
|
+
* keyGenerator: (ctx, defaultKey) => {
|
|
286
|
+
* const region = ctx.env.REGION || 'us';
|
|
287
|
+
* return `${region}:${defaultKey}`;
|
|
288
|
+
* }
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* @example Using cookies for locale-aware caching
|
|
292
|
+
* ```typescript
|
|
293
|
+
* keyGenerator: (ctx, defaultKey) => {
|
|
294
|
+
* const locale = cookies().get('locale')?.value || 'en';
|
|
295
|
+
* return `${locale}:${defaultKey}`;
|
|
296
|
+
* }
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
keyGenerator?: (ctx: RequestContext<TEnv>, defaultKey: string) => string | Promise<string>;
|
|
300
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** KV key byte-length ceiling. Cloudflare KV rejects keys larger than this. */
|
|
2
|
+
export declare const KV_MAX_KEY_BYTES = 512;
|
|
3
|
+
/**
|
|
4
|
+
* Cloudflare KV's minimum `expirationTtl` (seconds). A `put` with a smaller
|
|
5
|
+
* expirationTtl is rejected outright. Tag-invalidation markers (the only writes
|
|
6
|
+
* that take a consumer-supplied TTL via tagInvalidationTtl) are floored to this
|
|
7
|
+
* so a too-small value cannot make EVERY updateTag/revalidateTag throw.
|
|
8
|
+
*/
|
|
9
|
+
export declare const KV_MIN_EXPIRATION_TTL = 60;
|
|
10
|
+
/** UTF-8 byte length of a KV key (multibyte tags can exceed the char count). */
|
|
11
|
+
export declare function kvKeyByteLength(key: string): number;
|
|
12
|
+
/**
|
|
13
|
+
* Compute the Cache-Control directive for a stale-path REVALIDATING re-put from
|
|
14
|
+
* the entry's stored hard-expiry deadline (CACHE_EXPIRES_AT_HEADER). Returns the
|
|
15
|
+
* REMAINING ttl so the re-put preserves the original retention deadline instead
|
|
16
|
+
* of restarting it -- copying set()'s original full-window max-age would reset
|
|
17
|
+
* CF's retention clock on every re-arm and pin a perpetually-stale entry forever.
|
|
18
|
+
* An entry lacking a valid deadline (legacy/tampered) floors to max-age=1, so it
|
|
19
|
+
* hard-expires in ~1s and self-heals via KV. Mirrors promoteSegmentToL1's math.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare function remainingCacheControl(headers: Headers, now: number): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache-API path prefix for the optional per-colo L1 cache of tag-invalidation
|
|
3
|
+
* markers (enabled by tagCacheTtl). Distinct from data keys (doc:/fn:/segment)
|
|
4
|
+
* and from the KV marker prefix so the two never collide.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TAG_MARKER_CACHE_PREFIX = "__tagmarker__/";
|
|
7
|
+
/**
|
|
8
|
+
* Sentinel body for an L1-cached marker meaning "this tag has no invalidation
|
|
9
|
+
* marker." Distinct from any real ms-epoch timestamp (always a large positive
|
|
10
|
+
* integer). A Cache API miss (match() === undefined) always means "re-read KV",
|
|
11
|
+
* never "no marker" - absence is only ever represented by this cached sentinel.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TAG_MARKER_ABSENT = "none";
|
|
14
|
+
export declare function getTagMarkerMemo(ctx: object, store: object): Map<string, number | null>;
|
|
15
|
+
export declare function getTagMarkerInflight(ctx: object, store: object): Map<string, Promise<number | null>>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { CFCacheStore, type CFCacheStoreOptions, type CFCacheDebug, type CFCacheReadDebugEvent, type KVNamespace, } from "./cf-cache-store.js";
|
|
2
|
+
export { CACHE_STALE_AT_HEADER, CACHE_STATUS_HEADER, CACHE_REVALIDATING_AT_HEADER, } from "./cf-cache-store.js";
|
|
3
|
+
export { EDGE_LOOKUP_TIMEOUT_MS, EDGE_READ_TIMEOUT_MS, KV_READ_TIMEOUT_MS, } from "./cf-cache-store.js";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document-Level Cache Middleware
|
|
3
|
+
*
|
|
4
|
+
* Caches full HTTP responses at the edge based on Cache-Control headers.
|
|
5
|
+
* Routes opt-in to caching by setting s-maxage or stale-while-revalidate headers.
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* 1. Check cache for existing response
|
|
9
|
+
* 2. If fresh hit → return cached response
|
|
10
|
+
* 3. If stale hit (within SWR window) → return cached, revalidate in background
|
|
11
|
+
* 4. If miss → run handler, cache if response has cache headers
|
|
12
|
+
*/
|
|
13
|
+
import type { MiddlewareFn, MiddlewareContext } from "../router/middleware.js";
|
|
14
|
+
export interface DocumentCacheOptions<TEnv = any> {
|
|
15
|
+
/**
|
|
16
|
+
* Skip caching for specific paths (e.g., API routes)
|
|
17
|
+
*/
|
|
18
|
+
skipPaths?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Custom cache key generator.
|
|
21
|
+
*
|
|
22
|
+
* Replaces the default `host + pathname + search` key entirely. On a
|
|
23
|
+
* multi-domain deployment served by one function you MUST include `url.host`
|
|
24
|
+
* (or an equivalent tenant discriminator) yourself — the default key is
|
|
25
|
+
* host-namespaced, but a custom generator's output is used verbatim, so
|
|
26
|
+
* omitting host bleeds one hostname's cached response to another.
|
|
27
|
+
*/
|
|
28
|
+
keyGenerator?: (url: URL) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Callback to determine if caching should be enabled for this request.
|
|
31
|
+
* Receives the middleware context and returns true to enable caching.
|
|
32
|
+
* If not provided, caching is enabled by default.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* createDocumentCacheMiddleware({
|
|
37
|
+
* isEnabled: (ctx) => !ctx.request.headers.has('x-skip-cache'),
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
isEnabled?: (ctx: MiddlewareContext<TEnv>) => boolean | Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Enable debug logging for cache operations.
|
|
44
|
+
* Logs HIT, MISS, STALE, and REVALIDATED events.
|
|
45
|
+
* Defaults to false.
|
|
46
|
+
*/
|
|
47
|
+
debug?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create document cache middleware
|
|
51
|
+
*
|
|
52
|
+
* Add this middleware to your router to enable document-level caching.
|
|
53
|
+
* It uses the cache store's getResponse/putResponse methods for caching.
|
|
54
|
+
* Routes opt-in by setting Cache-Control headers with s-maxage.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // Add middleware to router
|
|
59
|
+
* const router = createRouter<AppEnv>()
|
|
60
|
+
* .use(createDocumentCacheMiddleware({
|
|
61
|
+
* isEnabled: (ctx) => ctx.url.pathname !== '/admin',
|
|
62
|
+
* }))
|
|
63
|
+
* .route("home", (ctx) => {
|
|
64
|
+
* ctx.headers.set("Cache-Control", "s-maxage=60, stale-while-revalidate=300");
|
|
65
|
+
* return <HomePage />;
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function createDocumentCacheMiddleware<TEnv = any>(options?: DocumentCacheOptions<TEnv>): MiddlewareFn<TEnv>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handle Capture
|
|
3
|
+
*
|
|
4
|
+
* Captures handle pushes during cached function execution.
|
|
5
|
+
* Extracted from cache-runtime.ts so tests can import without
|
|
6
|
+
* pulling in @vitejs/plugin-rsc/rsc dependencies.
|
|
7
|
+
*/
|
|
8
|
+
import type { HandleStore } from "../server/handle-store.js";
|
|
9
|
+
import type { SegmentHandleData } from "./types.js";
|
|
10
|
+
export interface HandleCapture {
|
|
11
|
+
data: Record<string, SegmentHandleData>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Start capturing handle pushes for a cached function execution.
|
|
15
|
+
*
|
|
16
|
+
* Concurrency-safe: multiple overlapping captures on the same
|
|
17
|
+
* HandleStore are independent. Each capture registers a token in a
|
|
18
|
+
* Set; stopping removes it. No ordering requirement (LIFO not needed).
|
|
19
|
+
*/
|
|
20
|
+
export declare function startHandleCapture(handleStore: HandleStore): {
|
|
21
|
+
capture: HandleCapture;
|
|
22
|
+
stop: () => void;
|
|
23
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handle Snapshot
|
|
3
|
+
*
|
|
4
|
+
* Capture and restore handle data for cached segments.
|
|
5
|
+
* Handle data (breadcrumbs, metadata from ctx.use(Handle)) is collected
|
|
6
|
+
* during segment resolution and stored alongside cached segments.
|
|
7
|
+
*/
|
|
8
|
+
import type { ResolvedSegment } from "../types.js";
|
|
9
|
+
import type { HandleStore } from "../server/handle-store.js";
|
|
10
|
+
import type { SegmentHandleData } from "./types.js";
|
|
11
|
+
type HandleRecord = Record<string, SegmentHandleData>;
|
|
12
|
+
export declare function encodeHandles(handles: HandleRecord): Promise<string>;
|
|
13
|
+
export declare function decodeHandles(encoded: string): Promise<HandleRecord | null>;
|
|
14
|
+
export declare function encodeHandleValue(value: unknown): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Decode a Flight-encoded handle-data string. Returns null on any decode
|
|
17
|
+
* failure so the caller can skip handle restore without discarding valid
|
|
18
|
+
* cached/prerendered segments.
|
|
19
|
+
*/
|
|
20
|
+
export declare function decodeHandleValue<T>(encoded: string): Promise<T | null>;
|
|
21
|
+
/**
|
|
22
|
+
* Capture handle data for a set of segments from the handle store.
|
|
23
|
+
* Used when caching segments to preserve their handle data.
|
|
24
|
+
*
|
|
25
|
+
* `exclude` (shell captures: RequestContext._shellCaptureLoaderHandleValues)
|
|
26
|
+
* drops DSL-loader-scoped push values from the CACHE WRITE only: loaders
|
|
27
|
+
* re-run fresh on every HIT, so replaying their captured values would
|
|
28
|
+
* duplicate the fresh push — and their masked nested promises would stall the
|
|
29
|
+
* Flight handle encode to its timeout. Threaded as an explicit argument so
|
|
30
|
+
* every other getDataForSegment consumer (the render-barrier snapshot,
|
|
31
|
+
* prerender) provably sees every push.
|
|
32
|
+
*/
|
|
33
|
+
export declare function captureHandles(segments: ResolvedSegment[], handleStore: HandleStore, exclude?: WeakSet<object>): Record<string, SegmentHandleData>;
|
|
34
|
+
/**
|
|
35
|
+
* Restore handle data from a cached snapshot into the handle store.
|
|
36
|
+
* Used when serving cached segments to replay their handle data.
|
|
37
|
+
*/
|
|
38
|
+
export declare function restoreHandles(handles: Record<string, SegmentHandleData>, handleStore: HandleStore): void;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { SegmentCacheStore, CachedEntryData, CacheGetResult, CacheItemResult, CacheItemOptions, ShellCacheEntry, SerializedSegmentData, SegmentHandleData, } from "./types.js";
|
|
2
|
+
export { MemorySegmentCacheStore } from "./memory-segment-store.js";
|
|
3
|
+
export { CFCacheStore, type CFCacheStoreOptions, type CFCacheDebug, type CFCacheReadDebugEvent, type KVNamespace, CACHE_STALE_AT_HEADER, CACHE_STATUS_HEADER, CACHE_REVALIDATING_AT_HEADER, EDGE_LOOKUP_TIMEOUT_MS, EDGE_READ_TIMEOUT_MS, KV_READ_TIMEOUT_MS, } from "./cf/index.js";
|
|
4
|
+
export { VercelCacheStore, type VercelCacheStoreOptions, type VercelRuntimeCache, type VercelCacheDebug, type VercelCacheReadDebugEvent, type VercelCacheReadOutcome, VERCEL_MAX_ITEM_BYTES, VERCEL_MAX_TAGS_PER_ITEM, VERCEL_MAX_TAG_BYTES, } from "./vercel/index.js";
|
|
5
|
+
export { CacheScope, createCacheScope } from "./cache-scope.js";
|
|
6
|
+
export { createDocumentCacheMiddleware, type DocumentCacheOptions, } from "./document-cache.js";
|
|
7
|
+
export type { CacheErrorCategory } from "./cache-error.js";
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-Memory Segment Cache Store
|
|
3
|
+
*
|
|
4
|
+
* Simple in-memory implementation of SegmentCacheStore.
|
|
5
|
+
* Uses globalThis to survive HMR in development.
|
|
6
|
+
*/
|
|
7
|
+
import type { SegmentCacheStore, CachedEntryData, CacheDefaults, CacheGetResult, CacheItemResult, CacheItemOptions, ShellCacheEntry } from "./types.js";
|
|
8
|
+
import type { RequestContext } from "../server/request-context.js";
|
|
9
|
+
/**
|
|
10
|
+
* Options for MemorySegmentCacheStore
|
|
11
|
+
*/
|
|
12
|
+
export interface MemorySegmentCacheStoreOptions<TEnv = unknown> {
|
|
13
|
+
/**
|
|
14
|
+
* Optional name for this store instance. Named stores persist their
|
|
15
|
+
* backing Map on globalThis so data survives Vite HMR module reloads.
|
|
16
|
+
* Stores with different names get separate Maps.
|
|
17
|
+
*
|
|
18
|
+
* When omitted, the store uses a plain instance-level Map with no
|
|
19
|
+
* globalThis sharing, which is the safest default for isolation.
|
|
20
|
+
*
|
|
21
|
+
* Caveat: two instances constructed with the SAME name share all backing maps
|
|
22
|
+
* (data + tag index), but each keeps its OWN `defaults` and `keyGenerator` from
|
|
23
|
+
* its options - those are not shared. Use one instance per name, or keep the
|
|
24
|
+
* options identical, to avoid surprising divergence.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Two named stores are isolated from each other
|
|
29
|
+
* const fast = new MemorySegmentCacheStore({ name: "fast", defaults: { ttl: 10 } });
|
|
30
|
+
* const slow = new MemorySegmentCacheStore({ name: "slow", defaults: { ttl: 300 } });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
name?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Default cache options for cache() boundaries.
|
|
36
|
+
* When cache() is called without explicit ttl/swr,
|
|
37
|
+
* these defaults are used.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const store = new MemorySegmentCacheStore({
|
|
42
|
+
* defaults: { ttl: 60, swr: 300 }
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
defaults?: CacheDefaults;
|
|
47
|
+
/**
|
|
48
|
+
* Custom key generator applied to all cache operations.
|
|
49
|
+
* Receives the full RequestContext and the default-generated key.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* keyGenerator: (ctx, defaultKey) => {
|
|
54
|
+
* const locale = cookies().get('locale')?.value || 'en';
|
|
55
|
+
* return `${locale}:${defaultKey}`;
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
keyGenerator?: (ctx: RequestContext<TEnv>, defaultKey: string) => string | Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Maximum number of entries kept per internal family (segment, response,
|
|
62
|
+
* item, shell). On insert, once a family reaches the cap its oldest entry is
|
|
63
|
+
* evicted FIFO (insertion order) and its tag-index entries are cleaned up, so
|
|
64
|
+
* a long-lived instance can't grow without bound. Lazy TTL expiry still runs
|
|
65
|
+
* independently. Defaults to DEFAULT_MAX_ENTRIES (1000).
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const store = new MemorySegmentCacheStore({ maxEntries: 500 });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
maxEntries?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* In-memory segment cache store.
|
|
76
|
+
*
|
|
77
|
+
* Suitable for development and single-instance deployments.
|
|
78
|
+
* For production with multiple instances, use a distributed store
|
|
79
|
+
* like Cloudflare KV or Redis.
|
|
80
|
+
*
|
|
81
|
+
* Each family is size-capped at `maxEntries` (default 1000) with FIFO eviction
|
|
82
|
+
* on insert, so a long-lived instance can't grow unbounded; TTL expiry stays
|
|
83
|
+
* lazy on top of that.
|
|
84
|
+
*
|
|
85
|
+
* Tag-index cleanup is lazy, mirroring the data maps: a tagged entry that
|
|
86
|
+
* expires but is never re-read or invalidated leaves its forward+reverse index
|
|
87
|
+
* entries resident until the key is reused, invalidated, or FIFO-evicted. This
|
|
88
|
+
* is bounded by the distinct-tag count and acceptable for a dev/single-instance
|
|
89
|
+
* store. FIFO eviction unregisters the evicted key's tags, so the tag maps do
|
|
90
|
+
* not outlive the capped data maps.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Basic usage
|
|
95
|
+
* const store = new MemorySegmentCacheStore();
|
|
96
|
+
*
|
|
97
|
+
* // With defaults for cache() boundaries
|
|
98
|
+
* const store = new MemorySegmentCacheStore({
|
|
99
|
+
* defaults: { ttl: 60 }
|
|
100
|
+
* });
|
|
101
|
+
*
|
|
102
|
+
* createRSCHandler({
|
|
103
|
+
* router,
|
|
104
|
+
* cache: { store }
|
|
105
|
+
* })
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare class MemorySegmentCacheStore<TEnv = unknown> implements SegmentCacheStore<TEnv> {
|
|
109
|
+
private cache;
|
|
110
|
+
private responseCache;
|
|
111
|
+
private itemCache;
|
|
112
|
+
private shellCache;
|
|
113
|
+
/** tag -> set of prefixed cache keys (seg:key, res:key, item:key, shell:key) */
|
|
114
|
+
private tagIndex;
|
|
115
|
+
/** prefixed cache key -> set of tags (reverse index for O(tags) unregister) */
|
|
116
|
+
private keyTags;
|
|
117
|
+
/**
|
|
118
|
+
* tag -> epoch ms of its latest invalidateTags() call. The build-shell
|
|
119
|
+
* read-through's isTagsInvalidatedSince gate: baked shell entries are
|
|
120
|
+
* immutable in the build manifest, so eviction is answered by comparing
|
|
121
|
+
* these markers against the entry's build-time createdAt. Per-isolate,
|
|
122
|
+
* like every other map here — matching this store's tag semantics.
|
|
123
|
+
*/
|
|
124
|
+
private tagInvalidatedAt;
|
|
125
|
+
readonly defaults?: CacheDefaults;
|
|
126
|
+
readonly keyGenerator?: (ctx: RequestContext<TEnv>, defaultKey: string) => string | Promise<string>;
|
|
127
|
+
/** Per-family FIFO entry cap. */
|
|
128
|
+
readonly maxEntries: number;
|
|
129
|
+
constructor(options?: MemorySegmentCacheStoreOptions<TEnv>);
|
|
130
|
+
/**
|
|
131
|
+
* FIFO cap enforcement, called before inserting `incomingKey` into `map`.
|
|
132
|
+
* When the key is new and the family is at capacity, the oldest entries are
|
|
133
|
+
* evicted in insertion order and their tag-index entries unregistered (so the
|
|
134
|
+
* tag maps don't outlive the capped data map). Overwriting an existing key
|
|
135
|
+
* grows nothing, so it is a no-op.
|
|
136
|
+
*/
|
|
137
|
+
private evictIfNeeded;
|
|
138
|
+
get(key: string): Promise<CacheGetResult | null>;
|
|
139
|
+
set(key: string, data: CachedEntryData, ttl: number, _swr?: number): Promise<void>;
|
|
140
|
+
delete(key: string): Promise<boolean>;
|
|
141
|
+
clear(): Promise<void>;
|
|
142
|
+
getResponse(key: string): Promise<{
|
|
143
|
+
response: Response;
|
|
144
|
+
shouldRevalidate: boolean;
|
|
145
|
+
} | null>;
|
|
146
|
+
putResponse(key: string, response: Response, ttl: number, swr?: number, tags?: string[]): Promise<void>;
|
|
147
|
+
getItem(key: string): Promise<CacheItemResult | null>;
|
|
148
|
+
setItem(key: string, value: string, options?: CacheItemOptions): Promise<void>;
|
|
149
|
+
getShell(key: string): Promise<{
|
|
150
|
+
entry: ShellCacheEntry;
|
|
151
|
+
shouldRevalidate?: boolean;
|
|
152
|
+
} | null>;
|
|
153
|
+
putShell(key: string, entry: ShellCacheEntry, ttlSeconds?: number, swrSeconds?: number, tags?: string[]): Promise<void>;
|
|
154
|
+
isTagsInvalidatedSince(tags: string[], sinceMs: number): Promise<boolean>;
|
|
155
|
+
invalidateTags(tags: string[]): Promise<void>;
|
|
156
|
+
private registerTags;
|
|
157
|
+
private unregisterTags;
|
|
158
|
+
getStats(): {
|
|
159
|
+
size: number;
|
|
160
|
+
keys: string[];
|
|
161
|
+
};
|
|
162
|
+
static resetGlobalCache(): void;
|
|
163
|
+
}
|