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