react-router 0.0.0-experimental-818f8e08d → 0.0.0-experimental-e56aa53bc
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 +0 -19
- package/dist/development/{chunk-4O47XL4L.mjs → chunk-RMWJZNG5.mjs} +1045 -354
- 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 +2 -2
- package/dist/development/dom-export.d.ts +2 -1
- package/dist/development/dom-export.js +6130 -35
- package/dist/development/dom-export.mjs +3 -6
- package/dist/development/fog-of-war-C5L_Yd5M.d.mts +1778 -0
- package/dist/{production/fog-of-war-B1MWugqW.d.mts → development/fog-of-war-DrUCUQQ-.d.ts} +170 -138
- package/dist/development/index.d.mts +68 -10
- package/dist/development/index.d.ts +207 -1889
- package/dist/development/index.js +1052 -352
- package/dist/development/index.mjs +19 -2
- package/dist/development/lib/types/route-module.d.mts +2 -1
- package/dist/development/lib/types/route-module.d.ts +2 -1
- 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-BvrN3Sw4.d.mts → development/route-data-BIYebJr3.d.mts} +12 -12
- package/dist/{production/route-data-fNWkI-4T.d.ts → development/route-data-BIYebJr3.d.ts} +12 -12
- package/dist/development/rsc-export.d.mts +1788 -0
- package/dist/development/rsc-export.d.ts +1788 -0
- package/dist/development/rsc-export.js +2778 -0
- package/dist/development/rsc-export.mjs +2743 -0
- package/dist/production/{chunk-P2C2EGLF.mjs → chunk-BXBFRMFA.mjs} +1045 -354
- 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 +2 -2
- package/dist/production/dom-export.d.ts +2 -1
- package/dist/production/dom-export.js +6130 -35
- package/dist/production/dom-export.mjs +3 -6
- package/dist/production/fog-of-war-C5L_Yd5M.d.mts +1778 -0
- package/dist/{development/fog-of-war-B1MWugqW.d.mts → production/fog-of-war-DrUCUQQ-.d.ts} +170 -138
- package/dist/production/index.d.mts +68 -10
- package/dist/production/index.d.ts +207 -1889
- package/dist/production/index.js +1052 -352
- package/dist/production/index.mjs +19 -2
- package/dist/production/lib/types/route-module.d.mts +2 -1
- package/dist/production/lib/types/route-module.d.ts +2 -1
- 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-BvrN3Sw4.d.mts → production/route-data-BIYebJr3.d.mts} +12 -12
- package/dist/{development/route-data-fNWkI-4T.d.ts → production/route-data-BIYebJr3.d.ts} +12 -12
- package/dist/production/rsc-export.d.mts +1788 -0
- package/dist/production/rsc-export.d.ts +1788 -0
- package/dist/production/rsc-export.js +2778 -0
- package/dist/production/rsc-export.mjs +2743 -0
- package/package.json +33 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-e56aa53bc
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
"use strict";
|
|
12
|
+
"use client";
|
|
12
13
|
var __create = Object.create;
|
|
13
14
|
var __defProp = Object.defineProperty;
|
|
14
15
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -62,6 +63,8 @@ __export(react_router_exports, {
|
|
|
62
63
|
NavigationType: () => Action,
|
|
63
64
|
Outlet: () => Outlet,
|
|
64
65
|
PrefetchPageLinks: () => PrefetchPageLinks,
|
|
66
|
+
RSCHydratedRouter: () => RSCHydratedRouter,
|
|
67
|
+
RSCStaticRouter: () => RSCStaticRouter,
|
|
65
68
|
Route: () => Route,
|
|
66
69
|
Router: () => Router,
|
|
67
70
|
RouterProvider: () => RouterProvider,
|
|
@@ -83,6 +86,9 @@ __export(react_router_exports, {
|
|
|
83
86
|
UNSAFE_ServerMode: () => ServerMode,
|
|
84
87
|
UNSAFE_SingleFetchRedirectSymbol: () => SingleFetchRedirectSymbol,
|
|
85
88
|
UNSAFE_ViewTransitionContext: () => ViewTransitionContext,
|
|
89
|
+
UNSAFE_WithErrorBoundaryProps: () => WithErrorBoundaryProps,
|
|
90
|
+
UNSAFE_WithHydrateFallbackProps: () => WithHydrateFallbackProps,
|
|
91
|
+
UNSAFE_WithRouteComponentProps: () => WithRouteComponentProps,
|
|
86
92
|
UNSAFE_createBrowserHistory: () => createBrowserHistory,
|
|
87
93
|
UNSAFE_createClientRoutes: () => createClientRoutes,
|
|
88
94
|
UNSAFE_createClientRoutesWithHMRRevalidationOptOut: () => createClientRoutesWithHMRRevalidationOptOut,
|
|
@@ -99,6 +105,7 @@ __export(react_router_exports, {
|
|
|
99
105
|
UNSAFE_useFogOFWarDiscovery: () => useFogOFWarDiscovery,
|
|
100
106
|
UNSAFE_useScrollRestoration: () => useScrollRestoration,
|
|
101
107
|
createBrowserRouter: () => createBrowserRouter,
|
|
108
|
+
createCallServer: () => createCallServer,
|
|
102
109
|
createCookie: () => createCookie,
|
|
103
110
|
createCookieSessionStorage: () => createCookieSessionStorage,
|
|
104
111
|
createHashRouter: () => createHashRouter,
|
|
@@ -116,6 +123,7 @@ __export(react_router_exports, {
|
|
|
116
123
|
createStaticRouter: () => createStaticRouter,
|
|
117
124
|
data: () => data,
|
|
118
125
|
generatePath: () => generatePath,
|
|
126
|
+
getServerStream: () => getServerStream,
|
|
119
127
|
href: () => href,
|
|
120
128
|
isCookie: () => isCookie,
|
|
121
129
|
isRouteErrorResponse: () => isRouteErrorResponse,
|
|
@@ -128,6 +136,7 @@ __export(react_router_exports, {
|
|
|
128
136
|
renderMatches: () => renderMatches,
|
|
129
137
|
replace: () => replace,
|
|
130
138
|
resolvePath: () => resolvePath,
|
|
139
|
+
routeRSCServerRequest: () => routeRSCServerRequest,
|
|
131
140
|
unstable_HistoryRouter: () => HistoryRouter,
|
|
132
141
|
unstable_RouterContextProvider: () => unstable_RouterContextProvider,
|
|
133
142
|
unstable_createContext: () => unstable_createContext,
|
|
@@ -195,19 +204,19 @@ function createMemoryHistory(options = {}) {
|
|
|
195
204
|
return entries[index];
|
|
196
205
|
}
|
|
197
206
|
function createMemoryLocation(to, state = null, key) {
|
|
198
|
-
let
|
|
207
|
+
let location2 = createLocation(
|
|
199
208
|
entries ? getCurrentLocation().pathname : "/",
|
|
200
209
|
to,
|
|
201
210
|
state,
|
|
202
211
|
key
|
|
203
212
|
);
|
|
204
213
|
warning(
|
|
205
|
-
|
|
214
|
+
location2.pathname.charAt(0) === "/",
|
|
206
215
|
`relative pathnames are not supported in memory history: ${JSON.stringify(
|
|
207
216
|
to
|
|
208
217
|
)}`
|
|
209
218
|
);
|
|
210
|
-
return
|
|
219
|
+
return location2;
|
|
211
220
|
}
|
|
212
221
|
function createHref2(to) {
|
|
213
222
|
return typeof to === "string" ? to : createPath(to);
|
|
@@ -318,9 +327,9 @@ function createHashHistory(options = {}) {
|
|
|
318
327
|
}
|
|
319
328
|
return href2 + "#" + (typeof to === "string" ? to : createPath(to));
|
|
320
329
|
}
|
|
321
|
-
function validateHashLocation(
|
|
330
|
+
function validateHashLocation(location2, to) {
|
|
322
331
|
warning(
|
|
323
|
-
|
|
332
|
+
location2.pathname.charAt(0) === "/",
|
|
324
333
|
`relative pathnames are not supported in hash history.push(${JSON.stringify(
|
|
325
334
|
to
|
|
326
335
|
)})`
|
|
@@ -350,15 +359,15 @@ function warning(cond, message) {
|
|
|
350
359
|
function createKey() {
|
|
351
360
|
return Math.random().toString(36).substring(2, 10);
|
|
352
361
|
}
|
|
353
|
-
function getHistoryState(
|
|
362
|
+
function getHistoryState(location2, index) {
|
|
354
363
|
return {
|
|
355
|
-
usr:
|
|
356
|
-
key:
|
|
364
|
+
usr: location2.state,
|
|
365
|
+
key: location2.key,
|
|
357
366
|
idx: index
|
|
358
367
|
};
|
|
359
368
|
}
|
|
360
369
|
function createLocation(current, to, state = null, key) {
|
|
361
|
-
let
|
|
370
|
+
let location2 = {
|
|
362
371
|
pathname: typeof current === "string" ? current : current.pathname,
|
|
363
372
|
search: "",
|
|
364
373
|
hash: "",
|
|
@@ -370,7 +379,7 @@ function createLocation(current, to, state = null, key) {
|
|
|
370
379
|
// keep as is for the time being and just let any incoming keys take precedence
|
|
371
380
|
key: to && to.key || key || createKey()
|
|
372
381
|
};
|
|
373
|
-
return
|
|
382
|
+
return location2;
|
|
374
383
|
}
|
|
375
384
|
function createPath({
|
|
376
385
|
pathname = "/",
|
|
@@ -427,11 +436,11 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
427
436
|
}
|
|
428
437
|
function push(to, state) {
|
|
429
438
|
action = "PUSH" /* Push */;
|
|
430
|
-
let
|
|
431
|
-
if (validateLocation) validateLocation(
|
|
439
|
+
let location2 = createLocation(history.location, to, state);
|
|
440
|
+
if (validateLocation) validateLocation(location2, to);
|
|
432
441
|
index = getIndex() + 1;
|
|
433
|
-
let historyState = getHistoryState(
|
|
434
|
-
let url = history.createHref(
|
|
442
|
+
let historyState = getHistoryState(location2, index);
|
|
443
|
+
let url = history.createHref(location2);
|
|
435
444
|
try {
|
|
436
445
|
globalHistory.pushState(historyState, "", url);
|
|
437
446
|
} catch (error) {
|
|
@@ -446,11 +455,11 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
446
455
|
}
|
|
447
456
|
function replace2(to, state) {
|
|
448
457
|
action = "REPLACE" /* Replace */;
|
|
449
|
-
let
|
|
450
|
-
if (validateLocation) validateLocation(
|
|
458
|
+
let location2 = createLocation(history.location, to, state);
|
|
459
|
+
if (validateLocation) validateLocation(location2, to);
|
|
451
460
|
index = getIndex();
|
|
452
|
-
let historyState = getHistoryState(
|
|
453
|
-
let url = history.createHref(
|
|
461
|
+
let historyState = getHistoryState(location2, index);
|
|
462
|
+
let url = history.createHref(location2);
|
|
454
463
|
globalHistory.replaceState(historyState, "", url);
|
|
455
464
|
if (v5Compat && listener) {
|
|
456
465
|
listener({ action, location: history.location, delta: 0 });
|
|
@@ -563,7 +572,7 @@ function isUnsupportedLazyRouteFunctionKey(key) {
|
|
|
563
572
|
function isIndexRoute(route) {
|
|
564
573
|
return route.index === true;
|
|
565
574
|
}
|
|
566
|
-
function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}) {
|
|
575
|
+
function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}, allowInPlaceMutations = false) {
|
|
567
576
|
return routes.map((route, index) => {
|
|
568
577
|
let treePath = [...parentPath, String(index)];
|
|
569
578
|
let id = typeof route.id === "string" ? route.id : treePath.join("-");
|
|
@@ -572,7 +581,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
572
581
|
`Cannot specify children on an index route`
|
|
573
582
|
);
|
|
574
583
|
invariant(
|
|
575
|
-
!manifest[id],
|
|
584
|
+
allowInPlaceMutations || !manifest[id],
|
|
576
585
|
`Found a route id collision on id "${id}". Route id's must be globally unique within Data Router usages`
|
|
577
586
|
);
|
|
578
587
|
if (isIndexRoute(route)) {
|
|
@@ -596,7 +605,8 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
596
605
|
route.children,
|
|
597
606
|
mapRouteProperties2,
|
|
598
607
|
treePath,
|
|
599
|
-
manifest
|
|
608
|
+
manifest,
|
|
609
|
+
allowInPlaceMutations
|
|
600
610
|
);
|
|
601
611
|
}
|
|
602
612
|
return pathOrLayoutRoute;
|
|
@@ -607,8 +617,8 @@ function matchRoutes(routes, locationArg, basename = "/") {
|
|
|
607
617
|
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
608
618
|
}
|
|
609
619
|
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
610
|
-
let
|
|
611
|
-
let pathname = stripBasename(
|
|
620
|
+
let location2 = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
621
|
+
let pathname = stripBasename(location2.pathname || "/", basename);
|
|
612
622
|
if (pathname == null) {
|
|
613
623
|
return null;
|
|
614
624
|
}
|
|
@@ -1212,7 +1222,7 @@ function createRouter(init) {
|
|
|
1212
1222
|
let pendingRevalidationDfd = null;
|
|
1213
1223
|
function initialize() {
|
|
1214
1224
|
unlistenHistory = init.history.listen(
|
|
1215
|
-
({ action: historyAction, location, delta }) => {
|
|
1225
|
+
({ action: historyAction, location: location2, delta }) => {
|
|
1216
1226
|
if (unblockBlockerHistoryUpdate) {
|
|
1217
1227
|
unblockBlockerHistoryUpdate();
|
|
1218
1228
|
unblockBlockerHistoryUpdate = void 0;
|
|
@@ -1224,7 +1234,7 @@ function createRouter(init) {
|
|
|
1224
1234
|
);
|
|
1225
1235
|
let blockerKey = shouldBlockNavigation({
|
|
1226
1236
|
currentLocation: state.location,
|
|
1227
|
-
nextLocation:
|
|
1237
|
+
nextLocation: location2,
|
|
1228
1238
|
historyAction
|
|
1229
1239
|
});
|
|
1230
1240
|
if (blockerKey && delta != null) {
|
|
@@ -1234,13 +1244,13 @@ function createRouter(init) {
|
|
|
1234
1244
|
init.history.go(delta * -1);
|
|
1235
1245
|
updateBlocker(blockerKey, {
|
|
1236
1246
|
state: "blocked",
|
|
1237
|
-
location,
|
|
1247
|
+
location: location2,
|
|
1238
1248
|
proceed() {
|
|
1239
1249
|
updateBlocker(blockerKey, {
|
|
1240
1250
|
state: "proceeding",
|
|
1241
1251
|
proceed: void 0,
|
|
1242
1252
|
reset: void 0,
|
|
1243
|
-
location
|
|
1253
|
+
location: location2
|
|
1244
1254
|
});
|
|
1245
1255
|
nextHistoryUpdatePromise.then(() => init.history.go(delta));
|
|
1246
1256
|
},
|
|
@@ -1252,7 +1262,7 @@ function createRouter(init) {
|
|
|
1252
1262
|
});
|
|
1253
1263
|
return;
|
|
1254
1264
|
}
|
|
1255
|
-
return startNavigation(historyAction,
|
|
1265
|
+
return startNavigation(historyAction, location2);
|
|
1256
1266
|
}
|
|
1257
1267
|
);
|
|
1258
1268
|
if (isBrowser2) {
|
|
@@ -1285,6 +1295,19 @@ function createRouter(init) {
|
|
|
1285
1295
|
return () => subscribers.delete(fn);
|
|
1286
1296
|
}
|
|
1287
1297
|
function updateState(newState, opts = {}) {
|
|
1298
|
+
if (newState.matches) {
|
|
1299
|
+
newState.matches = newState.matches.map((m) => {
|
|
1300
|
+
let route = manifest[m.route.id];
|
|
1301
|
+
let matchRoute = m.route;
|
|
1302
|
+
if (matchRoute.element !== route.element || matchRoute.errorElement !== route.errorElement || matchRoute.hydrateFallbackElement !== route.hydrateFallbackElement) {
|
|
1303
|
+
return {
|
|
1304
|
+
...m,
|
|
1305
|
+
route
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
return m;
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1288
1311
|
state = {
|
|
1289
1312
|
...state,
|
|
1290
1313
|
...newState
|
|
@@ -1315,8 +1338,8 @@ function createRouter(init) {
|
|
|
1315
1338
|
unmountedFetchers.forEach((key) => deleteFetcher(key));
|
|
1316
1339
|
mountedFetchers.forEach((key) => state.fetchers.delete(key));
|
|
1317
1340
|
}
|
|
1318
|
-
function completeNavigation(
|
|
1319
|
-
let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" &&
|
|
1341
|
+
function completeNavigation(location2, newState, { flushSync } = {}) {
|
|
1342
|
+
let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && location2.state?._isRedirect !== true;
|
|
1320
1343
|
let actionData;
|
|
1321
1344
|
if (newState.actionData) {
|
|
1322
1345
|
if (Object.keys(newState.actionData).length > 0) {
|
|
@@ -1340,7 +1363,7 @@ function createRouter(init) {
|
|
|
1340
1363
|
blockers = new Map(blockers);
|
|
1341
1364
|
blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));
|
|
1342
1365
|
}
|
|
1343
|
-
let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) &&
|
|
1366
|
+
let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location2.state?._isRedirect !== true;
|
|
1344
1367
|
if (inFlightDataRoutes) {
|
|
1345
1368
|
dataRoutes = inFlightDataRoutes;
|
|
1346
1369
|
inFlightDataRoutes = void 0;
|
|
@@ -1348,35 +1371,35 @@ function createRouter(init) {
|
|
|
1348
1371
|
if (isUninterruptedRevalidation) {
|
|
1349
1372
|
} else if (pendingAction === "POP" /* Pop */) {
|
|
1350
1373
|
} else if (pendingAction === "PUSH" /* Push */) {
|
|
1351
|
-
init.history.push(
|
|
1374
|
+
init.history.push(location2, location2.state);
|
|
1352
1375
|
} else if (pendingAction === "REPLACE" /* Replace */) {
|
|
1353
|
-
init.history.replace(
|
|
1376
|
+
init.history.replace(location2, location2.state);
|
|
1354
1377
|
}
|
|
1355
1378
|
let viewTransitionOpts;
|
|
1356
1379
|
if (pendingAction === "POP" /* Pop */) {
|
|
1357
1380
|
let priorPaths = appliedViewTransitions.get(state.location.pathname);
|
|
1358
|
-
if (priorPaths && priorPaths.has(
|
|
1381
|
+
if (priorPaths && priorPaths.has(location2.pathname)) {
|
|
1359
1382
|
viewTransitionOpts = {
|
|
1360
1383
|
currentLocation: state.location,
|
|
1361
|
-
nextLocation:
|
|
1384
|
+
nextLocation: location2
|
|
1362
1385
|
};
|
|
1363
|
-
} else if (appliedViewTransitions.has(
|
|
1386
|
+
} else if (appliedViewTransitions.has(location2.pathname)) {
|
|
1364
1387
|
viewTransitionOpts = {
|
|
1365
|
-
currentLocation:
|
|
1388
|
+
currentLocation: location2,
|
|
1366
1389
|
nextLocation: state.location
|
|
1367
1390
|
};
|
|
1368
1391
|
}
|
|
1369
1392
|
} else if (pendingViewTransitionEnabled) {
|
|
1370
1393
|
let toPaths = appliedViewTransitions.get(state.location.pathname);
|
|
1371
1394
|
if (toPaths) {
|
|
1372
|
-
toPaths.add(
|
|
1395
|
+
toPaths.add(location2.pathname);
|
|
1373
1396
|
} else {
|
|
1374
|
-
toPaths = /* @__PURE__ */ new Set([
|
|
1397
|
+
toPaths = /* @__PURE__ */ new Set([location2.pathname]);
|
|
1375
1398
|
appliedViewTransitions.set(state.location.pathname, toPaths);
|
|
1376
1399
|
}
|
|
1377
1400
|
viewTransitionOpts = {
|
|
1378
1401
|
currentLocation: state.location,
|
|
1379
|
-
nextLocation:
|
|
1402
|
+
nextLocation: location2
|
|
1380
1403
|
};
|
|
1381
1404
|
}
|
|
1382
1405
|
updateState(
|
|
@@ -1386,12 +1409,12 @@ function createRouter(init) {
|
|
|
1386
1409
|
actionData,
|
|
1387
1410
|
loaderData,
|
|
1388
1411
|
historyAction: pendingAction,
|
|
1389
|
-
location,
|
|
1412
|
+
location: location2,
|
|
1390
1413
|
initialized: true,
|
|
1391
1414
|
navigation: IDLE_NAVIGATION,
|
|
1392
1415
|
revalidation: "idle",
|
|
1393
1416
|
restoreScrollPosition: getSavedScrollPosition(
|
|
1394
|
-
|
|
1417
|
+
location2,
|
|
1395
1418
|
newState.matches || state.matches
|
|
1396
1419
|
),
|
|
1397
1420
|
preventScrollReset,
|
|
@@ -1508,7 +1531,7 @@ function createRouter(init) {
|
|
|
1508
1531
|
);
|
|
1509
1532
|
return promise;
|
|
1510
1533
|
}
|
|
1511
|
-
async function startNavigation(historyAction,
|
|
1534
|
+
async function startNavigation(historyAction, location2, opts) {
|
|
1512
1535
|
pendingNavigationController && pendingNavigationController.abort();
|
|
1513
1536
|
pendingNavigationController = null;
|
|
1514
1537
|
pendingAction = historyAction;
|
|
@@ -1521,22 +1544,22 @@ function createRouter(init) {
|
|
|
1521
1544
|
let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
|
|
1522
1545
|
// `matchRoutes()` has already been called if we're in here via `router.initialize()`
|
|
1523
1546
|
state.matches
|
|
1524
|
-
) : matchRoutes(routesToUse,
|
|
1547
|
+
) : matchRoutes(routesToUse, location2, basename);
|
|
1525
1548
|
let flushSync = (opts && opts.flushSync) === true;
|
|
1526
|
-
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location,
|
|
1527
|
-
completeNavigation(
|
|
1549
|
+
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location2) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
|
|
1550
|
+
completeNavigation(location2, { matches }, { flushSync });
|
|
1528
1551
|
return;
|
|
1529
1552
|
}
|
|
1530
|
-
let fogOfWar = checkFogOfWar(matches, routesToUse,
|
|
1553
|
+
let fogOfWar = checkFogOfWar(matches, routesToUse, location2.pathname);
|
|
1531
1554
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
1532
1555
|
matches = fogOfWar.matches;
|
|
1533
1556
|
}
|
|
1534
1557
|
if (!matches) {
|
|
1535
1558
|
let { error, notFoundMatches, route } = handleNavigational404(
|
|
1536
|
-
|
|
1559
|
+
location2.pathname
|
|
1537
1560
|
);
|
|
1538
1561
|
completeNavigation(
|
|
1539
|
-
|
|
1562
|
+
location2,
|
|
1540
1563
|
{
|
|
1541
1564
|
matches: notFoundMatches,
|
|
1542
1565
|
loaderData: {},
|
|
@@ -1551,7 +1574,7 @@ function createRouter(init) {
|
|
|
1551
1574
|
pendingNavigationController = new AbortController();
|
|
1552
1575
|
let request = createClientSideRequest(
|
|
1553
1576
|
init.history,
|
|
1554
|
-
|
|
1577
|
+
location2,
|
|
1555
1578
|
pendingNavigationController.signal,
|
|
1556
1579
|
opts && opts.submission
|
|
1557
1580
|
);
|
|
@@ -1567,7 +1590,7 @@ function createRouter(init) {
|
|
|
1567
1590
|
} else if (opts && opts.submission && isMutationMethod(opts.submission.formMethod)) {
|
|
1568
1591
|
let actionResult = await handleAction(
|
|
1569
1592
|
request,
|
|
1570
|
-
|
|
1593
|
+
location2,
|
|
1571
1594
|
opts.submission,
|
|
1572
1595
|
matches,
|
|
1573
1596
|
scopedContext,
|
|
@@ -1582,7 +1605,7 @@ function createRouter(init) {
|
|
|
1582
1605
|
let [routeId, result] = actionResult.pendingActionResult;
|
|
1583
1606
|
if (isErrorResult(result) && isRouteErrorResponse(result.error) && result.error.status === 404) {
|
|
1584
1607
|
pendingNavigationController = null;
|
|
1585
|
-
completeNavigation(
|
|
1608
|
+
completeNavigation(location2, {
|
|
1586
1609
|
matches: actionResult.matches,
|
|
1587
1610
|
loaderData: {},
|
|
1588
1611
|
errors: {
|
|
@@ -1594,7 +1617,7 @@ function createRouter(init) {
|
|
|
1594
1617
|
}
|
|
1595
1618
|
matches = actionResult.matches || matches;
|
|
1596
1619
|
pendingActionResult = actionResult.pendingActionResult;
|
|
1597
|
-
loadingNavigation = getLoadingNavigation(
|
|
1620
|
+
loadingNavigation = getLoadingNavigation(location2, opts.submission);
|
|
1598
1621
|
flushSync = false;
|
|
1599
1622
|
fogOfWar.active = false;
|
|
1600
1623
|
request = createClientSideRequest(
|
|
@@ -1610,7 +1633,7 @@ function createRouter(init) {
|
|
|
1610
1633
|
errors
|
|
1611
1634
|
} = await handleLoaders(
|
|
1612
1635
|
request,
|
|
1613
|
-
|
|
1636
|
+
location2,
|
|
1614
1637
|
matches,
|
|
1615
1638
|
scopedContext,
|
|
1616
1639
|
fogOfWar.active,
|
|
@@ -1626,21 +1649,21 @@ function createRouter(init) {
|
|
|
1626
1649
|
return;
|
|
1627
1650
|
}
|
|
1628
1651
|
pendingNavigationController = null;
|
|
1629
|
-
completeNavigation(
|
|
1652
|
+
completeNavigation(location2, {
|
|
1630
1653
|
matches: updatedMatches || matches,
|
|
1631
1654
|
...getActionDataForCommit(pendingActionResult),
|
|
1632
1655
|
loaderData,
|
|
1633
1656
|
errors
|
|
1634
1657
|
});
|
|
1635
1658
|
}
|
|
1636
|
-
async function handleAction(request,
|
|
1659
|
+
async function handleAction(request, location2, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
|
|
1637
1660
|
interruptActiveLoads();
|
|
1638
|
-
let navigation = getSubmittingNavigation(
|
|
1661
|
+
let navigation = getSubmittingNavigation(location2, submission);
|
|
1639
1662
|
updateState({ navigation }, { flushSync: opts.flushSync === true });
|
|
1640
1663
|
if (isFogOfWar) {
|
|
1641
1664
|
let discoverResult = await discoverRoutes(
|
|
1642
1665
|
matches,
|
|
1643
|
-
|
|
1666
|
+
location2.pathname,
|
|
1644
1667
|
request.signal
|
|
1645
1668
|
);
|
|
1646
1669
|
if (discoverResult.type === "aborted") {
|
|
@@ -1659,7 +1682,7 @@ function createRouter(init) {
|
|
|
1659
1682
|
};
|
|
1660
1683
|
} else if (!discoverResult.matches) {
|
|
1661
1684
|
let { notFoundMatches, error, route } = handleNavigational404(
|
|
1662
|
-
|
|
1685
|
+
location2.pathname
|
|
1663
1686
|
);
|
|
1664
1687
|
return {
|
|
1665
1688
|
matches: notFoundMatches,
|
|
@@ -1676,13 +1699,13 @@ function createRouter(init) {
|
|
|
1676
1699
|
}
|
|
1677
1700
|
}
|
|
1678
1701
|
let result;
|
|
1679
|
-
let actionMatch = getTargetMatch(matches,
|
|
1702
|
+
let actionMatch = getTargetMatch(matches, location2);
|
|
1680
1703
|
if (!actionMatch.route.action && !actionMatch.route.lazy) {
|
|
1681
1704
|
result = {
|
|
1682
1705
|
type: "error" /* error */,
|
|
1683
1706
|
error: getInternalRouterError(405, {
|
|
1684
1707
|
method: request.method,
|
|
1685
|
-
pathname:
|
|
1708
|
+
pathname: location2.pathname,
|
|
1686
1709
|
routeId: actionMatch.route.id
|
|
1687
1710
|
})
|
|
1688
1711
|
};
|
|
@@ -1720,12 +1743,12 @@ function createRouter(init) {
|
|
|
1720
1743
|
if (opts && opts.replace != null) {
|
|
1721
1744
|
replace2 = opts.replace;
|
|
1722
1745
|
} else {
|
|
1723
|
-
let
|
|
1746
|
+
let location3 = normalizeRedirectLocation(
|
|
1724
1747
|
result.response.headers.get("Location"),
|
|
1725
1748
|
new URL(request.url),
|
|
1726
1749
|
basename
|
|
1727
1750
|
);
|
|
1728
|
-
replace2 =
|
|
1751
|
+
replace2 = location3 === state.location.pathname + state.location.search;
|
|
1729
1752
|
}
|
|
1730
1753
|
await startRedirectNavigation(request, result, true, {
|
|
1731
1754
|
submission,
|
|
@@ -1740,11 +1763,7 @@ function createRouter(init) {
|
|
|
1740
1763
|
}
|
|
1741
1764
|
return {
|
|
1742
1765
|
matches,
|
|
1743
|
-
pendingActionResult: [
|
|
1744
|
-
boundaryMatch.route.id,
|
|
1745
|
-
result,
|
|
1746
|
-
actionMatch.route.id
|
|
1747
|
-
]
|
|
1766
|
+
pendingActionResult: [boundaryMatch.route.id, result]
|
|
1748
1767
|
};
|
|
1749
1768
|
}
|
|
1750
1769
|
return {
|
|
@@ -1752,8 +1771,8 @@ function createRouter(init) {
|
|
|
1752
1771
|
pendingActionResult: [actionMatch.route.id, result]
|
|
1753
1772
|
};
|
|
1754
1773
|
}
|
|
1755
|
-
async function handleLoaders(request,
|
|
1756
|
-
let loadingNavigation = overrideNavigation || getLoadingNavigation(
|
|
1774
|
+
async function handleLoaders(request, location2, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
|
|
1775
|
+
let loadingNavigation = overrideNavigation || getLoadingNavigation(location2, submission);
|
|
1757
1776
|
let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
|
|
1758
1777
|
let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
|
|
1759
1778
|
if (isFogOfWar) {
|
|
@@ -1771,7 +1790,7 @@ function createRouter(init) {
|
|
|
1771
1790
|
}
|
|
1772
1791
|
let discoverResult = await discoverRoutes(
|
|
1773
1792
|
matches,
|
|
1774
|
-
|
|
1793
|
+
location2.pathname,
|
|
1775
1794
|
request.signal
|
|
1776
1795
|
);
|
|
1777
1796
|
if (discoverResult.type === "aborted") {
|
|
@@ -1787,7 +1806,7 @@ function createRouter(init) {
|
|
|
1787
1806
|
};
|
|
1788
1807
|
} else if (!discoverResult.matches) {
|
|
1789
1808
|
let { error, notFoundMatches, route } = handleNavigational404(
|
|
1790
|
-
|
|
1809
|
+
location2.pathname
|
|
1791
1810
|
);
|
|
1792
1811
|
return {
|
|
1793
1812
|
matches: notFoundMatches,
|
|
@@ -1810,7 +1829,7 @@ function createRouter(init) {
|
|
|
1810
1829
|
state,
|
|
1811
1830
|
matches,
|
|
1812
1831
|
activeSubmission,
|
|
1813
|
-
|
|
1832
|
+
location2,
|
|
1814
1833
|
initialHydration ? [] : hydrationRouteProperties2,
|
|
1815
1834
|
initialHydration === true,
|
|
1816
1835
|
isRevalidationRequired,
|
|
@@ -1826,7 +1845,7 @@ function createRouter(init) {
|
|
|
1826
1845
|
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && revalidatingFetchers.length === 0) {
|
|
1827
1846
|
let updatedFetchers2 = markFetchRedirectsDone();
|
|
1828
1847
|
completeNavigation(
|
|
1829
|
-
|
|
1848
|
+
location2,
|
|
1830
1849
|
{
|
|
1831
1850
|
matches,
|
|
1832
1851
|
loaderData: {},
|
|
@@ -2337,31 +2356,31 @@ function createRouter(init) {
|
|
|
2337
2356
|
if (redirect2.response.headers.has("X-Remix-Revalidate")) {
|
|
2338
2357
|
isRevalidationRequired = true;
|
|
2339
2358
|
}
|
|
2340
|
-
let
|
|
2341
|
-
invariant(
|
|
2342
|
-
|
|
2343
|
-
|
|
2359
|
+
let location2 = redirect2.response.headers.get("Location");
|
|
2360
|
+
invariant(location2, "Expected a Location header on the redirect Response");
|
|
2361
|
+
location2 = normalizeRedirectLocation(
|
|
2362
|
+
location2,
|
|
2344
2363
|
new URL(request.url),
|
|
2345
2364
|
basename
|
|
2346
2365
|
);
|
|
2347
|
-
let redirectLocation = createLocation(state.location,
|
|
2366
|
+
let redirectLocation = createLocation(state.location, location2, {
|
|
2348
2367
|
_isRedirect: true
|
|
2349
2368
|
});
|
|
2350
2369
|
if (isBrowser2) {
|
|
2351
2370
|
let isDocumentReload = false;
|
|
2352
2371
|
if (redirect2.response.headers.has("X-Remix-Reload-Document")) {
|
|
2353
2372
|
isDocumentReload = true;
|
|
2354
|
-
} else if (ABSOLUTE_URL_REGEX.test(
|
|
2355
|
-
const url = init.history.createURL(
|
|
2373
|
+
} else if (ABSOLUTE_URL_REGEX.test(location2)) {
|
|
2374
|
+
const url = init.history.createURL(location2);
|
|
2356
2375
|
isDocumentReload = // Hard reload if it's an absolute URL to a new origin
|
|
2357
2376
|
url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename
|
|
2358
2377
|
stripBasename(url.pathname, basename) == null;
|
|
2359
2378
|
}
|
|
2360
2379
|
if (isDocumentReload) {
|
|
2361
2380
|
if (replace2) {
|
|
2362
|
-
routerWindow.location.replace(
|
|
2381
|
+
routerWindow.location.replace(location2);
|
|
2363
2382
|
} else {
|
|
2364
|
-
routerWindow.location.assign(
|
|
2383
|
+
routerWindow.location.assign(location2);
|
|
2365
2384
|
}
|
|
2366
2385
|
return;
|
|
2367
2386
|
}
|
|
@@ -2377,7 +2396,7 @@ function createRouter(init) {
|
|
|
2377
2396
|
await startNavigation(redirectNavigationType, redirectLocation, {
|
|
2378
2397
|
submission: {
|
|
2379
2398
|
...activeSubmission,
|
|
2380
|
-
formAction:
|
|
2399
|
+
formAction: location2
|
|
2381
2400
|
},
|
|
2382
2401
|
// Preserve these flags across redirects
|
|
2383
2402
|
preventScrollReset: preventScrollReset || pendingPreventScrollReset,
|
|
@@ -2648,25 +2667,25 @@ function createRouter(init) {
|
|
|
2648
2667
|
getScrollRestorationKey2 = null;
|
|
2649
2668
|
};
|
|
2650
2669
|
}
|
|
2651
|
-
function getScrollKey(
|
|
2670
|
+
function getScrollKey(location2, matches) {
|
|
2652
2671
|
if (getScrollRestorationKey2) {
|
|
2653
2672
|
let key = getScrollRestorationKey2(
|
|
2654
|
-
|
|
2673
|
+
location2,
|
|
2655
2674
|
matches.map((m) => convertRouteMatchToUiMatch(m, state.loaderData))
|
|
2656
2675
|
);
|
|
2657
|
-
return key ||
|
|
2676
|
+
return key || location2.key;
|
|
2658
2677
|
}
|
|
2659
|
-
return
|
|
2678
|
+
return location2.key;
|
|
2660
2679
|
}
|
|
2661
|
-
function saveScrollPosition(
|
|
2680
|
+
function saveScrollPosition(location2, matches) {
|
|
2662
2681
|
if (savedScrollPositions2 && getScrollPosition) {
|
|
2663
|
-
let key = getScrollKey(
|
|
2682
|
+
let key = getScrollKey(location2, matches);
|
|
2664
2683
|
savedScrollPositions2[key] = getScrollPosition();
|
|
2665
2684
|
}
|
|
2666
2685
|
}
|
|
2667
|
-
function getSavedScrollPosition(
|
|
2686
|
+
function getSavedScrollPosition(location2, matches) {
|
|
2668
2687
|
if (savedScrollPositions2) {
|
|
2669
|
-
let key = getScrollKey(
|
|
2688
|
+
let key = getScrollKey(location2, matches);
|
|
2670
2689
|
let y = savedScrollPositions2[key];
|
|
2671
2690
|
if (typeof y === "number") {
|
|
2672
2691
|
return y;
|
|
@@ -2720,7 +2739,8 @@ function createRouter(init) {
|
|
|
2720
2739
|
children,
|
|
2721
2740
|
routesToUse,
|
|
2722
2741
|
localManifest,
|
|
2723
|
-
mapRouteProperties2
|
|
2742
|
+
mapRouteProperties2,
|
|
2743
|
+
false
|
|
2724
2744
|
);
|
|
2725
2745
|
}
|
|
2726
2746
|
});
|
|
@@ -2761,7 +2781,7 @@ function createRouter(init) {
|
|
|
2761
2781
|
manifest
|
|
2762
2782
|
);
|
|
2763
2783
|
}
|
|
2764
|
-
function patchRoutes(routeId, children) {
|
|
2784
|
+
function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
|
|
2765
2785
|
let isNonHMR = inFlightDataRoutes == null;
|
|
2766
2786
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
2767
2787
|
patchRoutesImpl(
|
|
@@ -2769,7 +2789,8 @@ function createRouter(init) {
|
|
|
2769
2789
|
children,
|
|
2770
2790
|
routesToUse,
|
|
2771
2791
|
manifest,
|
|
2772
|
-
mapRouteProperties2
|
|
2792
|
+
mapRouteProperties2,
|
|
2793
|
+
unstable_allowElementMutations
|
|
2773
2794
|
);
|
|
2774
2795
|
if (isNonHMR) {
|
|
2775
2796
|
dataRoutes = [...dataRoutes];
|
|
@@ -2811,7 +2832,10 @@ function createRouter(init) {
|
|
|
2811
2832
|
_internalFetchControllers: fetchControllers,
|
|
2812
2833
|
// TODO: Remove setRoutes, it's temporary to avoid dealing with
|
|
2813
2834
|
// updating the tree while validating the update algorithm.
|
|
2814
|
-
_internalSetRoutes
|
|
2835
|
+
_internalSetRoutes,
|
|
2836
|
+
_internalSetStateDoNotUseOrYouWillBreakYourApp(newState) {
|
|
2837
|
+
updateState(newState);
|
|
2838
|
+
}
|
|
2815
2839
|
};
|
|
2816
2840
|
return router;
|
|
2817
2841
|
}
|
|
@@ -2839,15 +2863,15 @@ function createStaticHandler(routes, opts) {
|
|
|
2839
2863
|
} = {}) {
|
|
2840
2864
|
let url = new URL(request.url);
|
|
2841
2865
|
let method = request.method;
|
|
2842
|
-
let
|
|
2843
|
-
let matches = matchRoutes(dataRoutes,
|
|
2866
|
+
let location2 = createLocation("", createPath(url), null, "default");
|
|
2867
|
+
let matches = matchRoutes(dataRoutes, location2, basename);
|
|
2844
2868
|
requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
|
|
2845
2869
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
2846
2870
|
let error = getInternalRouterError(405, { method });
|
|
2847
2871
|
let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
2848
2872
|
let staticContext = {
|
|
2849
2873
|
basename,
|
|
2850
|
-
location,
|
|
2874
|
+
location: location2,
|
|
2851
2875
|
matches: methodNotAllowedMatches,
|
|
2852
2876
|
loaderData: {},
|
|
2853
2877
|
actionData: null,
|
|
@@ -2860,11 +2884,11 @@ function createStaticHandler(routes, opts) {
|
|
|
2860
2884
|
};
|
|
2861
2885
|
return respond ? respond(staticContext) : staticContext;
|
|
2862
2886
|
} else if (!matches) {
|
|
2863
|
-
let error = getInternalRouterError(404, { pathname:
|
|
2887
|
+
let error = getInternalRouterError(404, { pathname: location2.pathname });
|
|
2864
2888
|
let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
2865
2889
|
let staticContext = {
|
|
2866
2890
|
basename,
|
|
2867
|
-
location,
|
|
2891
|
+
location: location2,
|
|
2868
2892
|
matches: notFoundMatches,
|
|
2869
2893
|
loaderData: {},
|
|
2870
2894
|
actionData: null,
|
|
@@ -2904,7 +2928,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2904
2928
|
async () => {
|
|
2905
2929
|
let result2 = await queryImpl(
|
|
2906
2930
|
request,
|
|
2907
|
-
|
|
2931
|
+
location2,
|
|
2908
2932
|
matches,
|
|
2909
2933
|
requestContext,
|
|
2910
2934
|
dataStrategy || null,
|
|
@@ -2916,7 +2940,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2916
2940
|
if (isResponse(result2)) {
|
|
2917
2941
|
return result2;
|
|
2918
2942
|
}
|
|
2919
|
-
renderedStaticContext = { location, basename, ...result2 };
|
|
2943
|
+
renderedStaticContext = { location: location2, basename, ...result2 };
|
|
2920
2944
|
let res = await respond(renderedStaticContext);
|
|
2921
2945
|
return res;
|
|
2922
2946
|
},
|
|
@@ -2941,7 +2965,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2941
2965
|
let boundary = loaderIdx >= 0 ? findNearestBoundary(matches, matches[loaderIdx].route.id) : findNearestBoundary(matches);
|
|
2942
2966
|
return respond({
|
|
2943
2967
|
matches,
|
|
2944
|
-
location,
|
|
2968
|
+
location: location2,
|
|
2945
2969
|
basename,
|
|
2946
2970
|
loaderData: {},
|
|
2947
2971
|
actionData: null,
|
|
@@ -2966,7 +2990,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2966
2990
|
}
|
|
2967
2991
|
let result = await queryImpl(
|
|
2968
2992
|
request,
|
|
2969
|
-
|
|
2993
|
+
location2,
|
|
2970
2994
|
matches,
|
|
2971
2995
|
requestContext,
|
|
2972
2996
|
dataStrategy || null,
|
|
@@ -2978,7 +3002,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2978
3002
|
if (isResponse(result)) {
|
|
2979
3003
|
return result;
|
|
2980
3004
|
}
|
|
2981
|
-
return { location, basename, ...result };
|
|
3005
|
+
return { location: location2, basename, ...result };
|
|
2982
3006
|
}
|
|
2983
3007
|
async function queryRoute(request, {
|
|
2984
3008
|
routeId,
|
|
@@ -2988,22 +3012,22 @@ function createStaticHandler(routes, opts) {
|
|
|
2988
3012
|
} = {}) {
|
|
2989
3013
|
let url = new URL(request.url);
|
|
2990
3014
|
let method = request.method;
|
|
2991
|
-
let
|
|
2992
|
-
let matches = matchRoutes(dataRoutes,
|
|
3015
|
+
let location2 = createLocation("", createPath(url), null, "default");
|
|
3016
|
+
let matches = matchRoutes(dataRoutes, location2, basename);
|
|
2993
3017
|
requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
|
|
2994
3018
|
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
|
|
2995
3019
|
throw getInternalRouterError(405, { method });
|
|
2996
3020
|
} else if (!matches) {
|
|
2997
|
-
throw getInternalRouterError(404, { pathname:
|
|
3021
|
+
throw getInternalRouterError(404, { pathname: location2.pathname });
|
|
2998
3022
|
}
|
|
2999
|
-
let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches,
|
|
3023
|
+
let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location2);
|
|
3000
3024
|
if (routeId && !match) {
|
|
3001
3025
|
throw getInternalRouterError(403, {
|
|
3002
|
-
pathname:
|
|
3026
|
+
pathname: location2.pathname,
|
|
3003
3027
|
routeId
|
|
3004
3028
|
});
|
|
3005
3029
|
} else if (!match) {
|
|
3006
|
-
throw getInternalRouterError(404, { pathname:
|
|
3030
|
+
throw getInternalRouterError(404, { pathname: location2.pathname });
|
|
3007
3031
|
}
|
|
3008
3032
|
if (respond && matches.some(
|
|
3009
3033
|
(m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
|
|
@@ -3026,7 +3050,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3026
3050
|
async () => {
|
|
3027
3051
|
let result2 = await queryImpl(
|
|
3028
3052
|
request,
|
|
3029
|
-
|
|
3053
|
+
location2,
|
|
3030
3054
|
matches,
|
|
3031
3055
|
requestContext,
|
|
3032
3056
|
dataStrategy || null,
|
|
@@ -3059,7 +3083,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3059
3083
|
}
|
|
3060
3084
|
let result = await queryImpl(
|
|
3061
3085
|
request,
|
|
3062
|
-
|
|
3086
|
+
location2,
|
|
3063
3087
|
matches,
|
|
3064
3088
|
requestContext,
|
|
3065
3089
|
dataStrategy || null,
|
|
@@ -3083,7 +3107,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3083
3107
|
}
|
|
3084
3108
|
return void 0;
|
|
3085
3109
|
}
|
|
3086
|
-
async function queryImpl(request,
|
|
3110
|
+
async function queryImpl(request, location2, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
|
|
3087
3111
|
invariant(
|
|
3088
3112
|
request.signal,
|
|
3089
3113
|
"query()/queryRoute() requests must contain an AbortController signal"
|
|
@@ -3093,7 +3117,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3093
3117
|
let result2 = await submit(
|
|
3094
3118
|
request,
|
|
3095
3119
|
matches,
|
|
3096
|
-
routeMatch || getTargetMatch(matches,
|
|
3120
|
+
routeMatch || getTargetMatch(matches, location2),
|
|
3097
3121
|
requestContext,
|
|
3098
3122
|
dataStrategy,
|
|
3099
3123
|
skipLoaderErrorBubbling,
|
|
@@ -3409,7 +3433,7 @@ function throwStaticHandlerAbortedError(request, isRouteRequest) {
|
|
|
3409
3433
|
function isSubmissionNavigation(opts) {
|
|
3410
3434
|
return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0);
|
|
3411
3435
|
}
|
|
3412
|
-
function normalizeTo(
|
|
3436
|
+
function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
|
|
3413
3437
|
let contextualMatches;
|
|
3414
3438
|
let activeRouteMatch;
|
|
3415
3439
|
if (fromRouteId) {
|
|
@@ -3428,12 +3452,12 @@ function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
|
|
|
3428
3452
|
let path = resolveTo(
|
|
3429
3453
|
to ? to : ".",
|
|
3430
3454
|
getResolveToMatches(contextualMatches),
|
|
3431
|
-
stripBasename(
|
|
3455
|
+
stripBasename(location2.pathname, basename) || location2.pathname,
|
|
3432
3456
|
relative === "path"
|
|
3433
3457
|
);
|
|
3434
3458
|
if (to == null) {
|
|
3435
|
-
path.search =
|
|
3436
|
-
path.hash =
|
|
3459
|
+
path.search = location2.search;
|
|
3460
|
+
path.hash = location2.hash;
|
|
3437
3461
|
}
|
|
3438
3462
|
if ((to == null || to === "" || to === ".") && activeRouteMatch) {
|
|
3439
3463
|
let nakedIndex = hasNakedIndexQuery(path.search);
|
|
@@ -3560,10 +3584,10 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
|
|
|
3560
3584
|
parsedPath.search = `?${searchParams}`;
|
|
3561
3585
|
return { path: createPath(parsedPath), submission };
|
|
3562
3586
|
}
|
|
3563
|
-
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission,
|
|
3587
|
+
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location2, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
|
|
3564
3588
|
let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
|
|
3565
3589
|
let currentUrl = history.createURL(state.location);
|
|
3566
|
-
let nextUrl = history.createURL(
|
|
3590
|
+
let nextUrl = history.createURL(location2);
|
|
3567
3591
|
let maxIdx;
|
|
3568
3592
|
if (initialHydration && state.errors) {
|
|
3569
3593
|
let boundaryId = Object.keys(state.errors)[0];
|
|
@@ -3762,7 +3786,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
3762
3786
|
}
|
|
3763
3787
|
return arg.defaultShouldRevalidate;
|
|
3764
3788
|
}
|
|
3765
|
-
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2) {
|
|
3789
|
+
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
|
|
3766
3790
|
let childrenToPatch;
|
|
3767
3791
|
if (routeId) {
|
|
3768
3792
|
let route = manifest[routeId];
|
|
@@ -3777,18 +3801,47 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
3777
3801
|
} else {
|
|
3778
3802
|
childrenToPatch = routesToUse;
|
|
3779
3803
|
}
|
|
3780
|
-
let uniqueChildren =
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3804
|
+
let uniqueChildren = [];
|
|
3805
|
+
let existingChildren = [];
|
|
3806
|
+
children.forEach((newRoute) => {
|
|
3807
|
+
let existingRoute = childrenToPatch.find(
|
|
3808
|
+
(existingRoute2) => isSameRoute(newRoute, existingRoute2)
|
|
3809
|
+
);
|
|
3810
|
+
if (existingRoute) {
|
|
3811
|
+
existingChildren.push({ existingRoute, newRoute });
|
|
3812
|
+
} else {
|
|
3813
|
+
uniqueChildren.push(newRoute);
|
|
3814
|
+
}
|
|
3815
|
+
});
|
|
3816
|
+
if (uniqueChildren.length > 0) {
|
|
3817
|
+
let newRoutes = convertRoutesToDataRoutes(
|
|
3818
|
+
uniqueChildren,
|
|
3819
|
+
mapRouteProperties2,
|
|
3820
|
+
[routeId || "_", "patch", String(childrenToPatch?.length || "0")],
|
|
3821
|
+
manifest
|
|
3822
|
+
);
|
|
3823
|
+
childrenToPatch.push(...newRoutes);
|
|
3824
|
+
}
|
|
3825
|
+
if (allowElementMutations && existingChildren.length > 0) {
|
|
3826
|
+
for (let i = 0; i < existingChildren.length; i++) {
|
|
3827
|
+
let { existingRoute, newRoute } = existingChildren[i];
|
|
3828
|
+
let existingRouteTyped = existingRoute;
|
|
3829
|
+
let [newRouteTyped] = convertRoutesToDataRoutes(
|
|
3830
|
+
[newRoute],
|
|
3831
|
+
mapRouteProperties2,
|
|
3832
|
+
[],
|
|
3833
|
+
// Doesn't matter for mutated routes since they already have an id
|
|
3834
|
+
{},
|
|
3835
|
+
// Don't touch the manifest here since we're updating in place
|
|
3836
|
+
true
|
|
3837
|
+
);
|
|
3838
|
+
Object.assign(existingRouteTyped, {
|
|
3839
|
+
element: newRouteTyped.element ? newRouteTyped.element : existingRouteTyped.element,
|
|
3840
|
+
errorElement: newRouteTyped.errorElement ? newRouteTyped.errorElement : existingRouteTyped.errorElement,
|
|
3841
|
+
hydrateFallbackElement: newRouteTyped.hydrateFallbackElement ? newRouteTyped.hydrateFallbackElement : existingRouteTyped.hydrateFallbackElement
|
|
3842
|
+
});
|
|
3843
|
+
}
|
|
3844
|
+
}
|
|
3792
3845
|
}
|
|
3793
3846
|
function isSameRoute(newRoute, existingRoute) {
|
|
3794
3847
|
if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
|
|
@@ -4137,7 +4190,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, laz
|
|
|
4137
4190
|
return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
|
|
4138
4191
|
},
|
|
4139
4192
|
resolve(handlerOverride) {
|
|
4140
|
-
if (isUsingNewApi || shouldLoad || handlerOverride && request.method
|
|
4193
|
+
if (isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (match.route.lazy || match.route.loader)) {
|
|
4141
4194
|
return callLoaderOrAction({
|
|
4142
4195
|
request,
|
|
4143
4196
|
match,
|
|
@@ -4397,39 +4450,39 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
4397
4450
|
return { type: "data" /* data */, data: result };
|
|
4398
4451
|
}
|
|
4399
4452
|
function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename) {
|
|
4400
|
-
let
|
|
4453
|
+
let location2 = response.headers.get("Location");
|
|
4401
4454
|
invariant(
|
|
4402
|
-
|
|
4455
|
+
location2,
|
|
4403
4456
|
"Redirects returned/thrown from loaders/actions must have a Location header"
|
|
4404
4457
|
);
|
|
4405
|
-
if (!ABSOLUTE_URL_REGEX.test(
|
|
4458
|
+
if (!ABSOLUTE_URL_REGEX.test(location2)) {
|
|
4406
4459
|
let trimmedMatches = matches.slice(
|
|
4407
4460
|
0,
|
|
4408
4461
|
matches.findIndex((m) => m.route.id === routeId) + 1
|
|
4409
4462
|
);
|
|
4410
|
-
|
|
4463
|
+
location2 = normalizeTo(
|
|
4411
4464
|
new URL(request.url),
|
|
4412
4465
|
trimmedMatches,
|
|
4413
4466
|
basename,
|
|
4414
|
-
|
|
4467
|
+
location2
|
|
4415
4468
|
);
|
|
4416
|
-
response.headers.set("Location",
|
|
4469
|
+
response.headers.set("Location", location2);
|
|
4417
4470
|
}
|
|
4418
4471
|
return response;
|
|
4419
4472
|
}
|
|
4420
|
-
function normalizeRedirectLocation(
|
|
4421
|
-
if (ABSOLUTE_URL_REGEX.test(
|
|
4422
|
-
let normalizedLocation =
|
|
4473
|
+
function normalizeRedirectLocation(location2, currentUrl, basename) {
|
|
4474
|
+
if (ABSOLUTE_URL_REGEX.test(location2)) {
|
|
4475
|
+
let normalizedLocation = location2;
|
|
4423
4476
|
let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
|
|
4424
4477
|
let isSameBasename = stripBasename(url.pathname, basename) != null;
|
|
4425
4478
|
if (url.origin === currentUrl.origin && isSameBasename) {
|
|
4426
4479
|
return url.pathname + url.search + url.hash;
|
|
4427
4480
|
}
|
|
4428
4481
|
}
|
|
4429
|
-
return
|
|
4482
|
+
return location2;
|
|
4430
4483
|
}
|
|
4431
|
-
function createClientSideRequest(history,
|
|
4432
|
-
let url = history.createURL(stripHashFromPath(
|
|
4484
|
+
function createClientSideRequest(history, location2, signal, submission) {
|
|
4485
|
+
let url = history.createURL(stripHashFromPath(location2)).toString();
|
|
4433
4486
|
let init = { signal };
|
|
4434
4487
|
if (submission && isMutationMethod(submission.formMethod)) {
|
|
4435
4488
|
let { formMethod, formEncType } = submission;
|
|
@@ -4515,9 +4568,7 @@ function processRouteLoaderData(matches, results, pendingActionResult, isStaticH
|
|
|
4515
4568
|
});
|
|
4516
4569
|
if (pendingError !== void 0 && pendingActionResult) {
|
|
4517
4570
|
errors = { [pendingActionResult[0]]: pendingError };
|
|
4518
|
-
|
|
4519
|
-
loaderData[pendingActionResult[2]] = void 0;
|
|
4520
|
-
}
|
|
4571
|
+
loaderData[pendingActionResult[0]] = void 0;
|
|
4521
4572
|
}
|
|
4522
4573
|
return {
|
|
4523
4574
|
loaderData,
|
|
@@ -4701,8 +4752,8 @@ function isMutationMethod(method) {
|
|
|
4701
4752
|
function hasNakedIndexQuery(search) {
|
|
4702
4753
|
return new URLSearchParams(search).getAll("index").some((v) => v === "");
|
|
4703
4754
|
}
|
|
4704
|
-
function getTargetMatch(matches,
|
|
4705
|
-
let search = typeof
|
|
4755
|
+
function getTargetMatch(matches, location2) {
|
|
4756
|
+
let search = typeof location2 === "string" ? parsePath(location2).search : location2.search;
|
|
4706
4757
|
if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
|
|
4707
4758
|
return matches[matches.length - 1];
|
|
4708
4759
|
}
|
|
@@ -4743,11 +4794,11 @@ function getSubmissionFromNavigation(navigation) {
|
|
|
4743
4794
|
};
|
|
4744
4795
|
}
|
|
4745
4796
|
}
|
|
4746
|
-
function getLoadingNavigation(
|
|
4797
|
+
function getLoadingNavigation(location2, submission) {
|
|
4747
4798
|
if (submission) {
|
|
4748
4799
|
let navigation = {
|
|
4749
4800
|
state: "loading",
|
|
4750
|
-
location,
|
|
4801
|
+
location: location2,
|
|
4751
4802
|
formMethod: submission.formMethod,
|
|
4752
4803
|
formAction: submission.formAction,
|
|
4753
4804
|
formEncType: submission.formEncType,
|
|
@@ -4759,7 +4810,7 @@ function getLoadingNavigation(location, submission) {
|
|
|
4759
4810
|
} else {
|
|
4760
4811
|
let navigation = {
|
|
4761
4812
|
state: "loading",
|
|
4762
|
-
location,
|
|
4813
|
+
location: location2,
|
|
4763
4814
|
formMethod: void 0,
|
|
4764
4815
|
formAction: void 0,
|
|
4765
4816
|
formEncType: void 0,
|
|
@@ -4770,10 +4821,10 @@ function getLoadingNavigation(location, submission) {
|
|
|
4770
4821
|
return navigation;
|
|
4771
4822
|
}
|
|
4772
4823
|
}
|
|
4773
|
-
function getSubmittingNavigation(
|
|
4824
|
+
function getSubmittingNavigation(location2, submission) {
|
|
4774
4825
|
let navigation = {
|
|
4775
4826
|
state: "submitting",
|
|
4776
|
-
location,
|
|
4827
|
+
location: location2,
|
|
4777
4828
|
formMethod: submission.formMethod,
|
|
4778
4829
|
formAction: submission.formAction,
|
|
4779
4830
|
formEncType: submission.formEncType,
|
|
@@ -5099,18 +5150,18 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5099
5150
|
);
|
|
5100
5151
|
}
|
|
5101
5152
|
let locationFromContext = useLocation();
|
|
5102
|
-
let
|
|
5153
|
+
let location2;
|
|
5103
5154
|
if (locationArg) {
|
|
5104
5155
|
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
5105
5156
|
invariant(
|
|
5106
5157
|
parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase),
|
|
5107
5158
|
`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${parentPathnameBase}" but pathname "${parsedLocationArg.pathname}" was given in the \`location\` prop.`
|
|
5108
5159
|
);
|
|
5109
|
-
|
|
5160
|
+
location2 = parsedLocationArg;
|
|
5110
5161
|
} else {
|
|
5111
|
-
|
|
5162
|
+
location2 = locationFromContext;
|
|
5112
5163
|
}
|
|
5113
|
-
let pathname =
|
|
5164
|
+
let pathname = location2.pathname || "/";
|
|
5114
5165
|
let remainingPathname = pathname;
|
|
5115
5166
|
if (parentPathnameBase !== "/") {
|
|
5116
5167
|
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
|
|
@@ -5121,11 +5172,11 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5121
5172
|
if (ENABLE_DEV_WARNINGS) {
|
|
5122
5173
|
warning(
|
|
5123
5174
|
parentRoute || matches != null,
|
|
5124
|
-
`No routes matched location "${
|
|
5175
|
+
`No routes matched location "${location2.pathname}${location2.search}${location2.hash}" `
|
|
5125
5176
|
);
|
|
5126
5177
|
warning(
|
|
5127
5178
|
matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0,
|
|
5128
|
-
`Matched leaf route at location "${
|
|
5179
|
+
`Matched leaf route at location "${location2.pathname}${location2.search}${location2.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`
|
|
5129
5180
|
);
|
|
5130
5181
|
}
|
|
5131
5182
|
let renderedMatches = _renderMatches(
|
|
@@ -5159,7 +5210,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5159
5210
|
hash: "",
|
|
5160
5211
|
state: null,
|
|
5161
5212
|
key: "default",
|
|
5162
|
-
...
|
|
5213
|
+
...location2
|
|
5163
5214
|
},
|
|
5164
5215
|
navigationType: "POP" /* Pop */
|
|
5165
5216
|
}
|
|
@@ -5924,9 +5975,9 @@ function Router({
|
|
|
5924
5975
|
}
|
|
5925
5976
|
function Routes({
|
|
5926
5977
|
children,
|
|
5927
|
-
location
|
|
5978
|
+
location: location2
|
|
5928
5979
|
}) {
|
|
5929
|
-
return useRoutes(createRoutesFromChildren(children),
|
|
5980
|
+
return useRoutes(createRoutesFromChildren(children), location2);
|
|
5930
5981
|
}
|
|
5931
5982
|
function Await({
|
|
5932
5983
|
children,
|
|
@@ -5996,6 +6047,38 @@ function ResolveAwait({
|
|
|
5996
6047
|
let toRender = typeof children === "function" ? children(data2) : children;
|
|
5997
6048
|
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, toRender);
|
|
5998
6049
|
}
|
|
6050
|
+
function WithRouteComponentProps({
|
|
6051
|
+
children
|
|
6052
|
+
}) {
|
|
6053
|
+
let props = {
|
|
6054
|
+
loaderData: useLoaderData(),
|
|
6055
|
+
actionData: useActionData(),
|
|
6056
|
+
params: useParams(),
|
|
6057
|
+
matches: useMatches()
|
|
6058
|
+
};
|
|
6059
|
+
return React3.cloneElement(children, props);
|
|
6060
|
+
}
|
|
6061
|
+
function WithHydrateFallbackProps({
|
|
6062
|
+
children
|
|
6063
|
+
}) {
|
|
6064
|
+
let props = {
|
|
6065
|
+
loaderData: useLoaderData(),
|
|
6066
|
+
actionData: useActionData(),
|
|
6067
|
+
params: useParams()
|
|
6068
|
+
};
|
|
6069
|
+
return React3.cloneElement(children, props);
|
|
6070
|
+
}
|
|
6071
|
+
function WithErrorBoundaryProps({
|
|
6072
|
+
children
|
|
6073
|
+
}) {
|
|
6074
|
+
let props = {
|
|
6075
|
+
loaderData: useLoaderData(),
|
|
6076
|
+
actionData: useActionData(),
|
|
6077
|
+
params: useParams(),
|
|
6078
|
+
error: useRouteError()
|
|
6079
|
+
};
|
|
6080
|
+
return React3.cloneElement(children, props);
|
|
6081
|
+
}
|
|
5999
6082
|
function createRoutesFromChildren(children, parentPath = []) {
|
|
6000
6083
|
let routes = [];
|
|
6001
6084
|
React3.Children.forEach(children, (element, index) => {
|
|
@@ -6318,7 +6401,7 @@ async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
|
|
|
6318
6401
|
)
|
|
6319
6402
|
);
|
|
6320
6403
|
}
|
|
6321
|
-
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest,
|
|
6404
|
+
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location2, mode) {
|
|
6322
6405
|
let isNew = (match, index) => {
|
|
6323
6406
|
if (!currentMatches[index]) return true;
|
|
6324
6407
|
return match.route.id !== currentMatches[index].route.id;
|
|
@@ -6348,7 +6431,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
6348
6431
|
if (match.route.shouldRevalidate) {
|
|
6349
6432
|
let routeChoice = match.route.shouldRevalidate({
|
|
6350
6433
|
currentUrl: new URL(
|
|
6351
|
-
|
|
6434
|
+
location2.pathname + location2.search + location2.hash,
|
|
6352
6435
|
window.origin
|
|
6353
6436
|
),
|
|
6354
6437
|
currentParams: currentMatches[0]?.params || {},
|
|
@@ -6468,7 +6551,6 @@ async function createRequestInit(request) {
|
|
|
6468
6551
|
|
|
6469
6552
|
// lib/dom/ssr/single-fetch.tsx
|
|
6470
6553
|
var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
|
|
6471
|
-
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
6472
6554
|
var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205]);
|
|
6473
6555
|
function StreamTransfer({
|
|
6474
6556
|
context,
|
|
@@ -6681,8 +6763,7 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
|
|
|
6681
6763
|
)
|
|
6682
6764
|
);
|
|
6683
6765
|
await Promise.all(routeDfds.map((d) => d.promise));
|
|
6684
|
-
|
|
6685
|
-
if ((isInitialLoad || routesParams.size === 0) && !window.__reactRouterHdrActive) {
|
|
6766
|
+
if ((!router.state.initialized || routesParams.size === 0) && !window.__reactRouterHdrActive) {
|
|
6686
6767
|
singleFetchDfd.resolve({ routes: {} });
|
|
6687
6768
|
} else {
|
|
6688
6769
|
let targetRoutes = ssr && foundOptOutRoute && routesParams.size > 0 ? [...routesParams.keys()] : void 0;
|
|
@@ -6722,7 +6803,7 @@ function stripIndexParam(url) {
|
|
|
6722
6803
|
}
|
|
6723
6804
|
return url;
|
|
6724
6805
|
}
|
|
6725
|
-
function singleFetchUrl(reqUrl, basename) {
|
|
6806
|
+
function singleFetchUrl(reqUrl, basename, extension) {
|
|
6726
6807
|
let url = typeof reqUrl === "string" ? new URL(
|
|
6727
6808
|
reqUrl,
|
|
6728
6809
|
// This can be called during the SSR flow via PrefetchPageLinksImpl so
|
|
@@ -6730,17 +6811,17 @@ function singleFetchUrl(reqUrl, basename) {
|
|
|
6730
6811
|
typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
|
|
6731
6812
|
) : reqUrl;
|
|
6732
6813
|
if (url.pathname === "/") {
|
|
6733
|
-
url.pathname =
|
|
6814
|
+
url.pathname = `_root.${extension}`;
|
|
6734
6815
|
} else if (basename && stripBasename(url.pathname, basename) === "/") {
|
|
6735
|
-
url.pathname = `${basename.replace(/\/$/, "")}/_root
|
|
6816
|
+
url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
|
|
6736
6817
|
} else {
|
|
6737
|
-
url.pathname = `${url.pathname.replace(/\/$/, "")}
|
|
6818
|
+
url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
|
|
6738
6819
|
}
|
|
6739
6820
|
return url;
|
|
6740
6821
|
}
|
|
6741
6822
|
async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
6742
6823
|
let { request } = args;
|
|
6743
|
-
let url = singleFetchUrl(request.url, basename);
|
|
6824
|
+
let url = singleFetchUrl(request.url, basename, "data");
|
|
6744
6825
|
if (request.method === "GET") {
|
|
6745
6826
|
url = stripIndexParam(url);
|
|
6746
6827
|
if (targetRoutes) {
|
|
@@ -6751,20 +6832,6 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
|
6751
6832
|
if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
|
|
6752
6833
|
throw new ErrorResponseImpl(404, "Not Found", true);
|
|
6753
6834
|
}
|
|
6754
|
-
if (res.status === 204 && res.headers.has("X-Remix-Redirect")) {
|
|
6755
|
-
return {
|
|
6756
|
-
status: SINGLE_FETCH_REDIRECT_STATUS,
|
|
6757
|
-
data: {
|
|
6758
|
-
redirect: {
|
|
6759
|
-
redirect: res.headers.get("X-Remix-Redirect"),
|
|
6760
|
-
status: Number(res.headers.get("X-Remix-Status") || "302"),
|
|
6761
|
-
revalidate: res.headers.get("X-Remix-Revalidate") === "true",
|
|
6762
|
-
reload: res.headers.get("X-Remix-Reload-Document") === "true",
|
|
6763
|
-
replace: res.headers.get("X-Remix-Replace") === "true"
|
|
6764
|
-
}
|
|
6765
|
-
}
|
|
6766
|
-
};
|
|
6767
|
-
}
|
|
6768
6835
|
if (NO_BODY_STATUS_CODES.has(res.status)) {
|
|
6769
6836
|
let routes = {};
|
|
6770
6837
|
if (targetRoutes && request.method !== "GET") {
|
|
@@ -6837,13 +6904,13 @@ function decodeViaTurboStream(body, global2) {
|
|
|
6837
6904
|
function unwrapSingleFetchResult(result, routeId) {
|
|
6838
6905
|
if ("redirect" in result) {
|
|
6839
6906
|
let {
|
|
6840
|
-
redirect:
|
|
6907
|
+
redirect: location2,
|
|
6841
6908
|
revalidate,
|
|
6842
6909
|
reload,
|
|
6843
6910
|
replace: replace2,
|
|
6844
6911
|
status
|
|
6845
6912
|
} = result.redirect;
|
|
6846
|
-
throw redirect(
|
|
6913
|
+
throw redirect(location2, {
|
|
6847
6914
|
status,
|
|
6848
6915
|
headers: {
|
|
6849
6916
|
// Three R's of redirecting (lol Veep)
|
|
@@ -6854,12 +6921,13 @@ function unwrapSingleFetchResult(result, routeId) {
|
|
|
6854
6921
|
});
|
|
6855
6922
|
}
|
|
6856
6923
|
let routeResult = result.routes[routeId];
|
|
6924
|
+
invariant2(routeResult, `No response found for routeId "${routeId}"`);
|
|
6857
6925
|
if ("error" in routeResult) {
|
|
6858
6926
|
throw routeResult.error;
|
|
6859
6927
|
} else if ("data" in routeResult) {
|
|
6860
6928
|
return routeResult.data;
|
|
6861
6929
|
} else {
|
|
6862
|
-
throw new Error(`
|
|
6930
|
+
throw new Error(`Invalid response found for routeId "${routeId}"`);
|
|
6863
6931
|
}
|
|
6864
6932
|
}
|
|
6865
6933
|
function createDeferred2() {
|
|
@@ -7424,8 +7492,8 @@ var nextPaths = /* @__PURE__ */ new Set();
|
|
|
7424
7492
|
var discoveredPathsMaxSize = 1e3;
|
|
7425
7493
|
var discoveredPaths = /* @__PURE__ */ new Set();
|
|
7426
7494
|
var URL_LIMIT = 7680;
|
|
7427
|
-
function isFogOfWarEnabled(
|
|
7428
|
-
return
|
|
7495
|
+
function isFogOfWarEnabled(ssr) {
|
|
7496
|
+
return ssr === true;
|
|
7429
7497
|
}
|
|
7430
7498
|
function getPartialManifest({ sri, ...manifest }, router) {
|
|
7431
7499
|
let routeIds = new Set(router.state.matches.map((m) => m.route.id));
|
|
@@ -7452,8 +7520,8 @@ function getPartialManifest({ sri, ...manifest }, router) {
|
|
|
7452
7520
|
sri: sri ? true : void 0
|
|
7453
7521
|
};
|
|
7454
7522
|
}
|
|
7455
|
-
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr,
|
|
7456
|
-
if (!isFogOfWarEnabled(
|
|
7523
|
+
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
|
|
7524
|
+
if (!isFogOfWarEnabled(ssr)) {
|
|
7457
7525
|
return void 0;
|
|
7458
7526
|
}
|
|
7459
7527
|
return async ({ path, patch, signal, fetcherKey }) => {
|
|
@@ -7468,15 +7536,14 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDi
|
|
|
7468
7536
|
ssr,
|
|
7469
7537
|
isSpaMode,
|
|
7470
7538
|
basename,
|
|
7471
|
-
routeDiscovery.manifestPath,
|
|
7472
7539
|
patch,
|
|
7473
7540
|
signal
|
|
7474
7541
|
);
|
|
7475
7542
|
};
|
|
7476
7543
|
}
|
|
7477
|
-
function useFogOFWarDiscovery(router, manifest, routeModules, ssr,
|
|
7544
|
+
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
7478
7545
|
React8.useEffect(() => {
|
|
7479
|
-
if (!isFogOfWarEnabled(
|
|
7546
|
+
if (!isFogOfWarEnabled(ssr) || navigator.connection?.saveData === true) {
|
|
7480
7547
|
return;
|
|
7481
7548
|
}
|
|
7482
7549
|
function registerElement(el) {
|
|
@@ -7510,7 +7577,6 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscover
|
|
|
7510
7577
|
ssr,
|
|
7511
7578
|
isSpaMode,
|
|
7512
7579
|
router.basename,
|
|
7513
|
-
routeDiscovery.manifestPath,
|
|
7514
7580
|
router.patchRoutes
|
|
7515
7581
|
);
|
|
7516
7582
|
} catch (e) {
|
|
@@ -7527,21 +7593,15 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscover
|
|
|
7527
7593
|
attributeFilter: ["data-discover", "href", "action"]
|
|
7528
7594
|
});
|
|
7529
7595
|
return () => observer.disconnect();
|
|
7530
|
-
}, [ssr, isSpaMode, manifest, routeModules, router
|
|
7531
|
-
}
|
|
7532
|
-
function getManifestPath(_manifestPath, basename) {
|
|
7533
|
-
let manifestPath = _manifestPath || "/__manifest";
|
|
7534
|
-
if (basename == null) {
|
|
7535
|
-
return manifestPath;
|
|
7536
|
-
}
|
|
7537
|
-
return `${basename}${manifestPath}`.replace(/\/+/g, "/");
|
|
7596
|
+
}, [ssr, isSpaMode, manifest, routeModules, router]);
|
|
7538
7597
|
}
|
|
7539
7598
|
var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
|
|
7540
|
-
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename,
|
|
7541
|
-
let
|
|
7542
|
-
|
|
7543
|
-
|
|
7599
|
+
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, patchRoutes, signal) {
|
|
7600
|
+
let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
|
|
7601
|
+
/\/+/g,
|
|
7602
|
+
"/"
|
|
7544
7603
|
);
|
|
7604
|
+
let url = new URL(manifestPath, window.location.origin);
|
|
7545
7605
|
paths.sort().forEach((path) => url.searchParams.append("p", path));
|
|
7546
7606
|
url.searchParams.set("version", manifest.version);
|
|
7547
7607
|
if (url.toString().length > URL_LIMIT) {
|
|
@@ -7568,9 +7628,7 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
7568
7628
|
}
|
|
7569
7629
|
sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
|
|
7570
7630
|
window.location.href = errorReloadPath;
|
|
7571
|
-
|
|
7572
|
-
await new Promise(() => {
|
|
7573
|
-
});
|
|
7631
|
+
throw new Error("Detected manifest version mismatch, reloading...");
|
|
7574
7632
|
} else if (res.status >= 400) {
|
|
7575
7633
|
throw new Error(await res.text());
|
|
7576
7634
|
}
|
|
@@ -7769,7 +7827,7 @@ function PrefetchPageLinksImpl({
|
|
|
7769
7827
|
matches: nextMatches,
|
|
7770
7828
|
...linkProps
|
|
7771
7829
|
}) {
|
|
7772
|
-
let
|
|
7830
|
+
let location2 = useLocation();
|
|
7773
7831
|
let { manifest, routeModules } = useFrameworkContext();
|
|
7774
7832
|
let { basename } = useDataRouterContext2();
|
|
7775
7833
|
let { loaderData, matches } = useDataRouterStateContext();
|
|
@@ -7779,10 +7837,10 @@ function PrefetchPageLinksImpl({
|
|
|
7779
7837
|
nextMatches,
|
|
7780
7838
|
matches,
|
|
7781
7839
|
manifest,
|
|
7782
|
-
|
|
7840
|
+
location2,
|
|
7783
7841
|
"data"
|
|
7784
7842
|
),
|
|
7785
|
-
[page, nextMatches, matches, manifest,
|
|
7843
|
+
[page, nextMatches, matches, manifest, location2]
|
|
7786
7844
|
);
|
|
7787
7845
|
let newMatchesForAssets = React9.useMemo(
|
|
7788
7846
|
() => getNewMatchesForLinks(
|
|
@@ -7790,13 +7848,13 @@ function PrefetchPageLinksImpl({
|
|
|
7790
7848
|
nextMatches,
|
|
7791
7849
|
matches,
|
|
7792
7850
|
manifest,
|
|
7793
|
-
|
|
7851
|
+
location2,
|
|
7794
7852
|
"assets"
|
|
7795
7853
|
),
|
|
7796
|
-
[page, nextMatches, matches, manifest,
|
|
7854
|
+
[page, nextMatches, matches, manifest, location2]
|
|
7797
7855
|
);
|
|
7798
7856
|
let dataHrefs = React9.useMemo(() => {
|
|
7799
|
-
if (page ===
|
|
7857
|
+
if (page === location2.pathname + location2.search + location2.hash) {
|
|
7800
7858
|
return [];
|
|
7801
7859
|
}
|
|
7802
7860
|
let routesParams = /* @__PURE__ */ new Set();
|
|
@@ -7817,7 +7875,7 @@ function PrefetchPageLinksImpl({
|
|
|
7817
7875
|
if (routesParams.size === 0) {
|
|
7818
7876
|
return [];
|
|
7819
7877
|
}
|
|
7820
|
-
let url = singleFetchUrl(page, basename);
|
|
7878
|
+
let url = singleFetchUrl(page, basename, ".data");
|
|
7821
7879
|
if (foundOptOutRoute && routesParams.size > 0) {
|
|
7822
7880
|
url.searchParams.set(
|
|
7823
7881
|
"_routes",
|
|
@@ -7828,7 +7886,7 @@ function PrefetchPageLinksImpl({
|
|
|
7828
7886
|
}, [
|
|
7829
7887
|
basename,
|
|
7830
7888
|
loaderData,
|
|
7831
|
-
|
|
7889
|
+
location2,
|
|
7832
7890
|
manifest,
|
|
7833
7891
|
newMatchesForData,
|
|
7834
7892
|
nextMatches,
|
|
@@ -7853,7 +7911,7 @@ function Meta() {
|
|
|
7853
7911
|
matches: routerMatches,
|
|
7854
7912
|
loaderData
|
|
7855
7913
|
} = useDataRouterStateContext();
|
|
7856
|
-
let
|
|
7914
|
+
let location2 = useLocation();
|
|
7857
7915
|
let _matches = getActiveMatches(routerMatches, errors, isSpaMode);
|
|
7858
7916
|
let error = null;
|
|
7859
7917
|
if (errors) {
|
|
@@ -7883,7 +7941,7 @@ function Meta() {
|
|
|
7883
7941
|
routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
|
|
7884
7942
|
data: data2,
|
|
7885
7943
|
params,
|
|
7886
|
-
location,
|
|
7944
|
+
location: location2,
|
|
7887
7945
|
matches,
|
|
7888
7946
|
error
|
|
7889
7947
|
}) : Array.isArray(routeModule.meta) ? [...routeModule.meta] : routeModule.meta;
|
|
@@ -7949,17 +8007,10 @@ function isValidMetaTag(tagName) {
|
|
|
7949
8007
|
}
|
|
7950
8008
|
var isHydrated = false;
|
|
7951
8009
|
function Scripts(props) {
|
|
7952
|
-
let {
|
|
7953
|
-
manifest,
|
|
7954
|
-
serverHandoffString,
|
|
7955
|
-
isSpaMode,
|
|
7956
|
-
renderMeta,
|
|
7957
|
-
routeDiscovery,
|
|
7958
|
-
ssr
|
|
7959
|
-
} = useFrameworkContext();
|
|
8010
|
+
let { manifest, serverHandoffString, isSpaMode, ssr, renderMeta } = useFrameworkContext();
|
|
7960
8011
|
let { router, static: isStatic, staticContext } = useDataRouterContext2();
|
|
7961
8012
|
let { matches: routerMatches } = useDataRouterStateContext();
|
|
7962
|
-
let enableFogOfWar = isFogOfWarEnabled(
|
|
8013
|
+
let enableFogOfWar = isFogOfWarEnabled(ssr);
|
|
7963
8014
|
if (renderMeta) {
|
|
7964
8015
|
renderMeta.didRenderScripts = true;
|
|
7965
8016
|
}
|
|
@@ -8115,7 +8166,7 @@ function mergeRefs(...refs) {
|
|
|
8115
8166
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
8116
8167
|
try {
|
|
8117
8168
|
if (isBrowser) {
|
|
8118
|
-
window.__reactRouterVersion = "0.0.0-experimental-
|
|
8169
|
+
window.__reactRouterVersion = "0.0.0-experimental-e56aa53bc";
|
|
8119
8170
|
}
|
|
8120
8171
|
} catch (e) {
|
|
8121
8172
|
}
|
|
@@ -8373,14 +8424,14 @@ var NavLink = React10.forwardRef(
|
|
|
8373
8424
|
...rest
|
|
8374
8425
|
}, ref) {
|
|
8375
8426
|
let path = useResolvedPath(to, { relative: rest.relative });
|
|
8376
|
-
let
|
|
8427
|
+
let location2 = useLocation();
|
|
8377
8428
|
let routerState = React10.useContext(DataRouterStateContext);
|
|
8378
8429
|
let { navigator: navigator2, basename } = React10.useContext(NavigationContext);
|
|
8379
8430
|
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
|
8380
8431
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
8381
8432
|
useViewTransitionState(path) && viewTransition === true;
|
|
8382
8433
|
let toPathname = navigator2.encodeLocation ? navigator2.encodeLocation(path).pathname : path.pathname;
|
|
8383
|
-
let locationPathname =
|
|
8434
|
+
let locationPathname = location2.pathname;
|
|
8384
8435
|
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
|
|
8385
8436
|
if (!caseSensitive) {
|
|
8386
8437
|
locationPathname = locationPathname.toLowerCase();
|
|
@@ -8485,19 +8536,19 @@ function ScrollRestoration({
|
|
|
8485
8536
|
}) {
|
|
8486
8537
|
let remixContext = React10.useContext(FrameworkContext);
|
|
8487
8538
|
let { basename } = React10.useContext(NavigationContext);
|
|
8488
|
-
let
|
|
8539
|
+
let location2 = useLocation();
|
|
8489
8540
|
let matches = useMatches();
|
|
8490
8541
|
useScrollRestoration({ getKey, storageKey });
|
|
8491
8542
|
let ssrKey = React10.useMemo(
|
|
8492
8543
|
() => {
|
|
8493
8544
|
if (!remixContext || !getKey) return null;
|
|
8494
8545
|
let userKey = getScrollRestorationKey(
|
|
8495
|
-
|
|
8546
|
+
location2,
|
|
8496
8547
|
matches,
|
|
8497
8548
|
basename,
|
|
8498
8549
|
getKey
|
|
8499
8550
|
);
|
|
8500
|
-
return userKey !==
|
|
8551
|
+
return userKey !== location2.key ? userKey : null;
|
|
8501
8552
|
},
|
|
8502
8553
|
// Nah, we only need this the first time for the SSR render
|
|
8503
8554
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -8558,13 +8609,13 @@ function useLinkClickHandler(to, {
|
|
|
8558
8609
|
viewTransition
|
|
8559
8610
|
} = {}) {
|
|
8560
8611
|
let navigate = useNavigate();
|
|
8561
|
-
let
|
|
8612
|
+
let location2 = useLocation();
|
|
8562
8613
|
let path = useResolvedPath(to, { relative });
|
|
8563
8614
|
return React10.useCallback(
|
|
8564
8615
|
(event) => {
|
|
8565
8616
|
if (shouldProcessLinkClick(event, target)) {
|
|
8566
8617
|
event.preventDefault();
|
|
8567
|
-
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(
|
|
8618
|
+
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location2) === createPath(path);
|
|
8568
8619
|
navigate(to, {
|
|
8569
8620
|
replace: replace2,
|
|
8570
8621
|
state,
|
|
@@ -8575,7 +8626,7 @@ function useLinkClickHandler(to, {
|
|
|
8575
8626
|
}
|
|
8576
8627
|
},
|
|
8577
8628
|
[
|
|
8578
|
-
|
|
8629
|
+
location2,
|
|
8579
8630
|
navigate,
|
|
8580
8631
|
path,
|
|
8581
8632
|
replaceProp,
|
|
@@ -8595,18 +8646,18 @@ function useSearchParams(defaultInit) {
|
|
|
8595
8646
|
);
|
|
8596
8647
|
let defaultSearchParamsRef = React10.useRef(createSearchParams(defaultInit));
|
|
8597
8648
|
let hasSetSearchParamsRef = React10.useRef(false);
|
|
8598
|
-
let
|
|
8649
|
+
let location2 = useLocation();
|
|
8599
8650
|
let searchParams = React10.useMemo(
|
|
8600
8651
|
() => (
|
|
8601
8652
|
// Only merge in the defaults if we haven't yet called setSearchParams.
|
|
8602
8653
|
// Once we call that we want those to take precedence, otherwise you can't
|
|
8603
8654
|
// remove a param with setSearchParams({}) if it has an initial value
|
|
8604
8655
|
getSearchParamsForLocation(
|
|
8605
|
-
|
|
8656
|
+
location2.search,
|
|
8606
8657
|
hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
|
|
8607
8658
|
)
|
|
8608
8659
|
),
|
|
8609
|
-
[
|
|
8660
|
+
[location2.search]
|
|
8610
8661
|
);
|
|
8611
8662
|
let navigate = useNavigate();
|
|
8612
8663
|
let setSearchParams = React10.useCallback(
|
|
@@ -8667,9 +8718,9 @@ function useFormAction(action, { relative } = {}) {
|
|
|
8667
8718
|
invariant(routeContext, "useFormAction must be used inside a RouteContext");
|
|
8668
8719
|
let [match] = routeContext.matches.slice(-1);
|
|
8669
8720
|
let path = { ...useResolvedPath(action ? action : ".", { relative }) };
|
|
8670
|
-
let
|
|
8721
|
+
let location2 = useLocation();
|
|
8671
8722
|
if (action == null) {
|
|
8672
|
-
path.search =
|
|
8723
|
+
path.search = location2.search;
|
|
8673
8724
|
let params = new URLSearchParams(path.search);
|
|
8674
8725
|
let indexValues = params.getAll("index");
|
|
8675
8726
|
let hasNakedIndexParam = indexValues.some((v) => v === "");
|
|
@@ -8761,23 +8812,23 @@ function useFetchers() {
|
|
|
8761
8812
|
}
|
|
8762
8813
|
var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
|
|
8763
8814
|
var savedScrollPositions = {};
|
|
8764
|
-
function getScrollRestorationKey(
|
|
8815
|
+
function getScrollRestorationKey(location2, matches, basename, getKey) {
|
|
8765
8816
|
let key = null;
|
|
8766
8817
|
if (getKey) {
|
|
8767
8818
|
if (basename !== "/") {
|
|
8768
8819
|
key = getKey(
|
|
8769
8820
|
{
|
|
8770
|
-
...
|
|
8771
|
-
pathname: stripBasename(
|
|
8821
|
+
...location2,
|
|
8822
|
+
pathname: stripBasename(location2.pathname, basename) || location2.pathname
|
|
8772
8823
|
},
|
|
8773
8824
|
matches
|
|
8774
8825
|
);
|
|
8775
8826
|
} else {
|
|
8776
|
-
key = getKey(
|
|
8827
|
+
key = getKey(location2, matches);
|
|
8777
8828
|
}
|
|
8778
8829
|
}
|
|
8779
8830
|
if (key == null) {
|
|
8780
|
-
key =
|
|
8831
|
+
key = location2.key;
|
|
8781
8832
|
}
|
|
8782
8833
|
return key;
|
|
8783
8834
|
}
|
|
@@ -8790,7 +8841,7 @@ function useScrollRestoration({
|
|
|
8790
8841
|
"useScrollRestoration" /* UseScrollRestoration */
|
|
8791
8842
|
);
|
|
8792
8843
|
let { basename } = React10.useContext(NavigationContext);
|
|
8793
|
-
let
|
|
8844
|
+
let location2 = useLocation();
|
|
8794
8845
|
let matches = useMatches();
|
|
8795
8846
|
let navigation = useNavigation();
|
|
8796
8847
|
React10.useEffect(() => {
|
|
@@ -8802,7 +8853,7 @@ function useScrollRestoration({
|
|
|
8802
8853
|
usePageHide(
|
|
8803
8854
|
React10.useCallback(() => {
|
|
8804
8855
|
if (navigation.state === "idle") {
|
|
8805
|
-
let key = getScrollRestorationKey(
|
|
8856
|
+
let key = getScrollRestorationKey(location2, matches, basename, getKey);
|
|
8806
8857
|
savedScrollPositions[key] = window.scrollY;
|
|
8807
8858
|
}
|
|
8808
8859
|
try {
|
|
@@ -8817,7 +8868,7 @@ function useScrollRestoration({
|
|
|
8817
8868
|
);
|
|
8818
8869
|
}
|
|
8819
8870
|
window.history.scrollRestoration = "auto";
|
|
8820
|
-
}, [navigation.state, getKey, basename,
|
|
8871
|
+
}, [navigation.state, getKey, basename, location2, matches, storageKey])
|
|
8821
8872
|
);
|
|
8822
8873
|
if (typeof document !== "undefined") {
|
|
8823
8874
|
React10.useLayoutEffect(() => {
|
|
@@ -8835,7 +8886,7 @@ function useScrollRestoration({
|
|
|
8835
8886
|
let disableScrollRestoration = router?.enableScrollRestoration(
|
|
8836
8887
|
savedScrollPositions,
|
|
8837
8888
|
() => window.scrollY,
|
|
8838
|
-
getKey ? (
|
|
8889
|
+
getKey ? (location3, matches2) => getScrollRestorationKey(location3, matches2, basename, getKey) : void 0
|
|
8839
8890
|
);
|
|
8840
8891
|
return () => disableScrollRestoration && disableScrollRestoration();
|
|
8841
8892
|
}, [router, basename, getKey]);
|
|
@@ -8847,9 +8898,9 @@ function useScrollRestoration({
|
|
|
8847
8898
|
window.scrollTo(0, restoreScrollPosition);
|
|
8848
8899
|
return;
|
|
8849
8900
|
}
|
|
8850
|
-
if (
|
|
8901
|
+
if (location2.hash) {
|
|
8851
8902
|
let el = document.getElementById(
|
|
8852
|
-
decodeURIComponent(
|
|
8903
|
+
decodeURIComponent(location2.hash.slice(1))
|
|
8853
8904
|
);
|
|
8854
8905
|
if (el) {
|
|
8855
8906
|
el.scrollIntoView();
|
|
@@ -8860,7 +8911,7 @@ function useScrollRestoration({
|
|
|
8860
8911
|
return;
|
|
8861
8912
|
}
|
|
8862
8913
|
window.scrollTo(0, 0);
|
|
8863
|
-
}, [
|
|
8914
|
+
}, [location2, restoreScrollPosition, preventScrollReset]);
|
|
8864
8915
|
}
|
|
8865
8916
|
}
|
|
8866
8917
|
function useBeforeUnload(callback, options) {
|
|
@@ -8933,7 +8984,7 @@ function StaticRouter({
|
|
|
8933
8984
|
locationProp = parsePath(locationProp);
|
|
8934
8985
|
}
|
|
8935
8986
|
let action = "POP" /* Pop */;
|
|
8936
|
-
let
|
|
8987
|
+
let location2 = {
|
|
8937
8988
|
pathname: locationProp.pathname || "/",
|
|
8938
8989
|
search: locationProp.search || "",
|
|
8939
8990
|
hash: locationProp.hash || "",
|
|
@@ -8946,7 +8997,7 @@ function StaticRouter({
|
|
|
8946
8997
|
{
|
|
8947
8998
|
basename,
|
|
8948
8999
|
children,
|
|
8949
|
-
location,
|
|
9000
|
+
location: location2,
|
|
8950
9001
|
navigationType: action,
|
|
8951
9002
|
navigator: staticNavigator,
|
|
8952
9003
|
static: true
|
|
@@ -9165,6 +9216,9 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
9165
9216
|
_internalFetchControllers: /* @__PURE__ */ new Map(),
|
|
9166
9217
|
_internalSetRoutes() {
|
|
9167
9218
|
throw msg("_internalSetRoutes");
|
|
9219
|
+
},
|
|
9220
|
+
_internalSetStateDoNotUseOrYouWillBreakYourApp() {
|
|
9221
|
+
throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
|
|
9168
9222
|
}
|
|
9169
9223
|
};
|
|
9170
9224
|
}
|
|
@@ -9239,7 +9293,6 @@ function ServerRouter({
|
|
|
9239
9293
|
future: context.future,
|
|
9240
9294
|
ssr: context.ssr,
|
|
9241
9295
|
isSpaMode: context.isSpaMode,
|
|
9242
|
-
routeDiscovery: context.routeDiscovery,
|
|
9243
9296
|
serializeError: context.serializeError,
|
|
9244
9297
|
renderMeta: context.renderMeta
|
|
9245
9298
|
}
|
|
@@ -9289,8 +9342,7 @@ function createRoutesStub(routes, unstable_getContext) {
|
|
|
9289
9342
|
},
|
|
9290
9343
|
routeModules: {},
|
|
9291
9344
|
ssr: false,
|
|
9292
|
-
isSpaMode: false
|
|
9293
|
-
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }
|
|
9345
|
+
isSpaMode: false
|
|
9294
9346
|
};
|
|
9295
9347
|
let patched = processRoutes(
|
|
9296
9348
|
// @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
|
|
@@ -9694,26 +9746,6 @@ function invariant3(value, message) {
|
|
|
9694
9746
|
}
|
|
9695
9747
|
}
|
|
9696
9748
|
|
|
9697
|
-
// lib/server-runtime/dev.ts
|
|
9698
|
-
var globalDevServerHooksKey = "__reactRouterDevServerHooks";
|
|
9699
|
-
function setDevServerHooks(devServerHooks) {
|
|
9700
|
-
globalThis[globalDevServerHooksKey] = devServerHooks;
|
|
9701
|
-
}
|
|
9702
|
-
function getDevServerHooks() {
|
|
9703
|
-
return globalThis[globalDevServerHooksKey];
|
|
9704
|
-
}
|
|
9705
|
-
function getBuildTimeHeader(request, headerName) {
|
|
9706
|
-
if (typeof process !== "undefined") {
|
|
9707
|
-
try {
|
|
9708
|
-
if (process.env?.IS_RR_BUILD_REQUEST === "yes") {
|
|
9709
|
-
return request.headers.get(headerName);
|
|
9710
|
-
}
|
|
9711
|
-
} catch (e) {
|
|
9712
|
-
}
|
|
9713
|
-
}
|
|
9714
|
-
return null;
|
|
9715
|
-
}
|
|
9716
|
-
|
|
9717
9749
|
// lib/server-runtime/routes.ts
|
|
9718
9750
|
function groupRoutesByParentId2(manifest) {
|
|
9719
9751
|
let routes = {};
|
|
@@ -9745,11 +9777,10 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
|
|
|
9745
9777
|
// Need to use RR's version in the param typed here to permit the optional
|
|
9746
9778
|
// context even though we know it'll always be provided in remix
|
|
9747
9779
|
loader: route.module.loader ? async (args) => {
|
|
9748
|
-
|
|
9749
|
-
args.request
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
if (preRenderedData != null) {
|
|
9780
|
+
if (args.request.headers.has("X-React-Router-Prerender-Data")) {
|
|
9781
|
+
const preRenderedData = args.request.headers.get(
|
|
9782
|
+
"X-React-Router-Prerender-Data"
|
|
9783
|
+
);
|
|
9753
9784
|
let encoded = preRenderedData ? decodeURI(preRenderedData) : preRenderedData;
|
|
9754
9785
|
invariant3(encoded, "Missing prerendered data for route");
|
|
9755
9786
|
let uint8array = new TextEncoder().encode(encoded);
|
|
@@ -9824,12 +9855,21 @@ function createServerHandoffString(serverHandoff) {
|
|
|
9824
9855
|
return escapeHtml2(JSON.stringify(serverHandoff));
|
|
9825
9856
|
}
|
|
9826
9857
|
|
|
9858
|
+
// lib/server-runtime/dev.ts
|
|
9859
|
+
var globalDevServerHooksKey = "__reactRouterDevServerHooks";
|
|
9860
|
+
function setDevServerHooks(devServerHooks) {
|
|
9861
|
+
globalThis[globalDevServerHooksKey] = devServerHooks;
|
|
9862
|
+
}
|
|
9863
|
+
function getDevServerHooks() {
|
|
9864
|
+
return globalThis[globalDevServerHooksKey];
|
|
9865
|
+
}
|
|
9866
|
+
|
|
9827
9867
|
// lib/server-runtime/single-fetch.ts
|
|
9828
9868
|
var import_turbo_stream2 = require("turbo-stream");
|
|
9829
9869
|
|
|
9830
9870
|
// lib/server-runtime/headers.ts
|
|
9831
9871
|
var import_set_cookie_parser = require("set-cookie-parser");
|
|
9832
|
-
function getDocumentHeaders(
|
|
9872
|
+
function getDocumentHeaders(context, getRouteHeadersFn) {
|
|
9833
9873
|
let boundaryIdx = context.errors ? context.matches.findIndex((m) => context.errors[m.route.id]) : -1;
|
|
9834
9874
|
let matches = boundaryIdx >= 0 ? context.matches.slice(0, boundaryIdx + 1) : context.matches;
|
|
9835
9875
|
let errorHeaders;
|
|
@@ -9847,14 +9887,12 @@ function getDocumentHeaders(build, context) {
|
|
|
9847
9887
|
}
|
|
9848
9888
|
return matches.reduce((parentHeaders, match, idx) => {
|
|
9849
9889
|
let { id } = match.route;
|
|
9850
|
-
let route = build.routes[id];
|
|
9851
|
-
invariant3(route, `Route with id "${id}" not found in build`);
|
|
9852
|
-
let routeModule = route.module;
|
|
9853
9890
|
let loaderHeaders = context.loaderHeaders[id] || new Headers();
|
|
9854
9891
|
let actionHeaders = context.actionHeaders[id] || new Headers();
|
|
9855
9892
|
let includeErrorHeaders = errorHeaders != null && idx === matches.length - 1;
|
|
9856
9893
|
let includeErrorCookies = includeErrorHeaders && errorHeaders !== loaderHeaders && errorHeaders !== actionHeaders;
|
|
9857
|
-
|
|
9894
|
+
let headersFn = getRouteHeadersFn(match);
|
|
9895
|
+
if (headersFn == null) {
|
|
9858
9896
|
let headers2 = new Headers(parentHeaders);
|
|
9859
9897
|
if (includeErrorCookies) {
|
|
9860
9898
|
prependCookies(errorHeaders, headers2);
|
|
@@ -9864,12 +9902,12 @@ function getDocumentHeaders(build, context) {
|
|
|
9864
9902
|
return headers2;
|
|
9865
9903
|
}
|
|
9866
9904
|
let headers = new Headers(
|
|
9867
|
-
|
|
9905
|
+
typeof headersFn === "function" ? headersFn({
|
|
9868
9906
|
loaderHeaders,
|
|
9869
9907
|
parentHeaders,
|
|
9870
9908
|
actionHeaders,
|
|
9871
9909
|
errorHeaders: includeErrorHeaders ? errorHeaders : void 0
|
|
9872
|
-
}) :
|
|
9910
|
+
}) : headersFn
|
|
9873
9911
|
);
|
|
9874
9912
|
if (includeErrorCookies) {
|
|
9875
9913
|
prependCookies(errorHeaders, headers);
|
|
@@ -9894,6 +9932,7 @@ function prependCookies(parentHeaders, childHeaders) {
|
|
|
9894
9932
|
}
|
|
9895
9933
|
|
|
9896
9934
|
// lib/server-runtime/single-fetch.ts
|
|
9935
|
+
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
9897
9936
|
var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
9898
9937
|
...NO_BODY_STATUS_CODES,
|
|
9899
9938
|
304
|
|
@@ -9901,7 +9940,10 @@ var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
|
9901
9940
|
async function singleFetchAction(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
9902
9941
|
try {
|
|
9903
9942
|
let respond2 = function(context) {
|
|
9904
|
-
let headers = getDocumentHeaders(
|
|
9943
|
+
let headers = getDocumentHeaders(
|
|
9944
|
+
context,
|
|
9945
|
+
(m) => build.routes[m.route.id]?.module.headers
|
|
9946
|
+
);
|
|
9905
9947
|
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
9906
9948
|
return generateSingleFetchResponse(request, build, serverMode, {
|
|
9907
9949
|
result: getSingleFetchRedirect(
|
|
@@ -9976,7 +10018,10 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
|
|
|
9976
10018
|
async function singleFetchLoaders(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
9977
10019
|
try {
|
|
9978
10020
|
let respond2 = function(context) {
|
|
9979
|
-
let headers = getDocumentHeaders(
|
|
10021
|
+
let headers = getDocumentHeaders(
|
|
10022
|
+
context,
|
|
10023
|
+
(m) => build.routes[m.route.id]?.module.headers
|
|
10024
|
+
);
|
|
9980
10025
|
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
9981
10026
|
return generateSingleFetchResponse(request, build, serverMode, {
|
|
9982
10027
|
result: {
|
|
@@ -10232,10 +10277,9 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10232
10277
|
if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
|
|
10233
10278
|
normalizedPath = normalizedPath.slice(0, -1);
|
|
10234
10279
|
}
|
|
10235
|
-
let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
|
|
10236
10280
|
if (!_build.ssr) {
|
|
10237
10281
|
if (_build.prerender.length === 0) {
|
|
10238
|
-
|
|
10282
|
+
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
10239
10283
|
} else if (!_build.prerender.includes(normalizedPath) && !_build.prerender.includes(normalizedPath + "/")) {
|
|
10240
10284
|
if (url.pathname.endsWith(".data")) {
|
|
10241
10285
|
errorHandler(
|
|
@@ -10255,14 +10299,11 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10255
10299
|
statusText: "Not Found"
|
|
10256
10300
|
});
|
|
10257
10301
|
} else {
|
|
10258
|
-
|
|
10302
|
+
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
10259
10303
|
}
|
|
10260
10304
|
}
|
|
10261
10305
|
}
|
|
10262
|
-
let manifestUrl =
|
|
10263
|
-
_build.routeDiscovery.manifestPath,
|
|
10264
|
-
normalizedBasename
|
|
10265
|
-
);
|
|
10306
|
+
let manifestUrl = `${normalizedBasename}/__manifest`.replace(/\/+/g, "/");
|
|
10266
10307
|
if (url.pathname === manifestUrl) {
|
|
10267
10308
|
try {
|
|
10268
10309
|
let res = await handleManifestRequest(_build, routes, url);
|
|
@@ -10272,7 +10313,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10272
10313
|
return new Response("Unknown Server Error", { status: 500 });
|
|
10273
10314
|
}
|
|
10274
10315
|
}
|
|
10275
|
-
let matches = matchServerRoutes(routes,
|
|
10316
|
+
let matches = matchServerRoutes(routes, url.pathname, _build.basename);
|
|
10276
10317
|
if (matches && matches.length > 0) {
|
|
10277
10318
|
Object.assign(params, matches[0].params);
|
|
10278
10319
|
}
|
|
@@ -10327,7 +10368,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10327
10368
|
);
|
|
10328
10369
|
}
|
|
10329
10370
|
}
|
|
10330
|
-
} else if (!
|
|
10371
|
+
} else if (!request.headers.has("X-React-Router-SPA-Mode") && matches && matches[matches.length - 1].route.module.default == null && matches[matches.length - 1].route.module.ErrorBoundary == null) {
|
|
10331
10372
|
response = await handleResourceRequest(
|
|
10332
10373
|
serverMode,
|
|
10333
10374
|
_build,
|
|
@@ -10352,7 +10393,6 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10352
10393
|
request,
|
|
10353
10394
|
loadContext,
|
|
10354
10395
|
handleError,
|
|
10355
|
-
isSpaMode,
|
|
10356
10396
|
criticalCss
|
|
10357
10397
|
);
|
|
10358
10398
|
}
|
|
@@ -10428,7 +10468,8 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
|
|
|
10428
10468
|
);
|
|
10429
10469
|
return response;
|
|
10430
10470
|
}
|
|
10431
|
-
async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError,
|
|
10471
|
+
async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, criticalCss) {
|
|
10472
|
+
let isSpaMode = request.headers.has("X-React-Router-SPA-Mode");
|
|
10432
10473
|
try {
|
|
10433
10474
|
let response = await staticHandler.query(request, {
|
|
10434
10475
|
requestContext: loadContext,
|
|
@@ -10443,7 +10484,10 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10443
10484
|
if (isResponse(context)) {
|
|
10444
10485
|
return context;
|
|
10445
10486
|
}
|
|
10446
|
-
let headers = getDocumentHeaders(
|
|
10487
|
+
let headers = getDocumentHeaders(
|
|
10488
|
+
context,
|
|
10489
|
+
(m) => build.routes[m.route.id]?.module.headers
|
|
10490
|
+
);
|
|
10447
10491
|
if (SERVER_NO_BODY_STATUS_CODES.has(context.statusCode)) {
|
|
10448
10492
|
return new Response(null, { status: context.statusCode, headers });
|
|
10449
10493
|
}
|
|
@@ -10460,21 +10504,17 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10460
10504
|
actionData: context.actionData,
|
|
10461
10505
|
errors: serializeErrors2(context.errors, serverMode)
|
|
10462
10506
|
};
|
|
10463
|
-
let baseServerHandoff = {
|
|
10464
|
-
basename: build.basename,
|
|
10465
|
-
future: build.future,
|
|
10466
|
-
routeDiscovery: build.routeDiscovery,
|
|
10467
|
-
ssr: build.ssr,
|
|
10468
|
-
isSpaMode: isSpaMode2
|
|
10469
|
-
};
|
|
10470
10507
|
let entryContext = {
|
|
10471
10508
|
manifest: build.assets,
|
|
10472
10509
|
routeModules: createEntryRouteModules(build.routes),
|
|
10473
10510
|
staticHandlerContext: context,
|
|
10474
10511
|
criticalCss,
|
|
10475
10512
|
serverHandoffString: createServerHandoffString({
|
|
10476
|
-
|
|
10477
|
-
criticalCss
|
|
10513
|
+
basename: build.basename,
|
|
10514
|
+
criticalCss,
|
|
10515
|
+
future: build.future,
|
|
10516
|
+
ssr: build.ssr,
|
|
10517
|
+
isSpaMode: isSpaMode2
|
|
10478
10518
|
}),
|
|
10479
10519
|
serverHandoffStream: encodeViaTurboStream(
|
|
10480
10520
|
state,
|
|
@@ -10485,7 +10525,6 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10485
10525
|
renderMeta: {},
|
|
10486
10526
|
future: build.future,
|
|
10487
10527
|
ssr: build.ssr,
|
|
10488
|
-
routeDiscovery: build.routeDiscovery,
|
|
10489
10528
|
isSpaMode: isSpaMode2,
|
|
10490
10529
|
serializeError: (err) => serializeError(err, serverMode)
|
|
10491
10530
|
};
|
|
@@ -10528,7 +10567,12 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10528
10567
|
entryContext = {
|
|
10529
10568
|
...entryContext,
|
|
10530
10569
|
staticHandlerContext: context,
|
|
10531
|
-
serverHandoffString: createServerHandoffString(
|
|
10570
|
+
serverHandoffString: createServerHandoffString({
|
|
10571
|
+
basename: build.basename,
|
|
10572
|
+
future: build.future,
|
|
10573
|
+
ssr: build.ssr,
|
|
10574
|
+
isSpaMode: isSpaMode2
|
|
10575
|
+
}),
|
|
10532
10576
|
serverHandoffStream: encodeViaTurboStream(
|
|
10533
10577
|
state2,
|
|
10534
10578
|
request.signal,
|
|
@@ -10701,7 +10745,7 @@ function createSessionStorage({
|
|
|
10701
10745
|
function warnOnceAboutSigningSessionCookie(cookie) {
|
|
10702
10746
|
warnOnce(
|
|
10703
10747
|
cookie.isSigned,
|
|
10704
|
-
`The "${cookie.name}" cookie is not signed, but session cookies should be signed to prevent tampering on the client before they are sent back to the server. See https://
|
|
10748
|
+
`The "${cookie.name}" cookie is not signed, but session cookies should be signed to prevent tampering on the client before they are sent back to the server. See https://remix.run/utils/cookies#signing-cookies for more information.`
|
|
10705
10749
|
);
|
|
10706
10750
|
}
|
|
10707
10751
|
|
|
@@ -10781,6 +10825,680 @@ function href(path, ...args) {
|
|
|
10781
10825
|
}).filter((segment) => segment !== void 0).join("/");
|
|
10782
10826
|
}
|
|
10783
10827
|
|
|
10828
|
+
// lib/rsc/browser.tsx
|
|
10829
|
+
var React14 = __toESM(require("react"));
|
|
10830
|
+
|
|
10831
|
+
// lib/dom/ssr/hydration.tsx
|
|
10832
|
+
function getHydrationData(state, routes, getRouteInfo, location2, basename, isSpaMode) {
|
|
10833
|
+
let hydrationData = {
|
|
10834
|
+
...state,
|
|
10835
|
+
loaderData: { ...state.loaderData }
|
|
10836
|
+
};
|
|
10837
|
+
let initialMatches = matchRoutes(routes, location2, basename);
|
|
10838
|
+
if (initialMatches) {
|
|
10839
|
+
for (let match of initialMatches) {
|
|
10840
|
+
let routeId = match.route.id;
|
|
10841
|
+
let routeInfo = getRouteInfo(routeId);
|
|
10842
|
+
if (shouldHydrateRouteLoader(
|
|
10843
|
+
routeId,
|
|
10844
|
+
routeInfo.clientLoader,
|
|
10845
|
+
routeInfo.hasLoader,
|
|
10846
|
+
isSpaMode
|
|
10847
|
+
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
|
|
10848
|
+
delete hydrationData.loaderData[routeId];
|
|
10849
|
+
} else if (!routeInfo.hasLoader) {
|
|
10850
|
+
hydrationData.loaderData[routeId] = null;
|
|
10851
|
+
}
|
|
10852
|
+
}
|
|
10853
|
+
}
|
|
10854
|
+
return hydrationData;
|
|
10855
|
+
}
|
|
10856
|
+
|
|
10857
|
+
// lib/rsc/browser.tsx
|
|
10858
|
+
function createCallServer({
|
|
10859
|
+
decode: decode2,
|
|
10860
|
+
encodeAction
|
|
10861
|
+
}) {
|
|
10862
|
+
let landedActionId = 0;
|
|
10863
|
+
return async (id, args) => {
|
|
10864
|
+
let actionId = window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
|
|
10865
|
+
const response = await fetch(location.href, {
|
|
10866
|
+
body: await encodeAction(args),
|
|
10867
|
+
method: "POST",
|
|
10868
|
+
headers: {
|
|
10869
|
+
Accept: "text/x-component",
|
|
10870
|
+
"rsc-action-id": id
|
|
10871
|
+
}
|
|
10872
|
+
});
|
|
10873
|
+
if (!response.body) {
|
|
10874
|
+
throw new Error("No response body");
|
|
10875
|
+
}
|
|
10876
|
+
const payload = await decode2(response.body);
|
|
10877
|
+
if (payload.type !== "action") {
|
|
10878
|
+
throw new Error("Unexpected payload type");
|
|
10879
|
+
}
|
|
10880
|
+
if (payload.rerender) {
|
|
10881
|
+
(async () => {
|
|
10882
|
+
const rerender = await payload.rerender;
|
|
10883
|
+
if (!rerender) return;
|
|
10884
|
+
if (landedActionId < actionId && window.__routerActionID <= actionId) {
|
|
10885
|
+
landedActionId = actionId;
|
|
10886
|
+
if (rerender.type === "redirect") {
|
|
10887
|
+
if (rerender.reload) {
|
|
10888
|
+
window.location.href = rerender.location;
|
|
10889
|
+
return;
|
|
10890
|
+
}
|
|
10891
|
+
window.__router.navigate(rerender.location, {
|
|
10892
|
+
replace: rerender.replace
|
|
10893
|
+
});
|
|
10894
|
+
return;
|
|
10895
|
+
}
|
|
10896
|
+
let lastMatch;
|
|
10897
|
+
for (const match of rerender.matches) {
|
|
10898
|
+
window.__router.patchRoutes(
|
|
10899
|
+
lastMatch?.id ?? null,
|
|
10900
|
+
[createRouteFromServerManifest(match)],
|
|
10901
|
+
true
|
|
10902
|
+
);
|
|
10903
|
+
lastMatch = match;
|
|
10904
|
+
}
|
|
10905
|
+
window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({});
|
|
10906
|
+
React14.startTransition(() => {
|
|
10907
|
+
window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({
|
|
10908
|
+
loaderData: Object.assign(
|
|
10909
|
+
{},
|
|
10910
|
+
window.__router.state.loaderData,
|
|
10911
|
+
rerender.loaderData
|
|
10912
|
+
),
|
|
10913
|
+
errors: rerender.errors ? Object.assign(
|
|
10914
|
+
{},
|
|
10915
|
+
window.__router.state.errors,
|
|
10916
|
+
rerender.errors
|
|
10917
|
+
) : null
|
|
10918
|
+
});
|
|
10919
|
+
});
|
|
10920
|
+
}
|
|
10921
|
+
})();
|
|
10922
|
+
}
|
|
10923
|
+
return payload.actionResult;
|
|
10924
|
+
};
|
|
10925
|
+
}
|
|
10926
|
+
function createRouterFromPayload({
|
|
10927
|
+
decode: decode2,
|
|
10928
|
+
payload
|
|
10929
|
+
}) {
|
|
10930
|
+
if (window.__router) return window.__router;
|
|
10931
|
+
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
10932
|
+
let patches = /* @__PURE__ */ new Map();
|
|
10933
|
+
payload.patches?.forEach((patch) => {
|
|
10934
|
+
invariant(patch.parentId, "Invalid patch parentId");
|
|
10935
|
+
if (!patches.has(patch.parentId)) {
|
|
10936
|
+
patches.set(patch.parentId, []);
|
|
10937
|
+
}
|
|
10938
|
+
patches.get(patch.parentId)?.push(patch);
|
|
10939
|
+
});
|
|
10940
|
+
let routes = payload.matches.reduceRight((previous, match) => {
|
|
10941
|
+
const route = createRouteFromServerManifest(
|
|
10942
|
+
match,
|
|
10943
|
+
payload
|
|
10944
|
+
);
|
|
10945
|
+
if (previous.length > 0) {
|
|
10946
|
+
route.children = previous;
|
|
10947
|
+
let childrenToPatch = patches.get(match.id);
|
|
10948
|
+
if (childrenToPatch) {
|
|
10949
|
+
route.children.push(
|
|
10950
|
+
...childrenToPatch.map((r) => createRouteFromServerManifest(r))
|
|
10951
|
+
);
|
|
10952
|
+
}
|
|
10953
|
+
}
|
|
10954
|
+
return [route];
|
|
10955
|
+
}, []);
|
|
10956
|
+
window.__router = createRouter({
|
|
10957
|
+
routes,
|
|
10958
|
+
basename: payload.basename,
|
|
10959
|
+
history: createBrowserHistory(),
|
|
10960
|
+
hydrationData: getHydrationData(
|
|
10961
|
+
{
|
|
10962
|
+
loaderData: payload.loaderData,
|
|
10963
|
+
actionData: payload.actionData,
|
|
10964
|
+
errors: payload.errors
|
|
10965
|
+
},
|
|
10966
|
+
routes,
|
|
10967
|
+
(routeId) => {
|
|
10968
|
+
let match = payload.matches.find((m) => m.id === routeId);
|
|
10969
|
+
invariant(match, "Route not found in payload");
|
|
10970
|
+
return {
|
|
10971
|
+
clientLoader: match.clientLoader,
|
|
10972
|
+
hasLoader: match.hasLoader,
|
|
10973
|
+
hasHydrateFallback: match.hydrateFallbackElement != null
|
|
10974
|
+
};
|
|
10975
|
+
},
|
|
10976
|
+
payload.location,
|
|
10977
|
+
void 0,
|
|
10978
|
+
false
|
|
10979
|
+
),
|
|
10980
|
+
async patchRoutesOnNavigation({ patch, path, signal }) {
|
|
10981
|
+
let response = await fetch(`${path}.manifest`, { signal });
|
|
10982
|
+
if (!response.body || response.status < 200 || response.status >= 300) {
|
|
10983
|
+
throw new Error("Unable to fetch new route matches from the server");
|
|
10984
|
+
}
|
|
10985
|
+
let payload2 = await decode2(response.body);
|
|
10986
|
+
if (payload2.type !== "manifest") {
|
|
10987
|
+
throw new Error("Failed to patch routes on navigation");
|
|
10988
|
+
}
|
|
10989
|
+
payload2.matches.forEach(
|
|
10990
|
+
(match, i) => patch(payload2.matches[i - 1]?.id ?? null, [
|
|
10991
|
+
createRouteFromServerManifest(match)
|
|
10992
|
+
])
|
|
10993
|
+
);
|
|
10994
|
+
payload2.patches.forEach((p) => {
|
|
10995
|
+
patch(p.parentId ?? null, [createRouteFromServerManifest(p)]);
|
|
10996
|
+
});
|
|
10997
|
+
},
|
|
10998
|
+
// FIXME: Pass `build.ssr` and `build.basename` into this function
|
|
10999
|
+
dataStrategy: getRSCSingleFetchDataStrategy(
|
|
11000
|
+
() => window.__router,
|
|
11001
|
+
true,
|
|
11002
|
+
void 0,
|
|
11003
|
+
decode2
|
|
11004
|
+
)
|
|
11005
|
+
});
|
|
11006
|
+
if (window.__router.state.initialized) {
|
|
11007
|
+
window.__routerInitialized = true;
|
|
11008
|
+
window.__router.initialize();
|
|
11009
|
+
} else {
|
|
11010
|
+
window.__routerInitialized = false;
|
|
11011
|
+
}
|
|
11012
|
+
let lastLoaderData = void 0;
|
|
11013
|
+
window.__router.subscribe(({ loaderData, actionData }) => {
|
|
11014
|
+
if (lastLoaderData !== loaderData) {
|
|
11015
|
+
window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
|
|
11016
|
+
}
|
|
11017
|
+
});
|
|
11018
|
+
return window.__router;
|
|
11019
|
+
}
|
|
11020
|
+
var renderedRoutesContext = unstable_createContext();
|
|
11021
|
+
function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, decode2) {
|
|
11022
|
+
let dataStrategy = getSingleFetchDataStrategyImpl(
|
|
11023
|
+
getRouter,
|
|
11024
|
+
(match) => {
|
|
11025
|
+
let M = match;
|
|
11026
|
+
return {
|
|
11027
|
+
hasLoader: M.route.hasLoader,
|
|
11028
|
+
hasClientLoader: M.route.hasClientLoader,
|
|
11029
|
+
hasAction: M.route.hasAction,
|
|
11030
|
+
hasClientAction: M.route.hasClientAction,
|
|
11031
|
+
hasShouldRevalidate: M.route.hasShouldRevalidate
|
|
11032
|
+
};
|
|
11033
|
+
},
|
|
11034
|
+
// pass map into fetchAndDecode so it can add payloads
|
|
11035
|
+
getFetchAndDecodeViaRSC(decode2),
|
|
11036
|
+
ssr,
|
|
11037
|
+
basename
|
|
11038
|
+
);
|
|
11039
|
+
return async (args) => args.unstable_runClientMiddleware(async () => {
|
|
11040
|
+
let context = args.context;
|
|
11041
|
+
context.set(renderedRoutesContext, []);
|
|
11042
|
+
let results = await dataStrategy(args);
|
|
11043
|
+
const renderedRouteById = new Map(
|
|
11044
|
+
context.get(renderedRoutesContext).map((r) => [r.id, r])
|
|
11045
|
+
);
|
|
11046
|
+
for (const match of args.matches) {
|
|
11047
|
+
const rendered = renderedRouteById.get(match.route.id);
|
|
11048
|
+
if (rendered) {
|
|
11049
|
+
window.__router.patchRoutes(
|
|
11050
|
+
rendered.parentId ?? null,
|
|
11051
|
+
[createRouteFromServerManifest(rendered)],
|
|
11052
|
+
true
|
|
11053
|
+
);
|
|
11054
|
+
}
|
|
11055
|
+
}
|
|
11056
|
+
return results;
|
|
11057
|
+
});
|
|
11058
|
+
}
|
|
11059
|
+
function getFetchAndDecodeViaRSC(decode2) {
|
|
11060
|
+
return async (args, basename, targetRoutes) => {
|
|
11061
|
+
let { request, context } = args;
|
|
11062
|
+
let url = singleFetchUrl(request.url, basename, "rsc");
|
|
11063
|
+
if (request.method === "GET") {
|
|
11064
|
+
url = stripIndexParam(url);
|
|
11065
|
+
if (targetRoutes) {
|
|
11066
|
+
url.searchParams.set("_routes", targetRoutes.join(","));
|
|
11067
|
+
}
|
|
11068
|
+
}
|
|
11069
|
+
let res = await fetch(url, await createRequestInit(request));
|
|
11070
|
+
if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
|
|
11071
|
+
throw new ErrorResponseImpl(404, "Not Found", true);
|
|
11072
|
+
}
|
|
11073
|
+
invariant(res.body, "No response body to decode");
|
|
11074
|
+
try {
|
|
11075
|
+
const payload = await decode2(res.body);
|
|
11076
|
+
if (payload.type === "redirect") {
|
|
11077
|
+
return {
|
|
11078
|
+
status: res.status,
|
|
11079
|
+
data: {
|
|
11080
|
+
redirect: {
|
|
11081
|
+
redirect: payload.location,
|
|
11082
|
+
reload: false,
|
|
11083
|
+
replace: payload.replace,
|
|
11084
|
+
revalidate: false,
|
|
11085
|
+
status: payload.status
|
|
11086
|
+
}
|
|
11087
|
+
}
|
|
11088
|
+
};
|
|
11089
|
+
}
|
|
11090
|
+
if (payload.type !== "render") {
|
|
11091
|
+
throw new Error("Unexpected payload type");
|
|
11092
|
+
}
|
|
11093
|
+
context.get(renderedRoutesContext).push(...payload.matches);
|
|
11094
|
+
let results = { routes: {} };
|
|
11095
|
+
const dataKey = isMutationMethod(request.method) ? "actionData" : "loaderData";
|
|
11096
|
+
for (let [routeId, data2] of Object.entries(payload[dataKey] || {})) {
|
|
11097
|
+
results.routes[routeId] = { data: data2 };
|
|
11098
|
+
}
|
|
11099
|
+
if (payload.errors) {
|
|
11100
|
+
for (let [routeId, error] of Object.entries(payload.errors)) {
|
|
11101
|
+
results.routes[routeId] = { error };
|
|
11102
|
+
}
|
|
11103
|
+
}
|
|
11104
|
+
return { status: res.status, data: results };
|
|
11105
|
+
} catch (e) {
|
|
11106
|
+
throw new Error("Unable to decode RSC response");
|
|
11107
|
+
}
|
|
11108
|
+
};
|
|
11109
|
+
}
|
|
11110
|
+
function RSCHydratedRouter({
|
|
11111
|
+
decode: decode2,
|
|
11112
|
+
payload
|
|
11113
|
+
}) {
|
|
11114
|
+
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
11115
|
+
let router = React14.useMemo(
|
|
11116
|
+
() => createRouterFromPayload({ decode: decode2, payload }),
|
|
11117
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11118
|
+
[]
|
|
11119
|
+
);
|
|
11120
|
+
React14.useLayoutEffect(() => {
|
|
11121
|
+
if (!window.__routerInitialized) {
|
|
11122
|
+
window.__routerInitialized = true;
|
|
11123
|
+
window.__router.initialize();
|
|
11124
|
+
}
|
|
11125
|
+
}, []);
|
|
11126
|
+
const frameworkContext = {
|
|
11127
|
+
future: {
|
|
11128
|
+
// These flags have no runtime impact so can always be false. If we add
|
|
11129
|
+
// flags that drive runtime behavior they'll need to be proxied through.
|
|
11130
|
+
unstable_middleware: false,
|
|
11131
|
+
unstable_subResourceIntegrity: false
|
|
11132
|
+
},
|
|
11133
|
+
isSpaMode: true,
|
|
11134
|
+
ssr: true,
|
|
11135
|
+
criticalCss: "",
|
|
11136
|
+
manifest: {
|
|
11137
|
+
routes: {},
|
|
11138
|
+
version: "1",
|
|
11139
|
+
url: "",
|
|
11140
|
+
entry: {
|
|
11141
|
+
module: "",
|
|
11142
|
+
imports: []
|
|
11143
|
+
}
|
|
11144
|
+
},
|
|
11145
|
+
routeModules: {}
|
|
11146
|
+
};
|
|
11147
|
+
return /* @__PURE__ */ React14.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React14.createElement(RouterProvider, { router }));
|
|
11148
|
+
}
|
|
11149
|
+
function createRouteFromServerManifest(match, payload) {
|
|
11150
|
+
let hasInitialData = payload && match.id in payload.loaderData;
|
|
11151
|
+
let initialData = payload?.loaderData[match.id];
|
|
11152
|
+
let hasInitialError = payload?.errors && match.id in payload.errors;
|
|
11153
|
+
let initialError = payload?.errors?.[match.id];
|
|
11154
|
+
let isHydrationRequest = match.clientLoader?.hydrate === true || !match.hasLoader;
|
|
11155
|
+
let dataRoute = {
|
|
11156
|
+
id: match.id,
|
|
11157
|
+
element: match.element,
|
|
11158
|
+
errorElement: match.errorElement,
|
|
11159
|
+
handle: match.handle,
|
|
11160
|
+
hasErrorBoundary: match.hasErrorBoundary,
|
|
11161
|
+
hydrateFallbackElement: match.hydrateFallbackElement,
|
|
11162
|
+
index: match.index,
|
|
11163
|
+
loader: match.clientLoader ? async (args, singleFetch) => {
|
|
11164
|
+
try {
|
|
11165
|
+
let result = await match.clientLoader({
|
|
11166
|
+
...args,
|
|
11167
|
+
serverLoader: () => {
|
|
11168
|
+
preventInvalidServerHandlerCall2(
|
|
11169
|
+
"loader",
|
|
11170
|
+
match.id,
|
|
11171
|
+
match.hasLoader
|
|
11172
|
+
);
|
|
11173
|
+
if (isHydrationRequest) {
|
|
11174
|
+
if (hasInitialData) {
|
|
11175
|
+
return initialData;
|
|
11176
|
+
}
|
|
11177
|
+
if (hasInitialError) {
|
|
11178
|
+
throw initialError;
|
|
11179
|
+
}
|
|
11180
|
+
}
|
|
11181
|
+
return callSingleFetch(singleFetch);
|
|
11182
|
+
}
|
|
11183
|
+
});
|
|
11184
|
+
return result;
|
|
11185
|
+
} finally {
|
|
11186
|
+
isHydrationRequest = false;
|
|
11187
|
+
}
|
|
11188
|
+
} : (
|
|
11189
|
+
// We always make the call in this RSC world since even if we don't
|
|
11190
|
+
// have a `loader` we may need to get the `element` implementation
|
|
11191
|
+
(_, singleFetch) => callSingleFetch(singleFetch)
|
|
11192
|
+
),
|
|
11193
|
+
action: match.clientAction ? (args, singleFetch) => match.clientAction({
|
|
11194
|
+
...args,
|
|
11195
|
+
serverAction: async () => {
|
|
11196
|
+
preventInvalidServerHandlerCall2(
|
|
11197
|
+
"loader",
|
|
11198
|
+
match.id,
|
|
11199
|
+
match.hasLoader
|
|
11200
|
+
);
|
|
11201
|
+
return await callSingleFetch(singleFetch);
|
|
11202
|
+
}
|
|
11203
|
+
}) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : void 0,
|
|
11204
|
+
path: match.path,
|
|
11205
|
+
shouldRevalidate: match.shouldRevalidate,
|
|
11206
|
+
// We always have a "loader" in this RSC world since even if we don't
|
|
11207
|
+
// have a `loader` we may need to get the `element` implementation
|
|
11208
|
+
hasLoader: true,
|
|
11209
|
+
hasClientLoader: match.clientLoader != null,
|
|
11210
|
+
hasAction: match.hasAction,
|
|
11211
|
+
hasClientAction: match.clientAction != null,
|
|
11212
|
+
hasShouldRevalidate: match.shouldRevalidate != null
|
|
11213
|
+
};
|
|
11214
|
+
if (typeof dataRoute.loader === "function") {
|
|
11215
|
+
dataRoute.loader.hydrate = shouldHydrateRouteLoader(
|
|
11216
|
+
match.id,
|
|
11217
|
+
match.clientLoader,
|
|
11218
|
+
match.hasLoader,
|
|
11219
|
+
false
|
|
11220
|
+
);
|
|
11221
|
+
}
|
|
11222
|
+
return dataRoute;
|
|
11223
|
+
}
|
|
11224
|
+
function callSingleFetch(singleFetch) {
|
|
11225
|
+
invariant(typeof singleFetch === "function", "Invalid singleFetch parameter");
|
|
11226
|
+
return singleFetch();
|
|
11227
|
+
}
|
|
11228
|
+
function preventInvalidServerHandlerCall2(type, routeId, hasHandler) {
|
|
11229
|
+
if (!hasHandler) {
|
|
11230
|
+
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
11231
|
+
let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${routeId}")`;
|
|
11232
|
+
console.error(msg);
|
|
11233
|
+
throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
|
|
11234
|
+
}
|
|
11235
|
+
}
|
|
11236
|
+
|
|
11237
|
+
// lib/rsc/server.ssr.tsx
|
|
11238
|
+
var React15 = __toESM(require("react"));
|
|
11239
|
+
|
|
11240
|
+
// lib/rsc/html-stream/server.ts
|
|
11241
|
+
var encoder2 = new TextEncoder();
|
|
11242
|
+
var trailer = "</body></html>";
|
|
11243
|
+
function injectRSCPayload(rscStream) {
|
|
11244
|
+
let decoder = new TextDecoder();
|
|
11245
|
+
let resolveFlightDataPromise;
|
|
11246
|
+
let flightDataPromise = new Promise(
|
|
11247
|
+
(resolve) => resolveFlightDataPromise = resolve
|
|
11248
|
+
);
|
|
11249
|
+
let startedRSC = false;
|
|
11250
|
+
let buffered = [];
|
|
11251
|
+
let timeout = null;
|
|
11252
|
+
function flushBufferedChunks(controller) {
|
|
11253
|
+
for (let chunk of buffered) {
|
|
11254
|
+
let buf = decoder.decode(chunk, { stream: true });
|
|
11255
|
+
if (buf.endsWith(trailer)) {
|
|
11256
|
+
buf = buf.slice(0, -trailer.length);
|
|
11257
|
+
}
|
|
11258
|
+
controller.enqueue(encoder2.encode(buf));
|
|
11259
|
+
}
|
|
11260
|
+
buffered.length = 0;
|
|
11261
|
+
timeout = null;
|
|
11262
|
+
}
|
|
11263
|
+
return new TransformStream({
|
|
11264
|
+
transform(chunk, controller) {
|
|
11265
|
+
buffered.push(chunk);
|
|
11266
|
+
if (timeout) {
|
|
11267
|
+
return;
|
|
11268
|
+
}
|
|
11269
|
+
timeout = setTimeout(async () => {
|
|
11270
|
+
flushBufferedChunks(controller);
|
|
11271
|
+
if (!startedRSC) {
|
|
11272
|
+
startedRSC = true;
|
|
11273
|
+
writeRSCStream(rscStream, controller).catch((err) => controller.error(err)).then(resolveFlightDataPromise);
|
|
11274
|
+
}
|
|
11275
|
+
}, 0);
|
|
11276
|
+
},
|
|
11277
|
+
async flush(controller) {
|
|
11278
|
+
await flightDataPromise;
|
|
11279
|
+
if (timeout) {
|
|
11280
|
+
clearTimeout(timeout);
|
|
11281
|
+
flushBufferedChunks(controller);
|
|
11282
|
+
}
|
|
11283
|
+
controller.enqueue(encoder2.encode("</body></html>"));
|
|
11284
|
+
}
|
|
11285
|
+
});
|
|
11286
|
+
}
|
|
11287
|
+
async function writeRSCStream(rscStream, controller) {
|
|
11288
|
+
let decoder = new TextDecoder("utf-8", { fatal: true });
|
|
11289
|
+
const reader = rscStream.getReader();
|
|
11290
|
+
try {
|
|
11291
|
+
let read;
|
|
11292
|
+
while ((read = await reader.read()) && !read.done) {
|
|
11293
|
+
const chunk = read.value;
|
|
11294
|
+
try {
|
|
11295
|
+
writeChunk(
|
|
11296
|
+
JSON.stringify(decoder.decode(chunk, { stream: true })),
|
|
11297
|
+
controller
|
|
11298
|
+
);
|
|
11299
|
+
} catch (err) {
|
|
11300
|
+
let base64 = JSON.stringify(btoa(String.fromCodePoint(...chunk)));
|
|
11301
|
+
writeChunk(
|
|
11302
|
+
`Uint8Array.from(atob(${base64}), m => m.codePointAt(0))`,
|
|
11303
|
+
controller
|
|
11304
|
+
);
|
|
11305
|
+
}
|
|
11306
|
+
}
|
|
11307
|
+
} finally {
|
|
11308
|
+
reader.releaseLock();
|
|
11309
|
+
}
|
|
11310
|
+
let remaining = decoder.decode();
|
|
11311
|
+
if (remaining.length) {
|
|
11312
|
+
writeChunk(JSON.stringify(remaining), controller);
|
|
11313
|
+
}
|
|
11314
|
+
}
|
|
11315
|
+
function writeChunk(chunk, controller) {
|
|
11316
|
+
controller.enqueue(
|
|
11317
|
+
encoder2.encode(
|
|
11318
|
+
`<script>${escapeScript(
|
|
11319
|
+
`(self.__FLIGHT_DATA||=[]).push(${chunk})`
|
|
11320
|
+
)}</script>`
|
|
11321
|
+
)
|
|
11322
|
+
);
|
|
11323
|
+
}
|
|
11324
|
+
function escapeScript(script) {
|
|
11325
|
+
return script.replace(/<!--/g, "<\\!--").replace(/<\/(script)/gi, "</\\$1");
|
|
11326
|
+
}
|
|
11327
|
+
|
|
11328
|
+
// lib/rsc/server.ssr.tsx
|
|
11329
|
+
async function routeRSCServerRequest(request, requestServer, decode2, renderHTML) {
|
|
11330
|
+
const url = new URL(request.url);
|
|
11331
|
+
let serverRequest = request;
|
|
11332
|
+
const isDataRequest = isReactServerRequest(url);
|
|
11333
|
+
const respondWithRSCPayload = isDataRequest || isManifestRequest(url) || request.headers.has("rsc-action-id");
|
|
11334
|
+
if (isDataRequest) {
|
|
11335
|
+
const serverURL = new URL(request.url);
|
|
11336
|
+
serverURL.pathname = serverURL.pathname.replace(/(_root)?\.rsc$/, "");
|
|
11337
|
+
let headers = new Headers(request.headers);
|
|
11338
|
+
headers.set("X-React-Router-Data-Request", "true");
|
|
11339
|
+
serverRequest = new Request(serverURL, {
|
|
11340
|
+
body: request.body,
|
|
11341
|
+
duplex: request.body ? "half" : void 0,
|
|
11342
|
+
headers,
|
|
11343
|
+
method: request.method,
|
|
11344
|
+
signal: request.signal
|
|
11345
|
+
});
|
|
11346
|
+
}
|
|
11347
|
+
const serverResponse = await requestServer(serverRequest);
|
|
11348
|
+
if (respondWithRSCPayload) {
|
|
11349
|
+
return serverResponse;
|
|
11350
|
+
}
|
|
11351
|
+
if (!serverResponse.body) {
|
|
11352
|
+
throw new Error("Missing body in server response");
|
|
11353
|
+
}
|
|
11354
|
+
const serverResponseB = serverResponse.clone();
|
|
11355
|
+
if (!serverResponseB.body) {
|
|
11356
|
+
throw new Error("Failed to clone server response");
|
|
11357
|
+
}
|
|
11358
|
+
const payload = await decode2(serverResponse.body);
|
|
11359
|
+
if (payload.type === "redirect") {
|
|
11360
|
+
return new Response(null, {
|
|
11361
|
+
status: payload.status,
|
|
11362
|
+
headers: {
|
|
11363
|
+
Location: payload.location
|
|
11364
|
+
}
|
|
11365
|
+
});
|
|
11366
|
+
}
|
|
11367
|
+
const html = await renderHTML(payload);
|
|
11368
|
+
try {
|
|
11369
|
+
const body = html.pipeThrough(injectRSCPayload(serverResponseB.body));
|
|
11370
|
+
const headers = new Headers(serverResponse.headers);
|
|
11371
|
+
headers.set("Content-Type", "text/html");
|
|
11372
|
+
return new Response(body, {
|
|
11373
|
+
status: serverResponse.status,
|
|
11374
|
+
headers
|
|
11375
|
+
});
|
|
11376
|
+
} catch (reason) {
|
|
11377
|
+
throw reason;
|
|
11378
|
+
}
|
|
11379
|
+
}
|
|
11380
|
+
function RSCStaticRouter({ payload }) {
|
|
11381
|
+
if (payload.type !== "render") return null;
|
|
11382
|
+
const context = {
|
|
11383
|
+
actionData: payload.actionData,
|
|
11384
|
+
actionHeaders: {},
|
|
11385
|
+
basename: payload.basename,
|
|
11386
|
+
errors: payload.errors,
|
|
11387
|
+
loaderData: payload.loaderData,
|
|
11388
|
+
loaderHeaders: {},
|
|
11389
|
+
location: payload.location,
|
|
11390
|
+
statusCode: 200,
|
|
11391
|
+
matches: payload.matches.map((match) => ({
|
|
11392
|
+
params: match.params,
|
|
11393
|
+
pathname: match.pathname,
|
|
11394
|
+
pathnameBase: match.pathnameBase,
|
|
11395
|
+
route: {
|
|
11396
|
+
id: match.id,
|
|
11397
|
+
action: match.hasAction || !!match.clientAction,
|
|
11398
|
+
handle: match.handle,
|
|
11399
|
+
hasErrorBoundary: match.hasErrorBoundary,
|
|
11400
|
+
loader: match.hasLoader || !!match.clientLoader,
|
|
11401
|
+
index: match.index,
|
|
11402
|
+
path: match.path,
|
|
11403
|
+
shouldRevalidate: match.shouldRevalidate
|
|
11404
|
+
}
|
|
11405
|
+
}))
|
|
11406
|
+
};
|
|
11407
|
+
const router = createStaticRouter(
|
|
11408
|
+
payload.matches.reduceRight((previous, match) => {
|
|
11409
|
+
const route = {
|
|
11410
|
+
id: match.id,
|
|
11411
|
+
action: match.hasAction || !!match.clientAction,
|
|
11412
|
+
element: match.element,
|
|
11413
|
+
errorElement: match.errorElement,
|
|
11414
|
+
handle: match.handle,
|
|
11415
|
+
hasErrorBoundary: !!match.errorElement,
|
|
11416
|
+
hydrateFallbackElement: match.hydrateFallbackElement,
|
|
11417
|
+
index: match.index,
|
|
11418
|
+
loader: match.hasLoader || !!match.clientLoader,
|
|
11419
|
+
path: match.path,
|
|
11420
|
+
shouldRevalidate: match.shouldRevalidate
|
|
11421
|
+
};
|
|
11422
|
+
if (previous.length > 0) {
|
|
11423
|
+
route.children = previous;
|
|
11424
|
+
}
|
|
11425
|
+
return [route];
|
|
11426
|
+
}, []),
|
|
11427
|
+
context
|
|
11428
|
+
);
|
|
11429
|
+
const frameworkContext = {
|
|
11430
|
+
future: {
|
|
11431
|
+
// These flags have no runtime impact so can always be false. If we add
|
|
11432
|
+
// flags that drive runtime behavior they'll need to be proxied through.
|
|
11433
|
+
unstable_middleware: false,
|
|
11434
|
+
unstable_subResourceIntegrity: false
|
|
11435
|
+
},
|
|
11436
|
+
isSpaMode: false,
|
|
11437
|
+
ssr: true,
|
|
11438
|
+
criticalCss: "",
|
|
11439
|
+
manifest: {
|
|
11440
|
+
routes: {},
|
|
11441
|
+
version: "1",
|
|
11442
|
+
url: "",
|
|
11443
|
+
entry: {
|
|
11444
|
+
module: "",
|
|
11445
|
+
imports: []
|
|
11446
|
+
}
|
|
11447
|
+
},
|
|
11448
|
+
routeModules: {}
|
|
11449
|
+
};
|
|
11450
|
+
return /* @__PURE__ */ React15.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React15.createElement(
|
|
11451
|
+
StaticRouterProvider,
|
|
11452
|
+
{
|
|
11453
|
+
context,
|
|
11454
|
+
router,
|
|
11455
|
+
hydrate: false,
|
|
11456
|
+
nonce: payload.nonce
|
|
11457
|
+
}
|
|
11458
|
+
));
|
|
11459
|
+
}
|
|
11460
|
+
function isReactServerRequest(url) {
|
|
11461
|
+
return url.pathname.endsWith(".rsc");
|
|
11462
|
+
}
|
|
11463
|
+
function isManifestRequest(url) {
|
|
11464
|
+
return url.pathname.endsWith(".manifest");
|
|
11465
|
+
}
|
|
11466
|
+
|
|
11467
|
+
// lib/rsc/html-stream/browser.ts
|
|
11468
|
+
function getServerStream() {
|
|
11469
|
+
let encoder3 = new TextEncoder();
|
|
11470
|
+
let streamController = null;
|
|
11471
|
+
let rscStream = new ReadableStream({
|
|
11472
|
+
start(controller) {
|
|
11473
|
+
if (typeof window === "undefined") {
|
|
11474
|
+
return;
|
|
11475
|
+
}
|
|
11476
|
+
let handleChunk = (chunk) => {
|
|
11477
|
+
if (typeof chunk === "string") {
|
|
11478
|
+
controller.enqueue(encoder3.encode(chunk));
|
|
11479
|
+
} else {
|
|
11480
|
+
controller.enqueue(chunk);
|
|
11481
|
+
}
|
|
11482
|
+
};
|
|
11483
|
+
window.__FLIGHT_DATA || (window.__FLIGHT_DATA = []);
|
|
11484
|
+
window.__FLIGHT_DATA.forEach(handleChunk);
|
|
11485
|
+
window.__FLIGHT_DATA.push = (chunk) => {
|
|
11486
|
+
handleChunk(chunk);
|
|
11487
|
+
return 0;
|
|
11488
|
+
};
|
|
11489
|
+
streamController = controller;
|
|
11490
|
+
}
|
|
11491
|
+
});
|
|
11492
|
+
if (typeof document !== "undefined" && document.readyState === "loading") {
|
|
11493
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
11494
|
+
streamController?.close();
|
|
11495
|
+
});
|
|
11496
|
+
} else {
|
|
11497
|
+
streamController?.close();
|
|
11498
|
+
}
|
|
11499
|
+
return rscStream;
|
|
11500
|
+
}
|
|
11501
|
+
|
|
10784
11502
|
// lib/dom/ssr/errors.ts
|
|
10785
11503
|
function deserializeErrors2(errors) {
|
|
10786
11504
|
if (!errors) return null;
|
|
@@ -10817,32 +11535,6 @@ function deserializeErrors2(errors) {
|
|
|
10817
11535
|
}
|
|
10818
11536
|
return serialized;
|
|
10819
11537
|
}
|
|
10820
|
-
|
|
10821
|
-
// lib/dom/ssr/hydration.tsx
|
|
10822
|
-
function getHydrationData(state, routes, getRouteInfo, location, basename, isSpaMode) {
|
|
10823
|
-
let hydrationData = {
|
|
10824
|
-
...state,
|
|
10825
|
-
loaderData: { ...state.loaderData }
|
|
10826
|
-
};
|
|
10827
|
-
let initialMatches = matchRoutes(routes, location, basename);
|
|
10828
|
-
if (initialMatches) {
|
|
10829
|
-
for (let match of initialMatches) {
|
|
10830
|
-
let routeId = match.route.id;
|
|
10831
|
-
let routeInfo = getRouteInfo(routeId);
|
|
10832
|
-
if (shouldHydrateRouteLoader(
|
|
10833
|
-
routeId,
|
|
10834
|
-
routeInfo.clientLoader,
|
|
10835
|
-
routeInfo.hasLoader,
|
|
10836
|
-
isSpaMode
|
|
10837
|
-
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
|
|
10838
|
-
delete hydrationData.loaderData[routeId];
|
|
10839
|
-
} else if (!routeInfo.hasLoader) {
|
|
10840
|
-
hydrationData.loaderData[routeId] = null;
|
|
10841
|
-
}
|
|
10842
|
-
}
|
|
10843
|
-
}
|
|
10844
|
-
return hydrationData;
|
|
10845
|
-
}
|
|
10846
11538
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10847
11539
|
0 && (module.exports = {
|
|
10848
11540
|
Await,
|
|
@@ -10861,6 +11553,8 @@ function getHydrationData(state, routes, getRouteInfo, location, basename, isSpa
|
|
|
10861
11553
|
NavigationType,
|
|
10862
11554
|
Outlet,
|
|
10863
11555
|
PrefetchPageLinks,
|
|
11556
|
+
RSCHydratedRouter,
|
|
11557
|
+
RSCStaticRouter,
|
|
10864
11558
|
Route,
|
|
10865
11559
|
Router,
|
|
10866
11560
|
RouterProvider,
|
|
@@ -10882,6 +11576,9 @@ function getHydrationData(state, routes, getRouteInfo, location, basename, isSpa
|
|
|
10882
11576
|
UNSAFE_ServerMode,
|
|
10883
11577
|
UNSAFE_SingleFetchRedirectSymbol,
|
|
10884
11578
|
UNSAFE_ViewTransitionContext,
|
|
11579
|
+
UNSAFE_WithErrorBoundaryProps,
|
|
11580
|
+
UNSAFE_WithHydrateFallbackProps,
|
|
11581
|
+
UNSAFE_WithRouteComponentProps,
|
|
10885
11582
|
UNSAFE_createBrowserHistory,
|
|
10886
11583
|
UNSAFE_createClientRoutes,
|
|
10887
11584
|
UNSAFE_createClientRoutesWithHMRRevalidationOptOut,
|
|
@@ -10898,6 +11595,7 @@ function getHydrationData(state, routes, getRouteInfo, location, basename, isSpa
|
|
|
10898
11595
|
UNSAFE_useFogOFWarDiscovery,
|
|
10899
11596
|
UNSAFE_useScrollRestoration,
|
|
10900
11597
|
createBrowserRouter,
|
|
11598
|
+
createCallServer,
|
|
10901
11599
|
createCookie,
|
|
10902
11600
|
createCookieSessionStorage,
|
|
10903
11601
|
createHashRouter,
|
|
@@ -10915,6 +11613,7 @@ function getHydrationData(state, routes, getRouteInfo, location, basename, isSpa
|
|
|
10915
11613
|
createStaticRouter,
|
|
10916
11614
|
data,
|
|
10917
11615
|
generatePath,
|
|
11616
|
+
getServerStream,
|
|
10918
11617
|
href,
|
|
10919
11618
|
isCookie,
|
|
10920
11619
|
isRouteErrorResponse,
|
|
@@ -10927,6 +11626,7 @@ function getHydrationData(state, routes, getRouteInfo, location, basename, isSpa
|
|
|
10927
11626
|
renderMatches,
|
|
10928
11627
|
replace,
|
|
10929
11628
|
resolvePath,
|
|
11629
|
+
routeRSCServerRequest,
|
|
10930
11630
|
unstable_HistoryRouter,
|
|
10931
11631
|
unstable_RouterContextProvider,
|
|
10932
11632
|
unstable_createContext,
|