react-router 0.0.0-experimental-a6d1d1d4e → 0.0.0-experimental-1d760f6a6

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 (44) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/development/{chunk-OEAMHMGQ.mjs → chunk-QBMD7MNB.mjs} +293 -1025
  3. package/dist/development/dom-export.d.mts +2 -2
  4. package/dist/development/dom-export.d.ts +2 -2
  5. package/dist/development/dom-export.js +69 -103
  6. package/dist/development/dom-export.mjs +2 -2
  7. package/dist/development/{fog-of-war-DrUCUQQ-.d.ts → fog-of-war-BLArG-qZ.d.ts} +81 -168
  8. package/dist/{production/fog-of-war-C5L_Yd5M.d.mts → development/fog-of-war-D2zsXvum.d.mts} +81 -168
  9. package/dist/development/index.d.mts +8 -15
  10. package/dist/development/index.d.ts +8 -15
  11. package/dist/development/index.js +291 -1032
  12. package/dist/development/index.mjs +2 -19
  13. package/dist/development/lib/types/route-module.d.mts +1 -1
  14. package/dist/development/lib/types/route-module.d.ts +1 -1
  15. package/dist/development/lib/types/route-module.js +1 -1
  16. package/dist/development/lib/types/route-module.mjs +1 -1
  17. package/dist/development/{route-data-BIYebJr3.d.ts → route-data-C12CLHiN.d.mts} +1 -11
  18. package/dist/{production/route-data-BIYebJr3.d.mts → development/route-data-C12CLHiN.d.ts} +1 -11
  19. package/dist/production/{chunk-I2N4LFMP.mjs → chunk-DSJGM2GU.mjs} +293 -1025
  20. package/dist/production/dom-export.d.mts +2 -2
  21. package/dist/production/dom-export.d.ts +2 -2
  22. package/dist/production/dom-export.js +69 -103
  23. package/dist/production/dom-export.mjs +2 -2
  24. package/dist/production/{fog-of-war-DrUCUQQ-.d.ts → fog-of-war-BLArG-qZ.d.ts} +81 -168
  25. package/dist/{development/fog-of-war-C5L_Yd5M.d.mts → production/fog-of-war-D2zsXvum.d.mts} +81 -168
  26. package/dist/production/index.d.mts +8 -15
  27. package/dist/production/index.d.ts +8 -15
  28. package/dist/production/index.js +291 -1032
  29. package/dist/production/index.mjs +2 -19
  30. package/dist/production/lib/types/route-module.d.mts +1 -1
  31. package/dist/production/lib/types/route-module.d.ts +1 -1
  32. package/dist/production/lib/types/route-module.js +1 -1
  33. package/dist/production/lib/types/route-module.mjs +1 -1
  34. package/dist/production/{route-data-BIYebJr3.d.ts → route-data-C12CLHiN.d.mts} +1 -11
  35. package/dist/{development/route-data-BIYebJr3.d.mts → production/route-data-C12CLHiN.d.ts} +1 -11
  36. package/package.json +2 -33
  37. package/dist/development/rsc-export.d.mts +0 -1553
  38. package/dist/development/rsc-export.d.ts +0 -1553
  39. package/dist/development/rsc-export.js +0 -2413
  40. package/dist/development/rsc-export.mjs +0 -2385
  41. package/dist/production/rsc-export.d.mts +0 -1553
  42. package/dist/production/rsc-export.d.ts +0 -1553
  43. package/dist/production/rsc-export.js +0 -2413
  44. package/dist/production/rsc-export.mjs +0 -2385
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-a6d1d1d4e
2
+ * react-router v0.0.0-experimental-1d760f6a6
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,11 +296,11 @@ 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 });
@@ -413,7 +413,7 @@ function isUnsupportedLazyRouteFunctionKey(key) {
413
413
  function isIndexRoute(route) {
414
414
  return route.index === true;
415
415
  }
416
- function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}, allowInPlaceMutations = false) {
416
+ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}) {
417
417
  return routes.map((route, index) => {
418
418
  let treePath = [...parentPath, String(index)];
419
419
  let id = typeof route.id === "string" ? route.id : treePath.join("-");
@@ -422,7 +422,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
422
422
  `Cannot specify children on an index route`
423
423
  );
424
424
  invariant(
425
- allowInPlaceMutations || !manifest[id],
425
+ !manifest[id],
426
426
  `Found a route id collision on id "${id}". Route id's must be globally unique within Data Router usages`
427
427
  );
428
428
  if (isIndexRoute(route)) {
@@ -446,8 +446,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
446
446
  route.children,
447
447
  mapRouteProperties2,
448
448
  treePath,
449
- manifest,
450
- allowInPlaceMutations
449
+ manifest
451
450
  );
452
451
  }
453
452
  return pathOrLayoutRoute;
@@ -458,8 +457,8 @@ function matchRoutes(routes, locationArg, basename = "/") {
458
457
  return matchRoutesImpl(routes, locationArg, basename, false);
459
458
  }
460
459
  function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
461
- let location2 = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
462
- let pathname = stripBasename(location2.pathname || "/", basename);
460
+ let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
461
+ let pathname = stripBasename(location.pathname || "/", basename);
463
462
  if (pathname == null) {
464
463
  return null;
465
464
  }
@@ -1063,7 +1062,7 @@ function createRouter(init) {
1063
1062
  let pendingRevalidationDfd = null;
1064
1063
  function initialize() {
1065
1064
  unlistenHistory = init.history.listen(
1066
- ({ action: historyAction, location: location2, delta }) => {
1065
+ ({ action: historyAction, location, delta }) => {
1067
1066
  if (unblockBlockerHistoryUpdate) {
1068
1067
  unblockBlockerHistoryUpdate();
1069
1068
  unblockBlockerHistoryUpdate = void 0;
@@ -1075,7 +1074,7 @@ function createRouter(init) {
1075
1074
  );
1076
1075
  let blockerKey = shouldBlockNavigation({
1077
1076
  currentLocation: state.location,
1078
- nextLocation: location2,
1077
+ nextLocation: location,
1079
1078
  historyAction
1080
1079
  });
1081
1080
  if (blockerKey && delta != null) {
@@ -1085,13 +1084,13 @@ function createRouter(init) {
1085
1084
  init.history.go(delta * -1);
1086
1085
  updateBlocker(blockerKey, {
1087
1086
  state: "blocked",
1088
- location: location2,
1087
+ location,
1089
1088
  proceed() {
1090
1089
  updateBlocker(blockerKey, {
1091
1090
  state: "proceeding",
1092
1091
  proceed: void 0,
1093
1092
  reset: void 0,
1094
- location: location2
1093
+ location
1095
1094
  });
1096
1095
  nextHistoryUpdatePromise.then(() => init.history.go(delta));
1097
1096
  },
@@ -1103,7 +1102,7 @@ function createRouter(init) {
1103
1102
  });
1104
1103
  return;
1105
1104
  }
1106
- return startNavigation(historyAction, location2);
1105
+ return startNavigation(historyAction, location);
1107
1106
  }
1108
1107
  );
1109
1108
  if (isBrowser2) {
@@ -1136,19 +1135,6 @@ function createRouter(init) {
1136
1135
  return () => subscribers.delete(fn);
1137
1136
  }
1138
1137
  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
1138
  state = {
1153
1139
  ...state,
1154
1140
  ...newState
@@ -1179,8 +1165,8 @@ function createRouter(init) {
1179
1165
  unmountedFetchers.forEach((key) => deleteFetcher(key));
1180
1166
  mountedFetchers.forEach((key) => state.fetchers.delete(key));
1181
1167
  }
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;
1168
+ function completeNavigation(location, newState, { flushSync } = {}) {
1169
+ let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && location.state?._isRedirect !== true;
1184
1170
  let actionData;
1185
1171
  if (newState.actionData) {
1186
1172
  if (Object.keys(newState.actionData).length > 0) {
@@ -1204,7 +1190,7 @@ function createRouter(init) {
1204
1190
  blockers = new Map(blockers);
1205
1191
  blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));
1206
1192
  }
1207
- let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location2.state?._isRedirect !== true;
1193
+ let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location.state?._isRedirect !== true;
1208
1194
  if (inFlightDataRoutes) {
1209
1195
  dataRoutes = inFlightDataRoutes;
1210
1196
  inFlightDataRoutes = void 0;
@@ -1212,35 +1198,35 @@ function createRouter(init) {
1212
1198
  if (isUninterruptedRevalidation) {
1213
1199
  } else if (pendingAction === "POP" /* Pop */) {
1214
1200
  } else if (pendingAction === "PUSH" /* Push */) {
1215
- init.history.push(location2, location2.state);
1201
+ init.history.push(location, location.state);
1216
1202
  } else if (pendingAction === "REPLACE" /* Replace */) {
1217
- init.history.replace(location2, location2.state);
1203
+ init.history.replace(location, location.state);
1218
1204
  }
1219
1205
  let viewTransitionOpts;
1220
1206
  if (pendingAction === "POP" /* Pop */) {
1221
1207
  let priorPaths = appliedViewTransitions.get(state.location.pathname);
1222
- if (priorPaths && priorPaths.has(location2.pathname)) {
1208
+ if (priorPaths && priorPaths.has(location.pathname)) {
1223
1209
  viewTransitionOpts = {
1224
1210
  currentLocation: state.location,
1225
- nextLocation: location2
1211
+ nextLocation: location
1226
1212
  };
1227
- } else if (appliedViewTransitions.has(location2.pathname)) {
1213
+ } else if (appliedViewTransitions.has(location.pathname)) {
1228
1214
  viewTransitionOpts = {
1229
- currentLocation: location2,
1215
+ currentLocation: location,
1230
1216
  nextLocation: state.location
1231
1217
  };
1232
1218
  }
1233
1219
  } else if (pendingViewTransitionEnabled) {
1234
1220
  let toPaths = appliedViewTransitions.get(state.location.pathname);
1235
1221
  if (toPaths) {
1236
- toPaths.add(location2.pathname);
1222
+ toPaths.add(location.pathname);
1237
1223
  } else {
1238
- toPaths = /* @__PURE__ */ new Set([location2.pathname]);
1224
+ toPaths = /* @__PURE__ */ new Set([location.pathname]);
1239
1225
  appliedViewTransitions.set(state.location.pathname, toPaths);
1240
1226
  }
1241
1227
  viewTransitionOpts = {
1242
1228
  currentLocation: state.location,
1243
- nextLocation: location2
1229
+ nextLocation: location
1244
1230
  };
1245
1231
  }
1246
1232
  updateState(
@@ -1250,12 +1236,12 @@ function createRouter(init) {
1250
1236
  actionData,
1251
1237
  loaderData,
1252
1238
  historyAction: pendingAction,
1253
- location: location2,
1239
+ location,
1254
1240
  initialized: true,
1255
1241
  navigation: IDLE_NAVIGATION,
1256
1242
  revalidation: "idle",
1257
1243
  restoreScrollPosition: getSavedScrollPosition(
1258
- location2,
1244
+ location,
1259
1245
  newState.matches || state.matches
1260
1246
  ),
1261
1247
  preventScrollReset,
@@ -1372,7 +1358,7 @@ function createRouter(init) {
1372
1358
  );
1373
1359
  return promise;
1374
1360
  }
1375
- async function startNavigation(historyAction, location2, opts) {
1361
+ async function startNavigation(historyAction, location, opts) {
1376
1362
  pendingNavigationController && pendingNavigationController.abort();
1377
1363
  pendingNavigationController = null;
1378
1364
  pendingAction = historyAction;
@@ -1385,22 +1371,22 @@ function createRouter(init) {
1385
1371
  let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
1386
1372
  // `matchRoutes()` has already been called if we're in here via `router.initialize()`
1387
1373
  state.matches
1388
- ) : matchRoutes(routesToUse, location2, basename);
1374
+ ) : matchRoutes(routesToUse, location, basename);
1389
1375
  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 });
1376
+ if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1377
+ completeNavigation(location, { matches }, { flushSync });
1392
1378
  return;
1393
1379
  }
1394
- let fogOfWar = checkFogOfWar(matches, routesToUse, location2.pathname);
1380
+ let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
1395
1381
  if (fogOfWar.active && fogOfWar.matches) {
1396
1382
  matches = fogOfWar.matches;
1397
1383
  }
1398
1384
  if (!matches) {
1399
1385
  let { error, notFoundMatches, route } = handleNavigational404(
1400
- location2.pathname
1386
+ location.pathname
1401
1387
  );
1402
1388
  completeNavigation(
1403
- location2,
1389
+ location,
1404
1390
  {
1405
1391
  matches: notFoundMatches,
1406
1392
  loaderData: {},
@@ -1415,7 +1401,7 @@ function createRouter(init) {
1415
1401
  pendingNavigationController = new AbortController();
1416
1402
  let request = createClientSideRequest(
1417
1403
  init.history,
1418
- location2,
1404
+ location,
1419
1405
  pendingNavigationController.signal,
1420
1406
  opts && opts.submission
1421
1407
  );
@@ -1431,7 +1417,7 @@ function createRouter(init) {
1431
1417
  } else if (opts && opts.submission && isMutationMethod(opts.submission.formMethod)) {
1432
1418
  let actionResult = await handleAction(
1433
1419
  request,
1434
- location2,
1420
+ location,
1435
1421
  opts.submission,
1436
1422
  matches,
1437
1423
  scopedContext,
@@ -1446,7 +1432,7 @@ function createRouter(init) {
1446
1432
  let [routeId, result] = actionResult.pendingActionResult;
1447
1433
  if (isErrorResult(result) && isRouteErrorResponse(result.error) && result.error.status === 404) {
1448
1434
  pendingNavigationController = null;
1449
- completeNavigation(location2, {
1435
+ completeNavigation(location, {
1450
1436
  matches: actionResult.matches,
1451
1437
  loaderData: {},
1452
1438
  errors: {
@@ -1458,7 +1444,7 @@ function createRouter(init) {
1458
1444
  }
1459
1445
  matches = actionResult.matches || matches;
1460
1446
  pendingActionResult = actionResult.pendingActionResult;
1461
- loadingNavigation = getLoadingNavigation(location2, opts.submission);
1447
+ loadingNavigation = getLoadingNavigation(location, opts.submission);
1462
1448
  flushSync = false;
1463
1449
  fogOfWar.active = false;
1464
1450
  request = createClientSideRequest(
@@ -1474,7 +1460,7 @@ function createRouter(init) {
1474
1460
  errors
1475
1461
  } = await handleLoaders(
1476
1462
  request,
1477
- location2,
1463
+ location,
1478
1464
  matches,
1479
1465
  scopedContext,
1480
1466
  fogOfWar.active,
@@ -1490,21 +1476,21 @@ function createRouter(init) {
1490
1476
  return;
1491
1477
  }
1492
1478
  pendingNavigationController = null;
1493
- completeNavigation(location2, {
1479
+ completeNavigation(location, {
1494
1480
  matches: updatedMatches || matches,
1495
1481
  ...getActionDataForCommit(pendingActionResult),
1496
1482
  loaderData,
1497
1483
  errors
1498
1484
  });
1499
1485
  }
1500
- async function handleAction(request, location2, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
1486
+ async function handleAction(request, location, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
1501
1487
  interruptActiveLoads();
1502
- let navigation = getSubmittingNavigation(location2, submission);
1488
+ let navigation = getSubmittingNavigation(location, submission);
1503
1489
  updateState({ navigation }, { flushSync: opts.flushSync === true });
1504
1490
  if (isFogOfWar) {
1505
1491
  let discoverResult = await discoverRoutes(
1506
1492
  matches,
1507
- location2.pathname,
1493
+ location.pathname,
1508
1494
  request.signal
1509
1495
  );
1510
1496
  if (discoverResult.type === "aborted") {
@@ -1523,7 +1509,7 @@ function createRouter(init) {
1523
1509
  };
1524
1510
  } else if (!discoverResult.matches) {
1525
1511
  let { notFoundMatches, error, route } = handleNavigational404(
1526
- location2.pathname
1512
+ location.pathname
1527
1513
  );
1528
1514
  return {
1529
1515
  matches: notFoundMatches,
@@ -1540,13 +1526,13 @@ function createRouter(init) {
1540
1526
  }
1541
1527
  }
1542
1528
  let result;
1543
- let actionMatch = getTargetMatch(matches, location2);
1529
+ let actionMatch = getTargetMatch(matches, location);
1544
1530
  if (!actionMatch.route.action && !actionMatch.route.lazy) {
1545
1531
  result = {
1546
1532
  type: "error" /* error */,
1547
1533
  error: getInternalRouterError(405, {
1548
1534
  method: request.method,
1549
- pathname: location2.pathname,
1535
+ pathname: location.pathname,
1550
1536
  routeId: actionMatch.route.id
1551
1537
  })
1552
1538
  };
@@ -1584,12 +1570,12 @@ function createRouter(init) {
1584
1570
  if (opts && opts.replace != null) {
1585
1571
  replace2 = opts.replace;
1586
1572
  } else {
1587
- let location3 = normalizeRedirectLocation(
1573
+ let location2 = normalizeRedirectLocation(
1588
1574
  result.response.headers.get("Location"),
1589
1575
  new URL(request.url),
1590
1576
  basename
1591
1577
  );
1592
- replace2 = location3 === state.location.pathname + state.location.search;
1578
+ replace2 = location2 === state.location.pathname + state.location.search;
1593
1579
  }
1594
1580
  await startRedirectNavigation(request, result, true, {
1595
1581
  submission,
@@ -1612,8 +1598,8 @@ function createRouter(init) {
1612
1598
  pendingActionResult: [actionMatch.route.id, result]
1613
1599
  };
1614
1600
  }
1615
- async function handleLoaders(request, location2, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
1616
- let loadingNavigation = overrideNavigation || getLoadingNavigation(location2, submission);
1601
+ async function handleLoaders(request, location, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
1602
+ let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
1617
1603
  let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
1618
1604
  let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
1619
1605
  if (isFogOfWar) {
@@ -1631,7 +1617,7 @@ function createRouter(init) {
1631
1617
  }
1632
1618
  let discoverResult = await discoverRoutes(
1633
1619
  matches,
1634
- location2.pathname,
1620
+ location.pathname,
1635
1621
  request.signal
1636
1622
  );
1637
1623
  if (discoverResult.type === "aborted") {
@@ -1647,7 +1633,7 @@ function createRouter(init) {
1647
1633
  };
1648
1634
  } else if (!discoverResult.matches) {
1649
1635
  let { error, notFoundMatches, route } = handleNavigational404(
1650
- location2.pathname
1636
+ location.pathname
1651
1637
  );
1652
1638
  return {
1653
1639
  matches: notFoundMatches,
@@ -1670,7 +1656,7 @@ function createRouter(init) {
1670
1656
  state,
1671
1657
  matches,
1672
1658
  activeSubmission,
1673
- location2,
1659
+ location,
1674
1660
  initialHydration ? [] : hydrationRouteProperties2,
1675
1661
  initialHydration === true,
1676
1662
  isRevalidationRequired,
@@ -1686,7 +1672,7 @@ function createRouter(init) {
1686
1672
  if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && revalidatingFetchers.length === 0) {
1687
1673
  let updatedFetchers2 = markFetchRedirectsDone();
1688
1674
  completeNavigation(
1689
- location2,
1675
+ location,
1690
1676
  {
1691
1677
  matches,
1692
1678
  loaderData: {},
@@ -2197,31 +2183,31 @@ function createRouter(init) {
2197
2183
  if (redirect2.response.headers.has("X-Remix-Revalidate")) {
2198
2184
  isRevalidationRequired = true;
2199
2185
  }
2200
- let location2 = redirect2.response.headers.get("Location");
2201
- invariant(location2, "Expected a Location header on the redirect Response");
2202
- location2 = normalizeRedirectLocation(
2203
- location2,
2186
+ let location = redirect2.response.headers.get("Location");
2187
+ invariant(location, "Expected a Location header on the redirect Response");
2188
+ location = normalizeRedirectLocation(
2189
+ location,
2204
2190
  new URL(request.url),
2205
2191
  basename
2206
2192
  );
2207
- let redirectLocation = createLocation(state.location, location2, {
2193
+ let redirectLocation = createLocation(state.location, location, {
2208
2194
  _isRedirect: true
2209
2195
  });
2210
2196
  if (isBrowser2) {
2211
2197
  let isDocumentReload = false;
2212
2198
  if (redirect2.response.headers.has("X-Remix-Reload-Document")) {
2213
2199
  isDocumentReload = true;
2214
- } else if (ABSOLUTE_URL_REGEX.test(location2)) {
2215
- const url = init.history.createURL(location2);
2200
+ } else if (ABSOLUTE_URL_REGEX.test(location)) {
2201
+ const url = init.history.createURL(location);
2216
2202
  isDocumentReload = // Hard reload if it's an absolute URL to a new origin
2217
2203
  url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename
2218
2204
  stripBasename(url.pathname, basename) == null;
2219
2205
  }
2220
2206
  if (isDocumentReload) {
2221
2207
  if (replace2) {
2222
- routerWindow.location.replace(location2);
2208
+ routerWindow.location.replace(location);
2223
2209
  } else {
2224
- routerWindow.location.assign(location2);
2210
+ routerWindow.location.assign(location);
2225
2211
  }
2226
2212
  return;
2227
2213
  }
@@ -2237,7 +2223,7 @@ function createRouter(init) {
2237
2223
  await startNavigation(redirectNavigationType, redirectLocation, {
2238
2224
  submission: {
2239
2225
  ...activeSubmission,
2240
- formAction: location2
2226
+ formAction: location
2241
2227
  },
2242
2228
  // Preserve these flags across redirects
2243
2229
  preventScrollReset: preventScrollReset || pendingPreventScrollReset,
@@ -2508,25 +2494,25 @@ function createRouter(init) {
2508
2494
  getScrollRestorationKey2 = null;
2509
2495
  };
2510
2496
  }
2511
- function getScrollKey(location2, matches) {
2497
+ function getScrollKey(location, matches) {
2512
2498
  if (getScrollRestorationKey2) {
2513
2499
  let key = getScrollRestorationKey2(
2514
- location2,
2500
+ location,
2515
2501
  matches.map((m) => convertRouteMatchToUiMatch(m, state.loaderData))
2516
2502
  );
2517
- return key || location2.key;
2503
+ return key || location.key;
2518
2504
  }
2519
- return location2.key;
2505
+ return location.key;
2520
2506
  }
2521
- function saveScrollPosition(location2, matches) {
2507
+ function saveScrollPosition(location, matches) {
2522
2508
  if (savedScrollPositions2 && getScrollPosition) {
2523
- let key = getScrollKey(location2, matches);
2509
+ let key = getScrollKey(location, matches);
2524
2510
  savedScrollPositions2[key] = getScrollPosition();
2525
2511
  }
2526
2512
  }
2527
- function getSavedScrollPosition(location2, matches) {
2513
+ function getSavedScrollPosition(location, matches) {
2528
2514
  if (savedScrollPositions2) {
2529
- let key = getScrollKey(location2, matches);
2515
+ let key = getScrollKey(location, matches);
2530
2516
  let y = savedScrollPositions2[key];
2531
2517
  if (typeof y === "number") {
2532
2518
  return y;
@@ -2580,8 +2566,7 @@ function createRouter(init) {
2580
2566
  children,
2581
2567
  routesToUse,
2582
2568
  localManifest,
2583
- mapRouteProperties2,
2584
- false
2569
+ mapRouteProperties2
2585
2570
  );
2586
2571
  }
2587
2572
  });
@@ -2622,7 +2607,7 @@ function createRouter(init) {
2622
2607
  manifest
2623
2608
  );
2624
2609
  }
2625
- function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
2610
+ function patchRoutes(routeId, children) {
2626
2611
  let isNonHMR = inFlightDataRoutes == null;
2627
2612
  let routesToUse = inFlightDataRoutes || dataRoutes;
2628
2613
  patchRoutesImpl(
@@ -2630,8 +2615,7 @@ function createRouter(init) {
2630
2615
  children,
2631
2616
  routesToUse,
2632
2617
  manifest,
2633
- mapRouteProperties2,
2634
- unstable_allowElementMutations
2618
+ mapRouteProperties2
2635
2619
  );
2636
2620
  if (isNonHMR) {
2637
2621
  dataRoutes = [...dataRoutes];
@@ -2673,10 +2657,7 @@ function createRouter(init) {
2673
2657
  _internalFetchControllers: fetchControllers,
2674
2658
  // TODO: Remove setRoutes, it's temporary to avoid dealing with
2675
2659
  // updating the tree while validating the update algorithm.
2676
- _internalSetRoutes,
2677
- _internalSetStateDoNotUseOrYouWillBreakYourApp(newState) {
2678
- updateState(newState);
2679
- }
2660
+ _internalSetRoutes
2680
2661
  };
2681
2662
  return router;
2682
2663
  }
@@ -2704,15 +2685,15 @@ function createStaticHandler(routes, opts) {
2704
2685
  } = {}) {
2705
2686
  let url = new URL(request.url);
2706
2687
  let method = request.method;
2707
- let location2 = createLocation("", createPath(url), null, "default");
2708
- let matches = matchRoutes(dataRoutes, location2, basename);
2688
+ let location = createLocation("", createPath(url), null, "default");
2689
+ let matches = matchRoutes(dataRoutes, location, basename);
2709
2690
  requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
2710
2691
  if (!isValidMethod(method) && method !== "HEAD") {
2711
2692
  let error = getInternalRouterError(405, { method });
2712
2693
  let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
2713
2694
  let staticContext = {
2714
2695
  basename,
2715
- location: location2,
2696
+ location,
2716
2697
  matches: methodNotAllowedMatches,
2717
2698
  loaderData: {},
2718
2699
  actionData: null,
@@ -2725,11 +2706,11 @@ function createStaticHandler(routes, opts) {
2725
2706
  };
2726
2707
  return respond ? respond(staticContext) : staticContext;
2727
2708
  } else if (!matches) {
2728
- let error = getInternalRouterError(404, { pathname: location2.pathname });
2709
+ let error = getInternalRouterError(404, { pathname: location.pathname });
2729
2710
  let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
2730
2711
  let staticContext = {
2731
2712
  basename,
2732
- location: location2,
2713
+ location,
2733
2714
  matches: notFoundMatches,
2734
2715
  loaderData: {},
2735
2716
  actionData: null,
@@ -2769,7 +2750,7 @@ function createStaticHandler(routes, opts) {
2769
2750
  async () => {
2770
2751
  let result2 = await queryImpl(
2771
2752
  request,
2772
- location2,
2753
+ location,
2773
2754
  matches,
2774
2755
  requestContext,
2775
2756
  dataStrategy || null,
@@ -2781,7 +2762,7 @@ function createStaticHandler(routes, opts) {
2781
2762
  if (isResponse(result2)) {
2782
2763
  return result2;
2783
2764
  }
2784
- renderedStaticContext = { location: location2, basename, ...result2 };
2765
+ renderedStaticContext = { location, basename, ...result2 };
2785
2766
  let res = await respond(renderedStaticContext);
2786
2767
  return res;
2787
2768
  },
@@ -2806,7 +2787,7 @@ function createStaticHandler(routes, opts) {
2806
2787
  let boundary = loaderIdx >= 0 ? findNearestBoundary(matches, matches[loaderIdx].route.id) : findNearestBoundary(matches);
2807
2788
  return respond({
2808
2789
  matches,
2809
- location: location2,
2790
+ location,
2810
2791
  basename,
2811
2792
  loaderData: {},
2812
2793
  actionData: null,
@@ -2831,7 +2812,7 @@ function createStaticHandler(routes, opts) {
2831
2812
  }
2832
2813
  let result = await queryImpl(
2833
2814
  request,
2834
- location2,
2815
+ location,
2835
2816
  matches,
2836
2817
  requestContext,
2837
2818
  dataStrategy || null,
@@ -2843,7 +2824,7 @@ function createStaticHandler(routes, opts) {
2843
2824
  if (isResponse(result)) {
2844
2825
  return result;
2845
2826
  }
2846
- return { location: location2, basename, ...result };
2827
+ return { location, basename, ...result };
2847
2828
  }
2848
2829
  async function queryRoute(request, {
2849
2830
  routeId,
@@ -2853,22 +2834,22 @@ function createStaticHandler(routes, opts) {
2853
2834
  } = {}) {
2854
2835
  let url = new URL(request.url);
2855
2836
  let method = request.method;
2856
- let location2 = createLocation("", createPath(url), null, "default");
2857
- let matches = matchRoutes(dataRoutes, location2, basename);
2837
+ let location = createLocation("", createPath(url), null, "default");
2838
+ let matches = matchRoutes(dataRoutes, location, basename);
2858
2839
  requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
2859
2840
  if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
2860
2841
  throw getInternalRouterError(405, { method });
2861
2842
  } else if (!matches) {
2862
- throw getInternalRouterError(404, { pathname: location2.pathname });
2843
+ throw getInternalRouterError(404, { pathname: location.pathname });
2863
2844
  }
2864
- let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location2);
2845
+ let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location);
2865
2846
  if (routeId && !match) {
2866
2847
  throw getInternalRouterError(403, {
2867
- pathname: location2.pathname,
2848
+ pathname: location.pathname,
2868
2849
  routeId
2869
2850
  });
2870
2851
  } else if (!match) {
2871
- throw getInternalRouterError(404, { pathname: location2.pathname });
2852
+ throw getInternalRouterError(404, { pathname: location.pathname });
2872
2853
  }
2873
2854
  if (respond && matches.some(
2874
2855
  (m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
@@ -2891,7 +2872,7 @@ function createStaticHandler(routes, opts) {
2891
2872
  async () => {
2892
2873
  let result2 = await queryImpl(
2893
2874
  request,
2894
- location2,
2875
+ location,
2895
2876
  matches,
2896
2877
  requestContext,
2897
2878
  dataStrategy || null,
@@ -2924,7 +2905,7 @@ function createStaticHandler(routes, opts) {
2924
2905
  }
2925
2906
  let result = await queryImpl(
2926
2907
  request,
2927
- location2,
2908
+ location,
2928
2909
  matches,
2929
2910
  requestContext,
2930
2911
  dataStrategy || null,
@@ -2948,7 +2929,7 @@ function createStaticHandler(routes, opts) {
2948
2929
  }
2949
2930
  return void 0;
2950
2931
  }
2951
- async function queryImpl(request, location2, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
2932
+ async function queryImpl(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
2952
2933
  invariant(
2953
2934
  request.signal,
2954
2935
  "query()/queryRoute() requests must contain an AbortController signal"
@@ -2958,7 +2939,7 @@ function createStaticHandler(routes, opts) {
2958
2939
  let result2 = await submit(
2959
2940
  request,
2960
2941
  matches,
2961
- routeMatch || getTargetMatch(matches, location2),
2942
+ routeMatch || getTargetMatch(matches, location),
2962
2943
  requestContext,
2963
2944
  dataStrategy,
2964
2945
  skipLoaderErrorBubbling,
@@ -3274,7 +3255,7 @@ function throwStaticHandlerAbortedError(request, isRouteRequest) {
3274
3255
  function isSubmissionNavigation(opts) {
3275
3256
  return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0);
3276
3257
  }
3277
- function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
3258
+ function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
3278
3259
  let contextualMatches;
3279
3260
  let activeRouteMatch;
3280
3261
  if (fromRouteId) {
@@ -3293,12 +3274,12 @@ function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
3293
3274
  let path = resolveTo(
3294
3275
  to ? to : ".",
3295
3276
  getResolveToMatches(contextualMatches),
3296
- stripBasename(location2.pathname, basename) || location2.pathname,
3277
+ stripBasename(location.pathname, basename) || location.pathname,
3297
3278
  relative === "path"
3298
3279
  );
3299
3280
  if (to == null) {
3300
- path.search = location2.search;
3301
- path.hash = location2.hash;
3281
+ path.search = location.search;
3282
+ path.hash = location.hash;
3302
3283
  }
3303
3284
  if ((to == null || to === "" || to === ".") && activeRouteMatch) {
3304
3285
  let nakedIndex = hasNakedIndexQuery(path.search);
@@ -3425,10 +3406,10 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
3425
3406
  parsedPath.search = `?${searchParams}`;
3426
3407
  return { path: createPath(parsedPath), submission };
3427
3408
  }
3428
- function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location2, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
3409
+ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
3429
3410
  let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
3430
3411
  let currentUrl = history.createURL(state.location);
3431
- let nextUrl = history.createURL(location2);
3412
+ let nextUrl = history.createURL(location);
3432
3413
  let maxIdx;
3433
3414
  if (initialHydration && state.errors) {
3434
3415
  let boundaryId = Object.keys(state.errors)[0];
@@ -3627,7 +3608,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
3627
3608
  }
3628
3609
  return arg.defaultShouldRevalidate;
3629
3610
  }
3630
- function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
3611
+ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2) {
3631
3612
  let childrenToPatch;
3632
3613
  if (routeId) {
3633
3614
  let route = manifest[routeId];
@@ -3642,47 +3623,18 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
3642
3623
  } else {
3643
3624
  childrenToPatch = routesToUse;
3644
3625
  }
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
- }
3626
+ let uniqueChildren = children.filter(
3627
+ (newRoute) => !childrenToPatch.some(
3628
+ (existingRoute) => isSameRoute(newRoute, existingRoute)
3629
+ )
3630
+ );
3631
+ let newRoutes = convertRoutesToDataRoutes(
3632
+ uniqueChildren,
3633
+ mapRouteProperties2,
3634
+ [routeId || "_", "patch", String(childrenToPatch?.length || "0")],
3635
+ manifest
3636
+ );
3637
+ childrenToPatch.push(...newRoutes);
3686
3638
  }
3687
3639
  function isSameRoute(newRoute, existingRoute) {
3688
3640
  if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
@@ -4031,7 +3983,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, laz
4031
3983
  return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
4032
3984
  },
4033
3985
  resolve(handlerOverride) {
4034
- if (isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (match.route.lazy || match.route.loader)) {
3986
+ if (isUsingNewApi || shouldLoad || handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
4035
3987
  return callLoaderOrAction({
4036
3988
  request,
4037
3989
  match,
@@ -4291,39 +4243,39 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
4291
4243
  return { type: "data" /* data */, data: result };
4292
4244
  }
4293
4245
  function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename) {
4294
- let location2 = response.headers.get("Location");
4246
+ let location = response.headers.get("Location");
4295
4247
  invariant(
4296
- location2,
4248
+ location,
4297
4249
  "Redirects returned/thrown from loaders/actions must have a Location header"
4298
4250
  );
4299
- if (!ABSOLUTE_URL_REGEX.test(location2)) {
4251
+ if (!ABSOLUTE_URL_REGEX.test(location)) {
4300
4252
  let trimmedMatches = matches.slice(
4301
4253
  0,
4302
4254
  matches.findIndex((m) => m.route.id === routeId) + 1
4303
4255
  );
4304
- location2 = normalizeTo(
4256
+ location = normalizeTo(
4305
4257
  new URL(request.url),
4306
4258
  trimmedMatches,
4307
4259
  basename,
4308
- location2
4260
+ location
4309
4261
  );
4310
- response.headers.set("Location", location2);
4262
+ response.headers.set("Location", location);
4311
4263
  }
4312
4264
  return response;
4313
4265
  }
4314
- function normalizeRedirectLocation(location2, currentUrl, basename) {
4315
- if (ABSOLUTE_URL_REGEX.test(location2)) {
4316
- let normalizedLocation = location2;
4266
+ function normalizeRedirectLocation(location, currentUrl, basename) {
4267
+ if (ABSOLUTE_URL_REGEX.test(location)) {
4268
+ let normalizedLocation = location;
4317
4269
  let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
4318
4270
  let isSameBasename = stripBasename(url.pathname, basename) != null;
4319
4271
  if (url.origin === currentUrl.origin && isSameBasename) {
4320
4272
  return url.pathname + url.search + url.hash;
4321
4273
  }
4322
4274
  }
4323
- return location2;
4275
+ return location;
4324
4276
  }
4325
- function createClientSideRequest(history, location2, signal, submission) {
4326
- let url = history.createURL(stripHashFromPath(location2)).toString();
4277
+ function createClientSideRequest(history, location, signal, submission) {
4278
+ let url = history.createURL(stripHashFromPath(location)).toString();
4327
4279
  let init = { signal };
4328
4280
  if (submission && isMutationMethod(submission.formMethod)) {
4329
4281
  let { formMethod, formEncType } = submission;
@@ -4593,8 +4545,8 @@ function isMutationMethod(method) {
4593
4545
  function hasNakedIndexQuery(search) {
4594
4546
  return new URLSearchParams(search).getAll("index").some((v) => v === "");
4595
4547
  }
4596
- function getTargetMatch(matches, location2) {
4597
- let search = typeof location2 === "string" ? parsePath(location2).search : location2.search;
4548
+ function getTargetMatch(matches, location) {
4549
+ let search = typeof location === "string" ? parsePath(location).search : location.search;
4598
4550
  if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
4599
4551
  return matches[matches.length - 1];
4600
4552
  }
@@ -4635,11 +4587,11 @@ function getSubmissionFromNavigation(navigation) {
4635
4587
  };
4636
4588
  }
4637
4589
  }
4638
- function getLoadingNavigation(location2, submission) {
4590
+ function getLoadingNavigation(location, submission) {
4639
4591
  if (submission) {
4640
4592
  let navigation = {
4641
4593
  state: "loading",
4642
- location: location2,
4594
+ location,
4643
4595
  formMethod: submission.formMethod,
4644
4596
  formAction: submission.formAction,
4645
4597
  formEncType: submission.formEncType,
@@ -4651,7 +4603,7 @@ function getLoadingNavigation(location2, submission) {
4651
4603
  } else {
4652
4604
  let navigation = {
4653
4605
  state: "loading",
4654
- location: location2,
4606
+ location,
4655
4607
  formMethod: void 0,
4656
4608
  formAction: void 0,
4657
4609
  formEncType: void 0,
@@ -4662,10 +4614,10 @@ function getLoadingNavigation(location2, submission) {
4662
4614
  return navigation;
4663
4615
  }
4664
4616
  }
4665
- function getSubmittingNavigation(location2, submission) {
4617
+ function getSubmittingNavigation(location, submission) {
4666
4618
  let navigation = {
4667
4619
  state: "submitting",
4668
- location: location2,
4620
+ location,
4669
4621
  formMethod: submission.formMethod,
4670
4622
  formAction: submission.formAction,
4671
4623
  formEncType: submission.formEncType,
@@ -4991,18 +4943,18 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
4991
4943
  );
4992
4944
  }
4993
4945
  let locationFromContext = useLocation();
4994
- let location2;
4946
+ let location;
4995
4947
  if (locationArg) {
4996
4948
  let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
4997
4949
  invariant(
4998
4950
  parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase),
4999
4951
  `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
4952
  );
5001
- location2 = parsedLocationArg;
4953
+ location = parsedLocationArg;
5002
4954
  } else {
5003
- location2 = locationFromContext;
4955
+ location = locationFromContext;
5004
4956
  }
5005
- let pathname = location2.pathname || "/";
4957
+ let pathname = location.pathname || "/";
5006
4958
  let remainingPathname = pathname;
5007
4959
  if (parentPathnameBase !== "/") {
5008
4960
  let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
@@ -5013,11 +4965,11 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5013
4965
  if (ENABLE_DEV_WARNINGS) {
5014
4966
  warning(
5015
4967
  parentRoute || matches != null,
5016
- `No routes matched location "${location2.pathname}${location2.search}${location2.hash}" `
4968
+ `No routes matched location "${location.pathname}${location.search}${location.hash}" `
5017
4969
  );
5018
4970
  warning(
5019
4971
  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.`
4972
+ `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
4973
  );
5022
4974
  }
5023
4975
  let renderedMatches = _renderMatches(
@@ -5051,7 +5003,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5051
5003
  hash: "",
5052
5004
  state: null,
5053
5005
  key: "default",
5054
- ...location2
5006
+ ...location
5055
5007
  },
5056
5008
  navigationType: "POP" /* Pop */
5057
5009
  }
@@ -5816,9 +5768,9 @@ function Router({
5816
5768
  }
5817
5769
  function Routes({
5818
5770
  children,
5819
- location: location2
5771
+ location
5820
5772
  }) {
5821
- return useRoutes(createRoutesFromChildren(children), location2);
5773
+ return useRoutes(createRoutesFromChildren(children), location);
5822
5774
  }
5823
5775
  function Await({
5824
5776
  children,
@@ -5888,38 +5840,6 @@ function ResolveAwait({
5888
5840
  let toRender = typeof children === "function" ? children(data2) : children;
5889
5841
  return /* @__PURE__ */ React3.createElement(React3.Fragment, null, toRender);
5890
5842
  }
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
5843
  function createRoutesFromChildren(children, parentPath = []) {
5924
5844
  let routes = [];
5925
5845
  React3.Children.forEach(children, (element, index) => {
@@ -6242,7 +6162,7 @@ async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
6242
6162
  )
6243
6163
  );
6244
6164
  }
6245
- function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location2, mode) {
6165
+ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
6246
6166
  let isNew = (match, index) => {
6247
6167
  if (!currentMatches[index]) return true;
6248
6168
  return match.route.id !== currentMatches[index].route.id;
@@ -6272,7 +6192,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
6272
6192
  if (match.route.shouldRevalidate) {
6273
6193
  let routeChoice = match.route.shouldRevalidate({
6274
6194
  currentUrl: new URL(
6275
- location2.pathname + location2.search + location2.hash,
6195
+ location.pathname + location.search + location.hash,
6276
6196
  window.origin
6277
6197
  ),
6278
6198
  currentParams: currentMatches[0]?.params || {},
@@ -6392,6 +6312,7 @@ async function createRequestInit(request) {
6392
6312
 
6393
6313
  // lib/dom/ssr/single-fetch.tsx
6394
6314
  var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
6315
+ var SINGLE_FETCH_REDIRECT_STATUS = 202;
6395
6316
  var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205]);
6396
6317
  function StreamTransfer({
6397
6318
  context,
@@ -6644,7 +6565,7 @@ function stripIndexParam(url) {
6644
6565
  }
6645
6566
  return url;
6646
6567
  }
6647
- function singleFetchUrl(reqUrl, basename, extension) {
6568
+ function singleFetchUrl(reqUrl, basename) {
6648
6569
  let url = typeof reqUrl === "string" ? new URL(
6649
6570
  reqUrl,
6650
6571
  // This can be called during the SSR flow via PrefetchPageLinksImpl so
@@ -6652,17 +6573,17 @@ function singleFetchUrl(reqUrl, basename, extension) {
6652
6573
  typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
6653
6574
  ) : reqUrl;
6654
6575
  if (url.pathname === "/") {
6655
- url.pathname = `_root.${extension}`;
6576
+ url.pathname = "_root.data";
6656
6577
  } else if (basename && stripBasename(url.pathname, basename) === "/") {
6657
- url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
6578
+ url.pathname = `${basename.replace(/\/$/, "")}/_root.data`;
6658
6579
  } else {
6659
- url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
6580
+ url.pathname = `${url.pathname.replace(/\/$/, "")}.data`;
6660
6581
  }
6661
6582
  return url;
6662
6583
  }
6663
6584
  async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
6664
6585
  let { request } = args;
6665
- let url = singleFetchUrl(request.url, basename, "data");
6586
+ let url = singleFetchUrl(request.url, basename);
6666
6587
  if (request.method === "GET") {
6667
6588
  url = stripIndexParam(url);
6668
6589
  if (targetRoutes) {
@@ -6673,6 +6594,20 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
6673
6594
  if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
6674
6595
  throw new ErrorResponseImpl(404, "Not Found", true);
6675
6596
  }
6597
+ if (res.status === 204 && res.headers.has("X-Remix-Redirect")) {
6598
+ return {
6599
+ status: SINGLE_FETCH_REDIRECT_STATUS,
6600
+ data: {
6601
+ redirect: {
6602
+ redirect: res.headers.get("X-Remix-Redirect"),
6603
+ status: Number(res.headers.get("X-Remix-Status") || "302"),
6604
+ revalidate: res.headers.get("X-Remix-Revalidate") === "true",
6605
+ reload: res.headers.get("X-Remix-Reload-Document") === "true",
6606
+ replace: res.headers.get("X-Remix-Replace") === "true"
6607
+ }
6608
+ }
6609
+ };
6610
+ }
6676
6611
  if (NO_BODY_STATUS_CODES.has(res.status)) {
6677
6612
  let routes = {};
6678
6613
  if (targetRoutes && request.method !== "GET") {
@@ -6745,13 +6680,13 @@ function decodeViaTurboStream(body, global2) {
6745
6680
  function unwrapSingleFetchResult(result, routeId) {
6746
6681
  if ("redirect" in result) {
6747
6682
  let {
6748
- redirect: location2,
6683
+ redirect: location,
6749
6684
  revalidate,
6750
6685
  reload,
6751
6686
  replace: replace2,
6752
6687
  status
6753
6688
  } = result.redirect;
6754
- throw redirect(location2, {
6689
+ throw redirect(location, {
6755
6690
  status,
6756
6691
  headers: {
6757
6692
  // Three R's of redirecting (lol Veep)
@@ -6762,13 +6697,12 @@ function unwrapSingleFetchResult(result, routeId) {
6762
6697
  });
6763
6698
  }
6764
6699
  let routeResult = result.routes[routeId];
6765
- invariant2(routeResult, `No response found for routeId "${routeId}"`);
6766
6700
  if ("error" in routeResult) {
6767
6701
  throw routeResult.error;
6768
6702
  } else if ("data" in routeResult) {
6769
6703
  return routeResult.data;
6770
6704
  } else {
6771
- throw new Error(`Invalid response found for routeId "${routeId}"`);
6705
+ throw new Error(`No response found for routeId "${routeId}"`);
6772
6706
  }
6773
6707
  }
6774
6708
  function createDeferred2() {
@@ -7668,7 +7602,7 @@ function PrefetchPageLinksImpl({
7668
7602
  matches: nextMatches,
7669
7603
  ...linkProps
7670
7604
  }) {
7671
- let location2 = useLocation();
7605
+ let location = useLocation();
7672
7606
  let { manifest, routeModules } = useFrameworkContext();
7673
7607
  let { basename } = useDataRouterContext2();
7674
7608
  let { loaderData, matches } = useDataRouterStateContext();
@@ -7678,10 +7612,10 @@ function PrefetchPageLinksImpl({
7678
7612
  nextMatches,
7679
7613
  matches,
7680
7614
  manifest,
7681
- location2,
7615
+ location,
7682
7616
  "data"
7683
7617
  ),
7684
- [page, nextMatches, matches, manifest, location2]
7618
+ [page, nextMatches, matches, manifest, location]
7685
7619
  );
7686
7620
  let newMatchesForAssets = React9.useMemo(
7687
7621
  () => getNewMatchesForLinks(
@@ -7689,13 +7623,13 @@ function PrefetchPageLinksImpl({
7689
7623
  nextMatches,
7690
7624
  matches,
7691
7625
  manifest,
7692
- location2,
7626
+ location,
7693
7627
  "assets"
7694
7628
  ),
7695
- [page, nextMatches, matches, manifest, location2]
7629
+ [page, nextMatches, matches, manifest, location]
7696
7630
  );
7697
7631
  let dataHrefs = React9.useMemo(() => {
7698
- if (page === location2.pathname + location2.search + location2.hash) {
7632
+ if (page === location.pathname + location.search + location.hash) {
7699
7633
  return [];
7700
7634
  }
7701
7635
  let routesParams = /* @__PURE__ */ new Set();
@@ -7716,7 +7650,7 @@ function PrefetchPageLinksImpl({
7716
7650
  if (routesParams.size === 0) {
7717
7651
  return [];
7718
7652
  }
7719
- let url = singleFetchUrl(page, basename, ".data");
7653
+ let url = singleFetchUrl(page, basename);
7720
7654
  if (foundOptOutRoute && routesParams.size > 0) {
7721
7655
  url.searchParams.set(
7722
7656
  "_routes",
@@ -7727,7 +7661,7 @@ function PrefetchPageLinksImpl({
7727
7661
  }, [
7728
7662
  basename,
7729
7663
  loaderData,
7730
- location2,
7664
+ location,
7731
7665
  manifest,
7732
7666
  newMatchesForData,
7733
7667
  nextMatches,
@@ -7752,7 +7686,7 @@ function Meta() {
7752
7686
  matches: routerMatches,
7753
7687
  loaderData
7754
7688
  } = useDataRouterStateContext();
7755
- let location2 = useLocation();
7689
+ let location = useLocation();
7756
7690
  let _matches = getActiveMatches(routerMatches, errors, isSpaMode);
7757
7691
  let error = null;
7758
7692
  if (errors) {
@@ -7782,7 +7716,7 @@ function Meta() {
7782
7716
  routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
7783
7717
  data: data2,
7784
7718
  params,
7785
- location: location2,
7719
+ location,
7786
7720
  matches,
7787
7721
  error
7788
7722
  }) : Array.isArray(routeModule.meta) ? [...routeModule.meta] : routeModule.meta;
@@ -8007,7 +7941,7 @@ function mergeRefs(...refs) {
8007
7941
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
8008
7942
  try {
8009
7943
  if (isBrowser) {
8010
- window.__reactRouterVersion = "0.0.0-experimental-a6d1d1d4e";
7944
+ window.__reactRouterVersion = "0.0.0-experimental-1d760f6a6";
8011
7945
  }
8012
7946
  } catch (e) {
8013
7947
  }
@@ -8265,14 +8199,14 @@ var NavLink = React10.forwardRef(
8265
8199
  ...rest
8266
8200
  }, ref) {
8267
8201
  let path = useResolvedPath(to, { relative: rest.relative });
8268
- let location2 = useLocation();
8202
+ let location = useLocation();
8269
8203
  let routerState = React10.useContext(DataRouterStateContext);
8270
8204
  let { navigator: navigator2, basename } = React10.useContext(NavigationContext);
8271
8205
  let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
8272
8206
  // eslint-disable-next-line react-hooks/rules-of-hooks
8273
8207
  useViewTransitionState(path) && viewTransition === true;
8274
8208
  let toPathname = navigator2.encodeLocation ? navigator2.encodeLocation(path).pathname : path.pathname;
8275
- let locationPathname = location2.pathname;
8209
+ let locationPathname = location.pathname;
8276
8210
  let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
8277
8211
  if (!caseSensitive) {
8278
8212
  locationPathname = locationPathname.toLowerCase();
@@ -8377,19 +8311,19 @@ function ScrollRestoration({
8377
8311
  }) {
8378
8312
  let remixContext = React10.useContext(FrameworkContext);
8379
8313
  let { basename } = React10.useContext(NavigationContext);
8380
- let location2 = useLocation();
8314
+ let location = useLocation();
8381
8315
  let matches = useMatches();
8382
8316
  useScrollRestoration({ getKey, storageKey });
8383
8317
  let ssrKey = React10.useMemo(
8384
8318
  () => {
8385
8319
  if (!remixContext || !getKey) return null;
8386
8320
  let userKey = getScrollRestorationKey(
8387
- location2,
8321
+ location,
8388
8322
  matches,
8389
8323
  basename,
8390
8324
  getKey
8391
8325
  );
8392
- return userKey !== location2.key ? userKey : null;
8326
+ return userKey !== location.key ? userKey : null;
8393
8327
  },
8394
8328
  // Nah, we only need this the first time for the SSR render
8395
8329
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -8450,13 +8384,13 @@ function useLinkClickHandler(to, {
8450
8384
  viewTransition
8451
8385
  } = {}) {
8452
8386
  let navigate = useNavigate();
8453
- let location2 = useLocation();
8387
+ let location = useLocation();
8454
8388
  let path = useResolvedPath(to, { relative });
8455
8389
  return React10.useCallback(
8456
8390
  (event) => {
8457
8391
  if (shouldProcessLinkClick(event, target)) {
8458
8392
  event.preventDefault();
8459
- let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location2) === createPath(path);
8393
+ let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
8460
8394
  navigate(to, {
8461
8395
  replace: replace2,
8462
8396
  state,
@@ -8467,7 +8401,7 @@ function useLinkClickHandler(to, {
8467
8401
  }
8468
8402
  },
8469
8403
  [
8470
- location2,
8404
+ location,
8471
8405
  navigate,
8472
8406
  path,
8473
8407
  replaceProp,
@@ -8487,18 +8421,18 @@ function useSearchParams(defaultInit) {
8487
8421
  );
8488
8422
  let defaultSearchParamsRef = React10.useRef(createSearchParams(defaultInit));
8489
8423
  let hasSetSearchParamsRef = React10.useRef(false);
8490
- let location2 = useLocation();
8424
+ let location = useLocation();
8491
8425
  let searchParams = React10.useMemo(
8492
8426
  () => (
8493
8427
  // Only merge in the defaults if we haven't yet called setSearchParams.
8494
8428
  // Once we call that we want those to take precedence, otherwise you can't
8495
8429
  // remove a param with setSearchParams({}) if it has an initial value
8496
8430
  getSearchParamsForLocation(
8497
- location2.search,
8431
+ location.search,
8498
8432
  hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
8499
8433
  )
8500
8434
  ),
8501
- [location2.search]
8435
+ [location.search]
8502
8436
  );
8503
8437
  let navigate = useNavigate();
8504
8438
  let setSearchParams = React10.useCallback(
@@ -8559,9 +8493,9 @@ function useFormAction(action, { relative } = {}) {
8559
8493
  invariant(routeContext, "useFormAction must be used inside a RouteContext");
8560
8494
  let [match] = routeContext.matches.slice(-1);
8561
8495
  let path = { ...useResolvedPath(action ? action : ".", { relative }) };
8562
- let location2 = useLocation();
8496
+ let location = useLocation();
8563
8497
  if (action == null) {
8564
- path.search = location2.search;
8498
+ path.search = location.search;
8565
8499
  let params = new URLSearchParams(path.search);
8566
8500
  let indexValues = params.getAll("index");
8567
8501
  let hasNakedIndexParam = indexValues.some((v) => v === "");
@@ -8653,23 +8587,23 @@ function useFetchers() {
8653
8587
  }
8654
8588
  var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
8655
8589
  var savedScrollPositions = {};
8656
- function getScrollRestorationKey(location2, matches, basename, getKey) {
8590
+ function getScrollRestorationKey(location, matches, basename, getKey) {
8657
8591
  let key = null;
8658
8592
  if (getKey) {
8659
8593
  if (basename !== "/") {
8660
8594
  key = getKey(
8661
8595
  {
8662
- ...location2,
8663
- pathname: stripBasename(location2.pathname, basename) || location2.pathname
8596
+ ...location,
8597
+ pathname: stripBasename(location.pathname, basename) || location.pathname
8664
8598
  },
8665
8599
  matches
8666
8600
  );
8667
8601
  } else {
8668
- key = getKey(location2, matches);
8602
+ key = getKey(location, matches);
8669
8603
  }
8670
8604
  }
8671
8605
  if (key == null) {
8672
- key = location2.key;
8606
+ key = location.key;
8673
8607
  }
8674
8608
  return key;
8675
8609
  }
@@ -8682,7 +8616,7 @@ function useScrollRestoration({
8682
8616
  "useScrollRestoration" /* UseScrollRestoration */
8683
8617
  );
8684
8618
  let { basename } = React10.useContext(NavigationContext);
8685
- let location2 = useLocation();
8619
+ let location = useLocation();
8686
8620
  let matches = useMatches();
8687
8621
  let navigation = useNavigation();
8688
8622
  React10.useEffect(() => {
@@ -8694,7 +8628,7 @@ function useScrollRestoration({
8694
8628
  usePageHide(
8695
8629
  React10.useCallback(() => {
8696
8630
  if (navigation.state === "idle") {
8697
- let key = getScrollRestorationKey(location2, matches, basename, getKey);
8631
+ let key = getScrollRestorationKey(location, matches, basename, getKey);
8698
8632
  savedScrollPositions[key] = window.scrollY;
8699
8633
  }
8700
8634
  try {
@@ -8709,7 +8643,7 @@ function useScrollRestoration({
8709
8643
  );
8710
8644
  }
8711
8645
  window.history.scrollRestoration = "auto";
8712
- }, [navigation.state, getKey, basename, location2, matches, storageKey])
8646
+ }, [navigation.state, getKey, basename, location, matches, storageKey])
8713
8647
  );
8714
8648
  if (typeof document !== "undefined") {
8715
8649
  React10.useLayoutEffect(() => {
@@ -8727,7 +8661,7 @@ function useScrollRestoration({
8727
8661
  let disableScrollRestoration = router?.enableScrollRestoration(
8728
8662
  savedScrollPositions,
8729
8663
  () => window.scrollY,
8730
- getKey ? (location3, matches2) => getScrollRestorationKey(location3, matches2, basename, getKey) : void 0
8664
+ getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
8731
8665
  );
8732
8666
  return () => disableScrollRestoration && disableScrollRestoration();
8733
8667
  }, [router, basename, getKey]);
@@ -8739,9 +8673,9 @@ function useScrollRestoration({
8739
8673
  window.scrollTo(0, restoreScrollPosition);
8740
8674
  return;
8741
8675
  }
8742
- if (location2.hash) {
8676
+ if (location.hash) {
8743
8677
  let el = document.getElementById(
8744
- decodeURIComponent(location2.hash.slice(1))
8678
+ decodeURIComponent(location.hash.slice(1))
8745
8679
  );
8746
8680
  if (el) {
8747
8681
  el.scrollIntoView();
@@ -8752,7 +8686,7 @@ function useScrollRestoration({
8752
8686
  return;
8753
8687
  }
8754
8688
  window.scrollTo(0, 0);
8755
- }, [location2, restoreScrollPosition, preventScrollReset]);
8689
+ }, [location, restoreScrollPosition, preventScrollReset]);
8756
8690
  }
8757
8691
  }
8758
8692
  function useBeforeUnload(callback, options) {
@@ -8825,7 +8759,7 @@ function StaticRouter({
8825
8759
  locationProp = parsePath(locationProp);
8826
8760
  }
8827
8761
  let action = "POP" /* Pop */;
8828
- let location2 = {
8762
+ let location = {
8829
8763
  pathname: locationProp.pathname || "/",
8830
8764
  search: locationProp.search || "",
8831
8765
  hash: locationProp.hash || "",
@@ -8838,7 +8772,7 @@ function StaticRouter({
8838
8772
  {
8839
8773
  basename,
8840
8774
  children,
8841
- location: location2,
8775
+ location,
8842
8776
  navigationType: action,
8843
8777
  navigator: staticNavigator,
8844
8778
  static: true
@@ -9057,9 +8991,6 @@ function createStaticRouter(routes, context, opts = {}) {
9057
8991
  _internalFetchControllers: /* @__PURE__ */ new Map(),
9058
8992
  _internalSetRoutes() {
9059
8993
  throw msg("_internalSetRoutes");
9060
- },
9061
- _internalSetStateDoNotUseOrYouWillBreakYourApp() {
9062
- throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
9063
8994
  }
9064
8995
  };
9065
8996
  }
@@ -9587,6 +9518,26 @@ function invariant3(value, message) {
9587
9518
  }
9588
9519
  }
9589
9520
 
9521
+ // lib/server-runtime/dev.ts
9522
+ var globalDevServerHooksKey = "__reactRouterDevServerHooks";
9523
+ function setDevServerHooks(devServerHooks) {
9524
+ globalThis[globalDevServerHooksKey] = devServerHooks;
9525
+ }
9526
+ function getDevServerHooks() {
9527
+ return globalThis[globalDevServerHooksKey];
9528
+ }
9529
+ function getBuildTimeHeader(request, headerName) {
9530
+ if (typeof process !== "undefined") {
9531
+ try {
9532
+ if (process.env?.IS_RR_BUILD_REQUEST === "yes") {
9533
+ return request.headers.get(headerName);
9534
+ }
9535
+ } catch (e) {
9536
+ }
9537
+ }
9538
+ return null;
9539
+ }
9540
+
9590
9541
  // lib/server-runtime/routes.ts
9591
9542
  function groupRoutesByParentId2(manifest) {
9592
9543
  let routes = {};
@@ -9618,10 +9569,11 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
9618
9569
  // Need to use RR's version in the param typed here to permit the optional
9619
9570
  // context even though we know it'll always be provided in remix
9620
9571
  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
- );
9572
+ let preRenderedData = getBuildTimeHeader(
9573
+ args.request,
9574
+ "X-React-Router-Prerender-Data"
9575
+ );
9576
+ if (preRenderedData != null) {
9625
9577
  let encoded = preRenderedData ? decodeURI(preRenderedData) : preRenderedData;
9626
9578
  invariant3(encoded, "Missing prerendered data for route");
9627
9579
  let uint8array = new TextEncoder().encode(encoded);
@@ -9696,21 +9648,12 @@ function createServerHandoffString(serverHandoff) {
9696
9648
  return escapeHtml2(JSON.stringify(serverHandoff));
9697
9649
  }
9698
9650
 
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
9651
  // lib/server-runtime/single-fetch.ts
9709
9652
  import { encode } from "turbo-stream";
9710
9653
 
9711
9654
  // lib/server-runtime/headers.ts
9712
9655
  import { splitCookiesString } from "set-cookie-parser";
9713
- function getDocumentHeaders(context, getRouteHeadersFn) {
9656
+ function getDocumentHeaders(build, context) {
9714
9657
  let boundaryIdx = context.errors ? context.matches.findIndex((m) => context.errors[m.route.id]) : -1;
9715
9658
  let matches = boundaryIdx >= 0 ? context.matches.slice(0, boundaryIdx + 1) : context.matches;
9716
9659
  let errorHeaders;
@@ -9728,12 +9671,14 @@ function getDocumentHeaders(context, getRouteHeadersFn) {
9728
9671
  }
9729
9672
  return matches.reduce((parentHeaders, match, idx) => {
9730
9673
  let { id } = match.route;
9674
+ let route = build.routes[id];
9675
+ invariant3(route, `Route with id "${id}" not found in build`);
9676
+ let routeModule = route.module;
9731
9677
  let loaderHeaders = context.loaderHeaders[id] || new Headers();
9732
9678
  let actionHeaders = context.actionHeaders[id] || new Headers();
9733
9679
  let includeErrorHeaders = errorHeaders != null && idx === matches.length - 1;
9734
9680
  let includeErrorCookies = includeErrorHeaders && errorHeaders !== loaderHeaders && errorHeaders !== actionHeaders;
9735
- let headersFn = getRouteHeadersFn(match);
9736
- if (headersFn == null) {
9681
+ if (routeModule.headers == null) {
9737
9682
  let headers2 = new Headers(parentHeaders);
9738
9683
  if (includeErrorCookies) {
9739
9684
  prependCookies(errorHeaders, headers2);
@@ -9743,12 +9688,12 @@ function getDocumentHeaders(context, getRouteHeadersFn) {
9743
9688
  return headers2;
9744
9689
  }
9745
9690
  let headers = new Headers(
9746
- typeof headersFn === "function" ? headersFn({
9691
+ routeModule.headers ? typeof routeModule.headers === "function" ? routeModule.headers({
9747
9692
  loaderHeaders,
9748
9693
  parentHeaders,
9749
9694
  actionHeaders,
9750
9695
  errorHeaders: includeErrorHeaders ? errorHeaders : void 0
9751
- }) : headersFn
9696
+ }) : routeModule.headers : void 0
9752
9697
  );
9753
9698
  if (includeErrorCookies) {
9754
9699
  prependCookies(errorHeaders, headers);
@@ -9773,7 +9718,6 @@ function prependCookies(parentHeaders, childHeaders) {
9773
9718
  }
9774
9719
 
9775
9720
  // lib/server-runtime/single-fetch.ts
9776
- var SINGLE_FETCH_REDIRECT_STATUS = 202;
9777
9721
  var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
9778
9722
  ...NO_BODY_STATUS_CODES,
9779
9723
  304
@@ -9781,10 +9725,7 @@ var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
9781
9725
  async function singleFetchAction(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
9782
9726
  try {
9783
9727
  let respond2 = function(context) {
9784
- let headers = getDocumentHeaders(
9785
- context,
9786
- (m) => build.routes[m.route.id]?.module.headers
9787
- );
9728
+ let headers = getDocumentHeaders(build, context);
9788
9729
  if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
9789
9730
  return generateSingleFetchResponse(request, build, serverMode, {
9790
9731
  result: getSingleFetchRedirect(
@@ -9859,10 +9800,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
9859
9800
  async function singleFetchLoaders(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
9860
9801
  try {
9861
9802
  let respond2 = function(context) {
9862
- let headers = getDocumentHeaders(
9863
- context,
9864
- (m) => build.routes[m.route.id]?.module.headers
9865
- );
9803
+ let headers = getDocumentHeaders(build, context);
9866
9804
  if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
9867
9805
  return generateSingleFetchResponse(request, build, serverMode, {
9868
9806
  result: {
@@ -10118,9 +10056,10 @@ Error: ${e instanceof Error ? e.toString() : e}`
10118
10056
  if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
10119
10057
  normalizedPath = normalizedPath.slice(0, -1);
10120
10058
  }
10059
+ let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
10121
10060
  if (!_build.ssr) {
10122
10061
  if (_build.prerender.length === 0) {
10123
- request.headers.set("X-React-Router-SPA-Mode", "yes");
10062
+ isSpaMode = true;
10124
10063
  } else if (!_build.prerender.includes(normalizedPath) && !_build.prerender.includes(normalizedPath + "/")) {
10125
10064
  if (url.pathname.endsWith(".data")) {
10126
10065
  errorHandler(
@@ -10140,7 +10079,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
10140
10079
  statusText: "Not Found"
10141
10080
  });
10142
10081
  } else {
10143
- request.headers.set("X-React-Router-SPA-Mode", "yes");
10082
+ isSpaMode = true;
10144
10083
  }
10145
10084
  }
10146
10085
  }
@@ -10209,7 +10148,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
10209
10148
  );
10210
10149
  }
10211
10150
  }
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) {
10151
+ } else if (!isSpaMode && matches && matches[matches.length - 1].route.module.default == null && matches[matches.length - 1].route.module.ErrorBoundary == null) {
10213
10152
  response = await handleResourceRequest(
10214
10153
  serverMode,
10215
10154
  _build,
@@ -10234,6 +10173,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
10234
10173
  request,
10235
10174
  loadContext,
10236
10175
  handleError,
10176
+ isSpaMode,
10237
10177
  criticalCss
10238
10178
  );
10239
10179
  }
@@ -10309,8 +10249,7 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
10309
10249
  );
10310
10250
  return response;
10311
10251
  }
10312
- async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, criticalCss) {
10313
- let isSpaMode = request.headers.has("X-React-Router-SPA-Mode");
10252
+ async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, isSpaMode, criticalCss) {
10314
10253
  try {
10315
10254
  let response = await staticHandler.query(request, {
10316
10255
  requestContext: loadContext,
@@ -10325,10 +10264,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
10325
10264
  if (isResponse(context)) {
10326
10265
  return context;
10327
10266
  }
10328
- let headers = getDocumentHeaders(
10329
- context,
10330
- (m) => build.routes[m.route.id]?.module.headers
10331
- );
10267
+ let headers = getDocumentHeaders(build, context);
10332
10268
  if (SERVER_NO_BODY_STATUS_CODES.has(context.statusCode)) {
10333
10269
  return new Response(null, { status: context.statusCode, headers });
10334
10270
  }
@@ -10586,7 +10522,7 @@ function createSessionStorage({
10586
10522
  function warnOnceAboutSigningSessionCookie(cookie) {
10587
10523
  warnOnce(
10588
10524
  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.`
10525
+ `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
10526
  );
10591
10527
  }
10592
10528
 
@@ -10666,692 +10602,6 @@ function href(path, ...args) {
10666
10602
  }).filter((segment) => segment !== void 0).join("/");
10667
10603
  }
10668
10604
 
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 body = serverResponse.body;
11200
- let payloadPromise;
11201
- const getPayload = async () => {
11202
- if (payloadPromise) return payloadPromise;
11203
- payloadPromise = decode2(body);
11204
- return payloadPromise;
11205
- };
11206
- try {
11207
- const html = await renderHTML(getPayload);
11208
- const body2 = html.pipeThrough(injectRSCPayload(serverResponseB.body));
11209
- const headers = new Headers(serverResponse.headers);
11210
- headers.set("Content-Type", "text/html");
11211
- return new Response(body2, {
11212
- status: serverResponse.status,
11213
- headers
11214
- });
11215
- } catch (reason) {
11216
- if (reason instanceof Response) {
11217
- return reason;
11218
- }
11219
- throw reason;
11220
- }
11221
- }
11222
- function RSCStaticRouter({
11223
- getPayload
11224
- }) {
11225
- const payload = React15.use(getPayload());
11226
- if (payload.type === "redirect") {
11227
- throw new Response(null, {
11228
- status: payload.status,
11229
- headers: {
11230
- Location: payload.location
11231
- }
11232
- });
11233
- }
11234
- if (payload.type !== "render") return null;
11235
- const context = {
11236
- actionData: payload.actionData,
11237
- actionHeaders: {},
11238
- basename: payload.basename,
11239
- errors: payload.errors,
11240
- loaderData: payload.loaderData,
11241
- loaderHeaders: {},
11242
- location: payload.location,
11243
- statusCode: 200,
11244
- matches: payload.matches.map((match) => ({
11245
- params: match.params,
11246
- pathname: match.pathname,
11247
- pathnameBase: match.pathnameBase,
11248
- route: {
11249
- id: match.id,
11250
- action: match.hasAction || !!match.clientAction,
11251
- handle: match.handle,
11252
- hasErrorBoundary: match.hasErrorBoundary,
11253
- loader: match.hasLoader || !!match.clientLoader,
11254
- index: match.index,
11255
- path: match.path,
11256
- shouldRevalidate: match.shouldRevalidate
11257
- }
11258
- }))
11259
- };
11260
- const router = createStaticRouter(
11261
- payload.matches.reduceRight((previous, match) => {
11262
- const route = {
11263
- id: match.id,
11264
- action: match.hasAction || !!match.clientAction,
11265
- element: match.element,
11266
- errorElement: match.errorElement,
11267
- handle: match.handle,
11268
- hasErrorBoundary: !!match.errorElement,
11269
- hydrateFallbackElement: match.hydrateFallbackElement,
11270
- index: match.index,
11271
- loader: match.hasLoader || !!match.clientLoader,
11272
- path: match.path,
11273
- shouldRevalidate: match.shouldRevalidate
11274
- };
11275
- if (previous.length > 0) {
11276
- route.children = previous;
11277
- }
11278
- return [route];
11279
- }, []),
11280
- context
11281
- );
11282
- const frameworkContext = {
11283
- future: {
11284
- // These flags have no runtime impact so can always be false. If we add
11285
- // flags that drive runtime behavior they'll need to be proxied through.
11286
- unstable_middleware: false,
11287
- unstable_subResourceIntegrity: false
11288
- },
11289
- isSpaMode: false,
11290
- ssr: true,
11291
- criticalCss: "",
11292
- manifest: {
11293
- routes: {},
11294
- version: "1",
11295
- url: "",
11296
- entry: {
11297
- module: "",
11298
- imports: []
11299
- }
11300
- },
11301
- routeModules: {}
11302
- };
11303
- return /* @__PURE__ */ React15.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React15.createElement(
11304
- StaticRouterProvider,
11305
- {
11306
- context,
11307
- router,
11308
- hydrate: false,
11309
- nonce: payload.nonce
11310
- }
11311
- ));
11312
- }
11313
- function isReactServerRequest(url) {
11314
- return url.pathname.endsWith(".rsc");
11315
- }
11316
- function isManifestRequest(url) {
11317
- return url.pathname.endsWith(".manifest");
11318
- }
11319
-
11320
- // lib/rsc/html-stream/browser.ts
11321
- function getServerStream() {
11322
- let encoder3 = new TextEncoder();
11323
- let streamController = null;
11324
- let rscStream = new ReadableStream({
11325
- start(controller) {
11326
- if (typeof window === "undefined") {
11327
- return;
11328
- }
11329
- let handleChunk = (chunk) => {
11330
- if (typeof chunk === "string") {
11331
- controller.enqueue(encoder3.encode(chunk));
11332
- } else {
11333
- controller.enqueue(chunk);
11334
- }
11335
- };
11336
- window.__FLIGHT_DATA || (window.__FLIGHT_DATA = []);
11337
- window.__FLIGHT_DATA.forEach(handleChunk);
11338
- window.__FLIGHT_DATA.push = (chunk) => {
11339
- handleChunk(chunk);
11340
- return 0;
11341
- };
11342
- streamController = controller;
11343
- }
11344
- });
11345
- if (typeof document !== "undefined" && document.readyState === "loading") {
11346
- document.addEventListener("DOMContentLoaded", () => {
11347
- streamController?.close();
11348
- });
11349
- } else {
11350
- streamController?.close();
11351
- }
11352
- return rscStream;
11353
- }
11354
-
11355
10605
  // lib/dom/ssr/errors.ts
11356
10606
  function deserializeErrors2(errors) {
11357
10607
  if (!errors) return null;
@@ -11389,6 +10639,32 @@ function deserializeErrors2(errors) {
11389
10639
  return serialized;
11390
10640
  }
11391
10641
 
10642
+ // lib/dom/ssr/hydration.tsx
10643
+ function getHydrationData(state, routes, getRouteInfo, location, basename, isSpaMode) {
10644
+ let hydrationData = {
10645
+ ...state,
10646
+ loaderData: { ...state.loaderData }
10647
+ };
10648
+ let initialMatches = matchRoutes(routes, location, basename);
10649
+ if (initialMatches) {
10650
+ for (let match of initialMatches) {
10651
+ let routeId = match.route.id;
10652
+ let routeInfo = getRouteInfo(routeId);
10653
+ if (shouldHydrateRouteLoader(
10654
+ routeId,
10655
+ routeInfo.clientLoader,
10656
+ routeInfo.hasLoader,
10657
+ isSpaMode
10658
+ ) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
10659
+ delete hydrationData.loaderData[routeId];
10660
+ } else if (!routeInfo.hasLoader) {
10661
+ hydrationData.loaderData[routeId] = null;
10662
+ }
10663
+ }
10664
+ }
10665
+ return hydrationData;
10666
+ }
10667
+
11392
10668
  export {
11393
10669
  Action,
11394
10670
  createBrowserHistory,
@@ -11450,9 +10726,6 @@ export {
11450
10726
  Router,
11451
10727
  Routes,
11452
10728
  Await,
11453
- WithRouteComponentProps,
11454
- WithHydrateFallbackProps,
11455
- WithErrorBoundaryProps,
11456
10729
  createRoutesFromChildren,
11457
10730
  createRoutesFromElements,
11458
10731
  renderMatches,
@@ -11507,11 +10780,6 @@ export {
11507
10780
  createCookieSessionStorage,
11508
10781
  createMemorySessionStorage,
11509
10782
  href,
11510
- getHydrationData,
11511
- createCallServer,
11512
- RSCHydratedRouter,
11513
- routeRSCServerRequest,
11514
- RSCStaticRouter,
11515
- getServerStream,
11516
- deserializeErrors2 as deserializeErrors
10783
+ deserializeErrors2 as deserializeErrors,
10784
+ getHydrationData
11517
10785
  };