react-router 0.0.0-experimental-1fcc8eb1d → 0.0.0-experimental-d82b9430b

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 (39) hide show
  1. package/dist/development/{chunk-5QBUC2DR.mjs → chunk-KBNUQA6K.mjs} +274 -1138
  2. package/dist/development/dom-export.d.mts +2 -2
  3. package/dist/development/dom-export.js +1 -2
  4. package/dist/development/dom-export.mjs +2 -3
  5. package/dist/development/index.d.mts +5 -16
  6. package/dist/development/index.d.ts +3 -92
  7. package/dist/development/index.js +272 -1142
  8. package/dist/development/index.mjs +2 -13
  9. package/dist/development/lib/types/internal.d.mts +1 -1
  10. package/dist/development/lib/types/internal.d.ts +1 -1
  11. package/dist/development/lib/types/internal.js +1 -1
  12. package/dist/development/lib/types/internal.mjs +1 -1
  13. package/dist/development/{browser-BM9EKN98.d.mts → lib-C1JSsICm.d.mts} +2 -80
  14. package/dist/{production/register-B0EYMBux.d.ts → development/register-DCE0tH5m.d.ts} +2 -13
  15. package/dist/{production/route-data-B3YkvRuy.d.mts → development/route-data-ByAYLHuM.d.mts} +2 -13
  16. package/dist/production/{chunk-JCSCMN5T.mjs → chunk-KAPQWN2R.mjs} +274 -1138
  17. package/dist/production/dom-export.d.mts +2 -2
  18. package/dist/production/dom-export.js +1 -2
  19. package/dist/production/dom-export.mjs +2 -3
  20. package/dist/production/index.d.mts +5 -16
  21. package/dist/production/index.d.ts +3 -92
  22. package/dist/production/index.js +272 -1142
  23. package/dist/production/index.mjs +2 -13
  24. package/dist/production/lib/types/internal.d.mts +1 -1
  25. package/dist/production/lib/types/internal.d.ts +1 -1
  26. package/dist/production/lib/types/internal.js +1 -1
  27. package/dist/production/lib/types/internal.mjs +1 -1
  28. package/dist/production/{browser-BM9EKN98.d.mts → lib-C1JSsICm.d.mts} +2 -80
  29. package/dist/{development/register-B0EYMBux.d.ts → production/register-DCE0tH5m.d.ts} +2 -13
  30. package/dist/{development/route-data-B3YkvRuy.d.mts → production/route-data-ByAYLHuM.d.mts} +2 -13
  31. package/package.json +2 -33
  32. package/dist/development/rsc-export.d.mts +0 -1797
  33. package/dist/development/rsc-export.d.ts +0 -1797
  34. package/dist/development/rsc-export.js +0 -2901
  35. package/dist/development/rsc-export.mjs +0 -2865
  36. package/dist/production/rsc-export.d.mts +0 -1797
  37. package/dist/production/rsc-export.d.ts +0 -1797
  38. package/dist/production/rsc-export.js +0 -2901
  39. package/dist/production/rsc-export.mjs +0 -2865
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-1fcc8eb1d
2
+ * react-router v0.0.0-experimental-d82b9430b
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 });
@@ -419,7 +419,7 @@ function isUnsupportedLazyRouteFunctionKey(key) {
419
419
  function isIndexRoute(route) {
420
420
  return route.index === true;
421
421
  }
422
- function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}, allowInPlaceMutations = false) {
422
+ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}) {
423
423
  return routes.map((route, index) => {
424
424
  let treePath = [...parentPath, String(index)];
425
425
  let id = typeof route.id === "string" ? route.id : treePath.join("-");
@@ -428,7 +428,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
428
428
  `Cannot specify children on an index route`
429
429
  );
430
430
  invariant(
431
- allowInPlaceMutations || !manifest[id],
431
+ !manifest[id],
432
432
  `Found a route id collision on id "${id}". Route id's must be globally unique within Data Router usages`
433
433
  );
434
434
  if (isIndexRoute(route)) {
@@ -452,8 +452,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
452
452
  route.children,
453
453
  mapRouteProperties2,
454
454
  treePath,
455
- manifest,
456
- allowInPlaceMutations
455
+ manifest
457
456
  );
458
457
  }
459
458
  return pathOrLayoutRoute;
@@ -464,8 +463,8 @@ function matchRoutes(routes, locationArg, basename = "/") {
464
463
  return matchRoutesImpl(routes, locationArg, basename, false);
465
464
  }
466
465
  function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
467
- let location2 = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
468
- let pathname = stripBasename(location2.pathname || "/", basename);
466
+ let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
467
+ let pathname = stripBasename(location.pathname || "/", basename);
469
468
  if (pathname == null) {
470
469
  return null;
471
470
  }
@@ -1073,7 +1072,7 @@ function createRouter(init) {
1073
1072
  let pendingRevalidationDfd = null;
1074
1073
  function initialize() {
1075
1074
  unlistenHistory = init.history.listen(
1076
- ({ action: historyAction, location: location2, delta }) => {
1075
+ ({ action: historyAction, location, delta }) => {
1077
1076
  if (unblockBlockerHistoryUpdate) {
1078
1077
  unblockBlockerHistoryUpdate();
1079
1078
  unblockBlockerHistoryUpdate = void 0;
@@ -1085,7 +1084,7 @@ function createRouter(init) {
1085
1084
  );
1086
1085
  let blockerKey = shouldBlockNavigation({
1087
1086
  currentLocation: state.location,
1088
- nextLocation: location2,
1087
+ nextLocation: location,
1089
1088
  historyAction
1090
1089
  });
1091
1090
  if (blockerKey && delta != null) {
@@ -1095,13 +1094,13 @@ function createRouter(init) {
1095
1094
  init.history.go(delta * -1);
1096
1095
  updateBlocker(blockerKey, {
1097
1096
  state: "blocked",
1098
- location: location2,
1097
+ location,
1099
1098
  proceed() {
1100
1099
  updateBlocker(blockerKey, {
1101
1100
  state: "proceeding",
1102
1101
  proceed: void 0,
1103
1102
  reset: void 0,
1104
- location: location2
1103
+ location
1105
1104
  });
1106
1105
  nextHistoryUpdatePromise.then(() => init.history.go(delta));
1107
1106
  },
@@ -1113,7 +1112,7 @@ function createRouter(init) {
1113
1112
  });
1114
1113
  return;
1115
1114
  }
1116
- return startNavigation(historyAction, location2);
1115
+ return startNavigation(historyAction, location);
1117
1116
  }
1118
1117
  );
1119
1118
  if (isBrowser2) {
@@ -1146,19 +1145,6 @@ function createRouter(init) {
1146
1145
  return () => subscribers.delete(fn);
1147
1146
  }
1148
1147
  function updateState(newState, opts = {}) {
1149
- if (newState.matches) {
1150
- newState.matches = newState.matches.map((m) => {
1151
- let route = manifest[m.route.id];
1152
- let matchRoute = m.route;
1153
- if (matchRoute.element !== route.element || matchRoute.errorElement !== route.errorElement || matchRoute.hydrateFallbackElement !== route.hydrateFallbackElement) {
1154
- return {
1155
- ...m,
1156
- route
1157
- };
1158
- }
1159
- return m;
1160
- });
1161
- }
1162
1148
  state = {
1163
1149
  ...state,
1164
1150
  ...newState
@@ -1189,8 +1175,8 @@ function createRouter(init) {
1189
1175
  unmountedFetchers.forEach((key) => deleteFetcher(key));
1190
1176
  mountedFetchers.forEach((key) => state.fetchers.delete(key));
1191
1177
  }
1192
- function completeNavigation(location2, newState, { flushSync } = {}) {
1193
- let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && location2.state?._isRedirect !== true;
1178
+ function completeNavigation(location, newState, { flushSync } = {}) {
1179
+ let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && location.state?._isRedirect !== true;
1194
1180
  let actionData;
1195
1181
  if (newState.actionData) {
1196
1182
  if (Object.keys(newState.actionData).length > 0) {
@@ -1214,7 +1200,7 @@ function createRouter(init) {
1214
1200
  blockers = new Map(blockers);
1215
1201
  blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));
1216
1202
  }
1217
- let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location2.state?._isRedirect !== true;
1203
+ let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location.state?._isRedirect !== true;
1218
1204
  if (inFlightDataRoutes) {
1219
1205
  dataRoutes = inFlightDataRoutes;
1220
1206
  inFlightDataRoutes = void 0;
@@ -1222,35 +1208,35 @@ function createRouter(init) {
1222
1208
  if (isUninterruptedRevalidation) {
1223
1209
  } else if (pendingAction === "POP" /* Pop */) {
1224
1210
  } else if (pendingAction === "PUSH" /* Push */) {
1225
- init.history.push(location2, location2.state);
1211
+ init.history.push(location, location.state);
1226
1212
  } else if (pendingAction === "REPLACE" /* Replace */) {
1227
- init.history.replace(location2, location2.state);
1213
+ init.history.replace(location, location.state);
1228
1214
  }
1229
1215
  let viewTransitionOpts;
1230
1216
  if (pendingAction === "POP" /* Pop */) {
1231
1217
  let priorPaths = appliedViewTransitions.get(state.location.pathname);
1232
- if (priorPaths && priorPaths.has(location2.pathname)) {
1218
+ if (priorPaths && priorPaths.has(location.pathname)) {
1233
1219
  viewTransitionOpts = {
1234
1220
  currentLocation: state.location,
1235
- nextLocation: location2
1221
+ nextLocation: location
1236
1222
  };
1237
- } else if (appliedViewTransitions.has(location2.pathname)) {
1223
+ } else if (appliedViewTransitions.has(location.pathname)) {
1238
1224
  viewTransitionOpts = {
1239
- currentLocation: location2,
1225
+ currentLocation: location,
1240
1226
  nextLocation: state.location
1241
1227
  };
1242
1228
  }
1243
1229
  } else if (pendingViewTransitionEnabled) {
1244
1230
  let toPaths = appliedViewTransitions.get(state.location.pathname);
1245
1231
  if (toPaths) {
1246
- toPaths.add(location2.pathname);
1232
+ toPaths.add(location.pathname);
1247
1233
  } else {
1248
- toPaths = /* @__PURE__ */ new Set([location2.pathname]);
1234
+ toPaths = /* @__PURE__ */ new Set([location.pathname]);
1249
1235
  appliedViewTransitions.set(state.location.pathname, toPaths);
1250
1236
  }
1251
1237
  viewTransitionOpts = {
1252
1238
  currentLocation: state.location,
1253
- nextLocation: location2
1239
+ nextLocation: location
1254
1240
  };
1255
1241
  }
1256
1242
  updateState(
@@ -1260,12 +1246,12 @@ function createRouter(init) {
1260
1246
  actionData,
1261
1247
  loaderData,
1262
1248
  historyAction: pendingAction,
1263
- location: location2,
1249
+ location,
1264
1250
  initialized: true,
1265
1251
  navigation: IDLE_NAVIGATION,
1266
1252
  revalidation: "idle",
1267
1253
  restoreScrollPosition: getSavedScrollPosition(
1268
- location2,
1254
+ location,
1269
1255
  newState.matches || state.matches
1270
1256
  ),
1271
1257
  preventScrollReset,
@@ -1382,7 +1368,7 @@ function createRouter(init) {
1382
1368
  );
1383
1369
  return promise;
1384
1370
  }
1385
- async function startNavigation(historyAction, location2, opts) {
1371
+ async function startNavigation(historyAction, location, opts) {
1386
1372
  pendingNavigationController && pendingNavigationController.abort();
1387
1373
  pendingNavigationController = null;
1388
1374
  pendingAction = historyAction;
@@ -1395,22 +1381,22 @@ function createRouter(init) {
1395
1381
  let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
1396
1382
  // `matchRoutes()` has already been called if we're in here via `router.initialize()`
1397
1383
  state.matches
1398
- ) : matchRoutes(routesToUse, location2, basename);
1384
+ ) : matchRoutes(routesToUse, location, basename);
1399
1385
  let flushSync = (opts && opts.flushSync) === true;
1400
- if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location2) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1401
- completeNavigation(location2, { matches }, { flushSync });
1386
+ if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1387
+ completeNavigation(location, { matches }, { flushSync });
1402
1388
  return;
1403
1389
  }
1404
- let fogOfWar = checkFogOfWar(matches, routesToUse, location2.pathname);
1390
+ let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
1405
1391
  if (fogOfWar.active && fogOfWar.matches) {
1406
1392
  matches = fogOfWar.matches;
1407
1393
  }
1408
1394
  if (!matches) {
1409
1395
  let { error, notFoundMatches, route } = handleNavigational404(
1410
- location2.pathname
1396
+ location.pathname
1411
1397
  );
1412
1398
  completeNavigation(
1413
- location2,
1399
+ location,
1414
1400
  {
1415
1401
  matches: notFoundMatches,
1416
1402
  loaderData: {},
@@ -1425,7 +1411,7 @@ function createRouter(init) {
1425
1411
  pendingNavigationController = new AbortController();
1426
1412
  let request = createClientSideRequest(
1427
1413
  init.history,
1428
- location2,
1414
+ location,
1429
1415
  pendingNavigationController.signal,
1430
1416
  opts && opts.submission
1431
1417
  );
@@ -1441,7 +1427,7 @@ function createRouter(init) {
1441
1427
  } else if (opts && opts.submission && isMutationMethod(opts.submission.formMethod)) {
1442
1428
  let actionResult = await handleAction(
1443
1429
  request,
1444
- location2,
1430
+ location,
1445
1431
  opts.submission,
1446
1432
  matches,
1447
1433
  scopedContext,
@@ -1456,7 +1442,7 @@ function createRouter(init) {
1456
1442
  let [routeId, result] = actionResult.pendingActionResult;
1457
1443
  if (isErrorResult(result) && isRouteErrorResponse(result.error) && result.error.status === 404) {
1458
1444
  pendingNavigationController = null;
1459
- completeNavigation(location2, {
1445
+ completeNavigation(location, {
1460
1446
  matches: actionResult.matches,
1461
1447
  loaderData: {},
1462
1448
  errors: {
@@ -1468,7 +1454,7 @@ function createRouter(init) {
1468
1454
  }
1469
1455
  matches = actionResult.matches || matches;
1470
1456
  pendingActionResult = actionResult.pendingActionResult;
1471
- loadingNavigation = getLoadingNavigation(location2, opts.submission);
1457
+ loadingNavigation = getLoadingNavigation(location, opts.submission);
1472
1458
  flushSync = false;
1473
1459
  fogOfWar.active = false;
1474
1460
  request = createClientSideRequest(
@@ -1484,7 +1470,7 @@ function createRouter(init) {
1484
1470
  errors
1485
1471
  } = await handleLoaders(
1486
1472
  request,
1487
- location2,
1473
+ location,
1488
1474
  matches,
1489
1475
  scopedContext,
1490
1476
  fogOfWar.active,
@@ -1500,21 +1486,21 @@ function createRouter(init) {
1500
1486
  return;
1501
1487
  }
1502
1488
  pendingNavigationController = null;
1503
- completeNavigation(location2, {
1489
+ completeNavigation(location, {
1504
1490
  matches: updatedMatches || matches,
1505
1491
  ...getActionDataForCommit(pendingActionResult),
1506
1492
  loaderData,
1507
1493
  errors
1508
1494
  });
1509
1495
  }
1510
- async function handleAction(request, location2, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
1496
+ async function handleAction(request, location, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
1511
1497
  interruptActiveLoads();
1512
- let navigation = getSubmittingNavigation(location2, submission);
1498
+ let navigation = getSubmittingNavigation(location, submission);
1513
1499
  updateState({ navigation }, { flushSync: opts.flushSync === true });
1514
1500
  if (isFogOfWar) {
1515
1501
  let discoverResult = await discoverRoutes(
1516
1502
  matches,
1517
- location2.pathname,
1503
+ location.pathname,
1518
1504
  request.signal
1519
1505
  );
1520
1506
  if (discoverResult.type === "aborted") {
@@ -1533,7 +1519,7 @@ function createRouter(init) {
1533
1519
  };
1534
1520
  } else if (!discoverResult.matches) {
1535
1521
  let { notFoundMatches, error, route } = handleNavigational404(
1536
- location2.pathname
1522
+ location.pathname
1537
1523
  );
1538
1524
  return {
1539
1525
  matches: notFoundMatches,
@@ -1550,13 +1536,13 @@ function createRouter(init) {
1550
1536
  }
1551
1537
  }
1552
1538
  let result;
1553
- let actionMatch = getTargetMatch(matches, location2);
1539
+ let actionMatch = getTargetMatch(matches, location);
1554
1540
  if (!actionMatch.route.action && !actionMatch.route.lazy) {
1555
1541
  result = {
1556
1542
  type: "error" /* error */,
1557
1543
  error: getInternalRouterError(405, {
1558
1544
  method: request.method,
1559
- pathname: location2.pathname,
1545
+ pathname: location.pathname,
1560
1546
  routeId: actionMatch.route.id
1561
1547
  })
1562
1548
  };
@@ -1594,12 +1580,12 @@ function createRouter(init) {
1594
1580
  if (opts && opts.replace != null) {
1595
1581
  replace2 = opts.replace;
1596
1582
  } else {
1597
- let location3 = normalizeRedirectLocation(
1583
+ let location2 = normalizeRedirectLocation(
1598
1584
  result.response.headers.get("Location"),
1599
1585
  new URL(request.url),
1600
1586
  basename
1601
1587
  );
1602
- replace2 = location3 === state.location.pathname + state.location.search;
1588
+ replace2 = location2 === state.location.pathname + state.location.search;
1603
1589
  }
1604
1590
  await startRedirectNavigation(request, result, true, {
1605
1591
  submission,
@@ -1626,8 +1612,8 @@ function createRouter(init) {
1626
1612
  pendingActionResult: [actionMatch.route.id, result]
1627
1613
  };
1628
1614
  }
1629
- async function handleLoaders(request, location2, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
1630
- let loadingNavigation = overrideNavigation || getLoadingNavigation(location2, submission);
1615
+ async function handleLoaders(request, location, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
1616
+ let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
1631
1617
  let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
1632
1618
  let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
1633
1619
  if (isFogOfWar) {
@@ -1645,7 +1631,7 @@ function createRouter(init) {
1645
1631
  }
1646
1632
  let discoverResult = await discoverRoutes(
1647
1633
  matches,
1648
- location2.pathname,
1634
+ location.pathname,
1649
1635
  request.signal
1650
1636
  );
1651
1637
  if (discoverResult.type === "aborted") {
@@ -1661,7 +1647,7 @@ function createRouter(init) {
1661
1647
  };
1662
1648
  } else if (!discoverResult.matches) {
1663
1649
  let { error, notFoundMatches, route } = handleNavigational404(
1664
- location2.pathname
1650
+ location.pathname
1665
1651
  );
1666
1652
  return {
1667
1653
  matches: notFoundMatches,
@@ -1684,7 +1670,7 @@ function createRouter(init) {
1684
1670
  state,
1685
1671
  matches,
1686
1672
  activeSubmission,
1687
- location2,
1673
+ location,
1688
1674
  initialHydration ? [] : hydrationRouteProperties2,
1689
1675
  initialHydration === true,
1690
1676
  isRevalidationRequired,
@@ -1701,7 +1687,7 @@ function createRouter(init) {
1701
1687
  if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && revalidatingFetchers.length === 0) {
1702
1688
  let updatedFetchers2 = markFetchRedirectsDone();
1703
1689
  completeNavigation(
1704
- location2,
1690
+ location,
1705
1691
  {
1706
1692
  matches,
1707
1693
  loaderData: {},
@@ -2213,31 +2199,31 @@ function createRouter(init) {
2213
2199
  if (redirect2.response.headers.has("X-Remix-Revalidate")) {
2214
2200
  isRevalidationRequired = true;
2215
2201
  }
2216
- let location2 = redirect2.response.headers.get("Location");
2217
- invariant(location2, "Expected a Location header on the redirect Response");
2218
- location2 = normalizeRedirectLocation(
2219
- location2,
2202
+ let location = redirect2.response.headers.get("Location");
2203
+ invariant(location, "Expected a Location header on the redirect Response");
2204
+ location = normalizeRedirectLocation(
2205
+ location,
2220
2206
  new URL(request.url),
2221
2207
  basename
2222
2208
  );
2223
- let redirectLocation = createLocation(state.location, location2, {
2209
+ let redirectLocation = createLocation(state.location, location, {
2224
2210
  _isRedirect: true
2225
2211
  });
2226
2212
  if (isBrowser2) {
2227
2213
  let isDocumentReload = false;
2228
2214
  if (redirect2.response.headers.has("X-Remix-Reload-Document")) {
2229
2215
  isDocumentReload = true;
2230
- } else if (ABSOLUTE_URL_REGEX.test(location2)) {
2231
- const url = createBrowserURLImpl(location2, true);
2216
+ } else if (ABSOLUTE_URL_REGEX.test(location)) {
2217
+ const url = createBrowserURLImpl(location, true);
2232
2218
  isDocumentReload = // Hard reload if it's an absolute URL to a new origin
2233
2219
  url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename
2234
2220
  stripBasename(url.pathname, basename) == null;
2235
2221
  }
2236
2222
  if (isDocumentReload) {
2237
2223
  if (replace2) {
2238
- routerWindow.location.replace(location2);
2224
+ routerWindow.location.replace(location);
2239
2225
  } else {
2240
- routerWindow.location.assign(location2);
2226
+ routerWindow.location.assign(location);
2241
2227
  }
2242
2228
  return;
2243
2229
  }
@@ -2253,7 +2239,7 @@ function createRouter(init) {
2253
2239
  await startNavigation(redirectNavigationType, redirectLocation, {
2254
2240
  submission: {
2255
2241
  ...activeSubmission,
2256
- formAction: location2
2242
+ formAction: location
2257
2243
  },
2258
2244
  // Preserve these flags across redirects
2259
2245
  preventScrollReset: preventScrollReset || pendingPreventScrollReset,
@@ -2527,25 +2513,25 @@ function createRouter(init) {
2527
2513
  getScrollRestorationKey2 = null;
2528
2514
  };
2529
2515
  }
2530
- function getScrollKey(location2, matches) {
2516
+ function getScrollKey(location, matches) {
2531
2517
  if (getScrollRestorationKey2) {
2532
2518
  let key = getScrollRestorationKey2(
2533
- location2,
2519
+ location,
2534
2520
  matches.map((m) => convertRouteMatchToUiMatch(m, state.loaderData))
2535
2521
  );
2536
- return key || location2.key;
2522
+ return key || location.key;
2537
2523
  }
2538
- return location2.key;
2524
+ return location.key;
2539
2525
  }
2540
- function saveScrollPosition(location2, matches) {
2526
+ function saveScrollPosition(location, matches) {
2541
2527
  if (savedScrollPositions2 && getScrollPosition) {
2542
- let key = getScrollKey(location2, matches);
2528
+ let key = getScrollKey(location, matches);
2543
2529
  savedScrollPositions2[key] = getScrollPosition();
2544
2530
  }
2545
2531
  }
2546
- function getSavedScrollPosition(location2, matches) {
2532
+ function getSavedScrollPosition(location, matches) {
2547
2533
  if (savedScrollPositions2) {
2548
- let key = getScrollKey(location2, matches);
2534
+ let key = getScrollKey(location, matches);
2549
2535
  let y = savedScrollPositions2[key];
2550
2536
  if (typeof y === "number") {
2551
2537
  return y;
@@ -2599,8 +2585,7 @@ function createRouter(init) {
2599
2585
  children,
2600
2586
  routesToUse,
2601
2587
  localManifest,
2602
- mapRouteProperties2,
2603
- false
2588
+ mapRouteProperties2
2604
2589
  );
2605
2590
  }
2606
2591
  });
@@ -2641,7 +2626,7 @@ function createRouter(init) {
2641
2626
  manifest
2642
2627
  );
2643
2628
  }
2644
- function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
2629
+ function patchRoutes(routeId, children) {
2645
2630
  let isNonHMR = inFlightDataRoutes == null;
2646
2631
  let routesToUse = inFlightDataRoutes || dataRoutes;
2647
2632
  patchRoutesImpl(
@@ -2649,8 +2634,7 @@ function createRouter(init) {
2649
2634
  children,
2650
2635
  routesToUse,
2651
2636
  manifest,
2652
- mapRouteProperties2,
2653
- unstable_allowElementMutations
2637
+ mapRouteProperties2
2654
2638
  );
2655
2639
  if (isNonHMR) {
2656
2640
  dataRoutes = [...dataRoutes];
@@ -2692,10 +2676,7 @@ function createRouter(init) {
2692
2676
  _internalFetchControllers: fetchControllers,
2693
2677
  // TODO: Remove setRoutes, it's temporary to avoid dealing with
2694
2678
  // updating the tree while validating the update algorithm.
2695
- _internalSetRoutes,
2696
- _internalSetStateDoNotUseOrYouWillBreakYourApp(newState) {
2697
- updateState(newState);
2698
- }
2679
+ _internalSetRoutes
2699
2680
  };
2700
2681
  return router;
2701
2682
  }
@@ -2719,26 +2700,19 @@ function createStaticHandler(routes, opts) {
2719
2700
  skipLoaderErrorBubbling,
2720
2701
  skipRevalidation,
2721
2702
  dataStrategy,
2722
- unstable_stream: stream,
2723
2703
  unstable_respond: respond
2724
2704
  } = {}) {
2725
2705
  let url = new URL(request.url);
2726
2706
  let method = request.method;
2727
- let location2 = createLocation("", createPath(url), null, "default");
2728
- let matches = matchRoutes(dataRoutes, location2, basename);
2707
+ let location = createLocation("", createPath(url), null, "default");
2708
+ let matches = matchRoutes(dataRoutes, location, basename);
2729
2709
  requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
2730
- let respondOrStreamStaticContext = (ctx) => {
2731
- return stream ? stream(
2732
- requestContext,
2733
- () => Promise.resolve(ctx)
2734
- ) : respond ? respond(ctx) : void 0;
2735
- };
2736
2710
  if (!isValidMethod(method) && method !== "HEAD") {
2737
2711
  let error = getInternalRouterError(405, { method });
2738
2712
  let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
2739
2713
  let staticContext = {
2740
2714
  basename,
2741
- location: location2,
2715
+ location,
2742
2716
  matches: methodNotAllowedMatches,
2743
2717
  loaderData: {},
2744
2718
  actionData: null,
@@ -2749,13 +2723,13 @@ function createStaticHandler(routes, opts) {
2749
2723
  loaderHeaders: {},
2750
2724
  actionHeaders: {}
2751
2725
  };
2752
- return respondOrStreamStaticContext(staticContext) || staticContext;
2726
+ return respond ? respond(staticContext) : staticContext;
2753
2727
  } else if (!matches) {
2754
- let error = getInternalRouterError(404, { pathname: location2.pathname });
2728
+ let error = getInternalRouterError(404, { pathname: location.pathname });
2755
2729
  let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
2756
2730
  let staticContext = {
2757
2731
  basename,
2758
- location: location2,
2732
+ location,
2759
2733
  matches: notFoundMatches,
2760
2734
  loaderData: {},
2761
2735
  actionData: null,
@@ -2766,9 +2740,9 @@ function createStaticHandler(routes, opts) {
2766
2740
  loaderHeaders: {},
2767
2741
  actionHeaders: {}
2768
2742
  };
2769
- return respondOrStreamStaticContext(staticContext) || staticContext;
2743
+ return respond ? respond(staticContext) : staticContext;
2770
2744
  }
2771
- if (stream || respond && matches.some(
2745
+ if (respond && matches.some(
2772
2746
  (m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
2773
2747
  )) {
2774
2748
  invariant(
@@ -2793,30 +2767,9 @@ function createStaticHandler(routes, opts) {
2793
2767
  },
2794
2768
  true,
2795
2769
  async () => {
2796
- if (stream) {
2797
- let res2 = await stream(
2798
- requestContext,
2799
- async (revalidationRequest) => {
2800
- let result3 = await queryImpl(
2801
- revalidationRequest,
2802
- location2,
2803
- matches,
2804
- requestContext,
2805
- dataStrategy || null,
2806
- skipLoaderErrorBubbling === true,
2807
- null,
2808
- filterMatchesToLoad || null,
2809
- skipRevalidation === true
2810
- );
2811
- return isResponse(result3) ? result3 : { location: location2, basename, ...result3 };
2812
- }
2813
- );
2814
- return res2;
2815
- }
2816
- invariant(respond, "Expected respond to be defined");
2817
2770
  let result2 = await queryImpl(
2818
2771
  request,
2819
- location2,
2772
+ location,
2820
2773
  matches,
2821
2774
  requestContext,
2822
2775
  dataStrategy || null,
@@ -2828,7 +2781,7 @@ function createStaticHandler(routes, opts) {
2828
2781
  if (isResponse(result2)) {
2829
2782
  return result2;
2830
2783
  }
2831
- renderedStaticContext = { location: location2, basename, ...result2 };
2784
+ renderedStaticContext = { location, basename, ...result2 };
2832
2785
  let res = await respond(renderedStaticContext);
2833
2786
  return res;
2834
2787
  },
@@ -2840,13 +2793,14 @@ function createStaticHandler(routes, opts) {
2840
2793
  if (routeId in renderedStaticContext.loaderData) {
2841
2794
  renderedStaticContext.loaderData[routeId] = void 0;
2842
2795
  }
2843
- let staticContext = getStaticContextFromError(
2844
- dataRoutes,
2845
- renderedStaticContext,
2846
- error,
2847
- skipLoaderErrorBubbling ? routeId : findNearestBoundary(matches, routeId).route.id
2796
+ return respond(
2797
+ getStaticContextFromError(
2798
+ dataRoutes,
2799
+ renderedStaticContext,
2800
+ error,
2801
+ skipLoaderErrorBubbling ? routeId : findNearestBoundary(matches, routeId).route.id
2802
+ )
2848
2803
  );
2849
- return respondOrStreamStaticContext(staticContext) || staticContext;
2850
2804
  } else {
2851
2805
  let boundaryRouteId = skipLoaderErrorBubbling ? routeId : findNearestBoundary(
2852
2806
  matches,
@@ -2854,9 +2808,9 @@ function createStaticHandler(routes, opts) {
2854
2808
  (m) => m.route.id === routeId || m.route.loader
2855
2809
  )?.route.id || routeId
2856
2810
  ).route.id;
2857
- let staticContext = {
2811
+ return respond({
2858
2812
  matches,
2859
- location: location2,
2813
+ location,
2860
2814
  basename,
2861
2815
  loaderData: {},
2862
2816
  actionData: null,
@@ -2866,8 +2820,7 @@ function createStaticHandler(routes, opts) {
2866
2820
  statusCode: isRouteErrorResponse(error) ? error.status : 500,
2867
2821
  actionHeaders: {},
2868
2822
  loaderHeaders: {}
2869
- };
2870
- return respondOrStreamStaticContext(staticContext) || staticContext;
2823
+ });
2871
2824
  }
2872
2825
  }
2873
2826
  );
@@ -2882,7 +2835,7 @@ function createStaticHandler(routes, opts) {
2882
2835
  }
2883
2836
  let result = await queryImpl(
2884
2837
  request,
2885
- location2,
2838
+ location,
2886
2839
  matches,
2887
2840
  requestContext,
2888
2841
  dataStrategy || null,
@@ -2894,7 +2847,7 @@ function createStaticHandler(routes, opts) {
2894
2847
  if (isResponse(result)) {
2895
2848
  return result;
2896
2849
  }
2897
- return { location: location2, basename, ...result };
2850
+ return { location, basename, ...result };
2898
2851
  }
2899
2852
  async function queryRoute(request, {
2900
2853
  routeId,
@@ -2904,22 +2857,22 @@ function createStaticHandler(routes, opts) {
2904
2857
  } = {}) {
2905
2858
  let url = new URL(request.url);
2906
2859
  let method = request.method;
2907
- let location2 = createLocation("", createPath(url), null, "default");
2908
- let matches = matchRoutes(dataRoutes, location2, basename);
2860
+ let location = createLocation("", createPath(url), null, "default");
2861
+ let matches = matchRoutes(dataRoutes, location, basename);
2909
2862
  requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
2910
2863
  if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
2911
2864
  throw getInternalRouterError(405, { method });
2912
2865
  } else if (!matches) {
2913
- throw getInternalRouterError(404, { pathname: location2.pathname });
2866
+ throw getInternalRouterError(404, { pathname: location.pathname });
2914
2867
  }
2915
- let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location2);
2868
+ let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location);
2916
2869
  if (routeId && !match) {
2917
2870
  throw getInternalRouterError(403, {
2918
- pathname: location2.pathname,
2871
+ pathname: location.pathname,
2919
2872
  routeId
2920
2873
  });
2921
2874
  } else if (!match) {
2922
- throw getInternalRouterError(404, { pathname: location2.pathname });
2875
+ throw getInternalRouterError(404, { pathname: location.pathname });
2923
2876
  }
2924
2877
  if (respond && matches.some(
2925
2878
  (m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
@@ -2942,7 +2895,7 @@ function createStaticHandler(routes, opts) {
2942
2895
  async () => {
2943
2896
  let result2 = await queryImpl(
2944
2897
  request,
2945
- location2,
2898
+ location,
2946
2899
  matches,
2947
2900
  requestContext,
2948
2901
  dataStrategy || null,
@@ -2975,7 +2928,7 @@ function createStaticHandler(routes, opts) {
2975
2928
  }
2976
2929
  let result = await queryImpl(
2977
2930
  request,
2978
- location2,
2931
+ location,
2979
2932
  matches,
2980
2933
  requestContext,
2981
2934
  dataStrategy || null,
@@ -2999,7 +2952,7 @@ function createStaticHandler(routes, opts) {
2999
2952
  }
3000
2953
  return void 0;
3001
2954
  }
3002
- async function queryImpl(request, location2, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
2955
+ async function queryImpl(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
3003
2956
  invariant(
3004
2957
  request.signal,
3005
2958
  "query()/queryRoute() requests must contain an AbortController signal"
@@ -3009,7 +2962,7 @@ function createStaticHandler(routes, opts) {
3009
2962
  let result2 = await submit(
3010
2963
  request,
3011
2964
  matches,
3012
- routeMatch || getTargetMatch(matches, location2),
2965
+ routeMatch || getTargetMatch(matches, location),
3013
2966
  requestContext,
3014
2967
  dataStrategy,
3015
2968
  skipLoaderErrorBubbling,
@@ -3325,7 +3278,7 @@ function throwStaticHandlerAbortedError(request, isRouteRequest) {
3325
3278
  function isSubmissionNavigation(opts) {
3326
3279
  return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0);
3327
3280
  }
3328
- function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
3281
+ function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
3329
3282
  let contextualMatches;
3330
3283
  let activeRouteMatch;
3331
3284
  if (fromRouteId) {
@@ -3344,12 +3297,12 @@ function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
3344
3297
  let path = resolveTo(
3345
3298
  to ? to : ".",
3346
3299
  getResolveToMatches(contextualMatches),
3347
- stripBasename(location2.pathname, basename) || location2.pathname,
3300
+ stripBasename(location.pathname, basename) || location.pathname,
3348
3301
  relative === "path"
3349
3302
  );
3350
3303
  if (to == null) {
3351
- path.search = location2.search;
3352
- path.hash = location2.hash;
3304
+ path.search = location.search;
3305
+ path.hash = location.hash;
3353
3306
  }
3354
3307
  if ((to == null || to === "" || to === ".") && activeRouteMatch) {
3355
3308
  let nakedIndex = hasNakedIndexQuery(path.search);
@@ -3476,10 +3429,10 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
3476
3429
  parsedPath.search = `?${searchParams}`;
3477
3430
  return { path: createPath(parsedPath), submission };
3478
3431
  }
3479
- function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location2, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, pendingActionResult) {
3432
+ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, pendingActionResult) {
3480
3433
  let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
3481
3434
  let currentUrl = history.createURL(state.location);
3482
- let nextUrl = history.createURL(location2);
3435
+ let nextUrl = history.createURL(location);
3483
3436
  let maxIdx;
3484
3437
  if (initialHydration && state.errors) {
3485
3438
  let boundaryId = Object.keys(state.errors)[0];
@@ -3682,7 +3635,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
3682
3635
  }
3683
3636
  return arg.defaultShouldRevalidate;
3684
3637
  }
3685
- function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
3638
+ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2) {
3686
3639
  let childrenToPatch;
3687
3640
  if (routeId) {
3688
3641
  let route = manifest[routeId];
@@ -3697,47 +3650,18 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
3697
3650
  } else {
3698
3651
  childrenToPatch = routesToUse;
3699
3652
  }
3700
- let uniqueChildren = [];
3701
- let existingChildren = [];
3702
- children.forEach((newRoute) => {
3703
- let existingRoute = childrenToPatch.find(
3704
- (existingRoute2) => isSameRoute(newRoute, existingRoute2)
3705
- );
3706
- if (existingRoute) {
3707
- existingChildren.push({ existingRoute, newRoute });
3708
- } else {
3709
- uniqueChildren.push(newRoute);
3710
- }
3711
- });
3712
- if (uniqueChildren.length > 0) {
3713
- let newRoutes = convertRoutesToDataRoutes(
3714
- uniqueChildren,
3715
- mapRouteProperties2,
3716
- [routeId || "_", "patch", String(childrenToPatch?.length || "0")],
3717
- manifest
3718
- );
3719
- childrenToPatch.push(...newRoutes);
3720
- }
3721
- if (allowElementMutations && existingChildren.length > 0) {
3722
- for (let i = 0; i < existingChildren.length; i++) {
3723
- let { existingRoute, newRoute } = existingChildren[i];
3724
- let existingRouteTyped = existingRoute;
3725
- let [newRouteTyped] = convertRoutesToDataRoutes(
3726
- [newRoute],
3727
- mapRouteProperties2,
3728
- [],
3729
- // Doesn't matter for mutated routes since they already have an id
3730
- {},
3731
- // Don't touch the manifest here since we're updating in place
3732
- true
3733
- );
3734
- Object.assign(existingRouteTyped, {
3735
- element: newRouteTyped.element ? newRouteTyped.element : existingRouteTyped.element,
3736
- errorElement: newRouteTyped.errorElement ? newRouteTyped.errorElement : existingRouteTyped.errorElement,
3737
- hydrateFallbackElement: newRouteTyped.hydrateFallbackElement ? newRouteTyped.hydrateFallbackElement : existingRouteTyped.hydrateFallbackElement
3738
- });
3739
- }
3740
- }
3653
+ let uniqueChildren = children.filter(
3654
+ (newRoute) => !childrenToPatch.some(
3655
+ (existingRoute) => isSameRoute(newRoute, existingRoute)
3656
+ )
3657
+ );
3658
+ let newRoutes = convertRoutesToDataRoutes(
3659
+ uniqueChildren,
3660
+ mapRouteProperties2,
3661
+ [routeId || "_", "patch", String(childrenToPatch?.length || "0")],
3662
+ manifest
3663
+ );
3664
+ childrenToPatch.push(...newRoutes);
3741
3665
  }
3742
3666
  function isSameRoute(newRoute, existingRoute) {
3743
3667
  if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
@@ -4086,7 +4010,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, laz
4086
4010
  return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
4087
4011
  },
4088
4012
  resolve(handlerOverride) {
4089
- if (isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (match.route.lazy || match.route.loader)) {
4013
+ if (isUsingNewApi || shouldLoad || handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
4090
4014
  return callLoaderOrAction({
4091
4015
  request,
4092
4016
  match,
@@ -4346,39 +4270,39 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
4346
4270
  return { type: "data" /* data */, data: result };
4347
4271
  }
4348
4272
  function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename) {
4349
- let location2 = response.headers.get("Location");
4273
+ let location = response.headers.get("Location");
4350
4274
  invariant(
4351
- location2,
4275
+ location,
4352
4276
  "Redirects returned/thrown from loaders/actions must have a Location header"
4353
4277
  );
4354
- if (!ABSOLUTE_URL_REGEX.test(location2)) {
4278
+ if (!ABSOLUTE_URL_REGEX.test(location)) {
4355
4279
  let trimmedMatches = matches.slice(
4356
4280
  0,
4357
4281
  matches.findIndex((m) => m.route.id === routeId) + 1
4358
4282
  );
4359
- location2 = normalizeTo(
4283
+ location = normalizeTo(
4360
4284
  new URL(request.url),
4361
4285
  trimmedMatches,
4362
4286
  basename,
4363
- location2
4287
+ location
4364
4288
  );
4365
- response.headers.set("Location", location2);
4289
+ response.headers.set("Location", location);
4366
4290
  }
4367
4291
  return response;
4368
4292
  }
4369
- function normalizeRedirectLocation(location2, currentUrl, basename) {
4370
- if (ABSOLUTE_URL_REGEX.test(location2)) {
4371
- let normalizedLocation = location2;
4293
+ function normalizeRedirectLocation(location, currentUrl, basename) {
4294
+ if (ABSOLUTE_URL_REGEX.test(location)) {
4295
+ let normalizedLocation = location;
4372
4296
  let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
4373
4297
  let isSameBasename = stripBasename(url.pathname, basename) != null;
4374
4298
  if (url.origin === currentUrl.origin && isSameBasename) {
4375
4299
  return url.pathname + url.search + url.hash;
4376
4300
  }
4377
4301
  }
4378
- return location2;
4302
+ return location;
4379
4303
  }
4380
- function createClientSideRequest(history, location2, signal, submission) {
4381
- let url = history.createURL(stripHashFromPath(location2)).toString();
4304
+ function createClientSideRequest(history, location, signal, submission) {
4305
+ let url = history.createURL(stripHashFromPath(location)).toString();
4382
4306
  let init = { signal };
4383
4307
  if (submission && isMutationMethod(submission.formMethod)) {
4384
4308
  let { formMethod, formEncType } = submission;
@@ -4650,8 +4574,8 @@ function isMutationMethod(method) {
4650
4574
  function hasNakedIndexQuery(search) {
4651
4575
  return new URLSearchParams(search).getAll("index").some((v) => v === "");
4652
4576
  }
4653
- function getTargetMatch(matches, location2) {
4654
- let search = typeof location2 === "string" ? parsePath(location2).search : location2.search;
4577
+ function getTargetMatch(matches, location) {
4578
+ let search = typeof location === "string" ? parsePath(location).search : location.search;
4655
4579
  if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
4656
4580
  return matches[matches.length - 1];
4657
4581
  }
@@ -4692,11 +4616,11 @@ function getSubmissionFromNavigation(navigation) {
4692
4616
  };
4693
4617
  }
4694
4618
  }
4695
- function getLoadingNavigation(location2, submission) {
4619
+ function getLoadingNavigation(location, submission) {
4696
4620
  if (submission) {
4697
4621
  let navigation = {
4698
4622
  state: "loading",
4699
- location: location2,
4623
+ location,
4700
4624
  formMethod: submission.formMethod,
4701
4625
  formAction: submission.formAction,
4702
4626
  formEncType: submission.formEncType,
@@ -4708,7 +4632,7 @@ function getLoadingNavigation(location2, submission) {
4708
4632
  } else {
4709
4633
  let navigation = {
4710
4634
  state: "loading",
4711
- location: location2,
4635
+ location,
4712
4636
  formMethod: void 0,
4713
4637
  formAction: void 0,
4714
4638
  formEncType: void 0,
@@ -4719,10 +4643,10 @@ function getLoadingNavigation(location2, submission) {
4719
4643
  return navigation;
4720
4644
  }
4721
4645
  }
4722
- function getSubmittingNavigation(location2, submission) {
4646
+ function getSubmittingNavigation(location, submission) {
4723
4647
  let navigation = {
4724
4648
  state: "submitting",
4725
- location: location2,
4649
+ location,
4726
4650
  formMethod: submission.formMethod,
4727
4651
  formAction: submission.formAction,
4728
4652
  formEncType: submission.formEncType,
@@ -5048,18 +4972,18 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5048
4972
  );
5049
4973
  }
5050
4974
  let locationFromContext = useLocation();
5051
- let location2;
4975
+ let location;
5052
4976
  if (locationArg) {
5053
4977
  let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
5054
4978
  invariant(
5055
4979
  parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase),
5056
4980
  `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.`
5057
4981
  );
5058
- location2 = parsedLocationArg;
4982
+ location = parsedLocationArg;
5059
4983
  } else {
5060
- location2 = locationFromContext;
4984
+ location = locationFromContext;
5061
4985
  }
5062
- let pathname = location2.pathname || "/";
4986
+ let pathname = location.pathname || "/";
5063
4987
  let remainingPathname = pathname;
5064
4988
  if (parentPathnameBase !== "/") {
5065
4989
  let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
@@ -5070,11 +4994,11 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5070
4994
  if (ENABLE_DEV_WARNINGS) {
5071
4995
  warning(
5072
4996
  parentRoute || matches != null,
5073
- `No routes matched location "${location2.pathname}${location2.search}${location2.hash}" `
4997
+ `No routes matched location "${location.pathname}${location.search}${location.hash}" `
5074
4998
  );
5075
4999
  warning(
5076
5000
  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,
5077
- `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.`
5001
+ `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.`
5078
5002
  );
5079
5003
  }
5080
5004
  let renderedMatches = _renderMatches(
@@ -5108,7 +5032,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5108
5032
  hash: "",
5109
5033
  state: null,
5110
5034
  key: "default",
5111
- ...location2
5035
+ ...location
5112
5036
  },
5113
5037
  navigationType: "POP" /* Pop */
5114
5038
  }
@@ -5870,9 +5794,9 @@ function Router({
5870
5794
  }
5871
5795
  function Routes({
5872
5796
  children,
5873
- location: location2
5797
+ location
5874
5798
  }) {
5875
- return useRoutes(createRoutesFromChildren(children), location2);
5799
+ return useRoutes(createRoutesFromChildren(children), location);
5876
5800
  }
5877
5801
  function Await({
5878
5802
  children,
@@ -6296,7 +6220,7 @@ async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
6296
6220
  )
6297
6221
  );
6298
6222
  }
6299
- function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location2, mode) {
6223
+ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
6300
6224
  let isNew = (match, index) => {
6301
6225
  if (!currentMatches[index]) return true;
6302
6226
  return match.route.id !== currentMatches[index].route.id;
@@ -6326,7 +6250,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
6326
6250
  if (match.route.shouldRevalidate) {
6327
6251
  let routeChoice = match.route.shouldRevalidate({
6328
6252
  currentUrl: new URL(
6329
- location2.pathname + location2.search + location2.hash,
6253
+ location.pathname + location.search + location.hash,
6330
6254
  window.origin
6331
6255
  ),
6332
6256
  currentParams: currentMatches[0]?.params || {},
@@ -6956,7 +6880,7 @@ async function decodeDeferred(reader) {
6956
6880
  }
6957
6881
  function encode(input, options) {
6958
6882
  const { plugins, postPlugins, signal } = options ?? {};
6959
- const encoder3 = {
6883
+ const encoder2 = {
6960
6884
  deferred: {},
6961
6885
  index: 0,
6962
6886
  indices: /* @__PURE__ */ new Map(),
@@ -6969,7 +6893,7 @@ function encode(input, options) {
6969
6893
  let lastSentIndex = 0;
6970
6894
  const readable = new ReadableStream({
6971
6895
  async start(controller) {
6972
- const id = flatten.call(encoder3, input);
6896
+ const id = flatten.call(encoder2, input);
6973
6897
  if (Array.isArray(id)) {
6974
6898
  throw new Error("This should never happen");
6975
6899
  }
@@ -6978,13 +6902,13 @@ function encode(input, options) {
6978
6902
  `));
6979
6903
  } else {
6980
6904
  controller.enqueue(
6981
- textEncoder.encode(`[${encoder3.stringified.join(",")}]
6905
+ textEncoder.encode(`[${encoder2.stringified.join(",")}]
6982
6906
  `)
6983
6907
  );
6984
- lastSentIndex = encoder3.stringified.length - 1;
6908
+ lastSentIndex = encoder2.stringified.length - 1;
6985
6909
  }
6986
6910
  const seenPromises = /* @__PURE__ */ new WeakSet();
6987
- if (Object.keys(encoder3.deferred).length) {
6911
+ if (Object.keys(encoder2.deferred).length) {
6988
6912
  let raceDone;
6989
6913
  const racePromise = new Promise((resolve, reject) => {
6990
6914
  raceDone = resolve;
@@ -6999,19 +6923,19 @@ function encode(input, options) {
6999
6923
  }
7000
6924
  }
7001
6925
  });
7002
- while (Object.keys(encoder3.deferred).length > 0) {
6926
+ while (Object.keys(encoder2.deferred).length > 0) {
7003
6927
  for (const [deferredId, deferred] of Object.entries(
7004
- encoder3.deferred
6928
+ encoder2.deferred
7005
6929
  )) {
7006
6930
  if (seenPromises.has(deferred)) continue;
7007
6931
  seenPromises.add(
7008
6932
  // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
7009
- encoder3.deferred[Number(deferredId)] = Promise.race([
6933
+ encoder2.deferred[Number(deferredId)] = Promise.race([
7010
6934
  racePromise,
7011
6935
  deferred
7012
6936
  ]).then(
7013
6937
  (resolved) => {
7014
- const id2 = flatten.call(encoder3, resolved);
6938
+ const id2 = flatten.call(encoder2, resolved);
7015
6939
  if (Array.isArray(id2)) {
7016
6940
  controller.enqueue(
7017
6941
  textEncoder.encode(
@@ -7019,7 +6943,7 @@ function encode(input, options) {
7019
6943
  `
7020
6944
  )
7021
6945
  );
7022
- encoder3.index++;
6946
+ encoder2.index++;
7023
6947
  lastSentIndex++;
7024
6948
  } else if (id2 < 0) {
7025
6949
  controller.enqueue(
@@ -7029,21 +6953,21 @@ function encode(input, options) {
7029
6953
  )
7030
6954
  );
7031
6955
  } else {
7032
- const values = encoder3.stringified.slice(lastSentIndex + 1).join(",");
6956
+ const values = encoder2.stringified.slice(lastSentIndex + 1).join(",");
7033
6957
  controller.enqueue(
7034
6958
  textEncoder.encode(
7035
6959
  `${TYPE_PROMISE}${deferredId}:[${values}]
7036
6960
  `
7037
6961
  )
7038
6962
  );
7039
- lastSentIndex = encoder3.stringified.length - 1;
6963
+ lastSentIndex = encoder2.stringified.length - 1;
7040
6964
  }
7041
6965
  },
7042
6966
  (reason) => {
7043
6967
  if (!reason || typeof reason !== "object" || !(reason instanceof Error)) {
7044
6968
  reason = new Error("An unknown error occurred");
7045
6969
  }
7046
- const id2 = flatten.call(encoder3, reason);
6970
+ const id2 = flatten.call(encoder2, reason);
7047
6971
  if (Array.isArray(id2)) {
7048
6972
  controller.enqueue(
7049
6973
  textEncoder.encode(
@@ -7051,7 +6975,7 @@ function encode(input, options) {
7051
6975
  `
7052
6976
  )
7053
6977
  );
7054
- encoder3.index++;
6978
+ encoder2.index++;
7055
6979
  lastSentIndex++;
7056
6980
  } else if (id2 < 0) {
7057
6981
  controller.enqueue(
@@ -7059,26 +6983,26 @@ function encode(input, options) {
7059
6983
  `)
7060
6984
  );
7061
6985
  } else {
7062
- const values = encoder3.stringified.slice(lastSentIndex + 1).join(",");
6986
+ const values = encoder2.stringified.slice(lastSentIndex + 1).join(",");
7063
6987
  controller.enqueue(
7064
6988
  textEncoder.encode(
7065
6989
  `${TYPE_ERROR}${deferredId}:[${values}]
7066
6990
  `
7067
6991
  )
7068
6992
  );
7069
- lastSentIndex = encoder3.stringified.length - 1;
6993
+ lastSentIndex = encoder2.stringified.length - 1;
7070
6994
  }
7071
6995
  }
7072
6996
  ).finally(() => {
7073
- delete encoder3.deferred[Number(deferredId)];
6997
+ delete encoder2.deferred[Number(deferredId)];
7074
6998
  })
7075
6999
  );
7076
7000
  }
7077
- await Promise.race(Object.values(encoder3.deferred));
7001
+ await Promise.race(Object.values(encoder2.deferred));
7078
7002
  }
7079
7003
  raceDone();
7080
7004
  }
7081
- await Promise.all(Object.values(encoder3.deferred));
7005
+ await Promise.all(Object.values(encoder2.deferred));
7082
7006
  controller.close();
7083
7007
  }
7084
7008
  });
@@ -7197,7 +7121,7 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
7197
7121
  );
7198
7122
  return async (args) => args.unstable_runClientMiddleware(dataStrategy);
7199
7123
  }
7200
- function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode, ssr, basename, shouldAllowOptOut = () => true) {
7124
+ function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode, ssr, basename) {
7201
7125
  return async (args) => {
7202
7126
  let { request, matches, fetcherKey } = args;
7203
7127
  let router = getRouter();
@@ -7220,8 +7144,7 @@ function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode,
7220
7144
  getRouteInfo,
7221
7145
  fetchAndDecode,
7222
7146
  ssr,
7223
- basename,
7224
- shouldAllowOptOut
7147
+ basename
7225
7148
  );
7226
7149
  };
7227
7150
  }
@@ -7273,7 +7196,7 @@ async function nonSsrStrategy(args, getRouteInfo, fetchAndDecode, basename) {
7273
7196
  );
7274
7197
  return results;
7275
7198
  }
7276
- async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, basename, shouldAllowOptOut = () => true) {
7199
+ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, basename) {
7277
7200
  let routesParams = /* @__PURE__ */ new Set();
7278
7201
  let foundOptOutRoute = false;
7279
7202
  let routeDfds = args.matches.map(() => createDeferred2());
@@ -7293,7 +7216,7 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
7293
7216
  hasShouldRevalidate === true);
7294
7217
  return;
7295
7218
  }
7296
- if (shouldAllowOptOut(m) && hasClientLoader) {
7219
+ if (hasClientLoader) {
7297
7220
  if (hasLoader) {
7298
7221
  foundOptOutRoute = true;
7299
7222
  }
@@ -7396,7 +7319,7 @@ function stripIndexParam(url) {
7396
7319
  }
7397
7320
  return url;
7398
7321
  }
7399
- function singleFetchUrl(reqUrl, basename, extension) {
7322
+ function singleFetchUrl(reqUrl, basename) {
7400
7323
  let url = typeof reqUrl === "string" ? new URL(
7401
7324
  reqUrl,
7402
7325
  // This can be called during the SSR flow via PrefetchPageLinksImpl so
@@ -7404,17 +7327,17 @@ function singleFetchUrl(reqUrl, basename, extension) {
7404
7327
  typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
7405
7328
  ) : reqUrl;
7406
7329
  if (url.pathname === "/") {
7407
- url.pathname = `_root.${extension}`;
7330
+ url.pathname = "_root.data";
7408
7331
  } else if (basename && stripBasename(url.pathname, basename) === "/") {
7409
- url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
7332
+ url.pathname = `${basename.replace(/\/$/, "")}/_root.data`;
7410
7333
  } else {
7411
- url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
7334
+ url.pathname = `${url.pathname.replace(/\/$/, "")}.data`;
7412
7335
  }
7413
7336
  return url;
7414
7337
  }
7415
7338
  async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
7416
7339
  let { request } = args;
7417
- let url = singleFetchUrl(request.url, basename, "data");
7340
+ let url = singleFetchUrl(request.url, basename);
7418
7341
  if (request.method === "GET") {
7419
7342
  url = stripIndexParam(url);
7420
7343
  if (targetRoutes) {
@@ -7511,13 +7434,13 @@ function decodeViaTurboStream(body, global2) {
7511
7434
  function unwrapSingleFetchResult(result, routeId) {
7512
7435
  if ("redirect" in result) {
7513
7436
  let {
7514
- redirect: location2,
7437
+ redirect: location,
7515
7438
  revalidate,
7516
7439
  reload,
7517
7440
  replace: replace2,
7518
7441
  status
7519
7442
  } = result.redirect;
7520
- throw redirect(location2, {
7443
+ throw redirect(location, {
7521
7444
  status,
7522
7445
  headers: {
7523
7446
  // Three R's of redirecting (lol Veep)
@@ -8448,7 +8371,7 @@ function PrefetchPageLinksImpl({
8448
8371
  matches: nextMatches,
8449
8372
  ...linkProps
8450
8373
  }) {
8451
- let location2 = useLocation();
8374
+ let location = useLocation();
8452
8375
  let { manifest, routeModules } = useFrameworkContext();
8453
8376
  let { basename } = useDataRouterContext2();
8454
8377
  let { loaderData, matches } = useDataRouterStateContext();
@@ -8458,10 +8381,10 @@ function PrefetchPageLinksImpl({
8458
8381
  nextMatches,
8459
8382
  matches,
8460
8383
  manifest,
8461
- location2,
8384
+ location,
8462
8385
  "data"
8463
8386
  ),
8464
- [page, nextMatches, matches, manifest, location2]
8387
+ [page, nextMatches, matches, manifest, location]
8465
8388
  );
8466
8389
  let newMatchesForAssets = React9.useMemo(
8467
8390
  () => getNewMatchesForLinks(
@@ -8469,13 +8392,13 @@ function PrefetchPageLinksImpl({
8469
8392
  nextMatches,
8470
8393
  matches,
8471
8394
  manifest,
8472
- location2,
8395
+ location,
8473
8396
  "assets"
8474
8397
  ),
8475
- [page, nextMatches, matches, manifest, location2]
8398
+ [page, nextMatches, matches, manifest, location]
8476
8399
  );
8477
8400
  let dataHrefs = React9.useMemo(() => {
8478
- if (page === location2.pathname + location2.search + location2.hash) {
8401
+ if (page === location.pathname + location.search + location.hash) {
8479
8402
  return [];
8480
8403
  }
8481
8404
  let routesParams = /* @__PURE__ */ new Set();
@@ -8496,7 +8419,7 @@ function PrefetchPageLinksImpl({
8496
8419
  if (routesParams.size === 0) {
8497
8420
  return [];
8498
8421
  }
8499
- let url = singleFetchUrl(page, basename, "data");
8422
+ let url = singleFetchUrl(page, basename);
8500
8423
  if (foundOptOutRoute && routesParams.size > 0) {
8501
8424
  url.searchParams.set(
8502
8425
  "_routes",
@@ -8507,7 +8430,7 @@ function PrefetchPageLinksImpl({
8507
8430
  }, [
8508
8431
  basename,
8509
8432
  loaderData,
8510
- location2,
8433
+ location,
8511
8434
  manifest,
8512
8435
  newMatchesForData,
8513
8436
  nextMatches,
@@ -8532,7 +8455,7 @@ function Meta() {
8532
8455
  matches: routerMatches,
8533
8456
  loaderData
8534
8457
  } = useDataRouterStateContext();
8535
- let location2 = useLocation();
8458
+ let location = useLocation();
8536
8459
  let _matches = getActiveMatches(routerMatches, errors, isSpaMode);
8537
8460
  let error = null;
8538
8461
  if (errors) {
@@ -8562,7 +8485,7 @@ function Meta() {
8562
8485
  routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
8563
8486
  data: data2,
8564
8487
  params,
8565
- location: location2,
8488
+ location,
8566
8489
  matches,
8567
8490
  error
8568
8491
  }) : Array.isArray(routeModule.meta) ? [...routeModule.meta] : routeModule.meta;
@@ -8794,7 +8717,7 @@ function mergeRefs(...refs) {
8794
8717
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
8795
8718
  try {
8796
8719
  if (isBrowser) {
8797
- window.__reactRouterVersion = "0.0.0-experimental-1fcc8eb1d";
8720
+ window.__reactRouterVersion = "0.0.0-experimental-d82b9430b";
8798
8721
  }
8799
8722
  } catch (e) {
8800
8723
  }
@@ -9052,14 +8975,14 @@ var NavLink = React10.forwardRef(
9052
8975
  ...rest
9053
8976
  }, ref) {
9054
8977
  let path = useResolvedPath(to, { relative: rest.relative });
9055
- let location2 = useLocation();
8978
+ let location = useLocation();
9056
8979
  let routerState = React10.useContext(DataRouterStateContext);
9057
8980
  let { navigator, basename } = React10.useContext(NavigationContext);
9058
8981
  let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
9059
8982
  // eslint-disable-next-line react-hooks/rules-of-hooks
9060
8983
  useViewTransitionState(path) && viewTransition === true;
9061
8984
  let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
9062
- let locationPathname = location2.pathname;
8985
+ let locationPathname = location.pathname;
9063
8986
  let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
9064
8987
  if (!caseSensitive) {
9065
8988
  locationPathname = locationPathname.toLowerCase();
@@ -9164,19 +9087,19 @@ function ScrollRestoration({
9164
9087
  }) {
9165
9088
  let remixContext = React10.useContext(FrameworkContext);
9166
9089
  let { basename } = React10.useContext(NavigationContext);
9167
- let location2 = useLocation();
9090
+ let location = useLocation();
9168
9091
  let matches = useMatches();
9169
9092
  useScrollRestoration({ getKey, storageKey });
9170
9093
  let ssrKey = React10.useMemo(
9171
9094
  () => {
9172
9095
  if (!remixContext || !getKey) return null;
9173
9096
  let userKey = getScrollRestorationKey(
9174
- location2,
9097
+ location,
9175
9098
  matches,
9176
9099
  basename,
9177
9100
  getKey
9178
9101
  );
9179
- return userKey !== location2.key ? userKey : null;
9102
+ return userKey !== location.key ? userKey : null;
9180
9103
  },
9181
9104
  // Nah, we only need this the first time for the SSR render
9182
9105
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -9237,13 +9160,13 @@ function useLinkClickHandler(to, {
9237
9160
  viewTransition
9238
9161
  } = {}) {
9239
9162
  let navigate = useNavigate();
9240
- let location2 = useLocation();
9163
+ let location = useLocation();
9241
9164
  let path = useResolvedPath(to, { relative });
9242
9165
  return React10.useCallback(
9243
9166
  (event) => {
9244
9167
  if (shouldProcessLinkClick(event, target)) {
9245
9168
  event.preventDefault();
9246
- let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location2) === createPath(path);
9169
+ let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
9247
9170
  navigate(to, {
9248
9171
  replace: replace2,
9249
9172
  state,
@@ -9254,7 +9177,7 @@ function useLinkClickHandler(to, {
9254
9177
  }
9255
9178
  },
9256
9179
  [
9257
- location2,
9180
+ location,
9258
9181
  navigate,
9259
9182
  path,
9260
9183
  replaceProp,
@@ -9274,18 +9197,18 @@ function useSearchParams(defaultInit) {
9274
9197
  );
9275
9198
  let defaultSearchParamsRef = React10.useRef(createSearchParams(defaultInit));
9276
9199
  let hasSetSearchParamsRef = React10.useRef(false);
9277
- let location2 = useLocation();
9200
+ let location = useLocation();
9278
9201
  let searchParams = React10.useMemo(
9279
9202
  () => (
9280
9203
  // Only merge in the defaults if we haven't yet called setSearchParams.
9281
9204
  // Once we call that we want those to take precedence, otherwise you can't
9282
9205
  // remove a param with setSearchParams({}) if it has an initial value
9283
9206
  getSearchParamsForLocation(
9284
- location2.search,
9207
+ location.search,
9285
9208
  hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
9286
9209
  )
9287
9210
  ),
9288
- [location2.search]
9211
+ [location.search]
9289
9212
  );
9290
9213
  let navigate = useNavigate();
9291
9214
  let setSearchParams = React10.useCallback(
@@ -9346,9 +9269,9 @@ function useFormAction(action, { relative } = {}) {
9346
9269
  invariant(routeContext, "useFormAction must be used inside a RouteContext");
9347
9270
  let [match] = routeContext.matches.slice(-1);
9348
9271
  let path = { ...useResolvedPath(action ? action : ".", { relative }) };
9349
- let location2 = useLocation();
9272
+ let location = useLocation();
9350
9273
  if (action == null) {
9351
- path.search = location2.search;
9274
+ path.search = location.search;
9352
9275
  let params = new URLSearchParams(path.search);
9353
9276
  let indexValues = params.getAll("index");
9354
9277
  let hasNakedIndexParam = indexValues.some((v) => v === "");
@@ -9440,23 +9363,23 @@ function useFetchers() {
9440
9363
  }
9441
9364
  var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
9442
9365
  var savedScrollPositions = {};
9443
- function getScrollRestorationKey(location2, matches, basename, getKey) {
9366
+ function getScrollRestorationKey(location, matches, basename, getKey) {
9444
9367
  let key = null;
9445
9368
  if (getKey) {
9446
9369
  if (basename !== "/") {
9447
9370
  key = getKey(
9448
9371
  {
9449
- ...location2,
9450
- pathname: stripBasename(location2.pathname, basename) || location2.pathname
9372
+ ...location,
9373
+ pathname: stripBasename(location.pathname, basename) || location.pathname
9451
9374
  },
9452
9375
  matches
9453
9376
  );
9454
9377
  } else {
9455
- key = getKey(location2, matches);
9378
+ key = getKey(location, matches);
9456
9379
  }
9457
9380
  }
9458
9381
  if (key == null) {
9459
- key = location2.key;
9382
+ key = location.key;
9460
9383
  }
9461
9384
  return key;
9462
9385
  }
@@ -9469,7 +9392,7 @@ function useScrollRestoration({
9469
9392
  "useScrollRestoration" /* UseScrollRestoration */
9470
9393
  );
9471
9394
  let { basename } = React10.useContext(NavigationContext);
9472
- let location2 = useLocation();
9395
+ let location = useLocation();
9473
9396
  let matches = useMatches();
9474
9397
  let navigation = useNavigation();
9475
9398
  React10.useEffect(() => {
@@ -9481,7 +9404,7 @@ function useScrollRestoration({
9481
9404
  usePageHide(
9482
9405
  React10.useCallback(() => {
9483
9406
  if (navigation.state === "idle") {
9484
- let key = getScrollRestorationKey(location2, matches, basename, getKey);
9407
+ let key = getScrollRestorationKey(location, matches, basename, getKey);
9485
9408
  savedScrollPositions[key] = window.scrollY;
9486
9409
  }
9487
9410
  try {
@@ -9496,7 +9419,7 @@ function useScrollRestoration({
9496
9419
  );
9497
9420
  }
9498
9421
  window.history.scrollRestoration = "auto";
9499
- }, [navigation.state, getKey, basename, location2, matches, storageKey])
9422
+ }, [navigation.state, getKey, basename, location, matches, storageKey])
9500
9423
  );
9501
9424
  if (typeof document !== "undefined") {
9502
9425
  React10.useLayoutEffect(() => {
@@ -9514,7 +9437,7 @@ function useScrollRestoration({
9514
9437
  let disableScrollRestoration = router?.enableScrollRestoration(
9515
9438
  savedScrollPositions,
9516
9439
  () => window.scrollY,
9517
- getKey ? (location3, matches2) => getScrollRestorationKey(location3, matches2, basename, getKey) : void 0
9440
+ getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
9518
9441
  );
9519
9442
  return () => disableScrollRestoration && disableScrollRestoration();
9520
9443
  }, [router, basename, getKey]);
@@ -9526,9 +9449,9 @@ function useScrollRestoration({
9526
9449
  window.scrollTo(0, restoreScrollPosition);
9527
9450
  return;
9528
9451
  }
9529
- if (location2.hash) {
9452
+ if (location.hash) {
9530
9453
  let el = document.getElementById(
9531
- decodeURIComponent(location2.hash.slice(1))
9454
+ decodeURIComponent(location.hash.slice(1))
9532
9455
  );
9533
9456
  if (el) {
9534
9457
  el.scrollIntoView();
@@ -9539,7 +9462,7 @@ function useScrollRestoration({
9539
9462
  return;
9540
9463
  }
9541
9464
  window.scrollTo(0, 0);
9542
- }, [location2, restoreScrollPosition, preventScrollReset]);
9465
+ }, [location, restoreScrollPosition, preventScrollReset]);
9543
9466
  }
9544
9467
  }
9545
9468
  function useBeforeUnload(callback, options) {
@@ -9612,7 +9535,7 @@ function StaticRouter({
9612
9535
  locationProp = parsePath(locationProp);
9613
9536
  }
9614
9537
  let action = "POP" /* Pop */;
9615
- let location2 = {
9538
+ let location = {
9616
9539
  pathname: locationProp.pathname || "/",
9617
9540
  search: locationProp.search || "",
9618
9541
  hash: locationProp.hash || "",
@@ -9625,7 +9548,7 @@ function StaticRouter({
9625
9548
  {
9626
9549
  basename,
9627
9550
  children,
9628
- location: location2,
9551
+ location,
9629
9552
  navigationType: action,
9630
9553
  navigator: staticNavigator,
9631
9554
  static: true
@@ -9844,9 +9767,6 @@ function createStaticRouter(routes, context, opts = {}) {
9844
9767
  _internalFetchControllers: /* @__PURE__ */ new Map(),
9845
9768
  _internalSetRoutes() {
9846
9769
  throw msg("_internalSetRoutes");
9847
- },
9848
- _internalSetStateDoNotUseOrYouWillBreakYourApp() {
9849
- throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
9850
9770
  }
9851
9771
  };
9852
9772
  }
@@ -10508,7 +10428,7 @@ function createServerHandoffString(serverHandoff) {
10508
10428
 
10509
10429
  // lib/server-runtime/headers.ts
10510
10430
  import { splitCookiesString } from "set-cookie-parser";
10511
- function getDocumentHeaders(context, build) {
10431
+ function getDocumentHeaders(build, context) {
10512
10432
  return getDocumentHeadersImpl(context, (m) => {
10513
10433
  let route = build.routes[m.route.id];
10514
10434
  invariant3(route, `Route with id "${m.route.id}" not found in build`);
@@ -10585,7 +10505,7 @@ var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
10585
10505
  async function singleFetchAction(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
10586
10506
  try {
10587
10507
  let respond2 = function(context) {
10588
- let headers = getDocumentHeaders(context, build);
10508
+ let headers = getDocumentHeaders(build, context);
10589
10509
  if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
10590
10510
  return generateSingleFetchResponse(request, build, serverMode, {
10591
10511
  result: getSingleFetchRedirect(
@@ -10660,7 +10580,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
10660
10580
  async function singleFetchLoaders(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
10661
10581
  try {
10662
10582
  let respond2 = function(context) {
10663
- let headers = getDocumentHeaders(context, build);
10583
+ let headers = getDocumentHeaders(build, context);
10664
10584
  if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
10665
10585
  return generateSingleFetchResponse(request, build, serverMode, {
10666
10586
  result: {
@@ -11127,7 +11047,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
11127
11047
  if (isResponse(context)) {
11128
11048
  return context;
11129
11049
  }
11130
- let headers = getDocumentHeaders(context, build);
11050
+ let headers = getDocumentHeaders(build, context);
11131
11051
  if (SERVER_NO_BODY_STATUS_CODES.has(context.statusCode)) {
11132
11052
  return new Response(null, { status: context.statusCode, headers });
11133
11053
  }
@@ -11468,811 +11388,6 @@ function href(path, ...args) {
11468
11388
  }).filter((segment) => segment !== void 0).join("/");
11469
11389
  }
11470
11390
 
11471
- // lib/rsc/browser.tsx
11472
- import * as React14 from "react";
11473
-
11474
- // lib/dom/ssr/hydration.tsx
11475
- function getHydrationData(state, routes, getRouteInfo, location2, basename, isSpaMode) {
11476
- let hydrationData = {
11477
- ...state,
11478
- loaderData: { ...state.loaderData }
11479
- };
11480
- let initialMatches = matchRoutes(routes, location2, basename);
11481
- if (initialMatches) {
11482
- for (let match of initialMatches) {
11483
- let routeId = match.route.id;
11484
- let routeInfo = getRouteInfo(routeId);
11485
- if (shouldHydrateRouteLoader(
11486
- routeId,
11487
- routeInfo.clientLoader,
11488
- routeInfo.hasLoader,
11489
- isSpaMode
11490
- ) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
11491
- delete hydrationData.loaderData[routeId];
11492
- } else if (!routeInfo.hasLoader) {
11493
- hydrationData.loaderData[routeId] = null;
11494
- }
11495
- }
11496
- }
11497
- return hydrationData;
11498
- }
11499
-
11500
- // lib/rsc/browser.tsx
11501
- var neverResolvedPromise = new Promise(() => {
11502
- });
11503
- function createCallServer({
11504
- decode: decode2,
11505
- encodeAction
11506
- }) {
11507
- let landedActionId = 0;
11508
- return async (id, args) => {
11509
- let actionId = window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
11510
- const response = await fetch(location.href, {
11511
- body: await encodeAction(args),
11512
- method: "POST",
11513
- headers: {
11514
- Accept: "text/x-component",
11515
- "rsc-action-id": id
11516
- }
11517
- });
11518
- if (!response.body) {
11519
- throw new Error("No response body");
11520
- }
11521
- const payload = await decode2(response.body);
11522
- if (payload.type === "redirect") {
11523
- if (payload.reload) {
11524
- window.location.href = payload.location;
11525
- return;
11526
- }
11527
- window.__router.navigate(payload.location, {
11528
- replace: payload.replace
11529
- });
11530
- return neverResolvedPromise;
11531
- }
11532
- if (payload.type !== "action") {
11533
- throw new Error("Unexpected payload type");
11534
- }
11535
- if (payload.rerender) {
11536
- (async () => {
11537
- const rerender = await payload.rerender;
11538
- if (!rerender) return;
11539
- if (landedActionId < actionId && window.__routerActionID <= actionId) {
11540
- landedActionId = actionId;
11541
- if (rerender.type === "redirect") {
11542
- if (rerender.reload) {
11543
- window.location.href = rerender.location;
11544
- return;
11545
- }
11546
- window.__router.navigate(rerender.location, {
11547
- replace: rerender.replace
11548
- });
11549
- return;
11550
- }
11551
- let lastMatch;
11552
- for (const match of rerender.matches) {
11553
- window.__router.patchRoutes(
11554
- lastMatch?.id ?? null,
11555
- [createRouteFromServerManifest(match)],
11556
- true
11557
- );
11558
- lastMatch = match;
11559
- }
11560
- window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({});
11561
- React14.startTransition(() => {
11562
- window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({
11563
- loaderData: Object.assign(
11564
- {},
11565
- window.__router.state.loaderData,
11566
- rerender.loaderData
11567
- ),
11568
- errors: rerender.errors ? Object.assign(
11569
- {},
11570
- window.__router.state.errors,
11571
- rerender.errors
11572
- ) : null
11573
- });
11574
- });
11575
- }
11576
- })();
11577
- }
11578
- return payload.actionResult;
11579
- };
11580
- }
11581
- function createRouterFromPayload({
11582
- decode: decode2,
11583
- payload
11584
- }) {
11585
- if (window.__router) return window.__router;
11586
- if (payload.type !== "render") throw new Error("Invalid payload type");
11587
- let patches = /* @__PURE__ */ new Map();
11588
- payload.patches?.forEach((patch) => {
11589
- invariant(patch.parentId, "Invalid patch parentId");
11590
- if (!patches.has(patch.parentId)) {
11591
- patches.set(patch.parentId, []);
11592
- }
11593
- patches.get(patch.parentId)?.push(patch);
11594
- });
11595
- let routes = payload.matches.reduceRight((previous, match) => {
11596
- const route = createRouteFromServerManifest(
11597
- match,
11598
- payload
11599
- );
11600
- if (previous.length > 0) {
11601
- route.children = previous;
11602
- let childrenToPatch = patches.get(match.id);
11603
- if (childrenToPatch) {
11604
- route.children.push(
11605
- ...childrenToPatch.map((r) => createRouteFromServerManifest(r))
11606
- );
11607
- }
11608
- }
11609
- return [route];
11610
- }, []);
11611
- window.__router = createRouter({
11612
- routes,
11613
- basename: payload.basename,
11614
- history: createBrowserHistory(),
11615
- hydrationData: getHydrationData(
11616
- {
11617
- loaderData: payload.loaderData,
11618
- actionData: payload.actionData,
11619
- errors: payload.errors
11620
- },
11621
- routes,
11622
- (routeId) => {
11623
- let match = payload.matches.find((m) => m.id === routeId);
11624
- invariant(match, "Route not found in payload");
11625
- return {
11626
- clientLoader: match.clientLoader,
11627
- hasLoader: match.hasLoader,
11628
- hasHydrateFallback: match.hydrateFallbackElement != null
11629
- };
11630
- },
11631
- payload.location,
11632
- void 0,
11633
- false
11634
- ),
11635
- async patchRoutesOnNavigation({ path, signal }) {
11636
- if (discoveredPaths2.has(path)) {
11637
- return;
11638
- }
11639
- await fetchAndApplyManifestPatches2([path], decode2, signal);
11640
- },
11641
- // FIXME: Pass `build.ssr` and `build.basename` into this function
11642
- dataStrategy: getRSCSingleFetchDataStrategy(
11643
- () => window.__router,
11644
- true,
11645
- void 0,
11646
- decode2
11647
- )
11648
- });
11649
- if (window.__router.state.initialized) {
11650
- window.__routerInitialized = true;
11651
- window.__router.initialize();
11652
- } else {
11653
- window.__routerInitialized = false;
11654
- }
11655
- let lastLoaderData = void 0;
11656
- window.__router.subscribe(({ loaderData, actionData }) => {
11657
- if (lastLoaderData !== loaderData) {
11658
- window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
11659
- }
11660
- });
11661
- return window.__router;
11662
- }
11663
- var renderedRoutesContext = unstable_createContext();
11664
- function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, decode2) {
11665
- let dataStrategy = getSingleFetchDataStrategyImpl(
11666
- getRouter,
11667
- (match) => {
11668
- let M = match;
11669
- return {
11670
- hasLoader: M.route.hasLoader,
11671
- hasClientLoader: M.route.hasClientLoader,
11672
- hasAction: M.route.hasAction,
11673
- hasClientAction: M.route.hasClientAction,
11674
- hasShouldRevalidate: M.route.hasShouldRevalidate
11675
- };
11676
- },
11677
- // pass map into fetchAndDecode so it can add payloads
11678
- getFetchAndDecodeViaRSC(decode2),
11679
- ssr,
11680
- basename,
11681
- // If we don't have an element, we need to hit the server loader flow
11682
- // regardless of whether the client loader calls `serverLoader` or not,
11683
- // otherwise we'll have nothing to render.
11684
- // TODO: Do we need to account for API routes? Do we need a
11685
- // `match.hasComponent` flag?
11686
- (match) => match.route.element != null
11687
- );
11688
- return async (args) => args.unstable_runClientMiddleware(async () => {
11689
- let context = args.context;
11690
- context.set(renderedRoutesContext, []);
11691
- let results = await dataStrategy(args);
11692
- const renderedRoutesById = /* @__PURE__ */ new Map();
11693
- for (const route of context.get(renderedRoutesContext)) {
11694
- if (!renderedRoutesById.has(route.id)) {
11695
- renderedRoutesById.set(route.id, []);
11696
- }
11697
- renderedRoutesById.get(route.id).push(route);
11698
- }
11699
- for (const match of args.matches) {
11700
- const renderedRoutes = renderedRoutesById.get(match.route.id);
11701
- if (renderedRoutes) {
11702
- for (const rendered of renderedRoutes) {
11703
- window.__router.patchRoutes(
11704
- rendered.parentId ?? null,
11705
- [createRouteFromServerManifest(rendered)],
11706
- true
11707
- );
11708
- }
11709
- }
11710
- }
11711
- return results;
11712
- });
11713
- }
11714
- function getFetchAndDecodeViaRSC(decode2) {
11715
- return async (args, basename, targetRoutes) => {
11716
- let { request, context } = args;
11717
- let url = singleFetchUrl(request.url, basename, "rsc");
11718
- if (request.method === "GET") {
11719
- url = stripIndexParam(url);
11720
- if (targetRoutes) {
11721
- url.searchParams.set("_routes", targetRoutes.join(","));
11722
- }
11723
- }
11724
- let res = await fetch(url, await createRequestInit(request));
11725
- if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
11726
- throw new ErrorResponseImpl(404, "Not Found", true);
11727
- }
11728
- invariant(res.body, "No response body to decode");
11729
- try {
11730
- const payload = await decode2(res.body);
11731
- if (payload.type === "redirect") {
11732
- return {
11733
- status: res.status,
11734
- data: {
11735
- redirect: {
11736
- redirect: payload.location,
11737
- reload: false,
11738
- replace: payload.replace,
11739
- revalidate: false,
11740
- status: payload.status
11741
- }
11742
- }
11743
- };
11744
- }
11745
- if (payload.type !== "render") {
11746
- throw new Error("Unexpected payload type");
11747
- }
11748
- context.get(renderedRoutesContext).push(...payload.matches);
11749
- let results = { routes: {} };
11750
- const dataKey = isMutationMethod(request.method) ? "actionData" : "loaderData";
11751
- for (let [routeId, data2] of Object.entries(payload[dataKey] || {})) {
11752
- results.routes[routeId] = { data: data2 };
11753
- }
11754
- if (payload.errors) {
11755
- for (let [routeId, error] of Object.entries(payload.errors)) {
11756
- results.routes[routeId] = { error };
11757
- }
11758
- }
11759
- return { status: res.status, data: results };
11760
- } catch (e) {
11761
- throw new Error("Unable to decode RSC response");
11762
- }
11763
- };
11764
- }
11765
- function RSCHydratedRouter({
11766
- decode: decode2,
11767
- payload,
11768
- routeDiscovery = "eager"
11769
- }) {
11770
- if (payload.type !== "render") throw new Error("Invalid payload type");
11771
- let router = React14.useMemo(
11772
- () => createRouterFromPayload({ decode: decode2, payload }),
11773
- // eslint-disable-next-line react-hooks/exhaustive-deps
11774
- []
11775
- );
11776
- React14.useLayoutEffect(() => {
11777
- if (!window.__routerInitialized) {
11778
- window.__routerInitialized = true;
11779
- window.__router.initialize();
11780
- }
11781
- }, []);
11782
- React14.useEffect(() => {
11783
- if (routeDiscovery === "lazy" || // @ts-expect-error - TS doesn't know about this yet
11784
- window.navigator?.connection?.saveData === true) {
11785
- return;
11786
- }
11787
- function registerElement(el) {
11788
- let path = el.tagName === "FORM" ? el.getAttribute("action") : el.getAttribute("href");
11789
- if (!path) {
11790
- return;
11791
- }
11792
- let pathname = el.tagName === "A" ? el.pathname : new URL(path, window.location.origin).pathname;
11793
- if (!discoveredPaths2.has(pathname)) {
11794
- nextPaths2.add(pathname);
11795
- }
11796
- }
11797
- async function fetchPatches() {
11798
- document.querySelectorAll("a[data-discover], form[data-discover]").forEach(registerElement);
11799
- let paths = Array.from(nextPaths2.keys()).filter((path) => {
11800
- if (discoveredPaths2.has(path)) {
11801
- nextPaths2.delete(path);
11802
- return false;
11803
- }
11804
- return true;
11805
- });
11806
- if (paths.length === 0) {
11807
- return;
11808
- }
11809
- try {
11810
- await fetchAndApplyManifestPatches2(paths, decode2);
11811
- } catch (e) {
11812
- console.error("Failed to fetch manifest patches", e);
11813
- }
11814
- }
11815
- let debouncedFetchPatches = debounce2(fetchPatches, 100);
11816
- fetchPatches();
11817
- let observer = new MutationObserver(() => debouncedFetchPatches());
11818
- observer.observe(document.documentElement, {
11819
- subtree: true,
11820
- childList: true,
11821
- attributes: true,
11822
- attributeFilter: ["data-discover", "href", "action"]
11823
- });
11824
- }, [routeDiscovery, decode2]);
11825
- const frameworkContext = {
11826
- future: {
11827
- // These flags have no runtime impact so can always be false. If we add
11828
- // flags that drive runtime behavior they'll need to be proxied through.
11829
- unstable_middleware: false,
11830
- unstable_subResourceIntegrity: false
11831
- },
11832
- isSpaMode: true,
11833
- ssr: true,
11834
- criticalCss: "",
11835
- manifest: {
11836
- routes: {},
11837
- version: "1",
11838
- url: "",
11839
- entry: {
11840
- module: "",
11841
- imports: []
11842
- }
11843
- },
11844
- routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
11845
- routeModules: {}
11846
- };
11847
- return /* @__PURE__ */ React14.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React14.createElement(RouterProvider, { router }));
11848
- }
11849
- function createRouteFromServerManifest(match, payload) {
11850
- let hasInitialData = payload && match.id in payload.loaderData;
11851
- let initialData = payload?.loaderData[match.id];
11852
- let hasInitialError = payload?.errors && match.id in payload.errors;
11853
- let initialError = payload?.errors?.[match.id];
11854
- let isHydrationRequest = match.clientLoader?.hydrate === true || !match.hasLoader || // If we don't have an element, we need to hit the server loader flow
11855
- // regardless of whether the client loader calls `serverLoader` or not,
11856
- // otherwise we'll have nothing to render.
11857
- // TODO: Do we need to account for API routes? Do we need a
11858
- // `match.hasComponent` flag?
11859
- !match.element;
11860
- let dataRoute = {
11861
- id: match.id,
11862
- element: match.element,
11863
- errorElement: match.errorElement,
11864
- handle: match.handle,
11865
- hasErrorBoundary: match.hasErrorBoundary,
11866
- hydrateFallbackElement: match.hydrateFallbackElement,
11867
- index: match.index,
11868
- loader: match.clientLoader ? async (args, singleFetch) => {
11869
- try {
11870
- let result = await match.clientLoader({
11871
- ...args,
11872
- serverLoader: () => {
11873
- preventInvalidServerHandlerCall2(
11874
- "loader",
11875
- match.id,
11876
- match.hasLoader
11877
- );
11878
- if (isHydrationRequest) {
11879
- if (hasInitialData) {
11880
- return initialData;
11881
- }
11882
- if (hasInitialError) {
11883
- throw initialError;
11884
- }
11885
- }
11886
- return callSingleFetch(singleFetch);
11887
- }
11888
- });
11889
- return result;
11890
- } finally {
11891
- isHydrationRequest = false;
11892
- }
11893
- } : (
11894
- // We always make the call in this RSC world since even if we don't
11895
- // have a `loader` we may need to get the `element` implementation
11896
- (_, singleFetch) => callSingleFetch(singleFetch)
11897
- ),
11898
- action: match.clientAction ? (args, singleFetch) => match.clientAction({
11899
- ...args,
11900
- serverAction: async () => {
11901
- preventInvalidServerHandlerCall2(
11902
- "loader",
11903
- match.id,
11904
- match.hasLoader
11905
- );
11906
- return await callSingleFetch(singleFetch);
11907
- }
11908
- }) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : void 0,
11909
- path: match.path,
11910
- shouldRevalidate: match.shouldRevalidate,
11911
- // We always have a "loader" in this RSC world since even if we don't
11912
- // have a `loader` we may need to get the `element` implementation
11913
- hasLoader: true,
11914
- hasClientLoader: match.clientLoader != null,
11915
- hasAction: match.hasAction,
11916
- hasClientAction: match.clientAction != null,
11917
- hasShouldRevalidate: match.shouldRevalidate != null
11918
- };
11919
- if (typeof dataRoute.loader === "function") {
11920
- dataRoute.loader.hydrate = shouldHydrateRouteLoader(
11921
- match.id,
11922
- match.clientLoader,
11923
- match.hasLoader,
11924
- false
11925
- );
11926
- }
11927
- return dataRoute;
11928
- }
11929
- function callSingleFetch(singleFetch) {
11930
- invariant(typeof singleFetch === "function", "Invalid singleFetch parameter");
11931
- return singleFetch();
11932
- }
11933
- function preventInvalidServerHandlerCall2(type, routeId, hasHandler) {
11934
- if (!hasHandler) {
11935
- let fn = type === "action" ? "serverAction()" : "serverLoader()";
11936
- let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${routeId}")`;
11937
- console.error(msg);
11938
- throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
11939
- }
11940
- }
11941
- var nextPaths2 = /* @__PURE__ */ new Set();
11942
- var discoveredPathsMaxSize2 = 1e3;
11943
- var discoveredPaths2 = /* @__PURE__ */ new Set();
11944
- var URL_LIMIT2 = 7680;
11945
- async function fetchAndApplyManifestPatches2(paths, decode2, signal) {
11946
- let basename = (window.__router.basename ?? "").replace(/^\/|\/$/g, "");
11947
- let url = new URL(`${basename}/.manifest`, window.location.origin);
11948
- paths.sort().forEach((path) => url.searchParams.append("p", path));
11949
- if (url.toString().length > URL_LIMIT2) {
11950
- nextPaths2.clear();
11951
- return;
11952
- }
11953
- let response = await fetch(url, { signal });
11954
- if (!response.body || response.status < 200 || response.status >= 300) {
11955
- throw new Error("Unable to fetch new route matches from the server");
11956
- }
11957
- let payload = await decode2(response.body);
11958
- if (payload.type !== "manifest") {
11959
- throw new Error("Failed to patch routes");
11960
- }
11961
- paths.forEach((p) => addToFifoQueue2(p, discoveredPaths2));
11962
- payload.patches.forEach((p) => {
11963
- window.__router.patchRoutes(p.parentId ?? null, [
11964
- createRouteFromServerManifest(p)
11965
- ]);
11966
- });
11967
- }
11968
- function addToFifoQueue2(path, queue) {
11969
- if (queue.size >= discoveredPathsMaxSize2) {
11970
- let first = queue.values().next().value;
11971
- queue.delete(first);
11972
- }
11973
- queue.add(path);
11974
- }
11975
- function debounce2(callback, wait) {
11976
- let timeoutId;
11977
- return (...args) => {
11978
- window.clearTimeout(timeoutId);
11979
- timeoutId = window.setTimeout(() => callback(...args), wait);
11980
- };
11981
- }
11982
-
11983
- // lib/rsc/server.ssr.tsx
11984
- import * as React15 from "react";
11985
-
11986
- // lib/rsc/html-stream/server.ts
11987
- var encoder2 = new TextEncoder();
11988
- var trailer = "</body></html>";
11989
- function injectRSCPayload(rscStream) {
11990
- let decoder = new TextDecoder();
11991
- let resolveFlightDataPromise;
11992
- let flightDataPromise = new Promise(
11993
- (resolve) => resolveFlightDataPromise = resolve
11994
- );
11995
- let startedRSC = false;
11996
- let buffered = [];
11997
- let timeout = null;
11998
- function flushBufferedChunks(controller) {
11999
- for (let chunk of buffered) {
12000
- let buf = decoder.decode(chunk, { stream: true });
12001
- if (buf.endsWith(trailer)) {
12002
- buf = buf.slice(0, -trailer.length);
12003
- }
12004
- controller.enqueue(encoder2.encode(buf));
12005
- }
12006
- buffered.length = 0;
12007
- timeout = null;
12008
- }
12009
- return new TransformStream({
12010
- transform(chunk, controller) {
12011
- buffered.push(chunk);
12012
- if (timeout) {
12013
- return;
12014
- }
12015
- timeout = setTimeout(async () => {
12016
- flushBufferedChunks(controller);
12017
- if (!startedRSC) {
12018
- startedRSC = true;
12019
- writeRSCStream(rscStream, controller).catch((err) => controller.error(err)).then(resolveFlightDataPromise);
12020
- }
12021
- }, 0);
12022
- },
12023
- async flush(controller) {
12024
- await flightDataPromise;
12025
- if (timeout) {
12026
- clearTimeout(timeout);
12027
- flushBufferedChunks(controller);
12028
- }
12029
- controller.enqueue(encoder2.encode("</body></html>"));
12030
- }
12031
- });
12032
- }
12033
- async function writeRSCStream(rscStream, controller) {
12034
- let decoder = new TextDecoder("utf-8", { fatal: true });
12035
- const reader = rscStream.getReader();
12036
- try {
12037
- let read;
12038
- while ((read = await reader.read()) && !read.done) {
12039
- const chunk = read.value;
12040
- try {
12041
- writeChunk(
12042
- JSON.stringify(decoder.decode(chunk, { stream: true })),
12043
- controller
12044
- );
12045
- } catch (err) {
12046
- let base64 = JSON.stringify(btoa(String.fromCodePoint(...chunk)));
12047
- writeChunk(
12048
- `Uint8Array.from(atob(${base64}), m => m.codePointAt(0))`,
12049
- controller
12050
- );
12051
- }
12052
- }
12053
- } finally {
12054
- reader.releaseLock();
12055
- }
12056
- let remaining = decoder.decode();
12057
- if (remaining.length) {
12058
- writeChunk(JSON.stringify(remaining), controller);
12059
- }
12060
- }
12061
- function writeChunk(chunk, controller) {
12062
- controller.enqueue(
12063
- encoder2.encode(
12064
- `<script>${escapeScript(
12065
- `(self.__FLIGHT_DATA||=[]).push(${chunk})`
12066
- )}</script>`
12067
- )
12068
- );
12069
- }
12070
- function escapeScript(script) {
12071
- return script.replace(/<!--/g, "<\\!--").replace(/<\/(script)/gi, "</\\$1");
12072
- }
12073
-
12074
- // lib/rsc/server.ssr.tsx
12075
- async function routeRSCServerRequest({
12076
- request,
12077
- callServer,
12078
- decode: decode2,
12079
- renderHTML,
12080
- hydrate: hydrate2 = true
12081
- }) {
12082
- const url = new URL(request.url);
12083
- let serverRequest = request;
12084
- const isDataRequest = isReactServerRequest(url);
12085
- const respondWithRSCPayload = isDataRequest || isManifestRequest(url) || request.headers.has("rsc-action-id");
12086
- if (isDataRequest) {
12087
- const serverURL = new URL(request.url);
12088
- serverURL.pathname = serverURL.pathname.replace(/(_root)?\.rsc$/, "");
12089
- let headers = new Headers(request.headers);
12090
- headers.set("X-React-Router-Data-Request", "true");
12091
- serverRequest = new Request(serverURL, {
12092
- body: request.body,
12093
- duplex: request.body ? "half" : void 0,
12094
- headers,
12095
- method: request.method,
12096
- signal: request.signal
12097
- });
12098
- }
12099
- const serverResponse = await callServer(serverRequest);
12100
- if (respondWithRSCPayload) {
12101
- return serverResponse;
12102
- }
12103
- if (!serverResponse.body) {
12104
- throw new Error("Missing body in server response");
12105
- }
12106
- let serverResponseB = null;
12107
- if (hydrate2) {
12108
- serverResponseB = serverResponse.clone();
12109
- }
12110
- const body = serverResponse.body;
12111
- let payloadPromise;
12112
- const getPayload = async () => {
12113
- if (payloadPromise) return payloadPromise;
12114
- payloadPromise = decode2(body);
12115
- return payloadPromise;
12116
- };
12117
- try {
12118
- const html = await renderHTML(getPayload);
12119
- const headers = new Headers(serverResponse.headers);
12120
- headers.set("Content-Type", "text/html");
12121
- if (!hydrate2) {
12122
- return new Response(html, {
12123
- status: serverResponse.status,
12124
- headers
12125
- });
12126
- }
12127
- if (!serverResponseB?.body) {
12128
- throw new Error("Failed to clone server response");
12129
- }
12130
- const body2 = html.pipeThrough(injectRSCPayload(serverResponseB.body));
12131
- return new Response(body2, {
12132
- status: serverResponse.status,
12133
- headers
12134
- });
12135
- } catch (reason) {
12136
- if (reason instanceof Response) {
12137
- return reason;
12138
- }
12139
- throw reason;
12140
- }
12141
- }
12142
- function RSCStaticRouter({
12143
- getPayload
12144
- }) {
12145
- const payload = React15.use(getPayload());
12146
- if (payload.type === "redirect") {
12147
- throw new Response(null, {
12148
- status: payload.status,
12149
- headers: {
12150
- Location: payload.location
12151
- }
12152
- });
12153
- }
12154
- if (payload.type !== "render") return null;
12155
- const context = {
12156
- actionData: payload.actionData,
12157
- actionHeaders: {},
12158
- basename: payload.basename,
12159
- errors: payload.errors,
12160
- loaderData: payload.loaderData,
12161
- loaderHeaders: {},
12162
- location: payload.location,
12163
- statusCode: 200,
12164
- matches: payload.matches.map((match) => ({
12165
- params: match.params,
12166
- pathname: match.pathname,
12167
- pathnameBase: match.pathnameBase,
12168
- route: {
12169
- id: match.id,
12170
- action: match.hasAction || !!match.clientAction,
12171
- handle: match.handle,
12172
- hasErrorBoundary: match.hasErrorBoundary,
12173
- loader: match.hasLoader || !!match.clientLoader,
12174
- index: match.index,
12175
- path: match.path,
12176
- shouldRevalidate: match.shouldRevalidate
12177
- }
12178
- }))
12179
- };
12180
- const router = createStaticRouter(
12181
- payload.matches.reduceRight((previous, match) => {
12182
- const route = {
12183
- id: match.id,
12184
- action: match.hasAction || !!match.clientAction,
12185
- element: match.element,
12186
- errorElement: match.errorElement,
12187
- handle: match.handle,
12188
- hasErrorBoundary: !!match.errorElement,
12189
- hydrateFallbackElement: match.hydrateFallbackElement,
12190
- index: match.index,
12191
- loader: match.hasLoader || !!match.clientLoader,
12192
- path: match.path,
12193
- shouldRevalidate: match.shouldRevalidate
12194
- };
12195
- if (previous.length > 0) {
12196
- route.children = previous;
12197
- }
12198
- return [route];
12199
- }, []),
12200
- context
12201
- );
12202
- const frameworkContext = {
12203
- future: {
12204
- // These flags have no runtime impact so can always be false. If we add
12205
- // flags that drive runtime behavior they'll need to be proxied through.
12206
- unstable_middleware: false,
12207
- unstable_subResourceIntegrity: false
12208
- },
12209
- isSpaMode: false,
12210
- ssr: true,
12211
- criticalCss: "",
12212
- manifest: {
12213
- routes: {},
12214
- version: "1",
12215
- url: "",
12216
- entry: {
12217
- module: "",
12218
- imports: []
12219
- }
12220
- },
12221
- routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
12222
- routeModules: {}
12223
- };
12224
- return /* @__PURE__ */ React15.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React15.createElement(
12225
- StaticRouterProvider,
12226
- {
12227
- context,
12228
- router,
12229
- hydrate: false,
12230
- nonce: payload.nonce
12231
- }
12232
- ));
12233
- }
12234
- function isReactServerRequest(url) {
12235
- return url.pathname.endsWith(".rsc");
12236
- }
12237
- function isManifestRequest(url) {
12238
- return url.pathname.endsWith(".manifest");
12239
- }
12240
-
12241
- // lib/rsc/html-stream/browser.ts
12242
- function getServerStream() {
12243
- let encoder3 = new TextEncoder();
12244
- let streamController = null;
12245
- let rscStream = new ReadableStream({
12246
- start(controller) {
12247
- if (typeof window === "undefined") {
12248
- return;
12249
- }
12250
- let handleChunk = (chunk) => {
12251
- if (typeof chunk === "string") {
12252
- controller.enqueue(encoder3.encode(chunk));
12253
- } else {
12254
- controller.enqueue(chunk);
12255
- }
12256
- };
12257
- window.__FLIGHT_DATA || (window.__FLIGHT_DATA = []);
12258
- window.__FLIGHT_DATA.forEach(handleChunk);
12259
- window.__FLIGHT_DATA.push = (chunk) => {
12260
- handleChunk(chunk);
12261
- return 0;
12262
- };
12263
- streamController = controller;
12264
- }
12265
- });
12266
- if (typeof document !== "undefined" && document.readyState === "loading") {
12267
- document.addEventListener("DOMContentLoaded", () => {
12268
- streamController?.close();
12269
- });
12270
- } else {
12271
- streamController?.close();
12272
- }
12273
- return rscStream;
12274
- }
12275
-
12276
11391
  // lib/dom/ssr/errors.ts
12277
11392
  function deserializeErrors2(errors) {
12278
11393
  if (!errors) return null;
@@ -12310,6 +11425,32 @@ function deserializeErrors2(errors) {
12310
11425
  return serialized;
12311
11426
  }
12312
11427
 
11428
+ // lib/dom/ssr/hydration.tsx
11429
+ function getHydrationData(state, routes, getRouteInfo, location, basename, isSpaMode) {
11430
+ let hydrationData = {
11431
+ ...state,
11432
+ loaderData: { ...state.loaderData }
11433
+ };
11434
+ let initialMatches = matchRoutes(routes, location, basename);
11435
+ if (initialMatches) {
11436
+ for (let match of initialMatches) {
11437
+ let routeId = match.route.id;
11438
+ let routeInfo = getRouteInfo(routeId);
11439
+ if (shouldHydrateRouteLoader(
11440
+ routeId,
11441
+ routeInfo.clientLoader,
11442
+ routeInfo.hasLoader,
11443
+ isSpaMode
11444
+ ) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
11445
+ delete hydrationData.loaderData[routeId];
11446
+ } else if (!routeInfo.hasLoader) {
11447
+ hydrationData.loaderData[routeId] = null;
11448
+ }
11449
+ }
11450
+ }
11451
+ return hydrationData;
11452
+ }
11453
+
12313
11454
  export {
12314
11455
  Action,
12315
11456
  createBrowserHistory,
@@ -12428,11 +11569,6 @@ export {
12428
11569
  createCookieSessionStorage,
12429
11570
  createMemorySessionStorage,
12430
11571
  href,
12431
- getHydrationData,
12432
- createCallServer,
12433
- RSCHydratedRouter,
12434
- routeRSCServerRequest,
12435
- RSCStaticRouter,
12436
- getServerStream,
12437
- deserializeErrors2 as deserializeErrors
11572
+ deserializeErrors2 as deserializeErrors,
11573
+ getHydrationData
12438
11574
  };