ansi-styles
Advanced tools
Comparing version 5.2.0 to 6.0.0
266
index.d.ts
@@ -1,167 +0,165 @@ | ||
declare namespace ansiStyles { | ||
interface CSPair { | ||
/** | ||
The ANSI terminal control sequence for starting this style. | ||
*/ | ||
readonly open: string; | ||
export interface CSPair { | ||
/** | ||
The ANSI terminal control sequence for starting this style. | ||
*/ | ||
readonly open: string; | ||
/** | ||
The ANSI terminal control sequence for ending this style. | ||
*/ | ||
readonly close: string; | ||
} | ||
/** | ||
The ANSI terminal control sequence for ending this style. | ||
*/ | ||
readonly close: string; | ||
} | ||
interface ColorBase { | ||
/** | ||
The ANSI terminal control sequence for ending this color. | ||
*/ | ||
readonly close: string; | ||
export interface ColorBase { | ||
/** | ||
The ANSI terminal control sequence for ending this color. | ||
*/ | ||
readonly close: string; | ||
ansi256(code: number): string; | ||
ansi256(code: number): string; | ||
ansi16m(red: number, green: number, blue: number): string; | ||
} | ||
ansi16m(red: number, green: number, blue: number): string; | ||
} | ||
interface Modifier { | ||
/** | ||
Resets the current color chain. | ||
*/ | ||
readonly reset: CSPair; | ||
export interface Modifier { | ||
/** | ||
Resets the current color chain. | ||
*/ | ||
readonly reset: CSPair; | ||
/** | ||
Make text bold. | ||
*/ | ||
readonly bold: CSPair; | ||
/** | ||
Make text bold. | ||
*/ | ||
readonly bold: CSPair; | ||
/** | ||
Emitting only a small amount of light. | ||
*/ | ||
readonly dim: CSPair; | ||
/** | ||
Emitting only a small amount of light. | ||
*/ | ||
readonly dim: CSPair; | ||
/** | ||
Make text italic. (Not widely supported) | ||
*/ | ||
readonly italic: CSPair; | ||
/** | ||
Make text italic. (Not widely supported) | ||
*/ | ||
readonly italic: CSPair; | ||
/** | ||
Make text underline. (Not widely supported) | ||
*/ | ||
readonly underline: CSPair; | ||
/** | ||
Make text underline. (Not widely supported) | ||
*/ | ||
readonly underline: CSPair; | ||
/** | ||
Make text overline. | ||
/** | ||
Make text overline. | ||
Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash. | ||
*/ | ||
readonly overline: CSPair; | ||
Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash. | ||
*/ | ||
readonly overline: CSPair; | ||
/** | ||
Inverse background and foreground colors. | ||
*/ | ||
readonly inverse: CSPair; | ||
/** | ||
Inverse background and foreground colors. | ||
*/ | ||
readonly inverse: CSPair; | ||
/** | ||
Prints the text, but makes it invisible. | ||
*/ | ||
readonly hidden: CSPair; | ||
/** | ||
Prints the text, but makes it invisible. | ||
*/ | ||
readonly hidden: CSPair; | ||
/** | ||
Puts a horizontal line through the center of the text. (Not widely supported) | ||
*/ | ||
readonly strikethrough: CSPair; | ||
} | ||
/** | ||
Puts a horizontal line through the center of the text. (Not widely supported) | ||
*/ | ||
readonly strikethrough: CSPair; | ||
} | ||
interface ForegroundColor { | ||
readonly black: CSPair; | ||
readonly red: CSPair; | ||
readonly green: CSPair; | ||
readonly yellow: CSPair; | ||
readonly blue: CSPair; | ||
readonly cyan: CSPair; | ||
readonly magenta: CSPair; | ||
readonly white: CSPair; | ||
export interface ForegroundColor { | ||
readonly black: CSPair; | ||
readonly red: CSPair; | ||
readonly green: CSPair; | ||
readonly yellow: CSPair; | ||
readonly blue: CSPair; | ||
readonly cyan: CSPair; | ||
readonly magenta: CSPair; | ||
readonly white: CSPair; | ||
/** | ||
Alias for `blackBright`. | ||
*/ | ||
readonly gray: CSPair; | ||
/** | ||
Alias for `blackBright`. | ||
*/ | ||
readonly gray: CSPair; | ||
/** | ||
Alias for `blackBright`. | ||
*/ | ||
readonly grey: CSPair; | ||
/** | ||
Alias for `blackBright`. | ||
*/ | ||
readonly grey: CSPair; | ||
readonly blackBright: CSPair; | ||
readonly redBright: CSPair; | ||
readonly greenBright: CSPair; | ||
readonly yellowBright: CSPair; | ||
readonly blueBright: CSPair; | ||
readonly cyanBright: CSPair; | ||
readonly magentaBright: CSPair; | ||
readonly whiteBright: CSPair; | ||
} | ||
readonly blackBright: CSPair; | ||
readonly redBright: CSPair; | ||
readonly greenBright: CSPair; | ||
readonly yellowBright: CSPair; | ||
readonly blueBright: CSPair; | ||
readonly cyanBright: CSPair; | ||
readonly magentaBright: CSPair; | ||
readonly whiteBright: CSPair; | ||
} | ||
interface BackgroundColor { | ||
readonly bgBlack: CSPair; | ||
readonly bgRed: CSPair; | ||
readonly bgGreen: CSPair; | ||
readonly bgYellow: CSPair; | ||
readonly bgBlue: CSPair; | ||
readonly bgCyan: CSPair; | ||
readonly bgMagenta: CSPair; | ||
readonly bgWhite: CSPair; | ||
export interface BackgroundColor { | ||
readonly bgBlack: CSPair; | ||
readonly bgRed: CSPair; | ||
readonly bgGreen: CSPair; | ||
readonly bgYellow: CSPair; | ||
readonly bgBlue: CSPair; | ||
readonly bgCyan: CSPair; | ||
readonly bgMagenta: CSPair; | ||
readonly bgWhite: CSPair; | ||
/** | ||
Alias for `bgBlackBright`. | ||
*/ | ||
readonly bgGray: CSPair; | ||
/** | ||
Alias for `bgBlackBright`. | ||
*/ | ||
readonly bgGray: CSPair; | ||
/** | ||
Alias for `bgBlackBright`. | ||
*/ | ||
readonly bgGrey: CSPair; | ||
/** | ||
Alias for `bgBlackBright`. | ||
*/ | ||
readonly bgGrey: CSPair; | ||
readonly bgBlackBright: CSPair; | ||
readonly bgRedBright: CSPair; | ||
readonly bgGreenBright: CSPair; | ||
readonly bgYellowBright: CSPair; | ||
readonly bgBlueBright: CSPair; | ||
readonly bgCyanBright: CSPair; | ||
readonly bgMagentaBright: CSPair; | ||
readonly bgWhiteBright: CSPair; | ||
} | ||
readonly bgBlackBright: CSPair; | ||
readonly bgRedBright: CSPair; | ||
readonly bgGreenBright: CSPair; | ||
readonly bgYellowBright: CSPair; | ||
readonly bgBlueBright: CSPair; | ||
readonly bgCyanBright: CSPair; | ||
readonly bgMagentaBright: CSPair; | ||
readonly bgWhiteBright: CSPair; | ||
} | ||
interface ConvertColor { | ||
/** | ||
Convert from the RGB color space to the ANSI 256 color space. | ||
export interface ConvertColor { | ||
/** | ||
Convert from the RGB color space to the ANSI 256 color space. | ||
@param red - (`0...255`) | ||
@param green - (`0...255`) | ||
@param blue - (`0...255`) | ||
*/ | ||
rgbToAnsi256(red: number, green: number, blue: number): number; | ||
@param red - (`0...255`) | ||
@param green - (`0...255`) | ||
@param blue - (`0...255`) | ||
*/ | ||
rgbToAnsi256(red: number, green: number, blue: number): number; | ||
/** | ||
Convert from the RGB HEX color space to the RGB color space. | ||
/** | ||
Convert from the RGB HEX color space to the RGB color space. | ||
@param hex - A hexadecimal string containing RGB data. | ||
*/ | ||
hexToRgb(hex: string): [red: number, green: number, blue: number]; | ||
@param hex - A hexadecimal string containing RGB data. | ||
*/ | ||
hexToRgb(hex: string): [red: number, green: number, blue: number]; | ||
/** | ||
Convert from the RGB HEX color space to the ANSI 256 color space. | ||
/** | ||
Convert from the RGB HEX color space to the ANSI 256 color space. | ||
@param hex - A hexadecimal string containing RGB data. | ||
*/ | ||
hexToAnsi256(hex: string): number; | ||
} | ||
@param hex - A hexadecimal string containing RGB data. | ||
*/ | ||
hexToAnsi256(hex: string): number; | ||
} | ||
declare const ansiStyles: { | ||
readonly modifier: ansiStyles.Modifier; | ||
readonly color: ansiStyles.ForegroundColor & ansiStyles.ColorBase; | ||
readonly bgColor: ansiStyles.BackgroundColor & ansiStyles.ColorBase; | ||
readonly modifier: Modifier; | ||
readonly color: ColorBase & ForegroundColor; | ||
readonly bgColor: ColorBase & BackgroundColor; | ||
readonly codes: ReadonlyMap<number, number>; | ||
} & ansiStyles.BackgroundColor & ansiStyles.ForegroundColor & ansiStyles.Modifier & ansiStyles.ConvertColor; | ||
} & ForegroundColor & BackgroundColor & Modifier & ConvertColor; | ||
export = ansiStyles; | ||
export default ansiStyles; |
10
index.js
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
const ANSI_BACKGROUND_OFFSET = 10; | ||
@@ -160,6 +158,4 @@ | ||
// Make the export immutable | ||
Object.defineProperty(module, 'exports', { | ||
enumerable: true, | ||
get: assembleStyles | ||
}); | ||
const ansiStyles = assembleStyles(); | ||
export default ansiStyles; |
{ | ||
"name": "ansi-styles", | ||
"version": "5.2.0", | ||
"version": "6.0.0", | ||
"description": "ANSI escape codes for styling strings in the terminal", | ||
@@ -13,4 +13,6 @@ "license": "MIT", | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=10" | ||
"node": ">=12" | ||
}, | ||
@@ -48,7 +50,7 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^2.4.0", | ||
"ava": "^3.15.0", | ||
"svg-term-cli": "^2.1.1", | ||
"tsd": "^0.14.0", | ||
"xo": "^0.37.1" | ||
"xo": "^0.38.2" | ||
} | ||
} |
@@ -18,5 +18,5 @@ # ansi-styles | ||
```js | ||
const style = require('ansi-styles'); | ||
import styles from 'ansi-styles'; | ||
console.log(`${style.green.open}Hello world!${style.green.close}`); | ||
console.log(`${styles.green.open}Hello world!${styles.green.close}`); | ||
@@ -29,4 +29,4 @@ | ||
// original color. | ||
console.log(`${style.color.ansi256(style.rgbToAnsi256(199, 20, 250))}Hello World${style.color.close}`) | ||
console.log(`${style.color.ansi16m(...style.hexToRgb('#abcdef'))}Hello World${style.color.close}`) | ||
console.log(`${styles.color.ansi256(styles.rgbToAnsi256(199, 20, 250))}Hello World${styles.color.close}`) | ||
console.log(`${styles.color.ansi16m(...styles.hexToRgb('#abcdef'))}Hello World${styles.color.close}`) | ||
``` | ||
@@ -94,5 +94,5 @@ | ||
- `style.modifier` | ||
- `style.color` | ||
- `style.bgColor` | ||
- `styles.modifier` | ||
- `styles.color` | ||
- `styles.bgColor` | ||
@@ -102,6 +102,8 @@ ###### Example | ||
```js | ||
console.log(style.color.green.open); | ||
import styles from 'ansi-styles'; | ||
console.log(styles.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. | ||
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `styles.codes`, which returns a `Map` with the open codes as keys and close codes as values. | ||
@@ -111,3 +113,5 @@ ###### Example | ||
```js | ||
console.log(style.codes.get(36)); | ||
import styles from 'ansi-styles'; | ||
console.log(styles.codes.get(36)); | ||
//=> 39 | ||
@@ -129,7 +133,9 @@ ``` | ||
```js | ||
style.color.ansi256(style.rgbToAnsi256(100, 200, 15)); // RGB to 256 color ansi foreground code | ||
style.bgColor.ansi256(style.hexToAnsi256('#C0FFEE')); // HEX to 256 color ansi foreground code | ||
import styles from 'ansi-styles'; | ||
style.color.ansi16m(100, 200, 15); // RGB to 16 million color foreground code | ||
style.bgColor.ansi16m(...style.hexToRgb('#C0FFEE')); // Hex (RGB) to 16 million color foreground code | ||
styles.color.ansi256(styles.rgbToAnsi256(100, 200, 15)); // RGB to 256 color ansi foreground code | ||
styles.bgColor.ansi256(styles.hexToAnsi256('#C0FFEE')); // HEX to 256 color ansi foreground code | ||
styles.color.ansi16m(100, 200, 15); // RGB to 16 million color foreground code | ||
styles.bgColor.ansi16m(...styles.hexToRgb('#C0FFEE')); // Hex (RGB) to 16 million color foreground code | ||
``` | ||
@@ -136,0 +142,0 @@ |
Sorry, the diff of this file is not supported yet
151
Yes
13494
271