react-router 8.4.0 → 8.5.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 +94 -1
- package/dist/development/dom-export.d.ts +2 -1
- package/dist/development/dom-export.js +1 -1
- package/dist/development/index-react-server-client.js +2 -2
- package/dist/development/index-react-server.d.ts +237 -165
- package/dist/development/index-react-server.js +69 -33
- package/dist/development/index.d.ts +9 -8
- package/dist/development/index.js +5 -4
- package/dist/development/lib/actions.js +1 -1
- package/dist/development/lib/await.js +58 -0
- package/dist/development/lib/components.d.ts +41 -5
- package/dist/development/lib/components.js +82 -5
- package/dist/development/lib/context.d.ts +8 -3
- package/dist/development/lib/context.js +1 -1
- package/dist/development/lib/dom/dom.d.ts +3 -0
- package/dist/development/lib/dom/dom.js +1 -1
- package/dist/development/lib/dom/lib.d.ts +34 -9
- package/dist/development/lib/dom/lib.js +17 -6
- package/dist/development/lib/dom/server.js +2 -2
- package/dist/development/lib/dom/ssr/components.js +12 -9
- package/dist/development/lib/dom/ssr/data.js +1 -1
- package/dist/development/lib/dom/ssr/entry.d.ts +9 -2
- package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/development/lib/dom/ssr/fallback.js +1 -1
- package/dist/development/lib/dom/ssr/fog-of-war.d.ts +3 -2
- package/dist/development/lib/dom/ssr/fog-of-war.js +25 -13
- package/dist/development/lib/dom/ssr/hydration.js +1 -1
- package/dist/development/lib/dom/ssr/invariant.js +1 -1
- package/dist/development/lib/dom/ssr/links.js +1 -1
- package/dist/development/lib/dom/ssr/markup.js +1 -1
- package/dist/development/lib/dom/ssr/route-discovery.d.ts +120 -0
- package/dist/development/lib/dom/ssr/route-discovery.js +415 -0
- package/dist/development/lib/dom/ssr/routeModules.js +1 -1
- package/dist/development/lib/dom/ssr/routes-test-stub.js +2 -2
- package/dist/development/lib/dom/ssr/routes.d.ts +2 -2
- package/dist/development/lib/dom/ssr/routes.js +8 -8
- package/dist/development/lib/dom/ssr/server.js +3 -1
- package/dist/development/lib/dom/ssr/single-fetch.d.ts +28 -2
- package/dist/development/lib/dom/ssr/single-fetch.js +73 -55
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.d.ts +28 -0
- package/dist/development/lib/dom-export/hydrated-router.js +32 -12
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.d.ts +3 -6
- package/dist/development/lib/hooks.js +8 -9
- package/dist/development/lib/href.js +1 -1
- package/dist/development/lib/router/history.js +1 -1
- package/dist/development/lib/router/instrumentation.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/development/lib/router/matcher.js +6 -1
- package/dist/development/lib/router/navigation.js +1 -1
- package/dist/development/lib/router/router.d.ts +8 -0
- package/dist/development/lib/router/router.js +213 -91
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +31 -4
- package/dist/development/lib/router/utils.js +4 -3
- package/dist/development/lib/rsc/browser.js +4 -4
- package/dist/development/lib/rsc/errorBoundaries.js +1 -1
- package/dist/development/lib/rsc/html-stream/browser.js +1 -1
- package/dist/development/lib/rsc/html-stream/server.js +24 -12
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.rsc.d.ts +3 -2
- package/dist/development/lib/rsc/server.ssr.js +1 -1
- package/dist/development/lib/server-runtime/build.d.ts +14 -0
- package/dist/development/lib/server-runtime/cookies.js +1 -1
- package/dist/development/lib/server-runtime/crypto.js +1 -1
- package/dist/development/lib/server-runtime/data.js +1 -1
- package/dist/development/lib/server-runtime/dev.js +1 -1
- package/dist/development/lib/server-runtime/entry.js +1 -1
- package/dist/development/lib/server-runtime/errors.js +1 -1
- package/dist/development/lib/server-runtime/headers.js +1 -1
- package/dist/development/lib/server-runtime/invariant.js +1 -1
- package/dist/development/lib/server-runtime/mode.js +1 -1
- package/dist/development/lib/server-runtime/routeMatching.js +1 -1
- package/dist/development/lib/server-runtime/routes.d.ts +1 -1
- package/dist/development/lib/server-runtime/routes.js +1 -1
- package/dist/development/lib/server-runtime/server.js +24 -8
- package/dist/development/lib/server-runtime/serverHandoff.d.ts +17 -0
- package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions.js +2 -2
- package/dist/development/lib/server-runtime/single-fetch.js +1 -1
- package/dist/development/lib/server-runtime/urls.js +1 -1
- package/dist/development/lib/server-runtime/warnings.js +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/route-data.d.ts +2 -2
- package/dist/development/lib/types/route-module-annotations.d.ts +1 -1
- package/dist/development/route-pattern.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +23 -3
- package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
- package/dist/production/dom-export.d.ts +2 -1
- package/dist/production/dom-export.js +1 -1
- package/dist/production/index-react-server-client.js +2 -2
- package/dist/production/index-react-server.d.ts +237 -165
- package/dist/production/index-react-server.js +69 -33
- package/dist/production/index.d.ts +9 -8
- package/dist/production/index.js +5 -4
- package/dist/production/lib/actions.js +1 -1
- package/dist/production/lib/await.js +58 -0
- package/dist/production/lib/components.d.ts +41 -5
- package/dist/production/lib/components.js +82 -5
- package/dist/production/lib/context.d.ts +8 -3
- package/dist/production/lib/context.js +1 -1
- package/dist/production/lib/dom/dom.d.ts +3 -0
- package/dist/production/lib/dom/dom.js +1 -1
- package/dist/production/lib/dom/lib.d.ts +34 -9
- package/dist/production/lib/dom/lib.js +17 -6
- package/dist/production/lib/dom/server.js +2 -2
- package/dist/production/lib/dom/ssr/components.js +12 -9
- package/dist/production/lib/dom/ssr/data.js +1 -1
- package/dist/production/lib/dom/ssr/entry.d.ts +9 -2
- package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/production/lib/dom/ssr/fallback.js +1 -1
- package/dist/production/lib/dom/ssr/fog-of-war.d.ts +3 -2
- package/dist/production/lib/dom/ssr/fog-of-war.js +25 -13
- package/dist/production/lib/dom/ssr/hydration.js +1 -1
- package/dist/production/lib/dom/ssr/invariant.js +1 -1
- package/dist/production/lib/dom/ssr/links.js +1 -1
- package/dist/production/lib/dom/ssr/markup.js +1 -1
- package/dist/production/lib/dom/ssr/route-discovery.d.ts +120 -0
- package/dist/production/lib/dom/ssr/route-discovery.js +415 -0
- package/dist/production/lib/dom/ssr/routeModules.js +1 -1
- package/dist/production/lib/dom/ssr/routes-test-stub.js +2 -2
- package/dist/production/lib/dom/ssr/routes.d.ts +2 -2
- package/dist/production/lib/dom/ssr/routes.js +8 -8
- package/dist/production/lib/dom/ssr/server.js +3 -1
- package/dist/production/lib/dom/ssr/single-fetch.d.ts +28 -2
- package/dist/production/lib/dom/ssr/single-fetch.js +73 -55
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.d.ts +28 -0
- package/dist/production/lib/dom-export/hydrated-router.js +32 -12
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.d.ts +3 -6
- package/dist/production/lib/hooks.js +7 -8
- package/dist/production/lib/href.js +1 -1
- package/dist/production/lib/router/history.js +1 -1
- package/dist/production/lib/router/instrumentation.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/production/lib/router/matcher.js +6 -1
- package/dist/production/lib/router/navigation.js +1 -1
- package/dist/production/lib/router/router.d.ts +8 -0
- package/dist/production/lib/router/router.js +213 -91
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +31 -4
- package/dist/production/lib/router/utils.js +4 -3
- package/dist/production/lib/rsc/browser.js +4 -4
- package/dist/production/lib/rsc/errorBoundaries.js +1 -1
- package/dist/production/lib/rsc/html-stream/browser.js +1 -1
- package/dist/production/lib/rsc/html-stream/server.js +24 -12
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.rsc.d.ts +3 -2
- package/dist/production/lib/rsc/server.ssr.js +1 -1
- package/dist/production/lib/server-runtime/build.d.ts +14 -0
- package/dist/production/lib/server-runtime/cookies.js +1 -1
- package/dist/production/lib/server-runtime/crypto.js +1 -1
- package/dist/production/lib/server-runtime/data.js +1 -1
- package/dist/production/lib/server-runtime/dev.js +1 -1
- package/dist/production/lib/server-runtime/entry.js +1 -1
- package/dist/production/lib/server-runtime/errors.js +1 -1
- package/dist/production/lib/server-runtime/headers.js +1 -1
- package/dist/production/lib/server-runtime/invariant.js +1 -1
- package/dist/production/lib/server-runtime/mode.js +1 -1
- package/dist/production/lib/server-runtime/routeMatching.js +1 -1
- package/dist/production/lib/server-runtime/routes.d.ts +1 -1
- package/dist/production/lib/server-runtime/routes.js +1 -1
- package/dist/production/lib/server-runtime/server.js +24 -8
- package/dist/production/lib/server-runtime/serverHandoff.d.ts +17 -0
- package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions.js +2 -2
- package/dist/production/lib/server-runtime/single-fetch.js +1 -1
- package/dist/production/lib/server-runtime/urls.js +1 -1
- package/dist/production/lib/server-runtime/warnings.js +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/route-data.d.ts +2 -2
- package/dist/production/lib/types/route-module-annotations.d.ts +1 -1
- package/dist/production/route-pattern.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +23 -3
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/docs/explanation/backend-for-frontend.md +0 -3
- package/docs/explanation/code-splitting.md +0 -3
- package/docs/explanation/concurrency.md +0 -3
- package/docs/explanation/hot-module-replacement.md +0 -3
- package/docs/explanation/lazy-route-discovery.md +4 -3
- package/docs/explanation/progressive-enhancement.md +0 -3
- package/docs/explanation/race-conditions.md +0 -3
- package/docs/explanation/react-transitions.md +0 -3
- package/docs/explanation/sessions-and-cookies.md +109 -5
- package/docs/explanation/state-management.md +0 -3
- package/docs/explanation/styling.md +0 -3
- package/docs/explanation/type-safety.md +0 -3
- package/docs/how-to/accessibility.md +0 -6
- package/docs/how-to/client-data.md +0 -3
- package/docs/how-to/custom-fetch.md +218 -0
- package/docs/how-to/data-strategy.md +23 -4
- package/docs/how-to/error-boundary.md +0 -3
- package/docs/how-to/error-reporting.md +0 -3
- package/docs/how-to/fetchers.md +0 -3
- package/docs/how-to/file-route-conventions.md +0 -3
- package/docs/how-to/file-uploads.md +0 -3
- package/docs/how-to/form-validation.md +0 -3
- package/docs/how-to/headers.md +0 -3
- package/docs/how-to/instrumentation.md +0 -3
- package/docs/how-to/middleware.md +7 -3
- package/docs/how-to/navigation-blocking.md +0 -3
- package/docs/how-to/optimize-revalidation.md +2 -5
- package/docs/how-to/pre-rendering.md +23 -4
- package/docs/how-to/presets.md +0 -3
- package/docs/how-to/react-server-components.md +0 -3
- package/docs/how-to/resource-routes.md +0 -3
- package/docs/how-to/route-discovery.md +147 -0
- package/docs/how-to/route-module-type-safety.md +0 -3
- package/docs/how-to/security.md +0 -3
- package/docs/how-to/server-bundles.md +0 -3
- package/docs/how-to/spa.md +2 -3
- package/docs/how-to/status.md +0 -3
- package/docs/how-to/suspense.md +22 -6
- package/docs/how-to/using-handle.md +0 -3
- package/docs/how-to/view-transitions.md +79 -15
- package/docs/start/framework/data-loading.md +9 -0
- package/docs/start/framework/navigating.md +5 -9
- package/docs/start/framework/rendering.md +37 -0
- package/docs/upgrading/future.md +0 -12
- package/docs/upgrading/v7.md +3 -33
- package/package.json +9 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -50,6 +50,7 @@ function hydrate(index) {
|
|
|
50
50
|
set(-0);
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
|
+
validateIndex(index, values.length);
|
|
53
54
|
if (hydrated[index]) {
|
|
54
55
|
set(hydrated[index]);
|
|
55
56
|
continue;
|
|
@@ -121,11 +122,21 @@ function hydrate(index) {
|
|
|
121
122
|
set(obj);
|
|
122
123
|
continue;
|
|
123
124
|
case "P":
|
|
125
|
+
validateIndex(b, values.length);
|
|
124
126
|
if (hydrated[b]) set(hydrated[index] = hydrated[b]);
|
|
125
127
|
else {
|
|
126
128
|
const d = new Deferred();
|
|
129
|
+
const promise = d.promise;
|
|
130
|
+
promise.status = "pending";
|
|
131
|
+
promise.then((value) => {
|
|
132
|
+
promise.status = "fulfilled";
|
|
133
|
+
promise.value = value;
|
|
134
|
+
}, (reason) => {
|
|
135
|
+
promise.status = "rejected";
|
|
136
|
+
promise.reason = reason;
|
|
137
|
+
});
|
|
127
138
|
deferred[b] = d;
|
|
128
|
-
set(hydrated[index] =
|
|
139
|
+
set(hydrated[index] = promise);
|
|
129
140
|
}
|
|
130
141
|
continue;
|
|
131
142
|
case "E":
|
|
@@ -135,6 +146,7 @@ function hydrate(index) {
|
|
|
135
146
|
set(error);
|
|
136
147
|
continue;
|
|
137
148
|
case "Z":
|
|
149
|
+
validateIndex(b, values.length);
|
|
138
150
|
set(hydrated[index] = hydrated[b]);
|
|
139
151
|
continue;
|
|
140
152
|
default:
|
|
@@ -185,7 +197,12 @@ function hydrate(index) {
|
|
|
185
197
|
r[0] = k;
|
|
186
198
|
}]);
|
|
187
199
|
postRun.push(() => {
|
|
188
|
-
object
|
|
200
|
+
Object.defineProperty(object, r[0], {
|
|
201
|
+
value: r[1],
|
|
202
|
+
enumerable: true,
|
|
203
|
+
configurable: true,
|
|
204
|
+
writable: true
|
|
205
|
+
});
|
|
189
206
|
});
|
|
190
207
|
}
|
|
191
208
|
set(object);
|
|
@@ -195,5 +212,8 @@ function hydrate(index) {
|
|
|
195
212
|
while (postRun.length > 0) postRun.pop()();
|
|
196
213
|
return result;
|
|
197
214
|
}
|
|
215
|
+
function validateIndex(index, length) {
|
|
216
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= length) throw new SyntaxError();
|
|
217
|
+
}
|
|
198
218
|
//#endregion
|
|
199
219
|
export { unflatten };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import { RouterProvider, RouterProviderProps } from "./lib/dom-export/dom-router-provider.js";
|
|
3
|
+
import { RouterFetch, RouterFetchContext } from "./lib/dom/ssr/single-fetch.js";
|
|
3
4
|
import { DecodeActionFunction, DecodeFormStateFunction, DecodeReplyFunction, RSCManifestPayload, RSCPayload, RSCRenderPayload } from "./lib/rsc/server.rsc.js";
|
|
4
5
|
import { RSCHydratedRouter, createCallServer } from "./lib/rsc/browser.js";
|
|
5
6
|
import { HydratedRouter, HydratedRouterProps } from "./lib/dom-export/hydrated-router.js";
|
|
6
7
|
import { getRSCStream } from "./lib/rsc/html-stream/browser.js";
|
|
7
|
-
export { HydratedRouter, type HydratedRouterProps, RouterProvider, type RouterProviderProps, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, RSCHydratedRouter as unstable_RSCHydratedRouter, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, createCallServer as unstable_createCallServer, getRSCStream as unstable_getRSCStream };
|
|
8
|
+
export { HydratedRouter, type HydratedRouterProps, RouterProvider, type RouterProviderProps, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, RSCHydratedRouter as unstable_RSCHydratedRouter, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RouterFetch as unstable_RouterFetch, type RouterFetchContext as unstable_RouterFetchContext, createCallServer as unstable_createCallServer, getRSCStream as unstable_getRSCStream };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
"use client";
|
|
12
12
|
import { AwaitContextProvider } from "./lib/context.js";
|
|
13
|
-
import { MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps } from "./lib/components.js";
|
|
14
13
|
import { Links, Meta } from "./lib/dom/ssr/components.js";
|
|
14
|
+
import { MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps } from "./lib/components.js";
|
|
15
15
|
import { BrowserRouter, Form, HashRouter, HistoryRouter, Link, NavLink, ScrollRestoration } from "./lib/dom/lib.js";
|
|
16
16
|
import { StaticRouter, StaticRouterProvider } from "./lib/dom/server.js";
|
|
17
17
|
export { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, AwaitContextProvider as UNSAFE_AwaitContextProvider, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, HistoryRouter as unstable_HistoryRouter };
|
|
@@ -352,6 +352,13 @@ interface DataFunctionArgs<Context> {
|
|
|
352
352
|
* In Framework mode, this is a normalized URL with React-Router-specific
|
|
353
353
|
* implementation details removed (`.data` suffixes, `index`/`_routes` search
|
|
354
354
|
* params). For the raw incoming URL, use `request.url`.
|
|
355
|
+
*
|
|
356
|
+
* This normalization preserves standard URL pathname encoding and casing.
|
|
357
|
+
* For example, a request to `/%61dmin.data` produces a `url.pathname` of
|
|
358
|
+
* `/%61dmin`. This is not a canonical representation of the matched route.
|
|
359
|
+
* For authorization, attach {@link https://reactrouter.com/how-to/middleware#authentication server middleware}
|
|
360
|
+
* to the protected route or a common ancestor instead of relying on literal
|
|
361
|
+
* pathname-prefix comparisons.
|
|
355
362
|
*/
|
|
356
363
|
url: URL;
|
|
357
364
|
/**
|
|
@@ -556,6 +563,11 @@ interface DataStrategyMatch extends RouteMatch<string, DataRouteObject> {
|
|
|
556
563
|
*/
|
|
557
564
|
resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
|
|
558
565
|
}
|
|
566
|
+
/**
|
|
567
|
+
* The operation that initiated a data strategy execution. Static handler
|
|
568
|
+
* executions use `"static"`.
|
|
569
|
+
*/
|
|
570
|
+
type DataStrategyInitiator = "initialization" | "navigation" | "fetcher" | "revalidation" | "static";
|
|
559
571
|
interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
|
|
560
572
|
/**
|
|
561
573
|
* Matches for this route extended with Data strategy APIs
|
|
@@ -563,8 +575,23 @@ interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctio
|
|
|
563
575
|
matches: DataStrategyMatch[];
|
|
564
576
|
runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
|
|
565
577
|
/**
|
|
566
|
-
* The
|
|
567
|
-
*
|
|
578
|
+
* The operation that initiated this data strategy execution
|
|
579
|
+
*
|
|
580
|
+
* This field is experimental and subject to breaking changes.
|
|
581
|
+
*/
|
|
582
|
+
unstable_initiator: DataStrategyInitiator;
|
|
583
|
+
/**
|
|
584
|
+
* The history action (`"PUSH"`, `"REPLACE"`, or `"POP"`) for a navigation-
|
|
585
|
+
* initiated execution, including fetchers reloaded by that navigation.
|
|
586
|
+
* `null` for initialization, fetcher, revalidation, and static executions.
|
|
587
|
+
*
|
|
588
|
+
* This field is experimental and subject to breaking changes.
|
|
589
|
+
*/
|
|
590
|
+
unstable_navigationType: Action | null;
|
|
591
|
+
/**
|
|
592
|
+
* The key of the fetcher targeted by this data strategy execution, otherwise
|
|
593
|
+
* `null`. Fetchers reloaded during a navigation or revalidation retain that
|
|
594
|
+
* `unstable_initiator` while providing their key here.
|
|
568
595
|
*/
|
|
569
596
|
fetcherKey: string | null;
|
|
570
597
|
}
|
|
@@ -979,6 +1006,204 @@ type ErrorResponse = {
|
|
|
979
1006
|
*/
|
|
980
1007
|
declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
|
981
1008
|
//#endregion
|
|
1009
|
+
//#region lib/components.d.ts
|
|
1010
|
+
interface AwaitResolveRenderFunction<Resolve = any> {
|
|
1011
|
+
(data: Awaited<Resolve>): React.ReactNode;
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* @category Types
|
|
1015
|
+
*/
|
|
1016
|
+
interface AwaitProps<Resolve> {
|
|
1017
|
+
/** Use either `resolve` or `unstable_promise`, never both. */
|
|
1018
|
+
unstable_promise?: never;
|
|
1019
|
+
/**
|
|
1020
|
+
* When using a function, the resolved value is provided as the parameter.
|
|
1021
|
+
*
|
|
1022
|
+
* ```tsx [2]
|
|
1023
|
+
* <Await resolve={reviewsPromise}>
|
|
1024
|
+
* {(resolvedReviews) => <Reviews items={resolvedReviews} />}
|
|
1025
|
+
* </Await>
|
|
1026
|
+
* ```
|
|
1027
|
+
*
|
|
1028
|
+
* When using React elements, {@link useAsyncValue} will provide the
|
|
1029
|
+
* resolved value:
|
|
1030
|
+
*
|
|
1031
|
+
* ```tsx [2]
|
|
1032
|
+
* <Await resolve={reviewsPromise}>
|
|
1033
|
+
* <Reviews />
|
|
1034
|
+
* </Await>
|
|
1035
|
+
*
|
|
1036
|
+
* function Reviews() {
|
|
1037
|
+
* const resolvedReviews = useAsyncValue();
|
|
1038
|
+
* return <div>...</div>;
|
|
1039
|
+
* }
|
|
1040
|
+
* ```
|
|
1041
|
+
*/
|
|
1042
|
+
children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
|
|
1043
|
+
/**
|
|
1044
|
+
* The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
1045
|
+
* rejects.
|
|
1046
|
+
*
|
|
1047
|
+
* ```tsx
|
|
1048
|
+
* <Await
|
|
1049
|
+
* errorElement={<div>Oops</div>}
|
|
1050
|
+
* resolve={reviewsPromise}
|
|
1051
|
+
* >
|
|
1052
|
+
* <Reviews />
|
|
1053
|
+
* </Await>
|
|
1054
|
+
* ```
|
|
1055
|
+
*
|
|
1056
|
+
* To provide a more contextual error, you can use the {@link useAsyncError} in a
|
|
1057
|
+
* child component
|
|
1058
|
+
*
|
|
1059
|
+
* ```tsx
|
|
1060
|
+
* <Await
|
|
1061
|
+
* errorElement={<ReviewsError />}
|
|
1062
|
+
* resolve={reviewsPromise}
|
|
1063
|
+
* >
|
|
1064
|
+
* <Reviews />
|
|
1065
|
+
* </Await>
|
|
1066
|
+
*
|
|
1067
|
+
* function ReviewsError() {
|
|
1068
|
+
* const error = useAsyncError();
|
|
1069
|
+
* return <div>Error loading reviews: {error.message}</div>;
|
|
1070
|
+
* }
|
|
1071
|
+
* ```
|
|
1072
|
+
*
|
|
1073
|
+
* If you do not provide an `errorElement`, the rejected value will bubble up
|
|
1074
|
+
* to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
|
|
1075
|
+
* and be accessible via the {@link useRouteError} hook.
|
|
1076
|
+
*/
|
|
1077
|
+
errorElement?: React.ReactNode;
|
|
1078
|
+
/**
|
|
1079
|
+
* Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
1080
|
+
* returned from a [`loader`](../../start/framework/route-module#loader) to be
|
|
1081
|
+
* resolved and rendered.
|
|
1082
|
+
*
|
|
1083
|
+
* ```tsx
|
|
1084
|
+
* import { Await, useLoaderData } from "react-router";
|
|
1085
|
+
*
|
|
1086
|
+
* export async function loader() {
|
|
1087
|
+
* let reviews = getReviews(); // not awaited
|
|
1088
|
+
* let book = await getBook();
|
|
1089
|
+
* return {
|
|
1090
|
+
* book,
|
|
1091
|
+
* reviews, // this is a promise
|
|
1092
|
+
* };
|
|
1093
|
+
* }
|
|
1094
|
+
*
|
|
1095
|
+
* export default function Book() {
|
|
1096
|
+
* const {
|
|
1097
|
+
* book,
|
|
1098
|
+
* reviews, // this is the same promise
|
|
1099
|
+
* } = useLoaderData();
|
|
1100
|
+
*
|
|
1101
|
+
* return (
|
|
1102
|
+
* <div>
|
|
1103
|
+
* <h1>{book.title}</h1>
|
|
1104
|
+
* <p>{book.description}</p>
|
|
1105
|
+
* <React.Suspense fallback={<ReviewsSkeleton />}>
|
|
1106
|
+
* <Await
|
|
1107
|
+
* // and is the promise we pass to Await
|
|
1108
|
+
* resolve={reviews}
|
|
1109
|
+
* >
|
|
1110
|
+
* <Reviews />
|
|
1111
|
+
* </Await>
|
|
1112
|
+
* </React.Suspense>
|
|
1113
|
+
* </div>
|
|
1114
|
+
* );
|
|
1115
|
+
* }
|
|
1116
|
+
* ```
|
|
1117
|
+
*/
|
|
1118
|
+
resolve: Resolve;
|
|
1119
|
+
}
|
|
1120
|
+
interface AwaitPromiseProps<Resolve> extends Omit<AwaitProps<Resolve>, "resolve" | "unstable_promise"> {
|
|
1121
|
+
resolve?: never;
|
|
1122
|
+
/**
|
|
1123
|
+
* A promise (or value) to read using React's `use()` API in client components.
|
|
1124
|
+
* Unlike `resolve` in client components, this accepts promise-like values
|
|
1125
|
+
* without modifying the source promise.
|
|
1126
|
+
*
|
|
1127
|
+
* `errorElement` handles promise rejections. Errors thrown while rendering
|
|
1128
|
+
* children bubble to the nearest React error boundary.
|
|
1129
|
+
*
|
|
1130
|
+
* ```tsx
|
|
1131
|
+
* <Await unstable_promise={reviewsPromise} errorElement={<ReviewsError />}>
|
|
1132
|
+
* {(reviews) => <Reviews items={reviews} />}
|
|
1133
|
+
* </Await>
|
|
1134
|
+
* ```
|
|
1135
|
+
*
|
|
1136
|
+
* Pass exactly one of `unstable_promise` or `resolve`.
|
|
1137
|
+
*/
|
|
1138
|
+
unstable_promise: Resolve;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Used to render promise values with automatic error handling.
|
|
1142
|
+
*
|
|
1143
|
+
* **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
|
|
1144
|
+
*
|
|
1145
|
+
* Pass `unstable_promise` instead of `resolve` to opt into React's
|
|
1146
|
+
* [`use()`](https://react.dev/reference/react/use) implementation. With
|
|
1147
|
+
* `unstable_promise`, `errorElement` handles promise rejections, while errors
|
|
1148
|
+
* thrown by children bubble to the nearest React error boundary.
|
|
1149
|
+
*
|
|
1150
|
+
* In React Server Components, `resolve` already has this error-handling behavior:
|
|
1151
|
+
* `errorElement` handles only input rejections, while child render errors
|
|
1152
|
+
* propagate to the surrounding error boundary. Both props accept promise-like
|
|
1153
|
+
* values without modifying the source promise. Both props treat a falsy
|
|
1154
|
+
* `errorElement` as absent and propagate the rejection. Pass an empty fragment
|
|
1155
|
+
* to handle a rejection without rendering any content.
|
|
1156
|
+
*
|
|
1157
|
+
* <docs-warning>The `unstable_promise` prop is experimental and may change in
|
|
1158
|
+
* minor or patch releases.</docs-warning>
|
|
1159
|
+
*
|
|
1160
|
+
* @example
|
|
1161
|
+
* import { Await, useLoaderData } from "react-router";
|
|
1162
|
+
*
|
|
1163
|
+
* export async function loader() {
|
|
1164
|
+
* // not awaited
|
|
1165
|
+
* const reviews = getReviews();
|
|
1166
|
+
* // awaited (blocks the transition)
|
|
1167
|
+
* const book = await fetch("/api/book").then((res) => res.json());
|
|
1168
|
+
* return { book, reviews };
|
|
1169
|
+
* }
|
|
1170
|
+
*
|
|
1171
|
+
* function Book() {
|
|
1172
|
+
* const { book, reviews } = useLoaderData();
|
|
1173
|
+
* return (
|
|
1174
|
+
* <div>
|
|
1175
|
+
* <h1>{book.title}</h1>
|
|
1176
|
+
* <p>{book.description}</p>
|
|
1177
|
+
* <React.Suspense fallback={<ReviewsSkeleton />}>
|
|
1178
|
+
* <Await
|
|
1179
|
+
* resolve={reviews}
|
|
1180
|
+
* errorElement={
|
|
1181
|
+
* <div>Could not load reviews 😬</div>
|
|
1182
|
+
* }
|
|
1183
|
+
* children={(resolvedReviews) => (
|
|
1184
|
+
* <Reviews items={resolvedReviews} />
|
|
1185
|
+
* )}
|
|
1186
|
+
* />
|
|
1187
|
+
* </React.Suspense>
|
|
1188
|
+
* </div>
|
|
1189
|
+
* );
|
|
1190
|
+
* }
|
|
1191
|
+
*
|
|
1192
|
+
* @public
|
|
1193
|
+
* @category Components
|
|
1194
|
+
* @mode framework
|
|
1195
|
+
* @mode data
|
|
1196
|
+
* @param props Props
|
|
1197
|
+
* @param {AwaitProps.children} props.children n/a
|
|
1198
|
+
* @param {AwaitProps.errorElement} props.errorElement n/a
|
|
1199
|
+
* @param {AwaitProps.resolve} props.resolve n/a
|
|
1200
|
+
* @param props.unstable_promise A promise (or value) to read using React's `use()`
|
|
1201
|
+
* API in client components. Accepts promise-like values without modifying the
|
|
1202
|
+
* source promise. Pass exactly one of `unstable_promise` or `resolve`.
|
|
1203
|
+
* @returns React element for the rendered awaited value
|
|
1204
|
+
*/
|
|
1205
|
+
declare function Await$1<Resolve>(props: AwaitProps<Resolve> | AwaitPromiseProps<Resolve>): React.JSX.Element;
|
|
1206
|
+
//#endregion
|
|
982
1207
|
//#region lib/router/instrumentation.d.ts
|
|
983
1208
|
type ServerInstrumentation = {
|
|
984
1209
|
handler?: InstrumentRequestHandlerFunction;
|
|
@@ -1390,6 +1615,8 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
|
|
|
1390
1615
|
* Future flags to toggle new feature behavior
|
|
1391
1616
|
*/
|
|
1392
1617
|
interface FutureConfig {
|
|
1618
|
+
/** @internal Enables application-controlled Framework route discovery. */
|
|
1619
|
+
unstable_customRouteDiscovery?: boolean;
|
|
1393
1620
|
/** Enables route-pattern matching after calling `unstable_preloadRoutePattern()`. */
|
|
1394
1621
|
unstable_routePatternMatching?: boolean;
|
|
1395
1622
|
}
|
|
@@ -1435,6 +1662,8 @@ interface StaticHandler {
|
|
|
1435
1662
|
* The set of data routes managed by this handler
|
|
1436
1663
|
*/
|
|
1437
1664
|
dataRoutes: DataRouteObject[];
|
|
1665
|
+
/** @private Estimated route metadata visits per regex match. */
|
|
1666
|
+
readonly _matchCost?: number;
|
|
1438
1667
|
/**
|
|
1439
1668
|
* @private
|
|
1440
1669
|
* PRIVATE - DO NOT USE
|
|
@@ -1536,6 +1765,10 @@ type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
|
|
|
1536
1765
|
replace?: boolean;
|
|
1537
1766
|
state?: any;
|
|
1538
1767
|
fromRouteId?: string;
|
|
1768
|
+
/**
|
|
1769
|
+
* @deprecated Use React's `<ViewTransition>` component instead. See the
|
|
1770
|
+
* [migration guide](https://reactrouter.com/how-to/view-transitions).
|
|
1771
|
+
*/
|
|
1539
1772
|
viewTransition?: boolean;
|
|
1540
1773
|
mask?: To;
|
|
1541
1774
|
};
|
|
@@ -2087,168 +2320,6 @@ type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
|
|
|
2087
2320
|
*/
|
|
2088
2321
|
type RouteHandle = unknown;
|
|
2089
2322
|
//#endregion
|
|
2090
|
-
//#region lib/components.d.ts
|
|
2091
|
-
interface AwaitResolveRenderFunction<Resolve = any> {
|
|
2092
|
-
(data: Awaited<Resolve>): React.ReactNode;
|
|
2093
|
-
}
|
|
2094
|
-
/**
|
|
2095
|
-
* @category Types
|
|
2096
|
-
*/
|
|
2097
|
-
interface AwaitProps<Resolve> {
|
|
2098
|
-
/**
|
|
2099
|
-
* When using a function, the resolved value is provided as the parameter.
|
|
2100
|
-
*
|
|
2101
|
-
* ```tsx [2]
|
|
2102
|
-
* <Await resolve={reviewsPromise}>
|
|
2103
|
-
* {(resolvedReviews) => <Reviews items={resolvedReviews} />}
|
|
2104
|
-
* </Await>
|
|
2105
|
-
* ```
|
|
2106
|
-
*
|
|
2107
|
-
* When using React elements, {@link useAsyncValue} will provide the
|
|
2108
|
-
* resolved value:
|
|
2109
|
-
*
|
|
2110
|
-
* ```tsx [2]
|
|
2111
|
-
* <Await resolve={reviewsPromise}>
|
|
2112
|
-
* <Reviews />
|
|
2113
|
-
* </Await>
|
|
2114
|
-
*
|
|
2115
|
-
* function Reviews() {
|
|
2116
|
-
* const resolvedReviews = useAsyncValue();
|
|
2117
|
-
* return <div>...</div>;
|
|
2118
|
-
* }
|
|
2119
|
-
* ```
|
|
2120
|
-
*/
|
|
2121
|
-
children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
|
|
2122
|
-
/**
|
|
2123
|
-
* The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
2124
|
-
* rejects.
|
|
2125
|
-
*
|
|
2126
|
-
* ```tsx
|
|
2127
|
-
* <Await
|
|
2128
|
-
* errorElement={<div>Oops</div>}
|
|
2129
|
-
* resolve={reviewsPromise}
|
|
2130
|
-
* >
|
|
2131
|
-
* <Reviews />
|
|
2132
|
-
* </Await>
|
|
2133
|
-
* ```
|
|
2134
|
-
*
|
|
2135
|
-
* To provide a more contextual error, you can use the {@link useAsyncError} in a
|
|
2136
|
-
* child component
|
|
2137
|
-
*
|
|
2138
|
-
* ```tsx
|
|
2139
|
-
* <Await
|
|
2140
|
-
* errorElement={<ReviewsError />}
|
|
2141
|
-
* resolve={reviewsPromise}
|
|
2142
|
-
* >
|
|
2143
|
-
* <Reviews />
|
|
2144
|
-
* </Await>
|
|
2145
|
-
*
|
|
2146
|
-
* function ReviewsError() {
|
|
2147
|
-
* const error = useAsyncError();
|
|
2148
|
-
* return <div>Error loading reviews: {error.message}</div>;
|
|
2149
|
-
* }
|
|
2150
|
-
* ```
|
|
2151
|
-
*
|
|
2152
|
-
* If you do not provide an `errorElement`, the rejected value will bubble up
|
|
2153
|
-
* to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
|
|
2154
|
-
* and be accessible via the {@link useRouteError} hook.
|
|
2155
|
-
*/
|
|
2156
|
-
errorElement?: React.ReactNode;
|
|
2157
|
-
/**
|
|
2158
|
-
* Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
2159
|
-
* returned from a [`loader`](../../start/framework/route-module#loader) to be
|
|
2160
|
-
* resolved and rendered.
|
|
2161
|
-
*
|
|
2162
|
-
* ```tsx
|
|
2163
|
-
* import { Await, useLoaderData } from "react-router";
|
|
2164
|
-
*
|
|
2165
|
-
* export async function loader() {
|
|
2166
|
-
* let reviews = getReviews(); // not awaited
|
|
2167
|
-
* let book = await getBook();
|
|
2168
|
-
* return {
|
|
2169
|
-
* book,
|
|
2170
|
-
* reviews, // this is a promise
|
|
2171
|
-
* };
|
|
2172
|
-
* }
|
|
2173
|
-
*
|
|
2174
|
-
* export default function Book() {
|
|
2175
|
-
* const {
|
|
2176
|
-
* book,
|
|
2177
|
-
* reviews, // this is the same promise
|
|
2178
|
-
* } = useLoaderData();
|
|
2179
|
-
*
|
|
2180
|
-
* return (
|
|
2181
|
-
* <div>
|
|
2182
|
-
* <h1>{book.title}</h1>
|
|
2183
|
-
* <p>{book.description}</p>
|
|
2184
|
-
* <React.Suspense fallback={<ReviewsSkeleton />}>
|
|
2185
|
-
* <Await
|
|
2186
|
-
* // and is the promise we pass to Await
|
|
2187
|
-
* resolve={reviews}
|
|
2188
|
-
* >
|
|
2189
|
-
* <Reviews />
|
|
2190
|
-
* </Await>
|
|
2191
|
-
* </React.Suspense>
|
|
2192
|
-
* </div>
|
|
2193
|
-
* );
|
|
2194
|
-
* }
|
|
2195
|
-
* ```
|
|
2196
|
-
*/
|
|
2197
|
-
resolve: Resolve;
|
|
2198
|
-
}
|
|
2199
|
-
/**
|
|
2200
|
-
* Used to render promise values with automatic error handling.
|
|
2201
|
-
*
|
|
2202
|
-
* **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
|
|
2203
|
-
*
|
|
2204
|
-
* @example
|
|
2205
|
-
* import { Await, useLoaderData } from "react-router";
|
|
2206
|
-
*
|
|
2207
|
-
* export async function loader() {
|
|
2208
|
-
* // not awaited
|
|
2209
|
-
* const reviews = getReviews();
|
|
2210
|
-
* // awaited (blocks the transition)
|
|
2211
|
-
* const book = await fetch("/api/book").then((res) => res.json());
|
|
2212
|
-
* return { book, reviews };
|
|
2213
|
-
* }
|
|
2214
|
-
*
|
|
2215
|
-
* function Book() {
|
|
2216
|
-
* const { book, reviews } = useLoaderData();
|
|
2217
|
-
* return (
|
|
2218
|
-
* <div>
|
|
2219
|
-
* <h1>{book.title}</h1>
|
|
2220
|
-
* <p>{book.description}</p>
|
|
2221
|
-
* <React.Suspense fallback={<ReviewsSkeleton />}>
|
|
2222
|
-
* <Await
|
|
2223
|
-
* resolve={reviews}
|
|
2224
|
-
* errorElement={
|
|
2225
|
-
* <div>Could not load reviews 😬</div>
|
|
2226
|
-
* }
|
|
2227
|
-
* children={(resolvedReviews) => (
|
|
2228
|
-
* <Reviews items={resolvedReviews} />
|
|
2229
|
-
* )}
|
|
2230
|
-
* />
|
|
2231
|
-
* </React.Suspense>
|
|
2232
|
-
* </div>
|
|
2233
|
-
* );
|
|
2234
|
-
* }
|
|
2235
|
-
*
|
|
2236
|
-
* @public
|
|
2237
|
-
* @category Components
|
|
2238
|
-
* @mode framework
|
|
2239
|
-
* @mode data
|
|
2240
|
-
* @param props Props
|
|
2241
|
-
* @param {AwaitProps.children} props.children n/a
|
|
2242
|
-
* @param {AwaitProps.errorElement} props.errorElement n/a
|
|
2243
|
-
* @param {AwaitProps.resolve} props.resolve n/a
|
|
2244
|
-
* @returns React element for the rendered awaited value
|
|
2245
|
-
*/
|
|
2246
|
-
declare function Await$1<Resolve>({
|
|
2247
|
-
children,
|
|
2248
|
-
errorElement,
|
|
2249
|
-
resolve
|
|
2250
|
-
}: AwaitProps<Resolve>): React.JSX.Element;
|
|
2251
|
-
//#endregion
|
|
2252
2323
|
//#region lib/rsc/server.rsc.d.ts
|
|
2253
2324
|
declare function getRequest(): Request;
|
|
2254
2325
|
declare const redirect: typeof redirect$1;
|
|
@@ -2267,6 +2338,7 @@ type RSCRouteConfigEntryBase = {
|
|
|
2267
2338
|
links?: LinksFunction;
|
|
2268
2339
|
loader?: LoaderFunction;
|
|
2269
2340
|
meta?: MetaFunction;
|
|
2341
|
+
middleware?: MiddlewareFunction<any>[];
|
|
2270
2342
|
shouldRevalidate?: ShouldRevalidateFunction;
|
|
2271
2343
|
};
|
|
2272
2344
|
type RSCRouteConfigEntry = RSCRouteConfigEntryBase & {
|
|
@@ -2452,7 +2524,7 @@ declare function matchRSCServerRequest({
|
|
|
2452
2524
|
onError,
|
|
2453
2525
|
request,
|
|
2454
2526
|
routes,
|
|
2455
|
-
generateResponse
|
|
2527
|
+
generateResponse: encodeResponse
|
|
2456
2528
|
}: {
|
|
2457
2529
|
allowedActionOrigins?: string[];
|
|
2458
2530
|
createTemporaryReferenceSet: () => unknown;
|