react-router 7.14.2 → 7.15.1

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 (72) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/dist/development/{browser-I6n6wVSO.d.mts → browser-3AnU12UI.d.mts} +2 -2
  3. package/dist/{production/browser-I6n6wVSO.d.mts → development/browser-BOdXz9dK.d.ts} +2 -2
  4. package/dist/development/{chunk-EVOBXE3Y.mjs → chunk-4N6VE7H7.mjs} +567 -317
  5. package/dist/{production/chunk-PQL4HLVQ.js → development/chunk-4YRVXM2U.js} +7 -7
  6. package/dist/{production/chunk-UJQ4OJF4.js → development/chunk-66UKHEGQ.js} +153 -143
  7. package/dist/development/{chunk-ZZNWZ5Q3.js → chunk-D6LUOGOQ.js} +550 -310
  8. package/dist/development/{chunk-YQSHRJWW.mjs → chunk-RJYABSBD.mjs} +100 -80
  9. package/dist/{production/context-DGGUoDIu.d.mts → development/context-ByvtofY2.d.mts} +100 -42
  10. package/dist/development/{routeModules-7rtk67cd.d.ts → data-BVUf681J.d.mts} +64 -46
  11. package/dist/development/{routeModules-BW4a8k3I.d.mts → data-BqZ2x964.d.ts} +64 -46
  12. package/dist/development/dom-export.d.mts +8 -8
  13. package/dist/development/dom-export.d.ts +8 -8
  14. package/dist/development/dom-export.js +57 -62
  15. package/dist/development/dom-export.mjs +32 -37
  16. package/dist/{production/index-react-server-client-BBd0A0TL.d.ts → development/index-react-server-client-BS5F89FR.d.ts} +132 -122
  17. package/dist/{production/index-react-server-client-BjhKIe3u.d.mts → development/index-react-server-client-DY04-103.d.mts} +111 -101
  18. package/dist/development/index-react-server-client.d.mts +3 -3
  19. package/dist/development/index-react-server-client.d.ts +3 -3
  20. package/dist/development/index-react-server-client.js +4 -4
  21. package/dist/development/index-react-server-client.mjs +2 -2
  22. package/dist/development/index-react-server.d.mts +113 -36
  23. package/dist/development/index-react-server.d.ts +113 -36
  24. package/dist/development/index-react-server.js +63 -36
  25. package/dist/development/index-react-server.mjs +63 -36
  26. package/dist/development/index.d.mts +94 -12
  27. package/dist/development/index.d.ts +94 -12
  28. package/dist/development/index.js +193 -171
  29. package/dist/development/index.mjs +5 -3
  30. package/dist/{production/instrumentation-g0dG8UL0.d.ts → development/instrumentation-cRWWLfsU.d.ts} +79 -21
  31. package/dist/development/lib/types/internal.d.mts +2 -2
  32. package/dist/development/lib/types/internal.d.ts +2 -2
  33. package/dist/development/lib/types/internal.js +1 -1
  34. package/dist/development/lib/types/internal.mjs +1 -1
  35. package/dist/development/{register-DcBltf5q.d.ts → register-Bsscfj79.d.ts} +1 -1
  36. package/dist/{production/register-DcBltf5q.d.ts → development/register-Df8okEea.d.mts} +1 -1
  37. package/dist/production/{browser-C-UvoYvi.d.ts → browser-3AnU12UI.d.mts} +2 -2
  38. package/dist/{development/browser-C-UvoYvi.d.ts → production/browser-BOdXz9dK.d.ts} +2 -2
  39. package/dist/production/{chunk-2WLZNCK5.mjs → chunk-6S4627ZB.mjs} +100 -80
  40. package/dist/production/{chunk-X5SKXJ4A.js → chunk-HUBUW7R3.js} +550 -310
  41. package/dist/production/{chunk-LK6U7ULH.mjs → chunk-JAKZPQZC.mjs} +567 -317
  42. package/dist/{development/chunk-YZKCRDTN.js → production/chunk-PNZCCTKT.js} +153 -143
  43. package/dist/{development/chunk-PZFPF4X7.js → production/chunk-Y6IFXO7V.js} +7 -7
  44. package/dist/{development/context-DGGUoDIu.d.mts → production/context-ByvtofY2.d.mts} +100 -42
  45. package/dist/production/{routeModules-7rtk67cd.d.ts → data-BVUf681J.d.mts} +64 -46
  46. package/dist/production/{routeModules-BW4a8k3I.d.mts → data-BqZ2x964.d.ts} +64 -46
  47. package/dist/production/dom-export.d.mts +8 -8
  48. package/dist/production/dom-export.d.ts +8 -8
  49. package/dist/production/dom-export.js +57 -62
  50. package/dist/production/dom-export.mjs +32 -37
  51. package/dist/{development/index-react-server-client-BBd0A0TL.d.ts → production/index-react-server-client-BS5F89FR.d.ts} +132 -122
  52. package/dist/{development/index-react-server-client-BjhKIe3u.d.mts → production/index-react-server-client-DY04-103.d.mts} +111 -101
  53. package/dist/production/index-react-server-client.d.mts +3 -3
  54. package/dist/production/index-react-server-client.d.ts +3 -3
  55. package/dist/production/index-react-server-client.js +4 -4
  56. package/dist/production/index-react-server-client.mjs +2 -2
  57. package/dist/production/index-react-server.d.mts +113 -36
  58. package/dist/production/index-react-server.d.ts +113 -36
  59. package/dist/production/index-react-server.js +63 -36
  60. package/dist/production/index-react-server.mjs +63 -36
  61. package/dist/production/index.d.mts +94 -12
  62. package/dist/production/index.d.ts +94 -12
  63. package/dist/production/index.js +193 -171
  64. package/dist/production/index.mjs +5 -3
  65. package/dist/{development/instrumentation-g0dG8UL0.d.ts → production/instrumentation-cRWWLfsU.d.ts} +79 -21
  66. package/dist/production/lib/types/internal.d.mts +2 -2
  67. package/dist/production/lib/types/internal.d.ts +2 -2
  68. package/dist/production/lib/types/internal.js +1 -1
  69. package/dist/production/lib/types/internal.mjs +1 -1
  70. package/dist/{development/register-D9d2sMQ7.d.mts → production/register-Bsscfj79.d.ts} +1 -1
  71. package/dist/production/{register-D9d2sMQ7.d.mts → register-Df8okEea.d.mts} +1 -1
  72. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.14.2
2
+ * react-router v7.15.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -14,6 +14,7 @@ var __typeError = (msg) => {
14
14
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
15
15
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
16
16
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
17
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
17
18
 
18
19
  // lib/router/history.ts
19
20
  var Action = /* @__PURE__ */ ((Action2) => {
@@ -34,7 +35,7 @@ function createMemoryHistory(options = {}) {
34
35
  entry,
35
36
  typeof entry === "string" ? null : entry.state,
36
37
  index2 === 0 ? "default" : void 0,
37
- typeof entry === "string" ? void 0 : entry.unstable_mask
38
+ typeof entry === "string" ? void 0 : entry.mask
38
39
  )
39
40
  );
40
41
  let index = clampIndex(
@@ -48,13 +49,13 @@ function createMemoryHistory(options = {}) {
48
49
  function getCurrentLocation() {
49
50
  return entries[index];
50
51
  }
51
- function createMemoryLocation(to, state = null, key, unstable_mask) {
52
+ function createMemoryLocation(to, state = null, key, mask) {
52
53
  let location = createLocation(
53
54
  entries ? getCurrentLocation().pathname : "/",
54
55
  to,
55
56
  state,
56
57
  key,
57
- unstable_mask
58
+ mask
58
59
  );
59
60
  warning(
60
61
  location.pathname.charAt(0) === "/",
@@ -216,14 +217,14 @@ function getHistoryState(location, index) {
216
217
  usr: location.state,
217
218
  key: location.key,
218
219
  idx: index,
219
- masked: location.unstable_mask ? {
220
+ masked: location.mask ? {
220
221
  pathname: location.pathname,
221
222
  search: location.search,
222
223
  hash: location.hash
223
224
  } : void 0
224
225
  };
225
226
  }
226
- function createLocation(current, to, state = null, key, unstable_mask) {
227
+ function createLocation(current, to, state = null, key, mask) {
227
228
  let location = {
228
229
  pathname: typeof current === "string" ? current : current.pathname,
229
230
  search: "",
@@ -235,7 +236,7 @@ function createLocation(current, to, state = null, key, unstable_mask) {
235
236
  // But that's a pretty big refactor to the current test suite so going to
236
237
  // keep as is for the time being and just let any incoming keys take precedence
237
238
  key: to && to.key || key || createKey(),
238
- unstable_mask
239
+ mask
239
240
  };
240
241
  return location;
241
242
  }
@@ -298,7 +299,7 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
298
299
  if (validateLocation) validateLocation(location, to);
299
300
  index = getIndex() + 1;
300
301
  let historyState = getHistoryState(location, index);
301
- let url = history.createHref(location.unstable_mask || location);
302
+ let url = history.createHref(location.mask || location);
302
303
  try {
303
304
  globalHistory.pushState(historyState, "", url);
304
305
  } catch (error) {
@@ -317,7 +318,7 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
317
318
  if (validateLocation) validateLocation(location, to);
318
319
  index = getIndex();
319
320
  let historyState = getHistoryState(location, index);
320
- let url = history.createHref(location.unstable_mask || location);
321
+ let url = history.createHref(location.mask || location);
321
322
  globalHistory.replaceState(historyState, "", url);
322
323
  if (v5Compat && listener) {
323
324
  listener({ action, location: history.location, delta: 0 });
@@ -515,17 +516,16 @@ function mergeRouteUpdates(route, updates) {
515
516
  function matchRoutes(routes, locationArg, basename = "/") {
516
517
  return matchRoutesImpl(routes, locationArg, basename, false);
517
518
  }
518
- function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
519
+ function matchRoutesImpl(routes, locationArg, basename, allowPartial, precomputedBranches) {
519
520
  let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
520
521
  let pathname = stripBasename(location.pathname || "/", basename);
521
522
  if (pathname == null) {
522
523
  return null;
523
524
  }
524
- let branches = flattenRoutes(routes);
525
- rankRouteBranches(branches);
525
+ let branches = precomputedBranches ?? flattenAndRankRoutes(routes);
526
526
  let matches = null;
527
+ let decoded = decodePath(pathname);
527
528
  for (let i = 0; matches == null && i < branches.length; ++i) {
528
- let decoded = decodePath(pathname);
529
529
  matches = matchRouteBranch(
530
530
  branches[i],
531
531
  decoded,
@@ -545,6 +545,11 @@ function convertRouteMatchToUiMatch(match, loaderData) {
545
545
  handle: route.handle
546
546
  };
547
547
  }
548
+ function flattenAndRankRoutes(routes) {
549
+ let branches = flattenRoutes(routes);
550
+ rankRouteBranches(branches);
551
+ return branches;
552
+ }
548
553
  function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
549
554
  let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
550
555
  let meta = {
@@ -1252,11 +1257,11 @@ async function recurseRight(impls, info, handler, index) {
1252
1257
  };
1253
1258
  }
1254
1259
  function getHandlerInfo(args) {
1255
- let { request, context, params, unstable_pattern } = args;
1260
+ let { request, context, params, pattern } = args;
1256
1261
  return {
1257
1262
  request: getReadonlyRequest(request),
1258
1263
  params: { ...params },
1259
- unstable_pattern,
1264
+ pattern,
1260
1265
  context: getReadonlyContext(context)
1261
1266
  };
1262
1267
  }
@@ -1318,6 +1323,8 @@ var redirectPreserveMethodStatusCodes = /* @__PURE__ */ new Set([307, 308]);
1318
1323
  var IDLE_NAVIGATION = {
1319
1324
  state: "idle",
1320
1325
  location: void 0,
1326
+ matches: void 0,
1327
+ historyAction: void 0,
1321
1328
  formMethod: void 0,
1322
1329
  formAction: void 0,
1323
1330
  formEncType: void 0,
@@ -1346,6 +1353,55 @@ var defaultMapRouteProperties = (route) => ({
1346
1353
  });
1347
1354
  var TRANSITIONS_STORAGE_KEY = "remix-router-transitions";
1348
1355
  var ResetLoaderDataSymbol = Symbol("ResetLoaderData");
1356
+ var _routes, _branches, _hmrRoutes, _hmrBranches;
1357
+ var DataRoutes = class {
1358
+ constructor(routes) {
1359
+ __privateAdd(this, _routes);
1360
+ __privateAdd(this, _branches);
1361
+ __privateAdd(this, _hmrRoutes);
1362
+ __privateAdd(this, _hmrBranches);
1363
+ __privateSet(this, _routes, routes);
1364
+ __privateSet(this, _branches, flattenAndRankRoutes(routes));
1365
+ }
1366
+ /** The stable route tree */
1367
+ get stableRoutes() {
1368
+ return __privateGet(this, _routes);
1369
+ }
1370
+ /** The in-flight route tree if one is active, otherwise the stable tree */
1371
+ get activeRoutes() {
1372
+ return __privateGet(this, _hmrRoutes) ?? __privateGet(this, _routes);
1373
+ }
1374
+ /** Pre-computed branches */
1375
+ get branches() {
1376
+ return __privateGet(this, _hmrBranches) ?? __privateGet(this, _branches);
1377
+ }
1378
+ get hasHMRRoutes() {
1379
+ return __privateGet(this, _hmrRoutes) != null;
1380
+ }
1381
+ /** Replace the stable route tree and recompute its branches */
1382
+ setRoutes(routes) {
1383
+ __privateSet(this, _routes, routes);
1384
+ __privateSet(this, _branches, flattenAndRankRoutes(routes));
1385
+ }
1386
+ /** Set a new in-flight route tree and recompute its branches */
1387
+ setHmrRoutes(routes) {
1388
+ __privateSet(this, _hmrRoutes, routes);
1389
+ __privateSet(this, _hmrBranches, flattenAndRankRoutes(routes));
1390
+ }
1391
+ /** Commit in-flight routes/branches to the stable slot and clear in-flight */
1392
+ commitHmrRoutes() {
1393
+ if (__privateGet(this, _hmrRoutes)) {
1394
+ __privateSet(this, _routes, __privateGet(this, _hmrRoutes));
1395
+ __privateSet(this, _branches, __privateGet(this, _hmrBranches));
1396
+ __privateSet(this, _hmrRoutes, void 0);
1397
+ __privateSet(this, _hmrBranches, void 0);
1398
+ }
1399
+ }
1400
+ };
1401
+ _routes = new WeakMap();
1402
+ _branches = new WeakMap();
1403
+ _hmrRoutes = new WeakMap();
1404
+ _hmrBranches = new WeakMap();
1349
1405
  function createRouter(init) {
1350
1406
  const routerWindow = init.window ? init.window : typeof window !== "undefined" ? window : void 0;
1351
1407
  const isBrowser3 = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined";
@@ -1356,8 +1412,8 @@ function createRouter(init) {
1356
1412
  let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
1357
1413
  let _mapRouteProperties = init.mapRouteProperties || defaultMapRouteProperties;
1358
1414
  let mapRouteProperties2 = _mapRouteProperties;
1359
- if (init.unstable_instrumentations) {
1360
- let instrumentations = init.unstable_instrumentations;
1415
+ if (init.instrumentations) {
1416
+ let instrumentations = init.instrumentations;
1361
1417
  mapRouteProperties2 = (route) => {
1362
1418
  return {
1363
1419
  ..._mapRouteProperties(route),
@@ -1369,29 +1425,36 @@ function createRouter(init) {
1369
1425
  };
1370
1426
  }
1371
1427
  let manifest = {};
1372
- let dataRoutes = convertRoutesToDataRoutes(
1373
- init.routes,
1374
- mapRouteProperties2,
1375
- void 0,
1376
- manifest
1428
+ let dataRoutes = new DataRoutes(
1429
+ convertRoutesToDataRoutes(
1430
+ init.routes,
1431
+ mapRouteProperties2,
1432
+ void 0,
1433
+ manifest
1434
+ )
1377
1435
  );
1378
- let inFlightDataRoutes;
1379
1436
  let basename = init.basename || "/";
1380
1437
  if (!basename.startsWith("/")) {
1381
1438
  basename = `/${basename}`;
1382
1439
  }
1383
1440
  let dataStrategyImpl = init.dataStrategy || defaultDataStrategyWithMiddleware;
1384
1441
  let future = {
1385
- unstable_passThroughRequests: false,
1386
1442
  ...init.future
1387
1443
  };
1388
1444
  let unlistenHistory = null;
1389
1445
  let subscribers = /* @__PURE__ */ new Set();
1446
+ let bufferedInitialStateUpdate = null;
1390
1447
  let savedScrollPositions2 = null;
1391
1448
  let getScrollRestorationKey2 = null;
1392
1449
  let getScrollPosition = null;
1393
1450
  let initialScrollRestored = init.hydrationData != null;
1394
- let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
1451
+ let initialMatches = matchRoutesImpl(
1452
+ dataRoutes.activeRoutes,
1453
+ init.history.location,
1454
+ basename,
1455
+ false,
1456
+ dataRoutes.branches
1457
+ );
1395
1458
  let initialMatchesIsFOW = false;
1396
1459
  let initialErrors = null;
1397
1460
  let initialized;
@@ -1400,7 +1463,7 @@ function createRouter(init) {
1400
1463
  let error = getInternalRouterError(404, {
1401
1464
  pathname: init.history.location.pathname
1402
1465
  });
1403
- let { matches, route } = getShortCircuitMatches(dataRoutes);
1466
+ let { matches, route } = getShortCircuitMatches(dataRoutes.activeRoutes);
1404
1467
  initialized = true;
1405
1468
  renderFallback = !initialized;
1406
1469
  initialMatches = matches;
@@ -1409,7 +1472,7 @@ function createRouter(init) {
1409
1472
  if (initialMatches && !init.hydrationData) {
1410
1473
  let fogOfWar = checkFogOfWar(
1411
1474
  initialMatches,
1412
- dataRoutes,
1475
+ dataRoutes.activeRoutes,
1413
1476
  init.history.location.pathname
1414
1477
  );
1415
1478
  if (fogOfWar.active) {
@@ -1422,7 +1485,7 @@ function createRouter(init) {
1422
1485
  initialMatches = [];
1423
1486
  let fogOfWar = checkFogOfWar(
1424
1487
  null,
1425
- dataRoutes,
1488
+ dataRoutes.activeRoutes,
1426
1489
  init.history.location.pathname
1427
1490
  );
1428
1491
  if (fogOfWar.active && fogOfWar.matches) {
@@ -1562,11 +1625,21 @@ function createRouter(init) {
1562
1625
  }
1563
1626
  subscribers.clear();
1564
1627
  pendingNavigationController && pendingNavigationController.abort();
1565
- state.fetchers.forEach((_, key) => deleteFetcher(key));
1628
+ state.fetchers.forEach((_, key) => deleteFetcher(state.fetchers, key));
1566
1629
  state.blockers.forEach((_, key) => deleteBlocker(key));
1567
1630
  }
1568
1631
  function subscribe(fn) {
1569
1632
  subscribers.add(fn);
1633
+ if (bufferedInitialStateUpdate) {
1634
+ let { newErrors } = bufferedInitialStateUpdate;
1635
+ bufferedInitialStateUpdate = null;
1636
+ fn(state, {
1637
+ deletedFetchers: [],
1638
+ newErrors,
1639
+ viewTransitionOpts: void 0,
1640
+ flushSync: false
1641
+ });
1642
+ }
1570
1643
  return () => subscribers.delete(fn);
1571
1644
  }
1572
1645
  function updateState(newState, opts = {}) {
@@ -1603,6 +1676,9 @@ function createRouter(init) {
1603
1676
  unmountedFetchers.push(key);
1604
1677
  }
1605
1678
  });
1679
+ if (subscribers.size === 0) {
1680
+ bufferedInitialStateUpdate = { newErrors: newState.errors ?? null };
1681
+ }
1606
1682
  [...subscribers].forEach(
1607
1683
  (subscriber) => subscriber(state, {
1608
1684
  deletedFetchers: unmountedFetchers,
@@ -1611,7 +1687,7 @@ function createRouter(init) {
1611
1687
  flushSync: opts.flushSync === true
1612
1688
  })
1613
1689
  );
1614
- unmountedFetchers.forEach((key) => deleteFetcher(key));
1690
+ unmountedFetchers.forEach((key) => deleteFetcher(state.fetchers, key));
1615
1691
  mountedFetchers.forEach((key) => state.fetchers.delete(key));
1616
1692
  }
1617
1693
  function completeNavigation(location, newState, { flushSync } = {}) {
@@ -1641,10 +1717,7 @@ function createRouter(init) {
1641
1717
  }
1642
1718
  let restoreScrollPosition = isUninterruptedRevalidation ? false : getSavedScrollPosition(location, newState.matches || state.matches);
1643
1719
  let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location.state?._isRedirect !== true;
1644
- if (inFlightDataRoutes) {
1645
- dataRoutes = inFlightDataRoutes;
1646
- inFlightDataRoutes = void 0;
1647
- }
1720
+ dataRoutes.commitHmrRoutes();
1648
1721
  if (isUninterruptedRevalidation) {
1649
1722
  } else if (pendingAction === "POP" /* Pop */) {
1650
1723
  } else if (pendingAction === "PUSH" /* Push */) {
@@ -1735,10 +1808,10 @@ function createRouter(init) {
1735
1808
  opts
1736
1809
  );
1737
1810
  let maskPath;
1738
- if (opts?.unstable_mask) {
1739
- let partialPath = typeof opts.unstable_mask === "string" ? parsePath(opts.unstable_mask) : {
1740
- ...state.location.unstable_mask,
1741
- ...opts.unstable_mask
1811
+ if (opts?.mask) {
1812
+ let partialPath = typeof opts.mask === "string" ? parsePath(opts.mask) : {
1813
+ ...state.location.mask,
1814
+ ...opts.mask
1742
1815
  };
1743
1816
  maskPath = {
1744
1817
  pathname: "",
@@ -1804,7 +1877,7 @@ function createRouter(init) {
1804
1877
  replace: opts && opts.replace,
1805
1878
  enableViewTransition: opts && opts.viewTransition,
1806
1879
  flushSync,
1807
- callSiteDefaultShouldRevalidate: opts && opts.unstable_defaultShouldRevalidate
1880
+ callSiteDefaultShouldRevalidate: opts && opts.defaultShouldRevalidate
1808
1881
  });
1809
1882
  }
1810
1883
  function revalidate() {
@@ -1842,12 +1915,17 @@ function createRouter(init) {
1842
1915
  saveScrollPosition(state.location, state.matches);
1843
1916
  pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;
1844
1917
  pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
1845
- let routesToUse = inFlightDataRoutes || dataRoutes;
1846
- let loadingNavigation = opts && opts.overrideNavigation;
1918
+ let routesToUse = dataRoutes.activeRoutes;
1847
1919
  let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
1848
1920
  // `matchRoutes()` has already been called if we're in here via `router.initialize()`
1849
1921
  state.matches
1850
- ) : matchRoutes(routesToUse, location, basename);
1922
+ ) : matchRoutesImpl(
1923
+ routesToUse,
1924
+ location,
1925
+ basename,
1926
+ false,
1927
+ dataRoutes.branches
1928
+ );
1851
1929
  let flushSync = (opts && opts.flushSync) === true;
1852
1930
  if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1853
1931
  completeNavigation(location, { matches }, { flushSync });
@@ -1874,6 +1952,11 @@ function createRouter(init) {
1874
1952
  );
1875
1953
  return;
1876
1954
  }
1955
+ let loadingNavigation = opts && opts.overrideNavigation ? {
1956
+ ...opts.overrideNavigation,
1957
+ matches,
1958
+ historyAction
1959
+ } : void 0;
1877
1960
  pendingNavigationController = new AbortController();
1878
1961
  let request = createClientSideRequest(
1879
1962
  init.history,
@@ -1894,6 +1977,7 @@ function createRouter(init) {
1894
1977
  location,
1895
1978
  opts.submission,
1896
1979
  matches,
1980
+ historyAction,
1897
1981
  scopedContext,
1898
1982
  fogOfWar.active,
1899
1983
  opts && opts.initialHydration === true,
@@ -1918,7 +2002,12 @@ function createRouter(init) {
1918
2002
  }
1919
2003
  matches = actionResult.matches || matches;
1920
2004
  pendingActionResult = actionResult.pendingActionResult;
1921
- loadingNavigation = getLoadingNavigation(location, opts.submission);
2005
+ loadingNavigation = getLoadingNavigation(
2006
+ location,
2007
+ matches,
2008
+ historyAction,
2009
+ opts.submission
2010
+ );
1922
2011
  flushSync = false;
1923
2012
  fogOfWar.active = false;
1924
2013
  request = createClientSideRequest(
@@ -1931,11 +2020,13 @@ function createRouter(init) {
1931
2020
  shortCircuited,
1932
2021
  matches: updatedMatches,
1933
2022
  loaderData,
1934
- errors
2023
+ errors,
2024
+ workingFetchers
1935
2025
  } = await handleLoaders(
1936
2026
  request,
1937
2027
  location,
1938
2028
  matches,
2029
+ historyAction,
1939
2030
  scopedContext,
1940
2031
  fogOfWar.active,
1941
2032
  loadingNavigation,
@@ -1955,12 +2046,18 @@ function createRouter(init) {
1955
2046
  matches: updatedMatches || matches,
1956
2047
  ...getActionDataForCommit(pendingActionResult),
1957
2048
  loaderData,
1958
- errors
2049
+ errors,
2050
+ ...workingFetchers ? { fetchers: workingFetchers } : {}
1959
2051
  });
1960
2052
  }
1961
- async function handleAction(request, location, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
2053
+ async function handleAction(request, location, submission, matches, historyAction, scopedContext, isFogOfWar, initialHydration, opts = {}) {
1962
2054
  interruptActiveLoads();
1963
- let navigation = getSubmittingNavigation(location, submission);
2055
+ let navigation = getSubmittingNavigation(
2056
+ location,
2057
+ matches,
2058
+ historyAction,
2059
+ submission
2060
+ );
1964
2061
  updateState({ navigation }, { flushSync: opts.flushSync === true });
1965
2062
  if (isFogOfWar) {
1966
2063
  let discoverResult = await discoverRoutes(
@@ -1972,7 +2069,9 @@ function createRouter(init) {
1972
2069
  return { shortCircuited: true };
1973
2070
  } else if (discoverResult.type === "error") {
1974
2071
  if (discoverResult.partialMatches.length === 0) {
1975
- let { matches: matches2, route } = getShortCircuitMatches(dataRoutes);
2072
+ let { matches: matches2, route } = getShortCircuitMatches(
2073
+ dataRoutes.activeRoutes
2074
+ );
1976
2075
  return {
1977
2076
  matches: matches2,
1978
2077
  pendingActionResult: [
@@ -2093,8 +2192,8 @@ function createRouter(init) {
2093
2192
  pendingActionResult: [actionMatch.route.id, result]
2094
2193
  };
2095
2194
  }
2096
- async function handleLoaders(request, location, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult, callSiteDefaultShouldRevalidate) {
2097
- let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
2195
+ async function handleLoaders(request, location, matches, historyAction, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult, callSiteDefaultShouldRevalidate) {
2196
+ let loadingNavigation = overrideNavigation || getLoadingNavigation(location, matches, historyAction, submission);
2098
2197
  let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
2099
2198
  let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
2100
2199
  if (isFogOfWar) {
@@ -2119,7 +2218,9 @@ function createRouter(init) {
2119
2218
  return { shortCircuited: true };
2120
2219
  } else if (discoverResult.type === "error") {
2121
2220
  if (discoverResult.partialMatches.length === 0) {
2122
- let { matches: matches2, route } = getShortCircuitMatches(dataRoutes);
2221
+ let { matches: matches2, route } = getShortCircuitMatches(
2222
+ dataRoutes.activeRoutes
2223
+ );
2123
2224
  return {
2124
2225
  matches: matches2,
2125
2226
  loaderData: {},
@@ -2151,7 +2252,7 @@ function createRouter(init) {
2151
2252
  matches = discoverResult.matches;
2152
2253
  }
2153
2254
  }
2154
- let routesToUse = inFlightDataRoutes || dataRoutes;
2255
+ let routesToUse = dataRoutes.activeRoutes;
2155
2256
  let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
2156
2257
  request,
2157
2258
  scopedContext,
@@ -2172,6 +2273,7 @@ function createRouter(init) {
2172
2273
  routesToUse,
2173
2274
  basename,
2174
2275
  init.patchRoutesOnNavigation != null,
2276
+ dataRoutes.branches,
2175
2277
  pendingActionResult,
2176
2278
  callSiteDefaultShouldRevalidate
2177
2279
  );
@@ -2179,7 +2281,8 @@ function createRouter(init) {
2179
2281
  if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && !dsMatches.some(
2180
2282
  (m) => m.route.middleware && m.route.middleware.length > 0
2181
2283
  ) && revalidatingFetchers.length === 0) {
2182
- let updatedFetchers2 = markFetchRedirectsDone();
2284
+ let workingFetchers2 = new Map(state.fetchers);
2285
+ let didUpdateFetcherRedirects2 = markFetchRedirectsDone(workingFetchers2);
2183
2286
  completeNavigation(
2184
2287
  location,
2185
2288
  {
@@ -2188,7 +2291,7 @@ function createRouter(init) {
2188
2291
  // Commit pending error if we're short circuiting
2189
2292
  errors: pendingActionResult && isErrorResult(pendingActionResult[1]) ? { [pendingActionResult[0]]: pendingActionResult[1].error } : null,
2190
2293
  ...getActionDataForCommit(pendingActionResult),
2191
- ...updatedFetchers2 ? { fetchers: new Map(state.fetchers) } : {}
2294
+ ...didUpdateFetcherRedirects2 ? { fetchers: workingFetchers2 } : {}
2192
2295
  },
2193
2296
  { flushSync }
2194
2297
  );
@@ -2253,25 +2356,30 @@ function createRouter(init) {
2253
2356
  });
2254
2357
  return { shortCircuited: true };
2255
2358
  }
2359
+ let workingFetchers = new Map(state.fetchers);
2256
2360
  let { loaderData, errors } = processLoaderData(
2257
2361
  state,
2258
2362
  matches,
2259
2363
  loaderResults,
2260
2364
  pendingActionResult,
2261
2365
  revalidatingFetchers,
2262
- fetcherResults
2366
+ fetcherResults,
2367
+ workingFetchers
2263
2368
  );
2264
2369
  if (initialHydration && state.errors) {
2265
2370
  errors = { ...state.errors, ...errors };
2266
2371
  }
2267
- let updatedFetchers = markFetchRedirectsDone();
2268
- let didAbortFetchLoads = abortStaleFetchLoads(pendingNavigationLoadId);
2269
- let shouldUpdateFetchers = updatedFetchers || didAbortFetchLoads || revalidatingFetchers.length > 0;
2372
+ let didUpdateFetcherRedirects = markFetchRedirectsDone(workingFetchers);
2373
+ let didAbortFetchLoads = abortStaleFetchLoads(
2374
+ pendingNavigationLoadId,
2375
+ workingFetchers
2376
+ );
2377
+ let shouldUpdateFetchers = didUpdateFetcherRedirects || didAbortFetchLoads || revalidatingFetchers.length > 0;
2270
2378
  return {
2271
2379
  matches,
2272
2380
  loaderData,
2273
2381
  errors,
2274
- ...shouldUpdateFetchers ? { fetchers: new Map(state.fetchers) } : {}
2382
+ ...shouldUpdateFetchers ? { workingFetchers } : {}
2275
2383
  };
2276
2384
  }
2277
2385
  function getUpdatedActionData(pendingActionResult) {
@@ -2288,20 +2396,21 @@ function createRouter(init) {
2288
2396
  }
2289
2397
  }
2290
2398
  function getUpdatedRevalidatingFetchers(revalidatingFetchers) {
2399
+ let workingFetchers = new Map(state.fetchers);
2291
2400
  revalidatingFetchers.forEach((rf) => {
2292
- let fetcher = state.fetchers.get(rf.key);
2401
+ let fetcher = workingFetchers.get(rf.key);
2293
2402
  let revalidatingFetcher = getLoadingFetcher(
2294
2403
  void 0,
2295
2404
  fetcher ? fetcher.data : void 0
2296
2405
  );
2297
- state.fetchers.set(rf.key, revalidatingFetcher);
2406
+ workingFetchers.set(rf.key, revalidatingFetcher);
2298
2407
  });
2299
- return new Map(state.fetchers);
2408
+ return workingFetchers;
2300
2409
  }
2301
2410
  async function fetch2(key, routeId, href, opts) {
2302
2411
  abortFetcher(key);
2303
2412
  let flushSync = (opts && opts.flushSync) === true;
2304
- let routesToUse = inFlightDataRoutes || dataRoutes;
2413
+ let routesToUse = dataRoutes.activeRoutes;
2305
2414
  let normalizedPath = normalizeTo(
2306
2415
  state.location,
2307
2416
  state.matches,
@@ -2310,7 +2419,13 @@ function createRouter(init) {
2310
2419
  routeId,
2311
2420
  opts?.relative
2312
2421
  );
2313
- let matches = matchRoutes(routesToUse, normalizedPath, basename);
2422
+ let matches = matchRoutesImpl(
2423
+ routesToUse,
2424
+ normalizedPath,
2425
+ basename,
2426
+ false,
2427
+ dataRoutes.branches
2428
+ );
2314
2429
  let fogOfWar = checkFogOfWar(matches, routesToUse, normalizedPath);
2315
2430
  if (fogOfWar.active && fogOfWar.matches) {
2316
2431
  matches = fogOfWar.matches;
@@ -2346,7 +2461,7 @@ function createRouter(init) {
2346
2461
  flushSync,
2347
2462
  preventScrollReset,
2348
2463
  submission,
2349
- opts && opts.unstable_defaultShouldRevalidate
2464
+ opts && opts.defaultShouldRevalidate
2350
2465
  );
2351
2466
  return;
2352
2467
  }
@@ -2476,13 +2591,17 @@ function createRouter(init) {
2476
2591
  nextLocation,
2477
2592
  abortController.signal
2478
2593
  );
2479
- let routesToUse = inFlightDataRoutes || dataRoutes;
2480
- let matches = state.navigation.state !== "idle" ? matchRoutes(routesToUse, state.navigation.location, basename) : state.matches;
2594
+ let routesToUse = dataRoutes.activeRoutes;
2595
+ let matches = state.navigation.state !== "idle" ? matchRoutesImpl(
2596
+ routesToUse,
2597
+ state.navigation.location,
2598
+ basename,
2599
+ false,
2600
+ dataRoutes.branches
2601
+ ) : state.matches;
2481
2602
  invariant(matches, "Didn't find any matches after fetcher action");
2482
2603
  let loadId = ++incrementingLoadId;
2483
2604
  fetchReloadIds.set(key, loadId);
2484
- let loadFetcher = getLoadingFetcher(submission, actionResult.data);
2485
- state.fetchers.set(key, loadFetcher);
2486
2605
  let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
2487
2606
  revalidationRequest,
2488
2607
  scopedContext,
@@ -2503,23 +2622,27 @@ function createRouter(init) {
2503
2622
  routesToUse,
2504
2623
  basename,
2505
2624
  init.patchRoutesOnNavigation != null,
2625
+ dataRoutes.branches,
2506
2626
  [match.route.id, actionResult],
2507
2627
  callSiteDefaultShouldRevalidate
2508
2628
  );
2629
+ let loadFetcher = getLoadingFetcher(submission, actionResult.data);
2630
+ let workingFetchers = new Map(state.fetchers);
2631
+ workingFetchers.set(key, loadFetcher);
2509
2632
  revalidatingFetchers.filter((rf) => rf.key !== key).forEach((rf) => {
2510
2633
  let staleKey = rf.key;
2511
- let existingFetcher2 = state.fetchers.get(staleKey);
2634
+ let existingFetcher2 = workingFetchers.get(staleKey);
2512
2635
  let revalidatingFetcher = getLoadingFetcher(
2513
2636
  void 0,
2514
2637
  existingFetcher2 ? existingFetcher2.data : void 0
2515
2638
  );
2516
- state.fetchers.set(staleKey, revalidatingFetcher);
2639
+ workingFetchers.set(staleKey, revalidatingFetcher);
2517
2640
  abortFetcher(staleKey);
2518
2641
  if (rf.controller) {
2519
2642
  fetchControllers.set(staleKey, rf.controller);
2520
2643
  }
2521
2644
  });
2522
- updateState({ fetchers: new Map(state.fetchers) });
2645
+ updateState({ fetchers: workingFetchers });
2523
2646
  let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((rf) => abortFetcher(rf.key));
2524
2647
  abortController.signal.addEventListener(
2525
2648
  "abort",
@@ -2542,12 +2665,16 @@ function createRouter(init) {
2542
2665
  fetchReloadIds.delete(key);
2543
2666
  fetchControllers.delete(key);
2544
2667
  revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key));
2545
- if (state.fetchers.has(key)) {
2546
- let doneFetcher = getDoneFetcher(actionResult.data);
2547
- state.fetchers.set(key, doneFetcher);
2548
- }
2668
+ let fetcherIsMounted = state.fetchers.has(key);
2669
+ let getRedirectStateWithDoneFetcher = (s) => {
2670
+ if (!fetcherIsMounted) return s;
2671
+ let workingFetchers2 = new Map(s.fetchers);
2672
+ workingFetchers2.set(key, getDoneFetcher(actionResult.data));
2673
+ return { ...s, fetchers: workingFetchers2 };
2674
+ };
2549
2675
  let redirect2 = findRedirect(loaderResults);
2550
2676
  if (redirect2) {
2677
+ state = getRedirectStateWithDoneFetcher(state);
2551
2678
  return startRedirectNavigation(
2552
2679
  revalidationRequest,
2553
2680
  redirect2.result,
@@ -2558,6 +2685,7 @@ function createRouter(init) {
2558
2685
  redirect2 = findRedirect(fetcherResults);
2559
2686
  if (redirect2) {
2560
2687
  fetchRedirectIds.add(redirect2.key);
2688
+ state = getRedirectStateWithDoneFetcher(state);
2561
2689
  return startRedirectNavigation(
2562
2690
  revalidationRequest,
2563
2691
  redirect2.result,
@@ -2565,15 +2693,20 @@ function createRouter(init) {
2565
2693
  { preventScrollReset }
2566
2694
  );
2567
2695
  }
2696
+ let finalFetchers = new Map(state.fetchers);
2697
+ if (fetcherIsMounted) {
2698
+ finalFetchers.set(key, getDoneFetcher(actionResult.data));
2699
+ }
2568
2700
  let { loaderData, errors } = processLoaderData(
2569
2701
  state,
2570
2702
  matches,
2571
2703
  loaderResults,
2572
2704
  void 0,
2573
2705
  revalidatingFetchers,
2574
- fetcherResults
2706
+ fetcherResults,
2707
+ finalFetchers
2575
2708
  );
2576
- abortStaleFetchLoads(loadId);
2709
+ abortStaleFetchLoads(loadId, finalFetchers);
2577
2710
  if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) {
2578
2711
  invariant(pendingAction, "Expected pending action");
2579
2712
  pendingNavigationController && pendingNavigationController.abort();
@@ -2581,7 +2714,7 @@ function createRouter(init) {
2581
2714
  matches,
2582
2715
  loaderData,
2583
2716
  errors,
2584
- fetchers: new Map(state.fetchers)
2717
+ fetchers: finalFetchers
2585
2718
  });
2586
2719
  } else {
2587
2720
  updateState({
@@ -2592,7 +2725,7 @@ function createRouter(init) {
2592
2725
  matches,
2593
2726
  errors
2594
2727
  ),
2595
- fetchers: new Map(state.fetchers)
2728
+ fetchers: finalFetchers
2596
2729
  });
2597
2730
  isRevalidationRequired = false;
2598
2731
  }
@@ -2757,6 +2890,8 @@ function createRouter(init) {
2757
2890
  } else {
2758
2891
  let overrideNavigation = getLoadingNavigation(
2759
2892
  redirectLocation,
2893
+ [],
2894
+ redirectNavigationType,
2760
2895
  submission
2761
2896
  );
2762
2897
  await startNavigation(redirectNavigationType, redirectLocation, {
@@ -2880,21 +3015,23 @@ function createRouter(init) {
2880
3015
  });
2881
3016
  }
2882
3017
  function updateFetcherState(key, fetcher, opts = {}) {
2883
- state.fetchers.set(key, fetcher);
3018
+ let workingFetchers = new Map(state.fetchers);
3019
+ workingFetchers.set(key, fetcher);
2884
3020
  updateState(
2885
- { fetchers: new Map(state.fetchers) },
3021
+ { fetchers: workingFetchers },
2886
3022
  { flushSync: (opts && opts.flushSync) === true }
2887
3023
  );
2888
3024
  }
2889
3025
  function setFetcherError(key, routeId, error, opts = {}) {
2890
3026
  let boundaryMatch = findNearestBoundary(state.matches, routeId);
2891
- deleteFetcher(key);
3027
+ let workingFetchers = new Map(state.fetchers);
3028
+ deleteFetcher(workingFetchers, key);
2892
3029
  updateState(
2893
3030
  {
2894
3031
  errors: {
2895
3032
  [boundaryMatch.route.id]: error
2896
3033
  },
2897
- fetchers: new Map(state.fetchers)
3034
+ fetchers: workingFetchers
2898
3035
  },
2899
3036
  { flushSync: (opts && opts.flushSync) === true }
2900
3037
  );
@@ -2910,7 +3047,7 @@ function createRouter(init) {
2910
3047
  abortFetcher(key, opts?.reason);
2911
3048
  updateFetcherState(key, getDoneFetcher(null));
2912
3049
  }
2913
- function deleteFetcher(key) {
3050
+ function deleteFetcher(fetchers, key) {
2914
3051
  let fetcher = state.fetchers.get(key);
2915
3052
  if (fetchControllers.has(key) && !(fetcher && fetcher.state === "loading" && fetchReloadIds.has(key))) {
2916
3053
  abortFetcher(key);
@@ -2920,7 +3057,7 @@ function createRouter(init) {
2920
3057
  fetchRedirectIds.delete(key);
2921
3058
  fetchersQueuedForDeletion.delete(key);
2922
3059
  cancelledFetcherLoads.delete(key);
2923
- state.fetchers.delete(key);
3060
+ fetchers.delete(key);
2924
3061
  }
2925
3062
  function queueFetcherForDeletion(key) {
2926
3063
  let count = (activeFetchers.get(key) || 0) - 1;
@@ -2939,33 +3076,34 @@ function createRouter(init) {
2939
3076
  fetchControllers.delete(key);
2940
3077
  }
2941
3078
  }
2942
- function markFetchersDone(keys) {
3079
+ function markFetchersDone(keys, fetchers) {
2943
3080
  for (let key of keys) {
2944
- let fetcher = getFetcher(key);
3081
+ let fetcher = fetchers.get(key);
3082
+ invariant(fetcher, `Expected fetcher: ${key}`);
2945
3083
  let doneFetcher = getDoneFetcher(fetcher.data);
2946
- state.fetchers.set(key, doneFetcher);
3084
+ fetchers.set(key, doneFetcher);
2947
3085
  }
2948
3086
  }
2949
- function markFetchRedirectsDone() {
3087
+ function markFetchRedirectsDone(fetchers) {
2950
3088
  let doneKeys = [];
2951
- let updatedFetchers = false;
3089
+ let didUpdateFetchers = false;
2952
3090
  for (let key of fetchRedirectIds) {
2953
- let fetcher = state.fetchers.get(key);
3091
+ let fetcher = fetchers.get(key);
2954
3092
  invariant(fetcher, `Expected fetcher: ${key}`);
2955
3093
  if (fetcher.state === "loading") {
2956
3094
  fetchRedirectIds.delete(key);
2957
3095
  doneKeys.push(key);
2958
- updatedFetchers = true;
3096
+ didUpdateFetchers = true;
2959
3097
  }
2960
3098
  }
2961
- markFetchersDone(doneKeys);
2962
- return updatedFetchers;
3099
+ markFetchersDone(doneKeys, fetchers);
3100
+ return didUpdateFetchers;
2963
3101
  }
2964
- function abortStaleFetchLoads(landedId) {
3102
+ function abortStaleFetchLoads(landedId, fetchers) {
2965
3103
  let yeetedKeys = [];
2966
3104
  for (let [key, id] of fetchReloadIds) {
2967
3105
  if (id < landedId) {
2968
- let fetcher = state.fetchers.get(key);
3106
+ let fetcher = fetchers.get(key);
2969
3107
  invariant(fetcher, `Expected fetcher: ${key}`);
2970
3108
  if (fetcher.state === "loading") {
2971
3109
  abortFetcher(key);
@@ -2974,7 +3112,7 @@ function createRouter(init) {
2974
3112
  }
2975
3113
  }
2976
3114
  }
2977
- markFetchersDone(yeetedKeys);
3115
+ markFetchersDone(yeetedKeys, fetchers);
2978
3116
  return yeetedKeys.length > 0;
2979
3117
  }
2980
3118
  function getBlocker(key, fn) {
@@ -3021,7 +3159,7 @@ function createRouter(init) {
3021
3159
  }
3022
3160
  function handleNavigational404(pathname) {
3023
3161
  let error = getInternalRouterError(404, { pathname });
3024
- let routesToUse = inFlightDataRoutes || dataRoutes;
3162
+ let routesToUse = dataRoutes.activeRoutes;
3025
3163
  let { matches, route } = getShortCircuitMatches(routesToUse);
3026
3164
  return { notFoundMatches: matches, route, error };
3027
3165
  }
@@ -3070,12 +3208,14 @@ function createRouter(init) {
3070
3208
  }
3071
3209
  function checkFogOfWar(matches, routesToUse, pathname) {
3072
3210
  if (init.patchRoutesOnNavigation) {
3211
+ let activeBranches = dataRoutes.branches;
3073
3212
  if (!matches) {
3074
3213
  let fogMatches = matchRoutesImpl(
3075
3214
  routesToUse,
3076
3215
  pathname,
3077
3216
  basename,
3078
- true
3217
+ true,
3218
+ activeBranches
3079
3219
  );
3080
3220
  return { active: true, matches: fogMatches || [] };
3081
3221
  } else {
@@ -3084,7 +3224,8 @@ function createRouter(init) {
3084
3224
  routesToUse,
3085
3225
  pathname,
3086
3226
  basename,
3087
- true
3227
+ true,
3228
+ activeBranches
3088
3229
  );
3089
3230
  return { active: true, matches: partialMatches };
3090
3231
  }
@@ -3098,8 +3239,6 @@ function createRouter(init) {
3098
3239
  }
3099
3240
  let partialMatches = matches;
3100
3241
  while (true) {
3101
- let isNonHMR = inFlightDataRoutes == null;
3102
- let routesToUse = inFlightDataRoutes || dataRoutes;
3103
3242
  let localManifest = manifest;
3104
3243
  try {
3105
3244
  await init.patchRoutesOnNavigation({
@@ -3112,7 +3251,7 @@ function createRouter(init) {
3112
3251
  patchRoutesImpl(
3113
3252
  routeId,
3114
3253
  children,
3115
- routesToUse,
3254
+ dataRoutes,
3116
3255
  localManifest,
3117
3256
  mapRouteProperties2,
3118
3257
  false
@@ -3121,25 +3260,29 @@ function createRouter(init) {
3121
3260
  });
3122
3261
  } catch (e) {
3123
3262
  return { type: "error", error: e, partialMatches };
3124
- } finally {
3125
- if (isNonHMR && !signal.aborted) {
3126
- dataRoutes = [...dataRoutes];
3127
- }
3128
3263
  }
3129
3264
  if (signal.aborted) {
3130
3265
  return { type: "aborted" };
3131
3266
  }
3132
- let newMatches = matchRoutes(routesToUse, pathname, basename);
3267
+ let activeBranches = dataRoutes.branches;
3268
+ let newMatches = matchRoutesImpl(
3269
+ dataRoutes.activeRoutes,
3270
+ pathname,
3271
+ basename,
3272
+ false,
3273
+ activeBranches
3274
+ );
3133
3275
  let newPartialMatches = null;
3134
3276
  if (newMatches) {
3135
3277
  if (Object.keys(newMatches[0].params).length === 0) {
3136
3278
  return { type: "success", matches: newMatches };
3137
3279
  } else {
3138
3280
  newPartialMatches = matchRoutesImpl(
3139
- routesToUse,
3281
+ dataRoutes.activeRoutes,
3140
3282
  pathname,
3141
3283
  basename,
3142
- true
3284
+ true,
3285
+ activeBranches
3143
3286
  );
3144
3287
  let matchedDeeper = newPartialMatches && partialMatches.length < newPartialMatches.length && compareMatches(
3145
3288
  partialMatches,
@@ -3152,10 +3295,11 @@ function createRouter(init) {
3152
3295
  }
3153
3296
  if (!newPartialMatches) {
3154
3297
  newPartialMatches = matchRoutesImpl(
3155
- routesToUse,
3298
+ dataRoutes.activeRoutes,
3156
3299
  pathname,
3157
3300
  basename,
3158
- true
3301
+ true,
3302
+ activeBranches
3159
3303
  );
3160
3304
  }
3161
3305
  if (!newPartialMatches || compareMatches(partialMatches, newPartialMatches)) {
@@ -3169,26 +3313,25 @@ function createRouter(init) {
3169
3313
  }
3170
3314
  function _internalSetRoutes(newRoutes) {
3171
3315
  manifest = {};
3172
- inFlightDataRoutes = convertRoutesToDataRoutes(
3173
- newRoutes,
3174
- mapRouteProperties2,
3175
- void 0,
3176
- manifest
3316
+ dataRoutes.setHmrRoutes(
3317
+ convertRoutesToDataRoutes(
3318
+ newRoutes,
3319
+ mapRouteProperties2,
3320
+ void 0,
3321
+ manifest
3322
+ )
3177
3323
  );
3178
3324
  }
3179
3325
  function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
3180
- let isNonHMR = inFlightDataRoutes == null;
3181
- let routesToUse = inFlightDataRoutes || dataRoutes;
3182
3326
  patchRoutesImpl(
3183
3327
  routeId,
3184
3328
  children,
3185
- routesToUse,
3329
+ dataRoutes,
3186
3330
  manifest,
3187
3331
  mapRouteProperties2,
3188
3332
  unstable_allowElementMutations
3189
3333
  );
3190
- if (isNonHMR) {
3191
- dataRoutes = [...dataRoutes];
3334
+ if (!dataRoutes.hasHMRRoutes) {
3192
3335
  updateState({});
3193
3336
  }
3194
3337
  }
@@ -3203,7 +3346,13 @@ function createRouter(init) {
3203
3346
  return state;
3204
3347
  },
3205
3348
  get routes() {
3206
- return dataRoutes;
3349
+ return dataRoutes.stableRoutes;
3350
+ },
3351
+ get branches() {
3352
+ return dataRoutes.branches;
3353
+ },
3354
+ get manifest() {
3355
+ return manifest;
3207
3356
  },
3208
3357
  get window() {
3209
3358
  return routerWindow;
@@ -3233,10 +3382,10 @@ function createRouter(init) {
3233
3382
  updateState(newState);
3234
3383
  }
3235
3384
  };
3236
- if (init.unstable_instrumentations) {
3385
+ if (init.instrumentations) {
3237
3386
  router = instrumentClientSideRouter(
3238
3387
  router,
3239
- init.unstable_instrumentations.map((i) => i.router).filter(Boolean)
3388
+ init.instrumentations.map((i) => i.router).filter(Boolean)
3240
3389
  );
3241
3390
  }
3242
3391
  return router;
@@ -3251,12 +3400,10 @@ function createStaticHandler(routes, opts) {
3251
3400
  let _mapRouteProperties = opts?.mapRouteProperties || defaultMapRouteProperties;
3252
3401
  let mapRouteProperties2 = _mapRouteProperties;
3253
3402
  let future = {
3254
- unstable_passThroughRequests: false,
3255
- // unused in static handler
3256
3403
  ...opts?.future
3257
3404
  };
3258
- if (opts?.unstable_instrumentations) {
3259
- let instrumentations = opts.unstable_instrumentations;
3405
+ if (opts?.instrumentations) {
3406
+ let instrumentations = opts.instrumentations;
3260
3407
  mapRouteProperties2 = (route) => {
3261
3408
  return {
3262
3409
  ..._mapRouteProperties(route),
@@ -3273,6 +3420,7 @@ function createStaticHandler(routes, opts) {
3273
3420
  void 0,
3274
3421
  manifest
3275
3422
  );
3423
+ let routeBranches = flattenAndRankRoutes(dataRoutes);
3276
3424
  async function query(request, {
3277
3425
  requestContext,
3278
3426
  filterMatchesToLoad,
@@ -3280,12 +3428,23 @@ function createStaticHandler(routes, opts) {
3280
3428
  skipRevalidation,
3281
3429
  dataStrategy,
3282
3430
  generateMiddlewareResponse,
3283
- unstable_normalizePath
3431
+ normalizePath
3284
3432
  } = {}) {
3285
- let normalizePath = unstable_normalizePath || defaultNormalizePath;
3433
+ let normalizePathImpl = normalizePath || defaultNormalizePath;
3286
3434
  let method = request.method;
3287
- let location = createLocation("", normalizePath(request), null, "default");
3288
- let matches = matchRoutes(dataRoutes, location, basename);
3435
+ let location = createLocation(
3436
+ "",
3437
+ normalizePathImpl(request),
3438
+ null,
3439
+ "default"
3440
+ );
3441
+ let matches = matchRoutesImpl(
3442
+ dataRoutes,
3443
+ location,
3444
+ basename,
3445
+ false,
3446
+ routeBranches
3447
+ );
3289
3448
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
3290
3449
  if (!isValidMethod(method) && method !== "HEAD") {
3291
3450
  let error = getInternalRouterError(405, { method });
@@ -3337,8 +3496,8 @@ function createStaticHandler(routes, opts) {
3337
3496
  let response = await runServerMiddlewarePipeline(
3338
3497
  {
3339
3498
  request,
3340
- unstable_url: createDataFunctionUrl(request, location),
3341
- unstable_pattern: getRoutePattern(matches),
3499
+ url: createDataFunctionUrl(request, location),
3500
+ pattern: getRoutePattern(matches),
3342
3501
  matches,
3343
3502
  params: matches[0].params,
3344
3503
  // If we're calling middleware then it must be enabled so we can cast
@@ -3455,12 +3614,23 @@ function createStaticHandler(routes, opts) {
3455
3614
  requestContext,
3456
3615
  dataStrategy,
3457
3616
  generateMiddlewareResponse,
3458
- unstable_normalizePath
3617
+ normalizePath
3459
3618
  } = {}) {
3460
- let normalizePath = unstable_normalizePath || defaultNormalizePath;
3619
+ let normalizePathImpl = normalizePath || defaultNormalizePath;
3461
3620
  let method = request.method;
3462
- let location = createLocation("", normalizePath(request), null, "default");
3463
- let matches = matchRoutes(dataRoutes, location, basename);
3621
+ let location = createLocation(
3622
+ "",
3623
+ normalizePathImpl(request),
3624
+ null,
3625
+ "default"
3626
+ );
3627
+ let matches = matchRoutesImpl(
3628
+ dataRoutes,
3629
+ location,
3630
+ basename,
3631
+ false,
3632
+ routeBranches
3633
+ );
3464
3634
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
3465
3635
  if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
3466
3636
  throw getInternalRouterError(405, { method });
@@ -3485,8 +3655,8 @@ function createStaticHandler(routes, opts) {
3485
3655
  let response = await runServerMiddlewarePipeline(
3486
3656
  {
3487
3657
  request,
3488
- unstable_url: createDataFunctionUrl(request, location),
3489
- unstable_pattern: getRoutePattern(matches),
3658
+ url: createDataFunctionUrl(request, location),
3659
+ pattern: getRoutePattern(matches),
3490
3660
  matches,
3491
3661
  params: matches[0].params,
3492
3662
  // If we're calling middleware then it must be enabled so we can cast
@@ -3872,6 +4042,7 @@ function createStaticHandler(routes, opts) {
3872
4042
  }
3873
4043
  return {
3874
4044
  dataRoutes,
4045
+ _internalRouteBranches: routeBranches,
3875
4046
  query,
3876
4047
  queryRoute
3877
4048
  };
@@ -4057,7 +4228,7 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
4057
4228
  parsedPath.search = `?${searchParams}`;
4058
4229
  return { path: createPath(parsedPath), submission };
4059
4230
  }
4060
- function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, pendingActionResult, callSiteDefaultShouldRevalidate) {
4231
+ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, branches, pendingActionResult, callSiteDefaultShouldRevalidate) {
4061
4232
  let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
4062
4233
  let currentUrl = history.createURL(state.location);
4063
4234
  let nextUrl = history.createURL(location);
@@ -4153,7 +4324,13 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
4153
4324
  }
4154
4325
  let fetcher = state.fetchers.get(key);
4155
4326
  let isMidInitialLoad = fetcher && fetcher.state !== "idle" && fetcher.data === void 0;
4156
- let fetcherMatches = matchRoutes(routesToUse, f.path, basename);
4327
+ let fetcherMatches = matchRoutesImpl(
4328
+ routesToUse,
4329
+ f.path,
4330
+ basename ?? "/",
4331
+ false,
4332
+ branches
4333
+ );
4157
4334
  if (!fetcherMatches) {
4158
4335
  if (hasPatchRoutesOnNavigation && isMidInitialLoad) {
4159
4336
  return;
@@ -4294,7 +4471,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
4294
4471
  }
4295
4472
  return arg.defaultShouldRevalidate;
4296
4473
  }
4297
- function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
4474
+ function patchRoutesImpl(routeId, children, dataRoutes, manifest, mapRouteProperties2, allowElementMutations) {
4298
4475
  let childrenToPatch;
4299
4476
  if (routeId) {
4300
4477
  let route = manifest[routeId];
@@ -4307,7 +4484,7 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
4307
4484
  }
4308
4485
  childrenToPatch = route.children;
4309
4486
  } else {
4310
- childrenToPatch = routesToUse;
4487
+ childrenToPatch = dataRoutes.activeRoutes;
4311
4488
  }
4312
4489
  let uniqueChildren = [];
4313
4490
  let existingChildren = [];
@@ -4350,6 +4527,9 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
4350
4527
  });
4351
4528
  }
4352
4529
  }
4530
+ if (!dataRoutes.hasHMRRoutes) {
4531
+ dataRoutes.setRoutes([...dataRoutes.activeRoutes]);
4532
+ }
4353
4533
  }
4354
4534
  function isSameRoute(newRoute, existingRoute) {
4355
4535
  if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
@@ -4691,7 +4871,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
4691
4871
  handler: lazyRoutePromises.lazyHandlerPromise
4692
4872
  };
4693
4873
  }
4694
- function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
4874
+ function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
4695
4875
  let isUsingNewApi = false;
4696
4876
  let _lazyPromises = getDataStrategyMatchLazyPromises(
4697
4877
  mapRouteProperties2,
@@ -4732,7 +4912,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, unst
4732
4912
  return callLoaderOrAction({
4733
4913
  request,
4734
4914
  path,
4735
- unstable_pattern,
4915
+ pattern,
4736
4916
  match,
4737
4917
  lazyHandlerPromise: _lazyPromises?.handler,
4738
4918
  lazyRoutePromise: _lazyPromises?.route,
@@ -4782,8 +4962,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
4782
4962
  }
4783
4963
  let dataStrategyArgs = {
4784
4964
  request,
4785
- unstable_url: createDataFunctionUrl(request, path),
4786
- unstable_pattern: getRoutePattern(matches),
4965
+ url: createDataFunctionUrl(request, path),
4966
+ pattern: getRoutePattern(matches),
4787
4967
  params: matches[0].params,
4788
4968
  context: scopedContext,
4789
4969
  matches
@@ -4825,7 +5005,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
4825
5005
  async function callLoaderOrAction({
4826
5006
  request,
4827
5007
  path,
4828
- unstable_pattern,
5008
+ pattern,
4829
5009
  match,
4830
5010
  lazyHandlerPromise,
4831
5011
  lazyRoutePromise,
@@ -4852,8 +5032,8 @@ async function callLoaderOrAction({
4852
5032
  return handler(
4853
5033
  {
4854
5034
  request,
4855
- unstable_url: createDataFunctionUrl(request, path),
4856
- unstable_pattern,
5035
+ url: createDataFunctionUrl(request, path),
5036
+ pattern,
4857
5037
  params: match.params,
4858
5038
  context: scopedContext
4859
5039
  },
@@ -5160,7 +5340,7 @@ function processRouteLoaderData(matches, results, pendingActionResult, isStaticH
5160
5340
  loaderHeaders
5161
5341
  };
5162
5342
  }
5163
- function processLoaderData(state, matches, results, pendingActionResult, revalidatingFetchers, fetcherResults) {
5343
+ function processLoaderData(state, matches, results, pendingActionResult, revalidatingFetchers, fetcherResults, workingFetchers) {
5164
5344
  let { loaderData, errors } = processRouteLoaderData(
5165
5345
  matches,
5166
5346
  results,
@@ -5181,12 +5361,12 @@ function processLoaderData(state, matches, results, pendingActionResult, revalid
5181
5361
  [boundaryMatch.route.id]: result.error
5182
5362
  };
5183
5363
  }
5184
- state.fetchers.delete(key);
5364
+ workingFetchers.delete(key);
5185
5365
  } else if (isRedirectResult(result)) {
5186
5366
  invariant(false, "Unhandled fetcher revalidation redirect");
5187
5367
  } else {
5188
5368
  let doneFetcher = getDoneFetcher(result.data);
5189
- state.fetchers.set(key, doneFetcher);
5369
+ workingFetchers.set(key, doneFetcher);
5190
5370
  }
5191
5371
  });
5192
5372
  return { loaderData, errors };
@@ -5393,11 +5573,13 @@ function getSubmissionFromNavigation(navigation) {
5393
5573
  };
5394
5574
  }
5395
5575
  }
5396
- function getLoadingNavigation(location, submission) {
5576
+ function getLoadingNavigation(location, matches, historyAction, submission) {
5397
5577
  if (submission) {
5398
5578
  let navigation = {
5399
5579
  state: "loading",
5400
5580
  location,
5581
+ matches,
5582
+ historyAction,
5401
5583
  formMethod: submission.formMethod,
5402
5584
  formAction: submission.formAction,
5403
5585
  formEncType: submission.formEncType,
@@ -5410,6 +5592,8 @@ function getLoadingNavigation(location, submission) {
5410
5592
  let navigation = {
5411
5593
  state: "loading",
5412
5594
  location,
5595
+ matches,
5596
+ historyAction,
5413
5597
  formMethod: void 0,
5414
5598
  formAction: void 0,
5415
5599
  formEncType: void 0,
@@ -5420,10 +5604,12 @@ function getLoadingNavigation(location, submission) {
5420
5604
  return navigation;
5421
5605
  }
5422
5606
  }
5423
- function getSubmittingNavigation(location, submission) {
5607
+ function getSubmittingNavigation(location, matches, historyAction, submission) {
5424
5608
  let navigation = {
5425
5609
  state: "submitting",
5426
5610
  location,
5611
+ matches,
5612
+ historyAction,
5427
5613
  formMethod: submission.formMethod,
5428
5614
  formAction: submission.formAction,
5429
5615
  formEncType: submission.formEncType,
@@ -5804,7 +5990,15 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5804
5990
  let segments = pathname.replace(/^\//, "").split("/");
5805
5991
  remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
5806
5992
  }
5807
- let matches = matchRoutes(routes, { pathname: remainingPathname });
5993
+ let matches = dataRouterOpts && dataRouterOpts.state.matches.length ? (
5994
+ // If we're in a data router, use the matches we've already identified but ensure
5995
+ // we have the latest route instances from the manifest in case elements have changed
5996
+ dataRouterOpts.state.matches.map(
5997
+ (m) => Object.assign(m, {
5998
+ route: dataRouterOpts.manifest[m.route.id] || m.route
5999
+ })
6000
+ )
6001
+ ) : matchRoutes(routes, { pathname: remainingPathname });
5808
6002
  if (ENABLE_DEV_WARNINGS) {
5809
6003
  warning(
5810
6004
  parentRoute || matches != null,
@@ -5855,7 +6049,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5855
6049
  hash: "",
5856
6050
  state: null,
5857
6051
  key: "default",
5858
- unstable_mask: void 0,
6052
+ mask: void 0,
5859
6053
  ...location
5860
6054
  },
5861
6055
  navigationType: "POP" /* Pop */
@@ -6045,7 +6239,7 @@ function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
6045
6239
  onErrorHandler(error, {
6046
6240
  location: dataRouterState.location,
6047
6241
  params: dataRouterState.matches?.[0]?.params ?? {},
6048
- unstable_pattern: getRoutePattern(dataRouterState.matches),
6242
+ pattern: getRoutePattern(dataRouterState.matches),
6049
6243
  errorInfo
6050
6244
  });
6051
6245
  } : void 0;
@@ -6148,7 +6342,10 @@ function useRouteId() {
6148
6342
  }
6149
6343
  function useNavigation() {
6150
6344
  let state = useDataRouterState("useNavigation" /* UseNavigation */);
6151
- return state.navigation;
6345
+ return React2.useMemo(() => {
6346
+ let { matches, historyAction, ...rest } = state.navigation;
6347
+ return rest;
6348
+ }, [state.navigation]);
6152
6349
  }
6153
6350
  function useRevalidator() {
6154
6351
  let dataRouterContext = useDataRouterContext("useRevalidator" /* UseRevalidator */);
@@ -6283,6 +6480,65 @@ function useRoute(...args) {
6283
6480
  actionData: state.actionData?.[id]
6284
6481
  };
6285
6482
  }
6483
+ function toRouterStateMatch(match) {
6484
+ return {
6485
+ id: match.route.id,
6486
+ pathname: match.pathname,
6487
+ params: match.params,
6488
+ handle: match.route.handle
6489
+ };
6490
+ }
6491
+ function useRouterState() {
6492
+ let {
6493
+ location,
6494
+ historyAction: type,
6495
+ matches,
6496
+ navigation
6497
+ } = useDataRouterState("unstable_useRouterState" /* UseRouterState */);
6498
+ let active = React2.useMemo(
6499
+ () => ({
6500
+ type,
6501
+ location,
6502
+ searchParams: new URLSearchParams(location.search),
6503
+ params: matches[matches.length - 1]?.params ?? {},
6504
+ matches: matches.map((m) => toRouterStateMatch(m))
6505
+ }),
6506
+ [location, matches, type]
6507
+ );
6508
+ let pending = React2.useMemo(() => {
6509
+ if (navigation.state === "idle") return null;
6510
+ let shared = {
6511
+ type: navigation.historyAction,
6512
+ location: navigation.location,
6513
+ searchParams: new URLSearchParams(navigation.location.search),
6514
+ params: navigation.matches[navigation.matches.length - 1]?.params ?? {},
6515
+ matches: navigation.matches.map((m) => toRouterStateMatch(m))
6516
+ };
6517
+ return navigation.state === "loading" ? {
6518
+ ...shared,
6519
+ state: "loading",
6520
+ formMethod: navigation.formMethod,
6521
+ formAction: navigation.formAction,
6522
+ formEncType: navigation.formEncType,
6523
+ formData: navigation.formData,
6524
+ json: navigation.json,
6525
+ text: navigation.text
6526
+ } : {
6527
+ ...shared,
6528
+ state: "submitting",
6529
+ formMethod: navigation.formMethod,
6530
+ formAction: navigation.formAction,
6531
+ formEncType: navigation.formEncType,
6532
+ formData: navigation.formData,
6533
+ json: navigation.json,
6534
+ text: navigation.text
6535
+ };
6536
+ }, [navigation]);
6537
+ return React2.useMemo(
6538
+ () => ({ active, pending }),
6539
+ [active, pending]
6540
+ );
6541
+ }
6286
6542
 
6287
6543
  // lib/components.tsx
6288
6544
  import * as React3 from "react";
@@ -6376,7 +6632,7 @@ function createMemoryRouter(routes, opts) {
6376
6632
  mapRouteProperties,
6377
6633
  dataStrategy: opts?.dataStrategy,
6378
6634
  patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
6379
- unstable_instrumentations: opts?.unstable_instrumentations
6635
+ instrumentations: opts?.instrumentations
6380
6636
  }).initialize();
6381
6637
  }
6382
6638
  var Deferred = class {
@@ -6402,10 +6658,10 @@ function RouterProvider({
6402
6658
  router,
6403
6659
  flushSync: reactDomFlushSyncImpl,
6404
6660
  onError,
6405
- unstable_useTransitions
6661
+ useTransitions
6406
6662
  }) {
6407
6663
  let unstable_rsc = useIsRSCRouterContext();
6408
- unstable_useTransitions = unstable_rsc || unstable_useTransitions;
6664
+ useTransitions = unstable_rsc || useTransitions;
6409
6665
  let [_state, setStateImpl] = React3.useState(router.state);
6410
6666
  let [state, setOptimisticState] = useOptimisticSafe(_state);
6411
6667
  let [pendingState, setPendingState] = React3.useState();
@@ -6423,7 +6679,7 @@ function RouterProvider({
6423
6679
  (error) => onError(error, {
6424
6680
  location: newState.location,
6425
6681
  params: newState.matches[0]?.params ?? {},
6426
- unstable_pattern: getRoutePattern(newState.matches)
6682
+ pattern: getRoutePattern(newState.matches)
6427
6683
  })
6428
6684
  );
6429
6685
  }
@@ -6445,11 +6701,11 @@ function RouterProvider({
6445
6701
  if (!viewTransitionOpts || !isViewTransitionAvailable) {
6446
6702
  if (reactDomFlushSyncImpl && flushSync) {
6447
6703
  reactDomFlushSyncImpl(() => setStateImpl(newState));
6448
- } else if (unstable_useTransitions === false) {
6704
+ } else if (useTransitions === false) {
6449
6705
  setStateImpl(newState);
6450
6706
  } else {
6451
6707
  React3.startTransition(() => {
6452
- if (unstable_useTransitions === true) {
6708
+ if (useTransitions === true) {
6453
6709
  setOptimisticState((s) => getOptimisticRouterState(s, newState));
6454
6710
  }
6455
6711
  setStateImpl(newState);
@@ -6507,22 +6763,12 @@ function RouterProvider({
6507
6763
  reactDomFlushSyncImpl,
6508
6764
  transition,
6509
6765
  renderDfd,
6510
- unstable_useTransitions,
6766
+ useTransitions,
6511
6767
  setOptimisticState,
6512
6768
  onError
6513
6769
  ]
6514
6770
  );
6515
6771
  React3.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
6516
- let initialized = state.initialized;
6517
- React3.useLayoutEffect(() => {
6518
- if (!initialized && router.state.initialized) {
6519
- setState(router.state, {
6520
- deletedFetchers: [],
6521
- flushSync: false,
6522
- newErrors: null
6523
- });
6524
- }
6525
- }, [initialized, setState, router.state]);
6526
6772
  React3.useEffect(() => {
6527
6773
  if (vtContext.isTransitioning && !vtContext.flushSync) {
6528
6774
  setRenderDfd(new Deferred());
@@ -6533,11 +6779,11 @@ function RouterProvider({
6533
6779
  let newState = pendingState;
6534
6780
  let renderPromise = renderDfd.promise;
6535
6781
  let transition2 = router.window.document.startViewTransition(async () => {
6536
- if (unstable_useTransitions === false) {
6782
+ if (useTransitions === false) {
6537
6783
  setStateImpl(newState);
6538
6784
  } else {
6539
6785
  React3.startTransition(() => {
6540
- if (unstable_useTransitions === true) {
6786
+ if (useTransitions === true) {
6541
6787
  setOptimisticState((s) => getOptimisticRouterState(s, newState));
6542
6788
  }
6543
6789
  setStateImpl(newState);
@@ -6557,7 +6803,7 @@ function RouterProvider({
6557
6803
  pendingState,
6558
6804
  renderDfd,
6559
6805
  router.window,
6560
- unstable_useTransitions,
6806
+ useTransitions,
6561
6807
  setOptimisticState
6562
6808
  ]);
6563
6809
  React3.useEffect(() => {
@@ -6611,12 +6857,13 @@ function RouterProvider({
6611
6857
  location: state.location,
6612
6858
  navigationType: state.historyAction,
6613
6859
  navigator,
6614
- unstable_useTransitions
6860
+ useTransitions
6615
6861
  },
6616
6862
  /* @__PURE__ */ React3.createElement(
6617
6863
  MemoizedDataRoutes,
6618
6864
  {
6619
6865
  routes: router.routes,
6866
+ manifest: router.manifest,
6620
6867
  future: router.future,
6621
6868
  state,
6622
6869
  isStatic: false,
@@ -6639,22 +6886,29 @@ function getOptimisticRouterState(currentState, newState) {
6639
6886
  fetchers: newState.fetchers
6640
6887
  };
6641
6888
  }
6642
- var MemoizedDataRoutes = React3.memo(DataRoutes);
6643
- function DataRoutes({
6889
+ var MemoizedDataRoutes = React3.memo(DataRoutes2);
6890
+ function DataRoutes2({
6644
6891
  routes,
6892
+ manifest,
6645
6893
  future,
6646
6894
  state,
6647
6895
  isStatic,
6648
6896
  onError
6649
6897
  }) {
6650
- return useRoutesImpl(routes, void 0, { state, isStatic, onError, future });
6898
+ return useRoutesImpl(routes, void 0, {
6899
+ manifest,
6900
+ state,
6901
+ isStatic,
6902
+ onError,
6903
+ future
6904
+ });
6651
6905
  }
6652
6906
  function MemoryRouter({
6653
6907
  basename,
6654
6908
  children,
6655
6909
  initialEntries,
6656
6910
  initialIndex,
6657
- unstable_useTransitions
6911
+ useTransitions
6658
6912
  }) {
6659
6913
  let historyRef = React3.useRef();
6660
6914
  if (historyRef.current == null) {
@@ -6671,13 +6925,13 @@ function MemoryRouter({
6671
6925
  });
6672
6926
  let setState = React3.useCallback(
6673
6927
  (newState) => {
6674
- if (unstable_useTransitions === false) {
6928
+ if (useTransitions === false) {
6675
6929
  setStateImpl(newState);
6676
6930
  } else {
6677
6931
  React3.startTransition(() => setStateImpl(newState));
6678
6932
  }
6679
6933
  },
6680
- [unstable_useTransitions]
6934
+ [useTransitions]
6681
6935
  );
6682
6936
  React3.useLayoutEffect(() => history.listen(setState), [history, setState]);
6683
6937
  return /* @__PURE__ */ React3.createElement(
@@ -6688,7 +6942,7 @@ function MemoryRouter({
6688
6942
  location: state.location,
6689
6943
  navigationType: state.action,
6690
6944
  navigator: history,
6691
- unstable_useTransitions
6945
+ useTransitions
6692
6946
  }
6693
6947
  );
6694
6948
  }
@@ -6740,7 +6994,7 @@ function Router({
6740
6994
  navigationType = "POP" /* Pop */,
6741
6995
  navigator,
6742
6996
  static: staticProp = false,
6743
- unstable_useTransitions
6997
+ useTransitions
6744
6998
  }) {
6745
6999
  invariant(
6746
7000
  !useInRouterContext(),
@@ -6752,10 +7006,10 @@ function Router({
6752
7006
  basename,
6753
7007
  navigator,
6754
7008
  static: staticProp,
6755
- unstable_useTransitions,
7009
+ useTransitions,
6756
7010
  future: {}
6757
7011
  }),
6758
- [basename, navigator, staticProp, unstable_useTransitions]
7012
+ [basename, navigator, staticProp, useTransitions]
6759
7013
  );
6760
7014
  if (typeof locationProp === "string") {
6761
7015
  locationProp = parsePath(locationProp);
@@ -6766,7 +7020,7 @@ function Router({
6766
7020
  hash = "",
6767
7021
  state = null,
6768
7022
  key = "default",
6769
- unstable_mask
7023
+ mask
6770
7024
  } = locationProp;
6771
7025
  let locationContext = React3.useMemo(() => {
6772
7026
  let trailingPathname = stripBasename(pathname, basename);
@@ -6780,20 +7034,11 @@ function Router({
6780
7034
  hash,
6781
7035
  state,
6782
7036
  key,
6783
- unstable_mask
7037
+ mask
6784
7038
  },
6785
7039
  navigationType
6786
7040
  };
6787
- }, [
6788
- basename,
6789
- pathname,
6790
- search,
6791
- hash,
6792
- state,
6793
- key,
6794
- navigationType,
6795
- unstable_mask
6796
- ]);
7041
+ }, [basename, pathname, search, hash, state, key, navigationType, mask]);
6797
7042
  warning(
6798
7043
  locationContext != null,
6799
7044
  `<Router basename="${basename}"> is not able to match the URL "${pathname}${search}${hash}" because it does not start with the basename, so the <Router> won't render anything.`
@@ -6822,7 +7067,7 @@ function Await({
6822
7067
  dataRouterContext.onError(error, {
6823
7068
  location: dataRouterStateContext.location,
6824
7069
  params: dataRouterStateContext.matches[0]?.params || {},
6825
- unstable_pattern: getRoutePattern(dataRouterStateContext.matches),
7070
+ pattern: getRoutePattern(dataRouterStateContext.matches),
6826
7071
  errorInfo
6827
7072
  });
6828
7073
  }
@@ -7976,11 +8221,9 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
7976
8221
  (match) => {
7977
8222
  let manifestRoute = manifest.routes[match.route.id];
7978
8223
  invariant2(manifestRoute, "Route not found in manifest");
7979
- let routeModule = routeModules[match.route.id];
7980
8224
  return {
7981
8225
  hasLoader: manifestRoute.hasLoader,
7982
- hasClientLoader: manifestRoute.hasClientLoader,
7983
- hasShouldRevalidate: Boolean(routeModule?.shouldRevalidate)
8226
+ hasClientLoader: manifestRoute.hasClientLoader
7984
8227
  };
7985
8228
  },
7986
8229
  fetchAndDecodeViaTurboStream,
@@ -8100,13 +8343,12 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
8100
8343
  async (m, i) => m.resolve(async (handler) => {
8101
8344
  routeDfds[i].resolve();
8102
8345
  let routeId = m.route.id;
8103
- let { hasLoader, hasClientLoader, hasShouldRevalidate } = getRouteInfo(m);
8346
+ let { hasLoader, hasClientLoader } = getRouteInfo(m);
8104
8347
  let defaultShouldRevalidate = !m.shouldRevalidateArgs || m.shouldRevalidateArgs.actionStatus == null || m.shouldRevalidateArgs.actionStatus < 400;
8105
8348
  let shouldCall = m.shouldCallHandler(defaultShouldRevalidate);
8106
8349
  if (!shouldCall) {
8107
8350
  foundOptOutRoute || (foundOptOutRoute = m.shouldRevalidateArgs != null && // This is a revalidation,
8108
- hasLoader && // for a route with a server loader,
8109
- hasShouldRevalidate === true);
8351
+ hasLoader);
8110
8352
  return;
8111
8353
  }
8112
8354
  if (shouldAllowOptOut(m) && hasClientLoader) {
@@ -8843,46 +9085,38 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
8843
9085
  let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
8844
9086
  let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
8845
9087
  let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
8846
- dataRoute.loader = async ({
8847
- request,
8848
- params,
8849
- context,
8850
- unstable_pattern,
8851
- unstable_url
8852
- }, singleFetch) => {
8853
- try {
8854
- let result = await prefetchStylesAndCallHandler(async () => {
8855
- invariant2(
8856
- routeModule,
8857
- "No `routeModule` available for critical-route loader"
8858
- );
8859
- if (!routeModule.clientLoader) {
8860
- return fetchServerLoader(singleFetch);
8861
- }
8862
- return routeModule.clientLoader({
8863
- request,
8864
- params,
8865
- context,
8866
- unstable_pattern,
8867
- unstable_url,
8868
- async serverLoader() {
8869
- preventInvalidServerHandlerCall("loader", route);
8870
- if (isHydrationRequest) {
8871
- if (hasInitialData) {
8872
- return initialData;
8873
- }
8874
- if (hasInitialError) {
8875
- throw initialError;
8876
- }
9088
+ dataRoute.loader = async ({ request, params, context, pattern, url }, singleFetch) => {
9089
+ let _isHydrationRequest = isHydrationRequest;
9090
+ isHydrationRequest = false;
9091
+ let result = await prefetchStylesAndCallHandler(async () => {
9092
+ invariant2(
9093
+ routeModule,
9094
+ "No `routeModule` available for critical-route loader"
9095
+ );
9096
+ if (!routeModule.clientLoader) {
9097
+ return fetchServerLoader(singleFetch);
9098
+ }
9099
+ return routeModule.clientLoader({
9100
+ request,
9101
+ params,
9102
+ context,
9103
+ pattern,
9104
+ url,
9105
+ async serverLoader() {
9106
+ preventInvalidServerHandlerCall("loader", route);
9107
+ if (_isHydrationRequest) {
9108
+ if (hasInitialData) {
9109
+ return initialData;
9110
+ }
9111
+ if (hasInitialError) {
9112
+ throw initialError;
8877
9113
  }
8878
- return fetchServerLoader(singleFetch);
8879
9114
  }
8880
- });
9115
+ return fetchServerLoader(singleFetch);
9116
+ }
8881
9117
  });
8882
- return result;
8883
- } finally {
8884
- isHydrationRequest = false;
8885
- }
9118
+ });
9119
+ return result;
8886
9120
  };
8887
9121
  dataRoute.loader.hydrate = shouldHydrateRouteLoader(
8888
9122
  route.id,
@@ -8890,13 +9124,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
8890
9124
  route.hasLoader,
8891
9125
  isSpaMode
8892
9126
  );
8893
- dataRoute.action = ({
8894
- request,
8895
- params,
8896
- context,
8897
- unstable_pattern,
8898
- unstable_url
8899
- }, singleFetch) => {
9127
+ dataRoute.action = ({ request, params, context, pattern, url }, singleFetch) => {
8900
9128
  return prefetchStylesAndCallHandler(async () => {
8901
9129
  invariant2(
8902
9130
  routeModule,
@@ -8912,8 +9140,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
8912
9140
  request,
8913
9141
  params,
8914
9142
  context,
8915
- unstable_pattern,
8916
- unstable_url,
9143
+ pattern,
9144
+ url,
8917
9145
  async serverAction() {
8918
9146
  preventInvalidServerHandlerCall("action", route);
8919
9147
  return fetchServerAction(singleFetch);
@@ -9108,7 +9336,13 @@ function getPartialManifest({ sri, ...manifest }, router) {
9108
9336
  segments.pop();
9109
9337
  }
9110
9338
  paths.forEach((path) => {
9111
- let matches = matchRoutes(router.routes, path, router.basename);
9339
+ let matches = matchRoutesImpl(
9340
+ router.routes,
9341
+ path,
9342
+ router.basename || "/",
9343
+ false,
9344
+ router.branches
9345
+ );
9112
9346
  if (matches) {
9113
9347
  matches.forEach((m) => routeIds.add(m.route.id));
9114
9348
  }
@@ -9707,7 +9941,7 @@ function Meta() {
9707
9941
  dangerouslySetInnerHTML: { __html: escapeHtml(json) }
9708
9942
  }
9709
9943
  );
9710
- } catch (err) {
9944
+ } catch (e) {
9711
9945
  return null;
9712
9946
  }
9713
9947
  }
@@ -9823,13 +10057,16 @@ import(${JSON.stringify(manifest.entry.module)});`;
9823
10057
  }
9824
10058
  ));
9825
10059
  }, []);
9826
- let preloads = isHydrated || isRSCRouterContext ? [] : dedupe(
9827
- manifest.entry.imports.concat(
9828
- getModuleLinkHrefs(matches, manifest, {
9829
- includeHydrateFallback: true
9830
- })
10060
+ let preloads = isHydrated || isRSCRouterContext ? [] : [
10061
+ // Dedupe through a Set
10062
+ ...new Set(
10063
+ manifest.entry.imports.concat(
10064
+ getModuleLinkHrefs(matches, manifest, {
10065
+ includeHydrateFallback: true
10066
+ })
10067
+ )
9831
10068
  )
9832
- );
10069
+ ];
9833
10070
  let sri = typeof manifest.sri === "object" ? manifest.sri : {};
9834
10071
  warnOnce(
9835
10072
  !isRSCRouterContext,
@@ -9855,6 +10092,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
9855
10092
  href: manifest.url,
9856
10093
  crossOrigin: scriptProps.crossOrigin,
9857
10094
  integrity: sri[manifest.url],
10095
+ nonce: scriptProps.nonce,
9858
10096
  suppressHydrationWarning: true
9859
10097
  }
9860
10098
  ) : null, /* @__PURE__ */ React8.createElement(
@@ -9864,6 +10102,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
9864
10102
  href: manifest.entry.module,
9865
10103
  crossOrigin: scriptProps.crossOrigin,
9866
10104
  integrity: sri[manifest.entry.module],
10105
+ nonce: scriptProps.nonce,
9867
10106
  suppressHydrationWarning: true
9868
10107
  }
9869
10108
  ), preloads.map((path) => /* @__PURE__ */ React8.createElement(
@@ -9874,13 +10113,11 @@ import(${JSON.stringify(manifest.entry.module)});`;
9874
10113
  href: path,
9875
10114
  crossOrigin: scriptProps.crossOrigin,
9876
10115
  integrity: sri[path],
10116
+ nonce: scriptProps.nonce,
9877
10117
  suppressHydrationWarning: true
9878
10118
  }
9879
10119
  )), initialScripts);
9880
10120
  }
9881
- function dedupe(array) {
9882
- return [...new Set(array)];
9883
- }
9884
10121
  function mergeRefs(...refs) {
9885
10122
  return (value) => {
9886
10123
  refs.forEach((ref) => {
@@ -9996,7 +10233,7 @@ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "un
9996
10233
  try {
9997
10234
  if (isBrowser2) {
9998
10235
  window.__reactRouterVersion = // @ts-expect-error
9999
- "7.14.2";
10236
+ "7.15.1";
10000
10237
  }
10001
10238
  } catch (e) {
10002
10239
  }
@@ -10013,7 +10250,7 @@ function createBrowserRouter(routes, opts) {
10013
10250
  dataStrategy: opts?.dataStrategy,
10014
10251
  patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
10015
10252
  window: opts?.window,
10016
- unstable_instrumentations: opts?.unstable_instrumentations
10253
+ instrumentations: opts?.instrumentations
10017
10254
  }).initialize();
10018
10255
  }
10019
10256
  function createHashRouter(routes, opts) {
@@ -10029,7 +10266,7 @@ function createHashRouter(routes, opts) {
10029
10266
  dataStrategy: opts?.dataStrategy,
10030
10267
  patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
10031
10268
  window: opts?.window,
10032
- unstable_instrumentations: opts?.unstable_instrumentations
10269
+ instrumentations: opts?.instrumentations
10033
10270
  }).initialize();
10034
10271
  }
10035
10272
  function parseHydrationData() {
@@ -10080,7 +10317,7 @@ function deserializeErrors(errors) {
10080
10317
  function BrowserRouter({
10081
10318
  basename,
10082
10319
  children,
10083
- unstable_useTransitions,
10320
+ useTransitions,
10084
10321
  window: window2
10085
10322
  }) {
10086
10323
  let historyRef = React10.useRef();
@@ -10094,13 +10331,13 @@ function BrowserRouter({
10094
10331
  });
10095
10332
  let setState = React10.useCallback(
10096
10333
  (newState) => {
10097
- if (unstable_useTransitions === false) {
10334
+ if (useTransitions === false) {
10098
10335
  setStateImpl(newState);
10099
10336
  } else {
10100
10337
  React10.startTransition(() => setStateImpl(newState));
10101
10338
  }
10102
10339
  },
10103
- [unstable_useTransitions]
10340
+ [useTransitions]
10104
10341
  );
10105
10342
  React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
10106
10343
  return /* @__PURE__ */ React10.createElement(
@@ -10111,14 +10348,14 @@ function BrowserRouter({
10111
10348
  location: state.location,
10112
10349
  navigationType: state.action,
10113
10350
  navigator: history,
10114
- unstable_useTransitions
10351
+ useTransitions
10115
10352
  }
10116
10353
  );
10117
10354
  }
10118
10355
  function HashRouter({
10119
10356
  basename,
10120
10357
  children,
10121
- unstable_useTransitions,
10358
+ useTransitions,
10122
10359
  window: window2
10123
10360
  }) {
10124
10361
  let historyRef = React10.useRef();
@@ -10132,13 +10369,13 @@ function HashRouter({
10132
10369
  });
10133
10370
  let setState = React10.useCallback(
10134
10371
  (newState) => {
10135
- if (unstable_useTransitions === false) {
10372
+ if (useTransitions === false) {
10136
10373
  setStateImpl(newState);
10137
10374
  } else {
10138
10375
  React10.startTransition(() => setStateImpl(newState));
10139
10376
  }
10140
10377
  },
10141
- [unstable_useTransitions]
10378
+ [useTransitions]
10142
10379
  );
10143
10380
  React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
10144
10381
  return /* @__PURE__ */ React10.createElement(
@@ -10149,7 +10386,7 @@ function HashRouter({
10149
10386
  location: state.location,
10150
10387
  navigationType: state.action,
10151
10388
  navigator: history,
10152
- unstable_useTransitions
10389
+ useTransitions
10153
10390
  }
10154
10391
  );
10155
10392
  }
@@ -10157,7 +10394,7 @@ function HistoryRouter({
10157
10394
  basename,
10158
10395
  children,
10159
10396
  history,
10160
- unstable_useTransitions
10397
+ useTransitions
10161
10398
  }) {
10162
10399
  let [state, setStateImpl] = React10.useState({
10163
10400
  action: history.action,
@@ -10165,13 +10402,13 @@ function HistoryRouter({
10165
10402
  });
10166
10403
  let setState = React10.useCallback(
10167
10404
  (newState) => {
10168
- if (unstable_useTransitions === false) {
10405
+ if (useTransitions === false) {
10169
10406
  setStateImpl(newState);
10170
10407
  } else {
10171
10408
  React10.startTransition(() => setStateImpl(newState));
10172
10409
  }
10173
10410
  },
10174
- [unstable_useTransitions]
10411
+ [useTransitions]
10175
10412
  );
10176
10413
  React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
10177
10414
  return /* @__PURE__ */ React10.createElement(
@@ -10182,7 +10419,7 @@ function HistoryRouter({
10182
10419
  location: state.location,
10183
10420
  navigationType: state.action,
10184
10421
  navigator: history,
10185
- unstable_useTransitions
10422
+ useTransitions
10186
10423
  }
10187
10424
  );
10188
10425
  }
@@ -10196,27 +10433,27 @@ var Link = React10.forwardRef(
10196
10433
  relative,
10197
10434
  reloadDocument,
10198
10435
  replace: replace2,
10199
- unstable_mask,
10436
+ mask,
10200
10437
  state,
10201
10438
  target,
10202
10439
  to,
10203
10440
  preventScrollReset,
10204
10441
  viewTransition,
10205
- unstable_defaultShouldRevalidate,
10442
+ defaultShouldRevalidate,
10206
10443
  ...rest
10207
10444
  }, forwardedRef) {
10208
- let { basename, navigator, unstable_useTransitions } = React10.useContext(NavigationContext);
10445
+ let { basename, navigator, useTransitions } = React10.useContext(NavigationContext);
10209
10446
  let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
10210
10447
  let parsed = parseToInfo(to, basename);
10211
10448
  to = parsed.to;
10212
10449
  let href = useHref(to, { relative });
10213
10450
  let location = useLocation();
10214
10451
  let maskedHref = null;
10215
- if (unstable_mask) {
10452
+ if (mask) {
10216
10453
  let resolved = resolveTo(
10217
- unstable_mask,
10454
+ mask,
10218
10455
  [],
10219
- location.unstable_mask ? location.unstable_mask.pathname : "/",
10456
+ location.mask ? location.mask.pathname : "/",
10220
10457
  true
10221
10458
  );
10222
10459
  if (basename !== "/") {
@@ -10230,14 +10467,14 @@ var Link = React10.forwardRef(
10230
10467
  );
10231
10468
  let internalOnClick = useLinkClickHandler(to, {
10232
10469
  replace: replace2,
10233
- unstable_mask,
10470
+ mask,
10234
10471
  state,
10235
10472
  target,
10236
10473
  preventScrollReset,
10237
10474
  relative,
10238
10475
  viewTransition,
10239
- unstable_defaultShouldRevalidate,
10240
- unstable_useTransitions
10476
+ defaultShouldRevalidate,
10477
+ useTransitions
10241
10478
  });
10242
10479
  function handleClick(event) {
10243
10480
  if (onClick) onClick(event);
@@ -10346,10 +10583,10 @@ var Form = React10.forwardRef(
10346
10583
  relative,
10347
10584
  preventScrollReset,
10348
10585
  viewTransition,
10349
- unstable_defaultShouldRevalidate,
10586
+ defaultShouldRevalidate,
10350
10587
  ...props
10351
10588
  }, forwardedRef) => {
10352
- let { unstable_useTransitions } = React10.useContext(NavigationContext);
10589
+ let { useTransitions } = React10.useContext(NavigationContext);
10353
10590
  let submit = useSubmit();
10354
10591
  let formAction = useFormAction(action, { relative });
10355
10592
  let formMethod = method.toLowerCase() === "get" ? "get" : "post";
@@ -10369,9 +10606,9 @@ var Form = React10.forwardRef(
10369
10606
  relative,
10370
10607
  preventScrollReset,
10371
10608
  viewTransition,
10372
- unstable_defaultShouldRevalidate
10609
+ defaultShouldRevalidate
10373
10610
  });
10374
- if (unstable_useTransitions && navigate !== false) {
10611
+ if (useTransitions && navigate !== false) {
10375
10612
  React10.startTransition(() => doSubmit());
10376
10613
  } else {
10377
10614
  doSubmit();
@@ -10465,13 +10702,13 @@ function useDataRouterState2(hookName) {
10465
10702
  function useLinkClickHandler(to, {
10466
10703
  target,
10467
10704
  replace: replaceProp,
10468
- unstable_mask,
10705
+ mask,
10469
10706
  state,
10470
10707
  preventScrollReset,
10471
10708
  relative,
10472
10709
  viewTransition,
10473
- unstable_defaultShouldRevalidate,
10474
- unstable_useTransitions
10710
+ defaultShouldRevalidate,
10711
+ useTransitions
10475
10712
  } = {}) {
10476
10713
  let navigate = useNavigate();
10477
10714
  let location = useLocation();
@@ -10483,14 +10720,14 @@ function useLinkClickHandler(to, {
10483
10720
  let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
10484
10721
  let doNavigate = () => navigate(to, {
10485
10722
  replace: replace2,
10486
- unstable_mask,
10723
+ mask,
10487
10724
  state,
10488
10725
  preventScrollReset,
10489
10726
  relative,
10490
10727
  viewTransition,
10491
- unstable_defaultShouldRevalidate
10728
+ defaultShouldRevalidate
10492
10729
  });
10493
- if (unstable_useTransitions) {
10730
+ if (useTransitions) {
10494
10731
  React10.startTransition(() => doNavigate());
10495
10732
  } else {
10496
10733
  doNavigate();
@@ -10502,15 +10739,15 @@ function useLinkClickHandler(to, {
10502
10739
  navigate,
10503
10740
  path,
10504
10741
  replaceProp,
10505
- unstable_mask,
10742
+ mask,
10506
10743
  state,
10507
10744
  target,
10508
10745
  to,
10509
10746
  preventScrollReset,
10510
10747
  relative,
10511
10748
  viewTransition,
10512
- unstable_defaultShouldRevalidate,
10513
- unstable_useTransitions
10749
+ defaultShouldRevalidate,
10750
+ useTransitions
10514
10751
  ]
10515
10752
  );
10516
10753
  }
@@ -10564,7 +10801,7 @@ function useSubmit() {
10564
10801
  if (options.navigate === false) {
10565
10802
  let key = options.fetcherKey || getUniqueFetcherId();
10566
10803
  await routerFetch(key, currentRouteId, options.action || action, {
10567
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
10804
+ defaultShouldRevalidate: options.defaultShouldRevalidate,
10568
10805
  preventScrollReset: options.preventScrollReset,
10569
10806
  formData,
10570
10807
  body,
@@ -10574,7 +10811,7 @@ function useSubmit() {
10574
10811
  });
10575
10812
  } else {
10576
10813
  await routerNavigate(options.action || action, {
10577
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
10814
+ defaultShouldRevalidate: options.defaultShouldRevalidate,
10578
10815
  preventScrollReset: options.preventScrollReset,
10579
10816
  formData,
10580
10817
  body,
@@ -10690,10 +10927,13 @@ function useFetcher({
10690
10927
  }
10691
10928
  function useFetchers() {
10692
10929
  let state = useDataRouterState2("useFetchers" /* UseFetchers */);
10693
- return Array.from(state.fetchers.entries()).map(([key, fetcher]) => ({
10694
- ...fetcher,
10695
- key
10696
- }));
10930
+ return React10.useMemo(
10931
+ () => Array.from(state.fetchers.entries()).map(([key, fetcher]) => ({
10932
+ ...fetcher,
10933
+ key
10934
+ })),
10935
+ [state.fetchers]
10936
+ );
10697
10937
  }
10698
10938
  var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
10699
10939
  var savedScrollPositions = {};
@@ -10884,7 +11124,7 @@ function StaticRouter({
10884
11124
  hash: locationProp.hash || "",
10885
11125
  state: locationProp.state != null ? locationProp.state : null,
10886
11126
  key: locationProp.key || "default",
10887
- unstable_mask: void 0
11127
+ mask: void 0
10888
11128
  };
10889
11129
  let staticNavigator = getStatelessNavigator();
10890
11130
  return /* @__PURE__ */ React11.createElement(
@@ -10896,7 +11136,7 @@ function StaticRouter({
10896
11136
  navigationType: action,
10897
11137
  navigator: staticNavigator,
10898
11138
  static: true,
10899
- unstable_useTransitions: false
11139
+ useTransitions: false
10900
11140
  }
10901
11141
  );
10902
11142
  }
@@ -10937,11 +11177,12 @@ function StaticRouterProvider({
10937
11177
  navigationType: state.historyAction,
10938
11178
  navigator: dataRouterContext.navigator,
10939
11179
  static: dataRouterContext.static,
10940
- unstable_useTransitions: false
11180
+ useTransitions: false
10941
11181
  },
10942
11182
  /* @__PURE__ */ React11.createElement(
10943
- DataRoutes,
11183
+ DataRoutes2,
10944
11184
  {
11185
+ manifest: router.manifest,
10945
11186
  routes: router.routes,
10946
11187
  future: router.future,
10947
11188
  state,
@@ -11040,7 +11281,7 @@ function createStaticRouter(routes, context, opts = {}) {
11040
11281
  get future() {
11041
11282
  return {
11042
11283
  v8_middleware: false,
11043
- unstable_passThroughRequests: false,
11284
+ v8_passThroughRequests: false,
11044
11285
  ...opts?.future
11045
11286
  };
11046
11287
  },
@@ -11065,6 +11306,12 @@ function createStaticRouter(routes, context, opts = {}) {
11065
11306
  get routes() {
11066
11307
  return dataRoutes;
11067
11308
  },
11309
+ get branches() {
11310
+ return opts.branches;
11311
+ },
11312
+ get manifest() {
11313
+ return manifest;
11314
+ },
11068
11315
  get window() {
11069
11316
  return void 0;
11070
11317
  },
@@ -11145,6 +11392,7 @@ export {
11145
11392
  RouterContextProvider,
11146
11393
  convertRoutesToDataRoutes,
11147
11394
  matchRoutes,
11395
+ matchRoutesImpl,
11148
11396
  generatePath,
11149
11397
  matchPath,
11150
11398
  stripBasename,
@@ -11202,6 +11450,7 @@ export {
11202
11450
  useAsyncError,
11203
11451
  useBlocker,
11204
11452
  useRoute,
11453
+ useRouterState,
11205
11454
  warnOnce,
11206
11455
  mapRouteProperties,
11207
11456
  hydrationRouteProperties,
@@ -11242,6 +11491,7 @@ export {
11242
11491
  noActionDefinedError,
11243
11492
  createClientRoutes,
11244
11493
  shouldHydrateRouteLoader,
11494
+ URL_LIMIT,
11245
11495
  getPatchRoutesOnNavigationFunction,
11246
11496
  useFogOFWarDiscovery,
11247
11497
  getManifestPath,