@remix-run/router 1.17.1 → 1.18.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v1.17.1
2
+ * @remix-run/router v1.18.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1695,7 +1695,7 @@
1695
1695
  v7_partialHydration: false,
1696
1696
  v7_prependBasename: false,
1697
1697
  v7_relativeSplatPath: false,
1698
- unstable_skipActionErrorRevalidation: false
1698
+ v7_skipActionErrorRevalidation: false
1699
1699
  }, init.future);
1700
1700
  // Cleanup function for history
1701
1701
  let unlistenHistory = null;
@@ -1732,10 +1732,13 @@
1732
1732
  };
1733
1733
  }
1734
1734
 
1735
- // If the user provided a patchRoutesOnMiss implementation and our initial
1736
- // match is a splat route, clear them out so we run through lazy discovery
1737
- // on hydration in case there's a more accurate lazy route match
1738
- if (initialMatches && patchRoutesOnMissImpl) {
1735
+ // In SPA apps, if the user provided a patchRoutesOnMiss implementation and
1736
+ // our initial match is a splat route, clear them out so we run through lazy
1737
+ // discovery on hydration in case there's a more accurate lazy route match.
1738
+ // In SSR apps (with `hydrationData`), we expect that the server will send
1739
+ // up the proper matched routes so we don't want to run lazy discovery on
1740
+ // initial hydration and want to hydrate into the splat route.
1741
+ if (initialMatches && patchRoutesOnMissImpl && !init.hydrationData) {
1739
1742
  let fogOfWar = checkFogOfWar(initialMatches, dataRoutes, init.history.location.pathname);
1740
1743
  if (fogOfWar.active) {
1741
1744
  initialMatches = null;
@@ -2407,13 +2410,12 @@
2407
2410
  };
2408
2411
  } else if (discoverResult.type === "error") {
2409
2412
  let {
2410
- error,
2411
- notFoundMatches,
2412
- route
2413
+ boundaryId,
2414
+ error
2413
2415
  } = handleDiscoverRouteError(location.pathname, discoverResult);
2414
2416
  return {
2415
- matches: notFoundMatches,
2416
- pendingActionResult: [route.id, {
2417
+ matches: discoverResult.partialMatches,
2418
+ pendingActionResult: [boundaryId, {
2417
2419
  type: ResultType.error,
2418
2420
  error
2419
2421
  }]
@@ -2546,15 +2548,14 @@
2546
2548
  };
2547
2549
  } else if (discoverResult.type === "error") {
2548
2550
  let {
2549
- error,
2550
- notFoundMatches,
2551
- route
2551
+ boundaryId,
2552
+ error
2552
2553
  } = handleDiscoverRouteError(location.pathname, discoverResult);
2553
2554
  return {
2554
- matches: notFoundMatches,
2555
+ matches: discoverResult.partialMatches,
2555
2556
  loaderData: {},
2556
2557
  errors: {
2557
- [route.id]: error
2558
+ [boundaryId]: error
2558
2559
  }
2559
2560
  };
2560
2561
  } else if (!discoverResult.matches) {
@@ -2575,7 +2576,7 @@
2575
2576
  }
2576
2577
  }
2577
2578
  let routesToUse = inFlightDataRoutes || dataRoutes;
2578
- let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, activeSubmission, location, future.v7_partialHydration && initialHydration === true, future.unstable_skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult);
2579
+ let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, activeSubmission, location, future.v7_partialHydration && initialHydration === true, future.v7_skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult);
2579
2580
 
2580
2581
  // Cancel pending deferreds for no-longer-matched routes or routes we're
2581
2582
  // about to reload. Note that if this is an action reload we would have
@@ -2910,7 +2911,7 @@
2910
2911
  fetchReloadIds.set(key, loadId);
2911
2912
  let loadFetcher = getLoadingFetcher(submission, actionResult.data);
2912
2913
  state.fetchers.set(key, loadFetcher);
2913
- let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, submission, nextLocation, false, future.unstable_skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, [match.route.id, actionResult]);
2914
+ let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, submission, nextLocation, false, future.v7_skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, [match.route.id, actionResult]);
2914
2915
 
2915
2916
  // Put all revalidating fetchers into the loading state, except for the
2916
2917
  // current fetcher which we want to keep in it's current loading state which
@@ -3430,18 +3431,13 @@
3430
3431
  };
3431
3432
  }
3432
3433
  function handleDiscoverRouteError(pathname, discoverResult) {
3433
- let matches = discoverResult.partialMatches;
3434
- let route = matches[matches.length - 1].route;
3435
- let error = getInternalRouterError(400, {
3436
- type: "route-discovery",
3437
- routeId: route.id,
3438
- pathname,
3439
- message: discoverResult.error != null && "message" in discoverResult.error ? discoverResult.error : String(discoverResult.error)
3440
- });
3441
3434
  return {
3442
- notFoundMatches: matches,
3443
- route,
3444
- error
3435
+ boundaryId: findNearestBoundary(discoverResult.partialMatches).route.id,
3436
+ error: getInternalRouterError(400, {
3437
+ type: "route-discovery",
3438
+ pathname,
3439
+ message: discoverResult.error != null && "message" in discoverResult.error ? discoverResult.error : String(discoverResult.error)
3440
+ })
3445
3441
  };
3446
3442
  }
3447
3443
  function cancelActiveDeferreds(predicate) {
@@ -4363,7 +4359,7 @@
4363
4359
  nextParams: nextRouteMatch.params
4364
4360
  }, submission, {
4365
4361
  actionResult,
4366
- unstable_actionStatus: actionStatus,
4362
+ actionStatus,
4367
4363
  defaultShouldRevalidate: shouldSkipRevalidation ? false :
4368
4364
  // Forced revalidation due to submission, useRevalidator, or X-Remix-Revalidate
4369
4365
  isRevalidationRequired || currentUrl.pathname + currentUrl.search === nextUrl.pathname + nextUrl.search ||
@@ -4428,7 +4424,7 @@
4428
4424
  nextParams: matches[matches.length - 1].params
4429
4425
  }, submission, {
4430
4426
  actionResult,
4431
- unstable_actionStatus: actionStatus,
4427
+ actionStatus,
4432
4428
  defaultShouldRevalidate: shouldSkipRevalidation ? false : isRevalidationRequired
4433
4429
  }));
4434
4430
  }
@@ -5074,7 +5070,7 @@
5074
5070
  if (status === 400) {
5075
5071
  statusText = "Bad Request";
5076
5072
  if (type === "route-discovery") {
5077
- errorMessage = "Unable to match URL \"" + pathname + "\" - the `children()` function for " + ("route `" + routeId + "` threw the following error:\n" + message);
5073
+ errorMessage = "Unable to match URL \"" + pathname + "\" - the `unstable_patchRoutesOnMiss()` " + ("function threw the following error:\n" + message);
5078
5074
  } else if (method && pathname && routeId) {
5079
5075
  errorMessage = "You made a " + method + " request to \"" + pathname + "\" but " + ("did not provide a `loader` for route \"" + routeId + "\", ") + "so there is no way to handle the request.";
5080
5076
  } else if (type === "defer-action") {
@@ -5416,6 +5412,7 @@
5416
5412
  exports.UNSAFE_ErrorResponseImpl = ErrorResponseImpl;
5417
5413
  exports.UNSAFE_convertRouteMatchToUiMatch = convertRouteMatchToUiMatch;
5418
5414
  exports.UNSAFE_convertRoutesToDataRoutes = convertRoutesToDataRoutes;
5415
+ exports.UNSAFE_decodePath = decodePath;
5419
5416
  exports.UNSAFE_getResolveToMatches = getResolveToMatches;
5420
5417
  exports.UNSAFE_invariant = invariant;
5421
5418
  exports.UNSAFE_warning = warning;