react-router 7.9.4 → 7.9.6

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 (74) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/development/browser-BbBXFHbO.d.ts +310 -0
  3. package/dist/development/browser-C07r42Tt.d.mts +310 -0
  4. package/dist/development/{chunk-OIYGIGL5.mjs → chunk-4WY6JWTD.mjs} +458 -43
  5. package/dist/development/{chunk-DI2QHYMJ.js → chunk-AMVS5XVJ.js} +1314 -138
  6. package/dist/development/{chunk-WY5IRSCW.mjs → chunk-G3INQAYP.mjs} +197 -857
  7. package/dist/development/chunk-O4JVZSOY.js +1310 -0
  8. package/dist/development/chunk-PZWDWJAY.js +188 -0
  9. package/dist/development/dom-export.d.mts +103 -6
  10. package/dist/development/dom-export.d.ts +103 -4
  11. package/dist/development/dom-export.js +708 -20
  12. package/dist/development/dom-export.mjs +692 -11
  13. package/dist/{production/index-react-server-client-BbRcBjrA.d.ts → development/index-react-server-client-Da3kmxNd.d.ts} +195 -135
  14. package/dist/{production/index-react-server-client-BIz4AUNd.d.mts → development/index-react-server-client-rcoGPJhU.d.mts} +137 -78
  15. package/dist/development/index-react-server-client.d.mts +2 -3
  16. package/dist/development/index-react-server-client.d.ts +2 -2
  17. package/dist/development/index-react-server-client.js +4 -4
  18. package/dist/development/index-react-server-client.mjs +2 -2
  19. package/dist/development/index-react-server.d.mts +107 -3
  20. package/dist/development/index-react-server.d.ts +107 -3
  21. package/dist/development/index-react-server.js +259 -13
  22. package/dist/development/index-react-server.mjs +259 -13
  23. package/dist/development/index.d.mts +14 -320
  24. package/dist/development/index.d.ts +14 -362
  25. package/dist/development/index.js +146 -962
  26. package/dist/development/index.mjs +3 -9
  27. package/dist/development/{routeModules-D5iJ6JYT.d.ts → instrumentation-Unc20tLk.d.ts} +178 -25
  28. package/dist/development/lib/types/internal.d.mts +2 -3
  29. package/dist/development/lib/types/internal.d.ts +2 -2
  30. package/dist/development/lib/types/internal.js +1 -1
  31. package/dist/development/lib/types/internal.mjs +1 -1
  32. package/dist/{production/register-C34pU-in.d.ts → development/register-BpU9rFBJ.d.ts} +1 -1
  33. package/dist/development/{register-CI4bTprK.d.mts → register-QkB3HGjm.d.mts} +1 -1
  34. package/dist/{production/context-DSyS5mLj.d.mts → development/router-CAvh_Drx.d.mts} +1877 -1254
  35. package/dist/production/browser-BbBXFHbO.d.ts +310 -0
  36. package/dist/production/browser-C07r42Tt.d.mts +310 -0
  37. package/dist/production/{chunk-4E5LHRQP.js → chunk-EAIF67OW.js} +1314 -138
  38. package/dist/production/{chunk-FR6HSPLK.mjs → chunk-FDUMZGKM.mjs} +197 -857
  39. package/dist/production/{chunk-3TADTUL4.mjs → chunk-FUSXQSWG.mjs} +458 -43
  40. package/dist/production/chunk-G5A35OQU.js +188 -0
  41. package/dist/production/chunk-QN64DHI4.js +1310 -0
  42. package/dist/production/dom-export.d.mts +103 -6
  43. package/dist/production/dom-export.d.ts +103 -4
  44. package/dist/production/dom-export.js +708 -20
  45. package/dist/production/dom-export.mjs +692 -11
  46. package/dist/{development/index-react-server-client-BIz4AUNd.d.mts → production/index-react-server-client-Da3kmxNd.d.ts} +137 -78
  47. package/dist/{development/index-react-server-client-BbRcBjrA.d.ts → production/index-react-server-client-rcoGPJhU.d.mts} +195 -135
  48. package/dist/production/index-react-server-client.d.mts +2 -3
  49. package/dist/production/index-react-server-client.d.ts +2 -2
  50. package/dist/production/index-react-server-client.js +4 -4
  51. package/dist/production/index-react-server-client.mjs +2 -2
  52. package/dist/production/index-react-server.d.mts +107 -3
  53. package/dist/production/index-react-server.d.ts +107 -3
  54. package/dist/production/index-react-server.js +259 -13
  55. package/dist/production/index-react-server.mjs +259 -13
  56. package/dist/production/index.d.mts +14 -320
  57. package/dist/production/index.d.ts +14 -362
  58. package/dist/production/index.js +146 -962
  59. package/dist/production/index.mjs +3 -9
  60. package/dist/production/{routeModules-D5iJ6JYT.d.ts → instrumentation-Unc20tLk.d.ts} +178 -25
  61. package/dist/production/lib/types/internal.d.mts +2 -3
  62. package/dist/production/lib/types/internal.d.ts +2 -2
  63. package/dist/production/lib/types/internal.js +1 -1
  64. package/dist/production/lib/types/internal.mjs +1 -1
  65. package/dist/{development/register-C34pU-in.d.ts → production/register-BpU9rFBJ.d.ts} +1 -1
  66. package/dist/production/{register-CI4bTprK.d.mts → register-QkB3HGjm.d.mts} +1 -1
  67. package/dist/{development/context-DSyS5mLj.d.mts → production/router-CAvh_Drx.d.mts} +1877 -1254
  68. package/package.json +1 -1
  69. package/dist/development/browser-z32v5KVN.d.mts +0 -46
  70. package/dist/development/chunk-72XNTZCV.js +0 -2089
  71. package/dist/development/route-data-DZQOUSqV.d.mts +0 -473
  72. package/dist/production/browser-z32v5KVN.d.mts +0 -46
  73. package/dist/production/chunk-WNLQ53P5.js +0 -2089
  74. package/dist/production/route-data-DZQOUSqV.d.mts +0 -473
@@ -1,473 +0,0 @@
1
- import { ComponentType, ReactElement } from 'react';
2
- import { A as ActionFunctionArgs, b as LoaderFunctionArgs, c as ActionFunction, d as LoaderFunction, P as Params, L as Location, e as DataRouteMatch, f as MiddlewareFunction, D as DataStrategyResult, S as ShouldRevalidateFunction, g as RouterContextProvider, h as DataWithResponseInit, i as MiddlewareEnabled } from './context-DSyS5mLj.mjs';
3
-
4
- /**
5
- * An object of unknown type for route loaders and actions provided by the
6
- * server's `getLoadContext()` function. This is defined as an empty interface
7
- * specifically so apps can leverage declaration merging to augment this type
8
- * globally: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
9
- */
10
- interface AppLoadContext {
11
- [key: string]: unknown;
12
- }
13
-
14
- type Primitive = null | undefined | string | number | boolean | symbol | bigint;
15
- type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
16
- interface HtmlLinkProps {
17
- /**
18
- * Address of the hyperlink
19
- */
20
- href?: string;
21
- /**
22
- * How the element handles crossorigin requests
23
- */
24
- crossOrigin?: "anonymous" | "use-credentials";
25
- /**
26
- * Relationship between the document containing the hyperlink and the destination resource
27
- */
28
- rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
29
- /**
30
- * Applicable media: "screen", "print", "(max-width: 764px)"
31
- */
32
- media?: string;
33
- /**
34
- * Integrity metadata used in Subresource Integrity checks
35
- */
36
- integrity?: string;
37
- /**
38
- * Language of the linked resource
39
- */
40
- hrefLang?: string;
41
- /**
42
- * Hint for the type of the referenced resource
43
- */
44
- type?: string;
45
- /**
46
- * Referrer policy for fetches initiated by the element
47
- */
48
- referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
49
- /**
50
- * Sizes of the icons (for rel="icon")
51
- */
52
- sizes?: string;
53
- /**
54
- * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
55
- */
56
- as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
57
- /**
58
- * Color to use when customizing a site's icon (for rel="mask-icon")
59
- */
60
- color?: string;
61
- /**
62
- * Whether the link is disabled
63
- */
64
- disabled?: boolean;
65
- /**
66
- * The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
67
- */
68
- title?: string;
69
- /**
70
- * Images to use in different situations, e.g., high-resolution displays,
71
- * small monitors, etc. (for rel="preload")
72
- */
73
- imageSrcSet?: string;
74
- /**
75
- * Image sizes for different page layouts (for rel="preload")
76
- */
77
- imageSizes?: string;
78
- }
79
- interface HtmlLinkPreloadImage extends HtmlLinkProps {
80
- /**
81
- * Relationship between the document containing the hyperlink and the destination resource
82
- */
83
- rel: "preload";
84
- /**
85
- * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
86
- */
87
- as: "image";
88
- /**
89
- * Address of the hyperlink
90
- */
91
- href?: string;
92
- /**
93
- * Images to use in different situations, e.g., high-resolution displays,
94
- * small monitors, etc. (for rel="preload")
95
- */
96
- imageSrcSet: string;
97
- /**
98
- * Image sizes for different page layouts (for rel="preload")
99
- */
100
- imageSizes?: string;
101
- }
102
- /**
103
- * Represents a `<link>` element.
104
- *
105
- * WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
106
- */
107
- type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
108
- imageSizes?: never;
109
- });
110
- interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
111
- /**
112
- * A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
113
- * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
114
- * element
115
- */
116
- nonce?: string | undefined;
117
- /**
118
- * The absolute path of the page to prefetch, e.g. `/absolute/path`.
119
- */
120
- page: string;
121
- }
122
- type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
123
-
124
- interface RouteModules {
125
- [routeId: string]: RouteModule$1 | undefined;
126
- }
127
- /**
128
- * The shape of a route module shipped to the client
129
- */
130
- interface RouteModule$1 {
131
- clientAction?: ClientActionFunction;
132
- clientLoader?: ClientLoaderFunction;
133
- clientMiddleware?: MiddlewareFunction<Record<string, DataStrategyResult>>[];
134
- ErrorBoundary?: ErrorBoundaryComponent;
135
- HydrateFallback?: HydrateFallbackComponent;
136
- Layout?: LayoutComponent;
137
- default: RouteComponent;
138
- handle?: RouteHandle;
139
- links?: LinksFunction;
140
- meta?: MetaFunction;
141
- shouldRevalidate?: ShouldRevalidateFunction;
142
- }
143
- /**
144
- * The shape of a route module on the server
145
- */
146
- interface ServerRouteModule extends RouteModule$1 {
147
- action?: ActionFunction;
148
- headers?: HeadersFunction | {
149
- [name: string]: string;
150
- };
151
- loader?: LoaderFunction;
152
- middleware?: MiddlewareFunction<Response>[];
153
- }
154
- /**
155
- * A function that handles data mutations for a route on the client
156
- */
157
- type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<ActionFunction>;
158
- /**
159
- * Arguments passed to a route `clientAction` function
160
- */
161
- type ClientActionFunctionArgs = ActionFunctionArgs & {
162
- serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
163
- };
164
- /**
165
- * A function that loads data for a route on the client
166
- */
167
- type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<LoaderFunction>) & {
168
- hydrate?: boolean;
169
- };
170
- /**
171
- * Arguments passed to a route `clientLoader` function
172
- */
173
- type ClientLoaderFunctionArgs = LoaderFunctionArgs & {
174
- serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
175
- };
176
- /**
177
- * ErrorBoundary to display for this route
178
- */
179
- type ErrorBoundaryComponent = ComponentType;
180
- type HeadersArgs = {
181
- loaderHeaders: Headers;
182
- parentHeaders: Headers;
183
- actionHeaders: Headers;
184
- errorHeaders: Headers | undefined;
185
- };
186
- /**
187
- * A function that returns HTTP headers to be used for a route. These headers
188
- * will be merged with (and take precedence over) headers from parent routes.
189
- */
190
- interface HeadersFunction {
191
- (args: HeadersArgs): Headers | HeadersInit;
192
- }
193
- /**
194
- * `<Route HydrateFallback>` component to render on initial loads
195
- * when client loaders are present
196
- */
197
- type HydrateFallbackComponent = ComponentType;
198
- /**
199
- * Optional, root-only `<Route Layout>` component to wrap the root content in.
200
- * Useful for defining the <html>/<head>/<body> document shell shared by the
201
- * Component, HydrateFallback, and ErrorBoundary
202
- */
203
- type LayoutComponent = ComponentType<{
204
- children: ReactElement<unknown, ErrorBoundaryComponent | HydrateFallbackComponent | RouteComponent>;
205
- }>;
206
- /**
207
- * A function that defines `<link>` tags to be inserted into the `<head>` of
208
- * the document on route transitions.
209
- *
210
- * @see https://remix.run/route/meta
211
- */
212
- interface LinksFunction {
213
- (): LinkDescriptor[];
214
- }
215
- interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown> {
216
- id: RouteId;
217
- pathname: DataRouteMatch["pathname"];
218
- /** @deprecated Use `MetaMatch.loaderData` instead */
219
- data: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
220
- loaderData: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
221
- handle?: RouteHandle;
222
- params: DataRouteMatch["params"];
223
- meta: MetaDescriptor[];
224
- error?: unknown;
225
- }
226
- type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{
227
- [K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>;
228
- }[keyof MatchLoaders]>;
229
- interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
230
- /** @deprecated Use `MetaArgs.loaderData` instead */
231
- data: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
232
- loaderData: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
233
- params: Params;
234
- location: Location;
235
- matches: MetaMatches<MatchLoaders>;
236
- error?: unknown;
237
- }
238
- /**
239
- * A function that returns an array of data objects to use for rendering
240
- * metadata HTML tags in a route. These tags are not rendered on descendant
241
- * routes in the route hierarchy. In other words, they will only be rendered on
242
- * the route in which they are exported.
243
- *
244
- * @param Loader - The type of the current route's loader function
245
- * @param MatchLoaders - Mapping from a parent route's filepath to its loader
246
- * function type
247
- *
248
- * Note that parent route filepaths are relative to the `app/` directory.
249
- *
250
- * For example, if this meta function is for `/sales/customers/$customerId`:
251
- *
252
- * ```ts
253
- * // app/root.tsx
254
- * const loader = () => ({ hello: "world" })
255
- * export type Loader = typeof loader
256
- *
257
- * // app/routes/sales.tsx
258
- * const loader = () => ({ salesCount: 1074 })
259
- * export type Loader = typeof loader
260
- *
261
- * // app/routes/sales/customers.tsx
262
- * const loader = () => ({ customerCount: 74 })
263
- * export type Loader = typeof loader
264
- *
265
- * // app/routes/sales/customers/$customersId.tsx
266
- * import type { Loader as RootLoader } from "../../../root"
267
- * import type { Loader as SalesLoader } from "../../sales"
268
- * import type { Loader as CustomersLoader } from "../../sales/customers"
269
- *
270
- * const loader = () => ({ name: "Customer name" })
271
- *
272
- * const meta: MetaFunction<typeof loader, {
273
- * "root": RootLoader,
274
- * "routes/sales": SalesLoader,
275
- * "routes/sales/customers": CustomersLoader,
276
- * }> = ({ data, matches }) => {
277
- * const { name } = data
278
- * // ^? string
279
- * const { customerCount } = matches.find((match) => match.id === "routes/sales/customers").data
280
- * // ^? number
281
- * const { salesCount } = matches.find((match) => match.id === "routes/sales").data
282
- * // ^? number
283
- * const { hello } = matches.find((match) => match.id === "root").data
284
- * // ^? "world"
285
- * }
286
- * ```
287
- */
288
- interface MetaFunction<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
289
- (args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
290
- }
291
- type MetaDescriptor = {
292
- charSet: "utf-8";
293
- } | {
294
- title: string;
295
- } | {
296
- name: string;
297
- content: string;
298
- } | {
299
- property: string;
300
- content: string;
301
- } | {
302
- httpEquiv: string;
303
- content: string;
304
- } | {
305
- "script:ld+json": LdJsonObject;
306
- } | {
307
- tagName: "meta" | "link";
308
- [name: string]: string;
309
- } | {
310
- [name: string]: unknown;
311
- };
312
- type LdJsonObject = {
313
- [Key in string]: LdJsonValue;
314
- } & {
315
- [Key in string]?: LdJsonValue | undefined;
316
- };
317
- type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
318
- type LdJsonPrimitive = string | number | boolean | null;
319
- type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
320
- /**
321
- * A React component that is rendered for a route.
322
- */
323
- type RouteComponent = ComponentType<{}>;
324
- /**
325
- * An arbitrary object that is associated with a route.
326
- *
327
- * @see https://remix.run/route/handle
328
- */
329
- type RouteHandle = unknown;
330
-
331
- type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
332
- [key: PropertyKey]: Serializable;
333
- } | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
334
-
335
- type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
336
- type IsAny<T> = 0 extends 1 & T ? true : false;
337
- type Func = (...args: any[]) => unknown;
338
- type Pretty<T> = {
339
- [K in keyof T]: T[K];
340
- } & {};
341
- type Normalize<T> = _Normalize<UnionKeys<T>, T>;
342
- type _Normalize<Key extends keyof any, T> = T extends infer U ? Pretty<{
343
- [K in Key as K extends keyof U ? undefined extends U[K] ? never : K : never]: K extends keyof U ? U[K] : never;
344
- } & {
345
- [K in Key as K extends keyof U ? undefined extends U[K] ? K : never : never]?: K extends keyof U ? U[K] : never;
346
- } & {
347
- [K in Key as K extends keyof U ? never : K]?: undefined;
348
- }> : never;
349
- type UnionKeys<T> = T extends any ? keyof T : never;
350
-
351
- type RouteModule = {
352
- meta?: Func;
353
- links?: Func;
354
- headers?: Func;
355
- loader?: Func;
356
- clientLoader?: Func;
357
- action?: Func;
358
- clientAction?: Func;
359
- HydrateFallback?: Func;
360
- default?: Func;
361
- ErrorBoundary?: Func;
362
- [key: string]: unknown;
363
- };
364
-
365
- /**
366
- * A brand that can be applied to a type to indicate that it will serialize
367
- * to a specific type when transported to the client from a loader.
368
- * Only use this if you have additional serialization/deserialization logic
369
- * in your application.
370
- */
371
- type unstable_SerializesTo<T> = {
372
- unstable__ReactRouter_SerializesTo: [T];
373
- };
374
-
375
- type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends (...args: any[]) => unknown ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? {
376
- [K in keyof T]: Serialize<T[K]>;
377
- } : undefined;
378
- type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
379
- type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
380
- type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? U : T;
381
- type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
382
- type ServerDataFrom<T> = ServerData<DataFrom<T>>;
383
- type ClientDataFrom<T> = ClientData<DataFrom<T>>;
384
- type ClientDataFunctionArgs<Params> = {
385
- /**
386
- * A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
387
- *
388
- * @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
389
- **/
390
- request: Request;
391
- /**
392
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
393
- * @example
394
- * // app/routes.ts
395
- * route("teams/:teamId", "./team.tsx"),
396
- *
397
- * // app/team.tsx
398
- * export function clientLoader({
399
- * params,
400
- * }: Route.ClientLoaderArgs) {
401
- * params.teamId;
402
- * // ^ string
403
- * }
404
- **/
405
- params: Params;
406
- /**
407
- * When `future.v8_middleware` is not enabled, this is undefined.
408
- *
409
- * When `future.v8_middleware` is enabled, this is an instance of
410
- * `RouterContextProvider` and can be used to access context values
411
- * from your route middlewares. You may pass in initial context values in your
412
- * `<HydratedRouter getContext>` prop
413
- */
414
- context: Readonly<RouterContextProvider>;
415
- };
416
- type ServerDataFunctionArgs<Params> = {
417
- /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
418
- request: Request;
419
- /**
420
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
421
- * @example
422
- * // app/routes.ts
423
- * route("teams/:teamId", "./team.tsx"),
424
- *
425
- * // app/team.tsx
426
- * export function loader({
427
- * params,
428
- * }: Route.LoaderArgs) {
429
- * params.teamId;
430
- * // ^ string
431
- * }
432
- **/
433
- params: Params;
434
- /**
435
- * Without `future.v8_middleware` enabled, this is the context passed in
436
- * to your server adapter's `getLoadContext` function. It's a way to bridge the
437
- * gap between the adapter's request/response API with your React Router app.
438
- * It is only applicable if you are using a custom server adapter.
439
- *
440
- * With `future.v8_middleware` enabled, this is an instance of
441
- * `RouterContextProvider` and can be used for type-safe access to
442
- * context value set in your route middlewares. If you are using a custom
443
- * server adapter, you may provide an initial set of context values from your
444
- * `getLoadContext` function.
445
- */
446
- context: MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : AppLoadContext;
447
- };
448
- type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [
449
- ClientLoaderFunctionArgs | ClientActionFunctionArgs | ClientDataFunctionArgs<unknown>
450
- ] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
451
- type IsDefined<T> = Equal<T, undefined> extends true ? false : true;
452
- type IsHydrate<ClientLoader> = ClientLoader extends {
453
- hydrate: true;
454
- } ? true : ClientLoader extends {
455
- hydrate: false;
456
- } ? false : false;
457
- type GetLoaderData<T extends RouteModule> = _DataLoaderData<ServerDataFrom<T["loader"]>, ClientDataFrom<T["clientLoader"]>, IsHydrate<T["clientLoader"]>, T extends {
458
- HydrateFallback: Func;
459
- } ? true : false>;
460
- type _DataLoaderData<ServerLoaderData, ClientLoaderData, ClientLoaderHydrate extends boolean, HasHydrateFallback> = [
461
- HasHydrateFallback,
462
- ClientLoaderHydrate
463
- ] extends [true, true] ? IsDefined<ClientLoaderData> extends true ? ClientLoaderData : undefined : [
464
- IsDefined<ClientLoaderData>,
465
- IsDefined<ServerLoaderData>
466
- ] extends [true, true] ? ServerLoaderData | ClientLoaderData : IsDefined<ClientLoaderData> extends true ? ClientLoaderData : IsDefined<ServerLoaderData> extends true ? ServerLoaderData : undefined;
467
- type GetActionData<T extends RouteModule> = _DataActionData<ServerDataFrom<T["action"]>, ClientDataFrom<T["clientAction"]>>;
468
- type _DataActionData<ServerActionData, ClientActionData> = Awaited<[
469
- IsDefined<ServerActionData>,
470
- IsDefined<ClientActionData>
471
- ] extends [true, true] ? ServerActionData | ClientActionData : IsDefined<ClientActionData> extends true ? ClientActionData : IsDefined<ServerActionData> extends true ? ServerActionData : undefined>;
472
-
473
- export type { AppLoadContext as A, ClientDataFunctionArgs as C, Equal as E, Func as F, GetLoaderData as G, HeadersFunction as H, LinkDescriptor as L, MetaDescriptor as M, Normalize as N, Pretty as P, RouteModule as R, ServerDataFunctionArgs as S, ServerDataFrom as a, GetActionData as b, RouteModules as c, SerializeFrom as d, MetaFunction as e, LinksFunction as f, ClientActionFunction as g, ClientLoaderFunction as h, ClientActionFunctionArgs as i, ClientLoaderFunctionArgs as j, HeadersArgs as k, MetaArgs as l, PageLinkDescriptor as m, HtmlLinkDescriptor as n, ServerRouteModule as o, unstable_SerializesTo as u };