ansi-styles 6.2.0 → 6.2.3
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 +12 -12
- package/index.js +8 -8
- package/package.json +4 -4
package/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export
|
1
|
+
export type CSPair = { // eslint-disable-line @typescript-eslint/naming-convention
|
2
2
|
/**
|
3
3
|
The ANSI terminal control sequence for starting this style.
|
4
4
|
*/
|
@@ -8,9 +8,9 @@ export interface CSPair { // eslint-disable-line @typescript-eslint/naming-conve
|
|
8
8
|
The ANSI terminal control sequence for ending this style.
|
9
9
|
*/
|
10
10
|
readonly close: string;
|
11
|
-
}
|
11
|
+
};
|
12
12
|
|
13
|
-
export
|
13
|
+
export type ColorBase = {
|
14
14
|
/**
|
15
15
|
The ANSI terminal control sequence for ending this color.
|
16
16
|
*/
|
@@ -21,9 +21,9 @@ export interface ColorBase {
|
|
21
21
|
ansi256(code: number): string;
|
22
22
|
|
23
23
|
ansi16m(red: number, green: number, blue: number): string;
|
24
|
-
}
|
24
|
+
};
|
25
25
|
|
26
|
-
export
|
26
|
+
export type Modifier = {
|
27
27
|
/**
|
28
28
|
Resets the current color chain.
|
29
29
|
*/
|
@@ -70,9 +70,9 @@ export interface Modifier {
|
|
70
70
|
Puts a horizontal line through the center of the text. (Not widely supported)
|
71
71
|
*/
|
72
72
|
readonly strikethrough: CSPair;
|
73
|
-
}
|
73
|
+
};
|
74
74
|
|
75
|
-
export
|
75
|
+
export type ForegroundColor = {
|
76
76
|
readonly black: CSPair;
|
77
77
|
readonly red: CSPair;
|
78
78
|
readonly green: CSPair;
|
@@ -100,9 +100,9 @@ export interface ForegroundColor {
|
|
100
100
|
readonly cyanBright: CSPair;
|
101
101
|
readonly magentaBright: CSPair;
|
102
102
|
readonly whiteBright: CSPair;
|
103
|
-
}
|
103
|
+
};
|
104
104
|
|
105
|
-
export
|
105
|
+
export type BackgroundColor = {
|
106
106
|
readonly bgBlack: CSPair;
|
107
107
|
readonly bgRed: CSPair;
|
108
108
|
readonly bgGreen: CSPair;
|
@@ -130,9 +130,9 @@ export interface BackgroundColor {
|
|
130
130
|
readonly bgCyanBright: CSPair;
|
131
131
|
readonly bgMagentaBright: CSPair;
|
132
132
|
readonly bgWhiteBright: CSPair;
|
133
|
-
}
|
133
|
+
};
|
134
134
|
|
135
|
-
export
|
135
|
+
export type ConvertColor = {
|
136
136
|
/**
|
137
137
|
Convert from the RGB color space to the ANSI 256 color space.
|
138
138
|
|
@@ -178,7 +178,7 @@ export interface ConvertColor {
|
|
178
178
|
@param hex - A hexadecimal string containing RGB data.
|
179
179
|
*/
|
180
180
|
hexToAnsi(hex: string): number;
|
181
|
-
}
|
181
|
+
};
|
182
182
|
|
183
183
|
/**
|
184
184
|
Basic modifier names.
|
package/index.js
CHANGED
@@ -65,6 +65,11 @@ const styles = {
|
|
65
65
|
},
|
66
66
|
};
|
67
67
|
|
68
|
+
export const modifierNames = Object.keys(styles.modifier);
|
69
|
+
export const foregroundColorNames = Object.keys(styles.color);
|
70
|
+
export const backgroundColorNames = Object.keys(styles.bgColor);
|
71
|
+
export const colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
72
|
+
|
68
73
|
function assembleStyles() {
|
69
74
|
const codes = new Map();
|
70
75
|
|
@@ -104,7 +109,7 @@ function assembleStyles() {
|
|
104
109
|
// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
|
105
110
|
Object.defineProperties(styles, {
|
106
111
|
rgbToAnsi256: {
|
107
|
-
value
|
112
|
+
value(red, green, blue) {
|
108
113
|
// We use the extended greyscale palette here, with the exception of
|
109
114
|
// black and white. normal palette only has 4 greyscale shades.
|
110
115
|
if (red === green && green === blue) {
|
@@ -127,7 +132,7 @@ function assembleStyles() {
|
|
127
132
|
enumerable: false,
|
128
133
|
},
|
129
134
|
hexToRgb: {
|
130
|
-
value
|
135
|
+
value(hex) {
|
131
136
|
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
132
137
|
if (!matches) {
|
133
138
|
return [0, 0, 0];
|
@@ -156,7 +161,7 @@ function assembleStyles() {
|
|
156
161
|
enumerable: false,
|
157
162
|
},
|
158
163
|
ansi256ToAnsi: {
|
159
|
-
value
|
164
|
+
value(code) {
|
160
165
|
if (code < 8) {
|
161
166
|
return 30 + code;
|
162
167
|
}
|
@@ -216,8 +221,3 @@ function assembleStyles() {
|
|
216
221
|
const ansiStyles = assembleStyles();
|
217
222
|
|
218
223
|
export default ansiStyles;
|
219
|
-
|
220
|
-
export const modifierNames = Object.keys(styles.modifier);
|
221
|
-
export const foregroundColorNames = Object.keys(styles.color);
|
222
|
-
export const backgroundColorNames = Object.keys(styles.bgColor);
|
223
|
-
export const colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ansi-styles",
|
3
|
-
"version": "6.2.
|
3
|
+
"version": "6.2.3",
|
4
4
|
"description": "ANSI escape codes for styling strings in the terminal",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": "chalk/ansi-styles",
|
@@ -46,9 +46,9 @@
|
|
46
46
|
"text"
|
47
47
|
],
|
48
48
|
"devDependencies": {
|
49
|
-
"ava": "^
|
49
|
+
"ava": "^6.1.3",
|
50
50
|
"svg-term-cli": "^2.1.1",
|
51
|
-
"tsd": "^0.
|
52
|
-
"xo": "^0.
|
51
|
+
"tsd": "^0.31.1",
|
52
|
+
"xo": "^0.58.0"
|
53
53
|
}
|
54
54
|
}
|