react-router 7.7.0 → 7.7.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 (68) hide show
  1. package/CHANGELOG.md +11 -23
  2. package/dist/development/{browser-CcxeZJcQ.d.mts → browser-7LYX59NK.d.mts} +97 -1
  3. package/dist/development/{chunk-EF7DTUVF.mjs → chunk-C37GKA54.mjs} +83 -80
  4. package/dist/development/{chunk-V6PEDDZI.js → chunk-K7YFBME3.js} +79 -76
  5. package/dist/{production/chunk-GNZILI6H.mjs → development/chunk-KIUJAIYX.mjs} +3 -5
  6. package/dist/{production/chunk-2TYFPE3B.js → development/chunk-R73PQUJU.js} +132 -132
  7. package/dist/development/components-CjQijYga.d.mts +802 -0
  8. package/dist/development/dom-export.d.mts +13 -6
  9. package/dist/development/dom-export.d.ts +10 -3
  10. package/dist/development/dom-export.js +3 -3
  11. package/dist/development/dom-export.mjs +3 -3
  12. package/dist/development/index-react-server-client-Bi_fx8qz.d.ts +3163 -0
  13. package/dist/development/index-react-server-client-KLg-U4nr.d.mts +2366 -0
  14. package/dist/development/index-react-server-client.d.mts +3 -3
  15. package/dist/development/index-react-server-client.d.ts +2 -2
  16. package/dist/development/index-react-server-client.js +4 -4
  17. package/dist/development/index-react-server-client.mjs +2 -2
  18. package/dist/development/index-react-server.d.mts +109 -2
  19. package/dist/development/index-react-server.d.ts +109 -2
  20. package/dist/development/index-react-server.js +28 -20
  21. package/dist/development/index-react-server.mjs +29 -21
  22. package/dist/development/index.d.mts +918 -287
  23. package/dist/development/index.d.ts +1010 -283
  24. package/dist/development/index.js +98 -100
  25. package/dist/development/index.mjs +3 -3
  26. package/dist/development/lib/types/internal.d.mts +1 -1
  27. package/dist/development/lib/types/internal.d.ts +1 -1
  28. package/dist/development/lib/types/internal.js +1 -1
  29. package/dist/development/lib/types/internal.mjs +1 -1
  30. package/dist/{production/route-data-DjzmHYNR.d.mts → development/route-data-CqEmXQub.d.mts} +48 -2
  31. package/dist/{production/routeModules-g5PTiDfO.d.ts → development/routeModules-BR2FO0ix.d.ts} +48 -2
  32. package/dist/production/{browser-CcxeZJcQ.d.mts → browser-7LYX59NK.d.mts} +97 -1
  33. package/dist/{development/chunk-4ADB4KIO.js → production/chunk-4DGLNKXF.js} +132 -132
  34. package/dist/production/{chunk-5KHO4FML.js → chunk-7OQROU2D.js} +79 -76
  35. package/dist/production/{chunk-WPPIQDYG.mjs → chunk-IZ57JD2V.mjs} +83 -80
  36. package/dist/{development/chunk-T3VM44WY.mjs → production/chunk-K3SBCRK4.mjs} +3 -5
  37. package/dist/production/components-CjQijYga.d.mts +802 -0
  38. package/dist/production/dom-export.d.mts +13 -6
  39. package/dist/production/dom-export.d.ts +10 -3
  40. package/dist/production/dom-export.js +3 -3
  41. package/dist/production/dom-export.mjs +3 -3
  42. package/dist/production/index-react-server-client-Bi_fx8qz.d.ts +3163 -0
  43. package/dist/production/index-react-server-client-KLg-U4nr.d.mts +2366 -0
  44. package/dist/production/index-react-server-client.d.mts +3 -3
  45. package/dist/production/index-react-server-client.d.ts +2 -2
  46. package/dist/production/index-react-server-client.js +4 -4
  47. package/dist/production/index-react-server-client.mjs +2 -2
  48. package/dist/production/index-react-server.d.mts +109 -2
  49. package/dist/production/index-react-server.d.ts +109 -2
  50. package/dist/production/index-react-server.js +28 -20
  51. package/dist/production/index-react-server.mjs +29 -21
  52. package/dist/production/index.d.mts +918 -287
  53. package/dist/production/index.d.ts +1010 -283
  54. package/dist/production/index.js +98 -100
  55. package/dist/production/index.mjs +3 -3
  56. package/dist/production/lib/types/internal.d.mts +1 -1
  57. package/dist/production/lib/types/internal.d.ts +1 -1
  58. package/dist/production/lib/types/internal.js +1 -1
  59. package/dist/production/lib/types/internal.mjs +1 -1
  60. package/dist/{development/route-data-DjzmHYNR.d.mts → production/route-data-CqEmXQub.d.mts} +48 -2
  61. package/dist/{development/routeModules-g5PTiDfO.d.ts → production/routeModules-BR2FO0ix.d.ts} +48 -2
  62. package/package.json +1 -1
  63. package/dist/development/components-DzqPLVI1.d.mts +0 -464
  64. package/dist/development/index-react-server-client-CUidsuu_.d.mts +0 -1360
  65. package/dist/development/index-react-server-client-kY8DvDF3.d.ts +0 -1819
  66. package/dist/production/components-DzqPLVI1.d.mts +0 -464
  67. package/dist/production/index-react-server-client-CUidsuu_.d.mts +0 -1360
  68. package/dist/production/index-react-server-client-kY8DvDF3.d.ts +0 -1819
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.7.0
2
+ * react-router v7.7.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -31,7 +31,7 @@ import {
31
31
  isSession,
32
32
  routeRSCServerRequest,
33
33
  setDevServerHooks
34
- } from "./chunk-T3VM44WY.mjs";
34
+ } from "./chunk-KIUJAIYX.mjs";
35
35
  import {
36
36
  Action,
37
37
  Await,
@@ -140,7 +140,7 @@ import {
140
140
  withComponentProps,
141
141
  withErrorBoundaryProps,
142
142
  withHydrateFallbackProps
143
- } from "./chunk-EF7DTUVF.mjs";
143
+ } from "./chunk-C37GKA54.mjs";
144
144
  export {
145
145
  Await,
146
146
  BrowserRouter,
@@ -1,4 +1,4 @@
1
- import { n as RouteModule, o as LinkDescriptor, c as Location, p as Pretty, q as MetaDescriptor, G as GetLoaderData, r as ServerDataFunctionArgs, s as unstable_MiddlewareNextFunction, t as ClientDataFunctionArgs, v as ServerDataFrom, w as Normalize, x as GetActionData } from '../../route-data-DjzmHYNR.mjs';
1
+ import { n as RouteModule, o as LinkDescriptor, c as Location, p as Pretty, q as MetaDescriptor, G as GetLoaderData, r as ServerDataFunctionArgs, s as unstable_MiddlewareNextFunction, t as ClientDataFunctionArgs, v as ServerDataFrom, w as Normalize, x as GetActionData } from '../../route-data-CqEmXQub.mjs';
2
2
  import { R as RouteFiles, P as Pages } from '../../register-DiOIlEq5.mjs';
3
3
  import 'react';
4
4
 
@@ -1,4 +1,4 @@
1
- import { R as RouteModule, L as LinkDescriptor, a as Location, P as Pretty, M as MetaDescriptor, G as GetLoaderData, S as ServerDataFunctionArgs, u as unstable_MiddlewareNextFunction, C as ClientDataFunctionArgs, b as ServerDataFrom, N as Normalize, c as GetActionData } from '../../routeModules-g5PTiDfO.js';
1
+ import { R as RouteModule, L as LinkDescriptor, a as Location, P as Pretty, M as MetaDescriptor, G as GetLoaderData, S as ServerDataFunctionArgs, u as unstable_MiddlewareNextFunction, C as ClientDataFunctionArgs, b as ServerDataFrom, N as Normalize, c as GetActionData } from '../../routeModules-BR2FO0ix.js';
2
2
  import { R as RouteFiles, P as Pages } from '../../register-DiOIlEq5.js';
3
3
  import 'react';
4
4
 
@@ -1,5 +1,5 @@
1
1
  "use strict";/**
2
- * react-router v7.7.0
2
+ * react-router v7.7.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.7.0
2
+ * react-router v7.7.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -448,14 +448,56 @@ interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRoute
448
448
  handler: Promise<void> | undefined;
449
449
  route: Promise<void> | undefined;
450
450
  };
451
+ /**
452
+ * A boolean value indicating whether this route handler should be called in this pass.
453
+ *
454
+ * The `matches` array always includes _all_ matched routes even when only _some_
455
+ * route handlers need to be called so that things like middleware can be implemented.
456
+ *
457
+ * `shouldLoad` is usually only interesting if you are skipping the route handler
458
+ * entirely and implementing custom handler logic - since it lets you determine
459
+ * if that custom logic should run for this route or not.
460
+ *
461
+ * For example:
462
+ * - If you are on `/parent/child/a` and you navigate to `/parent/child/b` -
463
+ * you'll get an array of three matches (`[parent, child, b]`), but only `b`
464
+ * will have `shouldLoad=true` because the data for `parent` and `child` is
465
+ * already loaded
466
+ * - If you are on `/parent/child/a` and you submit to `a`'s `action`, then only
467
+ * `a` will have `shouldLoad=true` for the action execution of `dataStrategy`
468
+ * - After the `action`, `dataStrategy` will be called again for the `loader`
469
+ * revalidation, and all matches will have `shouldLoad=true` (assuming no custom
470
+ * `shouldRevalidate` implementations)
471
+ */
451
472
  shouldLoad: boolean;
452
473
  unstable_shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
453
474
  unstable_shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
475
+ /**
476
+ * An async function that will resolve any `route.lazy` implementations and
477
+ * execute the route's handler (if necessary), returning a `DataStrategyResult`
478
+ *
479
+ * - Calling `match.resolve` does not mean you're calling the `loader`/`action`
480
+ * (the "handler") - `resolve` will only call the `handler` internally if
481
+ * needed _and_ if you don't pass your own `handlerOverride` function parameter
482
+ * - It is safe to call `match.resolve` for all matches, even if they have
483
+ * `shouldLoad=false`, and it will no-op if no loading is required
484
+ * - You should generally always call `match.resolve()` for `shouldLoad:true`
485
+ * routes to ensure that any `route.lazy` implementations are processed
486
+ * - See the examples below for how to implement custom handler execution via
487
+ * `match.resolve`
488
+ */
454
489
  resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
455
490
  }
456
491
  interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
492
+ /**
493
+ * Matches for this route extended with Data strategy APIs
494
+ */
457
495
  matches: DataStrategyMatch[];
458
496
  unstable_runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
497
+ /**
498
+ * The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
499
+ * for navigational executions
500
+ */
459
501
  fetcherKey: string | null;
460
502
  }
461
503
  /**
@@ -1092,8 +1134,12 @@ interface GetScrollPositionFunction {
1092
1134
  (): number;
1093
1135
  }
1094
1136
  /**
1095
- - "route": relative to the route hierarchy so `..` means remove all segments of the current route even if it has many. For example, a `route("posts/:id")` would have both `:id` and `posts` removed from the url.
1096
- - "path": relative to the pathname so `..` means remove one segment of the pathname. For example, a `route("posts/:id")` would have only `:id` removed from the url.
1137
+ * - "route": relative to the route hierarchy so `..` means remove all segments
1138
+ * of the current route even if it has many. For example, a `route("posts/:id")`
1139
+ * would have both `:id` and `posts` removed from the url.
1140
+ * - "path": relative to the pathname so `..` means remove one segment of the
1141
+ * pathname. For example, a `route("posts/:id")` would have only `:id` removed
1142
+ * from the url.
1097
1143
  */
1098
1144
  type RelativeRoutingType = "route" | "path";
1099
1145
  type BaseNavigateOrFetchOptions = {
@@ -448,14 +448,56 @@ interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRoute
448
448
  handler: Promise<void> | undefined;
449
449
  route: Promise<void> | undefined;
450
450
  };
451
+ /**
452
+ * A boolean value indicating whether this route handler should be called in this pass.
453
+ *
454
+ * The `matches` array always includes _all_ matched routes even when only _some_
455
+ * route handlers need to be called so that things like middleware can be implemented.
456
+ *
457
+ * `shouldLoad` is usually only interesting if you are skipping the route handler
458
+ * entirely and implementing custom handler logic - since it lets you determine
459
+ * if that custom logic should run for this route or not.
460
+ *
461
+ * For example:
462
+ * - If you are on `/parent/child/a` and you navigate to `/parent/child/b` -
463
+ * you'll get an array of three matches (`[parent, child, b]`), but only `b`
464
+ * will have `shouldLoad=true` because the data for `parent` and `child` is
465
+ * already loaded
466
+ * - If you are on `/parent/child/a` and you submit to `a`'s `action`, then only
467
+ * `a` will have `shouldLoad=true` for the action execution of `dataStrategy`
468
+ * - After the `action`, `dataStrategy` will be called again for the `loader`
469
+ * revalidation, and all matches will have `shouldLoad=true` (assuming no custom
470
+ * `shouldRevalidate` implementations)
471
+ */
451
472
  shouldLoad: boolean;
452
473
  unstable_shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
453
474
  unstable_shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
475
+ /**
476
+ * An async function that will resolve any `route.lazy` implementations and
477
+ * execute the route's handler (if necessary), returning a `DataStrategyResult`
478
+ *
479
+ * - Calling `match.resolve` does not mean you're calling the `loader`/`action`
480
+ * (the "handler") - `resolve` will only call the `handler` internally if
481
+ * needed _and_ if you don't pass your own `handlerOverride` function parameter
482
+ * - It is safe to call `match.resolve` for all matches, even if they have
483
+ * `shouldLoad=false`, and it will no-op if no loading is required
484
+ * - You should generally always call `match.resolve()` for `shouldLoad:true`
485
+ * routes to ensure that any `route.lazy` implementations are processed
486
+ * - See the examples below for how to implement custom handler execution via
487
+ * `match.resolve`
488
+ */
454
489
  resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
455
490
  }
456
491
  interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
492
+ /**
493
+ * Matches for this route extended with Data strategy APIs
494
+ */
457
495
  matches: DataStrategyMatch[];
458
496
  unstable_runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
497
+ /**
498
+ * The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
499
+ * for navigational executions
500
+ */
459
501
  fetcherKey: string | null;
460
502
  }
461
503
  /**
@@ -1092,8 +1134,12 @@ interface GetScrollPositionFunction {
1092
1134
  (): number;
1093
1135
  }
1094
1136
  /**
1095
- - "route": relative to the route hierarchy so `..` means remove all segments of the current route even if it has many. For example, a `route("posts/:id")` would have both `:id` and `posts` removed from the url.
1096
- - "path": relative to the pathname so `..` means remove one segment of the pathname. For example, a `route("posts/:id")` would have only `:id` removed from the url.
1137
+ * - "route": relative to the route hierarchy so `..` means remove all segments
1138
+ * of the current route even if it has many. For example, a `route("posts/:id")`
1139
+ * would have both `:id` and `posts` removed from the url.
1140
+ * - "path": relative to the pathname so `..` means remove one segment of the
1141
+ * pathname. For example, a `route("posts/:id")` would have only `:id` removed
1142
+ * from the url.
1097
1143
  */
1098
1144
  type RelativeRoutingType = "route" | "path";
1099
1145
  type BaseNavigateOrFetchOptions = {
@@ -1,6 +1,6 @@
1
1
  import { AsyncLocalStorage } from 'node:async_hooks';
2
2
  import * as React from 'react';
3
- import { u as unstable_RouterContextProvider, i as ActionFunction, C as ClientActionFunction, j as ClientLoaderFunction, k as HeadersFunction, l as LinksFunction, m as LoaderFunction, M as MetaFunction, S as ShouldRevalidateFunction, c as Location, h as Params } from './route-data-DjzmHYNR.mjs';
3
+ import { u as unstable_RouterContextProvider, i as ActionFunction, C as ClientActionFunction, j as ClientLoaderFunction, k as HeadersFunction, l as LinksFunction, m as LoaderFunction, M as MetaFunction, S as ShouldRevalidateFunction, c as Location, h as Params } from './route-data-CqEmXQub.mjs';
4
4
 
5
5
  type ServerContext = {
6
6
  redirect?: Response;
@@ -104,6 +104,67 @@ type DecodeReplyFunction = (reply: FormData | string, { temporaryReferences }: {
104
104
  temporaryReferences: unknown;
105
105
  }) => Promise<unknown[]>;
106
106
  type LoadServerActionFunction = (id: string) => Promise<Function>;
107
+ /**
108
+ * Matches the given routes to a Request and returns a RSC Response encoding an
109
+ * `RSCPayload` for consumption by a RSC enabled client router.
110
+ *
111
+ * @example
112
+ * import {
113
+ * createTemporaryReferenceSet,
114
+ * decodeAction,
115
+ * decodeReply,
116
+ * loadServerAction,
117
+ * renderToReadableStream,
118
+ * } from "@vitejs/plugin-rsc/rsc";
119
+ * import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router";
120
+ *
121
+ * matchRSCServerRequest({
122
+ * createTemporaryReferenceSet,
123
+ * decodeAction,
124
+ * decodeFormState,
125
+ * decodeReply,
126
+ * loadServerAction,
127
+ * request,
128
+ * routes: routes(),
129
+ * generateResponse(match) {
130
+ * return new Response(
131
+ * renderToReadableStream(match.payload),
132
+ * {
133
+ * status: match.statusCode,
134
+ * headers: match.headers,
135
+ * }
136
+ * );
137
+ * },
138
+ * });
139
+ *
140
+ * @name unstable_matchRSCServerRequest
141
+ * @public
142
+ * @category RSC
143
+ * @mode data
144
+ * @param opts Options
145
+ * @param opts.basename The basename to use when matching the request.
146
+ * @param opts.decodeAction Your `react-server-dom-xyz/server`'s `decodeAction`
147
+ * function, responsible for loading a server action.
148
+ * @param opts.decodeReply Your `react-server-dom-xyz/server`'s `decodeReply`
149
+ * function, used to decode the server function's arguments and bind them to the
150
+ * implementation for invocation by the router.
151
+ * @param opts.decodeFormState A function responsible for decoding form state for
152
+ * progressively enhanceable forms with `useActionState` using your
153
+ * `react-server-dom-xyz/server`'s `decodeFormState`.
154
+ * @param opts.generateResponse A function responsible for using your
155
+ * `renderToReadableStream` to generate a Response encoding the `RSCPayload`.
156
+ * @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
157
+ * `loadServerAction` function, used to load a server action by ID.
158
+ * @param opts.request The request to match against.
159
+ * @param opts.requestContext An instance of `unstable_RouterContextProvider`
160
+ * that should be created per request, to be passed to loaders, actions and middleware.
161
+ * @param opts.routes Your route definitions.
162
+ * @param opts.createTemporaryReferenceSet A function that returns a temporary
163
+ * reference set for the request, used to track temporary references in the RSC stream.
164
+ * @param opts.onError An optional error handler that will be called with any
165
+ * errors that occur during the request processing.
166
+ * @returns A Response that contains the RSC data for hydration.
167
+ */
107
168
  declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
108
169
  createTemporaryReferenceSet: () => unknown;
109
170
  basename?: string;
@@ -125,6 +186,41 @@ declare global {
125
186
  __FLIGHT_DATA: any[];
126
187
  }
127
188
  }
189
+ /**
190
+ * Get the prerendered RSC stream for hydration. Usually passed directly to your
191
+ * `react-server-dom-xyz/client`'s `createFromReadableStream`.
192
+ *
193
+ * @example
194
+ * import { startTransition, StrictMode } from "react";
195
+ * import { hydrateRoot } from "react-dom/client";
196
+ * import {
197
+ * unstable_getRSCStream as getRSCStream,
198
+ * unstable_RSCHydratedRouter as RSCHydratedRouter,
199
+ * } from "react-router";
200
+ * import type { unstable_RSCPayload as RSCPayload } from "react-router";
201
+ *
202
+ * createFromReadableStream(getRSCStream()).then(
203
+ * (payload: RSCServerPayload) => {
204
+ * startTransition(async () => {
205
+ * hydrateRoot(
206
+ * document,
207
+ * <StrictMode>
208
+ * <RSCHydratedRouter ...props />
209
+ * </StrictMode>,
210
+ * {
211
+ * // Options
212
+ * }
213
+ * );
214
+ * });
215
+ * }
216
+ * );
217
+ *
218
+ * @name unstable_getRSCStream
219
+ * @public
220
+ * @category RSC
221
+ * @mode data
222
+ * @returns A `ReadableStream` that contains the RSC data for hydration.
223
+ */
128
224
  declare function getRSCStream(): ReadableStream<any>;
129
225
 
130
226
  export { type DecodeActionFunction as D, type LoadServerActionFunction as L, type RSCPayload as R, type DecodeFormStateFunction as a, type DecodeReplyFunction as b, type RSCManifestPayload as c, type RSCMatch as d, type RSCRenderPayload as e, type RSCRouteManifest as f, getRSCStream as g, type RSCRouteMatch as h, type RSCRouteConfigEntry as i, type RSCRouteConfig as j, matchRSCServerRequest as m };