@remix-run/router 1.20.0-pre.0 → 1.20.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/router",
3
- "version": "1.20.0-pre.0",
3
+ "version": "1.20.0",
4
4
  "description": "Nested/Data-driven/Framework-agnostic Routing",
5
5
  "keywords": [
6
6
  "remix",
package/router.ts CHANGED
@@ -1690,17 +1690,15 @@ export function createRouter(init: RouterInit): Router {
1690
1690
  if (discoverResult.type === "aborted") {
1691
1691
  return { shortCircuited: true };
1692
1692
  } else if (discoverResult.type === "error") {
1693
- let { boundaryId, error } = handleDiscoverRouteError(
1694
- location.pathname,
1695
- discoverResult
1696
- );
1693
+ let boundaryId = findNearestBoundary(discoverResult.partialMatches)
1694
+ .route.id;
1697
1695
  return {
1698
1696
  matches: discoverResult.partialMatches,
1699
1697
  pendingActionResult: [
1700
1698
  boundaryId,
1701
1699
  {
1702
1700
  type: ResultType.error,
1703
- error,
1701
+ error: discoverResult.error,
1704
1702
  },
1705
1703
  ],
1706
1704
  };
@@ -1868,15 +1866,13 @@ export function createRouter(init: RouterInit): Router {
1868
1866
  if (discoverResult.type === "aborted") {
1869
1867
  return { shortCircuited: true };
1870
1868
  } else if (discoverResult.type === "error") {
1871
- let { boundaryId, error } = handleDiscoverRouteError(
1872
- location.pathname,
1873
- discoverResult
1874
- );
1869
+ let boundaryId = findNearestBoundary(discoverResult.partialMatches)
1870
+ .route.id;
1875
1871
  return {
1876
1872
  matches: discoverResult.partialMatches,
1877
1873
  loaderData: {},
1878
1874
  errors: {
1879
- [boundaryId]: error,
1875
+ [boundaryId]: discoverResult.error,
1880
1876
  },
1881
1877
  };
1882
1878
  } else if (!discoverResult.matches) {
@@ -2254,8 +2250,7 @@ export function createRouter(init: RouterInit): Router {
2254
2250
  if (discoverResult.type === "aborted") {
2255
2251
  return;
2256
2252
  } else if (discoverResult.type === "error") {
2257
- let { error } = handleDiscoverRouteError(path, discoverResult);
2258
- setFetcherError(key, routeId, error, { flushSync });
2253
+ setFetcherError(key, routeId, discoverResult.error, { flushSync });
2259
2254
  return;
2260
2255
  } else if (!discoverResult.matches) {
2261
2256
  setFetcherError(
@@ -2547,8 +2542,7 @@ export function createRouter(init: RouterInit): Router {
2547
2542
  if (discoverResult.type === "aborted") {
2548
2543
  return;
2549
2544
  } else if (discoverResult.type === "error") {
2550
- let { error } = handleDiscoverRouteError(path, discoverResult);
2551
- setFetcherError(key, routeId, error, { flushSync });
2545
+ setFetcherError(key, routeId, discoverResult.error, { flushSync });
2552
2546
  return;
2553
2547
  } else if (!discoverResult.matches) {
2554
2548
  setFetcherError(
@@ -3124,23 +3118,6 @@ export function createRouter(init: RouterInit): Router {
3124
3118
  return { notFoundMatches: matches, route, error };
3125
3119
  }
3126
3120
 
3127
- function handleDiscoverRouteError(
3128
- pathname: string,
3129
- discoverResult: DiscoverRoutesErrorResult
3130
- ) {
3131
- return {
3132
- boundaryId: findNearestBoundary(discoverResult.partialMatches).route.id,
3133
- error: getInternalRouterError(400, {
3134
- type: "route-discovery",
3135
- pathname,
3136
- message:
3137
- discoverResult.error != null && "message" in discoverResult.error
3138
- ? discoverResult.error
3139
- : String(discoverResult.error),
3140
- }),
3141
- };
3142
- }
3143
-
3144
3121
  function cancelActiveDeferreds(
3145
3122
  predicate?: (routeId: string) => boolean
3146
3123
  ): string[] {
@@ -5485,7 +5462,7 @@ function getInternalRouterError(
5485
5462
  pathname?: string;
5486
5463
  routeId?: string;
5487
5464
  method?: string;
5488
- type?: "defer-action" | "invalid-body" | "route-discovery";
5465
+ type?: "defer-action" | "invalid-body";
5489
5466
  message?: string;
5490
5467
  } = {}
5491
5468
  ) {
@@ -5494,11 +5471,7 @@ function getInternalRouterError(
5494
5471
 
5495
5472
  if (status === 400) {
5496
5473
  statusText = "Bad Request";
5497
- if (type === "route-discovery") {
5498
- errorMessage =
5499
- `Unable to match URL "${pathname}" - the \`patchRoutesOnNavigation()\` ` +
5500
- `function threw the following error:\n${message}`;
5501
- } else if (method && pathname && routeId) {
5474
+ if (method && pathname && routeId) {
5502
5475
  errorMessage =
5503
5476
  `You made a ${method} request to "${pathname}" but ` +
5504
5477
  `did not provide a \`loader\` for route "${routeId}", ` +