react-router 0.0.0-experimental-beaa4f52a → 0.0.0-experimental-df0f1dfda
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/development/{chunk-3SBCR7VW.mjs → chunk-O5WSUTKP.mjs} +467 -758
- package/dist/development/data-CQbyyGzl.d.mts +11 -0
- package/dist/development/data-CQbyyGzl.d.ts +11 -0
- package/dist/development/dom-export.d.mts +3 -13
- package/dist/development/dom-export.d.ts +3 -13
- package/dist/development/dom-export.js +193 -262
- package/dist/development/dom-export.mjs +6 -9
- package/dist/development/{fog-of-war-CrM4EOZM.d.ts → fog-of-war-D3ny56dR.d.mts} +11 -87
- package/dist/{production/fog-of-war-CrM4EOZM.d.ts → development/fog-of-war-L5G-Cw9x.d.ts} +11 -87
- package/dist/development/index.d.mts +11 -7
- package/dist/development/index.d.ts +11 -7
- package/dist/development/index.js +467 -758
- package/dist/development/index.mjs +2 -2
- package/dist/development/lib/types/route-module.d.mts +5 -13
- package/dist/development/lib/types/route-module.d.ts +5 -13
- 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-C9zMg-qq.d.ts → route-data-Cq_b5feC.d.mts} +17 -54
- package/dist/{production/route-data-C9zMg-qq.d.mts → development/route-data-Cq_b5feC.d.ts} +17 -54
- package/dist/production/{chunk-DRRQRV77.mjs → chunk-F7U65DMX.mjs} +467 -758
- package/dist/production/data-CQbyyGzl.d.mts +11 -0
- package/dist/production/data-CQbyyGzl.d.ts +11 -0
- package/dist/production/dom-export.d.mts +3 -13
- package/dist/production/dom-export.d.ts +3 -13
- package/dist/production/dom-export.js +193 -262
- package/dist/production/dom-export.mjs +6 -9
- package/dist/production/{fog-of-war-CYAe8qUt.d.mts → fog-of-war-D3ny56dR.d.mts} +11 -87
- package/dist/{development/fog-of-war-CYAe8qUt.d.mts → production/fog-of-war-L5G-Cw9x.d.ts} +11 -87
- package/dist/production/index.d.mts +11 -7
- package/dist/production/index.d.ts +11 -7
- package/dist/production/index.js +467 -758
- package/dist/production/index.mjs +2 -2
- package/dist/production/lib/types/route-module.d.mts +5 -13
- package/dist/production/lib/types/route-module.d.ts +5 -13
- 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-C9zMg-qq.d.ts → route-data-Cq_b5feC.d.mts} +17 -54
- package/dist/{development/route-data-C9zMg-qq.d.mts → production/route-data-Cq_b5feC.d.ts} +17 -54
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-df0f1dfda
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -764,7 +764,6 @@ function createRouter(init) {
|
|
|
764
764
|
);
|
|
765
765
|
let inFlightDataRoutes;
|
|
766
766
|
let basename = init.basename || "/";
|
|
767
|
-
let routerContext = typeof init.context !== "undefined" ? init.context : {};
|
|
768
767
|
let dataStrategyImpl = init.dataStrategy || defaultDataStrategy;
|
|
769
768
|
let patchRoutesOnNavigationImpl = init.patchRoutesOnNavigation;
|
|
770
769
|
let future = {
|
|
@@ -777,6 +776,7 @@ function createRouter(init) {
|
|
|
777
776
|
let getScrollPosition = null;
|
|
778
777
|
let initialScrollRestored = init.hydrationData != null;
|
|
779
778
|
let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
|
|
779
|
+
let initialMatchesIsFOW = false;
|
|
780
780
|
let initialErrors = null;
|
|
781
781
|
if (initialMatches == null && !patchRoutesOnNavigationImpl) {
|
|
782
782
|
let error = getInternalRouterError(404, {
|
|
@@ -806,6 +806,7 @@ function createRouter(init) {
|
|
|
806
806
|
init.history.location.pathname
|
|
807
807
|
);
|
|
808
808
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
809
|
+
initialMatchesIsFOW = true;
|
|
809
810
|
initialMatches = fogOfWar.matches;
|
|
810
811
|
}
|
|
811
812
|
} else if (initialMatches.some((m) => m.route.lazy)) {
|
|
@@ -1171,7 +1172,10 @@ function createRouter(init) {
|
|
|
1171
1172
|
pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
|
|
1172
1173
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
1173
1174
|
let loadingNavigation = opts && opts.overrideNavigation;
|
|
1174
|
-
let matches =
|
|
1175
|
+
let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
|
|
1176
|
+
// `matchRoutes()` has already been called if we're in here via `router.initialize()`
|
|
1177
|
+
state.matches
|
|
1178
|
+
) : matchRoutes(routesToUse, location, basename);
|
|
1175
1179
|
let flushSync2 = (opts && opts.flushSync) === true;
|
|
1176
1180
|
let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
|
|
1177
1181
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
@@ -1205,7 +1209,6 @@ function createRouter(init) {
|
|
|
1205
1209
|
pendingNavigationController.signal,
|
|
1206
1210
|
opts && opts.submission
|
|
1207
1211
|
);
|
|
1208
|
-
let scopedContext = { ...routerContext };
|
|
1209
1212
|
let pendingActionResult;
|
|
1210
1213
|
if (opts && opts.pendingError) {
|
|
1211
1214
|
pendingActionResult = [
|
|
@@ -1218,7 +1221,6 @@ function createRouter(init) {
|
|
|
1218
1221
|
location,
|
|
1219
1222
|
opts.submission,
|
|
1220
1223
|
matches,
|
|
1221
|
-
scopedContext,
|
|
1222
1224
|
fogOfWar.active,
|
|
1223
1225
|
{ replace: opts.replace, flushSync: flushSync2 }
|
|
1224
1226
|
);
|
|
@@ -1259,7 +1261,6 @@ function createRouter(init) {
|
|
|
1259
1261
|
request,
|
|
1260
1262
|
location,
|
|
1261
1263
|
matches,
|
|
1262
|
-
scopedContext,
|
|
1263
1264
|
fogOfWar.active,
|
|
1264
1265
|
loadingNavigation,
|
|
1265
1266
|
opts && opts.submission,
|
|
@@ -1280,7 +1281,7 @@ function createRouter(init) {
|
|
|
1280
1281
|
errors
|
|
1281
1282
|
});
|
|
1282
1283
|
}
|
|
1283
|
-
async function handleAction(request, location, submission, matches,
|
|
1284
|
+
async function handleAction(request, location, submission, matches, isFogOfWar, opts = {}) {
|
|
1284
1285
|
interruptActiveLoads();
|
|
1285
1286
|
let navigation = getSubmittingNavigation(location, submission);
|
|
1286
1287
|
updateState({ navigation }, { flushSync: opts.flushSync === true });
|
|
@@ -1334,23 +1335,15 @@ function createRouter(init) {
|
|
|
1334
1335
|
})
|
|
1335
1336
|
};
|
|
1336
1337
|
} else {
|
|
1337
|
-
let results = await
|
|
1338
|
+
let results = await callDataStrategy(
|
|
1338
1339
|
"action",
|
|
1340
|
+
state,
|
|
1339
1341
|
request,
|
|
1340
1342
|
[actionMatch],
|
|
1341
1343
|
matches,
|
|
1342
|
-
scopedContext,
|
|
1343
1344
|
null
|
|
1344
1345
|
);
|
|
1345
1346
|
result = results[actionMatch.route.id];
|
|
1346
|
-
if (!result) {
|
|
1347
|
-
for (let match of matches) {
|
|
1348
|
-
if (results[match.route.id]) {
|
|
1349
|
-
result = results[match.route.id];
|
|
1350
|
-
break;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
1347
|
if (request.signal.aborted) {
|
|
1355
1348
|
return { shortCircuited: true };
|
|
1356
1349
|
}
|
|
@@ -1388,7 +1381,7 @@ function createRouter(init) {
|
|
|
1388
1381
|
pendingActionResult: [actionMatch.route.id, result]
|
|
1389
1382
|
};
|
|
1390
1383
|
}
|
|
1391
|
-
async function handleLoaders(request, location, matches,
|
|
1384
|
+
async function handleLoaders(request, location, matches, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync2, pendingActionResult) {
|
|
1392
1385
|
let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
|
|
1393
1386
|
let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
|
|
1394
1387
|
let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
|
|
@@ -1498,11 +1491,11 @@ function createRouter(init) {
|
|
|
1498
1491
|
);
|
|
1499
1492
|
}
|
|
1500
1493
|
let { loaderResults, fetcherResults } = await callLoadersAndMaybeResolveData(
|
|
1494
|
+
state,
|
|
1501
1495
|
matches,
|
|
1502
1496
|
matchesToLoad,
|
|
1503
1497
|
revalidatingFetchers,
|
|
1504
|
-
request
|
|
1505
|
-
scopedContext
|
|
1498
|
+
request
|
|
1506
1499
|
);
|
|
1507
1500
|
if (request.signal.aborted) {
|
|
1508
1501
|
return { shortCircuited: true };
|
|
@@ -1610,7 +1603,6 @@ function createRouter(init) {
|
|
|
1610
1603
|
return;
|
|
1611
1604
|
}
|
|
1612
1605
|
let match = getTargetMatch(matches, path);
|
|
1613
|
-
let scopedContext = { ...routerContext };
|
|
1614
1606
|
let preventScrollReset = (opts && opts.preventScrollReset) === true;
|
|
1615
1607
|
if (submission && isMutationMethod(submission.formMethod)) {
|
|
1616
1608
|
await handleFetcherAction(
|
|
@@ -1619,7 +1611,6 @@ function createRouter(init) {
|
|
|
1619
1611
|
path,
|
|
1620
1612
|
match,
|
|
1621
1613
|
matches,
|
|
1622
|
-
scopedContext,
|
|
1623
1614
|
fogOfWar.active,
|
|
1624
1615
|
flushSync2,
|
|
1625
1616
|
preventScrollReset,
|
|
@@ -1634,14 +1625,13 @@ function createRouter(init) {
|
|
|
1634
1625
|
path,
|
|
1635
1626
|
match,
|
|
1636
1627
|
matches,
|
|
1637
|
-
scopedContext,
|
|
1638
1628
|
fogOfWar.active,
|
|
1639
1629
|
flushSync2,
|
|
1640
1630
|
preventScrollReset,
|
|
1641
1631
|
submission
|
|
1642
1632
|
);
|
|
1643
1633
|
}
|
|
1644
|
-
async function handleFetcherAction(key, routeId, path, match, requestMatches,
|
|
1634
|
+
async function handleFetcherAction(key, routeId, path, match, requestMatches, isFogOfWar, flushSync2, preventScrollReset, submission) {
|
|
1645
1635
|
interruptActiveLoads();
|
|
1646
1636
|
fetchLoadMatches.delete(key);
|
|
1647
1637
|
function detectAndHandle405Error(m) {
|
|
@@ -1699,12 +1689,12 @@ function createRouter(init) {
|
|
|
1699
1689
|
}
|
|
1700
1690
|
fetchControllers.set(key, abortController);
|
|
1701
1691
|
let originatingLoadId = incrementingLoadId;
|
|
1702
|
-
let actionResults = await
|
|
1692
|
+
let actionResults = await callDataStrategy(
|
|
1703
1693
|
"action",
|
|
1694
|
+
state,
|
|
1704
1695
|
fetchRequest,
|
|
1705
1696
|
[match],
|
|
1706
1697
|
requestMatches,
|
|
1707
|
-
scopedContext,
|
|
1708
1698
|
key
|
|
1709
1699
|
);
|
|
1710
1700
|
let actionResult = actionResults[match.route.id];
|
|
@@ -1788,11 +1778,11 @@ function createRouter(init) {
|
|
|
1788
1778
|
abortPendingFetchRevalidations
|
|
1789
1779
|
);
|
|
1790
1780
|
let { loaderResults, fetcherResults } = await callLoadersAndMaybeResolveData(
|
|
1781
|
+
state,
|
|
1791
1782
|
matches,
|
|
1792
1783
|
matchesToLoad,
|
|
1793
1784
|
revalidatingFetchers,
|
|
1794
|
-
revalidationRequest
|
|
1795
|
-
scopedContext
|
|
1785
|
+
revalidationRequest
|
|
1796
1786
|
);
|
|
1797
1787
|
if (abortController.signal.aborted) {
|
|
1798
1788
|
return;
|
|
@@ -1859,7 +1849,7 @@ function createRouter(init) {
|
|
|
1859
1849
|
isRevalidationRequired = false;
|
|
1860
1850
|
}
|
|
1861
1851
|
}
|
|
1862
|
-
async function handleFetcherLoader(key, routeId, path, match, matches,
|
|
1852
|
+
async function handleFetcherLoader(key, routeId, path, match, matches, isFogOfWar, flushSync2, preventScrollReset, submission) {
|
|
1863
1853
|
let existingFetcher = state.fetchers.get(key);
|
|
1864
1854
|
updateFetcherState(
|
|
1865
1855
|
key,
|
|
@@ -1901,12 +1891,12 @@ function createRouter(init) {
|
|
|
1901
1891
|
}
|
|
1902
1892
|
fetchControllers.set(key, abortController);
|
|
1903
1893
|
let originatingLoadId = incrementingLoadId;
|
|
1904
|
-
let results = await
|
|
1894
|
+
let results = await callDataStrategy(
|
|
1905
1895
|
"loader",
|
|
1896
|
+
state,
|
|
1906
1897
|
fetchRequest,
|
|
1907
1898
|
[match],
|
|
1908
1899
|
matches,
|
|
1909
|
-
scopedContext,
|
|
1910
1900
|
key
|
|
1911
1901
|
);
|
|
1912
1902
|
let result = results[match.route.id];
|
|
@@ -2008,20 +1998,20 @@ function createRouter(init) {
|
|
|
2008
1998
|
});
|
|
2009
1999
|
}
|
|
2010
2000
|
}
|
|
2011
|
-
async function
|
|
2001
|
+
async function callDataStrategy(type, state2, request, matchesToLoad, matches, fetcherKey) {
|
|
2012
2002
|
let results;
|
|
2013
2003
|
let dataResults = {};
|
|
2014
2004
|
try {
|
|
2015
2005
|
results = await callDataStrategyImpl(
|
|
2016
2006
|
dataStrategyImpl,
|
|
2017
2007
|
type,
|
|
2008
|
+
state2,
|
|
2018
2009
|
request,
|
|
2019
2010
|
matchesToLoad,
|
|
2020
2011
|
matches,
|
|
2021
2012
|
fetcherKey,
|
|
2022
2013
|
manifest,
|
|
2023
|
-
mapRouteProperties2
|
|
2024
|
-
scopedContext
|
|
2014
|
+
mapRouteProperties2
|
|
2025
2015
|
);
|
|
2026
2016
|
} catch (e) {
|
|
2027
2017
|
matchesToLoad.forEach((m) => {
|
|
@@ -2053,24 +2043,24 @@ function createRouter(init) {
|
|
|
2053
2043
|
}
|
|
2054
2044
|
return dataResults;
|
|
2055
2045
|
}
|
|
2056
|
-
async function callLoadersAndMaybeResolveData(matches, matchesToLoad, fetchersToLoad, request
|
|
2057
|
-
let loaderResultsPromise =
|
|
2046
|
+
async function callLoadersAndMaybeResolveData(state2, matches, matchesToLoad, fetchersToLoad, request) {
|
|
2047
|
+
let loaderResultsPromise = callDataStrategy(
|
|
2058
2048
|
"loader",
|
|
2049
|
+
state2,
|
|
2059
2050
|
request,
|
|
2060
2051
|
matchesToLoad,
|
|
2061
2052
|
matches,
|
|
2062
|
-
scopedContext,
|
|
2063
2053
|
null
|
|
2064
2054
|
);
|
|
2065
2055
|
let fetcherResultsPromise = Promise.all(
|
|
2066
2056
|
fetchersToLoad.map(async (f) => {
|
|
2067
2057
|
if (f.matches && f.match && f.controller) {
|
|
2068
|
-
let results = await
|
|
2058
|
+
let results = await callDataStrategy(
|
|
2069
2059
|
"loader",
|
|
2060
|
+
state2,
|
|
2070
2061
|
createClientSideRequest(init.history, f.path, f.controller.signal),
|
|
2071
2062
|
[f.match],
|
|
2072
2063
|
f.matches,
|
|
2073
|
-
scopedContext,
|
|
2074
2064
|
f.key
|
|
2075
2065
|
);
|
|
2076
2066
|
let result = results[f.match.route.id];
|
|
@@ -2812,132 +2802,20 @@ async function loadLazyRouteModule(route, mapRouteProperties2, manifest) {
|
|
|
2812
2802
|
lazy: void 0
|
|
2813
2803
|
});
|
|
2814
2804
|
}
|
|
2815
|
-
async function defaultDataStrategy(
|
|
2816
|
-
let matchesToLoad = args.matches.filter((m) => m.shouldLoad);
|
|
2817
|
-
let lastIndex = args.matches.length - 1;
|
|
2818
|
-
for (let i = lastIndex; i >= 0; i--) {
|
|
2819
|
-
if (args.matches[i].shouldLoad) {
|
|
2820
|
-
lastIndex = i;
|
|
2821
|
-
break;
|
|
2822
|
-
}
|
|
2823
|
-
}
|
|
2824
|
-
let results = await runMiddlewarePipeline(
|
|
2825
|
-
args,
|
|
2826
|
-
lastIndex,
|
|
2827
|
-
false,
|
|
2828
|
-
async (keyedResults) => {
|
|
2829
|
-
let results2 = await Promise.all(matchesToLoad.map((m) => m.resolve()));
|
|
2830
|
-
results2.forEach((result, i) => {
|
|
2831
|
-
keyedResults[matchesToLoad[i].route.id] = result;
|
|
2832
|
-
});
|
|
2833
|
-
},
|
|
2834
|
-
(e, keyedResults) => {
|
|
2835
|
-
Object.assign(keyedResults, {
|
|
2836
|
-
[e.routeId]: { type: "error", result: e.error }
|
|
2837
|
-
});
|
|
2838
|
-
}
|
|
2839
|
-
);
|
|
2840
|
-
return results;
|
|
2841
|
-
}
|
|
2842
|
-
async function runMiddlewarePipeline({
|
|
2843
|
-
request,
|
|
2844
|
-
params,
|
|
2845
|
-
context,
|
|
2805
|
+
async function defaultDataStrategy({
|
|
2846
2806
|
matches
|
|
2847
|
-
}
|
|
2848
|
-
let
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
matches.slice(0, lastIndex + 1).flatMap(
|
|
2855
|
-
(m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
|
|
2856
|
-
),
|
|
2857
|
-
0,
|
|
2858
|
-
{ request, params, context },
|
|
2859
|
-
middlewareState,
|
|
2860
|
-
handler
|
|
2861
|
-
);
|
|
2862
|
-
return middlewareState.propagateResult ? result : middlewareState.keyedResults;
|
|
2863
|
-
} catch (e) {
|
|
2864
|
-
if (!(e instanceof MiddlewareError)) {
|
|
2865
|
-
throw e;
|
|
2866
|
-
}
|
|
2867
|
-
if (propagateResult && isResponse(e.error)) {
|
|
2868
|
-
throw e.error;
|
|
2869
|
-
}
|
|
2870
|
-
let result = await errorHandler(e, middlewareState.keyedResults);
|
|
2871
|
-
return middlewareState.propagateResult ? result : middlewareState.keyedResults;
|
|
2872
|
-
}
|
|
2873
|
-
}
|
|
2874
|
-
var MiddlewareError = class {
|
|
2875
|
-
constructor(routeId, error) {
|
|
2876
|
-
this.routeId = routeId;
|
|
2877
|
-
this.error = error;
|
|
2878
|
-
}
|
|
2879
|
-
};
|
|
2880
|
-
async function callRouteMiddleware(middlewares, idx, args, middlewareState, handler) {
|
|
2881
|
-
let { request } = args;
|
|
2882
|
-
if (request.signal.aborted) {
|
|
2883
|
-
if (request.signal.reason) {
|
|
2884
|
-
throw request.signal.reason;
|
|
2885
|
-
}
|
|
2886
|
-
throw new Error(
|
|
2887
|
-
`Request aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
|
|
2888
|
-
);
|
|
2889
|
-
}
|
|
2890
|
-
let tuple = middlewares[idx];
|
|
2891
|
-
if (!tuple) {
|
|
2892
|
-
let result = await handler(middlewareState.keyedResults);
|
|
2893
|
-
return result;
|
|
2894
|
-
}
|
|
2895
|
-
let [routeId, middleware] = tuple;
|
|
2896
|
-
let nextCalled = false;
|
|
2897
|
-
let next = async () => {
|
|
2898
|
-
if (nextCalled) {
|
|
2899
|
-
throw new Error("You may only call `next()` once per middleware");
|
|
2900
|
-
}
|
|
2901
|
-
nextCalled = true;
|
|
2902
|
-
let result = await callRouteMiddleware(
|
|
2903
|
-
middlewares,
|
|
2904
|
-
idx + 1,
|
|
2905
|
-
args,
|
|
2906
|
-
middlewareState,
|
|
2907
|
-
handler
|
|
2908
|
-
);
|
|
2909
|
-
if (middlewareState.propagateResult) {
|
|
2910
|
-
return result;
|
|
2911
|
-
}
|
|
2912
|
-
};
|
|
2913
|
-
try {
|
|
2914
|
-
let result = await middleware({
|
|
2915
|
-
request: args.request,
|
|
2916
|
-
params: args.params,
|
|
2917
|
-
context: args.context,
|
|
2918
|
-
next
|
|
2919
|
-
});
|
|
2920
|
-
return nextCalled ? result : next();
|
|
2921
|
-
} catch (e) {
|
|
2922
|
-
if (e instanceof MiddlewareError) {
|
|
2923
|
-
throw e;
|
|
2924
|
-
}
|
|
2925
|
-
throw new MiddlewareError(routeId, e);
|
|
2926
|
-
}
|
|
2807
|
+
}) {
|
|
2808
|
+
let matchesToLoad = matches.filter((m) => m.shouldLoad);
|
|
2809
|
+
let results = await Promise.all(matchesToLoad.map((m) => m.resolve()));
|
|
2810
|
+
return results.reduce(
|
|
2811
|
+
(acc, result, i) => Object.assign(acc, { [matchesToLoad[i].route.id]: result }),
|
|
2812
|
+
{}
|
|
2813
|
+
);
|
|
2927
2814
|
}
|
|
2928
|
-
async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties2,
|
|
2815
|
+
async function callDataStrategyImpl(dataStrategyImpl, type, state, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties2, requestContext) {
|
|
2929
2816
|
let loadRouteDefinitionsPromises = matches.map(
|
|
2930
2817
|
(m) => m.route.lazy ? loadLazyRouteModule(m.route, mapRouteProperties2, manifest) : void 0
|
|
2931
2818
|
);
|
|
2932
|
-
let lazyMiddlewarePromises = matches.map(
|
|
2933
|
-
(m, i) => m.route.lazy && !("middleware" in m.route) ? (
|
|
2934
|
-
// Swallow the error here, let it bubble up from resolve()
|
|
2935
|
-
loadRouteDefinitionsPromises[i].catch((e) => e)
|
|
2936
|
-
) : null
|
|
2937
|
-
).filter((p) => p != null);
|
|
2938
|
-
if (lazyMiddlewarePromises.length > 0) {
|
|
2939
|
-
await Promise.all(lazyMiddlewarePromises);
|
|
2940
|
-
}
|
|
2941
2819
|
let dsMatches = matches.map((match, i) => {
|
|
2942
2820
|
let loadRoutePromise = loadRouteDefinitionsPromises[i];
|
|
2943
2821
|
let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
|
|
@@ -2951,7 +2829,7 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
|
|
|
2951
2829
|
match,
|
|
2952
2830
|
loadRoutePromise,
|
|
2953
2831
|
handlerOverride,
|
|
2954
|
-
|
|
2832
|
+
requestContext
|
|
2955
2833
|
) : Promise.resolve({ type: "data" /* data */, result: void 0 });
|
|
2956
2834
|
};
|
|
2957
2835
|
return {
|
|
@@ -2965,7 +2843,7 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
|
|
|
2965
2843
|
request,
|
|
2966
2844
|
params: matches[0].params,
|
|
2967
2845
|
fetcherKey,
|
|
2968
|
-
context:
|
|
2846
|
+
context: requestContext
|
|
2969
2847
|
});
|
|
2970
2848
|
try {
|
|
2971
2849
|
await Promise.all(loadRouteDefinitionsPromises);
|
|
@@ -2973,7 +2851,7 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
|
|
|
2973
2851
|
}
|
|
2974
2852
|
return results;
|
|
2975
2853
|
}
|
|
2976
|
-
async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride,
|
|
2854
|
+
async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, staticContext) {
|
|
2977
2855
|
let result;
|
|
2978
2856
|
let onReject;
|
|
2979
2857
|
let runHandler = (handler) => {
|
|
@@ -2993,7 +2871,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
|
|
|
2993
2871
|
{
|
|
2994
2872
|
request,
|
|
2995
2873
|
params: match.params,
|
|
2996
|
-
context:
|
|
2874
|
+
context: staticContext
|
|
2997
2875
|
},
|
|
2998
2876
|
...ctx !== void 0 ? [ctx] : []
|
|
2999
2877
|
);
|
|
@@ -3100,14 +2978,20 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
3100
2978
|
return {
|
|
3101
2979
|
type: "error" /* error */,
|
|
3102
2980
|
error: result.data,
|
|
3103
|
-
statusCode: result.init?.status
|
|
2981
|
+
statusCode: result.init?.status,
|
|
2982
|
+
headers: result.init?.headers ? new Headers(result.init.headers) : void 0
|
|
3104
2983
|
};
|
|
3105
2984
|
}
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
2985
|
+
return {
|
|
2986
|
+
type: "error" /* error */,
|
|
2987
|
+
error: new ErrorResponseImpl(
|
|
2988
|
+
result.init?.status || 500,
|
|
2989
|
+
void 0,
|
|
2990
|
+
result.data
|
|
2991
|
+
),
|
|
2992
|
+
statusCode: isRouteErrorResponse(result) ? result.status : void 0,
|
|
2993
|
+
headers: result.init?.headers ? new Headers(result.init.headers) : void 0
|
|
2994
|
+
};
|
|
3111
2995
|
}
|
|
3112
2996
|
return {
|
|
3113
2997
|
type: "error" /* error */,
|
|
@@ -3712,7 +3596,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
3712
3596
|
let segments = pathname.replace(/^\//, "").split("/");
|
|
3713
3597
|
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
|
|
3714
3598
|
}
|
|
3715
|
-
let matches = matchRoutes(routes, { pathname: remainingPathname });
|
|
3599
|
+
let matches = dataRouterState && dataRouterState.matches && dataRouterState.matches.length > 0 ? dataRouterState.matches : matchRoutes(routes, { pathname: remainingPathname });
|
|
3716
3600
|
if (ENABLE_DEV_WARNINGS) {
|
|
3717
3601
|
warning(
|
|
3718
3602
|
parentRoute || matches != null,
|
|
@@ -4389,6 +4273,31 @@ async function prefetchStyleLink(descriptor) {
|
|
|
4389
4273
|
function isPageLinkDescriptor(object) {
|
|
4390
4274
|
return object != null && typeof object.page === "string";
|
|
4391
4275
|
}
|
|
4276
|
+
function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
|
|
4277
|
+
return dedupeHrefs(
|
|
4278
|
+
matches.map((match) => {
|
|
4279
|
+
let route = manifest.routes[match.route.id];
|
|
4280
|
+
if (!route) return [];
|
|
4281
|
+
let hrefs = [route.module];
|
|
4282
|
+
if (route.clientActionModule) {
|
|
4283
|
+
hrefs = hrefs.concat(route.clientActionModule);
|
|
4284
|
+
}
|
|
4285
|
+
if (route.clientLoaderModule) {
|
|
4286
|
+
hrefs = hrefs.concat(route.clientLoaderModule);
|
|
4287
|
+
}
|
|
4288
|
+
if (includeHydrateFallback && route.hydrateFallbackModule) {
|
|
4289
|
+
hrefs = hrefs.concat(route.hydrateFallbackModule);
|
|
4290
|
+
}
|
|
4291
|
+
if (route.imports) {
|
|
4292
|
+
hrefs = hrefs.concat(route.imports);
|
|
4293
|
+
}
|
|
4294
|
+
return hrefs;
|
|
4295
|
+
}).flat(1)
|
|
4296
|
+
);
|
|
4297
|
+
}
|
|
4298
|
+
function dedupeHrefs(hrefs) {
|
|
4299
|
+
return [...new Set(hrefs)];
|
|
4300
|
+
}
|
|
4392
4301
|
var _isPreloadSupported;
|
|
4393
4302
|
function isPreloadSupported() {
|
|
4394
4303
|
if (_isPreloadSupported !== void 0) {
|
|
@@ -4432,63 +4341,21 @@ async function createRequestInit(request) {
|
|
|
4432
4341
|
|
|
4433
4342
|
// lib/dom/ssr/single-fetch.tsx
|
|
4434
4343
|
var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
|
|
4435
|
-
function middlewareErrorHandler(e, keyedResults) {
|
|
4436
|
-
Object.assign(keyedResults, {
|
|
4437
|
-
[e.routeId]: { type: "error", result: e.error }
|
|
4438
|
-
});
|
|
4439
|
-
}
|
|
4440
4344
|
function getSingleFetchDataStrategy(manifest, routeModules, getRouter) {
|
|
4441
|
-
return async (
|
|
4442
|
-
let { request, matches, fetcherKey } = args;
|
|
4345
|
+
return async ({ request, matches, fetcherKey }) => {
|
|
4443
4346
|
if (request.method !== "GET") {
|
|
4444
|
-
return
|
|
4445
|
-
args,
|
|
4446
|
-
matches.findIndex((m) => m.shouldLoad),
|
|
4447
|
-
false,
|
|
4448
|
-
async (keyedResults) => {
|
|
4449
|
-
let results = await singleFetchActionStrategy(request, matches);
|
|
4450
|
-
Object.assign(keyedResults, results);
|
|
4451
|
-
},
|
|
4452
|
-
middlewareErrorHandler
|
|
4453
|
-
);
|
|
4347
|
+
return singleFetchActionStrategy(request, matches);
|
|
4454
4348
|
}
|
|
4455
4349
|
if (fetcherKey) {
|
|
4456
|
-
return
|
|
4457
|
-
args,
|
|
4458
|
-
matches.findIndex((m) => m.shouldLoad),
|
|
4459
|
-
false,
|
|
4460
|
-
async (keyedResults) => {
|
|
4461
|
-
let results = await singleFetchLoaderFetcherStrategy(
|
|
4462
|
-
request,
|
|
4463
|
-
matches
|
|
4464
|
-
);
|
|
4465
|
-
Object.assign(keyedResults, results);
|
|
4466
|
-
},
|
|
4467
|
-
middlewareErrorHandler
|
|
4468
|
-
);
|
|
4350
|
+
return singleFetchLoaderFetcherStrategy(request, matches);
|
|
4469
4351
|
}
|
|
4470
|
-
|
|
4352
|
+
return singleFetchLoaderNavigationStrategy(
|
|
4471
4353
|
manifest,
|
|
4472
4354
|
routeModules,
|
|
4473
4355
|
getRouter(),
|
|
4356
|
+
request,
|
|
4474
4357
|
matches
|
|
4475
4358
|
);
|
|
4476
|
-
return runMiddlewarePipeline(
|
|
4477
|
-
args,
|
|
4478
|
-
lowestLoadingIndex,
|
|
4479
|
-
false,
|
|
4480
|
-
async (keyedResults) => {
|
|
4481
|
-
let results = await singleFetchLoaderNavigationStrategy(
|
|
4482
|
-
manifest,
|
|
4483
|
-
routeModules,
|
|
4484
|
-
getRouter(),
|
|
4485
|
-
request,
|
|
4486
|
-
matches
|
|
4487
|
-
);
|
|
4488
|
-
Object.assign(keyedResults, results);
|
|
4489
|
-
},
|
|
4490
|
-
middlewareErrorHandler
|
|
4491
|
-
);
|
|
4492
4359
|
};
|
|
4493
4360
|
}
|
|
4494
4361
|
async function singleFetchActionStrategy(request, matches) {
|
|
@@ -4518,20 +4385,6 @@ async function singleFetchActionStrategy(request, matches) {
|
|
|
4518
4385
|
}
|
|
4519
4386
|
};
|
|
4520
4387
|
}
|
|
4521
|
-
function isOptedOut(manifestRoute, routeModule, match, router2) {
|
|
4522
|
-
return match.route.id in router2.state.loaderData && manifestRoute && manifestRoute.hasLoader && routeModule && routeModule.shouldRevalidate;
|
|
4523
|
-
}
|
|
4524
|
-
function getLowestLoadingIndex(manifest, routeModules, router2, matches) {
|
|
4525
|
-
let tailIdx = [...matches].reverse().findIndex(
|
|
4526
|
-
(m) => m.shouldLoad || !isOptedOut(
|
|
4527
|
-
manifest.routes[m.route.id],
|
|
4528
|
-
routeModules[m.route.id],
|
|
4529
|
-
m,
|
|
4530
|
-
router2
|
|
4531
|
-
)
|
|
4532
|
-
);
|
|
4533
|
-
return tailIdx < 0 ? 0 : matches.length - 1 - tailIdx;
|
|
4534
|
-
}
|
|
4535
4388
|
async function singleFetchLoaderNavigationStrategy(manifest, routeModules, router2, request, matches) {
|
|
4536
4389
|
let routesParams = /* @__PURE__ */ new Set();
|
|
4537
4390
|
let foundOptOutRoute = false;
|
|
@@ -4550,7 +4403,7 @@ async function singleFetchLoaderNavigationStrategy(manifest, routeModules, route
|
|
|
4550
4403
|
if (!router2.state.initialized) {
|
|
4551
4404
|
return;
|
|
4552
4405
|
}
|
|
4553
|
-
if (
|
|
4406
|
+
if (m.route.id in router2.state.loaderData && manifestRoute && manifestRoute.hasLoader && routeModules[m.route.id]?.shouldRevalidate) {
|
|
4554
4407
|
foundOptOutRoute = true;
|
|
4555
4408
|
return;
|
|
4556
4409
|
}
|
|
@@ -4977,6 +4830,21 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4977
4830
|
}
|
|
4978
4831
|
return fetchServerHandler(singleFetch);
|
|
4979
4832
|
}
|
|
4833
|
+
function prefetchModule(modulePath) {
|
|
4834
|
+
import(
|
|
4835
|
+
/* @vite-ignore */
|
|
4836
|
+
/* webpackIgnore: true */
|
|
4837
|
+
modulePath
|
|
4838
|
+
);
|
|
4839
|
+
}
|
|
4840
|
+
function prefetchRouteModuleChunks(route2) {
|
|
4841
|
+
if (route2.clientActionModule) {
|
|
4842
|
+
prefetchModule(route2.clientActionModule);
|
|
4843
|
+
}
|
|
4844
|
+
if (route2.clientLoaderModule) {
|
|
4845
|
+
prefetchModule(route2.clientLoaderModule);
|
|
4846
|
+
}
|
|
4847
|
+
}
|
|
4980
4848
|
async function prefetchStylesAndCallHandler(handler) {
|
|
4981
4849
|
let cachedModule = routeModulesCache[route.id];
|
|
4982
4850
|
let linkPrefetchPromise = cachedModule ? prefetchStyleLinks(route, cachedModule) : Promise.resolve();
|
|
@@ -4995,7 +4863,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4995
4863
|
Object.assign(dataRoute, {
|
|
4996
4864
|
...dataRoute,
|
|
4997
4865
|
...getRouteComponents(route, routeModule, isSpaMode),
|
|
4998
|
-
middleware: routeModule.clientMiddleware,
|
|
4999
4866
|
handle: routeModule.handle,
|
|
5000
4867
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
5001
4868
|
routeModule,
|
|
@@ -5008,7 +4875,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
5008
4875
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
5009
4876
|
let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
|
|
5010
4877
|
let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
|
|
5011
|
-
dataRoute.loader = async ({ request, params
|
|
4878
|
+
dataRoute.loader = async ({ request, params }, singleFetch) => {
|
|
5012
4879
|
try {
|
|
5013
4880
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
5014
4881
|
invariant2(
|
|
@@ -5022,7 +4889,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
5022
4889
|
return routeModule.clientLoader({
|
|
5023
4890
|
request,
|
|
5024
4891
|
params,
|
|
5025
|
-
context,
|
|
5026
4892
|
async serverLoader() {
|
|
5027
4893
|
preventInvalidServerHandlerCall("loader", route, isSpaMode);
|
|
5028
4894
|
if (isHydrationRequest) {
|
|
@@ -5047,7 +4913,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
5047
4913
|
routeModule,
|
|
5048
4914
|
isSpaMode
|
|
5049
4915
|
);
|
|
5050
|
-
dataRoute.action = ({ request, params
|
|
4916
|
+
dataRoute.action = ({ request, params }, singleFetch) => {
|
|
5051
4917
|
return prefetchStylesAndCallHandler(async () => {
|
|
5052
4918
|
invariant2(
|
|
5053
4919
|
routeModule,
|
|
@@ -5062,7 +4928,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
5062
4928
|
return routeModule.clientAction({
|
|
5063
4929
|
request,
|
|
5064
4930
|
params,
|
|
5065
|
-
context,
|
|
5066
4931
|
async serverAction() {
|
|
5067
4932
|
preventInvalidServerHandlerCall("action", route, isSpaMode);
|
|
5068
4933
|
return fetchServerAction(singleFetch);
|
|
@@ -5072,26 +4937,64 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
5072
4937
|
};
|
|
5073
4938
|
} else {
|
|
5074
4939
|
if (!route.hasClientLoader) {
|
|
5075
|
-
dataRoute.loader = (
|
|
4940
|
+
dataRoute.loader = ({ request }, singleFetch) => prefetchStylesAndCallHandler(() => {
|
|
5076
4941
|
if (isSpaMode) return Promise.resolve(null);
|
|
5077
4942
|
return fetchServerLoader(singleFetch);
|
|
5078
4943
|
});
|
|
4944
|
+
} else if (route.clientLoaderModule) {
|
|
4945
|
+
dataRoute.loader = async (args, singleFetch) => {
|
|
4946
|
+
invariant2(route.clientLoaderModule);
|
|
4947
|
+
let { clientLoader } = await import(
|
|
4948
|
+
/* @vite-ignore */
|
|
4949
|
+
/* webpackIgnore: true */
|
|
4950
|
+
route.clientLoaderModule
|
|
4951
|
+
);
|
|
4952
|
+
return clientLoader({
|
|
4953
|
+
...args,
|
|
4954
|
+
async serverLoader() {
|
|
4955
|
+
preventInvalidServerHandlerCall("loader", route, isSpaMode);
|
|
4956
|
+
return fetchServerLoader(singleFetch);
|
|
4957
|
+
}
|
|
4958
|
+
});
|
|
4959
|
+
};
|
|
5079
4960
|
}
|
|
5080
4961
|
if (!route.hasClientAction) {
|
|
5081
|
-
dataRoute.action = (
|
|
4962
|
+
dataRoute.action = ({ request }, singleFetch) => prefetchStylesAndCallHandler(() => {
|
|
5082
4963
|
if (isSpaMode) {
|
|
5083
4964
|
throw noActionDefinedError("clientAction", route.id);
|
|
5084
4965
|
}
|
|
5085
4966
|
return fetchServerAction(singleFetch);
|
|
5086
4967
|
});
|
|
4968
|
+
} else if (route.clientActionModule) {
|
|
4969
|
+
dataRoute.action = async (args, singleFetch) => {
|
|
4970
|
+
invariant2(route.clientActionModule);
|
|
4971
|
+
prefetchRouteModuleChunks(route);
|
|
4972
|
+
let { clientAction } = await import(
|
|
4973
|
+
/* @vite-ignore */
|
|
4974
|
+
/* webpackIgnore: true */
|
|
4975
|
+
route.clientActionModule
|
|
4976
|
+
);
|
|
4977
|
+
return clientAction({
|
|
4978
|
+
...args,
|
|
4979
|
+
async serverAction() {
|
|
4980
|
+
preventInvalidServerHandlerCall("action", route, isSpaMode);
|
|
4981
|
+
return fetchServerAction(singleFetch);
|
|
4982
|
+
}
|
|
4983
|
+
});
|
|
4984
|
+
};
|
|
5087
4985
|
}
|
|
5088
4986
|
dataRoute.lazy = async () => {
|
|
5089
|
-
|
|
4987
|
+
if (route.clientLoaderModule || route.clientActionModule) {
|
|
4988
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
4989
|
+
}
|
|
4990
|
+
let modPromise = loadRouteModuleWithBlockingLinks(
|
|
5090
4991
|
route,
|
|
5091
4992
|
routeModulesCache
|
|
5092
4993
|
);
|
|
4994
|
+
prefetchRouteModuleChunks(route);
|
|
4995
|
+
let mod = await modPromise;
|
|
5093
4996
|
let lazyRoute = { ...mod };
|
|
5094
|
-
if (mod.clientLoader) {
|
|
4997
|
+
if (mod.clientLoader && !route.clientLoaderModule) {
|
|
5095
4998
|
let clientLoader = mod.clientLoader;
|
|
5096
4999
|
lazyRoute.loader = (args, singleFetch) => clientLoader({
|
|
5097
5000
|
...args,
|
|
@@ -5101,7 +5004,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
5101
5004
|
}
|
|
5102
5005
|
});
|
|
5103
5006
|
}
|
|
5104
|
-
if (mod.clientAction) {
|
|
5007
|
+
if (mod.clientAction && !route.clientActionModule) {
|
|
5105
5008
|
let clientAction = mod.clientAction;
|
|
5106
5009
|
lazyRoute.action = (args, singleFetch) => clientAction({
|
|
5107
5010
|
...args,
|
|
@@ -5114,7 +5017,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
5114
5017
|
return {
|
|
5115
5018
|
...lazyRoute.loader ? { loader: lazyRoute.loader } : {},
|
|
5116
5019
|
...lazyRoute.action ? { action: lazyRoute.action } : {},
|
|
5117
|
-
middleware: mod.clientMiddleware,
|
|
5118
5020
|
hasErrorBoundary: lazyRoute.hasErrorBoundary,
|
|
5119
5021
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
5120
5022
|
lazyRoute,
|
|
@@ -5172,7 +5074,6 @@ async function loadRouteModuleWithBlockingLinks(route, routeModules) {
|
|
|
5172
5074
|
return {
|
|
5173
5075
|
Component: getRouteModuleComponent(routeModule),
|
|
5174
5076
|
ErrorBoundary: routeModule.ErrorBoundary,
|
|
5175
|
-
clientMiddleware: routeModule.clientMiddleware,
|
|
5176
5077
|
clientAction: routeModule.clientAction,
|
|
5177
5078
|
clientLoader: routeModule.clientLoader,
|
|
5178
5079
|
handle: routeModule.handle,
|
|
@@ -5404,11 +5305,44 @@ function Scripts(props) {
|
|
|
5404
5305
|
let streamScript = "window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());";
|
|
5405
5306
|
let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};${streamScript}` : " ";
|
|
5406
5307
|
let routeModulesScript = !isStatic ? " " : `${manifest.hmr?.runtime ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
|
|
5407
|
-
${matches.map(
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
)
|
|
5411
|
-
|
|
5308
|
+
${matches.map((match, routeIndex) => {
|
|
5309
|
+
let routeVarName = `route${routeIndex}`;
|
|
5310
|
+
let manifestEntry = manifest.routes[match.route.id];
|
|
5311
|
+
invariant2(manifestEntry, `Route ${match.route.id} not found in manifest`);
|
|
5312
|
+
let {
|
|
5313
|
+
clientActionModule,
|
|
5314
|
+
clientLoaderModule,
|
|
5315
|
+
hydrateFallbackModule,
|
|
5316
|
+
module: module2
|
|
5317
|
+
} = manifestEntry;
|
|
5318
|
+
let chunks = [
|
|
5319
|
+
...clientActionModule ? [
|
|
5320
|
+
{
|
|
5321
|
+
module: clientActionModule,
|
|
5322
|
+
varName: `${routeVarName}_clientAction`
|
|
5323
|
+
}
|
|
5324
|
+
] : [],
|
|
5325
|
+
...clientLoaderModule ? [
|
|
5326
|
+
{
|
|
5327
|
+
module: clientLoaderModule,
|
|
5328
|
+
varName: `${routeVarName}_clientLoader`
|
|
5329
|
+
}
|
|
5330
|
+
] : [],
|
|
5331
|
+
...hydrateFallbackModule ? [
|
|
5332
|
+
{
|
|
5333
|
+
module: hydrateFallbackModule,
|
|
5334
|
+
varName: `${routeVarName}_HydrateFallback`
|
|
5335
|
+
}
|
|
5336
|
+
] : [],
|
|
5337
|
+
{ module: module2, varName: `${routeVarName}_main` }
|
|
5338
|
+
];
|
|
5339
|
+
if (chunks.length === 1) {
|
|
5340
|
+
return `import * as ${routeVarName} from ${JSON.stringify(module2)};`;
|
|
5341
|
+
}
|
|
5342
|
+
let chunkImportsSnippet = chunks.map((chunk) => `import * as ${chunk.varName} from "${chunk.module}";`).join("\n");
|
|
5343
|
+
let mergedChunksSnippet = `const ${routeVarName} = {${chunks.map((chunk) => `...${chunk.varName}`).join(",")}};`;
|
|
5344
|
+
return [chunkImportsSnippet, mergedChunksSnippet].join("\n");
|
|
5345
|
+
}).join("\n")}
|
|
5412
5346
|
${enableFogOfWar ? (
|
|
5413
5347
|
// Inline a minimal manifest with the SSR matches
|
|
5414
5348
|
`window.__reactRouterManifest = ${JSON.stringify(
|
|
@@ -5439,11 +5373,11 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
5439
5373
|
}
|
|
5440
5374
|
));
|
|
5441
5375
|
}, []);
|
|
5442
|
-
let
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5376
|
+
let preloads = isHydrated ? [] : manifest.entry.imports.concat(
|
|
5377
|
+
getModuleLinkHrefs(matches, manifest, {
|
|
5378
|
+
includeHydrateFallback: true
|
|
5379
|
+
})
|
|
5380
|
+
);
|
|
5447
5381
|
return isHydrated ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, !enableFogOfWar ? /* @__PURE__ */ React9.createElement(
|
|
5448
5382
|
"link",
|
|
5449
5383
|
{
|
|
@@ -5530,9 +5464,7 @@ function initSsrInfo() {
|
|
|
5530
5464
|
};
|
|
5531
5465
|
}
|
|
5532
5466
|
}
|
|
5533
|
-
function createHydratedRouter({
|
|
5534
|
-
context
|
|
5535
|
-
}) {
|
|
5467
|
+
function createHydratedRouter() {
|
|
5536
5468
|
initSsrInfo();
|
|
5537
5469
|
if (!ssrInfo) {
|
|
5538
5470
|
throw new Error(
|
|
@@ -5598,10 +5530,9 @@ function createHydratedRouter({
|
|
|
5598
5530
|
routes,
|
|
5599
5531
|
history: createBrowserHistory(),
|
|
5600
5532
|
basename: ssrInfo.context.basename,
|
|
5601
|
-
context,
|
|
5602
5533
|
hydrationData,
|
|
5603
5534
|
mapRouteProperties,
|
|
5604
|
-
dataStrategy:
|
|
5535
|
+
dataStrategy: getSingleFetchDataStrategy(
|
|
5605
5536
|
ssrInfo.manifest,
|
|
5606
5537
|
ssrInfo.routeModules,
|
|
5607
5538
|
() => router2
|
|
@@ -5623,9 +5554,9 @@ function createHydratedRouter({
|
|
|
5623
5554
|
window.__reactRouterDataRouter = router2;
|
|
5624
5555
|
return router2;
|
|
5625
5556
|
}
|
|
5626
|
-
function HydratedRouter(
|
|
5557
|
+
function HydratedRouter() {
|
|
5627
5558
|
if (!router) {
|
|
5628
|
-
router = createHydratedRouter(
|
|
5559
|
+
router = createHydratedRouter();
|
|
5629
5560
|
}
|
|
5630
5561
|
let [criticalCss, setCriticalCss] = React11.useState(
|
|
5631
5562
|
process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0
|