-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
posthtml.js.flow
57 lines (50 loc) 路 1.44 KB
/
posthtml.js.flow
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
// @flow
// Derived from the PostHTML sources available at
// https://github.com/posthtml/posthtml-parser/blob/41df54c0ae3061cc6f417826676fda5a3d4806c0/index.js
// https://github.com/posthtml/posthtml/blob/881d4a5b170109789a5245a379229afb4793e21a/lib/index.js
// https://github.com/posthtml/posthtml/blob/881d4a5b170109789a5245a379229afb4793e21a/lib/api.js
// which is licensed MIT.
declare module 'posthtml' {
declare type PostHTMLNode = {
tag: string,
attrs?: {[string]: string, ...},
content?: Array<string | PostHTMLNode>,
location?: {
start: {|line: number, column: number|},
end: {|line: number, column: number|},
...
},
...
};
declare type PostHTMLTree = Array<PostHTMLNode>;
declare type PostHTMLOptions = {
sync: Boolean,
skipParse: Boolean,
...
};
declare type PostHTMLMessage = {
type: 'dependency',
file: string,
...
};
declare var walk: (fn: (node: PostHTMLNode) => PostHTMLNode | PostHTMLNode[]) => void;
declare var process: (
tree: PostHTMLTree | string,
options: ?PostHTMLOptions,
) => Promise<{
html: string,
tree: PostHTMLTree,
messages: Array<PostHTMLMessage>,
...
}>;
declare class Api {
static walk: typeof walk;
walk: typeof walk;
process: typeof process;
}
declare class PostHTML extends Api {
name: string;
version: number;
}
declare module.exports: (plugins: ?Array<Function>) => PostHTML;
}