react-router 7.9.5 → 7.9.6-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 (64) hide show
  1. package/CHANGELOG.md +37 -10
  2. package/dist/development/{browser-DM83uryY.d.ts → browser-BbBXFHbO.d.ts} +1 -1
  3. package/dist/development/{browser-DfMfSvsC.d.mts → browser-C07r42Tt.d.mts} +1 -1
  4. package/dist/development/{chunk-VNR6V74N.js → chunk-CYHICRRW.js} +124 -52
  5. package/dist/development/{chunk-UIGDSWPH.mjs → chunk-DKSAHU2I.mjs} +95 -23
  6. package/dist/{production/chunk-ERPFE3MR.js → development/chunk-HSVNPM3C.js} +93 -93
  7. package/dist/{production/chunk-CWEARR4H.js → development/chunk-OLIKX45O.js} +7 -7
  8. package/dist/development/{chunk-JG3XND5A.mjs → chunk-RGKEVI2W.mjs} +2 -2
  9. package/dist/development/dom-export.d.mts +2 -2
  10. package/dist/development/dom-export.d.ts +2 -2
  11. package/dist/development/dom-export.js +26 -26
  12. package/dist/development/dom-export.mjs +3 -3
  13. package/dist/{production/index-react-server-client-BSxMvS7Z.d.ts → development/index-react-server-client-Da3kmxNd.d.ts} +1 -1
  14. package/dist/development/{index-react-server-client-B0vnxMMk.d.mts → index-react-server-client-rcoGPJhU.d.mts} +1 -1
  15. package/dist/development/index-react-server-client.d.mts +2 -2
  16. package/dist/development/index-react-server-client.d.ts +2 -2
  17. package/dist/development/index-react-server-client.js +4 -4
  18. package/dist/development/index-react-server-client.mjs +2 -2
  19. package/dist/development/index-react-server.js +25 -4
  20. package/dist/development/index-react-server.mjs +25 -4
  21. package/dist/development/index.d.mts +8 -8
  22. package/dist/development/index.d.ts +8 -8
  23. package/dist/development/index.js +76 -76
  24. package/dist/development/index.mjs +3 -3
  25. package/dist/{production/instrumentation-iAqbU5Q4.d.ts → development/instrumentation-Unc20tLk.d.ts} +5 -1
  26. package/dist/development/lib/types/internal.d.mts +2 -2
  27. package/dist/development/lib/types/internal.d.ts +2 -2
  28. package/dist/development/lib/types/internal.js +1 -1
  29. package/dist/development/lib/types/internal.mjs +1 -1
  30. package/dist/development/{register-c-dooqKE.d.ts → register-BpU9rFBJ.d.ts} +1 -1
  31. package/dist/development/{register-_G476ptB.d.mts → register-QkB3HGjm.d.mts} +1 -1
  32. package/dist/development/{router-DIAPGK5f.d.mts → router-CAvh_Drx.d.mts} +5 -1
  33. package/dist/production/{browser-DM83uryY.d.ts → browser-BbBXFHbO.d.ts} +1 -1
  34. package/dist/production/{browser-DfMfSvsC.d.mts → browser-C07r42Tt.d.mts} +1 -1
  35. package/dist/production/{chunk-EAE7427A.js → chunk-2DNJUQK6.js} +124 -52
  36. package/dist/{development/chunk-IXESJAGJ.js → production/chunk-EDK3MRM6.js} +93 -93
  37. package/dist/{development/chunk-FQEOJFGW.js → production/chunk-JLDESRHY.js} +7 -7
  38. package/dist/production/{chunk-TPBVZP6U.mjs → chunk-LC2OWLJG.mjs} +2 -2
  39. package/dist/production/{chunk-RZ6LZWMW.mjs → chunk-LESYMMDQ.mjs} +95 -23
  40. package/dist/production/dom-export.d.mts +2 -2
  41. package/dist/production/dom-export.d.ts +2 -2
  42. package/dist/production/dom-export.js +26 -26
  43. package/dist/production/dom-export.mjs +3 -3
  44. package/dist/{development/index-react-server-client-BSxMvS7Z.d.ts → production/index-react-server-client-Da3kmxNd.d.ts} +1 -1
  45. package/dist/production/{index-react-server-client-B0vnxMMk.d.mts → index-react-server-client-rcoGPJhU.d.mts} +1 -1
  46. package/dist/production/index-react-server-client.d.mts +2 -2
  47. package/dist/production/index-react-server-client.d.ts +2 -2
  48. package/dist/production/index-react-server-client.js +4 -4
  49. package/dist/production/index-react-server-client.mjs +2 -2
  50. package/dist/production/index-react-server.js +25 -4
  51. package/dist/production/index-react-server.mjs +25 -4
  52. package/dist/production/index.d.mts +8 -8
  53. package/dist/production/index.d.ts +8 -8
  54. package/dist/production/index.js +76 -76
  55. package/dist/production/index.mjs +3 -3
  56. package/dist/{development/instrumentation-iAqbU5Q4.d.ts → production/instrumentation-Unc20tLk.d.ts} +5 -1
  57. package/dist/production/lib/types/internal.d.mts +2 -2
  58. package/dist/production/lib/types/internal.d.ts +2 -2
  59. package/dist/production/lib/types/internal.js +1 -1
  60. package/dist/production/lib/types/internal.mjs +1 -1
  61. package/dist/production/{register-c-dooqKE.d.ts → register-BpU9rFBJ.d.ts} +1 -1
  62. package/dist/production/{register-_G476ptB.d.mts → register-QkB3HGjm.d.mts} +1 -1
  63. package/dist/production/{router-DIAPGK5f.d.mts → router-CAvh_Drx.d.mts} +5 -1
  64. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.9.5
2
+ * react-router v7.9.6-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -811,13 +811,36 @@ function prependBasename({
811
811
  }) {
812
812
  return pathname === "/" ? basename : joinPaths([basename, pathname]);
813
813
  }
814
+ var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
815
+ var isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url);
814
816
  function resolvePath(to, fromPathname = "/") {
815
817
  let {
816
818
  pathname: toPathname,
817
819
  search = "",
818
820
  hash = ""
819
821
  } = typeof to === "string" ? parsePath(to) : to;
820
- let pathname = toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname(toPathname, fromPathname) : fromPathname;
822
+ let pathname;
823
+ if (toPathname) {
824
+ if (isAbsoluteUrl(toPathname)) {
825
+ pathname = toPathname;
826
+ } else {
827
+ if (toPathname.includes("//")) {
828
+ let oldPathname = toPathname;
829
+ toPathname = toPathname.replace(/\/\/+/g, "/");
830
+ warning(
831
+ false,
832
+ `Pathnames cannot have embedded double slashes - normalizing ${oldPathname} -> ${toPathname}`
833
+ );
834
+ }
835
+ if (toPathname.startsWith("/")) {
836
+ pathname = resolvePathname(toPathname.substring(1), "/");
837
+ } else {
838
+ pathname = resolvePathname(toPathname, fromPathname);
839
+ }
840
+ }
841
+ } else {
842
+ pathname = fromPathname;
843
+ }
821
844
  return {
822
845
  pathname,
823
846
  search: normalizeSearch(search),
@@ -1265,8 +1288,6 @@ var IDLE_BLOCKER = {
1265
1288
  reset: void 0,
1266
1289
  location: void 0
1267
1290
  };
1268
- var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1269
- var isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url);
1270
1291
  var defaultMapRouteProperties = (route) => ({
1271
1292
  hasErrorBoundary: Boolean(route.hasErrorBoundary)
1272
1293
  });
@@ -2306,6 +2327,14 @@ function createRouter(init) {
2306
2327
  key
2307
2328
  );
2308
2329
  let actionResult = actionResults[match.route.id];
2330
+ if (!actionResult) {
2331
+ for (let match2 of fetchMatches) {
2332
+ if (actionResults[match2.route.id]) {
2333
+ actionResult = actionResults[match2.route.id];
2334
+ break;
2335
+ }
2336
+ }
2337
+ }
2309
2338
  if (fetchRequest.signal.aborted) {
2310
2339
  if (fetchControllers.get(key) === abortController) {
2311
2340
  fetchControllers.delete(key);
@@ -2962,23 +2991,43 @@ function createRouter(init) {
2962
2991
  return { type: "aborted" };
2963
2992
  }
2964
2993
  let newMatches = matchRoutes(routesToUse, pathname, basename);
2994
+ let newPartialMatches = null;
2965
2995
  if (newMatches) {
2966
- return { type: "success", matches: newMatches };
2996
+ if (Object.keys(newMatches[0].params).length === 0) {
2997
+ return { type: "success", matches: newMatches };
2998
+ } else {
2999
+ newPartialMatches = matchRoutesImpl(
3000
+ routesToUse,
3001
+ pathname,
3002
+ basename,
3003
+ true
3004
+ );
3005
+ let matchedDeeper = newPartialMatches && partialMatches.length < newPartialMatches.length && compareMatches(
3006
+ partialMatches,
3007
+ newPartialMatches.slice(0, partialMatches.length)
3008
+ );
3009
+ if (!matchedDeeper) {
3010
+ return { type: "success", matches: newMatches };
3011
+ }
3012
+ }
2967
3013
  }
2968
- let newPartialMatches = matchRoutesImpl(
2969
- routesToUse,
2970
- pathname,
2971
- basename,
2972
- true
2973
- );
2974
- if (!newPartialMatches || partialMatches.length === newPartialMatches.length && partialMatches.every(
2975
- (m, i) => m.route.id === newPartialMatches[i].route.id
2976
- )) {
3014
+ if (!newPartialMatches) {
3015
+ newPartialMatches = matchRoutesImpl(
3016
+ routesToUse,
3017
+ pathname,
3018
+ basename,
3019
+ true
3020
+ );
3021
+ }
3022
+ if (!newPartialMatches || compareMatches(partialMatches, newPartialMatches)) {
2977
3023
  return { type: "success", matches: null };
2978
3024
  }
2979
3025
  partialMatches = newPartialMatches;
2980
3026
  }
2981
3027
  }
3028
+ function compareMatches(a, b) {
3029
+ return a.length === b.length && a.every((m, i) => m.route.id === b[i].route.id);
3030
+ }
2982
3031
  function _internalSetRoutes(newRoutes) {
2983
3032
  manifest = {};
2984
3033
  inFlightDataRoutes = convertRoutesToDataRoutes(
@@ -5589,8 +5638,8 @@ var RenderErrorBoundary = class extends React2.Component {
5589
5638
  };
5590
5639
  }
5591
5640
  componentDidCatch(error, errorInfo) {
5592
- if (this.props.unstable_onError) {
5593
- this.props.unstable_onError(error, errorInfo);
5641
+ if (this.props.onError) {
5642
+ this.props.onError(error, errorInfo);
5594
5643
  } else {
5595
5644
  console.error(
5596
5645
  "React Router caught the following error during render",
@@ -5668,6 +5717,13 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, uns
5668
5717
  }
5669
5718
  }
5670
5719
  }
5720
+ let onError = dataRouterState && unstable_onError ? (error, errorInfo) => {
5721
+ unstable_onError(error, {
5722
+ location: dataRouterState.location,
5723
+ params: dataRouterState.matches?.[0]?.params ?? {},
5724
+ errorInfo
5725
+ });
5726
+ } : void 0;
5671
5727
  return renderedMatches.reduceRight(
5672
5728
  (outlet, match, index) => {
5673
5729
  let error;
@@ -5728,7 +5784,7 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, uns
5728
5784
  error,
5729
5785
  children: getChildren(),
5730
5786
  routeContext: { outlet: null, matches: matches2, isDataRoute: true },
5731
- unstable_onError
5787
+ onError
5732
5788
  }
5733
5789
  ) : getChildren();
5734
5790
  },
@@ -6140,7 +6196,10 @@ function RouterProvider({
6140
6196
  if (newState.errors && unstable_onError) {
6141
6197
  Object.entries(newState.errors).forEach(([routeId, error]) => {
6142
6198
  if (prevState.errors?.[routeId] !== error) {
6143
- unstable_onError(error);
6199
+ unstable_onError(error, {
6200
+ location: newState.location,
6201
+ params: newState.matches[0]?.params ?? {}
6202
+ });
6144
6203
  }
6145
6204
  });
6146
6205
  }
@@ -6469,12 +6528,25 @@ function Await({
6469
6528
  resolve
6470
6529
  }) {
6471
6530
  let dataRouterContext = React3.useContext(DataRouterContext);
6531
+ let dataRouterStateContext = React3.useContext(DataRouterStateContext);
6532
+ let onError = React3.useCallback(
6533
+ (error, errorInfo) => {
6534
+ if (dataRouterContext && dataRouterContext.unstable_onError && dataRouterStateContext) {
6535
+ dataRouterContext.unstable_onError(error, {
6536
+ location: dataRouterStateContext.location,
6537
+ params: dataRouterStateContext.matches?.[0]?.params || {},
6538
+ errorInfo
6539
+ });
6540
+ }
6541
+ },
6542
+ [dataRouterContext, dataRouterStateContext]
6543
+ );
6472
6544
  return /* @__PURE__ */ React3.createElement(
6473
6545
  AwaitErrorBoundary,
6474
6546
  {
6475
6547
  resolve,
6476
6548
  errorElement,
6477
- unstable_onError: dataRouterContext?.unstable_onError
6549
+ onError
6478
6550
  },
6479
6551
  /* @__PURE__ */ React3.createElement(ResolveAwait, null, children)
6480
6552
  );
@@ -6488,8 +6560,8 @@ var AwaitErrorBoundary = class extends React3.Component {
6488
6560
  return { error };
6489
6561
  }
6490
6562
  componentDidCatch(error, errorInfo) {
6491
- if (this.props.unstable_onError) {
6492
- this.props.unstable_onError(error, errorInfo);
6563
+ if (this.props.onError) {
6564
+ this.props.onError(error, errorInfo);
6493
6565
  } else {
6494
6566
  console.error(
6495
6567
  "<Await> caught the following error during render",
@@ -6523,7 +6595,7 @@ var AwaitErrorBoundary = class extends React3.Component {
6523
6595
  promise = resolve.then(
6524
6596
  (data2) => Object.defineProperty(resolve, "_data", { get: () => data2 }),
6525
6597
  (error) => {
6526
- this.props.unstable_onError?.(error);
6598
+ this.props.onError?.(error);
6527
6599
  Object.defineProperty(resolve, "_error", { get: () => error });
6528
6600
  }
6529
6601
  );
@@ -9466,7 +9538,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
9466
9538
  try {
9467
9539
  if (isBrowser) {
9468
9540
  window.__reactRouterVersion = // @ts-expect-error
9469
- "7.9.5";
9541
+ "7.9.6-pre.1";
9470
9542
  }
9471
9543
  } catch (e) {
9472
9544
  }