react-router 0.0.0-experimental-e56aa53bc → 0.0.0-experimental-aecfb0db1

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/development/{chunk-RMWJZNG5.mjs → chunk-RXFCVJK2.mjs} +1132 -1142
  3. package/dist/development/dom-export.d.mts +2 -2
  4. package/dist/development/dom-export.d.ts +1 -2
  5. package/dist/development/dom-export.js +34 -6129
  6. package/dist/development/dom-export.mjs +6 -3
  7. package/dist/development/index.d.mts +13 -68
  8. package/dist/development/index.d.ts +1873 -198
  9. package/dist/development/index.js +1132 -1151
  10. package/dist/development/index.mjs +2 -19
  11. package/dist/development/lib/types/route-module.d.mts +1 -2
  12. package/dist/development/lib/types/route-module.d.ts +1 -2
  13. package/dist/development/lib/types/route-module.js +1 -1
  14. package/dist/development/lib/types/route-module.mjs +1 -1
  15. package/dist/development/{fog-of-war-DrUCUQQ-.d.ts → lib-BJBhVBWN.d.mts} +136 -178
  16. package/dist/{production/route-data-BIYebJr3.d.mts → development/route-data-BmDen1H_.d.mts} +12 -12
  17. package/dist/development/{route-data-BIYebJr3.d.mts → route-data-fNWkI-4T.d.ts} +12 -12
  18. package/dist/production/{chunk-BXBFRMFA.mjs → chunk-TLRBG5AD.mjs} +1132 -1142
  19. package/dist/production/dom-export.d.mts +2 -2
  20. package/dist/production/dom-export.d.ts +1 -2
  21. package/dist/production/dom-export.js +34 -6129
  22. package/dist/production/dom-export.mjs +6 -3
  23. package/dist/production/index.d.mts +13 -68
  24. package/dist/production/index.d.ts +1873 -198
  25. package/dist/production/index.js +1132 -1151
  26. package/dist/production/index.mjs +2 -19
  27. package/dist/production/lib/types/route-module.d.mts +1 -2
  28. package/dist/production/lib/types/route-module.d.ts +1 -2
  29. package/dist/production/lib/types/route-module.js +1 -1
  30. package/dist/production/lib/types/route-module.mjs +1 -1
  31. package/dist/production/{fog-of-war-DrUCUQQ-.d.ts → lib-BJBhVBWN.d.mts} +136 -178
  32. package/dist/{development/route-data-BIYebJr3.d.ts → production/route-data-BmDen1H_.d.mts} +12 -12
  33. package/dist/production/{route-data-BIYebJr3.d.ts → route-data-fNWkI-4T.d.ts} +12 -12
  34. package/package.json +6 -35
  35. package/dist/development/data-CQbyyGzl.d.mts +0 -11
  36. package/dist/development/data-CQbyyGzl.d.ts +0 -11
  37. package/dist/development/fog-of-war-C5L_Yd5M.d.mts +0 -1778
  38. package/dist/development/rsc-export.d.mts +0 -1788
  39. package/dist/development/rsc-export.d.ts +0 -1788
  40. package/dist/development/rsc-export.js +0 -2778
  41. package/dist/development/rsc-export.mjs +0 -2743
  42. package/dist/production/data-CQbyyGzl.d.mts +0 -11
  43. package/dist/production/data-CQbyyGzl.d.ts +0 -11
  44. package/dist/production/fog-of-war-C5L_Yd5M.d.mts +0 -1778
  45. package/dist/production/rsc-export.d.mts +0 -1788
  46. package/dist/production/rsc-export.d.ts +0 -1788
  47. package/dist/production/rsc-export.js +0 -2778
  48. package/dist/production/rsc-export.mjs +0 -2743
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-e56aa53bc
2
+ * react-router v0.0.0-experimental-aecfb0db1
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 location2 = createLocation(
48
+ let location = createLocation(
49
49
  entries ? getCurrentLocation().pathname : "/",
50
50
  to,
51
51
  state,
52
52
  key
53
53
  );
54
54
  warning(
55
- location2.pathname.charAt(0) === "/",
55
+ location.pathname.charAt(0) === "/",
56
56
  `relative pathnames are not supported in memory history: ${JSON.stringify(
57
57
  to
58
58
  )}`
59
59
  );
60
- return location2;
60
+ return location;
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(location2, to) {
171
+ function validateHashLocation(location, to) {
172
172
  warning(
173
- location2.pathname.charAt(0) === "/",
173
+ location.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(location2, index) {
203
+ function getHistoryState(location, index) {
204
204
  return {
205
- usr: location2.state,
206
- key: location2.key,
205
+ usr: location.state,
206
+ key: location.key,
207
207
  idx: index
208
208
  };
209
209
  }
210
210
  function createLocation(current, to, state = null, key) {
211
- let location2 = {
211
+ let location = {
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 location2;
223
+ return location;
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 location2 = createLocation(history.location, to, state);
281
- if (validateLocation) validateLocation(location2, to);
280
+ let location = createLocation(history.location, to, state);
281
+ if (validateLocation) validateLocation(location, to);
282
282
  index = getIndex() + 1;
283
- let historyState = getHistoryState(location2, index);
284
- let url = history.createHref(location2);
283
+ let historyState = getHistoryState(location, index);
284
+ let url = history.createHref(location);
285
285
  try {
286
286
  globalHistory.pushState(historyState, "", url);
287
287
  } catch (error) {
@@ -296,25 +296,18 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
296
296
  }
297
297
  function replace2(to, state) {
298
298
  action = "REPLACE" /* Replace */;
299
- let location2 = createLocation(history.location, to, state);
300
- if (validateLocation) validateLocation(location2, to);
299
+ let location = createLocation(history.location, to, state);
300
+ if (validateLocation) validateLocation(location, to);
301
301
  index = getIndex();
302
- let historyState = getHistoryState(location2, index);
303
- let url = history.createHref(location2);
302
+ let historyState = getHistoryState(location, index);
303
+ let url = history.createHref(location);
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
- 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);
310
+ return createBrowserURLImpl(to);
318
311
  }
319
312
  let history = {
320
313
  get action() {
@@ -354,6 +347,19 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
354
347
  };
355
348
  return history;
356
349
  }
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
+ }
357
363
 
358
364
  // lib/router/utils.ts
359
365
  function unstable_createContext(defaultValue) {
@@ -413,7 +419,7 @@ function isUnsupportedLazyRouteFunctionKey(key) {
413
419
  function isIndexRoute(route) {
414
420
  return route.index === true;
415
421
  }
416
- function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}, allowInPlaceMutations = false) {
422
+ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}) {
417
423
  return routes.map((route, index) => {
418
424
  let treePath = [...parentPath, String(index)];
419
425
  let id = typeof route.id === "string" ? route.id : treePath.join("-");
@@ -422,7 +428,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
422
428
  `Cannot specify children on an index route`
423
429
  );
424
430
  invariant(
425
- allowInPlaceMutations || !manifest[id],
431
+ !manifest[id],
426
432
  `Found a route id collision on id "${id}". Route id's must be globally unique within Data Router usages`
427
433
  );
428
434
  if (isIndexRoute(route)) {
@@ -446,8 +452,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
446
452
  route.children,
447
453
  mapRouteProperties2,
448
454
  treePath,
449
- manifest,
450
- allowInPlaceMutations
455
+ manifest
451
456
  );
452
457
  }
453
458
  return pathOrLayoutRoute;
@@ -458,8 +463,8 @@ function matchRoutes(routes, locationArg, basename = "/") {
458
463
  return matchRoutesImpl(routes, locationArg, basename, false);
459
464
  }
460
465
  function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
461
- let location2 = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
462
- let pathname = stripBasename(location2.pathname || "/", basename);
466
+ let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
467
+ let pathname = stripBasename(location.pathname || "/", basename);
463
468
  if (pathname == null) {
464
469
  return null;
465
470
  }
@@ -651,19 +656,19 @@ function generatePath(originalPath, params = {}) {
651
656
  path = path.replace(/\*$/, "/*");
652
657
  }
653
658
  const prefix = path.startsWith("/") ? "/" : "";
654
- const stringify = (p) => p == null ? "" : typeof p === "string" ? p : String(p);
659
+ const stringify2 = (p) => p == null ? "" : typeof p === "string" ? p : String(p);
655
660
  const segments = path.split(/\/+/).map((segment, index, array) => {
656
661
  const isLastSegment = index === array.length - 1;
657
662
  if (isLastSegment && segment === "*") {
658
663
  const star = "*";
659
- return stringify(params[star]);
664
+ return stringify2(params[star]);
660
665
  }
661
666
  const keyMatch = segment.match(/^:([\w-]+)(\??)$/);
662
667
  if (keyMatch) {
663
668
  const [, key, optional] = keyMatch;
664
669
  let param = params[key];
665
670
  invariant(optional === "?" || param != null, `Missing ":${key}" param`);
666
- return stringify(param);
671
+ return stringify2(param);
667
672
  }
668
673
  return segment.replace(/\?$/g, "");
669
674
  }).filter((segment) => !!segment);
@@ -975,53 +980,57 @@ function createRouter(init) {
975
980
  let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
976
981
  let initialMatchesIsFOW = false;
977
982
  let initialErrors = null;
983
+ let initialized;
978
984
  if (initialMatches == null && !init.patchRoutesOnNavigation) {
979
985
  let error = getInternalRouterError(404, {
980
986
  pathname: init.history.location.pathname
981
987
  });
982
988
  let { matches, route } = getShortCircuitMatches(dataRoutes);
989
+ initialized = true;
983
990
  initialMatches = matches;
984
991
  initialErrors = { [route.id]: error };
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;
994
- }
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
992
  } 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
993
+ if (initialMatches && !init.hydrationData) {
994
+ let fogOfWar = checkFogOfWar(
995
+ initialMatches,
996
+ dataRoutes,
997
+ init.history.location.pathname
1019
998
  );
1020
- initialized = initialMatches.slice(0, idx + 1).every((m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors));
1021
- } else {
1022
- initialized = initialMatches.every(
1023
- (m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)
999
+ if (fogOfWar.active) {
1000
+ initialMatches = null;
1001
+ }
1002
+ }
1003
+ if (!initialMatches) {
1004
+ initialized = false;
1005
+ initialMatches = [];
1006
+ let fogOfWar = checkFogOfWar(
1007
+ null,
1008
+ dataRoutes,
1009
+ init.history.location.pathname
1024
1010
  );
1011
+ if (fogOfWar.active && fogOfWar.matches) {
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;
1019
+ } else {
1020
+ let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
1021
+ let errors = init.hydrationData ? init.hydrationData.errors : null;
1022
+ if (errors) {
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
+ }
1025
1034
  }
1026
1035
  }
1027
1036
  let router;
@@ -1063,7 +1072,7 @@ function createRouter(init) {
1063
1072
  let pendingRevalidationDfd = null;
1064
1073
  function initialize() {
1065
1074
  unlistenHistory = init.history.listen(
1066
- ({ action: historyAction, location: location2, delta }) => {
1075
+ ({ action: historyAction, location, delta }) => {
1067
1076
  if (unblockBlockerHistoryUpdate) {
1068
1077
  unblockBlockerHistoryUpdate();
1069
1078
  unblockBlockerHistoryUpdate = void 0;
@@ -1075,7 +1084,7 @@ function createRouter(init) {
1075
1084
  );
1076
1085
  let blockerKey = shouldBlockNavigation({
1077
1086
  currentLocation: state.location,
1078
- nextLocation: location2,
1087
+ nextLocation: location,
1079
1088
  historyAction
1080
1089
  });
1081
1090
  if (blockerKey && delta != null) {
@@ -1085,13 +1094,13 @@ function createRouter(init) {
1085
1094
  init.history.go(delta * -1);
1086
1095
  updateBlocker(blockerKey, {
1087
1096
  state: "blocked",
1088
- location: location2,
1097
+ location,
1089
1098
  proceed() {
1090
1099
  updateBlocker(blockerKey, {
1091
1100
  state: "proceeding",
1092
1101
  proceed: void 0,
1093
1102
  reset: void 0,
1094
- location: location2
1103
+ location
1095
1104
  });
1096
1105
  nextHistoryUpdatePromise.then(() => init.history.go(delta));
1097
1106
  },
@@ -1103,7 +1112,7 @@ function createRouter(init) {
1103
1112
  });
1104
1113
  return;
1105
1114
  }
1106
- return startNavigation(historyAction, location2);
1115
+ return startNavigation(historyAction, location);
1107
1116
  }
1108
1117
  );
1109
1118
  if (isBrowser2) {
@@ -1136,19 +1145,6 @@ function createRouter(init) {
1136
1145
  return () => subscribers.delete(fn);
1137
1146
  }
1138
1147
  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
- }
1152
1148
  state = {
1153
1149
  ...state,
1154
1150
  ...newState
@@ -1179,8 +1175,8 @@ function createRouter(init) {
1179
1175
  unmountedFetchers.forEach((key) => deleteFetcher(key));
1180
1176
  mountedFetchers.forEach((key) => state.fetchers.delete(key));
1181
1177
  }
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;
1178
+ function completeNavigation(location, newState, { flushSync } = {}) {
1179
+ let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && location.state?._isRedirect !== true;
1184
1180
  let actionData;
1185
1181
  if (newState.actionData) {
1186
1182
  if (Object.keys(newState.actionData).length > 0) {
@@ -1204,7 +1200,7 @@ function createRouter(init) {
1204
1200
  blockers = new Map(blockers);
1205
1201
  blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));
1206
1202
  }
1207
- let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location2.state?._isRedirect !== true;
1203
+ let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location.state?._isRedirect !== true;
1208
1204
  if (inFlightDataRoutes) {
1209
1205
  dataRoutes = inFlightDataRoutes;
1210
1206
  inFlightDataRoutes = void 0;
@@ -1212,35 +1208,35 @@ function createRouter(init) {
1212
1208
  if (isUninterruptedRevalidation) {
1213
1209
  } else if (pendingAction === "POP" /* Pop */) {
1214
1210
  } else if (pendingAction === "PUSH" /* Push */) {
1215
- init.history.push(location2, location2.state);
1211
+ init.history.push(location, location.state);
1216
1212
  } else if (pendingAction === "REPLACE" /* Replace */) {
1217
- init.history.replace(location2, location2.state);
1213
+ init.history.replace(location, location.state);
1218
1214
  }
1219
1215
  let viewTransitionOpts;
1220
1216
  if (pendingAction === "POP" /* Pop */) {
1221
1217
  let priorPaths = appliedViewTransitions.get(state.location.pathname);
1222
- if (priorPaths && priorPaths.has(location2.pathname)) {
1218
+ if (priorPaths && priorPaths.has(location.pathname)) {
1223
1219
  viewTransitionOpts = {
1224
1220
  currentLocation: state.location,
1225
- nextLocation: location2
1221
+ nextLocation: location
1226
1222
  };
1227
- } else if (appliedViewTransitions.has(location2.pathname)) {
1223
+ } else if (appliedViewTransitions.has(location.pathname)) {
1228
1224
  viewTransitionOpts = {
1229
- currentLocation: location2,
1225
+ currentLocation: location,
1230
1226
  nextLocation: state.location
1231
1227
  };
1232
1228
  }
1233
1229
  } else if (pendingViewTransitionEnabled) {
1234
1230
  let toPaths = appliedViewTransitions.get(state.location.pathname);
1235
1231
  if (toPaths) {
1236
- toPaths.add(location2.pathname);
1232
+ toPaths.add(location.pathname);
1237
1233
  } else {
1238
- toPaths = /* @__PURE__ */ new Set([location2.pathname]);
1234
+ toPaths = /* @__PURE__ */ new Set([location.pathname]);
1239
1235
  appliedViewTransitions.set(state.location.pathname, toPaths);
1240
1236
  }
1241
1237
  viewTransitionOpts = {
1242
1238
  currentLocation: state.location,
1243
- nextLocation: location2
1239
+ nextLocation: location
1244
1240
  };
1245
1241
  }
1246
1242
  updateState(
@@ -1250,12 +1246,12 @@ function createRouter(init) {
1250
1246
  actionData,
1251
1247
  loaderData,
1252
1248
  historyAction: pendingAction,
1253
- location: location2,
1249
+ location,
1254
1250
  initialized: true,
1255
1251
  navigation: IDLE_NAVIGATION,
1256
1252
  revalidation: "idle",
1257
1253
  restoreScrollPosition: getSavedScrollPosition(
1258
- location2,
1254
+ location,
1259
1255
  newState.matches || state.matches
1260
1256
  ),
1261
1257
  preventScrollReset,
@@ -1372,7 +1368,7 @@ function createRouter(init) {
1372
1368
  );
1373
1369
  return promise;
1374
1370
  }
1375
- async function startNavigation(historyAction, location2, opts) {
1371
+ async function startNavigation(historyAction, location, opts) {
1376
1372
  pendingNavigationController && pendingNavigationController.abort();
1377
1373
  pendingNavigationController = null;
1378
1374
  pendingAction = historyAction;
@@ -1385,22 +1381,22 @@ function createRouter(init) {
1385
1381
  let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
1386
1382
  // `matchRoutes()` has already been called if we're in here via `router.initialize()`
1387
1383
  state.matches
1388
- ) : matchRoutes(routesToUse, location2, basename);
1384
+ ) : matchRoutes(routesToUse, location, basename);
1389
1385
  let flushSync = (opts && opts.flushSync) === true;
1390
- if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location2) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1391
- completeNavigation(location2, { matches }, { flushSync });
1386
+ if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1387
+ completeNavigation(location, { matches }, { flushSync });
1392
1388
  return;
1393
1389
  }
1394
- let fogOfWar = checkFogOfWar(matches, routesToUse, location2.pathname);
1390
+ let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
1395
1391
  if (fogOfWar.active && fogOfWar.matches) {
1396
1392
  matches = fogOfWar.matches;
1397
1393
  }
1398
1394
  if (!matches) {
1399
1395
  let { error, notFoundMatches, route } = handleNavigational404(
1400
- location2.pathname
1396
+ location.pathname
1401
1397
  );
1402
1398
  completeNavigation(
1403
- location2,
1399
+ location,
1404
1400
  {
1405
1401
  matches: notFoundMatches,
1406
1402
  loaderData: {},
@@ -1415,7 +1411,7 @@ function createRouter(init) {
1415
1411
  pendingNavigationController = new AbortController();
1416
1412
  let request = createClientSideRequest(
1417
1413
  init.history,
1418
- location2,
1414
+ location,
1419
1415
  pendingNavigationController.signal,
1420
1416
  opts && opts.submission
1421
1417
  );
@@ -1431,7 +1427,7 @@ function createRouter(init) {
1431
1427
  } else if (opts && opts.submission && isMutationMethod(opts.submission.formMethod)) {
1432
1428
  let actionResult = await handleAction(
1433
1429
  request,
1434
- location2,
1430
+ location,
1435
1431
  opts.submission,
1436
1432
  matches,
1437
1433
  scopedContext,
@@ -1446,7 +1442,7 @@ function createRouter(init) {
1446
1442
  let [routeId, result] = actionResult.pendingActionResult;
1447
1443
  if (isErrorResult(result) && isRouteErrorResponse(result.error) && result.error.status === 404) {
1448
1444
  pendingNavigationController = null;
1449
- completeNavigation(location2, {
1445
+ completeNavigation(location, {
1450
1446
  matches: actionResult.matches,
1451
1447
  loaderData: {},
1452
1448
  errors: {
@@ -1458,7 +1454,7 @@ function createRouter(init) {
1458
1454
  }
1459
1455
  matches = actionResult.matches || matches;
1460
1456
  pendingActionResult = actionResult.pendingActionResult;
1461
- loadingNavigation = getLoadingNavigation(location2, opts.submission);
1457
+ loadingNavigation = getLoadingNavigation(location, opts.submission);
1462
1458
  flushSync = false;
1463
1459
  fogOfWar.active = false;
1464
1460
  request = createClientSideRequest(
@@ -1474,7 +1470,7 @@ function createRouter(init) {
1474
1470
  errors
1475
1471
  } = await handleLoaders(
1476
1472
  request,
1477
- location2,
1473
+ location,
1478
1474
  matches,
1479
1475
  scopedContext,
1480
1476
  fogOfWar.active,
@@ -1490,21 +1486,21 @@ function createRouter(init) {
1490
1486
  return;
1491
1487
  }
1492
1488
  pendingNavigationController = null;
1493
- completeNavigation(location2, {
1489
+ completeNavigation(location, {
1494
1490
  matches: updatedMatches || matches,
1495
1491
  ...getActionDataForCommit(pendingActionResult),
1496
1492
  loaderData,
1497
1493
  errors
1498
1494
  });
1499
1495
  }
1500
- async function handleAction(request, location2, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
1496
+ async function handleAction(request, location, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
1501
1497
  interruptActiveLoads();
1502
- let navigation = getSubmittingNavigation(location2, submission);
1498
+ let navigation = getSubmittingNavigation(location, submission);
1503
1499
  updateState({ navigation }, { flushSync: opts.flushSync === true });
1504
1500
  if (isFogOfWar) {
1505
1501
  let discoverResult = await discoverRoutes(
1506
1502
  matches,
1507
- location2.pathname,
1503
+ location.pathname,
1508
1504
  request.signal
1509
1505
  );
1510
1506
  if (discoverResult.type === "aborted") {
@@ -1523,7 +1519,7 @@ function createRouter(init) {
1523
1519
  };
1524
1520
  } else if (!discoverResult.matches) {
1525
1521
  let { notFoundMatches, error, route } = handleNavigational404(
1526
- location2.pathname
1522
+ location.pathname
1527
1523
  );
1528
1524
  return {
1529
1525
  matches: notFoundMatches,
@@ -1540,13 +1536,13 @@ function createRouter(init) {
1540
1536
  }
1541
1537
  }
1542
1538
  let result;
1543
- let actionMatch = getTargetMatch(matches, location2);
1539
+ let actionMatch = getTargetMatch(matches, location);
1544
1540
  if (!actionMatch.route.action && !actionMatch.route.lazy) {
1545
1541
  result = {
1546
1542
  type: "error" /* error */,
1547
1543
  error: getInternalRouterError(405, {
1548
1544
  method: request.method,
1549
- pathname: location2.pathname,
1545
+ pathname: location.pathname,
1550
1546
  routeId: actionMatch.route.id
1551
1547
  })
1552
1548
  };
@@ -1584,12 +1580,12 @@ function createRouter(init) {
1584
1580
  if (opts && opts.replace != null) {
1585
1581
  replace2 = opts.replace;
1586
1582
  } else {
1587
- let location3 = normalizeRedirectLocation(
1583
+ let location2 = normalizeRedirectLocation(
1588
1584
  result.response.headers.get("Location"),
1589
1585
  new URL(request.url),
1590
1586
  basename
1591
1587
  );
1592
- replace2 = location3 === state.location.pathname + state.location.search;
1588
+ replace2 = location2 === state.location.pathname + state.location.search;
1593
1589
  }
1594
1590
  await startRedirectNavigation(request, result, true, {
1595
1591
  submission,
@@ -1604,7 +1600,11 @@ function createRouter(init) {
1604
1600
  }
1605
1601
  return {
1606
1602
  matches,
1607
- pendingActionResult: [boundaryMatch.route.id, result]
1603
+ pendingActionResult: [
1604
+ boundaryMatch.route.id,
1605
+ result,
1606
+ actionMatch.route.id
1607
+ ]
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, location2, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
1616
- let loadingNavigation = overrideNavigation || getLoadingNavigation(location2, submission);
1615
+ async function handleLoaders(request, location, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
1616
+ let loadingNavigation = overrideNavigation || getLoadingNavigation(location, 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
- location2.pathname,
1634
+ location.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
- location2.pathname
1650
+ location.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
- location2,
1673
+ location,
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
- location2,
1689
+ location,
1690
1690
  {
1691
1691
  matches,
1692
1692
  loaderData: {},
@@ -2046,6 +2046,10 @@ function createRouter(init) {
2046
2046
  fetchReloadIds.delete(key);
2047
2047
  fetchControllers.delete(key);
2048
2048
  revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key));
2049
+ if (state.fetchers.has(key)) {
2050
+ let doneFetcher = getDoneFetcher(actionResult.data);
2051
+ state.fetchers.set(key, doneFetcher);
2052
+ }
2049
2053
  let redirect2 = findRedirect(loaderResults);
2050
2054
  if (redirect2) {
2051
2055
  return startRedirectNavigation(
@@ -2073,10 +2077,6 @@ function createRouter(init) {
2073
2077
  revalidatingFetchers,
2074
2078
  fetcherResults
2075
2079
  );
2076
- if (state.fetchers.has(key)) {
2077
- let doneFetcher = getDoneFetcher(actionResult.data);
2078
- state.fetchers.set(key, doneFetcher);
2079
- }
2080
2080
  abortStaleFetchLoads(loadId);
2081
2081
  if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) {
2082
2082
  invariant(pendingAction, "Expected pending action");
@@ -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 location2 = redirect2.response.headers.get("Location");
2201
- invariant(location2, "Expected a Location header on the redirect Response");
2202
- location2 = normalizeRedirectLocation(
2203
- location2,
2200
+ let location = redirect2.response.headers.get("Location");
2201
+ invariant(location, "Expected a Location header on the redirect Response");
2202
+ location = normalizeRedirectLocation(
2203
+ location,
2204
2204
  new URL(request.url),
2205
2205
  basename
2206
2206
  );
2207
- let redirectLocation = createLocation(state.location, location2, {
2207
+ let redirectLocation = createLocation(state.location, location, {
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(location2)) {
2215
- const url = init.history.createURL(location2);
2214
+ } else if (ABSOLUTE_URL_REGEX.test(location)) {
2215
+ const url = createBrowserURLImpl(location, true);
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(location2);
2222
+ routerWindow.location.replace(location);
2223
2223
  } else {
2224
- routerWindow.location.assign(location2);
2224
+ routerWindow.location.assign(location);
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: location2
2240
+ formAction: location
2241
2241
  },
2242
2242
  // Preserve these flags across redirects
2243
2243
  preventScrollReset: preventScrollReset || pendingPreventScrollReset,
@@ -2279,6 +2279,9 @@ function createRouter(init) {
2279
2279
  });
2280
2280
  return dataResults;
2281
2281
  }
2282
+ if (request.signal.aborted) {
2283
+ return dataResults;
2284
+ }
2282
2285
  for (let [routeId, result] of Object.entries(results)) {
2283
2286
  if (isRedirectDataStrategyResult(result)) {
2284
2287
  let response = result.result;
@@ -2508,25 +2511,25 @@ function createRouter(init) {
2508
2511
  getScrollRestorationKey2 = null;
2509
2512
  };
2510
2513
  }
2511
- function getScrollKey(location2, matches) {
2514
+ function getScrollKey(location, matches) {
2512
2515
  if (getScrollRestorationKey2) {
2513
2516
  let key = getScrollRestorationKey2(
2514
- location2,
2517
+ location,
2515
2518
  matches.map((m) => convertRouteMatchToUiMatch(m, state.loaderData))
2516
2519
  );
2517
- return key || location2.key;
2520
+ return key || location.key;
2518
2521
  }
2519
- return location2.key;
2522
+ return location.key;
2520
2523
  }
2521
- function saveScrollPosition(location2, matches) {
2524
+ function saveScrollPosition(location, matches) {
2522
2525
  if (savedScrollPositions2 && getScrollPosition) {
2523
- let key = getScrollKey(location2, matches);
2526
+ let key = getScrollKey(location, matches);
2524
2527
  savedScrollPositions2[key] = getScrollPosition();
2525
2528
  }
2526
2529
  }
2527
- function getSavedScrollPosition(location2, matches) {
2530
+ function getSavedScrollPosition(location, matches) {
2528
2531
  if (savedScrollPositions2) {
2529
- let key = getScrollKey(location2, matches);
2532
+ let key = getScrollKey(location, matches);
2530
2533
  let y = savedScrollPositions2[key];
2531
2534
  if (typeof y === "number") {
2532
2535
  return y;
@@ -2580,8 +2583,7 @@ function createRouter(init) {
2580
2583
  children,
2581
2584
  routesToUse,
2582
2585
  localManifest,
2583
- mapRouteProperties2,
2584
- false
2586
+ mapRouteProperties2
2585
2587
  );
2586
2588
  }
2587
2589
  });
@@ -2622,7 +2624,7 @@ function createRouter(init) {
2622
2624
  manifest
2623
2625
  );
2624
2626
  }
2625
- function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
2627
+ function patchRoutes(routeId, children) {
2626
2628
  let isNonHMR = inFlightDataRoutes == null;
2627
2629
  let routesToUse = inFlightDataRoutes || dataRoutes;
2628
2630
  patchRoutesImpl(
@@ -2630,8 +2632,7 @@ function createRouter(init) {
2630
2632
  children,
2631
2633
  routesToUse,
2632
2634
  manifest,
2633
- mapRouteProperties2,
2634
- unstable_allowElementMutations
2635
+ mapRouteProperties2
2635
2636
  );
2636
2637
  if (isNonHMR) {
2637
2638
  dataRoutes = [...dataRoutes];
@@ -2673,10 +2674,7 @@ function createRouter(init) {
2673
2674
  _internalFetchControllers: fetchControllers,
2674
2675
  // TODO: Remove setRoutes, it's temporary to avoid dealing with
2675
2676
  // updating the tree while validating the update algorithm.
2676
- _internalSetRoutes,
2677
- _internalSetStateDoNotUseOrYouWillBreakYourApp(newState) {
2678
- updateState(newState);
2679
- }
2677
+ _internalSetRoutes
2680
2678
  };
2681
2679
  return router;
2682
2680
  }
@@ -2704,15 +2702,15 @@ function createStaticHandler(routes, opts) {
2704
2702
  } = {}) {
2705
2703
  let url = new URL(request.url);
2706
2704
  let method = request.method;
2707
- let location2 = createLocation("", createPath(url), null, "default");
2708
- let matches = matchRoutes(dataRoutes, location2, basename);
2705
+ let location = createLocation("", createPath(url), null, "default");
2706
+ let matches = matchRoutes(dataRoutes, location, basename);
2709
2707
  requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
2710
2708
  if (!isValidMethod(method) && method !== "HEAD") {
2711
2709
  let error = getInternalRouterError(405, { method });
2712
2710
  let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
2713
2711
  let staticContext = {
2714
2712
  basename,
2715
- location: location2,
2713
+ location,
2716
2714
  matches: methodNotAllowedMatches,
2717
2715
  loaderData: {},
2718
2716
  actionData: null,
@@ -2725,11 +2723,11 @@ function createStaticHandler(routes, opts) {
2725
2723
  };
2726
2724
  return respond ? respond(staticContext) : staticContext;
2727
2725
  } else if (!matches) {
2728
- let error = getInternalRouterError(404, { pathname: location2.pathname });
2726
+ let error = getInternalRouterError(404, { pathname: location.pathname });
2729
2727
  let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
2730
2728
  let staticContext = {
2731
2729
  basename,
2732
- location: location2,
2730
+ location,
2733
2731
  matches: notFoundMatches,
2734
2732
  loaderData: {},
2735
2733
  actionData: null,
@@ -2769,7 +2767,7 @@ function createStaticHandler(routes, opts) {
2769
2767
  async () => {
2770
2768
  let result2 = await queryImpl(
2771
2769
  request,
2772
- location2,
2770
+ location,
2773
2771
  matches,
2774
2772
  requestContext,
2775
2773
  dataStrategy || null,
@@ -2781,7 +2779,7 @@ function createStaticHandler(routes, opts) {
2781
2779
  if (isResponse(result2)) {
2782
2780
  return result2;
2783
2781
  }
2784
- renderedStaticContext = { location: location2, basename, ...result2 };
2782
+ renderedStaticContext = { location, basename, ...result2 };
2785
2783
  let res = await respond(renderedStaticContext);
2786
2784
  return res;
2787
2785
  },
@@ -2806,7 +2804,7 @@ function createStaticHandler(routes, opts) {
2806
2804
  let boundary = loaderIdx >= 0 ? findNearestBoundary(matches, matches[loaderIdx].route.id) : findNearestBoundary(matches);
2807
2805
  return respond({
2808
2806
  matches,
2809
- location: location2,
2807
+ location,
2810
2808
  basename,
2811
2809
  loaderData: {},
2812
2810
  actionData: null,
@@ -2831,7 +2829,7 @@ function createStaticHandler(routes, opts) {
2831
2829
  }
2832
2830
  let result = await queryImpl(
2833
2831
  request,
2834
- location2,
2832
+ location,
2835
2833
  matches,
2836
2834
  requestContext,
2837
2835
  dataStrategy || null,
@@ -2843,7 +2841,7 @@ function createStaticHandler(routes, opts) {
2843
2841
  if (isResponse(result)) {
2844
2842
  return result;
2845
2843
  }
2846
- return { location: location2, basename, ...result };
2844
+ return { location, basename, ...result };
2847
2845
  }
2848
2846
  async function queryRoute(request, {
2849
2847
  routeId,
@@ -2853,22 +2851,22 @@ function createStaticHandler(routes, opts) {
2853
2851
  } = {}) {
2854
2852
  let url = new URL(request.url);
2855
2853
  let method = request.method;
2856
- let location2 = createLocation("", createPath(url), null, "default");
2857
- let matches = matchRoutes(dataRoutes, location2, basename);
2854
+ let location = createLocation("", createPath(url), null, "default");
2855
+ let matches = matchRoutes(dataRoutes, location, basename);
2858
2856
  requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
2859
2857
  if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
2860
2858
  throw getInternalRouterError(405, { method });
2861
2859
  } else if (!matches) {
2862
- throw getInternalRouterError(404, { pathname: location2.pathname });
2860
+ throw getInternalRouterError(404, { pathname: location.pathname });
2863
2861
  }
2864
- let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location2);
2862
+ let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location);
2865
2863
  if (routeId && !match) {
2866
2864
  throw getInternalRouterError(403, {
2867
- pathname: location2.pathname,
2865
+ pathname: location.pathname,
2868
2866
  routeId
2869
2867
  });
2870
2868
  } else if (!match) {
2871
- throw getInternalRouterError(404, { pathname: location2.pathname });
2869
+ throw getInternalRouterError(404, { pathname: location.pathname });
2872
2870
  }
2873
2871
  if (respond && matches.some(
2874
2872
  (m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
@@ -2891,7 +2889,7 @@ function createStaticHandler(routes, opts) {
2891
2889
  async () => {
2892
2890
  let result2 = await queryImpl(
2893
2891
  request,
2894
- location2,
2892
+ location,
2895
2893
  matches,
2896
2894
  requestContext,
2897
2895
  dataStrategy || null,
@@ -2924,7 +2922,7 @@ function createStaticHandler(routes, opts) {
2924
2922
  }
2925
2923
  let result = await queryImpl(
2926
2924
  request,
2927
- location2,
2925
+ location,
2928
2926
  matches,
2929
2927
  requestContext,
2930
2928
  dataStrategy || null,
@@ -2948,7 +2946,7 @@ function createStaticHandler(routes, opts) {
2948
2946
  }
2949
2947
  return void 0;
2950
2948
  }
2951
- async function queryImpl(request, location2, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
2949
+ async function queryImpl(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
2952
2950
  invariant(
2953
2951
  request.signal,
2954
2952
  "query()/queryRoute() requests must contain an AbortController signal"
@@ -2958,7 +2956,7 @@ function createStaticHandler(routes, opts) {
2958
2956
  let result2 = await submit(
2959
2957
  request,
2960
2958
  matches,
2961
- routeMatch || getTargetMatch(matches, location2),
2959
+ routeMatch || getTargetMatch(matches, location),
2962
2960
  requestContext,
2963
2961
  dataStrategy,
2964
2962
  skipLoaderErrorBubbling,
@@ -3274,7 +3272,7 @@ function throwStaticHandlerAbortedError(request, isRouteRequest) {
3274
3272
  function isSubmissionNavigation(opts) {
3275
3273
  return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0);
3276
3274
  }
3277
- function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
3275
+ function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
3278
3276
  let contextualMatches;
3279
3277
  let activeRouteMatch;
3280
3278
  if (fromRouteId) {
@@ -3293,12 +3291,12 @@ function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
3293
3291
  let path = resolveTo(
3294
3292
  to ? to : ".",
3295
3293
  getResolveToMatches(contextualMatches),
3296
- stripBasename(location2.pathname, basename) || location2.pathname,
3294
+ stripBasename(location.pathname, basename) || location.pathname,
3297
3295
  relative === "path"
3298
3296
  );
3299
3297
  if (to == null) {
3300
- path.search = location2.search;
3301
- path.hash = location2.hash;
3298
+ path.search = location.search;
3299
+ path.hash = location.hash;
3302
3300
  }
3303
3301
  if ((to == null || to === "" || to === ".") && activeRouteMatch) {
3304
3302
  let nakedIndex = hasNakedIndexQuery(path.search);
@@ -3425,10 +3423,10 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
3425
3423
  parsedPath.search = `?${searchParams}`;
3426
3424
  return { path: createPath(parsedPath), submission };
3427
3425
  }
3428
- function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location2, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
3426
+ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
3429
3427
  let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
3430
3428
  let currentUrl = history.createURL(state.location);
3431
- let nextUrl = history.createURL(location2);
3429
+ let nextUrl = history.createURL(location);
3432
3430
  let maxIdx;
3433
3431
  if (initialHydration && state.errors) {
3434
3432
  let boundaryId = Object.keys(state.errors)[0];
@@ -3590,7 +3588,7 @@ function shouldLoadRouteOnHydration(route, loaderData, errors) {
3590
3588
  if (!route.loader) {
3591
3589
  return false;
3592
3590
  }
3593
- let hasData = loaderData != null && loaderData[route.id] !== void 0;
3591
+ let hasData = loaderData != null && route.id in loaderData;
3594
3592
  let hasError = errors != null && errors[route.id] !== void 0;
3595
3593
  if (!hasData && hasError) {
3596
3594
  return false;
@@ -3627,7 +3625,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
3627
3625
  }
3628
3626
  return arg.defaultShouldRevalidate;
3629
3627
  }
3630
- function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
3628
+ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2) {
3631
3629
  let childrenToPatch;
3632
3630
  if (routeId) {
3633
3631
  let route = manifest[routeId];
@@ -3642,47 +3640,18 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
3642
3640
  } else {
3643
3641
  childrenToPatch = routesToUse;
3644
3642
  }
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
- }
3643
+ let uniqueChildren = children.filter(
3644
+ (newRoute) => !childrenToPatch.some(
3645
+ (existingRoute) => isSameRoute(newRoute, existingRoute)
3646
+ )
3647
+ );
3648
+ let newRoutes = convertRoutesToDataRoutes(
3649
+ uniqueChildren,
3650
+ mapRouteProperties2,
3651
+ [routeId || "_", "patch", String(childrenToPatch?.length || "0")],
3652
+ manifest
3653
+ );
3654
+ childrenToPatch.push(...newRoutes);
3686
3655
  }
3687
3656
  function isSameRoute(newRoute, existingRoute) {
3688
3657
  if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
@@ -4031,7 +4000,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, laz
4031
4000
  return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
4032
4001
  },
4033
4002
  resolve(handlerOverride) {
4034
- if (isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (match.route.lazy || match.route.loader)) {
4003
+ if (isUsingNewApi || shouldLoad || handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
4035
4004
  return callLoaderOrAction({
4036
4005
  request,
4037
4006
  match,
@@ -4291,39 +4260,39 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
4291
4260
  return { type: "data" /* data */, data: result };
4292
4261
  }
4293
4262
  function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename) {
4294
- let location2 = response.headers.get("Location");
4263
+ let location = response.headers.get("Location");
4295
4264
  invariant(
4296
- location2,
4265
+ location,
4297
4266
  "Redirects returned/thrown from loaders/actions must have a Location header"
4298
4267
  );
4299
- if (!ABSOLUTE_URL_REGEX.test(location2)) {
4268
+ if (!ABSOLUTE_URL_REGEX.test(location)) {
4300
4269
  let trimmedMatches = matches.slice(
4301
4270
  0,
4302
4271
  matches.findIndex((m) => m.route.id === routeId) + 1
4303
4272
  );
4304
- location2 = normalizeTo(
4273
+ location = normalizeTo(
4305
4274
  new URL(request.url),
4306
4275
  trimmedMatches,
4307
4276
  basename,
4308
- location2
4277
+ location
4309
4278
  );
4310
- response.headers.set("Location", location2);
4279
+ response.headers.set("Location", location);
4311
4280
  }
4312
4281
  return response;
4313
4282
  }
4314
- function normalizeRedirectLocation(location2, currentUrl, basename) {
4315
- if (ABSOLUTE_URL_REGEX.test(location2)) {
4316
- let normalizedLocation = location2;
4283
+ function normalizeRedirectLocation(location, currentUrl, basename) {
4284
+ if (ABSOLUTE_URL_REGEX.test(location)) {
4285
+ let normalizedLocation = location;
4317
4286
  let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
4318
4287
  let isSameBasename = stripBasename(url.pathname, basename) != null;
4319
4288
  if (url.origin === currentUrl.origin && isSameBasename) {
4320
4289
  return url.pathname + url.search + url.hash;
4321
4290
  }
4322
4291
  }
4323
- return location2;
4292
+ return location;
4324
4293
  }
4325
- function createClientSideRequest(history, location2, signal, submission) {
4326
- let url = history.createURL(stripHashFromPath(location2)).toString();
4294
+ function createClientSideRequest(history, location, signal, submission) {
4295
+ let url = history.createURL(stripHashFromPath(location)).toString();
4327
4296
  let init = { signal };
4328
4297
  if (submission && isMutationMethod(submission.formMethod)) {
4329
4298
  let { formMethod, formEncType } = submission;
@@ -4409,7 +4378,9 @@ function processRouteLoaderData(matches, results, pendingActionResult, isStaticH
4409
4378
  });
4410
4379
  if (pendingError !== void 0 && pendingActionResult) {
4411
4380
  errors = { [pendingActionResult[0]]: pendingError };
4412
- loaderData[pendingActionResult[0]] = void 0;
4381
+ if (pendingActionResult[2]) {
4382
+ loaderData[pendingActionResult[2]] = void 0;
4383
+ }
4413
4384
  }
4414
4385
  return {
4415
4386
  loaderData,
@@ -4593,8 +4564,8 @@ function isMutationMethod(method) {
4593
4564
  function hasNakedIndexQuery(search) {
4594
4565
  return new URLSearchParams(search).getAll("index").some((v) => v === "");
4595
4566
  }
4596
- function getTargetMatch(matches, location2) {
4597
- let search = typeof location2 === "string" ? parsePath(location2).search : location2.search;
4567
+ function getTargetMatch(matches, location) {
4568
+ let search = typeof location === "string" ? parsePath(location).search : location.search;
4598
4569
  if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
4599
4570
  return matches[matches.length - 1];
4600
4571
  }
@@ -4635,11 +4606,11 @@ function getSubmissionFromNavigation(navigation) {
4635
4606
  };
4636
4607
  }
4637
4608
  }
4638
- function getLoadingNavigation(location2, submission) {
4609
+ function getLoadingNavigation(location, submission) {
4639
4610
  if (submission) {
4640
4611
  let navigation = {
4641
4612
  state: "loading",
4642
- location: location2,
4613
+ location,
4643
4614
  formMethod: submission.formMethod,
4644
4615
  formAction: submission.formAction,
4645
4616
  formEncType: submission.formEncType,
@@ -4651,7 +4622,7 @@ function getLoadingNavigation(location2, submission) {
4651
4622
  } else {
4652
4623
  let navigation = {
4653
4624
  state: "loading",
4654
- location: location2,
4625
+ location,
4655
4626
  formMethod: void 0,
4656
4627
  formAction: void 0,
4657
4628
  formEncType: void 0,
@@ -4662,10 +4633,10 @@ function getLoadingNavigation(location2, submission) {
4662
4633
  return navigation;
4663
4634
  }
4664
4635
  }
4665
- function getSubmittingNavigation(location2, submission) {
4636
+ function getSubmittingNavigation(location, submission) {
4666
4637
  let navigation = {
4667
4638
  state: "submitting",
4668
- location: location2,
4639
+ location,
4669
4640
  formMethod: submission.formMethod,
4670
4641
  formAction: submission.formAction,
4671
4642
  formEncType: submission.formEncType,
@@ -4826,10 +4797,10 @@ var RouteContext = React.createContext({
4826
4797
  RouteContext.displayName = "Route";
4827
4798
  var RouteErrorContext = React.createContext(null);
4828
4799
  RouteErrorContext.displayName = "RouteError";
4800
+ var ENABLE_DEV_WARNINGS = true;
4829
4801
 
4830
4802
  // lib/hooks.tsx
4831
4803
  import * as React2 from "react";
4832
- var ENABLE_DEV_WARNINGS = true;
4833
4804
  function useHref(to, { relative } = {}) {
4834
4805
  invariant(
4835
4806
  useInRouterContext(),
@@ -4837,13 +4808,13 @@ function useHref(to, { relative } = {}) {
4837
4808
  // router loaded. We can help them understand how to avoid that.
4838
4809
  `useHref() may be used only in the context of a <Router> component.`
4839
4810
  );
4840
- let { basename, navigator: navigator2 } = React2.useContext(NavigationContext);
4811
+ let { basename, navigator } = React2.useContext(NavigationContext);
4841
4812
  let { hash, pathname, search } = useResolvedPath(to, { relative });
4842
4813
  let joinedPathname = pathname;
4843
4814
  if (basename !== "/") {
4844
4815
  joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
4845
4816
  }
4846
- return navigator2.createHref({ pathname: joinedPathname, search, hash });
4817
+ return navigator.createHref({ pathname: joinedPathname, search, hash });
4847
4818
  }
4848
4819
  function useInRouterContext() {
4849
4820
  return React2.useContext(LocationContext) != null;
@@ -4892,7 +4863,7 @@ function useNavigateUnstable() {
4892
4863
  `useNavigate() may be used only in the context of a <Router> component.`
4893
4864
  );
4894
4865
  let dataRouterContext = React2.useContext(DataRouterContext);
4895
- let { basename, navigator: navigator2 } = React2.useContext(NavigationContext);
4866
+ let { basename, navigator } = React2.useContext(NavigationContext);
4896
4867
  let { matches } = React2.useContext(RouteContext);
4897
4868
  let { pathname: locationPathname } = useLocation();
4898
4869
  let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
@@ -4905,7 +4876,7 @@ function useNavigateUnstable() {
4905
4876
  warning(activeRef.current, navigateEffectWarning);
4906
4877
  if (!activeRef.current) return;
4907
4878
  if (typeof to === "number") {
4908
- navigator2.go(to);
4879
+ navigator.go(to);
4909
4880
  return;
4910
4881
  }
4911
4882
  let path = resolveTo(
@@ -4917,7 +4888,7 @@ function useNavigateUnstable() {
4917
4888
  if (dataRouterContext == null && basename !== "/") {
4918
4889
  path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
4919
4890
  }
4920
- (!!options.replace ? navigator2.replace : navigator2.push)(
4891
+ (!!options.replace ? navigator.replace : navigator.push)(
4921
4892
  path,
4922
4893
  options.state,
4923
4894
  options
@@ -4925,7 +4896,7 @@ function useNavigateUnstable() {
4925
4896
  },
4926
4897
  [
4927
4898
  basename,
4928
- navigator2,
4899
+ navigator,
4929
4900
  routePathnamesJson,
4930
4901
  locationPathname,
4931
4902
  dataRouterContext
@@ -4973,7 +4944,7 @@ function useRoutesImpl(routes, locationArg, dataRouterState, future) {
4973
4944
  // router loaded. We can help them understand how to avoid that.
4974
4945
  `useRoutes() may be used only in the context of a <Router> component.`
4975
4946
  );
4976
- let { navigator: navigator2, static: isStatic } = React2.useContext(NavigationContext);
4947
+ let { navigator, static: isStatic } = React2.useContext(NavigationContext);
4977
4948
  let { matches: parentMatches } = React2.useContext(RouteContext);
4978
4949
  let routeMatch = parentMatches[parentMatches.length - 1];
4979
4950
  let parentParams = routeMatch ? routeMatch.params : {};
@@ -4991,18 +4962,18 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
4991
4962
  );
4992
4963
  }
4993
4964
  let locationFromContext = useLocation();
4994
- let location2;
4965
+ let location;
4995
4966
  if (locationArg) {
4996
4967
  let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
4997
4968
  invariant(
4998
4969
  parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase),
4999
4970
  `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.`
5000
4971
  );
5001
- location2 = parsedLocationArg;
4972
+ location = parsedLocationArg;
5002
4973
  } else {
5003
- location2 = locationFromContext;
4974
+ location = locationFromContext;
5004
4975
  }
5005
- let pathname = location2.pathname || "/";
4976
+ let pathname = location.pathname || "/";
5006
4977
  let remainingPathname = pathname;
5007
4978
  if (parentPathnameBase !== "/") {
5008
4979
  let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
@@ -5013,11 +4984,11 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5013
4984
  if (ENABLE_DEV_WARNINGS) {
5014
4985
  warning(
5015
4986
  parentRoute || matches != null,
5016
- `No routes matched location "${location2.pathname}${location2.search}${location2.hash}" `
4987
+ `No routes matched location "${location.pathname}${location.search}${location.hash}" `
5017
4988
  );
5018
4989
  warning(
5019
4990
  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,
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.`
4991
+ `Matched leaf route at location "${location.pathname}${location.search}${location.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.`
5021
4992
  );
5022
4993
  }
5023
4994
  let renderedMatches = _renderMatches(
@@ -5027,12 +4998,12 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5027
4998
  pathname: joinPaths([
5028
4999
  parentPathnameBase,
5029
5000
  // Re-encode pathnames that were decoded inside matchRoutes
5030
- navigator2.encodeLocation ? navigator2.encodeLocation(match.pathname).pathname : match.pathname
5001
+ navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname
5031
5002
  ]),
5032
5003
  pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
5033
5004
  parentPathnameBase,
5034
5005
  // Re-encode pathnames that were decoded inside matchRoutes
5035
- navigator2.encodeLocation ? navigator2.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
5006
+ navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
5036
5007
  ])
5037
5008
  })
5038
5009
  ),
@@ -5051,7 +5022,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5051
5022
  hash: "",
5052
5023
  state: null,
5053
5024
  key: "default",
5054
- ...location2
5025
+ ...location
5055
5026
  },
5056
5027
  navigationType: "POP" /* Pop */
5057
5028
  }
@@ -5411,7 +5382,6 @@ function warnOnce(condition, message) {
5411
5382
  }
5412
5383
 
5413
5384
  // lib/components.tsx
5414
- var ENABLE_DEV_WARNINGS2 = true;
5415
5385
  function mapRouteProperties(route) {
5416
5386
  let updates = {
5417
5387
  // Note: this check also occurs in createRoutesFromChildren so update
@@ -5419,7 +5389,7 @@ function mapRouteProperties(route) {
5419
5389
  hasErrorBoundary: route.hasErrorBoundary || route.ErrorBoundary != null || route.errorElement != null
5420
5390
  };
5421
5391
  if (route.Component) {
5422
- if (ENABLE_DEV_WARNINGS2) {
5392
+ if (ENABLE_DEV_WARNINGS) {
5423
5393
  if (route.element) {
5424
5394
  warning(
5425
5395
  false,
@@ -5433,7 +5403,7 @@ function mapRouteProperties(route) {
5433
5403
  });
5434
5404
  }
5435
5405
  if (route.HydrateFallback) {
5436
- if (ENABLE_DEV_WARNINGS2) {
5406
+ if (ENABLE_DEV_WARNINGS) {
5437
5407
  if (route.hydrateFallbackElement) {
5438
5408
  warning(
5439
5409
  false,
@@ -5447,7 +5417,7 @@ function mapRouteProperties(route) {
5447
5417
  });
5448
5418
  }
5449
5419
  if (route.ErrorBoundary) {
5450
- if (ENABLE_DEV_WARNINGS2) {
5420
+ if (ENABLE_DEV_WARNINGS) {
5451
5421
  if (route.errorElement) {
5452
5422
  warning(
5453
5423
  false,
@@ -5532,11 +5502,25 @@ function RouterProvider({
5532
5502
  viewTransitionOpts == null || isViewTransitionAvailable,
5533
5503
  "You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."
5534
5504
  );
5505
+ const resetTransition = () => {
5506
+ setRenderDfd(void 0);
5507
+ setTransition(void 0);
5508
+ setPendingState(void 0);
5509
+ setVtContext({ isTransitioning: false });
5510
+ };
5535
5511
  if (!viewTransitionOpts || !isViewTransitionAvailable) {
5512
+ renderDfd?.resolve();
5513
+ transition?.skipTransition();
5536
5514
  if (reactDomFlushSyncImpl && flushSync) {
5537
- reactDomFlushSyncImpl(() => setStateImpl(newState));
5515
+ reactDomFlushSyncImpl(() => {
5516
+ setStateImpl(newState);
5517
+ resetTransition();
5518
+ });
5538
5519
  } else {
5539
- React3.startTransition(() => setStateImpl(newState));
5520
+ React3.startTransition(() => {
5521
+ setStateImpl(newState);
5522
+ resetTransition();
5523
+ });
5540
5524
  }
5541
5525
  return;
5542
5526
  }
@@ -5557,12 +5541,7 @@ function RouterProvider({
5557
5541
  reactDomFlushSyncImpl(() => setStateImpl(newState));
5558
5542
  });
5559
5543
  t.finished.finally(() => {
5560
- reactDomFlushSyncImpl(() => {
5561
- setRenderDfd(void 0);
5562
- setTransition(void 0);
5563
- setPendingState(void 0);
5564
- setVtContext({ isTransitioning: false });
5565
- });
5544
+ reactDomFlushSyncImpl(() => resetTransition());
5566
5545
  });
5567
5546
  reactDomFlushSyncImpl(() => setTransition(t));
5568
5547
  return;
@@ -5627,7 +5606,7 @@ function RouterProvider({
5627
5606
  setInterruption(void 0);
5628
5607
  }
5629
5608
  }, [vtContext.isTransitioning, interruption]);
5630
- let navigator2 = React3.useMemo(() => {
5609
+ let navigator = React3.useMemo(() => {
5631
5610
  return {
5632
5611
  createHref: router.createHref,
5633
5612
  encodeLocation: router.encodeLocation,
@@ -5647,11 +5626,11 @@ function RouterProvider({
5647
5626
  let dataRouterContext = React3.useMemo(
5648
5627
  () => ({
5649
5628
  router,
5650
- navigator: navigator2,
5629
+ navigator,
5651
5630
  static: false,
5652
5631
  basename
5653
5632
  }),
5654
- [router, navigator2, basename]
5633
+ [router, navigator, basename]
5655
5634
  );
5656
5635
  return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React3.createElement(DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React3.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React3.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React3.createElement(
5657
5636
  Router,
@@ -5659,7 +5638,7 @@ function RouterProvider({
5659
5638
  basename,
5660
5639
  location: state.location,
5661
5640
  navigationType: state.historyAction,
5662
- navigator: navigator2
5641
+ navigator
5663
5642
  },
5664
5643
  /* @__PURE__ */ React3.createElement(
5665
5644
  MemoizedDataRoutes,
@@ -5762,7 +5741,7 @@ function Router({
5762
5741
  children = null,
5763
5742
  location: locationProp,
5764
5743
  navigationType = "POP" /* Pop */,
5765
- navigator: navigator2,
5744
+ navigator,
5766
5745
  static: staticProp = false
5767
5746
  }) {
5768
5747
  invariant(
@@ -5773,11 +5752,11 @@ function Router({
5773
5752
  let navigationContext = React3.useMemo(
5774
5753
  () => ({
5775
5754
  basename,
5776
- navigator: navigator2,
5755
+ navigator,
5777
5756
  static: staticProp,
5778
5757
  future: {}
5779
5758
  }),
5780
- [basename, navigator2, staticProp]
5759
+ [basename, navigator, staticProp]
5781
5760
  );
5782
5761
  if (typeof locationProp === "string") {
5783
5762
  locationProp = parsePath(locationProp);
@@ -5816,9 +5795,9 @@ function Router({
5816
5795
  }
5817
5796
  function Routes({
5818
5797
  children,
5819
- location: location2
5798
+ location
5820
5799
  }) {
5821
- return useRoutes(createRoutesFromChildren(children), location2);
5800
+ return useRoutes(createRoutesFromChildren(children), location);
5822
5801
  }
5823
5802
  function Await({
5824
5803
  children,
@@ -5888,38 +5867,6 @@ function ResolveAwait({
5888
5867
  let toRender = typeof children === "function" ? children(data2) : children;
5889
5868
  return /* @__PURE__ */ React3.createElement(React3.Fragment, null, toRender);
5890
5869
  }
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
- }
5923
5870
  function createRoutesFromChildren(children, parentPath = []) {
5924
5871
  let routes = [];
5925
5872
  React3.Children.forEach(children, (element, index) => {
@@ -6242,7 +6189,7 @@ async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
6242
6189
  )
6243
6190
  );
6244
6191
  }
6245
- function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location2, mode) {
6192
+ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
6246
6193
  let isNew = (match, index) => {
6247
6194
  if (!currentMatches[index]) return true;
6248
6195
  return match.route.id !== currentMatches[index].route.id;
@@ -6272,7 +6219,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
6272
6219
  if (match.route.shouldRevalidate) {
6273
6220
  let routeChoice = match.route.shouldRevalidate({
6274
6221
  currentUrl: new URL(
6275
- location2.pathname + location2.search + location2.hash,
6222
+ location.pathname + location.search + location.hash,
6276
6223
  window.origin
6277
6224
  ),
6278
6225
  currentParams: currentMatches[0]?.params || {},
@@ -6367,7 +6314,669 @@ function createHtml(html) {
6367
6314
 
6368
6315
  // lib/dom/ssr/single-fetch.tsx
6369
6316
  import * as React4 from "react";
6370
- import { decode } from "turbo-stream";
6317
+
6318
+ // vendor/turbo-stream-v2/utils.ts
6319
+ var HOLE = -1;
6320
+ var NAN = -2;
6321
+ var NEGATIVE_INFINITY = -3;
6322
+ var NEGATIVE_ZERO = -4;
6323
+ var NULL = -5;
6324
+ var POSITIVE_INFINITY = -6;
6325
+ var UNDEFINED = -7;
6326
+ var TYPE_BIGINT = "B";
6327
+ var TYPE_DATE = "D";
6328
+ var TYPE_ERROR = "E";
6329
+ var TYPE_MAP = "M";
6330
+ var TYPE_NULL_OBJECT = "N";
6331
+ var TYPE_PROMISE = "P";
6332
+ var TYPE_REGEXP = "R";
6333
+ var TYPE_SET = "S";
6334
+ var TYPE_SYMBOL = "Y";
6335
+ var TYPE_URL = "U";
6336
+ var TYPE_PREVIOUS_RESOLVED = "Z";
6337
+ var Deferred2 = class {
6338
+ constructor() {
6339
+ this.promise = new Promise((resolve, reject) => {
6340
+ this.resolve = resolve;
6341
+ this.reject = reject;
6342
+ });
6343
+ }
6344
+ };
6345
+ function createLineSplittingTransform() {
6346
+ const decoder = new TextDecoder();
6347
+ let leftover = "";
6348
+ return new TransformStream({
6349
+ transform(chunk, controller) {
6350
+ const str = decoder.decode(chunk, { stream: true });
6351
+ const parts = (leftover + str).split("\n");
6352
+ leftover = parts.pop() || "";
6353
+ for (const part of parts) {
6354
+ controller.enqueue(part);
6355
+ }
6356
+ },
6357
+ flush(controller) {
6358
+ if (leftover) {
6359
+ controller.enqueue(leftover);
6360
+ }
6361
+ }
6362
+ });
6363
+ }
6364
+
6365
+ // vendor/turbo-stream-v2/flatten.ts
6366
+ function flatten(input) {
6367
+ const { indices } = this;
6368
+ const existing = indices.get(input);
6369
+ if (existing) return [existing];
6370
+ if (input === void 0) return UNDEFINED;
6371
+ if (input === null) return NULL;
6372
+ if (Number.isNaN(input)) return NAN;
6373
+ if (input === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY;
6374
+ if (input === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY;
6375
+ if (input === 0 && 1 / input < 0) return NEGATIVE_ZERO;
6376
+ const index = this.index++;
6377
+ indices.set(input, index);
6378
+ stringify.call(this, input, index);
6379
+ return index;
6380
+ }
6381
+ function stringify(input, index) {
6382
+ const { deferred, plugins, postPlugins } = this;
6383
+ const str = this.stringified;
6384
+ const stack = [[input, index]];
6385
+ while (stack.length > 0) {
6386
+ const [input2, index2] = stack.pop();
6387
+ const partsForObj = (obj) => Object.keys(obj).map((k) => `"_${flatten.call(this, k)}":${flatten.call(this, obj[k])}`).join(",");
6388
+ let error = null;
6389
+ switch (typeof input2) {
6390
+ case "boolean":
6391
+ case "number":
6392
+ case "string":
6393
+ str[index2] = JSON.stringify(input2);
6394
+ break;
6395
+ case "bigint":
6396
+ str[index2] = `["${TYPE_BIGINT}","${input2}"]`;
6397
+ break;
6398
+ case "symbol": {
6399
+ const keyFor = Symbol.keyFor(input2);
6400
+ if (!keyFor) {
6401
+ error = new Error(
6402
+ "Cannot encode symbol unless created with Symbol.for()"
6403
+ );
6404
+ } else {
6405
+ str[index2] = `["${TYPE_SYMBOL}",${JSON.stringify(keyFor)}]`;
6406
+ }
6407
+ break;
6408
+ }
6409
+ case "object": {
6410
+ if (!input2) {
6411
+ str[index2] = `${NULL}`;
6412
+ break;
6413
+ }
6414
+ const isArray = Array.isArray(input2);
6415
+ let pluginHandled = false;
6416
+ if (!isArray && plugins) {
6417
+ for (const plugin of plugins) {
6418
+ const pluginResult = plugin(input2);
6419
+ if (Array.isArray(pluginResult)) {
6420
+ pluginHandled = true;
6421
+ const [pluginIdentifier, ...rest] = pluginResult;
6422
+ str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
6423
+ if (rest.length > 0) {
6424
+ str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
6425
+ }
6426
+ str[index2] += "]";
6427
+ break;
6428
+ }
6429
+ }
6430
+ }
6431
+ if (!pluginHandled) {
6432
+ let result = isArray ? "[" : "{";
6433
+ if (isArray) {
6434
+ for (let i = 0; i < input2.length; i++)
6435
+ result += (i ? "," : "") + (i in input2 ? flatten.call(this, input2[i]) : HOLE);
6436
+ str[index2] = `${result}]`;
6437
+ } else if (input2 instanceof Date) {
6438
+ str[index2] = `["${TYPE_DATE}",${input2.getTime()}]`;
6439
+ } else if (input2 instanceof URL) {
6440
+ str[index2] = `["${TYPE_URL}",${JSON.stringify(input2.href)}]`;
6441
+ } else if (input2 instanceof RegExp) {
6442
+ str[index2] = `["${TYPE_REGEXP}",${JSON.stringify(
6443
+ input2.source
6444
+ )},${JSON.stringify(input2.flags)}]`;
6445
+ } else if (input2 instanceof Set) {
6446
+ if (input2.size > 0) {
6447
+ str[index2] = `["${TYPE_SET}",${[...input2].map((val) => flatten.call(this, val)).join(",")}]`;
6448
+ } else {
6449
+ str[index2] = `["${TYPE_SET}"]`;
6450
+ }
6451
+ } else if (input2 instanceof Map) {
6452
+ if (input2.size > 0) {
6453
+ str[index2] = `["${TYPE_MAP}",${[...input2].flatMap(([k, v]) => [
6454
+ flatten.call(this, k),
6455
+ flatten.call(this, v)
6456
+ ]).join(",")}]`;
6457
+ } else {
6458
+ str[index2] = `["${TYPE_MAP}"]`;
6459
+ }
6460
+ } else if (input2 instanceof Promise) {
6461
+ str[index2] = `["${TYPE_PROMISE}",${index2}]`;
6462
+ deferred[index2] = input2;
6463
+ } else if (input2 instanceof Error) {
6464
+ str[index2] = `["${TYPE_ERROR}",${JSON.stringify(input2.message)}`;
6465
+ if (input2.name !== "Error") {
6466
+ str[index2] += `,${JSON.stringify(input2.name)}`;
6467
+ }
6468
+ str[index2] += "]";
6469
+ } else if (Object.getPrototypeOf(input2) === null) {
6470
+ str[index2] = `["${TYPE_NULL_OBJECT}",{${partsForObj(input2)}}]`;
6471
+ } else if (isPlainObject(input2)) {
6472
+ str[index2] = `{${partsForObj(input2)}}`;
6473
+ } else {
6474
+ error = new Error("Cannot encode object with prototype");
6475
+ }
6476
+ }
6477
+ break;
6478
+ }
6479
+ default: {
6480
+ const isArray = Array.isArray(input2);
6481
+ let pluginHandled = false;
6482
+ if (!isArray && plugins) {
6483
+ for (const plugin of plugins) {
6484
+ const pluginResult = plugin(input2);
6485
+ if (Array.isArray(pluginResult)) {
6486
+ pluginHandled = true;
6487
+ const [pluginIdentifier, ...rest] = pluginResult;
6488
+ str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
6489
+ if (rest.length > 0) {
6490
+ str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
6491
+ }
6492
+ str[index2] += "]";
6493
+ break;
6494
+ }
6495
+ }
6496
+ }
6497
+ if (!pluginHandled) {
6498
+ error = new Error("Cannot encode function or unexpected type");
6499
+ }
6500
+ }
6501
+ }
6502
+ if (error) {
6503
+ let pluginHandled = false;
6504
+ if (postPlugins) {
6505
+ for (const plugin of postPlugins) {
6506
+ const pluginResult = plugin(input2);
6507
+ if (Array.isArray(pluginResult)) {
6508
+ pluginHandled = true;
6509
+ const [pluginIdentifier, ...rest] = pluginResult;
6510
+ str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
6511
+ if (rest.length > 0) {
6512
+ str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
6513
+ }
6514
+ str[index2] += "]";
6515
+ break;
6516
+ }
6517
+ }
6518
+ }
6519
+ if (!pluginHandled) {
6520
+ throw error;
6521
+ }
6522
+ }
6523
+ }
6524
+ }
6525
+ var objectProtoNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
6526
+ function isPlainObject(thing) {
6527
+ const proto = Object.getPrototypeOf(thing);
6528
+ return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
6529
+ }
6530
+
6531
+ // vendor/turbo-stream-v2/unflatten.ts
6532
+ var globalObj = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0;
6533
+ function unflatten(parsed) {
6534
+ const { hydrated, values } = this;
6535
+ if (typeof parsed === "number") return hydrate.call(this, parsed);
6536
+ if (!Array.isArray(parsed) || !parsed.length) throw new SyntaxError();
6537
+ const startIndex = values.length;
6538
+ for (const value of parsed) {
6539
+ values.push(value);
6540
+ }
6541
+ hydrated.length = values.length;
6542
+ return hydrate.call(this, startIndex);
6543
+ }
6544
+ function hydrate(index) {
6545
+ const { hydrated, values, deferred, plugins } = this;
6546
+ let result;
6547
+ const stack = [
6548
+ [
6549
+ index,
6550
+ (v) => {
6551
+ result = v;
6552
+ }
6553
+ ]
6554
+ ];
6555
+ let postRun = [];
6556
+ while (stack.length > 0) {
6557
+ const [index2, set] = stack.pop();
6558
+ switch (index2) {
6559
+ case UNDEFINED:
6560
+ set(void 0);
6561
+ continue;
6562
+ case NULL:
6563
+ set(null);
6564
+ continue;
6565
+ case NAN:
6566
+ set(NaN);
6567
+ continue;
6568
+ case POSITIVE_INFINITY:
6569
+ set(Infinity);
6570
+ continue;
6571
+ case NEGATIVE_INFINITY:
6572
+ set(-Infinity);
6573
+ continue;
6574
+ case NEGATIVE_ZERO:
6575
+ set(-0);
6576
+ continue;
6577
+ }
6578
+ if (hydrated[index2]) {
6579
+ set(hydrated[index2]);
6580
+ continue;
6581
+ }
6582
+ const value = values[index2];
6583
+ if (!value || typeof value !== "object") {
6584
+ hydrated[index2] = value;
6585
+ set(value);
6586
+ continue;
6587
+ }
6588
+ if (Array.isArray(value)) {
6589
+ if (typeof value[0] === "string") {
6590
+ const [type, b, c] = value;
6591
+ switch (type) {
6592
+ case TYPE_DATE:
6593
+ set(hydrated[index2] = new Date(b));
6594
+ continue;
6595
+ case TYPE_URL:
6596
+ set(hydrated[index2] = new URL(b));
6597
+ continue;
6598
+ case TYPE_BIGINT:
6599
+ set(hydrated[index2] = BigInt(b));
6600
+ continue;
6601
+ case TYPE_REGEXP:
6602
+ set(hydrated[index2] = new RegExp(b, c));
6603
+ continue;
6604
+ case TYPE_SYMBOL:
6605
+ set(hydrated[index2] = Symbol.for(b));
6606
+ continue;
6607
+ case TYPE_SET:
6608
+ const newSet = /* @__PURE__ */ new Set();
6609
+ hydrated[index2] = newSet;
6610
+ for (let i = value.length - 1; i > 0; i--)
6611
+ stack.push([
6612
+ value[i],
6613
+ (v) => {
6614
+ newSet.add(v);
6615
+ }
6616
+ ]);
6617
+ set(newSet);
6618
+ continue;
6619
+ case TYPE_MAP:
6620
+ const map = /* @__PURE__ */ new Map();
6621
+ hydrated[index2] = map;
6622
+ for (let i = value.length - 2; i > 0; i -= 2) {
6623
+ const r = [];
6624
+ stack.push([
6625
+ value[i + 1],
6626
+ (v) => {
6627
+ r[1] = v;
6628
+ }
6629
+ ]);
6630
+ stack.push([
6631
+ value[i],
6632
+ (k) => {
6633
+ r[0] = k;
6634
+ }
6635
+ ]);
6636
+ postRun.push(() => {
6637
+ map.set(r[0], r[1]);
6638
+ });
6639
+ }
6640
+ set(map);
6641
+ continue;
6642
+ case TYPE_NULL_OBJECT:
6643
+ const obj = /* @__PURE__ */ Object.create(null);
6644
+ hydrated[index2] = obj;
6645
+ for (const key of Object.keys(b).reverse()) {
6646
+ const r = [];
6647
+ stack.push([
6648
+ b[key],
6649
+ (v) => {
6650
+ r[1] = v;
6651
+ }
6652
+ ]);
6653
+ stack.push([
6654
+ Number(key.slice(1)),
6655
+ (k) => {
6656
+ r[0] = k;
6657
+ }
6658
+ ]);
6659
+ postRun.push(() => {
6660
+ obj[r[0]] = r[1];
6661
+ });
6662
+ }
6663
+ set(obj);
6664
+ continue;
6665
+ case TYPE_PROMISE:
6666
+ if (hydrated[b]) {
6667
+ set(hydrated[index2] = hydrated[b]);
6668
+ } else {
6669
+ const d = new Deferred2();
6670
+ deferred[b] = d;
6671
+ set(hydrated[index2] = d.promise);
6672
+ }
6673
+ continue;
6674
+ case TYPE_ERROR:
6675
+ const [, message, errorType] = value;
6676
+ let error = errorType && globalObj && globalObj[errorType] ? new globalObj[errorType](message) : new Error(message);
6677
+ hydrated[index2] = error;
6678
+ set(error);
6679
+ continue;
6680
+ case TYPE_PREVIOUS_RESOLVED:
6681
+ set(hydrated[index2] = hydrated[b]);
6682
+ continue;
6683
+ default:
6684
+ if (Array.isArray(plugins)) {
6685
+ const r = [];
6686
+ const vals = value.slice(1);
6687
+ for (let i = 0; i < vals.length; i++) {
6688
+ const v = vals[i];
6689
+ stack.push([
6690
+ v,
6691
+ (v2) => {
6692
+ r[i] = v2;
6693
+ }
6694
+ ]);
6695
+ }
6696
+ postRun.push(() => {
6697
+ for (const plugin of plugins) {
6698
+ const result2 = plugin(value[0], ...r);
6699
+ if (result2) {
6700
+ set(hydrated[index2] = result2.value);
6701
+ return;
6702
+ }
6703
+ }
6704
+ throw new SyntaxError();
6705
+ });
6706
+ continue;
6707
+ }
6708
+ throw new SyntaxError();
6709
+ }
6710
+ } else {
6711
+ const array = [];
6712
+ hydrated[index2] = array;
6713
+ for (let i = 0; i < value.length; i++) {
6714
+ const n = value[i];
6715
+ if (n !== HOLE) {
6716
+ stack.push([
6717
+ n,
6718
+ (v) => {
6719
+ array[i] = v;
6720
+ }
6721
+ ]);
6722
+ }
6723
+ }
6724
+ set(array);
6725
+ continue;
6726
+ }
6727
+ } else {
6728
+ const object = {};
6729
+ hydrated[index2] = object;
6730
+ for (const key of Object.keys(value).reverse()) {
6731
+ const r = [];
6732
+ stack.push([
6733
+ value[key],
6734
+ (v) => {
6735
+ r[1] = v;
6736
+ }
6737
+ ]);
6738
+ stack.push([
6739
+ Number(key.slice(1)),
6740
+ (k) => {
6741
+ r[0] = k;
6742
+ }
6743
+ ]);
6744
+ postRun.push(() => {
6745
+ object[r[0]] = r[1];
6746
+ });
6747
+ }
6748
+ set(object);
6749
+ continue;
6750
+ }
6751
+ }
6752
+ while (postRun.length > 0) {
6753
+ postRun.pop()();
6754
+ }
6755
+ return result;
6756
+ }
6757
+
6758
+ // vendor/turbo-stream-v2/turbo-stream.ts
6759
+ async function decode(readable, options) {
6760
+ const { plugins } = options ?? {};
6761
+ const done = new Deferred2();
6762
+ const reader = readable.pipeThrough(createLineSplittingTransform()).getReader();
6763
+ const decoder = {
6764
+ values: [],
6765
+ hydrated: [],
6766
+ deferred: {},
6767
+ plugins
6768
+ };
6769
+ const decoded = await decodeInitial.call(decoder, reader);
6770
+ let donePromise = done.promise;
6771
+ if (decoded.done) {
6772
+ done.resolve();
6773
+ } else {
6774
+ donePromise = decodeDeferred.call(decoder, reader).then(done.resolve).catch((reason) => {
6775
+ for (const deferred of Object.values(decoder.deferred)) {
6776
+ deferred.reject(reason);
6777
+ }
6778
+ done.reject(reason);
6779
+ });
6780
+ }
6781
+ return {
6782
+ done: donePromise.then(() => reader.closed),
6783
+ value: decoded.value
6784
+ };
6785
+ }
6786
+ async function decodeInitial(reader) {
6787
+ const read = await reader.read();
6788
+ if (!read.value) {
6789
+ throw new SyntaxError();
6790
+ }
6791
+ let line;
6792
+ try {
6793
+ line = JSON.parse(read.value);
6794
+ } catch (reason) {
6795
+ throw new SyntaxError();
6796
+ }
6797
+ return {
6798
+ done: read.done,
6799
+ value: unflatten.call(this, line)
6800
+ };
6801
+ }
6802
+ async function decodeDeferred(reader) {
6803
+ let read = await reader.read();
6804
+ while (!read.done) {
6805
+ if (!read.value) continue;
6806
+ const line = read.value;
6807
+ switch (line[0]) {
6808
+ case TYPE_PROMISE: {
6809
+ const colonIndex = line.indexOf(":");
6810
+ const deferredId = Number(line.slice(1, colonIndex));
6811
+ const deferred = this.deferred[deferredId];
6812
+ if (!deferred) {
6813
+ throw new Error(`Deferred ID ${deferredId} not found in stream`);
6814
+ }
6815
+ const lineData = line.slice(colonIndex + 1);
6816
+ let jsonLine;
6817
+ try {
6818
+ jsonLine = JSON.parse(lineData);
6819
+ } catch (reason) {
6820
+ throw new SyntaxError();
6821
+ }
6822
+ const value = unflatten.call(this, jsonLine);
6823
+ deferred.resolve(value);
6824
+ break;
6825
+ }
6826
+ case TYPE_ERROR: {
6827
+ const colonIndex = line.indexOf(":");
6828
+ const deferredId = Number(line.slice(1, colonIndex));
6829
+ const deferred = this.deferred[deferredId];
6830
+ if (!deferred) {
6831
+ throw new Error(`Deferred ID ${deferredId} not found in stream`);
6832
+ }
6833
+ const lineData = line.slice(colonIndex + 1);
6834
+ let jsonLine;
6835
+ try {
6836
+ jsonLine = JSON.parse(lineData);
6837
+ } catch (reason) {
6838
+ throw new SyntaxError();
6839
+ }
6840
+ const value = unflatten.call(this, jsonLine);
6841
+ deferred.reject(value);
6842
+ break;
6843
+ }
6844
+ default:
6845
+ throw new SyntaxError();
6846
+ }
6847
+ read = await reader.read();
6848
+ }
6849
+ }
6850
+ function encode(input, options) {
6851
+ const { plugins, postPlugins, signal } = options ?? {};
6852
+ const encoder2 = {
6853
+ deferred: {},
6854
+ index: 0,
6855
+ indices: /* @__PURE__ */ new Map(),
6856
+ stringified: [],
6857
+ plugins,
6858
+ postPlugins,
6859
+ signal
6860
+ };
6861
+ const textEncoder = new TextEncoder();
6862
+ let lastSentIndex = 0;
6863
+ const readable = new ReadableStream({
6864
+ async start(controller) {
6865
+ const id = flatten.call(encoder2, input);
6866
+ if (Array.isArray(id)) {
6867
+ throw new Error("This should never happen");
6868
+ }
6869
+ if (id < 0) {
6870
+ controller.enqueue(textEncoder.encode(`${id}
6871
+ `));
6872
+ } else {
6873
+ controller.enqueue(
6874
+ textEncoder.encode(`[${encoder2.stringified.join(",")}]
6875
+ `)
6876
+ );
6877
+ lastSentIndex = encoder2.stringified.length - 1;
6878
+ }
6879
+ const seenPromises = /* @__PURE__ */ new WeakSet();
6880
+ if (Object.keys(encoder2.deferred).length) {
6881
+ let raceDone;
6882
+ const racePromise = new Promise((resolve, reject) => {
6883
+ raceDone = resolve;
6884
+ if (signal) {
6885
+ const rejectPromise = () => reject(signal.reason || new Error("Signal was aborted."));
6886
+ if (signal.aborted) {
6887
+ rejectPromise();
6888
+ } else {
6889
+ signal.addEventListener("abort", (event) => {
6890
+ rejectPromise();
6891
+ });
6892
+ }
6893
+ }
6894
+ });
6895
+ while (Object.keys(encoder2.deferred).length > 0) {
6896
+ for (const [deferredId, deferred] of Object.entries(
6897
+ encoder2.deferred
6898
+ )) {
6899
+ if (seenPromises.has(deferred)) continue;
6900
+ seenPromises.add(
6901
+ // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
6902
+ encoder2.deferred[Number(deferredId)] = Promise.race([
6903
+ racePromise,
6904
+ deferred
6905
+ ]).then(
6906
+ (resolved) => {
6907
+ const id2 = flatten.call(encoder2, resolved);
6908
+ if (Array.isArray(id2)) {
6909
+ controller.enqueue(
6910
+ textEncoder.encode(
6911
+ `${TYPE_PROMISE}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
6912
+ `
6913
+ )
6914
+ );
6915
+ encoder2.index++;
6916
+ lastSentIndex++;
6917
+ } else if (id2 < 0) {
6918
+ controller.enqueue(
6919
+ textEncoder.encode(
6920
+ `${TYPE_PROMISE}${deferredId}:${id2}
6921
+ `
6922
+ )
6923
+ );
6924
+ } else {
6925
+ const values = encoder2.stringified.slice(lastSentIndex + 1).join(",");
6926
+ controller.enqueue(
6927
+ textEncoder.encode(
6928
+ `${TYPE_PROMISE}${deferredId}:[${values}]
6929
+ `
6930
+ )
6931
+ );
6932
+ lastSentIndex = encoder2.stringified.length - 1;
6933
+ }
6934
+ },
6935
+ (reason) => {
6936
+ if (!reason || typeof reason !== "object" || !(reason instanceof Error)) {
6937
+ reason = new Error("An unknown error occurred");
6938
+ }
6939
+ const id2 = flatten.call(encoder2, reason);
6940
+ if (Array.isArray(id2)) {
6941
+ controller.enqueue(
6942
+ textEncoder.encode(
6943
+ `${TYPE_ERROR}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
6944
+ `
6945
+ )
6946
+ );
6947
+ encoder2.index++;
6948
+ lastSentIndex++;
6949
+ } else if (id2 < 0) {
6950
+ controller.enqueue(
6951
+ textEncoder.encode(`${TYPE_ERROR}${deferredId}:${id2}
6952
+ `)
6953
+ );
6954
+ } else {
6955
+ const values = encoder2.stringified.slice(lastSentIndex + 1).join(",");
6956
+ controller.enqueue(
6957
+ textEncoder.encode(
6958
+ `${TYPE_ERROR}${deferredId}:[${values}]
6959
+ `
6960
+ )
6961
+ );
6962
+ lastSentIndex = encoder2.stringified.length - 1;
6963
+ }
6964
+ }
6965
+ ).finally(() => {
6966
+ delete encoder2.deferred[Number(deferredId)];
6967
+ })
6968
+ );
6969
+ }
6970
+ await Promise.race(Object.values(encoder2.deferred));
6971
+ }
6972
+ raceDone();
6973
+ }
6974
+ await Promise.all(Object.values(encoder2.deferred));
6975
+ controller.close();
6976
+ }
6977
+ });
6978
+ return readable;
6979
+ }
6371
6980
 
6372
6981
  // lib/dom/ssr/data.ts
6373
6982
  async function createRequestInit(request) {
@@ -6392,6 +7001,7 @@ async function createRequestInit(request) {
6392
7001
 
6393
7002
  // lib/dom/ssr/single-fetch.tsx
6394
7003
  var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
7004
+ var SINGLE_FETCH_REDIRECT_STATUS = 202;
6395
7005
  var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205]);
6396
7006
  function StreamTransfer({
6397
7007
  context,
@@ -6519,7 +7129,7 @@ async function singleFetchActionStrategy(args, fetchAndDecode, basename) {
6519
7129
  });
6520
7130
  return result2;
6521
7131
  });
6522
- if (isResponse(result.result) || isRouteErrorResponse(result.result)) {
7132
+ if (isResponse(result.result) || isRouteErrorResponse(result.result) || isDataWithResponseInit(result.result)) {
6523
7133
  return { [actionMatch.route.id]: result };
6524
7134
  }
6525
7135
  return {
@@ -6604,7 +7214,8 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
6604
7214
  )
6605
7215
  );
6606
7216
  await Promise.all(routeDfds.map((d) => d.promise));
6607
- if ((!router.state.initialized || routesParams.size === 0) && !window.__reactRouterHdrActive) {
7217
+ let isInitialLoad = !router.state.initialized && router.state.navigation.state === "idle";
7218
+ if ((isInitialLoad || routesParams.size === 0) && !window.__reactRouterHdrActive) {
6608
7219
  singleFetchDfd.resolve({ routes: {} });
6609
7220
  } else {
6610
7221
  let targetRoutes = ssr && foundOptOutRoute && routesParams.size > 0 ? [...routesParams.keys()] : void 0;
@@ -6644,7 +7255,7 @@ function stripIndexParam(url) {
6644
7255
  }
6645
7256
  return url;
6646
7257
  }
6647
- function singleFetchUrl(reqUrl, basename, extension) {
7258
+ function singleFetchUrl(reqUrl, basename) {
6648
7259
  let url = typeof reqUrl === "string" ? new URL(
6649
7260
  reqUrl,
6650
7261
  // This can be called during the SSR flow via PrefetchPageLinksImpl so
@@ -6652,17 +7263,17 @@ function singleFetchUrl(reqUrl, basename, extension) {
6652
7263
  typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
6653
7264
  ) : reqUrl;
6654
7265
  if (url.pathname === "/") {
6655
- url.pathname = `_root.${extension}`;
7266
+ url.pathname = "_root.data";
6656
7267
  } else if (basename && stripBasename(url.pathname, basename) === "/") {
6657
- url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
7268
+ url.pathname = `${basename.replace(/\/$/, "")}/_root.data`;
6658
7269
  } else {
6659
- url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
7270
+ url.pathname = `${url.pathname.replace(/\/$/, "")}.data`;
6660
7271
  }
6661
7272
  return url;
6662
7273
  }
6663
7274
  async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
6664
7275
  let { request } = args;
6665
- let url = singleFetchUrl(request.url, basename, "data");
7276
+ let url = singleFetchUrl(request.url, basename);
6666
7277
  if (request.method === "GET") {
6667
7278
  url = stripIndexParam(url);
6668
7279
  if (targetRoutes) {
@@ -6673,6 +7284,20 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
6673
7284
  if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
6674
7285
  throw new ErrorResponseImpl(404, "Not Found", true);
6675
7286
  }
7287
+ if (res.status === 204 && res.headers.has("X-Remix-Redirect")) {
7288
+ return {
7289
+ status: SINGLE_FETCH_REDIRECT_STATUS,
7290
+ data: {
7291
+ redirect: {
7292
+ redirect: res.headers.get("X-Remix-Redirect"),
7293
+ status: Number(res.headers.get("X-Remix-Status") || "302"),
7294
+ revalidate: res.headers.get("X-Remix-Revalidate") === "true",
7295
+ reload: res.headers.get("X-Remix-Reload-Document") === "true",
7296
+ replace: res.headers.get("X-Remix-Replace") === "true"
7297
+ }
7298
+ }
7299
+ };
7300
+ }
6676
7301
  if (NO_BODY_STATUS_CODES.has(res.status)) {
6677
7302
  let routes = {};
6678
7303
  if (targetRoutes && request.method !== "GET") {
@@ -6745,13 +7370,13 @@ function decodeViaTurboStream(body, global2) {
6745
7370
  function unwrapSingleFetchResult(result, routeId) {
6746
7371
  if ("redirect" in result) {
6747
7372
  let {
6748
- redirect: location2,
7373
+ redirect: location,
6749
7374
  revalidate,
6750
7375
  reload,
6751
7376
  replace: replace2,
6752
7377
  status
6753
7378
  } = result.redirect;
6754
- throw redirect(location2, {
7379
+ throw redirect(location, {
6755
7380
  status,
6756
7381
  headers: {
6757
7382
  // Three R's of redirecting (lol Veep)
@@ -6762,13 +7387,12 @@ function unwrapSingleFetchResult(result, routeId) {
6762
7387
  });
6763
7388
  }
6764
7389
  let routeResult = result.routes[routeId];
6765
- invariant2(routeResult, `No response found for routeId "${routeId}"`);
6766
7390
  if ("error" in routeResult) {
6767
7391
  throw routeResult.error;
6768
7392
  } else if ("data" in routeResult) {
6769
7393
  return routeResult.data;
6770
7394
  } else {
6771
- throw new Error(`Invalid response found for routeId "${routeId}"`);
7395
+ throw new Error(`No response found for routeId "${routeId}"`);
6772
7396
  }
6773
7397
  }
6774
7398
  function createDeferred2() {
@@ -6846,14 +7470,14 @@ function RemixRootDefaultErrorBoundary({
6846
7470
  dangerouslySetInnerHTML: {
6847
7471
  __html: `
6848
7472
  console.log(
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."
7473
+ "\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
6850
7474
  );
6851
7475
  `
6852
7476
  }
6853
7477
  }
6854
7478
  );
6855
7479
  if (isRouteErrorResponse(error)) {
6856
- return /* @__PURE__ */ React5.createElement(BoundaryShell, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ React5.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText), heyDeveloper);
7480
+ return /* @__PURE__ */ React5.createElement(BoundaryShell, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ React5.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText), ENABLE_DEV_WARNINGS ? heyDeveloper : null);
6857
7481
  }
6858
7482
  let errorInstance;
6859
7483
  if (error instanceof Error) {
@@ -6906,7 +7530,7 @@ function BoundaryShell({
6906
7530
  // lib/dom/ssr/fallback.tsx
6907
7531
  import * as React6 from "react";
6908
7532
  function RemixRootDefaultHydrateFallback() {
6909
- return /* @__PURE__ */ React6.createElement(BoundaryShell, { title: "Loading...", renderScripts: true }, /* @__PURE__ */ React6.createElement(
7533
+ return /* @__PURE__ */ React6.createElement(BoundaryShell, { title: "Loading...", renderScripts: true }, ENABLE_DEV_WARNINGS ? /* @__PURE__ */ React6.createElement(
6910
7534
  "script",
6911
7535
  {
6912
7536
  dangerouslySetInnerHTML: {
@@ -6914,13 +7538,13 @@ function RemixRootDefaultHydrateFallback() {
6914
7538
  console.log(
6915
7539
  "\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this " +
6916
7540
  "when your app is loading JS modules and/or running \`clientLoader\` " +
6917
- "functions. Check out https://remix.run/route/hydrate-fallback " +
7541
+ "functions. Check out https://reactrouter.com/start/framework/route-module#hydratefallback " +
6918
7542
  "for more information."
6919
7543
  );
6920
7544
  `
6921
7545
  }
6922
7546
  }
6923
- ));
7547
+ ) : null);
6924
7548
  }
6925
7549
 
6926
7550
  // lib/dom/ssr/routes.tsx
@@ -7333,8 +7957,8 @@ var nextPaths = /* @__PURE__ */ new Set();
7333
7957
  var discoveredPathsMaxSize = 1e3;
7334
7958
  var discoveredPaths = /* @__PURE__ */ new Set();
7335
7959
  var URL_LIMIT = 7680;
7336
- function isFogOfWarEnabled(ssr) {
7337
- return ssr === true;
7960
+ function isFogOfWarEnabled(routeDiscovery, ssr) {
7961
+ return routeDiscovery.mode === "lazy" && ssr === true;
7338
7962
  }
7339
7963
  function getPartialManifest({ sri, ...manifest }, router) {
7340
7964
  let routeIds = new Set(router.state.matches.map((m) => m.route.id));
@@ -7361,8 +7985,8 @@ function getPartialManifest({ sri, ...manifest }, router) {
7361
7985
  sri: sri ? true : void 0
7362
7986
  };
7363
7987
  }
7364
- function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
7365
- if (!isFogOfWarEnabled(ssr)) {
7988
+ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDiscovery, isSpaMode, basename) {
7989
+ if (!isFogOfWarEnabled(routeDiscovery, ssr)) {
7366
7990
  return void 0;
7367
7991
  }
7368
7992
  return async ({ path, patch, signal, fetcherKey }) => {
@@ -7377,14 +8001,16 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMo
7377
8001
  ssr,
7378
8002
  isSpaMode,
7379
8003
  basename,
8004
+ routeDiscovery.manifestPath,
7380
8005
  patch,
7381
8006
  signal
7382
8007
  );
7383
8008
  };
7384
8009
  }
7385
- function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
8010
+ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscovery, isSpaMode) {
7386
8011
  React8.useEffect(() => {
7387
- if (!isFogOfWarEnabled(ssr) || navigator.connection?.saveData === true) {
8012
+ if (!isFogOfWarEnabled(routeDiscovery, ssr) || // @ts-expect-error - TS doesn't know about this yet
8013
+ window.navigator?.connection?.saveData === true) {
7388
8014
  return;
7389
8015
  }
7390
8016
  function registerElement(el) {
@@ -7418,6 +8044,7 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
7418
8044
  ssr,
7419
8045
  isSpaMode,
7420
8046
  router.basename,
8047
+ routeDiscovery.manifestPath,
7421
8048
  router.patchRoutes
7422
8049
  );
7423
8050
  } catch (e) {
@@ -7434,15 +8061,21 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
7434
8061
  attributeFilter: ["data-discover", "href", "action"]
7435
8062
  });
7436
8063
  return () => observer.disconnect();
7437
- }, [ssr, isSpaMode, manifest, routeModules, router]);
8064
+ }, [ssr, isSpaMode, manifest, routeModules, router, routeDiscovery]);
8065
+ }
8066
+ function getManifestPath(_manifestPath, basename) {
8067
+ let manifestPath = _manifestPath || "/__manifest";
8068
+ if (basename == null) {
8069
+ return manifestPath;
8070
+ }
8071
+ return `${basename}${manifestPath}`.replace(/\/+/g, "/");
7438
8072
  }
7439
8073
  var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
7440
- async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, patchRoutes, signal) {
7441
- let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
7442
- /\/+/g,
7443
- "/"
8074
+ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
8075
+ let url = new URL(
8076
+ getManifestPath(manifestPath, basename),
8077
+ window.location.origin
7444
8078
  );
7445
- let url = new URL(manifestPath, window.location.origin);
7446
8079
  paths.sort().forEach((path) => url.searchParams.append("p", path));
7447
8080
  url.searchParams.set("version", manifest.version);
7448
8081
  if (url.toString().length > URL_LIMIT) {
@@ -7469,7 +8102,9 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
7469
8102
  }
7470
8103
  sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
7471
8104
  window.location.href = errorReloadPath;
7472
- throw new Error("Detected manifest version mismatch, reloading...");
8105
+ console.warn("Detected manifest version mismatch, reloading...");
8106
+ await new Promise(() => {
8107
+ });
7473
8108
  } else if (res.status >= 400) {
7474
8109
  throw new Error(await res.text());
7475
8110
  }
@@ -7668,7 +8303,7 @@ function PrefetchPageLinksImpl({
7668
8303
  matches: nextMatches,
7669
8304
  ...linkProps
7670
8305
  }) {
7671
- let location2 = useLocation();
8306
+ let location = useLocation();
7672
8307
  let { manifest, routeModules } = useFrameworkContext();
7673
8308
  let { basename } = useDataRouterContext2();
7674
8309
  let { loaderData, matches } = useDataRouterStateContext();
@@ -7678,10 +8313,10 @@ function PrefetchPageLinksImpl({
7678
8313
  nextMatches,
7679
8314
  matches,
7680
8315
  manifest,
7681
- location2,
8316
+ location,
7682
8317
  "data"
7683
8318
  ),
7684
- [page, nextMatches, matches, manifest, location2]
8319
+ [page, nextMatches, matches, manifest, location]
7685
8320
  );
7686
8321
  let newMatchesForAssets = React9.useMemo(
7687
8322
  () => getNewMatchesForLinks(
@@ -7689,13 +8324,13 @@ function PrefetchPageLinksImpl({
7689
8324
  nextMatches,
7690
8325
  matches,
7691
8326
  manifest,
7692
- location2,
8327
+ location,
7693
8328
  "assets"
7694
8329
  ),
7695
- [page, nextMatches, matches, manifest, location2]
8330
+ [page, nextMatches, matches, manifest, location]
7696
8331
  );
7697
8332
  let dataHrefs = React9.useMemo(() => {
7698
- if (page === location2.pathname + location2.search + location2.hash) {
8333
+ if (page === location.pathname + location.search + location.hash) {
7699
8334
  return [];
7700
8335
  }
7701
8336
  let routesParams = /* @__PURE__ */ new Set();
@@ -7716,7 +8351,7 @@ function PrefetchPageLinksImpl({
7716
8351
  if (routesParams.size === 0) {
7717
8352
  return [];
7718
8353
  }
7719
- let url = singleFetchUrl(page, basename, ".data");
8354
+ let url = singleFetchUrl(page, basename);
7720
8355
  if (foundOptOutRoute && routesParams.size > 0) {
7721
8356
  url.searchParams.set(
7722
8357
  "_routes",
@@ -7727,7 +8362,7 @@ function PrefetchPageLinksImpl({
7727
8362
  }, [
7728
8363
  basename,
7729
8364
  loaderData,
7730
- location2,
8365
+ location,
7731
8366
  manifest,
7732
8367
  newMatchesForData,
7733
8368
  nextMatches,
@@ -7752,7 +8387,7 @@ function Meta() {
7752
8387
  matches: routerMatches,
7753
8388
  loaderData
7754
8389
  } = useDataRouterStateContext();
7755
- let location2 = useLocation();
8390
+ let location = useLocation();
7756
8391
  let _matches = getActiveMatches(routerMatches, errors, isSpaMode);
7757
8392
  let error = null;
7758
8393
  if (errors) {
@@ -7782,7 +8417,7 @@ function Meta() {
7782
8417
  routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
7783
8418
  data: data2,
7784
8419
  params,
7785
- location: location2,
8420
+ location,
7786
8421
  matches,
7787
8422
  error
7788
8423
  }) : Array.isArray(routeModule.meta) ? [...routeModule.meta] : routeModule.meta;
@@ -7848,10 +8483,17 @@ function isValidMetaTag(tagName) {
7848
8483
  }
7849
8484
  var isHydrated = false;
7850
8485
  function Scripts(props) {
7851
- let { manifest, serverHandoffString, isSpaMode, ssr, renderMeta } = useFrameworkContext();
8486
+ let {
8487
+ manifest,
8488
+ serverHandoffString,
8489
+ isSpaMode,
8490
+ renderMeta,
8491
+ routeDiscovery,
8492
+ ssr
8493
+ } = useFrameworkContext();
7852
8494
  let { router, static: isStatic, staticContext } = useDataRouterContext2();
7853
8495
  let { matches: routerMatches } = useDataRouterStateContext();
7854
- let enableFogOfWar = isFogOfWarEnabled(ssr);
8496
+ let enableFogOfWar = isFogOfWarEnabled(routeDiscovery, ssr);
7855
8497
  if (renderMeta) {
7856
8498
  renderMeta.didRenderScripts = true;
7857
8499
  }
@@ -8007,7 +8649,7 @@ function mergeRefs(...refs) {
8007
8649
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
8008
8650
  try {
8009
8651
  if (isBrowser) {
8010
- window.__reactRouterVersion = "0.0.0-experimental-e56aa53bc";
8652
+ window.__reactRouterVersion = "0.0.0-experimental-aecfb0db1";
8011
8653
  }
8012
8654
  } catch (e) {
8013
8655
  }
@@ -8265,14 +8907,14 @@ var NavLink = React10.forwardRef(
8265
8907
  ...rest
8266
8908
  }, ref) {
8267
8909
  let path = useResolvedPath(to, { relative: rest.relative });
8268
- let location2 = useLocation();
8910
+ let location = useLocation();
8269
8911
  let routerState = React10.useContext(DataRouterStateContext);
8270
- let { navigator: navigator2, basename } = React10.useContext(NavigationContext);
8912
+ let { navigator, basename } = React10.useContext(NavigationContext);
8271
8913
  let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
8272
8914
  // eslint-disable-next-line react-hooks/rules-of-hooks
8273
8915
  useViewTransitionState(path) && viewTransition === true;
8274
- let toPathname = navigator2.encodeLocation ? navigator2.encodeLocation(path).pathname : path.pathname;
8275
- let locationPathname = location2.pathname;
8916
+ let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
8917
+ let locationPathname = location.pathname;
8276
8918
  let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
8277
8919
  if (!caseSensitive) {
8278
8920
  locationPathname = locationPathname.toLowerCase();
@@ -8377,19 +9019,19 @@ function ScrollRestoration({
8377
9019
  }) {
8378
9020
  let remixContext = React10.useContext(FrameworkContext);
8379
9021
  let { basename } = React10.useContext(NavigationContext);
8380
- let location2 = useLocation();
9022
+ let location = useLocation();
8381
9023
  let matches = useMatches();
8382
9024
  useScrollRestoration({ getKey, storageKey });
8383
9025
  let ssrKey = React10.useMemo(
8384
9026
  () => {
8385
9027
  if (!remixContext || !getKey) return null;
8386
9028
  let userKey = getScrollRestorationKey(
8387
- location2,
9029
+ location,
8388
9030
  matches,
8389
9031
  basename,
8390
9032
  getKey
8391
9033
  );
8392
- return userKey !== location2.key ? userKey : null;
9034
+ return userKey !== location.key ? userKey : null;
8393
9035
  },
8394
9036
  // Nah, we only need this the first time for the SSR render
8395
9037
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -8450,13 +9092,13 @@ function useLinkClickHandler(to, {
8450
9092
  viewTransition
8451
9093
  } = {}) {
8452
9094
  let navigate = useNavigate();
8453
- let location2 = useLocation();
9095
+ let location = useLocation();
8454
9096
  let path = useResolvedPath(to, { relative });
8455
9097
  return React10.useCallback(
8456
9098
  (event) => {
8457
9099
  if (shouldProcessLinkClick(event, target)) {
8458
9100
  event.preventDefault();
8459
- let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location2) === createPath(path);
9101
+ let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
8460
9102
  navigate(to, {
8461
9103
  replace: replace2,
8462
9104
  state,
@@ -8467,7 +9109,7 @@ function useLinkClickHandler(to, {
8467
9109
  }
8468
9110
  },
8469
9111
  [
8470
- location2,
9112
+ location,
8471
9113
  navigate,
8472
9114
  path,
8473
9115
  replaceProp,
@@ -8487,18 +9129,18 @@ function useSearchParams(defaultInit) {
8487
9129
  );
8488
9130
  let defaultSearchParamsRef = React10.useRef(createSearchParams(defaultInit));
8489
9131
  let hasSetSearchParamsRef = React10.useRef(false);
8490
- let location2 = useLocation();
9132
+ let location = useLocation();
8491
9133
  let searchParams = React10.useMemo(
8492
9134
  () => (
8493
9135
  // Only merge in the defaults if we haven't yet called setSearchParams.
8494
9136
  // Once we call that we want those to take precedence, otherwise you can't
8495
9137
  // remove a param with setSearchParams({}) if it has an initial value
8496
9138
  getSearchParamsForLocation(
8497
- location2.search,
9139
+ location.search,
8498
9140
  hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
8499
9141
  )
8500
9142
  ),
8501
- [location2.search]
9143
+ [location.search]
8502
9144
  );
8503
9145
  let navigate = useNavigate();
8504
9146
  let setSearchParams = React10.useCallback(
@@ -8559,9 +9201,9 @@ function useFormAction(action, { relative } = {}) {
8559
9201
  invariant(routeContext, "useFormAction must be used inside a RouteContext");
8560
9202
  let [match] = routeContext.matches.slice(-1);
8561
9203
  let path = { ...useResolvedPath(action ? action : ".", { relative }) };
8562
- let location2 = useLocation();
9204
+ let location = useLocation();
8563
9205
  if (action == null) {
8564
- path.search = location2.search;
9206
+ path.search = location.search;
8565
9207
  let params = new URLSearchParams(path.search);
8566
9208
  let indexValues = params.getAll("index");
8567
9209
  let hasNakedIndexParam = indexValues.some((v) => v === "");
@@ -8653,23 +9295,23 @@ function useFetchers() {
8653
9295
  }
8654
9296
  var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
8655
9297
  var savedScrollPositions = {};
8656
- function getScrollRestorationKey(location2, matches, basename, getKey) {
9298
+ function getScrollRestorationKey(location, matches, basename, getKey) {
8657
9299
  let key = null;
8658
9300
  if (getKey) {
8659
9301
  if (basename !== "/") {
8660
9302
  key = getKey(
8661
9303
  {
8662
- ...location2,
8663
- pathname: stripBasename(location2.pathname, basename) || location2.pathname
9304
+ ...location,
9305
+ pathname: stripBasename(location.pathname, basename) || location.pathname
8664
9306
  },
8665
9307
  matches
8666
9308
  );
8667
9309
  } else {
8668
- key = getKey(location2, matches);
9310
+ key = getKey(location, matches);
8669
9311
  }
8670
9312
  }
8671
9313
  if (key == null) {
8672
- key = location2.key;
9314
+ key = location.key;
8673
9315
  }
8674
9316
  return key;
8675
9317
  }
@@ -8682,7 +9324,7 @@ function useScrollRestoration({
8682
9324
  "useScrollRestoration" /* UseScrollRestoration */
8683
9325
  );
8684
9326
  let { basename } = React10.useContext(NavigationContext);
8685
- let location2 = useLocation();
9327
+ let location = useLocation();
8686
9328
  let matches = useMatches();
8687
9329
  let navigation = useNavigation();
8688
9330
  React10.useEffect(() => {
@@ -8694,7 +9336,7 @@ function useScrollRestoration({
8694
9336
  usePageHide(
8695
9337
  React10.useCallback(() => {
8696
9338
  if (navigation.state === "idle") {
8697
- let key = getScrollRestorationKey(location2, matches, basename, getKey);
9339
+ let key = getScrollRestorationKey(location, matches, basename, getKey);
8698
9340
  savedScrollPositions[key] = window.scrollY;
8699
9341
  }
8700
9342
  try {
@@ -8709,7 +9351,7 @@ function useScrollRestoration({
8709
9351
  );
8710
9352
  }
8711
9353
  window.history.scrollRestoration = "auto";
8712
- }, [navigation.state, getKey, basename, location2, matches, storageKey])
9354
+ }, [navigation.state, getKey, basename, location, matches, storageKey])
8713
9355
  );
8714
9356
  if (typeof document !== "undefined") {
8715
9357
  React10.useLayoutEffect(() => {
@@ -8727,7 +9369,7 @@ function useScrollRestoration({
8727
9369
  let disableScrollRestoration = router?.enableScrollRestoration(
8728
9370
  savedScrollPositions,
8729
9371
  () => window.scrollY,
8730
- getKey ? (location3, matches2) => getScrollRestorationKey(location3, matches2, basename, getKey) : void 0
9372
+ getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
8731
9373
  );
8732
9374
  return () => disableScrollRestoration && disableScrollRestoration();
8733
9375
  }, [router, basename, getKey]);
@@ -8739,9 +9381,9 @@ function useScrollRestoration({
8739
9381
  window.scrollTo(0, restoreScrollPosition);
8740
9382
  return;
8741
9383
  }
8742
- if (location2.hash) {
9384
+ if (location.hash) {
8743
9385
  let el = document.getElementById(
8744
- decodeURIComponent(location2.hash.slice(1))
9386
+ decodeURIComponent(location.hash.slice(1))
8745
9387
  );
8746
9388
  if (el) {
8747
9389
  el.scrollIntoView();
@@ -8752,7 +9394,7 @@ function useScrollRestoration({
8752
9394
  return;
8753
9395
  }
8754
9396
  window.scrollTo(0, 0);
8755
- }, [location2, restoreScrollPosition, preventScrollReset]);
9397
+ }, [location, restoreScrollPosition, preventScrollReset]);
8756
9398
  }
8757
9399
  }
8758
9400
  function useBeforeUnload(callback, options) {
@@ -8825,7 +9467,7 @@ function StaticRouter({
8825
9467
  locationProp = parsePath(locationProp);
8826
9468
  }
8827
9469
  let action = "POP" /* Pop */;
8828
- let location2 = {
9470
+ let location = {
8829
9471
  pathname: locationProp.pathname || "/",
8830
9472
  search: locationProp.search || "",
8831
9473
  hash: locationProp.hash || "",
@@ -8838,7 +9480,7 @@ function StaticRouter({
8838
9480
  {
8839
9481
  basename,
8840
9482
  children,
8841
- location: location2,
9483
+ location,
8842
9484
  navigationType: action,
8843
9485
  navigator: staticNavigator,
8844
9486
  static: true
@@ -8848,7 +9490,7 @@ function StaticRouter({
8848
9490
  function StaticRouterProvider({
8849
9491
  context,
8850
9492
  router,
8851
- hydrate = true,
9493
+ hydrate: hydrate2 = true,
8852
9494
  nonce
8853
9495
  }) {
8854
9496
  invariant(
@@ -8864,7 +9506,7 @@ function StaticRouterProvider({
8864
9506
  };
8865
9507
  let fetchersContext = /* @__PURE__ */ new Map();
8866
9508
  let hydrateScript = "";
8867
- if (hydrate !== false) {
9509
+ if (hydrate2 !== false) {
8868
9510
  let data2 = {
8869
9511
  loaderData: context.loaderData,
8870
9512
  actionData: context.actionData,
@@ -9057,9 +9699,6 @@ function createStaticRouter(routes, context, opts = {}) {
9057
9699
  _internalFetchControllers: /* @__PURE__ */ new Map(),
9058
9700
  _internalSetRoutes() {
9059
9701
  throw msg("_internalSetRoutes");
9060
- },
9061
- _internalSetStateDoNotUseOrYouWillBreakYourApp() {
9062
- throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
9063
9702
  }
9064
9703
  };
9065
9704
  }
@@ -9134,6 +9773,7 @@ function ServerRouter({
9134
9773
  future: context.future,
9135
9774
  ssr: context.ssr,
9136
9775
  isSpaMode: context.isSpaMode,
9776
+ routeDiscovery: context.routeDiscovery,
9137
9777
  serializeError: context.serializeError,
9138
9778
  renderMeta: context.renderMeta
9139
9779
  }
@@ -9183,7 +9823,8 @@ function createRoutesStub(routes, unstable_getContext) {
9183
9823
  },
9184
9824
  routeModules: {},
9185
9825
  ssr: false,
9186
- isSpaMode: false
9826
+ isSpaMode: false,
9827
+ routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }
9187
9828
  };
9188
9829
  let patched = processRoutes(
9189
9830
  // @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
@@ -9267,7 +9908,7 @@ function processRoutes(routes, manifest, routeModules, parentId) {
9267
9908
  import { parse, serialize } from "cookie";
9268
9909
 
9269
9910
  // lib/server-runtime/crypto.ts
9270
- var encoder = new TextEncoder();
9911
+ var encoder = /* @__PURE__ */ new TextEncoder();
9271
9912
  var sign = async (value, secret) => {
9272
9913
  let data2 = encoder.encode(value);
9273
9914
  let key = await createKey2(secret, ["sign"]);
@@ -9587,6 +10228,26 @@ function invariant3(value, message) {
9587
10228
  }
9588
10229
  }
9589
10230
 
10231
+ // lib/server-runtime/dev.ts
10232
+ var globalDevServerHooksKey = "__reactRouterDevServerHooks";
10233
+ function setDevServerHooks(devServerHooks) {
10234
+ globalThis[globalDevServerHooksKey] = devServerHooks;
10235
+ }
10236
+ function getDevServerHooks() {
10237
+ return globalThis[globalDevServerHooksKey];
10238
+ }
10239
+ function getBuildTimeHeader(request, headerName) {
10240
+ if (typeof process !== "undefined") {
10241
+ try {
10242
+ if (process.env?.IS_RR_BUILD_REQUEST === "yes") {
10243
+ return request.headers.get(headerName);
10244
+ }
10245
+ } catch (e) {
10246
+ }
10247
+ }
10248
+ return null;
10249
+ }
10250
+
9590
10251
  // lib/server-runtime/routes.ts
9591
10252
  function groupRoutesByParentId2(manifest) {
9592
10253
  let routes = {};
@@ -9618,10 +10279,11 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
9618
10279
  // Need to use RR's version in the param typed here to permit the optional
9619
10280
  // context even though we know it'll always be provided in remix
9620
10281
  loader: route.module.loader ? async (args) => {
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
- );
10282
+ let preRenderedData = getBuildTimeHeader(
10283
+ args.request,
10284
+ "X-React-Router-Prerender-Data"
10285
+ );
10286
+ if (preRenderedData != null) {
9625
10287
  let encoded = preRenderedData ? decodeURI(preRenderedData) : preRenderedData;
9626
10288
  invariant3(encoded, "Missing prerendered data for route");
9627
10289
  let uint8array = new TextEncoder().encode(encoded);
@@ -9696,21 +10358,9 @@ function createServerHandoffString(serverHandoff) {
9696
10358
  return escapeHtml2(JSON.stringify(serverHandoff));
9697
10359
  }
9698
10360
 
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
-
9708
- // lib/server-runtime/single-fetch.ts
9709
- import { encode } from "turbo-stream";
9710
-
9711
10361
  // lib/server-runtime/headers.ts
9712
10362
  import { splitCookiesString } from "set-cookie-parser";
9713
- function getDocumentHeaders(context, getRouteHeadersFn) {
10363
+ function getDocumentHeaders(build, context) {
9714
10364
  let boundaryIdx = context.errors ? context.matches.findIndex((m) => context.errors[m.route.id]) : -1;
9715
10365
  let matches = boundaryIdx >= 0 ? context.matches.slice(0, boundaryIdx + 1) : context.matches;
9716
10366
  let errorHeaders;
@@ -9728,12 +10378,14 @@ function getDocumentHeaders(context, getRouteHeadersFn) {
9728
10378
  }
9729
10379
  return matches.reduce((parentHeaders, match, idx) => {
9730
10380
  let { id } = match.route;
10381
+ let route = build.routes[id];
10382
+ invariant3(route, `Route with id "${id}" not found in build`);
10383
+ let routeModule = route.module;
9731
10384
  let loaderHeaders = context.loaderHeaders[id] || new Headers();
9732
10385
  let actionHeaders = context.actionHeaders[id] || new Headers();
9733
10386
  let includeErrorHeaders = errorHeaders != null && idx === matches.length - 1;
9734
10387
  let includeErrorCookies = includeErrorHeaders && errorHeaders !== loaderHeaders && errorHeaders !== actionHeaders;
9735
- let headersFn = getRouteHeadersFn(match);
9736
- if (headersFn == null) {
10388
+ if (routeModule.headers == null) {
9737
10389
  let headers2 = new Headers(parentHeaders);
9738
10390
  if (includeErrorCookies) {
9739
10391
  prependCookies(errorHeaders, headers2);
@@ -9743,12 +10395,12 @@ function getDocumentHeaders(context, getRouteHeadersFn) {
9743
10395
  return headers2;
9744
10396
  }
9745
10397
  let headers = new Headers(
9746
- typeof headersFn === "function" ? headersFn({
10398
+ routeModule.headers ? typeof routeModule.headers === "function" ? routeModule.headers({
9747
10399
  loaderHeaders,
9748
10400
  parentHeaders,
9749
10401
  actionHeaders,
9750
10402
  errorHeaders: includeErrorHeaders ? errorHeaders : void 0
9751
- }) : headersFn
10403
+ }) : routeModule.headers : void 0
9752
10404
  );
9753
10405
  if (includeErrorCookies) {
9754
10406
  prependCookies(errorHeaders, headers);
@@ -9773,7 +10425,6 @@ function prependCookies(parentHeaders, childHeaders) {
9773
10425
  }
9774
10426
 
9775
10427
  // lib/server-runtime/single-fetch.ts
9776
- var SINGLE_FETCH_REDIRECT_STATUS = 202;
9777
10428
  var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
9778
10429
  ...NO_BODY_STATUS_CODES,
9779
10430
  304
@@ -9781,10 +10432,7 @@ var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
9781
10432
  async function singleFetchAction(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
9782
10433
  try {
9783
10434
  let respond2 = function(context) {
9784
- let headers = getDocumentHeaders(
9785
- context,
9786
- (m) => build.routes[m.route.id]?.module.headers
9787
- );
10435
+ let headers = getDocumentHeaders(build, context);
9788
10436
  if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
9789
10437
  return generateSingleFetchResponse(request, build, serverMode, {
9790
10438
  result: getSingleFetchRedirect(
@@ -9859,10 +10507,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
9859
10507
  async function singleFetchLoaders(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
9860
10508
  try {
9861
10509
  let respond2 = function(context) {
9862
- let headers = getDocumentHeaders(
9863
- context,
9864
- (m) => build.routes[m.route.id]?.module.headers
9865
- );
10510
+ let headers = getDocumentHeaders(build, context);
9866
10511
  if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
9867
10512
  return generateSingleFetchResponse(request, build, serverMode, {
9868
10513
  result: {
@@ -10118,9 +10763,10 @@ Error: ${e instanceof Error ? e.toString() : e}`
10118
10763
  if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
10119
10764
  normalizedPath = normalizedPath.slice(0, -1);
10120
10765
  }
10766
+ let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
10121
10767
  if (!_build.ssr) {
10122
10768
  if (_build.prerender.length === 0) {
10123
- request.headers.set("X-React-Router-SPA-Mode", "yes");
10769
+ isSpaMode = true;
10124
10770
  } else if (!_build.prerender.includes(normalizedPath) && !_build.prerender.includes(normalizedPath + "/")) {
10125
10771
  if (url.pathname.endsWith(".data")) {
10126
10772
  errorHandler(
@@ -10140,11 +10786,14 @@ Error: ${e instanceof Error ? e.toString() : e}`
10140
10786
  statusText: "Not Found"
10141
10787
  });
10142
10788
  } else {
10143
- request.headers.set("X-React-Router-SPA-Mode", "yes");
10789
+ isSpaMode = true;
10144
10790
  }
10145
10791
  }
10146
10792
  }
10147
- let manifestUrl = `${normalizedBasename}/__manifest`.replace(/\/+/g, "/");
10793
+ let manifestUrl = getManifestPath(
10794
+ _build.routeDiscovery.manifestPath,
10795
+ normalizedBasename
10796
+ );
10148
10797
  if (url.pathname === manifestUrl) {
10149
10798
  try {
10150
10799
  let res = await handleManifestRequest(_build, routes, url);
@@ -10154,7 +10803,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
10154
10803
  return new Response("Unknown Server Error", { status: 500 });
10155
10804
  }
10156
10805
  }
10157
- let matches = matchServerRoutes(routes, url.pathname, _build.basename);
10806
+ let matches = matchServerRoutes(routes, normalizedPath, _build.basename);
10158
10807
  if (matches && matches.length > 0) {
10159
10808
  Object.assign(params, matches[0].params);
10160
10809
  }
@@ -10209,7 +10858,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
10209
10858
  );
10210
10859
  }
10211
10860
  }
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) {
10861
+ } else if (!isSpaMode && matches && matches[matches.length - 1].route.module.default == null && matches[matches.length - 1].route.module.ErrorBoundary == null) {
10213
10862
  response = await handleResourceRequest(
10214
10863
  serverMode,
10215
10864
  _build,
@@ -10234,6 +10883,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
10234
10883
  request,
10235
10884
  loadContext,
10236
10885
  handleError,
10886
+ isSpaMode,
10237
10887
  criticalCss
10238
10888
  );
10239
10889
  }
@@ -10309,8 +10959,7 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
10309
10959
  );
10310
10960
  return response;
10311
10961
  }
10312
- async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, criticalCss) {
10313
- let isSpaMode = request.headers.has("X-React-Router-SPA-Mode");
10962
+ async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, isSpaMode, criticalCss) {
10314
10963
  try {
10315
10964
  let response = await staticHandler.query(request, {
10316
10965
  requestContext: loadContext,
@@ -10325,10 +10974,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
10325
10974
  if (isResponse(context)) {
10326
10975
  return context;
10327
10976
  }
10328
- let headers = getDocumentHeaders(
10329
- context,
10330
- (m) => build.routes[m.route.id]?.module.headers
10331
- );
10977
+ let headers = getDocumentHeaders(build, context);
10332
10978
  if (SERVER_NO_BODY_STATUS_CODES.has(context.statusCode)) {
10333
10979
  return new Response(null, { status: context.statusCode, headers });
10334
10980
  }
@@ -10345,17 +10991,21 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
10345
10991
  actionData: context.actionData,
10346
10992
  errors: serializeErrors2(context.errors, serverMode)
10347
10993
  };
10994
+ let baseServerHandoff = {
10995
+ basename: build.basename,
10996
+ future: build.future,
10997
+ routeDiscovery: build.routeDiscovery,
10998
+ ssr: build.ssr,
10999
+ isSpaMode: isSpaMode2
11000
+ };
10348
11001
  let entryContext = {
10349
11002
  manifest: build.assets,
10350
11003
  routeModules: createEntryRouteModules(build.routes),
10351
11004
  staticHandlerContext: context,
10352
11005
  criticalCss,
10353
11006
  serverHandoffString: createServerHandoffString({
10354
- basename: build.basename,
10355
- criticalCss,
10356
- future: build.future,
10357
- ssr: build.ssr,
10358
- isSpaMode: isSpaMode2
11007
+ ...baseServerHandoff,
11008
+ criticalCss
10359
11009
  }),
10360
11010
  serverHandoffStream: encodeViaTurboStream(
10361
11011
  state,
@@ -10366,6 +11016,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
10366
11016
  renderMeta: {},
10367
11017
  future: build.future,
10368
11018
  ssr: build.ssr,
11019
+ routeDiscovery: build.routeDiscovery,
10369
11020
  isSpaMode: isSpaMode2,
10370
11021
  serializeError: (err) => serializeError(err, serverMode)
10371
11022
  };
@@ -10408,12 +11059,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
10408
11059
  entryContext = {
10409
11060
  ...entryContext,
10410
11061
  staticHandlerContext: context,
10411
- serverHandoffString: createServerHandoffString({
10412
- basename: build.basename,
10413
- future: build.future,
10414
- ssr: build.ssr,
10415
- isSpaMode: isSpaMode2
10416
- }),
11062
+ serverHandoffString: createServerHandoffString(baseServerHandoff),
10417
11063
  serverHandoffStream: encodeViaTurboStream(
10418
11064
  state2,
10419
11065
  request.signal,
@@ -10586,7 +11232,7 @@ function createSessionStorage({
10586
11232
  function warnOnceAboutSigningSessionCookie(cookie) {
10587
11233
  warnOnce(
10588
11234
  cookie.isSigned,
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.`
11235
+ `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://reactrouter.com/explanation/sessions-and-cookies#signing-cookies for more information.`
10590
11236
  );
10591
11237
  }
10592
11238
 
@@ -10666,680 +11312,6 @@ function href(path, ...args) {
10666
11312
  }).filter((segment) => segment !== void 0).join("/");
10667
11313
  }
10668
11314
 
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
-
11343
11315
  // lib/dom/ssr/errors.ts
11344
11316
  function deserializeErrors2(errors) {
11345
11317
  if (!errors) return null;
@@ -11377,6 +11349,32 @@ function deserializeErrors2(errors) {
11377
11349
  return serialized;
11378
11350
  }
11379
11351
 
11352
+ // lib/dom/ssr/hydration.tsx
11353
+ function getHydrationData(state, routes, getRouteInfo, location, basename, isSpaMode) {
11354
+ let hydrationData = {
11355
+ ...state,
11356
+ loaderData: { ...state.loaderData }
11357
+ };
11358
+ let initialMatches = matchRoutes(routes, location, basename);
11359
+ if (initialMatches) {
11360
+ for (let match of initialMatches) {
11361
+ let routeId = match.route.id;
11362
+ let routeInfo = getRouteInfo(routeId);
11363
+ if (shouldHydrateRouteLoader(
11364
+ routeId,
11365
+ routeInfo.clientLoader,
11366
+ routeInfo.hasLoader,
11367
+ isSpaMode
11368
+ ) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
11369
+ delete hydrationData.loaderData[routeId];
11370
+ } else if (!routeInfo.hasLoader) {
11371
+ hydrationData.loaderData[routeId] = null;
11372
+ }
11373
+ }
11374
+ }
11375
+ return hydrationData;
11376
+ }
11377
+
11380
11378
  export {
11381
11379
  Action,
11382
11380
  createBrowserHistory,
@@ -11438,9 +11436,6 @@ export {
11438
11436
  Router,
11439
11437
  Routes,
11440
11438
  Await,
11441
- WithRouteComponentProps,
11442
- WithHydrateFallbackProps,
11443
- WithErrorBoundaryProps,
11444
11439
  createRoutesFromChildren,
11445
11440
  createRoutesFromElements,
11446
11441
  renderMatches,
@@ -11495,11 +11490,6 @@ export {
11495
11490
  createCookieSessionStorage,
11496
11491
  createMemorySessionStorage,
11497
11492
  href,
11498
- getHydrationData,
11499
- createCallServer,
11500
- RSCHydratedRouter,
11501
- routeRSCServerRequest,
11502
- RSCStaticRouter,
11503
- getServerStream,
11504
- deserializeErrors2 as deserializeErrors
11493
+ deserializeErrors2 as deserializeErrors,
11494
+ getHydrationData
11505
11495
  };