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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNzcy1zeW50YXgtZXJyb3IuZXM2Il0sIm5hbWVzIjpbIkNzc1N5bnRheEVycm9yIiwibWVzc2FnZSIsImxpbmUiLCJjb2x1bW4iLCJzb3VyY2UiLCJmaWxlIiwicGx1Z2luIiwibmFtZSIsInJlYXNvbiIsInNldE1lc3NhZ2UiLCJFcnJvciIsImNhcHR1cmVTdGFja1RyYWNlIiwic2h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0+ICdhLmNzcydcbiAgICAgICAqL1xuICAgICAgdGhpcy5maWxlID0gZmlsZVxuICAgIH1cbiAgICBpZiAoc291cmNlKSB7XG4gICAgICAvKipcbiAgICAgICAqIFNvdXJjZSBjb2RlIG9mIHRoZSBicm9rZW4gZmlsZS5cbiAgICAgICAqXG4gICAgICAgKiBAdHlwZSB7c3RyaW5nfVxuICAgICAgICpcbiAgICAgICAqIEBleGFtcGxlXG4gICAgICAgKiBlcnJvci5zb3VyY2UgICAgICAgLy89PiAnYSB7IGIge30gfSdcbiAgICAgICAqIGVycm9yLmlucHV0LmNvbHVtbiAvLz0+ICdhIGIgeyB9J1xuICAgICAgICovXG4gICAgICB0aGlzLnNvdXJjZSA9IHNvdXJjZVxuICAgIH1cbiAgICBpZiAocGx1Z2luKSB7XG4gICAgICAvKipcbiAgICAgICAqIFBsdWdpbiBuYW1lLCBpZiBlcnJvciBjYW1lIGZyb20gcGx1Z2luLlxuICAgICAgICpcbiAgICAgICAqIEB0eXBlIHtzdHJpbmd9XG4gICAgICAgKlxuICAgICAgICogQGV4YW1wbGVcbiAgICAgICAqIGVycm9yLnBsdWdpbiAvLz0+ICdwb3N0Y3NzLXZhcnMnXG4gICAgICAgKi9cbiAgICAgIHRoaXMucGx1Z2luID0gcGx1Z2luXG4gICAgfVxuICAgIGlmICh0eXBlb2YgbGluZSAhPT0gJ3VuZGVmaW5lZCcgJiYgdHlwZW9mIGNvbHVtbiAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgIC8qKlxuICAgICAgICogU291cmNlIGxpbmUgb2YgdGhlIGVycm9yLlxuICAgICAgICpcbiAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgKlxuICAgICAgICogQGV4YW1wbGVcbiAgICAgICAqIGVycm9yLmxpbmUgICAgICAgLy89PiAyXG4gICAgICAgKiBlcnJvci5pbnB1dC5saW5lIC8vPT4gNFxuICAgICAgICovXG4gICAgICB0aGlzLmxpbmUgPSBsaW5lXG4gICAgIC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PSAnOiAnICsgdGhpcy5yZWFzb25cbiAgfVxuXG4gIC8qKlxuICAgKiBSZXR1cm5zIGEgZmV3IGxpbmVzIG9mIENTUyBzb3VyY2UgdGhhdCBjYXVzZWQgdGhlIGVycm9yLlxuICAgKlxuICAgKiBJZiB0aGUgQ1NTIGhhcyBhbiBpbnB1dCBzb3VyY2UgbWFwIHdpdGhvdXQgYHNvdXJjZUNvbnRlbnRgLFxuICAgKiB0aGlzIG1ldGhvZCB3aWxsIHJldHVybiBhbiBlbXB0eSBzdHJpbmcuXG4gICAqXG4gICAqIEBwYXJhbSB7Ym9vbGVhbn0gW2NvbG9yXSBXaGV0aGVyIGFycm93IHdpbGwgYmUgY29sb3JlZCByZWQgYnkgdGVybWluYWxcbiAgICogICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yIGNvZGVzLiBCeSBkZWZhdWx0LCBQb3N0Q1NTIHdpbGwgZGV0ZWN0XG4gICAqICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xvciBzdXBwb3J0IGJ5IGBwcm9jZXNzLnN0ZG91dC5pc1RUWWBcbiAgICogICAgICAgICAgICAgICAgICAgICAgICAgIGFuZCBgcHJvY2Vzcy5lbnYuTk9ERV9ESVNBQkxFX0NPTE9SU2AuXG4gICAqXG4gICAqIEBleGFtcGxlXG4gICAqIGVycm9yLnNob3dTb3VyY2VDb2RlKCkgLy89PiBcIiAgNCB8IH1cbiAgICogICAgICAgICAgICAgICAgICAgICAgICAvLyAgICAgIDUgfCBhIHtcbiAgICogICAgICAgICAgICAgICAgICAgICAgICAvLyAgICA+IDYgfCAgIGJhZFxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgICAgICB8ICAgXlxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgICAgNyB8IH1cbiAgICogICAgICAgICAgICAgICAgICAgICAgICAvLyAgICAgIDggfCBiIHtcIlxuICAgKlxuICAgKiBAcmV0dXJuIHtzdHJpbmd9IEZldyBsaW5lcyBv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