@tanstack/router-core 0.0.1-beta.182 → 0.0.1-beta.184

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.
@@ -789,8 +789,6 @@
789
789
  const val = search[key];
790
790
  if (typeof val === 'undefined' || val === undefined) {
791
791
  delete search[key];
792
- } else if (Array.isArray(val)) {
793
- search[key] = val.map(stringifyValue);
794
792
  } else {
795
793
  search[key] = stringifyValue(val);
796
794
  }
@@ -841,6 +839,16 @@
841
839
  return next.matchesById[id];
842
840
  });
843
841
  }
842
+ if (matchesByIdChanged || matchesChanged || pendingMatchesChanged) {
843
+ const hasPendingComponent = next.pendingMatches.some(d => {
844
+ const route = this.getRoute(d.routeId);
845
+ return !!route?.options.pendingComponent;
846
+ });
847
+ next.renderedMatchIds = hasPendingComponent ? next.pendingMatchIds : next.matchIds;
848
+ next.renderedMatches = next.renderedMatchIds.map(id => {
849
+ return next.matchesById[id];
850
+ });
851
+ }
844
852
  next.isFetching = [...next.matches, ...next.pendingMatches].some(d => d.isFetching);
845
853
  this.state = next;
846
854
  },
@@ -1054,20 +1062,10 @@
1054
1062
  return this.latestLoadPromise;
1055
1063
  };
1056
1064
  #mergeMatches = (prevMatchesById, nextMatches) => {
1057
- const nextMatchesById = {
1058
- ...prevMatchesById
1065
+ return {
1066
+ ...prevMatchesById,
1067
+ ...Object.fromEntries(nextMatches.map(match => [match.id, match]))
1059
1068
  };
1060
- let hadNew = false;
1061
- nextMatches.forEach(match => {
1062
- if (!nextMatchesById[match.id]) {
1063
- hadNew = true;
1064
- nextMatchesById[match.id] = match;
1065
- }
1066
- });
1067
- if (!hadNew) {
1068
- return prevMatchesById;
1069
- }
1070
- return nextMatchesById;
1071
1069
  };
1072
1070
  getRoute = id => {
1073
1071
  const route = this.routesById[id];
@@ -1217,14 +1215,17 @@
1217
1215
  };
1218
1216
  try {
1219
1217
  const validator = typeof route.options.validateSearch === 'object' ? route.options.validateSearch.parse : route.options.validateSearch;
1220
- const routeSearch = validator?.(parentSearchInfo.search) ?? {};
1221
- const search = {
1218
+ let routeSearch = validator?.(parentSearchInfo.search) ?? {};
1219
+ let search = {
1222
1220
  ...parentSearchInfo.search,
1223
1221
  ...routeSearch
1224
1222
  };
1223
+ routeSearch = replaceEqualDeep(match.routeSearch, routeSearch);
1224
+ search = replaceEqualDeep(match.search, search);
1225
1225
  return {
1226
- routeSearch: replaceEqualDeep(match.routeSearch, routeSearch),
1227
- search: replaceEqualDeep(match.search, search)
1226
+ routeSearch,
1227
+ search,
1228
+ searchDidChange: match.routeSearch !== routeSearch
1228
1229
  };
1229
1230
  } catch (err) {
1230
1231
  match.searchError = new SearchParamError(err.message, {
@@ -1805,7 +1806,6 @@
1805
1806
  };
1806
1807
  #commitLocation = async location => {
1807
1808
  const next = this.buildNext(location);
1808
- const id = '' + Date.now() + Math.random();
1809
1809
  if (this.navigateTimeout) clearTimeout(this.navigateTimeout);
1810
1810
  let nextAction = 'replace';
1811
1811
  if (!location.replace) {
@@ -1816,10 +1816,7 @@
1816
1816
  nextAction = 'replace';
1817
1817
  }
1818
1818
  const href = `${next.pathname}${next.searchStr}${next.hash ? `#${next.hash}` : ''}`;
1819
- this.history[nextAction === 'push' ? 'push' : 'replace'](href, {
1820
- id,
1821
- ...next.state
1822
- });
1819
+ this.history[nextAction === 'push' ? 'push' : 'replace'](href, next.state);
1823
1820
  this.resetNextScroll = location.resetScroll ?? true;
1824
1821
  return this.latestLoadPromise;
1825
1822
  };
@@ -1905,6 +1902,8 @@
1905
1902
  pendingMatchIds: [],
1906
1903
  matches: [],
1907
1904
  pendingMatches: [],
1905
+ renderedMatchIds: [],
1906
+ renderedMatches: [],
1908
1907
  lastUpdated: Date.now()
1909
1908
  };
1910
1909
  }