react-router 0.0.0-experimental-d4ee0faac → 0.0.0-experimental-80dc2f07b

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +13 -29
  2. package/dist/development/browser-DO9ukXOW.d.mts +226 -0
  3. package/dist/development/{chunk-AXZ7XWJM.mjs → chunk-FRVKHHSP.mjs} +138 -104
  4. package/dist/development/{chunk-TYXIL3CH.js → chunk-KW2YDZG2.js} +172 -142
  5. package/dist/development/{chunk-BYMLG5RB.js → chunk-QIEB5IKV.js} +84 -80
  6. package/dist/{production/chunk-SSVNUOFF.mjs → development/chunk-ZDIHB6MN.mjs} +32 -29
  7. package/dist/development/components-kfi-pq4A.d.mts +802 -0
  8. package/dist/development/dom-export.d.mts +13 -6
  9. package/dist/development/dom-export.d.ts +10 -3
  10. package/dist/development/dom-export.js +3 -3
  11. package/dist/development/dom-export.mjs +3 -3
  12. package/dist/development/index-react-server-client-C4nRtAah.d.ts +3178 -0
  13. package/dist/development/index-react-server-client-DWt5PSS7.d.mts +2381 -0
  14. package/dist/development/index-react-server-client.d.mts +3 -3
  15. package/dist/development/index-react-server-client.d.ts +2 -2
  16. package/dist/development/index-react-server-client.js +10 -4
  17. package/dist/development/index-react-server-client.mjs +9 -3
  18. package/dist/development/index-react-server.d.mts +115 -2
  19. package/dist/development/index-react-server.d.ts +115 -2
  20. package/dist/development/index-react-server.js +44 -22
  21. package/dist/development/index-react-server.mjs +45 -22
  22. package/dist/development/index.d.mts +1033 -15
  23. package/dist/development/index.d.ts +1107 -20
  24. package/dist/development/index.js +132 -123
  25. package/dist/development/index.mjs +9 -3
  26. package/dist/development/lib/types/internal.d.mts +1 -1
  27. package/dist/development/lib/types/internal.d.ts +1 -1
  28. package/dist/development/lib/types/internal.js +1 -1
  29. package/dist/development/lib/types/internal.mjs +1 -1
  30. package/dist/{production/route-data-DAw7Esur.d.mts → development/route-data-Dccdkjzt.d.mts} +55 -3
  31. package/dist/development/{route-data-7aXBQ4I3.d.ts → routeModules-ePxkpnOJ.d.ts} +210 -158
  32. package/dist/production/browser-DO9ukXOW.d.mts +226 -0
  33. package/dist/production/{chunk-XHN2I73S.js → chunk-BJQSOW5M.js} +84 -80
  34. package/dist/production/{chunk-EATVYSE3.js → chunk-IMCXOMKU.js} +172 -142
  35. package/dist/{development/chunk-ECP3BYMQ.mjs → production/chunk-NUPZJCEO.mjs} +32 -29
  36. package/dist/production/{chunk-RB7EVRHX.mjs → chunk-VQ4KM56U.mjs} +138 -104
  37. package/dist/production/components-kfi-pq4A.d.mts +802 -0
  38. package/dist/production/dom-export.d.mts +13 -6
  39. package/dist/production/dom-export.d.ts +10 -3
  40. package/dist/production/dom-export.js +3 -3
  41. package/dist/production/dom-export.mjs +3 -3
  42. package/dist/production/index-react-server-client-C4nRtAah.d.ts +3178 -0
  43. package/dist/production/index-react-server-client-DWt5PSS7.d.mts +2381 -0
  44. package/dist/production/index-react-server-client.d.mts +3 -3
  45. package/dist/production/index-react-server-client.d.ts +2 -2
  46. package/dist/production/index-react-server-client.js +10 -4
  47. package/dist/production/index-react-server-client.mjs +9 -3
  48. package/dist/production/index-react-server.d.mts +115 -2
  49. package/dist/production/index-react-server.d.ts +115 -2
  50. package/dist/production/index-react-server.js +44 -22
  51. package/dist/production/index-react-server.mjs +45 -22
  52. package/dist/production/index.d.mts +1033 -15
  53. package/dist/production/index.d.ts +1107 -20
  54. package/dist/production/index.js +132 -123
  55. package/dist/production/index.mjs +9 -3
  56. package/dist/production/lib/types/internal.d.mts +1 -1
  57. package/dist/production/lib/types/internal.d.ts +1 -1
  58. package/dist/production/lib/types/internal.js +1 -1
  59. package/dist/production/lib/types/internal.mjs +1 -1
  60. package/dist/{development/route-data-DAw7Esur.d.mts → production/route-data-Dccdkjzt.d.mts} +55 -3
  61. package/dist/production/{route-data-7aXBQ4I3.d.ts → routeModules-ePxkpnOJ.d.ts} +210 -158
  62. package/package.json +1 -1
  63. package/dist/development/browser-BSrXyLft.d.mts +0 -157
  64. package/dist/development/components-IaVqGBuO.d.mts +0 -816
  65. package/dist/development/index-react-server-client-DOK8MfYF.d.mts +0 -1360
  66. package/dist/development/index-react-server-client-LrDNRnlX.d.ts +0 -2171
  67. package/dist/production/browser-BSrXyLft.d.mts +0 -157
  68. package/dist/production/components-IaVqGBuO.d.mts +0 -816
  69. package/dist/production/index-react-server-client-DOK8MfYF.d.mts +0 -1360
  70. package/dist/production/index-react-server-client-LrDNRnlX.d.ts +0 -2171
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `react-router`
2
2
 
3
- ## 7.7.0-pre.0
3
+ ## 7.7.0
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -11,13 +11,21 @@
11
11
  ### Patch Changes
12
12
 
13
13
  - Handle `InvalidCharacterError` when validating cookie signature ([#13847](https://github.com/remix-run/react-router/pull/13847))
14
+
14
15
  - Pass a copy of `searchParams` to the `setSearchParams` callback function to avoid muations of the internal `searchParams` instance. This was an issue when navigations were blocked because the internal instance be out of sync with `useLocation().search`. ([#12784](https://github.com/remix-run/react-router/pull/12784))
16
+
15
17
  - Support invalid `Date` in `turbo-stream` v2 fork ([#13684](https://github.com/remix-run/react-router/pull/13684))
18
+
16
19
  - In Framework Mode, clear critical CSS in development after initial render ([#13872](https://github.com/remix-run/react-router/pull/13872))
20
+
17
21
  - Strip search parameters from `patchRoutesOnNavigation` `path` param for fetcher calls ([#13911](https://github.com/remix-run/react-router/pull/13911))
22
+
18
23
  - Skip scroll restoration on useRevalidator() calls because they're not new locations ([#13671](https://github.com/remix-run/react-router/pull/13671))
24
+
19
25
  - Support unencoded UTF-8 routes in prerender config with `ssr` set to `false` ([#13699](https://github.com/remix-run/react-router/pull/13699))
26
+
20
27
  - Do not throw if the url hash is not a valid URI component ([#13247](https://github.com/remix-run/react-router/pull/13247))
28
+
21
29
  - Fix a regression in `createRoutesStub` introduced with the middleware feature. ([#13946](https://github.com/remix-run/react-router/pull/13946))
22
30
 
23
31
  As part of that work we altered the signature to align with the new middleware APIs without making it backwards compatible with the prior `AppLoadContext` API. This permitted `createRoutesStub` to work if you were opting into middleware and the updated `context` typings, but broke `createRoutesStub` for users not yet opting into middleware.
@@ -165,7 +173,6 @@
165
173
  ### Minor Changes
166
174
 
167
175
  - Added a new `react-router.config.ts` `routeDiscovery` option to configure Lazy Route Discovery behavior. ([#13451](https://github.com/remix-run/react-router/pull/13451))
168
-
169
176
  - By default, Lazy Route Discovery is enabled and makes manifest requests to the `/__manifest` path:
170
177
  - `routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }`
171
178
  - You can modify the manifest path used:
@@ -211,7 +218,6 @@
211
218
  - Preserve status code if a `clientAction` throws a `data()` result in framework mode ([#13522](https://github.com/remix-run/react-router/pull/13522))
212
219
 
213
220
  - Be defensive against leading double slashes in paths to avoid `Invalid URL` errors from the URL constructor ([#13510](https://github.com/remix-run/react-router/pull/13510))
214
-
215
221
  - Note we do not sanitize/normalize these paths - we only detect them so we can avoid the error that would be thrown by `new URL("//", window.location.origin)`
216
222
 
217
223
  - Remove `Navigator` declaration for `navigator.connection.saveData` to avoid messing with any other types beyond `saveData` in userland ([#13512](https://github.com/remix-run/react-router/pull/13512))
@@ -227,7 +233,6 @@
227
233
  - UNSTABLE: Fix a few bugs with error bubbling in middleware use-cases ([#13538](https://github.com/remix-run/react-router/pull/13538))
228
234
 
229
235
  - Short circuit post-processing on aborted `dataStrategy` requests ([#13521](https://github.com/remix-run/react-router/pull/13521))
230
-
231
236
  - This resolves non-user-facing console errors of the form `Cannot read properties of undefined (reading 'result')`
232
237
 
233
238
  ## 7.5.3
@@ -242,7 +247,6 @@
242
247
  ### Patch Changes
243
248
 
244
249
  - Update Single Fetch to also handle the 204 redirects used in `?_data` requests in Remix v2 ([#13364](https://github.com/remix-run/react-router/pull/13364))
245
-
246
250
  - This allows applications to return a redirect on `.data` requests from outside the scope of React Router (i.e., an `express`/`hono` middleware)
247
251
  - ⚠️ Please note that doing so relies on implementation details that are subject to change without a SemVer major release
248
252
  - This is primarily done to ease upgrading to Single Fetch for existing Remix v2 applications, but the recommended way to handle this is redirecting from a route middleware
@@ -280,7 +284,6 @@
280
284
  - UNSTABLE: Add better error messaging when `getLoadContext` is not updated to return a `Map`" ([#13242](https://github.com/remix-run/react-router/pull/13242))
281
285
 
282
286
  - Do not automatically add `null` to `staticHandler.query()` `context.loaderData` if routes do not have loaders ([#13223](https://github.com/remix-run/react-router/pull/13223))
283
-
284
287
  - This was a Remix v2 implementation detail inadvertently left in for React Router v7
285
288
  - Now that we allow returning `undefined` from loaders, our prior check of `loaderData[routeId] !== undefined` was no longer sufficient and was changed to a `routeId in loaderData` check - these `null` values can cause issues for this new check
286
289
  - ⚠️ This could be a "breaking bug fix" for you if you are doing manual SSR with `createStaticHandler()`/`<StaticRouterProvider>`, and using `context.loaderData` to control `<RouterProvider>` hydration behavior on the client
@@ -359,7 +362,6 @@
359
362
  ### Minor Changes
360
363
 
361
364
  - Add `fetcherKey` as a parameter to `patchRoutesOnNavigation` ([#13061](https://github.com/remix-run/react-router/pull/13061))
362
-
363
365
  - In framework mode, Lazy Route Discovery will now detect manifest version mismatches after a new deploy
364
366
  - On navigations to undiscovered routes, this mismatch will trigger a document reload of the destination path
365
367
  - On `fetcher` calls to undiscovered routes, this mismatch will trigger a document reload of the current path
@@ -417,7 +419,7 @@
417
419
  ```tsx
418
420
  const clientLogger: Route.unstable_ClientMiddlewareFunction = async (
419
421
  { request },
420
- next
422
+ next,
421
423
  ) => {
422
424
  let start = performance.now();
423
425
 
@@ -436,7 +438,7 @@
436
438
  ```tsx
437
439
  const serverLogger: Route.unstable_MiddlewareFunction = async (
438
440
  { request, params, context },
439
- next
441
+ next,
440
442
  ) => {
441
443
  let start = performance.now();
442
444
 
@@ -457,7 +459,7 @@
457
459
  import { sessionContext } from "../context";
458
460
  const serverAuth: Route.unstable_MiddlewareFunction = (
459
461
  { request, params, context },
460
- next
462
+ next,
461
463
  ) => {
462
464
  let session = context.get(sessionContext);
463
465
  let user = session.get("user");
@@ -595,7 +597,6 @@
595
597
  ```
596
598
 
597
599
  Similar to server-side requests, a fresh `context` will be created per navigation (or `fetcher` call). If you have initial data you'd like to populate in the context for every request, you can provide an `unstable_getContext` function at the root of your app:
598
-
599
600
  - Library mode - `createBrowserRouter(routes, { unstable_getContext })`
600
601
  - Framework mode - `<HydratedRouter unstable_getContext>`
601
602
 
@@ -652,7 +653,6 @@
652
653
  - Don't apply Single Fetch revalidation de-optimization when in SPA mode since there is no server HTTP request ([#12948](https://github.com/remix-run/react-router/pull/12948))
653
654
 
654
655
  - Properly handle revalidations to across a prerender/SPA boundary ([#13021](https://github.com/remix-run/react-router/pull/13021))
655
-
656
656
  - In "hybrid" applications where some routes are pre-rendered and some are served from a SPA fallback, we need to avoid making `.data` requests if the path wasn't pre-rendered because the request will 404
657
657
  - We don't know all the pre-rendered paths client-side, however:
658
658
  - All `loader` data in `ssr:false` mode is static because it's generated at build time
@@ -662,7 +662,6 @@
662
662
  - This ensures that the route doesn't cause a `.data` request that would 404 after a submission
663
663
 
664
664
  - Error at build time in `ssr:false` + `prerender` apps for the edge case scenario of: ([#13021](https://github.com/remix-run/react-router/pull/13021))
665
-
666
665
  - A parent route has only a `loader` (does not have a `clientLoader`)
667
666
  - The parent route is pre-rendered
668
667
  - The parent route has children routes which are not prerendered
@@ -675,7 +674,6 @@
675
674
  - Add `unstable_SerializesTo` brand type for library authors to register types serializable by React Router's streaming format (`turbo-stream`) ([`ab5b05b02`](https://github.com/remix-run/react-router/commit/ab5b05b02f99f062edb3c536c392197c88eb6c77))
676
675
 
677
676
  - Align dev server behavior with static file server behavior when `ssr:false` is set ([#12948](https://github.com/remix-run/react-router/pull/12948))
678
-
679
677
  - When no `prerender` config exists, only SSR down to the root `HydrateFallback` (SPA Mode)
680
678
  - When a `prerender` config exists but the current path is not prerendered, only SSR down to the root `HydrateFallback` (SPA Fallback)
681
679
  - Return a 404 on `.data` requests to non-pre-rendered paths
@@ -683,7 +681,6 @@
683
681
  - Improve prefetch performance of CSS side effects in framework mode ([#12889](https://github.com/remix-run/react-router/pull/12889))
684
682
 
685
683
  - Disable Lazy Route Discovery for all `ssr:false` apps and not just "SPA Mode" because there is no runtime server to serve the search-param-configured `__manifest` requests ([#12894](https://github.com/remix-run/react-router/pull/12894))
686
-
687
684
  - We previously only disabled this for "SPA Mode" which is `ssr:false` and no `prerender` config but we realized it should apply to all `ssr:false` apps, including those prerendering multiple pages
688
685
  - In those `prerender` scenarios we would prerender the `/__manifest` file assuming the static file server would serve it but that makes some unneccesary assumptions about the static file server behaviors
689
686
 
@@ -760,7 +757,6 @@ _No changes_
760
757
  ### Major Changes
761
758
 
762
759
  - Remove the original `defer` implementation in favor of using raw promises via single fetch and `turbo-stream`. This removes these exports from React Router: ([#11744](https://github.com/remix-run/react-router/pull/11744))
763
-
764
760
  - `defer`
765
761
  - `AbortedDeferredError`
766
762
  - `type TypedDeferredData`
@@ -788,7 +784,6 @@ _No changes_
788
784
  - Remove `future.v7_normalizeFormMethod` future flag ([#11697](https://github.com/remix-run/react-router/pull/11697))
789
785
 
790
786
  - For Remix consumers migrating to React Router, the `crypto` global from the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) is now required when using cookie and session APIs. This means that the following APIs are provided from `react-router` rather than platform-specific packages: ([#11837](https://github.com/remix-run/react-router/pull/11837))
791
-
792
787
  - `createCookie`
793
788
  - `createCookieSessionStorage`
794
789
  - `createMemorySessionStorage`
@@ -797,14 +792,12 @@ _No changes_
797
792
  For consumers running older versions of Node, the `installGlobals` function from `@remix-run/node` has been updated to define `globalThis.crypto`, using [Node's `require('node:crypto').webcrypto` implementation.](https://nodejs.org/api/webcrypto.html)
798
793
 
799
794
  Since platform-specific packages no longer need to implement this API, the following low-level APIs have been removed:
800
-
801
795
  - `createCookieFactory`
802
796
  - `createSessionStorageFactory`
803
797
  - `createCookieSessionStorageFactory`
804
798
  - `createMemorySessionStorageFactory`
805
799
 
806
800
  - Imports/Exports cleanup ([#11840](https://github.com/remix-run/react-router/pull/11840))
807
-
808
801
  - Removed the following exports that were previously public API from `@remix-run/router`
809
802
  - types
810
803
  - `AgnosticDataIndexRouteObject`
@@ -841,7 +834,6 @@ _No changes_
841
834
  - Remove `future.v7_prependBasename` from the ionternalized `@remix-run/router` package ([#11726](https://github.com/remix-run/react-router/pull/11726))
842
835
 
843
836
  - Migrate Remix type generics to React Router ([#12180](https://github.com/remix-run/react-router/pull/12180))
844
-
845
837
  - These generics are provided for Remix v2 migration purposes
846
838
  - These generics and the APIs they exist on should be considered informally deprecated in favor of the new `Route.*` types
847
839
  - Anyone migrating from React Router v6 should probably not leverage these new generics and should migrate straight to the `Route.*` types
@@ -881,11 +873,9 @@ _No changes_
881
873
  - Remove `v7_relativeSplatPath` future flag ([#11695](https://github.com/remix-run/react-router/pull/11695))
882
874
 
883
875
  - Drop support for Node 18, update minimum Node vestion to 20 ([#12171](https://github.com/remix-run/react-router/pull/12171))
884
-
885
876
  - Remove `installGlobals()` as this should no longer be necessary
886
877
 
887
878
  - Remove remaining future flags ([#11820](https://github.com/remix-run/react-router/pull/11820))
888
-
889
879
  - React Router `v7_skipActionErrorRevalidation`
890
880
  - Remix `v3_fetcherPersist`, `v3_relativeSplatPath`, `v3_throwAbortReason`
891
881
 
@@ -894,7 +884,6 @@ _No changes_
894
884
  - Remove `@remix-run/router` deprecated `detectErrorBoundary` option in favor of `mapRouteProperties` ([#11751](https://github.com/remix-run/react-router/pull/11751))
895
885
 
896
886
  - Add `react-router/dom` subpath export to properly enable `react-dom` as an optional `peerDependency` ([#11851](https://github.com/remix-run/react-router/pull/11851))
897
-
898
887
  - This ensures that we don't blindly `import ReactDOM from "react-dom"` in `<RouterProvider>` in order to access `ReactDOM.flushSync()`, since that would break `createMemoryRouter` use cases in non-DOM environments
899
888
  - DOM environments should import from `react-router/dom` to get the proper component that makes `ReactDOM.flushSync()` available:
900
889
  - If you are using the Vite plugin, use this in your `entry.client.tsx`:
@@ -958,7 +947,6 @@ _No changes_
958
947
  ```
959
948
 
960
949
  This initial implementation targets type inference for:
961
-
962
950
  - `Params` : Path parameters from your routing config in `routes.ts` including file-based routing
963
951
  - `LoaderData` : Loader data from `loader` and/or `clientLoader` within your route module
964
952
  - `ActionData` : Action data from `action` and/or `clientAction` within your route module
@@ -973,7 +961,6 @@ _No changes_
973
961
  ```
974
962
 
975
963
  Check out our docs for more:
976
-
977
964
  - [_Explanations > Type Safety_](https://reactrouter.com/dev/guides/explanation/type-safety)
978
965
  - [_How-To > Setting up type safety_](https://reactrouter.com/dev/guides/how-to/setting-up-type-safety)
979
966
 
@@ -998,7 +985,6 @@ _No changes_
998
985
  - Replace `substr` with `substring` ([#12080](https://github.com/remix-run/react-router/pull/12080))
999
986
 
1000
987
  - Remove the deprecated `json` utility ([#12146](https://github.com/remix-run/react-router/pull/12146))
1001
-
1002
988
  - You can use [`Response.json`](https://developer.mozilla.org/en-US/docs/Web/API/Response/json_static) if you still need to construct JSON responses in your app
1003
989
 
1004
990
  - Remove unneeded dependency on source-map ([#12275](https://github.com/remix-run/react-router/pull/12275))
@@ -1352,7 +1338,6 @@ No significant changes to this package were made in this release. [See the repo
1352
1338
  - Fix `useActionData` so it returns proper contextual action data and not _any_ action data in the tree ([#11023](https://github.com/remix-run/react-router/pull/11023))
1353
1339
 
1354
1340
  - Fix bug in `useResolvedPath` that would cause `useResolvedPath(".")` in a splat route to lose the splat portion of the URL path. ([#10983](https://github.com/remix-run/react-router/pull/10983))
1355
-
1356
1341
  - ⚠️ This fixes a quite long-standing bug specifically for `"."` paths inside a splat route which incorrectly dropped the splat portion of the URL. If you are relative routing via `"."` inside a splat route in your application you should double check that your logic is not relying on this buggy behavior and update accordingly.
1357
1342
 
1358
1343
  - Updated dependencies:
@@ -1519,7 +1504,6 @@ No significant changes to this package were made in this release. [See the repo
1519
1504
  ### Minor Changes
1520
1505
 
1521
1506
  - Added support for [**Future Flags**](https://reactrouter.com/v6/guides/api-development-strategy) in React Router. The first flag being introduced is `future.v7_normalizeFormMethod` which will normalize the exposed `useNavigation()/useFetcher()` `formMethod` fields as uppercase HTTP methods to align with the `fetch()` behavior. ([#10207](https://github.com/remix-run/react-router/pull/10207))
1522
-
1523
1507
  - When `future.v7_normalizeFormMethod === false` (default v6 behavior),
1524
1508
  - `useNavigation().formMethod` is lowercase
1525
1509
  - `useFetcher().formMethod` is lowercase
@@ -1592,7 +1576,7 @@ No significant changes to this package were made in this release. [See the repo
1592
1576
  <Route index element={<Home />} />
1593
1577
  <Route path="a" lazy={() => import("./a")} />
1594
1578
  <Route path="b" lazy={() => import("./b")} />
1595
- </Route>
1579
+ </Route>,
1596
1580
  );
1597
1581
  ```
1598
1582
 
@@ -0,0 +1,226 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import * as React from 'react';
3
+ import { u as unstable_RouterContextProvider, i as ActionFunction, C as ClientActionFunction, j as ClientLoaderFunction, k as HeadersFunction, l as LinksFunction, m as LoaderFunction, M as MetaFunction, S as ShouldRevalidateFunction, c as Location, h as Params } from './route-data-Dccdkjzt.mjs';
4
+
5
+ type ServerContext = {
6
+ redirect?: Response;
7
+ };
8
+ declare global {
9
+ var ___reactRouterServerStorage___: AsyncLocalStorage<ServerContext> | undefined;
10
+ }
11
+ type RSCRouteConfigEntryBase = {
12
+ action?: ActionFunction;
13
+ clientAction?: ClientActionFunction;
14
+ clientLoader?: ClientLoaderFunction;
15
+ ErrorBoundary?: React.ComponentType<any>;
16
+ handle?: any;
17
+ headers?: HeadersFunction;
18
+ HydrateFallback?: React.ComponentType<any>;
19
+ Layout?: React.ComponentType<any>;
20
+ links?: LinksFunction;
21
+ loader?: LoaderFunction;
22
+ meta?: MetaFunction;
23
+ shouldRevalidate?: ShouldRevalidateFunction;
24
+ };
25
+ type RSCRouteConfigEntry = RSCRouteConfigEntryBase & {
26
+ id: string;
27
+ path?: string;
28
+ Component?: React.ComponentType<any>;
29
+ lazy?: () => Promise<RSCRouteConfigEntryBase & ({
30
+ default?: React.ComponentType<any>;
31
+ Component?: never;
32
+ } | {
33
+ default?: never;
34
+ Component?: React.ComponentType<any>;
35
+ })>;
36
+ } & ({
37
+ index: true;
38
+ } | {
39
+ children?: RSCRouteConfigEntry[];
40
+ });
41
+ type RSCRouteConfig = Array<RSCRouteConfigEntry>;
42
+ type RSCRouteManifest = {
43
+ clientAction?: ClientActionFunction;
44
+ clientLoader?: ClientLoaderFunction;
45
+ element?: React.ReactElement | false;
46
+ errorElement?: React.ReactElement;
47
+ handle?: any;
48
+ hasAction: boolean;
49
+ hasComponent: boolean;
50
+ hasErrorBoundary: boolean;
51
+ hasLoader: boolean;
52
+ hydrateFallbackElement?: React.ReactElement;
53
+ id: string;
54
+ index?: boolean;
55
+ links?: LinksFunction;
56
+ meta?: MetaFunction;
57
+ parentId?: string;
58
+ path?: string;
59
+ shouldRevalidate?: ShouldRevalidateFunction;
60
+ };
61
+ type RSCRouteMatch = RSCRouteManifest & {
62
+ params: Params;
63
+ pathname: string;
64
+ pathnameBase: string;
65
+ };
66
+ type RSCRenderPayload = {
67
+ type: "render";
68
+ actionData: Record<string, any> | null;
69
+ basename: string | undefined;
70
+ errors: Record<string, any> | null;
71
+ loaderData: Record<string, any>;
72
+ location: Location;
73
+ matches: RSCRouteMatch[];
74
+ patches?: RSCRouteManifest[];
75
+ nonce?: string;
76
+ formState?: unknown;
77
+ };
78
+ type RSCManifestPayload = {
79
+ type: "manifest";
80
+ patches: RSCRouteManifest[];
81
+ };
82
+ type RSCActionPayload = {
83
+ type: "action";
84
+ actionResult: Promise<unknown>;
85
+ rerender?: Promise<RSCRenderPayload | RSCRedirectPayload>;
86
+ };
87
+ type RSCRedirectPayload = {
88
+ type: "redirect";
89
+ status: number;
90
+ location: string;
91
+ replace: boolean;
92
+ reload: boolean;
93
+ actionResult?: Promise<unknown>;
94
+ };
95
+ type RSCPayload = RSCRenderPayload | RSCManifestPayload | RSCActionPayload | RSCRedirectPayload;
96
+ type RSCMatch = {
97
+ statusCode: number;
98
+ headers: Headers;
99
+ payload: RSCPayload;
100
+ };
101
+ type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
102
+ type DecodeFormStateFunction = (result: unknown, formData: FormData) => unknown;
103
+ type DecodeReplyFunction = (reply: FormData | string, { temporaryReferences }: {
104
+ temporaryReferences: unknown;
105
+ }) => Promise<unknown[]>;
106
+ type LoadServerActionFunction = (id: string) => Promise<Function>;
107
+ /**
108
+ * Matches the given routes to a Request and returns a RSC Response encoding an
109
+ * `RSCPayload` for consumption by a RSC enabled client router.
110
+ *
111
+ * @example
112
+ * import {
113
+ * createTemporaryReferenceSet,
114
+ * decodeAction,
115
+ * decodeReply,
116
+ * loadServerAction,
117
+ * renderToReadableStream,
118
+ * } from "@vitejs/plugin-rsc/rsc";
119
+ * import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router";
120
+ *
121
+ * matchRSCServerRequest({
122
+ * createTemporaryReferenceSet,
123
+ * decodeAction,
124
+ * decodeFormState,
125
+ * decodeReply,
126
+ * loadServerAction,
127
+ * request,
128
+ * routes: routes(),
129
+ * generateResponse(match) {
130
+ * return new Response(
131
+ * renderToReadableStream(match.payload),
132
+ * {
133
+ * status: match.statusCode,
134
+ * headers: match.headers,
135
+ * }
136
+ * );
137
+ * },
138
+ * });
139
+ *
140
+ * @name unstable_matchRSCServerRequest
141
+ * @public
142
+ * @category RSC
143
+ * @mode data
144
+ * @param opts Options
145
+ * @param opts.basename The basename to use when matching the request.
146
+ * @param opts.decodeAction Your `react-server-dom-xyz/server`'s `decodeAction`
147
+ * function, responsible for loading a server action.
148
+ * @param opts.decodeReply Your `react-server-dom-xyz/server`'s `decodeReply`
149
+ * function, used to decode the server function's arguments and bind them to the
150
+ * implementation for invocation by the router.
151
+ * @param opts.decodeFormState A function responsible for decoding form state for
152
+ * progressively enhanceable forms with `useActionState` using your
153
+ * `react-server-dom-xyz/server`'s `decodeFormState`.
154
+ * @param opts.generateResponse A function responsible for using your
155
+ * `renderToReadableStream` to generate a Response encoding the `RSCPayload`.
156
+ * @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
157
+ * `loadServerAction` function, used to load a server action by ID.
158
+ * @param opts.request The request to match against.
159
+ * @param opts.requestContext An instance of `unstable_RouterContextProvider`
160
+ * that should be created per request, to be passed to loaders, actions and middleware.
161
+ * @param opts.routes Your route definitions.
162
+ * @param opts.createTemporaryReferenceSet A function that returns a temporary
163
+ * reference set for the request, used to track temporary references in the RSC stream.
164
+ * @param opts.onError An optional error handler that will be called with any
165
+ * errors that occur during the request processing.
166
+ * @returns A Response that contains the RSC data for hydration.
167
+ */
168
+ declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
169
+ createTemporaryReferenceSet: () => unknown;
170
+ basename?: string;
171
+ decodeReply?: DecodeReplyFunction;
172
+ decodeAction?: DecodeActionFunction;
173
+ decodeFormState?: DecodeFormStateFunction;
174
+ requestContext?: unstable_RouterContextProvider;
175
+ loadServerAction?: LoadServerActionFunction;
176
+ onError?: (error: unknown) => void;
177
+ request: Request;
178
+ routes: RSCRouteConfigEntry[];
179
+ generateResponse: (match: RSCMatch, { temporaryReferences, }: {
180
+ temporaryReferences: unknown;
181
+ }) => Response;
182
+ }): Promise<Response>;
183
+
184
+ declare global {
185
+ interface Window {
186
+ __FLIGHT_DATA: any[];
187
+ }
188
+ }
189
+ /**
190
+ * Get the prerendered RSC stream for hydration. Usually passed directly to your
191
+ * `react-server-dom-xyz/client`'s `createFromReadableStream`.
192
+ *
193
+ * @example
194
+ * import { startTransition, StrictMode } from "react";
195
+ * import { hydrateRoot } from "react-dom/client";
196
+ * import {
197
+ * unstable_getRSCStream as getRSCStream,
198
+ * unstable_RSCHydratedRouter as RSCHydratedRouter,
199
+ * } from "react-router";
200
+ * import type { unstable_RSCPayload as RSCPayload } from "react-router";
201
+ *
202
+ * createFromReadableStream(getRSCStream()).then(
203
+ * (payload: RSCServerPayload) => {
204
+ * startTransition(async () => {
205
+ * hydrateRoot(
206
+ * document,
207
+ * <StrictMode>
208
+ * <RSCHydratedRouter ...props />
209
+ * </StrictMode>,
210
+ * {
211
+ * // Options
212
+ * }
213
+ * );
214
+ * });
215
+ * }
216
+ * );
217
+ *
218
+ * @name unstable_getRSCStream
219
+ * @public
220
+ * @category RSC
221
+ * @mode data
222
+ * @returns A `ReadableStream` that contains the RSC data for hydration.
223
+ */
224
+ declare function getRSCStream(): ReadableStream<any>;
225
+
226
+ export { type DecodeActionFunction as D, type LoadServerActionFunction as L, type RSCPayload as R, type DecodeFormStateFunction as a, type DecodeReplyFunction as b, type RSCManifestPayload as c, type RSCMatch as d, type RSCRenderPayload as e, type RSCRouteManifest as f, getRSCStream as g, type RSCRouteMatch as h, type RSCRouteConfigEntry as i, type RSCRouteConfig as j, matchRSCServerRequest as m };