@tanstack/router-core 1.131.17 → 1.131.18

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.
@@ -1115,10 +1115,12 @@ class RouterCore {
1115
1115
  this.getMatch(matchId),
1116
1116
  loaderData
1117
1117
  );
1118
- innerLoadContext.updateMatch(matchId, (prev) => ({
1119
- ...prev,
1120
- loaderData
1121
- }));
1118
+ if (loaderData !== void 0) {
1119
+ innerLoadContext.updateMatch(matchId, (prev) => ({
1120
+ ...prev,
1121
+ loaderData
1122
+ }));
1123
+ }
1122
1124
  }
1123
1125
  if (route._lazyPromise) await route._lazyPromise;
1124
1126
  const headResult = this.executeHead(innerLoadContext, matchId, route);
@@ -1203,9 +1205,9 @@ class RouterCore {
1203
1205
  return this.getMatch(matchId);
1204
1206
  }
1205
1207
  await prevMatch._nonReactive.loaderPromise;
1206
- const match = this.getMatch(matchId);
1207
- if (match.error) {
1208
- this.handleRedirectAndNotFound(innerLoadContext, match, match.error);
1208
+ const match2 = this.getMatch(matchId);
1209
+ if (match2.error) {
1210
+ this.handleRedirectAndNotFound(innerLoadContext, match2, match2.error);
1209
1211
  }
1210
1212
  } else {
1211
1213
  const age = Date.now() - this.getMatch(matchId).updatedAt;
@@ -1215,13 +1217,15 @@ class RouterCore {
1215
1217
  const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(
1216
1218
  this.getLoaderContext(innerLoadContext, matchId, index, route)
1217
1219
  ) : shouldReloadOption;
1218
- innerLoadContext.updateMatch(matchId, (prev) => {
1219
- prev._nonReactive.loaderPromise = utils.createControlledPromise();
1220
- return {
1220
+ const nextPreload = !!preload && !this.state.matches.some((d) => d.id === matchId);
1221
+ const match2 = this.getMatch(matchId);
1222
+ match2._nonReactive.loaderPromise = utils.createControlledPromise();
1223
+ if (nextPreload !== match2.preload) {
1224
+ innerLoadContext.updateMatch(matchId, (prev) => ({
1221
1225
  ...prev,
1222
- preload: !!preload && !this.state.matches.some((d) => d.id === matchId)
1223
- };
1224
- });
1226
+ preload: nextPreload
1227
+ }));
1228
+ }
1225
1229
  const { status, invalid } = this.getMatch(matchId);
1226
1230
  loaderShouldRunAsync = status === "success" && (invalid || (shouldReload ?? age > staleAge));
1227
1231
  if (preload && route.options.preload === false) ;
@@ -1231,10 +1235,10 @@ class RouterCore {
1231
1235
  var _a2, _b2;
1232
1236
  try {
1233
1237
  await this.runLoader(innerLoadContext, matchId, index, route);
1234
- const match = this.getMatch(matchId);
1235
- (_a2 = match._nonReactive.loaderPromise) == null ? void 0 : _a2.resolve();
1236
- (_b2 = match._nonReactive.loadPromise) == null ? void 0 : _b2.resolve();
1237
- match._nonReactive.loaderPromise = void 0;
1238
+ const match3 = this.getMatch(matchId);
1239
+ (_a2 = match3._nonReactive.loaderPromise) == null ? void 0 : _a2.resolve();
1240
+ (_b2 = match3._nonReactive.loadPromise) == null ? void 0 : _b2.resolve();
1241
+ match3._nonReactive.loaderPromise = void 0;
1238
1242
  } catch (err) {
1239
1243
  if (redirect.isRedirect(err)) {
1240
1244
  await this.navigate(err.options);
@@ -1254,22 +1258,23 @@ class RouterCore {
1254
1258
  }
1255
1259
  }
1256
1260
  }
1261
+ const match = this.getMatch(matchId);
1257
1262
  if (!loaderIsRunningAsync) {
1258
- const match = this.getMatch(matchId);
1259
1263
  (_a = match._nonReactive.loaderPromise) == null ? void 0 : _a.resolve();
1260
1264
  (_b = match._nonReactive.loadPromise) == null ? void 0 : _b.resolve();
1261
1265
  }
1262
- innerLoadContext.updateMatch(matchId, (prev) => {
1263
- clearTimeout(prev._nonReactive.pendingTimeout);
1264
- prev._nonReactive.pendingTimeout = void 0;
1265
- if (!loaderIsRunningAsync) prev._nonReactive.loaderPromise = void 0;
1266
- prev._nonReactive.dehydrated = void 0;
1267
- return {
1266
+ clearTimeout(match._nonReactive.pendingTimeout);
1267
+ match._nonReactive.pendingTimeout = void 0;
1268
+ if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = void 0;
1269
+ match._nonReactive.dehydrated = void 0;
1270
+ const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false;
1271
+ if (nextIsFetching !== match.isFetching || match.invalid !== false) {
1272
+ innerLoadContext.updateMatch(matchId, (prev) => ({
1268
1273
  ...prev,
1269
- isFetching: loaderIsRunningAsync ? prev.isFetching : false,
1274
+ isFetching: nextIsFetching,
1270
1275
  invalid: false
1271
- };
1272
- });
1276
+ }));
1277
+ }
1273
1278
  return this.getMatch(matchId);
1274
1279
  };
1275
1280
  this.loadMatches = async (baseContext) => {