@rangojs/router 0.0.0-experimental.13 → 0.0.0-experimental.130
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 +1040 -5
- 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 +1712 -212
- 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/{src/browser/react/use-client-cache.ts → dist/browser/react/use-client-cache.js} +9 -26
- 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/{src/handles/index.ts → dist/handles/index.js} +1 -1
- 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/testing/vitest.js +82 -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 +6263 -2733
- package/dist/vite/index.js.bak +5448 -0
- package/dist/vite/index.js.map +1 -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 +123 -68
- package/skills/api-client/SKILL.md +211 -0
- package/skills/breadcrumbs/SKILL.md +312 -0
- package/skills/bundle-analysis/SKILL.md +159 -0
- package/skills/cache-guide/SKILL.md +486 -0
- package/skills/caching/SKILL.md +349 -24
- package/skills/composability/SKILL.md +197 -0
- package/skills/css/SKILL.md +76 -0
- package/skills/debug-manifest/SKILL.md +12 -8
- package/skills/document-cache/SKILL.md +87 -62
- package/skills/fonts/SKILL.md +6 -4
- package/skills/handler-use/SKILL.md +364 -0
- package/skills/hooks/SKILL.md +557 -79
- package/skills/host-router/SKILL.md +278 -0
- package/skills/i18n/SKILL.md +276 -0
- package/skills/intercept/SKILL.md +175 -8
- package/skills/layout/SKILL.md +128 -5
- package/skills/links/SKILL.md +304 -25
- package/skills/loader/SKILL.md +604 -54
- package/skills/middleware/SKILL.md +213 -37
- package/skills/migrate-nextjs/SKILL.md +584 -0
- package/skills/migrate-react-router/SKILL.md +769 -0
- package/skills/mime-routes/SKILL.md +41 -10
- package/skills/observability/SKILL.md +172 -0
- package/skills/parallel/SKILL.md +276 -3
- package/skills/prerender/SKILL.md +432 -52
- package/skills/rango/SKILL.md +313 -21
- package/skills/react-compiler/SKILL.md +168 -0
- package/skills/response-routes/SKILL.md +248 -120
- package/skills/route/SKILL.md +287 -21
- package/skills/router-setup/SKILL.md +231 -33
- package/skills/server-actions/SKILL.md +775 -0
- package/skills/streams-and-websockets/SKILL.md +283 -0
- package/skills/tailwind/SKILL.md +27 -3
- package/skills/testing/SKILL.md +129 -0
- package/skills/testing/bindings.md +89 -0
- package/skills/testing/cache-prerender.md +124 -0
- package/skills/testing/client-components.md +122 -0
- package/skills/testing/e2e-parity.md +125 -0
- package/skills/testing/flight.md +92 -0
- package/skills/testing/handles.md +129 -0
- package/skills/testing/loader.md +128 -0
- package/skills/testing/middleware.md +99 -0
- package/skills/testing/render-handler.md +121 -0
- package/skills/testing/response-routes.md +95 -0
- package/skills/testing/reverse-and-types.md +84 -0
- package/skills/testing/server-actions.md +107 -0
- package/skills/testing/server-tree.md +128 -0
- package/skills/testing/setup.md +120 -0
- package/skills/theme/SKILL.md +9 -8
- package/skills/typesafety/SKILL.md +547 -107
- package/skills/use-cache/SKILL.md +355 -0
- package/skills/view-transitions/SKILL.md +294 -0
- package/src/__augment-tests__/augment.ts +81 -0
- package/src/__augment-tests__/augmented.check.ts +116 -0
- package/src/__internal.ts +77 -44
- package/src/bin/rango.ts +312 -15
- package/src/browser/action-coordinator.ts +114 -0
- package/src/browser/action-fence.ts +47 -0
- package/src/browser/app-shell.ts +39 -0
- package/src/browser/app-version.ts +14 -0
- package/src/browser/cookie-name.ts +140 -0
- package/src/browser/event-controller.ts +162 -200
- 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/invalidate-client-cache.ts +52 -0
- package/src/browser/link-interceptor.ts +24 -4
- package/src/browser/logging.ts +11 -0
- package/src/browser/merge-segment-loaders.ts +20 -12
- package/src/browser/navigation-bridge.ts +323 -563
- package/src/browser/navigation-client.ts +219 -75
- package/src/browser/navigation-store-handle.ts +38 -0
- package/src/browser/navigation-store.ts +104 -112
- package/src/browser/navigation-transaction.ts +247 -0
- package/src/browser/network-error-handler.ts +61 -0
- package/src/browser/partial-update.ts +328 -348
- package/src/browser/prefetch/cache.ts +324 -0
- package/src/browser/prefetch/fetch.ts +357 -0
- package/src/browser/prefetch/observer.ts +65 -0
- package/src/browser/prefetch/policy.ts +48 -0
- package/src/browser/prefetch/queue.ts +194 -0
- package/src/browser/prefetch/resource-ready.ts +77 -0
- package/src/browser/rango-state.ts +194 -0
- package/src/browser/react/Link.tsx +253 -71
- package/src/browser/react/NavigationProvider.tsx +155 -34
- package/src/browser/react/ScrollRestoration.tsx +10 -6
- package/src/browser/react/context.ts +11 -0
- package/src/browser/react/filter-segment-order.ts +53 -0
- package/src/browser/react/index.ts +0 -48
- package/src/browser/react/location-state-shared.ts +260 -60
- package/src/browser/react/location-state.ts +90 -20
- 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 +35 -66
- package/src/browser/react/use-handle.ts +39 -126
- package/src/browser/react/use-link-status.ts +6 -9
- package/src/browser/react/use-navigation.ts +44 -68
- package/src/browser/react/use-params.ts +75 -0
- package/src/browser/react/use-pathname.ts +47 -0
- package/src/browser/react/use-reverse.ts +106 -0
- package/src/browser/react/use-router.ts +98 -0
- package/src/browser/react/use-search-params.ts +51 -0
- package/src/browser/react/use-segments.ts +72 -99
- package/src/browser/response-adapter.ts +124 -0
- package/src/browser/rsc-router.tsx +290 -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 +621 -613
- package/src/browser/types.ts +175 -50
- package/src/browser/validate-redirect-origin.ts +56 -0
- package/src/build/collect-fallback-refs.ts +107 -0
- package/src/build/generate-manifest.ts +123 -56
- package/src/build/generate-route-types.ts +41 -1038
- package/src/build/index.ts +9 -6
- package/src/build/prefix-tree-utils.ts +123 -0
- package/src/build/route-trie.ts +165 -34
- 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 +113 -0
- package/src/build/route-types/include-resolution.ts +418 -0
- package/src/build/route-types/param-extraction.ts +51 -0
- package/src/build/route-types/per-module-writer.ts +131 -0
- package/src/build/route-types/router-processing.ts +651 -0
- package/src/build/route-types/scan-filter.ts +85 -0
- package/src/build/route-types/source-scan.ts +118 -0
- package/src/build/runtime-discovery.ts +220 -0
- package/src/cache/background-task.ts +34 -0
- package/src/cache/cache-error.ts +104 -0
- package/src/cache/cache-key-utils.ts +44 -0
- package/src/cache/cache-policy.ts +165 -0
- package/src/cache/cache-runtime.ts +444 -0
- package/src/cache/cache-scope.ts +231 -325
- package/src/cache/cache-tag.ts +98 -0
- package/src/cache/cf/cf-cache-store.ts +2644 -75
- package/src/cache/cf/index.ts +17 -17
- package/src/cache/document-cache.ts +172 -92
- package/src/cache/handle-capture.ts +81 -0
- package/src/cache/handle-snapshot.ts +104 -0
- package/src/cache/index.ts +11 -35
- package/src/cache/memory-segment-store.ts +307 -30
- package/src/cache/profile-registry.ts +49 -0
- package/src/cache/read-through-swr.ts +164 -0
- package/src/cache/segment-codec.ts +240 -0
- package/src/cache/tag-invalidation.ts +230 -0
- package/src/cache/taint.ts +153 -0
- package/src/cache/types.ts +94 -211
- package/src/client.rsc.tsx +8 -21
- package/src/client.tsx +123 -347
- package/src/cloudflare/index.ts +11 -0
- package/src/cloudflare/tracing.ts +109 -0
- package/src/component-utils.ts +23 -4
- package/src/components/DefaultDocument.tsx +5 -1
- package/src/context-var.ts +168 -0
- package/src/debug.ts +19 -9
- package/src/decode-loader-results.ts +36 -0
- package/src/defer.ts +196 -0
- package/src/deps/ssr.ts +0 -1
- package/src/errors.ts +106 -10
- package/src/handle.ts +76 -23
- package/src/handles/MetaTags.tsx +73 -34
- package/src/handles/breadcrumbs.ts +77 -0
- package/src/handles/meta.ts +30 -52
- package/src/host/cookie-handler.ts +21 -51
- package/src/host/errors.ts +8 -32
- package/src/host/index.ts +12 -9
- package/src/host/pattern-matcher.ts +34 -77
- package/src/host/router.ts +151 -121
- package/src/host/testing.ts +45 -32
- package/src/host/types.ts +52 -11
- package/src/host/utils.ts +2 -2
- package/src/href-client.ts +192 -57
- package/src/index.rsc.ts +174 -34
- package/src/index.ts +241 -73
- package/src/internal-debug.ts +8 -4
- package/src/loader-store.ts +500 -0
- package/src/loader.rsc.ts +31 -99
- package/src/loader.ts +30 -12
- package/src/missing-id-error.ts +68 -0
- package/src/network-error-thrower.tsx +4 -7
- package/src/outlet-context.ts +1 -1
- package/src/outlet-provider.tsx +41 -0
- package/src/prerender/param-hash.ts +14 -13
- package/src/prerender/store.ts +121 -21
- package/src/prerender.ts +445 -24
- package/src/redirect-origin.ts +100 -0
- package/src/response-utils.ts +37 -0
- package/src/reverse.ts +198 -128
- package/src/root-error-boundary.tsx +42 -48
- package/src/route-content-wrapper.tsx +10 -72
- package/src/route-definition/dsl-helpers.ts +1116 -0
- package/src/route-definition/helper-factories.ts +90 -0
- package/src/route-definition/helpers-types.ts +506 -0
- package/src/route-definition/index.ts +55 -0
- package/src/route-definition/redirect.ts +135 -0
- package/src/route-definition/resolve-handler-use.ts +161 -0
- package/src/route-definition/use-item-types.ts +32 -0
- package/src/route-definition.ts +1 -1450
- package/src/route-map-builder.ts +82 -144
- package/src/route-name.ts +53 -0
- package/src/route-types.ts +72 -41
- package/src/router/basename.ts +14 -0
- package/src/router/content-negotiation.ts +215 -0
- package/src/router/debug-manifest.ts +72 -0
- package/src/router/error-handling.ts +22 -26
- package/src/router/find-match.ts +181 -0
- package/src/router/handler-context.ts +372 -125
- package/src/router/instrument.ts +308 -0
- package/src/router/intercept-resolution.ts +34 -27
- package/src/router/lazy-includes.ts +200 -0
- package/src/router/loader-resolution.ts +381 -147
- package/src/router/logging.ts +106 -6
- package/src/router/manifest.ts +88 -51
- package/src/router/match-api.ts +162 -245
- package/src/router/match-context.ts +4 -24
- package/src/router/match-handlers.ts +440 -0
- package/src/router/match-middleware/background-revalidation.ts +90 -89
- package/src/router/match-middleware/cache-lookup.ts +297 -150
- package/src/router/match-middleware/cache-store.ts +75 -33
- package/src/router/match-middleware/intercept-resolution.ts +44 -43
- package/src/router/match-middleware/segment-resolution.ts +64 -22
- package/src/router/match-pipelines.ts +11 -87
- package/src/router/match-result.ts +121 -50
- package/src/router/metrics.ts +219 -28
- package/src/router/middleware-types.ts +93 -0
- package/src/router/middleware.ts +421 -413
- package/src/router/navigation-snapshot.ts +131 -0
- package/src/router/params-util.ts +23 -0
- package/src/router/pattern-matching.ts +263 -79
- package/src/router/prerender-match.ts +541 -0
- package/src/router/preview-match.ts +100 -0
- package/src/router/request-classification.ts +276 -0
- package/src/router/revalidation.ts +143 -44
- package/src/router/route-snapshot.ts +244 -0
- package/src/router/router-context.ts +41 -47
- package/src/router/router-interfaces.ts +525 -0
- package/src/router/router-options.ts +726 -0
- package/src/router/router-registry.ts +21 -0
- package/src/router/segment-resolution/fresh.ts +748 -0
- package/src/router/segment-resolution/helpers.ts +313 -0
- package/src/router/segment-resolution/loader-cache.ts +207 -0
- package/src/router/segment-resolution/revalidation.ts +1322 -0
- package/src/router/segment-resolution/static-store.ts +81 -0
- package/src/router/segment-resolution/streamed-handler-telemetry.ts +52 -0
- package/src/router/segment-resolution/view-transition-default.ts +36 -0
- package/src/router/segment-resolution.ts +24 -1354
- package/src/router/segment-wrappers.ts +289 -0
- package/src/router/state-cookie-name.ts +33 -0
- package/src/router/substitute-pattern-params.ts +56 -0
- package/src/router/telemetry-otel.ts +261 -0
- package/src/router/telemetry.ts +377 -0
- package/src/router/timeout.ts +128 -0
- package/src/router/tracing.ts +206 -0
- package/src/router/trie-matching.ts +172 -60
- package/src/router/types.ts +23 -70
- package/src/router/url-params.ts +44 -0
- package/src/router.ts +748 -2376
- package/src/rsc/handler-context.ts +46 -0
- package/src/rsc/handler.ts +861 -1141
- package/src/rsc/helpers.ts +269 -19
- package/src/rsc/index.ts +1 -21
- package/src/rsc/json-route-result.ts +38 -0
- package/src/rsc/loader-fetch.ts +235 -0
- package/src/rsc/manifest-init.ts +77 -0
- package/src/rsc/nonce.ts +14 -0
- package/src/rsc/origin-guard.ts +155 -0
- package/src/rsc/progressive-enhancement.ts +413 -0
- package/src/rsc/redirect-guard.ts +99 -0
- package/src/rsc/response-error.ts +104 -0
- package/src/rsc/response-route-handler.ts +374 -0
- package/src/rsc/rsc-rendering.ts +261 -0
- package/src/rsc/runtime-warnings.ts +55 -0
- package/src/rsc/server-action.ts +376 -0
- package/src/rsc/ssr-setup.ts +144 -0
- package/src/rsc/types.ts +58 -12
- package/src/runtime-env.ts +18 -0
- package/src/search-params.ts +70 -74
- package/src/segment-content-promise.ts +67 -0
- package/src/segment-loader-promise.ts +134 -0
- package/src/segment-system.tsx +292 -134
- package/src/serialize.ts +243 -0
- package/src/server/context.ts +439 -85
- package/src/server/cookie-store.ts +265 -0
- package/src/server/fetchable-loader-store.ts +11 -6
- package/src/server/handle-store.ts +112 -31
- package/src/server/loader-registry.ts +23 -82
- package/src/server/request-context.ts +724 -143
- package/src/server.ts +26 -164
- package/src/ssr/index.tsx +113 -36
- package/src/static-handler.ts +45 -18
- package/src/testing/cache-status.ts +162 -0
- package/src/testing/collect-handle.ts +40 -0
- package/src/testing/dispatch.ts +618 -0
- package/src/testing/dom.entry.ts +22 -0
- package/src/testing/e2e/fixture.ts +188 -0
- package/src/testing/e2e/index.ts +128 -0
- package/src/testing/e2e/matchers.ts +35 -0
- package/src/testing/e2e/page-helpers.ts +272 -0
- package/src/testing/e2e/parity.ts +387 -0
- package/src/testing/e2e/server.ts +195 -0
- package/src/testing/flight-matchers.ts +97 -0
- package/src/testing/flight-normalize.ts +11 -0
- package/src/testing/flight-runtime.d.ts +57 -0
- package/src/testing/flight-tree.ts +682 -0
- package/src/testing/flight.entry.ts +52 -0
- package/src/testing/flight.ts +232 -0
- package/src/testing/generated-routes.ts +183 -0
- package/src/testing/index.ts +99 -0
- package/src/testing/internal/context.ts +348 -0
- package/src/testing/internal/flight-client-globals.ts +30 -0
- package/src/testing/internal/seed-vars.ts +54 -0
- package/src/testing/render-handler.ts +330 -0
- package/src/testing/render-route.tsx +566 -0
- package/src/testing/run-loader.ts +378 -0
- package/src/testing/run-middleware.ts +205 -0
- package/src/testing/vitest-stubs/cloudflare-email.ts +9 -0
- package/src/testing/vitest-stubs/cloudflare-workers.ts +21 -0
- package/src/testing/vitest-stubs/plugin-rsc.ts +16 -0
- package/src/testing/vitest-stubs/version.ts +5 -0
- package/src/testing/vitest.ts +305 -0
- package/src/theme/ThemeProvider.tsx +21 -67
- package/src/theme/ThemeScript.tsx +5 -11
- package/src/theme/constants.ts +5 -14
- package/src/theme/index.ts +3 -20
- package/src/theme/theme-context.ts +5 -35
- package/src/theme/theme-script.ts +21 -32
- package/src/theme/use-theme.ts +0 -3
- package/src/types/boundaries.ts +123 -0
- package/src/types/cache-types.ts +207 -0
- package/src/types/error-types.ts +132 -0
- package/src/types/global-namespace.ts +113 -0
- package/src/types/handler-context.ts +839 -0
- package/src/types/index.ts +79 -0
- package/src/types/loader-types.ts +212 -0
- package/src/types/request-scope.ts +107 -0
- package/src/types/route-config.ts +126 -0
- package/src/types/route-entry.ts +114 -0
- package/src/types/segments.ts +171 -0
- package/src/types.ts +1 -1795
- package/src/urls/include-helper.ts +160 -0
- package/src/urls/index.ts +43 -0
- package/src/urls/path-helper-types.ts +386 -0
- package/src/urls/path-helper.ts +275 -0
- package/src/urls/pattern-types.ts +124 -0
- package/src/urls/response-types.ts +109 -0
- package/src/urls/type-extraction.ts +291 -0
- package/src/urls/urls-function.ts +81 -0
- package/src/urls.ts +1 -1323
- package/src/use-loader.tsx +406 -141
- package/src/vite/debug.ts +185 -0
- package/src/vite/discovery/bundle-postprocess.ts +182 -0
- package/src/vite/discovery/discover-routers.ts +389 -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 +467 -0
- package/src/vite/discovery/route-types-writer.ts +214 -0
- package/src/vite/discovery/self-gen-tracking.ts +73 -0
- package/src/vite/discovery/state.ts +161 -0
- package/src/vite/discovery/virtual-module-codegen.ts +183 -0
- package/src/vite/index.ts +17 -2259
- package/src/vite/plugin-types.ts +221 -0
- package/src/vite/plugins/cjs-to-esm.ts +83 -0
- package/src/vite/plugins/client-ref-dedup.ts +120 -0
- package/src/vite/plugins/client-ref-hashing.ts +118 -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 +194 -0
- package/src/vite/{expose-action-id.ts → plugins/expose-action-id.ts} +88 -110
- package/src/vite/{expose-id-utils.ts → plugins/expose-id-utils.ts} +13 -87
- package/src/vite/plugins/expose-ids/export-analysis.ts +338 -0
- package/src/vite/plugins/expose-ids/handler-transform.ts +141 -0
- package/src/vite/plugins/expose-ids/loader-transform.ts +57 -0
- package/src/vite/plugins/expose-ids/router-transform.ts +124 -0
- package/src/vite/plugins/expose-ids/types.ts +45 -0
- package/src/vite/plugins/expose-internal-ids.ts +806 -0
- package/src/vite/plugins/performance-tracks.ts +89 -0
- package/src/vite/plugins/refresh-cmd.ts +127 -0
- package/src/vite/plugins/use-cache-transform.ts +313 -0
- package/src/vite/plugins/version-injector.ts +79 -0
- package/src/vite/plugins/version-plugin.ts +275 -0
- package/src/vite/plugins/virtual-entries.ts +108 -0
- package/src/vite/plugins/virtual-stub-plugin.ts +29 -0
- package/src/vite/rango.ts +444 -0
- package/src/vite/router-discovery.ts +1581 -0
- package/src/vite/{ast-handler-extract.ts → utils/ast-handler-extract.ts} +193 -37
- package/src/vite/utils/banner.ts +36 -0
- package/src/vite/utils/bundle-analysis.ts +132 -0
- package/src/vite/utils/client-chunks.ts +184 -0
- package/src/vite/utils/forward-user-plugins.ts +171 -0
- package/src/vite/utils/manifest-utils.ts +15 -0
- package/src/vite/utils/package-resolution.ts +89 -0
- package/src/vite/utils/prerender-utils.ts +223 -0
- package/src/vite/utils/shared-utils.ts +219 -0
- package/CLAUDE.md +0 -43
- package/src/browser/lru-cache.ts +0 -69
- package/src/browser/request-controller.ts +0 -164
- package/src/browser/shallow.ts +0 -35
- package/src/cache/memory-store.ts +0 -253
- package/src/router.gen.ts +0 -6
- package/src/static-handler.gen.ts +0 -5
- package/src/urls.gen.ts +0 -8
- package/src/vite/expose-internal-ids.ts +0 -1167
- /package/src/vite/{version.d.ts → plugins/version.d.ts} +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Cache Policy Utilities
|
|
3
|
+
*
|
|
4
|
+
* Resolution cascades for TTL, SWR, cache key, and cache store.
|
|
5
|
+
* Consolidates the multi-tier resolution pattern:
|
|
6
|
+
* explicit option → store defaults → fallback constant
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { CacheDefaults, SegmentCacheStore } from "./types.js";
|
|
10
|
+
import { _getRequestContext } from "../server/request-context.js";
|
|
11
|
+
import type { RequestContext } from "../server/request-context.js";
|
|
12
|
+
import { normalizeTags } from "./cache-tag.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Default TTL for route-level cache() DSL and loader cache.
|
|
16
|
+
* Applied when neither the cache options nor the store defaults specify a TTL.
|
|
17
|
+
*/
|
|
18
|
+
export const DEFAULT_ROUTE_TTL = 60;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Default TTL for function-level "use cache" (setItem).
|
|
22
|
+
* Applied when neither the item options nor the store defaults specify a TTL.
|
|
23
|
+
*/
|
|
24
|
+
export const DEFAULT_FUNCTION_TTL = 900;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Resolve effective TTL from the 3-tier cascade:
|
|
28
|
+
* explicit → store defaults → fallback.
|
|
29
|
+
*/
|
|
30
|
+
export function resolveTtl(
|
|
31
|
+
explicit: number | undefined,
|
|
32
|
+
defaults: CacheDefaults | undefined,
|
|
33
|
+
fallback: number,
|
|
34
|
+
): number {
|
|
35
|
+
if (explicit !== undefined) return explicit;
|
|
36
|
+
if (defaults?.ttl !== undefined) return defaults.ttl;
|
|
37
|
+
return fallback;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Resolve effective SWR window from the 2-tier cascade:
|
|
42
|
+
* explicit → store defaults.
|
|
43
|
+
* Returns 0 when unset (no SWR window).
|
|
44
|
+
*/
|
|
45
|
+
export function resolveSwrWindow(
|
|
46
|
+
explicit: number | undefined,
|
|
47
|
+
defaults: CacheDefaults | undefined,
|
|
48
|
+
): number {
|
|
49
|
+
if (explicit !== undefined) return explicit;
|
|
50
|
+
if (defaults?.swr !== undefined) return defaults.swr;
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Compute staleAt and expiresAt timestamps from TTL and SWR window.
|
|
56
|
+
*
|
|
57
|
+
* - staleAt: when the entry becomes stale (TTL boundary)
|
|
58
|
+
* - expiresAt: when the entry should be evicted (TTL + SWR)
|
|
59
|
+
*
|
|
60
|
+
* When swrWindow is 0, staleAt === expiresAt (no SWR).
|
|
61
|
+
*/
|
|
62
|
+
export function computeExpiration(
|
|
63
|
+
ttlSeconds: number,
|
|
64
|
+
swrSeconds: number = 0,
|
|
65
|
+
): { staleAt: number; expiresAt: number } {
|
|
66
|
+
const now = Date.now();
|
|
67
|
+
const staleAt = now + ttlSeconds * 1000;
|
|
68
|
+
const expiresAt = staleAt + swrSeconds * 1000;
|
|
69
|
+
return { staleAt, expiresAt };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function resolveCacheKey(
|
|
73
|
+
keyFn: ((ctx: RequestContext) => string | Promise<string>) | undefined,
|
|
74
|
+
store: SegmentCacheStore | null,
|
|
75
|
+
defaultKey: string,
|
|
76
|
+
_label: string,
|
|
77
|
+
): Promise<string> {
|
|
78
|
+
const requestCtx = _getRequestContext();
|
|
79
|
+
|
|
80
|
+
if (keyFn && requestCtx) {
|
|
81
|
+
return await keyFn(requestCtx);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (store?.keyGenerator && requestCtx) {
|
|
85
|
+
return await store.keyGenerator(requestCtx, defaultKey);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return defaultKey;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function resolveTagsOption<TEnv>(
|
|
92
|
+
tags: string[] | ((ctx: RequestContext<TEnv>) => string[]) | undefined,
|
|
93
|
+
ctx: RequestContext<TEnv> | undefined,
|
|
94
|
+
label: string,
|
|
95
|
+
): string[] | undefined {
|
|
96
|
+
if (!tags) return undefined;
|
|
97
|
+
if (typeof tags === "function") {
|
|
98
|
+
if (!ctx) {
|
|
99
|
+
console.warn(
|
|
100
|
+
`[${label}] Dynamic tags function present but no request context; ` +
|
|
101
|
+
`caching without tags (this entry will not be tag-invalidatable).`,
|
|
102
|
+
);
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
return normalizeTagList(tags(ctx));
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error(
|
|
109
|
+
`[${label}] Tags function failed, caching without tags:`,
|
|
110
|
+
error,
|
|
111
|
+
);
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return normalizeTagList(tags);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Normalize a resolved tags array so the WRITE path matches the invalidate path:
|
|
120
|
+
* updateTag()/revalidateTag()/cacheTag() all drop empty/whitespace-only tags via
|
|
121
|
+
* normalizeTag(). Without this, an empty tag attached at write time would enter
|
|
122
|
+
* the store index but could never be invalidated (the verbs normalize it away),
|
|
123
|
+
* and on CFCacheStore would also cost a wasted KV marker read per request.
|
|
124
|
+
* Returns undefined when nothing usable remains, keeping the entry header-free.
|
|
125
|
+
*/
|
|
126
|
+
function normalizeTagList(tags: string[]): string[] | undefined {
|
|
127
|
+
const out = normalizeTags(tags);
|
|
128
|
+
return out.length > 0 ? out : undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function resolveCacheStore(
|
|
132
|
+
explicitStore: SegmentCacheStore | undefined,
|
|
133
|
+
): SegmentCacheStore | null {
|
|
134
|
+
if (explicitStore) {
|
|
135
|
+
registerExplicitTaggedStore(explicitStore);
|
|
136
|
+
return explicitStore;
|
|
137
|
+
}
|
|
138
|
+
return _getRequestContext()?._cacheStore ?? null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Upper bound on the per-handler explicit-store registry. A module-singleton
|
|
143
|
+
* store (the recommended pattern) dedupes to a single entry and never approaches
|
|
144
|
+
* this. The cap bounds the niche case of an explicit store constructed PER
|
|
145
|
+
* request/boundary (e.g. a ctx-bound CFCacheStore, which must take a per-request
|
|
146
|
+
* ctx): without it the registry - which intentionally persists across requests so
|
|
147
|
+
* a server action's updateTag() can reach stores a prior render registered -
|
|
148
|
+
* would accumulate one dead instance per request and fan invalidation out to
|
|
149
|
+
* finished execution contexts. LRU-touch on re-resolution keeps a live, re-used
|
|
150
|
+
* store from being evicted by that churn.
|
|
151
|
+
*/
|
|
152
|
+
const EXPLICIT_STORE_REGISTRY_CAP = 64;
|
|
153
|
+
|
|
154
|
+
function registerExplicitTaggedStore(store: SegmentCacheStore): void {
|
|
155
|
+
const set = _getRequestContext()?._explicitTaggedStores;
|
|
156
|
+
if (!set) return;
|
|
157
|
+
// LRU touch: move an already-present store to the most-recent position (Set
|
|
158
|
+
// preserves insertion order) so a store re-resolved every request stays live.
|
|
159
|
+
set.delete(store);
|
|
160
|
+
set.add(store);
|
|
161
|
+
if (set.size > EXPLICIT_STORE_REGISTRY_CAP) {
|
|
162
|
+
const oldest = set.values().next().value;
|
|
163
|
+
if (oldest !== undefined) set.delete(oldest);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "use cache" Runtime
|
|
3
|
+
*
|
|
4
|
+
* Provides the runtime wrapper for functions marked with "use cache" directive.
|
|
5
|
+
* The Vite transform plugin wraps exports with registerCachedFunction().
|
|
6
|
+
*
|
|
7
|
+
* On cache miss: executes the function, serializes the result via RSC Flight
|
|
8
|
+
* protocol, captures handle data if tainted ctx is detected, and stores in
|
|
9
|
+
* the SegmentCacheStore.
|
|
10
|
+
*
|
|
11
|
+
* On cache hit: deserializes the cached result, restores handle data if present.
|
|
12
|
+
*
|
|
13
|
+
* On stale hit: returns stale data immediately, triggers background
|
|
14
|
+
* re-execution via waitUntil().
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/// <reference types="@vitejs/plugin-rsc/types" />
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
encodeReply,
|
|
21
|
+
createClientTemporaryReferenceSet,
|
|
22
|
+
} from "@vitejs/plugin-rsc/rsc";
|
|
23
|
+
import { getRequestContext } from "../server/request-context.js";
|
|
24
|
+
import { isUnderTestRunner } from "../runtime-env.js";
|
|
25
|
+
import {
|
|
26
|
+
isTainted,
|
|
27
|
+
CACHED_FN_SYMBOL,
|
|
28
|
+
isCachedFunction,
|
|
29
|
+
stampCacheExec,
|
|
30
|
+
unstampCacheExec,
|
|
31
|
+
} from "./taint.js";
|
|
32
|
+
|
|
33
|
+
export { isCachedFunction };
|
|
34
|
+
import { serializeResult, deserializeResult } from "./segment-codec.js";
|
|
35
|
+
import { createHandleStore } from "../server/handle-store.js";
|
|
36
|
+
import {
|
|
37
|
+
restoreHandles,
|
|
38
|
+
encodeHandles,
|
|
39
|
+
decodeHandles,
|
|
40
|
+
} from "./handle-snapshot.js";
|
|
41
|
+
import { startHandleCapture, type HandleCapture } from "./handle-capture.js";
|
|
42
|
+
import { sortedSearchString } from "./cache-key-utils.js";
|
|
43
|
+
import { runBackground } from "./background-task.js";
|
|
44
|
+
import {
|
|
45
|
+
normalizeTags,
|
|
46
|
+
recordRequestTags,
|
|
47
|
+
runWithCacheTagScope,
|
|
48
|
+
} from "./cache-tag.js";
|
|
49
|
+
import { reportCacheError } from "./cache-error.js";
|
|
50
|
+
import type { CacheItemResult } from "./types.js";
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Convert encodeReply result to a stable string key.
|
|
54
|
+
* encodeReply may return string or FormData — normalize to string.
|
|
55
|
+
*/
|
|
56
|
+
async function replyToCacheKey(encoded: string | FormData): Promise<string> {
|
|
57
|
+
if (typeof encoded === "string") return encoded;
|
|
58
|
+
// FormData: convert to Response body, then to string for deterministic key
|
|
59
|
+
const text = await new Response(encoded).text();
|
|
60
|
+
return text;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Cached-fn ids already warned about running uncached under a test runner, so
|
|
64
|
+
// the test-ergonomics warning fires once per fn rather than once per call.
|
|
65
|
+
const warnedUncachedUnderTest = new Set<string>();
|
|
66
|
+
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Core: registerCachedFunction
|
|
69
|
+
// ============================================================================
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Register a function as a cached function.
|
|
73
|
+
* Called by the Vite transform for each "use cache" function.
|
|
74
|
+
*
|
|
75
|
+
* @param fn - The original async function
|
|
76
|
+
* @param id - Stable identifier (module path + export name)
|
|
77
|
+
* @param profileName - Cache profile name (from "use cache: profileName" or "default")
|
|
78
|
+
*/
|
|
79
|
+
export function registerCachedFunction<T extends (...args: any[]) => any>(
|
|
80
|
+
fn: T,
|
|
81
|
+
id: string,
|
|
82
|
+
profileName: string,
|
|
83
|
+
): T {
|
|
84
|
+
const wrapped = async function (this: any, ...args: any[]): Promise<any> {
|
|
85
|
+
const requestCtx = getRequestContext();
|
|
86
|
+
const store = requestCtx?._cacheStore;
|
|
87
|
+
const resolvedProfileName = profileName || "default";
|
|
88
|
+
|
|
89
|
+
// Bypass: no store or no getItem support. Still run inside a tag scope so a
|
|
90
|
+
// cacheTag() call inside the function degrades to a no-op rather than
|
|
91
|
+
// throwing "must be called inside a use cache function" - adopting cacheTag()
|
|
92
|
+
// must not hard-fail in apps/tests without an item-capable cache configured.
|
|
93
|
+
// Note: the INSIDE_CACHE_EXEC guard (cookies()/headers()/ctx.set() rejection)
|
|
94
|
+
// is intentionally NOT stamped here. It is a cached-path-only check; in the
|
|
95
|
+
// bypass the body actually executes, so the guarded side effects take effect
|
|
96
|
+
// and nothing is lost on a (non-existent) hit. Same applies to the
|
|
97
|
+
// non-serializable-args bypass below.
|
|
98
|
+
if (!store?.getItem) {
|
|
99
|
+
// Test-ergonomics guard: under a test runner, a "use cache" function that
|
|
100
|
+
// executes with no item-capable store seeded is exercising the UNCACHED
|
|
101
|
+
// path — a green test that proves nothing about caching. Warn once per fn
|
|
102
|
+
// id so the author knows to seed a cacheStore. Advisory (never throws), so
|
|
103
|
+
// a test that DELIBERATELY runs uncached is unaffected. Gated on the test
|
|
104
|
+
// runner (process.env.VITEST, not folded) so production never evaluates it.
|
|
105
|
+
if (isUnderTestRunner() && !warnedUncachedUnderTest.has(id)) {
|
|
106
|
+
warnedUncachedUnderTest.add(id);
|
|
107
|
+
console.warn(
|
|
108
|
+
`[rango] "use cache" function "${id}" executed but no cacheStore was ` +
|
|
109
|
+
`seeded; the cached path is NOT under test (it ran uncached). Pass ` +
|
|
110
|
+
`{ cacheStore, cacheProfiles } to runLoader/runMiddleware/renderHandler/` +
|
|
111
|
+
`runInRequestContext (or configure createRouter({ cache }) for dispatch) ` +
|
|
112
|
+
`to exercise it.`,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
const scoped = runWithCacheTagScope(() => fn.apply(this, args));
|
|
116
|
+
const result = await scoped.result;
|
|
117
|
+
// Still record the runtime tags into the request set so a cacheTag() in an
|
|
118
|
+
// uncached function tags the document, even with no item-capable store.
|
|
119
|
+
recordRequestTags(scoped.tags, requestCtx);
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Resolve profile strictly from request-scoped config (set by the
|
|
124
|
+
// active router via createRequestContext). No global fallback —
|
|
125
|
+
// global profile state is only for DSL-time cache("profileName").
|
|
126
|
+
const profile = requestCtx?._cacheProfiles?.[resolvedProfileName];
|
|
127
|
+
|
|
128
|
+
if (!profile) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
`[use cache] "${id}" uses unknown cache profile "${resolvedProfileName}". ` +
|
|
131
|
+
`Define it in createRouter({ cacheProfiles: { "${resolvedProfileName}": { ttl: ... } } }).`,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Separate tainted args (ctx, env, req) from key-generating args.
|
|
136
|
+
// For tainted objects that carry route context (params, pathname,
|
|
137
|
+
// searchParams), extract serializable values into the key so
|
|
138
|
+
// different routes, param combinations, and query variants produce
|
|
139
|
+
// distinct cache entries.
|
|
140
|
+
const keyArgs: unknown[] = [];
|
|
141
|
+
let hasTaintedArgs = false;
|
|
142
|
+
for (const arg of args) {
|
|
143
|
+
if (isTainted(arg)) {
|
|
144
|
+
hasTaintedArgs = true;
|
|
145
|
+
const ctx = arg as any;
|
|
146
|
+
if (ctx.params && typeof ctx.params === "object") {
|
|
147
|
+
// Include host to prevent cross-host cache collisions (same
|
|
148
|
+
// pattern as route-level cache-scope.ts key generation).
|
|
149
|
+
if (ctx.url?.host) {
|
|
150
|
+
keyArgs.push(ctx.url.host);
|
|
151
|
+
}
|
|
152
|
+
// Include route name to prevent collisions when the same cached
|
|
153
|
+
// function is reused across routes with identical pathname/params
|
|
154
|
+
// but different local reverse() scope.
|
|
155
|
+
if (ctx._routeName) {
|
|
156
|
+
keyArgs.push(ctx._routeName);
|
|
157
|
+
}
|
|
158
|
+
keyArgs.push(ctx.pathname, ctx.params);
|
|
159
|
+
if (ctx._responseType) {
|
|
160
|
+
keyArgs.push(ctx._responseType);
|
|
161
|
+
}
|
|
162
|
+
// Include user-facing search params (exclude internal _rsc*/__ params)
|
|
163
|
+
if (ctx.searchParams instanceof URLSearchParams) {
|
|
164
|
+
const normalized = sortedSearchString(ctx.searchParams);
|
|
165
|
+
if (normalized) {
|
|
166
|
+
keyArgs.push(normalized);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
keyArgs.push(arg);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// If tainted args are present, we need the handle store for capture/restore.
|
|
176
|
+
// During late streaming (Suspense boundary resolution), ALS context may be
|
|
177
|
+
// gone. Throw early rather than silently dropping handle side effects.
|
|
178
|
+
if (hasTaintedArgs && !requestCtx?._handleStore) {
|
|
179
|
+
throw new Error(
|
|
180
|
+
`[use cache] "${id}" receives a tainted argument (ctx/env/req) but the ` +
|
|
181
|
+
`HandleStore is not available. This typically happens when a "use cache" ` +
|
|
182
|
+
`function with ctx runs outside the request context (e.g., during late ` +
|
|
183
|
+
`streaming after AsyncLocalStorage context is lost). Move the "use cache" ` +
|
|
184
|
+
`directive to a function that does not receive request-scoped objects, or ` +
|
|
185
|
+
`use the route-level cache() DSL instead.`,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Generate cache key
|
|
190
|
+
let cacheKey: string;
|
|
191
|
+
try {
|
|
192
|
+
if (keyArgs.length > 0) {
|
|
193
|
+
const tempRefs = createClientTemporaryReferenceSet();
|
|
194
|
+
const encoded = await encodeReply(keyArgs as unknown[], {
|
|
195
|
+
temporaryReferences: tempRefs,
|
|
196
|
+
});
|
|
197
|
+
const argsKey = await replyToCacheKey(encoded);
|
|
198
|
+
cacheKey = `use-cache:${id}:${argsKey}`;
|
|
199
|
+
} else {
|
|
200
|
+
cacheKey = `use-cache:${id}`;
|
|
201
|
+
}
|
|
202
|
+
} catch {
|
|
203
|
+
// Non-serializable args: run uncached (within a tag scope so cacheTag()
|
|
204
|
+
// still does not throw). Record runtime tags so the document union still
|
|
205
|
+
// sees them even though this call is not itself cached.
|
|
206
|
+
const scoped = runWithCacheTagScope(() => fn.apply(this, args));
|
|
207
|
+
const result = await scoped.result;
|
|
208
|
+
recordRequestTags(scoped.tags, requestCtx);
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Cache lookup
|
|
213
|
+
const cached = await store.getItem(cacheKey);
|
|
214
|
+
|
|
215
|
+
// Serve a cached entry on the hit path: deserialize the stored value,
|
|
216
|
+
// replay handle data (gated on tainted args), and surface the entry's tags
|
|
217
|
+
// to the request set (the function did not re-run, so its runtime cacheTag()
|
|
218
|
+
// tags are only available from the stored entry). Shared by the fresh-hit
|
|
219
|
+
// and stale-hit branches; the only divergence is the stale branch scheduling
|
|
220
|
+
// background revalidation, which it does after this returns.
|
|
221
|
+
const serveCached = async (entry: CacheItemResult): Promise<any> => {
|
|
222
|
+
const result = await deserializeResult(entry.value);
|
|
223
|
+
if (entry.handles && hasTaintedArgs) {
|
|
224
|
+
const handleStore = requestCtx?._handleStore;
|
|
225
|
+
if (handleStore) {
|
|
226
|
+
const r = await decodeHandles(entry.handles);
|
|
227
|
+
if (r) restoreHandles(r, handleStore);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
recordRequestTags(entry.tags, requestCtx);
|
|
231
|
+
return result;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
if (cached && !cached.shouldRevalidate) {
|
|
235
|
+
// Fresh hit: deserialize and return
|
|
236
|
+
try {
|
|
237
|
+
return await serveCached(cached);
|
|
238
|
+
} catch (error) {
|
|
239
|
+
// The stored value is corrupt/partial (failed RSC deserialize). Report
|
|
240
|
+
// it, then fall through to fresh execution - the miss path below re-runs
|
|
241
|
+
// and setItem() overwrites the faulty entry under the same key (self-heal).
|
|
242
|
+
reportCacheError(
|
|
243
|
+
error,
|
|
244
|
+
"cache-corrupt",
|
|
245
|
+
`[use cache] "${id}" fresh-hit`,
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (cached?.shouldRevalidate) {
|
|
251
|
+
// Stale hit: return stale value, revalidate in background
|
|
252
|
+
try {
|
|
253
|
+
const result = await serveCached(cached);
|
|
254
|
+
// Background revalidation — must capture handles if tainted args present.
|
|
255
|
+
// Use an isolated handle store so background pushes don't pollute the
|
|
256
|
+
// live response or throw LateHandlePushError on the completed store.
|
|
257
|
+
// Same isolation pattern as route-level background-revalidation.ts.
|
|
258
|
+
runBackground(requestCtx, async () => {
|
|
259
|
+
// Reuse closure-captured requestCtx instead of calling
|
|
260
|
+
// getRequestContext() — ALS context may be gone inside waitUntil.
|
|
261
|
+
let originalHandleStore:
|
|
262
|
+
| ReturnType<typeof createHandleStore>
|
|
263
|
+
| undefined;
|
|
264
|
+
if (hasTaintedArgs && requestCtx) {
|
|
265
|
+
originalHandleStore = requestCtx._handleStore;
|
|
266
|
+
requestCtx._handleStore = createHandleStore();
|
|
267
|
+
}
|
|
268
|
+
const bgHandleStore = hasTaintedArgs
|
|
269
|
+
? requestCtx?._handleStore
|
|
270
|
+
: undefined;
|
|
271
|
+
let bgCapture: HandleCapture | undefined;
|
|
272
|
+
let bgStopCapture: (() => void) | undefined;
|
|
273
|
+
if (bgHandleStore) {
|
|
274
|
+
const c = startHandleCapture(bgHandleStore);
|
|
275
|
+
bgCapture = c.capture;
|
|
276
|
+
bgStopCapture = c.stop;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Stamp tainted ARGS only — not requestCtx. The args stamp guards
|
|
280
|
+
// direct ctx method calls (ctx.set, ctx.header, ctx.onResponse, etc.)
|
|
281
|
+
// which is sufficient for correctness.
|
|
282
|
+
//
|
|
283
|
+
// We intentionally skip stamping requestCtx here because:
|
|
284
|
+
// 1. runBackground starts the async task synchronously (before the
|
|
285
|
+
// first await), so stampCacheExec would pollute the shared
|
|
286
|
+
// requestCtx while the foreground pipeline is still running.
|
|
287
|
+
// This causes assertNotInsideCacheExec to fire when cache-store
|
|
288
|
+
// later calls requestCtx.onResponse().
|
|
289
|
+
// 2. requestCtx methods are closure-bound to the original ctx, so
|
|
290
|
+
// neither Object.create() nor a proxy can isolate the stamp.
|
|
291
|
+
// 3. The foreground miss path already stamps requestCtx and catches
|
|
292
|
+
// cookies()/headers() misuse on first execution. The background
|
|
293
|
+
// re-runs the same function with the same request.
|
|
294
|
+
const bgTaintedArgs: unknown[] = [];
|
|
295
|
+
for (const arg of args) {
|
|
296
|
+
if (isTainted(arg)) {
|
|
297
|
+
stampCacheExec(arg as object);
|
|
298
|
+
bgTaintedArgs.push(arg);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
try {
|
|
303
|
+
const scoped = runWithCacheTagScope(() => fn.apply(this, args));
|
|
304
|
+
const freshResult = await scoped.result;
|
|
305
|
+
bgStopCapture?.();
|
|
306
|
+
// Merge profile/DSL tags with runtime cacheTag() tags, read after
|
|
307
|
+
// awaiting so post-await cacheTag() calls are included. Normalize
|
|
308
|
+
// (drops empty profile tags, matching the invalidate path) + dedupe.
|
|
309
|
+
const freshTags = [
|
|
310
|
+
...new Set(
|
|
311
|
+
normalizeTags([...(profile.tags ?? []), ...scoped.tags]),
|
|
312
|
+
),
|
|
313
|
+
];
|
|
314
|
+
recordRequestTags(freshTags, requestCtx);
|
|
315
|
+
const serialized = await serializeResult(freshResult);
|
|
316
|
+
if (serialized !== null) {
|
|
317
|
+
const encodedHandles = bgCapture?.data
|
|
318
|
+
? await encodeHandles(bgCapture.data)
|
|
319
|
+
: undefined;
|
|
320
|
+
await store.setItem!(cacheKey, serialized, {
|
|
321
|
+
handles: encodedHandles,
|
|
322
|
+
ttl: profile.ttl,
|
|
323
|
+
swr: profile.swr,
|
|
324
|
+
tags: freshTags.length > 0 ? freshTags : undefined,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
} catch (bgError) {
|
|
328
|
+
bgStopCapture?.();
|
|
329
|
+
// Pass requestCtx explicitly: this runs in a detached background
|
|
330
|
+
// task where the ALS context is gone, so onError can only fire if
|
|
331
|
+
// we hand it the context captured up front.
|
|
332
|
+
reportCacheError(
|
|
333
|
+
bgError,
|
|
334
|
+
"stale-revalidation",
|
|
335
|
+
"[use cache] background revalidation failed",
|
|
336
|
+
requestCtx,
|
|
337
|
+
);
|
|
338
|
+
} finally {
|
|
339
|
+
for (const arg of bgTaintedArgs) {
|
|
340
|
+
unstampCacheExec(arg as object);
|
|
341
|
+
}
|
|
342
|
+
// Restore original handle store
|
|
343
|
+
if (originalHandleStore && requestCtx) {
|
|
344
|
+
requestCtx._handleStore = originalHandleStore;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
return result;
|
|
349
|
+
} catch (error) {
|
|
350
|
+
// Stale value is corrupt/partial; report and fall through to a fresh
|
|
351
|
+
// execution, which overwrites the faulty entry under the same key.
|
|
352
|
+
reportCacheError(
|
|
353
|
+
error,
|
|
354
|
+
"cache-corrupt",
|
|
355
|
+
`[use cache] "${id}" stale-hit`,
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Cache miss: execute, serialize, store
|
|
361
|
+
const handleStore = hasTaintedArgs ? requestCtx?._handleStore : undefined;
|
|
362
|
+
let capture: HandleCapture | undefined;
|
|
363
|
+
let stopCapture: (() => void) | undefined;
|
|
364
|
+
if (handleStore && hasTaintedArgs) {
|
|
365
|
+
const c = startHandleCapture(handleStore);
|
|
366
|
+
capture = c.capture;
|
|
367
|
+
stopCapture = c.stop;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Stamp tainted args so ctx.set(), ctx.header(), etc. throw if called
|
|
371
|
+
// inside the cached function body (those side effects are lost on hit).
|
|
372
|
+
// Uses ref-counted stamp/unstamp so overlapping executions
|
|
373
|
+
// sharing the same ctx don't clear each other's guards.
|
|
374
|
+
const taintedArgs: unknown[] = [];
|
|
375
|
+
for (const arg of args) {
|
|
376
|
+
if (isTainted(arg)) {
|
|
377
|
+
stampCacheExec(arg as object);
|
|
378
|
+
taintedArgs.push(arg);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// Always stamp the ALS RequestContext so cookies()/headers() guards fire
|
|
382
|
+
// even when the cached function receives no tainted args. The guard in
|
|
383
|
+
// cookie-store.ts checks RequestContext, not function args.
|
|
384
|
+
if (requestCtx) {
|
|
385
|
+
stampCacheExec(requestCtx as object);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
let result: any;
|
|
389
|
+
let scoped: ReturnType<typeof runWithCacheTagScope>;
|
|
390
|
+
try {
|
|
391
|
+
scoped = runWithCacheTagScope(() => fn.apply(this, args));
|
|
392
|
+
result = await scoped.result;
|
|
393
|
+
} finally {
|
|
394
|
+
// Decrement ref count; symbol is deleted when it reaches zero
|
|
395
|
+
for (const arg of taintedArgs) {
|
|
396
|
+
unstampCacheExec(arg as object);
|
|
397
|
+
}
|
|
398
|
+
if (requestCtx) {
|
|
399
|
+
unstampCacheExec(requestCtx as object);
|
|
400
|
+
}
|
|
401
|
+
// Remove this capture token (order-independent, safe for concurrent use)
|
|
402
|
+
stopCapture?.();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Merge profile/DSL tags with runtime cacheTag() tags. Read scoped.tags
|
|
406
|
+
// after awaiting result so post-await cacheTag() calls are included.
|
|
407
|
+
// Normalize (drops empty profile tags, matching the invalidate path) + dedupe.
|
|
408
|
+
const allTags = [
|
|
409
|
+
...new Set(normalizeTags([...(profile.tags ?? []), ...scoped!.tags])),
|
|
410
|
+
];
|
|
411
|
+
recordRequestTags(allTags, requestCtx);
|
|
412
|
+
|
|
413
|
+
// Serialize and store — fully non-blocking when waitUntil is available.
|
|
414
|
+
// The response does not need to wait for serialization or the store write.
|
|
415
|
+
const cacheWrite = async () => {
|
|
416
|
+
try {
|
|
417
|
+
const serialized = await serializeResult(result);
|
|
418
|
+
if (serialized !== null) {
|
|
419
|
+
const encodedHandles = capture?.data
|
|
420
|
+
? await encodeHandles(capture.data)
|
|
421
|
+
: undefined;
|
|
422
|
+
await store.setItem!(cacheKey, serialized, {
|
|
423
|
+
handles: encodedHandles,
|
|
424
|
+
ttl: profile.ttl,
|
|
425
|
+
swr: profile.swr,
|
|
426
|
+
tags: allTags.length > 0 ? allTags : undefined,
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
} catch (writeError) {
|
|
430
|
+
requestCtx?._reportBackgroundError?.(writeError, "cache-write");
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
await runBackground(requestCtx, cacheWrite, true);
|
|
435
|
+
|
|
436
|
+
return result;
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
// Brand the wrapper so it can be detected at runtime (e.g., to prevent
|
|
440
|
+
// accidental use as middleware).
|
|
441
|
+
(wrapped as any)[CACHED_FN_SYMBOL] = true;
|
|
442
|
+
|
|
443
|
+
return wrapped as unknown as T;
|
|
444
|
+
}
|