@remix-run/router 1.12.0 → 1.13.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/dist/router.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v1.12.0
2
+ * @remix-run/router v1.13.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -938,6 +938,12 @@ function getInvalidPathError(char, field, dest, path) {
938
938
  function getPathContributingMatches(matches) {
939
939
  return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0);
940
940
  }
941
+ // Return the array of pathnames for the current route matches - used to
942
+ // generate the routePathnames input for resolveTo()
943
+ function getResolveToMatches(matches) {
944
+ // Use the full pathname for the leaf match so we include splat values for "." links
945
+ return getPathContributingMatches(matches).map((match, idx) => idx === matches.length - 1 ? match.pathname : match.pathnameBase);
946
+ }
941
947
  /**
942
948
  * @private
943
949
  */
@@ -1987,7 +1993,7 @@ function createRouter(init) {
1987
1993
  // we have it on the loading navigation so use that if available
1988
1994
  let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
1989
1995
  let routesToUse = inFlightDataRoutes || dataRoutes;
1990
- let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, activeSubmission, location, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionData, pendingError);
1996
+ let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, activeSubmission, location, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionData, pendingError);
1991
1997
  // Cancel pending deferreds for no-longer-matched routes or routes we're
1992
1998
  // about to reload. Note that if this is an action reload we would have
1993
1999
  // already cancelled all pending deferreds so this would be a no-op
@@ -2231,7 +2237,7 @@ function createRouter(init) {
2231
2237
  fetchReloadIds.set(key, loadId);
2232
2238
  let loadFetcher = getLoadingFetcher(submission, actionResult.data);
2233
2239
  state.fetchers.set(key, loadFetcher);
2234
- let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, submission, nextLocation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, {
2240
+ let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, submission, nextLocation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, {
2235
2241
  [match.route.id]: actionResult.data
2236
2242
  }, undefined // No need to send through errors since we short circuit above
2237
2243
  );
@@ -3181,7 +3187,7 @@ function normalizeTo(location, matches, basename, prependBasename, to, fromRoute
3181
3187
  activeRouteMatch = matches[matches.length - 1];
3182
3188
  }
3183
3189
  // Resolve the relative path
3184
- let path = resolveTo(to ? to : ".", getPathContributingMatches(contextualMatches).map(m => m.pathnameBase), stripBasename(location.pathname, basename) || location.pathname, relative === "path");
3190
+ let path = resolveTo(to ? to : ".", getResolveToMatches(contextualMatches), stripBasename(location.pathname, basename) || location.pathname, relative === "path");
3185
3191
  // When `to` is not specified we inherit search/hash from the current
3186
3192
  // location, unlike when to="." and we just inherit the path.
3187
3193
  // See https://github.com/remix-run/remix/issues/927
@@ -3338,7 +3344,7 @@ function getLoaderMatchesUntilBoundary(matches, boundaryId) {
3338
3344
  }
3339
3345
  return boundaryMatches;
3340
3346
  }
3341
- function getMatchesToLoad(history, state, matches, submission, location, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionData, pendingError) {
3347
+ function getMatchesToLoad(history, state, matches, submission, location, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionData, pendingError) {
3342
3348
  let actionResult = pendingError ? Object.values(pendingError)[0] : pendingActionData ? Object.values(pendingActionData)[0] : undefined;
3343
3349
  let currentUrl = history.createURL(state.location);
3344
3350
  let nextUrl = history.createURL(location);
@@ -3383,7 +3389,7 @@ function getMatchesToLoad(history, state, matches, submission, location, isReval
3383
3389
  let revalidatingFetchers = [];
3384
3390
  fetchLoadMatches.forEach((f, key) => {
3385
3391
  // Don't revalidate if fetcher won't be present in the subsequent render
3386
- if (!matches.some(m => m.route.id === f.routeId)) {
3392
+ if (!matches.some(m => m.route.id === f.routeId) || deletedFetchers.has(key)) {
3387
3393
  return;
3388
3394
  }
3389
3395
  let fetcherMatches = matchRoutes(routesToUse, f.path, basename);
@@ -4233,5 +4239,5 @@ function persistAppliedTransitions(_window, transitions) {
4233
4239
  }
4234
4240
  //#endregion
4235
4241
 
4236
- export { AbortedDeferredError, Action, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, UNSAFE_DEFERRED_SYMBOL, DeferredData as UNSAFE_DeferredData, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, convertRouteMatchToUiMatch as UNSAFE_convertRouteMatchToUiMatch, convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, getPathContributingMatches as UNSAFE_getPathContributingMatches, invariant as UNSAFE_invariant, warning as UNSAFE_warning, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, createRouter, createStaticHandler, defer, generatePath, getStaticContextFromError, getToPathname, isDeferredData, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, parsePath, redirect, redirectDocument, resolvePath, resolveTo, stripBasename };
4242
+ export { AbortedDeferredError, Action, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, UNSAFE_DEFERRED_SYMBOL, DeferredData as UNSAFE_DeferredData, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, convertRouteMatchToUiMatch as UNSAFE_convertRouteMatchToUiMatch, convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, getResolveToMatches as UNSAFE_getResolveToMatches, invariant as UNSAFE_invariant, warning as UNSAFE_warning, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, createRouter, createStaticHandler, defer, generatePath, getStaticContextFromError, getToPathname, isDeferredData, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, parsePath, redirect, redirectDocument, resolvePath, resolveTo, stripBasename };
4237
4243
  //# sourceMappingURL=router.js.map