@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # `@remix-run/router`
2
2
 
3
+ ## 1.22.0-pre-v6.1
4
+
5
+ ### Minor Changes
6
+
7
+ - Provide the request `signal` as a parameter to `patchRoutesOnNavigation` ([#12900](https://github.com/remix-run/react-router/pull/12900))
8
+
9
+ - This can be used to abort any manifest fetches if the in-flight navigation/fetcher is aborted
10
+
11
+ ### Patch Changes
12
+
13
+ - Strip search parameters from `patchRoutesOnNavigation` `path` param for fetcher calls ([#12899](https://github.com/remix-run/react-router/pull/12899))
14
+
15
+ ## 1.21.2-pre-v6.0
16
+
17
+ ### Patch Changes
18
+
19
+ - Do not log v7 deprecation warnings in production builds ([#12794](https://github.com/remix-run/react-router/pull/12794))
20
+ - Properly bubble headers when throwing a `data()` result ([#12845](https://github.com/remix-run/react-router/pull/12845))
21
+ - Optimize route matching by skipping redundant `matchRoutes` calls when possible ([#12169](https://github.com/remix-run/react-router/pull/12169))
22
+
3
23
  ## 1.21.1
4
24
 
5
25
  ### Patch Changes
@@ -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
  *
@@ -1748,6 +1748,7 @@ function createRouter(init) {
1748
1748
  // SSR did the initial scroll restoration.
1749
1749
  let initialScrollRestored = init.hydrationData != null;
1750
1750
  let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
1751
+ let initialMatchesIsFOW = false;
1751
1752
  let initialErrors = null;
1752
1753
  if (initialMatches == null && !patchRoutesOnNavigationImpl) {
1753
1754
  // If we do not match a user-provided-route, fall back to the root
@@ -1788,6 +1789,7 @@ function createRouter(init) {
1788
1789
  if (future.v7_partialHydration) {
1789
1790
  let fogOfWar = checkFogOfWar(null, dataRoutes, init.history.location.pathname);
1790
1791
  if (fogOfWar.active && fogOfWar.matches) {
1792
+ initialMatchesIsFOW = true;
1791
1793
  initialMatches = fogOfWar.matches;
1792
1794
  }
1793
1795
  }
@@ -2316,7 +2318,9 @@ function createRouter(init) {
2316
2318
  pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
2317
2319
  let routesToUse = inFlightDataRoutes || dataRoutes;
2318
2320
  let loadingNavigation = opts && opts.overrideNavigation;
2319
- let matches = matchRoutes(routesToUse, location, basename);
2321
+ let matches = opts != null && opts.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ?
2322
+ // `matchRoutes()` has already been called if we're in here via `router.initialize()`
2323
+ state.matches : matchRoutes(routesToUse, location, basename);
2320
2324
  let flushSync = (opts && opts.flushSync) === true;
2321
2325
  let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
2322
2326
  if (fogOfWar.active && fogOfWar.matches) {
@@ -2852,7 +2856,7 @@ function createRouter(init) {
2852
2856
  let abortController = new AbortController();
2853
2857
  let fetchRequest = createClientSideRequest(init.history, path, abortController.signal, submission);
2854
2858
  if (isFogOfWar) {
2855
- let discoverResult = await discoverRoutes(requestMatches, path, fetchRequest.signal);
2859
+ let discoverResult = await discoverRoutes(requestMatches, new URL(fetchRequest.url).pathname, fetchRequest.signal);
2856
2860
  if (discoverResult.type === "aborted") {
2857
2861
  return;
2858
2862
  } else if (discoverResult.type === "error") {
@@ -3038,7 +3042,7 @@ function createRouter(init) {
3038
3042
  let abortController = new AbortController();
3039
3043
  let fetchRequest = createClientSideRequest(init.history, path, abortController.signal);
3040
3044
  if (isFogOfWar) {
3041
- let discoverResult = await discoverRoutes(matches, path, fetchRequest.signal);
3045
+ let discoverResult = await discoverRoutes(matches, new URL(fetchRequest.url).pathname, fetchRequest.signal);
3042
3046
  if (discoverResult.type === "aborted") {
3043
3047
  return;
3044
3048
  } else if (discoverResult.type === "error") {
@@ -3596,6 +3600,7 @@ function createRouter(init) {
3596
3600
  let localManifest = manifest;
3597
3601
  try {
3598
3602
  await patchRoutesOnNavigationImpl({
3603
+ signal,
3599
3604
  path: pathname,
3600
3605
  matches: partialMatches,
3601
3606
  patch: (routeId, children) => {
@@ -4868,18 +4873,24 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
4868
4873
  }
4869
4874
  if (type === ResultType.error) {
4870
4875
  if (isDataWithResponseInit(result)) {
4871
- var _result$init2;
4876
+ var _result$init3, _result$init4;
4872
4877
  if (result.data instanceof Error) {
4873
- var _result$init;
4878
+ var _result$init, _result$init2;
4874
4879
  return {
4875
4880
  type: ResultType.error,
4876
4881
  error: result.data,
4877
- statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status
4882
+ statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status,
4883
+ headers: (_result$init2 = result.init) != null && _result$init2.headers ? new Headers(result.init.headers) : undefined
4878
4884
  };
4879
4885
  }
4880
4886
 
4881
4887
  // Convert thrown data() to ErrorResponse instances
4882
- result = new ErrorResponseImpl(((_result$init2 = result.init) == null ? void 0 : _result$init2.status) || 500, undefined, result.data);
4888
+ return {
4889
+ type: ResultType.error,
4890
+ error: new ErrorResponseImpl(((_result$init3 = result.init) == null ? void 0 : _result$init3.status) || 500, undefined, result.data),
4891
+ statusCode: isRouteErrorResponse(result) ? result.status : undefined,
4892
+ headers: (_result$init4 = result.init) != null && _result$init4.headers ? new Headers(result.init.headers) : undefined
4893
+ };
4883
4894
  }
4884
4895
  return {
4885
4896
  type: ResultType.error,
@@ -4888,21 +4899,21 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
4888
4899
  };
4889
4900
  }
4890
4901
  if (isDeferredData(result)) {
4891
- var _result$init3, _result$init4;
4902
+ var _result$init5, _result$init6;
4892
4903
  return {
4893
4904
  type: ResultType.deferred,
4894
4905
  deferredData: result,
4895
- statusCode: (_result$init3 = result.init) == null ? void 0 : _result$init3.status,
4896
- headers: ((_result$init4 = result.init) == null ? void 0 : _result$init4.headers) && new Headers(result.init.headers)
4906
+ statusCode: (_result$init5 = result.init) == null ? void 0 : _result$init5.status,
4907
+ headers: ((_result$init6 = result.init) == null ? void 0 : _result$init6.headers) && new Headers(result.init.headers)
4897
4908
  };
4898
4909
  }
4899
4910
  if (isDataWithResponseInit(result)) {
4900
- var _result$init5, _result$init6;
4911
+ var _result$init7, _result$init8;
4901
4912
  return {
4902
4913
  type: ResultType.data,
4903
4914
  data: result.data,
4904
- statusCode: (_result$init5 = result.init) == null ? void 0 : _result$init5.status,
4905
- headers: (_result$init6 = result.init) != null && _result$init6.headers ? new Headers(result.init.headers) : undefined
4915
+ statusCode: (_result$init7 = result.init) == null ? void 0 : _result$init7.status,
4916
+ headers: (_result$init8 = result.init) != null && _result$init8.headers ? new Headers(result.init.headers) : undefined
4906
4917
  };
4907
4918
  }
4908
4919
  return {