react-router 7.8.2 → 7.9.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 +28 -0
- package/dist/development/{chunk-5UALIXAM.mjs → chunk-AVXIT45F.mjs} +94 -70
- package/dist/development/{chunk-PVWAREVJ.mjs → chunk-QZH3B547.mjs} +47 -50
- package/dist/development/{chunk-ZO66TDGB.js → chunk-RGB6BZUL.js} +41 -44
- package/dist/development/{chunk-CSDGKXLR.js → chunk-XYB2GISA.js} +135 -135
- package/dist/{production/context-jKip1TFB.d.mts → development/context-BH6Jwdoy.d.mts} +39 -32
- package/dist/development/dom-export.d.mts +3 -3
- package/dist/development/dom-export.d.ts +2 -2
- package/dist/development/dom-export.js +14 -14
- package/dist/development/dom-export.mjs +14 -14
- package/dist/development/{index-react-server-client-DRhjXpk2.d.mts → index-react-server-client-1cWMpKk4.d.mts} +13 -13
- package/dist/{production/index-react-server-client-BKpa2trA.d.ts → development/index-react-server-client-CMC2eQAY.d.ts} +12 -12
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +4 -4
- package/dist/development/index-react-server.d.mts +229 -37
- package/dist/development/index-react-server.d.ts +229 -37
- package/dist/development/index-react-server.js +89 -39
- package/dist/development/index-react-server.mjs +88 -36
- package/dist/development/index.d.mts +31 -24
- package/dist/development/index.d.ts +29 -22
- package/dist/development/index.js +184 -158
- package/dist/development/index.mjs +9 -7
- package/dist/development/lib/types/internal.d.mts +6 -6
- package/dist/development/lib/types/internal.d.ts +5 -5
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{route-data-DAVP2QQ0.d.mts → route-data-BQkq8Erj.d.mts} +12 -12
- package/dist/development/{routeModules-rOzWJJ9x.d.ts → routeModules-DSKAn01V.d.ts} +175 -168
- package/dist/production/{chunk-Z56HUDN5.js → chunk-A6EU7LHU.js} +41 -44
- package/dist/production/{chunk-REDRD2MB.mjs → chunk-BQLQLXP4.mjs} +47 -50
- package/dist/production/{chunk-JNT5PWCQ.js → chunk-IR3XRH6J.js} +135 -135
- package/dist/production/{chunk-KWHRV2I7.mjs → chunk-WMHWIEJV.mjs} +94 -70
- package/dist/{development/context-jKip1TFB.d.mts → production/context-BH6Jwdoy.d.mts} +39 -32
- package/dist/production/dom-export.d.mts +3 -3
- package/dist/production/dom-export.d.ts +2 -2
- package/dist/production/dom-export.js +14 -14
- package/dist/production/dom-export.mjs +14 -14
- package/dist/production/{index-react-server-client-DRhjXpk2.d.mts → index-react-server-client-1cWMpKk4.d.mts} +13 -13
- package/dist/{development/index-react-server-client-BKpa2trA.d.ts → production/index-react-server-client-CMC2eQAY.d.ts} +12 -12
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +4 -4
- package/dist/production/index-react-server.d.mts +229 -37
- package/dist/production/index-react-server.d.ts +229 -37
- package/dist/production/index-react-server.js +89 -39
- package/dist/production/index-react-server.mjs +88 -36
- package/dist/production/index.d.mts +31 -24
- package/dist/production/index.d.ts +29 -22
- package/dist/production/index.js +184 -158
- package/dist/production/index.mjs +9 -7
- package/dist/production/lib/types/internal.d.mts +6 -6
- package/dist/production/lib/types/internal.d.ts +5 -5
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/{route-data-DAVP2QQ0.d.mts → route-data-BQkq8Erj.d.mts} +12 -12
- package/dist/production/{routeModules-rOzWJJ9x.d.ts → routeModules-DSKAn01V.d.ts} +175 -168
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export {
|
|
2
|
+
export { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, unstable_HistoryRouter } from 'react-router/internal/react-server-client';
|
|
3
3
|
import { ParseOptions, SerializeOptions } from 'cookie';
|
|
4
4
|
export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
|
|
5
5
|
|
|
@@ -169,7 +169,7 @@ interface History {
|
|
|
169
169
|
interface Future {
|
|
170
170
|
}
|
|
171
171
|
type MiddlewareEnabled = Future extends {
|
|
172
|
-
|
|
172
|
+
middleware: infer T extends boolean;
|
|
173
173
|
} ? T : false;
|
|
174
174
|
|
|
175
175
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -229,14 +229,14 @@ type Submission = {
|
|
|
229
229
|
};
|
|
230
230
|
/**
|
|
231
231
|
* A context instance used as the key for the `get`/`set` methods of a
|
|
232
|
-
* {@link
|
|
232
|
+
* {@link RouterContextProvider}. Accepts an optional default
|
|
233
233
|
* value to be returned if no value has been set.
|
|
234
234
|
*/
|
|
235
|
-
interface
|
|
235
|
+
interface RouterContext<T = unknown> {
|
|
236
236
|
defaultValue?: T;
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
|
-
* Creates a type-safe {@link
|
|
239
|
+
* Creates a type-safe {@link RouterContext} object that can be used to
|
|
240
240
|
* store and retrieve arbitrary values in [`action`](../../start/framework/route-module#action)s,
|
|
241
241
|
* [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
|
|
242
242
|
* Similar to React's [`createContext`](https://react.dev/reference/react/createContext),
|
|
@@ -247,11 +247,11 @@ interface unstable_RouterContext<T = unknown> {
|
|
|
247
247
|
* when no value has been set will throw an error.
|
|
248
248
|
*
|
|
249
249
|
* ```tsx filename=app/context.ts
|
|
250
|
-
* import {
|
|
250
|
+
* import { createContext } from "react-router";
|
|
251
251
|
*
|
|
252
252
|
* // Create a context for user data
|
|
253
253
|
* export const userContext =
|
|
254
|
-
*
|
|
254
|
+
* createContext<User | null>(null);
|
|
255
255
|
* ```
|
|
256
256
|
*
|
|
257
257
|
* ```tsx filename=app/middleware/auth.ts
|
|
@@ -289,23 +289,23 @@ interface unstable_RouterContext<T = unknown> {
|
|
|
289
289
|
* @mode data
|
|
290
290
|
* @param defaultValue An optional default value for the context. This value
|
|
291
291
|
* will be returned if no value has been set for this context.
|
|
292
|
-
* @returns A {@link
|
|
292
|
+
* @returns A {@link RouterContext} object that can be used with
|
|
293
293
|
* `context.get()` and `context.set()` in [`action`](../../start/framework/route-module#action)s,
|
|
294
294
|
* [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
|
|
295
295
|
*/
|
|
296
|
-
declare function
|
|
296
|
+
declare function createContext<T>(defaultValue?: T): RouterContext<T>;
|
|
297
297
|
/**
|
|
298
298
|
* Provides methods for writing/reading values in application context in a
|
|
299
299
|
* type-safe way. Primarily for usage with [middleware](../../how-to/middleware).
|
|
300
300
|
*
|
|
301
301
|
* @example
|
|
302
302
|
* import {
|
|
303
|
-
*
|
|
304
|
-
*
|
|
303
|
+
* createContext,
|
|
304
|
+
* RouterContextProvider
|
|
305
305
|
* } from "react-router";
|
|
306
306
|
*
|
|
307
|
-
* const userContext =
|
|
308
|
-
* const contextProvider = new
|
|
307
|
+
* const userContext = createContext<User | null>(null);
|
|
308
|
+
* const contextProvider = new RouterContextProvider();
|
|
309
309
|
* contextProvider.set(userContext, getUser());
|
|
310
310
|
* // ^ Type-safe
|
|
311
311
|
* const user = contextProvider.get(userContext);
|
|
@@ -316,13 +316,13 @@ declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterCon
|
|
|
316
316
|
* @mode framework
|
|
317
317
|
* @mode data
|
|
318
318
|
*/
|
|
319
|
-
declare class
|
|
319
|
+
declare class RouterContextProvider {
|
|
320
320
|
#private;
|
|
321
321
|
/**
|
|
322
|
-
* Create a new `
|
|
322
|
+
* Create a new `RouterContextProvider` instance
|
|
323
323
|
* @param init An optional initial context map to populate the provider with
|
|
324
324
|
*/
|
|
325
|
-
constructor(init?: Map<
|
|
325
|
+
constructor(init?: Map<RouterContext, unknown>);
|
|
326
326
|
/**
|
|
327
327
|
* Access a value from the context. If no value has been set for the context,
|
|
328
328
|
* it will return the context's `defaultValue` if provided, or throw an error
|
|
@@ -331,7 +331,7 @@ declare class unstable_RouterContextProvider {
|
|
|
331
331
|
* @returns The value for the context, or the context's `defaultValue` if no
|
|
332
332
|
* value was set
|
|
333
333
|
*/
|
|
334
|
-
get<T>(context:
|
|
334
|
+
get<T>(context: RouterContext<T>): T;
|
|
335
335
|
/**
|
|
336
336
|
* Set a value for the context. If the context already has a value set, this
|
|
337
337
|
* will overwrite it.
|
|
@@ -340,9 +340,9 @@ declare class unstable_RouterContextProvider {
|
|
|
340
340
|
* @param value The value to set for the context
|
|
341
341
|
* @returns {void}
|
|
342
342
|
*/
|
|
343
|
-
set<C extends
|
|
343
|
+
set<C extends RouterContext>(context: C, value: C extends RouterContext<infer T> ? T : never): void;
|
|
344
344
|
}
|
|
345
|
-
type DefaultContext = MiddlewareEnabled extends true ? Readonly<
|
|
345
|
+
type DefaultContext = MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : any;
|
|
346
346
|
/**
|
|
347
347
|
* @private
|
|
348
348
|
* Arguments passed to route loader/action functions. Same for now but we keep
|
|
@@ -377,7 +377,7 @@ interface DataFunctionArgs<Context> {
|
|
|
377
377
|
* Route middleware `next` function to call downstream handlers and then complete
|
|
378
378
|
* middlewares from the bottom-up
|
|
379
379
|
*/
|
|
380
|
-
interface
|
|
380
|
+
interface MiddlewareNextFunction<Result = unknown> {
|
|
381
381
|
(): Promise<Result>;
|
|
382
382
|
}
|
|
383
383
|
/**
|
|
@@ -386,7 +386,7 @@ interface unstable_MiddlewareNextFunction<Result = unknown> {
|
|
|
386
386
|
* a `next` function as the second parameter which will call downstream handlers
|
|
387
387
|
* and then complete middlewares from the bottom-up
|
|
388
388
|
*/
|
|
389
|
-
type
|
|
389
|
+
type MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<RouterContextProvider>>, next: MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
|
|
390
390
|
/**
|
|
391
391
|
* Arguments passed to loader functions
|
|
392
392
|
*/
|
|
@@ -541,7 +541,7 @@ interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctio
|
|
|
541
541
|
* Matches for this route extended with Data strategy APIs
|
|
542
542
|
*/
|
|
543
543
|
matches: DataStrategyMatch[];
|
|
544
|
-
|
|
544
|
+
runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
|
|
545
545
|
/**
|
|
546
546
|
* The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
|
|
547
547
|
* for navigational executions
|
|
@@ -586,7 +586,7 @@ type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" |
|
|
|
586
586
|
* onto the route. Either they're meaningful to the router, or they'll get
|
|
587
587
|
* ignored.
|
|
588
588
|
*/
|
|
589
|
-
type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "
|
|
589
|
+
type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "middleware";
|
|
590
590
|
/**
|
|
591
591
|
* lazy object to load route properties, which can add non-matching
|
|
592
592
|
* related properties to a route
|
|
@@ -609,7 +609,7 @@ type AgnosticBaseRouteObject = {
|
|
|
609
609
|
caseSensitive?: boolean;
|
|
610
610
|
path?: string;
|
|
611
611
|
id?: string;
|
|
612
|
-
|
|
612
|
+
middleware?: MiddlewareFunction[];
|
|
613
613
|
loader?: LoaderFunction | boolean;
|
|
614
614
|
action?: ActionFunction | boolean;
|
|
615
615
|
hasErrorBoundary?: boolean;
|
|
@@ -1160,7 +1160,7 @@ interface RouterInit {
|
|
|
1160
1160
|
routes: AgnosticRouteObject[];
|
|
1161
1161
|
history: History;
|
|
1162
1162
|
basename?: string;
|
|
1163
|
-
|
|
1163
|
+
getContext?: () => MaybePromise<RouterContextProvider>;
|
|
1164
1164
|
mapRouteProperties?: MapRoutePropertiesFunction;
|
|
1165
1165
|
future?: Partial<FutureConfig>;
|
|
1166
1166
|
hydrationRouteProperties?: string[];
|
|
@@ -1195,7 +1195,7 @@ interface StaticHandler {
|
|
|
1195
1195
|
skipLoaderErrorBubbling?: boolean;
|
|
1196
1196
|
skipRevalidation?: boolean;
|
|
1197
1197
|
dataStrategy?: DataStrategyFunction<unknown>;
|
|
1198
|
-
|
|
1198
|
+
generateMiddlewareResponse?: (query: (r: Request, args?: {
|
|
1199
1199
|
filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
|
|
1200
1200
|
}) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
|
|
1201
1201
|
}): Promise<StaticHandlerContext | Response>;
|
|
@@ -1203,7 +1203,7 @@ interface StaticHandler {
|
|
|
1203
1203
|
routeId?: string;
|
|
1204
1204
|
requestContext?: unknown;
|
|
1205
1205
|
dataStrategy?: DataStrategyFunction<unknown>;
|
|
1206
|
-
|
|
1206
|
+
generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
|
|
1207
1207
|
}): Promise<any>;
|
|
1208
1208
|
}
|
|
1209
1209
|
type ViewTransitionOpts = {
|
|
@@ -1431,11 +1431,168 @@ interface CreateStaticHandlerOptions {
|
|
|
1431
1431
|
}
|
|
1432
1432
|
declare function createStaticHandler(routes: AgnosticRouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
|
|
1433
1433
|
|
|
1434
|
+
interface AwaitResolveRenderFunction<Resolve = any> {
|
|
1435
|
+
(data: Awaited<Resolve>): React.ReactNode;
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
* @category Types
|
|
1439
|
+
*/
|
|
1440
|
+
interface AwaitProps<Resolve> {
|
|
1441
|
+
/**
|
|
1442
|
+
* When using a function, the resolved value is provided as the parameter.
|
|
1443
|
+
*
|
|
1444
|
+
* ```tsx [2]
|
|
1445
|
+
* <Await resolve={reviewsPromise}>
|
|
1446
|
+
* {(resolvedReviews) => <Reviews items={resolvedReviews} />}
|
|
1447
|
+
* </Await>
|
|
1448
|
+
* ```
|
|
1449
|
+
*
|
|
1450
|
+
* When using React elements, {@link useAsyncValue} will provide the
|
|
1451
|
+
* resolved value:
|
|
1452
|
+
*
|
|
1453
|
+
* ```tsx [2]
|
|
1454
|
+
* <Await resolve={reviewsPromise}>
|
|
1455
|
+
* <Reviews />
|
|
1456
|
+
* </Await>
|
|
1457
|
+
*
|
|
1458
|
+
* function Reviews() {
|
|
1459
|
+
* const resolvedReviews = useAsyncValue();
|
|
1460
|
+
* return <div>...</div>;
|
|
1461
|
+
* }
|
|
1462
|
+
* ```
|
|
1463
|
+
*/
|
|
1464
|
+
children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
|
|
1465
|
+
/**
|
|
1466
|
+
* The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
1467
|
+
* rejects.
|
|
1468
|
+
*
|
|
1469
|
+
* ```tsx
|
|
1470
|
+
* <Await
|
|
1471
|
+
* errorElement={<div>Oops</div>}
|
|
1472
|
+
* resolve={reviewsPromise}
|
|
1473
|
+
* >
|
|
1474
|
+
* <Reviews />
|
|
1475
|
+
* </Await>
|
|
1476
|
+
* ```
|
|
1477
|
+
*
|
|
1478
|
+
* To provide a more contextual error, you can use the {@link useAsyncError} in a
|
|
1479
|
+
* child component
|
|
1480
|
+
*
|
|
1481
|
+
* ```tsx
|
|
1482
|
+
* <Await
|
|
1483
|
+
* errorElement={<ReviewsError />}
|
|
1484
|
+
* resolve={reviewsPromise}
|
|
1485
|
+
* >
|
|
1486
|
+
* <Reviews />
|
|
1487
|
+
* </Await>
|
|
1488
|
+
*
|
|
1489
|
+
* function ReviewsError() {
|
|
1490
|
+
* const error = useAsyncError();
|
|
1491
|
+
* return <div>Error loading reviews: {error.message}</div>;
|
|
1492
|
+
* }
|
|
1493
|
+
* ```
|
|
1494
|
+
*
|
|
1495
|
+
* If you do not provide an `errorElement`, the rejected value will bubble up
|
|
1496
|
+
* to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
|
|
1497
|
+
* and be accessible via the {@link useRouteError} hook.
|
|
1498
|
+
*/
|
|
1499
|
+
errorElement?: React.ReactNode;
|
|
1500
|
+
/**
|
|
1501
|
+
* Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
1502
|
+
* returned from a [`loader`](../../start/framework/route-module#loader) to be
|
|
1503
|
+
* resolved and rendered.
|
|
1504
|
+
*
|
|
1505
|
+
* ```tsx
|
|
1506
|
+
* import { Await, useLoaderData } from "react-router";
|
|
1507
|
+
*
|
|
1508
|
+
* export async function loader() {
|
|
1509
|
+
* let reviews = getReviews(); // not awaited
|
|
1510
|
+
* let book = await getBook();
|
|
1511
|
+
* return {
|
|
1512
|
+
* book,
|
|
1513
|
+
* reviews, // this is a promise
|
|
1514
|
+
* };
|
|
1515
|
+
* }
|
|
1516
|
+
*
|
|
1517
|
+
* export default function Book() {
|
|
1518
|
+
* const {
|
|
1519
|
+
* book,
|
|
1520
|
+
* reviews, // this is the same promise
|
|
1521
|
+
* } = useLoaderData();
|
|
1522
|
+
*
|
|
1523
|
+
* return (
|
|
1524
|
+
* <div>
|
|
1525
|
+
* <h1>{book.title}</h1>
|
|
1526
|
+
* <p>{book.description}</p>
|
|
1527
|
+
* <React.Suspense fallback={<ReviewsSkeleton />}>
|
|
1528
|
+
* <Await
|
|
1529
|
+
* // and is the promise we pass to Await
|
|
1530
|
+
* resolve={reviews}
|
|
1531
|
+
* >
|
|
1532
|
+
* <Reviews />
|
|
1533
|
+
* </Await>
|
|
1534
|
+
* </React.Suspense>
|
|
1535
|
+
* </div>
|
|
1536
|
+
* );
|
|
1537
|
+
* }
|
|
1538
|
+
* ```
|
|
1539
|
+
*/
|
|
1540
|
+
resolve: Resolve;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Used to render promise values with automatic error handling.
|
|
1544
|
+
*
|
|
1545
|
+
* **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
|
|
1546
|
+
*
|
|
1547
|
+
* @example
|
|
1548
|
+
* import { Await, useLoaderData } from "react-router";
|
|
1549
|
+
*
|
|
1550
|
+
* export async function loader() {
|
|
1551
|
+
* // not awaited
|
|
1552
|
+
* const reviews = getReviews();
|
|
1553
|
+
* // awaited (blocks the transition)
|
|
1554
|
+
* const book = await fetch("/api/book").then((res) => res.json());
|
|
1555
|
+
* return { book, reviews };
|
|
1556
|
+
* }
|
|
1557
|
+
*
|
|
1558
|
+
* function Book() {
|
|
1559
|
+
* const { book, reviews } = useLoaderData();
|
|
1560
|
+
* return (
|
|
1561
|
+
* <div>
|
|
1562
|
+
* <h1>{book.title}</h1>
|
|
1563
|
+
* <p>{book.description}</p>
|
|
1564
|
+
* <React.Suspense fallback={<ReviewsSkeleton />}>
|
|
1565
|
+
* <Await
|
|
1566
|
+
* resolve={reviews}
|
|
1567
|
+
* errorElement={
|
|
1568
|
+
* <div>Could not load reviews 😬</div>
|
|
1569
|
+
* }
|
|
1570
|
+
* children={(resolvedReviews) => (
|
|
1571
|
+
* <Reviews items={resolvedReviews} />
|
|
1572
|
+
* )}
|
|
1573
|
+
* />
|
|
1574
|
+
* </React.Suspense>
|
|
1575
|
+
* </div>
|
|
1576
|
+
* );
|
|
1577
|
+
* }
|
|
1578
|
+
*
|
|
1579
|
+
* @public
|
|
1580
|
+
* @category Components
|
|
1581
|
+
* @mode framework
|
|
1582
|
+
* @mode data
|
|
1583
|
+
* @param props Props
|
|
1584
|
+
* @param {AwaitProps.children} props.children n/a
|
|
1585
|
+
* @param {AwaitProps.errorElement} props.errorElement n/a
|
|
1586
|
+
* @param {AwaitProps.resolve} props.resolve n/a
|
|
1587
|
+
* @returns React element for the rendered awaited value
|
|
1588
|
+
*/
|
|
1589
|
+
declare function Await$1<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
|
|
1590
|
+
|
|
1434
1591
|
interface IndexRouteObject {
|
|
1435
1592
|
caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
|
|
1436
1593
|
path?: AgnosticIndexRouteObject["path"];
|
|
1437
1594
|
id?: AgnosticIndexRouteObject["id"];
|
|
1438
|
-
|
|
1595
|
+
middleware?: AgnosticIndexRouteObject["middleware"];
|
|
1439
1596
|
loader?: AgnosticIndexRouteObject["loader"];
|
|
1440
1597
|
action?: AgnosticIndexRouteObject["action"];
|
|
1441
1598
|
hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
|
|
@@ -1455,7 +1612,7 @@ interface NonIndexRouteObject {
|
|
|
1455
1612
|
caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
|
|
1456
1613
|
path?: AgnosticNonIndexRouteObject["path"];
|
|
1457
1614
|
id?: AgnosticNonIndexRouteObject["id"];
|
|
1458
|
-
|
|
1615
|
+
middleware?: AgnosticNonIndexRouteObject["middleware"];
|
|
1459
1616
|
loader?: AgnosticNonIndexRouteObject["loader"];
|
|
1460
1617
|
action?: AgnosticNonIndexRouteObject["action"];
|
|
1461
1618
|
hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
|
|
@@ -1641,14 +1798,14 @@ type ClientDataFunctionArgs<Params> = {
|
|
|
1641
1798
|
**/
|
|
1642
1799
|
params: Params;
|
|
1643
1800
|
/**
|
|
1644
|
-
* When `future.
|
|
1801
|
+
* When `future.v8_middleware` is not enabled, this is undefined.
|
|
1645
1802
|
*
|
|
1646
|
-
* When `future.
|
|
1647
|
-
* `
|
|
1803
|
+
* When `future.v8_middleware` is enabled, this is an instance of
|
|
1804
|
+
* `RouterContextProvider` and can be used to access context values
|
|
1648
1805
|
* from your route middlewares. You may pass in initial context values in your
|
|
1649
|
-
* `<HydratedRouter
|
|
1806
|
+
* `<HydratedRouter getContext>` prop
|
|
1650
1807
|
*/
|
|
1651
|
-
context: Readonly<
|
|
1808
|
+
context: Readonly<RouterContextProvider>;
|
|
1652
1809
|
};
|
|
1653
1810
|
type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [
|
|
1654
1811
|
ClientLoaderFunctionArgs | ClientActionFunctionArgs | ClientDataFunctionArgs<unknown>
|
|
@@ -1813,6 +1970,7 @@ type RouteHandle = unknown;
|
|
|
1813
1970
|
declare const redirect: typeof redirect$1;
|
|
1814
1971
|
declare const redirectDocument: typeof redirectDocument$1;
|
|
1815
1972
|
declare const replace: typeof replace$1;
|
|
1973
|
+
declare const Await: typeof Await$1;
|
|
1816
1974
|
type RSCRouteConfigEntryBase = {
|
|
1817
1975
|
action?: ActionFunction;
|
|
1818
1976
|
clientAction?: ClientActionFunction;
|
|
@@ -1971,7 +2129,7 @@ type LoadServerActionFunction = (id: string) => Promise<Function>;
|
|
|
1971
2129
|
* errors that occur during the request processing.
|
|
1972
2130
|
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
1973
2131
|
* to match against.
|
|
1974
|
-
* @param opts.requestContext An instance of {@link
|
|
2132
|
+
* @param opts.requestContext An instance of {@link RouterContextProvider}
|
|
1975
2133
|
* that should be created per request, to be passed to [`action`](../../start/data/route-object#action)s,
|
|
1976
2134
|
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
|
1977
2135
|
* @param opts.routes Your {@link unstable_RSCRouteConfigEntry | route definitions}.
|
|
@@ -1985,7 +2143,7 @@ declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename,
|
|
|
1985
2143
|
decodeReply?: DecodeReplyFunction;
|
|
1986
2144
|
decodeAction?: DecodeActionFunction;
|
|
1987
2145
|
decodeFormState?: DecodeFormStateFunction;
|
|
1988
|
-
requestContext?:
|
|
2146
|
+
requestContext?: RouterContextProvider;
|
|
1989
2147
|
loadServerAction?: LoadServerActionFunction;
|
|
1990
2148
|
onError?: (error: unknown) => void;
|
|
1991
2149
|
request: Request;
|
|
@@ -1995,6 +2153,40 @@ declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename,
|
|
|
1995
2153
|
}) => Response;
|
|
1996
2154
|
}): Promise<Response>;
|
|
1997
2155
|
|
|
2156
|
+
/**
|
|
2157
|
+
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
|
|
2158
|
+
* React Router should handle this for you via type generation.
|
|
2159
|
+
*
|
|
2160
|
+
* For more on declaration merging and module augmentation, see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation .
|
|
2161
|
+
*/
|
|
2162
|
+
interface Register {
|
|
2163
|
+
}
|
|
2164
|
+
type AnyParams = Record<string, string | undefined>;
|
|
2165
|
+
type AnyPages = Record<string, {
|
|
2166
|
+
params: AnyParams;
|
|
2167
|
+
}>;
|
|
2168
|
+
type Pages = Register extends {
|
|
2169
|
+
pages: infer Registered extends AnyPages;
|
|
2170
|
+
} ? Registered : AnyPages;
|
|
2171
|
+
|
|
2172
|
+
type Args = {
|
|
2173
|
+
[K in keyof Pages]: ToArgs<Pages[K]["params"]>;
|
|
2174
|
+
};
|
|
2175
|
+
type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [
|
|
2176
|
+
Params
|
|
2177
|
+
];
|
|
2178
|
+
/**
|
|
2179
|
+
Returns a resolved URL path for the specified route.
|
|
2180
|
+
|
|
2181
|
+
```tsx
|
|
2182
|
+
const h = href("/:lang?/about", { lang: "en" })
|
|
2183
|
+
// -> `/en/about`
|
|
2184
|
+
|
|
2185
|
+
<Link to={href("/products/:id", { id: "abc123" })} />
|
|
2186
|
+
```
|
|
2187
|
+
*/
|
|
2188
|
+
declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
|
|
2189
|
+
|
|
1998
2190
|
interface CookieSignatureOptions {
|
|
1999
2191
|
/**
|
|
2000
2192
|
* An array of secrets that may be used to sign/unsign the value of a cookie.
|
|
@@ -2225,4 +2417,4 @@ interface MemorySessionStorageOptions {
|
|
|
2225
2417
|
*/
|
|
2226
2418
|
declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({ cookie }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
|
|
2227
2419
|
|
|
2228
|
-
export { type Cookie, type CookieOptions, type CookieSignatureOptions, type FlashSessionData, type IsCookieFunction, type IsSessionFunction, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isRouteErrorResponse, isSession, matchRoutes, redirect, redirectDocument, replace, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type LoadServerActionFunction as unstable_LoadServerActionFunction, type
|
|
2420
|
+
export { Await, type Cookie, type CookieOptions, type CookieSignatureOptions, type FlashSessionData, type IsCookieFunction, type IsSessionFunction, type MiddlewareFunction, type MiddlewareNextFunction, type RouterContext, RouterContextProvider, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, createContext, createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, href, isCookie, isRouteErrorResponse, isSession, matchRoutes, redirect, redirectDocument, replace, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, matchRSCServerRequest as unstable_matchRSCServerRequest };
|