react-router 7.7.1 → 7.8.0-pre.1
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 +87 -5
- package/dist/development/browser-z32v5KVN.d.mts +46 -0
- package/dist/development/{chunk-R73PQUJU.js → chunk-4EVDZJGM.js} +130 -130
- package/dist/{production/chunk-K3SBCRK4.mjs → development/chunk-I22FVTOY.mjs} +177 -134
- package/dist/development/{chunk-K7YFBME3.js → chunk-NGF2R4G7.js} +285 -189
- package/dist/development/{chunk-C37GKA54.mjs → chunk-XFFANEXU.mjs} +266 -170
- package/dist/development/{components-CjQijYga.d.mts → components-CuPfnyiZ.d.mts} +33 -21
- package/dist/{production/route-data-CqEmXQub.d.mts → development/context-DohQKLID.d.mts} +312 -525
- package/dist/development/dom-export.d.mts +16 -12
- package/dist/development/dom-export.d.ts +13 -8
- package/dist/development/dom-export.js +3 -3
- package/dist/development/dom-export.mjs +3 -3
- package/dist/development/{index-react-server-client-Bi_fx8qz.d.ts → index-react-server-client-BzBbJLAD.d.ts} +357 -219
- package/dist/{production/index-react-server-client-KLg-U4nr.d.mts → development/index-react-server-client-CuajY2vy.d.mts} +327 -200
- package/dist/development/index-react-server-client.d.mts +4 -3
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +291 -71
- package/dist/development/index-react-server.d.ts +291 -71
- package/dist/development/index-react-server.js +209 -182
- package/dist/development/index-react-server.mjs +209 -182
- package/dist/development/index.d.mts +294 -86
- package/dist/development/index.d.ts +136 -105
- package/dist/development/index.js +258 -215
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.d.mts +13 -2
- package/dist/development/lib/types/internal.d.ts +12 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/route-data-CpB5xtMm.d.mts +473 -0
- package/dist/{production/routeModules-BR2FO0ix.d.ts → development/routeModules-qBivMBjd.d.ts} +325 -68
- package/dist/production/browser-z32v5KVN.d.mts +46 -0
- package/dist/production/{chunk-4DGLNKXF.js → chunk-4PESVXQ2.js} +130 -130
- package/dist/{development/chunk-KIUJAIYX.mjs → production/chunk-JJOMWYJ4.mjs} +177 -134
- package/dist/production/{chunk-IZ57JD2V.mjs → chunk-P2ZJHOXZ.mjs} +266 -170
- package/dist/production/{chunk-7OQROU2D.js → chunk-RLJ23MYZ.js} +285 -189
- package/dist/production/{components-CjQijYga.d.mts → components-CuPfnyiZ.d.mts} +33 -21
- package/dist/{development/route-data-CqEmXQub.d.mts → production/context-DohQKLID.d.mts} +312 -525
- package/dist/production/dom-export.d.mts +16 -12
- package/dist/production/dom-export.d.ts +13 -8
- package/dist/production/dom-export.js +3 -3
- package/dist/production/dom-export.mjs +3 -3
- package/dist/production/{index-react-server-client-Bi_fx8qz.d.ts → index-react-server-client-BzBbJLAD.d.ts} +357 -219
- package/dist/{development/index-react-server-client-KLg-U4nr.d.mts → production/index-react-server-client-CuajY2vy.d.mts} +327 -200
- package/dist/production/index-react-server-client.d.mts +4 -3
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +291 -71
- package/dist/production/index-react-server.d.ts +291 -71
- package/dist/production/index-react-server.js +209 -182
- package/dist/production/index-react-server.mjs +209 -182
- package/dist/production/index.d.mts +294 -86
- package/dist/production/index.d.ts +136 -105
- package/dist/production/index.js +258 -215
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.d.mts +13 -2
- package/dist/production/lib/types/internal.d.ts +12 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/route-data-CpB5xtMm.d.mts +473 -0
- package/dist/{development/routeModules-BR2FO0ix.d.ts → production/routeModules-qBivMBjd.d.ts} +325 -68
- package/package.json +1 -1
- package/dist/development/browser-7LYX59NK.d.mts +0 -226
- package/dist/production/browser-7LYX59NK.d.mts +0 -226
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,92 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## 7.8.0-pre.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [REMOVE] Few additional fixes for returning/throwing data from middleware - attach to #14093 ([#14128](https://github.com/remix-run/react-router/pull/14128))
|
|
8
|
+
|
|
9
|
+
## 7.8.0-pre.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Add `nonce` prop to `Links` & `PrefetchPageLinks` ([#14048](https://github.com/remix-run/react-router/pull/14048))
|
|
14
|
+
- Add `loaderData` arguments/properties alongside existing `data` arguments/properties to provide consistency and clarity between `loaderData` and `actionData` across the board ([#14047](https://github.com/remix-run/react-router/pull/14047))
|
|
15
|
+
- Updated types: `Route.MetaArgs`, `Route.MetaMatch`, `MetaArgs`, `MetaMatch`, `Route.ComponentProps.matches`, `UIMatch`
|
|
16
|
+
- `@deprecated` warnings have been added to the existing `data` properties to point users to new `loaderData` properties, in preparation for removing the `data` properties in a future major release
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [UNSTABLE] Ensure resource route errors go through `handleError` w/middleware enabled ([#14078](https://github.com/remix-run/react-router/pull/14078))
|
|
21
|
+
- Prevent _"Did not find corresponding fetcher result"_ console error when navigating during a `fetcher.submit` revalidation ([#14114](https://github.com/remix-run/react-router/pull/14114))
|
|
22
|
+
- Switch Lazy Route Discovery manifest URL generation to usea standalone `URLSearchParams` instance instead of `URL.searchParams` to avoid a major performance bottleneck in Chrome ([#14084](https://github.com/remix-run/react-router/pull/14084))
|
|
23
|
+
- [UNSTABLE] Propagate returned Response from server middleware if next wasn't called ([#14093](https://github.com/remix-run/react-router/pull/14093))
|
|
24
|
+
- [UNSTABLE] Allow server middlewares to return `data()` values which will be converted into a `Response` ([#14093](https://github.com/remix-run/react-router/pull/14093))
|
|
25
|
+
- [UNSTABLE] Update middleware error handling so that the `next` function never throws and instead handles any middleware errors at the proper `ErrorBoundary` and returns the `Response` up through the ancestor `next` function ([#14118](https://github.com/remix-run/react-router/pull/14118))
|
|
26
|
+
- - [UNSTABLE] When middleware is enabled, make the `context` parameter read-only (via `Readonly<unstable_RouterContextProvider>`) so that TypeScript will not allow you to write arbitrary fields to it in loaders, actions, or middleware. ([#14097](https://github.com/remix-run/react-router/pull/14097))
|
|
27
|
+
- [UNSTABLE] Rename and alter the signature/functionality of the `unstable_respond` API in `staticHandler.query`/`staticHandler.queryRoute` ([#14103](https://github.com/remix-run/react-router/pull/14103))
|
|
28
|
+
- The API has been renamed to `unstable_generateMiddlewareResponse` for clarity
|
|
29
|
+
- The main functional change is that instead of running the loaders/actions before calling `unstable_respond` and handing you the result, we now pass a `query`/`queryRoute` function as a parameter and you execute the loaders/actions inside your callback, giving you full access to pre-processing and error handling
|
|
30
|
+
- The `query` version of the API now has a signature of `(query: (r: Request) => Promise<StaticHandlerContext | Response>) => Promise<Response>`
|
|
31
|
+
- The `queryRoute` version of the API now has a signature of `(queryRoute: (r: Request) => Promise<Response>) => Promise<Response>`
|
|
32
|
+
- This allows for more advanced usages such as running logic before/after calling `query` and direct error handling of errors thrown from query
|
|
33
|
+
- ⚠️ This is a breaking change if you've adopted the `staticHandler` `unstable_respond` API
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
let response = await staticHandler.query(request, {
|
|
37
|
+
requestContext: new unstable_RouterContextProvider(),
|
|
38
|
+
async unstable_generateMiddlewareResponse(query) {
|
|
39
|
+
try {
|
|
40
|
+
// At this point we've run middleware top-down so we need to call the
|
|
41
|
+
// handlers and generate the Response to bubble back up the middleware
|
|
42
|
+
let result = await query(request);
|
|
43
|
+
if (isResponse(result)) {
|
|
44
|
+
return result; // Redirects, etc.
|
|
45
|
+
}
|
|
46
|
+
return await generateHtmlResponse(result);
|
|
47
|
+
} catch (error: unknown) {
|
|
48
|
+
return generateErrorResponse(error);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- [UNSTABLE] Convert internal middleware implementations to use the new `unstable_generateMiddlewareResponse` API ([#14103](https://github.com/remix-run/react-router/pull/14103))
|
|
55
|
+
- Adjust internal RSC usage of `React.use` to avoid Webpack compilation errors when using React 18 ([#14113](https://github.com/remix-run/react-router/pull/14113))
|
|
56
|
+
- [UNSTABLE] Change `getLoadContext` signature (`type GetLoadContextFunction`) when `future.unstable_middleware` is enabled so that it returns an `unstable_RouterContextProvider` instance instead of a `Map` used to contruct the instance internally ([#14097](https://github.com/remix-run/react-router/pull/14097))
|
|
57
|
+
- This also removes the `type unstable_InitialContext` export
|
|
58
|
+
- ⚠️ This is a breaking change if you have adopted middleware and are using a custom server with a `getLoadContext` function
|
|
59
|
+
|
|
60
|
+
- Remove dependency on `@types/node` in TypeScript declaration files ([#14059](https://github.com/remix-run/react-router/pull/14059))
|
|
61
|
+
- Fix types for `UIMatch` to reflect that the `loaderData`/`data` properties may be `undefined` ([#12206](https://github.com/remix-run/react-router/pull/12206))
|
|
62
|
+
- When an `ErrorBoundary` is being rendered, not all active matches will have loader data available, since it may have been their `loader` that threw to trigger the boundary
|
|
63
|
+
- The `UIMatch.data` type was not correctly handing this and would always reflect the presence of data, leading to the unexpected runtime errors when an `ErrorBoundary` was rendered
|
|
64
|
+
- ⚠️ This may cause some type errors to show up in your code for unguarded `match.data` accesses - you should properly guard for `undefined` values in those scenarios.
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
// app/root.tsx
|
|
68
|
+
export function loader() {
|
|
69
|
+
someFunctionThatThrows(); // ❌ Throws an Error
|
|
70
|
+
return { title: "My Title" };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function Layout({ children }: { children: React.ReactNode }) {
|
|
74
|
+
let matches = useMatches();
|
|
75
|
+
let rootMatch = matches[0] as UIMatch<Awaited<ReturnType<typeof loader>>>;
|
|
76
|
+
// ^ rootMatch.data is incorrectly typed here, so TypeScript does not
|
|
77
|
+
// complain if you do the following which throws an error at runtime:
|
|
78
|
+
let { title } = rootMatch.data; // 💥
|
|
79
|
+
|
|
80
|
+
return <html>...</html>;
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- [UNSTABLE] Run client middleware on client navigations even if no loaders exist ([#14106](https://github.com/remix-run/react-router/pull/14106))
|
|
85
|
+
- [UNSTABLE] Change the `unstable_getContext` signature on `RouterProvider`/`HydratedRouter`/`unstable_RSCHydratedRouter` so that it returns an `unstable_RouterContextProvider` instance instead of a `Map` used to contruct the instance internally ([#14097](https://github.com/remix-run/react-router/pull/14097))
|
|
86
|
+
- ⚠️ This is a breaking change if you have adopted the `unstable_getContext` prop
|
|
87
|
+
|
|
88
|
+
- Fix RSC Data Mode issue where routes that return `false` from `shouldRevalidate` would be replaced by an `<Outlet />` ([#14071](https://github.com/remix-run/react-router/pull/14071))
|
|
89
|
+
|
|
3
90
|
## 7.7.1
|
|
4
91
|
|
|
5
92
|
### Patch Changes
|
|
@@ -604,7 +691,6 @@
|
|
|
604
691
|
```
|
|
605
692
|
|
|
606
693
|
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:
|
|
607
|
-
|
|
608
694
|
- Library mode - `createBrowserRouter(routes, { unstable_getContext })`
|
|
609
695
|
- Framework mode - `<HydratedRouter unstable_getContext>`
|
|
610
696
|
|
|
@@ -792,7 +878,6 @@ _No changes_
|
|
|
792
878
|
- Remove `future.v7_normalizeFormMethod` future flag ([#11697](https://github.com/remix-run/react-router/pull/11697))
|
|
793
879
|
|
|
794
880
|
- 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))
|
|
795
|
-
|
|
796
881
|
- `createCookie`
|
|
797
882
|
- `createCookieSessionStorage`
|
|
798
883
|
- `createMemorySessionStorage`
|
|
@@ -801,7 +886,6 @@ _No changes_
|
|
|
801
886
|
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)
|
|
802
887
|
|
|
803
888
|
Since platform-specific packages no longer need to implement this API, the following low-level APIs have been removed:
|
|
804
|
-
|
|
805
889
|
- `createCookieFactory`
|
|
806
890
|
- `createSessionStorageFactory`
|
|
807
891
|
- `createCookieSessionStorageFactory`
|
|
@@ -957,7 +1041,6 @@ _No changes_
|
|
|
957
1041
|
```
|
|
958
1042
|
|
|
959
1043
|
This initial implementation targets type inference for:
|
|
960
|
-
|
|
961
1044
|
- `Params` : Path parameters from your routing config in `routes.ts` including file-based routing
|
|
962
1045
|
- `LoaderData` : Loader data from `loader` and/or `clientLoader` within your route module
|
|
963
1046
|
- `ActionData` : Action data from `action` and/or `clientAction` within your route module
|
|
@@ -972,7 +1055,6 @@ _No changes_
|
|
|
972
1055
|
```
|
|
973
1056
|
|
|
974
1057
|
Check out our docs for more:
|
|
975
|
-
|
|
976
1058
|
- [_Explanations > Type Safety_](https://reactrouter.com/dev/guides/explanation/type-safety)
|
|
977
1059
|
- [_How-To > Setting up type safety_](https://reactrouter.com/dev/guides/how-to/setting-up-type-safety)
|
|
978
1060
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
__FLIGHT_DATA: any[];
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Get the prerendered [RSC](https://react.dev/reference/rsc/server-components)
|
|
8
|
+
* stream for hydration. Usually passed directly to your
|
|
9
|
+
* `react-server-dom-xyz/client`'s `createFromReadableStream`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { startTransition, StrictMode } from "react";
|
|
13
|
+
* import { hydrateRoot } from "react-dom/client";
|
|
14
|
+
* import {
|
|
15
|
+
* unstable_getRSCStream as getRSCStream,
|
|
16
|
+
* unstable_RSCHydratedRouter as RSCHydratedRouter,
|
|
17
|
+
* } from "react-router";
|
|
18
|
+
* import type { unstable_RSCPayload as RSCPayload } from "react-router";
|
|
19
|
+
*
|
|
20
|
+
* createFromReadableStream(getRSCStream()).then(
|
|
21
|
+
* (payload: RSCServerPayload) => {
|
|
22
|
+
* startTransition(async () => {
|
|
23
|
+
* hydrateRoot(
|
|
24
|
+
* document,
|
|
25
|
+
* <StrictMode>
|
|
26
|
+
* <RSCHydratedRouter {...props} />
|
|
27
|
+
* </StrictMode>,
|
|
28
|
+
* {
|
|
29
|
+
* // Options
|
|
30
|
+
* }
|
|
31
|
+
* );
|
|
32
|
+
* });
|
|
33
|
+
* }
|
|
34
|
+
* );
|
|
35
|
+
*
|
|
36
|
+
* @name unstable_getRSCStream
|
|
37
|
+
* @public
|
|
38
|
+
* @category RSC
|
|
39
|
+
* @mode data
|
|
40
|
+
* @returns A [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
|
|
41
|
+
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
|
42
|
+
* data for hydration.
|
|
43
|
+
*/
|
|
44
|
+
declare function getRSCStream(): ReadableStream;
|
|
45
|
+
|
|
46
|
+
export { getRSCStream as g };
|