ansi-styles 4.1.0 → 4.2.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/index.d.ts +197 -0
- package/index.js +6 -5
- package/package.json +8 -4
- package/readme.md +11 -0
package/index.d.ts
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
import * as cssColors from 'color-name';
|
2
|
+
|
3
|
+
declare namespace ansiStyles {
|
4
|
+
interface ColorConvert {
|
5
|
+
/**
|
6
|
+
The RGB color space.
|
7
|
+
|
8
|
+
@param red - (`0`-`255`)
|
9
|
+
@param green - (`0`-`255`)
|
10
|
+
@param blue - (`0`-`255`)
|
11
|
+
*/
|
12
|
+
rgb(red: number, green: number, blue: number): string;
|
13
|
+
|
14
|
+
/**
|
15
|
+
The RGB HEX color space.
|
16
|
+
|
17
|
+
@param hex - A hexadecimal string containing RGB data.
|
18
|
+
*/
|
19
|
+
hex(hex: string): string;
|
20
|
+
|
21
|
+
/**
|
22
|
+
@param keyword - A CSS color name.
|
23
|
+
*/
|
24
|
+
keyword(keyword: keyof typeof cssColors): string;
|
25
|
+
|
26
|
+
/**
|
27
|
+
The HSL color space.
|
28
|
+
|
29
|
+
@param hue - (`0`-`360`)
|
30
|
+
@param saturation - (`0`-`100`)
|
31
|
+
@param lightness - (`0`-`100`)
|
32
|
+
*/
|
33
|
+
hsl(hue: number, saturation: number, lightness: number): string;
|
34
|
+
|
35
|
+
/**
|
36
|
+
The HSV color space.
|
37
|
+
|
38
|
+
@param hue - (`0`-`360`)
|
39
|
+
@param saturation - (`0`-`100`)
|
40
|
+
@param value - (`0`-`100`)
|
41
|
+
*/
|
42
|
+
hsv(hue: number, saturation: number, value: number): string;
|
43
|
+
|
44
|
+
/**
|
45
|
+
The HSV color space.
|
46
|
+
|
47
|
+
@param hue - (`0`-`360`)
|
48
|
+
@param whiteness - (`0`-`100`)
|
49
|
+
@param blackness - (`0`-`100`)
|
50
|
+
*/
|
51
|
+
hwb(hue: number, whiteness: number, blackness: number): string;
|
52
|
+
|
53
|
+
/**
|
54
|
+
Use a [4-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4-bit) to set text color.
|
55
|
+
*/
|
56
|
+
ansi(ansi: number): string;
|
57
|
+
|
58
|
+
/**
|
59
|
+
Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
60
|
+
*/
|
61
|
+
ansi256(ansi: number): string;
|
62
|
+
}
|
63
|
+
|
64
|
+
interface CSPair {
|
65
|
+
/**
|
66
|
+
The ANSI terminal control sequence for starting this style.
|
67
|
+
*/
|
68
|
+
readonly open: string;
|
69
|
+
|
70
|
+
/**
|
71
|
+
The ANSI terminal control sequence for ending this style.
|
72
|
+
*/
|
73
|
+
readonly close: string;
|
74
|
+
}
|
75
|
+
|
76
|
+
interface ColorBase {
|
77
|
+
readonly ansi: ColorConvert;
|
78
|
+
readonly ansi256: ColorConvert;
|
79
|
+
readonly ansi16m: ColorConvert;
|
80
|
+
|
81
|
+
/**
|
82
|
+
The ANSI terminal control sequence for ending this color.
|
83
|
+
*/
|
84
|
+
readonly close: string;
|
85
|
+
}
|
86
|
+
|
87
|
+
interface Modifier {
|
88
|
+
/**
|
89
|
+
Resets the current color chain.
|
90
|
+
*/
|
91
|
+
readonly reset: CSPair;
|
92
|
+
|
93
|
+
/**
|
94
|
+
Make text bold.
|
95
|
+
*/
|
96
|
+
readonly bold: CSPair;
|
97
|
+
|
98
|
+
/**
|
99
|
+
Emitting only a small amount of light.
|
100
|
+
*/
|
101
|
+
readonly dim: CSPair;
|
102
|
+
|
103
|
+
/**
|
104
|
+
Make text italic. (Not widely supported)
|
105
|
+
*/
|
106
|
+
readonly italic: CSPair;
|
107
|
+
|
108
|
+
/**
|
109
|
+
Make text underline. (Not widely supported)
|
110
|
+
*/
|
111
|
+
readonly underline: CSPair;
|
112
|
+
|
113
|
+
/**
|
114
|
+
Inverse background and foreground colors.
|
115
|
+
*/
|
116
|
+
readonly inverse: CSPair;
|
117
|
+
|
118
|
+
/**
|
119
|
+
Prints the text, but makes it invisible.
|
120
|
+
*/
|
121
|
+
readonly hidden: CSPair;
|
122
|
+
|
123
|
+
/**
|
124
|
+
Puts a horizontal line through the center of the text. (Not widely supported)
|
125
|
+
*/
|
126
|
+
readonly strikethrough: CSPair;
|
127
|
+
}
|
128
|
+
|
129
|
+
interface ForegroundColor {
|
130
|
+
readonly black: CSPair;
|
131
|
+
readonly red: CSPair;
|
132
|
+
readonly green: CSPair;
|
133
|
+
readonly yellow: CSPair;
|
134
|
+
readonly blue: CSPair;
|
135
|
+
readonly cyan: CSPair;
|
136
|
+
readonly magenta: CSPair;
|
137
|
+
readonly white: CSPair;
|
138
|
+
|
139
|
+
/**
|
140
|
+
Alias for `blackBright`.
|
141
|
+
*/
|
142
|
+
readonly gray: CSPair;
|
143
|
+
|
144
|
+
/**
|
145
|
+
Alias for `blackBright`.
|
146
|
+
*/
|
147
|
+
readonly grey: CSPair;
|
148
|
+
|
149
|
+
readonly blackBright: CSPair;
|
150
|
+
readonly redBright: CSPair;
|
151
|
+
readonly greenBright: CSPair;
|
152
|
+
readonly yellowBright: CSPair;
|
153
|
+
readonly blueBright: CSPair;
|
154
|
+
readonly cyanBright: CSPair;
|
155
|
+
readonly magentaBright: CSPair;
|
156
|
+
readonly whiteBright: CSPair;
|
157
|
+
}
|
158
|
+
|
159
|
+
interface BackgroundColor {
|
160
|
+
readonly bgBlack: CSPair;
|
161
|
+
readonly bgRed: CSPair;
|
162
|
+
readonly bgGreen: CSPair;
|
163
|
+
readonly bgYellow: CSPair;
|
164
|
+
readonly bgBlue: CSPair;
|
165
|
+
readonly bgCyan: CSPair;
|
166
|
+
readonly bgMagenta: CSPair;
|
167
|
+
readonly bgWhite: CSPair;
|
168
|
+
|
169
|
+
/**
|
170
|
+
Alias for `bgBlackBright`.
|
171
|
+
*/
|
172
|
+
readonly bgGray: CSPair;
|
173
|
+
|
174
|
+
/**
|
175
|
+
Alias for `bgBlackBright`.
|
176
|
+
*/
|
177
|
+
readonly bgGrey: CSPair;
|
178
|
+
|
179
|
+
readonly bgBlackBright: CSPair;
|
180
|
+
readonly bgRedBright: CSPair;
|
181
|
+
readonly bgGreenBright: CSPair;
|
182
|
+
readonly bgYellowBright: CSPair;
|
183
|
+
readonly bgBlueBright: CSPair;
|
184
|
+
readonly bgCyanBright: CSPair;
|
185
|
+
readonly bgMagentaBright: CSPair;
|
186
|
+
readonly bgWhiteBright: CSPair;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
declare const ansiStyles: {
|
191
|
+
readonly modifier: ansiStyles.Modifier;
|
192
|
+
readonly color: ansiStyles.ForegroundColor & ansiStyles.ColorBase;
|
193
|
+
readonly bgColor: ansiStyles.BackgroundColor & ansiStyles.ColorBase;
|
194
|
+
readonly codes: ReadonlyMap<number, number>;
|
195
|
+
} & ansiStyles.BackgroundColor & ansiStyles.ForegroundColor & ansiStyles.Modifier;
|
196
|
+
|
197
|
+
export = ansiStyles;
|
package/index.js
CHANGED
@@ -36,6 +36,7 @@ const setLazyProperty = (object, property, get) => {
|
|
36
36
|
});
|
37
37
|
};
|
38
38
|
|
39
|
+
/** @type {typeof import('color-convert')} */
|
39
40
|
let colorConvert;
|
40
41
|
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
41
42
|
if (colorConvert === undefined) {
|
@@ -135,13 +136,13 @@ function assembleStyles() {
|
|
135
136
|
value: group,
|
136
137
|
enumerable: false
|
137
138
|
});
|
138
|
-
|
139
|
-
Object.defineProperty(styles, 'codes', {
|
140
|
-
value: codes,
|
141
|
-
enumerable: false
|
142
|
-
});
|
143
139
|
}
|
144
140
|
|
141
|
+
Object.defineProperty(styles, 'codes', {
|
142
|
+
value: codes,
|
143
|
+
enumerable: false
|
144
|
+
});
|
145
|
+
|
145
146
|
styles.color.close = '\u001B[39m';
|
146
147
|
styles.bgColor.close = '\u001B[49m';
|
147
148
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ansi-styles",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.2.0",
|
4
4
|
"description": "ANSI escape codes for styling strings in the terminal",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": "chalk/ansi-styles",
|
@@ -13,11 +13,12 @@
|
|
13
13
|
"node": ">=8"
|
14
14
|
},
|
15
15
|
"scripts": {
|
16
|
-
"test": "xo && ava",
|
16
|
+
"test": "xo && ava && tsd",
|
17
17
|
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
|
18
18
|
},
|
19
19
|
"files": [
|
20
|
-
"index.js"
|
20
|
+
"index.js",
|
21
|
+
"index.d.ts"
|
21
22
|
],
|
22
23
|
"keywords": [
|
23
24
|
"ansi",
|
@@ -42,11 +43,14 @@
|
|
42
43
|
"text"
|
43
44
|
],
|
44
45
|
"dependencies": {
|
46
|
+
"@types/color-name": "^1.1.1",
|
45
47
|
"color-convert": "^2.0.1"
|
46
48
|
},
|
47
49
|
"devDependencies": {
|
50
|
+
"@types/color-convert": "^1.9.0",
|
48
51
|
"ava": "^2.3.0",
|
49
52
|
"svg-term-cli": "^2.1.1",
|
50
|
-
"
|
53
|
+
"tsd": "^0.10.0",
|
54
|
+
"xo": "^0.25.3"
|
51
55
|
}
|
52
56
|
}
|
package/readme.md
CHANGED
@@ -117,6 +117,17 @@ console.log(style.codes.get(36));
|
|
117
117
|
|
118
118
|
`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
|
119
119
|
|
120
|
+
The following color spaces from `color-convert` are supported:
|
121
|
+
|
122
|
+
- `rgb`
|
123
|
+
- `hex`
|
124
|
+
- `keyword`
|
125
|
+
- `hsl`
|
126
|
+
- `hsv`
|
127
|
+
- `hwb`
|
128
|
+
- `ansi`
|
129
|
+
- `ansi256`
|
130
|
+
|
120
131
|
To use these, call the associated conversion function with the intended output, for example:
|
121
132
|
|
122
133
|
```js
|