@@ -139,7 +139,6 @@ function handleMiddlewareError(error: unknown, routeId: string) {
139139
140140export function getSingleFetchDataStrategy (
141141 manifest : AssetsManifest ,
142- routeModules : RouteModules ,
143142 ssr : boolean ,
144143 basename : string | undefined ,
145144 getRouter : ( ) => DataRouter
@@ -152,12 +151,11 @@ export function getSingleFetchDataStrategy(
152151 return runMiddlewarePipeline (
153152 args ,
154153 false ,
155- ( ) => singleFetchActionStrategy ( request , matches , basename ) ,
154+ ( ) => singleFetchActionStrategy ( args , basename ) ,
156155 handleMiddlewareError
157156 ) as Promise < Record < string , DataStrategyResult > > ;
158157 }
159158
160- // TODO: Enable middleware for this flow
161159 if ( ! ssr ) {
162160 // If this is SPA mode, there won't be any loaders below root and we'll
163161 // disable single fetch. We have to keep the `dataStrategy` defined for
@@ -193,15 +191,15 @@ export function getSingleFetchDataStrategy(
193191 // the other end
194192 let foundRevalidatingServerLoader = matches . some (
195193 ( m ) =>
196- m . shouldLoad &&
194+ m . unstable_shouldCallHandler ( ) &&
197195 manifest . routes [ m . route . id ] ?. hasLoader &&
198196 ! manifest . routes [ m . route . id ] ?. hasClientLoader
199197 ) ;
200198 if ( ! foundRevalidatingServerLoader ) {
201199 return runMiddlewarePipeline (
202200 args ,
203201 false ,
204- ( ) => nonSsrStrategy ( manifest , request , matches , basename ) ,
202+ ( ) => nonSsrStrategy ( args , manifest , basename ) ,
205203 handleMiddlewareError
206204 ) as Promise < Record < string , DataStrategyResult > > ;
207205 }
@@ -223,12 +221,10 @@ export function getSingleFetchDataStrategy(
223221 false ,
224222 ( ) =>
225223 singleFetchLoaderNavigationStrategy (
224+ args ,
226225 manifest ,
227226 ssr ,
228227 getRouter ( ) ,
229- request ,
230- matches ,
231- args . unstable_shouldRevalidateArgs ,
232228 basename
233229 ) ,
234230 handleMiddlewareError
@@ -239,11 +235,10 @@ export function getSingleFetchDataStrategy(
239235// Actions are simple since they're singular calls to the server for both
240236// navigations and fetchers)
241237async function singleFetchActionStrategy (
242- request : Request ,
243- matches : DataStrategyFunctionArgs [ "matches" ] ,
238+ { request, matches } : DataStrategyFunctionArgs ,
244239 basename : string | undefined
245240) {
246- let actionMatch = matches . find ( ( m ) => m . shouldLoad ) ;
241+ let actionMatch = matches . find ( ( m ) => m . unstable_shouldCallHandler ( ) ) ;
247242 invariant ( actionMatch , "No action match found" ) ;
248243 let actionStatus : number | undefined = undefined ;
249244 let result = await actionMatch . resolve ( async ( handler ) => {
@@ -276,12 +271,11 @@ async function singleFetchActionStrategy(
276271
277272// We want to opt-out of Single Fetch when we aren't in SSR mode
278273async function nonSsrStrategy (
274+ { request, matches } : DataStrategyFunctionArgs ,
279275 manifest : AssetsManifest ,
280- request : Request ,
281- matches : DataStrategyFunctionArgs [ "matches" ] ,
282276 basename : string | undefined
283277) {
284- let matchesToLoad = matches . filter ( ( m ) => m . shouldLoad ) ;
278+ let matchesToLoad = matches . filter ( ( m ) => m . unstable_shouldCallHandler ( ) ) ;
285279 let url = stripIndexParam ( singleFetchUrl ( request . url , basename ) ) ;
286280 let init = await createRequestInit ( request ) ;
287281 let results : Record < string , DataStrategyResult > = { } ;
@@ -308,12 +302,14 @@ async function nonSsrStrategy(
308302// Loaders are trickier since we only want to hit the server once, so we
309303// create a singular promise for all server-loader routes to latch onto.
310304async function singleFetchLoaderNavigationStrategy (
305+ {
306+ request,
307+ matches,
308+ unstable_shouldRevalidateArgs : shouldRevalidateArgs ,
309+ } : DataStrategyFunctionArgs ,
311310 manifest : AssetsManifest ,
312311 ssr : boolean ,
313312 router : DataRouter ,
314- request : Request ,
315- matches : DataStrategyFunctionArgs [ "matches" ] ,
316- shouldRevalidateArgs : DataStrategyFunctionArgs [ "unstable_shouldRevalidateArgs" ] ,
317313 basename : string | undefined
318314) {
319315 // Track which routes need a server load - in case we need to tack on a
@@ -458,7 +454,7 @@ async function singleFetchLoaderFetcherStrategy(
458454 matches : DataStrategyFunctionArgs [ "matches" ] ,
459455 basename : string | undefined
460456) {
461- let fetcherMatch = matches . find ( ( m ) => m . shouldLoad ) ;
457+ let fetcherMatch = matches . find ( ( m ) => m . unstable_shouldCallHandler ( ) ) ;
462458 invariant ( fetcherMatch , "No fetcher match found" ) ;
463459 let result = await fetcherMatch . resolve ( async ( handler ) => {
464460 let url = stripIndexParam ( singleFetchUrl ( request . url , basename ) ) ;
0 commit comments