react-router 7.1.5 → 7.2.0-pre.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 +55 -1
- package/dist/development/{chunk-IR6S3I6Y.mjs → chunk-FXE4ZOSB.mjs} +282 -97
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.d.ts +2 -2
- package/dist/development/dom-export.js +222 -58
- package/dist/development/dom-export.mjs +12 -4
- package/dist/{production/fog-of-war-CCAcUMgB.d.ts → development/fog-of-war-rn7nVSAv.d.ts} +9 -5
- package/dist/development/{fog-of-war-D6dP9JIt.d.mts → fog-of-war-yKFj2vdd.d.mts} +9 -5
- package/dist/development/index.d.mts +43 -7
- package/dist/development/index.d.ts +43 -7
- package/dist/development/index.js +283 -97
- package/dist/development/index.mjs +4 -2
- package/dist/development/lib/types/route-module.d.mts +3 -1
- package/dist/development/lib/types/route-module.d.ts +3 -1
- 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-Cq_b5feC.d.ts → route-data-CfLfC_Bh.d.mts} +2 -1
- package/dist/{production/route-data-Cq_b5feC.d.mts → development/route-data-CfLfC_Bh.d.ts} +2 -1
- package/dist/production/{chunk-JRAGQQ3X.mjs → chunk-3BG6WSY4.mjs} +282 -97
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.d.ts +2 -2
- package/dist/production/dom-export.js +222 -58
- package/dist/production/dom-export.mjs +12 -4
- package/dist/{development/fog-of-war-CCAcUMgB.d.ts → production/fog-of-war-rn7nVSAv.d.ts} +9 -5
- package/dist/production/{fog-of-war-D6dP9JIt.d.mts → fog-of-war-yKFj2vdd.d.mts} +9 -5
- package/dist/production/index.d.mts +43 -7
- package/dist/production/index.d.ts +43 -7
- package/dist/production/index.js +283 -97
- package/dist/production/index.mjs +4 -2
- package/dist/production/lib/types/route-module.d.mts +3 -1
- package/dist/production/lib/types/route-module.d.ts +3 -1
- 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-Cq_b5feC.d.ts → route-data-CfLfC_Bh.d.mts} +2 -1
- package/dist/{development/route-data-Cq_b5feC.d.mts → production/route-data-CfLfC_Bh.d.ts} +2 -1
- package/package.json +1 -1
package/dist/production/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.1
|
|
2
|
+
* react-router v7.2.0-pre.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -108,6 +108,7 @@ __export(react_router_exports, {
|
|
|
108
108
|
createStaticRouter: () => createStaticRouter,
|
|
109
109
|
data: () => data,
|
|
110
110
|
generatePath: () => generatePath,
|
|
111
|
+
href: () => href,
|
|
111
112
|
isCookie: () => isCookie,
|
|
112
113
|
isRouteErrorResponse: () => isRouteErrorResponse,
|
|
113
114
|
isSession: () => isSession,
|
|
@@ -299,13 +300,13 @@ function createHashHistory(options = {}) {
|
|
|
299
300
|
}
|
|
300
301
|
function createHashHref(window2, to) {
|
|
301
302
|
let base = window2.document.querySelector("base");
|
|
302
|
-
let
|
|
303
|
+
let href2 = "";
|
|
303
304
|
if (base && base.getAttribute("href")) {
|
|
304
305
|
let url = window2.location.href;
|
|
305
306
|
let hashIndex = url.indexOf("#");
|
|
306
|
-
|
|
307
|
+
href2 = hashIndex === -1 ? url : url.slice(0, hashIndex);
|
|
307
308
|
}
|
|
308
|
-
return
|
|
309
|
+
return href2 + "#" + (typeof to === "string" ? to : createPath(to));
|
|
309
310
|
}
|
|
310
311
|
function validateHashLocation(location, to) {
|
|
311
312
|
warning(
|
|
@@ -447,13 +448,13 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
447
448
|
}
|
|
448
449
|
function createURL(to) {
|
|
449
450
|
let base = window2.location.origin !== "null" ? window2.location.origin : window2.location.href;
|
|
450
|
-
let
|
|
451
|
-
|
|
451
|
+
let href2 = typeof to === "string" ? to : createPath(to);
|
|
452
|
+
href2 = href2.replace(/ $/, "%20");
|
|
452
453
|
invariant(
|
|
453
454
|
base,
|
|
454
|
-
`No window.location.(origin|href) available to create URL for href: ${
|
|
455
|
+
`No window.location.(origin|href) available to create URL for href: ${href2}`
|
|
455
456
|
);
|
|
456
|
-
return new URL(
|
|
457
|
+
return new URL(href2, base);
|
|
457
458
|
}
|
|
458
459
|
let history = {
|
|
459
460
|
get action() {
|
|
@@ -1855,7 +1856,7 @@ function createRouter(init) {
|
|
|
1855
1856
|
});
|
|
1856
1857
|
return new Map(state.fetchers);
|
|
1857
1858
|
}
|
|
1858
|
-
async function fetch2(key, routeId,
|
|
1859
|
+
async function fetch2(key, routeId, href2, opts) {
|
|
1859
1860
|
abortFetcher(key);
|
|
1860
1861
|
let flushSync = (opts && opts.flushSync) === true;
|
|
1861
1862
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
@@ -1863,7 +1864,7 @@ function createRouter(init) {
|
|
|
1863
1864
|
state.location,
|
|
1864
1865
|
state.matches,
|
|
1865
1866
|
basename,
|
|
1866
|
-
|
|
1867
|
+
href2,
|
|
1867
1868
|
routeId,
|
|
1868
1869
|
opts?.relative
|
|
1869
1870
|
);
|
|
@@ -2604,6 +2605,7 @@ function createRouter(init) {
|
|
|
2604
2605
|
let localManifest = manifest;
|
|
2605
2606
|
try {
|
|
2606
2607
|
await patchRoutesOnNavigationImpl({
|
|
2608
|
+
signal,
|
|
2607
2609
|
path: pathname,
|
|
2608
2610
|
matches: partialMatches,
|
|
2609
2611
|
patch: (routeId, children) => {
|
|
@@ -5500,18 +5502,27 @@ function getKeyedLinksForMatches(matches, routeModules, manifest) {
|
|
|
5500
5502
|
let module2 = routeModules[match.route.id];
|
|
5501
5503
|
let route = manifest.routes[match.route.id];
|
|
5502
5504
|
return [
|
|
5503
|
-
route && route.css ? route.css.map((
|
|
5505
|
+
route && route.css ? route.css.map((href2) => ({ rel: "stylesheet", href: href2 })) : [],
|
|
5504
5506
|
module2?.links?.() || []
|
|
5505
5507
|
];
|
|
5506
5508
|
}).flat(2);
|
|
5507
|
-
let preloads =
|
|
5509
|
+
let preloads = getModuleLinkHrefs(matches, manifest);
|
|
5508
5510
|
return dedupeLinkDescriptors(descriptors, preloads);
|
|
5509
5511
|
}
|
|
5512
|
+
function getRouteCssDescriptors(route) {
|
|
5513
|
+
if (!route.css) return [];
|
|
5514
|
+
return route.css.map((href2) => ({ rel: "stylesheet", href: href2 }));
|
|
5515
|
+
}
|
|
5516
|
+
async function prefetchRouteCss(route) {
|
|
5517
|
+
if (!route.css) return;
|
|
5518
|
+
let descriptors = getRouteCssDescriptors(route);
|
|
5519
|
+
await Promise.all(descriptors.map(prefetchStyleLink));
|
|
5520
|
+
}
|
|
5510
5521
|
async function prefetchStyleLinks(route, routeModule) {
|
|
5511
5522
|
if (!route.css && !routeModule.links || !isPreloadSupported()) return;
|
|
5512
5523
|
let descriptors = [];
|
|
5513
5524
|
if (route.css) {
|
|
5514
|
-
descriptors.push(...route
|
|
5525
|
+
descriptors.push(...getRouteCssDescriptors(route));
|
|
5515
5526
|
}
|
|
5516
5527
|
if (routeModule.links) {
|
|
5517
5528
|
descriptors.push(...routeModule.links());
|
|
@@ -5527,13 +5538,15 @@ async function prefetchStyleLinks(route, routeModule) {
|
|
|
5527
5538
|
});
|
|
5528
5539
|
}
|
|
5529
5540
|
}
|
|
5530
|
-
|
|
5531
|
-
(link) => (!link.media || window.matchMedia(link.media).matches) && !document.querySelector(`link[rel="stylesheet"][href="${link.href}"]`)
|
|
5532
|
-
);
|
|
5533
|
-
await Promise.all(matchingLinks.map(prefetchStyleLink));
|
|
5541
|
+
await Promise.all(styleLinks.map(prefetchStyleLink));
|
|
5534
5542
|
}
|
|
5535
5543
|
async function prefetchStyleLink(descriptor) {
|
|
5536
5544
|
return new Promise((resolve) => {
|
|
5545
|
+
if (descriptor.media && !window.matchMedia(descriptor.media).matches || document.querySelector(
|
|
5546
|
+
`link[rel="stylesheet"][href="${descriptor.href}"]`
|
|
5547
|
+
)) {
|
|
5548
|
+
return resolve();
|
|
5549
|
+
}
|
|
5537
5550
|
let link = document.createElement("link");
|
|
5538
5551
|
Object.assign(link, descriptor);
|
|
5539
5552
|
function removeLink() {
|
|
@@ -5628,25 +5641,21 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
5628
5641
|
}
|
|
5629
5642
|
return [];
|
|
5630
5643
|
}
|
|
5631
|
-
function getModuleLinkHrefs(matches,
|
|
5632
|
-
return dedupeHrefs(
|
|
5633
|
-
matches.map((match) => {
|
|
5634
|
-
let route = manifestPatch.routes[match.route.id];
|
|
5635
|
-
if (!route) return [];
|
|
5636
|
-
let hrefs = [route.module];
|
|
5637
|
-
if (route.imports) {
|
|
5638
|
-
hrefs = hrefs.concat(route.imports);
|
|
5639
|
-
}
|
|
5640
|
-
return hrefs;
|
|
5641
|
-
}).flat(1)
|
|
5642
|
-
);
|
|
5643
|
-
}
|
|
5644
|
-
function getCurrentPageModulePreloadHrefs(matches, manifest) {
|
|
5644
|
+
function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
|
|
5645
5645
|
return dedupeHrefs(
|
|
5646
5646
|
matches.map((match) => {
|
|
5647
5647
|
let route = manifest.routes[match.route.id];
|
|
5648
5648
|
if (!route) return [];
|
|
5649
5649
|
let hrefs = [route.module];
|
|
5650
|
+
if (route.clientActionModule) {
|
|
5651
|
+
hrefs = hrefs.concat(route.clientActionModule);
|
|
5652
|
+
}
|
|
5653
|
+
if (route.clientLoaderModule) {
|
|
5654
|
+
hrefs = hrefs.concat(route.clientLoaderModule);
|
|
5655
|
+
}
|
|
5656
|
+
if (includeHydrateFallback && route.hydrateFallbackModule) {
|
|
5657
|
+
hrefs = hrefs.concat(route.hydrateFallbackModule);
|
|
5658
|
+
}
|
|
5650
5659
|
if (route.imports) {
|
|
5651
5660
|
hrefs = hrefs.concat(route.imports);
|
|
5652
5661
|
}
|
|
@@ -5801,17 +5810,31 @@ function StreamTransfer({
|
|
|
5801
5810
|
)));
|
|
5802
5811
|
}
|
|
5803
5812
|
}
|
|
5804
|
-
function getSingleFetchDataStrategy(manifest, routeModules, getRouter) {
|
|
5813
|
+
function getSingleFetchDataStrategy(manifest, routeModules, ssr, getRouter) {
|
|
5805
5814
|
return async ({ request, matches, fetcherKey }) => {
|
|
5806
5815
|
if (request.method !== "GET") {
|
|
5807
5816
|
return singleFetchActionStrategy(request, matches);
|
|
5808
5817
|
}
|
|
5818
|
+
if (!ssr) {
|
|
5819
|
+
let foundLoaderBelowRoot = matches.some(
|
|
5820
|
+
(m) => m.route.id !== "root" && manifest.routes[m.route.id]?.hasLoader
|
|
5821
|
+
);
|
|
5822
|
+
if (!foundLoaderBelowRoot) {
|
|
5823
|
+
let matchesToLoad = matches.filter((m) => m.shouldLoad);
|
|
5824
|
+
let results = await Promise.all(matchesToLoad.map((m) => m.resolve()));
|
|
5825
|
+
return results.reduce(
|
|
5826
|
+
(acc, result, i) => Object.assign(acc, { [matchesToLoad[i].route.id]: result }),
|
|
5827
|
+
{}
|
|
5828
|
+
);
|
|
5829
|
+
}
|
|
5830
|
+
}
|
|
5809
5831
|
if (fetcherKey) {
|
|
5810
5832
|
return singleFetchLoaderFetcherStrategy(request, matches);
|
|
5811
5833
|
}
|
|
5812
5834
|
return singleFetchLoaderNavigationStrategy(
|
|
5813
5835
|
manifest,
|
|
5814
5836
|
routeModules,
|
|
5837
|
+
ssr,
|
|
5815
5838
|
getRouter(),
|
|
5816
5839
|
request,
|
|
5817
5840
|
matches
|
|
@@ -5845,7 +5868,7 @@ async function singleFetchActionStrategy(request, matches) {
|
|
|
5845
5868
|
}
|
|
5846
5869
|
};
|
|
5847
5870
|
}
|
|
5848
|
-
async function singleFetchLoaderNavigationStrategy(manifest, routeModules, router, request, matches) {
|
|
5871
|
+
async function singleFetchLoaderNavigationStrategy(manifest, routeModules, ssr, router, request, matches) {
|
|
5849
5872
|
let routesParams = /* @__PURE__ */ new Set();
|
|
5850
5873
|
let foundOptOutRoute = false;
|
|
5851
5874
|
let routeDfds = matches.map(() => createDeferred2());
|
|
@@ -5911,7 +5934,7 @@ async function singleFetchLoaderNavigationStrategy(manifest, routeModules, route
|
|
|
5911
5934
|
singleFetchDfd.resolve({});
|
|
5912
5935
|
} else {
|
|
5913
5936
|
try {
|
|
5914
|
-
if (foundOptOutRoute && routesParams.size > 0) {
|
|
5937
|
+
if (ssr && foundOptOutRoute && routesParams.size > 0) {
|
|
5915
5938
|
url.searchParams.set(
|
|
5916
5939
|
"_routes",
|
|
5917
5940
|
matches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
|
|
@@ -6279,11 +6302,12 @@ function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId
|
|
|
6279
6302
|
return dataRoute;
|
|
6280
6303
|
});
|
|
6281
6304
|
}
|
|
6282
|
-
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState,
|
|
6305
|
+
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, ssr, isSpaMode) {
|
|
6283
6306
|
return createClientRoutes(
|
|
6284
6307
|
manifest,
|
|
6285
6308
|
routeModulesCache,
|
|
6286
6309
|
initialState,
|
|
6310
|
+
ssr,
|
|
6287
6311
|
isSpaMode,
|
|
6288
6312
|
"",
|
|
6289
6313
|
groupRoutesByParentId(manifest),
|
|
@@ -6292,14 +6316,14 @@ function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest
|
|
|
6292
6316
|
}
|
|
6293
6317
|
function preventInvalidServerHandlerCall(type, route, isSpaMode) {
|
|
6294
6318
|
if (isSpaMode) {
|
|
6295
|
-
let
|
|
6296
|
-
let
|
|
6297
|
-
console.error(
|
|
6298
|
-
throw new ErrorResponseImpl(400, "Bad Request", new Error(
|
|
6319
|
+
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
6320
|
+
let msg = `You cannot call ${fn} in SPA Mode (routeId: "${route.id}")`;
|
|
6321
|
+
console.error(msg);
|
|
6322
|
+
throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
|
|
6299
6323
|
}
|
|
6300
|
-
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
6301
|
-
let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
|
|
6302
6324
|
if (type === "loader" && !route.hasLoader || type === "action" && !route.hasAction) {
|
|
6325
|
+
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
6326
|
+
let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
|
|
6303
6327
|
console.error(msg);
|
|
6304
6328
|
throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
|
|
6305
6329
|
}
|
|
@@ -6310,7 +6334,7 @@ function noActionDefinedError(type, routeId) {
|
|
|
6310
6334
|
console.error(msg);
|
|
6311
6335
|
throw new ErrorResponseImpl(405, "Method Not Allowed", new Error(msg), true);
|
|
6312
6336
|
}
|
|
6313
|
-
function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
|
|
6337
|
+
function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
|
|
6314
6338
|
return (routesByParentId[parentId] || []).map((route) => {
|
|
6315
6339
|
let routeModule = routeModulesCache[route.id];
|
|
6316
6340
|
function fetchServerHandler(singleFetch) {
|
|
@@ -6330,6 +6354,21 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6330
6354
|
}
|
|
6331
6355
|
return fetchServerHandler(singleFetch);
|
|
6332
6356
|
}
|
|
6357
|
+
function prefetchModule(modulePath) {
|
|
6358
|
+
import(
|
|
6359
|
+
/* @vite-ignore */
|
|
6360
|
+
/* webpackIgnore: true */
|
|
6361
|
+
modulePath
|
|
6362
|
+
);
|
|
6363
|
+
}
|
|
6364
|
+
function prefetchRouteModuleChunks(route2) {
|
|
6365
|
+
if (route2.clientActionModule) {
|
|
6366
|
+
prefetchModule(route2.clientActionModule);
|
|
6367
|
+
}
|
|
6368
|
+
if (route2.clientLoaderModule) {
|
|
6369
|
+
prefetchModule(route2.clientLoaderModule);
|
|
6370
|
+
}
|
|
6371
|
+
}
|
|
6333
6372
|
async function prefetchStylesAndCallHandler(handler) {
|
|
6334
6373
|
let cachedModule = routeModulesCache[route.id];
|
|
6335
6374
|
let linkPrefetchPromise = cachedModule ? prefetchStyleLinks(route, cachedModule) : Promise.resolve();
|
|
@@ -6351,7 +6390,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6351
6390
|
handle: routeModule.handle,
|
|
6352
6391
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
6353
6392
|
routeModule,
|
|
6354
|
-
route
|
|
6393
|
+
route,
|
|
6394
|
+
ssr,
|
|
6355
6395
|
needsRevalidation
|
|
6356
6396
|
)
|
|
6357
6397
|
});
|
|
@@ -6368,7 +6408,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6368
6408
|
"No `routeModule` available for critical-route loader"
|
|
6369
6409
|
);
|
|
6370
6410
|
if (!routeModule.clientLoader) {
|
|
6371
|
-
if (isSpaMode) return null;
|
|
6372
6411
|
return fetchServerLoader(singleFetch);
|
|
6373
6412
|
}
|
|
6374
6413
|
return routeModule.clientLoader({
|
|
@@ -6423,9 +6462,24 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6423
6462
|
} else {
|
|
6424
6463
|
if (!route.hasClientLoader) {
|
|
6425
6464
|
dataRoute.loader = ({ request }, singleFetch) => prefetchStylesAndCallHandler(() => {
|
|
6426
|
-
if (isSpaMode) return Promise.resolve(null);
|
|
6427
6465
|
return fetchServerLoader(singleFetch);
|
|
6428
6466
|
});
|
|
6467
|
+
} else if (route.clientLoaderModule) {
|
|
6468
|
+
dataRoute.loader = async (args, singleFetch) => {
|
|
6469
|
+
invariant2(route.clientLoaderModule);
|
|
6470
|
+
let { clientLoader } = await import(
|
|
6471
|
+
/* @vite-ignore */
|
|
6472
|
+
/* webpackIgnore: true */
|
|
6473
|
+
route.clientLoaderModule
|
|
6474
|
+
);
|
|
6475
|
+
return clientLoader({
|
|
6476
|
+
...args,
|
|
6477
|
+
async serverLoader() {
|
|
6478
|
+
preventInvalidServerHandlerCall("loader", route, isSpaMode);
|
|
6479
|
+
return fetchServerLoader(singleFetch);
|
|
6480
|
+
}
|
|
6481
|
+
});
|
|
6482
|
+
};
|
|
6429
6483
|
}
|
|
6430
6484
|
if (!route.hasClientAction) {
|
|
6431
6485
|
dataRoute.action = ({ request }, singleFetch) => prefetchStylesAndCallHandler(() => {
|
|
@@ -6434,12 +6488,34 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6434
6488
|
}
|
|
6435
6489
|
return fetchServerAction(singleFetch);
|
|
6436
6490
|
});
|
|
6491
|
+
} else if (route.clientActionModule) {
|
|
6492
|
+
dataRoute.action = async (args, singleFetch) => {
|
|
6493
|
+
invariant2(route.clientActionModule);
|
|
6494
|
+
prefetchRouteModuleChunks(route);
|
|
6495
|
+
let { clientAction } = await import(
|
|
6496
|
+
/* @vite-ignore */
|
|
6497
|
+
/* webpackIgnore: true */
|
|
6498
|
+
route.clientActionModule
|
|
6499
|
+
);
|
|
6500
|
+
return clientAction({
|
|
6501
|
+
...args,
|
|
6502
|
+
async serverAction() {
|
|
6503
|
+
preventInvalidServerHandlerCall("action", route, isSpaMode);
|
|
6504
|
+
return fetchServerAction(singleFetch);
|
|
6505
|
+
}
|
|
6506
|
+
});
|
|
6507
|
+
};
|
|
6437
6508
|
}
|
|
6438
6509
|
dataRoute.lazy = async () => {
|
|
6439
|
-
|
|
6510
|
+
if (route.clientLoaderModule || route.clientActionModule) {
|
|
6511
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
6512
|
+
}
|
|
6513
|
+
let modPromise = loadRouteModuleWithBlockingLinks(
|
|
6440
6514
|
route,
|
|
6441
6515
|
routeModulesCache
|
|
6442
6516
|
);
|
|
6517
|
+
prefetchRouteModuleChunks(route);
|
|
6518
|
+
let mod = await modPromise;
|
|
6443
6519
|
let lazyRoute = { ...mod };
|
|
6444
6520
|
if (mod.clientLoader) {
|
|
6445
6521
|
let clientLoader = mod.clientLoader;
|
|
@@ -6467,7 +6543,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6467
6543
|
hasErrorBoundary: lazyRoute.hasErrorBoundary,
|
|
6468
6544
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
6469
6545
|
lazyRoute,
|
|
6470
|
-
route
|
|
6546
|
+
route,
|
|
6547
|
+
ssr,
|
|
6471
6548
|
needsRevalidation
|
|
6472
6549
|
),
|
|
6473
6550
|
handle: lazyRoute.handle,
|
|
@@ -6482,6 +6559,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6482
6559
|
manifest,
|
|
6483
6560
|
routeModulesCache,
|
|
6484
6561
|
initialState,
|
|
6562
|
+
ssr,
|
|
6485
6563
|
isSpaMode,
|
|
6486
6564
|
route.id,
|
|
6487
6565
|
routesByParentId,
|
|
@@ -6491,15 +6569,18 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6491
6569
|
return dataRoute;
|
|
6492
6570
|
});
|
|
6493
6571
|
}
|
|
6494
|
-
function getShouldRevalidateFunction(route,
|
|
6572
|
+
function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidation) {
|
|
6495
6573
|
if (needsRevalidation) {
|
|
6496
6574
|
return wrapShouldRevalidateForHdr(
|
|
6497
|
-
|
|
6575
|
+
manifestRoute.id,
|
|
6498
6576
|
route.shouldRevalidate,
|
|
6499
6577
|
needsRevalidation
|
|
6500
6578
|
);
|
|
6501
6579
|
}
|
|
6502
|
-
if (
|
|
6580
|
+
if (!ssr && manifestRoute.id === "root" && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
|
|
6581
|
+
return () => false;
|
|
6582
|
+
}
|
|
6583
|
+
if (ssr && route.shouldRevalidate) {
|
|
6503
6584
|
let fn = route.shouldRevalidate;
|
|
6504
6585
|
return (opts) => fn({ ...opts, defaultShouldRevalidate: true });
|
|
6505
6586
|
}
|
|
@@ -6516,8 +6597,13 @@ function wrapShouldRevalidateForHdr(routeId, routeShouldRevalidate, needsRevalid
|
|
|
6516
6597
|
};
|
|
6517
6598
|
}
|
|
6518
6599
|
async function loadRouteModuleWithBlockingLinks(route, routeModules) {
|
|
6519
|
-
let
|
|
6520
|
-
|
|
6600
|
+
let routeModulePromise = loadRouteModule(route, routeModules);
|
|
6601
|
+
let prefetchRouteCssPromise = prefetchRouteCss(route);
|
|
6602
|
+
let routeModule = await routeModulePromise;
|
|
6603
|
+
await Promise.all([
|
|
6604
|
+
prefetchRouteCssPromise,
|
|
6605
|
+
prefetchStyleLinks(route, routeModule)
|
|
6606
|
+
]);
|
|
6521
6607
|
return {
|
|
6522
6608
|
Component: getRouteModuleComponent(routeModule),
|
|
6523
6609
|
ErrorBoundary: routeModule.ErrorBoundary,
|
|
@@ -6545,8 +6631,8 @@ var nextPaths = /* @__PURE__ */ new Set();
|
|
|
6545
6631
|
var discoveredPathsMaxSize = 1e3;
|
|
6546
6632
|
var discoveredPaths = /* @__PURE__ */ new Set();
|
|
6547
6633
|
var URL_LIMIT = 7680;
|
|
6548
|
-
function isFogOfWarEnabled(
|
|
6549
|
-
return
|
|
6634
|
+
function isFogOfWarEnabled(ssr) {
|
|
6635
|
+
return ssr === true;
|
|
6550
6636
|
}
|
|
6551
6637
|
function getPartialManifest(manifest, router) {
|
|
6552
6638
|
let routeIds = new Set(router.state.matches.map((m) => m.route.id));
|
|
@@ -6572,11 +6658,11 @@ function getPartialManifest(manifest, router) {
|
|
|
6572
6658
|
routes: initialRoutes
|
|
6573
6659
|
};
|
|
6574
6660
|
}
|
|
6575
|
-
function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, basename) {
|
|
6576
|
-
if (!isFogOfWarEnabled(
|
|
6661
|
+
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
|
|
6662
|
+
if (!isFogOfWarEnabled(ssr)) {
|
|
6577
6663
|
return void 0;
|
|
6578
6664
|
}
|
|
6579
|
-
return async ({ path, patch }) => {
|
|
6665
|
+
return async ({ path, patch, signal }) => {
|
|
6580
6666
|
if (discoveredPaths.has(path)) {
|
|
6581
6667
|
return;
|
|
6582
6668
|
}
|
|
@@ -6584,15 +6670,17 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, b
|
|
|
6584
6670
|
[path],
|
|
6585
6671
|
manifest,
|
|
6586
6672
|
routeModules,
|
|
6673
|
+
ssr,
|
|
6587
6674
|
isSpaMode,
|
|
6588
6675
|
basename,
|
|
6589
|
-
patch
|
|
6676
|
+
patch,
|
|
6677
|
+
signal
|
|
6590
6678
|
);
|
|
6591
6679
|
};
|
|
6592
6680
|
}
|
|
6593
|
-
function useFogOFWarDiscovery(router, manifest, routeModules, isSpaMode) {
|
|
6681
|
+
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
6594
6682
|
React8.useEffect(() => {
|
|
6595
|
-
if (!isFogOfWarEnabled(
|
|
6683
|
+
if (!isFogOfWarEnabled(ssr) || navigator.connection?.saveData === true) {
|
|
6596
6684
|
return;
|
|
6597
6685
|
}
|
|
6598
6686
|
function registerElement(el) {
|
|
@@ -6622,6 +6710,7 @@ function useFogOFWarDiscovery(router, manifest, routeModules, isSpaMode) {
|
|
|
6622
6710
|
lazyPaths,
|
|
6623
6711
|
manifest,
|
|
6624
6712
|
routeModules,
|
|
6713
|
+
ssr,
|
|
6625
6714
|
isSpaMode,
|
|
6626
6715
|
router.basename,
|
|
6627
6716
|
router.patchRoutes
|
|
@@ -6640,9 +6729,9 @@ function useFogOFWarDiscovery(router, manifest, routeModules, isSpaMode) {
|
|
|
6640
6729
|
attributeFilter: ["data-discover", "href", "action"]
|
|
6641
6730
|
});
|
|
6642
6731
|
return () => observer.disconnect();
|
|
6643
|
-
}, [isSpaMode, manifest, routeModules, router]);
|
|
6732
|
+
}, [ssr, isSpaMode, manifest, routeModules, router]);
|
|
6644
6733
|
}
|
|
6645
|
-
async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpaMode, basename, patchRoutes) {
|
|
6734
|
+
async function fetchAndApplyManifestPatches(paths, manifest, routeModules, ssr, isSpaMode, basename, patchRoutes, signal) {
|
|
6646
6735
|
let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
|
|
6647
6736
|
/\/+/g,
|
|
6648
6737
|
"/"
|
|
@@ -6654,13 +6743,19 @@ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpa
|
|
|
6654
6743
|
nextPaths.clear();
|
|
6655
6744
|
return;
|
|
6656
6745
|
}
|
|
6657
|
-
let
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6746
|
+
let serverPatches;
|
|
6747
|
+
try {
|
|
6748
|
+
let res = await fetch(url, { signal });
|
|
6749
|
+
if (!res.ok) {
|
|
6750
|
+
throw new Error(`${res.status} ${res.statusText}`);
|
|
6751
|
+
} else if (res.status >= 400) {
|
|
6752
|
+
throw new Error(await res.text());
|
|
6753
|
+
}
|
|
6754
|
+
serverPatches = await res.json();
|
|
6755
|
+
} catch (e) {
|
|
6756
|
+
if (signal?.aborted) return;
|
|
6757
|
+
throw e;
|
|
6662
6758
|
}
|
|
6663
|
-
let serverPatches = await res.json();
|
|
6664
6759
|
let knownRoutes = new Set(Object.keys(manifest.routes));
|
|
6665
6760
|
let patches = Object.values(serverPatches).reduce((acc, route) => {
|
|
6666
6761
|
if (route && !knownRoutes.has(route.id)) {
|
|
@@ -6679,7 +6774,7 @@ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpa
|
|
|
6679
6774
|
parentIds.forEach(
|
|
6680
6775
|
(parentId) => patchRoutes(
|
|
6681
6776
|
parentId || null,
|
|
6682
|
-
createClientRoutes(patches, routeModules, null, isSpaMode, parentId)
|
|
6777
|
+
createClientRoutes(patches, routeModules, null, ssr, isSpaMode, parentId)
|
|
6683
6778
|
)
|
|
6684
6779
|
);
|
|
6685
6780
|
}
|
|
@@ -6919,7 +7014,7 @@ function PrefetchPageLinksImpl({
|
|
|
6919
7014
|
[newMatchesForAssets, manifest]
|
|
6920
7015
|
);
|
|
6921
7016
|
let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
|
|
6922
|
-
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, dataHrefs.map((
|
|
7017
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, dataHrefs.map((href2) => /* @__PURE__ */ React9.createElement("link", { key: href2, rel: "prefetch", as: "fetch", href: href2, ...linkProps })), moduleHrefs.map((href2) => /* @__PURE__ */ React9.createElement("link", { key: href2, rel: "modulepreload", href: href2, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
|
|
6923
7018
|
// these don't spread `linkProps` because they are full link descriptors
|
|
6924
7019
|
// already with their own props
|
|
6925
7020
|
/* @__PURE__ */ React9.createElement("link", { key, ...link })
|
|
@@ -7028,10 +7123,10 @@ function isValidMetaTag(tagName) {
|
|
|
7028
7123
|
}
|
|
7029
7124
|
var isHydrated = false;
|
|
7030
7125
|
function Scripts(props) {
|
|
7031
|
-
let { manifest, serverHandoffString, isSpaMode, renderMeta } = useFrameworkContext();
|
|
7126
|
+
let { manifest, serverHandoffString, isSpaMode, ssr, renderMeta } = useFrameworkContext();
|
|
7032
7127
|
let { router, static: isStatic, staticContext } = useDataRouterContext2();
|
|
7033
7128
|
let { matches: routerMatches } = useDataRouterStateContext();
|
|
7034
|
-
let enableFogOfWar = isFogOfWarEnabled(
|
|
7129
|
+
let enableFogOfWar = isFogOfWarEnabled(ssr);
|
|
7035
7130
|
if (renderMeta) {
|
|
7036
7131
|
renderMeta.didRenderScripts = true;
|
|
7037
7132
|
}
|
|
@@ -7043,11 +7138,44 @@ function Scripts(props) {
|
|
|
7043
7138
|
let streamScript = "window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());";
|
|
7044
7139
|
let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};${streamScript}` : " ";
|
|
7045
7140
|
let routeModulesScript = !isStatic ? " " : `${manifest.hmr?.runtime ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
|
|
7046
|
-
${matches.map(
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
)
|
|
7050
|
-
|
|
7141
|
+
${matches.map((match, routeIndex) => {
|
|
7142
|
+
let routeVarName = `route${routeIndex}`;
|
|
7143
|
+
let manifestEntry = manifest.routes[match.route.id];
|
|
7144
|
+
invariant2(manifestEntry, `Route ${match.route.id} not found in manifest`);
|
|
7145
|
+
let {
|
|
7146
|
+
clientActionModule,
|
|
7147
|
+
clientLoaderModule,
|
|
7148
|
+
hydrateFallbackModule,
|
|
7149
|
+
module: module2
|
|
7150
|
+
} = manifestEntry;
|
|
7151
|
+
let chunks = [
|
|
7152
|
+
...clientActionModule ? [
|
|
7153
|
+
{
|
|
7154
|
+
module: clientActionModule,
|
|
7155
|
+
varName: `${routeVarName}_clientAction`
|
|
7156
|
+
}
|
|
7157
|
+
] : [],
|
|
7158
|
+
...clientLoaderModule ? [
|
|
7159
|
+
{
|
|
7160
|
+
module: clientLoaderModule,
|
|
7161
|
+
varName: `${routeVarName}_clientLoader`
|
|
7162
|
+
}
|
|
7163
|
+
] : [],
|
|
7164
|
+
...hydrateFallbackModule ? [
|
|
7165
|
+
{
|
|
7166
|
+
module: hydrateFallbackModule,
|
|
7167
|
+
varName: `${routeVarName}_HydrateFallback`
|
|
7168
|
+
}
|
|
7169
|
+
] : [],
|
|
7170
|
+
{ module: module2, varName: `${routeVarName}_main` }
|
|
7171
|
+
];
|
|
7172
|
+
if (chunks.length === 1) {
|
|
7173
|
+
return `import * as ${routeVarName} from ${JSON.stringify(module2)};`;
|
|
7174
|
+
}
|
|
7175
|
+
let chunkImportsSnippet = chunks.map((chunk) => `import * as ${chunk.varName} from "${chunk.module}";`).join("\n");
|
|
7176
|
+
let mergedChunksSnippet = `const ${routeVarName} = {${chunks.map((chunk) => `...${chunk.varName}`).join(",")}};`;
|
|
7177
|
+
return [chunkImportsSnippet, mergedChunksSnippet].join("\n");
|
|
7178
|
+
}).join("\n")}
|
|
7051
7179
|
${enableFogOfWar ? (
|
|
7052
7180
|
// Inline a minimal manifest with the SSR matches
|
|
7053
7181
|
`window.__reactRouterManifest = ${JSON.stringify(
|
|
@@ -7078,11 +7206,11 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
7078
7206
|
}
|
|
7079
7207
|
));
|
|
7080
7208
|
}, []);
|
|
7081
|
-
let
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7209
|
+
let preloads = isHydrated ? [] : manifest.entry.imports.concat(
|
|
7210
|
+
getModuleLinkHrefs(matches, manifest, {
|
|
7211
|
+
includeHydrateFallback: true
|
|
7212
|
+
})
|
|
7213
|
+
);
|
|
7086
7214
|
return isHydrated ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, !enableFogOfWar ? /* @__PURE__ */ React9.createElement(
|
|
7087
7215
|
"link",
|
|
7088
7216
|
{
|
|
@@ -7126,7 +7254,7 @@ function mergeRefs(...refs) {
|
|
|
7126
7254
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
7127
7255
|
try {
|
|
7128
7256
|
if (isBrowser) {
|
|
7129
|
-
window.__reactRouterVersion = "7.1
|
|
7257
|
+
window.__reactRouterVersion = "7.2.0-pre.1";
|
|
7130
7258
|
}
|
|
7131
7259
|
} catch (e) {
|
|
7132
7260
|
}
|
|
@@ -7329,7 +7457,7 @@ var Link = React10.forwardRef(
|
|
|
7329
7457
|
}
|
|
7330
7458
|
}
|
|
7331
7459
|
}
|
|
7332
|
-
let
|
|
7460
|
+
let href2 = useHref(to, { relative });
|
|
7333
7461
|
let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(
|
|
7334
7462
|
prefetch,
|
|
7335
7463
|
rest
|
|
@@ -7355,7 +7483,7 @@ var Link = React10.forwardRef(
|
|
|
7355
7483
|
{
|
|
7356
7484
|
...rest,
|
|
7357
7485
|
...prefetchHandlers,
|
|
7358
|
-
href: absoluteHref ||
|
|
7486
|
+
href: absoluteHref || href2,
|
|
7359
7487
|
onClick: isExternal || reloadDocument ? onClick : handleClick,
|
|
7360
7488
|
ref: mergeRefs(forwardedRef, prefetchRef),
|
|
7361
7489
|
target,
|
|
@@ -7363,7 +7491,7 @@ var Link = React10.forwardRef(
|
|
|
7363
7491
|
}
|
|
7364
7492
|
)
|
|
7365
7493
|
);
|
|
7366
|
-
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React10.createElement(React10.Fragment, null, link, /* @__PURE__ */ React10.createElement(PrefetchPageLinks, { page:
|
|
7494
|
+
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React10.createElement(React10.Fragment, null, link, /* @__PURE__ */ React10.createElement(PrefetchPageLinks, { page: href2 })) : link;
|
|
7367
7495
|
}
|
|
7368
7496
|
);
|
|
7369
7497
|
Link.displayName = "Link";
|
|
@@ -7719,9 +7847,9 @@ function useFetcher({
|
|
|
7719
7847
|
return () => router.deleteFetcher(fetcherKey);
|
|
7720
7848
|
}, [router, fetcherKey]);
|
|
7721
7849
|
let load = React10.useCallback(
|
|
7722
|
-
async (
|
|
7850
|
+
async (href2, opts) => {
|
|
7723
7851
|
invariant(routeId, "No routeId available for fetcher.load()");
|
|
7724
|
-
await router.fetch(fetcherKey, routeId,
|
|
7852
|
+
await router.fetch(fetcherKey, routeId, href2, opts);
|
|
7725
7853
|
},
|
|
7726
7854
|
[fetcherKey, routeId, router]
|
|
7727
7855
|
);
|
|
@@ -8178,9 +8306,9 @@ function createHref(to) {
|
|
|
8178
8306
|
return typeof to === "string" ? to : createPath(to);
|
|
8179
8307
|
}
|
|
8180
8308
|
function encodeLocation(to) {
|
|
8181
|
-
let
|
|
8182
|
-
|
|
8183
|
-
let encoded = ABSOLUTE_URL_REGEX3.test(
|
|
8309
|
+
let href2 = typeof to === "string" ? to : createPath(to);
|
|
8310
|
+
href2 = href2.replace(/ $/, "%20");
|
|
8311
|
+
let encoded = ABSOLUTE_URL_REGEX3.test(href2) ? new URL(href2) : new URL(href2, "http://localhost");
|
|
8184
8312
|
return {
|
|
8185
8313
|
pathname: encoded.pathname,
|
|
8186
8314
|
search: encoded.search,
|
|
@@ -8238,6 +8366,7 @@ function ServerRouter({
|
|
|
8238
8366
|
criticalCss,
|
|
8239
8367
|
serverHandoffString,
|
|
8240
8368
|
future: context.future,
|
|
8369
|
+
ssr: context.ssr,
|
|
8241
8370
|
isSpaMode: context.isSpaMode,
|
|
8242
8371
|
serializeError: context.serializeError,
|
|
8243
8372
|
renderMeta: context.renderMeta
|
|
@@ -8284,6 +8413,7 @@ function createRoutesStub(routes, context = {}) {
|
|
|
8284
8413
|
version: ""
|
|
8285
8414
|
},
|
|
8286
8415
|
routeModules: {},
|
|
8416
|
+
ssr: false,
|
|
8287
8417
|
isSpaMode: false
|
|
8288
8418
|
};
|
|
8289
8419
|
let patched = processRoutes(
|
|
@@ -8335,8 +8465,11 @@ function processRoutes(routes, context, manifest, routeModules, parentId) {
|
|
|
8335
8465
|
hasClientAction: false,
|
|
8336
8466
|
hasClientLoader: false,
|
|
8337
8467
|
hasErrorBoundary: route.ErrorBoundary != null,
|
|
8338
|
-
|
|
8339
|
-
|
|
8468
|
+
// any need for these?
|
|
8469
|
+
module: "build/stub-path-to-module.js",
|
|
8470
|
+
clientActionModule: void 0,
|
|
8471
|
+
clientLoaderModule: void 0,
|
|
8472
|
+
hydrateFallbackModule: void 0
|
|
8340
8473
|
};
|
|
8341
8474
|
manifest.routes[newRoute.id] = entryRoute;
|
|
8342
8475
|
routeModules[route.id] = {
|
|
@@ -9126,6 +9259,10 @@ var createRequestHandler = (build, mode) => {
|
|
|
9126
9259
|
errorHandler = derived.errorHandler;
|
|
9127
9260
|
}
|
|
9128
9261
|
let url = new URL(request.url);
|
|
9262
|
+
let normalizedPath = url.pathname.replace(/\.data$/, "").replace(/^\/_root$/, "/");
|
|
9263
|
+
if (normalizedPath !== "/" && normalizedPath.endsWith("/")) {
|
|
9264
|
+
normalizedPath = normalizedPath.slice(0, -1);
|
|
9265
|
+
}
|
|
9129
9266
|
let params = {};
|
|
9130
9267
|
let handleError = (error) => {
|
|
9131
9268
|
if (mode === "development" /* Development */) {
|
|
@@ -9137,6 +9274,32 @@ var createRequestHandler = (build, mode) => {
|
|
|
9137
9274
|
request
|
|
9138
9275
|
});
|
|
9139
9276
|
};
|
|
9277
|
+
if (!_build.ssr) {
|
|
9278
|
+
if (_build.prerender.length === 0) {
|
|
9279
|
+
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
9280
|
+
} else if (!_build.prerender.includes(normalizedPath) && !_build.prerender.includes(normalizedPath + "/")) {
|
|
9281
|
+
if (url.pathname.endsWith(".data")) {
|
|
9282
|
+
errorHandler(
|
|
9283
|
+
new ErrorResponseImpl(
|
|
9284
|
+
404,
|
|
9285
|
+
"Not Found",
|
|
9286
|
+
`Refusing to SSR the path \`${normalizedPath}\` because \`ssr:false\` is set and the path is not included in the \`prerender\` config, so in production the path will be a 404.`
|
|
9287
|
+
),
|
|
9288
|
+
{
|
|
9289
|
+
context: loadContext,
|
|
9290
|
+
params,
|
|
9291
|
+
request
|
|
9292
|
+
}
|
|
9293
|
+
);
|
|
9294
|
+
return new Response("Not Found", {
|
|
9295
|
+
status: 404,
|
|
9296
|
+
statusText: "Not Found"
|
|
9297
|
+
});
|
|
9298
|
+
} else {
|
|
9299
|
+
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
9300
|
+
}
|
|
9301
|
+
}
|
|
9302
|
+
}
|
|
9140
9303
|
let manifestUrl = `${_build.basename ?? "/"}/__manifest`.replace(
|
|
9141
9304
|
/\/+/g,
|
|
9142
9305
|
"/"
|
|
@@ -9157,7 +9320,7 @@ var createRequestHandler = (build, mode) => {
|
|
|
9157
9320
|
let response;
|
|
9158
9321
|
if (url.pathname.endsWith(".data")) {
|
|
9159
9322
|
let handlerUrl = new URL(request.url);
|
|
9160
|
-
handlerUrl.pathname =
|
|
9323
|
+
handlerUrl.pathname = normalizedPath;
|
|
9161
9324
|
let singleFetchMatches = matchServerRoutes(
|
|
9162
9325
|
routes,
|
|
9163
9326
|
handlerUrl.pathname,
|
|
@@ -9297,6 +9460,7 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
|
|
|
9297
9460
|
);
|
|
9298
9461
|
}
|
|
9299
9462
|
async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, criticalCss) {
|
|
9463
|
+
let isSpaMode = request.headers.has("X-React-Router-SPA-Mode");
|
|
9300
9464
|
let context;
|
|
9301
9465
|
try {
|
|
9302
9466
|
context = await staticHandler.query(request, {
|
|
@@ -9335,7 +9499,8 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
9335
9499
|
basename: build.basename,
|
|
9336
9500
|
criticalCss,
|
|
9337
9501
|
future: build.future,
|
|
9338
|
-
|
|
9502
|
+
ssr: build.ssr,
|
|
9503
|
+
isSpaMode
|
|
9339
9504
|
}),
|
|
9340
9505
|
serverHandoffStream: encodeViaTurboStream(
|
|
9341
9506
|
state,
|
|
@@ -9345,7 +9510,8 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
9345
9510
|
),
|
|
9346
9511
|
renderMeta: {},
|
|
9347
9512
|
future: build.future,
|
|
9348
|
-
|
|
9513
|
+
ssr: build.ssr,
|
|
9514
|
+
isSpaMode,
|
|
9349
9515
|
serializeError: (err) => serializeError(err, serverMode)
|
|
9350
9516
|
};
|
|
9351
9517
|
let handleDocumentRequestFunction = build.entry.module.default;
|
|
@@ -9390,7 +9556,8 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
9390
9556
|
serverHandoffString: createServerHandoffString({
|
|
9391
9557
|
basename: build.basename,
|
|
9392
9558
|
future: build.future,
|
|
9393
|
-
|
|
9559
|
+
ssr: build.ssr,
|
|
9560
|
+
isSpaMode
|
|
9394
9561
|
}),
|
|
9395
9562
|
serverHandoffStream: encodeViaTurboStream(
|
|
9396
9563
|
state2,
|
|
@@ -9617,6 +9784,24 @@ function createMemorySessionStorage({ cookie } = {}) {
|
|
|
9617
9784
|
});
|
|
9618
9785
|
}
|
|
9619
9786
|
|
|
9787
|
+
// lib/href.ts
|
|
9788
|
+
function href(path, ...args) {
|
|
9789
|
+
let params = args[0];
|
|
9790
|
+
return path.split("/").map((segment) => {
|
|
9791
|
+
const match = segment.match(/^:([\w-]+)(\?)?/);
|
|
9792
|
+
if (!match) return segment;
|
|
9793
|
+
const param = match[1];
|
|
9794
|
+
const value = params ? params[param] : void 0;
|
|
9795
|
+
const isRequired = match[2] === void 0;
|
|
9796
|
+
if (isRequired && value === void 0) {
|
|
9797
|
+
throw Error(
|
|
9798
|
+
`Path '${path}' requires param '${param}' but it was not provided`
|
|
9799
|
+
);
|
|
9800
|
+
}
|
|
9801
|
+
return value;
|
|
9802
|
+
}).filter((segment) => segment !== void 0).join("/");
|
|
9803
|
+
}
|
|
9804
|
+
|
|
9620
9805
|
// lib/dom/ssr/errors.ts
|
|
9621
9806
|
function deserializeErrors2(errors) {
|
|
9622
9807
|
if (!errors) return null;
|
|
@@ -9723,6 +9908,7 @@ function deserializeErrors2(errors) {
|
|
|
9723
9908
|
createStaticRouter,
|
|
9724
9909
|
data,
|
|
9725
9910
|
generatePath,
|
|
9911
|
+
href,
|
|
9726
9912
|
isCookie,
|
|
9727
9913
|
isRouteErrorResponse,
|
|
9728
9914
|
isSession,
|