chalk 4.1.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/license +1 -1
- package/package.json +33 -24
- package/readme.md +44 -68
- package/source/index.d.ts +318 -0
- package/source/index.js +69 -86
- package/source/{util.js → utilities.js} +7 -13
- package/source/vendor/ansi-styles/index.d.ts +190 -0
- package/source/vendor/ansi-styles/index.js +219 -0
- package/source/vendor/supports-color/browser.d.ts +1 -0
- package/source/vendor/supports-color/browser.js +17 -0
- package/source/vendor/supports-color/index.d.ts +55 -0
- package/source/vendor/supports-color/index.js +169 -0
- package/index.d.ts +0 -415
- package/source/templates.js +0 -134
package/license
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chalk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Terminal string styling done right",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "chalk/chalk",
|
|
7
7
|
"funding": "https://github.com/chalk/chalk?sponsor=1",
|
|
8
|
-
"
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": "./source/index.js",
|
|
10
|
+
"imports": {
|
|
11
|
+
"#ansi-styles": "./source/vendor/ansi-styles/index.js",
|
|
12
|
+
"#supports-color": {
|
|
13
|
+
"node": "./source/vendor/supports-color/index.js",
|
|
14
|
+
"default": "./source/vendor/supports-color/browser.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"types": "./source/index.d.ts",
|
|
9
18
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
19
|
+
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
|
11
20
|
},
|
|
12
21
|
"scripts": {
|
|
13
|
-
"test": "xo &&
|
|
22
|
+
"test": "xo && c8 ava && tsd",
|
|
14
23
|
"bench": "matcha benchmark.js"
|
|
15
24
|
},
|
|
16
25
|
"files": [
|
|
17
26
|
"source",
|
|
18
|
-
"index.d.ts"
|
|
27
|
+
"!source/index.test-d.ts"
|
|
19
28
|
],
|
|
20
29
|
"keywords": [
|
|
21
30
|
"color",
|
|
@@ -25,7 +34,6 @@
|
|
|
25
34
|
"console",
|
|
26
35
|
"cli",
|
|
27
36
|
"string",
|
|
28
|
-
"str",
|
|
29
37
|
"ansi",
|
|
30
38
|
"style",
|
|
31
39
|
"styles",
|
|
@@ -40,29 +48,30 @@
|
|
|
40
48
|
"command-line",
|
|
41
49
|
"text"
|
|
42
50
|
],
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"ansi-styles": "^4.1.0",
|
|
45
|
-
"supports-color": "^7.1.0"
|
|
46
|
-
},
|
|
47
51
|
"devDependencies": {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
+
"@types/node": "^16.11.10",
|
|
53
|
+
"ava": "^3.15.0",
|
|
54
|
+
"c8": "^7.10.0",
|
|
55
|
+
"color-convert": "^2.0.1",
|
|
56
|
+
"execa": "^6.0.0",
|
|
57
|
+
"log-update": "^5.0.0",
|
|
52
58
|
"matcha": "^0.7.0",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"xo": "^0.28.2"
|
|
59
|
+
"tsd": "^0.19.0",
|
|
60
|
+
"xo": "^0.47.0",
|
|
61
|
+
"yoctodelay": "^2.0.0"
|
|
57
62
|
},
|
|
58
63
|
"xo": {
|
|
59
64
|
"rules": {
|
|
60
|
-
"unicorn/prefer-string-slice": "off"
|
|
61
|
-
"unicorn/prefer-includes": "off",
|
|
62
|
-
"@typescript-eslint/member-ordering": "off",
|
|
63
|
-
"no-redeclare": "off",
|
|
64
|
-
"unicorn/string-content": "off",
|
|
65
|
-
"unicorn/better-regex": "off"
|
|
65
|
+
"unicorn/prefer-string-slice": "off"
|
|
66
66
|
}
|
|
67
|
+
},
|
|
68
|
+
"c8": {
|
|
69
|
+
"reporter": [
|
|
70
|
+
"text",
|
|
71
|
+
"lcov"
|
|
72
|
+
],
|
|
73
|
+
"exclude": [
|
|
74
|
+
"source/vendor"
|
|
75
|
+
]
|
|
67
76
|
}
|
|
68
77
|
}
|
package/readme.md
CHANGED
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
> Terminal string styling done right
|
|
11
11
|
|
|
12
|
-
[](https://codecov.io/gh/chalk/chalk)
|
|
13
|
+
[](https://www.npmjs.com/package/chalk?activeTab=dependents) [](https://www.npmjs.com/package/chalk)
|
|
14
|
+
[](https://repl.it/github/chalk/chalk)
|
|
15
|
+
[](https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15)
|
|
13
16
|
|
|
14
17
|
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
|
|
15
18
|
|
|
@@ -49,9 +52,13 @@
|
|
|
49
52
|
</div>
|
|
50
53
|
</a>
|
|
51
54
|
<br>
|
|
52
|
-
<a href="https://
|
|
55
|
+
<a href="https://strapi.io/?ref=sindresorhus">
|
|
53
56
|
<div>
|
|
54
|
-
<img src="https://sindresorhus.com/assets/thanks/
|
|
57
|
+
<img src="https://sindresorhus.com/assets/thanks/strapi-logo-white-bg.png" width="220" alt="Strapi">
|
|
58
|
+
</div>
|
|
59
|
+
<b>Strapi is the leading open-source headless CMS.</b>
|
|
60
|
+
<div>
|
|
61
|
+
<sup>It’s 100% JavaScript, fully customizable, and developer-first.</sup>
|
|
55
62
|
</div>
|
|
56
63
|
</a>
|
|
57
64
|
</p>
|
|
@@ -65,24 +72,27 @@
|
|
|
65
72
|
|
|
66
73
|
- Expressive API
|
|
67
74
|
- Highly performant
|
|
75
|
+
- No dependencies
|
|
68
76
|
- Ability to nest styles
|
|
69
77
|
- [256/Truecolor color support](#256-and-truecolor-color-support)
|
|
70
78
|
- Auto-detects color support
|
|
71
79
|
- Doesn't extend `String.prototype`
|
|
72
80
|
- Clean and focused
|
|
73
81
|
- Actively maintained
|
|
74
|
-
- [Used by ~
|
|
82
|
+
- [Used by ~76,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 26, 2021
|
|
75
83
|
|
|
76
84
|
## Install
|
|
77
85
|
|
|
78
|
-
```
|
|
79
|
-
|
|
86
|
+
```sh
|
|
87
|
+
npm install chalk
|
|
80
88
|
```
|
|
81
89
|
|
|
90
|
+
**IMPORTANT:** Chalk 5 is ESM. If you want to use Chalk with TypeScript or a build tool, you will probably want to use Chalk 4 for now. [Read more.](https://github.com/chalk/chalk/releases/tag/v5.0.0)
|
|
91
|
+
|
|
82
92
|
## Usage
|
|
83
93
|
|
|
84
94
|
```js
|
|
85
|
-
|
|
95
|
+
import chalk from 'chalk';
|
|
86
96
|
|
|
87
97
|
console.log(chalk.blue('Hello world!'));
|
|
88
98
|
```
|
|
@@ -90,7 +100,8 @@ console.log(chalk.blue('Hello world!'));
|
|
|
90
100
|
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
|
91
101
|
|
|
92
102
|
```js
|
|
93
|
-
|
|
103
|
+
import chalk from 'chalk';
|
|
104
|
+
|
|
94
105
|
const log = console.log;
|
|
95
106
|
|
|
96
107
|
// Combine styled and normal strings
|
|
@@ -119,15 +130,7 @@ RAM: ${chalk.green('40%')}
|
|
|
119
130
|
DISK: ${chalk.yellow('70%')}
|
|
120
131
|
`);
|
|
121
132
|
|
|
122
|
-
// ES2015 tagged template literal
|
|
123
|
-
log(chalk`
|
|
124
|
-
CPU: {red ${cpu.totalPercent}%}
|
|
125
|
-
RAM: {green ${ram.used / ram.total * 100}%}
|
|
126
|
-
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
|
127
|
-
`);
|
|
128
|
-
|
|
129
133
|
// Use RGB colors in terminal emulators that support it.
|
|
130
|
-
log(chalk.keyword('orange')('Yay for orange colored text!'));
|
|
131
134
|
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
|
|
132
135
|
log(chalk.hex('#DEADED').bold('Bold gray!'));
|
|
133
136
|
```
|
|
@@ -135,10 +138,10 @@ log(chalk.hex('#DEADED').bold('Bold gray!'));
|
|
|
135
138
|
Easily define your own themes:
|
|
136
139
|
|
|
137
140
|
```js
|
|
138
|
-
|
|
141
|
+
import chalk from 'chalk';
|
|
139
142
|
|
|
140
143
|
const error = chalk.bold.red;
|
|
141
|
-
const warning = chalk.
|
|
144
|
+
const warning = chalk.hex('#FFA500'); // Orange color
|
|
142
145
|
|
|
143
146
|
console.log(error('Error!'));
|
|
144
147
|
console.log(warning('Warning!'));
|
|
@@ -147,6 +150,8 @@ console.log(warning('Warning!'));
|
|
|
147
150
|
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
|
|
148
151
|
|
|
149
152
|
```js
|
|
153
|
+
import chalk from 'chalk';
|
|
154
|
+
|
|
150
155
|
const name = 'Sindre';
|
|
151
156
|
console.log(chalk.green('Hello %s'), name);
|
|
152
157
|
//=> 'Hello Sindre'
|
|
@@ -171,7 +176,9 @@ Color support is automatically detected, but you can override it by setting the
|
|
|
171
176
|
If you need to change this in a reusable module, create a new instance:
|
|
172
177
|
|
|
173
178
|
```js
|
|
174
|
-
|
|
179
|
+
import {Chalk} from 'chalk';
|
|
180
|
+
|
|
181
|
+
const customChalk = new Chalk({level: 0});
|
|
175
182
|
```
|
|
176
183
|
|
|
177
184
|
| Level | Description |
|
|
@@ -181,7 +188,7 @@ const ctx = new chalk.Instance({level: 0});
|
|
|
181
188
|
| `2` | 256 color support |
|
|
182
189
|
| `3` | Truecolor support (16 million colors) |
|
|
183
190
|
|
|
184
|
-
###
|
|
191
|
+
### supportsColor
|
|
185
192
|
|
|
186
193
|
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
|
|
187
194
|
|
|
@@ -189,23 +196,24 @@ Can be overridden by the user with the flags `--color` and `--no-color`. For sit
|
|
|
189
196
|
|
|
190
197
|
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
|
191
198
|
|
|
192
|
-
###
|
|
199
|
+
### chalkStderr and supportsColorStderr
|
|
193
200
|
|
|
194
|
-
`
|
|
201
|
+
`chalkStderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `supportsColor` apply to this too. `supportsColorStderr` is exposed for convenience.
|
|
195
202
|
|
|
196
203
|
## Styles
|
|
197
204
|
|
|
198
205
|
### Modifiers
|
|
199
206
|
|
|
200
|
-
- `reset` -
|
|
201
|
-
- `bold` - Make text bold.
|
|
202
|
-
- `dim` -
|
|
203
|
-
- `italic` - Make text italic. *(Not widely supported)*
|
|
204
|
-
- `underline` -
|
|
205
|
-
- `
|
|
206
|
-
- `
|
|
207
|
+
- `reset` - Reset the current style.
|
|
208
|
+
- `bold` - Make the text bold.
|
|
209
|
+
- `dim` - Make the text have lower opacity.
|
|
210
|
+
- `italic` - Make the text italic. *(Not widely supported)*
|
|
211
|
+
- `underline` - Put a horizontal line below the text. *(Not widely supported)*
|
|
212
|
+
- `overline` - Put a horizontal line above the text. *(Not widely supported)*
|
|
213
|
+
- `inverse`- Invert background and foreground colors.
|
|
214
|
+
- `hidden` - Print the text but make it invisible.
|
|
207
215
|
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
|
|
208
|
-
- `visible`-
|
|
216
|
+
- `visible`- Print the text only when Chalk has a color level above zero. Can be useful for things that are purely cosmetic.
|
|
209
217
|
|
|
210
218
|
### Colors
|
|
211
219
|
|
|
@@ -245,36 +253,6 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
|
|
|
245
253
|
- `bgCyanBright`
|
|
246
254
|
- `bgWhiteBright`
|
|
247
255
|
|
|
248
|
-
## Tagged template literal
|
|
249
|
-
|
|
250
|
-
Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
|
|
251
|
-
|
|
252
|
-
```js
|
|
253
|
-
const chalk = require('chalk');
|
|
254
|
-
|
|
255
|
-
const miles = 18;
|
|
256
|
-
const calculateFeet = miles => miles * 5280;
|
|
257
|
-
|
|
258
|
-
console.log(chalk`
|
|
259
|
-
There are {bold 5280 feet} in a mile.
|
|
260
|
-
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
|
|
261
|
-
`);
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
|
|
265
|
-
|
|
266
|
-
Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
|
|
267
|
-
|
|
268
|
-
```js
|
|
269
|
-
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
|
|
270
|
-
console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
|
|
271
|
-
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
|
|
275
|
-
|
|
276
|
-
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
|
|
277
|
-
|
|
278
256
|
## 256 and Truecolor color support
|
|
279
257
|
|
|
280
258
|
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
|
|
@@ -284,26 +262,23 @@ Colors are downsampled from 16 million RGB values to an ANSI color format that i
|
|
|
284
262
|
Examples:
|
|
285
263
|
|
|
286
264
|
- `chalk.hex('#DEADED').underline('Hello, world!')`
|
|
287
|
-
- `chalk.keyword('orange')('Some orange text')`
|
|
288
265
|
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
|
|
289
266
|
|
|
290
|
-
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `
|
|
267
|
+
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `hex` for foreground colors and `bgHex` for background colors).
|
|
291
268
|
|
|
292
269
|
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
|
|
293
|
-
- `chalk.bgKeyword('orange')('Some orange text')`
|
|
294
270
|
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
|
|
295
271
|
|
|
296
272
|
The following color models can be used:
|
|
297
273
|
|
|
298
274
|
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
|
|
299
275
|
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
|
300
|
-
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
|
|
301
|
-
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
|
|
302
|
-
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
|
|
303
|
-
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
|
|
304
|
-
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
|
|
305
276
|
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
|
306
277
|
|
|
278
|
+
## Browser support
|
|
279
|
+
|
|
280
|
+
Since Chrome 69, ANSI escape codes are natively supported in the developer console.
|
|
281
|
+
|
|
307
282
|
## Windows
|
|
308
283
|
|
|
309
284
|
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
|
@@ -320,6 +295,7 @@ The maintainers of chalk and thousands of other packages are working with Tideli
|
|
|
320
295
|
|
|
321
296
|
## Related
|
|
322
297
|
|
|
298
|
+
- [chalk-template](https://github.com/chalk/chalk-template) - [Tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) support for this module
|
|
323
299
|
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
|
|
324
300
|
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
|
|
325
301
|
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
|
|
@@ -0,0 +1,318 @@
|
|
|
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;
|