react-router 7.8.0 → 7.8.1-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.
Files changed (54) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/development/{chunk-VC6RBZTR.js → chunk-3JDDYHAM.js} +130 -130
  3. package/dist/development/{chunk-EVX7OBGB.js → chunk-5556IWOV.js} +98 -83
  4. package/dist/development/{chunk-ZYFC6VSF.mjs → chunk-74543KUN.mjs} +62 -47
  5. package/dist/{production/chunk-XPGU3ZMH.mjs → development/chunk-NL6TORMN.mjs} +147 -33
  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 +56 -45
  17. package/dist/development/index-react-server.mjs +56 -46
  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-BOD6JCOU.js → chunk-3OSMCWIR.js} +98 -83
  29. package/dist/production/{chunk-SIHON65V.mjs → chunk-HVGIEXH6.mjs} +62 -47
  30. package/dist/{development/chunk-HZX6U7MI.mjs → production/chunk-J44BHEXU.mjs} +147 -33
  31. package/dist/production/{chunk-O6DRQPUD.js → chunk-OE6UW5JS.js} +130 -130
  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 +56 -45
  43. package/dist/production/index-react-server.mjs +56 -46
  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
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});/**
2
- * react-router v7.8.0
2
+ * react-router v7.8.1-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -30,11 +30,11 @@
30
30
 
31
31
 
32
32
 
33
- var _chunkVC6RBZTRjs = require('./chunk-VC6RBZTR.js');
33
+ var _chunk3JDDYHAMjs = require('./chunk-3JDDYHAM.js');
34
34
 
35
35
 
36
36
 
37
- var _chunkEVX7OBGBjs = require('./chunk-EVX7OBGB.js');
37
+ var _chunk5556IWOVjs = require('./chunk-5556IWOV.js');
38
38
 
39
39
 
40
40
 
@@ -58,4 +58,4 @@ var _chunkEVX7OBGBjs = require('./chunk-EVX7OBGB.js');
58
58
 
59
59
 
60
60
 
61
- exports.Await = _chunkVC6RBZTRjs.Await; exports.BrowserRouter = _chunkVC6RBZTRjs.BrowserRouter; exports.Form = _chunkVC6RBZTRjs.Form; exports.HashRouter = _chunkVC6RBZTRjs.HashRouter; exports.Link = _chunkVC6RBZTRjs.Link; exports.Links = _chunkEVX7OBGBjs.Links; exports.MemoryRouter = _chunkVC6RBZTRjs.MemoryRouter; exports.Meta = _chunkEVX7OBGBjs.Meta; exports.NavLink = _chunkVC6RBZTRjs.NavLink; exports.Navigate = _chunkVC6RBZTRjs.Navigate; exports.Outlet = _chunkVC6RBZTRjs.Outlet; exports.Route = _chunkVC6RBZTRjs.Route; exports.Router = _chunkVC6RBZTRjs.Router; exports.RouterProvider = _chunkVC6RBZTRjs.RouterProvider; exports.Routes = _chunkVC6RBZTRjs.Routes; exports.ScrollRestoration = _chunkVC6RBZTRjs.ScrollRestoration; exports.StaticRouter = _chunkVC6RBZTRjs.StaticRouter; exports.StaticRouterProvider = _chunkVC6RBZTRjs.StaticRouterProvider; exports.UNSAFE_WithComponentProps = _chunkVC6RBZTRjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkVC6RBZTRjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkVC6RBZTRjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunkVC6RBZTRjs.HistoryRouter;
61
+ exports.Await = _chunk3JDDYHAMjs.Await; exports.BrowserRouter = _chunk3JDDYHAMjs.BrowserRouter; exports.Form = _chunk3JDDYHAMjs.Form; exports.HashRouter = _chunk3JDDYHAMjs.HashRouter; exports.Link = _chunk3JDDYHAMjs.Link; exports.Links = _chunk5556IWOVjs.Links; exports.MemoryRouter = _chunk3JDDYHAMjs.MemoryRouter; exports.Meta = _chunk5556IWOVjs.Meta; exports.NavLink = _chunk3JDDYHAMjs.NavLink; exports.Navigate = _chunk3JDDYHAMjs.Navigate; exports.Outlet = _chunk3JDDYHAMjs.Outlet; exports.Route = _chunk3JDDYHAMjs.Route; exports.Router = _chunk3JDDYHAMjs.Router; exports.RouterProvider = _chunk3JDDYHAMjs.RouterProvider; exports.Routes = _chunk3JDDYHAMjs.Routes; exports.ScrollRestoration = _chunk3JDDYHAMjs.ScrollRestoration; exports.StaticRouter = _chunk3JDDYHAMjs.StaticRouter; exports.StaticRouterProvider = _chunk3JDDYHAMjs.StaticRouterProvider; exports.UNSAFE_WithComponentProps = _chunk3JDDYHAMjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunk3JDDYHAMjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunk3JDDYHAMjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunk3JDDYHAMjs.HistoryRouter;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.8.0
2
+ * react-router v7.8.1-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -32,7 +32,7 @@ import {
32
32
  WithComponentProps,
33
33
  WithErrorBoundaryProps,
34
34
  WithHydrateFallbackProps
35
- } from "./chunk-ZYFC6VSF.mjs";
35
+ } from "./chunk-74543KUN.mjs";
36
36
  export {
37
37
  Await,
38
38
  BrowserRouter,
@@ -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 };
@@ -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.1
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 === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
@@ -773,9 +782,23 @@ function createStaticHandler(routes, opts) {
773
782
  return res;
774
783
  },
775
784
  async (error, routeId) => {
776
- if (isResponse(error)) {
785
+ if (isRedirectResponse(error)) {
777
786
  return error;
778
787
  }
788
+ if (isResponse(error)) {
789
+ try {
790
+ error = new ErrorResponseImpl(
791
+ error.status,
792
+ error.statusText,
793
+ await parseResponseBody(error)
794
+ );
795
+ } catch (e) {
796
+ error = e;
797
+ }
798
+ }
799
+ if (isDataWithResponseInit(error)) {
800
+ error = dataWithResponseInitToErrorResponse(error);
801
+ }
779
802
  if (renderedStaticContext) {
780
803
  if (routeId in renderedStaticContext.loaderData) {
781
804
  renderedStaticContext.loaderData[routeId] = void 0;
@@ -901,8 +924,8 @@ function createStaticHandler(routes, opts) {
901
924
  return res;
902
925
  },
903
926
  (error) => {
904
- if (isRouteErrorResponse(error)) {
905
- return Promise.resolve(errorResponseToResponse(error));
927
+ if (isDataWithResponseInit(error)) {
928
+ return Promise.resolve(dataWithResponseInitToResponse(error));
906
929
  }
907
930
  if (isResponse(error)) {
908
931
  return Promise.resolve(error);
@@ -1229,8 +1252,12 @@ function createStaticHandler(routes, opts) {
1229
1252
  basename
1230
1253
  );
1231
1254
  }
1232
- if (isResponse(result.result) && isRouteRequest) {
1233
- throw result;
1255
+ if (isRouteRequest) {
1256
+ if (isResponse(result.result)) {
1257
+ throw result;
1258
+ } else if (isDataWithResponseInit(result.result)) {
1259
+ throw dataWithResponseInitToResponse(result.result);
1260
+ }
1234
1261
  }
1235
1262
  dataResults[match.route.id] = await convertDataStrategyResultToDataResult(result);
1236
1263
  })
@@ -1539,11 +1566,7 @@ async function callServerRouteMiddleware(args, middlewares, handler, errorHandle
1539
1566
  nextResult = result;
1540
1567
  return nextResult;
1541
1568
  } catch (e) {
1542
- nextResult = await errorHandler(
1543
- // Convert thrown data() values to ErrorResponses
1544
- isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
1545
- routeId
1546
- );
1569
+ nextResult = await errorHandler(e, routeId);
1547
1570
  return nextResult;
1548
1571
  }
1549
1572
  };
@@ -1568,11 +1591,7 @@ async function callServerRouteMiddleware(args, middlewares, handler, errorHandle
1568
1591
  return nextResult;
1569
1592
  }
1570
1593
  } catch (e) {
1571
- let response = await errorHandler(
1572
- // Convert thrown data() values to ErrorResponses
1573
- isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
1574
- routeId
1575
- );
1594
+ let response = await errorHandler(e, routeId);
1576
1595
  return response;
1577
1596
  }
1578
1597
  }
@@ -1798,21 +1817,19 @@ async function callLoaderOrAction({
1798
1817
  }
1799
1818
  return result;
1800
1819
  }
1820
+ async function parseResponseBody(response) {
1821
+ let contentType = response.headers.get("Content-Type");
1822
+ if (contentType && /\bapplication\/json\b/.test(contentType)) {
1823
+ return response.body == null ? null : response.json();
1824
+ }
1825
+ return response.text();
1826
+ }
1801
1827
  async function convertDataStrategyResultToDataResult(dataStrategyResult) {
1802
1828
  let { result, type } = dataStrategyResult;
1803
1829
  if (isResponse(result)) {
1804
1830
  let data2;
1805
1831
  try {
1806
- let contentType = result.headers.get("Content-Type");
1807
- if (contentType && /\bapplication\/json\b/.test(contentType)) {
1808
- if (result.body == null) {
1809
- data2 = null;
1810
- } else {
1811
- data2 = await result.json();
1812
- }
1813
- } else {
1814
- data2 = await result.text();
1815
- }
1832
+ data2 = await parseResponseBody(result);
1816
1833
  } catch (e) {
1817
1834
  return { type: "error" /* error */, error: e };
1818
1835
  }
@@ -2012,10 +2029,7 @@ function getInternalRouterError(status, {
2012
2029
  );
2013
2030
  }
2014
2031
  function dataWithResponseInitToResponse(data2) {
2015
- return new Response(
2016
- typeof data2.data === "string" ? data2.data : JSON.stringify(data2.data),
2017
- data2.init || void 0
2018
- );
2032
+ return Response.json(data2.data, data2.init ?? void 0);
2019
2033
  }
2020
2034
  function dataWithResponseInitToErrorResponse(data2) {
2021
2035
  return new ErrorResponseImpl(
@@ -2024,15 +2038,6 @@ function dataWithResponseInitToErrorResponse(data2) {
2024
2038
  data2.data
2025
2039
  );
2026
2040
  }
2027
- function errorResponseToResponse(error) {
2028
- return new Response(
2029
- typeof error.data === "string" ? error.data : JSON.stringify(error.data),
2030
- {
2031
- status: error.status,
2032
- statusText: error.statusText
2033
- }
2034
- );
2035
- }
2036
2041
  function isDataStrategyResult(result) {
2037
2042
  return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === "data" /* data */ || result.type === "error" /* error */);
2038
2043
  }
@@ -2740,7 +2745,12 @@ async function getRSCRouteMatch({
2740
2745
  path: match.route.path,
2741
2746
  pathname: match.pathname,
2742
2747
  pathnameBase: match.pathnameBase,
2743
- shouldRevalidate: match.route.shouldRevalidate
2748
+ shouldRevalidate: match.route.shouldRevalidate,
2749
+ // Add an unused client-only export (if present) so HMR can support
2750
+ // switching between server-first and client-only routes during development
2751
+ ...match.route.__ensureClientRouteModuleForHMR ? {
2752
+ __ensureClientRouteModuleForHMR: match.route.__ensureClientRouteModuleForHMR
2753
+ } : {}
2744
2754
  };
2745
2755
  }
2746
2756
  async function getManifestRoute(route) {
@@ -3249,6 +3259,7 @@ exports.createSessionStorage = createSessionStorage;
3249
3259
  exports.createStaticHandler = createStaticHandler;
3250
3260
  exports.data = data;
3251
3261
  exports.isCookie = isCookie;
3262
+ exports.isRouteErrorResponse = isRouteErrorResponse;
3252
3263
  exports.isSession = isSession;
3253
3264
  exports.matchRoutes = matchRoutes;
3254
3265
  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.1
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 === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
@@ -752,9 +761,23 @@ function createStaticHandler(routes, opts) {
752
761
  return res;
753
762
  },
754
763
  async (error, routeId) => {
755
- if (isResponse(error)) {
764
+ if (isRedirectResponse(error)) {
756
765
  return error;
757
766
  }
767
+ if (isResponse(error)) {
768
+ try {
769
+ error = new ErrorResponseImpl(
770
+ error.status,
771
+ error.statusText,
772
+ await parseResponseBody(error)
773
+ );
774
+ } catch (e) {
775
+ error = e;
776
+ }
777
+ }
778
+ if (isDataWithResponseInit(error)) {
779
+ error = dataWithResponseInitToErrorResponse(error);
780
+ }
758
781
  if (renderedStaticContext) {
759
782
  if (routeId in renderedStaticContext.loaderData) {
760
783
  renderedStaticContext.loaderData[routeId] = void 0;
@@ -880,8 +903,8 @@ function createStaticHandler(routes, opts) {
880
903
  return res;
881
904
  },
882
905
  (error) => {
883
- if (isRouteErrorResponse(error)) {
884
- return Promise.resolve(errorResponseToResponse(error));
906
+ if (isDataWithResponseInit(error)) {
907
+ return Promise.resolve(dataWithResponseInitToResponse(error));
885
908
  }
886
909
  if (isResponse(error)) {
887
910
  return Promise.resolve(error);
@@ -1208,8 +1231,12 @@ function createStaticHandler(routes, opts) {
1208
1231
  basename
1209
1232
  );
1210
1233
  }
1211
- if (isResponse(result.result) && isRouteRequest) {
1212
- throw result;
1234
+ if (isRouteRequest) {
1235
+ if (isResponse(result.result)) {
1236
+ throw result;
1237
+ } else if (isDataWithResponseInit(result.result)) {
1238
+ throw dataWithResponseInitToResponse(result.result);
1239
+ }
1213
1240
  }
1214
1241
  dataResults[match.route.id] = await convertDataStrategyResultToDataResult(result);
1215
1242
  })
@@ -1518,11 +1545,7 @@ async function callServerRouteMiddleware(args, middlewares, handler, errorHandle
1518
1545
  nextResult = result;
1519
1546
  return nextResult;
1520
1547
  } catch (e) {
1521
- nextResult = await errorHandler(
1522
- // Convert thrown data() values to ErrorResponses
1523
- isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
1524
- routeId
1525
- );
1548
+ nextResult = await errorHandler(e, routeId);
1526
1549
  return nextResult;
1527
1550
  }
1528
1551
  };
@@ -1547,11 +1570,7 @@ async function callServerRouteMiddleware(args, middlewares, handler, errorHandle
1547
1570
  return nextResult;
1548
1571
  }
1549
1572
  } catch (e) {
1550
- let response = await errorHandler(
1551
- // Convert thrown data() values to ErrorResponses
1552
- isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
1553
- routeId
1554
- );
1573
+ let response = await errorHandler(e, routeId);
1555
1574
  return response;
1556
1575
  }
1557
1576
  }
@@ -1777,21 +1796,19 @@ async function callLoaderOrAction({
1777
1796
  }
1778
1797
  return result;
1779
1798
  }
1799
+ async function parseResponseBody(response) {
1800
+ let contentType = response.headers.get("Content-Type");
1801
+ if (contentType && /\bapplication\/json\b/.test(contentType)) {
1802
+ return response.body == null ? null : response.json();
1803
+ }
1804
+ return response.text();
1805
+ }
1780
1806
  async function convertDataStrategyResultToDataResult(dataStrategyResult) {
1781
1807
  let { result, type } = dataStrategyResult;
1782
1808
  if (isResponse(result)) {
1783
1809
  let data2;
1784
1810
  try {
1785
- let contentType = result.headers.get("Content-Type");
1786
- if (contentType && /\bapplication\/json\b/.test(contentType)) {
1787
- if (result.body == null) {
1788
- data2 = null;
1789
- } else {
1790
- data2 = await result.json();
1791
- }
1792
- } else {
1793
- data2 = await result.text();
1794
- }
1811
+ data2 = await parseResponseBody(result);
1795
1812
  } catch (e) {
1796
1813
  return { type: "error" /* error */, error: e };
1797
1814
  }
@@ -1991,10 +2008,7 @@ function getInternalRouterError(status, {
1991
2008
  );
1992
2009
  }
1993
2010
  function dataWithResponseInitToResponse(data2) {
1994
- return new Response(
1995
- typeof data2.data === "string" ? data2.data : JSON.stringify(data2.data),
1996
- data2.init || void 0
1997
- );
2011
+ return Response.json(data2.data, data2.init ?? void 0);
1998
2012
  }
1999
2013
  function dataWithResponseInitToErrorResponse(data2) {
2000
2014
  return new ErrorResponseImpl(
@@ -2003,15 +2017,6 @@ function dataWithResponseInitToErrorResponse(data2) {
2003
2017
  data2.data
2004
2018
  );
2005
2019
  }
2006
- function errorResponseToResponse(error) {
2007
- return new Response(
2008
- typeof error.data === "string" ? error.data : JSON.stringify(error.data),
2009
- {
2010
- status: error.status,
2011
- statusText: error.statusText
2012
- }
2013
- );
2014
- }
2015
2020
  function isDataStrategyResult(result) {
2016
2021
  return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === "data" /* data */ || result.type === "error" /* error */);
2017
2022
  }
@@ -2719,7 +2724,12 @@ async function getRSCRouteMatch({
2719
2724
  path: match.route.path,
2720
2725
  pathname: match.pathname,
2721
2726
  pathnameBase: match.pathnameBase,
2722
- shouldRevalidate: match.route.shouldRevalidate
2727
+ shouldRevalidate: match.route.shouldRevalidate,
2728
+ // Add an unused client-only export (if present) so HMR can support
2729
+ // switching between server-first and client-only routes during development
2730
+ ...match.route.__ensureClientRouteModuleForHMR ? {
2731
+ __ensureClientRouteModuleForHMR: match.route.__ensureClientRouteModuleForHMR
2732
+ } : {}
2723
2733
  };
2724
2734
  }
2725
2735
  async function getManifestRoute(route) {
@@ -3144,4 +3154,4 @@ function createMemorySessionStorage({ cookie } = {}) {
3144
3154
  });
3145
3155
  }
3146
3156
 
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 };
3157
+ 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