123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- 'use strict';
- exports.__esModule = true;
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- var _lazyResult = require('./lazy-result');
- var _lazyResult2 = _interopRequireDefault(_lazyResult);
- 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 Processor = function () {
-
- function Processor() {
- var plugins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- _classCallCheck(this, Processor);
-
- this.version = '6.0.23';
-
- this.plugins = this.normalize(plugins);
- }
-
- Processor.prototype.use = function use(plugin) {
- this.plugins = this.plugins.concat(this.normalize([plugin]));
- return this;
- };
-
- Processor.prototype.process = function process(css) {
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- return new _lazyResult2.default(this, css, opts);
- };
- Processor.prototype.normalize = function normalize(plugins) {
- var normalized = [];
- for (var _iterator = plugins, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
- var _ref;
- if (_isArray) {
- if (_i >= _iterator.length) break;
- _ref = _iterator[_i++];
- } else {
- _i = _iterator.next();
- if (_i.done) break;
- _ref = _i.value;
- }
- var i = _ref;
- if (i.postcss) i = i.postcss;
- if ((typeof i === 'undefined' ? 'undefined' : _typeof(i)) === 'object' && Array.isArray(i.plugins)) {
- normalized = normalized.concat(i.plugins);
- } else if (typeof i === 'function') {
- normalized.push(i);
- } else if ((typeof i === 'undefined' ? 'undefined' : _typeof(i)) === 'object' && (i.parse || i.stringify)) {
- throw new Error('PostCSS syntaxes cannot be used as plugins. ' + 'Instead, please use one of the ' + 'syntax/parser/stringifier options as ' + 'outlined in your PostCSS ' + 'runner documentation.');
- } else {
- throw new Error(i + ' is not a PostCSS plugin');
- }
- }
- return normalized;
- };
- return Processor;
- }();
- exports.default = Processor;
- module.exports = exports['default'];
|