-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
postcss.js.flow
100 lines (83 loc) 路 2.25 KB
/
postcss.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
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
// @flow
// (Only covers the API that Parcel uses)
// Derived from the PostCSS docs available at
// http://api.postcss.org/postcss.html.
// eslint-disable-next-line import/no-extraneous-dependencies
import typeof {SourceMapGenerator} from 'source-map';
declare module 'postcss' {
declare type NodeCallback = (Node, number) => false | void;
declare interface Node {
parent: Container;
type: 'atrule' | 'comment' | 'decl' | 'root' | 'rule';
}
declare interface Container extends Node {
each(callback: NodeCallback): false | void;
nodes: Array<Node>;
walk(callback: NodeCallback): false | void;
}
declare interface Root extends Container {}
declare class Processor {
process(
css: string | Result | Root,
opts?: ProcessOptions,
): Promise<Result>;
}
declare type ProcessOptions = $Shape<{|
from: string,
to: string,
map: MapOptions,
parser: parser,
stringifier: stringifier,
syntax: {|
parser: parser,
stringifier: stringifier,
|},
|}>;
declare type MapOptions = {|
inline?: boolean,
prev?: string | any | false | function,
sourcesContent?: boolean,
annotation?: false | string,
from?: string,
|};
declare type Parser = (
css: string,
optsopt: {|from?: string, map?: MapOptions|},
) => Root;
declare type Plugin = {|
postcss(...args: Array<any>): void,
|};
declare type pluginFunction = (root: Root, result: Result) => void;
declare type Result = {
content: string,
css: string,
map: SourceMapGenerator,
messages: Array<Message>,
opts: processOptions,
processor: Processor,
root: Root,
toString(): string,
...
};
declare type Message = {|
type: string,
plugin: string,
|};
declare type Builder = (
part: string,
node: Root,
typeopt?: 'start' | 'end',
) => void;
declare type Stringifier = (root: Root, builder: Builder) => void;
declare module.exports: {
(plugins?: Array<Plugin | PluginFunction> | Processor): Processor,
parse: Parser,
stringify: Stringifier,
root: ($Shape<Node>) => Root,
atRule: ($Shape<Node>) => Container,
comment: ($Shape<Node>) => Node,
decl: ($Shape<Node>) => Node,
rule: ($Shape<Node>) => Container,
...
};
}