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