react-router 0.0.0-experimental-9ea41ead4 → 0.0.0-experimental-beaa4f52a
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 +23 -0
- package/dist/development/{chunk-RSP5WONC.mjs → chunk-3SBCR7VW.mjs} +759 -463
- package/dist/development/dom-export.d.mts +14 -4
- package/dist/development/dom-export.d.ts +14 -4
- package/dist/development/dom-export.js +269 -201
- package/dist/development/dom-export.mjs +9 -6
- package/dist/{production/fog-of-war-CTZ6x_bd.d.mts → development/fog-of-war-CYAe8qUt.d.mts} +93 -17
- package/dist/development/{fog-of-war-CTZ6x_bd.d.mts → fog-of-war-CrM4EOZM.d.ts} +93 -17
- package/dist/development/index.d.mts +10 -50
- package/dist/development/index.d.ts +10 -50
- package/dist/development/index.js +759 -463
- package/dist/development/index.mjs +2 -2
- package/dist/development/lib/types/route-module.d.mts +13 -5
- package/dist/development/lib/types/route-module.d.ts +13 -5
- package/dist/development/lib/types/route-module.js +1 -1
- package/dist/development/lib/types/route-module.mjs +1 -1
- package/dist/{production/route-data-JFOfNyPS.d.mts → development/route-data-C9zMg-qq.d.mts} +87 -18
- package/dist/development/{route-data-JFOfNyPS.d.mts → route-data-C9zMg-qq.d.ts} +87 -18
- package/dist/production/{chunk-3VYQCA5J.mjs → chunk-DRRQRV77.mjs} +759 -463
- package/dist/production/dom-export.d.mts +14 -4
- package/dist/production/dom-export.d.ts +14 -4
- package/dist/production/dom-export.js +269 -201
- package/dist/production/dom-export.mjs +9 -6
- package/dist/{development/fog-of-war-B3edLoNW.d.ts → production/fog-of-war-CYAe8qUt.d.mts} +93 -17
- package/dist/production/{fog-of-war-B3edLoNW.d.ts → fog-of-war-CrM4EOZM.d.ts} +93 -17
- package/dist/production/index.d.mts +10 -50
- package/dist/production/index.d.ts +10 -50
- package/dist/production/index.js +759 -463
- package/dist/production/index.mjs +2 -2
- package/dist/production/lib/types/route-module.d.mts +13 -5
- package/dist/production/lib/types/route-module.d.ts +13 -5
- package/dist/production/lib/types/route-module.js +1 -1
- package/dist/production/lib/types/route-module.mjs +1 -1
- package/dist/{development/route-data-JFOfNyPS.d.ts → production/route-data-C9zMg-qq.d.mts} +87 -18
- package/dist/production/{route-data-JFOfNyPS.d.ts → route-data-C9zMg-qq.d.ts} +87 -18
- package/package.json +1 -1
- package/dist/development/data-CQbyyGzl.d.mts +0 -11
- package/dist/development/data-CQbyyGzl.d.ts +0 -11
- package/dist/production/data-CQbyyGzl.d.mts +0 -11
- package/dist/production/data-CQbyyGzl.d.ts +0 -11
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-beaa4f52a
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -551,7 +551,7 @@ function decodePath(value) {
|
|
|
551
551
|
} catch (error) {
|
|
552
552
|
warning(
|
|
553
553
|
false,
|
|
554
|
-
`The URL path "${value}" could not be decoded because it is
|
|
554
|
+
`The URL path "${value}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`
|
|
555
555
|
);
|
|
556
556
|
return value;
|
|
557
557
|
}
|
|
@@ -764,6 +764,7 @@ function createRouter(init) {
|
|
|
764
764
|
);
|
|
765
765
|
let inFlightDataRoutes;
|
|
766
766
|
let basename = init.basename || "/";
|
|
767
|
+
let routerContext = typeof init.context !== "undefined" ? init.context : {};
|
|
767
768
|
let dataStrategyImpl = init.dataStrategy || defaultDataStrategy;
|
|
768
769
|
let patchRoutesOnNavigationImpl = init.patchRoutesOnNavigation;
|
|
769
770
|
let future = {
|
|
@@ -1204,6 +1205,7 @@ function createRouter(init) {
|
|
|
1204
1205
|
pendingNavigationController.signal,
|
|
1205
1206
|
opts && opts.submission
|
|
1206
1207
|
);
|
|
1208
|
+
let scopedContext = { ...routerContext };
|
|
1207
1209
|
let pendingActionResult;
|
|
1208
1210
|
if (opts && opts.pendingError) {
|
|
1209
1211
|
pendingActionResult = [
|
|
@@ -1216,6 +1218,7 @@ function createRouter(init) {
|
|
|
1216
1218
|
location,
|
|
1217
1219
|
opts.submission,
|
|
1218
1220
|
matches,
|
|
1221
|
+
scopedContext,
|
|
1219
1222
|
fogOfWar.active,
|
|
1220
1223
|
{ replace: opts.replace, flushSync: flushSync2 }
|
|
1221
1224
|
);
|
|
@@ -1256,6 +1259,7 @@ function createRouter(init) {
|
|
|
1256
1259
|
request,
|
|
1257
1260
|
location,
|
|
1258
1261
|
matches,
|
|
1262
|
+
scopedContext,
|
|
1259
1263
|
fogOfWar.active,
|
|
1260
1264
|
loadingNavigation,
|
|
1261
1265
|
opts && opts.submission,
|
|
@@ -1276,7 +1280,7 @@ function createRouter(init) {
|
|
|
1276
1280
|
errors
|
|
1277
1281
|
});
|
|
1278
1282
|
}
|
|
1279
|
-
async function handleAction(request, location, submission, matches, isFogOfWar, opts = {}) {
|
|
1283
|
+
async function handleAction(request, location, submission, matches, scopedContext, isFogOfWar, opts = {}) {
|
|
1280
1284
|
interruptActiveLoads();
|
|
1281
1285
|
let navigation = getSubmittingNavigation(location, submission);
|
|
1282
1286
|
updateState({ navigation }, { flushSync: opts.flushSync === true });
|
|
@@ -1330,15 +1334,23 @@ function createRouter(init) {
|
|
|
1330
1334
|
})
|
|
1331
1335
|
};
|
|
1332
1336
|
} else {
|
|
1333
|
-
let results = await
|
|
1337
|
+
let results = await callRouterDataStrategy(
|
|
1334
1338
|
"action",
|
|
1335
|
-
state,
|
|
1336
1339
|
request,
|
|
1337
1340
|
[actionMatch],
|
|
1338
1341
|
matches,
|
|
1342
|
+
scopedContext,
|
|
1339
1343
|
null
|
|
1340
1344
|
);
|
|
1341
1345
|
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
|
+
}
|
|
1342
1354
|
if (request.signal.aborted) {
|
|
1343
1355
|
return { shortCircuited: true };
|
|
1344
1356
|
}
|
|
@@ -1376,7 +1388,7 @@ function createRouter(init) {
|
|
|
1376
1388
|
pendingActionResult: [actionMatch.route.id, result]
|
|
1377
1389
|
};
|
|
1378
1390
|
}
|
|
1379
|
-
async function handleLoaders(request, location, matches, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync2, pendingActionResult) {
|
|
1391
|
+
async function handleLoaders(request, location, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync2, pendingActionResult) {
|
|
1380
1392
|
let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
|
|
1381
1393
|
let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
|
|
1382
1394
|
let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
|
|
@@ -1486,11 +1498,11 @@ function createRouter(init) {
|
|
|
1486
1498
|
);
|
|
1487
1499
|
}
|
|
1488
1500
|
let { loaderResults, fetcherResults } = await callLoadersAndMaybeResolveData(
|
|
1489
|
-
state,
|
|
1490
1501
|
matches,
|
|
1491
1502
|
matchesToLoad,
|
|
1492
1503
|
revalidatingFetchers,
|
|
1493
|
-
request
|
|
1504
|
+
request,
|
|
1505
|
+
scopedContext
|
|
1494
1506
|
);
|
|
1495
1507
|
if (request.signal.aborted) {
|
|
1496
1508
|
return { shortCircuited: true };
|
|
@@ -1598,6 +1610,7 @@ function createRouter(init) {
|
|
|
1598
1610
|
return;
|
|
1599
1611
|
}
|
|
1600
1612
|
let match = getTargetMatch(matches, path);
|
|
1613
|
+
let scopedContext = { ...routerContext };
|
|
1601
1614
|
let preventScrollReset = (opts && opts.preventScrollReset) === true;
|
|
1602
1615
|
if (submission && isMutationMethod(submission.formMethod)) {
|
|
1603
1616
|
await handleFetcherAction(
|
|
@@ -1606,6 +1619,7 @@ function createRouter(init) {
|
|
|
1606
1619
|
path,
|
|
1607
1620
|
match,
|
|
1608
1621
|
matches,
|
|
1622
|
+
scopedContext,
|
|
1609
1623
|
fogOfWar.active,
|
|
1610
1624
|
flushSync2,
|
|
1611
1625
|
preventScrollReset,
|
|
@@ -1620,13 +1634,14 @@ function createRouter(init) {
|
|
|
1620
1634
|
path,
|
|
1621
1635
|
match,
|
|
1622
1636
|
matches,
|
|
1637
|
+
scopedContext,
|
|
1623
1638
|
fogOfWar.active,
|
|
1624
1639
|
flushSync2,
|
|
1625
1640
|
preventScrollReset,
|
|
1626
1641
|
submission
|
|
1627
1642
|
);
|
|
1628
1643
|
}
|
|
1629
|
-
async function handleFetcherAction(key, routeId, path, match, requestMatches, isFogOfWar, flushSync2, preventScrollReset, submission) {
|
|
1644
|
+
async function handleFetcherAction(key, routeId, path, match, requestMatches, scopedContext, isFogOfWar, flushSync2, preventScrollReset, submission) {
|
|
1630
1645
|
interruptActiveLoads();
|
|
1631
1646
|
fetchLoadMatches.delete(key);
|
|
1632
1647
|
function detectAndHandle405Error(m) {
|
|
@@ -1684,12 +1699,12 @@ function createRouter(init) {
|
|
|
1684
1699
|
}
|
|
1685
1700
|
fetchControllers.set(key, abortController);
|
|
1686
1701
|
let originatingLoadId = incrementingLoadId;
|
|
1687
|
-
let actionResults = await
|
|
1702
|
+
let actionResults = await callRouterDataStrategy(
|
|
1688
1703
|
"action",
|
|
1689
|
-
state,
|
|
1690
1704
|
fetchRequest,
|
|
1691
1705
|
[match],
|
|
1692
1706
|
requestMatches,
|
|
1707
|
+
scopedContext,
|
|
1693
1708
|
key
|
|
1694
1709
|
);
|
|
1695
1710
|
let actionResult = actionResults[match.route.id];
|
|
@@ -1773,11 +1788,11 @@ function createRouter(init) {
|
|
|
1773
1788
|
abortPendingFetchRevalidations
|
|
1774
1789
|
);
|
|
1775
1790
|
let { loaderResults, fetcherResults } = await callLoadersAndMaybeResolveData(
|
|
1776
|
-
state,
|
|
1777
1791
|
matches,
|
|
1778
1792
|
matchesToLoad,
|
|
1779
1793
|
revalidatingFetchers,
|
|
1780
|
-
revalidationRequest
|
|
1794
|
+
revalidationRequest,
|
|
1795
|
+
scopedContext
|
|
1781
1796
|
);
|
|
1782
1797
|
if (abortController.signal.aborted) {
|
|
1783
1798
|
return;
|
|
@@ -1844,7 +1859,7 @@ function createRouter(init) {
|
|
|
1844
1859
|
isRevalidationRequired = false;
|
|
1845
1860
|
}
|
|
1846
1861
|
}
|
|
1847
|
-
async function handleFetcherLoader(key, routeId, path, match, matches, isFogOfWar, flushSync2, preventScrollReset, submission) {
|
|
1862
|
+
async function handleFetcherLoader(key, routeId, path, match, matches, scopedContext, isFogOfWar, flushSync2, preventScrollReset, submission) {
|
|
1848
1863
|
let existingFetcher = state.fetchers.get(key);
|
|
1849
1864
|
updateFetcherState(
|
|
1850
1865
|
key,
|
|
@@ -1886,12 +1901,12 @@ function createRouter(init) {
|
|
|
1886
1901
|
}
|
|
1887
1902
|
fetchControllers.set(key, abortController);
|
|
1888
1903
|
let originatingLoadId = incrementingLoadId;
|
|
1889
|
-
let results = await
|
|
1904
|
+
let results = await callRouterDataStrategy(
|
|
1890
1905
|
"loader",
|
|
1891
|
-
state,
|
|
1892
1906
|
fetchRequest,
|
|
1893
1907
|
[match],
|
|
1894
1908
|
matches,
|
|
1909
|
+
scopedContext,
|
|
1895
1910
|
key
|
|
1896
1911
|
);
|
|
1897
1912
|
let result = results[match.route.id];
|
|
@@ -1993,20 +2008,20 @@ function createRouter(init) {
|
|
|
1993
2008
|
});
|
|
1994
2009
|
}
|
|
1995
2010
|
}
|
|
1996
|
-
async function
|
|
2011
|
+
async function callRouterDataStrategy(type, request, matchesToLoad, matches, scopedContext, fetcherKey) {
|
|
1997
2012
|
let results;
|
|
1998
2013
|
let dataResults = {};
|
|
1999
2014
|
try {
|
|
2000
2015
|
results = await callDataStrategyImpl(
|
|
2001
2016
|
dataStrategyImpl,
|
|
2002
2017
|
type,
|
|
2003
|
-
state2,
|
|
2004
2018
|
request,
|
|
2005
2019
|
matchesToLoad,
|
|
2006
2020
|
matches,
|
|
2007
2021
|
fetcherKey,
|
|
2008
2022
|
manifest,
|
|
2009
|
-
mapRouteProperties2
|
|
2023
|
+
mapRouteProperties2,
|
|
2024
|
+
scopedContext
|
|
2010
2025
|
);
|
|
2011
2026
|
} catch (e) {
|
|
2012
2027
|
matchesToLoad.forEach((m) => {
|
|
@@ -2038,24 +2053,24 @@ function createRouter(init) {
|
|
|
2038
2053
|
}
|
|
2039
2054
|
return dataResults;
|
|
2040
2055
|
}
|
|
2041
|
-
async function callLoadersAndMaybeResolveData(
|
|
2042
|
-
let loaderResultsPromise =
|
|
2056
|
+
async function callLoadersAndMaybeResolveData(matches, matchesToLoad, fetchersToLoad, request, scopedContext) {
|
|
2057
|
+
let loaderResultsPromise = callRouterDataStrategy(
|
|
2043
2058
|
"loader",
|
|
2044
|
-
state2,
|
|
2045
2059
|
request,
|
|
2046
2060
|
matchesToLoad,
|
|
2047
2061
|
matches,
|
|
2062
|
+
scopedContext,
|
|
2048
2063
|
null
|
|
2049
2064
|
);
|
|
2050
2065
|
let fetcherResultsPromise = Promise.all(
|
|
2051
2066
|
fetchersToLoad.map(async (f) => {
|
|
2052
2067
|
if (f.matches && f.match && f.controller) {
|
|
2053
|
-
let results = await
|
|
2068
|
+
let results = await callRouterDataStrategy(
|
|
2054
2069
|
"loader",
|
|
2055
|
-
state2,
|
|
2056
2070
|
createClientSideRequest(init.history, f.path, f.controller.signal),
|
|
2057
2071
|
[f.match],
|
|
2058
2072
|
f.matches,
|
|
2073
|
+
scopedContext,
|
|
2059
2074
|
f.key
|
|
2060
2075
|
);
|
|
2061
2076
|
let result = results[f.match.route.id];
|
|
@@ -2797,20 +2812,132 @@ async function loadLazyRouteModule(route, mapRouteProperties2, manifest) {
|
|
|
2797
2812
|
lazy: void 0
|
|
2798
2813
|
});
|
|
2799
2814
|
}
|
|
2800
|
-
async function defaultDataStrategy({
|
|
2801
|
-
matches
|
|
2802
|
-
|
|
2803
|
-
let
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2815
|
+
async function defaultDataStrategy(args) {
|
|
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
|
+
}
|
|
2808
2839
|
);
|
|
2840
|
+
return results;
|
|
2841
|
+
}
|
|
2842
|
+
async function runMiddlewarePipeline({
|
|
2843
|
+
request,
|
|
2844
|
+
params,
|
|
2845
|
+
context,
|
|
2846
|
+
matches
|
|
2847
|
+
}, lastIndex, propagateResult, handler, errorHandler) {
|
|
2848
|
+
let middlewareState = {
|
|
2849
|
+
keyedResults: {},
|
|
2850
|
+
propagateResult
|
|
2851
|
+
};
|
|
2852
|
+
try {
|
|
2853
|
+
let result = await callRouteMiddleware(
|
|
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
|
+
}
|
|
2809
2927
|
}
|
|
2810
|
-
async function callDataStrategyImpl(dataStrategyImpl, type,
|
|
2928
|
+
async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties2, scopedContext) {
|
|
2811
2929
|
let loadRouteDefinitionsPromises = matches.map(
|
|
2812
2930
|
(m) => m.route.lazy ? loadLazyRouteModule(m.route, mapRouteProperties2, manifest) : void 0
|
|
2813
2931
|
);
|
|
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
|
+
}
|
|
2814
2941
|
let dsMatches = matches.map((match, i) => {
|
|
2815
2942
|
let loadRoutePromise = loadRouteDefinitionsPromises[i];
|
|
2816
2943
|
let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
|
|
@@ -2824,7 +2951,7 @@ async function callDataStrategyImpl(dataStrategyImpl, type, state, request, matc
|
|
|
2824
2951
|
match,
|
|
2825
2952
|
loadRoutePromise,
|
|
2826
2953
|
handlerOverride,
|
|
2827
|
-
|
|
2954
|
+
scopedContext
|
|
2828
2955
|
) : Promise.resolve({ type: "data" /* data */, result: void 0 });
|
|
2829
2956
|
};
|
|
2830
2957
|
return {
|
|
@@ -2838,7 +2965,7 @@ async function callDataStrategyImpl(dataStrategyImpl, type, state, request, matc
|
|
|
2838
2965
|
request,
|
|
2839
2966
|
params: matches[0].params,
|
|
2840
2967
|
fetcherKey,
|
|
2841
|
-
context:
|
|
2968
|
+
context: scopedContext
|
|
2842
2969
|
});
|
|
2843
2970
|
try {
|
|
2844
2971
|
await Promise.all(loadRouteDefinitionsPromises);
|
|
@@ -2846,7 +2973,7 @@ async function callDataStrategyImpl(dataStrategyImpl, type, state, request, matc
|
|
|
2846
2973
|
}
|
|
2847
2974
|
return results;
|
|
2848
2975
|
}
|
|
2849
|
-
async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride,
|
|
2976
|
+
async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, scopedContext) {
|
|
2850
2977
|
let result;
|
|
2851
2978
|
let onReject;
|
|
2852
2979
|
let runHandler = (handler) => {
|
|
@@ -2866,7 +2993,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
|
|
|
2866
2993
|
{
|
|
2867
2994
|
request,
|
|
2868
2995
|
params: match.params,
|
|
2869
|
-
context:
|
|
2996
|
+
context: scopedContext
|
|
2870
2997
|
},
|
|
2871
2998
|
...ctx !== void 0 ? [ctx] : []
|
|
2872
2999
|
);
|
|
@@ -4262,31 +4389,6 @@ async function prefetchStyleLink(descriptor) {
|
|
|
4262
4389
|
function isPageLinkDescriptor(object) {
|
|
4263
4390
|
return object != null && typeof object.page === "string";
|
|
4264
4391
|
}
|
|
4265
|
-
function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
|
|
4266
|
-
return dedupeHrefs(
|
|
4267
|
-
matches.map((match) => {
|
|
4268
|
-
let route = manifest.routes[match.route.id];
|
|
4269
|
-
if (!route) return [];
|
|
4270
|
-
let hrefs = [route.module];
|
|
4271
|
-
if (route.clientActionModule) {
|
|
4272
|
-
hrefs = hrefs.concat(route.clientActionModule);
|
|
4273
|
-
}
|
|
4274
|
-
if (route.clientLoaderModule) {
|
|
4275
|
-
hrefs = hrefs.concat(route.clientLoaderModule);
|
|
4276
|
-
}
|
|
4277
|
-
if (includeHydrateFallback && route.hydrateFallbackModule) {
|
|
4278
|
-
hrefs = hrefs.concat(route.hydrateFallbackModule);
|
|
4279
|
-
}
|
|
4280
|
-
if (route.imports) {
|
|
4281
|
-
hrefs = hrefs.concat(route.imports);
|
|
4282
|
-
}
|
|
4283
|
-
return hrefs;
|
|
4284
|
-
}).flat(1)
|
|
4285
|
-
);
|
|
4286
|
-
}
|
|
4287
|
-
function dedupeHrefs(hrefs) {
|
|
4288
|
-
return [...new Set(hrefs)];
|
|
4289
|
-
}
|
|
4290
4392
|
var _isPreloadSupported;
|
|
4291
4393
|
function isPreloadSupported() {
|
|
4292
4394
|
if (_isPreloadSupported !== void 0) {
|
|
@@ -4330,21 +4432,63 @@ async function createRequestInit(request) {
|
|
|
4330
4432
|
|
|
4331
4433
|
// lib/dom/ssr/single-fetch.tsx
|
|
4332
4434
|
var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
|
|
4435
|
+
function middlewareErrorHandler(e, keyedResults) {
|
|
4436
|
+
Object.assign(keyedResults, {
|
|
4437
|
+
[e.routeId]: { type: "error", result: e.error }
|
|
4438
|
+
});
|
|
4439
|
+
}
|
|
4333
4440
|
function getSingleFetchDataStrategy(manifest, routeModules, getRouter) {
|
|
4334
|
-
return async (
|
|
4441
|
+
return async (args) => {
|
|
4442
|
+
let { request, matches, fetcherKey } = args;
|
|
4335
4443
|
if (request.method !== "GET") {
|
|
4336
|
-
return
|
|
4444
|
+
return runMiddlewarePipeline(
|
|
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
|
+
);
|
|
4337
4454
|
}
|
|
4338
4455
|
if (fetcherKey) {
|
|
4339
|
-
return
|
|
4456
|
+
return runMiddlewarePipeline(
|
|
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
|
+
);
|
|
4340
4469
|
}
|
|
4341
|
-
|
|
4470
|
+
let lowestLoadingIndex = getLowestLoadingIndex(
|
|
4342
4471
|
manifest,
|
|
4343
4472
|
routeModules,
|
|
4344
4473
|
getRouter(),
|
|
4345
|
-
request,
|
|
4346
4474
|
matches
|
|
4347
4475
|
);
|
|
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
|
+
);
|
|
4348
4492
|
};
|
|
4349
4493
|
}
|
|
4350
4494
|
async function singleFetchActionStrategy(request, matches) {
|
|
@@ -4374,6 +4518,20 @@ async function singleFetchActionStrategy(request, matches) {
|
|
|
4374
4518
|
}
|
|
4375
4519
|
};
|
|
4376
4520
|
}
|
|
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
|
+
}
|
|
4377
4535
|
async function singleFetchLoaderNavigationStrategy(manifest, routeModules, router2, request, matches) {
|
|
4378
4536
|
let routesParams = /* @__PURE__ */ new Set();
|
|
4379
4537
|
let foundOptOutRoute = false;
|
|
@@ -4392,7 +4550,7 @@ async function singleFetchLoaderNavigationStrategy(manifest, routeModules, route
|
|
|
4392
4550
|
if (!router2.state.initialized) {
|
|
4393
4551
|
return;
|
|
4394
4552
|
}
|
|
4395
|
-
if (
|
|
4553
|
+
if (isOptedOut(manifestRoute, routeModules[m.route.id], m, router2)) {
|
|
4396
4554
|
foundOptOutRoute = true;
|
|
4397
4555
|
return;
|
|
4398
4556
|
}
|
|
@@ -4506,6 +4664,14 @@ async function fetchAndDecode(url, init) {
|
|
|
4506
4664
|
if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
|
|
4507
4665
|
throw new ErrorResponseImpl(404, "Not Found", true);
|
|
4508
4666
|
}
|
|
4667
|
+
const NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205]);
|
|
4668
|
+
if (NO_BODY_STATUS_CODES.has(res.status)) {
|
|
4669
|
+
if (!init.method || init.method === "GET") {
|
|
4670
|
+
return { status: res.status, data: {} };
|
|
4671
|
+
} else {
|
|
4672
|
+
return { status: res.status, data: { data: void 0 } };
|
|
4673
|
+
}
|
|
4674
|
+
}
|
|
4509
4675
|
invariant2(res.body, "No response body to decode");
|
|
4510
4676
|
try {
|
|
4511
4677
|
let decoded = await decodeViaTurboStream(res.body, window);
|
|
@@ -4811,21 +4977,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4811
4977
|
}
|
|
4812
4978
|
return fetchServerHandler(singleFetch);
|
|
4813
4979
|
}
|
|
4814
|
-
function prefetchModule(modulePath) {
|
|
4815
|
-
import(
|
|
4816
|
-
/* @vite-ignore */
|
|
4817
|
-
/* webpackIgnore: true */
|
|
4818
|
-
modulePath
|
|
4819
|
-
);
|
|
4820
|
-
}
|
|
4821
|
-
function prefetchRouteModuleChunks(route2) {
|
|
4822
|
-
if (route2.clientActionModule) {
|
|
4823
|
-
prefetchModule(route2.clientActionModule);
|
|
4824
|
-
}
|
|
4825
|
-
if (route2.clientLoaderModule) {
|
|
4826
|
-
prefetchModule(route2.clientLoaderModule);
|
|
4827
|
-
}
|
|
4828
|
-
}
|
|
4829
4980
|
async function prefetchStylesAndCallHandler(handler) {
|
|
4830
4981
|
let cachedModule = routeModulesCache[route.id];
|
|
4831
4982
|
let linkPrefetchPromise = cachedModule ? prefetchStyleLinks(route, cachedModule) : Promise.resolve();
|
|
@@ -4844,6 +4995,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4844
4995
|
Object.assign(dataRoute, {
|
|
4845
4996
|
...dataRoute,
|
|
4846
4997
|
...getRouteComponents(route, routeModule, isSpaMode),
|
|
4998
|
+
middleware: routeModule.clientMiddleware,
|
|
4847
4999
|
handle: routeModule.handle,
|
|
4848
5000
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
4849
5001
|
routeModule,
|
|
@@ -4856,7 +5008,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4856
5008
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
4857
5009
|
let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
|
|
4858
5010
|
let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
|
|
4859
|
-
dataRoute.loader = async ({ request, params }, singleFetch) => {
|
|
5011
|
+
dataRoute.loader = async ({ request, params, context }, singleFetch) => {
|
|
4860
5012
|
try {
|
|
4861
5013
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
4862
5014
|
invariant2(
|
|
@@ -4870,6 +5022,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4870
5022
|
return routeModule.clientLoader({
|
|
4871
5023
|
request,
|
|
4872
5024
|
params,
|
|
5025
|
+
context,
|
|
4873
5026
|
async serverLoader() {
|
|
4874
5027
|
preventInvalidServerHandlerCall("loader", route, isSpaMode);
|
|
4875
5028
|
if (isHydrationRequest) {
|
|
@@ -4894,7 +5047,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4894
5047
|
routeModule,
|
|
4895
5048
|
isSpaMode
|
|
4896
5049
|
);
|
|
4897
|
-
dataRoute.action = ({ request, params }, singleFetch) => {
|
|
5050
|
+
dataRoute.action = ({ request, params, context }, singleFetch) => {
|
|
4898
5051
|
return prefetchStylesAndCallHandler(async () => {
|
|
4899
5052
|
invariant2(
|
|
4900
5053
|
routeModule,
|
|
@@ -4909,6 +5062,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4909
5062
|
return routeModule.clientAction({
|
|
4910
5063
|
request,
|
|
4911
5064
|
params,
|
|
5065
|
+
context,
|
|
4912
5066
|
async serverAction() {
|
|
4913
5067
|
preventInvalidServerHandlerCall("action", route, isSpaMode);
|
|
4914
5068
|
return fetchServerAction(singleFetch);
|
|
@@ -4918,64 +5072,26 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4918
5072
|
};
|
|
4919
5073
|
} else {
|
|
4920
5074
|
if (!route.hasClientLoader) {
|
|
4921
|
-
dataRoute.loader = (
|
|
5075
|
+
dataRoute.loader = (_, singleFetch) => prefetchStylesAndCallHandler(() => {
|
|
4922
5076
|
if (isSpaMode) return Promise.resolve(null);
|
|
4923
5077
|
return fetchServerLoader(singleFetch);
|
|
4924
5078
|
});
|
|
4925
|
-
} else if (route.clientLoaderModule) {
|
|
4926
|
-
dataRoute.loader = async (args, singleFetch) => {
|
|
4927
|
-
invariant2(route.clientLoaderModule);
|
|
4928
|
-
let { clientLoader } = await import(
|
|
4929
|
-
/* @vite-ignore */
|
|
4930
|
-
/* webpackIgnore: true */
|
|
4931
|
-
route.clientLoaderModule
|
|
4932
|
-
);
|
|
4933
|
-
return clientLoader({
|
|
4934
|
-
...args,
|
|
4935
|
-
async serverLoader() {
|
|
4936
|
-
preventInvalidServerHandlerCall("loader", route, isSpaMode);
|
|
4937
|
-
return fetchServerLoader(singleFetch);
|
|
4938
|
-
}
|
|
4939
|
-
});
|
|
4940
|
-
};
|
|
4941
5079
|
}
|
|
4942
5080
|
if (!route.hasClientAction) {
|
|
4943
|
-
dataRoute.action = (
|
|
5081
|
+
dataRoute.action = (_, singleFetch) => prefetchStylesAndCallHandler(() => {
|
|
4944
5082
|
if (isSpaMode) {
|
|
4945
5083
|
throw noActionDefinedError("clientAction", route.id);
|
|
4946
5084
|
}
|
|
4947
5085
|
return fetchServerAction(singleFetch);
|
|
4948
5086
|
});
|
|
4949
|
-
} else if (route.clientActionModule) {
|
|
4950
|
-
dataRoute.action = async (args, singleFetch) => {
|
|
4951
|
-
invariant2(route.clientActionModule);
|
|
4952
|
-
prefetchRouteModuleChunks(route);
|
|
4953
|
-
let { clientAction } = await import(
|
|
4954
|
-
/* @vite-ignore */
|
|
4955
|
-
/* webpackIgnore: true */
|
|
4956
|
-
route.clientActionModule
|
|
4957
|
-
);
|
|
4958
|
-
return clientAction({
|
|
4959
|
-
...args,
|
|
4960
|
-
async serverAction() {
|
|
4961
|
-
preventInvalidServerHandlerCall("action", route, isSpaMode);
|
|
4962
|
-
return fetchServerAction(singleFetch);
|
|
4963
|
-
}
|
|
4964
|
-
});
|
|
4965
|
-
};
|
|
4966
5087
|
}
|
|
4967
5088
|
dataRoute.lazy = async () => {
|
|
4968
|
-
|
|
4969
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
4970
|
-
}
|
|
4971
|
-
let modPromise = loadRouteModuleWithBlockingLinks(
|
|
5089
|
+
let mod = await loadRouteModuleWithBlockingLinks(
|
|
4972
5090
|
route,
|
|
4973
5091
|
routeModulesCache
|
|
4974
5092
|
);
|
|
4975
|
-
prefetchRouteModuleChunks(route);
|
|
4976
|
-
let mod = await modPromise;
|
|
4977
5093
|
let lazyRoute = { ...mod };
|
|
4978
|
-
if (mod.clientLoader
|
|
5094
|
+
if (mod.clientLoader) {
|
|
4979
5095
|
let clientLoader = mod.clientLoader;
|
|
4980
5096
|
lazyRoute.loader = (args, singleFetch) => clientLoader({
|
|
4981
5097
|
...args,
|
|
@@ -4985,7 +5101,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4985
5101
|
}
|
|
4986
5102
|
});
|
|
4987
5103
|
}
|
|
4988
|
-
if (mod.clientAction
|
|
5104
|
+
if (mod.clientAction) {
|
|
4989
5105
|
let clientAction = mod.clientAction;
|
|
4990
5106
|
lazyRoute.action = (args, singleFetch) => clientAction({
|
|
4991
5107
|
...args,
|
|
@@ -4998,6 +5114,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4998
5114
|
return {
|
|
4999
5115
|
...lazyRoute.loader ? { loader: lazyRoute.loader } : {},
|
|
5000
5116
|
...lazyRoute.action ? { action: lazyRoute.action } : {},
|
|
5117
|
+
middleware: mod.clientMiddleware,
|
|
5001
5118
|
hasErrorBoundary: lazyRoute.hasErrorBoundary,
|
|
5002
5119
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
5003
5120
|
lazyRoute,
|
|
@@ -5055,6 +5172,7 @@ async function loadRouteModuleWithBlockingLinks(route, routeModules) {
|
|
|
5055
5172
|
return {
|
|
5056
5173
|
Component: getRouteModuleComponent(routeModule),
|
|
5057
5174
|
ErrorBoundary: routeModule.ErrorBoundary,
|
|
5175
|
+
clientMiddleware: routeModule.clientMiddleware,
|
|
5058
5176
|
clientAction: routeModule.clientAction,
|
|
5059
5177
|
clientLoader: routeModule.clientLoader,
|
|
5060
5178
|
handle: routeModule.handle,
|
|
@@ -5134,12 +5252,13 @@ function useFogOFWarDiscovery(router2, manifest, routeModules, isSpaMode) {
|
|
|
5134
5252
|
if (!path) {
|
|
5135
5253
|
return;
|
|
5136
5254
|
}
|
|
5137
|
-
let
|
|
5138
|
-
if (!discoveredPaths.has(
|
|
5139
|
-
nextPaths.add(
|
|
5255
|
+
let pathname = el.tagName === "A" ? el.pathname : new URL(path, window.location.origin).pathname;
|
|
5256
|
+
if (!discoveredPaths.has(pathname)) {
|
|
5257
|
+
nextPaths.add(pathname);
|
|
5140
5258
|
}
|
|
5141
5259
|
}
|
|
5142
5260
|
async function fetchPatches() {
|
|
5261
|
+
document.querySelectorAll("a[data-discover], form[data-discover]").forEach(registerElement);
|
|
5143
5262
|
let lazyPaths = Array.from(nextPaths.keys()).filter((path) => {
|
|
5144
5263
|
if (discoveredPaths.has(path)) {
|
|
5145
5264
|
nextPaths.delete(path);
|
|
@@ -5163,30 +5282,9 @@ function useFogOFWarDiscovery(router2, manifest, routeModules, isSpaMode) {
|
|
|
5163
5282
|
console.error("Failed to fetch manifest patches", e);
|
|
5164
5283
|
}
|
|
5165
5284
|
}
|
|
5166
|
-
document.body.querySelectorAll("a[data-discover], form[data-discover]").forEach((el) => registerElement(el));
|
|
5167
|
-
fetchPatches();
|
|
5168
5285
|
let debouncedFetchPatches = debounce(fetchPatches, 100);
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
}
|
|
5172
|
-
let observer = new MutationObserver((records) => {
|
|
5173
|
-
let elements = /* @__PURE__ */ new Set();
|
|
5174
|
-
records.forEach((r) => {
|
|
5175
|
-
[r.target, ...r.addedNodes].forEach((node) => {
|
|
5176
|
-
if (!isElement(node)) return;
|
|
5177
|
-
if (node.tagName === "A" && node.getAttribute("data-discover")) {
|
|
5178
|
-
elements.add(node);
|
|
5179
|
-
} else if (node.tagName === "FORM" && node.getAttribute("data-discover")) {
|
|
5180
|
-
elements.add(node);
|
|
5181
|
-
}
|
|
5182
|
-
if (node.tagName !== "A") {
|
|
5183
|
-
node.querySelectorAll("a[data-discover], form[data-discover]").forEach((el) => elements.add(el));
|
|
5184
|
-
}
|
|
5185
|
-
});
|
|
5186
|
-
});
|
|
5187
|
-
elements.forEach((el) => registerElement(el));
|
|
5188
|
-
debouncedFetchPatches();
|
|
5189
|
-
});
|
|
5286
|
+
fetchPatches();
|
|
5287
|
+
let observer = new MutationObserver(() => debouncedFetchPatches());
|
|
5190
5288
|
observer.observe(document.documentElement, {
|
|
5191
5289
|
subtree: true,
|
|
5192
5290
|
childList: true,
|
|
@@ -5306,44 +5404,11 @@ function Scripts(props) {
|
|
|
5306
5404
|
let streamScript = "window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());";
|
|
5307
5405
|
let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};${streamScript}` : " ";
|
|
5308
5406
|
let routeModulesScript = !isStatic ? " " : `${manifest.hmr?.runtime ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
|
|
5309
|
-
${matches.map(
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
clientActionModule,
|
|
5315
|
-
clientLoaderModule,
|
|
5316
|
-
hydrateFallbackModule,
|
|
5317
|
-
module: module2
|
|
5318
|
-
} = manifestEntry;
|
|
5319
|
-
let chunks = [
|
|
5320
|
-
...clientActionModule ? [
|
|
5321
|
-
{
|
|
5322
|
-
module: clientActionModule,
|
|
5323
|
-
varName: `${routeVarName}_clientAction`
|
|
5324
|
-
}
|
|
5325
|
-
] : [],
|
|
5326
|
-
...clientLoaderModule ? [
|
|
5327
|
-
{
|
|
5328
|
-
module: clientLoaderModule,
|
|
5329
|
-
varName: `${routeVarName}_clientLoader`
|
|
5330
|
-
}
|
|
5331
|
-
] : [],
|
|
5332
|
-
...hydrateFallbackModule ? [
|
|
5333
|
-
{
|
|
5334
|
-
module: hydrateFallbackModule,
|
|
5335
|
-
varName: `${routeVarName}_HydrateFallback`
|
|
5336
|
-
}
|
|
5337
|
-
] : [],
|
|
5338
|
-
{ module: module2, varName: `${routeVarName}_main` }
|
|
5339
|
-
];
|
|
5340
|
-
if (chunks.length === 1) {
|
|
5341
|
-
return `import * as ${routeVarName} from ${JSON.stringify(module2)};`;
|
|
5342
|
-
}
|
|
5343
|
-
let chunkImportsSnippet = chunks.map((chunk) => `import * as ${chunk.varName} from "${chunk.module}";`).join("\n");
|
|
5344
|
-
let mergedChunksSnippet = `const ${routeVarName} = {${chunks.map((chunk) => `...${chunk.varName}`).join(",")}};`;
|
|
5345
|
-
return [chunkImportsSnippet, mergedChunksSnippet].join("\n");
|
|
5346
|
-
}).join("\n")}
|
|
5407
|
+
${matches.map(
|
|
5408
|
+
(match, index) => `import * as route${index} from ${JSON.stringify(
|
|
5409
|
+
manifest.routes[match.route.id].module
|
|
5410
|
+
)};`
|
|
5411
|
+
).join("\n")}
|
|
5347
5412
|
${enableFogOfWar ? (
|
|
5348
5413
|
// Inline a minimal manifest with the SSR matches
|
|
5349
5414
|
`window.__reactRouterManifest = ${JSON.stringify(
|
|
@@ -5374,11 +5439,11 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
5374
5439
|
}
|
|
5375
5440
|
));
|
|
5376
5441
|
}, []);
|
|
5377
|
-
let
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
);
|
|
5442
|
+
let routePreloads = matches.map((match) => {
|
|
5443
|
+
let route = manifest.routes[match.route.id];
|
|
5444
|
+
return route ? (route.imports || []).concat([route.module]) : [];
|
|
5445
|
+
}).flat(1);
|
|
5446
|
+
let preloads = isHydrated ? [] : manifest.entry.imports.concat(routePreloads);
|
|
5382
5447
|
return isHydrated ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, !enableFogOfWar ? /* @__PURE__ */ React9.createElement(
|
|
5383
5448
|
"link",
|
|
5384
5449
|
{
|
|
@@ -5465,7 +5530,9 @@ function initSsrInfo() {
|
|
|
5465
5530
|
};
|
|
5466
5531
|
}
|
|
5467
5532
|
}
|
|
5468
|
-
function createHydratedRouter(
|
|
5533
|
+
function createHydratedRouter({
|
|
5534
|
+
context
|
|
5535
|
+
}) {
|
|
5469
5536
|
initSsrInfo();
|
|
5470
5537
|
if (!ssrInfo) {
|
|
5471
5538
|
throw new Error(
|
|
@@ -5531,9 +5598,10 @@ function createHydratedRouter() {
|
|
|
5531
5598
|
routes,
|
|
5532
5599
|
history: createBrowserHistory(),
|
|
5533
5600
|
basename: ssrInfo.context.basename,
|
|
5601
|
+
context,
|
|
5534
5602
|
hydrationData,
|
|
5535
5603
|
mapRouteProperties,
|
|
5536
|
-
dataStrategy: getSingleFetchDataStrategy(
|
|
5604
|
+
dataStrategy: ssrInfo.context.isSpaMode ? void 0 : getSingleFetchDataStrategy(
|
|
5537
5605
|
ssrInfo.manifest,
|
|
5538
5606
|
ssrInfo.routeModules,
|
|
5539
5607
|
() => router2
|
|
@@ -5555,9 +5623,9 @@ function createHydratedRouter() {
|
|
|
5555
5623
|
window.__reactRouterDataRouter = router2;
|
|
5556
5624
|
return router2;
|
|
5557
5625
|
}
|
|
5558
|
-
function HydratedRouter() {
|
|
5626
|
+
function HydratedRouter(props) {
|
|
5559
5627
|
if (!router) {
|
|
5560
|
-
router = createHydratedRouter();
|
|
5628
|
+
router = createHydratedRouter({ context: props.context });
|
|
5561
5629
|
}
|
|
5562
5630
|
let [criticalCss, setCriticalCss] = React11.useState(
|
|
5563
5631
|
process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0
|