react-router 7.8.2 → 7.9.0-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/development/{chunk-5UALIXAM.mjs → chunk-3TJX7VNY.mjs} +93 -57
  3. package/dist/development/{chunk-CSDGKXLR.js → chunk-4J2JOVAI.js} +135 -135
  4. package/dist/development/{chunk-PVWAREVJ.mjs → chunk-EAIS2CTK.mjs} +43 -44
  5. package/dist/development/{chunk-ZO66TDGB.js → chunk-ECJT65VE.js} +37 -38
  6. package/dist/{production/context-jKip1TFB.d.mts → development/context-BH6Jwdoy.d.mts} +39 -32
  7. package/dist/development/dom-export.d.mts +3 -3
  8. package/dist/development/dom-export.d.ts +2 -2
  9. package/dist/development/dom-export.js +14 -14
  10. package/dist/development/dom-export.mjs +14 -14
  11. package/dist/development/{index-react-server-client-DRhjXpk2.d.mts → index-react-server-client-1cWMpKk4.d.mts} +13 -13
  12. package/dist/{production/index-react-server-client-BKpa2trA.d.ts → development/index-react-server-client-CMC2eQAY.d.ts} +12 -12
  13. package/dist/development/index-react-server-client.d.mts +3 -3
  14. package/dist/development/index-react-server-client.d.ts +2 -2
  15. package/dist/development/index-react-server-client.js +4 -4
  16. package/dist/development/index-react-server-client.mjs +4 -4
  17. package/dist/development/index-react-server.d.mts +229 -37
  18. package/dist/development/index-react-server.d.ts +229 -37
  19. package/dist/development/index-react-server.js +89 -39
  20. package/dist/development/index-react-server.mjs +88 -36
  21. package/dist/development/index.d.mts +31 -24
  22. package/dist/development/index.d.ts +29 -22
  23. package/dist/development/index.js +182 -144
  24. package/dist/development/index.mjs +9 -7
  25. package/dist/development/lib/types/internal.d.mts +6 -6
  26. package/dist/development/lib/types/internal.d.ts +5 -5
  27. package/dist/development/lib/types/internal.js +1 -1
  28. package/dist/development/lib/types/internal.mjs +1 -1
  29. package/dist/development/{route-data-DAVP2QQ0.d.mts → route-data-BQkq8Erj.d.mts} +12 -12
  30. package/dist/development/{routeModules-rOzWJJ9x.d.ts → routeModules-DSKAn01V.d.ts} +175 -168
  31. package/dist/production/{chunk-REDRD2MB.mjs → chunk-47NS5WEV.mjs} +43 -44
  32. package/dist/production/{chunk-JNT5PWCQ.js → chunk-CSESPFUI.js} +135 -135
  33. package/dist/production/{chunk-Z56HUDN5.js → chunk-LQAK2UKE.js} +37 -38
  34. package/dist/production/{chunk-KWHRV2I7.mjs → chunk-SCSBSW2J.mjs} +93 -57
  35. package/dist/{development/context-jKip1TFB.d.mts → production/context-BH6Jwdoy.d.mts} +39 -32
  36. package/dist/production/dom-export.d.mts +3 -3
  37. package/dist/production/dom-export.d.ts +2 -2
  38. package/dist/production/dom-export.js +14 -14
  39. package/dist/production/dom-export.mjs +14 -14
  40. package/dist/production/{index-react-server-client-DRhjXpk2.d.mts → index-react-server-client-1cWMpKk4.d.mts} +13 -13
  41. package/dist/{development/index-react-server-client-BKpa2trA.d.ts → production/index-react-server-client-CMC2eQAY.d.ts} +12 -12
  42. package/dist/production/index-react-server-client.d.mts +3 -3
  43. package/dist/production/index-react-server-client.d.ts +2 -2
  44. package/dist/production/index-react-server-client.js +4 -4
  45. package/dist/production/index-react-server-client.mjs +4 -4
  46. package/dist/production/index-react-server.d.mts +229 -37
  47. package/dist/production/index-react-server.d.ts +229 -37
  48. package/dist/production/index-react-server.js +89 -39
  49. package/dist/production/index-react-server.mjs +88 -36
  50. package/dist/production/index.d.mts +31 -24
  51. package/dist/production/index.d.ts +29 -22
  52. package/dist/production/index.js +182 -144
  53. package/dist/production/index.mjs +9 -7
  54. package/dist/production/lib/types/internal.d.mts +6 -6
  55. package/dist/production/lib/types/internal.d.ts +5 -5
  56. package/dist/production/lib/types/internal.js +1 -1
  57. package/dist/production/lib/types/internal.mjs +1 -1
  58. package/dist/production/{route-data-DAVP2QQ0.d.mts → route-data-BQkq8Erj.d.mts} +12 -12
  59. package/dist/production/{routeModules-rOzWJJ9x.d.ts → routeModules-DSKAn01V.d.ts} +175 -168
  60. package/package.json +1 -1
@@ -1,16 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { ComponentType, ReactElement } from 'react';
3
3
 
4
- /**
5
- * An augmentable interface users can modify in their app-code to opt into
6
- * future-flag-specific types
7
- */
8
- interface Future {
9
- }
10
- type MiddlewareEnabled = Future extends {
11
- unstable_middleware: infer T extends boolean;
12
- } ? T : false;
13
-
14
4
  /**
15
5
  * Actions represent the type of change to a location value.
16
6
  */
@@ -216,6 +206,16 @@ type UrlHistoryOptions = {
216
206
  v5Compat?: boolean;
217
207
  };
218
208
 
209
+ /**
210
+ * An augmentable interface users can modify in their app-code to opt into
211
+ * future-flag-specific types
212
+ */
213
+ interface Future {
214
+ }
215
+ type MiddlewareEnabled = Future extends {
216
+ middleware: infer T extends boolean;
217
+ } ? T : false;
218
+
219
219
  type MaybePromise<T> = T | Promise<T>;
220
220
  /**
221
221
  * Map of routeId -> data returned from a loader/action/error
@@ -273,14 +273,14 @@ type Submission = {
273
273
  };
274
274
  /**
275
275
  * A context instance used as the key for the `get`/`set` methods of a
276
- * {@link unstable_RouterContextProvider}. Accepts an optional default
276
+ * {@link RouterContextProvider}. Accepts an optional default
277
277
  * value to be returned if no value has been set.
278
278
  */
279
- interface unstable_RouterContext<T = unknown> {
279
+ interface RouterContext<T = unknown> {
280
280
  defaultValue?: T;
281
281
  }
282
282
  /**
283
- * Creates a type-safe {@link unstable_RouterContext} object that can be used to
283
+ * Creates a type-safe {@link RouterContext} object that can be used to
284
284
  * store and retrieve arbitrary values in [`action`](../../start/framework/route-module#action)s,
285
285
  * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
286
286
  * Similar to React's [`createContext`](https://react.dev/reference/react/createContext),
@@ -291,11 +291,11 @@ interface unstable_RouterContext<T = unknown> {
291
291
  * when no value has been set will throw an error.
292
292
  *
293
293
  * ```tsx filename=app/context.ts
294
- * import { unstable_createContext } from "react-router";
294
+ * import { createContext } from "react-router";
295
295
  *
296
296
  * // Create a context for user data
297
297
  * export const userContext =
298
- * unstable_createContext<User | null>(null);
298
+ * createContext<User | null>(null);
299
299
  * ```
300
300
  *
301
301
  * ```tsx filename=app/middleware/auth.ts
@@ -333,23 +333,23 @@ interface unstable_RouterContext<T = unknown> {
333
333
  * @mode data
334
334
  * @param defaultValue An optional default value for the context. This value
335
335
  * will be returned if no value has been set for this context.
336
- * @returns A {@link unstable_RouterContext} object that can be used with
336
+ * @returns A {@link RouterContext} object that can be used with
337
337
  * `context.get()` and `context.set()` in [`action`](../../start/framework/route-module#action)s,
338
338
  * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
339
339
  */
340
- declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterContext<T>;
340
+ declare function createContext<T>(defaultValue?: T): RouterContext<T>;
341
341
  /**
342
342
  * Provides methods for writing/reading values in application context in a
343
343
  * type-safe way. Primarily for usage with [middleware](../../how-to/middleware).
344
344
  *
345
345
  * @example
346
346
  * import {
347
- * unstable_createContext,
348
- * unstable_RouterContextProvider
347
+ * createContext,
348
+ * RouterContextProvider
349
349
  * } from "react-router";
350
350
  *
351
- * const userContext = unstable_createContext<User | null>(null);
352
- * const contextProvider = new unstable_RouterContextProvider();
351
+ * const userContext = createContext<User | null>(null);
352
+ * const contextProvider = new RouterContextProvider();
353
353
  * contextProvider.set(userContext, getUser());
354
354
  * // ^ Type-safe
355
355
  * const user = contextProvider.get(userContext);
@@ -360,13 +360,13 @@ declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterCon
360
360
  * @mode framework
361
361
  * @mode data
362
362
  */
363
- declare class unstable_RouterContextProvider {
363
+ declare class RouterContextProvider {
364
364
  #private;
365
365
  /**
366
- * Create a new `unstable_RouterContextProvider` instance
366
+ * Create a new `RouterContextProvider` instance
367
367
  * @param init An optional initial context map to populate the provider with
368
368
  */
369
- constructor(init?: Map<unstable_RouterContext, unknown>);
369
+ constructor(init?: Map<RouterContext, unknown>);
370
370
  /**
371
371
  * Access a value from the context. If no value has been set for the context,
372
372
  * it will return the context's `defaultValue` if provided, or throw an error
@@ -375,7 +375,7 @@ declare class unstable_RouterContextProvider {
375
375
  * @returns The value for the context, or the context's `defaultValue` if no
376
376
  * value was set
377
377
  */
378
- get<T>(context: unstable_RouterContext<T>): T;
378
+ get<T>(context: RouterContext<T>): T;
379
379
  /**
380
380
  * Set a value for the context. If the context already has a value set, this
381
381
  * will overwrite it.
@@ -384,9 +384,9 @@ declare class unstable_RouterContextProvider {
384
384
  * @param value The value to set for the context
385
385
  * @returns {void}
386
386
  */
387
- set<C extends unstable_RouterContext>(context: C, value: C extends unstable_RouterContext<infer T> ? T : never): void;
387
+ set<C extends RouterContext>(context: C, value: C extends RouterContext<infer T> ? T : never): void;
388
388
  }
389
- type DefaultContext = MiddlewareEnabled extends true ? Readonly<unstable_RouterContextProvider> : any;
389
+ type DefaultContext = MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : any;
390
390
  /**
391
391
  * @private
392
392
  * Arguments passed to route loader/action functions. Same for now but we keep
@@ -421,7 +421,7 @@ interface DataFunctionArgs<Context> {
421
421
  * Route middleware `next` function to call downstream handlers and then complete
422
422
  * middlewares from the bottom-up
423
423
  */
424
- interface unstable_MiddlewareNextFunction<Result = unknown> {
424
+ interface MiddlewareNextFunction<Result = unknown> {
425
425
  (): Promise<Result>;
426
426
  }
427
427
  /**
@@ -430,7 +430,7 @@ interface unstable_MiddlewareNextFunction<Result = unknown> {
430
430
  * a `next` function as the second parameter which will call downstream handlers
431
431
  * and then complete middlewares from the bottom-up
432
432
  */
433
- type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<unstable_RouterContextProvider>>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
433
+ type MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<RouterContextProvider>>, next: MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
434
434
  /**
435
435
  * Arguments passed to loader functions
436
436
  */
@@ -585,7 +585,7 @@ interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctio
585
585
  * Matches for this route extended with Data strategy APIs
586
586
  */
587
587
  matches: DataStrategyMatch[];
588
- unstable_runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
588
+ runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
589
589
  /**
590
590
  * The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
591
591
  * for navigational executions
@@ -630,7 +630,7 @@ type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" |
630
630
  * onto the route. Either they're meaningful to the router, or they'll get
631
631
  * ignored.
632
632
  */
633
- type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "unstable_middleware";
633
+ type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "middleware";
634
634
  /**
635
635
  * lazy object to load route properties, which can add non-matching
636
636
  * related properties to a route
@@ -653,7 +653,7 @@ type AgnosticBaseRouteObject = {
653
653
  caseSensitive?: boolean;
654
654
  path?: string;
655
655
  id?: string;
656
- unstable_middleware?: unstable_MiddlewareFunction[];
656
+ middleware?: MiddlewareFunction[];
657
657
  loader?: LoaderFunction | boolean;
658
658
  action?: ActionFunction | boolean;
659
659
  hasErrorBoundary?: boolean;
@@ -903,6 +903,11 @@ declare class DataWithResponseInit<D> {
903
903
  * response init.
904
904
  */
905
905
  declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
906
+ interface TrackedPromise extends Promise<any> {
907
+ _tracked?: boolean;
908
+ _data?: any;
909
+ _error?: any;
910
+ }
906
911
  type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
907
912
  /**
908
913
  * A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
@@ -1308,7 +1313,7 @@ interface RouterInit {
1308
1313
  routes: AgnosticRouteObject[];
1309
1314
  history: History;
1310
1315
  basename?: string;
1311
- unstable_getContext?: () => MaybePromise<unstable_RouterContextProvider>;
1316
+ getContext?: () => MaybePromise<RouterContextProvider>;
1312
1317
  mapRouteProperties?: MapRoutePropertiesFunction;
1313
1318
  future?: Partial<FutureConfig>;
1314
1319
  hydrationRouteProperties?: string[];
@@ -1343,7 +1348,7 @@ interface StaticHandler {
1343
1348
  skipLoaderErrorBubbling?: boolean;
1344
1349
  skipRevalidation?: boolean;
1345
1350
  dataStrategy?: DataStrategyFunction<unknown>;
1346
- unstable_generateMiddlewareResponse?: (query: (r: Request, args?: {
1351
+ generateMiddlewareResponse?: (query: (r: Request, args?: {
1347
1352
  filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
1348
1353
  }) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
1349
1354
  }): Promise<StaticHandlerContext | Response>;
@@ -1351,7 +1356,7 @@ interface StaticHandler {
1351
1356
  routeId?: string;
1352
1357
  requestContext?: unknown;
1353
1358
  dataStrategy?: DataStrategyFunction<unknown>;
1354
- unstable_generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
1359
+ generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
1355
1360
  }): Promise<any>;
1356
1361
  }
1357
1362
  type ViewTransitionOpts = {
@@ -1585,124 +1590,6 @@ interface CreateStaticHandlerOptions {
1585
1590
  future?: {};
1586
1591
  }
1587
1592
 
1588
- interface IndexRouteObject {
1589
- caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
1590
- path?: AgnosticIndexRouteObject["path"];
1591
- id?: AgnosticIndexRouteObject["id"];
1592
- unstable_middleware?: AgnosticIndexRouteObject["unstable_middleware"];
1593
- loader?: AgnosticIndexRouteObject["loader"];
1594
- action?: AgnosticIndexRouteObject["action"];
1595
- hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
1596
- shouldRevalidate?: AgnosticIndexRouteObject["shouldRevalidate"];
1597
- handle?: AgnosticIndexRouteObject["handle"];
1598
- index: true;
1599
- children?: undefined;
1600
- element?: React.ReactNode | null;
1601
- hydrateFallbackElement?: React.ReactNode | null;
1602
- errorElement?: React.ReactNode | null;
1603
- Component?: React.ComponentType | null;
1604
- HydrateFallback?: React.ComponentType | null;
1605
- ErrorBoundary?: React.ComponentType | null;
1606
- lazy?: LazyRouteDefinition<RouteObject>;
1607
- }
1608
- interface NonIndexRouteObject {
1609
- caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
1610
- path?: AgnosticNonIndexRouteObject["path"];
1611
- id?: AgnosticNonIndexRouteObject["id"];
1612
- unstable_middleware?: AgnosticNonIndexRouteObject["unstable_middleware"];
1613
- loader?: AgnosticNonIndexRouteObject["loader"];
1614
- action?: AgnosticNonIndexRouteObject["action"];
1615
- hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
1616
- shouldRevalidate?: AgnosticNonIndexRouteObject["shouldRevalidate"];
1617
- handle?: AgnosticNonIndexRouteObject["handle"];
1618
- index?: false;
1619
- children?: RouteObject[];
1620
- element?: React.ReactNode | null;
1621
- hydrateFallbackElement?: React.ReactNode | null;
1622
- errorElement?: React.ReactNode | null;
1623
- Component?: React.ComponentType | null;
1624
- HydrateFallback?: React.ComponentType | null;
1625
- ErrorBoundary?: React.ComponentType | null;
1626
- lazy?: LazyRouteDefinition<RouteObject>;
1627
- }
1628
- type RouteObject = IndexRouteObject | NonIndexRouteObject;
1629
- type DataRouteObject = RouteObject & {
1630
- children?: DataRouteObject[];
1631
- id: string;
1632
- };
1633
- interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> extends AgnosticRouteMatch<ParamKey, RouteObjectType> {
1634
- }
1635
- interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
1636
- }
1637
- type PatchRoutesOnNavigationFunctionArgs = AgnosticPatchRoutesOnNavigationFunctionArgs<RouteObject, RouteMatch>;
1638
- type PatchRoutesOnNavigationFunction = AgnosticPatchRoutesOnNavigationFunction<RouteObject, RouteMatch>;
1639
- interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
1640
- router: Router$1;
1641
- staticContext?: StaticHandlerContext;
1642
- unstable_onError?: unstable_ClientOnErrorFunction;
1643
- }
1644
- declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
1645
- declare const DataRouterStateContext: React.Context<RouterState | null>;
1646
- type ViewTransitionContextObject = {
1647
- isTransitioning: false;
1648
- } | {
1649
- isTransitioning: true;
1650
- flushSync: boolean;
1651
- currentLocation: Location;
1652
- nextLocation: Location;
1653
- };
1654
- declare const ViewTransitionContext: React.Context<ViewTransitionContextObject>;
1655
- type FetchersContextObject = Map<string, any>;
1656
- declare const FetchersContext: React.Context<FetchersContextObject>;
1657
- interface NavigateOptions {
1658
- /** Replace the current entry in the history stack instead of pushing a new one */
1659
- replace?: boolean;
1660
- /** Adds persistent client side routing state to the next location */
1661
- state?: any;
1662
- /** If you are using {@link https://api.reactrouter.com/v7/functions/react_router.ScrollRestoration.html <ScrollRestoration>}, prevent the scroll position from being reset to the top of the window when navigating */
1663
- preventScrollReset?: boolean;
1664
- /** Defines the relative path behavior for the link. "route" will use the route hierarchy so ".." will remove all URL segments of the current route pattern while "path" will use the URL path so ".." will remove one URL segment. */
1665
- relative?: RelativeRoutingType;
1666
- /** Wraps the initial state update for this navigation in a {@link https://react.dev/reference/react-dom/flushSync ReactDOM.flushSync} call instead of the default {@link https://react.dev/reference/react/startTransition React.startTransition} */
1667
- flushSync?: boolean;
1668
- /** Enables a {@link https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API View Transition} for this navigation by wrapping the final state update in `document.startViewTransition()`. If you need to apply specific styles for this view transition, you will also need to leverage the {@link https://api.reactrouter.com/v7/functions/react_router.useViewTransitionState.html useViewTransitionState()} hook. */
1669
- viewTransition?: boolean;
1670
- }
1671
- /**
1672
- * A Navigator is a "location changer"; it's how you get to different locations.
1673
- *
1674
- * Every history instance conforms to the Navigator interface, but the
1675
- * distinction is useful primarily when it comes to the low-level `<Router>` API
1676
- * where both the location and a navigator must be provided separately in order
1677
- * to avoid "tearing" that may occur in a suspense-enabled app if the action
1678
- * and/or location were to be read directly from the history instance.
1679
- */
1680
- interface Navigator {
1681
- createHref: History["createHref"];
1682
- encodeLocation?: History["encodeLocation"];
1683
- go: History["go"];
1684
- push(to: To, state?: any, opts?: NavigateOptions): void;
1685
- replace(to: To, state?: any, opts?: NavigateOptions): void;
1686
- }
1687
- interface NavigationContextObject {
1688
- basename: string;
1689
- navigator: Navigator;
1690
- static: boolean;
1691
- future: {};
1692
- }
1693
- declare const NavigationContext: React.Context<NavigationContextObject>;
1694
- interface LocationContextObject {
1695
- location: Location;
1696
- navigationType: Action;
1697
- }
1698
- declare const LocationContext: React.Context<LocationContextObject>;
1699
- interface RouteContextObject {
1700
- outlet: React.ReactElement | null;
1701
- matches: RouteMatch[];
1702
- isDataRoute: boolean;
1703
- }
1704
- declare const RouteContext: React.Context<RouteContextObject>;
1705
-
1706
1593
  declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
1707
1594
  hasErrorBoundary: boolean;
1708
1595
  };
@@ -1716,13 +1603,13 @@ interface MemoryRouterOpts {
1716
1603
  */
1717
1604
  basename?: string;
1718
1605
  /**
1719
- * A function that returns an {@link unstable_RouterContextProvider} instance
1606
+ * A function that returns an {@link RouterContextProvider} instance
1720
1607
  * which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
1721
1608
  * [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
1722
1609
  * This function is called to generate a fresh `context` instance on each
1723
1610
  * navigation or fetcher call.
1724
1611
  */
1725
- unstable_getContext?: RouterInit["unstable_getContext"];
1612
+ getContext?: RouterInit["getContext"];
1726
1613
  /**
1727
1614
  * Future flags to enable for the router.
1728
1615
  */
@@ -1763,7 +1650,7 @@ interface MemoryRouterOpts {
1763
1650
  * @param {MemoryRouterOpts.basename} opts.basename n/a
1764
1651
  * @param {MemoryRouterOpts.dataStrategy} opts.dataStrategy n/a
1765
1652
  * @param {MemoryRouterOpts.future} opts.future n/a
1766
- * @param {MemoryRouterOpts.unstable_getContext} opts.unstable_getContext n/a
1653
+ * @param {MemoryRouterOpts.getContext} opts.getContext n/a
1767
1654
  * @param {MemoryRouterOpts.hydrationData} opts.hydrationData n/a
1768
1655
  * @param {MemoryRouterOpts.initialEntries} opts.initialEntries n/a
1769
1656
  * @param {MemoryRouterOpts.initialIndex} opts.initialIndex n/a
@@ -2539,6 +2426,126 @@ declare function withErrorBoundaryProps(ErrorBoundary: ErrorBoundaryType): () =>
2539
2426
  error: unknown;
2540
2427
  }, string | React.JSXElementConstructor<any>>;
2541
2428
 
2429
+ interface IndexRouteObject {
2430
+ caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
2431
+ path?: AgnosticIndexRouteObject["path"];
2432
+ id?: AgnosticIndexRouteObject["id"];
2433
+ middleware?: AgnosticIndexRouteObject["middleware"];
2434
+ loader?: AgnosticIndexRouteObject["loader"];
2435
+ action?: AgnosticIndexRouteObject["action"];
2436
+ hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
2437
+ shouldRevalidate?: AgnosticIndexRouteObject["shouldRevalidate"];
2438
+ handle?: AgnosticIndexRouteObject["handle"];
2439
+ index: true;
2440
+ children?: undefined;
2441
+ element?: React.ReactNode | null;
2442
+ hydrateFallbackElement?: React.ReactNode | null;
2443
+ errorElement?: React.ReactNode | null;
2444
+ Component?: React.ComponentType | null;
2445
+ HydrateFallback?: React.ComponentType | null;
2446
+ ErrorBoundary?: React.ComponentType | null;
2447
+ lazy?: LazyRouteDefinition<RouteObject>;
2448
+ }
2449
+ interface NonIndexRouteObject {
2450
+ caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
2451
+ path?: AgnosticNonIndexRouteObject["path"];
2452
+ id?: AgnosticNonIndexRouteObject["id"];
2453
+ middleware?: AgnosticNonIndexRouteObject["middleware"];
2454
+ loader?: AgnosticNonIndexRouteObject["loader"];
2455
+ action?: AgnosticNonIndexRouteObject["action"];
2456
+ hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
2457
+ shouldRevalidate?: AgnosticNonIndexRouteObject["shouldRevalidate"];
2458
+ handle?: AgnosticNonIndexRouteObject["handle"];
2459
+ index?: false;
2460
+ children?: RouteObject[];
2461
+ element?: React.ReactNode | null;
2462
+ hydrateFallbackElement?: React.ReactNode | null;
2463
+ errorElement?: React.ReactNode | null;
2464
+ Component?: React.ComponentType | null;
2465
+ HydrateFallback?: React.ComponentType | null;
2466
+ ErrorBoundary?: React.ComponentType | null;
2467
+ lazy?: LazyRouteDefinition<RouteObject>;
2468
+ }
2469
+ type RouteObject = IndexRouteObject | NonIndexRouteObject;
2470
+ type DataRouteObject = RouteObject & {
2471
+ children?: DataRouteObject[];
2472
+ id: string;
2473
+ };
2474
+ interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> extends AgnosticRouteMatch<ParamKey, RouteObjectType> {
2475
+ }
2476
+ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
2477
+ }
2478
+ type PatchRoutesOnNavigationFunctionArgs = AgnosticPatchRoutesOnNavigationFunctionArgs<RouteObject, RouteMatch>;
2479
+ type PatchRoutesOnNavigationFunction = AgnosticPatchRoutesOnNavigationFunction<RouteObject, RouteMatch>;
2480
+ interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
2481
+ router: Router$1;
2482
+ staticContext?: StaticHandlerContext;
2483
+ unstable_onError?: unstable_ClientOnErrorFunction;
2484
+ }
2485
+ declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
2486
+ declare const DataRouterStateContext: React.Context<RouterState | null>;
2487
+ type ViewTransitionContextObject = {
2488
+ isTransitioning: false;
2489
+ } | {
2490
+ isTransitioning: true;
2491
+ flushSync: boolean;
2492
+ currentLocation: Location;
2493
+ nextLocation: Location;
2494
+ };
2495
+ declare const ViewTransitionContext: React.Context<ViewTransitionContextObject>;
2496
+ type FetchersContextObject = Map<string, any>;
2497
+ declare const FetchersContext: React.Context<FetchersContextObject>;
2498
+ declare const AwaitContext: React.Context<TrackedPromise | null>;
2499
+ declare const AwaitContextProvider: (props: React.ComponentProps<typeof AwaitContext.Provider>) => React.FunctionComponentElement<React.ProviderProps<TrackedPromise | null>>;
2500
+ interface NavigateOptions {
2501
+ /** Replace the current entry in the history stack instead of pushing a new one */
2502
+ replace?: boolean;
2503
+ /** Adds persistent client side routing state to the next location */
2504
+ state?: any;
2505
+ /** If you are using {@link https://api.reactrouter.com/v7/functions/react_router.ScrollRestoration.html <ScrollRestoration>}, prevent the scroll position from being reset to the top of the window when navigating */
2506
+ preventScrollReset?: boolean;
2507
+ /** Defines the relative path behavior for the link. "route" will use the route hierarchy so ".." will remove all URL segments of the current route pattern while "path" will use the URL path so ".." will remove one URL segment. */
2508
+ relative?: RelativeRoutingType;
2509
+ /** Wraps the initial state update for this navigation in a {@link https://react.dev/reference/react-dom/flushSync ReactDOM.flushSync} call instead of the default {@link https://react.dev/reference/react/startTransition React.startTransition} */
2510
+ flushSync?: boolean;
2511
+ /** Enables a {@link https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API View Transition} for this navigation by wrapping the final state update in `document.startViewTransition()`. If you need to apply specific styles for this view transition, you will also need to leverage the {@link https://api.reactrouter.com/v7/functions/react_router.useViewTransitionState.html useViewTransitionState()} hook. */
2512
+ viewTransition?: boolean;
2513
+ }
2514
+ /**
2515
+ * A Navigator is a "location changer"; it's how you get to different locations.
2516
+ *
2517
+ * Every history instance conforms to the Navigator interface, but the
2518
+ * distinction is useful primarily when it comes to the low-level `<Router>` API
2519
+ * where both the location and a navigator must be provided separately in order
2520
+ * to avoid "tearing" that may occur in a suspense-enabled app if the action
2521
+ * and/or location were to be read directly from the history instance.
2522
+ */
2523
+ interface Navigator {
2524
+ createHref: History["createHref"];
2525
+ encodeLocation?: History["encodeLocation"];
2526
+ go: History["go"];
2527
+ push(to: To, state?: any, opts?: NavigateOptions): void;
2528
+ replace(to: To, state?: any, opts?: NavigateOptions): void;
2529
+ }
2530
+ interface NavigationContextObject {
2531
+ basename: string;
2532
+ navigator: Navigator;
2533
+ static: boolean;
2534
+ future: {};
2535
+ }
2536
+ declare const NavigationContext: React.Context<NavigationContextObject>;
2537
+ interface LocationContextObject {
2538
+ location: Location;
2539
+ navigationType: Action;
2540
+ }
2541
+ declare const LocationContext: React.Context<LocationContextObject>;
2542
+ interface RouteContextObject {
2543
+ outlet: React.ReactElement | null;
2544
+ matches: RouteMatch[];
2545
+ isDataRoute: boolean;
2546
+ }
2547
+ declare const RouteContext: React.Context<RouteContextObject>;
2548
+
2542
2549
  type Primitive = null | undefined | string | number | boolean | symbol | bigint;
2543
2550
  type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
2544
2551
  interface HtmlLinkProps {
@@ -2735,14 +2742,14 @@ type ClientDataFunctionArgs<Params> = {
2735
2742
  **/
2736
2743
  params: Params;
2737
2744
  /**
2738
- * When `future.unstable_middleware` is not enabled, this is undefined.
2745
+ * When `future.v8_middleware` is not enabled, this is undefined.
2739
2746
  *
2740
- * When `future.unstable_middleware` is enabled, this is an instance of
2741
- * `unstable_RouterContextProvider` and can be used to access context values
2747
+ * When `future.v8_middleware` is enabled, this is an instance of
2748
+ * `RouterContextProvider` and can be used to access context values
2742
2749
  * from your route middlewares. You may pass in initial context values in your
2743
- * `<HydratedRouter unstable_getContext>` prop
2750
+ * `<HydratedRouter getContext>` prop
2744
2751
  */
2745
- context: Readonly<unstable_RouterContextProvider>;
2752
+ context: Readonly<RouterContextProvider>;
2746
2753
  };
2747
2754
  type ServerDataFunctionArgs<Params> = {
2748
2755
  /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
@@ -2763,18 +2770,18 @@ type ServerDataFunctionArgs<Params> = {
2763
2770
  **/
2764
2771
  params: Params;
2765
2772
  /**
2766
- * Without `future.unstable_middleware` enabled, this is the context passed in
2773
+ * Without `future.v8_middleware` enabled, this is the context passed in
2767
2774
  * to your server adapter's `getLoadContext` function. It's a way to bridge the
2768
2775
  * gap between the adapter's request/response API with your React Router app.
2769
2776
  * It is only applicable if you are using a custom server adapter.
2770
2777
  *
2771
- * With `future.unstable_middleware` enabled, this is an instance of
2772
- * `unstable_RouterContextProvider` and can be used for type-safe access to
2778
+ * With `future.v8_middleware` enabled, this is an instance of
2779
+ * `RouterContextProvider` and can be used for type-safe access to
2773
2780
  * context value set in your route middlewares. If you are using a custom
2774
2781
  * server adapter, you may provide an initial set of context values from your
2775
2782
  * `getLoadContext` function.
2776
2783
  */
2777
- context: MiddlewareEnabled extends true ? Readonly<unstable_RouterContextProvider> : AppLoadContext;
2784
+ context: MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : AppLoadContext;
2778
2785
  };
2779
2786
  type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [
2780
2787
  ClientLoaderFunctionArgs | ClientActionFunctionArgs | ClientDataFunctionArgs<unknown>
@@ -2810,7 +2817,7 @@ interface RouteModules {
2810
2817
  interface RouteModule {
2811
2818
  clientAction?: ClientActionFunction;
2812
2819
  clientLoader?: ClientLoaderFunction;
2813
- unstable_clientMiddleware?: unstable_MiddlewareFunction<Record<string, DataStrategyResult>>[];
2820
+ clientMiddleware?: MiddlewareFunction<Record<string, DataStrategyResult>>[];
2814
2821
  ErrorBoundary?: ErrorBoundaryComponent;
2815
2822
  HydrateFallback?: HydrateFallbackComponent;
2816
2823
  Layout?: LayoutComponent;
@@ -2829,7 +2836,7 @@ interface ServerRouteModule extends RouteModule {
2829
2836
  [name: string]: string;
2830
2837
  };
2831
2838
  loader?: LoaderFunction;
2832
- unstable_middleware?: unstable_MiddlewareFunction<Response>[];
2839
+ middleware?: MiddlewareFunction<Response>[];
2833
2840
  }
2834
2841
  /**
2835
2842
  * A function that handles data mutations for a route on the client
@@ -3008,4 +3015,4 @@ type RouteComponent = ComponentType<{}>;
3008
3015
  */
3009
3016
  type RouteHandle = unknown;
3010
3017
 
3011
- export { type PatchRoutesOnNavigationFunction as $, Action as A, type BlockerFunction as B, type ClientDataFunctionArgs as C, type DataStrategyResult as D, type ErrorBoundaryType as E, type Func as F, type GetLoaderData as G, type HydrationState as H, type InitialEntry as I, type AppLoadContext as J, unstable_RouterContextProvider as K, type LinkDescriptor as L, type MetaDescriptor as M, type Normalize as N, type MiddlewareEnabled as O, type Pretty as P, type Equal as Q, type RouteModule$1 as R, type ServerDataFunctionArgs as S, type To as T, type UIMatch as U, type ClientActionFunction as V, type ClientLoaderFunction as W, type HeadersFunction as X, type ShouldRevalidateFunction as Y, type RouterInit as Z, type RouterState as _, type Location as a, Router as a$, type DataRouteObject as a0, type StaticHandler as a1, type GetScrollPositionFunction as a2, type GetScrollRestorationKeyFunction as a3, type StaticHandlerContext as a4, type Fetcher as a5, type NavigationStates as a6, type RouterSubscriber as a7, type RouterNavigateOptions as a8, type RouterFetchOptions as a9, matchRoutes as aA, redirect as aB, redirectDocument as aC, replace as aD, resolvePath as aE, type DataRouteMatch as aF, type Navigator as aG, type PatchRoutesOnNavigationFunctionArgs as aH, type RouteMatch as aI, type AwaitProps as aJ, type IndexRouteProps as aK, type unstable_ClientOnErrorFunction as aL, type LayoutRouteProps as aM, type MemoryRouterOpts as aN, type MemoryRouterProps as aO, type NavigateProps as aP, type OutletProps as aQ, type PathRouteProps as aR, type RouteProps as aS, type RouterProps as aT, type RouterProviderProps as aU, type RoutesProps as aV, Await as aW, MemoryRouter as aX, Navigate as aY, Outlet as aZ, Route as a_, type RevalidationState as aa, type ActionFunctionArgs as ab, type DataStrategyFunctionArgs as ac, type DataStrategyMatch as ad, DataWithResponseInit as ae, type ErrorResponse as af, type FormEncType as ag, type FormMethod as ah, type HTMLFormMethod as ai, type LazyRouteFunction as aj, type LoaderFunctionArgs as ak, type unstable_MiddlewareFunction as al, type PathParam as am, type RedirectFunction as an, type unstable_RouterContext as ao, type ShouldRevalidateFunctionArgs as ap, unstable_createContext as aq, createPath as ar, parsePath as as, IDLE_NAVIGATION as at, IDLE_FETCHER as au, IDLE_BLOCKER as av, data as aw, generatePath as ax, isRouteErrorResponse as ay, matchPath as az, type ServerDataFrom as b, RouterProvider as b0, Routes as b1, createMemoryRouter as b2, createRoutesFromChildren as b3, createRoutesFromElements as b4, renderMatches as b5, type ClientActionFunctionArgs as b6, type ClientLoaderFunctionArgs as b7, type HeadersArgs as b8, type MetaArgs as b9, type FutureConfig as bA, type CreateStaticHandlerOptions as bB, type PageLinkDescriptor as ba, type HtmlLinkDescriptor as bb, type Future as bc, type unstable_SerializesTo as bd, createBrowserHistory as be, invariant as bf, createRouter as bg, ErrorResponseImpl as bh, DataRouterContext as bi, DataRouterStateContext as bj, FetchersContext as bk, LocationContext as bl, NavigationContext as bm, RouteContext as bn, ViewTransitionContext as bo, hydrationRouteProperties as bp, mapRouteProperties as bq, WithComponentProps as br, withComponentProps as bs, WithHydrateFallbackProps as bt, withHydrateFallbackProps as bu, WithErrorBoundaryProps as bv, withErrorBoundaryProps as bw, type RouteManifest as bx, type ServerRouteModule as by, type History as bz, type GetActionData as c, type Router$1 as d, type RouteModules as e, type DataStrategyFunction as f, type NavigateOptions as g, type Blocker as h, type SerializeFrom as i, type RelativeRoutingType as j, type ParamParseKey as k, type Path as l, type PathPattern as m, type PathMatch as n, type Navigation as o, type Params as p, type RouteObject as q, type IndexRouteObject as r, type RouteComponentType as s, type HydrateFallbackType as t, type unstable_MiddlewareNextFunction as u, type LoaderFunction as v, type ActionFunction as w, type MetaFunction as x, type LinksFunction as y, type NonIndexRouteObject as z };
3018
+ export { type PatchRoutesOnNavigationFunction as $, Action as A, type BlockerFunction as B, type ClientDataFunctionArgs as C, type DataStrategyResult as D, type ErrorBoundaryType as E, type Func as F, type GetLoaderData as G, type HydrationState as H, type InitialEntry as I, type AppLoadContext as J, RouterContextProvider as K, type LinkDescriptor as L, type MetaDescriptor as M, type Normalize as N, type MiddlewareEnabled as O, type Pretty as P, type Equal as Q, type RouteModule$1 as R, type ServerDataFunctionArgs as S, type To as T, type UIMatch as U, type ClientActionFunction as V, type ClientLoaderFunction as W, type HeadersFunction as X, type ShouldRevalidateFunction as Y, type RouterInit as Z, type RouterState as _, type Location as a, Route as a$, type DataRouteObject as a0, type StaticHandler as a1, type GetScrollPositionFunction as a2, type GetScrollRestorationKeyFunction as a3, type StaticHandlerContext as a4, type Fetcher as a5, type NavigationStates as a6, type RouterSubscriber as a7, type RouterNavigateOptions as a8, type RouterFetchOptions as a9, matchRoutes as aA, redirect as aB, redirectDocument as aC, replace as aD, resolvePath as aE, type DataRouteMatch as aF, type Navigator as aG, type PatchRoutesOnNavigationFunctionArgs as aH, type RouteMatch as aI, AwaitContextProvider as aJ, type AwaitProps as aK, type IndexRouteProps as aL, type unstable_ClientOnErrorFunction as aM, type LayoutRouteProps as aN, type MemoryRouterOpts as aO, type MemoryRouterProps as aP, type NavigateProps as aQ, type OutletProps as aR, type PathRouteProps as aS, type RouteProps as aT, type RouterProps as aU, type RouterProviderProps as aV, type RoutesProps as aW, Await as aX, MemoryRouter as aY, Navigate as aZ, Outlet as a_, type RevalidationState as aa, type ActionFunctionArgs as ab, type DataStrategyFunctionArgs as ac, type DataStrategyMatch as ad, DataWithResponseInit as ae, type ErrorResponse as af, type FormEncType as ag, type FormMethod as ah, type HTMLFormMethod as ai, type LazyRouteFunction as aj, type LoaderFunctionArgs as ak, type MiddlewareFunction as al, type PathParam as am, type RedirectFunction as an, type RouterContext as ao, type ShouldRevalidateFunctionArgs as ap, createContext as aq, createPath as ar, parsePath as as, IDLE_NAVIGATION as at, IDLE_FETCHER as au, IDLE_BLOCKER as av, data as aw, generatePath as ax, isRouteErrorResponse as ay, matchPath as az, type MiddlewareNextFunction as b, Router as b0, RouterProvider as b1, Routes as b2, createMemoryRouter as b3, createRoutesFromChildren as b4, createRoutesFromElements as b5, renderMatches as b6, type ClientActionFunctionArgs as b7, type ClientLoaderFunctionArgs as b8, type HeadersArgs as b9, type History as bA, type FutureConfig as bB, type CreateStaticHandlerOptions as bC, type MetaArgs as ba, type PageLinkDescriptor as bb, type HtmlLinkDescriptor as bc, type Future as bd, type unstable_SerializesTo as be, createBrowserHistory as bf, invariant as bg, createRouter as bh, ErrorResponseImpl as bi, DataRouterContext as bj, DataRouterStateContext as bk, FetchersContext as bl, LocationContext as bm, NavigationContext as bn, RouteContext as bo, ViewTransitionContext as bp, hydrationRouteProperties as bq, mapRouteProperties as br, WithComponentProps as bs, withComponentProps as bt, WithHydrateFallbackProps as bu, withHydrateFallbackProps as bv, WithErrorBoundaryProps as bw, withErrorBoundaryProps as bx, type RouteManifest as by, type ServerRouteModule as bz, type ServerDataFrom as c, type GetActionData as d, type Router$1 as e, type RouteModules as f, type DataStrategyFunction as g, type NavigateOptions as h, type Blocker as i, type SerializeFrom as j, type RelativeRoutingType as k, type ParamParseKey as l, type Path as m, type PathPattern as n, type PathMatch as o, type Navigation as p, type Params as q, type RouteObject as r, type IndexRouteObject as s, type RouteComponentType as t, type HydrateFallbackType as u, type LoaderFunction as v, type ActionFunction as w, type MetaFunction as x, type LinksFunction as y, type NonIndexRouteObject as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router",
3
- "version": "7.8.2",
3
+ "version": "7.9.0-pre.0",
4
4
  "description": "Declarative routing for React",
5
5
  "keywords": [
6
6
  "react",