-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.d.ts
130 lines (123 loc) · 3.12 KB
/
index.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import type {VFileMessage} from 'vfile-message'
export {deadOrAlive, defaultAnchorAllowlist, defaultSleep} from './lib/index.js'
/**
* Allow extra anchors.
* The first item is a regular expression to match URLs (origin and path,
* so without search or hash),
* and the second item is a regular expression to match hashes (without `#`).
* When both match,
* the hash is allowed.
*/
export type AnchorAllow = [url: RegExp, anchor: RegExp]
/**
* Configuration.
*/
export interface Options {
/**
* Allow anchors (default: `defaultAnchorAllowlist`);
* each tuple is checked to match URLs (origin and path,
* so without search or hash),
* and then to match hashes (without `#`);
* when both match,
* the hash is allowed,
* and no `missing-anchor` error is used.
*/
anchorAllowlist?: ReadonlyArray<Readonly<AnchorAllow>> | null | undefined
/**
* Check whether URL hashes point to elements (default: `true`).
*/
checkAnchor?: boolean | null | undefined
/**
* Find URLs in the final resource (default: `true`);
* currently applies to HTML.
*/
findUrls?: boolean | null | undefined
/**
* Follow HTML redirects (default: `true`);
* a `<meta content=0;to http-equiv=refresh>` can be useful for static sites
* such as those on GH pages.
*/
followMetaHttpEquiv?: boolean | null | undefined
/**
* Inclusive maximum redirects to follow (default: `5`).
*/
maxRedirects?: number | null | undefined
/**
* Inclusive maximum number to try again on failures (default: `1`).
*/
maxRetries?: number | null | undefined
/**
* Accept `user-content-` prefix in `id` on elements (default: `true`).
*/
resolveClobberPrefix?: boolean | null | undefined
/**
* Calculate miliseconds to sleep between tries (default: `defaultSleep`).
*/
sleep?: Sleep | null | undefined
/**
* Timeout for HTTP request in miliseconds (default: `3000`).
*/
timeout?: number | null | undefined
/**
* User agent (default: `'Mozilla/5.0 … Safari/537.36'`, a modern Chrome on macOS user agent).
*/
userAgent?: string | null | undefined
}
/**
* Result.
*/
interface ResultAlive {
/**
* Messages where the first is a fatal error when dead.
*/
messages: Array<VFileMessage>
/**
* Whether all redirects were permanent.
*/
permanent: boolean | undefined
/**
* Status.
*/
status: 'alive'
/**
* Final URL if alive.
*/
url: string
/**
* Further URLs if `findUrls: true` and the resource was HTML.
*/
urls: Set<string> | undefined
}
/**
* Result.
*/
interface ResultDead {
/**
* Messages where the first is a fatal error when dead.
*/
messages: [VFileMessage, ...Array<VFileMessage>]
/**
* Whether all redirects were permanent.
*/
permanent: boolean | undefined
/**
* Status.
*/
status: 'dead'
/**
* Final URL if alive.
*/
url: undefined
/**
* Further URLs if `findUrls: true` and the resource was HTML.
*/
urls: Set<string> | undefined
}
/**
* Result.
*/
export type Result = ResultAlive | ResultDead
/**
* Calculate miliseconds to sleep between tries.
*/
export type Sleep = (retries: number) => number