react-router 7.15.1 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +181 -2
- package/dist/development/dom-export.d.ts +6 -172
- package/dist/development/dom-export.js +12 -1007
- package/dist/development/index-react-server-client.d.ts +7 -4
- package/dist/development/index-react-server-client.js +8 -52
- package/dist/development/index-react-server.d.ts +1789 -1657
- package/dist/development/index-react-server.js +3074 -3674
- package/dist/development/index.d.ts +41 -1469
- package/dist/development/index.js +36 -2621
- package/dist/development/lib/actions.js +50 -0
- package/dist/development/lib/components.d.ts +1030 -0
- package/dist/development/lib/components.js +841 -0
- package/dist/development/lib/context.d.ts +83 -0
- package/dist/development/lib/context.js +41 -0
- package/dist/development/lib/dom/dom.d.ts +119 -0
- package/dist/development/lib/dom/dom.js +143 -0
- package/dist/development/lib/dom/lib.d.ts +2054 -0
- package/dist/development/lib/dom/lib.js +1272 -0
- package/dist/development/lib/dom/server.d.ts +138 -0
- package/dist/development/lib/dom/server.js +301 -0
- package/dist/development/lib/dom/ssr/components.d.ts +198 -0
- package/dist/development/lib/dom/ssr/components.js +589 -0
- package/dist/development/lib/dom/ssr/data.js +29 -0
- package/dist/development/lib/dom/ssr/entry.d.ts +60 -0
- package/dist/development/lib/dom/ssr/errorBoundaries.d.ts +27 -0
- package/dist/development/lib/dom/ssr/errorBoundaries.js +87 -0
- package/dist/development/lib/dom/ssr/fallback.js +33 -0
- package/dist/development/lib/dom/ssr/fog-of-war.d.ts +12 -0
- package/dist/development/lib/dom/ssr/fog-of-war.js +185 -0
- package/dist/development/lib/dom/ssr/hydration.d.ts +32 -0
- package/dist/development/lib/dom/ssr/hydration.js +29 -0
- package/dist/development/lib/dom/ssr/invariant.js +16 -0
- package/dist/development/lib/dom/ssr/links.js +170 -0
- package/dist/development/lib/dom/ssr/markup.js +24 -0
- package/dist/development/lib/dom/ssr/routeModules.d.ts +206 -0
- package/dist/development/lib/dom/ssr/routeModules.js +31 -0
- package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +75 -0
- package/dist/development/lib/dom/ssr/routes-test-stub.js +121 -0
- package/dist/development/lib/dom/ssr/routes.d.ts +33 -0
- package/dist/development/lib/dom/ssr/routes.js +303 -0
- package/dist/development/lib/dom/ssr/server.d.ts +48 -0
- package/dist/development/lib/dom/ssr/server.js +69 -0
- package/dist/development/lib/dom/ssr/single-fetch.d.ts +14 -0
- package/dist/development/lib/dom/ssr/single-fetch.js +345 -0
- package/dist/development/lib/dom-export/dom-router-provider.d.ts +9 -0
- package/dist/development/lib/dom-export/dom-router-provider.js +22 -0
- package/dist/development/lib/dom-export/hydrated-router.d.ts +125 -0
- package/dist/development/lib/dom-export/hydrated-router.js +150 -0
- package/dist/development/lib/errors.js +29 -0
- package/dist/development/lib/hooks.d.ts +974 -0
- package/dist/development/lib/hooks.js +1415 -0
- package/dist/development/lib/href.d.ts +36 -0
- package/dist/development/lib/href.js +70 -0
- package/dist/development/lib/router/history.d.ts +264 -0
- package/dist/development/lib/router/history.js +378 -0
- package/dist/development/lib/router/instrumentation.d.ts +111 -0
- package/dist/development/lib/router/instrumentation.js +290 -0
- package/dist/development/lib/router/links.d.ts +114 -0
- package/dist/development/lib/router/router.d.ts +663 -0
- package/dist/development/lib/router/router.js +2988 -0
- package/dist/development/lib/router/url.js +18 -0
- package/dist/development/lib/router/utils.d.ts +960 -0
- package/dist/development/lib/router/utils.js +881 -0
- package/dist/development/lib/rsc/browser.d.ts +137 -0
- package/dist/development/lib/rsc/browser.js +612 -0
- package/dist/development/lib/rsc/errorBoundaries.d.ts +11 -0
- package/dist/development/lib/rsc/errorBoundaries.js +90 -0
- package/dist/development/lib/rsc/html-stream/browser.d.ts +48 -0
- package/dist/development/lib/rsc/html-stream/browser.js +74 -0
- package/dist/development/lib/rsc/html-stream/server.js +97 -0
- package/dist/development/lib/rsc/route-modules.js +27 -0
- package/dist/development/lib/rsc/server.rsc.d.ts +224 -0
- package/dist/development/lib/rsc/server.ssr.d.ts +152 -0
- package/dist/development/lib/rsc/server.ssr.js +419 -0
- package/dist/development/lib/server-runtime/build.d.ts +66 -0
- package/dist/development/lib/server-runtime/cookies.d.ts +92 -0
- package/dist/development/lib/server-runtime/cookies.js +153 -0
- package/dist/development/lib/server-runtime/crypto.js +43 -0
- package/dist/development/lib/server-runtime/data.js +25 -0
- package/dist/development/lib/server-runtime/dev.d.ts +9 -0
- package/dist/development/lib/server-runtime/dev.js +26 -0
- package/dist/development/lib/server-runtime/entry.js +20 -0
- package/dist/development/lib/server-runtime/errors.js +75 -0
- package/dist/development/lib/server-runtime/headers.js +73 -0
- package/dist/development/lib/server-runtime/invariant.js +19 -0
- package/dist/development/lib/server-runtime/mode.d.ts +12 -0
- package/dist/development/lib/server-runtime/mode.js +25 -0
- package/dist/development/lib/server-runtime/routeMatching.js +28 -0
- package/dist/development/lib/server-runtime/routes.d.ts +13 -0
- package/dist/development/lib/server-runtime/routes.js +74 -0
- package/dist/development/lib/server-runtime/server.d.ts +22 -0
- package/dist/development/lib/server-runtime/server.js +364 -0
- package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +33 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +53 -0
- package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +29 -0
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +58 -0
- package/dist/development/lib/server-runtime/sessions.d.ts +174 -0
- package/dist/development/lib/server-runtime/sessions.js +115 -0
- package/dist/development/lib/server-runtime/single-fetch.d.ts +7 -0
- package/dist/development/lib/server-runtime/single-fetch.js +215 -0
- package/dist/development/lib/server-runtime/urls.js +28 -0
- package/dist/development/lib/server-runtime/warnings.js +20 -0
- package/dist/development/lib/types/future.d.ts +9 -0
- package/dist/development/lib/types/internal.d.ts +26 -177
- package/dist/development/lib/types/internal.js +3 -2
- package/dist/{production/register-Bsscfj79.d.ts → development/lib/types/register.d.ts} +9 -15
- package/dist/development/lib/types/route-data.d.ts +113 -0
- package/dist/development/lib/types/route-module-annotations.d.ts +149 -0
- package/dist/development/lib/types/route-module.d.ts +19 -0
- package/dist/development/lib/types/serializes-to.d.ts +13 -0
- package/dist/development/lib/types/utils.d.ts +11 -0
- package/dist/development/vendor/turbo-stream-v2/flatten.js +159 -0
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +179 -0
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +199 -0
- package/dist/development/vendor/turbo-stream-v2/utils.js +39 -0
- package/dist/production/dom-export.d.ts +6 -172
- package/dist/production/dom-export.js +12 -1007
- package/dist/production/index-react-server-client.d.ts +7 -4
- package/dist/production/index-react-server-client.js +8 -52
- package/dist/production/index-react-server.d.ts +1789 -1657
- package/dist/production/index-react-server.js +3065 -3674
- package/dist/production/index.d.ts +41 -1469
- package/dist/production/index.js +36 -2621
- package/dist/production/lib/actions.js +50 -0
- package/dist/production/lib/components.d.ts +1030 -0
- package/dist/production/lib/components.js +841 -0
- package/dist/production/lib/context.d.ts +83 -0
- package/dist/production/lib/context.js +41 -0
- package/dist/production/lib/dom/dom.d.ts +119 -0
- package/dist/production/lib/dom/dom.js +143 -0
- package/dist/production/lib/dom/lib.d.ts +2054 -0
- package/dist/production/lib/dom/lib.js +1272 -0
- package/dist/production/lib/dom/server.d.ts +138 -0
- package/dist/production/lib/dom/server.js +301 -0
- package/dist/production/lib/dom/ssr/components.d.ts +198 -0
- package/dist/production/lib/dom/ssr/components.js +589 -0
- package/dist/production/lib/dom/ssr/data.js +29 -0
- package/dist/production/lib/dom/ssr/entry.d.ts +60 -0
- package/dist/production/lib/dom/ssr/errorBoundaries.d.ts +27 -0
- package/dist/production/lib/dom/ssr/errorBoundaries.js +87 -0
- package/dist/production/lib/dom/ssr/fallback.js +23 -0
- package/dist/production/lib/dom/ssr/fog-of-war.d.ts +12 -0
- package/dist/production/lib/dom/ssr/fog-of-war.js +185 -0
- package/dist/production/lib/dom/ssr/hydration.d.ts +32 -0
- package/dist/production/lib/dom/ssr/hydration.js +29 -0
- package/dist/production/lib/dom/ssr/invariant.js +16 -0
- package/dist/production/lib/dom/ssr/links.js +170 -0
- package/dist/production/lib/dom/ssr/markup.js +24 -0
- package/dist/production/lib/dom/ssr/routeModules.d.ts +206 -0
- package/dist/production/lib/dom/ssr/routeModules.js +31 -0
- package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +75 -0
- package/dist/production/lib/dom/ssr/routes-test-stub.js +121 -0
- package/dist/production/lib/dom/ssr/routes.d.ts +33 -0
- package/dist/production/lib/dom/ssr/routes.js +303 -0
- package/dist/production/lib/dom/ssr/server.d.ts +48 -0
- package/dist/production/lib/dom/ssr/server.js +69 -0
- package/dist/production/lib/dom/ssr/single-fetch.d.ts +14 -0
- package/dist/production/lib/dom/ssr/single-fetch.js +345 -0
- package/dist/production/lib/dom-export/dom-router-provider.d.ts +9 -0
- package/dist/production/lib/dom-export/dom-router-provider.js +22 -0
- package/dist/production/lib/dom-export/hydrated-router.d.ts +125 -0
- package/dist/production/lib/dom-export/hydrated-router.js +150 -0
- package/dist/production/lib/errors.js +29 -0
- package/dist/production/lib/hooks.d.ts +974 -0
- package/dist/production/lib/hooks.js +1400 -0
- package/dist/production/lib/href.d.ts +36 -0
- package/dist/production/lib/href.js +70 -0
- package/dist/production/lib/router/history.d.ts +264 -0
- package/dist/production/lib/router/history.js +378 -0
- package/dist/production/lib/router/instrumentation.d.ts +111 -0
- package/dist/production/lib/router/instrumentation.js +290 -0
- package/dist/production/lib/router/links.d.ts +114 -0
- package/dist/production/lib/router/router.d.ts +663 -0
- package/dist/production/lib/router/router.js +2988 -0
- package/dist/production/lib/router/url.js +18 -0
- package/dist/production/lib/router/utils.d.ts +960 -0
- package/dist/production/lib/router/utils.js +872 -0
- package/dist/production/lib/rsc/browser.d.ts +137 -0
- package/dist/production/lib/rsc/browser.js +612 -0
- package/dist/production/lib/rsc/errorBoundaries.d.ts +11 -0
- package/dist/production/lib/rsc/errorBoundaries.js +90 -0
- package/dist/production/lib/rsc/html-stream/browser.d.ts +48 -0
- package/dist/production/lib/rsc/html-stream/browser.js +74 -0
- package/dist/production/lib/rsc/html-stream/server.js +97 -0
- package/dist/production/lib/rsc/route-modules.js +27 -0
- package/dist/production/lib/rsc/server.rsc.d.ts +224 -0
- package/dist/production/lib/rsc/server.ssr.d.ts +152 -0
- package/dist/production/lib/rsc/server.ssr.js +419 -0
- package/dist/production/lib/server-runtime/build.d.ts +66 -0
- package/dist/production/lib/server-runtime/cookies.d.ts +92 -0
- package/dist/production/lib/server-runtime/cookies.js +153 -0
- package/dist/production/lib/server-runtime/crypto.js +43 -0
- package/dist/production/lib/server-runtime/data.js +25 -0
- package/dist/production/lib/server-runtime/dev.d.ts +9 -0
- package/dist/production/lib/server-runtime/dev.js +26 -0
- package/dist/production/lib/server-runtime/entry.js +20 -0
- package/dist/production/lib/server-runtime/errors.js +75 -0
- package/dist/production/lib/server-runtime/headers.js +73 -0
- package/dist/production/lib/server-runtime/invariant.js +19 -0
- package/dist/production/lib/server-runtime/mode.d.ts +12 -0
- package/dist/production/lib/server-runtime/mode.js +25 -0
- package/dist/production/lib/server-runtime/routeMatching.js +28 -0
- package/dist/production/lib/server-runtime/routes.d.ts +13 -0
- package/dist/production/lib/server-runtime/routes.js +74 -0
- package/dist/production/lib/server-runtime/server.d.ts +22 -0
- package/dist/production/lib/server-runtime/server.js +364 -0
- package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +33 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +53 -0
- package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +29 -0
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +58 -0
- package/dist/production/lib/server-runtime/sessions.d.ts +174 -0
- package/dist/production/lib/server-runtime/sessions.js +115 -0
- package/dist/production/lib/server-runtime/single-fetch.d.ts +7 -0
- package/dist/production/lib/server-runtime/single-fetch.js +215 -0
- package/dist/production/lib/server-runtime/urls.js +28 -0
- package/dist/production/lib/server-runtime/warnings.js +20 -0
- package/dist/production/lib/types/future.d.ts +9 -0
- package/dist/production/lib/types/internal.d.ts +26 -177
- package/dist/production/lib/types/internal.js +3 -2
- package/dist/{development/register-Bsscfj79.d.ts → production/lib/types/register.d.ts} +9 -15
- package/dist/production/lib/types/route-data.d.ts +113 -0
- package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
- package/dist/production/lib/types/route-module.d.ts +19 -0
- package/dist/production/lib/types/serializes-to.d.ts +13 -0
- package/dist/production/lib/types/utils.d.ts +11 -0
- package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +179 -0
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +199 -0
- package/dist/production/vendor/turbo-stream-v2/utils.js +39 -0
- package/docs/explanation/backend-for-frontend.md +50 -0
- package/docs/explanation/code-splitting.md +77 -0
- package/docs/explanation/concurrency.md +135 -0
- package/docs/explanation/form-vs-fetcher.md +292 -0
- package/docs/explanation/hot-module-replacement.md +137 -0
- package/docs/explanation/hydration.md +14 -0
- package/docs/explanation/index-query-param.md +86 -0
- package/docs/explanation/index.md +4 -0
- package/docs/explanation/lazy-route-discovery.md +78 -0
- package/docs/explanation/location.md +6 -0
- package/docs/explanation/progressive-enhancement.md +150 -0
- package/docs/explanation/race-conditions.md +88 -0
- package/docs/explanation/react-transitions.md +160 -0
- package/docs/explanation/route-matching.md +7 -0
- package/docs/explanation/server-client-execution.md +4 -0
- package/docs/explanation/sessions-and-cookies.md +465 -0
- package/docs/explanation/special-files.md +16 -0
- package/docs/explanation/state-management.md +524 -0
- package/docs/explanation/styling.md +87 -0
- package/docs/explanation/type-safety.md +82 -0
- package/docs/how-to/accessibility.md +44 -0
- package/docs/how-to/client-data.md +199 -0
- package/docs/how-to/data-strategy.md +317 -0
- package/docs/how-to/error-boundary.md +231 -0
- package/docs/how-to/error-reporting.md +142 -0
- package/docs/how-to/fetchers.md +307 -0
- package/docs/how-to/file-route-conventions.md +410 -0
- package/docs/how-to/file-uploads.md +217 -0
- package/docs/how-to/form-validation.md +120 -0
- package/docs/how-to/headers.md +165 -0
- package/docs/how-to/index.md +4 -0
- package/docs/how-to/instrumentation.md +661 -0
- package/docs/how-to/meta.md +40 -0
- package/docs/how-to/middleware.md +647 -0
- package/docs/how-to/navigation-blocking.md +233 -0
- package/docs/how-to/optimize-revalidation.md +12 -0
- package/docs/how-to/pre-rendering.md +225 -0
- package/docs/how-to/presets.md +103 -0
- package/docs/how-to/react-server-components.md +951 -0
- package/docs/how-to/resource-routes.md +126 -0
- package/docs/how-to/route-module-type-safety.md +85 -0
- package/docs/how-to/search-params.md +4 -0
- package/docs/how-to/security.md +39 -0
- package/docs/how-to/server-bundles.md +66 -0
- package/docs/how-to/spa.md +120 -0
- package/docs/how-to/status.md +63 -0
- package/docs/how-to/suspense.md +132 -0
- package/docs/how-to/using-handle.md +117 -0
- package/docs/how-to/view-transitions.md +237 -0
- package/docs/how-to/webhook.md +50 -0
- package/docs/index.md +36 -0
- package/docs/start/data/actions.md +138 -0
- package/docs/start/data/custom.md +198 -0
- package/docs/start/data/data-loading.md +44 -0
- package/docs/start/data/index.md +4 -0
- package/docs/start/data/installation.md +56 -0
- package/docs/start/data/navigating.md +12 -0
- package/docs/start/data/pending-ui.md +12 -0
- package/docs/start/data/route-object.md +268 -0
- package/docs/start/data/routing.md +281 -0
- package/docs/start/data/testing.md +8 -0
- package/docs/start/declarative/index.md +4 -0
- package/docs/start/declarative/installation.md +43 -0
- package/docs/start/declarative/navigating.md +133 -0
- package/docs/start/declarative/routing.md +237 -0
- package/docs/start/declarative/url-values.md +65 -0
- package/docs/start/framework/actions.md +174 -0
- package/docs/start/framework/data-loading.md +201 -0
- package/docs/start/framework/deploying.md +104 -0
- package/docs/start/framework/index.md +4 -0
- package/docs/start/framework/installation.md +41 -0
- package/docs/start/framework/navigating.md +182 -0
- package/docs/start/framework/pending-ui.md +142 -0
- package/docs/start/framework/rendering.md +59 -0
- package/docs/start/framework/route-module.md +527 -0
- package/docs/start/framework/routing.md +362 -0
- package/docs/start/framework/testing.md +133 -0
- package/docs/start/index.md +4 -0
- package/docs/start/modes.md +200 -0
- package/docs/upgrading/component-routes.md +363 -0
- package/docs/upgrading/future.md +111 -0
- package/docs/upgrading/index.md +4 -0
- package/docs/upgrading/router-provider.md +445 -0
- package/docs/upgrading/v7.md +460 -0
- package/package.json +44 -87
- package/dist/development/browser-3AnU12UI.d.mts +0 -318
- package/dist/development/browser-BOdXz9dK.d.ts +0 -318
- package/dist/development/chunk-4N6VE7H7.mjs +0 -11528
- package/dist/development/chunk-4YRVXM2U.js +0 -188
- package/dist/development/chunk-66UKHEGQ.js +0 -1362
- package/dist/development/chunk-D6LUOGOQ.js +0 -10229
- package/dist/development/chunk-RJYABSBD.mjs +0 -2585
- package/dist/development/context-ByvtofY2.d.mts +0 -1771
- package/dist/development/data-BVUf681J.d.mts +0 -1732
- package/dist/development/data-BqZ2x964.d.ts +0 -1732
- package/dist/development/dom-export.d.mts +0 -172
- package/dist/development/dom-export.mjs +0 -1008
- package/dist/development/index-react-server-client-BS5F89FR.d.ts +0 -3655
- package/dist/development/index-react-server-client-DY04-103.d.mts +0 -2600
- package/dist/development/index-react-server-client.d.mts +0 -4
- package/dist/development/index-react-server-client.mjs +0 -59
- package/dist/development/index-react-server.d.mts +0 -2703
- package/dist/development/index-react-server.mjs +0 -3780
- package/dist/development/index.d.mts +0 -1472
- package/dist/development/index.mjs +0 -277
- package/dist/development/instrumentation-cRWWLfsU.d.ts +0 -715
- package/dist/development/lib/types/internal.d.mts +0 -184
- package/dist/development/lib/types/internal.mjs +0 -10
- package/dist/development/register-Df8okEea.d.mts +0 -30
- package/dist/production/browser-3AnU12UI.d.mts +0 -318
- package/dist/production/browser-BOdXz9dK.d.ts +0 -318
- package/dist/production/chunk-6S4627ZB.mjs +0 -2585
- package/dist/production/chunk-HUBUW7R3.js +0 -10229
- package/dist/production/chunk-JAKZPQZC.mjs +0 -11528
- package/dist/production/chunk-PNZCCTKT.js +0 -1362
- package/dist/production/chunk-Y6IFXO7V.js +0 -188
- package/dist/production/context-ByvtofY2.d.mts +0 -1771
- package/dist/production/data-BVUf681J.d.mts +0 -1732
- package/dist/production/data-BqZ2x964.d.ts +0 -1732
- package/dist/production/dom-export.d.mts +0 -172
- package/dist/production/dom-export.mjs +0 -1008
- package/dist/production/index-react-server-client-BS5F89FR.d.ts +0 -3655
- package/dist/production/index-react-server-client-DY04-103.d.mts +0 -2600
- package/dist/production/index-react-server-client.d.mts +0 -4
- package/dist/production/index-react-server-client.mjs +0 -59
- package/dist/production/index-react-server.d.mts +0 -2703
- package/dist/production/index-react-server.mjs +0 -3780
- package/dist/production/index.d.mts +0 -1472
- package/dist/production/index.mjs +0 -277
- package/dist/production/instrumentation-cRWWLfsU.d.ts +0 -715
- package/dist/production/lib/types/internal.d.mts +0 -184
- package/dist/production/lib/types/internal.mjs +0 -10
- package/dist/production/register-Df8okEea.d.mts +0 -30
|
@@ -1,93 +1,95 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, unstable_HistoryRouter } from 'react-router/internal/react-server-client';
|
|
3
|
-
import { ParseOptions, SerializeOptions } from 'cookie';
|
|
4
|
-
export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
|
|
5
1
|
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { CookieParseOptions, CookieParseOptions as CookieParseOptions$1, CookieSerializeOptions, CookieSerializeOptions as CookieSerializeOptions$1 } from "cookie-es";
|
|
4
|
+
import { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, unstable_HistoryRouter } from "react-router/internal/react-server-client";
|
|
5
|
+
import { ReactFormState } from "react-dom/client";
|
|
6
|
+
|
|
7
|
+
//#region lib/router/history.d.ts
|
|
6
8
|
/**
|
|
7
9
|
* Actions represent the type of change to a location value.
|
|
8
10
|
*/
|
|
9
11
|
declare enum Action {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
/**
|
|
13
|
+
* A POP indicates a change to an arbitrary index in the history stack, such
|
|
14
|
+
* as a back or forward navigation. It does not describe the direction of the
|
|
15
|
+
* navigation, only that the current index changed.
|
|
16
|
+
*
|
|
17
|
+
* Note: This is the default action for newly created history objects.
|
|
18
|
+
*/
|
|
19
|
+
Pop = "POP",
|
|
20
|
+
/**
|
|
21
|
+
* A PUSH indicates a new entry being added to the history stack, such as when
|
|
22
|
+
* a link is clicked and a new page loads. When this happens, all subsequent
|
|
23
|
+
* entries in the stack are lost.
|
|
24
|
+
*/
|
|
25
|
+
Push = "PUSH",
|
|
26
|
+
/**
|
|
27
|
+
* A REPLACE indicates the entry at the current index in the history stack
|
|
28
|
+
* being replaced by a new one.
|
|
29
|
+
*/
|
|
30
|
+
Replace = "REPLACE"
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
31
33
|
* The pathname, search, and hash values of a URL.
|
|
32
34
|
*/
|
|
33
35
|
interface Path {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
/**
|
|
37
|
+
* A URL pathname, beginning with a /.
|
|
38
|
+
*/
|
|
39
|
+
pathname: string;
|
|
40
|
+
/**
|
|
41
|
+
* A URL search string, beginning with a ?.
|
|
42
|
+
*/
|
|
43
|
+
search: string;
|
|
44
|
+
/**
|
|
45
|
+
* A URL fragment identifier, beginning with a #.
|
|
46
|
+
*/
|
|
47
|
+
hash: string;
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
48
50
|
* An entry in a history stack. A location contains information about the
|
|
49
51
|
* URL path, as well as possibly some arbitrary state and a key.
|
|
50
52
|
*/
|
|
51
53
|
interface Location<State = any> extends Path {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
/**
|
|
55
|
+
* A value of arbitrary data associated with this location.
|
|
56
|
+
*/
|
|
57
|
+
state: State;
|
|
58
|
+
/**
|
|
59
|
+
* A unique string associated with this location. May be used to safely store
|
|
60
|
+
* and retrieve data in some other storage API, like `localStorage`.
|
|
61
|
+
*
|
|
62
|
+
* Note: This value is always "default" on the initial location.
|
|
63
|
+
*/
|
|
64
|
+
key: string;
|
|
65
|
+
/**
|
|
66
|
+
* The masked location displayed in the URL bar, which differs from the URL the
|
|
67
|
+
* router is operating on
|
|
68
|
+
*/
|
|
69
|
+
mask?: Path;
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
70
72
|
* A change to the current location.
|
|
71
73
|
*/
|
|
72
74
|
interface Update {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
/**
|
|
76
|
+
* The action that triggered the change.
|
|
77
|
+
*/
|
|
78
|
+
action: Action;
|
|
79
|
+
/**
|
|
80
|
+
* The new location.
|
|
81
|
+
*/
|
|
82
|
+
location: Location;
|
|
83
|
+
/**
|
|
84
|
+
* The delta between this location and the former location in the history stack
|
|
85
|
+
*/
|
|
86
|
+
delta: number | null;
|
|
85
87
|
}
|
|
86
88
|
/**
|
|
87
89
|
* A function that receives notifications about location changes.
|
|
88
90
|
*/
|
|
89
91
|
interface Listener {
|
|
90
|
-
|
|
92
|
+
(update: Update): void;
|
|
91
93
|
}
|
|
92
94
|
/**
|
|
93
95
|
* Describes a location that is the destination of some navigation used in
|
|
@@ -103,86 +105,77 @@ type To = string | Partial<Path>;
|
|
|
103
105
|
* focused API.
|
|
104
106
|
*/
|
|
105
107
|
interface History {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* An augmentable interface users can modify in their app-code to opt into
|
|
172
|
-
* future-flag-specific types
|
|
173
|
-
*/
|
|
174
|
-
interface Future {
|
|
108
|
+
/**
|
|
109
|
+
* The last action that modified the current location. This will always be
|
|
110
|
+
* Action.Pop when a history instance is first created. This value is mutable.
|
|
111
|
+
*/
|
|
112
|
+
readonly action: Action;
|
|
113
|
+
/**
|
|
114
|
+
* The current location. This value is mutable.
|
|
115
|
+
*/
|
|
116
|
+
readonly location: Location;
|
|
117
|
+
/**
|
|
118
|
+
* Returns a valid href for the given `to` value that may be used as
|
|
119
|
+
* the value of an <a href> attribute.
|
|
120
|
+
*
|
|
121
|
+
* @param to - The destination URL
|
|
122
|
+
*/
|
|
123
|
+
createHref(to: To): string;
|
|
124
|
+
/**
|
|
125
|
+
* Returns a URL for the given `to` value
|
|
126
|
+
*
|
|
127
|
+
* @param to - The destination URL
|
|
128
|
+
*/
|
|
129
|
+
createURL(to: To): URL;
|
|
130
|
+
/**
|
|
131
|
+
* Encode a location the same way window.history would do (no-op for memory
|
|
132
|
+
* history) so we ensure our PUSH/REPLACE navigations for data routers
|
|
133
|
+
* behave the same as POP
|
|
134
|
+
*
|
|
135
|
+
* @param to Unencoded path
|
|
136
|
+
*/
|
|
137
|
+
encodeLocation(to: To): Path;
|
|
138
|
+
/**
|
|
139
|
+
* Pushes a new location onto the history stack, increasing its length by one.
|
|
140
|
+
* If there were any entries in the stack after the current one, they are
|
|
141
|
+
* lost.
|
|
142
|
+
*
|
|
143
|
+
* @param to - The new URL
|
|
144
|
+
* @param state - Data to associate with the new location
|
|
145
|
+
*/
|
|
146
|
+
push(to: To, state?: any): void;
|
|
147
|
+
/**
|
|
148
|
+
* Replaces the current location in the history stack with a new one. The
|
|
149
|
+
* location that was replaced will no longer be available.
|
|
150
|
+
*
|
|
151
|
+
* @param to - The new URL
|
|
152
|
+
* @param state - Data to associate with the new location
|
|
153
|
+
*/
|
|
154
|
+
replace(to: To, state?: any): void;
|
|
155
|
+
/**
|
|
156
|
+
* Navigates `n` entries backward/forward in the history stack relative to the
|
|
157
|
+
* current index. For example, a "back" navigation would use go(-1).
|
|
158
|
+
*
|
|
159
|
+
* @param delta - The delta in the stack index
|
|
160
|
+
*/
|
|
161
|
+
go(delta: number): void;
|
|
162
|
+
/**
|
|
163
|
+
* Sets up a listener that will be called whenever the current location
|
|
164
|
+
* changes.
|
|
165
|
+
*
|
|
166
|
+
* @param listener - A function that will be called when the location changes
|
|
167
|
+
* @returns unlisten - A function that may be used to stop listening
|
|
168
|
+
*/
|
|
169
|
+
listen(listener: Listener): () => void;
|
|
175
170
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
} ? T : false;
|
|
179
|
-
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region lib/router/utils.d.ts
|
|
180
173
|
type MaybePromise<T> = T | Promise<T>;
|
|
181
174
|
/**
|
|
182
175
|
* Map of routeId -> data returned from a loader/action/error
|
|
183
176
|
*/
|
|
184
177
|
interface RouteData {
|
|
185
|
-
|
|
178
|
+
[routeId: string]: any;
|
|
186
179
|
}
|
|
187
180
|
type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
188
181
|
type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
|
|
@@ -197,11 +190,7 @@ type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;
|
|
|
197
190
|
*/
|
|
198
191
|
type FormMethod = UpperCaseFormMethod;
|
|
199
192
|
type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
|
|
200
|
-
type JsonObject = {
|
|
201
|
-
[Key in string]: JsonValue;
|
|
202
|
-
} & {
|
|
203
|
-
[Key in string]?: JsonValue | undefined;
|
|
204
|
-
};
|
|
193
|
+
type JsonObject = { [Key in string]: JsonValue } & { [Key in string]?: JsonValue | undefined };
|
|
205
194
|
type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
206
195
|
type JsonPrimitive = string | number | boolean | null;
|
|
207
196
|
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
@@ -211,26 +200,26 @@ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
|
211
200
|
* external consumption
|
|
212
201
|
*/
|
|
213
202
|
type Submission = {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
203
|
+
formMethod: FormMethod;
|
|
204
|
+
formAction: string;
|
|
205
|
+
formEncType: FormEncType;
|
|
206
|
+
formData: FormData;
|
|
207
|
+
json: undefined;
|
|
208
|
+
text: undefined;
|
|
220
209
|
} | {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
210
|
+
formMethod: FormMethod;
|
|
211
|
+
formAction: string;
|
|
212
|
+
formEncType: FormEncType;
|
|
213
|
+
formData: undefined;
|
|
214
|
+
json: JsonValue;
|
|
215
|
+
text: undefined;
|
|
227
216
|
} | {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
217
|
+
formMethod: FormMethod;
|
|
218
|
+
formAction: string;
|
|
219
|
+
formEncType: FormEncType;
|
|
220
|
+
formData: undefined;
|
|
221
|
+
json: undefined;
|
|
222
|
+
text: string;
|
|
234
223
|
};
|
|
235
224
|
/**
|
|
236
225
|
* A context instance used as the key for the `get`/`set` methods of a
|
|
@@ -238,7 +227,7 @@ type Submission = {
|
|
|
238
227
|
* value to be returned if no value has been set.
|
|
239
228
|
*/
|
|
240
229
|
interface RouterContext<T = unknown> {
|
|
241
|
-
|
|
230
|
+
defaultValue?: T;
|
|
242
231
|
}
|
|
243
232
|
/**
|
|
244
233
|
* Creates a type-safe {@link RouterContext} object that can be used to
|
|
@@ -322,82 +311,82 @@ declare function createContext<T>(defaultValue?: T): RouterContext<T>;
|
|
|
322
311
|
* @mode data
|
|
323
312
|
*/
|
|
324
313
|
declare class RouterContextProvider {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
314
|
+
#private;
|
|
315
|
+
/**
|
|
316
|
+
* Create a new `RouterContextProvider` instance
|
|
317
|
+
* @param init An optional initial context map to populate the provider with
|
|
318
|
+
*/
|
|
319
|
+
constructor(init?: Map<RouterContext, unknown>);
|
|
320
|
+
/**
|
|
321
|
+
* Access a value from the context. If no value has been set for the context,
|
|
322
|
+
* it will return the context's `defaultValue` if provided, or throw an error
|
|
323
|
+
* if no `defaultValue` was set.
|
|
324
|
+
* @param context The context to get the value for
|
|
325
|
+
* @returns The value for the context, or the context's `defaultValue` if no
|
|
326
|
+
* value was set
|
|
327
|
+
*/
|
|
328
|
+
get<T>(context: RouterContext<T>): T;
|
|
329
|
+
/**
|
|
330
|
+
* Set a value for the context. If the context already has a value set, this
|
|
331
|
+
* will overwrite it.
|
|
332
|
+
*
|
|
333
|
+
* @param context The context to set the value for
|
|
334
|
+
* @param value The value to set for the context
|
|
335
|
+
* @returns {void}
|
|
336
|
+
*/
|
|
337
|
+
set<C extends RouterContext>(context: C, value: C extends RouterContext<infer T> ? T : never): void;
|
|
349
338
|
}
|
|
350
|
-
type DefaultContext =
|
|
339
|
+
type DefaultContext = Readonly<RouterContextProvider>;
|
|
351
340
|
/**
|
|
352
341
|
* @private
|
|
353
342
|
* Arguments passed to route loader/action functions. Same for now but we keep
|
|
354
343
|
* this as a private implementation detail in case they diverge in the future.
|
|
355
344
|
*/
|
|
356
345
|
interface DataFunctionArgs<Context> {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
346
|
+
/** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read headers (like cookies, and {@link https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams URLSearchParams} from the request. */
|
|
347
|
+
request: Request;
|
|
348
|
+
/**
|
|
349
|
+
* A URL instance representing the application location being navigated to or
|
|
350
|
+
* fetched.
|
|
351
|
+
*
|
|
352
|
+
* In Framework mode, this is a normalized URL with React-Router-specific
|
|
353
|
+
* implementation details removed (`.data` suffixes, `index`/`_routes` search
|
|
354
|
+
* params). For the raw incoming URL, use `request.url`.
|
|
355
|
+
*/
|
|
356
|
+
url: URL;
|
|
357
|
+
/**
|
|
358
|
+
* Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
|
|
359
|
+
* Mostly useful as a identifier to aggregate on for logging/tracing/etc.
|
|
360
|
+
*/
|
|
361
|
+
pattern: string;
|
|
362
|
+
/**
|
|
363
|
+
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
364
|
+
* @example
|
|
365
|
+
* // app/routes.ts
|
|
366
|
+
* route("teams/:teamId", "./team.tsx"),
|
|
367
|
+
*
|
|
368
|
+
* // app/team.tsx
|
|
369
|
+
* export function loader({
|
|
370
|
+
* params,
|
|
371
|
+
* }: Route.LoaderArgs) {
|
|
372
|
+
* params.teamId;
|
|
373
|
+
* // ^ string
|
|
374
|
+
* }
|
|
375
|
+
*/
|
|
376
|
+
params: Params;
|
|
377
|
+
/**
|
|
378
|
+
* This is the context passed in to your server adapter's getLoadContext() function.
|
|
379
|
+
* It's a way to bridge the gap between the adapter's request/response API with your React Router app.
|
|
380
|
+
* It is only applicable if you are using a custom server adapter.
|
|
381
|
+
*/
|
|
382
|
+
context: Context;
|
|
394
383
|
}
|
|
395
384
|
/**
|
|
396
385
|
* Route middleware `next` function to call downstream handlers and then complete
|
|
397
386
|
* middlewares from the bottom-up
|
|
398
387
|
*/
|
|
399
388
|
interface MiddlewareNextFunction<Result = unknown> {
|
|
400
|
-
|
|
389
|
+
(): Promise<Result>;
|
|
401
390
|
}
|
|
402
391
|
/**
|
|
403
392
|
* Route middleware function signature. Receives the same "data" arguments as a
|
|
@@ -409,13 +398,11 @@ type MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<Rou
|
|
|
409
398
|
/**
|
|
410
399
|
* Arguments passed to loader functions
|
|
411
400
|
*/
|
|
412
|
-
interface LoaderFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
|
|
413
|
-
}
|
|
401
|
+
interface LoaderFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {}
|
|
414
402
|
/**
|
|
415
403
|
* Arguments passed to action functions
|
|
416
404
|
*/
|
|
417
|
-
interface ActionFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
|
|
418
|
-
}
|
|
405
|
+
interface ActionFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {}
|
|
419
406
|
/**
|
|
420
407
|
* Loaders and actions can return anything
|
|
421
408
|
*/
|
|
@@ -425,71 +412,71 @@ type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
|
|
|
425
412
|
* Route loader function signature
|
|
426
413
|
*/
|
|
427
414
|
type LoaderFunction<Context = DefaultContext> = {
|
|
428
|
-
|
|
415
|
+
(args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
|
429
416
|
} & {
|
|
430
|
-
|
|
417
|
+
hydrate?: boolean;
|
|
431
418
|
};
|
|
432
419
|
/**
|
|
433
420
|
* Route action function signature
|
|
434
421
|
*/
|
|
435
422
|
interface ActionFunction<Context = DefaultContext> {
|
|
436
|
-
|
|
423
|
+
(args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
|
437
424
|
}
|
|
438
425
|
/**
|
|
439
426
|
* Arguments passed to shouldRevalidate function
|
|
440
427
|
*/
|
|
441
428
|
interface ShouldRevalidateFunctionArgs {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
429
|
+
/** This is the url the navigation started from. You can compare it with `nextUrl` to decide if you need to revalidate this route's data. */
|
|
430
|
+
currentUrl: URL;
|
|
431
|
+
/** These are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the URL that can be compared to the `nextParams` to decide if you need to reload or not. Perhaps you're using only a partial piece of the param for data loading, you don't need to revalidate if a superfluous part of the param changed. */
|
|
432
|
+
currentParams: DataRouteMatch["params"];
|
|
433
|
+
/** In the case of navigation, this the URL the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentUrl. */
|
|
434
|
+
nextUrl: URL;
|
|
435
|
+
/** In the case of navigation, these are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the next location the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentParams. */
|
|
436
|
+
nextParams: DataRouteMatch["params"];
|
|
437
|
+
/** The method (probably `"GET"` or `"POST"`) used in the form submission that triggered the revalidation. */
|
|
438
|
+
formMethod?: Submission["formMethod"];
|
|
439
|
+
/** The form action (`<Form action="/somewhere">`) that triggered the revalidation. */
|
|
440
|
+
formAction?: Submission["formAction"];
|
|
441
|
+
/** The form encType (`<Form encType="application/x-www-form-urlencoded">) used in the form submission that triggered the revalidation*/
|
|
442
|
+
formEncType?: Submission["formEncType"];
|
|
443
|
+
/** The form submission data when the form's encType is `text/plain` */
|
|
444
|
+
text?: Submission["text"];
|
|
445
|
+
/** The form submission data when the form's encType is `application/x-www-form-urlencoded` or `multipart/form-data` */
|
|
446
|
+
formData?: Submission["formData"];
|
|
447
|
+
/** The form submission data when the form's encType is `application/json` */
|
|
448
|
+
json?: Submission["json"];
|
|
449
|
+
/** The status code of the action response */
|
|
450
|
+
actionStatus?: number;
|
|
451
|
+
/**
|
|
452
|
+
* When a submission causes the revalidation this will be the result of the action—either action data or an error if the action failed. It's common to include some information in the action result to instruct shouldRevalidate to revalidate or not.
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* export async function action() {
|
|
456
|
+
* await saveSomeStuff();
|
|
457
|
+
* return { ok: true };
|
|
458
|
+
* }
|
|
459
|
+
*
|
|
460
|
+
* export function shouldRevalidate({
|
|
461
|
+
* actionResult,
|
|
462
|
+
* }) {
|
|
463
|
+
* if (actionResult?.ok) {
|
|
464
|
+
* return false;
|
|
465
|
+
* }
|
|
466
|
+
* return true;
|
|
467
|
+
* }
|
|
468
|
+
*/
|
|
469
|
+
actionResult?: any;
|
|
470
|
+
/**
|
|
471
|
+
* By default, React Router doesn't call every loader all the time. There are reliable optimizations it can make by default. For example, only loaders with changing params are called. Consider navigating from the following URL to the one below it:
|
|
472
|
+
*
|
|
473
|
+
* /projects/123/tasks/abc
|
|
474
|
+
* /projects/123/tasks/def
|
|
475
|
+
* React Router will only call the loader for tasks/def because the param for projects/123 didn't change.
|
|
476
|
+
*
|
|
477
|
+
* It's safest to always return defaultShouldRevalidate after you've done your specific optimizations that return false, otherwise your UI might get out of sync with your data on the server.
|
|
478
|
+
*/
|
|
479
|
+
defaultShouldRevalidate: boolean;
|
|
493
480
|
}
|
|
494
481
|
/**
|
|
495
482
|
* Route shouldRevalidate function signature. This runs after any submission
|
|
@@ -499,113 +486,111 @@ interface ShouldRevalidateFunctionArgs {
|
|
|
499
486
|
* have to re-run based on the data models that were potentially mutated.
|
|
500
487
|
*/
|
|
501
488
|
interface ShouldRevalidateFunction {
|
|
502
|
-
|
|
489
|
+
(args: ShouldRevalidateFunctionArgs): boolean;
|
|
503
490
|
}
|
|
504
491
|
interface DataStrategyMatch extends RouteMatch<string, DataRouteObject> {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
492
|
+
/**
|
|
493
|
+
* @private
|
|
494
|
+
*/
|
|
495
|
+
_lazyPromises?: {
|
|
496
|
+
middleware: Promise<void> | undefined;
|
|
497
|
+
handler: Promise<void> | undefined;
|
|
498
|
+
route: Promise<void> | undefined;
|
|
499
|
+
};
|
|
500
|
+
/**
|
|
501
|
+
* @deprecated Deprecated in favor of `shouldCallHandler`
|
|
502
|
+
*
|
|
503
|
+
* A boolean value indicating whether this route handler should be called in
|
|
504
|
+
* this pass.
|
|
505
|
+
*
|
|
506
|
+
* The `matches` array always includes _all_ matched routes even when only
|
|
507
|
+
* _some_ route handlers need to be called so that things like middleware can
|
|
508
|
+
* be implemented.
|
|
509
|
+
*
|
|
510
|
+
* `shouldLoad` is usually only interesting if you are skipping the route
|
|
511
|
+
* handler entirely and implementing custom handler logic - since it lets you
|
|
512
|
+
* determine if that custom logic should run for this route or not.
|
|
513
|
+
*
|
|
514
|
+
* For example:
|
|
515
|
+
* - If you are on `/parent/child/a` and you navigate to `/parent/child/b` -
|
|
516
|
+
* you'll get an array of three matches (`[parent, child, b]`), but only `b`
|
|
517
|
+
* will have `shouldLoad=true` because the data for `parent` and `child` is
|
|
518
|
+
* already loaded
|
|
519
|
+
* - If you are on `/parent/child/a` and you submit to `a`'s [`action`](https://reactrouter.com/docs/start/data/route-object#action),
|
|
520
|
+
* then only `a` will have `shouldLoad=true` for the action execution of
|
|
521
|
+
* `dataStrategy`
|
|
522
|
+
* - After the [`action`](https://reactrouter.com/docs/start/data/route-object#action),
|
|
523
|
+
* `dataStrategy` will be called again for the [`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
|
|
524
|
+
* revalidation, and all matches will have `shouldLoad=true` (assuming no
|
|
525
|
+
* custom `shouldRevalidate` implementations)
|
|
526
|
+
*/
|
|
527
|
+
shouldLoad: boolean;
|
|
528
|
+
/**
|
|
529
|
+
* Arguments passed to the `shouldRevalidate` function for this `loader` execution.
|
|
530
|
+
* Will be `null` if this is not a revalidating loader {@link DataStrategyMatch}.
|
|
531
|
+
*/
|
|
532
|
+
shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
|
|
533
|
+
/**
|
|
534
|
+
* Determine if this route's handler should be called during this `dataStrategy`
|
|
535
|
+
* execution. Calling it with no arguments will leverage the default revalidation
|
|
536
|
+
* behavior. You can pass your own `defaultShouldRevalidate` value if you wish
|
|
537
|
+
* to change the default revalidation behavior with your `dataStrategy`.
|
|
538
|
+
*
|
|
539
|
+
* @param defaultShouldRevalidate `defaultShouldRevalidate` override value (optional)
|
|
540
|
+
*/
|
|
541
|
+
shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
|
|
542
|
+
/**
|
|
543
|
+
* An async function that will resolve any `route.lazy` implementations and
|
|
544
|
+
* execute the route's handler (if necessary), returning a {@link DataStrategyResult}
|
|
545
|
+
*
|
|
546
|
+
* - Calling `match.resolve` does not mean you're calling the
|
|
547
|
+
* [`action`](https://reactrouter.com/docs/start/data/route-object#action)/[`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
|
|
548
|
+
* (the "handler") - `resolve` will only call the `handler` internally if
|
|
549
|
+
* needed _and_ if you don't pass your own `handlerOverride` function parameter
|
|
550
|
+
* - It is safe to call `match.resolve` for all matches, even if they have
|
|
551
|
+
* `shouldLoad=false`, and it will no-op if no loading is required
|
|
552
|
+
* - You should generally always call `match.resolve()` for `shouldLoad:true`
|
|
553
|
+
* routes to ensure that any `route.lazy` implementations are processed
|
|
554
|
+
* - See the examples below for how to implement custom handler execution via
|
|
555
|
+
* `match.resolve`
|
|
556
|
+
*/
|
|
557
|
+
resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
|
|
571
558
|
}
|
|
572
559
|
interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
560
|
+
/**
|
|
561
|
+
* Matches for this route extended with Data strategy APIs
|
|
562
|
+
*/
|
|
563
|
+
matches: DataStrategyMatch[];
|
|
564
|
+
runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
|
|
565
|
+
/**
|
|
566
|
+
* The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
|
|
567
|
+
* for navigational executions
|
|
568
|
+
*/
|
|
569
|
+
fetcherKey: string | null;
|
|
583
570
|
}
|
|
584
571
|
/**
|
|
585
572
|
* Result from a loader or action called via dataStrategy
|
|
586
573
|
*/
|
|
587
574
|
interface DataStrategyResult {
|
|
588
|
-
|
|
589
|
-
|
|
575
|
+
type: "data" | "error";
|
|
576
|
+
result: unknown;
|
|
590
577
|
}
|
|
591
578
|
interface DataStrategyFunction<Context = DefaultContext> {
|
|
592
|
-
|
|
579
|
+
(args: DataStrategyFunctionArgs<Context>): Promise<Record<string, DataStrategyResult>>;
|
|
593
580
|
}
|
|
594
581
|
type PatchRoutesOnNavigationFunctionArgs = {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
582
|
+
signal: AbortSignal;
|
|
583
|
+
path: string;
|
|
584
|
+
matches: RouteMatch[];
|
|
585
|
+
fetcherKey: string | undefined;
|
|
586
|
+
patch: (routeId: string | null, children: RouteObject[]) => void;
|
|
600
587
|
};
|
|
601
588
|
type PatchRoutesOnNavigationFunction = (opts: PatchRoutesOnNavigationFunctionArgs) => MaybePromise<void>;
|
|
602
589
|
/**
|
|
603
590
|
* Function provided to set route-specific properties from route objects
|
|
604
591
|
*/
|
|
605
592
|
interface MapRoutePropertiesFunction {
|
|
606
|
-
|
|
607
|
-
hasErrorBoundary: boolean;
|
|
608
|
-
} & Record<string, any>;
|
|
593
|
+
(route: DataRouteObject): Partial<DataRouteObject>;
|
|
609
594
|
}
|
|
610
595
|
/**
|
|
611
596
|
* Keys we cannot change from within a lazy object. We spread all other keys
|
|
@@ -623,15 +608,13 @@ type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "middlewa
|
|
|
623
608
|
* lazy object to load route properties, which can add non-matching
|
|
624
609
|
* related properties to a route
|
|
625
610
|
*/
|
|
626
|
-
type LazyRouteObject<R extends RouteObject> = {
|
|
627
|
-
[K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined>;
|
|
628
|
-
};
|
|
611
|
+
type LazyRouteObject<R extends RouteObject> = { [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined> };
|
|
629
612
|
/**
|
|
630
613
|
* lazy() function to load a route definition, which can add non-matching
|
|
631
614
|
* related properties to a route
|
|
632
615
|
*/
|
|
633
616
|
interface LazyRouteFunction<R extends RouteObject> {
|
|
634
|
-
|
|
617
|
+
(): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
|
|
635
618
|
}
|
|
636
619
|
type LazyRouteDefinition<R extends RouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
|
|
637
620
|
/**
|
|
@@ -639,106 +622,105 @@ type LazyRouteDefinition<R extends RouteObject> = LazyRouteObject<R> | LazyRoute
|
|
|
639
622
|
* @internal
|
|
640
623
|
*/
|
|
641
624
|
type BaseRouteObject = {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
hydrateFallbackElement?: React.ReactNode | null;
|
|
625
|
+
/**
|
|
626
|
+
* Whether the path should be case-sensitive. Defaults to `false`.
|
|
627
|
+
*/
|
|
628
|
+
caseSensitive?: boolean;
|
|
629
|
+
/**
|
|
630
|
+
* The path pattern to match. If unspecified or empty, then this becomes a
|
|
631
|
+
* layout route.
|
|
632
|
+
*/
|
|
633
|
+
path?: string;
|
|
634
|
+
/**
|
|
635
|
+
* The unique identifier for this route (for use with {@link DataRouter}s)
|
|
636
|
+
*/
|
|
637
|
+
id?: string;
|
|
638
|
+
/**
|
|
639
|
+
* The route middleware.
|
|
640
|
+
* See [`middleware`](../../start/data/route-object#middleware).
|
|
641
|
+
*/
|
|
642
|
+
middleware?: MiddlewareFunction[];
|
|
643
|
+
/**
|
|
644
|
+
* The route loader.
|
|
645
|
+
* See [`loader`](../../start/data/route-object#loader).
|
|
646
|
+
*/
|
|
647
|
+
loader?: LoaderFunction | boolean;
|
|
648
|
+
/**
|
|
649
|
+
* The route action.
|
|
650
|
+
* See [`action`](../../start/data/route-object#action).
|
|
651
|
+
*/
|
|
652
|
+
action?: ActionFunction | boolean;
|
|
653
|
+
/**
|
|
654
|
+
* The route shouldRevalidate function.
|
|
655
|
+
* See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
|
|
656
|
+
*/
|
|
657
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
658
|
+
/**
|
|
659
|
+
* The route handle.
|
|
660
|
+
*/
|
|
661
|
+
handle?: any;
|
|
662
|
+
/**
|
|
663
|
+
* A function that returns a promise that resolves to the route object.
|
|
664
|
+
* Used for code-splitting routes.
|
|
665
|
+
* See [`lazy`](../../start/data/route-object#lazy).
|
|
666
|
+
*/
|
|
667
|
+
lazy?: LazyRouteDefinition<BaseRouteObject>;
|
|
668
|
+
/**
|
|
669
|
+
* The React Component to render when this route matches.
|
|
670
|
+
* Mutually exclusive with `element`.
|
|
671
|
+
*/
|
|
672
|
+
Component?: React.ComponentType | null;
|
|
673
|
+
/**
|
|
674
|
+
* The React element to render when this Route matches.
|
|
675
|
+
* Mutually exclusive with `Component`.
|
|
676
|
+
*/
|
|
677
|
+
element?: React.ReactNode | null;
|
|
678
|
+
/**
|
|
679
|
+
* The React Component to render at this route if an error occurs.
|
|
680
|
+
* Mutually exclusive with `errorElement`.
|
|
681
|
+
*/
|
|
682
|
+
ErrorBoundary?: React.ComponentType | null;
|
|
683
|
+
/**
|
|
684
|
+
* The React element to render at this route if an error occurs.
|
|
685
|
+
* Mutually exclusive with `ErrorBoundary`.
|
|
686
|
+
*/
|
|
687
|
+
errorElement?: React.ReactNode | null;
|
|
688
|
+
/**
|
|
689
|
+
* The React Component to render while this router is loading data.
|
|
690
|
+
* Mutually exclusive with `hydrateFallbackElement`.
|
|
691
|
+
*/
|
|
692
|
+
HydrateFallback?: React.ComponentType | null;
|
|
693
|
+
/**
|
|
694
|
+
* The React element to render while this router is loading data.
|
|
695
|
+
* Mutually exclusive with `HydrateFallback`.
|
|
696
|
+
*/
|
|
697
|
+
hydrateFallbackElement?: React.ReactNode | null;
|
|
716
698
|
};
|
|
717
699
|
/**
|
|
718
700
|
* Index routes must not have children
|
|
719
701
|
*/
|
|
720
702
|
type IndexRouteObject = BaseRouteObject & {
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
703
|
+
/**
|
|
704
|
+
* Child Route objects - not valid on index routes.
|
|
705
|
+
*/
|
|
706
|
+
children?: undefined;
|
|
707
|
+
/**
|
|
708
|
+
* Whether this is an index route.
|
|
709
|
+
*/
|
|
710
|
+
index: true;
|
|
729
711
|
};
|
|
730
712
|
/**
|
|
731
713
|
* Non-index routes may have children, but cannot have `index` set to `true`.
|
|
732
714
|
*/
|
|
733
715
|
type NonIndexRouteObject = BaseRouteObject & {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
716
|
+
/**
|
|
717
|
+
* Child Route objects.
|
|
718
|
+
*/
|
|
719
|
+
children?: RouteObject[];
|
|
720
|
+
/**
|
|
721
|
+
* Whether this is an index route - must be `false` or undefined on non-index routes.
|
|
722
|
+
*/
|
|
723
|
+
index?: false;
|
|
742
724
|
};
|
|
743
725
|
/**
|
|
744
726
|
* A route object represents a logical route, with (optionally) its child
|
|
@@ -746,11 +728,11 @@ type NonIndexRouteObject = BaseRouteObject & {
|
|
|
746
728
|
*/
|
|
747
729
|
type RouteObject = IndexRouteObject | NonIndexRouteObject;
|
|
748
730
|
type DataIndexRouteObject = IndexRouteObject & {
|
|
749
|
-
|
|
731
|
+
id: string;
|
|
750
732
|
};
|
|
751
733
|
type DataNonIndexRouteObject = NonIndexRouteObject & {
|
|
752
|
-
|
|
753
|
-
|
|
734
|
+
children?: DataRouteObject[];
|
|
735
|
+
id: string;
|
|
754
736
|
};
|
|
755
737
|
/**
|
|
756
738
|
* A data route object, which is just a RouteObject with a required unique ID
|
|
@@ -760,32 +742,29 @@ type RouteManifest<R = DataRouteObject> = Record<string, R | undefined>;
|
|
|
760
742
|
/**
|
|
761
743
|
* The parameters that were parsed from the URL path.
|
|
762
744
|
*/
|
|
763
|
-
type Params<Key extends string = string> = {
|
|
764
|
-
readonly [key in Key]: string | undefined;
|
|
765
|
-
};
|
|
745
|
+
type Params<Key extends string = string> = { readonly [key in Key]: string | undefined };
|
|
766
746
|
/**
|
|
767
747
|
* A RouteMatch contains info about how a route matched a URL.
|
|
768
748
|
*/
|
|
769
749
|
interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}
|
|
787
|
-
interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
|
|
750
|
+
/**
|
|
751
|
+
* The names and values of dynamic parameters in the URL.
|
|
752
|
+
*/
|
|
753
|
+
params: Params<ParamKey>;
|
|
754
|
+
/**
|
|
755
|
+
* The portion of the URL pathname that was matched.
|
|
756
|
+
*/
|
|
757
|
+
pathname: string;
|
|
758
|
+
/**
|
|
759
|
+
* The portion of the URL pathname that was matched before child routes.
|
|
760
|
+
*/
|
|
761
|
+
pathnameBase: string;
|
|
762
|
+
/**
|
|
763
|
+
* The route object that was used to match.
|
|
764
|
+
*/
|
|
765
|
+
route: RouteObjectType;
|
|
788
766
|
}
|
|
767
|
+
interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {}
|
|
789
768
|
/**
|
|
790
769
|
* Matches the given routes to a location and returns the match data.
|
|
791
770
|
*
|
|
@@ -814,37 +793,31 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
|
|
|
814
793
|
*/
|
|
815
794
|
declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
|
|
816
795
|
interface UIMatch<Data = unknown, Handle = unknown> {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
* an error and we're currently displaying an `ErrorBoundary`.
|
|
835
|
-
*/
|
|
836
|
-
loaderData: Data | undefined;
|
|
837
|
-
/**
|
|
838
|
-
* The {@link https://reactrouter.com/start/framework/route-module#handle handle object}
|
|
839
|
-
* exported from the matched route module
|
|
840
|
-
*/
|
|
841
|
-
handle: Handle;
|
|
796
|
+
id: string;
|
|
797
|
+
pathname: string;
|
|
798
|
+
/**
|
|
799
|
+
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
|
|
800
|
+
*/
|
|
801
|
+
params: RouteMatch["params"];
|
|
802
|
+
/**
|
|
803
|
+
* The return value from the matched route's loader or clientLoader. This might
|
|
804
|
+
* be `undefined` if this route's `loader` (or a deeper route's `loader`) threw
|
|
805
|
+
* an error and we're currently displaying an `ErrorBoundary`.
|
|
806
|
+
*/
|
|
807
|
+
loaderData: Data | undefined;
|
|
808
|
+
/**
|
|
809
|
+
* The {@link https://reactrouter.com/start/framework/route-module#handle handle object}
|
|
810
|
+
* exported from the matched route module
|
|
811
|
+
*/
|
|
812
|
+
handle: Handle;
|
|
842
813
|
}
|
|
843
814
|
interface RouteMeta<RouteObjectType extends RouteObject = RouteObject> {
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
815
|
+
relativePath: string;
|
|
816
|
+
caseSensitive: boolean;
|
|
817
|
+
childrenIndex: number;
|
|
818
|
+
route: RouteObjectType;
|
|
819
|
+
matcher?: RegExp;
|
|
820
|
+
compiledParams?: CompiledPathParam[];
|
|
848
821
|
}
|
|
849
822
|
/**
|
|
850
823
|
* @private
|
|
@@ -854,15 +827,19 @@ interface RouteMeta<RouteObjectType extends RouteObject = RouteObject> {
|
|
|
854
827
|
* This is an internal interface not intended for direct external usage.
|
|
855
828
|
*/
|
|
856
829
|
interface RouteBranch<RouteObjectType extends RouteObject = RouteObject> {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
830
|
+
path: string;
|
|
831
|
+
score: number;
|
|
832
|
+
routesMeta: RouteMeta<RouteObjectType>[];
|
|
860
833
|
}
|
|
834
|
+
type CompiledPathParam = {
|
|
835
|
+
paramName: string;
|
|
836
|
+
isOptional?: boolean;
|
|
837
|
+
};
|
|
861
838
|
declare class DataWithResponseInit<D> {
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
839
|
+
type: string;
|
|
840
|
+
data: D;
|
|
841
|
+
init: ResponseInit | null;
|
|
842
|
+
constructor(data: D, init?: ResponseInit);
|
|
866
843
|
}
|
|
867
844
|
/**
|
|
868
845
|
* Create "responses" that contain `headers`/`status` without forcing
|
|
@@ -982,11 +959,11 @@ declare const redirectDocument$1: RedirectFunction;
|
|
|
982
959
|
* object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
|
|
983
960
|
* header.
|
|
984
961
|
*/
|
|
985
|
-
declare const replace$
|
|
962
|
+
declare const replace$2: RedirectFunction;
|
|
986
963
|
type ErrorResponse = {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
964
|
+
status: number;
|
|
965
|
+
statusText: string;
|
|
966
|
+
data: any;
|
|
990
967
|
};
|
|
991
968
|
/**
|
|
992
969
|
* Check if the given error is an {@link ErrorResponse} generated from a 4xx/5xx
|
|
@@ -1020,383 +997,400 @@ type ErrorResponse = {
|
|
|
1020
997
|
* @returns `true` if the error is an {@link ErrorResponse}, `false` otherwise.
|
|
1021
998
|
*/
|
|
1022
999
|
declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
* An object of unknown type for route loaders and actions provided by the
|
|
1026
|
-
* server's `getLoadContext()` function. This is defined as an empty interface
|
|
1027
|
-
* specifically so apps can leverage declaration merging to augment this type
|
|
1028
|
-
* globally: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
|
|
1029
|
-
*/
|
|
1030
|
-
interface AppLoadContext {
|
|
1031
|
-
[key: string]: unknown;
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1000
|
+
//#endregion
|
|
1001
|
+
//#region lib/router/instrumentation.d.ts
|
|
1034
1002
|
type ServerInstrumentation = {
|
|
1035
|
-
|
|
1036
|
-
|
|
1003
|
+
handler?: InstrumentRequestHandlerFunction;
|
|
1004
|
+
route?: InstrumentRouteFunction;
|
|
1037
1005
|
};
|
|
1038
1006
|
type ClientInstrumentation = {
|
|
1039
|
-
|
|
1040
|
-
|
|
1007
|
+
router?: InstrumentRouterFunction;
|
|
1008
|
+
route?: InstrumentRouteFunction;
|
|
1041
1009
|
};
|
|
1042
1010
|
type InstrumentRequestHandlerFunction = (handler: InstrumentableRequestHandler) => void;
|
|
1043
1011
|
type InstrumentRouterFunction = (router: InstrumentableRouter) => void;
|
|
1044
1012
|
type InstrumentRouteFunction = (route: InstrumentableRoute) => void;
|
|
1013
|
+
/**
|
|
1014
|
+
* Route metadata available after React Router has matched an instrumented
|
|
1015
|
+
* request, navigation, or fetcher call.
|
|
1016
|
+
*/
|
|
1017
|
+
type InstrumentationResultMeta = {
|
|
1018
|
+
url: LoaderFunctionArgs["url"];
|
|
1019
|
+
pattern: string;
|
|
1020
|
+
params: LoaderFunctionArgs["params"];
|
|
1021
|
+
};
|
|
1022
|
+
/**
|
|
1023
|
+
* Result returned by route-level instrumented handler calls, such as
|
|
1024
|
+
* instrumented loaders, actions, middleware, and lazy route functions.
|
|
1025
|
+
*/
|
|
1045
1026
|
type InstrumentationHandlerResult = {
|
|
1046
|
-
|
|
1047
|
-
|
|
1027
|
+
status: "success";
|
|
1028
|
+
error: undefined;
|
|
1048
1029
|
} | {
|
|
1049
|
-
|
|
1050
|
-
|
|
1030
|
+
status: "error";
|
|
1031
|
+
error: Error;
|
|
1032
|
+
};
|
|
1033
|
+
/**
|
|
1034
|
+
* Result returned by client-side router instrumented navigation and fetcher
|
|
1035
|
+
* calls.
|
|
1036
|
+
*/
|
|
1037
|
+
type InstrumentationClientRouterResult = InstrumentationHandlerResult & {
|
|
1038
|
+
meta: InstrumentationResultMeta | undefined;
|
|
1039
|
+
};
|
|
1040
|
+
/**
|
|
1041
|
+
* Result returned by server request handler instrumentation.
|
|
1042
|
+
*/
|
|
1043
|
+
type InstrumentationServerHandlerResult = InstrumentationHandlerResult & {
|
|
1044
|
+
statusCode: number;
|
|
1045
|
+
meta: InstrumentationResultMeta | undefined;
|
|
1051
1046
|
};
|
|
1052
|
-
type InstrumentFunction<T> = (handler: () => Promise<
|
|
1047
|
+
type InstrumentFunction<T, TInnerResult = InstrumentationHandlerResult> = (handler: () => Promise<TInnerResult>, info: T) => Promise<void>;
|
|
1053
1048
|
type ReadonlyRequest = {
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1049
|
+
method: string;
|
|
1050
|
+
url: string;
|
|
1051
|
+
headers: Pick<Headers, "get">;
|
|
1057
1052
|
};
|
|
1058
|
-
type ReadonlyContext =
|
|
1053
|
+
type ReadonlyContext = Pick<RouterContextProvider, "get">;
|
|
1059
1054
|
type InstrumentableRoute = {
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1055
|
+
id: string;
|
|
1056
|
+
index: boolean | undefined;
|
|
1057
|
+
path: string | undefined;
|
|
1058
|
+
instrument(instrumentations: RouteInstrumentations): void;
|
|
1064
1059
|
};
|
|
1065
1060
|
type RouteInstrumentations = {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1061
|
+
lazy?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
|
1062
|
+
"lazy.loader"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
|
1063
|
+
"lazy.action"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
|
1064
|
+
"lazy.middleware"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
|
1065
|
+
middleware?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
|
|
1066
|
+
loader?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
|
|
1067
|
+
action?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
|
|
1073
1068
|
};
|
|
1074
1069
|
type RouteLazyInstrumentationInfo = undefined;
|
|
1075
|
-
type RouteHandlerInstrumentationInfo = Readonly<{
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
pattern: string;
|
|
1079
|
-
context: ReadonlyContext;
|
|
1070
|
+
type RouteHandlerInstrumentationInfo = Readonly<Omit<LoaderFunctionArgs, "request" | "context"> & {
|
|
1071
|
+
request: ReadonlyRequest;
|
|
1072
|
+
context: ReadonlyContext;
|
|
1080
1073
|
}>;
|
|
1081
1074
|
type InstrumentableRouter = {
|
|
1082
|
-
|
|
1075
|
+
instrument(instrumentations: RouterInstrumentations): void;
|
|
1083
1076
|
};
|
|
1084
1077
|
type RouterInstrumentations = {
|
|
1085
|
-
|
|
1086
|
-
|
|
1078
|
+
navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo, InstrumentationClientRouterResult>;
|
|
1079
|
+
fetch?: InstrumentFunction<RouterFetchInstrumentationInfo, InstrumentationClientRouterResult>;
|
|
1087
1080
|
};
|
|
1088
1081
|
type RouterNavigationInstrumentationInfo = Readonly<{
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1082
|
+
to: string | number;
|
|
1083
|
+
currentUrl: string;
|
|
1084
|
+
formMethod?: HTMLFormMethod;
|
|
1085
|
+
formEncType?: FormEncType;
|
|
1086
|
+
formData?: FormData;
|
|
1087
|
+
body?: any;
|
|
1095
1088
|
}>;
|
|
1096
1089
|
type RouterFetchInstrumentationInfo = Readonly<{
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1090
|
+
href: string;
|
|
1091
|
+
currentUrl: string;
|
|
1092
|
+
fetcherKey: string;
|
|
1093
|
+
formMethod?: HTMLFormMethod;
|
|
1094
|
+
formEncType?: FormEncType;
|
|
1095
|
+
formData?: FormData;
|
|
1096
|
+
body?: any;
|
|
1104
1097
|
}>;
|
|
1105
1098
|
type InstrumentableRequestHandler = {
|
|
1106
|
-
|
|
1099
|
+
instrument(instrumentations: RequestHandlerInstrumentations): void;
|
|
1107
1100
|
};
|
|
1108
1101
|
type RequestHandlerInstrumentations = {
|
|
1109
|
-
|
|
1102
|
+
request?: InstrumentFunction<RequestHandlerInstrumentationInfo, InstrumentationServerHandlerResult>;
|
|
1110
1103
|
};
|
|
1111
1104
|
type RequestHandlerInstrumentationInfo = Readonly<{
|
|
1112
|
-
|
|
1113
|
-
|
|
1105
|
+
request: ReadonlyRequest;
|
|
1106
|
+
context: ReadonlyContext | undefined;
|
|
1114
1107
|
}>;
|
|
1115
|
-
|
|
1108
|
+
//#endregion
|
|
1109
|
+
//#region lib/router/router.d.ts
|
|
1116
1110
|
/**
|
|
1117
1111
|
* A Router instance manages all navigation and data loading/mutations
|
|
1118
1112
|
*/
|
|
1119
|
-
interface Router {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1113
|
+
interface Router$1 {
|
|
1114
|
+
/**
|
|
1115
|
+
* @private
|
|
1116
|
+
* PRIVATE - DO NOT USE
|
|
1117
|
+
*
|
|
1118
|
+
* Return the basename for the router
|
|
1119
|
+
*/
|
|
1120
|
+
get basename(): RouterInit["basename"];
|
|
1121
|
+
/**
|
|
1122
|
+
* @private
|
|
1123
|
+
* PRIVATE - DO NOT USE
|
|
1124
|
+
*
|
|
1125
|
+
* Return the future config for the router
|
|
1126
|
+
*/
|
|
1127
|
+
get future(): FutureConfig;
|
|
1128
|
+
/**
|
|
1129
|
+
* @private
|
|
1130
|
+
* PRIVATE - DO NOT USE
|
|
1131
|
+
*
|
|
1132
|
+
* Return the current state of the router
|
|
1133
|
+
*/
|
|
1134
|
+
get state(): RouterState;
|
|
1135
|
+
/**
|
|
1136
|
+
* @private
|
|
1137
|
+
* PRIVATE - DO NOT USE
|
|
1138
|
+
*
|
|
1139
|
+
* Return the routes for this router instance
|
|
1140
|
+
*/
|
|
1141
|
+
get routes(): DataRouteObject[];
|
|
1142
|
+
/**
|
|
1143
|
+
* @private
|
|
1144
|
+
* PRIVATE - DO NOT USE
|
|
1145
|
+
*
|
|
1146
|
+
* Return the route branches for this router instance
|
|
1147
|
+
*/
|
|
1148
|
+
get branches(): RouteBranch<DataRouteObject>[] | undefined;
|
|
1149
|
+
/**
|
|
1150
|
+
* @private
|
|
1151
|
+
* PRIVATE - DO NOT USE
|
|
1152
|
+
*
|
|
1153
|
+
* Return the manifest for this router instance
|
|
1154
|
+
*/
|
|
1155
|
+
get manifest(): RouteManifest;
|
|
1156
|
+
/**
|
|
1157
|
+
* @private
|
|
1158
|
+
* PRIVATE - DO NOT USE
|
|
1159
|
+
*
|
|
1160
|
+
* Return the window associated with the router
|
|
1161
|
+
*/
|
|
1162
|
+
get window(): RouterInit["window"];
|
|
1163
|
+
/**
|
|
1164
|
+
* @private
|
|
1165
|
+
* PRIVATE - DO NOT USE
|
|
1166
|
+
*
|
|
1167
|
+
* Initialize the router, including adding history listeners and kicking off
|
|
1168
|
+
* initial data fetches. Returns a function to cleanup listeners and abort
|
|
1169
|
+
* any in-progress loads
|
|
1170
|
+
*/
|
|
1171
|
+
initialize(): Router$1;
|
|
1172
|
+
/**
|
|
1173
|
+
* @private
|
|
1174
|
+
* PRIVATE - DO NOT USE
|
|
1175
|
+
*
|
|
1176
|
+
* Subscribe to router.state updates
|
|
1177
|
+
*
|
|
1178
|
+
* @param fn function to call with the new state
|
|
1179
|
+
*/
|
|
1180
|
+
subscribe(fn: RouterSubscriber): () => void;
|
|
1181
|
+
/**
|
|
1182
|
+
* @private
|
|
1183
|
+
* PRIVATE - DO NOT USE
|
|
1184
|
+
*
|
|
1185
|
+
* Enable scroll restoration behavior in the router
|
|
1186
|
+
*
|
|
1187
|
+
* @param savedScrollPositions Object that will manage positions, in case
|
|
1188
|
+
* it's being restored from sessionStorage
|
|
1189
|
+
* @param getScrollPosition Function to get the active Y scroll position
|
|
1190
|
+
* @param getKey Function to get the key to use for restoration
|
|
1191
|
+
*/
|
|
1192
|
+
enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
|
|
1193
|
+
/**
|
|
1194
|
+
* @private
|
|
1195
|
+
* PRIVATE - DO NOT USE
|
|
1196
|
+
*
|
|
1197
|
+
* Navigate forward/backward in the history stack
|
|
1198
|
+
* @param to Delta to move in the history stack
|
|
1199
|
+
*/
|
|
1200
|
+
navigate(to: number): Promise<void>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Navigate to the given path
|
|
1203
|
+
* @param to Path to navigate to
|
|
1204
|
+
* @param opts Navigation options (method, submission, etc.)
|
|
1205
|
+
*/
|
|
1206
|
+
navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
|
|
1207
|
+
/**
|
|
1208
|
+
* @private
|
|
1209
|
+
* PRIVATE - DO NOT USE
|
|
1210
|
+
*
|
|
1211
|
+
* Trigger a fetcher load/submission
|
|
1212
|
+
*
|
|
1213
|
+
* @param key Fetcher key
|
|
1214
|
+
* @param routeId Route that owns the fetcher
|
|
1215
|
+
* @param href href to fetch
|
|
1216
|
+
* @param opts Fetcher options, (method, submission, etc.)
|
|
1217
|
+
*/
|
|
1218
|
+
fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): Promise<void>;
|
|
1219
|
+
/**
|
|
1220
|
+
* @private
|
|
1221
|
+
* PRIVATE - DO NOT USE
|
|
1222
|
+
*
|
|
1223
|
+
* Trigger a revalidation of all current route loaders and fetcher loads
|
|
1224
|
+
*/
|
|
1225
|
+
revalidate(): Promise<void>;
|
|
1226
|
+
/**
|
|
1227
|
+
* @private
|
|
1228
|
+
* PRIVATE - DO NOT USE
|
|
1229
|
+
*
|
|
1230
|
+
* Utility function to create an href for the given location
|
|
1231
|
+
* @param location
|
|
1232
|
+
*/
|
|
1233
|
+
createHref(location: Location | URL): string;
|
|
1234
|
+
/**
|
|
1235
|
+
* @private
|
|
1236
|
+
* PRIVATE - DO NOT USE
|
|
1237
|
+
*
|
|
1238
|
+
* Utility function to URL encode a destination path according to the internal
|
|
1239
|
+
* history implementation
|
|
1240
|
+
* @param to
|
|
1241
|
+
*/
|
|
1242
|
+
encodeLocation(to: To): Path;
|
|
1243
|
+
/**
|
|
1244
|
+
* @private
|
|
1245
|
+
* PRIVATE - DO NOT USE
|
|
1246
|
+
*
|
|
1247
|
+
* Get/create a fetcher for the given key
|
|
1248
|
+
* @param key
|
|
1249
|
+
*/
|
|
1250
|
+
getFetcher<TData = any>(key: string): Fetcher<TData>;
|
|
1251
|
+
/**
|
|
1252
|
+
* @internal
|
|
1253
|
+
* PRIVATE - DO NOT USE
|
|
1254
|
+
*
|
|
1255
|
+
* Reset the fetcher for a given key
|
|
1256
|
+
* @param key
|
|
1257
|
+
*/
|
|
1258
|
+
resetFetcher(key: string, opts?: {
|
|
1259
|
+
reason?: unknown;
|
|
1260
|
+
}): void;
|
|
1261
|
+
/**
|
|
1262
|
+
* @private
|
|
1263
|
+
* PRIVATE - DO NOT USE
|
|
1264
|
+
*
|
|
1265
|
+
* Delete the fetcher for a given key
|
|
1266
|
+
* @param key
|
|
1267
|
+
*/
|
|
1268
|
+
deleteFetcher(key: string): void;
|
|
1269
|
+
/**
|
|
1270
|
+
* @private
|
|
1271
|
+
* PRIVATE - DO NOT USE
|
|
1272
|
+
*
|
|
1273
|
+
* Cleanup listeners and abort any in-progress loads
|
|
1274
|
+
*/
|
|
1275
|
+
dispose(): void;
|
|
1276
|
+
/**
|
|
1277
|
+
* @private
|
|
1278
|
+
* PRIVATE - DO NOT USE
|
|
1279
|
+
*
|
|
1280
|
+
* Get a navigation blocker
|
|
1281
|
+
* @param key The identifier for the blocker
|
|
1282
|
+
* @param fn The blocker function implementation
|
|
1283
|
+
*/
|
|
1284
|
+
getBlocker(key: string, fn: BlockerFunction): Blocker;
|
|
1285
|
+
/**
|
|
1286
|
+
* @private
|
|
1287
|
+
* PRIVATE - DO NOT USE
|
|
1288
|
+
*
|
|
1289
|
+
* Delete a navigation blocker
|
|
1290
|
+
* @param key The identifier for the blocker
|
|
1291
|
+
*/
|
|
1292
|
+
deleteBlocker(key: string): void;
|
|
1293
|
+
/**
|
|
1294
|
+
* @private
|
|
1295
|
+
* PRIVATE DO NOT USE
|
|
1296
|
+
*
|
|
1297
|
+
* Patch additional children routes into an existing parent route
|
|
1298
|
+
* @param routeId The parent route id or a callback function accepting `patch`
|
|
1299
|
+
* to perform batch patching
|
|
1300
|
+
* @param children The additional children routes
|
|
1301
|
+
* @param unstable_allowElementMutations Allow mutation or route elements on
|
|
1302
|
+
* existing routes. Intended for RSC-usage
|
|
1303
|
+
* only.
|
|
1304
|
+
*/
|
|
1305
|
+
patchRoutes(routeId: string | null, children: RouteObject[], unstable_allowElementMutations?: boolean): void;
|
|
1306
|
+
/**
|
|
1307
|
+
* @private
|
|
1308
|
+
* PRIVATE - DO NOT USE
|
|
1309
|
+
*
|
|
1310
|
+
* HMR needs to pass in-flight route updates to React Router
|
|
1311
|
+
* TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
|
|
1312
|
+
*/
|
|
1313
|
+
_internalSetRoutes(routes: RouteObject[]): void;
|
|
1314
|
+
/**
|
|
1315
|
+
* @private
|
|
1316
|
+
* PRIVATE - DO NOT USE
|
|
1317
|
+
*
|
|
1318
|
+
* Cause subscribers to re-render. This is used to force a re-render.
|
|
1319
|
+
*/
|
|
1320
|
+
_internalSetStateDoNotUseOrYouWillBreakYourApp(state: Partial<RouterState>): void;
|
|
1321
|
+
/**
|
|
1322
|
+
* @private
|
|
1323
|
+
* PRIVATE - DO NOT USE
|
|
1324
|
+
*
|
|
1325
|
+
* Internal fetch AbortControllers accessed by unit tests
|
|
1326
|
+
*/
|
|
1327
|
+
_internalFetchControllers: Map<string, AbortController>;
|
|
1334
1328
|
}
|
|
1335
1329
|
/**
|
|
1336
1330
|
* State maintained internally by the router. During a navigation, all states
|
|
1337
1331
|
* reflect the "old" location unless otherwise noted.
|
|
1338
1332
|
*/
|
|
1339
1333
|
interface RouterState {
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1334
|
+
/**
|
|
1335
|
+
* The action of the most recent navigation
|
|
1336
|
+
*/
|
|
1337
|
+
historyAction: Action;
|
|
1338
|
+
/**
|
|
1339
|
+
* The current location reflected by the router
|
|
1340
|
+
*/
|
|
1341
|
+
location: Location;
|
|
1342
|
+
/**
|
|
1343
|
+
* The current set of route matches
|
|
1344
|
+
*/
|
|
1345
|
+
matches: DataRouteMatch[];
|
|
1346
|
+
/**
|
|
1347
|
+
* Tracks whether we've completed our initial data load
|
|
1348
|
+
*/
|
|
1349
|
+
initialized: boolean;
|
|
1350
|
+
/**
|
|
1351
|
+
* Tracks whether we should be rendering a HydrateFallback during hydration
|
|
1352
|
+
*/
|
|
1353
|
+
renderFallback: boolean;
|
|
1354
|
+
/**
|
|
1355
|
+
* Current scroll position we should start at for a new view
|
|
1356
|
+
* - number -> scroll position to restore to
|
|
1357
|
+
* - false -> do not restore scroll at all (used during submissions/revalidations)
|
|
1358
|
+
* - null -> don't have a saved position, scroll to hash or top of page
|
|
1359
|
+
*/
|
|
1360
|
+
restoreScrollPosition: number | false | null;
|
|
1361
|
+
/**
|
|
1362
|
+
* Indicate whether this navigation should skip resetting the scroll position
|
|
1363
|
+
* if we are unable to restore the scroll position
|
|
1364
|
+
*/
|
|
1365
|
+
preventScrollReset: boolean;
|
|
1366
|
+
/**
|
|
1367
|
+
* Tracks the state of the current navigation
|
|
1368
|
+
*/
|
|
1369
|
+
navigation: Navigation;
|
|
1370
|
+
/**
|
|
1371
|
+
* Tracks any in-progress revalidations
|
|
1372
|
+
*/
|
|
1373
|
+
revalidation: RevalidationState;
|
|
1374
|
+
/**
|
|
1375
|
+
* Data from the loaders for the current matches
|
|
1376
|
+
*/
|
|
1377
|
+
loaderData: RouteData;
|
|
1378
|
+
/**
|
|
1379
|
+
* Data from the action for the current matches
|
|
1380
|
+
*/
|
|
1381
|
+
actionData: RouteData | null;
|
|
1382
|
+
/**
|
|
1383
|
+
* Errors caught from loaders for the current matches
|
|
1384
|
+
*/
|
|
1385
|
+
errors: RouteData | null;
|
|
1386
|
+
/**
|
|
1387
|
+
* Map of current fetchers
|
|
1388
|
+
*/
|
|
1389
|
+
fetchers: Map<string, Fetcher>;
|
|
1390
|
+
/**
|
|
1391
|
+
* Map of current blockers
|
|
1392
|
+
*/
|
|
1393
|
+
blockers: Map<string, Blocker>;
|
|
1400
1394
|
}
|
|
1401
1395
|
/**
|
|
1402
1396
|
* Data that can be passed into hydrate a Router from SSR
|
|
@@ -1405,130 +1399,128 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
|
|
|
1405
1399
|
/**
|
|
1406
1400
|
* Future flags to toggle new feature behavior
|
|
1407
1401
|
*/
|
|
1408
|
-
interface FutureConfig {
|
|
1409
|
-
}
|
|
1402
|
+
interface FutureConfig {}
|
|
1410
1403
|
/**
|
|
1411
1404
|
* Initialization options for createRouter
|
|
1412
1405
|
*/
|
|
1413
1406
|
interface RouterInit {
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1407
|
+
routes: RouteObject[];
|
|
1408
|
+
history: History;
|
|
1409
|
+
basename?: string;
|
|
1410
|
+
getContext?: () => MaybePromise<RouterContextProvider>;
|
|
1411
|
+
instrumentations?: ClientInstrumentation[];
|
|
1412
|
+
mapRouteProperties?: MapRoutePropertiesFunction;
|
|
1413
|
+
future?: Partial<FutureConfig>;
|
|
1414
|
+
hydrationRouteProperties?: string[];
|
|
1415
|
+
hydrationData?: HydrationState;
|
|
1416
|
+
window?: Window;
|
|
1417
|
+
dataStrategy?: DataStrategyFunction;
|
|
1418
|
+
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
|
|
1426
1419
|
}
|
|
1427
1420
|
/**
|
|
1428
1421
|
* State returned from a server-side query() call
|
|
1429
1422
|
*/
|
|
1430
1423
|
interface StaticHandlerContext {
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1424
|
+
basename: Router$1["basename"];
|
|
1425
|
+
location: RouterState["location"];
|
|
1426
|
+
matches: RouterState["matches"];
|
|
1427
|
+
loaderData: RouterState["loaderData"];
|
|
1428
|
+
actionData: RouterState["actionData"];
|
|
1429
|
+
errors: RouterState["errors"];
|
|
1430
|
+
statusCode: number;
|
|
1431
|
+
loaderHeaders: Record<string, Headers>;
|
|
1432
|
+
actionHeaders: Record<string, Headers>;
|
|
1433
|
+
_deepestRenderedBoundaryId?: string | null;
|
|
1441
1434
|
}
|
|
1442
1435
|
/**
|
|
1443
1436
|
* A StaticHandler instance manages a singular SSR navigation/fetch event
|
|
1444
1437
|
*/
|
|
1445
1438
|
interface StaticHandler {
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
}): Promise<any>;
|
|
1439
|
+
/**
|
|
1440
|
+
* The set of data routes managed by this handler
|
|
1441
|
+
*/
|
|
1442
|
+
dataRoutes: DataRouteObject[];
|
|
1443
|
+
/**
|
|
1444
|
+
* @private
|
|
1445
|
+
* PRIVATE - DO NOT USE
|
|
1446
|
+
*
|
|
1447
|
+
* The route branches derived from the data routes, used for internal route
|
|
1448
|
+
* matching in Framework Mode
|
|
1449
|
+
*/
|
|
1450
|
+
_internalRouteBranches: RouteBranch<DataRouteObject>[];
|
|
1451
|
+
/**
|
|
1452
|
+
* Perform a query for a given request - executing all matched route
|
|
1453
|
+
* loaders/actions. Used for document requests.
|
|
1454
|
+
*
|
|
1455
|
+
* @param request The request to query
|
|
1456
|
+
* @param opts Optional query options
|
|
1457
|
+
* @param opts.dataStrategy Alternate dataStrategy implementation
|
|
1458
|
+
* @param opts.filterMatchesToLoad Predicate function to filter which matches should be loaded
|
|
1459
|
+
* @param opts.generateMiddlewareResponse To enable middleware, provide a function
|
|
1460
|
+
* to generate a response to bubble back up the middleware chain
|
|
1461
|
+
* @param opts.requestContext Context object to pass to loaders/actions
|
|
1462
|
+
* @param opts.skipLoaderErrorBubbling Skip loader error bubbling
|
|
1463
|
+
* @param opts.skipRevalidation Skip revalidation after action submission
|
|
1464
|
+
* @param opts.normalizePath Normalize the request path
|
|
1465
|
+
*/
|
|
1466
|
+
query(request: Request, opts?: {
|
|
1467
|
+
requestContext?: unknown;
|
|
1468
|
+
filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
|
|
1469
|
+
skipLoaderErrorBubbling?: boolean;
|
|
1470
|
+
skipRevalidation?: boolean;
|
|
1471
|
+
dataStrategy?: DataStrategyFunction<unknown>;
|
|
1472
|
+
generateMiddlewareResponse?: (query: (r: Request, args?: {
|
|
1473
|
+
filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
|
|
1474
|
+
}) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
|
|
1475
|
+
normalizePath?: (request: Request) => Path;
|
|
1476
|
+
}): Promise<StaticHandlerContext | Response>;
|
|
1477
|
+
/**
|
|
1478
|
+
* Perform a query for a specific route. Used for resource requests.
|
|
1479
|
+
*
|
|
1480
|
+
* @param request The request to query
|
|
1481
|
+
* @param opts Optional queryRoute options
|
|
1482
|
+
* @param opts.dataStrategy Alternate dataStrategy implementation
|
|
1483
|
+
* @param opts.generateMiddlewareResponse To enable middleware, provide a function
|
|
1484
|
+
* to generate a response to bubble back up the middleware chain
|
|
1485
|
+
* @param opts.requestContext Context object to pass to loaders/actions
|
|
1486
|
+
* @param opts.routeId The ID of the route to query
|
|
1487
|
+
* @param opts.normalizePath Normalize the request path
|
|
1488
|
+
*/
|
|
1489
|
+
queryRoute(request: Request, opts?: {
|
|
1490
|
+
routeId?: string;
|
|
1491
|
+
requestContext?: unknown;
|
|
1492
|
+
dataStrategy?: DataStrategyFunction<unknown>;
|
|
1493
|
+
generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
|
|
1494
|
+
normalizePath?: (request: Request) => Path;
|
|
1495
|
+
}): Promise<any>;
|
|
1504
1496
|
}
|
|
1505
1497
|
type ViewTransitionOpts = {
|
|
1506
|
-
|
|
1507
|
-
|
|
1498
|
+
currentLocation: Location;
|
|
1499
|
+
nextLocation: Location;
|
|
1508
1500
|
};
|
|
1509
1501
|
/**
|
|
1510
1502
|
* Subscriber function signature for changes to router state
|
|
1511
1503
|
*/
|
|
1512
1504
|
interface RouterSubscriber {
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1505
|
+
(state: RouterState, opts: {
|
|
1506
|
+
deletedFetchers: string[];
|
|
1507
|
+
newErrors: RouteData | null;
|
|
1508
|
+
viewTransitionOpts?: ViewTransitionOpts;
|
|
1509
|
+
flushSync: boolean;
|
|
1510
|
+
}): void;
|
|
1519
1511
|
}
|
|
1520
1512
|
/**
|
|
1521
1513
|
* Function signature for determining the key to be used in scroll restoration
|
|
1522
1514
|
* for a given location
|
|
1523
1515
|
*/
|
|
1524
1516
|
interface GetScrollRestorationKeyFunction {
|
|
1525
|
-
|
|
1517
|
+
(location: Location, matches: UIMatch[]): string | null;
|
|
1526
1518
|
}
|
|
1527
1519
|
/**
|
|
1528
1520
|
* Function signature for determining the current scroll position
|
|
1529
1521
|
*/
|
|
1530
1522
|
interface GetScrollPositionFunction {
|
|
1531
|
-
|
|
1523
|
+
(): number;
|
|
1532
1524
|
}
|
|
1533
1525
|
/**
|
|
1534
1526
|
* - "route": relative to the route hierarchy so `..` means remove all segments
|
|
@@ -1540,27 +1532,27 @@ interface GetScrollPositionFunction {
|
|
|
1540
1532
|
*/
|
|
1541
1533
|
type RelativeRoutingType = "route" | "path";
|
|
1542
1534
|
type BaseNavigateOrFetchOptions = {
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1535
|
+
preventScrollReset?: boolean;
|
|
1536
|
+
relative?: RelativeRoutingType;
|
|
1537
|
+
flushSync?: boolean;
|
|
1538
|
+
defaultShouldRevalidate?: boolean;
|
|
1547
1539
|
};
|
|
1548
1540
|
type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1541
|
+
replace?: boolean;
|
|
1542
|
+
state?: any;
|
|
1543
|
+
fromRouteId?: string;
|
|
1544
|
+
viewTransition?: boolean;
|
|
1545
|
+
mask?: To;
|
|
1554
1546
|
};
|
|
1555
1547
|
type BaseSubmissionOptions = {
|
|
1556
|
-
|
|
1557
|
-
|
|
1548
|
+
formMethod?: HTMLFormMethod;
|
|
1549
|
+
formEncType?: FormEncType;
|
|
1558
1550
|
} & ({
|
|
1559
|
-
|
|
1560
|
-
|
|
1551
|
+
formData: FormData;
|
|
1552
|
+
body?: undefined;
|
|
1561
1553
|
} | {
|
|
1562
|
-
|
|
1563
|
-
|
|
1554
|
+
formData?: undefined;
|
|
1555
|
+
body: any;
|
|
1564
1556
|
});
|
|
1565
1557
|
/**
|
|
1566
1558
|
* Options for a navigate() call for a normal (non-submission) navigation
|
|
@@ -1590,42 +1582,42 @@ type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
|
|
|
1590
1582
|
* Potential states for state.navigation
|
|
1591
1583
|
*/
|
|
1592
1584
|
type NavigationStates = {
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1585
|
+
Idle: {
|
|
1586
|
+
state: "idle";
|
|
1587
|
+
location: undefined;
|
|
1588
|
+
matches: undefined;
|
|
1589
|
+
historyAction: undefined;
|
|
1590
|
+
formMethod: undefined;
|
|
1591
|
+
formAction: undefined;
|
|
1592
|
+
formEncType: undefined;
|
|
1593
|
+
formData: undefined;
|
|
1594
|
+
json: undefined;
|
|
1595
|
+
text: undefined;
|
|
1596
|
+
};
|
|
1597
|
+
Loading: {
|
|
1598
|
+
state: "loading";
|
|
1599
|
+
location: Location;
|
|
1600
|
+
matches: DataRouteMatch[];
|
|
1601
|
+
historyAction: Action;
|
|
1602
|
+
formMethod: Submission["formMethod"] | undefined;
|
|
1603
|
+
formAction: Submission["formAction"] | undefined;
|
|
1604
|
+
formEncType: Submission["formEncType"] | undefined;
|
|
1605
|
+
formData: Submission["formData"] | undefined;
|
|
1606
|
+
json: Submission["json"] | undefined;
|
|
1607
|
+
text: Submission["text"] | undefined;
|
|
1608
|
+
};
|
|
1609
|
+
Submitting: {
|
|
1610
|
+
state: "submitting";
|
|
1611
|
+
location: Location;
|
|
1612
|
+
matches: DataRouteMatch[];
|
|
1613
|
+
historyAction: Action;
|
|
1614
|
+
formMethod: Submission["formMethod"];
|
|
1615
|
+
formAction: Submission["formAction"];
|
|
1616
|
+
formEncType: Submission["formEncType"];
|
|
1617
|
+
formData: Submission["formData"];
|
|
1618
|
+
json: Submission["json"];
|
|
1619
|
+
text: Submission["text"];
|
|
1620
|
+
};
|
|
1629
1621
|
};
|
|
1630
1622
|
type Navigation = NavigationStates[keyof NavigationStates];
|
|
1631
1623
|
type RevalidationState = "idle" | "loading";
|
|
@@ -1633,197 +1625,225 @@ type RevalidationState = "idle" | "loading";
|
|
|
1633
1625
|
* Potential states for fetchers
|
|
1634
1626
|
*/
|
|
1635
1627
|
type FetcherStates<TData = any> = {
|
|
1628
|
+
/**
|
|
1629
|
+
* The fetcher is not calling a loader or action
|
|
1630
|
+
*
|
|
1631
|
+
* ```tsx
|
|
1632
|
+
* fetcher.state === "idle"
|
|
1633
|
+
* ```
|
|
1634
|
+
*/
|
|
1635
|
+
Idle: {
|
|
1636
|
+
state: "idle";
|
|
1637
|
+
formMethod: undefined;
|
|
1638
|
+
formAction: undefined;
|
|
1639
|
+
formEncType: undefined;
|
|
1640
|
+
text: undefined;
|
|
1641
|
+
formData: undefined;
|
|
1642
|
+
json: undefined;
|
|
1636
1643
|
/**
|
|
1637
|
-
*
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
// the state will update
|
|
1690
|
-
fetcher.state === "submitting"
|
|
1691
|
-
|
|
1692
|
-
// and formData will be available
|
|
1693
|
-
fetcher.formData
|
|
1694
|
-
```
|
|
1695
|
-
*/
|
|
1696
|
-
Submitting: {
|
|
1697
|
-
state: "submitting";
|
|
1698
|
-
formMethod: Submission["formMethod"];
|
|
1699
|
-
formAction: Submission["formAction"];
|
|
1700
|
-
formEncType: Submission["formEncType"];
|
|
1701
|
-
text: Submission["text"];
|
|
1702
|
-
formData: Submission["formData"];
|
|
1703
|
-
json: Submission["json"];
|
|
1704
|
-
data: TData | undefined;
|
|
1705
|
-
};
|
|
1644
|
+
* If the fetcher has never been called, this will be undefined.
|
|
1645
|
+
*/
|
|
1646
|
+
data: TData | undefined;
|
|
1647
|
+
};
|
|
1648
|
+
/**
|
|
1649
|
+
* The fetcher is loading data from a {@link LoaderFunction | loader} from a
|
|
1650
|
+
* call to {@link FetcherWithComponents.load | `fetcher.load`}.
|
|
1651
|
+
*
|
|
1652
|
+
* ```tsx
|
|
1653
|
+
* // somewhere
|
|
1654
|
+
* <button onClick={() => fetcher.load("/some/route") }>Load</button>
|
|
1655
|
+
*
|
|
1656
|
+
* // the state will update
|
|
1657
|
+
* fetcher.state === "loading"
|
|
1658
|
+
* ```
|
|
1659
|
+
*/
|
|
1660
|
+
Loading: {
|
|
1661
|
+
state: "loading";
|
|
1662
|
+
formMethod: Submission["formMethod"] | undefined;
|
|
1663
|
+
formAction: Submission["formAction"] | undefined;
|
|
1664
|
+
formEncType: Submission["formEncType"] | undefined;
|
|
1665
|
+
text: Submission["text"] | undefined;
|
|
1666
|
+
formData: Submission["formData"] | undefined;
|
|
1667
|
+
json: Submission["json"] | undefined;
|
|
1668
|
+
data: TData | undefined;
|
|
1669
|
+
};
|
|
1670
|
+
/**
|
|
1671
|
+
The fetcher is submitting to a {@link LoaderFunction} (GET) or {@link ActionFunction} (POST) from a {@link FetcherWithComponents.Form | `fetcher.Form`} or {@link FetcherWithComponents.submit | `fetcher.submit`}.
|
|
1672
|
+
```tsx
|
|
1673
|
+
// somewhere
|
|
1674
|
+
<input
|
|
1675
|
+
onChange={e => {
|
|
1676
|
+
fetcher.submit(event.currentTarget.form, { method: "post" });
|
|
1677
|
+
}}
|
|
1678
|
+
/>
|
|
1679
|
+
// the state will update
|
|
1680
|
+
fetcher.state === "submitting"
|
|
1681
|
+
// and formData will be available
|
|
1682
|
+
fetcher.formData
|
|
1683
|
+
```
|
|
1684
|
+
*/
|
|
1685
|
+
Submitting: {
|
|
1686
|
+
state: "submitting";
|
|
1687
|
+
formMethod: Submission["formMethod"];
|
|
1688
|
+
formAction: Submission["formAction"];
|
|
1689
|
+
formEncType: Submission["formEncType"];
|
|
1690
|
+
text: Submission["text"];
|
|
1691
|
+
formData: Submission["formData"];
|
|
1692
|
+
json: Submission["json"];
|
|
1693
|
+
data: TData | undefined;
|
|
1694
|
+
};
|
|
1706
1695
|
};
|
|
1707
1696
|
type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
|
|
1708
1697
|
interface BlockerBlocked {
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1698
|
+
state: "blocked";
|
|
1699
|
+
reset: () => void;
|
|
1700
|
+
proceed: () => void;
|
|
1701
|
+
location: Location;
|
|
1713
1702
|
}
|
|
1714
1703
|
interface BlockerUnblocked {
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1704
|
+
state: "unblocked";
|
|
1705
|
+
reset: undefined;
|
|
1706
|
+
proceed: undefined;
|
|
1707
|
+
location: undefined;
|
|
1719
1708
|
}
|
|
1720
1709
|
interface BlockerProceeding {
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1710
|
+
state: "proceeding";
|
|
1711
|
+
reset: undefined;
|
|
1712
|
+
proceed: undefined;
|
|
1713
|
+
location: Location;
|
|
1725
1714
|
}
|
|
1726
1715
|
type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
|
|
1727
1716
|
type BlockerFunction = (args: {
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1717
|
+
currentLocation: Location;
|
|
1718
|
+
nextLocation: Location;
|
|
1719
|
+
historyAction: Action;
|
|
1731
1720
|
}) => boolean;
|
|
1732
1721
|
interface CreateStaticHandlerOptions {
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1722
|
+
basename?: string;
|
|
1723
|
+
mapRouteProperties?: MapRoutePropertiesFunction;
|
|
1724
|
+
instrumentations?: Pick<ServerInstrumentation, "route">[];
|
|
1725
|
+
future?: Partial<FutureConfig>;
|
|
1737
1726
|
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Create a static handler to perform server-side data loading
|
|
1729
|
+
*
|
|
1730
|
+
* @example
|
|
1731
|
+
* export async function handleRequest(request: Request) {
|
|
1732
|
+
* let { query, dataRoutes } = createStaticHandler(routes);
|
|
1733
|
+
* let context = await query(request);
|
|
1734
|
+
*
|
|
1735
|
+
* if (context instanceof Response) {
|
|
1736
|
+
* return context;
|
|
1737
|
+
* }
|
|
1738
|
+
*
|
|
1739
|
+
* let router = createStaticRouter(dataRoutes, context);
|
|
1740
|
+
* return new Response(
|
|
1741
|
+
* ReactDOMServer.renderToString(<StaticRouterProvider ... />),
|
|
1742
|
+
* { headers: { "Content-Type": "text/html" } }
|
|
1743
|
+
* );
|
|
1744
|
+
* }
|
|
1745
|
+
*
|
|
1746
|
+
* @public
|
|
1747
|
+
* @category Data Routers
|
|
1748
|
+
* @mode data
|
|
1749
|
+
* @param routes The {@link RouteObject | route objects} to create a static
|
|
1750
|
+
* handler for
|
|
1751
|
+
* @param opts Options
|
|
1752
|
+
* @param opts.basename The base URL for the static handler (default: `/`)
|
|
1753
|
+
* @param opts.future Future flags for the static handler
|
|
1754
|
+
* @returns A static handler that can be used to query data for the provided
|
|
1755
|
+
* routes
|
|
1756
|
+
*/
|
|
1738
1757
|
declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
|
|
1739
|
-
|
|
1758
|
+
//#endregion
|
|
1759
|
+
//#region lib/router/links.d.ts
|
|
1740
1760
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
1741
1761
|
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
1742
1762
|
interface HtmlLinkProps {
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1763
|
+
/**
|
|
1764
|
+
* Address of the hyperlink
|
|
1765
|
+
*/
|
|
1766
|
+
href?: string;
|
|
1767
|
+
/**
|
|
1768
|
+
* How the element handles crossorigin requests
|
|
1769
|
+
*/
|
|
1770
|
+
crossOrigin?: "anonymous" | "use-credentials";
|
|
1771
|
+
/**
|
|
1772
|
+
* Relationship between the document containing the hyperlink and the destination resource
|
|
1773
|
+
*/
|
|
1774
|
+
rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
|
|
1775
|
+
/**
|
|
1776
|
+
* Applicable media: "screen", "print", "(max-width: 764px)"
|
|
1777
|
+
*/
|
|
1778
|
+
media?: string;
|
|
1779
|
+
/**
|
|
1780
|
+
* Integrity metadata used in Subresource Integrity checks
|
|
1781
|
+
*/
|
|
1782
|
+
integrity?: string;
|
|
1783
|
+
/**
|
|
1784
|
+
* Language of the linked resource
|
|
1785
|
+
*/
|
|
1786
|
+
hrefLang?: string;
|
|
1787
|
+
/**
|
|
1788
|
+
* Hint for the type of the referenced resource
|
|
1789
|
+
*/
|
|
1790
|
+
type?: string;
|
|
1791
|
+
/**
|
|
1792
|
+
* Referrer policy for fetches initiated by the element
|
|
1793
|
+
*/
|
|
1794
|
+
referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
1795
|
+
/**
|
|
1796
|
+
* Sizes of the icons (for rel="icon")
|
|
1797
|
+
*/
|
|
1798
|
+
sizes?: string;
|
|
1799
|
+
/**
|
|
1800
|
+
* Potential destination for a preload request (for rel="preload" and rel="modulepreload")
|
|
1801
|
+
*/
|
|
1802
|
+
as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
|
|
1803
|
+
/**
|
|
1804
|
+
* Color to use when customizing a site's icon (for rel="mask-icon")
|
|
1805
|
+
*/
|
|
1806
|
+
color?: string;
|
|
1807
|
+
/**
|
|
1808
|
+
* Whether the link is disabled
|
|
1809
|
+
*/
|
|
1810
|
+
disabled?: boolean;
|
|
1811
|
+
/**
|
|
1812
|
+
* The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
|
|
1813
|
+
*/
|
|
1814
|
+
title?: string;
|
|
1815
|
+
/**
|
|
1816
|
+
* Images to use in different situations, e.g., high-resolution displays,
|
|
1817
|
+
* small monitors, etc. (for rel="preload")
|
|
1818
|
+
*/
|
|
1819
|
+
imageSrcSet?: string;
|
|
1820
|
+
/**
|
|
1821
|
+
* Image sizes for different page layouts (for rel="preload")
|
|
1822
|
+
*/
|
|
1823
|
+
imageSizes?: string;
|
|
1804
1824
|
}
|
|
1805
1825
|
interface HtmlLinkPreloadImage extends HtmlLinkProps {
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1826
|
+
/**
|
|
1827
|
+
* Relationship between the document containing the hyperlink and the destination resource
|
|
1828
|
+
*/
|
|
1829
|
+
rel: "preload";
|
|
1830
|
+
/**
|
|
1831
|
+
* Potential destination for a preload request (for rel="preload" and rel="modulepreload")
|
|
1832
|
+
*/
|
|
1833
|
+
as: "image";
|
|
1834
|
+
/**
|
|
1835
|
+
* Address of the hyperlink
|
|
1836
|
+
*/
|
|
1837
|
+
href?: string;
|
|
1838
|
+
/**
|
|
1839
|
+
* Images to use in different situations, e.g., high-resolution displays,
|
|
1840
|
+
* small monitors, etc. (for rel="preload")
|
|
1841
|
+
*/
|
|
1842
|
+
imageSrcSet: string;
|
|
1843
|
+
/**
|
|
1844
|
+
* Image sizes for different page layouts (for rel="preload")
|
|
1845
|
+
*/
|
|
1846
|
+
imageSizes?: string;
|
|
1827
1847
|
}
|
|
1828
1848
|
/**
|
|
1829
1849
|
* Represents a `<link>` element.
|
|
@@ -1831,30 +1851,34 @@ interface HtmlLinkPreloadImage extends HtmlLinkProps {
|
|
|
1831
1851
|
* WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
|
|
1832
1852
|
*/
|
|
1833
1853
|
type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
|
|
1834
|
-
|
|
1854
|
+
imageSizes?: never;
|
|
1835
1855
|
});
|
|
1836
1856
|
interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1857
|
+
/**
|
|
1858
|
+
* A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
|
|
1859
|
+
* attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
|
|
1860
|
+
* element. If not provided in Framework Mode, it will default to any
|
|
1861
|
+
* {@link ServerRouter | `<ServerRouter nonce>`} prop.
|
|
1862
|
+
*/
|
|
1863
|
+
nonce?: string | undefined;
|
|
1864
|
+
/**
|
|
1865
|
+
* The absolute path of the page to prefetch, e.g. `/absolute/path`.
|
|
1866
|
+
*/
|
|
1867
|
+
page: string;
|
|
1847
1868
|
}
|
|
1848
1869
|
type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
|
|
1849
|
-
|
|
1870
|
+
//#endregion
|
|
1871
|
+
//#region lib/server-runtime/single-fetch.d.ts
|
|
1850
1872
|
type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
|
|
1851
|
-
|
|
1873
|
+
[key: PropertyKey]: Serializable;
|
|
1852
1874
|
} | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
|
|
1853
|
-
|
|
1875
|
+
//#endregion
|
|
1876
|
+
//#region lib/types/utils.d.ts
|
|
1854
1877
|
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
1855
1878
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
1856
1879
|
type Func = (...args: any[]) => unknown;
|
|
1857
|
-
|
|
1880
|
+
//#endregion
|
|
1881
|
+
//#region lib/types/serializes-to.d.ts
|
|
1858
1882
|
/**
|
|
1859
1883
|
* A brand that can be applied to a type to indicate that it will serialize
|
|
1860
1884
|
* to a specific type when transported to the client from a loader.
|
|
@@ -1862,12 +1886,11 @@ type Func = (...args: any[]) => unknown;
|
|
|
1862
1886
|
* in your application.
|
|
1863
1887
|
*/
|
|
1864
1888
|
type unstable_SerializesTo<T> = {
|
|
1865
|
-
|
|
1889
|
+
unstable__ReactRouter_SerializesTo: [T];
|
|
1866
1890
|
};
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
} : undefined;
|
|
1891
|
+
//#endregion
|
|
1892
|
+
//#region lib/types/route-data.d.ts
|
|
1893
|
+
type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends ((...args: any[]) => unknown) ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? { [K in keyof T]: Serialize<T[K]> } : undefined;
|
|
1871
1894
|
type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
|
|
1872
1895
|
type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
|
|
1873
1896
|
type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? U : T;
|
|
@@ -1875,55 +1898,51 @@ type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit
|
|
|
1875
1898
|
type ServerDataFrom<T> = ServerData<DataFrom<T>>;
|
|
1876
1899
|
type ClientDataFrom<T> = ClientData<DataFrom<T>>;
|
|
1877
1900
|
type ClientDataFunctionArgs<Params> = {
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
* `<HydratedRouter getContext>` prop
|
|
1920
|
-
*/
|
|
1921
|
-
context: Readonly<RouterContextProvider>;
|
|
1901
|
+
/**
|
|
1902
|
+
* A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
|
|
1903
|
+
*
|
|
1904
|
+
* @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
|
|
1905
|
+
**/
|
|
1906
|
+
request: Request;
|
|
1907
|
+
/**
|
|
1908
|
+
* A URL instance representing the application location being navigated to or
|
|
1909
|
+
* fetched.
|
|
1910
|
+
*
|
|
1911
|
+
* In Framework mode, this is a normalized URL with React-Router-specific
|
|
1912
|
+
* implementation details removed (`.data` suffixes, `index`/`_routes` search
|
|
1913
|
+
* params). For the raw incoming URL, use `request.url`.
|
|
1914
|
+
*/
|
|
1915
|
+
url: URL;
|
|
1916
|
+
/**
|
|
1917
|
+
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
1918
|
+
* @example
|
|
1919
|
+
* // app/routes.ts
|
|
1920
|
+
* route("teams/:teamId", "./team.tsx"),
|
|
1921
|
+
*
|
|
1922
|
+
* // app/team.tsx
|
|
1923
|
+
* export function clientLoader({
|
|
1924
|
+
* params,
|
|
1925
|
+
* }: Route.ClientLoaderArgs) {
|
|
1926
|
+
* params.teamId;
|
|
1927
|
+
* // ^ string
|
|
1928
|
+
* }
|
|
1929
|
+
**/
|
|
1930
|
+
params: Params;
|
|
1931
|
+
/**
|
|
1932
|
+
* Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
|
|
1933
|
+
* Mostly useful as a identifier to aggregate on for logging/tracing/etc.
|
|
1934
|
+
*/
|
|
1935
|
+
pattern: string;
|
|
1936
|
+
/**
|
|
1937
|
+
* An instance of `RouterContextProvider` that can be used to access context
|
|
1938
|
+
* values from your route middlewares. You may pass in initial context values
|
|
1939
|
+
* in your `<HydratedRouter getContext>` prop.
|
|
1940
|
+
*/
|
|
1941
|
+
context: Readonly<RouterContextProvider>;
|
|
1922
1942
|
};
|
|
1923
|
-
type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1943
|
+
type SerializeFrom<T> = T extends ((...args: infer Args) => unknown) ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs | ClientDataFunctionArgs<unknown>] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
|
|
1944
|
+
//#endregion
|
|
1945
|
+
//#region lib/dom/ssr/routeModules.d.ts
|
|
1927
1946
|
/**
|
|
1928
1947
|
* A function that handles data mutations for a route on the client
|
|
1929
1948
|
*/
|
|
@@ -1932,32 +1951,32 @@ type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<Actio
|
|
|
1932
1951
|
* Arguments passed to a route `clientAction` function
|
|
1933
1952
|
*/
|
|
1934
1953
|
type ClientActionFunctionArgs = ActionFunctionArgs & {
|
|
1935
|
-
|
|
1954
|
+
serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
|
|
1936
1955
|
};
|
|
1937
1956
|
/**
|
|
1938
1957
|
* A function that loads data for a route on the client
|
|
1939
1958
|
*/
|
|
1940
1959
|
type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<LoaderFunction>) & {
|
|
1941
|
-
|
|
1960
|
+
hydrate?: boolean;
|
|
1942
1961
|
};
|
|
1943
1962
|
/**
|
|
1944
1963
|
* Arguments passed to a route `clientLoader` function
|
|
1945
1964
|
*/
|
|
1946
1965
|
type ClientLoaderFunctionArgs = LoaderFunctionArgs & {
|
|
1947
|
-
|
|
1966
|
+
serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
|
|
1948
1967
|
};
|
|
1949
1968
|
type HeadersArgs = {
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1969
|
+
loaderHeaders: Headers;
|
|
1970
|
+
parentHeaders: Headers;
|
|
1971
|
+
actionHeaders: Headers;
|
|
1972
|
+
errorHeaders: Headers | undefined;
|
|
1954
1973
|
};
|
|
1955
1974
|
/**
|
|
1956
1975
|
* A function that returns HTTP headers to be used for a route. These headers
|
|
1957
1976
|
* will be merged with (and take precedence over) headers from parent routes.
|
|
1958
1977
|
*/
|
|
1959
1978
|
interface HeadersFunction {
|
|
1960
|
-
|
|
1979
|
+
(args: HeadersArgs): Headers | HeadersInit;
|
|
1961
1980
|
}
|
|
1962
1981
|
/**
|
|
1963
1982
|
* A function that defines `<link>` tags to be inserted into the `<head>` of
|
|
@@ -1966,30 +1985,24 @@ interface HeadersFunction {
|
|
|
1966
1985
|
* @see https://reactrouter.com/start/framework/route-module#meta
|
|
1967
1986
|
*/
|
|
1968
1987
|
interface LinksFunction {
|
|
1969
|
-
|
|
1988
|
+
(): LinkDescriptor[];
|
|
1970
1989
|
}
|
|
1971
1990
|
interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown> {
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
meta: MetaDescriptor[];
|
|
1980
|
-
error?: unknown;
|
|
1991
|
+
id: RouteId;
|
|
1992
|
+
pathname: DataRouteMatch["pathname"];
|
|
1993
|
+
loaderData: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
|
|
1994
|
+
handle?: RouteHandle;
|
|
1995
|
+
params: DataRouteMatch["params"];
|
|
1996
|
+
meta: MetaDescriptor[];
|
|
1997
|
+
error?: unknown;
|
|
1981
1998
|
}
|
|
1982
|
-
type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{
|
|
1983
|
-
[K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>;
|
|
1984
|
-
}[keyof MatchLoaders]>;
|
|
1999
|
+
type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{ [K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]> }[keyof MatchLoaders]>;
|
|
1985
2000
|
interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
matches: MetaMatches<MatchLoaders>;
|
|
1992
|
-
error?: unknown;
|
|
2001
|
+
loaderData: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
|
|
2002
|
+
params: Params;
|
|
2003
|
+
location: Location;
|
|
2004
|
+
matches: MetaMatches<MatchLoaders>;
|
|
2005
|
+
error?: unknown;
|
|
1993
2006
|
}
|
|
1994
2007
|
/**
|
|
1995
2008
|
* A function that returns an array of data objects to use for rendering
|
|
@@ -2029,164 +2042,164 @@ interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknow
|
|
|
2029
2042
|
* "root": RootLoader,
|
|
2030
2043
|
* "routes/sales": SalesLoader,
|
|
2031
2044
|
* "routes/sales/customers": CustomersLoader,
|
|
2032
|
-
* }> = ({
|
|
2033
|
-
* const { name } =
|
|
2045
|
+
* }> = ({ loaderData, matches }) => {
|
|
2046
|
+
* const { name } = loaderData
|
|
2034
2047
|
* // ^? string
|
|
2035
|
-
* const { customerCount } = matches.find((match) => match.id === "routes/sales/customers").
|
|
2048
|
+
* const { customerCount } = matches.find((match) => match.id === "routes/sales/customers").loaderData
|
|
2036
2049
|
* // ^? number
|
|
2037
|
-
* const { salesCount } = matches.find((match) => match.id === "routes/sales").
|
|
2050
|
+
* const { salesCount } = matches.find((match) => match.id === "routes/sales").loaderData
|
|
2038
2051
|
* // ^? number
|
|
2039
|
-
* const { hello } = matches.find((match) => match.id === "root").
|
|
2052
|
+
* const { hello } = matches.find((match) => match.id === "root").loaderData
|
|
2040
2053
|
* // ^? "world"
|
|
2041
2054
|
* }
|
|
2042
2055
|
* ```
|
|
2043
2056
|
*/
|
|
2044
2057
|
interface MetaFunction<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
|
|
2045
|
-
|
|
2058
|
+
(args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
|
|
2046
2059
|
}
|
|
2047
2060
|
type MetaDescriptor = {
|
|
2048
|
-
|
|
2061
|
+
charSet: "utf-8";
|
|
2049
2062
|
} | {
|
|
2050
|
-
|
|
2063
|
+
title: string;
|
|
2051
2064
|
} | {
|
|
2052
|
-
|
|
2053
|
-
|
|
2065
|
+
name: string;
|
|
2066
|
+
content: string;
|
|
2054
2067
|
} | {
|
|
2055
|
-
|
|
2056
|
-
|
|
2068
|
+
property: string;
|
|
2069
|
+
content: string;
|
|
2057
2070
|
} | {
|
|
2058
|
-
|
|
2059
|
-
|
|
2071
|
+
httpEquiv: string;
|
|
2072
|
+
content: string;
|
|
2060
2073
|
} | {
|
|
2061
|
-
|
|
2074
|
+
"script:ld+json": LdJsonObject | LdJsonObject[];
|
|
2062
2075
|
} | {
|
|
2063
|
-
|
|
2064
|
-
|
|
2076
|
+
tagName: "meta" | "link";
|
|
2077
|
+
[name: string]: string;
|
|
2065
2078
|
} | {
|
|
2066
|
-
|
|
2067
|
-
};
|
|
2068
|
-
type LdJsonObject = {
|
|
2069
|
-
[Key in string]: LdJsonValue;
|
|
2070
|
-
} & {
|
|
2071
|
-
[Key in string]?: LdJsonValue | undefined;
|
|
2079
|
+
[name: string]: unknown;
|
|
2072
2080
|
};
|
|
2081
|
+
type LdJsonObject = { [Key in string]: LdJsonValue } & { [Key in string]?: LdJsonValue | undefined };
|
|
2073
2082
|
type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
|
|
2074
2083
|
type LdJsonPrimitive = string | number | boolean | null;
|
|
2075
2084
|
type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
|
|
2085
|
+
/**
|
|
2086
|
+
* A React component that is rendered for a route.
|
|
2087
|
+
*/
|
|
2076
2088
|
/**
|
|
2077
2089
|
* An arbitrary object that is associated with a route.
|
|
2078
2090
|
*
|
|
2079
2091
|
* @see https://reactrouter.com/how-to/using-handle
|
|
2080
2092
|
*/
|
|
2081
2093
|
type RouteHandle = unknown;
|
|
2082
|
-
|
|
2094
|
+
//#endregion
|
|
2095
|
+
//#region lib/components.d.ts
|
|
2083
2096
|
interface AwaitResolveRenderFunction<Resolve = any> {
|
|
2084
|
-
|
|
2097
|
+
(data: Awaited<Resolve>): React.ReactNode;
|
|
2085
2098
|
}
|
|
2086
2099
|
/**
|
|
2087
2100
|
* @category Types
|
|
2088
2101
|
*/
|
|
2089
2102
|
interface AwaitProps<Resolve> {
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2103
|
+
/**
|
|
2104
|
+
* When using a function, the resolved value is provided as the parameter.
|
|
2105
|
+
*
|
|
2106
|
+
* ```tsx [2]
|
|
2107
|
+
* <Await resolve={reviewsPromise}>
|
|
2108
|
+
* {(resolvedReviews) => <Reviews items={resolvedReviews} />}
|
|
2109
|
+
* </Await>
|
|
2110
|
+
* ```
|
|
2111
|
+
*
|
|
2112
|
+
* When using React elements, {@link useAsyncValue} will provide the
|
|
2113
|
+
* resolved value:
|
|
2114
|
+
*
|
|
2115
|
+
* ```tsx [2]
|
|
2116
|
+
* <Await resolve={reviewsPromise}>
|
|
2117
|
+
* <Reviews />
|
|
2118
|
+
* </Await>
|
|
2119
|
+
*
|
|
2120
|
+
* function Reviews() {
|
|
2121
|
+
* const resolvedReviews = useAsyncValue();
|
|
2122
|
+
* return <div>...</div>;
|
|
2123
|
+
* }
|
|
2124
|
+
* ```
|
|
2125
|
+
*/
|
|
2126
|
+
children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
|
|
2127
|
+
/**
|
|
2128
|
+
* The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
2129
|
+
* rejects.
|
|
2130
|
+
*
|
|
2131
|
+
* ```tsx
|
|
2132
|
+
* <Await
|
|
2133
|
+
* errorElement={<div>Oops</div>}
|
|
2134
|
+
* resolve={reviewsPromise}
|
|
2135
|
+
* >
|
|
2136
|
+
* <Reviews />
|
|
2137
|
+
* </Await>
|
|
2138
|
+
* ```
|
|
2139
|
+
*
|
|
2140
|
+
* To provide a more contextual error, you can use the {@link useAsyncError} in a
|
|
2141
|
+
* child component
|
|
2142
|
+
*
|
|
2143
|
+
* ```tsx
|
|
2144
|
+
* <Await
|
|
2145
|
+
* errorElement={<ReviewsError />}
|
|
2146
|
+
* resolve={reviewsPromise}
|
|
2147
|
+
* >
|
|
2148
|
+
* <Reviews />
|
|
2149
|
+
* </Await>
|
|
2150
|
+
*
|
|
2151
|
+
* function ReviewsError() {
|
|
2152
|
+
* const error = useAsyncError();
|
|
2153
|
+
* return <div>Error loading reviews: {error.message}</div>;
|
|
2154
|
+
* }
|
|
2155
|
+
* ```
|
|
2156
|
+
*
|
|
2157
|
+
* If you do not provide an `errorElement`, the rejected value will bubble up
|
|
2158
|
+
* to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
|
|
2159
|
+
* and be accessible via the {@link useRouteError} hook.
|
|
2160
|
+
*/
|
|
2161
|
+
errorElement?: React.ReactNode;
|
|
2162
|
+
/**
|
|
2163
|
+
* Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
2164
|
+
* returned from a [`loader`](../../start/framework/route-module#loader) to be
|
|
2165
|
+
* resolved and rendered.
|
|
2166
|
+
*
|
|
2167
|
+
* ```tsx
|
|
2168
|
+
* import { Await, useLoaderData } from "react-router";
|
|
2169
|
+
*
|
|
2170
|
+
* export async function loader() {
|
|
2171
|
+
* let reviews = getReviews(); // not awaited
|
|
2172
|
+
* let book = await getBook();
|
|
2173
|
+
* return {
|
|
2174
|
+
* book,
|
|
2175
|
+
* reviews, // this is a promise
|
|
2176
|
+
* };
|
|
2177
|
+
* }
|
|
2178
|
+
*
|
|
2179
|
+
* export default function Book() {
|
|
2180
|
+
* const {
|
|
2181
|
+
* book,
|
|
2182
|
+
* reviews, // this is the same promise
|
|
2183
|
+
* } = useLoaderData();
|
|
2184
|
+
*
|
|
2185
|
+
* return (
|
|
2186
|
+
* <div>
|
|
2187
|
+
* <h1>{book.title}</h1>
|
|
2188
|
+
* <p>{book.description}</p>
|
|
2189
|
+
* <React.Suspense fallback={<ReviewsSkeleton />}>
|
|
2190
|
+
* <Await
|
|
2191
|
+
* // and is the promise we pass to Await
|
|
2192
|
+
* resolve={reviews}
|
|
2193
|
+
* >
|
|
2194
|
+
* <Reviews />
|
|
2195
|
+
* </Await>
|
|
2196
|
+
* </React.Suspense>
|
|
2197
|
+
* </div>
|
|
2198
|
+
* );
|
|
2199
|
+
* }
|
|
2200
|
+
* ```
|
|
2201
|
+
*/
|
|
2202
|
+
resolve: Resolve;
|
|
2190
2203
|
}
|
|
2191
2204
|
/**
|
|
2192
2205
|
* Used to render promise values with automatic error handling.
|
|
@@ -2235,115 +2248,119 @@ interface AwaitProps<Resolve> {
|
|
|
2235
2248
|
* @param {AwaitProps.resolve} props.resolve n/a
|
|
2236
2249
|
* @returns React element for the rendered awaited value
|
|
2237
2250
|
*/
|
|
2238
|
-
declare function Await$1<Resolve>({
|
|
2239
|
-
|
|
2251
|
+
declare function Await$1<Resolve>({
|
|
2252
|
+
children,
|
|
2253
|
+
errorElement,
|
|
2254
|
+
resolve
|
|
2255
|
+
}: AwaitProps<Resolve>): React.JSX.Element;
|
|
2256
|
+
//#endregion
|
|
2257
|
+
//#region lib/rsc/server.rsc.d.ts
|
|
2240
2258
|
declare function getRequest(): Request;
|
|
2241
2259
|
declare const redirect: typeof redirect$1;
|
|
2242
2260
|
declare const redirectDocument: typeof redirectDocument$1;
|
|
2243
|
-
declare const replace: typeof replace$
|
|
2261
|
+
declare const replace$1: typeof replace$2;
|
|
2244
2262
|
declare const Await: typeof Await$1;
|
|
2245
2263
|
type RSCRouteConfigEntryBase = {
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2264
|
+
action?: ActionFunction;
|
|
2265
|
+
clientAction?: ClientActionFunction;
|
|
2266
|
+
clientLoader?: ClientLoaderFunction;
|
|
2267
|
+
ErrorBoundary?: React.ComponentType<any>;
|
|
2268
|
+
handle?: any;
|
|
2269
|
+
headers?: HeadersFunction;
|
|
2270
|
+
HydrateFallback?: React.ComponentType<any>;
|
|
2271
|
+
Layout?: React.ComponentType<any>;
|
|
2272
|
+
links?: LinksFunction;
|
|
2273
|
+
loader?: LoaderFunction;
|
|
2274
|
+
meta?: MetaFunction;
|
|
2275
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
2258
2276
|
};
|
|
2259
2277
|
type RSCRouteConfigEntry = RSCRouteConfigEntryBase & {
|
|
2260
|
-
|
|
2261
|
-
|
|
2278
|
+
id: string;
|
|
2279
|
+
path?: string;
|
|
2280
|
+
Component?: React.ComponentType<any>;
|
|
2281
|
+
lazy?: () => Promise<RSCRouteConfigEntryBase & ({
|
|
2282
|
+
default?: React.ComponentType<any>;
|
|
2283
|
+
Component?: never;
|
|
2284
|
+
} | {
|
|
2285
|
+
default?: never;
|
|
2262
2286
|
Component?: React.ComponentType<any>;
|
|
2263
|
-
|
|
2264
|
-
default?: React.ComponentType<any>;
|
|
2265
|
-
Component?: never;
|
|
2266
|
-
} | {
|
|
2267
|
-
default?: never;
|
|
2268
|
-
Component?: React.ComponentType<any>;
|
|
2269
|
-
})>;
|
|
2287
|
+
})>;
|
|
2270
2288
|
} & ({
|
|
2271
|
-
|
|
2289
|
+
index: true;
|
|
2272
2290
|
} | {
|
|
2273
|
-
|
|
2291
|
+
children?: RSCRouteConfigEntry[];
|
|
2274
2292
|
});
|
|
2275
2293
|
type RSCRouteConfig = Array<RSCRouteConfigEntry>;
|
|
2276
2294
|
type RSCRouteManifest = {
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
shouldRevalidate?: ShouldRevalidateFunction;
|
|
2295
|
+
clientAction?: ClientActionFunction;
|
|
2296
|
+
clientLoader?: ClientLoaderFunction;
|
|
2297
|
+
element?: React.ReactElement | false;
|
|
2298
|
+
errorElement?: React.ReactElement;
|
|
2299
|
+
handle?: any;
|
|
2300
|
+
hasAction: boolean;
|
|
2301
|
+
hasComponent: boolean;
|
|
2302
|
+
hasLoader: boolean;
|
|
2303
|
+
hydrateFallbackElement?: React.ReactElement;
|
|
2304
|
+
id: string;
|
|
2305
|
+
index?: boolean;
|
|
2306
|
+
links?: LinksFunction;
|
|
2307
|
+
meta?: MetaFunction;
|
|
2308
|
+
parentId?: string;
|
|
2309
|
+
path?: string;
|
|
2310
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
2294
2311
|
};
|
|
2295
2312
|
type RSCRouteMatch = RSCRouteManifest & {
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2313
|
+
params: Params;
|
|
2314
|
+
pathname: string;
|
|
2315
|
+
pathnameBase: string;
|
|
2299
2316
|
};
|
|
2300
2317
|
type RSCRenderPayload = {
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2318
|
+
type: "render";
|
|
2319
|
+
actionData: Record<string, any> | null;
|
|
2320
|
+
basename: string | undefined;
|
|
2321
|
+
clientVersion?: string;
|
|
2322
|
+
errors: Record<string, any> | null;
|
|
2323
|
+
loaderData: Record<string, any>;
|
|
2324
|
+
location: Location;
|
|
2325
|
+
routeDiscovery: RouteDiscovery;
|
|
2326
|
+
matches: RSCRouteMatch[];
|
|
2327
|
+
patches?: Promise<RSCRouteManifest[]>;
|
|
2328
|
+
formState?: ReactFormState;
|
|
2312
2329
|
};
|
|
2313
2330
|
type RSCManifestPayload = {
|
|
2314
|
-
|
|
2315
|
-
|
|
2331
|
+
type: "manifest";
|
|
2332
|
+
patches: Promise<RSCRouteManifest[]>;
|
|
2316
2333
|
};
|
|
2317
2334
|
type RSCActionPayload = {
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2335
|
+
type: "action";
|
|
2336
|
+
actionResult: Promise<unknown>;
|
|
2337
|
+
rerender?: Promise<RSCRenderPayload | RSCRedirectPayload>;
|
|
2321
2338
|
};
|
|
2322
2339
|
type RSCRedirectPayload = {
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2340
|
+
type: "redirect";
|
|
2341
|
+
status: number;
|
|
2342
|
+
location: string;
|
|
2343
|
+
replace: boolean;
|
|
2344
|
+
reload: boolean;
|
|
2345
|
+
actionResult?: Promise<unknown>;
|
|
2329
2346
|
};
|
|
2330
2347
|
type RSCPayload = RSCRenderPayload | RSCManifestPayload | RSCActionPayload | RSCRedirectPayload;
|
|
2331
2348
|
type RSCMatch = {
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2349
|
+
statusCode: number;
|
|
2350
|
+
headers: Headers;
|
|
2351
|
+
payload: RSCPayload;
|
|
2335
2352
|
};
|
|
2336
2353
|
type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
|
|
2337
|
-
type DecodeFormStateFunction = (result: unknown, formData: FormData) =>
|
|
2354
|
+
type DecodeFormStateFunction = (result: unknown, formData: FormData) => Promise<ReactFormState | undefined>;
|
|
2338
2355
|
type DecodeReplyFunction = (reply: FormData | string, options: {
|
|
2339
|
-
|
|
2356
|
+
temporaryReferences: unknown;
|
|
2340
2357
|
}) => Promise<unknown[]>;
|
|
2341
2358
|
type LoadServerActionFunction = (id: string) => Promise<Function>;
|
|
2342
2359
|
type RouteDiscovery = {
|
|
2343
|
-
|
|
2344
|
-
|
|
2360
|
+
mode: "lazy";
|
|
2361
|
+
manifestPath?: string | undefined;
|
|
2345
2362
|
} | {
|
|
2346
|
-
|
|
2363
|
+
mode: "initial";
|
|
2347
2364
|
};
|
|
2348
2365
|
/**
|
|
2349
2366
|
* Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
@@ -2404,6 +2421,8 @@ type RouteDiscovery = {
|
|
|
2404
2421
|
* encoding the {@link unstable_RSCPayload}.
|
|
2405
2422
|
* @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
|
|
2406
2423
|
* `loadServerAction` function, used to load a server action by ID.
|
|
2424
|
+
* @param opts.clientVersion A version derived from the client build output used
|
|
2425
|
+
* to detect stale clients during lazy route discovery.
|
|
2407
2426
|
* @param opts.onError An optional error handler that will be called with any
|
|
2408
2427
|
* errors that occur during the request processing.
|
|
2409
2428
|
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
@@ -2417,71 +2436,104 @@ type RouteDiscovery = {
|
|
|
2417
2436
|
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
|
2418
2437
|
* data for hydration.
|
|
2419
2438
|
*/
|
|
2420
|
-
declare function matchRSCServerRequest({
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2439
|
+
declare function matchRSCServerRequest({
|
|
2440
|
+
allowedActionOrigins,
|
|
2441
|
+
createTemporaryReferenceSet,
|
|
2442
|
+
basename,
|
|
2443
|
+
decodeReply,
|
|
2444
|
+
requestContext,
|
|
2445
|
+
routeDiscovery,
|
|
2446
|
+
loadServerAction,
|
|
2447
|
+
decodeAction,
|
|
2448
|
+
decodeFormState,
|
|
2449
|
+
clientVersion,
|
|
2450
|
+
onError,
|
|
2451
|
+
request,
|
|
2452
|
+
routes,
|
|
2453
|
+
generateResponse
|
|
2454
|
+
}: {
|
|
2455
|
+
allowedActionOrigins?: string[];
|
|
2456
|
+
createTemporaryReferenceSet: () => unknown;
|
|
2457
|
+
basename?: string;
|
|
2458
|
+
decodeReply?: DecodeReplyFunction;
|
|
2459
|
+
decodeAction?: DecodeActionFunction;
|
|
2460
|
+
decodeFormState?: DecodeFormStateFunction;
|
|
2461
|
+
requestContext?: RouterContextProvider;
|
|
2462
|
+
loadServerAction?: LoadServerActionFunction;
|
|
2463
|
+
clientVersion?: string;
|
|
2464
|
+
onError?: (error: unknown) => void;
|
|
2465
|
+
request: Request;
|
|
2466
|
+
routes: RSCRouteConfigEntry[];
|
|
2467
|
+
routeDiscovery?: RouteDiscovery;
|
|
2468
|
+
generateResponse: (match: RSCMatch, {
|
|
2469
|
+
onError,
|
|
2470
|
+
temporaryReferences
|
|
2471
|
+
}: {
|
|
2472
|
+
onError(error: unknown): string | undefined;
|
|
2473
|
+
temporaryReferences: unknown;
|
|
2474
|
+
}) => Response;
|
|
2437
2475
|
}): Promise<Response>;
|
|
2438
|
-
|
|
2476
|
+
//#endregion
|
|
2477
|
+
//#region lib/types/register.d.ts
|
|
2439
2478
|
/**
|
|
2440
2479
|
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
|
|
2441
2480
|
* React Router should handle this for you via type generation.
|
|
2442
2481
|
*
|
|
2443
2482
|
* For more on declaration merging and module augmentation, see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation .
|
|
2444
2483
|
*/
|
|
2445
|
-
interface Register {
|
|
2446
|
-
}
|
|
2484
|
+
interface Register {}
|
|
2447
2485
|
type AnyParams = Record<string, string | undefined>;
|
|
2448
2486
|
type AnyPages = Record<string, {
|
|
2449
|
-
|
|
2487
|
+
params: AnyParams;
|
|
2450
2488
|
}>;
|
|
2451
2489
|
type Pages = Register extends {
|
|
2452
|
-
|
|
2490
|
+
pages: infer Registered extends AnyPages;
|
|
2453
2491
|
} ? Registered : AnyPages;
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
};
|
|
2458
|
-
type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [
|
|
2459
|
-
Params
|
|
2460
|
-
];
|
|
2492
|
+
//#endregion
|
|
2493
|
+
//#region lib/href.d.ts
|
|
2494
|
+
type Args = { [K in keyof Pages]: ToArgs<Pages[K]["params"]> };
|
|
2495
|
+
type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [Params];
|
|
2461
2496
|
/**
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2497
|
+
* Returns a resolved URL path for the specified route.
|
|
2498
|
+
*
|
|
2499
|
+
* Param values are percent-encoded for use in a path segment: characters that
|
|
2500
|
+
* would change the URL structure (`/`, `?`, `#`, `%`, whitespace, non-ASCII)
|
|
2501
|
+
* are escaped, while characters that RFC 3986 allows literally in a path
|
|
2502
|
+
* segment (`$ & + , ; = : @`) are kept as-is. Note this differs from query-string
|
|
2503
|
+
* encoding (`encodeURIComponent`/`URLSearchParams`), where those characters are
|
|
2504
|
+
* delimiters and must be escaped. Splat (`*`) values are encoded per segment,
|
|
2505
|
+
* preserving `/` separators.
|
|
2506
|
+
*
|
|
2507
|
+
* See [RFC 3986 §3.3](https://datatracker.ietf.org/doc/html/rfc3986#section-3.3)
|
|
2508
|
+
*
|
|
2509
|
+
* @example
|
|
2510
|
+
* const h = href("/:lang?/about", { lang: "en" })
|
|
2511
|
+
* // -> `/en/about`
|
|
2512
|
+
*
|
|
2513
|
+
* <Link to={href("/products/:id", { id: "abc123" })} />
|
|
2514
|
+
*
|
|
2515
|
+
* @public
|
|
2516
|
+
* @category Utils
|
|
2517
|
+
* @mode framework
|
|
2518
|
+
* @param path The route path to resolve
|
|
2519
|
+
* @param args The route params to use when resolving the path
|
|
2520
|
+
* @returns The resolved URL path
|
|
2470
2521
|
*/
|
|
2471
2522
|
declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
|
|
2472
|
-
|
|
2523
|
+
//#endregion
|
|
2524
|
+
//#region lib/server-runtime/cookies.d.ts
|
|
2473
2525
|
interface CookieSignatureOptions {
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2526
|
+
/**
|
|
2527
|
+
* An array of secrets that may be used to sign/unsign the value of a cookie.
|
|
2528
|
+
*
|
|
2529
|
+
* The array makes it easy to rotate secrets. New secrets should be added to
|
|
2530
|
+
* the beginning of the array. `cookie.serialize()` will always use the first
|
|
2531
|
+
* value in the array, but `cookie.parse()` may use any of them so that
|
|
2532
|
+
* cookies that were signed with older secrets still work.
|
|
2533
|
+
*/
|
|
2534
|
+
secrets?: string[];
|
|
2483
2535
|
}
|
|
2484
|
-
type CookieOptions =
|
|
2536
|
+
type CookieOptions = CookieParseOptions & CookieSerializeOptions & CookieSignatureOptions;
|
|
2485
2537
|
/**
|
|
2486
2538
|
* A HTTP cookie.
|
|
2487
2539
|
*
|
|
@@ -2493,49 +2545,76 @@ type CookieOptions = ParseOptions & SerializeOptions & CookieSignatureOptions;
|
|
|
2493
2545
|
* @see https://remix.run/utils/cookies#cookie-api
|
|
2494
2546
|
*/
|
|
2495
2547
|
interface Cookie {
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2548
|
+
/**
|
|
2549
|
+
* The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
|
|
2550
|
+
*/
|
|
2551
|
+
readonly name: string;
|
|
2552
|
+
/**
|
|
2553
|
+
* True if this cookie uses one or more secrets for verification.
|
|
2554
|
+
*/
|
|
2555
|
+
readonly isSigned: boolean;
|
|
2556
|
+
/**
|
|
2557
|
+
* The Date this cookie expires.
|
|
2558
|
+
*
|
|
2559
|
+
* Note: This is calculated at access time using `maxAge` when no `expires`
|
|
2560
|
+
* option is provided to `createCookie()`.
|
|
2561
|
+
*/
|
|
2562
|
+
readonly expires?: Date;
|
|
2563
|
+
/**
|
|
2564
|
+
* Parses a raw `Cookie` header and returns the value of this cookie or
|
|
2565
|
+
* `null` if it's not present.
|
|
2566
|
+
*/
|
|
2567
|
+
parse(cookieHeader: string | null, options?: CookieParseOptions): Promise<any>;
|
|
2568
|
+
/**
|
|
2569
|
+
* Serializes the given value to a string and returns the `Set-Cookie`
|
|
2570
|
+
* header.
|
|
2571
|
+
*/
|
|
2572
|
+
serialize(value: any, options?: CookieSerializeOptions): Promise<string>;
|
|
2521
2573
|
}
|
|
2522
2574
|
/**
|
|
2523
2575
|
* Creates a logical container for managing a browser cookie from the server.
|
|
2576
|
+
*
|
|
2577
|
+
* @public
|
|
2578
|
+
* @category Utils
|
|
2579
|
+
* @mode framework
|
|
2580
|
+
* @mode data
|
|
2581
|
+
* @param name The name of the cookie.
|
|
2582
|
+
* @param cookieOptions Options for parsing and serializing the cookie.
|
|
2583
|
+
* @returns A {@link Cookie} object for parsing and serializing the cookie.
|
|
2524
2584
|
*/
|
|
2525
2585
|
declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
|
|
2586
|
+
/**
|
|
2587
|
+
* A function that determines whether a value is a React Router {@link Cookie}
|
|
2588
|
+
* object.
|
|
2589
|
+
*
|
|
2590
|
+
* @public
|
|
2591
|
+
* @category Utils
|
|
2592
|
+
* @mode framework
|
|
2593
|
+
* @mode data
|
|
2594
|
+
* @param object The value to check.
|
|
2595
|
+
* @returns `true` if the value is a React Router {@link Cookie} object;
|
|
2596
|
+
* otherwise, `false`.
|
|
2597
|
+
*/
|
|
2526
2598
|
type IsCookieFunction = (object: any) => object is Cookie;
|
|
2527
2599
|
/**
|
|
2528
|
-
* Returns true if
|
|
2600
|
+
* Returns `true` if a value is a React Router {@link Cookie} object.
|
|
2529
2601
|
*
|
|
2530
|
-
* @
|
|
2602
|
+
* @public
|
|
2603
|
+
* @category Utils
|
|
2604
|
+
* @mode framework
|
|
2605
|
+
* @mode data
|
|
2606
|
+
* @param object The value to check.
|
|
2607
|
+
* @returns `true` if the value is a React Router {@link Cookie} object;
|
|
2608
|
+
* otherwise, `false`.
|
|
2531
2609
|
*/
|
|
2532
2610
|
declare const isCookie: IsCookieFunction;
|
|
2533
|
-
|
|
2611
|
+
//#endregion
|
|
2612
|
+
//#region lib/server-runtime/sessions.d.ts
|
|
2534
2613
|
/**
|
|
2535
2614
|
* An object of name/value pairs to be used in the session.
|
|
2536
2615
|
*/
|
|
2537
2616
|
interface SessionData {
|
|
2538
|
-
|
|
2617
|
+
[name: string]: any;
|
|
2539
2618
|
}
|
|
2540
2619
|
/**
|
|
2541
2620
|
* Session persists data across HTTP requests.
|
|
@@ -2543,46 +2622,44 @@ interface SessionData {
|
|
|
2543
2622
|
* @see https://reactrouter.com/explanation/sessions-and-cookies#sessions
|
|
2544
2623
|
*/
|
|
2545
2624
|
interface Session<Data = SessionData, FlashData = Data> {
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2625
|
+
/**
|
|
2626
|
+
* A unique identifier for this session.
|
|
2627
|
+
*
|
|
2628
|
+
* Note: This will be the empty string for newly created sessions and
|
|
2629
|
+
* sessions that are not backed by a database (i.e. cookie-based sessions).
|
|
2630
|
+
*/
|
|
2631
|
+
readonly id: string;
|
|
2632
|
+
/**
|
|
2633
|
+
* The raw data contained in this session.
|
|
2634
|
+
*
|
|
2635
|
+
* This is useful mostly for SessionStorage internally to access the raw
|
|
2636
|
+
* session data to persist.
|
|
2637
|
+
*/
|
|
2638
|
+
readonly data: FlashSessionData<Data, FlashData>;
|
|
2639
|
+
/**
|
|
2640
|
+
* Returns `true` if the session has a value for the given `name`, `false`
|
|
2641
|
+
* otherwise.
|
|
2642
|
+
*/
|
|
2643
|
+
has(name: (keyof Data | keyof FlashData) & string): boolean;
|
|
2644
|
+
/**
|
|
2645
|
+
* Returns the value for the given `name` in this session.
|
|
2646
|
+
*/
|
|
2647
|
+
get<Key extends (keyof Data | keyof FlashData) & string>(name: Key): (Key extends keyof Data ? Data[Key] : undefined) | (Key extends keyof FlashData ? FlashData[Key] : undefined) | undefined;
|
|
2648
|
+
/**
|
|
2649
|
+
* Sets a value in the session for the given `name`.
|
|
2650
|
+
*/
|
|
2651
|
+
set<Key extends keyof Data & string>(name: Key, value: Data[Key]): void;
|
|
2652
|
+
/**
|
|
2653
|
+
* Sets a value in the session that is only valid until the next `get()`.
|
|
2654
|
+
* This can be useful for temporary values, like error messages.
|
|
2655
|
+
*/
|
|
2656
|
+
flash<Key extends keyof FlashData & string>(name: Key, value: FlashData[Key]): void;
|
|
2657
|
+
/**
|
|
2658
|
+
* Removes a value from the session.
|
|
2659
|
+
*/
|
|
2660
|
+
unset(name: keyof Data & string): void;
|
|
2582
2661
|
}
|
|
2583
|
-
type FlashSessionData<Data, FlashData> = Partial<Data & {
|
|
2584
|
-
[Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key];
|
|
2585
|
-
}>;
|
|
2662
|
+
type FlashSessionData<Data, FlashData> = Partial<Data & { [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key] }>;
|
|
2586
2663
|
type FlashDataKey<Key extends string> = `__flash_${Key}__`;
|
|
2587
2664
|
type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?: Data, id?: string) => Session<Data, FlashData>;
|
|
2588
2665
|
/**
|
|
@@ -2590,13 +2667,37 @@ type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?
|
|
|
2590
2667
|
*
|
|
2591
2668
|
* Note: This function is typically not invoked directly by application code.
|
|
2592
2669
|
* Instead, use a `SessionStorage` object's `getSession` method.
|
|
2670
|
+
*
|
|
2671
|
+
* @category Utils
|
|
2672
|
+
* @param initialData The initial data for the session.
|
|
2673
|
+
* @param id The identifier for the session. Defaults to an empty string for a
|
|
2674
|
+
* new session.
|
|
2675
|
+
* @returns A new {@link Session} object.
|
|
2593
2676
|
*/
|
|
2594
2677
|
declare const createSession: CreateSessionFunction;
|
|
2678
|
+
/**
|
|
2679
|
+
* A function that determines whether a value is a React Router {@link Session}
|
|
2680
|
+
* object.
|
|
2681
|
+
*
|
|
2682
|
+
* @public
|
|
2683
|
+
* @category Utils
|
|
2684
|
+
* @mode framework
|
|
2685
|
+
* @mode data
|
|
2686
|
+
* @param object The value to check.
|
|
2687
|
+
* @returns `true` if the value is a React Router {@link Session} object;
|
|
2688
|
+
* otherwise, `false`.
|
|
2689
|
+
*/
|
|
2595
2690
|
type IsSessionFunction = (object: any) => object is Session;
|
|
2596
2691
|
/**
|
|
2597
|
-
* Returns true if
|
|
2692
|
+
* Returns `true` if a value is a React Router {@link Session} object.
|
|
2598
2693
|
*
|
|
2599
|
-
* @
|
|
2694
|
+
* @public
|
|
2695
|
+
* @category Utils
|
|
2696
|
+
* @mode framework
|
|
2697
|
+
* @mode data
|
|
2698
|
+
* @param object The value to check.
|
|
2699
|
+
* @returns `true` if the value is a React Router {@link Session} object;
|
|
2700
|
+
* otherwise, `false`.
|
|
2600
2701
|
*/
|
|
2601
2702
|
declare const isSession: IsSessionFunction;
|
|
2602
2703
|
/**
|
|
@@ -2607,22 +2708,22 @@ declare const isSession: IsSessionFunction;
|
|
|
2607
2708
|
* Then, later it generates the `Set-Cookie` header to be used in the response.
|
|
2608
2709
|
*/
|
|
2609
2710
|
interface SessionStorage<Data = SessionData, FlashData = Data> {
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2711
|
+
/**
|
|
2712
|
+
* Parses a Cookie header from a HTTP request and returns the associated
|
|
2713
|
+
* Session. If there is no session associated with the cookie, this will
|
|
2714
|
+
* return a new Session with no data.
|
|
2715
|
+
*/
|
|
2716
|
+
getSession: (cookieHeader?: string | null, options?: CookieParseOptions$1) => Promise<Session<Data, FlashData>>;
|
|
2717
|
+
/**
|
|
2718
|
+
* Stores all data in the Session and returns the Set-Cookie header to be
|
|
2719
|
+
* used in the HTTP response.
|
|
2720
|
+
*/
|
|
2721
|
+
commitSession: (session: Session<Data, FlashData>, options?: CookieSerializeOptions$1) => Promise<string>;
|
|
2722
|
+
/**
|
|
2723
|
+
* Deletes all data associated with the Session and returns the Set-Cookie
|
|
2724
|
+
* header to be used in the HTTP response.
|
|
2725
|
+
*/
|
|
2726
|
+
destroySession: (session: Session<Data, FlashData>, options?: CookieSerializeOptions$1) => Promise<string>;
|
|
2626
2727
|
}
|
|
2627
2728
|
/**
|
|
2628
2729
|
* SessionIdStorageStrategy is designed to allow anyone to easily build their
|
|
@@ -2634,44 +2735,56 @@ interface SessionStorage<Data = SessionData, FlashData = Data> {
|
|
|
2634
2735
|
* are provided for managing the session data.
|
|
2635
2736
|
*/
|
|
2636
2737
|
interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2738
|
+
/**
|
|
2739
|
+
* The Cookie used to store the session id, or options used to automatically
|
|
2740
|
+
* create one.
|
|
2741
|
+
*/
|
|
2742
|
+
cookie?: Cookie | (CookieOptions & {
|
|
2743
|
+
name?: string;
|
|
2744
|
+
});
|
|
2745
|
+
/**
|
|
2746
|
+
* Creates a new record with the given data and returns the session id.
|
|
2747
|
+
*/
|
|
2748
|
+
createData: (data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<string>;
|
|
2749
|
+
/**
|
|
2750
|
+
* Returns data for a given session id, or `null` if there isn't any.
|
|
2751
|
+
*/
|
|
2752
|
+
readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
|
|
2753
|
+
/**
|
|
2754
|
+
* Updates data for the given session id.
|
|
2755
|
+
*/
|
|
2756
|
+
updateData: (id: string, data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<void>;
|
|
2757
|
+
/**
|
|
2758
|
+
* Deletes data for a given session id from the data store.
|
|
2759
|
+
*/
|
|
2760
|
+
deleteData: (id: string) => Promise<void>;
|
|
2660
2761
|
}
|
|
2661
2762
|
/**
|
|
2662
2763
|
* Creates a SessionStorage object using a SessionIdStorageStrategy.
|
|
2663
2764
|
*
|
|
2664
2765
|
* Note: This is a low-level API that should only be used if none of the
|
|
2665
2766
|
* existing session storage options meet your requirements.
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2767
|
+
*
|
|
2768
|
+
* @category Utils
|
|
2769
|
+
* @param strategy The strategy used to store session identifiers and data.
|
|
2770
|
+
* @returns A {@link SessionStorage} object that persists session data using the
|
|
2771
|
+
* provided strategy.
|
|
2772
|
+
*/
|
|
2773
|
+
declare function createSessionStorage<Data = SessionData, FlashData = Data>({
|
|
2774
|
+
cookie: cookieArg,
|
|
2775
|
+
createData,
|
|
2776
|
+
readData,
|
|
2777
|
+
updateData,
|
|
2778
|
+
deleteData
|
|
2779
|
+
}: SessionIdStorageStrategy<Data, FlashData>): SessionStorage<Data, FlashData>;
|
|
2780
|
+
//#endregion
|
|
2781
|
+
//#region lib/server-runtime/sessions/cookieStorage.d.ts
|
|
2669
2782
|
interface CookieSessionStorageOptions {
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2783
|
+
/**
|
|
2784
|
+
* The Cookie used to store the session data on the client, or options used
|
|
2785
|
+
* to automatically create one.
|
|
2786
|
+
*/
|
|
2787
|
+
cookie?: SessionIdStorageStrategy["cookie"];
|
|
2675
2788
|
}
|
|
2676
2789
|
/**
|
|
2677
2790
|
* Creates and returns a SessionStorage object that stores all session data
|
|
@@ -2681,23 +2794,42 @@ interface CookieSessionStorageOptions {
|
|
|
2681
2794
|
* needed, and can help to simplify some load-balanced scenarios. However, it
|
|
2682
2795
|
* also has the limitation that serialized session data may not exceed the
|
|
2683
2796
|
* browser's maximum cookie size. Trade-offs!
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2797
|
+
*
|
|
2798
|
+
* @public
|
|
2799
|
+
* @category Utils
|
|
2800
|
+
* @mode framework
|
|
2801
|
+
* @mode data
|
|
2802
|
+
* @param options Options for creating the cookie-backed session storage.
|
|
2803
|
+
* @returns A {@link SessionStorage} object that stores all session data in its
|
|
2804
|
+
* cookie.
|
|
2805
|
+
*/
|
|
2806
|
+
declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({
|
|
2807
|
+
cookie: cookieArg
|
|
2808
|
+
}?: CookieSessionStorageOptions): SessionStorage<Data, FlashData>;
|
|
2809
|
+
//#endregion
|
|
2810
|
+
//#region lib/server-runtime/sessions/memoryStorage.d.ts
|
|
2687
2811
|
interface MemorySessionStorageOptions {
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2812
|
+
/**
|
|
2813
|
+
* The Cookie used to store the session id on the client, or options used
|
|
2814
|
+
* to automatically create one.
|
|
2815
|
+
*/
|
|
2816
|
+
cookie?: SessionIdStorageStrategy["cookie"];
|
|
2693
2817
|
}
|
|
2694
2818
|
/**
|
|
2695
|
-
* Creates and returns a simple in-memory SessionStorage object
|
|
2696
|
-
* for testing and as a reference implementation.
|
|
2819
|
+
* Creates and returns a simple in-memory SessionStorage object.
|
|
2697
2820
|
*
|
|
2698
|
-
*
|
|
2699
|
-
*
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2821
|
+
* Intended for local development and testing. It does not scale beyond a single
|
|
2822
|
+
* process, and all session data is lost when the server process stops/restarts.
|
|
2823
|
+
*
|
|
2824
|
+
* @public
|
|
2825
|
+
* @category Utils
|
|
2826
|
+
* @mode framework
|
|
2827
|
+
* @mode data
|
|
2828
|
+
* @param options Options for creating the in-memory session storage.
|
|
2829
|
+
* @returns A {@link SessionStorage} object that stores session data in memory.
|
|
2830
|
+
*/
|
|
2831
|
+
declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({
|
|
2832
|
+
cookie
|
|
2833
|
+
}?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
|
|
2834
|
+
//#endregion
|
|
2835
|
+
export { Await, BrowserRouter, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type FlashSessionData, Form, HashRouter, type IsCookieFunction, type IsSessionFunction, Link, Links, MemoryRouter, Meta, type MiddlewareFunction, type MiddlewareNextFunction, NavLink, Navigate, Outlet, Route, Router, type RouterContext, RouterContextProvider, RouterProvider, Routes, ScrollRestoration, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticRouter, StaticRouterProvider, createContext, createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, href, isCookie, isRouteErrorResponse, isSession, matchRoutes, redirect, redirectDocument, replace$1 as replace, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, getRequest as unstable_getRequest, matchRSCServerRequest as unstable_matchRSCServerRequest };
|