Comparing version 4.1.2 to 4.1.3
@@ -0,1 +1,4 @@ | ||
## 4.1.3 | ||
* Add Promise polyfill for node.js 0.10 and IE. | ||
## 4.1.2 | ||
@@ -2,0 +5,0 @@ * List helpers can be accessed independently `var space = postcss.list.space`. |
@@ -1,11 +0,15 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var Container = _interopRequire(require("./container")); | ||
exports.__esModule = true; | ||
var _Container2 = require('./container'); | ||
var _Container3 = _interopRequireWildcard(_Container2); | ||
var AtRule = (function (_Container) { | ||
@@ -15,4 +19,4 @@ function AtRule(defaults) { | ||
this.type = "atrule"; | ||
_Container.call(this, defaults); | ||
this.type = 'atrule'; | ||
} | ||
@@ -23,9 +27,9 @@ | ||
AtRule.prototype.stringify = function stringify(builder, semicolon) { | ||
var name = "@" + this.name; | ||
var params = this.params ? this.stringifyRaw("params") : ""; | ||
var name = '@' + this.name; | ||
var params = this.params ? this.stringifyRaw('params') : ''; | ||
if (typeof this.afterName !== "undefined") { | ||
if (typeof this.afterName !== 'undefined') { | ||
name += this.afterName; | ||
} else if (params) { | ||
name += " "; | ||
name += ' '; | ||
} | ||
@@ -36,5 +40,5 @@ | ||
} else { | ||
var before = this.style("before"); | ||
var before = this.style('before'); | ||
if (before) builder(before); | ||
var end = (this.between || "") + (semicolon ? ";" : ""); | ||
var end = (this.between || '') + (semicolon ? ';' : ''); | ||
builder(name + params + end, this); | ||
@@ -65,4 +69,5 @@ } | ||
return AtRule; | ||
})(Container); | ||
})(_Container3['default']); | ||
module.exports = AtRule; | ||
exports['default'] = AtRule; | ||
module.exports = exports['default']; |
@@ -1,11 +0,15 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var Node = _interopRequire(require("./node")); | ||
exports.__esModule = true; | ||
var _Node2 = require('./node'); | ||
var _Node3 = _interopRequireWildcard(_Node2); | ||
var Comment = (function (_Node) { | ||
@@ -15,4 +19,4 @@ function Comment(defaults) { | ||
this.type = "comment"; | ||
_Node.call(this, defaults); | ||
this.type = 'comment'; | ||
} | ||
@@ -23,12 +27,13 @@ | ||
Comment.prototype.stringify = function stringify(builder) { | ||
var before = this.style("before"); | ||
var before = this.style('before'); | ||
if (before) builder(before); | ||
var left = this.style("left", "commentLeft"); | ||
var right = this.style("right", "commentRight"); | ||
builder("/*" + left + this.text + right + "*/", this); | ||
var left = this.style('left', 'commentLeft'); | ||
var right = this.style('right', 'commentRight'); | ||
builder('/*' + left + this.text + right + '*/', this); | ||
}; | ||
return Comment; | ||
})(Node); | ||
})(_Node3['default']); | ||
module.exports = Comment; | ||
exports['default'] = Comment; | ||
module.exports = exports['default']; |
@@ -1,17 +0,25 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var Declaration = _interopRequire(require("./declaration")); | ||
exports.__esModule = true; | ||
var Comment = _interopRequire(require("./comment")); | ||
var _Declaration = require('./declaration'); | ||
var Node = _interopRequire(require("./node")); | ||
var _Declaration2 = _interopRequireWildcard(_Declaration); | ||
var _Comment = require('./comment'); | ||
var _Comment2 = _interopRequireWildcard(_Comment); | ||
var _Node2 = require('./node'); | ||
var _Node3 = _interopRequireWildcard(_Node2); | ||
var Container = (function (_Node) { | ||
@@ -34,7 +42,7 @@ function Container() { | ||
while (last > 0) { | ||
if (this.nodes[last].type !== "comment") break; | ||
if (this.nodes[last].type !== 'comment') break; | ||
last -= 1; | ||
} | ||
var semicolon = this.style("semicolon"); | ||
var semicolon = this.style('semicolon'); | ||
for (i = 0; i < this.nodes.length; i++) { | ||
@@ -46,7 +54,7 @@ this.nodes[i].stringify(builder, last !== i || semicolon); | ||
Container.prototype.stringifyBlock = function stringifyBlock(builder, start) { | ||
var before = this.style("before"); | ||
var before = this.style('before'); | ||
if (before) builder(before); | ||
var between = this.style("between", "beforeOpen"); | ||
builder(start + between + "{", this, "start"); | ||
var between = this.style('between', 'beforeOpen'); | ||
builder(start + between + '{', this, 'start'); | ||
@@ -56,9 +64,9 @@ var after = undefined; | ||
this.stringifyContent(builder); | ||
after = this.style("after"); | ||
after = this.style('after'); | ||
} else { | ||
after = this.style("after", "emptyBody"); | ||
after = this.style('after', 'emptyBody'); | ||
} | ||
if (after) builder(after); | ||
builder("}", this, "end"); | ||
builder('}', this, 'end'); | ||
}; | ||
@@ -115,3 +123,3 @@ | ||
return this.eachInside(function (child, i) { | ||
if (child.type === "decl") { | ||
if (child.type === 'decl') { | ||
var result = callback(child, i); | ||
@@ -123,3 +131,3 @@ if (result === false) return result; | ||
return this.eachInside(function (child, i) { | ||
if (child.type === "decl" && prop.test(child.prop)) { | ||
if (child.type === 'decl' && prop.test(child.prop)) { | ||
var result = callback(child, i); | ||
@@ -131,3 +139,3 @@ if (result === false) return result; | ||
return this.eachInside(function (child, i) { | ||
if (child.type === "decl" && child.prop === prop) { | ||
if (child.type === 'decl' && child.prop === prop) { | ||
var result = callback(child, i); | ||
@@ -142,3 +150,3 @@ if (result === false) return result; | ||
return this.eachInside(function (child, i) { | ||
if (child.type === "rule") { | ||
if (child.type === 'rule') { | ||
var result = callback(child, i); | ||
@@ -154,3 +162,3 @@ if (result === false) return result; | ||
return this.eachInside(function (child, i) { | ||
if (child.type === "atrule") { | ||
if (child.type === 'atrule') { | ||
var result = callback(child, i); | ||
@@ -162,3 +170,3 @@ if (result === false) return result; | ||
return this.eachInside(function (child, i) { | ||
if (child.type === "atrule" && name.test(child.name)) { | ||
if (child.type === 'atrule' && name.test(child.name)) { | ||
var result = callback(child, i); | ||
@@ -170,3 +178,3 @@ if (result === false) return result; | ||
return this.eachInside(function (child, i) { | ||
if (child.type === "atrule" && child.name === name) { | ||
if (child.type === 'atrule' && child.name === name) { | ||
var result = callback(child, i); | ||
@@ -181,3 +189,3 @@ if (result === false) return result; | ||
return this.eachInside(function (child, i) { | ||
if (child.type === "comment") { | ||
if (child.type === 'comment') { | ||
var result = callback(child, i); | ||
@@ -209,16 +217,16 @@ if (result === false) return result; | ||
Container.prototype.prepend = function prepend(child) { | ||
var nodes = this.normalize(child, this.first, "prepend").reverse(); | ||
for (var _iterator = nodes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
var nodes = this.normalize(child, this.first, 'prepend').reverse(); | ||
for (var _iterator2 = nodes, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { | ||
var _ref2; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
if (_isArray2) { | ||
if (_i2 >= _iterator2.length) break; | ||
_ref2 = _iterator2[_i2++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
_i2 = _iterator2.next(); | ||
if (_i2.done) break; | ||
_ref2 = _i2.value; | ||
} | ||
var node = _ref; | ||
var node = _ref2; | ||
this.nodes.unshift(node); | ||
@@ -235,17 +243,17 @@ }for (var id in this.indexes) { | ||
var type = exist === 0 ? "prepend" : false; | ||
var type = exist === 0 ? 'prepend' : false; | ||
var nodes = this.normalize(add, this.nodes[exist], type).reverse(); | ||
for (var _iterator = nodes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
for (var _iterator3 = nodes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { | ||
var _ref3; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
if (_isArray3) { | ||
if (_i3 >= _iterator3.length) break; | ||
_ref3 = _iterator3[_i3++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
_i3 = _iterator3.next(); | ||
if (_i3.done) break; | ||
_ref3 = _i3.value; | ||
} | ||
var node = _ref; | ||
var node = _ref3; | ||
this.nodes.splice(exist, 0, node); | ||
@@ -267,15 +275,15 @@ }var index = undefined; | ||
var nodes = this.normalize(add, this.nodes[exist]).reverse(); | ||
for (var _iterator = nodes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
for (var _iterator4 = nodes, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) { | ||
var _ref4; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
if (_isArray4) { | ||
if (_i4 >= _iterator4.length) break; | ||
_ref4 = _iterator4[_i4++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
_i4 = _iterator4.next(); | ||
if (_i4.done) break; | ||
_ref4 = _i4.value; | ||
} | ||
var node = _ref; | ||
var node = _ref4; | ||
this.nodes.splice(exist + 1, 0, node); | ||
@@ -310,15 +318,15 @@ }var index = undefined; | ||
Container.prototype.removeAll = function removeAll() { | ||
for (var _iterator = this.nodes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
for (var _iterator5 = this.nodes, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) { | ||
var _ref5; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
if (_isArray5) { | ||
if (_i5 >= _iterator5.length) break; | ||
_ref5 = _iterator5[_i5++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
_i5 = _iterator5.next(); | ||
if (_i5.done) break; | ||
_ref5 = _i5.value; | ||
} | ||
var node = _ref; | ||
var node = _ref5; | ||
node.parent = undefined; | ||
@@ -354,3 +362,3 @@ }this.nodes = []; | ||
Container.prototype.index = function index(child) { | ||
if (typeof child === "number") { | ||
if (typeof child === 'number') { | ||
return child; | ||
@@ -365,7 +373,7 @@ } else { | ||
if (typeof nodes === "string") { | ||
var parse = require("./parse"); | ||
if (typeof nodes === 'string') { | ||
var parse = require('./parse'); | ||
nodes = parse(nodes).nodes; | ||
} else if (!Array.isArray(nodes)) { | ||
if (nodes.type === "root") { | ||
if (nodes.type === 'root') { | ||
nodes = nodes.nodes; | ||
@@ -375,16 +383,16 @@ } else if (nodes.type) { | ||
} else if (nodes.prop) { | ||
if (typeof nodes.value === "undefined") { | ||
throw "value field is missed in node creation"; | ||
if (typeof nodes.value === 'undefined') { | ||
throw 'value field is missed in node creation'; | ||
} | ||
nodes = [new Declaration(nodes)]; | ||
nodes = [new _Declaration2['default'](nodes)]; | ||
} else if (nodes.selector) { | ||
var Rule = require("./rule"); | ||
var Rule = require('./rule'); | ||
nodes = [new Rule(nodes)]; | ||
} else if (nodes.name) { | ||
var AtRule = require("./at-rule"); | ||
var AtRule = require('./at-rule'); | ||
nodes = [new AtRule(nodes)]; | ||
} else if (nodes.text) { | ||
nodes = [new Comment(nodes)]; | ||
nodes = [new _Comment2['default'](nodes)]; | ||
} else { | ||
throw "Unknown node type in node creation"; | ||
throw 'Unknown node type in node creation'; | ||
} | ||
@@ -395,5 +403,5 @@ } | ||
if (child.parent) child = child.clone(); | ||
if (typeof child.before === "undefined") { | ||
if (sample && typeof sample.before !== "undefined") { | ||
child.before = sample.before.replace(/[^\s]/g, ""); | ||
if (typeof child.before === 'undefined') { | ||
if (sample && typeof sample.before !== 'undefined') { | ||
child.before = sample.before.replace(/[^\s]/g, ''); | ||
} | ||
@@ -408,20 +416,20 @@ } | ||
_createClass(Container, { | ||
first: { | ||
get: function () { | ||
if (!this.nodes) return undefined; | ||
return this.nodes[0]; | ||
} | ||
}, | ||
last: { | ||
get: function () { | ||
if (!this.nodes) return undefined; | ||
return this.nodes[this.nodes.length - 1]; | ||
} | ||
_createClass(Container, [{ | ||
key: 'first', | ||
get: function () { | ||
if (!this.nodes) return undefined; | ||
return this.nodes[0]; | ||
} | ||
}); | ||
}, { | ||
key: 'last', | ||
get: function () { | ||
if (!this.nodes) return undefined; | ||
return this.nodes[this.nodes.length - 1]; | ||
} | ||
}]); | ||
return Container; | ||
})(Node); | ||
})(_Node3['default']); | ||
module.exports = Container; | ||
exports['default'] = Container; | ||
module.exports = exports['default']; |
@@ -1,11 +0,15 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var warnOnce = _interopRequire(require("./warn-once")); | ||
exports.__esModule = true; | ||
var _warnOnce = require('./warn-once'); | ||
var _warnOnce2 = _interopRequireWildcard(_warnOnce); | ||
var CssSyntaxError = (function (_SyntaxError) { | ||
@@ -15,12 +19,13 @@ function CssSyntaxError(message, line, column, source, file, plugin) { | ||
_SyntaxError.call(this, message); | ||
this.reason = message; | ||
this.message = plugin ? plugin + ": " : ""; | ||
this.message += file ? file : "<css input>"; | ||
if (typeof line !== "undefined" && typeof column !== "undefined") { | ||
this.message = plugin ? plugin + ': ' : ''; | ||
this.message += file ? file : '<css input>'; | ||
if (typeof line !== 'undefined' && typeof column !== 'undefined') { | ||
this.line = line; | ||
this.column = column; | ||
this.message += ":" + line + ":" + column + ": " + message; | ||
this.message += ':' + line + ':' + column + ': ' + message; | ||
} else { | ||
this.message += ": " + message; | ||
this.message += ': ' + message; | ||
} | ||
@@ -41,16 +46,16 @@ | ||
if (!this.source) { | ||
return ""; | ||
return ''; | ||
}var num = this.line - 1; | ||
var lines = this.source.split("\n"); | ||
var lines = this.source.split('\n'); | ||
var prev = num > 0 ? lines[num - 1] + "\n" : ""; | ||
var prev = num > 0 ? lines[num - 1] + '\n' : ''; | ||
var broken = lines[num]; | ||
var next = num < lines.length - 1 ? "\n" + lines[num + 1] : ""; | ||
var next = num < lines.length - 1 ? '\n' + lines[num + 1] : ''; | ||
var mark = "\n"; | ||
var mark = '\n'; | ||
for (var i = 0; i < this.column - 1; i++) { | ||
mark += " "; | ||
mark += ' '; | ||
} | ||
if (typeof color === "undefined" && typeof process !== "undefined") { | ||
if (typeof color === 'undefined' && typeof process !== 'undefined') { | ||
if (process.stdout && process.env) { | ||
@@ -62,13 +67,13 @@ color = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS; | ||
if (color) { | ||
mark += "\u001b[1;31m^\u001b[0m"; | ||
mark += '\u001b[1;31m^\u001b[0m'; | ||
} else { | ||
mark += "^"; | ||
mark += '^'; | ||
} | ||
return "\n" + prev + broken + mark + next; | ||
return '\n' + prev + broken + mark + next; | ||
}; | ||
CssSyntaxError.prototype.highlight = function highlight(color) { | ||
warnOnce("CssSyntaxError#highlight is deprecated and will be " + "removed in 5.0. Use error.showSourceCode instead."); | ||
return this.showSourceCode(color).replace(/^\n/, ""); | ||
_warnOnce2['default']('CssSyntaxError#highlight is deprecated and will be ' + 'removed in 5.0. Use error.showSourceCode instead.'); | ||
return this.showSourceCode(color).replace(/^\n/, ''); | ||
}; | ||
@@ -85,3 +90,3 @@ | ||
CssSyntaxError.prototype.toString = function toString() { | ||
return this.name + ": " + this.message + this.showSourceCode(); | ||
return this.name + ': ' + this.message + this.showSourceCode(); | ||
}; | ||
@@ -92,4 +97,5 @@ | ||
module.exports = CssSyntaxError; | ||
exports['default'] = CssSyntaxError; | ||
CssSyntaxError.prototype.name = "CssSyntaxError"; | ||
CssSyntaxError.prototype.name = 'CssSyntaxError'; | ||
module.exports = exports['default']; |
@@ -1,11 +0,15 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var Node = _interopRequire(require("./node")); | ||
exports.__esModule = true; | ||
var _Node2 = require('./node'); | ||
var _Node3 = _interopRequireWildcard(_Node2); | ||
var Declaration = (function (_Node) { | ||
@@ -15,4 +19,4 @@ function Declaration(defaults) { | ||
this.type = "decl"; | ||
_Node.call(this, defaults); | ||
this.type = 'decl'; | ||
} | ||
@@ -23,13 +27,13 @@ | ||
Declaration.prototype.stringify = function stringify(builder, semicolon) { | ||
var before = this.style("before"); | ||
var before = this.style('before'); | ||
if (before) builder(before); | ||
var between = this.style("between", "colon"); | ||
var string = this.prop + between + this.stringifyRaw("value"); | ||
var between = this.style('between', 'colon'); | ||
var string = this.prop + between + this.stringifyRaw('value'); | ||
if (this.important) { | ||
string += this._important || " !important"; | ||
string += this._important || ' !important'; | ||
} | ||
if (semicolon) string += ";"; | ||
if (semicolon) string += ';'; | ||
builder(string, this); | ||
@@ -39,4 +43,5 @@ }; | ||
return Declaration; | ||
})(Node); | ||
})(_Node3['default']); | ||
module.exports = Declaration; | ||
exports['default'] = Declaration; | ||
module.exports = exports['default']; |
@@ -1,13 +0,21 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var CssSyntaxError = _interopRequire(require("./css-syntax-error")); | ||
exports.__esModule = true; | ||
var PreviousMap = _interopRequire(require("./previous-map")); | ||
var _CssSyntaxError = require('./css-syntax-error'); | ||
var path = _interopRequire(require("path")); | ||
var _CssSyntaxError2 = _interopRequireWildcard(_CssSyntaxError); | ||
var _PreviousMap = require('./previous-map'); | ||
var _PreviousMap2 = _interopRequireWildcard(_PreviousMap); | ||
var _path = require('path'); | ||
var _path2 = _interopRequireWildcard(_path); | ||
var sequence = 0; | ||
@@ -23,3 +31,3 @@ | ||
if (this.css[0] === "" || this.css[0] === "") { | ||
if (this.css[0] === '' || this.css[0] === '') { | ||
this.css = this.css.slice(1); | ||
@@ -30,5 +38,5 @@ } | ||
if (opts.from) this.file = path.resolve(opts.from); | ||
if (opts.from) this.file = _path2['default'].resolve(opts.from); | ||
var map = new PreviousMap(this.css, opts, this.id); | ||
var map = new _PreviousMap2['default'](this.css, opts, this.id); | ||
if (map.text) { | ||
@@ -44,3 +52,3 @@ this.map = map; | ||
sequence += 1; | ||
this.id = "<input css " + sequence + ">"; | ||
this.id = '<input css ' + sequence + '>'; | ||
this.from = this.id; | ||
@@ -51,12 +59,22 @@ } | ||
Input.prototype.error = function error(message, line, column) { | ||
Input.prototype.error = (function (_error) { | ||
function error(_x, _x2, _x3) { | ||
return _error.apply(this, arguments); | ||
} | ||
error.toString = function () { | ||
return error.toString(); | ||
}; | ||
return error; | ||
})(function (message, line, column) { | ||
var opts = arguments[3] === undefined ? {} : arguments[3]; | ||
var error = new CssSyntaxError(message); | ||
var error = new _CssSyntaxError2['default'](message); | ||
var origin = this.origin(line, column); | ||
if (origin) { | ||
error = new CssSyntaxError(message, origin.line, origin.column, origin.source, origin.file, opts.plugin); | ||
error = new _CssSyntaxError2['default'](message, origin.line, origin.column, origin.source, origin.file, opts.plugin); | ||
} else { | ||
error = new CssSyntaxError(message, line, column, this.css, this.file, opts.plugin); | ||
error = new _CssSyntaxError2['default'](message, line, column, this.css, this.file, opts.plugin); | ||
} | ||
@@ -72,3 +90,3 @@ | ||
return error; | ||
}; | ||
}); | ||
@@ -96,3 +114,3 @@ Input.prototype.origin = function origin(line, column) { | ||
Input.prototype.mapResolve = function mapResolve(file) { | ||
return path.resolve(this.map.consumer().sourceRoot || ".", file); | ||
return _path2['default'].resolve(this.map.consumer().sourceRoot || '.', file); | ||
}; | ||
@@ -103,2 +121,3 @@ | ||
module.exports = Input; | ||
exports['default'] = Input; | ||
module.exports = exports['default']; |
@@ -1,23 +0,35 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
exports.__esModule = true; | ||
var MapGenerator = _interopRequire(require("./map-generator")); | ||
var _MapGenerator = require('./map-generator'); | ||
var warnOnce = _interopRequire(require("./warn-once")); | ||
var _MapGenerator2 = _interopRequireWildcard(_MapGenerator); | ||
var Result = _interopRequire(require("./result")); | ||
var _warnOnce = require('./warn-once'); | ||
var parse = _interopRequire(require("./parse")); | ||
var _warnOnce2 = _interopRequireWildcard(_warnOnce); | ||
var Root = _interopRequire(require("./root")); | ||
var _Result = require('./result'); | ||
var _Result2 = _interopRequireWildcard(_Result); | ||
var _parse = require('./parse'); | ||
var _parse2 = _interopRequireWildcard(_parse); | ||
var _Root = require('./root'); | ||
var _Root2 = _interopRequireWildcard(_Root); | ||
var Promise = global.Promise || require('es6-promise').Promise; | ||
function isPromise(obj) { | ||
return typeof obj === "object" && typeof obj.then === "function"; | ||
return typeof obj === 'object' && typeof obj.then === 'function'; | ||
} | ||
@@ -33,14 +45,14 @@ | ||
var root = undefined; | ||
if (css instanceof Root) { | ||
if (css instanceof _Root2['default']) { | ||
root = css; | ||
} else if (css instanceof LazyResult || css instanceof Result) { | ||
} else if (css instanceof LazyResult || css instanceof _Result2['default']) { | ||
root = css.root; | ||
if (css.map && typeof opts.map === "undefined") { | ||
if (css.map && typeof opts.map === 'undefined') { | ||
opts.map = { prev: css.map }; | ||
} | ||
} else { | ||
root = parse(css, opts); | ||
root = _parse2['default'](css, opts); | ||
} | ||
this.result = new Result(processor, root, opts); | ||
this.result = new _Result2['default'](processor, root, opts); | ||
} | ||
@@ -60,4 +72,4 @@ | ||
LazyResult.prototype["catch"] = function _catch(onRejected) { | ||
return this.async()["catch"](onRejected); | ||
LazyResult.prototype['catch'] = function _catch(onRejected) { | ||
return this.async()['catch'](onRejected); | ||
}; | ||
@@ -74,3 +86,3 @@ | ||
_this.asyncTick(plugins, resolve, reject); | ||
})["catch"](function (error) { | ||
})['catch'](function (error) { | ||
reject(error); | ||
@@ -84,7 +96,7 @@ }); | ||
LazyResult.prototype.async = function async() { | ||
var _this = this; | ||
var _this2 = this; | ||
if (this.processed) { | ||
return Promise.resolve().then(function () { | ||
return _this.stringify(); | ||
return _this2.stringify(); | ||
}); | ||
@@ -98,6 +110,6 @@ } | ||
this.processing = new Promise(function (resolve, reject) { | ||
_this.asyncTick(plugins, resolve, reject); | ||
_this2.asyncTick(plugins, resolve, reject); | ||
}).then(function () { | ||
_this.processed = true; | ||
return _this.stringify(); | ||
_this2.processed = true; | ||
return _this2.stringify(); | ||
}); | ||
@@ -114,3 +126,3 @@ | ||
if (this.processing) { | ||
throw "Use process(css).then(cb) to work with async plugins"; | ||
throw 'Use process(css).then(cb) to work with async plugins'; | ||
} | ||
@@ -134,3 +146,3 @@ | ||
if (isPromise(promise)) { | ||
throw "Use process(css).then(cb) to work with async plugins"; | ||
throw 'Use process(css).then(cb) to work with async plugins'; | ||
} | ||
@@ -153,7 +165,7 @@ } | ||
var runtimeVersion = this.result.processor.version; | ||
var a = pluginVersion.split("."); | ||
var b = runtimeVersion.split("."); | ||
var a = pluginVersion.split('.'); | ||
var b = runtimeVersion.split('.'); | ||
if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) { | ||
warnOnce("" + pluginName + " is based on " + ("PostCSS " + pluginVersion + " but you use it ") + ("with PostCSS " + runtimeVersion + ". ") + "Maybe this is a source of error below."); | ||
_warnOnce2['default']('' + pluginName + ' is based on ' + ('PostCSS ' + pluginVersion + ' but you use it ') + ('with PostCSS ' + runtimeVersion + '. ') + 'Maybe this is a source of error below.'); | ||
} | ||
@@ -164,3 +176,3 @@ } | ||
if (returned instanceof Root) { | ||
if (returned instanceof _Root2['default']) { | ||
this.result.root = returned; | ||
@@ -178,46 +190,43 @@ } else { | ||
this.sync(); | ||
var map = new MapGenerator(this.result.root, this.result.opts); | ||
var map = new _MapGenerator2['default'](this.result.root, this.result.opts); | ||
var _ref = map.generate(); | ||
var _map$generate = map.generate(); | ||
var _ref2 = _slicedToArray(_ref, 2); | ||
this.result.css = _map$generate[0]; | ||
this.result.map = _map$generate[1]; | ||
this.result.css = _ref2[0]; | ||
this.result.map = _ref2[1]; | ||
return this.result; | ||
}; | ||
_createClass(LazyResult, { | ||
processor: { | ||
get: function () { | ||
return this.result.processor; | ||
} | ||
}, | ||
opts: { | ||
get: function () { | ||
return this.result.opts; | ||
} | ||
}, | ||
css: { | ||
get: function () { | ||
return this.stringify().css; | ||
} | ||
}, | ||
map: { | ||
get: function () { | ||
return this.stringify().map; | ||
} | ||
}, | ||
root: { | ||
get: function () { | ||
return this.sync().root; | ||
} | ||
}, | ||
messages: { | ||
get: function () { | ||
return this.sync().messages; | ||
} | ||
_createClass(LazyResult, [{ | ||
key: 'processor', | ||
get: function () { | ||
return this.result.processor; | ||
} | ||
}); | ||
}, { | ||
key: 'opts', | ||
get: function () { | ||
return this.result.opts; | ||
} | ||
}, { | ||
key: 'css', | ||
get: function () { | ||
return this.stringify().css; | ||
} | ||
}, { | ||
key: 'map', | ||
get: function () { | ||
return this.stringify().map; | ||
} | ||
}, { | ||
key: 'root', | ||
get: function () { | ||
return this.sync().root; | ||
} | ||
}, { | ||
key: 'messages', | ||
get: function () { | ||
return this.sync().messages; | ||
} | ||
}]); | ||
@@ -227,2 +236,3 @@ return LazyResult; | ||
module.exports = LazyResult; | ||
exports['default'] = LazyResult; | ||
module.exports = exports['default']; |
@@ -1,18 +0,9 @@ | ||
"use strict"; | ||
'use strict'; | ||
exports.__esModule = true; | ||
var list = { | ||
split: (function (_split) { | ||
var _splitWrapper = function split(_x, _x2, _x3) { | ||
return _split.apply(this, arguments); | ||
}; | ||
_splitWrapper.toString = function () { | ||
return _split.toString(); | ||
}; | ||
return _splitWrapper; | ||
})(function (string, separators, last) { | ||
split: function split(string, separators, last) { | ||
var array = []; | ||
var current = ""; | ||
var current = ''; | ||
var split = false; | ||
@@ -30,3 +21,3 @@ | ||
escape = false; | ||
} else if (letter === "\\") { | ||
} else if (letter === '\\') { | ||
escape = true; | ||
@@ -36,7 +27,7 @@ } else if (letter === quote) { | ||
} | ||
} else if (letter === "\"" || letter === "'") { | ||
} else if (letter === '"' || letter === '\'') { | ||
quote = letter; | ||
} else if (letter === "(") { | ||
} else if (letter === '(') { | ||
func += 1; | ||
} else if (letter === ")") { | ||
} else if (letter === ')') { | ||
if (func > 0) func -= 1; | ||
@@ -50,4 +41,4 @@ } else if (func === 0) { | ||
if (split) { | ||
if (current !== "") array.push(current.trim()); | ||
current = ""; | ||
if (current !== '') array.push(current.trim()); | ||
current = ''; | ||
split = false; | ||
@@ -59,28 +50,19 @@ } else { | ||
if (last || current !== "") array.push(current.trim()); | ||
if (last || current !== '') array.push(current.trim()); | ||
return array; | ||
}), | ||
}, | ||
space: function space(string) { | ||
var spaces = [" ", "\n", "\t"]; | ||
var spaces = [' ', '\n', '\t']; | ||
return list.split(string, spaces); | ||
}, | ||
comma: (function (_comma) { | ||
var _commaWrapper = function comma(_x) { | ||
return _comma.apply(this, arguments); | ||
}; | ||
_commaWrapper.toString = function () { | ||
return _comma.toString(); | ||
}; | ||
return _commaWrapper; | ||
})(function (string) { | ||
var comma = ","; | ||
comma: function comma(string) { | ||
var comma = ','; | ||
return list.split(string, [comma], true); | ||
}) | ||
} | ||
}; | ||
module.exports = list; | ||
exports['default'] = list; | ||
module.exports = exports['default']; |
@@ -1,13 +0,19 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var Base64 = require("js-base64").Base64; | ||
exports.__esModule = true; | ||
var mozilla = _interopRequire(require("source-map")); | ||
var _Base64 = require('js-base64'); | ||
var path = _interopRequire(require("path")); | ||
var _mozilla = require('source-map'); | ||
var _mozilla2 = _interopRequireWildcard(_mozilla); | ||
var _path = require('path'); | ||
var _path2 = _interopRequireWildcard(_path); | ||
var _default = (function () { | ||
@@ -23,3 +29,3 @@ var _class = function _default(root, opts) { | ||
_class.prototype.isMap = function isMap() { | ||
if (typeof this.opts.map !== "undefined") { | ||
if (typeof this.opts.map !== 'undefined') { | ||
return !!this.opts.map; | ||
@@ -50,3 +56,3 @@ } else { | ||
_class.prototype.isInline = function isInline() { | ||
if (typeof this.mapOpts.inline !== "undefined") { | ||
if (typeof this.mapOpts.inline !== 'undefined') { | ||
return this.mapOpts.inline; | ||
@@ -56,3 +62,3 @@ } | ||
var annotation = this.mapOpts.annotation; | ||
if (typeof annotation !== "undefined" && annotation !== true) { | ||
if (typeof annotation !== 'undefined' && annotation !== true) { | ||
return false; | ||
@@ -71,3 +77,3 @@ } | ||
_class.prototype.isSourcesContent = function isSourcesContent() { | ||
if (typeof this.mapOpts.sourcesContent !== "undefined") { | ||
if (typeof this.mapOpts.sourcesContent !== 'undefined') { | ||
return this.mapOpts.sourcesContent; | ||
@@ -90,4 +96,4 @@ } | ||
node = this.root.nodes[i]; | ||
if (node.type !== "comment") continue; | ||
if (node.text.indexOf("# sourceMappingURL=") === 0) { | ||
if (node.type !== 'comment') continue; | ||
if (node.text.indexOf('# sourceMappingURL=') === 0) { | ||
this.root.remove(i); | ||
@@ -99,3 +105,3 @@ } | ||
_class.prototype.setSourcesContent = function setSourcesContent() { | ||
var _this = this; | ||
var _this2 = this; | ||
@@ -108,4 +114,4 @@ var already = {}; | ||
already[from] = true; | ||
var relative = _this.relative(from); | ||
_this.map.setSourceContent(relative, node.source.input.css); | ||
var relative = _this2.relative(from); | ||
_this2.map.setSourceContent(relative, node.source.input.css); | ||
} | ||
@@ -132,7 +138,7 @@ } | ||
var from = this.relative(prev.file); | ||
var root = prev.root || path.dirname(prev.file); | ||
var root = prev.root || _path2['default'].dirname(prev.file); | ||
var map = undefined; | ||
if (this.mapOpts.sourcesContent === false) { | ||
map = new mozilla.SourceMapConsumer(prev.text); | ||
map = new _mozilla2['default'].SourceMapConsumer(prev.text); | ||
if (map.sourcesContent) { | ||
@@ -154,3 +160,3 @@ map.sourcesContent = map.sourcesContent.map(function () { | ||
return true; | ||
} else if (typeof this.mapOpts.annotation !== "undefined") { | ||
} else if (typeof this.mapOpts.annotation !== 'undefined') { | ||
return this.mapOpts.annotation; | ||
@@ -170,10 +176,10 @@ } else if (this.previous().length) { | ||
if (this.isInline()) { | ||
content = "data:application/json;base64," + Base64.encode(this.map.toString()); | ||
} else if (typeof this.mapOpts.annotation === "string") { | ||
content = 'data:application/json;base64,' + _Base64.Base64.encode(this.map.toString()); | ||
} else if (typeof this.mapOpts.annotation === 'string') { | ||
content = this.mapOpts.annotation; | ||
} else { | ||
content = this.outputFile() + ".map"; | ||
content = this.outputFile() + '.map'; | ||
} | ||
this.css += "\n/*# sourceMappingURL=" + content + " */"; | ||
this.css += '\n/*# sourceMappingURL=' + content + ' */'; | ||
}; | ||
@@ -187,3 +193,3 @@ | ||
} else { | ||
return "to.css"; | ||
return 'to.css'; | ||
} | ||
@@ -206,11 +212,11 @@ }; | ||
_class.prototype.relative = function relative(file) { | ||
var from = this.opts.to ? path.dirname(this.opts.to) : "."; | ||
var from = this.opts.to ? _path2['default'].dirname(this.opts.to) : '.'; | ||
if (typeof this.mapOpts.annotation === "string") { | ||
from = path.dirname(path.resolve(from, this.mapOpts.annotation)); | ||
if (typeof this.mapOpts.annotation === 'string') { | ||
from = _path2['default'].dirname(_path2['default'].resolve(from, this.mapOpts.annotation)); | ||
} | ||
file = path.relative(from, file); | ||
if (path.sep === "\\") { | ||
return file.replace(/\\/g, "/"); | ||
file = _path2['default'].relative(from, file); | ||
if (_path2['default'].sep === '\\') { | ||
return file.replace(/\\/g, '/'); | ||
} else { | ||
@@ -226,6 +232,6 @@ return file; | ||
_class.prototype.stringify = function stringify() { | ||
var _this = this; | ||
var _this3 = this; | ||
this.css = ""; | ||
this.map = new mozilla.SourceMapGenerator({ file: this.outputFile() }); | ||
this.css = ''; | ||
this.map = new _mozilla2['default'].SourceMapGenerator({ file: this.outputFile() }); | ||
@@ -237,8 +243,8 @@ var line = 1; | ||
last = undefined; | ||
var builder = function (str, node, type) { | ||
_this.css += str; | ||
var builder = function builder(str, node, type) { | ||
_this3.css += str; | ||
if (node && node.source && node.source.start && type !== "end") { | ||
_this.map.addMapping({ | ||
source: _this.sourcePath(node), | ||
if (node && node.source && node.source.start && type !== 'end') { | ||
_this3.map.addMapping({ | ||
source: _this3.sourcePath(node), | ||
original: { | ||
@@ -258,3 +264,3 @@ line: node.source.start.line, | ||
line += lines.length; | ||
last = str.lastIndexOf("\n"); | ||
last = str.lastIndexOf('\n'); | ||
column = str.length - last; | ||
@@ -265,5 +271,5 @@ } else { | ||
if (node && node.source && node.source.end && type !== "start") { | ||
_this.map.addMapping({ | ||
source: _this.sourcePath(node), | ||
if (node && node.source && node.source.end && type !== 'start') { | ||
_this3.map.addMapping({ | ||
source: _this3.sourcePath(node), | ||
original: { | ||
@@ -297,2 +303,3 @@ line: node.source.end.line, | ||
module.exports = _default; | ||
exports['default'] = _default; | ||
module.exports = exports['default']; |
191
lib/node.js
@@ -1,35 +0,39 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var CssSyntaxError = _interopRequire(require("./css-syntax-error")); | ||
exports.__esModule = true; | ||
var _CssSyntaxError = require('./css-syntax-error'); | ||
var _CssSyntaxError2 = _interopRequireWildcard(_CssSyntaxError); | ||
var defaultStyle = { | ||
colon: ": ", | ||
indent: " ", | ||
beforeDecl: "\n", | ||
beforeRule: "\n", | ||
beforeOpen: " ", | ||
beforeClose: "\n", | ||
beforeComment: "\n", | ||
after: "\n", | ||
emptyBody: "", | ||
commentLeft: " ", | ||
commentRight: " " | ||
colon: ': ', | ||
indent: ' ', | ||
beforeDecl: '\n', | ||
beforeRule: '\n', | ||
beforeOpen: ' ', | ||
beforeClose: '\n', | ||
beforeComment: '\n', | ||
after: '\n', | ||
emptyBody: '', | ||
commentLeft: ' ', | ||
commentRight: ' ' | ||
}; | ||
var cloneNode = (function (_cloneNode) { | ||
var _cloneNodeWrapper = function cloneNode(_x, _x2) { | ||
function cloneNode(_x, _x2) { | ||
return _cloneNode.apply(this, arguments); | ||
}; | ||
} | ||
_cloneNodeWrapper.toString = function () { | ||
return _cloneNode.toString(); | ||
cloneNode.toString = function () { | ||
return cloneNode.toString(); | ||
}; | ||
return _cloneNodeWrapper; | ||
return cloneNode; | ||
})(function (obj, parent) { | ||
if (typeof obj !== "object") return obj; | ||
if (typeof obj !== 'object') return obj; | ||
var cloned = new obj.constructor(); | ||
@@ -41,5 +45,5 @@ | ||
if (i === "parent" && typeof value === "object") { | ||
if (i === 'parent' && typeof value === 'object') { | ||
if (parent) cloned[i] = parent; | ||
} else if (i === "source") { | ||
} else if (i === 'source') { | ||
cloned[i] = value; | ||
@@ -50,3 +54,3 @@ } else if (value instanceof Array) { | ||
}); | ||
} else if (i !== "before" && i !== "after" && i !== "between" && i !== "semicolon") { | ||
} else if (i !== 'before' && i !== 'after' && i !== 'between' && i !== 'semicolon') { | ||
cloned[i] = cloneNode(value, cloned); | ||
@@ -77,3 +81,3 @@ } | ||
} else { | ||
return new CssSyntaxError(message); | ||
return new _CssSyntaxError2['default'](message); | ||
} | ||
@@ -97,4 +101,4 @@ }; | ||
_class.prototype.toString = function toString() { | ||
var result = ""; | ||
var builder = function (str) { | ||
var result = ''; | ||
var builder = function builder(str) { | ||
return result += str; | ||
@@ -110,4 +114,4 @@ }; | ||
var cloned = cloneNode(this); | ||
for (var _name in overrides) { | ||
cloned[_name] = overrides[_name]; | ||
for (var _name2 in overrides) { | ||
cloned[_name2] = overrides[_name2]; | ||
} | ||
@@ -173,10 +177,10 @@ return cloned; | ||
for (var _name in this) { | ||
if (!this.hasOwnProperty(_name)) continue; | ||
if (_name === "parent") continue; | ||
var value = this[_name]; | ||
for (var _name3 in this) { | ||
if (!this.hasOwnProperty(_name3)) continue; | ||
if (_name3 === 'parent') continue; | ||
var value = this[_name3]; | ||
if (value instanceof Array) { | ||
fixed[_name] = value.map(function (i) { | ||
if (typeof i === "object" && i.toJSON) { | ||
fixed[_name3] = value.map(function (i) { | ||
if (typeof i === 'object' && i.toJSON) { | ||
return i.toJSON(); | ||
@@ -187,6 +191,6 @@ } else { | ||
}); | ||
} else if (typeof value === "object" && value.toJSON) { | ||
fixed[_name] = value.toJSON(); | ||
} else if (typeof value === 'object' && value.toJSON) { | ||
fixed[_name3] = value.toJSON(); | ||
} else { | ||
fixed[_name] = value; | ||
fixed[_name3] = value; | ||
} | ||
@@ -205,3 +209,3 @@ } | ||
value = this[own]; | ||
if (typeof value !== "undefined") { | ||
if (typeof value !== 'undefined') { | ||
return value; | ||
@@ -214,5 +218,5 @@ } | ||
// Hack for first rule in CSS | ||
if (detect === "before") { | ||
if (!parent || parent.type === "root" && parent.first === this) { | ||
return ""; | ||
if (detect === 'before') { | ||
if (!parent || parent.type === 'root' && parent.first === this) { | ||
return ''; | ||
} | ||
@@ -227,28 +231,28 @@ } | ||
if (!root.styleCache) root.styleCache = {}; | ||
if (typeof root.styleCache[detect] !== "undefined") { | ||
if (typeof root.styleCache[detect] !== 'undefined') { | ||
return root.styleCache[detect]; | ||
} | ||
if (detect === "semicolon") { | ||
if (detect === 'semicolon') { | ||
root.eachInside(function (i) { | ||
if (i.nodes && i.nodes.length && i.last.type === "decl") { | ||
if (i.nodes && i.nodes.length && i.last.type === 'decl') { | ||
value = i.semicolon; | ||
if (typeof value !== "undefined") return false; | ||
if (typeof value !== 'undefined') return false; | ||
} | ||
}); | ||
} else if (detect === "emptyBody") { | ||
} else if (detect === 'emptyBody') { | ||
root.eachInside(function (i) { | ||
if (i.nodes && i.nodes.length === 0) { | ||
value = i.after; | ||
if (typeof value !== "undefined") return false; | ||
if (typeof value !== 'undefined') return false; | ||
} | ||
}); | ||
} else if (detect === "indent") { | ||
} else if (detect === 'indent') { | ||
root.eachInside(function (i) { | ||
var p = i.parent; | ||
if (p && p !== root && p.parent && p.parent === root) { | ||
if (typeof i.before !== "undefined") { | ||
var parts = i.before.split("\n"); | ||
if (typeof i.before !== 'undefined') { | ||
var parts = i.before.split('\n'); | ||
value = parts[parts.length - 1]; | ||
value = value.replace(/[^\s]/g, ""); | ||
value = value.replace(/[^\s]/g, ''); | ||
return false; | ||
@@ -258,8 +262,8 @@ } | ||
}); | ||
} else if (detect === "beforeComment") { | ||
} else if (detect === 'beforeComment') { | ||
root.eachComment(function (i) { | ||
if (typeof i.before !== "undefined") { | ||
if (typeof i.before !== 'undefined') { | ||
value = i.before; | ||
if (value.indexOf("\n") !== -1) { | ||
value = value.replace(/[^\n]+$/, ""); | ||
if (value.indexOf('\n') !== -1) { | ||
value = value.replace(/[^\n]+$/, ''); | ||
} | ||
@@ -269,11 +273,11 @@ return false; | ||
}); | ||
if (typeof value === "undefined") { | ||
value = this.style(null, "beforeDecl"); | ||
if (typeof value === 'undefined') { | ||
value = this.style(null, 'beforeDecl'); | ||
} | ||
} else if (detect === "beforeDecl") { | ||
} else if (detect === 'beforeDecl') { | ||
root.eachDecl(function (i) { | ||
if (typeof i.before !== "undefined") { | ||
if (typeof i.before !== 'undefined') { | ||
value = i.before; | ||
if (value.indexOf("\n") !== -1) { | ||
value = value.replace(/[^\n]+$/, ""); | ||
if (value.indexOf('\n') !== -1) { | ||
value = value.replace(/[^\n]+$/, ''); | ||
} | ||
@@ -283,12 +287,12 @@ return false; | ||
}); | ||
if (typeof value === "undefined") { | ||
value = this.style(null, "beforeRule"); | ||
if (typeof value === 'undefined') { | ||
value = this.style(null, 'beforeRule'); | ||
} | ||
} else if (detect === "beforeRule") { | ||
} else if (detect === 'beforeRule') { | ||
root.eachInside(function (i) { | ||
if (i.nodes && (i.parent !== root || root.first !== i)) { | ||
if (typeof i.before !== "undefined") { | ||
if (typeof i.before !== 'undefined') { | ||
value = i.before; | ||
if (value.indexOf("\n") !== -1) { | ||
value = value.replace(/[^\n]+$/, ""); | ||
if (value.indexOf('\n') !== -1) { | ||
value = value.replace(/[^\n]+$/, ''); | ||
} | ||
@@ -299,9 +303,9 @@ return false; | ||
}); | ||
} else if (detect === "beforeClose") { | ||
} else if (detect === 'beforeClose') { | ||
root.eachInside(function (i) { | ||
if (i.nodes && i.nodes.length > 0) { | ||
if (typeof i.after !== "undefined") { | ||
if (typeof i.after !== 'undefined') { | ||
value = i.after; | ||
if (value.indexOf("\n") !== -1) { | ||
value = value.replace(/[^\n]+$/, ""); | ||
if (value.indexOf('\n') !== -1) { | ||
value = value.replace(/[^\n]+$/, ''); | ||
} | ||
@@ -312,11 +316,11 @@ return false; | ||
}); | ||
} else if (detect === "before" || detect === "after") { | ||
if (this.type === "decl") { | ||
value = this.style(null, "beforeDecl"); | ||
} else if (this.type === "comment") { | ||
value = this.style(null, "beforeComment"); | ||
} else if (detect === "before") { | ||
value = this.style(null, "beforeRule"); | ||
} else if (detect === 'before' || detect === 'after') { | ||
if (this.type === 'decl') { | ||
value = this.style(null, 'beforeDecl'); | ||
} else if (this.type === 'comment') { | ||
value = this.style(null, 'beforeComment'); | ||
} else if (detect === 'before') { | ||
value = this.style(null, 'beforeRule'); | ||
} else { | ||
value = this.style(null, "beforeClose"); | ||
value = this.style(null, 'beforeClose'); | ||
} | ||
@@ -326,3 +330,3 @@ | ||
var depth = 0; | ||
while (node && node.type !== "root") { | ||
while (node && node.type !== 'root') { | ||
depth += 1; | ||
@@ -332,4 +336,4 @@ node = node.parent; | ||
if (value.indexOf("\n") !== -1) { | ||
var indent = this.style(null, "indent"); | ||
if (value.indexOf('\n') !== -1) { | ||
var indent = this.style(null, 'indent'); | ||
if (indent.length) { | ||
@@ -343,14 +347,14 @@ for (var step = 0; step < depth; step++) { | ||
return value; | ||
} else if (detect === "colon") { | ||
} else if (detect === 'colon') { | ||
root.eachDecl(function (i) { | ||
if (typeof i.between !== "undefined") { | ||
value = i.between.replace(/[^\s:]/g, ""); | ||
if (typeof i.between !== 'undefined') { | ||
value = i.between.replace(/[^\s:]/g, ''); | ||
return false; | ||
} | ||
}); | ||
} else if (detect === "beforeOpen") { | ||
} else if (detect === 'beforeOpen') { | ||
root.eachInside(function (i) { | ||
if (i.type !== "decl") { | ||
if (i.type !== 'decl') { | ||
value = i.between; | ||
if (typeof value !== "undefined") return false; | ||
if (typeof value !== 'undefined') return false; | ||
} | ||
@@ -361,7 +365,7 @@ }); | ||
value = i[own]; | ||
if (typeof value !== "undefined") return false; | ||
if (typeof value !== 'undefined') return false; | ||
}); | ||
} | ||
if (typeof value === "undefined") value = defaultStyle[detect]; | ||
if (typeof value === 'undefined') value = defaultStyle[detect]; | ||
@@ -404,3 +408,3 @@ root.styleCache[detect] = value; | ||
var value = this[prop]; | ||
var raw = this["_" + prop]; | ||
var raw = this['_' + prop]; | ||
if (raw && raw.value === value) { | ||
@@ -416,2 +420,3 @@ return raw.raw; | ||
module.exports = _default; | ||
exports['default'] = _default; | ||
module.exports = exports['default']; |
@@ -1,15 +0,20 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
module.exports = parse; | ||
exports.__esModule = true; | ||
exports['default'] = parse; | ||
var Parser = _interopRequire(require("./parser")); | ||
var _Parser = require('./parser'); | ||
var Input = _interopRequire(require("./input")); | ||
var _Parser2 = _interopRequireWildcard(_Parser); | ||
var _Input = require('./input'); | ||
var _Input2 = _interopRequireWildcard(_Input); | ||
function parse(css, opts) { | ||
var input = new Input(css, opts); | ||
var input = new _Input2['default'](css, opts); | ||
var parser = new Parser(input); | ||
var parser = new _Parser2['default'](input); | ||
parser.tokenize(); | ||
@@ -19,2 +24,4 @@ parser.loop(); | ||
return parser.root; | ||
} | ||
} | ||
module.exports = exports['default']; |
@@ -1,19 +0,33 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var Declaration = _interopRequire(require("./declaration")); | ||
exports.__esModule = true; | ||
var tokenizer = _interopRequire(require("./tokenize")); | ||
var _Declaration = require('./declaration'); | ||
var Comment = _interopRequire(require("./comment")); | ||
var _Declaration2 = _interopRequireWildcard(_Declaration); | ||
var AtRule = _interopRequire(require("./at-rule")); | ||
var _tokenizer = require('./tokenize'); | ||
var Root = _interopRequire(require("./root")); | ||
var _tokenizer2 = _interopRequireWildcard(_tokenizer); | ||
var Rule = _interopRequire(require("./rule")); | ||
var _Comment = require('./comment'); | ||
var _Comment2 = _interopRequireWildcard(_Comment); | ||
var _AtRule = require('./at-rule'); | ||
var _AtRule2 = _interopRequireWildcard(_AtRule); | ||
var _Root = require('./root'); | ||
var _Root2 = _interopRequireWildcard(_Root); | ||
var _Rule = require('./rule'); | ||
var _Rule2 = _interopRequireWildcard(_Rule); | ||
var Parser = (function () { | ||
@@ -26,5 +40,5 @@ function Parser(input) { | ||
this.pos = 0; | ||
this.root = new Root(); | ||
this.root = new _Root2['default'](); | ||
this.current = this.root; | ||
this.spaces = ""; | ||
this.spaces = ''; | ||
this.semicolon = false; | ||
@@ -37,3 +51,3 @@ | ||
Parser.prototype.tokenize = function tokenize() { | ||
this.tokens = tokenizer(this.input); | ||
this.tokens = _tokenizer2['default'](this.input); | ||
}; | ||
@@ -47,20 +61,20 @@ | ||
switch (token[0]) { | ||
case "word": | ||
case ":": | ||
case 'word': | ||
case ':': | ||
this.word(token); | ||
break; | ||
case "}": | ||
case '}': | ||
this.end(token); | ||
break; | ||
case "comment": | ||
case 'comment': | ||
this.comment(token); | ||
break; | ||
case "at-word": | ||
case 'at-word': | ||
this.atrule(token); | ||
break; | ||
case "{": | ||
case '{': | ||
this.emptyRule(token); | ||
@@ -80,3 +94,3 @@ break; | ||
Parser.prototype.comment = function comment(token) { | ||
var node = new Comment(); | ||
var node = new _Comment2['default'](); | ||
this.init(node, token[2], token[3]); | ||
@@ -88,4 +102,4 @@ node.source.end = { line: token[4], column: token[5] }; | ||
node.left = text; | ||
node.text = ""; | ||
node.right = ""; | ||
node.text = ''; | ||
node.right = ''; | ||
} else { | ||
@@ -100,6 +114,6 @@ var match = text.match(/^(\s*)([^]*[^\s])(\s*)$/); | ||
Parser.prototype.emptyRule = function emptyRule(token) { | ||
var node = new Rule(); | ||
var node = new _Rule2['default'](); | ||
this.init(node, token[2], token[3]); | ||
node.between = ""; | ||
node.selector = ""; | ||
node.between = ''; | ||
node.selector = ''; | ||
this.current = node; | ||
@@ -122,7 +136,7 @@ }; | ||
if (type === "(") { | ||
if (type === '(') { | ||
if (!bracket) bracket = token; | ||
brackets += 1; | ||
} else if (brackets === 0) { | ||
if (type === ";") { | ||
if (type === ';') { | ||
if (colon) { | ||
@@ -134,16 +148,16 @@ this.decl(this.tokens.slice(start, this.pos + 1)); | ||
} | ||
} else if (type === "{") { | ||
} else if (type === '{') { | ||
this.rule(this.tokens.slice(start, this.pos + 1)); | ||
return; | ||
} else if (type === "}") { | ||
} else if (type === '}') { | ||
this.pos -= 1; | ||
end = true; | ||
break; | ||
} else if (type === "at-word") { | ||
} else if (type === 'at-word') { | ||
this.pos -= 1; | ||
break; | ||
} else { | ||
if (type === ":") colon = true; | ||
if (type === ':') colon = true; | ||
} | ||
} else if (type === ")") { | ||
} else if (type === ')') { | ||
brackets -= 1; | ||
@@ -161,3 +175,3 @@ if (brackets === 0) bracket = null; | ||
if (brackets > 0 && !this.input.safe) { | ||
throw this.input.error("Unclosed bracket", bracket[2], bracket[3]); | ||
throw this.input.error('Unclosed bracket', bracket[2], bracket[3]); | ||
} | ||
@@ -168,3 +182,3 @@ | ||
token = this.tokens[this.pos][0]; | ||
if (token !== "space" && token !== "comment") break; | ||
if (token !== 'space' && token !== 'comment') break; | ||
this.pos -= 1; | ||
@@ -180,6 +194,6 @@ } | ||
return i[1]; | ||
}).join(""); | ||
}).join(''); | ||
} else { | ||
token = this.tokens[start]; | ||
throw this.input.error("Unknown word", token[2], token[3]); | ||
throw this.input.error('Unknown word', token[2], token[3]); | ||
} | ||
@@ -191,7 +205,7 @@ }; | ||
var node = new Rule(); | ||
var node = new _Rule2['default'](); | ||
this.init(node, tokens[0][2], tokens[0][3]); | ||
node.between = this.spacesFromEnd(tokens); | ||
this.raw(node, "selector", tokens); | ||
this.raw(node, 'selector', tokens); | ||
this.current = node; | ||
@@ -201,7 +215,7 @@ }; | ||
Parser.prototype.decl = function decl(tokens) { | ||
var node = new Declaration(); | ||
var node = new _Declaration2['default'](); | ||
this.init(node); | ||
var last = tokens[tokens.length - 1]; | ||
if (last[0] === ";") { | ||
if (last[0] === ';') { | ||
this.semicolon = true; | ||
@@ -216,3 +230,3 @@ tokens.pop(); | ||
while (tokens[0][0] !== "word") { | ||
while (tokens[0][0] !== 'word') { | ||
node.before += tokens.shift()[1]; | ||
@@ -223,3 +237,3 @@ } | ||
node.prop = tokens.shift()[1]; | ||
node.between = ""; | ||
node.between = ''; | ||
@@ -230,6 +244,6 @@ var token = undefined; | ||
if (token[0] === ":") { | ||
if (token[0] === ':') { | ||
node.between += token[1]; | ||
break; | ||
} else if (token[0] !== "space" && token[0] !== "comment") { | ||
} else if (token[0] !== 'space' && token[0] !== 'comment') { | ||
this.unknownWord(node, token, tokens); | ||
@@ -241,3 +255,3 @@ } else { | ||
if (node.prop[0] === "_" || node.prop[0] === "*") { | ||
if (node.prop[0] === '_' || node.prop[0] === '*') { | ||
node.before += node.prop[0]; | ||
@@ -252,14 +266,14 @@ node.prop = node.prop.slice(1); | ||
token = tokens[i]; | ||
if (token[1] === "!important") { | ||
if (token[1] === '!important') { | ||
node.important = true; | ||
var string = this.stringFrom(tokens, i); | ||
string = this.spacesFromEnd(tokens) + string; | ||
if (string !== " !important") node._important = string; | ||
if (string !== ' !important') node._important = string; | ||
break; | ||
} else if (token[1] === "important") { | ||
} else if (token[1] === 'important') { | ||
var cache = tokens.slice(0); | ||
var str = ""; | ||
var str = ''; | ||
for (var j = i; j > 0; j--) { | ||
var type = cache[j][0]; | ||
if (str.trim().indexOf("!") === 0 && type !== "space") { | ||
if (str.trim().indexOf('!') === 0 && type !== 'space') { | ||
break; | ||
@@ -269,3 +283,3 @@ } | ||
} | ||
if (str.trim().indexOf("!") === 0) { | ||
if (str.trim().indexOf('!') === 0) { | ||
node.important = true; | ||
@@ -277,3 +291,3 @@ node._important = str; | ||
if (token[0] !== "space" && token[0] !== "comment") { | ||
if (token[0] !== 'space' && token[0] !== 'comment') { | ||
break; | ||
@@ -283,5 +297,5 @@ } | ||
this.raw(node, "value", tokens); | ||
this.raw(node, 'value', tokens); | ||
if (node.value.indexOf(":") !== -1 && !this.input.safe) { | ||
if (node.value.indexOf(':') !== -1 && !this.input.safe) { | ||
this.checkMissedSemicolon(tokens); | ||
@@ -292,9 +306,9 @@ } | ||
Parser.prototype.atrule = function atrule(token) { | ||
var node = new AtRule(); | ||
var node = new _AtRule2['default'](); | ||
node.name = token[1].slice(1); | ||
if (node.name === "") { | ||
if (node.name === '') { | ||
if (this.input.safe) { | ||
node.name = ""; | ||
node.name = ''; | ||
} else { | ||
throw this.input.error("At-rule without name", token[2], token[3]); | ||
throw this.input.error('At-rule without name', token[2], token[3]); | ||
} | ||
@@ -312,7 +326,7 @@ } | ||
if (token[0] === ";") { | ||
if (token[0] === ';') { | ||
node.source.end = { line: token[2], column: token[3] }; | ||
this.semicolon = true; | ||
break; | ||
} else if (token[0] === "{") { | ||
} else if (token[0] === '{') { | ||
open = true; | ||
@@ -333,3 +347,3 @@ break; | ||
node.afterName = this.spacesFromStart(params); | ||
this.raw(node, "params", params); | ||
this.raw(node, 'params', params); | ||
if (last) { | ||
@@ -339,7 +353,7 @@ token = params[params.length - 1]; | ||
this.spaces = node.between; | ||
node.between = ""; | ||
node.between = ''; | ||
} | ||
} else { | ||
node.afterName = ""; | ||
node.params = ""; | ||
node.afterName = ''; | ||
node.params = ''; | ||
} | ||
@@ -359,4 +373,4 @@ | ||
this.current.after = (this.current.after || "") + this.spaces; | ||
this.spaces = ""; | ||
this.current.after = (this.current.after || '') + this.spaces; | ||
this.spaces = ''; | ||
@@ -367,5 +381,5 @@ if (this.current.parent) { | ||
} else if (!this.input.safe) { | ||
throw this.input.error("Unexpected }", token[2], token[3]); | ||
throw this.input.error('Unexpected }', token[2], token[3]); | ||
} else { | ||
this.current.after += "}"; | ||
this.current.after += '}'; | ||
} | ||
@@ -377,3 +391,3 @@ }; | ||
var pos = this.current.source.start; | ||
throw this.input.error("Unclosed block", pos.line, pos.column); | ||
throw this.input.error('Unclosed block', pos.line, pos.column); | ||
} | ||
@@ -384,7 +398,7 @@ | ||
} | ||
this.current.after = (this.current.after || "") + this.spaces; | ||
this.current.after = (this.current.after || '') + this.spaces; | ||
while (this.current.parent) { | ||
this.current = this.current.parent; | ||
this.current.after = ""; | ||
this.current.after = ''; | ||
} | ||
@@ -398,5 +412,5 @@ }; | ||
node.prop = token[1]; | ||
node.between = ""; | ||
node.between = ''; | ||
} else { | ||
throw this.input.error("Unknown word", token[2], token[3]); | ||
throw this.input.error('Unknown word', token[2], token[3]); | ||
} | ||
@@ -415,12 +429,12 @@ }; | ||
if (type === "(") { | ||
if (type === '(') { | ||
brackets += 1; | ||
} else if (type === ")") { | ||
} else if (type === ')') { | ||
brackets -= 0; | ||
} else if (brackets === 0 && type === ":") { | ||
} else if (brackets === 0 && type === ':') { | ||
if (!prev && this.input.safe) { | ||
continue; | ||
} else if (!prev) { | ||
throw this.input.error("Double colon", token[2], token[3]); | ||
} else if (prev[0] === "word" && prev[1] === "progid") { | ||
throw this.input.error('Double colon', token[2], token[3]); | ||
} else if (prev[0] === 'word' && prev[1] === 'progid') { | ||
continue; | ||
@@ -441,6 +455,6 @@ } else { | ||
for (split = colon - 1; split >= 0; split--) { | ||
if (tokens[split][0] === "word") break; | ||
if (tokens[split][0] === 'word') break; | ||
} | ||
for (split -= 1; split >= 0; split--) { | ||
if (tokens[split][0] !== "space") { | ||
if (tokens[split][0] !== 'space') { | ||
split += 1; | ||
@@ -456,3 +470,3 @@ break; | ||
token = tokens[j]; | ||
if (token[0] !== "space") { | ||
if (token[0] !== 'space') { | ||
founded += 1; | ||
@@ -462,3 +476,3 @@ if (founded === 2) break; | ||
} | ||
throw this.input.error("Missed semicolon", token[2], token[3]); | ||
throw this.input.error('Missed semicolon', token[2], token[3]); | ||
} | ||
@@ -474,4 +488,4 @@ }; | ||
node.before = this.spaces; | ||
this.spaces = ""; | ||
if (node.type !== "comment") this.semicolon = false; | ||
this.spaces = ''; | ||
if (node.type !== 'comment') this.semicolon = false; | ||
}; | ||
@@ -481,3 +495,3 @@ | ||
var token = undefined; | ||
var value = ""; | ||
var value = ''; | ||
var clean = true; | ||
@@ -494,3 +508,3 @@ for (var _iterator = tokens, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
if (token[0] === "comment") { | ||
if (token[0] === 'comment') { | ||
clean = false; | ||
@@ -502,3 +516,3 @@ } else { | ||
if (!clean) { | ||
var origin = ""; | ||
var origin = ''; | ||
for (var _iterator2 = tokens, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { | ||
@@ -515,3 +529,3 @@ if (_isArray2) { | ||
origin += token[1]; | ||
}node["_" + prop] = { value: value, raw: origin }; | ||
}node['_' + prop] = { value: value, raw: origin }; | ||
} | ||
@@ -523,6 +537,6 @@ node[prop] = value; | ||
var next = undefined; | ||
var spaces = ""; | ||
var spaces = ''; | ||
while (tokens.length) { | ||
next = tokens[tokens.length - 1][0]; | ||
if (next !== "space" && next !== "comment") break; | ||
if (next !== 'space' && next !== 'comment') break; | ||
spaces += tokens.pop()[1]; | ||
@@ -535,6 +549,6 @@ } | ||
var next = undefined; | ||
var spaces = ""; | ||
var spaces = ''; | ||
while (tokens.length) { | ||
next = tokens[0][0]; | ||
if (next !== "space" && next !== "comment") break; | ||
if (next !== 'space' && next !== 'comment') break; | ||
spaces += tokens.shift()[1]; | ||
@@ -546,3 +560,3 @@ } | ||
Parser.prototype.stringFrom = function stringFrom(tokens, from) { | ||
var result = ""; | ||
var result = ''; | ||
for (var i = from; i < tokens.length; i++) { | ||
@@ -558,2 +572,3 @@ result += tokens[i][1]; | ||
module.exports = Parser; | ||
exports['default'] = Parser; | ||
module.exports = exports['default']; |
@@ -1,23 +0,43 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var Declaration = _interopRequire(require("./declaration")); | ||
exports.__esModule = true; | ||
var Processor = _interopRequire(require("./processor")); | ||
var _Declaration = require('./declaration'); | ||
var Comment = _interopRequire(require("./comment")); | ||
var _Declaration2 = _interopRequireWildcard(_Declaration); | ||
var AtRule = _interopRequire(require("./at-rule")); | ||
var _Processor = require('./processor'); | ||
var vendor = _interopRequire(require("./vendor")); | ||
var _Processor2 = _interopRequireWildcard(_Processor); | ||
var parse = _interopRequire(require("./parse")); | ||
var _Comment = require('./comment'); | ||
var list = _interopRequire(require("./list")); | ||
var _Comment2 = _interopRequireWildcard(_Comment); | ||
var Rule = _interopRequire(require("./rule")); | ||
var _AtRule = require('./at-rule'); | ||
var Root = _interopRequire(require("./root")); | ||
var _AtRule2 = _interopRequireWildcard(_AtRule); | ||
var _vendor = require('./vendor'); | ||
var _vendor2 = _interopRequireWildcard(_vendor); | ||
var _parse = require('./parse'); | ||
var _parse2 = _interopRequireWildcard(_parse); | ||
var _list = require('./list'); | ||
var _list2 = _interopRequireWildcard(_list); | ||
var _Rule = require('./rule'); | ||
var _Rule2 = _interopRequireWildcard(_Rule); | ||
var _Root = require('./root'); | ||
var _Root2 = _interopRequireWildcard(_Root); | ||
var postcss = function postcss() { | ||
@@ -31,3 +51,3 @@ for (var _len = arguments.length, plugins = Array(_len), _key = 0; _key < _len; _key++) { | ||
} | ||
return new Processor(plugins); | ||
return new _Processor2['default'](plugins); | ||
}; | ||
@@ -39,3 +59,3 @@ | ||
transformer.postcssPlugin = name; | ||
transformer.postcssVersion = Processor.prototype.version; | ||
transformer.postcssVersion = _Processor2['default'].prototype.version; | ||
return transformer; | ||
@@ -48,24 +68,25 @@ }; | ||
postcss.vendor = vendor; | ||
postcss.vendor = _vendor2['default']; | ||
postcss.parse = parse; | ||
postcss.parse = _parse2['default']; | ||
postcss.list = list; | ||
postcss.list = _list2['default']; | ||
postcss.comment = function (defaults) { | ||
return new Comment(defaults); | ||
return new _Comment2['default'](defaults); | ||
}; | ||
postcss.atRule = function (defaults) { | ||
return new AtRule(defaults); | ||
return new _AtRule2['default'](defaults); | ||
}; | ||
postcss.decl = function (defaults) { | ||
return new Declaration(defaults); | ||
return new _Declaration2['default'](defaults); | ||
}; | ||
postcss.rule = function (defaults) { | ||
return new Rule(defaults); | ||
return new _Rule2['default'](defaults); | ||
}; | ||
postcss.root = function (defaults) { | ||
return new Root(defaults); | ||
return new _Root2['default'](defaults); | ||
}; | ||
module.exports = postcss; | ||
exports['default'] = postcss; | ||
module.exports = exports['default']; |
@@ -1,15 +0,23 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var Base64 = require("js-base64").Base64; | ||
exports.__esModule = true; | ||
var mozilla = _interopRequire(require("source-map")); | ||
var _Base64 = require('js-base64'); | ||
var path = _interopRequire(require("path")); | ||
var _mozilla = require('source-map'); | ||
var fs = _interopRequire(require("fs")); | ||
var _mozilla2 = _interopRequireWildcard(_mozilla); | ||
var _path = require('path'); | ||
var _path2 = _interopRequireWildcard(_path); | ||
var _fs = require('fs'); | ||
var _fs2 = _interopRequireWildcard(_fs); | ||
var PreviousMap = (function () { | ||
@@ -20,3 +28,3 @@ function PreviousMap(css, opts) { | ||
this.loadAnnotation(css); | ||
this.inline = this.startWith(this.annotation, "data:"); | ||
this.inline = this.startWith(this.annotation, 'data:'); | ||
@@ -30,3 +38,3 @@ var prev = opts.map ? opts.map.prev : undefined; | ||
if (!this.consumerCache) { | ||
this.consumerCache = new mozilla.SourceMapConsumer(this.text); | ||
this.consumerCache = new _mozilla2['default'].SourceMapConsumer(this.text); | ||
} | ||
@@ -52,4 +60,4 @@ return this.consumerCache; | ||
PreviousMap.prototype.decodeInline = function decodeInline(text) { | ||
var uri = "data:application/json,"; | ||
var base64 = "data:application/json;base64,"; | ||
var uri = 'data:application/json,'; | ||
var base64 = 'data:application/json;base64,'; | ||
@@ -59,6 +67,6 @@ if (this.startWith(text, uri)) { | ||
} else if (this.startWith(text, base64)) { | ||
return Base64.decode(text.substr(base64.length)); | ||
return _Base64.Base64.decode(text.substr(base64.length)); | ||
} else { | ||
var encoding = text.match(/data:application\/json;([^,]+),/)[1]; | ||
throw new Error("Unsupported source map encoding " + encoding); | ||
throw new Error('Unsupported source map encoding ' + encoding); | ||
} | ||
@@ -71,12 +79,12 @@ }; | ||
}if (prev) { | ||
if (typeof prev === "string") { | ||
if (typeof prev === 'string') { | ||
return prev; | ||
} else if (prev instanceof mozilla.SourceMapConsumer) { | ||
return mozilla.SourceMapGenerator.fromSourceMap(prev).toString(); | ||
} else if (prev instanceof mozilla.SourceMapGenerator) { | ||
} else if (prev instanceof _mozilla2['default'].SourceMapConsumer) { | ||
return _mozilla2['default'].SourceMapGenerator.fromSourceMap(prev).toString(); | ||
} else if (prev instanceof _mozilla2['default'].SourceMapGenerator) { | ||
return prev.toString(); | ||
} else if (typeof prev === "object" && prev.mappings) { | ||
} else if (typeof prev === 'object' && prev.mappings) { | ||
return JSON.stringify(prev); | ||
} else { | ||
throw new Error("Unsupported previous source map format: " + prev.toString()); | ||
throw new Error('Unsupported previous source map format: ' + prev.toString()); | ||
} | ||
@@ -87,7 +95,7 @@ } else if (this.inline) { | ||
var map = this.annotation; | ||
if (file) map = path.join(path.dirname(file), map); | ||
if (file) map = _path2['default'].join(_path2['default'].dirname(file), map); | ||
this.root = path.dirname(map); | ||
if (fs.existsSync && fs.existsSync(map)) { | ||
return fs.readFileSync(map, "utf-8").toString().trim(); | ||
this.root = _path2['default'].dirname(map); | ||
if (_fs2['default'].existsSync && _fs2['default'].existsSync(map)) { | ||
return _fs2['default'].readFileSync(map, 'utf-8').toString().trim(); | ||
} else { | ||
@@ -102,2 +110,3 @@ return false; | ||
module.exports = PreviousMap; | ||
exports['default'] = PreviousMap; | ||
module.exports = exports['default']; |
@@ -1,9 +0,13 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var LazyResult = _interopRequire(require("./lazy-result")); | ||
exports.__esModule = true; | ||
var _LazyResult = require('./lazy-result'); | ||
var _LazyResult2 = _interopRequireWildcard(_LazyResult); | ||
var Processor = (function () { | ||
@@ -24,3 +28,3 @@ function Processor() { | ||
plugin = this.normalize(plugin); | ||
if (typeof plugin === "object" && Array.isArray(plugin.plugins)) { | ||
if (typeof plugin === 'object' && Array.isArray(plugin.plugins)) { | ||
this.plugins = this.plugins.concat(plugin.plugins); | ||
@@ -36,3 +40,3 @@ } else { | ||
return new LazyResult(this, css, opts); | ||
return new _LazyResult2['default'](this, css, opts); | ||
}; | ||
@@ -42,3 +46,3 @@ | ||
var type = typeof plugin; | ||
if ((type === "object" || type === "function") && plugin.postcss) { | ||
if ((type === 'object' || type === 'function') && plugin.postcss) { | ||
return plugin.postcss; | ||
@@ -53,4 +57,5 @@ } else { | ||
module.exports = Processor; | ||
exports['default'] = Processor; | ||
Processor.prototype.version = require("../package").version; | ||
Processor.prototype.version = require('../package').version; | ||
module.exports = exports['default']; |
@@ -1,13 +0,19 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var warnOnce = _interopRequire(require("./warn-once")); | ||
exports.__esModule = true; | ||
var Warning = _interopRequire(require("./warning")); | ||
var _warnOnce = require('./warn-once'); | ||
var _warnOnce2 = _interopRequireWildcard(_warnOnce); | ||
var _Warning = require('./warning'); | ||
var _Warning2 = _interopRequireWildcard(_Warning); | ||
var Result = (function () { | ||
@@ -38,3 +44,3 @@ function Result(processor, root, opts) { | ||
this.messages.push(new Warning(text, opts)); | ||
this.messages.push(new _Warning2['default'](text, opts)); | ||
}; | ||
@@ -44,20 +50,19 @@ | ||
return this.messages.filter(function (i) { | ||
return i.type === "warning"; | ||
return i.type === 'warning'; | ||
}); | ||
}; | ||
_createClass(Result, { | ||
from: { | ||
get: function () { | ||
warnOnce("result.from is deprecated and will be removed in 5.0. " + "Use result.opts.from instead."); | ||
return this.opts.from; | ||
} | ||
}, | ||
to: { | ||
get: function () { | ||
warnOnce("result.to is deprecated and will be removed in 5.0. " + "Use result.opts.to instead."); | ||
return this.opts.to; | ||
} | ||
_createClass(Result, [{ | ||
key: 'from', | ||
get: function () { | ||
_warnOnce2['default']('result.from is deprecated and will be removed in 5.0. ' + 'Use result.opts.from instead.'); | ||
return this.opts.from; | ||
} | ||
}); | ||
}, { | ||
key: 'to', | ||
get: function () { | ||
_warnOnce2['default']('result.to is deprecated and will be removed in 5.0. ' + 'Use result.opts.to instead.'); | ||
return this.opts.to; | ||
} | ||
}]); | ||
@@ -67,2 +72,3 @@ return Result; | ||
module.exports = Result; | ||
exports['default'] = Result; | ||
module.exports = exports['default']; |
@@ -1,11 +0,15 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var Container = _interopRequire(require("./container")); | ||
exports.__esModule = true; | ||
var _Container2 = require('./container'); | ||
var _Container3 = _interopRequireWildcard(_Container2); | ||
var Root = (function (_Container) { | ||
@@ -15,5 +19,5 @@ function Root(defaults) { | ||
this.type = "root"; | ||
this.nodes = []; | ||
_Container.call(this, defaults); | ||
if (!this.nodes) this.nodes = []; | ||
this.type = 'root'; | ||
} | ||
@@ -37,3 +41,3 @@ | ||
if (sample) { | ||
if (type === "prepend") { | ||
if (type === 'prepend') { | ||
if (this.nodes.length > 1) { | ||
@@ -75,4 +79,4 @@ sample.before = this.nodes[1].before; | ||
var LazyResult = require("./lazy-result"); | ||
var Processor = require("./processor"); | ||
var LazyResult = require('./lazy-result'); | ||
var Processor = require('./processor'); | ||
@@ -84,4 +88,5 @@ var lazy = new LazyResult(new Processor(), this, opts); | ||
return Root; | ||
})(Container); | ||
})(_Container3['default']); | ||
module.exports = Root; | ||
exports['default'] = Root; | ||
module.exports = exports['default']; |
@@ -1,15 +0,21 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (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) subClass.__proto__ = superClass; }; | ||
var Container = _interopRequire(require("./container")); | ||
exports.__esModule = true; | ||
var list = _interopRequire(require("./list")); | ||
var _Container2 = require('./container'); | ||
var _Container3 = _interopRequireWildcard(_Container2); | ||
var _list = require('./list'); | ||
var _list2 = _interopRequireWildcard(_list); | ||
var Rule = (function (_Container) { | ||
@@ -19,5 +25,5 @@ function Rule(defaults) { | ||
this.type = "rule"; | ||
this.nodes = []; | ||
_Container.call(this, defaults); | ||
if (!this.nodes) this.nodes = []; | ||
this.type = 'rule'; | ||
} | ||
@@ -28,19 +34,19 @@ | ||
Rule.prototype.stringify = function stringify(builder) { | ||
this.stringifyBlock(builder, this.stringifyRaw("selector")); | ||
this.stringifyBlock(builder, this.stringifyRaw('selector')); | ||
}; | ||
_createClass(Rule, { | ||
selectors: { | ||
get: function () { | ||
return list.comma(this.selector); | ||
}, | ||
set: function (values) { | ||
this.selector = values.join(", "); | ||
} | ||
_createClass(Rule, [{ | ||
key: 'selectors', | ||
get: function () { | ||
return _list2['default'].comma(this.selector); | ||
}, | ||
set: function (values) { | ||
this.selector = values.join(', '); | ||
} | ||
}); | ||
}]); | ||
return Rule; | ||
})(Container); | ||
})(_Container3['default']); | ||
module.exports = Rule; | ||
exports['default'] = Rule; | ||
module.exports = exports['default']; |
@@ -1,21 +0,22 @@ | ||
"use strict"; | ||
'use strict'; | ||
module.exports = tokenize; | ||
var singleQuote = "'".charCodeAt(0), | ||
doubleQuote = "\"".charCodeAt(0), | ||
backslash = "\\".charCodeAt(0), | ||
slash = "/".charCodeAt(0), | ||
newline = "\n".charCodeAt(0), | ||
space = " ".charCodeAt(0), | ||
feed = "\f".charCodeAt(0), | ||
tab = "\t".charCodeAt(0), | ||
cr = "\r".charCodeAt(0), | ||
openBracket = "(".charCodeAt(0), | ||
closeBracket = ")".charCodeAt(0), | ||
openCurly = "{".charCodeAt(0), | ||
closeCurly = "}".charCodeAt(0), | ||
semicolon = ";".charCodeAt(0), | ||
asterisk = "*".charCodeAt(0), | ||
colon = ":".charCodeAt(0), | ||
at = "@".charCodeAt(0), | ||
exports.__esModule = true; | ||
exports['default'] = tokenize; | ||
var singleQuote = '\''.charCodeAt(0), | ||
doubleQuote = '"'.charCodeAt(0), | ||
backslash = '\\'.charCodeAt(0), | ||
slash = '/'.charCodeAt(0), | ||
newline = '\n'.charCodeAt(0), | ||
space = ' '.charCodeAt(0), | ||
feed = '\f'.charCodeAt(0), | ||
tab = '\t'.charCodeAt(0), | ||
cr = '\r'.charCodeAt(0), | ||
openBracket = '('.charCodeAt(0), | ||
closeBracket = ')'.charCodeAt(0), | ||
openCurly = '{'.charCodeAt(0), | ||
closeCurly = '}'.charCodeAt(0), | ||
semicolon = ';'.charCodeAt(0), | ||
asterisk = '*'.charCodeAt(0), | ||
colon = ':'.charCodeAt(0), | ||
at = '@'.charCodeAt(0), | ||
atEnd = /[ \n\t\r\{\(\)'"\\/]/g, | ||
@@ -51,3 +52,3 @@ wordEnd = /[ \n\t\r\(\)\{\}:;@!'"\\]|\/(?=\*)/g, | ||
} else { | ||
throw input.error("Unclosed " + what, line, pos - offset); | ||
throw input.error('Unclosed ' + what, line, pos - offset); | ||
} | ||
@@ -80,3 +81,3 @@ }; | ||
tokens.push(["space", css.slice(pos, next)]); | ||
tokens.push(['space', css.slice(pos, next)]); | ||
pos = next - 1; | ||
@@ -86,25 +87,25 @@ break; | ||
case openCurly: | ||
tokens.push(["{", "{", line, pos - offset]); | ||
tokens.push(['{', '{', line, pos - offset]); | ||
break; | ||
case closeCurly: | ||
tokens.push(["}", "}", line, pos - offset]); | ||
tokens.push(['}', '}', line, pos - offset]); | ||
break; | ||
case colon: | ||
tokens.push([":", ":", line, pos - offset]); | ||
tokens.push([':', ':', line, pos - offset]); | ||
break; | ||
case semicolon: | ||
tokens.push([";", ";", line, pos - offset]); | ||
tokens.push([';', ';', line, pos - offset]); | ||
break; | ||
case openBracket: | ||
next = css.indexOf(")", pos + 1); | ||
next = css.indexOf(')', pos + 1); | ||
content = css.slice(pos, next + 1); | ||
if (next === -1 || badBracket.test(content)) { | ||
tokens.push(["(", "(", line, pos - offset]); | ||
tokens.push(['(', '(', line, pos - offset]); | ||
} else { | ||
tokens.push(["brackets", content, line, pos - offset, line, next - offset]); | ||
tokens.push(['brackets', content, line, pos - offset, line, next - offset]); | ||
pos = next; | ||
@@ -116,3 +117,3 @@ } | ||
case closeBracket: | ||
tokens.push([")", ")", line, pos - offset]); | ||
tokens.push([')', ')', line, pos - offset]); | ||
break; | ||
@@ -122,3 +123,3 @@ | ||
case doubleQuote: | ||
quote = code === singleQuote ? "'" : "\""; | ||
quote = code === singleQuote ? '\'' : '"'; | ||
next = pos; | ||
@@ -128,3 +129,3 @@ do { | ||
next = css.indexOf(quote, next + 1); | ||
if (next === -1) unclosed("quote", quote); | ||
if (next === -1) unclosed('quote', quote); | ||
escapePos = next; | ||
@@ -137,3 +138,3 @@ while (css.charCodeAt(escapePos - 1) === backslash) { | ||
tokens.push(["string", css.slice(pos, next + 1), line, pos - offset, line, next - offset]); | ||
tokens.push(['string', css.slice(pos, next + 1), line, pos - offset, line, next - offset]); | ||
pos = next; | ||
@@ -150,3 +151,3 @@ break; | ||
} | ||
tokens.push(["at-word", css.slice(pos, next + 1), line, pos - offset, line, next - offset]); | ||
tokens.push(['at-word', css.slice(pos, next + 1), line, pos - offset, line, next - offset]); | ||
pos = next; | ||
@@ -166,3 +167,3 @@ break; | ||
} | ||
tokens.push(["word", css.slice(pos, next + 1), line, pos - offset, line, next - offset]); | ||
tokens.push(['word', css.slice(pos, next + 1), line, pos - offset, line, next - offset]); | ||
pos = next; | ||
@@ -173,7 +174,7 @@ break; | ||
if (code === slash && css.charCodeAt(pos + 1) === asterisk) { | ||
next = css.indexOf("*/", pos + 2) + 1; | ||
if (next === 0) unclosed("comment", "*/"); | ||
next = css.indexOf('*/', pos + 2) + 1; | ||
if (next === 0) unclosed('comment', '*/'); | ||
content = css.slice(pos, next + 1); | ||
lines = content.split("\n"); | ||
lines = content.split('\n'); | ||
last = lines.length - 1; | ||
@@ -189,3 +190,3 @@ | ||
tokens.push(["comment", content, line, pos - offset, nextLine, next - nextOffset]); | ||
tokens.push(['comment', content, line, pos - offset, nextLine, next - nextOffset]); | ||
@@ -204,3 +205,3 @@ offset = nextOffset; | ||
tokens.push(["word", css.slice(pos, next + 1), line, pos - offset, line, next - offset]); | ||
tokens.push(['word', css.slice(pos, next + 1), line, pos - offset, line, next - offset]); | ||
pos = next; | ||
@@ -216,2 +217,4 @@ } | ||
return tokens; | ||
} | ||
} | ||
module.exports = exports['default']; |
@@ -1,11 +0,12 @@ | ||
"use strict"; | ||
'use strict'; | ||
module.exports = { | ||
exports.__esModule = true; | ||
exports['default'] = { | ||
prefix: function prefix(prop) { | ||
if (prop[0] === "-") { | ||
var sep = prop.indexOf("-", 1); | ||
if (prop[0] === '-') { | ||
var sep = prop.indexOf('-', 1); | ||
return prop.substr(0, sep + 1); | ||
} else { | ||
return ""; | ||
return ''; | ||
} | ||
@@ -15,4 +16,4 @@ }, | ||
unprefixed: function unprefixed(prop) { | ||
if (prop[0] === "-") { | ||
var sep = prop.indexOf("-", 1); | ||
if (prop[0] === '-') { | ||
var sep = prop.indexOf('-', 1); | ||
return prop.substr(sep + 1); | ||
@@ -24,2 +25,3 @@ } else { | ||
}; | ||
}; | ||
module.exports = exports['default']; |
@@ -1,4 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
module.exports = warnOnce; | ||
exports.__esModule = true; | ||
exports['default'] = warnOnce; | ||
var printed = {}; | ||
@@ -11,3 +12,5 @@ | ||
if (typeof console !== "undefined" && console.warn) console.warn(message); | ||
} | ||
if (typeof console !== 'undefined' && console.warn) console.warn(message); | ||
} | ||
module.exports = exports['default']; |
@@ -1,5 +0,7 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
exports.__esModule = true; | ||
var Warning = (function () { | ||
@@ -11,3 +13,3 @@ function Warning(text) { | ||
this.type = "warning"; | ||
this.type = 'warning'; | ||
this.text = text; | ||
@@ -23,3 +25,3 @@ for (var opt in opts) { | ||
} else if (this.plugin) { | ||
return this.plugin + ": " + this.text; | ||
return this.plugin + ': ' + this.text; | ||
} else { | ||
@@ -33,2 +35,3 @@ return this.text; | ||
module.exports = Warning; | ||
exports['default'] = Warning; | ||
module.exports = exports['default']; |
{ | ||
"name": "postcss", | ||
"version": "4.1.2", | ||
"version": "4.1.3", | ||
"description": "Tool for transforming CSS with JS plugins", | ||
@@ -31,4 +31,5 @@ "keywords": [ | ||
"gulp-eslint": "0.6.0", | ||
"browserify": "9.0.4", | ||
"gulp-babel": "4.0.1", | ||
"es6-promise": "2.0.1", | ||
"browserify": "9.0.7", | ||
"gulp-babel": "5.0.0", | ||
"gulp-bench": "1.1.0", | ||
@@ -43,3 +44,3 @@ "gulp-mocha": "2.0.1", | ||
"stylecow": "5.0.0", | ||
"request": "2.54.0", | ||
"request": "2.55.0", | ||
"cssnext": "1.2.1", | ||
@@ -54,5 +55,5 @@ "rework": "1.0.1", | ||
"gulp": "3.8.11", | ||
"less": "2.4.0", | ||
"less": "2.5.0", | ||
"chai": "2.2.0", | ||
"babel": "4.7.16" | ||
"babel": "5.0.8" | ||
}, | ||
@@ -59,0 +60,0 @@ "scripts": { |
@@ -16,2 +16,19 @@ # PostCSS [![Build Status](https://travis-ci.org/postcss/postcss.svg)](https://travis-ci.org/postcss/postcss) [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/postcss/postcss?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
Twitter account for articles, releases, and new plugins: [@postcss]. | ||
Weibo account: [postcss]. | ||
[Examples](#what-is-postcss) | [Features](#features) | [Quick Start](#quick-start) | [Plugins](#plugins) | [Usages](#usage) | [Plugin Development](#how-to-develop-postcss-plugin) | ||
--- | --- | --- | --- | --- | --- | ||
<a href="https://evilmartians.com/?utm_source=postcss"> | ||
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"> | ||
</a> | ||
[Autoprefixer]: https://github.com/postcss/autoprefixer | ||
[@postcss]: https://twitter.com/postcss | ||
[postcss]: http://weibo.com/postcss | ||
[cssnext]: https://github.com/cssnext/cssnext | ||
## What is PostCSS | ||
PostCSS itself is very small. It includes only a CSS parser, | ||
@@ -79,15 +96,5 @@ a CSS node tree API, a source map generator, and a node tree stringifier. | ||
Twitter account for articles, releases, and new plugins: [@postcss]. | ||
Weibo account: [postcss]. | ||
<a href="https://evilmartians.com/?utm_source=postcss"> | ||
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"> | ||
</a> | ||
[Autoprefixer]: https://github.com/postcss/autoprefixer | ||
[@postcss]: https://twitter.com/postcss | ||
[postcss]: http://weibo.com/postcss | ||
[cssnext]: https://github.com/cssnext/cssnext | ||
## How PostCSS differs from Preprocessors | ||
### How PostCSS Differs from Preprocessors | ||
@@ -201,4 +208,6 @@ Sass, Less and Stylus provide specialized languages that you can use to write | ||
## Plugins Packs | ||
## Plugins | ||
### Packs | ||
* [cssnext] contains plugins that allow you to use future CSS features today. | ||
@@ -211,4 +220,2 @@ * [AtCSS] contains plugins that transform your CSS according | ||
## Plugins | ||
### Future CSS Syntax | ||
@@ -236,2 +243,3 @@ | ||
* [`postcss-epub`] adds the `-epub-` prefix to relevant properties. | ||
* [`postcss-image-set`] adds `background-image` with first image for `image-set()` | ||
* [`postcss-opacity`] adds opacity filter for IE8. | ||
@@ -268,2 +276,3 @@ * [`postcss-pseudoelements`] Convert `::` selectors into `:` selectors | ||
(when expressions involve the same units). | ||
* [`postcss-colormin`] reduces color values to their smallest representations. | ||
* [`postcss-data-packer`] moves embedded Base64 data out of the stylesheet | ||
@@ -273,2 +282,3 @@ and into a separate file. | ||
* [`postcss-discard-empty`] removes empty rules and declarations. | ||
* [`postcss-discard-font-face`] removes unused `@font-face` declarations. | ||
* [`postcss-font-family`] optimises `font` and `font-family` declarations. | ||
@@ -278,2 +288,3 @@ * [`postcss-import`] inlines the stylesheets referred to by `@import` rules. | ||
selectors/properties overlap. | ||
* [`postcss-minify-font-weight`] compresses `font-weight` values. | ||
* [`postcss-minify-selectors`] normalizes selectors for better compression. | ||
@@ -292,2 +303,3 @@ * [`postcss-normalize-url`] normalizes `url()`s and trims quotes | ||
* [`postcss-default-unit`] adds default unit to numeric CSS properties. | ||
* [`postcss-easings`] replaces easing names from easings.net | ||
@@ -304,2 +316,4 @@ with `cubic-bezier()` functions. | ||
* [`postcss-discard-comments`] removes comments based on rules you specify. | ||
* [`postcss-messages`] displays warning messages from other plugins | ||
right in your browser. | ||
* [`postcss-single-charset`] ensures that there is one | ||
@@ -320,2 +334,4 @@ and only one `@charset` rule at the top of file. | ||
[`postcss-discard-duplicates`]: https://github.com/ben-eb/postcss-discard-duplicates | ||
[`postcss-minify-font-weight`]: https://github.com/ben-eb/postcss-minify-font-weight | ||
[`postcss-discard-font-face`]: https://github.com/ben-eb/postcss-discard-font-face | ||
[`postcss-custom-properties`]: https://github.com/postcss/postcss-custom-properties | ||
@@ -334,2 +350,3 @@ [`postcss-custom-selectors`]: https://github.com/postcss/postcss-custom-selectors | ||
[`postcss-simple-extend`]: https://github.com/davidtheclark/postcss-simple-extend | ||
[`postcss-default-unit`]: https://github.com/antyakushev/postcss-default-unit | ||
[`postcss-media-minmax`]: https://github.com/postcss/postcss-media-minmax | ||
@@ -349,3 +366,6 @@ [`postcss-custom-media`]: https://github.com/postcss/postcss-custom-media | ||
[`postcss-color-hwb`]: https://github.com/postcss/postcss-color-hwb | ||
[`postcss-image-set`]: https://github.com/alex499/postcss-image-set | ||
[`postcss-colormin`]: https://github.com/ben-eb/colormin | ||
[`pleeease-filters`]: https://github.com/iamvdo/pleeease-filters | ||
[`postcss-messages`]: https://github.com/postcss/postcss-messages | ||
[`postcss-easings`]: https://github.com/postcss/postcss-easings | ||
@@ -398,8 +418,5 @@ [`postcss-opacity`]: https://github.com/iamvdo/postcss-opacity | ||
If you uses node.js 0.10, you should add [some Promise polyfill]. | ||
Read the [PostCSS API] for more details. | ||
[some Promise polyfill]: https://github.com/jakearchibald/es6-promise | ||
[PostCSS API]: https://github.com/postcss/postcss/blob/master/API.md | ||
[PostCSS API]: https://github.com/postcss/postcss/blob/master/API.md | ||
@@ -406,0 +423,0 @@ ### Source Maps |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
183640
2442
496
30