PromoCursed/node_modules/.cache/babel-loader/b8f7971f3ac6e26854982298de1a1f4c54601dcf173640f6dfcf93da2d16a6e3.json

1 line
14 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"'use strict';\n\nmodule.exports = ansiHTML;\n\n// Reference to https://github.com/sindresorhus/ansi-regex\nvar _regANSI = /(?:(?:\\u001b\\[)|\\u009b)(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\\u001b[A-M]/;\nvar _defColors = {\n reset: ['fff', '000'],\n // [FOREGROUD_COLOR, BACKGROUND_COLOR]\n black: '000',\n red: 'ff0000',\n green: '209805',\n yellow: 'e8bf03',\n blue: '0000ff',\n magenta: 'ff00ff',\n cyan: '00ffee',\n lightgrey: 'f0f0f0',\n darkgrey: '888'\n};\nvar _styles = {\n 30: 'black',\n 31: 'red',\n 32: 'green',\n 33: 'yellow',\n 34: 'blue',\n 35: 'magenta',\n 36: 'cyan',\n 37: 'lightgrey'\n};\nvar _openTags = {\n '1': 'font-weight:bold',\n // bold\n '2': 'opacity:0.5',\n // dim\n '3': '<i>',\n // italic\n '4': '<u>',\n // underscore\n '8': 'display:none',\n // hidden\n '9': '<del>' // delete\n};\nvar _closeTags = {\n '23': '</i>',\n // reset italic\n '24': '</u>',\n // reset underscore\n '29': '</del>' // reset delete\n};\n[0, 21, 22, 27, 28, 39, 49].forEach(function (n) {\n _closeTags[n] = '</span>';\n});\n\n/**\n * Converts text with ANSI color codes to HTML markup.\n * @param {String} text\n * @returns {*}\n */\nfunction ansiHTML(text) {\n // Returns the text if the string has no ANSI escape code.\n if (!_regANSI.test(text)) {\n return text;\n }\n\n // Cache opened sequence.\n var ansiCodes = [];\n // Replace with markup.\n var ret = text.replace(/\\033\\[(\\d+)m/g, function (match, seq) {\n var ot = _openTags[seq];\n if (ot) {\n // If current sequence has been opened, close it.\n if (!!~ansiCodes.indexOf(seq)) {\n // eslint-disable-line no-extra-boolean-cast\n ansiCodes.pop();\n return '</span>';\n }\n // Open tag.\n ansiCodes.push(seq);\n return ot[0] === '<' ? ot : '<span style=\"' + ot + ';\">';\n }\n var ct = _closeTags[seq];\n if (ct) {\n // Pop sequence\n ansiCodes.pop();\n return ct;\n }\n return '';\n });\n\n // Make sure tags are closed.\n var l = ansiCodes.length;\n l > 0 && (ret += Array(l + 1).join('</span>'));\n return ret;\n}\n\n/**\n * Customize colors.\n * @param {Object} colors reference to _defColors\n */\nansiHTML.setColors = function (colors) {\n if (typeof colors !== 'object') {\n throw new Error('`colors` parameter must be an Object.');\n }\n var _finalColors = {};\n for (var key in _defColors) {\n var hex = colors.hasOwnProperty(key) ? colors[key] : null;\n if (!hex) {\n _finalColors[key] = _defColors[key];\n continue;\n }\n if ('reset' === key) {\n if (typeof hex === 'string') {\n hex = [hex];\n }\n if (!Array.isArray(hex) || hex.length === 0 || hex.some(function (h) {\n return typeof h !== 'string';\n })) {\n throw new Error('The value of `' + key + '` property must be an Array and each item could only be a hex string, e.g.: FF0000');\n }\n var defHexColor = _defColors[key];\n if (!hex[0]) {\n hex[0] = defHexColor[0];\n }\n if (hex.length === 1 || !hex[1]) {\n hex = [hex[0]];\n hex.push(defHexColor[1]);\n }\n hex = hex.slice(0, 2);\n } else if (typeof hex !== 'string') {\n throw new Error('The value of `' + key + '` property must be a hex string, e.g.: FF0000');\n }\n _finalColors[key] = hex;\n }\n _setTags(_finalColors);\n};\n\n/**\n * Reset colors.\n */\nansiHTML.reset = function () {\n _setTags(_defColors);\n};\n\n/**\n * Expose tags, including open and close.\n * @type {Object}\n */\nansiHTML.tags = {};\nif (Object.defineProperty) {\n Object.defineProperty(ansiHTML.tags, 'open', {\n get: function () {\n return _openTags;\n }\n });\n Object.defineProperty(ansiHTML.tags, 'close', {\n get: function () {\n return _closeTags;\n }\n });\n} else {\n ansiHTML.tags.open = _openTags;\n ansiHTML.tags.close = _closeTags;\n}\nfunction _setTags(colors) {\n // reset all\n _openTags['0'] = 'font-weight:normal;opacity:1;color:#' + colors.reset[0] + ';background:#