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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/development/{chunk-OEAMHMGQ.mjs → chunk-QBMD7MNB.mjs} +293 -1025
  3. package/dist/development/dom-export.d.mts +2 -2
  4. package/dist/development/dom-export.d.ts +2 -2
  5. package/dist/development/dom-export.js +69 -103
  6. package/dist/development/dom-export.mjs +2 -2
  7. package/dist/development/{fog-of-war-DrUCUQQ-.d.ts → fog-of-war-BLArG-qZ.d.ts} +81 -168
  8. package/dist/{production/fog-of-war-C5L_Yd5M.d.mts → development/fog-of-war-D2zsXvum.d.mts} +81 -168
  9. package/dist/development/index.d.mts +8 -15
  10. package/dist/development/index.d.ts +8 -15
  11. package/dist/development/index.js +291 -1032
  12. package/dist/development/index.mjs +2 -19
  13. package/dist/development/lib/types/route-module.d.mts +1 -1
  14. package/dist/development/lib/types/route-module.d.ts +1 -1
  15. package/dist/development/lib/types/route-module.js +1 -1
  16. package/dist/development/lib/types/route-module.mjs +1 -1
  17. package/dist/development/{route-data-BIYebJr3.d.ts → route-data-C12CLHiN.d.mts} +1 -11
  18. package/dist/{production/route-data-BIYebJr3.d.mts → development/route-data-C12CLHiN.d.ts} +1 -11
  19. package/dist/production/{chunk-I2N4LFMP.mjs → chunk-DSJGM2GU.mjs} +293 -1025
  20. package/dist/production/dom-export.d.mts +2 -2
  21. package/dist/production/dom-export.d.ts +2 -2
  22. package/dist/production/dom-export.js +69 -103
  23. package/dist/production/dom-export.mjs +2 -2
  24. package/dist/production/{fog-of-war-DrUCUQQ-.d.ts → fog-of-war-BLArG-qZ.d.ts} +81 -168
  25. package/dist/{development/fog-of-war-C5L_Yd5M.d.mts → production/fog-of-war-D2zsXvum.d.mts} +81 -168
  26. package/dist/production/index.d.mts +8 -15
  27. package/dist/production/index.d.ts +8 -15
  28. package/dist/production/index.js +291 -1032
  29. package/dist/production/index.mjs +2 -19
  30. package/dist/production/lib/types/route-module.d.mts +1 -1
  31. package/dist/production/lib/types/route-module.d.ts +1 -1
  32. package/dist/production/lib/types/route-module.js +1 -1
  33. package/dist/production/lib/types/route-module.mjs +1 -1
  34. package/dist/production/{route-data-BIYebJr3.d.ts → route-data-C12CLHiN.d.mts} +1 -11
  35. package/dist/{development/route-data-BIYebJr3.d.mts → production/route-data-C12CLHiN.d.ts} +1 -11
  36. package/package.json +2 -33
  37. package/dist/development/rsc-export.d.mts +0 -1553
  38. package/dist/development/rsc-export.d.ts +0 -1553
  39. package/dist/development/rsc-export.js +0 -2413
  40. package/dist/development/rsc-export.mjs +0 -2385
  41. package/dist/production/rsc-export.d.mts +0 -1553
  42. package/dist/production/rsc-export.d.ts +0 -1553
  43. package/dist/production/rsc-export.js +0 -2413
  44. package/dist/production/rsc-export.mjs +0 -2385
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-a6d1d1d4e
2
+ * react-router v0.0.0-experimental-1d760f6a6
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -9,7 +9,6 @@
9
9
  * @license MIT
10
10
  */
11
11
  "use strict";
12
- "use client";
13
12
  var __create = Object.create;
14
13
  var __defProp = Object.defineProperty;
15
14
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -63,8 +62,6 @@ __export(react_router_exports, {
63
62
  NavigationType: () => Action,
64
63
  Outlet: () => Outlet,
65
64
  PrefetchPageLinks: () => PrefetchPageLinks,
66
- RSCHydratedRouter: () => RSCHydratedRouter,
67
- RSCStaticRouter: () => RSCStaticRouter,
68
65
  Route: () => Route,
69
66
  Router: () => Router,
70
67
  RouterProvider: () => RouterProvider,
@@ -86,9 +83,6 @@ __export(react_router_exports, {
86
83
  UNSAFE_ServerMode: () => ServerMode,
87
84
  UNSAFE_SingleFetchRedirectSymbol: () => SingleFetchRedirectSymbol,
88
85
  UNSAFE_ViewTransitionContext: () => ViewTransitionContext,
89
- UNSAFE_WithErrorBoundaryProps: () => WithErrorBoundaryProps,
90
- UNSAFE_WithHydrateFallbackProps: () => WithHydrateFallbackProps,
91
- UNSAFE_WithRouteComponentProps: () => WithRouteComponentProps,
92
86
  UNSAFE_createBrowserHistory: () => createBrowserHistory,
93
87
  UNSAFE_createClientRoutes: () => createClientRoutes,
94
88
  UNSAFE_createClientRoutesWithHMRRevalidationOptOut: () => createClientRoutesWithHMRRevalidationOptOut,
@@ -105,7 +99,6 @@ __export(react_router_exports, {
105
99
  UNSAFE_useFogOFWarDiscovery: () => useFogOFWarDiscovery,
106
100
  UNSAFE_useScrollRestoration: () => useScrollRestoration,
107
101
  createBrowserRouter: () => createBrowserRouter,
108
- createCallServer: () => createCallServer,
109
102
  createCookie: () => createCookie,
110
103
  createCookieSessionStorage: () => createCookieSessionStorage,
111
104
  createHashRouter: () => createHashRouter,
@@ -123,7 +116,6 @@ __export(react_router_exports, {
123
116
  createStaticRouter: () => createStaticRouter,
124
117
  data: () => data,
125
118
  generatePath: () => generatePath,
126
- getServerStream: () => getServerStream,
127
119
  href: () => href,
128
120
  isCookie: () => isCookie,
129
121
  isRouteErrorResponse: () => isRouteErrorResponse,
@@ -136,7 +128,6 @@ __export(react_router_exports, {
136
128
  renderMatches: () => renderMatches,
137
129
  replace: () => replace,
138
130
  resolvePath: () => resolvePath,
139
- routeRSCServerRequest: () => routeRSCServerRequest,
140
131
  unstable_HistoryRouter: () => HistoryRouter,
141
132
  unstable_RouterContextProvider: () => unstable_RouterContextProvider,
142
133
  unstable_createContext: () => unstable_createContext,
@@ -204,19 +195,19 @@ function createMemoryHistory(options = {}) {
204
195
  return entries[index];
205
196
  }
206
197
  function createMemoryLocation(to, state = null, key) {
207
- let location2 = createLocation(
198
+ let location = createLocation(
208
199
  entries ? getCurrentLocation().pathname : "/",
209
200
  to,
210
201
  state,
211
202
  key
212
203
  );
213
204
  warning(
214
- location2.pathname.charAt(0) === "/",
205
+ location.pathname.charAt(0) === "/",
215
206
  `relative pathnames are not supported in memory history: ${JSON.stringify(
216
207
  to
217
208
  )}`
218
209
  );
219
- return location2;
210
+ return location;
220
211
  }
221
212
  function createHref2(to) {
222
213
  return typeof to === "string" ? to : createPath(to);
@@ -327,9 +318,9 @@ function createHashHistory(options = {}) {
327
318
  }
328
319
  return href2 + "#" + (typeof to === "string" ? to : createPath(to));
329
320
  }
330
- function validateHashLocation(location2, to) {
321
+ function validateHashLocation(location, to) {
331
322
  warning(
332
- location2.pathname.charAt(0) === "/",
323
+ location.pathname.charAt(0) === "/",
333
324
  `relative pathnames are not supported in hash history.push(${JSON.stringify(
334
325
  to
335
326
  )})`
@@ -359,15 +350,15 @@ function warning(cond, message) {
359
350
  function createKey() {
360
351
  return Math.random().toString(36).substring(2, 10);
361
352
  }
362
- function getHistoryState(location2, index) {
353
+ function getHistoryState(location, index) {
363
354
  return {
364
- usr: location2.state,
365
- key: location2.key,
355
+ usr: location.state,
356
+ key: location.key,
366
357
  idx: index
367
358
  };
368
359
  }
369
360
  function createLocation(current, to, state = null, key) {
370
- let location2 = {
361
+ let location = {
371
362
  pathname: typeof current === "string" ? current : current.pathname,
372
363
  search: "",
373
364
  hash: "",
@@ -379,7 +370,7 @@ function createLocation(current, to, state = null, key) {
379
370
  // keep as is for the time being and just let any incoming keys take precedence
380
371
  key: to && to.key || key || createKey()
381
372
  };
382
- return location2;
373
+ return location;
383
374
  }
384
375
  function createPath({
385
376
  pathname = "/",
@@ -436,11 +427,11 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
436
427
  }
437
428
  function push(to, state) {
438
429
  action = "PUSH" /* Push */;
439
- let location2 = createLocation(history.location, to, state);
440
- if (validateLocation) validateLocation(location2, to);
430
+ let location = createLocation(history.location, to, state);
431
+ if (validateLocation) validateLocation(location, to);
441
432
  index = getIndex() + 1;
442
- let historyState = getHistoryState(location2, index);
443
- let url = history.createHref(location2);
433
+ let historyState = getHistoryState(location, index);
434
+ let url = history.createHref(location);
444
435
  try {
445
436
  globalHistory.pushState(historyState, "", url);
446
437
  } catch (error) {
@@ -455,11 +446,11 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
455
446
  }
456
447
  function replace2(to, state) {
457
448
  action = "REPLACE" /* Replace */;
458
- let location2 = createLocation(history.location, to, state);
459
- if (validateLocation) validateLocation(location2, to);
449
+ let location = createLocation(history.location, to, state);
450
+ if (validateLocation) validateLocation(location, to);
460
451
  index = getIndex();
461
- let historyState = getHistoryState(location2, index);
462
- let url = history.createHref(location2);
452
+ let historyState = getHistoryState(location, index);
453
+ let url = history.createHref(location);
463
454
  globalHistory.replaceState(historyState, "", url);
464
455
  if (v5Compat && listener) {
465
456
  listener({ action, location: history.location, delta: 0 });
@@ -572,7 +563,7 @@ function isUnsupportedLazyRouteFunctionKey(key) {
572
563
  function isIndexRoute(route) {
573
564
  return route.index === true;
574
565
  }
575
- function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}, allowInPlaceMutations = false) {
566
+ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}) {
576
567
  return routes.map((route, index) => {
577
568
  let treePath = [...parentPath, String(index)];
578
569
  let id = typeof route.id === "string" ? route.id : treePath.join("-");
@@ -581,7 +572,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
581
572
  `Cannot specify children on an index route`
582
573
  );
583
574
  invariant(
584
- allowInPlaceMutations || !manifest[id],
575
+ !manifest[id],
585
576
  `Found a route id collision on id "${id}". Route id's must be globally unique within Data Router usages`
586
577
  );
587
578
  if (isIndexRoute(route)) {
@@ -605,8 +596,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
605
596
  route.children,
606
597
  mapRouteProperties2,
607
598
  treePath,
608
- manifest,
609
- allowInPlaceMutations
599
+ manifest
610
600
  );
611
601
  }
612
602
  return pathOrLayoutRoute;
@@ -617,8 +607,8 @@ function matchRoutes(routes, locationArg, basename = "/") {
617
607
  return matchRoutesImpl(routes, locationArg, basename, false);
618
608
  }
619
609
  function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
620
- let location2 = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
621
- let pathname = stripBasename(location2.pathname || "/", basename);
610
+ let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
611
+ let pathname = stripBasename(location.pathname || "/", basename);
622
612
  if (pathname == null) {
623
613
  return null;
624
614
  }
@@ -1222,7 +1212,7 @@ function createRouter(init) {
1222
1212
  let pendingRevalidationDfd = null;
1223
1213
  function initialize() {
1224
1214
  unlistenHistory = init.history.listen(
1225
- ({ action: historyAction, location: location2, delta }) => {
1215
+ ({ action: historyAction, location, delta }) => {
1226
1216
  if (unblockBlockerHistoryUpdate) {
1227
1217
  unblockBlockerHistoryUpdate();
1228
1218
  unblockBlockerHistoryUpdate = void 0;
@@ -1234,7 +1224,7 @@ function createRouter(init) {
1234
1224
  );
1235
1225
  let blockerKey = shouldBlockNavigation({
1236
1226
  currentLocation: state.location,
1237
- nextLocation: location2,
1227
+ nextLocation: location,
1238
1228
  historyAction
1239
1229
  });
1240
1230
  if (blockerKey && delta != null) {
@@ -1244,13 +1234,13 @@ function createRouter(init) {
1244
1234
  init.history.go(delta * -1);
1245
1235
  updateBlocker(blockerKey, {
1246
1236
  state: "blocked",
1247
- location: location2,
1237
+ location,
1248
1238
  proceed() {
1249
1239
  updateBlocker(blockerKey, {
1250
1240
  state: "proceeding",
1251
1241
  proceed: void 0,
1252
1242
  reset: void 0,
1253
- location: location2
1243
+ location
1254
1244
  });
1255
1245
  nextHistoryUpdatePromise.then(() => init.history.go(delta));
1256
1246
  },
@@ -1262,7 +1252,7 @@ function createRouter(init) {
1262
1252
  });
1263
1253
  return;
1264
1254
  }
1265
- return startNavigation(historyAction, location2);
1255
+ return startNavigation(historyAction, location);
1266
1256
  }
1267
1257
  );
1268
1258
  if (isBrowser2) {
@@ -1295,19 +1285,6 @@ function createRouter(init) {
1295
1285
  return () => subscribers.delete(fn);
1296
1286
  }
1297
1287
  function updateState(newState, opts = {}) {
1298
- if (newState.matches) {
1299
- newState.matches = newState.matches.map((m) => {
1300
- let route = manifest[m.route.id];
1301
- let matchRoute = m.route;
1302
- if (matchRoute.element !== route.element || matchRoute.errorElement !== route.errorElement || matchRoute.hydrateFallbackElement !== route.hydrateFallbackElement) {
1303
- return {
1304
- ...m,
1305
- route
1306
- };
1307
- }
1308
- return m;
1309
- });
1310
- }
1311
1288
  state = {
1312
1289
  ...state,
1313
1290
  ...newState
@@ -1338,8 +1315,8 @@ function createRouter(init) {
1338
1315
  unmountedFetchers.forEach((key) => deleteFetcher(key));
1339
1316
  mountedFetchers.forEach((key) => state.fetchers.delete(key));
1340
1317
  }
1341
- function completeNavigation(location2, newState, { flushSync } = {}) {
1342
- let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && location2.state?._isRedirect !== true;
1318
+ function completeNavigation(location, newState, { flushSync } = {}) {
1319
+ let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && location.state?._isRedirect !== true;
1343
1320
  let actionData;
1344
1321
  if (newState.actionData) {
1345
1322
  if (Object.keys(newState.actionData).length > 0) {
@@ -1363,7 +1340,7 @@ function createRouter(init) {
1363
1340
  blockers = new Map(blockers);
1364
1341
  blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));
1365
1342
  }
1366
- let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location2.state?._isRedirect !== true;
1343
+ let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location.state?._isRedirect !== true;
1367
1344
  if (inFlightDataRoutes) {
1368
1345
  dataRoutes = inFlightDataRoutes;
1369
1346
  inFlightDataRoutes = void 0;
@@ -1371,35 +1348,35 @@ function createRouter(init) {
1371
1348
  if (isUninterruptedRevalidation) {
1372
1349
  } else if (pendingAction === "POP" /* Pop */) {
1373
1350
  } else if (pendingAction === "PUSH" /* Push */) {
1374
- init.history.push(location2, location2.state);
1351
+ init.history.push(location, location.state);
1375
1352
  } else if (pendingAction === "REPLACE" /* Replace */) {
1376
- init.history.replace(location2, location2.state);
1353
+ init.history.replace(location, location.state);
1377
1354
  }
1378
1355
  let viewTransitionOpts;
1379
1356
  if (pendingAction === "POP" /* Pop */) {
1380
1357
  let priorPaths = appliedViewTransitions.get(state.location.pathname);
1381
- if (priorPaths && priorPaths.has(location2.pathname)) {
1358
+ if (priorPaths && priorPaths.has(location.pathname)) {
1382
1359
  viewTransitionOpts = {
1383
1360
  currentLocation: state.location,
1384
- nextLocation: location2
1361
+ nextLocation: location
1385
1362
  };
1386
- } else if (appliedViewTransitions.has(location2.pathname)) {
1363
+ } else if (appliedViewTransitions.has(location.pathname)) {
1387
1364
  viewTransitionOpts = {
1388
- currentLocation: location2,
1365
+ currentLocation: location,
1389
1366
  nextLocation: state.location
1390
1367
  };
1391
1368
  }
1392
1369
  } else if (pendingViewTransitionEnabled) {
1393
1370
  let toPaths = appliedViewTransitions.get(state.location.pathname);
1394
1371
  if (toPaths) {
1395
- toPaths.add(location2.pathname);
1372
+ toPaths.add(location.pathname);
1396
1373
  } else {
1397
- toPaths = /* @__PURE__ */ new Set([location2.pathname]);
1374
+ toPaths = /* @__PURE__ */ new Set([location.pathname]);
1398
1375
  appliedViewTransitions.set(state.location.pathname, toPaths);
1399
1376
  }
1400
1377
  viewTransitionOpts = {
1401
1378
  currentLocation: state.location,
1402
- nextLocation: location2
1379
+ nextLocation: location
1403
1380
  };
1404
1381
  }
1405
1382
  updateState(
@@ -1409,12 +1386,12 @@ function createRouter(init) {
1409
1386
  actionData,
1410
1387
  loaderData,
1411
1388
  historyAction: pendingAction,
1412
- location: location2,
1389
+ location,
1413
1390
  initialized: true,
1414
1391
  navigation: IDLE_NAVIGATION,
1415
1392
  revalidation: "idle",
1416
1393
  restoreScrollPosition: getSavedScrollPosition(
1417
- location2,
1394
+ location,
1418
1395
  newState.matches || state.matches
1419
1396
  ),
1420
1397
  preventScrollReset,
@@ -1531,7 +1508,7 @@ function createRouter(init) {
1531
1508
  );
1532
1509
  return promise;
1533
1510
  }
1534
- async function startNavigation(historyAction, location2, opts) {
1511
+ async function startNavigation(historyAction, location, opts) {
1535
1512
  pendingNavigationController && pendingNavigationController.abort();
1536
1513
  pendingNavigationController = null;
1537
1514
  pendingAction = historyAction;
@@ -1544,22 +1521,22 @@ function createRouter(init) {
1544
1521
  let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
1545
1522
  // `matchRoutes()` has already been called if we're in here via `router.initialize()`
1546
1523
  state.matches
1547
- ) : matchRoutes(routesToUse, location2, basename);
1524
+ ) : matchRoutes(routesToUse, location, basename);
1548
1525
  let flushSync = (opts && opts.flushSync) === true;
1549
- if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location2) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1550
- completeNavigation(location2, { matches }, { flushSync });
1526
+ if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1527
+ completeNavigation(location, { matches }, { flushSync });
1551
1528
  return;
1552
1529
  }
1553
- let fogOfWar = checkFogOfWar(matches, routesToUse, location2.pathname);
1530
+ let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
1554
1531
  if (fogOfWar.active && fogOfWar.matches) {
1555
1532
  matches = fogOfWar.matches;
1556
1533
  }
1557
1534
  if (!matches) {
1558
1535
  let { error, notFoundMatches, route } = handleNavigational404(
1559
- location2.pathname
1536
+ location.pathname
1560
1537
  );
1561
1538
  completeNavigation(
1562
- location2,
1539
+ location,
1563
1540
  {
1564
1541
  matches: notFoundMatches,
1565
1542
  loaderData: {},
@@ -1574,7 +1551,7 @@ function createRouter(init) {
1574
1551
  pendingNavigationController = new AbortController();
1575
1552
  let request = createClientSideRequest(
1576
1553
  init.history,
1577
- location2,
1554
+ location,
1578
1555
  pendingNavigationController.signal,
1579
1556
  opts && opts.submission
1580
1557
  );
@@ -1590,7 +1567,7 @@ function createRouter(init) {
1590
1567
  } else if (opts && opts.submission && isMutationMethod(opts.submission.formMethod)) {
1591
1568
  let actionResult = await handleAction(
1592
1569
  request,
1593
- location2,
1570
+ location,
1594
1571
  opts.submission,
1595
1572
  matches,
1596
1573
  scopedContext,
@@ -1605,7 +1582,7 @@ function createRouter(init) {
1605
1582
  let [routeId, result] = actionResult.pendingActionResult;
1606
1583
  if (isErrorResult(result) && isRouteErrorResponse(result.error) && result.error.status === 404) {
1607
1584
  pendingNavigationController = null;
1608
- completeNavigation(location2, {
1585
+ completeNavigation(location, {
1609
1586
  matches: actionResult.matches,
1610
1587
  loaderData: {},
1611
1588
  errors: {
@@ -1617,7 +1594,7 @@ function createRouter(init) {
1617
1594
  }
1618
1595
  matches = actionResult.matches || matches;
1619
1596
  pendingActionResult = actionResult.pendingActionResult;
1620
- loadingNavigation = getLoadingNavigation(location2, opts.submission);
1597
+ loadingNavigation = getLoadingNavigation(location, opts.submission);
1621
1598
  flushSync = false;
1622
1599
  fogOfWar.active = false;
1623
1600
  request = createClientSideRequest(
@@ -1633,7 +1610,7 @@ function createRouter(init) {
1633
1610
  errors
1634
1611
  } = await handleLoaders(
1635
1612
  request,
1636
- location2,
1613
+ location,
1637
1614
  matches,
1638
1615
  scopedContext,
1639
1616
  fogOfWar.active,
@@ -1649,21 +1626,21 @@ function createRouter(init) {
1649
1626
  return;
1650
1627
  }
1651
1628
  pendingNavigationController = null;
1652
- completeNavigation(location2, {
1629
+ completeNavigation(location, {
1653
1630
  matches: updatedMatches || matches,
1654
1631
  ...getActionDataForCommit(pendingActionResult),
1655
1632
  loaderData,
1656
1633
  errors
1657
1634
  });
1658
1635
  }
1659
- async function handleAction(request, location2, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
1636
+ async function handleAction(request, location, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
1660
1637
  interruptActiveLoads();
1661
- let navigation = getSubmittingNavigation(location2, submission);
1638
+ let navigation = getSubmittingNavigation(location, submission);
1662
1639
  updateState({ navigation }, { flushSync: opts.flushSync === true });
1663
1640
  if (isFogOfWar) {
1664
1641
  let discoverResult = await discoverRoutes(
1665
1642
  matches,
1666
- location2.pathname,
1643
+ location.pathname,
1667
1644
  request.signal
1668
1645
  );
1669
1646
  if (discoverResult.type === "aborted") {
@@ -1682,7 +1659,7 @@ function createRouter(init) {
1682
1659
  };
1683
1660
  } else if (!discoverResult.matches) {
1684
1661
  let { notFoundMatches, error, route } = handleNavigational404(
1685
- location2.pathname
1662
+ location.pathname
1686
1663
  );
1687
1664
  return {
1688
1665
  matches: notFoundMatches,
@@ -1699,13 +1676,13 @@ function createRouter(init) {
1699
1676
  }
1700
1677
  }
1701
1678
  let result;
1702
- let actionMatch = getTargetMatch(matches, location2);
1679
+ let actionMatch = getTargetMatch(matches, location);
1703
1680
  if (!actionMatch.route.action && !actionMatch.route.lazy) {
1704
1681
  result = {
1705
1682
  type: "error" /* error */,
1706
1683
  error: getInternalRouterError(405, {
1707
1684
  method: request.method,
1708
- pathname: location2.pathname,
1685
+ pathname: location.pathname,
1709
1686
  routeId: actionMatch.route.id
1710
1687
  })
1711
1688
  };
@@ -1743,12 +1720,12 @@ function createRouter(init) {
1743
1720
  if (opts && opts.replace != null) {
1744
1721
  replace2 = opts.replace;
1745
1722
  } else {
1746
- let location3 = normalizeRedirectLocation(
1723
+ let location2 = normalizeRedirectLocation(
1747
1724
  result.response.headers.get("Location"),
1748
1725
  new URL(request.url),
1749
1726
  basename
1750
1727
  );
1751
- replace2 = location3 === state.location.pathname + state.location.search;
1728
+ replace2 = location2 === state.location.pathname + state.location.search;
1752
1729
  }
1753
1730
  await startRedirectNavigation(request, result, true, {
1754
1731
  submission,
@@ -1771,8 +1748,8 @@ function createRouter(init) {
1771
1748
  pendingActionResult: [actionMatch.route.id, result]
1772
1749
  };
1773
1750
  }
1774
- async function handleLoaders(request, location2, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
1775
- let loadingNavigation = overrideNavigation || getLoadingNavigation(location2, submission);
1751
+ async function handleLoaders(request, location, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
1752
+ let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
1776
1753
  let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
1777
1754
  let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
1778
1755
  if (isFogOfWar) {
@@ -1790,7 +1767,7 @@ function createRouter(init) {
1790
1767
  }
1791
1768
  let discoverResult = await discoverRoutes(
1792
1769
  matches,
1793
- location2.pathname,
1770
+ location.pathname,
1794
1771
  request.signal
1795
1772
  );
1796
1773
  if (discoverResult.type === "aborted") {
@@ -1806,7 +1783,7 @@ function createRouter(init) {
1806
1783
  };
1807
1784
  } else if (!discoverResult.matches) {
1808
1785
  let { error, notFoundMatches, route } = handleNavigational404(
1809
- location2.pathname
1786
+ location.pathname
1810
1787
  );
1811
1788
  return {
1812
1789
  matches: notFoundMatches,
@@ -1829,7 +1806,7 @@ function createRouter(init) {
1829
1806
  state,
1830
1807
  matches,
1831
1808
  activeSubmission,
1832
- location2,
1809
+ location,
1833
1810
  initialHydration ? [] : hydrationRouteProperties2,
1834
1811
  initialHydration === true,
1835
1812
  isRevalidationRequired,
@@ -1845,7 +1822,7 @@ function createRouter(init) {
1845
1822
  if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && revalidatingFetchers.length === 0) {
1846
1823
  let updatedFetchers2 = markFetchRedirectsDone();
1847
1824
  completeNavigation(
1848
- location2,
1825
+ location,
1849
1826
  {
1850
1827
  matches,
1851
1828
  loaderData: {},
@@ -2356,31 +2333,31 @@ function createRouter(init) {
2356
2333
  if (redirect2.response.headers.has("X-Remix-Revalidate")) {
2357
2334
  isRevalidationRequired = true;
2358
2335
  }
2359
- let location2 = redirect2.response.headers.get("Location");
2360
- invariant(location2, "Expected a Location header on the redirect Response");
2361
- location2 = normalizeRedirectLocation(
2362
- location2,
2336
+ let location = redirect2.response.headers.get("Location");
2337
+ invariant(location, "Expected a Location header on the redirect Response");
2338
+ location = normalizeRedirectLocation(
2339
+ location,
2363
2340
  new URL(request.url),
2364
2341
  basename
2365
2342
  );
2366
- let redirectLocation = createLocation(state.location, location2, {
2343
+ let redirectLocation = createLocation(state.location, location, {
2367
2344
  _isRedirect: true
2368
2345
  });
2369
2346
  if (isBrowser2) {
2370
2347
  let isDocumentReload = false;
2371
2348
  if (redirect2.response.headers.has("X-Remix-Reload-Document")) {
2372
2349
  isDocumentReload = true;
2373
- } else if (ABSOLUTE_URL_REGEX.test(location2)) {
2374
- const url = init.history.createURL(location2);
2350
+ } else if (ABSOLUTE_URL_REGEX.test(location)) {
2351
+ const url = init.history.createURL(location);
2375
2352
  isDocumentReload = // Hard reload if it's an absolute URL to a new origin
2376
2353
  url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename
2377
2354
  stripBasename(url.pathname, basename) == null;
2378
2355
  }
2379
2356
  if (isDocumentReload) {
2380
2357
  if (replace2) {
2381
- routerWindow.location.replace(location2);
2358
+ routerWindow.location.replace(location);
2382
2359
  } else {
2383
- routerWindow.location.assign(location2);
2360
+ routerWindow.location.assign(location);
2384
2361
  }
2385
2362
  return;
2386
2363
  }
@@ -2396,7 +2373,7 @@ function createRouter(init) {
2396
2373
  await startNavigation(redirectNavigationType, redirectLocation, {
2397
2374
  submission: {
2398
2375
  ...activeSubmission,
2399
- formAction: location2
2376
+ formAction: location
2400
2377
  },
2401
2378
  // Preserve these flags across redirects
2402
2379
  preventScrollReset: preventScrollReset || pendingPreventScrollReset,
@@ -2667,25 +2644,25 @@ function createRouter(init) {
2667
2644
  getScrollRestorationKey2 = null;
2668
2645
  };
2669
2646
  }
2670
- function getScrollKey(location2, matches) {
2647
+ function getScrollKey(location, matches) {
2671
2648
  if (getScrollRestorationKey2) {
2672
2649
  let key = getScrollRestorationKey2(
2673
- location2,
2650
+ location,
2674
2651
  matches.map((m) => convertRouteMatchToUiMatch(m, state.loaderData))
2675
2652
  );
2676
- return key || location2.key;
2653
+ return key || location.key;
2677
2654
  }
2678
- return location2.key;
2655
+ return location.key;
2679
2656
  }
2680
- function saveScrollPosition(location2, matches) {
2657
+ function saveScrollPosition(location, matches) {
2681
2658
  if (savedScrollPositions2 && getScrollPosition) {
2682
- let key = getScrollKey(location2, matches);
2659
+ let key = getScrollKey(location, matches);
2683
2660
  savedScrollPositions2[key] = getScrollPosition();
2684
2661
  }
2685
2662
  }
2686
- function getSavedScrollPosition(location2, matches) {
2663
+ function getSavedScrollPosition(location, matches) {
2687
2664
  if (savedScrollPositions2) {
2688
- let key = getScrollKey(location2, matches);
2665
+ let key = getScrollKey(location, matches);
2689
2666
  let y = savedScrollPositions2[key];
2690
2667
  if (typeof y === "number") {
2691
2668
  return y;
@@ -2739,8 +2716,7 @@ function createRouter(init) {
2739
2716
  children,
2740
2717
  routesToUse,
2741
2718
  localManifest,
2742
- mapRouteProperties2,
2743
- false
2719
+ mapRouteProperties2
2744
2720
  );
2745
2721
  }
2746
2722
  });
@@ -2781,7 +2757,7 @@ function createRouter(init) {
2781
2757
  manifest
2782
2758
  );
2783
2759
  }
2784
- function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
2760
+ function patchRoutes(routeId, children) {
2785
2761
  let isNonHMR = inFlightDataRoutes == null;
2786
2762
  let routesToUse = inFlightDataRoutes || dataRoutes;
2787
2763
  patchRoutesImpl(
@@ -2789,8 +2765,7 @@ function createRouter(init) {
2789
2765
  children,
2790
2766
  routesToUse,
2791
2767
  manifest,
2792
- mapRouteProperties2,
2793
- unstable_allowElementMutations
2768
+ mapRouteProperties2
2794
2769
  );
2795
2770
  if (isNonHMR) {
2796
2771
  dataRoutes = [...dataRoutes];
@@ -2832,10 +2807,7 @@ function createRouter(init) {
2832
2807
  _internalFetchControllers: fetchControllers,
2833
2808
  // TODO: Remove setRoutes, it's temporary to avoid dealing with
2834
2809
  // updating the tree while validating the update algorithm.
2835
- _internalSetRoutes,
2836
- _internalSetStateDoNotUseOrYouWillBreakYourApp(newState) {
2837
- updateState(newState);
2838
- }
2810
+ _internalSetRoutes
2839
2811
  };
2840
2812
  return router;
2841
2813
  }
@@ -2863,15 +2835,15 @@ function createStaticHandler(routes, opts) {
2863
2835
  } = {}) {
2864
2836
  let url = new URL(request.url);
2865
2837
  let method = request.method;
2866
- let location2 = createLocation("", createPath(url), null, "default");
2867
- let matches = matchRoutes(dataRoutes, location2, basename);
2838
+ let location = createLocation("", createPath(url), null, "default");
2839
+ let matches = matchRoutes(dataRoutes, location, basename);
2868
2840
  requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
2869
2841
  if (!isValidMethod(method) && method !== "HEAD") {
2870
2842
  let error = getInternalRouterError(405, { method });
2871
2843
  let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
2872
2844
  let staticContext = {
2873
2845
  basename,
2874
- location: location2,
2846
+ location,
2875
2847
  matches: methodNotAllowedMatches,
2876
2848
  loaderData: {},
2877
2849
  actionData: null,
@@ -2884,11 +2856,11 @@ function createStaticHandler(routes, opts) {
2884
2856
  };
2885
2857
  return respond ? respond(staticContext) : staticContext;
2886
2858
  } else if (!matches) {
2887
- let error = getInternalRouterError(404, { pathname: location2.pathname });
2859
+ let error = getInternalRouterError(404, { pathname: location.pathname });
2888
2860
  let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
2889
2861
  let staticContext = {
2890
2862
  basename,
2891
- location: location2,
2863
+ location,
2892
2864
  matches: notFoundMatches,
2893
2865
  loaderData: {},
2894
2866
  actionData: null,
@@ -2928,7 +2900,7 @@ function createStaticHandler(routes, opts) {
2928
2900
  async () => {
2929
2901
  let result2 = await queryImpl(
2930
2902
  request,
2931
- location2,
2903
+ location,
2932
2904
  matches,
2933
2905
  requestContext,
2934
2906
  dataStrategy || null,
@@ -2940,7 +2912,7 @@ function createStaticHandler(routes, opts) {
2940
2912
  if (isResponse(result2)) {
2941
2913
  return result2;
2942
2914
  }
2943
- renderedStaticContext = { location: location2, basename, ...result2 };
2915
+ renderedStaticContext = { location, basename, ...result2 };
2944
2916
  let res = await respond(renderedStaticContext);
2945
2917
  return res;
2946
2918
  },
@@ -2965,7 +2937,7 @@ function createStaticHandler(routes, opts) {
2965
2937
  let boundary = loaderIdx >= 0 ? findNearestBoundary(matches, matches[loaderIdx].route.id) : findNearestBoundary(matches);
2966
2938
  return respond({
2967
2939
  matches,
2968
- location: location2,
2940
+ location,
2969
2941
  basename,
2970
2942
  loaderData: {},
2971
2943
  actionData: null,
@@ -2990,7 +2962,7 @@ function createStaticHandler(routes, opts) {
2990
2962
  }
2991
2963
  let result = await queryImpl(
2992
2964
  request,
2993
- location2,
2965
+ location,
2994
2966
  matches,
2995
2967
  requestContext,
2996
2968
  dataStrategy || null,
@@ -3002,7 +2974,7 @@ function createStaticHandler(routes, opts) {
3002
2974
  if (isResponse(result)) {
3003
2975
  return result;
3004
2976
  }
3005
- return { location: location2, basename, ...result };
2977
+ return { location, basename, ...result };
3006
2978
  }
3007
2979
  async function queryRoute(request, {
3008
2980
  routeId,
@@ -3012,22 +2984,22 @@ function createStaticHandler(routes, opts) {
3012
2984
  } = {}) {
3013
2985
  let url = new URL(request.url);
3014
2986
  let method = request.method;
3015
- let location2 = createLocation("", createPath(url), null, "default");
3016
- let matches = matchRoutes(dataRoutes, location2, basename);
2987
+ let location = createLocation("", createPath(url), null, "default");
2988
+ let matches = matchRoutes(dataRoutes, location, basename);
3017
2989
  requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
3018
2990
  if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
3019
2991
  throw getInternalRouterError(405, { method });
3020
2992
  } else if (!matches) {
3021
- throw getInternalRouterError(404, { pathname: location2.pathname });
2993
+ throw getInternalRouterError(404, { pathname: location.pathname });
3022
2994
  }
3023
- let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location2);
2995
+ let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location);
3024
2996
  if (routeId && !match) {
3025
2997
  throw getInternalRouterError(403, {
3026
- pathname: location2.pathname,
2998
+ pathname: location.pathname,
3027
2999
  routeId
3028
3000
  });
3029
3001
  } else if (!match) {
3030
- throw getInternalRouterError(404, { pathname: location2.pathname });
3002
+ throw getInternalRouterError(404, { pathname: location.pathname });
3031
3003
  }
3032
3004
  if (respond && matches.some(
3033
3005
  (m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
@@ -3050,7 +3022,7 @@ function createStaticHandler(routes, opts) {
3050
3022
  async () => {
3051
3023
  let result2 = await queryImpl(
3052
3024
  request,
3053
- location2,
3025
+ location,
3054
3026
  matches,
3055
3027
  requestContext,
3056
3028
  dataStrategy || null,
@@ -3083,7 +3055,7 @@ function createStaticHandler(routes, opts) {
3083
3055
  }
3084
3056
  let result = await queryImpl(
3085
3057
  request,
3086
- location2,
3058
+ location,
3087
3059
  matches,
3088
3060
  requestContext,
3089
3061
  dataStrategy || null,
@@ -3107,7 +3079,7 @@ function createStaticHandler(routes, opts) {
3107
3079
  }
3108
3080
  return void 0;
3109
3081
  }
3110
- async function queryImpl(request, location2, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
3082
+ async function queryImpl(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
3111
3083
  invariant(
3112
3084
  request.signal,
3113
3085
  "query()/queryRoute() requests must contain an AbortController signal"
@@ -3117,7 +3089,7 @@ function createStaticHandler(routes, opts) {
3117
3089
  let result2 = await submit(
3118
3090
  request,
3119
3091
  matches,
3120
- routeMatch || getTargetMatch(matches, location2),
3092
+ routeMatch || getTargetMatch(matches, location),
3121
3093
  requestContext,
3122
3094
  dataStrategy,
3123
3095
  skipLoaderErrorBubbling,
@@ -3433,7 +3405,7 @@ function throwStaticHandlerAbortedError(request, isRouteRequest) {
3433
3405
  function isSubmissionNavigation(opts) {
3434
3406
  return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0);
3435
3407
  }
3436
- function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
3408
+ function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
3437
3409
  let contextualMatches;
3438
3410
  let activeRouteMatch;
3439
3411
  if (fromRouteId) {
@@ -3452,12 +3424,12 @@ function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
3452
3424
  let path = resolveTo(
3453
3425
  to ? to : ".",
3454
3426
  getResolveToMatches(contextualMatches),
3455
- stripBasename(location2.pathname, basename) || location2.pathname,
3427
+ stripBasename(location.pathname, basename) || location.pathname,
3456
3428
  relative === "path"
3457
3429
  );
3458
3430
  if (to == null) {
3459
- path.search = location2.search;
3460
- path.hash = location2.hash;
3431
+ path.search = location.search;
3432
+ path.hash = location.hash;
3461
3433
  }
3462
3434
  if ((to == null || to === "" || to === ".") && activeRouteMatch) {
3463
3435
  let nakedIndex = hasNakedIndexQuery(path.search);
@@ -3584,10 +3556,10 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
3584
3556
  parsedPath.search = `?${searchParams}`;
3585
3557
  return { path: createPath(parsedPath), submission };
3586
3558
  }
3587
- function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location2, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
3559
+ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
3588
3560
  let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
3589
3561
  let currentUrl = history.createURL(state.location);
3590
- let nextUrl = history.createURL(location2);
3562
+ let nextUrl = history.createURL(location);
3591
3563
  let maxIdx;
3592
3564
  if (initialHydration && state.errors) {
3593
3565
  let boundaryId = Object.keys(state.errors)[0];
@@ -3786,7 +3758,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
3786
3758
  }
3787
3759
  return arg.defaultShouldRevalidate;
3788
3760
  }
3789
- function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
3761
+ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2) {
3790
3762
  let childrenToPatch;
3791
3763
  if (routeId) {
3792
3764
  let route = manifest[routeId];
@@ -3801,47 +3773,18 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
3801
3773
  } else {
3802
3774
  childrenToPatch = routesToUse;
3803
3775
  }
3804
- let uniqueChildren = [];
3805
- let existingChildren = [];
3806
- children.forEach((newRoute) => {
3807
- let existingRoute = childrenToPatch.find(
3808
- (existingRoute2) => isSameRoute(newRoute, existingRoute2)
3809
- );
3810
- if (existingRoute) {
3811
- existingChildren.push({ existingRoute, newRoute });
3812
- } else {
3813
- uniqueChildren.push(newRoute);
3814
- }
3815
- });
3816
- if (uniqueChildren.length > 0) {
3817
- let newRoutes = convertRoutesToDataRoutes(
3818
- uniqueChildren,
3819
- mapRouteProperties2,
3820
- [routeId || "_", "patch", String(childrenToPatch?.length || "0")],
3821
- manifest
3822
- );
3823
- childrenToPatch.push(...newRoutes);
3824
- }
3825
- if (allowElementMutations && existingChildren.length > 0) {
3826
- for (let i = 0; i < existingChildren.length; i++) {
3827
- let { existingRoute, newRoute } = existingChildren[i];
3828
- let existingRouteTyped = existingRoute;
3829
- let [newRouteTyped] = convertRoutesToDataRoutes(
3830
- [newRoute],
3831
- mapRouteProperties2,
3832
- [],
3833
- // Doesn't matter for mutated routes since they already have an id
3834
- {},
3835
- // Don't touch the manifest here since we're updating in place
3836
- true
3837
- );
3838
- Object.assign(existingRouteTyped, {
3839
- element: newRouteTyped.element ? newRouteTyped.element : existingRouteTyped.element,
3840
- errorElement: newRouteTyped.errorElement ? newRouteTyped.errorElement : existingRouteTyped.errorElement,
3841
- hydrateFallbackElement: newRouteTyped.hydrateFallbackElement ? newRouteTyped.hydrateFallbackElement : existingRouteTyped.hydrateFallbackElement
3842
- });
3843
- }
3844
- }
3776
+ let uniqueChildren = children.filter(
3777
+ (newRoute) => !childrenToPatch.some(
3778
+ (existingRoute) => isSameRoute(newRoute, existingRoute)
3779
+ )
3780
+ );
3781
+ let newRoutes = convertRoutesToDataRoutes(
3782
+ uniqueChildren,
3783
+ mapRouteProperties2,
3784
+ [routeId || "_", "patch", String(childrenToPatch?.length || "0")],
3785
+ manifest
3786
+ );
3787
+ childrenToPatch.push(...newRoutes);
3845
3788
  }
3846
3789
  function isSameRoute(newRoute, existingRoute) {
3847
3790
  if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
@@ -4190,7 +4133,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, laz
4190
4133
  return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
4191
4134
  },
4192
4135
  resolve(handlerOverride) {
4193
- if (isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (match.route.lazy || match.route.loader)) {
4136
+ if (isUsingNewApi || shouldLoad || handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
4194
4137
  return callLoaderOrAction({
4195
4138
  request,
4196
4139
  match,
@@ -4450,39 +4393,39 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
4450
4393
  return { type: "data" /* data */, data: result };
4451
4394
  }
4452
4395
  function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename) {
4453
- let location2 = response.headers.get("Location");
4396
+ let location = response.headers.get("Location");
4454
4397
  invariant(
4455
- location2,
4398
+ location,
4456
4399
  "Redirects returned/thrown from loaders/actions must have a Location header"
4457
4400
  );
4458
- if (!ABSOLUTE_URL_REGEX.test(location2)) {
4401
+ if (!ABSOLUTE_URL_REGEX.test(location)) {
4459
4402
  let trimmedMatches = matches.slice(
4460
4403
  0,
4461
4404
  matches.findIndex((m) => m.route.id === routeId) + 1
4462
4405
  );
4463
- location2 = normalizeTo(
4406
+ location = normalizeTo(
4464
4407
  new URL(request.url),
4465
4408
  trimmedMatches,
4466
4409
  basename,
4467
- location2
4410
+ location
4468
4411
  );
4469
- response.headers.set("Location", location2);
4412
+ response.headers.set("Location", location);
4470
4413
  }
4471
4414
  return response;
4472
4415
  }
4473
- function normalizeRedirectLocation(location2, currentUrl, basename) {
4474
- if (ABSOLUTE_URL_REGEX.test(location2)) {
4475
- let normalizedLocation = location2;
4416
+ function normalizeRedirectLocation(location, currentUrl, basename) {
4417
+ if (ABSOLUTE_URL_REGEX.test(location)) {
4418
+ let normalizedLocation = location;
4476
4419
  let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
4477
4420
  let isSameBasename = stripBasename(url.pathname, basename) != null;
4478
4421
  if (url.origin === currentUrl.origin && isSameBasename) {
4479
4422
  return url.pathname + url.search + url.hash;
4480
4423
  }
4481
4424
  }
4482
- return location2;
4425
+ return location;
4483
4426
  }
4484
- function createClientSideRequest(history, location2, signal, submission) {
4485
- let url = history.createURL(stripHashFromPath(location2)).toString();
4427
+ function createClientSideRequest(history, location, signal, submission) {
4428
+ let url = history.createURL(stripHashFromPath(location)).toString();
4486
4429
  let init = { signal };
4487
4430
  if (submission && isMutationMethod(submission.formMethod)) {
4488
4431
  let { formMethod, formEncType } = submission;
@@ -4752,8 +4695,8 @@ function isMutationMethod(method) {
4752
4695
  function hasNakedIndexQuery(search) {
4753
4696
  return new URLSearchParams(search).getAll("index").some((v) => v === "");
4754
4697
  }
4755
- function getTargetMatch(matches, location2) {
4756
- let search = typeof location2 === "string" ? parsePath(location2).search : location2.search;
4698
+ function getTargetMatch(matches, location) {
4699
+ let search = typeof location === "string" ? parsePath(location).search : location.search;
4757
4700
  if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
4758
4701
  return matches[matches.length - 1];
4759
4702
  }
@@ -4794,11 +4737,11 @@ function getSubmissionFromNavigation(navigation) {
4794
4737
  };
4795
4738
  }
4796
4739
  }
4797
- function getLoadingNavigation(location2, submission) {
4740
+ function getLoadingNavigation(location, submission) {
4798
4741
  if (submission) {
4799
4742
  let navigation = {
4800
4743
  state: "loading",
4801
- location: location2,
4744
+ location,
4802
4745
  formMethod: submission.formMethod,
4803
4746
  formAction: submission.formAction,
4804
4747
  formEncType: submission.formEncType,
@@ -4810,7 +4753,7 @@ function getLoadingNavigation(location2, submission) {
4810
4753
  } else {
4811
4754
  let navigation = {
4812
4755
  state: "loading",
4813
- location: location2,
4756
+ location,
4814
4757
  formMethod: void 0,
4815
4758
  formAction: void 0,
4816
4759
  formEncType: void 0,
@@ -4821,10 +4764,10 @@ function getLoadingNavigation(location2, submission) {
4821
4764
  return navigation;
4822
4765
  }
4823
4766
  }
4824
- function getSubmittingNavigation(location2, submission) {
4767
+ function getSubmittingNavigation(location, submission) {
4825
4768
  let navigation = {
4826
4769
  state: "submitting",
4827
- location: location2,
4770
+ location,
4828
4771
  formMethod: submission.formMethod,
4829
4772
  formAction: submission.formAction,
4830
4773
  formEncType: submission.formEncType,
@@ -5150,18 +5093,18 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5150
5093
  );
5151
5094
  }
5152
5095
  let locationFromContext = useLocation();
5153
- let location2;
5096
+ let location;
5154
5097
  if (locationArg) {
5155
5098
  let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
5156
5099
  invariant(
5157
5100
  parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase),
5158
5101
  `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.`
5159
5102
  );
5160
- location2 = parsedLocationArg;
5103
+ location = parsedLocationArg;
5161
5104
  } else {
5162
- location2 = locationFromContext;
5105
+ location = locationFromContext;
5163
5106
  }
5164
- let pathname = location2.pathname || "/";
5107
+ let pathname = location.pathname || "/";
5165
5108
  let remainingPathname = pathname;
5166
5109
  if (parentPathnameBase !== "/") {
5167
5110
  let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
@@ -5172,11 +5115,11 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5172
5115
  if (ENABLE_DEV_WARNINGS) {
5173
5116
  warning(
5174
5117
  parentRoute || matches != null,
5175
- `No routes matched location "${location2.pathname}${location2.search}${location2.hash}" `
5118
+ `No routes matched location "${location.pathname}${location.search}${location.hash}" `
5176
5119
  );
5177
5120
  warning(
5178
5121
  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,
5179
- `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.`
5122
+ `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.`
5180
5123
  );
5181
5124
  }
5182
5125
  let renderedMatches = _renderMatches(
@@ -5210,7 +5153,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5210
5153
  hash: "",
5211
5154
  state: null,
5212
5155
  key: "default",
5213
- ...location2
5156
+ ...location
5214
5157
  },
5215
5158
  navigationType: "POP" /* Pop */
5216
5159
  }
@@ -5975,9 +5918,9 @@ function Router({
5975
5918
  }
5976
5919
  function Routes({
5977
5920
  children,
5978
- location: location2
5921
+ location
5979
5922
  }) {
5980
- return useRoutes(createRoutesFromChildren(children), location2);
5923
+ return useRoutes(createRoutesFromChildren(children), location);
5981
5924
  }
5982
5925
  function Await({
5983
5926
  children,
@@ -6047,38 +5990,6 @@ function ResolveAwait({
6047
5990
  let toRender = typeof children === "function" ? children(data2) : children;
6048
5991
  return /* @__PURE__ */ React3.createElement(React3.Fragment, null, toRender);
6049
5992
  }
6050
- function WithRouteComponentProps({
6051
- children
6052
- }) {
6053
- let props = {
6054
- loaderData: useLoaderData(),
6055
- actionData: useActionData(),
6056
- params: useParams(),
6057
- matches: useMatches()
6058
- };
6059
- return React3.cloneElement(children, props);
6060
- }
6061
- function WithHydrateFallbackProps({
6062
- children
6063
- }) {
6064
- let props = {
6065
- loaderData: useLoaderData(),
6066
- actionData: useActionData(),
6067
- params: useParams()
6068
- };
6069
- return React3.cloneElement(children, props);
6070
- }
6071
- function WithErrorBoundaryProps({
6072
- children
6073
- }) {
6074
- let props = {
6075
- loaderData: useLoaderData(),
6076
- actionData: useActionData(),
6077
- params: useParams(),
6078
- error: useRouteError()
6079
- };
6080
- return React3.cloneElement(children, props);
6081
- }
6082
5993
  function createRoutesFromChildren(children, parentPath = []) {
6083
5994
  let routes = [];
6084
5995
  React3.Children.forEach(children, (element, index) => {
@@ -6401,7 +6312,7 @@ async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
6401
6312
  )
6402
6313
  );
6403
6314
  }
6404
- function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location2, mode) {
6315
+ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
6405
6316
  let isNew = (match, index) => {
6406
6317
  if (!currentMatches[index]) return true;
6407
6318
  return match.route.id !== currentMatches[index].route.id;
@@ -6431,7 +6342,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
6431
6342
  if (match.route.shouldRevalidate) {
6432
6343
  let routeChoice = match.route.shouldRevalidate({
6433
6344
  currentUrl: new URL(
6434
- location2.pathname + location2.search + location2.hash,
6345
+ location.pathname + location.search + location.hash,
6435
6346
  window.origin
6436
6347
  ),
6437
6348
  currentParams: currentMatches[0]?.params || {},
@@ -6551,6 +6462,7 @@ async function createRequestInit(request) {
6551
6462
 
6552
6463
  // lib/dom/ssr/single-fetch.tsx
6553
6464
  var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
6465
+ var SINGLE_FETCH_REDIRECT_STATUS = 202;
6554
6466
  var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205]);
6555
6467
  function StreamTransfer({
6556
6468
  context,
@@ -6803,7 +6715,7 @@ function stripIndexParam(url) {
6803
6715
  }
6804
6716
  return url;
6805
6717
  }
6806
- function singleFetchUrl(reqUrl, basename, extension) {
6718
+ function singleFetchUrl(reqUrl, basename) {
6807
6719
  let url = typeof reqUrl === "string" ? new URL(
6808
6720
  reqUrl,
6809
6721
  // This can be called during the SSR flow via PrefetchPageLinksImpl so
@@ -6811,17 +6723,17 @@ function singleFetchUrl(reqUrl, basename, extension) {
6811
6723
  typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
6812
6724
  ) : reqUrl;
6813
6725
  if (url.pathname === "/") {
6814
- url.pathname = `_root.${extension}`;
6726
+ url.pathname = "_root.data";
6815
6727
  } else if (basename && stripBasename(url.pathname, basename) === "/") {
6816
- url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
6728
+ url.pathname = `${basename.replace(/\/$/, "")}/_root.data`;
6817
6729
  } else {
6818
- url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
6730
+ url.pathname = `${url.pathname.replace(/\/$/, "")}.data`;
6819
6731
  }
6820
6732
  return url;
6821
6733
  }
6822
6734
  async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
6823
6735
  let { request } = args;
6824
- let url = singleFetchUrl(request.url, basename, "data");
6736
+ let url = singleFetchUrl(request.url, basename);
6825
6737
  if (request.method === "GET") {
6826
6738
  url = stripIndexParam(url);
6827
6739
  if (targetRoutes) {
@@ -6832,6 +6744,20 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
6832
6744
  if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
6833
6745
  throw new ErrorResponseImpl(404, "Not Found", true);
6834
6746
  }
6747
+ if (res.status === 204 && res.headers.has("X-Remix-Redirect")) {
6748
+ return {
6749
+ status: SINGLE_FETCH_REDIRECT_STATUS,
6750
+ data: {
6751
+ redirect: {
6752
+ redirect: res.headers.get("X-Remix-Redirect"),
6753
+ status: Number(res.headers.get("X-Remix-Status") || "302"),
6754
+ revalidate: res.headers.get("X-Remix-Revalidate") === "true",
6755
+ reload: res.headers.get("X-Remix-Reload-Document") === "true",
6756
+ replace: res.headers.get("X-Remix-Replace") === "true"
6757
+ }
6758
+ }
6759
+ };
6760
+ }
6835
6761
  if (NO_BODY_STATUS_CODES.has(res.status)) {
6836
6762
  let routes = {};
6837
6763
  if (targetRoutes && request.method !== "GET") {
@@ -6904,13 +6830,13 @@ function decodeViaTurboStream(body, global2) {
6904
6830
  function unwrapSingleFetchResult(result, routeId) {
6905
6831
  if ("redirect" in result) {
6906
6832
  let {
6907
- redirect: location2,
6833
+ redirect: location,
6908
6834
  revalidate,
6909
6835
  reload,
6910
6836
  replace: replace2,
6911
6837
  status
6912
6838
  } = result.redirect;
6913
- throw redirect(location2, {
6839
+ throw redirect(location, {
6914
6840
  status,
6915
6841
  headers: {
6916
6842
  // Three R's of redirecting (lol Veep)
@@ -6921,13 +6847,12 @@ function unwrapSingleFetchResult(result, routeId) {
6921
6847
  });
6922
6848
  }
6923
6849
  let routeResult = result.routes[routeId];
6924
- invariant2(routeResult, `No response found for routeId "${routeId}"`);
6925
6850
  if ("error" in routeResult) {
6926
6851
  throw routeResult.error;
6927
6852
  } else if ("data" in routeResult) {
6928
6853
  return routeResult.data;
6929
6854
  } else {
6930
- throw new Error(`Invalid response found for routeId "${routeId}"`);
6855
+ throw new Error(`No response found for routeId "${routeId}"`);
6931
6856
  }
6932
6857
  }
6933
6858
  function createDeferred2() {
@@ -7827,7 +7752,7 @@ function PrefetchPageLinksImpl({
7827
7752
  matches: nextMatches,
7828
7753
  ...linkProps
7829
7754
  }) {
7830
- let location2 = useLocation();
7755
+ let location = useLocation();
7831
7756
  let { manifest, routeModules } = useFrameworkContext();
7832
7757
  let { basename } = useDataRouterContext2();
7833
7758
  let { loaderData, matches } = useDataRouterStateContext();
@@ -7837,10 +7762,10 @@ function PrefetchPageLinksImpl({
7837
7762
  nextMatches,
7838
7763
  matches,
7839
7764
  manifest,
7840
- location2,
7765
+ location,
7841
7766
  "data"
7842
7767
  ),
7843
- [page, nextMatches, matches, manifest, location2]
7768
+ [page, nextMatches, matches, manifest, location]
7844
7769
  );
7845
7770
  let newMatchesForAssets = React9.useMemo(
7846
7771
  () => getNewMatchesForLinks(
@@ -7848,13 +7773,13 @@ function PrefetchPageLinksImpl({
7848
7773
  nextMatches,
7849
7774
  matches,
7850
7775
  manifest,
7851
- location2,
7776
+ location,
7852
7777
  "assets"
7853
7778
  ),
7854
- [page, nextMatches, matches, manifest, location2]
7779
+ [page, nextMatches, matches, manifest, location]
7855
7780
  );
7856
7781
  let dataHrefs = React9.useMemo(() => {
7857
- if (page === location2.pathname + location2.search + location2.hash) {
7782
+ if (page === location.pathname + location.search + location.hash) {
7858
7783
  return [];
7859
7784
  }
7860
7785
  let routesParams = /* @__PURE__ */ new Set();
@@ -7875,7 +7800,7 @@ function PrefetchPageLinksImpl({
7875
7800
  if (routesParams.size === 0) {
7876
7801
  return [];
7877
7802
  }
7878
- let url = singleFetchUrl(page, basename, ".data");
7803
+ let url = singleFetchUrl(page, basename);
7879
7804
  if (foundOptOutRoute && routesParams.size > 0) {
7880
7805
  url.searchParams.set(
7881
7806
  "_routes",
@@ -7886,7 +7811,7 @@ function PrefetchPageLinksImpl({
7886
7811
  }, [
7887
7812
  basename,
7888
7813
  loaderData,
7889
- location2,
7814
+ location,
7890
7815
  manifest,
7891
7816
  newMatchesForData,
7892
7817
  nextMatches,
@@ -7911,7 +7836,7 @@ function Meta() {
7911
7836
  matches: routerMatches,
7912
7837
  loaderData
7913
7838
  } = useDataRouterStateContext();
7914
- let location2 = useLocation();
7839
+ let location = useLocation();
7915
7840
  let _matches = getActiveMatches(routerMatches, errors, isSpaMode);
7916
7841
  let error = null;
7917
7842
  if (errors) {
@@ -7941,7 +7866,7 @@ function Meta() {
7941
7866
  routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
7942
7867
  data: data2,
7943
7868
  params,
7944
- location: location2,
7869
+ location,
7945
7870
  matches,
7946
7871
  error
7947
7872
  }) : Array.isArray(routeModule.meta) ? [...routeModule.meta] : routeModule.meta;
@@ -8166,7 +8091,7 @@ function mergeRefs(...refs) {
8166
8091
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
8167
8092
  try {
8168
8093
  if (isBrowser) {
8169
- window.__reactRouterVersion = "0.0.0-experimental-a6d1d1d4e";
8094
+ window.__reactRouterVersion = "0.0.0-experimental-1d760f6a6";
8170
8095
  }
8171
8096
  } catch (e) {
8172
8097
  }
@@ -8424,14 +8349,14 @@ var NavLink = React10.forwardRef(
8424
8349
  ...rest
8425
8350
  }, ref) {
8426
8351
  let path = useResolvedPath(to, { relative: rest.relative });
8427
- let location2 = useLocation();
8352
+ let location = useLocation();
8428
8353
  let routerState = React10.useContext(DataRouterStateContext);
8429
8354
  let { navigator: navigator2, basename } = React10.useContext(NavigationContext);
8430
8355
  let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
8431
8356
  // eslint-disable-next-line react-hooks/rules-of-hooks
8432
8357
  useViewTransitionState(path) && viewTransition === true;
8433
8358
  let toPathname = navigator2.encodeLocation ? navigator2.encodeLocation(path).pathname : path.pathname;
8434
- let locationPathname = location2.pathname;
8359
+ let locationPathname = location.pathname;
8435
8360
  let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
8436
8361
  if (!caseSensitive) {
8437
8362
  locationPathname = locationPathname.toLowerCase();
@@ -8536,19 +8461,19 @@ function ScrollRestoration({
8536
8461
  }) {
8537
8462
  let remixContext = React10.useContext(FrameworkContext);
8538
8463
  let { basename } = React10.useContext(NavigationContext);
8539
- let location2 = useLocation();
8464
+ let location = useLocation();
8540
8465
  let matches = useMatches();
8541
8466
  useScrollRestoration({ getKey, storageKey });
8542
8467
  let ssrKey = React10.useMemo(
8543
8468
  () => {
8544
8469
  if (!remixContext || !getKey) return null;
8545
8470
  let userKey = getScrollRestorationKey(
8546
- location2,
8471
+ location,
8547
8472
  matches,
8548
8473
  basename,
8549
8474
  getKey
8550
8475
  );
8551
- return userKey !== location2.key ? userKey : null;
8476
+ return userKey !== location.key ? userKey : null;
8552
8477
  },
8553
8478
  // Nah, we only need this the first time for the SSR render
8554
8479
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -8609,13 +8534,13 @@ function useLinkClickHandler(to, {
8609
8534
  viewTransition
8610
8535
  } = {}) {
8611
8536
  let navigate = useNavigate();
8612
- let location2 = useLocation();
8537
+ let location = useLocation();
8613
8538
  let path = useResolvedPath(to, { relative });
8614
8539
  return React10.useCallback(
8615
8540
  (event) => {
8616
8541
  if (shouldProcessLinkClick(event, target)) {
8617
8542
  event.preventDefault();
8618
- let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location2) === createPath(path);
8543
+ let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
8619
8544
  navigate(to, {
8620
8545
  replace: replace2,
8621
8546
  state,
@@ -8626,7 +8551,7 @@ function useLinkClickHandler(to, {
8626
8551
  }
8627
8552
  },
8628
8553
  [
8629
- location2,
8554
+ location,
8630
8555
  navigate,
8631
8556
  path,
8632
8557
  replaceProp,
@@ -8646,18 +8571,18 @@ function useSearchParams(defaultInit) {
8646
8571
  );
8647
8572
  let defaultSearchParamsRef = React10.useRef(createSearchParams(defaultInit));
8648
8573
  let hasSetSearchParamsRef = React10.useRef(false);
8649
- let location2 = useLocation();
8574
+ let location = useLocation();
8650
8575
  let searchParams = React10.useMemo(
8651
8576
  () => (
8652
8577
  // Only merge in the defaults if we haven't yet called setSearchParams.
8653
8578
  // Once we call that we want those to take precedence, otherwise you can't
8654
8579
  // remove a param with setSearchParams({}) if it has an initial value
8655
8580
  getSearchParamsForLocation(
8656
- location2.search,
8581
+ location.search,
8657
8582
  hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
8658
8583
  )
8659
8584
  ),
8660
- [location2.search]
8585
+ [location.search]
8661
8586
  );
8662
8587
  let navigate = useNavigate();
8663
8588
  let setSearchParams = React10.useCallback(
@@ -8718,9 +8643,9 @@ function useFormAction(action, { relative } = {}) {
8718
8643
  invariant(routeContext, "useFormAction must be used inside a RouteContext");
8719
8644
  let [match] = routeContext.matches.slice(-1);
8720
8645
  let path = { ...useResolvedPath(action ? action : ".", { relative }) };
8721
- let location2 = useLocation();
8646
+ let location = useLocation();
8722
8647
  if (action == null) {
8723
- path.search = location2.search;
8648
+ path.search = location.search;
8724
8649
  let params = new URLSearchParams(path.search);
8725
8650
  let indexValues = params.getAll("index");
8726
8651
  let hasNakedIndexParam = indexValues.some((v) => v === "");
@@ -8812,23 +8737,23 @@ function useFetchers() {
8812
8737
  }
8813
8738
  var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
8814
8739
  var savedScrollPositions = {};
8815
- function getScrollRestorationKey(location2, matches, basename, getKey) {
8740
+ function getScrollRestorationKey(location, matches, basename, getKey) {
8816
8741
  let key = null;
8817
8742
  if (getKey) {
8818
8743
  if (basename !== "/") {
8819
8744
  key = getKey(
8820
8745
  {
8821
- ...location2,
8822
- pathname: stripBasename(location2.pathname, basename) || location2.pathname
8746
+ ...location,
8747
+ pathname: stripBasename(location.pathname, basename) || location.pathname
8823
8748
  },
8824
8749
  matches
8825
8750
  );
8826
8751
  } else {
8827
- key = getKey(location2, matches);
8752
+ key = getKey(location, matches);
8828
8753
  }
8829
8754
  }
8830
8755
  if (key == null) {
8831
- key = location2.key;
8756
+ key = location.key;
8832
8757
  }
8833
8758
  return key;
8834
8759
  }
@@ -8841,7 +8766,7 @@ function useScrollRestoration({
8841
8766
  "useScrollRestoration" /* UseScrollRestoration */
8842
8767
  );
8843
8768
  let { basename } = React10.useContext(NavigationContext);
8844
- let location2 = useLocation();
8769
+ let location = useLocation();
8845
8770
  let matches = useMatches();
8846
8771
  let navigation = useNavigation();
8847
8772
  React10.useEffect(() => {
@@ -8853,7 +8778,7 @@ function useScrollRestoration({
8853
8778
  usePageHide(
8854
8779
  React10.useCallback(() => {
8855
8780
  if (navigation.state === "idle") {
8856
- let key = getScrollRestorationKey(location2, matches, basename, getKey);
8781
+ let key = getScrollRestorationKey(location, matches, basename, getKey);
8857
8782
  savedScrollPositions[key] = window.scrollY;
8858
8783
  }
8859
8784
  try {
@@ -8868,7 +8793,7 @@ function useScrollRestoration({
8868
8793
  );
8869
8794
  }
8870
8795
  window.history.scrollRestoration = "auto";
8871
- }, [navigation.state, getKey, basename, location2, matches, storageKey])
8796
+ }, [navigation.state, getKey, basename, location, matches, storageKey])
8872
8797
  );
8873
8798
  if (typeof document !== "undefined") {
8874
8799
  React10.useLayoutEffect(() => {
@@ -8886,7 +8811,7 @@ function useScrollRestoration({
8886
8811
  let disableScrollRestoration = router?.enableScrollRestoration(
8887
8812
  savedScrollPositions,
8888
8813
  () => window.scrollY,
8889
- getKey ? (location3, matches2) => getScrollRestorationKey(location3, matches2, basename, getKey) : void 0
8814
+ getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
8890
8815
  );
8891
8816
  return () => disableScrollRestoration && disableScrollRestoration();
8892
8817
  }, [router, basename, getKey]);
@@ -8898,9 +8823,9 @@ function useScrollRestoration({
8898
8823
  window.scrollTo(0, restoreScrollPosition);
8899
8824
  return;
8900
8825
  }
8901
- if (location2.hash) {
8826
+ if (location.hash) {
8902
8827
  let el = document.getElementById(
8903
- decodeURIComponent(location2.hash.slice(1))
8828
+ decodeURIComponent(location.hash.slice(1))
8904
8829
  );
8905
8830
  if (el) {
8906
8831
  el.scrollIntoView();
@@ -8911,7 +8836,7 @@ function useScrollRestoration({
8911
8836
  return;
8912
8837
  }
8913
8838
  window.scrollTo(0, 0);
8914
- }, [location2, restoreScrollPosition, preventScrollReset]);
8839
+ }, [location, restoreScrollPosition, preventScrollReset]);
8915
8840
  }
8916
8841
  }
8917
8842
  function useBeforeUnload(callback, options) {
@@ -8984,7 +8909,7 @@ function StaticRouter({
8984
8909
  locationProp = parsePath(locationProp);
8985
8910
  }
8986
8911
  let action = "POP" /* Pop */;
8987
- let location2 = {
8912
+ let location = {
8988
8913
  pathname: locationProp.pathname || "/",
8989
8914
  search: locationProp.search || "",
8990
8915
  hash: locationProp.hash || "",
@@ -8997,7 +8922,7 @@ function StaticRouter({
8997
8922
  {
8998
8923
  basename,
8999
8924
  children,
9000
- location: location2,
8925
+ location,
9001
8926
  navigationType: action,
9002
8927
  navigator: staticNavigator,
9003
8928
  static: true
@@ -9216,9 +9141,6 @@ function createStaticRouter(routes, context, opts = {}) {
9216
9141
  _internalFetchControllers: /* @__PURE__ */ new Map(),
9217
9142
  _internalSetRoutes() {
9218
9143
  throw msg("_internalSetRoutes");
9219
- },
9220
- _internalSetStateDoNotUseOrYouWillBreakYourApp() {
9221
- throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
9222
9144
  }
9223
9145
  };
9224
9146
  }
@@ -9746,6 +9668,26 @@ function invariant3(value, message) {
9746
9668
  }
9747
9669
  }
9748
9670
 
9671
+ // lib/server-runtime/dev.ts
9672
+ var globalDevServerHooksKey = "__reactRouterDevServerHooks";
9673
+ function setDevServerHooks(devServerHooks) {
9674
+ globalThis[globalDevServerHooksKey] = devServerHooks;
9675
+ }
9676
+ function getDevServerHooks() {
9677
+ return globalThis[globalDevServerHooksKey];
9678
+ }
9679
+ function getBuildTimeHeader(request, headerName) {
9680
+ if (typeof process !== "undefined") {
9681
+ try {
9682
+ if (process.env?.IS_RR_BUILD_REQUEST === "yes") {
9683
+ return request.headers.get(headerName);
9684
+ }
9685
+ } catch (e) {
9686
+ }
9687
+ }
9688
+ return null;
9689
+ }
9690
+
9749
9691
  // lib/server-runtime/routes.ts
9750
9692
  function groupRoutesByParentId2(manifest) {
9751
9693
  let routes = {};
@@ -9777,10 +9719,11 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
9777
9719
  // Need to use RR's version in the param typed here to permit the optional
9778
9720
  // context even though we know it'll always be provided in remix
9779
9721
  loader: route.module.loader ? async (args) => {
9780
- if (args.request.headers.has("X-React-Router-Prerender-Data")) {
9781
- const preRenderedData = args.request.headers.get(
9782
- "X-React-Router-Prerender-Data"
9783
- );
9722
+ let preRenderedData = getBuildTimeHeader(
9723
+ args.request,
9724
+ "X-React-Router-Prerender-Data"
9725
+ );
9726
+ if (preRenderedData != null) {
9784
9727
  let encoded = preRenderedData ? decodeURI(preRenderedData) : preRenderedData;
9785
9728
  invariant3(encoded, "Missing prerendered data for route");
9786
9729
  let uint8array = new TextEncoder().encode(encoded);
@@ -9855,21 +9798,12 @@ function createServerHandoffString(serverHandoff) {
9855
9798
  return escapeHtml2(JSON.stringify(serverHandoff));
9856
9799
  }
9857
9800
 
9858
- // lib/server-runtime/dev.ts
9859
- var globalDevServerHooksKey = "__reactRouterDevServerHooks";
9860
- function setDevServerHooks(devServerHooks) {
9861
- globalThis[globalDevServerHooksKey] = devServerHooks;
9862
- }
9863
- function getDevServerHooks() {
9864
- return globalThis[globalDevServerHooksKey];
9865
- }
9866
-
9867
9801
  // lib/server-runtime/single-fetch.ts
9868
9802
  var import_turbo_stream2 = require("turbo-stream");
9869
9803
 
9870
9804
  // lib/server-runtime/headers.ts
9871
9805
  var import_set_cookie_parser = require("set-cookie-parser");
9872
- function getDocumentHeaders(context, getRouteHeadersFn) {
9806
+ function getDocumentHeaders(build, context) {
9873
9807
  let boundaryIdx = context.errors ? context.matches.findIndex((m) => context.errors[m.route.id]) : -1;
9874
9808
  let matches = boundaryIdx >= 0 ? context.matches.slice(0, boundaryIdx + 1) : context.matches;
9875
9809
  let errorHeaders;
@@ -9887,12 +9821,14 @@ function getDocumentHeaders(context, getRouteHeadersFn) {
9887
9821
  }
9888
9822
  return matches.reduce((parentHeaders, match, idx) => {
9889
9823
  let { id } = match.route;
9824
+ let route = build.routes[id];
9825
+ invariant3(route, `Route with id "${id}" not found in build`);
9826
+ let routeModule = route.module;
9890
9827
  let loaderHeaders = context.loaderHeaders[id] || new Headers();
9891
9828
  let actionHeaders = context.actionHeaders[id] || new Headers();
9892
9829
  let includeErrorHeaders = errorHeaders != null && idx === matches.length - 1;
9893
9830
  let includeErrorCookies = includeErrorHeaders && errorHeaders !== loaderHeaders && errorHeaders !== actionHeaders;
9894
- let headersFn = getRouteHeadersFn(match);
9895
- if (headersFn == null) {
9831
+ if (routeModule.headers == null) {
9896
9832
  let headers2 = new Headers(parentHeaders);
9897
9833
  if (includeErrorCookies) {
9898
9834
  prependCookies(errorHeaders, headers2);
@@ -9902,12 +9838,12 @@ function getDocumentHeaders(context, getRouteHeadersFn) {
9902
9838
  return headers2;
9903
9839
  }
9904
9840
  let headers = new Headers(
9905
- typeof headersFn === "function" ? headersFn({
9841
+ routeModule.headers ? typeof routeModule.headers === "function" ? routeModule.headers({
9906
9842
  loaderHeaders,
9907
9843
  parentHeaders,
9908
9844
  actionHeaders,
9909
9845
  errorHeaders: includeErrorHeaders ? errorHeaders : void 0
9910
- }) : headersFn
9846
+ }) : routeModule.headers : void 0
9911
9847
  );
9912
9848
  if (includeErrorCookies) {
9913
9849
  prependCookies(errorHeaders, headers);
@@ -9932,7 +9868,6 @@ function prependCookies(parentHeaders, childHeaders) {
9932
9868
  }
9933
9869
 
9934
9870
  // lib/server-runtime/single-fetch.ts
9935
- var SINGLE_FETCH_REDIRECT_STATUS = 202;
9936
9871
  var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
9937
9872
  ...NO_BODY_STATUS_CODES,
9938
9873
  304
@@ -9940,10 +9875,7 @@ var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
9940
9875
  async function singleFetchAction(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
9941
9876
  try {
9942
9877
  let respond2 = function(context) {
9943
- let headers = getDocumentHeaders(
9944
- context,
9945
- (m) => build.routes[m.route.id]?.module.headers
9946
- );
9878
+ let headers = getDocumentHeaders(build, context);
9947
9879
  if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
9948
9880
  return generateSingleFetchResponse(request, build, serverMode, {
9949
9881
  result: getSingleFetchRedirect(
@@ -10018,10 +9950,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
10018
9950
  async function singleFetchLoaders(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
10019
9951
  try {
10020
9952
  let respond2 = function(context) {
10021
- let headers = getDocumentHeaders(
10022
- context,
10023
- (m) => build.routes[m.route.id]?.module.headers
10024
- );
9953
+ let headers = getDocumentHeaders(build, context);
10025
9954
  if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
10026
9955
  return generateSingleFetchResponse(request, build, serverMode, {
10027
9956
  result: {
@@ -10277,9 +10206,10 @@ Error: ${e instanceof Error ? e.toString() : e}`
10277
10206
  if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
10278
10207
  normalizedPath = normalizedPath.slice(0, -1);
10279
10208
  }
10209
+ let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
10280
10210
  if (!_build.ssr) {
10281
10211
  if (_build.prerender.length === 0) {
10282
- request.headers.set("X-React-Router-SPA-Mode", "yes");
10212
+ isSpaMode = true;
10283
10213
  } else if (!_build.prerender.includes(normalizedPath) && !_build.prerender.includes(normalizedPath + "/")) {
10284
10214
  if (url.pathname.endsWith(".data")) {
10285
10215
  errorHandler(
@@ -10299,7 +10229,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
10299
10229
  statusText: "Not Found"
10300
10230
  });
10301
10231
  } else {
10302
- request.headers.set("X-React-Router-SPA-Mode", "yes");
10232
+ isSpaMode = true;
10303
10233
  }
10304
10234
  }
10305
10235
  }
@@ -10368,7 +10298,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
10368
10298
  );
10369
10299
  }
10370
10300
  }
10371
- } else if (!request.headers.has("X-React-Router-SPA-Mode") && matches && matches[matches.length - 1].route.module.default == null && matches[matches.length - 1].route.module.ErrorBoundary == null) {
10301
+ } else if (!isSpaMode && matches && matches[matches.length - 1].route.module.default == null && matches[matches.length - 1].route.module.ErrorBoundary == null) {
10372
10302
  response = await handleResourceRequest(
10373
10303
  serverMode,
10374
10304
  _build,
@@ -10393,6 +10323,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
10393
10323
  request,
10394
10324
  loadContext,
10395
10325
  handleError,
10326
+ isSpaMode,
10396
10327
  criticalCss
10397
10328
  );
10398
10329
  }
@@ -10468,8 +10399,7 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
10468
10399
  );
10469
10400
  return response;
10470
10401
  }
10471
- async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, criticalCss) {
10472
- let isSpaMode = request.headers.has("X-React-Router-SPA-Mode");
10402
+ async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, isSpaMode, criticalCss) {
10473
10403
  try {
10474
10404
  let response = await staticHandler.query(request, {
10475
10405
  requestContext: loadContext,
@@ -10484,10 +10414,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
10484
10414
  if (isResponse(context)) {
10485
10415
  return context;
10486
10416
  }
10487
- let headers = getDocumentHeaders(
10488
- context,
10489
- (m) => build.routes[m.route.id]?.module.headers
10490
- );
10417
+ let headers = getDocumentHeaders(build, context);
10491
10418
  if (SERVER_NO_BODY_STATUS_CODES.has(context.statusCode)) {
10492
10419
  return new Response(null, { status: context.statusCode, headers });
10493
10420
  }
@@ -10745,7 +10672,7 @@ function createSessionStorage({
10745
10672
  function warnOnceAboutSigningSessionCookie(cookie) {
10746
10673
  warnOnce(
10747
10674
  cookie.isSigned,
10748
- `The "${cookie.name}" cookie is not signed, but session cookies should be signed to prevent tampering on the client before they are sent back to the server. See https://remix.run/utils/cookies#signing-cookies for more information.`
10675
+ `The "${cookie.name}" cookie is not signed, but session cookies should be signed to prevent tampering on the client before they are sent back to the server. See https://reactrouter.com/explanation/sessions-and-cookies#signing-cookies for more information.`
10749
10676
  );
10750
10677
  }
10751
10678
 
@@ -10825,692 +10752,6 @@ function href(path, ...args) {
10825
10752
  }).filter((segment) => segment !== void 0).join("/");
10826
10753
  }
10827
10754
 
10828
- // lib/rsc/browser.tsx
10829
- var React14 = __toESM(require("react"));
10830
-
10831
- // lib/dom/ssr/hydration.tsx
10832
- function getHydrationData(state, routes, getRouteInfo, location2, basename, isSpaMode) {
10833
- let hydrationData = {
10834
- ...state,
10835
- loaderData: { ...state.loaderData }
10836
- };
10837
- let initialMatches = matchRoutes(routes, location2, basename);
10838
- if (initialMatches) {
10839
- for (let match of initialMatches) {
10840
- let routeId = match.route.id;
10841
- let routeInfo = getRouteInfo(routeId);
10842
- if (shouldHydrateRouteLoader(
10843
- routeId,
10844
- routeInfo.clientLoader,
10845
- routeInfo.hasLoader,
10846
- isSpaMode
10847
- ) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
10848
- delete hydrationData.loaderData[routeId];
10849
- } else if (!routeInfo.hasLoader) {
10850
- hydrationData.loaderData[routeId] = null;
10851
- }
10852
- }
10853
- }
10854
- return hydrationData;
10855
- }
10856
-
10857
- // lib/rsc/browser.tsx
10858
- function createCallServer({
10859
- decode: decode2,
10860
- encodeAction
10861
- }) {
10862
- let landedActionId = 0;
10863
- return async (id, args) => {
10864
- let actionId = window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
10865
- const response = await fetch(location.href, {
10866
- body: await encodeAction(args),
10867
- method: "POST",
10868
- headers: {
10869
- Accept: "text/x-component",
10870
- "rsc-action-id": id
10871
- }
10872
- });
10873
- if (!response.body) {
10874
- throw new Error("No response body");
10875
- }
10876
- const payload = await decode2(response.body);
10877
- if (payload.type !== "action") {
10878
- throw new Error("Unexpected payload type");
10879
- }
10880
- if (payload.rerender) {
10881
- (async () => {
10882
- const rerender = await payload.rerender;
10883
- if (!rerender) return;
10884
- if (landedActionId < actionId && window.__routerActionID <= actionId) {
10885
- landedActionId = actionId;
10886
- if (rerender.type === "redirect") {
10887
- if (rerender.reload) {
10888
- window.location.href = rerender.location;
10889
- return;
10890
- }
10891
- window.__router.navigate(rerender.location, {
10892
- replace: rerender.replace
10893
- });
10894
- return;
10895
- }
10896
- let lastMatch;
10897
- for (const match of rerender.matches) {
10898
- window.__router.patchRoutes(
10899
- lastMatch?.id ?? null,
10900
- [createRouteFromServerManifest(match)],
10901
- true
10902
- );
10903
- lastMatch = match;
10904
- }
10905
- window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({});
10906
- React14.startTransition(() => {
10907
- window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({
10908
- loaderData: Object.assign(
10909
- {},
10910
- window.__router.state.loaderData,
10911
- rerender.loaderData
10912
- ),
10913
- errors: rerender.errors ? Object.assign(
10914
- {},
10915
- window.__router.state.errors,
10916
- rerender.errors
10917
- ) : null
10918
- });
10919
- });
10920
- }
10921
- })();
10922
- }
10923
- return payload.actionResult;
10924
- };
10925
- }
10926
- function createRouterFromPayload({
10927
- decode: decode2,
10928
- payload
10929
- }) {
10930
- if (window.__router) return window.__router;
10931
- if (payload.type !== "render") throw new Error("Invalid payload type");
10932
- let patches = /* @__PURE__ */ new Map();
10933
- payload.patches?.forEach((patch) => {
10934
- invariant(patch.parentId, "Invalid patch parentId");
10935
- if (!patches.has(patch.parentId)) {
10936
- patches.set(patch.parentId, []);
10937
- }
10938
- patches.get(patch.parentId)?.push(patch);
10939
- });
10940
- let routes = payload.matches.reduceRight((previous, match) => {
10941
- const route = createRouteFromServerManifest(
10942
- match,
10943
- payload
10944
- );
10945
- if (previous.length > 0) {
10946
- route.children = previous;
10947
- let childrenToPatch = patches.get(match.id);
10948
- if (childrenToPatch) {
10949
- route.children.push(
10950
- ...childrenToPatch.map((r) => createRouteFromServerManifest(r))
10951
- );
10952
- }
10953
- }
10954
- return [route];
10955
- }, []);
10956
- window.__router = createRouter({
10957
- routes,
10958
- basename: payload.basename,
10959
- history: createBrowserHistory(),
10960
- hydrationData: getHydrationData(
10961
- {
10962
- loaderData: payload.loaderData,
10963
- actionData: payload.actionData,
10964
- errors: payload.errors
10965
- },
10966
- routes,
10967
- (routeId) => {
10968
- let match = payload.matches.find((m) => m.id === routeId);
10969
- invariant(match, "Route not found in payload");
10970
- return {
10971
- clientLoader: match.clientLoader,
10972
- hasLoader: match.hasLoader,
10973
- hasHydrateFallback: match.hydrateFallbackElement != null
10974
- };
10975
- },
10976
- payload.location,
10977
- void 0,
10978
- false
10979
- ),
10980
- async patchRoutesOnNavigation({ patch, path, signal }) {
10981
- let response = await fetch(`${path}.manifest`, { signal });
10982
- if (!response.body || response.status < 200 || response.status >= 300) {
10983
- throw new Error("Unable to fetch new route matches from the server");
10984
- }
10985
- let payload2 = await decode2(response.body);
10986
- if (payload2.type !== "manifest") {
10987
- throw new Error("Failed to patch routes on navigation");
10988
- }
10989
- payload2.matches.forEach(
10990
- (match, i) => patch(payload2.matches[i - 1]?.id ?? null, [
10991
- createRouteFromServerManifest(match)
10992
- ])
10993
- );
10994
- payload2.patches.forEach((p) => {
10995
- patch(p.parentId ?? null, [createRouteFromServerManifest(p)]);
10996
- });
10997
- },
10998
- // FIXME: Pass `build.ssr` and `build.basename` into this function
10999
- dataStrategy: getRSCSingleFetchDataStrategy(
11000
- () => window.__router,
11001
- true,
11002
- void 0,
11003
- decode2
11004
- )
11005
- });
11006
- if (window.__router.state.initialized) {
11007
- window.__routerInitialized = true;
11008
- window.__router.initialize();
11009
- } else {
11010
- window.__routerInitialized = false;
11011
- }
11012
- let lastLoaderData = void 0;
11013
- window.__router.subscribe(({ loaderData, actionData }) => {
11014
- if (lastLoaderData !== loaderData) {
11015
- window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
11016
- }
11017
- });
11018
- return window.__router;
11019
- }
11020
- var renderedRoutesContext = unstable_createContext();
11021
- function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, decode2) {
11022
- let dataStrategy = getSingleFetchDataStrategyImpl(
11023
- getRouter,
11024
- (match) => {
11025
- let M = match;
11026
- return {
11027
- hasLoader: M.route.hasLoader,
11028
- hasClientLoader: M.route.hasClientLoader,
11029
- hasAction: M.route.hasAction,
11030
- hasClientAction: M.route.hasClientAction,
11031
- hasShouldRevalidate: M.route.hasShouldRevalidate
11032
- };
11033
- },
11034
- // pass map into fetchAndDecode so it can add payloads
11035
- getFetchAndDecodeViaRSC(decode2),
11036
- ssr,
11037
- basename
11038
- );
11039
- return async (args) => args.unstable_runClientMiddleware(async () => {
11040
- let context = args.context;
11041
- context.set(renderedRoutesContext, []);
11042
- let results = await dataStrategy(args);
11043
- const renderedRouteById = new Map(
11044
- context.get(renderedRoutesContext).map((r) => [r.id, r])
11045
- );
11046
- for (const match of args.matches) {
11047
- const rendered = renderedRouteById.get(match.route.id);
11048
- if (rendered) {
11049
- window.__router.patchRoutes(
11050
- rendered.parentId ?? null,
11051
- [createRouteFromServerManifest(rendered)],
11052
- true
11053
- );
11054
- }
11055
- }
11056
- return results;
11057
- });
11058
- }
11059
- function getFetchAndDecodeViaRSC(decode2) {
11060
- return async (args, basename, targetRoutes) => {
11061
- let { request, context } = args;
11062
- let url = singleFetchUrl(request.url, basename, "rsc");
11063
- if (request.method === "GET") {
11064
- url = stripIndexParam(url);
11065
- if (targetRoutes) {
11066
- url.searchParams.set("_routes", targetRoutes.join(","));
11067
- }
11068
- }
11069
- let res = await fetch(url, await createRequestInit(request));
11070
- if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
11071
- throw new ErrorResponseImpl(404, "Not Found", true);
11072
- }
11073
- invariant(res.body, "No response body to decode");
11074
- try {
11075
- const payload = await decode2(res.body);
11076
- if (payload.type === "redirect") {
11077
- return {
11078
- status: res.status,
11079
- data: {
11080
- redirect: {
11081
- redirect: payload.location,
11082
- reload: false,
11083
- replace: payload.replace,
11084
- revalidate: false,
11085
- status: payload.status
11086
- }
11087
- }
11088
- };
11089
- }
11090
- if (payload.type !== "render") {
11091
- throw new Error("Unexpected payload type");
11092
- }
11093
- context.get(renderedRoutesContext).push(...payload.matches);
11094
- let results = { routes: {} };
11095
- const dataKey = isMutationMethod(request.method) ? "actionData" : "loaderData";
11096
- for (let [routeId, data2] of Object.entries(payload[dataKey] || {})) {
11097
- results.routes[routeId] = { data: data2 };
11098
- }
11099
- if (payload.errors) {
11100
- for (let [routeId, error] of Object.entries(payload.errors)) {
11101
- results.routes[routeId] = { error };
11102
- }
11103
- }
11104
- return { status: res.status, data: results };
11105
- } catch (e) {
11106
- throw new Error("Unable to decode RSC response");
11107
- }
11108
- };
11109
- }
11110
- function RSCHydratedRouter({
11111
- decode: decode2,
11112
- payload
11113
- }) {
11114
- if (payload.type !== "render") throw new Error("Invalid payload type");
11115
- let router = React14.useMemo(
11116
- () => createRouterFromPayload({ decode: decode2, payload }),
11117
- // eslint-disable-next-line react-hooks/exhaustive-deps
11118
- []
11119
- );
11120
- React14.useLayoutEffect(() => {
11121
- if (!window.__routerInitialized) {
11122
- window.__routerInitialized = true;
11123
- window.__router.initialize();
11124
- }
11125
- }, []);
11126
- const frameworkContext = {
11127
- future: {
11128
- // These flags have no runtime impact so can always be false. If we add
11129
- // flags that drive runtime behavior they'll need to be proxied through.
11130
- unstable_middleware: false,
11131
- unstable_subResourceIntegrity: false
11132
- },
11133
- isSpaMode: true,
11134
- ssr: true,
11135
- criticalCss: "",
11136
- manifest: {
11137
- routes: {},
11138
- version: "1",
11139
- url: "",
11140
- entry: {
11141
- module: "",
11142
- imports: []
11143
- }
11144
- },
11145
- routeModules: {}
11146
- };
11147
- return /* @__PURE__ */ React14.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React14.createElement(RouterProvider, { router }));
11148
- }
11149
- function createRouteFromServerManifest(match, payload) {
11150
- let hasInitialData = payload && match.id in payload.loaderData;
11151
- let initialData = payload?.loaderData[match.id];
11152
- let hasInitialError = payload?.errors && match.id in payload.errors;
11153
- let initialError = payload?.errors?.[match.id];
11154
- let isHydrationRequest = match.clientLoader?.hydrate === true || !match.hasLoader;
11155
- let dataRoute = {
11156
- id: match.id,
11157
- element: match.element,
11158
- errorElement: match.errorElement,
11159
- handle: match.handle,
11160
- hasErrorBoundary: match.hasErrorBoundary,
11161
- hydrateFallbackElement: match.hydrateFallbackElement,
11162
- index: match.index,
11163
- loader: match.clientLoader ? async (args, singleFetch) => {
11164
- try {
11165
- let result = await match.clientLoader({
11166
- ...args,
11167
- serverLoader: () => {
11168
- preventInvalidServerHandlerCall2(
11169
- "loader",
11170
- match.id,
11171
- match.hasLoader
11172
- );
11173
- if (isHydrationRequest) {
11174
- if (hasInitialData) {
11175
- return initialData;
11176
- }
11177
- if (hasInitialError) {
11178
- throw initialError;
11179
- }
11180
- }
11181
- return callSingleFetch(singleFetch);
11182
- }
11183
- });
11184
- return result;
11185
- } finally {
11186
- isHydrationRequest = false;
11187
- }
11188
- } : (
11189
- // We always make the call in this RSC world since even if we don't
11190
- // have a `loader` we may need to get the `element` implementation
11191
- (_, singleFetch) => callSingleFetch(singleFetch)
11192
- ),
11193
- action: match.clientAction ? (args, singleFetch) => match.clientAction({
11194
- ...args,
11195
- serverAction: async () => {
11196
- preventInvalidServerHandlerCall2(
11197
- "loader",
11198
- match.id,
11199
- match.hasLoader
11200
- );
11201
- return await callSingleFetch(singleFetch);
11202
- }
11203
- }) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : void 0,
11204
- path: match.path,
11205
- shouldRevalidate: match.shouldRevalidate,
11206
- // We always have a "loader" in this RSC world since even if we don't
11207
- // have a `loader` we may need to get the `element` implementation
11208
- hasLoader: true,
11209
- hasClientLoader: match.clientLoader != null,
11210
- hasAction: match.hasAction,
11211
- hasClientAction: match.clientAction != null,
11212
- hasShouldRevalidate: match.shouldRevalidate != null
11213
- };
11214
- if (typeof dataRoute.loader === "function") {
11215
- dataRoute.loader.hydrate = shouldHydrateRouteLoader(
11216
- match.id,
11217
- match.clientLoader,
11218
- match.hasLoader,
11219
- false
11220
- );
11221
- }
11222
- return dataRoute;
11223
- }
11224
- function callSingleFetch(singleFetch) {
11225
- invariant(typeof singleFetch === "function", "Invalid singleFetch parameter");
11226
- return singleFetch();
11227
- }
11228
- function preventInvalidServerHandlerCall2(type, routeId, hasHandler) {
11229
- if (!hasHandler) {
11230
- let fn = type === "action" ? "serverAction()" : "serverLoader()";
11231
- let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${routeId}")`;
11232
- console.error(msg);
11233
- throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
11234
- }
11235
- }
11236
-
11237
- // lib/rsc/server.ssr.tsx
11238
- var React15 = __toESM(require("react"));
11239
-
11240
- // lib/rsc/html-stream/server.ts
11241
- var encoder2 = new TextEncoder();
11242
- var trailer = "</body></html>";
11243
- function injectRSCPayload(rscStream) {
11244
- let decoder = new TextDecoder();
11245
- let resolveFlightDataPromise;
11246
- let flightDataPromise = new Promise(
11247
- (resolve) => resolveFlightDataPromise = resolve
11248
- );
11249
- let startedRSC = false;
11250
- let buffered = [];
11251
- let timeout = null;
11252
- function flushBufferedChunks(controller) {
11253
- for (let chunk of buffered) {
11254
- let buf = decoder.decode(chunk, { stream: true });
11255
- if (buf.endsWith(trailer)) {
11256
- buf = buf.slice(0, -trailer.length);
11257
- }
11258
- controller.enqueue(encoder2.encode(buf));
11259
- }
11260
- buffered.length = 0;
11261
- timeout = null;
11262
- }
11263
- return new TransformStream({
11264
- transform(chunk, controller) {
11265
- buffered.push(chunk);
11266
- if (timeout) {
11267
- return;
11268
- }
11269
- timeout = setTimeout(async () => {
11270
- flushBufferedChunks(controller);
11271
- if (!startedRSC) {
11272
- startedRSC = true;
11273
- writeRSCStream(rscStream, controller).catch((err) => controller.error(err)).then(resolveFlightDataPromise);
11274
- }
11275
- }, 0);
11276
- },
11277
- async flush(controller) {
11278
- await flightDataPromise;
11279
- if (timeout) {
11280
- clearTimeout(timeout);
11281
- flushBufferedChunks(controller);
11282
- }
11283
- controller.enqueue(encoder2.encode("</body></html>"));
11284
- }
11285
- });
11286
- }
11287
- async function writeRSCStream(rscStream, controller) {
11288
- let decoder = new TextDecoder("utf-8", { fatal: true });
11289
- const reader = rscStream.getReader();
11290
- try {
11291
- let read;
11292
- while ((read = await reader.read()) && !read.done) {
11293
- const chunk = read.value;
11294
- try {
11295
- writeChunk(
11296
- JSON.stringify(decoder.decode(chunk, { stream: true })),
11297
- controller
11298
- );
11299
- } catch (err) {
11300
- let base64 = JSON.stringify(btoa(String.fromCodePoint(...chunk)));
11301
- writeChunk(
11302
- `Uint8Array.from(atob(${base64}), m => m.codePointAt(0))`,
11303
- controller
11304
- );
11305
- }
11306
- }
11307
- } finally {
11308
- reader.releaseLock();
11309
- }
11310
- let remaining = decoder.decode();
11311
- if (remaining.length) {
11312
- writeChunk(JSON.stringify(remaining), controller);
11313
- }
11314
- }
11315
- function writeChunk(chunk, controller) {
11316
- controller.enqueue(
11317
- encoder2.encode(
11318
- `<script>${escapeScript(
11319
- `(self.__FLIGHT_DATA||=[]).push(${chunk})`
11320
- )}</script>`
11321
- )
11322
- );
11323
- }
11324
- function escapeScript(script) {
11325
- return script.replace(/<!--/g, "<\\!--").replace(/<\/(script)/gi, "</\\$1");
11326
- }
11327
-
11328
- // lib/rsc/server.ssr.tsx
11329
- async function routeRSCServerRequest(request, requestServer, decode2, renderHTML) {
11330
- const url = new URL(request.url);
11331
- let serverRequest = request;
11332
- const isDataRequest = isReactServerRequest(url);
11333
- const respondWithRSCPayload = isDataRequest || isManifestRequest(url) || request.headers.has("rsc-action-id");
11334
- if (isDataRequest) {
11335
- const serverURL = new URL(request.url);
11336
- serverURL.pathname = serverURL.pathname.replace(/(_root)?\.rsc$/, "");
11337
- let headers = new Headers(request.headers);
11338
- headers.set("X-React-Router-Data-Request", "true");
11339
- serverRequest = new Request(serverURL, {
11340
- body: request.body,
11341
- duplex: request.body ? "half" : void 0,
11342
- headers,
11343
- method: request.method,
11344
- signal: request.signal
11345
- });
11346
- }
11347
- const serverResponse = await requestServer(serverRequest);
11348
- if (respondWithRSCPayload) {
11349
- return serverResponse;
11350
- }
11351
- if (!serverResponse.body) {
11352
- throw new Error("Missing body in server response");
11353
- }
11354
- const serverResponseB = serverResponse.clone();
11355
- if (!serverResponseB.body) {
11356
- throw new Error("Failed to clone server response");
11357
- }
11358
- const body = serverResponse.body;
11359
- let payloadPromise;
11360
- const getPayload = async () => {
11361
- if (payloadPromise) return payloadPromise;
11362
- payloadPromise = decode2(body);
11363
- return payloadPromise;
11364
- };
11365
- try {
11366
- const html = await renderHTML(getPayload);
11367
- const body2 = html.pipeThrough(injectRSCPayload(serverResponseB.body));
11368
- const headers = new Headers(serverResponse.headers);
11369
- headers.set("Content-Type", "text/html");
11370
- return new Response(body2, {
11371
- status: serverResponse.status,
11372
- headers
11373
- });
11374
- } catch (reason) {
11375
- if (reason instanceof Response) {
11376
- return reason;
11377
- }
11378
- throw reason;
11379
- }
11380
- }
11381
- function RSCStaticRouter({
11382
- getPayload
11383
- }) {
11384
- const payload = React15.use(getPayload());
11385
- if (payload.type === "redirect") {
11386
- throw new Response(null, {
11387
- status: payload.status,
11388
- headers: {
11389
- Location: payload.location
11390
- }
11391
- });
11392
- }
11393
- if (payload.type !== "render") return null;
11394
- const context = {
11395
- actionData: payload.actionData,
11396
- actionHeaders: {},
11397
- basename: payload.basename,
11398
- errors: payload.errors,
11399
- loaderData: payload.loaderData,
11400
- loaderHeaders: {},
11401
- location: payload.location,
11402
- statusCode: 200,
11403
- matches: payload.matches.map((match) => ({
11404
- params: match.params,
11405
- pathname: match.pathname,
11406
- pathnameBase: match.pathnameBase,
11407
- route: {
11408
- id: match.id,
11409
- action: match.hasAction || !!match.clientAction,
11410
- handle: match.handle,
11411
- hasErrorBoundary: match.hasErrorBoundary,
11412
- loader: match.hasLoader || !!match.clientLoader,
11413
- index: match.index,
11414
- path: match.path,
11415
- shouldRevalidate: match.shouldRevalidate
11416
- }
11417
- }))
11418
- };
11419
- const router = createStaticRouter(
11420
- payload.matches.reduceRight((previous, match) => {
11421
- const route = {
11422
- id: match.id,
11423
- action: match.hasAction || !!match.clientAction,
11424
- element: match.element,
11425
- errorElement: match.errorElement,
11426
- handle: match.handle,
11427
- hasErrorBoundary: !!match.errorElement,
11428
- hydrateFallbackElement: match.hydrateFallbackElement,
11429
- index: match.index,
11430
- loader: match.hasLoader || !!match.clientLoader,
11431
- path: match.path,
11432
- shouldRevalidate: match.shouldRevalidate
11433
- };
11434
- if (previous.length > 0) {
11435
- route.children = previous;
11436
- }
11437
- return [route];
11438
- }, []),
11439
- context
11440
- );
11441
- const frameworkContext = {
11442
- future: {
11443
- // These flags have no runtime impact so can always be false. If we add
11444
- // flags that drive runtime behavior they'll need to be proxied through.
11445
- unstable_middleware: false,
11446
- unstable_subResourceIntegrity: false
11447
- },
11448
- isSpaMode: false,
11449
- ssr: true,
11450
- criticalCss: "",
11451
- manifest: {
11452
- routes: {},
11453
- version: "1",
11454
- url: "",
11455
- entry: {
11456
- module: "",
11457
- imports: []
11458
- }
11459
- },
11460
- routeModules: {}
11461
- };
11462
- return /* @__PURE__ */ React15.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React15.createElement(
11463
- StaticRouterProvider,
11464
- {
11465
- context,
11466
- router,
11467
- hydrate: false,
11468
- nonce: payload.nonce
11469
- }
11470
- ));
11471
- }
11472
- function isReactServerRequest(url) {
11473
- return url.pathname.endsWith(".rsc");
11474
- }
11475
- function isManifestRequest(url) {
11476
- return url.pathname.endsWith(".manifest");
11477
- }
11478
-
11479
- // lib/rsc/html-stream/browser.ts
11480
- function getServerStream() {
11481
- let encoder3 = new TextEncoder();
11482
- let streamController = null;
11483
- let rscStream = new ReadableStream({
11484
- start(controller) {
11485
- if (typeof window === "undefined") {
11486
- return;
11487
- }
11488
- let handleChunk = (chunk) => {
11489
- if (typeof chunk === "string") {
11490
- controller.enqueue(encoder3.encode(chunk));
11491
- } else {
11492
- controller.enqueue(chunk);
11493
- }
11494
- };
11495
- window.__FLIGHT_DATA || (window.__FLIGHT_DATA = []);
11496
- window.__FLIGHT_DATA.forEach(handleChunk);
11497
- window.__FLIGHT_DATA.push = (chunk) => {
11498
- handleChunk(chunk);
11499
- return 0;
11500
- };
11501
- streamController = controller;
11502
- }
11503
- });
11504
- if (typeof document !== "undefined" && document.readyState === "loading") {
11505
- document.addEventListener("DOMContentLoaded", () => {
11506
- streamController?.close();
11507
- });
11508
- } else {
11509
- streamController?.close();
11510
- }
11511
- return rscStream;
11512
- }
11513
-
11514
10755
  // lib/dom/ssr/errors.ts
11515
10756
  function deserializeErrors2(errors) {
11516
10757
  if (!errors) return null;
@@ -11547,6 +10788,32 @@ function deserializeErrors2(errors) {
11547
10788
  }
11548
10789
  return serialized;
11549
10790
  }
10791
+
10792
+ // lib/dom/ssr/hydration.tsx
10793
+ function getHydrationData(state, routes, getRouteInfo, location, basename, isSpaMode) {
10794
+ let hydrationData = {
10795
+ ...state,
10796
+ loaderData: { ...state.loaderData }
10797
+ };
10798
+ let initialMatches = matchRoutes(routes, location, basename);
10799
+ if (initialMatches) {
10800
+ for (let match of initialMatches) {
10801
+ let routeId = match.route.id;
10802
+ let routeInfo = getRouteInfo(routeId);
10803
+ if (shouldHydrateRouteLoader(
10804
+ routeId,
10805
+ routeInfo.clientLoader,
10806
+ routeInfo.hasLoader,
10807
+ isSpaMode
10808
+ ) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
10809
+ delete hydrationData.loaderData[routeId];
10810
+ } else if (!routeInfo.hasLoader) {
10811
+ hydrationData.loaderData[routeId] = null;
10812
+ }
10813
+ }
10814
+ }
10815
+ return hydrationData;
10816
+ }
11550
10817
  // Annotate the CommonJS export names for ESM import in node:
11551
10818
  0 && (module.exports = {
11552
10819
  Await,
@@ -11565,8 +10832,6 @@ function deserializeErrors2(errors) {
11565
10832
  NavigationType,
11566
10833
  Outlet,
11567
10834
  PrefetchPageLinks,
11568
- RSCHydratedRouter,
11569
- RSCStaticRouter,
11570
10835
  Route,
11571
10836
  Router,
11572
10837
  RouterProvider,
@@ -11588,9 +10853,6 @@ function deserializeErrors2(errors) {
11588
10853
  UNSAFE_ServerMode,
11589
10854
  UNSAFE_SingleFetchRedirectSymbol,
11590
10855
  UNSAFE_ViewTransitionContext,
11591
- UNSAFE_WithErrorBoundaryProps,
11592
- UNSAFE_WithHydrateFallbackProps,
11593
- UNSAFE_WithRouteComponentProps,
11594
10856
  UNSAFE_createBrowserHistory,
11595
10857
  UNSAFE_createClientRoutes,
11596
10858
  UNSAFE_createClientRoutesWithHMRRevalidationOptOut,
@@ -11607,7 +10869,6 @@ function deserializeErrors2(errors) {
11607
10869
  UNSAFE_useFogOFWarDiscovery,
11608
10870
  UNSAFE_useScrollRestoration,
11609
10871
  createBrowserRouter,
11610
- createCallServer,
11611
10872
  createCookie,
11612
10873
  createCookieSessionStorage,
11613
10874
  createHashRouter,
@@ -11625,7 +10886,6 @@ function deserializeErrors2(errors) {
11625
10886
  createStaticRouter,
11626
10887
  data,
11627
10888
  generatePath,
11628
- getServerStream,
11629
10889
  href,
11630
10890
  isCookie,
11631
10891
  isRouteErrorResponse,
@@ -11638,7 +10898,6 @@ function deserializeErrors2(errors) {
11638
10898
  renderMatches,
11639
10899
  replace,
11640
10900
  resolvePath,
11641
- routeRSCServerRequest,
11642
10901
  unstable_HistoryRouter,
11643
10902
  unstable_RouterContextProvider,
11644
10903
  unstable_createContext,