ansi-styles 3.1.0 → 3.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.js +13 -4
- package/license +4 -16
- package/package.json +52 -57
- package/readme.md +23 -11
package/index.js
CHANGED
@@ -17,6 +17,7 @@ const wrapAnsi16m = (fn, offset) => function () {
|
|
17
17
|
};
|
18
18
|
|
19
19
|
function assembleStyles() {
|
20
|
+
const codes = new Map();
|
20
21
|
const styles = {
|
21
22
|
modifier: {
|
22
23
|
reset: [0, 0],
|
@@ -74,10 +75,10 @@ function assembleStyles() {
|
|
74
75
|
// Fix humans
|
75
76
|
styles.color.grey = styles.color.gray;
|
76
77
|
|
77
|
-
Object.keys(styles)
|
78
|
+
for (const groupName of Object.keys(styles)) {
|
78
79
|
const group = styles[groupName];
|
79
80
|
|
80
|
-
Object.keys(group)
|
81
|
+
for (const styleName of Object.keys(group)) {
|
81
82
|
const style = group[styleName];
|
82
83
|
|
83
84
|
styles[styleName] = {
|
@@ -86,13 +87,20 @@ function assembleStyles() {
|
|
86
87
|
};
|
87
88
|
|
88
89
|
group[styleName] = styles[styleName];
|
89
|
-
|
90
|
+
|
91
|
+
codes.set(style[0], style[1]);
|
92
|
+
}
|
90
93
|
|
91
94
|
Object.defineProperty(styles, groupName, {
|
92
95
|
value: group,
|
93
96
|
enumerable: false
|
94
97
|
});
|
95
|
-
|
98
|
+
|
99
|
+
Object.defineProperty(styles, 'codes', {
|
100
|
+
value: codes,
|
101
|
+
enumerable: false
|
102
|
+
});
|
103
|
+
}
|
96
104
|
|
97
105
|
const rgb2rgb = (r, g, b) => [r, g, b];
|
98
106
|
|
@@ -137,6 +145,7 @@ function assembleStyles() {
|
|
137
145
|
return styles;
|
138
146
|
}
|
139
147
|
|
148
|
+
// Make the export immutable
|
140
149
|
Object.defineProperty(module, 'exports', {
|
141
150
|
enumerable: true,
|
142
151
|
get: assembleStyles
|
package/license
CHANGED
@@ -1,21 +1,9 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
2
|
|
3
3
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
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:
|
11
6
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
14
8
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
@@ -1,59 +1,54 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
"xo": "*"
|
55
|
-
},
|
56
|
-
"ava": {
|
57
|
-
"require": "babel-polyfill"
|
58
|
-
}
|
2
|
+
"name": "ansi-styles",
|
3
|
+
"version": "3.2.0",
|
4
|
+
"description": "ANSI escape codes for styling strings in the terminal",
|
5
|
+
"license": "MIT",
|
6
|
+
"repository": "chalk/ansi-styles",
|
7
|
+
"author": {
|
8
|
+
"name": "Sindre Sorhus",
|
9
|
+
"email": "sindresorhus@gmail.com",
|
10
|
+
"url": "sindresorhus.com"
|
11
|
+
},
|
12
|
+
"engines": {
|
13
|
+
"node": ">=4"
|
14
|
+
},
|
15
|
+
"scripts": {
|
16
|
+
"test": "xo && ava"
|
17
|
+
},
|
18
|
+
"files": [
|
19
|
+
"index.js"
|
20
|
+
],
|
21
|
+
"keywords": [
|
22
|
+
"ansi",
|
23
|
+
"styles",
|
24
|
+
"color",
|
25
|
+
"colour",
|
26
|
+
"colors",
|
27
|
+
"terminal",
|
28
|
+
"console",
|
29
|
+
"cli",
|
30
|
+
"string",
|
31
|
+
"tty",
|
32
|
+
"escape",
|
33
|
+
"formatting",
|
34
|
+
"rgb",
|
35
|
+
"256",
|
36
|
+
"shell",
|
37
|
+
"xterm",
|
38
|
+
"log",
|
39
|
+
"logging",
|
40
|
+
"command-line",
|
41
|
+
"text"
|
42
|
+
],
|
43
|
+
"dependencies": {
|
44
|
+
"color-convert": "^1.9.0"
|
45
|
+
},
|
46
|
+
"devDependencies": {
|
47
|
+
"ava": "*",
|
48
|
+
"babel-polyfill": "^6.23.0",
|
49
|
+
"xo": "*"
|
50
|
+
},
|
51
|
+
"ava": {
|
52
|
+
"require": "babel-polyfill"
|
53
|
+
}
|
59
54
|
}
|
package/readme.md
CHANGED
@@ -10,7 +10,7 @@ You probably want the higher-level [chalk](https://github.com/chalk/chalk) modul
|
|
10
10
|
## Install
|
11
11
|
|
12
12
|
```
|
13
|
-
$ npm install
|
13
|
+
$ npm install ansi-styles
|
14
14
|
```
|
15
15
|
|
16
16
|
|
@@ -22,8 +22,8 @@ const style = require('ansi-styles');
|
|
22
22
|
console.log(`${style.green.open}Hello world!${style.green.close}`);
|
23
23
|
|
24
24
|
|
25
|
-
//
|
26
|
-
// NOTE:
|
25
|
+
// Color conversion between 16/256/truecolor
|
26
|
+
// NOTE: If conversion goes to 16 colors or 256 colors, the original color
|
27
27
|
// may be degraded to fit that color palette. This means terminals
|
28
28
|
// that do not support 16 million colors will best-match the
|
29
29
|
// original color.
|
@@ -44,11 +44,11 @@ Each style has an `open` and `close` property.
|
|
44
44
|
- `reset`
|
45
45
|
- `bold`
|
46
46
|
- `dim`
|
47
|
-
- `italic` *(
|
47
|
+
- `italic` *(Not widely supported)*
|
48
48
|
- `underline`
|
49
49
|
- `inverse`
|
50
50
|
- `hidden`
|
51
|
-
- `strikethrough` *(
|
51
|
+
- `strikethrough` *(Not widely supported)*
|
52
52
|
|
53
53
|
### Colors
|
54
54
|
|
@@ -60,9 +60,7 @@ Each style has an `open` and `close` property.
|
|
60
60
|
- `magenta`
|
61
61
|
- `cyan`
|
62
62
|
- `white`
|
63
|
-
- `gray`
|
64
|
-
|
65
|
-
- `blackBright`
|
63
|
+
- `gray` ("bright black")
|
66
64
|
- `redBright`
|
67
65
|
- `greenBright`
|
68
66
|
- `yellowBright`
|
@@ -81,7 +79,6 @@ Each style has an `open` and `close` property.
|
|
81
79
|
- `bgMagenta`
|
82
80
|
- `bgCyan`
|
83
81
|
- `bgWhite`
|
84
|
-
|
85
82
|
- `bgBlackBright`
|
86
83
|
- `bgRedBright`
|
87
84
|
- `bgGreenBright`
|
@@ -91,6 +88,7 @@ Each style has an `open` and `close` property.
|
|
91
88
|
- `bgCyanBright`
|
92
89
|
- `bgWhiteBright`
|
93
90
|
|
91
|
+
|
94
92
|
## Advanced usage
|
95
93
|
|
96
94
|
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
|
@@ -99,13 +97,21 @@ By default, you get a map of styles, but the styles are also available as groups
|
|
99
97
|
- `style.color`
|
100
98
|
- `style.bgColor`
|
101
99
|
|
102
|
-
|
103
100
|
###### Example
|
104
101
|
|
105
102
|
```js
|
106
103
|
console.log(style.color.green.open);
|
107
104
|
```
|
108
105
|
|
106
|
+
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
|
107
|
+
|
108
|
+
###### Example
|
109
|
+
|
110
|
+
```js
|
111
|
+
console.log(style.codes.get(36));
|
112
|
+
//=> 39
|
113
|
+
```
|
114
|
+
|
109
115
|
|
110
116
|
## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
|
111
117
|
|
@@ -130,6 +136,12 @@ style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color backgroun
|
|
130
136
|
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
|
131
137
|
|
132
138
|
|
139
|
+
## Maintainers
|
140
|
+
|
141
|
+
- [Sindre Sorhus](https://github.com/sindresorhus)
|
142
|
+
- [Josh Junon](https://github.com/qix-)
|
143
|
+
|
144
|
+
|
133
145
|
## License
|
134
146
|
|
135
|
-
MIT
|
147
|
+
MIT
|