react-router 7.5.0-pre.0 → 7.5.0-pre.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # `react-router`
2
2
 
3
+ ## 7.5.0-pre.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [REMOVE]: Additional work on route.lazy object form ([#13339](https://github.com/remix-run/react-router/pull/13339))
8
+
3
9
  ## 7.5.0-pre.0
4
10
 
5
11
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -3610,19 +3610,29 @@ var loadLazyRouteProperty = ({
3610
3610
  return propertyPromise;
3611
3611
  };
3612
3612
  var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
3613
- async function loadLazyRoute(route, manifest, mapRouteProperties2) {
3613
+ function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
3614
3614
  let routeToUpdate = manifest[route.id];
3615
3615
  invariant(routeToUpdate, "No route found in manifest");
3616
3616
  if (!route.lazy) {
3617
- return;
3617
+ return {
3618
+ lazyRoutePromise: void 0,
3619
+ lazyHandlerPromise: void 0
3620
+ };
3618
3621
  }
3619
3622
  if (typeof route.lazy === "function") {
3620
3623
  let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
3621
3624
  if (cachedPromise) {
3622
- await cachedPromise;
3623
- return;
3625
+ return {
3626
+ lazyRoutePromise: cachedPromise,
3627
+ lazyHandlerPromise: cachedPromise
3628
+ };
3624
3629
  }
3625
- let lazyRoutePromise = route.lazy().then((lazyRoute) => {
3630
+ let lazyRoutePromise2 = (async () => {
3631
+ invariant(
3632
+ typeof route.lazy === "function",
3633
+ "No lazy route function found"
3634
+ );
3635
+ let lazyRoute = await route.lazy();
3626
3636
  let routeUpdates = {};
3627
3637
  for (let lazyRouteProperty in lazyRoute) {
3628
3638
  let lazyValue = lazyRoute[lazyRouteProperty];
@@ -3656,22 +3666,39 @@ async function loadLazyRoute(route, manifest, mapRouteProperties2) {
3656
3666
  ...mapRouteProperties2(routeToUpdate),
3657
3667
  lazy: void 0
3658
3668
  });
3659
- });
3660
- lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
3661
- await lazyRoutePromise;
3662
- return;
3669
+ })();
3670
+ lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise2);
3671
+ return {
3672
+ lazyRoutePromise: lazyRoutePromise2,
3673
+ lazyHandlerPromise: lazyRoutePromise2
3674
+ };
3663
3675
  }
3664
3676
  let lazyKeys = Object.keys(route.lazy);
3665
- await Promise.all(
3666
- lazyKeys.map(
3667
- (key) => loadLazyRouteProperty({
3668
- key,
3669
- route,
3670
- manifest,
3671
- mapRouteProperties: mapRouteProperties2
3672
- })
3673
- )
3674
- );
3677
+ let lazyPropertyPromises = [];
3678
+ let lazyHandlerPromise = void 0;
3679
+ for (let key of lazyKeys) {
3680
+ let promise = loadLazyRouteProperty({
3681
+ key,
3682
+ route,
3683
+ manifest,
3684
+ mapRouteProperties: mapRouteProperties2
3685
+ });
3686
+ if (promise) {
3687
+ lazyPropertyPromises.push(promise);
3688
+ if (key === type) {
3689
+ lazyHandlerPromise = promise;
3690
+ }
3691
+ }
3692
+ }
3693
+ let lazyRoutePromise = Promise.all(lazyPropertyPromises).then(() => {
3694
+ });
3695
+ return {
3696
+ lazyRoutePromise,
3697
+ lazyHandlerPromise
3698
+ };
3699
+ }
3700
+ function isNonNullable(value) {
3701
+ return value !== void 0;
3675
3702
  }
3676
3703
  function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
3677
3704
  let promises = matches.map(({ route }) => {
@@ -3684,7 +3711,7 @@ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
3684
3711
  manifest,
3685
3712
  mapRouteProperties: mapRouteProperties2
3686
3713
  });
3687
- }).filter((p) => p != null);
3714
+ }).filter(isNonNullable);
3688
3715
  return promises.length > 0 ? Promise.all(promises) : void 0;
3689
3716
  }
3690
3717
  async function defaultDataStrategy(args) {
@@ -3807,27 +3834,28 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3807
3834
  manifest,
3808
3835
  mapRouteProperties2
3809
3836
  );
3810
- let loadLazyRoutePromises = matches.map(
3811
- (m) => m.route.lazy ? loadLazyRoute(m.route, manifest, mapRouteProperties2) : void 0
3837
+ let lazyRoutePromises = matches.map(
3838
+ (m) => loadLazyRoute(m.route, type, manifest, mapRouteProperties2)
3812
3839
  );
3813
3840
  if (loadMiddlewarePromise) {
3814
3841
  await loadMiddlewarePromise;
3815
3842
  }
3816
3843
  let dsMatches = matches.map((match, i) => {
3817
- let loadRoutePromise = loadLazyRoutePromises[i];
3844
+ let { lazyRoutePromise, lazyHandlerPromise } = lazyRoutePromises[i];
3818
3845
  let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
3819
3846
  let resolve = async (handlerOverride) => {
3820
3847
  if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
3821
3848
  shouldLoad = true;
3822
3849
  }
3823
- return shouldLoad ? callLoaderOrAction(
3850
+ return shouldLoad ? callLoaderOrAction({
3824
3851
  type,
3825
3852
  request,
3826
3853
  match,
3827
- loadRoutePromise,
3854
+ lazyHandlerPromise,
3855
+ lazyRoutePromise,
3828
3856
  handlerOverride,
3829
3857
  scopedContext
3830
- ) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3858
+ }) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3831
3859
  };
3832
3860
  return {
3833
3861
  ...match,
@@ -3842,13 +3870,24 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3842
3870
  fetcherKey,
3843
3871
  context: scopedContext
3844
3872
  });
3873
+ let allLazyRoutePromises = lazyRoutePromises.flatMap(
3874
+ (promiseMap) => Object.values(promiseMap).filter(isNonNullable)
3875
+ );
3845
3876
  try {
3846
- await Promise.all(loadLazyRoutePromises);
3877
+ await Promise.all(allLazyRoutePromises);
3847
3878
  } catch (e) {
3848
3879
  }
3849
3880
  return results;
3850
3881
  }
3851
- async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, scopedContext) {
3882
+ async function callLoaderOrAction({
3883
+ type,
3884
+ request,
3885
+ match,
3886
+ lazyHandlerPromise,
3887
+ lazyRoutePromise,
3888
+ handlerOverride,
3889
+ scopedContext
3890
+ }) {
3852
3891
  let result;
3853
3892
  let onReject;
3854
3893
  let runHandler = (handler) => {
@@ -3885,7 +3924,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3885
3924
  };
3886
3925
  try {
3887
3926
  let handler = match.route[type];
3888
- if (loadRoutePromise) {
3927
+ if (lazyHandlerPromise || lazyRoutePromise) {
3889
3928
  if (handler) {
3890
3929
  let handlerError;
3891
3930
  let [value] = await Promise.all([
@@ -3895,17 +3934,19 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3895
3934
  runHandler(handler).catch((e) => {
3896
3935
  handlerError = e;
3897
3936
  }),
3898
- loadRoutePromise
3937
+ // Ensure all lazy route promises are resolved before continuing
3938
+ lazyHandlerPromise,
3939
+ lazyRoutePromise
3899
3940
  ]);
3900
3941
  if (handlerError !== void 0) {
3901
3942
  throw handlerError;
3902
3943
  }
3903
3944
  result = value;
3904
3945
  } else {
3905
- await loadRoutePromise;
3946
+ await lazyHandlerPromise;
3906
3947
  handler = match.route[type];
3907
3948
  if (handler) {
3908
- result = await runHandler(handler);
3949
+ [result] = await Promise.all([runHandler(handler), lazyRoutePromise]);
3909
3950
  } else if (type === "action") {
3910
3951
  let url = new URL(request.url);
3911
3952
  let pathname = url.pathname + url.search;
@@ -7675,7 +7716,7 @@ function mergeRefs(...refs) {
7675
7716
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7676
7717
  try {
7677
7718
  if (isBrowser) {
7678
- window.__reactRouterVersion = "7.5.0-pre.0";
7719
+ window.__reactRouterVersion = "7.5.0-pre.1";
7679
7720
  }
7680
7721
  } catch (e) {
7681
7722
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2898,19 +2898,29 @@ var loadLazyRouteProperty = ({
2898
2898
  return propertyPromise;
2899
2899
  };
2900
2900
  var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
2901
- async function loadLazyRoute(route, manifest, mapRouteProperties2) {
2901
+ function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
2902
2902
  let routeToUpdate = manifest[route.id];
2903
2903
  invariant(routeToUpdate, "No route found in manifest");
2904
2904
  if (!route.lazy) {
2905
- return;
2905
+ return {
2906
+ lazyRoutePromise: void 0,
2907
+ lazyHandlerPromise: void 0
2908
+ };
2906
2909
  }
2907
2910
  if (typeof route.lazy === "function") {
2908
2911
  let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
2909
2912
  if (cachedPromise) {
2910
- await cachedPromise;
2911
- return;
2913
+ return {
2914
+ lazyRoutePromise: cachedPromise,
2915
+ lazyHandlerPromise: cachedPromise
2916
+ };
2912
2917
  }
2913
- let lazyRoutePromise = route.lazy().then((lazyRoute) => {
2918
+ let lazyRoutePromise2 = (async () => {
2919
+ invariant(
2920
+ typeof route.lazy === "function",
2921
+ "No lazy route function found"
2922
+ );
2923
+ let lazyRoute = await route.lazy();
2914
2924
  let routeUpdates = {};
2915
2925
  for (let lazyRouteProperty in lazyRoute) {
2916
2926
  let lazyValue = lazyRoute[lazyRouteProperty];
@@ -2944,22 +2954,39 @@ async function loadLazyRoute(route, manifest, mapRouteProperties2) {
2944
2954
  ...mapRouteProperties2(routeToUpdate),
2945
2955
  lazy: void 0
2946
2956
  });
2947
- });
2948
- lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
2949
- await lazyRoutePromise;
2950
- return;
2957
+ })();
2958
+ lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise2);
2959
+ return {
2960
+ lazyRoutePromise: lazyRoutePromise2,
2961
+ lazyHandlerPromise: lazyRoutePromise2
2962
+ };
2951
2963
  }
2952
2964
  let lazyKeys = Object.keys(route.lazy);
2953
- await Promise.all(
2954
- lazyKeys.map(
2955
- (key) => loadLazyRouteProperty({
2956
- key,
2957
- route,
2958
- manifest,
2959
- mapRouteProperties: mapRouteProperties2
2960
- })
2961
- )
2962
- );
2965
+ let lazyPropertyPromises = [];
2966
+ let lazyHandlerPromise = void 0;
2967
+ for (let key of lazyKeys) {
2968
+ let promise = loadLazyRouteProperty({
2969
+ key,
2970
+ route,
2971
+ manifest,
2972
+ mapRouteProperties: mapRouteProperties2
2973
+ });
2974
+ if (promise) {
2975
+ lazyPropertyPromises.push(promise);
2976
+ if (key === type) {
2977
+ lazyHandlerPromise = promise;
2978
+ }
2979
+ }
2980
+ }
2981
+ let lazyRoutePromise = Promise.all(lazyPropertyPromises).then(() => {
2982
+ });
2983
+ return {
2984
+ lazyRoutePromise,
2985
+ lazyHandlerPromise
2986
+ };
2987
+ }
2988
+ function isNonNullable(value) {
2989
+ return value !== void 0;
2963
2990
  }
2964
2991
  function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
2965
2992
  let promises = matches.map(({ route }) => {
@@ -2972,7 +2999,7 @@ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
2972
2999
  manifest,
2973
3000
  mapRouteProperties: mapRouteProperties2
2974
3001
  });
2975
- }).filter((p) => p != null);
3002
+ }).filter(isNonNullable);
2976
3003
  return promises.length > 0 ? Promise.all(promises) : void 0;
2977
3004
  }
2978
3005
  async function defaultDataStrategy(args) {
@@ -3095,27 +3122,28 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3095
3122
  manifest,
3096
3123
  mapRouteProperties2
3097
3124
  );
3098
- let loadLazyRoutePromises = matches.map(
3099
- (m) => m.route.lazy ? loadLazyRoute(m.route, manifest, mapRouteProperties2) : void 0
3125
+ let lazyRoutePromises = matches.map(
3126
+ (m) => loadLazyRoute(m.route, type, manifest, mapRouteProperties2)
3100
3127
  );
3101
3128
  if (loadMiddlewarePromise) {
3102
3129
  await loadMiddlewarePromise;
3103
3130
  }
3104
3131
  let dsMatches = matches.map((match, i) => {
3105
- let loadRoutePromise = loadLazyRoutePromises[i];
3132
+ let { lazyRoutePromise, lazyHandlerPromise } = lazyRoutePromises[i];
3106
3133
  let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
3107
3134
  let resolve = async (handlerOverride) => {
3108
3135
  if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
3109
3136
  shouldLoad = true;
3110
3137
  }
3111
- return shouldLoad ? callLoaderOrAction(
3138
+ return shouldLoad ? callLoaderOrAction({
3112
3139
  type,
3113
3140
  request,
3114
3141
  match,
3115
- loadRoutePromise,
3142
+ lazyHandlerPromise,
3143
+ lazyRoutePromise,
3116
3144
  handlerOverride,
3117
3145
  scopedContext
3118
- ) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3146
+ }) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3119
3147
  };
3120
3148
  return {
3121
3149
  ...match,
@@ -3130,13 +3158,24 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3130
3158
  fetcherKey,
3131
3159
  context: scopedContext
3132
3160
  });
3161
+ let allLazyRoutePromises = lazyRoutePromises.flatMap(
3162
+ (promiseMap) => Object.values(promiseMap).filter(isNonNullable)
3163
+ );
3133
3164
  try {
3134
- await Promise.all(loadLazyRoutePromises);
3165
+ await Promise.all(allLazyRoutePromises);
3135
3166
  } catch (e) {
3136
3167
  }
3137
3168
  return results;
3138
3169
  }
3139
- async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, scopedContext) {
3170
+ async function callLoaderOrAction({
3171
+ type,
3172
+ request,
3173
+ match,
3174
+ lazyHandlerPromise,
3175
+ lazyRoutePromise,
3176
+ handlerOverride,
3177
+ scopedContext
3178
+ }) {
3140
3179
  let result;
3141
3180
  let onReject;
3142
3181
  let runHandler = (handler) => {
@@ -3173,7 +3212,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3173
3212
  };
3174
3213
  try {
3175
3214
  let handler = match.route[type];
3176
- if (loadRoutePromise) {
3215
+ if (lazyHandlerPromise || lazyRoutePromise) {
3177
3216
  if (handler) {
3178
3217
  let handlerError;
3179
3218
  let [value] = await Promise.all([
@@ -3183,17 +3222,19 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3183
3222
  runHandler(handler).catch((e) => {
3184
3223
  handlerError = e;
3185
3224
  }),
3186
- loadRoutePromise
3225
+ // Ensure all lazy route promises are resolved before continuing
3226
+ lazyHandlerPromise,
3227
+ lazyRoutePromise
3187
3228
  ]);
3188
3229
  if (handlerError !== void 0) {
3189
3230
  throw handlerError;
3190
3231
  }
3191
3232
  result = value;
3192
3233
  } else {
3193
- await loadRoutePromise;
3234
+ await lazyHandlerPromise;
3194
3235
  handler = match.route[type];
3195
3236
  if (handler) {
3196
- result = await runHandler(handler);
3237
+ [result] = await Promise.all([runHandler(handler), lazyRoutePromise]);
3197
3238
  } else if (type === "action") {
3198
3239
  let url = new URL(request.url);
3199
3240
  let pathname = url.pathname + url.search;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -25,7 +25,7 @@ import {
25
25
  matchRoutes,
26
26
  shouldHydrateRouteLoader,
27
27
  useFogOFWarDiscovery
28
- } from "./chunk-YTH545ZN.mjs";
28
+ } from "./chunk-5BSZVSUP.mjs";
29
29
 
30
30
  // lib/dom-export/dom-router-provider.tsx
31
31
  import * as React from "react";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -3758,19 +3758,29 @@ var loadLazyRouteProperty = ({
3758
3758
  return propertyPromise;
3759
3759
  };
3760
3760
  var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
3761
- async function loadLazyRoute(route, manifest, mapRouteProperties2) {
3761
+ function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
3762
3762
  let routeToUpdate = manifest[route.id];
3763
3763
  invariant(routeToUpdate, "No route found in manifest");
3764
3764
  if (!route.lazy) {
3765
- return;
3765
+ return {
3766
+ lazyRoutePromise: void 0,
3767
+ lazyHandlerPromise: void 0
3768
+ };
3766
3769
  }
3767
3770
  if (typeof route.lazy === "function") {
3768
3771
  let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
3769
3772
  if (cachedPromise) {
3770
- await cachedPromise;
3771
- return;
3773
+ return {
3774
+ lazyRoutePromise: cachedPromise,
3775
+ lazyHandlerPromise: cachedPromise
3776
+ };
3772
3777
  }
3773
- let lazyRoutePromise = route.lazy().then((lazyRoute) => {
3778
+ let lazyRoutePromise2 = (async () => {
3779
+ invariant(
3780
+ typeof route.lazy === "function",
3781
+ "No lazy route function found"
3782
+ );
3783
+ let lazyRoute = await route.lazy();
3774
3784
  let routeUpdates = {};
3775
3785
  for (let lazyRouteProperty in lazyRoute) {
3776
3786
  let lazyValue = lazyRoute[lazyRouteProperty];
@@ -3804,22 +3814,39 @@ async function loadLazyRoute(route, manifest, mapRouteProperties2) {
3804
3814
  ...mapRouteProperties2(routeToUpdate),
3805
3815
  lazy: void 0
3806
3816
  });
3807
- });
3808
- lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
3809
- await lazyRoutePromise;
3810
- return;
3817
+ })();
3818
+ lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise2);
3819
+ return {
3820
+ lazyRoutePromise: lazyRoutePromise2,
3821
+ lazyHandlerPromise: lazyRoutePromise2
3822
+ };
3811
3823
  }
3812
3824
  let lazyKeys = Object.keys(route.lazy);
3813
- await Promise.all(
3814
- lazyKeys.map(
3815
- (key) => loadLazyRouteProperty({
3816
- key,
3817
- route,
3818
- manifest,
3819
- mapRouteProperties: mapRouteProperties2
3820
- })
3821
- )
3822
- );
3825
+ let lazyPropertyPromises = [];
3826
+ let lazyHandlerPromise = void 0;
3827
+ for (let key of lazyKeys) {
3828
+ let promise = loadLazyRouteProperty({
3829
+ key,
3830
+ route,
3831
+ manifest,
3832
+ mapRouteProperties: mapRouteProperties2
3833
+ });
3834
+ if (promise) {
3835
+ lazyPropertyPromises.push(promise);
3836
+ if (key === type) {
3837
+ lazyHandlerPromise = promise;
3838
+ }
3839
+ }
3840
+ }
3841
+ let lazyRoutePromise = Promise.all(lazyPropertyPromises).then(() => {
3842
+ });
3843
+ return {
3844
+ lazyRoutePromise,
3845
+ lazyHandlerPromise
3846
+ };
3847
+ }
3848
+ function isNonNullable(value) {
3849
+ return value !== void 0;
3823
3850
  }
3824
3851
  function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
3825
3852
  let promises = matches.map(({ route }) => {
@@ -3832,7 +3859,7 @@ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
3832
3859
  manifest,
3833
3860
  mapRouteProperties: mapRouteProperties2
3834
3861
  });
3835
- }).filter((p) => p != null);
3862
+ }).filter(isNonNullable);
3836
3863
  return promises.length > 0 ? Promise.all(promises) : void 0;
3837
3864
  }
3838
3865
  async function defaultDataStrategy(args) {
@@ -3955,27 +3982,28 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3955
3982
  manifest,
3956
3983
  mapRouteProperties2
3957
3984
  );
3958
- let loadLazyRoutePromises = matches.map(
3959
- (m) => m.route.lazy ? loadLazyRoute(m.route, manifest, mapRouteProperties2) : void 0
3985
+ let lazyRoutePromises = matches.map(
3986
+ (m) => loadLazyRoute(m.route, type, manifest, mapRouteProperties2)
3960
3987
  );
3961
3988
  if (loadMiddlewarePromise) {
3962
3989
  await loadMiddlewarePromise;
3963
3990
  }
3964
3991
  let dsMatches = matches.map((match, i) => {
3965
- let loadRoutePromise = loadLazyRoutePromises[i];
3992
+ let { lazyRoutePromise, lazyHandlerPromise } = lazyRoutePromises[i];
3966
3993
  let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
3967
3994
  let resolve = async (handlerOverride) => {
3968
3995
  if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
3969
3996
  shouldLoad = true;
3970
3997
  }
3971
- return shouldLoad ? callLoaderOrAction(
3998
+ return shouldLoad ? callLoaderOrAction({
3972
3999
  type,
3973
4000
  request,
3974
4001
  match,
3975
- loadRoutePromise,
4002
+ lazyHandlerPromise,
4003
+ lazyRoutePromise,
3976
4004
  handlerOverride,
3977
4005
  scopedContext
3978
- ) : Promise.resolve({ type: "data" /* data */, result: void 0 });
4006
+ }) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3979
4007
  };
3980
4008
  return {
3981
4009
  ...match,
@@ -3990,13 +4018,24 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3990
4018
  fetcherKey,
3991
4019
  context: scopedContext
3992
4020
  });
4021
+ let allLazyRoutePromises = lazyRoutePromises.flatMap(
4022
+ (promiseMap) => Object.values(promiseMap).filter(isNonNullable)
4023
+ );
3993
4024
  try {
3994
- await Promise.all(loadLazyRoutePromises);
4025
+ await Promise.all(allLazyRoutePromises);
3995
4026
  } catch (e) {
3996
4027
  }
3997
4028
  return results;
3998
4029
  }
3999
- async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, scopedContext) {
4030
+ async function callLoaderOrAction({
4031
+ type,
4032
+ request,
4033
+ match,
4034
+ lazyHandlerPromise,
4035
+ lazyRoutePromise,
4036
+ handlerOverride,
4037
+ scopedContext
4038
+ }) {
4000
4039
  let result;
4001
4040
  let onReject;
4002
4041
  let runHandler = (handler) => {
@@ -4033,7 +4072,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
4033
4072
  };
4034
4073
  try {
4035
4074
  let handler = match.route[type];
4036
- if (loadRoutePromise) {
4075
+ if (lazyHandlerPromise || lazyRoutePromise) {
4037
4076
  if (handler) {
4038
4077
  let handlerError;
4039
4078
  let [value] = await Promise.all([
@@ -4043,17 +4082,19 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
4043
4082
  runHandler(handler).catch((e) => {
4044
4083
  handlerError = e;
4045
4084
  }),
4046
- loadRoutePromise
4085
+ // Ensure all lazy route promises are resolved before continuing
4086
+ lazyHandlerPromise,
4087
+ lazyRoutePromise
4047
4088
  ]);
4048
4089
  if (handlerError !== void 0) {
4049
4090
  throw handlerError;
4050
4091
  }
4051
4092
  result = value;
4052
4093
  } else {
4053
- await loadRoutePromise;
4094
+ await lazyHandlerPromise;
4054
4095
  handler = match.route[type];
4055
4096
  if (handler) {
4056
- result = await runHandler(handler);
4097
+ [result] = await Promise.all([runHandler(handler), lazyRoutePromise]);
4057
4098
  } else if (type === "action") {
4058
4099
  let url = new URL(request.url);
4059
4100
  let pathname = url.pathname + url.search;
@@ -7823,7 +7864,7 @@ function mergeRefs(...refs) {
7823
7864
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7824
7865
  try {
7825
7866
  if (isBrowser) {
7826
- window.__reactRouterVersion = "7.5.0-pre.0";
7867
+ window.__reactRouterVersion = "7.5.0-pre.1";
7827
7868
  }
7828
7869
  } catch (e) {
7829
7870
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -123,7 +123,7 @@ import {
123
123
  useSearchParams,
124
124
  useSubmit,
125
125
  useViewTransitionState
126
- } from "./chunk-YTH545ZN.mjs";
126
+ } from "./chunk-5BSZVSUP.mjs";
127
127
  export {
128
128
  Await,
129
129
  BrowserRouter,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -3610,19 +3610,29 @@ var loadLazyRouteProperty = ({
3610
3610
  return propertyPromise;
3611
3611
  };
3612
3612
  var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
3613
- async function loadLazyRoute(route, manifest, mapRouteProperties2) {
3613
+ function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
3614
3614
  let routeToUpdate = manifest[route.id];
3615
3615
  invariant(routeToUpdate, "No route found in manifest");
3616
3616
  if (!route.lazy) {
3617
- return;
3617
+ return {
3618
+ lazyRoutePromise: void 0,
3619
+ lazyHandlerPromise: void 0
3620
+ };
3618
3621
  }
3619
3622
  if (typeof route.lazy === "function") {
3620
3623
  let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
3621
3624
  if (cachedPromise) {
3622
- await cachedPromise;
3623
- return;
3625
+ return {
3626
+ lazyRoutePromise: cachedPromise,
3627
+ lazyHandlerPromise: cachedPromise
3628
+ };
3624
3629
  }
3625
- let lazyRoutePromise = route.lazy().then((lazyRoute) => {
3630
+ let lazyRoutePromise2 = (async () => {
3631
+ invariant(
3632
+ typeof route.lazy === "function",
3633
+ "No lazy route function found"
3634
+ );
3635
+ let lazyRoute = await route.lazy();
3626
3636
  let routeUpdates = {};
3627
3637
  for (let lazyRouteProperty in lazyRoute) {
3628
3638
  let lazyValue = lazyRoute[lazyRouteProperty];
@@ -3656,22 +3666,39 @@ async function loadLazyRoute(route, manifest, mapRouteProperties2) {
3656
3666
  ...mapRouteProperties2(routeToUpdate),
3657
3667
  lazy: void 0
3658
3668
  });
3659
- });
3660
- lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
3661
- await lazyRoutePromise;
3662
- return;
3669
+ })();
3670
+ lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise2);
3671
+ return {
3672
+ lazyRoutePromise: lazyRoutePromise2,
3673
+ lazyHandlerPromise: lazyRoutePromise2
3674
+ };
3663
3675
  }
3664
3676
  let lazyKeys = Object.keys(route.lazy);
3665
- await Promise.all(
3666
- lazyKeys.map(
3667
- (key) => loadLazyRouteProperty({
3668
- key,
3669
- route,
3670
- manifest,
3671
- mapRouteProperties: mapRouteProperties2
3672
- })
3673
- )
3674
- );
3677
+ let lazyPropertyPromises = [];
3678
+ let lazyHandlerPromise = void 0;
3679
+ for (let key of lazyKeys) {
3680
+ let promise = loadLazyRouteProperty({
3681
+ key,
3682
+ route,
3683
+ manifest,
3684
+ mapRouteProperties: mapRouteProperties2
3685
+ });
3686
+ if (promise) {
3687
+ lazyPropertyPromises.push(promise);
3688
+ if (key === type) {
3689
+ lazyHandlerPromise = promise;
3690
+ }
3691
+ }
3692
+ }
3693
+ let lazyRoutePromise = Promise.all(lazyPropertyPromises).then(() => {
3694
+ });
3695
+ return {
3696
+ lazyRoutePromise,
3697
+ lazyHandlerPromise
3698
+ };
3699
+ }
3700
+ function isNonNullable(value) {
3701
+ return value !== void 0;
3675
3702
  }
3676
3703
  function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
3677
3704
  let promises = matches.map(({ route }) => {
@@ -3684,7 +3711,7 @@ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
3684
3711
  manifest,
3685
3712
  mapRouteProperties: mapRouteProperties2
3686
3713
  });
3687
- }).filter((p) => p != null);
3714
+ }).filter(isNonNullable);
3688
3715
  return promises.length > 0 ? Promise.all(promises) : void 0;
3689
3716
  }
3690
3717
  async function defaultDataStrategy(args) {
@@ -3807,27 +3834,28 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3807
3834
  manifest,
3808
3835
  mapRouteProperties2
3809
3836
  );
3810
- let loadLazyRoutePromises = matches.map(
3811
- (m) => m.route.lazy ? loadLazyRoute(m.route, manifest, mapRouteProperties2) : void 0
3837
+ let lazyRoutePromises = matches.map(
3838
+ (m) => loadLazyRoute(m.route, type, manifest, mapRouteProperties2)
3812
3839
  );
3813
3840
  if (loadMiddlewarePromise) {
3814
3841
  await loadMiddlewarePromise;
3815
3842
  }
3816
3843
  let dsMatches = matches.map((match, i) => {
3817
- let loadRoutePromise = loadLazyRoutePromises[i];
3844
+ let { lazyRoutePromise, lazyHandlerPromise } = lazyRoutePromises[i];
3818
3845
  let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
3819
3846
  let resolve = async (handlerOverride) => {
3820
3847
  if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
3821
3848
  shouldLoad = true;
3822
3849
  }
3823
- return shouldLoad ? callLoaderOrAction(
3850
+ return shouldLoad ? callLoaderOrAction({
3824
3851
  type,
3825
3852
  request,
3826
3853
  match,
3827
- loadRoutePromise,
3854
+ lazyHandlerPromise,
3855
+ lazyRoutePromise,
3828
3856
  handlerOverride,
3829
3857
  scopedContext
3830
- ) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3858
+ }) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3831
3859
  };
3832
3860
  return {
3833
3861
  ...match,
@@ -3842,13 +3870,24 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3842
3870
  fetcherKey,
3843
3871
  context: scopedContext
3844
3872
  });
3873
+ let allLazyRoutePromises = lazyRoutePromises.flatMap(
3874
+ (promiseMap) => Object.values(promiseMap).filter(isNonNullable)
3875
+ );
3845
3876
  try {
3846
- await Promise.all(loadLazyRoutePromises);
3877
+ await Promise.all(allLazyRoutePromises);
3847
3878
  } catch (e) {
3848
3879
  }
3849
3880
  return results;
3850
3881
  }
3851
- async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, scopedContext) {
3882
+ async function callLoaderOrAction({
3883
+ type,
3884
+ request,
3885
+ match,
3886
+ lazyHandlerPromise,
3887
+ lazyRoutePromise,
3888
+ handlerOverride,
3889
+ scopedContext
3890
+ }) {
3852
3891
  let result;
3853
3892
  let onReject;
3854
3893
  let runHandler = (handler) => {
@@ -3885,7 +3924,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3885
3924
  };
3886
3925
  try {
3887
3926
  let handler = match.route[type];
3888
- if (loadRoutePromise) {
3927
+ if (lazyHandlerPromise || lazyRoutePromise) {
3889
3928
  if (handler) {
3890
3929
  let handlerError;
3891
3930
  let [value] = await Promise.all([
@@ -3895,17 +3934,19 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3895
3934
  runHandler(handler).catch((e) => {
3896
3935
  handlerError = e;
3897
3936
  }),
3898
- loadRoutePromise
3937
+ // Ensure all lazy route promises are resolved before continuing
3938
+ lazyHandlerPromise,
3939
+ lazyRoutePromise
3899
3940
  ]);
3900
3941
  if (handlerError !== void 0) {
3901
3942
  throw handlerError;
3902
3943
  }
3903
3944
  result = value;
3904
3945
  } else {
3905
- await loadRoutePromise;
3946
+ await lazyHandlerPromise;
3906
3947
  handler = match.route[type];
3907
3948
  if (handler) {
3908
- result = await runHandler(handler);
3949
+ [result] = await Promise.all([runHandler(handler), lazyRoutePromise]);
3909
3950
  } else if (type === "action") {
3910
3951
  let url = new URL(request.url);
3911
3952
  let pathname = url.pathname + url.search;
@@ -7675,7 +7716,7 @@ function mergeRefs(...refs) {
7675
7716
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7676
7717
  try {
7677
7718
  if (isBrowser) {
7678
- window.__reactRouterVersion = "7.5.0-pre.0";
7719
+ window.__reactRouterVersion = "7.5.0-pre.1";
7679
7720
  }
7680
7721
  } catch (e) {
7681
7722
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2898,19 +2898,29 @@ var loadLazyRouteProperty = ({
2898
2898
  return propertyPromise;
2899
2899
  };
2900
2900
  var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
2901
- async function loadLazyRoute(route, manifest, mapRouteProperties2) {
2901
+ function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
2902
2902
  let routeToUpdate = manifest[route.id];
2903
2903
  invariant(routeToUpdate, "No route found in manifest");
2904
2904
  if (!route.lazy) {
2905
- return;
2905
+ return {
2906
+ lazyRoutePromise: void 0,
2907
+ lazyHandlerPromise: void 0
2908
+ };
2906
2909
  }
2907
2910
  if (typeof route.lazy === "function") {
2908
2911
  let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
2909
2912
  if (cachedPromise) {
2910
- await cachedPromise;
2911
- return;
2913
+ return {
2914
+ lazyRoutePromise: cachedPromise,
2915
+ lazyHandlerPromise: cachedPromise
2916
+ };
2912
2917
  }
2913
- let lazyRoutePromise = route.lazy().then((lazyRoute) => {
2918
+ let lazyRoutePromise2 = (async () => {
2919
+ invariant(
2920
+ typeof route.lazy === "function",
2921
+ "No lazy route function found"
2922
+ );
2923
+ let lazyRoute = await route.lazy();
2914
2924
  let routeUpdates = {};
2915
2925
  for (let lazyRouteProperty in lazyRoute) {
2916
2926
  let lazyValue = lazyRoute[lazyRouteProperty];
@@ -2944,22 +2954,39 @@ async function loadLazyRoute(route, manifest, mapRouteProperties2) {
2944
2954
  ...mapRouteProperties2(routeToUpdate),
2945
2955
  lazy: void 0
2946
2956
  });
2947
- });
2948
- lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
2949
- await lazyRoutePromise;
2950
- return;
2957
+ })();
2958
+ lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise2);
2959
+ return {
2960
+ lazyRoutePromise: lazyRoutePromise2,
2961
+ lazyHandlerPromise: lazyRoutePromise2
2962
+ };
2951
2963
  }
2952
2964
  let lazyKeys = Object.keys(route.lazy);
2953
- await Promise.all(
2954
- lazyKeys.map(
2955
- (key) => loadLazyRouteProperty({
2956
- key,
2957
- route,
2958
- manifest,
2959
- mapRouteProperties: mapRouteProperties2
2960
- })
2961
- )
2962
- );
2965
+ let lazyPropertyPromises = [];
2966
+ let lazyHandlerPromise = void 0;
2967
+ for (let key of lazyKeys) {
2968
+ let promise = loadLazyRouteProperty({
2969
+ key,
2970
+ route,
2971
+ manifest,
2972
+ mapRouteProperties: mapRouteProperties2
2973
+ });
2974
+ if (promise) {
2975
+ lazyPropertyPromises.push(promise);
2976
+ if (key === type) {
2977
+ lazyHandlerPromise = promise;
2978
+ }
2979
+ }
2980
+ }
2981
+ let lazyRoutePromise = Promise.all(lazyPropertyPromises).then(() => {
2982
+ });
2983
+ return {
2984
+ lazyRoutePromise,
2985
+ lazyHandlerPromise
2986
+ };
2987
+ }
2988
+ function isNonNullable(value) {
2989
+ return value !== void 0;
2963
2990
  }
2964
2991
  function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
2965
2992
  let promises = matches.map(({ route }) => {
@@ -2972,7 +2999,7 @@ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
2972
2999
  manifest,
2973
3000
  mapRouteProperties: mapRouteProperties2
2974
3001
  });
2975
- }).filter((p) => p != null);
3002
+ }).filter(isNonNullable);
2976
3003
  return promises.length > 0 ? Promise.all(promises) : void 0;
2977
3004
  }
2978
3005
  async function defaultDataStrategy(args) {
@@ -3095,27 +3122,28 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3095
3122
  manifest,
3096
3123
  mapRouteProperties2
3097
3124
  );
3098
- let loadLazyRoutePromises = matches.map(
3099
- (m) => m.route.lazy ? loadLazyRoute(m.route, manifest, mapRouteProperties2) : void 0
3125
+ let lazyRoutePromises = matches.map(
3126
+ (m) => loadLazyRoute(m.route, type, manifest, mapRouteProperties2)
3100
3127
  );
3101
3128
  if (loadMiddlewarePromise) {
3102
3129
  await loadMiddlewarePromise;
3103
3130
  }
3104
3131
  let dsMatches = matches.map((match, i) => {
3105
- let loadRoutePromise = loadLazyRoutePromises[i];
3132
+ let { lazyRoutePromise, lazyHandlerPromise } = lazyRoutePromises[i];
3106
3133
  let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
3107
3134
  let resolve = async (handlerOverride) => {
3108
3135
  if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
3109
3136
  shouldLoad = true;
3110
3137
  }
3111
- return shouldLoad ? callLoaderOrAction(
3138
+ return shouldLoad ? callLoaderOrAction({
3112
3139
  type,
3113
3140
  request,
3114
3141
  match,
3115
- loadRoutePromise,
3142
+ lazyHandlerPromise,
3143
+ lazyRoutePromise,
3116
3144
  handlerOverride,
3117
3145
  scopedContext
3118
- ) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3146
+ }) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3119
3147
  };
3120
3148
  return {
3121
3149
  ...match,
@@ -3130,13 +3158,24 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3130
3158
  fetcherKey,
3131
3159
  context: scopedContext
3132
3160
  });
3161
+ let allLazyRoutePromises = lazyRoutePromises.flatMap(
3162
+ (promiseMap) => Object.values(promiseMap).filter(isNonNullable)
3163
+ );
3133
3164
  try {
3134
- await Promise.all(loadLazyRoutePromises);
3165
+ await Promise.all(allLazyRoutePromises);
3135
3166
  } catch (e) {
3136
3167
  }
3137
3168
  return results;
3138
3169
  }
3139
- async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, scopedContext) {
3170
+ async function callLoaderOrAction({
3171
+ type,
3172
+ request,
3173
+ match,
3174
+ lazyHandlerPromise,
3175
+ lazyRoutePromise,
3176
+ handlerOverride,
3177
+ scopedContext
3178
+ }) {
3140
3179
  let result;
3141
3180
  let onReject;
3142
3181
  let runHandler = (handler) => {
@@ -3173,7 +3212,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3173
3212
  };
3174
3213
  try {
3175
3214
  let handler = match.route[type];
3176
- if (loadRoutePromise) {
3215
+ if (lazyHandlerPromise || lazyRoutePromise) {
3177
3216
  if (handler) {
3178
3217
  let handlerError;
3179
3218
  let [value] = await Promise.all([
@@ -3183,17 +3222,19 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3183
3222
  runHandler(handler).catch((e) => {
3184
3223
  handlerError = e;
3185
3224
  }),
3186
- loadRoutePromise
3225
+ // Ensure all lazy route promises are resolved before continuing
3226
+ lazyHandlerPromise,
3227
+ lazyRoutePromise
3187
3228
  ]);
3188
3229
  if (handlerError !== void 0) {
3189
3230
  throw handlerError;
3190
3231
  }
3191
3232
  result = value;
3192
3233
  } else {
3193
- await loadRoutePromise;
3234
+ await lazyHandlerPromise;
3194
3235
  handler = match.route[type];
3195
3236
  if (handler) {
3196
- result = await runHandler(handler);
3237
+ [result] = await Promise.all([runHandler(handler), lazyRoutePromise]);
3197
3238
  } else if (type === "action") {
3198
3239
  let url = new URL(request.url);
3199
3240
  let pathname = url.pathname + url.search;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -25,7 +25,7 @@ import {
25
25
  matchRoutes,
26
26
  shouldHydrateRouteLoader,
27
27
  useFogOFWarDiscovery
28
- } from "./chunk-RSOGH2WR.mjs";
28
+ } from "./chunk-AISJZE44.mjs";
29
29
 
30
30
  // lib/dom-export/dom-router-provider.tsx
31
31
  import * as React from "react";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -3758,19 +3758,29 @@ var loadLazyRouteProperty = ({
3758
3758
  return propertyPromise;
3759
3759
  };
3760
3760
  var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
3761
- async function loadLazyRoute(route, manifest, mapRouteProperties2) {
3761
+ function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
3762
3762
  let routeToUpdate = manifest[route.id];
3763
3763
  invariant(routeToUpdate, "No route found in manifest");
3764
3764
  if (!route.lazy) {
3765
- return;
3765
+ return {
3766
+ lazyRoutePromise: void 0,
3767
+ lazyHandlerPromise: void 0
3768
+ };
3766
3769
  }
3767
3770
  if (typeof route.lazy === "function") {
3768
3771
  let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
3769
3772
  if (cachedPromise) {
3770
- await cachedPromise;
3771
- return;
3773
+ return {
3774
+ lazyRoutePromise: cachedPromise,
3775
+ lazyHandlerPromise: cachedPromise
3776
+ };
3772
3777
  }
3773
- let lazyRoutePromise = route.lazy().then((lazyRoute) => {
3778
+ let lazyRoutePromise2 = (async () => {
3779
+ invariant(
3780
+ typeof route.lazy === "function",
3781
+ "No lazy route function found"
3782
+ );
3783
+ let lazyRoute = await route.lazy();
3774
3784
  let routeUpdates = {};
3775
3785
  for (let lazyRouteProperty in lazyRoute) {
3776
3786
  let lazyValue = lazyRoute[lazyRouteProperty];
@@ -3804,22 +3814,39 @@ async function loadLazyRoute(route, manifest, mapRouteProperties2) {
3804
3814
  ...mapRouteProperties2(routeToUpdate),
3805
3815
  lazy: void 0
3806
3816
  });
3807
- });
3808
- lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
3809
- await lazyRoutePromise;
3810
- return;
3817
+ })();
3818
+ lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise2);
3819
+ return {
3820
+ lazyRoutePromise: lazyRoutePromise2,
3821
+ lazyHandlerPromise: lazyRoutePromise2
3822
+ };
3811
3823
  }
3812
3824
  let lazyKeys = Object.keys(route.lazy);
3813
- await Promise.all(
3814
- lazyKeys.map(
3815
- (key) => loadLazyRouteProperty({
3816
- key,
3817
- route,
3818
- manifest,
3819
- mapRouteProperties: mapRouteProperties2
3820
- })
3821
- )
3822
- );
3825
+ let lazyPropertyPromises = [];
3826
+ let lazyHandlerPromise = void 0;
3827
+ for (let key of lazyKeys) {
3828
+ let promise = loadLazyRouteProperty({
3829
+ key,
3830
+ route,
3831
+ manifest,
3832
+ mapRouteProperties: mapRouteProperties2
3833
+ });
3834
+ if (promise) {
3835
+ lazyPropertyPromises.push(promise);
3836
+ if (key === type) {
3837
+ lazyHandlerPromise = promise;
3838
+ }
3839
+ }
3840
+ }
3841
+ let lazyRoutePromise = Promise.all(lazyPropertyPromises).then(() => {
3842
+ });
3843
+ return {
3844
+ lazyRoutePromise,
3845
+ lazyHandlerPromise
3846
+ };
3847
+ }
3848
+ function isNonNullable(value) {
3849
+ return value !== void 0;
3823
3850
  }
3824
3851
  function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
3825
3852
  let promises = matches.map(({ route }) => {
@@ -3832,7 +3859,7 @@ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
3832
3859
  manifest,
3833
3860
  mapRouteProperties: mapRouteProperties2
3834
3861
  });
3835
- }).filter((p) => p != null);
3862
+ }).filter(isNonNullable);
3836
3863
  return promises.length > 0 ? Promise.all(promises) : void 0;
3837
3864
  }
3838
3865
  async function defaultDataStrategy(args) {
@@ -3955,27 +3982,28 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3955
3982
  manifest,
3956
3983
  mapRouteProperties2
3957
3984
  );
3958
- let loadLazyRoutePromises = matches.map(
3959
- (m) => m.route.lazy ? loadLazyRoute(m.route, manifest, mapRouteProperties2) : void 0
3985
+ let lazyRoutePromises = matches.map(
3986
+ (m) => loadLazyRoute(m.route, type, manifest, mapRouteProperties2)
3960
3987
  );
3961
3988
  if (loadMiddlewarePromise) {
3962
3989
  await loadMiddlewarePromise;
3963
3990
  }
3964
3991
  let dsMatches = matches.map((match, i) => {
3965
- let loadRoutePromise = loadLazyRoutePromises[i];
3992
+ let { lazyRoutePromise, lazyHandlerPromise } = lazyRoutePromises[i];
3966
3993
  let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
3967
3994
  let resolve = async (handlerOverride) => {
3968
3995
  if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
3969
3996
  shouldLoad = true;
3970
3997
  }
3971
- return shouldLoad ? callLoaderOrAction(
3998
+ return shouldLoad ? callLoaderOrAction({
3972
3999
  type,
3973
4000
  request,
3974
4001
  match,
3975
- loadRoutePromise,
4002
+ lazyHandlerPromise,
4003
+ lazyRoutePromise,
3976
4004
  handlerOverride,
3977
4005
  scopedContext
3978
- ) : Promise.resolve({ type: "data" /* data */, result: void 0 });
4006
+ }) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3979
4007
  };
3980
4008
  return {
3981
4009
  ...match,
@@ -3990,13 +4018,24 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3990
4018
  fetcherKey,
3991
4019
  context: scopedContext
3992
4020
  });
4021
+ let allLazyRoutePromises = lazyRoutePromises.flatMap(
4022
+ (promiseMap) => Object.values(promiseMap).filter(isNonNullable)
4023
+ );
3993
4024
  try {
3994
- await Promise.all(loadLazyRoutePromises);
4025
+ await Promise.all(allLazyRoutePromises);
3995
4026
  } catch (e) {
3996
4027
  }
3997
4028
  return results;
3998
4029
  }
3999
- async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, scopedContext) {
4030
+ async function callLoaderOrAction({
4031
+ type,
4032
+ request,
4033
+ match,
4034
+ lazyHandlerPromise,
4035
+ lazyRoutePromise,
4036
+ handlerOverride,
4037
+ scopedContext
4038
+ }) {
4000
4039
  let result;
4001
4040
  let onReject;
4002
4041
  let runHandler = (handler) => {
@@ -4033,7 +4072,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
4033
4072
  };
4034
4073
  try {
4035
4074
  let handler = match.route[type];
4036
- if (loadRoutePromise) {
4075
+ if (lazyHandlerPromise || lazyRoutePromise) {
4037
4076
  if (handler) {
4038
4077
  let handlerError;
4039
4078
  let [value] = await Promise.all([
@@ -4043,17 +4082,19 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
4043
4082
  runHandler(handler).catch((e) => {
4044
4083
  handlerError = e;
4045
4084
  }),
4046
- loadRoutePromise
4085
+ // Ensure all lazy route promises are resolved before continuing
4086
+ lazyHandlerPromise,
4087
+ lazyRoutePromise
4047
4088
  ]);
4048
4089
  if (handlerError !== void 0) {
4049
4090
  throw handlerError;
4050
4091
  }
4051
4092
  result = value;
4052
4093
  } else {
4053
- await loadRoutePromise;
4094
+ await lazyHandlerPromise;
4054
4095
  handler = match.route[type];
4055
4096
  if (handler) {
4056
- result = await runHandler(handler);
4097
+ [result] = await Promise.all([runHandler(handler), lazyRoutePromise]);
4057
4098
  } else if (type === "action") {
4058
4099
  let url = new URL(request.url);
4059
4100
  let pathname = url.pathname + url.search;
@@ -7823,7 +7864,7 @@ function mergeRefs(...refs) {
7823
7864
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7824
7865
  try {
7825
7866
  if (isBrowser) {
7826
- window.__reactRouterVersion = "7.5.0-pre.0";
7867
+ window.__reactRouterVersion = "7.5.0-pre.1";
7827
7868
  }
7828
7869
  } catch (e) {
7829
7870
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -123,7 +123,7 @@ import {
123
123
  useSearchParams,
124
124
  useSubmit,
125
125
  useViewTransitionState
126
- } from "./chunk-RSOGH2WR.mjs";
126
+ } from "./chunk-AISJZE44.mjs";
127
127
  export {
128
128
  Await,
129
129
  BrowserRouter,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.5.0-pre.0
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router",
3
- "version": "7.5.0-pre.0",
3
+ "version": "7.5.0-pre.1",
4
4
  "description": "Declarative routing for React",
5
5
  "keywords": [
6
6
  "react",