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,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1 } from './fog-of-war-BaM-ohjc.js';
3
- import { R as RouterInit } from './route-data-BL8ToWby.js';
2
+ import { R as RouterProviderProps$1 } from './fog-of-war-oa9CGk10.js';
3
+ import { R as RouterInit } from './route-data-5OzAzQtT.js';
4
4
 
5
5
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
6
6
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
@@ -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
  *
@@ -275,6 +275,19 @@ var unstable_RouterContextProvider = class {
275
275
  }
276
276
  };
277
277
  _map = new WeakMap();
278
+ var unsupportedLazyRouteObjectKeys = /* @__PURE__ */ new Set([
279
+ "lazy",
280
+ "caseSensitive",
281
+ "path",
282
+ "id",
283
+ "index",
284
+ "children"
285
+ ]);
286
+ function isUnsupportedLazyRouteObjectKey(key) {
287
+ return unsupportedLazyRouteObjectKeys.has(
288
+ key
289
+ );
290
+ }
278
291
  var unsupportedLazyRouteFunctionKeys = /* @__PURE__ */ new Set([
279
292
  "lazy",
280
293
  "caseSensitive",
@@ -282,9 +295,13 @@ var unsupportedLazyRouteFunctionKeys = /* @__PURE__ */ new Set([
282
295
  "id",
283
296
  "index",
284
297
  "unstable_middleware",
285
- "unstable_lazyMiddleware",
286
298
  "children"
287
299
  ]);
300
+ function isUnsupportedLazyRouteFunctionKey(key) {
301
+ return unsupportedLazyRouteFunctionKeys.has(
302
+ key
303
+ );
304
+ }
288
305
  function isIndexRoute(route) {
289
306
  return route.index === true;
290
307
  }
@@ -2823,79 +2840,166 @@ function isSameRoute(newRoute, existingRoute) {
2823
2840
  (aChild, i) => existingRoute.children?.some((bChild) => isSameRoute(aChild, bChild))
2824
2841
  );
2825
2842
  }
2826
- var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
2827
- async function loadLazyRouteModule(route, mapRouteProperties2, manifest) {
2843
+ var lazyRoutePropertyCache = /* @__PURE__ */ new WeakMap();
2844
+ var loadLazyRouteProperty = ({
2845
+ key,
2846
+ route,
2847
+ manifest,
2848
+ mapRouteProperties: mapRouteProperties2
2849
+ }) => {
2828
2850
  let routeToUpdate = manifest[route.id];
2829
2851
  invariant(routeToUpdate, "No route found in manifest");
2830
- if (!route.lazy) {
2852
+ if (!routeToUpdate.lazy || typeof routeToUpdate.lazy !== "object") {
2831
2853
  return;
2832
2854
  }
2833
- let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
2834
- if (cachedPromise) {
2835
- await cachedPromise;
2855
+ let lazyFn = routeToUpdate.lazy[key];
2856
+ if (!lazyFn) {
2836
2857
  return;
2837
2858
  }
2838
- let lazyRoutePromise = route.lazy().then((lazyRoute) => {
2839
- let routeUpdates = {};
2840
- for (let lazyRouteProperty in lazyRoute) {
2841
- let staticRouteValue = routeToUpdate[lazyRouteProperty];
2842
- let isPropertyStaticallyDefined = staticRouteValue !== void 0 && // This property isn't static since it should always be updated based
2843
- // on the route updates
2844
- lazyRouteProperty !== "hasErrorBoundary";
2859
+ let cache = lazyRoutePropertyCache.get(routeToUpdate);
2860
+ if (!cache) {
2861
+ cache = {};
2862
+ lazyRoutePropertyCache.set(routeToUpdate, cache);
2863
+ }
2864
+ let cachedPromise = cache[key];
2865
+ if (cachedPromise) {
2866
+ return cachedPromise;
2867
+ }
2868
+ let propertyPromise = (async () => {
2869
+ let isUnsupported = isUnsupportedLazyRouteObjectKey(key);
2870
+ let staticRouteValue = routeToUpdate[key];
2871
+ let isStaticallyDefined = staticRouteValue !== void 0 && key !== "hasErrorBoundary";
2872
+ if (isUnsupported) {
2845
2873
  warning(
2846
- !isPropertyStaticallyDefined,
2847
- `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.`
2874
+ !isUnsupported,
2875
+ "Route property " + key + " is not a supported lazy route property. This property will be ignored."
2848
2876
  );
2877
+ cache[key] = Promise.resolve();
2878
+ } else if (isStaticallyDefined) {
2849
2879
  warning(
2850
- !unsupportedLazyRouteFunctionKeys.has(
2851
- lazyRouteProperty
2852
- ),
2853
- "Route property " + lazyRouteProperty + " is not a supported property to be returned from a lazy route function. This property will be ignored."
2880
+ false,
2881
+ `Route "${routeToUpdate.id}" has a static property "${key}" defined. The lazy property will be ignored.`
2854
2882
  );
2855
- if (!isPropertyStaticallyDefined && !unsupportedLazyRouteFunctionKeys.has(
2856
- lazyRouteProperty
2857
- )) {
2858
- routeUpdates[lazyRouteProperty] = lazyRoute[lazyRouteProperty];
2883
+ } else {
2884
+ let value = await lazyFn();
2885
+ if (value != null) {
2886
+ Object.assign(routeToUpdate, { [key]: value });
2887
+ Object.assign(routeToUpdate, mapRouteProperties2(routeToUpdate));
2859
2888
  }
2860
2889
  }
2861
- Object.assign(routeToUpdate, routeUpdates);
2862
- Object.assign(routeToUpdate, {
2863
- // To keep things framework agnostic, we use the provided `mapRouteProperties`
2864
- // function to set the framework-aware properties (`element`/`hasErrorBoundary`)
2865
- // since the logic will differ between frameworks.
2866
- ...mapRouteProperties2(routeToUpdate),
2867
- lazy: void 0
2868
- });
2869
- });
2870
- lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
2871
- await lazyRoutePromise;
2872
- }
2873
- async function loadLazyMiddleware(route, manifest) {
2874
- if (!route.unstable_lazyMiddleware) {
2875
- return;
2876
- }
2890
+ if (typeof routeToUpdate.lazy === "object") {
2891
+ routeToUpdate.lazy[key] = void 0;
2892
+ if (Object.values(routeToUpdate.lazy).every((value) => value === void 0)) {
2893
+ routeToUpdate.lazy = void 0;
2894
+ }
2895
+ }
2896
+ })();
2897
+ cache[key] = propertyPromise;
2898
+ return propertyPromise;
2899
+ };
2900
+ var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
2901
+ function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
2877
2902
  let routeToUpdate = manifest[route.id];
2878
2903
  invariant(routeToUpdate, "No route found in manifest");
2879
- if (routeToUpdate.unstable_middleware) {
2880
- warning(
2881
- false,
2882
- `Route "${routeToUpdate.id}" has a static property "unstable_middleware" defined. The "unstable_lazyMiddleware" function will be ignored.`
2883
- );
2884
- } else {
2885
- let middleware = await route.unstable_lazyMiddleware();
2886
- if (!route.unstable_lazyMiddleware) {
2887
- return;
2904
+ if (!route.lazy) {
2905
+ return {
2906
+ lazyRoutePromise: void 0,
2907
+ lazyHandlerPromise: void 0
2908
+ };
2909
+ }
2910
+ if (typeof route.lazy === "function") {
2911
+ let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
2912
+ if (cachedPromise) {
2913
+ return {
2914
+ lazyRoutePromise: cachedPromise,
2915
+ lazyHandlerPromise: cachedPromise
2916
+ };
2888
2917
  }
2889
- if (!routeToUpdate.unstable_middleware) {
2890
- routeToUpdate.unstable_middleware = middleware;
2918
+ let lazyRoutePromise2 = (async () => {
2919
+ invariant(
2920
+ typeof route.lazy === "function",
2921
+ "No lazy route function found"
2922
+ );
2923
+ let lazyRoute = await route.lazy();
2924
+ let routeUpdates = {};
2925
+ for (let lazyRouteProperty in lazyRoute) {
2926
+ let lazyValue = lazyRoute[lazyRouteProperty];
2927
+ if (lazyValue === void 0) {
2928
+ continue;
2929
+ }
2930
+ let isUnsupported = isUnsupportedLazyRouteFunctionKey(lazyRouteProperty);
2931
+ let staticRouteValue = routeToUpdate[lazyRouteProperty];
2932
+ let isStaticallyDefined = staticRouteValue !== void 0 && // This property isn't static since it should always be updated based
2933
+ // on the route updates
2934
+ lazyRouteProperty !== "hasErrorBoundary";
2935
+ if (isUnsupported) {
2936
+ warning(
2937
+ !isUnsupported,
2938
+ "Route property " + lazyRouteProperty + " is not a supported property to be returned from a lazy route function. This property will be ignored."
2939
+ );
2940
+ } else if (isStaticallyDefined) {
2941
+ warning(
2942
+ !isStaticallyDefined,
2943
+ `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.`
2944
+ );
2945
+ } else {
2946
+ routeUpdates[lazyRouteProperty] = lazyValue;
2947
+ }
2948
+ }
2949
+ Object.assign(routeToUpdate, routeUpdates);
2950
+ Object.assign(routeToUpdate, {
2951
+ // To keep things framework agnostic, we use the provided `mapRouteProperties`
2952
+ // function to set the framework-aware properties (`element`/`hasErrorBoundary`)
2953
+ // since the logic will differ between frameworks.
2954
+ ...mapRouteProperties2(routeToUpdate),
2955
+ lazy: void 0
2956
+ });
2957
+ })();
2958
+ lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise2);
2959
+ return {
2960
+ lazyRoutePromise: lazyRoutePromise2,
2961
+ lazyHandlerPromise: lazyRoutePromise2
2962
+ };
2963
+ }
2964
+ let lazyKeys = Object.keys(route.lazy);
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
+ }
2891
2979
  }
2892
2980
  }
2893
- routeToUpdate.unstable_lazyMiddleware = void 0;
2981
+ let lazyRoutePromise = Promise.all(lazyPropertyPromises).then(() => {
2982
+ });
2983
+ return {
2984
+ lazyRoutePromise,
2985
+ lazyHandlerPromise
2986
+ };
2894
2987
  }
2895
- function loadLazyMiddlewareForMatches(matches, manifest) {
2896
- let promises = matches.map(
2897
- (m) => m.route.unstable_lazyMiddleware ? loadLazyMiddleware(m.route, manifest) : void 0
2898
- ).filter(Boolean);
2988
+ function isNonNullable(value) {
2989
+ return value !== void 0;
2990
+ }
2991
+ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
2992
+ let promises = matches.map(({ route }) => {
2993
+ if (typeof route.lazy !== "object" || !route.lazy.unstable_middleware) {
2994
+ return void 0;
2995
+ }
2996
+ return loadLazyRouteProperty({
2997
+ key: "unstable_middleware",
2998
+ route,
2999
+ manifest,
3000
+ mapRouteProperties: mapRouteProperties2
3001
+ });
3002
+ }).filter(isNonNullable);
2899
3003
  return promises.length > 0 ? Promise.all(promises) : void 0;
2900
3004
  }
2901
3005
  async function defaultDataStrategy(args) {
@@ -3013,28 +3117,33 @@ async function callRouteMiddleware(args, middlewares, propagateResult, middlewar
3013
3117
  }
3014
3118
  }
3015
3119
  async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties2, scopedContext) {
3016
- let loadMiddlewarePromise = loadLazyMiddlewareForMatches(matches, manifest);
3017
- let loadRouteDefinitionsPromises = matches.map(
3018
- (m) => m.route.lazy ? loadLazyRouteModule(m.route, mapRouteProperties2, manifest) : void 0
3120
+ let loadMiddlewarePromise = loadLazyMiddlewareForMatches(
3121
+ matches,
3122
+ manifest,
3123
+ mapRouteProperties2
3124
+ );
3125
+ let lazyRoutePromises = matches.map(
3126
+ (m) => loadLazyRoute(m.route, type, manifest, mapRouteProperties2)
3019
3127
  );
3020
3128
  if (loadMiddlewarePromise) {
3021
3129
  await loadMiddlewarePromise;
3022
3130
  }
3023
3131
  let dsMatches = matches.map((match, i) => {
3024
- let loadRoutePromise = loadRouteDefinitionsPromises[i];
3132
+ let { lazyRoutePromise, lazyHandlerPromise } = lazyRoutePromises[i];
3025
3133
  let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
3026
3134
  let resolve = async (handlerOverride) => {
3027
3135
  if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
3028
3136
  shouldLoad = true;
3029
3137
  }
3030
- return shouldLoad ? callLoaderOrAction(
3138
+ return shouldLoad ? callLoaderOrAction({
3031
3139
  type,
3032
3140
  request,
3033
3141
  match,
3034
- loadRoutePromise,
3142
+ lazyHandlerPromise,
3143
+ lazyRoutePromise,
3035
3144
  handlerOverride,
3036
3145
  scopedContext
3037
- ) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3146
+ }) : Promise.resolve({ type: "data" /* data */, result: void 0 });
3038
3147
  };
3039
3148
  return {
3040
3149
  ...match,
@@ -3049,13 +3158,24 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
3049
3158
  fetcherKey,
3050
3159
  context: scopedContext
3051
3160
  });
3161
+ let allLazyRoutePromises = lazyRoutePromises.flatMap(
3162
+ (promiseMap) => Object.values(promiseMap).filter(isNonNullable)
3163
+ );
3052
3164
  try {
3053
- await Promise.all(loadRouteDefinitionsPromises);
3165
+ await Promise.all(allLazyRoutePromises);
3054
3166
  } catch (e) {
3055
3167
  }
3056
3168
  return results;
3057
3169
  }
3058
- 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
+ }) {
3059
3179
  let result;
3060
3180
  let onReject;
3061
3181
  let runHandler = (handler) => {
@@ -3092,7 +3212,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3092
3212
  };
3093
3213
  try {
3094
3214
  let handler = match.route[type];
3095
- if (loadRoutePromise) {
3215
+ if (lazyHandlerPromise || lazyRoutePromise) {
3096
3216
  if (handler) {
3097
3217
  let handlerError;
3098
3218
  let [value] = await Promise.all([
@@ -3102,17 +3222,19 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
3102
3222
  runHandler(handler).catch((e) => {
3103
3223
  handlerError = e;
3104
3224
  }),
3105
- loadRoutePromise
3225
+ // Ensure all lazy route promises are resolved before continuing
3226
+ lazyHandlerPromise,
3227
+ lazyRoutePromise
3106
3228
  ]);
3107
3229
  if (handlerError !== void 0) {
3108
3230
  throw handlerError;
3109
3231
  }
3110
3232
  result = value;
3111
3233
  } else {
3112
- await loadRoutePromise;
3234
+ await lazyHandlerPromise;
3113
3235
  handler = match.route[type];
3114
3236
  if (handler) {
3115
- result = await runHandler(handler);
3237
+ [result] = await Promise.all([runHandler(handler), lazyRoutePromise]);
3116
3238
  } else if (type === "action") {
3117
3239
  let url = new URL(request.url);
3118
3240
  let pathname = url.pathname + url.search;
@@ -5210,22 +5332,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
5210
5332
  dataRoute.loader = (_, singleFetch) => prefetchStylesAndCallHandler(() => {
5211
5333
  return fetchServerLoader(singleFetch);
5212
5334
  });
5213
- } else if (route.clientLoaderModule) {
5214
- dataRoute.loader = async (args, singleFetch) => {
5215
- invariant2(route.clientLoaderModule);
5216
- let { clientLoader } = await import(
5217
- /* @vite-ignore */
5218
- /* webpackIgnore: true */
5219
- route.clientLoaderModule
5220
- );
5221
- return clientLoader({
5222
- ...args,
5223
- async serverLoader() {
5224
- preventInvalidServerHandlerCall("loader", route);
5225
- return fetchServerLoader(singleFetch);
5226
- }
5227
- });
5228
- };
5229
5335
  }
5230
5336
  if (!route.hasClientAction) {
5231
5337
  dataRoute.action = (_, singleFetch) => prefetchStylesAndCallHandler(() => {
@@ -5234,86 +5340,84 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
5234
5340
  }
5235
5341
  return fetchServerAction(singleFetch);
5236
5342
  });
5237
- } else if (route.clientActionModule) {
5238
- dataRoute.action = async (args, singleFetch) => {
5239
- invariant2(route.clientActionModule);
5240
- prefetchRouteModuleChunks(route);
5241
- let { clientAction } = await import(
5242
- /* @vite-ignore */
5243
- /* webpackIgnore: true */
5244
- route.clientActionModule
5343
+ }
5344
+ let lazyRoutePromise;
5345
+ async function getLazyRoute() {
5346
+ if (lazyRoutePromise) {
5347
+ return await lazyRoutePromise;
5348
+ }
5349
+ lazyRoutePromise = (async () => {
5350
+ if (route.clientLoaderModule || route.clientActionModule) {
5351
+ await new Promise((resolve) => setTimeout(resolve, 0));
5352
+ }
5353
+ let routeModulePromise = loadRouteModuleWithBlockingLinks(
5354
+ route,
5355
+ routeModulesCache
5245
5356
  );
5246
- return clientAction({
5247
- ...args,
5248
- async serverAction() {
5249
- preventInvalidServerHandlerCall("action", route);
5250
- return fetchServerAction(singleFetch);
5251
- }
5252
- });
5253
- };
5357
+ prefetchRouteModuleChunks(route);
5358
+ return await routeModulePromise;
5359
+ })();
5360
+ return await lazyRoutePromise;
5254
5361
  }
5255
- if (route.hasClientMiddleware) {
5256
- dataRoute.unstable_lazyMiddleware = async () => {
5257
- invariant2(route);
5258
- let clientMiddlewareModule = await import(
5362
+ dataRoute.lazy = {
5363
+ loader: route.hasClientLoader ? async () => {
5364
+ let { clientLoader } = route.clientLoaderModule ? await import(
5259
5365
  /* @vite-ignore */
5260
5366
  /* webpackIgnore: true */
5261
- route.clientMiddlewareModule || route.module
5262
- );
5263
- invariant2(
5264
- clientMiddlewareModule?.unstable_clientMiddleware,
5265
- "No `unstable_clientMiddleware` export in chunk"
5266
- );
5267
- return clientMiddlewareModule.unstable_clientMiddleware;
5268
- };
5269
- }
5270
- dataRoute.lazy = async () => {
5271
- if (route.clientLoaderModule || route.clientActionModule) {
5272
- await new Promise((resolve) => setTimeout(resolve, 0));
5273
- }
5274
- let modPromise = loadRouteModuleWithBlockingLinks(
5275
- route,
5276
- routeModulesCache
5277
- );
5278
- prefetchRouteModuleChunks(route);
5279
- let mod = await modPromise;
5280
- let lazyRoute = { ...mod };
5281
- if (mod.clientLoader) {
5282
- let clientLoader = mod.clientLoader;
5283
- lazyRoute.loader = (args, singleFetch) => clientLoader({
5367
+ route.clientLoaderModule
5368
+ ) : await getLazyRoute();
5369
+ invariant2(clientLoader, "No `clientLoader` export found");
5370
+ return (args, singleFetch) => clientLoader({
5284
5371
  ...args,
5285
5372
  async serverLoader() {
5286
5373
  preventInvalidServerHandlerCall("loader", route);
5287
5374
  return fetchServerLoader(singleFetch);
5288
5375
  }
5289
5376
  });
5290
- }
5291
- if (mod.clientAction) {
5292
- let clientAction = mod.clientAction;
5293
- lazyRoute.action = (args, singleFetch) => clientAction({
5377
+ } : void 0,
5378
+ action: route.hasClientAction ? async () => {
5379
+ let clientActionPromise = route.clientActionModule ? import(
5380
+ /* @vite-ignore */
5381
+ /* webpackIgnore: true */
5382
+ route.clientActionModule
5383
+ ) : getLazyRoute();
5384
+ prefetchRouteModuleChunks(route);
5385
+ let { clientAction } = await clientActionPromise;
5386
+ invariant2(clientAction, "No `clientAction` export found");
5387
+ return (args, singleFetch) => clientAction({
5294
5388
  ...args,
5295
5389
  async serverAction() {
5296
5390
  preventInvalidServerHandlerCall("action", route);
5297
5391
  return fetchServerAction(singleFetch);
5298
5392
  }
5299
5393
  });
5300
- }
5301
- return {
5302
- ...lazyRoute.loader ? { loader: lazyRoute.loader } : {},
5303
- ...lazyRoute.action ? { action: lazyRoute.action } : {},
5304
- hasErrorBoundary: lazyRoute.hasErrorBoundary,
5305
- shouldRevalidate: getShouldRevalidateFunction(
5394
+ } : void 0,
5395
+ unstable_middleware: route.hasClientMiddleware ? async () => {
5396
+ let { unstable_clientMiddleware } = route.clientMiddlewareModule ? await import(
5397
+ /* @vite-ignore */
5398
+ /* webpackIgnore: true */
5399
+ route.clientMiddlewareModule
5400
+ ) : await getLazyRoute();
5401
+ invariant2(
5402
+ unstable_clientMiddleware,
5403
+ "No `unstable_clientMiddleware` export found"
5404
+ );
5405
+ return unstable_clientMiddleware;
5406
+ } : void 0,
5407
+ shouldRevalidate: async () => {
5408
+ let lazyRoute = await getLazyRoute();
5409
+ return getShouldRevalidateFunction(
5306
5410
  lazyRoute,
5307
5411
  route,
5308
5412
  ssr,
5309
5413
  needsRevalidation
5310
- ),
5311
- handle: lazyRoute.handle,
5312
- // No need to wrap these in layout since the root route is never
5313
- // loaded via route.lazy()
5314
- Component: lazyRoute.Component,
5315
- ErrorBoundary: lazyRoute.ErrorBoundary
5316
- };
5414
+ );
5415
+ },
5416
+ handle: async () => (await getLazyRoute()).handle,
5417
+ // No need to wrap these in layout since the root route is never
5418
+ // loaded via route.lazy()
5419
+ Component: async () => (await getLazyRoute()).Component,
5420
+ ErrorBoundary: route.hasErrorBoundary ? async () => (await getLazyRoute()).ErrorBoundary : void 0
5317
5421
  };
5318
5422
  }
5319
5423
  let children = createClientRoutes(
@@ -5401,7 +5505,7 @@ var URL_LIMIT = 7680;
5401
5505
  function isFogOfWarEnabled(ssr) {
5402
5506
  return ssr === true;
5403
5507
  }
5404
- function getPartialManifest(manifest, router2) {
5508
+ function getPartialManifest({ sri, ...manifest }, router2) {
5405
5509
  let routeIds = new Set(router2.state.matches.map((m) => m.route.id));
5406
5510
  let segments = router2.state.location.pathname.split("/").filter(Boolean);
5407
5511
  let paths = ["/"];
@@ -5422,7 +5526,8 @@ function getPartialManifest(manifest, router2) {
5422
5526
  );
5423
5527
  return {
5424
5528
  ...manifest,
5425
- routes: initialRoutes
5529
+ routes: initialRoutes,
5530
+ sri: sri ? true : void 0
5426
5531
  };
5427
5532
  }
5428
5533
  function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
@@ -5709,32 +5814,53 @@ import(${JSON.stringify(manifest.entry.module)});`;
5709
5814
  }
5710
5815
  ));
5711
5816
  }, []);
5712
- let preloads = isHydrated ? [] : manifest.entry.imports.concat(
5713
- getModuleLinkHrefs(matches, manifest, {
5714
- includeHydrateFallback: true
5715
- })
5817
+ let preloads = isHydrated ? [] : dedupe(
5818
+ manifest.entry.imports.concat(
5819
+ getModuleLinkHrefs(matches, manifest, {
5820
+ includeHydrateFallback: true
5821
+ })
5822
+ )
5716
5823
  );
5717
- return isHydrated ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, !enableFogOfWar ? /* @__PURE__ */ React9.createElement(
5824
+ let sri = typeof manifest.sri === "object" ? manifest.sri : {};
5825
+ return isHydrated ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, typeof manifest.sri === "object" ? /* @__PURE__ */ React9.createElement(
5826
+ "script",
5827
+ {
5828
+ "rr-importmap": "",
5829
+ type: "importmap",
5830
+ suppressHydrationWarning: true,
5831
+ dangerouslySetInnerHTML: {
5832
+ __html: JSON.stringify({
5833
+ integrity: sri
5834
+ })
5835
+ }
5836
+ }
5837
+ ) : null, !enableFogOfWar ? /* @__PURE__ */ React9.createElement(
5718
5838
  "link",
5719
5839
  {
5720
5840
  rel: "modulepreload",
5721
5841
  href: manifest.url,
5722
- crossOrigin: props.crossOrigin
5842
+ crossOrigin: props.crossOrigin,
5843
+ integrity: sri[manifest.url],
5844
+ suppressHydrationWarning: true
5723
5845
  }
5724
5846
  ) : null, /* @__PURE__ */ React9.createElement(
5725
5847
  "link",
5726
5848
  {
5727
5849
  rel: "modulepreload",
5728
5850
  href: manifest.entry.module,
5729
- crossOrigin: props.crossOrigin
5851
+ crossOrigin: props.crossOrigin,
5852
+ integrity: sri[manifest.entry.module],
5853
+ suppressHydrationWarning: true
5730
5854
  }
5731
- ), dedupe(preloads).map((path) => /* @__PURE__ */ React9.createElement(
5855
+ ), preloads.map((path) => /* @__PURE__ */ React9.createElement(
5732
5856
  "link",
5733
5857
  {
5734
5858
  key: path,
5735
5859
  rel: "modulepreload",
5736
5860
  href: path,
5737
- crossOrigin: props.crossOrigin
5861
+ crossOrigin: props.crossOrigin,
5862
+ integrity: sri[path],
5863
+ suppressHydrationWarning: true
5738
5864
  }
5739
5865
  )), initialScripts);
5740
5866
  }
@@ -5790,6 +5916,18 @@ var ssrInfo = null;
5790
5916
  var router = null;
5791
5917
  function initSsrInfo() {
5792
5918
  if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
5919
+ if (window.__reactRouterManifest.sri === true) {
5920
+ const importMap = document.querySelector("script[rr-importmap]");
5921
+ if (importMap?.textContent) {
5922
+ try {
5923
+ window.__reactRouterManifest.sri = JSON.parse(
5924
+ importMap.textContent
5925
+ ).integrity;
5926
+ } catch (err) {
5927
+ console.error("Failed to parse import map", err);
5928
+ }
5929
+ }
5930
+ }
5793
5931
  ssrInfo = {
5794
5932
  context: window.__reactRouterContext,
5795
5933
  manifest: window.__reactRouterManifest,
@@ -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
  *
@@ -25,7 +25,7 @@ import {
25
25
  matchRoutes,
26
26
  shouldHydrateRouteLoader,
27
27
  useFogOFWarDiscovery
28
- } from "./chunk-XJI4KG32.mjs";
28
+ } from "./chunk-5BSZVSUP.mjs";
29
29
 
30
30
  // lib/dom-export/dom-router-provider.tsx
31
31
  import * as React from "react";
@@ -40,6 +40,18 @@ var ssrInfo = null;
40
40
  var router = null;
41
41
  function initSsrInfo() {
42
42
  if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
43
+ if (window.__reactRouterManifest.sri === true) {
44
+ const importMap = document.querySelector("script[rr-importmap]");
45
+ if (importMap?.textContent) {
46
+ try {
47
+ window.__reactRouterManifest.sri = JSON.parse(
48
+ importMap.textContent
49
+ ).integrity;
50
+ } catch (err) {
51
+ console.error("Failed to parse import map", err);
52
+ }
53
+ }
54
+ }
43
55
  ssrInfo = {
44
56
  context: window.__reactRouterContext,
45
57
  manifest: window.__reactRouterManifest,