react-router 7.6.0-pre.0 → 7.6.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 (36) hide show
  1. package/CHANGELOG.md +104 -1
  2. package/dist/development/dom-export.d.mts +1 -2
  3. package/dist/development/dom-export.js +1 -1
  4. package/dist/development/dom-export.mjs +23 -23
  5. package/dist/development/index.d.mts +3740 -260
  6. package/dist/development/index.d.ts +1762 -12
  7. package/dist/development/index.js +16 -7
  8. package/dist/development/index.mjs +11439 -121
  9. package/dist/development/internal-export.d.mts +504 -0
  10. package/dist/development/internal-export.d.ts +504 -0
  11. package/dist/development/{lib/types/route-module.js → internal-export.js} +4 -4
  12. package/dist/development/{lib/types/route-module.mjs → internal-export.mjs} +1 -1
  13. package/dist/production/dom-export.d.mts +1 -2
  14. package/dist/production/dom-export.js +1 -1
  15. package/dist/production/dom-export.mjs +23 -23
  16. package/dist/production/index.d.mts +3740 -260
  17. package/dist/production/index.d.ts +1762 -12
  18. package/dist/production/index.js +16 -7
  19. package/dist/production/index.mjs +11439 -121
  20. package/dist/production/internal-export.d.mts +504 -0
  21. package/dist/production/internal-export.d.ts +504 -0
  22. package/dist/production/{lib/types/route-module.js → internal-export.js} +4 -4
  23. package/dist/production/{lib/types/route-module.mjs → internal-export.mjs} +1 -1
  24. package/package.json +7 -7
  25. package/dist/development/chunk-RXI6MVY4.mjs +0 -11556
  26. package/dist/development/lib/types/route-module.d.mts +0 -208
  27. package/dist/development/lib/types/route-module.d.ts +0 -208
  28. package/dist/development/lib-CCSAGgcP.d.mts +0 -1736
  29. package/dist/development/route-data-B9_30zbP.d.ts +0 -1749
  30. package/dist/development/route-data-C6QaL0wu.d.mts +0 -1749
  31. package/dist/production/chunk-TW7XT4WH.mjs +0 -11556
  32. package/dist/production/lib/types/route-module.d.mts +0 -208
  33. package/dist/production/lib/types/route-module.d.ts +0 -208
  34. package/dist/production/lib-CCSAGgcP.d.mts +0 -1736
  35. package/dist/production/route-data-B9_30zbP.d.ts +0 -1749
  36. package/dist/production/route-data-C6QaL0wu.d.mts +0 -1749
package/CHANGELOG.md CHANGED
@@ -1,6 +1,96 @@
1
1
  # `react-router`
2
2
 
3
- ## 7.6.0-pre.0
3
+ ## 7.6.1-pre.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Update `Route.MetaArgs` to reflect that `data` can be potentially `undefined` ([#13563](https://github.com/remix-run/react-router/pull/13563))
8
+
9
+ This is primarily for cases where a route `loader` threw an error to it's own `ErrorBoundary`. but it also arises in the case of a 404 which renders the root `ErrorBoundary`/`meta` but the root loader did not run because not routes matched.
10
+
11
+ - Partially revert optimization added in `7.1.4` to reduce calls to `matchRoutes` because it surfaced other issues ([#13562](https://github.com/remix-run/react-router/pull/13562))
12
+ - Fix typegen when same route is used at multiple paths ([#13574](https://github.com/remix-run/react-router/pull/13574))
13
+
14
+ For example, `routes/route.tsx` is used at 4 different paths here:
15
+
16
+ ```ts
17
+ import { type RouteConfig, route } from "@react-router/dev/routes";
18
+ export default [
19
+ route("base/:base", "routes/base.tsx", [
20
+ route("home/:home", "routes/route.tsx", { id: "home" }),
21
+ route("changelog/:changelog", "routes/route.tsx", { id: "changelog" }),
22
+ route("splat/*", "routes/route.tsx", { id: "splat" }),
23
+ ]),
24
+ route("other/:other", "routes/route.tsx", { id: "other" }),
25
+ ] satisfies RouteConfig;
26
+ ```
27
+
28
+ Previously, typegen would arbitrarily pick one of these paths to be the "winner" and generate types for the route module based on that path.
29
+ Now, typegen creates unions as necessary for alternate paths for the same route file.
30
+
31
+ - Better types for `params` ([#13543](https://github.com/remix-run/react-router/pull/13543))
32
+
33
+ For example:
34
+
35
+ ```ts
36
+ // routes.ts
37
+ import { type RouteConfig, route } from "@react-router/dev/routes";
38
+
39
+ export default [
40
+ route("parent/:p", "routes/parent.tsx", [
41
+ route("route/:r", "routes/route.tsx", [
42
+ route("child1/:c1a/:c1b", "routes/child1.tsx"),
43
+ route("child2/:c2a/:c2b", "routes/child2.tsx"),
44
+ ]),
45
+ ]),
46
+ ] satisfies RouteConfig;
47
+ ```
48
+
49
+ Previously, `params` for `routes/route` were calculated as `{ p: string, r: string }`.
50
+ This incorrectly ignores params that could come from child routes.
51
+ If visiting `/parent/1/route/2/child1/3/4`, the actual params passed to `routes/route` will have a type of `{ p: string, r: string, c1a: string, c1b: string }`.
52
+
53
+ Now, `params` are aware of child routes and autocompletion will include child params as optionals:
54
+
55
+ ```ts
56
+ params.|
57
+ // ^ cursor is here and you ask for autocompletion
58
+ // p: string
59
+ // r: string
60
+ // c1a?: string
61
+ // c1b?: string
62
+ // c2a?: string
63
+ // c2b?: string
64
+ ```
65
+
66
+ You can also narrow the types for `params` as it is implemented as a normalized union of params for each page that includes `routes/route`:
67
+
68
+ ```ts
69
+ if (typeof params.c1a === 'string') {
70
+ params.|
71
+ // ^ cursor is here and you ask for autocompletion
72
+ // p: string
73
+ // r: string
74
+ // c1a: string
75
+ // c1b: string
76
+ }
77
+ ```
78
+
79
+ ***
80
+
81
+ UNSTABLE: renamed internal `react-router/route-module` export to `react-router/internal`
82
+ UNSTABLE: removed `Info` export from generated `+types/*` files
83
+
84
+ - Avoid initial fetcher execution 404 error when Lazy Route Discovery is interrupted by a navigation ([#13564](https://github.com/remix-run/react-router/pull/13564))
85
+ - Remove hashes from files in `dist/` for easier usage with `patch-package` ([#13567](https://github.com/remix-run/react-router/pull/13567))
86
+ - href replaces splats `*` ([#13593](https://github.com/remix-run/react-router/pull/13593))
87
+
88
+ ```ts
89
+ const a = href("/products/*", { "*": "/1/edit" });
90
+ // -> /products/1/edit
91
+ ```
92
+
93
+ ## 7.6.0
4
94
 
5
95
  ### Minor Changes
6
96
 
@@ -37,22 +127,35 @@
37
127
  ### Patch Changes
38
128
 
39
129
  - Fix `react-router` module augmentation for `NodeNext` ([#13498](https://github.com/remix-run/react-router/pull/13498))
130
+
40
131
  - Don't bundle `react-router` in `react-router/dom` CJS export ([#13497](https://github.com/remix-run/react-router/pull/13497))
132
+
41
133
  - Fix bug where a submitting `fetcher` would get stuck in a `loading` state if a revalidating `loader` redirected ([#12873](https://github.com/remix-run/react-router/pull/12873))
134
+
42
135
  - Fix hydration error if a server `loader` returned `undefined` ([#13496](https://github.com/remix-run/react-router/pull/13496))
136
+
43
137
  - Fix initial load 404 scenarios in data mode ([#13500](https://github.com/remix-run/react-router/pull/13500))
138
+
44
139
  - Stabilize `useRevalidator`'s `revalidate` function ([#13542](https://github.com/remix-run/react-router/pull/13542))
140
+
45
141
  - Preserve status code if a `clientAction` throws a `data()` result in framework mode ([#13522](https://github.com/remix-run/react-router/pull/13522))
142
+
46
143
  - 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))
47
144
 
48
145
  - 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)`
49
146
 
50
147
  - 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))
148
+
51
149
  - Fix `handleError` `params` values on `.data` requests for routes with a dynamic param as the last URL segment ([#13481](https://github.com/remix-run/react-router/pull/13481))
150
+
52
151
  - Don't trigger an `ErrorBoundary` UI before the reload when we detect a manifest verison mismatch in Lazy Route Discovery ([#13480](https://github.com/remix-run/react-router/pull/13480))
152
+
53
153
  - Inline `turbo-stream@2.4.1` dependency and fix decoding ordering of Map/Set instances ([#13518](https://github.com/remix-run/react-router/pull/13518))
154
+
54
155
  - Only render dev warnings in DEV mode ([#13461](https://github.com/remix-run/react-router/pull/13461))
156
+
55
157
  - UNSTABLE: Fix a few bugs with error bubbling in middleware use-cases ([#13538](https://github.com/remix-run/react-router/pull/13538))
158
+
56
159
  - Short circuit post-processing on aborted `dataStrategy` requests ([#13521](https://github.com/remix-run/react-router/pull/13521))
57
160
 
58
161
  - This resolves non-user-facing console errors of the form `Cannot read properties of undefined (reading 'result')`
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1 } from './lib-CCSAGgcP.mjs';
3
- import { R as RouterInit } from './route-data-C6QaL0wu.mjs';
2
+ import { RouterProviderProps as RouterProviderProps$1, RouterInit } from 'react-router';
4
3
 
5
4
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
6
5
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.6.0-pre.0
2
+ * react-router v7.6.1-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.6.0-pre.0
2
+ * react-router v7.6.1-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,34 +8,34 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import {
12
- FrameworkContext,
13
- RemixErrorBoundary,
14
- RouterProvider,
15
- createBrowserHistory,
16
- createClientRoutes,
17
- createClientRoutesWithHMRRevalidationOptOut,
18
- createRouter,
19
- decodeViaTurboStream,
20
- deserializeErrors,
21
- getHydrationData,
22
- getPatchRoutesOnNavigationFunction,
23
- getTurboStreamSingleFetchDataStrategy,
24
- hydrationRouteProperties,
25
- invariant,
26
- mapRouteProperties,
27
- useFogOFWarDiscovery
28
- } from "./chunk-RXI6MVY4.mjs";
29
11
 
30
12
  // lib/dom-export/dom-router-provider.tsx
31
13
  import * as React from "react";
32
14
  import * as ReactDOM from "react-dom";
33
- function RouterProvider2(props) {
34
- return /* @__PURE__ */ React.createElement(RouterProvider, { flushSync: ReactDOM.flushSync, ...props });
15
+ import { RouterProvider as BaseRouterProvider } from "react-router";
16
+ function RouterProvider(props) {
17
+ return /* @__PURE__ */ React.createElement(BaseRouterProvider, { flushSync: ReactDOM.flushSync, ...props });
35
18
  }
36
19
 
37
20
  // lib/dom-export/hydrated-router.tsx
38
21
  import * as React2 from "react";
22
+ import {
23
+ UNSAFE_getHydrationData as getHydrationData,
24
+ UNSAFE_invariant as invariant,
25
+ UNSAFE_FrameworkContext as FrameworkContext,
26
+ UNSAFE_decodeViaTurboStream as decodeViaTurboStream,
27
+ UNSAFE_RemixErrorBoundary as RemixErrorBoundary,
28
+ UNSAFE_createBrowserHistory as createBrowserHistory,
29
+ UNSAFE_createClientRoutes as createClientRoutes,
30
+ UNSAFE_createRouter as createRouter,
31
+ UNSAFE_deserializeErrors as deserializeErrors,
32
+ UNSAFE_getTurboStreamSingleFetchDataStrategy as getTurboStreamSingleFetchDataStrategy,
33
+ UNSAFE_getPatchRoutesOnNavigationFunction as getPatchRoutesOnNavigationFunction,
34
+ UNSAFE_useFogOFWarDiscovery as useFogOFWarDiscovery,
35
+ UNSAFE_mapRouteProperties as mapRouteProperties,
36
+ UNSAFE_hydrationRouteProperties as hydrationRouteProperties,
37
+ UNSAFE_createClientRoutesWithHMRRevalidationOptOut as createClientRoutesWithHMRRevalidationOptOut
38
+ } from "react-router";
39
39
  var ssrInfo = null;
40
40
  var router = null;
41
41
  function initSsrInfo() {
@@ -215,11 +215,11 @@ function HydratedRouter(props) {
215
215
  routeDiscovery: ssrInfo.context.routeDiscovery
216
216
  }
217
217
  },
218
- /* @__PURE__ */ React2.createElement(RemixErrorBoundary, { location }, /* @__PURE__ */ React2.createElement(RouterProvider2, { router }))
218
+ /* @__PURE__ */ React2.createElement(RemixErrorBoundary, { location }, /* @__PURE__ */ React2.createElement(RouterProvider, { router }))
219
219
  ), /* @__PURE__ */ React2.createElement(React2.Fragment, null))
220
220
  );
221
221
  }
222
222
  export {
223
223
  HydratedRouter,
224
- RouterProvider2 as RouterProvider
224
+ RouterProvider
225
225
  };