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