react-router 6.27.0 → 7.0.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 +309 -11
- package/README.md +1 -14
- package/dist/dom-export.d.ts +3 -0
- package/dist/dom-export.mjs +205 -0
- package/dist/dom-export.mjs.map +1 -0
- package/dist/index.d.ts +74 -29
- package/dist/index.mjs +11543 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/components.d.ts +250 -35
- package/dist/lib/context.d.ts +18 -5
- package/dist/lib/dom/dom.d.ts +123 -0
- package/dist/lib/dom/global.d.ts +40 -0
- package/dist/lib/dom/lib.d.ts +940 -0
- package/dist/lib/dom/server.d.ts +41 -0
- package/dist/lib/dom/ssr/components.d.ts +123 -0
- package/dist/lib/dom/ssr/data.d.ts +7 -0
- package/dist/lib/dom/ssr/entry.d.ts +47 -0
- package/dist/lib/dom/ssr/errorBoundaries.d.ts +36 -0
- package/dist/lib/dom/ssr/errors.d.ts +2 -0
- package/dist/lib/dom/ssr/fallback.d.ts +2 -0
- package/dist/lib/dom/ssr/fog-of-war.d.ts +28 -0
- package/dist/lib/dom/ssr/invariant.d.ts +2 -0
- package/dist/lib/dom/ssr/links.d.ts +25 -0
- package/dist/lib/dom/ssr/markup.d.ts +5 -0
- package/dist/lib/dom/ssr/routeModules.d.ts +141 -0
- package/dist/lib/dom/ssr/routes-test-stub.d.ts +59 -0
- package/dist/lib/dom/ssr/routes.d.ts +32 -0
- package/dist/lib/dom/ssr/server.d.ts +16 -0
- package/dist/lib/dom/ssr/single-fetch.d.ts +37 -0
- package/dist/lib/dom-export/dom-router-provider.d.ts +5 -0
- package/dist/lib/dom-export/hydrated-router.d.ts +5 -0
- package/dist/lib/dom-export.d.ts +3 -0
- package/dist/lib/hooks.d.ts +286 -57
- package/dist/lib/router/history.d.ts +253 -0
- package/dist/lib/router/links.d.ts +104 -0
- package/dist/lib/router/router.d.ts +540 -0
- package/dist/lib/router/utils.d.ts +505 -0
- package/dist/lib/server-runtime/build.d.ts +38 -0
- package/dist/lib/server-runtime/cookies.d.ts +62 -0
- package/dist/lib/server-runtime/crypto.d.ts +2 -0
- package/dist/lib/server-runtime/data.d.ts +15 -0
- package/dist/lib/server-runtime/dev.d.ts +8 -0
- package/dist/lib/server-runtime/entry.d.ts +3 -0
- package/dist/lib/server-runtime/errors.d.ts +51 -0
- package/dist/lib/server-runtime/headers.d.ts +3 -0
- package/dist/lib/server-runtime/invariant.d.ts +2 -0
- package/dist/lib/server-runtime/jsonify.d.ts +33 -0
- package/dist/lib/server-runtime/markup.d.ts +1 -0
- package/dist/lib/server-runtime/mode.d.ts +9 -0
- package/dist/lib/server-runtime/responses.d.ts +37 -0
- package/dist/lib/server-runtime/routeMatching.d.ts +8 -0
- package/dist/lib/server-runtime/routeModules.d.ts +212 -0
- package/dist/lib/server-runtime/routes.d.ts +31 -0
- package/dist/lib/server-runtime/server.d.ts +5 -0
- package/dist/lib/server-runtime/serverHandoff.d.ts +11 -0
- package/dist/lib/server-runtime/sessions/cookieStorage.d.ts +19 -0
- package/dist/lib/server-runtime/sessions/memoryStorage.d.ts +17 -0
- package/dist/lib/server-runtime/sessions.d.ts +140 -0
- package/dist/lib/server-runtime/single-fetch.d.ts +30 -0
- package/dist/lib/server-runtime/typecheck.d.ts +4 -0
- package/dist/lib/server-runtime/warnings.d.ts +1 -0
- package/dist/lib/types.d.ts +76 -0
- package/dist/lib/types.mjs +10 -0
- package/dist/main-dom-export.js +19 -0
- package/dist/main.js +1 -1
- package/dist/react-router-dom.development.js +199 -0
- package/dist/react-router-dom.development.js.map +1 -0
- package/dist/react-router-dom.production.min.js +12 -0
- package/dist/react-router-dom.production.min.js.map +1 -0
- package/dist/react-router.development.js +12281 -1141
- package/dist/react-router.development.js.map +1 -1
- package/dist/react-router.production.min.js +2 -2
- package/dist/react-router.production.min.js.map +1 -1
- package/dist/umd/react-router-dom.development.js +241 -0
- package/dist/umd/react-router-dom.development.js.map +1 -0
- package/dist/umd/react-router-dom.production.min.js +12 -0
- package/dist/umd/react-router-dom.production.min.js.map +1 -0
- package/dist/umd/react-router.development.js +12467 -1238
- package/dist/umd/react-router.development.js.map +1 -1
- package/dist/umd/react-router.production.min.js +2 -2
- package/dist/umd/react-router.production.min.js.map +1 -1
- package/package.json +35 -6
- package/dist/index.js +0 -1467
- package/dist/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,23 +1,321 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 7.0.0-pre.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix typegen for routes with a client loader but no server loader ([#12117](https://github.com/remix-run/react-router/pull/12117))
|
|
8
|
+
- - Fix `react-router-serve` handling of prerendered HTML files by removing the `redirect: false` option so it now falls back on the default `redirect: true` behavior of redirecting from `/folder` -> `/folder/` which will then pick up `/folder/index.html` from disk. See https://expressjs.com/en/resources/middleware/serve-static.html ([#12071](https://github.com/remix-run/react-router/pull/12071))
|
|
9
|
+
- Proxy prerendered loader data into prerender pass for HTML files to avoid double-invocations of the loader at build time
|
|
10
|
+
- Updated dependencies:
|
|
11
|
+
- `react-router@7.0.0-pre.1`
|
|
12
|
+
|
|
13
|
+
## 7.0.0-pre.0
|
|
14
|
+
|
|
15
|
+
### Major Changes
|
|
16
|
+
|
|
17
|
+
- 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))
|
|
18
|
+
|
|
19
|
+
- `defer`
|
|
20
|
+
- `AbortedDeferredError`
|
|
21
|
+
- `type TypedDeferredData`
|
|
22
|
+
- `UNSAFE_DeferredData`
|
|
23
|
+
- `UNSAFE_DEFERRED_SYMBOL`,
|
|
24
|
+
|
|
25
|
+
- - Collapse `@remix-run/router` into `react-router` ([#11505](https://github.com/remix-run/react-router/pull/11505))
|
|
26
|
+
- Collapse `react-router-dom` into `react-router`
|
|
27
|
+
- Collapse `@remix-run/server-runtime` into `react-router`
|
|
28
|
+
- Collapse `@remix-run/testing` into `react-router`
|
|
29
|
+
- Remove single_fetch future flag. ([#11522](https://github.com/remix-run/react-router/pull/11522))
|
|
30
|
+
- Drop support for Node 16, React Router SSR now requires Node 18 or higher ([#11391](https://github.com/remix-run/react-router/pull/11391))
|
|
31
|
+
- Remove `future.v7_startTransition` flag ([#11696](https://github.com/remix-run/react-router/pull/11696))
|
|
32
|
+
- - 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))
|
|
33
|
+
- `useNavigate()`
|
|
34
|
+
- `useSubmit`
|
|
35
|
+
- `useFetcher().load`
|
|
36
|
+
- `useFetcher().submit`
|
|
37
|
+
- `useRevalidator.revalidate`
|
|
38
|
+
- Remove `future.v7_normalizeFormMethod` future flag ([#11697](https://github.com/remix-run/react-router/pull/11697))
|
|
39
|
+
- 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))
|
|
40
|
+
|
|
41
|
+
- `createCookie`
|
|
42
|
+
- `createCookieSessionStorage`
|
|
43
|
+
- `createMemorySessionStorage`
|
|
44
|
+
- `createSessionStorage`
|
|
45
|
+
|
|
46
|
+
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)
|
|
47
|
+
|
|
48
|
+
Since platform-specific packages no longer need to implement this API, the following low-level APIs have been removed:
|
|
49
|
+
|
|
50
|
+
- `createCookieFactory`
|
|
51
|
+
- `createSessionStorageFactory`
|
|
52
|
+
- `createCookieSessionStorageFactory`
|
|
53
|
+
- `createMemorySessionStorageFactory`
|
|
54
|
+
|
|
55
|
+
- Imports/Exports cleanup ([#11840](https://github.com/remix-run/react-router/pull/11840))
|
|
56
|
+
|
|
57
|
+
- Removed the following exports that were previously public API from `@remix-run/router`
|
|
58
|
+
- types
|
|
59
|
+
- `AgnosticDataIndexRouteObject`
|
|
60
|
+
- `AgnosticDataNonIndexRouteObject`
|
|
61
|
+
- `AgnosticDataRouteMatch`
|
|
62
|
+
- `AgnosticDataRouteObject`
|
|
63
|
+
- `AgnosticIndexRouteObject`
|
|
64
|
+
- `AgnosticNonIndexRouteObject`
|
|
65
|
+
- `AgnosticRouteMatch`
|
|
66
|
+
- `AgnosticRouteObject`
|
|
67
|
+
- `TrackedPromise`
|
|
68
|
+
- `unstable_AgnosticPatchRoutesOnMissFunction`
|
|
69
|
+
- `Action` -> exported as `NavigationType` via `react-router`
|
|
70
|
+
- `Router` exported as `DataRouter` to differentiate from RR's `<Router>`
|
|
71
|
+
- API
|
|
72
|
+
- `getToPathname` (`@private`)
|
|
73
|
+
- `joinPaths` (`@private`)
|
|
74
|
+
- `normalizePathname` (`@private`)
|
|
75
|
+
- `resolveTo` (`@private`)
|
|
76
|
+
- `stripBasename` (`@private`)
|
|
77
|
+
- `createBrowserHistory` -> in favor of `createBrowserRouter`
|
|
78
|
+
- `createHashHistory` -> in favor of `createHashRouter`
|
|
79
|
+
- `createMemoryHistory` -> in favor of `createMemoryRouter`
|
|
80
|
+
- `createRouter`
|
|
81
|
+
- `createStaticHandler` -> in favor of wrapper `createStaticHandler` in RR Dom
|
|
82
|
+
- `getStaticContextFromError`
|
|
83
|
+
- Removed the following exports that were previously public API from `react-router`
|
|
84
|
+
- `Hash`
|
|
85
|
+
- `Pathname`
|
|
86
|
+
- `Search`
|
|
87
|
+
|
|
88
|
+
- update minimum node version to 18 ([#11690](https://github.com/remix-run/react-router/pull/11690))
|
|
89
|
+
- Remove `future.v7_prependBasename` from the ionternalized `@remix-run/router` package ([#11726](https://github.com/remix-run/react-router/pull/11726))
|
|
90
|
+
- Remove `future.v7_throwAbortReason` from internalized `@remix-run/router` package ([#11728](https://github.com/remix-run/react-router/pull/11728))
|
|
91
|
+
- Add `exports` field to all packages ([#11675](https://github.com/remix-run/react-router/pull/11675))
|
|
92
|
+
- node package no longer re-exports from react-router ([#11702](https://github.com/remix-run/react-router/pull/11702))
|
|
93
|
+
- renamed RemixContext to FrameworkContext ([#11705](https://github.com/remix-run/react-router/pull/11705))
|
|
94
|
+
- updates the minimum React version to 18 ([#11689](https://github.com/remix-run/react-router/pull/11689))
|
|
95
|
+
- PrefetchPageDescriptor replaced by PageLinkDescriptor ([#11960](https://github.com/remix-run/react-router/pull/11960))
|
|
96
|
+
- - Remove the `future.v7_partialHydration` flag ([#11725](https://github.com/remix-run/react-router/pull/11725))
|
|
97
|
+
- This also removes the `<RouterProvider fallbackElement>` prop
|
|
98
|
+
- To migrate, move the `fallbackElement` to a `hydrateFallbackElement`/`HydrateFallback` on your root route
|
|
99
|
+
- Also worth nothing there is a related breaking changer with this future flag:
|
|
100
|
+
- Without `future.v7_partialHydration` (when using `fallbackElement`), `state.navigation` was populated during the initial load
|
|
101
|
+
- With `future.v7_partialHydration`, `state.navigation` remains in an `"idle"` state during the initial load
|
|
102
|
+
- Remove `v7_relativeSplatPath` future flag ([#11695](https://github.com/remix-run/react-router/pull/11695))
|
|
103
|
+
- Remove remaining future flags ([#11820](https://github.com/remix-run/react-router/pull/11820))
|
|
104
|
+
|
|
105
|
+
- React Router `v7_skipActionErrorRevalidation`
|
|
106
|
+
- Remix `v3_fetcherPersist`, `v3_relativeSplatPath`, `v3_throwAbortReason`
|
|
107
|
+
|
|
108
|
+
- rename createRemixStub to createRoutesStub ([#11692](https://github.com/remix-run/react-router/pull/11692))
|
|
109
|
+
- Remove `@remix-run/router` deprecated `detectErrorBoundary` option in favor of `mapRouteProperties` ([#11751](https://github.com/remix-run/react-router/pull/11751))
|
|
110
|
+
- 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))
|
|
111
|
+
|
|
112
|
+
- 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
|
|
113
|
+
- DOM environments should import from `react-router/dom` to get the proper component that makes `ReactDOM.flushSync()` available:
|
|
114
|
+
- If you are using the Vite plugin, use this in your `entry.client.tsx`:
|
|
115
|
+
- `import { HydratedRouter } from 'react-router/dom'`
|
|
116
|
+
- If you are not using the Vite plugin and are manually calling `createBrowserRouter`/`createHashRouter`:
|
|
117
|
+
- `import { RouterProvider } from "react-router/dom"`
|
|
118
|
+
|
|
119
|
+
- Remove `future.v7_fetcherPersist` flag ([#11731](https://github.com/remix-run/react-router/pull/11731))
|
|
4
120
|
|
|
5
121
|
### Minor Changes
|
|
6
122
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
123
|
+
- - 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))
|
|
124
|
+
- 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)
|
|
125
|
+
- `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.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
export default defineConfig({
|
|
129
|
+
plugins: [
|
|
130
|
+
reactRouter({
|
|
131
|
+
async prerender() {
|
|
132
|
+
let slugs = await fakeGetSlugsFromCms();
|
|
133
|
+
// Prerender these paths into `.html` files at build time, and `.data`
|
|
134
|
+
// files if they have loaders
|
|
135
|
+
return ["/", "/about", ...slugs.map((slug) => `/product/${slug}`)];
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
tsconfigPaths(),
|
|
139
|
+
],
|
|
140
|
+
});
|
|
12
141
|
|
|
13
|
-
|
|
142
|
+
async function fakeGetSlugsFromCms() {
|
|
143
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
144
|
+
return ["shirt", "hat"];
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- [REMOVE] Allow returning undefined from loaders/actions part 2 ([#12057](https://github.com/remix-run/react-router/pull/12057))
|
|
149
|
+
|
|
150
|
+
- This is a follow up to #11680 which missed some of the Remix codepaths
|
|
151
|
+
|
|
152
|
+
- Params, loader data, and action data as props for route component exports ([#11961](https://github.com/remix-run/react-router/pull/11961))
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
export default function Component({ params, loaderData, actionData }) {}
|
|
156
|
+
|
|
157
|
+
export function HydrateFallback({ params }) {}
|
|
158
|
+
export function ErrorBoundary({ params, loaderData, actionData }) {}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
- Remove duplicate `RouterProvider` impliementations ([#11679](https://github.com/remix-run/react-router/pull/11679))
|
|
162
|
+
- ### Typesafety improvements ([#12019](https://github.com/remix-run/react-router/pull/12019))
|
|
163
|
+
|
|
164
|
+
React Router now generates types for each of your route modules.
|
|
165
|
+
You can access those types by importing them from `./+types.<route filename without extension>`.
|
|
166
|
+
For example:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
// app/routes/product.tsx
|
|
170
|
+
import type * as Route from "./+types.product";
|
|
171
|
+
|
|
172
|
+
export function loader({ params }: Route.LoaderArgs) {}
|
|
173
|
+
|
|
174
|
+
export default function Component({ loaderData }: Route.ComponentProps) {}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
This initial implementation targets type inference for:
|
|
178
|
+
|
|
179
|
+
- `Params` : Path parameters from your routing config in `routes.ts` including file-based routing
|
|
180
|
+
- `LoaderData` : Loader data from `loader` and/or `clientLoader` within your route module
|
|
181
|
+
- `ActionData` : Action data from `action` and/or `clientAction` within your route module
|
|
182
|
+
|
|
183
|
+
These types are then used to create types for route export args and props:
|
|
184
|
+
|
|
185
|
+
- `LoaderArgs`
|
|
186
|
+
- `ClientLoaderArgs`
|
|
187
|
+
- `ActionArgs`
|
|
188
|
+
- `ClientActionArgs`
|
|
189
|
+
- `HydrateFallbackProps`
|
|
190
|
+
- `ComponentProps` (for the `default` export)
|
|
191
|
+
- `ErrorBoundaryProps`
|
|
192
|
+
|
|
193
|
+
In the future, we plan to add types for the rest of the route module exports: `meta`, `links`, `headers`, `shouldRevalidate`, etc.
|
|
194
|
+
We also plan to generate types for typesafe `Link`s:
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
<Link to="/products/:id" params={{ id: 1 }} />
|
|
198
|
+
// ^^^^^^^^^^^^^ ^^^^^^^^^
|
|
199
|
+
// typesafe `to` and `params` based on the available routes in your app
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### Setup
|
|
203
|
+
|
|
204
|
+
React Router will generate types into a `.react-router/` directory at the root of your app.
|
|
205
|
+
This directory is fully managed by React Router and is derived based on your route config (`routes.ts`).
|
|
206
|
+
|
|
207
|
+
👉 **Add `.react-router/` to `.gitignore`**
|
|
208
|
+
|
|
209
|
+
```txt
|
|
210
|
+
.react-router
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
You should also ensure that generated types for routes are always present before running typechecking,
|
|
214
|
+
especially for running typechecking in CI.
|
|
215
|
+
|
|
216
|
+
👉 **Add `react-router typegen` to your `typecheck` command in `package.json`**
|
|
14
217
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"scripts": {
|
|
221
|
+
"typecheck": "react-router typegen && tsc"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
To get TypeScript to use those generated types, you'll need to add them to `include` in `tsconfig.json`.
|
|
227
|
+
And to be able to import them as if they files next to your route modules, you'll also need to configure `rootDirs`.
|
|
228
|
+
|
|
229
|
+
👉 **Configure `tsconfig.json` for generated types**
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"include": [".react-router/types/**/*"],
|
|
234
|
+
"compilerOptions": {
|
|
235
|
+
"rootDirs": [".", "./.react-router/types"]
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
#### `typegen` command
|
|
241
|
+
|
|
242
|
+
You can manually generate types with the new `typegen` command:
|
|
243
|
+
|
|
244
|
+
```sh
|
|
245
|
+
react-router typegen
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
However, manual type generation is tedious and types can get out of sync quickly if you ever forget to run `typegen`.
|
|
249
|
+
Instead, we recommend that you setup our new TypeScript plugin which will automatically generate fresh types whenever routes change.
|
|
250
|
+
That way, you'll always have up-to-date types.
|
|
251
|
+
|
|
252
|
+
#### TypeScript plugin
|
|
253
|
+
|
|
254
|
+
To get automatic type generation, you can use our new TypeScript plugin.
|
|
255
|
+
|
|
256
|
+
👉 **Add the TypeScript plugin to `tsconfig.json`**
|
|
257
|
+
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
"compilerOptions": {
|
|
261
|
+
"plugins": [{ "name": "@react-router/dev" }]
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
We plan to add some other goodies to our TypeScript plugin soon, including:
|
|
267
|
+
|
|
268
|
+
- Automatic `jsdoc` for route exports that include links to official docs
|
|
269
|
+
- Autocomplete for route exports
|
|
270
|
+
- Warnings for non-HMR compliant exports
|
|
271
|
+
|
|
272
|
+
##### VSCode
|
|
273
|
+
|
|
274
|
+
TypeScript looks for plugins registered in `tsconfig.json` in the local `node_modules/`,
|
|
275
|
+
but VSCode ships with its own copy of TypeScript that is installed outside of your project.
|
|
276
|
+
For TypeScript plugins to work, you'll need to tell VSCode to use the local workspace version of TypeScript.
|
|
277
|
+
For security reasons, [VSCode won't use the workspace version of TypeScript](https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript) until you manually opt-in.
|
|
278
|
+
|
|
279
|
+
Your project should have a `.vscode/settings.json` with the following settings:
|
|
280
|
+
|
|
281
|
+
```json
|
|
282
|
+
{
|
|
283
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
284
|
+
"typescript.enablePromptUseWorkspaceTsdk": true
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
That way [VSCode will ask you](https://code.visualstudio.com/updates/v1_45#_prompt-users-to-switch-to-the-workspace-version-of-typescript) if you want to use the workspace version of TypeScript the first time you open a TS file in that project.
|
|
289
|
+
|
|
290
|
+
> [!IMPORTANT]
|
|
291
|
+
> You'll need to install dependencies first so that the workspace version of TypeScript is available.
|
|
292
|
+
|
|
293
|
+
👉 **Select "Allow" when VSCode asks if you want to use the workspace version of TypeScript**
|
|
294
|
+
|
|
295
|
+
Otherwise, you can also manually opt-in to the workspace version:
|
|
296
|
+
|
|
297
|
+
1. Open up any TypeScript file in your project
|
|
298
|
+
2. Open up the VSCode Command Palette (<kbd>Cmd</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>)
|
|
299
|
+
3. Search for `Select TypeScript Version`
|
|
300
|
+
4. Choose `Use Workspace Version`
|
|
301
|
+
5. Quit and reopen VSCode
|
|
302
|
+
|
|
303
|
+
##### Troubleshooting
|
|
304
|
+
|
|
305
|
+
In VSCode, open up any TypeScript file in your project and then use <kbd>CMD</kbd>+<kbd>SHIFT</kbd>+<kbd>P</kbd> to select `Open TS Server log`.
|
|
306
|
+
There should be a log for `[react-router] setup` that indicates that the plugin was resolved correctly.
|
|
307
|
+
Then look for any errors in the log.
|
|
308
|
+
|
|
309
|
+
- Stabilize `unstable_dataStrategy` ([#11969](https://github.com/remix-run/react-router/pull/11969))
|
|
310
|
+
- Stabilize `unstable_patchRoutesOnNavigation` ([#11970](https://github.com/remix-run/react-router/pull/11970))
|
|
311
|
+
|
|
312
|
+
### Patch Changes
|
|
18
313
|
|
|
314
|
+
- Remove unstable upload handler. ([#12015](https://github.com/remix-run/react-router/pull/12015))
|
|
315
|
+
- Fix redirects returned from loaders/actions using `data()` ([#12021](https://github.com/remix-run/react-router/pull/12021))
|
|
316
|
+
- [REMOVE] Rename RemixRouter->DataRouter ([#12062](https://github.com/remix-run/react-router/pull/12062))
|
|
19
317
|
- Updated dependencies:
|
|
20
|
-
-
|
|
318
|
+
- `react-router@7.0.0-pre.0`
|
|
21
319
|
|
|
22
320
|
## 6.26.2
|
|
23
321
|
|
package/README.md
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
1
|
# React Router
|
|
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).
|
|
8
|
-
|
|
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.
|
|
3
|
+
The `react-router` package is the heart of [React Router](https://github.com/remix-run/react-router) and provides all the core functionality.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Router v7.0.0-pre.1
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import * as ReactDOM from 'react-dom';
|
|
13
|
+
import { UNSAFE_invariant, UNSAFE_useFogOFWarDiscovery, UNSAFE_FrameworkContext, UNSAFE_RemixErrorBoundary, UNSAFE_decodeViaTurboStream, UNSAFE_createClientRoutes, matchRoutes, UNSAFE_shouldHydrateRouteLoader, UNSAFE_deserializeErrors, UNSAFE_createRouter, UNSAFE_createBrowserHistory, UNSAFE_mapRouteProperties, UNSAFE_getSingleFetchDataStrategy, UNSAFE_getPatchRoutesOnNavigationFunction, UNSAFE_createClientRoutesWithHMRRevalidationOptOut, RouterProvider as RouterProvider$1 } from 'react-router';
|
|
14
|
+
|
|
15
|
+
function _extends() {
|
|
16
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
+
var source = arguments[i];
|
|
19
|
+
for (var key in source) {
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
21
|
+
target[key] = source[key];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return target;
|
|
26
|
+
};
|
|
27
|
+
return _extends.apply(this, arguments);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let ssrInfo = null;
|
|
31
|
+
let router = null;
|
|
32
|
+
function initSsrInfo() {
|
|
33
|
+
if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
|
|
34
|
+
ssrInfo = {
|
|
35
|
+
context: window.__reactRouterContext,
|
|
36
|
+
manifest: window.__reactRouterManifest,
|
|
37
|
+
routeModules: window.__reactRouterRouteModules,
|
|
38
|
+
stateDecodingPromise: undefined,
|
|
39
|
+
router: undefined,
|
|
40
|
+
routerInitialized: false
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function createHydratedRouter() {
|
|
45
|
+
initSsrInfo();
|
|
46
|
+
if (!ssrInfo) {
|
|
47
|
+
throw new Error("You must be using the SSR features of React Router in order to skip " + "passing a `router` prop to `<RouterProvider>`");
|
|
48
|
+
}
|
|
49
|
+
// We need to suspend until the initial state snapshot is decoded into
|
|
50
|
+
// window.__reactRouterContext.state
|
|
51
|
+
let localSsrInfo = ssrInfo;
|
|
52
|
+
// Note: `stateDecodingPromise` is not coupled to `router` - we'll reach this
|
|
53
|
+
// code potentially many times waiting for our state to arrive, but we'll
|
|
54
|
+
// then only get past here and create the `router` one time
|
|
55
|
+
if (!ssrInfo.stateDecodingPromise) {
|
|
56
|
+
let stream = ssrInfo.context.stream;
|
|
57
|
+
!stream ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "No stream found for single fetch decoding") : UNSAFE_invariant(false) : void 0;
|
|
58
|
+
ssrInfo.context.stream = undefined;
|
|
59
|
+
ssrInfo.stateDecodingPromise = UNSAFE_decodeViaTurboStream(stream, window).then(value => {
|
|
60
|
+
ssrInfo.context.state = value.value;
|
|
61
|
+
localSsrInfo.stateDecodingPromise.value = true;
|
|
62
|
+
}).catch(e => {
|
|
63
|
+
localSsrInfo.stateDecodingPromise.error = e;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (ssrInfo.stateDecodingPromise.error) {
|
|
67
|
+
throw ssrInfo.stateDecodingPromise.error;
|
|
68
|
+
}
|
|
69
|
+
if (!ssrInfo.stateDecodingPromise.value) {
|
|
70
|
+
throw ssrInfo.stateDecodingPromise;
|
|
71
|
+
}
|
|
72
|
+
let routes = UNSAFE_createClientRoutes(ssrInfo.manifest.routes, ssrInfo.routeModules, ssrInfo.context.state, ssrInfo.context.isSpaMode);
|
|
73
|
+
let hydrationData = undefined;
|
|
74
|
+
if (!ssrInfo.context.isSpaMode) {
|
|
75
|
+
var _window$__reactRouter;
|
|
76
|
+
// Create a shallow clone of `loaderData` we can mutate for partial hydration.
|
|
77
|
+
// When a route exports a `clientLoader` and a `HydrateFallback`, the SSR will
|
|
78
|
+
// render the fallback so we need the client to do the same for hydration.
|
|
79
|
+
// The server loader data has already been exposed to these route `clientLoader`'s
|
|
80
|
+
// in `createClientRoutes` above, so we need to clear out the version we pass to
|
|
81
|
+
// `createBrowserRouter` so it initializes and runs the client loaders.
|
|
82
|
+
hydrationData = _extends({}, ssrInfo.context.state, {
|
|
83
|
+
loaderData: _extends({}, ssrInfo.context.state.loaderData)
|
|
84
|
+
});
|
|
85
|
+
let initialMatches = matchRoutes(routes, window.location, (_window$__reactRouter = window.__reactRouterContext) == null ? void 0 : _window$__reactRouter.basename);
|
|
86
|
+
if (initialMatches) {
|
|
87
|
+
for (let match of initialMatches) {
|
|
88
|
+
let routeId = match.route.id;
|
|
89
|
+
let route = ssrInfo.routeModules[routeId];
|
|
90
|
+
let manifestRoute = ssrInfo.manifest.routes[routeId];
|
|
91
|
+
// Clear out the loaderData to avoid rendering the route component when the
|
|
92
|
+
// route opted into clientLoader hydration and either:
|
|
93
|
+
// * gave us a HydrateFallback
|
|
94
|
+
// * or doesn't have a server loader and we have no data to render
|
|
95
|
+
if (route && UNSAFE_shouldHydrateRouteLoader(manifestRoute, route, ssrInfo.context.isSpaMode) && (route.HydrateFallback || !manifestRoute.hasLoader)) {
|
|
96
|
+
delete hydrationData.loaderData[routeId];
|
|
97
|
+
} else if (manifestRoute && !manifestRoute.hasLoader) {
|
|
98
|
+
// Since every Remix route gets a `loader` on the client side to load
|
|
99
|
+
// the route JS module, we need to add a `null` value to `loaderData`
|
|
100
|
+
// for any routes that don't have server loaders so our partial
|
|
101
|
+
// hydration logic doesn't kick off the route module loaders during
|
|
102
|
+
// hydration
|
|
103
|
+
hydrationData.loaderData[routeId] = null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (hydrationData && hydrationData.errors) {
|
|
108
|
+
// TODO: De-dup this or remove entirely in v7 where single fetch is the
|
|
109
|
+
// only approach and we have already serialized or deserialized on the server
|
|
110
|
+
hydrationData.errors = UNSAFE_deserializeErrors(hydrationData.errors);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// We don't use createBrowserRouter here because we need fine-grained control
|
|
114
|
+
// over initialization to support synchronous `clientLoader` flows.
|
|
115
|
+
let router = UNSAFE_createRouter({
|
|
116
|
+
routes,
|
|
117
|
+
history: UNSAFE_createBrowserHistory(),
|
|
118
|
+
basename: ssrInfo.context.basename,
|
|
119
|
+
hydrationData,
|
|
120
|
+
mapRouteProperties: UNSAFE_mapRouteProperties,
|
|
121
|
+
dataStrategy: UNSAFE_getSingleFetchDataStrategy(ssrInfo.manifest, ssrInfo.routeModules, () => router),
|
|
122
|
+
patchRoutesOnNavigation: UNSAFE_getPatchRoutesOnNavigationFunction(ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.isSpaMode, ssrInfo.context.basename)
|
|
123
|
+
});
|
|
124
|
+
ssrInfo.router = router;
|
|
125
|
+
// We can call initialize() immediately if the router doesn't have any
|
|
126
|
+
// loaders to run on hydration
|
|
127
|
+
if (router.state.initialized) {
|
|
128
|
+
ssrInfo.routerInitialized = true;
|
|
129
|
+
router.initialize();
|
|
130
|
+
}
|
|
131
|
+
// @ts-ignore
|
|
132
|
+
router.createRoutesForHMR = /* spacer so ts-ignore does not affect the right hand of the assignment */
|
|
133
|
+
UNSAFE_createClientRoutesWithHMRRevalidationOptOut;
|
|
134
|
+
window.__reactRouterDataRouter = router;
|
|
135
|
+
return router;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* @category Router Components
|
|
139
|
+
*/
|
|
140
|
+
function HydratedRouter() {
|
|
141
|
+
var _ssrInfo;
|
|
142
|
+
if (!router) {
|
|
143
|
+
router = createHydratedRouter();
|
|
144
|
+
}
|
|
145
|
+
// Critical CSS can become stale after code changes, e.g. styles might be
|
|
146
|
+
// removed from a component, but the styles will still be present in the
|
|
147
|
+
// server HTML. This allows our HMR logic to clear the critical CSS state.
|
|
148
|
+
let [criticalCss, setCriticalCss] = React.useState(process.env.NODE_ENV === "development" ? (_ssrInfo = ssrInfo) == null ? void 0 : _ssrInfo.context.criticalCss : undefined);
|
|
149
|
+
if (process.env.NODE_ENV === "development") {
|
|
150
|
+
if (ssrInfo) {
|
|
151
|
+
window.__reactRouterClearCriticalCss = () => setCriticalCss(undefined);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
let [location, setLocation] = React.useState(router.state.location);
|
|
155
|
+
React.useLayoutEffect(() => {
|
|
156
|
+
// If we had to run clientLoaders on hydration, we delay initialization until
|
|
157
|
+
// after we've hydrated to avoid hydration issues from synchronous client loaders
|
|
158
|
+
if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
|
|
159
|
+
ssrInfo.routerInitialized = true;
|
|
160
|
+
ssrInfo.router.initialize();
|
|
161
|
+
}
|
|
162
|
+
}, []);
|
|
163
|
+
React.useLayoutEffect(() => {
|
|
164
|
+
if (ssrInfo && ssrInfo.router) {
|
|
165
|
+
return ssrInfo.router.subscribe(newState => {
|
|
166
|
+
if (newState.location !== location) {
|
|
167
|
+
setLocation(newState.location);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}, [location]);
|
|
172
|
+
!ssrInfo ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "ssrInfo unavailable for HydratedRouter") : UNSAFE_invariant(false) : void 0;
|
|
173
|
+
UNSAFE_useFogOFWarDiscovery(router, ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.isSpaMode);
|
|
174
|
+
// We need to include a wrapper RemixErrorBoundary here in case the root error
|
|
175
|
+
// boundary also throws and we need to bubble up outside of the router entirely.
|
|
176
|
+
// Then we need a stateful location here so the user can back-button navigate
|
|
177
|
+
// out of there
|
|
178
|
+
return (
|
|
179
|
+
/*#__PURE__*/
|
|
180
|
+
// This fragment is important to ensure we match the <ServerRouter> JSX
|
|
181
|
+
// structure so that useId values hydrate correctly
|
|
182
|
+
React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(UNSAFE_FrameworkContext.Provider, {
|
|
183
|
+
value: {
|
|
184
|
+
manifest: ssrInfo.manifest,
|
|
185
|
+
routeModules: ssrInfo.routeModules,
|
|
186
|
+
future: ssrInfo.context.future,
|
|
187
|
+
criticalCss,
|
|
188
|
+
isSpaMode: ssrInfo.context.isSpaMode
|
|
189
|
+
}
|
|
190
|
+
}, /*#__PURE__*/React.createElement(UNSAFE_RemixErrorBoundary, {
|
|
191
|
+
location: location
|
|
192
|
+
}, /*#__PURE__*/React.createElement(RouterProvider, {
|
|
193
|
+
router: router
|
|
194
|
+
}))), /*#__PURE__*/React.createElement(React.Fragment, null))
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function RouterProvider(props) {
|
|
199
|
+
return /*#__PURE__*/React.createElement(RouterProvider$1, _extends({
|
|
200
|
+
flushSync: ReactDOM.flushSync
|
|
201
|
+
}, props));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export { HydratedRouter, RouterProvider };
|
|
205
|
+
//# sourceMappingURL=dom-export.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom-export.mjs","sources":["../../lib/dom-export/hydrated-router.tsx","../../lib/dom-export/dom-router-provider.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport type {\n UNSAFE_AssetsManifest as AssetsManifest,\n UNSAFE_RouteModules as RouteModules,\n DataRouter,\n HydrationState,\n} from \"react-router\";\nimport {\n UNSAFE_invariant as invariant,\n UNSAFE_FrameworkContext as FrameworkContext,\n UNSAFE_decodeViaTurboStream as decodeViaTurboStream,\n UNSAFE_RemixErrorBoundary as RemixErrorBoundary,\n UNSAFE_createBrowserHistory as createBrowserHistory,\n UNSAFE_createClientRoutes as createClientRoutes,\n UNSAFE_createRouter as createRouter,\n UNSAFE_deserializeErrors as deserializeErrors,\n UNSAFE_getSingleFetchDataStrategy as getSingleFetchDataStrategy,\n UNSAFE_getPatchRoutesOnNavigationFunction as getPatchRoutesOnNavigationFunction,\n UNSAFE_shouldHydrateRouteLoader as shouldHydrateRouteLoader,\n UNSAFE_useFogOFWarDiscovery as useFogOFWarDiscovery,\n UNSAFE_mapRouteProperties as mapRouteProperties,\n UNSAFE_createClientRoutesWithHMRRevalidationOptOut as createClientRoutesWithHMRRevalidationOptOut,\n matchRoutes,\n} from \"react-router\";\nimport { RouterProvider } from \"./dom-router-provider\";\n\ntype SSRInfo = {\n context: NonNullable<(typeof window)[\"__reactRouterContext\"]>;\n routeModules: RouteModules;\n manifest: AssetsManifest;\n stateDecodingPromise:\n | (Promise<void> & {\n value?: unknown;\n error?: unknown;\n })\n | undefined;\n router: DataRouter | undefined;\n routerInitialized: boolean;\n};\n\nlet ssrInfo: SSRInfo | null = null;\nlet router: DataRouter | null = null;\n\nfunction initSsrInfo(): void {\n if (\n !ssrInfo &&\n window.__reactRouterContext &&\n window.__reactRouterManifest &&\n window.__reactRouterRouteModules\n ) {\n ssrInfo = {\n context: window.__reactRouterContext,\n manifest: window.__reactRouterManifest,\n routeModules: window.__reactRouterRouteModules,\n stateDecodingPromise: undefined,\n router: undefined,\n routerInitialized: false,\n };\n }\n}\n\nfunction createHydratedRouter(): DataRouter {\n initSsrInfo();\n\n if (!ssrInfo) {\n throw new Error(\n \"You must be using the SSR features of React Router in order to skip \" +\n \"passing a `router` prop to `<RouterProvider>`\"\n );\n }\n\n // We need to suspend until the initial state snapshot is decoded into\n // window.__reactRouterContext.state\n\n let localSsrInfo = ssrInfo;\n // Note: `stateDecodingPromise` is not coupled to `router` - we'll reach this\n // code potentially many times waiting for our state to arrive, but we'll\n // then only get past here and create the `router` one time\n if (!ssrInfo.stateDecodingPromise) {\n let stream = ssrInfo.context.stream;\n invariant(stream, \"No stream found for single fetch decoding\");\n ssrInfo.context.stream = undefined;\n ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window)\n .then((value) => {\n ssrInfo!.context.state =\n value.value as typeof localSsrInfo.context.state;\n localSsrInfo.stateDecodingPromise!.value = true;\n })\n .catch((e) => {\n localSsrInfo.stateDecodingPromise!.error = e;\n });\n }\n if (ssrInfo.stateDecodingPromise.error) {\n throw ssrInfo.stateDecodingPromise.error;\n }\n if (!ssrInfo.stateDecodingPromise.value) {\n throw ssrInfo.stateDecodingPromise;\n }\n\n let routes = createClientRoutes(\n ssrInfo.manifest.routes,\n ssrInfo.routeModules,\n ssrInfo.context.state,\n ssrInfo.context.isSpaMode\n );\n\n let hydrationData: HydrationState | undefined = undefined;\n if (!ssrInfo.context.isSpaMode) {\n // Create a shallow clone of `loaderData` we can mutate for partial hydration.\n // When a route exports a `clientLoader` and a `HydrateFallback`, the SSR will\n // render the fallback so we need the client to do the same for hydration.\n // The server loader data has already been exposed to these route `clientLoader`'s\n // in `createClientRoutes` above, so we need to clear out the version we pass to\n // `createBrowserRouter` so it initializes and runs the client loaders.\n hydrationData = {\n ...ssrInfo.context.state,\n loaderData: { ...ssrInfo.context.state.loaderData },\n };\n let initialMatches = matchRoutes(\n routes,\n window.location,\n window.__reactRouterContext?.basename\n );\n if (initialMatches) {\n for (let match of initialMatches) {\n let routeId = match.route.id;\n let route = ssrInfo.routeModules[routeId];\n let manifestRoute = ssrInfo.manifest.routes[routeId];\n // Clear out the loaderData to avoid rendering the route component when the\n // route opted into clientLoader hydration and either:\n // * gave us a HydrateFallback\n // * or doesn't have a server loader and we have no data to render\n if (\n route &&\n shouldHydrateRouteLoader(\n manifestRoute,\n route,\n ssrInfo.context.isSpaMode\n ) &&\n (route.HydrateFallback || !manifestRoute.hasLoader)\n ) {\n delete hydrationData.loaderData![routeId];\n } else if (manifestRoute && !manifestRoute.hasLoader) {\n // Since every Remix route gets a `loader` on the client side to load\n // the route JS module, we need to add a `null` value to `loaderData`\n // for any routes that don't have server loaders so our partial\n // hydration logic doesn't kick off the route module loaders during\n // hydration\n hydrationData.loaderData![routeId] = null;\n }\n }\n }\n\n if (hydrationData && hydrationData.errors) {\n // TODO: De-dup this or remove entirely in v7 where single fetch is the\n // only approach and we have already serialized or deserialized on the server\n hydrationData.errors = deserializeErrors(hydrationData.errors);\n }\n }\n\n // We don't use createBrowserRouter here because we need fine-grained control\n // over initialization to support synchronous `clientLoader` flows.\n let router = createRouter({\n routes,\n history: createBrowserHistory(),\n basename: ssrInfo.context.basename,\n hydrationData,\n mapRouteProperties,\n dataStrategy: getSingleFetchDataStrategy(\n ssrInfo.manifest,\n ssrInfo.routeModules,\n () => router\n ),\n patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(\n ssrInfo.manifest,\n ssrInfo.routeModules,\n ssrInfo.context.isSpaMode,\n ssrInfo.context.basename\n ),\n });\n ssrInfo.router = router;\n\n // We can call initialize() immediately if the router doesn't have any\n // loaders to run on hydration\n if (router.state.initialized) {\n ssrInfo.routerInitialized = true;\n router.initialize();\n }\n\n // @ts-ignore\n router.createRoutesForHMR =\n /* spacer so ts-ignore does not affect the right hand of the assignment */\n createClientRoutesWithHMRRevalidationOptOut;\n window.__reactRouterDataRouter = router;\n\n return router;\n}\n\n/**\n * @category Router Components\n */\nexport function HydratedRouter() {\n if (!router) {\n router = createHydratedRouter();\n }\n\n // Critical CSS can become stale after code changes, e.g. styles might be\n // removed from a component, but the styles will still be present in the\n // server HTML. This allows our HMR logic to clear the critical CSS state.\n let [criticalCss, setCriticalCss] = React.useState(\n process.env.NODE_ENV === \"development\"\n ? ssrInfo?.context.criticalCss\n : undefined\n );\n if (process.env.NODE_ENV === \"development\") {\n if (ssrInfo) {\n window.__reactRouterClearCriticalCss = () => setCriticalCss(undefined);\n }\n }\n\n let [location, setLocation] = React.useState(router.state.location);\n\n React.useLayoutEffect(() => {\n // If we had to run clientLoaders on hydration, we delay initialization until\n // after we've hydrated to avoid hydration issues from synchronous client loaders\n if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {\n ssrInfo.routerInitialized = true;\n ssrInfo.router.initialize();\n }\n }, []);\n\n React.useLayoutEffect(() => {\n if (ssrInfo && ssrInfo.router) {\n return ssrInfo.router.subscribe((newState) => {\n if (newState.location !== location) {\n setLocation(newState.location);\n }\n });\n }\n }, [location]);\n\n invariant(ssrInfo, \"ssrInfo unavailable for HydratedRouter\");\n\n useFogOFWarDiscovery(\n router,\n ssrInfo.manifest,\n ssrInfo.routeModules,\n ssrInfo.context.isSpaMode\n );\n\n // We need to include a wrapper RemixErrorBoundary here in case the root error\n // boundary also throws and we need to bubble up outside of the router entirely.\n // Then we need a stateful location here so the user can back-button navigate\n // out of there\n return (\n // This fragment is important to ensure we match the <ServerRouter> JSX\n // structure so that useId values hydrate correctly\n <>\n <FrameworkContext.Provider\n value={{\n manifest: ssrInfo.manifest,\n routeModules: ssrInfo.routeModules,\n future: ssrInfo.context.future,\n criticalCss,\n isSpaMode: ssrInfo.context.isSpaMode,\n }}\n >\n <RemixErrorBoundary location={location}>\n <RouterProvider router={router} />\n </RemixErrorBoundary>\n </FrameworkContext.Provider>\n {/*\n This fragment is important to ensure we match the <ServerRouter> JSX\n structure so that useId values hydrate correctly\n */}\n <></>\n </>\n );\n}\n","import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\n\nimport type { RouterProviderProps as BaseRouterProviderProps } from \"react-router\";\nimport { RouterProvider as BaseRouterProvider } from \"react-router\";\n\nexport { HydratedRouter } from \"./hydrated-router\";\n\nexport type RouterProviderProps = Omit<BaseRouterProviderProps, \"flushSync\">;\n\nexport function RouterProvider(props: Omit<RouterProviderProps, \"flushSync\">) {\n return <BaseRouterProvider flushSync={ReactDOM.flushSync} {...props} />;\n}\n"],"names":["ssrInfo","router","initSsrInfo","window","__reactRouterContext","__reactRouterManifest","__reactRouterRouteModules","context","manifest","routeModules","stateDecodingPromise","undefined","routerInitialized","createHydratedRouter","Error","localSsrInfo","stream","process","env","NODE_ENV","invariant","decodeViaTurboStream","then","value","state","catch","e","error","routes","createClientRoutes","isSpaMode","hydrationData","_window$__reactRouter","_extends","loaderData","initialMatches","matchRoutes","location","basename","match","routeId","route","id","manifestRoute","shouldHydrateRouteLoader","HydrateFallback","hasLoader","errors","deserializeErrors","createRouter","history","createBrowserHistory","mapRouteProperties","dataStrategy","getSingleFetchDataStrategy","patchRoutesOnNavigation","getPatchRoutesOnNavigationFunction","initialized","initialize","createRoutesForHMR","createClientRoutesWithHMRRevalidationOptOut","__reactRouterDataRouter","HydratedRouter","_ssrInfo","criticalCss","setCriticalCss","React","useState","__reactRouterClearCriticalCss","setLocation","useLayoutEffect","subscribe","newState","useFogOFWarDiscovery","createElement","Fragment","FrameworkContext","Provider","future","RemixErrorBoundary","RouterProvider","props","BaseRouterProvider","flushSync","ReactDOM"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAIA,OAAO,GAAmB,IAAI,CAAA;AAClC,IAAIC,MAAM,GAAsB,IAAI,CAAA;AAEpC,SAASC,WAAWA,GAAA;AAClB,EAAA,IACE,CAACF,OAAO,IACRG,MAAM,CAACC,oBAAoB,IAC3BD,MAAM,CAACE,qBAAqB,IAC5BF,MAAM,CAACG,yBAAyB,EAChC;AACAN,IAAAA,OAAO,GAAG;MACRO,OAAO,EAAEJ,MAAM,CAACC,oBAAoB;MACpCI,QAAQ,EAAEL,MAAM,CAACE,qBAAqB;MACtCI,YAAY,EAAEN,MAAM,CAACG,yBAAyB;AAC9CI,MAAAA,oBAAoB,EAAEC,SAAS;AAC/BV,MAAAA,MAAM,EAAEU,SAAS;AACjBC,MAAAA,iBAAiB,EAAE,KAAA;KACpB,CAAA;AACH,GAAA;AACF,CAAA;AAEA,SAASC,oBAAoBA,GAAA;AAC3BX,EAAAA,WAAW,EAAE,CAAA;EAEb,IAAI,CAACF,OAAO,EAAE;AACZ,IAAA,MAAM,IAAIc,KAAK,CACb,sEAAsE,GACpE,+CAA+C,CAClD,CAAA;AACH,GAAA;AAEA;AACA;EAEA,IAAIC,YAAY,GAAGf,OAAO,CAAA;AAC1B;AACA;AACA;AACA,EAAA,IAAI,CAACA,OAAO,CAACU,oBAAoB,EAAE;AACjC,IAAA,IAAIM,MAAM,GAAGhB,OAAO,CAACO,OAAO,CAACS,MAAM,CAAA;AACnC,IAAA,CAAUA,MAAM,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,KAAA,YAAA,GAAhBC,gB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