react-router 0.0.0-experimental-213e4b178 → 0.0.0-experimental-0be18542a

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 (43) hide show
  1. package/dist/development/{browser-CYoCBM_s.d.mts → browser-D6LL53bK.d.mts} +1 -1
  2. package/dist/development/{browser-vPEOwWRD.d.ts → browser-cstcbNCb.d.ts} +1 -1
  3. package/dist/development/{chunk-KO5HLSX2.mjs → chunk-GCL7JN2I.mjs} +158 -134
  4. package/dist/development/dom-export.d.mts +2 -2
  5. package/dist/development/dom-export.d.ts +2 -2
  6. package/dist/development/dom-export.js +222 -190
  7. package/dist/development/dom-export.mjs +2 -2
  8. package/dist/development/index.d.mts +4 -4
  9. package/dist/development/index.d.ts +4 -4
  10. package/dist/development/index.js +158 -134
  11. package/dist/development/index.mjs +2 -2
  12. package/dist/development/lib/types/route-module.d.mts +1 -1
  13. package/dist/development/lib/types/route-module.d.ts +1 -1
  14. package/dist/development/lib/types/route-module.js +1 -1
  15. package/dist/development/lib/types/route-module.mjs +1 -1
  16. package/dist/{production/route-data-BaZTTsr9.d.mts → development/route-data-D8Uf5Cm-.d.mts} +3 -1
  17. package/dist/{production/route-data-BaZTTsr9.d.ts → development/route-data-D8Uf5Cm-.d.ts} +3 -1
  18. package/dist/development/server.d.mts +3 -1
  19. package/dist/development/server.d.ts +3 -1
  20. package/dist/development/server.js +54 -53
  21. package/dist/development/server.mjs +54 -53
  22. package/dist/production/{browser-CYoCBM_s.d.mts → browser-D6LL53bK.d.mts} +1 -1
  23. package/dist/production/{browser-vPEOwWRD.d.ts → browser-cstcbNCb.d.ts} +1 -1
  24. package/dist/production/{chunk-A54HSCHT.mjs → chunk-LKN6HKRD.mjs} +158 -134
  25. package/dist/production/dom-export.d.mts +2 -2
  26. package/dist/production/dom-export.d.ts +2 -2
  27. package/dist/production/dom-export.js +222 -190
  28. package/dist/production/dom-export.mjs +2 -2
  29. package/dist/production/index.d.mts +4 -4
  30. package/dist/production/index.d.ts +4 -4
  31. package/dist/production/index.js +158 -134
  32. package/dist/production/index.mjs +2 -2
  33. package/dist/production/lib/types/route-module.d.mts +1 -1
  34. package/dist/production/lib/types/route-module.d.ts +1 -1
  35. package/dist/production/lib/types/route-module.js +1 -1
  36. package/dist/production/lib/types/route-module.mjs +1 -1
  37. package/dist/{development/route-data-BaZTTsr9.d.ts → production/route-data-D8Uf5Cm-.d.mts} +3 -1
  38. package/dist/{development/route-data-BaZTTsr9.d.mts → production/route-data-D8Uf5Cm-.d.ts} +3 -1
  39. package/dist/production/server.d.mts +3 -1
  40. package/dist/production/server.d.ts +3 -1
  41. package/dist/production/server.js +54 -53
  42. package/dist/production/server.mjs +54 -53
  43. package/package.json +20 -1
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { k as RouteObject, R as RouterInit, F as FutureConfig$1, H as HydrationState, I as InitialEntry, D as DataStrategyFunction, as as PatchRoutesOnNavigationFunction, a as Router$1, T as To, d as RelativeRoutingType, y as NonIndexRouteObject, a3 as LazyRouteFunction, s as IndexRouteObject, e as Location, f as Action, ar as Navigator, au as RouteMatch, p as StaticHandlerContext, c as RouteManifest, b as RouteModules, aq as DataRouteObject, aT as RouteModule, a2 as HTMLFormMethod, a0 as FormEncType, aD as PageLinkDescriptor, aU as History, J as GetScrollRestorationKeyFunction, N as NavigateOptions, K as Fetcher, n as SerializeFrom, B as BlockerFunction, av as ClientActionFunction, ax as ClientLoaderFunction, x as LinksFunction, w as MetaFunction, a8 as ShouldRevalidateFunction, j as Params, v as ActionFunction, t as LoaderFunction } from './route-data-BaZTTsr9.mjs';
2
+ import { k as RouteObject, R as RouterInit, F as FutureConfig$1, H as HydrationState, I as InitialEntry, D as DataStrategyFunction, as as PatchRoutesOnNavigationFunction, a as Router$1, T as To, d as RelativeRoutingType, y as NonIndexRouteObject, a3 as LazyRouteFunction, s as IndexRouteObject, e as Location, f as Action, ar as Navigator, au as RouteMatch, p as StaticHandlerContext, c as RouteManifest, b as RouteModules, aq as DataRouteObject, aT as RouteModule, a2 as HTMLFormMethod, a0 as FormEncType, aD as PageLinkDescriptor, aU as History, J as GetScrollRestorationKeyFunction, N as NavigateOptions, K as Fetcher, n as SerializeFrom, B as BlockerFunction, av as ClientActionFunction, ax as ClientLoaderFunction, x as LinksFunction, w as MetaFunction, a8 as ShouldRevalidateFunction, j as Params, v as ActionFunction, t as LoaderFunction } from './route-data-D8Uf5Cm-.mjs';
3
3
 
4
4
  /**
5
5
  * @private
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { k as RouteObject, R as RouterInit, F as FutureConfig$1, H as HydrationState, I as InitialEntry, D as DataStrategyFunction, as as PatchRoutesOnNavigationFunction, a as Router$1, T as To, d as RelativeRoutingType, y as NonIndexRouteObject, a3 as LazyRouteFunction, s as IndexRouteObject, e as Location, f as Action, ar as Navigator, au as RouteMatch, p as StaticHandlerContext, c as RouteManifest, b as RouteModules, aq as DataRouteObject, aT as RouteModule, a2 as HTMLFormMethod, a0 as FormEncType, aD as PageLinkDescriptor, aU as History, J as GetScrollRestorationKeyFunction, N as NavigateOptions, K as Fetcher, n as SerializeFrom, B as BlockerFunction, av as ClientActionFunction, ax as ClientLoaderFunction, x as LinksFunction, w as MetaFunction, a8 as ShouldRevalidateFunction, j as Params, v as ActionFunction, t as LoaderFunction } from './route-data-BaZTTsr9.js';
2
+ import { k as RouteObject, R as RouterInit, F as FutureConfig$1, H as HydrationState, I as InitialEntry, D as DataStrategyFunction, as as PatchRoutesOnNavigationFunction, a as Router$1, T as To, d as RelativeRoutingType, y as NonIndexRouteObject, a3 as LazyRouteFunction, s as IndexRouteObject, e as Location, f as Action, ar as Navigator, au as RouteMatch, p as StaticHandlerContext, c as RouteManifest, b as RouteModules, aq as DataRouteObject, aT as RouteModule, a2 as HTMLFormMethod, a0 as FormEncType, aD as PageLinkDescriptor, aU as History, J as GetScrollRestorationKeyFunction, N as NavigateOptions, K as Fetcher, n as SerializeFrom, B as BlockerFunction, av as ClientActionFunction, ax as ClientLoaderFunction, x as LinksFunction, w as MetaFunction, a8 as ShouldRevalidateFunction, j as Params, v as ActionFunction, t as LoaderFunction } from './route-data-D8Uf5Cm-.js';
3
3
 
4
4
  /**
5
5
  * @private
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-213e4b178
2
+ * react-router v0.0.0-experimental-0be18542a
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -413,7 +413,7 @@ function isUnsupportedLazyRouteFunctionKey(key) {
413
413
  function isIndexRoute(route) {
414
414
  return route.index === true;
415
415
  }
416
- function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}) {
416
+ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}, allowInPlaceMutations = false) {
417
417
  return routes.map((route, index) => {
418
418
  let treePath = [...parentPath, String(index)];
419
419
  let id = typeof route.id === "string" ? route.id : treePath.join("-");
@@ -421,6 +421,10 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
421
421
  route.index !== true || !route.children,
422
422
  `Cannot specify children on an index route`
423
423
  );
424
+ invariant(
425
+ allowInPlaceMutations || !manifest[id],
426
+ `Found a route id collision on id "${id}". Route id's must be globally unique within Data Router usages`
427
+ );
424
428
  if (isIndexRoute(route)) {
425
429
  let indexRoute = {
426
430
  ...route,
@@ -442,7 +446,8 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
442
446
  route.children,
443
447
  mapRouteProperties2,
444
448
  treePath,
445
- manifest
449
+ manifest,
450
+ allowInPlaceMutations
446
451
  );
447
452
  }
448
453
  return pathOrLayoutRoute;
@@ -955,7 +960,6 @@ function createRouter(init) {
955
960
  manifest
956
961
  );
957
962
  let inFlightDataRoutes;
958
- let routesPatched = false;
959
963
  let basename = init.basename || "/";
960
964
  let dataStrategyImpl = init.dataStrategy || defaultDataStrategyWithMiddleware;
961
965
  let future = {
@@ -1132,6 +1136,12 @@ function createRouter(init) {
1132
1136
  return () => subscribers.delete(fn);
1133
1137
  }
1134
1138
  function updateState(newState, opts = {}) {
1139
+ if (newState.matches) {
1140
+ newState.matches = newState.matches.map((m) => {
1141
+ let route = manifest[m.route.id];
1142
+ return { ...m, route };
1143
+ });
1144
+ }
1135
1145
  state = {
1136
1146
  ...state,
1137
1147
  ...newState
@@ -1163,10 +1173,6 @@ function createRouter(init) {
1163
1173
  mountedFetchers.forEach((key) => state.fetchers.delete(key));
1164
1174
  }
1165
1175
  function completeNavigation(location2, newState, { flushSync } = {}) {
1166
- if (routesPatched) {
1167
- newState.matches = matchRoutes(dataRoutes, location2) ?? newState.matches;
1168
- routesPatched = false;
1169
- }
1170
1176
  let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && location2.state?._isRedirect !== true;
1171
1177
  let actionData;
1172
1178
  if (newState.actionData) {
@@ -2567,7 +2573,8 @@ function createRouter(init) {
2567
2573
  children,
2568
2574
  routesToUse,
2569
2575
  localManifest,
2570
- mapRouteProperties2
2576
+ mapRouteProperties2,
2577
+ false
2571
2578
  );
2572
2579
  }
2573
2580
  });
@@ -2608,7 +2615,7 @@ function createRouter(init) {
2608
2615
  manifest
2609
2616
  );
2610
2617
  }
2611
- function patchRoutes(routeId, children) {
2618
+ function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
2612
2619
  let isNonHMR = inFlightDataRoutes == null;
2613
2620
  let routesToUse = inFlightDataRoutes || dataRoutes;
2614
2621
  patchRoutesImpl(
@@ -2616,9 +2623,9 @@ function createRouter(init) {
2616
2623
  children,
2617
2624
  routesToUse,
2618
2625
  manifest,
2619
- mapRouteProperties2
2626
+ mapRouteProperties2,
2627
+ unstable_allowElementMutations
2620
2628
  );
2621
- routesPatched = true;
2622
2629
  if (isNonHMR) {
2623
2630
  dataRoutes = [...dataRoutes];
2624
2631
  updateState({});
@@ -2661,10 +2668,6 @@ function createRouter(init) {
2661
2668
  // updating the tree while validating the update algorithm.
2662
2669
  _internalSetRoutes,
2663
2670
  _internalSetStateDoNotUseOrYouWillBreakYourApp(newState) {
2664
- if (routesPatched) {
2665
- newState.matches = matchRoutes(dataRoutes, location) ?? newState.matches;
2666
- routesPatched = false;
2667
- }
2668
2671
  updateState(newState);
2669
2672
  }
2670
2673
  };
@@ -3617,24 +3620,10 @@ function shouldRevalidateLoader(loaderMatch, arg) {
3617
3620
  }
3618
3621
  return arg.defaultShouldRevalidate;
3619
3622
  }
3620
- function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2) {
3621
- const findRouteRecursively = (id, routes = routesToUse) => {
3622
- for (const route of routes) {
3623
- if (route.id === id) {
3624
- return route;
3625
- }
3626
- if (route.children) {
3627
- const found = findRouteRecursively(id, route.children);
3628
- if (found) {
3629
- return found;
3630
- }
3631
- }
3632
- }
3633
- return null;
3634
- };
3623
+ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
3635
3624
  let childrenToPatch;
3636
3625
  if (routeId) {
3637
- let route = findRouteRecursively(routeId);
3626
+ let route = findRouteRecursively(routeId, routesToUse);
3638
3627
  invariant(
3639
3628
  route,
3640
3629
  `No route found to patch children into: routeId = ${routeId}`
@@ -3646,27 +3635,74 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
3646
3635
  } else {
3647
3636
  childrenToPatch = routesToUse;
3648
3637
  }
3649
- let newRoutes = convertRoutesToDataRoutes(
3650
- children,
3651
- mapRouteProperties2,
3652
- [routeId || "_", "patch", String(childrenToPatch?.length || "0")],
3653
- manifest
3654
- );
3655
- for (const newRoute of newRoutes) {
3656
- const existingRoute = childrenToPatch.find((r) => r.id === newRoute.id);
3638
+ let uniqueChildren = [];
3639
+ let existingChildren = [];
3640
+ children.forEach((newRoute) => {
3641
+ let existingRoute = childrenToPatch.find(
3642
+ (existingRoute2) => isSameRoute(newRoute, existingRoute2)
3643
+ );
3657
3644
  if (existingRoute) {
3658
- let anyRoute = newRoute;
3659
- if (anyRoute.element) {
3660
- Object.assign(existingRoute, newRoute, {
3661
- element: anyRoute.element,
3662
- errorElement: anyRoute.errorElement,
3663
- hydrateFallbackElement: anyRoute.hydrateFallbackElement
3664
- });
3665
- }
3645
+ existingChildren.push({ existingRoute, newRoute });
3666
3646
  } else {
3667
- childrenToPatch.push(newRoute);
3647
+ uniqueChildren.push(newRoute);
3648
+ }
3649
+ });
3650
+ if (uniqueChildren.length > 0) {
3651
+ let newRoutes = convertRoutesToDataRoutes(
3652
+ uniqueChildren,
3653
+ mapRouteProperties2,
3654
+ [routeId || "_", "patch", String(childrenToPatch?.length || "0")],
3655
+ manifest
3656
+ );
3657
+ childrenToPatch.push(...newRoutes);
3658
+ }
3659
+ if (allowElementMutations && existingChildren.length > 0) {
3660
+ for (let i = 0; i < existingChildren.length; i++) {
3661
+ let { existingRoute, newRoute } = existingChildren[i];
3662
+ let existingRouteAny = existingRoute;
3663
+ let [newRouteAny] = convertRoutesToDataRoutes(
3664
+ [newRoute],
3665
+ mapRouteProperties2,
3666
+ [],
3667
+ // Doesn't matter for mutated routes since they already have an id
3668
+ manifest,
3669
+ true
3670
+ );
3671
+ Object.assign(existingRouteAny, {
3672
+ element: newRouteAny.element ? newRouteAny.element : existingRouteAny.element,
3673
+ errorElement: newRouteAny.errorElement ? newRouteAny.errorElement : existingRouteAny.errorElement,
3674
+ hydrateFallbackElement: newRouteAny.hydrateFallbackElement ? newRouteAny.hydrateFallbackElement : existingRouteAny.hydrateFallbackElement
3675
+ });
3676
+ }
3677
+ }
3678
+ }
3679
+ function isSameRoute(newRoute, existingRoute) {
3680
+ if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
3681
+ return true;
3682
+ }
3683
+ if (!(newRoute.index === existingRoute.index && newRoute.path === existingRoute.path && newRoute.caseSensitive === existingRoute.caseSensitive)) {
3684
+ return false;
3685
+ }
3686
+ if ((!newRoute.children || newRoute.children.length === 0) && (!existingRoute.children || existingRoute.children.length === 0)) {
3687
+ return true;
3688
+ }
3689
+ return newRoute.children.every(
3690
+ (aChild, i) => existingRoute.children?.some((bChild) => isSameRoute(aChild, bChild))
3691
+ );
3692
+ }
3693
+ function findRouteRecursively(id, routes) {
3694
+ for (const route of routes) {
3695
+ if (route.id === id) {
3696
+ return route;
3697
+ }
3698
+ if (route.children) {
3699
+ const found = findRouteRecursively(id, route.children);
3700
+ if (found) {
3701
+ return found;
3702
+ }
3668
3703
  }
3669
3704
  }
3705
+ return null;
3670
3706
  }
3671
3707
  var lazyRoutePropertyCache = /* @__PURE__ */ new WeakMap();
3672
3708
  var loadLazyRouteProperty = ({
@@ -6431,12 +6467,7 @@ function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode,
6431
6467
  return nonSsrStrategy(args, getRouteInfo, fetchAndDecode, basename);
6432
6468
  }
6433
6469
  if (fetcherKey) {
6434
- return singleFetchLoaderFetcherStrategy(
6435
- request,
6436
- matches,
6437
- fetchAndDecode,
6438
- basename
6439
- );
6470
+ return singleFetchLoaderFetcherStrategy(args, fetchAndDecode, basename);
6440
6471
  }
6441
6472
  return singleFetchLoaderNavigationStrategy(
6442
6473
  args,
@@ -6448,13 +6479,13 @@ function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode,
6448
6479
  );
6449
6480
  };
6450
6481
  }
6451
- async function singleFetchActionStrategy({ request, matches }, fetchAndDecode, basename) {
6452
- let actionMatch = matches.find((m) => m.unstable_shouldCallHandler());
6482
+ async function singleFetchActionStrategy(args, fetchAndDecode, basename) {
6483
+ let actionMatch = args.matches.find((m) => m.unstable_shouldCallHandler());
6453
6484
  invariant2(actionMatch, "No action match found");
6454
6485
  let actionStatus = void 0;
6455
6486
  let result = await actionMatch.resolve(async (handler) => {
6456
6487
  let result2 = await handler(async () => {
6457
- let { data: data2, status } = await fetchAndDecode(request, basename, [
6488
+ let { data: data2, status } = await fetchAndDecode(args, basename, [
6458
6489
  actionMatch.route.id
6459
6490
  ]);
6460
6491
  actionStatus = status;
@@ -6472,8 +6503,10 @@ async function singleFetchActionStrategy({ request, matches }, fetchAndDecode, b
6472
6503
  }
6473
6504
  };
6474
6505
  }
6475
- async function nonSsrStrategy({ request, matches }, getRouteInfo, fetchAndDecode, basename) {
6476
- let matchesToLoad = matches.filter((m) => m.unstable_shouldCallHandler());
6506
+ async function nonSsrStrategy(args, getRouteInfo, fetchAndDecode, basename) {
6507
+ let matchesToLoad = args.matches.filter(
6508
+ (m) => m.unstable_shouldCallHandler()
6509
+ );
6477
6510
  let results = {};
6478
6511
  await Promise.all(
6479
6512
  matchesToLoad.map(
@@ -6482,9 +6515,7 @@ async function nonSsrStrategy({ request, matches }, getRouteInfo, fetchAndDecode
6482
6515
  let { hasClientLoader } = getRouteInfo(m);
6483
6516
  let routeId = m.route.id;
6484
6517
  let result = hasClientLoader ? await handler(async () => {
6485
- let { data: data2 } = await fetchAndDecode(request, basename, [
6486
- routeId
6487
- ]);
6518
+ let { data: data2 } = await fetchAndDecode(args, basename, [routeId]);
6488
6519
  return unwrapSingleFetchResult(data2, routeId);
6489
6520
  }) : await handler();
6490
6521
  results[m.route.id] = { type: "data", result };
@@ -6496,14 +6527,14 @@ async function nonSsrStrategy({ request, matches }, getRouteInfo, fetchAndDecode
6496
6527
  );
6497
6528
  return results;
6498
6529
  }
6499
- async function singleFetchLoaderNavigationStrategy({ request, matches }, router, getRouteInfo, fetchAndDecode, ssr, basename) {
6530
+ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, basename) {
6500
6531
  let routesParams = /* @__PURE__ */ new Set();
6501
6532
  let foundOptOutRoute = false;
6502
- let routeDfds = matches.map(() => createDeferred2());
6533
+ let routeDfds = args.matches.map(() => createDeferred2());
6503
6534
  let singleFetchDfd = createDeferred2();
6504
6535
  let results = {};
6505
6536
  let resolvePromise = Promise.all(
6506
- matches.map(
6537
+ args.matches.map(
6507
6538
  async (m, i) => m.resolve(async (handler) => {
6508
6539
  routeDfds[i].resolve();
6509
6540
  let routeId = m.route.id;
@@ -6522,7 +6553,7 @@ async function singleFetchLoaderNavigationStrategy({ request, matches }, router,
6522
6553
  }
6523
6554
  try {
6524
6555
  let result = await handler(async () => {
6525
- let { data: data2 } = await fetchAndDecode(request, basename, [routeId]);
6556
+ let { data: data2 } = await fetchAndDecode(args, basename, [routeId]);
6526
6557
  return unwrapSingleFetchResult(data2, routeId);
6527
6558
  });
6528
6559
  results[routeId] = { type: "data", result };
@@ -6552,7 +6583,7 @@ async function singleFetchLoaderNavigationStrategy({ request, matches }, router,
6552
6583
  } else {
6553
6584
  let targetRoutes = ssr && foundOptOutRoute && routesParams.size > 0 ? [...routesParams.keys()] : void 0;
6554
6585
  try {
6555
- let data2 = await fetchAndDecode(request, basename, targetRoutes);
6586
+ let data2 = await fetchAndDecode(args, basename, targetRoutes);
6556
6587
  singleFetchDfd.resolve(data2.data);
6557
6588
  } catch (e) {
6558
6589
  singleFetchDfd.reject(e);
@@ -6561,13 +6592,13 @@ async function singleFetchLoaderNavigationStrategy({ request, matches }, router,
6561
6592
  await resolvePromise;
6562
6593
  return results;
6563
6594
  }
6564
- async function singleFetchLoaderFetcherStrategy(request, matches, fetchAndDecode, basename) {
6565
- let fetcherMatch = matches.find((m) => m.unstable_shouldCallHandler());
6595
+ async function singleFetchLoaderFetcherStrategy(args, fetchAndDecode, basename) {
6596
+ let fetcherMatch = args.matches.find((m) => m.unstable_shouldCallHandler());
6566
6597
  invariant2(fetcherMatch, "No fetcher match found");
6567
6598
  let routeId = fetcherMatch.route.id;
6568
6599
  let result = await fetcherMatch.resolve(
6569
6600
  async (handler) => handler(async () => {
6570
- let { data: data2 } = await fetchAndDecode(request, basename, [routeId]);
6601
+ let { data: data2 } = await fetchAndDecode(args, basename, [routeId]);
6571
6602
  return unwrapSingleFetchResult(data2, routeId);
6572
6603
  })
6573
6604
  );
@@ -6603,7 +6634,8 @@ function singleFetchUrl(reqUrl, basename, extension) {
6603
6634
  }
6604
6635
  return url;
6605
6636
  }
6606
- var fetchAndDecodeViaTurboStream = async (request, basename, targetRoutes) => {
6637
+ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
6638
+ let { request } = args;
6607
6639
  let url = singleFetchUrl(request.url, basename, "data");
6608
6640
  if (request.method === "GET") {
6609
6641
  url = stripIndexParam(url);
@@ -6650,7 +6682,7 @@ var fetchAndDecodeViaTurboStream = async (request, basename, targetRoutes) => {
6650
6682
  } catch (e) {
6651
6683
  throw new Error("Unable to decode turbo-stream response");
6652
6684
  }
6653
- };
6685
+ }
6654
6686
  function decodeViaTurboStream(body, global2) {
6655
6687
  return decode(body, {
6656
6688
  plugins: [
@@ -7947,7 +7979,7 @@ function mergeRefs(...refs) {
7947
7979
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7948
7980
  try {
7949
7981
  if (isBrowser) {
7950
- window.__reactRouterVersion = "0.0.0-experimental-213e4b178";
7982
+ window.__reactRouterVersion = "0.0.0-experimental-0be18542a";
7951
7983
  }
7952
7984
  } catch (e) {
7953
7985
  }
@@ -10801,10 +10833,13 @@ async function matchServerRequest({
10801
10833
  }
10802
10834
  const getRenderPayload = async () => {
10803
10835
  const handler = createStaticHandler(routes);
10836
+ let method = request.method.toUpperCase();
10837
+ let skipRevalidation = method !== "GET" && method !== "HEAD";
10804
10838
  let url2 = new URL(request.url);
10805
- let routeIdsToLoad = url2.searchParams.has("_routes") ? url2.searchParams.get("_routes").split(",") : null;
10839
+ let routeIdsToLoad = skipRevalidation ? [] : url2.searchParams.has("_routes") ? url2.searchParams.get("_routes").split(",") : null;
10806
10840
  const staticContext = await handler.query(request, {
10807
10841
  skipLoaderErrorBubbling: true,
10842
+ skipRevalidation,
10808
10843
  ...routeIdsToLoad ? {
10809
10844
  filterMatchesToLoad: (m) => routeIdsToLoad.includes(m.route.id)
10810
10845
  } : null
@@ -10830,10 +10865,7 @@ async function matchServerRequest({
10830
10865
  const HydrateFallback = match.route.HydrateFallback;
10831
10866
  const element = Component4 ? React14.createElement(
10832
10867
  Layout,
10833
- {
10834
- loaderData: staticContext.loaderData[match.route.id],
10835
- actionData: staticContext.actionData?.[match.route.id]
10836
- },
10868
+ null,
10837
10869
  React14.createElement(Component4, {
10838
10870
  loaderData: staticContext.loaderData[match.route.id],
10839
10871
  actionData: staticContext.actionData?.[match.route.id]
@@ -10841,18 +10873,14 @@ async function matchServerRequest({
10841
10873
  ) : void 0;
10842
10874
  const errorElement = ErrorBoundary ? React14.createElement(
10843
10875
  Layout,
10844
- {
10845
- loaderData: staticContext.loaderData[match.route.id],
10846
- actionData: staticContext.actionData?.[match.route.id]
10847
- },
10848
- React14.createElement(ErrorBoundary)
10876
+ null,
10877
+ React14.createElement(ErrorBoundary, {
10878
+ error: staticContext.errors?.[match.route.id]
10879
+ })
10849
10880
  ) : void 0;
10850
10881
  const hydrateFallbackElement = HydrateFallback ? React14.createElement(
10851
10882
  Layout,
10852
- {
10853
- loaderData: staticContext.loaderData[match.route.id],
10854
- actionData: staticContext.actionData?.[match.route.id]
10855
- },
10883
+ null,
10856
10884
  React14.createElement(HydrateFallback, {
10857
10885
  loaderData: staticContext.loaderData[match.route.id],
10858
10886
  actionData: staticContext.actionData?.[match.route.id]
@@ -11003,18 +11031,15 @@ function createCallServer({
11003
11031
  landedActionId = actionId;
11004
11032
  let lastMatch;
11005
11033
  for (const match of rendered.matches) {
11006
- window.__router.patchRoutes(lastMatch?.id ?? null, [
11007
- createRouteFromServerManifest(match)
11008
- ]);
11034
+ window.__router.patchRoutes(
11035
+ lastMatch?.id ?? null,
11036
+ [createRouteFromServerManifest(match)],
11037
+ true
11038
+ );
11009
11039
  lastMatch = match;
11010
11040
  }
11011
11041
  React15.startTransition(() => {
11012
11042
  window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({
11013
- actionData: Object.assign(
11014
- {},
11015
- window.__router.state.actionData,
11016
- rendered.actionData
11017
- ),
11018
11043
  loaderData: Object.assign(
11019
11044
  {},
11020
11045
  window.__router.state.loaderData,
@@ -11055,21 +11080,20 @@ function createRouterFromPayload({
11055
11080
  loaderData: payload.loaderData
11056
11081
  },
11057
11082
  routes,
11058
- async patchRoutesOnNavigation({ matches, patch, path, signal }) {
11059
- const response = await fetch(`${path}.manifest`, { signal });
11083
+ async patchRoutesOnNavigation({ patch, path, signal }) {
11084
+ let response = await fetch(`${path}.manifest`, { signal });
11060
11085
  if (!response.body || response.status < 200 || response.status >= 300) {
11061
- return;
11086
+ throw new Error("Unable to fetch new route matches from the server");
11062
11087
  }
11063
- const payload2 = await decode2(response.body);
11088
+ let payload2 = await decode2(response.body);
11064
11089
  if (payload2.type !== "manifest") {
11065
11090
  throw new Error("Failed to patch routes on navigation");
11066
11091
  }
11067
- const existingIds = new Set(matches.map((m) => m.route.id));
11068
- let lastMatch;
11069
- for (const match of payload2.matches) {
11070
- patch(lastMatch?.id ?? null, [createRouteFromServerManifest(match)]);
11071
- lastMatch = match;
11072
- }
11092
+ payload2.matches.forEach(
11093
+ (match, i) => patch(payload2.matches[i - 1]?.id ?? null, [
11094
+ createRouteFromServerManifest(match)
11095
+ ])
11096
+ );
11073
11097
  },
11074
11098
  // FIXME: Pass `build.ssr` and `build.basename` into this function
11075
11099
  dataStrategy: getRSCSingleFetchDataStrategy(
@@ -11092,7 +11116,7 @@ function createRouterFromPayload({
11092
11116
  }
11093
11117
  return window.__router;
11094
11118
  }
11095
- var requestRenderedRouteCache = /* @__PURE__ */ new WeakMap();
11119
+ var renderedRoutesContext = unstable_createContext();
11096
11120
  function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, decode2) {
11097
11121
  let dataStrategy = getSingleFetchDataStrategyImpl(
11098
11122
  getRouter,
@@ -11112,24 +11136,28 @@ function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, decode2) {
11112
11136
  basename
11113
11137
  );
11114
11138
  return async (args) => args.unstable_runClientMiddleware(async () => {
11115
- const renderedRoutes = [];
11116
- requestRenderedRouteCache.set(args.request, renderedRoutes);
11139
+ let context = args.context;
11140
+ context.set(renderedRoutesContext, []);
11117
11141
  let results = await dataStrategy(args);
11118
- const renderedRouteById = new Map(renderedRoutes.map((r) => [r.id, r]));
11142
+ const renderedRouteById = new Map(
11143
+ context.get(renderedRoutesContext).map((r) => [r.id, r])
11144
+ );
11119
11145
  for (const match of args.matches) {
11120
11146
  const rendered = renderedRouteById.get(match.route.id);
11121
- if (!rendered) continue;
11122
- window.__router.patchRoutes(rendered.parentId ?? null, [
11123
- createRouteFromServerManifest(rendered)
11124
- ]);
11147
+ if (rendered) {
11148
+ window.__router.patchRoutes(
11149
+ rendered.parentId ?? null,
11150
+ [createRouteFromServerManifest(rendered)],
11151
+ true
11152
+ );
11153
+ }
11125
11154
  }
11126
11155
  return results;
11127
11156
  });
11128
11157
  }
11129
11158
  function getFetchAndDecodeViaRSC(decode2) {
11130
- return async (request, basename, targetRoutes) => {
11131
- const renderedRoutes = requestRenderedRouteCache.get(request);
11132
- invariant(renderedRoutes, "No rendered routes cache for request");
11159
+ return async (args, basename, targetRoutes) => {
11160
+ let { request, context } = args;
11133
11161
  let url = singleFetchUrl(request.url, basename, "rsc");
11134
11162
  if (request.method === "GET") {
11135
11163
  url = stripIndexParam(url);
@@ -11147,7 +11175,7 @@ function getFetchAndDecodeViaRSC(decode2) {
11147
11175
  if (payload.type !== "render") {
11148
11176
  throw new Error("Unexpected payload type");
11149
11177
  }
11150
- renderedRoutes.push(...payload.matches);
11178
+ context.get(renderedRoutesContext).push(...payload.matches);
11151
11179
  let results = { routes: {} };
11152
11180
  const dataKey = isMutationMethod(request.method) ? "actionData" : "loaderData";
11153
11181
  for (let [routeId, data2] of Object.entries(payload[dataKey] || {})) {
@@ -11206,28 +11234,20 @@ function ServerBrowserRouter({
11206
11234
  function createRouteFromServerManifest(match) {
11207
11235
  return {
11208
11236
  id: match.id,
11209
- action: match.hasAction || !!match.clientAction,
11210
11237
  element: match.element,
11211
11238
  errorElement: match.errorElement,
11212
11239
  handle: match.handle,
11213
11240
  hasErrorBoundary: match.hasErrorBoundary,
11214
11241
  hydrateFallbackElement: match.hydrateFallbackElement,
11215
11242
  index: match.index,
11216
- loader: (
11217
- // prettier-ignore
11218
- match.clientLoader ? (args, singleFetch) => {
11219
- return match.clientLoader({
11220
- ...args,
11221
- async serverLoader() {
11222
- invariant(typeof singleFetch === "function", "Invalid singleFetch parameter");
11223
- return singleFetch();
11224
- }
11225
- });
11226
- } : match.hasLoader ? (args, singleFetch) => {
11227
- invariant(typeof singleFetch === "function", "Invalid singleFetch parameter");
11228
- return singleFetch();
11229
- } : void 0
11230
- ),
11243
+ loader: match.clientLoader ? (args, singleFetch) => match.clientLoader({
11244
+ ...args,
11245
+ serverLoader: () => callSingleFetch(singleFetch)
11246
+ }) : match.hasLoader ? (_, singleFetch) => callSingleFetch(singleFetch) : void 0,
11247
+ action: match.clientAction ? (args, singleFetch) => match.clientAction({
11248
+ ...args,
11249
+ serverAction: () => callSingleFetch(singleFetch)
11250
+ }) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : void 0,
11231
11251
  path: match.path,
11232
11252
  shouldRevalidate: match.shouldRevalidate,
11233
11253
  hasLoader: match.hasLoader,
@@ -11237,6 +11257,10 @@ function createRouteFromServerManifest(match) {
11237
11257
  hasShouldRevalidate: match.shouldRevalidate != null
11238
11258
  };
11239
11259
  }
11260
+ function callSingleFetch(singleFetch) {
11261
+ invariant(typeof singleFetch === "function", "Invalid singleFetch parameter");
11262
+ return singleFetch();
11263
+ }
11240
11264
 
11241
11265
  // lib/server.static.tsx
11242
11266
  import * as React16 from "react";
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1 } from './browser-CYoCBM_s.mjs';
3
- import { R as RouterInit } from './route-data-BaZTTsr9.mjs';
2
+ import { R as RouterProviderProps$1 } from './browser-D6LL53bK.mjs';
3
+ import { R as RouterInit } from './route-data-D8Uf5Cm-.mjs';
4
4
 
5
5
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
6
6
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1 } from './browser-vPEOwWRD.js';
3
- import { R as RouterInit } from './route-data-BaZTTsr9.js';
2
+ import { R as RouterProviderProps$1 } from './browser-cstcbNCb.js';
3
+ import { R as RouterInit } from './route-data-D8Uf5Cm-.js';
4
4
 
5
5
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
6
6
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;