|
"use strict";
|
|
|
|
exports.__esModule = true;
|
|
exports.default = void 0;
|
|
|
|
var _path = _interopRequireDefault(require("path"));
|
|
|
|
var _cssSyntaxError = _interopRequireDefault(require("./css-syntax-error"));
|
|
|
|
var _previousMap = _interopRequireDefault(require("./previous-map"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
var sequence = 0;
|
|
/**
|
|
* Represents the source CSS.
|
|
*
|
|
* @example
|
|
* const root = postcss.parse(css, { from: file })
|
|
* const input = root.source.input
|
|
*/
|
|
|
|
var Input =
|
|
/*#__PURE__*/
|
|
function () {
|
|
/**
|
|
* @param {string} css Input CSS source.
|
|
* @param {object} [opts] {@link Processor#process} options.
|
|
*/
|
|
function Input(css, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
|
|
if (css === null || typeof css === 'object' && !css.toString) {
|
|
throw new Error("PostCSS received " + css + " instead of CSS string");
|
|
}
|
|
/**
|
|
* Input CSS source
|
|
*
|
|
* @type {string}
|
|
*
|
|
* @example
|
|
* const input = postcss.parse('a{}', { from: file }).input
|
|
* input.css //=> "a{}"
|
|
*/
|
|
|
|
|
|
this.css = css.toString();
|
|
|
|
if (this.css[0] === "\uFEFF" || this.css[0] === "\uFFFE") {
|
|
this.hasBOM = true;
|
|
this.css = this.css.slice(1);
|
|
} else {
|
|
this.hasBOM = false;
|
|
}
|
|
|
|
if (opts.from) {
|
|
if (/^\w+:\/\//.test(opts.from)) {
|
|
/**
|
|
* The absolute path to the CSS source file defined
|
|
* with the `from` option.
|
|
*
|
|
* @type {string}
|
|
*
|
|
* @example
|
|
* const root = postcss.parse(css, { from: 'a.css' })
|
|
* root.source.input.file //=> '/home/ai/a.css'
|
|
*/
|
|
this.file = opts.from;
|
|
} else {
|
|
this.file = _path.default.resolve(opts.from);
|
|
}
|
|
}
|
|
|
|
var map = new _previousMap.default(this.css, opts);
|
|
|
|
if (map.text) {
|
|
/**
|
|
* The input source map passed from a compilation step before PostCSS
|
|
* (for example, from Sass compiler).
|
|
*
|
|
* @type {PreviousMap}
|
|
*
|
|
* @example
|
|
* root.source.input.map.consumer().sources //=> ['a.sass']
|
|
*/
|
|
this.map = map;
|
|
var file = map.consumer().file;
|
|
if (!this.file && file) this.file = this.mapResolve(file);
|
|
}
|
|
|
|
if (!this.file) {
|
|
sequence += 1;
|
|
/**
|
|
* The unique ID of the CSS source. It will be created if `from` option
|
|
* is not provided (because PostCSS does not know the file path).
|
|
*
|
|
* @type {string}
|
|
*
|
|
* @example
|
|
* const root = postcss.parse(css)
|
|
* root.source.input.file //=> undefined
|
|
* root.source.input.id //=> "<input css 1>"
|
|
*/
|
|
|
|
this.id = '<input css ' + sequence + '>';
|
|
}
|
|
|
|
if (this.map) this.map.file = this.from;
|
|
}
|
|
|
|
var _proto = Input.prototype;
|
|
|
|
_proto.error = function error(message, line, column, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
|
|
var result;
|
|
var origin = this.origin(line, column);
|
|
|
|
if (origin) {
|
|
result = new _cssSyntaxError.default(message, origin.line, origin.column, origin.source, origin.file, opts.plugin);
|
|
} else {
|
|
result = new _cssSyntaxError.default(message, line, column, this.css, this.file, opts.plugin);
|
|
}
|
|
|
|
result.input = {
|
|
line: line,
|
|
column: column,
|
|
source: this.css
|
|
};
|
|
if (this.file) result.input.file = this.file;
|
|
return result;
|
|
}
|
|
/**
|
|
* Reads the input source map and returns a symbol position
|
|
* in the input source (e.g., in a Sass file that was compiled
|
|
* to CSS before being passed to PostCSS).
|
|
*
|
|
* @param {number} line Line in input CSS.
|
|
* @param {number} column Column in input CSS.
|
|
*
|
|
* @return {filePosition} Position in input source.
|
|
*
|
|
* @example
|
|
* root.source.input.origin(1, 1) //=> { file: 'a.css', line: 3, column: 1 }
|
|
*/
|
|
;
|
|
|
|
_proto.origin = function origin(line, column) {
|
|
if (!this.map) return false;
|
|
var consumer = this.map.consumer();
|
|
var from = consumer.originalPositionFor({
|
|
line: line,
|
|
column: column
|
|
});
|
|
if (!from.source) return false;
|
|
var result = {
|
|
file: this.mapResolve(from.source),
|
|
line: from.line,
|
|
column: from.column
|
|
};
|
|
var source = consumer.sourceContentFor(from.source);
|
|
if (source) result.source = source;
|
|
return result;
|
|
};
|
|
|
|
_proto.mapResolve = function mapResolve(file) {
|
|
if (/^\w+:\/\//.test(file)) {
|
|
return file;
|
|
}
|
|
|
|
return _path.default.resolve(this.map.consumer().sourceRoot || '.', file);
|
|
}
|
|
/**
|
|
* The CSS source identifier. Contains {@link Input#file} if the user
|
|
* set the `from` option, or {@link Input#id} if they did not.
|
|
*
|
|
* @type {string}
|
|
*
|
|
* @example
|
|
* const root = postcss.parse(css, { from: 'a.css' })
|
|
* root.source.input.from //=> "/home/ai/a.css"
|
|
*
|
|
* const root = postcss.parse(css)
|
|
* root.source.input.from //=> "<input css 1>"
|
|
*/
|
|
;
|
|
|
|
_createClass(Input, [{
|
|
key: "from",
|
|
get: function get() {
|
|
return this.file || this.id;
|
|
}
|
|
}]);
|
|
|
|
return Input;
|
|
}();
|
|
|
|
var _default = Input;
|
|
/**
|
|
* @typedef {object} filePosition
|
|
* @property {string} file Path to file.
|
|
* @property {number} line Source line in file.
|
|
* @property {number} column Source column in file.
|
|
*/
|
|
|
|
exports.default = _default;
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImlucHV0LmVzNiJdLCJuYW1lcyI6WyJzZXF1ZW5jZSIsIklucHV0IiwiY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