217 lines
17 KiB
JavaScript
217 lines
17 KiB
JavaScript
"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) || _path.default.isAbsolute(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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImlucH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