react-router 7.5.0 → 7.5.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 +42 -0
- package/dist/development/{chunk-KNED5TY2.mjs → chunk-LSOULM7L.mjs} +586 -346
- package/dist/development/{future-ldDp5FKH.d.ts → data-CQbyyGzl.d.mts} +1 -11
- package/dist/{production/future-ldDp5FKH.d.mts → development/data-CQbyyGzl.d.ts} +1 -11
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.d.ts +2 -2
- package/dist/development/dom-export.js +479 -311
- package/dist/development/dom-export.mjs +18 -6
- package/dist/{production/fog-of-war-1hWhK5ey.d.mts → development/fog-of-war-CyHis97d.d.mts} +3 -2
- package/dist/development/{fog-of-war-oa9CGk10.d.ts → fog-of-war-D4x86-Xc.d.ts} +3 -2
- package/dist/development/index.d.mts +12 -8
- package/dist/development/index.d.ts +12 -8
- package/dist/development/index.js +587 -346
- package/dist/development/index.mjs +4 -2
- package/dist/development/lib/types/route-module.d.mts +2 -2
- package/dist/development/lib/types/route-module.d.ts +2 -2
- package/dist/development/lib/types/route-module.js +1 -1
- package/dist/development/lib/types/route-module.mjs +1 -1
- package/dist/development/{route-data-5OzAzQtT.d.mts → route-data-OcOrqK13.d.mts} +30 -7
- package/dist/{production/route-data-5OzAzQtT.d.mts → development/route-data-OcOrqK13.d.ts} +30 -7
- package/dist/production/{chunk-ZIM7OIE3.mjs → chunk-SAWFLE7G.mjs} +586 -346
- package/dist/production/{future-ldDp5FKH.d.ts → data-CQbyyGzl.d.mts} +1 -11
- package/dist/{development/future-ldDp5FKH.d.mts → production/data-CQbyyGzl.d.ts} +1 -11
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.d.ts +2 -2
- package/dist/production/dom-export.js +479 -311
- package/dist/production/dom-export.mjs +18 -6
- package/dist/{development/fog-of-war-1hWhK5ey.d.mts → production/fog-of-war-CyHis97d.d.mts} +3 -2
- package/dist/production/{fog-of-war-oa9CGk10.d.ts → fog-of-war-D4x86-Xc.d.ts} +3 -2
- package/dist/production/index.d.mts +12 -8
- package/dist/production/index.d.ts +12 -8
- package/dist/production/index.js +587 -346
- package/dist/production/index.mjs +4 -2
- package/dist/production/lib/types/route-module.d.mts +2 -2
- package/dist/production/lib/types/route-module.d.ts +2 -2
- package/dist/production/lib/types/route-module.js +1 -1
- package/dist/production/lib/types/route-module.mjs +1 -1
- package/dist/production/{route-data-5OzAzQtT.d.ts → route-data-OcOrqK13.d.mts} +30 -7
- package/dist/{development/route-data-5OzAzQtT.d.ts → production/route-data-OcOrqK13.d.ts} +30 -7
- package/package.json +1 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.5.
|
|
2
|
+
* react-router v7.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -91,6 +91,7 @@ __export(react_router_exports, {
|
|
|
91
91
|
UNSAFE_deserializeErrors: () => deserializeErrors2,
|
|
92
92
|
UNSAFE_getPatchRoutesOnNavigationFunction: () => getPatchRoutesOnNavigationFunction,
|
|
93
93
|
UNSAFE_getSingleFetchDataStrategy: () => getSingleFetchDataStrategy,
|
|
94
|
+
UNSAFE_hydrationRouteProperties: () => hydrationRouteProperties,
|
|
94
95
|
UNSAFE_invariant: () => invariant,
|
|
95
96
|
UNSAFE_mapRouteProperties: () => mapRouteProperties,
|
|
96
97
|
UNSAFE_shouldHydrateRouteLoader: () => shouldHydrateRouteLoader,
|
|
@@ -1097,6 +1098,7 @@ function createRouter(init) {
|
|
|
1097
1098
|
init.routes.length > 0,
|
|
1098
1099
|
"You must provide a non-empty routes array to createRouter"
|
|
1099
1100
|
);
|
|
1101
|
+
let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
|
|
1100
1102
|
let mapRouteProperties2 = init.mapRouteProperties || defaultMapRouteProperties;
|
|
1101
1103
|
let manifest = {};
|
|
1102
1104
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
@@ -1569,6 +1571,7 @@ function createRouter(init) {
|
|
|
1569
1571
|
matches,
|
|
1570
1572
|
scopedContext,
|
|
1571
1573
|
fogOfWar.active,
|
|
1574
|
+
opts && opts.initialHydration === true,
|
|
1572
1575
|
{ replace: opts.replace, flushSync }
|
|
1573
1576
|
);
|
|
1574
1577
|
if (actionResult.shortCircuited) {
|
|
@@ -1629,7 +1632,7 @@ function createRouter(init) {
|
|
|
1629
1632
|
errors
|
|
1630
1633
|
});
|
|
1631
1634
|
}
|
|
1632
|
-
async function handleAction(request, location, submission, matches, scopedContext, isFogOfWar, opts = {}) {
|
|
1635
|
+
async function handleAction(request, location, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
|
|
1633
1636
|
interruptActiveLoads();
|
|
1634
1637
|
let navigation = getSubmittingNavigation(location, submission);
|
|
1635
1638
|
updateState({ navigation }, { flushSync: opts.flushSync === true });
|
|
@@ -1683,11 +1686,18 @@ function createRouter(init) {
|
|
|
1683
1686
|
})
|
|
1684
1687
|
};
|
|
1685
1688
|
} else {
|
|
1686
|
-
let
|
|
1687
|
-
|
|
1689
|
+
let dsMatches = getTargetedDataStrategyMatches(
|
|
1690
|
+
mapRouteProperties2,
|
|
1691
|
+
manifest,
|
|
1688
1692
|
request,
|
|
1689
|
-
[actionMatch],
|
|
1690
1693
|
matches,
|
|
1694
|
+
actionMatch,
|
|
1695
|
+
initialHydration ? [] : hydrationRouteProperties2,
|
|
1696
|
+
scopedContext
|
|
1697
|
+
);
|
|
1698
|
+
let results = await callDataStrategy(
|
|
1699
|
+
request,
|
|
1700
|
+
dsMatches,
|
|
1691
1701
|
scopedContext,
|
|
1692
1702
|
null
|
|
1693
1703
|
);
|
|
@@ -1786,12 +1796,17 @@ function createRouter(init) {
|
|
|
1786
1796
|
}
|
|
1787
1797
|
}
|
|
1788
1798
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
1789
|
-
let
|
|
1799
|
+
let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
|
|
1800
|
+
request,
|
|
1801
|
+
scopedContext,
|
|
1802
|
+
mapRouteProperties2,
|
|
1803
|
+
manifest,
|
|
1790
1804
|
init.history,
|
|
1791
1805
|
state,
|
|
1792
1806
|
matches,
|
|
1793
1807
|
activeSubmission,
|
|
1794
1808
|
location,
|
|
1809
|
+
initialHydration ? [] : hydrationRouteProperties2,
|
|
1795
1810
|
initialHydration === true,
|
|
1796
1811
|
isRevalidationRequired,
|
|
1797
1812
|
cancelledFetcherLoads,
|
|
@@ -1803,7 +1818,7 @@ function createRouter(init) {
|
|
|
1803
1818
|
pendingActionResult
|
|
1804
1819
|
);
|
|
1805
1820
|
pendingNavigationLoadId = ++incrementingLoadId;
|
|
1806
|
-
if (
|
|
1821
|
+
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && revalidatingFetchers.length === 0) {
|
|
1807
1822
|
let updatedFetchers2 = markFetchRedirectsDone();
|
|
1808
1823
|
completeNavigation(
|
|
1809
1824
|
location,
|
|
@@ -1847,8 +1862,7 @@ function createRouter(init) {
|
|
|
1847
1862
|
);
|
|
1848
1863
|
}
|
|
1849
1864
|
let { loaderResults, fetcherResults } = await callLoadersAndMaybeResolveData(
|
|
1850
|
-
|
|
1851
|
-
matchesToLoad,
|
|
1865
|
+
dsMatches,
|
|
1852
1866
|
revalidatingFetchers,
|
|
1853
1867
|
request,
|
|
1854
1868
|
scopedContext
|
|
@@ -2051,11 +2065,18 @@ function createRouter(init) {
|
|
|
2051
2065
|
}
|
|
2052
2066
|
fetchControllers.set(key, abortController);
|
|
2053
2067
|
let originatingLoadId = incrementingLoadId;
|
|
2054
|
-
let
|
|
2055
|
-
|
|
2068
|
+
let fetchMatches = getTargetedDataStrategyMatches(
|
|
2069
|
+
mapRouteProperties2,
|
|
2070
|
+
manifest,
|
|
2056
2071
|
fetchRequest,
|
|
2057
|
-
[match],
|
|
2058
2072
|
requestMatches,
|
|
2073
|
+
match,
|
|
2074
|
+
hydrationRouteProperties2,
|
|
2075
|
+
scopedContext
|
|
2076
|
+
);
|
|
2077
|
+
let actionResults = await callDataStrategy(
|
|
2078
|
+
fetchRequest,
|
|
2079
|
+
fetchMatches,
|
|
2059
2080
|
scopedContext,
|
|
2060
2081
|
key
|
|
2061
2082
|
);
|
|
@@ -2104,12 +2125,17 @@ function createRouter(init) {
|
|
|
2104
2125
|
fetchReloadIds.set(key, loadId);
|
|
2105
2126
|
let loadFetcher = getLoadingFetcher(submission, actionResult.data);
|
|
2106
2127
|
state.fetchers.set(key, loadFetcher);
|
|
2107
|
-
let
|
|
2128
|
+
let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
|
|
2129
|
+
revalidationRequest,
|
|
2130
|
+
scopedContext,
|
|
2131
|
+
mapRouteProperties2,
|
|
2132
|
+
manifest,
|
|
2108
2133
|
init.history,
|
|
2109
2134
|
state,
|
|
2110
2135
|
matches,
|
|
2111
2136
|
submission,
|
|
2112
2137
|
nextLocation,
|
|
2138
|
+
hydrationRouteProperties2,
|
|
2113
2139
|
false,
|
|
2114
2140
|
isRevalidationRequired,
|
|
2115
2141
|
cancelledFetcherLoads,
|
|
@@ -2140,8 +2166,7 @@ function createRouter(init) {
|
|
|
2140
2166
|
abortPendingFetchRevalidations
|
|
2141
2167
|
);
|
|
2142
2168
|
let { loaderResults, fetcherResults } = await callLoadersAndMaybeResolveData(
|
|
2143
|
-
|
|
2144
|
-
matchesToLoad,
|
|
2169
|
+
dsMatches,
|
|
2145
2170
|
revalidatingFetchers,
|
|
2146
2171
|
revalidationRequest,
|
|
2147
2172
|
scopedContext
|
|
@@ -2254,11 +2279,18 @@ function createRouter(init) {
|
|
|
2254
2279
|
}
|
|
2255
2280
|
fetchControllers.set(key, abortController);
|
|
2256
2281
|
let originatingLoadId = incrementingLoadId;
|
|
2257
|
-
let
|
|
2258
|
-
|
|
2282
|
+
let dsMatches = getTargetedDataStrategyMatches(
|
|
2283
|
+
mapRouteProperties2,
|
|
2284
|
+
manifest,
|
|
2259
2285
|
fetchRequest,
|
|
2260
|
-
[match],
|
|
2261
2286
|
matches,
|
|
2287
|
+
match,
|
|
2288
|
+
hydrationRouteProperties2,
|
|
2289
|
+
scopedContext
|
|
2290
|
+
);
|
|
2291
|
+
let results = await callDataStrategy(
|
|
2292
|
+
fetchRequest,
|
|
2293
|
+
dsMatches,
|
|
2262
2294
|
scopedContext,
|
|
2263
2295
|
key
|
|
2264
2296
|
);
|
|
@@ -2361,23 +2393,20 @@ function createRouter(init) {
|
|
|
2361
2393
|
});
|
|
2362
2394
|
}
|
|
2363
2395
|
}
|
|
2364
|
-
async function callDataStrategy(
|
|
2396
|
+
async function callDataStrategy(request, matches, scopedContext, fetcherKey) {
|
|
2365
2397
|
let results;
|
|
2366
2398
|
let dataResults = {};
|
|
2367
2399
|
try {
|
|
2368
2400
|
results = await callDataStrategyImpl(
|
|
2369
2401
|
dataStrategyImpl,
|
|
2370
|
-
type,
|
|
2371
2402
|
request,
|
|
2372
|
-
matchesToLoad,
|
|
2373
2403
|
matches,
|
|
2374
2404
|
fetcherKey,
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
scopedContext
|
|
2405
|
+
scopedContext,
|
|
2406
|
+
false
|
|
2378
2407
|
);
|
|
2379
2408
|
} catch (e) {
|
|
2380
|
-
|
|
2409
|
+
matches.filter((m) => m.shouldLoad).forEach((m) => {
|
|
2381
2410
|
dataResults[m.route.id] = {
|
|
2382
2411
|
type: "error" /* error */,
|
|
2383
2412
|
error: e
|
|
@@ -2406,22 +2435,18 @@ function createRouter(init) {
|
|
|
2406
2435
|
}
|
|
2407
2436
|
return dataResults;
|
|
2408
2437
|
}
|
|
2409
|
-
async function callLoadersAndMaybeResolveData(matches,
|
|
2438
|
+
async function callLoadersAndMaybeResolveData(matches, fetchersToLoad, request, scopedContext) {
|
|
2410
2439
|
let loaderResultsPromise = callDataStrategy(
|
|
2411
|
-
"loader",
|
|
2412
2440
|
request,
|
|
2413
|
-
matchesToLoad,
|
|
2414
2441
|
matches,
|
|
2415
2442
|
scopedContext,
|
|
2416
2443
|
null
|
|
2417
2444
|
);
|
|
2418
2445
|
let fetcherResultsPromise = Promise.all(
|
|
2419
2446
|
fetchersToLoad.map(async (f) => {
|
|
2420
|
-
if (f.matches && f.match && f.controller) {
|
|
2447
|
+
if (f.matches && f.match && f.request && f.controller) {
|
|
2421
2448
|
let results = await callDataStrategy(
|
|
2422
|
-
|
|
2423
|
-
createClientSideRequest(init.history, f.path, f.controller.signal),
|
|
2424
|
-
[f.match],
|
|
2449
|
+
f.request,
|
|
2425
2450
|
f.matches,
|
|
2426
2451
|
scopedContext,
|
|
2427
2452
|
f.key
|
|
@@ -3116,11 +3141,18 @@ function createStaticHandler(routes, opts) {
|
|
|
3116
3141
|
error
|
|
3117
3142
|
};
|
|
3118
3143
|
} else {
|
|
3119
|
-
let
|
|
3120
|
-
|
|
3144
|
+
let dsMatches = getTargetedDataStrategyMatches(
|
|
3145
|
+
mapRouteProperties2,
|
|
3146
|
+
manifest,
|
|
3121
3147
|
request,
|
|
3122
|
-
[actionMatch],
|
|
3123
3148
|
matches,
|
|
3149
|
+
actionMatch,
|
|
3150
|
+
[],
|
|
3151
|
+
requestContext
|
|
3152
|
+
);
|
|
3153
|
+
let results = await callDataStrategy(
|
|
3154
|
+
request,
|
|
3155
|
+
dsMatches,
|
|
3124
3156
|
isRouteRequest,
|
|
3125
3157
|
requestContext,
|
|
3126
3158
|
dataStrategy
|
|
@@ -3238,18 +3270,49 @@ function createStaticHandler(routes, opts) {
|
|
|
3238
3270
|
routeId: routeMatch?.route.id
|
|
3239
3271
|
});
|
|
3240
3272
|
}
|
|
3241
|
-
let
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3273
|
+
let dsMatches;
|
|
3274
|
+
if (routeMatch) {
|
|
3275
|
+
dsMatches = getTargetedDataStrategyMatches(
|
|
3276
|
+
mapRouteProperties2,
|
|
3277
|
+
manifest,
|
|
3278
|
+
request,
|
|
3279
|
+
matches,
|
|
3280
|
+
routeMatch,
|
|
3281
|
+
[],
|
|
3282
|
+
requestContext
|
|
3283
|
+
);
|
|
3284
|
+
} else {
|
|
3285
|
+
let maxIdx = pendingActionResult && isErrorResult(pendingActionResult[1]) ? (
|
|
3286
|
+
// Up to but not including the boundary
|
|
3287
|
+
matches.findIndex((m) => m.route.id === pendingActionResult[0]) - 1
|
|
3288
|
+
) : void 0;
|
|
3289
|
+
dsMatches = matches.map((match, index) => {
|
|
3290
|
+
if (maxIdx != null && index > maxIdx) {
|
|
3291
|
+
return getDataStrategyMatch(
|
|
3292
|
+
mapRouteProperties2,
|
|
3293
|
+
manifest,
|
|
3294
|
+
request,
|
|
3295
|
+
match,
|
|
3296
|
+
[],
|
|
3297
|
+
requestContext,
|
|
3298
|
+
false
|
|
3299
|
+
);
|
|
3300
|
+
}
|
|
3301
|
+
return getDataStrategyMatch(
|
|
3302
|
+
mapRouteProperties2,
|
|
3303
|
+
manifest,
|
|
3304
|
+
request,
|
|
3305
|
+
match,
|
|
3306
|
+
[],
|
|
3307
|
+
requestContext,
|
|
3308
|
+
(match.route.loader || match.route.lazy) != null && (!filterMatchesToLoad || filterMatchesToLoad(match))
|
|
3309
|
+
);
|
|
3310
|
+
});
|
|
3311
|
+
}
|
|
3312
|
+
if (!dataStrategy && !dsMatches.some((m) => m.shouldLoad)) {
|
|
3246
3313
|
return {
|
|
3247
3314
|
matches,
|
|
3248
|
-
|
|
3249
|
-
loaderData: matches.reduce(
|
|
3250
|
-
(acc, m) => Object.assign(acc, { [m.route.id]: null }),
|
|
3251
|
-
{}
|
|
3252
|
-
),
|
|
3315
|
+
loaderData: {},
|
|
3253
3316
|
errors: pendingActionResult && isErrorResult(pendingActionResult[1]) ? {
|
|
3254
3317
|
[pendingActionResult[0]]: pendingActionResult[1].error
|
|
3255
3318
|
} : null,
|
|
@@ -3258,10 +3321,8 @@ function createStaticHandler(routes, opts) {
|
|
|
3258
3321
|
};
|
|
3259
3322
|
}
|
|
3260
3323
|
let results = await callDataStrategy(
|
|
3261
|
-
"loader",
|
|
3262
3324
|
request,
|
|
3263
|
-
|
|
3264
|
-
matches,
|
|
3325
|
+
dsMatches,
|
|
3265
3326
|
isRouteRequest,
|
|
3266
3327
|
requestContext,
|
|
3267
3328
|
dataStrategy
|
|
@@ -3276,30 +3337,19 @@ function createStaticHandler(routes, opts) {
|
|
|
3276
3337
|
true,
|
|
3277
3338
|
skipLoaderErrorBubbling
|
|
3278
3339
|
);
|
|
3279
|
-
let executedLoaders = new Set(
|
|
3280
|
-
matchesToLoad.map((match) => match.route.id)
|
|
3281
|
-
);
|
|
3282
|
-
matches.forEach((match) => {
|
|
3283
|
-
if (!executedLoaders.has(match.route.id)) {
|
|
3284
|
-
handlerContext.loaderData[match.route.id] = null;
|
|
3285
|
-
}
|
|
3286
|
-
});
|
|
3287
3340
|
return {
|
|
3288
3341
|
...handlerContext,
|
|
3289
3342
|
matches
|
|
3290
3343
|
};
|
|
3291
3344
|
}
|
|
3292
|
-
async function callDataStrategy(
|
|
3345
|
+
async function callDataStrategy(request, matches, isRouteRequest, requestContext, dataStrategy) {
|
|
3293
3346
|
let results = await callDataStrategyImpl(
|
|
3294
3347
|
dataStrategy || defaultDataStrategy,
|
|
3295
|
-
type,
|
|
3296
3348
|
request,
|
|
3297
|
-
matchesToLoad,
|
|
3298
3349
|
matches,
|
|
3299
3350
|
null,
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
requestContext
|
|
3351
|
+
requestContext,
|
|
3352
|
+
true
|
|
3303
3353
|
);
|
|
3304
3354
|
let dataResults = {};
|
|
3305
3355
|
await Promise.all(
|
|
@@ -3505,62 +3555,78 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
|
|
|
3505
3555
|
parsedPath.search = `?${searchParams}`;
|
|
3506
3556
|
return { path: createPath(parsedPath), submission };
|
|
3507
3557
|
}
|
|
3508
|
-
function
|
|
3509
|
-
let index = matches.findIndex((m) => m.route.id === boundaryId);
|
|
3510
|
-
if (index >= 0) {
|
|
3511
|
-
return matches.slice(0, includeBoundary ? index + 1 : index);
|
|
3512
|
-
}
|
|
3513
|
-
return matches;
|
|
3514
|
-
}
|
|
3515
|
-
function getMatchesToLoad(history, state, matches, submission, location, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
|
|
3558
|
+
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
|
|
3516
3559
|
let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
|
|
3517
3560
|
let currentUrl = history.createURL(state.location);
|
|
3518
3561
|
let nextUrl = history.createURL(location);
|
|
3519
|
-
let
|
|
3562
|
+
let maxIdx;
|
|
3520
3563
|
if (initialHydration && state.errors) {
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
Object.keys(state.errors)[0],
|
|
3524
|
-
true
|
|
3525
|
-
);
|
|
3564
|
+
let boundaryId = Object.keys(state.errors)[0];
|
|
3565
|
+
maxIdx = matches.findIndex((m) => m.route.id === boundaryId);
|
|
3526
3566
|
} else if (pendingActionResult && isErrorResult(pendingActionResult[1])) {
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
pendingActionResult[0]
|
|
3530
|
-
);
|
|
3567
|
+
let boundaryId = pendingActionResult[0];
|
|
3568
|
+
maxIdx = matches.findIndex((m) => m.route.id === boundaryId) - 1;
|
|
3531
3569
|
}
|
|
3532
3570
|
let actionStatus = pendingActionResult ? pendingActionResult[1].statusCode : void 0;
|
|
3533
3571
|
let shouldSkipRevalidation = actionStatus && actionStatus >= 400;
|
|
3534
|
-
let
|
|
3572
|
+
let baseShouldRevalidateArgs = {
|
|
3573
|
+
currentUrl,
|
|
3574
|
+
currentParams: state.matches[0]?.params || {},
|
|
3575
|
+
nextUrl,
|
|
3576
|
+
nextParams: matches[0].params,
|
|
3577
|
+
...submission,
|
|
3578
|
+
actionResult,
|
|
3579
|
+
actionStatus
|
|
3580
|
+
};
|
|
3581
|
+
let dsMatches = matches.map((match, index) => {
|
|
3535
3582
|
let { route } = match;
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
if (route.
|
|
3540
|
-
|
|
3541
|
-
}
|
|
3542
|
-
|
|
3543
|
-
|
|
3583
|
+
let forceShouldLoad = null;
|
|
3584
|
+
if (maxIdx != null && index > maxIdx) {
|
|
3585
|
+
forceShouldLoad = false;
|
|
3586
|
+
} else if (route.lazy) {
|
|
3587
|
+
forceShouldLoad = true;
|
|
3588
|
+
} else if (route.loader == null) {
|
|
3589
|
+
forceShouldLoad = false;
|
|
3590
|
+
} else if (initialHydration) {
|
|
3591
|
+
forceShouldLoad = shouldLoadRouteOnHydration(
|
|
3592
|
+
route,
|
|
3593
|
+
state.loaderData,
|
|
3594
|
+
state.errors
|
|
3595
|
+
);
|
|
3596
|
+
} else if (isNewLoader(state.loaderData, state.matches[index], match)) {
|
|
3597
|
+
forceShouldLoad = true;
|
|
3544
3598
|
}
|
|
3545
|
-
if (
|
|
3546
|
-
return
|
|
3599
|
+
if (forceShouldLoad !== null) {
|
|
3600
|
+
return getDataStrategyMatch(
|
|
3601
|
+
mapRouteProperties2,
|
|
3602
|
+
manifest,
|
|
3603
|
+
request,
|
|
3604
|
+
match,
|
|
3605
|
+
lazyRoutePropertiesToSkip,
|
|
3606
|
+
scopedContext,
|
|
3607
|
+
forceShouldLoad
|
|
3608
|
+
);
|
|
3547
3609
|
}
|
|
3548
|
-
let
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
currentUrl,
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3610
|
+
let defaultShouldRevalidate = shouldSkipRevalidation ? false : (
|
|
3611
|
+
// Forced revalidation due to submission, useRevalidator, or X-Remix-Revalidate
|
|
3612
|
+
isRevalidationRequired || currentUrl.pathname + currentUrl.search === nextUrl.pathname + nextUrl.search || // Search params affect all loaders
|
|
3613
|
+
currentUrl.search !== nextUrl.search || isNewRouteInstance(state.matches[index], match)
|
|
3614
|
+
);
|
|
3615
|
+
let shouldRevalidateArgs = {
|
|
3616
|
+
...baseShouldRevalidateArgs,
|
|
3617
|
+
defaultShouldRevalidate
|
|
3618
|
+
};
|
|
3619
|
+
let shouldLoad = shouldRevalidateLoader(match, shouldRevalidateArgs);
|
|
3620
|
+
return getDataStrategyMatch(
|
|
3621
|
+
mapRouteProperties2,
|
|
3622
|
+
manifest,
|
|
3623
|
+
request,
|
|
3624
|
+
match,
|
|
3625
|
+
lazyRoutePropertiesToSkip,
|
|
3626
|
+
scopedContext,
|
|
3627
|
+
shouldLoad,
|
|
3628
|
+
shouldRevalidateArgs
|
|
3629
|
+
);
|
|
3564
3630
|
});
|
|
3565
3631
|
let revalidatingFetchers = [];
|
|
3566
3632
|
fetchLoadMatches.forEach((f, key) => {
|
|
@@ -3575,44 +3641,77 @@ function getMatchesToLoad(history, state, matches, submission, location, initial
|
|
|
3575
3641
|
path: f.path,
|
|
3576
3642
|
matches: null,
|
|
3577
3643
|
match: null,
|
|
3644
|
+
request: null,
|
|
3578
3645
|
controller: null
|
|
3579
3646
|
});
|
|
3580
3647
|
return;
|
|
3581
3648
|
}
|
|
3649
|
+
if (fetchRedirectIds.has(key)) {
|
|
3650
|
+
return;
|
|
3651
|
+
}
|
|
3582
3652
|
let fetcher = state.fetchers.get(key);
|
|
3583
3653
|
let fetcherMatch = getTargetMatch(fetcherMatches, f.path);
|
|
3584
|
-
let
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3654
|
+
let fetchController = new AbortController();
|
|
3655
|
+
let fetchRequest = createClientSideRequest(
|
|
3656
|
+
history,
|
|
3657
|
+
f.path,
|
|
3658
|
+
fetchController.signal
|
|
3659
|
+
);
|
|
3660
|
+
let fetcherDsMatches = null;
|
|
3661
|
+
if (cancelledFetcherLoads.has(key)) {
|
|
3588
3662
|
cancelledFetcherLoads.delete(key);
|
|
3589
|
-
|
|
3663
|
+
fetcherDsMatches = getTargetedDataStrategyMatches(
|
|
3664
|
+
mapRouteProperties2,
|
|
3665
|
+
manifest,
|
|
3666
|
+
fetchRequest,
|
|
3667
|
+
fetcherMatches,
|
|
3668
|
+
fetcherMatch,
|
|
3669
|
+
lazyRoutePropertiesToSkip,
|
|
3670
|
+
scopedContext
|
|
3671
|
+
);
|
|
3590
3672
|
} else if (fetcher && fetcher.state !== "idle" && fetcher.data === void 0) {
|
|
3591
|
-
|
|
3673
|
+
if (isRevalidationRequired) {
|
|
3674
|
+
fetcherDsMatches = getTargetedDataStrategyMatches(
|
|
3675
|
+
mapRouteProperties2,
|
|
3676
|
+
manifest,
|
|
3677
|
+
fetchRequest,
|
|
3678
|
+
fetcherMatches,
|
|
3679
|
+
fetcherMatch,
|
|
3680
|
+
lazyRoutePropertiesToSkip,
|
|
3681
|
+
scopedContext
|
|
3682
|
+
);
|
|
3683
|
+
}
|
|
3592
3684
|
} else {
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
currentParams: state.matches[state.matches.length - 1].params,
|
|
3596
|
-
nextUrl,
|
|
3597
|
-
nextParams: matches[matches.length - 1].params,
|
|
3598
|
-
...submission,
|
|
3599
|
-
actionResult,
|
|
3600
|
-
actionStatus,
|
|
3685
|
+
let shouldRevalidateArgs = {
|
|
3686
|
+
...baseShouldRevalidateArgs,
|
|
3601
3687
|
defaultShouldRevalidate: shouldSkipRevalidation ? false : isRevalidationRequired
|
|
3602
|
-
}
|
|
3688
|
+
};
|
|
3689
|
+
if (shouldRevalidateLoader(fetcherMatch, shouldRevalidateArgs)) {
|
|
3690
|
+
fetcherDsMatches = getTargetedDataStrategyMatches(
|
|
3691
|
+
mapRouteProperties2,
|
|
3692
|
+
manifest,
|
|
3693
|
+
fetchRequest,
|
|
3694
|
+
fetcherMatches,
|
|
3695
|
+
fetcherMatch,
|
|
3696
|
+
lazyRoutePropertiesToSkip,
|
|
3697
|
+
scopedContext,
|
|
3698
|
+
shouldRevalidateArgs
|
|
3699
|
+
);
|
|
3700
|
+
}
|
|
3603
3701
|
}
|
|
3604
|
-
if (
|
|
3702
|
+
if (fetcherDsMatches) {
|
|
3605
3703
|
revalidatingFetchers.push({
|
|
3606
3704
|
key,
|
|
3607
3705
|
routeId: f.routeId,
|
|
3608
3706
|
path: f.path,
|
|
3609
|
-
matches:
|
|
3707
|
+
matches: fetcherDsMatches,
|
|
3610
3708
|
match: fetcherMatch,
|
|
3611
|
-
|
|
3709
|
+
request: fetchRequest,
|
|
3710
|
+
controller: fetchController
|
|
3612
3711
|
});
|
|
3613
3712
|
}
|
|
3614
3713
|
});
|
|
3615
|
-
return
|
|
3714
|
+
return { dsMatches, revalidatingFetchers };
|
|
3616
3715
|
}
|
|
3617
3716
|
function shouldLoadRouteOnHydration(route, loaderData, errors) {
|
|
3618
3717
|
if (route.lazy) {
|
|
@@ -3758,7 +3857,7 @@ var loadLazyRouteProperty = ({
|
|
|
3758
3857
|
return propertyPromise;
|
|
3759
3858
|
};
|
|
3760
3859
|
var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
|
|
3761
|
-
function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
|
|
3860
|
+
function loadLazyRoute(route, type, manifest, mapRouteProperties2, lazyRoutePropertiesToSkip) {
|
|
3762
3861
|
let routeToUpdate = manifest[route.id];
|
|
3763
3862
|
invariant(routeToUpdate, "No route found in manifest");
|
|
3764
3863
|
if (!route.lazy) {
|
|
@@ -3816,6 +3915,8 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
|
|
|
3816
3915
|
});
|
|
3817
3916
|
})();
|
|
3818
3917
|
lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise2);
|
|
3918
|
+
lazyRoutePromise2.catch(() => {
|
|
3919
|
+
});
|
|
3819
3920
|
return {
|
|
3820
3921
|
lazyRoutePromise: lazyRoutePromise2,
|
|
3821
3922
|
lazyHandlerPromise: lazyRoutePromise2
|
|
@@ -3825,6 +3926,9 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
|
|
|
3825
3926
|
let lazyPropertyPromises = [];
|
|
3826
3927
|
let lazyHandlerPromise = void 0;
|
|
3827
3928
|
for (let key of lazyKeys) {
|
|
3929
|
+
if (lazyRoutePropertiesToSkip && lazyRoutePropertiesToSkip.includes(key)) {
|
|
3930
|
+
continue;
|
|
3931
|
+
}
|
|
3828
3932
|
let promise = loadLazyRouteProperty({
|
|
3829
3933
|
key,
|
|
3830
3934
|
route,
|
|
@@ -3838,7 +3942,11 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
|
|
|
3838
3942
|
}
|
|
3839
3943
|
}
|
|
3840
3944
|
}
|
|
3841
|
-
let lazyRoutePromise = Promise.all(lazyPropertyPromises).then(() => {
|
|
3945
|
+
let lazyRoutePromise = lazyPropertyPromises.length > 0 ? Promise.all(lazyPropertyPromises).then(() => {
|
|
3946
|
+
}) : void 0;
|
|
3947
|
+
lazyRoutePromise?.catch(() => {
|
|
3948
|
+
});
|
|
3949
|
+
lazyHandlerPromise?.catch(() => {
|
|
3842
3950
|
});
|
|
3843
3951
|
return {
|
|
3844
3952
|
lazyRoutePromise,
|
|
@@ -3976,59 +4084,145 @@ async function callRouteMiddleware(args, middlewares, propagateResult, middlewar
|
|
|
3976
4084
|
throw error;
|
|
3977
4085
|
}
|
|
3978
4086
|
}
|
|
3979
|
-
|
|
3980
|
-
let
|
|
3981
|
-
|
|
4087
|
+
function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
4088
|
+
let lazyMiddlewarePromise = loadLazyRouteProperty({
|
|
4089
|
+
key: "unstable_middleware",
|
|
4090
|
+
route: match.route,
|
|
3982
4091
|
manifest,
|
|
3983
|
-
mapRouteProperties2
|
|
4092
|
+
mapRouteProperties: mapRouteProperties2
|
|
4093
|
+
});
|
|
4094
|
+
let lazyRoutePromises = loadLazyRoute(
|
|
4095
|
+
match.route,
|
|
4096
|
+
isMutationMethod(request.method) ? "action" : "loader",
|
|
4097
|
+
manifest,
|
|
4098
|
+
mapRouteProperties2,
|
|
4099
|
+
lazyRoutePropertiesToSkip
|
|
3984
4100
|
);
|
|
3985
|
-
|
|
3986
|
-
|
|
4101
|
+
return {
|
|
4102
|
+
middleware: lazyMiddlewarePromise,
|
|
4103
|
+
route: lazyRoutePromises.lazyRoutePromise,
|
|
4104
|
+
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4105
|
+
};
|
|
4106
|
+
}
|
|
4107
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
|
|
4108
|
+
let isUsingNewApi = false;
|
|
4109
|
+
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4110
|
+
mapRouteProperties2,
|
|
4111
|
+
manifest,
|
|
4112
|
+
request,
|
|
4113
|
+
match,
|
|
4114
|
+
lazyRoutePropertiesToSkip
|
|
3987
4115
|
);
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
if (
|
|
3996
|
-
shouldLoad
|
|
3997
|
-
}
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4116
|
+
return {
|
|
4117
|
+
...match,
|
|
4118
|
+
_lazyPromises,
|
|
4119
|
+
shouldLoad,
|
|
4120
|
+
unstable_shouldRevalidateArgs,
|
|
4121
|
+
unstable_shouldCallHandler(defaultShouldRevalidate) {
|
|
4122
|
+
isUsingNewApi = true;
|
|
4123
|
+
if (!unstable_shouldRevalidateArgs) {
|
|
4124
|
+
return shouldLoad;
|
|
4125
|
+
}
|
|
4126
|
+
if (typeof defaultShouldRevalidate === "boolean") {
|
|
4127
|
+
return shouldRevalidateLoader(match, {
|
|
4128
|
+
...unstable_shouldRevalidateArgs,
|
|
4129
|
+
defaultShouldRevalidate
|
|
4130
|
+
});
|
|
4131
|
+
}
|
|
4132
|
+
return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
|
|
4133
|
+
},
|
|
4134
|
+
resolve(handlerOverride) {
|
|
4135
|
+
if (isUsingNewApi || shouldLoad || handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
|
|
4136
|
+
return callLoaderOrAction({
|
|
4137
|
+
request,
|
|
4138
|
+
match,
|
|
4139
|
+
lazyHandlerPromise: _lazyPromises?.handler,
|
|
4140
|
+
lazyRoutePromise: _lazyPromises?.route,
|
|
4141
|
+
handlerOverride,
|
|
4142
|
+
scopedContext
|
|
4143
|
+
});
|
|
4144
|
+
}
|
|
4145
|
+
return Promise.resolve({ type: "data" /* data */, result: void 0 });
|
|
4146
|
+
}
|
|
4147
|
+
};
|
|
4148
|
+
}
|
|
4149
|
+
function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
|
|
4150
|
+
return matches.map((match) => {
|
|
4151
|
+
if (match.route.id !== targetMatch.route.id) {
|
|
4152
|
+
return {
|
|
4153
|
+
...match,
|
|
4154
|
+
shouldLoad: false,
|
|
4155
|
+
unstable_shouldRevalidateArgs: shouldRevalidateArgs,
|
|
4156
|
+
unstable_shouldCallHandler: () => false,
|
|
4157
|
+
_lazyPromises: getDataStrategyMatchLazyPromises(
|
|
4158
|
+
mapRouteProperties2,
|
|
4159
|
+
manifest,
|
|
4160
|
+
request,
|
|
4161
|
+
match,
|
|
4162
|
+
lazyRoutePropertiesToSkip
|
|
4163
|
+
),
|
|
4164
|
+
resolve: () => Promise.resolve({ type: "data", result: void 0 })
|
|
4165
|
+
};
|
|
4166
|
+
}
|
|
4167
|
+
return getDataStrategyMatch(
|
|
4168
|
+
mapRouteProperties2,
|
|
4169
|
+
manifest,
|
|
4170
|
+
request,
|
|
4171
|
+
match,
|
|
4172
|
+
lazyRoutePropertiesToSkip,
|
|
4173
|
+
scopedContext,
|
|
4174
|
+
true,
|
|
4175
|
+
shouldRevalidateArgs
|
|
4176
|
+
);
|
|
4013
4177
|
});
|
|
4014
|
-
|
|
4015
|
-
|
|
4178
|
+
}
|
|
4179
|
+
async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherKey, scopedContext, isStaticHandler) {
|
|
4180
|
+
if (matches.some((m) => m._lazyPromises?.middleware)) {
|
|
4181
|
+
await Promise.all(matches.map((m) => m._lazyPromises?.middleware));
|
|
4182
|
+
}
|
|
4183
|
+
let dataStrategyArgs = {
|
|
4016
4184
|
request,
|
|
4017
4185
|
params: matches[0].params,
|
|
4186
|
+
context: scopedContext,
|
|
4187
|
+
matches
|
|
4188
|
+
};
|
|
4189
|
+
let unstable_runClientMiddleware = isStaticHandler ? () => {
|
|
4190
|
+
throw new Error(
|
|
4191
|
+
"You cannot call `unstable_runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`"
|
|
4192
|
+
);
|
|
4193
|
+
} : (cb) => {
|
|
4194
|
+
let typedDataStrategyArgs = dataStrategyArgs;
|
|
4195
|
+
return runMiddlewarePipeline(
|
|
4196
|
+
typedDataStrategyArgs,
|
|
4197
|
+
false,
|
|
4198
|
+
() => cb({
|
|
4199
|
+
...typedDataStrategyArgs,
|
|
4200
|
+
fetcherKey,
|
|
4201
|
+
unstable_runClientMiddleware: () => {
|
|
4202
|
+
throw new Error(
|
|
4203
|
+
"Cannot call `unstable_runClientMiddleware()` from within an `unstable_runClientMiddleware` handler"
|
|
4204
|
+
);
|
|
4205
|
+
}
|
|
4206
|
+
}),
|
|
4207
|
+
(error, routeId) => ({
|
|
4208
|
+
[routeId]: { type: "error", result: error }
|
|
4209
|
+
})
|
|
4210
|
+
);
|
|
4211
|
+
};
|
|
4212
|
+
let results = await dataStrategyImpl({
|
|
4213
|
+
...dataStrategyArgs,
|
|
4018
4214
|
fetcherKey,
|
|
4019
|
-
|
|
4215
|
+
unstable_runClientMiddleware
|
|
4020
4216
|
});
|
|
4021
|
-
let allLazyRoutePromises = lazyRoutePromises.flatMap(
|
|
4022
|
-
(promiseMap) => Object.values(promiseMap).filter(isNonNullable)
|
|
4023
|
-
);
|
|
4024
4217
|
try {
|
|
4025
|
-
await Promise.all(
|
|
4218
|
+
await Promise.all(
|
|
4219
|
+
matches.flatMap((m) => [m._lazyPromises?.handler, m._lazyPromises?.route])
|
|
4220
|
+
);
|
|
4026
4221
|
} catch (e) {
|
|
4027
4222
|
}
|
|
4028
4223
|
return results;
|
|
4029
4224
|
}
|
|
4030
4225
|
async function callLoaderOrAction({
|
|
4031
|
-
type,
|
|
4032
4226
|
request,
|
|
4033
4227
|
match,
|
|
4034
4228
|
lazyHandlerPromise,
|
|
@@ -4038,6 +4232,8 @@ async function callLoaderOrAction({
|
|
|
4038
4232
|
}) {
|
|
4039
4233
|
let result;
|
|
4040
4234
|
let onReject;
|
|
4235
|
+
let isAction = isMutationMethod(request.method);
|
|
4236
|
+
let type = isAction ? "action" : "loader";
|
|
4041
4237
|
let runHandler = (handler) => {
|
|
4042
4238
|
let reject;
|
|
4043
4239
|
let abortPromise = new Promise((_, r) => reject = r);
|
|
@@ -4071,7 +4267,7 @@ async function callLoaderOrAction({
|
|
|
4071
4267
|
return Promise.race([handlerPromise, abortPromise]);
|
|
4072
4268
|
};
|
|
4073
4269
|
try {
|
|
4074
|
-
let handler = match.route
|
|
4270
|
+
let handler = isAction ? match.route.action : match.route.loader;
|
|
4075
4271
|
if (lazyHandlerPromise || lazyRoutePromise) {
|
|
4076
4272
|
if (handler) {
|
|
4077
4273
|
let handlerError;
|
|
@@ -4092,9 +4288,9 @@ async function callLoaderOrAction({
|
|
|
4092
4288
|
result = value;
|
|
4093
4289
|
} else {
|
|
4094
4290
|
await lazyHandlerPromise;
|
|
4095
|
-
|
|
4096
|
-
if (
|
|
4097
|
-
[result] = await Promise.all([runHandler(
|
|
4291
|
+
let handler2 = isAction ? match.route.action : match.route.loader;
|
|
4292
|
+
if (handler2) {
|
|
4293
|
+
[result] = await Promise.all([runHandler(handler2), lazyRoutePromise]);
|
|
4098
4294
|
} else if (type === "action") {
|
|
4099
4295
|
let url = new URL(request.url);
|
|
4100
4296
|
let pathname = url.pathname + url.search;
|
|
@@ -4329,7 +4525,7 @@ function processLoaderData(state, matches, results, pendingActionResult, revalid
|
|
|
4329
4525
|
results,
|
|
4330
4526
|
pendingActionResult
|
|
4331
4527
|
);
|
|
4332
|
-
revalidatingFetchers.forEach((rf) => {
|
|
4528
|
+
revalidatingFetchers.filter((f) => !f.matches || f.matches.some((m) => m.shouldLoad)).forEach((rf) => {
|
|
4333
4529
|
let { key, match, controller } = rf;
|
|
4334
4530
|
let result = fetcherResults[key];
|
|
4335
4531
|
invariant(result, "Did not find corresponding fetcher result");
|
|
@@ -5367,6 +5563,10 @@ function mapRouteProperties(route) {
|
|
|
5367
5563
|
}
|
|
5368
5564
|
return updates;
|
|
5369
5565
|
}
|
|
5566
|
+
var hydrationRouteProperties = [
|
|
5567
|
+
"HydrateFallback",
|
|
5568
|
+
"hydrateFallbackElement"
|
|
5569
|
+
];
|
|
5370
5570
|
function createMemoryRouter(routes, opts) {
|
|
5371
5571
|
return createRouter({
|
|
5372
5572
|
basename: opts?.basename,
|
|
@@ -5378,6 +5578,7 @@ function createMemoryRouter(routes, opts) {
|
|
|
5378
5578
|
}),
|
|
5379
5579
|
hydrationData: opts?.hydrationData,
|
|
5380
5580
|
routes,
|
|
5581
|
+
hydrationRouteProperties,
|
|
5381
5582
|
mapRouteProperties,
|
|
5382
5583
|
dataStrategy: opts?.dataStrategy,
|
|
5383
5584
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation
|
|
@@ -6260,6 +6461,7 @@ async function createRequestInit(request) {
|
|
|
6260
6461
|
|
|
6261
6462
|
// lib/dom/ssr/single-fetch.tsx
|
|
6262
6463
|
var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
|
|
6464
|
+
var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205]);
|
|
6263
6465
|
function StreamTransfer({
|
|
6264
6466
|
context,
|
|
6265
6467
|
identifier,
|
|
@@ -6326,71 +6528,54 @@ function StreamTransfer({
|
|
|
6326
6528
|
)));
|
|
6327
6529
|
}
|
|
6328
6530
|
}
|
|
6329
|
-
function
|
|
6330
|
-
|
|
6531
|
+
function getSingleFetchDataStrategy(getRouter, getRouteInfo, ssr, basename) {
|
|
6532
|
+
let dataStrategy = getSingleFetchDataStrategyImpl(
|
|
6533
|
+
getRouter,
|
|
6534
|
+
getRouteInfo,
|
|
6535
|
+
fetchAndDecodeViaTurboStream,
|
|
6536
|
+
ssr,
|
|
6537
|
+
basename
|
|
6538
|
+
);
|
|
6539
|
+
return async (args) => args.unstable_runClientMiddleware(dataStrategy);
|
|
6331
6540
|
}
|
|
6332
|
-
function
|
|
6541
|
+
function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode, ssr, basename) {
|
|
6333
6542
|
return async (args) => {
|
|
6334
6543
|
let { request, matches, fetcherKey } = args;
|
|
6544
|
+
let router = getRouter();
|
|
6335
6545
|
if (request.method !== "GET") {
|
|
6336
|
-
return
|
|
6337
|
-
args,
|
|
6338
|
-
false,
|
|
6339
|
-
() => singleFetchActionStrategy(request, matches, basename),
|
|
6340
|
-
handleMiddlewareError
|
|
6341
|
-
);
|
|
6546
|
+
return singleFetchActionStrategy(args, fetchAndDecode, basename);
|
|
6342
6547
|
}
|
|
6343
|
-
|
|
6344
|
-
let
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
args,
|
|
6350
|
-
false,
|
|
6351
|
-
() => nonSsrStrategy(manifest, request, matches, basename),
|
|
6352
|
-
handleMiddlewareError
|
|
6353
|
-
);
|
|
6354
|
-
}
|
|
6548
|
+
let foundRevalidatingServerLoader = matches.some((m) => {
|
|
6549
|
+
let { hasLoader, hasClientLoader } = getRouteInfo(m.route.id);
|
|
6550
|
+
return m.unstable_shouldCallHandler() && hasLoader && !hasClientLoader;
|
|
6551
|
+
});
|
|
6552
|
+
if (!ssr && !foundRevalidatingServerLoader) {
|
|
6553
|
+
return nonSsrStrategy(args, getRouteInfo, fetchAndDecode, basename);
|
|
6355
6554
|
}
|
|
6356
6555
|
if (fetcherKey) {
|
|
6357
|
-
return
|
|
6358
|
-
args,
|
|
6359
|
-
false,
|
|
6360
|
-
() => singleFetchLoaderFetcherStrategy(request, matches, basename),
|
|
6361
|
-
handleMiddlewareError
|
|
6362
|
-
);
|
|
6556
|
+
return singleFetchLoaderFetcherStrategy(args, fetchAndDecode, basename);
|
|
6363
6557
|
}
|
|
6364
|
-
return
|
|
6558
|
+
return singleFetchLoaderNavigationStrategy(
|
|
6365
6559
|
args,
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
getRouter(),
|
|
6372
|
-
request,
|
|
6373
|
-
matches,
|
|
6374
|
-
basename
|
|
6375
|
-
),
|
|
6376
|
-
handleMiddlewareError
|
|
6560
|
+
router,
|
|
6561
|
+
getRouteInfo,
|
|
6562
|
+
fetchAndDecode,
|
|
6563
|
+
ssr,
|
|
6564
|
+
basename
|
|
6377
6565
|
);
|
|
6378
6566
|
};
|
|
6379
6567
|
}
|
|
6380
|
-
async function singleFetchActionStrategy(
|
|
6381
|
-
let actionMatch = matches.find((m) => m.
|
|
6568
|
+
async function singleFetchActionStrategy(args, fetchAndDecode, basename) {
|
|
6569
|
+
let actionMatch = args.matches.find((m) => m.unstable_shouldCallHandler());
|
|
6382
6570
|
invariant2(actionMatch, "No action match found");
|
|
6383
6571
|
let actionStatus = void 0;
|
|
6384
6572
|
let result = await actionMatch.resolve(async (handler) => {
|
|
6385
6573
|
let result2 = await handler(async () => {
|
|
6386
|
-
let
|
|
6387
|
-
let init = await createRequestInit(request);
|
|
6388
|
-
let { data: data2, status } = await fetchAndDecode(url, init);
|
|
6389
|
-
actionStatus = status;
|
|
6390
|
-
return unwrapSingleFetchResult(
|
|
6391
|
-
data2,
|
|
6574
|
+
let { data: data2, status } = await fetchAndDecode(args, basename, [
|
|
6392
6575
|
actionMatch.route.id
|
|
6393
|
-
);
|
|
6576
|
+
]);
|
|
6577
|
+
actionStatus = status;
|
|
6578
|
+
return unwrapSingleFetchResult(data2, actionMatch.route.id);
|
|
6394
6579
|
});
|
|
6395
6580
|
return result2;
|
|
6396
6581
|
});
|
|
@@ -6404,16 +6589,21 @@ async function singleFetchActionStrategy(request, matches, basename) {
|
|
|
6404
6589
|
}
|
|
6405
6590
|
};
|
|
6406
6591
|
}
|
|
6407
|
-
async function nonSsrStrategy(
|
|
6408
|
-
let matchesToLoad = matches.filter(
|
|
6409
|
-
|
|
6410
|
-
|
|
6592
|
+
async function nonSsrStrategy(args, getRouteInfo, fetchAndDecode, basename) {
|
|
6593
|
+
let matchesToLoad = args.matches.filter(
|
|
6594
|
+
(m) => m.unstable_shouldCallHandler()
|
|
6595
|
+
);
|
|
6411
6596
|
let results = {};
|
|
6412
6597
|
await Promise.all(
|
|
6413
6598
|
matchesToLoad.map(
|
|
6414
6599
|
(m) => m.resolve(async (handler) => {
|
|
6415
6600
|
try {
|
|
6416
|
-
let
|
|
6601
|
+
let { hasClientLoader } = getRouteInfo(m.route.id);
|
|
6602
|
+
let routeId = m.route.id;
|
|
6603
|
+
let result = hasClientLoader ? await handler(async () => {
|
|
6604
|
+
let { data: data2 } = await fetchAndDecode(args, basename, [routeId]);
|
|
6605
|
+
return unwrapSingleFetchResult(data2, routeId);
|
|
6606
|
+
}) : await handler();
|
|
6417
6607
|
results[m.route.id] = { type: "data", result };
|
|
6418
6608
|
} catch (e) {
|
|
6419
6609
|
results[m.route.id] = { type: "error", result: e };
|
|
@@ -6423,81 +6613,63 @@ async function nonSsrStrategy(manifest, request, matches, basename) {
|
|
|
6423
6613
|
);
|
|
6424
6614
|
return results;
|
|
6425
6615
|
}
|
|
6426
|
-
async function singleFetchLoaderNavigationStrategy(
|
|
6616
|
+
async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, basename) {
|
|
6427
6617
|
let routesParams = /* @__PURE__ */ new Set();
|
|
6428
6618
|
let foundOptOutRoute = false;
|
|
6429
|
-
let routeDfds = matches.map(() => createDeferred2());
|
|
6430
|
-
let routesLoadedPromise = Promise.all(routeDfds.map((d) => d.promise));
|
|
6619
|
+
let routeDfds = args.matches.map(() => createDeferred2());
|
|
6431
6620
|
let singleFetchDfd = createDeferred2();
|
|
6432
|
-
let url = stripIndexParam(singleFetchUrl(request.url, basename));
|
|
6433
|
-
let init = await createRequestInit(request);
|
|
6434
6621
|
let results = {};
|
|
6435
6622
|
let resolvePromise = Promise.all(
|
|
6436
|
-
matches.map(
|
|
6623
|
+
args.matches.map(
|
|
6437
6624
|
async (m, i) => m.resolve(async (handler) => {
|
|
6438
6625
|
routeDfds[i].resolve();
|
|
6439
|
-
let
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
return;
|
|
6449
|
-
}
|
|
6626
|
+
let routeId = m.route.id;
|
|
6627
|
+
let { hasLoader, hasClientLoader, hasShouldRevalidate } = getRouteInfo(routeId);
|
|
6628
|
+
let defaultShouldRevalidate = !m.unstable_shouldRevalidateArgs || m.unstable_shouldRevalidateArgs.actionStatus == null || m.unstable_shouldRevalidateArgs.actionStatus < 400;
|
|
6629
|
+
let shouldCall = m.unstable_shouldCallHandler(defaultShouldRevalidate);
|
|
6630
|
+
if (!shouldCall) {
|
|
6631
|
+
foundOptOutRoute || (foundOptOutRoute = m.unstable_shouldRevalidateArgs != null && // This is a revalidation,
|
|
6632
|
+
hasLoader && // for a route with a server loader,
|
|
6633
|
+
hasShouldRevalidate === true);
|
|
6634
|
+
return;
|
|
6450
6635
|
}
|
|
6451
|
-
if (
|
|
6452
|
-
if (
|
|
6636
|
+
if (hasClientLoader) {
|
|
6637
|
+
if (hasLoader) {
|
|
6453
6638
|
foundOptOutRoute = true;
|
|
6454
6639
|
}
|
|
6455
6640
|
try {
|
|
6456
|
-
let result = await
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
);
|
|
6462
|
-
results[m.route.id] = { type: "data", result };
|
|
6641
|
+
let result = await handler(async () => {
|
|
6642
|
+
let { data: data2 } = await fetchAndDecode(args, basename, [routeId]);
|
|
6643
|
+
return unwrapSingleFetchResult(data2, routeId);
|
|
6644
|
+
});
|
|
6645
|
+
results[routeId] = { type: "data", result };
|
|
6463
6646
|
} catch (e) {
|
|
6464
|
-
results[
|
|
6647
|
+
results[routeId] = { type: "error", result: e };
|
|
6465
6648
|
}
|
|
6466
6649
|
return;
|
|
6467
6650
|
}
|
|
6468
|
-
if (
|
|
6469
|
-
routesParams.add(
|
|
6651
|
+
if (hasLoader) {
|
|
6652
|
+
routesParams.add(routeId);
|
|
6470
6653
|
}
|
|
6471
6654
|
try {
|
|
6472
6655
|
let result = await handler(async () => {
|
|
6473
6656
|
let data2 = await singleFetchDfd.promise;
|
|
6474
|
-
return
|
|
6657
|
+
return unwrapSingleFetchResult(data2, routeId);
|
|
6475
6658
|
});
|
|
6476
|
-
results[
|
|
6477
|
-
type: "data",
|
|
6478
|
-
result
|
|
6479
|
-
};
|
|
6659
|
+
results[routeId] = { type: "data", result };
|
|
6480
6660
|
} catch (e) {
|
|
6481
|
-
results[
|
|
6482
|
-
type: "error",
|
|
6483
|
-
result: e
|
|
6484
|
-
};
|
|
6661
|
+
results[routeId] = { type: "error", result: e };
|
|
6485
6662
|
}
|
|
6486
6663
|
})
|
|
6487
6664
|
)
|
|
6488
6665
|
);
|
|
6489
|
-
await
|
|
6666
|
+
await Promise.all(routeDfds.map((d) => d.promise));
|
|
6490
6667
|
if ((!router.state.initialized || routesParams.size === 0) && !window.__reactRouterHdrActive) {
|
|
6491
6668
|
singleFetchDfd.resolve({});
|
|
6492
6669
|
} else {
|
|
6670
|
+
let targetRoutes = ssr && foundOptOutRoute && routesParams.size > 0 ? [...routesParams.keys()] : void 0;
|
|
6493
6671
|
try {
|
|
6494
|
-
|
|
6495
|
-
url.searchParams.set(
|
|
6496
|
-
"_routes",
|
|
6497
|
-
matches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
|
|
6498
|
-
);
|
|
6499
|
-
}
|
|
6500
|
-
let data2 = await fetchAndDecode(url, init);
|
|
6672
|
+
let data2 = await fetchAndDecode(args, basename, targetRoutes);
|
|
6501
6673
|
singleFetchDfd.resolve(data2.data);
|
|
6502
6674
|
} catch (e) {
|
|
6503
6675
|
singleFetchDfd.reject(e);
|
|
@@ -6506,24 +6678,18 @@ async function singleFetchLoaderNavigationStrategy(manifest, routeModules, ssr,
|
|
|
6506
6678
|
await resolvePromise;
|
|
6507
6679
|
return results;
|
|
6508
6680
|
}
|
|
6509
|
-
async function singleFetchLoaderFetcherStrategy(
|
|
6510
|
-
let fetcherMatch = matches.find((m) => m.
|
|
6681
|
+
async function singleFetchLoaderFetcherStrategy(args, fetchAndDecode, basename) {
|
|
6682
|
+
let fetcherMatch = args.matches.find((m) => m.unstable_shouldCallHandler());
|
|
6511
6683
|
invariant2(fetcherMatch, "No fetcher match found");
|
|
6512
|
-
let
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6684
|
+
let routeId = fetcherMatch.route.id;
|
|
6685
|
+
let result = await fetcherMatch.resolve(
|
|
6686
|
+
async (handler) => handler(async () => {
|
|
6687
|
+
let { data: data2 } = await fetchAndDecode(args, basename, [routeId]);
|
|
6688
|
+
return unwrapSingleFetchResult(data2, routeId);
|
|
6689
|
+
})
|
|
6690
|
+
);
|
|
6517
6691
|
return { [fetcherMatch.route.id]: result };
|
|
6518
6692
|
}
|
|
6519
|
-
function fetchSingleLoader(handler, url, init, routeId) {
|
|
6520
|
-
return handler(async () => {
|
|
6521
|
-
let singleLoaderUrl = new URL(url);
|
|
6522
|
-
singleLoaderUrl.searchParams.set("_routes", routeId);
|
|
6523
|
-
let { data: data2 } = await fetchAndDecode(singleLoaderUrl, init);
|
|
6524
|
-
return unwrapSingleFetchResults(data2, routeId);
|
|
6525
|
-
});
|
|
6526
|
-
}
|
|
6527
6693
|
function stripIndexParam(url) {
|
|
6528
6694
|
let indexValues = url.searchParams.getAll("index");
|
|
6529
6695
|
url.searchParams.delete("index");
|
|
@@ -6554,23 +6720,51 @@ function singleFetchUrl(reqUrl, basename) {
|
|
|
6554
6720
|
}
|
|
6555
6721
|
return url;
|
|
6556
6722
|
}
|
|
6557
|
-
async function
|
|
6558
|
-
let
|
|
6723
|
+
async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
6724
|
+
let { request } = args;
|
|
6725
|
+
let url = singleFetchUrl(request.url, basename);
|
|
6726
|
+
if (request.method === "GET") {
|
|
6727
|
+
url = stripIndexParam(url);
|
|
6728
|
+
if (targetRoutes) {
|
|
6729
|
+
url.searchParams.set("_routes", targetRoutes.join(","));
|
|
6730
|
+
}
|
|
6731
|
+
}
|
|
6732
|
+
let res = await fetch(url, await createRequestInit(request));
|
|
6559
6733
|
if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
|
|
6560
6734
|
throw new ErrorResponseImpl(404, "Not Found", true);
|
|
6561
6735
|
}
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
if (
|
|
6565
|
-
|
|
6566
|
-
} else {
|
|
6567
|
-
return { status: res.status, data: { data: void 0 } };
|
|
6736
|
+
if (NO_BODY_STATUS_CODES.has(res.status)) {
|
|
6737
|
+
let routes = {};
|
|
6738
|
+
if (targetRoutes && request.method !== "GET") {
|
|
6739
|
+
routes[targetRoutes[0]] = { data: void 0 };
|
|
6568
6740
|
}
|
|
6741
|
+
return {
|
|
6742
|
+
status: res.status,
|
|
6743
|
+
data: { routes }
|
|
6744
|
+
};
|
|
6569
6745
|
}
|
|
6570
6746
|
invariant2(res.body, "No response body to decode");
|
|
6571
6747
|
try {
|
|
6572
6748
|
let decoded = await decodeViaTurboStream(res.body, window);
|
|
6573
|
-
|
|
6749
|
+
let data2;
|
|
6750
|
+
if (request.method === "GET") {
|
|
6751
|
+
let typed = decoded.value;
|
|
6752
|
+
if (SingleFetchRedirectSymbol in typed) {
|
|
6753
|
+
data2 = { redirect: typed[SingleFetchRedirectSymbol] };
|
|
6754
|
+
} else {
|
|
6755
|
+
data2 = { routes: typed };
|
|
6756
|
+
}
|
|
6757
|
+
} else {
|
|
6758
|
+
let typed = decoded.value;
|
|
6759
|
+
let routeId = targetRoutes?.[0];
|
|
6760
|
+
invariant2(routeId, "No routeId found for single fetch call decoding");
|
|
6761
|
+
if ("redirect" in typed) {
|
|
6762
|
+
data2 = { redirect: typed };
|
|
6763
|
+
} else {
|
|
6764
|
+
data2 = { routes: { [routeId]: typed } };
|
|
6765
|
+
}
|
|
6766
|
+
}
|
|
6767
|
+
return { status: res.status, data: data2 };
|
|
6574
6768
|
} catch (e) {
|
|
6575
6769
|
throw new Error("Unable to decode turbo-stream response");
|
|
6576
6770
|
}
|
|
@@ -6608,30 +6802,30 @@ function decodeViaTurboStream(body, global2) {
|
|
|
6608
6802
|
]
|
|
6609
6803
|
});
|
|
6610
6804
|
}
|
|
6611
|
-
function unwrapSingleFetchResults(results, routeId) {
|
|
6612
|
-
let redirect2 = results[SingleFetchRedirectSymbol];
|
|
6613
|
-
if (redirect2) {
|
|
6614
|
-
return unwrapSingleFetchResult(redirect2, routeId);
|
|
6615
|
-
}
|
|
6616
|
-
return results[routeId] !== void 0 ? unwrapSingleFetchResult(results[routeId], routeId) : null;
|
|
6617
|
-
}
|
|
6618
6805
|
function unwrapSingleFetchResult(result, routeId) {
|
|
6619
|
-
if ("
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6806
|
+
if ("redirect" in result) {
|
|
6807
|
+
let {
|
|
6808
|
+
redirect: location,
|
|
6809
|
+
revalidate,
|
|
6810
|
+
reload,
|
|
6811
|
+
replace: replace2,
|
|
6812
|
+
status
|
|
6813
|
+
} = result.redirect;
|
|
6814
|
+
throw redirect(location, {
|
|
6815
|
+
status,
|
|
6816
|
+
headers: {
|
|
6817
|
+
// Three R's of redirecting (lol Veep)
|
|
6818
|
+
...revalidate ? { "X-Remix-Revalidate": "yes" } : null,
|
|
6819
|
+
...reload ? { "X-Remix-Reload-Document": "yes" } : null,
|
|
6820
|
+
...replace2 ? { "X-Remix-Replace": "yes" } : null
|
|
6821
|
+
}
|
|
6822
|
+
});
|
|
6823
|
+
}
|
|
6824
|
+
let routeResult = result.routes[routeId];
|
|
6825
|
+
if ("error" in routeResult) {
|
|
6826
|
+
throw routeResult.error;
|
|
6827
|
+
} else if ("data" in routeResult) {
|
|
6828
|
+
return routeResult.data;
|
|
6635
6829
|
} else {
|
|
6636
6830
|
throw new Error(`No response found for routeId "${routeId}"`);
|
|
6637
6831
|
}
|
|
@@ -6943,6 +7137,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
6943
7137
|
unstable_middleware: routeModule.unstable_clientMiddleware,
|
|
6944
7138
|
handle: routeModule.handle,
|
|
6945
7139
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
7140
|
+
dataRoute.path,
|
|
6946
7141
|
routeModule,
|
|
6947
7142
|
route,
|
|
6948
7143
|
ssr,
|
|
@@ -7095,6 +7290,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7095
7290
|
shouldRevalidate: async () => {
|
|
7096
7291
|
let lazyRoute = await getLazyRoute();
|
|
7097
7292
|
return getShouldRevalidateFunction(
|
|
7293
|
+
dataRoute.path,
|
|
7098
7294
|
lazyRoute,
|
|
7099
7295
|
route,
|
|
7100
7296
|
ssr,
|
|
@@ -7122,7 +7318,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7122
7318
|
return dataRoute;
|
|
7123
7319
|
});
|
|
7124
7320
|
}
|
|
7125
|
-
function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidation) {
|
|
7321
|
+
function getShouldRevalidateFunction(path, route, manifestRoute, ssr, needsRevalidation) {
|
|
7126
7322
|
if (needsRevalidation) {
|
|
7127
7323
|
return wrapShouldRevalidateForHdr(
|
|
7128
7324
|
manifestRoute.id,
|
|
@@ -7131,11 +7327,16 @@ function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidatio
|
|
|
7131
7327
|
);
|
|
7132
7328
|
}
|
|
7133
7329
|
if (!ssr && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
|
|
7330
|
+
let myParams = path ? compilePath(path)[1].map((p) => p.paramName) : [];
|
|
7331
|
+
const didParamsChange = (opts) => myParams.some((p) => opts.currentParams[p] !== opts.nextParams[p]);
|
|
7134
7332
|
if (route.shouldRevalidate) {
|
|
7135
7333
|
let fn = route.shouldRevalidate;
|
|
7136
|
-
return (opts) => fn({
|
|
7334
|
+
return (opts) => fn({
|
|
7335
|
+
...opts,
|
|
7336
|
+
defaultShouldRevalidate: didParamsChange(opts)
|
|
7337
|
+
});
|
|
7137
7338
|
} else {
|
|
7138
|
-
return () =>
|
|
7339
|
+
return (opts) => didParamsChange(opts);
|
|
7139
7340
|
}
|
|
7140
7341
|
}
|
|
7141
7342
|
if (ssr && route.shouldRevalidate) {
|
|
@@ -7864,7 +8065,7 @@ function mergeRefs(...refs) {
|
|
|
7864
8065
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
7865
8066
|
try {
|
|
7866
8067
|
if (isBrowser) {
|
|
7867
|
-
window.__reactRouterVersion = "7.5.
|
|
8068
|
+
window.__reactRouterVersion = "7.5.1";
|
|
7868
8069
|
}
|
|
7869
8070
|
} catch (e) {
|
|
7870
8071
|
}
|
|
@@ -7877,6 +8078,7 @@ function createBrowserRouter(routes, opts) {
|
|
|
7877
8078
|
hydrationData: opts?.hydrationData || parseHydrationData(),
|
|
7878
8079
|
routes,
|
|
7879
8080
|
mapRouteProperties,
|
|
8081
|
+
hydrationRouteProperties,
|
|
7880
8082
|
dataStrategy: opts?.dataStrategy,
|
|
7881
8083
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
7882
8084
|
window: opts?.window
|
|
@@ -7891,6 +8093,7 @@ function createHashRouter(routes, opts) {
|
|
|
7891
8093
|
hydrationData: opts?.hydrationData || parseHydrationData(),
|
|
7892
8094
|
routes,
|
|
7893
8095
|
mapRouteProperties,
|
|
8096
|
+
hydrationRouteProperties,
|
|
7894
8097
|
dataStrategy: opts?.dataStrategy,
|
|
7895
8098
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
7896
8099
|
window: opts?.window
|
|
@@ -9480,13 +9683,28 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
|
|
|
9480
9683
|
});
|
|
9481
9684
|
let decoded = await decodeViaTurboStream(stream, global);
|
|
9482
9685
|
let data2 = decoded.value;
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9686
|
+
if (data2 && SingleFetchRedirectSymbol in data2) {
|
|
9687
|
+
let result = data2[SingleFetchRedirectSymbol];
|
|
9688
|
+
let init = { status: result.status };
|
|
9689
|
+
if (result.reload) {
|
|
9690
|
+
throw redirectDocument(result.redirect, init);
|
|
9691
|
+
} else if (result.replace) {
|
|
9692
|
+
throw replace(result.redirect, init);
|
|
9693
|
+
} else {
|
|
9694
|
+
throw redirect(result.redirect, init);
|
|
9695
|
+
}
|
|
9696
|
+
} else {
|
|
9697
|
+
invariant3(
|
|
9698
|
+
data2 && route.id in data2,
|
|
9699
|
+
"Unable to decode prerendered data"
|
|
9700
|
+
);
|
|
9701
|
+
let result = data2[route.id];
|
|
9702
|
+
invariant3(
|
|
9703
|
+
"data" in result,
|
|
9704
|
+
"Unable to process prerendered data"
|
|
9705
|
+
);
|
|
9706
|
+
return result.data;
|
|
9707
|
+
}
|
|
9490
9708
|
}
|
|
9491
9709
|
let val = await callRouteHandler(route.module.loader, args);
|
|
9492
9710
|
return val;
|
|
@@ -9607,8 +9825,11 @@ function prependCookies(parentHeaders, childHeaders) {
|
|
|
9607
9825
|
}
|
|
9608
9826
|
|
|
9609
9827
|
// lib/server-runtime/single-fetch.ts
|
|
9610
|
-
var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205, 304]);
|
|
9611
9828
|
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
9829
|
+
var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
9830
|
+
...NO_BODY_STATUS_CODES,
|
|
9831
|
+
304
|
|
9832
|
+
]);
|
|
9612
9833
|
async function singleFetchAction(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
9613
9834
|
try {
|
|
9614
9835
|
let respond2 = function(context) {
|
|
@@ -9777,7 +9998,7 @@ function generateSingleFetchResponse(request, build, serverMode, {
|
|
|
9777
9998
|
}) {
|
|
9778
9999
|
let resultHeaders = new Headers(headers);
|
|
9779
10000
|
resultHeaders.set("X-Remix-Response", "yes");
|
|
9780
|
-
if (
|
|
10001
|
+
if (SERVER_NO_BODY_STATUS_CODES.has(status)) {
|
|
9781
10002
|
return new Response(null, { status, headers: resultHeaders });
|
|
9782
10003
|
}
|
|
9783
10004
|
resultHeaders.set("Content-Type", "text/x-script");
|
|
@@ -9886,9 +10107,6 @@ var createRequestHandler = (build, mode) => {
|
|
|
9886
10107
|
let errorHandler;
|
|
9887
10108
|
return async function requestHandler(request, initialContext) {
|
|
9888
10109
|
_build = typeof build === "function" ? await build() : build;
|
|
9889
|
-
let loadContext = _build.future.unstable_middleware ? new unstable_RouterContextProvider(
|
|
9890
|
-
initialContext
|
|
9891
|
-
) : initialContext || {};
|
|
9892
10110
|
if (typeof build === "function") {
|
|
9893
10111
|
let derived = derive(_build, mode);
|
|
9894
10112
|
routes = derived.routes;
|
|
@@ -9902,18 +10120,8 @@ var createRequestHandler = (build, mode) => {
|
|
|
9902
10120
|
staticHandler = derived.staticHandler;
|
|
9903
10121
|
errorHandler = derived.errorHandler;
|
|
9904
10122
|
}
|
|
9905
|
-
let url = new URL(request.url);
|
|
9906
|
-
let normalizedBasename = _build.basename || "/";
|
|
9907
|
-
let normalizedPath = url.pathname;
|
|
9908
|
-
if (stripBasename(normalizedPath, normalizedBasename) === "/_root.data") {
|
|
9909
|
-
normalizedPath = normalizedBasename;
|
|
9910
|
-
} else if (normalizedPath.endsWith(".data")) {
|
|
9911
|
-
normalizedPath = normalizedPath.replace(/\.data$/, "");
|
|
9912
|
-
}
|
|
9913
|
-
if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
|
|
9914
|
-
normalizedPath = normalizedPath.slice(0, -1);
|
|
9915
|
-
}
|
|
9916
10123
|
let params = {};
|
|
10124
|
+
let loadContext;
|
|
9917
10125
|
let handleError = (error) => {
|
|
9918
10126
|
if (mode === "development" /* Development */) {
|
|
9919
10127
|
getDevServerHooks()?.processRequestError?.(error);
|
|
@@ -9924,6 +10132,38 @@ var createRequestHandler = (build, mode) => {
|
|
|
9924
10132
|
request
|
|
9925
10133
|
});
|
|
9926
10134
|
};
|
|
10135
|
+
if (_build.future.unstable_middleware) {
|
|
10136
|
+
if (initialContext == null) {
|
|
10137
|
+
loadContext = new unstable_RouterContextProvider();
|
|
10138
|
+
} else {
|
|
10139
|
+
try {
|
|
10140
|
+
loadContext = new unstable_RouterContextProvider(
|
|
10141
|
+
initialContext
|
|
10142
|
+
);
|
|
10143
|
+
} catch (e) {
|
|
10144
|
+
let error = new Error(
|
|
10145
|
+
`Unable to create initial \`unstable_RouterContextProvider\` instance. Please confirm you are returning an instance of \`Map<unstable_routerContext, unknown>\` from your \`getLoadContext\` function.
|
|
10146
|
+
|
|
10147
|
+
Error: ${e instanceof Error ? e.toString() : e}`
|
|
10148
|
+
);
|
|
10149
|
+
handleError(error);
|
|
10150
|
+
return returnLastResortErrorResponse(error, serverMode);
|
|
10151
|
+
}
|
|
10152
|
+
}
|
|
10153
|
+
} else {
|
|
10154
|
+
loadContext = initialContext || {};
|
|
10155
|
+
}
|
|
10156
|
+
let url = new URL(request.url);
|
|
10157
|
+
let normalizedBasename = _build.basename || "/";
|
|
10158
|
+
let normalizedPath = url.pathname;
|
|
10159
|
+
if (stripBasename(normalizedPath, normalizedBasename) === "/_root.data") {
|
|
10160
|
+
normalizedPath = normalizedBasename;
|
|
10161
|
+
} else if (normalizedPath.endsWith(".data")) {
|
|
10162
|
+
normalizedPath = normalizedPath.replace(/\.data$/, "");
|
|
10163
|
+
}
|
|
10164
|
+
if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
|
|
10165
|
+
normalizedPath = normalizedPath.slice(0, -1);
|
|
10166
|
+
}
|
|
9927
10167
|
if (!_build.ssr) {
|
|
9928
10168
|
if (_build.prerender.length === 0) {
|
|
9929
10169
|
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
@@ -10132,7 +10372,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10132
10372
|
return context;
|
|
10133
10373
|
}
|
|
10134
10374
|
let headers = getDocumentHeaders(build, context);
|
|
10135
|
-
if (
|
|
10375
|
+
if (SERVER_NO_BODY_STATUS_CODES.has(context.statusCode)) {
|
|
10136
10376
|
return new Response(null, { status: context.statusCode, headers });
|
|
10137
10377
|
}
|
|
10138
10378
|
if (context.errors) {
|
|
@@ -10552,6 +10792,7 @@ function deserializeErrors2(errors) {
|
|
|
10552
10792
|
UNSAFE_deserializeErrors,
|
|
10553
10793
|
UNSAFE_getPatchRoutesOnNavigationFunction,
|
|
10554
10794
|
UNSAFE_getSingleFetchDataStrategy,
|
|
10795
|
+
UNSAFE_hydrationRouteProperties,
|
|
10555
10796
|
UNSAFE_invariant,
|
|
10556
10797
|
UNSAFE_mapRouteProperties,
|
|
10557
10798
|
UNSAFE_shouldHydrateRouteLoader,
|