react-router 0.0.0-experimental-a65d6f5 → 0.0.0-experimental-c19b79d

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 (65) hide show
  1. package/dist/development/{chunk-ZLVXSGFL.js → chunk-2G2U5HGB.js} +161 -164
  2. package/dist/development/{chunk-CWSJ6RYI.mjs → chunk-AGOH44BE.mjs} +51 -67
  3. package/dist/development/{chunk-47MIYFLC.mjs → chunk-IMKEG5CI.mjs} +29 -309
  4. package/dist/development/{chunk-QOFB7XZ5.js → chunk-LUB73E44.js} +70 -347
  5. package/dist/development/{router-DQIRhYoj.d.mts → context-BqL5Eckq.d.mts} +1288 -1441
  6. package/dist/development/dom-export.d.mts +4 -59
  7. package/dist/development/dom-export.d.ts +3 -59
  8. package/dist/development/dom-export.js +5 -8
  9. package/dist/development/dom-export.mjs +5 -8
  10. package/dist/{production/index-react-server-client-lf74v6ET.d.mts → development/index-react-server-client-2EDmGlsZ.d.mts} +77 -140
  11. package/dist/development/{index-react-server-client-lf74v6ET.d.mts → index-react-server-client-DKvU8YRr.d.ts} +134 -198
  12. package/dist/development/index-react-server-client.d.mts +3 -3
  13. package/dist/development/index-react-server-client.d.ts +2 -3
  14. package/dist/development/index-react-server-client.js +4 -4
  15. package/dist/development/index-react-server-client.mjs +2 -2
  16. package/dist/development/index-react-server.d.mts +1 -106
  17. package/dist/development/index-react-server.d.ts +1 -106
  18. package/dist/development/index-react-server.js +8 -181
  19. package/dist/development/index-react-server.mjs +8 -181
  20. package/dist/development/index.d.mts +20 -13
  21. package/dist/development/index.d.ts +18 -13
  22. package/dist/development/index.js +147 -161
  23. package/dist/development/index.mjs +5 -3
  24. package/dist/development/lib/types/internal.d.mts +3 -3
  25. package/dist/development/lib/types/internal.d.ts +2 -3
  26. package/dist/development/lib/types/internal.js +1 -1
  27. package/dist/development/lib/types/internal.mjs +1 -1
  28. package/dist/development/{register-DiOIlEq5.d.mts → register-BrVEYTED.d.mts} +7 -1
  29. package/dist/{production/register-DiOIlEq5.d.mts → development/register-D8NQoPsO.d.ts} +7 -1
  30. package/dist/development/{routeModules--SgCTStn.d.mts → route-data-CDwqkzPE.d.mts} +147 -157
  31. package/dist/{production/routeModules-rxNxBmdR.d.ts → development/routeModules-BmVo7q9e.d.ts} +1046 -73
  32. package/dist/production/{chunk-ZOHTOBOT.js → chunk-2L5AG5Y5.js} +70 -347
  33. package/dist/production/{chunk-UAAA7FTX.mjs → chunk-AODJW4D3.mjs} +51 -67
  34. package/dist/production/{chunk-4SPSFXAZ.js → chunk-FGRCWJDI.js} +161 -164
  35. package/dist/production/{chunk-MMAHTIVZ.mjs → chunk-UOQCOPF6.mjs} +29 -309
  36. package/dist/production/{router-DQIRhYoj.d.mts → context-BqL5Eckq.d.mts} +1288 -1441
  37. package/dist/production/dom-export.d.mts +4 -59
  38. package/dist/production/dom-export.d.ts +3 -59
  39. package/dist/production/dom-export.js +5 -8
  40. package/dist/production/dom-export.mjs +5 -8
  41. package/dist/{development/index-react-server-client-Iw2PMej2.d.ts → production/index-react-server-client-2EDmGlsZ.d.mts} +77 -140
  42. package/dist/production/{index-react-server-client-Iw2PMej2.d.ts → index-react-server-client-DKvU8YRr.d.ts} +134 -198
  43. package/dist/production/index-react-server-client.d.mts +3 -3
  44. package/dist/production/index-react-server-client.d.ts +2 -3
  45. package/dist/production/index-react-server-client.js +4 -4
  46. package/dist/production/index-react-server-client.mjs +2 -2
  47. package/dist/production/index-react-server.d.mts +1 -106
  48. package/dist/production/index-react-server.d.ts +1 -106
  49. package/dist/production/index-react-server.js +8 -181
  50. package/dist/production/index-react-server.mjs +8 -181
  51. package/dist/production/index.d.mts +20 -13
  52. package/dist/production/index.d.ts +18 -13
  53. package/dist/production/index.js +147 -161
  54. package/dist/production/index.mjs +5 -3
  55. package/dist/production/lib/types/internal.d.mts +3 -3
  56. package/dist/production/lib/types/internal.d.ts +2 -3
  57. package/dist/production/lib/types/internal.js +1 -1
  58. package/dist/production/lib/types/internal.mjs +1 -1
  59. package/dist/{development/register-DiOIlEq5.d.ts → production/register-BrVEYTED.d.mts} +7 -1
  60. package/dist/production/{register-DiOIlEq5.d.ts → register-D8NQoPsO.d.ts} +7 -1
  61. package/dist/production/{routeModules--SgCTStn.d.mts → route-data-CDwqkzPE.d.mts} +147 -157
  62. package/dist/{development/routeModules-rxNxBmdR.d.ts → production/routeModules-BmVo7q9e.d.ts} +1046 -73
  63. package/package.json +1 -1
  64. package/dist/development/instrumentation-BWRz1MRU.d.ts +0 -1138
  65. package/dist/production/instrumentation-BWRz1MRU.d.ts +0 -1138
@@ -1,1138 +0,0 @@
1
- /**
2
- * An augmentable interface users can modify in their app-code to opt into
3
- * future-flag-specific types
4
- */
5
- interface Future {
6
- }
7
- type MiddlewareEnabled = Future extends {
8
- v8_middleware: infer T extends boolean;
9
- } ? T : false;
10
-
11
- /**
12
- * Actions represent the type of change to a location value.
13
- */
14
- declare enum Action {
15
- /**
16
- * A POP indicates a change to an arbitrary index in the history stack, such
17
- * as a back or forward navigation. It does not describe the direction of the
18
- * navigation, only that the current index changed.
19
- *
20
- * Note: This is the default action for newly created history objects.
21
- */
22
- Pop = "POP",
23
- /**
24
- * A PUSH indicates a new entry being added to the history stack, such as when
25
- * a link is clicked and a new page loads. When this happens, all subsequent
26
- * entries in the stack are lost.
27
- */
28
- Push = "PUSH",
29
- /**
30
- * A REPLACE indicates the entry at the current index in the history stack
31
- * being replaced by a new one.
32
- */
33
- Replace = "REPLACE"
34
- }
35
- /**
36
- * The pathname, search, and hash values of a URL.
37
- */
38
- interface Path {
39
- /**
40
- * A URL pathname, beginning with a /.
41
- */
42
- pathname: string;
43
- /**
44
- * A URL search string, beginning with a ?.
45
- */
46
- search: string;
47
- /**
48
- * A URL fragment identifier, beginning with a #.
49
- */
50
- hash: string;
51
- }
52
- /**
53
- * An entry in a history stack. A location contains information about the
54
- * URL path, as well as possibly some arbitrary state and a key.
55
- */
56
- interface Location<State = any> extends Path {
57
- /**
58
- * A value of arbitrary data associated with this location.
59
- */
60
- state: State;
61
- /**
62
- * A unique string associated with this location. May be used to safely store
63
- * and retrieve data in some other storage API, like `localStorage`.
64
- *
65
- * Note: This value is always "default" on the initial location.
66
- */
67
- key: string;
68
- }
69
- /**
70
- * A change to the current location.
71
- */
72
- interface Update {
73
- /**
74
- * The action that triggered the change.
75
- */
76
- action: Action;
77
- /**
78
- * The new location.
79
- */
80
- location: Location;
81
- /**
82
- * The delta between this location and the former location in the history stack
83
- */
84
- delta: number | null;
85
- }
86
- /**
87
- * A function that receives notifications about location changes.
88
- */
89
- interface Listener {
90
- (update: Update): void;
91
- }
92
- /**
93
- * Describes a location that is the destination of some navigation used in
94
- * {@link Link}, {@link useNavigate}, etc.
95
- */
96
- type To = string | Partial<Path>;
97
- /**
98
- * A history is an interface to the navigation stack. The history serves as the
99
- * source of truth for the current location, as well as provides a set of
100
- * methods that may be used to change it.
101
- *
102
- * It is similar to the DOM's `window.history` object, but with a smaller, more
103
- * focused API.
104
- */
105
- interface History {
106
- /**
107
- * The last action that modified the current location. This will always be
108
- * Action.Pop when a history instance is first created. This value is mutable.
109
- */
110
- readonly action: Action;
111
- /**
112
- * The current location. This value is mutable.
113
- */
114
- readonly location: Location;
115
- /**
116
- * Returns a valid href for the given `to` value that may be used as
117
- * the value of an <a href> attribute.
118
- *
119
- * @param to - The destination URL
120
- */
121
- createHref(to: To): string;
122
- /**
123
- * Returns a URL for the given `to` value
124
- *
125
- * @param to - The destination URL
126
- */
127
- createURL(to: To): URL;
128
- /**
129
- * Encode a location the same way window.history would do (no-op for memory
130
- * history) so we ensure our PUSH/REPLACE navigations for data routers
131
- * behave the same as POP
132
- *
133
- * @param to Unencoded path
134
- */
135
- encodeLocation(to: To): Path;
136
- /**
137
- * Pushes a new location onto the history stack, increasing its length by one.
138
- * If there were any entries in the stack after the current one, they are
139
- * lost.
140
- *
141
- * @param to - The new URL
142
- * @param state - Data to associate with the new location
143
- */
144
- push(to: To, state?: any): void;
145
- /**
146
- * Replaces the current location in the history stack with a new one. The
147
- * location that was replaced will no longer be available.
148
- *
149
- * @param to - The new URL
150
- * @param state - Data to associate with the new location
151
- */
152
- replace(to: To, state?: any): void;
153
- /**
154
- * Navigates `n` entries backward/forward in the history stack relative to the
155
- * current index. For example, a "back" navigation would use go(-1).
156
- *
157
- * @param delta - The delta in the stack index
158
- */
159
- go(delta: number): void;
160
- /**
161
- * Sets up a listener that will be called whenever the current location
162
- * changes.
163
- *
164
- * @param listener - A function that will be called when the location changes
165
- * @returns unlisten - A function that may be used to stop listening
166
- */
167
- listen(listener: Listener): () => void;
168
- }
169
- /**
170
- * A user-supplied object that describes a location. Used when providing
171
- * entries to `createMemoryHistory` via its `initialEntries` option.
172
- */
173
- type InitialEntry = string | Partial<Location>;
174
- /**
175
- * A browser history stores the current location in regular URLs in a web
176
- * browser environment. This is the standard for most web apps and provides the
177
- * cleanest URLs the browser's address bar.
178
- *
179
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory
180
- */
181
- interface BrowserHistory extends UrlHistory {
182
- }
183
- type BrowserHistoryOptions = UrlHistoryOptions;
184
- /**
185
- * Browser history stores the location in regular URLs. This is the standard for
186
- * most web apps, but it requires some configuration on the server to ensure you
187
- * serve the same app at multiple URLs.
188
- *
189
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
190
- */
191
- declare function createBrowserHistory(options?: BrowserHistoryOptions): BrowserHistory;
192
- /**
193
- * @private
194
- */
195
- declare function invariant(value: boolean, message?: string): asserts value;
196
- declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
197
- /**
198
- * Creates a string URL path from the given pathname, search, and hash components.
199
- *
200
- * @category Utils
201
- */
202
- declare function createPath({ pathname, search, hash, }: Partial<Path>): string;
203
- /**
204
- * Parses a string URL path into its separate pathname, search, and hash components.
205
- *
206
- * @category Utils
207
- */
208
- declare function parsePath(path: string): Partial<Path>;
209
- interface UrlHistory extends History {
210
- }
211
- type UrlHistoryOptions = {
212
- window?: Window;
213
- v5Compat?: boolean;
214
- };
215
-
216
- type MaybePromise<T> = T | Promise<T>;
217
- /**
218
- * Map of routeId -> data returned from a loader/action/error
219
- */
220
- interface RouteData {
221
- [routeId: string]: any;
222
- }
223
- type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
224
- type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
225
- /**
226
- * Users can specify either lowercase or uppercase form methods on `<Form>`,
227
- * useSubmit(), `<fetcher.Form>`, etc.
228
- */
229
- type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;
230
- /**
231
- * Active navigation/fetcher form methods are exposed in uppercase on the
232
- * RouterState. This is to align with the normalization done via fetch().
233
- */
234
- type FormMethod = UpperCaseFormMethod;
235
- type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
236
- type JsonObject = {
237
- [Key in string]: JsonValue;
238
- } & {
239
- [Key in string]?: JsonValue | undefined;
240
- };
241
- type JsonArray = JsonValue[] | readonly JsonValue[];
242
- type JsonPrimitive = string | number | boolean | null;
243
- type JsonValue = JsonPrimitive | JsonObject | JsonArray;
244
- /**
245
- * @private
246
- * Internal interface to pass around for action submissions, not intended for
247
- * external consumption
248
- */
249
- type Submission = {
250
- formMethod: FormMethod;
251
- formAction: string;
252
- formEncType: FormEncType;
253
- formData: FormData;
254
- json: undefined;
255
- text: undefined;
256
- } | {
257
- formMethod: FormMethod;
258
- formAction: string;
259
- formEncType: FormEncType;
260
- formData: undefined;
261
- json: JsonValue;
262
- text: undefined;
263
- } | {
264
- formMethod: FormMethod;
265
- formAction: string;
266
- formEncType: FormEncType;
267
- formData: undefined;
268
- json: undefined;
269
- text: string;
270
- };
271
- /**
272
- * A context instance used as the key for the `get`/`set` methods of a
273
- * {@link RouterContextProvider}. Accepts an optional default
274
- * value to be returned if no value has been set.
275
- */
276
- interface RouterContext<T = unknown> {
277
- defaultValue?: T;
278
- }
279
- /**
280
- * Creates a type-safe {@link RouterContext} object that can be used to
281
- * store and retrieve arbitrary values in [`action`](../../start/framework/route-module#action)s,
282
- * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
283
- * Similar to React's [`createContext`](https://react.dev/reference/react/createContext),
284
- * but specifically designed for React Router's request/response lifecycle.
285
- *
286
- * If a `defaultValue` is provided, it will be returned from `context.get()`
287
- * when no value has been set for the context. Otherwise, reading this context
288
- * when no value has been set will throw an error.
289
- *
290
- * ```tsx filename=app/context.ts
291
- * import { createContext } from "react-router";
292
- *
293
- * // Create a context for user data
294
- * export const userContext =
295
- * createContext<User | null>(null);
296
- * ```
297
- *
298
- * ```tsx filename=app/middleware/auth.ts
299
- * import { getUserFromSession } from "~/auth.server";
300
- * import { userContext } from "~/context";
301
- *
302
- * export const authMiddleware = async ({
303
- * context,
304
- * request,
305
- * }) => {
306
- * const user = await getUserFromSession(request);
307
- * context.set(userContext, user);
308
- * };
309
- * ```
310
- *
311
- * ```tsx filename=app/routes/profile.tsx
312
- * import { userContext } from "~/context";
313
- *
314
- * export async function loader({
315
- * context,
316
- * }: Route.LoaderArgs) {
317
- * const user = context.get(userContext);
318
- *
319
- * if (!user) {
320
- * throw new Response("Unauthorized", { status: 401 });
321
- * }
322
- *
323
- * return { user };
324
- * }
325
- * ```
326
- *
327
- * @public
328
- * @category Utils
329
- * @mode framework
330
- * @mode data
331
- * @param defaultValue An optional default value for the context. This value
332
- * will be returned if no value has been set for this context.
333
- * @returns A {@link RouterContext} object that can be used with
334
- * `context.get()` and `context.set()` in [`action`](../../start/framework/route-module#action)s,
335
- * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
336
- */
337
- declare function createContext<T>(defaultValue?: T): RouterContext<T>;
338
- /**
339
- * Provides methods for writing/reading values in application context in a
340
- * type-safe way. Primarily for usage with [middleware](../../how-to/middleware).
341
- *
342
- * @example
343
- * import {
344
- * createContext,
345
- * RouterContextProvider
346
- * } from "react-router";
347
- *
348
- * const userContext = createContext<User | null>(null);
349
- * const contextProvider = new RouterContextProvider();
350
- * contextProvider.set(userContext, getUser());
351
- * // ^ Type-safe
352
- * const user = contextProvider.get(userContext);
353
- * // ^ User
354
- *
355
- * @public
356
- * @category Utils
357
- * @mode framework
358
- * @mode data
359
- */
360
- declare class RouterContextProvider {
361
- #private;
362
- /**
363
- * Create a new `RouterContextProvider` instance
364
- * @param init An optional initial context map to populate the provider with
365
- */
366
- constructor(init?: Map<RouterContext, unknown>);
367
- /**
368
- * Access a value from the context. If no value has been set for the context,
369
- * it will return the context's `defaultValue` if provided, or throw an error
370
- * if no `defaultValue` was set.
371
- * @param context The context to get the value for
372
- * @returns The value for the context, or the context's `defaultValue` if no
373
- * value was set
374
- */
375
- get<T>(context: RouterContext<T>): T;
376
- /**
377
- * Set a value for the context. If the context already has a value set, this
378
- * will overwrite it.
379
- *
380
- * @param context The context to set the value for
381
- * @param value The value to set for the context
382
- * @returns {void}
383
- */
384
- set<C extends RouterContext>(context: C, value: C extends RouterContext<infer T> ? T : never): void;
385
- }
386
- type DefaultContext = MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : any;
387
- /**
388
- * @private
389
- * Arguments passed to route loader/action functions. Same for now but we keep
390
- * this as a private implementation detail in case they diverge in the future.
391
- */
392
- interface DataFunctionArgs<Context> {
393
- /** 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. */
394
- request: Request;
395
- /**
396
- * Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
397
- * Mostly useful as a identifier to aggregate on for logging/tracing/etc.
398
- */
399
- unstable_pattern: string;
400
- /**
401
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
402
- * @example
403
- * // app/routes.ts
404
- * route("teams/:teamId", "./team.tsx"),
405
- *
406
- * // app/team.tsx
407
- * export function loader({
408
- * params,
409
- * }: Route.LoaderArgs) {
410
- * params.teamId;
411
- * // ^ string
412
- * }
413
- */
414
- params: Params;
415
- /**
416
- * This is the context passed in to your server adapter's getLoadContext() function.
417
- * It's a way to bridge the gap between the adapter's request/response API with your React Router app.
418
- * It is only applicable if you are using a custom server adapter.
419
- */
420
- context: Context;
421
- }
422
- /**
423
- * Route middleware `next` function to call downstream handlers and then complete
424
- * middlewares from the bottom-up
425
- */
426
- interface MiddlewareNextFunction<Result = unknown> {
427
- (): Promise<Result>;
428
- }
429
- /**
430
- * Route middleware function signature. Receives the same "data" arguments as a
431
- * `loader`/`action` (`request`, `params`, `context`) as the first parameter and
432
- * a `next` function as the second parameter which will call downstream handlers
433
- * and then complete middlewares from the bottom-up
434
- */
435
- type MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<RouterContextProvider>>, next: MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
436
- /**
437
- * Arguments passed to loader functions
438
- */
439
- interface LoaderFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
440
- }
441
- /**
442
- * Arguments passed to action functions
443
- */
444
- interface ActionFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
445
- }
446
- /**
447
- * Loaders and actions can return anything
448
- */
449
- type DataFunctionValue = unknown;
450
- type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
451
- /**
452
- * Route loader function signature
453
- */
454
- type LoaderFunction<Context = DefaultContext> = {
455
- (args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
456
- } & {
457
- hydrate?: boolean;
458
- };
459
- /**
460
- * Route action function signature
461
- */
462
- interface ActionFunction<Context = DefaultContext> {
463
- (args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
464
- }
465
- /**
466
- * Arguments passed to shouldRevalidate function
467
- */
468
- interface ShouldRevalidateFunctionArgs {
469
- /** 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. */
470
- currentUrl: URL;
471
- /** 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. */
472
- currentParams: AgnosticDataRouteMatch["params"];
473
- /** 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. */
474
- nextUrl: URL;
475
- /** 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. */
476
- nextParams: AgnosticDataRouteMatch["params"];
477
- /** The method (probably `"GET"` or `"POST"`) used in the form submission that triggered the revalidation. */
478
- formMethod?: Submission["formMethod"];
479
- /** The form action (`<Form action="/somewhere">`) that triggered the revalidation. */
480
- formAction?: Submission["formAction"];
481
- /** The form encType (`<Form encType="application/x-www-form-urlencoded">) used in the form submission that triggered the revalidation*/
482
- formEncType?: Submission["formEncType"];
483
- /** The form submission data when the form's encType is `text/plain` */
484
- text?: Submission["text"];
485
- /** The form submission data when the form's encType is `application/x-www-form-urlencoded` or `multipart/form-data` */
486
- formData?: Submission["formData"];
487
- /** The form submission data when the form's encType is `application/json` */
488
- json?: Submission["json"];
489
- /** The status code of the action response */
490
- actionStatus?: number;
491
- /**
492
- * 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.
493
- *
494
- * @example
495
- * export async function action() {
496
- * await saveSomeStuff();
497
- * return { ok: true };
498
- * }
499
- *
500
- * export function shouldRevalidate({
501
- * actionResult,
502
- * }) {
503
- * if (actionResult?.ok) {
504
- * return false;
505
- * }
506
- * return true;
507
- * }
508
- */
509
- actionResult?: any;
510
- /**
511
- * 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:
512
- *
513
- * /projects/123/tasks/abc
514
- * /projects/123/tasks/def
515
- * React Router will only call the loader for tasks/def because the param for projects/123 didn't change.
516
- *
517
- * 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.
518
- */
519
- defaultShouldRevalidate: boolean;
520
- }
521
- /**
522
- * Route shouldRevalidate function signature. This runs after any submission
523
- * (navigation or fetcher), so we flatten the navigation/fetcher submission
524
- * onto the arguments. It shouldn't matter whether it came from a navigation
525
- * or a fetcher, what really matters is the URLs and the formData since loaders
526
- * have to re-run based on the data models that were potentially mutated.
527
- */
528
- interface ShouldRevalidateFunction {
529
- (args: ShouldRevalidateFunctionArgs): boolean;
530
- }
531
- interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
532
- /**
533
- * @private
534
- */
535
- _lazyPromises?: {
536
- middleware: Promise<void> | undefined;
537
- handler: Promise<void> | undefined;
538
- route: Promise<void> | undefined;
539
- };
540
- /**
541
- * A boolean value indicating whether this route handler should be called in
542
- * this pass.
543
- *
544
- * The `matches` array always includes _all_ matched routes even when only
545
- * _some_ route handlers need to be called so that things like middleware can
546
- * be implemented.
547
- *
548
- * `shouldLoad` is usually only interesting if you are skipping the route
549
- * handler entirely and implementing custom handler logic - since it lets you
550
- * determine if that custom logic should run for this route or not.
551
- *
552
- * For example:
553
- * - If you are on `/parent/child/a` and you navigate to `/parent/child/b` -
554
- * you'll get an array of three matches (`[parent, child, b]`), but only `b`
555
- * will have `shouldLoad=true` because the data for `parent` and `child` is
556
- * already loaded
557
- * - If you are on `/parent/child/a` and you submit to `a`'s [`action`](https://reactrouter.com/docs/start/data/route-object#action),
558
- * then only `a` will have `shouldLoad=true` for the action execution of
559
- * `dataStrategy`
560
- * - After the [`action`](https://reactrouter.com/docs/start/data/route-object#action),
561
- * `dataStrategy` will be called again for the [`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
562
- * revalidation, and all matches will have `shouldLoad=true` (assuming no
563
- * custom `shouldRevalidate` implementations)
564
- */
565
- shouldLoad: boolean;
566
- unstable_shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
567
- unstable_shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
568
- /**
569
- * An async function that will resolve any `route.lazy` implementations and
570
- * execute the route's handler (if necessary), returning a {@link DataStrategyResult}
571
- *
572
- * - Calling `match.resolve` does not mean you're calling the
573
- * [`action`](https://reactrouter.com/docs/start/data/route-object#action)/[`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
574
- * (the "handler") - `resolve` will only call the `handler` internally if
575
- * needed _and_ if you don't pass your own `handlerOverride` function parameter
576
- * - It is safe to call `match.resolve` for all matches, even if they have
577
- * `shouldLoad=false`, and it will no-op if no loading is required
578
- * - You should generally always call `match.resolve()` for `shouldLoad:true`
579
- * routes to ensure that any `route.lazy` implementations are processed
580
- * - See the examples below for how to implement custom handler execution via
581
- * `match.resolve`
582
- */
583
- resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
584
- }
585
- interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
586
- /**
587
- * Matches for this route extended with Data strategy APIs
588
- */
589
- matches: DataStrategyMatch[];
590
- runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
591
- /**
592
- * The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
593
- * for navigational executions
594
- */
595
- fetcherKey: string | null;
596
- }
597
- /**
598
- * Result from a loader or action called via dataStrategy
599
- */
600
- interface DataStrategyResult {
601
- type: "data" | "error";
602
- result: unknown;
603
- }
604
- interface DataStrategyFunction<Context = DefaultContext> {
605
- (args: DataStrategyFunctionArgs<Context>): Promise<Record<string, DataStrategyResult>>;
606
- }
607
- type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = {
608
- signal: AbortSignal;
609
- path: string;
610
- matches: M[];
611
- fetcherKey: string | undefined;
612
- patch: (routeId: string | null, children: O[]) => void;
613
- };
614
- type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => MaybePromise<void>;
615
- /**
616
- * Function provided by the framework-aware layers to set any framework-specific
617
- * properties from framework-agnostic properties
618
- */
619
- interface MapRoutePropertiesFunction {
620
- (route: AgnosticDataRouteObject): {
621
- hasErrorBoundary: boolean;
622
- } & Record<string, any>;
623
- }
624
- /**
625
- * Keys we cannot change from within a lazy object. We spread all other keys
626
- * onto the route. Either they're meaningful to the router, or they'll get
627
- * ignored.
628
- */
629
- type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
630
- /**
631
- * Keys we cannot change from within a lazy() function. We spread all other keys
632
- * onto the route. Either they're meaningful to the router, or they'll get
633
- * ignored.
634
- */
635
- type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "middleware";
636
- /**
637
- * lazy object to load route properties, which can add non-matching
638
- * related properties to a route
639
- */
640
- type LazyRouteObject<R extends AgnosticRouteObject> = {
641
- [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined>;
642
- };
643
- /**
644
- * lazy() function to load a route definition, which can add non-matching
645
- * related properties to a route
646
- */
647
- interface LazyRouteFunction<R extends AgnosticRouteObject> {
648
- (): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
649
- }
650
- type LazyRouteDefinition<R extends AgnosticRouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
651
- /**
652
- * Base RouteObject with common props shared by all types of routes
653
- */
654
- type AgnosticBaseRouteObject = {
655
- caseSensitive?: boolean;
656
- path?: string;
657
- id?: string;
658
- middleware?: MiddlewareFunction[];
659
- loader?: LoaderFunction | boolean;
660
- action?: ActionFunction | boolean;
661
- hasErrorBoundary?: boolean;
662
- shouldRevalidate?: ShouldRevalidateFunction;
663
- handle?: any;
664
- lazy?: LazyRouteDefinition<AgnosticBaseRouteObject>;
665
- };
666
- /**
667
- * Index routes must not have children
668
- */
669
- type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
670
- children?: undefined;
671
- index: true;
672
- };
673
- /**
674
- * Non-index routes may have children, but cannot have index
675
- */
676
- type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
677
- children?: AgnosticRouteObject[];
678
- index?: false;
679
- };
680
- /**
681
- * A route object represents a logical route, with (optionally) its child
682
- * routes organized in a tree-like structure.
683
- */
684
- type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
685
- type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
686
- id: string;
687
- };
688
- type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
689
- children?: AgnosticDataRouteObject[];
690
- id: string;
691
- };
692
- /**
693
- * A data route object, which is just a RouteObject with a required unique ID
694
- */
695
- type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
696
- type RouteManifest<R = AgnosticDataRouteObject> = Record<string, R | undefined>;
697
- 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";
698
- 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";
699
- type Regex_09 = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
700
- type Regex_w = Regex_az | Regez_AZ | Regex_09 | "_";
701
- type ParamChar = Regex_w | "-";
702
- 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;
703
- 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;
704
- type PathParam<Path extends string> = Path extends "*" | "/*" ? "*" : Path extends `${infer Rest}/*` ? "*" | _PathParam<Rest> : _PathParam<Path>;
705
- type ParamParseKey<Segment extends string> = [
706
- PathParam<Segment>
707
- ] extends [never] ? string : PathParam<Segment>;
708
- /**
709
- * The parameters that were parsed from the URL path.
710
- */
711
- type Params<Key extends string = string> = {
712
- readonly [key in Key]: string | undefined;
713
- };
714
- /**
715
- * A RouteMatch contains info about how a route matched a URL.
716
- */
717
- interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
718
- /**
719
- * The names and values of dynamic parameters in the URL.
720
- */
721
- params: Params<ParamKey>;
722
- /**
723
- * The portion of the URL pathname that was matched.
724
- */
725
- pathname: string;
726
- /**
727
- * The portion of the URL pathname that was matched before child routes.
728
- */
729
- pathnameBase: string;
730
- /**
731
- * The route object that was used to match.
732
- */
733
- route: RouteObjectType;
734
- }
735
- interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
736
- }
737
- /**
738
- * Matches the given routes to a location and returns the match data.
739
- *
740
- * @example
741
- * import { matchRoutes } from "react-router";
742
- *
743
- * let routes = [{
744
- * path: "/",
745
- * Component: Root,
746
- * children: [{
747
- * path: "dashboard",
748
- * Component: Dashboard,
749
- * }]
750
- * }];
751
- *
752
- * matchRoutes(routes, "/dashboard"); // [rootMatch, dashboardMatch]
753
- *
754
- * @public
755
- * @category Utils
756
- * @param routes The array of route objects to match against.
757
- * @param locationArg The location to match against, either a string path or a
758
- * partial {@link Location} object
759
- * @param basename Optional base path to strip from the location before matching.
760
- * Defaults to `/`.
761
- * @returns An array of matched routes, or `null` if no matches were found.
762
- */
763
- declare function matchRoutes<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): AgnosticRouteMatch<string, RouteObjectType>[] | null;
764
- interface UIMatch<Data = unknown, Handle = unknown> {
765
- id: string;
766
- pathname: string;
767
- /**
768
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
769
- */
770
- params: AgnosticRouteMatch["params"];
771
- /**
772
- * The return value from the matched route's loader or clientLoader. This might
773
- * be `undefined` if this route's `loader` (or a deeper route's `loader`) threw
774
- * an error and we're currently displaying an `ErrorBoundary`.
775
- *
776
- * @deprecated Use `UIMatch.loaderData` instead
777
- */
778
- data: Data | undefined;
779
- /**
780
- * The return value from the matched route's loader or clientLoader. This might
781
- * be `undefined` if this route's `loader` (or a deeper route's `loader`) threw
782
- * an error and we're currently displaying an `ErrorBoundary`.
783
- */
784
- loaderData: Data | undefined;
785
- /**
786
- * The {@link https://reactrouter.com/start/framework/route-module#handle handle object}
787
- * exported from the matched route module
788
- */
789
- handle: Handle;
790
- }
791
- /**
792
- * Returns a path with params interpolated.
793
- *
794
- * @example
795
- * import { generatePath } from "react-router";
796
- *
797
- * generatePath("/users/:id", { id: "123" }); // "/users/123"
798
- *
799
- * @public
800
- * @category Utils
801
- * @param originalPath The original path to generate.
802
- * @param params The parameters to interpolate into the path.
803
- * @returns The generated path with parameters interpolated.
804
- */
805
- declare function generatePath<Path extends string>(originalPath: Path, params?: {
806
- [key in PathParam<Path>]: string | null;
807
- }): string;
808
- /**
809
- * Used to match on some portion of a URL pathname.
810
- */
811
- interface PathPattern<Path extends string = string> {
812
- /**
813
- * A string to match against a URL pathname. May contain `:id`-style segments
814
- * to indicate placeholders for dynamic parameters. It May also end with `/*`
815
- * to indicate matching the rest of the URL pathname.
816
- */
817
- path: Path;
818
- /**
819
- * Should be `true` if the static portions of the `path` should be matched in
820
- * the same case.
821
- */
822
- caseSensitive?: boolean;
823
- /**
824
- * Should be `true` if this pattern should match the entire URL pathname.
825
- */
826
- end?: boolean;
827
- }
828
- /**
829
- * Contains info about how a {@link PathPattern} matched on a URL pathname.
830
- */
831
- interface PathMatch<ParamKey extends string = string> {
832
- /**
833
- * The names and values of dynamic parameters in the URL.
834
- */
835
- params: Params<ParamKey>;
836
- /**
837
- * The portion of the URL pathname that was matched.
838
- */
839
- pathname: string;
840
- /**
841
- * The portion of the URL pathname that was matched before child routes.
842
- */
843
- pathnameBase: string;
844
- /**
845
- * The pattern that was used to match.
846
- */
847
- pattern: PathPattern;
848
- }
849
- /**
850
- * Performs pattern matching on a URL pathname and returns information about
851
- * the match.
852
- *
853
- * @public
854
- * @category Utils
855
- * @param pattern The pattern to match against the URL pathname. This can be a
856
- * string or a {@link PathPattern} object. If a string is provided, it will be
857
- * treated as a pattern with `caseSensitive` set to `false` and `end` set to
858
- * `true`.
859
- * @param pathname The URL pathname to match against the pattern.
860
- * @returns A path match object if the pattern matches the pathname,
861
- * or `null` if it does not match.
862
- */
863
- declare function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamKey> | null;
864
- /**
865
- * Returns a resolved {@link Path} object relative to the given pathname.
866
- *
867
- * @public
868
- * @category Utils
869
- * @param to The path to resolve, either a string or a partial {@link Path}
870
- * object.
871
- * @param fromPathname The pathname to resolve the path from. Defaults to `/`.
872
- * @returns A {@link Path} object with the resolved pathname, search, and hash.
873
- */
874
- declare function resolvePath(to: To, fromPathname?: string): Path;
875
- declare class DataWithResponseInit<D> {
876
- type: string;
877
- data: D;
878
- init: ResponseInit | null;
879
- constructor(data: D, init?: ResponseInit);
880
- }
881
- /**
882
- * Create "responses" that contain `headers`/`status` without forcing
883
- * serialization into an actual [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
884
- *
885
- * @example
886
- * import { data } from "react-router";
887
- *
888
- * export async function action({ request }: Route.ActionArgs) {
889
- * let formData = await request.formData();
890
- * let item = await createItem(formData);
891
- * return data(item, {
892
- * headers: { "X-Custom-Header": "value" }
893
- * status: 201,
894
- * });
895
- * }
896
- *
897
- * @public
898
- * @category Utils
899
- * @mode framework
900
- * @mode data
901
- * @param data The data to be included in the response.
902
- * @param init The status code or a `ResponseInit` object to be included in the
903
- * response.
904
- * @returns A {@link DataWithResponseInit} instance containing the data and
905
- * response init.
906
- */
907
- declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
908
- interface TrackedPromise extends Promise<any> {
909
- _tracked?: boolean;
910
- _data?: any;
911
- _error?: any;
912
- }
913
- type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
914
- /**
915
- * A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
916
- * Sets the status code and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
917
- * header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
918
- *
919
- * @example
920
- * import { redirect } from "react-router";
921
- *
922
- * export async function loader({ request }: Route.LoaderArgs) {
923
- * if (!isLoggedIn(request))
924
- * throw redirect("/login");
925
- * }
926
- *
927
- * // ...
928
- * }
929
- *
930
- * @public
931
- * @category Utils
932
- * @mode framework
933
- * @mode data
934
- * @param url The URL to redirect to.
935
- * @param init The status code or a `ResponseInit` object to be included in the
936
- * response.
937
- * @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
938
- * object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
939
- * header.
940
- */
941
- declare const redirect: RedirectFunction;
942
- /**
943
- * A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
944
- * that will force a document reload to the new location. Sets the status code
945
- * and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
946
- * header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
947
- *
948
- * ```tsx filename=routes/logout.tsx
949
- * import { redirectDocument } from "react-router";
950
- *
951
- * import { destroySession } from "../sessions.server";
952
- *
953
- * export async function action({ request }: Route.ActionArgs) {
954
- * let session = await getSession(request.headers.get("Cookie"));
955
- * return redirectDocument("/", {
956
- * headers: { "Set-Cookie": await destroySession(session) }
957
- * });
958
- * }
959
- * ```
960
- *
961
- * @public
962
- * @category Utils
963
- * @mode framework
964
- * @mode data
965
- * @param url The URL to redirect to.
966
- * @param init The status code or a `ResponseInit` object to be included in the
967
- * response.
968
- * @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
969
- * object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
970
- * header.
971
- */
972
- declare const redirectDocument: RedirectFunction;
973
- /**
974
- * A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
975
- * that will perform a [`history.replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState)
976
- * instead of a [`history.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState)
977
- * for client-side navigation redirects. Sets the status code and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
978
- * header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
979
- *
980
- * @example
981
- * import { replace } from "react-router";
982
- *
983
- * export async function loader() {
984
- * return replace("/new-location");
985
- * }
986
- *
987
- * @public
988
- * @category Utils
989
- * @mode framework
990
- * @mode data
991
- * @param url The URL to redirect to.
992
- * @param init The status code or a `ResponseInit` object to be included in the
993
- * response.
994
- * @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
995
- * object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
996
- * header.
997
- */
998
- declare const replace: RedirectFunction;
999
- type ErrorResponse = {
1000
- status: number;
1001
- statusText: string;
1002
- data: any;
1003
- };
1004
- declare class ErrorResponseImpl implements ErrorResponse {
1005
- status: number;
1006
- statusText: string;
1007
- data: any;
1008
- private error?;
1009
- private internal;
1010
- constructor(status: number, statusText: string | undefined, data: any, internal?: boolean);
1011
- }
1012
- /**
1013
- * Check if the given error is an {@link ErrorResponse} generated from a 4xx/5xx
1014
- * [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
1015
- * thrown from an [`action`](../../start/framework/route-module#action)/[`loader`](../../start/framework/route-module#loader)
1016
- *
1017
- * @example
1018
- * import { isRouteErrorResponse } from "react-router";
1019
- *
1020
- * export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
1021
- * if (isRouteErrorResponse(error)) {
1022
- * return (
1023
- * <>
1024
- * <p>Error: `${error.status}: ${error.statusText}`</p>
1025
- * <p>{error.data}</p>
1026
- * </>
1027
- * );
1028
- * }
1029
- *
1030
- * return (
1031
- * <p>Error: {error instanceof Error ? error.message : "Unknown Error"}</p>
1032
- * );
1033
- * }
1034
- *
1035
- * @public
1036
- * @category Utils
1037
- * @mode framework
1038
- * @mode data
1039
- * @param error The error to check.
1040
- * @returns `true` if the error is an {@link ErrorResponse}, `false` otherwise.
1041
- *
1042
- */
1043
- declare function isRouteErrorResponse(error: any): error is ErrorResponse;
1044
-
1045
- type unstable_ServerInstrumentation = {
1046
- handler?: unstable_InstrumentRequestHandlerFunction;
1047
- route?: unstable_InstrumentRouteFunction;
1048
- };
1049
- type unstable_ClientInstrumentation = {
1050
- router?: unstable_InstrumentRouterFunction;
1051
- route?: unstable_InstrumentRouteFunction;
1052
- };
1053
- type unstable_InstrumentRequestHandlerFunction = (handler: InstrumentableRequestHandler) => void;
1054
- type unstable_InstrumentRouterFunction = (router: InstrumentableRouter) => void;
1055
- type unstable_InstrumentRouteFunction = (route: InstrumentableRoute) => void;
1056
- interface GenericInstrumentFunction {
1057
- (handler: () => Promise<void>, info: unknown): Promise<void>;
1058
- }
1059
- type InstrumentableRoute = {
1060
- id: string;
1061
- index: boolean | undefined;
1062
- path: string | undefined;
1063
- instrument(instrumentations: RouteInstrumentations): void;
1064
- };
1065
- type RouteInstrumentations = {
1066
- lazy?: InstrumentLazyFunction;
1067
- "lazy.loader"?: InstrumentLazyFunction;
1068
- "lazy.action"?: InstrumentLazyFunction;
1069
- "lazy.middleware"?: InstrumentLazyFunction;
1070
- middleware?: InstrumentRouteHandlerFunction;
1071
- loader?: InstrumentRouteHandlerFunction;
1072
- action?: InstrumentRouteHandlerFunction;
1073
- };
1074
- type RouteHandlerInstrumentationInfo = Readonly<{
1075
- request: {
1076
- method: string;
1077
- url: string;
1078
- headers: Pick<Headers, "get">;
1079
- };
1080
- params: LoaderFunctionArgs["params"];
1081
- unstable_pattern: string;
1082
- context: Pick<RouterContextProvider, "get">;
1083
- }>;
1084
- interface InstrumentLazyFunction extends GenericInstrumentFunction {
1085
- (handler: () => Promise<void>): Promise<void>;
1086
- }
1087
- interface InstrumentRouteHandlerFunction extends GenericInstrumentFunction {
1088
- (handler: () => Promise<void>, info: RouteHandlerInstrumentationInfo): Promise<void>;
1089
- }
1090
- type InstrumentableRouter = {
1091
- instrument(instrumentations: RouterInstrumentations): void;
1092
- };
1093
- type RouterInstrumentations = {
1094
- navigate?: InstrumentNavigateFunction;
1095
- fetch?: InstrumentFetchFunction;
1096
- };
1097
- type RouterNavigationInstrumentationInfo = Readonly<{
1098
- to: string | number;
1099
- currentUrl: string;
1100
- formMethod?: HTMLFormMethod;
1101
- formEncType?: FormEncType;
1102
- formData?: FormData;
1103
- body?: any;
1104
- }>;
1105
- type RouterFetchInstrumentationInfo = Readonly<{
1106
- href: string;
1107
- currentUrl: string;
1108
- fetcherKey: string;
1109
- formMethod?: HTMLFormMethod;
1110
- formEncType?: FormEncType;
1111
- formData?: FormData;
1112
- body?: any;
1113
- }>;
1114
- interface InstrumentNavigateFunction extends GenericInstrumentFunction {
1115
- (handler: () => Promise<void>, info: RouterNavigationInstrumentationInfo): MaybePromise<void>;
1116
- }
1117
- interface InstrumentFetchFunction extends GenericInstrumentFunction {
1118
- (handler: () => Promise<void>, info: RouterFetchInstrumentationInfo): MaybePromise<void>;
1119
- }
1120
- type InstrumentableRequestHandler = {
1121
- instrument(instrumentations: RequestHandlerInstrumentations): void;
1122
- };
1123
- type RequestHandlerInstrumentations = {
1124
- request?: InstrumentRequestHandlerFunction;
1125
- };
1126
- type RequestHandlerInstrumentationInfo = Readonly<{
1127
- request: {
1128
- method: string;
1129
- url: string;
1130
- headers: Pick<Headers, "get">;
1131
- };
1132
- context: Pick<RouterContextProvider, "get">;
1133
- }>;
1134
- interface InstrumentRequestHandlerFunction extends GenericInstrumentFunction {
1135
- (handler: () => Promise<void>, info: RequestHandlerInstrumentationInfo): MaybePromise<void>;
1136
- }
1137
-
1138
- export { type unstable_InstrumentRequestHandlerFunction as $, type AgnosticRouteObject as A, type ShouldRevalidateFunction as B, type ParamParseKey as C, type DataStrategyResult as D, type PathPattern as E, type FormEncType as F, type PathMatch as G, type History as H, type InitialEntry as I, type DataStrategyFunctionArgs as J, type DataStrategyMatch as K, type Location as L, type MiddlewareNextFunction as M, type ErrorResponse as N, type FormMethod as O, type Path as P, type PathParam as Q, RouterContextProvider as R, type Submission as S, type To as T, type UIMatch as U, type RedirectFunction as V, type RouterContext as W, type ShouldRevalidateFunctionArgs as X, createContext as Y, createPath as Z, parsePath as _, type MaybePromise as a, type unstable_InstrumentRouterFunction as a0, type unstable_InstrumentRouteFunction as a1, data as a2, generatePath as a3, isRouteErrorResponse as a4, matchPath as a5, matchRoutes as a6, redirect as a7, redirectDocument as a8, replace as a9, resolvePath as aa, type Future as ab, createBrowserHistory as ac, invariant as ad, ErrorResponseImpl as ae, type RouteManifest as af, type MapRoutePropertiesFunction as b, Action as c, type AgnosticDataRouteMatch as d, type RouteData as e, type DataStrategyFunction as f, type AgnosticPatchRoutesOnNavigationFunction as g, type AgnosticDataRouteObject as h, type HTMLFormMethod as i, type unstable_ServerInstrumentation as j, type LazyRouteFunction as k, type Params as l, type TrackedPromise as m, type AgnosticNonIndexRouteObject as n, type AgnosticIndexRouteObject as o, type LazyRouteDefinition as p, type AgnosticRouteMatch as q, type AgnosticPatchRoutesOnNavigationFunctionArgs as r, DataWithResponseInit as s, type MiddlewareEnabled as t, type unstable_ClientInstrumentation as u, type ActionFunctionArgs as v, type LoaderFunctionArgs as w, type ActionFunction as x, type LoaderFunction as y, type MiddlewareFunction as z };