1 | // TODO: Make it this when TS suports that.
|
2 | // import {ColorInfo, ColorSupportLevel} from '#supports-color';
|
3 | import {ColorInfo, ColorSupportLevel} from './vendor/supports-color/index.js';
|
4 |
|
5 | /**
|
6 | Basic foreground colors.
|
7 |
|
8 | [More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
9 | */
|
10 | export type ForegroundColor =
|
11 | | 'black'
|
12 | | 'red'
|
13 | | 'green'
|
14 | | 'yellow'
|
15 | | 'blue'
|
16 | | 'magenta'
|
17 | | 'cyan'
|
18 | | 'white'
|
19 | | 'gray'
|
20 | | 'grey'
|
21 | | 'blackBright'
|
22 | | 'redBright'
|
23 | | 'greenBright'
|
24 | | 'yellowBright'
|
25 | | 'blueBright'
|
26 | | 'magentaBright'
|
27 | | 'cyanBright'
|
28 | | 'whiteBright';
|
29 |
|
30 | /**
|
31 | Basic background colors.
|
32 |
|
33 | [More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
34 | */
|
35 | export type BackgroundColor =
|
36 | | 'bgBlack'
|
37 | | 'bgRed'
|
38 | | 'bgGreen'
|
39 | | 'bgYellow'
|
40 | | 'bgBlue'
|
41 | | 'bgMagenta'
|
42 | | 'bgCyan'
|
43 | | 'bgWhite'
|
44 | | 'bgGray'
|
45 | | 'bgGrey'
|
46 | | 'bgBlackBright'
|
47 | | 'bgRedBright'
|
48 | | 'bgGreenBright'
|
49 | | 'bgYellowBright'
|
50 | | 'bgBlueBright'
|
51 | | 'bgMagentaBright'
|
52 | | 'bgCyanBright'
|
53 | | 'bgWhiteBright';
|
54 |
|
55 | /**
|
56 | Basic colors.
|
57 |
|
58 | [More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
59 | */
|
60 | export type Color = ForegroundColor | BackgroundColor;
|
61 |
|
62 | export type Modifiers =
|
63 | | 'reset'
|
64 | | 'bold'
|
65 | | 'dim'
|
66 | | 'italic'
|
67 | | 'underline'
|
68 | | 'overline'
|
69 | | 'inverse'
|
70 | | 'hidden'
|
71 | | 'strikethrough'
|
72 | | 'visible';
|
73 |
|
74 | export interface Options {
|
75 | /**
|
76 | Specify the color support for Chalk.
|
77 |
|
78 | By default, color support is automatically detected based on the environment.
|
79 |
|
80 | Levels:
|
81 | - `0` - All colors disabled.
|
82 | - `1` - Basic 16 colors support.
|
83 | - `2` - ANSI 256 colors support.
|
84 | - `3` - Truecolor 16 million colors support.
|
85 | */
|
86 | readonly level?: ColorSupportLevel;
|
87 | }
|
88 |
|
89 | /**
|
90 | Return a new Chalk instance.
|
91 | */
|
92 | export const Chalk: new (options?: Options) => ChalkInstance; // eslint-disable-line @typescript-eslint/naming-convention
|
93 |
|
94 | export interface ChalkInstance {
|
95 | (...text: unknown[]): string;
|
96 |
|
97 | /**
|
98 | The color support for Chalk.
|
99 |
|
100 | By default, color support is automatically detected based on the environment.
|
101 |
|
102 | Levels:
|
103 | - `0` - All colors disabled.
|
104 | - `1` - Basic 16 colors support.
|
105 | - `2` - ANSI 256 colors support.
|
106 | - `3` - Truecolor 16 million colors support.
|
107 | */
|
108 | level: ColorSupportLevel;
|
109 |
|
110 | /**
|
111 | Use RGB values to set text color.
|
112 |
|
113 | @example
|
114 | ```
|
115 | import chalk from 'chalk';
|
116 |
|
117 | chalk.rgb(222, 173, 237);
|
118 | ```
|
119 | */
|
120 | rgb: (red: number, green: number, blue: number) => this;
|
121 |
|
122 | /**
|
123 | Use HEX value to set text color.
|
124 |
|
125 | @param color - Hexadecimal value representing the desired color.
|
126 |
|
127 | @example
|
128 | ```
|
129 | import chalk from 'chalk';
|
130 |
|
131 | chalk.hex('#DEADED');
|
132 | ```
|
133 | */
|
134 | hex: (color: string) => this;
|
135 |
|
136 | /**
|
137 | Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
138 |
|
139 | @example
|
140 | ```
|
141 | import chalk from 'chalk';
|
142 |
|
143 | chalk.ansi256(201);
|
144 | ```
|
145 | */
|
146 | ansi256: (index: number) => this;
|
147 |
|
148 | /**
|
149 | Use RGB values to set background color.
|
150 |
|
151 | @example
|
152 | ```
|
153 | import chalk from 'chalk';
|
154 |
|
155 | chalk.bgRgb(222, 173, 237);
|
156 | ```
|
157 | */
|
158 | bgRgb: (red: number, green: number, blue: number) => this;
|
159 |
|
160 | /**
|
161 | Use HEX value to set background color.
|
162 |
|
163 | @param color - Hexadecimal value representing the desired color.
|
164 |
|
165 | @example
|
166 | ```
|
167 | import chalk from 'chalk';
|
168 |
|
169 | chalk.bgHex('#DEADED');
|
170 | ```
|
171 | */
|
172 | bgHex: (color: string) => this;
|
173 |
|
174 | /**
|
175 | Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
176 |
|
177 | @example
|
178 | ```
|
179 | import chalk from 'chalk';
|
180 |
|
181 | chalk.bgAnsi256(201);
|
182 | ```
|
183 | */
|
184 | bgAnsi256: (index: number) => this;
|
185 |
|
186 | /**
|
187 | Modifier: Reset the current style.
|
188 | */
|
189 | readonly reset: this;
|
190 |
|
191 | /**
|
192 | Modifier: Make the text bold.
|
193 | */
|
194 | readonly bold: this;
|
195 |
|
196 | /**
|
197 | Modifier: Make the text have lower opacity.
|
198 | */
|
199 | readonly dim: this;
|
200 |
|
201 | /**
|
202 | Modifier: Make the text italic. *(Not widely supported)*
|
203 | */
|
204 | readonly italic: this;
|
205 |
|
206 | /**
|
207 | Modifier: Put a horizontal line below the text. *(Not widely supported)*
|
208 | */
|
209 | readonly underline: this;
|
210 |
|
211 | /**
|
212 | Modifier: Put a horizontal line above the text. *(Not widely supported)*
|
213 | */
|
214 | readonly overline: this;
|
215 |
|
216 | /**
|
217 | Modifier: Invert background and foreground colors.
|
218 | */
|
219 | readonly inverse: this;
|
220 |
|
221 | /**
|
222 | Modifier: Print the text but make it invisible.
|
223 | */
|
224 | readonly hidden: this;
|
225 |
|
226 | /**
|
227 | Modifier: Puts a horizontal line through the center of the text. *(Not widely supported)*
|
228 | */
|
229 | readonly strikethrough: this;
|
230 |
|
231 | /**
|
232 | Modifier: Print the text only when Chalk has a color level above zero.
|
233 |
|
234 | Can be useful for things that are purely cosmetic.
|
235 | */
|
236 | readonly visible: this;
|
237 |
|
238 | readonly black: this;
|
239 | readonly red: this;
|
240 | readonly green: this;
|
241 | readonly yellow: this;
|
242 | readonly blue: this;
|
243 | readonly magenta: this;
|
244 | readonly cyan: this;
|
245 | readonly white: this;
|
246 |
|
247 | /*
|
248 | Alias for `blackBright`.
|
249 | */
|
250 | readonly gray: this;
|
251 |
|
252 | /*
|
253 | Alias for `blackBright`.
|
254 | */
|
255 | readonly grey: this;
|
256 |
|
257 | readonly blackBright: this;
|
258 | readonly redBright: this;
|
259 | readonly greenBright: this;
|
260 | readonly yellowBright: this;
|
261 | readonly blueBright: this;
|
262 | readonly magentaBright: this;
|
263 | readonly cyanBright: this;
|
264 | readonly whiteBright: this;
|
265 |
|
266 | readonly bgBlack: this;
|
267 | readonly bgRed: this;
|
268 | readonly bgGreen: this;
|
269 | readonly bgYellow: this;
|
270 | readonly bgBlue: this;
|
271 | readonly bgMagenta: this;
|
272 | readonly bgCyan: this;
|
273 | readonly bgWhite: this;
|
274 |
|
275 | /*
|
276 | Alias for `bgBlackBright`.
|
277 | */
|
278 | readonly bgGray: this;
|
279 |
|
280 | /*
|
281 | Alias for `bgBlackBright`.
|
282 | */
|
283 | readonly bgGrey: this;
|
284 |
|
285 | readonly bgBlackBright: this;
|
286 | readonly bgRedBright: this;
|
287 | readonly bgGreenBright: this;
|
288 | readonly bgYellowBright: this;
|
289 | readonly bgBlueBright: this;
|
290 | readonly bgMagentaBright: this;
|
291 | readonly bgCyanBright: this;
|
292 | readonly bgWhiteBright: this;
|
293 | }
|
294 |
|
295 | /**
|
296 | Main Chalk object that allows to chain styles together.
|
297 |
|
298 | Call the last one as a method with a string argument.
|
299 |
|
300 | Order doesn't matter, and later styles take precedent in case of a conflict.
|
301 |
|
302 | This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
303 | */
|
304 | declare const chalk: ChalkInstance;
|
305 |
|
306 | export const supportsColor: ColorInfo;
|
307 |
|
308 | export const chalkStderr: typeof chalk;
|
309 | export const supportsColorStderr: typeof supportsColor;
|
310 |
|
311 | export {
|
312 | ColorInfo,
|
313 | ColorSupport,
|
314 | ColorSupportLevel,
|
315 | // } from '#supports-color';
|
316 | } from './vendor/supports-color/index.js';
|
317 |
|
318 | export default chalk;
|