Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,68 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Prefixer = require('./prefixer');
var AtRule = function (_Prefixer) {
_inherits(AtRule, _Prefixer);
function AtRule() {
_classCallCheck(this, AtRule);
return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
}
/**
* Clone and add prefixes for at-rule
*/
AtRule.prototype.add = function add(rule, prefix) {
var prefixed = prefix + rule.name;
var already = rule.parent.some(function (i) {
return i.name === prefixed && i.params === rule.params;
});
if (already) {
return undefined;
}
var cloned = this.clone(rule, { name: prefixed });
return rule.parent.insertBefore(rule, cloned);
};
/**
* Clone node with prefixes
*/
AtRule.prototype.process = function process(node) {
var parent = this.parentPrefix(node);
for (var _iterator = this.prefixes, _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 prefix = _ref;
if (!parent || parent === prefix) {
this.add(node, prefix);
}
}
};
return AtRule;
}(Prefixer);
module.exports = AtRule;

View File

@@ -0,0 +1,120 @@
'use strict';
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 browserslist = require('browserslist');
var postcss = require('postcss');
var Browsers = require('./browsers');
var Prefixes = require('./prefixes');
function isPlainObject(obj) {
return Object.prototype.toString.apply(obj) === '[object Object]';
}
var cache = {};
function timeCapsule(result, prefixes) {
if (prefixes.browsers.selected.length === 0) {
return;
}
if (prefixes.add.selectors.length > 0) {
return;
}
if (Object.keys(prefixes.add).length > 2) {
return;
}
result.warn('Greetings, time traveller. ' + 'We are in the golden age of prefix-less CSS, ' + 'where Autoprefixer is no longer needed for your stylesheet.');
}
module.exports = postcss.plugin('autoprefixer', function () {
for (var _len = arguments.length, reqs = Array(_len), _key = 0; _key < _len; _key++) {
reqs[_key] = arguments[_key];
}
var options = void 0;
if (reqs.length === 1 && isPlainObject(reqs[0])) {
options = reqs[0];
reqs = undefined;
} else if (reqs.length === 0 || reqs.length === 1 && !reqs[0]) {
reqs = undefined;
} else if (reqs.length <= 2 && (reqs[0] instanceof Array || !reqs[0])) {
options = reqs[1];
reqs = reqs[0];
} else if (_typeof(reqs[reqs.length - 1]) === 'object') {
options = reqs.pop();
}
if (!options) {
options = {};
}
if (options.browser) {
throw new Error('Change `browser` option to `browsers` in Autoprefixer');
} else if (options.browserslist) {
throw new Error('Change `browserslist` option to `browsers` in Autoprefixer');
}
if (options.browsers) {
reqs = options.browsers;
}
if (typeof options.grid === 'undefined') {
options.grid = false;
}
var loadPrefixes = function loadPrefixes(opts) {
var data = module.exports.data;
var browsers = new Browsers(data.browsers, reqs, opts, options.stats);
var key = browsers.selected.join(', ') + JSON.stringify(options);
if (!cache[key]) {
cache[key] = new Prefixes(data.prefixes, browsers, options);
}
return cache[key];
};
var plugin = function plugin(css, result) {
var prefixes = loadPrefixes({
from: css.source && css.source.input.file,
env: options.env
});
timeCapsule(result, prefixes);
if (options.remove !== false) {
prefixes.processor.remove(css, result);
}
if (options.add !== false) {
prefixes.processor.add(css, result);
}
};
plugin.options = options;
plugin.info = function (opts) {
return require('./info')(loadPrefixes(opts));
};
return plugin;
});
/**
* Autoprefixer data
*/
module.exports.data = {
browsers: require('caniuse-lite').agents,
prefixes: require('../data/prefixes')
};
/**
* Autoprefixer default browsers
*/
module.exports.defaults = browserslist.defaults;
/**
* Inspect with default Autoprefixer
*/
module.exports.info = function () {
return module.exports().info();
};

View File

@@ -0,0 +1,71 @@
'use strict';
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 last = function last(array) {
return array[array.length - 1];
};
var brackets = {
/**
* Parse string to nodes tree
*/
parse: function parse(str) {
var current = [''];
var stack = [current];
for (var i = 0; i < str.length; i++) {
var sym = str[i];
if (sym === '(') {
current = [''];
last(stack).push(current);
stack.push(current);
continue;
}
if (sym === ')') {
stack.pop();
current = last(stack);
current.push('');
continue;
}
current[current.length - 1] += sym;
}
return stack[0];
},
/**
* Generate output string by nodes tree
*/
stringify: function stringify(ast) {
var result = '';
for (var _iterator = ast, _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 ((typeof i === 'undefined' ? 'undefined' : _typeof(i)) === 'object') {
result += '(' + brackets.stringify(i) + ')';
continue;
}
result += i;
}
return result;
}
};
module.exports = brackets;

View File

@@ -0,0 +1,123 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var browserslist = require('browserslist');
var utils = require('./utils');
var Browsers = function () {
/**
* Return all prefixes for default browser data
*/
Browsers.prefixes = function prefixes() {
if (this.prefixesCache) {
return this.prefixesCache;
}
var data = require('caniuse-lite').agents;
this.prefixesCache = [];
for (var name in data) {
this.prefixesCache.push('-' + data[name].prefix + '-');
}
this.prefixesCache = utils.uniq(this.prefixesCache).sort(function (a, b) {
return b.length - a.length;
});
return this.prefixesCache;
};
/**
* Check is value contain any possibe prefix
*/
Browsers.withPrefix = function withPrefix(value) {
if (!this.prefixesRegexp) {
this.prefixesRegexp = new RegExp(this.prefixes().join('|'));
}
return this.prefixesRegexp.test(value);
};
function Browsers(data, requirements, options, stats) {
_classCallCheck(this, Browsers);
this.data = data;
this.options = options || {};
this.stats = stats;
this.selected = this.parse(requirements);
}
/**
* Return browsers selected by requirements
*/
Browsers.prototype.parse = function parse(requirements) {
return browserslist(requirements, {
stats: this.stats,
path: this.options.from,
env: this.options.env
});
};
/**
* Select major browsers versions by criteria
*/
Browsers.prototype.browsers = function browsers(criteria) {
var _this = this;
var selected = [];
var _loop = function _loop(browser) {
var data = _this.data[browser];
var versions = criteria(data).map(function (version) {
return browser + ' ' + version;
});
selected = selected.concat(versions);
};
for (var browser in this.data) {
_loop(browser);
}
return selected;
};
/**
* Return prefix for selected browser
*/
Browsers.prototype.prefix = function prefix(browser) {
var _browser$split = browser.split(' '),
name = _browser$split[0],
version = _browser$split[1];
var data = this.data[name];
var prefix = data.prefix_exceptions && data.prefix_exceptions[version];
if (!prefix) {
prefix = data.prefix;
}
return '-' + prefix + '-';
};
/**
* Is browser is selected by requirements
*/
Browsers.prototype.isSelected = function isSelected(browser) {
return this.selected.indexOf(browser) !== -1;
};
return Browsers;
}();
module.exports = Browsers;

View File

@@ -0,0 +1,259 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Prefixer = require('./prefixer');
var Browsers = require('./browsers');
var utils = require('./utils');
var Declaration = function (_Prefixer) {
_inherits(Declaration, _Prefixer);
function Declaration() {
_classCallCheck(this, Declaration);
return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
}
/**
* Always true, because we already get prefixer by property name
*/
Declaration.prototype.check = function check() /* decl */{
return true;
};
/**
* Return prefixed version of property
*/
Declaration.prototype.prefixed = function prefixed(prop, prefix) {
return prefix + prop;
};
/**
* Return unprefixed version of property
*/
Declaration.prototype.normalize = function normalize(prop) {
return prop;
};
/**
* Check `value`, that it contain other prefixes, rather than `prefix`
*/
Declaration.prototype.otherPrefixes = function otherPrefixes(value, prefix) {
for (var _iterator = Browsers.prefixes(), _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 other = _ref;
if (other === prefix) {
continue;
}
if (value.indexOf(other) !== -1) {
return true;
}
}
return false;
};
/**
* Set prefix to declaration
*/
Declaration.prototype.set = function set(decl, prefix) {
decl.prop = this.prefixed(decl.prop, prefix);
return decl;
};
/**
* Should we use visual cascade for prefixes
*/
Declaration.prototype.needCascade = function needCascade(decl) {
if (!decl._autoprefixerCascade) {
decl._autoprefixerCascade = this.all.options.cascade !== false && decl.raw('before').indexOf('\n') !== -1;
}
return decl._autoprefixerCascade;
};
/**
* Return maximum length of possible prefixed property
*/
Declaration.prototype.maxPrefixed = function maxPrefixed(prefixes, decl) {
if (decl._autoprefixerMax) {
return decl._autoprefixerMax;
}
var max = 0;
for (var _iterator2 = prefixes, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var prefix = _ref2;
prefix = utils.removeNote(prefix);
if (prefix.length > max) {
max = prefix.length;
}
}
decl._autoprefixerMax = max;
return decl._autoprefixerMax;
};
/**
* Calculate indentation to create visual cascade
*/
Declaration.prototype.calcBefore = function calcBefore(prefixes, decl) {
var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var max = this.maxPrefixed(prefixes, decl);
var diff = max - utils.removeNote(prefix).length;
var before = decl.raw('before');
if (diff > 0) {
before += Array(diff).fill(' ').join('');
}
return before;
};
/**
* Remove visual cascade
*/
Declaration.prototype.restoreBefore = function restoreBefore(decl) {
var lines = decl.raw('before').split('\n');
var min = lines[lines.length - 1];
this.all.group(decl).up(function (prefixed) {
var array = prefixed.raw('before').split('\n');
var last = array[array.length - 1];
if (last.length < min.length) {
min = last;
}
});
lines[lines.length - 1] = min;
decl.raws.before = lines.join('\n');
};
/**
* Clone and insert new declaration
*/
Declaration.prototype.insert = function insert(decl, prefix, prefixes) {
var cloned = this.set(this.clone(decl), prefix);
if (!cloned) return undefined;
var already = decl.parent.some(function (i) {
return i.prop === cloned.prop && i.value === cloned.value;
});
if (already) {
return undefined;
}
if (this.needCascade(decl)) {
cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
}
return decl.parent.insertBefore(decl, cloned);
};
/**
* Did this declaration has this prefix above
*/
Declaration.prototype.isAlready = function isAlready(decl, prefixed) {
var already = this.all.group(decl).up(function (i) {
return i.prop === prefixed;
});
if (!already) {
already = this.all.group(decl).down(function (i) {
return i.prop === prefixed;
});
}
return already;
};
/**
* Clone and add prefixes for declaration
*/
Declaration.prototype.add = function add(decl, prefix, prefixes) {
var prefixed = this.prefixed(decl.prop, prefix);
if (this.isAlready(decl, prefixed) || this.otherPrefixes(decl.value, prefix)) {
return undefined;
}
return this.insert(decl, prefix, prefixes);
};
/**
* Add spaces for visual cascade
*/
Declaration.prototype.process = function process(decl) {
if (!this.needCascade(decl)) {
_Prefixer.prototype.process.call(this, decl);
return;
}
var prefixes = _Prefixer.prototype.process.call(this, decl);
if (!prefixes || !prefixes.length) {
return;
}
this.restoreBefore(decl);
decl.raws.before = this.calcBefore(prefixes, decl);
};
/**
* Return list of prefixed properties to clean old prefixes
*/
Declaration.prototype.old = function old(prop, prefix) {
return [this.prefixed(prop, prefix)];
};
return Declaration;
}(Prefixer);
module.exports = Declaration;

View File

@@ -0,0 +1,84 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var AlignContent = function (_Declaration) {
_inherits(AlignContent, _Declaration);
function AlignContent() {
_classCallCheck(this, AlignContent);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Change property name for 2012 spec
*/
AlignContent.prototype.prefixed = function prefixed(prop, prefix) {
var spec = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec === 2012) {
return prefix + 'flex-line-pack';
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Return property name by final spec
*/
AlignContent.prototype.normalize = function normalize() {
return 'align-content';
};
/**
* Change value for 2012 spec and ignore prefix for 2009
*/
AlignContent.prototype.set = function set(decl, prefix) {
var spec = flexSpec(prefix)[0];
if (spec === 2012) {
decl.value = AlignContent.oldValues[decl.value] || decl.value;
return _Declaration.prototype.set.call(this, decl, prefix);
} else if (spec === 'final') {
return _Declaration.prototype.set.call(this, decl, prefix);
}
return undefined;
};
return AlignContent;
}(Declaration);
Object.defineProperty(AlignContent, 'names', {
enumerable: true,
writable: true,
value: ['align-content', 'flex-line-pack']
});
Object.defineProperty(AlignContent, 'oldValues', {
enumerable: true,
writable: true,
value: {
'flex-end': 'end',
'flex-start': 'start',
'space-between': 'justify',
'space-around': 'distribute'
}
});
module.exports = AlignContent;

View File

@@ -0,0 +1,81 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var AlignItems = function (_Declaration) {
_inherits(AlignItems, _Declaration);
function AlignItems() {
_classCallCheck(this, AlignItems);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Change property name for 2009 and 2012 specs
*/
AlignItems.prototype.prefixed = function prefixed(prop, prefix) {
var spec = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec === 2009) {
return prefix + 'box-align';
} else if (spec === 2012) {
return prefix + 'flex-align';
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Return property name by final spec
*/
AlignItems.prototype.normalize = function normalize() {
return 'align-items';
};
/**
* Change value for 2009 and 2012 specs
*/
AlignItems.prototype.set = function set(decl, prefix) {
var spec = flexSpec(prefix)[0];
if (spec === 2009 || spec === 2012) {
decl.value = AlignItems.oldValues[decl.value] || decl.value;
}
return _Declaration.prototype.set.call(this, decl, prefix);
};
return AlignItems;
}(Declaration);
Object.defineProperty(AlignItems, 'names', {
enumerable: true,
writable: true,
value: ['align-items', 'flex-align', 'box-align']
});
Object.defineProperty(AlignItems, 'oldValues', {
enumerable: true,
writable: true,
value: {
'flex-end': 'end',
'flex-start': 'start'
}
});
module.exports = AlignItems;

View File

@@ -0,0 +1,82 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var AlignSelf = function (_Declaration) {
_inherits(AlignSelf, _Declaration);
function AlignSelf() {
_classCallCheck(this, AlignSelf);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Change property name for 2012 specs
*/
AlignSelf.prototype.prefixed = function prefixed(prop, prefix) {
var spec = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec === 2012) {
return prefix + 'flex-item-align';
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Return property name by final spec
*/
AlignSelf.prototype.normalize = function normalize() {
return 'align-self';
};
/**
* Change value for 2012 spec and ignore prefix for 2009
*/
AlignSelf.prototype.set = function set(decl, prefix) {
var spec = flexSpec(prefix)[0];
if (spec === 2012) {
decl.value = AlignSelf.oldValues[decl.value] || decl.value;
return _Declaration.prototype.set.call(this, decl, prefix);
} else if (spec === 'final') {
return _Declaration.prototype.set.call(this, decl, prefix);
}
return undefined;
};
return AlignSelf;
}(Declaration);
Object.defineProperty(AlignSelf, 'names', {
enumerable: true,
writable: true,
value: ['align-self', 'flex-item-align']
});
Object.defineProperty(AlignSelf, 'oldValues', {
enumerable: true,
writable: true,
value: {
'flex-end': 'end',
'flex-start': 'start'
}
});
module.exports = AlignSelf;

View File

@@ -0,0 +1,42 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var utils = require('../utils');
var Appearance = function (_Declaration) {
_inherits(Appearance, _Declaration);
function Appearance(name, prefixes, all) {
_classCallCheck(this, Appearance);
var _this = _possibleConstructorReturn(this, _Declaration.call(this, name, prefixes, all));
if (_this.prefixes) {
_this.prefixes = utils.uniq(_this.prefixes.map(function (i) {
if (i === '-ms-') {
return '-webkit-';
} else {
return i;
}
}));
}
return _this;
}
return Appearance;
}(Declaration);
Object.defineProperty(Appearance, 'names', {
enumerable: true,
writable: true,
value: ['appearance']
});
module.exports = Appearance;

View File

@@ -0,0 +1,41 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var BackgroundSize = function (_Declaration) {
_inherits(BackgroundSize, _Declaration);
function BackgroundSize() {
_classCallCheck(this, BackgroundSize);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Duplication parameter for -webkit- browsers
*/
BackgroundSize.prototype.set = function set(decl, prefix) {
var value = decl.value.toLowerCase();
if (prefix === '-webkit-' && value.indexOf(' ') === -1 && value !== 'contain' && value !== 'cover') {
decl.value = decl.value + ' ' + decl.value;
}
return _Declaration.prototype.set.call(this, decl, prefix);
};
return BackgroundSize;
}(Declaration);
Object.defineProperty(BackgroundSize, 'names', {
enumerable: true,
writable: true,
value: ['background-size']
});
module.exports = BackgroundSize;

View File

@@ -0,0 +1,50 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var BlockLogical = function (_Declaration) {
_inherits(BlockLogical, _Declaration);
function BlockLogical() {
_classCallCheck(this, BlockLogical);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Use old syntax for -moz- and -webkit-
*/
BlockLogical.prototype.prefixed = function prefixed(prop, prefix) {
return prefix + (prop.indexOf('-start') !== -1 ? prop.replace('-block-start', '-before') : prop.replace('-block-end', '-after'));
};
/**
* Return property name by spec
*/
BlockLogical.prototype.normalize = function normalize(prop) {
if (prop.indexOf('-before') !== -1) {
return prop.replace('-before', '-block-start');
} else {
return prop.replace('-after', '-block-end');
}
};
return BlockLogical;
}(Declaration);
Object.defineProperty(BlockLogical, 'names', {
enumerable: true,
writable: true,
value: ['border-block-start', 'border-block-end', 'margin-block-start', 'margin-block-end', 'padding-block-start', 'padding-block-end', 'border-before', 'border-after', 'margin-before', 'margin-after', 'padding-before', 'padding-after']
});
module.exports = BlockLogical;

View File

@@ -0,0 +1,38 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var BorderImage = function (_Declaration) {
_inherits(BorderImage, _Declaration);
function BorderImage() {
_classCallCheck(this, BorderImage);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Remove fill parameter for prefixed declarations
*/
BorderImage.prototype.set = function set(decl, prefix) {
decl.value = decl.value.replace(/\s+fill(\s)/, '$1');
return _Declaration.prototype.set.call(this, decl, prefix);
};
return BorderImage;
}(Declaration);
Object.defineProperty(BorderImage, 'names', {
enumerable: true,
writable: true,
value: ['border-image']
});
module.exports = BorderImage;

View File

@@ -0,0 +1,77 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var BorderRadius = function (_Declaration) {
_inherits(BorderRadius, _Declaration);
function BorderRadius() {
_classCallCheck(this, BorderRadius);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Change syntax, when add Mozilla prefix
*/
BorderRadius.prototype.prefixed = function prefixed(prop, prefix) {
if (prefix === '-moz-') {
return prefix + (BorderRadius.toMozilla[prop] || prop);
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Return unprefixed version of property
*/
BorderRadius.prototype.normalize = function normalize(prop) {
return BorderRadius.toNormal[prop] || prop;
};
return BorderRadius;
}(Declaration);
Object.defineProperty(BorderRadius, 'names', {
enumerable: true,
writable: true,
value: ['border-radius']
});
Object.defineProperty(BorderRadius, 'toMozilla', {
enumerable: true,
writable: true,
value: {}
});
Object.defineProperty(BorderRadius, 'toNormal', {
enumerable: true,
writable: true,
value: {}
});
var _arr = ['top', 'bottom'];
for (var _i = 0; _i < _arr.length; _i++) {
var ver = _arr[_i];var _arr2 = ['left', 'right'];
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var hor = _arr2[_i2];
var normal = 'border-' + ver + '-' + hor + '-radius';
var mozilla = 'border-radius-' + ver + hor;
BorderRadius.names.push(normal);
BorderRadius.names.push(mozilla);
BorderRadius.toMozilla[normal] = mozilla;
BorderRadius.toNormal[mozilla] = normal;
}
}
module.exports = BorderRadius;

View File

@@ -0,0 +1,89 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var BreakProps = function (_Declaration) {
_inherits(BreakProps, _Declaration);
function BreakProps() {
_classCallCheck(this, BreakProps);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Change name for -webkit- and -moz- prefix
*/
BreakProps.prototype.prefixed = function prefixed(prop, prefix) {
if (prefix === '-webkit-') {
return '-webkit-column-' + prop;
} else if (prefix === '-moz-') {
return 'page-' + prop;
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Return property name by final spec
*/
BreakProps.prototype.normalize = function normalize(prop) {
if (prop.indexOf('inside') !== -1) {
return 'break-inside';
} else if (prop.indexOf('before') !== -1) {
return 'break-before';
} else if (prop.indexOf('after') !== -1) {
return 'break-after';
}
return undefined;
};
/**
* Change prefixed value for avoid-column and avoid-page
*/
BreakProps.prototype.set = function set(decl, prefix) {
var v = decl.value;
if (decl.prop === 'break-inside' && v === 'avoid-column' || v === 'avoid-page') {
decl.value = 'avoid';
}
return _Declaration.prototype.set.call(this, decl, prefix);
};
/**
* Dont prefix some values
*/
BreakProps.prototype.insert = function insert(decl, prefix, prefixes) {
if (decl.prop !== 'break-inside') {
return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
} else if (decl.value === 'avoid-region') {
return undefined;
} else if (decl.value === 'avoid-page' && prefix === '-webkit-') {
return undefined;
} else {
return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
}
};
return BreakProps;
}(Declaration);
Object.defineProperty(BreakProps, 'names', {
enumerable: true,
writable: true,
value: ['break-inside', 'page-break-inside', 'column-break-inside', 'break-before', 'page-break-before', 'column-break-before', 'break-after', 'page-break-after', 'column-break-after']
});
module.exports = BreakProps;

View File

@@ -0,0 +1,56 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Value = require('../value');
var list = require('postcss/lib/list');
var CrossFade = function (_Value) {
_inherits(CrossFade, _Value);
function CrossFade() {
_classCallCheck(this, CrossFade);
return _possibleConstructorReturn(this, _Value.apply(this, arguments));
}
CrossFade.prototype.replace = function replace(string, prefix) {
var _this2 = this;
return list.space(string).map(function (value) {
if (value.slice(0, +_this2.name.length + 1) !== _this2.name + '(') {
return value;
}
var close = value.lastIndexOf(')');
var after = value.slice(close + 1);
var args = value.slice(_this2.name.length + 1, close);
if (prefix === '-webkit-') {
var match = args.match(/\d*.?\d+%?/);
if (match) {
args = args.slice(match[0].length).trim();
args += ', ' + match[0];
} else {
args += ', 0.5';
}
}
return prefix + _this2.name + '(' + args + ')' + after;
}).join(' ');
};
return CrossFade;
}(Value);
Object.defineProperty(CrossFade, 'names', {
enumerable: true,
writable: true,
value: ['cross-fade']
});
module.exports = CrossFade;

View File

@@ -0,0 +1,102 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var OldValue = require('../old-value');
var Value = require('../value');
var DisplayFlex = function (_Value) {
_inherits(DisplayFlex, _Value);
function DisplayFlex(name, prefixes) {
_classCallCheck(this, DisplayFlex);
var _this = _possibleConstructorReturn(this, _Value.call(this, name, prefixes));
if (name === 'display-flex') {
_this.name = 'flex';
}
return _this;
}
/**
* Faster check for flex value
*/
DisplayFlex.prototype.check = function check(decl) {
return decl.prop === 'display' && decl.value === this.name;
};
/**
* Return value by spec
*/
DisplayFlex.prototype.prefixed = function prefixed(prefix) {
var spec = void 0,
value = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec === 2009) {
if (this.name === 'flex') {
value = 'box';
} else {
value = 'inline-box';
}
} else if (spec === 2012) {
if (this.name === 'flex') {
value = 'flexbox';
} else {
value = 'inline-flexbox';
}
} else if (spec === 'final') {
value = this.name;
}
return prefix + value;
};
/**
* Add prefix to value depend on flebox spec version
*/
DisplayFlex.prototype.replace = function replace(string, prefix) {
return this.prefixed(prefix);
};
/**
* Change value for old specs
*/
DisplayFlex.prototype.old = function old(prefix) {
var prefixed = this.prefixed(prefix);
if (prefixed) {
return new OldValue(this.name, prefixed);
}
return undefined;
};
return DisplayFlex;
}(Value);
Object.defineProperty(DisplayFlex, 'names', {
enumerable: true,
writable: true,
value: ['display-flex', 'inline-flex']
});
module.exports = DisplayFlex;

View File

@@ -0,0 +1,44 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Value = require('../value');
var DisplayGrid = function (_Value) {
_inherits(DisplayGrid, _Value);
function DisplayGrid(name, prefixes) {
_classCallCheck(this, DisplayGrid);
var _this = _possibleConstructorReturn(this, _Value.call(this, name, prefixes));
if (name === 'display-grid') {
_this.name = 'grid';
}
return _this;
}
/**
* Faster check for flex value
*/
DisplayGrid.prototype.check = function check(decl) {
return decl.prop === 'display' && decl.value === this.name;
};
return DisplayGrid;
}(Value);
Object.defineProperty(DisplayGrid, 'names', {
enumerable: true,
writable: true,
value: ['display-grid', 'inline-grid']
});
module.exports = DisplayGrid;

View File

@@ -0,0 +1,93 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var OldValue = require('../old-value');
var Value = require('../value');
var utils = require('../utils');
var OldFilterValue = function (_OldValue) {
_inherits(OldFilterValue, _OldValue);
function OldFilterValue() {
_classCallCheck(this, OldFilterValue);
return _possibleConstructorReturn(this, _OldValue.apply(this, arguments));
}
/**
* Clean -webkit-filter from properties list
*/
OldFilterValue.prototype.clean = function clean(decl) {
var _this2 = this;
decl.value = utils.editList(decl.value, function (props) {
if (props.every(function (i) {
return i.indexOf(_this2.unprefixed) !== 0;
})) {
return props;
}
return props.filter(function (i) {
return i.indexOf(_this2.prefixed) === -1;
});
});
};
return OldFilterValue;
}(OldValue);
var FilterValue = function (_Value) {
_inherits(FilterValue, _Value);
function FilterValue(name, prefixes) {
_classCallCheck(this, FilterValue);
var _this3 = _possibleConstructorReturn(this, _Value.call(this, name, prefixes));
if (name === 'filter-function') {
_this3.name = 'filter';
}
return _this3;
}
/**
* Use prefixed and unprefixed filter for WebKit
*/
FilterValue.prototype.replace = function replace(value, prefix) {
if (prefix === '-webkit-' && value.indexOf('filter(') === -1) {
if (value.indexOf('-webkit-filter') === -1) {
return _Value.prototype.replace.call(this, value, prefix) + ', ' + value;
} else {
return value;
}
} else {
return _Value.prototype.replace.call(this, value, prefix);
}
};
/**
* Clean -webkit-filter
*/
FilterValue.prototype.old = function old(prefix) {
return new OldFilterValue(this.name, prefix + this.name);
};
return FilterValue;
}(Value);
Object.defineProperty(FilterValue, 'names', {
enumerable: true,
writable: true,
value: ['filter', 'filter-function']
});
module.exports = FilterValue;

View File

@@ -0,0 +1,38 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var Filter = function (_Declaration) {
_inherits(Filter, _Declaration);
function Filter() {
_classCallCheck(this, Filter);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Check is it Internet Explorer filter
*/
Filter.prototype.check = function check(decl) {
var v = decl.value;
return v.toLowerCase().indexOf('alpha(') === -1 && v.indexOf('DXImageTransform.Microsoft') === -1 && v.indexOf('data:image/svg+xml') === -1;
};
return Filter;
}(Declaration);
Object.defineProperty(Filter, 'names', {
enumerable: true,
writable: true,
value: ['filter']
});
module.exports = Filter;

View File

@@ -0,0 +1,77 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var FlexBasis = function (_Declaration) {
_inherits(FlexBasis, _Declaration);
function FlexBasis() {
_classCallCheck(this, FlexBasis);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Return property name by final spec
*/
FlexBasis.prototype.normalize = function normalize() {
return 'flex-basis';
};
/**
* Return flex property for 2012 spec
*/
FlexBasis.prototype.prefixed = function prefixed(prop, prefix) {
var spec = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec === 2012) {
return prefix + 'flex-preferred-size';
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Ignore 2009 spec and use flex property for 2012
*/
FlexBasis.prototype.set = function set(decl, prefix) {
var spec = void 0;
var _flexSpec2 = flexSpec(prefix);
spec = _flexSpec2[0];
prefix = _flexSpec2[1];
if (spec === 2012 || spec === 'final') {
return _Declaration.prototype.set.call(this, decl, prefix);
}
return undefined;
};
return FlexBasis;
}(Declaration);
Object.defineProperty(FlexBasis, 'names', {
enumerable: true,
writable: true,
value: ['flex-basis', 'flex-preferred-size']
});
module.exports = FlexBasis;

View File

@@ -0,0 +1,110 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var FlexDirection = function (_Declaration) {
_inherits(FlexDirection, _Declaration);
function FlexDirection() {
_classCallCheck(this, FlexDirection);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Return property name by final spec
*/
FlexDirection.prototype.normalize = function normalize() {
return 'flex-direction';
};
/**
* Use two properties for 2009 spec
*/
FlexDirection.prototype.insert = function insert(decl, prefix, prefixes) {
var spec = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec !== 2009) {
return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
} else {
var already = decl.parent.some(function (i) {
return i.prop === prefix + 'box-orient' || i.prop === prefix + 'box-direction';
});
if (already) {
return undefined;
}
var v = decl.value;
var orient = void 0,
dir = void 0;
if (v === 'inherit' || v === 'initial' || v === 'unset') {
orient = v;
dir = v;
} else {
orient = v.indexOf('row') !== -1 ? 'horizontal' : 'vertical';
dir = v.indexOf('reverse') !== -1 ? 'reverse' : 'normal';
}
var cloned = this.clone(decl);
cloned.prop = prefix + 'box-orient';
cloned.value = orient;
if (this.needCascade(decl)) {
cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
}
decl.parent.insertBefore(decl, cloned);
cloned = this.clone(decl);
cloned.prop = prefix + 'box-direction';
cloned.value = dir;
if (this.needCascade(decl)) {
cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
}
return decl.parent.insertBefore(decl, cloned);
}
};
/**
* Clean two properties for 2009 spec
*/
FlexDirection.prototype.old = function old(prop, prefix) {
var spec = void 0;
var _flexSpec2 = flexSpec(prefix);
spec = _flexSpec2[0];
prefix = _flexSpec2[1];
if (spec === 2009) {
return [prefix + 'box-orient', prefix + 'box-direction'];
} else {
return _Declaration.prototype.old.call(this, prop, prefix);
}
};
return FlexDirection;
}(Declaration);
Object.defineProperty(FlexDirection, 'names', {
enumerable: true,
writable: true,
value: ['flex-direction', 'box-direction', 'box-orient']
});
module.exports = FlexDirection;

View File

@@ -0,0 +1,81 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var FlexFlow = function (_Declaration) {
_inherits(FlexFlow, _Declaration);
function FlexFlow() {
_classCallCheck(this, FlexFlow);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Use two properties for 2009 spec
*/
FlexFlow.prototype.insert = function insert(decl, prefix, prefixes) {
var spec = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec !== 2009) {
return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
} else {
var values = decl.value.split(/\s+/).filter(function (i) {
return i !== 'wrap' && i !== 'nowrap' && 'wrap-reverse';
});
if (values.length === 0) {
return undefined;
}
var already = decl.parent.some(function (i) {
return i.prop === prefix + 'box-orient' || i.prop === prefix + 'box-direction';
});
if (already) {
return undefined;
}
var value = values[0];
var orient = value.indexOf('row') !== -1 ? 'horizontal' : 'vertical';
var dir = value.indexOf('reverse') !== -1 ? 'reverse' : 'normal';
var cloned = this.clone(decl);
cloned.prop = prefix + 'box-orient';
cloned.value = orient;
if (this.needCascade(decl)) {
cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
}
decl.parent.insertBefore(decl, cloned);
cloned = this.clone(decl);
cloned.prop = prefix + 'box-direction';
cloned.value = dir;
if (this.needCascade(decl)) {
cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
}
return decl.parent.insertBefore(decl, cloned);
}
};
return FlexFlow;
}(Declaration);
Object.defineProperty(FlexFlow, 'names', {
enumerable: true,
writable: true,
value: ['flex-flow', 'box-direction', 'box-orient']
});
module.exports = FlexFlow;

View File

@@ -0,0 +1,60 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var Flex = function (_Declaration) {
_inherits(Flex, _Declaration);
function Flex() {
_classCallCheck(this, Flex);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Return property name by final spec
*/
Flex.prototype.normalize = function normalize() {
return 'flex';
};
/**
* Return flex property for 2009 and 2012 specs
*/
Flex.prototype.prefixed = function prefixed(prop, prefix) {
var spec = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec === 2009) {
return prefix + 'box-flex';
} else if (spec === 2012) {
return prefix + 'flex-positive';
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
return Flex;
}(Declaration);
Object.defineProperty(Flex, 'names', {
enumerable: true,
writable: true,
value: ['flex-grow', 'flex-positive']
});
module.exports = Flex;

View File

@@ -0,0 +1,77 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var FlexShrink = function (_Declaration) {
_inherits(FlexShrink, _Declaration);
function FlexShrink() {
_classCallCheck(this, FlexShrink);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Return property name by final spec
*/
FlexShrink.prototype.normalize = function normalize() {
return 'flex-shrink';
};
/**
* Return flex property for 2012 spec
*/
FlexShrink.prototype.prefixed = function prefixed(prop, prefix) {
var spec = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec === 2012) {
return prefix + 'flex-negative';
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Ignore 2009 spec and use flex property for 2012
*/
FlexShrink.prototype.set = function set(decl, prefix) {
var spec = void 0;
var _flexSpec2 = flexSpec(prefix);
spec = _flexSpec2[0];
prefix = _flexSpec2[1];
if (spec === 2012 || spec === 'final') {
return _Declaration.prototype.set.call(this, decl, prefix);
}
return undefined;
};
return FlexShrink;
}(Declaration);
Object.defineProperty(FlexShrink, 'names', {
enumerable: true,
writable: true,
value: ['flex-shrink', 'flex-negative']
});
module.exports = FlexShrink;

View File

@@ -0,0 +1,21 @@
'use strict';
/**
* Return flexbox spec versions by prefix
*/
module.exports = function (prefix) {
var spec = void 0;
if (prefix === '-webkit- 2009' || prefix === '-moz-') {
spec = 2009;
} else if (prefix === '-ms-') {
spec = 2012;
} else if (prefix === '-webkit-') {
spec = 'final';
}
if (prefix === '-webkit- 2009') {
prefix = '-webkit-';
}
return [spec, prefix];
};

View File

@@ -0,0 +1,56 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var OldValue = require('../old-value');
var Value = require('../value');
var FlexValues = function (_Value) {
_inherits(FlexValues, _Value);
function FlexValues() {
_classCallCheck(this, FlexValues);
return _possibleConstructorReturn(this, _Value.apply(this, arguments));
}
/**
* Return prefixed property name
*/
FlexValues.prototype.prefixed = function prefixed(prefix) {
return this.all.prefixed(this.name, prefix);
};
/**
* Change property name to prefixed property name
*/
FlexValues.prototype.replace = function replace(string, prefix) {
return string.replace(this.regexp(), '$1' + this.prefixed(prefix) + '$3');
};
/**
* Return function to fast prefixed property name
*/
FlexValues.prototype.old = function old(prefix) {
return new OldValue(this.name, this.prefixed(prefix));
};
return FlexValues;
}(Value);
Object.defineProperty(FlexValues, 'names', {
enumerable: true,
writable: true,
value: ['flex', 'flex-grow', 'flex-shrink', 'flex-basis']
});
module.exports = FlexValues;

View File

@@ -0,0 +1,42 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var FlexWrap = function (_Declaration) {
_inherits(FlexWrap, _Declaration);
function FlexWrap() {
_classCallCheck(this, FlexWrap);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Don't add prefix for 2009 spec
*/
FlexWrap.prototype.set = function set(decl, prefix) {
var spec = flexSpec(prefix)[0];
if (spec !== 2009) {
return _Declaration.prototype.set.call(this, decl, prefix);
}
return undefined;
};
return FlexWrap;
}(Declaration);
Object.defineProperty(FlexWrap, 'names', {
enumerable: true,
writable: true,
value: ['flex-wrap']
});
module.exports = FlexWrap;

View File

@@ -0,0 +1,89 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var list = require('postcss/lib/list');
var Flex = function (_Declaration) {
_inherits(Flex, _Declaration);
function Flex() {
_classCallCheck(this, Flex);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Change property name for 2009 spec
*/
Flex.prototype.prefixed = function prefixed(prop, prefix) {
var spec = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec === 2009) {
return prefix + 'box-flex';
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Return property name by final spec
*/
Flex.prototype.normalize = function normalize() {
return 'flex';
};
/**
* Spec 2009 supports only first argument
* Spec 2012 disallows unitless basis
*/
Flex.prototype.set = function set(decl, prefix) {
var spec = flexSpec(prefix)[0];
if (spec === 2009) {
decl.value = list.space(decl.value)[0];
decl.value = Flex.oldValues[decl.value] || decl.value;
return _Declaration.prototype.set.call(this, decl, prefix);
} else if (spec === 2012) {
var components = list.space(decl.value);
if (components.length === 3 && components[2] === '0') {
decl.value = components.slice(0, 2).concat('0px').join(' ');
}
}
return _Declaration.prototype.set.call(this, decl, prefix);
};
return Flex;
}(Declaration);
Object.defineProperty(Flex, 'names', {
enumerable: true,
writable: true,
value: ['flex', 'box-flex']
});
Object.defineProperty(Flex, 'oldValues', {
enumerable: true,
writable: true,
value: {
auto: '1',
none: '0'
}
});
module.exports = Flex;

View File

@@ -0,0 +1,43 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Selector = require('../selector');
var Fullscreen = function (_Selector) {
_inherits(Fullscreen, _Selector);
function Fullscreen() {
_classCallCheck(this, Fullscreen);
return _possibleConstructorReturn(this, _Selector.apply(this, arguments));
}
/**
* Return different selectors depend on prefix
*/
Fullscreen.prototype.prefixed = function prefixed(prefix) {
if (prefix === '-webkit-') {
return ':-webkit-full-screen';
} else if (prefix === '-moz-') {
return ':-moz-full-screen';
} else {
return ':' + prefix + 'fullscreen';
}
};
return Fullscreen;
}(Selector);
Object.defineProperty(Fullscreen, 'names', {
enumerable: true,
writable: true,
value: [':fullscreen']
});
module.exports = Fullscreen;

View File

@@ -0,0 +1,531 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var OldValue = require('../old-value');
var Value = require('../value');
var utils = require('../utils');
var parser = require('postcss-value-parser');
var range = require('normalize-range');
var isDirection = /top|left|right|bottom/gi;
var Gradient = function (_Value) {
_inherits(Gradient, _Value);
function Gradient() {
var _temp, _this, _ret;
_classCallCheck(this, Gradient);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Value.call.apply(_Value, [this].concat(args))), _this), Object.defineProperty(_this, 'directions', {
enumerable: true,
writable: true,
value: {
top: 'bottom',
left: 'right',
bottom: 'top',
right: 'left'
}
}), Object.defineProperty(_this, 'oldDirections', {
enumerable: true,
writable: true,
value: {
'top': 'left bottom, left top',
'left': 'right top, left top',
'bottom': 'left top, left bottom',
'right': 'left top, right top',
'top right': 'left bottom, right top',
'top left': 'right bottom, left top',
'right top': 'left bottom, right top',
'right bottom': 'left top, right bottom',
'bottom right': 'left top, right bottom',
'bottom left': 'right top, left bottom',
'left top': 'right bottom, left top',
'left bottom': 'right top, left bottom'
}
}), _temp), _possibleConstructorReturn(_this, _ret);
}
// Direction to replace
// Direction to replace
/**
* Change degrees for webkit prefix
*/
Gradient.prototype.replace = function replace(string, prefix) {
var ast = parser(string);
for (var _iterator = ast.nodes, _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 node = _ref;
if (node.type === 'function' && node.value === this.name) {
node.nodes = this.newDirection(node.nodes);
node.nodes = this.normalize(node.nodes);
if (prefix === '-webkit- old') {
var changes = this.oldWebkit(node);
if (!changes) {
return undefined;
}
} else {
node.nodes = this.convertDirection(node.nodes);
node.value = prefix + node.value;
}
}
}
return ast.toString();
};
/**
* Replace first token
*/
Gradient.prototype.replaceFirst = function replaceFirst(params) {
for (var _len2 = arguments.length, words = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
words[_key2 - 1] = arguments[_key2];
}
var prefix = words.map(function (i) {
if (i === ' ') {
return { type: 'space', value: i };
} else {
return { type: 'word', value: i };
}
});
return prefix.concat(params.slice(1));
};
/**
* Convert angle unit to deg
*/
Gradient.prototype.normalizeUnit = function normalizeUnit(str, full) {
var num = parseFloat(str);
var deg = num / full * 360;
return deg + 'deg';
};
/**
* Normalize angle
*/
Gradient.prototype.normalize = function normalize(nodes) {
if (!nodes[0]) {
return nodes;
}
if (/-?\d+(.\d+)?grad/.test(nodes[0].value)) {
nodes[0].value = this.normalizeUnit(nodes[0].value, 400);
} else if (/-?\d+(.\d+)?rad/.test(nodes[0].value)) {
nodes[0].value = this.normalizeUnit(nodes[0].value, 2 * Math.PI);
} else if (/-?\d+(.\d+)?turn/.test(nodes[0].value)) {
nodes[0].value = this.normalizeUnit(nodes[0].value, 1);
} else if (nodes[0].value.indexOf('deg') !== -1) {
var num = parseFloat(nodes[0].value);
num = range.wrap(0, 360, num);
nodes[0].value = num + 'deg';
}
if (nodes[0].value === '0deg') {
nodes = this.replaceFirst(nodes, 'to', ' ', 'top');
} else if (nodes[0].value === '90deg') {
nodes = this.replaceFirst(nodes, 'to', ' ', 'right');
} else if (nodes[0].value === '180deg') {
nodes = this.replaceFirst(nodes, 'to', ' ', 'bottom');
} else if (nodes[0].value === '270deg') {
nodes = this.replaceFirst(nodes, 'to', ' ', 'left');
}
return nodes;
};
/**
* Replace old direction to new
*/
Gradient.prototype.newDirection = function newDirection(params) {
if (params[0].value === 'to') {
return params;
}
isDirection.lastIndex = 0; // reset search index of global regexp
if (!isDirection.test(params[0].value)) {
return params;
}
params.unshift({
type: 'word',
value: 'to'
}, {
type: 'space',
value: ' '
});
for (var i = 2; i < params.length; i++) {
if (params[i].type === 'div') {
break;
}
if (params[i].type === 'word') {
params[i].value = this.revertDirection(params[i].value);
}
}
return params;
};
/**
* Change new direction to old
*/
Gradient.prototype.convertDirection = function convertDirection(params) {
if (params.length > 0) {
if (params[0].value === 'to') {
this.fixDirection(params);
} else if (params[0].value.indexOf('deg') !== -1) {
this.fixAngle(params);
} else if (params[2].value === 'at') {
this.fixRadial(params);
}
}
return params;
};
/**
* Replace `to top left` to `bottom right`
*/
Gradient.prototype.fixDirection = function fixDirection(params) {
params.splice(0, 2);
for (var _iterator2 = params, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var param = _ref2;
if (param.type === 'div') {
break;
}
if (param.type === 'word') {
param.value = this.revertDirection(param.value);
}
}
};
/**
* Add 90 degrees
*/
Gradient.prototype.fixAngle = function fixAngle(params) {
var first = params[0].value;
first = parseFloat(first);
first = Math.abs(450 - first) % 360;
first = this.roundFloat(first, 3);
params[0].value = first + 'deg';
};
/**
* Fix radial direction syntax
*/
Gradient.prototype.fixRadial = function fixRadial(params) {
var first = params[0];
var second = [];
var i = void 0;
var div = void 0;
for (i = 4; i < params.length; i++) {
if (params[i].type === 'div') {
div = params[i];
break;
} else {
second.push(params[i]);
}
}
params.splice.apply(params, [0, i].concat(second, [div, first]));
};
Gradient.prototype.revertDirection = function revertDirection(word) {
return this.directions[word.toLowerCase()] || word;
};
/**
* Round float and save digits under dot
*/
Gradient.prototype.roundFloat = function roundFloat(float, digits) {
return parseFloat(float.toFixed(digits));
};
/**
* Convert to old webkit syntax
*/
Gradient.prototype.oldWebkit = function oldWebkit(node) {
var nodes = node.nodes;
var string = parser.stringify(node.nodes);
if (this.name !== 'linear-gradient') {
return false;
}
if (nodes[0] && nodes[0].value.indexOf('deg') !== -1) {
return false;
}
if (string.indexOf('px') !== -1) {
return false;
}
if (string.indexOf('-corner') !== -1) {
return false;
}
if (string.indexOf('-side') !== -1) {
return false;
}
var params = [[]];
for (var _iterator3 = nodes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
var _ref3;
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref3 = _iterator3[_i3++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
_ref3 = _i3.value;
}
var i = _ref3;
params[params.length - 1].push(i);
if (i.type === 'div' && i.value === ',') {
params.push([]);
}
}
this.oldDirection(params);
this.colorStops(params);
node.nodes = [];
for (var _iterator4 = params, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
var _ref4;
if (_isArray4) {
if (_i4 >= _iterator4.length) break;
_ref4 = _iterator4[_i4++];
} else {
_i4 = _iterator4.next();
if (_i4.done) break;
_ref4 = _i4.value;
}
var param = _ref4;
node.nodes = node.nodes.concat(param);
}
node.nodes.unshift({ type: 'word', value: 'linear' }, this.cloneDiv(node.nodes));
node.value = '-webkit-gradient';
return true;
};
/**
* Change direction syntax to old webkit
*/
Gradient.prototype.oldDirection = function oldDirection(params) {
var div = this.cloneDiv(params[0]);
if (params[0][0].value !== 'to') {
return params.unshift([{ type: 'word', value: this.oldDirections.bottom }, div]);
} else {
var _words = [];
for (var _iterator5 = params[0].slice(2), _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) {
var _ref5;
if (_isArray5) {
if (_i5 >= _iterator5.length) break;
_ref5 = _iterator5[_i5++];
} else {
_i5 = _iterator5.next();
if (_i5.done) break;
_ref5 = _i5.value;
}
var node = _ref5;
if (node.type === 'word') {
_words.push(node.value.toLowerCase());
}
}
_words = _words.join(' ');
var old = this.oldDirections[_words] || _words;
params[0] = [{ type: 'word', value: old }, div];
return params[0];
}
};
/**
* Get div token from exists parameters
*/
Gradient.prototype.cloneDiv = function cloneDiv(params) {
for (var _iterator6 = params, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) {
var _ref6;
if (_isArray6) {
if (_i6 >= _iterator6.length) break;
_ref6 = _iterator6[_i6++];
} else {
_i6 = _iterator6.next();
if (_i6.done) break;
_ref6 = _i6.value;
}
var i = _ref6;
if (i.type === 'div' && i.value === ',') {
return i;
}
}
return { type: 'div', value: ',', after: ' ' };
};
/**
* Change colors syntax to old webkit
*/
Gradient.prototype.colorStops = function colorStops(params) {
var result = [];
for (var i = 0; i < params.length; i++) {
var pos = void 0;
var param = params[i];
var item = void 0;
if (i === 0) {
continue;
}
var color = parser.stringify(param[0]);
if (param[1] && param[1].type === 'word') {
pos = param[1].value;
} else if (param[2] && param[2].type === 'word') {
pos = param[2].value;
}
var stop = void 0;
if (i === 1 && (!pos || pos === '0%')) {
stop = 'from(' + color + ')';
} else if (i === params.length - 1 && (!pos || pos === '100%')) {
stop = 'to(' + color + ')';
} else if (pos) {
stop = 'color-stop(' + pos + ', ' + color + ')';
} else {
stop = 'color-stop(' + color + ')';
}
var div = param[param.length - 1];
params[i] = [{ type: 'word', value: stop }];
if (div.type === 'div' && div.value === ',') {
item = params[i].push(div);
}
result.push(item);
}
return result;
};
/**
* Remove old WebKit gradient too
*/
Gradient.prototype.old = function old(prefix) {
if (prefix === '-webkit-') {
var type = this.name === 'linear-gradient' ? 'linear' : 'radial';
var string = '-gradient';
var regexp = utils.regexp('-webkit-(' + type + '-gradient|gradient\\(\\s*' + type + ')', false);
return new OldValue(this.name, prefix + this.name, string, regexp);
} else {
return _Value.prototype.old.call(this, prefix);
}
};
/**
* Do not add non-webkit prefixes for list-style and object
*/
Gradient.prototype.add = function add(decl, prefix) {
var p = decl.prop;
if (p.indexOf('mask') !== -1) {
if (prefix === '-webkit-' || prefix === '-webkit- old') {
return _Value.prototype.add.call(this, decl, prefix);
}
} else if (p === 'list-style' || p === 'list-style-image' || p === 'content') {
if (prefix === '-webkit-' || prefix === '-webkit- old') {
return _Value.prototype.add.call(this, decl, prefix);
}
} else {
return _Value.prototype.add.call(this, decl, prefix);
}
return undefined;
};
return Gradient;
}(Value);
Object.defineProperty(Gradient, 'names', {
enumerable: true,
writable: true,
value: ['linear-gradient', 'repeating-linear-gradient', 'radial-gradient', 'repeating-radial-gradient']
});
module.exports = Gradient;

View File

@@ -0,0 +1,55 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var GridColumnAlign = function (_Declaration) {
_inherits(GridColumnAlign, _Declaration);
function GridColumnAlign() {
_classCallCheck(this, GridColumnAlign);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Do not prefix flexbox values
*/
GridColumnAlign.prototype.check = function check(decl) {
return decl.value.indexOf('flex-') === -1 && decl.value !== 'baseline';
};
/**
* Change property name for IE
*/
GridColumnAlign.prototype.prefixed = function prefixed(prop, prefix) {
return prefix + 'grid-column-align';
};
/**
* Change IE property back
*/
GridColumnAlign.prototype.normalize = function normalize() {
return 'justify-self';
};
return GridColumnAlign;
}(Declaration);
Object.defineProperty(GridColumnAlign, 'names', {
enumerable: true,
writable: true,
value: ['grid-column-align']
});
module.exports = GridColumnAlign;

View File

@@ -0,0 +1,71 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var GridEnd = function (_Declaration) {
_inherits(GridEnd, _Declaration);
function GridEnd() {
_classCallCheck(this, GridEnd);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Do not add prefix for unsupported value in IE
*/
GridEnd.prototype.check = function check(decl) {
return decl.value.indexOf('span') !== -1;
};
/**
* Return a final spec property
*/
GridEnd.prototype.normalize = function normalize(prop) {
return prop.replace(/(-span|-end)/, '');
};
/**
* Change property name for IE
*/
GridEnd.prototype.prefixed = function prefixed(prop, prefix) {
if (prefix === '-ms-') {
return prefix + prop.replace('-end', '-span');
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Change repeating syntax for IE
*/
GridEnd.prototype.set = function set(decl, prefix) {
if (prefix === '-ms-') {
decl.value = decl.value.replace(/span\s/i, '');
}
return _Declaration.prototype.set.call(this, decl, prefix);
};
return GridEnd;
}(Declaration);
Object.defineProperty(GridEnd, 'names', {
enumerable: true,
writable: true,
value: ['grid-row-end', 'grid-column-end', 'grid-row-span', 'grid-column-span']
});
module.exports = GridEnd;

View File

@@ -0,0 +1,55 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var GridRowAlign = function (_Declaration) {
_inherits(GridRowAlign, _Declaration);
function GridRowAlign() {
_classCallCheck(this, GridRowAlign);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Do not prefix flexbox values
*/
GridRowAlign.prototype.check = function check(decl) {
return decl.value.indexOf('flex-') === -1 && decl.value !== 'baseline';
};
/**
* Change property name for IE
*/
GridRowAlign.prototype.prefixed = function prefixed(prop, prefix) {
return prefix + 'grid-row-align';
};
/**
* Change IE property back
*/
GridRowAlign.prototype.normalize = function normalize() {
return 'align-self';
};
return GridRowAlign;
}(Declaration);
Object.defineProperty(GridRowAlign, 'names', {
enumerable: true,
writable: true,
value: ['grid-row-align']
});
module.exports = GridRowAlign;

View File

@@ -0,0 +1,103 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var GridStart = function (_Declaration) {
_inherits(GridStart, _Declaration);
function GridStart() {
_classCallCheck(this, GridStart);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Do not add prefix for unsupported value in IE
*/
GridStart.prototype.check = function check(decl) {
return decl.value.indexOf('/') === -1 || decl.value.indexOf('span') !== -1;
};
/**
* Return a final spec property
*/
GridStart.prototype.normalize = function normalize(prop) {
return prop.replace('-start', '');
};
/**
* Change property name for IE
*/
GridStart.prototype.prefixed = function prefixed(prop, prefix) {
if (prefix === '-ms-') {
return prefix + prop.replace('-start', '');
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Split one value to two
*/
GridStart.prototype.insert = function insert(decl, prefix, prefixes) {
var parts = this.splitValue(decl, prefix);
if (parts.length === 2) {
decl.cloneBefore({
prop: '-ms-' + decl.prop + '-span',
value: parts[1]
});
}
return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
};
/**
* Change value for combine property
*/
GridStart.prototype.set = function set(decl, prefix) {
var parts = this.splitValue(decl, prefix);
if (parts.length === 2) {
decl.value = parts[0];
}
return _Declaration.prototype.set.call(this, decl, prefix);
};
/**
* If property contains start and end
*/
GridStart.prototype.splitValue = function splitValue(decl, prefix) {
if (prefix === '-ms-' && decl.prop.indexOf('-start') === -1) {
var parts = decl.value.split(/\s*\/\s*span\s+/);
if (parts.length === 2) {
return parts;
}
}
return false;
};
return GridStart;
}(Declaration);
Object.defineProperty(GridStart, 'names', {
enumerable: true,
writable: true,
value: ['grid-row-start', 'grid-column-start', 'grid-row', 'grid-column']
});
module.exports = GridStart;

View File

@@ -0,0 +1,113 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var parser = require('postcss-value-parser');
var Declaration = require('../declaration');
var GridTemplate = function (_Declaration) {
_inherits(GridTemplate, _Declaration);
function GridTemplate() {
_classCallCheck(this, GridTemplate);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Change property name for IE
*/
GridTemplate.prototype.prefixed = function prefixed(prop, prefix) {
if (prefix === '-ms-') {
return prefix + prop.replace('template-', '');
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Change IE property back
*/
GridTemplate.prototype.normalize = function normalize(prop) {
return prop.replace(/^grid-(rows|columns)/, 'grid-template-$1');
};
/**
* Recursive part of changeRepeat
*/
GridTemplate.prototype.walkRepeat = function walkRepeat(node) {
var fixed = [];
for (var _iterator = node.nodes, _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.nodes) {
this.walkRepeat(i);
}
fixed.push(i);
if (i.type === 'function' && i.value === 'repeat') {
var first = i.nodes.shift();
if (first) {
var count = first.value;
i.nodes.shift();
i.value = '';
fixed.push({ type: 'word', value: '[' + count + ']' });
}
}
}
node.nodes = fixed;
};
/**
* IE repeating syntax
*/
GridTemplate.prototype.changeRepeat = function changeRepeat(value) {
var ast = parser(value);
this.walkRepeat(ast);
return ast.toString();
};
/**
* Change repeating syntax for IE
*/
GridTemplate.prototype.set = function set(decl, prefix) {
if (prefix === '-ms-' && decl.value.indexOf('repeat(') !== -1) {
decl.value = this.changeRepeat(decl.value);
}
return _Declaration.prototype.set.call(this, decl, prefix);
};
return GridTemplate;
}(Declaration);
Object.defineProperty(GridTemplate, 'names', {
enumerable: true,
writable: true,
value: ['grid-template-rows', 'grid-template-columns', 'grid-rows', 'grid-columns']
});
module.exports = GridTemplate;

View File

@@ -0,0 +1,83 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var ImageRendering = function (_Declaration) {
_inherits(ImageRendering, _Declaration);
function ImageRendering() {
_classCallCheck(this, ImageRendering);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Add hack only for crisp-edges
*/
ImageRendering.prototype.check = function check(decl) {
return decl.value === 'pixelated';
};
/**
* Change property name for IE
*/
ImageRendering.prototype.prefixed = function prefixed(prop, prefix) {
if (prefix === '-ms-') {
return '-ms-interpolation-mode';
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Change property and value for IE
*/
ImageRendering.prototype.set = function set(decl, prefix) {
if (prefix === '-ms-') {
decl.prop = '-ms-interpolation-mode';
decl.value = 'nearest-neighbor';
return decl;
} else {
return _Declaration.prototype.set.call(this, decl, prefix);
}
};
/**
* Return property name by spec
*/
ImageRendering.prototype.normalize = function normalize() {
return 'image-rendering';
};
/**
* Warn on old value
*/
ImageRendering.prototype.process = function process(node, result) {
return _Declaration.prototype.process.call(this, node, result);
};
return ImageRendering;
}(Declaration);
Object.defineProperty(ImageRendering, 'names', {
enumerable: true,
writable: true,
value: ['image-rendering', 'interpolation-mode']
});
module.exports = ImageRendering;

View File

@@ -0,0 +1,41 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Value = require('../value');
var ImageSet = function (_Value) {
_inherits(ImageSet, _Value);
function ImageSet() {
_classCallCheck(this, ImageSet);
return _possibleConstructorReturn(this, _Value.apply(this, arguments));
}
/**
* Use non-standard name for WebKit and Firefox
*/
ImageSet.prototype.replace = function replace(string, prefix) {
if (prefix === '-webkit-') {
return _Value.prototype.replace.call(this, string, prefix).replace(/("[^"]+"|'[^']+')(\s+\d+\w)/gi, 'url($1)$2');
} else {
return _Value.prototype.replace.call(this, string, prefix);
}
};
return ImageSet;
}(Value);
Object.defineProperty(ImageSet, 'names', {
enumerable: true,
writable: true,
value: ['image-set']
});
module.exports = ImageSet;

View File

@@ -0,0 +1,46 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var InlineLogical = function (_Declaration) {
_inherits(InlineLogical, _Declaration);
function InlineLogical() {
_classCallCheck(this, InlineLogical);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Use old syntax for -moz- and -webkit-
*/
InlineLogical.prototype.prefixed = function prefixed(prop, prefix) {
return prefix + prop.replace('-inline', '');
};
/**
* Return property name by spec
*/
InlineLogical.prototype.normalize = function normalize(prop) {
return prop.replace(/(margin|padding|border)-(start|end)/, '$1-inline-$2');
};
return InlineLogical;
}(Declaration);
Object.defineProperty(InlineLogical, 'names', {
enumerable: true,
writable: true,
value: ['border-inline-start', 'border-inline-end', 'margin-inline-start', 'margin-inline-end', 'padding-inline-start', 'padding-inline-end', 'border-start', 'border-end', 'margin-start', 'margin-end', 'padding-start', 'padding-end']
});
module.exports = InlineLogical;

View File

@@ -0,0 +1,73 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var OldValue = require('../old-value');
var Value = require('../value');
function _regexp(name) {
return new RegExp('(^|[\\s,(])(' + name + '($|[\\s),]))', 'gi');
}
var Intrinsic = function (_Value) {
_inherits(Intrinsic, _Value);
function Intrinsic() {
_classCallCheck(this, Intrinsic);
return _possibleConstructorReturn(this, _Value.apply(this, arguments));
}
Intrinsic.prototype.regexp = function regexp() {
if (!this.regexpCache) this.regexpCache = _regexp(this.name);
return this.regexpCache;
};
Intrinsic.prototype.isStretch = function isStretch() {
return this.name === 'stretch' || this.name === 'fill' || this.name === 'fill-available';
};
Intrinsic.prototype.replace = function replace(string, prefix) {
if (prefix === '-moz-' && this.isStretch()) {
return string.replace(this.regexp(), '$1-moz-available$3');
} else if (prefix === '-webkit-' && this.isStretch()) {
return string.replace(this.regexp(), '$1-webkit-fill-available$3');
} else {
return _Value.prototype.replace.call(this, string, prefix);
}
};
Intrinsic.prototype.old = function old(prefix) {
var prefixed = prefix + this.name;
if (this.isStretch()) {
if (prefix === '-moz-') {
prefixed = '-moz-available';
} else if (prefix === '-webkit-') {
prefixed = '-webkit-fill-available';
}
}
return new OldValue(this.name, prefixed, prefixed, _regexp(prefixed));
};
Intrinsic.prototype.add = function add(decl, prefix) {
if (decl.prop.indexOf('grid') !== -1 && prefix !== '-webkit-') {
return undefined;
}
return _Value.prototype.add.call(this, decl, prefix);
};
return Intrinsic;
}(Value);
Object.defineProperty(Intrinsic, 'names', {
enumerable: true,
writable: true,
value: ['max-content', 'min-content', 'fit-content', 'fill', 'fill-available', 'stretch']
});
module.exports = Intrinsic;

View File

@@ -0,0 +1,89 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var JustifyContent = function (_Declaration) {
_inherits(JustifyContent, _Declaration);
function JustifyContent() {
_classCallCheck(this, JustifyContent);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Change property name for 2009 and 2012 specs
*/
JustifyContent.prototype.prefixed = function prefixed(prop, prefix) {
var spec = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec === 2009) {
return prefix + 'box-pack';
} else if (spec === 2012) {
return prefix + 'flex-pack';
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Return property name by final spec
*/
JustifyContent.prototype.normalize = function normalize() {
return 'justify-content';
};
/**
* Change value for 2009 and 2012 specs
*/
JustifyContent.prototype.set = function set(decl, prefix) {
var spec = flexSpec(prefix)[0];
if (spec === 2009 || spec === 2012) {
var value = JustifyContent.oldValues[decl.value] || decl.value;
decl.value = value;
if (spec !== 2009 || value !== 'distribute') {
return _Declaration.prototype.set.call(this, decl, prefix);
}
} else if (spec === 'final') {
return _Declaration.prototype.set.call(this, decl, prefix);
}
return undefined;
};
return JustifyContent;
}(Declaration);
Object.defineProperty(JustifyContent, 'names', {
enumerable: true,
writable: true,
value: ['justify-content', 'flex-pack', 'box-pack']
});
Object.defineProperty(JustifyContent, 'oldValues', {
enumerable: true,
writable: true,
value: {
'flex-end': 'end',
'flex-start': 'start',
'space-between': 'justify',
'space-around': 'distribute'
}
});
module.exports = JustifyContent;

View File

@@ -0,0 +1,50 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var MaskBorder = function (_Declaration) {
_inherits(MaskBorder, _Declaration);
function MaskBorder() {
_classCallCheck(this, MaskBorder);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Return property name by final spec
*/
MaskBorder.prototype.normalize = function normalize() {
return this.name.replace('box-image', 'border');
};
/**
* Return flex property for 2012 spec
*/
MaskBorder.prototype.prefixed = function prefixed(prop, prefix) {
if (prefix === '-webkit-') {
return _Declaration.prototype.prefixed.call(this, prop, prefix).replace('border', 'box-image');
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
return MaskBorder;
}(Declaration);
Object.defineProperty(MaskBorder, 'names', {
enumerable: true,
writable: true,
value: ['mask-border', 'mask-border-source', 'mask-border-slice', 'mask-border-width', 'mask-border-outset', 'mask-border-repeat', 'mask-box-image', 'mask-box-image-source', 'mask-box-image-slice', 'mask-box-image-width', 'mask-box-image-outset', 'mask-box-image-repeat']
});
module.exports = MaskBorder;

View File

@@ -0,0 +1,75 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var flexSpec = require('./flex-spec');
var Declaration = require('../declaration');
var Order = function (_Declaration) {
_inherits(Order, _Declaration);
function Order() {
_classCallCheck(this, Order);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Change property name for 2009 and 2012 specs
*/
Order.prototype.prefixed = function prefixed(prop, prefix) {
var spec = void 0;
var _flexSpec = flexSpec(prefix);
spec = _flexSpec[0];
prefix = _flexSpec[1];
if (spec === 2009) {
return prefix + 'box-ordinal-group';
} else if (spec === 2012) {
return prefix + 'flex-order';
} else {
return _Declaration.prototype.prefixed.call(this, prop, prefix);
}
};
/**
* Return property name by final spec
*/
Order.prototype.normalize = function normalize() {
return 'order';
};
/**
* Fix value for 2009 spec
*/
Order.prototype.set = function set(decl, prefix) {
var spec = flexSpec(prefix)[0];
if (spec === 2009 && /\d/.test(decl.value)) {
decl.value = (parseInt(decl.value) + 1).toString();
return _Declaration.prototype.set.call(this, decl, prefix);
} else {
return _Declaration.prototype.set.call(this, decl, prefix);
}
};
return Order;
}(Declaration);
Object.defineProperty(Order, 'names', {
enumerable: true,
writable: true,
value: ['order', 'flex-order', 'box-ordinal-group']
});
module.exports = Order;

View File

@@ -0,0 +1,59 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var OldValue = require('../old-value');
var Value = require('../value');
var Pixelated = function (_Value) {
_inherits(Pixelated, _Value);
function Pixelated() {
_classCallCheck(this, Pixelated);
return _possibleConstructorReturn(this, _Value.apply(this, arguments));
}
/**
* Use non-standard name for WebKit and Firefox
*/
Pixelated.prototype.replace = function replace(string, prefix) {
if (prefix === '-webkit-') {
return string.replace(this.regexp(), '$1-webkit-optimize-contrast');
} else if (prefix === '-moz-') {
return string.replace(this.regexp(), '$1-moz-crisp-edges');
} else {
return _Value.prototype.replace.call(this, string, prefix);
}
};
/**
* Different name for WebKit and Firefox
*/
Pixelated.prototype.old = function old(prefix) {
if (prefix === '-webkit-') {
return new OldValue(this.name, '-webkit-optimize-contrast');
} else if (prefix === '-moz-') {
return new OldValue(this.name, '-moz-crisp-edges');
} else {
return _Value.prototype.old.call(this, prefix);
}
};
return Pixelated;
}(Value);
Object.defineProperty(Pixelated, 'names', {
enumerable: true,
writable: true,
value: ['pixelated']
});
module.exports = Pixelated;

View File

@@ -0,0 +1,56 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Selector = require('../selector');
var Placeholder = function (_Selector) {
_inherits(Placeholder, _Selector);
function Placeholder() {
_classCallCheck(this, Placeholder);
return _possibleConstructorReturn(this, _Selector.apply(this, arguments));
}
/**
* Add old mozilla to possible prefixes
*/
Placeholder.prototype.possible = function possible() {
return _Selector.prototype.possible.call(this).concat(['-moz- old', '-ms- old']);
};
/**
* Return different selectors depend on prefix
*/
Placeholder.prototype.prefixed = function prefixed(prefix) {
if (prefix === '-webkit-') {
return '::-webkit-input-placeholder';
} else if (prefix === '-ms-') {
return '::-ms-input-placeholder';
} else if (prefix === '-ms- old') {
return ':-ms-input-placeholder';
} else if (prefix === '-moz- old') {
return ':-moz-placeholder';
} else {
return '::' + prefix + 'placeholder';
}
};
return Placeholder;
}(Selector);
Object.defineProperty(Placeholder, 'names', {
enumerable: true,
writable: true,
value: ['::placeholder']
});
module.exports = Placeholder;

View File

@@ -0,0 +1,41 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var BASIC = ['none', 'underline', 'overline', 'line-through', 'blink', 'inherit', 'initial', 'unset'];
var TextDecoration = function (_Declaration) {
_inherits(TextDecoration, _Declaration);
function TextDecoration() {
_classCallCheck(this, TextDecoration);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Do not add prefixes for basic values.
*/
TextDecoration.prototype.check = function check(decl) {
return decl.value.split(/\s+/).some(function (i) {
return BASIC.indexOf(i) === -1;
});
};
return TextDecoration;
}(Declaration);
Object.defineProperty(TextDecoration, 'names', {
enumerable: true,
writable: true,
value: ['text-decoration']
});
module.exports = TextDecoration;

View File

@@ -0,0 +1,39 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var TextEmphasisPosition = function (_Declaration) {
_inherits(TextEmphasisPosition, _Declaration);
function TextEmphasisPosition() {
_classCallCheck(this, TextEmphasisPosition);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
TextEmphasisPosition.prototype.set = function set(decl, prefix) {
if (prefix === '-webkit-') {
decl.value = decl.value.replace(/\s*(right|left)\s*/i, '');
return _Declaration.prototype.set.call(this, decl, prefix);
} else {
return _Declaration.prototype.set.call(this, decl, prefix);
}
};
return TextEmphasisPosition;
}(Declaration);
Object.defineProperty(TextEmphasisPosition, 'names', {
enumerable: true,
writable: true,
value: ['text-emphasis-position']
});
module.exports = TextEmphasisPosition;

View File

@@ -0,0 +1,116 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var TransformDecl = function (_Declaration) {
_inherits(TransformDecl, _Declaration);
function TransformDecl() {
_classCallCheck(this, TransformDecl);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
/**
* Recursively check all parents for @keyframes
*/
TransformDecl.prototype.keyframeParents = function keyframeParents(decl) {
var parent = decl.parent;
while (parent) {
if (parent.type === 'atrule' && parent.name === 'keyframes') {
return true;
}
var _parent = parent;
parent = _parent.parent;
}
return false;
};
/**
* Is transform caontain 3D commands
*/
TransformDecl.prototype.contain3d = function contain3d(decl) {
if (decl.prop === 'transform-origin') {
return false;
}
for (var _iterator = TransformDecl.functions3d, _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 func = _ref;
if (decl.value.indexOf(func + '(') !== -1) {
return true;
}
}
return false;
};
/**
* Replace rotateZ to rotate for IE 9
*/
TransformDecl.prototype.set = function set(decl, prefix) {
decl = _Declaration.prototype.set.call(this, decl, prefix);
if (prefix === '-ms-') {
decl.value = decl.value.replace(/rotateZ/gi, 'rotate');
}
return decl;
};
/**
* Don't add prefix for IE in keyframes
*/
TransformDecl.prototype.insert = function insert(decl, prefix, prefixes) {
if (prefix === '-ms-') {
if (!this.contain3d(decl) && !this.keyframeParents(decl)) {
return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
}
} else if (prefix === '-o-') {
if (!this.contain3d(decl)) {
return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
}
} else {
return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
}
return undefined;
};
return TransformDecl;
}(Declaration);
Object.defineProperty(TransformDecl, 'names', {
enumerable: true,
writable: true,
value: ['transform', 'transform-origin']
});
Object.defineProperty(TransformDecl, 'functions3d', {
enumerable: true,
writable: true,
value: ['matrix3d', 'translate3d', 'translateZ', 'scale3d', 'scaleZ', 'rotate3d', 'rotateX', 'rotateY', 'perspective']
});
module.exports = TransformDecl;

View File

@@ -0,0 +1,48 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Declaration = require('../declaration');
var WritingMode = function (_Declaration) {
_inherits(WritingMode, _Declaration);
function WritingMode() {
_classCallCheck(this, WritingMode);
return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
}
WritingMode.prototype.set = function set(decl, prefix) {
if (prefix === '-ms-') {
decl.value = WritingMode.msValues[decl.value] || decl.value;
return _Declaration.prototype.set.call(this, decl, prefix);
} else {
return _Declaration.prototype.set.call(this, decl, prefix);
}
};
return WritingMode;
}(Declaration);
Object.defineProperty(WritingMode, 'names', {
enumerable: true,
writable: true,
value: ['writing-mode']
});
Object.defineProperty(WritingMode, 'msValues', {
enumerable: true,
writable: true,
value: {
'horizontal-tb': 'lr-tb',
'vertical-rl': 'tb-rl',
'vertical-lr': 'tb-lr'
}
});
module.exports = WritingMode;

View File

@@ -0,0 +1,152 @@
'use strict';
var browserslist = require('browserslist');
function capitalize(str) {
return str.slice(0, 1).toUpperCase() + str.slice(1);
}
var 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'
};
var prefix = function prefix(name, prefixes) {
var out = ' ' + name + ': ';
out += prefixes.map(function (i) {
return i.replace(/^-(.*)-$/g, '$1');
}).join(', ');
out += '\n';
return out;
};
module.exports = function (prefixes) {
if (prefixes.browsers.selected.length === 0) {
return 'No browsers selected';
}
var versions = {};
for (var _iterator = prefixes.browsers.selected, _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 browser = _ref;
var _browser$split = browser.split(' '),
name = _browser$split[0],
version = _browser$split[1];
name = names[name] || capitalize(name);
if (versions[name]) {
versions[name].push(version);
} else {
versions[name] = [version];
}
}
var out = 'Browsers:\n';
for (var _browser in versions) {
var list = versions[_browser];
list = list.sort(function (a, b) {
return parseFloat(b) - parseFloat(a);
});
out += ' ' + _browser + ': ' + list.join(', ') + '\n';
}
var coverage = browserslist.coverage(prefixes.browsers.selected);
var round = Math.round(coverage * 100) / 100.0;
out += '\nThese browsers account for ' + round + '% of all users globally\n';
var atrules = '';
for (var name in prefixes.add) {
var data = prefixes.add[name];
if (name[0] === '@' && data.prefixes) {
atrules += prefix(name, data.prefixes);
}
}
if (atrules !== '') {
out += '\nAt-Rules:\n' + atrules;
}
var selectors = '';
for (var _iterator2 = prefixes.add.selectors, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var selector = _ref2;
if (selector.prefixes) {
selectors += prefix(selector.name, selector.prefixes);
}
}
if (selectors !== '') {
out += '\nSelectors:\n' + selectors;
}
var values = '';
var props = '';
for (var _name in prefixes.add) {
var _data = prefixes.add[_name];
if (_name[0] !== '@' && _data.prefixes) {
props += prefix(_name, _data.prefixes);
}
if (!_data.values) {
continue;
}
for (var _iterator3 = _data.values, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
var _ref3;
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref3 = _iterator3[_i3++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
_ref3 = _i3.value;
}
var value = _ref3;
var 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;
};

View File

@@ -0,0 +1,94 @@
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var OldSelector = function () {
function OldSelector(selector, prefix) {
_classCallCheck(this, OldSelector);
this.prefix = prefix;
this.prefixed = selector.prefixed(this.prefix);
this.regexp = selector.regexp(this.prefix);
this.prefixeds = selector.possible().map(function (x) {
return [selector.prefixed(x), selector.regexp(x)];
});
this.unprefixed = selector.name;
this.nameRegexp = selector.regexp();
}
/**
* Is rule a hack without unprefixed version bottom
*/
OldSelector.prototype.isHack = function isHack(rule) {
var index = rule.parent.index(rule) + 1;
var rules = rule.parent.nodes;
while (index < rules.length) {
var before = rules[index].selector;
if (!before) {
return true;
}
if (before.indexOf(this.unprefixed) !== -1 && before.match(this.nameRegexp)) {
return false;
}
var some = false;
for (var _iterator = this.prefixeds, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref2;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref2 = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref2 = _i.value;
}
var _ref = _ref2;
var string = _ref[0];
var regexp = _ref[1];
if (before.indexOf(string) !== -1 && before.match(regexp)) {
some = true;
break;
}
}
if (!some) {
return true;
}
index += 1;
}
return true;
};
/**
* Does rule contain an unnecessary prefixed selector
*/
OldSelector.prototype.check = function check(rule) {
if (rule.selector.indexOf(this.prefixed) === -1) {
return false;
}
if (!rule.selector.match(this.regexp)) {
return false;
}
if (this.isHack(rule)) {
return false;
}
return true;
};
return OldSelector;
}();
module.exports = OldSelector;

View File

@@ -0,0 +1,32 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var utils = require('./utils');
var OldValue = function () {
function OldValue(unprefixed, prefixed, string, regexp) {
_classCallCheck(this, OldValue);
this.unprefixed = unprefixed;
this.prefixed = prefixed;
this.string = string || prefixed;
this.regexp = regexp || utils.regexp(prefixed);
}
/**
* Check, that value contain old value
*/
OldValue.prototype.check = function check(value) {
if (value.indexOf(this.string) !== -1) {
return !!value.match(this.regexp);
}
return false;
};
return OldValue;
}();
module.exports = OldValue;

View File

@@ -0,0 +1,190 @@
'use strict';
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; };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Browsers = require('./browsers');
var utils = require('./utils');
var vendor = require('postcss/lib/vendor');
/**
* Recursivly clone objects
*/
function _clone(obj, parent) {
var cloned = new obj.constructor();
for (var _iterator = Object.keys(obj || {}), _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;
var value = obj[i];
if (i === 'parent' && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
if (parent) {
cloned[i] = parent;
}
} else if (i === 'source') {
cloned[i] = value;
} else if (i === null) {
cloned[i] = value;
} else if (value instanceof Array) {
cloned[i] = value.map(function (x) {
return _clone(x, cloned);
});
} else if (i !== '_autoprefixerPrefix' && i !== '_autoprefixerValues') {
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null) {
value = _clone(value, cloned);
}
cloned[i] = value;
}
}
return cloned;
}
var Prefixer = function () {
/**
* Add hack to selected names
*/
Prefixer.hack = function hack(klass) {
var _this = this;
if (!this.hacks) {
this.hacks = {};
}
return klass.names.map(function (name) {
_this.hacks[name] = klass;
return _this.hacks[name];
});
};
/**
* Load hacks for some names
*/
Prefixer.load = function load(name, prefixes, all) {
var Klass = this.hacks && this.hacks[name];
if (Klass) {
return new Klass(name, prefixes, all);
} else {
return new this(name, prefixes, all);
}
};
/**
* Clone node and clean autprefixer custom caches
*/
Prefixer.clone = function clone(node, overrides) {
var cloned = _clone(node);
for (var name in overrides) {
cloned[name] = overrides[name];
}
return cloned;
};
function Prefixer(name, prefixes, all) {
_classCallCheck(this, Prefixer);
this.name = name;
this.prefixes = prefixes;
this.all = all;
}
/**
* Find prefix in node parents
*/
Prefixer.prototype.parentPrefix = function parentPrefix(node) {
var prefix = void 0;
if (typeof node._autoprefixerPrefix !== 'undefined') {
prefix = node._autoprefixerPrefix;
} else if (node.type === 'decl' && node.prop[0] === '-') {
prefix = vendor.prefix(node.prop);
} else if (node.type === 'root') {
prefix = false;
} else if (node.type === 'rule' && node.selector.indexOf(':-') !== -1 && /:(-\w+-)/.test(node.selector)) {
prefix = node.selector.match(/:(-\w+-)/)[1];
} else if (node.type === 'atrule' && node.name[0] === '-') {
prefix = vendor.prefix(node.name);
} else {
prefix = this.parentPrefix(node.parent);
}
if (Browsers.prefixes().indexOf(prefix) === -1) {
prefix = false;
}
node._autoprefixerPrefix = prefix;
return node._autoprefixerPrefix;
};
/**
* Clone node with prefixes
*/
Prefixer.prototype.process = function process(node) {
if (!this.check(node)) {
return undefined;
}
var parent = this.parentPrefix(node);
var prefixes = this.prefixes.filter(function (prefix) {
return !parent || parent === utils.removeNote(prefix);
});
var added = [];
for (var _iterator2 = prefixes, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var prefix = _ref2;
if (this.add(node, prefix, added.concat([prefix]))) {
added.push(prefix);
}
}
return added;
};
/**
* Shortcut for Prefixer.clone
*/
Prefixer.prototype.clone = function clone(node, overrides) {
return Prefixer.clone(node, overrides);
};
return Prefixer;
}();
module.exports = Prefixer;

View File

@@ -0,0 +1,506 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Declaration = require('./declaration');
var Resolution = require('./resolution');
var Transition = require('./transition');
var Processor = require('./processor');
var Supports = require('./supports');
var Browsers = require('./browsers');
var Selector = require('./selector');
var AtRule = require('./at-rule');
var Value = require('./value');
var utils = require('./utils');
var vendor = require('postcss/lib/vendor');
Selector.hack(require('./hacks/fullscreen'));
Selector.hack(require('./hacks/placeholder'));
Declaration.hack(require('./hacks/flex'));
Declaration.hack(require('./hacks/order'));
Declaration.hack(require('./hacks/filter'));
Declaration.hack(require('./hacks/grid-end'));
Declaration.hack(require('./hacks/flex-flow'));
Declaration.hack(require('./hacks/flex-grow'));
Declaration.hack(require('./hacks/flex-wrap'));
Declaration.hack(require('./hacks/grid-start'));
Declaration.hack(require('./hacks/align-self'));
Declaration.hack(require('./hacks/appearance'));
Declaration.hack(require('./hacks/flex-basis'));
Declaration.hack(require('./hacks/mask-border'));
Declaration.hack(require('./hacks/align-items'));
Declaration.hack(require('./hacks/flex-shrink'));
Declaration.hack(require('./hacks/break-props'));
Declaration.hack(require('./hacks/writing-mode'));
Declaration.hack(require('./hacks/border-image'));
Declaration.hack(require('./hacks/align-content'));
Declaration.hack(require('./hacks/border-radius'));
Declaration.hack(require('./hacks/block-logical'));
Declaration.hack(require('./hacks/grid-template'));
Declaration.hack(require('./hacks/inline-logical'));
Declaration.hack(require('./hacks/grid-row-align'));
Declaration.hack(require('./hacks/transform-decl'));
Declaration.hack(require('./hacks/flex-direction'));
Declaration.hack(require('./hacks/image-rendering'));
Declaration.hack(require('./hacks/text-decoration'));
Declaration.hack(require('./hacks/justify-content'));
Declaration.hack(require('./hacks/background-size'));
Declaration.hack(require('./hacks/grid-column-align'));
Declaration.hack(require('./hacks/text-emphasis-position'));
Value.hack(require('./hacks/gradient'));
Value.hack(require('./hacks/intrinsic'));
Value.hack(require('./hacks/pixelated'));
Value.hack(require('./hacks/image-set'));
Value.hack(require('./hacks/cross-fade'));
Value.hack(require('./hacks/flex-values'));
Value.hack(require('./hacks/display-flex'));
Value.hack(require('./hacks/display-grid'));
Value.hack(require('./hacks/filter-value'));
var declsCache = {};
var Prefixes = function () {
function Prefixes(data, browsers) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
_classCallCheck(this, Prefixes);
this.data = data;
this.browsers = browsers;
this.options = options;
var _preprocess = this.preprocess(this.select(this.data));
this.add = _preprocess[0];
this.remove = _preprocess[1];
this.transition = new Transition(this);
this.processor = new Processor(this);
}
/**
* Return clone instance to remove all prefixes
*/
Prefixes.prototype.cleaner = function cleaner() {
if (this.cleanerCache) {
return this.cleanerCache;
}
if (this.browsers.selected.length) {
var empty = new Browsers(this.browsers.data, []);
this.cleanerCache = new Prefixes(this.data, empty, this.options);
} else {
return this;
}
return this.cleanerCache;
};
/**
* Select prefixes from data, which is necessary for selected browsers
*/
Prefixes.prototype.select = function select(list) {
var _this = this;
var selected = { add: {}, remove: {} };
var _loop = function _loop(name) {
var data = list[name];
var add = data.browsers.map(function (i) {
var params = i.split(' ');
return {
browser: params[0] + ' ' + params[1],
note: params[2]
};
});
var notes = add.filter(function (i) {
return i.note;
}).map(function (i) {
return _this.browsers.prefix(i.browser) + ' ' + i.note;
});
notes = utils.uniq(notes);
add = add.filter(function (i) {
return _this.browsers.isSelected(i.browser);
}).map(function (i) {
var prefix = _this.browsers.prefix(i.browser);
if (i.note) {
return prefix + ' ' + i.note;
} else {
return prefix;
}
});
add = _this.sort(utils.uniq(add));
if (_this.options.flexbox === 'no-2009') {
add = add.filter(function (i) {
return i.indexOf('2009') === -1;
});
}
var all = data.browsers.map(function (i) {
return _this.browsers.prefix(i);
});
if (data.mistakes) {
all = all.concat(data.mistakes);
}
all = all.concat(notes);
all = utils.uniq(all);
if (add.length) {
selected.add[name] = add;
if (add.length < all.length) {
selected.remove[name] = all.filter(function (i) {
return add.indexOf(i) === -1;
});
}
} else {
selected.remove[name] = all;
}
};
for (var name in list) {
_loop(name);
}
return selected;
};
/**
* Sort vendor prefixes
*/
Prefixes.prototype.sort = function sort(prefixes) {
return prefixes.sort(function (a, b) {
var aLength = utils.removeNote(a).length;
var bLength = utils.removeNote(b).length;
if (aLength === bLength) {
return b.length - a.length;
} else {
return bLength - aLength;
}
});
};
/**
* Cache prefixes data to fast CSS processing
*/
Prefixes.prototype.preprocess = function preprocess(selected) {
var add = {
'selectors': [],
'@supports': new Supports(Prefixes, this)
};
for (var name in selected.add) {
var prefixes = selected.add[name];
if (name === '@keyframes' || name === '@viewport') {
add[name] = new AtRule(name, prefixes, this);
} else if (name === '@resolution') {
add[name] = new Resolution(name, prefixes, this);
} else if (this.data[name].selector) {
add.selectors.push(Selector.load(name, prefixes, this));
} else {
var props = this.data[name].props;
if (props) {
var value = Value.load(name, prefixes, this);
for (var _iterator = props, _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 prop = _ref;
if (!add[prop]) {
add[prop] = { values: [] };
}
add[prop].values.push(value);
}
} else {
var values = add[name] && add[name].values || [];
add[name] = Declaration.load(name, prefixes, this);
add[name].values = values;
}
}
}
var remove = { selectors: [] };
for (var _name in selected.remove) {
var _prefixes = selected.remove[_name];
if (this.data[_name].selector) {
var selector = Selector.load(_name, _prefixes);
for (var _iterator2 = _prefixes, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var prefix = _ref2;
remove.selectors.push(selector.old(prefix));
}
} else if (_name === '@keyframes' || _name === '@viewport') {
for (var _iterator3 = _prefixes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
var _ref3;
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref3 = _iterator3[_i3++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
_ref3 = _i3.value;
}
var _prefix = _ref3;
var prefixed = '@' + _prefix + _name.slice(1);
remove[prefixed] = { remove: true };
}
} else if (_name === '@resolution') {
remove[_name] = new Resolution(_name, _prefixes, this);
} else {
var _props = this.data[_name].props;
if (_props) {
var _value = Value.load(_name, [], this);
for (var _iterator4 = _prefixes, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
var _ref4;
if (_isArray4) {
if (_i4 >= _iterator4.length) break;
_ref4 = _iterator4[_i4++];
} else {
_i4 = _iterator4.next();
if (_i4.done) break;
_ref4 = _i4.value;
}
var _prefix2 = _ref4;
var old = _value.old(_prefix2);
if (old) {
for (var _iterator5 = _props, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) {
var _ref5;
if (_isArray5) {
if (_i5 >= _iterator5.length) break;
_ref5 = _iterator5[_i5++];
} else {
_i5 = _iterator5.next();
if (_i5.done) break;
_ref5 = _i5.value;
}
var _prop = _ref5;
if (!remove[_prop]) {
remove[_prop] = {};
}
if (!remove[_prop].values) {
remove[_prop].values = [];
}
remove[_prop].values.push(old);
}
}
}
} else {
for (var _iterator6 = _prefixes, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) {
var _ref6;
if (_isArray6) {
if (_i6 >= _iterator6.length) break;
_ref6 = _iterator6[_i6++];
} else {
_i6 = _iterator6.next();
if (_i6.done) break;
_ref6 = _i6.value;
}
var _prefix3 = _ref6;
var olds = this.decl(_name).old(_name, _prefix3);
if (_name === 'align-self') {
var a = add[_name] && add[_name].prefixes;
if (a) {
if (_prefix3 === '-webkit- 2009' && a.indexOf('-webkit-') !== -1) {
continue;
} else if (_prefix3 === '-webkit-' && a.indexOf('-webkit- 2009') !== -1) {
continue;
}
}
}
for (var _iterator7 = olds, _isArray7 = Array.isArray(_iterator7), _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : _iterator7[Symbol.iterator]();;) {
var _ref7;
if (_isArray7) {
if (_i7 >= _iterator7.length) break;
_ref7 = _iterator7[_i7++];
} else {
_i7 = _iterator7.next();
if (_i7.done) break;
_ref7 = _i7.value;
}
var _prefixed = _ref7;
if (!remove[_prefixed]) {
remove[_prefixed] = {};
}
remove[_prefixed].remove = true;
}
}
}
}
}
return [add, remove];
};
/**
* Declaration loader with caching
*/
Prefixes.prototype.decl = function decl(prop) {
var decl = declsCache[prop];
if (decl) {
return decl;
} else {
declsCache[prop] = Declaration.load(prop);
return declsCache[prop];
}
};
/**
* Return unprefixed version of property
*/
Prefixes.prototype.unprefixed = function unprefixed(prop) {
var value = this.normalize(vendor.unprefixed(prop));
if (value === 'flex-direction') {
value = 'flex-flow';
}
return value;
};
/**
* Normalize prefix for remover
*/
Prefixes.prototype.normalize = function normalize(prop) {
return this.decl(prop).normalize(prop);
};
/**
* Return prefixed version of property
*/
Prefixes.prototype.prefixed = function prefixed(prop, prefix) {
prop = vendor.unprefixed(prop);
return this.decl(prop).prefixed(prop, prefix);
};
/**
* Return values, which must be prefixed in selected property
*/
Prefixes.prototype.values = function values(type, prop) {
var data = this[type];
var global = data['*'] && data['*'].values;
var values = data[prop] && data[prop].values;
if (global && values) {
return utils.uniq(global.concat(values));
} else {
return global || values || [];
}
};
/**
* Group declaration by unprefixed property to check them
*/
Prefixes.prototype.group = function group(decl) {
var _this2 = this;
var rule = decl.parent;
var index = rule.index(decl);
var length = rule.nodes.length;
var unprefixed = this.unprefixed(decl.prop);
var checker = function checker(step, callback) {
index += step;
while (index >= 0 && index < length) {
var other = rule.nodes[index];
if (other.type === 'decl') {
if (step === -1 && other.prop === unprefixed) {
if (!Browsers.withPrefix(other.value)) {
break;
}
}
if (_this2.unprefixed(other.prop) !== unprefixed) {
break;
} else if (callback(other) === true) {
return true;
}
if (step === +1 && other.prop === unprefixed) {
if (!Browsers.withPrefix(other.value)) {
break;
}
}
}
index += step;
}
return false;
};
return {
up: function up(callback) {
return checker(-1, callback);
},
down: function down(callback) {
return checker(+1, callback);
}
};
};
return Prefixes;
}();
module.exports = Prefixes;

View File

@@ -0,0 +1,457 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Value = require('./value');
var OLD_LINEAR = /(^|[^-])linear-gradient\(\s*(top|left|right|bottom)/i;
var OLD_RADIAL = /(^|[^-])radial-gradient\(\s*\d+(\w*|%)\s+\d+(\w*|%)\s*,/i;
var SIZES = ['width', 'height', 'min-width', 'max-width', 'min-height', 'max-height', 'inline-size', 'min-inline-size', 'max-inline-size', 'block-size', 'min-block-size', 'max-block-size'];
var Processor = function () {
function Processor(prefixes) {
_classCallCheck(this, Processor);
this.prefixes = prefixes;
}
/**
* Add necessary prefixes
*/
Processor.prototype.add = function add(css, result) {
var _this = this;
// At-rules
var resolution = this.prefixes.add['@resolution'];
var keyframes = this.prefixes.add['@keyframes'];
var viewport = this.prefixes.add['@viewport'];
var supports = this.prefixes.add['@supports'];
css.walkAtRules(function (rule) {
if (rule.name === 'keyframes') {
if (!_this.disabled(rule, result)) {
return keyframes && keyframes.process(rule);
}
} else if (rule.name === 'viewport') {
if (!_this.disabled(rule, result)) {
return viewport && viewport.process(rule);
}
} else if (rule.name === 'supports') {
if (_this.prefixes.options.supports !== false && !_this.disabled(rule, result)) {
return supports.process(rule);
}
} else if (rule.name === 'media' && rule.params.indexOf('-resolution') !== -1) {
if (!_this.disabled(rule, result)) {
return resolution && resolution.process(rule);
}
}
return undefined;
});
// Selectors
css.walkRules(function (rule) {
if (_this.disabled(rule, result)) return undefined;
return _this.prefixes.add.selectors.map(function (selector) {
return selector.process(rule, result);
});
});
css.walkDecls(function (decl) {
if (_this.disabledDecl(decl, result)) return undefined;
if (decl.prop === 'display' && decl.value === 'box') {
result.warn('You should write display: flex by final spec ' + 'instead of display: box', { node: decl });
return undefined;
}
if (decl.value.indexOf('linear-gradient') !== -1) {
if (OLD_LINEAR.test(decl.value)) {
result.warn('Gradient has outdated direction syntax. ' + 'New syntax is like `to left` instead of `right`.', { node: decl });
}
}
if (decl.value.indexOf('radial-gradient') !== -1) {
if (OLD_RADIAL.test(decl.value)) {
result.warn('Gradient has outdated direction syntax. ' + 'New syntax is like `closest-side at 0 0` ' + 'instead of `0 0, closest-side`.', { node: decl });
}
}
if (decl.prop === 'text-emphasis-position') {
if (decl.value === 'under' || decl.value === 'over') {
result.warn('You should use 2 values for text-emphasis-position ' + 'For example, `under left` instead of just `under`.', { node: decl });
}
}
if (SIZES.indexOf(decl.prop) !== -1) {
if (decl.value.indexOf('fill-available') !== -1) {
result.warn('Replace fill-available to stretch, ' + 'because spec had been changed', { node: decl });
} else if (decl.value.indexOf('fill') !== -1) {
result.warn('Replace fill to stretch, ' + 'because spec had been changed', { node: decl });
}
}
if (_this.prefixes.options.flexbox !== false) {
if (decl.prop === 'grid-row-end' && decl.value.indexOf('span') === -1) {
result.warn('IE supports only grid-row-end with span. ' + 'You should add grid: false option to Autoprefixer ' + 'and use some JS grid polyfill for full spec support', { node: decl });
}
if (decl.prop === 'grid-row') {
if (decl.value.indexOf('/') !== -1 && decl.value.indexOf('span') === -1) {
result.warn('IE supports only grid-row with / and span. ' + 'You should add grid: false option ' + 'to Autoprefixer and use some JS grid polyfill ' + 'for full spec support', { node: decl });
}
}
}
var prefixer = void 0;
if (decl.prop === 'transition' || decl.prop === 'transition-property') {
// Transition
return _this.prefixes.transition.add(decl, result);
} else if (decl.prop === 'align-self') {
// align-self flexbox or grid
var display = _this.displayType(decl);
if (display !== 'grid' && _this.prefixes.options.flexbox !== false) {
prefixer = _this.prefixes.add['align-self'];
if (prefixer && prefixer.prefixes) {
prefixer.process(decl);
}
}
if (display !== 'flex' && _this.prefixes.options.grid !== false) {
prefixer = _this.prefixes.add['grid-row-align'];
if (prefixer && prefixer.prefixes) {
return prefixer.process(decl);
}
}
} else if (decl.prop === 'justify-self') {
// justify-self flexbox or grid
var _display = _this.displayType(decl);
if (_display !== 'flex' && _this.prefixes.options.grid !== false) {
prefixer = _this.prefixes.add['grid-column-align'];
if (prefixer && prefixer.prefixes) {
return prefixer.process(decl);
}
}
} else {
// Properties
prefixer = _this.prefixes.add[decl.prop];
if (prefixer && prefixer.prefixes) {
return prefixer.process(decl);
}
}
return undefined;
});
// Values
return css.walkDecls(function (decl) {
if (_this.disabledValue(decl, result)) return;
var unprefixed = _this.prefixes.unprefixed(decl.prop);
for (var _iterator = _this.prefixes.values('add', unprefixed), _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 value = _ref;
value.process(decl, result);
}
Value.save(_this.prefixes, decl);
});
};
/**
* Remove unnecessary pefixes
*/
Processor.prototype.remove = function remove(css, result) {
var _this2 = this;
// At-rules
var resolution = this.prefixes.remove['@resolution'];
css.walkAtRules(function (rule, i) {
if (_this2.prefixes.remove['@' + rule.name]) {
if (!_this2.disabled(rule, result)) {
rule.parent.removeChild(i);
}
} else if (rule.name === 'media' && rule.params.indexOf('-resolution') !== -1 && resolution) {
resolution.clean(rule);
}
});
// Selectors
var _loop = function _loop(checker) {
css.walkRules(function (rule, i) {
if (checker.check(rule)) {
if (!_this2.disabled(rule, result)) {
rule.parent.removeChild(i);
}
}
});
};
for (var _iterator2 = this.prefixes.remove.selectors, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var checker = _ref2;
_loop(checker);
}
return css.walkDecls(function (decl, i) {
if (_this2.disabled(decl, result)) return;
var rule = decl.parent;
var unprefixed = _this2.prefixes.unprefixed(decl.prop);
// Transition
if (decl.prop === 'transition' || decl.prop === 'transition-property') {
_this2.prefixes.transition.remove(decl);
}
// Properties
if (_this2.prefixes.remove[decl.prop] && _this2.prefixes.remove[decl.prop].remove) {
var notHack = _this2.prefixes.group(decl).down(function (other) {
return _this2.prefixes.normalize(other.prop) === unprefixed;
});
if (unprefixed === 'flex-flow') {
notHack = true;
}
if (notHack && !_this2.withHackValue(decl)) {
if (decl.raw('before').indexOf('\n') > -1) {
_this2.reduceSpaces(decl);
}
rule.removeChild(i);
return;
}
}
// Values
for (var _iterator3 = _this2.prefixes.values('remove', unprefixed), _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
var _ref3;
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref3 = _iterator3[_i3++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
_ref3 = _i3.value;
}
var checker = _ref3;
if (!checker.check(decl.value)) {
continue;
}
unprefixed = checker.unprefixed;
var _notHack = _this2.prefixes.group(decl).down(function (other) {
return other.value.indexOf(unprefixed) !== -1;
});
if (_notHack) {
rule.removeChild(i);
return;
}
if (checker.clean) {
checker.clean(decl);
return;
}
}
});
};
/**
* Some rare old values, which is not in standard
*/
Processor.prototype.withHackValue = function withHackValue(decl) {
return decl.prop === '-webkit-background-clip' && decl.value === 'text';
};
/**
* Check for grid/flexbox options.
*/
Processor.prototype.disabledValue = function disabledValue(node, result) {
if (this.prefixes.options.grid === false && node.type === 'decl') {
if (node.prop === 'display' && node.value.indexOf('grid') !== -1) {
return true;
}
}
if (this.prefixes.options.flexbox === false && node.type === 'decl') {
if (node.prop === 'display' && node.value.indexOf('flex') !== -1) {
return true;
}
}
return this.disabled(node, result);
};
/**
* Check for grid/flexbox options.
*/
Processor.prototype.disabledDecl = function disabledDecl(node, result) {
if (this.prefixes.options.grid === false && node.type === 'decl') {
if (node.prop.indexOf('grid') !== -1 || node.prop === 'justify-items') {
return true;
}
}
if (this.prefixes.options.flexbox === false && node.type === 'decl') {
var other = ['order', 'justify-content', 'align-items', 'align-content'];
if (node.prop.indexOf('flex') !== -1 || other.indexOf(node.prop) !== -1) {
return true;
}
}
return this.disabled(node, result);
};
/**
* Check for control comment and global options
*/
Processor.prototype.disabled = function disabled(node, result) {
if (node._autoprefixerDisabled !== undefined) {
return node._autoprefixerDisabled;
}
if (node.nodes) {
var status = undefined;
node.each(function (i) {
if (i.type !== 'comment') {
return undefined;
}
if (/(!\s*)?autoprefixer:\s*(off|on)/i.test(i.text)) {
if (typeof status !== 'undefined') {
result.warn('Second Autoprefixer control comment ' + 'was ignored. Autoprefixer applies control ' + 'comment to whole block, not to next rules.', { node: i });
} else {
status = /on/i.test(i.text);
}
}
return undefined;
});
var value = false;
if (status !== undefined) {
value = !status;
} else if (node.parent) {
value = this.disabled(node.parent, result);
}
node._autoprefixerDisabled = value;
return node._autoprefixerDisabled;
}
if (node.parent) {
node._autoprefixerDisabled = this.disabled(node.parent, result);
return node._autoprefixerDisabled;
}
// unknown state
return false;
};
/**
* Normalize spaces in cascade declaration group
*/
Processor.prototype.reduceSpaces = function reduceSpaces(decl) {
var stop = false;
this.prefixes.group(decl).up(function () {
stop = true;
return true;
});
if (stop) {
return;
}
var parts = decl.raw('before').split('\n');
var prevMin = parts[parts.length - 1].length;
var diff = false;
this.prefixes.group(decl).down(function (other) {
parts = other.raw('before').split('\n');
var last = parts.length - 1;
if (parts[last].length > prevMin) {
if (diff === false) {
diff = parts[last].length - prevMin;
}
parts[last] = parts[last].slice(0, -diff);
other.raws.before = parts.join('\n');
}
});
};
/**
* Is it flebox or grid rule
*/
Processor.prototype.displayType = function displayType(decl) {
for (var _iterator4 = decl.parent.nodes, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
var _ref4;
if (_isArray4) {
if (_i4 >= _iterator4.length) break;
_ref4 = _iterator4[_i4++];
} else {
_i4 = _iterator4.next();
if (_i4.done) break;
_ref4 = _i4.value;
}
var i = _ref4;
if (i.prop !== 'display') {
continue;
}
if (i.value.indexOf('flex') !== -1) {
return 'flex';
}
if (i.value.indexOf('grid') !== -1) {
return 'grid';
}
}
return false;
};
return Processor;
}();
module.exports = Processor;

View File

@@ -0,0 +1,158 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Prefixer = require('./prefixer');
var utils = require('./utils');
var n2f = require('num2fraction');
var regexp = /(min|max)-resolution\s*:\s*\d*\.?\d+(dppx|dpi)/gi;
var split = /(min|max)-resolution(\s*:\s*)(\d*\.?\d+)(dppx|dpi)/i;
var Resolution = function (_Prefixer) {
_inherits(Resolution, _Prefixer);
function Resolution() {
_classCallCheck(this, Resolution);
return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
}
/**
* Return prefixed query name
*/
Resolution.prototype.prefixName = function prefixName(prefix, name) {
var newName = prefix === '-moz-' ? name + '--moz-device-pixel-ratio' : prefix + name + '-device-pixel-ratio';
return newName;
};
/**
* Return prefixed query
*/
Resolution.prototype.prefixQuery = function prefixQuery(prefix, name, colon, value, units) {
if (units === 'dpi') {
value = Number(value / 96);
}
if (prefix === '-o-') {
value = n2f(value);
}
return this.prefixName(prefix, name) + colon + value;
};
/**
* Remove prefixed queries
*/
Resolution.prototype.clean = function clean(rule) {
var _this2 = this;
if (!this.bad) {
this.bad = [];
for (var _iterator = this.prefixes, _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 prefix = _ref;
this.bad.push(this.prefixName(prefix, 'min'));
this.bad.push(this.prefixName(prefix, 'max'));
}
}
rule.params = utils.editList(rule.params, function (queries) {
return queries.filter(function (query) {
return _this2.bad.every(function (i) {
return query.indexOf(i) === -1;
});
});
});
};
/**
* Add prefixed queries
*/
Resolution.prototype.process = function process(rule) {
var _this3 = this;
var parent = this.parentPrefix(rule);
var prefixes = parent ? [parent] : this.prefixes;
rule.params = utils.editList(rule.params, function (origin, prefixed) {
for (var _iterator2 = origin, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var query = _ref2;
if (query.indexOf('min-resolution') === -1 && query.indexOf('max-resolution') === -1) {
prefixed.push(query);
continue;
}
var _loop = function _loop(prefix) {
if (prefix === '-moz-' && rule.params.indexOf('dpi') !== -1) {
return 'continue';
}
var processed = query.replace(regexp, function (str) {
var parts = str.match(split);
return _this3.prefixQuery(prefix, parts[1], parts[2], parts[3], parts[4]);
});
prefixed.push(processed);
};
for (var _iterator3 = prefixes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
var _ref3;
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref3 = _iterator3[_i3++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
_ref3 = _i3.value;
}
var prefix = _ref3;
var _ret = _loop(prefix);
if (_ret === 'continue') continue;
}
prefixed.push(query);
}
return utils.uniq(prefixed);
});
};
return Resolution;
}(Prefixer);
module.exports = Resolution;

View File

@@ -0,0 +1,178 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var OldSelector = require('./old-selector');
var Prefixer = require('./prefixer');
var Browsers = require('./browsers');
var utils = require('./utils');
var Selector = function (_Prefixer) {
_inherits(Selector, _Prefixer);
function Selector(name, prefixes, all) {
_classCallCheck(this, Selector);
var _this = _possibleConstructorReturn(this, _Prefixer.call(this, name, prefixes, all));
_this.regexpCache = {};
return _this;
}
/**
* Is rule selectors need to be prefixed
*/
Selector.prototype.check = function check(rule) {
if (rule.selector.indexOf(this.name) !== -1) {
return !!rule.selector.match(this.regexp());
}
return false;
};
/**
* Return prefixed version of selector
*/
Selector.prototype.prefixed = function prefixed(prefix) {
return this.name.replace(/^([^\w]*)/, '$1' + prefix);
};
/**
* Lazy loadRegExp for name
*/
Selector.prototype.regexp = function regexp(prefix) {
if (this.regexpCache[prefix]) {
return this.regexpCache[prefix];
}
var name = prefix ? this.prefixed(prefix) : this.name;
this.regexpCache[prefix] = new RegExp('(^|[^:"\'=])' + utils.escapeRegexp(name), 'gi');
return this.regexpCache[prefix];
};
/**
* All possible prefixes
*/
Selector.prototype.possible = function possible() {
return Browsers.prefixes();
};
/**
* Return all possible selector prefixes
*/
Selector.prototype.prefixeds = function prefixeds(rule) {
if (rule._autoprefixerPrefixeds) {
return rule._autoprefixerPrefixeds;
}
var prefixeds = {};
for (var _iterator = this.possible(), _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 prefix = _ref;
prefixeds[prefix] = this.replace(rule.selector, prefix);
}
rule._autoprefixerPrefixeds = prefixeds;
return rule._autoprefixerPrefixeds;
};
/**
* Is rule already prefixed before
*/
Selector.prototype.already = function already(rule, prefixeds, prefix) {
var index = rule.parent.index(rule) - 1;
while (index >= 0) {
var before = rule.parent.nodes[index];
if (before.type !== 'rule') {
return false;
}
var some = false;
for (var key in prefixeds) {
var prefixed = prefixeds[key];
if (before.selector === prefixed) {
if (prefix === key) {
return true;
} else {
some = true;
break;
}
}
}
if (!some) {
return false;
}
index -= 1;
}
return false;
};
/**
* Replace selectors by prefixed one
*/
Selector.prototype.replace = function replace(selector, prefix) {
return selector.replace(this.regexp(), '$1' + this.prefixed(prefix));
};
/**
* Clone and add prefixes for at-rule
*/
Selector.prototype.add = function add(rule, prefix) {
var prefixeds = this.prefixeds(rule);
if (this.already(rule, prefixeds, prefix)) {
return;
}
var cloned = this.clone(rule, { selector: prefixeds[prefix] });
rule.parent.insertBefore(rule, cloned);
};
/**
* Return function to fast find prefixed selector
*/
Selector.prototype.old = function old(prefix) {
return new OldSelector(this, prefix);
};
return Selector;
}(Prefixer);
module.exports = Selector;

View File

@@ -0,0 +1,380 @@
'use strict';
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; };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Browsers = require('./browsers');
var brackets = require('./brackets');
var Value = require('./value');
var utils = require('./utils');
var postcss = require('postcss');
var supported = [];
var data = require('caniuse-lite').feature(require('caniuse-lite/data/features/css-featurequeries.js'));
for (var browser in data.stats) {
var versions = data.stats[browser];
for (var version in versions) {
var support = versions[version];
if (/y/.test(support)) {
supported.push(browser + ' ' + version);
}
}
}
var Supports = function () {
function Supports(Prefixes, all) {
_classCallCheck(this, Supports);
this.Prefixes = Prefixes;
this.all = all;
}
/**
* Return prefixer only with @supports supported browsers
*/
Supports.prototype.prefixer = function prefixer() {
if (this.prefixerCache) {
return this.prefixerCache;
}
var filtered = this.all.browsers.selected.filter(function (i) {
return supported.indexOf(i) !== -1;
});
var browsers = new Browsers(this.all.browsers.data, filtered, this.all.options);
this.prefixerCache = new this.Prefixes(this.all.data, browsers, this.all.options);
return this.prefixerCache;
};
/**
* Parse string into declaration property and value
*/
Supports.prototype.parse = function parse(str) {
var _str$split = str.split(':'),
prop = _str$split[0],
value = _str$split[1];
if (!value) value = '';
return [prop.trim(), value.trim()];
};
/**
* Create virtual rule to process it by prefixer
*/
Supports.prototype.virtual = function virtual(str) {
var _parse = this.parse(str),
prop = _parse[0],
value = _parse[1];
var rule = postcss.parse('a{}').first;
rule.append({ prop: prop, value: value, raws: { before: '' } });
return rule;
};
/**
* Return array of Declaration with all necessary prefixes
*/
Supports.prototype.prefixed = function prefixed(str) {
var rule = this.virtual(str);
if (this.disabled(rule.first)) {
return rule.nodes;
}
var prefixer = this.prefixer().add[rule.first.prop];
prefixer && prefixer.process && prefixer.process(rule.first);
for (var _iterator = rule.nodes, _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 decl = _ref;
for (var _iterator2 = this.prefixer().values('add', rule.first.prop), _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var value = _ref2;
value.process(decl);
}
Value.save(this.all, decl);
}
return rule.nodes;
};
/**
* Return true if brackets node is "not" word
*/
Supports.prototype.isNot = function isNot(node) {
return typeof node === 'string' && /not\s*/i.test(node);
};
/**
* Return true if brackets node is "or" word
*/
Supports.prototype.isOr = function isOr(node) {
return typeof node === 'string' && /\s*or\s*/i.test(node);
};
/**
* Return true if brackets node is (prop: value)
*/
Supports.prototype.isProp = function isProp(node) {
return (typeof node === 'undefined' ? 'undefined' : _typeof(node)) === 'object' && node.length === 1 && typeof node[0] === 'string';
};
/**
* Return true if prefixed property has no unprefixed
*/
Supports.prototype.isHack = function isHack(all, unprefixed) {
var check = new RegExp('(\\(|\\s)' + utils.escapeRegexp(unprefixed) + ':');
return !check.test(all);
};
/**
* Return true if we need to remove node
*/
Supports.prototype.toRemove = function toRemove(str, all) {
var _parse2 = this.parse(str),
prop = _parse2[0],
value = _parse2[1];
var unprefixed = this.all.unprefixed(prop);
var cleaner = this.all.cleaner();
if (cleaner.remove[prop] && cleaner.remove[prop].remove && !this.isHack(all, unprefixed)) {
return true;
}
for (var _iterator3 = cleaner.values('remove', unprefixed), _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
var _ref3;
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref3 = _iterator3[_i3++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
_ref3 = _i3.value;
}
var checker = _ref3;
if (checker.check(value)) {
return true;
}
}
return false;
};
/**
* Remove all unnecessary prefixes
*/
Supports.prototype.remove = function remove(nodes, all) {
var i = 0;
while (i < nodes.length) {
if (!this.isNot(nodes[i - 1]) && this.isProp(nodes[i]) && this.isOr(nodes[i + 1])) {
if (this.toRemove(nodes[i][0], all)) {
nodes.splice(i, 2);
continue;
}
i += 2;
continue;
}
if (_typeof(nodes[i]) === 'object') {
nodes[i] = this.remove(nodes[i], all);
}
i += 1;
}
return nodes;
};
/**
* Clean brackets with one child
*/
Supports.prototype.cleanBrackets = function cleanBrackets(nodes) {
var _this = this;
return nodes.map(function (i) {
if ((typeof i === 'undefined' ? 'undefined' : _typeof(i)) !== 'object') {
return i;
}
if (i.length === 1 && _typeof(i[0]) === 'object') {
return _this.cleanBrackets(i[0]);
}
return _this.cleanBrackets(i);
});
};
/**
* Add " or " between properties and convert it to brackets format
*/
Supports.prototype.convert = function convert(progress) {
var result = [''];
for (var _iterator4 = progress, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
var _ref4;
if (_isArray4) {
if (_i4 >= _iterator4.length) break;
_ref4 = _iterator4[_i4++];
} else {
_i4 = _iterator4.next();
if (_i4.done) break;
_ref4 = _i4.value;
}
var i = _ref4;
result.push([i.prop + ': ' + i.value]);
result.push(' or ');
}
result[result.length - 1] = '';
return result;
};
/**
* Compress value functions into a string nodes
*/
Supports.prototype.normalize = function normalize(nodes) {
var _this2 = this;
if ((typeof nodes === 'undefined' ? 'undefined' : _typeof(nodes)) !== 'object') {
return nodes;
}
nodes = nodes.filter(function (i) {
return i !== '';
});
if (typeof nodes[0] === 'string' && nodes[0].indexOf(':') !== -1) {
return [brackets.stringify(nodes)];
}
return nodes.map(function (i) {
return _this2.normalize(i);
});
};
/**
* Add prefixes
*/
Supports.prototype.add = function add(nodes, all) {
var _this3 = this;
return nodes.map(function (i) {
if (_this3.isProp(i)) {
var prefixed = _this3.prefixed(i[0]);
if (prefixed.length > 1) {
return _this3.convert(prefixed);
}
return i;
}
if ((typeof i === 'undefined' ? 'undefined' : _typeof(i)) === 'object') {
return _this3.add(i, all);
}
return i;
});
};
/**
* Add prefixed declaration
*/
Supports.prototype.process = function process(rule) {
var ast = brackets.parse(rule.params);
ast = this.normalize(ast);
ast = this.remove(ast, rule.params);
ast = this.add(ast, rule.params);
ast = this.cleanBrackets(ast);
rule.params = brackets.stringify(ast);
};
/**
* Check global options
*/
Supports.prototype.disabled = function disabled(node) {
if (this.all.options.grid === false) {
if (node.prop === 'display' && node.value.indexOf('grid') !== -1) {
return true;
}
if (node.prop.indexOf('grid') !== -1 || node.prop === 'justify-items') {
return true;
}
}
if (this.all.options.flexbox === false) {
if (node.prop === 'display' && node.value.indexOf('flex') !== -1) {
return true;
}
var other = ['order', 'justify-content', 'align-items', 'align-content'];
if (node.prop.indexOf('flex') !== -1 || other.indexOf(node.prop) !== -1) {
return true;
}
}
return false;
};
return Supports;
}();
module.exports = Supports;

View File

@@ -0,0 +1,449 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var parser = require('postcss-value-parser');
var vendor = require('postcss/lib/vendor');
var list = require('postcss/lib/list');
var Transition = function () {
function Transition(prefixes) {
_classCallCheck(this, Transition);
Object.defineProperty(this, 'props', {
enumerable: true,
writable: true,
value: ['transition', 'transition-property']
});
this.prefixes = prefixes;
}
/**
* Process transition and add prefies for all necessary properties
*/
Transition.prototype.add = function add(decl, result) {
var _this = this;
var prefix = void 0,
prop = void 0;
var declPrefixes = this.prefixes.add[decl.prop] && this.prefixes.add[decl.prop].prefixes || [];
var params = this.parse(decl.value);
var names = params.map(function (i) {
return _this.findProp(i);
});
var added = [];
if (names.some(function (i) {
return i[0] === '-';
})) {
return;
}
for (var _iterator = params, _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 param = _ref;
prop = this.findProp(param);
if (prop[0] === '-') {
continue;
}
var prefixer = this.prefixes.add[prop];
if (!prefixer || !prefixer.prefixes) {
continue;
}
for (var _iterator3 = prefixer.prefixes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
prefix = _iterator3[_i3++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
prefix = _i3.value;
}
var prefixed = this.prefixes.prefixed(prop, prefix);
if (prefixed !== '-ms-transform' && names.indexOf(prefixed) === -1) {
if (!this.disabled(prop, prefix)) {
added.push(this.clone(prop, prefixed, param));
}
}
}
}
params = params.concat(added);
var value = this.stringify(params);
var webkitClean = this.stringify(this.cleanFromUnprefixed(params, '-webkit-'));
if (declPrefixes.indexOf('-webkit-') !== -1) {
this.cloneBefore(decl, '-webkit-' + decl.prop, webkitClean);
}
this.cloneBefore(decl, decl.prop, webkitClean);
if (declPrefixes.indexOf('-o-') !== -1) {
var operaClean = this.stringify(this.cleanFromUnprefixed(params, '-o-'));
this.cloneBefore(decl, '-o-' + decl.prop, operaClean);
}
for (var _iterator2 = declPrefixes, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
prefix = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
prefix = _i2.value;
}
if (prefix !== '-webkit-' && prefix !== '-o-') {
var prefixValue = this.stringify(this.cleanOtherPrefixes(params, prefix));
this.cloneBefore(decl, prefix + decl.prop, prefixValue);
}
}
if (value !== decl.value && !this.already(decl, decl.prop, value)) {
this.checkForWarning(result, decl);
decl.cloneBefore();
decl.value = value;
}
};
/**
* Find property name
*/
Transition.prototype.findProp = function findProp(param) {
var prop = param[0].value;
if (/^\d/.test(prop)) {
for (var i = 0; i < param.length; i++) {
var token = param[i];
if (i !== 0 && token.type === 'word') {
return token.value;
}
}
}
return prop;
};
/**
* Does we aready have this declaration
*/
Transition.prototype.already = function already(decl, prop, value) {
return decl.parent.some(function (i) {
return i.prop === prop && i.value === value;
});
};
/**
* Add declaration if it is not exist
*/
Transition.prototype.cloneBefore = function cloneBefore(decl, prop, value) {
if (!this.already(decl, prop, value)) {
decl.cloneBefore({ prop: prop, value: value });
}
};
/**
* Show transition-property warning
*/
Transition.prototype.checkForWarning = function checkForWarning(result, decl) {
if (decl.prop !== 'transition-property') {
return;
}
decl.parent.each(function (i) {
if (i.type !== 'decl') {
return undefined;
}
if (i.prop.indexOf('transition-') !== 0) {
return undefined;
}
if (i.prop === 'transition-property') {
return undefined;
}
if (list.comma(i.value).length > 1) {
decl.warn(result, 'Replace transition-property to transition, ' + 'because Autoprefixer could not support ' + 'any cases of transition-property ' + 'and other transition-*');
}
return false;
});
};
/**
* Process transition and remove all unnecessary properties
*/
Transition.prototype.remove = function remove(decl) {
var _this2 = this;
var params = this.parse(decl.value);
params = params.filter(function (i) {
var prop = _this2.prefixes.remove[_this2.findProp(i)];
return !prop || !prop.remove;
});
var value = this.stringify(params);
if (decl.value === value) {
return;
}
if (params.length === 0) {
decl.remove();
return;
}
var double = decl.parent.some(function (i) {
return i.prop === decl.prop && i.value === value;
});
var smaller = decl.parent.some(function (i) {
return i !== decl && i.prop === decl.prop && i.value.length > value.length;
});
if (double || smaller) {
decl.remove();
return;
}
decl.value = value;
};
/**
* Parse properties list to array
*/
Transition.prototype.parse = function parse(value) {
var ast = parser(value);
var result = [];
var param = [];
for (var _iterator4 = ast.nodes, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
var _ref2;
if (_isArray4) {
if (_i4 >= _iterator4.length) break;
_ref2 = _iterator4[_i4++];
} else {
_i4 = _iterator4.next();
if (_i4.done) break;
_ref2 = _i4.value;
}
var node = _ref2;
param.push(node);
if (node.type === 'div' && node.value === ',') {
result.push(param);
param = [];
}
}
result.push(param);
return result.filter(function (i) {
return i.length > 0;
});
};
/**
* Return properties string from array
*/
Transition.prototype.stringify = function stringify(params) {
if (params.length === 0) {
return '';
}
var nodes = [];
for (var _iterator5 = params, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) {
var _ref3;
if (_isArray5) {
if (_i5 >= _iterator5.length) break;
_ref3 = _iterator5[_i5++];
} else {
_i5 = _iterator5.next();
if (_i5.done) break;
_ref3 = _i5.value;
}
var param = _ref3;
if (param[param.length - 1].type !== 'div') {
param.push(this.div(params));
}
nodes = nodes.concat(param);
}
if (nodes[0].type === 'div') {
nodes = nodes.slice(1);
}
if (nodes[nodes.length - 1].type === 'div') {
nodes = nodes.slice(0, +-2 + 1 || undefined);
}
return parser.stringify({ nodes: nodes });
};
/**
* Return new param array with different name
*/
Transition.prototype.clone = function clone(origin, name, param) {
var result = [];
var changed = false;
for (var _iterator6 = param, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) {
var _ref4;
if (_isArray6) {
if (_i6 >= _iterator6.length) break;
_ref4 = _iterator6[_i6++];
} else {
_i6 = _iterator6.next();
if (_i6.done) break;
_ref4 = _i6.value;
}
var i = _ref4;
if (!changed && i.type === 'word' && i.value === origin) {
result.push({ type: 'word', value: name });
changed = true;
} else {
result.push(i);
}
}
return result;
};
/**
* Find or create seperator
*/
Transition.prototype.div = function div(params) {
for (var _iterator7 = params, _isArray7 = Array.isArray(_iterator7), _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : _iterator7[Symbol.iterator]();;) {
var _ref5;
if (_isArray7) {
if (_i7 >= _iterator7.length) break;
_ref5 = _iterator7[_i7++];
} else {
_i7 = _iterator7.next();
if (_i7.done) break;
_ref5 = _i7.value;
}
var param = _ref5;
for (var _iterator8 = param, _isArray8 = Array.isArray(_iterator8), _i8 = 0, _iterator8 = _isArray8 ? _iterator8 : _iterator8[Symbol.iterator]();;) {
var _ref6;
if (_isArray8) {
if (_i8 >= _iterator8.length) break;
_ref6 = _iterator8[_i8++];
} else {
_i8 = _iterator8.next();
if (_i8.done) break;
_ref6 = _i8.value;
}
var node = _ref6;
if (node.type === 'div' && node.value === ',') {
return node;
}
}
}
return { type: 'div', value: ',', after: ' ' };
};
Transition.prototype.cleanOtherPrefixes = function cleanOtherPrefixes(params, prefix) {
var _this3 = this;
return params.filter(function (param) {
var current = vendor.prefix(_this3.findProp(param));
return current === '' || current === prefix;
});
};
/**
* Remove all non-webkit prefixes and unprefixed params if we have prefixed
*/
Transition.prototype.cleanFromUnprefixed = function cleanFromUnprefixed(params, prefix) {
var _this4 = this;
var remove = params.map(function (i) {
return _this4.findProp(i);
}).filter(function (i) {
return i.slice(0, prefix.length) === prefix;
}).map(function (i) {
return _this4.prefixes.unprefixed(i);
});
var result = [];
for (var _iterator9 = params, _isArray9 = Array.isArray(_iterator9), _i9 = 0, _iterator9 = _isArray9 ? _iterator9 : _iterator9[Symbol.iterator]();;) {
var _ref7;
if (_isArray9) {
if (_i9 >= _iterator9.length) break;
_ref7 = _iterator9[_i9++];
} else {
_i9 = _iterator9.next();
if (_i9.done) break;
_ref7 = _i9.value;
}
var param = _ref7;
var prop = this.findProp(param);
var p = vendor.prefix(prop);
if (remove.indexOf(prop) === -1 && (p === prefix || p === '')) {
result.push(param);
}
}
return result;
};
/**
* Check property for disabled by option
*/
Transition.prototype.disabled = function disabled(prop, prefix) {
var other = ['order', 'justify-content', 'align-self', 'align-content'];
if (prop.indexOf('flex') !== -1 || other.indexOf(prop) !== -1) {
if (this.prefixes.options.flexbox === false) {
return true;
}
if (this.prefixes.options.flexbox === 'no-2009') {
return prefix.indexOf('2009') !== -1;
}
}
return undefined;
};
return Transition;
}();
module.exports = Transition;

View File

@@ -0,0 +1,93 @@
'use strict';
var list = require('postcss/lib/list');
module.exports = {
/**
* Throw special error, to tell beniary,
* that this error is from Autoprefixer.
*/
error: function error(text) {
var err = new Error(text);
err.autoprefixer = true;
throw err;
},
/**
* Return array, that doesnt contain duplicates.
*/
uniq: function uniq(array) {
var filtered = [];
for (var _iterator = array, _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 (filtered.indexOf(i) === -1) {
filtered.push(i);
}
}
return filtered;
},
/**
* Return "-webkit-" on "-webkit- old"
*/
removeNote: function removeNote(string) {
if (string.indexOf(' ') === -1) {
return string;
}
return string.split(' ')[0];
},
/**
* Escape RegExp symbols
*/
escapeRegexp: function escapeRegexp(string) {
return string.replace(/[.?*+\^\$\[\]\\(){}|\-]/g, '\\$&');
},
/**
* Return regexp to check, that CSS string contain word
*/
regexp: function regexp(word) {
var escape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (escape) {
word = this.escapeRegexp(word);
}
return new RegExp('(^|[\\s,(])(' + word + '($|[\\s(,]))', 'gi');
},
/**
* Change comma list
*/
editList: function editList(value, callback) {
var origin = list.comma(value);
var changed = callback(origin, []);
if (origin === changed) {
return value;
}
var join = value.match(/,\s*/);
join = join ? join[0] : ', ';
return changed.join(join);
}
};

View File

@@ -0,0 +1,161 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Prefixer = require('./prefixer');
var OldValue = require('./old-value');
var utils = require('./utils');
var vendor = require('postcss/lib/vendor');
var Value = function (_Prefixer) {
_inherits(Value, _Prefixer);
function Value() {
_classCallCheck(this, Value);
return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
}
/**
* Clone decl for each prefixed values
*/
Value.save = function save(prefixes, decl) {
var _this2 = this;
var prop = decl.prop;
var result = [];
var _loop = function _loop(prefix) {
var value = decl._autoprefixerValues[prefix];
if (value === decl.value) {
return 'continue';
}
var item = void 0;
var propPrefix = vendor.prefix(prop);
if (propPrefix === '-pie-') {
return 'continue';
}
if (propPrefix === prefix) {
item = decl.value = value;
result.push(item);
return 'continue';
}
var prefixed = prefixes.prefixed(prop, prefix);
var rule = decl.parent;
if (!rule.every(function (i) {
return i.prop !== prefixed;
})) {
result.push(item);
return 'continue';
}
var trimmed = value.replace(/\s+/, ' ');
var already = rule.some(function (i) {
return i.prop === decl.prop && i.value.replace(/\s+/, ' ') === trimmed;
});
if (already) {
result.push(item);
return 'continue';
}
var cloned = _this2.clone(decl, { value: value });
item = decl.parent.insertBefore(decl, cloned);
result.push(item);
};
for (var prefix in decl._autoprefixerValues) {
var _ret = _loop(prefix);
if (_ret === 'continue') continue;
}
return result;
};
/**
* Is declaration need to be prefixed
*/
Value.prototype.check = function check(decl) {
var value = decl.value;
if (value.indexOf(this.name) === -1) {
return false;
}
return !!value.match(this.regexp());
};
/**
* Lazy regexp loading
*/
Value.prototype.regexp = function regexp() {
return this.regexpCache || (this.regexpCache = utils.regexp(this.name));
};
/**
* Add prefix to values in string
*/
Value.prototype.replace = function replace(string, prefix) {
return string.replace(this.regexp(), '$1' + prefix + '$2');
};
/**
* Get value with comments if it was not changed
*/
Value.prototype.value = function value(decl) {
if (decl.raws.value && decl.raws.value.value === decl.value) {
return decl.raws.value.raw;
} else {
return decl.value;
}
};
/**
* Save values with next prefixed token
*/
Value.prototype.add = function add(decl, prefix) {
if (!decl._autoprefixerValues) {
decl._autoprefixerValues = {};
}
var value = decl._autoprefixerValues[prefix] || this.value(decl);
value = this.replace(value, prefix);
if (value) {
decl._autoprefixerValues[prefix] = value;
}
};
/**
* Return function to fast find prefixed value
*/
Value.prototype.old = function old(prefix) {
return new OldValue(this.name, prefix + this.name);
};
return Value;
}(Prefixer);
module.exports = Value;