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
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.8.0
2
+ * react-router v7.8.1-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -46,6 +46,7 @@ import {
46
46
  redirect,
47
47
  redirectDocument,
48
48
  replace,
49
+ setIsHydrated,
49
50
  shouldHydrateRouteLoader,
50
51
  singleFetchUrl,
51
52
  stripBasename,
@@ -57,7 +58,7 @@ import {
57
58
  withComponentProps,
58
59
  withErrorBoundaryProps,
59
60
  withHydrateFallbackProps
60
- } from "./chunk-SIHON65V.mjs";
61
+ } from "./chunk-WKLBIS42.mjs";
61
62
 
62
63
  // lib/dom/ssr/server.tsx
63
64
  import * as React from "react";
@@ -1122,6 +1123,28 @@ var createRequestHandler = (build, mode) => {
1122
1123
  let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
1123
1124
  if (!_build.ssr) {
1124
1125
  let decodedPath = decodeURI(normalizedPath);
1126
+ if (normalizedBasename !== "/") {
1127
+ let strippedPath = stripBasename(decodedPath, normalizedBasename);
1128
+ if (strippedPath == null) {
1129
+ errorHandler(
1130
+ new ErrorResponseImpl(
1131
+ 404,
1132
+ "Not Found",
1133
+ `Refusing to prerender the \`${decodedPath}\` path because it does not start with the basename \`${normalizedBasename}\``
1134
+ ),
1135
+ {
1136
+ context: loadContext,
1137
+ params,
1138
+ request
1139
+ }
1140
+ );
1141
+ return new Response("Not Found", {
1142
+ status: 404,
1143
+ statusText: "Not Found"
1144
+ });
1145
+ }
1146
+ decodedPath = strippedPath;
1147
+ }
1125
1148
  if (_build.prerender.length === 0) {
1126
1149
  isSpaMode = true;
1127
1150
  } else if (!_build.prerender.includes(decodedPath) && !_build.prerender.includes(decodedPath + "/")) {
@@ -1834,6 +1857,26 @@ function RSCDefaultRootErrorBoundary({
1834
1857
  );
1835
1858
  }
1836
1859
 
1860
+ // lib/rsc/route-modules.ts
1861
+ function createRSCRouteModules(payload) {
1862
+ const routeModules = {};
1863
+ for (const match of payload.matches) {
1864
+ populateRSCRouteModules(routeModules, match);
1865
+ }
1866
+ return routeModules;
1867
+ }
1868
+ function populateRSCRouteModules(routeModules, matches) {
1869
+ matches = Array.isArray(matches) ? matches : [matches];
1870
+ for (const match of matches) {
1871
+ routeModules[match.id] = {
1872
+ links: match.links,
1873
+ meta: match.meta,
1874
+ default: noopComponent
1875
+ };
1876
+ }
1877
+ }
1878
+ var noopComponent = () => null;
1879
+
1837
1880
  // lib/rsc/browser.tsx
1838
1881
  function createCallServer({
1839
1882
  createFromReadableStream,
@@ -1867,7 +1910,7 @@ function createCallServer({
1867
1910
  window.location.href = payload.location;
1868
1911
  return;
1869
1912
  }
1870
- globalVar.__router.navigate(payload.location, {
1913
+ globalVar.__reactRouterDataRouter.navigate(payload.location, {
1871
1914
  replace: payload.replace
1872
1915
  });
1873
1916
  return payload.actionResult;
@@ -1888,34 +1931,38 @@ function createCallServer({
1888
1931
  window.location.href = rerender.location;
1889
1932
  return;
1890
1933
  }
1891
- globalVar.__router.navigate(rerender.location, {
1934
+ globalVar.__reactRouterDataRouter.navigate(rerender.location, {
1892
1935
  replace: rerender.replace
1893
1936
  });
1894
1937
  return;
1895
1938
  }
1896
1939
  let lastMatch;
1897
1940
  for (const match of rerender.matches) {
1898
- globalVar.__router.patchRoutes(
1941
+ globalVar.__reactRouterDataRouter.patchRoutes(
1899
1942
  lastMatch?.id ?? null,
1900
1943
  [createRouteFromServerManifest(match)],
1901
1944
  true
1902
1945
  );
1903
1946
  lastMatch = match;
1904
1947
  }
1905
- window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({});
1948
+ window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
1949
+ {}
1950
+ );
1906
1951
  React4.startTransition(() => {
1907
- window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({
1908
- loaderData: Object.assign(
1909
- {},
1910
- globalVar.__router.state.loaderData,
1911
- rerender.loaderData
1912
- ),
1913
- errors: rerender.errors ? Object.assign(
1914
- {},
1915
- globalVar.__router.state.errors,
1916
- rerender.errors
1917
- ) : null
1918
- });
1952
+ window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
1953
+ {
1954
+ loaderData: Object.assign(
1955
+ {},
1956
+ globalVar.__reactRouterDataRouter.state.loaderData,
1957
+ rerender.loaderData
1958
+ ),
1959
+ errors: rerender.errors ? Object.assign(
1960
+ {},
1961
+ globalVar.__reactRouterDataRouter.state.errors,
1962
+ rerender.errors
1963
+ ) : null
1964
+ }
1965
+ );
1919
1966
  });
1920
1967
  }
1921
1968
  }
@@ -1931,8 +1978,14 @@ function createRouterFromPayload({
1931
1978
  payload
1932
1979
  }) {
1933
1980
  const globalVar = window;
1934
- if (globalVar.__router) return globalVar.__router;
1981
+ if (globalVar.__reactRouterDataRouter && globalVar.__reactRouterRouteModules)
1982
+ return {
1983
+ router: globalVar.__reactRouterDataRouter,
1984
+ routeModules: globalVar.__reactRouterRouteModules
1985
+ };
1935
1986
  if (payload.type !== "render") throw new Error("Invalid payload type");
1987
+ globalVar.__reactRouterRouteModules = globalVar.__reactRouterRouteModules ?? {};
1988
+ populateRSCRouteModules(globalVar.__reactRouterRouteModules, payload.matches);
1936
1989
  let patches = /* @__PURE__ */ new Map();
1937
1990
  payload.patches?.forEach((patch) => {
1938
1991
  invariant(patch.parentId, "Invalid patch parentId");
@@ -1957,7 +2010,7 @@ function createRouterFromPayload({
1957
2010
  }
1958
2011
  return [route];
1959
2012
  }, []);
1960
- globalVar.__router = createRouter({
2013
+ globalVar.__reactRouterDataRouter = createRouter({
1961
2014
  routes,
1962
2015
  unstable_getContext,
1963
2016
  basename: payload.basename,
@@ -1995,26 +2048,79 @@ function createRouterFromPayload({
1995
2048
  },
1996
2049
  // FIXME: Pass `build.ssr` into this function
1997
2050
  dataStrategy: getRSCSingleFetchDataStrategy(
1998
- () => globalVar.__router,
2051
+ () => globalVar.__reactRouterDataRouter,
1999
2052
  true,
2000
2053
  payload.basename,
2001
2054
  createFromReadableStream,
2002
2055
  fetchImplementation
2003
2056
  )
2004
2057
  });
2005
- if (globalVar.__router.state.initialized) {
2058
+ if (globalVar.__reactRouterDataRouter.state.initialized) {
2006
2059
  globalVar.__routerInitialized = true;
2007
- globalVar.__router.initialize();
2060
+ globalVar.__reactRouterDataRouter.initialize();
2008
2061
  } else {
2009
2062
  globalVar.__routerInitialized = false;
2010
2063
  }
2011
2064
  let lastLoaderData = void 0;
2012
- globalVar.__router.subscribe(({ loaderData, actionData }) => {
2065
+ globalVar.__reactRouterDataRouter.subscribe(({ loaderData, actionData }) => {
2013
2066
  if (lastLoaderData !== loaderData) {
2014
2067
  globalVar.__routerActionID = (globalVar.__routerActionID ?? (globalVar.__routerActionID = 0)) + 1;
2015
2068
  }
2016
2069
  });
2017
- return globalVar.__router;
2070
+ globalVar.__reactRouterDataRouter._updateRoutesForHMR = (routeUpdateByRouteId) => {
2071
+ const oldRoutes = window.__reactRouterDataRouter.routes;
2072
+ const newRoutes = [];
2073
+ function walkRoutes(routes2, parentId) {
2074
+ return routes2.map((route) => {
2075
+ const routeUpdate = routeUpdateByRouteId.get(route.id);
2076
+ if (routeUpdate) {
2077
+ const {
2078
+ routeModule,
2079
+ hasAction,
2080
+ hasComponent,
2081
+ hasErrorBoundary,
2082
+ hasLoader
2083
+ } = routeUpdate;
2084
+ const newRoute = createRouteFromServerManifest({
2085
+ clientAction: routeModule.clientAction,
2086
+ clientLoader: routeModule.clientLoader,
2087
+ element: route.element,
2088
+ errorElement: route.errorElement,
2089
+ handle: route.handle,
2090
+ hasAction,
2091
+ hasComponent,
2092
+ hasErrorBoundary,
2093
+ hasLoader,
2094
+ hydrateFallbackElement: route.hydrateFallbackElement,
2095
+ id: route.id,
2096
+ index: route.index,
2097
+ links: routeModule.links,
2098
+ meta: routeModule.meta,
2099
+ parentId,
2100
+ path: route.path,
2101
+ shouldRevalidate: routeModule.shouldRevalidate
2102
+ });
2103
+ if (route.children) {
2104
+ newRoute.children = walkRoutes(route.children, route.id);
2105
+ }
2106
+ return newRoute;
2107
+ }
2108
+ const updatedRoute = { ...route };
2109
+ if (route.children) {
2110
+ updatedRoute.children = walkRoutes(route.children, route.id);
2111
+ }
2112
+ return updatedRoute;
2113
+ });
2114
+ }
2115
+ newRoutes.push(
2116
+ ...walkRoutes(oldRoutes, void 0)
2117
+ );
2118
+ window.__reactRouterDataRouter._internalSetRoutes(newRoutes);
2119
+ };
2120
+ return {
2121
+ router: globalVar.__reactRouterDataRouter,
2122
+ routeModules: globalVar.__reactRouterRouteModules
2123
+ };
2018
2124
  }
2019
2125
  var renderedRoutesContext = unstable_createContext();
2020
2126
  function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
@@ -2058,7 +2164,7 @@ function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReada
2058
2164
  const renderedRoutes = renderedRoutesById.get(match.route.id);
2059
2165
  if (renderedRoutes) {
2060
2166
  for (const rendered of renderedRoutes) {
2061
- window.__router.patchRoutes(
2167
+ window.__reactRouterDataRouter.patchRoutes(
2062
2168
  rendered.parentId ?? null,
2063
2169
  [createRouteFromServerManifest(rendered)],
2064
2170
  true
@@ -2132,7 +2238,7 @@ function RSCHydratedRouter({
2132
2238
  unstable_getContext
2133
2239
  }) {
2134
2240
  if (payload.type !== "render") throw new Error("Invalid payload type");
2135
- let router = React4.useMemo(
2241
+ let { router, routeModules } = React4.useMemo(
2136
2242
  () => createRouterFromPayload({
2137
2243
  payload,
2138
2244
  fetchImplementation,
@@ -2146,11 +2252,14 @@ function RSCHydratedRouter({
2146
2252
  unstable_getContext
2147
2253
  ]
2148
2254
  );
2255
+ React4.useEffect(() => {
2256
+ setIsHydrated();
2257
+ }, []);
2149
2258
  React4.useLayoutEffect(() => {
2150
2259
  const globalVar = window;
2151
2260
  if (!globalVar.__routerInitialized) {
2152
2261
  globalVar.__routerInitialized = true;
2153
- globalVar.__router.initialize();
2262
+ globalVar.__reactRouterDataRouter.initialize();
2154
2263
  }
2155
2264
  }, []);
2156
2265
  let [location2, setLocation] = React4.useState(router.state.location);
@@ -2216,7 +2325,7 @@ function RSCHydratedRouter({
2216
2325
  unstable_middleware: false,
2217
2326
  unstable_subResourceIntegrity: false
2218
2327
  },
2219
- isSpaMode: true,
2328
+ isSpaMode: false,
2220
2329
  ssr: true,
2221
2330
  criticalCss: "",
2222
2331
  manifest: {
@@ -2229,7 +2338,7 @@ function RSCHydratedRouter({
2229
2338
  }
2230
2339
  },
2231
2340
  routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
2232
- routeModules: {}
2341
+ routeModules
2233
2342
  };
2234
2343
  return /* @__PURE__ */ React4.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React4.createElement(RSCRouterGlobalErrorBoundary, { location: location2 }, /* @__PURE__ */ React4.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React4.createElement(RouterProvider, { router, flushSync: ReactDOM.flushSync }))));
2235
2344
  }
@@ -2242,6 +2351,8 @@ function createRouteFromServerManifest(match, payload) {
2242
2351
  // the server loader flow regardless of whether the client loader calls
2243
2352
  // `serverLoader` or not, otherwise we'll have nothing to render.
2244
2353
  match.hasComponent && !match.element;
2354
+ invariant(window.__reactRouterRouteModules);
2355
+ populateRSCRouteModules(window.__reactRouterRouteModules, match);
2245
2356
  let dataRoute = {
2246
2357
  id: match.id,
2247
2358
  element: match.element,
@@ -2337,7 +2448,10 @@ function getManifestUrl(paths) {
2337
2448
  return new URL(`${paths[0]}.manifest`, window.location.origin);
2338
2449
  }
2339
2450
  const globalVar = window;
2340
- let basename = (globalVar.__router.basename ?? "").replace(/^\/|\/$/g, "");
2451
+ let basename = (globalVar.__reactRouterDataRouter.basename ?? "").replace(
2452
+ /^\/|\/$/g,
2453
+ ""
2454
+ );
2341
2455
  let url = new URL(`${basename}/.manifest`, window.location.origin);
2342
2456
  paths.sort().forEach((path) => url.searchParams.append("p", path));
2343
2457
  return url;
@@ -2363,7 +2477,7 @@ async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fet
2363
2477
  }
2364
2478
  paths.forEach((p) => addToFifoQueue(p, discoveredPaths));
2365
2479
  payload.patches.forEach((p) => {
2366
- window.__router.patchRoutes(
2480
+ window.__reactRouterDataRouter.patchRoutes(
2367
2481
  p.parentId ?? null,
2368
2482
  [createRouteFromServerManifest(p)]
2369
2483
  );
@@ -2640,7 +2754,7 @@ function RSCStaticRouter({ getPayload }) {
2640
2754
  }
2641
2755
  },
2642
2756
  routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
2643
- routeModules: {}
2757
+ routeModules: createRSCRouteModules(payload)
2644
2758
  };
2645
2759
  return /* @__PURE__ */ React5.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React5.createElement(RSCRouterGlobalErrorBoundary, { location: payload.location }, /* @__PURE__ */ React5.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React5.createElement(
2646
2760
  StaticRouterProvider,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.8.0
2
+ * react-router v7.8.1-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -513,8 +513,8 @@ function convertRouteMatchToUiMatch(match, loaderData) {
513
513
  handle: route.handle
514
514
  };
515
515
  }
516
- function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "") {
517
- let flattenRoute = (route, index, relativePath) => {
516
+ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
517
+ let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
518
518
  let meta = {
519
519
  relativePath: relativePath === void 0 ? route.path || "" : relativePath,
520
520
  caseSensitive: route.caseSensitive === true,
@@ -522,6 +522,9 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
522
522
  route
523
523
  };
524
524
  if (meta.relativePath.startsWith("/")) {
525
+ if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
526
+ return;
527
+ }
525
528
  invariant(
526
529
  meta.relativePath.startsWith(parentPath),
527
530
  `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.`
@@ -537,7 +540,13 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
537
540
  route.index !== true,
538
541
  `Index routes must not have child routes. Please remove all child routes from route path "${path}".`
539
542
  );
540
- flattenRoutes(route.children, branches, routesMeta, path);
543
+ flattenRoutes(
544
+ route.children,
545
+ branches,
546
+ routesMeta,
547
+ path,
548
+ hasParentOptionalSegments
549
+ );
541
550
  }
542
551
  if (route.path == null && !route.index) {
543
552
  return;
@@ -553,7 +562,7 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
553
562
  flattenRoute(route, index);
554
563
  } else {
555
564
  for (let exploded of explodeOptionalSegments(route.path)) {
556
- flattenRoute(route, index, exploded);
565
+ flattenRoute(route, index, true, exploded);
557
566
  }
558
567
  }
559
568
  });
@@ -745,7 +754,7 @@ function compilePath(path, caseSensitive = false, end = true) {
745
754
  params.push({ paramName, isOptional: isOptional != null });
746
755
  return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
747
756
  }
748
- );
757
+ ).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
749
758
  if (path.endsWith("*")) {
750
759
  params.push({ paramName: "*" });
751
760
  regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
@@ -3272,8 +3281,12 @@ function createStaticHandler(routes, opts) {
3272
3281
  basename
3273
3282
  );
3274
3283
  }
3275
- if (isResponse(result.result) && isRouteRequest) {
3276
- throw result;
3284
+ if (isRouteRequest) {
3285
+ if (isResponse(result.result)) {
3286
+ throw result;
3287
+ } else if (isDataWithResponseInit(result.result)) {
3288
+ throw dataWithResponseInitToResponse(result.result);
3289
+ }
3277
3290
  }
3278
3291
  dataResults[match.route.id] = await convertDataStrategyResultToDataResult(result);
3279
3292
  })
@@ -3941,9 +3954,15 @@ function clientMiddlewareErrorHandler(error, routeId, matches, didCallHandler) {
3941
3954
  [routeId]: { type: "error", result: error }
3942
3955
  };
3943
3956
  } else {
3957
+ let maxBoundaryIdx = Math.min(
3958
+ // Throwing route
3959
+ matches.findIndex((m) => m.route.id === routeId) || 0,
3960
+ // or the shallowest route that needs to load data
3961
+ matches.findIndex((m) => m.unstable_shouldCallHandler()) || 0
3962
+ );
3944
3963
  let boundaryRouteId = findNearestBoundary(
3945
3964
  matches,
3946
- matches.find((m) => m.route.id === routeId || m.route.loader)?.route.id || routeId
3965
+ matches[maxBoundaryIdx].route.id
3947
3966
  ).route.id;
3948
3967
  return {
3949
3968
  [boundaryRouteId]: { type: "error", result: error }
@@ -8698,6 +8717,9 @@ function isValidMetaTag(tagName) {
8698
8717
  return typeof tagName === "string" && /^(meta|link)$/.test(tagName);
8699
8718
  }
8700
8719
  var isHydrated = false;
8720
+ function setIsHydrated() {
8721
+ isHydrated = true;
8722
+ }
8701
8723
  function Scripts(scriptProps) {
8702
8724
  let {
8703
8725
  manifest,
@@ -8716,7 +8738,7 @@ function Scripts(scriptProps) {
8716
8738
  }
8717
8739
  let matches = getActiveMatches(routerMatches, null, isSpaMode);
8718
8740
  React8.useEffect(() => {
8719
- isHydrated = true;
8741
+ setIsHydrated();
8720
8742
  }, []);
8721
8743
  let initialScripts = React8.useMemo(() => {
8722
8744
  if (isRSCRouterContext) {
@@ -8972,7 +8994,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
8972
8994
  try {
8973
8995
  if (isBrowser) {
8974
8996
  window.__reactRouterVersion = // @ts-expect-error
8975
- "7.8.0";
8997
+ "7.8.1-pre.0";
8976
8998
  }
8977
8999
  } catch (e) {
8978
9000
  }
@@ -10171,6 +10193,7 @@ export {
10171
10193
  Links,
10172
10194
  PrefetchPageLinks,
10173
10195
  Meta,
10196
+ setIsHydrated,
10174
10197
  Scripts,
10175
10198
  createBrowserRouter,
10176
10199
  createHashRouter,
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
2
- * react-router v7.8.0
2
+ * react-router v7.8.1-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -11,7 +11,7 @@
11
11
  "use client";
12
12
 
13
13
 
14
- var _chunkEVX7OBGBjs = require('./chunk-EVX7OBGB.js');
14
+ var _chunkCXAO7FY7js = require('./chunk-CXAO7FY7.js');
15
15
 
16
16
  // lib/dom-export/dom-router-provider.tsx
17
17
  var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
@@ -180,7 +180,7 @@ function HydratedRouter(props) {
180
180
  }, []);
181
181
  React2.useEffect(() => {
182
182
  if (process.env.NODE_ENV === "development" && criticalCss === void 0) {
183
- document.querySelectorAll(`[${_chunkEVX7OBGBjs.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
183
+ document.querySelectorAll(`[${_chunkCXAO7FY7js.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
184
184
  }
185
185
  }, [criticalCss]);
186
186
  let [location, setLocation] = React2.useState(router.state.location);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.8.0
2
+ * react-router v7.8.1-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -12,7 +12,7 @@
12
12
  import {
13
13
  deserializeErrors,
14
14
  getHydrationData
15
- } from "./chunk-HZX6U7MI.mjs";
15
+ } from "./chunk-V2P3SFSY.mjs";
16
16
  import {
17
17
  CRITICAL_CSS_DATA_ATTRIBUTE,
18
18
  FrameworkContext,
@@ -29,7 +29,7 @@ import {
29
29
  invariant,
30
30
  mapRouteProperties,
31
31
  useFogOFWarDiscovery
32
- } from "./chunk-ZYFC6VSF.mjs";
32
+ } from "./chunk-WKLBIS42.mjs";
33
33
 
34
34
  // lib/dom-export/dom-router-provider.tsx
35
35
  import * as React from "react";
@@ -1,7 +1,7 @@
1
1
  import './components-CuPfnyiZ.mjs';
2
2
  import * as React from 'react';
3
3
  import { az as RouteManifest, M as MiddlewareEnabled, o as unstable_RouterContextProvider, j as LoaderFunctionArgs, i as ActionFunctionArgs, J as StaticHandlerContext, H as HydrationState, z as DataRouteObject, a2 as HTMLFormMethod, a0 as FormEncType, a as RelativeRoutingType, T as To, aA as History, E as GetScrollRestorationKeyFunction, e as RouterInit, F as FutureConfig$1, D as DataStrategyFunction, P as PatchRoutesOnNavigationFunction, q as NavigateOptions, K as Fetcher, f as RouteObject, R as Router, B as BlockerFunction, c as Location, aB as CreateStaticHandlerOptions$1, C as StaticHandler } from './context-DohQKLID.mjs';
4
- import { o as ServerRouteModule, A as AppLoadContext, c as RouteModules, h as ClientLoaderFunction, m as PageLinkDescriptor, d as SerializeFrom } from './route-data-CpB5xtMm.mjs';
4
+ import { o as ServerRouteModule, A as AppLoadContext, c as RouteModules, h as ClientLoaderFunction, m as PageLinkDescriptor, d as SerializeFrom } from './route-data-CNjObrhZ.mjs';
5
5
 
6
6
  type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
7
7
  interface ServerRoute extends Route {
@@ -1,4 +1,4 @@
1
- import { I as InitialEntry, T as To, i as RelativeRoutingType, w as NonIndexRouteObject, af as LazyRouteFunction, q as IndexRouteObject, a as Location, A as Action, aC as Navigator, d as Router$1, Q as RouterInit, aY as FutureConfig$1, H as HydrationState, D as DataStrategyFunction, W as PatchRoutesOnNavigationFunction, p as RouteObject, aE as RouteMatch, o as Params, U as UIMatch, ae as HTMLFormMethod, ac as FormEncType, aZ as RouteManifest, a_ as ServerRouteModule, z as MiddlewareEnabled, y as unstable_RouterContextProvider, x as AppLoadContext, ag as LoaderFunctionArgs, a6 as ActionFunctionArgs, e as RouteModules, X as DataRouteObject, J as ClientLoaderFunction, $ as StaticHandlerContext, aJ as PageLinkDescriptor, a$ as History, _ as GetScrollRestorationKeyFunction, f as NavigateOptions, a0 as Fetcher, h as SerializeFrom, B as BlockerFunction, b0 as CreateStaticHandlerOptions$1, Y as StaticHandler } from './routeModules-qBivMBjd.js';
1
+ import { I as InitialEntry, T as To, i as RelativeRoutingType, w as NonIndexRouteObject, ag as LazyRouteFunction, q as IndexRouteObject, a as Location, A as Action, aD as Navigator, d as Router$1, V as RouterInit, aZ as FutureConfig$1, H as HydrationState, D as DataStrategyFunction, X as PatchRoutesOnNavigationFunction, p as RouteObject, aF as RouteMatch, o as Params, U as UIMatch, af as HTMLFormMethod, ad as FormEncType, a_ as RouteManifest, a$ as ServerRouteModule, z as MiddlewareEnabled, y as unstable_RouterContextProvider, x as AppLoadContext, ah as LoaderFunctionArgs, a7 as ActionFunctionArgs, e as RouteModules, Y as DataRouteObject, K as ClientLoaderFunction, a0 as StaticHandlerContext, aK as PageLinkDescriptor, b0 as History, $ as GetScrollRestorationKeyFunction, f as NavigateOptions, a1 as Fetcher, h as SerializeFrom, B as BlockerFunction, b1 as CreateStaticHandlerOptions$1, Z as StaticHandler } from './routeModules-C3oqzPpI.js';
2
2
  import * as React from 'react';
3
3
 
4
4
  declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
@@ -1,5 +1,5 @@
1
1
  export { f as Await, g as MemoryRouter, h as Navigate, i as Outlet, j as Route, k as Router, l as RouterProvider, m as Routes, W as UNSAFE_WithComponentProps, v as UNSAFE_WithErrorBoundaryProps, t as UNSAFE_WithHydrateFallbackProps } from './components-CuPfnyiZ.mjs';
2
- export { l as BrowserRouter, q as Form, m as HashRouter, n as Link, X as Links, W as Meta, p as NavLink, r as ScrollRestoration, T as StaticRouter, V as StaticRouterProvider, o as unstable_HistoryRouter } from './index-react-server-client-DXb0OgpJ.mjs';
2
+ export { l as BrowserRouter, q as Form, m as HashRouter, n as Link, X as Links, W as Meta, p as NavLink, r as ScrollRestoration, T as StaticRouter, V as StaticRouterProvider, o as unstable_HistoryRouter } from './index-react-server-client-11fLy3qB.mjs';
3
3
  import './context-DohQKLID.mjs';
4
4
  import 'react';
5
- import './route-data-CpB5xtMm.mjs';
5
+ import './route-data-CNjObrhZ.mjs';
@@ -1,3 +1,3 @@
1
- export { h as Await, V as BrowserRouter, _ as Form, W as HashRouter, X as Link, am as Links, i as MemoryRouter, al as Meta, Z as NavLink, j as Navigate, k as Outlet, l as Route, m as Router, n as RouterProvider, o as Routes, $ as ScrollRestoration, aj as StaticRouter, ak as StaticRouterProvider, az as UNSAFE_WithComponentProps, aD as UNSAFE_WithErrorBoundaryProps, aB as UNSAFE_WithHydrateFallbackProps, Y as unstable_HistoryRouter } from './index-react-server-client-CMphySRb.js';
2
- import './routeModules-qBivMBjd.js';
1
+ export { h as Await, V as BrowserRouter, _ as Form, W as HashRouter, X as Link, am as Links, i as MemoryRouter, al as Meta, Z as NavLink, j as Navigate, k as Outlet, l as Route, m as Router, n as RouterProvider, o as Routes, $ as ScrollRestoration, aj as StaticRouter, ak as StaticRouterProvider, az as UNSAFE_WithComponentProps, aD as UNSAFE_WithErrorBoundaryProps, aB as UNSAFE_WithHydrateFallbackProps, Y as unstable_HistoryRouter } from './index-react-server-client-BQ6FxdA_.js';
2
+ import './routeModules-C3oqzPpI.js';
3
3
  import 'react';
@@ -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.0
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 _chunk3JLHOGU7js = require('./chunk-3JLHOGU7.js');
34
34
 
35
35
 
36
36
 
37
- var _chunkEVX7OBGBjs = require('./chunk-EVX7OBGB.js');
37
+ var _chunkCXAO7FY7js = require('./chunk-CXAO7FY7.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 = _chunk3JLHOGU7js.Await; exports.BrowserRouter = _chunk3JLHOGU7js.BrowserRouter; exports.Form = _chunk3JLHOGU7js.Form; exports.HashRouter = _chunk3JLHOGU7js.HashRouter; exports.Link = _chunk3JLHOGU7js.Link; exports.Links = _chunkCXAO7FY7js.Links; exports.MemoryRouter = _chunk3JLHOGU7js.MemoryRouter; exports.Meta = _chunkCXAO7FY7js.Meta; exports.NavLink = _chunk3JLHOGU7js.NavLink; exports.Navigate = _chunk3JLHOGU7js.Navigate; exports.Outlet = _chunk3JLHOGU7js.Outlet; exports.Route = _chunk3JLHOGU7js.Route; exports.Router = _chunk3JLHOGU7js.Router; exports.RouterProvider = _chunk3JLHOGU7js.RouterProvider; exports.Routes = _chunk3JLHOGU7js.Routes; exports.ScrollRestoration = _chunk3JLHOGU7js.ScrollRestoration; exports.StaticRouter = _chunk3JLHOGU7js.StaticRouter; exports.StaticRouterProvider = _chunk3JLHOGU7js.StaticRouterProvider; exports.UNSAFE_WithComponentProps = _chunk3JLHOGU7js.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunk3JLHOGU7js.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunk3JLHOGU7js.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunk3JLHOGU7js.HistoryRouter;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.8.0
2
+ * react-router v7.8.1-pre.0
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-WKLBIS42.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 };