react-router 0.0.0-experimental-119d5d872 → 0.0.0-experimental-2bfe0a2f2

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 (53) hide show
  1. package/CHANGELOG.md +258 -3
  2. package/README.md +5 -14
  3. package/dist/development/chunk-MADJIA3T.mjs +9987 -0
  4. package/dist/development/dom-export.d.mts +23 -0
  5. package/dist/development/dom-export.d.ts +23 -0
  6. package/dist/development/dom-export.js +5682 -0
  7. package/dist/development/dom-export.mjs +202 -0
  8. package/dist/development/fog-of-war-BGx5gCsj.d.mts +1677 -0
  9. package/dist/development/fog-of-war-BtD7bJau.d.ts +1677 -0
  10. package/dist/development/index.d.mts +837 -0
  11. package/dist/development/index.d.ts +837 -0
  12. package/dist/development/index.js +10132 -0
  13. package/dist/development/index.mjs +236 -0
  14. package/dist/development/lib/types/route-module.d.mts +115 -0
  15. package/dist/development/lib/types/route-module.d.ts +115 -0
  16. package/dist/development/lib/types/route-module.js +28 -0
  17. package/dist/development/lib/types/route-module.mjs +10 -0
  18. package/dist/development/route-data-C8zta6G6.d.mts +1589 -0
  19. package/dist/development/route-data-C8zta6G6.d.ts +1589 -0
  20. package/dist/production/chunk-6RN32PD3.mjs +9987 -0
  21. package/dist/production/dom-export.d.mts +23 -0
  22. package/dist/production/dom-export.d.ts +23 -0
  23. package/dist/production/dom-export.js +5682 -0
  24. package/dist/production/dom-export.mjs +202 -0
  25. package/dist/production/fog-of-war-BGx5gCsj.d.mts +1677 -0
  26. package/dist/production/fog-of-war-BtD7bJau.d.ts +1677 -0
  27. package/dist/production/index.d.mts +837 -0
  28. package/dist/production/index.d.ts +837 -0
  29. package/dist/production/index.js +10132 -0
  30. package/dist/production/index.mjs +236 -0
  31. package/dist/production/lib/types/route-module.d.mts +115 -0
  32. package/dist/production/lib/types/route-module.d.ts +115 -0
  33. package/dist/production/lib/types/route-module.js +28 -0
  34. package/dist/production/lib/types/route-module.mjs +10 -0
  35. package/dist/production/route-data-C8zta6G6.d.mts +1589 -0
  36. package/dist/production/route-data-C8zta6G6.d.ts +1589 -0
  37. package/package.json +80 -9
  38. package/dist/index.d.ts +0 -30
  39. package/dist/index.js +0 -1500
  40. package/dist/index.js.map +0 -1
  41. package/dist/lib/components.d.ts +0 -157
  42. package/dist/lib/context.d.ts +0 -102
  43. package/dist/lib/deprecations.d.ts +0 -4
  44. package/dist/lib/hooks.d.ts +0 -181
  45. package/dist/main.js +0 -19
  46. package/dist/react-router.development.js +0 -1396
  47. package/dist/react-router.development.js.map +0 -1
  48. package/dist/react-router.production.min.js +0 -12
  49. package/dist/react-router.production.min.js.map +0 -1
  50. package/dist/umd/react-router.development.js +0 -1623
  51. package/dist/umd/react-router.development.js.map +0 -1
  52. package/dist/umd/react-router.production.min.js +0 -12
  53. package/dist/umd/react-router.production.min.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,16 +1,271 @@
1
1
  # `react-router`
2
2
 
3
- ## 6.28.1
3
+ ## 7.0.2
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Allow users to opt out of deprecation warnings by setting flags to false ([#12441](https://github.com/remix-run/react-router/pull/12441))
7
+ - temporarily only use one build in export map so packages can have a peer dependency on react router ([#12437](https://github.com/remix-run/react-router/pull/12437))
8
+ - Generate wide `matches` and `params` types for current route and child routes ([#12397](https://github.com/remix-run/react-router/pull/12397))
9
+
10
+ At runtime, `matches` includes child route matches and `params` include child route path parameters.
11
+ But previously, we only generated types for parent routes in `matches`; for `params`, we only considered the parent routes and the current route.
12
+ To align our generated types more closely to the runtime behavior, we now generate more permissive, wider types when accessing child route information.
13
+
14
+ ## 7.0.1
15
+
16
+ ## 7.0.0
17
+
18
+ ### Major Changes
19
+
20
+ - 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))
21
+
22
+ - `defer`
23
+ - `AbortedDeferredError`
24
+ - `type TypedDeferredData`
25
+ - `UNSAFE_DeferredData`
26
+ - `UNSAFE_DEFERRED_SYMBOL`,
27
+
28
+ - - Collapse `@remix-run/router` into `react-router` ([#11505](https://github.com/remix-run/react-router/pull/11505))
29
+ - Collapse `react-router-dom` into `react-router`
30
+ - Collapse `@remix-run/server-runtime` into `react-router`
31
+ - Collapse `@remix-run/testing` into `react-router`
32
+
33
+ - Remove single_fetch future flag. ([#11522](https://github.com/remix-run/react-router/pull/11522))
34
+
35
+ - Drop support for Node 16, React Router SSR now requires Node 18 or higher ([#11391](https://github.com/remix-run/react-router/pull/11391))
36
+
37
+ - Remove `future.v7_startTransition` flag ([#11696](https://github.com/remix-run/react-router/pull/11696))
38
+
39
+ - - Expose the underlying router promises from the following APIs for compsition in React 19 APIs: ([#11521](https://github.com/remix-run/react-router/pull/11521))
40
+ - `useNavigate()`
41
+ - `useSubmit`
42
+ - `useFetcher().load`
43
+ - `useFetcher().submit`
44
+ - `useRevalidator.revalidate`
45
+
46
+ - Remove `future.v7_normalizeFormMethod` future flag ([#11697](https://github.com/remix-run/react-router/pull/11697))
47
+
48
+ - 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))
49
+
50
+ - `createCookie`
51
+ - `createCookieSessionStorage`
52
+ - `createMemorySessionStorage`
53
+ - `createSessionStorage`
54
+
55
+ 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)
56
+
57
+ Since platform-specific packages no longer need to implement this API, the following low-level APIs have been removed:
58
+
59
+ - `createCookieFactory`
60
+ - `createSessionStorageFactory`
61
+ - `createCookieSessionStorageFactory`
62
+ - `createMemorySessionStorageFactory`
63
+
64
+ - Imports/Exports cleanup ([#11840](https://github.com/remix-run/react-router/pull/11840))
65
+
66
+ - Removed the following exports that were previously public API from `@remix-run/router`
67
+ - types
68
+ - `AgnosticDataIndexRouteObject`
69
+ - `AgnosticDataNonIndexRouteObject`
70
+ - `AgnosticDataRouteMatch`
71
+ - `AgnosticDataRouteObject`
72
+ - `AgnosticIndexRouteObject`
73
+ - `AgnosticNonIndexRouteObject`
74
+ - `AgnosticRouteMatch`
75
+ - `AgnosticRouteObject`
76
+ - `TrackedPromise`
77
+ - `unstable_AgnosticPatchRoutesOnMissFunction`
78
+ - `Action` -> exported as `NavigationType` via `react-router`
79
+ - `Router` exported as `DataRouter` to differentiate from RR's `<Router>`
80
+ - API
81
+ - `getToPathname` (`@private`)
82
+ - `joinPaths` (`@private`)
83
+ - `normalizePathname` (`@private`)
84
+ - `resolveTo` (`@private`)
85
+ - `stripBasename` (`@private`)
86
+ - `createBrowserHistory` -> in favor of `createBrowserRouter`
87
+ - `createHashHistory` -> in favor of `createHashRouter`
88
+ - `createMemoryHistory` -> in favor of `createMemoryRouter`
89
+ - `createRouter`
90
+ - `createStaticHandler` -> in favor of wrapper `createStaticHandler` in RR Dom
91
+ - `getStaticContextFromError`
92
+ - Removed the following exports that were previously public API from `react-router`
93
+ - `Hash`
94
+ - `Pathname`
95
+ - `Search`
96
+
97
+ - update minimum node version to 18 ([#11690](https://github.com/remix-run/react-router/pull/11690))
98
+
99
+ - Remove `future.v7_prependBasename` from the ionternalized `@remix-run/router` package ([#11726](https://github.com/remix-run/react-router/pull/11726))
100
+
101
+ - Migrate Remix type generics to React Router ([#12180](https://github.com/remix-run/react-router/pull/12180))
102
+
103
+ - These generics are provided for Remix v2 migration purposes
104
+ - These generics and the APIs they exist on should be considered informally deprecated in favor of the new `Route.*` types
105
+ - Anyone migrating from React Router v6 should probably not leverage these new generics and should migrate straight to the `Route.*` types
106
+ - For React Router v6 users, these generics are new and should not impact your app, with one exception
107
+ - `useFetcher` previously had an optional generic (used primarily by Remix v2) that expected the data type
108
+ - This has been updated in v7 to expect the type of the function that generates the data (i.e., `typeof loader`/`typeof action`)
109
+ - Therefore, you should update your usages:
110
+ - ❌ `useFetcher<LoaderData>()`
111
+ - ✅ `useFetcher<typeof loader>()`
112
+
113
+ - Remove `future.v7_throwAbortReason` from internalized `@remix-run/router` package ([#11728](https://github.com/remix-run/react-router/pull/11728))
114
+
115
+ - Add `exports` field to all packages ([#11675](https://github.com/remix-run/react-router/pull/11675))
116
+
117
+ - node package no longer re-exports from react-router ([#11702](https://github.com/remix-run/react-router/pull/11702))
118
+
119
+ - renamed RemixContext to FrameworkContext ([#11705](https://github.com/remix-run/react-router/pull/11705))
120
+
121
+ - updates the minimum React version to 18 ([#11689](https://github.com/remix-run/react-router/pull/11689))
122
+
123
+ - PrefetchPageDescriptor replaced by PageLinkDescriptor ([#11960](https://github.com/remix-run/react-router/pull/11960))
124
+
125
+ - - Consolidate types previously duplicated across `@remix-run/router`, `@remix-run/server-runtime`, and `@remix-run/react` now that they all live in `react-router` ([#12177](https://github.com/remix-run/react-router/pull/12177))
126
+ - Examples: `LoaderFunction`, `LoaderFunctionArgs`, `ActionFunction`, `ActionFunctionArgs`, `DataFunctionArgs`, `RouteManifest`, `LinksFunction`, `Route`, `EntryRoute`
127
+ - The `RouteManifest` type used by the "remix" code is now slightly stricter because it is using the former `@remix-run/router` `RouteManifest`
128
+ - `Record<string, Route> -> Record<string, Route | undefined>`
129
+ - Removed `AppData` type in favor of inlining `unknown` in the few locations it was used
130
+ - Removed `ServerRuntimeMeta*` types in favor of the `Meta*` types they were duplicated from
131
+
132
+ - - Remove the `future.v7_partialHydration` flag ([#11725](https://github.com/remix-run/react-router/pull/11725))
133
+ - This also removes the `<RouterProvider fallbackElement>` prop
134
+ - To migrate, move the `fallbackElement` to a `hydrateFallbackElement`/`HydrateFallback` on your root route
135
+ - Also worth nothing there is a related breaking changer with this future flag:
136
+ - Without `future.v7_partialHydration` (when using `fallbackElement`), `state.navigation` was populated during the initial load
137
+ - With `future.v7_partialHydration`, `state.navigation` remains in an `"idle"` state during the initial load
138
+
139
+ - Remove `v7_relativeSplatPath` future flag ([#11695](https://github.com/remix-run/react-router/pull/11695))
140
+
141
+ - Drop support for Node 18, update minimum Node vestion to 20 ([#12171](https://github.com/remix-run/react-router/pull/12171))
142
+
143
+ - Remove `installGlobals()` as this should no longer be necessary
144
+
145
+ - Remove remaining future flags ([#11820](https://github.com/remix-run/react-router/pull/11820))
146
+
147
+ - React Router `v7_skipActionErrorRevalidation`
148
+ - Remix `v3_fetcherPersist`, `v3_relativeSplatPath`, `v3_throwAbortReason`
149
+
150
+ - rename createRemixStub to createRoutesStub ([#11692](https://github.com/remix-run/react-router/pull/11692))
151
+
152
+ - Remove `@remix-run/router` deprecated `detectErrorBoundary` option in favor of `mapRouteProperties` ([#11751](https://github.com/remix-run/react-router/pull/11751))
153
+
154
+ - 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))
155
+
156
+ - 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
157
+ - DOM environments should import from `react-router/dom` to get the proper component that makes `ReactDOM.flushSync()` available:
158
+ - If you are using the Vite plugin, use this in your `entry.client.tsx`:
159
+ - `import { HydratedRouter } from 'react-router/dom'`
160
+ - If you are not using the Vite plugin and are manually calling `createBrowserRouter`/`createHashRouter`:
161
+ - `import { RouterProvider } from "react-router/dom"`
162
+
163
+ - Remove `future.v7_fetcherPersist` flag ([#11731](https://github.com/remix-run/react-router/pull/11731))
164
+
165
+ - Update `cookie` dependency to `^1.0.1` - please see the [release notes](https://github.com/jshttp/cookie/releases) for any breaking changes ([#12172](https://github.com/remix-run/react-router/pull/12172))
166
+
167
+ ### Minor Changes
168
+
169
+ - - Add support for `prerender` config in the React Router vite plugin, to support existing SSG use-cases ([#11539](https://github.com/remix-run/react-router/pull/11539))
170
+ - You can use the `prerender` config to pre-render your `.html` and `.data` files at build time and then serve them statically at runtime (either from a running server or a CDN)
171
+ - `prerender` can either be an array of string paths, or a function (sync or async) that returns an array of strings so that you can dynamically generate the paths by talking to your CMS, etc.
172
+
173
+ ```ts
174
+ // react-router.config.ts
175
+ import type { Config } from "@react-router/dev/config";
176
+
177
+ export default {
178
+ async prerender() {
179
+ let slugs = await fakeGetSlugsFromCms();
180
+ // Prerender these paths into `.html` files at build time, and `.data`
181
+ // files if they have loaders
182
+ return ["/", "/about", ...slugs.map((slug) => `/product/${slug}`)];
183
+ },
184
+ } satisfies Config;
185
+
186
+ async function fakeGetSlugsFromCms() {
187
+ await new Promise((r) => setTimeout(r, 1000));
188
+ return ["shirt", "hat"];
189
+ }
190
+ ```
191
+
192
+ - Params, loader data, and action data as props for route component exports ([#11961](https://github.com/remix-run/react-router/pull/11961))
193
+
194
+ ```tsx
195
+ export default function Component({ params, loaderData, actionData }) {}
196
+
197
+ export function HydrateFallback({ params }) {}
198
+ export function ErrorBoundary({ params, loaderData, actionData }) {}
199
+ ```
200
+
201
+ - Remove duplicate `RouterProvider` impliementations ([#11679](https://github.com/remix-run/react-router/pull/11679))
202
+
203
+ - ### Typesafety improvements ([#12019](https://github.com/remix-run/react-router/pull/12019))
204
+
205
+ React Router now generates types for each of your route modules.
206
+ You can access those types by importing them from `./+types.<route filename without extension>`.
207
+ For example:
208
+
209
+ ```ts
210
+ // app/routes/product.tsx
211
+ import type * as Route from "./+types.product";
212
+
213
+ export function loader({ params }: Route.LoaderArgs) {}
214
+
215
+ export default function Component({ loaderData }: Route.ComponentProps) {}
216
+ ```
217
+
218
+ This initial implementation targets type inference for:
219
+
220
+ - `Params` : Path parameters from your routing config in `routes.ts` including file-based routing
221
+ - `LoaderData` : Loader data from `loader` and/or `clientLoader` within your route module
222
+ - `ActionData` : Action data from `action` and/or `clientAction` within your route module
223
+
224
+ In the future, we plan to add types for the rest of the route module exports: `meta`, `links`, `headers`, `shouldRevalidate`, etc.
225
+ We also plan to generate types for typesafe `Link`s:
226
+
227
+ ```tsx
228
+ <Link to="/products/:id" params={{ id: 1 }} />
229
+ // ^^^^^^^^^^^^^ ^^^^^^^^^
230
+ // typesafe `to` and `params` based on the available routes in your app
231
+ ```
232
+
233
+ Check out our docs for more:
234
+
235
+ - [_Explanations > Type Safety_](https://reactrouter.com/dev/guides/explanation/type-safety)
236
+ - [_How-To > Setting up type safety_](https://reactrouter.com/dev/guides/how-to/setting-up-type-safety)
237
+
238
+ - Stabilize `unstable_dataStrategy` ([#11969](https://github.com/remix-run/react-router/pull/11969))
239
+
240
+ - Stabilize `unstable_patchRoutesOnNavigation` ([#11970](https://github.com/remix-run/react-router/pull/11970))
241
+
242
+ ### Patch Changes
243
+
244
+ - No changes ([`506329c4e`](https://github.com/remix-run/react-router/commit/506329c4e2e7aba9837cbfa44df6103b49423745))
245
+
246
+ - chore: re-enable development warnings through a `development` exports condition. ([#12269](https://github.com/remix-run/react-router/pull/12269))
247
+
248
+ - Remove unstable upload handler. ([#12015](https://github.com/remix-run/react-router/pull/12015))
249
+
250
+ - Remove unneeded dependency on @web3-storage/multipart-parser ([#12274](https://github.com/remix-run/react-router/pull/12274))
251
+
252
+ - Fix redirects returned from loaders/actions using `data()` ([#12021](https://github.com/remix-run/react-router/pull/12021))
253
+
254
+ - fix(react-router): (v7) fix static prerender of non-ascii characters ([#12161](https://github.com/remix-run/react-router/pull/12161))
255
+
256
+ - Replace `substr` with `substring` ([#12080](https://github.com/remix-run/react-router/pull/12080))
257
+
258
+ - Remove the deprecated `json` utility ([#12146](https://github.com/remix-run/react-router/pull/12146))
259
+
260
+ - 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
261
+
262
+ - Remove unneeded dependency on source-map ([#12275](https://github.com/remix-run/react-router/pull/12275))
8
263
 
9
264
  ## 6.28.0
10
265
 
11
266
  ### Minor Changes
12
267
 
13
- - Log deprecation warnings for v7 flags ([#11750](https://github.com/remix-run/react-router/pull/11750))
268
+ - - Log deprecation warnings for v7 flags ([#11750](https://github.com/remix-run/react-router/pull/11750))
14
269
  - Add deprecation warnings to `json`/`defer` in favor of returning raw objects
15
270
  - These methods will be removed in React Router v7
16
271
 
package/README.md CHANGED
@@ -1,16 +1,7 @@
1
- # React Router
1
+ `react-router` is the primary package in the React Router project.
2
2
 
3
- The `react-router` package is the heart of [React Router](https://github.com/remix-run/react-router) and provides all
4
- the core functionality for both
5
- [`react-router-dom`](https://github.com/remix-run/react-router/tree/main/packages/react-router-dom)
6
- and
7
- [`react-router-native`](https://github.com/remix-run/react-router/tree/main/packages/react-router-native).
3
+ ## Installation
8
4
 
9
- If you're using React Router, you should never `import` anything directly from
10
- the `react-router` package, but you should have everything you need in either
11
- `react-router-dom` or `react-router-native`. Both of those packages re-export
12
- everything from `react-router`.
13
-
14
- If you'd like to extend React Router and you know what you're doing, you should
15
- add `react-router` **as a peer dependency, not a regular dependency** in your
16
- package.
5
+ ```sh
6
+ npm i react-router
7
+ ```