react-router 7.15.1 → 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 +18 -2
- package/dist/development/dom-export.d.ts +6 -172
- package/dist/development/dom-export.js +12 -1007
- package/dist/development/index-react-server-client.d.ts +7 -4
- package/dist/development/index-react-server-client.js +8 -52
- package/dist/development/index-react-server.d.ts +1645 -1635
- package/dist/development/index-react-server.js +2880 -3642
- package/dist/development/index.d.ts +43 -1469
- 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-Bsscfj79.d.ts → development/lib/types/register.d.ts} +9 -15
- package/dist/development/lib/types/route-data.d.ts +113 -0
- package/dist/development/lib/types/route-module-annotations.d.ts +149 -0
- package/dist/development/lib/types/route-module.d.ts +19 -0
- package/dist/development/lib/types/serializes-to.d.ts +13 -0
- package/dist/development/lib/types/utils.d.ts +11 -0
- package/dist/development/vendor/turbo-stream-v2/flatten.js +159 -0
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +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 -1469
- 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-Bsscfj79.d.ts → production/lib/types/register.d.ts} +9 -15
- package/dist/production/lib/types/route-data.d.ts +113 -0
- package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
- package/dist/production/lib/types/route-module.d.ts +19 -0
- package/dist/production/lib/types/serializes-to.d.ts +13 -0
- package/dist/production/lib/types/utils.d.ts +11 -0
- package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +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-3AnU12UI.d.mts +0 -318
- package/dist/development/browser-BOdXz9dK.d.ts +0 -318
- package/dist/development/chunk-4N6VE7H7.mjs +0 -11528
- package/dist/development/chunk-4YRVXM2U.js +0 -188
- package/dist/development/chunk-66UKHEGQ.js +0 -1362
- package/dist/development/chunk-D6LUOGOQ.js +0 -10229
- package/dist/development/chunk-RJYABSBD.mjs +0 -2585
- package/dist/development/context-ByvtofY2.d.mts +0 -1771
- package/dist/development/data-BVUf681J.d.mts +0 -1732
- package/dist/development/data-BqZ2x964.d.ts +0 -1732
- package/dist/development/dom-export.d.mts +0 -172
- package/dist/development/dom-export.mjs +0 -1008
- package/dist/development/index-react-server-client-BS5F89FR.d.ts +0 -3655
- package/dist/development/index-react-server-client-DY04-103.d.mts +0 -2600
- package/dist/development/index-react-server-client.d.mts +0 -4
- package/dist/development/index-react-server-client.mjs +0 -59
- package/dist/development/index-react-server.d.mts +0 -2703
- package/dist/development/index-react-server.mjs +0 -3780
- package/dist/development/index.d.mts +0 -1472
- package/dist/development/index.mjs +0 -277
- package/dist/development/instrumentation-cRWWLfsU.d.ts +0 -715
- package/dist/development/lib/types/internal.d.mts +0 -184
- package/dist/development/lib/types/internal.mjs +0 -10
- package/dist/development/register-Df8okEea.d.mts +0 -30
- package/dist/production/browser-3AnU12UI.d.mts +0 -318
- package/dist/production/browser-BOdXz9dK.d.ts +0 -318
- package/dist/production/chunk-6S4627ZB.mjs +0 -2585
- package/dist/production/chunk-HUBUW7R3.js +0 -10229
- package/dist/production/chunk-JAKZPQZC.mjs +0 -11528
- package/dist/production/chunk-PNZCCTKT.js +0 -1362
- package/dist/production/chunk-Y6IFXO7V.js +0 -188
- package/dist/production/context-ByvtofY2.d.mts +0 -1771
- package/dist/production/data-BVUf681J.d.mts +0 -1732
- package/dist/production/data-BqZ2x964.d.ts +0 -1732
- package/dist/production/dom-export.d.mts +0 -172
- package/dist/production/dom-export.mjs +0 -1008
- package/dist/production/index-react-server-client-BS5F89FR.d.ts +0 -3655
- package/dist/production/index-react-server-client-DY04-103.d.mts +0 -2600
- package/dist/production/index-react-server-client.d.mts +0 -4
- package/dist/production/index-react-server-client.mjs +0 -59
- package/dist/production/index-react-server.d.mts +0 -2703
- package/dist/production/index-react-server.mjs +0 -3780
- package/dist/production/index.d.mts +0 -1472
- package/dist/production/index.mjs +0 -277
- package/dist/production/instrumentation-cRWWLfsU.d.ts +0 -715
- package/dist/production/lib/types/internal.d.mts +0 -184
- package/dist/production/lib/types/internal.mjs +0 -10
- package/dist/production/register-Df8okEea.d.mts +0 -30
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
|
|
2
|
+
import { Location } from "../router/history.js";
|
|
3
|
+
import { DataRouteObject, RouteBranch, RouteObject } from "../router/utils.js";
|
|
4
|
+
import { FutureConfig, Router, StaticHandlerContext } from "../router/router.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
|
|
7
|
+
//#region lib/dom/server.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* @category Types
|
|
10
|
+
*/
|
|
11
|
+
interface StaticRouterProps {
|
|
12
|
+
/**
|
|
13
|
+
* The base URL for the static router (default: `/`)
|
|
14
|
+
*/
|
|
15
|
+
basename?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The child elements to render inside the static router
|
|
18
|
+
*/
|
|
19
|
+
children?: React$1.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* The {@link Location} to render the static router at (default: `/`)
|
|
22
|
+
*/
|
|
23
|
+
location: Partial<Location> | string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A {@link Router | `<Router>`} that may not navigate to any other {@link Location}.
|
|
27
|
+
* This is useful on the server where there is no stateful UI.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
* @category Declarative Routers
|
|
31
|
+
* @mode declarative
|
|
32
|
+
* @param props Props
|
|
33
|
+
* @param {StaticRouterProps.basename} props.basename n/a
|
|
34
|
+
* @param {StaticRouterProps.children} props.children n/a
|
|
35
|
+
* @param {StaticRouterProps.location} props.location n/a
|
|
36
|
+
* @returns A React element that renders the static {@link Router | `<Router>`}
|
|
37
|
+
*/
|
|
38
|
+
declare function StaticRouter({
|
|
39
|
+
basename,
|
|
40
|
+
children,
|
|
41
|
+
location: locationProp
|
|
42
|
+
}: StaticRouterProps): React$1.JSX.Element;
|
|
43
|
+
/**
|
|
44
|
+
* @category Types
|
|
45
|
+
*/
|
|
46
|
+
interface StaticRouterProviderProps {
|
|
47
|
+
/**
|
|
48
|
+
* The {@link StaticHandlerContext} returned from {@link StaticHandler}'s
|
|
49
|
+
* `query`
|
|
50
|
+
*/
|
|
51
|
+
context: StaticHandlerContext;
|
|
52
|
+
/**
|
|
53
|
+
* The static {@link DataRouter} from {@link createStaticRouter}
|
|
54
|
+
*/
|
|
55
|
+
router: Router;
|
|
56
|
+
/**
|
|
57
|
+
* Whether to hydrate the router on the client (default `true`)
|
|
58
|
+
*/
|
|
59
|
+
hydrate?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
|
|
62
|
+
* to use for the hydration [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
|
63
|
+
* tag
|
|
64
|
+
*/
|
|
65
|
+
nonce?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A {@link DataRouter} that may not navigate to any other {@link Location}.
|
|
69
|
+
* This is useful on the server where there is no stateful UI.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* export async function handleRequest(request: Request) {
|
|
73
|
+
* let { query, dataRoutes } = createStaticHandler(routes);
|
|
74
|
+
* let context = await query(request));
|
|
75
|
+
*
|
|
76
|
+
* if (context instanceof Response) {
|
|
77
|
+
* return context;
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
80
|
+
* let router = createStaticRouter(dataRoutes, context);
|
|
81
|
+
* return new Response(
|
|
82
|
+
* ReactDOMServer.renderToString(<StaticRouterProvider ... />),
|
|
83
|
+
* { headers: { "Content-Type": "text/html" } }
|
|
84
|
+
* );
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* @public
|
|
88
|
+
* @category Data Routers
|
|
89
|
+
* @mode data
|
|
90
|
+
* @param props Props
|
|
91
|
+
* @param {StaticRouterProviderProps.context} props.context n/a
|
|
92
|
+
* @param {StaticRouterProviderProps.hydrate} props.hydrate n/a
|
|
93
|
+
* @param {StaticRouterProviderProps.nonce} props.nonce n/a
|
|
94
|
+
* @param {StaticRouterProviderProps.router} props.router n/a
|
|
95
|
+
* @returns A React element that renders the static router provider
|
|
96
|
+
*/
|
|
97
|
+
declare function StaticRouterProvider({
|
|
98
|
+
context,
|
|
99
|
+
router,
|
|
100
|
+
hydrate,
|
|
101
|
+
nonce
|
|
102
|
+
}: StaticRouterProviderProps): React$1.JSX.Element;
|
|
103
|
+
/**
|
|
104
|
+
* Create a static {@link DataRouter} for server-side rendering
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* export async function handleRequest(request: Request) {
|
|
108
|
+
* let { query, dataRoutes } = createStaticHandler(routes);
|
|
109
|
+
* let context = await query(request);
|
|
110
|
+
*
|
|
111
|
+
* if (context instanceof Response) {
|
|
112
|
+
* return context;
|
|
113
|
+
* }
|
|
114
|
+
*
|
|
115
|
+
* let router = createStaticRouter(dataRoutes, context);
|
|
116
|
+
* return new Response(
|
|
117
|
+
* ReactDOMServer.renderToString(<StaticRouterProvider ... />),
|
|
118
|
+
* { headers: { "Content-Type": "text/html" } }
|
|
119
|
+
* );
|
|
120
|
+
* }
|
|
121
|
+
*
|
|
122
|
+
* @public
|
|
123
|
+
* @category Data Routers
|
|
124
|
+
* @mode data
|
|
125
|
+
* @param routes The route objects to create a static {@link DataRouter} for
|
|
126
|
+
* @param context The {@link StaticHandlerContext} returned from {@link StaticHandler}'s
|
|
127
|
+
* `query`
|
|
128
|
+
* @param opts Options
|
|
129
|
+
* @param opts.future Future flags for the static {@link DataRouter}
|
|
130
|
+
* @param opts.branches Optional pre-computed route branches
|
|
131
|
+
* @returns A static {@link DataRouter} that can be used to render the provided routes
|
|
132
|
+
*/
|
|
133
|
+
declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
|
|
134
|
+
branches?: RouteBranch<DataRouteObject>[];
|
|
135
|
+
future?: Partial<FutureConfig>;
|
|
136
|
+
}): Router;
|
|
137
|
+
//#endregion
|
|
138
|
+
export { StaticRouter, StaticRouterProps, StaticRouterProvider, StaticRouterProviderProps, createStaticRouter };
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.0.0-pre.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import { createPath, invariant, parsePath } from "../router/history.js";
|
|
12
|
+
import { convertRoutesToDataRoutes, isRouteErrorResponse } from "../router/utils.js";
|
|
13
|
+
import { IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION } from "../router/router.js";
|
|
14
|
+
import { DataRouterContext, DataRouterStateContext, FetchersContext, ViewTransitionContext } from "../context.js";
|
|
15
|
+
import { DataRoutes, Router } from "../components.js";
|
|
16
|
+
import { escapeHtml } from "./ssr/markup.js";
|
|
17
|
+
import * as React$1 from "react";
|
|
18
|
+
//#region lib/dom/server.tsx
|
|
19
|
+
/**
|
|
20
|
+
* A {@link Router | `<Router>`} that may not navigate to any other {@link Location}.
|
|
21
|
+
* This is useful on the server where there is no stateful UI.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
* @category Declarative Routers
|
|
25
|
+
* @mode declarative
|
|
26
|
+
* @param props Props
|
|
27
|
+
* @param {StaticRouterProps.basename} props.basename n/a
|
|
28
|
+
* @param {StaticRouterProps.children} props.children n/a
|
|
29
|
+
* @param {StaticRouterProps.location} props.location n/a
|
|
30
|
+
* @returns A React element that renders the static {@link Router | `<Router>`}
|
|
31
|
+
*/
|
|
32
|
+
function StaticRouter({ basename, children, location: locationProp = "/" }) {
|
|
33
|
+
if (typeof locationProp === "string") locationProp = parsePath(locationProp);
|
|
34
|
+
let action = "POP";
|
|
35
|
+
let location = {
|
|
36
|
+
pathname: locationProp.pathname || "/",
|
|
37
|
+
search: locationProp.search || "",
|
|
38
|
+
hash: locationProp.hash || "",
|
|
39
|
+
state: locationProp.state != null ? locationProp.state : null,
|
|
40
|
+
key: locationProp.key || "default",
|
|
41
|
+
mask: void 0
|
|
42
|
+
};
|
|
43
|
+
let staticNavigator = getStatelessNavigator();
|
|
44
|
+
return /* @__PURE__ */ React$1.createElement(Router, {
|
|
45
|
+
basename,
|
|
46
|
+
children,
|
|
47
|
+
location,
|
|
48
|
+
navigationType: action,
|
|
49
|
+
navigator: staticNavigator,
|
|
50
|
+
static: true,
|
|
51
|
+
useTransitions: false
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A {@link DataRouter} that may not navigate to any other {@link Location}.
|
|
56
|
+
* This is useful on the server where there is no stateful UI.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* export async function handleRequest(request: Request) {
|
|
60
|
+
* let { query, dataRoutes } = createStaticHandler(routes);
|
|
61
|
+
* let context = await query(request));
|
|
62
|
+
*
|
|
63
|
+
* if (context instanceof Response) {
|
|
64
|
+
* return context;
|
|
65
|
+
* }
|
|
66
|
+
*
|
|
67
|
+
* let router = createStaticRouter(dataRoutes, context);
|
|
68
|
+
* return new Response(
|
|
69
|
+
* ReactDOMServer.renderToString(<StaticRouterProvider ... />),
|
|
70
|
+
* { headers: { "Content-Type": "text/html" } }
|
|
71
|
+
* );
|
|
72
|
+
* }
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
* @category Data Routers
|
|
76
|
+
* @mode data
|
|
77
|
+
* @param props Props
|
|
78
|
+
* @param {StaticRouterProviderProps.context} props.context n/a
|
|
79
|
+
* @param {StaticRouterProviderProps.hydrate} props.hydrate n/a
|
|
80
|
+
* @param {StaticRouterProviderProps.nonce} props.nonce n/a
|
|
81
|
+
* @param {StaticRouterProviderProps.router} props.router n/a
|
|
82
|
+
* @returns A React element that renders the static router provider
|
|
83
|
+
*/
|
|
84
|
+
function StaticRouterProvider({ context, router, hydrate = true, nonce }) {
|
|
85
|
+
invariant(router && context, "You must provide `router` and `context` to <StaticRouterProvider>");
|
|
86
|
+
let dataRouterContext = {
|
|
87
|
+
router,
|
|
88
|
+
navigator: getStatelessNavigator(),
|
|
89
|
+
static: true,
|
|
90
|
+
staticContext: context,
|
|
91
|
+
basename: context.basename || "/"
|
|
92
|
+
};
|
|
93
|
+
let fetchersContext = /* @__PURE__ */ new Map();
|
|
94
|
+
let hydrateScript = "";
|
|
95
|
+
if (hydrate !== false) {
|
|
96
|
+
let data = {
|
|
97
|
+
loaderData: context.loaderData,
|
|
98
|
+
actionData: context.actionData,
|
|
99
|
+
errors: serializeErrors(context.errors)
|
|
100
|
+
};
|
|
101
|
+
hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${escapeHtml(JSON.stringify(JSON.stringify(data)))});`;
|
|
102
|
+
}
|
|
103
|
+
let { state } = dataRouterContext.router;
|
|
104
|
+
return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React$1.createElement(DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React$1.createElement(FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React$1.createElement(ViewTransitionContext.Provider, { value: { isTransitioning: false } }, /* @__PURE__ */ React$1.createElement(Router, {
|
|
105
|
+
basename: dataRouterContext.basename,
|
|
106
|
+
location: state.location,
|
|
107
|
+
navigationType: state.historyAction,
|
|
108
|
+
navigator: dataRouterContext.navigator,
|
|
109
|
+
static: dataRouterContext.static,
|
|
110
|
+
useTransitions: false
|
|
111
|
+
}, /* @__PURE__ */ React$1.createElement(DataRoutes, {
|
|
112
|
+
manifest: router.manifest,
|
|
113
|
+
routes: router.routes,
|
|
114
|
+
future: router.future,
|
|
115
|
+
state,
|
|
116
|
+
isStatic: true
|
|
117
|
+
})))))), hydrateScript ? /* @__PURE__ */ React$1.createElement("script", {
|
|
118
|
+
suppressHydrationWarning: true,
|
|
119
|
+
nonce,
|
|
120
|
+
dangerouslySetInnerHTML: { __html: hydrateScript }
|
|
121
|
+
}) : null);
|
|
122
|
+
}
|
|
123
|
+
function serializeErrors(errors) {
|
|
124
|
+
if (!errors) return null;
|
|
125
|
+
let entries = Object.entries(errors);
|
|
126
|
+
let serialized = {};
|
|
127
|
+
for (let [key, val] of entries) if (isRouteErrorResponse(val)) serialized[key] = {
|
|
128
|
+
...val,
|
|
129
|
+
__type: "RouteErrorResponse"
|
|
130
|
+
};
|
|
131
|
+
else if (val instanceof Error) serialized[key] = {
|
|
132
|
+
message: val.message,
|
|
133
|
+
__type: "Error",
|
|
134
|
+
...val.name !== "Error" ? { __subType: val.name } : {}
|
|
135
|
+
};
|
|
136
|
+
else serialized[key] = val;
|
|
137
|
+
return serialized;
|
|
138
|
+
}
|
|
139
|
+
function getStatelessNavigator() {
|
|
140
|
+
return {
|
|
141
|
+
createHref,
|
|
142
|
+
encodeLocation,
|
|
143
|
+
push(to) {
|
|
144
|
+
throw new Error(`You cannot use navigator.push() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)})\` somewhere in your app.`);
|
|
145
|
+
},
|
|
146
|
+
replace(to) {
|
|
147
|
+
throw new Error(`You cannot use navigator.replace() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)}, { replace: true })\` somewhere in your app.`);
|
|
148
|
+
},
|
|
149
|
+
go(delta) {
|
|
150
|
+
throw new Error(`You cannot use navigator.go() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${delta})\` somewhere in your app.`);
|
|
151
|
+
},
|
|
152
|
+
back() {
|
|
153
|
+
throw new Error("You cannot use navigator.back() on the server because it is a stateless environment.");
|
|
154
|
+
},
|
|
155
|
+
forward() {
|
|
156
|
+
throw new Error("You cannot use navigator.forward() on the server because it is a stateless environment.");
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Create a static {@link DataRouter} for server-side rendering
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* export async function handleRequest(request: Request) {
|
|
165
|
+
* let { query, dataRoutes } = createStaticHandler(routes);
|
|
166
|
+
* let context = await query(request);
|
|
167
|
+
*
|
|
168
|
+
* if (context instanceof Response) {
|
|
169
|
+
* return context;
|
|
170
|
+
* }
|
|
171
|
+
*
|
|
172
|
+
* let router = createStaticRouter(dataRoutes, context);
|
|
173
|
+
* return new Response(
|
|
174
|
+
* ReactDOMServer.renderToString(<StaticRouterProvider ... />),
|
|
175
|
+
* { headers: { "Content-Type": "text/html" } }
|
|
176
|
+
* );
|
|
177
|
+
* }
|
|
178
|
+
*
|
|
179
|
+
* @public
|
|
180
|
+
* @category Data Routers
|
|
181
|
+
* @mode data
|
|
182
|
+
* @param routes The route objects to create a static {@link DataRouter} for
|
|
183
|
+
* @param context The {@link StaticHandlerContext} returned from {@link StaticHandler}'s
|
|
184
|
+
* `query`
|
|
185
|
+
* @param opts Options
|
|
186
|
+
* @param opts.future Future flags for the static {@link DataRouter}
|
|
187
|
+
* @param opts.branches Optional pre-computed route branches
|
|
188
|
+
* @returns A static {@link DataRouter} that can be used to render the provided routes
|
|
189
|
+
*/
|
|
190
|
+
function createStaticRouter(routes, context, opts = {}) {
|
|
191
|
+
let manifest = {};
|
|
192
|
+
let dataRoutes = convertRoutesToDataRoutes(routes, void 0, void 0, manifest);
|
|
193
|
+
let matches = context.matches.map((match) => {
|
|
194
|
+
let route = manifest[match.route.id] || match.route;
|
|
195
|
+
return {
|
|
196
|
+
...match,
|
|
197
|
+
route
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
let msg = (method) => `You cannot use router.${method}() on the server because it is a stateless environment`;
|
|
201
|
+
return {
|
|
202
|
+
get basename() {
|
|
203
|
+
return context.basename;
|
|
204
|
+
},
|
|
205
|
+
get future() {
|
|
206
|
+
return { ...opts?.future };
|
|
207
|
+
},
|
|
208
|
+
get state() {
|
|
209
|
+
return {
|
|
210
|
+
historyAction: "POP",
|
|
211
|
+
location: context.location,
|
|
212
|
+
matches,
|
|
213
|
+
loaderData: context.loaderData,
|
|
214
|
+
actionData: context.actionData,
|
|
215
|
+
errors: context.errors,
|
|
216
|
+
initialized: true,
|
|
217
|
+
renderFallback: false,
|
|
218
|
+
navigation: IDLE_NAVIGATION,
|
|
219
|
+
restoreScrollPosition: null,
|
|
220
|
+
preventScrollReset: false,
|
|
221
|
+
revalidation: "idle",
|
|
222
|
+
fetchers: /* @__PURE__ */ new Map(),
|
|
223
|
+
blockers: /* @__PURE__ */ new Map()
|
|
224
|
+
};
|
|
225
|
+
},
|
|
226
|
+
get routes() {
|
|
227
|
+
return dataRoutes;
|
|
228
|
+
},
|
|
229
|
+
get branches() {
|
|
230
|
+
return opts.branches;
|
|
231
|
+
},
|
|
232
|
+
get manifest() {
|
|
233
|
+
return manifest;
|
|
234
|
+
},
|
|
235
|
+
get window() {},
|
|
236
|
+
initialize() {
|
|
237
|
+
throw msg("initialize");
|
|
238
|
+
},
|
|
239
|
+
subscribe() {
|
|
240
|
+
throw msg("subscribe");
|
|
241
|
+
},
|
|
242
|
+
enableScrollRestoration() {
|
|
243
|
+
throw msg("enableScrollRestoration");
|
|
244
|
+
},
|
|
245
|
+
navigate() {
|
|
246
|
+
throw msg("navigate");
|
|
247
|
+
},
|
|
248
|
+
fetch() {
|
|
249
|
+
throw msg("fetch");
|
|
250
|
+
},
|
|
251
|
+
revalidate() {
|
|
252
|
+
throw msg("revalidate");
|
|
253
|
+
},
|
|
254
|
+
createHref,
|
|
255
|
+
encodeLocation,
|
|
256
|
+
getFetcher() {
|
|
257
|
+
return IDLE_FETCHER;
|
|
258
|
+
},
|
|
259
|
+
deleteFetcher() {
|
|
260
|
+
throw msg("deleteFetcher");
|
|
261
|
+
},
|
|
262
|
+
resetFetcher() {
|
|
263
|
+
throw msg("resetFetcher");
|
|
264
|
+
},
|
|
265
|
+
dispose() {
|
|
266
|
+
throw msg("dispose");
|
|
267
|
+
},
|
|
268
|
+
getBlocker() {
|
|
269
|
+
return IDLE_BLOCKER;
|
|
270
|
+
},
|
|
271
|
+
deleteBlocker() {
|
|
272
|
+
throw msg("deleteBlocker");
|
|
273
|
+
},
|
|
274
|
+
patchRoutes() {
|
|
275
|
+
throw msg("patchRoutes");
|
|
276
|
+
},
|
|
277
|
+
_internalFetchControllers: /* @__PURE__ */ new Map(),
|
|
278
|
+
_internalSetRoutes() {
|
|
279
|
+
throw msg("_internalSetRoutes");
|
|
280
|
+
},
|
|
281
|
+
_internalSetStateDoNotUseOrYouWillBreakYourApp() {
|
|
282
|
+
throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function createHref(to) {
|
|
287
|
+
return typeof to === "string" ? to : createPath(to);
|
|
288
|
+
}
|
|
289
|
+
function encodeLocation(to) {
|
|
290
|
+
let href = typeof to === "string" ? to : createPath(to);
|
|
291
|
+
href = href.replace(/ $/, "%20");
|
|
292
|
+
let encoded = ABSOLUTE_URL_REGEX.test(href) ? new URL(href) : new URL(href, "http://localhost");
|
|
293
|
+
return {
|
|
294
|
+
pathname: encoded.pathname,
|
|
295
|
+
search: encoded.search,
|
|
296
|
+
hash: encoded.hash
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
300
|
+
//#endregion
|
|
301
|
+
export { StaticRouter, StaticRouterProvider, createStaticRouter };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
|
|
2
|
+
import { PageLinkDescriptor } from "../../router/links.js";
|
|
3
|
+
import { FrameworkContextObject } from "./entry.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
|
|
6
|
+
//#region lib/dom/ssr/components.d.ts
|
|
7
|
+
declare const FrameworkContext: React$1.Context<FrameworkContextObject | undefined>;
|
|
8
|
+
/**
|
|
9
|
+
* Defines the [lazy route discovery](../../explanation/lazy-route-discovery)
|
|
10
|
+
* behavior of the link/form:
|
|
11
|
+
*
|
|
12
|
+
* - "render" - default, discover the route when the link renders
|
|
13
|
+
* - "none" - don't eagerly discover, only discover if the link is clicked
|
|
14
|
+
*/
|
|
15
|
+
type DiscoverBehavior = "render" | "none";
|
|
16
|
+
/**
|
|
17
|
+
* Defines the prefetching behavior of the link:
|
|
18
|
+
*
|
|
19
|
+
* - "none": Never fetched
|
|
20
|
+
* - "intent": Fetched when the user focuses or hovers the link
|
|
21
|
+
* - "render": Fetched when the link is rendered
|
|
22
|
+
* - "viewport": Fetched when the link is in the viewport
|
|
23
|
+
*/
|
|
24
|
+
type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
|
|
25
|
+
/**
|
|
26
|
+
* Props for the {@link Links} component.
|
|
27
|
+
*
|
|
28
|
+
* @category Types
|
|
29
|
+
*/
|
|
30
|
+
interface LinksProps {
|
|
31
|
+
/**
|
|
32
|
+
* A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
|
|
33
|
+
* attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
|
|
34
|
+
* element
|
|
35
|
+
*/
|
|
36
|
+
nonce?: string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* A [`crossOrigin`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin)
|
|
39
|
+
* attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
|
|
40
|
+
* element
|
|
41
|
+
*/
|
|
42
|
+
crossOrigin?: "anonymous" | "use-credentials";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Renders all the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
|
|
46
|
+
* tags created by the route module's [`links`](../../start/framework/route-module#links)
|
|
47
|
+
* export. You should render it inside the [`<head>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head)
|
|
48
|
+
* of your document.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* import { Links } from "react-router";
|
|
52
|
+
*
|
|
53
|
+
* export default function Root() {
|
|
54
|
+
* return (
|
|
55
|
+
* <html>
|
|
56
|
+
* <head>
|
|
57
|
+
* <Links />
|
|
58
|
+
* </head>
|
|
59
|
+
* <body></body>
|
|
60
|
+
* </html>
|
|
61
|
+
* );
|
|
62
|
+
* }
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
* @category Components
|
|
66
|
+
* @mode framework
|
|
67
|
+
* @param props Props
|
|
68
|
+
* @param {LinksProps.nonce} props.nonce n/a
|
|
69
|
+
* @param {LinksProps.crossOrigin} props.crossOrigin n/a
|
|
70
|
+
* @returns A collection of React elements for [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
|
|
71
|
+
* tags
|
|
72
|
+
*/
|
|
73
|
+
declare function Links({
|
|
74
|
+
nonce,
|
|
75
|
+
crossOrigin
|
|
76
|
+
}: LinksProps): React$1.JSX.Element;
|
|
77
|
+
/**
|
|
78
|
+
* Renders [`<link rel=prefetch|modulepreload>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/rel)
|
|
79
|
+
* tags for modules and data of another page to enable an instant navigation to
|
|
80
|
+
* that page. [`<Link prefetch>`](./Link#prefetch) uses this internally, but you
|
|
81
|
+
* can render it to prefetch a page for any other reason.
|
|
82
|
+
*
|
|
83
|
+
* For example, you may render one of this as the user types into a search field
|
|
84
|
+
* to prefetch search results before they click through to their selection.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* import { PrefetchPageLinks } from "react-router";
|
|
88
|
+
*
|
|
89
|
+
* <PrefetchPageLinks page="/absolute/path" />
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
* @category Components
|
|
93
|
+
* @mode framework
|
|
94
|
+
* @param props Props
|
|
95
|
+
* @param {PageLinkDescriptor.page} props.page n/a
|
|
96
|
+
* @param props.linkProps Additional props to spread onto the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
|
|
97
|
+
* tags, such as [`crossOrigin`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/crossOrigin),
|
|
98
|
+
* [`integrity`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/integrity),
|
|
99
|
+
* [`rel`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/rel),
|
|
100
|
+
* etc.
|
|
101
|
+
* @returns A collection of React elements for [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
|
|
102
|
+
* tags
|
|
103
|
+
*/
|
|
104
|
+
declare function PrefetchPageLinks({
|
|
105
|
+
page,
|
|
106
|
+
...linkProps
|
|
107
|
+
}: PageLinkDescriptor): React$1.JSX.Element | null;
|
|
108
|
+
/**
|
|
109
|
+
* Renders all the [`<meta>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta)
|
|
110
|
+
* tags created by the route module's [`meta`](../../start/framework/route-module#meta)
|
|
111
|
+
* export. You should render it inside the [`<head>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head)
|
|
112
|
+
* of your document.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* import { Meta } from "react-router";
|
|
116
|
+
*
|
|
117
|
+
* export default function Root() {
|
|
118
|
+
* return (
|
|
119
|
+
* <html>
|
|
120
|
+
* <head>
|
|
121
|
+
* <Meta />
|
|
122
|
+
* </head>
|
|
123
|
+
* </html>
|
|
124
|
+
* );
|
|
125
|
+
* }
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
* @category Components
|
|
129
|
+
* @mode framework
|
|
130
|
+
* @returns A collection of React elements for [`<meta>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta)
|
|
131
|
+
* tags
|
|
132
|
+
*/
|
|
133
|
+
declare function Meta(): React$1.JSX.Element;
|
|
134
|
+
/**
|
|
135
|
+
* A couple common attributes:
|
|
136
|
+
*
|
|
137
|
+
* - `<Scripts crossOrigin>` for hosting your static assets on a different
|
|
138
|
+
* server than your app.
|
|
139
|
+
* - `<Scripts nonce>` to support a [content security policy for scripts](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src)
|
|
140
|
+
* with [nonce-sources](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/Sources#sources)
|
|
141
|
+
* for your [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
|
142
|
+
* tags.
|
|
143
|
+
*
|
|
144
|
+
* You cannot pass through attributes such as [`async`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/async),
|
|
145
|
+
* [`defer`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/defer),
|
|
146
|
+
* [`noModule`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/noModule),
|
|
147
|
+
* [`src`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/src),
|
|
148
|
+
* or [`type`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/type),
|
|
149
|
+
* because they are managed by React Router internally.
|
|
150
|
+
*
|
|
151
|
+
* @category Types
|
|
152
|
+
*/
|
|
153
|
+
type ScriptsProps = Omit<React$1.HTMLProps<HTMLScriptElement>, "async" | "children" | "dangerouslySetInnerHTML" | "defer" | "noModule" | "src" | "suppressHydrationWarning" | "type"> & {
|
|
154
|
+
/**
|
|
155
|
+
* A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
|
|
156
|
+
* attribute to render on the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
|
157
|
+
* element
|
|
158
|
+
*/
|
|
159
|
+
nonce?: string | undefined;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Renders the client runtime of your app. It should be rendered inside the
|
|
163
|
+
* [`<body>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body)
|
|
164
|
+
* of the document.
|
|
165
|
+
*
|
|
166
|
+
* If server rendering, you can omit `<Scripts/>` and the app will work as a
|
|
167
|
+
* traditional web app without JavaScript, relying solely on HTML and browser
|
|
168
|
+
* behaviors.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* import { Scripts } from "react-router";
|
|
172
|
+
*
|
|
173
|
+
* export default function Root() {
|
|
174
|
+
* return (
|
|
175
|
+
* <html>
|
|
176
|
+
* <head />
|
|
177
|
+
* <body>
|
|
178
|
+
* <Scripts />
|
|
179
|
+
* </body>
|
|
180
|
+
* </html>
|
|
181
|
+
* );
|
|
182
|
+
* }
|
|
183
|
+
*
|
|
184
|
+
* @public
|
|
185
|
+
* @category Components
|
|
186
|
+
* @mode framework
|
|
187
|
+
* @param scriptProps Additional props to spread onto the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
|
188
|
+
* tags, such as [`crossOrigin`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/crossOrigin),
|
|
189
|
+
* [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce),
|
|
190
|
+
* etc.
|
|
191
|
+
* @returns A collection of React elements for [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
|
192
|
+
* tags
|
|
193
|
+
*/
|
|
194
|
+
declare function Scripts(scriptProps: ScriptsProps): React$1.JSX.Element | null;
|
|
195
|
+
//#endregion
|
|
196
|
+
export { DiscoverBehavior, FrameworkContext, Links, LinksProps, Meta, PrefetchBehavior, PrefetchPageLinks, Scripts, ScriptsProps };
|