react-router 0.0.0-experimental-e56aa53bc → 0.0.0-experimental-e6fb6e074

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/CHANGELOG.md +18 -734
  2. package/README.md +14 -5
  3. package/dist/index.d.ts +30 -0
  4. package/dist/index.js +1501 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/components.d.ts +157 -0
  7. package/dist/lib/context.d.ts +102 -0
  8. package/dist/lib/deprecations.d.ts +4 -0
  9. package/dist/lib/hooks.d.ts +181 -0
  10. package/dist/main.js +19 -0
  11. package/dist/react-router.development.js +1397 -0
  12. package/dist/react-router.development.js.map +1 -0
  13. package/dist/react-router.production.min.js +12 -0
  14. package/dist/react-router.production.min.js.map +1 -0
  15. package/dist/umd/react-router.development.js +1624 -0
  16. package/dist/umd/react-router.development.js.map +1 -0
  17. package/dist/umd/react-router.production.min.js +12 -0
  18. package/dist/umd/react-router.production.min.js.map +1 -0
  19. package/package.json +9 -111
  20. package/dist/development/chunk-RMWJZNG5.mjs +0 -11505
  21. package/dist/development/data-CQbyyGzl.d.mts +0 -11
  22. package/dist/development/data-CQbyyGzl.d.ts +0 -11
  23. package/dist/development/dom-export.d.mts +0 -23
  24. package/dist/development/dom-export.d.ts +0 -23
  25. package/dist/development/dom-export.js +0 -6341
  26. package/dist/development/dom-export.mjs +0 -222
  27. package/dist/development/fog-of-war-C5L_Yd5M.d.mts +0 -1778
  28. package/dist/development/fog-of-war-DrUCUQQ-.d.ts +0 -1778
  29. package/dist/development/index.d.mts +0 -855
  30. package/dist/development/index.d.ts +0 -855
  31. package/dist/development/index.js +0 -11664
  32. package/dist/development/index.mjs +0 -263
  33. package/dist/development/lib/types/route-module.d.mts +0 -209
  34. package/dist/development/lib/types/route-module.d.ts +0 -209
  35. package/dist/development/lib/types/route-module.js +0 -28
  36. package/dist/development/lib/types/route-module.mjs +0 -10
  37. package/dist/development/route-data-BIYebJr3.d.mts +0 -1749
  38. package/dist/development/route-data-BIYebJr3.d.ts +0 -1749
  39. package/dist/development/rsc-export.d.mts +0 -1788
  40. package/dist/development/rsc-export.d.ts +0 -1788
  41. package/dist/development/rsc-export.js +0 -2778
  42. package/dist/development/rsc-export.mjs +0 -2743
  43. package/dist/production/chunk-BXBFRMFA.mjs +0 -11505
  44. package/dist/production/data-CQbyyGzl.d.mts +0 -11
  45. package/dist/production/data-CQbyyGzl.d.ts +0 -11
  46. package/dist/production/dom-export.d.mts +0 -23
  47. package/dist/production/dom-export.d.ts +0 -23
  48. package/dist/production/dom-export.js +0 -6341
  49. package/dist/production/dom-export.mjs +0 -222
  50. package/dist/production/fog-of-war-C5L_Yd5M.d.mts +0 -1778
  51. package/dist/production/fog-of-war-DrUCUQQ-.d.ts +0 -1778
  52. package/dist/production/index.d.mts +0 -855
  53. package/dist/production/index.d.ts +0 -855
  54. package/dist/production/index.js +0 -11664
  55. package/dist/production/index.mjs +0 -263
  56. package/dist/production/lib/types/route-module.d.mts +0 -209
  57. package/dist/production/lib/types/route-module.d.ts +0 -209
  58. package/dist/production/lib/types/route-module.js +0 -28
  59. package/dist/production/lib/types/route-module.mjs +0 -10
  60. package/dist/production/route-data-BIYebJr3.d.mts +0 -1749
  61. package/dist/production/route-data-BIYebJr3.d.ts +0 -1749
  62. package/dist/production/rsc-export.d.mts +0 -1788
  63. package/dist/production/rsc-export.d.ts +0 -1788
  64. package/dist/production/rsc-export.js +0 -2778
  65. package/dist/production/rsc-export.mjs +0 -2743
@@ -1,1788 +0,0 @@
1
- import { ParseOptions, SerializeOptions } from 'cookie';
2
- export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
3
- import * as React from 'react';
4
-
5
- /**
6
- * Actions represent the type of change to a location value.
7
- */
8
- declare enum Action {
9
- /**
10
- * A POP indicates a change to an arbitrary index in the history stack, such
11
- * as a back or forward navigation. It does not describe the direction of the
12
- * navigation, only that the current index changed.
13
- *
14
- * Note: This is the default action for newly created history objects.
15
- */
16
- Pop = "POP",
17
- /**
18
- * A PUSH indicates a new entry being added to the history stack, such as when
19
- * a link is clicked and a new page loads. When this happens, all subsequent
20
- * entries in the stack are lost.
21
- */
22
- Push = "PUSH",
23
- /**
24
- * A REPLACE indicates the entry at the current index in the history stack
25
- * being replaced by a new one.
26
- */
27
- Replace = "REPLACE"
28
- }
29
- /**
30
- * The pathname, search, and hash values of a URL.
31
- */
32
- interface Path {
33
- /**
34
- * A URL pathname, beginning with a /.
35
- */
36
- pathname: string;
37
- /**
38
- * A URL search string, beginning with a ?.
39
- */
40
- search: string;
41
- /**
42
- * A URL fragment identifier, beginning with a #.
43
- */
44
- hash: string;
45
- }
46
- /**
47
- * An entry in a history stack. A location contains information about the
48
- * URL path, as well as possibly some arbitrary state and a key.
49
- */
50
- interface Location<State = any> extends Path {
51
- /**
52
- * A value of arbitrary data associated with this location.
53
- */
54
- state: State;
55
- /**
56
- * A unique string associated with this location. May be used to safely store
57
- * and retrieve data in some other storage API, like `localStorage`.
58
- *
59
- * Note: This value is always "default" on the initial location.
60
- */
61
- key: string;
62
- }
63
- /**
64
- * A change to the current location.
65
- */
66
- interface Update {
67
- /**
68
- * The action that triggered the change.
69
- */
70
- action: Action;
71
- /**
72
- * The new location.
73
- */
74
- location: Location;
75
- /**
76
- * The delta between this location and the former location in the history stack
77
- */
78
- delta: number | null;
79
- }
80
- /**
81
- * A function that receives notifications about location changes.
82
- */
83
- interface Listener {
84
- (update: Update): void;
85
- }
86
- /**
87
- * Describes a location that is the destination of some navigation used in
88
- * {@link Link}, {@link useNavigate}, etc.
89
- */
90
- type To = string | Partial<Path>;
91
- /**
92
- * A history is an interface to the navigation stack. The history serves as the
93
- * source of truth for the current location, as well as provides a set of
94
- * methods that may be used to change it.
95
- *
96
- * It is similar to the DOM's `window.history` object, but with a smaller, more
97
- * focused API.
98
- */
99
- interface History {
100
- /**
101
- * The last action that modified the current location. This will always be
102
- * Action.Pop when a history instance is first created. This value is mutable.
103
- */
104
- readonly action: Action;
105
- /**
106
- * The current location. This value is mutable.
107
- */
108
- readonly location: Location;
109
- /**
110
- * Returns a valid href for the given `to` value that may be used as
111
- * the value of an <a href> attribute.
112
- *
113
- * @param to - The destination URL
114
- */
115
- createHref(to: To): string;
116
- /**
117
- * Returns a URL for the given `to` value
118
- *
119
- * @param to - The destination URL
120
- */
121
- createURL(to: To): URL;
122
- /**
123
- * Encode a location the same way window.history would do (no-op for memory
124
- * history) so we ensure our PUSH/REPLACE navigations for data routers
125
- * behave the same as POP
126
- *
127
- * @param to Unencoded path
128
- */
129
- encodeLocation(to: To): Path;
130
- /**
131
- * Pushes a new location onto the history stack, increasing its length by one.
132
- * If there were any entries in the stack after the current one, they are
133
- * lost.
134
- *
135
- * @param to - The new URL
136
- * @param state - Data to associate with the new location
137
- */
138
- push(to: To, state?: any): void;
139
- /**
140
- * Replaces the current location in the history stack with a new one. The
141
- * location that was replaced will no longer be available.
142
- *
143
- * @param to - The new URL
144
- * @param state - Data to associate with the new location
145
- */
146
- replace(to: To, state?: any): void;
147
- /**
148
- * Navigates `n` entries backward/forward in the history stack relative to the
149
- * current index. For example, a "back" navigation would use go(-1).
150
- *
151
- * @param delta - The delta in the stack index
152
- */
153
- go(delta: number): void;
154
- /**
155
- * Sets up a listener that will be called whenever the current location
156
- * changes.
157
- *
158
- * @param listener - A function that will be called when the location changes
159
- * @returns unlisten - A function that may be used to stop listening
160
- */
161
- listen(listener: Listener): () => void;
162
- }
163
-
164
- /**
165
- * An augmentable interface users can modify in their app-code to opt into
166
- * future-flag-specific types
167
- */
168
- interface Future {
169
- }
170
- type MiddlewareEnabled = Future extends {
171
- unstable_middleware: infer T extends boolean;
172
- } ? T : false;
173
-
174
- type MaybePromise<T> = T | Promise<T>;
175
- /**
176
- * Map of routeId -> data returned from a loader/action/error
177
- */
178
- interface RouteData {
179
- [routeId: string]: any;
180
- }
181
- type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
182
- type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
183
- /**
184
- * Users can specify either lowercase or uppercase form methods on `<Form>`,
185
- * useSubmit(), `<fetcher.Form>`, etc.
186
- */
187
- type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;
188
- /**
189
- * Active navigation/fetcher form methods are exposed in uppercase on the
190
- * RouterState. This is to align with the normalization done via fetch().
191
- */
192
- type FormMethod = UpperCaseFormMethod;
193
- type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
194
- type JsonObject = {
195
- [Key in string]: JsonValue;
196
- } & {
197
- [Key in string]?: JsonValue | undefined;
198
- };
199
- type JsonArray = JsonValue[] | readonly JsonValue[];
200
- type JsonPrimitive = string | number | boolean | null;
201
- type JsonValue = JsonPrimitive | JsonObject | JsonArray;
202
- /**
203
- * @private
204
- * Internal interface to pass around for action submissions, not intended for
205
- * external consumption
206
- */
207
- type Submission = {
208
- formMethod: FormMethod;
209
- formAction: string;
210
- formEncType: FormEncType;
211
- formData: FormData;
212
- json: undefined;
213
- text: undefined;
214
- } | {
215
- formMethod: FormMethod;
216
- formAction: string;
217
- formEncType: FormEncType;
218
- formData: undefined;
219
- json: JsonValue;
220
- text: undefined;
221
- } | {
222
- formMethod: FormMethod;
223
- formAction: string;
224
- formEncType: FormEncType;
225
- formData: undefined;
226
- json: undefined;
227
- text: string;
228
- };
229
- interface unstable_RouterContext<T = unknown> {
230
- defaultValue?: T;
231
- }
232
- /**
233
- * A Map of RouterContext objects to their initial values - used to populate a
234
- * fresh `context` value per request/navigation/fetch
235
- */
236
- type unstable_InitialContext = Map<unstable_RouterContext, unknown>;
237
- /**
238
- * Provides methods for writing/reading values in application context in a typesafe way.
239
- */
240
- declare class unstable_RouterContextProvider {
241
- #private;
242
- constructor(init?: unstable_InitialContext);
243
- get<T>(context: unstable_RouterContext<T>): T;
244
- set<C extends unstable_RouterContext>(context: C, value: C extends unstable_RouterContext<infer T> ? T : never): void;
245
- }
246
- type DefaultContext = MiddlewareEnabled extends true ? unstable_RouterContextProvider : any;
247
- /**
248
- * @private
249
- * Arguments passed to route loader/action functions. Same for now but we keep
250
- * this as a private implementation detail in case they diverge in the future.
251
- */
252
- interface DataFunctionArgs<Context> {
253
- /** 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. */
254
- request: Request;
255
- /**
256
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
257
- * @example
258
- * // app/routes.ts
259
- * route("teams/:teamId", "./team.tsx"),
260
- *
261
- * // app/team.tsx
262
- * export function loader({
263
- * params,
264
- * }: Route.LoaderArgs) {
265
- * params.teamId;
266
- * // ^ string
267
- * }
268
- **/
269
- params: Params;
270
- /**
271
- * This is the context passed in to your server adapter's getLoadContext() function.
272
- * It's a way to bridge the gap between the adapter's request/response API with your React Router app.
273
- * It is only applicable if you are using a custom server adapter.
274
- */
275
- context: Context;
276
- }
277
- /**
278
- * Route middleware `next` function to call downstream handlers and then complete
279
- * middlewares from the bottom-up
280
- */
281
- interface unstable_MiddlewareNextFunction<Result = unknown> {
282
- (): MaybePromise<Result>;
283
- }
284
- /**
285
- * Route middleware function signature. Receives the same "data" arguments as a
286
- * `loader`/`action` (`request`, `params`, `context`) as the first parameter and
287
- * a `next` function as the second parameter which will call downstream handlers
288
- * and then complete middlewares from the bottom-up
289
- */
290
- type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
291
- /**
292
- * Arguments passed to loader functions
293
- */
294
- interface LoaderFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
295
- }
296
- /**
297
- * Arguments passed to action functions
298
- */
299
- interface ActionFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
300
- }
301
- /**
302
- * Loaders and actions can return anything
303
- */
304
- type DataFunctionValue = unknown;
305
- type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
306
- /**
307
- * Route loader function signature
308
- */
309
- type LoaderFunction<Context = DefaultContext> = {
310
- (args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
311
- } & {
312
- hydrate?: boolean;
313
- };
314
- /**
315
- * Route action function signature
316
- */
317
- interface ActionFunction<Context = DefaultContext> {
318
- (args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
319
- }
320
- /**
321
- * Arguments passed to shouldRevalidate function
322
- */
323
- interface ShouldRevalidateFunctionArgs {
324
- /** 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. */
325
- currentUrl: URL;
326
- /** 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. */
327
- currentParams: AgnosticDataRouteMatch["params"];
328
- /** 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. */
329
- nextUrl: URL;
330
- /** 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. */
331
- nextParams: AgnosticDataRouteMatch["params"];
332
- /** The method (probably `"GET"` or `"POST"`) used in the form submission that triggered the revalidation. */
333
- formMethod?: Submission["formMethod"];
334
- /** The form action (`<Form action="/somewhere">`) that triggered the revalidation. */
335
- formAction?: Submission["formAction"];
336
- /** The form encType (`<Form encType="application/x-www-form-urlencoded">) used in the form submission that triggered the revalidation*/
337
- formEncType?: Submission["formEncType"];
338
- /** The form submission data when the form's encType is `text/plain` */
339
- text?: Submission["text"];
340
- /** The form submission data when the form's encType is `application/x-www-form-urlencoded` or `multipart/form-data` */
341
- formData?: Submission["formData"];
342
- /** The form submission data when the form's encType is `application/json` */
343
- json?: Submission["json"];
344
- /** The status code of the action response */
345
- actionStatus?: number;
346
- /**
347
- * 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.
348
- *
349
- * @example
350
- * export async function action() {
351
- * await saveSomeStuff();
352
- * return { ok: true };
353
- * }
354
- *
355
- * export function shouldRevalidate({
356
- * actionResult,
357
- * }) {
358
- * if (actionResult?.ok) {
359
- * return false;
360
- * }
361
- * return true;
362
- * }
363
- */
364
- actionResult?: any;
365
- /**
366
- * 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:
367
- *
368
- * /projects/123/tasks/abc
369
- * /projects/123/tasks/def
370
- * React Router will only call the loader for tasks/def because the param for projects/123 didn't change.
371
- *
372
- * 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.
373
- */
374
- defaultShouldRevalidate: boolean;
375
- }
376
- /**
377
- * Route shouldRevalidate function signature. This runs after any submission
378
- * (navigation or fetcher), so we flatten the navigation/fetcher submission
379
- * onto the arguments. It shouldn't matter whether it came from a navigation
380
- * or a fetcher, what really matters is the URLs and the formData since loaders
381
- * have to re-run based on the data models that were potentially mutated.
382
- */
383
- interface ShouldRevalidateFunction {
384
- (args: ShouldRevalidateFunctionArgs): boolean;
385
- }
386
- interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
387
- /**
388
- * @private
389
- */
390
- _lazyPromises?: {
391
- middleware: Promise<void> | undefined;
392
- handler: Promise<void> | undefined;
393
- route: Promise<void> | undefined;
394
- };
395
- shouldLoad: boolean;
396
- unstable_shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
397
- unstable_shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
398
- resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
399
- }
400
- interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
401
- matches: DataStrategyMatch[];
402
- unstable_runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
403
- fetcherKey: string | null;
404
- }
405
- /**
406
- * Result from a loader or action called via dataStrategy
407
- */
408
- interface DataStrategyResult {
409
- type: "data" | "error";
410
- result: unknown;
411
- }
412
- interface DataStrategyFunction<Context = DefaultContext> {
413
- (args: DataStrategyFunctionArgs<Context>): Promise<Record<string, DataStrategyResult>>;
414
- }
415
- type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = {
416
- signal: AbortSignal;
417
- path: string;
418
- matches: M[];
419
- fetcherKey: string | undefined;
420
- patch: (routeId: string | null, children: O[]) => void;
421
- };
422
- type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => MaybePromise<void>;
423
- /**
424
- * Function provided by the framework-aware layers to set any framework-specific
425
- * properties from framework-agnostic properties
426
- */
427
- interface MapRoutePropertiesFunction {
428
- (route: AgnosticRouteObject): {
429
- hasErrorBoundary: boolean;
430
- } & Record<string, any>;
431
- }
432
- /**
433
- * Keys we cannot change from within a lazy object. We spread all other keys
434
- * onto the route. Either they're meaningful to the router, or they'll get
435
- * ignored.
436
- */
437
- type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
438
- /**
439
- * Keys we cannot change from within a lazy() function. We spread all other keys
440
- * onto the route. Either they're meaningful to the router, or they'll get
441
- * ignored.
442
- */
443
- type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "unstable_middleware";
444
- /**
445
- * lazy object to load route properties, which can add non-matching
446
- * related properties to a route
447
- */
448
- type LazyRouteObject<R extends AgnosticRouteObject> = {
449
- [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined>;
450
- };
451
- /**
452
- * lazy() function to load a route definition, which can add non-matching
453
- * related properties to a route
454
- */
455
- interface LazyRouteFunction<R extends AgnosticRouteObject> {
456
- (): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
457
- }
458
- type LazyRouteDefinition<R extends AgnosticRouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
459
- /**
460
- * Base RouteObject with common props shared by all types of routes
461
- */
462
- type AgnosticBaseRouteObject = {
463
- caseSensitive?: boolean;
464
- path?: string;
465
- id?: string;
466
- unstable_middleware?: unstable_MiddlewareFunction[];
467
- loader?: LoaderFunction | boolean;
468
- action?: ActionFunction | boolean;
469
- hasErrorBoundary?: boolean;
470
- shouldRevalidate?: ShouldRevalidateFunction;
471
- handle?: any;
472
- lazy?: LazyRouteDefinition<AgnosticBaseRouteObject>;
473
- };
474
- /**
475
- * Index routes must not have children
476
- */
477
- type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
478
- children?: undefined;
479
- index: true;
480
- };
481
- /**
482
- * Non-index routes may have children, but cannot have index
483
- */
484
- type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
485
- children?: AgnosticRouteObject[];
486
- index?: false;
487
- };
488
- /**
489
- * A route object represents a logical route, with (optionally) its child
490
- * routes organized in a tree-like structure.
491
- */
492
- type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
493
- type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
494
- id: string;
495
- };
496
- type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
497
- children?: AgnosticDataRouteObject[];
498
- id: string;
499
- };
500
- /**
501
- * A data route object, which is just a RouteObject with a required unique ID
502
- */
503
- type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
504
- /**
505
- * The parameters that were parsed from the URL path.
506
- */
507
- type Params<Key extends string = string> = {
508
- readonly [key in Key]: string | undefined;
509
- };
510
- /**
511
- * A RouteMatch contains info about how a route matched a URL.
512
- */
513
- interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
514
- /**
515
- * The names and values of dynamic parameters in the URL.
516
- */
517
- params: Params<ParamKey>;
518
- /**
519
- * The portion of the URL pathname that was matched.
520
- */
521
- pathname: string;
522
- /**
523
- * The portion of the URL pathname that was matched before child routes.
524
- */
525
- pathnameBase: string;
526
- /**
527
- * The route object that was used to match.
528
- */
529
- route: RouteObjectType;
530
- }
531
- interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
532
- }
533
- /**
534
- * Matches the given routes to a location and returns the match data.
535
- *
536
- * @category Utils
537
- */
538
- declare function matchRoutes<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): AgnosticRouteMatch<string, RouteObjectType>[] | null;
539
- interface UIMatch<Data = unknown, Handle = unknown> {
540
- id: string;
541
- pathname: string;
542
- /**
543
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
544
- **/
545
- params: AgnosticRouteMatch["params"];
546
- /** The return value from the matched route's loader or clientLoader */
547
- data: Data;
548
- /** The {@link https://reactrouter.com/start/framework/route-module#handle handle object} exported from the matched route module */
549
- handle: Handle;
550
- }
551
- declare class DataWithResponseInit<D> {
552
- type: string;
553
- data: D;
554
- init: ResponseInit | null;
555
- constructor(data: D, init?: ResponseInit);
556
- }
557
- /**
558
- * Create "responses" that contain `status`/`headers` without forcing
559
- * serialization into an actual `Response` - used by Remix single fetch
560
- *
561
- * @category Utils
562
- */
563
- declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
564
- type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
565
- /**
566
- * A redirect response. Sets the status code and the `Location` header.
567
- * Defaults to "302 Found".
568
- *
569
- * @category Utils
570
- */
571
- declare const redirect: RedirectFunction;
572
- /**
573
- * A redirect response that will force a document reload to the new location.
574
- * Sets the status code and the `Location` header.
575
- * Defaults to "302 Found".
576
- *
577
- * @category Utils
578
- */
579
- declare const redirectDocument: RedirectFunction;
580
- /**
581
- * A redirect response that will perform a `history.replaceState` instead of a
582
- * `history.pushState` for client-side navigation redirects.
583
- * Sets the status code and the `Location` header.
584
- * Defaults to "302 Found".
585
- *
586
- * @category Utils
587
- */
588
- declare const replace: RedirectFunction;
589
-
590
- /**
591
- * A Router instance manages all navigation and data loading/mutations
592
- */
593
- interface Router {
594
- /**
595
- * @private
596
- * PRIVATE - DO NOT USE
597
- *
598
- * Return the basename for the router
599
- */
600
- get basename(): RouterInit["basename"];
601
- /**
602
- * @private
603
- * PRIVATE - DO NOT USE
604
- *
605
- * Return the future config for the router
606
- */
607
- get future(): FutureConfig;
608
- /**
609
- * @private
610
- * PRIVATE - DO NOT USE
611
- *
612
- * Return the current state of the router
613
- */
614
- get state(): RouterState;
615
- /**
616
- * @private
617
- * PRIVATE - DO NOT USE
618
- *
619
- * Return the routes for this router instance
620
- */
621
- get routes(): AgnosticDataRouteObject[];
622
- /**
623
- * @private
624
- * PRIVATE - DO NOT USE
625
- *
626
- * Return the window associated with the router
627
- */
628
- get window(): RouterInit["window"];
629
- /**
630
- * @private
631
- * PRIVATE - DO NOT USE
632
- *
633
- * Initialize the router, including adding history listeners and kicking off
634
- * initial data fetches. Returns a function to cleanup listeners and abort
635
- * any in-progress loads
636
- */
637
- initialize(): Router;
638
- /**
639
- * @private
640
- * PRIVATE - DO NOT USE
641
- *
642
- * Subscribe to router.state updates
643
- *
644
- * @param fn function to call with the new state
645
- */
646
- subscribe(fn: RouterSubscriber): () => void;
647
- /**
648
- * @private
649
- * PRIVATE - DO NOT USE
650
- *
651
- * Enable scroll restoration behavior in the router
652
- *
653
- * @param savedScrollPositions Object that will manage positions, in case
654
- * it's being restored from sessionStorage
655
- * @param getScrollPosition Function to get the active Y scroll position
656
- * @param getKey Function to get the key to use for restoration
657
- */
658
- enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
659
- /**
660
- * @private
661
- * PRIVATE - DO NOT USE
662
- *
663
- * Navigate forward/backward in the history stack
664
- * @param to Delta to move in the history stack
665
- */
666
- navigate(to: number): Promise<void>;
667
- /**
668
- * Navigate to the given path
669
- * @param to Path to navigate to
670
- * @param opts Navigation options (method, submission, etc.)
671
- */
672
- navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
673
- /**
674
- * @private
675
- * PRIVATE - DO NOT USE
676
- *
677
- * Trigger a fetcher load/submission
678
- *
679
- * @param key Fetcher key
680
- * @param routeId Route that owns the fetcher
681
- * @param href href to fetch
682
- * @param opts Fetcher options, (method, submission, etc.)
683
- */
684
- fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): Promise<void>;
685
- /**
686
- * @private
687
- * PRIVATE - DO NOT USE
688
- *
689
- * Trigger a revalidation of all current route loaders and fetcher loads
690
- */
691
- revalidate(): Promise<void>;
692
- /**
693
- * @private
694
- * PRIVATE - DO NOT USE
695
- *
696
- * Utility function to create an href for the given location
697
- * @param location
698
- */
699
- createHref(location: Location | URL): string;
700
- /**
701
- * @private
702
- * PRIVATE - DO NOT USE
703
- *
704
- * Utility function to URL encode a destination path according to the internal
705
- * history implementation
706
- * @param to
707
- */
708
- encodeLocation(to: To): Path;
709
- /**
710
- * @private
711
- * PRIVATE - DO NOT USE
712
- *
713
- * Get/create a fetcher for the given key
714
- * @param key
715
- */
716
- getFetcher<TData = any>(key: string): Fetcher<TData>;
717
- /**
718
- * @private
719
- * PRIVATE - DO NOT USE
720
- *
721
- * Delete the fetcher for a given key
722
- * @param key
723
- */
724
- deleteFetcher(key: string): void;
725
- /**
726
- * @private
727
- * PRIVATE - DO NOT USE
728
- *
729
- * Cleanup listeners and abort any in-progress loads
730
- */
731
- dispose(): void;
732
- /**
733
- * @private
734
- * PRIVATE - DO NOT USE
735
- *
736
- * Get a navigation blocker
737
- * @param key The identifier for the blocker
738
- * @param fn The blocker function implementation
739
- */
740
- getBlocker(key: string, fn: BlockerFunction): Blocker;
741
- /**
742
- * @private
743
- * PRIVATE - DO NOT USE
744
- *
745
- * Delete a navigation blocker
746
- * @param key The identifier for the blocker
747
- */
748
- deleteBlocker(key: string): void;
749
- /**
750
- * @private
751
- * PRIVATE DO NOT USE
752
- *
753
- * Patch additional children routes into an existing parent route
754
- * @param routeId The parent route id or a callback function accepting `patch`
755
- * to perform batch patching
756
- * @param children The additional children routes
757
- * @param unstable_allowElementMutations Allow mutation or route elements on
758
- * existing routes. Intended for RSC-usage
759
- * only.
760
- */
761
- patchRoutes(routeId: string | null, children: AgnosticRouteObject[], unstable_allowElementMutations?: boolean): void;
762
- /**
763
- * @private
764
- * PRIVATE - DO NOT USE
765
- *
766
- * HMR needs to pass in-flight route updates to React Router
767
- * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
768
- */
769
- _internalSetRoutes(routes: AgnosticRouteObject[]): void;
770
- /**
771
- * @private
772
- * PRIVATE - DO NOT USE
773
- *
774
- * Cause subscribers to re-render. This is used to force a re-render.
775
- */
776
- _internalSetStateDoNotUseOrYouWillBreakYourApp(state: Partial<RouterState>): void;
777
- /**
778
- * @private
779
- * PRIVATE - DO NOT USE
780
- *
781
- * Internal fetch AbortControllers accessed by unit tests
782
- */
783
- _internalFetchControllers: Map<string, AbortController>;
784
- }
785
- /**
786
- * State maintained internally by the router. During a navigation, all states
787
- * reflect the "old" location unless otherwise noted.
788
- */
789
- interface RouterState {
790
- /**
791
- * The action of the most recent navigation
792
- */
793
- historyAction: Action;
794
- /**
795
- * The current location reflected by the router
796
- */
797
- location: Location;
798
- /**
799
- * The current set of route matches
800
- */
801
- matches: AgnosticDataRouteMatch[];
802
- /**
803
- * Tracks whether we've completed our initial data load
804
- */
805
- initialized: boolean;
806
- /**
807
- * Current scroll position we should start at for a new view
808
- * - number -> scroll position to restore to
809
- * - false -> do not restore scroll at all (used during submissions)
810
- * - null -> don't have a saved position, scroll to hash or top of page
811
- */
812
- restoreScrollPosition: number | false | null;
813
- /**
814
- * Indicate whether this navigation should skip resetting the scroll position
815
- * if we are unable to restore the scroll position
816
- */
817
- preventScrollReset: boolean;
818
- /**
819
- * Tracks the state of the current navigation
820
- */
821
- navigation: Navigation;
822
- /**
823
- * Tracks any in-progress revalidations
824
- */
825
- revalidation: RevalidationState;
826
- /**
827
- * Data from the loaders for the current matches
828
- */
829
- loaderData: RouteData;
830
- /**
831
- * Data from the action for the current matches
832
- */
833
- actionData: RouteData | null;
834
- /**
835
- * Errors caught from loaders for the current matches
836
- */
837
- errors: RouteData | null;
838
- /**
839
- * Map of current fetchers
840
- */
841
- fetchers: Map<string, Fetcher>;
842
- /**
843
- * Map of current blockers
844
- */
845
- blockers: Map<string, Blocker>;
846
- }
847
- /**
848
- * Data that can be passed into hydrate a Router from SSR
849
- */
850
- type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
851
- /**
852
- * Future flags to toggle new feature behavior
853
- */
854
- interface FutureConfig {
855
- unstable_middleware: boolean;
856
- }
857
- /**
858
- * Initialization options for createRouter
859
- */
860
- interface RouterInit {
861
- routes: AgnosticRouteObject[];
862
- history: History;
863
- basename?: string;
864
- unstable_getContext?: () => MaybePromise<unstable_InitialContext>;
865
- mapRouteProperties?: MapRoutePropertiesFunction;
866
- future?: Partial<FutureConfig>;
867
- hydrationRouteProperties?: string[];
868
- hydrationData?: HydrationState;
869
- window?: Window;
870
- dataStrategy?: DataStrategyFunction;
871
- patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction;
872
- }
873
- /**
874
- * State returned from a server-side query() call
875
- */
876
- interface StaticHandlerContext {
877
- basename: Router["basename"];
878
- location: RouterState["location"];
879
- matches: RouterState["matches"];
880
- loaderData: RouterState["loaderData"];
881
- actionData: RouterState["actionData"];
882
- errors: RouterState["errors"];
883
- statusCode: number;
884
- loaderHeaders: Record<string, Headers>;
885
- actionHeaders: Record<string, Headers>;
886
- _deepestRenderedBoundaryId?: string | null;
887
- }
888
- /**
889
- * A StaticHandler instance manages a singular SSR navigation/fetch event
890
- */
891
- interface StaticHandler {
892
- dataRoutes: AgnosticDataRouteObject[];
893
- query(request: Request, opts?: {
894
- requestContext?: unknown;
895
- filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
896
- skipLoaderErrorBubbling?: boolean;
897
- skipRevalidation?: boolean;
898
- dataStrategy?: DataStrategyFunction<unknown>;
899
- unstable_respond?: (staticContext: StaticHandlerContext) => MaybePromise<Response>;
900
- }): Promise<StaticHandlerContext | Response>;
901
- queryRoute(request: Request, opts?: {
902
- routeId?: string;
903
- requestContext?: unknown;
904
- dataStrategy?: DataStrategyFunction<unknown>;
905
- unstable_respond?: (res: Response) => MaybePromise<Response>;
906
- }): Promise<any>;
907
- }
908
- type ViewTransitionOpts = {
909
- currentLocation: Location;
910
- nextLocation: Location;
911
- };
912
- /**
913
- * Subscriber function signature for changes to router state
914
- */
915
- interface RouterSubscriber {
916
- (state: RouterState, opts: {
917
- deletedFetchers: string[];
918
- viewTransitionOpts?: ViewTransitionOpts;
919
- flushSync: boolean;
920
- }): void;
921
- }
922
- /**
923
- * Function signature for determining the key to be used in scroll restoration
924
- * for a given location
925
- */
926
- interface GetScrollRestorationKeyFunction {
927
- (location: Location, matches: UIMatch[]): string | null;
928
- }
929
- /**
930
- * Function signature for determining the current scroll position
931
- */
932
- interface GetScrollPositionFunction {
933
- (): number;
934
- }
935
- /**
936
- - "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.
937
- - "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.
938
- */
939
- type RelativeRoutingType = "route" | "path";
940
- type BaseNavigateOrFetchOptions = {
941
- preventScrollReset?: boolean;
942
- relative?: RelativeRoutingType;
943
- flushSync?: boolean;
944
- };
945
- type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
946
- replace?: boolean;
947
- state?: any;
948
- fromRouteId?: string;
949
- viewTransition?: boolean;
950
- };
951
- type BaseSubmissionOptions = {
952
- formMethod?: HTMLFormMethod;
953
- formEncType?: FormEncType;
954
- } & ({
955
- formData: FormData;
956
- body?: undefined;
957
- } | {
958
- formData?: undefined;
959
- body: any;
960
- });
961
- /**
962
- * Options for a navigate() call for a normal (non-submission) navigation
963
- */
964
- type LinkNavigateOptions = BaseNavigateOptions;
965
- /**
966
- * Options for a navigate() call for a submission navigation
967
- */
968
- type SubmissionNavigateOptions = BaseNavigateOptions & BaseSubmissionOptions;
969
- /**
970
- * Options to pass to navigate() for a navigation
971
- */
972
- type RouterNavigateOptions = LinkNavigateOptions | SubmissionNavigateOptions;
973
- /**
974
- * Options for a fetch() load
975
- */
976
- type LoadFetchOptions = BaseNavigateOrFetchOptions;
977
- /**
978
- * Options for a fetch() submission
979
- */
980
- type SubmitFetchOptions = BaseNavigateOrFetchOptions & BaseSubmissionOptions;
981
- /**
982
- * Options to pass to fetch()
983
- */
984
- type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
985
- /**
986
- * Potential states for state.navigation
987
- */
988
- type NavigationStates = {
989
- Idle: {
990
- state: "idle";
991
- location: undefined;
992
- formMethod: undefined;
993
- formAction: undefined;
994
- formEncType: undefined;
995
- formData: undefined;
996
- json: undefined;
997
- text: undefined;
998
- };
999
- Loading: {
1000
- state: "loading";
1001
- location: Location;
1002
- formMethod: Submission["formMethod"] | undefined;
1003
- formAction: Submission["formAction"] | undefined;
1004
- formEncType: Submission["formEncType"] | undefined;
1005
- formData: Submission["formData"] | undefined;
1006
- json: Submission["json"] | undefined;
1007
- text: Submission["text"] | undefined;
1008
- };
1009
- Submitting: {
1010
- state: "submitting";
1011
- location: Location;
1012
- formMethod: Submission["formMethod"];
1013
- formAction: Submission["formAction"];
1014
- formEncType: Submission["formEncType"];
1015
- formData: Submission["formData"];
1016
- json: Submission["json"];
1017
- text: Submission["text"];
1018
- };
1019
- };
1020
- type Navigation = NavigationStates[keyof NavigationStates];
1021
- type RevalidationState = "idle" | "loading";
1022
- /**
1023
- * Potential states for fetchers
1024
- */
1025
- type FetcherStates<TData = any> = {
1026
- /**
1027
- * The fetcher is not calling a loader or action
1028
- *
1029
- * ```tsx
1030
- * fetcher.state === "idle"
1031
- * ```
1032
- */
1033
- Idle: {
1034
- state: "idle";
1035
- formMethod: undefined;
1036
- formAction: undefined;
1037
- formEncType: undefined;
1038
- text: undefined;
1039
- formData: undefined;
1040
- json: undefined;
1041
- /**
1042
- * If the fetcher has never been called, this will be undefined.
1043
- */
1044
- data: TData | undefined;
1045
- };
1046
- /**
1047
- * The fetcher is loading data from a {@link LoaderFunction | loader} from a
1048
- * call to {@link FetcherWithComponents.load | `fetcher.load`}.
1049
- *
1050
- * ```tsx
1051
- * // somewhere
1052
- * <button onClick={() => fetcher.load("/some/route") }>Load</button>
1053
- *
1054
- * // the state will update
1055
- * fetcher.state === "loading"
1056
- * ```
1057
- */
1058
- Loading: {
1059
- state: "loading";
1060
- formMethod: Submission["formMethod"] | undefined;
1061
- formAction: Submission["formAction"] | undefined;
1062
- formEncType: Submission["formEncType"] | undefined;
1063
- text: Submission["text"] | undefined;
1064
- formData: Submission["formData"] | undefined;
1065
- json: Submission["json"] | undefined;
1066
- data: TData | undefined;
1067
- };
1068
- /**
1069
- 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`}.
1070
-
1071
- ```tsx
1072
- // somewhere
1073
- <input
1074
- onChange={e => {
1075
- fetcher.submit(event.currentTarget.form, { method: "post" });
1076
- }}
1077
- />
1078
-
1079
- // the state will update
1080
- fetcher.state === "submitting"
1081
-
1082
- // and formData will be available
1083
- fetcher.formData
1084
- ```
1085
- */
1086
- Submitting: {
1087
- state: "submitting";
1088
- formMethod: Submission["formMethod"];
1089
- formAction: Submission["formAction"];
1090
- formEncType: Submission["formEncType"];
1091
- text: Submission["text"];
1092
- formData: Submission["formData"];
1093
- json: Submission["json"];
1094
- data: TData | undefined;
1095
- };
1096
- };
1097
- type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
1098
- interface BlockerBlocked {
1099
- state: "blocked";
1100
- reset(): void;
1101
- proceed(): void;
1102
- location: Location;
1103
- }
1104
- interface BlockerUnblocked {
1105
- state: "unblocked";
1106
- reset: undefined;
1107
- proceed: undefined;
1108
- location: undefined;
1109
- }
1110
- interface BlockerProceeding {
1111
- state: "proceeding";
1112
- reset: undefined;
1113
- proceed: undefined;
1114
- location: Location;
1115
- }
1116
- type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
1117
- type BlockerFunction = (args: {
1118
- currentLocation: Location;
1119
- nextLocation: Location;
1120
- historyAction: Action;
1121
- }) => boolean;
1122
- interface CreateStaticHandlerOptions {
1123
- basename?: string;
1124
- mapRouteProperties?: MapRoutePropertiesFunction;
1125
- future?: {};
1126
- }
1127
- declare function createStaticHandler(routes: AgnosticRouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
1128
-
1129
- interface CookieSignatureOptions {
1130
- /**
1131
- * An array of secrets that may be used to sign/unsign the value of a cookie.
1132
- *
1133
- * The array makes it easy to rotate secrets. New secrets should be added to
1134
- * the beginning of the array. `cookie.serialize()` will always use the first
1135
- * value in the array, but `cookie.parse()` may use any of them so that
1136
- * cookies that were signed with older secrets still work.
1137
- */
1138
- secrets?: string[];
1139
- }
1140
- type CookieOptions = ParseOptions & SerializeOptions & CookieSignatureOptions;
1141
- /**
1142
- * A HTTP cookie.
1143
- *
1144
- * A Cookie is a logical container for metadata about a HTTP cookie; its name
1145
- * and options. But it doesn't contain a value. Instead, it has `parse()` and
1146
- * `serialize()` methods that allow a single instance to be reused for
1147
- * parsing/encoding multiple different values.
1148
- *
1149
- * @see https://remix.run/utils/cookies#cookie-api
1150
- */
1151
- interface Cookie {
1152
- /**
1153
- * The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
1154
- */
1155
- readonly name: string;
1156
- /**
1157
- * True if this cookie uses one or more secrets for verification.
1158
- */
1159
- readonly isSigned: boolean;
1160
- /**
1161
- * The Date this cookie expires.
1162
- *
1163
- * Note: This is calculated at access time using `maxAge` when no `expires`
1164
- * option is provided to `createCookie()`.
1165
- */
1166
- readonly expires?: Date;
1167
- /**
1168
- * Parses a raw `Cookie` header and returns the value of this cookie or
1169
- * `null` if it's not present.
1170
- */
1171
- parse(cookieHeader: string | null, options?: ParseOptions): Promise<any>;
1172
- /**
1173
- * Serializes the given value to a string and returns the `Set-Cookie`
1174
- * header.
1175
- */
1176
- serialize(value: any, options?: SerializeOptions): Promise<string>;
1177
- }
1178
- /**
1179
- * Creates a logical container for managing a browser cookie from the server.
1180
- */
1181
- declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
1182
- type IsCookieFunction = (object: any) => object is Cookie;
1183
- /**
1184
- * Returns true if an object is a Remix cookie container.
1185
- *
1186
- * @see https://remix.run/utils/cookies#iscookie
1187
- */
1188
- declare const isCookie: IsCookieFunction;
1189
-
1190
- /**
1191
- * An object of name/value pairs to be used in the session.
1192
- */
1193
- interface SessionData {
1194
- [name: string]: any;
1195
- }
1196
- /**
1197
- * Session persists data across HTTP requests.
1198
- *
1199
- * @see https://remix.run/utils/sessions#session-api
1200
- */
1201
- interface Session<Data = SessionData, FlashData = Data> {
1202
- /**
1203
- * A unique identifier for this session.
1204
- *
1205
- * Note: This will be the empty string for newly created sessions and
1206
- * sessions that are not backed by a database (i.e. cookie-based sessions).
1207
- */
1208
- readonly id: string;
1209
- /**
1210
- * The raw data contained in this session.
1211
- *
1212
- * This is useful mostly for SessionStorage internally to access the raw
1213
- * session data to persist.
1214
- */
1215
- readonly data: FlashSessionData<Data, FlashData>;
1216
- /**
1217
- * Returns `true` if the session has a value for the given `name`, `false`
1218
- * otherwise.
1219
- */
1220
- has(name: (keyof Data | keyof FlashData) & string): boolean;
1221
- /**
1222
- * Returns the value for the given `name` in this session.
1223
- */
1224
- get<Key extends (keyof Data | keyof FlashData) & string>(name: Key): (Key extends keyof Data ? Data[Key] : undefined) | (Key extends keyof FlashData ? FlashData[Key] : undefined) | undefined;
1225
- /**
1226
- * Sets a value in the session for the given `name`.
1227
- */
1228
- set<Key extends keyof Data & string>(name: Key, value: Data[Key]): void;
1229
- /**
1230
- * Sets a value in the session that is only valid until the next `get()`.
1231
- * This can be useful for temporary values, like error messages.
1232
- */
1233
- flash<Key extends keyof FlashData & string>(name: Key, value: FlashData[Key]): void;
1234
- /**
1235
- * Removes a value from the session.
1236
- */
1237
- unset(name: keyof Data & string): void;
1238
- }
1239
- type FlashSessionData<Data, FlashData> = Partial<Data & {
1240
- [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key];
1241
- }>;
1242
- type FlashDataKey<Key extends string> = `__flash_${Key}__`;
1243
- type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?: Data, id?: string) => Session<Data, FlashData>;
1244
- /**
1245
- * Creates a new Session object.
1246
- *
1247
- * Note: This function is typically not invoked directly by application code.
1248
- * Instead, use a `SessionStorage` object's `getSession` method.
1249
- *
1250
- * @see https://remix.run/utils/sessions#createsession
1251
- */
1252
- declare const createSession: CreateSessionFunction;
1253
- type IsSessionFunction = (object: any) => object is Session;
1254
- /**
1255
- * Returns true if an object is a Remix session.
1256
- *
1257
- * @see https://remix.run/utils/sessions#issession
1258
- */
1259
- declare const isSession: IsSessionFunction;
1260
- /**
1261
- * SessionStorage stores session data between HTTP requests and knows how to
1262
- * parse and create cookies.
1263
- *
1264
- * A SessionStorage creates Session objects using a `Cookie` header as input.
1265
- * Then, later it generates the `Set-Cookie` header to be used in the response.
1266
- */
1267
- interface SessionStorage<Data = SessionData, FlashData = Data> {
1268
- /**
1269
- * Parses a Cookie header from a HTTP request and returns the associated
1270
- * Session. If there is no session associated with the cookie, this will
1271
- * return a new Session with no data.
1272
- */
1273
- getSession: (cookieHeader?: string | null, options?: ParseOptions) => Promise<Session<Data, FlashData>>;
1274
- /**
1275
- * Stores all data in the Session and returns the Set-Cookie header to be
1276
- * used in the HTTP response.
1277
- */
1278
- commitSession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
1279
- /**
1280
- * Deletes all data associated with the Session and returns the Set-Cookie
1281
- * header to be used in the HTTP response.
1282
- */
1283
- destroySession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
1284
- }
1285
- /**
1286
- * SessionIdStorageStrategy is designed to allow anyone to easily build their
1287
- * own SessionStorage using `createSessionStorage(strategy)`.
1288
- *
1289
- * This strategy describes a common scenario where the session id is stored in
1290
- * a cookie but the actual session data is stored elsewhere, usually in a
1291
- * database or on disk. A set of create, read, update, and delete operations
1292
- * are provided for managing the session data.
1293
- */
1294
- interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
1295
- /**
1296
- * The Cookie used to store the session id, or options used to automatically
1297
- * create one.
1298
- */
1299
- cookie?: Cookie | (CookieOptions & {
1300
- name?: string;
1301
- });
1302
- /**
1303
- * Creates a new record with the given data and returns the session id.
1304
- */
1305
- createData: (data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<string>;
1306
- /**
1307
- * Returns data for a given session id, or `null` if there isn't any.
1308
- */
1309
- readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
1310
- /**
1311
- * Updates data for the given session id.
1312
- */
1313
- updateData: (id: string, data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<void>;
1314
- /**
1315
- * Deletes data for a given session id from the data store.
1316
- */
1317
- deleteData: (id: string) => Promise<void>;
1318
- }
1319
- /**
1320
- * Creates a SessionStorage object using a SessionIdStorageStrategy.
1321
- *
1322
- * Note: This is a low-level API that should only be used if none of the
1323
- * existing session storage options meet your requirements.
1324
- */
1325
- declare function createSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg, createData, readData, updateData, deleteData, }: SessionIdStorageStrategy<Data, FlashData>): SessionStorage<Data, FlashData>;
1326
-
1327
- interface CookieSessionStorageOptions {
1328
- /**
1329
- * The Cookie used to store the session data on the client, or options used
1330
- * to automatically create one.
1331
- */
1332
- cookie?: SessionIdStorageStrategy["cookie"];
1333
- }
1334
- /**
1335
- * Creates and returns a SessionStorage object that stores all session data
1336
- * directly in the session cookie itself.
1337
- *
1338
- * This has the advantage that no database or other backend services are
1339
- * needed, and can help to simplify some load-balanced scenarios. However, it
1340
- * also has the limitation that serialized session data may not exceed the
1341
- * browser's maximum cookie size. Trade-offs!
1342
- */
1343
- declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg }?: CookieSessionStorageOptions): SessionStorage<Data, FlashData>;
1344
-
1345
- interface MemorySessionStorageOptions {
1346
- /**
1347
- * The Cookie used to store the session id on the client, or options used
1348
- * to automatically create one.
1349
- */
1350
- cookie?: SessionIdStorageStrategy["cookie"];
1351
- }
1352
- /**
1353
- * Creates and returns a simple in-memory SessionStorage object, mostly useful
1354
- * for testing and as a reference implementation.
1355
- *
1356
- * Note: This storage does not scale beyond a single process, so it is not
1357
- * suitable for most production scenarios.
1358
- */
1359
- declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({ cookie }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
1360
-
1361
- interface IndexRouteObject {
1362
- caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
1363
- path?: AgnosticIndexRouteObject["path"];
1364
- id?: AgnosticIndexRouteObject["id"];
1365
- unstable_middleware?: AgnosticIndexRouteObject["unstable_middleware"];
1366
- loader?: AgnosticIndexRouteObject["loader"];
1367
- action?: AgnosticIndexRouteObject["action"];
1368
- hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
1369
- shouldRevalidate?: AgnosticIndexRouteObject["shouldRevalidate"];
1370
- handle?: AgnosticIndexRouteObject["handle"];
1371
- index: true;
1372
- children?: undefined;
1373
- element?: React.ReactNode | null;
1374
- hydrateFallbackElement?: React.ReactNode | null;
1375
- errorElement?: React.ReactNode | null;
1376
- Component?: React.ComponentType | null;
1377
- HydrateFallback?: React.ComponentType | null;
1378
- ErrorBoundary?: React.ComponentType | null;
1379
- lazy?: LazyRouteDefinition<RouteObject>;
1380
- }
1381
- interface NonIndexRouteObject {
1382
- caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
1383
- path?: AgnosticNonIndexRouteObject["path"];
1384
- id?: AgnosticNonIndexRouteObject["id"];
1385
- unstable_middleware?: AgnosticNonIndexRouteObject["unstable_middleware"];
1386
- loader?: AgnosticNonIndexRouteObject["loader"];
1387
- action?: AgnosticNonIndexRouteObject["action"];
1388
- hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
1389
- shouldRevalidate?: AgnosticNonIndexRouteObject["shouldRevalidate"];
1390
- handle?: AgnosticNonIndexRouteObject["handle"];
1391
- index?: false;
1392
- children?: RouteObject[];
1393
- element?: React.ReactNode | null;
1394
- hydrateFallbackElement?: React.ReactNode | null;
1395
- errorElement?: React.ReactNode | null;
1396
- Component?: React.ComponentType | null;
1397
- HydrateFallback?: React.ComponentType | null;
1398
- ErrorBoundary?: React.ComponentType | null;
1399
- lazy?: LazyRouteDefinition<RouteObject>;
1400
- }
1401
- type RouteObject = IndexRouteObject | NonIndexRouteObject;
1402
- type DataRouteObject = RouteObject & {
1403
- children?: DataRouteObject[];
1404
- id: string;
1405
- };
1406
- interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> extends AgnosticRouteMatch<ParamKey, RouteObjectType> {
1407
- }
1408
- interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
1409
- }
1410
-
1411
- type Primitive = null | undefined | string | number | boolean | symbol | bigint;
1412
- type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
1413
- interface HtmlLinkProps {
1414
- /**
1415
- * Address of the hyperlink
1416
- */
1417
- href?: string;
1418
- /**
1419
- * How the element handles crossorigin requests
1420
- */
1421
- crossOrigin?: "anonymous" | "use-credentials";
1422
- /**
1423
- * Relationship between the document containing the hyperlink and the destination resource
1424
- */
1425
- rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
1426
- /**
1427
- * Applicable media: "screen", "print", "(max-width: 764px)"
1428
- */
1429
- media?: string;
1430
- /**
1431
- * Integrity metadata used in Subresource Integrity checks
1432
- */
1433
- integrity?: string;
1434
- /**
1435
- * Language of the linked resource
1436
- */
1437
- hrefLang?: string;
1438
- /**
1439
- * Hint for the type of the referenced resource
1440
- */
1441
- type?: string;
1442
- /**
1443
- * Referrer policy for fetches initiated by the element
1444
- */
1445
- referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
1446
- /**
1447
- * Sizes of the icons (for rel="icon")
1448
- */
1449
- sizes?: string;
1450
- /**
1451
- * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
1452
- */
1453
- as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
1454
- /**
1455
- * Color to use when customizing a site's icon (for rel="mask-icon")
1456
- */
1457
- color?: string;
1458
- /**
1459
- * Whether the link is disabled
1460
- */
1461
- disabled?: boolean;
1462
- /**
1463
- * The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
1464
- */
1465
- title?: string;
1466
- /**
1467
- * Images to use in different situations, e.g., high-resolution displays,
1468
- * small monitors, etc. (for rel="preload")
1469
- */
1470
- imageSrcSet?: string;
1471
- /**
1472
- * Image sizes for different page layouts (for rel="preload")
1473
- */
1474
- imageSizes?: string;
1475
- }
1476
- interface HtmlLinkPreloadImage extends HtmlLinkProps {
1477
- /**
1478
- * Relationship between the document containing the hyperlink and the destination resource
1479
- */
1480
- rel: "preload";
1481
- /**
1482
- * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
1483
- */
1484
- as: "image";
1485
- /**
1486
- * Address of the hyperlink
1487
- */
1488
- href?: string;
1489
- /**
1490
- * Images to use in different situations, e.g., high-resolution displays,
1491
- * small monitors, etc. (for rel="preload")
1492
- */
1493
- imageSrcSet: string;
1494
- /**
1495
- * Image sizes for different page layouts (for rel="preload")
1496
- */
1497
- imageSizes?: string;
1498
- }
1499
- /**
1500
- * Represents a `<link>` element.
1501
- *
1502
- * WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
1503
- */
1504
- type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
1505
- imageSizes?: never;
1506
- });
1507
- interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
1508
- /**
1509
- * The absolute path of the page to prefetch.
1510
- */
1511
- page: string;
1512
- }
1513
- type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
1514
-
1515
- type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
1516
- [key: PropertyKey]: Serializable;
1517
- } | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
1518
-
1519
- /**
1520
- * A brand that can be applied to a type to indicate that it will serialize
1521
- * to a specific type when transported to the client from a loader.
1522
- * Only use this if you have additional serialization/deserialization logic
1523
- * in your application.
1524
- */
1525
- type unstable_SerializesTo<T> = {
1526
- unstable__ReactRouter_SerializesTo: [T];
1527
- };
1528
-
1529
- type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
1530
- type IsAny<T> = 0 extends 1 & T ? true : false;
1531
- type Func = (...args: any[]) => unknown;
1532
-
1533
- 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> ? {
1534
- [K in keyof T]: Serialize<T[K]>;
1535
- } : undefined;
1536
- type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
1537
- type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
1538
- type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? U : T;
1539
- type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
1540
- type ServerDataFrom<T> = ServerData<DataFrom<T>>;
1541
- type ClientDataFrom<T> = ClientData<DataFrom<T>>;
1542
- type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
1543
-
1544
- /**
1545
- * A function that handles data mutations for a route on the client
1546
- */
1547
- type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<ActionFunction>;
1548
- /**
1549
- * Arguments passed to a route `clientAction` function
1550
- */
1551
- type ClientActionFunctionArgs = ActionFunctionArgs & {
1552
- serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
1553
- };
1554
- /**
1555
- * A function that loads data for a route on the client
1556
- */
1557
- type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<LoaderFunction>) & {
1558
- hydrate?: boolean;
1559
- };
1560
- /**
1561
- * Arguments passed to a route `clientLoader` function
1562
- */
1563
- type ClientLoaderFunctionArgs = LoaderFunctionArgs & {
1564
- serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
1565
- };
1566
- type HeadersArgs = {
1567
- loaderHeaders: Headers;
1568
- parentHeaders: Headers;
1569
- actionHeaders: Headers;
1570
- errorHeaders: Headers | undefined;
1571
- };
1572
- /**
1573
- * A function that returns HTTP headers to be used for a route. These headers
1574
- * will be merged with (and take precedence over) headers from parent routes.
1575
- */
1576
- interface HeadersFunction {
1577
- (args: HeadersArgs): Headers | HeadersInit;
1578
- }
1579
- /**
1580
- * A function that defines `<link>` tags to be inserted into the `<head>` of
1581
- * the document on route transitions.
1582
- *
1583
- * @see https://remix.run/route/meta
1584
- */
1585
- interface LinksFunction {
1586
- (): LinkDescriptor[];
1587
- }
1588
- interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown> {
1589
- id: RouteId;
1590
- pathname: DataRouteMatch["pathname"];
1591
- data: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
1592
- handle?: RouteHandle;
1593
- params: DataRouteMatch["params"];
1594
- meta: MetaDescriptor[];
1595
- error?: unknown;
1596
- }
1597
- type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{
1598
- [K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>;
1599
- }[keyof MatchLoaders]>;
1600
- interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
1601
- data: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
1602
- params: Params;
1603
- location: Location;
1604
- matches: MetaMatches<MatchLoaders>;
1605
- error?: unknown;
1606
- }
1607
- /**
1608
- * A function that returns an array of data objects to use for rendering
1609
- * metadata HTML tags in a route. These tags are not rendered on descendant
1610
- * routes in the route hierarchy. In other words, they will only be rendered on
1611
- * the route in which they are exported.
1612
- *
1613
- * @param Loader - The type of the current route's loader function
1614
- * @param MatchLoaders - Mapping from a parent route's filepath to its loader
1615
- * function type
1616
- *
1617
- * Note that parent route filepaths are relative to the `app/` directory.
1618
- *
1619
- * For example, if this meta function is for `/sales/customers/$customerId`:
1620
- *
1621
- * ```ts
1622
- * // app/root.tsx
1623
- * const loader = () => ({ hello: "world" })
1624
- * export type Loader = typeof loader
1625
- *
1626
- * // app/routes/sales.tsx
1627
- * const loader = () => ({ salesCount: 1074 })
1628
- * export type Loader = typeof loader
1629
- *
1630
- * // app/routes/sales/customers.tsx
1631
- * const loader = () => ({ customerCount: 74 })
1632
- * export type Loader = typeof loader
1633
- *
1634
- * // app/routes/sales/customers/$customersId.tsx
1635
- * import type { Loader as RootLoader } from "../../../root"
1636
- * import type { Loader as SalesLoader } from "../../sales"
1637
- * import type { Loader as CustomersLoader } from "../../sales/customers"
1638
- *
1639
- * const loader = () => ({ name: "Customer name" })
1640
- *
1641
- * const meta: MetaFunction<typeof loader, {
1642
- * "root": RootLoader,
1643
- * "routes/sales": SalesLoader,
1644
- * "routes/sales/customers": CustomersLoader,
1645
- * }> = ({ data, matches }) => {
1646
- * const { name } = data
1647
- * // ^? string
1648
- * const { customerCount } = matches.find((match) => match.id === "routes/sales/customers").data
1649
- * // ^? number
1650
- * const { salesCount } = matches.find((match) => match.id === "routes/sales").data
1651
- * // ^? number
1652
- * const { hello } = matches.find((match) => match.id === "root").data
1653
- * // ^? "world"
1654
- * }
1655
- * ```
1656
- */
1657
- interface MetaFunction<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
1658
- (args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
1659
- }
1660
- type MetaDescriptor = {
1661
- charSet: "utf-8";
1662
- } | {
1663
- title: string;
1664
- } | {
1665
- name: string;
1666
- content: string;
1667
- } | {
1668
- property: string;
1669
- content: string;
1670
- } | {
1671
- httpEquiv: string;
1672
- content: string;
1673
- } | {
1674
- "script:ld+json": LdJsonObject;
1675
- } | {
1676
- tagName: "meta" | "link";
1677
- [name: string]: string;
1678
- } | {
1679
- [name: string]: unknown;
1680
- };
1681
- type LdJsonObject = {
1682
- [Key in string]: LdJsonValue;
1683
- } & {
1684
- [Key in string]?: LdJsonValue | undefined;
1685
- };
1686
- type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
1687
- type LdJsonPrimitive = string | number | boolean | null;
1688
- type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
1689
- /**
1690
- * An arbitrary object that is associated with a route.
1691
- *
1692
- * @see https://remix.run/route/handle
1693
- */
1694
- type RouteHandle = unknown;
1695
-
1696
- type ServerRouteObjectBase = {
1697
- action?: ActionFunction;
1698
- clientAction?: ClientActionFunction;
1699
- clientLoader?: ClientLoaderFunction;
1700
- default?: React.ComponentType<any>;
1701
- ErrorBoundary?: React.ComponentType<any>;
1702
- handle?: any;
1703
- headers?: HeadersFunction;
1704
- HydrateFallback?: React.ComponentType<any>;
1705
- Layout?: React.ComponentType<any>;
1706
- links?: LinksFunction;
1707
- loader?: LoaderFunction;
1708
- meta?: MetaFunction;
1709
- shouldRevalidate?: ShouldRevalidateFunction;
1710
- };
1711
- type ServerRouteObject = ServerRouteObjectBase & {
1712
- id: string;
1713
- path?: string;
1714
- lazy?: () => Promise<ServerRouteObjectBase>;
1715
- } & ({
1716
- index: true;
1717
- } | {
1718
- children?: ServerRouteObject[];
1719
- });
1720
- type RenderedRoute = {
1721
- clientAction?: ClientActionFunction;
1722
- clientLoader?: ClientLoaderFunction;
1723
- element?: React.ReactElement | false;
1724
- errorElement?: React.ReactElement;
1725
- handle?: any;
1726
- hasAction: boolean;
1727
- hasErrorBoundary: boolean;
1728
- hasLoader: boolean;
1729
- hydrateFallbackElement?: React.ReactElement;
1730
- id: string;
1731
- index?: boolean;
1732
- links?: LinksFunction;
1733
- meta?: MetaFunction;
1734
- parentId?: string;
1735
- path?: string;
1736
- shouldRevalidate?: ShouldRevalidateFunction;
1737
- };
1738
- type ServerRouteMatch = RenderedRoute & {
1739
- params: Params;
1740
- pathname: string;
1741
- pathnameBase: string;
1742
- };
1743
- type ServerRenderPayload = {
1744
- type: "render";
1745
- actionData: Record<string, any> | null;
1746
- basename?: string;
1747
- errors: Record<string, any> | null;
1748
- loaderData: Record<string, any>;
1749
- location: Location;
1750
- matches: ServerRouteMatch[];
1751
- patches?: RenderedRoute[];
1752
- nonce?: string;
1753
- };
1754
- type ServerManifestPayload = {
1755
- type: "manifest";
1756
- matches: RenderedRoute[];
1757
- patches: RenderedRoute[];
1758
- };
1759
- type ServerActionPayload = {
1760
- type: "action";
1761
- actionResult: Promise<unknown>;
1762
- rerender?: Promise<ServerRenderPayload | ServerRedirectPayload>;
1763
- };
1764
- type ServerRedirectPayload = {
1765
- type: "redirect";
1766
- status: number;
1767
- location: string;
1768
- replace: boolean;
1769
- reload: boolean;
1770
- };
1771
- type ServerPayload = ServerRenderPayload | ServerManifestPayload | ServerActionPayload | ServerRedirectPayload;
1772
- type ServerMatch = {
1773
- statusCode: number;
1774
- headers: Headers;
1775
- payload: ServerPayload;
1776
- };
1777
- type DecodeCallServerFunction = (id: string, reply: FormData | string) => Promise<() => Promise<unknown>>;
1778
- type DecodeFormActionFunction = (formData: FormData) => Promise<() => Promise<void>>;
1779
- declare function matchRSCServerRequest({ decodeCallServer, decodeFormAction, onError, request, routes, generateResponse, }: {
1780
- decodeCallServer?: DecodeCallServerFunction;
1781
- decodeFormAction?: DecodeFormActionFunction;
1782
- onError?: (error: unknown) => void;
1783
- request: Request;
1784
- routes: ServerRouteObject[];
1785
- generateResponse: (match: ServerMatch) => Response;
1786
- }): Promise<Response>;
1787
-
1788
- export { type Cookie, type CookieOptions, type CookieSignatureOptions, type DecodeCallServerFunction, type DecodeFormActionFunction, type FlashSessionData, type IsCookieFunction, type IsSessionFunction, type ServerManifestPayload, type ServerMatch, type ServerPayload, type ServerRenderPayload, type RenderedRoute as ServerRouteManifest, type ServerRouteMatch, type ServerRouteObject, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isSession, matchRSCServerRequest, matchRoutes, redirect, redirectDocument, replace };