UNPKG

zephyr-agent

Version:
63 lines (62 loc) • 3.7 kB
import "node:module"; import { is_debug_enabled } from "./debug-enabled.mjs"; import { isatty } from "node:tty"; const isTTY = !is_debug_enabled && !process.env['NO_COLOR'] && process.env['FORCE_COLOR'] || isatty(process.stdout.fd) && !process.env['CI'] && 'dumb' !== process.env['TERM']; const replaceClose = (str, close, replace, index)=>{ const start = str.substring(0, index) + replace; const end = str.substring(index + close.length); const nextIndex = end.indexOf(close); return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end; }; const formatter = (open, close, replace = open)=>{ if (!isTTY) return String; return (input)=>{ const string = '' + input; const index = string.indexOf(close, open.length); return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close; }; }; const picocolor_reset = isTTY ? (s)=>`\x1b[0m${s}\x1b[0m` : String; const bold = formatter('\x1b[1m', '\x1b[22m', '\x1b[22m\x1b[1m'); const dim = formatter('\x1b[2m', '\x1b[22m', '\x1b[22m\x1b[2m'); const italic = formatter('\x1b[3m', '\x1b[23m'); const underline = formatter('\x1b[4m', '\x1b[24m'); const inverse = formatter('\x1b[7m', '\x1b[27m'); const picocolor_hidden = formatter('\x1b[8m', '\x1b[28m'); const strikethrough = formatter('\x1b[9m', '\x1b[29m'); const black = formatter('\x1b[30m', '\x1b[39m'); const red = formatter('\x1b[31m', '\x1b[39m'); const green = formatter('\x1b[32m', '\x1b[39m'); const yellow = formatter('\x1b[33m', '\x1b[39m'); const blue = formatter('\x1b[34m', '\x1b[39m'); const magenta = formatter('\x1b[35m', '\x1b[39m'); const purple = formatter('\x1b[38;2;173;127;168m', '\x1b[39m'); const cyan = formatter('\x1b[36m', '\x1b[39m'); const white = formatter('\x1b[37m', '\x1b[39m'); const gray = formatter('\x1b[90m', '\x1b[39m'); const bgBlack = formatter('\x1b[40m', '\x1b[49m'); const bgRed = formatter('\x1b[41m', '\x1b[49m'); const bgGreen = formatter('\x1b[42m', '\x1b[49m'); const bgYellow = formatter('\x1b[43m', '\x1b[49m'); const bgBlue = formatter('\x1b[44m', '\x1b[49m'); const bgMagenta = formatter('\x1b[45m', '\x1b[49m'); const bgCyan = formatter('\x1b[46m', '\x1b[49m'); const bgWhite = formatter('\x1b[47m', '\x1b[49m'); const blackBright = formatter('\x1b[90m', '\x1b[39m'); const redBright = formatter('\x1b[91m', '\x1b[39m'); const greenBright = formatter('\x1b[92m', '\x1b[39m'); const yellowBright = formatter('\x1b[93m', '\x1b[39m'); const blueBright = formatter('\x1b[94m', '\x1b[39m'); const magentaBright = formatter('\x1b[95m', '\x1b[39m'); const cyanBright = formatter('\x1b[96m', '\x1b[39m'); const whiteBright = formatter('\x1b[97m', '\x1b[39m'); const bgBlackBright = formatter('\x1b[100m', '\x1b[49m'); const bgRedBright = formatter('\x1b[101m', '\x1b[49m'); const bgGreenBright = formatter('\x1b[102m', '\x1b[49m'); const bgYellowBright = formatter('\x1b[103m', '\x1b[49m'); const bgBlueBright = formatter('\x1b[104m', '\x1b[49m'); const bgMagentaBright = formatter('\x1b[105m', '\x1b[49m'); const bgCyanBright = formatter('\x1b[106m', '\x1b[49m'); const bgWhiteBright = formatter('\x1b[107m', '\x1b[49m'); export { bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, cyan, cyanBright, dim, gray, green, greenBright, inverse, isTTY, italic, magenta, magentaBright, picocolor_hidden as hidden, picocolor_reset as reset, purple, red, redBright, strikethrough, underline, white, whiteBright, yellow, yellowBright }; //# sourceMappingURL=picocolor.mjs.map