mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
299 lines
24 KiB
JavaScript
299 lines
24 KiB
JavaScript
|
"use strict";
|
||
|
|
||
|
exports.__esModule = true;
|
||
|
exports.default = void 0;
|
||
|
|
||
|
var _supportsColor = _interopRequireDefault(require("supports-color"));
|
||
|
|
||
|
var _chalk = _interopRequireDefault(require("chalk"));
|
||
|
|
||
|
var _terminalHighlight = _interopRequireDefault(require("./terminal-highlight"));
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
||
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||
|
|
||
|
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
||
|
|
||
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
||
|
|
||
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
||
|
|
||
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||
|
|
||
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
||
|
|
||
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||
|
|
||
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||
|
|
||
|
/**
|
||
|
* The CSS parser throws this error for broken CSS.
|
||
|
*
|
||
|
* Custom parsers can throw this error for broken custom syntax using
|
||
|
* the {@link Node#error} method.
|
||
|
*
|
||
|
* PostCSS will use the input source map to detect the original error location.
|
||
|
* If you wrote a Sass file, compiled it to CSS and then parsed it with PostCSS,
|
||
|
* PostCSS will show the original position in the Sass file.
|
||
|
*
|
||
|
* If you need the position in the PostCSS input
|
||
|
* (e.g., to debug the previous compiler), use `error.input.file`.
|
||
|
*
|
||
|
* @example
|
||
|
* // Catching and checking syntax error
|
||
|
* try {
|
||
|
* postcss.parse('a{')
|
||
|
* } catch (error) {
|
||
|
* if (error.name === 'CssSyntaxError') {
|
||
|
* error //=> CssSyntaxError
|
||
|
* }
|
||
|
* }
|
||
|
*
|
||
|
* @example
|
||
|
* // Raising error from plugin
|
||
|
* throw node.error('Unknown variable', { plugin: 'postcss-vars' })
|
||
|
*/
|
||
|
var CssSyntaxError = /*#__PURE__*/function (_Error) {
|
||
|
_inheritsLoose(CssSyntaxError, _Error);
|
||
|
|
||
|
/**
|
||
|
* @param {string} message Error message.
|
||
|
* @param {number} [line] Source line of the error.
|
||
|
* @param {number} [column] Source column of the error.
|
||
|
* @param {string} [source] Source code of the broken file.
|
||
|
* @param {string} [file] Absolute path to the broken file.
|
||
|
* @param {string} [plugin] PostCSS plugin name, if error came from plugin.
|
||
|
*/
|
||
|
function CssSyntaxError(message, line, column, source, file, plugin) {
|
||
|
var _this;
|
||
|
|
||
|
_this = _Error.call(this, message) || this;
|
||
|
/**
|
||
|
* Always equal to `'CssSyntaxError'`. You should always check error type
|
||
|
* by `error.name === 'CssSyntaxError'`
|
||
|
* instead of `error instanceof CssSyntaxError`,
|
||
|
* because npm could have several PostCSS versions.
|
||
|
*
|
||
|
* @type {string}
|
||
|
*
|
||
|
* @example
|
||
|
* if (error.name === 'CssSyntaxError') {
|
||
|
* error //=> CssSyntaxError
|
||
|
* }
|
||
|
*/
|
||
|
|
||
|
_this.name = 'CssSyntaxError';
|
||
|
/**
|
||
|
* Error message.
|
||
|
*
|
||
|
* @type {string}
|
||
|
*
|
||
|
* @example
|
||
|
* error.message //=> 'Unclosed block'
|
||
|
*/
|
||
|
|
||
|
_this.reason = message;
|
||
|
|
||
|
if (file) {
|
||
|
/**
|
||
|
* Absolute path to the broken file.
|
||
|
*
|
||
|
* @type {string}
|
||
|
*
|
||
|
* @example
|
||
|
* error.file //=> 'a.sass'
|
||
|
* error.input.file //=> 'a.css'
|
||
|
*/
|
||
|
_this.file = file;
|
||
|
}
|
||
|
|
||
|
if (source) {
|
||
|
/**
|
||
|
* Source code of the broken file.
|
||
|
*
|
||
|
* @type {string}
|
||
|
*
|
||
|
* @example
|
||
|
* error.source //=> 'a { b {} }'
|
||
|
* error.input.column //=> 'a b { }'
|
||
|
*/
|
||
|
_this.source = source;
|
||
|
}
|
||
|
|
||
|
if (plugin) {
|
||
|
/**
|
||
|
* Plugin name, if error came from plugin.
|
||
|
*
|
||
|
* @type {string}
|
||
|
*
|
||
|
* @example
|
||
|
* error.plugin //=> 'postcss-vars'
|
||
|
*/
|
||
|
_this.plugin = plugin;
|
||
|
}
|
||
|
|
||
|
if (typeof line !== 'undefined' && typeof column !== 'undefined') {
|
||
|
/**
|
||
|
* Source line of the error.
|
||
|
*
|
||
|
* @type {number}
|
||
|
*
|
||
|
* @example
|
||
|
* error.line //=> 2
|
||
|
* error.input.line //=> 4
|
||
|
*/
|
||
|
_this.line = line;
|
||
|
/**
|
||
|
* Source column of the error.
|
||
|
*
|
||
|
* @type {number}
|
||
|
*
|
||
|
* @example
|
||
|
* error.column //=> 1
|
||
|
* error.input.column //=> 4
|
||
|
*/
|
||
|
|
||
|
_this.column = column;
|
||
|
}
|
||
|
|
||
|
_this.setMessage();
|
||
|
|
||
|
if (Error.captureStackTrace) {
|
||
|
Error.captureStackTrace(_assertThisInitialized(_this), CssSyntaxError);
|
||
|
}
|
||
|
|
||
|
return _this;
|
||
|
}
|
||
|
|
||
|
var _proto = CssSyntaxError.prototype;
|
||
|
|
||
|
_proto.setMessage = function setMessage() {
|
||
|
/**
|
||
|
* Full error text in the GNU error format
|
||
|
* with plugin, file, line and column.
|
||
|
*
|
||
|
* @type {string}
|
||
|
*
|
||
|
* @example
|
||
|
* error.message //=> 'a.css:1:1: Unclosed block'
|
||
|
*/
|
||
|
this.message = this.plugin ? this.plugin + ': ' : '';
|
||
|
this.message += this.file ? this.file : '<css input>';
|
||
|
|
||
|
if (typeof this.line !== 'undefined') {
|
||
|
this.message += ':' + this.line + ':' + this.column;
|
||
|
}
|
||
|
|
||
|
this.message += ': ' + this.reason;
|
||
|
}
|
||
|
/**
|
||
|
* Returns a few lines of CSS source that caused the error.
|
||
|
*
|
||
|
* If the CSS has an input source map without `sourceContent`,
|
||
|
* this method will return an empty string.
|
||
|
*
|
||
|
* @param {boolean} [color] Whether arrow will be colored red by terminal
|
||
|
* color codes. By default, PostCSS will detect
|
||
|
* color support by `process.stdout.isTTY`
|
||
|
* and `process.env.NODE_DISABLE_COLORS`.
|
||
|
*
|
||
|
* @example
|
||
|
* error.showSourceCode() //=> " 4 | }
|
||
|
* // 5 | a {
|
||
|
* // > 6 | bad
|
||
|
* // | ^
|
||
|
* // 7 | }
|
||
|
* // 8 | b {"
|
||
|
*
|
||
|
* @return {string} Few lines of CSS source that caused the error.
|
||
|
*/
|
||
|
;
|
||
|
|
||
|
_proto.showSourceCode = function showSourceCode(color) {
|
||
|
var _this2 = this;
|
||
|
|
||
|
if (!this.source) return '';
|
||
|
var css = this.source;
|
||
|
|
||
|
if (_terminalHighlight.default) {
|
||
|
if (typeof color === 'undefined') color = _supportsColor.default.stdout;
|
||
|
if (color) css = (0, _terminalHighlight.default)(css);
|
||
|
}
|
||
|
|
||
|
var lines = css.split(/\r?\n/);
|
||
|
var start = Math.max(this.line - 3, 0);
|
||
|
var end = Math.min(this.line + 2, lines.length);
|
||
|
var maxWidth = String(end).length;
|
||
|
|
||
|
function mark(text) {
|
||
|
if (color && _chalk.default.red) {
|
||
|
return _chalk.default.red.bold(text);
|
||
|
}
|
||
|
|
||
|
return text;
|
||
|
}
|
||
|
|
||
|
function aside(text) {
|
||
|
if (color && _chalk.default.gray) {
|
||
|
return _chalk.default.gray(text);
|
||
|
}
|
||
|
|
||
|
return text;
|
||
|
}
|
||
|
|
||
|
return lines.slice(start, end).map(function (line, index) {
|
||
|
var number = start + 1 + index;
|
||
|
var gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
|
||
|
|
||
|
if (number === _this2.line) {
|
||
|
var spacing = aside(gutter.replace(/\d/g, ' ')) + line.slice(0, _this2.column - 1).replace(/[^\t]/g, ' ');
|
||
|
return mark('>') + aside(gutter) + line + '\n ' + spacing + mark('^');
|
||
|
}
|
||
|
|
||
|
return ' ' + aside(gutter) + line;
|
||
|
}).join('\n');
|
||
|
}
|
||
|
/**
|
||
|
* Returns error position, message and source code of the broken part.
|
||
|
*
|
||
|
* @example
|
||
|
* error.toString() //=> "CssSyntaxError: app.css:1:1: Unclosed block
|
||
|
* // > 1 | a {
|
||
|
* // | ^"
|
||
|
*
|
||
|
* @return {string} Error position, message and source code.
|
||
|
*/
|
||
|
;
|
||
|
|
||
|
_proto.toString = function toString() {
|
||
|
var code = this.showSourceCode();
|
||
|
|
||
|
if (code) {
|
||
|
code = '\n\n' + code + '\n';
|
||
|
}
|
||
|
|
||
|
return this.name + ': ' + this.message + code;
|
||
|
}
|
||
|
/**
|
||
|
* @memberof CssSyntaxError#
|
||
|
* @member {Input} input Input object with PostCSS internal information
|
||
|
* about input file. If input has source map
|
||
|
* from previous tool, PostCSS will use origin
|
||
|
* (for example, Sass) source. You can use this
|
||
|
* object to get PostCSS input source.
|
||
|
*
|
||
|
* @example
|
||
|
* error.input.file //=> 'a.css'
|
||
|
* error.file //=> 'a.sass'
|
||
|
*/
|
||
|
;
|
||
|
|
||
|
return CssSyntaxError;
|
||
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
||
|
|
||
|
var _default = CssSyntaxError;
|
||
|
exports.default = _default;
|
||
|
module.exports = exports.default;
|
||
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNzcy1zeW50YXgtZXJyb3IuZXM2Il0sIm5hbWVzIjpbIkNzc1N5bnRheEVycm9yIiwibWVzc2FnZSIsImxpbmUiLCJjb2x1bW4iLCJzb3VyY2UiLCJmaWxlIiwicGx1Z2luIiwibmFtZSIsInJlYXNvbiIsInNldE1lc3NhZ2UiLCJFcnJvciIsImNhcHR1cmVTdGFja1RyYWNlIiwic2hvd1NvdXJjZUNvZGUiLCJjb2xvciIsImNzcyIsInRlcm1pbmFsSGlnaGxpZ2h0Iiwic3VwcG9ydHNDb2xvciIsInN0ZG91dCIsImxpbmVzIiwic3BsaXQiLCJzdGFydCIsIk1hdGgiLCJtYXgiLCJlbmQiLCJtaW4iLCJsZW5ndGgiLCJtYXhXaWR0aCIsIlN0cmluZyIsIm1hcmsiLCJ0ZXh0IiwiY2hhbGsiLCJyZWQiLCJib2xkIiwiYXNpZGUiLCJncmF5Iiwic2xpY2UiLCJtYXAiLCJpbmRleCIsIm51bWJlciIsImd1dHRlciIsInNwYWNpbmciLCJyZXBsYWNlIiwiam9pbiIsInRvU3RyaW5nIiwiY29kZSJdLCJtYXBwaW5ncyI6Ij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