react-router 7.6.0 → 7.6.1-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 +96 -0
  2. package/dist/development/dom-export.d.mts +1 -2
  3. package/dist/development/dom-export.js +1 -1
  4. package/dist/development/dom-export.mjs +23 -23
  5. package/dist/development/index.d.mts +3740 -260
  6. package/dist/development/index.d.ts +1762 -12
  7. package/dist/development/index.js +16 -7
  8. package/dist/development/index.mjs +11439 -121
  9. package/dist/development/internal-export.d.mts +504 -0
  10. package/dist/development/internal-export.d.ts +504 -0
  11. package/dist/development/{lib/types/route-module.js → internal-export.js} +4 -4
  12. package/dist/development/{lib/types/route-module.mjs → internal-export.mjs} +1 -1
  13. package/dist/production/dom-export.d.mts +1 -2
  14. package/dist/production/dom-export.js +1 -1
  15. package/dist/production/dom-export.mjs +23 -23
  16. package/dist/production/index.d.mts +3740 -260
  17. package/dist/production/index.d.ts +1762 -12
  18. package/dist/production/index.js +16 -7
  19. package/dist/production/index.mjs +11439 -121
  20. package/dist/production/internal-export.d.mts +504 -0
  21. package/dist/production/internal-export.d.ts +504 -0
  22. package/dist/production/{lib/types/route-module.js → internal-export.js} +4 -4
  23. package/dist/production/{lib/types/route-module.mjs → internal-export.mjs} +1 -1
  24. package/package.json +7 -7
  25. package/dist/development/chunk-D4RADZKF.mjs +0 -11556
  26. package/dist/development/lib/types/route-module.d.mts +0 -208
  27. package/dist/development/lib/types/route-module.d.ts +0 -208
  28. package/dist/development/lib-CCSAGgcP.d.mts +0 -1736
  29. package/dist/development/route-data-B9_30zbP.d.ts +0 -1749
  30. package/dist/development/route-data-C6QaL0wu.d.mts +0 -1749
  31. package/dist/production/chunk-CVXGOGHQ.mjs +0 -11556
  32. package/dist/production/lib/types/route-module.d.mts +0 -208
  33. package/dist/production/lib/types/route-module.d.ts +0 -208
  34. package/dist/production/lib-CCSAGgcP.d.mts +0 -1736
  35. package/dist/production/route-data-B9_30zbP.d.ts +0 -1749
  36. package/dist/production/route-data-C6QaL0wu.d.mts +0 -1749
@@ -1,10 +1,1404 @@
1
- import { R as RouteObject, a as RouterInit, F as FutureConfig$1, H as HydrationState, I as InitialEntry, D as DataStrategyFunction, P as PatchRoutesOnNavigationFunction, b as Router$1, T as To, c as RelativeRoutingType, N as NonIndexRouteObject, L as LazyRouteFunction, d as IndexRouteObject, e as Location, A as Action, f as Navigator, g as RouteMatch, h as RouteManifest, S as ServerRouteModule, M as MiddlewareEnabled, u as unstable_RouterContextProvider, i as AppLoadContext, j as LoaderFunctionArgs, k as ActionFunctionArgs, l as StaticHandlerContext, m as RouteModules, n as DataRouteObject, C as ClientLoaderFunction, o as ParamParseKey, p as Path, q as PathPattern, r as PathMatch, s as NavigateOptions, t as Params$1, v as Navigation, U as UIMatch, w as SerializeFrom, B as BlockerFunction, x as Blocker, y as HTMLFormMethod, z as FormEncType, E as PageLinkDescriptor, G as History, J as GetScrollRestorationKeyFunction, K as Fetcher, O as StaticHandler, Q as CreateStaticHandlerOptions$1, V as unstable_InitialContext, W as LoaderFunction, X as ActionFunction, Y as MetaFunction, Z as LinksFunction, _ as Equal, $ as RouterState } from './route-data-B9_30zbP.js';
2
- export { az as ClientActionFunction, aA as ClientActionFunctionArgs, aB as ClientLoaderFunctionArgs, ax as DataRouteMatch, a6 as DataStrategyFunctionArgs, a7 as DataStrategyMatch, a8 as DataStrategyResult, aa as ErrorResponse, ab as FormMethod, aI as Future, a0 as GetScrollPositionFunction, aC as HeadersArgs, aD as HeadersFunction, aG as HtmlLinkDescriptor, an as IDLE_BLOCKER, am as IDLE_FETCHER, al as IDLE_NAVIGATION, aH as LinkDescriptor, aE as MetaArgs, aF as MetaDescriptor, a1 as NavigationStates, ay as PatchRoutesOnNavigationFunctionArgs, ad as PathParam, ae as RedirectFunction, a5 as RevalidationState, a4 as RouterFetchOptions, a3 as RouterNavigateOptions, a2 as RouterSubscriber, ag as ShouldRevalidateFunction, ah as ShouldRevalidateFunctionArgs, aO as UNSAFE_DataRouterContext, aP as UNSAFE_DataRouterStateContext, a9 as UNSAFE_DataWithResponseInit, aN as UNSAFE_ErrorResponseImpl, aQ as UNSAFE_FetchersContext, aR as UNSAFE_LocationContext, aS as UNSAFE_NavigationContext, aT as UNSAFE_RouteContext, aU as UNSAFE_ViewTransitionContext, aK as UNSAFE_createBrowserHistory, aM as UNSAFE_createRouter, aL as UNSAFE_invariant, aj as createPath, ao as data, ap as generatePath, aq as isRouteErrorResponse, ar as matchPath, as as matchRoutes, ak as parsePath, at as redirect, au as redirectDocument, av as replace, aw as resolvePath, ac as unstable_MiddlewareFunction, af as unstable_RouterContext, aJ as unstable_SerializesTo, ai as unstable_createContext } from './route-data-B9_30zbP.js';
3
1
  import * as React from 'react';
4
- import { ReactElement } from 'react';
2
+ import { ComponentType, ReactElement } from 'react';
5
3
  import { ParseOptions, SerializeOptions } from 'cookie';
6
4
  export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
7
5
 
6
+ /**
7
+ * Actions represent the type of change to a location value.
8
+ */
9
+ declare enum Action {
10
+ /**
11
+ * A POP indicates a change to an arbitrary index in the history stack, such
12
+ * as a back or forward navigation. It does not describe the direction of the
13
+ * navigation, only that the current index changed.
14
+ *
15
+ * Note: This is the default action for newly created history objects.
16
+ */
17
+ Pop = "POP",
18
+ /**
19
+ * A PUSH indicates a new entry being added to the history stack, such as when
20
+ * a link is clicked and a new page loads. When this happens, all subsequent
21
+ * entries in the stack are lost.
22
+ */
23
+ Push = "PUSH",
24
+ /**
25
+ * A REPLACE indicates the entry at the current index in the history stack
26
+ * being replaced by a new one.
27
+ */
28
+ Replace = "REPLACE"
29
+ }
30
+ /**
31
+ * The pathname, search, and hash values of a URL.
32
+ */
33
+ interface Path {
34
+ /**
35
+ * A URL pathname, beginning with a /.
36
+ */
37
+ pathname: string;
38
+ /**
39
+ * A URL search string, beginning with a ?.
40
+ */
41
+ search: string;
42
+ /**
43
+ * A URL fragment identifier, beginning with a #.
44
+ */
45
+ hash: string;
46
+ }
47
+ /**
48
+ * An entry in a history stack. A location contains information about the
49
+ * URL path, as well as possibly some arbitrary state and a key.
50
+ */
51
+ interface Location<State = any> extends Path {
52
+ /**
53
+ * A value of arbitrary data associated with this location.
54
+ */
55
+ state: State;
56
+ /**
57
+ * A unique string associated with this location. May be used to safely store
58
+ * and retrieve data in some other storage API, like `localStorage`.
59
+ *
60
+ * Note: This value is always "default" on the initial location.
61
+ */
62
+ key: string;
63
+ }
64
+ /**
65
+ * A change to the current location.
66
+ */
67
+ interface Update {
68
+ /**
69
+ * The action that triggered the change.
70
+ */
71
+ action: Action;
72
+ /**
73
+ * The new location.
74
+ */
75
+ location: Location;
76
+ /**
77
+ * The delta between this location and the former location in the history stack
78
+ */
79
+ delta: number | null;
80
+ }
81
+ /**
82
+ * A function that receives notifications about location changes.
83
+ */
84
+ interface Listener {
85
+ (update: Update): void;
86
+ }
87
+ /**
88
+ * Describes a location that is the destination of some navigation used in
89
+ * {@link Link}, {@link useNavigate}, etc.
90
+ */
91
+ type To = string | Partial<Path>;
92
+ /**
93
+ * A history is an interface to the navigation stack. The history serves as the
94
+ * source of truth for the current location, as well as provides a set of
95
+ * methods that may be used to change it.
96
+ *
97
+ * It is similar to the DOM's `window.history` object, but with a smaller, more
98
+ * focused API.
99
+ */
100
+ interface History {
101
+ /**
102
+ * The last action that modified the current location. This will always be
103
+ * Action.Pop when a history instance is first created. This value is mutable.
104
+ */
105
+ readonly action: Action;
106
+ /**
107
+ * The current location. This value is mutable.
108
+ */
109
+ readonly location: Location;
110
+ /**
111
+ * Returns a valid href for the given `to` value that may be used as
112
+ * the value of an <a href> attribute.
113
+ *
114
+ * @param to - The destination URL
115
+ */
116
+ createHref(to: To): string;
117
+ /**
118
+ * Returns a URL for the given `to` value
119
+ *
120
+ * @param to - The destination URL
121
+ */
122
+ createURL(to: To): URL;
123
+ /**
124
+ * Encode a location the same way window.history would do (no-op for memory
125
+ * history) so we ensure our PUSH/REPLACE navigations for data routers
126
+ * behave the same as POP
127
+ *
128
+ * @param to Unencoded path
129
+ */
130
+ encodeLocation(to: To): Path;
131
+ /**
132
+ * Pushes a new location onto the history stack, increasing its length by one.
133
+ * If there were any entries in the stack after the current one, they are
134
+ * lost.
135
+ *
136
+ * @param to - The new URL
137
+ * @param state - Data to associate with the new location
138
+ */
139
+ push(to: To, state?: any): void;
140
+ /**
141
+ * Replaces the current location in the history stack with a new one. The
142
+ * location that was replaced will no longer be available.
143
+ *
144
+ * @param to - The new URL
145
+ * @param state - Data to associate with the new location
146
+ */
147
+ replace(to: To, state?: any): void;
148
+ /**
149
+ * Navigates `n` entries backward/forward in the history stack relative to the
150
+ * current index. For example, a "back" navigation would use go(-1).
151
+ *
152
+ * @param delta - The delta in the stack index
153
+ */
154
+ go(delta: number): void;
155
+ /**
156
+ * Sets up a listener that will be called whenever the current location
157
+ * changes.
158
+ *
159
+ * @param listener - A function that will be called when the location changes
160
+ * @returns unlisten - A function that may be used to stop listening
161
+ */
162
+ listen(listener: Listener): () => void;
163
+ }
164
+ /**
165
+ * A user-supplied object that describes a location. Used when providing
166
+ * entries to `createMemoryHistory` via its `initialEntries` option.
167
+ */
168
+ type InitialEntry = string | Partial<Location>;
169
+ /**
170
+ * A browser history stores the current location in regular URLs in a web
171
+ * browser environment. This is the standard for most web apps and provides the
172
+ * cleanest URLs the browser's address bar.
173
+ *
174
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory
175
+ */
176
+ interface BrowserHistory extends UrlHistory {
177
+ }
178
+ type BrowserHistoryOptions = UrlHistoryOptions;
179
+ /**
180
+ * Browser history stores the location in regular URLs. This is the standard for
181
+ * most web apps, but it requires some configuration on the server to ensure you
182
+ * serve the same app at multiple URLs.
183
+ *
184
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
185
+ */
186
+ declare function createBrowserHistory(options?: BrowserHistoryOptions): BrowserHistory;
187
+ /**
188
+ * @private
189
+ */
190
+ declare function invariant(value: boolean, message?: string): asserts value;
191
+ declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
192
+ /**
193
+ * Creates a string URL path from the given pathname, search, and hash components.
194
+ *
195
+ * @category Utils
196
+ */
197
+ declare function createPath({ pathname, search, hash, }: Partial<Path>): string;
198
+ /**
199
+ * Parses a string URL path into its separate pathname, search, and hash components.
200
+ *
201
+ * @category Utils
202
+ */
203
+ declare function parsePath(path: string): Partial<Path>;
204
+ interface UrlHistory extends History {
205
+ }
206
+ type UrlHistoryOptions = {
207
+ window?: Window;
208
+ v5Compat?: boolean;
209
+ };
210
+
211
+ /**
212
+ * An augmentable interface users can modify in their app-code to opt into
213
+ * future-flag-specific types
214
+ */
215
+ interface Future {
216
+ }
217
+ type MiddlewareEnabled = Future extends {
218
+ unstable_middleware: infer T extends boolean;
219
+ } ? T : false;
220
+
221
+ type MaybePromise<T> = T | Promise<T>;
222
+ /**
223
+ * Map of routeId -> data returned from a loader/action/error
224
+ */
225
+ interface RouteData {
226
+ [routeId: string]: any;
227
+ }
228
+ type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
229
+ type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
230
+ /**
231
+ * Users can specify either lowercase or uppercase form methods on `<Form>`,
232
+ * useSubmit(), `<fetcher.Form>`, etc.
233
+ */
234
+ type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;
235
+ /**
236
+ * Active navigation/fetcher form methods are exposed in uppercase on the
237
+ * RouterState. This is to align with the normalization done via fetch().
238
+ */
239
+ type FormMethod = UpperCaseFormMethod;
240
+ type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
241
+ type JsonObject$1 = {
242
+ [Key in string]: JsonValue$1;
243
+ } & {
244
+ [Key in string]?: JsonValue$1 | undefined;
245
+ };
246
+ type JsonArray$1 = JsonValue$1[] | readonly JsonValue$1[];
247
+ type JsonPrimitive$1 = string | number | boolean | null;
248
+ type JsonValue$1 = JsonPrimitive$1 | JsonObject$1 | JsonArray$1;
249
+ /**
250
+ * @private
251
+ * Internal interface to pass around for action submissions, not intended for
252
+ * external consumption
253
+ */
254
+ type Submission = {
255
+ formMethod: FormMethod;
256
+ formAction: string;
257
+ formEncType: FormEncType;
258
+ formData: FormData;
259
+ json: undefined;
260
+ text: undefined;
261
+ } | {
262
+ formMethod: FormMethod;
263
+ formAction: string;
264
+ formEncType: FormEncType;
265
+ formData: undefined;
266
+ json: JsonValue$1;
267
+ text: undefined;
268
+ } | {
269
+ formMethod: FormMethod;
270
+ formAction: string;
271
+ formEncType: FormEncType;
272
+ formData: undefined;
273
+ json: undefined;
274
+ text: string;
275
+ };
276
+ interface unstable_RouterContext<T = unknown> {
277
+ defaultValue?: T;
278
+ }
279
+ /**
280
+ * Creates a context object that may be used to store and retrieve arbitrary values.
281
+ *
282
+ * If a `defaultValue` is provided, it will be returned from `context.get()` when no value has been
283
+ * set for the context. Otherwise reading this context when no value has been set will throw an
284
+ * error.
285
+ *
286
+ * @param defaultValue The default value for the context
287
+ * @returns A context object
288
+ */
289
+ declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterContext<T>;
290
+ /**
291
+ * A Map of RouterContext objects to their initial values - used to populate a
292
+ * fresh `context` value per request/navigation/fetch
293
+ */
294
+ type unstable_InitialContext = Map<unstable_RouterContext, unknown>;
295
+ /**
296
+ * Provides methods for writing/reading values in application context in a typesafe way.
297
+ */
298
+ declare class unstable_RouterContextProvider {
299
+ #private;
300
+ constructor(init?: unstable_InitialContext);
301
+ get<T>(context: unstable_RouterContext<T>): T;
302
+ set<C extends unstable_RouterContext>(context: C, value: C extends unstable_RouterContext<infer T> ? T : never): void;
303
+ }
304
+ type DefaultContext = MiddlewareEnabled extends true ? unstable_RouterContextProvider : any;
305
+ /**
306
+ * @private
307
+ * Arguments passed to route loader/action functions. Same for now but we keep
308
+ * this as a private implementation detail in case they diverge in the future.
309
+ */
310
+ interface DataFunctionArgs<Context> {
311
+ /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read headers (like cookies, and {@link https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams URLSearchParams} from the request. */
312
+ request: Request;
313
+ /**
314
+ * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
315
+ * @example
316
+ * // app/routes.ts
317
+ * route("teams/:teamId", "./team.tsx"),
318
+ *
319
+ * // app/team.tsx
320
+ * export function loader({
321
+ * params,
322
+ * }: Route.LoaderArgs) {
323
+ * params.teamId;
324
+ * // ^ string
325
+ * }
326
+ **/
327
+ params: Params;
328
+ /**
329
+ * This is the context passed in to your server adapter's getLoadContext() function.
330
+ * It's a way to bridge the gap between the adapter's request/response API with your React Router app.
331
+ * It is only applicable if you are using a custom server adapter.
332
+ */
333
+ context: Context;
334
+ }
335
+ /**
336
+ * Route middleware `next` function to call downstream handlers and then complete
337
+ * middlewares from the bottom-up
338
+ */
339
+ interface unstable_MiddlewareNextFunction<Result = unknown> {
340
+ (): MaybePromise<Result>;
341
+ }
342
+ /**
343
+ * Route middleware function signature. Receives the same "data" arguments as a
344
+ * `loader`/`action` (`request`, `params`, `context`) as the first parameter and
345
+ * a `next` function as the second parameter which will call downstream handlers
346
+ * and then complete middlewares from the bottom-up
347
+ */
348
+ type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
349
+ /**
350
+ * Arguments passed to loader functions
351
+ */
352
+ interface LoaderFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
353
+ }
354
+ /**
355
+ * Arguments passed to action functions
356
+ */
357
+ interface ActionFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
358
+ }
359
+ /**
360
+ * Loaders and actions can return anything
361
+ */
362
+ type DataFunctionValue = unknown;
363
+ type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
364
+ /**
365
+ * Route loader function signature
366
+ */
367
+ type LoaderFunction<Context = DefaultContext> = {
368
+ (args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
369
+ } & {
370
+ hydrate?: boolean;
371
+ };
372
+ /**
373
+ * Route action function signature
374
+ */
375
+ interface ActionFunction<Context = DefaultContext> {
376
+ (args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
377
+ }
378
+ /**
379
+ * Arguments passed to shouldRevalidate function
380
+ */
381
+ interface ShouldRevalidateFunctionArgs {
382
+ /** This is the url the navigation started from. You can compare it with `nextUrl` to decide if you need to revalidate this route's data. */
383
+ currentUrl: URL;
384
+ /** These are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the URL that can be compared to the `nextParams` to decide if you need to reload or not. Perhaps you're using only a partial piece of the param for data loading, you don't need to revalidate if a superfluous part of the param changed. */
385
+ currentParams: AgnosticDataRouteMatch["params"];
386
+ /** In the case of navigation, this the URL the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentUrl. */
387
+ nextUrl: URL;
388
+ /** In the case of navigation, these are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the next location the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentParams. */
389
+ nextParams: AgnosticDataRouteMatch["params"];
390
+ /** The method (probably `"GET"` or `"POST"`) used in the form submission that triggered the revalidation. */
391
+ formMethod?: Submission["formMethod"];
392
+ /** The form action (`<Form action="/somewhere">`) that triggered the revalidation. */
393
+ formAction?: Submission["formAction"];
394
+ /** The form encType (`<Form encType="application/x-www-form-urlencoded">) used in the form submission that triggered the revalidation*/
395
+ formEncType?: Submission["formEncType"];
396
+ /** The form submission data when the form's encType is `text/plain` */
397
+ text?: Submission["text"];
398
+ /** The form submission data when the form's encType is `application/x-www-form-urlencoded` or `multipart/form-data` */
399
+ formData?: Submission["formData"];
400
+ /** The form submission data when the form's encType is `application/json` */
401
+ json?: Submission["json"];
402
+ /** The status code of the action response */
403
+ actionStatus?: number;
404
+ /**
405
+ * When a submission causes the revalidation this will be the result of the action—either action data or an error if the action failed. It's common to include some information in the action result to instruct shouldRevalidate to revalidate or not.
406
+ *
407
+ * @example
408
+ * export async function action() {
409
+ * await saveSomeStuff();
410
+ * return { ok: true };
411
+ * }
412
+ *
413
+ * export function shouldRevalidate({
414
+ * actionResult,
415
+ * }) {
416
+ * if (actionResult?.ok) {
417
+ * return false;
418
+ * }
419
+ * return true;
420
+ * }
421
+ */
422
+ actionResult?: any;
423
+ /**
424
+ * By default, React Router doesn't call every loader all the time. There are reliable optimizations it can make by default. For example, only loaders with changing params are called. Consider navigating from the following URL to the one below it:
425
+ *
426
+ * /projects/123/tasks/abc
427
+ * /projects/123/tasks/def
428
+ * React Router will only call the loader for tasks/def because the param for projects/123 didn't change.
429
+ *
430
+ * It's safest to always return defaultShouldRevalidate after you've done your specific optimizations that return false, otherwise your UI might get out of sync with your data on the server.
431
+ */
432
+ defaultShouldRevalidate: boolean;
433
+ }
434
+ /**
435
+ * Route shouldRevalidate function signature. This runs after any submission
436
+ * (navigation or fetcher), so we flatten the navigation/fetcher submission
437
+ * onto the arguments. It shouldn't matter whether it came from a navigation
438
+ * or a fetcher, what really matters is the URLs and the formData since loaders
439
+ * have to re-run based on the data models that were potentially mutated.
440
+ */
441
+ interface ShouldRevalidateFunction {
442
+ (args: ShouldRevalidateFunctionArgs): boolean;
443
+ }
444
+ interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
445
+ /**
446
+ * @private
447
+ */
448
+ _lazyPromises?: {
449
+ middleware: Promise<void> | undefined;
450
+ handler: Promise<void> | undefined;
451
+ route: Promise<void> | undefined;
452
+ };
453
+ shouldLoad: boolean;
454
+ unstable_shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
455
+ unstable_shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
456
+ resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
457
+ }
458
+ interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
459
+ matches: DataStrategyMatch[];
460
+ unstable_runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
461
+ fetcherKey: string | null;
462
+ }
463
+ /**
464
+ * Result from a loader or action called via dataStrategy
465
+ */
466
+ interface DataStrategyResult {
467
+ type: "data" | "error";
468
+ result: unknown;
469
+ }
470
+ interface DataStrategyFunction<Context = DefaultContext> {
471
+ (args: DataStrategyFunctionArgs<Context>): Promise<Record<string, DataStrategyResult>>;
472
+ }
473
+ type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = {
474
+ signal: AbortSignal;
475
+ path: string;
476
+ matches: M[];
477
+ fetcherKey: string | undefined;
478
+ patch: (routeId: string | null, children: O[]) => void;
479
+ };
480
+ type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => MaybePromise<void>;
481
+ /**
482
+ * Function provided by the framework-aware layers to set any framework-specific
483
+ * properties from framework-agnostic properties
484
+ */
485
+ interface MapRoutePropertiesFunction {
486
+ (route: AgnosticRouteObject): {
487
+ hasErrorBoundary: boolean;
488
+ } & Record<string, any>;
489
+ }
490
+ /**
491
+ * Keys we cannot change from within a lazy object. We spread all other keys
492
+ * onto the route. Either they're meaningful to the router, or they'll get
493
+ * ignored.
494
+ */
495
+ type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
496
+ /**
497
+ * Keys we cannot change from within a lazy() function. We spread all other keys
498
+ * onto the route. Either they're meaningful to the router, or they'll get
499
+ * ignored.
500
+ */
501
+ type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "unstable_middleware";
502
+ /**
503
+ * lazy object to load route properties, which can add non-matching
504
+ * related properties to a route
505
+ */
506
+ type LazyRouteObject<R extends AgnosticRouteObject> = {
507
+ [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined>;
508
+ };
509
+ /**
510
+ * lazy() function to load a route definition, which can add non-matching
511
+ * related properties to a route
512
+ */
513
+ interface LazyRouteFunction<R extends AgnosticRouteObject> {
514
+ (): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
515
+ }
516
+ type LazyRouteDefinition<R extends AgnosticRouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
517
+ /**
518
+ * Base RouteObject with common props shared by all types of routes
519
+ */
520
+ type AgnosticBaseRouteObject = {
521
+ caseSensitive?: boolean;
522
+ path?: string;
523
+ id?: string;
524
+ unstable_middleware?: unstable_MiddlewareFunction[];
525
+ loader?: LoaderFunction | boolean;
526
+ action?: ActionFunction | boolean;
527
+ hasErrorBoundary?: boolean;
528
+ shouldRevalidate?: ShouldRevalidateFunction;
529
+ handle?: any;
530
+ lazy?: LazyRouteDefinition<AgnosticBaseRouteObject>;
531
+ };
532
+ /**
533
+ * Index routes must not have children
534
+ */
535
+ type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
536
+ children?: undefined;
537
+ index: true;
538
+ };
539
+ /**
540
+ * Non-index routes may have children, but cannot have index
541
+ */
542
+ type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
543
+ children?: AgnosticRouteObject[];
544
+ index?: false;
545
+ };
546
+ /**
547
+ * A route object represents a logical route, with (optionally) its child
548
+ * routes organized in a tree-like structure.
549
+ */
550
+ type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
551
+ type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
552
+ id: string;
553
+ };
554
+ type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
555
+ children?: AgnosticDataRouteObject[];
556
+ id: string;
557
+ };
558
+ /**
559
+ * A data route object, which is just a RouteObject with a required unique ID
560
+ */
561
+ type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
562
+ type RouteManifest<R = AgnosticDataRouteObject> = Record<string, R | undefined>;
563
+ type Regex_az = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
564
+ type Regez_AZ = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z";
565
+ type Regex_09 = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
566
+ type Regex_w = Regex_az | Regez_AZ | Regex_09 | "_";
567
+ type ParamChar = Regex_w | "-";
568
+ type RegexMatchPlus<CharPattern extends string, T extends string> = T extends `${infer First}${infer Rest}` ? First extends CharPattern ? RegexMatchPlus<CharPattern, Rest> extends never ? First : `${First}${RegexMatchPlus<CharPattern, Rest>}` : never : never;
569
+ type _PathParam<Path extends string> = Path extends `${infer L}/${infer R}` ? _PathParam<L> | _PathParam<R> : Path extends `:${infer Param}` ? Param extends `${infer Optional}?${string}` ? RegexMatchPlus<ParamChar, Optional> : RegexMatchPlus<ParamChar, Param> : never;
570
+ type PathParam<Path extends string> = Path extends "*" | "/*" ? "*" : Path extends `${infer Rest}/*` ? "*" | _PathParam<Rest> : _PathParam<Path>;
571
+ type ParamParseKey<Segment extends string> = [
572
+ PathParam<Segment>
573
+ ] extends [never] ? string : PathParam<Segment>;
574
+ /**
575
+ * The parameters that were parsed from the URL path.
576
+ */
577
+ type Params<Key extends string = string> = {
578
+ readonly [key in Key]: string | undefined;
579
+ };
580
+ /**
581
+ * A RouteMatch contains info about how a route matched a URL.
582
+ */
583
+ interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
584
+ /**
585
+ * The names and values of dynamic parameters in the URL.
586
+ */
587
+ params: Params<ParamKey>;
588
+ /**
589
+ * The portion of the URL pathname that was matched.
590
+ */
591
+ pathname: string;
592
+ /**
593
+ * The portion of the URL pathname that was matched before child routes.
594
+ */
595
+ pathnameBase: string;
596
+ /**
597
+ * The route object that was used to match.
598
+ */
599
+ route: RouteObjectType;
600
+ }
601
+ interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
602
+ }
603
+ /**
604
+ * Matches the given routes to a location and returns the match data.
605
+ *
606
+ * @category Utils
607
+ */
608
+ declare function matchRoutes<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): AgnosticRouteMatch<string, RouteObjectType>[] | null;
609
+ interface UIMatch<Data = unknown, Handle = unknown> {
610
+ id: string;
611
+ pathname: string;
612
+ /**
613
+ * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
614
+ **/
615
+ params: AgnosticRouteMatch["params"];
616
+ /** The return value from the matched route's loader or clientLoader */
617
+ data: Data;
618
+ /** The {@link https://reactrouter.com/start/framework/route-module#handle handle object} exported from the matched route module */
619
+ handle: Handle;
620
+ }
621
+ /**
622
+ * Returns a path with params interpolated.
623
+ *
624
+ * @category Utils
625
+ */
626
+ declare function generatePath<Path extends string>(originalPath: Path, params?: {
627
+ [key in PathParam<Path>]: string | null;
628
+ }): string;
629
+ /**
630
+ * A PathPattern is used to match on some portion of a URL pathname.
631
+ */
632
+ interface PathPattern<Path extends string = string> {
633
+ /**
634
+ * A string to match against a URL pathname. May contain `:id`-style segments
635
+ * to indicate placeholders for dynamic parameters. May also end with `/*` to
636
+ * indicate matching the rest of the URL pathname.
637
+ */
638
+ path: Path;
639
+ /**
640
+ * Should be `true` if the static portions of the `path` should be matched in
641
+ * the same case.
642
+ */
643
+ caseSensitive?: boolean;
644
+ /**
645
+ * Should be `true` if this pattern should match the entire URL pathname.
646
+ */
647
+ end?: boolean;
648
+ }
649
+ /**
650
+ * A PathMatch contains info about how a PathPattern matched on a URL pathname.
651
+ */
652
+ interface PathMatch<ParamKey extends string = string> {
653
+ /**
654
+ * The names and values of dynamic parameters in the URL.
655
+ */
656
+ params: Params<ParamKey>;
657
+ /**
658
+ * The portion of the URL pathname that was matched.
659
+ */
660
+ pathname: string;
661
+ /**
662
+ * The portion of the URL pathname that was matched before child routes.
663
+ */
664
+ pathnameBase: string;
665
+ /**
666
+ * The pattern that was used to match.
667
+ */
668
+ pattern: PathPattern;
669
+ }
670
+ /**
671
+ * Performs pattern matching on a URL pathname and returns information about
672
+ * the match.
673
+ *
674
+ * @category Utils
675
+ */
676
+ declare function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamKey> | null;
677
+ /**
678
+ * Returns a resolved path object relative to the given pathname.
679
+ *
680
+ * @category Utils
681
+ */
682
+ declare function resolvePath(to: To, fromPathname?: string): Path;
683
+ declare class DataWithResponseInit<D> {
684
+ type: string;
685
+ data: D;
686
+ init: ResponseInit | null;
687
+ constructor(data: D, init?: ResponseInit);
688
+ }
689
+ /**
690
+ * Create "responses" that contain `status`/`headers` without forcing
691
+ * serialization into an actual `Response` - used by Remix single fetch
692
+ *
693
+ * @category Utils
694
+ */
695
+ declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
696
+ type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
697
+ /**
698
+ * A redirect response. Sets the status code and the `Location` header.
699
+ * Defaults to "302 Found".
700
+ *
701
+ * @category Utils
702
+ */
703
+ declare const redirect: RedirectFunction;
704
+ /**
705
+ * A redirect response that will force a document reload to the new location.
706
+ * Sets the status code and the `Location` header.
707
+ * Defaults to "302 Found".
708
+ *
709
+ * @category Utils
710
+ */
711
+ declare const redirectDocument: RedirectFunction;
712
+ /**
713
+ * A redirect response that will perform a `history.replaceState` instead of a
714
+ * `history.pushState` for client-side navigation redirects.
715
+ * Sets the status code and the `Location` header.
716
+ * Defaults to "302 Found".
717
+ *
718
+ * @category Utils
719
+ */
720
+ declare const replace: RedirectFunction;
721
+ type ErrorResponse = {
722
+ status: number;
723
+ statusText: string;
724
+ data: any;
725
+ };
726
+ /**
727
+ * @private
728
+ * Utility class we use to hold auto-unwrapped 4xx/5xx Response bodies
729
+ *
730
+ * We don't export the class for public use since it's an implementation
731
+ * detail, but we export the interface above so folks can build their own
732
+ * abstractions around instances via isRouteErrorResponse()
733
+ */
734
+ declare class ErrorResponseImpl implements ErrorResponse {
735
+ status: number;
736
+ statusText: string;
737
+ data: any;
738
+ private error?;
739
+ private internal;
740
+ constructor(status: number, statusText: string | undefined, data: any, internal?: boolean);
741
+ }
742
+ /**
743
+ * Check if the given error is an ErrorResponse generated from a 4xx/5xx
744
+ * Response thrown from an action/loader
745
+ *
746
+ * @category Utils
747
+ */
748
+ declare function isRouteErrorResponse(error: any): error is ErrorResponse;
749
+
750
+ /**
751
+ * A Router instance manages all navigation and data loading/mutations
752
+ */
753
+ interface Router$1 {
754
+ /**
755
+ * @private
756
+ * PRIVATE - DO NOT USE
757
+ *
758
+ * Return the basename for the router
759
+ */
760
+ get basename(): RouterInit["basename"];
761
+ /**
762
+ * @private
763
+ * PRIVATE - DO NOT USE
764
+ *
765
+ * Return the future config for the router
766
+ */
767
+ get future(): FutureConfig$1;
768
+ /**
769
+ * @private
770
+ * PRIVATE - DO NOT USE
771
+ *
772
+ * Return the current state of the router
773
+ */
774
+ get state(): RouterState;
775
+ /**
776
+ * @private
777
+ * PRIVATE - DO NOT USE
778
+ *
779
+ * Return the routes for this router instance
780
+ */
781
+ get routes(): AgnosticDataRouteObject[];
782
+ /**
783
+ * @private
784
+ * PRIVATE - DO NOT USE
785
+ *
786
+ * Return the window associated with the router
787
+ */
788
+ get window(): RouterInit["window"];
789
+ /**
790
+ * @private
791
+ * PRIVATE - DO NOT USE
792
+ *
793
+ * Initialize the router, including adding history listeners and kicking off
794
+ * initial data fetches. Returns a function to cleanup listeners and abort
795
+ * any in-progress loads
796
+ */
797
+ initialize(): Router$1;
798
+ /**
799
+ * @private
800
+ * PRIVATE - DO NOT USE
801
+ *
802
+ * Subscribe to router.state updates
803
+ *
804
+ * @param fn function to call with the new state
805
+ */
806
+ subscribe(fn: RouterSubscriber): () => void;
807
+ /**
808
+ * @private
809
+ * PRIVATE - DO NOT USE
810
+ *
811
+ * Enable scroll restoration behavior in the router
812
+ *
813
+ * @param savedScrollPositions Object that will manage positions, in case
814
+ * it's being restored from sessionStorage
815
+ * @param getScrollPosition Function to get the active Y scroll position
816
+ * @param getKey Function to get the key to use for restoration
817
+ */
818
+ enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
819
+ /**
820
+ * @private
821
+ * PRIVATE - DO NOT USE
822
+ *
823
+ * Navigate forward/backward in the history stack
824
+ * @param to Delta to move in the history stack
825
+ */
826
+ navigate(to: number): Promise<void>;
827
+ /**
828
+ * Navigate to the given path
829
+ * @param to Path to navigate to
830
+ * @param opts Navigation options (method, submission, etc.)
831
+ */
832
+ navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
833
+ /**
834
+ * @private
835
+ * PRIVATE - DO NOT USE
836
+ *
837
+ * Trigger a fetcher load/submission
838
+ *
839
+ * @param key Fetcher key
840
+ * @param routeId Route that owns the fetcher
841
+ * @param href href to fetch
842
+ * @param opts Fetcher options, (method, submission, etc.)
843
+ */
844
+ fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): Promise<void>;
845
+ /**
846
+ * @private
847
+ * PRIVATE - DO NOT USE
848
+ *
849
+ * Trigger a revalidation of all current route loaders and fetcher loads
850
+ */
851
+ revalidate(): Promise<void>;
852
+ /**
853
+ * @private
854
+ * PRIVATE - DO NOT USE
855
+ *
856
+ * Utility function to create an href for the given location
857
+ * @param location
858
+ */
859
+ createHref(location: Location | URL): string;
860
+ /**
861
+ * @private
862
+ * PRIVATE - DO NOT USE
863
+ *
864
+ * Utility function to URL encode a destination path according to the internal
865
+ * history implementation
866
+ * @param to
867
+ */
868
+ encodeLocation(to: To): Path;
869
+ /**
870
+ * @private
871
+ * PRIVATE - DO NOT USE
872
+ *
873
+ * Get/create a fetcher for the given key
874
+ * @param key
875
+ */
876
+ getFetcher<TData = any>(key: string): Fetcher<TData>;
877
+ /**
878
+ * @private
879
+ * PRIVATE - DO NOT USE
880
+ *
881
+ * Delete the fetcher for a given key
882
+ * @param key
883
+ */
884
+ deleteFetcher(key: string): void;
885
+ /**
886
+ * @private
887
+ * PRIVATE - DO NOT USE
888
+ *
889
+ * Cleanup listeners and abort any in-progress loads
890
+ */
891
+ dispose(): void;
892
+ /**
893
+ * @private
894
+ * PRIVATE - DO NOT USE
895
+ *
896
+ * Get a navigation blocker
897
+ * @param key The identifier for the blocker
898
+ * @param fn The blocker function implementation
899
+ */
900
+ getBlocker(key: string, fn: BlockerFunction): Blocker;
901
+ /**
902
+ * @private
903
+ * PRIVATE - DO NOT USE
904
+ *
905
+ * Delete a navigation blocker
906
+ * @param key The identifier for the blocker
907
+ */
908
+ deleteBlocker(key: string): void;
909
+ /**
910
+ * @private
911
+ * PRIVATE DO NOT USE
912
+ *
913
+ * Patch additional children routes into an existing parent route
914
+ * @param routeId The parent route id or a callback function accepting `patch`
915
+ * to perform batch patching
916
+ * @param children The additional children routes
917
+ */
918
+ patchRoutes(routeId: string | null, children: AgnosticRouteObject[]): void;
919
+ /**
920
+ * @private
921
+ * PRIVATE - DO NOT USE
922
+ *
923
+ * HMR needs to pass in-flight route updates to React Router
924
+ * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
925
+ */
926
+ _internalSetRoutes(routes: AgnosticRouteObject[]): void;
927
+ /**
928
+ * @private
929
+ * PRIVATE - DO NOT USE
930
+ *
931
+ * Internal fetch AbortControllers accessed by unit tests
932
+ */
933
+ _internalFetchControllers: Map<string, AbortController>;
934
+ }
935
+ /**
936
+ * State maintained internally by the router. During a navigation, all states
937
+ * reflect the "old" location unless otherwise noted.
938
+ */
939
+ interface RouterState {
940
+ /**
941
+ * The action of the most recent navigation
942
+ */
943
+ historyAction: Action;
944
+ /**
945
+ * The current location reflected by the router
946
+ */
947
+ location: Location;
948
+ /**
949
+ * The current set of route matches
950
+ */
951
+ matches: AgnosticDataRouteMatch[];
952
+ /**
953
+ * Tracks whether we've completed our initial data load
954
+ */
955
+ initialized: boolean;
956
+ /**
957
+ * Current scroll position we should start at for a new view
958
+ * - number -> scroll position to restore to
959
+ * - false -> do not restore scroll at all (used during submissions)
960
+ * - null -> don't have a saved position, scroll to hash or top of page
961
+ */
962
+ restoreScrollPosition: number | false | null;
963
+ /**
964
+ * Indicate whether this navigation should skip resetting the scroll position
965
+ * if we are unable to restore the scroll position
966
+ */
967
+ preventScrollReset: boolean;
968
+ /**
969
+ * Tracks the state of the current navigation
970
+ */
971
+ navigation: Navigation;
972
+ /**
973
+ * Tracks any in-progress revalidations
974
+ */
975
+ revalidation: RevalidationState;
976
+ /**
977
+ * Data from the loaders for the current matches
978
+ */
979
+ loaderData: RouteData;
980
+ /**
981
+ * Data from the action for the current matches
982
+ */
983
+ actionData: RouteData | null;
984
+ /**
985
+ * Errors caught from loaders for the current matches
986
+ */
987
+ errors: RouteData | null;
988
+ /**
989
+ * Map of current fetchers
990
+ */
991
+ fetchers: Map<string, Fetcher>;
992
+ /**
993
+ * Map of current blockers
994
+ */
995
+ blockers: Map<string, Blocker>;
996
+ }
997
+ /**
998
+ * Data that can be passed into hydrate a Router from SSR
999
+ */
1000
+ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
1001
+ /**
1002
+ * Future flags to toggle new feature behavior
1003
+ */
1004
+ interface FutureConfig$1 {
1005
+ unstable_middleware: boolean;
1006
+ }
1007
+ /**
1008
+ * Initialization options for createRouter
1009
+ */
1010
+ interface RouterInit {
1011
+ routes: AgnosticRouteObject[];
1012
+ history: History;
1013
+ basename?: string;
1014
+ unstable_getContext?: () => MaybePromise<unstable_InitialContext>;
1015
+ mapRouteProperties?: MapRoutePropertiesFunction;
1016
+ future?: Partial<FutureConfig$1>;
1017
+ hydrationRouteProperties?: string[];
1018
+ hydrationData?: HydrationState;
1019
+ window?: Window;
1020
+ dataStrategy?: DataStrategyFunction;
1021
+ patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction;
1022
+ }
1023
+ /**
1024
+ * State returned from a server-side query() call
1025
+ */
1026
+ interface StaticHandlerContext {
1027
+ basename: Router$1["basename"];
1028
+ location: RouterState["location"];
1029
+ matches: RouterState["matches"];
1030
+ loaderData: RouterState["loaderData"];
1031
+ actionData: RouterState["actionData"];
1032
+ errors: RouterState["errors"];
1033
+ statusCode: number;
1034
+ loaderHeaders: Record<string, Headers>;
1035
+ actionHeaders: Record<string, Headers>;
1036
+ _deepestRenderedBoundaryId?: string | null;
1037
+ }
1038
+ /**
1039
+ * A StaticHandler instance manages a singular SSR navigation/fetch event
1040
+ */
1041
+ interface StaticHandler {
1042
+ dataRoutes: AgnosticDataRouteObject[];
1043
+ query(request: Request, opts?: {
1044
+ requestContext?: unknown;
1045
+ filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
1046
+ skipLoaderErrorBubbling?: boolean;
1047
+ skipRevalidation?: boolean;
1048
+ dataStrategy?: DataStrategyFunction<unknown>;
1049
+ unstable_respond?: (staticContext: StaticHandlerContext) => MaybePromise<Response>;
1050
+ }): Promise<StaticHandlerContext | Response>;
1051
+ queryRoute(request: Request, opts?: {
1052
+ routeId?: string;
1053
+ requestContext?: unknown;
1054
+ dataStrategy?: DataStrategyFunction<unknown>;
1055
+ unstable_respond?: (res: Response) => MaybePromise<Response>;
1056
+ }): Promise<any>;
1057
+ }
1058
+ type ViewTransitionOpts = {
1059
+ currentLocation: Location;
1060
+ nextLocation: Location;
1061
+ };
1062
+ /**
1063
+ * Subscriber function signature for changes to router state
1064
+ */
1065
+ interface RouterSubscriber {
1066
+ (state: RouterState, opts: {
1067
+ deletedFetchers: string[];
1068
+ viewTransitionOpts?: ViewTransitionOpts;
1069
+ flushSync: boolean;
1070
+ }): void;
1071
+ }
1072
+ /**
1073
+ * Function signature for determining the key to be used in scroll restoration
1074
+ * for a given location
1075
+ */
1076
+ interface GetScrollRestorationKeyFunction {
1077
+ (location: Location, matches: UIMatch[]): string | null;
1078
+ }
1079
+ /**
1080
+ * Function signature for determining the current scroll position
1081
+ */
1082
+ interface GetScrollPositionFunction {
1083
+ (): number;
1084
+ }
1085
+ /**
1086
+ - "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.
1087
+ - "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.
1088
+ */
1089
+ type RelativeRoutingType = "route" | "path";
1090
+ type BaseNavigateOrFetchOptions = {
1091
+ preventScrollReset?: boolean;
1092
+ relative?: RelativeRoutingType;
1093
+ flushSync?: boolean;
1094
+ };
1095
+ type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
1096
+ replace?: boolean;
1097
+ state?: any;
1098
+ fromRouteId?: string;
1099
+ viewTransition?: boolean;
1100
+ };
1101
+ type BaseSubmissionOptions = {
1102
+ formMethod?: HTMLFormMethod;
1103
+ formEncType?: FormEncType;
1104
+ } & ({
1105
+ formData: FormData;
1106
+ body?: undefined;
1107
+ } | {
1108
+ formData?: undefined;
1109
+ body: any;
1110
+ });
1111
+ /**
1112
+ * Options for a navigate() call for a normal (non-submission) navigation
1113
+ */
1114
+ type LinkNavigateOptions = BaseNavigateOptions;
1115
+ /**
1116
+ * Options for a navigate() call for a submission navigation
1117
+ */
1118
+ type SubmissionNavigateOptions = BaseNavigateOptions & BaseSubmissionOptions;
1119
+ /**
1120
+ * Options to pass to navigate() for a navigation
1121
+ */
1122
+ type RouterNavigateOptions = LinkNavigateOptions | SubmissionNavigateOptions;
1123
+ /**
1124
+ * Options for a fetch() load
1125
+ */
1126
+ type LoadFetchOptions = BaseNavigateOrFetchOptions;
1127
+ /**
1128
+ * Options for a fetch() submission
1129
+ */
1130
+ type SubmitFetchOptions = BaseNavigateOrFetchOptions & BaseSubmissionOptions;
1131
+ /**
1132
+ * Options to pass to fetch()
1133
+ */
1134
+ type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
1135
+ /**
1136
+ * Potential states for state.navigation
1137
+ */
1138
+ type NavigationStates = {
1139
+ Idle: {
1140
+ state: "idle";
1141
+ location: undefined;
1142
+ formMethod: undefined;
1143
+ formAction: undefined;
1144
+ formEncType: undefined;
1145
+ formData: undefined;
1146
+ json: undefined;
1147
+ text: undefined;
1148
+ };
1149
+ Loading: {
1150
+ state: "loading";
1151
+ location: Location;
1152
+ formMethod: Submission["formMethod"] | undefined;
1153
+ formAction: Submission["formAction"] | undefined;
1154
+ formEncType: Submission["formEncType"] | undefined;
1155
+ formData: Submission["formData"] | undefined;
1156
+ json: Submission["json"] | undefined;
1157
+ text: Submission["text"] | undefined;
1158
+ };
1159
+ Submitting: {
1160
+ state: "submitting";
1161
+ location: Location;
1162
+ formMethod: Submission["formMethod"];
1163
+ formAction: Submission["formAction"];
1164
+ formEncType: Submission["formEncType"];
1165
+ formData: Submission["formData"];
1166
+ json: Submission["json"];
1167
+ text: Submission["text"];
1168
+ };
1169
+ };
1170
+ type Navigation = NavigationStates[keyof NavigationStates];
1171
+ type RevalidationState = "idle" | "loading";
1172
+ /**
1173
+ * Potential states for fetchers
1174
+ */
1175
+ type FetcherStates<TData = any> = {
1176
+ /**
1177
+ * The fetcher is not calling a loader or action
1178
+ *
1179
+ * ```tsx
1180
+ * fetcher.state === "idle"
1181
+ * ```
1182
+ */
1183
+ Idle: {
1184
+ state: "idle";
1185
+ formMethod: undefined;
1186
+ formAction: undefined;
1187
+ formEncType: undefined;
1188
+ text: undefined;
1189
+ formData: undefined;
1190
+ json: undefined;
1191
+ /**
1192
+ * If the fetcher has never been called, this will be undefined.
1193
+ */
1194
+ data: TData | undefined;
1195
+ };
1196
+ /**
1197
+ * The fetcher is loading data from a {@link LoaderFunction | loader} from a
1198
+ * call to {@link FetcherWithComponents.load | `fetcher.load`}.
1199
+ *
1200
+ * ```tsx
1201
+ * // somewhere
1202
+ * <button onClick={() => fetcher.load("/some/route") }>Load</button>
1203
+ *
1204
+ * // the state will update
1205
+ * fetcher.state === "loading"
1206
+ * ```
1207
+ */
1208
+ Loading: {
1209
+ state: "loading";
1210
+ formMethod: Submission["formMethod"] | undefined;
1211
+ formAction: Submission["formAction"] | undefined;
1212
+ formEncType: Submission["formEncType"] | undefined;
1213
+ text: Submission["text"] | undefined;
1214
+ formData: Submission["formData"] | undefined;
1215
+ json: Submission["json"] | undefined;
1216
+ data: TData | undefined;
1217
+ };
1218
+ /**
1219
+ The fetcher is submitting to a {@link LoaderFunction} (GET) or {@link ActionFunction} (POST) from a {@link FetcherWithComponents.Form | `fetcher.Form`} or {@link FetcherWithComponents.submit | `fetcher.submit`}.
1220
+
1221
+ ```tsx
1222
+ // somewhere
1223
+ <input
1224
+ onChange={e => {
1225
+ fetcher.submit(event.currentTarget.form, { method: "post" });
1226
+ }}
1227
+ />
1228
+
1229
+ // the state will update
1230
+ fetcher.state === "submitting"
1231
+
1232
+ // and formData will be available
1233
+ fetcher.formData
1234
+ ```
1235
+ */
1236
+ Submitting: {
1237
+ state: "submitting";
1238
+ formMethod: Submission["formMethod"];
1239
+ formAction: Submission["formAction"];
1240
+ formEncType: Submission["formEncType"];
1241
+ text: Submission["text"];
1242
+ formData: Submission["formData"];
1243
+ json: Submission["json"];
1244
+ data: TData | undefined;
1245
+ };
1246
+ };
1247
+ type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
1248
+ interface BlockerBlocked {
1249
+ state: "blocked";
1250
+ reset(): void;
1251
+ proceed(): void;
1252
+ location: Location;
1253
+ }
1254
+ interface BlockerUnblocked {
1255
+ state: "unblocked";
1256
+ reset: undefined;
1257
+ proceed: undefined;
1258
+ location: undefined;
1259
+ }
1260
+ interface BlockerProceeding {
1261
+ state: "proceeding";
1262
+ reset: undefined;
1263
+ proceed: undefined;
1264
+ location: Location;
1265
+ }
1266
+ type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
1267
+ type BlockerFunction = (args: {
1268
+ currentLocation: Location;
1269
+ nextLocation: Location;
1270
+ historyAction: Action;
1271
+ }) => boolean;
1272
+ declare const IDLE_NAVIGATION: NavigationStates["Idle"];
1273
+ declare const IDLE_FETCHER: FetcherStates["Idle"];
1274
+ declare const IDLE_BLOCKER: BlockerUnblocked;
1275
+ /**
1276
+ * Create a router and listen to history POP navigations
1277
+ */
1278
+ declare function createRouter(init: RouterInit): Router$1;
1279
+ interface CreateStaticHandlerOptions$1 {
1280
+ basename?: string;
1281
+ mapRouteProperties?: MapRoutePropertiesFunction;
1282
+ future?: {};
1283
+ }
1284
+
1285
+ interface IndexRouteObject {
1286
+ caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
1287
+ path?: AgnosticIndexRouteObject["path"];
1288
+ id?: AgnosticIndexRouteObject["id"];
1289
+ unstable_middleware?: AgnosticIndexRouteObject["unstable_middleware"];
1290
+ loader?: AgnosticIndexRouteObject["loader"];
1291
+ action?: AgnosticIndexRouteObject["action"];
1292
+ hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
1293
+ shouldRevalidate?: AgnosticIndexRouteObject["shouldRevalidate"];
1294
+ handle?: AgnosticIndexRouteObject["handle"];
1295
+ index: true;
1296
+ children?: undefined;
1297
+ element?: React.ReactNode | null;
1298
+ hydrateFallbackElement?: React.ReactNode | null;
1299
+ errorElement?: React.ReactNode | null;
1300
+ Component?: React.ComponentType | null;
1301
+ HydrateFallback?: React.ComponentType | null;
1302
+ ErrorBoundary?: React.ComponentType | null;
1303
+ lazy?: LazyRouteDefinition<RouteObject>;
1304
+ }
1305
+ interface NonIndexRouteObject {
1306
+ caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
1307
+ path?: AgnosticNonIndexRouteObject["path"];
1308
+ id?: AgnosticNonIndexRouteObject["id"];
1309
+ unstable_middleware?: AgnosticNonIndexRouteObject["unstable_middleware"];
1310
+ loader?: AgnosticNonIndexRouteObject["loader"];
1311
+ action?: AgnosticNonIndexRouteObject["action"];
1312
+ hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
1313
+ shouldRevalidate?: AgnosticNonIndexRouteObject["shouldRevalidate"];
1314
+ handle?: AgnosticNonIndexRouteObject["handle"];
1315
+ index?: false;
1316
+ children?: RouteObject[];
1317
+ element?: React.ReactNode | null;
1318
+ hydrateFallbackElement?: React.ReactNode | null;
1319
+ errorElement?: React.ReactNode | null;
1320
+ Component?: React.ComponentType | null;
1321
+ HydrateFallback?: React.ComponentType | null;
1322
+ ErrorBoundary?: React.ComponentType | null;
1323
+ lazy?: LazyRouteDefinition<RouteObject>;
1324
+ }
1325
+ type RouteObject = IndexRouteObject | NonIndexRouteObject;
1326
+ type DataRouteObject = RouteObject & {
1327
+ children?: DataRouteObject[];
1328
+ id: string;
1329
+ };
1330
+ interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> extends AgnosticRouteMatch<ParamKey, RouteObjectType> {
1331
+ }
1332
+ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
1333
+ }
1334
+ type PatchRoutesOnNavigationFunctionArgs = AgnosticPatchRoutesOnNavigationFunctionArgs<RouteObject, RouteMatch>;
1335
+ type PatchRoutesOnNavigationFunction = AgnosticPatchRoutesOnNavigationFunction<RouteObject, RouteMatch>;
1336
+ interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
1337
+ router: Router$1;
1338
+ staticContext?: StaticHandlerContext;
1339
+ }
1340
+ declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
1341
+ declare const DataRouterStateContext: React.Context<RouterState | null>;
1342
+ type ViewTransitionContextObject = {
1343
+ isTransitioning: false;
1344
+ } | {
1345
+ isTransitioning: true;
1346
+ flushSync: boolean;
1347
+ currentLocation: Location;
1348
+ nextLocation: Location;
1349
+ };
1350
+ declare const ViewTransitionContext: React.Context<ViewTransitionContextObject>;
1351
+ type FetchersContextObject = Map<string, any>;
1352
+ declare const FetchersContext: React.Context<FetchersContextObject>;
1353
+ interface NavigateOptions {
1354
+ /** Replace the current entry in the history stack instead of pushing a new one */
1355
+ replace?: boolean;
1356
+ /** Adds persistent client side routing state to the next location */
1357
+ state?: any;
1358
+ /** If you are using {@link https://api.reactrouter.com/v7/functions/react_router.ScrollRestoration.html <ScrollRestoration>}, prevent the scroll position from being reset to the top of the window when navigating */
1359
+ preventScrollReset?: boolean;
1360
+ /** Defines the relative path behavior for the link. "route" will use the route hierarchy so ".." will remove all URL segments of the current route pattern while "path" will use the URL path so ".." will remove one URL segment. */
1361
+ relative?: RelativeRoutingType;
1362
+ /** Wraps the initial state update for this navigation in a {@link https://react.dev/reference/react-dom/flushSync ReactDOM.flushSync} call instead of the default {@link https://react.dev/reference/react/startTransition React.startTransition} */
1363
+ flushSync?: boolean;
1364
+ /** Enables a {@link https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API View Transition} for this navigation by wrapping the final state update in `document.startViewTransition()`. If you need to apply specific styles for this view transition, you will also need to leverage the {@link https://api.reactrouter.com/v7/functions/react_router.useViewTransitionState.html useViewTransitionState()} hook. */
1365
+ viewTransition?: boolean;
1366
+ }
1367
+ /**
1368
+ * A Navigator is a "location changer"; it's how you get to different locations.
1369
+ *
1370
+ * Every history instance conforms to the Navigator interface, but the
1371
+ * distinction is useful primarily when it comes to the low-level `<Router>` API
1372
+ * where both the location and a navigator must be provided separately in order
1373
+ * to avoid "tearing" that may occur in a suspense-enabled app if the action
1374
+ * and/or location were to be read directly from the history instance.
1375
+ */
1376
+ interface Navigator {
1377
+ createHref: History["createHref"];
1378
+ encodeLocation?: History["encodeLocation"];
1379
+ go: History["go"];
1380
+ push(to: To, state?: any, opts?: NavigateOptions): void;
1381
+ replace(to: To, state?: any, opts?: NavigateOptions): void;
1382
+ }
1383
+ interface NavigationContextObject {
1384
+ basename: string;
1385
+ navigator: Navigator;
1386
+ static: boolean;
1387
+ future: {};
1388
+ }
1389
+ declare const NavigationContext: React.Context<NavigationContextObject>;
1390
+ interface LocationContextObject {
1391
+ location: Location;
1392
+ navigationType: Action;
1393
+ }
1394
+ declare const LocationContext: React.Context<LocationContextObject>;
1395
+ interface RouteContextObject {
1396
+ outlet: React.ReactElement | null;
1397
+ matches: RouteMatch[];
1398
+ isDataRoute: boolean;
1399
+ }
1400
+ declare const RouteContext: React.Context<RouteContextObject>;
1401
+
8
1402
  /**
9
1403
  * @private
10
1404
  */
@@ -422,6 +1816,16 @@ interface ServerRoute extends Route {
422
1816
  module: ServerRouteModule;
423
1817
  }
424
1818
 
1819
+ /**
1820
+ * An object of unknown type for route loaders and actions provided by the
1821
+ * server's `getLoadContext()` function. This is defined as an empty interface
1822
+ * specifically so apps can leverage declaration merging to augment this type
1823
+ * globally: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
1824
+ */
1825
+ interface AppLoadContext {
1826
+ [key: string]: unknown;
1827
+ }
1828
+
425
1829
  type OptionalCriticalCss = CriticalCss | undefined;
426
1830
  /**
427
1831
  * The output of the compiler for the server build.
@@ -549,6 +1953,313 @@ declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation:
549
1953
  declare function createClientRoutes(manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState | null, ssr: boolean, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, needsRevalidation?: Set<string>): DataRouteObject[];
550
1954
  declare function shouldHydrateRouteLoader(routeId: string, clientLoader: ClientLoaderFunction | undefined, hasLoader: boolean, isSpaMode: boolean): boolean;
551
1955
 
1956
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
1957
+ type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
1958
+ interface HtmlLinkProps {
1959
+ /**
1960
+ * Address of the hyperlink
1961
+ */
1962
+ href?: string;
1963
+ /**
1964
+ * How the element handles crossorigin requests
1965
+ */
1966
+ crossOrigin?: "anonymous" | "use-credentials";
1967
+ /**
1968
+ * Relationship between the document containing the hyperlink and the destination resource
1969
+ */
1970
+ rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
1971
+ /**
1972
+ * Applicable media: "screen", "print", "(max-width: 764px)"
1973
+ */
1974
+ media?: string;
1975
+ /**
1976
+ * Integrity metadata used in Subresource Integrity checks
1977
+ */
1978
+ integrity?: string;
1979
+ /**
1980
+ * Language of the linked resource
1981
+ */
1982
+ hrefLang?: string;
1983
+ /**
1984
+ * Hint for the type of the referenced resource
1985
+ */
1986
+ type?: string;
1987
+ /**
1988
+ * Referrer policy for fetches initiated by the element
1989
+ */
1990
+ referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
1991
+ /**
1992
+ * Sizes of the icons (for rel="icon")
1993
+ */
1994
+ sizes?: string;
1995
+ /**
1996
+ * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
1997
+ */
1998
+ as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
1999
+ /**
2000
+ * Color to use when customizing a site's icon (for rel="mask-icon")
2001
+ */
2002
+ color?: string;
2003
+ /**
2004
+ * Whether the link is disabled
2005
+ */
2006
+ disabled?: boolean;
2007
+ /**
2008
+ * The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
2009
+ */
2010
+ title?: string;
2011
+ /**
2012
+ * Images to use in different situations, e.g., high-resolution displays,
2013
+ * small monitors, etc. (for rel="preload")
2014
+ */
2015
+ imageSrcSet?: string;
2016
+ /**
2017
+ * Image sizes for different page layouts (for rel="preload")
2018
+ */
2019
+ imageSizes?: string;
2020
+ }
2021
+ interface HtmlLinkPreloadImage extends HtmlLinkProps {
2022
+ /**
2023
+ * Relationship between the document containing the hyperlink and the destination resource
2024
+ */
2025
+ rel: "preload";
2026
+ /**
2027
+ * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
2028
+ */
2029
+ as: "image";
2030
+ /**
2031
+ * Address of the hyperlink
2032
+ */
2033
+ href?: string;
2034
+ /**
2035
+ * Images to use in different situations, e.g., high-resolution displays,
2036
+ * small monitors, etc. (for rel="preload")
2037
+ */
2038
+ imageSrcSet: string;
2039
+ /**
2040
+ * Image sizes for different page layouts (for rel="preload")
2041
+ */
2042
+ imageSizes?: string;
2043
+ }
2044
+ /**
2045
+ * Represents a `<link>` element.
2046
+ *
2047
+ * WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
2048
+ */
2049
+ type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
2050
+ imageSizes?: never;
2051
+ });
2052
+ interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
2053
+ /**
2054
+ * The absolute path of the page to prefetch.
2055
+ */
2056
+ page: string;
2057
+ }
2058
+ type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
2059
+
2060
+ interface RouteModules {
2061
+ [routeId: string]: RouteModule | undefined;
2062
+ }
2063
+ /**
2064
+ * The shape of a route module shipped to the client
2065
+ */
2066
+ interface RouteModule {
2067
+ clientAction?: ClientActionFunction;
2068
+ clientLoader?: ClientLoaderFunction;
2069
+ unstable_clientMiddleware?: unstable_MiddlewareFunction<undefined>[];
2070
+ ErrorBoundary?: ErrorBoundaryComponent;
2071
+ HydrateFallback?: HydrateFallbackComponent;
2072
+ Layout?: LayoutComponent;
2073
+ default: RouteComponent;
2074
+ handle?: RouteHandle;
2075
+ links?: LinksFunction;
2076
+ meta?: MetaFunction;
2077
+ shouldRevalidate?: ShouldRevalidateFunction;
2078
+ }
2079
+ /**
2080
+ * The shape of a route module on the server
2081
+ */
2082
+ interface ServerRouteModule extends RouteModule {
2083
+ action?: ActionFunction;
2084
+ headers?: HeadersFunction | {
2085
+ [name: string]: string;
2086
+ };
2087
+ loader?: LoaderFunction;
2088
+ unstable_middleware?: unstable_MiddlewareFunction<Response>[];
2089
+ }
2090
+ /**
2091
+ * A function that handles data mutations for a route on the client
2092
+ */
2093
+ type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<ActionFunction>;
2094
+ /**
2095
+ * Arguments passed to a route `clientAction` function
2096
+ */
2097
+ type ClientActionFunctionArgs = ActionFunctionArgs & {
2098
+ serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
2099
+ };
2100
+ /**
2101
+ * A function that loads data for a route on the client
2102
+ */
2103
+ type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<LoaderFunction>) & {
2104
+ hydrate?: boolean;
2105
+ };
2106
+ /**
2107
+ * Arguments passed to a route `clientLoader` function
2108
+ */
2109
+ type ClientLoaderFunctionArgs = LoaderFunctionArgs & {
2110
+ serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
2111
+ };
2112
+ /**
2113
+ * ErrorBoundary to display for this route
2114
+ */
2115
+ type ErrorBoundaryComponent = ComponentType;
2116
+ type HeadersArgs = {
2117
+ loaderHeaders: Headers;
2118
+ parentHeaders: Headers;
2119
+ actionHeaders: Headers;
2120
+ errorHeaders: Headers | undefined;
2121
+ };
2122
+ /**
2123
+ * A function that returns HTTP headers to be used for a route. These headers
2124
+ * will be merged with (and take precedence over) headers from parent routes.
2125
+ */
2126
+ interface HeadersFunction {
2127
+ (args: HeadersArgs): Headers | HeadersInit;
2128
+ }
2129
+ /**
2130
+ * `<Route HydrateFallback>` component to render on initial loads
2131
+ * when client loaders are present
2132
+ */
2133
+ type HydrateFallbackComponent = ComponentType;
2134
+ /**
2135
+ * Optional, root-only `<Route Layout>` component to wrap the root content in.
2136
+ * Useful for defining the <html>/<head>/<body> document shell shared by the
2137
+ * Component, HydrateFallback, and ErrorBoundary
2138
+ */
2139
+ type LayoutComponent = ComponentType<{
2140
+ children: ReactElement<unknown, ErrorBoundaryComponent | HydrateFallbackComponent | RouteComponent>;
2141
+ }>;
2142
+ /**
2143
+ * A function that defines `<link>` tags to be inserted into the `<head>` of
2144
+ * the document on route transitions.
2145
+ *
2146
+ * @see https://remix.run/route/meta
2147
+ */
2148
+ interface LinksFunction {
2149
+ (): LinkDescriptor[];
2150
+ }
2151
+ interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown> {
2152
+ id: RouteId;
2153
+ pathname: DataRouteMatch["pathname"];
2154
+ data: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
2155
+ handle?: RouteHandle;
2156
+ params: DataRouteMatch["params"];
2157
+ meta: MetaDescriptor[];
2158
+ error?: unknown;
2159
+ }
2160
+ type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{
2161
+ [K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>;
2162
+ }[keyof MatchLoaders]>;
2163
+ interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
2164
+ data: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
2165
+ params: Params;
2166
+ location: Location;
2167
+ matches: MetaMatches<MatchLoaders>;
2168
+ error?: unknown;
2169
+ }
2170
+ /**
2171
+ * A function that returns an array of data objects to use for rendering
2172
+ * metadata HTML tags in a route. These tags are not rendered on descendant
2173
+ * routes in the route hierarchy. In other words, they will only be rendered on
2174
+ * the route in which they are exported.
2175
+ *
2176
+ * @param Loader - The type of the current route's loader function
2177
+ * @param MatchLoaders - Mapping from a parent route's filepath to its loader
2178
+ * function type
2179
+ *
2180
+ * Note that parent route filepaths are relative to the `app/` directory.
2181
+ *
2182
+ * For example, if this meta function is for `/sales/customers/$customerId`:
2183
+ *
2184
+ * ```ts
2185
+ * // app/root.tsx
2186
+ * const loader = () => ({ hello: "world" })
2187
+ * export type Loader = typeof loader
2188
+ *
2189
+ * // app/routes/sales.tsx
2190
+ * const loader = () => ({ salesCount: 1074 })
2191
+ * export type Loader = typeof loader
2192
+ *
2193
+ * // app/routes/sales/customers.tsx
2194
+ * const loader = () => ({ customerCount: 74 })
2195
+ * export type Loader = typeof loader
2196
+ *
2197
+ * // app/routes/sales/customers/$customersId.tsx
2198
+ * import type { Loader as RootLoader } from "../../../root"
2199
+ * import type { Loader as SalesLoader } from "../../sales"
2200
+ * import type { Loader as CustomersLoader } from "../../sales/customers"
2201
+ *
2202
+ * const loader = () => ({ name: "Customer name" })
2203
+ *
2204
+ * const meta: MetaFunction<typeof loader, {
2205
+ * "root": RootLoader,
2206
+ * "routes/sales": SalesLoader,
2207
+ * "routes/sales/customers": CustomersLoader,
2208
+ * }> = ({ data, matches }) => {
2209
+ * const { name } = data
2210
+ * // ^? string
2211
+ * const { customerCount } = matches.find((match) => match.id === "routes/sales/customers").data
2212
+ * // ^? number
2213
+ * const { salesCount } = matches.find((match) => match.id === "routes/sales").data
2214
+ * // ^? number
2215
+ * const { hello } = matches.find((match) => match.id === "root").data
2216
+ * // ^? "world"
2217
+ * }
2218
+ * ```
2219
+ */
2220
+ interface MetaFunction<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
2221
+ (args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
2222
+ }
2223
+ type MetaDescriptor = {
2224
+ charSet: "utf-8";
2225
+ } | {
2226
+ title: string;
2227
+ } | {
2228
+ name: string;
2229
+ content: string;
2230
+ } | {
2231
+ property: string;
2232
+ content: string;
2233
+ } | {
2234
+ httpEquiv: string;
2235
+ content: string;
2236
+ } | {
2237
+ "script:ld+json": LdJsonObject;
2238
+ } | {
2239
+ tagName: "meta" | "link";
2240
+ [name: string]: string;
2241
+ } | {
2242
+ [name: string]: unknown;
2243
+ };
2244
+ type LdJsonObject = {
2245
+ [Key in string]: LdJsonValue;
2246
+ } & {
2247
+ [Key in string]?: LdJsonValue | undefined;
2248
+ };
2249
+ type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
2250
+ type LdJsonPrimitive = string | number | boolean | null;
2251
+ type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
2252
+ /**
2253
+ * A React component that is rendered for a route.
2254
+ */
2255
+ type RouteComponent = ComponentType<{}>;
2256
+ /**
2257
+ * An arbitrary object that is associated with a route.
2258
+ *
2259
+ * @see https://remix.run/route/handle
2260
+ */
2261
+ type RouteHandle = unknown;
2262
+
552
2263
  declare const SingleFetchRedirectSymbol: unique symbol;
553
2264
  declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router$1, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined): DataStrategyFunction;
554
2265
  declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
@@ -565,6 +2276,35 @@ declare enum ServerMode {
565
2276
  Test = "test"
566
2277
  }
567
2278
 
2279
+ type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
2280
+ [key: PropertyKey]: Serializable;
2281
+ } | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
2282
+
2283
+ /**
2284
+ * A brand that can be applied to a type to indicate that it will serialize
2285
+ * to a specific type when transported to the client from a loader.
2286
+ * Only use this if you have additional serialization/deserialization logic
2287
+ * in your application.
2288
+ */
2289
+ type unstable_SerializesTo<T> = {
2290
+ unstable__ReactRouter_SerializesTo: [T];
2291
+ };
2292
+
2293
+ type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
2294
+ type IsAny<T> = 0 extends 1 & T ? true : false;
2295
+ type Func = (...args: any[]) => unknown;
2296
+
2297
+ 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 Set<infer U> ? Set<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> ? {
2298
+ [K in keyof T]: Serialize<T[K]>;
2299
+ } : undefined;
2300
+ type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
2301
+ type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
2302
+ type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? U : T;
2303
+ type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
2304
+ type ServerDataFrom<T> = ServerData<DataFrom<T>>;
2305
+ type ClientDataFrom<T> = ClientData<DataFrom<T>>;
2306
+ type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
2307
+
568
2308
  /**
569
2309
  Resolves a URL against the current location.
570
2310
 
@@ -689,7 +2429,7 @@ declare function useOutlet(context?: unknown): React.ReactElement | null;
689
2429
  */
690
2430
  declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
691
2431
  ParamsOrKey
692
- ] extends [string] ? Params$1<ParamsOrKey> : Partial<ParamsOrKey>>;
2432
+ ] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
693
2433
  /**
694
2434
  Resolves the pathname of the given `to` value against the current location. Similar to {@link useHref}, but returns a {@link Path} instead of a string.
695
2435
 
@@ -2482,16 +4222,26 @@ declare function setDevServerHooks(devServerHooks: DevServerHooks): void;
2482
4222
  */
2483
4223
  interface Register {
2484
4224
  }
4225
+ type AnyParams = Record<string, string | undefined>;
4226
+ type AnyPages = Record<string, {
4227
+ params: AnyParams;
4228
+ }>;
4229
+ type Pages = Register extends {
4230
+ pages: infer Registered extends AnyPages;
4231
+ } ? Registered : AnyPages;
4232
+ type AnyRouteFiles = Record<string, {
4233
+ id: string;
4234
+ page: string;
4235
+ }>;
4236
+ type RouteFiles = Register extends {
4237
+ routeFiles: infer Registered extends AnyRouteFiles;
4238
+ } ? Registered : AnyRouteFiles;
2485
4239
 
2486
- type AnyParams = Record<string, Record<string, string | undefined>>;
2487
- type Params = Register extends {
2488
- params: infer RegisteredParams extends AnyParams;
2489
- } ? RegisteredParams : AnyParams;
2490
4240
  type Args = {
2491
- [K in keyof Params]: ToArgs<Params[K]>;
4241
+ [K in keyof Pages]: ToArgs<Pages[K]["params"]>;
2492
4242
  };
2493
- type ToArgs<T> = Equal<T, {}> extends true ? [] : Partial<T> extends T ? [T] | [] : [
2494
- T
4243
+ type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [
4244
+ Params
2495
4245
  ];
2496
4246
  /**
2497
4247
  Returns a resolved URL path for the specified route.
@@ -2541,4 +4291,4 @@ declare function getHydrationData(state: {
2541
4291
  hasHydrateFallback: boolean;
2542
4292
  }, location: Path, basename: string | undefined, isSpaMode: boolean): HydrationState;
2543
4293
 
2544
- export { ActionFunction, ActionFunctionArgs, AppLoadContext, Await, type AwaitProps, Blocker, BlockerFunction, BrowserRouter, type BrowserRouterProps, ClientLoaderFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, DataRouteObject, Router$1 as DataRouter, DataStrategyFunction, type EntryContext, Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, FormEncType, type FormProps, GetScrollRestorationKeyFunction, HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HistoryRouterProps, HydrationState, IndexRouteObject, type IndexRouteProps, InitialEntry, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, LazyRouteFunction, Link, type LinkProps, Links, LinksFunction, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, MetaFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, NavigateOptions, type NavigateProps, Navigation, Action as NavigationType, Navigator, NonIndexRouteObject, Outlet, type OutletProps, PageLinkDescriptor, type ParamKeyValuePair, ParamParseKey, Params$1 as Params, PatchRoutesOnNavigationFunction, Path, PathMatch, PathPattern, type PathRouteProps, PrefetchPageLinks, type Register, RelativeRoutingType, type RequestHandler, Route$1 as Route, RouteMatch, RouteObject, type RouteProps, Router, RouterInit, type RouterProps, RouterProvider, type RouterProviderProps, RouterState, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, To, UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, FrameworkContext as UNSAFE_FrameworkContext, MiddlewareEnabled as UNSAFE_MiddlewareEnabled, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, mapRouteProperties as UNSAFE_mapRouteProperties, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, type URLSearchParamsInit, createBrowserRouter, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, href, isCookie, isSession, renderMatches, HistoryRouter as unstable_HistoryRouter, unstable_InitialContext, unstable_RouterContextProvider, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
4294
+ export { type ActionFunction, type ActionFunctionArgs, type AppLoadContext, Await, type AwaitProps, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router$1 as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type Pages, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route$1 as Route, type RouteFiles, type RouteMatch, type RouteObject, type RouteProps, Router, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, type MiddlewareEnabled as UNSAFE_MiddlewareEnabled, NavigationContext as UNSAFE_NavigationContext, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, mapRouteProperties as UNSAFE_mapRouteProperties, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, type URLSearchParamsInit, createBrowserRouter, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, HistoryRouter as unstable_HistoryRouter, type unstable_InitialContext, type unstable_MiddlewareFunction, type unstable_RouterContext, unstable_RouterContextProvider, type unstable_SerializesTo, unstable_createContext, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };