aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ansi-styles
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/ansi-styles
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
downloadwallet-core-363723fc84f7b8477592e0105aeb331ec9a017af.tar.xz
node_modules
Diffstat (limited to 'node_modules/ansi-styles')
-rw-r--r--node_modules/ansi-styles/index.js125
-rw-r--r--node_modules/ansi-styles/license20
-rw-r--r--node_modules/ansi-styles/package.json100
-rw-r--r--node_modules/ansi-styles/readme.md87
4 files changed, 236 insertions, 96 deletions
diff --git a/node_modules/ansi-styles/index.js b/node_modules/ansi-styles/index.js
index 78945278f..3d3baa66d 100644
--- a/node_modules/ansi-styles/index.js
+++ b/node_modules/ansi-styles/index.js
@@ -1,10 +1,28 @@
'use strict';
+const colorConvert = require('color-convert');
-function assembleStyles () {
- var styles = {
- modifiers: {
+const wrapAnsi16 = (fn, offset) => function () {
+ const code = fn.apply(colorConvert, arguments);
+ return `\u001B[${code + offset}m`;
+};
+
+const wrapAnsi256 = (fn, offset) => function () {
+ const code = fn.apply(colorConvert, arguments);
+ return `\u001B[${38 + offset};5;${code}m`;
+};
+
+const wrapAnsi16m = (fn, offset) => function () {
+ const rgb = fn.apply(colorConvert, arguments);
+ return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
+};
+
+function assembleStyles() {
+ const codes = new Map();
+ const styles = {
+ modifier: {
reset: [0, 0],
- bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
+ // 21 isn't widely supported and 22 does the same thing
+ bold: [1, 22],
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
@@ -12,7 +30,7 @@ function assembleStyles () {
hidden: [8, 28],
strikethrough: [9, 29]
},
- colors: {
+ color: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
@@ -21,9 +39,18 @@ function assembleStyles () {
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
- gray: [90, 39]
+ gray: [90, 39],
+
+ // Bright color
+ redBright: [91, 39],
+ greenBright: [92, 39],
+ yellowBright: [93, 39],
+ blueBright: [94, 39],
+ magentaBright: [95, 39],
+ cyanBright: [96, 39],
+ whiteBright: [97, 39]
},
- bgColors: {
+ bgColor: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
@@ -31,34 +58,94 @@ function assembleStyles () {
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
- bgWhite: [47, 49]
+ bgWhite: [47, 49],
+
+ // Bright color
+ bgBlackBright: [100, 49],
+ bgRedBright: [101, 49],
+ bgGreenBright: [102, 49],
+ bgYellowBright: [103, 49],
+ bgBlueBright: [104, 49],
+ bgMagentaBright: [105, 49],
+ bgCyanBright: [106, 49],
+ bgWhiteBright: [107, 49]
}
};
- // fix humans
- styles.colors.grey = styles.colors.gray;
+ // Fix humans
+ styles.color.grey = styles.color.gray;
- Object.keys(styles).forEach(function (groupName) {
- var group = styles[groupName];
+ for (const groupName of Object.keys(styles)) {
+ const group = styles[groupName];
- Object.keys(group).forEach(function (styleName) {
- var style = group[styleName];
+ for (const styleName of Object.keys(group)) {
+ const style = group[styleName];
- styles[styleName] = group[styleName] = {
- open: '\u001b[' + style[0] + 'm',
- close: '\u001b[' + style[1] + 'm'
+ styles[styleName] = {
+ open: `\u001B[${style[0]}m`,
+ close: `\u001B[${style[1]}m`
};
- });
+
+ group[styleName] = styles[styleName];
+
+ codes.set(style[0], style[1]);
+ }
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
- });
+
+ Object.defineProperty(styles, 'codes', {
+ value: codes,
+ enumerable: false
+ });
+ }
+
+ const rgb2rgb = (r, g, b) => [r, g, b];
+
+ styles.color.close = '\u001B[39m';
+ styles.bgColor.close = '\u001B[49m';
+
+ styles.color.ansi = {};
+ styles.color.ansi256 = {};
+ styles.color.ansi16m = {
+ rgb: wrapAnsi16m(rgb2rgb, 0)
+ };
+
+ styles.bgColor.ansi = {};
+ styles.bgColor.ansi256 = {};
+ styles.bgColor.ansi16m = {
+ rgb: wrapAnsi16m(rgb2rgb, 10)
+ };
+
+ for (const key of Object.keys(colorConvert)) {
+ if (typeof colorConvert[key] !== 'object') {
+ continue;
+ }
+
+ const suite = colorConvert[key];
+
+ if ('ansi16' in suite) {
+ styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
+ styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
+ }
+
+ if ('ansi256' in suite) {
+ styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
+ styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
+ }
+
+ if ('rgb' in suite) {
+ styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
+ styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
+ }
+ }
return styles;
}
+// Make the export immutable
Object.defineProperty(module, 'exports', {
enumerable: true,
get: assembleStyles
diff --git a/node_modules/ansi-styles/license b/node_modules/ansi-styles/license
index 654d0bfe9..e7af2f771 100644
--- a/node_modules/ansi-styles/license
+++ b/node_modules/ansi-styles/license
@@ -1,21 +1,9 @@
-The MIT License (MIT)
+MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
-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:
+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:
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-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.
+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.
diff --git a/node_modules/ansi-styles/package.json b/node_modules/ansi-styles/package.json
index 78c535f74..432ed81f2 100644
--- a/node_modules/ansi-styles/package.json
+++ b/node_modules/ansi-styles/package.json
@@ -1,50 +1,54 @@
{
- "name": "ansi-styles",
- "version": "2.2.1",
- "description": "ANSI escape codes for styling strings in the terminal",
- "license": "MIT",
- "repository": "chalk/ansi-styles",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "maintainers": [
- "Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)",
- "Joshua Appelman <jappelman@xebia.com> (jbnicolai.com)"
- ],
- "engines": {
- "node": ">=0.10.0"
- },
- "scripts": {
- "test": "mocha"
- },
- "files": [
- "index.js"
- ],
- "keywords": [
- "ansi",
- "styles",
- "color",
- "colour",
- "colors",
- "terminal",
- "console",
- "cli",
- "string",
- "tty",
- "escape",
- "formatting",
- "rgb",
- "256",
- "shell",
- "xterm",
- "log",
- "logging",
- "command-line",
- "text"
- ],
- "devDependencies": {
- "mocha": "*"
- }
+ "name": "ansi-styles",
+ "version": "3.2.0",
+ "description": "ANSI escape codes for styling strings in the terminal",
+ "license": "MIT",
+ "repository": "chalk/ansi-styles",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "ansi",
+ "styles",
+ "color",
+ "colour",
+ "colors",
+ "terminal",
+ "console",
+ "cli",
+ "string",
+ "tty",
+ "escape",
+ "formatting",
+ "rgb",
+ "256",
+ "shell",
+ "xterm",
+ "log",
+ "logging",
+ "command-line",
+ "text"
+ ],
+ "dependencies": {
+ "color-convert": "^1.9.0"
+ },
+ "devDependencies": {
+ "ava": "*",
+ "babel-polyfill": "^6.23.0",
+ "xo": "*"
+ },
+ "ava": {
+ "require": "babel-polyfill"
+ }
}
diff --git a/node_modules/ansi-styles/readme.md b/node_modules/ansi-styles/readme.md
index 3f933f616..dce368742 100644
--- a/node_modules/ansi-styles/readme.md
+++ b/node_modules/ansi-styles/readme.md
@@ -10,18 +10,27 @@ You probably want the higher-level [chalk](https://github.com/chalk/chalk) modul
## Install
```
-$ npm install --save ansi-styles
+$ npm install ansi-styles
```
## Usage
```js
-var ansi = require('ansi-styles');
+const style = require('ansi-styles');
+
+console.log(`${style.green.open}Hello world!${style.green.close}`);
-console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
-```
+// Color conversion between 16/256/truecolor
+// NOTE: If conversion goes to 16 colors or 256 colors, the original color
+// may be degraded to fit that color palette. This means terminals
+// that do not support 16 million colors will best-match the
+// original color.
+console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
+console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
+console.log(style.color.ansi16m.hex('#ABCDEF') + 'Hello world!' + style.color.close);
+```
## API
@@ -35,11 +44,11 @@ Each style has an `open` and `close` property.
- `reset`
- `bold`
- `dim`
-- `italic` *(not widely supported)*
+- `italic` *(Not widely supported)*
- `underline`
- `inverse`
- `hidden`
-- `strikethrough` *(not widely supported)*
+- `strikethrough` *(Not widely supported)*
### Colors
@@ -51,7 +60,14 @@ Each style has an `open` and `close` property.
- `magenta`
- `cyan`
- `white`
-- `gray`
+- `gray` ("bright black")
+- `redBright`
+- `greenBright`
+- `yellowBright`
+- `blueBright`
+- `magentaBright`
+- `cyanBright`
+- `whiteBright`
### Background colors
@@ -63,24 +79,69 @@ Each style has an `open` and `close` property.
- `bgMagenta`
- `bgCyan`
- `bgWhite`
+- `bgBlackBright`
+- `bgRedBright`
+- `bgGreenBright`
+- `bgYellowBright`
+- `bgBlueBright`
+- `bgMagentaBright`
+- `bgCyanBright`
+- `bgWhiteBright`
## Advanced usage
-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.
+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.
+
+- `style.modifier`
+- `style.color`
+- `style.bgColor`
+
+###### Example
-- `ansi.modifiers`
-- `ansi.colors`
-- `ansi.bgColors`
+```js
+console.log(style.color.green.open);
+```
+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.
###### Example
```js
-console.log(ansi.colors.green.open);
+console.log(style.codes.get(36));
+//=> 39
```
+## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
+
+`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.
+
+To use these, call the associated conversion function with the intended output, for example:
+
+```js
+style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
+style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
+
+style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
+style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
+
+style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
+style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
+```
+
+
+## Related
+
+- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
+
+
+## Maintainers
+
+- [Sindre Sorhus](https://github.com/sindresorhus)
+- [Josh Junon](https://github.com/qix-)
+
+
## License
-MIT © [Sindre Sorhus](http://sindresorhus.com)
+MIT