@remix-run/router 1.21.1 → 1.22.0-pre-v6.1

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.22.0-pre-v6.1
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) {
@@ -2854,7 +2858,7 @@
2854
2858
  let abortController = new AbortController();
2855
2859
  let fetchRequest = createClientSideRequest(init.history, path, abortController.signal, submission);
2856
2860
  if (isFogOfWar) {
2857
- let discoverResult = await discoverRoutes(requestMatches, path, fetchRequest.signal);
2861
+ let discoverResult = await discoverRoutes(requestMatches, new URL(fetchRequest.url).pathname, fetchRequest.signal);
2858
2862
  if (discoverResult.type === "aborted") {
2859
2863
  return;
2860
2864
  } else if (discoverResult.type === "error") {
@@ -3040,7 +3044,7 @@
3040
3044
  let abortController = new AbortController();
3041
3045
  let fetchRequest = createClientSideRequest(init.history, path, abortController.signal);
3042
3046
  if (isFogOfWar) {
3043
- let discoverResult = await discoverRoutes(matches, path, fetchRequest.signal);
3047
+ let discoverResult = await discoverRoutes(matches, new URL(fetchRequest.url).pathname, fetchRequest.signal);
3044
3048
  if (discoverResult.type === "aborted") {
3045
3049
  return;
3046
3050
  } else if (discoverResult.type === "error") {
@@ -3598,6 +3602,7 @@
3598
3602
  let localManifest = manifest;
3599
3603
  try {
3600
3604
  await patchRoutesOnNavigationImpl({
3605
+ signal,
3601
3606
  path: pathname,
3602
3607
  matches: partialMatches,
3603
3608
  patch: (routeId, children) => {
@@ -4870,18 +4875,24 @@
4870
4875
  }
4871
4876
  if (type === ResultType.error) {
4872
4877
  if (isDataWithResponseInit(result)) {
4873
- var _result$init2;
4878
+ var _result$init3, _result$init4;
4874
4879
  if (result.data instanceof Error) {
4875
- var _result$init;
4880
+ var _result$init, _result$init2;
4876
4881
  return {
4877
4882
  type: ResultType.error,
4878
4883
  error: result.data,
4879
- statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status
4884
+ statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status,
4885
+ headers: (_result$init2 = result.init) != null && _result$init2.headers ? new Headers(result.init.headers) : undefined
4880
4886
  };
4881
4887
  }
4882
4888
 
4883
4889
  // Convert thrown data() to ErrorResponse instances
4884
- result = new ErrorResponseImpl(((_result$init2 = result.init) == null ? void 0 : _result$init2.status) || 500, undefined, result.data);
4890
+ return {
4891
+ type: ResultType.error,
4892
+ error: new ErrorResponseImpl(((_result$init3 = result.init) == null ? void 0 : _result$init3.status) || 500, undefined, result.data),
4893
+ statusCode: isRouteErrorResponse(result) ? result.status : undefined,
4894
+ headers: (_result$init4 = result.init) != null && _result$init4.headers ? new Headers(result.init.headers) : undefined
4895
+ };
4885
4896
  }
4886
4897
  return {
4887
4898
  type: ResultType.error,
@@ -4890,21 +4901,21 @@
4890
4901
  };
4891
4902
  }
4892
4903
  if (isDeferredData(result)) {
4893
- var _result$init3, _result$init4;
4904
+ var _result$init5, _result$init6;
4894
4905
  return {
4895
4906
  type: ResultType.deferred,
4896
4907
  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)
4908
+ statusCode: (_result$init5 = result.init) == null ? void 0 : _result$init5.status,
4909
+ headers: ((_result$init6 = result.init) == null ? void 0 : _result$init6.headers) && new Headers(result.init.headers)
4899
4910
  };
4900
4911
  }
4901
4912
  if (isDataWithResponseInit(result)) {
4902
- var _result$init5, _result$init6;
4913
+ var _result$init7, _result$init8;
4903
4914
  return {
4904
4915
  type: ResultType.data,
4905
4916
  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
4917
+ statusCode: (_result$init7 = result.init) == null ? void 0 : _result$init7.status,
4918
+ headers: (_result$init8 = result.init) != null && _result$init8.headers ? new Headers(result.init.headers) : undefined
4908
4919
  };
4909
4920
  }
4910
4921
  return {