@rangojs/router 0.0.0-experimental.dfa55db4 → 0.0.0-experimental.e16b7c00
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 +120 -25
- package/dist/bin/rango.js +147 -57
- package/dist/vite/index.js +2108 -829
- package/dist/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
- package/package.json +13 -8
- package/skills/breadcrumbs/SKILL.md +3 -1
- package/skills/bundle-analysis/SKILL.md +159 -0
- package/skills/cache-guide/SKILL.md +222 -30
- package/skills/caching/SKILL.md +188 -8
- package/skills/composability/SKILL.md +27 -2
- package/skills/document-cache/SKILL.md +78 -55
- package/skills/handler-use/SKILL.md +364 -0
- package/skills/hooks/SKILL.md +229 -20
- package/skills/host-router/SKILL.md +45 -20
- package/skills/i18n/SKILL.md +276 -0
- package/skills/intercept/SKILL.md +46 -4
- package/skills/layout/SKILL.md +28 -7
- package/skills/links/SKILL.md +247 -17
- package/skills/loader/SKILL.md +219 -9
- package/skills/middleware/SKILL.md +47 -12
- package/skills/migrate-nextjs/SKILL.md +582 -0
- package/skills/migrate-react-router/SKILL.md +769 -0
- package/skills/mime-routes/SKILL.md +27 -0
- package/skills/observability/SKILL.md +137 -0
- package/skills/parallel/SKILL.md +71 -6
- package/skills/prerender/SKILL.md +14 -33
- package/skills/rango/SKILL.md +236 -22
- package/skills/react-compiler/SKILL.md +168 -0
- package/skills/response-routes/SKILL.md +66 -9
- package/skills/route/SKILL.md +57 -4
- package/skills/router-setup/SKILL.md +3 -3
- package/skills/server-actions/SKILL.md +751 -0
- package/skills/streams-and-websockets/SKILL.md +283 -0
- package/skills/typesafety/SKILL.md +319 -27
- package/skills/use-cache/SKILL.md +36 -5
- package/skills/view-transitions/SKILL.md +294 -0
- package/src/__augment-tests__/augment.ts +81 -0
- package/src/__augment-tests__/augmented.check.ts +117 -0
- package/src/browser/action-coordinator.ts +53 -36
- package/src/browser/app-shell.ts +52 -0
- package/src/browser/event-controller.ts +86 -70
- package/src/browser/history-state.ts +21 -0
- package/src/browser/index.ts +3 -3
- package/src/browser/navigation-bridge.ts +86 -11
- package/src/browser/navigation-client.ts +76 -28
- package/src/browser/navigation-store.ts +32 -9
- package/src/browser/navigation-transaction.ts +10 -28
- package/src/browser/partial-update.ts +64 -26
- package/src/browser/prefetch/cache.ts +129 -21
- package/src/browser/prefetch/fetch.ts +148 -16
- package/src/browser/prefetch/queue.ts +36 -5
- package/src/browser/rango-state.ts +53 -13
- package/src/browser/react/Link.tsx +30 -2
- package/src/browser/react/NavigationProvider.tsx +72 -31
- package/src/browser/react/filter-segment-order.ts +51 -7
- package/src/browser/react/index.ts +3 -0
- package/src/browser/react/location-state-shared.ts +175 -4
- package/src/browser/react/location-state.ts +39 -13
- package/src/browser/react/use-handle.ts +17 -9
- package/src/browser/react/use-navigation.ts +22 -2
- package/src/browser/react/use-params.ts +20 -8
- package/src/browser/react/use-reverse.ts +106 -0
- package/src/browser/react/use-router.ts +22 -2
- package/src/browser/react/use-segments.ts +11 -8
- package/src/browser/response-adapter.ts +25 -0
- package/src/browser/rsc-router.tsx +64 -22
- package/src/browser/scroll-restoration.ts +22 -14
- package/src/browser/segment-reconciler.ts +36 -14
- package/src/browser/segment-structure-assert.ts +2 -2
- package/src/browser/server-action-bridge.ts +23 -30
- package/src/browser/types.ts +21 -0
- package/src/build/collect-fallback-refs.ts +107 -0
- package/src/build/generate-manifest.ts +60 -35
- package/src/build/generate-route-types.ts +2 -0
- package/src/build/index.ts +2 -0
- package/src/build/route-trie.ts +52 -25
- package/src/build/route-types/codegen.ts +4 -4
- package/src/build/route-types/include-resolution.ts +1 -1
- package/src/build/route-types/per-module-writer.ts +7 -4
- package/src/build/route-types/router-processing.ts +55 -14
- package/src/build/route-types/scan-filter.ts +1 -1
- package/src/build/route-types/source-scan.ts +118 -0
- package/src/build/runtime-discovery.ts +9 -20
- package/src/cache/cache-error.ts +104 -0
- package/src/cache/cache-policy.ts +95 -1
- package/src/cache/cache-runtime.ts +79 -13
- package/src/cache/cache-scope.ts +77 -46
- package/src/cache/cache-tag.ts +135 -0
- package/src/cache/cf/cf-cache-store.ts +1067 -176
- package/src/cache/cf/index.ts +4 -1
- package/src/cache/document-cache.ts +59 -7
- package/src/cache/index.ts +6 -0
- package/src/cache/memory-segment-store.ts +158 -14
- package/src/cache/tag-invalidation.ts +206 -0
- package/src/cache/types.ts +27 -0
- package/src/client.rsc.tsx +3 -0
- package/src/client.tsx +92 -182
- package/src/context-var.ts +5 -5
- package/src/decode-loader-results.ts +36 -0
- package/src/errors.ts +30 -1
- package/src/handle.ts +4 -6
- package/src/host/index.ts +2 -2
- package/src/host/router.ts +129 -57
- package/src/host/types.ts +31 -2
- package/src/host/utils.ts +1 -1
- package/src/href-client.ts +140 -20
- package/src/index.rsc.ts +16 -4
- package/src/index.ts +65 -15
- package/src/loader-store.ts +500 -0
- package/src/loader.rsc.ts +2 -5
- package/src/loader.ts +3 -10
- package/src/missing-id-error.ts +68 -0
- package/src/outlet-context.ts +1 -1
- package/src/prerender.ts +4 -4
- package/src/response-utils.ts +37 -0
- package/src/reverse.ts +65 -36
- package/src/route-content-wrapper.tsx +6 -28
- package/src/route-definition/dsl-helpers.ts +384 -257
- package/src/route-definition/helper-factories.ts +29 -139
- package/src/route-definition/helpers-types.ts +100 -28
- package/src/route-definition/resolve-handler-use.ts +6 -0
- package/src/route-definition/use-item-types.ts +32 -0
- package/src/route-types.ts +26 -41
- package/src/router/content-negotiation.ts +15 -2
- package/src/router/error-handling.ts +1 -1
- package/src/router/handler-context.ts +21 -38
- package/src/router/intercept-resolution.ts +4 -18
- package/src/router/lazy-includes.ts +8 -8
- package/src/router/loader-resolution.ts +19 -2
- package/src/router/manifest.ts +22 -13
- package/src/router/match-api.ts +4 -3
- package/src/router/match-handlers.ts +1 -0
- package/src/router/match-middleware/cache-lookup.ts +46 -92
- package/src/router/match-middleware/cache-store.ts +3 -2
- package/src/router/match-result.ts +103 -4
- package/src/router/metrics.ts +1 -1
- package/src/router/middleware-types.ts +15 -26
- package/src/router/middleware.ts +99 -84
- package/src/router/pattern-matching.ts +101 -17
- package/src/router/prerender-match.ts +3 -1
- package/src/router/preview-match.ts +3 -1
- package/src/router/request-classification.ts +4 -28
- package/src/router/revalidation.ts +58 -2
- package/src/router/router-interfaces.ts +45 -28
- package/src/router/router-options.ts +25 -1
- package/src/router/router-registry.ts +2 -5
- package/src/router/segment-resolution/fresh.ts +32 -6
- package/src/router/segment-resolution/loader-cache.ts +8 -17
- package/src/router/segment-resolution/revalidation.ts +154 -107
- package/src/router/segment-resolution/view-transition-default.ts +36 -0
- package/src/router/substitute-pattern-params.ts +56 -0
- package/src/router/trie-matching.ts +18 -13
- package/src/router/types.ts +8 -0
- package/src/router/url-params.ts +49 -0
- package/src/router.ts +23 -18
- package/src/rsc/handler-context.ts +2 -2
- package/src/rsc/handler.ts +46 -74
- package/src/rsc/helpers.ts +72 -43
- package/src/rsc/index.ts +1 -1
- package/src/rsc/origin-guard.ts +28 -10
- package/src/rsc/progressive-enhancement.ts +4 -0
- package/src/rsc/response-route-handler.ts +54 -54
- package/src/rsc/rsc-rendering.ts +35 -51
- package/src/rsc/runtime-warnings.ts +9 -10
- package/src/rsc/server-action.ts +17 -37
- package/src/rsc/ssr-setup.ts +16 -0
- package/src/rsc/types.ts +8 -2
- package/src/search-params.ts +4 -4
- package/src/segment-content-promise.ts +67 -0
- package/src/segment-loader-promise.ts +122 -0
- package/src/segment-system.tsx +132 -116
- package/src/serialize.ts +243 -0
- package/src/server/context.ts +143 -53
- package/src/server/cookie-store.ts +28 -4
- package/src/server/request-context.ts +46 -44
- package/src/ssr/index.tsx +5 -1
- package/src/static-handler.ts +1 -1
- package/src/types/cache-types.ts +13 -4
- package/src/types/error-types.ts +5 -1
- package/src/types/global-namespace.ts +39 -26
- package/src/types/handler-context.ts +68 -50
- package/src/types/index.ts +1 -0
- package/src/types/loader-types.ts +5 -6
- package/src/types/request-scope.ts +126 -0
- package/src/types/route-entry.ts +11 -0
- package/src/types/segments.ts +36 -2
- package/src/urls/include-helper.ts +34 -67
- package/src/urls/index.ts +0 -3
- package/src/urls/path-helper-types.ts +41 -7
- package/src/urls/path-helper.ts +17 -52
- package/src/urls/pattern-types.ts +36 -19
- package/src/urls/response-types.ts +22 -29
- package/src/urls/type-extraction.ts +26 -116
- package/src/urls/urls-function.ts +1 -5
- package/src/use-loader.tsx +416 -42
- package/src/vite/debug.ts +185 -0
- package/src/vite/discovery/bundle-postprocess.ts +6 -6
- package/src/vite/discovery/discover-routers.ts +101 -51
- package/src/vite/discovery/discovery-errors.ts +194 -0
- package/src/vite/discovery/gate-state.ts +171 -0
- package/src/vite/discovery/prerender-collection.ts +67 -26
- package/src/vite/discovery/route-types-writer.ts +40 -84
- package/src/vite/discovery/self-gen-tracking.ts +27 -1
- package/src/vite/discovery/state.ts +33 -0
- package/src/vite/discovery/virtual-module-codegen.ts +13 -23
- package/src/vite/index.ts +2 -0
- package/src/vite/plugin-types.ts +67 -0
- package/src/vite/plugins/cjs-to-esm.ts +8 -7
- package/src/vite/plugins/client-ref-dedup.ts +16 -0
- package/src/vite/plugins/client-ref-hashing.ts +28 -5
- package/src/vite/plugins/cloudflare-protocol-loader-hook.d.mts +23 -0
- package/src/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
- package/src/vite/plugins/cloudflare-protocol-stub.ts +214 -0
- package/src/vite/plugins/expose-action-id.ts +54 -30
- package/src/vite/plugins/expose-id-utils.ts +24 -8
- package/src/vite/plugins/expose-ids/export-analysis.ts +100 -20
- package/src/vite/plugins/expose-ids/handler-transform.ts +8 -61
- package/src/vite/plugins/expose-ids/loader-transform.ts +3 -5
- package/src/vite/plugins/expose-ids/router-transform.ts +20 -3
- package/src/vite/plugins/expose-internal-ids.ts +503 -468
- package/src/vite/plugins/performance-tracks.ts +29 -25
- package/src/vite/plugins/use-cache-transform.ts +65 -50
- package/src/vite/plugins/version-injector.ts +39 -23
- package/src/vite/plugins/version-plugin.ts +59 -2
- package/src/vite/plugins/virtual-entries.ts +2 -2
- package/src/vite/rango.ts +116 -29
- package/src/vite/router-discovery.ts +750 -100
- package/src/vite/utils/ast-handler-extract.ts +15 -15
- package/src/vite/utils/banner.ts +1 -1
- package/src/vite/utils/bundle-analysis.ts +4 -2
- package/src/vite/utils/client-chunks.ts +190 -0
- package/src/vite/utils/forward-user-plugins.ts +193 -0
- package/src/vite/utils/manifest-utils.ts +21 -5
- package/src/vite/utils/package-resolution.ts +41 -1
- package/src/vite/utils/prerender-utils.ts +21 -6
- package/src/vite/utils/shared-utils.ts +107 -26
- package/dist/__internal.d.ts +0 -83
- package/dist/__internal.d.ts.map +0 -1
- package/dist/__internal.js +0 -19
- package/dist/__internal.js.map +0 -1
- package/dist/__mocks__/version.d.ts +0 -7
- package/dist/__mocks__/version.d.ts.map +0 -1
- package/dist/__mocks__/version.js +0 -7
- package/dist/__mocks__/version.js.map +0 -1
- package/dist/__tests__/client-href.test.d.ts +0 -2
- package/dist/__tests__/client-href.test.d.ts.map +0 -1
- package/dist/__tests__/client-href.test.js +0 -74
- package/dist/__tests__/client-href.test.js.map +0 -1
- package/dist/__tests__/component-utils.test.d.ts +0 -2
- package/dist/__tests__/component-utils.test.d.ts.map +0 -1
- package/dist/__tests__/component-utils.test.js +0 -51
- package/dist/__tests__/component-utils.test.js.map +0 -1
- package/dist/__tests__/event-controller.test.d.ts +0 -2
- package/dist/__tests__/event-controller.test.d.ts.map +0 -1
- package/dist/__tests__/event-controller.test.js +0 -538
- package/dist/__tests__/event-controller.test.js.map +0 -1
- package/dist/__tests__/helpers/route-tree.d.ts +0 -118
- package/dist/__tests__/helpers/route-tree.d.ts.map +0 -1
- package/dist/__tests__/helpers/route-tree.js +0 -374
- package/dist/__tests__/helpers/route-tree.js.map +0 -1
- package/dist/__tests__/match-result.test.d.ts +0 -2
- package/dist/__tests__/match-result.test.d.ts.map +0 -1
- package/dist/__tests__/match-result.test.js +0 -154
- package/dist/__tests__/match-result.test.js.map +0 -1
- package/dist/__tests__/navigation-store.test.d.ts +0 -2
- package/dist/__tests__/navigation-store.test.d.ts.map +0 -1
- package/dist/__tests__/navigation-store.test.js +0 -440
- package/dist/__tests__/navigation-store.test.js.map +0 -1
- package/dist/__tests__/partial-update.test.d.ts +0 -2
- package/dist/__tests__/partial-update.test.d.ts.map +0 -1
- package/dist/__tests__/partial-update.test.js +0 -1009
- package/dist/__tests__/partial-update.test.js.map +0 -1
- package/dist/__tests__/reverse-types.test.d.ts +0 -8
- package/dist/__tests__/reverse-types.test.d.ts.map +0 -1
- package/dist/__tests__/reverse-types.test.js +0 -656
- package/dist/__tests__/reverse-types.test.js.map +0 -1
- package/dist/__tests__/route-definition.test.d.ts +0 -2
- package/dist/__tests__/route-definition.test.d.ts.map +0 -1
- package/dist/__tests__/route-definition.test.js +0 -55
- package/dist/__tests__/route-definition.test.js.map +0 -1
- package/dist/__tests__/router-helpers.test.d.ts +0 -2
- package/dist/__tests__/router-helpers.test.d.ts.map +0 -1
- package/dist/__tests__/router-helpers.test.js +0 -377
- package/dist/__tests__/router-helpers.test.js.map +0 -1
- package/dist/__tests__/router-integration-2.test.d.ts +0 -2
- package/dist/__tests__/router-integration-2.test.d.ts.map +0 -1
- package/dist/__tests__/router-integration-2.test.js +0 -426
- package/dist/__tests__/router-integration-2.test.js.map +0 -1
- package/dist/__tests__/router-integration.test.d.ts +0 -2
- package/dist/__tests__/router-integration.test.d.ts.map +0 -1
- package/dist/__tests__/router-integration.test.js +0 -1051
- package/dist/__tests__/router-integration.test.js.map +0 -1
- package/dist/__tests__/search-params.test.d.ts +0 -5
- package/dist/__tests__/search-params.test.d.ts.map +0 -1
- package/dist/__tests__/search-params.test.js +0 -306
- package/dist/__tests__/search-params.test.js.map +0 -1
- package/dist/__tests__/segment-system.test.d.ts +0 -2
- package/dist/__tests__/segment-system.test.d.ts.map +0 -1
- package/dist/__tests__/segment-system.test.js +0 -627
- package/dist/__tests__/segment-system.test.js.map +0 -1
- package/dist/__tests__/static-handler-types.test.d.ts +0 -8
- package/dist/__tests__/static-handler-types.test.d.ts.map +0 -1
- package/dist/__tests__/static-handler-types.test.js +0 -63
- package/dist/__tests__/static-handler-types.test.js.map +0 -1
- package/dist/__tests__/urls.test.d.ts +0 -2
- package/dist/__tests__/urls.test.d.ts.map +0 -1
- package/dist/__tests__/urls.test.js +0 -421
- package/dist/__tests__/urls.test.js.map +0 -1
- package/dist/__tests__/use-mount.test.d.ts +0 -2
- package/dist/__tests__/use-mount.test.d.ts.map +0 -1
- package/dist/__tests__/use-mount.test.js +0 -35
- package/dist/__tests__/use-mount.test.js.map +0 -1
- package/dist/bin/rango.d.ts +0 -2
- package/dist/bin/rango.d.ts.map +0 -1
- package/dist/bin/rango.js.map +0 -1
- package/dist/browser/event-controller.d.ts +0 -191
- package/dist/browser/event-controller.d.ts.map +0 -1
- package/dist/browser/event-controller.js +0 -559
- package/dist/browser/event-controller.js.map +0 -1
- package/dist/browser/index.d.ts +0 -2
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/index.js +0 -14
- package/dist/browser/index.js.map +0 -1
- package/dist/browser/link-interceptor.d.ts +0 -38
- package/dist/browser/link-interceptor.d.ts.map +0 -1
- package/dist/browser/link-interceptor.js +0 -99
- package/dist/browser/link-interceptor.js.map +0 -1
- package/dist/browser/logging.d.ts +0 -10
- package/dist/browser/logging.d.ts.map +0 -1
- package/dist/browser/logging.js +0 -29
- package/dist/browser/logging.js.map +0 -1
- package/dist/browser/lru-cache.d.ts +0 -17
- package/dist/browser/lru-cache.d.ts.map +0 -1
- package/dist/browser/lru-cache.js +0 -50
- package/dist/browser/lru-cache.js.map +0 -1
- package/dist/browser/merge-segment-loaders.d.ts +0 -39
- package/dist/browser/merge-segment-loaders.d.ts.map +0 -1
- package/dist/browser/merge-segment-loaders.js +0 -102
- package/dist/browser/merge-segment-loaders.js.map +0 -1
- package/dist/browser/navigation-bridge.d.ts +0 -102
- package/dist/browser/navigation-bridge.d.ts.map +0 -1
- package/dist/browser/navigation-bridge.js +0 -708
- package/dist/browser/navigation-bridge.js.map +0 -1
- package/dist/browser/navigation-client.d.ts +0 -25
- package/dist/browser/navigation-client.d.ts.map +0 -1
- package/dist/browser/navigation-client.js +0 -157
- package/dist/browser/navigation-client.js.map +0 -1
- package/dist/browser/navigation-store.d.ts +0 -101
- package/dist/browser/navigation-store.d.ts.map +0 -1
- package/dist/browser/navigation-store.js +0 -625
- package/dist/browser/navigation-store.js.map +0 -1
- package/dist/browser/partial-update.d.ts +0 -75
- package/dist/browser/partial-update.d.ts.map +0 -1
- package/dist/browser/partial-update.js +0 -426
- package/dist/browser/partial-update.js.map +0 -1
- package/dist/browser/react/Link.d.ts +0 -86
- package/dist/browser/react/Link.d.ts.map +0 -1
- package/dist/browser/react/Link.js +0 -128
- package/dist/browser/react/Link.js.map +0 -1
- package/dist/browser/react/NavigationProvider.d.ts +0 -63
- package/dist/browser/react/NavigationProvider.d.ts.map +0 -1
- package/dist/browser/react/NavigationProvider.js +0 -216
- package/dist/browser/react/NavigationProvider.js.map +0 -1
- package/dist/browser/react/ScrollRestoration.d.ts +0 -75
- package/dist/browser/react/ScrollRestoration.d.ts.map +0 -1
- package/dist/browser/react/ScrollRestoration.js +0 -57
- package/dist/browser/react/ScrollRestoration.js.map +0 -1
- package/dist/browser/react/context.d.ts +0 -46
- package/dist/browser/react/context.d.ts.map +0 -1
- package/dist/browser/react/context.js +0 -10
- package/dist/browser/react/context.js.map +0 -1
- package/dist/browser/react/index.d.ts +0 -11
- package/dist/browser/react/index.d.ts.map +0 -1
- package/dist/browser/react/index.js +0 -22
- package/dist/browser/react/index.js.map +0 -1
- package/dist/browser/react/location-state-shared.d.ts +0 -63
- package/dist/browser/react/location-state-shared.d.ts.map +0 -1
- package/dist/browser/react/location-state-shared.js +0 -81
- package/dist/browser/react/location-state-shared.js.map +0 -1
- package/dist/browser/react/location-state.d.ts +0 -23
- package/dist/browser/react/location-state.d.ts.map +0 -1
- package/dist/browser/react/location-state.js +0 -29
- package/dist/browser/react/location-state.js.map +0 -1
- package/dist/browser/react/mount-context.d.ts +0 -24
- package/dist/browser/react/mount-context.d.ts.map +0 -1
- package/dist/browser/react/mount-context.js +0 -24
- package/dist/browser/react/mount-context.js.map +0 -1
- package/dist/browser/react/use-action.d.ts +0 -64
- package/dist/browser/react/use-action.d.ts.map +0 -1
- package/dist/browser/react/use-action.js +0 -134
- package/dist/browser/react/use-action.js.map +0 -1
- package/dist/browser/react/use-client-cache.d.ts +0 -41
- package/dist/browser/react/use-client-cache.d.ts.map +0 -1
- package/dist/browser/react/use-client-cache.js +0 -39
- package/dist/browser/react/use-client-cache.js.map +0 -1
- package/dist/browser/react/use-handle.d.ts +0 -31
- package/dist/browser/react/use-handle.d.ts.map +0 -1
- package/dist/browser/react/use-handle.js +0 -144
- package/dist/browser/react/use-handle.js.map +0 -1
- package/dist/browser/react/use-href.d.ts +0 -33
- package/dist/browser/react/use-href.d.ts.map +0 -1
- package/dist/browser/react/use-href.js +0 -39
- package/dist/browser/react/use-href.js.map +0 -1
- package/dist/browser/react/use-link-status.d.ts +0 -37
- package/dist/browser/react/use-link-status.d.ts.map +0 -1
- package/dist/browser/react/use-link-status.js +0 -99
- package/dist/browser/react/use-link-status.js.map +0 -1
- package/dist/browser/react/use-mount.d.ts +0 -25
- package/dist/browser/react/use-mount.d.ts.map +0 -1
- package/dist/browser/react/use-mount.js +0 -30
- package/dist/browser/react/use-mount.js.map +0 -1
- package/dist/browser/react/use-navigation.d.ts +0 -27
- package/dist/browser/react/use-navigation.d.ts.map +0 -1
- package/dist/browser/react/use-navigation.js +0 -87
- package/dist/browser/react/use-navigation.js.map +0 -1
- package/dist/browser/react/use-segments.d.ts +0 -38
- package/dist/browser/react/use-segments.d.ts.map +0 -1
- package/dist/browser/react/use-segments.js +0 -130
- package/dist/browser/react/use-segments.js.map +0 -1
- package/dist/browser/request-controller.d.ts +0 -26
- package/dist/browser/request-controller.d.ts.map +0 -1
- package/dist/browser/request-controller.js +0 -147
- package/dist/browser/request-controller.js.map +0 -1
- package/dist/browser/rsc-router.d.ts +0 -129
- package/dist/browser/rsc-router.d.ts.map +0 -1
- package/dist/browser/rsc-router.js +0 -195
- package/dist/browser/rsc-router.js.map +0 -1
- package/dist/browser/scroll-restoration.d.ts +0 -93
- package/dist/browser/scroll-restoration.d.ts.map +0 -1
- package/dist/browser/scroll-restoration.js +0 -321
- package/dist/browser/scroll-restoration.js.map +0 -1
- package/dist/browser/segment-structure-assert.d.ts +0 -17
- package/dist/browser/segment-structure-assert.d.ts.map +0 -1
- package/dist/browser/segment-structure-assert.js +0 -59
- package/dist/browser/segment-structure-assert.js.map +0 -1
- package/dist/browser/server-action-bridge.d.ts +0 -26
- package/dist/browser/server-action-bridge.d.ts.map +0 -1
- package/dist/browser/server-action-bridge.js +0 -668
- package/dist/browser/server-action-bridge.js.map +0 -1
- package/dist/browser/shallow.d.ts +0 -12
- package/dist/browser/shallow.d.ts.map +0 -1
- package/dist/browser/shallow.js +0 -34
- package/dist/browser/shallow.js.map +0 -1
- package/dist/browser/types.d.ts +0 -369
- package/dist/browser/types.d.ts.map +0 -1
- package/dist/browser/types.js +0 -2
- package/dist/browser/types.js.map +0 -1
- package/dist/build/__tests__/generate-cli.test.d.ts +0 -2
- package/dist/build/__tests__/generate-cli.test.d.ts.map +0 -1
- package/dist/build/__tests__/generate-cli.test.js +0 -237
- package/dist/build/__tests__/generate-cli.test.js.map +0 -1
- package/dist/build/__tests__/generate-manifest.test.d.ts +0 -2
- package/dist/build/__tests__/generate-manifest.test.d.ts.map +0 -1
- package/dist/build/__tests__/generate-manifest.test.js +0 -119
- package/dist/build/__tests__/generate-manifest.test.js.map +0 -1
- package/dist/build/__tests__/generate-route-types.test.d.ts +0 -2
- package/dist/build/__tests__/generate-route-types.test.d.ts.map +0 -1
- package/dist/build/__tests__/generate-route-types.test.js +0 -620
- package/dist/build/__tests__/generate-route-types.test.js.map +0 -1
- package/dist/build/__tests__/per-router-manifest.test.d.ts +0 -2
- package/dist/build/__tests__/per-router-manifest.test.d.ts.map +0 -1
- package/dist/build/__tests__/per-router-manifest.test.js +0 -308
- package/dist/build/__tests__/per-router-manifest.test.js.map +0 -1
- package/dist/build/generate-manifest.d.ts +0 -81
- package/dist/build/generate-manifest.d.ts.map +0 -1
- package/dist/build/generate-manifest.js +0 -276
- package/dist/build/generate-manifest.js.map +0 -1
- package/dist/build/generate-route-types.d.ts +0 -115
- package/dist/build/generate-route-types.d.ts.map +0 -1
- package/dist/build/generate-route-types.js +0 -740
- package/dist/build/generate-route-types.js.map +0 -1
- package/dist/build/index.d.ts +0 -21
- package/dist/build/index.d.ts.map +0 -1
- package/dist/build/index.js +0 -21
- package/dist/build/index.js.map +0 -1
- package/dist/build/route-trie.d.ts +0 -71
- package/dist/build/route-trie.d.ts.map +0 -1
- package/dist/build/route-trie.js +0 -175
- package/dist/build/route-trie.js.map +0 -1
- package/dist/cache/__tests__/cache-scope.test.d.ts +0 -2
- package/dist/cache/__tests__/cache-scope.test.d.ts.map +0 -1
- package/dist/cache/__tests__/cache-scope.test.js +0 -208
- package/dist/cache/__tests__/cache-scope.test.js.map +0 -1
- package/dist/cache/__tests__/document-cache.test.d.ts +0 -2
- package/dist/cache/__tests__/document-cache.test.d.ts.map +0 -1
- package/dist/cache/__tests__/document-cache.test.js +0 -345
- package/dist/cache/__tests__/document-cache.test.js.map +0 -1
- package/dist/cache/__tests__/memory-segment-store.test.d.ts +0 -2
- package/dist/cache/__tests__/memory-segment-store.test.d.ts.map +0 -1
- package/dist/cache/__tests__/memory-segment-store.test.js +0 -425
- package/dist/cache/__tests__/memory-segment-store.test.js.map +0 -1
- package/dist/cache/__tests__/memory-store.test.d.ts +0 -2
- package/dist/cache/__tests__/memory-store.test.d.ts.map +0 -1
- package/dist/cache/__tests__/memory-store.test.js +0 -367
- package/dist/cache/__tests__/memory-store.test.js.map +0 -1
- package/dist/cache/cache-scope.d.ts +0 -102
- package/dist/cache/cache-scope.d.ts.map +0 -1
- package/dist/cache/cache-scope.js +0 -440
- package/dist/cache/cache-scope.js.map +0 -1
- package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts +0 -2
- package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts.map +0 -1
- package/dist/cache/cf/__tests__/cf-cache-store.test.js +0 -330
- package/dist/cache/cf/__tests__/cf-cache-store.test.js.map +0 -1
- package/dist/cache/cf/cf-cache-store.d.ts +0 -165
- package/dist/cache/cf/cf-cache-store.d.ts.map +0 -1
- package/dist/cache/cf/cf-cache-store.js +0 -242
- package/dist/cache/cf/cf-cache-store.js.map +0 -1
- package/dist/cache/cf/index.d.ts +0 -14
- package/dist/cache/cf/index.d.ts.map +0 -1
- package/dist/cache/cf/index.js +0 -17
- package/dist/cache/cf/index.js.map +0 -1
- package/dist/cache/document-cache.d.ts +0 -64
- package/dist/cache/document-cache.d.ts.map +0 -1
- package/dist/cache/document-cache.js +0 -228
- package/dist/cache/document-cache.js.map +0 -1
- package/dist/cache/index.d.ts +0 -19
- package/dist/cache/index.d.ts.map +0 -1
- package/dist/cache/index.js +0 -21
- package/dist/cache/index.js.map +0 -1
- package/dist/cache/memory-segment-store.d.ts +0 -110
- package/dist/cache/memory-segment-store.d.ts.map +0 -1
- package/dist/cache/memory-segment-store.js +0 -117
- package/dist/cache/memory-segment-store.js.map +0 -1
- package/dist/cache/memory-store.d.ts +0 -41
- package/dist/cache/memory-store.d.ts.map +0 -1
- package/dist/cache/memory-store.js +0 -191
- package/dist/cache/memory-store.js.map +0 -1
- package/dist/cache/types.d.ts +0 -317
- package/dist/cache/types.d.ts.map +0 -1
- package/dist/cache/types.js +0 -12
- package/dist/cache/types.js.map +0 -1
- package/dist/client.d.ts +0 -248
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -367
- package/dist/client.js.map +0 -1
- package/dist/client.rsc.d.ts +0 -26
- package/dist/client.rsc.d.ts.map +0 -1
- package/dist/client.rsc.js +0 -46
- package/dist/client.rsc.js.map +0 -1
- package/dist/component-utils.d.ts +0 -36
- package/dist/component-utils.d.ts.map +0 -1
- package/dist/component-utils.js +0 -61
- package/dist/component-utils.js.map +0 -1
- package/dist/components/DefaultDocument.d.ts +0 -13
- package/dist/components/DefaultDocument.d.ts.map +0 -1
- package/dist/components/DefaultDocument.js +0 -15
- package/dist/components/DefaultDocument.js.map +0 -1
- package/dist/debug.d.ts +0 -58
- package/dist/debug.d.ts.map +0 -1
- package/dist/debug.js +0 -157
- package/dist/debug.js.map +0 -1
- package/dist/default-error-boundary.d.ts +0 -11
- package/dist/default-error-boundary.d.ts.map +0 -1
- package/dist/default-error-boundary.js +0 -45
- package/dist/default-error-boundary.js.map +0 -1
- package/dist/deps/browser.d.ts +0 -2
- package/dist/deps/browser.d.ts.map +0 -1
- package/dist/deps/browser.js +0 -3
- package/dist/deps/browser.js.map +0 -1
- package/dist/deps/html-stream-client.d.ts +0 -2
- package/dist/deps/html-stream-client.d.ts.map +0 -1
- package/dist/deps/html-stream-client.js +0 -3
- package/dist/deps/html-stream-client.js.map +0 -1
- package/dist/deps/html-stream-server.d.ts +0 -2
- package/dist/deps/html-stream-server.d.ts.map +0 -1
- package/dist/deps/html-stream-server.js +0 -3
- package/dist/deps/html-stream-server.js.map +0 -1
- package/dist/deps/rsc.d.ts +0 -2
- package/dist/deps/rsc.d.ts.map +0 -1
- package/dist/deps/rsc.js +0 -4
- package/dist/deps/rsc.js.map +0 -1
- package/dist/deps/ssr.d.ts +0 -2
- package/dist/deps/ssr.d.ts.map +0 -1
- package/dist/deps/ssr.js +0 -3
- package/dist/deps/ssr.js.map +0 -1
- package/dist/errors.d.ts +0 -174
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -241
- package/dist/errors.js.map +0 -1
- package/dist/handle.d.ts +0 -78
- package/dist/handle.d.ts.map +0 -1
- package/dist/handle.js +0 -82
- package/dist/handle.js.map +0 -1
- package/dist/handles/MetaTags.d.ts +0 -14
- package/dist/handles/MetaTags.d.ts.map +0 -1
- package/dist/handles/MetaTags.js +0 -136
- package/dist/handles/MetaTags.js.map +0 -1
- package/dist/handles/index.d.ts +0 -6
- package/dist/handles/index.d.ts.map +0 -1
- package/dist/handles/index.js +0 -6
- package/dist/handles/index.js.map +0 -1
- package/dist/handles/meta.d.ts +0 -39
- package/dist/handles/meta.d.ts.map +0 -1
- package/dist/handles/meta.js +0 -202
- package/dist/handles/meta.js.map +0 -1
- package/dist/host/__tests__/errors.test.d.ts +0 -2
- package/dist/host/__tests__/errors.test.d.ts.map +0 -1
- package/dist/host/__tests__/errors.test.js +0 -76
- package/dist/host/__tests__/errors.test.js.map +0 -1
- package/dist/host/__tests__/pattern-comprehensive.test.d.ts +0 -2
- package/dist/host/__tests__/pattern-comprehensive.test.d.ts.map +0 -1
- package/dist/host/__tests__/pattern-comprehensive.test.js +0 -732
- package/dist/host/__tests__/pattern-comprehensive.test.js.map +0 -1
- package/dist/host/__tests__/pattern-matcher.test.d.ts +0 -2
- package/dist/host/__tests__/pattern-matcher.test.d.ts.map +0 -1
- package/dist/host/__tests__/pattern-matcher.test.js +0 -251
- package/dist/host/__tests__/pattern-matcher.test.js.map +0 -1
- package/dist/host/__tests__/router.test.d.ts +0 -2
- package/dist/host/__tests__/router.test.d.ts.map +0 -1
- package/dist/host/__tests__/router.test.js +0 -241
- package/dist/host/__tests__/router.test.js.map +0 -1
- package/dist/host/__tests__/testing.test.d.ts +0 -2
- package/dist/host/__tests__/testing.test.d.ts.map +0 -1
- package/dist/host/__tests__/testing.test.js +0 -64
- package/dist/host/__tests__/testing.test.js.map +0 -1
- package/dist/host/__tests__/utils.test.d.ts +0 -2
- package/dist/host/__tests__/utils.test.d.ts.map +0 -1
- package/dist/host/__tests__/utils.test.js +0 -29
- package/dist/host/__tests__/utils.test.js.map +0 -1
- package/dist/host/cookie-handler.d.ts +0 -34
- package/dist/host/cookie-handler.d.ts.map +0 -1
- package/dist/host/cookie-handler.js +0 -124
- package/dist/host/cookie-handler.js.map +0 -1
- package/dist/host/errors.d.ts +0 -56
- package/dist/host/errors.d.ts.map +0 -1
- package/dist/host/errors.js +0 -79
- package/dist/host/errors.js.map +0 -1
- package/dist/host/index.d.ts +0 -29
- package/dist/host/index.d.ts.map +0 -1
- package/dist/host/index.js +0 -32
- package/dist/host/index.js.map +0 -1
- package/dist/host/pattern-matcher.d.ts +0 -36
- package/dist/host/pattern-matcher.d.ts.map +0 -1
- package/dist/host/pattern-matcher.js +0 -172
- package/dist/host/pattern-matcher.js.map +0 -1
- package/dist/host/router.d.ts +0 -26
- package/dist/host/router.d.ts.map +0 -1
- package/dist/host/router.js +0 -218
- package/dist/host/router.js.map +0 -1
- package/dist/host/testing.d.ts +0 -36
- package/dist/host/testing.d.ts.map +0 -1
- package/dist/host/testing.js +0 -55
- package/dist/host/testing.js.map +0 -1
- package/dist/host/types.d.ts +0 -115
- package/dist/host/types.d.ts.map +0 -1
- package/dist/host/types.js +0 -7
- package/dist/host/types.js.map +0 -1
- package/dist/host/utils.d.ts +0 -21
- package/dist/host/utils.d.ts.map +0 -1
- package/dist/host/utils.js +0 -23
- package/dist/host/utils.js.map +0 -1
- package/dist/href-client.d.ts +0 -131
- package/dist/href-client.d.ts.map +0 -1
- package/dist/href-client.js +0 -64
- package/dist/href-client.js.map +0 -1
- package/dist/href-context.d.ts +0 -29
- package/dist/href-context.d.ts.map +0 -1
- package/dist/href-context.js +0 -21
- package/dist/href-context.js.map +0 -1
- package/dist/index.d.ts +0 -73
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -91
- package/dist/index.js.map +0 -1
- package/dist/index.rsc.d.ts +0 -32
- package/dist/index.rsc.d.ts.map +0 -1
- package/dist/index.rsc.js +0 -40
- package/dist/index.rsc.js.map +0 -1
- package/dist/internal-debug.d.ts +0 -2
- package/dist/internal-debug.d.ts.map +0 -1
- package/dist/internal-debug.js +0 -5
- package/dist/internal-debug.js.map +0 -1
- package/dist/loader.d.ts +0 -14
- package/dist/loader.d.ts.map +0 -1
- package/dist/loader.js +0 -20
- package/dist/loader.js.map +0 -1
- package/dist/loader.rsc.d.ts +0 -19
- package/dist/loader.rsc.d.ts.map +0 -1
- package/dist/loader.rsc.js +0 -99
- package/dist/loader.rsc.js.map +0 -1
- package/dist/network-error-thrower.d.ts +0 -17
- package/dist/network-error-thrower.d.ts.map +0 -1
- package/dist/network-error-thrower.js +0 -14
- package/dist/network-error-thrower.js.map +0 -1
- package/dist/outlet-context.d.ts +0 -13
- package/dist/outlet-context.d.ts.map +0 -1
- package/dist/outlet-context.js +0 -3
- package/dist/outlet-context.js.map +0 -1
- package/dist/prerender/__tests__/param-hash.test.d.ts +0 -2
- package/dist/prerender/__tests__/param-hash.test.d.ts.map +0 -1
- package/dist/prerender/__tests__/param-hash.test.js +0 -148
- package/dist/prerender/__tests__/param-hash.test.js.map +0 -1
- package/dist/prerender/param-hash.d.ts +0 -16
- package/dist/prerender/param-hash.d.ts.map +0 -1
- package/dist/prerender/param-hash.js +0 -36
- package/dist/prerender/param-hash.js.map +0 -1
- package/dist/prerender/store.d.ts +0 -38
- package/dist/prerender/store.d.ts.map +0 -1
- package/dist/prerender/store.js +0 -61
- package/dist/prerender/store.js.map +0 -1
- package/dist/prerender.d.ts +0 -66
- package/dist/prerender.d.ts.map +0 -1
- package/dist/prerender.js +0 -57
- package/dist/prerender.js.map +0 -1
- package/dist/reverse.d.ts +0 -196
- package/dist/reverse.d.ts.map +0 -1
- package/dist/reverse.js +0 -78
- package/dist/reverse.js.map +0 -1
- package/dist/root-error-boundary.d.ts +0 -33
- package/dist/root-error-boundary.d.ts.map +0 -1
- package/dist/root-error-boundary.js +0 -165
- package/dist/root-error-boundary.js.map +0 -1
- package/dist/route-content-wrapper.d.ts +0 -46
- package/dist/route-content-wrapper.d.ts.map +0 -1
- package/dist/route-content-wrapper.js +0 -77
- package/dist/route-content-wrapper.js.map +0 -1
- package/dist/route-definition.d.ts +0 -421
- package/dist/route-definition.d.ts.map +0 -1
- package/dist/route-definition.js +0 -868
- package/dist/route-definition.js.map +0 -1
- package/dist/route-map-builder.d.ts +0 -155
- package/dist/route-map-builder.d.ts.map +0 -1
- package/dist/route-map-builder.js +0 -237
- package/dist/route-map-builder.js.map +0 -1
- package/dist/route-types.d.ts +0 -165
- package/dist/route-types.d.ts.map +0 -1
- package/dist/route-types.js +0 -7
- package/dist/route-types.js.map +0 -1
- package/dist/router/__tests__/handler-context.test.d.ts +0 -2
- package/dist/router/__tests__/handler-context.test.d.ts.map +0 -1
- package/dist/router/__tests__/handler-context.test.js +0 -65
- package/dist/router/__tests__/handler-context.test.js.map +0 -1
- package/dist/router/__tests__/loader-cycle-detection.test.d.ts +0 -2
- package/dist/router/__tests__/loader-cycle-detection.test.d.ts.map +0 -1
- package/dist/router/__tests__/loader-cycle-detection.test.js +0 -221
- package/dist/router/__tests__/loader-cycle-detection.test.js.map +0 -1
- package/dist/router/__tests__/match-context.test.d.ts +0 -2
- package/dist/router/__tests__/match-context.test.d.ts.map +0 -1
- package/dist/router/__tests__/match-context.test.js +0 -92
- package/dist/router/__tests__/match-context.test.js.map +0 -1
- package/dist/router/__tests__/match-pipelines.test.d.ts +0 -2
- package/dist/router/__tests__/match-pipelines.test.d.ts.map +0 -1
- package/dist/router/__tests__/match-pipelines.test.js +0 -417
- package/dist/router/__tests__/match-pipelines.test.js.map +0 -1
- package/dist/router/__tests__/match-result.test.d.ts +0 -2
- package/dist/router/__tests__/match-result.test.d.ts.map +0 -1
- package/dist/router/__tests__/match-result.test.js +0 -457
- package/dist/router/__tests__/match-result.test.js.map +0 -1
- package/dist/router/__tests__/on-error.test.d.ts +0 -2
- package/dist/router/__tests__/on-error.test.d.ts.map +0 -1
- package/dist/router/__tests__/on-error.test.js +0 -678
- package/dist/router/__tests__/on-error.test.js.map +0 -1
- package/dist/router/__tests__/pattern-matching.test.d.ts +0 -2
- package/dist/router/__tests__/pattern-matching.test.d.ts.map +0 -1
- package/dist/router/__tests__/pattern-matching.test.js +0 -629
- package/dist/router/__tests__/pattern-matching.test.js.map +0 -1
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts +0 -2
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts.map +0 -1
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.js +0 -155
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.js.map +0 -1
- package/dist/router/error-handling.d.ts +0 -77
- package/dist/router/error-handling.d.ts.map +0 -1
- package/dist/router/error-handling.js +0 -202
- package/dist/router/error-handling.js.map +0 -1
- package/dist/router/handler-context.d.ts +0 -20
- package/dist/router/handler-context.d.ts.map +0 -1
- package/dist/router/handler-context.js +0 -198
- package/dist/router/handler-context.js.map +0 -1
- package/dist/router/intercept-resolution.d.ts +0 -66
- package/dist/router/intercept-resolution.d.ts.map +0 -1
- package/dist/router/intercept-resolution.js +0 -246
- package/dist/router/intercept-resolution.js.map +0 -1
- package/dist/router/loader-resolution.d.ts +0 -64
- package/dist/router/loader-resolution.d.ts.map +0 -1
- package/dist/router/loader-resolution.js +0 -284
- package/dist/router/loader-resolution.js.map +0 -1
- package/dist/router/logging.d.ts +0 -15
- package/dist/router/logging.d.ts.map +0 -1
- package/dist/router/logging.js +0 -99
- package/dist/router/logging.js.map +0 -1
- package/dist/router/manifest.d.ts +0 -22
- package/dist/router/manifest.d.ts.map +0 -1
- package/dist/router/manifest.js +0 -181
- package/dist/router/manifest.js.map +0 -1
- package/dist/router/match-api.d.ts +0 -35
- package/dist/router/match-api.d.ts.map +0 -1
- package/dist/router/match-api.js +0 -406
- package/dist/router/match-api.js.map +0 -1
- package/dist/router/match-context.d.ts +0 -206
- package/dist/router/match-context.d.ts.map +0 -1
- package/dist/router/match-context.js +0 -17
- package/dist/router/match-context.js.map +0 -1
- package/dist/router/match-middleware/background-revalidation.d.ts +0 -127
- package/dist/router/match-middleware/background-revalidation.d.ts.map +0 -1
- package/dist/router/match-middleware/background-revalidation.js +0 -75
- package/dist/router/match-middleware/background-revalidation.js.map +0 -1
- package/dist/router/match-middleware/cache-lookup.d.ts +0 -112
- package/dist/router/match-middleware/cache-lookup.d.ts.map +0 -1
- package/dist/router/match-middleware/cache-lookup.js +0 -257
- package/dist/router/match-middleware/cache-lookup.js.map +0 -1
- package/dist/router/match-middleware/cache-store.d.ts +0 -113
- package/dist/router/match-middleware/cache-store.d.ts.map +0 -1
- package/dist/router/match-middleware/cache-store.js +0 -108
- package/dist/router/match-middleware/cache-store.js.map +0 -1
- package/dist/router/match-middleware/index.d.ts +0 -81
- package/dist/router/match-middleware/index.d.ts.map +0 -1
- package/dist/router/match-middleware/index.js +0 -80
- package/dist/router/match-middleware/index.js.map +0 -1
- package/dist/router/match-middleware/intercept-resolution.d.ts +0 -117
- package/dist/router/match-middleware/intercept-resolution.d.ts.map +0 -1
- package/dist/router/match-middleware/intercept-resolution.js +0 -134
- package/dist/router/match-middleware/intercept-resolution.js.map +0 -1
- package/dist/router/match-middleware/segment-resolution.d.ts +0 -99
- package/dist/router/match-middleware/segment-resolution.d.ts.map +0 -1
- package/dist/router/match-middleware/segment-resolution.js +0 -53
- package/dist/router/match-middleware/segment-resolution.js.map +0 -1
- package/dist/router/match-pipelines.d.ts +0 -147
- package/dist/router/match-pipelines.d.ts.map +0 -1
- package/dist/router/match-pipelines.js +0 -82
- package/dist/router/match-pipelines.js.map +0 -1
- package/dist/router/match-result.d.ts +0 -126
- package/dist/router/match-result.d.ts.map +0 -1
- package/dist/router/match-result.js +0 -93
- package/dist/router/match-result.js.map +0 -1
- package/dist/router/metrics.d.ts +0 -20
- package/dist/router/metrics.d.ts.map +0 -1
- package/dist/router/metrics.js +0 -47
- package/dist/router/metrics.js.map +0 -1
- package/dist/router/middleware.d.ts +0 -249
- package/dist/router/middleware.d.ts.map +0 -1
- package/dist/router/middleware.js +0 -434
- package/dist/router/middleware.js.map +0 -1
- package/dist/router/middleware.test.d.ts +0 -2
- package/dist/router/middleware.test.d.ts.map +0 -1
- package/dist/router/middleware.test.js +0 -816
- package/dist/router/middleware.test.js.map +0 -1
- package/dist/router/pattern-matching.d.ts +0 -149
- package/dist/router/pattern-matching.d.ts.map +0 -1
- package/dist/router/pattern-matching.js +0 -349
- package/dist/router/pattern-matching.js.map +0 -1
- package/dist/router/revalidation.d.ts +0 -44
- package/dist/router/revalidation.d.ts.map +0 -1
- package/dist/router/revalidation.js +0 -147
- package/dist/router/revalidation.js.map +0 -1
- package/dist/router/router-context.d.ts +0 -135
- package/dist/router/router-context.d.ts.map +0 -1
- package/dist/router/router-context.js +0 -36
- package/dist/router/router-context.js.map +0 -1
- package/dist/router/segment-resolution.d.ts +0 -127
- package/dist/router/segment-resolution.d.ts.map +0 -1
- package/dist/router/segment-resolution.js +0 -919
- package/dist/router/segment-resolution.js.map +0 -1
- package/dist/router/trie-matching.d.ts +0 -40
- package/dist/router/trie-matching.d.ts.map +0 -1
- package/dist/router/trie-matching.js +0 -127
- package/dist/router/trie-matching.js.map +0 -1
- package/dist/router/types.d.ts +0 -136
- package/dist/router/types.d.ts.map +0 -1
- package/dist/router/types.js +0 -7
- package/dist/router/types.js.map +0 -1
- package/dist/router.d.ts +0 -753
- package/dist/router.d.ts.map +0 -1
- package/dist/router.gen.d.ts +0 -6
- package/dist/router.gen.d.ts.map +0 -1
- package/dist/router.gen.js +0 -6
- package/dist/router.gen.js.map +0 -1
- package/dist/router.js +0 -1304
- package/dist/router.js.map +0 -1
- package/dist/rsc/__tests__/helpers.test.d.ts +0 -2
- package/dist/rsc/__tests__/helpers.test.d.ts.map +0 -1
- package/dist/rsc/__tests__/helpers.test.js +0 -140
- package/dist/rsc/__tests__/helpers.test.js.map +0 -1
- package/dist/rsc/handler.d.ts +0 -45
- package/dist/rsc/handler.d.ts.map +0 -1
- package/dist/rsc/handler.js +0 -1172
- package/dist/rsc/handler.js.map +0 -1
- package/dist/rsc/helpers.d.ts +0 -16
- package/dist/rsc/helpers.d.ts.map +0 -1
- package/dist/rsc/helpers.js +0 -55
- package/dist/rsc/helpers.js.map +0 -1
- package/dist/rsc/index.d.ts +0 -22
- package/dist/rsc/index.d.ts.map +0 -1
- package/dist/rsc/index.js +0 -23
- package/dist/rsc/index.js.map +0 -1
- package/dist/rsc/nonce.d.ts +0 -9
- package/dist/rsc/nonce.d.ts.map +0 -1
- package/dist/rsc/nonce.js +0 -18
- package/dist/rsc/nonce.js.map +0 -1
- package/dist/rsc/types.d.ts +0 -206
- package/dist/rsc/types.d.ts.map +0 -1
- package/dist/rsc/types.js +0 -8
- package/dist/rsc/types.js.map +0 -1
- package/dist/search-params.d.ts +0 -103
- package/dist/search-params.d.ts.map +0 -1
- package/dist/search-params.js +0 -74
- package/dist/search-params.js.map +0 -1
- package/dist/segment-system.d.ts +0 -75
- package/dist/segment-system.d.ts.map +0 -1
- package/dist/segment-system.js +0 -336
- package/dist/segment-system.js.map +0 -1
- package/dist/server/context.d.ts +0 -245
- package/dist/server/context.d.ts.map +0 -1
- package/dist/server/context.js +0 -197
- package/dist/server/context.js.map +0 -1
- package/dist/server/fetchable-loader-store.d.ts +0 -18
- package/dist/server/fetchable-loader-store.d.ts.map +0 -1
- package/dist/server/fetchable-loader-store.js +0 -18
- package/dist/server/fetchable-loader-store.js.map +0 -1
- package/dist/server/handle-store.d.ts +0 -85
- package/dist/server/handle-store.d.ts.map +0 -1
- package/dist/server/handle-store.js +0 -142
- package/dist/server/handle-store.js.map +0 -1
- package/dist/server/loader-registry.d.ts +0 -55
- package/dist/server/loader-registry.d.ts.map +0 -1
- package/dist/server/loader-registry.js +0 -132
- package/dist/server/loader-registry.js.map +0 -1
- package/dist/server/request-context.d.ts +0 -226
- package/dist/server/request-context.d.ts.map +0 -1
- package/dist/server/request-context.js +0 -290
- package/dist/server/request-context.js.map +0 -1
- package/dist/server/root-layout.d.ts +0 -4
- package/dist/server/root-layout.d.ts.map +0 -1
- package/dist/server/root-layout.js +0 -5
- package/dist/server/root-layout.js.map +0 -1
- package/dist/server.d.ts +0 -15
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -20
- package/dist/server.js.map +0 -1
- package/dist/ssr/__tests__/ssr-handler.test.d.ts +0 -2
- package/dist/ssr/__tests__/ssr-handler.test.d.ts.map +0 -1
- package/dist/ssr/__tests__/ssr-handler.test.js +0 -132
- package/dist/ssr/__tests__/ssr-handler.test.js.map +0 -1
- package/dist/ssr/index.d.ts +0 -98
- package/dist/ssr/index.d.ts.map +0 -1
- package/dist/ssr/index.js +0 -158
- package/dist/ssr/index.js.map +0 -1
- package/dist/static-handler.d.ts +0 -50
- package/dist/static-handler.d.ts.map +0 -1
- package/dist/static-handler.gen.d.ts +0 -5
- package/dist/static-handler.gen.d.ts.map +0 -1
- package/dist/static-handler.gen.js +0 -5
- package/dist/static-handler.gen.js.map +0 -1
- package/dist/static-handler.js +0 -29
- package/dist/static-handler.js.map +0 -1
- package/dist/theme/ThemeProvider.d.ts +0 -20
- package/dist/theme/ThemeProvider.d.ts.map +0 -1
- package/dist/theme/ThemeProvider.js +0 -240
- package/dist/theme/ThemeProvider.js.map +0 -1
- package/dist/theme/ThemeScript.d.ts +0 -48
- package/dist/theme/ThemeScript.d.ts.map +0 -1
- package/dist/theme/ThemeScript.js +0 -13
- package/dist/theme/ThemeScript.js.map +0 -1
- package/dist/theme/__tests__/theme.test.d.ts +0 -2
- package/dist/theme/__tests__/theme.test.d.ts.map +0 -1
- package/dist/theme/__tests__/theme.test.js +0 -103
- package/dist/theme/__tests__/theme.test.js.map +0 -1
- package/dist/theme/constants.d.ts +0 -29
- package/dist/theme/constants.d.ts.map +0 -1
- package/dist/theme/constants.js +0 -48
- package/dist/theme/constants.js.map +0 -1
- package/dist/theme/index.d.ts +0 -31
- package/dist/theme/index.d.ts.map +0 -1
- package/dist/theme/index.js +0 -36
- package/dist/theme/index.js.map +0 -1
- package/dist/theme/theme-context.d.ts +0 -40
- package/dist/theme/theme-context.d.ts.map +0 -1
- package/dist/theme/theme-context.js +0 -60
- package/dist/theme/theme-context.js.map +0 -1
- package/dist/theme/theme-script.d.ts +0 -27
- package/dist/theme/theme-script.d.ts.map +0 -1
- package/dist/theme/theme-script.js +0 -147
- package/dist/theme/theme-script.js.map +0 -1
- package/dist/theme/types.d.ts +0 -163
- package/dist/theme/types.d.ts.map +0 -1
- package/dist/theme/types.js +0 -11
- package/dist/theme/types.js.map +0 -1
- package/dist/theme/use-theme.d.ts +0 -12
- package/dist/theme/use-theme.d.ts.map +0 -1
- package/dist/theme/use-theme.js +0 -40
- package/dist/theme/use-theme.js.map +0 -1
- package/dist/types.d.ts +0 -1479
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -10
- package/dist/types.js.map +0 -1
- package/dist/urls.d.ts +0 -441
- package/dist/urls.d.ts.map +0 -1
- package/dist/urls.gen.d.ts +0 -8
- package/dist/urls.gen.d.ts.map +0 -1
- package/dist/urls.gen.js +0 -8
- package/dist/urls.gen.js.map +0 -1
- package/dist/urls.js +0 -443
- package/dist/urls.js.map +0 -1
- package/dist/use-loader.d.ts +0 -127
- package/dist/use-loader.d.ts.map +0 -1
- package/dist/use-loader.js +0 -237
- package/dist/use-loader.js.map +0 -1
- package/dist/vite/__tests__/ast-handler-extract.test.d.ts +0 -2
- package/dist/vite/__tests__/ast-handler-extract.test.d.ts.map +0 -1
- package/dist/vite/__tests__/ast-handler-extract.test.js +0 -294
- package/dist/vite/__tests__/ast-handler-extract.test.js.map +0 -1
- package/dist/vite/__tests__/expose-id-utils.test.d.ts +0 -2
- package/dist/vite/__tests__/expose-id-utils.test.d.ts.map +0 -1
- package/dist/vite/__tests__/expose-id-utils.test.js +0 -224
- package/dist/vite/__tests__/expose-id-utils.test.js.map +0 -1
- package/dist/vite/__tests__/expose-internal-ids.test.d.ts +0 -2
- package/dist/vite/__tests__/expose-internal-ids.test.d.ts.map +0 -1
- package/dist/vite/__tests__/expose-internal-ids.test.js +0 -647
- package/dist/vite/__tests__/expose-internal-ids.test.js.map +0 -1
- package/dist/vite/__tests__/expose-router-id.test.d.ts +0 -2
- package/dist/vite/__tests__/expose-router-id.test.d.ts.map +0 -1
- package/dist/vite/__tests__/expose-router-id.test.js +0 -39
- package/dist/vite/__tests__/expose-router-id.test.js.map +0 -1
- package/dist/vite/ast-handler-extract.d.ts +0 -49
- package/dist/vite/ast-handler-extract.d.ts.map +0 -1
- package/dist/vite/ast-handler-extract.js +0 -249
- package/dist/vite/ast-handler-extract.js.map +0 -1
- package/dist/vite/expose-action-id.d.ts +0 -19
- package/dist/vite/expose-action-id.d.ts.map +0 -1
- package/dist/vite/expose-action-id.js +0 -250
- package/dist/vite/expose-action-id.js.map +0 -1
- package/dist/vite/expose-id-utils.d.ts +0 -69
- package/dist/vite/expose-id-utils.d.ts.map +0 -1
- package/dist/vite/expose-id-utils.js +0 -289
- package/dist/vite/expose-id-utils.js.map +0 -1
- package/dist/vite/expose-internal-ids.d.ts +0 -22
- package/dist/vite/expose-internal-ids.d.ts.map +0 -1
- package/dist/vite/expose-internal-ids.js +0 -886
- package/dist/vite/expose-internal-ids.js.map +0 -1
- package/dist/vite/index.d.ts +0 -149
- package/dist/vite/index.d.ts.map +0 -1
- package/dist/vite/index.js.bak +0 -5448
- package/dist/vite/index.js.map +0 -1
- package/dist/vite/index.named-routes.gen.ts +0 -103
- package/dist/vite/package-resolution.d.ts +0 -43
- package/dist/vite/package-resolution.d.ts.map +0 -1
- package/dist/vite/package-resolution.js +0 -112
- package/dist/vite/package-resolution.js.map +0 -1
- package/dist/vite/virtual-entries.d.ts +0 -25
- package/dist/vite/virtual-entries.d.ts.map +0 -1
- package/dist/vite/virtual-entries.js +0 -110
- package/dist/vite/virtual-entries.js.map +0 -1
- package/src/browser/action-response-classifier.ts +0 -99
package/src/cache/cf/index.ts
CHANGED
|
@@ -16,7 +16,10 @@ export {
|
|
|
16
16
|
type KVNamespace,
|
|
17
17
|
} from "./cf-cache-store.js";
|
|
18
18
|
|
|
19
|
-
// Header constants for debugging and inspection
|
|
19
|
+
// Header constants for debugging and inspection. The tag headers
|
|
20
|
+
// (x-edge-cache-tags / x-edge-cache-tagged-at) are intentionally NOT re-exported:
|
|
21
|
+
// they are an internal encoding detail of the store's tag-invalidation check, not
|
|
22
|
+
// a consumer-inspectable contract.
|
|
20
23
|
export {
|
|
21
24
|
CACHE_STALE_AT_HEADER,
|
|
22
25
|
CACHE_STATUS_HEADER,
|
|
@@ -12,10 +12,14 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import type { MiddlewareFn, MiddlewareContext } from "../router/middleware.js";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
getRequestContext,
|
|
17
|
+
type RequestContext,
|
|
18
|
+
} from "../server/request-context.js";
|
|
16
19
|
import { mayNeedSSR } from "../rsc/ssr-setup.js";
|
|
17
20
|
import { sortedSearchString } from "./cache-key-utils.js";
|
|
18
21
|
import { runBackground } from "./background-task.js";
|
|
22
|
+
import { reportCacheError } from "./cache-error.js";
|
|
19
23
|
|
|
20
24
|
// ============================================================================
|
|
21
25
|
// Constants
|
|
@@ -24,6 +28,32 @@ import { runBackground } from "./background-task.js";
|
|
|
24
28
|
/** Header indicating cache status for debugging */
|
|
25
29
|
const CACHE_STATUS_HEADER = "x-document-cache-status";
|
|
26
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Snapshot the request-scoped tag union for a document cache write. The full-page
|
|
33
|
+
* entry is tagged with every cache tag its content resolved (runtime cacheTag(),
|
|
34
|
+
* "use cache" profile tags, and loader cache tags) so updateTag()/revalidateTag()
|
|
35
|
+
* can invalidate it. Returns undefined when no tags were used, keeping untagged
|
|
36
|
+
* document entries header-free.
|
|
37
|
+
*
|
|
38
|
+
* This is a plain synchronous snapshot. The CALLER must drain the rendered body
|
|
39
|
+
* first (see the cache-write closures): runtime cacheTag()/"use cache" and loader
|
|
40
|
+
* tags are recorded synchronously as each value resolves during render, including
|
|
41
|
+
* Suspense-streamed ones that resolve AFTER the handler-settlement barrier - so
|
|
42
|
+
* the correct barrier is the stream draining (render complete), not _handleStore.
|
|
43
|
+
*
|
|
44
|
+
* Caveat: segment cache({ tags }) DSL tags are recorded inside the deferred
|
|
45
|
+
* cacheRoute waitUntil, which can still run after this snapshot; a document that
|
|
46
|
+
* combines whole-page document caching with segment-DSL tags may miss those (the
|
|
47
|
+
* segment cache entry itself is still correctly tagged and invalidated). Runtime
|
|
48
|
+
* cacheTag()/"use cache" and loader tags are always captured once the body drains.
|
|
49
|
+
*/
|
|
50
|
+
function collectRequestTags(
|
|
51
|
+
requestCtx: RequestContext | undefined,
|
|
52
|
+
): string[] | undefined {
|
|
53
|
+
const tags = requestCtx?._requestTags;
|
|
54
|
+
return tags && tags.size > 0 ? [...tags] : undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
27
57
|
/**
|
|
28
58
|
* Simple hash function for segment IDs.
|
|
29
59
|
* Creates a short, deterministic hash to differentiate cache keys
|
|
@@ -303,17 +333,26 @@ export function createDocumentCacheMiddleware<TEnv = any>(
|
|
|
303
333
|
const fresh = await next();
|
|
304
334
|
const directives = shouldCacheResponse(fresh);
|
|
305
335
|
|
|
306
|
-
if (directives) {
|
|
336
|
+
if (directives && fresh.body) {
|
|
337
|
+
// Background revalidation: nothing streams to a client, so drain
|
|
338
|
+
// the fresh render fully before snapshotting tags (same
|
|
339
|
+
// render-complete barrier as the miss path).
|
|
340
|
+
const body = await new Response(fresh.body).arrayBuffer();
|
|
307
341
|
await store.putResponse!(
|
|
308
342
|
cacheKey,
|
|
309
|
-
fresh,
|
|
343
|
+
new Response(body, fresh),
|
|
310
344
|
directives.sMaxAge!,
|
|
311
345
|
directives.staleWhileRevalidate,
|
|
346
|
+
collectRequestTags(requestCtx),
|
|
312
347
|
);
|
|
313
348
|
log(`[DocumentCache] REVALIDATED ${typeLabel}: ${url.pathname}`);
|
|
314
349
|
}
|
|
315
350
|
} catch (error) {
|
|
316
|
-
|
|
351
|
+
reportCacheError(
|
|
352
|
+
error,
|
|
353
|
+
"cache-write",
|
|
354
|
+
"[DocumentCache] revalidation",
|
|
355
|
+
);
|
|
317
356
|
}
|
|
318
357
|
});
|
|
319
358
|
|
|
@@ -346,14 +385,27 @@ export function createDocumentCacheMiddleware<TEnv = any>(
|
|
|
346
385
|
// Clone response for caching (non-blocking)
|
|
347
386
|
runBackground(requestCtx, async () => {
|
|
348
387
|
try {
|
|
388
|
+
// Drain the cache copy fully BEFORE snapshotting tags. Tags from
|
|
389
|
+
// Suspense-streamed "use cache"/cacheTag and loaders are recorded as
|
|
390
|
+
// each value resolves during the RSC/HTML render, which completes
|
|
391
|
+
// only when the stream ends - the handler-settlement barrier is too
|
|
392
|
+
// early. Buffering the body (the client streams the other tee branch,
|
|
393
|
+
// unaffected) is the render-complete barrier that keeps the cached
|
|
394
|
+
// body and its tag set consistent.
|
|
395
|
+
const body = await new Response(cacheStream).arrayBuffer();
|
|
349
396
|
await store.putResponse!(
|
|
350
397
|
cacheKey,
|
|
351
|
-
new Response(
|
|
398
|
+
new Response(body, originalResponse),
|
|
352
399
|
directives.sMaxAge!,
|
|
353
400
|
directives.staleWhileRevalidate,
|
|
401
|
+
collectRequestTags(requestCtx),
|
|
354
402
|
);
|
|
355
403
|
} catch (error) {
|
|
356
|
-
|
|
404
|
+
reportCacheError(
|
|
405
|
+
error,
|
|
406
|
+
"cache-write",
|
|
407
|
+
"[DocumentCache] cache write",
|
|
408
|
+
);
|
|
357
409
|
}
|
|
358
410
|
});
|
|
359
411
|
|
|
@@ -366,7 +418,7 @@ export function createDocumentCacheMiddleware<TEnv = any>(
|
|
|
366
418
|
// No cache headers - pass through
|
|
367
419
|
return originalResponse;
|
|
368
420
|
} catch (error) {
|
|
369
|
-
|
|
421
|
+
reportCacheError(error, "cache-read", "[DocumentCache] middleware");
|
|
370
422
|
if (handlerCalled) {
|
|
371
423
|
// Post-handler failure (e.g. body.tee()): do not call next() again
|
|
372
424
|
// as that would re-run handler side effects.
|
package/src/cache/index.ts
CHANGED
|
@@ -42,3 +42,9 @@ export {
|
|
|
42
42
|
createDocumentCacheMiddleware,
|
|
43
43
|
type DocumentCacheOptions,
|
|
44
44
|
} from "./document-cache.js";
|
|
45
|
+
|
|
46
|
+
// Cache error reporting. CacheErrorCategory is the discriminator surfaced to a
|
|
47
|
+
// router's onError callback as `metadata.category` for the `cache` phase, so
|
|
48
|
+
// consumers can branch on the failure kind (e.g. distinguish a transient
|
|
49
|
+
// cache-read outage from cache-corrupt self-heal).
|
|
50
|
+
export type { CacheErrorCategory } from "./cache-error.js";
|
|
@@ -21,10 +21,13 @@ import {
|
|
|
21
21
|
computeExpiration,
|
|
22
22
|
DEFAULT_FUNCTION_TTL,
|
|
23
23
|
} from "./cache-policy.js";
|
|
24
|
+
import { reportCacheError } from "./cache-error.js";
|
|
24
25
|
|
|
25
26
|
const CACHE_REGISTRY_KEY = "__rsc_router_segment_cache_registry__";
|
|
26
27
|
const RESPONSE_CACHE_REGISTRY_KEY = "__rsc_router_response_cache_registry__";
|
|
27
28
|
const ITEM_CACHE_REGISTRY_KEY = "__rsc_router_item_cache_registry__";
|
|
29
|
+
const TAG_INDEX_REGISTRY_KEY = "__rsc_router_tag_index_registry__";
|
|
30
|
+
const KEY_TAGS_REGISTRY_KEY = "__rsc_router_key_tags_registry__";
|
|
28
31
|
|
|
29
32
|
/**
|
|
30
33
|
* Get or create a named Map from a globalThis-backed registry.
|
|
@@ -59,6 +62,7 @@ interface CachedItemEntry {
|
|
|
59
62
|
handles?: Record<string, SegmentHandleData>;
|
|
60
63
|
expiresAt: number;
|
|
61
64
|
staleAt: number;
|
|
65
|
+
tags?: string[];
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
/**
|
|
@@ -73,6 +77,11 @@ export interface MemorySegmentCacheStoreOptions<TEnv = unknown> {
|
|
|
73
77
|
* When omitted, the store uses a plain instance-level Map with no
|
|
74
78
|
* globalThis sharing, which is the safest default for isolation.
|
|
75
79
|
*
|
|
80
|
+
* Caveat: two instances constructed with the SAME name share all backing maps
|
|
81
|
+
* (data + tag index), but each keeps its OWN `defaults` and `keyGenerator` from
|
|
82
|
+
* its options - those are not shared. Use one instance per name, or keep the
|
|
83
|
+
* options identical, to avoid surprising divergence.
|
|
84
|
+
*
|
|
76
85
|
* @example
|
|
77
86
|
* ```typescript
|
|
78
87
|
* // Two named stores are isolated from each other
|
|
@@ -121,6 +130,11 @@ export interface MemorySegmentCacheStoreOptions<TEnv = unknown> {
|
|
|
121
130
|
* For production with multiple instances, use a distributed store
|
|
122
131
|
* like Cloudflare KV or Redis.
|
|
123
132
|
*
|
|
133
|
+
* Tag-index cleanup is lazy, mirroring the data maps: a tagged entry that
|
|
134
|
+
* expires but is never re-read or invalidated leaves its forward+reverse index
|
|
135
|
+
* entries resident until the key is reused or invalidated. This is bounded by
|
|
136
|
+
* the distinct-tag count and acceptable for a dev/single-instance store.
|
|
137
|
+
*
|
|
124
138
|
* @example
|
|
125
139
|
* ```typescript
|
|
126
140
|
* // Basic usage
|
|
@@ -143,6 +157,10 @@ export class MemorySegmentCacheStore<
|
|
|
143
157
|
private cache: Map<string, CachedEntryData>;
|
|
144
158
|
private responseCache: Map<string, CachedResponseEntry>;
|
|
145
159
|
private itemCache: Map<string, CachedItemEntry>;
|
|
160
|
+
/** tag -> set of prefixed cache keys (seg:key, res:key, item:key) */
|
|
161
|
+
private tagIndex: Map<string, Set<string>>;
|
|
162
|
+
/** prefixed cache key -> set of tags (reverse index for O(tags) unregister) */
|
|
163
|
+
private keyTags: Map<string, Set<string>>;
|
|
146
164
|
readonly defaults?: CacheDefaults;
|
|
147
165
|
readonly keyGenerator?: (
|
|
148
166
|
ctx: RequestContext<TEnv>,
|
|
@@ -165,11 +183,21 @@ export class MemorySegmentCacheStore<
|
|
|
165
183
|
ITEM_CACHE_REGISTRY_KEY,
|
|
166
184
|
options.name,
|
|
167
185
|
);
|
|
186
|
+
this.tagIndex = getNamedMap<Set<string>>(
|
|
187
|
+
TAG_INDEX_REGISTRY_KEY,
|
|
188
|
+
options.name,
|
|
189
|
+
);
|
|
190
|
+
this.keyTags = getNamedMap<Set<string>>(
|
|
191
|
+
KEY_TAGS_REGISTRY_KEY,
|
|
192
|
+
options.name,
|
|
193
|
+
);
|
|
168
194
|
} else {
|
|
169
195
|
// Unnamed stores get a plain instance-level Map (no globalThis sharing).
|
|
170
196
|
this.cache = new Map<string, CachedEntryData>();
|
|
171
197
|
this.responseCache = new Map<string, CachedResponseEntry>();
|
|
172
198
|
this.itemCache = new Map<string, CachedItemEntry>();
|
|
199
|
+
this.tagIndex = new Map<string, Set<string>>();
|
|
200
|
+
this.keyTags = new Map<string, Set<string>>();
|
|
173
201
|
}
|
|
174
202
|
this.defaults = options?.defaults;
|
|
175
203
|
this.keyGenerator = options?.keyGenerator;
|
|
@@ -184,6 +212,7 @@ export class MemorySegmentCacheStore<
|
|
|
184
212
|
|
|
185
213
|
// Check expiration
|
|
186
214
|
if (Date.now() > cached.expiresAt) {
|
|
215
|
+
this.unregisterTags(`seg:${key}`);
|
|
187
216
|
this.cache.delete(key);
|
|
188
217
|
return null;
|
|
189
218
|
}
|
|
@@ -204,10 +233,18 @@ export class MemorySegmentCacheStore<
|
|
|
204
233
|
...data,
|
|
205
234
|
expiresAt: Date.now() + ttl * 1000,
|
|
206
235
|
};
|
|
236
|
+
const prefixedKey = `seg:${key}`;
|
|
237
|
+
// Always drop stale tag mappings before writing so an overwrite with
|
|
238
|
+
// different (or no) tags cannot leave the previous tags pointing here.
|
|
239
|
+
this.unregisterTags(prefixedKey);
|
|
207
240
|
this.cache.set(key, entry);
|
|
241
|
+
if (data.tags && data.tags.length > 0) {
|
|
242
|
+
this.registerTags(data.tags, prefixedKey);
|
|
243
|
+
}
|
|
208
244
|
}
|
|
209
245
|
|
|
210
246
|
async delete(key: string): Promise<boolean> {
|
|
247
|
+
this.unregisterTags(`seg:${key}`);
|
|
211
248
|
return this.cache.delete(key);
|
|
212
249
|
}
|
|
213
250
|
|
|
@@ -215,6 +252,8 @@ export class MemorySegmentCacheStore<
|
|
|
215
252
|
this.cache.clear();
|
|
216
253
|
this.responseCache.clear();
|
|
217
254
|
this.itemCache.clear();
|
|
255
|
+
this.tagIndex.clear();
|
|
256
|
+
this.keyTags.clear();
|
|
218
257
|
}
|
|
219
258
|
|
|
220
259
|
async getResponse(
|
|
@@ -224,6 +263,7 @@ export class MemorySegmentCacheStore<
|
|
|
224
263
|
if (!cached) return null;
|
|
225
264
|
|
|
226
265
|
if (Date.now() > cached.expiresAt) {
|
|
266
|
+
this.unregisterTags(`res:${key}`);
|
|
227
267
|
this.responseCache.delete(key);
|
|
228
268
|
return null;
|
|
229
269
|
}
|
|
@@ -244,23 +284,40 @@ export class MemorySegmentCacheStore<
|
|
|
244
284
|
response: Response,
|
|
245
285
|
ttl: number,
|
|
246
286
|
swr?: number,
|
|
287
|
+
tags?: string[],
|
|
247
288
|
): Promise<void> {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
289
|
+
try {
|
|
290
|
+
// arrayBuffer() can reject (e.g. an already-consumed body). A write
|
|
291
|
+
// failure must degrade to a no-op (entry simply not cached), never throw
|
|
292
|
+
// up and fail the request.
|
|
293
|
+
const body = await response.clone().arrayBuffer();
|
|
294
|
+
const headers: [string, string][] = [];
|
|
295
|
+
response.headers.forEach((value, name) => {
|
|
296
|
+
headers.push([name, value]);
|
|
297
|
+
});
|
|
253
298
|
|
|
254
|
-
|
|
255
|
-
|
|
299
|
+
const swrWindow = resolveSwrWindow(swr, this.defaults);
|
|
300
|
+
const { staleAt, expiresAt } = computeExpiration(ttl, swrWindow);
|
|
256
301
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
302
|
+
const prefixedKey = `res:${key}`;
|
|
303
|
+
this.unregisterTags(prefixedKey);
|
|
304
|
+
this.responseCache.set(key, {
|
|
305
|
+
body,
|
|
306
|
+
status: response.status,
|
|
307
|
+
headers,
|
|
308
|
+
expiresAt,
|
|
309
|
+
staleAt,
|
|
310
|
+
});
|
|
311
|
+
if (tags && tags.length > 0) {
|
|
312
|
+
this.registerTags(tags, prefixedKey);
|
|
313
|
+
}
|
|
314
|
+
} catch (error) {
|
|
315
|
+
reportCacheError(
|
|
316
|
+
error,
|
|
317
|
+
"cache-write",
|
|
318
|
+
"[MemorySegmentCacheStore] putResponse",
|
|
319
|
+
);
|
|
320
|
+
}
|
|
264
321
|
}
|
|
265
322
|
|
|
266
323
|
async getItem(key: string): Promise<CacheItemResult | null> {
|
|
@@ -269,6 +326,7 @@ export class MemorySegmentCacheStore<
|
|
|
269
326
|
|
|
270
327
|
const now = Date.now();
|
|
271
328
|
if (now > cached.expiresAt) {
|
|
329
|
+
this.unregisterTags(`item:${key}`);
|
|
272
330
|
this.itemCache.delete(key);
|
|
273
331
|
return null;
|
|
274
332
|
}
|
|
@@ -278,6 +336,7 @@ export class MemorySegmentCacheStore<
|
|
|
278
336
|
value: cached.value,
|
|
279
337
|
handles: cached.handles,
|
|
280
338
|
shouldRevalidate: isStale,
|
|
339
|
+
tags: cached.tags,
|
|
281
340
|
};
|
|
282
341
|
}
|
|
283
342
|
|
|
@@ -289,12 +348,95 @@ export class MemorySegmentCacheStore<
|
|
|
289
348
|
const ttl = resolveTtl(options?.ttl, this.defaults, DEFAULT_FUNCTION_TTL);
|
|
290
349
|
const swrWindow = resolveSwrWindow(options?.swr, this.defaults);
|
|
291
350
|
const { staleAt, expiresAt } = computeExpiration(ttl, swrWindow);
|
|
351
|
+
const prefixedKey = `item:${key}`;
|
|
352
|
+
this.unregisterTags(prefixedKey);
|
|
292
353
|
this.itemCache.set(key, {
|
|
293
354
|
value,
|
|
294
355
|
handles: options?.handles,
|
|
295
356
|
expiresAt,
|
|
296
357
|
staleAt,
|
|
358
|
+
tags: options?.tags,
|
|
297
359
|
});
|
|
360
|
+
if (options?.tags && options.tags.length > 0) {
|
|
361
|
+
this.registerTags(options.tags, prefixedKey);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Invalidate every cache entry (segment, response, item) tagged with any of
|
|
367
|
+
* `tags`. Entries are dropped immediately; the next read is a miss and
|
|
368
|
+
* re-renders fresh. This is the store-level primitive both updateTag() and
|
|
369
|
+
* revalidateTag() delegate to. (In-process, so there is nothing to batch
|
|
370
|
+
* beyond looping the tags.)
|
|
371
|
+
*/
|
|
372
|
+
async invalidateTags(tags: string[]): Promise<void> {
|
|
373
|
+
for (const tag of tags) {
|
|
374
|
+
const keys = this.tagIndex.get(tag);
|
|
375
|
+
if (!keys || keys.size === 0) continue;
|
|
376
|
+
|
|
377
|
+
// Snapshot the keys before mutating the index inside the loop.
|
|
378
|
+
const prefixedKeys = [...keys];
|
|
379
|
+
|
|
380
|
+
for (const prefixedKey of prefixedKeys) {
|
|
381
|
+
const colonIdx = prefixedKey.indexOf(":");
|
|
382
|
+
const prefix = prefixedKey.slice(0, colonIdx);
|
|
383
|
+
const rawKey = prefixedKey.slice(colonIdx + 1);
|
|
384
|
+
|
|
385
|
+
if (prefix === "seg") {
|
|
386
|
+
this.cache.delete(rawKey);
|
|
387
|
+
} else if (prefix === "res") {
|
|
388
|
+
this.responseCache.delete(rawKey);
|
|
389
|
+
} else if (prefix === "item") {
|
|
390
|
+
this.itemCache.delete(rawKey);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Drop this key from every tag set it belonged to, not just `tag`.
|
|
394
|
+
this.unregisterTags(prefixedKey);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Register `tags` for a prefixed cache key in both the forward
|
|
401
|
+
* (tag -> keys) and reverse (key -> tags) indexes.
|
|
402
|
+
* Callers must call unregisterTags() first to clear stale mappings.
|
|
403
|
+
* @internal
|
|
404
|
+
*/
|
|
405
|
+
private registerTags(tags: string[], prefixedKey: string): void {
|
|
406
|
+
let tagSet = this.keyTags.get(prefixedKey);
|
|
407
|
+
if (!tagSet) {
|
|
408
|
+
tagSet = new Set();
|
|
409
|
+
this.keyTags.set(prefixedKey, tagSet);
|
|
410
|
+
}
|
|
411
|
+
for (const tag of tags) {
|
|
412
|
+
tagSet.add(tag);
|
|
413
|
+
let keys = this.tagIndex.get(tag);
|
|
414
|
+
if (!keys) {
|
|
415
|
+
keys = new Set();
|
|
416
|
+
this.tagIndex.set(tag, keys);
|
|
417
|
+
}
|
|
418
|
+
keys.add(prefixedKey);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Remove a prefixed cache key from every tag set it belongs to.
|
|
424
|
+
* Uses the reverse index so this is O(tags-per-key), not O(total-tags).
|
|
425
|
+
* @internal
|
|
426
|
+
*/
|
|
427
|
+
private unregisterTags(prefixedKey: string): void {
|
|
428
|
+
const tagSet = this.keyTags.get(prefixedKey);
|
|
429
|
+
if (!tagSet) return;
|
|
430
|
+
for (const tag of tagSet) {
|
|
431
|
+
const keys = this.tagIndex.get(tag);
|
|
432
|
+
if (keys) {
|
|
433
|
+
keys.delete(prefixedKey);
|
|
434
|
+
if (keys.size === 0) {
|
|
435
|
+
this.tagIndex.delete(tag);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
this.keyTags.delete(prefixedKey);
|
|
298
440
|
}
|
|
299
441
|
|
|
300
442
|
/**
|
|
@@ -324,5 +466,7 @@ export class MemorySegmentCacheStore<
|
|
|
324
466
|
delete (globalThis as any)[CACHE_REGISTRY_KEY];
|
|
325
467
|
delete (globalThis as any)[RESPONSE_CACHE_REGISTRY_KEY];
|
|
326
468
|
delete (globalThis as any)[ITEM_CACHE_REGISTRY_KEY];
|
|
469
|
+
delete (globalThis as any)[TAG_INDEX_REGISTRY_KEY];
|
|
470
|
+
delete (globalThis as any)[KEY_TAGS_REGISTRY_KEY];
|
|
327
471
|
}
|
|
328
472
|
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache Tag Invalidation API
|
|
3
|
+
*
|
|
4
|
+
* Two on-demand invalidation verbs, mirroring the distinction popularized by
|
|
5
|
+
* Next.js so consumers can pick the right consistency model:
|
|
6
|
+
*
|
|
7
|
+
* - updateTag(...tags): read-your-own-writes. Awaitable - resolves only after
|
|
8
|
+
* in-process invalidation across every configured store completes. Use in a
|
|
9
|
+
* Server Action and `await` it before the action re-renders, so the action's
|
|
10
|
+
* own response reflects the mutation.
|
|
11
|
+
*
|
|
12
|
+
* - revalidateTag(...tags): fire-and-forget via waitUntil - the response is not
|
|
13
|
+
* blocked. Use in Route Handlers / webhooks. NOTE: both verbs hard-purge; the
|
|
14
|
+
* only difference is awaitability. revalidateTag does NOT serve stale content -
|
|
15
|
+
* the next read after the invalidation lands is a hard miss that re-renders.
|
|
16
|
+
* (The name mirrors Next.js, where it is SWR; here it is background-purge.)
|
|
17
|
+
*
|
|
18
|
+
* Both fan out across the app-level store (ctx._cacheStore) and every explicit
|
|
19
|
+
* per-scope store from cache({ store }) registered for this handler
|
|
20
|
+
* (ctx._explicitTaggedStores), calling the store-level invalidateTags()
|
|
21
|
+
* primitive for each tag. A single configured store (the common case) owns its
|
|
22
|
+
* own tag index and distributed invalidation - there is no separate
|
|
23
|
+
* tag-invalidation store.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { _getRequestContext } from "../server/request-context.js";
|
|
27
|
+
import { reportingAsync } from "./cache-error.js";
|
|
28
|
+
import { normalizeTags } from "./cache-tag.js";
|
|
29
|
+
import type { SegmentCacheStore } from "./types.js";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Collect every store that may hold entries tagged for this request's handler:
|
|
33
|
+
* the app-level store plus all explicit per-scope stores (deduplicated). Splits
|
|
34
|
+
* them into tag-capable (implement invalidateTags()) and not, so callers can
|
|
35
|
+
* warn about configured stores whose tagged entries will NOT be invalidated.
|
|
36
|
+
*/
|
|
37
|
+
function collectStores(): {
|
|
38
|
+
capable: SegmentCacheStore[];
|
|
39
|
+
incapable: number;
|
|
40
|
+
} {
|
|
41
|
+
const ctx = _getRequestContext();
|
|
42
|
+
const stores = new Set<SegmentCacheStore>();
|
|
43
|
+
if (ctx?._cacheStore) stores.add(ctx._cacheStore);
|
|
44
|
+
if (ctx?._explicitTaggedStores) {
|
|
45
|
+
for (const store of ctx._explicitTaggedStores) stores.add(store);
|
|
46
|
+
}
|
|
47
|
+
const capable: SegmentCacheStore[] = [];
|
|
48
|
+
let incapable = 0;
|
|
49
|
+
for (const store of stores) {
|
|
50
|
+
if (typeof store.invalidateTags === "function") capable.push(store);
|
|
51
|
+
else incapable++;
|
|
52
|
+
}
|
|
53
|
+
return { capable, incapable };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Production-visible warning. A misconfigured store silently dropping
|
|
58
|
+
* invalidations is a data-correctness footgun, so this surfaces in every
|
|
59
|
+
* environment (not dev-only).
|
|
60
|
+
*/
|
|
61
|
+
function warnNoTagStore(fn: string, tags: string[]): void {
|
|
62
|
+
console.warn(
|
|
63
|
+
`[${fn}] No tag-capable cache store is configured; tags ` +
|
|
64
|
+
`[${tags.join(", ")}] were not invalidated. The configured store must ` +
|
|
65
|
+
`implement invalidateTags() (the built-in MemorySegmentCacheStore and ` +
|
|
66
|
+
`CFCacheStore do).`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Production-visible warning for mixed-store configs: at least one configured
|
|
72
|
+
* store does not support tag invalidation, so its tagged entries (if any) are
|
|
73
|
+
* left stale even though other stores were invalidated.
|
|
74
|
+
*/
|
|
75
|
+
function warnPartialTagStore(fn: string, incapable: number): void {
|
|
76
|
+
console.warn(
|
|
77
|
+
`[${fn}] ${incapable} configured cache store(s) do not implement ` +
|
|
78
|
+
`invalidateTags(); their tagged entries were NOT invalidated. Use a ` +
|
|
79
|
+
`tag-capable store (e.g. MemorySegmentCacheStore / CFCacheStore) for any ` +
|
|
80
|
+
`cache({ store }) boundary whose entries you invalidate by tag.`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function invalidateAcross(
|
|
85
|
+
stores: SegmentCacheStore[],
|
|
86
|
+
tags: string[],
|
|
87
|
+
): Promise<void> {
|
|
88
|
+
// One invalidateTags(tags) call per store: the store receives the whole tag
|
|
89
|
+
// batch so it can do a single CDN purge request rather than one per tag.
|
|
90
|
+
//
|
|
91
|
+
// allSettled, not all: a store's invalidateTags() can reject (e.g. CFCacheStore
|
|
92
|
+
// surfaces a failed durable KV marker write). With Promise.all, the first
|
|
93
|
+
// rejection would short-circuit and the other stores' outcomes would go
|
|
94
|
+
// unobserved. Attempt every store, then surface a combined error so an awaited
|
|
95
|
+
// updateTag() still rejects (read-your-own-writes honesty) without masking the
|
|
96
|
+
// stores that did succeed.
|
|
97
|
+
const results = await Promise.allSettled(
|
|
98
|
+
stores.map((store) => store.invalidateTags!(tags)),
|
|
99
|
+
);
|
|
100
|
+
const errors = results
|
|
101
|
+
.filter((r): r is PromiseRejectedResult => r.status === "rejected")
|
|
102
|
+
.map((r) => r.reason);
|
|
103
|
+
if (errors.length > 0) {
|
|
104
|
+
const err = new Error(
|
|
105
|
+
`[tag invalidation] ${errors.length}/${stores.length} store(s) failed to ` +
|
|
106
|
+
`invalidate tags [${tags.join(", ")}]; their entries may still serve ` +
|
|
107
|
+
`stale data. Retry the invalidation.`,
|
|
108
|
+
);
|
|
109
|
+
(err as Error & { cause?: unknown }).cause = errors[0];
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Immediately expire every cache entry tagged with any of `tags`, resolving
|
|
116
|
+
* once in-process invalidation across all configured stores completes.
|
|
117
|
+
*
|
|
118
|
+
* Read-your-own-writes: because the returned promise resolves before you return
|
|
119
|
+
* from a Server Action, awaiting it guarantees the action's own re-render (and
|
|
120
|
+
* any subsequent read) sees fresh data.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* async function updateProduct(formData: FormData) {
|
|
125
|
+
* "use server";
|
|
126
|
+
* await db.updateProduct(formData);
|
|
127
|
+
* await updateTag("products"); // next render is fresh
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export async function updateTag(...tags: string[]): Promise<void> {
|
|
132
|
+
const valid = normalizeTags(tags);
|
|
133
|
+
if (valid.length === 0) return;
|
|
134
|
+
|
|
135
|
+
const { capable, incapable } = collectStores();
|
|
136
|
+
if (capable.length === 0) {
|
|
137
|
+
warnNoTagStore("updateTag", valid);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (incapable > 0) warnPartialTagStore("updateTag", incapable);
|
|
141
|
+
|
|
142
|
+
await invalidateAcross(capable, valid);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Invalidate every cache entry tagged with any of `tags` in the background,
|
|
147
|
+
* without blocking the current response (fire-and-forget via waitUntil).
|
|
148
|
+
*
|
|
149
|
+
* This is NOT stale-while-revalidate: like updateTag() it hard-purges, so the
|
|
150
|
+
* next read after the invalidation lands is a miss that re-renders fresh. The
|
|
151
|
+
* only difference from updateTag() is awaitability - revalidateTag() defers the
|
|
152
|
+
* purge off the response path and is not awaited.
|
|
153
|
+
*
|
|
154
|
+
* Use in Route Handlers / webhooks. For read-your-own-writes inside a Server
|
|
155
|
+
* Action, use updateTag() instead so the action's own response is fresh.
|
|
156
|
+
*
|
|
157
|
+
* Fire-and-forget: because this returns void and runs in the background, a
|
|
158
|
+
* failed durable marker write (e.g. a transient KV outage) is NOT surfaced to
|
|
159
|
+
* the caller. It IS reported - logged loudly and routed through the router's
|
|
160
|
+
* `onError` callback (phase `cache`, `metadata.category === "cache-invalidate"`)
|
|
161
|
+
* via reportingAsync - so the failure is observable in telemetry even though it
|
|
162
|
+
* cannot be awaited. If you need the invalidation to be CONFIRMED (and to retry
|
|
163
|
+
* on failure), use `await updateTag()` instead, which rejects when a store's
|
|
164
|
+
* durable write fails.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* // route handler invoked by an external webhook
|
|
169
|
+
* export async function POST() {
|
|
170
|
+
* "use server";
|
|
171
|
+
* revalidateTag("products");
|
|
172
|
+
* return new Response("ok");
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export function revalidateTag(...tags: string[]): void {
|
|
177
|
+
const valid = normalizeTags(tags);
|
|
178
|
+
if (valid.length === 0) return;
|
|
179
|
+
|
|
180
|
+
const { capable, incapable } = collectStores();
|
|
181
|
+
if (capable.length === 0) {
|
|
182
|
+
warnNoTagStore("revalidateTag", valid);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (incapable > 0) warnPartialTagStore("revalidateTag", incapable);
|
|
186
|
+
|
|
187
|
+
const ctx = _getRequestContext();
|
|
188
|
+
// reportingAsync never rejects: it catches a failed durable write and routes
|
|
189
|
+
// it through reportCacheError (loud log + onError). This is the only place a
|
|
190
|
+
// revalidateTag failure can be observed, since it is not awaitable. Pass ctx
|
|
191
|
+
// explicitly - the run executes in a detached waitUntil where the ALS context
|
|
192
|
+
// is gone, so onError fires only if we hand it the captured context.
|
|
193
|
+
const run = () =>
|
|
194
|
+
reportingAsync(
|
|
195
|
+
() => invalidateAcross(capable, valid),
|
|
196
|
+
"cache-invalidate",
|
|
197
|
+
"[revalidateTag] background invalidation",
|
|
198
|
+
ctx,
|
|
199
|
+
);
|
|
200
|
+
if (ctx?.waitUntil) {
|
|
201
|
+
ctx.waitUntil(run);
|
|
202
|
+
} else {
|
|
203
|
+
// No request context (e.g. called outside ALS): best-effort background run.
|
|
204
|
+
void run();
|
|
205
|
+
}
|
|
206
|
+
}
|