-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouteModules.d.ts
106 lines (106 loc) · 3.25 KB
/
routeModules.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import type { Location } from "history";
import type { ComponentType } from "react";
import type { Params } from "react-router-dom";
import type { AppLoadContext, AppData } from "./data";
import type { LinkDescriptor } from "./links";
import type { RouteData } from "./routeData";
export interface RouteModules<RouteModule> {
[routeId: string]: RouteModule;
}
/**
* The arguments passed to ActionFunction and LoaderFunction.
*/
export interface DataFunctionArgs {
request: Request;
context: AppLoadContext;
params: Params;
}
/**
* A function that handles data mutations for a route.
*/
export interface ActionFunction {
(args: DataFunctionArgs): Promise<Response> | Response | Promise<AppData> | AppData;
}
/**
* A React component that is rendered when the server throws a Response.
*/
export declare type CatchBoundaryComponent = ComponentType<{}>;
/**
* A React component that is rendered when there is an error on a route.
*/
export declare type ErrorBoundaryComponent = ComponentType<{
error: Error;
}>;
/**
* A function that returns HTTP headers to be used for a route. These headers
* will be merged with (and take precedence over) headers from parent routes.
*/
export interface HeadersFunction {
(args: {
loaderHeaders: Headers;
parentHeaders: Headers;
actionHeaders: Headers;
}): Headers | HeadersInit;
}
/**
* A function that defines `<link>` tags to be inserted into the `<head>` of
* the document on route transitions.
*/
export interface LinksFunction {
(): LinkDescriptor[];
}
/**
* A function that loads data for a route.
*/
export interface LoaderFunction {
(args: DataFunctionArgs): Promise<Response> | Response | Promise<AppData> | AppData;
}
/**
* A function that returns an object of name + content pairs to use for
* `<meta>` tags for a route. These tags will be merged with (and take
* precedence over) tags from parent routes.
*/
export interface MetaFunction {
(args: {
data: AppData;
parentsData: RouteData;
params: Params;
location: Location;
}): HtmlMetaDescriptor;
}
/**
* A name/content pair used to render `<meta>` tags in a meta function for a
* route. The value can be either a string, which will render a single `<meta>`
* tag, or an array of strings that will render multiple tags with the same
* `name` attribute.
*/
export interface HtmlMetaDescriptor {
charset?: "utf-8";
charSet?: "utf-8";
title?: string;
[name: string]: null | string | undefined | Record<string, string> | Array<Record<string, string> | string>;
}
export declare type MetaDescriptor = HtmlMetaDescriptor;
/**
* A React component that is rendered for a route.
*/
export declare type RouteComponent = ComponentType<{}>;
/**
* An arbitrary object that is associated with a route.
*/
export declare type RouteHandle = any;
export interface EntryRouteModule {
CatchBoundary?: CatchBoundaryComponent;
ErrorBoundary?: ErrorBoundaryComponent;
default: RouteComponent;
handle?: RouteHandle;
links?: LinksFunction;
meta?: MetaFunction | HtmlMetaDescriptor;
}
export interface ServerRouteModule extends EntryRouteModule {
action?: ActionFunction;
headers?: HeadersFunction | {
[name: string]: string;
};
loader?: LoaderFunction;
}