react-router 7.4.1 → 7.5.0-pre.0

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 +40 -0
  2. package/dist/development/{chunk-XJI4KG32.mjs → chunk-YTH545ZN.mjs} +244 -154
  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 +246 -149
  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 +244 -154
  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-RSOGH2WR.mjs} +244 -154
  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 +246 -149
  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 +244 -154
  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
@@ -463,25 +463,33 @@ interface MapRoutePropertiesFunction {
463
463
  hasErrorBoundary: boolean;
464
464
  } & Record<string, any>;
465
465
  }
466
+ /**
467
+ * Keys we cannot change from within a lazy object. We spread all other keys
468
+ * onto the route. Either they're meaningful to the router, or they'll get
469
+ * ignored.
470
+ */
471
+ type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
466
472
  /**
467
473
  * Keys we cannot change from within a lazy() function. We spread all other keys
468
474
  * onto the route. Either they're meaningful to the router, or they'll get
469
475
  * ignored.
470
476
  */
471
- type UnsupportedLazyRouteFunctionKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "unstable_middleware" | "unstable_lazyMiddleware" | "children";
472
- type RequireOne<T, Key = keyof T> = Exclude<{
473
- [K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
474
- }[keyof T], undefined>;
477
+ type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "unstable_middleware";
478
+ /**
479
+ * lazy object to load route properties, which can add non-matching
480
+ * related properties to a route
481
+ */
482
+ type LazyRouteObject<R extends AgnosticRouteObject> = {
483
+ [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined>;
484
+ };
475
485
  /**
476
486
  * lazy() function to load a route definition, which can add non-matching
477
487
  * related properties to a route
478
488
  */
479
489
  interface LazyRouteFunction<R extends AgnosticRouteObject> {
480
- (): Promise<RequireOne<Omit<R, UnsupportedLazyRouteFunctionKey>>>;
481
- }
482
- interface LazyMiddlewareFunction {
483
- (): Promise<unstable_MiddlewareFunction[]>;
490
+ (): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
484
491
  }
492
+ type LazyRouteDefinition<R extends AgnosticRouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
485
493
  /**
486
494
  * Base RouteObject with common props shared by all types of routes
487
495
  */
@@ -490,13 +498,12 @@ type AgnosticBaseRouteObject = {
490
498
  path?: string;
491
499
  id?: string;
492
500
  unstable_middleware?: unstable_MiddlewareFunction[];
493
- unstable_lazyMiddleware?: LazyMiddlewareFunction;
494
501
  loader?: LoaderFunction | boolean;
495
502
  action?: ActionFunction | boolean;
496
503
  hasErrorBoundary?: boolean;
497
504
  shouldRevalidate?: ShouldRevalidateFunction;
498
505
  handle?: any;
499
- lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
506
+ lazy?: LazyRouteDefinition<AgnosticBaseRouteObject>;
500
507
  };
501
508
  /**
502
509
  * Index routes must not have children
@@ -1255,7 +1262,6 @@ interface IndexRouteObject {
1255
1262
  path?: AgnosticIndexRouteObject["path"];
1256
1263
  id?: AgnosticIndexRouteObject["id"];
1257
1264
  unstable_middleware?: AgnosticIndexRouteObject["unstable_middleware"];
1258
- unstable_lazyMiddleware?: AgnosticIndexRouteObject["unstable_lazyMiddleware"];
1259
1265
  loader?: AgnosticIndexRouteObject["loader"];
1260
1266
  action?: AgnosticIndexRouteObject["action"];
1261
1267
  hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
@@ -1269,14 +1275,13 @@ interface IndexRouteObject {
1269
1275
  Component?: React.ComponentType | null;
1270
1276
  HydrateFallback?: React.ComponentType | null;
1271
1277
  ErrorBoundary?: React.ComponentType | null;
1272
- lazy?: LazyRouteFunction<RouteObject>;
1278
+ lazy?: LazyRouteDefinition<RouteObject>;
1273
1279
  }
1274
1280
  interface NonIndexRouteObject {
1275
1281
  caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
1276
1282
  path?: AgnosticNonIndexRouteObject["path"];
1277
1283
  id?: AgnosticNonIndexRouteObject["id"];
1278
1284
  unstable_middleware?: AgnosticNonIndexRouteObject["unstable_middleware"];
1279
- unstable_lazyMiddleware?: AgnosticNonIndexRouteObject["unstable_lazyMiddleware"];
1280
1285
  loader?: AgnosticNonIndexRouteObject["loader"];
1281
1286
  action?: AgnosticNonIndexRouteObject["action"];
1282
1287
  hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
@@ -1290,7 +1295,7 @@ interface NonIndexRouteObject {
1290
1295
  Component?: React.ComponentType | null;
1291
1296
  HydrateFallback?: React.ComponentType | null;
1292
1297
  ErrorBoundary?: React.ComponentType | null;
1293
- lazy?: LazyRouteFunction<RouteObject>;
1298
+ lazy?: LazyRouteDefinition<RouteObject>;
1294
1299
  }
1295
1300
  type RouteObject = IndexRouteObject | NonIndexRouteObject;
1296
1301
  type DataRouteObject = RouteObject & {
@@ -463,25 +463,33 @@ interface MapRoutePropertiesFunction {
463
463
  hasErrorBoundary: boolean;
464
464
  } & Record<string, any>;
465
465
  }
466
+ /**
467
+ * Keys we cannot change from within a lazy object. We spread all other keys
468
+ * onto the route. Either they're meaningful to the router, or they'll get
469
+ * ignored.
470
+ */
471
+ type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
466
472
  /**
467
473
  * Keys we cannot change from within a lazy() function. We spread all other keys
468
474
  * onto the route. Either they're meaningful to the router, or they'll get
469
475
  * ignored.
470
476
  */
471
- type UnsupportedLazyRouteFunctionKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "unstable_middleware" | "unstable_lazyMiddleware" | "children";
472
- type RequireOne<T, Key = keyof T> = Exclude<{
473
- [K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
474
- }[keyof T], undefined>;
477
+ type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "unstable_middleware";
478
+ /**
479
+ * lazy object to load route properties, which can add non-matching
480
+ * related properties to a route
481
+ */
482
+ type LazyRouteObject<R extends AgnosticRouteObject> = {
483
+ [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined>;
484
+ };
475
485
  /**
476
486
  * lazy() function to load a route definition, which can add non-matching
477
487
  * related properties to a route
478
488
  */
479
489
  interface LazyRouteFunction<R extends AgnosticRouteObject> {
480
- (): Promise<RequireOne<Omit<R, UnsupportedLazyRouteFunctionKey>>>;
481
- }
482
- interface LazyMiddlewareFunction {
483
- (): Promise<unstable_MiddlewareFunction[]>;
490
+ (): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
484
491
  }
492
+ type LazyRouteDefinition<R extends AgnosticRouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
485
493
  /**
486
494
  * Base RouteObject with common props shared by all types of routes
487
495
  */
@@ -490,13 +498,12 @@ type AgnosticBaseRouteObject = {
490
498
  path?: string;
491
499
  id?: string;
492
500
  unstable_middleware?: unstable_MiddlewareFunction[];
493
- unstable_lazyMiddleware?: LazyMiddlewareFunction;
494
501
  loader?: LoaderFunction | boolean;
495
502
  action?: ActionFunction | boolean;
496
503
  hasErrorBoundary?: boolean;
497
504
  shouldRevalidate?: ShouldRevalidateFunction;
498
505
  handle?: any;
499
- lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
506
+ lazy?: LazyRouteDefinition<AgnosticBaseRouteObject>;
500
507
  };
501
508
  /**
502
509
  * Index routes must not have children
@@ -1255,7 +1262,6 @@ interface IndexRouteObject {
1255
1262
  path?: AgnosticIndexRouteObject["path"];
1256
1263
  id?: AgnosticIndexRouteObject["id"];
1257
1264
  unstable_middleware?: AgnosticIndexRouteObject["unstable_middleware"];
1258
- unstable_lazyMiddleware?: AgnosticIndexRouteObject["unstable_lazyMiddleware"];
1259
1265
  loader?: AgnosticIndexRouteObject["loader"];
1260
1266
  action?: AgnosticIndexRouteObject["action"];
1261
1267
  hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
@@ -1269,14 +1275,13 @@ interface IndexRouteObject {
1269
1275
  Component?: React.ComponentType | null;
1270
1276
  HydrateFallback?: React.ComponentType | null;
1271
1277
  ErrorBoundary?: React.ComponentType | null;
1272
- lazy?: LazyRouteFunction<RouteObject>;
1278
+ lazy?: LazyRouteDefinition<RouteObject>;
1273
1279
  }
1274
1280
  interface NonIndexRouteObject {
1275
1281
  caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
1276
1282
  path?: AgnosticNonIndexRouteObject["path"];
1277
1283
  id?: AgnosticNonIndexRouteObject["id"];
1278
1284
  unstable_middleware?: AgnosticNonIndexRouteObject["unstable_middleware"];
1279
- unstable_lazyMiddleware?: AgnosticNonIndexRouteObject["unstable_lazyMiddleware"];
1280
1285
  loader?: AgnosticNonIndexRouteObject["loader"];
1281
1286
  action?: AgnosticNonIndexRouteObject["action"];
1282
1287
  hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
@@ -1290,7 +1295,7 @@ interface NonIndexRouteObject {
1290
1295
  Component?: React.ComponentType | null;
1291
1296
  HydrateFallback?: React.ComponentType | null;
1292
1297
  ErrorBoundary?: React.ComponentType | null;
1293
- lazy?: LazyRouteFunction<RouteObject>;
1298
+ lazy?: LazyRouteDefinition<RouteObject>;
1294
1299
  }
1295
1300
  type RouteObject = IndexRouteObject | NonIndexRouteObject;
1296
1301
  type DataRouteObject = RouteObject & {