react-router 7.7.0 → 7.7.1-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.
Files changed (68) hide show
  1. package/CHANGELOG.md +11 -28
  2. package/dist/development/{browser-CcxeZJcQ.d.mts → browser-7LYX59NK.d.mts} +97 -1
  3. package/dist/development/{chunk-V6PEDDZI.js → chunk-4DODSFAK.js} +79 -76
  4. package/dist/development/{chunk-EF7DTUVF.mjs → chunk-FSG5FGWQ.mjs} +83 -80
  5. package/dist/{production/chunk-2TYFPE3B.js → development/chunk-JKVEU2V7.js} +132 -132
  6. package/dist/{production/chunk-GNZILI6H.mjs → development/chunk-KFHXRAUZ.mjs} +3 -5
  7. package/dist/development/components-CjQijYga.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-Bi_fx8qz.d.ts +3163 -0
  13. package/dist/development/index-react-server-client-KLg-U4nr.d.mts +2366 -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 +4 -4
  17. package/dist/development/index-react-server-client.mjs +2 -2
  18. package/dist/development/index-react-server.d.mts +109 -2
  19. package/dist/development/index-react-server.d.ts +109 -2
  20. package/dist/development/index-react-server.js +28 -20
  21. package/dist/development/index-react-server.mjs +29 -21
  22. package/dist/development/index.d.mts +918 -287
  23. package/dist/development/index.d.ts +1010 -283
  24. package/dist/development/index.js +98 -100
  25. package/dist/development/index.mjs +3 -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-DjzmHYNR.d.mts → development/route-data-CqEmXQub.d.mts} +48 -2
  31. package/dist/{production/routeModules-g5PTiDfO.d.ts → development/routeModules-BR2FO0ix.d.ts} +48 -2
  32. package/dist/production/{browser-CcxeZJcQ.d.mts → browser-7LYX59NK.d.mts} +97 -1
  33. package/dist/production/{chunk-5KHO4FML.js → chunk-BPUKNCMM.js} +79 -76
  34. package/dist/production/{chunk-WPPIQDYG.mjs → chunk-J4LDCI7O.mjs} +83 -80
  35. package/dist/{development/chunk-T3VM44WY.mjs → production/chunk-MZVTKUZ4.mjs} +3 -5
  36. package/dist/{development/chunk-4ADB4KIO.js → production/chunk-PVPY6FX7.js} +132 -132
  37. package/dist/production/components-CjQijYga.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-Bi_fx8qz.d.ts +3163 -0
  43. package/dist/production/index-react-server-client-KLg-U4nr.d.mts +2366 -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 +4 -4
  47. package/dist/production/index-react-server-client.mjs +2 -2
  48. package/dist/production/index-react-server.d.mts +109 -2
  49. package/dist/production/index-react-server.d.ts +109 -2
  50. package/dist/production/index-react-server.js +28 -20
  51. package/dist/production/index-react-server.mjs +29 -21
  52. package/dist/production/index.d.mts +918 -287
  53. package/dist/production/index.d.ts +1010 -283
  54. package/dist/production/index.js +98 -100
  55. package/dist/production/index.mjs +3 -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-DjzmHYNR.d.mts → production/route-data-CqEmXQub.d.mts} +48 -2
  61. package/dist/{development/routeModules-g5PTiDfO.d.ts → production/routeModules-BR2FO0ix.d.ts} +48 -2
  62. package/package.json +1 -1
  63. package/dist/development/components-DzqPLVI1.d.mts +0 -464
  64. package/dist/development/index-react-server-client-CUidsuu_.d.mts +0 -1360
  65. package/dist/development/index-react-server-client-kY8DvDF3.d.ts +0 -1819
  66. package/dist/production/components-DzqPLVI1.d.mts +0 -464
  67. package/dist/production/index-react-server-client-CUidsuu_.d.mts +0 -1360
  68. package/dist/production/index-react-server-client-kY8DvDF3.d.ts +0 -1819
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # `react-router`
2
2
 
3
+ ## 7.7.1-pre.0
4
+
5
+ ### Patch Changes
6
+
7
+ - In RSC Data Mode, fix bug where routes with errors weren't forced to revalidate when `shouldRevalidate` returned false ([#14026](https://github.com/remix-run/react-router/pull/14026))
8
+ - In RSC Data Mode, fix `Matched leaf route at location "/..." does not have an element or Component` warnings when error boundaries are rendered. ([#14021](https://github.com/remix-run/react-router/pull/14021))
9
+
3
10
  ## 7.7.0
4
11
 
5
12
  ### Minor Changes
@@ -173,7 +180,6 @@
173
180
  ### Minor Changes
174
181
 
175
182
  - 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))
176
-
177
183
  - By default, Lazy Route Discovery is enabled and makes manifest requests to the `/__manifest` path:
178
184
  - `routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }`
179
185
  - You can modify the manifest path used:
@@ -219,7 +225,6 @@
219
225
  - Preserve status code if a `clientAction` throws a `data()` result in framework mode ([#13522](https://github.com/remix-run/react-router/pull/13522))
220
226
 
221
227
  - 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))
222
-
223
228
  - 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)`
224
229
 
225
230
  - 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))
@@ -235,7 +240,6 @@
235
240
  - UNSTABLE: Fix a few bugs with error bubbling in middleware use-cases ([#13538](https://github.com/remix-run/react-router/pull/13538))
236
241
 
237
242
  - Short circuit post-processing on aborted `dataStrategy` requests ([#13521](https://github.com/remix-run/react-router/pull/13521))
238
-
239
243
  - This resolves non-user-facing console errors of the form `Cannot read properties of undefined (reading 'result')`
240
244
 
241
245
  ## 7.5.3
@@ -250,7 +254,6 @@
250
254
  ### Patch Changes
251
255
 
252
256
  - 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))
253
-
254
257
  - This allows applications to return a redirect on `.data` requests from outside the scope of React Router (i.e., an `express`/`hono` middleware)
255
258
  - ⚠️ Please note that doing so relies on implementation details that are subject to change without a SemVer major release
256
259
  - 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
@@ -288,7 +291,6 @@
288
291
  - UNSTABLE: Add better error messaging when `getLoadContext` is not updated to return a `Map`" ([#13242](https://github.com/remix-run/react-router/pull/13242))
289
292
 
290
293
  - 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))
291
-
292
294
  - This was a Remix v2 implementation detail inadvertently left in for React Router v7
293
295
  - 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
294
296
  - ⚠️ 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
@@ -367,7 +369,6 @@
367
369
  ### Minor Changes
368
370
 
369
371
  - Add `fetcherKey` as a parameter to `patchRoutesOnNavigation` ([#13061](https://github.com/remix-run/react-router/pull/13061))
370
-
371
372
  - In framework mode, Lazy Route Discovery will now detect manifest version mismatches after a new deploy
372
373
  - On navigations to undiscovered routes, this mismatch will trigger a document reload of the destination path
373
374
  - On `fetcher` calls to undiscovered routes, this mismatch will trigger a document reload of the current path
@@ -425,7 +426,7 @@
425
426
  ```tsx
426
427
  const clientLogger: Route.unstable_ClientMiddlewareFunction = async (
427
428
  { request },
428
- next
429
+ next,
429
430
  ) => {
430
431
  let start = performance.now();
431
432
 
@@ -444,7 +445,7 @@
444
445
  ```tsx
445
446
  const serverLogger: Route.unstable_MiddlewareFunction = async (
446
447
  { request, params, context },
447
- next
448
+ next,
448
449
  ) => {
449
450
  let start = performance.now();
450
451
 
@@ -465,7 +466,7 @@
465
466
  import { sessionContext } from "../context";
466
467
  const serverAuth: Route.unstable_MiddlewareFunction = (
467
468
  { request, params, context },
468
- next
469
+ next,
469
470
  ) => {
470
471
  let session = context.get(sessionContext);
471
472
  let user = session.get("user");
@@ -603,7 +604,6 @@
603
604
  ```
604
605
 
605
606
  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:
606
-
607
607
  - Library mode - `createBrowserRouter(routes, { unstable_getContext })`
608
608
  - Framework mode - `<HydratedRouter unstable_getContext>`
609
609
 
@@ -660,7 +660,6 @@
660
660
  - 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))
661
661
 
662
662
  - Properly handle revalidations to across a prerender/SPA boundary ([#13021](https://github.com/remix-run/react-router/pull/13021))
663
-
664
663
  - 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
665
664
  - We don't know all the pre-rendered paths client-side, however:
666
665
  - All `loader` data in `ssr:false` mode is static because it's generated at build time
@@ -670,7 +669,6 @@
670
669
  - This ensures that the route doesn't cause a `.data` request that would 404 after a submission
671
670
 
672
671
  - 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))
673
-
674
672
  - A parent route has only a `loader` (does not have a `clientLoader`)
675
673
  - The parent route is pre-rendered
676
674
  - The parent route has children routes which are not prerendered
@@ -683,7 +681,6 @@
683
681
  - 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))
684
682
 
685
683
  - Align dev server behavior with static file server behavior when `ssr:false` is set ([#12948](https://github.com/remix-run/react-router/pull/12948))
686
-
687
684
  - When no `prerender` config exists, only SSR down to the root `HydrateFallback` (SPA Mode)
688
685
  - When a `prerender` config exists but the current path is not prerendered, only SSR down to the root `HydrateFallback` (SPA Fallback)
689
686
  - Return a 404 on `.data` requests to non-pre-rendered paths
@@ -691,7 +688,6 @@
691
688
  - Improve prefetch performance of CSS side effects in framework mode ([#12889](https://github.com/remix-run/react-router/pull/12889))
692
689
 
693
690
  - 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))
694
-
695
691
  - 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
696
692
  - 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
697
693
 
@@ -768,7 +764,6 @@ _No changes_
768
764
  ### Major Changes
769
765
 
770
766
  - 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))
771
-
772
767
  - `defer`
773
768
  - `AbortedDeferredError`
774
769
  - `type TypedDeferredData`
@@ -796,7 +791,6 @@ _No changes_
796
791
  - Remove `future.v7_normalizeFormMethod` future flag ([#11697](https://github.com/remix-run/react-router/pull/11697))
797
792
 
798
793
  - 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))
799
-
800
794
  - `createCookie`
801
795
  - `createCookieSessionStorage`
802
796
  - `createMemorySessionStorage`
@@ -805,14 +799,12 @@ _No changes_
805
799
  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)
806
800
 
807
801
  Since platform-specific packages no longer need to implement this API, the following low-level APIs have been removed:
808
-
809
802
  - `createCookieFactory`
810
803
  - `createSessionStorageFactory`
811
804
  - `createCookieSessionStorageFactory`
812
805
  - `createMemorySessionStorageFactory`
813
806
 
814
807
  - Imports/Exports cleanup ([#11840](https://github.com/remix-run/react-router/pull/11840))
815
-
816
808
  - Removed the following exports that were previously public API from `@remix-run/router`
817
809
  - types
818
810
  - `AgnosticDataIndexRouteObject`
@@ -849,7 +841,6 @@ _No changes_
849
841
  - Remove `future.v7_prependBasename` from the ionternalized `@remix-run/router` package ([#11726](https://github.com/remix-run/react-router/pull/11726))
850
842
 
851
843
  - Migrate Remix type generics to React Router ([#12180](https://github.com/remix-run/react-router/pull/12180))
852
-
853
844
  - These generics are provided for Remix v2 migration purposes
854
845
  - These generics and the APIs they exist on should be considered informally deprecated in favor of the new `Route.*` types
855
846
  - Anyone migrating from React Router v6 should probably not leverage these new generics and should migrate straight to the `Route.*` types
@@ -889,11 +880,9 @@ _No changes_
889
880
  - Remove `v7_relativeSplatPath` future flag ([#11695](https://github.com/remix-run/react-router/pull/11695))
890
881
 
891
882
  - Drop support for Node 18, update minimum Node vestion to 20 ([#12171](https://github.com/remix-run/react-router/pull/12171))
892
-
893
883
  - Remove `installGlobals()` as this should no longer be necessary
894
884
 
895
885
  - Remove remaining future flags ([#11820](https://github.com/remix-run/react-router/pull/11820))
896
-
897
886
  - React Router `v7_skipActionErrorRevalidation`
898
887
  - Remix `v3_fetcherPersist`, `v3_relativeSplatPath`, `v3_throwAbortReason`
899
888
 
@@ -902,7 +891,6 @@ _No changes_
902
891
  - Remove `@remix-run/router` deprecated `detectErrorBoundary` option in favor of `mapRouteProperties` ([#11751](https://github.com/remix-run/react-router/pull/11751))
903
892
 
904
893
  - 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))
905
-
906
894
  - 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
907
895
  - DOM environments should import from `react-router/dom` to get the proper component that makes `ReactDOM.flushSync()` available:
908
896
  - If you are using the Vite plugin, use this in your `entry.client.tsx`:
@@ -966,7 +954,6 @@ _No changes_
966
954
  ```
967
955
 
968
956
  This initial implementation targets type inference for:
969
-
970
957
  - `Params` : Path parameters from your routing config in `routes.ts` including file-based routing
971
958
  - `LoaderData` : Loader data from `loader` and/or `clientLoader` within your route module
972
959
  - `ActionData` : Action data from `action` and/or `clientAction` within your route module
@@ -981,7 +968,6 @@ _No changes_
981
968
  ```
982
969
 
983
970
  Check out our docs for more:
984
-
985
971
  - [_Explanations > Type Safety_](https://reactrouter.com/dev/guides/explanation/type-safety)
986
972
  - [_How-To > Setting up type safety_](https://reactrouter.com/dev/guides/how-to/setting-up-type-safety)
987
973
 
@@ -1006,7 +992,6 @@ _No changes_
1006
992
  - Replace `substr` with `substring` ([#12080](https://github.com/remix-run/react-router/pull/12080))
1007
993
 
1008
994
  - Remove the deprecated `json` utility ([#12146](https://github.com/remix-run/react-router/pull/12146))
1009
-
1010
995
  - 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
1011
996
 
1012
997
  - Remove unneeded dependency on source-map ([#12275](https://github.com/remix-run/react-router/pull/12275))
@@ -1360,7 +1345,6 @@ No significant changes to this package were made in this release. [See the repo
1360
1345
  - 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))
1361
1346
 
1362
1347
  - 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))
1363
-
1364
1348
  - ⚠️ 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.
1365
1349
 
1366
1350
  - Updated dependencies:
@@ -1527,7 +1511,6 @@ No significant changes to this package were made in this release. [See the repo
1527
1511
  ### Minor Changes
1528
1512
 
1529
1513
  - 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))
1530
-
1531
1514
  - When `future.v7_normalizeFormMethod === false` (default v6 behavior),
1532
1515
  - `useNavigation().formMethod` is lowercase
1533
1516
  - `useFetcher().formMethod` is lowercase
@@ -1600,7 +1583,7 @@ No significant changes to this package were made in this release. [See the repo
1600
1583
  <Route index element={<Home />} />
1601
1584
  <Route path="a" lazy={() => import("./a")} />
1602
1585
  <Route path="b" lazy={() => import("./b")} />
1603
- </Route>
1586
+ </Route>,
1604
1587
  );
1605
1588
  ```
1606
1589
 
@@ -1,6 +1,6 @@
1
1
  import { AsyncLocalStorage } from 'node:async_hooks';
2
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-DjzmHYNR.mjs';
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-CqEmXQub.mjs';
4
4
 
5
5
  type ServerContext = {
6
6
  redirect?: Response;
@@ -104,6 +104,67 @@ type DecodeReplyFunction = (reply: FormData | string, { temporaryReferences }: {
104
104
  temporaryReferences: unknown;
105
105
  }) => Promise<unknown[]>;
106
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
+ */
107
168
  declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
108
169
  createTemporaryReferenceSet: () => unknown;
109
170
  basename?: string;
@@ -125,6 +186,41 @@ declare global {
125
186
  __FLIGHT_DATA: any[];
126
187
  }
127
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
+ */
128
224
  declare function getRSCStream(): ReadableStream<any>;
129
225
 
130
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 };
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
2
- * react-router v7.7.0
2
+ * react-router v7.7.1-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2305,9 +2305,7 @@ function createRouter(init) {
2305
2305
  )
2306
2306
  };
2307
2307
  } else {
2308
- dataResults[routeId] = await convertDataStrategyResultToDataResult(
2309
- result
2310
- );
2308
+ dataResults[routeId] = await convertDataStrategyResultToDataResult(result);
2311
2309
  }
2312
2310
  }
2313
2311
  return dataResults;
@@ -4163,7 +4161,10 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
4163
4161
  });
4164
4162
  try {
4165
4163
  await Promise.all(
4166
- matches.flatMap((m) => [_optionalChain([m, 'access', _43 => _43._lazyPromises, 'optionalAccess', _44 => _44.handler]), _optionalChain([m, 'access', _45 => _45._lazyPromises, 'optionalAccess', _46 => _46.route])])
4164
+ matches.flatMap((m) => [
4165
+ _optionalChain([m, 'access', _43 => _43._lazyPromises, 'optionalAccess', _44 => _44.handler]),
4166
+ _optionalChain([m, 'access', _45 => _45._lazyPromises, 'optionalAccess', _46 => _46.route])
4167
+ ])
4167
4168
  );
4168
4169
  } catch (e) {
4169
4170
  }
@@ -5478,8 +5479,10 @@ function encode(input, options) {
5478
5479
  lastSentIndex++;
5479
5480
  } else if (id2 < 0) {
5480
5481
  controller.enqueue(
5481
- textEncoder.encode(`${TYPE_ERROR}${deferredId}:${id2}
5482
- `)
5482
+ textEncoder.encode(
5483
+ `${TYPE_ERROR}${deferredId}:${id2}
5484
+ `
5485
+ )
5483
5486
  );
5484
5487
  } else {
5485
5488
  const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
@@ -6406,68 +6409,71 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, fut
6406
6409
  }
6407
6410
  }
6408
6411
  }
6409
- return renderedMatches.reduceRight((outlet, match, index) => {
6410
- let error;
6411
- let shouldRenderHydrateFallback = false;
6412
- let errorElement = null;
6413
- let hydrateFallbackElement = null;
6414
- if (dataRouterState) {
6415
- error = errors && match.route.id ? errors[match.route.id] : void 0;
6416
- errorElement = match.route.errorElement || defaultErrorElement;
6417
- if (renderFallback) {
6418
- if (fallbackIndex < 0 && index === 0) {
6419
- warningOnce(
6420
- "route-fallback",
6421
- false,
6422
- "No `HydrateFallback` element provided to render during initial hydration"
6423
- );
6424
- shouldRenderHydrateFallback = true;
6425
- hydrateFallbackElement = null;
6426
- } else if (fallbackIndex === index) {
6427
- shouldRenderHydrateFallback = true;
6428
- hydrateFallbackElement = match.route.hydrateFallbackElement || null;
6412
+ return renderedMatches.reduceRight(
6413
+ (outlet, match, index) => {
6414
+ let error;
6415
+ let shouldRenderHydrateFallback = false;
6416
+ let errorElement = null;
6417
+ let hydrateFallbackElement = null;
6418
+ if (dataRouterState) {
6419
+ error = errors && match.route.id ? errors[match.route.id] : void 0;
6420
+ errorElement = match.route.errorElement || defaultErrorElement;
6421
+ if (renderFallback) {
6422
+ if (fallbackIndex < 0 && index === 0) {
6423
+ warningOnce(
6424
+ "route-fallback",
6425
+ false,
6426
+ "No `HydrateFallback` element provided to render during initial hydration"
6427
+ );
6428
+ shouldRenderHydrateFallback = true;
6429
+ hydrateFallbackElement = null;
6430
+ } else if (fallbackIndex === index) {
6431
+ shouldRenderHydrateFallback = true;
6432
+ hydrateFallbackElement = match.route.hydrateFallbackElement || null;
6433
+ }
6429
6434
  }
6430
6435
  }
6431
- }
6432
- let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
6433
- let getChildren = () => {
6434
- let children;
6435
- if (error) {
6436
- children = errorElement;
6437
- } else if (shouldRenderHydrateFallback) {
6438
- children = hydrateFallbackElement;
6439
- } else if (match.route.Component) {
6440
- children = /* @__PURE__ */ React3.createElement(match.route.Component, null);
6441
- } else if (match.route.element) {
6442
- children = match.route.element;
6443
- } else {
6444
- children = outlet;
6445
- }
6446
- return /* @__PURE__ */ React3.createElement(
6447
- RenderedRoute,
6436
+ let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
6437
+ let getChildren = () => {
6438
+ let children;
6439
+ if (error) {
6440
+ children = errorElement;
6441
+ } else if (shouldRenderHydrateFallback) {
6442
+ children = hydrateFallbackElement;
6443
+ } else if (match.route.Component) {
6444
+ children = /* @__PURE__ */ React3.createElement(match.route.Component, null);
6445
+ } else if (match.route.element) {
6446
+ children = match.route.element;
6447
+ } else {
6448
+ children = outlet;
6449
+ }
6450
+ return /* @__PURE__ */ React3.createElement(
6451
+ RenderedRoute,
6452
+ {
6453
+ match,
6454
+ routeContext: {
6455
+ outlet,
6456
+ matches: matches2,
6457
+ isDataRoute: dataRouterState != null
6458
+ },
6459
+ children
6460
+ }
6461
+ );
6462
+ };
6463
+ return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React3.createElement(
6464
+ RenderErrorBoundary,
6448
6465
  {
6449
- match,
6450
- routeContext: {
6451
- outlet,
6452
- matches: matches2,
6453
- isDataRoute: dataRouterState != null
6454
- },
6455
- children
6466
+ location: dataRouterState.location,
6467
+ revalidation: dataRouterState.revalidation,
6468
+ component: errorElement,
6469
+ error,
6470
+ children: getChildren(),
6471
+ routeContext: { outlet: null, matches: matches2, isDataRoute: true }
6456
6472
  }
6457
- );
6458
- };
6459
- return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React3.createElement(
6460
- RenderErrorBoundary,
6461
- {
6462
- location: dataRouterState.location,
6463
- revalidation: dataRouterState.revalidation,
6464
- component: errorElement,
6465
- error,
6466
- children: getChildren(),
6467
- routeContext: { outlet: null, matches: matches2, isDataRoute: true }
6468
- }
6469
- ) : getChildren();
6470
- }, null);
6473
+ ) : getChildren();
6474
+ },
6475
+ null
6476
+ );
6471
6477
  }
6472
6478
  function getDataRouterConsoleError(hookName) {
6473
6479
  return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
@@ -7630,10 +7636,7 @@ function Links() {
7630
7636
  ({ key, link }) => isPageLinkDescriptor(link) ? /* @__PURE__ */ React7.createElement(PrefetchPageLinks, { key, ...link }) : /* @__PURE__ */ React7.createElement("link", { key, ...link })
7631
7637
  ));
7632
7638
  }
7633
- function PrefetchPageLinks({
7634
- page,
7635
- ...dataLinkProps
7636
- }) {
7639
+ function PrefetchPageLinks({ page, ...linkProps }) {
7637
7640
  let { router } = useDataRouterContext2();
7638
7641
  let matches = React7.useMemo(
7639
7642
  () => matchRoutes(router.routes, page, router.basename),
@@ -7642,7 +7645,7 @@ function PrefetchPageLinks({
7642
7645
  if (!matches) {
7643
7646
  return null;
7644
7647
  }
7645
- return /* @__PURE__ */ React7.createElement(PrefetchPageLinksImpl, { page, matches, ...dataLinkProps });
7648
+ return /* @__PURE__ */ React7.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
7646
7649
  }
7647
7650
  function useKeyedPrefetchLinks(matches) {
7648
7651
  let { manifest, routeModules } = useFrameworkContext();
@@ -7846,7 +7849,7 @@ function isValidMetaTag(tagName) {
7846
7849
  return typeof tagName === "string" && /^(meta|link)$/.test(tagName);
7847
7850
  }
7848
7851
  var isHydrated = false;
7849
- function Scripts(props) {
7852
+ function Scripts(scriptProps) {
7850
7853
  let {
7851
7854
  manifest,
7852
7855
  serverHandoffString,
@@ -7932,7 +7935,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
7932
7935
  return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(
7933
7936
  "script",
7934
7937
  {
7935
- ...props,
7938
+ ...scriptProps,
7936
7939
  suppressHydrationWarning: true,
7937
7940
  dangerouslySetInnerHTML: createHtml(contextScript),
7938
7941
  type: void 0
@@ -7940,7 +7943,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
7940
7943
  ), /* @__PURE__ */ React7.createElement(
7941
7944
  "script",
7942
7945
  {
7943
- ...props,
7946
+ ...scriptProps,
7944
7947
  suppressHydrationWarning: true,
7945
7948
  dangerouslySetInnerHTML: createHtml(routeModulesScript),
7946
7949
  type: "module",
@@ -7977,7 +7980,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
7977
7980
  {
7978
7981
  rel: "modulepreload",
7979
7982
  href: manifest.url,
7980
- crossOrigin: props.crossOrigin,
7983
+ crossOrigin: scriptProps.crossOrigin,
7981
7984
  integrity: sri[manifest.url],
7982
7985
  suppressHydrationWarning: true
7983
7986
  }
@@ -7986,7 +7989,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
7986
7989
  {
7987
7990
  rel: "modulepreload",
7988
7991
  href: manifest.entry.module,
7989
- crossOrigin: props.crossOrigin,
7992
+ crossOrigin: scriptProps.crossOrigin,
7990
7993
  integrity: sri[manifest.entry.module],
7991
7994
  suppressHydrationWarning: true
7992
7995
  }
@@ -7996,7 +7999,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
7996
7999
  key: path,
7997
8000
  rel: "modulepreload",
7998
8001
  href: path,
7999
- crossOrigin: props.crossOrigin,
8002
+ crossOrigin: scriptProps.crossOrigin,
8000
8003
  integrity: sri[path],
8001
8004
  suppressHydrationWarning: true
8002
8005
  }