@remix-run/router 1.21.1 → 1.21.2-pre-v6.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.21.1
2
+ * @remix-run/router v1.21.2-pre-v6.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1750,6 +1750,7 @@
1750
1750
  // SSR did the initial scroll restoration.
1751
1751
  let initialScrollRestored = init.hydrationData != null;
1752
1752
  let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
1753
+ let initialMatchesIsFOW = false;
1753
1754
  let initialErrors = null;
1754
1755
  if (initialMatches == null && !patchRoutesOnNavigationImpl) {
1755
1756
  // If we do not match a user-provided-route, fall back to the root
@@ -1790,6 +1791,7 @@
1790
1791
  if (future.v7_partialHydration) {
1791
1792
  let fogOfWar = checkFogOfWar(null, dataRoutes, init.history.location.pathname);
1792
1793
  if (fogOfWar.active && fogOfWar.matches) {
1794
+ initialMatchesIsFOW = true;
1793
1795
  initialMatches = fogOfWar.matches;
1794
1796
  }
1795
1797
  }
@@ -2318,7 +2320,9 @@
2318
2320
  pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
2319
2321
  let routesToUse = inFlightDataRoutes || dataRoutes;
2320
2322
  let loadingNavigation = opts && opts.overrideNavigation;
2321
- let matches = matchRoutes(routesToUse, location, basename);
2323
+ let matches = opts != null && opts.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ?
2324
+ // `matchRoutes()` has already been called if we're in here via `router.initialize()`
2325
+ state.matches : matchRoutes(routesToUse, location, basename);
2322
2326
  let flushSync = (opts && opts.flushSync) === true;
2323
2327
  let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
2324
2328
  if (fogOfWar.active && fogOfWar.matches) {
@@ -4870,18 +4874,24 @@
4870
4874
  }
4871
4875
  if (type === ResultType.error) {
4872
4876
  if (isDataWithResponseInit(result)) {
4873
- var _result$init2;
4877
+ var _result$init3, _result$init4;
4874
4878
  if (result.data instanceof Error) {
4875
- var _result$init;
4879
+ var _result$init, _result$init2;
4876
4880
  return {
4877
4881
  type: ResultType.error,
4878
4882
  error: result.data,
4879
- statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status
4883
+ statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status,
4884
+ headers: (_result$init2 = result.init) != null && _result$init2.headers ? new Headers(result.init.headers) : undefined
4880
4885
  };
4881
4886
  }
4882
4887
 
4883
4888
  // Convert thrown data() to ErrorResponse instances
4884
- result = new ErrorResponseImpl(((_result$init2 = result.init) == null ? void 0 : _result$init2.status) || 500, undefined, result.data);
4889
+ return {
4890
+ type: ResultType.error,
4891
+ error: new ErrorResponseImpl(((_result$init3 = result.init) == null ? void 0 : _result$init3.status) || 500, undefined, result.data),
4892
+ statusCode: isRouteErrorResponse(result) ? result.status : undefined,
4893
+ headers: (_result$init4 = result.init) != null && _result$init4.headers ? new Headers(result.init.headers) : undefined
4894
+ };
4885
4895
  }
4886
4896
  return {
4887
4897
  type: ResultType.error,
@@ -4890,21 +4900,21 @@
4890
4900
  };
4891
4901
  }
4892
4902
  if (isDeferredData(result)) {
4893
- var _result$init3, _result$init4;
4903
+ var _result$init5, _result$init6;
4894
4904
  return {
4895
4905
  type: ResultType.deferred,
4896
4906
  deferredData: result,
4897
- statusCode: (_result$init3 = result.init) == null ? void 0 : _result$init3.status,
4898
- headers: ((_result$init4 = result.init) == null ? void 0 : _result$init4.headers) && new Headers(result.init.headers)
4907
+ statusCode: (_result$init5 = result.init) == null ? void 0 : _result$init5.status,
4908
+ headers: ((_result$init6 = result.init) == null ? void 0 : _result$init6.headers) && new Headers(result.init.headers)
4899
4909
  };
4900
4910
  }
4901
4911
  if (isDataWithResponseInit(result)) {
4902
- var _result$init5, _result$init6;
4912
+ var _result$init7, _result$init8;
4903
4913
  return {
4904
4914
  type: ResultType.data,
4905
4915
  data: result.data,
4906
- statusCode: (_result$init5 = result.init) == null ? void 0 : _result$init5.status,
4907
- headers: (_result$init6 = result.init) != null && _result$init6.headers ? new Headers(result.init.headers) : undefined
4916
+ statusCode: (_result$init7 = result.init) == null ? void 0 : _result$init7.status,
4917
+ headers: (_result$init8 = result.init) != null && _result$init8.headers ? new Headers(result.init.headers) : undefined
4908
4918
  };
4909
4919
  }
4910
4920
  return {