react-router 7.4.1 → 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.
Files changed (36) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/development/{chunk-XJI4KG32.mjs → chunk-5BSZVSUP.mjs} +293 -162
  3. package/dist/development/dom-export.d.mts +2 -2
  4. package/dist/development/dom-export.d.ts +2 -2
  5. package/dist/development/dom-export.js +295 -157
  6. package/dist/development/dom-export.mjs +14 -2
  7. package/dist/development/{fog-of-war-BjgPfDmv.d.mts → fog-of-war-1hWhK5ey.d.mts} +3 -1
  8. package/dist/{production/fog-of-war-BaM-ohjc.d.ts → development/fog-of-war-oa9CGk10.d.ts} +3 -1
  9. package/dist/development/index.d.mts +4 -4
  10. package/dist/development/index.d.ts +4 -4
  11. package/dist/development/index.js +293 -162
  12. package/dist/development/index.mjs +2 -2
  13. package/dist/development/lib/types/route-module.d.mts +1 -1
  14. package/dist/development/lib/types/route-module.d.ts +1 -1
  15. package/dist/development/lib/types/route-module.js +1 -1
  16. package/dist/development/lib/types/route-module.mjs +1 -1
  17. package/dist/development/{route-data-BL8ToWby.d.ts → route-data-5OzAzQtT.d.mts} +19 -14
  18. package/dist/{production/route-data-BL8ToWby.d.mts → development/route-data-5OzAzQtT.d.ts} +19 -14
  19. package/dist/production/{chunk-T6D7EGPT.mjs → chunk-AISJZE44.mjs} +293 -162
  20. package/dist/production/dom-export.d.mts +2 -2
  21. package/dist/production/dom-export.d.ts +2 -2
  22. package/dist/production/dom-export.js +295 -157
  23. package/dist/production/dom-export.mjs +14 -2
  24. package/dist/production/{fog-of-war-BjgPfDmv.d.mts → fog-of-war-1hWhK5ey.d.mts} +3 -1
  25. package/dist/{development/fog-of-war-BaM-ohjc.d.ts → production/fog-of-war-oa9CGk10.d.ts} +3 -1
  26. package/dist/production/index.d.mts +4 -4
  27. package/dist/production/index.d.ts +4 -4
  28. package/dist/production/index.js +293 -162
  29. package/dist/production/index.mjs +2 -2
  30. package/dist/production/lib/types/route-module.d.mts +1 -1
  31. package/dist/production/lib/types/route-module.d.ts +1 -1
  32. package/dist/production/lib/types/route-module.js +1 -1
  33. package/dist/production/lib/types/route-module.mjs +1 -1
  34. package/dist/production/{route-data-BL8ToWby.d.ts → route-data-5OzAzQtT.d.mts} +19 -14
  35. package/dist/{development/route-data-BL8ToWby.d.mts → production/route-data-5OzAzQtT.d.ts} +19 -14
  36. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.4.1
2
+ * react-router v7.5.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -383,6 +383,19 @@ var unstable_RouterContextProvider = class {
383
383
  }
384
384
  };
385
385
  _map = new WeakMap();
386
+ var unsupportedLazyRouteObjectKeys = /* @__PURE__ */ new Set([
387
+ "lazy",
388
+ "caseSensitive",
389
+ "path",
390
+ "id",
391
+ "index",
392
+ "children"
393
+ ]);
394
+ function isUnsupportedLazyRouteObjectKey(key) {
395
+ return unsupportedLazyRouteObjectKeys.has(
396
+ key
397
+ );
398
+ }
386
399
  var unsupportedLazyRouteFunctionKeys = /* @__PURE__ */ new Set([
387
400
  "lazy",
388
401
  "caseSensitive",
@@ -390,9 +403,13 @@ var unsupportedLazyRouteFunctionKeys = /* @__PURE__ */ new Set([
390
403
  "id",
391
404
  "index",
392
405
  "unstable_middleware",
393
- "unstable_lazyMiddleware",
394
406
  "children"
395
407
  ]);
408
+ function isUnsupportedLazyRouteFunctionKey(key) {
409
+ return unsupportedLazyRouteFunctionKeys.has(
410
+ key
411
+ );
412
+ }
396
413
  function isIndexRoute(route) {
397
414
  return route.index === true;
398
415
  }
@@ -2683,14 +2700,18 @@ function createStaticHandler(routes, opts) {
2683
2700
  return respond ? respond(staticContext) : staticContext;
2684
2701
  }
2685
2702
  if (respond && matches.some(
2686
- (m) => m.route.unstable_middleware || m.route.unstable_lazyMiddleware
2703
+ (m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
2687
2704
  )) {
2688
2705
  invariant(
2689
2706
  requestContext instanceof unstable_RouterContextProvider,
2690
2707
  "When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"
2691
2708
  );
2692
2709
  try {
2693
- await loadLazyMiddlewareForMatches(matches, manifest);
2710
+ await loadLazyMiddlewareForMatches(
2711
+ matches,
2712
+ manifest,
2713
+ mapRouteProperties2
2714
+ );
2694
2715
  let renderedStaticContext;
2695
2716
  let response = await runMiddlewarePipeline(
2696
2717
  {
@@ -2807,13 +2828,13 @@ function createStaticHandler(routes, opts) {
2807
2828
  throw getInternalRouterError(404, { pathname: location.pathname });
2808
2829
  }
2809
2830
  if (respond && matches.some(
2810
- (m) => m.route.unstable_middleware || m.route.unstable_lazyMiddleware
2831
+ (m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
2811
2832
  )) {
2812
2833
  invariant(
2813
2834
  requestContext instanceof unstable_RouterContextProvider,
2814
2835
  "When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"
2815
2836
  );
2816
- await loadLazyMiddlewareForMatches(matches, manifest);
2837
+ await loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2);
2817
2838
  let response = await runMiddlewarePipeline(
2818
2839
  {
2819
2840
  request,
@@ -3531,79 +3552,166 @@ function isSameRoute(newRoute, existingRoute) {
3531
3552
  (aChild, i) => existingRoute.children?.some((bChild) => isSameRoute(aChild, bChild))
3532
3553
  );
3533
3554
  }
3534
- var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
3535
- async function loadLazyRouteModule(route, mapRouteProperties2, manifest) {
3555
+ var lazyRoutePropertyCache = /* @__PURE__ */ new WeakMap();
3556
+ var loadLazyRouteProperty = ({
3557
+ key,
3558
+ route,
3559
+ manifest,
3560
+ mapRouteProperties: mapRouteProperties2
3561
+ }) => {
3536
3562
  let routeToUpdate = manifest[route.id];
3537
3563
  invariant(routeToUpdate, "No route found in manifest");
3538
- if (!route.lazy) {
3564
+ if (!routeToUpdate.lazy || typeof routeToUpdate.lazy !== "object") {
3539
3565
  return;
3540
3566
  }
3541
- let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
3542
- if (cachedPromise) {
3543
- await cachedPromise;
3567
+ let lazyFn = routeToUpdate.lazy[key];
3568
+ if (!lazyFn) {
3544
3569
  return;
3545
3570
  }
3546
- let lazyRoutePromise = route.lazy().then((lazyRoute) => {
3547
- let routeUpdates = {};
3548
- for (let lazyRouteProperty in lazyRoute) {
3549
- let staticRouteValue = routeToUpdate[lazyRouteProperty];
3550
- let isPropertyStaticallyDefined = staticRouteValue !== void 0 && // This property isn't static since it should always be updated based
3551
- // on the route updates
3552
- lazyRouteProperty !== "hasErrorBoundary";
3571
+ let cache = lazyRoutePropertyCache.get(routeToUpdate);
3572
+ if (!cache) {
3573
+ cache = {};
3574
+ lazyRoutePropertyCache.set(routeToUpdate, cache);
3575
+ }
3576
+ let cachedPromise = cache[key];
3577
+ if (cachedPromise) {
3578
+ return cachedPromise;
3579
+ }
3580
+ let propertyPromise = (async () => {
3581
+ let isUnsupported = isUnsupportedLazyRouteObjectKey(key);
3582
+ let staticRouteValue = routeToUpdate[key];
3583
+ let isStaticallyDefined = staticRouteValue !== void 0 && key !== "hasErrorBoundary";
3584
+ if (isUnsupported) {
3553
3585
  warning(
3554
- !isPropertyStaticallyDefined,
3555
- `Route "${routeToUpdate.id}" has a static property "${lazyRouteProperty}" defined but its lazy function is also returning a value for this property. The lazy route property "${lazyRouteProperty}" will be ignored.`
3586
+ !isUnsupported,
3587
+ "Route property " + key + " is not a supported lazy route property. This property will be ignored."
3556
3588
  );
3589
+ cache[key] = Promise.resolve();
3590
+ } else if (isStaticallyDefined) {
3557
3591
  warning(
3558
- !unsupportedLazyRouteFunctionKeys.has(
3559
- lazyRouteProperty
3560
- ),
3561
- "Route property " + lazyRouteProperty + " is not a supported property to be returned from a lazy route function. This property will be ignored."
3592
+ false,
3593
+ `Route "${routeToUpdate.id}" has a static property "${key}" defined. The lazy property will be ignored.`
3562
3594
  );
3563
- if (!isPropertyStaticallyDefined && !unsupportedLazyRouteFunctionKeys.has(
3564
- lazyRouteProperty
3565
- )) {
3566
- routeUpdates[lazyRouteProperty] = lazyRoute[lazyRouteProperty];
3595
+ } else {
3596
+ let value = await lazyFn();
3597
+ if (value != null) {
3598
+ Object.assign(routeToUpdate, { [key]: value });
3599
+ Object.assign(routeToUpdate, mapRouteProperties2(routeToUpdate));
3567
3600
  }
3568
3601
  }
3569
- Object.assign(routeToUpdate, routeUpdates);
3570
- Object.assign(routeToUpdate, {
3571
- // To keep things framework agnostic, we use the provided `mapRouteProperties`
3572
- // function to set the framework-aware properties (`element`/`hasErrorBoundary`)
3573
- // since the logic will differ between frameworks.
3574
- ...mapRouteProperties2(routeToUpdate),
3575
- lazy: void 0
3576
- });
3577
- });
3578
- lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
3579
- await lazyRoutePromise;
3580
- }
3581
- async function loadLazyMiddleware(route, manifest) {
3582
- if (!route.unstable_lazyMiddleware) {
3583
- return;
3584
- }
3602
+ if (typeof routeToUpdate.lazy === "object") {
3603
+ routeToUpdate.lazy[key] = void 0;
3604
+ if (Object.values(routeToUpdate.lazy).every((value) => value === void 0)) {
3605
+ routeToUpdate.lazy = void 0;
3606
+ }
3607
+ }
3608
+ })();
3609
+ cache[key] = propertyPromise;
3610
+ return propertyPromise;
3611
+ };
3612
+ var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
3613
+ function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
3585
3614
  let routeToUpdate = manifest[route.id];
3586
3615
  invariant(routeToUpdate, "No route found in manifest");
3587
- if (routeToUpdate.unstable_middleware) {
3588
- warning(
3589
- false,
3590
- `Route "${routeToUpdate.id}" has a static property "unstable_middleware" defined. The "unstable_lazyMiddleware" function will be ignored.`
3591
- );
3592
- } else {
3593
- let middleware = await route.unstable_lazyMiddleware();
3594
- if (!route.unstable_lazyMiddleware) {
3595
- return;
3616
+ if (!route.lazy) {
3617
+ return {
3618
+ lazyRoutePromise: void 0,
3619
+ lazyHandlerPromise: void 0
3620
+ };
3621
+ }
3622
+ if (typeof route.lazy === "function") {
3623
+ let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
3624
+ if (cachedPromise) {
3625
+ return {
3626
+ lazyRoutePromise: cachedPromise,
3627
+ lazyHandlerPromise: cachedPromise
3628
+ };
3596
3629
  }
3597
- if (!routeToUpdate.unstable_middleware) {
3598
- routeToUpdate.unstable_middleware = middleware;
3630
+ let lazyRoutePromise2 = (async () => {
3631
+ invariant(
3632
+ typeof route.lazy === "function",
3633
+ "No lazy route function found"
3634
+ );
3635
+ let lazyRoute = await route.lazy();
3636
+ let routeUpdates = {};
3637
+ for (let lazyRouteProperty in lazyRoute) {
3638
+ let lazyValue = lazyRoute[lazyRouteProperty];
3639
+ if (lazyValue === void 0) {
3640
+ continue;
3641
+ }
3642
+ let isUnsupported = isUnsupportedLazyRouteFunctionKey(lazyRouteProperty);
3643
+ let staticRouteValue = routeToUpdate[lazyRouteProperty];
3644
+ let isStaticallyDefined = staticRouteValue !== void 0 && // This property isn't static since it should always be updated based
3645
+ // on the route updates
3646
+ lazyRouteProperty !== "hasErrorBoundary";
3647
+ if (isUnsupported) {
3648
+ warning(
3649
+ !isUnsupported,
3650
+ "Route property " + lazyRouteProperty + " is not a supported property to be returned from a lazy route function. This property will be ignored."
3651
+ );
3652
+ } else if (isStaticallyDefined) {
3653
+ warning(
3654
+ !isStaticallyDefined,
3655
+ `Route "${routeToUpdate.id}" has a static property "${lazyRouteProperty}" defined but its lazy function is also returning a value for this property. The lazy route property "${lazyRouteProperty}" will be ignored.`
3656
+ );
3657
+ } else {
3658
+ routeUpdates[lazyRouteProperty] = lazyValue;
3659
+ }
3660
+ }
3661
+ Object.assign(routeToUpdate, routeUpdates);
3662
+ Object.assign(routeToUpdate, {
3663
+ // To keep things framework agnostic, we use the provided `mapRouteProperties`
3664
+ // function to set the framework-aware properties (`element`/`hasErrorBoundary`)
3665
+ // since the logic will differ between frameworks.
3666
+ ...mapRouteProperties2(routeToUpdate),
3667
+ lazy: void 0
3668
+ });
3669
+ })();
3670
+ lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise2);
3671
+ return {
3672
+ lazyRoutePromise: lazyRoutePromise2,
3673
+ lazyHandlerPromise: lazyRoutePromise2
3674
+ };
3675
+ }
3676
+ let lazyKeys = Object.keys(route.lazy);
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
+ }
3599
3691
  }
3600
3692
  }
3601
- routeToUpdate.unstable_lazyMiddleware = void 0;
3693
+ let lazyRoutePromise = Promise.all(lazyPropertyPromises).then(() => {
3694
+ });
3695
+ return {
3696
+ lazyRoutePromise,
3697
+ lazyHandlerPromise
3698
+ };
3602
3699
  }
3603
- function loadLazyMiddlewareForMatches(matches, manifest) {
3604
- let promises = matches.map(
3605
- (m) => m.route.unstable_lazyMiddleware ? loadLazyMiddleware(m.route, manifest) : void 0
3606
- ).filter(Boolean);
3700
+ function isNonNullable(value) {
3701
+ return value !== void 0;
3702
+ }
3703
+ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
3704
+ let promises = matches.map(({ route }) => {
3705
+ if (typeof route.lazy !== "object" || !route.lazy.unstable_middleware) {
3706
+ return void 0;
3707
+ }
3708
+ return loadLazyRouteProperty({
3709
+ key: "unstable_middleware",
3710
+ route,
3711
+ manifest,
3712
+ mapRouteProperties: mapRouteProperties2
3713
+ });
3714
+ }).filter(isNonNullable);
3607
3715
  return promises.length > 0 ? Promise.all(promises) : void 0;
3608
3716
  }
3609
3717
  async function defaultDataStrategy(args) {
@@ -3721,28 +3829,33 @@ async function callRouteMiddleware(args, middlewares, propagateResult, middlewar
3721
3829
  }
3722
3830
  }
3723
3831
  async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties2, scopedContext) {
3724
- let loadMiddlewarePromise = loadLazyMiddlewareForMatches(matches, manifest);
3725
- let loadRouteDefinitionsPromises = matches.map(
3726
- (m) => m.route.lazy ? loadLazyRouteModule(m.route, mapRouteProperties2, manifest) : void 0
3832
+ let loadMiddlewarePromise = loadLazyMiddlewareForMatches(
3833
+ matches,
3834
+ manifest,
3835
+ mapRouteProperties2
3836
+ );
3837
+ let lazyRoutePromises = matches.map(
3838
+ (m) => loadLazyRoute(m.route, type, manifest, mapRouteProperties2)
3727
3839
  );
3728
3840
  if (loadMiddlewarePromise) {
3729
3841
  await loadMiddlewarePromise;
3730
3842
  }
3731
3843
  let dsMatches = matches.map((match, i) => {
3732
- let loadRoutePromise = loadRouteDefinitionsPromises[i];
3844
+ let { lazyRoutePromise, lazyHandlerPromise } = lazyRoutePromises[i];
3733
3845
  let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
3734
3846
  let resolve = async (handlerOverride) => {
3735
3847
  if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
3736
3848
  shouldLoad = true;
3737
3849
  }
3738
- return shouldLoad ? callLoaderOrAction(
3850
+ return shouldLoad ? callLoaderOrAction({
3739
3851
  type,
3740
3852
  request,
3741
3853
  match,
3742
- loadRoutePromise,
3854
+ lazyHandlerPromise,
3855
+ lazyRoutePromise,
3743
3856
  handlerOverride,
3744
3857
  scopedContext
3745
- ) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3858
+ }) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3746
3859
  };
3747
3860
  return {
3748
3861
  ...match,
@@ -3757,13 +3870,24 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3757
3870
  fetcherKey,
3758
3871
  context: scopedContext
3759
3872
  });
3873
+ let allLazyRoutePromises = lazyRoutePromises.flatMap(
3874
+ (promiseMap) => Object.values(promiseMap).filter(isNonNullable)
3875
+ );
3760
3876
  try {
3761
- await Promise.all(loadRouteDefinitionsPromises);
3877
+ await Promise.all(allLazyRoutePromises);
3762
3878
  } catch (e) {
3763
3879
  }
3764
3880
  return results;
3765
3881
  }
3766
- 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
+ }) {
3767
3891
  let result;
3768
3892
  let onReject;
3769
3893
  let runHandler = (handler) => {
@@ -3800,7 +3924,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3800
3924
  };
3801
3925
  try {
3802
3926
  let handler = match.route[type];
3803
- if (loadRoutePromise) {
3927
+ if (lazyHandlerPromise || lazyRoutePromise) {
3804
3928
  if (handler) {
3805
3929
  let handlerError;
3806
3930
  let [value] = await Promise.all([
@@ -3810,17 +3934,19 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3810
3934
  runHandler(handler).catch((e) => {
3811
3935
  handlerError = e;
3812
3936
  }),
3813
- loadRoutePromise
3937
+ // Ensure all lazy route promises are resolved before continuing
3938
+ lazyHandlerPromise,
3939
+ lazyRoutePromise
3814
3940
  ]);
3815
3941
  if (handlerError !== void 0) {
3816
3942
  throw handlerError;
3817
3943
  }
3818
3944
  result = value;
3819
3945
  } else {
3820
- await loadRoutePromise;
3946
+ await lazyHandlerPromise;
3821
3947
  handler = match.route[type];
3822
3948
  if (handler) {
3823
- result = await runHandler(handler);
3949
+ [result] = await Promise.all([runHandler(handler), lazyRoutePromise]);
3824
3950
  } else if (type === "action") {
3825
3951
  let url = new URL(request.url);
3826
3952
  let pathname = url.pathname + url.search;
@@ -6746,22 +6872,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6746
6872
  dataRoute.loader = (_, singleFetch) => prefetchStylesAndCallHandler(() => {
6747
6873
  return fetchServerLoader(singleFetch);
6748
6874
  });
6749
- } else if (route.clientLoaderModule) {
6750
- dataRoute.loader = async (args, singleFetch) => {
6751
- invariant2(route.clientLoaderModule);
6752
- let { clientLoader } = await import(
6753
- /* @vite-ignore */
6754
- /* webpackIgnore: true */
6755
- route.clientLoaderModule
6756
- );
6757
- return clientLoader({
6758
- ...args,
6759
- async serverLoader() {
6760
- preventInvalidServerHandlerCall("loader", route);
6761
- return fetchServerLoader(singleFetch);
6762
- }
6763
- });
6764
- };
6765
6875
  }
6766
6876
  if (!route.hasClientAction) {
6767
6877
  dataRoute.action = (_, singleFetch) => prefetchStylesAndCallHandler(() => {
@@ -6770,86 +6880,84 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6770
6880
  }
6771
6881
  return fetchServerAction(singleFetch);
6772
6882
  });
6773
- } else if (route.clientActionModule) {
6774
- dataRoute.action = async (args, singleFetch) => {
6775
- invariant2(route.clientActionModule);
6776
- prefetchRouteModuleChunks(route);
6777
- let { clientAction } = await import(
6778
- /* @vite-ignore */
6779
- /* webpackIgnore: true */
6780
- route.clientActionModule
6883
+ }
6884
+ let lazyRoutePromise;
6885
+ async function getLazyRoute() {
6886
+ if (lazyRoutePromise) {
6887
+ return await lazyRoutePromise;
6888
+ }
6889
+ lazyRoutePromise = (async () => {
6890
+ if (route.clientLoaderModule || route.clientActionModule) {
6891
+ await new Promise((resolve) => setTimeout(resolve, 0));
6892
+ }
6893
+ let routeModulePromise = loadRouteModuleWithBlockingLinks(
6894
+ route,
6895
+ routeModulesCache
6781
6896
  );
6782
- return clientAction({
6783
- ...args,
6784
- async serverAction() {
6785
- preventInvalidServerHandlerCall("action", route);
6786
- return fetchServerAction(singleFetch);
6787
- }
6788
- });
6789
- };
6897
+ prefetchRouteModuleChunks(route);
6898
+ return await routeModulePromise;
6899
+ })();
6900
+ return await lazyRoutePromise;
6790
6901
  }
6791
- if (route.hasClientMiddleware) {
6792
- dataRoute.unstable_lazyMiddleware = async () => {
6793
- invariant2(route);
6794
- let clientMiddlewareModule = await import(
6902
+ dataRoute.lazy = {
6903
+ loader: route.hasClientLoader ? async () => {
6904
+ let { clientLoader } = route.clientLoaderModule ? await import(
6795
6905
  /* @vite-ignore */
6796
6906
  /* webpackIgnore: true */
6797
- route.clientMiddlewareModule || route.module
6798
- );
6799
- invariant2(
6800
- clientMiddlewareModule?.unstable_clientMiddleware,
6801
- "No `unstable_clientMiddleware` export in chunk"
6802
- );
6803
- return clientMiddlewareModule.unstable_clientMiddleware;
6804
- };
6805
- }
6806
- dataRoute.lazy = async () => {
6807
- if (route.clientLoaderModule || route.clientActionModule) {
6808
- await new Promise((resolve) => setTimeout(resolve, 0));
6809
- }
6810
- let modPromise = loadRouteModuleWithBlockingLinks(
6811
- route,
6812
- routeModulesCache
6813
- );
6814
- prefetchRouteModuleChunks(route);
6815
- let mod = await modPromise;
6816
- let lazyRoute = { ...mod };
6817
- if (mod.clientLoader) {
6818
- let clientLoader = mod.clientLoader;
6819
- lazyRoute.loader = (args, singleFetch) => clientLoader({
6907
+ route.clientLoaderModule
6908
+ ) : await getLazyRoute();
6909
+ invariant2(clientLoader, "No `clientLoader` export found");
6910
+ return (args, singleFetch) => clientLoader({
6820
6911
  ...args,
6821
6912
  async serverLoader() {
6822
6913
  preventInvalidServerHandlerCall("loader", route);
6823
6914
  return fetchServerLoader(singleFetch);
6824
6915
  }
6825
6916
  });
6826
- }
6827
- if (mod.clientAction) {
6828
- let clientAction = mod.clientAction;
6829
- lazyRoute.action = (args, singleFetch) => clientAction({
6917
+ } : void 0,
6918
+ action: route.hasClientAction ? async () => {
6919
+ let clientActionPromise = route.clientActionModule ? import(
6920
+ /* @vite-ignore */
6921
+ /* webpackIgnore: true */
6922
+ route.clientActionModule
6923
+ ) : getLazyRoute();
6924
+ prefetchRouteModuleChunks(route);
6925
+ let { clientAction } = await clientActionPromise;
6926
+ invariant2(clientAction, "No `clientAction` export found");
6927
+ return (args, singleFetch) => clientAction({
6830
6928
  ...args,
6831
6929
  async serverAction() {
6832
6930
  preventInvalidServerHandlerCall("action", route);
6833
6931
  return fetchServerAction(singleFetch);
6834
6932
  }
6835
6933
  });
6836
- }
6837
- return {
6838
- ...lazyRoute.loader ? { loader: lazyRoute.loader } : {},
6839
- ...lazyRoute.action ? { action: lazyRoute.action } : {},
6840
- hasErrorBoundary: lazyRoute.hasErrorBoundary,
6841
- shouldRevalidate: getShouldRevalidateFunction(
6934
+ } : void 0,
6935
+ unstable_middleware: route.hasClientMiddleware ? async () => {
6936
+ let { unstable_clientMiddleware } = route.clientMiddlewareModule ? await import(
6937
+ /* @vite-ignore */
6938
+ /* webpackIgnore: true */
6939
+ route.clientMiddlewareModule
6940
+ ) : await getLazyRoute();
6941
+ invariant2(
6942
+ unstable_clientMiddleware,
6943
+ "No `unstable_clientMiddleware` export found"
6944
+ );
6945
+ return unstable_clientMiddleware;
6946
+ } : void 0,
6947
+ shouldRevalidate: async () => {
6948
+ let lazyRoute = await getLazyRoute();
6949
+ return getShouldRevalidateFunction(
6842
6950
  lazyRoute,
6843
6951
  route,
6844
6952
  ssr,
6845
6953
  needsRevalidation
6846
- ),
6847
- handle: lazyRoute.handle,
6848
- // No need to wrap these in layout since the root route is never
6849
- // loaded via route.lazy()
6850
- Component: lazyRoute.Component,
6851
- ErrorBoundary: lazyRoute.ErrorBoundary
6852
- };
6954
+ );
6955
+ },
6956
+ handle: async () => (await getLazyRoute()).handle,
6957
+ // No need to wrap these in layout since the root route is never
6958
+ // loaded via route.lazy()
6959
+ Component: async () => (await getLazyRoute()).Component,
6960
+ ErrorBoundary: route.hasErrorBoundary ? async () => (await getLazyRoute()).ErrorBoundary : void 0
6853
6961
  };
6854
6962
  }
6855
6963
  let children = createClientRoutes(
@@ -6937,7 +7045,7 @@ var URL_LIMIT = 7680;
6937
7045
  function isFogOfWarEnabled(ssr) {
6938
7046
  return ssr === true;
6939
7047
  }
6940
- function getPartialManifest(manifest, router) {
7048
+ function getPartialManifest({ sri, ...manifest }, router) {
6941
7049
  let routeIds = new Set(router.state.matches.map((m) => m.route.id));
6942
7050
  let segments = router.state.location.pathname.split("/").filter(Boolean);
6943
7051
  let paths = ["/"];
@@ -6958,7 +7066,8 @@ function getPartialManifest(manifest, router) {
6958
7066
  );
6959
7067
  return {
6960
7068
  ...manifest,
6961
- routes: initialRoutes
7069
+ routes: initialRoutes,
7070
+ sri: sri ? true : void 0
6962
7071
  };
6963
7072
  }
6964
7073
  function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
@@ -7538,32 +7647,53 @@ import(${JSON.stringify(manifest.entry.module)});`;
7538
7647
  }
7539
7648
  ));
7540
7649
  }, []);
7541
- let preloads = isHydrated ? [] : manifest.entry.imports.concat(
7542
- getModuleLinkHrefs(matches, manifest, {
7543
- includeHydrateFallback: true
7544
- })
7650
+ let preloads = isHydrated ? [] : dedupe(
7651
+ manifest.entry.imports.concat(
7652
+ getModuleLinkHrefs(matches, manifest, {
7653
+ includeHydrateFallback: true
7654
+ })
7655
+ )
7545
7656
  );
7546
- return isHydrated ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, !enableFogOfWar ? /* @__PURE__ */ React9.createElement(
7657
+ let sri = typeof manifest.sri === "object" ? manifest.sri : {};
7658
+ return isHydrated ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, typeof manifest.sri === "object" ? /* @__PURE__ */ React9.createElement(
7659
+ "script",
7660
+ {
7661
+ "rr-importmap": "",
7662
+ type: "importmap",
7663
+ suppressHydrationWarning: true,
7664
+ dangerouslySetInnerHTML: {
7665
+ __html: JSON.stringify({
7666
+ integrity: sri
7667
+ })
7668
+ }
7669
+ }
7670
+ ) : null, !enableFogOfWar ? /* @__PURE__ */ React9.createElement(
7547
7671
  "link",
7548
7672
  {
7549
7673
  rel: "modulepreload",
7550
7674
  href: manifest.url,
7551
- crossOrigin: props.crossOrigin
7675
+ crossOrigin: props.crossOrigin,
7676
+ integrity: sri[manifest.url],
7677
+ suppressHydrationWarning: true
7552
7678
  }
7553
7679
  ) : null, /* @__PURE__ */ React9.createElement(
7554
7680
  "link",
7555
7681
  {
7556
7682
  rel: "modulepreload",
7557
7683
  href: manifest.entry.module,
7558
- crossOrigin: props.crossOrigin
7684
+ crossOrigin: props.crossOrigin,
7685
+ integrity: sri[manifest.entry.module],
7686
+ suppressHydrationWarning: true
7559
7687
  }
7560
- ), dedupe(preloads).map((path) => /* @__PURE__ */ React9.createElement(
7688
+ ), preloads.map((path) => /* @__PURE__ */ React9.createElement(
7561
7689
  "link",
7562
7690
  {
7563
7691
  key: path,
7564
7692
  rel: "modulepreload",
7565
7693
  href: path,
7566
- crossOrigin: props.crossOrigin
7694
+ crossOrigin: props.crossOrigin,
7695
+ integrity: sri[path],
7696
+ suppressHydrationWarning: true
7567
7697
  }
7568
7698
  )), initialScripts);
7569
7699
  }
@@ -7586,7 +7716,7 @@ function mergeRefs(...refs) {
7586
7716
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7587
7717
  try {
7588
7718
  if (isBrowser) {
7589
- window.__reactRouterVersion = "7.4.1";
7719
+ window.__reactRouterVersion = "7.5.0-pre.1";
7590
7720
  }
7591
7721
  } catch (e) {
7592
7722
  }
@@ -8741,6 +8871,7 @@ function createRoutesStub(routes, unstable_getContext) {
8741
8871
  if (routerRef.current == null) {
8742
8872
  remixContextRef.current = {
8743
8873
  future: {
8874
+ unstable_subResourceIntegrity: future?.unstable_subResourceIntegrity === true,
8744
8875
  unstable_middleware: future?.unstable_middleware === true
8745
8876
  },
8746
8877
  manifest: {
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1 } from './fog-of-war-BjgPfDmv.mjs';
3
- import { R as RouterInit } from './route-data-BL8ToWby.mjs';
2
+ import { R as RouterProviderProps$1 } from './fog-of-war-1hWhK5ey.mjs';
3
+ import { R as RouterInit } from './route-data-5OzAzQtT.mjs';
4
4
 
5
5
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
6
6
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;