forked from parcel-bundler/parcel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathless.js.flow
97 lines (84 loc) · 2.53 KB
/
less.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
// @flow
// These types are much more than what Parcel is currently using, and much less
// than a complete typing of Less. The cutoff was pretty arbitrary; I tried to
// err on the side of inclusion for class members and exclusion for everything
// else, but ultimately there's no principle for what's in and what's out of the
// bits that Parcel doesn't need.
declare module 'less' {
declare type FileInfo = {|
rewriteUrls?: boolean,
filename: string,
rootpath: string,
currentDirectory: string,
rootFilename: string,
entryPath: string,
reference?: boolean,
|};
declare type Context = {...};
declare type Visitor = {
visit(value: Node): Node,
...
};
// Derived manually from
// https://github.com/less/less.js/blob/2c5e4dd9b9fbe6e5a4ef0c57c827e1ac3443ef0c/packages/less/src/less/tree/node.js
declare class Node {
parent: ?Node;
visibilityBlocks: ?number;
nodeVisible: ?boolean;
rootNode: ?Node;
parsed: ?boolean;
+currentFileInfo: FileInfo;
+index: number;
setParent(nodes: Node | Array<Node>, parent: Node): void;
getIndex(): number;
fileInfo(): FileInfo;
isRulesetLike(): boolean;
toCSS(context: Context): string;
genCSS(context: Context, output: mixed): void;
accept(visitor: Visitor): void;
eval(): mixed;
fround(context: Context, value: number): number;
blocksVisibility(): boolean;
addVisibilityBlock(): void;
removeVisibilityBlock(): void;
ensureVisibility(): void;
ensureInvisibility(): void;
isVisible(): ?boolean;
visibilityInfo(): {|visibilityBlocks: ?number, nodeVisible: ?boolean|};
copyVisibilityInfo(info: {
visibilityBlocks: ?number,
nodeVisible: ?boolean,
...
}): void;
}
// Derived manually from
// https://github.com/less/less.js/blob/2c5e4dd9b9fbe6e5a4ef0c57c827e1ac3443ef0c/packages/less/src/less/tree/url.js
declare class URL extends Node {
value: Node;
isEvald: boolean;
}
// This is very ad-hoc, based on current Parcel usage instead of the actual
// class in Less.
declare class visitors$Visitor {
constructor({
visitUrl?: (node: URL) => Node,
...
}): visitors$Visitor;
visit(node: Node): Node;
run?: Node => Node;
}
// Obviously an extremely incomplete type definition.
declare module.exports: {
tree: {
Node: typeof Node,
URL: typeof URL,
...
},
visitors: {
Visitor: typeof visitors$Visitor,
...
},
render(string, any): Promise<{|map: string, css: string|}>,
...
};
}