Comparing version 0.54.5 to 0.54.6
@@ -78,2 +78,4 @@ /*! | ||
return this['visit' + name](node); | ||
case 'font-face': | ||
return this.visitFontFace(node); | ||
} | ||
@@ -99,2 +101,21 @@ }; | ||
/** | ||
* Visit FontFace `node`. | ||
* | ||
* @param {FontFace} node | ||
* @return {String} | ||
* @api private | ||
*/ | ||
Converter.prototype.visitFontFace = function(node){ | ||
var buf = this.indent + '@font-face'; | ||
buf += '\n'; | ||
++this.indents; | ||
for (var i = 0, len = node.declarations.length; i < len; ++i) { | ||
buf += this.visitDeclaration(node.declarations[i]); | ||
} | ||
--this.indents; | ||
return buf; | ||
}; | ||
/** | ||
* Visit Media `node`. | ||
@@ -101,0 +122,0 @@ * |
@@ -16,8 +16,2 @@ | ||
/** | ||
* Inherit from `Error.prototype`. | ||
*/ | ||
SyntaxError.prototype.__proto__ = Error.prototype; | ||
/** | ||
* Initialize a new `ParseError` with the given `msg`. | ||
@@ -32,3 +26,5 @@ * | ||
this.message = msg; | ||
Error.captureStackTrace(this, ParseError); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, ParseError); | ||
} | ||
} | ||
@@ -52,3 +48,5 @@ | ||
this.message = msg; | ||
Error.captureStackTrace(this, ParseError); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, ParseError); | ||
} | ||
} | ||
@@ -61,2 +59,1 @@ | ||
SyntaxError.prototype.__proto__ = Error.prototype; | ||
@@ -13,3 +13,3 @@ var utils = require('../utils'); | ||
module.exports = function adjust(color, prop, amount){ | ||
function adjust(color, prop, amount){ | ||
utils.assertColor(color, 'color'); | ||
@@ -30,1 +30,3 @@ utils.assertString(prop, 'prop'); | ||
}; | ||
adjust.params = ['color', 'prop', 'amount']; | ||
module.exports = adjust; |
@@ -25,3 +25,3 @@ var nodes = require('../nodes') | ||
module.exports = function alpha(color, value){ | ||
function alpha(color, value){ | ||
color = color.rgba; | ||
@@ -38,1 +38,3 @@ if (value) { | ||
}; | ||
alpha.params = ['color', 'value']; | ||
module.exports = alpha; |
@@ -12,5 +12,7 @@ var utils = require('../utils') | ||
module.exports = function basename(p, ext){ | ||
function basename(p, ext){ | ||
utils.assertString(p, 'path'); | ||
return path.basename(p.val, ext && ext.val); | ||
}; | ||
basename.params = ['p', 'ext']; | ||
module.exports = basename; |
@@ -24,3 +24,3 @@ var utils = require('../utils') | ||
module.exports = function blend(top, bottom){ | ||
function blend(top, bottom){ | ||
// TODO: different blend modes like overlay etc. | ||
@@ -39,1 +39,3 @@ utils.assertColor(top); | ||
}; | ||
blend.params = ['top', 'bottom']; | ||
module.exports = blend; |
@@ -22,3 +22,3 @@ var nodes = require('../nodes') | ||
module.exports = function blue(color, value){ | ||
function blue(color, value){ | ||
color = color.rgba; | ||
@@ -35,1 +35,3 @@ if (value) { | ||
}; | ||
blue.params = ['color', 'value']; | ||
module.exports = blue; |
@@ -51,3 +51,3 @@ var utils = require('../utils') | ||
module.exports = function component(color, name) { | ||
function component(color, name) { | ||
utils.assertColor(color, 'color'); | ||
@@ -62,1 +62,3 @@ utils.assertString(name, 'name'); | ||
}; | ||
component.params = ['color', 'name']; | ||
module.exports = component; |
@@ -25,3 +25,3 @@ var utils = require('../utils') | ||
module.exports = function contrast(top, bottom){ | ||
function contrast(top, bottom){ | ||
if ('rgba' != top.nodeName && 'hsla' != top.nodeName) { | ||
@@ -77,1 +77,3 @@ return new nodes.Literal('contrast(' + (top.isNull ? '' : top.toString()) + ')'); | ||
} | ||
contrast.params = ['top', 'bottom']; | ||
module.exports = contrast; |
@@ -12,5 +12,7 @@ var utils = require('../utils'); | ||
module.exports = function convert(str){ | ||
function convert(str){ | ||
utils.assertString(str, 'str'); | ||
return utils.parseString(str.string); | ||
}; | ||
convert.params = ['str']; | ||
module.exports = convert; |
@@ -13,3 +13,3 @@ var utils = require('../utils') | ||
module.exports = function define(name, expr, global){ | ||
function define(name, expr, global){ | ||
utils.assertType(name, 'string', 'name'); | ||
@@ -25,1 +25,3 @@ expr = utils.unwrap(expr); | ||
}; | ||
define.params = ['name', 'expr', 'global']; | ||
module.exports = define; |
@@ -12,5 +12,7 @@ var utils = require('../utils') | ||
module.exports = function dirname(p){ | ||
function dirname(p){ | ||
utils.assertString(p, 'path'); | ||
return path.dirname(p.val).replace(/\\/g, '/'); | ||
}; | ||
dirname.params = ['p']; | ||
module.exports = dirname; |
@@ -10,3 +10,3 @@ var utils = require('../utils'); | ||
module.exports = function error(msg){ | ||
function error(msg){ | ||
utils.assertType(msg, 'string', 'msg'); | ||
@@ -17,1 +17,3 @@ var err = new Error(msg.val); | ||
}; | ||
error.params = ['msg']; | ||
module.exports = error; |
@@ -12,5 +12,7 @@ var utils = require('../utils') | ||
module.exports = function extname(p){ | ||
function extname(p){ | ||
utils.assertString(p, 'path'); | ||
return path.extname(p.val); | ||
}; | ||
extname.params = ['p']; | ||
module.exports = extname; |
@@ -22,3 +22,3 @@ var nodes = require('../nodes') | ||
module.exports = function green(color, value){ | ||
function green(color, value){ | ||
color = color.rgba; | ||
@@ -35,1 +35,3 @@ if (value) { | ||
}; | ||
green.params = ['color', 'value']; | ||
module.exports = green; |
@@ -24,3 +24,3 @@ var utils = require('../utils') | ||
module.exports = function hsl(hue, saturation, lightness){ | ||
function hsl(hue, saturation, lightness){ | ||
if (1 == arguments.length) { | ||
@@ -37,1 +37,3 @@ utils.assertColor(hue, 'color'); | ||
}; | ||
hsl.params = ['hue', 'saturation', 'lightness']; | ||
module.exports = hsl; |
@@ -24,3 +24,3 @@ var utils = require('../utils') | ||
module.exports = function hsla(hue, saturation, lightness, alpha){ | ||
function hsla(hue, saturation, lightness, alpha){ | ||
switch (arguments.length) { | ||
@@ -55,1 +55,3 @@ case 1: | ||
}; | ||
hsla.params = ['hue', 'saturation', 'lightness', 'alpha']; | ||
module.exports = hsla; |
@@ -23,3 +23,3 @@ var nodes = require('../nodes') | ||
module.exports = function hue(color, value){ | ||
function hue(color, value){ | ||
if (value) { | ||
@@ -36,1 +36,3 @@ var hslaColor = color.hsla; | ||
}; | ||
hue.params = ['color', 'value']; | ||
module.exports = hue; |
@@ -35,3 +35,3 @@ var utils = require('../utils') | ||
module.exports = function imageSize(img, ignoreErr) { | ||
function imageSize(img, ignoreErr) { | ||
utils.assertType(img, 'string', 'img'); | ||
@@ -60,1 +60,3 @@ try { | ||
}; | ||
imageSize.params = ['img', 'ignoreErr']; | ||
module.exports = imageSize; |
@@ -15,2 +15,3 @@ | ||
, nodes = require('../nodes') | ||
, Buffer = require('safer-buffer').Buffer | ||
, fs = require('fs') | ||
@@ -70,3 +71,3 @@ , path = require('path') | ||
var type | ||
, buf = new Buffer(4); | ||
, buf = Buffer.alloc(4); | ||
@@ -112,3 +113,3 @@ fs.readSync(this.fd, buf, 0, 4, 0); | ||
case 'jpeg': | ||
buf = new Buffer(this.length); | ||
buf = Buffer.alloc(this.length); | ||
fs.readSync(this.fd, buf, 0, this.length, 0); | ||
@@ -132,3 +133,3 @@ offset = 4; | ||
case 'png': | ||
buf = new Buffer(8); | ||
buf = Buffer.alloc(8); | ||
// IHDR chunk width / height uint32_t big-endian | ||
@@ -140,3 +141,3 @@ fs.readSync(this.fd, buf, 0, 8, 16); | ||
case 'gif': | ||
buf = new Buffer(4); | ||
buf = Buffer.alloc(4); | ||
// width / height uint16_t little-endian | ||
@@ -149,3 +150,3 @@ fs.readSync(this.fd, buf, 0, 4, 6); | ||
offset = Math.min(this.length, 1024); | ||
buf = new Buffer(offset); | ||
buf = Buffer.alloc(offset); | ||
fs.readSync(this.fd, buf, 0, offset, 0); | ||
@@ -152,0 +153,0 @@ buf = buf.toString('utf8'); |
@@ -38,3 +38,3 @@ var utils = require('../utils') | ||
module.exports = function(path, local, namePrefix){ | ||
function json(path, local, namePrefix){ | ||
utils.assertString(path, 'path'); | ||
@@ -83,2 +83,4 @@ | ||
}; | ||
json.params = ['path', 'local', 'namePrefix']; | ||
module.exports = json; | ||
@@ -85,0 +87,0 @@ /** |
@@ -17,2 +17,4 @@ var utils = require('../utils'); | ||
return nodes[0].length; | ||
} else if (1 == nodes.length && 'string' == nodes[0].nodeName) { | ||
return nodes[0].val.length; | ||
} else { | ||
@@ -19,0 +21,0 @@ return nodes.length; |
@@ -23,3 +23,3 @@ var nodes = require('../nodes') | ||
module.exports = function lightness(color, value){ | ||
function lightness(color, value){ | ||
if (value) { | ||
@@ -36,1 +36,3 @@ var hslaColor = color.hsla; | ||
}; | ||
lightness.params = ['color', 'value']; | ||
module.exports = lightness; |
@@ -12,3 +12,3 @@ var utils = require('../utils') | ||
module.exports = function lookup(name){ | ||
function lookup(name){ | ||
utils.assertType(name, 'string', 'name'); | ||
@@ -18,2 +18,4 @@ var node = this.lookup(name.val); | ||
return this.visit(node); | ||
}; | ||
} | ||
lookup.params = ['name']; | ||
module.exports = lookup; |
@@ -24,3 +24,3 @@ var utils = require('../utils') | ||
module.exports = function luminosity(color){ | ||
function luminosity(color){ | ||
utils.assertColor(color); | ||
@@ -40,1 +40,3 @@ color = color.rgba; | ||
}; | ||
luminosity.params = ['color']; | ||
module.exports = luminosity; |
@@ -27,3 +27,3 @@ var utils = require('../utils') | ||
module.exports = function match(pattern, val, flags){ | ||
function match(pattern, val, flags){ | ||
utils.assertType(pattern, 'string', 'pattern'); | ||
@@ -33,3 +33,5 @@ utils.assertString(val, 'val'); | ||
return val.string.match(re); | ||
}; | ||
} | ||
match.params = ['pattern', 'val', 'flags']; | ||
module.exports = match; | ||
@@ -36,0 +38,0 @@ function validateFlags(flags) { |
@@ -11,4 +11,6 @@ var nodes = require('../nodes'); | ||
module.exports = function math(prop){ | ||
function math(prop){ | ||
return new nodes.Unit(Math[prop.string]); | ||
}; | ||
} | ||
math.params = ['prop']; | ||
module.exports = math; |
@@ -13,6 +13,8 @@ var utils = require('../utils') | ||
module.exports = function math(n, fn){ | ||
function math(n, fn){ | ||
utils.assertType(n, 'unit', 'n'); | ||
utils.assertString(fn, 'fn'); | ||
return new nodes.Unit(Math[fn.string](n.val), n.type); | ||
}; | ||
} | ||
math.params = ['n', 'fn']; | ||
module.exports = math; |
@@ -13,3 +13,3 @@ var utils = require('../utils'); | ||
module.exports = function operate(op, left, right){ | ||
function operate(op, left, right){ | ||
utils.assertType(op, 'string', 'op'); | ||
@@ -19,2 +19,4 @@ utils.assertPresent(left, 'left'); | ||
return left.operate(op.val, right); | ||
}; | ||
} | ||
operate.params = ['op', 'left', 'right']; | ||
module.exports = operate; |
@@ -12,3 +12,3 @@ var utils = require('../utils'); | ||
module.exports = function prefixClasses(prefix, block){ | ||
function prefixClasses(prefix, block){ | ||
utils.assertString(prefix, 'prefix'); | ||
@@ -23,2 +23,4 @@ utils.assertType(block, 'block', 'block'); | ||
return block; | ||
}; | ||
} | ||
prefixClasses.params = ['prefix', 'block']; | ||
module.exports = prefixClasses; |
@@ -16,3 +16,3 @@ var utils = require('../utils') | ||
module.exports = function range(start, stop, step){ | ||
function range(start, stop, step){ | ||
utils.assertType(start, 'unit', 'start'); | ||
@@ -33,2 +33,4 @@ utils.assertType(stop, 'unit', 'stop'); | ||
return list; | ||
}; | ||
} | ||
range.params = ['start', 'stop', 'step']; | ||
module.exports = range; |
@@ -22,3 +22,3 @@ var nodes = require('../nodes') | ||
module.exports = function red(color, value){ | ||
function red(color, value){ | ||
color = color.rgba; | ||
@@ -34,2 +34,4 @@ if (value) { | ||
return new nodes.Unit(color.r, ''); | ||
}; | ||
} | ||
red.params = ['color', 'value']; | ||
module.exports = red; |
@@ -12,3 +12,3 @@ var utils = require('../utils'); | ||
module.exports = function remove(object, key){ | ||
function remove(object, key){ | ||
utils.assertType(object, 'object', 'object'); | ||
@@ -18,2 +18,4 @@ utils.assertString(key, 'key'); | ||
return object; | ||
}; | ||
} | ||
remove.params = ['object', 'key']; | ||
module.exports = remove; |
@@ -14,3 +14,3 @@ var utils = require('../utils') | ||
module.exports = function replace(pattern, replacement, val){ | ||
function replace(pattern, replacement, val){ | ||
utils.assertString(pattern, 'pattern'); | ||
@@ -24,2 +24,4 @@ utils.assertString(replacement, 'replacement'); | ||
: new nodes.String(res); | ||
}; | ||
} | ||
replace.params = ['pattern', 'replacement', 'val']; | ||
module.exports = replace; |
@@ -23,3 +23,3 @@ var utils = require('../utils') | ||
module.exports = function rgb(red, green, blue){ | ||
function rgb(red, green, blue){ | ||
switch (arguments.length) { | ||
@@ -41,2 +41,4 @@ case 1: | ||
} | ||
}; | ||
} | ||
rgb.params = ['red', 'green', 'blue']; | ||
module.exports = rgb; |
@@ -26,3 +26,3 @@ var utils = require('../utils') | ||
module.exports = function rgba(red, green, blue, alpha){ | ||
function rgba(red, green, blue, alpha){ | ||
switch (arguments.length) { | ||
@@ -60,2 +60,4 @@ case 1: | ||
} | ||
}; | ||
} | ||
rgba.params = ['red', 'green', 'blue', 'alpha']; | ||
module.exports = rgba; |
@@ -23,3 +23,3 @@ var nodes = require('../nodes') | ||
module.exports = function saturation(color, value){ | ||
function saturation(color, value){ | ||
if (value) { | ||
@@ -35,3 +35,4 @@ var hslaColor = color.hsla; | ||
return component(color, new nodes.String('saturation')); | ||
}; | ||
} | ||
saturation.params = ['color', 'value']; | ||
module.exports = saturation; |
@@ -11,3 +11,3 @@ var utils = require('../utils'); | ||
module.exports = function selectorExists(sel) { | ||
function selectorExists(sel) { | ||
utils.assertString(sel, 'selector'); | ||
@@ -24,2 +24,4 @@ | ||
return sel.string in this.__selectorsMap__; | ||
}; | ||
} | ||
selectorExists.params = ['sel']; | ||
module.exports = selectorExists; |
@@ -5,3 +5,3 @@ var utils = require('../utils'), | ||
/** | ||
* This is a heler function for the slice method | ||
* This is a helper function for the slice method | ||
* | ||
@@ -8,0 +8,0 @@ * @param {String|Ident} vals |
@@ -13,3 +13,3 @@ var utils = require('../utils') | ||
module.exports = function split(delim, val){ | ||
function split(delim, val){ | ||
utils.assertString(delim, 'delimiter'); | ||
@@ -26,2 +26,4 @@ utils.assertString(val, 'val'); | ||
return expr; | ||
}; | ||
} | ||
split.params = ['delim', 'val']; | ||
module.exports = split; |
@@ -14,3 +14,3 @@ var utils = require('../utils') | ||
module.exports = function substr(val, start, length){ | ||
function substr(val, start, length){ | ||
utils.assertString(val, 'val'); | ||
@@ -23,2 +23,4 @@ utils.assertType(start, 'unit', 'start'); | ||
: new nodes.String(res); | ||
}; | ||
} | ||
substr.params = ['val', 'start', 'length']; | ||
module.exports = substr; |
@@ -12,3 +12,3 @@ var utils = require('../utils') | ||
module.exports = function tan(angle) { | ||
function tan(angle) { | ||
utils.assertType(angle, 'unit', 'angle'); | ||
@@ -29,2 +29,4 @@ | ||
return new nodes.Unit(tan, ''); | ||
}; | ||
} | ||
tan.params = ['angle']; | ||
module.exports = tan; |
@@ -26,3 +26,3 @@ var utils = require('../utils') | ||
module.exports = function transparentify(top, bottom, alpha){ | ||
function transparentify(top, bottom, alpha){ | ||
utils.assertColor(top); | ||
@@ -40,3 +40,3 @@ top = top.rgba; | ||
return (top[channel] - bottom[channel]) / ((0 < (top[channel] - bottom[channel]) ? 255 : 0) - bottom[channel]); | ||
}).sort(function(a, b){return a < b;})[0]; | ||
}).sort(function(a, b){return b - a;})[0]; | ||
if (alpha) { | ||
@@ -66,1 +66,3 @@ utils.assertType(alpha, 'unit', 'alpha'); | ||
} | ||
transparentify.params = ['top', 'bottom', 'alpha']; | ||
module.exports = transparentify; |
@@ -27,5 +27,7 @@ var utils = require('../utils'); | ||
module.exports = function type(node){ | ||
function type(node){ | ||
utils.assertPresent(node, 'expression'); | ||
return node.nodeName; | ||
}; | ||
} | ||
type.params = ['node']; | ||
module.exports = type; |
@@ -13,3 +13,3 @@ var utils = require('../utils') | ||
module.exports = function unit(unit, type){ | ||
function unit(unit, type){ | ||
utils.assertType(unit, 'unit', 'unit'); | ||
@@ -24,2 +24,4 @@ | ||
} | ||
}; | ||
} | ||
unit.params = ['unit', 'type']; | ||
module.exports = unit; |
@@ -20,5 +20,7 @@ var utils = require('../utils') | ||
module.exports = function unquote(string){ | ||
function unquote(string){ | ||
utils.assertString(string, 'string'); | ||
return new nodes.Literal(string.string); | ||
}; | ||
} | ||
unquote.params = ['string']; | ||
module.exports = unquote; |
@@ -15,3 +15,3 @@ var utils = require('../utils') | ||
module.exports = function use(plugin, options){ | ||
function use(plugin, options){ | ||
utils.assertString(plugin, 'plugin'); | ||
@@ -35,3 +35,5 @@ | ||
this.renderer.use(fn(options || this.options)); | ||
}; | ||
} | ||
use.params = ['plugin', 'options']; | ||
module.exports = use; | ||
@@ -38,0 +40,0 @@ /** |
@@ -11,6 +11,8 @@ var utils = require('../utils') | ||
module.exports = function warn(msg){ | ||
function warn(msg){ | ||
utils.assertType(msg, 'string', 'msg'); | ||
console.warn('Warning: %s', msg.val); | ||
return nodes.null; | ||
}; | ||
} | ||
warn.params = ['msg']; | ||
module.exports = warn; |
115
lib/lexer.js
@@ -74,3 +74,3 @@ | ||
? str | ||
: val + '\r'; | ||
: ((val === ',' && /^[,\t\n]+$/.test(str)) ? str.replace(/\n/, '\r') : val + '\r'); | ||
}; | ||
@@ -94,7 +94,7 @@ | ||
Lexer.prototype = { | ||
/** | ||
* Custom inspect. | ||
*/ | ||
inspect: function(){ | ||
@@ -118,3 +118,3 @@ var tok | ||
*/ | ||
lookahead: function(n){ | ||
@@ -125,3 +125,3 @@ var fetch = n - this.stash.length; | ||
}, | ||
/** | ||
@@ -230,7 +230,18 @@ * Consume the given `len`. | ||
|| this.op() | ||
|| this.eol() | ||
|| (function () { | ||
var token = this.eol(); | ||
if (token) { | ||
column = token.column; | ||
line = token.lineno; | ||
} | ||
return token; | ||
}).call(this) | ||
|| this.space() | ||
|| this.selector(); | ||
tok.lineno = line; | ||
tok.column = column; | ||
return tok; | ||
@@ -245,7 +256,7 @@ }, | ||
*/ | ||
peek: function() { | ||
return this.lookahead(1); | ||
}, | ||
/** | ||
@@ -309,6 +320,10 @@ * Return the next possibly stashed token. | ||
this.skip(1); | ||
this.column = 1; | ||
while(this.space()); | ||
return this.advance(); | ||
} | ||
}, | ||
/** | ||
@@ -325,7 +340,7 @@ * ' '+ | ||
}, | ||
/** | ||
* '\\' . ' '* | ||
*/ | ||
escaped: function() { | ||
@@ -339,7 +354,7 @@ var captures; | ||
}, | ||
/** | ||
* '@css' ' '* '{' .* '}' ' '* | ||
*/ | ||
literal: function() { | ||
@@ -373,7 +388,7 @@ // HACK attack !!! | ||
}, | ||
/** | ||
* '!important' ' '* | ||
*/ | ||
important: function() { | ||
@@ -386,7 +401,7 @@ var captures; | ||
}, | ||
/** | ||
* '{' | '}' | ||
*/ | ||
brace: function() { | ||
@@ -400,7 +415,7 @@ var captures; | ||
}, | ||
/** | ||
* '(' | ')' ' '* | ||
*/ | ||
paren: function() { | ||
@@ -417,7 +432,7 @@ var captures; | ||
}, | ||
/** | ||
* 'null' | ||
*/ | ||
null: function() { | ||
@@ -436,3 +451,3 @@ var captures | ||
}, | ||
/** | ||
@@ -446,3 +461,3 @@ * 'if' | ||
*/ | ||
keyword: function() { | ||
@@ -462,3 +477,3 @@ var captures | ||
}, | ||
/** | ||
@@ -474,3 +489,3 @@ * 'not' | ||
*/ | ||
namedop: function() { | ||
@@ -529,3 +544,3 @@ var captures | ||
*/ | ||
op: function() { | ||
@@ -564,3 +579,3 @@ var captures; | ||
var captures; | ||
if (captures = /^@(?:-(\w+)-)?([a-zA-Z0-9-_]+)[ \t]*/.exec(this.str)) { | ||
if (captures = /^@(?!apply)(?:-(\w+)-)?([a-zA-Z0-9-_]+)[ \t]*/.exec(this.str)) { | ||
this.skip(captures); | ||
@@ -597,3 +612,3 @@ var vendor = captures[1] | ||
*/ | ||
comment: function() { | ||
@@ -631,3 +646,3 @@ // Single line | ||
*/ | ||
boolean: function() { | ||
@@ -659,3 +674,3 @@ var captures; | ||
*/ | ||
function: function() { | ||
@@ -670,3 +685,3 @@ var captures; | ||
return tok; | ||
} | ||
} | ||
}, | ||
@@ -677,6 +692,6 @@ | ||
*/ | ||
ident: function() { | ||
var captures; | ||
if (captures = /^-*[_a-zA-Z$][-\w\d$]*/.exec(this.str)) { | ||
if (captures = /^-*[@_a-zA-Z$][-\w\d$]*/.exec(this.str)) { | ||
this.skip(captures); | ||
@@ -793,3 +808,3 @@ return new Token('ident', new nodes.Ident(captures[0])); | ||
*/ | ||
n: function() { | ||
@@ -802,3 +817,3 @@ var captures; | ||
color.raw = captures[0]; | ||
return new Token('color', color); | ||
return new Token('color', color); | ||
} | ||
@@ -810,3 +825,3 @@ }, | ||
*/ | ||
nn: function() { | ||
@@ -819,3 +834,3 @@ var captures; | ||
color.raw = captures[0]; | ||
return new Token('color', color); | ||
return new Token('color', color); | ||
} | ||
@@ -827,3 +842,3 @@ }, | ||
*/ | ||
rgb: function() { | ||
@@ -839,10 +854,10 @@ var captures; | ||
color.raw = captures[0]; | ||
return new Token('color', color); | ||
return new Token('color', color); | ||
} | ||
}, | ||
/** | ||
* #rgba | ||
*/ | ||
rgba: function() { | ||
@@ -859,10 +874,10 @@ var captures; | ||
color.raw = captures[0]; | ||
return new Token('color', color); | ||
return new Token('color', color); | ||
} | ||
}, | ||
/** | ||
* #rrggbb | ||
*/ | ||
rrggbb: function() { | ||
@@ -878,10 +893,10 @@ var captures; | ||
color.raw = captures[0]; | ||
return new Token('color', color); | ||
return new Token('color', color); | ||
} | ||
}, | ||
/** | ||
* #rrggbbaa | ||
*/ | ||
rrggbbaa: function() { | ||
@@ -898,10 +913,10 @@ var captures; | ||
color.raw = captures[0]; | ||
return new Token('color', color); | ||
return new Token('color', color); | ||
} | ||
}, | ||
/** | ||
* ^|[^\n,;]+ | ||
*/ | ||
selector: function() { | ||
@@ -908,0 +923,0 @@ var captures; |
@@ -12,9 +12,10 @@ /*! | ||
var stylus = require('./stylus') | ||
, semver = require('semver') | ||
, fs = require('fs') | ||
, url = require('url') | ||
, dirname = require('path').dirname | ||
, mkdirp = require('mkdirp') | ||
, join = require('path').join | ||
, sep = require('path').sep | ||
, debug = require('debug')('stylus:middleware'); | ||
, debug = require('debug')('stylus:middleware') | ||
, mkdir = semver.satisfies(process.version, '>=10.12.0') ? fs.mkdir : require('mkdirp'); | ||
@@ -43,3 +44,3 @@ /** | ||
* be used by the FireStylus Firebug plugin | ||
* `linenos` Emits comments in the generated CSS indicating | ||
* `linenos` Emits comments in the generated CSS indicating | ||
* the corresponding Stylus line | ||
@@ -49,9 +50,9 @@ * 'sourcemap' Generates a sourcemap in sourcemaps v3 format | ||
* Examples: | ||
* | ||
* | ||
* Here we set up the custom compile function so that we may | ||
* set the `compress` option, or define additional functions. | ||
* | ||
* | ||
* By default the compile function simply sets the `filename` | ||
* and renders the CSS. | ||
* | ||
* | ||
* function compile(str, path) { | ||
@@ -62,11 +63,11 @@ * return stylus(str) | ||
* } | ||
* | ||
* | ||
* Pass the middleware to Connect, grabbing .styl files from this directory | ||
* and saving .css files to _./public_. Also supplying our custom `compile` function. | ||
* | ||
* | ||
* Following that we have a `static()` layer setup to serve the .css | ||
* files generated by Stylus. | ||
* | ||
* | ||
* var app = connect(); | ||
* | ||
* | ||
* app.middleware({ | ||
@@ -77,5 +78,5 @@ * src: __dirname | ||
* }) | ||
* | ||
* | ||
* app.use(connect.static(__dirname + '/public')); | ||
* | ||
* | ||
* @param {Object} options | ||
@@ -164,3 +165,3 @@ * @return {Function} | ||
imports[stylusPath] = paths; | ||
mkdirp(dirname(cssPath), parseInt('0700', 8), function(err){ | ||
mkdir(dirname(cssPath), { mode: parseInt('0700', 8), recursive: true }, function(err){ | ||
if (err) return error(err); | ||
@@ -167,0 +168,0 @@ fs.writeFile(cssPath, css, 'utf8', next); |
@@ -75,3 +75,3 @@ | ||
Block.prototype.__defineGetter__('isEmpty', function(){ | ||
return !this.nodes.length; | ||
return !this.nodes.length || this.nodes.every(function(n){return n.nodeName == 'comment'}); | ||
}); | ||
@@ -78,0 +78,0 @@ |
@@ -54,3 +54,3 @@ | ||
Literal.prototype.toString = function(){ | ||
return this.val; | ||
return this.val.toString(); | ||
}; | ||
@@ -57,0 +57,0 @@ |
@@ -26,3 +26,5 @@ | ||
this.message = msg | ||
Error.captureStackTrace(this, CoercionError); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, CoercionError); | ||
} | ||
} | ||
@@ -29,0 +31,0 @@ |
@@ -25,2 +25,3 @@ | ||
this.vals = {}; | ||
this.keys = {}; | ||
}; | ||
@@ -43,3 +44,3 @@ | ||
Object.prototype.set = function(key, val){ | ||
Object.prototype.setValue = function(key, val){ | ||
this.vals[key] = val; | ||
@@ -50,2 +51,21 @@ return this; | ||
/** | ||
* Alias for `setValue` for compatible API | ||
*/ | ||
Object.prototype.set = Object.prototype.setValue; | ||
/** | ||
* Set `key` to `val`. | ||
* | ||
* @param {String} key | ||
* @param {Node} val | ||
* @return {Object} for chaining | ||
* @api public | ||
*/ | ||
Object.prototype.setKey = function(key, val){ | ||
this.keys[key] = val; | ||
return this; | ||
}; | ||
/** | ||
* Return length. | ||
@@ -141,2 +161,3 @@ * | ||
, val; | ||
for (key in this.vals) { | ||
@@ -156,3 +177,5 @@ val = this.get(key); | ||
} | ||
str += '}'; | ||
return str; | ||
@@ -172,3 +195,3 @@ | ||
* Return a clone of this node. | ||
* | ||
* | ||
* @return {Node} | ||
@@ -183,5 +206,12 @@ * @api public | ||
clone.filename = this.filename; | ||
for (var key in this.vals) { | ||
var key; | ||
for (key in this.vals) { | ||
clone.vals[key] = this.vals[key].clone(parent, clone); | ||
} | ||
for (key in this.keys) { | ||
clone.keys[key] = this.keys[key].clone(parent, clone); | ||
} | ||
return clone; | ||
@@ -201,2 +231,3 @@ }; | ||
vals: this.vals, | ||
keys: this.keys, | ||
lineno: this.lineno, | ||
@@ -203,0 +234,0 @@ column: this.column, |
@@ -494,2 +494,3 @@ /*! | ||
var i = 1 | ||
, node | ||
, brace; | ||
@@ -517,5 +518,49 @@ | ||
if ('.' == this.lookahead(i).type && 'ident' == this.lookahead(i + 1).type) | ||
// Hash values inside properties | ||
if ( | ||
i > 1 && | ||
'ident' === this.lookahead(i - 1).type && | ||
'.' === this.lookahead(i).type && | ||
'ident' === this.lookahead(i + 1).type | ||
) { | ||
while ((node = this.lookahead(i + 2))) { | ||
if (~[ | ||
'indent', | ||
'outdent', | ||
'{', | ||
';', | ||
'eos', | ||
'selector', | ||
'media', | ||
'if', | ||
'atrule', | ||
')', | ||
'}', | ||
'unit', | ||
'[', | ||
'for', | ||
'function' | ||
].indexOf(node.type)) { | ||
if (node.type === '[') { | ||
while ((node = this.lookahead(i + 3)) && node.type !== ']') { | ||
if (~['.', 'unit'].indexOf(node.type)) { | ||
return false; | ||
} | ||
i += 1 | ||
} | ||
} else { | ||
return !~['outdent', ';', 'eos', 'media', 'if', 'atrule', ')', '}', 'unit', 'for', 'function'].indexOf(node.type); | ||
} | ||
} | ||
i += 1 | ||
} | ||
return true; | ||
} | ||
if ('.' == this.lookahead(i).type && 'ident' == this.lookahead(i + 1).type) { | ||
return true; | ||
} | ||
if ('*' == this.lookahead(i).type && 'newline' == this.lookahead(i + 1).type) | ||
@@ -527,3 +572,3 @@ return true; | ||
&& ':' == this.lookahead(i + 1).type) | ||
return true; | ||
return true; | ||
@@ -758,4 +803,4 @@ // #a after an ident and newline | ||
stmt: function() { | ||
var type = this.peek().type; | ||
switch (type) { | ||
var tok = this.peek(), selector; | ||
switch (tok.type) { | ||
case 'keyframes': | ||
@@ -782,3 +827,3 @@ return this.keyframes(); | ||
case 'if': | ||
return this[type](); | ||
return this[tok.type](); | ||
case 'return': | ||
@@ -791,3 +836,3 @@ return this.return(); | ||
if (this.stateAllowsSelector()) { | ||
switch (type) { | ||
switch (tok.type) { | ||
case 'color': | ||
@@ -803,3 +848,6 @@ case '~': | ||
case '/': | ||
return this.selector(); | ||
selector = this.selector(); | ||
selector.column = tok.column; | ||
selector.lineno = tok.lineno; | ||
return selector; | ||
// relative reference | ||
@@ -817,3 +865,8 @@ case '..': | ||
case 'unit': | ||
if (this.looksLikeKeyframe()) return this.selector(); | ||
if (this.looksLikeKeyframe()) { | ||
selector = this.selector(); | ||
selector.column = tok.column; | ||
selector.lineno = tok.lineno; | ||
return selector; | ||
} | ||
case '-': | ||
@@ -955,3 +1008,4 @@ if ('{' == this.lookahead(2).type) | ||
if: function() { | ||
this.expect('if'); | ||
var token = this.expect('if'); | ||
this.state.push('conditional'); | ||
@@ -961,3 +1015,7 @@ this.cond = true; | ||
, cond | ||
, block; | ||
, block | ||
, item; | ||
node.column = token.column; | ||
this.cond = false; | ||
@@ -967,3 +1025,4 @@ node.block = this.block(node, false); | ||
while (this.accept('else')) { | ||
if (this.accept('if')) { | ||
token = this.accept('if'); | ||
if (token) { | ||
this.cond = true; | ||
@@ -973,3 +1032,7 @@ cond = this.expression(); | ||
block = this.block(node, false); | ||
node.elses.push(new nodes.If(cond, block)); | ||
item = new nodes.If(cond, block); | ||
item.column = token.column; | ||
node.elses.push(item); | ||
} else { | ||
@@ -1331,2 +1394,4 @@ node.elses.push(this.block(node, false)); | ||
keyframes = new nodes.Keyframes(this.selectorParts(), tok.val); | ||
keyframes.column = tok.column; | ||
this.skipSpacesAndComments(); | ||
@@ -1627,5 +1692,7 @@ | ||
assignment: function() { | ||
var op | ||
, node | ||
, name = this.id().name; | ||
var | ||
op, | ||
node, | ||
ident = this.id(), | ||
name = ident.name; | ||
@@ -1645,2 +1712,6 @@ if (op = | ||
node = new nodes.Ident(name, expr); | ||
node.lineno = ident.lineno; | ||
node.column = ident.column; | ||
this.state.pop(); | ||
@@ -1727,3 +1798,6 @@ | ||
if ('url' == this.peek().val.name) return this.url(); | ||
var name = this.expect('function').val.name; | ||
var tok = this.expect('function').val; | ||
var name = tok.name; | ||
this.state.push('function arguments'); | ||
@@ -1736,2 +1810,6 @@ this.parens++; | ||
var call = new nodes.Call(name, args); | ||
call.column = tok.column; | ||
call.lineno = tok.lineno; | ||
if (withBlock) { | ||
@@ -1750,3 +1828,5 @@ this.state.push('function'); | ||
functionDefinition: function() { | ||
var name = this.expect('function').val.name; | ||
var | ||
tok = this.expect('function'), | ||
name = tok.val.name; | ||
@@ -1764,2 +1844,6 @@ // params | ||
var fn = new nodes.Function(name, params); | ||
fn.column = tok.column; | ||
fn.lineno = tok.lineno; | ||
fn.block = this.block(fn); | ||
@@ -2087,3 +2171,3 @@ this.state.pop(); | ||
*/ | ||
member: function() { | ||
@@ -2113,3 +2197,3 @@ var node = this.primary(); | ||
var obj = new nodes.Object | ||
, id, val, comma; | ||
, id, val, comma, hash; | ||
this.expect('{'); | ||
@@ -2124,8 +2208,17 @@ this.skipWhitespace(); | ||
id = this.accept('ident') || this.accept('string'); | ||
if (!id) this.error('expected "ident" or "string", got {peek}'); | ||
id = id.val.hash; | ||
if (!id) { | ||
this.error('expected "ident" or "string", got {peek}'); | ||
} | ||
hash = id.val.hash; | ||
this.skipSpacesAndComments(); | ||
this.expect(':'); | ||
val = this.expression(); | ||
obj.set(id, val); | ||
obj.setValue(hash, val); | ||
obj.setKey(hash, id.val); | ||
comma = this.accept(','); | ||
@@ -2132,0 +2225,0 @@ this.skipWhitespace(); |
@@ -41,3 +41,3 @@ | ||
options.use = Array.isArray(options.use) ? options.use : [options.use]; | ||
options.imports = [join(__dirname, 'functions')]; | ||
options.imports = [join(__dirname, 'functions')].concat(options.imports || []); | ||
options.paths = options.paths || []; | ||
@@ -44,0 +44,0 @@ options.filename = options.filename || 'stylus'; |
@@ -38,3 +38,3 @@ | ||
Scope.prototype.lookup = function(name){ | ||
return this.locals[name]; | ||
return hasOwnProperty(this.locals, name) ? this.locals[name] : undefined; | ||
}; | ||
@@ -55,1 +55,10 @@ | ||
}; | ||
/** | ||
* @param {Object} obj | ||
* @param {String} propName | ||
* @returns {Boolean} | ||
*/ | ||
function hasOwnProperty(obj, propName) { | ||
return Object.prototype.hasOwnProperty.call(obj, propName); | ||
} |
@@ -519,5 +519,3 @@ | ||
parser = new Parser(str); | ||
parser.state.push('expression'); | ||
ret = new nodes.Expression(); | ||
ret.nodes = parser.parse().nodes; | ||
ret = parser.list(); | ||
} catch (e) { | ||
@@ -524,0 +522,0 @@ ret = new nodes.Literal(str); |
@@ -116,3 +116,4 @@ /*! | ||
, separator = this.compress ? '' : '\n' | ||
, needBrackets; | ||
, needBrackets | ||
, lastPropertyIndex; | ||
@@ -122,2 +123,10 @@ if (block.hasProperties && !block.lacksRenderedSelectors) { | ||
if (this.compress) { | ||
for (var i = block.nodes.length - 1; i >= 0; --i) { | ||
if (block.nodes[i].nodeName === 'property') { | ||
lastPropertyIndex = i; | ||
break; | ||
} | ||
} | ||
} | ||
if (needBrackets) { | ||
@@ -128,3 +137,3 @@ this.buf += this.out(this.compress ? '{' : ' {\n'); | ||
for (var i = 0, len = block.nodes.length; i < len; ++i) { | ||
this.last = len - 1 == i; | ||
this.last = lastPropertyIndex === i; | ||
node = block.nodes[i]; | ||
@@ -293,3 +302,5 @@ switch (node.nodeName) { | ||
if (atrule.block) { | ||
if (atrule.hasOnlyProperties) { | ||
if (atrule.block.isEmpty) { | ||
this.buf += this.out((this.compress ? '' : ' ') + '{}' + newline); | ||
} else if (atrule.hasOnlyProperties) { | ||
this.visit(atrule.block); | ||
@@ -539,2 +550,12 @@ } else { | ||
, arr = []; | ||
if (name === '@apply') { | ||
arr.push( | ||
this.out(this.indent), | ||
this.out(name + ' ', prop), | ||
this.out(val, prop.expr), | ||
this.out(this.compress ? (this.last ? '' : ';') : ';') | ||
); | ||
return arr.join(''); | ||
} | ||
arr.push( | ||
@@ -541,0 +562,0 @@ this.out(this.indent), |
@@ -1033,3 +1033,6 @@ | ||
} else { | ||
args = utils.params(fn).reduce(function(ret, param){ | ||
if (!fn.params) { | ||
fn.params = utils.params(fn); | ||
} | ||
args = fn.params.reduce(function(ret, param){ | ||
var arg = args.map[param] || args.nodes.shift() | ||
@@ -1422,3 +1425,3 @@ if (arg) { | ||
if (self.prefix && !node.prefixed && !node.val.nodeName) { | ||
node.val = node.val.replace(/\./g, '.' + self.prefix); | ||
node.val = node.val.replace(/\.(?=[\w-])|^\.$/g, '.' + self.prefix); | ||
node.prefixed = true; | ||
@@ -1425,0 +1428,0 @@ } |
@@ -406,6 +406,9 @@ | ||
if (extend.optional) return; | ||
var err = new Error('Failed to @extend "' + extend.selector + '"'); | ||
err.lineno = extend.lineno; | ||
err.column = extend.column; | ||
throw err; | ||
groups = self._checkForPrefixedGroups(extend.selector); | ||
if(!groups) { | ||
var err = new Error('Failed to @extend "' + extend.selector + '"'); | ||
err.lineno = extend.lineno; | ||
err.column = extend.column; | ||
throw err; | ||
} | ||
} | ||
@@ -426,1 +429,17 @@ selectors.forEach(function(selector){ | ||
}; | ||
Normalizer.prototype._checkForPrefixedGroups = function (selector) { | ||
var prefix = []; | ||
var map = this.map; | ||
var result = null; | ||
for (var i = 0; i < this.stack.length; i++) { | ||
var stackElementArray=this.stack[i]; | ||
var stackElement = stackElementArray[0]; | ||
prefix.push(stackElement.val); | ||
var fullSelector = prefix.join(" ") + " " + selector; | ||
result = map[fullSelector]; | ||
if (result) | ||
break; | ||
} | ||
return result; | ||
}; |
@@ -12,2 +12,3 @@ /*! | ||
var Compiler = require('./compiler') | ||
, Buffer = require('safer-buffer').Buffer | ||
, SourceMapGenerator = require('source-map').SourceMapGenerator | ||
@@ -83,3 +84,3 @@ , basename = require('path').basename | ||
+ (this.utf8 ? 'charset=utf-8;' : '') + 'base64,' | ||
+ new Buffer(map).toString('base64'); | ||
+ Buffer.from(map).toString('base64'); | ||
} | ||
@@ -86,0 +87,0 @@ if (this.inline || false !== this.comment) |
{ | ||
"name": "stylus", | ||
"description": "Robust, expressive, and feature-rich CSS superset", | ||
"version": "0.54.5", | ||
"version": "0.54.6", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -32,13 +32,15 @@ "keywords": [ | ||
"dependencies": { | ||
"css-parse": "1.7.x", | ||
"mkdirp": "0.5.x", | ||
"debug": "*", | ||
"sax": "0.5.x", | ||
"glob": "7.0.x", | ||
"source-map": "0.1.x" | ||
"css-parse": "~2.0.0", | ||
"debug": "~3.1.0", | ||
"glob": "^7.1.3", | ||
"mkdirp": "~0.5.x", | ||
"safer-buffer": "^2.1.2", | ||
"sax": "~1.2.4", | ||
"semver": "^6.0.0", | ||
"source-map": "^0.7.3" | ||
}, | ||
"devDependencies": { | ||
"should": "8.x", | ||
"mocha": "*", | ||
"jscoverage": "0.3.8" | ||
"jscoverage": "~0.6.0", | ||
"mocha": "^5.2.0", | ||
"should": "^13.2.3" | ||
}, | ||
@@ -45,0 +47,0 @@ "bugs": { |
@@ -1,5 +0,10 @@ | ||
# Stylus [![Build Status](https://travis-ci.org/stylus/stylus.svg?branch=master)](https://travis-ci.org/stylus/stylus) | ||
# Stylus | ||
Stylus is a revolutionary new language, providing an efficient, dynamic, and expressive way to generate CSS. Supporting both an indented syntax and regular CSS style. | ||
[![Build Status](https://travis-ci.org/stylus/stylus.svg?branch=master)](https://travis-ci.org/stylus/stylus) | ||
[![npm version](https://badge.fury.io/js/stylus.svg)](https://badge.fury.io/js/stylus) | ||
[![npm](https://img.shields.io/npm/dm/stylus.svg)](https://www.npmjs.com/package/stylus) | ||
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/stylus) | ||
Stylus is a revolutionary new language, providing an efficient, dynamic, and expressive way to generate CSS. Supporting both an indented syntax and regular CSS style. | ||
## Installation | ||
@@ -113,3 +118,3 @@ | ||
- gedit [language-spec](docs/gedit.md) | ||
- VIM [Syntax](https://github.com/wavded/vim-stylus) | ||
- VIM [Syntax](https://github.com/iloginow/vim-stylus) | ||
- Espresso [Sugar](https://github.com/aljs/Stylus.sugar) | ||
@@ -133,2 +138,3 @@ - [Firebug extension](docs/firebug.md) | ||
- [Derby](https://github.com/derbyjs/derby-stylus) | ||
- [Laravel](https://laravel.com/docs/5.5/mix#stylus) | ||
@@ -142,3 +148,2 @@ ### CMS Support | ||
- [Stylus Intro](http://www.screenr.com/bNY) | ||
- [CSS Syntax & Postfix Conditionals](http://www.screenr.com/A8v) | ||
@@ -145,0 +150,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
440157
153
13886
0
184
8
4
+ Addedsafer-buffer@^2.1.2
+ Addedsemver@^6.0.0
+ Addedatob@2.1.2(transitive)
+ Addedcss@2.2.4(transitive)
+ Addedcss-parse@2.0.0(transitive)
+ Addeddebug@3.1.0(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedms@2.0.0(transitive)
+ Addedresolve-url@0.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsax@1.2.4(transitive)
+ Addedsemver@6.3.1(transitive)
+ Addedsource-map@0.6.10.7.4(transitive)
+ Addedsource-map-resolve@0.5.3(transitive)
+ Addedsource-map-url@0.4.1(transitive)
+ Addedurix@0.1.0(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedcss-parse@1.7.0(transitive)
- Removeddebug@4.3.7(transitive)
- Removedglob@7.0.6(transitive)
- Removedms@2.1.3(transitive)
- Removedsax@0.5.8(transitive)
- Removedsource-map@0.1.43(transitive)
Updatedcss-parse@~2.0.0
Updateddebug@~3.1.0
Updatedglob@^7.1.3
Updatedmkdirp@~0.5.x
Updatedsax@~1.2.4
Updatedsource-map@^0.7.3