index.js.flow 1.88 KB
Newer Older
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
// @flow strict

type TemplateStringsArray = $ReadOnlyArray<string>;

export type Level = $Values<{
	None: 0,
	Basic: 1,
	Ansi256: 2,
	TrueColor: 3
}>;

export type ChalkOptions = {|
	enabled?: boolean,
	level?: Level
|};

export type ColorSupport = {|
	level: Level,
	hasBasic: boolean,
	has256: boolean,
	has16m: boolean
|};

export interface Chalk {
	(...text: string[]): string,
	(text: TemplateStringsArray, ...placeholders: string[]): string,
	constructor(options?: ChalkOptions): Chalk,
	enabled: boolean,
	level: Level,
	rgb(r: number, g: number, b: number): Chalk,
	hsl(h: number, s: number, l: number): Chalk,
	hsv(h: number, s: number, v: number): Chalk,
	hwb(h: number, w: number, b: number): Chalk,
	bgHex(color: string): Chalk,
	bgKeyword(color: string): Chalk,
	bgRgb(r: number, g: number, b: number): Chalk,
	bgHsl(h: number, s: number, l: number): Chalk,
	bgHsv(h: number, s: number, v: number): Chalk,
	bgHwb(h: number, w: number, b: number): Chalk,
	hex(color: string): Chalk,
	keyword(color: string): Chalk,

	+reset: Chalk,
	+bold: Chalk,
	+dim: Chalk,
	+italic: Chalk,
	+underline: Chalk,
	+inverse: Chalk,
	+hidden: Chalk,
	+strikethrough: Chalk,

	+visible: Chalk,

	+black: Chalk,
	+red: Chalk,
	+green: Chalk,
	+yellow: Chalk,
	+blue: Chalk,
	+magenta: Chalk,
	+cyan: Chalk,
	+white: Chalk,
	+gray: Chalk,
	+grey: Chalk,
	+blackBright: Chalk,
	+redBright: Chalk,
	+greenBright: Chalk,
	+yellowBright: Chalk,
	+blueBright: Chalk,
	+magentaBright: Chalk,
	+cyanBright: Chalk,
	+whiteBright: Chalk,

	+bgBlack: Chalk,
	+bgRed: Chalk,
	+bgGreen: Chalk,
	+bgYellow: Chalk,
	+bgBlue: Chalk,
	+bgMagenta: Chalk,
	+bgCyan: Chalk,
	+bgWhite: Chalk,
	+bgBlackBright: Chalk,
	+bgRedBright: Chalk,
	+bgGreenBright: Chalk,
	+bgYellowBright: Chalk,
	+bgBlueBright: Chalk,
	+bgMagentaBright: Chalk,
	+bgCyanBright: Chalk,
	+bgWhiteBrigh: Chalk,

	supportsColor: ColorSupport
};

declare module.exports: Chalk;