@visulima/colorize 1.2.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +106 -16
- package/dist/gradient.cjs +14 -0
- package/dist/gradient.cjs.map +1 -0
- package/dist/gradient.d.cts +112 -0
- package/dist/gradient.d.ts +112 -0
- package/dist/gradient.js +10 -0
- package/dist/gradient.js.map +1 -0
- package/dist/index.browser.d.ts +5 -4
- package/dist/index.browser.js +2 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.server.cjs +4 -4
- package/dist/index.server.cjs.map +1 -1
- package/dist/index.server.d.cts +3 -2
- package/dist/index.server.d.ts +5 -4
- package/dist/index.server.js +3 -3
- package/dist/index.server.js.map +1 -1
- package/dist/template.cjs +15 -0
- package/dist/template.cjs.map +1 -0
- package/dist/template.d.cts +69 -0
- package/dist/template.d.ts +69 -0
- package/dist/template.js +9 -0
- package/dist/template.js.map +1 -0
- package/package.json +62 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js","../src/ansi-codes.ts","../src/utils.ts","../src/colorize.server.ts","../src/index.server.cts"],"names":["ansiRegex","onlyFirst","pattern","isStdoutColorSupported","hexToRgb","hex","color","number_","clamp","min","max","stringReplaceAll","string_","searchValue","replaceValue","pos","substringLength","lastPos","result","esc","open","close","createAnsi256","code","createBgAnsi256","createRgb","r","g","b","createBgRgb","baseStyles","baseColors","styleMethods","styles","stylePrototype","wrapText","strings","values","properties","string","currentProperties","createStyle","props","openStack","closeStack","style","Colorize","self","value","name","arguments_","colorize_server_default","colorize","index_server_default"],"mappings":"AAAe,SAARA,EAA2B,CAAC,UAAAC,EAAY,EAAK,EAAI,CAAC,EAAG,CAC3D,IAAMC,EAAU,CACZ,+HACH,0DACD,EAAE,KAAK,GAAG,EAEV,OAAO,IAAI,OAAOA,EAASD,E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GD,CAAM,EAEnD,OAAO,eAAec,EAAMb,CAAc,EAEnCa,CAEX,EAGA,QAAWE,KAAQjB,EACfC,EAAOgB,CAAiC,EAAI,CACxC,KAAM,CACF,MAAO,IAAIC,IAGPT,EAAY,KAAMT,EAAaiB,CAAiC,EAAE,GAAGC,CAAU,CAAC,CACxF,CACJ,EAGJjB,EAAO,QAAaA,EAAO,GAC3BA,EAAO,UAAeA,EAAO,GAG7B,IAAOkB,EAAQL,ECnIf,IAAMM,EAAyB,IAAID,EAG5BE,EAAQD,EAGFN,EAAWK","sourcesContent":["export default function ansiRegex({onlyFirst = false} = {}) {\n\tconst pattern = [\n\t '[\\\\u001B\\\\u009B][[\\\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]+)*|[a-zA-Z\\\\d]+(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*)?\\\\u0007)',\n\t\t'(?:(?:\\\\d{1,4}(?:;\\\\d{0,4})*)?[\\\\dA-PR-TZcf-ntqry=><~]))'\n\t].join('|');\n\n\treturn new RegExp(pattern, onlyFirst ? undefined : 'g');\n}\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/ansi-codes.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\nimport { isStdoutColorSupported } from \"@visulima/is-ansi-color-supported\";\n\nimport type { AnsiColors, AnsiStyles, ColorData } from \"./types\";\nimport { clamp, hexToRgb } from \"./utils\";\n\nconst esc: (open: number | string, close: number | string) => ColorData =\n isStdoutColorSupported() > 0\n ? (open: number | string, close: number | string): ColorData => {\n return { close: \"\\u001B[\" + close + \"m\", open: \"\\u001B[\" + open + \"m\" };\n }\n : (): ColorData => {\n return { close: \"\", open: \"\" };\n };\n\nconst createAnsi256 = (code: number | string): ColorData => esc(\"38;5;\" + code, 39);\n\nconst createBgAnsi256 = (code: number | string): ColorData => esc(\"48;5;\" + code, 49);\n\nconst createRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"38;2;\" + r + \";\" + g + \";\" + b, 39);\n\nconst createBgRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"48;2;\" + r + \";\" + g + \";\" + b, 49);\n\nexport const baseStyles: Required<Record<AnsiStyles, ColorData>> = {\n // 21 isn't widely supported and 22 does the same thing\n bold: esc(1, 22),\n dim: esc(2, 22),\n hidden: esc(8, 28),\n inverse: esc(7, 27),\n italic: esc(3, 23),\n overline: esc(53, 55),\n reset: esc(0, 0),\n strike: esc(9, 29), // alias for strikethrough\n strikethrough: esc(9, 29),\n underline: esc(4, 24),\n visible: { close: \"\", open: \"\" },\n};\n\nexport const baseColors: Required<Record<AnsiColors, ColorData>> = {\n bgBlack: esc(40, 49),\n bgBlackBright: esc(100, 49),\n bgBlue: esc(44, 49),\n bgBlueBright: esc(104, 49),\n bgCyan: esc(46, 49),\n bgCyanBright: esc(106, 49),\n bgGray: esc(100, 49), // US spelling alias for bgBlackBright\n bgGreen: esc(42, 49),\n bgGreenBright: esc(102, 49),\n bgGrey: esc(100, 49), // UK spelling alias for bgBlackBright\n bgMagenta: esc(45, 49),\n bgMagentaBright: esc(105, 49),\n bgRed: esc(41, 49),\n bgRedBright: esc(101, 49),\n bgWhite: esc(47, 49),\n bgWhiteBright: esc(107, 49),\n bgYellow: esc(43, 49),\n bgYellowBright: esc(103, 49),\n black: esc(30, 39),\n blackBright: esc(90, 39),\n blue: esc(34, 39),\n blueBright: esc(94, 39),\n cyan: esc(36, 39),\n cyanBright: esc(96, 39),\n gray: esc(90, 39), // US spelling alias for blackBright\n green: esc(32, 39),\n greenBright: esc(92, 39),\n grey: esc(90, 39), // UK spelling alias for blackBright\n magenta: esc(35, 39),\n magentaBright: esc(95, 39),\n red: esc(31, 39),\n redBright: esc(91, 39),\n white: esc(37, 39),\n whiteBright: esc(97, 39),\n yellow: esc(33, 39),\n yellowBright: esc(93, 39),\n};\n\nexport const styleMethods: {\n bg: (code: number) => ColorData;\n bgHex: (hex: string) => ColorData;\n bgRgb: (r: number, g: number, b: number) => ColorData;\n fg: (code: number) => ColorData;\n hex: (hex: string) => ColorData;\n rgb: (r: number, g: number, b: number) => ColorData;\n} = {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bg: (code) => createBgAnsi256(clamp(code, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bgHex: (hex) => createBgRgb(...hexToRgb(hex)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bgRgb: (r, g, b) => createBgRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n fg: (code) => createAnsi256(clamp(code, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hex: (hex) => createRgb(...hexToRgb(hex)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n rgb: (r, g, b) => createRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n/**\n * Convert hex color string to RGB values.\n *\n * A hexadecimal color code can be 3 or 6 digits with an optional \"#\" prefix.\n *\n * The 3 digits specifies an RGB doublet data as a fully opaque color.\n * For example, \"#123\" specifies the color that is represented by \"#112233\".\n *\n * The 6 digits specifies a fully opaque color.\n * For example, \"#112233\".\n *\n * @param {string} hex A string that contains the hexadecimal RGB color representation.\n * @return {[number, number, number]} The red, green, blue values in range [0, 255] .\n */\nexport const hexToRgb = (hex: string): [number, number, number] => {\n let color: string = hex.replace(\"#\", \"\");\n\n if (color.length === 3) {\n color = (color[0] as string) + (color[0] as string) + (color[1] as string) + (color[1] as string) + (color[2] as string) + (color[2] as string);\n } else if (color.length !== 6) {\n return [0, 0, 0];\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const number_ = Number.parseInt(color, 16);\n\n // eslint-disable-next-line no-bitwise\n return [(number_ >> 16) & 255, (number_ >> 8) & 255, number_ & 255];\n};\n\n/**\n * Clamp a number within the inclusive range specified by min and max.\n * @note: The ternary operator is a tick quicker than Math.min(Math.max(num, min), max).\n */\nexport const clamp = (number_: number, min: number, max: number): number => (min > number_ ? min : number_ > max ? max : number_);\n\n/**\n * Replace all matched strings.\n * Note: this implementation is over 30% faster than String.replaceAll().\n */\nexport const stringReplaceAll = (string_: string, searchValue: string, replaceValue: string): string => {\n // visible style has empty open/close props\n if (searchValue === \"\") {\n return string_;\n }\n\n let pos = string_.indexOf(searchValue);\n if (pos < 0) {\n return string_;\n }\n\n const substringLength = searchValue.length;\n let lastPos = 0;\n let result = \"\";\n\n // eslint-disable-next-line no-loops/no-loops,no-bitwise\n while (~pos) {\n result += string_.slice(lastPos, pos) + replaceValue;\n lastPos = pos + substringLength;\n pos = string_.indexOf(searchValue, lastPos);\n }\n\n return result + string_.slice(lastPos);\n};\n\nexport const ansiCodeHexMap: Record<number, string> = {\n 0: \"#000\",\n 1: \"#800\",\n 2: \"#080\",\n 3: \"#880\",\n 4: \"#008\",\n 5: \"#808\",\n 6: \"#088\",\n 7: \"#ccc\",\n 8: \"#444\",\n 9: \"#f00\",\n 10: \"#0f0\",\n 11: \"#ff0\",\n 12: \"#00f\",\n 13: \"#f0f\",\n 14: \"#0ff\",\n 15: \"#fff\",\n 16: \"#000\",\n 17: \"#00005f\",\n 18: \"#000087\",\n 19: \"#0000af\",\n 20: \"#0000d7\",\n 21: \"#0000ff\",\n 22: \"#005f00\",\n 23: \"#005f5f\",\n 24: \"#005f87\",\n 25: \"#005faf\",\n 26: \"#005fd7\",\n 27: \"#005fff\",\n 28: \"#008700\",\n 29: \"#00875f\",\n 30: \"#008787\",\n 31: \"#0087af\",\n 32: \"#0087d7\",\n 33: \"#0087ff\",\n 34: \"#00af00\",\n 35: \"#00af5f\",\n 36: \"#00af87\",\n 37: \"#00afaf\",\n 38: \"#00afd7\",\n 39: \"#00afff\",\n 40: \"#00d700\",\n 41: \"#00d75f\",\n 42: \"#00d787\",\n 43: \"#00d7af\",\n 44: \"#00d7d7\",\n 45: \"#00d7ff\",\n 46: \"#00ff00\",\n 47: \"#00ff5f\",\n 48: \"#00ff87\",\n 49: \"#00ffaf\",\n 50: \"#00ffd7\",\n 51: \"#00ffff\",\n 52: \"#5f0000\",\n 53: \"#5f005f\",\n 54: \"#5f0087\",\n 55: \"#5f00af\",\n 56: \"#5f00d7\",\n 57: \"#5f00ff\",\n 58: \"#5f5f00\",\n 59: \"#5f5f5f\",\n 60: \"#5f5f87\",\n 61: \"#5f5faf\",\n 62: \"#5f5fd7\",\n 63: \"#5f5fff\",\n 64: \"#5f8700\",\n 65: \"#5f875f\",\n 66: \"#5f8787\",\n 67: \"#5f87af\",\n 68: \"#5f87d7\",\n 69: \"#5f87ff\",\n 70: \"#5faf00\",\n 71: \"#5faf5f\",\n 72: \"#5faf87\",\n 73: \"#5fafaf\",\n 74: \"#5fafd7\",\n 75: \"#5fafff\",\n 76: \"#5fd700\",\n 77: \"#5fd75f\",\n 78: \"#5fd787\",\n 79: \"#5fd7af\",\n 80: \"#5fd7d7\",\n 81: \"#5fd7ff\",\n 82: \"#5fff00\",\n 83: \"#5fff5f\",\n 84: \"#5fff87\",\n 85: \"#5fffaf\",\n 86: \"#5fffd7\",\n 87: \"#5fffff\",\n 88: \"#870000\",\n 89: \"#87005f\",\n 90: \"#870087\",\n 91: \"#8700af\",\n 92: \"#8700d7\",\n 93: \"#8700ff\",\n 94: \"#875f00\",\n 95: \"#875f5f\",\n 96: \"#875f87\",\n 97: \"#875faf\",\n 98: \"#875fd7\",\n 99: \"#875fff\",\n 100: \"#878700\",\n 101: \"#87875f\",\n 102: \"#878787\",\n 103: \"#8787af\",\n 104: \"#8787d7\",\n 105: \"#8787ff\",\n 106: \"#87af00\",\n 107: \"#87af5f\",\n 108: \"#87af87\",\n 109: \"#87afaf\",\n 110: \"#87afd7\",\n 111: \"#87afff\",\n 112: \"#87d700\",\n 113: \"#87d75f\",\n 114: \"#87d787\",\n 115: \"#87d7af\",\n 116: \"#87d7d7\",\n 117: \"#87d7ff\",\n 118: \"#87ff00\",\n 119: \"#87ff5f\",\n 120: \"#87ff87\",\n 121: \"#87ffaf\",\n 122: \"#87ffd7\",\n 123: \"#87ffff\",\n 124: \"#af0000\",\n 125: \"#af005f\",\n 126: \"#af0087\",\n 127: \"#af00af\",\n 128: \"#af00d7\",\n 129: \"#af00ff\",\n 130: \"#af5f00\",\n 131: \"#af5f5f\",\n 132: \"#af5f87\",\n 133: \"#af5faf\",\n 134: \"#af5fd7\",\n 135: \"#af5fff\",\n 136: \"#af8700\",\n 137: \"#af875f\",\n 138: \"#af8787\",\n 139: \"#af87af\",\n 140: \"#af87d7\",\n 141: \"#af87ff\",\n 142: \"#afaf00\",\n 143: \"#afaf5f\",\n 144: \"#afaf87\",\n 145: \"#afafaf\",\n 146: \"#afafd7\",\n 147: \"#afafff\",\n 148: \"#afd700\",\n 149: \"#afd75f\",\n 150: \"#afd787\",\n 151: \"#afd7af\",\n 152: \"#afd7d7\",\n 153: \"#afd7ff\",\n 154: \"#afff00\",\n 155: \"#afff5f\",\n 156: \"#afff87\",\n 157: \"#afffaf\",\n 158: \"#afffd7\",\n 159: \"#afffff\",\n 160: \"#d70000\",\n 161: \"#d7005f\",\n 162: \"#d70087\",\n 163: \"#d700af\",\n 164: \"#d700d7\",\n 165: \"#d700ff\",\n 166: \"#d75f00\",\n 167: \"#d75f5f\",\n 168: \"#d75f87\",\n 169: \"#d75faf\",\n 170: \"#d75fd7\",\n 171: \"#d75fff\",\n 172: \"#d78700\",\n 173: \"#d7875f\",\n 174: \"#d78787\",\n 175: \"#d787af\",\n 176: \"#d787d7\",\n 177: \"#d787ff\",\n 178: \"#d7af00\",\n 179: \"#d7af5f\",\n 180: \"#d7af87\",\n 181: \"#d7afaf\",\n 182: \"#d7afd7\",\n 183: \"#d7afff\",\n 184: \"#d7d700\",\n 185: \"#d7d75f\",\n 186: \"#d7d787\",\n 187: \"#d7d7af\",\n 188: \"#d7d7d7\",\n 189: \"#d7d7ff\",\n 190: \"#d7ff00\",\n 191: \"#d7ff5f\",\n 192: \"#d7ff87\",\n 193: \"#d7ffaf\",\n 194: \"#d7ffd7\",\n 195: \"#d7ffff\",\n 196: \"#ff0000\",\n 197: \"#ff005f\",\n 198: \"#ff0087\",\n 199: \"#ff00af\",\n 200: \"#ff00d7\",\n 201: \"#ff00ff\",\n 202: \"#ff5f00\",\n 203: \"#ff5f5f\",\n 204: \"#ff5f87\",\n 205: \"#ff5faf\",\n 206: \"#ff5fd7\",\n 207: \"#ff5fff\",\n 208: \"#ff8700\",\n 209: \"#ff875f\",\n 210: \"#ff8787\",\n 211: \"#ff87af\",\n 212: \"#ff87d7\",\n 213: \"#ff87ff\",\n 214: \"#ffaf00\",\n 215: \"#ffaf5f\",\n 216: \"#ffaf87\",\n 217: \"#ffafaf\",\n 218: \"#ffafd7\",\n 219: \"#ffafff\",\n 220: \"#ffd700\",\n 221: \"#ffd75f\",\n 222: \"#ffd787\",\n 223: \"#ffd7af\",\n 224: \"#ffd7d7\",\n 225: \"#ffd7ff\",\n 226: \"#ffff00\",\n 227: \"#ffff5f\",\n 228: \"#ffff87\",\n 229: \"#ffffaf\",\n 230: \"#ffffd7\",\n 231: \"#ffffff\",\n 232: \"#080808\",\n 233: \"#121212\",\n 234: \"#1c1c1c\",\n 235: \"#262626\",\n 236: \"#303030\",\n 237: \"#3a3a3a\",\n 238: \"#444444\",\n 239: \"#4e4e4e\",\n 240: \"#585858\",\n 241: \"#626262\",\n 242: \"#6c6c6c\",\n 243: \"#767676\",\n 244: \"#808080\",\n 245: \"#8a8a8a\",\n 246: \"#949494\",\n 247: \"#9e9e9e\",\n 248: \"#a8a8a8\",\n 249: \"#b2b2b2\",\n 250: \"#bcbcbc\",\n 251: \"#c6c6c6\",\n 252: \"#d0d0d0\",\n 253: \"#dadada\",\n 254: \"#e4e4e4\",\n 255: \"#eeeeee\",\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/index.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport ansiRegex from \"ansi-regex\";\n\nimport { baseColors, baseStyles, styleMethods } from \"./ansi-codes\";\nimport type { ColorData, ColorizeType } from \"./types\";\nimport { stringReplaceAll } from \"./utils\";\n\nconst styles: Record<string, object> = {};\n\nlet stylePrototype: object | null = null;\n\nconst wrapText = (\n strings: ArrayLike<string> | ReadonlyArray<string> | number | string | { raw: ArrayLike<string> | ReadonlyArray<string> },\n values: string[],\n properties: ColorizeProperties,\n) => {\n if (!strings) {\n return \"\";\n }\n\n let string =\n (strings as { raw?: ArrayLike<string> | ReadonlyArray<string> | null }).raw == null\n ? (((strings as number | string) + \"\") as string)\n : String.raw(strings as { raw: ArrayLike<string> | ReadonlyArray<string> }, ...values);\n\n if (string.includes(\"\\u001B\")) {\n // eslint-disable-next-line no-loops/no-loops,@typescript-eslint/no-unnecessary-condition\n for (let currentProperties = properties; currentProperties; currentProperties = currentProperties.props) {\n string = stringReplaceAll(string, currentProperties.close, currentProperties.open);\n }\n }\n\n if (string.includes(\"\\n\")) {\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n string = string.replace(/(\\r*\\n)/g, properties.closeStack + \"$1\" + properties.openStack);\n }\n\n return properties.openStack + string + properties.closeStack;\n};\n\ntype ColorizeProperties = { close: string; closeStack: string; open: string; openStack: string; props: ColorizeProperties };\n\nconst createStyle = (\n { props }: { props?: ColorizeProperties },\n { close, open }: ColorData,\n): {\n (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]): string;\n close: string;\n open: string;\n props: { close: string; closeStack: string; open: string; openStack: string; props?: ColorizeProperties };\n} => {\n const openStack: string = (props?.openStack ?? \"\") + open;\n const closeStack: string = close + (props?.closeStack ?? \"\");\n\n const style = (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]) => wrapText(strings, values, style.props);\n\n Object.setPrototypeOf(style, stylePrototype);\n\n style.props = { close, closeStack, open, openStack, props } as ColorizeProperties;\n style.open = openStack;\n style.close = closeStack;\n\n return style;\n};\n\n// eslint-disable-next-line func-names\nconst Colorize = function () {\n const self = (string_: number | string) => string_ + \"\";\n\n self.strip = (value: string): string => value.replaceAll(ansiRegex(), \"\");\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseColors) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const style = createStyle(this, baseColors[name as keyof typeof baseColors]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseStyles) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const style = createStyle(this, baseStyles[name as keyof typeof baseStyles]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // This needs to be the last thing we do, so that the prototype is fully populated.\n stylePrototype = Object.defineProperties({}, styles);\n\n Object.setPrototypeOf(self, stylePrototype);\n\n return self;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} as any as new () => ColorizeType;\n\n// eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\nfor (const name in styleMethods) {\n styles[name as keyof typeof styleMethods] = {\n get() {\n return (...arguments_: (number | string)[]) =>\n // @ts-expect-error: TODO: fix typing of `arguments_`\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n createStyle(this, styleMethods[name as keyof typeof styleMethods](...arguments_));\n },\n };\n}\n\nstyles[\"ansi256\"] = styles[\"fg\"] as object;\nstyles[\"bgAnsi256\"] = styles[\"bg\"] as object;\n\n// eslint-disable-next-line import/no-default-export\nexport default Colorize;\n","import ColorizeImpl from \"./colorize.server\";\nimport type { ColorizeType } from \"./types\";\n\nconst colorize: ColorizeType = new ColorizeImpl() as ColorizeType;\n\n// eslint-disable-next-line import/no-default-export,import/no-unused-modules\nexport default colorize as ColorizeType;\n\n// eslint-disable-next-line unicorn/prefer-export-from,import/no-unused-modules\nexport const Colorize = ColorizeImpl;\n\n// eslint-disable-next-line import/no-unused-modules\nexport type { AnsiColors, AnsiStyles, ColorizeType } from \"./types\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js","../src/ansi-codes.ts","../src/util/clamp.ts","../src/util/hex-to-rgb.ts","../src/util/string-replace-all.ts","../src/colorize.server.ts","../src/index.server.cts"],"names":["ansiRegex","onlyFirst","pattern","isStdoutColorSupported","clamp","number_","min","max","hexToRgb","hex","color","esc","open","close","createAnsi256","code","createBgAnsi256","createRgb","r","g","b","createBgRgb","baseStyles","baseColors","styleMethods","stringReplaceAll","string_","searchValue","replaceValue","pos","substringLength","lastPos","result","styles","stylePrototype","wrapText","strings","values","properties","string","currentProperties","createStyle","props","openStack","closeStack","style","Colorize","self","value","name","arguments_","colorize_server_default","colorize","index_server_default"],"mappings":"AAAe,SAARA,EAA2B,CAAC,UAAAC,EAAY,EAAK,EAAI,CAAC,EAAG,CAC3D,IAAMC,EAAU,CACZ,+HACH,0DACD,EAAE,KAAK,GAAG,EAEV,OAAO,IAAI,OAAOA,EAASD,EAAY,OAAY,GAAG,CACvD,CCCA,OAAS,0BAAAE,MAA8B,oCCKhC,IAAMC,EAAQ,CAACC,EAAiBC,EAAaC,IAAyBD,EAAMD,EAAUC,EAAMD,EAAUE,EAAMA,EAAMF,ECWlH,IAAMG,EAAYC,GAAiD,CACtE,IAAIC,EAAgBD,EAAI,QAAQ,IAAK,EAAE,EAEvC,GAAIC,EAAM,SAAW,EACjBA,EAASA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM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ansiRegex({onlyFirst = false} = {}) {\n\tconst pattern = [\n\t '[\\\\u001B\\\\u009B][[\\\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]+)*|[a-zA-Z\\\\d]+(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*)?\\\\u0007)',\n\t\t'(?:(?:\\\\d{1,4}(?:;\\\\d{0,4})*)?[\\\\dA-PR-TZcf-ntqry=><~]))'\n\t].join('|');\n\n\treturn new RegExp(pattern, onlyFirst ? undefined : 'g');\n}\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/ansi-codes.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\nimport { isStdoutColorSupported } from \"@visulima/is-ansi-color-supported\";\n\nimport type { AnsiColors, AnsiStyles, ColorData, ColorValueHex } from \"./types\";\nimport { clamp } from \"./util/clamp\";\nimport { hexToRgb } from \"./util/hex-to-rgb\";\n\nconst esc: (open: number | string, close: number | string) => ColorData =\n isStdoutColorSupported() > 0\n ? (open: number | string, close: number | string): ColorData => {\n return { close: \"\\u001B[\" + close + \"m\", open: \"\\u001B[\" + open + \"m\" };\n }\n : (): ColorData => {\n return { close: \"\", open: \"\" };\n };\n\nconst createAnsi256 = (code: number | string): ColorData => esc(\"38;5;\" + code, 39);\n\nconst createBgAnsi256 = (code: number | string): ColorData => esc(\"48;5;\" + code, 49);\n\nconst createRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"38;2;\" + r + \";\" + g + \";\" + b, 39);\n\nconst createBgRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"48;2;\" + r + \";\" + g + \";\" + b, 49);\n\nexport const baseStyles: Required<Record<AnsiStyles, ColorData>> = {\n // 21 isn't widely supported and 22 does the same thing\n bold: esc(1, 22),\n dim: esc(2, 22),\n hidden: esc(8, 28),\n inverse: esc(7, 27),\n italic: esc(3, 23),\n overline: esc(53, 55),\n reset: esc(0, 0),\n strike: esc(9, 29), // alias for strikethrough\n strikethrough: esc(9, 29),\n underline: esc(4, 24),\n visible: { close: \"\", open: \"\" },\n};\n\nexport const baseColors: Required<Record<AnsiColors, ColorData>> = {\n bgBlack: esc(40, 49),\n bgBlackBright: esc(100, 49),\n bgBlue: esc(44, 49),\n bgBlueBright: esc(104, 49),\n bgCyan: esc(46, 49),\n bgCyanBright: esc(106, 49),\n bgGray: esc(100, 49), // US spelling alias for bgBlackBright\n bgGreen: esc(42, 49),\n bgGreenBright: esc(102, 49),\n bgGrey: esc(100, 49), // UK spelling alias for bgBlackBright\n bgMagenta: esc(45, 49),\n bgMagentaBright: esc(105, 49),\n bgRed: esc(41, 49),\n bgRedBright: esc(101, 49),\n bgWhite: esc(47, 49),\n bgWhiteBright: esc(107, 49),\n bgYellow: esc(43, 49),\n bgYellowBright: esc(103, 49),\n black: esc(30, 39),\n blackBright: esc(90, 39),\n blue: esc(34, 39),\n blueBright: esc(94, 39),\n cyan: esc(36, 39),\n cyanBright: esc(96, 39),\n gray: esc(90, 39), // US spelling alias for blackBright\n green: esc(32, 39),\n greenBright: esc(92, 39),\n grey: esc(90, 39), // UK spelling alias for blackBright\n magenta: esc(35, 39),\n magentaBright: esc(95, 39),\n red: esc(31, 39),\n redBright: esc(91, 39),\n white: esc(37, 39),\n whiteBright: esc(97, 39),\n yellow: esc(33, 39),\n yellowBright: esc(93, 39),\n};\n\nexport const styleMethods: {\n bg: (code: number) => ColorData;\n bgHex: (hex: ColorValueHex) => ColorData;\n bgRgb: (r: number, g: number, b: number) => ColorData;\n fg: (code: number) => ColorData;\n hex: (hex: ColorValueHex) => ColorData;\n rgb: (r: number, g: number, b: number) => ColorData;\n} = {\n bg: (code) => createBgAnsi256(clamp(code, 0, 255)),\n\n bgHex: (hex) => createBgRgb(...hexToRgb(hex)),\n\n bgRgb: (r, g, b) => createBgRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n\n fg: (code) => createAnsi256(clamp(code, 0, 255)),\n\n hex: (hex) => createRgb(...hexToRgb(hex)),\n\n rgb: (r, g, b) => createRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n/**\n * Clamp a number within the inclusive range specified by min and max.\n * @note: The ternary operator is a tick quicker than Math.min(Math.max(num, min), max).\n */\n\nexport const clamp = (number_: number, min: number, max: number): number => (min > number_ ? min : number_ > max ? max : number_);\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\nimport type { ColorValueHex } from \"../types\";\n\n/**\n * Convert hex color string to RGB values.\n *\n * A hexadecimal color code can be 3 or 6 digits with an optional \"#\" prefix.\n *\n * The 3 digits specifies an RGB doublet data as a fully opaque color.\n * For example, \"#123\" specifies the color that is represented by \"#112233\".\n *\n * The 6 digits specifies a fully opaque color.\n * For example, \"#112233\".\n *\n * @param {string} hex A string that contains the hexadecimal RGB color representation.\n * @return {[number, number, number]} The red, green, blue values in range [0, 255] .\n */\nexport const hexToRgb = (hex: ColorValueHex): [number, number, number] => {\n let color: string = hex.replace(\"#\", \"\");\n\n if (color.length === 3) {\n color = (color[0] as string) + (color[0] as string) + (color[1] as string) + (color[1] as string) + (color[2] as string) + (color[2] as string);\n } else if (color.length !== 6) {\n return [0, 0, 0];\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const number_ = Number.parseInt(color, 16);\n\n // eslint-disable-next-line no-bitwise\n return [(number_ >> 16) & 255, (number_ >> 8) & 255, number_ & 255];\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n/**\n * Replace all matched strings.\n * Note: this implementation is over 30% faster than String.replaceAll().\n */\nexport const stringReplaceAll = (string_: string, searchValue: string, replaceValue: string): string => {\n // visible style has empty open/close props\n if (searchValue === \"\") {\n return string_;\n }\n\n let pos = string_.indexOf(searchValue);\n if (pos < 0) {\n return string_;\n }\n\n const substringLength = searchValue.length;\n let lastPos = 0;\n let result = \"\";\n\n // eslint-disable-next-line no-loops/no-loops,no-bitwise\n while (~pos) {\n result += string_.slice(lastPos, pos) + replaceValue;\n lastPos = pos + substringLength;\n pos = string_.indexOf(searchValue, lastPos);\n }\n\n return result + string_.slice(lastPos);\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/index.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport ansiRegex from \"ansi-regex\";\n\nimport { baseColors, baseStyles, styleMethods } from \"./ansi-codes\";\nimport type { ColorData, ColorizeType } from \"./types\";\nimport { stringReplaceAll } from \"./util/string-replace-all\";\n\nconst styles: Record<string, object> = {};\n\nlet stylePrototype: object | null = null;\n\nconst wrapText = (\n strings: ArrayLike<string> | ReadonlyArray<string> | number | string | { raw: ArrayLike<string> | ReadonlyArray<string> },\n values: string[],\n properties: ColorizeProperties,\n) => {\n if (!strings) {\n return \"\";\n }\n\n let string =\n (strings as { raw?: ArrayLike<string> | ReadonlyArray<string> | null }).raw == null\n ? (((strings as number | string) + \"\") as string)\n : String.raw(strings as { raw: ArrayLike<string> | ReadonlyArray<string> }, ...values);\n\n if (string.includes(\"\\u001B\")) {\n // eslint-disable-next-line no-loops/no-loops,@typescript-eslint/no-unnecessary-condition\n for (let currentProperties = properties; currentProperties; currentProperties = currentProperties.props) {\n string = stringReplaceAll(string, currentProperties.close, currentProperties.open);\n }\n }\n\n if (string.includes(\"\\n\")) {\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n string = string.replace(/(\\r*\\n)/g, properties.closeStack + \"$1\" + properties.openStack);\n }\n\n return properties.openStack + string + properties.closeStack;\n};\n\ntype ColorizeProperties = { close: string; closeStack: string; open: string; openStack: string; props: ColorizeProperties };\n\nconst createStyle = (\n { props }: { props?: ColorizeProperties },\n { close, open }: ColorData,\n): {\n (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]): string;\n close: string;\n open: string;\n props: { close: string; closeStack: string; open: string; openStack: string; props?: ColorizeProperties };\n} => {\n const openStack: string = (props?.openStack ?? \"\") + open;\n const closeStack: string = close + (props?.closeStack ?? \"\");\n\n const style = (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]) => wrapText(strings, values, style.props);\n\n Object.setPrototypeOf(style, stylePrototype);\n\n style.props = { close, closeStack, open, openStack, props } as ColorizeProperties;\n style.open = openStack;\n style.close = closeStack;\n\n return style;\n};\n\n// eslint-disable-next-line func-names\nconst Colorize = function () {\n const self = (string_: number | string) => string_ + \"\";\n\n self.strip = (value: string): string => value.replaceAll(ansiRegex(), \"\");\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseColors) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n const style = createStyle(this, baseColors[name as keyof typeof baseColors]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseStyles) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n const style = createStyle(this, baseStyles[name as keyof typeof baseStyles]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // This needs to be the last thing we do, so that the prototype is fully populated.\n stylePrototype = Object.defineProperties({}, styles);\n\n Object.setPrototypeOf(self, stylePrototype);\n\n return self;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} as any as new () => ColorizeType;\n\n// eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\nfor (const name in styleMethods) {\n styles[name as keyof typeof styleMethods] = {\n get() {\n return (...arguments_: (number | string)[]) =>\n // @ts-expect-error: TODO: fix typing of `arguments_`\n\n createStyle(this, styleMethods[name as keyof typeof styleMethods](...arguments_));\n },\n };\n}\n\nstyles[\"ansi256\"] = styles[\"fg\"] as object;\nstyles[\"bgAnsi256\"] = styles[\"bg\"] as object;\n\n// eslint-disable-next-line import/no-default-export\nexport default Colorize;\n","import ColorizeImpl from \"./colorize.server\";\nimport type { ColorizeType } from \"./types\";\n\nconst colorize: ColorizeType = new ColorizeImpl() as ColorizeType;\n\n// eslint-disable-next-line import/no-default-export,import/no-unused-modules\nexport default colorize as ColorizeType;\n\n// eslint-disable-next-line unicorn/prefer-export-from,import/no-unused-modules\nexport const Colorize = ColorizeImpl;\n\n// eslint-disable-next-line import/no-unused-modules\nexport type { AnsiColors, AnsiStyles, ColorizeType } from \"./types\";\n"]}
|
package/dist/index.server.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type ColorValueHex = `#${string}`;
|
|
1
2
|
interface ColorizeType {
|
|
2
3
|
(string: number | string): string;
|
|
3
4
|
(string: TemplateStringsArray, ...parameters: string[]): string;
|
|
@@ -14,7 +15,7 @@ interface ColorizeType {
|
|
|
14
15
|
readonly bgGreen: this;
|
|
15
16
|
readonly bgGreenBright: this;
|
|
16
17
|
readonly bgGrey: this;
|
|
17
|
-
bgHex: (color:
|
|
18
|
+
bgHex: (color: ColorValueHex) => this;
|
|
18
19
|
readonly bgMagenta: this;
|
|
19
20
|
readonly bgMagentaBright: this;
|
|
20
21
|
readonly bgRed: this;
|
|
@@ -38,7 +39,7 @@ interface ColorizeType {
|
|
|
38
39
|
readonly green: this;
|
|
39
40
|
readonly greenBright: this;
|
|
40
41
|
readonly grey: this;
|
|
41
|
-
hex: (color:
|
|
42
|
+
hex: (color: ColorValueHex) => this;
|
|
42
43
|
readonly hidden: this;
|
|
43
44
|
readonly inverse: this;
|
|
44
45
|
readonly italic: this;
|
package/dist/index.server.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type ColorValueHex = `#${string}`;
|
|
1
2
|
interface ColorizeType {
|
|
2
3
|
(string: number | string): string;
|
|
3
4
|
(string: TemplateStringsArray, ...parameters: string[]): string;
|
|
@@ -14,7 +15,7 @@ interface ColorizeType {
|
|
|
14
15
|
readonly bgGreen: this;
|
|
15
16
|
readonly bgGreenBright: this;
|
|
16
17
|
readonly bgGrey: this;
|
|
17
|
-
bgHex: (color:
|
|
18
|
+
bgHex: (color: ColorValueHex) => this;
|
|
18
19
|
readonly bgMagenta: this;
|
|
19
20
|
readonly bgMagentaBright: this;
|
|
20
21
|
readonly bgRed: this;
|
|
@@ -38,7 +39,7 @@ interface ColorizeType {
|
|
|
38
39
|
readonly green: this;
|
|
39
40
|
readonly greenBright: this;
|
|
40
41
|
readonly grey: this;
|
|
41
|
-
hex: (color:
|
|
42
|
+
hex: (color: ColorValueHex) => this;
|
|
42
43
|
readonly hidden: this;
|
|
43
44
|
readonly inverse: this;
|
|
44
45
|
readonly italic: this;
|
|
@@ -80,7 +81,7 @@ declare const bgGray: ColorizeType;
|
|
|
80
81
|
declare const bgGreen: ColorizeType;
|
|
81
82
|
declare const bgGreenBright: ColorizeType;
|
|
82
83
|
declare const bgGrey: ColorizeType;
|
|
83
|
-
declare const bgHex: (color: string) => ColorizeType;
|
|
84
|
+
declare const bgHex: (color: `#${string}`) => ColorizeType;
|
|
84
85
|
declare const bgMagenta: ColorizeType;
|
|
85
86
|
declare const bgMagentaBright: ColorizeType;
|
|
86
87
|
declare const bgRed: ColorizeType;
|
|
@@ -103,7 +104,7 @@ declare const gray: ColorizeType;
|
|
|
103
104
|
declare const green: ColorizeType;
|
|
104
105
|
declare const greenBright: ColorizeType;
|
|
105
106
|
declare const grey: ColorizeType;
|
|
106
|
-
declare const hex: (color: string) => ColorizeType;
|
|
107
|
+
declare const hex: (color: `#${string}`) => ColorizeType;
|
|
107
108
|
declare const hidden: ColorizeType;
|
|
108
109
|
declare const inverse: ColorizeType;
|
|
109
110
|
declare const italic: ColorizeType;
|
package/dist/index.server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isStdoutColorSupported } from '@visulima/is-ansi-color-supported';
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
`)&&(
|
|
3
|
+
function b({onlyFirst:e=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}var g=(e,t,o)=>t>e?t:e>o?o:e;var c=e=>{let t=e.replace("#","");if(t.length===3)t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2];else if(t.length!==6)return [0,0,0];let o=Number.parseInt(t,16);return [o>>16&255,o>>8&255,o&255]};var r=isStdoutColorSupported()>0?(e,t)=>({close:"\x1B["+t+"m",open:"\x1B["+e+"m"}):()=>({close:"",open:""}),R=e=>r("38;5;"+e,39),w=e=>r("48;5;"+e,49),f=(e,t,o)=>r("38;2;"+e+";"+t+";"+o,39),C=(e,t,o)=>r("48;2;"+e+";"+t+";"+o,49),p={bold:r(1,22),dim:r(2,22),hidden:r(8,28),inverse:r(7,27),italic:r(3,23),overline:r(53,55),reset:r(0,0),strike:r(9,29),strikethrough:r(9,29),underline:r(4,24),visible:{close:"",open:""}},u={bgBlack:r(40,49),bgBlackBright:r(100,49),bgBlue:r(44,49),bgBlueBright:r(104,49),bgCyan:r(46,49),bgCyanBright:r(106,49),bgGray:r(100,49),bgGreen:r(42,49),bgGreenBright:r(102,49),bgGrey:r(100,49),bgMagenta:r(45,49),bgMagentaBright:r(105,49),bgRed:r(41,49),bgRedBright:r(101,49),bgWhite:r(47,49),bgWhiteBright:r(107,49),bgYellow:r(43,49),bgYellowBright:r(103,49),black:r(30,39),blackBright:r(90,39),blue:r(34,39),blueBright:r(94,39),cyan:r(36,39),cyanBright:r(96,39),gray:r(90,39),green:r(32,39),greenBright:r(92,39),grey:r(90,39),magenta:r(35,39),magentaBright:r(95,39),red:r(31,39),redBright:r(91,39),white:r(37,39),whiteBright:r(97,39),yellow:r(33,39),yellowBright:r(93,39)},y={bg:e=>w(g(e,0,255)),bgHex:e=>C(...c(e)),bgRgb:(e,t,o)=>C(g(e,0,255),g(t,0,255),g(o,0,255)),fg:e=>R(g(e,0,255)),hex:e=>f(...c(e)),rgb:(e,t,o)=>f(g(e,0,255),g(t,0,255),g(o,0,255))};var B=(e,t,o)=>{if(t==="")return e;let n=e.indexOf(t);if(n<0)return e;let i=t.length,s=0,a="";for(;~n;)a+=e.slice(s,n)+o,s=n+i,n=e.indexOf(t,s);return a+e.slice(s)};var l={},m=null,S=(e,t,o)=>{if(!e)return "";let n=e.raw==null?e+"":String.raw(e,...t);if(n.includes("\x1B"))for(let i=o;i;i=i.props)n=B(n,i.close,i.open);return n.includes(`
|
|
4
|
+
`)&&(n=n.replace(/(\r*\n)/g,o.closeStack+"$1"+o.openStack)),o.openStack+n+o.closeStack},h=({props:e},{close:t,open:o})=>{let n=(e?.openStack??"")+o,i=t+(e?.closeStack??""),s=(a,...x)=>S(a,x,s.props);return Object.setPrototypeOf(s,m),s.props={close:t,closeStack:i,open:o,openStack:n,props:e},s.open=n,s.close=i,s},z=function(){let e=t=>t+"";e.strip=t=>t.replaceAll(b(),"");for(let t in u)l[t]={get(){let o=h(this,u[t]);return Object.defineProperty(this,t,{value:o}),o}};for(let t in p)l[t]={get(){let o=h(this,p[t]);return Object.defineProperty(this,t,{value:o}),o}};return m=Object.defineProperties({},l),Object.setPrototypeOf(e,m),e};for(let e in y)l[e]={get(){return (...t)=>h(this,y[e](...t))}};l.ansi256=l.fg;l.bgAnsi256=l.bg;var d=z;var k=new d,q=k,{ansi256:I,bg:V,bgAnsi256:E,bgBlack:N,bgBlackBright:$,bgBlue:F,bgBlueBright:J,bgCyan:K,bgCyanBright:Q,bgGray:U,bgGreen:X,bgGreenBright:_,bgGrey:ee,bgHex:re,bgMagenta:te,bgMagentaBright:oe,bgRed:ne,bgRedBright:se,bgRgb:ie,bgWhite:ge,bgWhiteBright:le,bgYellow:ae,bgYellowBright:be,black:ce,blackBright:pe,blue:ue,blueBright:ye,bold:me,cyan:he,cyanBright:de,dim:fe,fg:Ce,gray:Be,green:ke,greenBright:xe,grey:Ae,hex:Re,hidden:we,inverse:Se,italic:ze,magenta:De,magentaBright:Pe,overline:Te,red:je,redBright:ve,reset:Oe,rgb:Ge,strike:He,strikethrough:Me,strip:Le,underline:We,visible:Ye,white:Ze,whiteBright:qe,yellow:Ie,yellowBright:Ve}=k;
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export { d as Colorize, I as ansi256, V as bg, E as bgAnsi256, N as bgBlack, $ as bgBlackBright, F as bgBlue, J as bgBlueBright, K as bgCyan, Q as bgCyanBright, U as bgGray, X as bgGreen, _ as bgGreenBright, ee as bgGrey, re as bgHex, te as bgMagenta, oe as bgMagentaBright, ne as bgRed, se as bgRedBright, ie as bgRgb, ge as bgWhite, le as bgWhiteBright, ae as bgYellow, be as bgYellowBright, ce as black, pe as blackBright, ue as blue, ye as blueBright, me as bold, he as cyan, de as cyanBright, q as default, fe as dim, Ce as fg, Be as gray, ke as green, xe as greenBright, Ae as grey, Re as hex, we as hidden, Se as inverse, ze as italic, De as magenta, Pe as magentaBright, Te as overline, je as red, ve as redBright, Oe as reset, Ge as rgb, He as strike, Me as strikethrough, Le as strip, We as underline, Ye as visible, Ze as white, qe as whiteBright, Ie as yellow, Ve as yellowBright };
|
|
7
7
|
//# sourceMappingURL=out.js.map
|
|
8
8
|
//# sourceMappingURL=index.server.js.map
|
package/dist/index.server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js","../src/ansi-codes.ts","../src/utils.ts","../src/colorize.server.ts","../src/index.server.mts"],"names":["ansiRegex","onlyFirst","pattern","isStdoutColorSupported","hexToRgb","hex","color","number_","clamp","min","max","stringReplaceAll","string_","searchValue","replaceValue","pos","substringLength","lastPos","result","esc","open","close","createAnsi256","code","createBgAnsi256","createRgb","r","g","b","createBgRgb","baseStyles","baseColors","styleMethods","styles","stylePrototype","wrapText","strings","values","properties","string","currentProperties","createStyle","props","openStack","closeStack","style","Colorize","self","value","name","arguments_","colorize_server_default","colorize","index_server_default","ansi256","bg","bgAnsi256","bgBlack","bgBlackBright","bgBlue","bgBlueBright","bgCyan","bgCyanBright","bgGray","bgGreen","bgGreenBright","bgGrey","bgHex","bgMagenta","bgMagentaBright","bgRed","bgRedBright","bgRgb","bgWhite","bgWhiteBright","bgYellow","bgYellowBright","black","blackBright","blue","blueBright","bold","cyan","cyanBright","dim","fg","gray","green","greenBright","grey","hidden","inverse","italic","magenta","magentaBright","overline","red","redBright","reset","rgb","strike","strikethrough","strip","underline","visible","white","whiteBright","yellow","yellowBright"],"mappings":"AAAe,SAARA,EAA2B,CAAC,UAAAC,EAAY,EAAK,EAAI,CAAC,EAAG,CAC3D,IAAMC,EAAU,CACZ,+HACH,0DACD,EAAE,KAAK,GAAG,EAEV,OAAO,IAAI,OAAOA,EAASD,EAAY,OAAY,GAAG,CACvD,CCCA,OAAS,0BAAAE,MAA8B,oCCchC,IAAMC,EAAYC,GAA0C,CAC/D,IAAIC,EAAgBD,EAAI,QAAQ,IAAK,EAAE,EAEvC,GAAIC,EAAM,SAAW,EACjBA,EAASA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,UAC5HA,EAAM,SAAW,EACxB,MAAO,CAAC,EAAG,EAAG,CAAC,EAInB,IAAMC,EAAU,OAAO,SAASD,EAAO,EAAE,EAGzC,MAAO,CAAEC,GAAW,GAAM,IAAMA,GAAW,EAAK,IAAKA,EAAU,GAAG,CACtE,EAMaC,EAAQ,CAACD,EAAi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A,OAAAC,EACA,MAAAC,EACA,UAAAC,EACA,gBAAAC,GACA,MAAAC,GACA,YAAAC,GACA,MAAAC,GACA,QAAAC,GACA,cAAAC,GACA,SAAAC,GACA,eAAAC,GACA,MAAAC,GACA,YAAAC,GACA,KAAAC,GACA,WAAAC,GACA,KAAAC,GACA,KAAAC,GACA,WAAAC,GACA,IAAAC,GACA,GAAAC,GACA,KAAAC,GACA,MAAAC,GACA,YAAAC,GACA,KAAAC,GACA,IAAApF,GACA,OAAAqF,GACA,QAAAC,GACA,OAAAC,GACA,QAAAC,GACA,cAAAC,GACA,SAAAC,GACA,IAAAC,GACA,UAAAC,GACA,MAAAC,GACA,IAAAC,GACA,OAAAC,GACA,cAAAC,GACA,MAAAC,GACA,UAAAC,GACA,QAAAC,GACA,MAAAC,GACA,YAAAC,GACA,OAAAC,GACA,aAAAC,EACJ,EAAIxD","sourcesContent":["export default function ansiRegex({onlyFirst = false} = {}) {\n\tconst pattern = [\n\t '[\\\\u001B\\\\u009B][[\\\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]+)*|[a-zA-Z\\\\d]+(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*)?\\\\u0007)',\n\t\t'(?:(?:\\\\d{1,4}(?:;\\\\d{0,4})*)?[\\\\dA-PR-TZcf-ntqry=><~]))'\n\t].join('|');\n\n\treturn new RegExp(pattern, onlyFirst ? undefined : 'g');\n}\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/ansi-codes.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\nimport { isStdoutColorSupported } from \"@visulima/is-ansi-color-supported\";\n\nimport type { AnsiColors, AnsiStyles, ColorData } from \"./types\";\nimport { clamp, hexToRgb } from \"./utils\";\n\nconst esc: (open: number | string, close: number | string) => ColorData =\n isStdoutColorSupported() > 0\n ? (open: number | string, close: number | string): ColorData => {\n return { close: \"\\u001B[\" + close + \"m\", open: \"\\u001B[\" + open + \"m\" };\n }\n : (): ColorData => {\n return { close: \"\", open: \"\" };\n };\n\nconst createAnsi256 = (code: number | string): ColorData => esc(\"38;5;\" + code, 39);\n\nconst createBgAnsi256 = (code: number | string): ColorData => esc(\"48;5;\" + code, 49);\n\nconst createRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"38;2;\" + r + \";\" + g + \";\" + b, 39);\n\nconst createBgRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"48;2;\" + r + \";\" + g + \";\" + b, 49);\n\nexport const baseStyles: Required<Record<AnsiStyles, ColorData>> = {\n // 21 isn't widely supported and 22 does the same thing\n bold: esc(1, 22),\n dim: esc(2, 22),\n hidden: esc(8, 28),\n inverse: esc(7, 27),\n italic: esc(3, 23),\n overline: esc(53, 55),\n reset: esc(0, 0),\n strike: esc(9, 29), // alias for strikethrough\n strikethrough: esc(9, 29),\n underline: esc(4, 24),\n visible: { close: \"\", open: \"\" },\n};\n\nexport const baseColors: Required<Record<AnsiColors, ColorData>> = {\n bgBlack: esc(40, 49),\n bgBlackBright: esc(100, 49),\n bgBlue: esc(44, 49),\n bgBlueBright: esc(104, 49),\n bgCyan: esc(46, 49),\n bgCyanBright: esc(106, 49),\n bgGray: esc(100, 49), // US spelling alias for bgBlackBright\n bgGreen: esc(42, 49),\n bgGreenBright: esc(102, 49),\n bgGrey: esc(100, 49), // UK spelling alias for bgBlackBright\n bgMagenta: esc(45, 49),\n bgMagentaBright: esc(105, 49),\n bgRed: esc(41, 49),\n bgRedBright: esc(101, 49),\n bgWhite: esc(47, 49),\n bgWhiteBright: esc(107, 49),\n bgYellow: esc(43, 49),\n bgYellowBright: esc(103, 49),\n black: esc(30, 39),\n blackBright: esc(90, 39),\n blue: esc(34, 39),\n blueBright: esc(94, 39),\n cyan: esc(36, 39),\n cyanBright: esc(96, 39),\n gray: esc(90, 39), // US spelling alias for blackBright\n green: esc(32, 39),\n greenBright: esc(92, 39),\n grey: esc(90, 39), // UK spelling alias for blackBright\n magenta: esc(35, 39),\n magentaBright: esc(95, 39),\n red: esc(31, 39),\n redBright: esc(91, 39),\n white: esc(37, 39),\n whiteBright: esc(97, 39),\n yellow: esc(33, 39),\n yellowBright: esc(93, 39),\n};\n\nexport const styleMethods: {\n bg: (code: number) => ColorData;\n bgHex: (hex: string) => ColorData;\n bgRgb: (r: number, g: number, b: number) => ColorData;\n fg: (code: number) => ColorData;\n hex: (hex: string) => ColorData;\n rgb: (r: number, g: number, b: number) => ColorData;\n} = {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bg: (code) => createBgAnsi256(clamp(code, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bgHex: (hex) => createBgRgb(...hexToRgb(hex)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bgRgb: (r, g, b) => createBgRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n fg: (code) => createAnsi256(clamp(code, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hex: (hex) => createRgb(...hexToRgb(hex)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n rgb: (r, g, b) => createRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n/**\n * Convert hex color string to RGB values.\n *\n * A hexadecimal color code can be 3 or 6 digits with an optional \"#\" prefix.\n *\n * The 3 digits specifies an RGB doublet data as a fully opaque color.\n * For example, \"#123\" specifies the color that is represented by \"#112233\".\n *\n * The 6 digits specifies a fully opaque color.\n * For example, \"#112233\".\n *\n * @param {string} hex A string that contains the hexadecimal RGB color representation.\n * @return {[number, number, number]} The red, green, blue values in range [0, 255] .\n */\nexport const hexToRgb = (hex: string): [number, number, number] => {\n let color: string = hex.replace(\"#\", \"\");\n\n if (color.length === 3) {\n color = (color[0] as string) + (color[0] as string) + (color[1] as string) + (color[1] as string) + (color[2] as string) + (color[2] as string);\n } else if (color.length !== 6) {\n return [0, 0, 0];\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const number_ = Number.parseInt(color, 16);\n\n // eslint-disable-next-line no-bitwise\n return [(number_ >> 16) & 255, (number_ >> 8) & 255, number_ & 255];\n};\n\n/**\n * Clamp a number within the inclusive range specified by min and max.\n * @note: The ternary operator is a tick quicker than Math.min(Math.max(num, min), max).\n */\nexport const clamp = (number_: number, min: number, max: number): number => (min > number_ ? min : number_ > max ? max : number_);\n\n/**\n * Replace all matched strings.\n * Note: this implementation is over 30% faster than String.replaceAll().\n */\nexport const stringReplaceAll = (string_: string, searchValue: string, replaceValue: string): string => {\n // visible style has empty open/close props\n if (searchValue === \"\") {\n return string_;\n }\n\n let pos = string_.indexOf(searchValue);\n if (pos < 0) {\n return string_;\n }\n\n const substringLength = searchValue.length;\n let lastPos = 0;\n let result = \"\";\n\n // eslint-disable-next-line no-loops/no-loops,no-bitwise\n while (~pos) {\n result += string_.slice(lastPos, pos) + replaceValue;\n lastPos = pos + substringLength;\n pos = string_.indexOf(searchValue, lastPos);\n }\n\n return result + string_.slice(lastPos);\n};\n\nexport const ansiCodeHexMap: Record<number, string> = {\n 0: \"#000\",\n 1: \"#800\",\n 2: \"#080\",\n 3: \"#880\",\n 4: \"#008\",\n 5: \"#808\",\n 6: \"#088\",\n 7: \"#ccc\",\n 8: \"#444\",\n 9: \"#f00\",\n 10: \"#0f0\",\n 11: \"#ff0\",\n 12: \"#00f\",\n 13: \"#f0f\",\n 14: \"#0ff\",\n 15: \"#fff\",\n 16: \"#000\",\n 17: \"#00005f\",\n 18: \"#000087\",\n 19: \"#0000af\",\n 20: \"#0000d7\",\n 21: \"#0000ff\",\n 22: \"#005f00\",\n 23: \"#005f5f\",\n 24: \"#005f87\",\n 25: \"#005faf\",\n 26: \"#005fd7\",\n 27: \"#005fff\",\n 28: \"#008700\",\n 29: \"#00875f\",\n 30: \"#008787\",\n 31: \"#0087af\",\n 32: \"#0087d7\",\n 33: \"#0087ff\",\n 34: \"#00af00\",\n 35: \"#00af5f\",\n 36: \"#00af87\",\n 37: \"#00afaf\",\n 38: \"#00afd7\",\n 39: \"#00afff\",\n 40: \"#00d700\",\n 41: \"#00d75f\",\n 42: \"#00d787\",\n 43: \"#00d7af\",\n 44: \"#00d7d7\",\n 45: \"#00d7ff\",\n 46: \"#00ff00\",\n 47: \"#00ff5f\",\n 48: \"#00ff87\",\n 49: \"#00ffaf\",\n 50: \"#00ffd7\",\n 51: \"#00ffff\",\n 52: \"#5f0000\",\n 53: \"#5f005f\",\n 54: \"#5f0087\",\n 55: \"#5f00af\",\n 56: \"#5f00d7\",\n 57: \"#5f00ff\",\n 58: \"#5f5f00\",\n 59: \"#5f5f5f\",\n 60: \"#5f5f87\",\n 61: \"#5f5faf\",\n 62: \"#5f5fd7\",\n 63: \"#5f5fff\",\n 64: \"#5f8700\",\n 65: \"#5f875f\",\n 66: \"#5f8787\",\n 67: \"#5f87af\",\n 68: \"#5f87d7\",\n 69: \"#5f87ff\",\n 70: \"#5faf00\",\n 71: \"#5faf5f\",\n 72: \"#5faf87\",\n 73: \"#5fafaf\",\n 74: \"#5fafd7\",\n 75: \"#5fafff\",\n 76: \"#5fd700\",\n 77: \"#5fd75f\",\n 78: \"#5fd787\",\n 79: \"#5fd7af\",\n 80: \"#5fd7d7\",\n 81: \"#5fd7ff\",\n 82: \"#5fff00\",\n 83: \"#5fff5f\",\n 84: \"#5fff87\",\n 85: \"#5fffaf\",\n 86: \"#5fffd7\",\n 87: \"#5fffff\",\n 88: \"#870000\",\n 89: \"#87005f\",\n 90: \"#870087\",\n 91: \"#8700af\",\n 92: \"#8700d7\",\n 93: \"#8700ff\",\n 94: \"#875f00\",\n 95: \"#875f5f\",\n 96: \"#875f87\",\n 97: \"#875faf\",\n 98: \"#875fd7\",\n 99: \"#875fff\",\n 100: \"#878700\",\n 101: \"#87875f\",\n 102: \"#878787\",\n 103: \"#8787af\",\n 104: \"#8787d7\",\n 105: \"#8787ff\",\n 106: \"#87af00\",\n 107: \"#87af5f\",\n 108: \"#87af87\",\n 109: \"#87afaf\",\n 110: \"#87afd7\",\n 111: \"#87afff\",\n 112: \"#87d700\",\n 113: \"#87d75f\",\n 114: \"#87d787\",\n 115: \"#87d7af\",\n 116: \"#87d7d7\",\n 117: \"#87d7ff\",\n 118: \"#87ff00\",\n 119: \"#87ff5f\",\n 120: \"#87ff87\",\n 121: \"#87ffaf\",\n 122: \"#87ffd7\",\n 123: \"#87ffff\",\n 124: \"#af0000\",\n 125: \"#af005f\",\n 126: \"#af0087\",\n 127: \"#af00af\",\n 128: \"#af00d7\",\n 129: \"#af00ff\",\n 130: \"#af5f00\",\n 131: \"#af5f5f\",\n 132: \"#af5f87\",\n 133: \"#af5faf\",\n 134: \"#af5fd7\",\n 135: \"#af5fff\",\n 136: \"#af8700\",\n 137: \"#af875f\",\n 138: \"#af8787\",\n 139: \"#af87af\",\n 140: \"#af87d7\",\n 141: \"#af87ff\",\n 142: \"#afaf00\",\n 143: \"#afaf5f\",\n 144: \"#afaf87\",\n 145: \"#afafaf\",\n 146: \"#afafd7\",\n 147: \"#afafff\",\n 148: \"#afd700\",\n 149: \"#afd75f\",\n 150: \"#afd787\",\n 151: \"#afd7af\",\n 152: \"#afd7d7\",\n 153: \"#afd7ff\",\n 154: \"#afff00\",\n 155: \"#afff5f\",\n 156: \"#afff87\",\n 157: \"#afffaf\",\n 158: \"#afffd7\",\n 159: \"#afffff\",\n 160: \"#d70000\",\n 161: \"#d7005f\",\n 162: \"#d70087\",\n 163: \"#d700af\",\n 164: \"#d700d7\",\n 165: \"#d700ff\",\n 166: \"#d75f00\",\n 167: \"#d75f5f\",\n 168: \"#d75f87\",\n 169: \"#d75faf\",\n 170: \"#d75fd7\",\n 171: \"#d75fff\",\n 172: \"#d78700\",\n 173: \"#d7875f\",\n 174: \"#d78787\",\n 175: \"#d787af\",\n 176: \"#d787d7\",\n 177: \"#d787ff\",\n 178: \"#d7af00\",\n 179: \"#d7af5f\",\n 180: \"#d7af87\",\n 181: \"#d7afaf\",\n 182: \"#d7afd7\",\n 183: \"#d7afff\",\n 184: \"#d7d700\",\n 185: \"#d7d75f\",\n 186: \"#d7d787\",\n 187: \"#d7d7af\",\n 188: \"#d7d7d7\",\n 189: \"#d7d7ff\",\n 190: \"#d7ff00\",\n 191: \"#d7ff5f\",\n 192: \"#d7ff87\",\n 193: \"#d7ffaf\",\n 194: \"#d7ffd7\",\n 195: \"#d7ffff\",\n 196: \"#ff0000\",\n 197: \"#ff005f\",\n 198: \"#ff0087\",\n 199: \"#ff00af\",\n 200: \"#ff00d7\",\n 201: \"#ff00ff\",\n 202: \"#ff5f00\",\n 203: \"#ff5f5f\",\n 204: \"#ff5f87\",\n 205: \"#ff5faf\",\n 206: \"#ff5fd7\",\n 207: \"#ff5fff\",\n 208: \"#ff8700\",\n 209: \"#ff875f\",\n 210: \"#ff8787\",\n 211: \"#ff87af\",\n 212: \"#ff87d7\",\n 213: \"#ff87ff\",\n 214: \"#ffaf00\",\n 215: \"#ffaf5f\",\n 216: \"#ffaf87\",\n 217: \"#ffafaf\",\n 218: \"#ffafd7\",\n 219: \"#ffafff\",\n 220: \"#ffd700\",\n 221: \"#ffd75f\",\n 222: \"#ffd787\",\n 223: \"#ffd7af\",\n 224: \"#ffd7d7\",\n 225: \"#ffd7ff\",\n 226: \"#ffff00\",\n 227: \"#ffff5f\",\n 228: \"#ffff87\",\n 229: \"#ffffaf\",\n 230: \"#ffffd7\",\n 231: \"#ffffff\",\n 232: \"#080808\",\n 233: \"#121212\",\n 234: \"#1c1c1c\",\n 235: \"#262626\",\n 236: \"#303030\",\n 237: \"#3a3a3a\",\n 238: \"#444444\",\n 239: \"#4e4e4e\",\n 240: \"#585858\",\n 241: \"#626262\",\n 242: \"#6c6c6c\",\n 243: \"#767676\",\n 244: \"#808080\",\n 245: \"#8a8a8a\",\n 246: \"#949494\",\n 247: \"#9e9e9e\",\n 248: \"#a8a8a8\",\n 249: \"#b2b2b2\",\n 250: \"#bcbcbc\",\n 251: \"#c6c6c6\",\n 252: \"#d0d0d0\",\n 253: \"#dadada\",\n 254: \"#e4e4e4\",\n 255: \"#eeeeee\",\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/index.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport ansiRegex from \"ansi-regex\";\n\nimport { baseColors, baseStyles, styleMethods } from \"./ansi-codes\";\nimport type { ColorData, ColorizeType } from \"./types\";\nimport { stringReplaceAll } from \"./utils\";\n\nconst styles: Record<string, object> = {};\n\nlet stylePrototype: object | null = null;\n\nconst wrapText = (\n strings: ArrayLike<string> | ReadonlyArray<string> | number | string | { raw: ArrayLike<string> | ReadonlyArray<string> },\n values: string[],\n properties: ColorizeProperties,\n) => {\n if (!strings) {\n return \"\";\n }\n\n let string =\n (strings as { raw?: ArrayLike<string> | ReadonlyArray<string> | null }).raw == null\n ? (((strings as number | string) + \"\") as string)\n : String.raw(strings as { raw: ArrayLike<string> | ReadonlyArray<string> }, ...values);\n\n if (string.includes(\"\\u001B\")) {\n // eslint-disable-next-line no-loops/no-loops,@typescript-eslint/no-unnecessary-condition\n for (let currentProperties = properties; currentProperties; currentProperties = currentProperties.props) {\n string = stringReplaceAll(string, currentProperties.close, currentProperties.open);\n }\n }\n\n if (string.includes(\"\\n\")) {\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n string = string.replace(/(\\r*\\n)/g, properties.closeStack + \"$1\" + properties.openStack);\n }\n\n return properties.openStack + string + properties.closeStack;\n};\n\ntype ColorizeProperties = { close: string; closeStack: string; open: string; openStack: string; props: ColorizeProperties };\n\nconst createStyle = (\n { props }: { props?: ColorizeProperties },\n { close, open }: ColorData,\n): {\n (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]): string;\n close: string;\n open: string;\n props: { close: string; closeStack: string; open: string; openStack: string; props?: ColorizeProperties };\n} => {\n const openStack: string = (props?.openStack ?? \"\") + open;\n const closeStack: string = close + (props?.closeStack ?? \"\");\n\n const style = (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]) => wrapText(strings, values, style.props);\n\n Object.setPrototypeOf(style, stylePrototype);\n\n style.props = { close, closeStack, open, openStack, props } as ColorizeProperties;\n style.open = openStack;\n style.close = closeStack;\n\n return style;\n};\n\n// eslint-disable-next-line func-names\nconst Colorize = function () {\n const self = (string_: number | string) => string_ + \"\";\n\n self.strip = (value: string): string => value.replaceAll(ansiRegex(), \"\");\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseColors) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const style = createStyle(this, baseColors[name as keyof typeof baseColors]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseStyles) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const style = createStyle(this, baseStyles[name as keyof typeof baseStyles]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // This needs to be the last thing we do, so that the prototype is fully populated.\n stylePrototype = Object.defineProperties({}, styles);\n\n Object.setPrototypeOf(self, stylePrototype);\n\n return self;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} as any as new () => ColorizeType;\n\n// eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\nfor (const name in styleMethods) {\n styles[name as keyof typeof styleMethods] = {\n get() {\n return (...arguments_: (number | string)[]) =>\n // @ts-expect-error: TODO: fix typing of `arguments_`\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n createStyle(this, styleMethods[name as keyof typeof styleMethods](...arguments_));\n },\n };\n}\n\nstyles[\"ansi256\"] = styles[\"fg\"] as object;\nstyles[\"bgAnsi256\"] = styles[\"bg\"] as object;\n\n// eslint-disable-next-line import/no-default-export\nexport default Colorize;\n","import ColorizeImpl from \"./colorize.server\";\nimport type { ColorizeType } from \"./types\";\n\nconst colorize: ColorizeType = new ColorizeImpl() as ColorizeType;\n\n// eslint-disable-next-line import/no-default-export\nexport default colorize as ColorizeType;\n\n// eslint-disable-next-line import/no-unused-modules\nexport const {\n ansi256,\n bg,\n bgAnsi256,\n bgBlack,\n bgBlackBright,\n bgBlue,\n bgBlueBright,\n bgCyan,\n bgCyanBright,\n bgGray,\n bgGreen,\n bgGreenBright,\n bgGrey,\n bgHex,\n bgMagenta,\n bgMagentaBright,\n bgRed,\n bgRedBright,\n bgRgb,\n bgWhite,\n bgWhiteBright,\n bgYellow,\n bgYellowBright,\n black,\n blackBright,\n blue,\n blueBright,\n bold,\n cyan,\n cyanBright,\n dim,\n fg,\n gray,\n green,\n greenBright,\n grey,\n hex,\n hidden,\n inverse,\n italic,\n magenta,\n magentaBright,\n overline,\n red,\n redBright,\n reset,\n rgb,\n strike,\n strikethrough,\n strip,\n underline,\n visible,\n white,\n whiteBright,\n yellow,\n yellowBright,\n} = colorize;\n\nexport { default as Colorize } from \"./colorize.server\";\n\n// eslint-disable-next-line import/no-unused-modules\nexport type { AnsiColors, AnsiStyles, ColorizeType } from \"./types\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js","../src/ansi-codes.ts","../src/util/clamp.ts","../src/util/hex-to-rgb.ts","../src/util/string-replace-all.ts","../src/colorize.server.ts","../src/index.server.mts"],"names":["ansiRegex","onlyFirst","pattern","isStdoutColorSupported","clamp","number_","min","max","hexToRgb","hex","color","esc","open","close","createAnsi256","code","createBgAnsi256","createRgb","r","g","b","createBgRgb","baseStyles","baseColors","styleMethods","stringReplaceAll","string_","searchValue","replaceValue","pos","substringLength","lastPos","result","styles","stylePrototype","wrapText","strings","values","properties","string","currentProperties","createStyle","props","openStack","closeStack","style","Colorize","self","value","name","arguments_","colorize_server_default","colorize","index_server_default","ansi256","bg","bgAnsi256","bgBlack","bgBlackBright","bgBlue","bgBlueBright","bgCyan","bgCyanBright","bgGray","bgGreen","bgGreenBright","bgGrey","bgHex","bgMagenta","bgMagentaBright","bgRed","bgRedBright","bgRgb","bgWhite","bgWhiteBright","bgYellow","bgYellowBright","black","blackBright","blue","blueBright","bold","cyan","cyanBright","dim","fg","gray","green","greenBright","grey","hidden","inverse","italic","magenta","magentaBright","overline","red","redBright","reset","rgb","strike","strikethrough","strip","underline","visible","white","whiteBright","yellow","yellowBright"],"mappings":"AAAe,SAARA,EAA2B,CAAC,UAAAC,EAAY,EAAK,EAAI,CAAC,EAAG,CAC3D,IAAMC,EAAU,CACZ,+HACH,0DACD,EAAE,KAAK,GAAG,EAEV,OAAO,IAAI,OAAOA,EAASD,EAAY,OAAY,GAAG,CACvD,CCCA,OAAS,0BAAAE,MAA8B,oCCKhC,IAAMC,EAAQ,CAACC,EAAiBC,EAAaC,IAAyBD,EAAMD,EAAUC,EAAMD,EAAUE,EAAMA,EAAMF,ECWlH,IAAMG,EAAYC,GAAiD,CACtE,IAAIC,EAAgBD,EAAI,QAAQ,IAAK,EAAE,EAEvC,GAAIC,EAAM,SAAW,EACjBA,EAASA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,UAC5HA,EAAM,SAAW,EACxB,MAAO,CAAC,EAAG,EAAG,CAAC,EAInB,IAAML,EAAU,OAAO,SAASK,EAAO,EAAE,EAGzC,MAAO,CAAEL,GAAW,GAAM,IAAMA,GAAW,EAAK,IAAKA,EAAU,GAAG,CACtE,EFxBA,IAAMM,EACFR,EAAuB,EAAI,EACrB,CAAC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A,eAAAC,GACA,MAAAC,GACA,YAAAC,GACA,KAAAC,GACA,WAAAC,GACA,KAAAC,GACA,KAAAC,GACA,WAAAC,GACA,IAAAC,GACA,GAAAC,GACA,KAAAC,GACA,MAAAC,GACA,YAAAC,GACA,KAAAC,GACA,IAAAhF,GACA,OAAAiF,GACA,QAAAC,GACA,OAAAC,GACA,QAAAC,GACA,cAAAC,GACA,SAAAC,GACA,IAAAC,GACA,UAAAC,GACA,MAAAC,GACA,IAAAC,GACA,OAAAC,GACA,cAAAC,GACA,MAAAC,GACA,UAAAC,GACA,QAAAC,GACA,MAAAC,GACA,YAAAC,GACA,OAAAC,GACA,aAAAC,EACJ,EAAIxD","sourcesContent":["export default function ansiRegex({onlyFirst = false} = {}) {\n\tconst pattern = [\n\t '[\\\\u001B\\\\u009B][[\\\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]+)*|[a-zA-Z\\\\d]+(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*)?\\\\u0007)',\n\t\t'(?:(?:\\\\d{1,4}(?:;\\\\d{0,4})*)?[\\\\dA-PR-TZcf-ntqry=><~]))'\n\t].join('|');\n\n\treturn new RegExp(pattern, onlyFirst ? undefined : 'g');\n}\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/ansi-codes.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\nimport { isStdoutColorSupported } from \"@visulima/is-ansi-color-supported\";\n\nimport type { AnsiColors, AnsiStyles, ColorData, ColorValueHex } from \"./types\";\nimport { clamp } from \"./util/clamp\";\nimport { hexToRgb } from \"./util/hex-to-rgb\";\n\nconst esc: (open: number | string, close: number | string) => ColorData =\n isStdoutColorSupported() > 0\n ? (open: number | string, close: number | string): ColorData => {\n return { close: \"\\u001B[\" + close + \"m\", open: \"\\u001B[\" + open + \"m\" };\n }\n : (): ColorData => {\n return { close: \"\", open: \"\" };\n };\n\nconst createAnsi256 = (code: number | string): ColorData => esc(\"38;5;\" + code, 39);\n\nconst createBgAnsi256 = (code: number | string): ColorData => esc(\"48;5;\" + code, 49);\n\nconst createRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"38;2;\" + r + \";\" + g + \";\" + b, 39);\n\nconst createBgRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"48;2;\" + r + \";\" + g + \";\" + b, 49);\n\nexport const baseStyles: Required<Record<AnsiStyles, ColorData>> = {\n // 21 isn't widely supported and 22 does the same thing\n bold: esc(1, 22),\n dim: esc(2, 22),\n hidden: esc(8, 28),\n inverse: esc(7, 27),\n italic: esc(3, 23),\n overline: esc(53, 55),\n reset: esc(0, 0),\n strike: esc(9, 29), // alias for strikethrough\n strikethrough: esc(9, 29),\n underline: esc(4, 24),\n visible: { close: \"\", open: \"\" },\n};\n\nexport const baseColors: Required<Record<AnsiColors, ColorData>> = {\n bgBlack: esc(40, 49),\n bgBlackBright: esc(100, 49),\n bgBlue: esc(44, 49),\n bgBlueBright: esc(104, 49),\n bgCyan: esc(46, 49),\n bgCyanBright: esc(106, 49),\n bgGray: esc(100, 49), // US spelling alias for bgBlackBright\n bgGreen: esc(42, 49),\n bgGreenBright: esc(102, 49),\n bgGrey: esc(100, 49), // UK spelling alias for bgBlackBright\n bgMagenta: esc(45, 49),\n bgMagentaBright: esc(105, 49),\n bgRed: esc(41, 49),\n bgRedBright: esc(101, 49),\n bgWhite: esc(47, 49),\n bgWhiteBright: esc(107, 49),\n bgYellow: esc(43, 49),\n bgYellowBright: esc(103, 49),\n black: esc(30, 39),\n blackBright: esc(90, 39),\n blue: esc(34, 39),\n blueBright: esc(94, 39),\n cyan: esc(36, 39),\n cyanBright: esc(96, 39),\n gray: esc(90, 39), // US spelling alias for blackBright\n green: esc(32, 39),\n greenBright: esc(92, 39),\n grey: esc(90, 39), // UK spelling alias for blackBright\n magenta: esc(35, 39),\n magentaBright: esc(95, 39),\n red: esc(31, 39),\n redBright: esc(91, 39),\n white: esc(37, 39),\n whiteBright: esc(97, 39),\n yellow: esc(33, 39),\n yellowBright: esc(93, 39),\n};\n\nexport const styleMethods: {\n bg: (code: number) => ColorData;\n bgHex: (hex: ColorValueHex) => ColorData;\n bgRgb: (r: number, g: number, b: number) => ColorData;\n fg: (code: number) => ColorData;\n hex: (hex: ColorValueHex) => ColorData;\n rgb: (r: number, g: number, b: number) => ColorData;\n} = {\n bg: (code) => createBgAnsi256(clamp(code, 0, 255)),\n\n bgHex: (hex) => createBgRgb(...hexToRgb(hex)),\n\n bgRgb: (r, g, b) => createBgRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n\n fg: (code) => createAnsi256(clamp(code, 0, 255)),\n\n hex: (hex) => createRgb(...hexToRgb(hex)),\n\n rgb: (r, g, b) => createRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n/**\n * Clamp a number within the inclusive range specified by min and max.\n * @note: The ternary operator is a tick quicker than Math.min(Math.max(num, min), max).\n */\n\nexport const clamp = (number_: number, min: number, max: number): number => (min > number_ ? min : number_ > max ? max : number_);\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\nimport type { ColorValueHex } from \"../types\";\n\n/**\n * Convert hex color string to RGB values.\n *\n * A hexadecimal color code can be 3 or 6 digits with an optional \"#\" prefix.\n *\n * The 3 digits specifies an RGB doublet data as a fully opaque color.\n * For example, \"#123\" specifies the color that is represented by \"#112233\".\n *\n * The 6 digits specifies a fully opaque color.\n * For example, \"#112233\".\n *\n * @param {string} hex A string that contains the hexadecimal RGB color representation.\n * @return {[number, number, number]} The red, green, blue values in range [0, 255] .\n */\nexport const hexToRgb = (hex: ColorValueHex): [number, number, number] => {\n let color: string = hex.replace(\"#\", \"\");\n\n if (color.length === 3) {\n color = (color[0] as string) + (color[0] as string) + (color[1] as string) + (color[1] as string) + (color[2] as string) + (color[2] as string);\n } else if (color.length !== 6) {\n return [0, 0, 0];\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const number_ = Number.parseInt(color, 16);\n\n // eslint-disable-next-line no-bitwise\n return [(number_ >> 16) & 255, (number_ >> 8) & 255, number_ & 255];\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n/**\n * Replace all matched strings.\n * Note: this implementation is over 30% faster than String.replaceAll().\n */\nexport const stringReplaceAll = (string_: string, searchValue: string, replaceValue: string): string => {\n // visible style has empty open/close props\n if (searchValue === \"\") {\n return string_;\n }\n\n let pos = string_.indexOf(searchValue);\n if (pos < 0) {\n return string_;\n }\n\n const substringLength = searchValue.length;\n let lastPos = 0;\n let result = \"\";\n\n // eslint-disable-next-line no-loops/no-loops,no-bitwise\n while (~pos) {\n result += string_.slice(lastPos, pos) + replaceValue;\n lastPos = pos + substringLength;\n pos = string_.indexOf(searchValue, lastPos);\n }\n\n return result + string_.slice(lastPos);\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/index.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport ansiRegex from \"ansi-regex\";\n\nimport { baseColors, baseStyles, styleMethods } from \"./ansi-codes\";\nimport type { ColorData, ColorizeType } from \"./types\";\nimport { stringReplaceAll } from \"./util/string-replace-all\";\n\nconst styles: Record<string, object> = {};\n\nlet stylePrototype: object | null = null;\n\nconst wrapText = (\n strings: ArrayLike<string> | ReadonlyArray<string> | number | string | { raw: ArrayLike<string> | ReadonlyArray<string> },\n values: string[],\n properties: ColorizeProperties,\n) => {\n if (!strings) {\n return \"\";\n }\n\n let string =\n (strings as { raw?: ArrayLike<string> | ReadonlyArray<string> | null }).raw == null\n ? (((strings as number | string) + \"\") as string)\n : String.raw(strings as { raw: ArrayLike<string> | ReadonlyArray<string> }, ...values);\n\n if (string.includes(\"\\u001B\")) {\n // eslint-disable-next-line no-loops/no-loops,@typescript-eslint/no-unnecessary-condition\n for (let currentProperties = properties; currentProperties; currentProperties = currentProperties.props) {\n string = stringReplaceAll(string, currentProperties.close, currentProperties.open);\n }\n }\n\n if (string.includes(\"\\n\")) {\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n string = string.replace(/(\\r*\\n)/g, properties.closeStack + \"$1\" + properties.openStack);\n }\n\n return properties.openStack + string + properties.closeStack;\n};\n\ntype ColorizeProperties = { close: string; closeStack: string; open: string; openStack: string; props: ColorizeProperties };\n\nconst createStyle = (\n { props }: { props?: ColorizeProperties },\n { close, open }: ColorData,\n): {\n (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]): string;\n close: string;\n open: string;\n props: { close: string; closeStack: string; open: string; openStack: string; props?: ColorizeProperties };\n} => {\n const openStack: string = (props?.openStack ?? \"\") + open;\n const closeStack: string = close + (props?.closeStack ?? \"\");\n\n const style = (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]) => wrapText(strings, values, style.props);\n\n Object.setPrototypeOf(style, stylePrototype);\n\n style.props = { close, closeStack, open, openStack, props } as ColorizeProperties;\n style.open = openStack;\n style.close = closeStack;\n\n return style;\n};\n\n// eslint-disable-next-line func-names\nconst Colorize = function () {\n const self = (string_: number | string) => string_ + \"\";\n\n self.strip = (value: string): string => value.replaceAll(ansiRegex(), \"\");\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseColors) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n const style = createStyle(this, baseColors[name as keyof typeof baseColors]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseStyles) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n const style = createStyle(this, baseStyles[name as keyof typeof baseStyles]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // This needs to be the last thing we do, so that the prototype is fully populated.\n stylePrototype = Object.defineProperties({}, styles);\n\n Object.setPrototypeOf(self, stylePrototype);\n\n return self;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} as any as new () => ColorizeType;\n\n// eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\nfor (const name in styleMethods) {\n styles[name as keyof typeof styleMethods] = {\n get() {\n return (...arguments_: (number | string)[]) =>\n // @ts-expect-error: TODO: fix typing of `arguments_`\n\n createStyle(this, styleMethods[name as keyof typeof styleMethods](...arguments_));\n },\n };\n}\n\nstyles[\"ansi256\"] = styles[\"fg\"] as object;\nstyles[\"bgAnsi256\"] = styles[\"bg\"] as object;\n\n// eslint-disable-next-line import/no-default-export\nexport default Colorize;\n","import ColorizeImpl from \"./colorize.server\";\nimport type { ColorizeType } from \"./types\";\n\nconst colorize: ColorizeType = new ColorizeImpl() as ColorizeType;\n\n// eslint-disable-next-line import/no-default-export\nexport default colorize as ColorizeType;\n\n// eslint-disable-next-line import/no-unused-modules\nexport const {\n ansi256,\n bg,\n bgAnsi256,\n bgBlack,\n bgBlackBright,\n bgBlue,\n bgBlueBright,\n bgCyan,\n bgCyanBright,\n bgGray,\n bgGreen,\n bgGreenBright,\n bgGrey,\n bgHex,\n bgMagenta,\n bgMagentaBright,\n bgRed,\n bgRedBright,\n bgRgb,\n bgWhite,\n bgWhiteBright,\n bgYellow,\n bgYellowBright,\n black,\n blackBright,\n blue,\n blueBright,\n bold,\n cyan,\n cyanBright,\n dim,\n fg,\n gray,\n green,\n greenBright,\n grey,\n hex,\n hidden,\n inverse,\n italic,\n magenta,\n magentaBright,\n overline,\n red,\n redBright,\n reset,\n rgb,\n strike,\n strikethrough,\n strip,\n underline,\n visible,\n white,\n whiteBright,\n yellow,\n yellowBright,\n} = colorize;\n\nexport { default as Colorize } from \"./colorize.server\";\n\n// eslint-disable-next-line import/no-unused-modules\nexport type { AnsiColors, AnsiStyles, ColorizeType } from \"./types\";\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var isAnsiColorSupported = require('@visulima/is-ansi-color-supported');
|
|
6
|
+
|
|
7
|
+
function b({onlyFirst:e=!1}={}){let r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(r,e?void 0:"g")}var a=(e,r,t)=>r>e?r:e>t?t:e;var u=e=>{let r=e.replace("#","");if(r.length===3)r=r[0]+r[0]+r[1]+r[1]+r[2]+r[2];else if(r.length!==6)return [0,0,0];let t=Number.parseInt(r,16);return [t>>16&255,t>>8&255,t&255]};var n=isAnsiColorSupported.isStdoutColorSupported()>0?(e,r)=>({close:"\x1B["+r+"m",open:"\x1B["+e+"m"}):()=>({close:"",open:""}),j=e=>n("38;5;"+e,39),v=e=>n("48;5;"+e,49),S=(e,r,t)=>n("38;2;"+e+";"+r+";"+t,39),R=(e,r,t)=>n("48;2;"+e+";"+r+";"+t,49),y={bold:n(1,22),dim:n(2,22),hidden:n(8,28),inverse:n(7,27),italic:n(3,23),overline:n(53,55),reset:n(0,0),strike:n(9,29),strikethrough:n(9,29),underline:n(4,24),visible:{close:"",open:""}},f={bgBlack:n(40,49),bgBlackBright:n(100,49),bgBlue:n(44,49),bgBlueBright:n(104,49),bgCyan:n(46,49),bgCyanBright:n(106,49),bgGray:n(100,49),bgGreen:n(42,49),bgGreenBright:n(102,49),bgGrey:n(100,49),bgMagenta:n(45,49),bgMagentaBright:n(105,49),bgRed:n(41,49),bgRedBright:n(101,49),bgWhite:n(47,49),bgWhiteBright:n(107,49),bgYellow:n(43,49),bgYellowBright:n(103,49),black:n(30,39),blackBright:n(90,39),blue:n(34,39),blueBright:n(94,39),cyan:n(36,39),cyanBright:n(96,39),gray:n(90,39),green:n(32,39),greenBright:n(92,39),grey:n(90,39),magenta:n(35,39),magentaBright:n(95,39),red:n(31,39),redBright:n(91,39),white:n(37,39),whiteBright:n(97,39),yellow:n(33,39),yellowBright:n(93,39)},d={bg:e=>v(a(e,0,255)),bgHex:e=>R(...u(e)),bgRgb:(e,r,t)=>R(a(e,0,255),a(r,0,255),a(t,0,255)),fg:e=>j(a(e,0,255)),hex:e=>S(...u(e)),rgb:(e,r,t)=>S(a(e,0,255),a(r,0,255),a(t,0,255))};var T=(e,r,t)=>{if(r==="")return e;let s=e.indexOf(r);if(s<0)return e;let o=r.length,i=0,l="";for(;~s;)l+=e.slice(i,s)+t,i=s+o,s=e.indexOf(r,i);return l+e.slice(i)};var g={},h=null,H=(e,r,t)=>{if(!e)return "";let s=e.raw==null?e+"":String.raw(e,...r);if(s.includes("\x1B"))for(let o=t;o;o=o.props)s=T(s,o.close,o.open);return s.includes(`
|
|
8
|
+
`)&&(s=s.replace(/(\r*\n)/g,t.closeStack+"$1"+t.openStack)),t.openStack+s+t.closeStack},C=({props:e},{close:r,open:t})=>{let s=(e?.openStack??"")+t,o=r+(e?.closeStack??""),i=(l,...c)=>H(l,c,i.props);return Object.setPrototypeOf(i,h),i.props={close:r,closeStack:o,open:t,openStack:s,props:e},i.open=s,i.close=o,i},O=function(){let e=r=>r+"";e.strip=r=>r.replaceAll(b(),"");for(let r in f)g[r]={get(){let t=C(this,f[r]);return Object.defineProperty(this,r,{value:t}),t}};for(let r in y)g[r]={get(){let t=C(this,y[r]);return Object.defineProperty(this,r,{value:t}),t}};return h=Object.defineProperties({},g),Object.setPrototypeOf(e,h),e};for(let e in d)g[e]={get(){return (...r)=>C(this,d[e](...r))}};g.ansi256=g.fg;g.bgAnsi256=g.bg;var B=O;var x=e=>(r,...t)=>{if(!Array.isArray(r)||!Array.isArray(r.raw))throw new TypeError("A tagged template literal must be provided");let s=[r.raw[0]];for(let o=1;o<r.raw.length;o++)s.push(String(t[o-1]).replaceAll(/[{}\\]/g,"\\$&"),String(r.raw[o]));return e(s.join(""))};var G=new Map([["\\","\\"],["0","\0"],["a","\x07"],["b","\b"],["e","\x1B"],["f","\f"],["n",`
|
|
9
|
+
`],["r","\r"],["t"," "],["v","\v"]]),k=e=>{let r=e.startsWith("u"),t=e[1]==="{";return r&&!t&&e.length===5||e.startsWith("x")&&e.length===3?String.fromCodePoint(Number.parseInt(e.slice(1),16)):r&&t?String.fromCodePoint(Number.parseInt(e.slice(2,-1),16)):G.get(e)??e};var L=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,z=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,N=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,M=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,$=(e,r)=>{let t=[],s=r.trim().split(/\s*,\s*/),o;for(let i of s){let l=Number(i);if(!Number.isNaN(l))t.push(l);else if(o=N.exec(i))t.push(o[2].replace(M,(c,p,m)=>p?k(p):m));else throw new Error(`Invalid template style argument: ${i} (in style '${e}')`)}return t},I=e=>{z.lastIndex=0;let r=[],t;for(;(t=z.exec(e))!==null;){let s=t[1];t[2]?r.push([s,...$(s,t[2])]):t[3]||t[4]?(t[3]&&r.push(["rgb",...u(t[3])]),t[4]&&r.push(["bgRgb",...u(t[4])])):r.push([s]);}return r},E=(e,r)=>{let t={};for(let o of r)for(let i of o.styles)t[i[0]]=o.inverse?null:i.slice(1);let s=e;for(let[o,i]of Object.entries(t))if(Array.isArray(i)){if(!(o in s))throw new Error(`Unknown style: ${o}`);s=i.length>0?s[o](...i):s[o];}return s},A=e=>r=>{let t=[],s=[],o=[];if(r.replaceAll(L,(i,l,c,p,m,P)=>{if(l)o.push(k(l));else if(p){let w=o.join("");o=[],s.push(t.length===0?w:E(e,t)(w)),t.push({inverse:c,styles:I(p)});}else if(m){if(t.length===0)throw new Error("Found extraneous } in template literal");s.push(E(e,t)(o.join(""))),o=[],t.pop();}else o.push(P);}),s.push(o.join("")),t.length>0)throw new Error(`template literal is missing ${t.length} closing bracket${t.length===1?"":"s"} (\`}\`)`);return s.join("")};var V=new B,ue=e=>x(A(e)),W=A(V),pe=x(W);
|
|
10
|
+
|
|
11
|
+
module.exports = pe;
|
|
12
|
+
exports.makeTaggedTemplate = ue;
|
|
13
|
+
exports.template = W;
|
|
14
|
+
//# sourceMappingURL=out.js.map
|
|
15
|
+
//# sourceMappingURL=template.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js","../src/ansi-codes.ts","../src/util/clamp.ts","../src/util/hex-to-rgb.ts","../src/util/string-replace-all.ts","../src/colorize.server.ts","../src/template/make-colorize-template.ts","../src/util/unescape.ts","../src/template/make-template.ts","../src/template.ts"],"names":["ansiRegex","onlyFirst","pattern","isStdoutColorSupported","clamp","number_","min","max","hexToRgb","hex","color","esc","open","close","createAnsi256","code","createBgAnsi256","createRgb","r","g","b","createBgRgb","baseStyles","baseColors","styleMethods","stringReplaceAll","string_","searchValue","replaceValue","pos","substringLength","lastPos","result","styles","stylePrototype","wrapText","strings","values","properties","string","currentProperties","createStyle","props","openStack","closeStack","style","Colorize","self","value","name","arguments_","colorize_server_default","makeColorizeTemplate","template","firstString","parts","index","ESCAPES","unescape","c","u","bracket","TEMPLATE_REGEX","STYLE_REGEX","STRING_REGEX","ESCAPE_REGEX","parseArguments","results","chunks","matches","chunk","number","_","escape","character","parseStyle","buildStyle","colorize","enabled","layer","current","styleName","enabledStyles","makeTemplate","escapeCharacter","inverse","joinedChunk","makeTaggedTemplate","instance","template_default"],"mappings":"AAAe,SAARA,EAA2B,CAAC,UAAAC,EAAY,EAAK,EAAI,CAAC,EAAG,CAC3D,IAAMC,EAAU,CACZ,+HACH,0DACD,EAAE,KAAK,GAAG,EAEV,OAAO,IAAI,OAAOA,EAASD,EAAY,OAAY,GAAG,CACvD,CCCA,OAAS,0BAAAE,MAA8B,oCCKhC,IAAMC,EAAQ,CAACC,EAAiBC,EAAaC,IAAyBD,EAAMD,EAAUC,EAAMD,EAAUE,EAAMA,EAAMF,ECWlH,IAAMG,EAAYC,GAAiD,CACtE,IAAIC,EAAgBD,EAAI,QAAQ,IAAK,EAAE,EAEvC,GAAIC,EAAM,SAAW,EACjBA,EAASA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,UAC5HA,EAAM,SAAW,EACxB,MAAO,CAAC,EAAG,EAAG,CAAC,EAInB,IAAML,EAAU,OAAO,SAASK,EAAO,EAAE,EAGzC,MAAO,CAAEL,GAAW,GAAM,IAAMA,GAAW,EAAK,IAAKA,EAAU,GAAG,CACtE,EFxBA,IAAMM,EACFR,EAAuB,EAAI,EACrB,CAACS,EAAuBC,KACb,CAAE,MAAO,QAAYA,EAAQ,IAAK,KAAM,QAAYD,EAAO,GAAI,GAE1E,KACW,CAAE,MAAO,GAAI,KAAM,EAAG,GAGrCE,EAAiBC,GAAqCJ,EAAI,QAAUI,EAAM,EAAE,EAE5EC,EAAmBD,GAAqCJ,EAAI,QAAUI,EAAM,EAAE,EAE9EE,EAAY,CAACC,EAAoBC,EAAoBC,IAAkCT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nC,EAAO,SAAW,EAAIqD,EAAcV,EAAWC,EAAU5C,CAAM,EAAEqD,CAAW,CAAC,EAEzFrD,EAAO,KAAK,CAAE,QAAAoD,EAAS,OAAQV,EAAW9B,CAAK,CAAE,CAAC,CACtD,SAAWhC,EAAO,CACd,GAAIoB,EAAO,SAAW,EAClB,MAAM,IAAI,MAAM,wCAAwC,EAG5DmC,EAAO,KAAKQ,EAAWC,EAAU5C,CAAM,EAAEqC,EAAM,KAAK,EAAE,CAAC,CAAC,EACxDA,EAAQ,CAAC,EAETrC,EAAO,IAAI,CACf,MACIqC,EAAM,KAAKI,CAAmB,CAEtC,CACJ,EAEAN,EAAO,KAAKE,EAAM,KAAK,EAAE,CAAC,EAEtBrC,EAAO,OAAS,EAChB,MAAM,IAAI,MAAM,+BAA+BA,EAAO,MAAM,mBAAmBA,EAAO,SAAW,EAAI,GAAK,GAAG,UAAU,EAG3H,OAAOmC,EAAO,KAAK,EAAE,CACzB,EC/JJ,IAAMS,EAAyB,IAAI1B,EAGtBoC,GAAsBC,GAC/BpC,EAAqB+B,EAAaK,CAAQ,CAAC,EAGlCnC,EAAW8B,EAAaN,CAAQ,EAGtCY,GAAQrC,EAAqBC,CAAQ","sourcesContent":["export default function ansiRegex({onlyFirst = false} = {}) {\n\tconst pattern = [\n\t '[\\\\u001B\\\\u009B][[\\\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]+)*|[a-zA-Z\\\\d]+(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*)?\\\\u0007)',\n\t\t'(?:(?:\\\\d{1,4}(?:;\\\\d{0,4})*)?[\\\\dA-PR-TZcf-ntqry=><~]))'\n\t].join('|');\n\n\treturn new RegExp(pattern, onlyFirst ? undefined : 'g');\n}\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/ansi-codes.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\nimport { isStdoutColorSupported } from \"@visulima/is-ansi-color-supported\";\n\nimport type { AnsiColors, AnsiStyles, ColorData, ColorValueHex } from \"./types\";\nimport { clamp } from \"./util/clamp\";\nimport { hexToRgb } from \"./util/hex-to-rgb\";\n\nconst esc: (open: number | string, close: number | string) => ColorData =\n isStdoutColorSupported() > 0\n ? (open: number | string, close: number | string): ColorData => {\n return { close: \"\\u001B[\" + close + \"m\", open: \"\\u001B[\" + open + \"m\" };\n }\n : (): ColorData => {\n return { close: \"\", open: \"\" };\n };\n\nconst createAnsi256 = (code: number | string): ColorData => esc(\"38;5;\" + code, 39);\n\nconst createBgAnsi256 = (code: number | string): ColorData => esc(\"48;5;\" + code, 49);\n\nconst createRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"38;2;\" + r + \";\" + g + \";\" + b, 39);\n\nconst createBgRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"48;2;\" + r + \";\" + g + \";\" + b, 49);\n\nexport const baseStyles: Required<Record<AnsiStyles, ColorData>> = {\n // 21 isn't widely supported and 22 does the same thing\n bold: esc(1, 22),\n dim: esc(2, 22),\n hidden: esc(8, 28),\n inverse: esc(7, 27),\n italic: esc(3, 23),\n overline: esc(53, 55),\n reset: esc(0, 0),\n strike: esc(9, 29), // alias for strikethrough\n strikethrough: esc(9, 29),\n underline: esc(4, 24),\n visible: { close: \"\", open: \"\" },\n};\n\nexport const baseColors: Required<Record<AnsiColors, ColorData>> = {\n bgBlack: esc(40, 49),\n bgBlackBright: esc(100, 49),\n bgBlue: esc(44, 49),\n bgBlueBright: esc(104, 49),\n bgCyan: esc(46, 49),\n bgCyanBright: esc(106, 49),\n bgGray: esc(100, 49), // US spelling alias for bgBlackBright\n bgGreen: esc(42, 49),\n bgGreenBright: esc(102, 49),\n bgGrey: esc(100, 49), // UK spelling alias for bgBlackBright\n bgMagenta: esc(45, 49),\n bgMagentaBright: esc(105, 49),\n bgRed: esc(41, 49),\n bgRedBright: esc(101, 49),\n bgWhite: esc(47, 49),\n bgWhiteBright: esc(107, 49),\n bgYellow: esc(43, 49),\n bgYellowBright: esc(103, 49),\n black: esc(30, 39),\n blackBright: esc(90, 39),\n blue: esc(34, 39),\n blueBright: esc(94, 39),\n cyan: esc(36, 39),\n cyanBright: esc(96, 39),\n gray: esc(90, 39), // US spelling alias for blackBright\n green: esc(32, 39),\n greenBright: esc(92, 39),\n grey: esc(90, 39), // UK spelling alias for blackBright\n magenta: esc(35, 39),\n magentaBright: esc(95, 39),\n red: esc(31, 39),\n redBright: esc(91, 39),\n white: esc(37, 39),\n whiteBright: esc(97, 39),\n yellow: esc(33, 39),\n yellowBright: esc(93, 39),\n};\n\nexport const styleMethods: {\n bg: (code: number) => ColorData;\n bgHex: (hex: ColorValueHex) => ColorData;\n bgRgb: (r: number, g: number, b: number) => ColorData;\n fg: (code: number) => ColorData;\n hex: (hex: ColorValueHex) => ColorData;\n rgb: (r: number, g: number, b: number) => ColorData;\n} = {\n bg: (code) => createBgAnsi256(clamp(code, 0, 255)),\n\n bgHex: (hex) => createBgRgb(...hexToRgb(hex)),\n\n bgRgb: (r, g, b) => createBgRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n\n fg: (code) => createAnsi256(clamp(code, 0, 255)),\n\n hex: (hex) => createRgb(...hexToRgb(hex)),\n\n rgb: (r, g, b) => createRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n/**\n * Clamp a number within the inclusive range specified by min and max.\n * @note: The ternary operator is a tick quicker than Math.min(Math.max(num, min), max).\n */\n\nexport const clamp = (number_: number, min: number, max: number): number => (min > number_ ? min : number_ > max ? max : number_);\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\nimport type { ColorValueHex } from \"../types\";\n\n/**\n * Convert hex color string to RGB values.\n *\n * A hexadecimal color code can be 3 or 6 digits with an optional \"#\" prefix.\n *\n * The 3 digits specifies an RGB doublet data as a fully opaque color.\n * For example, \"#123\" specifies the color that is represented by \"#112233\".\n *\n * The 6 digits specifies a fully opaque color.\n * For example, \"#112233\".\n *\n * @param {string} hex A string that contains the hexadecimal RGB color representation.\n * @return {[number, number, number]} The red, green, blue values in range [0, 255] .\n */\nexport const hexToRgb = (hex: ColorValueHex): [number, number, number] => {\n let color: string = hex.replace(\"#\", \"\");\n\n if (color.length === 3) {\n color = (color[0] as string) + (color[0] as string) + (color[1] as string) + (color[1] as string) + (color[2] as string) + (color[2] as string);\n } else if (color.length !== 6) {\n return [0, 0, 0];\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const number_ = Number.parseInt(color, 16);\n\n // eslint-disable-next-line no-bitwise\n return [(number_ >> 16) & 255, (number_ >> 8) & 255, number_ & 255];\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n/**\n * Replace all matched strings.\n * Note: this implementation is over 30% faster than String.replaceAll().\n */\nexport const stringReplaceAll = (string_: string, searchValue: string, replaceValue: string): string => {\n // visible style has empty open/close props\n if (searchValue === \"\") {\n return string_;\n }\n\n let pos = string_.indexOf(searchValue);\n if (pos < 0) {\n return string_;\n }\n\n const substringLength = searchValue.length;\n let lastPos = 0;\n let result = \"\";\n\n // eslint-disable-next-line no-loops/no-loops,no-bitwise\n while (~pos) {\n result += string_.slice(lastPos, pos) + replaceValue;\n lastPos = pos + substringLength;\n pos = string_.indexOf(searchValue, lastPos);\n }\n\n return result + string_.slice(lastPos);\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/index.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport ansiRegex from \"ansi-regex\";\n\nimport { baseColors, baseStyles, styleMethods } from \"./ansi-codes\";\nimport type { ColorData, ColorizeType } from \"./types\";\nimport { stringReplaceAll } from \"./util/string-replace-all\";\n\nconst styles: Record<string, object> = {};\n\nlet stylePrototype: object | null = null;\n\nconst wrapText = (\n strings: ArrayLike<string> | ReadonlyArray<string> | number | string | { raw: ArrayLike<string> | ReadonlyArray<string> },\n values: string[],\n properties: ColorizeProperties,\n) => {\n if (!strings) {\n return \"\";\n }\n\n let string =\n (strings as { raw?: ArrayLike<string> | ReadonlyArray<string> | null }).raw == null\n ? (((strings as number | string) + \"\") as string)\n : String.raw(strings as { raw: ArrayLike<string> | ReadonlyArray<string> }, ...values);\n\n if (string.includes(\"\\u001B\")) {\n // eslint-disable-next-line no-loops/no-loops,@typescript-eslint/no-unnecessary-condition\n for (let currentProperties = properties; currentProperties; currentProperties = currentProperties.props) {\n string = stringReplaceAll(string, currentProperties.close, currentProperties.open);\n }\n }\n\n if (string.includes(\"\\n\")) {\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n string = string.replace(/(\\r*\\n)/g, properties.closeStack + \"$1\" + properties.openStack);\n }\n\n return properties.openStack + string + properties.closeStack;\n};\n\ntype ColorizeProperties = { close: string; closeStack: string; open: string; openStack: string; props: ColorizeProperties };\n\nconst createStyle = (\n { props }: { props?: ColorizeProperties },\n { close, open }: ColorData,\n): {\n (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]): string;\n close: string;\n open: string;\n props: { close: string; closeStack: string; open: string; openStack: string; props?: ColorizeProperties };\n} => {\n const openStack: string = (props?.openStack ?? \"\") + open;\n const closeStack: string = close + (props?.closeStack ?? \"\");\n\n const style = (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]) => wrapText(strings, values, style.props);\n\n Object.setPrototypeOf(style, stylePrototype);\n\n style.props = { close, closeStack, open, openStack, props } as ColorizeProperties;\n style.open = openStack;\n style.close = closeStack;\n\n return style;\n};\n\n// eslint-disable-next-line func-names\nconst Colorize = function () {\n const self = (string_: number | string) => string_ + \"\";\n\n self.strip = (value: string): string => value.replaceAll(ansiRegex(), \"\");\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseColors) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n const style = createStyle(this, baseColors[name as keyof typeof baseColors]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseStyles) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n const style = createStyle(this, baseStyles[name as keyof typeof baseStyles]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // This needs to be the last thing we do, so that the prototype is fully populated.\n stylePrototype = Object.defineProperties({}, styles);\n\n Object.setPrototypeOf(self, stylePrototype);\n\n return self;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} as any as new () => ColorizeType;\n\n// eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\nfor (const name in styleMethods) {\n styles[name as keyof typeof styleMethods] = {\n get() {\n return (...arguments_: (number | string)[]) =>\n // @ts-expect-error: TODO: fix typing of `arguments_`\n\n createStyle(this, styleMethods[name as keyof typeof styleMethods](...arguments_));\n },\n };\n}\n\nstyles[\"ansi256\"] = styles[\"fg\"] as object;\nstyles[\"bgAnsi256\"] = styles[\"bg\"] as object;\n\n// eslint-disable-next-line import/no-default-export\nexport default Colorize;\n","/**\n * Modified copy of https://github.com/chalk/chalk-template/blob/main/index.js\n *\n * MIT License\n *\n * Copyright (c) Josh Junon\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n */\n\n// prettier-ignore\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const makeColorizeTemplate = (template: (text: string) => string): ((firstString: TemplateStringsArray, ...arguments_: any[]) => string) =>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (firstString: TemplateStringsArray, ...arguments_: any[]): string => {\n if (!Array.isArray(firstString) || !Array.isArray(firstString.raw)) {\n // If chalkTemplate() was called by itself or with a string\n throw new TypeError(\"A tagged template literal must be provided\");\n }\n\n const parts = [firstString.raw[0]];\n\n // eslint-disable-next-line no-loops/no-loops,no-plusplus\n for (let index = 1; index < firstString.raw.length; index++) {\n // eslint-disable-next-line security/detect-object-injection\n parts.push(String(arguments_[index - 1]).replaceAll(/[{}\\\\]/g, \"\\\\$&\"), String(firstString.raw[index]));\n }\n\n return template(parts.join(\"\"));\n };\n","/**\n * Modified copy of https://github.com/chalk/chalk-template/blob/main/index.js\n *\n * MIT License\n *\n * Copyright (c) Josh Junon\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n */\n\nconst ESCAPES = new Map([\n [\"\\\\\", \"\\\\\"],\n [\"0\", \"\\0\"],\n [\"a\", \"\\u0007\"],\n [\"b\", \"\\b\"],\n [\"e\", \"\\u001B\"],\n [\"f\", \"\\f\"],\n [\"n\", \"\\n\"],\n [\"r\", \"\\r\"],\n [\"t\", \"\\t\"],\n [\"v\", \"\\v\"],\n]);\n\nexport const unescape = (c: string): string => {\n const u = c.startsWith(\"u\");\n const bracket = c[1] === \"{\";\n\n if ((u && !bracket && c.length === 5) || (c.startsWith(\"x\") && c.length === 3)) {\n return String.fromCodePoint(Number.parseInt(c.slice(1), 16));\n }\n\n if (u && bracket) {\n return String.fromCodePoint(Number.parseInt(c.slice(2, -1), 16));\n }\n\n return ESCAPES.get(c) ?? c;\n};\n","/**\n * Modified copy of https://github.com/chalk/chalk-template/blob/main/index.js\n *\n * MIT License\n *\n * Copyright (c) Josh Junon\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n */\n\nimport type { ColorizeType, ColorValueHex } from \"../types\";\nimport { hexToRgb } from \"../util/hex-to-rgb\";\nimport { unescape } from \"../util/unescape\";\n\nconst TEMPLATE_REGEX =\n // eslint-disable-next-line security/detect-unsafe-regex,regexp/no-lazy-ends,regexp/no-dupe-disjunctions\n /\\\\(u(?:[a-f\\d]{4}|\\{[a-f\\d]{1,6}\\})|x[a-f\\d]{2}|.)|\\{(~)?(#?[\\w:]+(?:\\([^)]*\\))?(?:\\.#?[\\w:]+(?:\\([^)]*\\))?)*)(?:[ \\t]|(?=\\r?\\n))|(\\})|((?:.|[\\r\\n\\f])+?)/gi;\n// eslint-disable-next-line security/detect-unsafe-regex,regexp/optimal-lookaround-quantifier\nconst STYLE_REGEX = /(?:^|\\.)(?:(\\w+)(?:\\(([^)]*)\\))?|#(?=[:a-f\\d]{2,})([a-f\\d]{6})?(?::([a-f\\d]{6}))?)/gi;\nconst STRING_REGEX = /^(['\"])((?:\\\\.|(?!\\1)[^\\\\])*)\\1$/;\nconst ESCAPE_REGEX = /\\\\(u(?:[a-f\\d]{4}|\\{[a-f\\d]{1,6}\\})|x[a-f\\d]{2}|.)|([^\\\\])/gi;\n\nconst parseArguments = (name: string, value: string): (number | string)[] => {\n const results: (number | string)[] = [];\n const chunks = value.trim().split(/\\s*,\\s*/);\n\n let matches;\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const chunk of chunks) {\n const number = Number(chunk);\n\n if (!Number.isNaN(number)) {\n results.push(number);\n // eslint-disable-next-line no-cond-assign\n } else if ((matches = STRING_REGEX.exec(chunk))) {\n // eslint-disable-next-line unicorn/prefer-string-replace-all,@typescript-eslint/no-unsafe-return\n results.push((matches[2] as string).replace(ESCAPE_REGEX, (_, escape, character) => (escape ? unescape(escape as string) : character)));\n } else {\n throw new Error(`Invalid template style argument: ${chunk} (in style '${name}')`);\n }\n }\n\n return results;\n};\n\nconst parseStyle: (style: string) => (number | string | undefined)[][] = (style: string) => {\n STYLE_REGEX.lastIndex = 0;\n\n const results: (number | string | undefined)[][] = [];\n let matches;\n\n // eslint-disable-next-line no-loops/no-loops,no-cond-assign\n while ((matches = STYLE_REGEX.exec(style)) !== null) {\n const name = matches[1];\n\n if (matches[2]) {\n results.push([name, ...parseArguments(name as string, matches[2])]);\n } else if (matches[3] || matches[4]) {\n if (matches[3]) {\n results.push([\"rgb\", ...hexToRgb(matches[3] as ColorValueHex)]);\n }\n\n if (matches[4]) {\n results.push([\"bgRgb\", ...hexToRgb(matches[4] as ColorValueHex)]);\n }\n } else {\n results.push([name]);\n }\n }\n\n return results;\n};\n\nconst buildStyle = (\n colorize: ColorizeType,\n styles: {\n inverse: string | undefined;\n styles: (number | string | undefined)[][];\n }[],\n) => {\n const enabled: Record<string, (number | string | undefined)[] | null> = {};\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const layer of styles) {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const style of layer.styles) {\n enabled[style[0] as string] = layer.inverse ? null : style.slice(1);\n }\n }\n\n let current: ColorizeType = colorize;\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const [styleName, enabledStyles] of Object.entries(enabled)) {\n if (!Array.isArray(enabledStyles)) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (!(styleName in current)) {\n throw new Error(`Unknown style: ${styleName}`);\n }\n\n // @ts-expect-error - @TODO fix types\n\n current = enabledStyles.length > 0 ? current[styleName as keyof ColorizeType](...enabledStyles) : current[styleName as keyof ColorizeType];\n }\n\n return current;\n};\n\nexport const makeTemplate =\n (colorize: ColorizeType): ((string: string) => string) =>\n (string: string) => {\n const styles: {\n inverse: string | undefined;\n styles: (number | string | undefined)[][];\n }[] = [];\n const chunks = [];\n\n let chunk: string[] = [];\n\n string.replaceAll(\n TEMPLATE_REGEX,\n // @ts-expect-error - TS doesn't understand that the regex args are defined\n (\n _: string,\n escapeCharacter: string | undefined,\n inverse: string | undefined,\n style: string | undefined,\n close: string | undefined,\n character: string | undefined,\n ) => {\n if (escapeCharacter) {\n chunk.push(unescape(escapeCharacter) as string);\n } else if (style) {\n const joinedChunk = chunk.join(\"\");\n\n chunk = [];\n chunks.push(styles.length === 0 ? joinedChunk : buildStyle(colorize, styles)(joinedChunk));\n\n styles.push({ inverse, styles: parseStyle(style) });\n } else if (close) {\n if (styles.length === 0) {\n throw new Error(\"Found extraneous } in template literal\");\n }\n\n chunks.push(buildStyle(colorize, styles)(chunk.join(\"\")));\n chunk = [];\n\n styles.pop();\n } else {\n chunk.push(character as string);\n }\n },\n );\n\n chunks.push(chunk.join(\"\"));\n\n if (styles.length > 0) {\n throw new Error(`template literal is missing ${styles.length} closing bracket${styles.length === 1 ? \"\" : \"s\"} (\\`}\\`)`);\n }\n\n return chunks.join(\"\");\n };\n","import ColorizeImpl from \"./colorize.server\";\nimport { makeColorizeTemplate } from \"./template/make-colorize-template\";\nimport { makeTemplate } from \"./template/make-template\";\nimport type { ColorizeType } from \"./types\";\n\nconst colorize: ColorizeType = new ColorizeImpl() as ColorizeType;\n\n// eslint-disable-next-line import/no-unused-modules,@typescript-eslint/no-explicit-any\nexport const makeTaggedTemplate = (instance: ColorizeType): ((firstString: TemplateStringsArray, ...arguments_: any[]) => string) =>\n makeColorizeTemplate(makeTemplate(instance));\n\n// eslint-disable-next-line import/no-unused-modules\nexport const template = makeTemplate(colorize);\n\n// eslint-disable-next-line import/no-default-export\nexport default makeColorizeTemplate(template);\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
type ColorValueHex = `#${string}`;
|
|
2
|
+
interface ColorizeType {
|
|
3
|
+
(string: number | string): string;
|
|
4
|
+
(string: TemplateStringsArray, ...parameters: string[]): string;
|
|
5
|
+
ansi256: (code: number) => this;
|
|
6
|
+
bg: (code: number) => this;
|
|
7
|
+
bgAnsi256: (code: number) => this;
|
|
8
|
+
readonly bgBlack: this;
|
|
9
|
+
readonly bgBlackBright: this;
|
|
10
|
+
readonly bgBlue: this;
|
|
11
|
+
readonly bgBlueBright: this;
|
|
12
|
+
readonly bgCyan: this;
|
|
13
|
+
readonly bgCyanBright: this;
|
|
14
|
+
readonly bgGray: this;
|
|
15
|
+
readonly bgGreen: this;
|
|
16
|
+
readonly bgGreenBright: this;
|
|
17
|
+
readonly bgGrey: this;
|
|
18
|
+
bgHex: (color: ColorValueHex) => this;
|
|
19
|
+
readonly bgMagenta: this;
|
|
20
|
+
readonly bgMagentaBright: this;
|
|
21
|
+
readonly bgRed: this;
|
|
22
|
+
readonly bgRedBright: this;
|
|
23
|
+
bgRgb: (red: number, green: number, blue: number) => this;
|
|
24
|
+
readonly bgWhite: this;
|
|
25
|
+
readonly bgWhiteBright: this;
|
|
26
|
+
readonly bgYellow: this;
|
|
27
|
+
readonly bgYellowBright: this;
|
|
28
|
+
readonly black: this;
|
|
29
|
+
readonly blackBright: this;
|
|
30
|
+
readonly blue: this;
|
|
31
|
+
readonly blueBright: this;
|
|
32
|
+
readonly bold: this;
|
|
33
|
+
readonly close: string;
|
|
34
|
+
readonly cyan: this;
|
|
35
|
+
readonly cyanBright: this;
|
|
36
|
+
readonly dim: this;
|
|
37
|
+
fg: (code: number) => this;
|
|
38
|
+
readonly gray: this;
|
|
39
|
+
readonly green: this;
|
|
40
|
+
readonly greenBright: this;
|
|
41
|
+
readonly grey: this;
|
|
42
|
+
hex: (color: ColorValueHex) => this;
|
|
43
|
+
readonly hidden: this;
|
|
44
|
+
readonly inverse: this;
|
|
45
|
+
readonly italic: this;
|
|
46
|
+
readonly magenta: this;
|
|
47
|
+
readonly magentaBright: this;
|
|
48
|
+
readonly open: string;
|
|
49
|
+
readonly overline: this;
|
|
50
|
+
readonly red: this;
|
|
51
|
+
readonly redBright: this;
|
|
52
|
+
readonly reset: this;
|
|
53
|
+
rgb: (red: number, green: number, blue: number) => this;
|
|
54
|
+
readonly strike: this;
|
|
55
|
+
readonly strikethrough: this;
|
|
56
|
+
strip: (string: string) => string;
|
|
57
|
+
readonly underline: this;
|
|
58
|
+
readonly visible: this;
|
|
59
|
+
readonly white: this;
|
|
60
|
+
readonly whiteBright: this;
|
|
61
|
+
readonly yellow: this;
|
|
62
|
+
readonly yellowBright: this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare const makeTaggedTemplate: (instance: ColorizeType) => (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
|
|
66
|
+
declare const template: (string: string) => string;
|
|
67
|
+
declare const _default: (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
|
|
68
|
+
|
|
69
|
+
export { _default as default, makeTaggedTemplate, template };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
type ColorValueHex = `#${string}`;
|
|
2
|
+
interface ColorizeType {
|
|
3
|
+
(string: number | string): string;
|
|
4
|
+
(string: TemplateStringsArray, ...parameters: string[]): string;
|
|
5
|
+
ansi256: (code: number) => this;
|
|
6
|
+
bg: (code: number) => this;
|
|
7
|
+
bgAnsi256: (code: number) => this;
|
|
8
|
+
readonly bgBlack: this;
|
|
9
|
+
readonly bgBlackBright: this;
|
|
10
|
+
readonly bgBlue: this;
|
|
11
|
+
readonly bgBlueBright: this;
|
|
12
|
+
readonly bgCyan: this;
|
|
13
|
+
readonly bgCyanBright: this;
|
|
14
|
+
readonly bgGray: this;
|
|
15
|
+
readonly bgGreen: this;
|
|
16
|
+
readonly bgGreenBright: this;
|
|
17
|
+
readonly bgGrey: this;
|
|
18
|
+
bgHex: (color: ColorValueHex) => this;
|
|
19
|
+
readonly bgMagenta: this;
|
|
20
|
+
readonly bgMagentaBright: this;
|
|
21
|
+
readonly bgRed: this;
|
|
22
|
+
readonly bgRedBright: this;
|
|
23
|
+
bgRgb: (red: number, green: number, blue: number) => this;
|
|
24
|
+
readonly bgWhite: this;
|
|
25
|
+
readonly bgWhiteBright: this;
|
|
26
|
+
readonly bgYellow: this;
|
|
27
|
+
readonly bgYellowBright: this;
|
|
28
|
+
readonly black: this;
|
|
29
|
+
readonly blackBright: this;
|
|
30
|
+
readonly blue: this;
|
|
31
|
+
readonly blueBright: this;
|
|
32
|
+
readonly bold: this;
|
|
33
|
+
readonly close: string;
|
|
34
|
+
readonly cyan: this;
|
|
35
|
+
readonly cyanBright: this;
|
|
36
|
+
readonly dim: this;
|
|
37
|
+
fg: (code: number) => this;
|
|
38
|
+
readonly gray: this;
|
|
39
|
+
readonly green: this;
|
|
40
|
+
readonly greenBright: this;
|
|
41
|
+
readonly grey: this;
|
|
42
|
+
hex: (color: ColorValueHex) => this;
|
|
43
|
+
readonly hidden: this;
|
|
44
|
+
readonly inverse: this;
|
|
45
|
+
readonly italic: this;
|
|
46
|
+
readonly magenta: this;
|
|
47
|
+
readonly magentaBright: this;
|
|
48
|
+
readonly open: string;
|
|
49
|
+
readonly overline: this;
|
|
50
|
+
readonly red: this;
|
|
51
|
+
readonly redBright: this;
|
|
52
|
+
readonly reset: this;
|
|
53
|
+
rgb: (red: number, green: number, blue: number) => this;
|
|
54
|
+
readonly strike: this;
|
|
55
|
+
readonly strikethrough: this;
|
|
56
|
+
strip: (string: string) => string;
|
|
57
|
+
readonly underline: this;
|
|
58
|
+
readonly visible: this;
|
|
59
|
+
readonly white: this;
|
|
60
|
+
readonly whiteBright: this;
|
|
61
|
+
readonly yellow: this;
|
|
62
|
+
readonly yellowBright: this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare const makeTaggedTemplate: (instance: ColorizeType) => (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
|
|
66
|
+
declare const template: (string: string) => string;
|
|
67
|
+
declare const _default: (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
|
|
68
|
+
|
|
69
|
+
export { _default as default, makeTaggedTemplate, template };
|