1 | /**
|
2 | Basic foreground colors.
|
3 |
|
4 | [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
5 | */
|
6 | declare type ForegroundColor =
|
7 | | 'black'
|
8 | | 'red'
|
9 | | 'green'
|
10 | | 'yellow'
|
11 | | 'blue'
|
12 | | 'magenta'
|
13 | | 'cyan'
|
14 | | 'white'
|
15 | | 'gray'
|
16 | | 'grey'
|
17 | | 'blackBright'
|
18 | | 'redBright'
|
19 | | 'greenBright'
|
20 | | 'yellowBright'
|
21 | | 'blueBright'
|
22 | | 'magentaBright'
|
23 | | 'cyanBright'
|
24 | | 'whiteBright';
|
25 |
|
26 | /**
|
27 | Basic background colors.
|
28 |
|
29 | [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
30 | */
|
31 | declare type BackgroundColor =
|
32 | | 'bgBlack'
|
33 | | 'bgRed'
|
34 | | 'bgGreen'
|
35 | | 'bgYellow'
|
36 | | 'bgBlue'
|
37 | | 'bgMagenta'
|
38 | | 'bgCyan'
|
39 | | 'bgWhite'
|
40 | | 'bgGray'
|
41 | | 'bgGrey'
|
42 | | 'bgBlackBright'
|
43 | | 'bgRedBright'
|
44 | | 'bgGreenBright'
|
45 | | 'bgYellowBright'
|
46 | | 'bgBlueBright'
|
47 | | 'bgMagentaBright'
|
48 | | 'bgCyanBright'
|
49 | | 'bgWhiteBright';
|
50 |
|
51 | /**
|
52 | Basic colors.
|
53 |
|
54 | [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
55 | */
|
56 | declare type Color = ForegroundColor | BackgroundColor;
|
57 |
|
58 | declare type Modifiers =
|
59 | | 'reset'
|
60 | | 'bold'
|
61 | | 'dim'
|
62 | | 'italic'
|
63 | | 'underline'
|
64 | | 'inverse'
|
65 | | 'hidden'
|
66 | | 'strikethrough'
|
67 | | 'visible';
|
68 |
|
69 | declare namespace chalk {
|
70 | /**
|
71 | Levels:
|
72 | - `0` - All colors disabled.
|
73 | - `1` - Basic 16 colors support.
|
74 | - `2` - ANSI 256 colors support.
|
75 | - `3` - Truecolor 16 million colors support.
|
76 | */
|
77 | type Level = 0 | 1 | 2 | 3;
|
78 |
|
79 | interface Options {
|
80 | /**
|
81 | Specify the color support for Chalk.
|
82 |
|
83 | By default, color support is automatically detected based on the environment.
|
84 |
|
85 | Levels:
|
86 | - `0` - All colors disabled.
|
87 | - `1` - Basic 16 colors support.
|
88 | - `2` - ANSI 256 colors support.
|
89 | - `3` - Truecolor 16 million colors support.
|
90 | */
|
91 | level?: Level;
|
92 | }
|
93 |
|
94 | /**
|
95 | Return a new Chalk instance.
|
96 | */
|
97 | type Instance = new (options?: Options) => Chalk;
|
98 |
|
99 | /**
|
100 | Detect whether the terminal supports color.
|
101 | */
|
102 | interface ColorSupport {
|
103 | /**
|
104 | The color level used by Chalk.
|
105 | */
|
106 | level: Level;
|
107 |
|
108 | /**
|
109 | Return whether Chalk supports basic 16 colors.
|
110 | */
|
111 | hasBasic: boolean;
|
112 |
|
113 | /**
|
114 | Return whether Chalk supports ANSI 256 colors.
|
115 | */
|
116 | has256: boolean;
|
117 |
|
118 | /**
|
119 | Return whether Chalk supports Truecolor 16 million colors.
|
120 | */
|
121 | has16m: boolean;
|
122 | }
|
123 |
|
124 | interface ChalkFunction {
|
125 | /**
|
126 | Use a template string.
|
127 |
|
128 | @remarks Template literals are unsupported for nested calls (see [issue #341](https://github.com/chalk/chalk/issues/341))
|
129 |
|
130 | @example
|
131 | ```
|
132 | import chalk = require('chalk');
|
133 |
|
134 | log(chalk`
|
135 | CPU: {red ${cpu.totalPercent}%}
|
136 | RAM: {green ${ram.used / ram.total * 100}%}
|
137 | DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
138 | `);
|
139 | ```
|
140 | */
|
141 | (text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
142 |
|
143 | (...text: unknown[]): string;
|
144 | }
|
145 |
|
146 | interface Chalk extends ChalkFunction {
|
147 | /**
|
148 | Return a new Chalk instance.
|
149 | */
|
150 | Instance: Instance;
|
151 |
|
152 | /**
|
153 | The color support for Chalk.
|
154 |
|
155 | By default, color support is automatically detected based on the environment.
|
156 |
|
157 | Levels:
|
158 | - `0` - All colors disabled.
|
159 | - `1` - Basic 16 colors support.
|
160 | - `2` - ANSI 256 colors support.
|
161 | - `3` - Truecolor 16 million colors support.
|
162 | */
|
163 | level: Level;
|
164 |
|
165 | /**
|
166 | Use HEX value to set text color.
|
167 |
|
168 | @param color - Hexadecimal value representing the desired color.
|
169 |
|
170 | @example
|
171 | ```
|
172 | import chalk = require('chalk');
|
173 |
|
174 | chalk.hex('#DEADED');
|
175 | ```
|
176 | */
|
177 | hex(color: string): Chalk;
|
178 |
|
179 | /**
|
180 | Use keyword color value to set text color.
|
181 |
|
182 | @param color - Keyword value representing the desired color.
|
183 |
|
184 | @example
|
185 | ```
|
186 | import chalk = require('chalk');
|
187 |
|
188 | chalk.keyword('orange');
|
189 | ```
|
190 | */
|
191 | keyword(color: string): Chalk;
|
192 |
|
193 | /**
|
194 | Use RGB values to set text color.
|
195 | */
|
196 | rgb(red: number, green: number, blue: number): Chalk;
|
197 |
|
198 | /**
|
199 | Use HSL values to set text color.
|
200 | */
|
201 | hsl(hue: number, saturation: number, lightness: number): Chalk;
|
202 |
|
203 | /**
|
204 | Use HSV values to set text color.
|
205 | */
|
206 | hsv(hue: number, saturation: number, value: number): Chalk;
|
207 |
|
208 | /**
|
209 | Use HWB values to set text color.
|
210 | */
|
211 | hwb(hue: number, whiteness: number, blackness: number): Chalk;
|
212 |
|
213 | /**
|
214 | Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
|
215 |
|
216 | 30 <= code && code < 38 || 90 <= code && code < 98
|
217 | For example, 31 for red, 91 for redBright.
|
218 | */
|
219 | ansi(code: number): Chalk;
|
220 |
|
221 | /**
|
222 | Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
223 | */
|
224 | ansi256(index: number): Chalk;
|
225 |
|
226 | /**
|
227 | Use HEX value to set background color.
|
228 |
|
229 | @param color - Hexadecimal value representing the desired color.
|
230 |
|
231 | @example
|
232 | ```
|
233 | import chalk = require('chalk');
|
234 |
|
235 | chalk.bgHex('#DEADED');
|
236 | ```
|
237 | */
|
238 | bgHex(color: string): Chalk;
|
239 |
|
240 | /**
|
241 | Use keyword color value to set background color.
|
242 |
|
243 | @param color - Keyword value representing the desired color.
|
244 |
|
245 | @example
|
246 | ```
|
247 | import chalk = require('chalk');
|
248 |
|
249 | chalk.bgKeyword('orange');
|
250 | ```
|
251 | */
|
252 | bgKeyword(color: string): Chalk;
|
253 |
|
254 | /**
|
255 | Use RGB values to set background color.
|
256 | */
|
257 | bgRgb(red: number, green: number, blue: number): Chalk;
|
258 |
|
259 | /**
|
260 | Use HSL values to set background color.
|
261 | */
|
262 | bgHsl(hue: number, saturation: number, lightness: number): Chalk;
|
263 |
|
264 | /**
|
265 | Use HSV values to set background color.
|
266 | */
|
267 | bgHsv(hue: number, saturation: number, value: number): Chalk;
|
268 |
|
269 | /**
|
270 | Use HWB values to set background color.
|
271 | */
|
272 | bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
|
273 |
|
274 | /**
|
275 | Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
|
276 |
|
277 | 30 <= code && code < 38 || 90 <= code && code < 98
|
278 | For example, 31 for red, 91 for redBright.
|
279 | Use the foreground code, not the background code (for example, not 41, nor 101).
|
280 | */
|
281 | bgAnsi(code: number): Chalk;
|
282 |
|
283 | /**
|
284 | Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
285 | */
|
286 | bgAnsi256(index: number): Chalk;
|
287 |
|
288 | /**
|
289 | Modifier: Resets the current color chain.
|
290 | */
|
291 | readonly reset: Chalk;
|
292 |
|
293 | /**
|
294 | Modifier: Make text bold.
|
295 | */
|
296 | readonly bold: Chalk;
|
297 |
|
298 | /**
|
299 | Modifier: Emitting only a small amount of light.
|
300 | */
|
301 | readonly dim: Chalk;
|
302 |
|
303 | /**
|
304 | Modifier: Make text italic. (Not widely supported)
|
305 | */
|
306 | readonly italic: Chalk;
|
307 |
|
308 | /**
|
309 | Modifier: Make text underline. (Not widely supported)
|
310 | */
|
311 | readonly underline: Chalk;
|
312 |
|
313 | /**
|
314 | Modifier: Inverse background and foreground colors.
|
315 | */
|
316 | readonly inverse: Chalk;
|
317 |
|
318 | /**
|
319 | Modifier: Prints the text, but makes it invisible.
|
320 | */
|
321 | readonly hidden: Chalk;
|
322 |
|
323 | /**
|
324 | Modifier: Puts a horizontal line through the center of the text. (Not widely supported)
|
325 | */
|
326 | readonly strikethrough: Chalk;
|
327 |
|
328 | /**
|
329 | Modifier: Prints the text only when Chalk has a color support level > 0.
|
330 | Can be useful for things that are purely cosmetic.
|
331 | */
|
332 | readonly visible: Chalk;
|
333 |
|
334 | readonly black: Chalk;
|
335 | readonly red: Chalk;
|
336 | readonly green: Chalk;
|
337 | readonly yellow: Chalk;
|
338 | readonly blue: Chalk;
|
339 | readonly magenta: Chalk;
|
340 | readonly cyan: Chalk;
|
341 | readonly white: Chalk;
|
342 |
|
343 | /*
|
344 | Alias for `blackBright`.
|
345 | */
|
346 | readonly gray: Chalk;
|
347 |
|
348 | /*
|
349 | Alias for `blackBright`.
|
350 | */
|
351 | readonly grey: Chalk;
|
352 |
|
353 | readonly blackBright: Chalk;
|
354 | readonly redBright: Chalk;
|
355 | readonly greenBright: Chalk;
|
356 | readonly yellowBright: Chalk;
|
357 | readonly blueBright: Chalk;
|
358 | readonly magentaBright: Chalk;
|
359 | readonly cyanBright: Chalk;
|
360 | readonly whiteBright: Chalk;
|
361 |
|
362 | readonly bgBlack: Chalk;
|
363 | readonly bgRed: Chalk;
|
364 | readonly bgGreen: Chalk;
|
365 | readonly bgYellow: Chalk;
|
366 | readonly bgBlue: Chalk;
|
367 | readonly bgMagenta: Chalk;
|
368 | readonly bgCyan: Chalk;
|
369 | readonly bgWhite: Chalk;
|
370 |
|
371 | /*
|
372 | Alias for `bgBlackBright`.
|
373 | */
|
374 | readonly bgGray: Chalk;
|
375 |
|
376 | /*
|
377 | Alias for `bgBlackBright`.
|
378 | */
|
379 | readonly bgGrey: Chalk;
|
380 |
|
381 | readonly bgBlackBright: Chalk;
|
382 | readonly bgRedBright: Chalk;
|
383 | readonly bgGreenBright: Chalk;
|
384 | readonly bgYellowBright: Chalk;
|
385 | readonly bgBlueBright: Chalk;
|
386 | readonly bgMagentaBright: Chalk;
|
387 | readonly bgCyanBright: Chalk;
|
388 | readonly bgWhiteBright: Chalk;
|
389 | }
|
390 | }
|
391 |
|
392 | /**
|
393 | Main Chalk object that allows to chain styles together.
|
394 | Call the last one as a method with a string argument.
|
395 | Order doesn't matter, and later styles take precedent in case of a conflict.
|
396 | This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
397 | */
|
398 | declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
|
399 | supportsColor: chalk.ColorSupport | false;
|
400 | Level: chalk.Level;
|
401 | Color: Color;
|
402 | ForegroundColor: ForegroundColor;
|
403 | BackgroundColor: BackgroundColor;
|
404 | Modifiers: Modifiers;
|
405 | stderr: chalk.Chalk & {supportsColor: chalk.ColorSupport | false};
|
406 | };
|
407 |
|
408 | export = chalk;
|