@rangojs/router 0.0.0-experimental.11 → 0.0.0-experimental.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +9 -0
- package/README.md +1037 -4
- package/dist/__internal.d.ts +83 -0
- package/dist/__internal.d.ts.map +1 -0
- package/dist/__internal.js +19 -0
- package/dist/__internal.js.map +1 -0
- package/dist/__mocks__/version.d.ts +7 -0
- package/dist/__mocks__/version.d.ts.map +1 -0
- package/dist/__mocks__/version.js +7 -0
- package/dist/__mocks__/version.js.map +1 -0
- package/dist/__tests__/client-href.test.d.ts +2 -0
- package/dist/__tests__/client-href.test.d.ts.map +1 -0
- package/dist/__tests__/client-href.test.js +74 -0
- package/dist/__tests__/client-href.test.js.map +1 -0
- package/dist/__tests__/component-utils.test.d.ts +2 -0
- package/dist/__tests__/component-utils.test.d.ts.map +1 -0
- package/dist/__tests__/component-utils.test.js +51 -0
- package/dist/__tests__/component-utils.test.js.map +1 -0
- package/dist/__tests__/event-controller.test.d.ts +2 -0
- package/dist/__tests__/event-controller.test.d.ts.map +1 -0
- package/dist/__tests__/event-controller.test.js +538 -0
- package/dist/__tests__/event-controller.test.js.map +1 -0
- package/dist/__tests__/helpers/route-tree.d.ts +118 -0
- package/dist/__tests__/helpers/route-tree.d.ts.map +1 -0
- package/dist/__tests__/helpers/route-tree.js +374 -0
- package/dist/__tests__/helpers/route-tree.js.map +1 -0
- package/dist/__tests__/match-result.test.d.ts +2 -0
- package/dist/__tests__/match-result.test.d.ts.map +1 -0
- package/dist/__tests__/match-result.test.js +154 -0
- package/dist/__tests__/match-result.test.js.map +1 -0
- package/dist/__tests__/navigation-store.test.d.ts +2 -0
- package/dist/__tests__/navigation-store.test.d.ts.map +1 -0
- package/dist/__tests__/navigation-store.test.js +440 -0
- package/dist/__tests__/navigation-store.test.js.map +1 -0
- package/dist/__tests__/partial-update.test.d.ts +2 -0
- package/dist/__tests__/partial-update.test.d.ts.map +1 -0
- package/dist/__tests__/partial-update.test.js +1009 -0
- package/dist/__tests__/partial-update.test.js.map +1 -0
- package/dist/__tests__/reverse-types.test.d.ts +8 -0
- package/dist/__tests__/reverse-types.test.d.ts.map +1 -0
- package/dist/__tests__/reverse-types.test.js +656 -0
- package/dist/__tests__/reverse-types.test.js.map +1 -0
- package/dist/__tests__/route-definition.test.d.ts +2 -0
- package/dist/__tests__/route-definition.test.d.ts.map +1 -0
- package/dist/__tests__/route-definition.test.js +55 -0
- package/dist/__tests__/route-definition.test.js.map +1 -0
- package/dist/__tests__/router-helpers.test.d.ts +2 -0
- package/dist/__tests__/router-helpers.test.d.ts.map +1 -0
- package/dist/__tests__/router-helpers.test.js +377 -0
- package/dist/__tests__/router-helpers.test.js.map +1 -0
- package/dist/__tests__/router-integration-2.test.d.ts +2 -0
- package/dist/__tests__/router-integration-2.test.d.ts.map +1 -0
- package/dist/__tests__/router-integration-2.test.js +426 -0
- package/dist/__tests__/router-integration-2.test.js.map +1 -0
- package/dist/__tests__/router-integration.test.d.ts +2 -0
- package/dist/__tests__/router-integration.test.d.ts.map +1 -0
- package/dist/__tests__/router-integration.test.js +1051 -0
- package/dist/__tests__/router-integration.test.js.map +1 -0
- package/dist/__tests__/search-params.test.d.ts +5 -0
- package/dist/__tests__/search-params.test.d.ts.map +1 -0
- package/dist/__tests__/search-params.test.js +306 -0
- package/dist/__tests__/search-params.test.js.map +1 -0
- package/dist/__tests__/segment-system.test.d.ts +2 -0
- package/dist/__tests__/segment-system.test.d.ts.map +1 -0
- package/dist/__tests__/segment-system.test.js +627 -0
- package/dist/__tests__/segment-system.test.js.map +1 -0
- package/dist/__tests__/static-handler-types.test.d.ts +8 -0
- package/dist/__tests__/static-handler-types.test.d.ts.map +1 -0
- package/dist/__tests__/static-handler-types.test.js +63 -0
- package/dist/__tests__/static-handler-types.test.js.map +1 -0
- package/dist/__tests__/urls.test.d.ts +2 -0
- package/dist/__tests__/urls.test.d.ts.map +1 -0
- package/dist/__tests__/urls.test.js +421 -0
- package/dist/__tests__/urls.test.js.map +1 -0
- package/dist/__tests__/use-mount.test.d.ts +2 -0
- package/dist/__tests__/use-mount.test.d.ts.map +1 -0
- package/dist/__tests__/use-mount.test.js +35 -0
- package/dist/__tests__/use-mount.test.js.map +1 -0
- package/dist/bin/rango.d.ts +2 -0
- package/dist/bin/rango.d.ts.map +1 -0
- package/dist/bin/rango.js +1635 -158
- package/dist/bin/rango.js.map +1 -0
- package/dist/browser/event-controller.d.ts +191 -0
- package/dist/browser/event-controller.d.ts.map +1 -0
- package/dist/browser/event-controller.js +559 -0
- package/dist/browser/event-controller.js.map +1 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +14 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/link-interceptor.d.ts +38 -0
- package/dist/browser/link-interceptor.d.ts.map +1 -0
- package/dist/browser/link-interceptor.js +99 -0
- package/dist/browser/link-interceptor.js.map +1 -0
- package/dist/browser/logging.d.ts +10 -0
- package/dist/browser/logging.d.ts.map +1 -0
- package/dist/browser/logging.js +29 -0
- package/dist/browser/logging.js.map +1 -0
- package/dist/browser/lru-cache.d.ts +17 -0
- package/dist/browser/lru-cache.d.ts.map +1 -0
- package/dist/browser/lru-cache.js +50 -0
- package/dist/browser/lru-cache.js.map +1 -0
- package/dist/browser/merge-segment-loaders.d.ts +39 -0
- package/dist/browser/merge-segment-loaders.d.ts.map +1 -0
- package/dist/browser/merge-segment-loaders.js +102 -0
- package/dist/browser/merge-segment-loaders.js.map +1 -0
- package/dist/browser/navigation-bridge.d.ts +102 -0
- package/dist/browser/navigation-bridge.d.ts.map +1 -0
- package/dist/browser/navigation-bridge.js +708 -0
- package/dist/browser/navigation-bridge.js.map +1 -0
- package/dist/browser/navigation-client.d.ts +25 -0
- package/dist/browser/navigation-client.d.ts.map +1 -0
- package/dist/browser/navigation-client.js +157 -0
- package/dist/browser/navigation-client.js.map +1 -0
- package/dist/browser/navigation-store.d.ts +101 -0
- package/dist/browser/navigation-store.d.ts.map +1 -0
- package/dist/browser/navigation-store.js +625 -0
- package/dist/browser/navigation-store.js.map +1 -0
- package/dist/browser/partial-update.d.ts +75 -0
- package/dist/browser/partial-update.d.ts.map +1 -0
- package/dist/browser/partial-update.js +426 -0
- package/dist/browser/partial-update.js.map +1 -0
- package/dist/browser/react/Link.d.ts +86 -0
- package/dist/browser/react/Link.d.ts.map +1 -0
- package/dist/browser/react/Link.js +128 -0
- package/dist/browser/react/Link.js.map +1 -0
- package/dist/browser/react/NavigationProvider.d.ts +63 -0
- package/dist/browser/react/NavigationProvider.d.ts.map +1 -0
- package/dist/browser/react/NavigationProvider.js +216 -0
- package/dist/browser/react/NavigationProvider.js.map +1 -0
- package/dist/browser/react/ScrollRestoration.d.ts +75 -0
- package/dist/browser/react/ScrollRestoration.d.ts.map +1 -0
- package/dist/browser/react/ScrollRestoration.js +57 -0
- package/dist/browser/react/ScrollRestoration.js.map +1 -0
- package/dist/browser/react/context.d.ts +46 -0
- package/dist/browser/react/context.d.ts.map +1 -0
- package/dist/browser/react/context.js +10 -0
- package/dist/browser/react/context.js.map +1 -0
- package/dist/browser/react/index.d.ts +11 -0
- package/dist/browser/react/index.d.ts.map +1 -0
- package/dist/browser/react/index.js +22 -0
- package/dist/browser/react/index.js.map +1 -0
- package/dist/browser/react/location-state-shared.d.ts +63 -0
- package/dist/browser/react/location-state-shared.d.ts.map +1 -0
- package/dist/browser/react/location-state-shared.js +81 -0
- package/dist/browser/react/location-state-shared.js.map +1 -0
- package/dist/browser/react/location-state.d.ts +23 -0
- package/dist/browser/react/location-state.d.ts.map +1 -0
- package/dist/browser/react/location-state.js +29 -0
- package/dist/browser/react/location-state.js.map +1 -0
- package/dist/browser/react/mount-context.d.ts +24 -0
- package/dist/browser/react/mount-context.d.ts.map +1 -0
- package/dist/browser/react/mount-context.js +24 -0
- package/dist/browser/react/mount-context.js.map +1 -0
- package/dist/browser/react/use-action.d.ts +64 -0
- package/dist/browser/react/use-action.d.ts.map +1 -0
- package/dist/browser/react/use-action.js +134 -0
- package/dist/browser/react/use-action.js.map +1 -0
- package/dist/browser/react/use-client-cache.d.ts +41 -0
- package/dist/browser/react/use-client-cache.d.ts.map +1 -0
- package/dist/browser/react/use-client-cache.js +39 -0
- package/dist/browser/react/use-client-cache.js.map +1 -0
- package/dist/browser/react/use-handle.d.ts +31 -0
- package/dist/browser/react/use-handle.d.ts.map +1 -0
- package/dist/browser/react/use-handle.js +144 -0
- package/dist/browser/react/use-handle.js.map +1 -0
- package/dist/browser/react/use-href.d.ts +33 -0
- package/dist/browser/react/use-href.d.ts.map +1 -0
- package/dist/browser/react/use-href.js +39 -0
- package/dist/browser/react/use-href.js.map +1 -0
- package/dist/browser/react/use-link-status.d.ts +37 -0
- package/dist/browser/react/use-link-status.d.ts.map +1 -0
- package/dist/browser/react/use-link-status.js +99 -0
- package/dist/browser/react/use-link-status.js.map +1 -0
- package/dist/browser/react/use-mount.d.ts +25 -0
- package/dist/browser/react/use-mount.d.ts.map +1 -0
- package/dist/browser/react/use-mount.js +30 -0
- package/dist/browser/react/use-mount.js.map +1 -0
- package/dist/browser/react/use-navigation.d.ts +27 -0
- package/dist/browser/react/use-navigation.d.ts.map +1 -0
- package/dist/browser/react/use-navigation.js +87 -0
- package/dist/browser/react/use-navigation.js.map +1 -0
- package/dist/browser/react/use-segments.d.ts +38 -0
- package/dist/browser/react/use-segments.d.ts.map +1 -0
- package/dist/browser/react/use-segments.js +130 -0
- package/dist/browser/react/use-segments.js.map +1 -0
- package/dist/browser/request-controller.d.ts +26 -0
- package/dist/browser/request-controller.d.ts.map +1 -0
- package/dist/browser/request-controller.js +147 -0
- package/dist/browser/request-controller.js.map +1 -0
- package/dist/browser/rsc-router.d.ts +129 -0
- package/dist/browser/rsc-router.d.ts.map +1 -0
- package/dist/browser/rsc-router.js +195 -0
- package/dist/browser/rsc-router.js.map +1 -0
- package/dist/browser/scroll-restoration.d.ts +93 -0
- package/dist/browser/scroll-restoration.d.ts.map +1 -0
- package/dist/browser/scroll-restoration.js +321 -0
- package/dist/browser/scroll-restoration.js.map +1 -0
- package/dist/browser/segment-structure-assert.d.ts +17 -0
- package/dist/browser/segment-structure-assert.d.ts.map +1 -0
- package/dist/browser/segment-structure-assert.js +59 -0
- package/dist/browser/segment-structure-assert.js.map +1 -0
- package/dist/browser/server-action-bridge.d.ts +26 -0
- package/dist/browser/server-action-bridge.d.ts.map +1 -0
- package/dist/browser/server-action-bridge.js +668 -0
- package/dist/browser/server-action-bridge.js.map +1 -0
- package/dist/browser/shallow.d.ts +12 -0
- package/dist/browser/shallow.d.ts.map +1 -0
- package/dist/browser/shallow.js +34 -0
- package/dist/browser/shallow.js.map +1 -0
- package/dist/browser/types.d.ts +369 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/browser/types.js +2 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/build/__tests__/generate-cli.test.d.ts +2 -0
- package/dist/build/__tests__/generate-cli.test.d.ts.map +1 -0
- package/dist/build/__tests__/generate-cli.test.js +237 -0
- package/dist/build/__tests__/generate-cli.test.js.map +1 -0
- package/dist/build/__tests__/generate-manifest.test.d.ts +2 -0
- package/dist/build/__tests__/generate-manifest.test.d.ts.map +1 -0
- package/dist/build/__tests__/generate-manifest.test.js +119 -0
- package/dist/build/__tests__/generate-manifest.test.js.map +1 -0
- package/dist/build/__tests__/generate-route-types.test.d.ts +2 -0
- package/dist/build/__tests__/generate-route-types.test.d.ts.map +1 -0
- package/dist/build/__tests__/generate-route-types.test.js +620 -0
- package/dist/build/__tests__/generate-route-types.test.js.map +1 -0
- package/dist/build/__tests__/per-router-manifest.test.d.ts +2 -0
- package/dist/build/__tests__/per-router-manifest.test.d.ts.map +1 -0
- package/dist/build/__tests__/per-router-manifest.test.js +308 -0
- package/dist/build/__tests__/per-router-manifest.test.js.map +1 -0
- package/dist/build/generate-manifest.d.ts +81 -0
- package/dist/build/generate-manifest.d.ts.map +1 -0
- package/dist/build/generate-manifest.js +276 -0
- package/dist/build/generate-manifest.js.map +1 -0
- package/dist/build/generate-route-types.d.ts +115 -0
- package/dist/build/generate-route-types.d.ts.map +1 -0
- package/dist/build/generate-route-types.js +740 -0
- package/dist/build/generate-route-types.js.map +1 -0
- package/dist/build/index.d.ts +21 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +21 -0
- package/dist/build/index.js.map +1 -0
- package/dist/build/route-trie.d.ts +71 -0
- package/dist/build/route-trie.d.ts.map +1 -0
- package/dist/build/route-trie.js +175 -0
- package/dist/build/route-trie.js.map +1 -0
- package/dist/cache/__tests__/cache-scope.test.d.ts +2 -0
- package/dist/cache/__tests__/cache-scope.test.d.ts.map +1 -0
- package/dist/cache/__tests__/cache-scope.test.js +208 -0
- package/dist/cache/__tests__/cache-scope.test.js.map +1 -0
- package/dist/cache/__tests__/document-cache.test.d.ts +2 -0
- package/dist/cache/__tests__/document-cache.test.d.ts.map +1 -0
- package/dist/cache/__tests__/document-cache.test.js +345 -0
- package/dist/cache/__tests__/document-cache.test.js.map +1 -0
- package/dist/cache/__tests__/memory-segment-store.test.d.ts +2 -0
- package/dist/cache/__tests__/memory-segment-store.test.d.ts.map +1 -0
- package/dist/cache/__tests__/memory-segment-store.test.js +425 -0
- package/dist/cache/__tests__/memory-segment-store.test.js.map +1 -0
- package/dist/cache/__tests__/memory-store.test.d.ts +2 -0
- package/dist/cache/__tests__/memory-store.test.d.ts.map +1 -0
- package/dist/cache/__tests__/memory-store.test.js +367 -0
- package/dist/cache/__tests__/memory-store.test.js.map +1 -0
- package/dist/cache/cache-scope.d.ts +102 -0
- package/dist/cache/cache-scope.d.ts.map +1 -0
- package/dist/cache/cache-scope.js +440 -0
- package/dist/cache/cache-scope.js.map +1 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts +2 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts.map +1 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.js +330 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.js.map +1 -0
- package/dist/cache/cf/cf-cache-store.d.ts +165 -0
- package/dist/cache/cf/cf-cache-store.d.ts.map +1 -0
- package/dist/cache/cf/cf-cache-store.js +242 -0
- package/dist/cache/cf/cf-cache-store.js.map +1 -0
- package/dist/cache/cf/index.d.ts +14 -0
- package/dist/cache/cf/index.d.ts.map +1 -0
- package/dist/cache/cf/index.js +17 -0
- package/dist/cache/cf/index.js.map +1 -0
- package/dist/cache/document-cache.d.ts +64 -0
- package/dist/cache/document-cache.d.ts.map +1 -0
- package/dist/cache/document-cache.js +228 -0
- package/dist/cache/document-cache.js.map +1 -0
- package/dist/cache/index.d.ts +19 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +21 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/memory-segment-store.d.ts +110 -0
- package/dist/cache/memory-segment-store.d.ts.map +1 -0
- package/dist/cache/memory-segment-store.js +117 -0
- package/dist/cache/memory-segment-store.js.map +1 -0
- package/dist/cache/memory-store.d.ts +41 -0
- package/dist/cache/memory-store.d.ts.map +1 -0
- package/dist/cache/memory-store.js +191 -0
- package/dist/cache/memory-store.js.map +1 -0
- package/dist/cache/types.d.ts +317 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cache/types.js +12 -0
- package/dist/cache/types.js.map +1 -0
- package/dist/client.d.ts +248 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +367 -0
- package/dist/client.js.map +1 -0
- package/dist/client.rsc.d.ts +26 -0
- package/dist/client.rsc.d.ts.map +1 -0
- package/dist/client.rsc.js +46 -0
- package/dist/client.rsc.js.map +1 -0
- package/dist/component-utils.d.ts +36 -0
- package/dist/component-utils.d.ts.map +1 -0
- package/dist/component-utils.js +61 -0
- package/dist/component-utils.js.map +1 -0
- package/dist/components/DefaultDocument.d.ts +13 -0
- package/dist/components/DefaultDocument.d.ts.map +1 -0
- package/dist/components/DefaultDocument.js +15 -0
- package/dist/components/DefaultDocument.js.map +1 -0
- package/dist/debug.d.ts +58 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +157 -0
- package/dist/debug.js.map +1 -0
- package/dist/default-error-boundary.d.ts +11 -0
- package/dist/default-error-boundary.d.ts.map +1 -0
- package/dist/default-error-boundary.js +45 -0
- package/dist/default-error-boundary.js.map +1 -0
- package/dist/deps/browser.d.ts +2 -0
- package/dist/deps/browser.d.ts.map +1 -0
- package/dist/deps/browser.js +3 -0
- package/dist/deps/browser.js.map +1 -0
- package/dist/deps/html-stream-client.d.ts +2 -0
- package/dist/deps/html-stream-client.d.ts.map +1 -0
- package/dist/deps/html-stream-client.js +3 -0
- package/dist/deps/html-stream-client.js.map +1 -0
- package/dist/deps/html-stream-server.d.ts +2 -0
- package/dist/deps/html-stream-server.d.ts.map +1 -0
- package/dist/deps/html-stream-server.js +3 -0
- package/dist/deps/html-stream-server.js.map +1 -0
- package/dist/deps/rsc.d.ts +2 -0
- package/dist/deps/rsc.d.ts.map +1 -0
- package/dist/deps/rsc.js +4 -0
- package/dist/deps/rsc.js.map +1 -0
- package/dist/deps/ssr.d.ts +2 -0
- package/dist/deps/ssr.d.ts.map +1 -0
- package/dist/deps/ssr.js +3 -0
- package/dist/deps/ssr.js.map +1 -0
- package/dist/errors.d.ts +174 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +241 -0
- package/dist/errors.js.map +1 -0
- package/dist/handle.d.ts +78 -0
- package/dist/handle.d.ts.map +1 -0
- package/dist/handle.js +82 -0
- package/dist/handle.js.map +1 -0
- package/dist/handles/MetaTags.d.ts +14 -0
- package/dist/handles/MetaTags.d.ts.map +1 -0
- package/dist/handles/MetaTags.js +136 -0
- package/dist/handles/MetaTags.js.map +1 -0
- package/dist/handles/index.d.ts +6 -0
- package/dist/handles/index.d.ts.map +1 -0
- package/dist/handles/index.js +6 -0
- package/dist/handles/index.js.map +1 -0
- package/dist/handles/meta.d.ts +39 -0
- package/dist/handles/meta.d.ts.map +1 -0
- package/dist/handles/meta.js +202 -0
- package/dist/handles/meta.js.map +1 -0
- package/dist/host/__tests__/errors.test.d.ts +2 -0
- package/dist/host/__tests__/errors.test.d.ts.map +1 -0
- package/dist/host/__tests__/errors.test.js +76 -0
- package/dist/host/__tests__/errors.test.js.map +1 -0
- package/dist/host/__tests__/pattern-comprehensive.test.d.ts +2 -0
- package/dist/host/__tests__/pattern-comprehensive.test.d.ts.map +1 -0
- package/dist/host/__tests__/pattern-comprehensive.test.js +732 -0
- package/dist/host/__tests__/pattern-comprehensive.test.js.map +1 -0
- package/dist/host/__tests__/pattern-matcher.test.d.ts +2 -0
- package/dist/host/__tests__/pattern-matcher.test.d.ts.map +1 -0
- package/dist/host/__tests__/pattern-matcher.test.js +251 -0
- package/dist/host/__tests__/pattern-matcher.test.js.map +1 -0
- package/dist/host/__tests__/router.test.d.ts +2 -0
- package/dist/host/__tests__/router.test.d.ts.map +1 -0
- package/dist/host/__tests__/router.test.js +241 -0
- package/dist/host/__tests__/router.test.js.map +1 -0
- package/dist/host/__tests__/testing.test.d.ts +2 -0
- package/dist/host/__tests__/testing.test.d.ts.map +1 -0
- package/dist/host/__tests__/testing.test.js +64 -0
- package/dist/host/__tests__/testing.test.js.map +1 -0
- package/dist/host/__tests__/utils.test.d.ts +2 -0
- package/dist/host/__tests__/utils.test.d.ts.map +1 -0
- package/dist/host/__tests__/utils.test.js +29 -0
- package/dist/host/__tests__/utils.test.js.map +1 -0
- package/dist/host/cookie-handler.d.ts +34 -0
- package/dist/host/cookie-handler.d.ts.map +1 -0
- package/dist/host/cookie-handler.js +124 -0
- package/dist/host/cookie-handler.js.map +1 -0
- package/dist/host/errors.d.ts +56 -0
- package/dist/host/errors.d.ts.map +1 -0
- package/dist/host/errors.js +79 -0
- package/dist/host/errors.js.map +1 -0
- package/dist/host/index.d.ts +29 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +32 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/pattern-matcher.d.ts +36 -0
- package/dist/host/pattern-matcher.d.ts.map +1 -0
- package/dist/host/pattern-matcher.js +172 -0
- package/dist/host/pattern-matcher.js.map +1 -0
- package/dist/host/router.d.ts +26 -0
- package/dist/host/router.d.ts.map +1 -0
- package/dist/host/router.js +218 -0
- package/dist/host/router.js.map +1 -0
- package/dist/host/testing.d.ts +36 -0
- package/dist/host/testing.d.ts.map +1 -0
- package/dist/host/testing.js +55 -0
- package/dist/host/testing.js.map +1 -0
- package/dist/host/types.d.ts +115 -0
- package/dist/host/types.d.ts.map +1 -0
- package/dist/host/types.js +7 -0
- package/dist/host/types.js.map +1 -0
- package/dist/host/utils.d.ts +21 -0
- package/dist/host/utils.d.ts.map +1 -0
- package/dist/host/utils.js +23 -0
- package/dist/host/utils.js.map +1 -0
- package/dist/href-client.d.ts +131 -0
- package/dist/href-client.d.ts.map +1 -0
- package/dist/href-client.js +64 -0
- package/dist/href-client.js.map +1 -0
- package/{src/href-context.ts → dist/href-context.d.ts} +7 -11
- package/dist/href-context.d.ts.map +1 -0
- package/dist/href-context.js +21 -0
- package/dist/href-context.js.map +1 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/index.rsc.d.ts +32 -0
- package/dist/index.rsc.d.ts.map +1 -0
- package/dist/index.rsc.js +40 -0
- package/dist/index.rsc.js.map +1 -0
- package/dist/internal-debug.d.ts +2 -0
- package/dist/internal-debug.d.ts.map +1 -0
- package/dist/internal-debug.js +5 -0
- package/dist/internal-debug.js.map +1 -0
- package/dist/loader.d.ts +14 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +20 -0
- package/dist/loader.js.map +1 -0
- package/dist/loader.rsc.d.ts +19 -0
- package/dist/loader.rsc.d.ts.map +1 -0
- package/dist/loader.rsc.js +99 -0
- package/dist/loader.rsc.js.map +1 -0
- package/dist/network-error-thrower.d.ts +17 -0
- package/dist/network-error-thrower.d.ts.map +1 -0
- package/dist/network-error-thrower.js +14 -0
- package/dist/network-error-thrower.js.map +1 -0
- package/dist/outlet-context.d.ts +13 -0
- package/dist/outlet-context.d.ts.map +1 -0
- package/dist/outlet-context.js +3 -0
- package/dist/outlet-context.js.map +1 -0
- package/dist/prerender/__tests__/param-hash.test.d.ts +2 -0
- package/dist/prerender/__tests__/param-hash.test.d.ts.map +1 -0
- package/dist/prerender/__tests__/param-hash.test.js +148 -0
- package/dist/prerender/__tests__/param-hash.test.js.map +1 -0
- package/dist/prerender/param-hash.d.ts +16 -0
- package/dist/prerender/param-hash.d.ts.map +1 -0
- package/dist/prerender/param-hash.js +36 -0
- package/dist/prerender/param-hash.js.map +1 -0
- package/dist/prerender/store.d.ts +38 -0
- package/dist/prerender/store.d.ts.map +1 -0
- package/dist/prerender/store.js +61 -0
- package/dist/prerender/store.js.map +1 -0
- package/dist/prerender.d.ts +66 -0
- package/dist/prerender.d.ts.map +1 -0
- package/dist/prerender.js +57 -0
- package/dist/prerender.js.map +1 -0
- package/dist/reverse.d.ts +196 -0
- package/dist/reverse.d.ts.map +1 -0
- package/dist/reverse.js +78 -0
- package/dist/reverse.js.map +1 -0
- package/dist/root-error-boundary.d.ts +33 -0
- package/dist/root-error-boundary.d.ts.map +1 -0
- package/dist/root-error-boundary.js +165 -0
- package/dist/root-error-boundary.js.map +1 -0
- package/dist/route-content-wrapper.d.ts +46 -0
- package/dist/route-content-wrapper.d.ts.map +1 -0
- package/dist/route-content-wrapper.js +77 -0
- package/dist/route-content-wrapper.js.map +1 -0
- package/dist/route-definition.d.ts +421 -0
- package/dist/route-definition.d.ts.map +1 -0
- package/dist/route-definition.js +868 -0
- package/dist/route-definition.js.map +1 -0
- package/dist/route-map-builder.d.ts +155 -0
- package/dist/route-map-builder.d.ts.map +1 -0
- package/dist/route-map-builder.js +237 -0
- package/dist/route-map-builder.js.map +1 -0
- package/dist/route-types.d.ts +165 -0
- package/dist/route-types.d.ts.map +1 -0
- package/dist/route-types.js +7 -0
- package/dist/route-types.js.map +1 -0
- package/dist/router/__tests__/handler-context.test.d.ts +2 -0
- package/dist/router/__tests__/handler-context.test.d.ts.map +1 -0
- package/dist/router/__tests__/handler-context.test.js +65 -0
- package/dist/router/__tests__/handler-context.test.js.map +1 -0
- package/dist/router/__tests__/loader-cycle-detection.test.d.ts +2 -0
- package/dist/router/__tests__/loader-cycle-detection.test.d.ts.map +1 -0
- package/dist/router/__tests__/loader-cycle-detection.test.js +221 -0
- package/dist/router/__tests__/loader-cycle-detection.test.js.map +1 -0
- package/dist/router/__tests__/match-context.test.d.ts +2 -0
- package/dist/router/__tests__/match-context.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-context.test.js +92 -0
- package/dist/router/__tests__/match-context.test.js.map +1 -0
- package/dist/router/__tests__/match-pipelines.test.d.ts +2 -0
- package/dist/router/__tests__/match-pipelines.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-pipelines.test.js +417 -0
- package/dist/router/__tests__/match-pipelines.test.js.map +1 -0
- package/dist/router/__tests__/match-result.test.d.ts +2 -0
- package/dist/router/__tests__/match-result.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-result.test.js +457 -0
- package/dist/router/__tests__/match-result.test.js.map +1 -0
- package/dist/router/__tests__/on-error.test.d.ts +2 -0
- package/dist/router/__tests__/on-error.test.d.ts.map +1 -0
- package/dist/router/__tests__/on-error.test.js +678 -0
- package/dist/router/__tests__/on-error.test.js.map +1 -0
- package/dist/router/__tests__/pattern-matching.test.d.ts +2 -0
- package/dist/router/__tests__/pattern-matching.test.d.ts.map +1 -0
- package/dist/router/__tests__/pattern-matching.test.js +629 -0
- package/dist/router/__tests__/pattern-matching.test.js.map +1 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts +2 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts.map +1 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.js +155 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.js.map +1 -0
- package/dist/router/error-handling.d.ts +77 -0
- package/dist/router/error-handling.d.ts.map +1 -0
- package/dist/router/error-handling.js +202 -0
- package/dist/router/error-handling.js.map +1 -0
- package/dist/router/handler-context.d.ts +20 -0
- package/dist/router/handler-context.d.ts.map +1 -0
- package/dist/router/handler-context.js +198 -0
- package/dist/router/handler-context.js.map +1 -0
- package/dist/router/intercept-resolution.d.ts +66 -0
- package/dist/router/intercept-resolution.d.ts.map +1 -0
- package/dist/router/intercept-resolution.js +246 -0
- package/dist/router/intercept-resolution.js.map +1 -0
- package/dist/router/loader-resolution.d.ts +64 -0
- package/dist/router/loader-resolution.d.ts.map +1 -0
- package/dist/router/loader-resolution.js +284 -0
- package/dist/router/loader-resolution.js.map +1 -0
- package/dist/router/logging.d.ts +15 -0
- package/dist/router/logging.d.ts.map +1 -0
- package/dist/router/logging.js +99 -0
- package/dist/router/logging.js.map +1 -0
- package/dist/router/manifest.d.ts +22 -0
- package/dist/router/manifest.d.ts.map +1 -0
- package/dist/router/manifest.js +181 -0
- package/dist/router/manifest.js.map +1 -0
- package/dist/router/match-api.d.ts +35 -0
- package/dist/router/match-api.d.ts.map +1 -0
- package/dist/router/match-api.js +406 -0
- package/dist/router/match-api.js.map +1 -0
- package/dist/router/match-context.d.ts +206 -0
- package/dist/router/match-context.d.ts.map +1 -0
- package/dist/router/match-context.js +17 -0
- package/dist/router/match-context.js.map +1 -0
- package/dist/router/match-middleware/background-revalidation.d.ts +127 -0
- package/dist/router/match-middleware/background-revalidation.d.ts.map +1 -0
- package/dist/router/match-middleware/background-revalidation.js +75 -0
- package/dist/router/match-middleware/background-revalidation.js.map +1 -0
- package/dist/router/match-middleware/cache-lookup.d.ts +112 -0
- package/dist/router/match-middleware/cache-lookup.d.ts.map +1 -0
- package/dist/router/match-middleware/cache-lookup.js +257 -0
- package/dist/router/match-middleware/cache-lookup.js.map +1 -0
- package/dist/router/match-middleware/cache-store.d.ts +113 -0
- package/dist/router/match-middleware/cache-store.d.ts.map +1 -0
- package/dist/router/match-middleware/cache-store.js +108 -0
- package/dist/router/match-middleware/cache-store.js.map +1 -0
- package/dist/router/match-middleware/index.d.ts +81 -0
- package/dist/router/match-middleware/index.d.ts.map +1 -0
- package/dist/router/match-middleware/index.js +80 -0
- package/dist/router/match-middleware/index.js.map +1 -0
- package/dist/router/match-middleware/intercept-resolution.d.ts +117 -0
- package/dist/router/match-middleware/intercept-resolution.d.ts.map +1 -0
- package/dist/router/match-middleware/intercept-resolution.js +134 -0
- package/dist/router/match-middleware/intercept-resolution.js.map +1 -0
- package/dist/router/match-middleware/segment-resolution.d.ts +99 -0
- package/dist/router/match-middleware/segment-resolution.d.ts.map +1 -0
- package/dist/router/match-middleware/segment-resolution.js +53 -0
- package/dist/router/match-middleware/segment-resolution.js.map +1 -0
- package/dist/router/match-pipelines.d.ts +147 -0
- package/dist/router/match-pipelines.d.ts.map +1 -0
- package/dist/router/match-pipelines.js +82 -0
- package/dist/router/match-pipelines.js.map +1 -0
- package/dist/router/match-result.d.ts +126 -0
- package/dist/router/match-result.d.ts.map +1 -0
- package/dist/router/match-result.js +93 -0
- package/dist/router/match-result.js.map +1 -0
- package/dist/router/metrics.d.ts +20 -0
- package/dist/router/metrics.d.ts.map +1 -0
- package/dist/router/metrics.js +47 -0
- package/dist/router/metrics.js.map +1 -0
- package/dist/router/middleware.d.ts +249 -0
- package/dist/router/middleware.d.ts.map +1 -0
- package/dist/router/middleware.js +434 -0
- package/dist/router/middleware.js.map +1 -0
- package/dist/router/middleware.test.d.ts +2 -0
- package/dist/router/middleware.test.d.ts.map +1 -0
- package/dist/router/middleware.test.js +816 -0
- package/dist/router/middleware.test.js.map +1 -0
- package/dist/router/pattern-matching.d.ts +149 -0
- package/dist/router/pattern-matching.d.ts.map +1 -0
- package/dist/router/pattern-matching.js +349 -0
- package/dist/router/pattern-matching.js.map +1 -0
- package/dist/router/revalidation.d.ts +44 -0
- package/dist/router/revalidation.d.ts.map +1 -0
- package/dist/router/revalidation.js +147 -0
- package/dist/router/revalidation.js.map +1 -0
- package/dist/router/router-context.d.ts +135 -0
- package/dist/router/router-context.d.ts.map +1 -0
- package/dist/router/router-context.js +36 -0
- package/dist/router/router-context.js.map +1 -0
- package/dist/router/segment-resolution.d.ts +127 -0
- package/dist/router/segment-resolution.d.ts.map +1 -0
- package/dist/router/segment-resolution.js +919 -0
- package/dist/router/segment-resolution.js.map +1 -0
- package/dist/router/trie-matching.d.ts +40 -0
- package/dist/router/trie-matching.d.ts.map +1 -0
- package/dist/router/trie-matching.js +127 -0
- package/dist/router/trie-matching.js.map +1 -0
- package/dist/router/types.d.ts +136 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/types.js +7 -0
- package/dist/router/types.js.map +1 -0
- package/dist/router.d.ts +753 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.gen.d.ts +6 -0
- package/dist/router.gen.d.ts.map +1 -0
- package/dist/router.gen.js +6 -0
- package/dist/router.gen.js.map +1 -0
- package/dist/router.js +1304 -0
- package/dist/router.js.map +1 -0
- package/dist/rsc/__tests__/helpers.test.d.ts +2 -0
- package/dist/rsc/__tests__/helpers.test.d.ts.map +1 -0
- package/dist/rsc/__tests__/helpers.test.js +140 -0
- package/dist/rsc/__tests__/helpers.test.js.map +1 -0
- package/dist/rsc/handler.d.ts +45 -0
- package/dist/rsc/handler.d.ts.map +1 -0
- package/dist/rsc/handler.js +1172 -0
- package/dist/rsc/handler.js.map +1 -0
- package/dist/rsc/helpers.d.ts +16 -0
- package/dist/rsc/helpers.d.ts.map +1 -0
- package/dist/rsc/helpers.js +55 -0
- package/dist/rsc/helpers.js.map +1 -0
- package/dist/rsc/index.d.ts +22 -0
- package/dist/rsc/index.d.ts.map +1 -0
- package/dist/rsc/index.js +23 -0
- package/dist/rsc/index.js.map +1 -0
- package/dist/rsc/nonce.d.ts +9 -0
- package/dist/rsc/nonce.d.ts.map +1 -0
- package/dist/rsc/nonce.js +18 -0
- package/dist/rsc/nonce.js.map +1 -0
- package/dist/rsc/types.d.ts +206 -0
- package/dist/rsc/types.d.ts.map +1 -0
- package/dist/rsc/types.js +8 -0
- package/dist/rsc/types.js.map +1 -0
- package/dist/search-params.d.ts +103 -0
- package/dist/search-params.d.ts.map +1 -0
- package/dist/search-params.js +74 -0
- package/dist/search-params.js.map +1 -0
- package/dist/segment-system.d.ts +75 -0
- package/dist/segment-system.d.ts.map +1 -0
- package/dist/segment-system.js +336 -0
- package/dist/segment-system.js.map +1 -0
- package/dist/server/context.d.ts +245 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +197 -0
- package/dist/server/context.js.map +1 -0
- package/dist/server/fetchable-loader-store.d.ts +18 -0
- package/dist/server/fetchable-loader-store.d.ts.map +1 -0
- package/dist/server/fetchable-loader-store.js +18 -0
- package/dist/server/fetchable-loader-store.js.map +1 -0
- package/dist/server/handle-store.d.ts +85 -0
- package/dist/server/handle-store.d.ts.map +1 -0
- package/dist/server/handle-store.js +142 -0
- package/dist/server/handle-store.js.map +1 -0
- package/dist/server/loader-registry.d.ts +55 -0
- package/dist/server/loader-registry.d.ts.map +1 -0
- package/dist/server/loader-registry.js +132 -0
- package/dist/server/loader-registry.js.map +1 -0
- package/dist/server/request-context.d.ts +226 -0
- package/dist/server/request-context.d.ts.map +1 -0
- package/dist/server/request-context.js +290 -0
- package/dist/server/request-context.js.map +1 -0
- package/dist/server/root-layout.d.ts +4 -0
- package/dist/server/root-layout.d.ts.map +1 -0
- package/dist/server/root-layout.js +5 -0
- package/dist/server/root-layout.js.map +1 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +20 -0
- package/dist/server.js.map +1 -0
- package/dist/ssr/__tests__/ssr-handler.test.d.ts +2 -0
- package/dist/ssr/__tests__/ssr-handler.test.d.ts.map +1 -0
- package/dist/ssr/__tests__/ssr-handler.test.js +132 -0
- package/dist/ssr/__tests__/ssr-handler.test.js.map +1 -0
- package/dist/ssr/index.d.ts +98 -0
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/index.js +158 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/static-handler.d.ts +50 -0
- package/dist/static-handler.d.ts.map +1 -0
- package/dist/static-handler.gen.d.ts +5 -0
- package/dist/static-handler.gen.d.ts.map +1 -0
- package/dist/static-handler.gen.js +5 -0
- package/dist/static-handler.gen.js.map +1 -0
- package/dist/static-handler.js +29 -0
- package/dist/static-handler.js.map +1 -0
- package/dist/theme/ThemeProvider.d.ts +20 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/ThemeProvider.js +240 -0
- package/dist/theme/ThemeProvider.js.map +1 -0
- package/dist/theme/ThemeScript.d.ts +48 -0
- package/dist/theme/ThemeScript.d.ts.map +1 -0
- package/dist/theme/ThemeScript.js +13 -0
- package/dist/theme/ThemeScript.js.map +1 -0
- package/dist/theme/__tests__/theme.test.d.ts +2 -0
- package/dist/theme/__tests__/theme.test.d.ts.map +1 -0
- package/dist/theme/__tests__/theme.test.js +103 -0
- package/dist/theme/__tests__/theme.test.js.map +1 -0
- package/dist/theme/constants.d.ts +29 -0
- package/dist/theme/constants.d.ts.map +1 -0
- package/dist/theme/constants.js +48 -0
- package/dist/theme/constants.js.map +1 -0
- package/dist/theme/index.d.ts +31 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +36 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/theme-context.d.ts +40 -0
- package/dist/theme/theme-context.d.ts.map +1 -0
- package/dist/theme/theme-context.js +60 -0
- package/dist/theme/theme-context.js.map +1 -0
- package/dist/theme/theme-script.d.ts +27 -0
- package/dist/theme/theme-script.d.ts.map +1 -0
- package/dist/theme/theme-script.js +147 -0
- package/dist/theme/theme-script.js.map +1 -0
- package/dist/theme/types.d.ts +163 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/types.js +11 -0
- package/dist/theme/types.js.map +1 -0
- package/dist/theme/use-theme.d.ts +12 -0
- package/dist/theme/use-theme.d.ts.map +1 -0
- package/dist/theme/use-theme.js +40 -0
- package/dist/theme/use-theme.js.map +1 -0
- package/dist/types.d.ts +1479 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/urls.d.ts +441 -0
- package/dist/urls.d.ts.map +1 -0
- package/dist/urls.gen.d.ts +8 -0
- package/dist/urls.gen.d.ts.map +1 -0
- package/dist/urls.gen.js +8 -0
- package/dist/urls.gen.js.map +1 -0
- package/dist/urls.js +443 -0
- package/dist/urls.js.map +1 -0
- package/dist/use-loader.d.ts +127 -0
- package/dist/use-loader.d.ts.map +1 -0
- package/dist/use-loader.js +237 -0
- package/dist/use-loader.js.map +1 -0
- package/dist/vite/__tests__/ast-handler-extract.test.d.ts +2 -0
- package/dist/vite/__tests__/ast-handler-extract.test.d.ts.map +1 -0
- package/dist/vite/__tests__/ast-handler-extract.test.js +294 -0
- package/dist/vite/__tests__/ast-handler-extract.test.js.map +1 -0
- package/dist/vite/__tests__/expose-id-utils.test.d.ts +2 -0
- package/dist/vite/__tests__/expose-id-utils.test.d.ts.map +1 -0
- package/dist/vite/__tests__/expose-id-utils.test.js +224 -0
- package/dist/vite/__tests__/expose-id-utils.test.js.map +1 -0
- package/dist/vite/__tests__/expose-internal-ids.test.d.ts +2 -0
- package/dist/vite/__tests__/expose-internal-ids.test.d.ts.map +1 -0
- package/dist/vite/__tests__/expose-internal-ids.test.js +647 -0
- package/dist/vite/__tests__/expose-internal-ids.test.js.map +1 -0
- package/dist/vite/__tests__/expose-router-id.test.d.ts +2 -0
- package/dist/vite/__tests__/expose-router-id.test.d.ts.map +1 -0
- package/dist/vite/__tests__/expose-router-id.test.js +39 -0
- package/dist/vite/__tests__/expose-router-id.test.js.map +1 -0
- package/dist/vite/ast-handler-extract.d.ts +49 -0
- package/dist/vite/ast-handler-extract.d.ts.map +1 -0
- package/dist/vite/ast-handler-extract.js +249 -0
- package/dist/vite/ast-handler-extract.js.map +1 -0
- package/dist/vite/expose-action-id.d.ts +19 -0
- package/dist/vite/expose-action-id.d.ts.map +1 -0
- package/dist/vite/expose-action-id.js +250 -0
- package/dist/vite/expose-action-id.js.map +1 -0
- package/dist/vite/expose-id-utils.d.ts +69 -0
- package/dist/vite/expose-id-utils.d.ts.map +1 -0
- package/dist/vite/expose-id-utils.js +289 -0
- package/dist/vite/expose-id-utils.js.map +1 -0
- package/dist/vite/expose-internal-ids.d.ts +22 -0
- package/dist/vite/expose-internal-ids.d.ts.map +1 -0
- package/dist/vite/expose-internal-ids.js +886 -0
- package/dist/vite/expose-internal-ids.js.map +1 -0
- package/dist/vite/index.d.ts +149 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +6148 -2425
- package/dist/vite/index.js.bak +5448 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/vite/index.named-routes.gen.ts +103 -0
- package/dist/vite/package-resolution.d.ts +43 -0
- package/dist/vite/package-resolution.d.ts.map +1 -0
- package/{src/vite/package-resolution.ts → dist/vite/package-resolution.js} +53 -66
- package/dist/vite/package-resolution.js.map +1 -0
- package/dist/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
- package/dist/vite/virtual-entries.d.ts +25 -0
- package/dist/vite/virtual-entries.d.ts.map +1 -0
- package/{src/vite/virtual-entries.ts → dist/vite/virtual-entries.js} +12 -16
- package/dist/vite/virtual-entries.js.map +1 -0
- package/package.json +73 -66
- package/skills/breadcrumbs/SKILL.md +252 -0
- package/skills/bundle-analysis/SKILL.md +159 -0
- package/skills/cache-guide/SKILL.md +473 -0
- package/skills/caching/SKILL.md +94 -24
- package/skills/composability/SKILL.md +197 -0
- package/skills/debug-manifest/SKILL.md +12 -8
- package/skills/document-cache/SKILL.md +18 -16
- package/skills/fonts/SKILL.md +6 -4
- package/skills/handler-use/SKILL.md +364 -0
- package/skills/hooks/SKILL.md +524 -71
- package/skills/host-router/SKILL.md +243 -0
- package/skills/i18n/SKILL.md +276 -0
- package/skills/intercept/SKILL.md +173 -8
- package/skills/layout/SKILL.md +123 -5
- package/skills/links/SKILL.md +316 -25
- package/skills/loader/SKILL.md +620 -50
- package/skills/middleware/SKILL.md +211 -37
- package/skills/migrate-nextjs/SKILL.md +562 -0
- package/skills/migrate-react-router/SKILL.md +769 -0
- package/skills/mime-routes/SKILL.md +42 -11
- package/skills/observability/SKILL.md +137 -0
- package/skills/parallel/SKILL.md +271 -3
- package/skills/prerender/SKILL.md +448 -63
- package/skills/rango/SKILL.md +273 -21
- package/skills/response-routes/SKILL.md +210 -100
- package/skills/route/SKILL.md +310 -14
- package/skills/router-setup/SKILL.md +211 -33
- package/skills/server-actions/SKILL.md +751 -0
- package/skills/streams-and-websockets/SKILL.md +283 -0
- package/skills/theme/SKILL.md +9 -8
- package/skills/typesafety/SKILL.md +622 -91
- package/skills/use-cache/SKILL.md +324 -0
- package/skills/view-transitions/SKILL.md +212 -0
- package/src/__augment-tests__/augment.ts +81 -0
- package/src/__augment-tests__/augmented.check.ts +117 -0
- package/src/__internal.ts +102 -4
- package/src/bin/rango.ts +312 -15
- package/src/browser/action-coordinator.ts +97 -0
- package/src/browser/action-response-classifier.ts +99 -0
- package/src/browser/app-shell.ts +52 -0
- package/src/browser/app-version.ts +14 -0
- package/src/browser/event-controller.ts +136 -68
- package/src/browser/history-state.ts +101 -0
- package/src/browser/index.ts +3 -3
- package/src/browser/intercept-utils.ts +52 -0
- package/src/browser/link-interceptor.ts +24 -4
- package/src/browser/logging.ts +55 -0
- package/src/browser/merge-segment-loaders.ts +20 -12
- package/src/browser/navigation-bridge.ts +370 -561
- package/src/browser/navigation-client.ts +228 -70
- package/src/browser/navigation-store.ts +97 -55
- package/src/browser/navigation-transaction.ts +293 -0
- package/src/browser/network-error-handler.ts +61 -0
- package/src/browser/partial-update.ts +376 -315
- package/src/browser/prefetch/cache.ts +314 -0
- package/src/browser/prefetch/fetch.ts +282 -0
- package/src/browser/prefetch/observer.ts +65 -0
- package/src/browser/prefetch/policy.ts +48 -0
- package/src/browser/prefetch/queue.ts +191 -0
- package/src/browser/prefetch/resource-ready.ts +77 -0
- package/src/browser/rango-state.ts +152 -0
- package/src/browser/react/Link.tsx +255 -71
- package/src/browser/react/NavigationProvider.tsx +152 -24
- package/src/browser/react/context.ts +11 -0
- package/src/browser/react/filter-segment-order.ts +55 -0
- package/src/browser/react/index.ts +15 -12
- package/src/browser/react/location-state-shared.ts +176 -53
- package/src/browser/react/location-state.ts +90 -19
- package/src/browser/react/mount-context.ts +6 -1
- package/src/browser/react/nonce-context.ts +23 -0
- package/src/browser/react/shallow-equal.ts +27 -0
- package/src/browser/react/use-action.ts +29 -51
- package/src/browser/react/use-client-cache.ts +5 -3
- package/src/browser/react/use-handle.ts +41 -123
- package/src/browser/react/use-link-status.ts +6 -5
- package/src/browser/react/use-navigation.ts +44 -65
- package/src/browser/react/use-params.ts +78 -0
- package/src/browser/react/use-pathname.ts +47 -0
- package/src/browser/react/use-reverse.ts +99 -0
- package/src/browser/react/use-router.ts +96 -0
- package/src/browser/react/use-search-params.ts +56 -0
- package/src/browser/react/use-segments.ts +85 -99
- package/src/browser/response-adapter.ts +73 -0
- package/src/browser/rsc-router.tsx +254 -72
- package/src/browser/scroll-restoration.ts +132 -49
- package/src/browser/segment-reconciler.ts +243 -0
- package/src/browser/segment-structure-assert.ts +17 -1
- package/src/browser/server-action-bridge.ts +510 -603
- package/src/browser/shallow.ts +6 -1
- package/src/browser/types.ts +158 -48
- package/src/browser/validate-redirect-origin.ts +29 -0
- package/src/build/generate-manifest.ts +87 -26
- package/src/build/generate-route-types.ts +39 -828
- package/src/build/index.ts +2 -5
- package/src/build/route-trie.ts +84 -31
- package/src/build/route-types/ast-helpers.ts +25 -0
- package/src/build/route-types/ast-route-extraction.ts +98 -0
- package/src/build/route-types/codegen.ts +102 -0
- package/src/build/route-types/include-resolution.ts +418 -0
- package/src/build/route-types/param-extraction.ts +48 -0
- package/src/build/route-types/per-module-writer.ts +128 -0
- package/src/build/route-types/router-processing.ts +618 -0
- package/src/build/route-types/scan-filter.ts +85 -0
- package/src/build/runtime-discovery.ts +231 -0
- package/src/cache/background-task.ts +34 -0
- package/src/cache/cache-key-utils.ts +44 -0
- package/src/cache/cache-policy.ts +125 -0
- package/src/cache/cache-runtime.ts +342 -0
- package/src/cache/cache-scope.ts +167 -307
- package/src/cache/cf/cf-cache-store.ts +573 -21
- package/src/cache/cf/index.ts +13 -3
- package/src/cache/document-cache.ts +116 -77
- package/src/cache/handle-capture.ts +81 -0
- package/src/cache/handle-snapshot.ts +41 -0
- package/src/cache/index.ts +1 -15
- package/src/cache/memory-segment-store.ts +191 -13
- package/src/cache/profile-registry.ts +73 -0
- package/src/cache/read-through-swr.ts +134 -0
- package/src/cache/segment-codec.ts +256 -0
- package/src/cache/taint.ts +153 -0
- package/src/cache/types.ts +72 -122
- package/src/client.rsc.tsx +6 -1
- package/src/client.tsx +117 -303
- package/src/component-utils.ts +4 -4
- package/src/components/DefaultDocument.tsx +5 -1
- package/src/context-var.ts +156 -0
- package/src/debug.ts +19 -9
- package/src/errors.ts +78 -8
- package/src/handle.ts +56 -11
- package/src/handles/MetaTags.tsx +73 -20
- package/src/handles/breadcrumbs.ts +66 -0
- package/src/handles/index.ts +1 -0
- package/src/handles/meta.ts +30 -13
- package/src/host/cookie-handler.ts +21 -15
- package/src/host/errors.ts +8 -8
- package/src/host/index.ts +6 -9
- package/src/host/pattern-matcher.ts +27 -27
- package/src/host/router.ts +176 -82
- package/src/host/testing.ts +8 -8
- package/src/host/types.ts +46 -9
- package/src/host/utils.ts +2 -2
- package/src/href-client.ts +196 -56
- package/src/index.rsc.ts +140 -22
- package/src/index.ts +214 -53
- package/src/internal-debug.ts +11 -0
- package/src/loader-store.ts +463 -0
- package/src/loader.rsc.ts +25 -143
- package/src/loader.ts +27 -10
- package/src/network-error-thrower.tsx +3 -1
- package/src/outlet-context.ts +1 -1
- package/src/outlet-provider.tsx +45 -0
- package/src/prerender/param-hash.ts +4 -2
- package/src/prerender/store.ts +122 -17
- package/src/prerender.ts +397 -29
- package/src/response-utils.ts +28 -0
- package/src/reverse.ts +231 -121
- package/src/root-error-boundary.tsx +41 -29
- package/src/route-content-wrapper.tsx +7 -4
- package/src/route-definition/dsl-helpers.ts +1134 -0
- package/src/route-definition/helper-factories.ts +200 -0
- package/src/route-definition/helpers-types.ts +485 -0
- package/src/route-definition/index.ts +55 -0
- package/src/route-definition/redirect.ts +101 -0
- package/src/route-definition/resolve-handler-use.ts +155 -0
- package/src/route-definition.ts +1 -1431
- package/src/route-map-builder.ts +162 -123
- package/src/route-name.ts +53 -0
- package/src/route-types.ts +64 -9
- package/src/router/content-negotiation.ts +215 -0
- package/src/router/debug-manifest.ts +72 -0
- package/src/router/error-handling.ts +10 -10
- package/src/router/find-match.ts +160 -0
- package/src/router/handler-context.ts +376 -109
- package/src/router/intercept-resolution.ts +35 -20
- package/src/router/lazy-includes.ts +237 -0
- package/src/router/loader-resolution.ts +330 -145
- package/src/router/logging.ts +251 -0
- package/src/router/manifest.ts +70 -22
- package/src/router/match-api.ts +196 -261
- package/src/router/match-context.ts +4 -2
- package/src/router/match-handlers.ts +441 -0
- package/src/router/match-middleware/background-revalidation.ts +108 -93
- package/src/router/match-middleware/cache-lookup.ts +414 -91
- package/src/router/match-middleware/cache-store.ts +91 -29
- package/src/router/match-middleware/intercept-resolution.ts +48 -21
- package/src/router/match-middleware/segment-resolution.ts +73 -9
- package/src/router/match-pipelines.ts +10 -45
- package/src/router/match-result.ts +154 -35
- package/src/router/metrics.ts +241 -16
- package/src/router/middleware-cookies.ts +55 -0
- package/src/router/middleware-types.ts +209 -0
- package/src/router/middleware.ts +373 -371
- package/src/router/navigation-snapshot.ts +182 -0
- package/src/router/pattern-matching.ts +291 -54
- package/src/router/prerender-match.ts +502 -0
- package/src/router/preview-match.ts +98 -0
- package/src/router/request-classification.ts +310 -0
- package/src/router/revalidation.ts +195 -40
- package/src/router/route-snapshot.ts +245 -0
- package/src/router/router-context.ts +41 -21
- package/src/router/router-interfaces.ts +490 -0
- package/src/router/router-options.ts +618 -0
- package/src/router/router-registry.ts +21 -0
- package/src/router/segment-resolution/fresh.ts +756 -0
- package/src/router/segment-resolution/helpers.ts +268 -0
- package/src/router/segment-resolution/loader-cache.ts +199 -0
- package/src/router/segment-resolution/revalidation.ts +1407 -0
- package/src/router/segment-resolution/static-store.ts +67 -0
- package/src/router/segment-resolution.ts +21 -1336
- package/src/router/segment-wrappers.ts +291 -0
- package/src/router/substitute-pattern-params.ts +56 -0
- package/src/router/telemetry-otel.ts +299 -0
- package/src/router/telemetry.ts +300 -0
- package/src/router/timeout.ts +148 -0
- package/src/router/trie-matching.ts +111 -39
- package/src/router/types.ts +17 -9
- package/src/router/url-params.ts +49 -0
- package/src/router.ts +707 -2291
- package/src/rsc/handler-context.ts +45 -0
- package/src/rsc/handler.ts +864 -1117
- package/src/rsc/helpers.ts +181 -19
- package/src/rsc/index.ts +1 -21
- package/src/rsc/loader-fetch.ts +229 -0
- package/src/rsc/manifest-init.ts +90 -0
- package/src/rsc/nonce.ts +14 -0
- package/src/rsc/origin-guard.ts +141 -0
- package/src/rsc/progressive-enhancement.ts +395 -0
- package/src/rsc/response-error.ts +37 -0
- package/src/rsc/response-route-handler.ts +360 -0
- package/src/rsc/rsc-rendering.ts +256 -0
- package/src/rsc/runtime-warnings.ts +42 -0
- package/src/rsc/server-action.ts +360 -0
- package/src/rsc/ssr-setup.ts +128 -0
- package/src/rsc/types.ts +52 -11
- package/src/search-params.ts +230 -0
- package/src/segment-content-promise.ts +67 -0
- package/src/segment-loader-promise.ts +122 -0
- package/src/segment-system.tsx +187 -38
- package/src/serialize.ts +243 -0
- package/src/server/context.ts +344 -70
- package/src/server/cookie-store.ts +190 -0
- package/src/server/fetchable-loader-store.ts +37 -0
- package/src/server/handle-store.ts +113 -15
- package/src/server/loader-registry.ts +24 -64
- package/src/server/request-context.ts +603 -109
- package/src/server.ts +35 -155
- package/src/ssr/index.tsx +107 -30
- package/src/static-handler.ts +126 -0
- package/src/theme/ThemeProvider.tsx +21 -15
- package/src/theme/ThemeScript.tsx +5 -5
- package/src/theme/constants.ts +5 -2
- package/src/theme/index.ts +4 -14
- package/src/theme/theme-context.ts +4 -30
- package/src/theme/theme-script.ts +21 -18
- package/src/types/boundaries.ts +158 -0
- package/src/types/cache-types.ts +198 -0
- package/src/types/error-types.ts +192 -0
- package/src/types/global-namespace.ts +113 -0
- package/src/types/handler-context.ts +806 -0
- package/src/types/index.ts +89 -0
- package/src/types/loader-types.ts +209 -0
- package/src/types/request-scope.ts +126 -0
- package/src/types/route-config.ts +170 -0
- package/src/types/route-entry.ts +120 -0
- package/src/types/segments.ts +167 -0
- package/src/types.ts +1 -1763
- package/src/urls/include-helper.ts +207 -0
- package/src/urls/index.ts +53 -0
- package/src/urls/path-helper-types.ts +372 -0
- package/src/urls/path-helper.ts +364 -0
- package/src/urls/pattern-types.ts +141 -0
- package/src/urls/response-types.ts +108 -0
- package/src/urls/type-extraction.ts +377 -0
- package/src/urls/urls-function.ts +98 -0
- package/src/urls.ts +1 -1288
- package/src/use-loader.tsx +511 -107
- package/src/vite/debug.ts +184 -0
- package/src/vite/discovery/bundle-postprocess.ts +181 -0
- package/src/vite/discovery/discover-routers.ts +374 -0
- 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 +480 -0
- package/src/vite/discovery/route-types-writer.ts +258 -0
- package/src/vite/discovery/self-gen-tracking.ts +73 -0
- package/src/vite/discovery/state.ts +143 -0
- package/src/vite/discovery/virtual-module-codegen.ts +193 -0
- package/src/vite/index.ts +15 -2012
- package/src/vite/plugin-types.ts +103 -0
- package/src/vite/plugins/cjs-to-esm.ts +98 -0
- package/src/vite/plugins/client-ref-dedup.ts +131 -0
- package/src/vite/plugins/client-ref-hashing.ts +117 -0
- 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/{expose-action-id.ts → plugins/expose-action-id.ts} +109 -66
- package/src/vite/plugins/expose-id-utils.ts +303 -0
- package/src/vite/plugins/expose-ids/export-analysis.ts +320 -0
- package/src/vite/plugins/expose-ids/handler-transform.ts +209 -0
- package/src/vite/plugins/expose-ids/loader-transform.ts +74 -0
- package/src/vite/plugins/expose-ids/router-transform.ts +127 -0
- package/src/vite/plugins/expose-ids/types.ts +45 -0
- package/src/vite/plugins/expose-internal-ids.ts +816 -0
- package/src/vite/plugins/performance-tracks.ts +92 -0
- package/src/vite/plugins/refresh-cmd.ts +127 -0
- package/src/vite/plugins/use-cache-transform.ts +336 -0
- package/src/vite/plugins/version-injector.ts +109 -0
- package/src/vite/plugins/version-plugin.ts +323 -0
- package/src/vite/plugins/virtual-entries.ts +123 -0
- package/src/vite/plugins/virtual-stub-plugin.ts +29 -0
- package/src/vite/rango.ts +509 -0
- package/src/vite/router-discovery.ts +1511 -0
- package/src/vite/utils/ast-handler-extract.ts +517 -0
- package/src/vite/utils/banner.ts +36 -0
- package/src/vite/utils/bundle-analysis.ts +139 -0
- package/src/vite/utils/forward-user-plugins.ts +193 -0
- package/src/vite/utils/manifest-utils.ts +86 -0
- package/src/vite/utils/package-resolution.ts +161 -0
- package/src/vite/utils/prerender-utils.ts +222 -0
- package/src/vite/utils/shared-utils.ts +174 -0
- package/CLAUDE.md +0 -43
- package/src/browser/lru-cache.ts +0 -69
- package/src/browser/request-controller.ts +0 -164
- package/src/cache/memory-store.ts +0 -253
- package/src/router.gen.ts +0 -6
- package/src/urls.gen.ts +0 -8
- package/src/vite/expose-handle-id.ts +0 -209
- package/src/vite/expose-loader-id.ts +0 -426
- package/src/vite/expose-location-state-id.ts +0 -177
- package/src/vite/expose-prerender-handler-id.ts +0 -429
- /package/src/vite/{version.d.ts → plugins/version.d.ts} +0 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cache-guide
|
|
3
|
+
description: When to use cache() DSL vs "use cache" directive — key differences and decision guide
|
|
4
|
+
argument-hint:
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# cache() vs "use cache" — When to Use Which
|
|
8
|
+
|
|
9
|
+
Both mechanisms share the same backing store, cache profiles, and tag-based
|
|
10
|
+
invalidation. They differ in scope, cache key, execution model, and runtime control.
|
|
11
|
+
|
|
12
|
+
## Two axes — do not conflate
|
|
13
|
+
|
|
14
|
+
Everything on this page is **axis 1: stored-value freshness** — _is a cached
|
|
15
|
+
value still good?_ There is a second, orthogonal axis it is easy to mistake for
|
|
16
|
+
caching:
|
|
17
|
+
|
|
18
|
+
1. **Stored-value freshness** — _is a cached value still good?_
|
|
19
|
+
→ `"use cache"` (fn/component), `cache()` (segment), loader `cache()` (loader data).
|
|
20
|
+
Entries are coupled across the one store by **tags** (`revalidateTag`).
|
|
21
|
+
2. **Client-update selection** — _should this segment re-run and stream to the
|
|
22
|
+
client on this navigation/action?_
|
|
23
|
+
→ `revalidate()`. Covered in `/loader` and `/route`, **not here**.
|
|
24
|
+
|
|
25
|
+
They are orthogonal and compose: a segment selected by `revalidate()` still
|
|
26
|
+
consults its cache (hit → no recompute); a cache bust does **not** force a client
|
|
27
|
+
update, and `revalidate()` never reads, writes, or expires a cached value. If you
|
|
28
|
+
know React Router, `revalidate()` is `shouldRevalidate`, not `Cache-Control`. See
|
|
29
|
+
`/rango` → "Coming from another framework" for the cross-framework mapping.
|
|
30
|
+
|
|
31
|
+
## Fast choice
|
|
32
|
+
|
|
33
|
+
Read this first; use the rest of the page when the choice has edge cases.
|
|
34
|
+
|
|
35
|
+
1. Do you want to cache an entire route or group of routes?
|
|
36
|
+
**Yes** -> `cache()`
|
|
37
|
+
2. Do you need runtime conditions, such as skip for authed users or key by
|
|
38
|
+
locale?
|
|
39
|
+
**Yes** -> `cache()` with `condition` / `key`
|
|
40
|
+
3. Do you want to cache a data fetch or helper shared across routes?
|
|
41
|
+
**Yes** -> `"use cache"`
|
|
42
|
+
4. Do you need different cache entries for different function arguments?
|
|
43
|
+
**Yes** -> `"use cache"` (keyed by args)
|
|
44
|
+
5. Is the expensive part rendering a subtree?
|
|
45
|
+
**Yes** -> `cache()` (caches rendered segments)
|
|
46
|
+
6. Is the expensive part one query inside a larger live handler?
|
|
47
|
+
**Yes** -> `"use cache"` on the query function
|
|
48
|
+
|
|
49
|
+
## Correctness & invalidation
|
|
50
|
+
|
|
51
|
+
rango's caches are built so a hit can't serve wrong or stale-shaped data. These
|
|
52
|
+
guarantees are mostly automatic — worth knowing so you don't reimplement
|
|
53
|
+
protection the framework already gives you (or assume one it deliberately
|
|
54
|
+
doesn't).
|
|
55
|
+
|
|
56
|
+
There are two guard models to keep separate. Both block response side effects
|
|
57
|
+
(`ctx.header()`, cookie writes) that would be lost on a hit; they differ in what
|
|
58
|
+
else they allow:
|
|
59
|
+
|
|
60
|
+
- **`cache()` boundary guard** (route-level) — fires while the handler runs on a
|
|
61
|
+
miss. `ctx.get(nonCacheableVar)` throws (a tainted value would be baked into the
|
|
62
|
+
cached segment) and response side effects (`ctx.header()`, `ctx.setCookie()`,
|
|
63
|
+
`ctx.setStatus()`, `ctx.onResponse()`) throw. `ctx.set()` of a cacheable var is
|
|
64
|
+
**allowed** — children are cached too and can read it.
|
|
65
|
+
- **`"use cache"` exec-guard** (function-level) — stricter: inside the cached
|
|
66
|
+
function `cookies()`, `headers()`, `ctx.set()`, and `ctx.header()` all throw.
|
|
67
|
+
|
|
68
|
+
### Cross-deploy safety: version-segmented store keys
|
|
69
|
+
|
|
70
|
+
`CFCacheStore` prefixes every **physical** store key (the CF Cache API URL and
|
|
71
|
+
the KV key) with the build version — auto-generated from the
|
|
72
|
+
`@rangojs/router:version` virtual module, overridable via the store's `version`
|
|
73
|
+
option. A new deploy reads under a new prefix, so it can **never** read a
|
|
74
|
+
previous build's entries: no cross-deploy shape drift, and no dead client-chunk
|
|
75
|
+
references baked into cached RSC.
|
|
76
|
+
|
|
77
|
+
The tradeoff to know: **loader/data caches use the same store**, so they're
|
|
78
|
+
version-segmented too. Every deploy is therefore a _cold data cache_ — SWR can't
|
|
79
|
+
soften it, because no stale entry exists under the new key. For high-traffic,
|
|
80
|
+
frequently-deploying, data-bound apps that's a deploy-time origin warm-up. Decide
|
|
81
|
+
deliberately: accept it (correctness over hit-rate), or split the policy — let
|
|
82
|
+
the render/edge cache auto-version while a separate data store gets a stable
|
|
83
|
+
`version` so its entries survive deploys. (Per-process stores like
|
|
84
|
+
`MemorySegmentCacheStore` are cold on every restart anyway; this matters for
|
|
85
|
+
persistent stores.) See `/caching` for store setup.
|
|
86
|
+
|
|
87
|
+
### Client cache: forward/back is mutation-aware
|
|
88
|
+
|
|
89
|
+
The browser keeps a history (forward/back) cache of rendered segments. Any
|
|
90
|
+
client-side mutation (a server action) marks those entries **stale** and
|
|
91
|
+
broadcasts it to other tabs. On back/forward (popstate) the router looks up the
|
|
92
|
+
entry, sees it's stale, and revalidates — so your `revalidate()` predicates re-run
|
|
93
|
+
and the segment refreshes (SWR: the stale view paints instantly, fresh data
|
|
94
|
+
streams in). It's the client-side analog of the server-cache correctness problem,
|
|
95
|
+
solved on the partial-render axis.
|
|
96
|
+
|
|
97
|
+
### Request-scoped data: the `cache: false` taint
|
|
98
|
+
|
|
99
|
+
`createVar({ cache: false })` (or a `ctx.set(var, v, { cache: false })` write)
|
|
100
|
+
taints a value as request-scoped; reading it **directly** with `ctx.get()` inside
|
|
101
|
+
a `cache()` boundary throws — the guard against the catastrophic "serve user A's
|
|
102
|
+
data to user B" bug. The guarantee is precise and intentionally narrow — see
|
|
103
|
+
"Context Variable Cache Safety" below for exactly what it does and does not catch.
|
|
104
|
+
|
|
105
|
+
## Stale-while-revalidate
|
|
106
|
+
|
|
107
|
+
SWR is a first-class cache behavior when the backing store supports it: while an
|
|
108
|
+
entry is within its SWR window the cache serves the **stale value instantly** and
|
|
109
|
+
refreshes it in the **background** (`waitUntil`), so users never wait on a
|
|
110
|
+
recompute for a merely-aging entry.
|
|
111
|
+
|
|
112
|
+
- **`"use cache"`** resolves to the `default` profile `{ ttl: 900, swr: 1800 }`,
|
|
113
|
+
so function/component caching gets a 30-minute SWR window **out of the box**.
|
|
114
|
+
Tune or add profiles via `createRouter({ cacheProfiles: { … } })`
|
|
115
|
+
(`"use cache: short"` → the `short` profile).
|
|
116
|
+
- **`cache()` DSL and loader caches** take an explicit `swr` in seconds (or
|
|
117
|
+
inherit `store.defaults.swr`): `cache({ ttl: 60, swr: 300 })` → fresh ≤60s,
|
|
118
|
+
stale-served 60–360s, miss after 360s in stores that implement SWR for that
|
|
119
|
+
layer.
|
|
120
|
+
- **Client forward/back** is SWR after a mutation — see "Correctness &
|
|
121
|
+
invalidation" → Client cache.
|
|
122
|
+
- **Edge / document layer** uses the HTTP `stale-while-revalidate` directive; see
|
|
123
|
+
`/document-cache`.
|
|
124
|
+
|
|
125
|
+
SWR softens normal TTL expiry, **not** a cross-deploy cold cache — a new build
|
|
126
|
+
has no stale entry to serve (see version-segmented store keys above).
|
|
127
|
+
|
|
128
|
+
Store support is layer-specific. `CFCacheStore` supports SWR for segment,
|
|
129
|
+
document/response, and `"use cache"` item entries. `MemorySegmentCacheStore`
|
|
130
|
+
supports SWR for response and `"use cache"` item entries, but its route-segment
|
|
131
|
+
entries expire at TTL and never background-revalidate. Use the memory store for
|
|
132
|
+
local/dev behavior, not as proof that segment SWR is active.
|
|
133
|
+
|
|
134
|
+
## Key Differences
|
|
135
|
+
|
|
136
|
+
| | `cache()` DSL | `"use cache"` directive |
|
|
137
|
+
| -------------------- | ----------------------------------------------------- | -------------------------------------------------- |
|
|
138
|
+
| **Scope** | Route segment tree (handler + children + parallels) | Single function return value |
|
|
139
|
+
| **Defined at** | Route definition site (`urls.ts`) | Inside function body or at file top |
|
|
140
|
+
| **Cache key** | Request type + pathname + params (+ optional custom) | Function identity + serialized non-tainted args |
|
|
141
|
+
| **Execution on hit** | All-or-nothing: entire handler skipped | Partial: function body skipped, calling code runs |
|
|
142
|
+
| **Runtime control** | `condition` to disable, custom `key` function | None — if the directive is present, it caches |
|
|
143
|
+
| **Side effects** | Response side effects throw inside the boundary | `ctx.header()`, `ctx.set()`, etc. throw at runtime |
|
|
144
|
+
| **Handle data** | Captured and replayed | Captured and replayed |
|
|
145
|
+
| **Loaders** | Always fresh — excluded from cache, opt-in per loader | Can be used inside loaders |
|
|
146
|
+
| **Nesting** | Nest `cache()` boundaries with different TTLs | Compose by calling cached functions from uncached |
|
|
147
|
+
|
|
148
|
+
### cache() Cache Key
|
|
149
|
+
|
|
150
|
+
The key is `{requestType}:{pathname}:{params}` where requestType is one of
|
|
151
|
+
`doc:`, `partial:`, or `intercept:`. This means the same URL cached separately
|
|
152
|
+
for full document loads, client navigations, and intercept navigations.
|
|
153
|
+
|
|
154
|
+
Custom `key` functions can segment the cache further (e.g., by user role or locale).
|
|
155
|
+
`condition` can disable caching entirely at runtime (e.g., skip for authenticated users).
|
|
156
|
+
|
|
157
|
+
### "use cache" Cache Key
|
|
158
|
+
|
|
159
|
+
The key is `use-cache:{functionId}:{serializedArgs}` where functionId is a stable
|
|
160
|
+
ID from the Vite transform (module path + export name) and args are serialized via
|
|
161
|
+
RSC `encodeReply()`. Tainted arguments (ctx, env, req) are excluded.
|
|
162
|
+
|
|
163
|
+
## Execution Model
|
|
164
|
+
|
|
165
|
+
This is the most important distinction.
|
|
166
|
+
|
|
167
|
+
### cache() — all-or-nothing
|
|
168
|
+
|
|
169
|
+
On cache hit, the cache-lookup middleware short-circuits the entire pipeline.
|
|
170
|
+
No handler code runs. On miss, all handlers execute normally and segments are
|
|
171
|
+
stored.
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
HIT → cached segments served, loaders resolved fresh, no handler runs
|
|
175
|
+
MISS → all handlers run, segments cached, response built normally
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Headers, cookies, and ctx.set() calls inside handlers naturally don't execute on
|
|
179
|
+
hit. There is no partial execution, so no runtime guards are needed.
|
|
180
|
+
|
|
181
|
+
### "use cache" — partial execution
|
|
182
|
+
|
|
183
|
+
Only the wrapped function body is skipped on hit. The code that calls the
|
|
184
|
+
cached function still runs. This means ctx side effects inside the cached body
|
|
185
|
+
would silently disappear on hit.
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
HIT → function body skipped, calling code runs, handle data replayed
|
|
189
|
+
MISS → function body runs, return value + handle data cached
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Runtime guards throw if you call cookies(), headers(), ctx.header(), ctx.set(),
|
|
193
|
+
ctx.onResponse(), ctx.setTheme(), or ctx.setLocationState() inside a "use cache"
|
|
194
|
+
function. cookies() and headers() are blocked because per-request data is not in the
|
|
195
|
+
cache key. Side-effect methods are blocked because their effects are lost on hit.
|
|
196
|
+
Use ctx.use(Handle) instead for data — handle data is captured and replayed.
|
|
197
|
+
|
|
198
|
+
## When to Use cache()
|
|
199
|
+
|
|
200
|
+
Use the route-level `cache()` DSL when:
|
|
201
|
+
|
|
202
|
+
- **Caching entire routes or sections** — wrap a set of paths with one TTL.
|
|
203
|
+
- **You need runtime control** — disable caching for authenticated users with
|
|
204
|
+
`condition`, or segment cache keys by user/locale with `key`.
|
|
205
|
+
- **UI rendering is expensive** — the cached segments include the rendered
|
|
206
|
+
component tree, skipping RSC rendering on hit.
|
|
207
|
+
- **You want one cache entry per URL** — keyed on pathname + params, not on
|
|
208
|
+
function arguments.
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
export const urlpatterns = urls(({ path, cache }) => [
|
|
212
|
+
cache({ ttl: 300, condition: (ctx) => !ctx.get("user") }, () => [
|
|
213
|
+
path("/blog", BlogIndex, { name: "blog" }),
|
|
214
|
+
path("/blog/:slug", BlogPost, { name: "blogPost" }),
|
|
215
|
+
]),
|
|
216
|
+
]);
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## When to Use "use cache"
|
|
220
|
+
|
|
221
|
+
Use the `"use cache"` directive when:
|
|
222
|
+
|
|
223
|
+
- **Caching a specific data fetch** — one database query used across multiple
|
|
224
|
+
routes or components.
|
|
225
|
+
- **Different call sites need different cache entries** — the cache key includes
|
|
226
|
+
all non-tainted arguments, so `getProduct("a")` and `getProduct("b")` cache
|
|
227
|
+
separately.
|
|
228
|
+
- **Fine-grained caching within a handler** — cache the expensive part, keep
|
|
229
|
+
ctx side effects outside.
|
|
230
|
+
- **Caching an RSC component** — a component that fetches its own data can cache
|
|
231
|
+
its entire render.
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
async function getProductData(slug: string) {
|
|
235
|
+
"use cache: short";
|
|
236
|
+
return await db.query("SELECT * FROM products WHERE slug = ?", [slug]);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Handler calls cached function, sets headers outside
|
|
240
|
+
async function ProductPage(ctx) {
|
|
241
|
+
const data = await getProductData(ctx.params.slug);
|
|
242
|
+
ctx.header("X-Product", data.id);
|
|
243
|
+
return <Product data={data} />;
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Combining Both
|
|
248
|
+
|
|
249
|
+
They compose naturally. Use `cache()` for the route boundary and `"use cache"`
|
|
250
|
+
for shared data functions:
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
// urls.tsx — route-level cache for the rendered segment tree
|
|
254
|
+
cache({ ttl: 60 }, () => [
|
|
255
|
+
path("/product/:slug", ProductPage, { name: "product" }),
|
|
256
|
+
]);
|
|
257
|
+
|
|
258
|
+
// data.ts — function-level cache for the database query
|
|
259
|
+
export async function getProductData(slug: string) {
|
|
260
|
+
"use cache: long";
|
|
261
|
+
return await db.query("SELECT * FROM products WHERE slug = ?", [slug]);
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
On cache hit for the route, the handler doesn't run and `getProductData` is never
|
|
266
|
+
called. On cache miss, the handler runs and `getProductData` may itself return a
|
|
267
|
+
cached value from a previous call with the same slug.
|
|
268
|
+
|
|
269
|
+
### Nesting rule: the outer window bounds the inner
|
|
270
|
+
|
|
271
|
+
A cache's window bounds everything rendered inside it (loaders excepted). An
|
|
272
|
+
inner shorter TTL only takes effect when the **enclosing** cache recomputes — it
|
|
273
|
+
does **not** keep a value fresher than its parent:
|
|
274
|
+
|
|
275
|
+
- Outer `cache()` **fresh hit** → the subtree is served from stored RSC, so inner
|
|
276
|
+
`"use cache"` functions are **not consulted** (frozen at the outer's age — no
|
|
277
|
+
code inside the boundary runs on a hit).
|
|
278
|
+
- Outer **miss / SWR revalidation** → inner caches are consulted, each per its own
|
|
279
|
+
ttl/swr. With SWR on the outer, a stale subtree serves instantly and refreshes
|
|
280
|
+
in the background, so under traffic it keeps refreshing rather than rotting to
|
|
281
|
+
the worst case.
|
|
282
|
+
- **Loaders are the exception** — excluded from the segment cache, re-resolved
|
|
283
|
+
live even on an outer hit.
|
|
284
|
+
|
|
285
|
+
So `"use cache: short"` (60s) inside `cache({ ttl: 600 })` yields ~600s freshness
|
|
286
|
+
on hits, **not** 60s. This is not a bug: setting `cache({ ttl: 600 })` declares
|
|
287
|
+
"this subtree may be ~600s stale." **If a value must be fresher than its
|
|
288
|
+
enclosing segment, put it in a loader** (always live). `debugPerformance` prints
|
|
289
|
+
cache hits per layer, so the actual per-request behavior is observable.
|
|
290
|
+
|
|
291
|
+
## Headers and Cookies
|
|
292
|
+
|
|
293
|
+
Neither mechanism caches response headers or cookies.
|
|
294
|
+
|
|
295
|
+
- **cache()**: Response-level side effects throw inside the cache boundary even
|
|
296
|
+
on a miss: `ctx.header()`, `ctx.setCookie()`, `ctx.deleteCookie()`,
|
|
297
|
+
`ctx.setStatus()`, `ctx.onResponse()`, and direct `ctx.headers` mutation. On a
|
|
298
|
+
hit the handler would be skipped, so allowing the write on a miss would produce
|
|
299
|
+
inconsistent responses. If you need headers or cookies on every response, set
|
|
300
|
+
them in middleware or a live segment outside the cache boundary.
|
|
301
|
+
- **"use cache"**: cookies() and headers() throw inside the cached function
|
|
302
|
+
(both reads and writes). ctx.header() also throws. Move them outside.
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
// Set headers that must appear on every response in middleware
|
|
306
|
+
middleware(async (ctx, next) => {
|
|
307
|
+
ctx.header("X-Frame-Options", "DENY");
|
|
308
|
+
await next();
|
|
309
|
+
});
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Context Variable Cache Safety
|
|
313
|
+
|
|
314
|
+
Context variables created with `createVar()` are cacheable by default and can
|
|
315
|
+
be read freely inside cached scopes. A non-cacheable var throws when read
|
|
316
|
+
**directly** with `ctx.get()` inside a `cache()` boundary — where the value would
|
|
317
|
+
otherwise be serialized into the stored segment.
|
|
318
|
+
|
|
319
|
+
There are two ways to mark a value as non-cacheable:
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
// Var-level policy — inherently request-specific data
|
|
323
|
+
const Session = createVar<SessionData>({ cache: false });
|
|
324
|
+
|
|
325
|
+
// Write-level escalation — this specific write is non-cacheable
|
|
326
|
+
ctx.set(Theme, derivedTheme, { cache: false });
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
"Least cacheable wins": if either the var definition or the `ctx.set()` call
|
|
330
|
+
specifies `cache: false`, the value is non-cacheable.
|
|
331
|
+
|
|
332
|
+
**Behavior inside a `cache()` boundary:**
|
|
333
|
+
|
|
334
|
+
| Operation | Inside a `cache()` boundary |
|
|
335
|
+
| --------------------------------- | -------------------------------------------------- |
|
|
336
|
+
| `ctx.get(cacheableVar)` | Allowed |
|
|
337
|
+
| `ctx.get(nonCacheableVar)` | Throws (would be baked in) |
|
|
338
|
+
| `ctx.set(var, value)` (cacheable) | Allowed |
|
|
339
|
+
| `ctx.header()` / cookie writes | Throws (response side effect would be lost on hit) |
|
|
340
|
+
|
|
341
|
+
(Inside a `"use cache"` function the scoping differs: `ctx.set`, `ctx.header()`,
|
|
342
|
+
`cookies()`, and `headers()` **throw** via the cache-exec guard. Inside
|
|
343
|
+
`cache()`, response side effects throw via the cache-boundary guard, while the
|
|
344
|
+
`ctx.get(nonCacheableVar)` taint check above is tied to the `cache()` boundary —
|
|
345
|
+
see "Headers and Cookies" and the precise guarantee below.)
|
|
346
|
+
|
|
347
|
+
Write is dumb — `ctx.set()` stores the cache metadata but does not enforce.
|
|
348
|
+
Enforcement happens at read time (`ctx.get()`), where ALS detects the cache
|
|
349
|
+
scope and rejects non-cacheable reads.
|
|
350
|
+
|
|
351
|
+
### The guarantee is precise — a direct read inside `cache()`, not propagating
|
|
352
|
+
|
|
353
|
+
The guard fires on a **direct** `ctx.get(taintedVar)` **inside a `cache()`
|
|
354
|
+
boundary** (the scope `isInsideCacheScope` detects). The taint lives on the
|
|
355
|
+
variable; a value **derived** from it and read **outside** the boundary is not
|
|
356
|
+
tracked:
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
// CAUGHT — direct read of a tainted var inside a cache() boundary
|
|
360
|
+
cache({ ttl: 60 }, () => [
|
|
361
|
+
path("/dashboard", (ctx) => {
|
|
362
|
+
const user = ctx.get(User); // throws: non-cacheable read inside cache()
|
|
363
|
+
return <Dashboard user={user} />;
|
|
364
|
+
}, { name: "dashboard" }),
|
|
365
|
+
]);
|
|
366
|
+
|
|
367
|
+
// NOT CAUGHT — read outside the boundary, derived value cached
|
|
368
|
+
layout((ctx) => {
|
|
369
|
+
const name = ctx.get(User).name; // allowed — this layout is not cached
|
|
370
|
+
ctx.set(UserName, name); // now a plain (cacheable) string
|
|
371
|
+
return <Outlet />;
|
|
372
|
+
}, () => [
|
|
373
|
+
cache({ ttl: 60 }, () => [
|
|
374
|
+
// a child reads ctx.get(UserName) and silently caches user-derived data
|
|
375
|
+
]),
|
|
376
|
+
]);
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
So do **not** read this as "you can't cache user data" — that overstates it and
|
|
380
|
+
breeds the false confidence that makes the derived leak _more_ likely. The guard
|
|
381
|
+
is deliberately non-propagating (propagation would cost a wrapper per derivation
|
|
382
|
+
on the hot path), and it is scoped to the `cache()` segment boundary — `"use
|
|
383
|
+
cache"` functions guard request data differently (tainted `ctx`/`env`/`req` args
|
|
384
|
+
are excluded from the cache key, and `cookies()` / `headers()` throw inside them;
|
|
385
|
+
see "Headers and Cookies"). The pattern that stays safe is also the natural one:
|
|
386
|
+
**read tainted context at the point of use, in the path that needs it (a loader or
|
|
387
|
+
live segment) — never extract user data into a plain value and cache that.**
|
|
388
|
+
Loaders are exempt because they run outside the cache scope and resolve fresh
|
|
389
|
+
every request.
|
|
390
|
+
|
|
391
|
+
## Loaders Are Always Fresh
|
|
392
|
+
|
|
393
|
+
Loaders are **never cached** by route-level `cache()`. Even on a full cache hit
|
|
394
|
+
where all UI segments are served from cache, loaders are re-resolved fresh on
|
|
395
|
+
every request. This is enforced at two levels:
|
|
396
|
+
|
|
397
|
+
1. **Storage**: `cacheRoute()` filters out loader segments before serialization
|
|
398
|
+
(`segments.filter(s => s.type !== "loader")`).
|
|
399
|
+
2. **Retrieval**: On cache hit, `resolveLoadersOnly()` runs after yielding cached
|
|
400
|
+
UI segments, ensuring fresh data regardless of cache state.
|
|
401
|
+
|
|
402
|
+
This means `cache()` gives you cached UI + fresh data by default. To also cache
|
|
403
|
+
a loader's data, explicitly opt in with `loader(Fn, () => [cache({...})])`.
|
|
404
|
+
|
|
405
|
+
## cache() Placement Patterns
|
|
406
|
+
|
|
407
|
+
### Wrapping children of a path
|
|
408
|
+
|
|
409
|
+
An orphan `cache()` inside a path's children becomes the parent for all
|
|
410
|
+
subsequent siblings. Everything below the cache boundary is cached as one unit:
|
|
411
|
+
|
|
412
|
+
```typescript
|
|
413
|
+
path("/dashboard", DashboardPage, { name: "dashboard" }, () => [
|
|
414
|
+
cache("long"),
|
|
415
|
+
layout(DashboardSidebar, () => [
|
|
416
|
+
parallel("@stats", StatsPanel),
|
|
417
|
+
parallel("@activity", ActivityFeed),
|
|
418
|
+
]),
|
|
419
|
+
]),
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
On hit: DashboardPage, DashboardSidebar, StatsPanel, and ActivityFeed are all
|
|
423
|
+
served from cache. On miss: all handlers run, all segments cached together.
|
|
424
|
+
|
|
425
|
+
### Uncached layout with cached children
|
|
426
|
+
|
|
427
|
+
The cache boundary only covers what's inside it. Parent segments above the
|
|
428
|
+
boundary are not cached and always re-render:
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
layout(RootLayout, () => [
|
|
432
|
+
// RootLayout is NOT cached — runs every request
|
|
433
|
+
path("/products/:slug", ProductPage, { name: "product" }, () => [
|
|
434
|
+
cache("long"),
|
|
435
|
+
layout(ProductSidebar),
|
|
436
|
+
parallel("@reviews", ReviewsPanel),
|
|
437
|
+
parallel("@related", RelatedProducts),
|
|
438
|
+
]),
|
|
439
|
+
]),
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
RootLayout renders fresh every request. ProductPage, ProductSidebar,
|
|
443
|
+
ReviewsPanel, and RelatedProducts are all inside the cache boundary and
|
|
444
|
+
served from cache on hit. This is useful when the root layout depends on
|
|
445
|
+
request-specific data (user session, theme) but the product content is
|
|
446
|
+
cacheable.
|
|
447
|
+
|
|
448
|
+
### Loader-level caching
|
|
449
|
+
|
|
450
|
+
Loaders are excluded from route-level `cache()` by default — they always
|
|
451
|
+
resolve fresh. To opt a specific loader into caching, give it its own
|
|
452
|
+
`cache()` child:
|
|
453
|
+
|
|
454
|
+
```typescript
|
|
455
|
+
path("/product/:slug", ProductPage, { name: "product" }, () => [
|
|
456
|
+
// This loader is cached for 5 minutes
|
|
457
|
+
loader(ProductLoader, () => [cache({ ttl: 300 })]),
|
|
458
|
+
|
|
459
|
+
// This loader is always fresh
|
|
460
|
+
loader(CartLoader),
|
|
461
|
+
]),
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
This attaches the cache config directly to the loader entry. The loader's
|
|
465
|
+
data is cached independently from the route's segment cache. Loader caching
|
|
466
|
+
supports custom keys, tags, SWR, conditional bypass, and per-loader store
|
|
467
|
+
overrides — see `/loader` for the full reference.
|
|
468
|
+
|
|
469
|
+
## See Also
|
|
470
|
+
|
|
471
|
+
- `/caching` — cache() DSL setup, stores, nested boundaries
|
|
472
|
+
- `/use-cache` — "use cache" directive details, profiles, transforms, guards
|
|
473
|
+
- `/document-cache` — Edge caching with Cache-Control headers (different layer)
|
package/skills/caching/SKILL.md
CHANGED
|
@@ -30,14 +30,45 @@ export const urlpatterns = urls(({ path, cache }) => [
|
|
|
30
30
|
## Cache Options
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
33
|
-
cache(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
cache(
|
|
34
|
+
{
|
|
35
|
+
ttl: 60, // Time-to-live in seconds (default: 60)
|
|
36
|
+
swr: 300, // Stale-while-revalidate window (default: 300)
|
|
37
|
+
},
|
|
38
|
+
() => [
|
|
39
|
+
// Cached routes
|
|
40
|
+
],
|
|
41
|
+
);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Named Profile Shorthand
|
|
45
|
+
|
|
46
|
+
Use a named cache profile string instead of an options object. The profile must be
|
|
47
|
+
defined in `createRouter({ cacheProfiles })`. Unknown names throw at boot time.
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// Define profiles in router
|
|
51
|
+
createRouter({
|
|
52
|
+
cacheProfiles: {
|
|
53
|
+
default: { ttl: 900, swr: 1800 },
|
|
54
|
+
short: { ttl: 60, swr: 120 },
|
|
55
|
+
long: { ttl: 3600, swr: 7200 },
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Use by name in urls
|
|
60
|
+
export const urlpatterns = urls(({ path, cache }) => [
|
|
61
|
+
cache("long", () => [path("/blog", BlogIndex, { name: "blog" })]),
|
|
62
|
+
|
|
63
|
+
// Also works without children (orphan cache boundary)
|
|
64
|
+
cache("short"),
|
|
65
|
+
path("/feed", FeedPage, { name: "feed" }),
|
|
66
|
+
]);
|
|
39
67
|
```
|
|
40
68
|
|
|
69
|
+
These profile names are shared with the `"use cache: <name>"` directive. See
|
|
70
|
+
`/use-cache` for function-level caching.
|
|
71
|
+
|
|
41
72
|
## Loader-Level Caching
|
|
42
73
|
|
|
43
74
|
Cache individual loaders:
|
|
@@ -45,13 +76,11 @@ Cache individual loaders:
|
|
|
45
76
|
```typescript
|
|
46
77
|
path("/product/:slug", ProductPage, { name: "product" }, () => [
|
|
47
78
|
// Cache this loader's results
|
|
48
|
-
loader(ProductLoader, () => [
|
|
49
|
-
cache({ ttl: 300 }),
|
|
50
|
-
]),
|
|
79
|
+
loader(ProductLoader, () => [cache({ ttl: 300 })]),
|
|
51
80
|
|
|
52
81
|
// This loader is not cached
|
|
53
82
|
loader(CartLoader),
|
|
54
|
-
])
|
|
83
|
+
]);
|
|
55
84
|
```
|
|
56
85
|
|
|
57
86
|
## Global Cache Configuration
|
|
@@ -60,7 +89,7 @@ Configure a cache store in the router:
|
|
|
60
89
|
|
|
61
90
|
```typescript
|
|
62
91
|
import { createRouter } from "@rangojs/router";
|
|
63
|
-
import { MemorySegmentCacheStore } from "@rangojs/router/
|
|
92
|
+
import { MemorySegmentCacheStore } from "@rangojs/router/cache";
|
|
64
93
|
|
|
65
94
|
const store = new MemorySegmentCacheStore({
|
|
66
95
|
defaults: { ttl: 60, swr: 300 },
|
|
@@ -83,34 +112,75 @@ const router = createRouter({
|
|
|
83
112
|
For single-instance deployments:
|
|
84
113
|
|
|
85
114
|
```typescript
|
|
86
|
-
import { MemorySegmentCacheStore } from "@rangojs/router/
|
|
115
|
+
import { MemorySegmentCacheStore } from "@rangojs/router/cache";
|
|
87
116
|
|
|
88
117
|
const store = new MemorySegmentCacheStore({
|
|
89
118
|
defaults: { ttl: 60, swr: 300 },
|
|
90
|
-
maxSize: 1000,
|
|
119
|
+
maxSize: 1000, // Max entries
|
|
91
120
|
});
|
|
92
121
|
```
|
|
93
122
|
|
|
94
|
-
### Cloudflare
|
|
123
|
+
### Cloudflare Edge Cache Store
|
|
95
124
|
|
|
96
|
-
For distributed caching on Cloudflare Workers:
|
|
125
|
+
For distributed caching on Cloudflare Workers using the Cache API:
|
|
97
126
|
|
|
98
127
|
```typescript
|
|
99
|
-
import { CFCacheStore } from "@rangojs/router/cache
|
|
128
|
+
import { CFCacheStore } from "@rangojs/router/cache";
|
|
100
129
|
|
|
101
|
-
const router = createRouter({
|
|
130
|
+
const router = createRouter<AppBindings>({
|
|
131
|
+
document: Document,
|
|
132
|
+
urls: urlpatterns,
|
|
133
|
+
cache: (env, ctx) => ({
|
|
134
|
+
store: new CFCacheStore({
|
|
135
|
+
ctx,
|
|
136
|
+
defaults: { ttl: 60, swr: 300 },
|
|
137
|
+
}),
|
|
138
|
+
enabled: true,
|
|
139
|
+
}),
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### With KV L2 Persistence
|
|
144
|
+
|
|
145
|
+
Add a KV namespace for global cross-colo persistence. On Cache API miss, KV is
|
|
146
|
+
checked and hits are promoted back to L1. Writes go to both layers.
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { CFCacheStore } from "@rangojs/router/cache";
|
|
150
|
+
|
|
151
|
+
const router = createRouter<AppBindings>({
|
|
102
152
|
document: Document,
|
|
103
153
|
urls: urlpatterns,
|
|
104
|
-
cache: (env) => ({
|
|
154
|
+
cache: (env, ctx) => ({
|
|
105
155
|
store: new CFCacheStore({
|
|
106
|
-
|
|
107
|
-
|
|
156
|
+
ctx,
|
|
157
|
+
kv: env.CACHE_KV, // optional KV namespace binding
|
|
158
|
+
defaults: { ttl: 60, swr: 300 },
|
|
108
159
|
}),
|
|
109
160
|
enabled: true,
|
|
110
161
|
}),
|
|
111
162
|
});
|
|
112
163
|
```
|
|
113
164
|
|
|
165
|
+
**How the two layers work:**
|
|
166
|
+
|
|
167
|
+
| Scenario | L1 (Cache API) | L2 (KV) | Result |
|
|
168
|
+
| ------------ | -------------- | ------- | ----------------------------- |
|
|
169
|
+
| Hot request | HIT | — | Serve from L1 (fast) |
|
|
170
|
+
| Cold colo | MISS | HIT | Serve from KV, promote to L1 |
|
|
171
|
+
| First render | MISS | MISS | Render, write to both L1 + KV |
|
|
172
|
+
|
|
173
|
+
KV entries require `expirationTtl >= 60s`. Short-lived entries (< 60s total TTL)
|
|
174
|
+
are only cached in L1.
|
|
175
|
+
|
|
176
|
+
## Context Variables Inside Cache Boundaries
|
|
177
|
+
|
|
178
|
+
Context variables (`createVar`) are cacheable by default and can be read and
|
|
179
|
+
written inside `cache()` scopes. Variables marked with `{ cache: false }` (at
|
|
180
|
+
the var level or write level) throw when read inside a cache scope. Response
|
|
181
|
+
side effects (`ctx.header()`, `ctx.cookie()`) always throw inside cache
|
|
182
|
+
boundaries. See `/cache-guide` for the full cache safety table.
|
|
183
|
+
|
|
114
184
|
## Nested Cache Boundaries
|
|
115
185
|
|
|
116
186
|
Override cache settings for specific sections:
|
|
@@ -124,7 +194,7 @@ cache({ ttl: 300 }, () => [
|
|
|
124
194
|
cache({ ttl: 30 }, () => [
|
|
125
195
|
path("/blog/:slug", BlogPost, { name: "blogPost" }),
|
|
126
196
|
]),
|
|
127
|
-
])
|
|
197
|
+
]);
|
|
128
198
|
```
|
|
129
199
|
|
|
130
200
|
## Custom Cache Store
|
|
@@ -139,14 +209,14 @@ const checkoutCache = new MemorySegmentCacheStore({
|
|
|
139
209
|
// In urls
|
|
140
210
|
cache({ store: checkoutCache }, () => [
|
|
141
211
|
path("/checkout", CheckoutPage, { name: "checkout" }),
|
|
142
|
-
])
|
|
212
|
+
]);
|
|
143
213
|
```
|
|
144
214
|
|
|
145
215
|
## Complete Example
|
|
146
216
|
|
|
147
217
|
```typescript
|
|
148
218
|
import { urls } from "@rangojs/router";
|
|
149
|
-
import { MemorySegmentCacheStore } from "@rangojs/router/
|
|
219
|
+
import { MemorySegmentCacheStore } from "@rangojs/router/cache";
|
|
150
220
|
|
|
151
221
|
// Custom store for checkout (short TTL)
|
|
152
222
|
const checkoutCache = new MemorySegmentCacheStore({
|
|
@@ -175,7 +245,7 @@ export const urlpatterns = urls(({ path, layout, cache, loader, revalidate }) =>
|
|
|
175
245
|
path("/shop/product/:slug", ProductPage, { name: "product" }, () => [
|
|
176
246
|
loader(ProductLoader, () => [cache({ ttl: 120 })]),
|
|
177
247
|
loader(CartLoader, () => [
|
|
178
|
-
revalidate(({ actionId }) => actionId?.includes("Cart")
|
|
248
|
+
revalidate(({ actionId }) => actionId?.includes("Cart") || undefined),
|
|
179
249
|
]),
|
|
180
250
|
]),
|
|
181
251
|
]),
|