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,48 @@
|
|
|
1
|
+
|
|
2
|
+
//#region lib/rsc/html-stream/browser.d.ts
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
__FLIGHT_DATA: any[];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get the prerendered [RSC](https://react.dev/reference/rsc/server-components)
|
|
10
|
+
* stream for hydration. Usually passed directly to your
|
|
11
|
+
* `react-server-dom-xyz/client`'s `createFromReadableStream`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { startTransition, StrictMode } from "react";
|
|
15
|
+
* import { hydrateRoot } from "react-dom/client";
|
|
16
|
+
* import {
|
|
17
|
+
* unstable_getRSCStream as getRSCStream,
|
|
18
|
+
* unstable_RSCHydratedRouter as RSCHydratedRouter,
|
|
19
|
+
* } from "react-router";
|
|
20
|
+
* import type { unstable_RSCPayload as RSCPayload } from "react-router";
|
|
21
|
+
*
|
|
22
|
+
* createFromReadableStream(getRSCStream()).then(
|
|
23
|
+
* (payload: RSCServerPayload) => {
|
|
24
|
+
* startTransition(async () => {
|
|
25
|
+
* hydrateRoot(
|
|
26
|
+
* document,
|
|
27
|
+
* <StrictMode>
|
|
28
|
+
* <RSCHydratedRouter {...props} />
|
|
29
|
+
* </StrictMode>,
|
|
30
|
+
* {
|
|
31
|
+
* // Options
|
|
32
|
+
* }
|
|
33
|
+
* );
|
|
34
|
+
* });
|
|
35
|
+
* }
|
|
36
|
+
* );
|
|
37
|
+
*
|
|
38
|
+
* @name unstable_getRSCStream
|
|
39
|
+
* @public
|
|
40
|
+
* @category RSC
|
|
41
|
+
* @mode data
|
|
42
|
+
* @returns A [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
|
|
43
|
+
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
|
44
|
+
* data for hydration.
|
|
45
|
+
*/
|
|
46
|
+
declare function getRSCStream(): ReadableStream;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { getRSCStream };
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
//#region lib/rsc/html-stream/browser.ts
|
|
12
|
+
/**
|
|
13
|
+
* Get the prerendered [RSC](https://react.dev/reference/rsc/server-components)
|
|
14
|
+
* stream for hydration. Usually passed directly to your
|
|
15
|
+
* `react-server-dom-xyz/client`'s `createFromReadableStream`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* import { startTransition, StrictMode } from "react";
|
|
19
|
+
* import { hydrateRoot } from "react-dom/client";
|
|
20
|
+
* import {
|
|
21
|
+
* unstable_getRSCStream as getRSCStream,
|
|
22
|
+
* unstable_RSCHydratedRouter as RSCHydratedRouter,
|
|
23
|
+
* } from "react-router";
|
|
24
|
+
* import type { unstable_RSCPayload as RSCPayload } from "react-router";
|
|
25
|
+
*
|
|
26
|
+
* createFromReadableStream(getRSCStream()).then(
|
|
27
|
+
* (payload: RSCServerPayload) => {
|
|
28
|
+
* startTransition(async () => {
|
|
29
|
+
* hydrateRoot(
|
|
30
|
+
* document,
|
|
31
|
+
* <StrictMode>
|
|
32
|
+
* <RSCHydratedRouter {...props} />
|
|
33
|
+
* </StrictMode>,
|
|
34
|
+
* {
|
|
35
|
+
* // Options
|
|
36
|
+
* }
|
|
37
|
+
* );
|
|
38
|
+
* });
|
|
39
|
+
* }
|
|
40
|
+
* );
|
|
41
|
+
*
|
|
42
|
+
* @name unstable_getRSCStream
|
|
43
|
+
* @public
|
|
44
|
+
* @category RSC
|
|
45
|
+
* @mode data
|
|
46
|
+
* @returns A [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
|
|
47
|
+
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
|
48
|
+
* data for hydration.
|
|
49
|
+
*/
|
|
50
|
+
function getRSCStream() {
|
|
51
|
+
let encoder = new TextEncoder();
|
|
52
|
+
let streamController = null;
|
|
53
|
+
let rscStream = new ReadableStream({ start(controller) {
|
|
54
|
+
if (typeof window === "undefined") return;
|
|
55
|
+
let handleChunk = (chunk) => {
|
|
56
|
+
if (typeof chunk === "string") controller.enqueue(encoder.encode(chunk));
|
|
57
|
+
else controller.enqueue(chunk);
|
|
58
|
+
};
|
|
59
|
+
window.__FLIGHT_DATA ||= [];
|
|
60
|
+
window.__FLIGHT_DATA.forEach(handleChunk);
|
|
61
|
+
window.__FLIGHT_DATA.push = (chunk) => {
|
|
62
|
+
handleChunk(chunk);
|
|
63
|
+
return 0;
|
|
64
|
+
};
|
|
65
|
+
streamController = controller;
|
|
66
|
+
} });
|
|
67
|
+
if (typeof document !== "undefined" && document.readyState === "loading") document.addEventListener("DOMContentLoaded", () => {
|
|
68
|
+
streamController?.close();
|
|
69
|
+
});
|
|
70
|
+
else streamController?.close();
|
|
71
|
+
return rscStream;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { getRSCStream };
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
//#region lib/rsc/html-stream/server.ts
|
|
12
|
+
const encoder = new TextEncoder();
|
|
13
|
+
const trailer = "</body></html>";
|
|
14
|
+
function injectRSCPayload(rscStream) {
|
|
15
|
+
let decoder = new TextDecoder();
|
|
16
|
+
let resolveFlightDataPromise;
|
|
17
|
+
let flightDataPromise = new Promise((resolve) => resolveFlightDataPromise = resolve);
|
|
18
|
+
let startedRSC = false;
|
|
19
|
+
let buffered = [];
|
|
20
|
+
let timeout = null;
|
|
21
|
+
function flushBufferedChunks(controller) {
|
|
22
|
+
for (let chunk of buffered) {
|
|
23
|
+
let buf = decoder.decode(chunk, { stream: true });
|
|
24
|
+
if (buf.endsWith(trailer)) buf = buf.slice(0, -14);
|
|
25
|
+
controller.enqueue(encoder.encode(buf));
|
|
26
|
+
}
|
|
27
|
+
buffered.length = 0;
|
|
28
|
+
timeout = null;
|
|
29
|
+
}
|
|
30
|
+
return new TransformStream({
|
|
31
|
+
transform(chunk, controller) {
|
|
32
|
+
buffered.push(chunk);
|
|
33
|
+
if (timeout) return;
|
|
34
|
+
timeout = setTimeout(async () => {
|
|
35
|
+
flushBufferedChunks(controller);
|
|
36
|
+
if (!startedRSC) {
|
|
37
|
+
startedRSC = true;
|
|
38
|
+
writeRSCStream(rscStream, controller).catch((err) => controller.error(err)).then(resolveFlightDataPromise);
|
|
39
|
+
}
|
|
40
|
+
}, 0);
|
|
41
|
+
},
|
|
42
|
+
async flush(controller) {
|
|
43
|
+
await flightDataPromise;
|
|
44
|
+
if (timeout) {
|
|
45
|
+
clearTimeout(timeout);
|
|
46
|
+
flushBufferedChunks(controller);
|
|
47
|
+
}
|
|
48
|
+
controller.enqueue(encoder.encode("</body></html>"));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async function writeRSCStream(rscStream, controller) {
|
|
53
|
+
let decoder = new TextDecoder("utf-8", { fatal: true });
|
|
54
|
+
const reader = rscStream.getReader();
|
|
55
|
+
try {
|
|
56
|
+
let read;
|
|
57
|
+
while ((read = await reader.read()) && !read.done) {
|
|
58
|
+
const chunk = read.value;
|
|
59
|
+
try {
|
|
60
|
+
writeChunk(JSON.stringify(decoder.decode(chunk, { stream: true })), controller);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
writeChunk(`Uint8Array.from(atob(${JSON.stringify(btoa(String.fromCodePoint(...chunk)))}), m => m.codePointAt(0))`, controller);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} finally {
|
|
66
|
+
reader.releaseLock();
|
|
67
|
+
}
|
|
68
|
+
let remaining = decoder.decode();
|
|
69
|
+
if (remaining.length) writeChunk(JSON.stringify(remaining), controller);
|
|
70
|
+
}
|
|
71
|
+
function writeChunk(chunk, controller) {
|
|
72
|
+
controller.enqueue(encoder.encode(`<script>${escapeScript(`(self.__FLIGHT_DATA||=[]).push(${chunk})`)}<\/script>`));
|
|
73
|
+
}
|
|
74
|
+
function escapeScript(script) {
|
|
75
|
+
return script.replace(/<!--/g, "<\\!--").replace(/<\/(script)/gi, "</\\$1");
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { injectRSCPayload };
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
//#region lib/rsc/route-modules.ts
|
|
12
|
+
function createRSCRouteModules(payload) {
|
|
13
|
+
const routeModules = {};
|
|
14
|
+
for (const match of payload.matches) populateRSCRouteModules(routeModules, match);
|
|
15
|
+
return routeModules;
|
|
16
|
+
}
|
|
17
|
+
function populateRSCRouteModules(routeModules, matches) {
|
|
18
|
+
matches = Array.isArray(matches) ? matches : [matches];
|
|
19
|
+
for (const match of matches) routeModules[match.id] = {
|
|
20
|
+
links: match.links,
|
|
21
|
+
meta: match.meta,
|
|
22
|
+
default: noopComponent
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const noopComponent = () => null;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { createRSCRouteModules, populateRSCRouteModules };
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
|
|
2
|
+
import { Location } from "../router/history.js";
|
|
3
|
+
import { ActionFunction, LoaderFunction, Params, RouterContextProvider, ShouldRevalidateFunction } from "../router/utils.js";
|
|
4
|
+
import { ClientActionFunction, ClientLoaderFunction, HeadersFunction, LinksFunction, MetaFunction } from "../dom/ssr/routeModules.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
|
|
7
|
+
//#region lib/rsc/server.rsc.d.ts
|
|
8
|
+
declare function getRequest(): Request;
|
|
9
|
+
type RSCRouteConfigEntryBase = {
|
|
10
|
+
action?: ActionFunction;
|
|
11
|
+
clientAction?: ClientActionFunction;
|
|
12
|
+
clientLoader?: ClientLoaderFunction;
|
|
13
|
+
ErrorBoundary?: React$1.ComponentType<any>;
|
|
14
|
+
handle?: any;
|
|
15
|
+
headers?: HeadersFunction;
|
|
16
|
+
HydrateFallback?: React$1.ComponentType<any>;
|
|
17
|
+
Layout?: React$1.ComponentType<any>;
|
|
18
|
+
links?: LinksFunction;
|
|
19
|
+
loader?: LoaderFunction;
|
|
20
|
+
meta?: MetaFunction;
|
|
21
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
22
|
+
};
|
|
23
|
+
type RSCRouteConfigEntry = RSCRouteConfigEntryBase & {
|
|
24
|
+
id: string;
|
|
25
|
+
path?: string;
|
|
26
|
+
Component?: React$1.ComponentType<any>;
|
|
27
|
+
lazy?: () => Promise<RSCRouteConfigEntryBase & ({
|
|
28
|
+
default?: React$1.ComponentType<any>;
|
|
29
|
+
Component?: never;
|
|
30
|
+
} | {
|
|
31
|
+
default?: never;
|
|
32
|
+
Component?: React$1.ComponentType<any>;
|
|
33
|
+
})>;
|
|
34
|
+
} & ({
|
|
35
|
+
index: true;
|
|
36
|
+
} | {
|
|
37
|
+
children?: RSCRouteConfigEntry[];
|
|
38
|
+
});
|
|
39
|
+
type RSCRouteConfig = Array<RSCRouteConfigEntry>;
|
|
40
|
+
type RSCRouteManifest = {
|
|
41
|
+
clientAction?: ClientActionFunction;
|
|
42
|
+
clientLoader?: ClientLoaderFunction;
|
|
43
|
+
element?: React$1.ReactElement | false;
|
|
44
|
+
errorElement?: React$1.ReactElement;
|
|
45
|
+
handle?: any;
|
|
46
|
+
hasAction: boolean;
|
|
47
|
+
hasComponent: boolean;
|
|
48
|
+
hasLoader: boolean;
|
|
49
|
+
hydrateFallbackElement?: React$1.ReactElement;
|
|
50
|
+
id: string;
|
|
51
|
+
index?: boolean;
|
|
52
|
+
links?: LinksFunction;
|
|
53
|
+
meta?: MetaFunction;
|
|
54
|
+
parentId?: string;
|
|
55
|
+
path?: string;
|
|
56
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
57
|
+
};
|
|
58
|
+
type RSCRouteMatch = RSCRouteManifest & {
|
|
59
|
+
params: Params;
|
|
60
|
+
pathname: string;
|
|
61
|
+
pathnameBase: string;
|
|
62
|
+
};
|
|
63
|
+
type RSCRenderPayload = {
|
|
64
|
+
type: "render";
|
|
65
|
+
actionData: Record<string, any> | null;
|
|
66
|
+
basename: string | undefined;
|
|
67
|
+
errors: Record<string, any> | null;
|
|
68
|
+
loaderData: Record<string, any>;
|
|
69
|
+
location: Location;
|
|
70
|
+
routeDiscovery: RouteDiscovery;
|
|
71
|
+
matches: RSCRouteMatch[];
|
|
72
|
+
patches?: Promise<RSCRouteManifest[]>;
|
|
73
|
+
nonce?: string;
|
|
74
|
+
formState?: unknown;
|
|
75
|
+
};
|
|
76
|
+
type RSCManifestPayload = {
|
|
77
|
+
type: "manifest";
|
|
78
|
+
patches: Promise<RSCRouteManifest[]>;
|
|
79
|
+
};
|
|
80
|
+
type RSCActionPayload = {
|
|
81
|
+
type: "action";
|
|
82
|
+
actionResult: Promise<unknown>;
|
|
83
|
+
rerender?: Promise<RSCRenderPayload | RSCRedirectPayload>;
|
|
84
|
+
};
|
|
85
|
+
type RSCRedirectPayload = {
|
|
86
|
+
type: "redirect";
|
|
87
|
+
status: number;
|
|
88
|
+
location: string;
|
|
89
|
+
replace: boolean;
|
|
90
|
+
reload: boolean;
|
|
91
|
+
actionResult?: Promise<unknown>;
|
|
92
|
+
};
|
|
93
|
+
type RSCPayload = RSCRenderPayload | RSCManifestPayload | RSCActionPayload | RSCRedirectPayload;
|
|
94
|
+
type RSCMatch = {
|
|
95
|
+
statusCode: number;
|
|
96
|
+
headers: Headers;
|
|
97
|
+
payload: RSCPayload;
|
|
98
|
+
};
|
|
99
|
+
type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
|
|
100
|
+
type DecodeFormStateFunction = (result: unknown, formData: FormData) => unknown;
|
|
101
|
+
type DecodeReplyFunction = (reply: FormData | string, options: {
|
|
102
|
+
temporaryReferences: unknown;
|
|
103
|
+
}) => Promise<unknown[]>;
|
|
104
|
+
type LoadServerActionFunction = (id: string) => Promise<Function>;
|
|
105
|
+
type RouteDiscovery = {
|
|
106
|
+
mode: "lazy";
|
|
107
|
+
manifestPath?: string | undefined;
|
|
108
|
+
} | {
|
|
109
|
+
mode: "initial";
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
113
|
+
* and returns an [RSC](https://react.dev/reference/rsc/server-components)
|
|
114
|
+
* [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
115
|
+
* encoding an {@link unstable_RSCPayload} for consumption by an [RSC](https://react.dev/reference/rsc/server-components)
|
|
116
|
+
* enabled client router.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* import {
|
|
120
|
+
* createTemporaryReferenceSet,
|
|
121
|
+
* decodeAction,
|
|
122
|
+
* decodeReply,
|
|
123
|
+
* loadServerAction,
|
|
124
|
+
* renderToReadableStream,
|
|
125
|
+
* } from "@vitejs/plugin-rsc/rsc";
|
|
126
|
+
* import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router";
|
|
127
|
+
*
|
|
128
|
+
* matchRSCServerRequest({
|
|
129
|
+
* createTemporaryReferenceSet,
|
|
130
|
+
* decodeAction,
|
|
131
|
+
* decodeFormState,
|
|
132
|
+
* decodeReply,
|
|
133
|
+
* loadServerAction,
|
|
134
|
+
* request,
|
|
135
|
+
* routes: routes(),
|
|
136
|
+
* generateResponse(match) {
|
|
137
|
+
* return new Response(
|
|
138
|
+
* renderToReadableStream(match.payload),
|
|
139
|
+
* {
|
|
140
|
+
* status: match.statusCode,
|
|
141
|
+
* headers: match.headers,
|
|
142
|
+
* }
|
|
143
|
+
* );
|
|
144
|
+
* },
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* @name unstable_matchRSCServerRequest
|
|
148
|
+
* @public
|
|
149
|
+
* @category RSC
|
|
150
|
+
* @mode data
|
|
151
|
+
* @param opts Options
|
|
152
|
+
* @param opts.allowedActionOrigins Origin patterns that are allowed to execute actions.
|
|
153
|
+
* @param opts.basename The basename to use when matching the request.
|
|
154
|
+
* @param opts.createTemporaryReferenceSet A function that returns a temporary
|
|
155
|
+
* reference set for the request, used to track temporary references in the [RSC](https://react.dev/reference/rsc/server-components)
|
|
156
|
+
* stream.
|
|
157
|
+
* @param opts.decodeAction Your `react-server-dom-xyz/server`'s `decodeAction`
|
|
158
|
+
* function, responsible for loading a server action.
|
|
159
|
+
* @param opts.decodeFormState A function responsible for decoding form state for
|
|
160
|
+
* progressively enhanceable forms with React's [`useActionState`](https://react.dev/reference/react/useActionState)
|
|
161
|
+
* using your `react-server-dom-xyz/server`'s `decodeFormState`.
|
|
162
|
+
* @param opts.decodeReply Your `react-server-dom-xyz/server`'s `decodeReply`
|
|
163
|
+
* function, used to decode the server function's arguments and bind them to the
|
|
164
|
+
* implementation for invocation by the router.
|
|
165
|
+
* @param opts.generateResponse A function responsible for using your
|
|
166
|
+
* `renderToReadableStream` to generate a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
167
|
+
* encoding the {@link unstable_RSCPayload}.
|
|
168
|
+
* @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
|
|
169
|
+
* `loadServerAction` function, used to load a server action by ID.
|
|
170
|
+
* @param opts.onError An optional error handler that will be called with any
|
|
171
|
+
* errors that occur during the request processing.
|
|
172
|
+
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
173
|
+
* to match against.
|
|
174
|
+
* @param opts.requestContext An instance of {@link RouterContextProvider}
|
|
175
|
+
* that should be created per request, to be passed to [`action`](../../start/data/route-object#action)s,
|
|
176
|
+
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
|
177
|
+
* @param opts.routeDiscovery The route discovery configuration, used to determine how the router should discover new routes during navigations.
|
|
178
|
+
* @param opts.routes Your {@link unstable_RSCRouteConfigEntry | route definitions}.
|
|
179
|
+
* @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
180
|
+
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
|
181
|
+
* data for hydration.
|
|
182
|
+
*/
|
|
183
|
+
declare function matchRSCServerRequest({
|
|
184
|
+
allowedActionOrigins,
|
|
185
|
+
createTemporaryReferenceSet,
|
|
186
|
+
basename,
|
|
187
|
+
decodeReply,
|
|
188
|
+
requestContext,
|
|
189
|
+
routeDiscovery,
|
|
190
|
+
loadServerAction,
|
|
191
|
+
decodeAction,
|
|
192
|
+
decodeFormState,
|
|
193
|
+
onError,
|
|
194
|
+
request,
|
|
195
|
+
routes,
|
|
196
|
+
generateResponse
|
|
197
|
+
}: {
|
|
198
|
+
allowedActionOrigins?: string[];
|
|
199
|
+
createTemporaryReferenceSet: () => unknown;
|
|
200
|
+
basename?: string;
|
|
201
|
+
decodeReply?: DecodeReplyFunction;
|
|
202
|
+
decodeAction?: DecodeActionFunction;
|
|
203
|
+
decodeFormState?: DecodeFormStateFunction;
|
|
204
|
+
requestContext?: RouterContextProvider;
|
|
205
|
+
loadServerAction?: LoadServerActionFunction;
|
|
206
|
+
onError?: (error: unknown) => void;
|
|
207
|
+
request: Request;
|
|
208
|
+
routes: RSCRouteConfigEntry[];
|
|
209
|
+
routeDiscovery?: RouteDiscovery;
|
|
210
|
+
generateResponse: (match: RSCMatch, {
|
|
211
|
+
onError,
|
|
212
|
+
temporaryReferences
|
|
213
|
+
}: {
|
|
214
|
+
onError(error: unknown): string | undefined;
|
|
215
|
+
temporaryReferences: unknown;
|
|
216
|
+
}) => Response;
|
|
217
|
+
}): Promise<Response>;
|
|
218
|
+
//#endregion
|
|
219
|
+
export { DecodeActionFunction, DecodeFormStateFunction, DecodeReplyFunction, LoadServerActionFunction, RSCManifestPayload, RSCMatch, RSCPayload, RSCRenderPayload, RSCRouteConfig, RSCRouteConfigEntry, RSCRouteManifest, RSCRouteMatch, getRequest, matchRSCServerRequest };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
|
|
2
|
+
import { RSCPayload } from "./server.rsc.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
|
|
5
|
+
//#region lib/rsc/server.ssr.d.ts
|
|
6
|
+
type DecodedPayload = Promise<RSCPayload> & {
|
|
7
|
+
_deepestRenderedBoundaryId?: string | null;
|
|
8
|
+
formState: Promise<any>;
|
|
9
|
+
};
|
|
10
|
+
type SSRCreateFromReadableStreamFunction = (body: ReadableStream<Uint8Array>) => Promise<unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Routes the incoming [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
13
|
+
* to the [RSC](https://react.dev/reference/rsc/server-components) server and
|
|
14
|
+
* appropriately proxies the server response for data / resource requests, or
|
|
15
|
+
* renders to HTML for a document request.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* import { createFromReadableStream } from "@vitejs/plugin-rsc/ssr";
|
|
19
|
+
* import * as ReactDomServer from "react-dom/server.edge";
|
|
20
|
+
* import {
|
|
21
|
+
* unstable_RSCStaticRouter as RSCStaticRouter,
|
|
22
|
+
* unstable_routeRSCServerRequest as routeRSCServerRequest,
|
|
23
|
+
* } from "react-router";
|
|
24
|
+
*
|
|
25
|
+
* routeRSCServerRequest({
|
|
26
|
+
* request,
|
|
27
|
+
* serverResponse,
|
|
28
|
+
* createFromReadableStream,
|
|
29
|
+
* async renderHTML(getPayload) {
|
|
30
|
+
* const payload = getPayload();
|
|
31
|
+
*
|
|
32
|
+
* return await renderHTMLToReadableStream(
|
|
33
|
+
* <RSCStaticRouter getPayload={getPayload} />,
|
|
34
|
+
* {
|
|
35
|
+
* bootstrapScriptContent,
|
|
36
|
+
* formState: await payload.formState,
|
|
37
|
+
* }
|
|
38
|
+
* );
|
|
39
|
+
* },
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* @name unstable_routeRSCServerRequest
|
|
43
|
+
* @public
|
|
44
|
+
* @category RSC
|
|
45
|
+
* @mode data
|
|
46
|
+
* @param opts Options
|
|
47
|
+
* @param opts.createFromReadableStream Your `react-server-dom-xyz/client`'s
|
|
48
|
+
* `createFromReadableStream` function, used to decode payloads from the server.
|
|
49
|
+
* @param opts.serverResponse A Response or partial response generated by the [RSC](https://react.dev/reference/rsc/server-components) handler containing a serialized {@link unstable_RSCPayload}.
|
|
50
|
+
* @param opts.hydrate Whether to hydrate the server response with the RSC payload.
|
|
51
|
+
* Defaults to `true`.
|
|
52
|
+
* @param opts.renderHTML A function that renders the {@link unstable_RSCPayload} to
|
|
53
|
+
* HTML, usually using a {@link unstable_RSCStaticRouter | `<RSCStaticRouter>`}.
|
|
54
|
+
* @param opts.request The request to route.
|
|
55
|
+
* @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
56
|
+
* that either contains the [RSC](https://react.dev/reference/rsc/server-components)
|
|
57
|
+
* payload for data requests, or renders the HTML for document requests.
|
|
58
|
+
*/
|
|
59
|
+
declare function routeRSCServerRequest({
|
|
60
|
+
request,
|
|
61
|
+
serverResponse,
|
|
62
|
+
createFromReadableStream,
|
|
63
|
+
renderHTML,
|
|
64
|
+
hydrate
|
|
65
|
+
}: {
|
|
66
|
+
request: Request;
|
|
67
|
+
serverResponse: Response;
|
|
68
|
+
createFromReadableStream: SSRCreateFromReadableStreamFunction;
|
|
69
|
+
renderHTML: (getPayload: () => DecodedPayload, options: {
|
|
70
|
+
onError(error: unknown): string | undefined;
|
|
71
|
+
onHeaders(headers: Headers): void;
|
|
72
|
+
}) => ReadableStream<Uint8Array> | Promise<ReadableStream<Uint8Array>>;
|
|
73
|
+
hydrate?: boolean;
|
|
74
|
+
}): Promise<Response>;
|
|
75
|
+
/**
|
|
76
|
+
* Props for the {@link unstable_RSCStaticRouter} component.
|
|
77
|
+
*
|
|
78
|
+
* @name unstable_RSCStaticRouterProps
|
|
79
|
+
* @category Types
|
|
80
|
+
*/
|
|
81
|
+
interface RSCStaticRouterProps {
|
|
82
|
+
/**
|
|
83
|
+
* A function that starts decoding of the {@link unstable_RSCPayload}. Usually passed
|
|
84
|
+
* through from {@link unstable_routeRSCServerRequest}'s `renderHTML`.
|
|
85
|
+
*/
|
|
86
|
+
getPayload: () => DecodedPayload;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Pre-renders an {@link unstable_RSCPayload} to HTML. Usually used in
|
|
90
|
+
* {@link unstable_routeRSCServerRequest}'s `renderHTML` callback.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* import { createFromReadableStream } from "@vitejs/plugin-rsc/ssr";
|
|
94
|
+
* import * as ReactDomServer from "react-dom/server.edge";
|
|
95
|
+
* import {
|
|
96
|
+
* unstable_RSCStaticRouter as RSCStaticRouter,
|
|
97
|
+
* unstable_routeRSCServerRequest as routeRSCServerRequest,
|
|
98
|
+
* } from "react-router";
|
|
99
|
+
*
|
|
100
|
+
* routeRSCServerRequest({
|
|
101
|
+
* request,
|
|
102
|
+
* serverResponse,
|
|
103
|
+
* createFromReadableStream,
|
|
104
|
+
* async renderHTML(getPayload) {
|
|
105
|
+
* const payload = getPayload();
|
|
106
|
+
*
|
|
107
|
+
* return await renderHTMLToReadableStream(
|
|
108
|
+
* <RSCStaticRouter getPayload={getPayload} />,
|
|
109
|
+
* {
|
|
110
|
+
* bootstrapScriptContent,
|
|
111
|
+
* formState: await payload.formState,
|
|
112
|
+
* }
|
|
113
|
+
* );
|
|
114
|
+
* },
|
|
115
|
+
* });
|
|
116
|
+
*
|
|
117
|
+
* @name unstable_RSCStaticRouter
|
|
118
|
+
* @public
|
|
119
|
+
* @category RSC
|
|
120
|
+
* @mode data
|
|
121
|
+
* @param props Props
|
|
122
|
+
* @param {unstable_RSCStaticRouterProps.getPayload} props.getPayload n/a
|
|
123
|
+
* @returns A React component that renders the {@link unstable_RSCPayload} as HTML.
|
|
124
|
+
*/
|
|
125
|
+
declare function RSCStaticRouter({
|
|
126
|
+
getPayload
|
|
127
|
+
}: RSCStaticRouterProps): React$1.JSX.Element | null;
|
|
128
|
+
//#endregion
|
|
129
|
+
export { RSCStaticRouter, RSCStaticRouterProps, SSRCreateFromReadableStreamFunction, routeRSCServerRequest };
|