@bevry/ansi
Advanced tools
Comparing version 2.1.0 to 3.0.0-next.1604376478.2b78ad17455acaf17ffa8fbf3e7cb0c99b8d1c48
@@ -0,1 +1,11 @@ | ||
export declare enum Color { | ||
Black = 0, | ||
Red = 1, | ||
Green = 2, | ||
Yellow = 3, | ||
Blue = 4, | ||
Magenta = 5, | ||
Cyan = 6, | ||
White = 7, | ||
} | ||
/** A factory method to generate an ANSI style applier from the open and close codes */ | ||
@@ -6,11 +16,21 @@ export declare function style( | ||
): (str: string) => string | ||
/** A factory method to generate an ANSI color applier from the color code */ | ||
export declare function color(open: number): (str: string) => string | ||
/** A factory method to generate an ANSI foreground color applier from the foreground color code */ | ||
export declare function foregroundColor( | ||
color: Color, | ||
bright?: boolean | ||
): (str: string) => string | ||
/** A factory method to generate an ANSI background color applier from the background color code */ | ||
export declare function backgroundColor(open: number): (str: string) => string | ||
export declare function backgroundColor( | ||
color: Color, | ||
bright?: boolean | ||
): (str: string) => string | ||
/** Make the text look normal */ | ||
export declare const reset: (str: string) => string | ||
/** Make the text brighter than usual */ | ||
/** Make the text bold, or with increased intensity */ | ||
export declare const bold: (str: string) => string | ||
/** Make the text faint, or with decreased intensity */ | ||
export declare const faint: (str: string) => string | ||
/** Make the text bold, or with increased intensity */ | ||
export declare const bright: (str: string) => string | ||
/** Make the text dimmer than usual */ | ||
/** Make the text faint, or with decreased intensity */ | ||
export declare const dim: (str: string) => string | ||
@@ -21,22 +41,38 @@ /** Make the text italicized */ | ||
export declare const underline: (str: string) => string | ||
/** Make the text blink */ | ||
/** Make the text slow blink */ | ||
export declare const slowBlink: (str: string) => string | ||
/** Make the text slow blink */ | ||
export declare const blink: (str: string) => string | ||
/** Make the text rapid blink */ | ||
export declare const rapidBlink: (str: string) => string | ||
/** Invert the colors of the text */ | ||
export declare const inverse: (str: string) => string | ||
/** Make the text white */ | ||
export declare const white: (str: string) => string | ||
/** Make the text concealed */ | ||
export declare const conceal: (str: string) => string | ||
/** Make the text crossed-out */ | ||
export declare const crossout: (str: string) => string | ||
/** Make the text crossed-out */ | ||
export declare const strikethrough: (str: string) => string | ||
/** Make the text framed */ | ||
export declare const frame: (str: string) => string | ||
/** Make the text encircled */ | ||
export declare const encircle: (str: string) => string | ||
/** Make the text overlined */ | ||
export declare const overline: (str: string) => string | ||
/** Make the text black */ | ||
export declare const black: (str: string) => string | ||
/** Make the text red */ | ||
export declare const red: (str: string) => string | ||
/** Make the text green */ | ||
export declare const green: (str: string) => string | ||
/** Make the text yellow */ | ||
export declare const yellow: (str: string) => string | ||
/** Make the text blue */ | ||
export declare const blue: (str: string) => string | ||
/** Make the text magenta */ | ||
export declare const magenta: (str: string) => string | ||
/** Make the text cyan */ | ||
export declare const cyan: (str: string) => string | ||
/** Make the text green */ | ||
export declare const green: (str: string) => string | ||
/** Make the text magenta */ | ||
export declare const magenta: (str: string) => string | ||
/** Make the text red */ | ||
export declare const red: (str: string) => string | ||
/** Make the text yellow */ | ||
export declare const yellow: (str: string) => string | ||
/** Make the text white */ | ||
export declare const white: (str: string) => string | ||
/** Make the text bright black */ | ||
@@ -43,0 +79,0 @@ export declare const brightBlack: (str: string) => string |
@@ -1,16 +0,16 @@ | ||
/* | ||
* Color Codes explained: http://www.termsys.demon.co.uk/vtansi.htm#colors | ||
* Following caveats: | ||
* bright - brightens the color (bold-blue is same as brightBlue) | ||
* dim - nothing on Mac or Linux | ||
* italic - nothing on Mac or Linux | ||
* underline - underlines string | ||
* blink - nothing on Mac or linux | ||
* inverse - background becomes foreground and vice versa | ||
* | ||
* In summary, the only styles that work are: | ||
* - bright, underline and inverse | ||
* - the others are only included for completeness | ||
*/ | ||
// Styles | ||
// https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
// Colors | ||
// https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit | ||
export var Color | ||
;(function (Color) { | ||
Color[(Color['Black'] = 0)] = 'Black' | ||
Color[(Color['Red'] = 1)] = 'Red' | ||
Color[(Color['Green'] = 2)] = 'Green' | ||
Color[(Color['Yellow'] = 3)] = 'Yellow' | ||
Color[(Color['Blue'] = 4)] = 'Blue' | ||
Color[(Color['Magenta'] = 5)] = 'Magenta' | ||
Color[(Color['Cyan'] = 6)] = 'Cyan' | ||
Color[(Color['White'] = 7)] = 'White' | ||
})(Color || (Color = {})) | ||
/** A factory method to generate an ANSI style applier from the open and close codes */ | ||
@@ -20,16 +20,28 @@ export function style(open, close) { | ||
} | ||
/** A factory method to generate an ANSI color applier from the color code */ | ||
export function color(open) { | ||
return style(open, 39) | ||
/** A factory method to generate an ANSI foreground color applier from the foreground color code */ | ||
export function foregroundColor(color, bright = false) { | ||
// 30-37, 38 | ||
return style((bright ? 90 : 30) + color, 39) | ||
} | ||
/** A factory method to generate an ANSI background color applier from the background color code */ | ||
export function backgroundColor(open) { | ||
return style(open, 49) | ||
export function backgroundColor(color, bright = false) { | ||
// 40-47, 48 | ||
return style((bright ? 100 : 40) + color, 49) | ||
} | ||
// /** A factory method to generate an ANSI underline color applier from the underline color code */ | ||
// export function underlineColor(open: number) { | ||
// // 58, 59 | ||
// // requires a different style to set the colour though, which needs to be figured out | ||
// return style(open, 59) | ||
// } | ||
/** Make the text look normal */ | ||
export const reset = style(0, 22) | ||
/** Make the text brighter than usual */ | ||
export const bright = style(1, 22) | ||
/** Make the text dimmer than usual */ | ||
export const dim = style(2, 22) | ||
/** Make the text bold, or with increased intensity */ | ||
export const bold = style(1, 22) | ||
/** Make the text faint, or with decreased intensity */ | ||
export const faint = style(2, 22) | ||
/** Make the text bold, or with increased intensity */ | ||
export const bright = bold | ||
/** Make the text faint, or with decreased intensity */ | ||
export const dim = faint | ||
/** Make the text italicized */ | ||
@@ -39,69 +51,85 @@ export const italic = style(3, 23) | ||
export const underline = style(4, 24) | ||
/** Make the text blink */ | ||
export const blink = style(5, 25) | ||
/** Make the text slow blink */ | ||
export const slowBlink = style(5, 25) | ||
/** Make the text slow blink */ | ||
export const blink = slowBlink | ||
/** Make the text rapid blink */ | ||
export const rapidBlink = style(6, 25) | ||
/** Invert the colors of the text */ | ||
export const inverse = style(7, 27) | ||
/** Make the text white */ | ||
export const white = color(37) | ||
/** Make the text concealed */ | ||
export const conceal = style(8, 28) | ||
/** Make the text crossed-out */ | ||
export const crossout = style(9, 29) | ||
/** Make the text crossed-out */ | ||
export const strikethrough = crossout | ||
/** Make the text framed */ | ||
export const frame = style(51, 54) | ||
/** Make the text encircled */ | ||
export const encircle = style(52, 54) | ||
/** Make the text overlined */ | ||
export const overline = style(53, 55) | ||
/** Make the text black */ | ||
export const black = color(30) | ||
export const black = foregroundColor(Color.Black) | ||
/** Make the text red */ | ||
export const red = foregroundColor(Color.Red) | ||
/** Make the text green */ | ||
export const green = foregroundColor(Color.Green) | ||
/** Make the text yellow */ | ||
export const yellow = foregroundColor(Color.Yellow) | ||
/** Make the text blue */ | ||
export const blue = color(34) | ||
export const blue = foregroundColor(Color.Blue) | ||
/** Make the text magenta */ | ||
export const magenta = foregroundColor(Color.Magenta) | ||
/** Make the text cyan */ | ||
export const cyan = color(36) | ||
/** Make the text green */ | ||
export const green = color(32) | ||
/** Make the text magenta */ | ||
export const magenta = color(35) | ||
/** Make the text red */ | ||
export const red = color(31) | ||
/** Make the text yellow */ | ||
export const yellow = color(33) | ||
export const cyan = foregroundColor(Color.Cyan) | ||
/** Make the text white */ | ||
export const white = foregroundColor(Color.White) | ||
/** Make the text bright black */ | ||
export const brightBlack = color(90) | ||
export const brightBlack = foregroundColor(Color.Black, true) | ||
/** Make the text bright red */ | ||
export const brightRed = color(91) | ||
export const brightRed = foregroundColor(Color.Red, true) | ||
/** Make the text bright green */ | ||
export const brightGreen = color(92) | ||
export const brightGreen = foregroundColor(Color.Green, true) | ||
/** Make the text bright yellow */ | ||
export const brightYellow = color(93) | ||
export const brightYellow = foregroundColor(Color.Yellow, true) | ||
/** Make the text bright blue */ | ||
export const brightBlue = color(94) | ||
export const brightBlue = foregroundColor(Color.Blue, true) | ||
/** Make the text bright magenta */ | ||
export const brightMagenta = color(95) | ||
export const brightMagenta = foregroundColor(Color.Magenta, true) | ||
/** Make the text bright cyan */ | ||
export const brightCyan = color(96) | ||
export const brightCyan = foregroundColor(Color.Cyan, true) | ||
/** Make the text bright white */ | ||
export const brightWhite = color(97) | ||
export const brightWhite = foregroundColor(Color.White, true) | ||
/** Make the text's background black */ | ||
export const bgBlack = backgroundColor(40) | ||
export const bgBlack = backgroundColor(Color.Black) | ||
/** Make the text's background red */ | ||
export const bgRed = backgroundColor(41) | ||
export const bgRed = backgroundColor(Color.Red) | ||
/** Make the text's background green */ | ||
export const bgGreen = backgroundColor(42) | ||
export const bgGreen = backgroundColor(Color.Green) | ||
/** Make the text's background yellow */ | ||
export const bgYellow = backgroundColor(43) | ||
export const bgYellow = backgroundColor(Color.Yellow) | ||
/** Make the text's background blue */ | ||
export const bgBlue = backgroundColor(44) | ||
export const bgBlue = backgroundColor(Color.Blue) | ||
/** Make the text's background magenta */ | ||
export const bgMagenta = backgroundColor(45) | ||
export const bgMagenta = backgroundColor(Color.Magenta) | ||
/** Make the text's background cyan */ | ||
export const bgCyan = backgroundColor(46) | ||
export const bgCyan = backgroundColor(Color.Cyan) | ||
/** Make the text's background white */ | ||
export const bgWhite = backgroundColor(47) | ||
export const bgWhite = backgroundColor(Color.White) | ||
/** Make the text's background bright black */ | ||
export const bgBrightBlack = backgroundColor(100) | ||
export const bgBrightBlack = backgroundColor(Color.Black, true) | ||
/** Make the text's background bright red */ | ||
export const bgBrightRed = backgroundColor(101) | ||
export const bgBrightRed = backgroundColor(Color.Red, true) | ||
/** Make the text's background bright green */ | ||
export const bgBrightGreen = backgroundColor(102) | ||
export const bgBrightGreen = backgroundColor(Color.Green, true) | ||
/** Make the text's background bright yellow */ | ||
export const bgBrightYellow = backgroundColor(103) | ||
export const bgBrightYellow = backgroundColor(Color.Yellow, true) | ||
/** Make the text's background bright blue */ | ||
export const bgBrightBlue = backgroundColor(104) | ||
export const bgBrightBlue = backgroundColor(Color.Blue, true) | ||
/** Make the text's background bright magenta */ | ||
export const bgBrightMagenta = backgroundColor(105) | ||
export const bgBrightMagenta = backgroundColor(Color.Magenta, true) | ||
/** Make the text's background bright cyan */ | ||
export const bgBrightCyan = backgroundColor(106) | ||
export const bgBrightCyan = backgroundColor(Color.Cyan, true) | ||
/** Make the text's background bright white */ | ||
export const bgBrightWhite = backgroundColor(107) | ||
export const bgBrightWhite = backgroundColor(Color.White, true) |
@@ -1,16 +0,16 @@ | ||
/* | ||
* Color Codes explained: http://www.termsys.demon.co.uk/vtansi.htm#colors | ||
// Styles | ||
// https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
* Following caveats: | ||
* bright - brightens the color (bold-blue is same as brightBlue) | ||
* dim - nothing on Mac or Linux | ||
* italic - nothing on Mac or Linux | ||
* underline - underlines string | ||
* blink - nothing on Mac or linux | ||
* inverse - background becomes foreground and vice versa | ||
* | ||
* In summary, the only styles that work are: | ||
* - bright, underline and inverse | ||
* - the others are only included for completeness | ||
*/ | ||
// Colors | ||
// https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit | ||
export enum Color { | ||
Black = 0, | ||
Red = 1, | ||
Green = 2, | ||
Yellow = 3, | ||
Blue = 4, | ||
Magenta = 5, | ||
Cyan = 6, | ||
White = 7, | ||
} | ||
@@ -22,21 +22,36 @@ /** A factory method to generate an ANSI style applier from the open and close codes */ | ||
/** A factory method to generate an ANSI color applier from the color code */ | ||
export function color(open: number) { | ||
return style(open, 39) | ||
/** A factory method to generate an ANSI foreground color applier from the foreground color code */ | ||
export function foregroundColor(color: Color, bright = false) { | ||
// 30-37, 38 | ||
return style((bright ? 90 : 30) + color, 39) | ||
} | ||
/** A factory method to generate an ANSI background color applier from the background color code */ | ||
export function backgroundColor(open: number) { | ||
return style(open, 49) | ||
export function backgroundColor(color: Color, bright = false) { | ||
// 40-47, 48 | ||
return style((bright ? 100 : 40) + color, 49) | ||
} | ||
// /** A factory method to generate an ANSI underline color applier from the underline color code */ | ||
// export function underlineColor(open: number) { | ||
// // 58, 59 | ||
// // requires a different style to set the colour though, which needs to be figured out | ||
// return style(open, 59) | ||
// } | ||
/** Make the text look normal */ | ||
export const reset = style(0, 22) | ||
/** Make the text brighter than usual */ | ||
export const bright = style(1, 22) | ||
/** Make the text bold, or with increased intensity */ | ||
export const bold = style(1, 22) | ||
/** Make the text dimmer than usual */ | ||
export const dim = style(2, 22) | ||
/** Make the text faint, or with decreased intensity */ | ||
export const faint = style(2, 22) | ||
/** Make the text bold, or with increased intensity */ | ||
export const bright = bold | ||
/** Make the text faint, or with decreased intensity */ | ||
export const dim = faint | ||
/** Make the text italicized */ | ||
@@ -48,102 +63,126 @@ export const italic = style(3, 23) | ||
/** Make the text blink */ | ||
export const blink = style(5, 25) | ||
/** Make the text slow blink */ | ||
export const slowBlink = style(5, 25) | ||
/** Make the text slow blink */ | ||
export const blink = slowBlink | ||
/** Make the text rapid blink */ | ||
export const rapidBlink = style(6, 25) | ||
/** Invert the colors of the text */ | ||
export const inverse = style(7, 27) | ||
/** Make the text white */ | ||
export const white = color(37) | ||
/** Make the text concealed */ | ||
export const conceal = style(8, 28) | ||
/** Make the text black */ | ||
export const black = color(30) | ||
/** Make the text crossed-out */ | ||
export const crossout = style(9, 29) | ||
/** Make the text blue */ | ||
export const blue = color(34) | ||
/** Make the text crossed-out */ | ||
export const strikethrough = crossout | ||
/** Make the text cyan */ | ||
export const cyan = color(36) | ||
/** Make the text framed */ | ||
export const frame = style(51, 54) | ||
/** Make the text green */ | ||
export const green = color(32) | ||
/** Make the text encircled */ | ||
export const encircle = style(52, 54) | ||
/** Make the text magenta */ | ||
export const magenta = color(35) | ||
/** Make the text overlined */ | ||
export const overline = style(53, 55) | ||
/** Make the text black */ | ||
export const black = foregroundColor(Color.Black) | ||
/** Make the text red */ | ||
export const red = color(31) | ||
export const red = foregroundColor(Color.Red) | ||
/** Make the text green */ | ||
export const green = foregroundColor(Color.Green) | ||
/** Make the text yellow */ | ||
export const yellow = color(33) | ||
export const yellow = foregroundColor(Color.Yellow) | ||
/** Make the text blue */ | ||
export const blue = foregroundColor(Color.Blue) | ||
/** Make the text magenta */ | ||
export const magenta = foregroundColor(Color.Magenta) | ||
/** Make the text cyan */ | ||
export const cyan = foregroundColor(Color.Cyan) | ||
/** Make the text white */ | ||
export const white = foregroundColor(Color.White) | ||
/** Make the text bright black */ | ||
export const brightBlack = color(90) | ||
export const brightBlack = foregroundColor(Color.Black, true) | ||
/** Make the text bright red */ | ||
export const brightRed = color(91) | ||
export const brightRed = foregroundColor(Color.Red, true) | ||
/** Make the text bright green */ | ||
export const brightGreen = color(92) | ||
export const brightGreen = foregroundColor(Color.Green, true) | ||
/** Make the text bright yellow */ | ||
export const brightYellow = color(93) | ||
export const brightYellow = foregroundColor(Color.Yellow, true) | ||
/** Make the text bright blue */ | ||
export const brightBlue = color(94) | ||
export const brightBlue = foregroundColor(Color.Blue, true) | ||
/** Make the text bright magenta */ | ||
export const brightMagenta = color(95) | ||
export const brightMagenta = foregroundColor(Color.Magenta, true) | ||
/** Make the text bright cyan */ | ||
export const brightCyan = color(96) | ||
export const brightCyan = foregroundColor(Color.Cyan, true) | ||
/** Make the text bright white */ | ||
export const brightWhite = color(97) | ||
export const brightWhite = foregroundColor(Color.White, true) | ||
/** Make the text's background black */ | ||
export const bgBlack = backgroundColor(40) | ||
export const bgBlack = backgroundColor(Color.Black) | ||
/** Make the text's background red */ | ||
export const bgRed = backgroundColor(41) | ||
export const bgRed = backgroundColor(Color.Red) | ||
/** Make the text's background green */ | ||
export const bgGreen = backgroundColor(42) | ||
export const bgGreen = backgroundColor(Color.Green) | ||
/** Make the text's background yellow */ | ||
export const bgYellow = backgroundColor(43) | ||
export const bgYellow = backgroundColor(Color.Yellow) | ||
/** Make the text's background blue */ | ||
export const bgBlue = backgroundColor(44) | ||
export const bgBlue = backgroundColor(Color.Blue) | ||
/** Make the text's background magenta */ | ||
export const bgMagenta = backgroundColor(45) | ||
export const bgMagenta = backgroundColor(Color.Magenta) | ||
/** Make the text's background cyan */ | ||
export const bgCyan = backgroundColor(46) | ||
export const bgCyan = backgroundColor(Color.Cyan) | ||
/** Make the text's background white */ | ||
export const bgWhite = backgroundColor(47) | ||
export const bgWhite = backgroundColor(Color.White) | ||
/** Make the text's background bright black */ | ||
export const bgBrightBlack = backgroundColor(100) | ||
export const bgBrightBlack = backgroundColor(Color.Black, true) | ||
/** Make the text's background bright red */ | ||
export const bgBrightRed = backgroundColor(101) | ||
export const bgBrightRed = backgroundColor(Color.Red, true) | ||
/** Make the text's background bright green */ | ||
export const bgBrightGreen = backgroundColor(102) | ||
export const bgBrightGreen = backgroundColor(Color.Green, true) | ||
/** Make the text's background bright yellow */ | ||
export const bgBrightYellow = backgroundColor(103) | ||
export const bgBrightYellow = backgroundColor(Color.Yellow, true) | ||
/** Make the text's background bright blue */ | ||
export const bgBrightBlue = backgroundColor(104) | ||
export const bgBrightBlue = backgroundColor(Color.Blue, true) | ||
/** Make the text's background bright magenta */ | ||
export const bgBrightMagenta = backgroundColor(105) | ||
export const bgBrightMagenta = backgroundColor(Color.Magenta, true) | ||
/** Make the text's background bright cyan */ | ||
export const bgBrightCyan = backgroundColor(106) | ||
export const bgBrightCyan = backgroundColor(Color.Cyan, true) | ||
/** Make the text's background bright white */ | ||
export const bgBrightWhite = backgroundColor(107) | ||
export const bgBrightWhite = backgroundColor(Color.White, true) |
@@ -1,16 +0,16 @@ | ||
/* | ||
* Color Codes explained: http://www.termsys.demon.co.uk/vtansi.htm#colors | ||
* Following caveats: | ||
* bright - brightens the color (bold-blue is same as brightBlue) | ||
* dim - nothing on Mac or Linux | ||
* italic - nothing on Mac or Linux | ||
* underline - underlines string | ||
* blink - nothing on Mac or linux | ||
* inverse - background becomes foreground and vice versa | ||
* | ||
* In summary, the only styles that work are: | ||
* - bright, underline and inverse | ||
* - the others are only included for completeness | ||
*/ | ||
// Styles | ||
// https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
// Colors | ||
// https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit | ||
export var Color | ||
;(function (Color) { | ||
Color[(Color['Black'] = 0)] = 'Black' | ||
Color[(Color['Red'] = 1)] = 'Red' | ||
Color[(Color['Green'] = 2)] = 'Green' | ||
Color[(Color['Yellow'] = 3)] = 'Yellow' | ||
Color[(Color['Blue'] = 4)] = 'Blue' | ||
Color[(Color['Magenta'] = 5)] = 'Magenta' | ||
Color[(Color['Cyan'] = 6)] = 'Cyan' | ||
Color[(Color['White'] = 7)] = 'White' | ||
})(Color || (Color = {})) | ||
/** A factory method to generate an ANSI style applier from the open and close codes */ | ||
@@ -20,16 +20,28 @@ export function style(open, close) { | ||
} | ||
/** A factory method to generate an ANSI color applier from the color code */ | ||
export function color(open) { | ||
return style(open, 39) | ||
/** A factory method to generate an ANSI foreground color applier from the foreground color code */ | ||
export function foregroundColor(color, bright = false) { | ||
// 30-37, 38 | ||
return style((bright ? 90 : 30) + color, 39) | ||
} | ||
/** A factory method to generate an ANSI background color applier from the background color code */ | ||
export function backgroundColor(open) { | ||
return style(open, 49) | ||
export function backgroundColor(color, bright = false) { | ||
// 40-47, 48 | ||
return style((bright ? 100 : 40) + color, 49) | ||
} | ||
// /** A factory method to generate an ANSI underline color applier from the underline color code */ | ||
// export function underlineColor(open: number) { | ||
// // 58, 59 | ||
// // requires a different style to set the colour though, which needs to be figured out | ||
// return style(open, 59) | ||
// } | ||
/** Make the text look normal */ | ||
export const reset = style(0, 22) | ||
/** Make the text brighter than usual */ | ||
export const bright = style(1, 22) | ||
/** Make the text dimmer than usual */ | ||
export const dim = style(2, 22) | ||
/** Make the text bold, or with increased intensity */ | ||
export const bold = style(1, 22) | ||
/** Make the text faint, or with decreased intensity */ | ||
export const faint = style(2, 22) | ||
/** Make the text bold, or with increased intensity */ | ||
export const bright = bold | ||
/** Make the text faint, or with decreased intensity */ | ||
export const dim = faint | ||
/** Make the text italicized */ | ||
@@ -39,69 +51,85 @@ export const italic = style(3, 23) | ||
export const underline = style(4, 24) | ||
/** Make the text blink */ | ||
export const blink = style(5, 25) | ||
/** Make the text slow blink */ | ||
export const slowBlink = style(5, 25) | ||
/** Make the text slow blink */ | ||
export const blink = slowBlink | ||
/** Make the text rapid blink */ | ||
export const rapidBlink = style(6, 25) | ||
/** Invert the colors of the text */ | ||
export const inverse = style(7, 27) | ||
/** Make the text white */ | ||
export const white = color(37) | ||
/** Make the text concealed */ | ||
export const conceal = style(8, 28) | ||
/** Make the text crossed-out */ | ||
export const crossout = style(9, 29) | ||
/** Make the text crossed-out */ | ||
export const strikethrough = crossout | ||
/** Make the text framed */ | ||
export const frame = style(51, 54) | ||
/** Make the text encircled */ | ||
export const encircle = style(52, 54) | ||
/** Make the text overlined */ | ||
export const overline = style(53, 55) | ||
/** Make the text black */ | ||
export const black = color(30) | ||
export const black = foregroundColor(Color.Black) | ||
/** Make the text red */ | ||
export const red = foregroundColor(Color.Red) | ||
/** Make the text green */ | ||
export const green = foregroundColor(Color.Green) | ||
/** Make the text yellow */ | ||
export const yellow = foregroundColor(Color.Yellow) | ||
/** Make the text blue */ | ||
export const blue = color(34) | ||
export const blue = foregroundColor(Color.Blue) | ||
/** Make the text magenta */ | ||
export const magenta = foregroundColor(Color.Magenta) | ||
/** Make the text cyan */ | ||
export const cyan = color(36) | ||
/** Make the text green */ | ||
export const green = color(32) | ||
/** Make the text magenta */ | ||
export const magenta = color(35) | ||
/** Make the text red */ | ||
export const red = color(31) | ||
/** Make the text yellow */ | ||
export const yellow = color(33) | ||
export const cyan = foregroundColor(Color.Cyan) | ||
/** Make the text white */ | ||
export const white = foregroundColor(Color.White) | ||
/** Make the text bright black */ | ||
export const brightBlack = color(90) | ||
export const brightBlack = foregroundColor(Color.Black, true) | ||
/** Make the text bright red */ | ||
export const brightRed = color(91) | ||
export const brightRed = foregroundColor(Color.Red, true) | ||
/** Make the text bright green */ | ||
export const brightGreen = color(92) | ||
export const brightGreen = foregroundColor(Color.Green, true) | ||
/** Make the text bright yellow */ | ||
export const brightYellow = color(93) | ||
export const brightYellow = foregroundColor(Color.Yellow, true) | ||
/** Make the text bright blue */ | ||
export const brightBlue = color(94) | ||
export const brightBlue = foregroundColor(Color.Blue, true) | ||
/** Make the text bright magenta */ | ||
export const brightMagenta = color(95) | ||
export const brightMagenta = foregroundColor(Color.Magenta, true) | ||
/** Make the text bright cyan */ | ||
export const brightCyan = color(96) | ||
export const brightCyan = foregroundColor(Color.Cyan, true) | ||
/** Make the text bright white */ | ||
export const brightWhite = color(97) | ||
export const brightWhite = foregroundColor(Color.White, true) | ||
/** Make the text's background black */ | ||
export const bgBlack = backgroundColor(40) | ||
export const bgBlack = backgroundColor(Color.Black) | ||
/** Make the text's background red */ | ||
export const bgRed = backgroundColor(41) | ||
export const bgRed = backgroundColor(Color.Red) | ||
/** Make the text's background green */ | ||
export const bgGreen = backgroundColor(42) | ||
export const bgGreen = backgroundColor(Color.Green) | ||
/** Make the text's background yellow */ | ||
export const bgYellow = backgroundColor(43) | ||
export const bgYellow = backgroundColor(Color.Yellow) | ||
/** Make the text's background blue */ | ||
export const bgBlue = backgroundColor(44) | ||
export const bgBlue = backgroundColor(Color.Blue) | ||
/** Make the text's background magenta */ | ||
export const bgMagenta = backgroundColor(45) | ||
export const bgMagenta = backgroundColor(Color.Magenta) | ||
/** Make the text's background cyan */ | ||
export const bgCyan = backgroundColor(46) | ||
export const bgCyan = backgroundColor(Color.Cyan) | ||
/** Make the text's background white */ | ||
export const bgWhite = backgroundColor(47) | ||
export const bgWhite = backgroundColor(Color.White) | ||
/** Make the text's background bright black */ | ||
export const bgBrightBlack = backgroundColor(100) | ||
export const bgBrightBlack = backgroundColor(Color.Black, true) | ||
/** Make the text's background bright red */ | ||
export const bgBrightRed = backgroundColor(101) | ||
export const bgBrightRed = backgroundColor(Color.Red, true) | ||
/** Make the text's background bright green */ | ||
export const bgBrightGreen = backgroundColor(102) | ||
export const bgBrightGreen = backgroundColor(Color.Green, true) | ||
/** Make the text's background bright yellow */ | ||
export const bgBrightYellow = backgroundColor(103) | ||
export const bgBrightYellow = backgroundColor(Color.Yellow, true) | ||
/** Make the text's background bright blue */ | ||
export const bgBrightBlue = backgroundColor(104) | ||
export const bgBrightBlue = backgroundColor(Color.Blue, true) | ||
/** Make the text's background bright magenta */ | ||
export const bgBrightMagenta = backgroundColor(105) | ||
export const bgBrightMagenta = backgroundColor(Color.Magenta, true) | ||
/** Make the text's background bright cyan */ | ||
export const bgBrightCyan = backgroundColor(106) | ||
export const bgBrightCyan = backgroundColor(Color.Cyan, true) | ||
/** Make the text's background bright white */ | ||
export const bgBrightWhite = backgroundColor(107) | ||
export const bgBrightWhite = backgroundColor(Color.White, true) |
'use strict' | ||
/* | ||
* Color Codes explained: http://www.termsys.demon.co.uk/vtansi.htm#colors | ||
* Following caveats: | ||
* bright - brightens the color (bold-blue is same as brightBlue) | ||
* dim - nothing on Mac or Linux | ||
* italic - nothing on Mac or Linux | ||
* underline - underlines string | ||
* blink - nothing on Mac or linux | ||
* inverse - background becomes foreground and vice versa | ||
* | ||
* In summary, the only styles that work are: | ||
* - bright, underline and inverse | ||
* - the others are only included for completeness | ||
*/ | ||
// Styles | ||
// https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
exports.bgBrightWhite = exports.bgBrightCyan = exports.bgBrightMagenta = exports.bgBrightBlue = exports.bgBrightYellow = exports.bgBrightGreen = exports.bgBrightRed = exports.bgBrightBlack = exports.bgWhite = exports.bgCyan = exports.bgMagenta = exports.bgBlue = exports.bgYellow = exports.bgGreen = exports.bgRed = exports.bgBlack = exports.brightWhite = exports.brightCyan = exports.brightMagenta = exports.brightBlue = exports.brightYellow = exports.brightGreen = exports.brightRed = exports.brightBlack = exports.yellow = exports.red = exports.magenta = exports.green = exports.cyan = exports.blue = exports.black = exports.white = exports.inverse = exports.blink = exports.underline = exports.italic = exports.dim = exports.bright = exports.reset = exports.backgroundColor = exports.color = exports.style = void 0 | ||
exports.bgBrightWhite = exports.bgBrightCyan = exports.bgBrightMagenta = exports.bgBrightBlue = exports.bgBrightYellow = exports.bgBrightGreen = exports.bgBrightRed = exports.bgBrightBlack = exports.bgWhite = exports.bgCyan = exports.bgMagenta = exports.bgBlue = exports.bgYellow = exports.bgGreen = exports.bgRed = exports.bgBlack = exports.brightWhite = exports.brightCyan = exports.brightMagenta = exports.brightBlue = exports.brightYellow = exports.brightGreen = exports.brightRed = exports.brightBlack = exports.white = exports.cyan = exports.magenta = exports.blue = exports.yellow = exports.green = exports.red = exports.black = exports.overline = exports.encircle = exports.frame = exports.strikethrough = exports.crossout = exports.conceal = exports.inverse = exports.rapidBlink = exports.blink = exports.slowBlink = exports.underline = exports.italic = exports.dim = exports.bright = exports.faint = exports.bold = exports.reset = exports.backgroundColor = exports.foregroundColor = exports.style = exports.Color = void 0 | ||
// Colors | ||
// https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit | ||
var Color | ||
;(function (Color) { | ||
Color[(Color['Black'] = 0)] = 'Black' | ||
Color[(Color['Red'] = 1)] = 'Red' | ||
Color[(Color['Green'] = 2)] = 'Green' | ||
Color[(Color['Yellow'] = 3)] = 'Yellow' | ||
Color[(Color['Blue'] = 4)] = 'Blue' | ||
Color[(Color['Magenta'] = 5)] = 'Magenta' | ||
Color[(Color['Cyan'] = 6)] = 'Cyan' | ||
Color[(Color['White'] = 7)] = 'White' | ||
})((Color = exports.Color || (exports.Color = {}))) | ||
/** A factory method to generate an ANSI style applier from the open and close codes */ | ||
@@ -24,18 +24,30 @@ function style(open, close) { | ||
exports.style = style | ||
/** A factory method to generate an ANSI color applier from the color code */ | ||
function color(open) { | ||
return style(open, 39) | ||
/** A factory method to generate an ANSI foreground color applier from the foreground color code */ | ||
function foregroundColor(color, bright = false) { | ||
// 30-37, 38 | ||
return style((bright ? 90 : 30) + color, 39) | ||
} | ||
exports.color = color | ||
exports.foregroundColor = foregroundColor | ||
/** A factory method to generate an ANSI background color applier from the background color code */ | ||
function backgroundColor(open) { | ||
return style(open, 49) | ||
function backgroundColor(color, bright = false) { | ||
// 40-47, 48 | ||
return style((bright ? 100 : 40) + color, 49) | ||
} | ||
exports.backgroundColor = backgroundColor | ||
// /** A factory method to generate an ANSI underline color applier from the underline color code */ | ||
// export function underlineColor(open: number) { | ||
// // 58, 59 | ||
// // requires a different style to set the colour though, which needs to be figured out | ||
// return style(open, 59) | ||
// } | ||
/** Make the text look normal */ | ||
exports.reset = style(0, 22) | ||
/** Make the text brighter than usual */ | ||
exports.bright = style(1, 22) | ||
/** Make the text dimmer than usual */ | ||
exports.dim = style(2, 22) | ||
/** Make the text bold, or with increased intensity */ | ||
exports.bold = style(1, 22) | ||
/** Make the text faint, or with decreased intensity */ | ||
exports.faint = style(2, 22) | ||
/** Make the text bold, or with increased intensity */ | ||
exports.bright = exports.bold | ||
/** Make the text faint, or with decreased intensity */ | ||
exports.dim = exports.faint | ||
/** Make the text italicized */ | ||
@@ -45,69 +57,85 @@ exports.italic = style(3, 23) | ||
exports.underline = style(4, 24) | ||
/** Make the text blink */ | ||
exports.blink = style(5, 25) | ||
/** Make the text slow blink */ | ||
exports.slowBlink = style(5, 25) | ||
/** Make the text slow blink */ | ||
exports.blink = exports.slowBlink | ||
/** Make the text rapid blink */ | ||
exports.rapidBlink = style(6, 25) | ||
/** Invert the colors of the text */ | ||
exports.inverse = style(7, 27) | ||
/** Make the text white */ | ||
exports.white = color(37) | ||
/** Make the text concealed */ | ||
exports.conceal = style(8, 28) | ||
/** Make the text crossed-out */ | ||
exports.crossout = style(9, 29) | ||
/** Make the text crossed-out */ | ||
exports.strikethrough = exports.crossout | ||
/** Make the text framed */ | ||
exports.frame = style(51, 54) | ||
/** Make the text encircled */ | ||
exports.encircle = style(52, 54) | ||
/** Make the text overlined */ | ||
exports.overline = style(53, 55) | ||
/** Make the text black */ | ||
exports.black = color(30) | ||
exports.black = foregroundColor(Color.Black) | ||
/** Make the text red */ | ||
exports.red = foregroundColor(Color.Red) | ||
/** Make the text green */ | ||
exports.green = foregroundColor(Color.Green) | ||
/** Make the text yellow */ | ||
exports.yellow = foregroundColor(Color.Yellow) | ||
/** Make the text blue */ | ||
exports.blue = color(34) | ||
exports.blue = foregroundColor(Color.Blue) | ||
/** Make the text magenta */ | ||
exports.magenta = foregroundColor(Color.Magenta) | ||
/** Make the text cyan */ | ||
exports.cyan = color(36) | ||
/** Make the text green */ | ||
exports.green = color(32) | ||
/** Make the text magenta */ | ||
exports.magenta = color(35) | ||
/** Make the text red */ | ||
exports.red = color(31) | ||
/** Make the text yellow */ | ||
exports.yellow = color(33) | ||
exports.cyan = foregroundColor(Color.Cyan) | ||
/** Make the text white */ | ||
exports.white = foregroundColor(Color.White) | ||
/** Make the text bright black */ | ||
exports.brightBlack = color(90) | ||
exports.brightBlack = foregroundColor(Color.Black, true) | ||
/** Make the text bright red */ | ||
exports.brightRed = color(91) | ||
exports.brightRed = foregroundColor(Color.Red, true) | ||
/** Make the text bright green */ | ||
exports.brightGreen = color(92) | ||
exports.brightGreen = foregroundColor(Color.Green, true) | ||
/** Make the text bright yellow */ | ||
exports.brightYellow = color(93) | ||
exports.brightYellow = foregroundColor(Color.Yellow, true) | ||
/** Make the text bright blue */ | ||
exports.brightBlue = color(94) | ||
exports.brightBlue = foregroundColor(Color.Blue, true) | ||
/** Make the text bright magenta */ | ||
exports.brightMagenta = color(95) | ||
exports.brightMagenta = foregroundColor(Color.Magenta, true) | ||
/** Make the text bright cyan */ | ||
exports.brightCyan = color(96) | ||
exports.brightCyan = foregroundColor(Color.Cyan, true) | ||
/** Make the text bright white */ | ||
exports.brightWhite = color(97) | ||
exports.brightWhite = foregroundColor(Color.White, true) | ||
/** Make the text's background black */ | ||
exports.bgBlack = backgroundColor(40) | ||
exports.bgBlack = backgroundColor(Color.Black) | ||
/** Make the text's background red */ | ||
exports.bgRed = backgroundColor(41) | ||
exports.bgRed = backgroundColor(Color.Red) | ||
/** Make the text's background green */ | ||
exports.bgGreen = backgroundColor(42) | ||
exports.bgGreen = backgroundColor(Color.Green) | ||
/** Make the text's background yellow */ | ||
exports.bgYellow = backgroundColor(43) | ||
exports.bgYellow = backgroundColor(Color.Yellow) | ||
/** Make the text's background blue */ | ||
exports.bgBlue = backgroundColor(44) | ||
exports.bgBlue = backgroundColor(Color.Blue) | ||
/** Make the text's background magenta */ | ||
exports.bgMagenta = backgroundColor(45) | ||
exports.bgMagenta = backgroundColor(Color.Magenta) | ||
/** Make the text's background cyan */ | ||
exports.bgCyan = backgroundColor(46) | ||
exports.bgCyan = backgroundColor(Color.Cyan) | ||
/** Make the text's background white */ | ||
exports.bgWhite = backgroundColor(47) | ||
exports.bgWhite = backgroundColor(Color.White) | ||
/** Make the text's background bright black */ | ||
exports.bgBrightBlack = backgroundColor(100) | ||
exports.bgBrightBlack = backgroundColor(Color.Black, true) | ||
/** Make the text's background bright red */ | ||
exports.bgBrightRed = backgroundColor(101) | ||
exports.bgBrightRed = backgroundColor(Color.Red, true) | ||
/** Make the text's background bright green */ | ||
exports.bgBrightGreen = backgroundColor(102) | ||
exports.bgBrightGreen = backgroundColor(Color.Green, true) | ||
/** Make the text's background bright yellow */ | ||
exports.bgBrightYellow = backgroundColor(103) | ||
exports.bgBrightYellow = backgroundColor(Color.Yellow, true) | ||
/** Make the text's background bright blue */ | ||
exports.bgBrightBlue = backgroundColor(104) | ||
exports.bgBrightBlue = backgroundColor(Color.Blue, true) | ||
/** Make the text's background bright magenta */ | ||
exports.bgBrightMagenta = backgroundColor(105) | ||
exports.bgBrightMagenta = backgroundColor(Color.Magenta, true) | ||
/** Make the text's background bright cyan */ | ||
exports.bgBrightCyan = backgroundColor(106) | ||
exports.bgBrightCyan = backgroundColor(Color.Cyan, true) | ||
/** Make the text's background bright white */ | ||
exports.bgBrightWhite = backgroundColor(107) | ||
exports.bgBrightWhite = backgroundColor(Color.White, true) |
# History | ||
## v3.0.0 2020 November 3 | ||
- Added missing styles and aliases | ||
- Color and style methods remain the same, however if you were a rare user who used the factory method to generate custom colours, those methods now accept different inputs | ||
- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation) | ||
## v2.1.0 2020 October 29 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@bevry/ansi", | ||
"version": "2.1.0", | ||
"description": "Fork of @thlorenz's ansicolors and ansistyles packages that converts them to typescript and makes them compatible with deno", | ||
"version": "3.0.0-next.1604376478.2b78ad17455acaf17ffa8fbf3e7cb0c99b8d1c48", | ||
"description": "ANSI colors and styles for Deno, Node.js, JavaScript, and TypeScript", | ||
"homepage": "https://github.com/bevry/ansi", | ||
@@ -9,6 +9,18 @@ "license": "MIT", | ||
"256", | ||
"8", | ||
"ansi", | ||
"background", | ||
"bit", | ||
"black", | ||
"blink", | ||
"blue", | ||
"bold", | ||
"bright", | ||
"browser", | ||
"cicle", | ||
"color", | ||
"colour", | ||
"crossed-out", | ||
"crossout", | ||
"cyan", | ||
"deno", | ||
@@ -18,9 +30,31 @@ "deno-edition", | ||
"denoland", | ||
"dim", | ||
"encircle", | ||
"encircled", | ||
"es5", | ||
"esnext", | ||
"faint", | ||
"fast", | ||
"foreground", | ||
"formatting", | ||
"frame", | ||
"framed", | ||
"green", | ||
"highlight", | ||
"inverse", | ||
"invert", | ||
"italic", | ||
"magenta", | ||
"module", | ||
"node", | ||
"overline", | ||
"overlined", | ||
"rapid", | ||
"red", | ||
"reset", | ||
"rgb", | ||
"slow", | ||
"strikethrough", | ||
"string", | ||
"style", | ||
"styles", | ||
@@ -30,3 +64,6 @@ "terminal", | ||
"types", | ||
"typescript" | ||
"typescript", | ||
"underline", | ||
"white", | ||
"yellow" | ||
], | ||
@@ -114,3 +151,3 @@ "badges": { | ||
{ | ||
"description": "TypeScript compiled against ESNext for Node.js 4 || 6 || 8 || 10 || 12 || 14 || 15 with Require for modules", | ||
"description": "TypeScript compiled against ESNext for Node.js 6 || 8 || 10 || 12 || 14 || 15 with Require for modules", | ||
"directory": "edition-esnext", | ||
@@ -125,2 +162,17 @@ "entry": "index.js", | ||
"engines": { | ||
"node": "6 || 8 || 10 || 12 || 14 || 15", | ||
"browsers": false | ||
} | ||
}, | ||
{ | ||
"description": "TypeScript compiled against ES5 for Node.js 4 || 6 || 8 || 10 || 12 || 14 || 15 with Require for modules", | ||
"directory": "edition-es5", | ||
"entry": "index.js", | ||
"tags": [ | ||
"compiled", | ||
"javascript", | ||
"es5", | ||
"require" | ||
], | ||
"engines": { | ||
"node": "4 || 6 || 8 || 10 || 12 || 14 || 15", | ||
@@ -162,6 +214,7 @@ "browsers": false | ||
"type": "module", | ||
"main": "edition-esnext/index.js", | ||
"main": "index.cjs", | ||
"exports": { | ||
"node": { | ||
"import": "./edition-esnext-esm/index.js", | ||
"default": "./index.cjs", | ||
"require": "./edition-esnext/index.js" | ||
@@ -176,9 +229,12 @@ }, | ||
"module": "edition-browsers/index.js", | ||
"dependencies": { | ||
"editions": "^6.1.0" | ||
}, | ||
"devDependencies": { | ||
"@bevry/update-contributors": "^1.17.0", | ||
"@typescript-eslint/eslint-plugin": "^4.6.0", | ||
"@typescript-eslint/parser": "^4.6.0", | ||
"assert-helpers": "^8.0.1", | ||
"@bevry/update-contributors": "^1.18.0", | ||
"@typescript-eslint/eslint-plugin": "^4.6.1", | ||
"@typescript-eslint/parser": "^4.6.1", | ||
"assert-helpers": "^8.1.0", | ||
"eslint": "^7.12.1", | ||
"eslint-config-bevry": "^3.22.0", | ||
"eslint-config-bevry": "^3.23.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
@@ -189,14 +245,15 @@ "eslint-plugin-prettier": "^3.1.4", | ||
"prettier": "^2.1.2", | ||
"projectz": "^2.16.0", | ||
"projectz": "^2.17.0", | ||
"surge": "^0.21.6", | ||
"typedoc": "^0.19.2", | ||
"typescript": "^4.0.5", | ||
"valid-directory": "^3.4.0", | ||
"valid-module": "^1.14.0" | ||
"valid-directory": "^3.5.0", | ||
"valid-module": "^1.15.0" | ||
}, | ||
"scripts": { | ||
"our:clean": "rm -Rf ./docs ./edition* ./es2015 ./es5 ./out ./.next", | ||
"our:compile": "npm run our:compile:deno && npm run our:compile:edition-browsers && npm run our:compile:edition-esnext && npm run our:compile:edition-esnext-esm && npm run our:compile:types", | ||
"our:compile": "npm run our:compile:deno && npm run our:compile:edition-browsers && npm run our:compile:edition-es5 && npm run our:compile:edition-esnext && npm run our:compile:edition-esnext-esm && npm run our:compile:types", | ||
"our:compile:deno": "make-deno-edition --attempt", | ||
"our:compile:edition-browsers": "tsc --module ESNext --target ES2019 --outDir ./edition-browsers --project tsconfig.json && ( test ! -d edition-browsers/source || ( mv edition-browsers/source edition-temp && rm -Rf edition-browsers && mv edition-temp edition-browsers ) )", | ||
"our:compile:edition-es5": "tsc --module commonjs --target ES5 --outDir ./edition-es5 --project tsconfig.json && ( test ! -d edition-es5/source || ( mv edition-es5/source edition-temp && rm -Rf edition-es5 && mv edition-temp edition-es5 ) ) && echo '{\"type\": \"commonjs\"}' > edition-es5/package.json", | ||
"our:compile:edition-esnext": "tsc --module commonjs --target ESNext --outDir ./edition-esnext --project tsconfig.json && ( test ! -d edition-esnext/source || ( mv edition-esnext/source edition-temp && rm -Rf edition-esnext && mv edition-temp edition-esnext ) ) && echo '{\"type\": \"commonjs\"}' > edition-esnext/package.json", | ||
@@ -225,3 +282,3 @@ "our:compile:edition-esnext-esm": "tsc --module ESNext --target ESNext --outDir ./edition-esnext-esm --project tsconfig.json && ( test ! -d edition-esnext-esm/source || ( mv edition-esnext-esm/source edition-temp && rm -Rf edition-esnext-esm && mv edition-temp edition-esnext-esm ) ) && echo '{\"type\": \"module\"}' > edition-esnext-esm/package.json", | ||
"our:verify:prettier": "prettier --write .", | ||
"test": "node ./edition-esnext/test.js" | ||
"test": "node ./test.cjs" | ||
}, | ||
@@ -228,0 +285,0 @@ "eslintConfig": { |
@@ -31,3 +31,3 @@ <!-- TITLE/ --> | ||
Fork of @thlorenz's ansicolors and ansistyles packages that converts them to typescript and makes them compatible with deno | ||
ANSI colors and styles for Deno, Node.js, JavaScript, and TypeScript | ||
@@ -37,2 +37,4 @@ <!-- /DESCRIPTION --> | ||
Foundations of this project were [Thorsten Lorenz's](https://github.com/thlorenz) excellent work on the early [ansistyles](https://github.com/thlorenz/ansistyles) and [ansicolors](https://github.com/thlorenz/ansicolors) packages. | ||
## Usage | ||
@@ -56,3 +58,3 @@ | ||
``` typescript | ||
import * as pkg from 'https://unpkg.com/@bevry/ansi@^2.1.0/edition-deno/index.ts' | ||
import * as pkg from 'https://unpkg.com/@bevry/ansi@^3.0.0/edition-deno/index.ts' | ||
``` | ||
@@ -64,3 +66,3 @@ | ||
<script type="module"> | ||
import * as pkg from '//cdn.skypack.dev/@bevry/ansi@^2.1.0' | ||
import * as pkg from '//cdn.skypack.dev/@bevry/ansi@^3.0.0' | ||
</script> | ||
@@ -73,3 +75,3 @@ ``` | ||
<script type="module"> | ||
import * as pkg from '//unpkg.com/@bevry/ansi@^2.1.0' | ||
import * as pkg from '//unpkg.com/@bevry/ansi@^3.0.0' | ||
</script> | ||
@@ -82,3 +84,3 @@ ``` | ||
<script type="module"> | ||
import * as pkg from '//dev.jspm.io/@bevry/ansi@2.1.0' | ||
import * as pkg from '//dev.jspm.io/@bevry/ansi@3.0.0' | ||
</script> | ||
@@ -91,6 +93,7 @@ ``` | ||
<ul><li><code>@bevry/ansi/source/index.ts</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> source code with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li> | ||
<ul><li><code>@bevry/ansi</code> aliases <code>@bevry/ansi/index.cjs</code> which uses the <a href="https://github.com/bevry/editions" title="You can use the Editions Autoloader to autoload the appropriate edition for your consumers environment">Editions Autoloader</a> to automatically select the correct edition for the consumer's environment</li> | ||
<li><code>@bevry/ansi/source/index.ts</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> source code with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li> | ||
<li><code>@bevry/ansi/edition-browsers/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_-_ECMAScript_2019" title="ECMAScript ES2019">ES2019</a> for web browsers with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li> | ||
<li><code>@bevry/ansi</code> aliases <code>@bevry/ansi/edition-esnext/index.js</code></li> | ||
<li><code>@bevry/ansi/edition-esnext/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> 4 || 6 || 8 || 10 || 12 || 14 || 15 with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li> | ||
<li><code>@bevry/ansi/edition-esnext/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> 6 || 8 || 10 || 12 || 14 || 15 with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li> | ||
<li><code>@bevry/ansi/edition-es5/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against ES5 for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> 4 || 6 || 8 || 10 || 12 || 14 || 15 with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li> | ||
<li><code>@bevry/ansi/edition-esnext-esm/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> 12 || 14 || 15 with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li> | ||
@@ -97,0 +100,0 @@ <li><code>@bevry/ansi/edition-deno/index.ts</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> source code made to be compatible with <a href="https://deno.land" title="Deno is a secure runtime for JavaScript and TypeScript, it is an alternative to Node.js">Deno</a></li></ul> |
@@ -1,16 +0,16 @@ | ||
/* | ||
* Color Codes explained: http://www.termsys.demon.co.uk/vtansi.htm#colors | ||
// Styles | ||
// https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
* Following caveats: | ||
* bright - brightens the color (bold-blue is same as brightBlue) | ||
* dim - nothing on Mac or Linux | ||
* italic - nothing on Mac or Linux | ||
* underline - underlines string | ||
* blink - nothing on Mac or linux | ||
* inverse - background becomes foreground and vice versa | ||
* | ||
* In summary, the only styles that work are: | ||
* - bright, underline and inverse | ||
* - the others are only included for completeness | ||
*/ | ||
// Colors | ||
// https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit | ||
export enum Color { | ||
Black = 0, | ||
Red = 1, | ||
Green = 2, | ||
Yellow = 3, | ||
Blue = 4, | ||
Magenta = 5, | ||
Cyan = 6, | ||
White = 7, | ||
} | ||
@@ -22,21 +22,36 @@ /** A factory method to generate an ANSI style applier from the open and close codes */ | ||
/** A factory method to generate an ANSI color applier from the color code */ | ||
export function color(open: number) { | ||
return style(open, 39) | ||
/** A factory method to generate an ANSI foreground color applier from the foreground color code */ | ||
export function foregroundColor(color: Color, bright = false) { | ||
// 30-37, 38 | ||
return style((bright ? 90 : 30) + color, 39) | ||
} | ||
/** A factory method to generate an ANSI background color applier from the background color code */ | ||
export function backgroundColor(open: number) { | ||
return style(open, 49) | ||
export function backgroundColor(color: Color, bright = false) { | ||
// 40-47, 48 | ||
return style((bright ? 100 : 40) + color, 49) | ||
} | ||
// /** A factory method to generate an ANSI underline color applier from the underline color code */ | ||
// export function underlineColor(open: number) { | ||
// // 58, 59 | ||
// // requires a different style to set the colour though, which needs to be figured out | ||
// return style(open, 59) | ||
// } | ||
/** Make the text look normal */ | ||
export const reset = style(0, 22) | ||
/** Make the text brighter than usual */ | ||
export const bright = style(1, 22) | ||
/** Make the text bold, or with increased intensity */ | ||
export const bold = style(1, 22) | ||
/** Make the text dimmer than usual */ | ||
export const dim = style(2, 22) | ||
/** Make the text faint, or with decreased intensity */ | ||
export const faint = style(2, 22) | ||
/** Make the text bold, or with increased intensity */ | ||
export const bright = bold | ||
/** Make the text faint, or with decreased intensity */ | ||
export const dim = faint | ||
/** Make the text italicized */ | ||
@@ -48,102 +63,126 @@ export const italic = style(3, 23) | ||
/** Make the text blink */ | ||
export const blink = style(5, 25) | ||
/** Make the text slow blink */ | ||
export const slowBlink = style(5, 25) | ||
/** Make the text slow blink */ | ||
export const blink = slowBlink | ||
/** Make the text rapid blink */ | ||
export const rapidBlink = style(6, 25) | ||
/** Invert the colors of the text */ | ||
export const inverse = style(7, 27) | ||
/** Make the text white */ | ||
export const white = color(37) | ||
/** Make the text concealed */ | ||
export const conceal = style(8, 28) | ||
/** Make the text black */ | ||
export const black = color(30) | ||
/** Make the text crossed-out */ | ||
export const crossout = style(9, 29) | ||
/** Make the text blue */ | ||
export const blue = color(34) | ||
/** Make the text crossed-out */ | ||
export const strikethrough = crossout | ||
/** Make the text cyan */ | ||
export const cyan = color(36) | ||
/** Make the text framed */ | ||
export const frame = style(51, 54) | ||
/** Make the text green */ | ||
export const green = color(32) | ||
/** Make the text encircled */ | ||
export const encircle = style(52, 54) | ||
/** Make the text magenta */ | ||
export const magenta = color(35) | ||
/** Make the text overlined */ | ||
export const overline = style(53, 55) | ||
/** Make the text black */ | ||
export const black = foregroundColor(Color.Black) | ||
/** Make the text red */ | ||
export const red = color(31) | ||
export const red = foregroundColor(Color.Red) | ||
/** Make the text green */ | ||
export const green = foregroundColor(Color.Green) | ||
/** Make the text yellow */ | ||
export const yellow = color(33) | ||
export const yellow = foregroundColor(Color.Yellow) | ||
/** Make the text blue */ | ||
export const blue = foregroundColor(Color.Blue) | ||
/** Make the text magenta */ | ||
export const magenta = foregroundColor(Color.Magenta) | ||
/** Make the text cyan */ | ||
export const cyan = foregroundColor(Color.Cyan) | ||
/** Make the text white */ | ||
export const white = foregroundColor(Color.White) | ||
/** Make the text bright black */ | ||
export const brightBlack = color(90) | ||
export const brightBlack = foregroundColor(Color.Black, true) | ||
/** Make the text bright red */ | ||
export const brightRed = color(91) | ||
export const brightRed = foregroundColor(Color.Red, true) | ||
/** Make the text bright green */ | ||
export const brightGreen = color(92) | ||
export const brightGreen = foregroundColor(Color.Green, true) | ||
/** Make the text bright yellow */ | ||
export const brightYellow = color(93) | ||
export const brightYellow = foregroundColor(Color.Yellow, true) | ||
/** Make the text bright blue */ | ||
export const brightBlue = color(94) | ||
export const brightBlue = foregroundColor(Color.Blue, true) | ||
/** Make the text bright magenta */ | ||
export const brightMagenta = color(95) | ||
export const brightMagenta = foregroundColor(Color.Magenta, true) | ||
/** Make the text bright cyan */ | ||
export const brightCyan = color(96) | ||
export const brightCyan = foregroundColor(Color.Cyan, true) | ||
/** Make the text bright white */ | ||
export const brightWhite = color(97) | ||
export const brightWhite = foregroundColor(Color.White, true) | ||
/** Make the text's background black */ | ||
export const bgBlack = backgroundColor(40) | ||
export const bgBlack = backgroundColor(Color.Black) | ||
/** Make the text's background red */ | ||
export const bgRed = backgroundColor(41) | ||
export const bgRed = backgroundColor(Color.Red) | ||
/** Make the text's background green */ | ||
export const bgGreen = backgroundColor(42) | ||
export const bgGreen = backgroundColor(Color.Green) | ||
/** Make the text's background yellow */ | ||
export const bgYellow = backgroundColor(43) | ||
export const bgYellow = backgroundColor(Color.Yellow) | ||
/** Make the text's background blue */ | ||
export const bgBlue = backgroundColor(44) | ||
export const bgBlue = backgroundColor(Color.Blue) | ||
/** Make the text's background magenta */ | ||
export const bgMagenta = backgroundColor(45) | ||
export const bgMagenta = backgroundColor(Color.Magenta) | ||
/** Make the text's background cyan */ | ||
export const bgCyan = backgroundColor(46) | ||
export const bgCyan = backgroundColor(Color.Cyan) | ||
/** Make the text's background white */ | ||
export const bgWhite = backgroundColor(47) | ||
export const bgWhite = backgroundColor(Color.White) | ||
/** Make the text's background bright black */ | ||
export const bgBrightBlack = backgroundColor(100) | ||
export const bgBrightBlack = backgroundColor(Color.Black, true) | ||
/** Make the text's background bright red */ | ||
export const bgBrightRed = backgroundColor(101) | ||
export const bgBrightRed = backgroundColor(Color.Red, true) | ||
/** Make the text's background bright green */ | ||
export const bgBrightGreen = backgroundColor(102) | ||
export const bgBrightGreen = backgroundColor(Color.Green, true) | ||
/** Make the text's background bright yellow */ | ||
export const bgBrightYellow = backgroundColor(103) | ||
export const bgBrightYellow = backgroundColor(Color.Yellow, true) | ||
/** Make the text's background bright blue */ | ||
export const bgBrightBlue = backgroundColor(104) | ||
export const bgBrightBlue = backgroundColor(Color.Blue, true) | ||
/** Make the text's background bright magenta */ | ||
export const bgBrightMagenta = backgroundColor(105) | ||
export const bgBrightMagenta = backgroundColor(Color.Magenta, true) | ||
/** Make the text's background bright cyan */ | ||
export const bgBrightCyan = backgroundColor(106) | ||
export const bgBrightCyan = backgroundColor(Color.Cyan, true) | ||
/** Make the text's background bright white */ | ||
export const bgBrightWhite = backgroundColor(107) | ||
export const bgBrightWhite = backgroundColor(Color.White, true) |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
73517
26
1041
166
1
1
1
+ Addededitions@^6.1.0
+ Addededitions@6.21.0(transitive)
+ Addedversion-range@4.14.0(transitive)