hexo/node_modules/scss-tokenizer/lib/input.js

64 lines
2.3 KiB
JavaScript
Raw Normal View History

2023-10-03 11:14:36 +08:00
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _previousMap = require('./previous-map');
var _previousMap2 = _interopRequireDefault(_previousMap);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var sequence = 0;
var Input = function () {
function Input(css) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, Input);
this.css = css.toString();
if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
this.css = this.css.slice(1);
}
if (opts.from) this.file = _path2.default.resolve(opts.from);
var map = new _previousMap2.default(this.css, opts, this.id);
if (map.text) {
this.map = map;
var file = map.consumer().file;
if (!this.file && file) this.file = this.mapResolve(file);
}
if (this.file) {
this.from = this.file;
} else {
sequence += 1;
this.id = '<input css ' + sequence + '>';
this.from = this.id;
}
if (this.map) this.map.file = this.from;
}
_createClass(Input, [{
key: 'mapResolve',
value: function mapResolve(file) {
return _path2.default.resolve(this.map.consumer().sourceRoot || '.', file);
}
}]);
return Input;
}();
2023-09-25 15:58:56 +08:00
exports.default = Input;