-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathrouteModules.ts
56 lines (49 loc) · 1.71 KB
/
routeModules.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
import type { ActionFunction, LoaderFunction } from "../router/utils";
import type {
ClientActionFunction,
ClientLoaderFunction,
LinksFunction,
MetaFunction,
} from "../dom/ssr/routeModules";
export interface RouteModules<RouteModule> {
[routeId: string]: RouteModule | undefined;
}
export type HeadersArgs = {
loaderHeaders: Headers;
parentHeaders: Headers;
actionHeaders: Headers;
errorHeaders: Headers | undefined;
};
/**
* 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: HeadersArgs): Headers | HeadersInit;
}
type LdJsonObject = { [Key in string]: LdJsonValue } & {
[Key in string]?: LdJsonValue | undefined;
};
type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
type LdJsonPrimitive = string | number | boolean | null;
type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
/**
* An arbitrary object that is associated with a route.
*/
export type RouteHandle = unknown;
export interface EntryRouteModule {
clientAction?: ClientActionFunction;
clientLoader?: ClientLoaderFunction;
ErrorBoundary?: any; // Weakly typed because server-runtime is not React-aware
HydrateFallback?: any; // Weakly typed because server-runtime is not React-aware
Layout?: any; // Weakly typed because server-runtime is not React-aware
default: any; // Weakly typed because server-runtime is not React-aware
handle?: RouteHandle;
links?: LinksFunction;
meta?: MetaFunction;
}
export interface ServerRouteModule extends EntryRouteModule {
action?: ActionFunction;
headers?: HeadersFunction | { [name: string]: string };
loader?: LoaderFunction;
}