Opal-Estate-Pro/node_modules/autoprefixer/lib/info.js
2019-09-13 11:27:52 +07:00

114 lines
3.2 KiB
JavaScript

(function() {
var browserslist, capitalize, names, prefix;
browserslist = require('browserslist');
capitalize = function(str) {
return str.slice(0, 1).toUpperCase() + str.slice(1);
};
names = {
ie: 'IE',
ie_mob: 'IE Mobile',
ios_saf: 'iOS',
op_mini: 'Opera Mini',
op_mob: 'Opera Mobile',
and_chr: 'Chrome for Android',
and_ff: 'Firefox for Android',
and_uc: 'UC for Android'
};
prefix = function(name, prefixes) {
var out;
out = ' ' + name + ': ';
out += prefixes.map(function(i) {
return i.replace(/^-(.*)-$/g, '$1');
}).join(', ');
out += "\n";
return out;
};
module.exports = function(prefixes) {
var atrules, browser, coverage, data, j, k, l, len, len1, len2, list, name, out, props, ref, ref1, ref2, ref3, ref4, ref5, round, selector, selectors, string, value, values, version, versions;
if (prefixes.browsers.selected.length === 0) {
return "No browsers selected";
}
versions = [];
ref = prefixes.browsers.selected;
for (j = 0, len = ref.length; j < len; j++) {
browser = ref[j];
ref1 = browser.split(' '), name = ref1[0], version = ref1[1];
name = names[name] || capitalize(name);
if (versions[name]) {
versions[name].push(version);
} else {
versions[name] = [version];
}
}
out = "Browsers:\n";
for (browser in versions) {
list = versions[browser];
list = list.sort(function(a, b) {
return parseFloat(b) - parseFloat(a);
});
out += ' ' + browser + ': ' + list.join(', ') + "\n";
}
coverage = browserslist.coverage(prefixes.browsers.selected);
round = Math.round(coverage * 100) / 100.0;
out += "\nThese browsers account for " + round + "% of all users globally\n";
atrules = '';
ref2 = prefixes.add;
for (name in ref2) {
data = ref2[name];
if (name[0] === '@' && data.prefixes) {
atrules += prefix(name, data.prefixes);
}
}
if (atrules !== '') {
out += "\nAt-Rules:\n" + atrules;
}
selectors = '';
ref3 = prefixes.add.selectors;
for (k = 0, len1 = ref3.length; k < len1; k++) {
selector = ref3[k];
if (selector.prefixes) {
selectors += prefix(selector.name, selector.prefixes);
}
}
if (selectors !== '') {
out += "\nSelectors:\n" + selectors;
}
values = '';
props = '';
ref4 = prefixes.add;
for (name in ref4) {
data = ref4[name];
if (name[0] !== '@' && data.prefixes) {
props += prefix(name, data.prefixes);
}
if (!data.values) {
continue;
}
ref5 = data.values;
for (l = 0, len2 = ref5.length; l < len2; l++) {
value = ref5[l];
string = prefix(value.name, value.prefixes);
if (values.indexOf(string) === -1) {
values += string;
}
}
}
if (props !== '') {
out += "\nProperties:\n" + props;
}
if (values !== '') {
out += "\nValues:\n" + values;
}
if (atrules === '' && selectors === '' && props === '' && values === '') {
out += '\nAwesome! Your browsers don\'t require any vendor prefixes.' + '\nNow you can remove Autoprefixer from build steps.';
}
return out;
};
}).call(this);