@rangojs/router 0.0.0-experimental.0b82333f
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 +899 -0
- 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 +1601 -0
- 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/dist/href-context.d.ts +29 -0
- 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 +5214 -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/dist/vite/package-resolution.js +112 -0
- package/dist/vite/package-resolution.js.map +1 -0
- package/dist/vite/virtual-entries.d.ts +25 -0
- package/dist/vite/virtual-entries.d.ts.map +1 -0
- package/dist/vite/virtual-entries.js +110 -0
- package/dist/vite/virtual-entries.js.map +1 -0
- package/package.json +177 -0
- package/skills/breadcrumbs/SKILL.md +250 -0
- package/skills/cache-guide/SKILL.md +262 -0
- package/skills/caching/SKILL.md +220 -0
- package/skills/composability/SKILL.md +172 -0
- package/skills/debug-manifest/SKILL.md +112 -0
- package/skills/document-cache/SKILL.md +182 -0
- package/skills/fonts/SKILL.md +167 -0
- package/skills/hooks/SKILL.md +704 -0
- package/skills/host-router/SKILL.md +218 -0
- package/skills/intercept/SKILL.md +313 -0
- package/skills/layout/SKILL.md +310 -0
- package/skills/links/SKILL.md +239 -0
- package/skills/loader/SKILL.md +596 -0
- package/skills/middleware/SKILL.md +339 -0
- package/skills/mime-routes/SKILL.md +128 -0
- package/skills/parallel/SKILL.md +305 -0
- package/skills/prerender/SKILL.md +643 -0
- package/skills/rango/SKILL.md +118 -0
- package/skills/response-routes/SKILL.md +411 -0
- package/skills/route/SKILL.md +385 -0
- package/skills/router-setup/SKILL.md +439 -0
- package/skills/tailwind/SKILL.md +129 -0
- package/skills/theme/SKILL.md +79 -0
- package/skills/typesafety/SKILL.md +623 -0
- package/skills/use-cache/SKILL.md +324 -0
- package/src/__internal.ts +273 -0
- package/src/bin/rango.ts +321 -0
- package/src/browser/action-coordinator.ts +97 -0
- package/src/browser/action-response-classifier.ts +99 -0
- package/src/browser/event-controller.ts +899 -0
- package/src/browser/history-state.ts +80 -0
- package/src/browser/index.ts +18 -0
- package/src/browser/intercept-utils.ts +52 -0
- package/src/browser/link-interceptor.ts +141 -0
- package/src/browser/logging.ts +55 -0
- package/src/browser/merge-segment-loaders.ts +134 -0
- package/src/browser/navigation-bridge.ts +640 -0
- package/src/browser/navigation-client.ts +215 -0
- package/src/browser/navigation-store.ts +806 -0
- package/src/browser/navigation-transaction.ts +295 -0
- package/src/browser/network-error-handler.ts +61 -0
- package/src/browser/partial-update.ts +552 -0
- package/src/browser/prefetch/cache.ts +154 -0
- package/src/browser/prefetch/fetch.ts +135 -0
- package/src/browser/prefetch/observer.ts +65 -0
- package/src/browser/prefetch/policy.ts +48 -0
- package/src/browser/prefetch/queue.ts +88 -0
- package/src/browser/rango-state.ts +112 -0
- package/src/browser/react/Link.tsx +360 -0
- package/src/browser/react/NavigationProvider.tsx +386 -0
- package/src/browser/react/ScrollRestoration.tsx +94 -0
- package/src/browser/react/context.ts +59 -0
- package/src/browser/react/filter-segment-order.ts +11 -0
- package/src/browser/react/index.ts +52 -0
- package/src/browser/react/location-state-shared.ts +162 -0
- package/src/browser/react/location-state.ts +107 -0
- package/src/browser/react/mount-context.ts +37 -0
- 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 +218 -0
- package/src/browser/react/use-client-cache.ts +58 -0
- package/src/browser/react/use-handle.ts +162 -0
- package/src/browser/react/use-href.tsx +40 -0
- package/src/browser/react/use-link-status.ts +135 -0
- package/src/browser/react/use-mount.ts +31 -0
- package/src/browser/react/use-navigation.ts +99 -0
- package/src/browser/react/use-params.ts +65 -0
- package/src/browser/react/use-pathname.ts +47 -0
- package/src/browser/react/use-router.ts +63 -0
- package/src/browser/react/use-search-params.ts +56 -0
- package/src/browser/react/use-segments.ts +171 -0
- package/src/browser/response-adapter.ts +73 -0
- package/src/browser/rsc-router.tsx +431 -0
- package/src/browser/scroll-restoration.ts +384 -0
- package/src/browser/segment-reconciler.ts +216 -0
- package/src/browser/segment-structure-assert.ts +83 -0
- package/src/browser/server-action-bridge.ts +667 -0
- package/src/browser/shallow.ts +40 -0
- package/src/browser/types.ts +538 -0
- package/src/browser/validate-redirect-origin.ts +29 -0
- package/src/build/generate-manifest.ts +438 -0
- package/src/build/generate-route-types.ts +36 -0
- package/src/build/index.ts +35 -0
- package/src/build/route-trie.ts +265 -0
- 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 +411 -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 +469 -0
- package/src/build/route-types/scan-filter.ts +78 -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 +338 -0
- package/src/cache/cache-scope.ts +382 -0
- package/src/cache/cf/cf-cache-store.ts +540 -0
- package/src/cache/cf/index.ts +25 -0
- package/src/cache/document-cache.ts +369 -0
- package/src/cache/handle-capture.ts +81 -0
- package/src/cache/handle-snapshot.ts +41 -0
- package/src/cache/index.ts +43 -0
- package/src/cache/memory-segment-store.ts +328 -0
- 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 +98 -0
- package/src/cache/types.ts +342 -0
- package/src/client.rsc.tsx +85 -0
- package/src/client.tsx +601 -0
- package/src/component-utils.ts +76 -0
- package/src/components/DefaultDocument.tsx +27 -0
- package/src/context-var.ts +86 -0
- package/src/debug.ts +243 -0
- package/src/default-error-boundary.tsx +88 -0
- package/src/deps/browser.ts +8 -0
- package/src/deps/html-stream-client.ts +2 -0
- package/src/deps/html-stream-server.ts +2 -0
- package/src/deps/rsc.ts +10 -0
- package/src/deps/ssr.ts +2 -0
- package/src/errors.ts +365 -0
- package/src/handle.ts +135 -0
- package/src/handles/MetaTags.tsx +246 -0
- package/src/handles/breadcrumbs.ts +66 -0
- package/src/handles/index.ts +7 -0
- package/src/handles/meta.ts +264 -0
- package/src/host/cookie-handler.ts +165 -0
- package/src/host/errors.ts +97 -0
- package/src/host/index.ts +53 -0
- package/src/host/pattern-matcher.ts +214 -0
- package/src/host/router.ts +352 -0
- package/src/host/testing.ts +79 -0
- package/src/host/types.ts +146 -0
- package/src/host/utils.ts +25 -0
- package/src/href-client.ts +222 -0
- package/src/index.rsc.ts +233 -0
- package/src/index.ts +277 -0
- package/src/internal-debug.ts +11 -0
- package/src/loader.rsc.ts +89 -0
- package/src/loader.ts +64 -0
- package/src/network-error-thrower.tsx +23 -0
- package/src/outlet-context.ts +15 -0
- package/src/outlet-provider.tsx +45 -0
- package/src/prerender/param-hash.ts +37 -0
- package/src/prerender/store.ts +185 -0
- package/src/prerender.ts +463 -0
- package/src/reverse.ts +330 -0
- package/src/root-error-boundary.tsx +289 -0
- package/src/route-content-wrapper.tsx +196 -0
- package/src/route-definition/dsl-helpers.ts +934 -0
- package/src/route-definition/helper-factories.ts +200 -0
- package/src/route-definition/helpers-types.ts +430 -0
- package/src/route-definition/index.ts +52 -0
- package/src/route-definition/redirect.ts +93 -0
- package/src/route-definition.ts +1 -0
- package/src/route-map-builder.ts +275 -0
- package/src/route-name.ts +53 -0
- package/src/route-types.ts +259 -0
- package/src/router/content-negotiation.ts +116 -0
- package/src/router/debug-manifest.ts +72 -0
- package/src/router/error-handling.ts +287 -0
- package/src/router/find-match.ts +158 -0
- package/src/router/handler-context.ts +451 -0
- package/src/router/intercept-resolution.ts +395 -0
- package/src/router/lazy-includes.ts +234 -0
- package/src/router/loader-resolution.ts +420 -0
- package/src/router/logging.ts +248 -0
- package/src/router/manifest.ts +267 -0
- package/src/router/match-api.ts +620 -0
- package/src/router/match-context.ts +266 -0
- package/src/router/match-handlers.ts +440 -0
- package/src/router/match-middleware/background-revalidation.ts +223 -0
- package/src/router/match-middleware/cache-lookup.ts +634 -0
- package/src/router/match-middleware/cache-store.ts +295 -0
- package/src/router/match-middleware/index.ts +81 -0
- package/src/router/match-middleware/intercept-resolution.ts +306 -0
- package/src/router/match-middleware/segment-resolution.ts +192 -0
- package/src/router/match-pipelines.ts +179 -0
- package/src/router/match-result.ts +219 -0
- package/src/router/metrics.ts +282 -0
- package/src/router/middleware-cookies.ts +55 -0
- package/src/router/middleware-types.ts +222 -0
- package/src/router/middleware.ts +748 -0
- package/src/router/pattern-matching.ts +563 -0
- package/src/router/prerender-match.ts +402 -0
- package/src/router/preview-match.ts +170 -0
- package/src/router/revalidation.ts +289 -0
- package/src/router/router-context.ts +316 -0
- package/src/router/router-interfaces.ts +452 -0
- package/src/router/router-options.ts +592 -0
- package/src/router/router-registry.ts +24 -0
- package/src/router/segment-resolution/fresh.ts +570 -0
- package/src/router/segment-resolution/helpers.ts +263 -0
- package/src/router/segment-resolution/loader-cache.ts +198 -0
- package/src/router/segment-resolution/revalidation.ts +1239 -0
- package/src/router/segment-resolution/static-store.ts +67 -0
- package/src/router/segment-resolution.ts +21 -0
- package/src/router/segment-wrappers.ts +289 -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 +239 -0
- package/src/router/types.ts +170 -0
- package/src/router.ts +1002 -0
- package/src/rsc/handler-context.ts +45 -0
- package/src/rsc/handler.ts +1089 -0
- package/src/rsc/helpers.ts +198 -0
- package/src/rsc/index.ts +36 -0
- package/src/rsc/loader-fetch.ts +209 -0
- package/src/rsc/manifest-init.ts +86 -0
- package/src/rsc/nonce.ts +32 -0
- package/src/rsc/origin-guard.ts +141 -0
- package/src/rsc/progressive-enhancement.ts +379 -0
- package/src/rsc/response-error.ts +37 -0
- package/src/rsc/response-route-handler.ts +347 -0
- package/src/rsc/rsc-rendering.ts +237 -0
- package/src/rsc/runtime-warnings.ts +42 -0
- package/src/rsc/server-action.ts +348 -0
- package/src/rsc/ssr-setup.ts +128 -0
- package/src/rsc/types.ts +263 -0
- package/src/search-params.ts +230 -0
- package/src/segment-system.tsx +454 -0
- package/src/server/context.ts +591 -0
- package/src/server/cookie-store.ts +190 -0
- package/src/server/fetchable-loader-store.ts +37 -0
- package/src/server/handle-store.ts +308 -0
- package/src/server/loader-registry.ts +133 -0
- package/src/server/request-context.ts +914 -0
- package/src/server/root-layout.tsx +10 -0
- package/src/server/tsconfig.json +14 -0
- package/src/server.ts +51 -0
- package/src/ssr/index.tsx +365 -0
- package/src/static-handler.ts +114 -0
- package/src/theme/ThemeProvider.tsx +297 -0
- package/src/theme/ThemeScript.tsx +61 -0
- package/src/theme/constants.ts +62 -0
- package/src/theme/index.ts +48 -0
- package/src/theme/theme-context.ts +44 -0
- package/src/theme/theme-script.ts +155 -0
- package/src/theme/types.ts +182 -0
- package/src/theme/use-theme.ts +44 -0
- 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 +100 -0
- package/src/types/handler-context.ts +687 -0
- package/src/types/index.ts +88 -0
- package/src/types/loader-types.ts +183 -0
- package/src/types/route-config.ts +170 -0
- package/src/types/route-entry.ts +102 -0
- package/src/types/segments.ts +148 -0
- package/src/types.ts +1 -0
- package/src/urls/include-helper.ts +197 -0
- package/src/urls/index.ts +53 -0
- package/src/urls/path-helper-types.ts +339 -0
- package/src/urls/path-helper.ts +329 -0
- package/src/urls/pattern-types.ts +95 -0
- package/src/urls/response-types.ts +106 -0
- package/src/urls/type-extraction.ts +372 -0
- package/src/urls/urls-function.ts +98 -0
- package/src/urls.ts +1 -0
- package/src/use-loader.tsx +354 -0
- package/src/vite/discovery/bundle-postprocess.ts +184 -0
- package/src/vite/discovery/discover-routers.ts +344 -0
- package/src/vite/discovery/prerender-collection.ts +385 -0
- package/src/vite/discovery/route-types-writer.ts +258 -0
- package/src/vite/discovery/self-gen-tracking.ts +47 -0
- package/src/vite/discovery/state.ts +110 -0
- package/src/vite/discovery/virtual-module-codegen.ts +203 -0
- package/src/vite/index.ts +16 -0
- package/src/vite/plugin-types.ts +131 -0
- package/src/vite/plugins/cjs-to-esm.ts +93 -0
- package/src/vite/plugins/client-ref-dedup.ts +115 -0
- package/src/vite/plugins/client-ref-hashing.ts +105 -0
- package/src/vite/plugins/expose-action-id.ts +365 -0
- package/src/vite/plugins/expose-id-utils.ts +287 -0
- package/src/vite/plugins/expose-ids/export-analysis.ts +296 -0
- package/src/vite/plugins/expose-ids/handler-transform.ts +179 -0
- package/src/vite/plugins/expose-ids/loader-transform.ts +74 -0
- package/src/vite/plugins/expose-ids/router-transform.ts +110 -0
- package/src/vite/plugins/expose-ids/types.ts +45 -0
- package/src/vite/plugins/expose-internal-ids.ts +569 -0
- package/src/vite/plugins/refresh-cmd.ts +65 -0
- package/src/vite/plugins/use-cache-transform.ts +323 -0
- package/src/vite/plugins/version-injector.ts +83 -0
- package/src/vite/plugins/version-plugin.ts +254 -0
- package/src/vite/plugins/version.d.ts +12 -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 +510 -0
- package/src/vite/router-discovery.ts +785 -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 +137 -0
- package/src/vite/utils/manifest-utils.ts +70 -0
- package/src/vite/utils/package-resolution.ts +121 -0
- package/src/vite/utils/prerender-utils.ts +189 -0
- package/src/vite/utils/shared-utils.ts +169 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,1479 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { AllUseItems } from "./route-types.js";
|
|
3
|
+
import type { Handle } from "./handle.js";
|
|
4
|
+
import type { MiddlewareFn } from "./router/middleware.js";
|
|
5
|
+
import type { Theme } from "./theme/types.js";
|
|
6
|
+
import type { ScopedReverseFunction } from "./reverse.js";
|
|
7
|
+
import type { SearchSchema, ResolveSearchSchema } from "./search-params.js";
|
|
8
|
+
export type { MiddlewareFn } from "./router/middleware.js";
|
|
9
|
+
/**
|
|
10
|
+
* Props for the Document component that wraps the entire application.
|
|
11
|
+
*/
|
|
12
|
+
export type DocumentProps = {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Global namespace for module augmentation
|
|
17
|
+
*
|
|
18
|
+
* Users can augment this to provide type-safe context globally:
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // In router.tsx or env.d.ts
|
|
23
|
+
* declare global {
|
|
24
|
+
* namespace RSCRouter {
|
|
25
|
+
* interface Env extends RouterEnv<AppBindings, AppVariables> {}
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* // Now all handlers have type-safe context without imports!
|
|
30
|
+
* export default map<typeof shopRoutes>({
|
|
31
|
+
* [middleware('*', 'auth')]: [
|
|
32
|
+
* (ctx, next) => {
|
|
33
|
+
* ctx.set('user', ...) // Type-safe!
|
|
34
|
+
* }
|
|
35
|
+
* ]
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare global {
|
|
40
|
+
namespace RSCRouter {
|
|
41
|
+
interface Env {
|
|
42
|
+
}
|
|
43
|
+
interface RegisteredRoutes {
|
|
44
|
+
}
|
|
45
|
+
interface GeneratedRouteMap {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get registered routes or fallback to generic Record<string, string>
|
|
51
|
+
* When RSCRouter.RegisteredRoutes is augmented, provides autocomplete for route names
|
|
52
|
+
* When not augmented, allows any string (no autocomplete)
|
|
53
|
+
*/
|
|
54
|
+
export type GetRegisteredRoutes = keyof RSCRouter.RegisteredRoutes extends never ? Record<string, string> : RSCRouter.RegisteredRoutes;
|
|
55
|
+
/**
|
|
56
|
+
* Default route map for Handler type.
|
|
57
|
+
* Uses GeneratedRouteMap (from gen file) instead of RegisteredRoutes to avoid
|
|
58
|
+
* circular dependencies: router.tsx -> urls.tsx -> handler.tsx -> RegisteredRoutes -> router.tsx.
|
|
59
|
+
* GeneratedRouteMap is declared in a standalone gen file with no imports.
|
|
60
|
+
*/
|
|
61
|
+
type DefaultHandlerRouteMap = keyof RSCRouter.GeneratedRouteMap extends never ? {} : RSCRouter.GeneratedRouteMap;
|
|
62
|
+
/**
|
|
63
|
+
* Default environment type - uses global augmentation if available, any otherwise
|
|
64
|
+
*/
|
|
65
|
+
export type DefaultEnv = keyof RSCRouter.Env extends never ? any : RSCRouter.Env;
|
|
66
|
+
/**
|
|
67
|
+
* Router environment (Hono-inspired type-safe context)
|
|
68
|
+
*
|
|
69
|
+
* @template TBindings - Platform bindings (DB, KV, secrets, etc.)
|
|
70
|
+
* @template TVariables - Middleware-injected variables (user, permissions, etc.)
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* interface AppBindings {
|
|
75
|
+
* DB: D1Database;
|
|
76
|
+
* KV: KVNamespace;
|
|
77
|
+
* STRIPE_KEY: string;
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
80
|
+
* interface AppVariables {
|
|
81
|
+
* user?: { id: string; name: string };
|
|
82
|
+
* permissions?: string[];
|
|
83
|
+
* }
|
|
84
|
+
*
|
|
85
|
+
* type AppEnv = RouterEnv<AppBindings, AppVariables>;
|
|
86
|
+
* const router = createRouter<AppEnv>();
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export interface RouterEnv<TBindings = {}, TVariables = {}> {
|
|
90
|
+
Bindings: TBindings;
|
|
91
|
+
Variables: TVariables;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Parse constraint values into a union type
|
|
95
|
+
* "a|b|c" → "a" | "b" | "c"
|
|
96
|
+
*/
|
|
97
|
+
type ParseConstraint<T extends string> = T extends `${infer First}|${infer Rest}` ? First | ParseConstraint<Rest> : T;
|
|
98
|
+
/**
|
|
99
|
+
* Extract param info from a param segment
|
|
100
|
+
*
|
|
101
|
+
* Handles:
|
|
102
|
+
* - :param → { name: "param", optional: false, type: string }
|
|
103
|
+
* - :param? → { name: "param", optional: true, type: string }
|
|
104
|
+
* - :param(a|b) → { name: "param", optional: false, type: "a" | "b" }
|
|
105
|
+
* - :param(a|b)? → { name: "param", optional: true, type: "a" | "b" }
|
|
106
|
+
*/
|
|
107
|
+
type ExtractParamInfo<T extends string> = T extends `${infer Name}(${infer Constraint})?` ? {
|
|
108
|
+
name: Name;
|
|
109
|
+
optional: true;
|
|
110
|
+
type: ParseConstraint<Constraint>;
|
|
111
|
+
} : T extends `${infer Name}(${infer Constraint})` ? {
|
|
112
|
+
name: Name;
|
|
113
|
+
optional: false;
|
|
114
|
+
type: ParseConstraint<Constraint>;
|
|
115
|
+
} : T extends `${infer Name}?` ? {
|
|
116
|
+
name: Name;
|
|
117
|
+
optional: true;
|
|
118
|
+
type: string;
|
|
119
|
+
} : {
|
|
120
|
+
name: T;
|
|
121
|
+
optional: false;
|
|
122
|
+
type: string;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Build param object from info
|
|
126
|
+
*/
|
|
127
|
+
type ParamFromInfo<Info> = Info extends {
|
|
128
|
+
name: infer N extends string;
|
|
129
|
+
optional: true;
|
|
130
|
+
type: infer V;
|
|
131
|
+
} ? {
|
|
132
|
+
[K in N]?: V;
|
|
133
|
+
} : Info extends {
|
|
134
|
+
name: infer N extends string;
|
|
135
|
+
optional: false;
|
|
136
|
+
type: infer V;
|
|
137
|
+
} ? {
|
|
138
|
+
[K in N]: V;
|
|
139
|
+
} : never;
|
|
140
|
+
/**
|
|
141
|
+
* Merge two param objects preserving optionality
|
|
142
|
+
* Uses Pick to preserve the modifiers from source types
|
|
143
|
+
*/
|
|
144
|
+
type MergeParams<A, B> = Pick<A, keyof A> & Pick<B, keyof B> extends infer O ? {
|
|
145
|
+
[K in keyof O]: O[K];
|
|
146
|
+
} : never;
|
|
147
|
+
/**
|
|
148
|
+
* Extract route params from a pattern with depth limit to prevent infinite recursion
|
|
149
|
+
*
|
|
150
|
+
* Supports:
|
|
151
|
+
* - Required params: /:slug → { slug: string }
|
|
152
|
+
* - Optional params: /:locale? → { locale?: string }
|
|
153
|
+
* - Constrained params: /:locale(en|gb) → { locale: "en" | "gb" }
|
|
154
|
+
* - Optional + constrained: /:locale(en|gb)? → { locale?: "en" | "gb" }
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ExtractParams<"/products/:id"> // { id: string }
|
|
158
|
+
* ExtractParams<"/:locale?/blog/:slug"> // { locale?: string; slug: string }
|
|
159
|
+
* ExtractParams<"/:locale(en|gb)/blog"> // { locale: "en" | "gb" }
|
|
160
|
+
* ExtractParams<"/:locale(en|gb)?/blog/:slug"> // { locale?: "en" | "gb"; slug: string }
|
|
161
|
+
*/
|
|
162
|
+
export type ExtractParams<T extends string, Depth extends readonly unknown[] = []> = Depth["length"] extends 10 ? {
|
|
163
|
+
[key: string]: string | undefined;
|
|
164
|
+
} : T extends `${infer _Start}:${infer Param}/${infer Rest}` ? MergeParams<ParamFromInfo<ExtractParamInfo<Param>>, ExtractParams<`/${Rest}`, readonly [...Depth, unknown]>> : T extends `${infer _Start}:${infer Param}` ? ParamFromInfo<ExtractParamInfo<Param>> : {};
|
|
165
|
+
/**
|
|
166
|
+
* Route definition - maps route names to patterns
|
|
167
|
+
*/
|
|
168
|
+
/**
|
|
169
|
+
* Trailing slash handling mode
|
|
170
|
+
* - "never": Redirect URLs with trailing slash to without
|
|
171
|
+
* - "always": Redirect URLs without trailing slash to with
|
|
172
|
+
* - "ignore": Match both with and without trailing slash
|
|
173
|
+
*/
|
|
174
|
+
export type TrailingSlashMode = "never" | "always" | "ignore";
|
|
175
|
+
/**
|
|
176
|
+
* Route configuration object (alternative to string path)
|
|
177
|
+
*/
|
|
178
|
+
export type RouteConfig = {
|
|
179
|
+
path: string;
|
|
180
|
+
trailingSlash?: TrailingSlashMode;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Route definition options (global defaults)
|
|
184
|
+
*/
|
|
185
|
+
export type RouteDefinitionOptions = {
|
|
186
|
+
trailingSlash?: TrailingSlashMode;
|
|
187
|
+
};
|
|
188
|
+
export type RouteDefinition = {
|
|
189
|
+
[key: string]: string | RouteConfig | RouteDefinition;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Recursively flatten nested routes with depth limit to prevent infinite recursion
|
|
193
|
+
* Transforms: { products: { detail: "/product/:slug" } } => { "products.detail": "/product/:slug" }
|
|
194
|
+
* Also handles RouteConfig objects: { api: { path: "/api" } } => { "api": "/api" }
|
|
195
|
+
*/
|
|
196
|
+
type FlattenRoutes<T extends RouteDefinition, Prefix extends string = "", Depth extends readonly unknown[] = []> = Depth["length"] extends 5 ? never : {
|
|
197
|
+
[K in keyof T]: T[K] extends string ? Record<`${Prefix}${K & string}`, T[K]> : T[K] extends RouteConfig ? Record<`${Prefix}${K & string}`, T[K]["path"]> : T[K] extends RouteDefinition ? FlattenRoutes<T[K], `${Prefix}${K & string}.`, readonly [...Depth, unknown]> : never;
|
|
198
|
+
}[keyof T];
|
|
199
|
+
/**
|
|
200
|
+
* Union to intersection helper
|
|
201
|
+
*/
|
|
202
|
+
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
203
|
+
/**
|
|
204
|
+
* Resolved route map - flattened route definitions with full paths
|
|
205
|
+
*/
|
|
206
|
+
export type ResolvedRouteMap<T extends RouteDefinition> = UnionToIntersection<FlattenRoutes<T>>;
|
|
207
|
+
/**
|
|
208
|
+
* Handler function that receives context and returns React content or a Response
|
|
209
|
+
*
|
|
210
|
+
* @template T - Params object OR path pattern string
|
|
211
|
+
* @template TEnv - Environment type
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* // With explicit params object
|
|
216
|
+
* const handler: Handler<{ id: string }> = (ctx) => {
|
|
217
|
+
* ctx.params.id // string
|
|
218
|
+
* }
|
|
219
|
+
*
|
|
220
|
+
* // With path pattern - params extracted automatically
|
|
221
|
+
* const handler: Handler<"/product/:id"> = (ctx) => {
|
|
222
|
+
* ctx.params.id // string
|
|
223
|
+
* }
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
/**
|
|
227
|
+
* Create a scoped view of a route map by stripping a name prefix.
|
|
228
|
+
* Useful for handlers in modules mounted via include() — use the local
|
|
229
|
+
* route name instead of the fully qualified global name.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* // Given GeneratedRouteMap: { "blog.index": "/blog"; "blog.post": "/blog/:postId"; ... }
|
|
234
|
+
* type BlogRoutes = ScopedRouteMap<"blog">;
|
|
235
|
+
* // Resolves to: { "index": "/blog"; "post": "/blog/:postId" }
|
|
236
|
+
*
|
|
237
|
+
* const handler: Handler<"post", BlogRoutes> = (ctx) => {
|
|
238
|
+
* ctx.params.postId // string
|
|
239
|
+
* };
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
export type ScopedRouteMap<TPrefix extends string, TMap = RSCRouter.GeneratedRouteMap> = {
|
|
243
|
+
[K in keyof TMap as K extends `${TPrefix}.${infer Rest}` ? Rest : never]: TMap[K];
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Extract the search schema from a route map entry.
|
|
247
|
+
* - string value (old format): no search schema -> {}
|
|
248
|
+
* - { path, search } value: extract search
|
|
249
|
+
* - { path, response } value (no search): -> {}
|
|
250
|
+
*/
|
|
251
|
+
type ExtractSearchFromRouteMap<TRouteMap, T> = T extends keyof TRouteMap ? TRouteMap[T] extends {
|
|
252
|
+
readonly search: infer S extends SearchSchema;
|
|
253
|
+
} ? S : {} : {};
|
|
254
|
+
export type Handler<T extends keyof TRouteMap | (string & {}) | Record<string, any> = {}, TRouteMap extends {} = DefaultHandlerRouteMap, TEnv = DefaultEnv> = (ctx: HandlerContext<T extends keyof TRouteMap ? TRouteMap[T] extends string ? ExtractParams<TRouteMap[T]> : TRouteMap[T] extends {
|
|
255
|
+
readonly path: infer P extends string;
|
|
256
|
+
} ? ExtractParams<P> : T extends string ? ExtractParams<T> : T : T extends string ? ExtractParams<T> : T, TEnv, ExtractSearchFromRouteMap<TRouteMap, T>, TRouteMap extends DefaultHandlerRouteMap ? never : TRouteMap>) => ReactNode | Promise<ReactNode> | Response | Promise<Response>;
|
|
257
|
+
/**
|
|
258
|
+
* Context passed to handlers (Hono-inspired type-safe context)
|
|
259
|
+
*
|
|
260
|
+
* Provides type-safe access to:
|
|
261
|
+
* - Route params (from URL pattern)
|
|
262
|
+
* - Request data (request, searchParams, pathname, url)
|
|
263
|
+
* - Platform bindings (env.DB, env.KV, env.SECRETS)
|
|
264
|
+
* - Middleware variables (var.user, var.permissions)
|
|
265
|
+
* - Getter/setter for variables (get('user'), set('user', ...))
|
|
266
|
+
*
|
|
267
|
+
* **Note:** System parameters (query params starting with `_rsc`) are automatically
|
|
268
|
+
* filtered from `url`, `searchParams`, and `request.url` for cleaner access.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```typescript
|
|
272
|
+
* const handler = (ctx: HandlerContext<{ slug: string }, AppEnv>) => {
|
|
273
|
+
* ctx.params.slug // Route param (string)
|
|
274
|
+
* ctx.env.DB // Binding (D1Database)
|
|
275
|
+
* ctx.var.user // Variable (User | undefined)
|
|
276
|
+
* ctx.get('user') // Alternative getter
|
|
277
|
+
* ctx.set('user', {...}) // Setter
|
|
278
|
+
* ctx.url // Clean URL (no _rsc* params)
|
|
279
|
+
* ctx.searchParams // Clean params (no _rsc* params)
|
|
280
|
+
* }
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
export type HandlerContext<TParams = {}, TEnv = DefaultEnv, TSearch extends SearchSchema = {}, TRouteMap = never> = {
|
|
284
|
+
/**
|
|
285
|
+
* Route parameters extracted from the URL pattern.
|
|
286
|
+
* Type-safe when using Handler<"/path/:param"> or Handler<{ param: string }>.
|
|
287
|
+
*/
|
|
288
|
+
params: TParams;
|
|
289
|
+
/** @internal Phantom property for params type invariance. Prevents mounting handlers on wrong routes. */
|
|
290
|
+
readonly _paramCheck?: (params: TParams) => TParams;
|
|
291
|
+
/**
|
|
292
|
+
* The incoming Request object.
|
|
293
|
+
* System params (`_rsc*`) are filtered from the URL for cleaner access.
|
|
294
|
+
*/
|
|
295
|
+
request: Request;
|
|
296
|
+
/**
|
|
297
|
+
* Query parameters from the URL (system params like `_rsc*` are filtered).
|
|
298
|
+
*
|
|
299
|
+
* When a route defines a `search` schema, this is a typed object with
|
|
300
|
+
* parsed values. Otherwise it is the standard URLSearchParams.
|
|
301
|
+
*/
|
|
302
|
+
searchParams: {} extends TSearch ? URLSearchParams : ResolveSearchSchema<TSearch>;
|
|
303
|
+
/**
|
|
304
|
+
* The pathname portion of the request URL.
|
|
305
|
+
*/
|
|
306
|
+
pathname: string;
|
|
307
|
+
/**
|
|
308
|
+
* The full URL object (with system params filtered).
|
|
309
|
+
*/
|
|
310
|
+
url: URL;
|
|
311
|
+
/**
|
|
312
|
+
* Platform bindings (DB, KV, secrets, etc.) from RouterEnv.
|
|
313
|
+
* Access resources like `ctx.env.DB`, `ctx.env.KV`.
|
|
314
|
+
*/
|
|
315
|
+
env: TEnv extends RouterEnv<infer B, any> ? B : {};
|
|
316
|
+
/**
|
|
317
|
+
* Middleware-injected variables from RouterEnv.
|
|
318
|
+
* Access values like `ctx.var.user`, `ctx.var.permissions`.
|
|
319
|
+
*/
|
|
320
|
+
var: TEnv extends RouterEnv<any, infer V> ? V : {};
|
|
321
|
+
/**
|
|
322
|
+
* Type-safe getter for middleware variables.
|
|
323
|
+
* Alternative to `ctx.var.key` with better autocomplete.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```typescript
|
|
327
|
+
* const user = ctx.get("user"); // Type-safe!
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
get: TEnv extends RouterEnv<any, infer V> ? <K extends keyof V>(key: K) => V[K] : (key: string) => any;
|
|
331
|
+
/**
|
|
332
|
+
* Type-safe setter for middleware variables.
|
|
333
|
+
* Use in middleware to pass data to handlers.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```typescript
|
|
337
|
+
* ctx.set("user", { id: "123", name: "John" }); // Type-safe!
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
set: TEnv extends RouterEnv<any, infer V> ? <K extends keyof V>(key: K, value: V[K]) => void : (key: string, value: any) => void;
|
|
341
|
+
/**
|
|
342
|
+
* Stub response for setting headers/cookies.
|
|
343
|
+
* Headers set here are merged into the final response.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* route("product", (ctx) => {
|
|
348
|
+
* ctx.res.headers.set("Cache-Control", "s-maxage=60");
|
|
349
|
+
* return <ProductPage />;
|
|
350
|
+
* });
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
res: Response;
|
|
354
|
+
/**
|
|
355
|
+
* Shorthand for ctx.res.headers - response headers.
|
|
356
|
+
* Headers set here are merged into the final response.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* route("product", (ctx) => {
|
|
361
|
+
* ctx.headers.set("Cache-Control", "s-maxage=60");
|
|
362
|
+
* return <ProductPage />;
|
|
363
|
+
* });
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
headers: Headers;
|
|
367
|
+
/**
|
|
368
|
+
* Access loader data or push handle data.
|
|
369
|
+
*
|
|
370
|
+
* For loaders: Returns a promise that resolves to the loader data.
|
|
371
|
+
* Loaders are executed in parallel and memoized per request.
|
|
372
|
+
*
|
|
373
|
+
* For handles: Returns a push function to add data for this segment.
|
|
374
|
+
* Handle data accumulates across all matched route segments.
|
|
375
|
+
* Push accepts: direct value, Promise, or async callback (executed immediately).
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```typescript
|
|
379
|
+
* // Loader usage
|
|
380
|
+
* route("cart", async (ctx) => {
|
|
381
|
+
* const cart = await ctx.use(CartLoader);
|
|
382
|
+
* return <CartPage cart={cart} />;
|
|
383
|
+
* });
|
|
384
|
+
*
|
|
385
|
+
* // Handle usage - direct value
|
|
386
|
+
* route("shop", (ctx) => {
|
|
387
|
+
* const push = ctx.use(Breadcrumbs);
|
|
388
|
+
* push({ label: "Shop", href: "/shop" });
|
|
389
|
+
* return <ShopPage />;
|
|
390
|
+
* });
|
|
391
|
+
*
|
|
392
|
+
* // Handle usage - Promise
|
|
393
|
+
* route("product", (ctx) => {
|
|
394
|
+
* const push = ctx.use(Breadcrumbs);
|
|
395
|
+
* push(fetchProductBreadcrumb(ctx.params.id));
|
|
396
|
+
* return <ProductPage />;
|
|
397
|
+
* });
|
|
398
|
+
*
|
|
399
|
+
* // Handle usage - async callback (executed immediately)
|
|
400
|
+
* route("product", (ctx) => {
|
|
401
|
+
* const push = ctx.use(Breadcrumbs);
|
|
402
|
+
* push(async () => {
|
|
403
|
+
* const product = await db.getProduct(ctx.params.id);
|
|
404
|
+
* return { label: product.name, href: `/product/${product.id}` };
|
|
405
|
+
* });
|
|
406
|
+
* return <ProductPage />;
|
|
407
|
+
* });
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
use: {
|
|
411
|
+
<T, TLoaderParams = any>(loader: LoaderDefinition<T, TLoaderParams>): Promise<T>;
|
|
412
|
+
<TData, TAccumulated = TData[]>(handle: Handle<TData, TAccumulated>): (data: TData | Promise<TData> | (() => Promise<TData>)) => void;
|
|
413
|
+
};
|
|
414
|
+
/**
|
|
415
|
+
* Current theme (from cookie or default).
|
|
416
|
+
* Only available when theme is enabled in router config.
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```typescript
|
|
420
|
+
* route("settings", (ctx) => {
|
|
421
|
+
* const currentTheme = ctx.theme; // "light" | "dark" | "system" | undefined
|
|
422
|
+
* return <SettingsPage theme={currentTheme} />;
|
|
423
|
+
* });
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
theme?: Theme;
|
|
427
|
+
/**
|
|
428
|
+
* Set the theme (only available when theme is enabled in router config).
|
|
429
|
+
* Sets a cookie with the new theme value.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```typescript
|
|
433
|
+
* route("settings", async (ctx) => {
|
|
434
|
+
* if (ctx.request.method === "POST") {
|
|
435
|
+
* const formData = await ctx.request.formData();
|
|
436
|
+
* const newTheme = formData.get("theme") as Theme;
|
|
437
|
+
* ctx.setTheme?.(newTheme);
|
|
438
|
+
* }
|
|
439
|
+
* return <SettingsPage />;
|
|
440
|
+
* });
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
setTheme?: (theme: Theme) => void;
|
|
444
|
+
/**
|
|
445
|
+
* Generate URLs from route names (Django-style URL reversal).
|
|
446
|
+
*
|
|
447
|
+
* **Recommended: Use route names for type safety.**
|
|
448
|
+
* Route names validate both the route exists and params are correct.
|
|
449
|
+
* Path-based URLs (`/...`) are an escape hatch with no validation.
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```typescript
|
|
453
|
+
* // RECOMMENDED: Use route names for type safety
|
|
454
|
+
* ctx.reverse("shop.cart") // ✓ Validates route exists
|
|
455
|
+
* ctx.reverse("blog.post", { slug: "hello" }) // ✓ Validates route + params
|
|
456
|
+
*
|
|
457
|
+
* // ESCAPE HATCH: Path-based URLs (no validation)
|
|
458
|
+
* ctx.reverse("/about") // ⚠ No type checking
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
reverse: [TRouteMap] extends [never] ? ScopedReverseFunction<GetRegisteredRoutes> : ScopedReverseFunction<TRouteMap & GetRegisteredRoutes>;
|
|
462
|
+
};
|
|
463
|
+
/**
|
|
464
|
+
* Internal handler context with additional props for router internals.
|
|
465
|
+
* Use `HandlerContext` for user-facing code.
|
|
466
|
+
* @internal
|
|
467
|
+
*/
|
|
468
|
+
export type InternalHandlerContext<TParams = {}, TEnv = DefaultEnv, TSearch extends SearchSchema = {}> = HandlerContext<TParams, TEnv, TSearch> & {
|
|
469
|
+
/** Raw request with all system parameters intact. */
|
|
470
|
+
_originalRequest: Request;
|
|
471
|
+
/** Current segment ID for handle data attribution. */
|
|
472
|
+
_currentSegmentId?: string;
|
|
473
|
+
};
|
|
474
|
+
/**
|
|
475
|
+
* Generic params type - flexible object with string keys
|
|
476
|
+
* Users can narrow this by explicitly typing their params:
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```typescript
|
|
480
|
+
* [revalidate('post')]: (({ currentParams, nextParams }: RevalidateParams<{ slug: string }>) => {
|
|
481
|
+
* currentParams.slug // typed as string
|
|
482
|
+
* return currentParams.slug !== nextParams.slug;
|
|
483
|
+
* })
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
export type GenericParams = {
|
|
487
|
+
[key: string]: string | undefined;
|
|
488
|
+
};
|
|
489
|
+
/**
|
|
490
|
+
* Helper type for revalidation handler params
|
|
491
|
+
* Allows inline type annotation for stricter param typing
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```typescript
|
|
495
|
+
* [revalidate('post')]: (params: RevalidateParams<{ slug: string }>) => {
|
|
496
|
+
* params.currentParams.slug // typed as string
|
|
497
|
+
* return params.defaultShouldRevalidate;
|
|
498
|
+
* }
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
export type RevalidateParams<TParams = GenericParams, TEnv = any> = Parameters<ShouldRevalidateFn<TParams, TEnv>>[0];
|
|
502
|
+
/**
|
|
503
|
+
* Should revalidate function signature (inspired by React Router)
|
|
504
|
+
*
|
|
505
|
+
* Determines whether a route segment should re-render during partial navigation.
|
|
506
|
+
* Multiple revalidation functions can be defined per route - they execute in order.
|
|
507
|
+
*
|
|
508
|
+
* **Return Types:**
|
|
509
|
+
* - `boolean` - Hard decision: immediately returns this value (short-circuits)
|
|
510
|
+
* - `{ defaultShouldRevalidate: boolean }` - Soft decision: updates suggestion for next revalidator
|
|
511
|
+
*
|
|
512
|
+
* **Execution Flow:**
|
|
513
|
+
* 1. Start with built-in `defaultShouldRevalidate` (true if params changed)
|
|
514
|
+
* 2. Execute global revalidators first, then route-specific
|
|
515
|
+
* 3. Hard decision (boolean): stop immediately and use that value
|
|
516
|
+
* 4. Soft decision (object): update suggestion and continue to next revalidator
|
|
517
|
+
* 5. If all return soft decisions: use the final suggestion
|
|
518
|
+
*
|
|
519
|
+
* @param args.currentParams - Previous route params (generic by default, can be narrowed)
|
|
520
|
+
* @param args.currentUrl - Previous URL
|
|
521
|
+
* @param args.nextParams - Next route params (generic by default, can be narrowed)
|
|
522
|
+
* @param args.nextUrl - Next URL
|
|
523
|
+
* @param args.defaultShouldRevalidate - Current suggestion (updated by soft decisions)
|
|
524
|
+
* @param args.context - App context (db, user, etc.)
|
|
525
|
+
* @param args.actionResult - Result from action (future support)
|
|
526
|
+
* @param args.formData - Form data from action (future support)
|
|
527
|
+
* @param args.formMethod - HTTP method from action (future support)
|
|
528
|
+
*
|
|
529
|
+
* @returns Hard decision (boolean) or soft suggestion (object)
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* ```typescript
|
|
533
|
+
* // Hard decision - definitive answer
|
|
534
|
+
* [revalidate('post')]: ({ currentParams, nextParams }) => {
|
|
535
|
+
* return currentParams.slug !== nextParams.slug; // boolean - short-circuits
|
|
536
|
+
* }
|
|
537
|
+
*
|
|
538
|
+
* // Soft decision - allows downstream revalidators to override
|
|
539
|
+
* [revalidate('*', 'global')]: ({ defaultShouldRevalidate }) => {
|
|
540
|
+
* return { defaultShouldRevalidate: true }; // object - continues to next
|
|
541
|
+
* }
|
|
542
|
+
*
|
|
543
|
+
* // Explicit typing for stricter params
|
|
544
|
+
* [revalidate('post')]: ((params: RevalidateParams<{ slug: string }>) => {
|
|
545
|
+
* return params.currentParams.slug !== params.nextParams.slug;
|
|
546
|
+
* })
|
|
547
|
+
* ```
|
|
548
|
+
*/
|
|
549
|
+
export type ShouldRevalidateFn<TParams = GenericParams, TEnv = any> = (args: {
|
|
550
|
+
currentParams: TParams;
|
|
551
|
+
currentUrl: URL;
|
|
552
|
+
nextParams: TParams;
|
|
553
|
+
nextUrl: URL;
|
|
554
|
+
defaultShouldRevalidate: boolean;
|
|
555
|
+
context: HandlerContext<TParams, TEnv>;
|
|
556
|
+
segmentType: "layout" | "route" | "parallel";
|
|
557
|
+
layoutName?: string;
|
|
558
|
+
slotName?: string;
|
|
559
|
+
actionId?: string;
|
|
560
|
+
actionUrl?: URL;
|
|
561
|
+
actionResult?: any;
|
|
562
|
+
formData?: FormData;
|
|
563
|
+
method?: string;
|
|
564
|
+
routeName?: string;
|
|
565
|
+
stale?: boolean;
|
|
566
|
+
}) => boolean | {
|
|
567
|
+
defaultShouldRevalidate: boolean;
|
|
568
|
+
};
|
|
569
|
+
/**
|
|
570
|
+
* Middleware function signature
|
|
571
|
+
*
|
|
572
|
+
* Middleware can either call `next()` to continue the pipeline,
|
|
573
|
+
* or return a Response to short-circuit and skip remaining middleware + handler.
|
|
574
|
+
*
|
|
575
|
+
* **Short-Circuit Patterns:**
|
|
576
|
+
* - `return redirect('/login')` - Soft redirect (SPA navigation)
|
|
577
|
+
* - `return Response.redirect('/login', 302)` - Hard redirect (full page reload)
|
|
578
|
+
* - `return new Response('Unauthorized', { status: 401 })` - Error response
|
|
579
|
+
*
|
|
580
|
+
* @param TParams - Route params (defaults to GenericParams, can be narrowed with satisfies)
|
|
581
|
+
* @param TEnv - Environment type
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* ```typescript
|
|
585
|
+
* [middleware('checkout.*', 'auth')]: [
|
|
586
|
+
* (ctx, next) => {
|
|
587
|
+
* if (!ctx.get('user')) {
|
|
588
|
+
* return redirect('/login'); // Soft redirect - short-circuit
|
|
589
|
+
* }
|
|
590
|
+
* next(); // Continue pipeline
|
|
591
|
+
* }
|
|
592
|
+
* ]
|
|
593
|
+
* ```
|
|
594
|
+
*/
|
|
595
|
+
/**
|
|
596
|
+
* Extract all route keys from a route definition (includes flattened nested routes)
|
|
597
|
+
*/
|
|
598
|
+
export type RouteKeys<T extends RouteDefinition> = keyof ResolvedRouteMap<T> & string;
|
|
599
|
+
/**
|
|
600
|
+
* Valid layout value - component or handler function
|
|
601
|
+
* Note: Arrays are not supported. Use separate layout() declarations with unique names instead.
|
|
602
|
+
*/
|
|
603
|
+
type LayoutValue<TEnv = any> = ReactNode | Handler<any, any, TEnv>;
|
|
604
|
+
/**
|
|
605
|
+
* Helper to extract params from a route key using the resolved (flattened) route map
|
|
606
|
+
*/
|
|
607
|
+
export type ExtractRouteParams<T extends RouteDefinition, K extends string> = K extends keyof ResolvedRouteMap<T> ? ResolvedRouteMap<T>[K] extends string ? ExtractParams<ResolvedRouteMap<T>[K]> : GenericParams : GenericParams;
|
|
608
|
+
/**
|
|
609
|
+
* Handlers object that maps route names to handler functions with type-safe string patterns
|
|
610
|
+
*/
|
|
611
|
+
export type HandlersForRouteMap<T extends RouteDefinition, TEnv = any> = {
|
|
612
|
+
[K in RouteKeys<T>]?: Handler<ExtractRouteParams<T, K & string>, any, TEnv>;
|
|
613
|
+
} & {
|
|
614
|
+
[K in `$layout.${RouteKeys<T> | "*"}.${string}`]?: LayoutValue<TEnv>;
|
|
615
|
+
} & {
|
|
616
|
+
[K in `$parallel.${RouteKeys<T>}.${string}`]?: Record<`@${string}`, Handler<K extends `$parallel.${infer RouteKey}.${string}` ? RouteKey extends RouteKeys<T> ? ExtractRouteParams<T, RouteKey & string> : GenericParams : GenericParams, any, TEnv>>;
|
|
617
|
+
} & {
|
|
618
|
+
[K in `$parallel.${"*"}.${string}`]?: Record<`@${string}`, Handler<GenericParams, any, TEnv>>;
|
|
619
|
+
} & {
|
|
620
|
+
[K in `$middleware.${RouteKeys<T> | "*"}.${string}`]?: MiddlewareFn<TEnv, GenericParams>[];
|
|
621
|
+
} & {
|
|
622
|
+
[K in `$revalidate.route.${RouteKeys<T> | "*"}.${string}`]?: ShouldRevalidateFn<GenericParams, TEnv>;
|
|
623
|
+
} & {
|
|
624
|
+
[K in `$revalidate.layout.${RouteKeys<T> | "*"}.${string}.${string}`]?: ShouldRevalidateFn<GenericParams, TEnv>;
|
|
625
|
+
} & {
|
|
626
|
+
[K in `$revalidate.parallel.${RouteKeys<T> | "*"}.${string}.${string}.${string}`]?: ShouldRevalidateFn<GenericParams, TEnv>;
|
|
627
|
+
};
|
|
628
|
+
/**
|
|
629
|
+
* Error information passed to error boundary fallback components
|
|
630
|
+
*/
|
|
631
|
+
export interface ErrorInfo {
|
|
632
|
+
/** Error message (always available) */
|
|
633
|
+
message: string;
|
|
634
|
+
/** Error name/type (e.g., "RouteNotFoundError", "MiddlewareError") */
|
|
635
|
+
name: string;
|
|
636
|
+
/** Optional error code for programmatic handling */
|
|
637
|
+
code?: string;
|
|
638
|
+
/** Stack trace (only in development) */
|
|
639
|
+
stack?: string;
|
|
640
|
+
/** Original error cause if available */
|
|
641
|
+
cause?: unknown;
|
|
642
|
+
/** Segment ID where the error occurred */
|
|
643
|
+
segmentId: string;
|
|
644
|
+
/** Segment type where the error occurred */
|
|
645
|
+
segmentType: "layout" | "route" | "parallel" | "loader" | "middleware" | "cache";
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Props passed to server-side error boundary fallback components
|
|
649
|
+
*
|
|
650
|
+
* Server error boundaries don't have a reset function since the error
|
|
651
|
+
* occurred during server rendering. Users can navigate away or refresh.
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
* ```typescript
|
|
655
|
+
* function ProductErrorFallback({ error }: ErrorBoundaryFallbackProps) {
|
|
656
|
+
* return (
|
|
657
|
+
* <div>
|
|
658
|
+
* <h2>Something went wrong loading the product</h2>
|
|
659
|
+
* <p>{error.message}</p>
|
|
660
|
+
* <a href="/">Go home</a>
|
|
661
|
+
* </div>
|
|
662
|
+
* );
|
|
663
|
+
* }
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
export interface ErrorBoundaryFallbackProps {
|
|
667
|
+
/** Error information */
|
|
668
|
+
error: ErrorInfo;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Error boundary handler - receives error info and returns fallback UI
|
|
672
|
+
*/
|
|
673
|
+
export type ErrorBoundaryHandler = (props: ErrorBoundaryFallbackProps) => ReactNode;
|
|
674
|
+
/**
|
|
675
|
+
* Props passed to client-side error boundary fallback components
|
|
676
|
+
*
|
|
677
|
+
* Client error boundaries have a reset function that clears the error state
|
|
678
|
+
* and re-renders the children.
|
|
679
|
+
*
|
|
680
|
+
* @example
|
|
681
|
+
* ```typescript
|
|
682
|
+
* function ClientErrorFallback({ error, reset }: ClientErrorBoundaryFallbackProps) {
|
|
683
|
+
* return (
|
|
684
|
+
* <div>
|
|
685
|
+
* <h2>Something went wrong</h2>
|
|
686
|
+
* <p>{error.message}</p>
|
|
687
|
+
* <button onClick={reset}>Try again</button>
|
|
688
|
+
* </div>
|
|
689
|
+
* );
|
|
690
|
+
* }
|
|
691
|
+
* ```
|
|
692
|
+
*/
|
|
693
|
+
export interface ClientErrorBoundaryFallbackProps {
|
|
694
|
+
/** Error information */
|
|
695
|
+
error: ErrorInfo;
|
|
696
|
+
/** Function to reset error state and retry rendering */
|
|
697
|
+
reset: () => void;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Wrapped loader data result for deferred resolution with error handling.
|
|
701
|
+
* When loaders are deferred to client-side resolution, errors need to be
|
|
702
|
+
* wrapped so the client can handle them appropriately.
|
|
703
|
+
*/
|
|
704
|
+
export type LoaderDataResult<T = unknown> = {
|
|
705
|
+
__loaderResult: true;
|
|
706
|
+
ok: true;
|
|
707
|
+
data: T;
|
|
708
|
+
} | {
|
|
709
|
+
__loaderResult: true;
|
|
710
|
+
ok: false;
|
|
711
|
+
error: ErrorInfo;
|
|
712
|
+
fallback: ReactNode | null;
|
|
713
|
+
};
|
|
714
|
+
/**
|
|
715
|
+
* Type guard to check if a value is a wrapped loader result
|
|
716
|
+
*/
|
|
717
|
+
export declare function isLoaderDataResult(value: unknown): value is LoaderDataResult;
|
|
718
|
+
/**
|
|
719
|
+
* Not found information passed to notFound boundary fallback components
|
|
720
|
+
*/
|
|
721
|
+
export interface NotFoundInfo {
|
|
722
|
+
/** Not found message */
|
|
723
|
+
message: string;
|
|
724
|
+
/** Segment ID where notFound was thrown */
|
|
725
|
+
segmentId: string;
|
|
726
|
+
/** Segment type where notFound was thrown */
|
|
727
|
+
segmentType: "layout" | "route" | "parallel" | "loader" | "middleware" | "cache";
|
|
728
|
+
/** The pathname that triggered the not found */
|
|
729
|
+
pathname?: string;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Props passed to notFound boundary fallback components
|
|
733
|
+
*
|
|
734
|
+
* @example
|
|
735
|
+
* ```typescript
|
|
736
|
+
* function ProductNotFound({ notFound }: NotFoundBoundaryFallbackProps) {
|
|
737
|
+
* return (
|
|
738
|
+
* <div>
|
|
739
|
+
* <h2>Product Not Found</h2>
|
|
740
|
+
* <p>{notFound.message}</p>
|
|
741
|
+
* <a href="/products">Browse all products</a>
|
|
742
|
+
* </div>
|
|
743
|
+
* );
|
|
744
|
+
* }
|
|
745
|
+
* ```
|
|
746
|
+
*/
|
|
747
|
+
export interface NotFoundBoundaryFallbackProps {
|
|
748
|
+
/** Not found information */
|
|
749
|
+
notFound: NotFoundInfo;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* NotFound boundary handler - receives not found info and returns fallback UI
|
|
753
|
+
*/
|
|
754
|
+
export type NotFoundBoundaryHandler = (props: NotFoundBoundaryFallbackProps) => ReactNode;
|
|
755
|
+
/**
|
|
756
|
+
* Resolved segment with component
|
|
757
|
+
*
|
|
758
|
+
* Segment types:
|
|
759
|
+
* - layout: Wraps child content via <Outlet />
|
|
760
|
+
* - route: The leaf content for a URL
|
|
761
|
+
* - parallel: Named slots rendered via <ParallelOutlet name="@slot" />
|
|
762
|
+
* - loader: Data segment (no visual rendering, carries loaderData)
|
|
763
|
+
* - error: Error fallback segment (replaces failed segment with error UI)
|
|
764
|
+
* - notFound: Not found fallback segment (replaces segment when data not found)
|
|
765
|
+
*
|
|
766
|
+
* @internal This type is an implementation detail and may change without notice.
|
|
767
|
+
*/
|
|
768
|
+
export interface ResolvedSegment {
|
|
769
|
+
id: string;
|
|
770
|
+
namespace: string;
|
|
771
|
+
type: "layout" | "route" | "parallel" | "loader" | "error" | "notFound";
|
|
772
|
+
index: number;
|
|
773
|
+
component: ReactNode;
|
|
774
|
+
loading?: ReactNode;
|
|
775
|
+
layout?: ReactNode;
|
|
776
|
+
params?: Record<string, string>;
|
|
777
|
+
slot?: string;
|
|
778
|
+
belongsToRoute?: boolean;
|
|
779
|
+
layoutName?: string;
|
|
780
|
+
parallelName?: string;
|
|
781
|
+
loaderId?: string;
|
|
782
|
+
loaderData?: any;
|
|
783
|
+
loaderDataPromise?: Promise<any[]> | any[];
|
|
784
|
+
loaderIds?: string[];
|
|
785
|
+
error?: ErrorInfo;
|
|
786
|
+
notFoundInfo?: NotFoundInfo;
|
|
787
|
+
mountPath?: string;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Segment metadata (without component)
|
|
791
|
+
*
|
|
792
|
+
* @internal This type is an implementation detail and may change without notice.
|
|
793
|
+
*/
|
|
794
|
+
export interface SegmentMetadata {
|
|
795
|
+
id: string;
|
|
796
|
+
type: "layout" | "route" | "parallel" | "loader" | "error" | "notFound";
|
|
797
|
+
index: number;
|
|
798
|
+
params?: Record<string, string>;
|
|
799
|
+
slot?: string;
|
|
800
|
+
loaderId?: string;
|
|
801
|
+
error?: ErrorInfo;
|
|
802
|
+
notFoundInfo?: NotFoundInfo;
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* State of a named slot (e.g., @modal, @sidebar)
|
|
806
|
+
* Used for intercepting routes where slots render alternative content
|
|
807
|
+
*
|
|
808
|
+
* @internal This type is an implementation detail and may change without notice.
|
|
809
|
+
*/
|
|
810
|
+
export interface SlotState {
|
|
811
|
+
/**
|
|
812
|
+
* Whether the slot is currently active (has content to render)
|
|
813
|
+
*/
|
|
814
|
+
active: boolean;
|
|
815
|
+
/**
|
|
816
|
+
* Segments for this slot when active
|
|
817
|
+
*/
|
|
818
|
+
segments?: ResolvedSegment[];
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Props passed to the root layout component
|
|
822
|
+
*/
|
|
823
|
+
export interface RootLayoutProps {
|
|
824
|
+
children: ReactNode;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Router match result
|
|
828
|
+
*
|
|
829
|
+
* @internal This type is an implementation detail and may change without notice.
|
|
830
|
+
*/
|
|
831
|
+
export interface MatchResult {
|
|
832
|
+
segments: ResolvedSegment[];
|
|
833
|
+
matched: string[];
|
|
834
|
+
diff: string[];
|
|
835
|
+
/**
|
|
836
|
+
* Merged route params from all matched segments
|
|
837
|
+
* Available for use by the handler after route matching
|
|
838
|
+
*/
|
|
839
|
+
params: Record<string, string>;
|
|
840
|
+
/**
|
|
841
|
+
* The matched route name (includes name prefix from include()).
|
|
842
|
+
* Used by ctx.reverse() for local name resolution.
|
|
843
|
+
*/
|
|
844
|
+
routeName?: string;
|
|
845
|
+
/**
|
|
846
|
+
* Server-Timing header value (only present when debugPerformance is enabled)
|
|
847
|
+
* Can be added to response headers for DevTools integration
|
|
848
|
+
*/
|
|
849
|
+
serverTiming?: string;
|
|
850
|
+
/**
|
|
851
|
+
* State of named slots for this route match
|
|
852
|
+
* Key is slot name (e.g., "@modal"), value is slot state
|
|
853
|
+
* Slots are used for intercepting routes during soft navigation
|
|
854
|
+
*/
|
|
855
|
+
slots?: Record<string, SlotState>;
|
|
856
|
+
/**
|
|
857
|
+
* Redirect URL for trailing slash normalization.
|
|
858
|
+
* When set, the RSC handler should return a 308 redirect to this URL
|
|
859
|
+
* instead of rendering the page.
|
|
860
|
+
*/
|
|
861
|
+
redirect?: string;
|
|
862
|
+
/**
|
|
863
|
+
* Route-level middleware collected from the matched entry tree.
|
|
864
|
+
* These run with the same onion-style execution as app-level middleware,
|
|
865
|
+
* wrapping the entire RSC response creation.
|
|
866
|
+
*/
|
|
867
|
+
routeMiddleware?: Array<{
|
|
868
|
+
handler: import("./router/middleware.js").MiddlewareFn;
|
|
869
|
+
params: Record<string, string>;
|
|
870
|
+
}>;
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Context captured for lazy include evaluation
|
|
874
|
+
*/
|
|
875
|
+
export interface LazyIncludeContext {
|
|
876
|
+
urlPrefix: string;
|
|
877
|
+
namePrefix: string | undefined;
|
|
878
|
+
parent: unknown;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Internal route entry stored in router
|
|
882
|
+
*/
|
|
883
|
+
export interface RouteEntry<TEnv = any> {
|
|
884
|
+
prefix: string;
|
|
885
|
+
/**
|
|
886
|
+
* Pre-computed static prefix for fast short-circuit matching.
|
|
887
|
+
* Extracted from prefix at registration time (everything before first param).
|
|
888
|
+
*
|
|
889
|
+
* Examples:
|
|
890
|
+
* - "/api" → staticPrefix = "/api"
|
|
891
|
+
* - "/site/:locale" → staticPrefix = "/site"
|
|
892
|
+
* - "/:locale" → staticPrefix = "" (empty, can't optimize)
|
|
893
|
+
*
|
|
894
|
+
* At runtime: if staticPrefix && !pathname.startsWith(staticPrefix), skip entry.
|
|
895
|
+
*/
|
|
896
|
+
staticPrefix: string;
|
|
897
|
+
/**
|
|
898
|
+
* Route patterns map. For lazy entries, this starts as empty and is
|
|
899
|
+
* populated on first request.
|
|
900
|
+
*/
|
|
901
|
+
routes: ResolvedRouteMap<any>;
|
|
902
|
+
/**
|
|
903
|
+
* Trailing slash config per route key
|
|
904
|
+
* If not specified for a route, defaults to pattern-based detection
|
|
905
|
+
*/
|
|
906
|
+
trailingSlash?: Record<string, TrailingSlashMode>;
|
|
907
|
+
handler: () => Array<AllUseItems> | Promise<{
|
|
908
|
+
default: () => Array<AllUseItems>;
|
|
909
|
+
}> | Promise<() => Array<AllUseItems>>;
|
|
910
|
+
mountIndex: number;
|
|
911
|
+
/**
|
|
912
|
+
* Route keys in this entry that have pre-render handlers.
|
|
913
|
+
* Used by the non-trie match path to set the `pr` flag.
|
|
914
|
+
*/
|
|
915
|
+
prerenderRouteKeys?: Set<string>;
|
|
916
|
+
/**
|
|
917
|
+
* Whether this entry is lazily evaluated.
|
|
918
|
+
* When true, routes are populated on first matching request.
|
|
919
|
+
*/
|
|
920
|
+
lazy?: boolean;
|
|
921
|
+
/**
|
|
922
|
+
* For lazy entries: the UrlPatterns to evaluate
|
|
923
|
+
*/
|
|
924
|
+
lazyPatterns?: unknown;
|
|
925
|
+
/**
|
|
926
|
+
* For lazy entries: captured context at definition time
|
|
927
|
+
*/
|
|
928
|
+
lazyContext?: LazyIncludeContext;
|
|
929
|
+
/**
|
|
930
|
+
* For lazy entries: whether patterns have been evaluated
|
|
931
|
+
*/
|
|
932
|
+
lazyEvaluated?: boolean;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Revalidation function with typed params
|
|
936
|
+
*
|
|
937
|
+
* @template T - Params object
|
|
938
|
+
* @template TEnv - Environment type
|
|
939
|
+
*
|
|
940
|
+
* @example
|
|
941
|
+
* ```typescript
|
|
942
|
+
* const revalidate: Revalidate<{ slug: string }> = ({ currentParams, nextParams }) => {
|
|
943
|
+
* return currentParams.slug !== nextParams.slug;
|
|
944
|
+
* }
|
|
945
|
+
* ```
|
|
946
|
+
*/
|
|
947
|
+
export type Revalidate<T = GenericParams, TEnv = DefaultEnv> = ShouldRevalidateFn<T, TEnv>;
|
|
948
|
+
/**
|
|
949
|
+
* Middleware function with typed params and environment
|
|
950
|
+
*
|
|
951
|
+
* @template TParams - Params object (defaults to generic)
|
|
952
|
+
* @template TEnv - Environment type (defaults to global RSCRouter.Env)
|
|
953
|
+
*
|
|
954
|
+
* Note: Middleware cannot directly use route names for params typing because
|
|
955
|
+
* middleware is defined during router setup, before RegisteredRoutes is populated.
|
|
956
|
+
* Use ExtractParams<"/path/:id"> for typed params from a path pattern.
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* // Basic middleware (uses global RSCRouter.Env via module augmentation)
|
|
961
|
+
* const middleware: Middleware = async (ctx, next) => {
|
|
962
|
+
* ctx.set("user", { id: "123" }); // Type-safe!
|
|
963
|
+
* await next();
|
|
964
|
+
* }
|
|
965
|
+
*
|
|
966
|
+
* // With explicit params (most common)
|
|
967
|
+
* const middleware: Middleware<{ id: string }> = async (ctx, next) => {
|
|
968
|
+
* console.log(ctx.params.id);
|
|
969
|
+
* await next();
|
|
970
|
+
* }
|
|
971
|
+
*
|
|
972
|
+
* // With params from path pattern
|
|
973
|
+
* const middleware: Middleware<ExtractParams<"/products/:id">> = async (ctx, next) => {
|
|
974
|
+
* console.log(ctx.params.id);
|
|
975
|
+
* await next();
|
|
976
|
+
* }
|
|
977
|
+
*
|
|
978
|
+
* // With both params and explicit env
|
|
979
|
+
* const middleware: Middleware<{ id: string }, AppEnv> = async (ctx, next) => {
|
|
980
|
+
* ctx.set("user", { id: ctx.params.id });
|
|
981
|
+
* await next();
|
|
982
|
+
* }
|
|
983
|
+
* ```
|
|
984
|
+
*/
|
|
985
|
+
export type Middleware<TParams = GenericParams, TEnv = DefaultEnv> = MiddlewareFn<TEnv, TParams>;
|
|
986
|
+
/**
|
|
987
|
+
* Context passed to cache condition/key/tags functions.
|
|
988
|
+
*
|
|
989
|
+
* This is a subset of RequestContext that's guaranteed to be available
|
|
990
|
+
* during cache key generation (before middleware runs).
|
|
991
|
+
*
|
|
992
|
+
* Note: While the full RequestContext is passed, middleware-set variables
|
|
993
|
+
* (ctx.var, ctx.get()) may not be populated yet since cache lookup
|
|
994
|
+
* happens before middleware execution.
|
|
995
|
+
*/
|
|
996
|
+
export type { RequestContext as CacheContext } from "./server/request-context.js";
|
|
997
|
+
/**
|
|
998
|
+
* Cache configuration options for cache() DSL
|
|
999
|
+
*
|
|
1000
|
+
* Controls how segments, layouts, and loaders are cached.
|
|
1001
|
+
* Cache configuration inherits down the route tree unless overridden.
|
|
1002
|
+
*
|
|
1003
|
+
* @example
|
|
1004
|
+
* ```typescript
|
|
1005
|
+
* // Basic caching with TTL
|
|
1006
|
+
* cache({ ttl: 60 }, () => [
|
|
1007
|
+
* layout(<BlogLayout />),
|
|
1008
|
+
* route("post/:slug"),
|
|
1009
|
+
* ])
|
|
1010
|
+
*
|
|
1011
|
+
* // With stale-while-revalidate
|
|
1012
|
+
* cache({ ttl: 60, swr: 300 }, () => [
|
|
1013
|
+
* route("product/:id"),
|
|
1014
|
+
* ])
|
|
1015
|
+
*
|
|
1016
|
+
* // Conditional caching
|
|
1017
|
+
* cache({
|
|
1018
|
+
* ttl: 300,
|
|
1019
|
+
* condition: (ctx) => !ctx.request.headers.get('x-preview'),
|
|
1020
|
+
* }, () => [...])
|
|
1021
|
+
*
|
|
1022
|
+
* // Custom cache key
|
|
1023
|
+
* cache({
|
|
1024
|
+
* ttl: 300,
|
|
1025
|
+
* key: (ctx) => `product-${ctx.params.id}-${ctx.searchParams.get('variant')}`,
|
|
1026
|
+
* }, () => [...])
|
|
1027
|
+
*
|
|
1028
|
+
* // With tags for invalidation
|
|
1029
|
+
* cache({
|
|
1030
|
+
* ttl: 300,
|
|
1031
|
+
* tags: (ctx) => [`product:${ctx.params.id}`, 'products'],
|
|
1032
|
+
* }, () => [...])
|
|
1033
|
+
* ```
|
|
1034
|
+
*/
|
|
1035
|
+
export interface CacheOptions<TEnv = unknown> {
|
|
1036
|
+
/**
|
|
1037
|
+
* Time-to-live in seconds.
|
|
1038
|
+
* After this period, cached content is considered stale.
|
|
1039
|
+
*/
|
|
1040
|
+
ttl: number;
|
|
1041
|
+
/**
|
|
1042
|
+
* Stale-while-revalidate window in seconds (after TTL).
|
|
1043
|
+
* During this window, stale content is served immediately while
|
|
1044
|
+
* fresh content is fetched in the background via waitUntil.
|
|
1045
|
+
*
|
|
1046
|
+
* @example
|
|
1047
|
+
* // TTL: 60s, SWR: 300s
|
|
1048
|
+
* // 0-60s: FRESH (serve from cache)
|
|
1049
|
+
* // 60-360s: STALE (serve from cache, revalidate in background)
|
|
1050
|
+
* // 360s+: EXPIRED (cache miss, fetch fresh)
|
|
1051
|
+
*/
|
|
1052
|
+
swr?: number;
|
|
1053
|
+
/**
|
|
1054
|
+
* Override the cache store for this boundary.
|
|
1055
|
+
* When specified, this boundary and its children use this store
|
|
1056
|
+
* instead of the app-level store from handler config.
|
|
1057
|
+
*
|
|
1058
|
+
* Useful for:
|
|
1059
|
+
* - Different backends per route section (memory vs KV vs Redis)
|
|
1060
|
+
* - Loader-specific caching strategies
|
|
1061
|
+
* - Hot data in fast cache, cold data in larger/slower cache
|
|
1062
|
+
*
|
|
1063
|
+
* @example
|
|
1064
|
+
* ```typescript
|
|
1065
|
+
* const kvStore = new CloudflareKVStore(env.CACHE_KV);
|
|
1066
|
+
* const memoryStore = new MemorySegmentCacheStore({ defaults: { ttl: 10 } });
|
|
1067
|
+
*
|
|
1068
|
+
* // Fast memory cache for hot data
|
|
1069
|
+
* cache({ store: memoryStore }, () => [
|
|
1070
|
+
* route("dashboard"),
|
|
1071
|
+
* ])
|
|
1072
|
+
*
|
|
1073
|
+
* // KV for larger, less frequently accessed data
|
|
1074
|
+
* cache({ store: kvStore, ttl: 3600 }, () => [
|
|
1075
|
+
* route("archive/:year"),
|
|
1076
|
+
* ])
|
|
1077
|
+
* ```
|
|
1078
|
+
*/
|
|
1079
|
+
store?: import("./cache/types.js").SegmentCacheStore;
|
|
1080
|
+
/**
|
|
1081
|
+
* Conditional cache read function.
|
|
1082
|
+
* Return false to skip cache for this request (always fetch fresh).
|
|
1083
|
+
*
|
|
1084
|
+
* Has access to full RequestContext including env, request, params, cookies, etc.
|
|
1085
|
+
* Note: Middleware-set variables (ctx.var) may not be populated yet.
|
|
1086
|
+
*
|
|
1087
|
+
* @example
|
|
1088
|
+
* ```typescript
|
|
1089
|
+
* condition: (ctx) => {
|
|
1090
|
+
* // Skip cache for preview mode
|
|
1091
|
+
* if (ctx.request.headers.get('x-preview')) return false;
|
|
1092
|
+
* // Skip cache for authenticated users
|
|
1093
|
+
* if (ctx.request.headers.has('authorization')) return false;
|
|
1094
|
+
* return true;
|
|
1095
|
+
* }
|
|
1096
|
+
* ```
|
|
1097
|
+
*/
|
|
1098
|
+
condition?: (ctx: import("./server/request-context.js").RequestContext<TEnv>) => boolean;
|
|
1099
|
+
/**
|
|
1100
|
+
* Custom cache key function - FULL OVERRIDE.
|
|
1101
|
+
* Bypasses default key generation AND store's keyGenerator.
|
|
1102
|
+
*
|
|
1103
|
+
* Has access to full RequestContext including env, request, params, cookies, etc.
|
|
1104
|
+
* Note: Middleware-set variables (ctx.var) may not be populated yet.
|
|
1105
|
+
*
|
|
1106
|
+
* @example
|
|
1107
|
+
* ```typescript
|
|
1108
|
+
* // Include query params in cache key
|
|
1109
|
+
* key: (ctx) => `product-${ctx.params.id}-${ctx.searchParams.get('variant')}`
|
|
1110
|
+
*
|
|
1111
|
+
* // Include env bindings
|
|
1112
|
+
* key: (ctx) => `${ctx.env.REGION}:product:${ctx.params.id}`
|
|
1113
|
+
*
|
|
1114
|
+
* // Include cookies
|
|
1115
|
+
* key: (ctx) => `${ctx.cookie('locale')}:${ctx.pathname}`
|
|
1116
|
+
* ```
|
|
1117
|
+
*/
|
|
1118
|
+
key?: (ctx: import("./server/request-context.js").RequestContext<TEnv>) => string | Promise<string>;
|
|
1119
|
+
/**
|
|
1120
|
+
* Tags for cache invalidation.
|
|
1121
|
+
* Can be a static array or a function that returns tags.
|
|
1122
|
+
*
|
|
1123
|
+
* @example
|
|
1124
|
+
* ```typescript
|
|
1125
|
+
* // Static tags
|
|
1126
|
+
* tags: ['products', 'catalog']
|
|
1127
|
+
*
|
|
1128
|
+
* // Dynamic tags
|
|
1129
|
+
* tags: (ctx) => [`product:${ctx.params.id}`, 'products']
|
|
1130
|
+
* ```
|
|
1131
|
+
*/
|
|
1132
|
+
tags?: string[] | ((ctx: import("./server/request-context.js").RequestContext<TEnv>) => string[]);
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Partial cache options for cache() DSL.
|
|
1136
|
+
*
|
|
1137
|
+
* When `ttl` is not specified, it will use the default from cache config.
|
|
1138
|
+
* This allows cache() calls to inherit app-level defaults:
|
|
1139
|
+
*
|
|
1140
|
+
* @example
|
|
1141
|
+
* ```typescript
|
|
1142
|
+
* // App-level default (in handler config)
|
|
1143
|
+
* cache: { store: myStore, defaults: { ttl: 60 } }
|
|
1144
|
+
*
|
|
1145
|
+
* // Route-level (inherits ttl from defaults)
|
|
1146
|
+
* cache(() => [
|
|
1147
|
+
* route("products"),
|
|
1148
|
+
* ])
|
|
1149
|
+
*
|
|
1150
|
+
* // Override with explicit ttl
|
|
1151
|
+
* cache({ ttl: 300 }, () => [...])
|
|
1152
|
+
* ```
|
|
1153
|
+
*/
|
|
1154
|
+
export type PartialCacheOptions<TEnv = unknown> = Partial<CacheOptions<TEnv>>;
|
|
1155
|
+
/**
|
|
1156
|
+
* Cache entry configuration stored in EntryData.
|
|
1157
|
+
* Represents the resolved cache config for a segment.
|
|
1158
|
+
*/
|
|
1159
|
+
export interface EntryCacheConfig {
|
|
1160
|
+
/** Cache options (false means caching disabled for this entry) - ttl is optional, uses defaults */
|
|
1161
|
+
options: PartialCacheOptions | false;
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Context passed to loader functions during execution
|
|
1165
|
+
*
|
|
1166
|
+
* Loaders run after middleware but before handlers, so they have access
|
|
1167
|
+
* to middleware-set variables via get().
|
|
1168
|
+
*
|
|
1169
|
+
* @template TParams - Route params type (e.g., { slug: string })
|
|
1170
|
+
* @template TEnv - Environment type for bindings/variables
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```typescript
|
|
1174
|
+
* const CartLoader = createLoader(async (ctx) => {
|
|
1175
|
+
* "use server";
|
|
1176
|
+
* const user = ctx.get("user"); // From auth middleware
|
|
1177
|
+
* return await db.cart.get(user.id);
|
|
1178
|
+
* });
|
|
1179
|
+
*
|
|
1180
|
+
* // With typed params:
|
|
1181
|
+
* const ProductLoader = createLoader<Product, { slug: string }>(async (ctx) => {
|
|
1182
|
+
* "use server";
|
|
1183
|
+
* const { slug } = ctx.params; // slug is typed as string
|
|
1184
|
+
* return await db.products.findBySlug(slug);
|
|
1185
|
+
* });
|
|
1186
|
+
* ```
|
|
1187
|
+
*/
|
|
1188
|
+
export type LoaderContext<TParams = Record<string, string | undefined>, TEnv = DefaultEnv, TBody = unknown, TSearch extends SearchSchema = {}> = {
|
|
1189
|
+
params: TParams;
|
|
1190
|
+
request: Request;
|
|
1191
|
+
searchParams: {} extends TSearch ? URLSearchParams : ResolveSearchSchema<TSearch>;
|
|
1192
|
+
pathname: string;
|
|
1193
|
+
url: URL;
|
|
1194
|
+
env: TEnv extends RouterEnv<infer B, any> ? B : {};
|
|
1195
|
+
var: TEnv extends RouterEnv<any, infer V> ? V : {};
|
|
1196
|
+
get: TEnv extends RouterEnv<any, infer V> ? <K extends keyof V>(key: K) => V[K] : (key: string) => any;
|
|
1197
|
+
/**
|
|
1198
|
+
* Access another loader's data (returns promise since loaders run in parallel)
|
|
1199
|
+
*/
|
|
1200
|
+
use: <T, TLoaderParams = any>(loader: LoaderDefinition<T, TLoaderParams>) => Promise<T>;
|
|
1201
|
+
/**
|
|
1202
|
+
* HTTP method (GET, POST, PUT, PATCH, DELETE)
|
|
1203
|
+
* Available when loader is called via load({ method: "POST", ... })
|
|
1204
|
+
*/
|
|
1205
|
+
method: string;
|
|
1206
|
+
/**
|
|
1207
|
+
* Request body for POST/PUT/PATCH/DELETE requests
|
|
1208
|
+
* Available when loader is called via load({ method: "POST", body: {...} })
|
|
1209
|
+
*/
|
|
1210
|
+
body: TBody | undefined;
|
|
1211
|
+
/**
|
|
1212
|
+
* Form data when loader is invoked via action (fetchable loaders)
|
|
1213
|
+
* Available when loader is called via form submission
|
|
1214
|
+
*/
|
|
1215
|
+
formData?: FormData;
|
|
1216
|
+
};
|
|
1217
|
+
/**
|
|
1218
|
+
* Loader function signature
|
|
1219
|
+
*
|
|
1220
|
+
* @template T - The return type of the loader
|
|
1221
|
+
* @template TParams - Route params type (defaults to generic Record)
|
|
1222
|
+
* @template TEnv - Environment type for bindings/variables
|
|
1223
|
+
*
|
|
1224
|
+
* @example
|
|
1225
|
+
* ```typescript
|
|
1226
|
+
* const myLoader: LoaderFn<{ items: Item[] }> = async (ctx) => {
|
|
1227
|
+
* "use server";
|
|
1228
|
+
* return { items: await db.items.list() };
|
|
1229
|
+
* };
|
|
1230
|
+
*
|
|
1231
|
+
* // With typed params:
|
|
1232
|
+
* const productLoader: LoaderFn<Product, { slug: string }> = async (ctx) => {
|
|
1233
|
+
* "use server";
|
|
1234
|
+
* const { slug } = ctx.params; // typed as string
|
|
1235
|
+
* return await db.products.findBySlug(slug);
|
|
1236
|
+
* };
|
|
1237
|
+
* ```
|
|
1238
|
+
*/
|
|
1239
|
+
export type LoaderFn<T, TParams = Record<string, string | undefined>, TEnv = DefaultEnv> = (ctx: LoaderContext<TParams, TEnv>) => Promise<T> | T;
|
|
1240
|
+
/**
|
|
1241
|
+
* Loader definition object
|
|
1242
|
+
*
|
|
1243
|
+
* Created via createLoader(). Contains the loader name and function.
|
|
1244
|
+
* On client builds, the fn is stripped by the bundler (via "use server" directive).
|
|
1245
|
+
*
|
|
1246
|
+
* @template T - The return type of the loader
|
|
1247
|
+
* @template TParams - Route params type (for type-safe params access)
|
|
1248
|
+
*
|
|
1249
|
+
* @example
|
|
1250
|
+
* ```typescript
|
|
1251
|
+
* // Definition (same file works on server and client)
|
|
1252
|
+
* export const CartLoader = createLoader(async (ctx) => {
|
|
1253
|
+
* "use server";
|
|
1254
|
+
* return await db.cart.get(ctx.get("user").id);
|
|
1255
|
+
* });
|
|
1256
|
+
*
|
|
1257
|
+
* // With typed params:
|
|
1258
|
+
* export const ProductLoader = createLoader<Product, { slug: string }>(async (ctx) => {
|
|
1259
|
+
* "use server";
|
|
1260
|
+
* const { slug } = ctx.params; // slug is typed as string
|
|
1261
|
+
* return await db.products.findBySlug(slug);
|
|
1262
|
+
* });
|
|
1263
|
+
*
|
|
1264
|
+
* // Server usage
|
|
1265
|
+
* const cart = ctx.use(CartLoader);
|
|
1266
|
+
*
|
|
1267
|
+
* // Client usage (fn is stripped, only name remains)
|
|
1268
|
+
* const cart = useLoader(CartLoader);
|
|
1269
|
+
* ```
|
|
1270
|
+
*/
|
|
1271
|
+
/**
|
|
1272
|
+
* Options for fetchable loaders
|
|
1273
|
+
*
|
|
1274
|
+
* Middleware uses the same MiddlewareFn signature as route/app middleware,
|
|
1275
|
+
* enabling reuse of the same middleware functions everywhere.
|
|
1276
|
+
*/
|
|
1277
|
+
export type FetchableLoaderOptions = {
|
|
1278
|
+
fetchable?: true;
|
|
1279
|
+
middleware?: MiddlewareFn[];
|
|
1280
|
+
};
|
|
1281
|
+
/**
|
|
1282
|
+
* Options for load() calls - type-safe union based on method
|
|
1283
|
+
*/
|
|
1284
|
+
export type LoadOptions = {
|
|
1285
|
+
method?: "GET";
|
|
1286
|
+
params?: Record<string, string>;
|
|
1287
|
+
} | {
|
|
1288
|
+
method: "POST" | "PUT" | "PATCH" | "DELETE";
|
|
1289
|
+
params?: Record<string, string>;
|
|
1290
|
+
body?: FormData | Record<string, any>;
|
|
1291
|
+
};
|
|
1292
|
+
/**
|
|
1293
|
+
* Context passed to loader action on server
|
|
1294
|
+
*/
|
|
1295
|
+
export type LoaderActionContext = {
|
|
1296
|
+
method: string;
|
|
1297
|
+
params: Record<string, string>;
|
|
1298
|
+
body?: FormData | Record<string, any>;
|
|
1299
|
+
formData?: FormData;
|
|
1300
|
+
};
|
|
1301
|
+
/**
|
|
1302
|
+
* @deprecated Use MiddlewareFn instead for fetchable loader middleware.
|
|
1303
|
+
* This type is kept for backwards compatibility but will be removed in a future version.
|
|
1304
|
+
*
|
|
1305
|
+
* Fetchable loaders now use the same middleware signature as routes,
|
|
1306
|
+
* enabling middleware reuse across routes and loaders.
|
|
1307
|
+
*/
|
|
1308
|
+
export type LoaderMiddlewareFn = (ctx: LoaderActionContext, next: () => Promise<void>) => Response | Promise<Response> | void | Promise<void>;
|
|
1309
|
+
/**
|
|
1310
|
+
* Loader action function type - server action for form-based fetching
|
|
1311
|
+
* This is a server action that can be passed to useActionState or form action prop.
|
|
1312
|
+
*
|
|
1313
|
+
* The signature (prevState, formData) is required for useActionState compatibility.
|
|
1314
|
+
* When used with useActionState, React passes the previous state as the first argument.
|
|
1315
|
+
*/
|
|
1316
|
+
export type LoaderAction<T> = (prevState: T | null, formData: FormData) => Promise<T>;
|
|
1317
|
+
export type LoaderDefinition<T = any, TParams = Record<string, string | undefined>> = {
|
|
1318
|
+
__brand: "loader";
|
|
1319
|
+
$$id: string;
|
|
1320
|
+
fn?: LoaderFn<T, TParams, any>;
|
|
1321
|
+
action?: LoaderAction<T>;
|
|
1322
|
+
};
|
|
1323
|
+
/**
|
|
1324
|
+
* Phase where the error occurred during request handling.
|
|
1325
|
+
*
|
|
1326
|
+
* Coverage notes:
|
|
1327
|
+
* - "routing": Invoked when route matching fails (router.ts, rsc/handler.ts)
|
|
1328
|
+
* - "manifest": Reserved for manifest loading errors (not currently invoked)
|
|
1329
|
+
* - "middleware": Reserved for middleware execution errors (errors propagate to handler phase)
|
|
1330
|
+
* - "loader": Invoked when loader execution fails (router.ts via wrapLoaderWithErrorHandling, rsc/handler.ts)
|
|
1331
|
+
* - "handler": Invoked when route/layout handler execution fails (router.ts)
|
|
1332
|
+
* - "rendering": Invoked during SSR rendering errors (ssr/index.tsx, separate callback)
|
|
1333
|
+
* - "action": Invoked when server action execution fails (rsc/handler.ts, router.ts)
|
|
1334
|
+
* - "revalidation": Invoked when revalidation fails (router.ts, conditional with action)
|
|
1335
|
+
* - "unknown": Fallback for unclassified errors (not currently invoked)
|
|
1336
|
+
*/
|
|
1337
|
+
export type ErrorPhase = "routing" | "manifest" | "middleware" | "loader" | "handler" | "rendering" | "action" | "revalidation" | "unknown";
|
|
1338
|
+
/**
|
|
1339
|
+
* Comprehensive context passed to onError callback
|
|
1340
|
+
*
|
|
1341
|
+
* Provides all available information about where and when an error occurred
|
|
1342
|
+
* during request handling. The callback can use this for logging, monitoring,
|
|
1343
|
+
* error tracking services, or custom error responses.
|
|
1344
|
+
*
|
|
1345
|
+
* @example
|
|
1346
|
+
* ```typescript
|
|
1347
|
+
* const router = createRouter<AppEnv>({
|
|
1348
|
+
* onError: (context) => {
|
|
1349
|
+
* // Log to error tracking service
|
|
1350
|
+
* errorTracker.capture({
|
|
1351
|
+
* error: context.error,
|
|
1352
|
+
* phase: context.phase,
|
|
1353
|
+
* url: context.request.url,
|
|
1354
|
+
* route: context.routeKey,
|
|
1355
|
+
* userId: context.env?.user?.id,
|
|
1356
|
+
* });
|
|
1357
|
+
*
|
|
1358
|
+
* // Log to console with context
|
|
1359
|
+
* console.error(`[${context.phase}] Error in ${context.routeKey}:`, {
|
|
1360
|
+
* message: context.error.message,
|
|
1361
|
+
* segment: context.segmentId,
|
|
1362
|
+
* duration: context.duration,
|
|
1363
|
+
* });
|
|
1364
|
+
* },
|
|
1365
|
+
* });
|
|
1366
|
+
* ```
|
|
1367
|
+
*/
|
|
1368
|
+
export interface OnErrorContext<TEnv = any> {
|
|
1369
|
+
/**
|
|
1370
|
+
* The error that occurred
|
|
1371
|
+
*/
|
|
1372
|
+
error: Error;
|
|
1373
|
+
/**
|
|
1374
|
+
* Phase where the error occurred
|
|
1375
|
+
*/
|
|
1376
|
+
phase: ErrorPhase;
|
|
1377
|
+
/**
|
|
1378
|
+
* The original request
|
|
1379
|
+
*/
|
|
1380
|
+
request: Request;
|
|
1381
|
+
/**
|
|
1382
|
+
* Parsed URL from the request
|
|
1383
|
+
*/
|
|
1384
|
+
url: URL;
|
|
1385
|
+
/**
|
|
1386
|
+
* Request pathname
|
|
1387
|
+
*/
|
|
1388
|
+
pathname: string;
|
|
1389
|
+
/**
|
|
1390
|
+
* HTTP method
|
|
1391
|
+
*/
|
|
1392
|
+
method: string;
|
|
1393
|
+
/**
|
|
1394
|
+
* Matched route key (if available)
|
|
1395
|
+
* e.g., "shop.products.detail"
|
|
1396
|
+
*/
|
|
1397
|
+
routeKey?: string;
|
|
1398
|
+
/**
|
|
1399
|
+
* Route params (if available)
|
|
1400
|
+
* e.g., { slug: "headphones" }
|
|
1401
|
+
*/
|
|
1402
|
+
params?: Record<string, string>;
|
|
1403
|
+
/**
|
|
1404
|
+
* Segment ID where error occurred (if available)
|
|
1405
|
+
* e.g., "M1L0" for a layout, "M1R0" for a route
|
|
1406
|
+
*/
|
|
1407
|
+
segmentId?: string;
|
|
1408
|
+
/**
|
|
1409
|
+
* Segment type where error occurred (if available)
|
|
1410
|
+
*/
|
|
1411
|
+
segmentType?: "layout" | "route" | "parallel" | "loader" | "middleware";
|
|
1412
|
+
/**
|
|
1413
|
+
* Loader name (if error occurred in a loader)
|
|
1414
|
+
*/
|
|
1415
|
+
loaderName?: string;
|
|
1416
|
+
/**
|
|
1417
|
+
* Middleware name/id (if error occurred in middleware)
|
|
1418
|
+
*/
|
|
1419
|
+
middlewareId?: string;
|
|
1420
|
+
/**
|
|
1421
|
+
* Action ID (if error occurred during server action)
|
|
1422
|
+
* e.g., "src/actions.ts#addToCart"
|
|
1423
|
+
*/
|
|
1424
|
+
actionId?: string;
|
|
1425
|
+
/**
|
|
1426
|
+
* Environment/bindings (platform context)
|
|
1427
|
+
*/
|
|
1428
|
+
env?: TEnv;
|
|
1429
|
+
/**
|
|
1430
|
+
* Duration from request start to error (milliseconds)
|
|
1431
|
+
*/
|
|
1432
|
+
duration?: number;
|
|
1433
|
+
/**
|
|
1434
|
+
* Whether this is a partial/navigation request
|
|
1435
|
+
*/
|
|
1436
|
+
isPartial?: boolean;
|
|
1437
|
+
/**
|
|
1438
|
+
* Whether an error boundary caught the error
|
|
1439
|
+
* If true, the error was handled and a fallback UI was rendered
|
|
1440
|
+
*/
|
|
1441
|
+
handledByBoundary?: boolean;
|
|
1442
|
+
/**
|
|
1443
|
+
* Stack trace (if available)
|
|
1444
|
+
*/
|
|
1445
|
+
stack?: string;
|
|
1446
|
+
/**
|
|
1447
|
+
* Additional metadata specific to the error phase
|
|
1448
|
+
*/
|
|
1449
|
+
metadata?: Record<string, unknown>;
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Callback function for error handling
|
|
1453
|
+
*
|
|
1454
|
+
* Called whenever an error occurs during request handling.
|
|
1455
|
+
* The callback is for notification/logging purposes - it cannot
|
|
1456
|
+
* modify the error handling flow (use errorBoundary for that).
|
|
1457
|
+
*
|
|
1458
|
+
* @param context - Comprehensive error context
|
|
1459
|
+
*
|
|
1460
|
+
* @example
|
|
1461
|
+
* ```typescript
|
|
1462
|
+
* const onError: OnErrorCallback = (context) => {
|
|
1463
|
+
* // Send to error tracking service
|
|
1464
|
+
* Sentry.captureException(context.error, {
|
|
1465
|
+
* tags: {
|
|
1466
|
+
* phase: context.phase,
|
|
1467
|
+
* route: context.routeKey,
|
|
1468
|
+
* },
|
|
1469
|
+
* extra: {
|
|
1470
|
+
* url: context.url.toString(),
|
|
1471
|
+
* params: context.params,
|
|
1472
|
+
* duration: context.duration,
|
|
1473
|
+
* },
|
|
1474
|
+
* });
|
|
1475
|
+
* };
|
|
1476
|
+
* ```
|
|
1477
|
+
*/
|
|
1478
|
+
export type OnErrorCallback<TEnv = any> = (context: OnErrorContext<TEnv>) => void | Promise<void>;
|
|
1479
|
+
//# sourceMappingURL=types.d.ts.map
|