react-router 0.0.0-experimental-ab0e85b04 → 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-EBUZVJTZ.mjs → chunk-RMWJZNG5.mjs} +1102 -420
- 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 -2
- package/dist/development/dom-export.js +179 -181
- package/dist/development/dom-export.mjs +3 -6
- package/dist/development/{fog-of-war-k8KWkMZc.d.ts → fog-of-war-C5L_Yd5M.d.mts} +170 -138
- 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 +68 -10
- package/dist/development/index.js +1109 -418
- 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/development/{route-data-BvrN3Sw4.d.ts → route-data-BIYebJr3.d.mts} +12 -12
- package/dist/{production/route-data-BvrN3Sw4.d.mts → 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-3F6ADOVA.mjs → chunk-BXBFRMFA.mjs} +1102 -420
- 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 -2
- package/dist/production/dom-export.js +179 -181
- package/dist/production/dom-export.mjs +3 -6
- package/dist/production/{fog-of-war-k8KWkMZc.d.ts → fog-of-war-C5L_Yd5M.d.mts} +170 -138
- 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 +68 -10
- package/dist/production/index.js +1109 -418
- 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/production/{route-data-BvrN3Sw4.d.ts → route-data-BIYebJr3.d.mts} +12 -12
- package/dist/{development/route-data-BvrN3Sw4.d.mts → 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 -5
|
@@ -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,18 +296,25 @@ 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 });
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
function createURL(to) {
|
|
310
|
-
|
|
310
|
+
let base = window2.location.origin !== "null" ? window2.location.origin : window2.location.href;
|
|
311
|
+
let href2 = typeof to === "string" ? to : createPath(to);
|
|
312
|
+
href2 = href2.replace(/ $/, "%20");
|
|
313
|
+
invariant(
|
|
314
|
+
base,
|
|
315
|
+
`No window.location.(origin|href) available to create URL for href: ${href2}`
|
|
316
|
+
);
|
|
317
|
+
return new URL(href2, base);
|
|
311
318
|
}
|
|
312
319
|
let history = {
|
|
313
320
|
get action() {
|
|
@@ -347,19 +354,6 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
347
354
|
};
|
|
348
355
|
return history;
|
|
349
356
|
}
|
|
350
|
-
function createBrowserURLImpl(to, isAbsolute = false) {
|
|
351
|
-
let base = "http://localhost";
|
|
352
|
-
if (typeof window !== "undefined") {
|
|
353
|
-
base = window.location.origin !== "null" ? window.location.origin : window.location.href;
|
|
354
|
-
}
|
|
355
|
-
invariant(base, "No window.location.(origin|href) available to create URL");
|
|
356
|
-
let href2 = typeof to === "string" ? to : createPath(to);
|
|
357
|
-
href2 = href2.replace(/ $/, "%20");
|
|
358
|
-
if (!isAbsolute && href2.startsWith("//")) {
|
|
359
|
-
href2 = base + href2;
|
|
360
|
-
}
|
|
361
|
-
return new URL(href2, base);
|
|
362
|
-
}
|
|
363
357
|
|
|
364
358
|
// lib/router/utils.ts
|
|
365
359
|
function unstable_createContext(defaultValue) {
|
|
@@ -419,7 +413,7 @@ function isUnsupportedLazyRouteFunctionKey(key) {
|
|
|
419
413
|
function isIndexRoute(route) {
|
|
420
414
|
return route.index === true;
|
|
421
415
|
}
|
|
422
|
-
function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}) {
|
|
416
|
+
function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}, allowInPlaceMutations = false) {
|
|
423
417
|
return routes.map((route, index) => {
|
|
424
418
|
let treePath = [...parentPath, String(index)];
|
|
425
419
|
let id = typeof route.id === "string" ? route.id : treePath.join("-");
|
|
@@ -428,7 +422,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
428
422
|
`Cannot specify children on an index route`
|
|
429
423
|
);
|
|
430
424
|
invariant(
|
|
431
|
-
!manifest[id],
|
|
425
|
+
allowInPlaceMutations || !manifest[id],
|
|
432
426
|
`Found a route id collision on id "${id}". Route id's must be globally unique within Data Router usages`
|
|
433
427
|
);
|
|
434
428
|
if (isIndexRoute(route)) {
|
|
@@ -452,7 +446,8 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
452
446
|
route.children,
|
|
453
447
|
mapRouteProperties2,
|
|
454
448
|
treePath,
|
|
455
|
-
manifest
|
|
449
|
+
manifest,
|
|
450
|
+
allowInPlaceMutations
|
|
456
451
|
);
|
|
457
452
|
}
|
|
458
453
|
return pathOrLayoutRoute;
|
|
@@ -463,8 +458,8 @@ function matchRoutes(routes, locationArg, basename = "/") {
|
|
|
463
458
|
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
464
459
|
}
|
|
465
460
|
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
466
|
-
let
|
|
467
|
-
let pathname = stripBasename(
|
|
461
|
+
let location2 = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
462
|
+
let pathname = stripBasename(location2.pathname || "/", basename);
|
|
468
463
|
if (pathname == null) {
|
|
469
464
|
return null;
|
|
470
465
|
}
|
|
@@ -980,57 +975,53 @@ function createRouter(init) {
|
|
|
980
975
|
let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
|
|
981
976
|
let initialMatchesIsFOW = false;
|
|
982
977
|
let initialErrors = null;
|
|
983
|
-
let initialized;
|
|
984
978
|
if (initialMatches == null && !init.patchRoutesOnNavigation) {
|
|
985
979
|
let error = getInternalRouterError(404, {
|
|
986
980
|
pathname: init.history.location.pathname
|
|
987
981
|
});
|
|
988
982
|
let { matches, route } = getShortCircuitMatches(dataRoutes);
|
|
989
|
-
initialized = true;
|
|
990
983
|
initialMatches = matches;
|
|
991
984
|
initialErrors = { [route.id]: error };
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}
|
|
985
|
+
}
|
|
986
|
+
if (initialMatches && !init.hydrationData) {
|
|
987
|
+
let fogOfWar = checkFogOfWar(
|
|
988
|
+
initialMatches,
|
|
989
|
+
dataRoutes,
|
|
990
|
+
init.history.location.pathname
|
|
991
|
+
);
|
|
992
|
+
if (fogOfWar.active) {
|
|
993
|
+
initialMatches = null;
|
|
1002
994
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
995
|
+
}
|
|
996
|
+
let initialized;
|
|
997
|
+
if (!initialMatches) {
|
|
998
|
+
initialized = false;
|
|
999
|
+
initialMatches = [];
|
|
1000
|
+
let fogOfWar = checkFogOfWar(
|
|
1001
|
+
null,
|
|
1002
|
+
dataRoutes,
|
|
1003
|
+
init.history.location.pathname
|
|
1004
|
+
);
|
|
1005
|
+
if (fogOfWar.active && fogOfWar.matches) {
|
|
1006
|
+
initialMatchesIsFOW = true;
|
|
1007
|
+
initialMatches = fogOfWar.matches;
|
|
1008
|
+
}
|
|
1009
|
+
} else if (initialMatches.some((m) => m.route.lazy)) {
|
|
1010
|
+
initialized = false;
|
|
1011
|
+
} else if (!initialMatches.some((m) => m.route.loader)) {
|
|
1012
|
+
initialized = true;
|
|
1013
|
+
} else {
|
|
1014
|
+
let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
|
|
1015
|
+
let errors = init.hydrationData ? init.hydrationData.errors : null;
|
|
1016
|
+
if (errors) {
|
|
1017
|
+
let idx = initialMatches.findIndex(
|
|
1018
|
+
(m) => errors[m.route.id] !== void 0
|
|
1010
1019
|
);
|
|
1011
|
-
|
|
1012
|
-
initialMatchesIsFOW = true;
|
|
1013
|
-
initialMatches = fogOfWar.matches;
|
|
1014
|
-
}
|
|
1015
|
-
} else if (initialMatches.some((m) => m.route.lazy)) {
|
|
1016
|
-
initialized = false;
|
|
1017
|
-
} else if (!initialMatches.some((m) => m.route.loader)) {
|
|
1018
|
-
initialized = true;
|
|
1020
|
+
initialized = initialMatches.slice(0, idx + 1).every((m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors));
|
|
1019
1021
|
} else {
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
let idx = initialMatches.findIndex(
|
|
1024
|
-
(m) => errors[m.route.id] !== void 0
|
|
1025
|
-
);
|
|
1026
|
-
initialized = initialMatches.slice(0, idx + 1).every(
|
|
1027
|
-
(m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)
|
|
1028
|
-
);
|
|
1029
|
-
} else {
|
|
1030
|
-
initialized = initialMatches.every(
|
|
1031
|
-
(m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)
|
|
1032
|
-
);
|
|
1033
|
-
}
|
|
1022
|
+
initialized = initialMatches.every(
|
|
1023
|
+
(m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)
|
|
1024
|
+
);
|
|
1034
1025
|
}
|
|
1035
1026
|
}
|
|
1036
1027
|
let router;
|
|
@@ -1072,7 +1063,7 @@ function createRouter(init) {
|
|
|
1072
1063
|
let pendingRevalidationDfd = null;
|
|
1073
1064
|
function initialize() {
|
|
1074
1065
|
unlistenHistory = init.history.listen(
|
|
1075
|
-
({ action: historyAction, location, delta }) => {
|
|
1066
|
+
({ action: historyAction, location: location2, delta }) => {
|
|
1076
1067
|
if (unblockBlockerHistoryUpdate) {
|
|
1077
1068
|
unblockBlockerHistoryUpdate();
|
|
1078
1069
|
unblockBlockerHistoryUpdate = void 0;
|
|
@@ -1084,7 +1075,7 @@ function createRouter(init) {
|
|
|
1084
1075
|
);
|
|
1085
1076
|
let blockerKey = shouldBlockNavigation({
|
|
1086
1077
|
currentLocation: state.location,
|
|
1087
|
-
nextLocation:
|
|
1078
|
+
nextLocation: location2,
|
|
1088
1079
|
historyAction
|
|
1089
1080
|
});
|
|
1090
1081
|
if (blockerKey && delta != null) {
|
|
@@ -1094,13 +1085,13 @@ function createRouter(init) {
|
|
|
1094
1085
|
init.history.go(delta * -1);
|
|
1095
1086
|
updateBlocker(blockerKey, {
|
|
1096
1087
|
state: "blocked",
|
|
1097
|
-
location,
|
|
1088
|
+
location: location2,
|
|
1098
1089
|
proceed() {
|
|
1099
1090
|
updateBlocker(blockerKey, {
|
|
1100
1091
|
state: "proceeding",
|
|
1101
1092
|
proceed: void 0,
|
|
1102
1093
|
reset: void 0,
|
|
1103
|
-
location
|
|
1094
|
+
location: location2
|
|
1104
1095
|
});
|
|
1105
1096
|
nextHistoryUpdatePromise.then(() => init.history.go(delta));
|
|
1106
1097
|
},
|
|
@@ -1112,7 +1103,7 @@ function createRouter(init) {
|
|
|
1112
1103
|
});
|
|
1113
1104
|
return;
|
|
1114
1105
|
}
|
|
1115
|
-
return startNavigation(historyAction,
|
|
1106
|
+
return startNavigation(historyAction, location2);
|
|
1116
1107
|
}
|
|
1117
1108
|
);
|
|
1118
1109
|
if (isBrowser2) {
|
|
@@ -1145,6 +1136,19 @@ function createRouter(init) {
|
|
|
1145
1136
|
return () => subscribers.delete(fn);
|
|
1146
1137
|
}
|
|
1147
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
|
+
}
|
|
1148
1152
|
state = {
|
|
1149
1153
|
...state,
|
|
1150
1154
|
...newState
|
|
@@ -1175,8 +1179,8 @@ function createRouter(init) {
|
|
|
1175
1179
|
unmountedFetchers.forEach((key) => deleteFetcher(key));
|
|
1176
1180
|
mountedFetchers.forEach((key) => state.fetchers.delete(key));
|
|
1177
1181
|
}
|
|
1178
|
-
function completeNavigation(
|
|
1179
|
-
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;
|
|
1180
1184
|
let actionData;
|
|
1181
1185
|
if (newState.actionData) {
|
|
1182
1186
|
if (Object.keys(newState.actionData).length > 0) {
|
|
@@ -1200,7 +1204,7 @@ function createRouter(init) {
|
|
|
1200
1204
|
blockers = new Map(blockers);
|
|
1201
1205
|
blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));
|
|
1202
1206
|
}
|
|
1203
|
-
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;
|
|
1204
1208
|
if (inFlightDataRoutes) {
|
|
1205
1209
|
dataRoutes = inFlightDataRoutes;
|
|
1206
1210
|
inFlightDataRoutes = void 0;
|
|
@@ -1208,35 +1212,35 @@ function createRouter(init) {
|
|
|
1208
1212
|
if (isUninterruptedRevalidation) {
|
|
1209
1213
|
} else if (pendingAction === "POP" /* Pop */) {
|
|
1210
1214
|
} else if (pendingAction === "PUSH" /* Push */) {
|
|
1211
|
-
init.history.push(
|
|
1215
|
+
init.history.push(location2, location2.state);
|
|
1212
1216
|
} else if (pendingAction === "REPLACE" /* Replace */) {
|
|
1213
|
-
init.history.replace(
|
|
1217
|
+
init.history.replace(location2, location2.state);
|
|
1214
1218
|
}
|
|
1215
1219
|
let viewTransitionOpts;
|
|
1216
1220
|
if (pendingAction === "POP" /* Pop */) {
|
|
1217
1221
|
let priorPaths = appliedViewTransitions.get(state.location.pathname);
|
|
1218
|
-
if (priorPaths && priorPaths.has(
|
|
1222
|
+
if (priorPaths && priorPaths.has(location2.pathname)) {
|
|
1219
1223
|
viewTransitionOpts = {
|
|
1220
1224
|
currentLocation: state.location,
|
|
1221
|
-
nextLocation:
|
|
1225
|
+
nextLocation: location2
|
|
1222
1226
|
};
|
|
1223
|
-
} else if (appliedViewTransitions.has(
|
|
1227
|
+
} else if (appliedViewTransitions.has(location2.pathname)) {
|
|
1224
1228
|
viewTransitionOpts = {
|
|
1225
|
-
currentLocation:
|
|
1229
|
+
currentLocation: location2,
|
|
1226
1230
|
nextLocation: state.location
|
|
1227
1231
|
};
|
|
1228
1232
|
}
|
|
1229
1233
|
} else if (pendingViewTransitionEnabled) {
|
|
1230
1234
|
let toPaths = appliedViewTransitions.get(state.location.pathname);
|
|
1231
1235
|
if (toPaths) {
|
|
1232
|
-
toPaths.add(
|
|
1236
|
+
toPaths.add(location2.pathname);
|
|
1233
1237
|
} else {
|
|
1234
|
-
toPaths = /* @__PURE__ */ new Set([
|
|
1238
|
+
toPaths = /* @__PURE__ */ new Set([location2.pathname]);
|
|
1235
1239
|
appliedViewTransitions.set(state.location.pathname, toPaths);
|
|
1236
1240
|
}
|
|
1237
1241
|
viewTransitionOpts = {
|
|
1238
1242
|
currentLocation: state.location,
|
|
1239
|
-
nextLocation:
|
|
1243
|
+
nextLocation: location2
|
|
1240
1244
|
};
|
|
1241
1245
|
}
|
|
1242
1246
|
updateState(
|
|
@@ -1246,12 +1250,12 @@ function createRouter(init) {
|
|
|
1246
1250
|
actionData,
|
|
1247
1251
|
loaderData,
|
|
1248
1252
|
historyAction: pendingAction,
|
|
1249
|
-
location,
|
|
1253
|
+
location: location2,
|
|
1250
1254
|
initialized: true,
|
|
1251
1255
|
navigation: IDLE_NAVIGATION,
|
|
1252
1256
|
revalidation: "idle",
|
|
1253
1257
|
restoreScrollPosition: getSavedScrollPosition(
|
|
1254
|
-
|
|
1258
|
+
location2,
|
|
1255
1259
|
newState.matches || state.matches
|
|
1256
1260
|
),
|
|
1257
1261
|
preventScrollReset,
|
|
@@ -1368,7 +1372,7 @@ function createRouter(init) {
|
|
|
1368
1372
|
);
|
|
1369
1373
|
return promise;
|
|
1370
1374
|
}
|
|
1371
|
-
async function startNavigation(historyAction,
|
|
1375
|
+
async function startNavigation(historyAction, location2, opts) {
|
|
1372
1376
|
pendingNavigationController && pendingNavigationController.abort();
|
|
1373
1377
|
pendingNavigationController = null;
|
|
1374
1378
|
pendingAction = historyAction;
|
|
@@ -1381,22 +1385,22 @@ function createRouter(init) {
|
|
|
1381
1385
|
let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
|
|
1382
1386
|
// `matchRoutes()` has already been called if we're in here via `router.initialize()`
|
|
1383
1387
|
state.matches
|
|
1384
|
-
) : matchRoutes(routesToUse,
|
|
1388
|
+
) : matchRoutes(routesToUse, location2, basename);
|
|
1385
1389
|
let flushSync = (opts && opts.flushSync) === true;
|
|
1386
|
-
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location,
|
|
1387
|
-
completeNavigation(
|
|
1390
|
+
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location2) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
|
|
1391
|
+
completeNavigation(location2, { matches }, { flushSync });
|
|
1388
1392
|
return;
|
|
1389
1393
|
}
|
|
1390
|
-
let fogOfWar = checkFogOfWar(matches, routesToUse,
|
|
1394
|
+
let fogOfWar = checkFogOfWar(matches, routesToUse, location2.pathname);
|
|
1391
1395
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
1392
1396
|
matches = fogOfWar.matches;
|
|
1393
1397
|
}
|
|
1394
1398
|
if (!matches) {
|
|
1395
1399
|
let { error, notFoundMatches, route } = handleNavigational404(
|
|
1396
|
-
|
|
1400
|
+
location2.pathname
|
|
1397
1401
|
);
|
|
1398
1402
|
completeNavigation(
|
|
1399
|
-
|
|
1403
|
+
location2,
|
|
1400
1404
|
{
|
|
1401
1405
|
matches: notFoundMatches,
|
|
1402
1406
|
loaderData: {},
|
|
@@ -1411,7 +1415,7 @@ function createRouter(init) {
|
|
|
1411
1415
|
pendingNavigationController = new AbortController();
|
|
1412
1416
|
let request = createClientSideRequest(
|
|
1413
1417
|
init.history,
|
|
1414
|
-
|
|
1418
|
+
location2,
|
|
1415
1419
|
pendingNavigationController.signal,
|
|
1416
1420
|
opts && opts.submission
|
|
1417
1421
|
);
|
|
@@ -1427,7 +1431,7 @@ function createRouter(init) {
|
|
|
1427
1431
|
} else if (opts && opts.submission && isMutationMethod(opts.submission.formMethod)) {
|
|
1428
1432
|
let actionResult = await handleAction(
|
|
1429
1433
|
request,
|
|
1430
|
-
|
|
1434
|
+
location2,
|
|
1431
1435
|
opts.submission,
|
|
1432
1436
|
matches,
|
|
1433
1437
|
scopedContext,
|
|
@@ -1442,7 +1446,7 @@ function createRouter(init) {
|
|
|
1442
1446
|
let [routeId, result] = actionResult.pendingActionResult;
|
|
1443
1447
|
if (isErrorResult(result) && isRouteErrorResponse(result.error) && result.error.status === 404) {
|
|
1444
1448
|
pendingNavigationController = null;
|
|
1445
|
-
completeNavigation(
|
|
1449
|
+
completeNavigation(location2, {
|
|
1446
1450
|
matches: actionResult.matches,
|
|
1447
1451
|
loaderData: {},
|
|
1448
1452
|
errors: {
|
|
@@ -1454,7 +1458,7 @@ function createRouter(init) {
|
|
|
1454
1458
|
}
|
|
1455
1459
|
matches = actionResult.matches || matches;
|
|
1456
1460
|
pendingActionResult = actionResult.pendingActionResult;
|
|
1457
|
-
loadingNavigation = getLoadingNavigation(
|
|
1461
|
+
loadingNavigation = getLoadingNavigation(location2, opts.submission);
|
|
1458
1462
|
flushSync = false;
|
|
1459
1463
|
fogOfWar.active = false;
|
|
1460
1464
|
request = createClientSideRequest(
|
|
@@ -1470,7 +1474,7 @@ function createRouter(init) {
|
|
|
1470
1474
|
errors
|
|
1471
1475
|
} = await handleLoaders(
|
|
1472
1476
|
request,
|
|
1473
|
-
|
|
1477
|
+
location2,
|
|
1474
1478
|
matches,
|
|
1475
1479
|
scopedContext,
|
|
1476
1480
|
fogOfWar.active,
|
|
@@ -1486,21 +1490,21 @@ function createRouter(init) {
|
|
|
1486
1490
|
return;
|
|
1487
1491
|
}
|
|
1488
1492
|
pendingNavigationController = null;
|
|
1489
|
-
completeNavigation(
|
|
1493
|
+
completeNavigation(location2, {
|
|
1490
1494
|
matches: updatedMatches || matches,
|
|
1491
1495
|
...getActionDataForCommit(pendingActionResult),
|
|
1492
1496
|
loaderData,
|
|
1493
1497
|
errors
|
|
1494
1498
|
});
|
|
1495
1499
|
}
|
|
1496
|
-
async function handleAction(request,
|
|
1500
|
+
async function handleAction(request, location2, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
|
|
1497
1501
|
interruptActiveLoads();
|
|
1498
|
-
let navigation = getSubmittingNavigation(
|
|
1502
|
+
let navigation = getSubmittingNavigation(location2, submission);
|
|
1499
1503
|
updateState({ navigation }, { flushSync: opts.flushSync === true });
|
|
1500
1504
|
if (isFogOfWar) {
|
|
1501
1505
|
let discoverResult = await discoverRoutes(
|
|
1502
1506
|
matches,
|
|
1503
|
-
|
|
1507
|
+
location2.pathname,
|
|
1504
1508
|
request.signal
|
|
1505
1509
|
);
|
|
1506
1510
|
if (discoverResult.type === "aborted") {
|
|
@@ -1519,7 +1523,7 @@ function createRouter(init) {
|
|
|
1519
1523
|
};
|
|
1520
1524
|
} else if (!discoverResult.matches) {
|
|
1521
1525
|
let { notFoundMatches, error, route } = handleNavigational404(
|
|
1522
|
-
|
|
1526
|
+
location2.pathname
|
|
1523
1527
|
);
|
|
1524
1528
|
return {
|
|
1525
1529
|
matches: notFoundMatches,
|
|
@@ -1536,13 +1540,13 @@ function createRouter(init) {
|
|
|
1536
1540
|
}
|
|
1537
1541
|
}
|
|
1538
1542
|
let result;
|
|
1539
|
-
let actionMatch = getTargetMatch(matches,
|
|
1543
|
+
let actionMatch = getTargetMatch(matches, location2);
|
|
1540
1544
|
if (!actionMatch.route.action && !actionMatch.route.lazy) {
|
|
1541
1545
|
result = {
|
|
1542
1546
|
type: "error" /* error */,
|
|
1543
1547
|
error: getInternalRouterError(405, {
|
|
1544
1548
|
method: request.method,
|
|
1545
|
-
pathname:
|
|
1549
|
+
pathname: location2.pathname,
|
|
1546
1550
|
routeId: actionMatch.route.id
|
|
1547
1551
|
})
|
|
1548
1552
|
};
|
|
@@ -1580,12 +1584,12 @@ function createRouter(init) {
|
|
|
1580
1584
|
if (opts && opts.replace != null) {
|
|
1581
1585
|
replace2 = opts.replace;
|
|
1582
1586
|
} else {
|
|
1583
|
-
let
|
|
1587
|
+
let location3 = normalizeRedirectLocation(
|
|
1584
1588
|
result.response.headers.get("Location"),
|
|
1585
1589
|
new URL(request.url),
|
|
1586
1590
|
basename
|
|
1587
1591
|
);
|
|
1588
|
-
replace2 =
|
|
1592
|
+
replace2 = location3 === state.location.pathname + state.location.search;
|
|
1589
1593
|
}
|
|
1590
1594
|
await startRedirectNavigation(request, result, true, {
|
|
1591
1595
|
submission,
|
|
@@ -1600,11 +1604,7 @@ function createRouter(init) {
|
|
|
1600
1604
|
}
|
|
1601
1605
|
return {
|
|
1602
1606
|
matches,
|
|
1603
|
-
pendingActionResult: [
|
|
1604
|
-
boundaryMatch.route.id,
|
|
1605
|
-
result,
|
|
1606
|
-
actionMatch.route.id
|
|
1607
|
-
]
|
|
1607
|
+
pendingActionResult: [boundaryMatch.route.id, result]
|
|
1608
1608
|
};
|
|
1609
1609
|
}
|
|
1610
1610
|
return {
|
|
@@ -1612,8 +1612,8 @@ function createRouter(init) {
|
|
|
1612
1612
|
pendingActionResult: [actionMatch.route.id, result]
|
|
1613
1613
|
};
|
|
1614
1614
|
}
|
|
1615
|
-
async function handleLoaders(request,
|
|
1616
|
-
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);
|
|
1617
1617
|
let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
|
|
1618
1618
|
let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
|
|
1619
1619
|
if (isFogOfWar) {
|
|
@@ -1631,7 +1631,7 @@ function createRouter(init) {
|
|
|
1631
1631
|
}
|
|
1632
1632
|
let discoverResult = await discoverRoutes(
|
|
1633
1633
|
matches,
|
|
1634
|
-
|
|
1634
|
+
location2.pathname,
|
|
1635
1635
|
request.signal
|
|
1636
1636
|
);
|
|
1637
1637
|
if (discoverResult.type === "aborted") {
|
|
@@ -1647,7 +1647,7 @@ function createRouter(init) {
|
|
|
1647
1647
|
};
|
|
1648
1648
|
} else if (!discoverResult.matches) {
|
|
1649
1649
|
let { error, notFoundMatches, route } = handleNavigational404(
|
|
1650
|
-
|
|
1650
|
+
location2.pathname
|
|
1651
1651
|
);
|
|
1652
1652
|
return {
|
|
1653
1653
|
matches: notFoundMatches,
|
|
@@ -1670,7 +1670,7 @@ function createRouter(init) {
|
|
|
1670
1670
|
state,
|
|
1671
1671
|
matches,
|
|
1672
1672
|
activeSubmission,
|
|
1673
|
-
|
|
1673
|
+
location2,
|
|
1674
1674
|
initialHydration ? [] : hydrationRouteProperties2,
|
|
1675
1675
|
initialHydration === true,
|
|
1676
1676
|
isRevalidationRequired,
|
|
@@ -1686,7 +1686,7 @@ function createRouter(init) {
|
|
|
1686
1686
|
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && revalidatingFetchers.length === 0) {
|
|
1687
1687
|
let updatedFetchers2 = markFetchRedirectsDone();
|
|
1688
1688
|
completeNavigation(
|
|
1689
|
-
|
|
1689
|
+
location2,
|
|
1690
1690
|
{
|
|
1691
1691
|
matches,
|
|
1692
1692
|
loaderData: {},
|
|
@@ -2197,31 +2197,31 @@ function createRouter(init) {
|
|
|
2197
2197
|
if (redirect2.response.headers.has("X-Remix-Revalidate")) {
|
|
2198
2198
|
isRevalidationRequired = true;
|
|
2199
2199
|
}
|
|
2200
|
-
let
|
|
2201
|
-
invariant(
|
|
2202
|
-
|
|
2203
|
-
|
|
2200
|
+
let location2 = redirect2.response.headers.get("Location");
|
|
2201
|
+
invariant(location2, "Expected a Location header on the redirect Response");
|
|
2202
|
+
location2 = normalizeRedirectLocation(
|
|
2203
|
+
location2,
|
|
2204
2204
|
new URL(request.url),
|
|
2205
2205
|
basename
|
|
2206
2206
|
);
|
|
2207
|
-
let redirectLocation = createLocation(state.location,
|
|
2207
|
+
let redirectLocation = createLocation(state.location, location2, {
|
|
2208
2208
|
_isRedirect: true
|
|
2209
2209
|
});
|
|
2210
2210
|
if (isBrowser2) {
|
|
2211
2211
|
let isDocumentReload = false;
|
|
2212
2212
|
if (redirect2.response.headers.has("X-Remix-Reload-Document")) {
|
|
2213
2213
|
isDocumentReload = true;
|
|
2214
|
-
} else if (ABSOLUTE_URL_REGEX.test(
|
|
2215
|
-
const url =
|
|
2214
|
+
} else if (ABSOLUTE_URL_REGEX.test(location2)) {
|
|
2215
|
+
const url = init.history.createURL(location2);
|
|
2216
2216
|
isDocumentReload = // Hard reload if it's an absolute URL to a new origin
|
|
2217
2217
|
url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename
|
|
2218
2218
|
stripBasename(url.pathname, basename) == null;
|
|
2219
2219
|
}
|
|
2220
2220
|
if (isDocumentReload) {
|
|
2221
2221
|
if (replace2) {
|
|
2222
|
-
routerWindow.location.replace(
|
|
2222
|
+
routerWindow.location.replace(location2);
|
|
2223
2223
|
} else {
|
|
2224
|
-
routerWindow.location.assign(
|
|
2224
|
+
routerWindow.location.assign(location2);
|
|
2225
2225
|
}
|
|
2226
2226
|
return;
|
|
2227
2227
|
}
|
|
@@ -2237,7 +2237,7 @@ function createRouter(init) {
|
|
|
2237
2237
|
await startNavigation(redirectNavigationType, redirectLocation, {
|
|
2238
2238
|
submission: {
|
|
2239
2239
|
...activeSubmission,
|
|
2240
|
-
formAction:
|
|
2240
|
+
formAction: location2
|
|
2241
2241
|
},
|
|
2242
2242
|
// Preserve these flags across redirects
|
|
2243
2243
|
preventScrollReset: preventScrollReset || pendingPreventScrollReset,
|
|
@@ -2508,25 +2508,25 @@ function createRouter(init) {
|
|
|
2508
2508
|
getScrollRestorationKey2 = null;
|
|
2509
2509
|
};
|
|
2510
2510
|
}
|
|
2511
|
-
function getScrollKey(
|
|
2511
|
+
function getScrollKey(location2, matches) {
|
|
2512
2512
|
if (getScrollRestorationKey2) {
|
|
2513
2513
|
let key = getScrollRestorationKey2(
|
|
2514
|
-
|
|
2514
|
+
location2,
|
|
2515
2515
|
matches.map((m) => convertRouteMatchToUiMatch(m, state.loaderData))
|
|
2516
2516
|
);
|
|
2517
|
-
return key ||
|
|
2517
|
+
return key || location2.key;
|
|
2518
2518
|
}
|
|
2519
|
-
return
|
|
2519
|
+
return location2.key;
|
|
2520
2520
|
}
|
|
2521
|
-
function saveScrollPosition(
|
|
2521
|
+
function saveScrollPosition(location2, matches) {
|
|
2522
2522
|
if (savedScrollPositions2 && getScrollPosition) {
|
|
2523
|
-
let key = getScrollKey(
|
|
2523
|
+
let key = getScrollKey(location2, matches);
|
|
2524
2524
|
savedScrollPositions2[key] = getScrollPosition();
|
|
2525
2525
|
}
|
|
2526
2526
|
}
|
|
2527
|
-
function getSavedScrollPosition(
|
|
2527
|
+
function getSavedScrollPosition(location2, matches) {
|
|
2528
2528
|
if (savedScrollPositions2) {
|
|
2529
|
-
let key = getScrollKey(
|
|
2529
|
+
let key = getScrollKey(location2, matches);
|
|
2530
2530
|
let y = savedScrollPositions2[key];
|
|
2531
2531
|
if (typeof y === "number") {
|
|
2532
2532
|
return y;
|
|
@@ -2580,7 +2580,8 @@ function createRouter(init) {
|
|
|
2580
2580
|
children,
|
|
2581
2581
|
routesToUse,
|
|
2582
2582
|
localManifest,
|
|
2583
|
-
mapRouteProperties2
|
|
2583
|
+
mapRouteProperties2,
|
|
2584
|
+
false
|
|
2584
2585
|
);
|
|
2585
2586
|
}
|
|
2586
2587
|
});
|
|
@@ -2621,7 +2622,7 @@ function createRouter(init) {
|
|
|
2621
2622
|
manifest
|
|
2622
2623
|
);
|
|
2623
2624
|
}
|
|
2624
|
-
function patchRoutes(routeId, children) {
|
|
2625
|
+
function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
|
|
2625
2626
|
let isNonHMR = inFlightDataRoutes == null;
|
|
2626
2627
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
2627
2628
|
patchRoutesImpl(
|
|
@@ -2629,7 +2630,8 @@ function createRouter(init) {
|
|
|
2629
2630
|
children,
|
|
2630
2631
|
routesToUse,
|
|
2631
2632
|
manifest,
|
|
2632
|
-
mapRouteProperties2
|
|
2633
|
+
mapRouteProperties2,
|
|
2634
|
+
unstable_allowElementMutations
|
|
2633
2635
|
);
|
|
2634
2636
|
if (isNonHMR) {
|
|
2635
2637
|
dataRoutes = [...dataRoutes];
|
|
@@ -2671,7 +2673,10 @@ function createRouter(init) {
|
|
|
2671
2673
|
_internalFetchControllers: fetchControllers,
|
|
2672
2674
|
// TODO: Remove setRoutes, it's temporary to avoid dealing with
|
|
2673
2675
|
// updating the tree while validating the update algorithm.
|
|
2674
|
-
_internalSetRoutes
|
|
2676
|
+
_internalSetRoutes,
|
|
2677
|
+
_internalSetStateDoNotUseOrYouWillBreakYourApp(newState) {
|
|
2678
|
+
updateState(newState);
|
|
2679
|
+
}
|
|
2675
2680
|
};
|
|
2676
2681
|
return router;
|
|
2677
2682
|
}
|
|
@@ -2699,15 +2704,15 @@ function createStaticHandler(routes, opts) {
|
|
|
2699
2704
|
} = {}) {
|
|
2700
2705
|
let url = new URL(request.url);
|
|
2701
2706
|
let method = request.method;
|
|
2702
|
-
let
|
|
2703
|
-
let matches = matchRoutes(dataRoutes,
|
|
2707
|
+
let location2 = createLocation("", createPath(url), null, "default");
|
|
2708
|
+
let matches = matchRoutes(dataRoutes, location2, basename);
|
|
2704
2709
|
requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
|
|
2705
2710
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
2706
2711
|
let error = getInternalRouterError(405, { method });
|
|
2707
2712
|
let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
2708
2713
|
let staticContext = {
|
|
2709
2714
|
basename,
|
|
2710
|
-
location,
|
|
2715
|
+
location: location2,
|
|
2711
2716
|
matches: methodNotAllowedMatches,
|
|
2712
2717
|
loaderData: {},
|
|
2713
2718
|
actionData: null,
|
|
@@ -2720,11 +2725,11 @@ function createStaticHandler(routes, opts) {
|
|
|
2720
2725
|
};
|
|
2721
2726
|
return respond ? respond(staticContext) : staticContext;
|
|
2722
2727
|
} else if (!matches) {
|
|
2723
|
-
let error = getInternalRouterError(404, { pathname:
|
|
2728
|
+
let error = getInternalRouterError(404, { pathname: location2.pathname });
|
|
2724
2729
|
let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
2725
2730
|
let staticContext = {
|
|
2726
2731
|
basename,
|
|
2727
|
-
location,
|
|
2732
|
+
location: location2,
|
|
2728
2733
|
matches: notFoundMatches,
|
|
2729
2734
|
loaderData: {},
|
|
2730
2735
|
actionData: null,
|
|
@@ -2764,7 +2769,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2764
2769
|
async () => {
|
|
2765
2770
|
let result2 = await queryImpl(
|
|
2766
2771
|
request,
|
|
2767
|
-
|
|
2772
|
+
location2,
|
|
2768
2773
|
matches,
|
|
2769
2774
|
requestContext,
|
|
2770
2775
|
dataStrategy || null,
|
|
@@ -2776,7 +2781,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2776
2781
|
if (isResponse(result2)) {
|
|
2777
2782
|
return result2;
|
|
2778
2783
|
}
|
|
2779
|
-
renderedStaticContext = { location, basename, ...result2 };
|
|
2784
|
+
renderedStaticContext = { location: location2, basename, ...result2 };
|
|
2780
2785
|
let res = await respond(renderedStaticContext);
|
|
2781
2786
|
return res;
|
|
2782
2787
|
},
|
|
@@ -2801,7 +2806,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2801
2806
|
let boundary = loaderIdx >= 0 ? findNearestBoundary(matches, matches[loaderIdx].route.id) : findNearestBoundary(matches);
|
|
2802
2807
|
return respond({
|
|
2803
2808
|
matches,
|
|
2804
|
-
location,
|
|
2809
|
+
location: location2,
|
|
2805
2810
|
basename,
|
|
2806
2811
|
loaderData: {},
|
|
2807
2812
|
actionData: null,
|
|
@@ -2826,7 +2831,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2826
2831
|
}
|
|
2827
2832
|
let result = await queryImpl(
|
|
2828
2833
|
request,
|
|
2829
|
-
|
|
2834
|
+
location2,
|
|
2830
2835
|
matches,
|
|
2831
2836
|
requestContext,
|
|
2832
2837
|
dataStrategy || null,
|
|
@@ -2838,7 +2843,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2838
2843
|
if (isResponse(result)) {
|
|
2839
2844
|
return result;
|
|
2840
2845
|
}
|
|
2841
|
-
return { location, basename, ...result };
|
|
2846
|
+
return { location: location2, basename, ...result };
|
|
2842
2847
|
}
|
|
2843
2848
|
async function queryRoute(request, {
|
|
2844
2849
|
routeId,
|
|
@@ -2848,22 +2853,22 @@ function createStaticHandler(routes, opts) {
|
|
|
2848
2853
|
} = {}) {
|
|
2849
2854
|
let url = new URL(request.url);
|
|
2850
2855
|
let method = request.method;
|
|
2851
|
-
let
|
|
2852
|
-
let matches = matchRoutes(dataRoutes,
|
|
2856
|
+
let location2 = createLocation("", createPath(url), null, "default");
|
|
2857
|
+
let matches = matchRoutes(dataRoutes, location2, basename);
|
|
2853
2858
|
requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
|
|
2854
2859
|
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
|
|
2855
2860
|
throw getInternalRouterError(405, { method });
|
|
2856
2861
|
} else if (!matches) {
|
|
2857
|
-
throw getInternalRouterError(404, { pathname:
|
|
2862
|
+
throw getInternalRouterError(404, { pathname: location2.pathname });
|
|
2858
2863
|
}
|
|
2859
|
-
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);
|
|
2860
2865
|
if (routeId && !match) {
|
|
2861
2866
|
throw getInternalRouterError(403, {
|
|
2862
|
-
pathname:
|
|
2867
|
+
pathname: location2.pathname,
|
|
2863
2868
|
routeId
|
|
2864
2869
|
});
|
|
2865
2870
|
} else if (!match) {
|
|
2866
|
-
throw getInternalRouterError(404, { pathname:
|
|
2871
|
+
throw getInternalRouterError(404, { pathname: location2.pathname });
|
|
2867
2872
|
}
|
|
2868
2873
|
if (respond && matches.some(
|
|
2869
2874
|
(m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
|
|
@@ -2886,7 +2891,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2886
2891
|
async () => {
|
|
2887
2892
|
let result2 = await queryImpl(
|
|
2888
2893
|
request,
|
|
2889
|
-
|
|
2894
|
+
location2,
|
|
2890
2895
|
matches,
|
|
2891
2896
|
requestContext,
|
|
2892
2897
|
dataStrategy || null,
|
|
@@ -2919,7 +2924,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2919
2924
|
}
|
|
2920
2925
|
let result = await queryImpl(
|
|
2921
2926
|
request,
|
|
2922
|
-
|
|
2927
|
+
location2,
|
|
2923
2928
|
matches,
|
|
2924
2929
|
requestContext,
|
|
2925
2930
|
dataStrategy || null,
|
|
@@ -2943,7 +2948,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2943
2948
|
}
|
|
2944
2949
|
return void 0;
|
|
2945
2950
|
}
|
|
2946
|
-
async function queryImpl(request,
|
|
2951
|
+
async function queryImpl(request, location2, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
|
|
2947
2952
|
invariant(
|
|
2948
2953
|
request.signal,
|
|
2949
2954
|
"query()/queryRoute() requests must contain an AbortController signal"
|
|
@@ -2953,7 +2958,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2953
2958
|
let result2 = await submit(
|
|
2954
2959
|
request,
|
|
2955
2960
|
matches,
|
|
2956
|
-
routeMatch || getTargetMatch(matches,
|
|
2961
|
+
routeMatch || getTargetMatch(matches, location2),
|
|
2957
2962
|
requestContext,
|
|
2958
2963
|
dataStrategy,
|
|
2959
2964
|
skipLoaderErrorBubbling,
|
|
@@ -3269,7 +3274,7 @@ function throwStaticHandlerAbortedError(request, isRouteRequest) {
|
|
|
3269
3274
|
function isSubmissionNavigation(opts) {
|
|
3270
3275
|
return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0);
|
|
3271
3276
|
}
|
|
3272
|
-
function normalizeTo(
|
|
3277
|
+
function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
|
|
3273
3278
|
let contextualMatches;
|
|
3274
3279
|
let activeRouteMatch;
|
|
3275
3280
|
if (fromRouteId) {
|
|
@@ -3288,12 +3293,12 @@ function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
|
|
|
3288
3293
|
let path = resolveTo(
|
|
3289
3294
|
to ? to : ".",
|
|
3290
3295
|
getResolveToMatches(contextualMatches),
|
|
3291
|
-
stripBasename(
|
|
3296
|
+
stripBasename(location2.pathname, basename) || location2.pathname,
|
|
3292
3297
|
relative === "path"
|
|
3293
3298
|
);
|
|
3294
3299
|
if (to == null) {
|
|
3295
|
-
path.search =
|
|
3296
|
-
path.hash =
|
|
3300
|
+
path.search = location2.search;
|
|
3301
|
+
path.hash = location2.hash;
|
|
3297
3302
|
}
|
|
3298
3303
|
if ((to == null || to === "" || to === ".") && activeRouteMatch) {
|
|
3299
3304
|
let nakedIndex = hasNakedIndexQuery(path.search);
|
|
@@ -3420,10 +3425,10 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
|
|
|
3420
3425
|
parsedPath.search = `?${searchParams}`;
|
|
3421
3426
|
return { path: createPath(parsedPath), submission };
|
|
3422
3427
|
}
|
|
3423
|
-
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) {
|
|
3424
3429
|
let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
|
|
3425
3430
|
let currentUrl = history.createURL(state.location);
|
|
3426
|
-
let nextUrl = history.createURL(
|
|
3431
|
+
let nextUrl = history.createURL(location2);
|
|
3427
3432
|
let maxIdx;
|
|
3428
3433
|
if (initialHydration && state.errors) {
|
|
3429
3434
|
let boundaryId = Object.keys(state.errors)[0];
|
|
@@ -3585,7 +3590,7 @@ function shouldLoadRouteOnHydration(route, loaderData, errors) {
|
|
|
3585
3590
|
if (!route.loader) {
|
|
3586
3591
|
return false;
|
|
3587
3592
|
}
|
|
3588
|
-
let hasData = loaderData != null && route.id
|
|
3593
|
+
let hasData = loaderData != null && loaderData[route.id] !== void 0;
|
|
3589
3594
|
let hasError = errors != null && errors[route.id] !== void 0;
|
|
3590
3595
|
if (!hasData && hasError) {
|
|
3591
3596
|
return false;
|
|
@@ -3622,7 +3627,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
3622
3627
|
}
|
|
3623
3628
|
return arg.defaultShouldRevalidate;
|
|
3624
3629
|
}
|
|
3625
|
-
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2) {
|
|
3630
|
+
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
|
|
3626
3631
|
let childrenToPatch;
|
|
3627
3632
|
if (routeId) {
|
|
3628
3633
|
let route = manifest[routeId];
|
|
@@ -3637,18 +3642,47 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
3637
3642
|
} else {
|
|
3638
3643
|
childrenToPatch = routesToUse;
|
|
3639
3644
|
}
|
|
3640
|
-
let uniqueChildren =
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
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
|
+
}
|
|
3652
3686
|
}
|
|
3653
3687
|
function isSameRoute(newRoute, existingRoute) {
|
|
3654
3688
|
if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
|
|
@@ -3997,7 +4031,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, laz
|
|
|
3997
4031
|
return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
|
|
3998
4032
|
},
|
|
3999
4033
|
resolve(handlerOverride) {
|
|
4000
|
-
if (isUsingNewApi || shouldLoad || handlerOverride && request.method
|
|
4034
|
+
if (isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (match.route.lazy || match.route.loader)) {
|
|
4001
4035
|
return callLoaderOrAction({
|
|
4002
4036
|
request,
|
|
4003
4037
|
match,
|
|
@@ -4257,39 +4291,39 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
4257
4291
|
return { type: "data" /* data */, data: result };
|
|
4258
4292
|
}
|
|
4259
4293
|
function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename) {
|
|
4260
|
-
let
|
|
4294
|
+
let location2 = response.headers.get("Location");
|
|
4261
4295
|
invariant(
|
|
4262
|
-
|
|
4296
|
+
location2,
|
|
4263
4297
|
"Redirects returned/thrown from loaders/actions must have a Location header"
|
|
4264
4298
|
);
|
|
4265
|
-
if (!ABSOLUTE_URL_REGEX.test(
|
|
4299
|
+
if (!ABSOLUTE_URL_REGEX.test(location2)) {
|
|
4266
4300
|
let trimmedMatches = matches.slice(
|
|
4267
4301
|
0,
|
|
4268
4302
|
matches.findIndex((m) => m.route.id === routeId) + 1
|
|
4269
4303
|
);
|
|
4270
|
-
|
|
4304
|
+
location2 = normalizeTo(
|
|
4271
4305
|
new URL(request.url),
|
|
4272
4306
|
trimmedMatches,
|
|
4273
4307
|
basename,
|
|
4274
|
-
|
|
4308
|
+
location2
|
|
4275
4309
|
);
|
|
4276
|
-
response.headers.set("Location",
|
|
4310
|
+
response.headers.set("Location", location2);
|
|
4277
4311
|
}
|
|
4278
4312
|
return response;
|
|
4279
4313
|
}
|
|
4280
|
-
function normalizeRedirectLocation(
|
|
4281
|
-
if (ABSOLUTE_URL_REGEX.test(
|
|
4282
|
-
let normalizedLocation =
|
|
4314
|
+
function normalizeRedirectLocation(location2, currentUrl, basename) {
|
|
4315
|
+
if (ABSOLUTE_URL_REGEX.test(location2)) {
|
|
4316
|
+
let normalizedLocation = location2;
|
|
4283
4317
|
let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
|
|
4284
4318
|
let isSameBasename = stripBasename(url.pathname, basename) != null;
|
|
4285
4319
|
if (url.origin === currentUrl.origin && isSameBasename) {
|
|
4286
4320
|
return url.pathname + url.search + url.hash;
|
|
4287
4321
|
}
|
|
4288
4322
|
}
|
|
4289
|
-
return
|
|
4323
|
+
return location2;
|
|
4290
4324
|
}
|
|
4291
|
-
function createClientSideRequest(history,
|
|
4292
|
-
let url = history.createURL(stripHashFromPath(
|
|
4325
|
+
function createClientSideRequest(history, location2, signal, submission) {
|
|
4326
|
+
let url = history.createURL(stripHashFromPath(location2)).toString();
|
|
4293
4327
|
let init = { signal };
|
|
4294
4328
|
if (submission && isMutationMethod(submission.formMethod)) {
|
|
4295
4329
|
let { formMethod, formEncType } = submission;
|
|
@@ -4375,9 +4409,7 @@ function processRouteLoaderData(matches, results, pendingActionResult, isStaticH
|
|
|
4375
4409
|
});
|
|
4376
4410
|
if (pendingError !== void 0 && pendingActionResult) {
|
|
4377
4411
|
errors = { [pendingActionResult[0]]: pendingError };
|
|
4378
|
-
|
|
4379
|
-
loaderData[pendingActionResult[2]] = void 0;
|
|
4380
|
-
}
|
|
4412
|
+
loaderData[pendingActionResult[0]] = void 0;
|
|
4381
4413
|
}
|
|
4382
4414
|
return {
|
|
4383
4415
|
loaderData,
|
|
@@ -4561,8 +4593,8 @@ function isMutationMethod(method) {
|
|
|
4561
4593
|
function hasNakedIndexQuery(search) {
|
|
4562
4594
|
return new URLSearchParams(search).getAll("index").some((v) => v === "");
|
|
4563
4595
|
}
|
|
4564
|
-
function getTargetMatch(matches,
|
|
4565
|
-
let search = typeof
|
|
4596
|
+
function getTargetMatch(matches, location2) {
|
|
4597
|
+
let search = typeof location2 === "string" ? parsePath(location2).search : location2.search;
|
|
4566
4598
|
if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
|
|
4567
4599
|
return matches[matches.length - 1];
|
|
4568
4600
|
}
|
|
@@ -4603,11 +4635,11 @@ function getSubmissionFromNavigation(navigation) {
|
|
|
4603
4635
|
};
|
|
4604
4636
|
}
|
|
4605
4637
|
}
|
|
4606
|
-
function getLoadingNavigation(
|
|
4638
|
+
function getLoadingNavigation(location2, submission) {
|
|
4607
4639
|
if (submission) {
|
|
4608
4640
|
let navigation = {
|
|
4609
4641
|
state: "loading",
|
|
4610
|
-
location,
|
|
4642
|
+
location: location2,
|
|
4611
4643
|
formMethod: submission.formMethod,
|
|
4612
4644
|
formAction: submission.formAction,
|
|
4613
4645
|
formEncType: submission.formEncType,
|
|
@@ -4619,7 +4651,7 @@ function getLoadingNavigation(location, submission) {
|
|
|
4619
4651
|
} else {
|
|
4620
4652
|
let navigation = {
|
|
4621
4653
|
state: "loading",
|
|
4622
|
-
location,
|
|
4654
|
+
location: location2,
|
|
4623
4655
|
formMethod: void 0,
|
|
4624
4656
|
formAction: void 0,
|
|
4625
4657
|
formEncType: void 0,
|
|
@@ -4630,10 +4662,10 @@ function getLoadingNavigation(location, submission) {
|
|
|
4630
4662
|
return navigation;
|
|
4631
4663
|
}
|
|
4632
4664
|
}
|
|
4633
|
-
function getSubmittingNavigation(
|
|
4665
|
+
function getSubmittingNavigation(location2, submission) {
|
|
4634
4666
|
let navigation = {
|
|
4635
4667
|
state: "submitting",
|
|
4636
|
-
location,
|
|
4668
|
+
location: location2,
|
|
4637
4669
|
formMethod: submission.formMethod,
|
|
4638
4670
|
formAction: submission.formAction,
|
|
4639
4671
|
formEncType: submission.formEncType,
|
|
@@ -4794,10 +4826,10 @@ var RouteContext = React.createContext({
|
|
|
4794
4826
|
RouteContext.displayName = "Route";
|
|
4795
4827
|
var RouteErrorContext = React.createContext(null);
|
|
4796
4828
|
RouteErrorContext.displayName = "RouteError";
|
|
4797
|
-
var ENABLE_DEV_WARNINGS = true;
|
|
4798
4829
|
|
|
4799
4830
|
// lib/hooks.tsx
|
|
4800
4831
|
import * as React2 from "react";
|
|
4832
|
+
var ENABLE_DEV_WARNINGS = true;
|
|
4801
4833
|
function useHref(to, { relative } = {}) {
|
|
4802
4834
|
invariant(
|
|
4803
4835
|
useInRouterContext(),
|
|
@@ -4959,18 +4991,18 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
4959
4991
|
);
|
|
4960
4992
|
}
|
|
4961
4993
|
let locationFromContext = useLocation();
|
|
4962
|
-
let
|
|
4994
|
+
let location2;
|
|
4963
4995
|
if (locationArg) {
|
|
4964
4996
|
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
4965
4997
|
invariant(
|
|
4966
4998
|
parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase),
|
|
4967
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.`
|
|
4968
5000
|
);
|
|
4969
|
-
|
|
5001
|
+
location2 = parsedLocationArg;
|
|
4970
5002
|
} else {
|
|
4971
|
-
|
|
5003
|
+
location2 = locationFromContext;
|
|
4972
5004
|
}
|
|
4973
|
-
let pathname =
|
|
5005
|
+
let pathname = location2.pathname || "/";
|
|
4974
5006
|
let remainingPathname = pathname;
|
|
4975
5007
|
if (parentPathnameBase !== "/") {
|
|
4976
5008
|
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
|
|
@@ -4981,11 +5013,11 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
4981
5013
|
if (ENABLE_DEV_WARNINGS) {
|
|
4982
5014
|
warning(
|
|
4983
5015
|
parentRoute || matches != null,
|
|
4984
|
-
`No routes matched location "${
|
|
5016
|
+
`No routes matched location "${location2.pathname}${location2.search}${location2.hash}" `
|
|
4985
5017
|
);
|
|
4986
5018
|
warning(
|
|
4987
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,
|
|
4988
|
-
`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.`
|
|
4989
5021
|
);
|
|
4990
5022
|
}
|
|
4991
5023
|
let renderedMatches = _renderMatches(
|
|
@@ -5019,7 +5051,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5019
5051
|
hash: "",
|
|
5020
5052
|
state: null,
|
|
5021
5053
|
key: "default",
|
|
5022
|
-
...
|
|
5054
|
+
...location2
|
|
5023
5055
|
},
|
|
5024
5056
|
navigationType: "POP" /* Pop */
|
|
5025
5057
|
}
|
|
@@ -5379,6 +5411,7 @@ function warnOnce(condition, message) {
|
|
|
5379
5411
|
}
|
|
5380
5412
|
|
|
5381
5413
|
// lib/components.tsx
|
|
5414
|
+
var ENABLE_DEV_WARNINGS2 = true;
|
|
5382
5415
|
function mapRouteProperties(route) {
|
|
5383
5416
|
let updates = {
|
|
5384
5417
|
// Note: this check also occurs in createRoutesFromChildren so update
|
|
@@ -5386,7 +5419,7 @@ function mapRouteProperties(route) {
|
|
|
5386
5419
|
hasErrorBoundary: route.hasErrorBoundary || route.ErrorBoundary != null || route.errorElement != null
|
|
5387
5420
|
};
|
|
5388
5421
|
if (route.Component) {
|
|
5389
|
-
if (
|
|
5422
|
+
if (ENABLE_DEV_WARNINGS2) {
|
|
5390
5423
|
if (route.element) {
|
|
5391
5424
|
warning(
|
|
5392
5425
|
false,
|
|
@@ -5400,7 +5433,7 @@ function mapRouteProperties(route) {
|
|
|
5400
5433
|
});
|
|
5401
5434
|
}
|
|
5402
5435
|
if (route.HydrateFallback) {
|
|
5403
|
-
if (
|
|
5436
|
+
if (ENABLE_DEV_WARNINGS2) {
|
|
5404
5437
|
if (route.hydrateFallbackElement) {
|
|
5405
5438
|
warning(
|
|
5406
5439
|
false,
|
|
@@ -5414,7 +5447,7 @@ function mapRouteProperties(route) {
|
|
|
5414
5447
|
});
|
|
5415
5448
|
}
|
|
5416
5449
|
if (route.ErrorBoundary) {
|
|
5417
|
-
if (
|
|
5450
|
+
if (ENABLE_DEV_WARNINGS2) {
|
|
5418
5451
|
if (route.errorElement) {
|
|
5419
5452
|
warning(
|
|
5420
5453
|
false,
|
|
@@ -5783,9 +5816,9 @@ function Router({
|
|
|
5783
5816
|
}
|
|
5784
5817
|
function Routes({
|
|
5785
5818
|
children,
|
|
5786
|
-
location
|
|
5819
|
+
location: location2
|
|
5787
5820
|
}) {
|
|
5788
|
-
return useRoutes(createRoutesFromChildren(children),
|
|
5821
|
+
return useRoutes(createRoutesFromChildren(children), location2);
|
|
5789
5822
|
}
|
|
5790
5823
|
function Await({
|
|
5791
5824
|
children,
|
|
@@ -5855,6 +5888,38 @@ function ResolveAwait({
|
|
|
5855
5888
|
let toRender = typeof children === "function" ? children(data2) : children;
|
|
5856
5889
|
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, toRender);
|
|
5857
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
|
+
}
|
|
5858
5923
|
function createRoutesFromChildren(children, parentPath = []) {
|
|
5859
5924
|
let routes = [];
|
|
5860
5925
|
React3.Children.forEach(children, (element, index) => {
|
|
@@ -6177,7 +6242,7 @@ async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
|
|
|
6177
6242
|
)
|
|
6178
6243
|
);
|
|
6179
6244
|
}
|
|
6180
|
-
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest,
|
|
6245
|
+
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location2, mode) {
|
|
6181
6246
|
let isNew = (match, index) => {
|
|
6182
6247
|
if (!currentMatches[index]) return true;
|
|
6183
6248
|
return match.route.id !== currentMatches[index].route.id;
|
|
@@ -6207,7 +6272,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
6207
6272
|
if (match.route.shouldRevalidate) {
|
|
6208
6273
|
let routeChoice = match.route.shouldRevalidate({
|
|
6209
6274
|
currentUrl: new URL(
|
|
6210
|
-
|
|
6275
|
+
location2.pathname + location2.search + location2.hash,
|
|
6211
6276
|
window.origin
|
|
6212
6277
|
),
|
|
6213
6278
|
currentParams: currentMatches[0]?.params || {},
|
|
@@ -6327,7 +6392,6 @@ async function createRequestInit(request) {
|
|
|
6327
6392
|
|
|
6328
6393
|
// lib/dom/ssr/single-fetch.tsx
|
|
6329
6394
|
var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
|
|
6330
|
-
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
6331
6395
|
var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205]);
|
|
6332
6396
|
function StreamTransfer({
|
|
6333
6397
|
context,
|
|
@@ -6540,8 +6604,7 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
|
|
|
6540
6604
|
)
|
|
6541
6605
|
);
|
|
6542
6606
|
await Promise.all(routeDfds.map((d) => d.promise));
|
|
6543
|
-
|
|
6544
|
-
if ((isInitialLoad || routesParams.size === 0) && !window.__reactRouterHdrActive) {
|
|
6607
|
+
if ((!router.state.initialized || routesParams.size === 0) && !window.__reactRouterHdrActive) {
|
|
6545
6608
|
singleFetchDfd.resolve({ routes: {} });
|
|
6546
6609
|
} else {
|
|
6547
6610
|
let targetRoutes = ssr && foundOptOutRoute && routesParams.size > 0 ? [...routesParams.keys()] : void 0;
|
|
@@ -6581,7 +6644,7 @@ function stripIndexParam(url) {
|
|
|
6581
6644
|
}
|
|
6582
6645
|
return url;
|
|
6583
6646
|
}
|
|
6584
|
-
function singleFetchUrl(reqUrl, basename) {
|
|
6647
|
+
function singleFetchUrl(reqUrl, basename, extension) {
|
|
6585
6648
|
let url = typeof reqUrl === "string" ? new URL(
|
|
6586
6649
|
reqUrl,
|
|
6587
6650
|
// This can be called during the SSR flow via PrefetchPageLinksImpl so
|
|
@@ -6589,17 +6652,17 @@ function singleFetchUrl(reqUrl, basename) {
|
|
|
6589
6652
|
typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
|
|
6590
6653
|
) : reqUrl;
|
|
6591
6654
|
if (url.pathname === "/") {
|
|
6592
|
-
url.pathname =
|
|
6655
|
+
url.pathname = `_root.${extension}`;
|
|
6593
6656
|
} else if (basename && stripBasename(url.pathname, basename) === "/") {
|
|
6594
|
-
url.pathname = `${basename.replace(/\/$/, "")}/_root
|
|
6657
|
+
url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
|
|
6595
6658
|
} else {
|
|
6596
|
-
url.pathname = `${url.pathname.replace(/\/$/, "")}
|
|
6659
|
+
url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
|
|
6597
6660
|
}
|
|
6598
6661
|
return url;
|
|
6599
6662
|
}
|
|
6600
6663
|
async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
6601
6664
|
let { request } = args;
|
|
6602
|
-
let url = singleFetchUrl(request.url, basename);
|
|
6665
|
+
let url = singleFetchUrl(request.url, basename, "data");
|
|
6603
6666
|
if (request.method === "GET") {
|
|
6604
6667
|
url = stripIndexParam(url);
|
|
6605
6668
|
if (targetRoutes) {
|
|
@@ -6610,20 +6673,6 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
|
6610
6673
|
if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
|
|
6611
6674
|
throw new ErrorResponseImpl(404, "Not Found", true);
|
|
6612
6675
|
}
|
|
6613
|
-
if (res.status === 204 && res.headers.has("X-Remix-Redirect")) {
|
|
6614
|
-
return {
|
|
6615
|
-
status: SINGLE_FETCH_REDIRECT_STATUS,
|
|
6616
|
-
data: {
|
|
6617
|
-
redirect: {
|
|
6618
|
-
redirect: res.headers.get("X-Remix-Redirect"),
|
|
6619
|
-
status: Number(res.headers.get("X-Remix-Status") || "302"),
|
|
6620
|
-
revalidate: res.headers.get("X-Remix-Revalidate") === "true",
|
|
6621
|
-
reload: res.headers.get("X-Remix-Reload-Document") === "true",
|
|
6622
|
-
replace: res.headers.get("X-Remix-Replace") === "true"
|
|
6623
|
-
}
|
|
6624
|
-
}
|
|
6625
|
-
};
|
|
6626
|
-
}
|
|
6627
6676
|
if (NO_BODY_STATUS_CODES.has(res.status)) {
|
|
6628
6677
|
let routes = {};
|
|
6629
6678
|
if (targetRoutes && request.method !== "GET") {
|
|
@@ -6696,13 +6745,13 @@ function decodeViaTurboStream(body, global2) {
|
|
|
6696
6745
|
function unwrapSingleFetchResult(result, routeId) {
|
|
6697
6746
|
if ("redirect" in result) {
|
|
6698
6747
|
let {
|
|
6699
|
-
redirect:
|
|
6748
|
+
redirect: location2,
|
|
6700
6749
|
revalidate,
|
|
6701
6750
|
reload,
|
|
6702
6751
|
replace: replace2,
|
|
6703
6752
|
status
|
|
6704
6753
|
} = result.redirect;
|
|
6705
|
-
throw redirect(
|
|
6754
|
+
throw redirect(location2, {
|
|
6706
6755
|
status,
|
|
6707
6756
|
headers: {
|
|
6708
6757
|
// Three R's of redirecting (lol Veep)
|
|
@@ -6713,12 +6762,13 @@ function unwrapSingleFetchResult(result, routeId) {
|
|
|
6713
6762
|
});
|
|
6714
6763
|
}
|
|
6715
6764
|
let routeResult = result.routes[routeId];
|
|
6765
|
+
invariant2(routeResult, `No response found for routeId "${routeId}"`);
|
|
6716
6766
|
if ("error" in routeResult) {
|
|
6717
6767
|
throw routeResult.error;
|
|
6718
6768
|
} else if ("data" in routeResult) {
|
|
6719
6769
|
return routeResult.data;
|
|
6720
6770
|
} else {
|
|
6721
|
-
throw new Error(`
|
|
6771
|
+
throw new Error(`Invalid response found for routeId "${routeId}"`);
|
|
6722
6772
|
}
|
|
6723
6773
|
}
|
|
6724
6774
|
function createDeferred2() {
|
|
@@ -6796,14 +6846,14 @@ function RemixRootDefaultErrorBoundary({
|
|
|
6796
6846
|
dangerouslySetInnerHTML: {
|
|
6797
6847
|
__html: `
|
|
6798
6848
|
console.log(
|
|
6799
|
-
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://
|
|
6849
|
+
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://remix.run/guides/errors for more information."
|
|
6800
6850
|
);
|
|
6801
6851
|
`
|
|
6802
6852
|
}
|
|
6803
6853
|
}
|
|
6804
6854
|
);
|
|
6805
6855
|
if (isRouteErrorResponse(error)) {
|
|
6806
|
-
return /* @__PURE__ */ React5.createElement(BoundaryShell, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ React5.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText),
|
|
6856
|
+
return /* @__PURE__ */ React5.createElement(BoundaryShell, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ React5.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText), heyDeveloper);
|
|
6807
6857
|
}
|
|
6808
6858
|
let errorInstance;
|
|
6809
6859
|
if (error instanceof Error) {
|
|
@@ -6856,7 +6906,7 @@ function BoundaryShell({
|
|
|
6856
6906
|
// lib/dom/ssr/fallback.tsx
|
|
6857
6907
|
import * as React6 from "react";
|
|
6858
6908
|
function RemixRootDefaultHydrateFallback() {
|
|
6859
|
-
return /* @__PURE__ */ React6.createElement(BoundaryShell, { title: "Loading...", renderScripts: true },
|
|
6909
|
+
return /* @__PURE__ */ React6.createElement(BoundaryShell, { title: "Loading...", renderScripts: true }, /* @__PURE__ */ React6.createElement(
|
|
6860
6910
|
"script",
|
|
6861
6911
|
{
|
|
6862
6912
|
dangerouslySetInnerHTML: {
|
|
@@ -6864,13 +6914,13 @@ function RemixRootDefaultHydrateFallback() {
|
|
|
6864
6914
|
console.log(
|
|
6865
6915
|
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this " +
|
|
6866
6916
|
"when your app is loading JS modules and/or running \`clientLoader\` " +
|
|
6867
|
-
"functions. Check out https://
|
|
6917
|
+
"functions. Check out https://remix.run/route/hydrate-fallback " +
|
|
6868
6918
|
"for more information."
|
|
6869
6919
|
);
|
|
6870
6920
|
`
|
|
6871
6921
|
}
|
|
6872
6922
|
}
|
|
6873
|
-
)
|
|
6923
|
+
));
|
|
6874
6924
|
}
|
|
6875
6925
|
|
|
6876
6926
|
// lib/dom/ssr/routes.tsx
|
|
@@ -7283,8 +7333,8 @@ var nextPaths = /* @__PURE__ */ new Set();
|
|
|
7283
7333
|
var discoveredPathsMaxSize = 1e3;
|
|
7284
7334
|
var discoveredPaths = /* @__PURE__ */ new Set();
|
|
7285
7335
|
var URL_LIMIT = 7680;
|
|
7286
|
-
function isFogOfWarEnabled(
|
|
7287
|
-
return
|
|
7336
|
+
function isFogOfWarEnabled(ssr) {
|
|
7337
|
+
return ssr === true;
|
|
7288
7338
|
}
|
|
7289
7339
|
function getPartialManifest({ sri, ...manifest }, router) {
|
|
7290
7340
|
let routeIds = new Set(router.state.matches.map((m) => m.route.id));
|
|
@@ -7311,8 +7361,8 @@ function getPartialManifest({ sri, ...manifest }, router) {
|
|
|
7311
7361
|
sri: sri ? true : void 0
|
|
7312
7362
|
};
|
|
7313
7363
|
}
|
|
7314
|
-
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr,
|
|
7315
|
-
if (!isFogOfWarEnabled(
|
|
7364
|
+
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
|
|
7365
|
+
if (!isFogOfWarEnabled(ssr)) {
|
|
7316
7366
|
return void 0;
|
|
7317
7367
|
}
|
|
7318
7368
|
return async ({ path, patch, signal, fetcherKey }) => {
|
|
@@ -7327,15 +7377,14 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDi
|
|
|
7327
7377
|
ssr,
|
|
7328
7378
|
isSpaMode,
|
|
7329
7379
|
basename,
|
|
7330
|
-
routeDiscovery.manifestPath,
|
|
7331
7380
|
patch,
|
|
7332
7381
|
signal
|
|
7333
7382
|
);
|
|
7334
7383
|
};
|
|
7335
7384
|
}
|
|
7336
|
-
function useFogOFWarDiscovery(router, manifest, routeModules, ssr,
|
|
7385
|
+
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
7337
7386
|
React8.useEffect(() => {
|
|
7338
|
-
if (!isFogOfWarEnabled(
|
|
7387
|
+
if (!isFogOfWarEnabled(ssr) || navigator.connection?.saveData === true) {
|
|
7339
7388
|
return;
|
|
7340
7389
|
}
|
|
7341
7390
|
function registerElement(el) {
|
|
@@ -7369,7 +7418,6 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscover
|
|
|
7369
7418
|
ssr,
|
|
7370
7419
|
isSpaMode,
|
|
7371
7420
|
router.basename,
|
|
7372
|
-
routeDiscovery.manifestPath,
|
|
7373
7421
|
router.patchRoutes
|
|
7374
7422
|
);
|
|
7375
7423
|
} catch (e) {
|
|
@@ -7386,21 +7434,15 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscover
|
|
|
7386
7434
|
attributeFilter: ["data-discover", "href", "action"]
|
|
7387
7435
|
});
|
|
7388
7436
|
return () => observer.disconnect();
|
|
7389
|
-
}, [ssr, isSpaMode, manifest, routeModules, router
|
|
7390
|
-
}
|
|
7391
|
-
function getManifestPath(_manifestPath, basename) {
|
|
7392
|
-
let manifestPath = _manifestPath || "/__manifest";
|
|
7393
|
-
if (basename == null) {
|
|
7394
|
-
return manifestPath;
|
|
7395
|
-
}
|
|
7396
|
-
return `${basename}${manifestPath}`.replace(/\/+/g, "/");
|
|
7437
|
+
}, [ssr, isSpaMode, manifest, routeModules, router]);
|
|
7397
7438
|
}
|
|
7398
7439
|
var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
|
|
7399
|
-
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename,
|
|
7400
|
-
let
|
|
7401
|
-
|
|
7402
|
-
|
|
7440
|
+
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, patchRoutes, signal) {
|
|
7441
|
+
let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
|
|
7442
|
+
/\/+/g,
|
|
7443
|
+
"/"
|
|
7403
7444
|
);
|
|
7445
|
+
let url = new URL(manifestPath, window.location.origin);
|
|
7404
7446
|
paths.sort().forEach((path) => url.searchParams.append("p", path));
|
|
7405
7447
|
url.searchParams.set("version", manifest.version);
|
|
7406
7448
|
if (url.toString().length > URL_LIMIT) {
|
|
@@ -7427,9 +7469,7 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
7427
7469
|
}
|
|
7428
7470
|
sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
|
|
7429
7471
|
window.location.href = errorReloadPath;
|
|
7430
|
-
|
|
7431
|
-
await new Promise(() => {
|
|
7432
|
-
});
|
|
7472
|
+
throw new Error("Detected manifest version mismatch, reloading...");
|
|
7433
7473
|
} else if (res.status >= 400) {
|
|
7434
7474
|
throw new Error(await res.text());
|
|
7435
7475
|
}
|
|
@@ -7628,7 +7668,7 @@ function PrefetchPageLinksImpl({
|
|
|
7628
7668
|
matches: nextMatches,
|
|
7629
7669
|
...linkProps
|
|
7630
7670
|
}) {
|
|
7631
|
-
let
|
|
7671
|
+
let location2 = useLocation();
|
|
7632
7672
|
let { manifest, routeModules } = useFrameworkContext();
|
|
7633
7673
|
let { basename } = useDataRouterContext2();
|
|
7634
7674
|
let { loaderData, matches } = useDataRouterStateContext();
|
|
@@ -7638,10 +7678,10 @@ function PrefetchPageLinksImpl({
|
|
|
7638
7678
|
nextMatches,
|
|
7639
7679
|
matches,
|
|
7640
7680
|
manifest,
|
|
7641
|
-
|
|
7681
|
+
location2,
|
|
7642
7682
|
"data"
|
|
7643
7683
|
),
|
|
7644
|
-
[page, nextMatches, matches, manifest,
|
|
7684
|
+
[page, nextMatches, matches, manifest, location2]
|
|
7645
7685
|
);
|
|
7646
7686
|
let newMatchesForAssets = React9.useMemo(
|
|
7647
7687
|
() => getNewMatchesForLinks(
|
|
@@ -7649,13 +7689,13 @@ function PrefetchPageLinksImpl({
|
|
|
7649
7689
|
nextMatches,
|
|
7650
7690
|
matches,
|
|
7651
7691
|
manifest,
|
|
7652
|
-
|
|
7692
|
+
location2,
|
|
7653
7693
|
"assets"
|
|
7654
7694
|
),
|
|
7655
|
-
[page, nextMatches, matches, manifest,
|
|
7695
|
+
[page, nextMatches, matches, manifest, location2]
|
|
7656
7696
|
);
|
|
7657
7697
|
let dataHrefs = React9.useMemo(() => {
|
|
7658
|
-
if (page ===
|
|
7698
|
+
if (page === location2.pathname + location2.search + location2.hash) {
|
|
7659
7699
|
return [];
|
|
7660
7700
|
}
|
|
7661
7701
|
let routesParams = /* @__PURE__ */ new Set();
|
|
@@ -7676,7 +7716,7 @@ function PrefetchPageLinksImpl({
|
|
|
7676
7716
|
if (routesParams.size === 0) {
|
|
7677
7717
|
return [];
|
|
7678
7718
|
}
|
|
7679
|
-
let url = singleFetchUrl(page, basename);
|
|
7719
|
+
let url = singleFetchUrl(page, basename, ".data");
|
|
7680
7720
|
if (foundOptOutRoute && routesParams.size > 0) {
|
|
7681
7721
|
url.searchParams.set(
|
|
7682
7722
|
"_routes",
|
|
@@ -7687,7 +7727,7 @@ function PrefetchPageLinksImpl({
|
|
|
7687
7727
|
}, [
|
|
7688
7728
|
basename,
|
|
7689
7729
|
loaderData,
|
|
7690
|
-
|
|
7730
|
+
location2,
|
|
7691
7731
|
manifest,
|
|
7692
7732
|
newMatchesForData,
|
|
7693
7733
|
nextMatches,
|
|
@@ -7712,7 +7752,7 @@ function Meta() {
|
|
|
7712
7752
|
matches: routerMatches,
|
|
7713
7753
|
loaderData
|
|
7714
7754
|
} = useDataRouterStateContext();
|
|
7715
|
-
let
|
|
7755
|
+
let location2 = useLocation();
|
|
7716
7756
|
let _matches = getActiveMatches(routerMatches, errors, isSpaMode);
|
|
7717
7757
|
let error = null;
|
|
7718
7758
|
if (errors) {
|
|
@@ -7742,7 +7782,7 @@ function Meta() {
|
|
|
7742
7782
|
routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
|
|
7743
7783
|
data: data2,
|
|
7744
7784
|
params,
|
|
7745
|
-
location,
|
|
7785
|
+
location: location2,
|
|
7746
7786
|
matches,
|
|
7747
7787
|
error
|
|
7748
7788
|
}) : Array.isArray(routeModule.meta) ? [...routeModule.meta] : routeModule.meta;
|
|
@@ -7808,17 +7848,10 @@ function isValidMetaTag(tagName) {
|
|
|
7808
7848
|
}
|
|
7809
7849
|
var isHydrated = false;
|
|
7810
7850
|
function Scripts(props) {
|
|
7811
|
-
let {
|
|
7812
|
-
manifest,
|
|
7813
|
-
serverHandoffString,
|
|
7814
|
-
isSpaMode,
|
|
7815
|
-
renderMeta,
|
|
7816
|
-
routeDiscovery,
|
|
7817
|
-
ssr
|
|
7818
|
-
} = useFrameworkContext();
|
|
7851
|
+
let { manifest, serverHandoffString, isSpaMode, ssr, renderMeta } = useFrameworkContext();
|
|
7819
7852
|
let { router, static: isStatic, staticContext } = useDataRouterContext2();
|
|
7820
7853
|
let { matches: routerMatches } = useDataRouterStateContext();
|
|
7821
|
-
let enableFogOfWar = isFogOfWarEnabled(
|
|
7854
|
+
let enableFogOfWar = isFogOfWarEnabled(ssr);
|
|
7822
7855
|
if (renderMeta) {
|
|
7823
7856
|
renderMeta.didRenderScripts = true;
|
|
7824
7857
|
}
|
|
@@ -7974,7 +8007,7 @@ function mergeRefs(...refs) {
|
|
|
7974
8007
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
7975
8008
|
try {
|
|
7976
8009
|
if (isBrowser) {
|
|
7977
|
-
window.__reactRouterVersion = "0.0.0-experimental-
|
|
8010
|
+
window.__reactRouterVersion = "0.0.0-experimental-e56aa53bc";
|
|
7978
8011
|
}
|
|
7979
8012
|
} catch (e) {
|
|
7980
8013
|
}
|
|
@@ -8232,14 +8265,14 @@ var NavLink = React10.forwardRef(
|
|
|
8232
8265
|
...rest
|
|
8233
8266
|
}, ref) {
|
|
8234
8267
|
let path = useResolvedPath(to, { relative: rest.relative });
|
|
8235
|
-
let
|
|
8268
|
+
let location2 = useLocation();
|
|
8236
8269
|
let routerState = React10.useContext(DataRouterStateContext);
|
|
8237
8270
|
let { navigator: navigator2, basename } = React10.useContext(NavigationContext);
|
|
8238
8271
|
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
|
8239
8272
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
8240
8273
|
useViewTransitionState(path) && viewTransition === true;
|
|
8241
8274
|
let toPathname = navigator2.encodeLocation ? navigator2.encodeLocation(path).pathname : path.pathname;
|
|
8242
|
-
let locationPathname =
|
|
8275
|
+
let locationPathname = location2.pathname;
|
|
8243
8276
|
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
|
|
8244
8277
|
if (!caseSensitive) {
|
|
8245
8278
|
locationPathname = locationPathname.toLowerCase();
|
|
@@ -8344,19 +8377,19 @@ function ScrollRestoration({
|
|
|
8344
8377
|
}) {
|
|
8345
8378
|
let remixContext = React10.useContext(FrameworkContext);
|
|
8346
8379
|
let { basename } = React10.useContext(NavigationContext);
|
|
8347
|
-
let
|
|
8380
|
+
let location2 = useLocation();
|
|
8348
8381
|
let matches = useMatches();
|
|
8349
8382
|
useScrollRestoration({ getKey, storageKey });
|
|
8350
8383
|
let ssrKey = React10.useMemo(
|
|
8351
8384
|
() => {
|
|
8352
8385
|
if (!remixContext || !getKey) return null;
|
|
8353
8386
|
let userKey = getScrollRestorationKey(
|
|
8354
|
-
|
|
8387
|
+
location2,
|
|
8355
8388
|
matches,
|
|
8356
8389
|
basename,
|
|
8357
8390
|
getKey
|
|
8358
8391
|
);
|
|
8359
|
-
return userKey !==
|
|
8392
|
+
return userKey !== location2.key ? userKey : null;
|
|
8360
8393
|
},
|
|
8361
8394
|
// Nah, we only need this the first time for the SSR render
|
|
8362
8395
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -8417,13 +8450,13 @@ function useLinkClickHandler(to, {
|
|
|
8417
8450
|
viewTransition
|
|
8418
8451
|
} = {}) {
|
|
8419
8452
|
let navigate = useNavigate();
|
|
8420
|
-
let
|
|
8453
|
+
let location2 = useLocation();
|
|
8421
8454
|
let path = useResolvedPath(to, { relative });
|
|
8422
8455
|
return React10.useCallback(
|
|
8423
8456
|
(event) => {
|
|
8424
8457
|
if (shouldProcessLinkClick(event, target)) {
|
|
8425
8458
|
event.preventDefault();
|
|
8426
|
-
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(
|
|
8459
|
+
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location2) === createPath(path);
|
|
8427
8460
|
navigate(to, {
|
|
8428
8461
|
replace: replace2,
|
|
8429
8462
|
state,
|
|
@@ -8434,7 +8467,7 @@ function useLinkClickHandler(to, {
|
|
|
8434
8467
|
}
|
|
8435
8468
|
},
|
|
8436
8469
|
[
|
|
8437
|
-
|
|
8470
|
+
location2,
|
|
8438
8471
|
navigate,
|
|
8439
8472
|
path,
|
|
8440
8473
|
replaceProp,
|
|
@@ -8454,18 +8487,18 @@ function useSearchParams(defaultInit) {
|
|
|
8454
8487
|
);
|
|
8455
8488
|
let defaultSearchParamsRef = React10.useRef(createSearchParams(defaultInit));
|
|
8456
8489
|
let hasSetSearchParamsRef = React10.useRef(false);
|
|
8457
|
-
let
|
|
8490
|
+
let location2 = useLocation();
|
|
8458
8491
|
let searchParams = React10.useMemo(
|
|
8459
8492
|
() => (
|
|
8460
8493
|
// Only merge in the defaults if we haven't yet called setSearchParams.
|
|
8461
8494
|
// Once we call that we want those to take precedence, otherwise you can't
|
|
8462
8495
|
// remove a param with setSearchParams({}) if it has an initial value
|
|
8463
8496
|
getSearchParamsForLocation(
|
|
8464
|
-
|
|
8497
|
+
location2.search,
|
|
8465
8498
|
hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
|
|
8466
8499
|
)
|
|
8467
8500
|
),
|
|
8468
|
-
[
|
|
8501
|
+
[location2.search]
|
|
8469
8502
|
);
|
|
8470
8503
|
let navigate = useNavigate();
|
|
8471
8504
|
let setSearchParams = React10.useCallback(
|
|
@@ -8526,9 +8559,9 @@ function useFormAction(action, { relative } = {}) {
|
|
|
8526
8559
|
invariant(routeContext, "useFormAction must be used inside a RouteContext");
|
|
8527
8560
|
let [match] = routeContext.matches.slice(-1);
|
|
8528
8561
|
let path = { ...useResolvedPath(action ? action : ".", { relative }) };
|
|
8529
|
-
let
|
|
8562
|
+
let location2 = useLocation();
|
|
8530
8563
|
if (action == null) {
|
|
8531
|
-
path.search =
|
|
8564
|
+
path.search = location2.search;
|
|
8532
8565
|
let params = new URLSearchParams(path.search);
|
|
8533
8566
|
let indexValues = params.getAll("index");
|
|
8534
8567
|
let hasNakedIndexParam = indexValues.some((v) => v === "");
|
|
@@ -8620,23 +8653,23 @@ function useFetchers() {
|
|
|
8620
8653
|
}
|
|
8621
8654
|
var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
|
|
8622
8655
|
var savedScrollPositions = {};
|
|
8623
|
-
function getScrollRestorationKey(
|
|
8656
|
+
function getScrollRestorationKey(location2, matches, basename, getKey) {
|
|
8624
8657
|
let key = null;
|
|
8625
8658
|
if (getKey) {
|
|
8626
8659
|
if (basename !== "/") {
|
|
8627
8660
|
key = getKey(
|
|
8628
8661
|
{
|
|
8629
|
-
...
|
|
8630
|
-
pathname: stripBasename(
|
|
8662
|
+
...location2,
|
|
8663
|
+
pathname: stripBasename(location2.pathname, basename) || location2.pathname
|
|
8631
8664
|
},
|
|
8632
8665
|
matches
|
|
8633
8666
|
);
|
|
8634
8667
|
} else {
|
|
8635
|
-
key = getKey(
|
|
8668
|
+
key = getKey(location2, matches);
|
|
8636
8669
|
}
|
|
8637
8670
|
}
|
|
8638
8671
|
if (key == null) {
|
|
8639
|
-
key =
|
|
8672
|
+
key = location2.key;
|
|
8640
8673
|
}
|
|
8641
8674
|
return key;
|
|
8642
8675
|
}
|
|
@@ -8649,7 +8682,7 @@ function useScrollRestoration({
|
|
|
8649
8682
|
"useScrollRestoration" /* UseScrollRestoration */
|
|
8650
8683
|
);
|
|
8651
8684
|
let { basename } = React10.useContext(NavigationContext);
|
|
8652
|
-
let
|
|
8685
|
+
let location2 = useLocation();
|
|
8653
8686
|
let matches = useMatches();
|
|
8654
8687
|
let navigation = useNavigation();
|
|
8655
8688
|
React10.useEffect(() => {
|
|
@@ -8661,7 +8694,7 @@ function useScrollRestoration({
|
|
|
8661
8694
|
usePageHide(
|
|
8662
8695
|
React10.useCallback(() => {
|
|
8663
8696
|
if (navigation.state === "idle") {
|
|
8664
|
-
let key = getScrollRestorationKey(
|
|
8697
|
+
let key = getScrollRestorationKey(location2, matches, basename, getKey);
|
|
8665
8698
|
savedScrollPositions[key] = window.scrollY;
|
|
8666
8699
|
}
|
|
8667
8700
|
try {
|
|
@@ -8676,7 +8709,7 @@ function useScrollRestoration({
|
|
|
8676
8709
|
);
|
|
8677
8710
|
}
|
|
8678
8711
|
window.history.scrollRestoration = "auto";
|
|
8679
|
-
}, [navigation.state, getKey, basename,
|
|
8712
|
+
}, [navigation.state, getKey, basename, location2, matches, storageKey])
|
|
8680
8713
|
);
|
|
8681
8714
|
if (typeof document !== "undefined") {
|
|
8682
8715
|
React10.useLayoutEffect(() => {
|
|
@@ -8694,7 +8727,7 @@ function useScrollRestoration({
|
|
|
8694
8727
|
let disableScrollRestoration = router?.enableScrollRestoration(
|
|
8695
8728
|
savedScrollPositions,
|
|
8696
8729
|
() => window.scrollY,
|
|
8697
|
-
getKey ? (
|
|
8730
|
+
getKey ? (location3, matches2) => getScrollRestorationKey(location3, matches2, basename, getKey) : void 0
|
|
8698
8731
|
);
|
|
8699
8732
|
return () => disableScrollRestoration && disableScrollRestoration();
|
|
8700
8733
|
}, [router, basename, getKey]);
|
|
@@ -8706,9 +8739,9 @@ function useScrollRestoration({
|
|
|
8706
8739
|
window.scrollTo(0, restoreScrollPosition);
|
|
8707
8740
|
return;
|
|
8708
8741
|
}
|
|
8709
|
-
if (
|
|
8742
|
+
if (location2.hash) {
|
|
8710
8743
|
let el = document.getElementById(
|
|
8711
|
-
decodeURIComponent(
|
|
8744
|
+
decodeURIComponent(location2.hash.slice(1))
|
|
8712
8745
|
);
|
|
8713
8746
|
if (el) {
|
|
8714
8747
|
el.scrollIntoView();
|
|
@@ -8719,7 +8752,7 @@ function useScrollRestoration({
|
|
|
8719
8752
|
return;
|
|
8720
8753
|
}
|
|
8721
8754
|
window.scrollTo(0, 0);
|
|
8722
|
-
}, [
|
|
8755
|
+
}, [location2, restoreScrollPosition, preventScrollReset]);
|
|
8723
8756
|
}
|
|
8724
8757
|
}
|
|
8725
8758
|
function useBeforeUnload(callback, options) {
|
|
@@ -8792,7 +8825,7 @@ function StaticRouter({
|
|
|
8792
8825
|
locationProp = parsePath(locationProp);
|
|
8793
8826
|
}
|
|
8794
8827
|
let action = "POP" /* Pop */;
|
|
8795
|
-
let
|
|
8828
|
+
let location2 = {
|
|
8796
8829
|
pathname: locationProp.pathname || "/",
|
|
8797
8830
|
search: locationProp.search || "",
|
|
8798
8831
|
hash: locationProp.hash || "",
|
|
@@ -8805,7 +8838,7 @@ function StaticRouter({
|
|
|
8805
8838
|
{
|
|
8806
8839
|
basename,
|
|
8807
8840
|
children,
|
|
8808
|
-
location,
|
|
8841
|
+
location: location2,
|
|
8809
8842
|
navigationType: action,
|
|
8810
8843
|
navigator: staticNavigator,
|
|
8811
8844
|
static: true
|
|
@@ -9024,6 +9057,9 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
9024
9057
|
_internalFetchControllers: /* @__PURE__ */ new Map(),
|
|
9025
9058
|
_internalSetRoutes() {
|
|
9026
9059
|
throw msg("_internalSetRoutes");
|
|
9060
|
+
},
|
|
9061
|
+
_internalSetStateDoNotUseOrYouWillBreakYourApp() {
|
|
9062
|
+
throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
|
|
9027
9063
|
}
|
|
9028
9064
|
};
|
|
9029
9065
|
}
|
|
@@ -9098,7 +9134,6 @@ function ServerRouter({
|
|
|
9098
9134
|
future: context.future,
|
|
9099
9135
|
ssr: context.ssr,
|
|
9100
9136
|
isSpaMode: context.isSpaMode,
|
|
9101
|
-
routeDiscovery: context.routeDiscovery,
|
|
9102
9137
|
serializeError: context.serializeError,
|
|
9103
9138
|
renderMeta: context.renderMeta
|
|
9104
9139
|
}
|
|
@@ -9148,8 +9183,7 @@ function createRoutesStub(routes, unstable_getContext) {
|
|
|
9148
9183
|
},
|
|
9149
9184
|
routeModules: {},
|
|
9150
9185
|
ssr: false,
|
|
9151
|
-
isSpaMode: false
|
|
9152
|
-
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }
|
|
9186
|
+
isSpaMode: false
|
|
9153
9187
|
};
|
|
9154
9188
|
let patched = processRoutes(
|
|
9155
9189
|
// @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
|
|
@@ -9233,7 +9267,7 @@ function processRoutes(routes, manifest, routeModules, parentId) {
|
|
|
9233
9267
|
import { parse, serialize } from "cookie";
|
|
9234
9268
|
|
|
9235
9269
|
// lib/server-runtime/crypto.ts
|
|
9236
|
-
var encoder =
|
|
9270
|
+
var encoder = new TextEncoder();
|
|
9237
9271
|
var sign = async (value, secret) => {
|
|
9238
9272
|
let data2 = encoder.encode(value);
|
|
9239
9273
|
let key = await createKey2(secret, ["sign"]);
|
|
@@ -9553,26 +9587,6 @@ function invariant3(value, message) {
|
|
|
9553
9587
|
}
|
|
9554
9588
|
}
|
|
9555
9589
|
|
|
9556
|
-
// lib/server-runtime/dev.ts
|
|
9557
|
-
var globalDevServerHooksKey = "__reactRouterDevServerHooks";
|
|
9558
|
-
function setDevServerHooks(devServerHooks) {
|
|
9559
|
-
globalThis[globalDevServerHooksKey] = devServerHooks;
|
|
9560
|
-
}
|
|
9561
|
-
function getDevServerHooks() {
|
|
9562
|
-
return globalThis[globalDevServerHooksKey];
|
|
9563
|
-
}
|
|
9564
|
-
function getBuildTimeHeader(request, headerName) {
|
|
9565
|
-
if (typeof process !== "undefined") {
|
|
9566
|
-
try {
|
|
9567
|
-
if (process.env?.IS_RR_BUILD_REQUEST === "yes") {
|
|
9568
|
-
return request.headers.get(headerName);
|
|
9569
|
-
}
|
|
9570
|
-
} catch (e) {
|
|
9571
|
-
}
|
|
9572
|
-
}
|
|
9573
|
-
return null;
|
|
9574
|
-
}
|
|
9575
|
-
|
|
9576
9590
|
// lib/server-runtime/routes.ts
|
|
9577
9591
|
function groupRoutesByParentId2(manifest) {
|
|
9578
9592
|
let routes = {};
|
|
@@ -9604,11 +9618,10 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
|
|
|
9604
9618
|
// Need to use RR's version in the param typed here to permit the optional
|
|
9605
9619
|
// context even though we know it'll always be provided in remix
|
|
9606
9620
|
loader: route.module.loader ? async (args) => {
|
|
9607
|
-
|
|
9608
|
-
args.request
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
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
|
+
);
|
|
9612
9625
|
let encoded = preRenderedData ? decodeURI(preRenderedData) : preRenderedData;
|
|
9613
9626
|
invariant3(encoded, "Missing prerendered data for route");
|
|
9614
9627
|
let uint8array = new TextEncoder().encode(encoded);
|
|
@@ -9683,12 +9696,21 @@ function createServerHandoffString(serverHandoff) {
|
|
|
9683
9696
|
return escapeHtml2(JSON.stringify(serverHandoff));
|
|
9684
9697
|
}
|
|
9685
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
|
+
|
|
9686
9708
|
// lib/server-runtime/single-fetch.ts
|
|
9687
9709
|
import { encode } from "turbo-stream";
|
|
9688
9710
|
|
|
9689
9711
|
// lib/server-runtime/headers.ts
|
|
9690
9712
|
import { splitCookiesString } from "set-cookie-parser";
|
|
9691
|
-
function getDocumentHeaders(
|
|
9713
|
+
function getDocumentHeaders(context, getRouteHeadersFn) {
|
|
9692
9714
|
let boundaryIdx = context.errors ? context.matches.findIndex((m) => context.errors[m.route.id]) : -1;
|
|
9693
9715
|
let matches = boundaryIdx >= 0 ? context.matches.slice(0, boundaryIdx + 1) : context.matches;
|
|
9694
9716
|
let errorHeaders;
|
|
@@ -9706,14 +9728,12 @@ function getDocumentHeaders(build, context) {
|
|
|
9706
9728
|
}
|
|
9707
9729
|
return matches.reduce((parentHeaders, match, idx) => {
|
|
9708
9730
|
let { id } = match.route;
|
|
9709
|
-
let route = build.routes[id];
|
|
9710
|
-
invariant3(route, `Route with id "${id}" not found in build`);
|
|
9711
|
-
let routeModule = route.module;
|
|
9712
9731
|
let loaderHeaders = context.loaderHeaders[id] || new Headers();
|
|
9713
9732
|
let actionHeaders = context.actionHeaders[id] || new Headers();
|
|
9714
9733
|
let includeErrorHeaders = errorHeaders != null && idx === matches.length - 1;
|
|
9715
9734
|
let includeErrorCookies = includeErrorHeaders && errorHeaders !== loaderHeaders && errorHeaders !== actionHeaders;
|
|
9716
|
-
|
|
9735
|
+
let headersFn = getRouteHeadersFn(match);
|
|
9736
|
+
if (headersFn == null) {
|
|
9717
9737
|
let headers2 = new Headers(parentHeaders);
|
|
9718
9738
|
if (includeErrorCookies) {
|
|
9719
9739
|
prependCookies(errorHeaders, headers2);
|
|
@@ -9723,12 +9743,12 @@ function getDocumentHeaders(build, context) {
|
|
|
9723
9743
|
return headers2;
|
|
9724
9744
|
}
|
|
9725
9745
|
let headers = new Headers(
|
|
9726
|
-
|
|
9746
|
+
typeof headersFn === "function" ? headersFn({
|
|
9727
9747
|
loaderHeaders,
|
|
9728
9748
|
parentHeaders,
|
|
9729
9749
|
actionHeaders,
|
|
9730
9750
|
errorHeaders: includeErrorHeaders ? errorHeaders : void 0
|
|
9731
|
-
}) :
|
|
9751
|
+
}) : headersFn
|
|
9732
9752
|
);
|
|
9733
9753
|
if (includeErrorCookies) {
|
|
9734
9754
|
prependCookies(errorHeaders, headers);
|
|
@@ -9753,6 +9773,7 @@ function prependCookies(parentHeaders, childHeaders) {
|
|
|
9753
9773
|
}
|
|
9754
9774
|
|
|
9755
9775
|
// lib/server-runtime/single-fetch.ts
|
|
9776
|
+
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
9756
9777
|
var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
9757
9778
|
...NO_BODY_STATUS_CODES,
|
|
9758
9779
|
304
|
|
@@ -9760,7 +9781,10 @@ var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
|
9760
9781
|
async function singleFetchAction(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
9761
9782
|
try {
|
|
9762
9783
|
let respond2 = function(context) {
|
|
9763
|
-
let headers = getDocumentHeaders(
|
|
9784
|
+
let headers = getDocumentHeaders(
|
|
9785
|
+
context,
|
|
9786
|
+
(m) => build.routes[m.route.id]?.module.headers
|
|
9787
|
+
);
|
|
9764
9788
|
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
9765
9789
|
return generateSingleFetchResponse(request, build, serverMode, {
|
|
9766
9790
|
result: getSingleFetchRedirect(
|
|
@@ -9835,7 +9859,10 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
|
|
|
9835
9859
|
async function singleFetchLoaders(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
9836
9860
|
try {
|
|
9837
9861
|
let respond2 = function(context) {
|
|
9838
|
-
let headers = getDocumentHeaders(
|
|
9862
|
+
let headers = getDocumentHeaders(
|
|
9863
|
+
context,
|
|
9864
|
+
(m) => build.routes[m.route.id]?.module.headers
|
|
9865
|
+
);
|
|
9839
9866
|
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
9840
9867
|
return generateSingleFetchResponse(request, build, serverMode, {
|
|
9841
9868
|
result: {
|
|
@@ -10091,10 +10118,9 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10091
10118
|
if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
|
|
10092
10119
|
normalizedPath = normalizedPath.slice(0, -1);
|
|
10093
10120
|
}
|
|
10094
|
-
let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
|
|
10095
10121
|
if (!_build.ssr) {
|
|
10096
10122
|
if (_build.prerender.length === 0) {
|
|
10097
|
-
|
|
10123
|
+
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
10098
10124
|
} else if (!_build.prerender.includes(normalizedPath) && !_build.prerender.includes(normalizedPath + "/")) {
|
|
10099
10125
|
if (url.pathname.endsWith(".data")) {
|
|
10100
10126
|
errorHandler(
|
|
@@ -10114,14 +10140,11 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10114
10140
|
statusText: "Not Found"
|
|
10115
10141
|
});
|
|
10116
10142
|
} else {
|
|
10117
|
-
|
|
10143
|
+
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
10118
10144
|
}
|
|
10119
10145
|
}
|
|
10120
10146
|
}
|
|
10121
|
-
let manifestUrl =
|
|
10122
|
-
_build.routeDiscovery.manifestPath,
|
|
10123
|
-
normalizedBasename
|
|
10124
|
-
);
|
|
10147
|
+
let manifestUrl = `${normalizedBasename}/__manifest`.replace(/\/+/g, "/");
|
|
10125
10148
|
if (url.pathname === manifestUrl) {
|
|
10126
10149
|
try {
|
|
10127
10150
|
let res = await handleManifestRequest(_build, routes, url);
|
|
@@ -10131,7 +10154,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10131
10154
|
return new Response("Unknown Server Error", { status: 500 });
|
|
10132
10155
|
}
|
|
10133
10156
|
}
|
|
10134
|
-
let matches = matchServerRoutes(routes,
|
|
10157
|
+
let matches = matchServerRoutes(routes, url.pathname, _build.basename);
|
|
10135
10158
|
if (matches && matches.length > 0) {
|
|
10136
10159
|
Object.assign(params, matches[0].params);
|
|
10137
10160
|
}
|
|
@@ -10186,7 +10209,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10186
10209
|
);
|
|
10187
10210
|
}
|
|
10188
10211
|
}
|
|
10189
|
-
} 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) {
|
|
10190
10213
|
response = await handleResourceRequest(
|
|
10191
10214
|
serverMode,
|
|
10192
10215
|
_build,
|
|
@@ -10211,7 +10234,6 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10211
10234
|
request,
|
|
10212
10235
|
loadContext,
|
|
10213
10236
|
handleError,
|
|
10214
|
-
isSpaMode,
|
|
10215
10237
|
criticalCss
|
|
10216
10238
|
);
|
|
10217
10239
|
}
|
|
@@ -10287,7 +10309,8 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
|
|
|
10287
10309
|
);
|
|
10288
10310
|
return response;
|
|
10289
10311
|
}
|
|
10290
|
-
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");
|
|
10291
10314
|
try {
|
|
10292
10315
|
let response = await staticHandler.query(request, {
|
|
10293
10316
|
requestContext: loadContext,
|
|
@@ -10302,7 +10325,10 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10302
10325
|
if (isResponse(context)) {
|
|
10303
10326
|
return context;
|
|
10304
10327
|
}
|
|
10305
|
-
let headers = getDocumentHeaders(
|
|
10328
|
+
let headers = getDocumentHeaders(
|
|
10329
|
+
context,
|
|
10330
|
+
(m) => build.routes[m.route.id]?.module.headers
|
|
10331
|
+
);
|
|
10306
10332
|
if (SERVER_NO_BODY_STATUS_CODES.has(context.statusCode)) {
|
|
10307
10333
|
return new Response(null, { status: context.statusCode, headers });
|
|
10308
10334
|
}
|
|
@@ -10319,21 +10345,17 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10319
10345
|
actionData: context.actionData,
|
|
10320
10346
|
errors: serializeErrors2(context.errors, serverMode)
|
|
10321
10347
|
};
|
|
10322
|
-
let baseServerHandoff = {
|
|
10323
|
-
basename: build.basename,
|
|
10324
|
-
future: build.future,
|
|
10325
|
-
routeDiscovery: build.routeDiscovery,
|
|
10326
|
-
ssr: build.ssr,
|
|
10327
|
-
isSpaMode: isSpaMode2
|
|
10328
|
-
};
|
|
10329
10348
|
let entryContext = {
|
|
10330
10349
|
manifest: build.assets,
|
|
10331
10350
|
routeModules: createEntryRouteModules(build.routes),
|
|
10332
10351
|
staticHandlerContext: context,
|
|
10333
10352
|
criticalCss,
|
|
10334
10353
|
serverHandoffString: createServerHandoffString({
|
|
10335
|
-
|
|
10336
|
-
criticalCss
|
|
10354
|
+
basename: build.basename,
|
|
10355
|
+
criticalCss,
|
|
10356
|
+
future: build.future,
|
|
10357
|
+
ssr: build.ssr,
|
|
10358
|
+
isSpaMode: isSpaMode2
|
|
10337
10359
|
}),
|
|
10338
10360
|
serverHandoffStream: encodeViaTurboStream(
|
|
10339
10361
|
state,
|
|
@@ -10344,7 +10366,6 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10344
10366
|
renderMeta: {},
|
|
10345
10367
|
future: build.future,
|
|
10346
10368
|
ssr: build.ssr,
|
|
10347
|
-
routeDiscovery: build.routeDiscovery,
|
|
10348
10369
|
isSpaMode: isSpaMode2,
|
|
10349
10370
|
serializeError: (err) => serializeError(err, serverMode)
|
|
10350
10371
|
};
|
|
@@ -10387,7 +10408,12 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10387
10408
|
entryContext = {
|
|
10388
10409
|
...entryContext,
|
|
10389
10410
|
staticHandlerContext: context,
|
|
10390
|
-
serverHandoffString: createServerHandoffString(
|
|
10411
|
+
serverHandoffString: createServerHandoffString({
|
|
10412
|
+
basename: build.basename,
|
|
10413
|
+
future: build.future,
|
|
10414
|
+
ssr: build.ssr,
|
|
10415
|
+
isSpaMode: isSpaMode2
|
|
10416
|
+
}),
|
|
10391
10417
|
serverHandoffStream: encodeViaTurboStream(
|
|
10392
10418
|
state2,
|
|
10393
10419
|
request.signal,
|
|
@@ -10560,7 +10586,7 @@ function createSessionStorage({
|
|
|
10560
10586
|
function warnOnceAboutSigningSessionCookie(cookie) {
|
|
10561
10587
|
warnOnce(
|
|
10562
10588
|
cookie.isSigned,
|
|
10563
|
-
`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.`
|
|
10564
10590
|
);
|
|
10565
10591
|
}
|
|
10566
10592
|
|
|
@@ -10640,6 +10666,680 @@ function href(path, ...args) {
|
|
|
10640
10666
|
}).filter((segment) => segment !== void 0).join("/");
|
|
10641
10667
|
}
|
|
10642
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
|
+
|
|
10643
11343
|
// lib/dom/ssr/errors.ts
|
|
10644
11344
|
function deserializeErrors2(errors) {
|
|
10645
11345
|
if (!errors) return null;
|
|
@@ -10677,32 +11377,6 @@ function deserializeErrors2(errors) {
|
|
|
10677
11377
|
return serialized;
|
|
10678
11378
|
}
|
|
10679
11379
|
|
|
10680
|
-
// lib/dom/ssr/hydration.tsx
|
|
10681
|
-
function getHydrationData(state, routes, getRouteInfo, location, basename, isSpaMode) {
|
|
10682
|
-
let hydrationData = {
|
|
10683
|
-
...state,
|
|
10684
|
-
loaderData: { ...state.loaderData }
|
|
10685
|
-
};
|
|
10686
|
-
let initialMatches = matchRoutes(routes, location, basename);
|
|
10687
|
-
if (initialMatches) {
|
|
10688
|
-
for (let match of initialMatches) {
|
|
10689
|
-
let routeId = match.route.id;
|
|
10690
|
-
let routeInfo = getRouteInfo(routeId);
|
|
10691
|
-
if (shouldHydrateRouteLoader(
|
|
10692
|
-
routeId,
|
|
10693
|
-
routeInfo.clientLoader,
|
|
10694
|
-
routeInfo.hasLoader,
|
|
10695
|
-
isSpaMode
|
|
10696
|
-
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
|
|
10697
|
-
delete hydrationData.loaderData[routeId];
|
|
10698
|
-
} else if (!routeInfo.hasLoader) {
|
|
10699
|
-
hydrationData.loaderData[routeId] = null;
|
|
10700
|
-
}
|
|
10701
|
-
}
|
|
10702
|
-
}
|
|
10703
|
-
return hydrationData;
|
|
10704
|
-
}
|
|
10705
|
-
|
|
10706
11380
|
export {
|
|
10707
11381
|
Action,
|
|
10708
11382
|
createBrowserHistory,
|
|
@@ -10764,6 +11438,9 @@ export {
|
|
|
10764
11438
|
Router,
|
|
10765
11439
|
Routes,
|
|
10766
11440
|
Await,
|
|
11441
|
+
WithRouteComponentProps,
|
|
11442
|
+
WithHydrateFallbackProps,
|
|
11443
|
+
WithErrorBoundaryProps,
|
|
10767
11444
|
createRoutesFromChildren,
|
|
10768
11445
|
createRoutesFromElements,
|
|
10769
11446
|
renderMatches,
|
|
@@ -10818,6 +11495,11 @@ export {
|
|
|
10818
11495
|
createCookieSessionStorage,
|
|
10819
11496
|
createMemorySessionStorage,
|
|
10820
11497
|
href,
|
|
10821
|
-
|
|
10822
|
-
|
|
11498
|
+
getHydrationData,
|
|
11499
|
+
createCallServer,
|
|
11500
|
+
RSCHydratedRouter,
|
|
11501
|
+
routeRSCServerRequest,
|
|
11502
|
+
RSCStaticRouter,
|
|
11503
|
+
getServerStream,
|
|
11504
|
+
deserializeErrors2 as deserializeErrors
|
|
10823
11505
|
};
|