You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
14 KiB

4 years ago
{"ast":null,"code":"'use strict';\n\nconst colorConvert = require('color-convert');\n\nconst wrapAnsi16 = (fn, offset) => function () {\n const code = fn.apply(colorConvert, arguments);\n return `\\u001B[${code + offset}m`;\n};\n\nconst wrapAnsi256 = (fn, offset) => function () {\n const code = fn.apply(colorConvert, arguments);\n return `\\u001B[${38 + offset};5;${code}m`;\n};\n\nconst wrapAnsi16m = (fn, offset) => function () {\n const rgb = fn.apply(colorConvert, arguments);\n return `\\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;\n};\n\nfunction assembleStyles() {\n const codes = new Map();\n const styles = {\n modifier: {\n reset: [0, 0],\n // 21 isn't widely supported and 22 does the same thing\n bold: [1, 22],\n dim: [2, 22],\n italic: [3, 23],\n underline: [4, 24],\n inverse: [7, 27],\n hidden: [8, 28],\n strikethrough: [9, 29]\n },\n color: {\n black: [30, 39],\n red: [31, 39],\n green: [32, 39],\n yellow: [33, 39],\n blue: [34, 39],\n magenta: [35, 39],\n cyan: [36, 39],\n white: [37, 39],\n gray: [90, 39],\n // Bright color\n redBright: [91, 39],\n greenBright: [92, 39],\n yellowBright: [93, 39],\n blueBright: [94, 39],\n magentaBright: [95, 39],\n cyanBright: [96, 39],\n whiteBright: [97, 39]\n },\n bgColor: {\n bgBlack: [40, 49],\n bgRed: [41, 49],\n bgGreen: [42, 49],\n bgYellow: [43, 49],\n bgBlue: [44, 49],\n bgMagenta: [45, 49],\n bgCyan: [46, 49],\n bgWhite: [47, 49],\n // Bright color\n bgBlackBright: [100, 49],\n bgRedBright: [101, 49],\n bgGreenBright: [102, 49],\n bgYellowBright: [103, 49],\n bgBlueBright: [104, 49],\n bgMagentaBright: [105, 49],\n bgCyanBright: [106, 49],\n bgWhiteBright: [107, 49]\n }\n }; // Fix humans\n\n styles.color.grey = styles.color.gray;\n\n for (const groupName of Object.keys(styles)) {\n const group = styles[groupName];\n\n for (const styleName of Object.keys(group)) {\n const style = group[styleName];\n styles[styleName] = {\n open: `\\u001B[${style[0]}m`,\n close: `\\u001B[${style[1]}m`\n };\n group[styleName] = styles[styleName];\n codes.set(style[0], style[1]);\n }\n\n Object.defineProperty(styles, groupName, {\n value: group,\n enumerable: false\n });\n Object.defineProperty(styles, 'codes', {\n value: codes,\n enumerable: false\n });\n }\n\n const ansi2ansi = n => n;\n\n const rgb2rgb = (r, g, b) => [r, g, b];\n\n styles.color.close = '\\u001B[39m';\n styles.bgColor.close = '\\u001B[49m';\n styles.color.ansi = {\n ansi: wrapAnsi16(ansi2ansi, 0)\n };\n styles.color.ansi256 = {\n ansi256: wrapAnsi256(ansi2ansi, 0)\n };\n styles.color.ansi16m = {\n rgb: wrapAnsi16m(rgb2rgb, 0)\n };\n styles.bgColor.ansi = {\n ansi: wrapAnsi16(ansi2ansi, 10)\n };\n styles.bgColor.ansi256 = {\n ansi256: wrapAnsi256(ansi2ansi, 10)\n };\n styles.bgColor.ansi16m = {\n rgb: wrapAnsi16m(rgb2rgb, 10)\n };\n\n for (let key of Object.keys(colorConvert)) {\n if (typeof colorConvert[key] !== 'object') {\n continue;\n }\n\n const suite = colorConvert[key];\n\n if (key === 'ansi16') {\n key = 'ansi';\n }\n\n if ('ansi16' in suite) {\n styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);\n styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);\n }\n\n if ('ansi256' in suite) {\n styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);\n styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);\n }\n\n if ('rgb' in suite) {\n styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);\n styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);\n }\n }\n\n return styles;\n} // Make the export immutable\n\n\nObject.defineProperty(module, 'exports', {\n enumerable: true,\n get: assembleStyles\n});","map":{"version":3,"sources":["C:/Users/user/Documents/myapp/