1 line
9.2 KiB
JSON
1 line
9.2 KiB
JSON
{"ast":null,"code":"'use strict';\n\nfunction _createForOfIteratorHelper(o) { if (typeof Symbol === \"undefined\" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nvar escapeStringRegexp = require('escape-string-regexp');\n\nvar ansiStyles = require('ansi-styles');\n\nvar stdoutColor = require('supports-color').stdout;\n\nvar template = require('./templates.js');\n\nvar isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping\n\nvar levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such\n\nvar skipModels = new Set(['gray']);\nvar styles = Object.create(null);\n\nfunction applyOptions(obj, options) {\n options = options || {}; // Detect level if not set manually\n\n var scLevel = stdoutColor ? stdoutColor.level : 0;\n obj.level = options.level === undefined ? scLevel : options.level;\n obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;\n}\n\nfunction Chalk(options) {\n // We check for this.template here since calling `chalk.constructor()`\n // by itself will have a `this` of a previously constructed chalk object\n if (!this || !(this instanceof Chalk) || this.template) {\n var chalk = {};\n applyOptions(chalk, options);\n\n chalk.template = function () {\n var args = [].slice.call(arguments);\n return chalkTag.apply(null, [chalk.template].concat(args));\n };\n\n Object.setPrototypeOf(chalk, Chalk.prototype);\n Object.setPrototypeOf(chalk.template, chalk);\n chalk.template.constructor = Chalk;\n return chalk.template;\n }\n\n applyOptions(this, options);\n} // Use bright blue on Windows as the normal blue color is illegible\n\n\nif (isSimpleWindowsTerm) {\n ansiStyles.blue.open = \"\\x1B[94m\";\n}\n\nvar _loop = function _loop() {\n var key = _Object$keys[_i];\n ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');\n styles[key] = {\n get: function get() {\n var codes = ansiStyles[key];\n return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);\n }\n };\n};\n\nfor (var _i = 0, _Object$keys = Object.keys(ansiStyles); _i < _Object$keys.length; _i++) {\n _loop();\n}\n\nstyles.visible = {\n get: function get() {\n return build.call(this, this._styles || [], true, 'visible');\n }\n};\nansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');\n\nvar _loop2 = function _loop2() {\n var model = _Object$keys2[_i2];\n\n if (skipModels.has(model)) {\n return \"continue\";\n }\n\n styles[model] = {\n get: function get() {\n var level = this.level;\n return function () {\n var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);\n var codes = {\n open: open,\n close: ansiStyles.color.close,\n closeRe: ansiStyles.color.closeRe\n };\n return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);\n };\n }\n };\n};\n\nfor (var _i2 = 0, _Object$keys2 = Object.keys(ansiStyles.color.ansi); _i2 < _Object$keys2.length; _i2++) {\n var _ret = _loop2();\n\n if (_ret === \"continue\") continue;\n}\n\nansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');\n\nvar _loop3 = function _loop3() {\n var model = _Object$keys3[_i3];\n\n if (skipModels.has(model)) {\n return \"continue\";\n }\n\n var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);\n styles[bgModel] = {\n get: function get() {\n var level = this.level;\n return function () {\n var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);\n var codes = {\n open: open,\n close: ansiStyles.bgColor.close,\n closeRe: ansiStyles.bgColor.closeRe\n };\n return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);\n };\n }\n };\n};\n\nfor (var _i3 = 0, _Object$keys3 = Object.keys(ansiStyles.bgColor.ansi); _i3 < _Object$keys3.length; _i3++) {\n var _ret2 = _loop3();\n\n if (_ret2 === \"continue\") continue;\n}\n\nvar proto = Object.defineProperties(function () {}, styles);\n\nfunction build(_styles, _empty, key) {\n var builder = function builder() {\n return applyStyle.apply(builder, arguments);\n };\n\n builder._styles = _styles;\n builder._empty = _empty;\n var self = this;\n Object.defineProperty(builder, 'level', {\n enumerable: true,\n get: function get() {\n return self.level;\n },\n set: function set(level) {\n self.level = level;\n }\n });\n Object.defineProperty(builder, 'enabled', {\n enumerable: true,\n get: function get() {\n return self.enabled;\n },\n set: function set(enabled) {\n self.enabled = enabled;\n }\n }); // See below for fix regarding invisible grey/dim combination on Windows\n\n builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is\n // no way to create a function with a different prototype\n\n builder.__proto__ = proto; // eslint-disable-line no-proto\n\n return builder;\n}\n\nfunction applyStyle() {\n // Support varags, but simply cast to string in case there's only one arg\n var args = arguments;\n var argsLen = args.length;\n var str = String(arguments[0]);\n\n if (argsLen === 0) {\n return '';\n }\n\n if (argsLen > 1) {\n // Don't slice `arguments`, it prevents V8 optimizations\n for (var a = 1; a < argsLen; a++) {\n str += ' ' + args[a];\n }\n }\n\n if (!this.enabled || this.level <= 0 || !str) {\n return this._empty ? '' : str;\n } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,\n // see https://github.com/chalk/chalk/issues/58\n // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.\n\n\n var originalDim = ansiStyles.dim.open;\n\n if (isSimpleWindowsTerm && this.hasGrey) {\n ansiStyles.dim.open = '';\n }\n\n var _iterator = _createForOfIteratorHelper(this._styles.slice().reverse()),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var code = _step.value;\n // Replace any instances already present with a re-opening code\n // otherwise only the part of the string until said closing code\n // will be colored, and the rest will simply be 'plain'.\n str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen\n // after next line to fix a bleed issue on macOS\n // https://github.com/chalk/chalk/pull/92\n\n str = str.replace(/\\r?\\n/g, \"\".concat(code.close, \"$&\").concat(code.open));\n } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue\n\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n ansiStyles.dim.open = originalDim;\n return str;\n}\n\nfunction chalkTag(chalk, strings) {\n if (!Array.isArray(strings)) {\n // If chalk() was called by itself or with a string,\n // return the string itself as a string.\n return [].slice.call(arguments, 1).join(' ');\n }\n\n var args = [].slice.call(arguments, 2);\n var parts = [strings.raw[0]];\n\n for (var i = 1; i < strings.length; i++) {\n parts.push(String(args[i - 1]).replace(/[{}\\\\]/g, '\\\\$&'));\n parts.push(String(strings.raw[i]));\n }\n\n return template(chalk, parts.join(''));\n}\n\nObject.defineProperties(Chalk.prototype, styles);\nmodule.exports = Chalk(); // eslint-disable-line new-cap\n\nmodule.exports.supportsColor = stdoutColor;\nmodule.exports.default = module.exports; // For TypeScript","map":null,"metadata":{},"sourceType":"script"} |