react-router 7.9.5-pre.0 → 7.9.6-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 (64) hide show
  1. package/CHANGELOG.md +33 -1
  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-76L3QNAV.mjs → chunk-7TW6LJC6.mjs} +71 -20
  5. package/dist/development/{chunk-KXZSW2DO.js → chunk-DB25NZIA.js} +7 -7
  6. package/dist/development/{chunk-FXLUBU25.js → chunk-IR7LYQCC.js} +93 -93
  7. package/dist/{production/chunk-4JX2RDWY.mjs → development/chunk-P6ZEAD4C.mjs} +2 -2
  8. package/dist/development/{chunk-TSYPWE43.js → chunk-TUTX3ERH.js} +100 -49
  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/development/{index-react-server-client-BSxMvS7Z.d.ts → 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 +1 -1
  20. package/dist/development/index-react-server.mjs +1 -1
  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/{production/router-DIAPGK5f.d.mts → development/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/{development/chunk-B6QYCHJF.mjs → production/chunk-4MBU4DF6.mjs} +2 -2
  36. package/dist/production/{chunk-7EXEUENX.mjs → chunk-GG2LAVOQ.mjs} +71 -20
  37. package/dist/production/{chunk-4SZHQXEM.js → chunk-MKF3AQDO.js} +7 -7
  38. package/dist/production/{chunk-ARKB3I5K.js → chunk-RBZEEJIK.js} +100 -49
  39. package/dist/production/{chunk-OB3KSCCZ.js → chunk-ZHTTD7UY.js} +93 -93
  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/production/{index-react-server-client-BSxMvS7Z.d.ts → 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 +1 -1
  51. package/dist/production/index-react-server.mjs +1 -1
  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/{development/router-DIAPGK5f.d.mts → production/router-CAvh_Drx.d.mts} +5 -1
  64. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,10 +1,41 @@
1
1
  # `react-router`
2
2
 
3
- ## 7.9.5-pre.0
3
+ ## 7.9.6-pre.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [UNSTABLE] Add `location`/`params` as arguments to client-side `unstable_onError` to permit enhanced error reporting. ([#14509](https://github.com/remix-run/react-router/pull/14509))
8
+
9
+ ⚠️ This is a breaking change if you've already adopted `unstable_onError`. The second `errorInfo` parameter is now an object with `location` and `params`:
10
+
11
+ ```tsx
12
+ // Before
13
+ function errorHandler(error: unknown, errorInfo?: React.errorInfo) {
14
+ /*...*/
15
+ }
16
+
17
+ // After
18
+ function errorHandler(
19
+ error: unknown,
20
+ info: {
21
+ location: Location;
22
+ params: Params;
23
+ errorInfo?: React.ErrorInfo;
24
+ },
25
+ ) {
26
+ /*...*/
27
+ }
28
+ ```
29
+
30
+ - Properly handle ancestor thrown middleware errors before `next()` on fetcher submissions ([#14517](https://github.com/remix-run/react-router/pull/14517))
31
+ - Fix issue with splat routes interfering with multiple calls to patchRoutesOnNavigation ([#14487](https://github.com/remix-run/react-router/pull/14487))
32
+
33
+ ## 7.9.5
4
34
 
5
35
  ### Patch Changes
6
36
 
7
37
  - Move RSCHydratedRouter and utils to `/dom` export. ([#14457](https://github.com/remix-run/react-router/pull/14457))
38
+
8
39
  - useRoute: return type-safe `handle` ([#14462](https://github.com/remix-run/react-router/pull/14462))
9
40
 
10
41
  For example:
@@ -25,6 +56,7 @@
25
56
  ```
26
57
 
27
58
  - Ensure action handlers run for routes with middleware even if no loader is present ([#14443](https://github.com/remix-run/react-router/pull/14443))
59
+
28
60
  - Add `unstable_instrumentations` API to allow users to add observablity to their apps by instrumenting route loaders, actions, middlewares, lazy, as well as server-side request handlers and client side navigations/fetches ([#14412](https://github.com/remix-run/react-router/pull/14412))
29
61
  - Framework Mode:
30
62
  - `entry.server.tsx`: `export const unstable_instrumentations = [...]`
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction, e as RouterInit } from './instrumentation-iAqbU5Q4.js';
2
+ import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction, e as RouterInit } from './instrumentation-Unc20tLk.js';
3
3
 
4
4
  type RSCRouteConfigEntryBase = {
5
5
  action?: ActionFunction;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction, e as RouterInit } from './router-DIAPGK5f.mjs';
2
+ import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction, e as RouterInit } from './router-CAvh_Drx.mjs';
3
3
 
4
4
  type RSCRouteConfigEntryBase = {
5
5
  action?: ActionFunction;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.9.5-pre.0
2
+ * react-router v7.9.6-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2306,6 +2306,14 @@ function createRouter(init) {
2306
2306
  key
2307
2307
  );
2308
2308
  let actionResult = actionResults[match.route.id];
2309
+ if (!actionResult) {
2310
+ for (let match2 of fetchMatches) {
2311
+ if (actionResults[match2.route.id]) {
2312
+ actionResult = actionResults[match2.route.id];
2313
+ break;
2314
+ }
2315
+ }
2316
+ }
2309
2317
  if (fetchRequest.signal.aborted) {
2310
2318
  if (fetchControllers.get(key) === abortController) {
2311
2319
  fetchControllers.delete(key);
@@ -2962,23 +2970,43 @@ function createRouter(init) {
2962
2970
  return { type: "aborted" };
2963
2971
  }
2964
2972
  let newMatches = matchRoutes(routesToUse, pathname, basename);
2973
+ let newPartialMatches = null;
2965
2974
  if (newMatches) {
2966
- return { type: "success", matches: newMatches };
2975
+ if (Object.keys(newMatches[0].params).length === 0) {
2976
+ return { type: "success", matches: newMatches };
2977
+ } else {
2978
+ newPartialMatches = matchRoutesImpl(
2979
+ routesToUse,
2980
+ pathname,
2981
+ basename,
2982
+ true
2983
+ );
2984
+ let matchedDeeper = newPartialMatches && partialMatches.length < newPartialMatches.length && compareMatches(
2985
+ partialMatches,
2986
+ newPartialMatches.slice(0, partialMatches.length)
2987
+ );
2988
+ if (!matchedDeeper) {
2989
+ return { type: "success", matches: newMatches };
2990
+ }
2991
+ }
2967
2992
  }
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
- )) {
2993
+ if (!newPartialMatches) {
2994
+ newPartialMatches = matchRoutesImpl(
2995
+ routesToUse,
2996
+ pathname,
2997
+ basename,
2998
+ true
2999
+ );
3000
+ }
3001
+ if (!newPartialMatches || compareMatches(partialMatches, newPartialMatches)) {
2977
3002
  return { type: "success", matches: null };
2978
3003
  }
2979
3004
  partialMatches = newPartialMatches;
2980
3005
  }
2981
3006
  }
3007
+ function compareMatches(a, b) {
3008
+ return a.length === b.length && a.every((m, i) => m.route.id === b[i].route.id);
3009
+ }
2982
3010
  function _internalSetRoutes(newRoutes) {
2983
3011
  manifest = {};
2984
3012
  inFlightDataRoutes = convertRoutesToDataRoutes(
@@ -5589,8 +5617,8 @@ var RenderErrorBoundary = class extends React2.Component {
5589
5617
  };
5590
5618
  }
5591
5619
  componentDidCatch(error, errorInfo) {
5592
- if (this.props.unstable_onError) {
5593
- this.props.unstable_onError(error, errorInfo);
5620
+ if (this.props.onError) {
5621
+ this.props.onError(error, errorInfo);
5594
5622
  } else {
5595
5623
  console.error(
5596
5624
  "React Router caught the following error during render",
@@ -5668,6 +5696,13 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, uns
5668
5696
  }
5669
5697
  }
5670
5698
  }
5699
+ let onError = dataRouterState && unstable_onError ? (error, errorInfo) => {
5700
+ unstable_onError(error, {
5701
+ location: dataRouterState.location,
5702
+ params: dataRouterState.matches?.[0]?.params ?? {},
5703
+ errorInfo
5704
+ });
5705
+ } : void 0;
5671
5706
  return renderedMatches.reduceRight(
5672
5707
  (outlet, match, index) => {
5673
5708
  let error;
@@ -5728,7 +5763,7 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, uns
5728
5763
  error,
5729
5764
  children: getChildren(),
5730
5765
  routeContext: { outlet: null, matches: matches2, isDataRoute: true },
5731
- unstable_onError
5766
+ onError
5732
5767
  }
5733
5768
  ) : getChildren();
5734
5769
  },
@@ -6140,7 +6175,10 @@ function RouterProvider({
6140
6175
  if (newState.errors && unstable_onError) {
6141
6176
  Object.entries(newState.errors).forEach(([routeId, error]) => {
6142
6177
  if (prevState.errors?.[routeId] !== error) {
6143
- unstable_onError(error);
6178
+ unstable_onError(error, {
6179
+ location: newState.location,
6180
+ params: newState.matches[0]?.params ?? {}
6181
+ });
6144
6182
  }
6145
6183
  });
6146
6184
  }
@@ -6469,12 +6507,25 @@ function Await({
6469
6507
  resolve
6470
6508
  }) {
6471
6509
  let dataRouterContext = React3.useContext(DataRouterContext);
6510
+ let dataRouterStateContext = React3.useContext(DataRouterStateContext);
6511
+ let onError = React3.useCallback(
6512
+ (error, errorInfo) => {
6513
+ if (dataRouterContext && dataRouterContext.unstable_onError && dataRouterStateContext) {
6514
+ dataRouterContext.unstable_onError(error, {
6515
+ location: dataRouterStateContext.location,
6516
+ params: dataRouterStateContext.matches?.[0]?.params || {},
6517
+ errorInfo
6518
+ });
6519
+ }
6520
+ },
6521
+ [dataRouterContext, dataRouterStateContext]
6522
+ );
6472
6523
  return /* @__PURE__ */ React3.createElement(
6473
6524
  AwaitErrorBoundary,
6474
6525
  {
6475
6526
  resolve,
6476
6527
  errorElement,
6477
- unstable_onError: dataRouterContext?.unstable_onError
6528
+ onError
6478
6529
  },
6479
6530
  /* @__PURE__ */ React3.createElement(ResolveAwait, null, children)
6480
6531
  );
@@ -6488,8 +6539,8 @@ var AwaitErrorBoundary = class extends React3.Component {
6488
6539
  return { error };
6489
6540
  }
6490
6541
  componentDidCatch(error, errorInfo) {
6491
- if (this.props.unstable_onError) {
6492
- this.props.unstable_onError(error, errorInfo);
6542
+ if (this.props.onError) {
6543
+ this.props.onError(error, errorInfo);
6493
6544
  } else {
6494
6545
  console.error(
6495
6546
  "<Await> caught the following error during render",
@@ -6523,7 +6574,7 @@ var AwaitErrorBoundary = class extends React3.Component {
6523
6574
  promise = resolve.then(
6524
6575
  (data2) => Object.defineProperty(resolve, "_data", { get: () => data2 }),
6525
6576
  (error) => {
6526
- this.props.unstable_onError?.(error);
6577
+ this.props.onError?.(error);
6527
6578
  Object.defineProperty(resolve, "_error", { get: () => error });
6528
6579
  }
6529
6580
  );
@@ -9466,7 +9517,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
9466
9517
  try {
9467
9518
  if (isBrowser) {
9468
9519
  window.__reactRouterVersion = // @ts-expect-error
9469
- "7.9.5-pre.0";
9520
+ "7.9.6-pre.0";
9470
9521
  }
9471
9522
  } catch (e) {
9472
9523
  }
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/**
2
- * react-router v7.9.5-pre.0
2
+ * react-router v7.9.6-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
 
17
- var _chunkTSYPWE43js = require('./chunk-TSYPWE43.js');
17
+ var _chunkTUTX3ERHjs = require('./chunk-TUTX3ERH.js');
18
18
 
19
19
  // lib/dom/ssr/hydration.tsx
20
20
  function getHydrationData({
@@ -29,12 +29,12 @@ function getHydrationData({
29
29
  ...state,
30
30
  loaderData: { ...state.loaderData }
31
31
  };
32
- let initialMatches = _chunkTSYPWE43js.matchRoutes.call(void 0, routes, location, basename);
32
+ let initialMatches = _chunkTUTX3ERHjs.matchRoutes.call(void 0, routes, location, basename);
33
33
  if (initialMatches) {
34
34
  for (let match of initialMatches) {
35
35
  let routeId = match.route.id;
36
36
  let routeInfo = getRouteInfo(routeId);
37
- if (_chunkTSYPWE43js.shouldHydrateRouteLoader.call(void 0,
37
+ if (_chunkTUTX3ERHjs.shouldHydrateRouteLoader.call(void 0,
38
38
  routeId,
39
39
  routeInfo.clientLoader,
40
40
  routeInfo.hasLoader,
@@ -112,7 +112,7 @@ function RSCDefaultRootErrorBoundaryImpl({
112
112
  }
113
113
  }
114
114
  );
115
- if (_chunkTSYPWE43js.isRouteErrorResponse.call(void 0, error)) {
115
+ if (_chunkTUTX3ERHjs.isRouteErrorResponse.call(void 0, error)) {
116
116
  return /* @__PURE__ */ _react2.default.createElement(
117
117
  ErrorWrapper,
118
118
  {
@@ -120,7 +120,7 @@ function RSCDefaultRootErrorBoundaryImpl({
120
120
  title: "Unhandled Thrown Response!"
121
121
  },
122
122
  /* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText),
123
- _chunkTSYPWE43js.ENABLE_DEV_WARNINGS ? heyDeveloper : null
123
+ _chunkTUTX3ERHjs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
124
124
  );
125
125
  }
126
126
  let errorInstance;
@@ -146,7 +146,7 @@ function RSCDefaultRootErrorBoundaryImpl({
146
146
  function RSCDefaultRootErrorBoundary({
147
147
  hasRootLayout
148
148
  }) {
149
- let error = _chunkTSYPWE43js.useRouteError.call(void 0, );
149
+ let error = _chunkTUTX3ERHjs.useRouteError.call(void 0, );
150
150
  if (hasRootLayout === void 0) {
151
151
  throw new Error("Missing 'hasRootLayout' prop");
152
152
  }