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
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
|
|
2
|
+
import { FormEncType, HTMLFormMethod, LoaderFunctionArgs, RouterContextProvider } from "./utils.js";
|
|
3
|
+
//#region lib/router/instrumentation.d.ts
|
|
4
|
+
type ServerInstrumentation = {
|
|
5
|
+
handler?: InstrumentRequestHandlerFunction;
|
|
6
|
+
route?: InstrumentRouteFunction;
|
|
7
|
+
};
|
|
8
|
+
type ClientInstrumentation = {
|
|
9
|
+
router?: InstrumentRouterFunction;
|
|
10
|
+
route?: InstrumentRouteFunction;
|
|
11
|
+
};
|
|
12
|
+
type InstrumentRequestHandlerFunction = (handler: InstrumentableRequestHandler) => void;
|
|
13
|
+
type InstrumentRouterFunction = (router: InstrumentableRouter) => void;
|
|
14
|
+
type InstrumentRouteFunction = (route: InstrumentableRoute) => void;
|
|
15
|
+
type InstrumentationHandlerResult = {
|
|
16
|
+
status: "success";
|
|
17
|
+
error: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
status: "error";
|
|
20
|
+
error: Error;
|
|
21
|
+
};
|
|
22
|
+
type InstrumentFunction<T> = (handler: () => Promise<InstrumentationHandlerResult>, info: T) => Promise<void>;
|
|
23
|
+
type ReadonlyRequest = {
|
|
24
|
+
method: string;
|
|
25
|
+
url: string;
|
|
26
|
+
headers: Pick<Headers, "get">;
|
|
27
|
+
};
|
|
28
|
+
type ReadonlyContext = Pick<RouterContextProvider, "get">;
|
|
29
|
+
type InstrumentableRoute = {
|
|
30
|
+
id: string;
|
|
31
|
+
index: boolean | undefined;
|
|
32
|
+
path: string | undefined;
|
|
33
|
+
instrument(instrumentations: RouteInstrumentations): void;
|
|
34
|
+
};
|
|
35
|
+
type RouteInstrumentations = {
|
|
36
|
+
lazy?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
|
37
|
+
"lazy.loader"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
|
38
|
+
"lazy.action"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
|
39
|
+
"lazy.middleware"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
|
40
|
+
middleware?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
|
|
41
|
+
loader?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
|
|
42
|
+
action?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
|
|
43
|
+
};
|
|
44
|
+
type RouteLazyInstrumentationInfo = undefined;
|
|
45
|
+
type RouteHandlerInstrumentationInfo = Readonly<{
|
|
46
|
+
request: ReadonlyRequest;
|
|
47
|
+
params: LoaderFunctionArgs["params"];
|
|
48
|
+
pattern: string;
|
|
49
|
+
context: ReadonlyContext;
|
|
50
|
+
}>;
|
|
51
|
+
type InstrumentableRouter = {
|
|
52
|
+
instrument(instrumentations: RouterInstrumentations): void;
|
|
53
|
+
};
|
|
54
|
+
type RouterInstrumentations = {
|
|
55
|
+
navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo>;
|
|
56
|
+
fetch?: InstrumentFunction<RouterFetchInstrumentationInfo>;
|
|
57
|
+
};
|
|
58
|
+
type RouterNavigationInstrumentationInfo = Readonly<{
|
|
59
|
+
to: string | number;
|
|
60
|
+
currentUrl: string;
|
|
61
|
+
formMethod?: HTMLFormMethod;
|
|
62
|
+
formEncType?: FormEncType;
|
|
63
|
+
formData?: FormData;
|
|
64
|
+
body?: any;
|
|
65
|
+
}>;
|
|
66
|
+
type RouterFetchInstrumentationInfo = Readonly<{
|
|
67
|
+
href: string;
|
|
68
|
+
currentUrl: string;
|
|
69
|
+
fetcherKey: string;
|
|
70
|
+
formMethod?: HTMLFormMethod;
|
|
71
|
+
formEncType?: FormEncType;
|
|
72
|
+
formData?: FormData;
|
|
73
|
+
body?: any;
|
|
74
|
+
}>;
|
|
75
|
+
type InstrumentableRequestHandler = {
|
|
76
|
+
instrument(instrumentations: RequestHandlerInstrumentations): void;
|
|
77
|
+
};
|
|
78
|
+
type RequestHandlerInstrumentations = {
|
|
79
|
+
request?: InstrumentFunction<RequestHandlerInstrumentationInfo>;
|
|
80
|
+
};
|
|
81
|
+
type RequestHandlerInstrumentationInfo = Readonly<{
|
|
82
|
+
request: ReadonlyRequest;
|
|
83
|
+
context: ReadonlyContext | undefined;
|
|
84
|
+
}>;
|
|
85
|
+
//#endregion
|
|
86
|
+
export { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRouteFunction, InstrumentRouterFunction, InstrumentationHandlerResult, ServerInstrumentation };
|
|
@@ -0,0 +1,213 @@
|
|
|
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 } from "./history.js";
|
|
12
|
+
//#region lib/router/instrumentation.ts
|
|
13
|
+
const UninstrumentedSymbol = Symbol("Uninstrumented");
|
|
14
|
+
function getRouteInstrumentationUpdates(fns, route) {
|
|
15
|
+
let aggregated = {
|
|
16
|
+
lazy: [],
|
|
17
|
+
"lazy.loader": [],
|
|
18
|
+
"lazy.action": [],
|
|
19
|
+
"lazy.middleware": [],
|
|
20
|
+
middleware: [],
|
|
21
|
+
loader: [],
|
|
22
|
+
action: []
|
|
23
|
+
};
|
|
24
|
+
fns.forEach((fn) => fn({
|
|
25
|
+
id: route.id,
|
|
26
|
+
index: route.index,
|
|
27
|
+
path: route.path,
|
|
28
|
+
instrument(i) {
|
|
29
|
+
let keys = Object.keys(aggregated);
|
|
30
|
+
for (let key of keys) if (i[key]) aggregated[key].push(i[key]);
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
let updates = {};
|
|
34
|
+
if (typeof route.lazy === "function" && aggregated.lazy.length > 0) {
|
|
35
|
+
let instrumented = wrapImpl(aggregated.lazy, route.lazy, () => void 0);
|
|
36
|
+
if (instrumented) updates.lazy = instrumented;
|
|
37
|
+
}
|
|
38
|
+
if (typeof route.lazy === "object") {
|
|
39
|
+
let lazyObject = route.lazy;
|
|
40
|
+
[
|
|
41
|
+
"middleware",
|
|
42
|
+
"loader",
|
|
43
|
+
"action"
|
|
44
|
+
].forEach((key) => {
|
|
45
|
+
let lazyFn = lazyObject[key];
|
|
46
|
+
let instrumentations = aggregated[`lazy.${key}`];
|
|
47
|
+
if (typeof lazyFn === "function" && instrumentations.length > 0) {
|
|
48
|
+
let instrumented = wrapImpl(instrumentations, lazyFn, () => void 0);
|
|
49
|
+
if (instrumented) updates.lazy = Object.assign(updates.lazy || {}, { [key]: instrumented });
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
["loader", "action"].forEach((key) => {
|
|
54
|
+
let handler = route[key];
|
|
55
|
+
if (typeof handler === "function" && aggregated[key].length > 0) {
|
|
56
|
+
let original = handler[UninstrumentedSymbol] ?? handler;
|
|
57
|
+
let instrumented = wrapImpl(aggregated[key], original, (...args) => getHandlerInfo(args[0]));
|
|
58
|
+
if (instrumented) {
|
|
59
|
+
if (key === "loader" && original.hydrate === true) instrumented.hydrate = true;
|
|
60
|
+
instrumented[UninstrumentedSymbol] = original;
|
|
61
|
+
updates[key] = instrumented;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
if (route.middleware && route.middleware.length > 0 && aggregated.middleware.length > 0) updates.middleware = route.middleware.map((middleware) => {
|
|
66
|
+
let original = middleware[UninstrumentedSymbol] ?? middleware;
|
|
67
|
+
let instrumented = wrapImpl(aggregated.middleware, original, (...args) => getHandlerInfo(args[0]));
|
|
68
|
+
if (instrumented) {
|
|
69
|
+
instrumented[UninstrumentedSymbol] = original;
|
|
70
|
+
return instrumented;
|
|
71
|
+
}
|
|
72
|
+
return middleware;
|
|
73
|
+
});
|
|
74
|
+
return updates;
|
|
75
|
+
}
|
|
76
|
+
function instrumentClientSideRouter(router, fns) {
|
|
77
|
+
let aggregated = {
|
|
78
|
+
navigate: [],
|
|
79
|
+
fetch: []
|
|
80
|
+
};
|
|
81
|
+
fns.forEach((fn) => fn({ instrument(i) {
|
|
82
|
+
let keys = Object.keys(i);
|
|
83
|
+
for (let key of keys) if (i[key]) aggregated[key].push(i[key]);
|
|
84
|
+
} }));
|
|
85
|
+
if (aggregated.navigate.length > 0) {
|
|
86
|
+
let navigate = router.navigate[UninstrumentedSymbol] ?? router.navigate;
|
|
87
|
+
let instrumentedNavigate = wrapImpl(aggregated.navigate, navigate, (...args) => {
|
|
88
|
+
let [to, opts] = args;
|
|
89
|
+
return {
|
|
90
|
+
to: typeof to === "number" || typeof to === "string" ? to : to ? createPath(to) : ".",
|
|
91
|
+
...getRouterInfo(router, opts ?? {})
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
if (instrumentedNavigate) {
|
|
95
|
+
instrumentedNavigate[UninstrumentedSymbol] = navigate;
|
|
96
|
+
router.navigate = instrumentedNavigate;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (aggregated.fetch.length > 0) {
|
|
100
|
+
let fetch = router.fetch[UninstrumentedSymbol] ?? router.fetch;
|
|
101
|
+
let instrumentedFetch = wrapImpl(aggregated.fetch, fetch, (...args) => {
|
|
102
|
+
let [key, , href, opts] = args;
|
|
103
|
+
return {
|
|
104
|
+
href: href ?? ".",
|
|
105
|
+
fetcherKey: key,
|
|
106
|
+
...getRouterInfo(router, opts ?? {})
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
if (instrumentedFetch) {
|
|
110
|
+
instrumentedFetch[UninstrumentedSymbol] = fetch;
|
|
111
|
+
router.fetch = instrumentedFetch;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return router;
|
|
115
|
+
}
|
|
116
|
+
function instrumentHandler(handler, fns) {
|
|
117
|
+
let aggregated = { request: [] };
|
|
118
|
+
fns.forEach((fn) => fn({ instrument(i) {
|
|
119
|
+
let keys = Object.keys(i);
|
|
120
|
+
for (let key of keys) if (i[key]) aggregated[key].push(i[key]);
|
|
121
|
+
} }));
|
|
122
|
+
let instrumentedHandler = handler;
|
|
123
|
+
if (aggregated.request.length > 0) instrumentedHandler = wrapImpl(aggregated.request, handler, (...args) => {
|
|
124
|
+
let [request, context] = args;
|
|
125
|
+
return {
|
|
126
|
+
request: getReadonlyRequest(request),
|
|
127
|
+
context: context != null ? getReadonlyContext(context) : context
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
return instrumentedHandler;
|
|
131
|
+
}
|
|
132
|
+
function wrapImpl(impls, handler, getInfo) {
|
|
133
|
+
if (impls.length === 0) return null;
|
|
134
|
+
return async (...args) => {
|
|
135
|
+
let result = await recurseRight(impls, getInfo(...args), () => handler(...args), impls.length - 1);
|
|
136
|
+
if (result.type === "error") throw result.value;
|
|
137
|
+
return result.value;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
async function recurseRight(impls, info, handler, index) {
|
|
141
|
+
let impl = impls[index];
|
|
142
|
+
let result;
|
|
143
|
+
if (!impl) try {
|
|
144
|
+
result = {
|
|
145
|
+
type: "success",
|
|
146
|
+
value: await handler()
|
|
147
|
+
};
|
|
148
|
+
} catch (e) {
|
|
149
|
+
result = {
|
|
150
|
+
type: "error",
|
|
151
|
+
value: e
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
let handlerPromise = void 0;
|
|
156
|
+
let callHandler = async () => {
|
|
157
|
+
if (handlerPromise) console.error("You cannot call instrumented handlers more than once");
|
|
158
|
+
else handlerPromise = recurseRight(impls, info, handler, index - 1);
|
|
159
|
+
result = await handlerPromise;
|
|
160
|
+
invariant(result, "Expected a result");
|
|
161
|
+
if (result.type === "error" && result.value instanceof Error) return {
|
|
162
|
+
status: "error",
|
|
163
|
+
error: result.value
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
status: "success",
|
|
167
|
+
error: void 0
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
try {
|
|
171
|
+
await impl(callHandler, info);
|
|
172
|
+
} catch (e) {
|
|
173
|
+
console.error("An instrumentation function threw an error:", e);
|
|
174
|
+
}
|
|
175
|
+
if (!handlerPromise) await callHandler();
|
|
176
|
+
await handlerPromise;
|
|
177
|
+
}
|
|
178
|
+
if (result) return result;
|
|
179
|
+
return {
|
|
180
|
+
type: "error",
|
|
181
|
+
value: /* @__PURE__ */ new Error("No result assigned in instrumentation chain.")
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function getHandlerInfo(args) {
|
|
185
|
+
let { request, context, params, pattern } = args;
|
|
186
|
+
return {
|
|
187
|
+
request: getReadonlyRequest(request),
|
|
188
|
+
params: { ...params },
|
|
189
|
+
pattern,
|
|
190
|
+
context: getReadonlyContext(context)
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function getRouterInfo(router, opts) {
|
|
194
|
+
return {
|
|
195
|
+
currentUrl: createPath(router.state.location),
|
|
196
|
+
..."formMethod" in opts ? { formMethod: opts.formMethod } : {},
|
|
197
|
+
..."formEncType" in opts ? { formEncType: opts.formEncType } : {},
|
|
198
|
+
..."formData" in opts ? { formData: opts.formData } : {},
|
|
199
|
+
..."body" in opts ? { body: opts.body } : {}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function getReadonlyRequest(request) {
|
|
203
|
+
return {
|
|
204
|
+
method: request.method,
|
|
205
|
+
url: request.url,
|
|
206
|
+
headers: { get: (...args) => request.headers.get(...args) }
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function getReadonlyContext(context) {
|
|
210
|
+
return { get: (ctx) => context.get(ctx) };
|
|
211
|
+
}
|
|
212
|
+
//#endregion
|
|
213
|
+
export { getRouteInstrumentationUpdates, instrumentClientSideRouter, instrumentHandler };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
|
|
2
|
+
//#region lib/router/links.d.ts
|
|
3
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
4
|
+
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
5
|
+
interface HtmlLinkProps {
|
|
6
|
+
/**
|
|
7
|
+
* Address of the hyperlink
|
|
8
|
+
*/
|
|
9
|
+
href?: string;
|
|
10
|
+
/**
|
|
11
|
+
* How the element handles crossorigin requests
|
|
12
|
+
*/
|
|
13
|
+
crossOrigin?: "anonymous" | "use-credentials";
|
|
14
|
+
/**
|
|
15
|
+
* Relationship between the document containing the hyperlink and the destination resource
|
|
16
|
+
*/
|
|
17
|
+
rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
|
|
18
|
+
/**
|
|
19
|
+
* Applicable media: "screen", "print", "(max-width: 764px)"
|
|
20
|
+
*/
|
|
21
|
+
media?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Integrity metadata used in Subresource Integrity checks
|
|
24
|
+
*/
|
|
25
|
+
integrity?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Language of the linked resource
|
|
28
|
+
*/
|
|
29
|
+
hrefLang?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Hint for the type of the referenced resource
|
|
32
|
+
*/
|
|
33
|
+
type?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Referrer policy for fetches initiated by the element
|
|
36
|
+
*/
|
|
37
|
+
referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
38
|
+
/**
|
|
39
|
+
* Sizes of the icons (for rel="icon")
|
|
40
|
+
*/
|
|
41
|
+
sizes?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Potential destination for a preload request (for rel="preload" and rel="modulepreload")
|
|
44
|
+
*/
|
|
45
|
+
as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
|
|
46
|
+
/**
|
|
47
|
+
* Color to use when customizing a site's icon (for rel="mask-icon")
|
|
48
|
+
*/
|
|
49
|
+
color?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the link is disabled
|
|
52
|
+
*/
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
|
|
56
|
+
*/
|
|
57
|
+
title?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Images to use in different situations, e.g., high-resolution displays,
|
|
60
|
+
* small monitors, etc. (for rel="preload")
|
|
61
|
+
*/
|
|
62
|
+
imageSrcSet?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Image sizes for different page layouts (for rel="preload")
|
|
65
|
+
*/
|
|
66
|
+
imageSizes?: string;
|
|
67
|
+
}
|
|
68
|
+
interface HtmlLinkPreloadImage extends HtmlLinkProps {
|
|
69
|
+
/**
|
|
70
|
+
* Relationship between the document containing the hyperlink and the destination resource
|
|
71
|
+
*/
|
|
72
|
+
rel: "preload";
|
|
73
|
+
/**
|
|
74
|
+
* Potential destination for a preload request (for rel="preload" and rel="modulepreload")
|
|
75
|
+
*/
|
|
76
|
+
as: "image";
|
|
77
|
+
/**
|
|
78
|
+
* Address of the hyperlink
|
|
79
|
+
*/
|
|
80
|
+
href?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Images to use in different situations, e.g., high-resolution displays,
|
|
83
|
+
* small monitors, etc. (for rel="preload")
|
|
84
|
+
*/
|
|
85
|
+
imageSrcSet: string;
|
|
86
|
+
/**
|
|
87
|
+
* Image sizes for different page layouts (for rel="preload")
|
|
88
|
+
*/
|
|
89
|
+
imageSizes?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Represents a `<link>` element.
|
|
93
|
+
*
|
|
94
|
+
* WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
|
|
95
|
+
*/
|
|
96
|
+
type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
|
|
97
|
+
imageSizes?: never;
|
|
98
|
+
});
|
|
99
|
+
interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
|
|
100
|
+
/**
|
|
101
|
+
* A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
|
|
102
|
+
* attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
|
|
103
|
+
* element
|
|
104
|
+
*/
|
|
105
|
+
nonce?: string | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* The absolute path of the page to prefetch, e.g. `/absolute/path`.
|
|
108
|
+
*/
|
|
109
|
+
page: string;
|
|
110
|
+
}
|
|
111
|
+
type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
|
|
112
|
+
//#endregion
|
|
113
|
+
export { HtmlLinkDescriptor, LinkDescriptor, PageLinkDescriptor };
|