@tanstack/router-core 1.131.17 → 1.131.19
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/dist/cjs/router.cjs +43 -48
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +43 -48
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +40 -46
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -2697,10 +2697,12 @@ export class RouterCore<
|
|
|
2697
2697
|
this.getMatch(matchId),
|
|
2698
2698
|
loaderData,
|
|
2699
2699
|
)
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2700
|
+
if (loaderData !== undefined) {
|
|
2701
|
+
innerLoadContext.updateMatch(matchId, (prev) => ({
|
|
2702
|
+
...prev,
|
|
2703
|
+
loaderData,
|
|
2704
|
+
}))
|
|
2705
|
+
}
|
|
2704
2706
|
}
|
|
2705
2707
|
|
|
2706
2708
|
// Lazy option can modify the route options,
|
|
@@ -2837,14 +2839,16 @@ export class RouterCore<
|
|
|
2837
2839
|
)
|
|
2838
2840
|
: shouldReloadOption
|
|
2839
2841
|
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2842
|
+
const nextPreload =
|
|
2843
|
+
!!preload && !this.state.matches.some((d) => d.id === matchId)
|
|
2844
|
+
const match = this.getMatch(matchId)!
|
|
2845
|
+
match._nonReactive.loaderPromise = createControlledPromise<void>()
|
|
2846
|
+
if (nextPreload !== match.preload) {
|
|
2847
|
+
innerLoadContext.updateMatch(matchId, (prev) => ({
|
|
2843
2848
|
...prev,
|
|
2844
|
-
preload:
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
})
|
|
2849
|
+
preload: nextPreload,
|
|
2850
|
+
}))
|
|
2851
|
+
}
|
|
2848
2852
|
|
|
2849
2853
|
// If the route is successful and still fresh, just resolve
|
|
2850
2854
|
const { status, invalid } = this.getMatch(matchId)!
|
|
@@ -2886,23 +2890,24 @@ export class RouterCore<
|
|
|
2886
2890
|
}
|
|
2887
2891
|
}
|
|
2888
2892
|
}
|
|
2893
|
+
const match = this.getMatch(matchId)!
|
|
2889
2894
|
if (!loaderIsRunningAsync) {
|
|
2890
|
-
const match = this.getMatch(matchId)!
|
|
2891
2895
|
match._nonReactive.loaderPromise?.resolve()
|
|
2892
2896
|
match._nonReactive.loadPromise?.resolve()
|
|
2893
2897
|
}
|
|
2894
2898
|
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2899
|
+
clearTimeout(match._nonReactive.pendingTimeout)
|
|
2900
|
+
match._nonReactive.pendingTimeout = undefined
|
|
2901
|
+
if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = undefined
|
|
2902
|
+
match._nonReactive.dehydrated = undefined
|
|
2903
|
+
const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false
|
|
2904
|
+
if (nextIsFetching !== match.isFetching || match.invalid !== false) {
|
|
2905
|
+
innerLoadContext.updateMatch(matchId, (prev) => ({
|
|
2901
2906
|
...prev,
|
|
2902
|
-
isFetching:
|
|
2907
|
+
isFetching: nextIsFetching,
|
|
2903
2908
|
invalid: false,
|
|
2904
|
-
}
|
|
2905
|
-
}
|
|
2909
|
+
}))
|
|
2910
|
+
}
|
|
2906
2911
|
return this.getMatch(matchId)!
|
|
2907
2912
|
}
|
|
2908
2913
|
|
|
@@ -2925,33 +2930,22 @@ export class RouterCore<
|
|
|
2925
2930
|
}
|
|
2926
2931
|
|
|
2927
2932
|
try {
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
const beforeLoad = this.handleBeforeLoad(innerLoadContext, i)
|
|
2934
|
-
if (isPromise(beforeLoad)) await beforeLoad
|
|
2935
|
-
}
|
|
2936
|
-
|
|
2937
|
-
// Execute all loaders in parallel
|
|
2938
|
-
const max =
|
|
2939
|
-
innerLoadContext.firstBadMatchIndex ??
|
|
2940
|
-
innerLoadContext.matches.length
|
|
2941
|
-
for (let i = 0; i < max; i++) {
|
|
2942
|
-
innerLoadContext.matchPromises.push(
|
|
2943
|
-
this.loadRouteMatch(innerLoadContext, i),
|
|
2944
|
-
)
|
|
2945
|
-
}
|
|
2933
|
+
// Execute all beforeLoads one by one
|
|
2934
|
+
for (let i = 0; i < innerLoadContext.matches.length; i++) {
|
|
2935
|
+
const beforeLoad = this.handleBeforeLoad(innerLoadContext, i)
|
|
2936
|
+
if (isPromise(beforeLoad)) await beforeLoad
|
|
2937
|
+
}
|
|
2946
2938
|
|
|
2947
|
-
|
|
2939
|
+
// Execute all loaders in parallel
|
|
2940
|
+
const max =
|
|
2941
|
+
innerLoadContext.firstBadMatchIndex ?? innerLoadContext.matches.length
|
|
2942
|
+
for (let i = 0; i < max; i++) {
|
|
2943
|
+
innerLoadContext.matchPromises.push(
|
|
2944
|
+
this.loadRouteMatch(innerLoadContext, i),
|
|
2945
|
+
)
|
|
2946
|
+
}
|
|
2947
|
+
await Promise.all(innerLoadContext.matchPromises)
|
|
2948
2948
|
|
|
2949
|
-
resolveAll()
|
|
2950
|
-
} catch (err) {
|
|
2951
|
-
rejectAll(err)
|
|
2952
|
-
}
|
|
2953
|
-
})()
|
|
2954
|
-
})
|
|
2955
2949
|
const readyPromise = this.triggerOnReady(innerLoadContext)
|
|
2956
2950
|
if (isPromise(readyPromise)) await readyPromise
|
|
2957
2951
|
} catch (err) {
|