react-router 7.8.0 → 7.8.1-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 (54) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/development/{chunk-VC6RBZTR.js → chunk-3JLHOGU7.js} +130 -130
  3. package/dist/development/{chunk-EVX7OBGB.js → chunk-CXAO7FY7.js} +70 -47
  4. package/dist/{production/chunk-XPGU3ZMH.mjs → development/chunk-V2P3SFSY.mjs} +147 -33
  5. package/dist/development/{chunk-ZYFC6VSF.mjs → chunk-WKLBIS42.mjs} +34 -11
  6. package/dist/development/dom-export.js +3 -3
  7. package/dist/development/dom-export.mjs +3 -3
  8. package/dist/{production/index-react-server-client-DXb0OgpJ.d.mts → development/index-react-server-client-11fLy3qB.d.mts} +1 -1
  9. package/dist/development/{index-react-server-client-CMphySRb.d.ts → index-react-server-client-BQ6FxdA_.d.ts} +1 -1
  10. package/dist/development/index-react-server-client.d.mts +2 -2
  11. package/dist/development/index-react-server-client.d.ts +2 -2
  12. package/dist/development/index-react-server-client.js +4 -4
  13. package/dist/development/index-react-server-client.mjs +2 -2
  14. package/dist/development/index-react-server.d.mts +38 -1
  15. package/dist/development/index-react-server.d.ts +38 -1
  16. package/dist/development/index-react-server.js +28 -9
  17. package/dist/development/index-react-server.mjs +28 -10
  18. package/dist/development/index.d.mts +42 -4
  19. package/dist/development/index.d.ts +42 -4
  20. package/dist/development/index.js +242 -128
  21. package/dist/development/index.mjs +3 -3
  22. package/dist/development/lib/types/internal.d.mts +6 -3
  23. package/dist/development/lib/types/internal.d.ts +6 -3
  24. package/dist/development/lib/types/internal.js +1 -1
  25. package/dist/development/lib/types/internal.mjs +1 -1
  26. package/dist/development/{route-data-CpB5xtMm.d.mts → route-data-CNjObrhZ.d.mts} +1 -1
  27. package/dist/development/{routeModules-qBivMBjd.d.ts → routeModules-C3oqzPpI.d.ts} +1 -1
  28. package/dist/production/{chunk-O6DRQPUD.js → chunk-6K5ETUFZ.js} +130 -130
  29. package/dist/production/{chunk-SIHON65V.mjs → chunk-GIJZ6O2U.mjs} +34 -11
  30. package/dist/production/{chunk-BOD6JCOU.js → chunk-ZFXTWIWH.js} +70 -47
  31. package/dist/{development/chunk-HZX6U7MI.mjs → production/chunk-ZKLGVTLT.mjs} +147 -33
  32. package/dist/production/dom-export.js +3 -3
  33. package/dist/production/dom-export.mjs +3 -3
  34. package/dist/{development/index-react-server-client-DXb0OgpJ.d.mts → production/index-react-server-client-11fLy3qB.d.mts} +1 -1
  35. package/dist/production/{index-react-server-client-CMphySRb.d.ts → index-react-server-client-BQ6FxdA_.d.ts} +1 -1
  36. package/dist/production/index-react-server-client.d.mts +2 -2
  37. package/dist/production/index-react-server-client.d.ts +2 -2
  38. package/dist/production/index-react-server-client.js +4 -4
  39. package/dist/production/index-react-server-client.mjs +2 -2
  40. package/dist/production/index-react-server.d.mts +38 -1
  41. package/dist/production/index-react-server.d.ts +38 -1
  42. package/dist/production/index-react-server.js +28 -9
  43. package/dist/production/index-react-server.mjs +28 -10
  44. package/dist/production/index.d.mts +42 -4
  45. package/dist/production/index.d.ts +42 -4
  46. package/dist/production/index.js +242 -128
  47. package/dist/production/index.mjs +3 -3
  48. package/dist/production/lib/types/internal.d.mts +6 -3
  49. package/dist/production/lib/types/internal.d.ts +6 -3
  50. package/dist/production/lib/types/internal.js +1 -1
  51. package/dist/production/lib/types/internal.mjs +1 -1
  52. package/dist/production/{route-data-CpB5xtMm.d.mts → route-data-CNjObrhZ.d.mts} +1 -1
  53. package/dist/production/{routeModules-qBivMBjd.d.ts → routeModules-C3oqzPpI.d.ts} +1 -1
  54. package/package.json +1 -1
@@ -849,6 +849,43 @@ declare const redirectDocument$1: RedirectFunction;
849
849
  * header.
850
850
  */
851
851
  declare const replace$1: RedirectFunction;
852
+ type ErrorResponse = {
853
+ status: number;
854
+ statusText: string;
855
+ data: any;
856
+ };
857
+ /**
858
+ * Check if the given error is an {@link ErrorResponse} generated from a 4xx/5xx
859
+ * [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
860
+ * thrown from an [`action`](../../start/framework/route-module#action)/[`loader`](../../start/framework/route-module#loader)
861
+ *
862
+ * @example
863
+ * import { isRouteErrorResponse } from "react-router";
864
+ *
865
+ * export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
866
+ * if (isRouteErrorResponse(error)) {
867
+ * return (
868
+ * <>
869
+ * <p>Error: `${error.status}: ${error.statusText}`</p>
870
+ * <p>{error.data}</p>
871
+ * </>
872
+ * );
873
+ * }
874
+ *
875
+ * return (
876
+ * <p>Error: {error instanceof Error ? error.message : "Unknown Error"}</p>
877
+ * );
878
+ * }
879
+ *
880
+ * @public
881
+ * @category Utils
882
+ * @mode framework
883
+ * @mode data
884
+ * @param error The error to check.
885
+ * @returns `true` if the error is an {@link ErrorResponse}, `false` otherwise.
886
+ *
887
+ */
888
+ declare function isRouteErrorResponse(error: any): error is ErrorResponse;
852
889
 
853
890
  /**
854
891
  * A Router instance manages all navigation and data loading/mutations
@@ -2187,4 +2224,4 @@ interface MemorySessionStorageOptions {
2187
2224
  */
2188
2225
  declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({ cookie }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
2189
2226
 
2190
- 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, 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 unstable_MiddlewareFunction, type unstable_MiddlewareNextFunction, 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, type unstable_RouterContext, unstable_RouterContextProvider, unstable_createContext, matchRSCServerRequest as unstable_matchRSCServerRequest };
2227
+ 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 unstable_MiddlewareFunction, type unstable_MiddlewareNextFunction, 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, type unstable_RouterContext, unstable_RouterContextProvider, unstable_createContext, matchRSCServerRequest as unstable_matchRSCServerRequest };
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
27
27
  var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
28
28
 
29
29
  /**
30
- * react-router v7.8.0
30
+ * react-router v7.8.1-pre.0
31
31
  *
32
32
  * Copyright (c) Remix Software Inc.
33
33
  *
@@ -259,8 +259,8 @@ function convertRouteMatchToUiMatch(match, loaderData) {
259
259
  handle: route.handle
260
260
  };
261
261
  }
262
- function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "") {
263
- let flattenRoute = (route, index, relativePath) => {
262
+ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
263
+ let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
264
264
  let meta = {
265
265
  relativePath: relativePath === void 0 ? route.path || "" : relativePath,
266
266
  caseSensitive: route.caseSensitive === true,
@@ -268,6 +268,9 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
268
268
  route
269
269
  };
270
270
  if (meta.relativePath.startsWith("/")) {
271
+ if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
272
+ return;
273
+ }
271
274
  invariant(
272
275
  meta.relativePath.startsWith(parentPath),
273
276
  `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
@@ -283,7 +286,13 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
283
286
  route.index !== true,
284
287
  `Index routes must not have child routes. Please remove all child routes from route path "${path}".`
285
288
  );
286
- flattenRoutes(route.children, branches, routesMeta, path);
289
+ flattenRoutes(
290
+ route.children,
291
+ branches,
292
+ routesMeta,
293
+ path,
294
+ hasParentOptionalSegments
295
+ );
287
296
  }
288
297
  if (route.path == null && !route.index) {
289
298
  return;
@@ -299,7 +308,7 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
299
308
  flattenRoute(route, index);
300
309
  } else {
301
310
  for (let exploded of explodeOptionalSegments(route.path)) {
302
- flattenRoute(route, index, exploded);
311
+ flattenRoute(route, index, true, exploded);
303
312
  }
304
313
  }
305
314
  });
@@ -463,7 +472,7 @@ function compilePath(path, caseSensitive = false, end = true) {
463
472
  params.push({ paramName, isOptional: isOptional != null });
464
473
  return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
465
474
  }
466
- );
475
+ ).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
467
476
  if (path.endsWith("*")) {
468
477
  params.push({ paramName: "*" });
469
478
  regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
@@ -1229,8 +1238,12 @@ function createStaticHandler(routes, opts) {
1229
1238
  basename
1230
1239
  );
1231
1240
  }
1232
- if (isResponse(result.result) && isRouteRequest) {
1233
- throw result;
1241
+ if (isRouteRequest) {
1242
+ if (isResponse(result.result)) {
1243
+ throw result;
1244
+ } else if (isDataWithResponseInit(result.result)) {
1245
+ throw dataWithResponseInitToResponse(result.result);
1246
+ }
1234
1247
  }
1235
1248
  dataResults[match.route.id] = await convertDataStrategyResultToDataResult(result);
1236
1249
  })
@@ -2740,7 +2753,12 @@ async function getRSCRouteMatch({
2740
2753
  path: match.route.path,
2741
2754
  pathname: match.pathname,
2742
2755
  pathnameBase: match.pathnameBase,
2743
- shouldRevalidate: match.route.shouldRevalidate
2756
+ shouldRevalidate: match.route.shouldRevalidate,
2757
+ // Add an unused client-only export (if present) so HMR can support
2758
+ // switching between server-first and client-only routes during development
2759
+ ...match.route.__ensureClientRouteModuleForHMR ? {
2760
+ __ensureClientRouteModuleForHMR: match.route.__ensureClientRouteModuleForHMR
2761
+ } : {}
2744
2762
  };
2745
2763
  }
2746
2764
  async function getManifestRoute(route) {
@@ -3249,6 +3267,7 @@ exports.createSessionStorage = createSessionStorage;
3249
3267
  exports.createStaticHandler = createStaticHandler;
3250
3268
  exports.data = data;
3251
3269
  exports.isCookie = isCookie;
3270
+ exports.isRouteErrorResponse = isRouteErrorResponse;
3252
3271
  exports.isSession = isSession;
3253
3272
  exports.matchRoutes = matchRoutes;
3254
3273
  exports.redirect = redirect2;
@@ -6,7 +6,7 @@ export { Await, BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta
6
6
  import { serialize, parse } from 'cookie';
7
7
 
8
8
  /**
9
- * react-router v7.8.0
9
+ * react-router v7.8.1-pre.0
10
10
  *
11
11
  * Copyright (c) Remix Software Inc.
12
12
  *
@@ -238,8 +238,8 @@ function convertRouteMatchToUiMatch(match, loaderData) {
238
238
  handle: route.handle
239
239
  };
240
240
  }
241
- function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "") {
242
- let flattenRoute = (route, index, relativePath) => {
241
+ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
242
+ let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
243
243
  let meta = {
244
244
  relativePath: relativePath === void 0 ? route.path || "" : relativePath,
245
245
  caseSensitive: route.caseSensitive === true,
@@ -247,6 +247,9 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
247
247
  route
248
248
  };
249
249
  if (meta.relativePath.startsWith("/")) {
250
+ if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
251
+ return;
252
+ }
250
253
  invariant(
251
254
  meta.relativePath.startsWith(parentPath),
252
255
  `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
@@ -262,7 +265,13 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
262
265
  route.index !== true,
263
266
  `Index routes must not have child routes. Please remove all child routes from route path "${path}".`
264
267
  );
265
- flattenRoutes(route.children, branches, routesMeta, path);
268
+ flattenRoutes(
269
+ route.children,
270
+ branches,
271
+ routesMeta,
272
+ path,
273
+ hasParentOptionalSegments
274
+ );
266
275
  }
267
276
  if (route.path == null && !route.index) {
268
277
  return;
@@ -278,7 +287,7 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
278
287
  flattenRoute(route, index);
279
288
  } else {
280
289
  for (let exploded of explodeOptionalSegments(route.path)) {
281
- flattenRoute(route, index, exploded);
290
+ flattenRoute(route, index, true, exploded);
282
291
  }
283
292
  }
284
293
  });
@@ -442,7 +451,7 @@ function compilePath(path, caseSensitive = false, end = true) {
442
451
  params.push({ paramName, isOptional: isOptional != null });
443
452
  return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
444
453
  }
445
- );
454
+ ).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
446
455
  if (path.endsWith("*")) {
447
456
  params.push({ paramName: "*" });
448
457
  regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
@@ -1208,8 +1217,12 @@ function createStaticHandler(routes, opts) {
1208
1217
  basename
1209
1218
  );
1210
1219
  }
1211
- if (isResponse(result.result) && isRouteRequest) {
1212
- throw result;
1220
+ if (isRouteRequest) {
1221
+ if (isResponse(result.result)) {
1222
+ throw result;
1223
+ } else if (isDataWithResponseInit(result.result)) {
1224
+ throw dataWithResponseInitToResponse(result.result);
1225
+ }
1213
1226
  }
1214
1227
  dataResults[match.route.id] = await convertDataStrategyResultToDataResult(result);
1215
1228
  })
@@ -2719,7 +2732,12 @@ async function getRSCRouteMatch({
2719
2732
  path: match.route.path,
2720
2733
  pathname: match.pathname,
2721
2734
  pathnameBase: match.pathnameBase,
2722
- shouldRevalidate: match.route.shouldRevalidate
2735
+ shouldRevalidate: match.route.shouldRevalidate,
2736
+ // Add an unused client-only export (if present) so HMR can support
2737
+ // switching between server-first and client-only routes during development
2738
+ ...match.route.__ensureClientRouteModuleForHMR ? {
2739
+ __ensureClientRouteModuleForHMR: match.route.__ensureClientRouteModuleForHMR
2740
+ } : {}
2723
2741
  };
2724
2742
  }
2725
2743
  async function getManifestRoute(route) {
@@ -3144,4 +3162,4 @@ function createMemorySessionStorage({ cookie } = {}) {
3144
3162
  });
3145
3163
  }
3146
3164
 
3147
- export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isSession, matchRoutes, redirect2 as redirect, redirectDocument2 as redirectDocument, replace2 as replace, unstable_RouterContextProvider, unstable_createContext, matchRSCServerRequest as unstable_matchRSCServerRequest };
3165
+ export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isRouteErrorResponse, isSession, matchRoutes, redirect2 as redirect, redirectDocument2 as redirectDocument, replace2 as replace, unstable_RouterContextProvider, unstable_createContext, matchRSCServerRequest as unstable_matchRSCServerRequest };
@@ -4,10 +4,10 @@ import { a as RouteComponentType, H as HydrateFallbackType, E as ErrorBoundaryTy
4
4
  export { f as Await, A as AwaitProps, I as IndexRouteProps, L as LayoutRouteProps, g as MemoryRouter, M as MemoryRouterOpts, b as MemoryRouterProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, P as PathRouteProps, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, W as UNSAFE_WithComponentProps, v as UNSAFE_WithErrorBoundaryProps, t as UNSAFE_WithHydrateFallbackProps, q as UNSAFE_hydrationRouteProperties, s as UNSAFE_mapRouteProperties, w as UNSAFE_withComponentProps, x as UNSAFE_withErrorBoundaryProps, u as UNSAFE_withHydrateFallbackProps, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, r as renderMatches } from './components-CuPfnyiZ.mjs';
5
5
  import * as React from 'react';
6
6
  import React__default, { ReactElement } from 'react';
7
- import { c as RouteModules, d as SerializeFrom, e as MetaFunction, f as LinksFunction, A as AppLoadContext, E as Equal, g as ClientActionFunction, h as ClientLoaderFunction, H as HeadersFunction } from './route-data-CpB5xtMm.mjs';
8
- export { i as ClientActionFunctionArgs, j as ClientLoaderFunctionArgs, k as HeadersArgs, n as HtmlLinkDescriptor, L as LinkDescriptor, l as MetaArgs, M as MetaDescriptor, m as PageLinkDescriptor, u as unstable_SerializesTo } from './route-data-CpB5xtMm.mjs';
9
- import { A as AssetsManifest, E as EntryContext, F as FutureConfig, S as ServerBuild } from './index-react-server-client-DXb0OgpJ.mjs';
10
- export { l as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, a1 as DiscoverBehavior, c as FetcherFormProps, h as FetcherSubmitFunction, G as FetcherSubmitOptions, i as FetcherWithComponents, q as Form, d as FormProps, a2 as HandleDataRequestFunction, a3 as HandleDocumentRequestFunction, a4 as HandleErrorFunction, m as HashRouter, H as HashRouterProps, a as HistoryRouterProps, n as Link, L as LinkProps, X as Links, _ as LinksProps, W as Meta, p as NavLink, N as NavLinkProps, b as NavLinkRenderProps, P as ParamKeyValuePair, a0 as PrefetchBehavior, Z as PrefetchPageLinks, Y as Scripts, $ as ScriptsProps, r as ScrollRestoration, e as ScrollRestorationProps, a5 as ServerEntryModule, f as SetURLSearchParams, T as StaticRouter, M as StaticRouterProps, V as StaticRouterProvider, O as StaticRouterProviderProps, g as SubmitFunction, I as SubmitOptions, J as SubmitTarget, a6 as UNSAFE_FrameworkContext, a7 as UNSAFE_createClientRoutes, a8 as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, a9 as UNSAFE_shouldHydrateRouteLoader, aa as UNSAFE_useScrollRestoration, U as URLSearchParamsInit, j as createBrowserRouter, k as createHashRouter, K as createSearchParams, Q as createStaticHandler, R as createStaticRouter, o as unstable_HistoryRouter, z as unstable_usePrompt, y as useBeforeUnload, w as useFetcher, x as useFetchers, v as useFormAction, u as useLinkClickHandler, s as useSearchParams, t as useSubmit, C as useViewTransitionState } from './index-react-server-client-DXb0OgpJ.mjs';
7
+ import { c as RouteModules, d as SerializeFrom, e as MetaFunction, f as LinksFunction, A as AppLoadContext, E as Equal, g as ClientActionFunction, h as ClientLoaderFunction, H as HeadersFunction } from './route-data-CNjObrhZ.mjs';
8
+ export { i as ClientActionFunctionArgs, j as ClientLoaderFunctionArgs, k as HeadersArgs, n as HtmlLinkDescriptor, L as LinkDescriptor, l as MetaArgs, M as MetaDescriptor, m as PageLinkDescriptor, u as unstable_SerializesTo } from './route-data-CNjObrhZ.mjs';
9
+ import { A as AssetsManifest, E as EntryContext, F as FutureConfig, S as ServerBuild } from './index-react-server-client-11fLy3qB.mjs';
10
+ export { l as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, a1 as DiscoverBehavior, c as FetcherFormProps, h as FetcherSubmitFunction, G as FetcherSubmitOptions, i as FetcherWithComponents, q as Form, d as FormProps, a2 as HandleDataRequestFunction, a3 as HandleDocumentRequestFunction, a4 as HandleErrorFunction, m as HashRouter, H as HashRouterProps, a as HistoryRouterProps, n as Link, L as LinkProps, X as Links, _ as LinksProps, W as Meta, p as NavLink, N as NavLinkProps, b as NavLinkRenderProps, P as ParamKeyValuePair, a0 as PrefetchBehavior, Z as PrefetchPageLinks, Y as Scripts, $ as ScriptsProps, r as ScrollRestoration, e as ScrollRestorationProps, a5 as ServerEntryModule, f as SetURLSearchParams, T as StaticRouter, M as StaticRouterProps, V as StaticRouterProvider, O as StaticRouterProviderProps, g as SubmitFunction, I as SubmitOptions, J as SubmitTarget, a6 as UNSAFE_FrameworkContext, a7 as UNSAFE_createClientRoutes, a8 as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, a9 as UNSAFE_shouldHydrateRouteLoader, aa as UNSAFE_useScrollRestoration, U as URLSearchParamsInit, j as createBrowserRouter, k as createHashRouter, K as createSearchParams, Q as createStaticHandler, R as createStaticRouter, o as unstable_HistoryRouter, z as unstable_usePrompt, y as useBeforeUnload, w as useFetcher, x as useFetchers, v as useFormAction, u as useLinkClickHandler, s as useSearchParams, t as useSubmit, C as useViewTransitionState } from './index-react-server-client-11fLy3qB.mjs';
11
11
  import { ParseOptions, SerializeOptions } from 'cookie';
12
12
  export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
13
13
  import { P as Pages } from './register-DiOIlEq5.mjs';
@@ -220,6 +220,44 @@ interface NavigateFunction {
220
220
  * middle of a page, and you don't want it to scroll to the top when a tab is
221
221
  * clicked.
222
222
  *
223
+ * ### Return Type Augmentation
224
+ *
225
+ * Internally, `useNavigate` uses a separate implementation when you are in
226
+ * Declarative mode versus Data/Framework mode - the primary difference being
227
+ * that the latter is able to return a stable reference that does not change
228
+ * identity across navigations. The implementation in Data/Framework mode also
229
+ * returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
230
+ * that resolves when the navigation is completed. This means the return type of
231
+ * `useNavigate` is `void | Promise<void>`. This is accurate, but can lead to
232
+ * some red squigglies based on the union in the return value:
233
+ *
234
+ * - If you're using `typescript-eslint`, you may see errors from
235
+ * [`@typescript-eslint/no-floating-promises`](https://typescript-eslint.io/rules/no-floating-promises)
236
+ * - In Framework/Data mode, `React.use(navigate())` will show a false-positive
237
+ * `Argument of type 'void | Promise<void>' is not assignable to parameter of
238
+ * type 'Usable<void>'` error
239
+ *
240
+ * The easiest way to work around these issues is to augment the type based on the
241
+ * router you're using:
242
+ *
243
+ * ```ts
244
+ * // If using <BrowserRouter>
245
+ * declare module "react-router" {
246
+ * interface NavigateFunction {
247
+ * (to: To, options?: NavigateOptions): void;
248
+ * (delta: number): void;
249
+ * }
250
+ * }
251
+ *
252
+ * // If using <RouterProvider> or Framework mode
253
+ * declare module "react-router" {
254
+ * interface NavigateFunction {
255
+ * (to: To, options?: NavigateOptions): Promise<void>;
256
+ * (delta: number): Promise<void>;
257
+ * }
258
+ * }
259
+ * ```
260
+ *
223
261
  * @public
224
262
  * @category Hooks
225
263
  * @returns A navigate function for programmatic navigation
@@ -1,7 +1,7 @@
1
- import { d as Router, e as RouteModules, D as DataStrategyFunction, T as To, f as NavigateOptions, B as BlockerFunction, g as Blocker, h as SerializeFrom, i as RelativeRoutingType, a as Location, j as ParamParseKey, k as Path, l as PathPattern, m as PathMatch, U as UIMatch, n as Navigation, A as Action, o as Params, p as RouteObject, I as InitialEntry, H as HydrationState, q as IndexRouteObject, r as LoaderFunction, s as ActionFunction, t as MetaFunction, v as LinksFunction, w as NonIndexRouteObject, x as AppLoadContext, y as unstable_RouterContextProvider, z as MiddlewareEnabled, E as Equal, F as ClientActionFunction, J as ClientLoaderFunction, K as HeadersFunction, O as ShouldRevalidateFunction, Q as RouterInit, V as RouterState, W as PatchRoutesOnNavigationFunction, X as DataRouteObject } from './routeModules-qBivMBjd.js';
2
- export { a6 as ActionFunctionArgs, aF as ClientActionFunctionArgs, aG as ClientLoaderFunctionArgs, aB as DataRouteMatch, a7 as DataStrategyFunctionArgs, a8 as DataStrategyMatch, a9 as DataStrategyResult, ab as ErrorResponse, a0 as Fetcher, ac as FormEncType, ad as FormMethod, aL as Future, Z as GetScrollPositionFunction, _ as GetScrollRestorationKeyFunction, ae as HTMLFormMethod, aH as HeadersArgs, aK as HtmlLinkDescriptor, ar as IDLE_BLOCKER, aq as IDLE_FETCHER, ap as IDLE_NAVIGATION, af as LazyRouteFunction, L as LinkDescriptor, ag as LoaderFunctionArgs, aI as MetaArgs, M as MetaDescriptor, a1 as NavigationStates, aC as Navigator, aJ as PageLinkDescriptor, aD as PatchRoutesOnNavigationFunctionArgs, ai as PathParam, aj as RedirectFunction, a5 as RevalidationState, aE as RouteMatch, a4 as RouterFetchOptions, a3 as RouterNavigateOptions, a2 as RouterSubscriber, al as ShouldRevalidateFunctionArgs, Y as StaticHandler, $ as StaticHandlerContext, aR as UNSAFE_DataRouterContext, aS as UNSAFE_DataRouterStateContext, aa as UNSAFE_DataWithResponseInit, aQ as UNSAFE_ErrorResponseImpl, aT as UNSAFE_FetchersContext, aU as UNSAFE_LocationContext, aV as UNSAFE_NavigationContext, aW as UNSAFE_RouteContext, aX as UNSAFE_ViewTransitionContext, aN as UNSAFE_createBrowserHistory, aP as UNSAFE_createRouter, aO as UNSAFE_invariant, an as createPath, as as data, at as generatePath, au as isRouteErrorResponse, av as matchPath, aw as matchRoutes, ao as parsePath, ax as redirect, ay as redirectDocument, az as replace, aA as resolvePath, ah as unstable_MiddlewareFunction, ak as unstable_RouterContext, aM as unstable_SerializesTo, am as unstable_createContext } from './routeModules-qBivMBjd.js';
3
- import { A as AssetsManifest, E as EntryContext, F as FutureConfig, R as RouteComponentType, H as HydrateFallbackType, a as ErrorBoundaryType, S as ServerBuild } from './index-react-server-client-CMphySRb.js';
4
- export { h as Await, b as AwaitProps, V as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, as as DiscoverBehavior, y as FetcherFormProps, K as FetcherSubmitFunction, a9 as FetcherSubmitOptions, Q as FetcherWithComponents, _ as Form, z as FormProps, at as HandleDataRequestFunction, au as HandleDocumentRequestFunction, av as HandleErrorFunction, W as HashRouter, t as HashRouterProps, u as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, X as Link, v as LinkProps, am as Links, ap as LinksProps, i as MemoryRouter, M as MemoryRouterOpts, c as MemoryRouterProps, al as Meta, Z as NavLink, w as NavLinkProps, x as NavLinkRenderProps, j as Navigate, N as NavigateProps, k as Outlet, O as OutletProps, aa as ParamKeyValuePair, P as PathRouteProps, ar as PrefetchBehavior, ao as PrefetchPageLinks, l as Route, d as RouteProps, m as Router, e as RouterProps, n as RouterProvider, f as RouterProviderProps, o as Routes, g as RoutesProps, an as Scripts, aq as ScriptsProps, $ as ScrollRestoration, C as ScrollRestorationProps, aw as ServerEntryModule, G as SetURLSearchParams, aj as StaticRouter, af as StaticRouterProps, ak as StaticRouterProvider, ag as StaticRouterProviderProps, J as SubmitFunction, ab as SubmitOptions, ad as SubmitTarget, aF as UNSAFE_FrameworkContext, az as UNSAFE_WithComponentProps, aD as UNSAFE_WithErrorBoundaryProps, aB as UNSAFE_WithHydrateFallbackProps, aG as UNSAFE_createClientRoutes, aH as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, ax as UNSAFE_hydrationRouteProperties, ay as UNSAFE_mapRouteProperties, aI as UNSAFE_shouldHydrateRouteLoader, aJ as UNSAFE_useScrollRestoration, aA as UNSAFE_withComponentProps, aE as UNSAFE_withErrorBoundaryProps, aC as UNSAFE_withHydrateFallbackProps, ac as URLSearchParamsInit, T as createBrowserRouter, U as createHashRouter, p as createMemoryRouter, q as createRoutesFromChildren, r as createRoutesFromElements, ae as createSearchParams, ah as createStaticHandler, ai as createStaticRouter, s as renderMatches, Y as unstable_HistoryRouter, a7 as unstable_usePrompt, a6 as useBeforeUnload, a4 as useFetcher, a5 as useFetchers, a3 as useFormAction, a0 as useLinkClickHandler, a1 as useSearchParams, a2 as useSubmit, a8 as useViewTransitionState } from './index-react-server-client-CMphySRb.js';
1
+ import { d as Router, e as RouteModules, D as DataStrategyFunction, T as To, f as NavigateOptions, B as BlockerFunction, g as Blocker, h as SerializeFrom, i as RelativeRoutingType, a as Location, j as ParamParseKey, k as Path, l as PathPattern, m as PathMatch, U as UIMatch, n as Navigation, A as Action, o as Params, p as RouteObject, I as InitialEntry, H as HydrationState, q as IndexRouteObject, r as LoaderFunction, s as ActionFunction, t as MetaFunction, v as LinksFunction, w as NonIndexRouteObject, x as AppLoadContext, y as unstable_RouterContextProvider, z as MiddlewareEnabled, E as Equal, J as ClientActionFunction, K as ClientLoaderFunction, O as HeadersFunction, Q as ShouldRevalidateFunction, V as RouterInit, W as RouterState, X as PatchRoutesOnNavigationFunction, Y as DataRouteObject } from './routeModules-C3oqzPpI.js';
2
+ export { a7 as ActionFunctionArgs, aG as ClientActionFunctionArgs, aH as ClientLoaderFunctionArgs, aC as DataRouteMatch, a8 as DataStrategyFunctionArgs, a9 as DataStrategyMatch, aa as DataStrategyResult, ac as ErrorResponse, a1 as Fetcher, ad as FormEncType, ae as FormMethod, aM as Future, _ as GetScrollPositionFunction, $ as GetScrollRestorationKeyFunction, af as HTMLFormMethod, aI as HeadersArgs, aL as HtmlLinkDescriptor, as as IDLE_BLOCKER, ar as IDLE_FETCHER, aq as IDLE_NAVIGATION, ag as LazyRouteFunction, L as LinkDescriptor, ah as LoaderFunctionArgs, aJ as MetaArgs, M as MetaDescriptor, a2 as NavigationStates, aD as Navigator, aK as PageLinkDescriptor, aE as PatchRoutesOnNavigationFunctionArgs, aj as PathParam, ak as RedirectFunction, a6 as RevalidationState, aF as RouteMatch, a5 as RouterFetchOptions, a4 as RouterNavigateOptions, a3 as RouterSubscriber, am as ShouldRevalidateFunctionArgs, Z as StaticHandler, a0 as StaticHandlerContext, aS as UNSAFE_DataRouterContext, aT as UNSAFE_DataRouterStateContext, ab as UNSAFE_DataWithResponseInit, aR as UNSAFE_ErrorResponseImpl, aU as UNSAFE_FetchersContext, aV as UNSAFE_LocationContext, aW as UNSAFE_NavigationContext, aX as UNSAFE_RouteContext, aY as UNSAFE_ViewTransitionContext, aO as UNSAFE_createBrowserHistory, aQ as UNSAFE_createRouter, aP as UNSAFE_invariant, ao as createPath, at as data, au as generatePath, av as isRouteErrorResponse, aw as matchPath, ax as matchRoutes, ap as parsePath, ay as redirect, az as redirectDocument, aA as replace, aB as resolvePath, ai as unstable_MiddlewareFunction, al as unstable_RouterContext, aN as unstable_SerializesTo, an as unstable_createContext } from './routeModules-C3oqzPpI.js';
3
+ import { A as AssetsManifest, E as EntryContext, F as FutureConfig, R as RouteComponentType, H as HydrateFallbackType, a as ErrorBoundaryType, S as ServerBuild } from './index-react-server-client-BQ6FxdA_.js';
4
+ export { h as Await, b as AwaitProps, V as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, as as DiscoverBehavior, y as FetcherFormProps, K as FetcherSubmitFunction, a9 as FetcherSubmitOptions, Q as FetcherWithComponents, _ as Form, z as FormProps, at as HandleDataRequestFunction, au as HandleDocumentRequestFunction, av as HandleErrorFunction, W as HashRouter, t as HashRouterProps, u as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, X as Link, v as LinkProps, am as Links, ap as LinksProps, i as MemoryRouter, M as MemoryRouterOpts, c as MemoryRouterProps, al as Meta, Z as NavLink, w as NavLinkProps, x as NavLinkRenderProps, j as Navigate, N as NavigateProps, k as Outlet, O as OutletProps, aa as ParamKeyValuePair, P as PathRouteProps, ar as PrefetchBehavior, ao as PrefetchPageLinks, l as Route, d as RouteProps, m as Router, e as RouterProps, n as RouterProvider, f as RouterProviderProps, o as Routes, g as RoutesProps, an as Scripts, aq as ScriptsProps, $ as ScrollRestoration, C as ScrollRestorationProps, aw as ServerEntryModule, G as SetURLSearchParams, aj as StaticRouter, af as StaticRouterProps, ak as StaticRouterProvider, ag as StaticRouterProviderProps, J as SubmitFunction, ab as SubmitOptions, ad as SubmitTarget, aF as UNSAFE_FrameworkContext, az as UNSAFE_WithComponentProps, aD as UNSAFE_WithErrorBoundaryProps, aB as UNSAFE_WithHydrateFallbackProps, aG as UNSAFE_createClientRoutes, aH as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, ax as UNSAFE_hydrationRouteProperties, ay as UNSAFE_mapRouteProperties, aI as UNSAFE_shouldHydrateRouteLoader, aJ as UNSAFE_useScrollRestoration, aA as UNSAFE_withComponentProps, aE as UNSAFE_withErrorBoundaryProps, aC as UNSAFE_withHydrateFallbackProps, ac as URLSearchParamsInit, T as createBrowserRouter, U as createHashRouter, p as createMemoryRouter, q as createRoutesFromChildren, r as createRoutesFromElements, ae as createSearchParams, ah as createStaticHandler, ai as createStaticRouter, s as renderMatches, Y as unstable_HistoryRouter, a7 as unstable_usePrompt, a6 as useBeforeUnload, a4 as useFetcher, a5 as useFetchers, a3 as useFormAction, a0 as useLinkClickHandler, a1 as useSearchParams, a2 as useSubmit, a8 as useViewTransitionState } from './index-react-server-client-BQ6FxdA_.js';
5
5
  import * as React from 'react';
6
6
  import React__default, { ReactElement } from 'react';
7
7
  import { ParseOptions, SerializeOptions } from 'cookie';
@@ -215,6 +215,44 @@ interface NavigateFunction {
215
215
  * middle of a page, and you don't want it to scroll to the top when a tab is
216
216
  * clicked.
217
217
  *
218
+ * ### Return Type Augmentation
219
+ *
220
+ * Internally, `useNavigate` uses a separate implementation when you are in
221
+ * Declarative mode versus Data/Framework mode - the primary difference being
222
+ * that the latter is able to return a stable reference that does not change
223
+ * identity across navigations. The implementation in Data/Framework mode also
224
+ * returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
225
+ * that resolves when the navigation is completed. This means the return type of
226
+ * `useNavigate` is `void | Promise<void>`. This is accurate, but can lead to
227
+ * some red squigglies based on the union in the return value:
228
+ *
229
+ * - If you're using `typescript-eslint`, you may see errors from
230
+ * [`@typescript-eslint/no-floating-promises`](https://typescript-eslint.io/rules/no-floating-promises)
231
+ * - In Framework/Data mode, `React.use(navigate())` will show a false-positive
232
+ * `Argument of type 'void | Promise<void>' is not assignable to parameter of
233
+ * type 'Usable<void>'` error
234
+ *
235
+ * The easiest way to work around these issues is to augment the type based on the
236
+ * router you're using:
237
+ *
238
+ * ```ts
239
+ * // If using <BrowserRouter>
240
+ * declare module "react-router" {
241
+ * interface NavigateFunction {
242
+ * (to: To, options?: NavigateOptions): void;
243
+ * (delta: number): void;
244
+ * }
245
+ * }
246
+ *
247
+ * // If using <RouterProvider> or Framework mode
248
+ * declare module "react-router" {
249
+ * interface NavigateFunction {
250
+ * (to: To, options?: NavigateOptions): Promise<void>;
251
+ * (delta: number): Promise<void>;
252
+ * }
253
+ * }
254
+ * ```
255
+ *
218
256
  * @public
219
257
  * @category Hooks
220
258
  * @returns A navigate function for programmatic navigation