3 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; };
5 var browserslist = require('browserslist');
6 var postcss = require('postcss');
8 var Browsers = require('./browsers');
9 var Prefixes = require('./prefixes');
11 function isPlainObject(obj) {
12 return Object.prototype.toString.apply(obj) === '[object Object]';
17 function timeCapsule(result, prefixes) {
18 if (prefixes.browsers.selected.length === 0) {
21 if (prefixes.add.selectors.length > 0) {
24 if (Object.keys(prefixes.add).length > 2) {
28 /* istanbul ignore next */
29 result.warn('Greetings, time traveller. ' + 'We are in the golden age of prefix-less CSS, ' + 'where Autoprefixer is no longer needed for your stylesheet.');
32 module.exports = postcss.plugin('autoprefixer', function () {
33 for (var _len = arguments.length, reqs = Array(_len), _key = 0; _key < _len; _key++) {
34 reqs[_key] = arguments[_key];
38 if (reqs.length === 1 && isPlainObject(reqs[0])) {
41 } else if (reqs.length === 0 || reqs.length === 1 && !reqs[0]) {
43 } else if (reqs.length <= 2 && (reqs[0] instanceof Array || !reqs[0])) {
46 } else if (_typeof(reqs[reqs.length - 1]) === 'object') {
54 if (options.browser) {
55 throw new Error('Change `browser` option to `browsers` in Autoprefixer');
56 } else if (options.browserslist) {
57 throw new Error('Change `browserslist` option to `browsers` in Autoprefixer');
60 if (options.browsers) {
61 reqs = options.browsers;
64 if (typeof options.grid === 'undefined') {
68 var loadPrefixes = function loadPrefixes(opts) {
69 var data = module.exports.data;
70 var browsers = new Browsers(data.browsers, reqs, opts, options.stats);
71 var key = browsers.selected.join(', ') + JSON.stringify(options);
74 cache[key] = new Prefixes(data.prefixes, browsers, options);
80 var plugin = function plugin(css, result) {
81 var prefixes = loadPrefixes({
82 from: css.source && css.source.input.file,
85 timeCapsule(result, prefixes);
86 if (options.remove !== false) {
87 prefixes.processor.remove(css, result);
89 if (options.add !== false) {
90 prefixes.processor.add(css, result);
94 plugin.options = options;
96 plugin.browsers = reqs;
98 plugin.info = function (opts) {
100 opts.from = opts.from || process.cwd();
102 return require('./info')(loadPrefixes(opts));
111 module.exports.data = {
112 browsers: require('caniuse-lite').agents,
113 prefixes: require('../data/prefixes')
117 * Autoprefixer default browsers
119 module.exports.defaults = browserslist.defaults;
122 * Inspect with default Autoprefixer
124 module.exports.info = function () {
125 return module.exports().info();