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
|
*
|
|
@@ -45,19 +45,19 @@ function createMemoryHistory(options = {}) {
|
|
|
45
45
|
return entries[index];
|
|
46
46
|
}
|
|
47
47
|
function createMemoryLocation(to, state = null, key) {
|
|
48
|
-
let
|
|
48
|
+
let location2 = createLocation(
|
|
49
49
|
entries ? getCurrentLocation().pathname : "/",
|
|
50
50
|
to,
|
|
51
51
|
state,
|
|
52
52
|
key
|
|
53
53
|
);
|
|
54
54
|
warning(
|
|
55
|
-
|
|
55
|
+
location2.pathname.charAt(0) === "/",
|
|
56
56
|
`relative pathnames are not supported in memory history: ${JSON.stringify(
|
|
57
57
|
to
|
|
58
58
|
)}`
|
|
59
59
|
);
|
|
60
|
-
return
|
|
60
|
+
return location2;
|
|
61
61
|
}
|
|
62
62
|
function createHref2(to) {
|
|
63
63
|
return typeof to === "string" ? to : createPath(to);
|
|
@@ -168,9 +168,9 @@ function createHashHistory(options = {}) {
|
|
|
168
168
|
}
|
|
169
169
|
return href2 + "#" + (typeof to === "string" ? to : createPath(to));
|
|
170
170
|
}
|
|
171
|
-
function validateHashLocation(
|
|
171
|
+
function validateHashLocation(location2, to) {
|
|
172
172
|
warning(
|
|
173
|
-
|
|
173
|
+
location2.pathname.charAt(0) === "/",
|
|
174
174
|
`relative pathnames are not supported in hash history.push(${JSON.stringify(
|
|
175
175
|
to
|
|
176
176
|
)})`
|
|
@@ -200,15 +200,15 @@ function warning(cond, message) {
|
|
|
200
200
|
function createKey() {
|
|
201
201
|
return Math.random().toString(36).substring(2, 10);
|
|
202
202
|
}
|
|
203
|
-
function getHistoryState(
|
|
203
|
+
function getHistoryState(location2, index) {
|
|
204
204
|
return {
|
|
205
|
-
usr:
|
|
206
|
-
key:
|
|
205
|
+
usr: location2.state,
|
|
206
|
+
key: location2.key,
|
|
207
207
|
idx: index
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
210
|
function createLocation(current, to, state = null, key) {
|
|
211
|
-
let
|
|
211
|
+
let location2 = {
|
|
212
212
|
pathname: typeof current === "string" ? current : current.pathname,
|
|
213
213
|
search: "",
|
|
214
214
|
hash: "",
|
|
@@ -220,7 +220,7 @@ function createLocation(current, to, state = null, key) {
|
|
|
220
220
|
// keep as is for the time being and just let any incoming keys take precedence
|
|
221
221
|
key: to && to.key || key || createKey()
|
|
222
222
|
};
|
|
223
|
-
return
|
|
223
|
+
return location2;
|
|
224
224
|
}
|
|
225
225
|
function createPath({
|
|
226
226
|
pathname = "/",
|
|
@@ -277,11 +277,11 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
277
277
|
}
|
|
278
278
|
function push(to, state) {
|
|
279
279
|
action = "PUSH" /* Push */;
|
|
280
|
-
let
|
|
281
|
-
if (validateLocation) validateLocation(
|
|
280
|
+
let location2 = createLocation(history.location, to, state);
|
|
281
|
+
if (validateLocation) validateLocation(location2, to);
|
|
282
282
|
index = getIndex() + 1;
|
|
283
|
-
let historyState = getHistoryState(
|
|
284
|
-
let url = history.createHref(
|
|
283
|
+
let historyState = getHistoryState(location2, index);
|
|
284
|
+
let url = history.createHref(location2);
|
|
285
285
|
try {
|
|
286
286
|
globalHistory.pushState(historyState, "", url);
|
|
287
287
|
} catch (error) {
|
|
@@ -296,11 +296,11 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
296
296
|
}
|
|
297
297
|
function replace2(to, state) {
|
|
298
298
|
action = "REPLACE" /* Replace */;
|
|
299
|
-
let
|
|
300
|
-
if (validateLocation) validateLocation(
|
|
299
|
+
let location2 = createLocation(history.location, to, state);
|
|
300
|
+
if (validateLocation) validateLocation(location2, to);
|
|
301
301
|
index = getIndex();
|
|
302
|
-
let historyState = getHistoryState(
|
|
303
|
-
let url = history.createHref(
|
|
302
|
+
let historyState = getHistoryState(location2, index);
|
|
303
|
+
let url = history.createHref(location2);
|
|
304
304
|
globalHistory.replaceState(historyState, "", url);
|
|
305
305
|
if (v5Compat && listener) {
|
|
306
306
|
listener({ action, location: history.location, delta: 0 });
|
|
@@ -413,7 +413,7 @@ function isUnsupportedLazyRouteFunctionKey(key) {
|
|
|
413
413
|
function isIndexRoute(route) {
|
|
414
414
|
return route.index === true;
|
|
415
415
|
}
|
|
416
|
-
function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}) {
|
|
416
|
+
function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}, allowInPlaceMutations = false) {
|
|
417
417
|
return routes.map((route, index) => {
|
|
418
418
|
let treePath = [...parentPath, String(index)];
|
|
419
419
|
let id = typeof route.id === "string" ? route.id : treePath.join("-");
|
|
@@ -422,7 +422,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
422
422
|
`Cannot specify children on an index route`
|
|
423
423
|
);
|
|
424
424
|
invariant(
|
|
425
|
-
!manifest[id],
|
|
425
|
+
allowInPlaceMutations || !manifest[id],
|
|
426
426
|
`Found a route id collision on id "${id}". Route id's must be globally unique within Data Router usages`
|
|
427
427
|
);
|
|
428
428
|
if (isIndexRoute(route)) {
|
|
@@ -446,7 +446,8 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
446
446
|
route.children,
|
|
447
447
|
mapRouteProperties2,
|
|
448
448
|
treePath,
|
|
449
|
-
manifest
|
|
449
|
+
manifest,
|
|
450
|
+
allowInPlaceMutations
|
|
450
451
|
);
|
|
451
452
|
}
|
|
452
453
|
return pathOrLayoutRoute;
|
|
@@ -457,8 +458,8 @@ function matchRoutes(routes, locationArg, basename = "/") {
|
|
|
457
458
|
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
458
459
|
}
|
|
459
460
|
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
460
|
-
let
|
|
461
|
-
let pathname = stripBasename(
|
|
461
|
+
let location2 = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
462
|
+
let pathname = stripBasename(location2.pathname || "/", basename);
|
|
462
463
|
if (pathname == null) {
|
|
463
464
|
return null;
|
|
464
465
|
}
|
|
@@ -1062,7 +1063,7 @@ function createRouter(init) {
|
|
|
1062
1063
|
let pendingRevalidationDfd = null;
|
|
1063
1064
|
function initialize() {
|
|
1064
1065
|
unlistenHistory = init.history.listen(
|
|
1065
|
-
({ action: historyAction, location, delta }) => {
|
|
1066
|
+
({ action: historyAction, location: location2, delta }) => {
|
|
1066
1067
|
if (unblockBlockerHistoryUpdate) {
|
|
1067
1068
|
unblockBlockerHistoryUpdate();
|
|
1068
1069
|
unblockBlockerHistoryUpdate = void 0;
|
|
@@ -1074,7 +1075,7 @@ function createRouter(init) {
|
|
|
1074
1075
|
);
|
|
1075
1076
|
let blockerKey = shouldBlockNavigation({
|
|
1076
1077
|
currentLocation: state.location,
|
|
1077
|
-
nextLocation:
|
|
1078
|
+
nextLocation: location2,
|
|
1078
1079
|
historyAction
|
|
1079
1080
|
});
|
|
1080
1081
|
if (blockerKey && delta != null) {
|
|
@@ -1084,13 +1085,13 @@ function createRouter(init) {
|
|
|
1084
1085
|
init.history.go(delta * -1);
|
|
1085
1086
|
updateBlocker(blockerKey, {
|
|
1086
1087
|
state: "blocked",
|
|
1087
|
-
location,
|
|
1088
|
+
location: location2,
|
|
1088
1089
|
proceed() {
|
|
1089
1090
|
updateBlocker(blockerKey, {
|
|
1090
1091
|
state: "proceeding",
|
|
1091
1092
|
proceed: void 0,
|
|
1092
1093
|
reset: void 0,
|
|
1093
|
-
location
|
|
1094
|
+
location: location2
|
|
1094
1095
|
});
|
|
1095
1096
|
nextHistoryUpdatePromise.then(() => init.history.go(delta));
|
|
1096
1097
|
},
|
|
@@ -1102,7 +1103,7 @@ function createRouter(init) {
|
|
|
1102
1103
|
});
|
|
1103
1104
|
return;
|
|
1104
1105
|
}
|
|
1105
|
-
return startNavigation(historyAction,
|
|
1106
|
+
return startNavigation(historyAction, location2);
|
|
1106
1107
|
}
|
|
1107
1108
|
);
|
|
1108
1109
|
if (isBrowser2) {
|
|
@@ -1135,6 +1136,19 @@ function createRouter(init) {
|
|
|
1135
1136
|
return () => subscribers.delete(fn);
|
|
1136
1137
|
}
|
|
1137
1138
|
function updateState(newState, opts = {}) {
|
|
1139
|
+
if (newState.matches) {
|
|
1140
|
+
newState.matches = newState.matches.map((m) => {
|
|
1141
|
+
let route = manifest[m.route.id];
|
|
1142
|
+
let matchRoute = m.route;
|
|
1143
|
+
if (matchRoute.element !== route.element || matchRoute.errorElement !== route.errorElement || matchRoute.hydrateFallbackElement !== route.hydrateFallbackElement) {
|
|
1144
|
+
return {
|
|
1145
|
+
...m,
|
|
1146
|
+
route
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
return m;
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1138
1152
|
state = {
|
|
1139
1153
|
...state,
|
|
1140
1154
|
...newState
|
|
@@ -1165,8 +1179,8 @@ function createRouter(init) {
|
|
|
1165
1179
|
unmountedFetchers.forEach((key) => deleteFetcher(key));
|
|
1166
1180
|
mountedFetchers.forEach((key) => state.fetchers.delete(key));
|
|
1167
1181
|
}
|
|
1168
|
-
function completeNavigation(
|
|
1169
|
-
let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" &&
|
|
1182
|
+
function completeNavigation(location2, newState, { flushSync } = {}) {
|
|
1183
|
+
let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && location2.state?._isRedirect !== true;
|
|
1170
1184
|
let actionData;
|
|
1171
1185
|
if (newState.actionData) {
|
|
1172
1186
|
if (Object.keys(newState.actionData).length > 0) {
|
|
@@ -1190,7 +1204,7 @@ function createRouter(init) {
|
|
|
1190
1204
|
blockers = new Map(blockers);
|
|
1191
1205
|
blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));
|
|
1192
1206
|
}
|
|
1193
|
-
let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) &&
|
|
1207
|
+
let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location2.state?._isRedirect !== true;
|
|
1194
1208
|
if (inFlightDataRoutes) {
|
|
1195
1209
|
dataRoutes = inFlightDataRoutes;
|
|
1196
1210
|
inFlightDataRoutes = void 0;
|
|
@@ -1198,35 +1212,35 @@ function createRouter(init) {
|
|
|
1198
1212
|
if (isUninterruptedRevalidation) {
|
|
1199
1213
|
} else if (pendingAction === "POP" /* Pop */) {
|
|
1200
1214
|
} else if (pendingAction === "PUSH" /* Push */) {
|
|
1201
|
-
init.history.push(
|
|
1215
|
+
init.history.push(location2, location2.state);
|
|
1202
1216
|
} else if (pendingAction === "REPLACE" /* Replace */) {
|
|
1203
|
-
init.history.replace(
|
|
1217
|
+
init.history.replace(location2, location2.state);
|
|
1204
1218
|
}
|
|
1205
1219
|
let viewTransitionOpts;
|
|
1206
1220
|
if (pendingAction === "POP" /* Pop */) {
|
|
1207
1221
|
let priorPaths = appliedViewTransitions.get(state.location.pathname);
|
|
1208
|
-
if (priorPaths && priorPaths.has(
|
|
1222
|
+
if (priorPaths && priorPaths.has(location2.pathname)) {
|
|
1209
1223
|
viewTransitionOpts = {
|
|
1210
1224
|
currentLocation: state.location,
|
|
1211
|
-
nextLocation:
|
|
1225
|
+
nextLocation: location2
|
|
1212
1226
|
};
|
|
1213
|
-
} else if (appliedViewTransitions.has(
|
|
1227
|
+
} else if (appliedViewTransitions.has(location2.pathname)) {
|
|
1214
1228
|
viewTransitionOpts = {
|
|
1215
|
-
currentLocation:
|
|
1229
|
+
currentLocation: location2,
|
|
1216
1230
|
nextLocation: state.location
|
|
1217
1231
|
};
|
|
1218
1232
|
}
|
|
1219
1233
|
} else if (pendingViewTransitionEnabled) {
|
|
1220
1234
|
let toPaths = appliedViewTransitions.get(state.location.pathname);
|
|
1221
1235
|
if (toPaths) {
|
|
1222
|
-
toPaths.add(
|
|
1236
|
+
toPaths.add(location2.pathname);
|
|
1223
1237
|
} else {
|
|
1224
|
-
toPaths = /* @__PURE__ */ new Set([
|
|
1238
|
+
toPaths = /* @__PURE__ */ new Set([location2.pathname]);
|
|
1225
1239
|
appliedViewTransitions.set(state.location.pathname, toPaths);
|
|
1226
1240
|
}
|
|
1227
1241
|
viewTransitionOpts = {
|
|
1228
1242
|
currentLocation: state.location,
|
|
1229
|
-
nextLocation:
|
|
1243
|
+
nextLocation: location2
|
|
1230
1244
|
};
|
|
1231
1245
|
}
|
|
1232
1246
|
updateState(
|
|
@@ -1236,12 +1250,12 @@ function createRouter(init) {
|
|
|
1236
1250
|
actionData,
|
|
1237
1251
|
loaderData,
|
|
1238
1252
|
historyAction: pendingAction,
|
|
1239
|
-
location,
|
|
1253
|
+
location: location2,
|
|
1240
1254
|
initialized: true,
|
|
1241
1255
|
navigation: IDLE_NAVIGATION,
|
|
1242
1256
|
revalidation: "idle",
|
|
1243
1257
|
restoreScrollPosition: getSavedScrollPosition(
|
|
1244
|
-
|
|
1258
|
+
location2,
|
|
1245
1259
|
newState.matches || state.matches
|
|
1246
1260
|
),
|
|
1247
1261
|
preventScrollReset,
|
|
@@ -1358,7 +1372,7 @@ function createRouter(init) {
|
|
|
1358
1372
|
);
|
|
1359
1373
|
return promise;
|
|
1360
1374
|
}
|
|
1361
|
-
async function startNavigation(historyAction,
|
|
1375
|
+
async function startNavigation(historyAction, location2, opts) {
|
|
1362
1376
|
pendingNavigationController && pendingNavigationController.abort();
|
|
1363
1377
|
pendingNavigationController = null;
|
|
1364
1378
|
pendingAction = historyAction;
|
|
@@ -1371,22 +1385,22 @@ function createRouter(init) {
|
|
|
1371
1385
|
let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
|
|
1372
1386
|
// `matchRoutes()` has already been called if we're in here via `router.initialize()`
|
|
1373
1387
|
state.matches
|
|
1374
|
-
) : matchRoutes(routesToUse,
|
|
1388
|
+
) : matchRoutes(routesToUse, location2, basename);
|
|
1375
1389
|
let flushSync = (opts && opts.flushSync) === true;
|
|
1376
|
-
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location,
|
|
1377
|
-
completeNavigation(
|
|
1390
|
+
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location2) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
|
|
1391
|
+
completeNavigation(location2, { matches }, { flushSync });
|
|
1378
1392
|
return;
|
|
1379
1393
|
}
|
|
1380
|
-
let fogOfWar = checkFogOfWar(matches, routesToUse,
|
|
1394
|
+
let fogOfWar = checkFogOfWar(matches, routesToUse, location2.pathname);
|
|
1381
1395
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
1382
1396
|
matches = fogOfWar.matches;
|
|
1383
1397
|
}
|
|
1384
1398
|
if (!matches) {
|
|
1385
1399
|
let { error, notFoundMatches, route } = handleNavigational404(
|
|
1386
|
-
|
|
1400
|
+
location2.pathname
|
|
1387
1401
|
);
|
|
1388
1402
|
completeNavigation(
|
|
1389
|
-
|
|
1403
|
+
location2,
|
|
1390
1404
|
{
|
|
1391
1405
|
matches: notFoundMatches,
|
|
1392
1406
|
loaderData: {},
|
|
@@ -1401,7 +1415,7 @@ function createRouter(init) {
|
|
|
1401
1415
|
pendingNavigationController = new AbortController();
|
|
1402
1416
|
let request = createClientSideRequest(
|
|
1403
1417
|
init.history,
|
|
1404
|
-
|
|
1418
|
+
location2,
|
|
1405
1419
|
pendingNavigationController.signal,
|
|
1406
1420
|
opts && opts.submission
|
|
1407
1421
|
);
|
|
@@ -1417,7 +1431,7 @@ function createRouter(init) {
|
|
|
1417
1431
|
} else if (opts && opts.submission && isMutationMethod(opts.submission.formMethod)) {
|
|
1418
1432
|
let actionResult = await handleAction(
|
|
1419
1433
|
request,
|
|
1420
|
-
|
|
1434
|
+
location2,
|
|
1421
1435
|
opts.submission,
|
|
1422
1436
|
matches,
|
|
1423
1437
|
scopedContext,
|
|
@@ -1432,7 +1446,7 @@ function createRouter(init) {
|
|
|
1432
1446
|
let [routeId, result] = actionResult.pendingActionResult;
|
|
1433
1447
|
if (isErrorResult(result) && isRouteErrorResponse(result.error) && result.error.status === 404) {
|
|
1434
1448
|
pendingNavigationController = null;
|
|
1435
|
-
completeNavigation(
|
|
1449
|
+
completeNavigation(location2, {
|
|
1436
1450
|
matches: actionResult.matches,
|
|
1437
1451
|
loaderData: {},
|
|
1438
1452
|
errors: {
|
|
@@ -1444,7 +1458,7 @@ function createRouter(init) {
|
|
|
1444
1458
|
}
|
|
1445
1459
|
matches = actionResult.matches || matches;
|
|
1446
1460
|
pendingActionResult = actionResult.pendingActionResult;
|
|
1447
|
-
loadingNavigation = getLoadingNavigation(
|
|
1461
|
+
loadingNavigation = getLoadingNavigation(location2, opts.submission);
|
|
1448
1462
|
flushSync = false;
|
|
1449
1463
|
fogOfWar.active = false;
|
|
1450
1464
|
request = createClientSideRequest(
|
|
@@ -1460,7 +1474,7 @@ function createRouter(init) {
|
|
|
1460
1474
|
errors
|
|
1461
1475
|
} = await handleLoaders(
|
|
1462
1476
|
request,
|
|
1463
|
-
|
|
1477
|
+
location2,
|
|
1464
1478
|
matches,
|
|
1465
1479
|
scopedContext,
|
|
1466
1480
|
fogOfWar.active,
|
|
@@ -1476,21 +1490,21 @@ function createRouter(init) {
|
|
|
1476
1490
|
return;
|
|
1477
1491
|
}
|
|
1478
1492
|
pendingNavigationController = null;
|
|
1479
|
-
completeNavigation(
|
|
1493
|
+
completeNavigation(location2, {
|
|
1480
1494
|
matches: updatedMatches || matches,
|
|
1481
1495
|
...getActionDataForCommit(pendingActionResult),
|
|
1482
1496
|
loaderData,
|
|
1483
1497
|
errors
|
|
1484
1498
|
});
|
|
1485
1499
|
}
|
|
1486
|
-
async function handleAction(request,
|
|
1500
|
+
async function handleAction(request, location2, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
|
|
1487
1501
|
interruptActiveLoads();
|
|
1488
|
-
let navigation = getSubmittingNavigation(
|
|
1502
|
+
let navigation = getSubmittingNavigation(location2, submission);
|
|
1489
1503
|
updateState({ navigation }, { flushSync: opts.flushSync === true });
|
|
1490
1504
|
if (isFogOfWar) {
|
|
1491
1505
|
let discoverResult = await discoverRoutes(
|
|
1492
1506
|
matches,
|
|
1493
|
-
|
|
1507
|
+
location2.pathname,
|
|
1494
1508
|
request.signal
|
|
1495
1509
|
);
|
|
1496
1510
|
if (discoverResult.type === "aborted") {
|
|
@@ -1509,7 +1523,7 @@ function createRouter(init) {
|
|
|
1509
1523
|
};
|
|
1510
1524
|
} else if (!discoverResult.matches) {
|
|
1511
1525
|
let { notFoundMatches, error, route } = handleNavigational404(
|
|
1512
|
-
|
|
1526
|
+
location2.pathname
|
|
1513
1527
|
);
|
|
1514
1528
|
return {
|
|
1515
1529
|
matches: notFoundMatches,
|
|
@@ -1526,13 +1540,13 @@ function createRouter(init) {
|
|
|
1526
1540
|
}
|
|
1527
1541
|
}
|
|
1528
1542
|
let result;
|
|
1529
|
-
let actionMatch = getTargetMatch(matches,
|
|
1543
|
+
let actionMatch = getTargetMatch(matches, location2);
|
|
1530
1544
|
if (!actionMatch.route.action && !actionMatch.route.lazy) {
|
|
1531
1545
|
result = {
|
|
1532
1546
|
type: "error" /* error */,
|
|
1533
1547
|
error: getInternalRouterError(405, {
|
|
1534
1548
|
method: request.method,
|
|
1535
|
-
pathname:
|
|
1549
|
+
pathname: location2.pathname,
|
|
1536
1550
|
routeId: actionMatch.route.id
|
|
1537
1551
|
})
|
|
1538
1552
|
};
|
|
@@ -1570,12 +1584,12 @@ function createRouter(init) {
|
|
|
1570
1584
|
if (opts && opts.replace != null) {
|
|
1571
1585
|
replace2 = opts.replace;
|
|
1572
1586
|
} else {
|
|
1573
|
-
let
|
|
1587
|
+
let location3 = normalizeRedirectLocation(
|
|
1574
1588
|
result.response.headers.get("Location"),
|
|
1575
1589
|
new URL(request.url),
|
|
1576
1590
|
basename
|
|
1577
1591
|
);
|
|
1578
|
-
replace2 =
|
|
1592
|
+
replace2 = location3 === state.location.pathname + state.location.search;
|
|
1579
1593
|
}
|
|
1580
1594
|
await startRedirectNavigation(request, result, true, {
|
|
1581
1595
|
submission,
|
|
@@ -1590,11 +1604,7 @@ function createRouter(init) {
|
|
|
1590
1604
|
}
|
|
1591
1605
|
return {
|
|
1592
1606
|
matches,
|
|
1593
|
-
pendingActionResult: [
|
|
1594
|
-
boundaryMatch.route.id,
|
|
1595
|
-
result,
|
|
1596
|
-
actionMatch.route.id
|
|
1597
|
-
]
|
|
1607
|
+
pendingActionResult: [boundaryMatch.route.id, result]
|
|
1598
1608
|
};
|
|
1599
1609
|
}
|
|
1600
1610
|
return {
|
|
@@ -1602,8 +1612,8 @@ function createRouter(init) {
|
|
|
1602
1612
|
pendingActionResult: [actionMatch.route.id, result]
|
|
1603
1613
|
};
|
|
1604
1614
|
}
|
|
1605
|
-
async function handleLoaders(request,
|
|
1606
|
-
let loadingNavigation = overrideNavigation || getLoadingNavigation(
|
|
1615
|
+
async function handleLoaders(request, location2, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
|
|
1616
|
+
let loadingNavigation = overrideNavigation || getLoadingNavigation(location2, submission);
|
|
1607
1617
|
let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
|
|
1608
1618
|
let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
|
|
1609
1619
|
if (isFogOfWar) {
|
|
@@ -1621,7 +1631,7 @@ function createRouter(init) {
|
|
|
1621
1631
|
}
|
|
1622
1632
|
let discoverResult = await discoverRoutes(
|
|
1623
1633
|
matches,
|
|
1624
|
-
|
|
1634
|
+
location2.pathname,
|
|
1625
1635
|
request.signal
|
|
1626
1636
|
);
|
|
1627
1637
|
if (discoverResult.type === "aborted") {
|
|
@@ -1637,7 +1647,7 @@ function createRouter(init) {
|
|
|
1637
1647
|
};
|
|
1638
1648
|
} else if (!discoverResult.matches) {
|
|
1639
1649
|
let { error, notFoundMatches, route } = handleNavigational404(
|
|
1640
|
-
|
|
1650
|
+
location2.pathname
|
|
1641
1651
|
);
|
|
1642
1652
|
return {
|
|
1643
1653
|
matches: notFoundMatches,
|
|
@@ -1660,7 +1670,7 @@ function createRouter(init) {
|
|
|
1660
1670
|
state,
|
|
1661
1671
|
matches,
|
|
1662
1672
|
activeSubmission,
|
|
1663
|
-
|
|
1673
|
+
location2,
|
|
1664
1674
|
initialHydration ? [] : hydrationRouteProperties2,
|
|
1665
1675
|
initialHydration === true,
|
|
1666
1676
|
isRevalidationRequired,
|
|
@@ -1676,7 +1686,7 @@ function createRouter(init) {
|
|
|
1676
1686
|
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && revalidatingFetchers.length === 0) {
|
|
1677
1687
|
let updatedFetchers2 = markFetchRedirectsDone();
|
|
1678
1688
|
completeNavigation(
|
|
1679
|
-
|
|
1689
|
+
location2,
|
|
1680
1690
|
{
|
|
1681
1691
|
matches,
|
|
1682
1692
|
loaderData: {},
|
|
@@ -2187,31 +2197,31 @@ function createRouter(init) {
|
|
|
2187
2197
|
if (redirect2.response.headers.has("X-Remix-Revalidate")) {
|
|
2188
2198
|
isRevalidationRequired = true;
|
|
2189
2199
|
}
|
|
2190
|
-
let
|
|
2191
|
-
invariant(
|
|
2192
|
-
|
|
2193
|
-
|
|
2200
|
+
let location2 = redirect2.response.headers.get("Location");
|
|
2201
|
+
invariant(location2, "Expected a Location header on the redirect Response");
|
|
2202
|
+
location2 = normalizeRedirectLocation(
|
|
2203
|
+
location2,
|
|
2194
2204
|
new URL(request.url),
|
|
2195
2205
|
basename
|
|
2196
2206
|
);
|
|
2197
|
-
let redirectLocation = createLocation(state.location,
|
|
2207
|
+
let redirectLocation = createLocation(state.location, location2, {
|
|
2198
2208
|
_isRedirect: true
|
|
2199
2209
|
});
|
|
2200
2210
|
if (isBrowser2) {
|
|
2201
2211
|
let isDocumentReload = false;
|
|
2202
2212
|
if (redirect2.response.headers.has("X-Remix-Reload-Document")) {
|
|
2203
2213
|
isDocumentReload = true;
|
|
2204
|
-
} else if (ABSOLUTE_URL_REGEX.test(
|
|
2205
|
-
const url = init.history.createURL(
|
|
2214
|
+
} else if (ABSOLUTE_URL_REGEX.test(location2)) {
|
|
2215
|
+
const url = init.history.createURL(location2);
|
|
2206
2216
|
isDocumentReload = // Hard reload if it's an absolute URL to a new origin
|
|
2207
2217
|
url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename
|
|
2208
2218
|
stripBasename(url.pathname, basename) == null;
|
|
2209
2219
|
}
|
|
2210
2220
|
if (isDocumentReload) {
|
|
2211
2221
|
if (replace2) {
|
|
2212
|
-
routerWindow.location.replace(
|
|
2222
|
+
routerWindow.location.replace(location2);
|
|
2213
2223
|
} else {
|
|
2214
|
-
routerWindow.location.assign(
|
|
2224
|
+
routerWindow.location.assign(location2);
|
|
2215
2225
|
}
|
|
2216
2226
|
return;
|
|
2217
2227
|
}
|
|
@@ -2227,7 +2237,7 @@ function createRouter(init) {
|
|
|
2227
2237
|
await startNavigation(redirectNavigationType, redirectLocation, {
|
|
2228
2238
|
submission: {
|
|
2229
2239
|
...activeSubmission,
|
|
2230
|
-
formAction:
|
|
2240
|
+
formAction: location2
|
|
2231
2241
|
},
|
|
2232
2242
|
// Preserve these flags across redirects
|
|
2233
2243
|
preventScrollReset: preventScrollReset || pendingPreventScrollReset,
|
|
@@ -2498,25 +2508,25 @@ function createRouter(init) {
|
|
|
2498
2508
|
getScrollRestorationKey2 = null;
|
|
2499
2509
|
};
|
|
2500
2510
|
}
|
|
2501
|
-
function getScrollKey(
|
|
2511
|
+
function getScrollKey(location2, matches) {
|
|
2502
2512
|
if (getScrollRestorationKey2) {
|
|
2503
2513
|
let key = getScrollRestorationKey2(
|
|
2504
|
-
|
|
2514
|
+
location2,
|
|
2505
2515
|
matches.map((m) => convertRouteMatchToUiMatch(m, state.loaderData))
|
|
2506
2516
|
);
|
|
2507
|
-
return key ||
|
|
2517
|
+
return key || location2.key;
|
|
2508
2518
|
}
|
|
2509
|
-
return
|
|
2519
|
+
return location2.key;
|
|
2510
2520
|
}
|
|
2511
|
-
function saveScrollPosition(
|
|
2521
|
+
function saveScrollPosition(location2, matches) {
|
|
2512
2522
|
if (savedScrollPositions2 && getScrollPosition) {
|
|
2513
|
-
let key = getScrollKey(
|
|
2523
|
+
let key = getScrollKey(location2, matches);
|
|
2514
2524
|
savedScrollPositions2[key] = getScrollPosition();
|
|
2515
2525
|
}
|
|
2516
2526
|
}
|
|
2517
|
-
function getSavedScrollPosition(
|
|
2527
|
+
function getSavedScrollPosition(location2, matches) {
|
|
2518
2528
|
if (savedScrollPositions2) {
|
|
2519
|
-
let key = getScrollKey(
|
|
2529
|
+
let key = getScrollKey(location2, matches);
|
|
2520
2530
|
let y = savedScrollPositions2[key];
|
|
2521
2531
|
if (typeof y === "number") {
|
|
2522
2532
|
return y;
|
|
@@ -2570,7 +2580,8 @@ function createRouter(init) {
|
|
|
2570
2580
|
children,
|
|
2571
2581
|
routesToUse,
|
|
2572
2582
|
localManifest,
|
|
2573
|
-
mapRouteProperties2
|
|
2583
|
+
mapRouteProperties2,
|
|
2584
|
+
false
|
|
2574
2585
|
);
|
|
2575
2586
|
}
|
|
2576
2587
|
});
|
|
@@ -2611,7 +2622,7 @@ function createRouter(init) {
|
|
|
2611
2622
|
manifest
|
|
2612
2623
|
);
|
|
2613
2624
|
}
|
|
2614
|
-
function patchRoutes(routeId, children) {
|
|
2625
|
+
function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
|
|
2615
2626
|
let isNonHMR = inFlightDataRoutes == null;
|
|
2616
2627
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
2617
2628
|
patchRoutesImpl(
|
|
@@ -2619,7 +2630,8 @@ function createRouter(init) {
|
|
|
2619
2630
|
children,
|
|
2620
2631
|
routesToUse,
|
|
2621
2632
|
manifest,
|
|
2622
|
-
mapRouteProperties2
|
|
2633
|
+
mapRouteProperties2,
|
|
2634
|
+
unstable_allowElementMutations
|
|
2623
2635
|
);
|
|
2624
2636
|
if (isNonHMR) {
|
|
2625
2637
|
dataRoutes = [...dataRoutes];
|
|
@@ -2661,7 +2673,10 @@ function createRouter(init) {
|
|
|
2661
2673
|
_internalFetchControllers: fetchControllers,
|
|
2662
2674
|
// TODO: Remove setRoutes, it's temporary to avoid dealing with
|
|
2663
2675
|
// updating the tree while validating the update algorithm.
|
|
2664
|
-
_internalSetRoutes
|
|
2676
|
+
_internalSetRoutes,
|
|
2677
|
+
_internalSetStateDoNotUseOrYouWillBreakYourApp(newState) {
|
|
2678
|
+
updateState(newState);
|
|
2679
|
+
}
|
|
2665
2680
|
};
|
|
2666
2681
|
return router;
|
|
2667
2682
|
}
|
|
@@ -2689,15 +2704,15 @@ function createStaticHandler(routes, opts) {
|
|
|
2689
2704
|
} = {}) {
|
|
2690
2705
|
let url = new URL(request.url);
|
|
2691
2706
|
let method = request.method;
|
|
2692
|
-
let
|
|
2693
|
-
let matches = matchRoutes(dataRoutes,
|
|
2707
|
+
let location2 = createLocation("", createPath(url), null, "default");
|
|
2708
|
+
let matches = matchRoutes(dataRoutes, location2, basename);
|
|
2694
2709
|
requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
|
|
2695
2710
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
2696
2711
|
let error = getInternalRouterError(405, { method });
|
|
2697
2712
|
let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
2698
2713
|
let staticContext = {
|
|
2699
2714
|
basename,
|
|
2700
|
-
location,
|
|
2715
|
+
location: location2,
|
|
2701
2716
|
matches: methodNotAllowedMatches,
|
|
2702
2717
|
loaderData: {},
|
|
2703
2718
|
actionData: null,
|
|
@@ -2710,11 +2725,11 @@ function createStaticHandler(routes, opts) {
|
|
|
2710
2725
|
};
|
|
2711
2726
|
return respond ? respond(staticContext) : staticContext;
|
|
2712
2727
|
} else if (!matches) {
|
|
2713
|
-
let error = getInternalRouterError(404, { pathname:
|
|
2728
|
+
let error = getInternalRouterError(404, { pathname: location2.pathname });
|
|
2714
2729
|
let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
2715
2730
|
let staticContext = {
|
|
2716
2731
|
basename,
|
|
2717
|
-
location,
|
|
2732
|
+
location: location2,
|
|
2718
2733
|
matches: notFoundMatches,
|
|
2719
2734
|
loaderData: {},
|
|
2720
2735
|
actionData: null,
|
|
@@ -2754,7 +2769,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2754
2769
|
async () => {
|
|
2755
2770
|
let result2 = await queryImpl(
|
|
2756
2771
|
request,
|
|
2757
|
-
|
|
2772
|
+
location2,
|
|
2758
2773
|
matches,
|
|
2759
2774
|
requestContext,
|
|
2760
2775
|
dataStrategy || null,
|
|
@@ -2766,7 +2781,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2766
2781
|
if (isResponse(result2)) {
|
|
2767
2782
|
return result2;
|
|
2768
2783
|
}
|
|
2769
|
-
renderedStaticContext = { location, basename, ...result2 };
|
|
2784
|
+
renderedStaticContext = { location: location2, basename, ...result2 };
|
|
2770
2785
|
let res = await respond(renderedStaticContext);
|
|
2771
2786
|
return res;
|
|
2772
2787
|
},
|
|
@@ -2791,7 +2806,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2791
2806
|
let boundary = loaderIdx >= 0 ? findNearestBoundary(matches, matches[loaderIdx].route.id) : findNearestBoundary(matches);
|
|
2792
2807
|
return respond({
|
|
2793
2808
|
matches,
|
|
2794
|
-
location,
|
|
2809
|
+
location: location2,
|
|
2795
2810
|
basename,
|
|
2796
2811
|
loaderData: {},
|
|
2797
2812
|
actionData: null,
|
|
@@ -2816,7 +2831,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2816
2831
|
}
|
|
2817
2832
|
let result = await queryImpl(
|
|
2818
2833
|
request,
|
|
2819
|
-
|
|
2834
|
+
location2,
|
|
2820
2835
|
matches,
|
|
2821
2836
|
requestContext,
|
|
2822
2837
|
dataStrategy || null,
|
|
@@ -2828,7 +2843,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2828
2843
|
if (isResponse(result)) {
|
|
2829
2844
|
return result;
|
|
2830
2845
|
}
|
|
2831
|
-
return { location, basename, ...result };
|
|
2846
|
+
return { location: location2, basename, ...result };
|
|
2832
2847
|
}
|
|
2833
2848
|
async function queryRoute(request, {
|
|
2834
2849
|
routeId,
|
|
@@ -2838,22 +2853,22 @@ function createStaticHandler(routes, opts) {
|
|
|
2838
2853
|
} = {}) {
|
|
2839
2854
|
let url = new URL(request.url);
|
|
2840
2855
|
let method = request.method;
|
|
2841
|
-
let
|
|
2842
|
-
let matches = matchRoutes(dataRoutes,
|
|
2856
|
+
let location2 = createLocation("", createPath(url), null, "default");
|
|
2857
|
+
let matches = matchRoutes(dataRoutes, location2, basename);
|
|
2843
2858
|
requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
|
|
2844
2859
|
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
|
|
2845
2860
|
throw getInternalRouterError(405, { method });
|
|
2846
2861
|
} else if (!matches) {
|
|
2847
|
-
throw getInternalRouterError(404, { pathname:
|
|
2862
|
+
throw getInternalRouterError(404, { pathname: location2.pathname });
|
|
2848
2863
|
}
|
|
2849
|
-
let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches,
|
|
2864
|
+
let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location2);
|
|
2850
2865
|
if (routeId && !match) {
|
|
2851
2866
|
throw getInternalRouterError(403, {
|
|
2852
|
-
pathname:
|
|
2867
|
+
pathname: location2.pathname,
|
|
2853
2868
|
routeId
|
|
2854
2869
|
});
|
|
2855
2870
|
} else if (!match) {
|
|
2856
|
-
throw getInternalRouterError(404, { pathname:
|
|
2871
|
+
throw getInternalRouterError(404, { pathname: location2.pathname });
|
|
2857
2872
|
}
|
|
2858
2873
|
if (respond && matches.some(
|
|
2859
2874
|
(m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
|
|
@@ -2876,7 +2891,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2876
2891
|
async () => {
|
|
2877
2892
|
let result2 = await queryImpl(
|
|
2878
2893
|
request,
|
|
2879
|
-
|
|
2894
|
+
location2,
|
|
2880
2895
|
matches,
|
|
2881
2896
|
requestContext,
|
|
2882
2897
|
dataStrategy || null,
|
|
@@ -2909,7 +2924,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2909
2924
|
}
|
|
2910
2925
|
let result = await queryImpl(
|
|
2911
2926
|
request,
|
|
2912
|
-
|
|
2927
|
+
location2,
|
|
2913
2928
|
matches,
|
|
2914
2929
|
requestContext,
|
|
2915
2930
|
dataStrategy || null,
|
|
@@ -2933,7 +2948,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2933
2948
|
}
|
|
2934
2949
|
return void 0;
|
|
2935
2950
|
}
|
|
2936
|
-
async function queryImpl(request,
|
|
2951
|
+
async function queryImpl(request, location2, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
|
|
2937
2952
|
invariant(
|
|
2938
2953
|
request.signal,
|
|
2939
2954
|
"query()/queryRoute() requests must contain an AbortController signal"
|
|
@@ -2943,7 +2958,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2943
2958
|
let result2 = await submit(
|
|
2944
2959
|
request,
|
|
2945
2960
|
matches,
|
|
2946
|
-
routeMatch || getTargetMatch(matches,
|
|
2961
|
+
routeMatch || getTargetMatch(matches, location2),
|
|
2947
2962
|
requestContext,
|
|
2948
2963
|
dataStrategy,
|
|
2949
2964
|
skipLoaderErrorBubbling,
|
|
@@ -3259,7 +3274,7 @@ function throwStaticHandlerAbortedError(request, isRouteRequest) {
|
|
|
3259
3274
|
function isSubmissionNavigation(opts) {
|
|
3260
3275
|
return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0);
|
|
3261
3276
|
}
|
|
3262
|
-
function normalizeTo(
|
|
3277
|
+
function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
|
|
3263
3278
|
let contextualMatches;
|
|
3264
3279
|
let activeRouteMatch;
|
|
3265
3280
|
if (fromRouteId) {
|
|
@@ -3278,12 +3293,12 @@ function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
|
|
|
3278
3293
|
let path = resolveTo(
|
|
3279
3294
|
to ? to : ".",
|
|
3280
3295
|
getResolveToMatches(contextualMatches),
|
|
3281
|
-
stripBasename(
|
|
3296
|
+
stripBasename(location2.pathname, basename) || location2.pathname,
|
|
3282
3297
|
relative === "path"
|
|
3283
3298
|
);
|
|
3284
3299
|
if (to == null) {
|
|
3285
|
-
path.search =
|
|
3286
|
-
path.hash =
|
|
3300
|
+
path.search = location2.search;
|
|
3301
|
+
path.hash = location2.hash;
|
|
3287
3302
|
}
|
|
3288
3303
|
if ((to == null || to === "" || to === ".") && activeRouteMatch) {
|
|
3289
3304
|
let nakedIndex = hasNakedIndexQuery(path.search);
|
|
@@ -3410,10 +3425,10 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
|
|
|
3410
3425
|
parsedPath.search = `?${searchParams}`;
|
|
3411
3426
|
return { path: createPath(parsedPath), submission };
|
|
3412
3427
|
}
|
|
3413
|
-
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission,
|
|
3428
|
+
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location2, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
|
|
3414
3429
|
let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
|
|
3415
3430
|
let currentUrl = history.createURL(state.location);
|
|
3416
|
-
let nextUrl = history.createURL(
|
|
3431
|
+
let nextUrl = history.createURL(location2);
|
|
3417
3432
|
let maxIdx;
|
|
3418
3433
|
if (initialHydration && state.errors) {
|
|
3419
3434
|
let boundaryId = Object.keys(state.errors)[0];
|
|
@@ -3612,7 +3627,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
3612
3627
|
}
|
|
3613
3628
|
return arg.defaultShouldRevalidate;
|
|
3614
3629
|
}
|
|
3615
|
-
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2) {
|
|
3630
|
+
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
|
|
3616
3631
|
let childrenToPatch;
|
|
3617
3632
|
if (routeId) {
|
|
3618
3633
|
let route = manifest[routeId];
|
|
@@ -3627,18 +3642,47 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
3627
3642
|
} else {
|
|
3628
3643
|
childrenToPatch = routesToUse;
|
|
3629
3644
|
}
|
|
3630
|
-
let uniqueChildren =
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3645
|
+
let uniqueChildren = [];
|
|
3646
|
+
let existingChildren = [];
|
|
3647
|
+
children.forEach((newRoute) => {
|
|
3648
|
+
let existingRoute = childrenToPatch.find(
|
|
3649
|
+
(existingRoute2) => isSameRoute(newRoute, existingRoute2)
|
|
3650
|
+
);
|
|
3651
|
+
if (existingRoute) {
|
|
3652
|
+
existingChildren.push({ existingRoute, newRoute });
|
|
3653
|
+
} else {
|
|
3654
|
+
uniqueChildren.push(newRoute);
|
|
3655
|
+
}
|
|
3656
|
+
});
|
|
3657
|
+
if (uniqueChildren.length > 0) {
|
|
3658
|
+
let newRoutes = convertRoutesToDataRoutes(
|
|
3659
|
+
uniqueChildren,
|
|
3660
|
+
mapRouteProperties2,
|
|
3661
|
+
[routeId || "_", "patch", String(childrenToPatch?.length || "0")],
|
|
3662
|
+
manifest
|
|
3663
|
+
);
|
|
3664
|
+
childrenToPatch.push(...newRoutes);
|
|
3665
|
+
}
|
|
3666
|
+
if (allowElementMutations && existingChildren.length > 0) {
|
|
3667
|
+
for (let i = 0; i < existingChildren.length; i++) {
|
|
3668
|
+
let { existingRoute, newRoute } = existingChildren[i];
|
|
3669
|
+
let existingRouteTyped = existingRoute;
|
|
3670
|
+
let [newRouteTyped] = convertRoutesToDataRoutes(
|
|
3671
|
+
[newRoute],
|
|
3672
|
+
mapRouteProperties2,
|
|
3673
|
+
[],
|
|
3674
|
+
// Doesn't matter for mutated routes since they already have an id
|
|
3675
|
+
{},
|
|
3676
|
+
// Don't touch the manifest here since we're updating in place
|
|
3677
|
+
true
|
|
3678
|
+
);
|
|
3679
|
+
Object.assign(existingRouteTyped, {
|
|
3680
|
+
element: newRouteTyped.element ? newRouteTyped.element : existingRouteTyped.element,
|
|
3681
|
+
errorElement: newRouteTyped.errorElement ? newRouteTyped.errorElement : existingRouteTyped.errorElement,
|
|
3682
|
+
hydrateFallbackElement: newRouteTyped.hydrateFallbackElement ? newRouteTyped.hydrateFallbackElement : existingRouteTyped.hydrateFallbackElement
|
|
3683
|
+
});
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3642
3686
|
}
|
|
3643
3687
|
function isSameRoute(newRoute, existingRoute) {
|
|
3644
3688
|
if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
|
|
@@ -3987,7 +4031,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, laz
|
|
|
3987
4031
|
return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
|
|
3988
4032
|
},
|
|
3989
4033
|
resolve(handlerOverride) {
|
|
3990
|
-
if (isUsingNewApi || shouldLoad || handlerOverride && request.method
|
|
4034
|
+
if (isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (match.route.lazy || match.route.loader)) {
|
|
3991
4035
|
return callLoaderOrAction({
|
|
3992
4036
|
request,
|
|
3993
4037
|
match,
|
|
@@ -4247,39 +4291,39 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
4247
4291
|
return { type: "data" /* data */, data: result };
|
|
4248
4292
|
}
|
|
4249
4293
|
function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename) {
|
|
4250
|
-
let
|
|
4294
|
+
let location2 = response.headers.get("Location");
|
|
4251
4295
|
invariant(
|
|
4252
|
-
|
|
4296
|
+
location2,
|
|
4253
4297
|
"Redirects returned/thrown from loaders/actions must have a Location header"
|
|
4254
4298
|
);
|
|
4255
|
-
if (!ABSOLUTE_URL_REGEX.test(
|
|
4299
|
+
if (!ABSOLUTE_URL_REGEX.test(location2)) {
|
|
4256
4300
|
let trimmedMatches = matches.slice(
|
|
4257
4301
|
0,
|
|
4258
4302
|
matches.findIndex((m) => m.route.id === routeId) + 1
|
|
4259
4303
|
);
|
|
4260
|
-
|
|
4304
|
+
location2 = normalizeTo(
|
|
4261
4305
|
new URL(request.url),
|
|
4262
4306
|
trimmedMatches,
|
|
4263
4307
|
basename,
|
|
4264
|
-
|
|
4308
|
+
location2
|
|
4265
4309
|
);
|
|
4266
|
-
response.headers.set("Location",
|
|
4310
|
+
response.headers.set("Location", location2);
|
|
4267
4311
|
}
|
|
4268
4312
|
return response;
|
|
4269
4313
|
}
|
|
4270
|
-
function normalizeRedirectLocation(
|
|
4271
|
-
if (ABSOLUTE_URL_REGEX.test(
|
|
4272
|
-
let normalizedLocation =
|
|
4314
|
+
function normalizeRedirectLocation(location2, currentUrl, basename) {
|
|
4315
|
+
if (ABSOLUTE_URL_REGEX.test(location2)) {
|
|
4316
|
+
let normalizedLocation = location2;
|
|
4273
4317
|
let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
|
|
4274
4318
|
let isSameBasename = stripBasename(url.pathname, basename) != null;
|
|
4275
4319
|
if (url.origin === currentUrl.origin && isSameBasename) {
|
|
4276
4320
|
return url.pathname + url.search + url.hash;
|
|
4277
4321
|
}
|
|
4278
4322
|
}
|
|
4279
|
-
return
|
|
4323
|
+
return location2;
|
|
4280
4324
|
}
|
|
4281
|
-
function createClientSideRequest(history,
|
|
4282
|
-
let url = history.createURL(stripHashFromPath(
|
|
4325
|
+
function createClientSideRequest(history, location2, signal, submission) {
|
|
4326
|
+
let url = history.createURL(stripHashFromPath(location2)).toString();
|
|
4283
4327
|
let init = { signal };
|
|
4284
4328
|
if (submission && isMutationMethod(submission.formMethod)) {
|
|
4285
4329
|
let { formMethod, formEncType } = submission;
|
|
@@ -4365,9 +4409,7 @@ function processRouteLoaderData(matches, results, pendingActionResult, isStaticH
|
|
|
4365
4409
|
});
|
|
4366
4410
|
if (pendingError !== void 0 && pendingActionResult) {
|
|
4367
4411
|
errors = { [pendingActionResult[0]]: pendingError };
|
|
4368
|
-
|
|
4369
|
-
loaderData[pendingActionResult[2]] = void 0;
|
|
4370
|
-
}
|
|
4412
|
+
loaderData[pendingActionResult[0]] = void 0;
|
|
4371
4413
|
}
|
|
4372
4414
|
return {
|
|
4373
4415
|
loaderData,
|
|
@@ -4551,8 +4593,8 @@ function isMutationMethod(method) {
|
|
|
4551
4593
|
function hasNakedIndexQuery(search) {
|
|
4552
4594
|
return new URLSearchParams(search).getAll("index").some((v) => v === "");
|
|
4553
4595
|
}
|
|
4554
|
-
function getTargetMatch(matches,
|
|
4555
|
-
let search = typeof
|
|
4596
|
+
function getTargetMatch(matches, location2) {
|
|
4597
|
+
let search = typeof location2 === "string" ? parsePath(location2).search : location2.search;
|
|
4556
4598
|
if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
|
|
4557
4599
|
return matches[matches.length - 1];
|
|
4558
4600
|
}
|
|
@@ -4593,11 +4635,11 @@ function getSubmissionFromNavigation(navigation) {
|
|
|
4593
4635
|
};
|
|
4594
4636
|
}
|
|
4595
4637
|
}
|
|
4596
|
-
function getLoadingNavigation(
|
|
4638
|
+
function getLoadingNavigation(location2, submission) {
|
|
4597
4639
|
if (submission) {
|
|
4598
4640
|
let navigation = {
|
|
4599
4641
|
state: "loading",
|
|
4600
|
-
location,
|
|
4642
|
+
location: location2,
|
|
4601
4643
|
formMethod: submission.formMethod,
|
|
4602
4644
|
formAction: submission.formAction,
|
|
4603
4645
|
formEncType: submission.formEncType,
|
|
@@ -4609,7 +4651,7 @@ function getLoadingNavigation(location, submission) {
|
|
|
4609
4651
|
} else {
|
|
4610
4652
|
let navigation = {
|
|
4611
4653
|
state: "loading",
|
|
4612
|
-
location,
|
|
4654
|
+
location: location2,
|
|
4613
4655
|
formMethod: void 0,
|
|
4614
4656
|
formAction: void 0,
|
|
4615
4657
|
formEncType: void 0,
|
|
@@ -4620,10 +4662,10 @@ function getLoadingNavigation(location, submission) {
|
|
|
4620
4662
|
return navigation;
|
|
4621
4663
|
}
|
|
4622
4664
|
}
|
|
4623
|
-
function getSubmittingNavigation(
|
|
4665
|
+
function getSubmittingNavigation(location2, submission) {
|
|
4624
4666
|
let navigation = {
|
|
4625
4667
|
state: "submitting",
|
|
4626
|
-
location,
|
|
4668
|
+
location: location2,
|
|
4627
4669
|
formMethod: submission.formMethod,
|
|
4628
4670
|
formAction: submission.formAction,
|
|
4629
4671
|
formEncType: submission.formEncType,
|
|
@@ -4949,18 +4991,18 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
4949
4991
|
);
|
|
4950
4992
|
}
|
|
4951
4993
|
let locationFromContext = useLocation();
|
|
4952
|
-
let
|
|
4994
|
+
let location2;
|
|
4953
4995
|
if (locationArg) {
|
|
4954
4996
|
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
4955
4997
|
invariant(
|
|
4956
4998
|
parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase),
|
|
4957
4999
|
`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.`
|
|
4958
5000
|
);
|
|
4959
|
-
|
|
5001
|
+
location2 = parsedLocationArg;
|
|
4960
5002
|
} else {
|
|
4961
|
-
|
|
5003
|
+
location2 = locationFromContext;
|
|
4962
5004
|
}
|
|
4963
|
-
let pathname =
|
|
5005
|
+
let pathname = location2.pathname || "/";
|
|
4964
5006
|
let remainingPathname = pathname;
|
|
4965
5007
|
if (parentPathnameBase !== "/") {
|
|
4966
5008
|
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
|
|
@@ -4971,11 +5013,11 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
4971
5013
|
if (ENABLE_DEV_WARNINGS) {
|
|
4972
5014
|
warning(
|
|
4973
5015
|
parentRoute || matches != null,
|
|
4974
|
-
`No routes matched location "${
|
|
5016
|
+
`No routes matched location "${location2.pathname}${location2.search}${location2.hash}" `
|
|
4975
5017
|
);
|
|
4976
5018
|
warning(
|
|
4977
5019
|
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,
|
|
4978
|
-
`Matched leaf route at location "${
|
|
5020
|
+
`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.`
|
|
4979
5021
|
);
|
|
4980
5022
|
}
|
|
4981
5023
|
let renderedMatches = _renderMatches(
|
|
@@ -5009,7 +5051,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5009
5051
|
hash: "",
|
|
5010
5052
|
state: null,
|
|
5011
5053
|
key: "default",
|
|
5012
|
-
...
|
|
5054
|
+
...location2
|
|
5013
5055
|
},
|
|
5014
5056
|
navigationType: "POP" /* Pop */
|
|
5015
5057
|
}
|
|
@@ -5774,9 +5816,9 @@ function Router({
|
|
|
5774
5816
|
}
|
|
5775
5817
|
function Routes({
|
|
5776
5818
|
children,
|
|
5777
|
-
location
|
|
5819
|
+
location: location2
|
|
5778
5820
|
}) {
|
|
5779
|
-
return useRoutes(createRoutesFromChildren(children),
|
|
5821
|
+
return useRoutes(createRoutesFromChildren(children), location2);
|
|
5780
5822
|
}
|
|
5781
5823
|
function Await({
|
|
5782
5824
|
children,
|
|
@@ -5846,6 +5888,38 @@ function ResolveAwait({
|
|
|
5846
5888
|
let toRender = typeof children === "function" ? children(data2) : children;
|
|
5847
5889
|
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, toRender);
|
|
5848
5890
|
}
|
|
5891
|
+
function WithRouteComponentProps({
|
|
5892
|
+
children
|
|
5893
|
+
}) {
|
|
5894
|
+
let props = {
|
|
5895
|
+
loaderData: useLoaderData(),
|
|
5896
|
+
actionData: useActionData(),
|
|
5897
|
+
params: useParams(),
|
|
5898
|
+
matches: useMatches()
|
|
5899
|
+
};
|
|
5900
|
+
return React3.cloneElement(children, props);
|
|
5901
|
+
}
|
|
5902
|
+
function WithHydrateFallbackProps({
|
|
5903
|
+
children
|
|
5904
|
+
}) {
|
|
5905
|
+
let props = {
|
|
5906
|
+
loaderData: useLoaderData(),
|
|
5907
|
+
actionData: useActionData(),
|
|
5908
|
+
params: useParams()
|
|
5909
|
+
};
|
|
5910
|
+
return React3.cloneElement(children, props);
|
|
5911
|
+
}
|
|
5912
|
+
function WithErrorBoundaryProps({
|
|
5913
|
+
children
|
|
5914
|
+
}) {
|
|
5915
|
+
let props = {
|
|
5916
|
+
loaderData: useLoaderData(),
|
|
5917
|
+
actionData: useActionData(),
|
|
5918
|
+
params: useParams(),
|
|
5919
|
+
error: useRouteError()
|
|
5920
|
+
};
|
|
5921
|
+
return React3.cloneElement(children, props);
|
|
5922
|
+
}
|
|
5849
5923
|
function createRoutesFromChildren(children, parentPath = []) {
|
|
5850
5924
|
let routes = [];
|
|
5851
5925
|
React3.Children.forEach(children, (element, index) => {
|
|
@@ -6168,7 +6242,7 @@ async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
|
|
|
6168
6242
|
)
|
|
6169
6243
|
);
|
|
6170
6244
|
}
|
|
6171
|
-
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest,
|
|
6245
|
+
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location2, mode) {
|
|
6172
6246
|
let isNew = (match, index) => {
|
|
6173
6247
|
if (!currentMatches[index]) return true;
|
|
6174
6248
|
return match.route.id !== currentMatches[index].route.id;
|
|
@@ -6198,7 +6272,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
6198
6272
|
if (match.route.shouldRevalidate) {
|
|
6199
6273
|
let routeChoice = match.route.shouldRevalidate({
|
|
6200
6274
|
currentUrl: new URL(
|
|
6201
|
-
|
|
6275
|
+
location2.pathname + location2.search + location2.hash,
|
|
6202
6276
|
window.origin
|
|
6203
6277
|
),
|
|
6204
6278
|
currentParams: currentMatches[0]?.params || {},
|
|
@@ -6318,7 +6392,6 @@ async function createRequestInit(request) {
|
|
|
6318
6392
|
|
|
6319
6393
|
// lib/dom/ssr/single-fetch.tsx
|
|
6320
6394
|
var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
|
|
6321
|
-
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
6322
6395
|
var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205]);
|
|
6323
6396
|
function StreamTransfer({
|
|
6324
6397
|
context,
|
|
@@ -6531,8 +6604,7 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
|
|
|
6531
6604
|
)
|
|
6532
6605
|
);
|
|
6533
6606
|
await Promise.all(routeDfds.map((d) => d.promise));
|
|
6534
|
-
|
|
6535
|
-
if ((isInitialLoad || routesParams.size === 0) && !window.__reactRouterHdrActive) {
|
|
6607
|
+
if ((!router.state.initialized || routesParams.size === 0) && !window.__reactRouterHdrActive) {
|
|
6536
6608
|
singleFetchDfd.resolve({ routes: {} });
|
|
6537
6609
|
} else {
|
|
6538
6610
|
let targetRoutes = ssr && foundOptOutRoute && routesParams.size > 0 ? [...routesParams.keys()] : void 0;
|
|
@@ -6572,7 +6644,7 @@ function stripIndexParam(url) {
|
|
|
6572
6644
|
}
|
|
6573
6645
|
return url;
|
|
6574
6646
|
}
|
|
6575
|
-
function singleFetchUrl(reqUrl, basename) {
|
|
6647
|
+
function singleFetchUrl(reqUrl, basename, extension) {
|
|
6576
6648
|
let url = typeof reqUrl === "string" ? new URL(
|
|
6577
6649
|
reqUrl,
|
|
6578
6650
|
// This can be called during the SSR flow via PrefetchPageLinksImpl so
|
|
@@ -6580,17 +6652,17 @@ function singleFetchUrl(reqUrl, basename) {
|
|
|
6580
6652
|
typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
|
|
6581
6653
|
) : reqUrl;
|
|
6582
6654
|
if (url.pathname === "/") {
|
|
6583
|
-
url.pathname =
|
|
6655
|
+
url.pathname = `_root.${extension}`;
|
|
6584
6656
|
} else if (basename && stripBasename(url.pathname, basename) === "/") {
|
|
6585
|
-
url.pathname = `${basename.replace(/\/$/, "")}/_root
|
|
6657
|
+
url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
|
|
6586
6658
|
} else {
|
|
6587
|
-
url.pathname = `${url.pathname.replace(/\/$/, "")}
|
|
6659
|
+
url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
|
|
6588
6660
|
}
|
|
6589
6661
|
return url;
|
|
6590
6662
|
}
|
|
6591
6663
|
async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
6592
6664
|
let { request } = args;
|
|
6593
|
-
let url = singleFetchUrl(request.url, basename);
|
|
6665
|
+
let url = singleFetchUrl(request.url, basename, "data");
|
|
6594
6666
|
if (request.method === "GET") {
|
|
6595
6667
|
url = stripIndexParam(url);
|
|
6596
6668
|
if (targetRoutes) {
|
|
@@ -6601,20 +6673,6 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
|
6601
6673
|
if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
|
|
6602
6674
|
throw new ErrorResponseImpl(404, "Not Found", true);
|
|
6603
6675
|
}
|
|
6604
|
-
if (res.status === 204 && res.headers.has("X-Remix-Redirect")) {
|
|
6605
|
-
return {
|
|
6606
|
-
status: SINGLE_FETCH_REDIRECT_STATUS,
|
|
6607
|
-
data: {
|
|
6608
|
-
redirect: {
|
|
6609
|
-
redirect: res.headers.get("X-Remix-Redirect"),
|
|
6610
|
-
status: Number(res.headers.get("X-Remix-Status") || "302"),
|
|
6611
|
-
revalidate: res.headers.get("X-Remix-Revalidate") === "true",
|
|
6612
|
-
reload: res.headers.get("X-Remix-Reload-Document") === "true",
|
|
6613
|
-
replace: res.headers.get("X-Remix-Replace") === "true"
|
|
6614
|
-
}
|
|
6615
|
-
}
|
|
6616
|
-
};
|
|
6617
|
-
}
|
|
6618
6676
|
if (NO_BODY_STATUS_CODES.has(res.status)) {
|
|
6619
6677
|
let routes = {};
|
|
6620
6678
|
if (targetRoutes && request.method !== "GET") {
|
|
@@ -6687,13 +6745,13 @@ function decodeViaTurboStream(body, global2) {
|
|
|
6687
6745
|
function unwrapSingleFetchResult(result, routeId) {
|
|
6688
6746
|
if ("redirect" in result) {
|
|
6689
6747
|
let {
|
|
6690
|
-
redirect:
|
|
6748
|
+
redirect: location2,
|
|
6691
6749
|
revalidate,
|
|
6692
6750
|
reload,
|
|
6693
6751
|
replace: replace2,
|
|
6694
6752
|
status
|
|
6695
6753
|
} = result.redirect;
|
|
6696
|
-
throw redirect(
|
|
6754
|
+
throw redirect(location2, {
|
|
6697
6755
|
status,
|
|
6698
6756
|
headers: {
|
|
6699
6757
|
// Three R's of redirecting (lol Veep)
|
|
@@ -6704,12 +6762,13 @@ function unwrapSingleFetchResult(result, routeId) {
|
|
|
6704
6762
|
});
|
|
6705
6763
|
}
|
|
6706
6764
|
let routeResult = result.routes[routeId];
|
|
6765
|
+
invariant2(routeResult, `No response found for routeId "${routeId}"`);
|
|
6707
6766
|
if ("error" in routeResult) {
|
|
6708
6767
|
throw routeResult.error;
|
|
6709
6768
|
} else if ("data" in routeResult) {
|
|
6710
6769
|
return routeResult.data;
|
|
6711
6770
|
} else {
|
|
6712
|
-
throw new Error(`
|
|
6771
|
+
throw new Error(`Invalid response found for routeId "${routeId}"`);
|
|
6713
6772
|
}
|
|
6714
6773
|
}
|
|
6715
6774
|
function createDeferred2() {
|
|
@@ -7274,8 +7333,8 @@ var nextPaths = /* @__PURE__ */ new Set();
|
|
|
7274
7333
|
var discoveredPathsMaxSize = 1e3;
|
|
7275
7334
|
var discoveredPaths = /* @__PURE__ */ new Set();
|
|
7276
7335
|
var URL_LIMIT = 7680;
|
|
7277
|
-
function isFogOfWarEnabled(
|
|
7278
|
-
return
|
|
7336
|
+
function isFogOfWarEnabled(ssr) {
|
|
7337
|
+
return ssr === true;
|
|
7279
7338
|
}
|
|
7280
7339
|
function getPartialManifest({ sri, ...manifest }, router) {
|
|
7281
7340
|
let routeIds = new Set(router.state.matches.map((m) => m.route.id));
|
|
@@ -7302,8 +7361,8 @@ function getPartialManifest({ sri, ...manifest }, router) {
|
|
|
7302
7361
|
sri: sri ? true : void 0
|
|
7303
7362
|
};
|
|
7304
7363
|
}
|
|
7305
|
-
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr,
|
|
7306
|
-
if (!isFogOfWarEnabled(
|
|
7364
|
+
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
|
|
7365
|
+
if (!isFogOfWarEnabled(ssr)) {
|
|
7307
7366
|
return void 0;
|
|
7308
7367
|
}
|
|
7309
7368
|
return async ({ path, patch, signal, fetcherKey }) => {
|
|
@@ -7318,15 +7377,14 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDi
|
|
|
7318
7377
|
ssr,
|
|
7319
7378
|
isSpaMode,
|
|
7320
7379
|
basename,
|
|
7321
|
-
routeDiscovery.manifestPath,
|
|
7322
7380
|
patch,
|
|
7323
7381
|
signal
|
|
7324
7382
|
);
|
|
7325
7383
|
};
|
|
7326
7384
|
}
|
|
7327
|
-
function useFogOFWarDiscovery(router, manifest, routeModules, ssr,
|
|
7385
|
+
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
7328
7386
|
React8.useEffect(() => {
|
|
7329
|
-
if (!isFogOfWarEnabled(
|
|
7387
|
+
if (!isFogOfWarEnabled(ssr) || navigator.connection?.saveData === true) {
|
|
7330
7388
|
return;
|
|
7331
7389
|
}
|
|
7332
7390
|
function registerElement(el) {
|
|
@@ -7360,7 +7418,6 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscover
|
|
|
7360
7418
|
ssr,
|
|
7361
7419
|
isSpaMode,
|
|
7362
7420
|
router.basename,
|
|
7363
|
-
routeDiscovery.manifestPath,
|
|
7364
7421
|
router.patchRoutes
|
|
7365
7422
|
);
|
|
7366
7423
|
} catch (e) {
|
|
@@ -7377,21 +7434,15 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscover
|
|
|
7377
7434
|
attributeFilter: ["data-discover", "href", "action"]
|
|
7378
7435
|
});
|
|
7379
7436
|
return () => observer.disconnect();
|
|
7380
|
-
}, [ssr, isSpaMode, manifest, routeModules, router
|
|
7381
|
-
}
|
|
7382
|
-
function getManifestPath(_manifestPath, basename) {
|
|
7383
|
-
let manifestPath = _manifestPath || "/__manifest";
|
|
7384
|
-
if (basename == null) {
|
|
7385
|
-
return manifestPath;
|
|
7386
|
-
}
|
|
7387
|
-
return `${basename}${manifestPath}`.replace(/\/+/g, "/");
|
|
7437
|
+
}, [ssr, isSpaMode, manifest, routeModules, router]);
|
|
7388
7438
|
}
|
|
7389
7439
|
var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
|
|
7390
|
-
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename,
|
|
7391
|
-
let
|
|
7392
|
-
|
|
7393
|
-
|
|
7440
|
+
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, patchRoutes, signal) {
|
|
7441
|
+
let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
|
|
7442
|
+
/\/+/g,
|
|
7443
|
+
"/"
|
|
7394
7444
|
);
|
|
7445
|
+
let url = new URL(manifestPath, window.location.origin);
|
|
7395
7446
|
paths.sort().forEach((path) => url.searchParams.append("p", path));
|
|
7396
7447
|
url.searchParams.set("version", manifest.version);
|
|
7397
7448
|
if (url.toString().length > URL_LIMIT) {
|
|
@@ -7418,9 +7469,7 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
7418
7469
|
}
|
|
7419
7470
|
sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
|
|
7420
7471
|
window.location.href = errorReloadPath;
|
|
7421
|
-
|
|
7422
|
-
await new Promise(() => {
|
|
7423
|
-
});
|
|
7472
|
+
throw new Error("Detected manifest version mismatch, reloading...");
|
|
7424
7473
|
} else if (res.status >= 400) {
|
|
7425
7474
|
throw new Error(await res.text());
|
|
7426
7475
|
}
|
|
@@ -7619,7 +7668,7 @@ function PrefetchPageLinksImpl({
|
|
|
7619
7668
|
matches: nextMatches,
|
|
7620
7669
|
...linkProps
|
|
7621
7670
|
}) {
|
|
7622
|
-
let
|
|
7671
|
+
let location2 = useLocation();
|
|
7623
7672
|
let { manifest, routeModules } = useFrameworkContext();
|
|
7624
7673
|
let { basename } = useDataRouterContext2();
|
|
7625
7674
|
let { loaderData, matches } = useDataRouterStateContext();
|
|
@@ -7629,10 +7678,10 @@ function PrefetchPageLinksImpl({
|
|
|
7629
7678
|
nextMatches,
|
|
7630
7679
|
matches,
|
|
7631
7680
|
manifest,
|
|
7632
|
-
|
|
7681
|
+
location2,
|
|
7633
7682
|
"data"
|
|
7634
7683
|
),
|
|
7635
|
-
[page, nextMatches, matches, manifest,
|
|
7684
|
+
[page, nextMatches, matches, manifest, location2]
|
|
7636
7685
|
);
|
|
7637
7686
|
let newMatchesForAssets = React9.useMemo(
|
|
7638
7687
|
() => getNewMatchesForLinks(
|
|
@@ -7640,13 +7689,13 @@ function PrefetchPageLinksImpl({
|
|
|
7640
7689
|
nextMatches,
|
|
7641
7690
|
matches,
|
|
7642
7691
|
manifest,
|
|
7643
|
-
|
|
7692
|
+
location2,
|
|
7644
7693
|
"assets"
|
|
7645
7694
|
),
|
|
7646
|
-
[page, nextMatches, matches, manifest,
|
|
7695
|
+
[page, nextMatches, matches, manifest, location2]
|
|
7647
7696
|
);
|
|
7648
7697
|
let dataHrefs = React9.useMemo(() => {
|
|
7649
|
-
if (page ===
|
|
7698
|
+
if (page === location2.pathname + location2.search + location2.hash) {
|
|
7650
7699
|
return [];
|
|
7651
7700
|
}
|
|
7652
7701
|
let routesParams = /* @__PURE__ */ new Set();
|
|
@@ -7667,7 +7716,7 @@ function PrefetchPageLinksImpl({
|
|
|
7667
7716
|
if (routesParams.size === 0) {
|
|
7668
7717
|
return [];
|
|
7669
7718
|
}
|
|
7670
|
-
let url = singleFetchUrl(page, basename);
|
|
7719
|
+
let url = singleFetchUrl(page, basename, ".data");
|
|
7671
7720
|
if (foundOptOutRoute && routesParams.size > 0) {
|
|
7672
7721
|
url.searchParams.set(
|
|
7673
7722
|
"_routes",
|
|
@@ -7678,7 +7727,7 @@ function PrefetchPageLinksImpl({
|
|
|
7678
7727
|
}, [
|
|
7679
7728
|
basename,
|
|
7680
7729
|
loaderData,
|
|
7681
|
-
|
|
7730
|
+
location2,
|
|
7682
7731
|
manifest,
|
|
7683
7732
|
newMatchesForData,
|
|
7684
7733
|
nextMatches,
|
|
@@ -7703,7 +7752,7 @@ function Meta() {
|
|
|
7703
7752
|
matches: routerMatches,
|
|
7704
7753
|
loaderData
|
|
7705
7754
|
} = useDataRouterStateContext();
|
|
7706
|
-
let
|
|
7755
|
+
let location2 = useLocation();
|
|
7707
7756
|
let _matches = getActiveMatches(routerMatches, errors, isSpaMode);
|
|
7708
7757
|
let error = null;
|
|
7709
7758
|
if (errors) {
|
|
@@ -7733,7 +7782,7 @@ function Meta() {
|
|
|
7733
7782
|
routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
|
|
7734
7783
|
data: data2,
|
|
7735
7784
|
params,
|
|
7736
|
-
location,
|
|
7785
|
+
location: location2,
|
|
7737
7786
|
matches,
|
|
7738
7787
|
error
|
|
7739
7788
|
}) : Array.isArray(routeModule.meta) ? [...routeModule.meta] : routeModule.meta;
|
|
@@ -7799,17 +7848,10 @@ function isValidMetaTag(tagName) {
|
|
|
7799
7848
|
}
|
|
7800
7849
|
var isHydrated = false;
|
|
7801
7850
|
function Scripts(props) {
|
|
7802
|
-
let {
|
|
7803
|
-
manifest,
|
|
7804
|
-
serverHandoffString,
|
|
7805
|
-
isSpaMode,
|
|
7806
|
-
renderMeta,
|
|
7807
|
-
routeDiscovery,
|
|
7808
|
-
ssr
|
|
7809
|
-
} = useFrameworkContext();
|
|
7851
|
+
let { manifest, serverHandoffString, isSpaMode, ssr, renderMeta } = useFrameworkContext();
|
|
7810
7852
|
let { router, static: isStatic, staticContext } = useDataRouterContext2();
|
|
7811
7853
|
let { matches: routerMatches } = useDataRouterStateContext();
|
|
7812
|
-
let enableFogOfWar = isFogOfWarEnabled(
|
|
7854
|
+
let enableFogOfWar = isFogOfWarEnabled(ssr);
|
|
7813
7855
|
if (renderMeta) {
|
|
7814
7856
|
renderMeta.didRenderScripts = true;
|
|
7815
7857
|
}
|
|
@@ -7965,7 +8007,7 @@ function mergeRefs(...refs) {
|
|
|
7965
8007
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
7966
8008
|
try {
|
|
7967
8009
|
if (isBrowser) {
|
|
7968
|
-
window.__reactRouterVersion = "0.0.0-experimental-
|
|
8010
|
+
window.__reactRouterVersion = "0.0.0-experimental-e56aa53bc";
|
|
7969
8011
|
}
|
|
7970
8012
|
} catch (e) {
|
|
7971
8013
|
}
|
|
@@ -8223,14 +8265,14 @@ var NavLink = React10.forwardRef(
|
|
|
8223
8265
|
...rest
|
|
8224
8266
|
}, ref) {
|
|
8225
8267
|
let path = useResolvedPath(to, { relative: rest.relative });
|
|
8226
|
-
let
|
|
8268
|
+
let location2 = useLocation();
|
|
8227
8269
|
let routerState = React10.useContext(DataRouterStateContext);
|
|
8228
8270
|
let { navigator: navigator2, basename } = React10.useContext(NavigationContext);
|
|
8229
8271
|
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
|
8230
8272
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
8231
8273
|
useViewTransitionState(path) && viewTransition === true;
|
|
8232
8274
|
let toPathname = navigator2.encodeLocation ? navigator2.encodeLocation(path).pathname : path.pathname;
|
|
8233
|
-
let locationPathname =
|
|
8275
|
+
let locationPathname = location2.pathname;
|
|
8234
8276
|
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
|
|
8235
8277
|
if (!caseSensitive) {
|
|
8236
8278
|
locationPathname = locationPathname.toLowerCase();
|
|
@@ -8335,19 +8377,19 @@ function ScrollRestoration({
|
|
|
8335
8377
|
}) {
|
|
8336
8378
|
let remixContext = React10.useContext(FrameworkContext);
|
|
8337
8379
|
let { basename } = React10.useContext(NavigationContext);
|
|
8338
|
-
let
|
|
8380
|
+
let location2 = useLocation();
|
|
8339
8381
|
let matches = useMatches();
|
|
8340
8382
|
useScrollRestoration({ getKey, storageKey });
|
|
8341
8383
|
let ssrKey = React10.useMemo(
|
|
8342
8384
|
() => {
|
|
8343
8385
|
if (!remixContext || !getKey) return null;
|
|
8344
8386
|
let userKey = getScrollRestorationKey(
|
|
8345
|
-
|
|
8387
|
+
location2,
|
|
8346
8388
|
matches,
|
|
8347
8389
|
basename,
|
|
8348
8390
|
getKey
|
|
8349
8391
|
);
|
|
8350
|
-
return userKey !==
|
|
8392
|
+
return userKey !== location2.key ? userKey : null;
|
|
8351
8393
|
},
|
|
8352
8394
|
// Nah, we only need this the first time for the SSR render
|
|
8353
8395
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -8408,13 +8450,13 @@ function useLinkClickHandler(to, {
|
|
|
8408
8450
|
viewTransition
|
|
8409
8451
|
} = {}) {
|
|
8410
8452
|
let navigate = useNavigate();
|
|
8411
|
-
let
|
|
8453
|
+
let location2 = useLocation();
|
|
8412
8454
|
let path = useResolvedPath(to, { relative });
|
|
8413
8455
|
return React10.useCallback(
|
|
8414
8456
|
(event) => {
|
|
8415
8457
|
if (shouldProcessLinkClick(event, target)) {
|
|
8416
8458
|
event.preventDefault();
|
|
8417
|
-
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(
|
|
8459
|
+
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location2) === createPath(path);
|
|
8418
8460
|
navigate(to, {
|
|
8419
8461
|
replace: replace2,
|
|
8420
8462
|
state,
|
|
@@ -8425,7 +8467,7 @@ function useLinkClickHandler(to, {
|
|
|
8425
8467
|
}
|
|
8426
8468
|
},
|
|
8427
8469
|
[
|
|
8428
|
-
|
|
8470
|
+
location2,
|
|
8429
8471
|
navigate,
|
|
8430
8472
|
path,
|
|
8431
8473
|
replaceProp,
|
|
@@ -8445,18 +8487,18 @@ function useSearchParams(defaultInit) {
|
|
|
8445
8487
|
);
|
|
8446
8488
|
let defaultSearchParamsRef = React10.useRef(createSearchParams(defaultInit));
|
|
8447
8489
|
let hasSetSearchParamsRef = React10.useRef(false);
|
|
8448
|
-
let
|
|
8490
|
+
let location2 = useLocation();
|
|
8449
8491
|
let searchParams = React10.useMemo(
|
|
8450
8492
|
() => (
|
|
8451
8493
|
// Only merge in the defaults if we haven't yet called setSearchParams.
|
|
8452
8494
|
// Once we call that we want those to take precedence, otherwise you can't
|
|
8453
8495
|
// remove a param with setSearchParams({}) if it has an initial value
|
|
8454
8496
|
getSearchParamsForLocation(
|
|
8455
|
-
|
|
8497
|
+
location2.search,
|
|
8456
8498
|
hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
|
|
8457
8499
|
)
|
|
8458
8500
|
),
|
|
8459
|
-
[
|
|
8501
|
+
[location2.search]
|
|
8460
8502
|
);
|
|
8461
8503
|
let navigate = useNavigate();
|
|
8462
8504
|
let setSearchParams = React10.useCallback(
|
|
@@ -8517,9 +8559,9 @@ function useFormAction(action, { relative } = {}) {
|
|
|
8517
8559
|
invariant(routeContext, "useFormAction must be used inside a RouteContext");
|
|
8518
8560
|
let [match] = routeContext.matches.slice(-1);
|
|
8519
8561
|
let path = { ...useResolvedPath(action ? action : ".", { relative }) };
|
|
8520
|
-
let
|
|
8562
|
+
let location2 = useLocation();
|
|
8521
8563
|
if (action == null) {
|
|
8522
|
-
path.search =
|
|
8564
|
+
path.search = location2.search;
|
|
8523
8565
|
let params = new URLSearchParams(path.search);
|
|
8524
8566
|
let indexValues = params.getAll("index");
|
|
8525
8567
|
let hasNakedIndexParam = indexValues.some((v) => v === "");
|
|
@@ -8611,23 +8653,23 @@ function useFetchers() {
|
|
|
8611
8653
|
}
|
|
8612
8654
|
var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
|
|
8613
8655
|
var savedScrollPositions = {};
|
|
8614
|
-
function getScrollRestorationKey(
|
|
8656
|
+
function getScrollRestorationKey(location2, matches, basename, getKey) {
|
|
8615
8657
|
let key = null;
|
|
8616
8658
|
if (getKey) {
|
|
8617
8659
|
if (basename !== "/") {
|
|
8618
8660
|
key = getKey(
|
|
8619
8661
|
{
|
|
8620
|
-
...
|
|
8621
|
-
pathname: stripBasename(
|
|
8662
|
+
...location2,
|
|
8663
|
+
pathname: stripBasename(location2.pathname, basename) || location2.pathname
|
|
8622
8664
|
},
|
|
8623
8665
|
matches
|
|
8624
8666
|
);
|
|
8625
8667
|
} else {
|
|
8626
|
-
key = getKey(
|
|
8668
|
+
key = getKey(location2, matches);
|
|
8627
8669
|
}
|
|
8628
8670
|
}
|
|
8629
8671
|
if (key == null) {
|
|
8630
|
-
key =
|
|
8672
|
+
key = location2.key;
|
|
8631
8673
|
}
|
|
8632
8674
|
return key;
|
|
8633
8675
|
}
|
|
@@ -8640,7 +8682,7 @@ function useScrollRestoration({
|
|
|
8640
8682
|
"useScrollRestoration" /* UseScrollRestoration */
|
|
8641
8683
|
);
|
|
8642
8684
|
let { basename } = React10.useContext(NavigationContext);
|
|
8643
|
-
let
|
|
8685
|
+
let location2 = useLocation();
|
|
8644
8686
|
let matches = useMatches();
|
|
8645
8687
|
let navigation = useNavigation();
|
|
8646
8688
|
React10.useEffect(() => {
|
|
@@ -8652,7 +8694,7 @@ function useScrollRestoration({
|
|
|
8652
8694
|
usePageHide(
|
|
8653
8695
|
React10.useCallback(() => {
|
|
8654
8696
|
if (navigation.state === "idle") {
|
|
8655
|
-
let key = getScrollRestorationKey(
|
|
8697
|
+
let key = getScrollRestorationKey(location2, matches, basename, getKey);
|
|
8656
8698
|
savedScrollPositions[key] = window.scrollY;
|
|
8657
8699
|
}
|
|
8658
8700
|
try {
|
|
@@ -8667,7 +8709,7 @@ function useScrollRestoration({
|
|
|
8667
8709
|
);
|
|
8668
8710
|
}
|
|
8669
8711
|
window.history.scrollRestoration = "auto";
|
|
8670
|
-
}, [navigation.state, getKey, basename,
|
|
8712
|
+
}, [navigation.state, getKey, basename, location2, matches, storageKey])
|
|
8671
8713
|
);
|
|
8672
8714
|
if (typeof document !== "undefined") {
|
|
8673
8715
|
React10.useLayoutEffect(() => {
|
|
@@ -8685,7 +8727,7 @@ function useScrollRestoration({
|
|
|
8685
8727
|
let disableScrollRestoration = router?.enableScrollRestoration(
|
|
8686
8728
|
savedScrollPositions,
|
|
8687
8729
|
() => window.scrollY,
|
|
8688
|
-
getKey ? (
|
|
8730
|
+
getKey ? (location3, matches2) => getScrollRestorationKey(location3, matches2, basename, getKey) : void 0
|
|
8689
8731
|
);
|
|
8690
8732
|
return () => disableScrollRestoration && disableScrollRestoration();
|
|
8691
8733
|
}, [router, basename, getKey]);
|
|
@@ -8697,9 +8739,9 @@ function useScrollRestoration({
|
|
|
8697
8739
|
window.scrollTo(0, restoreScrollPosition);
|
|
8698
8740
|
return;
|
|
8699
8741
|
}
|
|
8700
|
-
if (
|
|
8742
|
+
if (location2.hash) {
|
|
8701
8743
|
let el = document.getElementById(
|
|
8702
|
-
decodeURIComponent(
|
|
8744
|
+
decodeURIComponent(location2.hash.slice(1))
|
|
8703
8745
|
);
|
|
8704
8746
|
if (el) {
|
|
8705
8747
|
el.scrollIntoView();
|
|
@@ -8710,7 +8752,7 @@ function useScrollRestoration({
|
|
|
8710
8752
|
return;
|
|
8711
8753
|
}
|
|
8712
8754
|
window.scrollTo(0, 0);
|
|
8713
|
-
}, [
|
|
8755
|
+
}, [location2, restoreScrollPosition, preventScrollReset]);
|
|
8714
8756
|
}
|
|
8715
8757
|
}
|
|
8716
8758
|
function useBeforeUnload(callback, options) {
|
|
@@ -8783,7 +8825,7 @@ function StaticRouter({
|
|
|
8783
8825
|
locationProp = parsePath(locationProp);
|
|
8784
8826
|
}
|
|
8785
8827
|
let action = "POP" /* Pop */;
|
|
8786
|
-
let
|
|
8828
|
+
let location2 = {
|
|
8787
8829
|
pathname: locationProp.pathname || "/",
|
|
8788
8830
|
search: locationProp.search || "",
|
|
8789
8831
|
hash: locationProp.hash || "",
|
|
@@ -8796,7 +8838,7 @@ function StaticRouter({
|
|
|
8796
8838
|
{
|
|
8797
8839
|
basename,
|
|
8798
8840
|
children,
|
|
8799
|
-
location,
|
|
8841
|
+
location: location2,
|
|
8800
8842
|
navigationType: action,
|
|
8801
8843
|
navigator: staticNavigator,
|
|
8802
8844
|
static: true
|
|
@@ -9015,6 +9057,9 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
9015
9057
|
_internalFetchControllers: /* @__PURE__ */ new Map(),
|
|
9016
9058
|
_internalSetRoutes() {
|
|
9017
9059
|
throw msg("_internalSetRoutes");
|
|
9060
|
+
},
|
|
9061
|
+
_internalSetStateDoNotUseOrYouWillBreakYourApp() {
|
|
9062
|
+
throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
|
|
9018
9063
|
}
|
|
9019
9064
|
};
|
|
9020
9065
|
}
|
|
@@ -9089,7 +9134,6 @@ function ServerRouter({
|
|
|
9089
9134
|
future: context.future,
|
|
9090
9135
|
ssr: context.ssr,
|
|
9091
9136
|
isSpaMode: context.isSpaMode,
|
|
9092
|
-
routeDiscovery: context.routeDiscovery,
|
|
9093
9137
|
serializeError: context.serializeError,
|
|
9094
9138
|
renderMeta: context.renderMeta
|
|
9095
9139
|
}
|
|
@@ -9139,8 +9183,7 @@ function createRoutesStub(routes, unstable_getContext) {
|
|
|
9139
9183
|
},
|
|
9140
9184
|
routeModules: {},
|
|
9141
9185
|
ssr: false,
|
|
9142
|
-
isSpaMode: false
|
|
9143
|
-
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }
|
|
9186
|
+
isSpaMode: false
|
|
9144
9187
|
};
|
|
9145
9188
|
let patched = processRoutes(
|
|
9146
9189
|
// @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
|
|
@@ -9544,26 +9587,6 @@ function invariant3(value, message) {
|
|
|
9544
9587
|
}
|
|
9545
9588
|
}
|
|
9546
9589
|
|
|
9547
|
-
// lib/server-runtime/dev.ts
|
|
9548
|
-
var globalDevServerHooksKey = "__reactRouterDevServerHooks";
|
|
9549
|
-
function setDevServerHooks(devServerHooks) {
|
|
9550
|
-
globalThis[globalDevServerHooksKey] = devServerHooks;
|
|
9551
|
-
}
|
|
9552
|
-
function getDevServerHooks() {
|
|
9553
|
-
return globalThis[globalDevServerHooksKey];
|
|
9554
|
-
}
|
|
9555
|
-
function getBuildTimeHeader(request, headerName) {
|
|
9556
|
-
if (typeof process !== "undefined") {
|
|
9557
|
-
try {
|
|
9558
|
-
if (process.env?.IS_RR_BUILD_REQUEST === "yes") {
|
|
9559
|
-
return request.headers.get(headerName);
|
|
9560
|
-
}
|
|
9561
|
-
} catch (e) {
|
|
9562
|
-
}
|
|
9563
|
-
}
|
|
9564
|
-
return null;
|
|
9565
|
-
}
|
|
9566
|
-
|
|
9567
9590
|
// lib/server-runtime/routes.ts
|
|
9568
9591
|
function groupRoutesByParentId2(manifest) {
|
|
9569
9592
|
let routes = {};
|
|
@@ -9595,11 +9618,10 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
|
|
|
9595
9618
|
// Need to use RR's version in the param typed here to permit the optional
|
|
9596
9619
|
// context even though we know it'll always be provided in remix
|
|
9597
9620
|
loader: route.module.loader ? async (args) => {
|
|
9598
|
-
|
|
9599
|
-
args.request
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
if (preRenderedData != null) {
|
|
9621
|
+
if (args.request.headers.has("X-React-Router-Prerender-Data")) {
|
|
9622
|
+
const preRenderedData = args.request.headers.get(
|
|
9623
|
+
"X-React-Router-Prerender-Data"
|
|
9624
|
+
);
|
|
9603
9625
|
let encoded = preRenderedData ? decodeURI(preRenderedData) : preRenderedData;
|
|
9604
9626
|
invariant3(encoded, "Missing prerendered data for route");
|
|
9605
9627
|
let uint8array = new TextEncoder().encode(encoded);
|
|
@@ -9674,12 +9696,21 @@ function createServerHandoffString(serverHandoff) {
|
|
|
9674
9696
|
return escapeHtml2(JSON.stringify(serverHandoff));
|
|
9675
9697
|
}
|
|
9676
9698
|
|
|
9699
|
+
// lib/server-runtime/dev.ts
|
|
9700
|
+
var globalDevServerHooksKey = "__reactRouterDevServerHooks";
|
|
9701
|
+
function setDevServerHooks(devServerHooks) {
|
|
9702
|
+
globalThis[globalDevServerHooksKey] = devServerHooks;
|
|
9703
|
+
}
|
|
9704
|
+
function getDevServerHooks() {
|
|
9705
|
+
return globalThis[globalDevServerHooksKey];
|
|
9706
|
+
}
|
|
9707
|
+
|
|
9677
9708
|
// lib/server-runtime/single-fetch.ts
|
|
9678
9709
|
import { encode } from "turbo-stream";
|
|
9679
9710
|
|
|
9680
9711
|
// lib/server-runtime/headers.ts
|
|
9681
9712
|
import { splitCookiesString } from "set-cookie-parser";
|
|
9682
|
-
function getDocumentHeaders(
|
|
9713
|
+
function getDocumentHeaders(context, getRouteHeadersFn) {
|
|
9683
9714
|
let boundaryIdx = context.errors ? context.matches.findIndex((m) => context.errors[m.route.id]) : -1;
|
|
9684
9715
|
let matches = boundaryIdx >= 0 ? context.matches.slice(0, boundaryIdx + 1) : context.matches;
|
|
9685
9716
|
let errorHeaders;
|
|
@@ -9697,14 +9728,12 @@ function getDocumentHeaders(build, context) {
|
|
|
9697
9728
|
}
|
|
9698
9729
|
return matches.reduce((parentHeaders, match, idx) => {
|
|
9699
9730
|
let { id } = match.route;
|
|
9700
|
-
let route = build.routes[id];
|
|
9701
|
-
invariant3(route, `Route with id "${id}" not found in build`);
|
|
9702
|
-
let routeModule = route.module;
|
|
9703
9731
|
let loaderHeaders = context.loaderHeaders[id] || new Headers();
|
|
9704
9732
|
let actionHeaders = context.actionHeaders[id] || new Headers();
|
|
9705
9733
|
let includeErrorHeaders = errorHeaders != null && idx === matches.length - 1;
|
|
9706
9734
|
let includeErrorCookies = includeErrorHeaders && errorHeaders !== loaderHeaders && errorHeaders !== actionHeaders;
|
|
9707
|
-
|
|
9735
|
+
let headersFn = getRouteHeadersFn(match);
|
|
9736
|
+
if (headersFn == null) {
|
|
9708
9737
|
let headers2 = new Headers(parentHeaders);
|
|
9709
9738
|
if (includeErrorCookies) {
|
|
9710
9739
|
prependCookies(errorHeaders, headers2);
|
|
@@ -9714,12 +9743,12 @@ function getDocumentHeaders(build, context) {
|
|
|
9714
9743
|
return headers2;
|
|
9715
9744
|
}
|
|
9716
9745
|
let headers = new Headers(
|
|
9717
|
-
|
|
9746
|
+
typeof headersFn === "function" ? headersFn({
|
|
9718
9747
|
loaderHeaders,
|
|
9719
9748
|
parentHeaders,
|
|
9720
9749
|
actionHeaders,
|
|
9721
9750
|
errorHeaders: includeErrorHeaders ? errorHeaders : void 0
|
|
9722
|
-
}) :
|
|
9751
|
+
}) : headersFn
|
|
9723
9752
|
);
|
|
9724
9753
|
if (includeErrorCookies) {
|
|
9725
9754
|
prependCookies(errorHeaders, headers);
|
|
@@ -9744,6 +9773,7 @@ function prependCookies(parentHeaders, childHeaders) {
|
|
|
9744
9773
|
}
|
|
9745
9774
|
|
|
9746
9775
|
// lib/server-runtime/single-fetch.ts
|
|
9776
|
+
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
9747
9777
|
var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
9748
9778
|
...NO_BODY_STATUS_CODES,
|
|
9749
9779
|
304
|
|
@@ -9751,7 +9781,10 @@ var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
|
9751
9781
|
async function singleFetchAction(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
9752
9782
|
try {
|
|
9753
9783
|
let respond2 = function(context) {
|
|
9754
|
-
let headers = getDocumentHeaders(
|
|
9784
|
+
let headers = getDocumentHeaders(
|
|
9785
|
+
context,
|
|
9786
|
+
(m) => build.routes[m.route.id]?.module.headers
|
|
9787
|
+
);
|
|
9755
9788
|
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
9756
9789
|
return generateSingleFetchResponse(request, build, serverMode, {
|
|
9757
9790
|
result: getSingleFetchRedirect(
|
|
@@ -9826,7 +9859,10 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
|
|
|
9826
9859
|
async function singleFetchLoaders(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
9827
9860
|
try {
|
|
9828
9861
|
let respond2 = function(context) {
|
|
9829
|
-
let headers = getDocumentHeaders(
|
|
9862
|
+
let headers = getDocumentHeaders(
|
|
9863
|
+
context,
|
|
9864
|
+
(m) => build.routes[m.route.id]?.module.headers
|
|
9865
|
+
);
|
|
9830
9866
|
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
9831
9867
|
return generateSingleFetchResponse(request, build, serverMode, {
|
|
9832
9868
|
result: {
|
|
@@ -10082,10 +10118,9 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10082
10118
|
if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
|
|
10083
10119
|
normalizedPath = normalizedPath.slice(0, -1);
|
|
10084
10120
|
}
|
|
10085
|
-
let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
|
|
10086
10121
|
if (!_build.ssr) {
|
|
10087
10122
|
if (_build.prerender.length === 0) {
|
|
10088
|
-
|
|
10123
|
+
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
10089
10124
|
} else if (!_build.prerender.includes(normalizedPath) && !_build.prerender.includes(normalizedPath + "/")) {
|
|
10090
10125
|
if (url.pathname.endsWith(".data")) {
|
|
10091
10126
|
errorHandler(
|
|
@@ -10105,14 +10140,11 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10105
10140
|
statusText: "Not Found"
|
|
10106
10141
|
});
|
|
10107
10142
|
} else {
|
|
10108
|
-
|
|
10143
|
+
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
10109
10144
|
}
|
|
10110
10145
|
}
|
|
10111
10146
|
}
|
|
10112
|
-
let manifestUrl =
|
|
10113
|
-
_build.routeDiscovery.manifestPath,
|
|
10114
|
-
normalizedBasename
|
|
10115
|
-
);
|
|
10147
|
+
let manifestUrl = `${normalizedBasename}/__manifest`.replace(/\/+/g, "/");
|
|
10116
10148
|
if (url.pathname === manifestUrl) {
|
|
10117
10149
|
try {
|
|
10118
10150
|
let res = await handleManifestRequest(_build, routes, url);
|
|
@@ -10122,7 +10154,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10122
10154
|
return new Response("Unknown Server Error", { status: 500 });
|
|
10123
10155
|
}
|
|
10124
10156
|
}
|
|
10125
|
-
let matches = matchServerRoutes(routes,
|
|
10157
|
+
let matches = matchServerRoutes(routes, url.pathname, _build.basename);
|
|
10126
10158
|
if (matches && matches.length > 0) {
|
|
10127
10159
|
Object.assign(params, matches[0].params);
|
|
10128
10160
|
}
|
|
@@ -10177,7 +10209,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10177
10209
|
);
|
|
10178
10210
|
}
|
|
10179
10211
|
}
|
|
10180
|
-
} else if (!
|
|
10212
|
+
} 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) {
|
|
10181
10213
|
response = await handleResourceRequest(
|
|
10182
10214
|
serverMode,
|
|
10183
10215
|
_build,
|
|
@@ -10202,7 +10234,6 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10202
10234
|
request,
|
|
10203
10235
|
loadContext,
|
|
10204
10236
|
handleError,
|
|
10205
|
-
isSpaMode,
|
|
10206
10237
|
criticalCss
|
|
10207
10238
|
);
|
|
10208
10239
|
}
|
|
@@ -10278,7 +10309,8 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
|
|
|
10278
10309
|
);
|
|
10279
10310
|
return response;
|
|
10280
10311
|
}
|
|
10281
|
-
async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError,
|
|
10312
|
+
async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, criticalCss) {
|
|
10313
|
+
let isSpaMode = request.headers.has("X-React-Router-SPA-Mode");
|
|
10282
10314
|
try {
|
|
10283
10315
|
let response = await staticHandler.query(request, {
|
|
10284
10316
|
requestContext: loadContext,
|
|
@@ -10293,7 +10325,10 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10293
10325
|
if (isResponse(context)) {
|
|
10294
10326
|
return context;
|
|
10295
10327
|
}
|
|
10296
|
-
let headers = getDocumentHeaders(
|
|
10328
|
+
let headers = getDocumentHeaders(
|
|
10329
|
+
context,
|
|
10330
|
+
(m) => build.routes[m.route.id]?.module.headers
|
|
10331
|
+
);
|
|
10297
10332
|
if (SERVER_NO_BODY_STATUS_CODES.has(context.statusCode)) {
|
|
10298
10333
|
return new Response(null, { status: context.statusCode, headers });
|
|
10299
10334
|
}
|
|
@@ -10310,21 +10345,17 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10310
10345
|
actionData: context.actionData,
|
|
10311
10346
|
errors: serializeErrors2(context.errors, serverMode)
|
|
10312
10347
|
};
|
|
10313
|
-
let baseServerHandoff = {
|
|
10314
|
-
basename: build.basename,
|
|
10315
|
-
future: build.future,
|
|
10316
|
-
routeDiscovery: build.routeDiscovery,
|
|
10317
|
-
ssr: build.ssr,
|
|
10318
|
-
isSpaMode: isSpaMode2
|
|
10319
|
-
};
|
|
10320
10348
|
let entryContext = {
|
|
10321
10349
|
manifest: build.assets,
|
|
10322
10350
|
routeModules: createEntryRouteModules(build.routes),
|
|
10323
10351
|
staticHandlerContext: context,
|
|
10324
10352
|
criticalCss,
|
|
10325
10353
|
serverHandoffString: createServerHandoffString({
|
|
10326
|
-
|
|
10327
|
-
criticalCss
|
|
10354
|
+
basename: build.basename,
|
|
10355
|
+
criticalCss,
|
|
10356
|
+
future: build.future,
|
|
10357
|
+
ssr: build.ssr,
|
|
10358
|
+
isSpaMode: isSpaMode2
|
|
10328
10359
|
}),
|
|
10329
10360
|
serverHandoffStream: encodeViaTurboStream(
|
|
10330
10361
|
state,
|
|
@@ -10335,7 +10366,6 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10335
10366
|
renderMeta: {},
|
|
10336
10367
|
future: build.future,
|
|
10337
10368
|
ssr: build.ssr,
|
|
10338
|
-
routeDiscovery: build.routeDiscovery,
|
|
10339
10369
|
isSpaMode: isSpaMode2,
|
|
10340
10370
|
serializeError: (err) => serializeError(err, serverMode)
|
|
10341
10371
|
};
|
|
@@ -10378,7 +10408,12 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10378
10408
|
entryContext = {
|
|
10379
10409
|
...entryContext,
|
|
10380
10410
|
staticHandlerContext: context,
|
|
10381
|
-
serverHandoffString: createServerHandoffString(
|
|
10411
|
+
serverHandoffString: createServerHandoffString({
|
|
10412
|
+
basename: build.basename,
|
|
10413
|
+
future: build.future,
|
|
10414
|
+
ssr: build.ssr,
|
|
10415
|
+
isSpaMode: isSpaMode2
|
|
10416
|
+
}),
|
|
10382
10417
|
serverHandoffStream: encodeViaTurboStream(
|
|
10383
10418
|
state2,
|
|
10384
10419
|
request.signal,
|
|
@@ -10551,7 +10586,7 @@ function createSessionStorage({
|
|
|
10551
10586
|
function warnOnceAboutSigningSessionCookie(cookie) {
|
|
10552
10587
|
warnOnce(
|
|
10553
10588
|
cookie.isSigned,
|
|
10554
|
-
`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://
|
|
10589
|
+
`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.`
|
|
10555
10590
|
);
|
|
10556
10591
|
}
|
|
10557
10592
|
|
|
@@ -10631,6 +10666,680 @@ function href(path, ...args) {
|
|
|
10631
10666
|
}).filter((segment) => segment !== void 0).join("/");
|
|
10632
10667
|
}
|
|
10633
10668
|
|
|
10669
|
+
// lib/rsc/browser.tsx
|
|
10670
|
+
import * as React14 from "react";
|
|
10671
|
+
|
|
10672
|
+
// lib/dom/ssr/hydration.tsx
|
|
10673
|
+
function getHydrationData(state, routes, getRouteInfo, location2, basename, isSpaMode) {
|
|
10674
|
+
let hydrationData = {
|
|
10675
|
+
...state,
|
|
10676
|
+
loaderData: { ...state.loaderData }
|
|
10677
|
+
};
|
|
10678
|
+
let initialMatches = matchRoutes(routes, location2, basename);
|
|
10679
|
+
if (initialMatches) {
|
|
10680
|
+
for (let match of initialMatches) {
|
|
10681
|
+
let routeId = match.route.id;
|
|
10682
|
+
let routeInfo = getRouteInfo(routeId);
|
|
10683
|
+
if (shouldHydrateRouteLoader(
|
|
10684
|
+
routeId,
|
|
10685
|
+
routeInfo.clientLoader,
|
|
10686
|
+
routeInfo.hasLoader,
|
|
10687
|
+
isSpaMode
|
|
10688
|
+
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
|
|
10689
|
+
delete hydrationData.loaderData[routeId];
|
|
10690
|
+
} else if (!routeInfo.hasLoader) {
|
|
10691
|
+
hydrationData.loaderData[routeId] = null;
|
|
10692
|
+
}
|
|
10693
|
+
}
|
|
10694
|
+
}
|
|
10695
|
+
return hydrationData;
|
|
10696
|
+
}
|
|
10697
|
+
|
|
10698
|
+
// lib/rsc/browser.tsx
|
|
10699
|
+
function createCallServer({
|
|
10700
|
+
decode: decode2,
|
|
10701
|
+
encodeAction
|
|
10702
|
+
}) {
|
|
10703
|
+
let landedActionId = 0;
|
|
10704
|
+
return async (id, args) => {
|
|
10705
|
+
let actionId = window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
|
|
10706
|
+
const response = await fetch(location.href, {
|
|
10707
|
+
body: await encodeAction(args),
|
|
10708
|
+
method: "POST",
|
|
10709
|
+
headers: {
|
|
10710
|
+
Accept: "text/x-component",
|
|
10711
|
+
"rsc-action-id": id
|
|
10712
|
+
}
|
|
10713
|
+
});
|
|
10714
|
+
if (!response.body) {
|
|
10715
|
+
throw new Error("No response body");
|
|
10716
|
+
}
|
|
10717
|
+
const payload = await decode2(response.body);
|
|
10718
|
+
if (payload.type !== "action") {
|
|
10719
|
+
throw new Error("Unexpected payload type");
|
|
10720
|
+
}
|
|
10721
|
+
if (payload.rerender) {
|
|
10722
|
+
(async () => {
|
|
10723
|
+
const rerender = await payload.rerender;
|
|
10724
|
+
if (!rerender) return;
|
|
10725
|
+
if (landedActionId < actionId && window.__routerActionID <= actionId) {
|
|
10726
|
+
landedActionId = actionId;
|
|
10727
|
+
if (rerender.type === "redirect") {
|
|
10728
|
+
if (rerender.reload) {
|
|
10729
|
+
window.location.href = rerender.location;
|
|
10730
|
+
return;
|
|
10731
|
+
}
|
|
10732
|
+
window.__router.navigate(rerender.location, {
|
|
10733
|
+
replace: rerender.replace
|
|
10734
|
+
});
|
|
10735
|
+
return;
|
|
10736
|
+
}
|
|
10737
|
+
let lastMatch;
|
|
10738
|
+
for (const match of rerender.matches) {
|
|
10739
|
+
window.__router.patchRoutes(
|
|
10740
|
+
lastMatch?.id ?? null,
|
|
10741
|
+
[createRouteFromServerManifest(match)],
|
|
10742
|
+
true
|
|
10743
|
+
);
|
|
10744
|
+
lastMatch = match;
|
|
10745
|
+
}
|
|
10746
|
+
window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({});
|
|
10747
|
+
React14.startTransition(() => {
|
|
10748
|
+
window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({
|
|
10749
|
+
loaderData: Object.assign(
|
|
10750
|
+
{},
|
|
10751
|
+
window.__router.state.loaderData,
|
|
10752
|
+
rerender.loaderData
|
|
10753
|
+
),
|
|
10754
|
+
errors: rerender.errors ? Object.assign(
|
|
10755
|
+
{},
|
|
10756
|
+
window.__router.state.errors,
|
|
10757
|
+
rerender.errors
|
|
10758
|
+
) : null
|
|
10759
|
+
});
|
|
10760
|
+
});
|
|
10761
|
+
}
|
|
10762
|
+
})();
|
|
10763
|
+
}
|
|
10764
|
+
return payload.actionResult;
|
|
10765
|
+
};
|
|
10766
|
+
}
|
|
10767
|
+
function createRouterFromPayload({
|
|
10768
|
+
decode: decode2,
|
|
10769
|
+
payload
|
|
10770
|
+
}) {
|
|
10771
|
+
if (window.__router) return window.__router;
|
|
10772
|
+
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
10773
|
+
let patches = /* @__PURE__ */ new Map();
|
|
10774
|
+
payload.patches?.forEach((patch) => {
|
|
10775
|
+
invariant(patch.parentId, "Invalid patch parentId");
|
|
10776
|
+
if (!patches.has(patch.parentId)) {
|
|
10777
|
+
patches.set(patch.parentId, []);
|
|
10778
|
+
}
|
|
10779
|
+
patches.get(patch.parentId)?.push(patch);
|
|
10780
|
+
});
|
|
10781
|
+
let routes = payload.matches.reduceRight((previous, match) => {
|
|
10782
|
+
const route = createRouteFromServerManifest(
|
|
10783
|
+
match,
|
|
10784
|
+
payload
|
|
10785
|
+
);
|
|
10786
|
+
if (previous.length > 0) {
|
|
10787
|
+
route.children = previous;
|
|
10788
|
+
let childrenToPatch = patches.get(match.id);
|
|
10789
|
+
if (childrenToPatch) {
|
|
10790
|
+
route.children.push(
|
|
10791
|
+
...childrenToPatch.map((r) => createRouteFromServerManifest(r))
|
|
10792
|
+
);
|
|
10793
|
+
}
|
|
10794
|
+
}
|
|
10795
|
+
return [route];
|
|
10796
|
+
}, []);
|
|
10797
|
+
window.__router = createRouter({
|
|
10798
|
+
routes,
|
|
10799
|
+
basename: payload.basename,
|
|
10800
|
+
history: createBrowserHistory(),
|
|
10801
|
+
hydrationData: getHydrationData(
|
|
10802
|
+
{
|
|
10803
|
+
loaderData: payload.loaderData,
|
|
10804
|
+
actionData: payload.actionData,
|
|
10805
|
+
errors: payload.errors
|
|
10806
|
+
},
|
|
10807
|
+
routes,
|
|
10808
|
+
(routeId) => {
|
|
10809
|
+
let match = payload.matches.find((m) => m.id === routeId);
|
|
10810
|
+
invariant(match, "Route not found in payload");
|
|
10811
|
+
return {
|
|
10812
|
+
clientLoader: match.clientLoader,
|
|
10813
|
+
hasLoader: match.hasLoader,
|
|
10814
|
+
hasHydrateFallback: match.hydrateFallbackElement != null
|
|
10815
|
+
};
|
|
10816
|
+
},
|
|
10817
|
+
payload.location,
|
|
10818
|
+
void 0,
|
|
10819
|
+
false
|
|
10820
|
+
),
|
|
10821
|
+
async patchRoutesOnNavigation({ patch, path, signal }) {
|
|
10822
|
+
let response = await fetch(`${path}.manifest`, { signal });
|
|
10823
|
+
if (!response.body || response.status < 200 || response.status >= 300) {
|
|
10824
|
+
throw new Error("Unable to fetch new route matches from the server");
|
|
10825
|
+
}
|
|
10826
|
+
let payload2 = await decode2(response.body);
|
|
10827
|
+
if (payload2.type !== "manifest") {
|
|
10828
|
+
throw new Error("Failed to patch routes on navigation");
|
|
10829
|
+
}
|
|
10830
|
+
payload2.matches.forEach(
|
|
10831
|
+
(match, i) => patch(payload2.matches[i - 1]?.id ?? null, [
|
|
10832
|
+
createRouteFromServerManifest(match)
|
|
10833
|
+
])
|
|
10834
|
+
);
|
|
10835
|
+
payload2.patches.forEach((p) => {
|
|
10836
|
+
patch(p.parentId ?? null, [createRouteFromServerManifest(p)]);
|
|
10837
|
+
});
|
|
10838
|
+
},
|
|
10839
|
+
// FIXME: Pass `build.ssr` and `build.basename` into this function
|
|
10840
|
+
dataStrategy: getRSCSingleFetchDataStrategy(
|
|
10841
|
+
() => window.__router,
|
|
10842
|
+
true,
|
|
10843
|
+
void 0,
|
|
10844
|
+
decode2
|
|
10845
|
+
)
|
|
10846
|
+
});
|
|
10847
|
+
if (window.__router.state.initialized) {
|
|
10848
|
+
window.__routerInitialized = true;
|
|
10849
|
+
window.__router.initialize();
|
|
10850
|
+
} else {
|
|
10851
|
+
window.__routerInitialized = false;
|
|
10852
|
+
}
|
|
10853
|
+
let lastLoaderData = void 0;
|
|
10854
|
+
window.__router.subscribe(({ loaderData, actionData }) => {
|
|
10855
|
+
if (lastLoaderData !== loaderData) {
|
|
10856
|
+
window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
|
|
10857
|
+
}
|
|
10858
|
+
});
|
|
10859
|
+
return window.__router;
|
|
10860
|
+
}
|
|
10861
|
+
var renderedRoutesContext = unstable_createContext();
|
|
10862
|
+
function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, decode2) {
|
|
10863
|
+
let dataStrategy = getSingleFetchDataStrategyImpl(
|
|
10864
|
+
getRouter,
|
|
10865
|
+
(match) => {
|
|
10866
|
+
let M = match;
|
|
10867
|
+
return {
|
|
10868
|
+
hasLoader: M.route.hasLoader,
|
|
10869
|
+
hasClientLoader: M.route.hasClientLoader,
|
|
10870
|
+
hasAction: M.route.hasAction,
|
|
10871
|
+
hasClientAction: M.route.hasClientAction,
|
|
10872
|
+
hasShouldRevalidate: M.route.hasShouldRevalidate
|
|
10873
|
+
};
|
|
10874
|
+
},
|
|
10875
|
+
// pass map into fetchAndDecode so it can add payloads
|
|
10876
|
+
getFetchAndDecodeViaRSC(decode2),
|
|
10877
|
+
ssr,
|
|
10878
|
+
basename
|
|
10879
|
+
);
|
|
10880
|
+
return async (args) => args.unstable_runClientMiddleware(async () => {
|
|
10881
|
+
let context = args.context;
|
|
10882
|
+
context.set(renderedRoutesContext, []);
|
|
10883
|
+
let results = await dataStrategy(args);
|
|
10884
|
+
const renderedRouteById = new Map(
|
|
10885
|
+
context.get(renderedRoutesContext).map((r) => [r.id, r])
|
|
10886
|
+
);
|
|
10887
|
+
for (const match of args.matches) {
|
|
10888
|
+
const rendered = renderedRouteById.get(match.route.id);
|
|
10889
|
+
if (rendered) {
|
|
10890
|
+
window.__router.patchRoutes(
|
|
10891
|
+
rendered.parentId ?? null,
|
|
10892
|
+
[createRouteFromServerManifest(rendered)],
|
|
10893
|
+
true
|
|
10894
|
+
);
|
|
10895
|
+
}
|
|
10896
|
+
}
|
|
10897
|
+
return results;
|
|
10898
|
+
});
|
|
10899
|
+
}
|
|
10900
|
+
function getFetchAndDecodeViaRSC(decode2) {
|
|
10901
|
+
return async (args, basename, targetRoutes) => {
|
|
10902
|
+
let { request, context } = args;
|
|
10903
|
+
let url = singleFetchUrl(request.url, basename, "rsc");
|
|
10904
|
+
if (request.method === "GET") {
|
|
10905
|
+
url = stripIndexParam(url);
|
|
10906
|
+
if (targetRoutes) {
|
|
10907
|
+
url.searchParams.set("_routes", targetRoutes.join(","));
|
|
10908
|
+
}
|
|
10909
|
+
}
|
|
10910
|
+
let res = await fetch(url, await createRequestInit(request));
|
|
10911
|
+
if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
|
|
10912
|
+
throw new ErrorResponseImpl(404, "Not Found", true);
|
|
10913
|
+
}
|
|
10914
|
+
invariant(res.body, "No response body to decode");
|
|
10915
|
+
try {
|
|
10916
|
+
const payload = await decode2(res.body);
|
|
10917
|
+
if (payload.type === "redirect") {
|
|
10918
|
+
return {
|
|
10919
|
+
status: res.status,
|
|
10920
|
+
data: {
|
|
10921
|
+
redirect: {
|
|
10922
|
+
redirect: payload.location,
|
|
10923
|
+
reload: false,
|
|
10924
|
+
replace: payload.replace,
|
|
10925
|
+
revalidate: false,
|
|
10926
|
+
status: payload.status
|
|
10927
|
+
}
|
|
10928
|
+
}
|
|
10929
|
+
};
|
|
10930
|
+
}
|
|
10931
|
+
if (payload.type !== "render") {
|
|
10932
|
+
throw new Error("Unexpected payload type");
|
|
10933
|
+
}
|
|
10934
|
+
context.get(renderedRoutesContext).push(...payload.matches);
|
|
10935
|
+
let results = { routes: {} };
|
|
10936
|
+
const dataKey = isMutationMethod(request.method) ? "actionData" : "loaderData";
|
|
10937
|
+
for (let [routeId, data2] of Object.entries(payload[dataKey] || {})) {
|
|
10938
|
+
results.routes[routeId] = { data: data2 };
|
|
10939
|
+
}
|
|
10940
|
+
if (payload.errors) {
|
|
10941
|
+
for (let [routeId, error] of Object.entries(payload.errors)) {
|
|
10942
|
+
results.routes[routeId] = { error };
|
|
10943
|
+
}
|
|
10944
|
+
}
|
|
10945
|
+
return { status: res.status, data: results };
|
|
10946
|
+
} catch (e) {
|
|
10947
|
+
throw new Error("Unable to decode RSC response");
|
|
10948
|
+
}
|
|
10949
|
+
};
|
|
10950
|
+
}
|
|
10951
|
+
function RSCHydratedRouter({
|
|
10952
|
+
decode: decode2,
|
|
10953
|
+
payload
|
|
10954
|
+
}) {
|
|
10955
|
+
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
10956
|
+
let router = React14.useMemo(
|
|
10957
|
+
() => createRouterFromPayload({ decode: decode2, payload }),
|
|
10958
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10959
|
+
[]
|
|
10960
|
+
);
|
|
10961
|
+
React14.useLayoutEffect(() => {
|
|
10962
|
+
if (!window.__routerInitialized) {
|
|
10963
|
+
window.__routerInitialized = true;
|
|
10964
|
+
window.__router.initialize();
|
|
10965
|
+
}
|
|
10966
|
+
}, []);
|
|
10967
|
+
const frameworkContext = {
|
|
10968
|
+
future: {
|
|
10969
|
+
// These flags have no runtime impact so can always be false. If we add
|
|
10970
|
+
// flags that drive runtime behavior they'll need to be proxied through.
|
|
10971
|
+
unstable_middleware: false,
|
|
10972
|
+
unstable_subResourceIntegrity: false
|
|
10973
|
+
},
|
|
10974
|
+
isSpaMode: true,
|
|
10975
|
+
ssr: true,
|
|
10976
|
+
criticalCss: "",
|
|
10977
|
+
manifest: {
|
|
10978
|
+
routes: {},
|
|
10979
|
+
version: "1",
|
|
10980
|
+
url: "",
|
|
10981
|
+
entry: {
|
|
10982
|
+
module: "",
|
|
10983
|
+
imports: []
|
|
10984
|
+
}
|
|
10985
|
+
},
|
|
10986
|
+
routeModules: {}
|
|
10987
|
+
};
|
|
10988
|
+
return /* @__PURE__ */ React14.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React14.createElement(RouterProvider, { router }));
|
|
10989
|
+
}
|
|
10990
|
+
function createRouteFromServerManifest(match, payload) {
|
|
10991
|
+
let hasInitialData = payload && match.id in payload.loaderData;
|
|
10992
|
+
let initialData = payload?.loaderData[match.id];
|
|
10993
|
+
let hasInitialError = payload?.errors && match.id in payload.errors;
|
|
10994
|
+
let initialError = payload?.errors?.[match.id];
|
|
10995
|
+
let isHydrationRequest = match.clientLoader?.hydrate === true || !match.hasLoader;
|
|
10996
|
+
let dataRoute = {
|
|
10997
|
+
id: match.id,
|
|
10998
|
+
element: match.element,
|
|
10999
|
+
errorElement: match.errorElement,
|
|
11000
|
+
handle: match.handle,
|
|
11001
|
+
hasErrorBoundary: match.hasErrorBoundary,
|
|
11002
|
+
hydrateFallbackElement: match.hydrateFallbackElement,
|
|
11003
|
+
index: match.index,
|
|
11004
|
+
loader: match.clientLoader ? async (args, singleFetch) => {
|
|
11005
|
+
try {
|
|
11006
|
+
let result = await match.clientLoader({
|
|
11007
|
+
...args,
|
|
11008
|
+
serverLoader: () => {
|
|
11009
|
+
preventInvalidServerHandlerCall2(
|
|
11010
|
+
"loader",
|
|
11011
|
+
match.id,
|
|
11012
|
+
match.hasLoader
|
|
11013
|
+
);
|
|
11014
|
+
if (isHydrationRequest) {
|
|
11015
|
+
if (hasInitialData) {
|
|
11016
|
+
return initialData;
|
|
11017
|
+
}
|
|
11018
|
+
if (hasInitialError) {
|
|
11019
|
+
throw initialError;
|
|
11020
|
+
}
|
|
11021
|
+
}
|
|
11022
|
+
return callSingleFetch(singleFetch);
|
|
11023
|
+
}
|
|
11024
|
+
});
|
|
11025
|
+
return result;
|
|
11026
|
+
} finally {
|
|
11027
|
+
isHydrationRequest = false;
|
|
11028
|
+
}
|
|
11029
|
+
} : (
|
|
11030
|
+
// We always make the call in this RSC world since even if we don't
|
|
11031
|
+
// have a `loader` we may need to get the `element` implementation
|
|
11032
|
+
(_, singleFetch) => callSingleFetch(singleFetch)
|
|
11033
|
+
),
|
|
11034
|
+
action: match.clientAction ? (args, singleFetch) => match.clientAction({
|
|
11035
|
+
...args,
|
|
11036
|
+
serverAction: async () => {
|
|
11037
|
+
preventInvalidServerHandlerCall2(
|
|
11038
|
+
"loader",
|
|
11039
|
+
match.id,
|
|
11040
|
+
match.hasLoader
|
|
11041
|
+
);
|
|
11042
|
+
return await callSingleFetch(singleFetch);
|
|
11043
|
+
}
|
|
11044
|
+
}) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : void 0,
|
|
11045
|
+
path: match.path,
|
|
11046
|
+
shouldRevalidate: match.shouldRevalidate,
|
|
11047
|
+
// We always have a "loader" in this RSC world since even if we don't
|
|
11048
|
+
// have a `loader` we may need to get the `element` implementation
|
|
11049
|
+
hasLoader: true,
|
|
11050
|
+
hasClientLoader: match.clientLoader != null,
|
|
11051
|
+
hasAction: match.hasAction,
|
|
11052
|
+
hasClientAction: match.clientAction != null,
|
|
11053
|
+
hasShouldRevalidate: match.shouldRevalidate != null
|
|
11054
|
+
};
|
|
11055
|
+
if (typeof dataRoute.loader === "function") {
|
|
11056
|
+
dataRoute.loader.hydrate = shouldHydrateRouteLoader(
|
|
11057
|
+
match.id,
|
|
11058
|
+
match.clientLoader,
|
|
11059
|
+
match.hasLoader,
|
|
11060
|
+
false
|
|
11061
|
+
);
|
|
11062
|
+
}
|
|
11063
|
+
return dataRoute;
|
|
11064
|
+
}
|
|
11065
|
+
function callSingleFetch(singleFetch) {
|
|
11066
|
+
invariant(typeof singleFetch === "function", "Invalid singleFetch parameter");
|
|
11067
|
+
return singleFetch();
|
|
11068
|
+
}
|
|
11069
|
+
function preventInvalidServerHandlerCall2(type, routeId, hasHandler) {
|
|
11070
|
+
if (!hasHandler) {
|
|
11071
|
+
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
11072
|
+
let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${routeId}")`;
|
|
11073
|
+
console.error(msg);
|
|
11074
|
+
throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
|
|
11075
|
+
}
|
|
11076
|
+
}
|
|
11077
|
+
|
|
11078
|
+
// lib/rsc/server.ssr.tsx
|
|
11079
|
+
import * as React15 from "react";
|
|
11080
|
+
|
|
11081
|
+
// lib/rsc/html-stream/server.ts
|
|
11082
|
+
var encoder2 = new TextEncoder();
|
|
11083
|
+
var trailer = "</body></html>";
|
|
11084
|
+
function injectRSCPayload(rscStream) {
|
|
11085
|
+
let decoder = new TextDecoder();
|
|
11086
|
+
let resolveFlightDataPromise;
|
|
11087
|
+
let flightDataPromise = new Promise(
|
|
11088
|
+
(resolve) => resolveFlightDataPromise = resolve
|
|
11089
|
+
);
|
|
11090
|
+
let startedRSC = false;
|
|
11091
|
+
let buffered = [];
|
|
11092
|
+
let timeout = null;
|
|
11093
|
+
function flushBufferedChunks(controller) {
|
|
11094
|
+
for (let chunk of buffered) {
|
|
11095
|
+
let buf = decoder.decode(chunk, { stream: true });
|
|
11096
|
+
if (buf.endsWith(trailer)) {
|
|
11097
|
+
buf = buf.slice(0, -trailer.length);
|
|
11098
|
+
}
|
|
11099
|
+
controller.enqueue(encoder2.encode(buf));
|
|
11100
|
+
}
|
|
11101
|
+
buffered.length = 0;
|
|
11102
|
+
timeout = null;
|
|
11103
|
+
}
|
|
11104
|
+
return new TransformStream({
|
|
11105
|
+
transform(chunk, controller) {
|
|
11106
|
+
buffered.push(chunk);
|
|
11107
|
+
if (timeout) {
|
|
11108
|
+
return;
|
|
11109
|
+
}
|
|
11110
|
+
timeout = setTimeout(async () => {
|
|
11111
|
+
flushBufferedChunks(controller);
|
|
11112
|
+
if (!startedRSC) {
|
|
11113
|
+
startedRSC = true;
|
|
11114
|
+
writeRSCStream(rscStream, controller).catch((err) => controller.error(err)).then(resolveFlightDataPromise);
|
|
11115
|
+
}
|
|
11116
|
+
}, 0);
|
|
11117
|
+
},
|
|
11118
|
+
async flush(controller) {
|
|
11119
|
+
await flightDataPromise;
|
|
11120
|
+
if (timeout) {
|
|
11121
|
+
clearTimeout(timeout);
|
|
11122
|
+
flushBufferedChunks(controller);
|
|
11123
|
+
}
|
|
11124
|
+
controller.enqueue(encoder2.encode("</body></html>"));
|
|
11125
|
+
}
|
|
11126
|
+
});
|
|
11127
|
+
}
|
|
11128
|
+
async function writeRSCStream(rscStream, controller) {
|
|
11129
|
+
let decoder = new TextDecoder("utf-8", { fatal: true });
|
|
11130
|
+
const reader = rscStream.getReader();
|
|
11131
|
+
try {
|
|
11132
|
+
let read;
|
|
11133
|
+
while ((read = await reader.read()) && !read.done) {
|
|
11134
|
+
const chunk = read.value;
|
|
11135
|
+
try {
|
|
11136
|
+
writeChunk(
|
|
11137
|
+
JSON.stringify(decoder.decode(chunk, { stream: true })),
|
|
11138
|
+
controller
|
|
11139
|
+
);
|
|
11140
|
+
} catch (err) {
|
|
11141
|
+
let base64 = JSON.stringify(btoa(String.fromCodePoint(...chunk)));
|
|
11142
|
+
writeChunk(
|
|
11143
|
+
`Uint8Array.from(atob(${base64}), m => m.codePointAt(0))`,
|
|
11144
|
+
controller
|
|
11145
|
+
);
|
|
11146
|
+
}
|
|
11147
|
+
}
|
|
11148
|
+
} finally {
|
|
11149
|
+
reader.releaseLock();
|
|
11150
|
+
}
|
|
11151
|
+
let remaining = decoder.decode();
|
|
11152
|
+
if (remaining.length) {
|
|
11153
|
+
writeChunk(JSON.stringify(remaining), controller);
|
|
11154
|
+
}
|
|
11155
|
+
}
|
|
11156
|
+
function writeChunk(chunk, controller) {
|
|
11157
|
+
controller.enqueue(
|
|
11158
|
+
encoder2.encode(
|
|
11159
|
+
`<script>${escapeScript(
|
|
11160
|
+
`(self.__FLIGHT_DATA||=[]).push(${chunk})`
|
|
11161
|
+
)}</script>`
|
|
11162
|
+
)
|
|
11163
|
+
);
|
|
11164
|
+
}
|
|
11165
|
+
function escapeScript(script) {
|
|
11166
|
+
return script.replace(/<!--/g, "<\\!--").replace(/<\/(script)/gi, "</\\$1");
|
|
11167
|
+
}
|
|
11168
|
+
|
|
11169
|
+
// lib/rsc/server.ssr.tsx
|
|
11170
|
+
async function routeRSCServerRequest(request, requestServer, decode2, renderHTML) {
|
|
11171
|
+
const url = new URL(request.url);
|
|
11172
|
+
let serverRequest = request;
|
|
11173
|
+
const isDataRequest = isReactServerRequest(url);
|
|
11174
|
+
const respondWithRSCPayload = isDataRequest || isManifestRequest(url) || request.headers.has("rsc-action-id");
|
|
11175
|
+
if (isDataRequest) {
|
|
11176
|
+
const serverURL = new URL(request.url);
|
|
11177
|
+
serverURL.pathname = serverURL.pathname.replace(/(_root)?\.rsc$/, "");
|
|
11178
|
+
let headers = new Headers(request.headers);
|
|
11179
|
+
headers.set("X-React-Router-Data-Request", "true");
|
|
11180
|
+
serverRequest = new Request(serverURL, {
|
|
11181
|
+
body: request.body,
|
|
11182
|
+
duplex: request.body ? "half" : void 0,
|
|
11183
|
+
headers,
|
|
11184
|
+
method: request.method,
|
|
11185
|
+
signal: request.signal
|
|
11186
|
+
});
|
|
11187
|
+
}
|
|
11188
|
+
const serverResponse = await requestServer(serverRequest);
|
|
11189
|
+
if (respondWithRSCPayload) {
|
|
11190
|
+
return serverResponse;
|
|
11191
|
+
}
|
|
11192
|
+
if (!serverResponse.body) {
|
|
11193
|
+
throw new Error("Missing body in server response");
|
|
11194
|
+
}
|
|
11195
|
+
const serverResponseB = serverResponse.clone();
|
|
11196
|
+
if (!serverResponseB.body) {
|
|
11197
|
+
throw new Error("Failed to clone server response");
|
|
11198
|
+
}
|
|
11199
|
+
const payload = await decode2(serverResponse.body);
|
|
11200
|
+
if (payload.type === "redirect") {
|
|
11201
|
+
return new Response(null, {
|
|
11202
|
+
status: payload.status,
|
|
11203
|
+
headers: {
|
|
11204
|
+
Location: payload.location
|
|
11205
|
+
}
|
|
11206
|
+
});
|
|
11207
|
+
}
|
|
11208
|
+
const html = await renderHTML(payload);
|
|
11209
|
+
try {
|
|
11210
|
+
const body = html.pipeThrough(injectRSCPayload(serverResponseB.body));
|
|
11211
|
+
const headers = new Headers(serverResponse.headers);
|
|
11212
|
+
headers.set("Content-Type", "text/html");
|
|
11213
|
+
return new Response(body, {
|
|
11214
|
+
status: serverResponse.status,
|
|
11215
|
+
headers
|
|
11216
|
+
});
|
|
11217
|
+
} catch (reason) {
|
|
11218
|
+
throw reason;
|
|
11219
|
+
}
|
|
11220
|
+
}
|
|
11221
|
+
function RSCStaticRouter({ payload }) {
|
|
11222
|
+
if (payload.type !== "render") return null;
|
|
11223
|
+
const context = {
|
|
11224
|
+
actionData: payload.actionData,
|
|
11225
|
+
actionHeaders: {},
|
|
11226
|
+
basename: payload.basename,
|
|
11227
|
+
errors: payload.errors,
|
|
11228
|
+
loaderData: payload.loaderData,
|
|
11229
|
+
loaderHeaders: {},
|
|
11230
|
+
location: payload.location,
|
|
11231
|
+
statusCode: 200,
|
|
11232
|
+
matches: payload.matches.map((match) => ({
|
|
11233
|
+
params: match.params,
|
|
11234
|
+
pathname: match.pathname,
|
|
11235
|
+
pathnameBase: match.pathnameBase,
|
|
11236
|
+
route: {
|
|
11237
|
+
id: match.id,
|
|
11238
|
+
action: match.hasAction || !!match.clientAction,
|
|
11239
|
+
handle: match.handle,
|
|
11240
|
+
hasErrorBoundary: match.hasErrorBoundary,
|
|
11241
|
+
loader: match.hasLoader || !!match.clientLoader,
|
|
11242
|
+
index: match.index,
|
|
11243
|
+
path: match.path,
|
|
11244
|
+
shouldRevalidate: match.shouldRevalidate
|
|
11245
|
+
}
|
|
11246
|
+
}))
|
|
11247
|
+
};
|
|
11248
|
+
const router = createStaticRouter(
|
|
11249
|
+
payload.matches.reduceRight((previous, match) => {
|
|
11250
|
+
const route = {
|
|
11251
|
+
id: match.id,
|
|
11252
|
+
action: match.hasAction || !!match.clientAction,
|
|
11253
|
+
element: match.element,
|
|
11254
|
+
errorElement: match.errorElement,
|
|
11255
|
+
handle: match.handle,
|
|
11256
|
+
hasErrorBoundary: !!match.errorElement,
|
|
11257
|
+
hydrateFallbackElement: match.hydrateFallbackElement,
|
|
11258
|
+
index: match.index,
|
|
11259
|
+
loader: match.hasLoader || !!match.clientLoader,
|
|
11260
|
+
path: match.path,
|
|
11261
|
+
shouldRevalidate: match.shouldRevalidate
|
|
11262
|
+
};
|
|
11263
|
+
if (previous.length > 0) {
|
|
11264
|
+
route.children = previous;
|
|
11265
|
+
}
|
|
11266
|
+
return [route];
|
|
11267
|
+
}, []),
|
|
11268
|
+
context
|
|
11269
|
+
);
|
|
11270
|
+
const frameworkContext = {
|
|
11271
|
+
future: {
|
|
11272
|
+
// These flags have no runtime impact so can always be false. If we add
|
|
11273
|
+
// flags that drive runtime behavior they'll need to be proxied through.
|
|
11274
|
+
unstable_middleware: false,
|
|
11275
|
+
unstable_subResourceIntegrity: false
|
|
11276
|
+
},
|
|
11277
|
+
isSpaMode: false,
|
|
11278
|
+
ssr: true,
|
|
11279
|
+
criticalCss: "",
|
|
11280
|
+
manifest: {
|
|
11281
|
+
routes: {},
|
|
11282
|
+
version: "1",
|
|
11283
|
+
url: "",
|
|
11284
|
+
entry: {
|
|
11285
|
+
module: "",
|
|
11286
|
+
imports: []
|
|
11287
|
+
}
|
|
11288
|
+
},
|
|
11289
|
+
routeModules: {}
|
|
11290
|
+
};
|
|
11291
|
+
return /* @__PURE__ */ React15.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React15.createElement(
|
|
11292
|
+
StaticRouterProvider,
|
|
11293
|
+
{
|
|
11294
|
+
context,
|
|
11295
|
+
router,
|
|
11296
|
+
hydrate: false,
|
|
11297
|
+
nonce: payload.nonce
|
|
11298
|
+
}
|
|
11299
|
+
));
|
|
11300
|
+
}
|
|
11301
|
+
function isReactServerRequest(url) {
|
|
11302
|
+
return url.pathname.endsWith(".rsc");
|
|
11303
|
+
}
|
|
11304
|
+
function isManifestRequest(url) {
|
|
11305
|
+
return url.pathname.endsWith(".manifest");
|
|
11306
|
+
}
|
|
11307
|
+
|
|
11308
|
+
// lib/rsc/html-stream/browser.ts
|
|
11309
|
+
function getServerStream() {
|
|
11310
|
+
let encoder3 = new TextEncoder();
|
|
11311
|
+
let streamController = null;
|
|
11312
|
+
let rscStream = new ReadableStream({
|
|
11313
|
+
start(controller) {
|
|
11314
|
+
if (typeof window === "undefined") {
|
|
11315
|
+
return;
|
|
11316
|
+
}
|
|
11317
|
+
let handleChunk = (chunk) => {
|
|
11318
|
+
if (typeof chunk === "string") {
|
|
11319
|
+
controller.enqueue(encoder3.encode(chunk));
|
|
11320
|
+
} else {
|
|
11321
|
+
controller.enqueue(chunk);
|
|
11322
|
+
}
|
|
11323
|
+
};
|
|
11324
|
+
window.__FLIGHT_DATA || (window.__FLIGHT_DATA = []);
|
|
11325
|
+
window.__FLIGHT_DATA.forEach(handleChunk);
|
|
11326
|
+
window.__FLIGHT_DATA.push = (chunk) => {
|
|
11327
|
+
handleChunk(chunk);
|
|
11328
|
+
return 0;
|
|
11329
|
+
};
|
|
11330
|
+
streamController = controller;
|
|
11331
|
+
}
|
|
11332
|
+
});
|
|
11333
|
+
if (typeof document !== "undefined" && document.readyState === "loading") {
|
|
11334
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
11335
|
+
streamController?.close();
|
|
11336
|
+
});
|
|
11337
|
+
} else {
|
|
11338
|
+
streamController?.close();
|
|
11339
|
+
}
|
|
11340
|
+
return rscStream;
|
|
11341
|
+
}
|
|
11342
|
+
|
|
10634
11343
|
// lib/dom/ssr/errors.ts
|
|
10635
11344
|
function deserializeErrors2(errors) {
|
|
10636
11345
|
if (!errors) return null;
|
|
@@ -10668,32 +11377,6 @@ function deserializeErrors2(errors) {
|
|
|
10668
11377
|
return serialized;
|
|
10669
11378
|
}
|
|
10670
11379
|
|
|
10671
|
-
// lib/dom/ssr/hydration.tsx
|
|
10672
|
-
function getHydrationData(state, routes, getRouteInfo, location, basename, isSpaMode) {
|
|
10673
|
-
let hydrationData = {
|
|
10674
|
-
...state,
|
|
10675
|
-
loaderData: { ...state.loaderData }
|
|
10676
|
-
};
|
|
10677
|
-
let initialMatches = matchRoutes(routes, location, basename);
|
|
10678
|
-
if (initialMatches) {
|
|
10679
|
-
for (let match of initialMatches) {
|
|
10680
|
-
let routeId = match.route.id;
|
|
10681
|
-
let routeInfo = getRouteInfo(routeId);
|
|
10682
|
-
if (shouldHydrateRouteLoader(
|
|
10683
|
-
routeId,
|
|
10684
|
-
routeInfo.clientLoader,
|
|
10685
|
-
routeInfo.hasLoader,
|
|
10686
|
-
isSpaMode
|
|
10687
|
-
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
|
|
10688
|
-
delete hydrationData.loaderData[routeId];
|
|
10689
|
-
} else if (!routeInfo.hasLoader) {
|
|
10690
|
-
hydrationData.loaderData[routeId] = null;
|
|
10691
|
-
}
|
|
10692
|
-
}
|
|
10693
|
-
}
|
|
10694
|
-
return hydrationData;
|
|
10695
|
-
}
|
|
10696
|
-
|
|
10697
11380
|
export {
|
|
10698
11381
|
Action,
|
|
10699
11382
|
createBrowserHistory,
|
|
@@ -10755,6 +11438,9 @@ export {
|
|
|
10755
11438
|
Router,
|
|
10756
11439
|
Routes,
|
|
10757
11440
|
Await,
|
|
11441
|
+
WithRouteComponentProps,
|
|
11442
|
+
WithHydrateFallbackProps,
|
|
11443
|
+
WithErrorBoundaryProps,
|
|
10758
11444
|
createRoutesFromChildren,
|
|
10759
11445
|
createRoutesFromElements,
|
|
10760
11446
|
renderMatches,
|
|
@@ -10809,6 +11495,11 @@ export {
|
|
|
10809
11495
|
createCookieSessionStorage,
|
|
10810
11496
|
createMemorySessionStorage,
|
|
10811
11497
|
href,
|
|
10812
|
-
|
|
10813
|
-
|
|
11498
|
+
getHydrationData,
|
|
11499
|
+
createCallServer,
|
|
11500
|
+
RSCHydratedRouter,
|
|
11501
|
+
routeRSCServerRequest,
|
|
11502
|
+
RSCStaticRouter,
|
|
11503
|
+
getServerStream,
|
|
11504
|
+
deserializeErrors2 as deserializeErrors
|
|
10814
11505
|
};
|