react-router 0.0.0-experimental-2e661fbb4 → 0.0.0-experimental-c8b52c995

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 +53 -1
  2. package/dist/development/{chunk-J5BQFBPQ.mjs → chunk-4K5PIBZY.mjs} +336 -179
  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 +305 -160
  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 +336 -179
  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-XSS6E6T7.mjs → chunk-UDVCEGG6.mjs} +336 -179
  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 +305 -160
  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 +336 -179
  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 v0.0.0-experimental-2e661fbb4
2
+ * react-router v0.0.0-experimental-c8b52c995
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;
@@ -6669,6 +6795,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6669
6795
  unstable_middleware: routeModule.unstable_clientMiddleware,
6670
6796
  handle: routeModule.handle,
6671
6797
  shouldRevalidate: getShouldRevalidateFunction(
6798
+ dataRoute.path,
6672
6799
  routeModule,
6673
6800
  route,
6674
6801
  ssr,
@@ -6746,22 +6873,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6746
6873
  dataRoute.loader = (_, singleFetch) => prefetchStylesAndCallHandler(() => {
6747
6874
  return fetchServerLoader(singleFetch);
6748
6875
  });
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
6876
  }
6766
6877
  if (!route.hasClientAction) {
6767
6878
  dataRoute.action = (_, singleFetch) => prefetchStylesAndCallHandler(() => {
@@ -6770,86 +6881,85 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6770
6881
  }
6771
6882
  return fetchServerAction(singleFetch);
6772
6883
  });
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
6884
+ }
6885
+ let lazyRoutePromise;
6886
+ async function getLazyRoute() {
6887
+ if (lazyRoutePromise) {
6888
+ return await lazyRoutePromise;
6889
+ }
6890
+ lazyRoutePromise = (async () => {
6891
+ if (route.clientLoaderModule || route.clientActionModule) {
6892
+ await new Promise((resolve) => setTimeout(resolve, 0));
6893
+ }
6894
+ let routeModulePromise = loadRouteModuleWithBlockingLinks(
6895
+ route,
6896
+ routeModulesCache
6781
6897
  );
6782
- return clientAction({
6783
- ...args,
6784
- async serverAction() {
6785
- preventInvalidServerHandlerCall("action", route);
6786
- return fetchServerAction(singleFetch);
6787
- }
6788
- });
6789
- };
6898
+ prefetchRouteModuleChunks(route);
6899
+ return await routeModulePromise;
6900
+ })();
6901
+ return await lazyRoutePromise;
6790
6902
  }
6791
- if (route.hasClientMiddleware) {
6792
- dataRoute.unstable_lazyMiddleware = async () => {
6793
- invariant2(route);
6794
- let clientMiddlewareModule = await import(
6903
+ dataRoute.lazy = {
6904
+ loader: route.hasClientLoader ? async () => {
6905
+ let { clientLoader } = route.clientLoaderModule ? await import(
6795
6906
  /* @vite-ignore */
6796
6907
  /* 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({
6908
+ route.clientLoaderModule
6909
+ ) : await getLazyRoute();
6910
+ invariant2(clientLoader, "No `clientLoader` export found");
6911
+ return (args, singleFetch) => clientLoader({
6820
6912
  ...args,
6821
6913
  async serverLoader() {
6822
6914
  preventInvalidServerHandlerCall("loader", route);
6823
6915
  return fetchServerLoader(singleFetch);
6824
6916
  }
6825
6917
  });
6826
- }
6827
- if (mod.clientAction) {
6828
- let clientAction = mod.clientAction;
6829
- lazyRoute.action = (args, singleFetch) => clientAction({
6918
+ } : void 0,
6919
+ action: route.hasClientAction ? async () => {
6920
+ let clientActionPromise = route.clientActionModule ? import(
6921
+ /* @vite-ignore */
6922
+ /* webpackIgnore: true */
6923
+ route.clientActionModule
6924
+ ) : getLazyRoute();
6925
+ prefetchRouteModuleChunks(route);
6926
+ let { clientAction } = await clientActionPromise;
6927
+ invariant2(clientAction, "No `clientAction` export found");
6928
+ return (args, singleFetch) => clientAction({
6830
6929
  ...args,
6831
6930
  async serverAction() {
6832
6931
  preventInvalidServerHandlerCall("action", route);
6833
6932
  return fetchServerAction(singleFetch);
6834
6933
  }
6835
6934
  });
6836
- }
6837
- return {
6838
- ...lazyRoute.loader ? { loader: lazyRoute.loader } : {},
6839
- ...lazyRoute.action ? { action: lazyRoute.action } : {},
6840
- hasErrorBoundary: lazyRoute.hasErrorBoundary,
6841
- shouldRevalidate: getShouldRevalidateFunction(
6935
+ } : void 0,
6936
+ unstable_middleware: route.hasClientMiddleware ? async () => {
6937
+ let { unstable_clientMiddleware } = route.clientMiddlewareModule ? await import(
6938
+ /* @vite-ignore */
6939
+ /* webpackIgnore: true */
6940
+ route.clientMiddlewareModule
6941
+ ) : await getLazyRoute();
6942
+ invariant2(
6943
+ unstable_clientMiddleware,
6944
+ "No `unstable_clientMiddleware` export found"
6945
+ );
6946
+ return unstable_clientMiddleware;
6947
+ } : void 0,
6948
+ shouldRevalidate: async () => {
6949
+ let lazyRoute = await getLazyRoute();
6950
+ return getShouldRevalidateFunction(
6951
+ dataRoute.path,
6842
6952
  lazyRoute,
6843
6953
  route,
6844
6954
  ssr,
6845
6955
  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
- };
6956
+ );
6957
+ },
6958
+ handle: async () => (await getLazyRoute()).handle,
6959
+ // No need to wrap these in layout since the root route is never
6960
+ // loaded via route.lazy()
6961
+ Component: async () => (await getLazyRoute()).Component,
6962
+ ErrorBoundary: route.hasErrorBoundary ? async () => (await getLazyRoute()).ErrorBoundary : void 0
6853
6963
  };
6854
6964
  }
6855
6965
  let children = createClientRoutes(
@@ -6866,7 +6976,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6866
6976
  return dataRoute;
6867
6977
  });
6868
6978
  }
6869
- function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidation) {
6979
+ function getShouldRevalidateFunction(path, route, manifestRoute, ssr, needsRevalidation) {
6870
6980
  if (needsRevalidation) {
6871
6981
  return wrapShouldRevalidateForHdr(
6872
6982
  manifestRoute.id,
@@ -6875,11 +6985,16 @@ function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidatio
6875
6985
  );
6876
6986
  }
6877
6987
  if (!ssr && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
6988
+ let myParams = path ? compilePath(path)[1].map((p) => p.paramName) : [];
6989
+ const didParamsChange = (opts) => myParams.some((p) => opts.currentParams[p] !== opts.nextParams[p]);
6878
6990
  if (route.shouldRevalidate) {
6879
6991
  let fn = route.shouldRevalidate;
6880
- return (opts) => fn({ ...opts, defaultShouldRevalidate: false });
6992
+ return (opts) => fn({
6993
+ ...opts,
6994
+ defaultShouldRevalidate: didParamsChange(opts)
6995
+ });
6881
6996
  } else {
6882
- return () => false;
6997
+ return (opts) => didParamsChange(opts);
6883
6998
  }
6884
6999
  }
6885
7000
  if (ssr && route.shouldRevalidate) {
@@ -6937,7 +7052,7 @@ var URL_LIMIT = 7680;
6937
7052
  function isFogOfWarEnabled(ssr) {
6938
7053
  return ssr === true;
6939
7054
  }
6940
- function getPartialManifest(manifest, router) {
7055
+ function getPartialManifest({ sri, ...manifest }, router) {
6941
7056
  let routeIds = new Set(router.state.matches.map((m) => m.route.id));
6942
7057
  let segments = router.state.location.pathname.split("/").filter(Boolean);
6943
7058
  let paths = ["/"];
@@ -6958,7 +7073,8 @@ function getPartialManifest(manifest, router) {
6958
7073
  );
6959
7074
  return {
6960
7075
  ...manifest,
6961
- routes: initialRoutes
7076
+ routes: initialRoutes,
7077
+ sri: sri ? true : void 0
6962
7078
  };
6963
7079
  }
6964
7080
  function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
@@ -7538,32 +7654,53 @@ import(${JSON.stringify(manifest.entry.module)});`;
7538
7654
  }
7539
7655
  ));
7540
7656
  }, []);
7541
- let preloads = isHydrated ? [] : manifest.entry.imports.concat(
7542
- getModuleLinkHrefs(matches, manifest, {
7543
- includeHydrateFallback: true
7544
- })
7657
+ let preloads = isHydrated ? [] : dedupe(
7658
+ manifest.entry.imports.concat(
7659
+ getModuleLinkHrefs(matches, manifest, {
7660
+ includeHydrateFallback: true
7661
+ })
7662
+ )
7545
7663
  );
7546
- return isHydrated ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, !enableFogOfWar ? /* @__PURE__ */ React9.createElement(
7664
+ let sri = typeof manifest.sri === "object" ? manifest.sri : {};
7665
+ return isHydrated ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, typeof manifest.sri === "object" ? /* @__PURE__ */ React9.createElement(
7666
+ "script",
7667
+ {
7668
+ "rr-importmap": "",
7669
+ type: "importmap",
7670
+ suppressHydrationWarning: true,
7671
+ dangerouslySetInnerHTML: {
7672
+ __html: JSON.stringify({
7673
+ integrity: sri
7674
+ })
7675
+ }
7676
+ }
7677
+ ) : null, !enableFogOfWar ? /* @__PURE__ */ React9.createElement(
7547
7678
  "link",
7548
7679
  {
7549
7680
  rel: "modulepreload",
7550
7681
  href: manifest.url,
7551
- crossOrigin: props.crossOrigin
7682
+ crossOrigin: props.crossOrigin,
7683
+ integrity: sri[manifest.url],
7684
+ suppressHydrationWarning: true
7552
7685
  }
7553
7686
  ) : null, /* @__PURE__ */ React9.createElement(
7554
7687
  "link",
7555
7688
  {
7556
7689
  rel: "modulepreload",
7557
7690
  href: manifest.entry.module,
7558
- crossOrigin: props.crossOrigin
7691
+ crossOrigin: props.crossOrigin,
7692
+ integrity: sri[manifest.entry.module],
7693
+ suppressHydrationWarning: true
7559
7694
  }
7560
- ), dedupe(preloads).map((path) => /* @__PURE__ */ React9.createElement(
7695
+ ), preloads.map((path) => /* @__PURE__ */ React9.createElement(
7561
7696
  "link",
7562
7697
  {
7563
7698
  key: path,
7564
7699
  rel: "modulepreload",
7565
7700
  href: path,
7566
- crossOrigin: props.crossOrigin
7701
+ crossOrigin: props.crossOrigin,
7702
+ integrity: sri[path],
7703
+ suppressHydrationWarning: true
7567
7704
  }
7568
7705
  )), initialScripts);
7569
7706
  }
@@ -7586,7 +7723,7 @@ function mergeRefs(...refs) {
7586
7723
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7587
7724
  try {
7588
7725
  if (isBrowser) {
7589
- window.__reactRouterVersion = "0.0.0-experimental-2e661fbb4";
7726
+ window.__reactRouterVersion = "0.0.0-experimental-c8b52c995";
7590
7727
  }
7591
7728
  } catch (e) {
7592
7729
  }
@@ -8741,6 +8878,7 @@ function createRoutesStub(routes, unstable_getContext) {
8741
8878
  if (routerRef.current == null) {
8742
8879
  remixContextRef.current = {
8743
8880
  future: {
8881
+ unstable_subResourceIntegrity: future?.unstable_subResourceIntegrity === true,
8744
8882
  unstable_middleware: future?.unstable_middleware === true
8745
8883
  },
8746
8884
  manifest: {
@@ -9607,9 +9745,6 @@ var createRequestHandler = (build, mode) => {
9607
9745
  let errorHandler;
9608
9746
  return async function requestHandler(request, initialContext) {
9609
9747
  _build = typeof build === "function" ? await build() : build;
9610
- let loadContext = _build.future.unstable_middleware ? new unstable_RouterContextProvider(
9611
- initialContext
9612
- ) : initialContext || {};
9613
9748
  if (typeof build === "function") {
9614
9749
  let derived = derive(_build, mode);
9615
9750
  routes = derived.routes;
@@ -9623,18 +9758,8 @@ var createRequestHandler = (build, mode) => {
9623
9758
  staticHandler = derived.staticHandler;
9624
9759
  errorHandler = derived.errorHandler;
9625
9760
  }
9626
- let url = new URL(request.url);
9627
- let normalizedBasename = _build.basename || "/";
9628
- let normalizedPath = url.pathname;
9629
- if (stripBasename(normalizedPath, normalizedBasename) === "/_root.data") {
9630
- normalizedPath = normalizedBasename;
9631
- } else if (normalizedPath.endsWith(".data")) {
9632
- normalizedPath = normalizedPath.replace(/\.data$/, "");
9633
- }
9634
- if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
9635
- normalizedPath = normalizedPath.slice(0, -1);
9636
- }
9637
9761
  let params = {};
9762
+ let loadContext;
9638
9763
  let handleError = (error) => {
9639
9764
  if (mode === "development" /* Development */) {
9640
9765
  getDevServerHooks()?.processRequestError?.(error);
@@ -9645,6 +9770,38 @@ var createRequestHandler = (build, mode) => {
9645
9770
  request
9646
9771
  });
9647
9772
  };
9773
+ if (_build.future.unstable_middleware) {
9774
+ if (initialContext == null) {
9775
+ loadContext = new unstable_RouterContextProvider();
9776
+ } else {
9777
+ try {
9778
+ loadContext = new unstable_RouterContextProvider(
9779
+ initialContext
9780
+ );
9781
+ } catch (e) {
9782
+ let error = new Error(
9783
+ `Unable to create initial \`unstable_RouterContextProvider\` instance. Please confirm you are returning an instance of \`Map<unstable_routerContext, unknown>\` from your \`getLoadContext\` function.
9784
+
9785
+ Error: ${e instanceof Error ? e.toString() : e}`
9786
+ );
9787
+ handleError(error);
9788
+ return returnLastResortErrorResponse(error, serverMode);
9789
+ }
9790
+ }
9791
+ } else {
9792
+ loadContext = initialContext || {};
9793
+ }
9794
+ let url = new URL(request.url);
9795
+ let normalizedBasename = _build.basename || "/";
9796
+ let normalizedPath = url.pathname;
9797
+ if (stripBasename(normalizedPath, normalizedBasename) === "/_root.data") {
9798
+ normalizedPath = normalizedBasename;
9799
+ } else if (normalizedPath.endsWith(".data")) {
9800
+ normalizedPath = normalizedPath.replace(/\.data$/, "");
9801
+ }
9802
+ if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
9803
+ normalizedPath = normalizedPath.slice(0, -1);
9804
+ }
9648
9805
  if (!_build.ssr) {
9649
9806
  if (_build.prerender.length === 0) {
9650
9807
  request.headers.set("X-React-Router-SPA-Mode", "yes");