Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stylus

Package Overview
Dependencies
Maintainers
0
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylus - npm Package Compare versions

Comparing version 0.6.5 to 0.6.6

lib/nodes/._block.js

4

._History.md

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�{��"�"com.macromates.caret{
column = 25;
Mac OS X  2��ATTR��|��"�"com.macromates.caret{
column = 79;
line = 4;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�{��"�"com.macromates.caret{
Mac OS X  2��ATTR�����"�"com.macromates.caret{
column = 21;
line = 2;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�{ ��#�#com.macromates.caret{
column = 62;
line = 82;
Mac OS X  2��ATTR�����#�#com.macromates.caret{
column = 65;
line = 51;
}
0.6.6 / 2011-03-01
==================
* Added string -> unit type coercion support aka `5px + "10"` will give `15px`
* Added `warn` option Closes #152
Currently this only reports on re-definition of functions
* Added '$' as a valid identifier character
* Added `mixin` local variable for function introspection capabilities. Closes #162
* Fixed typo, `Unit#toBoolean()` is now correct
* Fixed interpolation function calls. Closes #156
* Fixed mixins within Media node. Closes #153
* Fixed function call in ret val. Closes #154
0.6.5 / 2011-02-24

@@ -3,0 +16,0 @@ ==================

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�{(��#�#com.macromates.caret{
Mac OS X  2��ATTR�����#�#com.macromates.caret{
column = 0;
line = 876;
line = 458;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�{,��#�#com.macromates.caret{
Mac OS X  2��ATTR�����#�#com.macromates.caret{
column = 24;
line = 25;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�{/��#�#com.macromates.caret{
column = 37;
line = 47;
Mac OS X  2��ATTR�����#�#com.macromates.caret{
column = 0;
line = 134;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�{Y��#�#com.macromates.caret{
Mac OS X  2��ATTR�����#�#com.macromates.caret{
column = 0;
line = 566;
line = 161;
}

@@ -68,5 +68,6 @@

options = options || {};
this.str = str.replace(/\r\n?/g, '\n').replace(/\t/g, ' ');
this.str = str.replace(/\r\n?/g, '\n');
this.stash = [];
this.prevIndents = 0;
this.indentStack = [];
this.indentRe = null;
this.lineno = 0;

@@ -204,5 +205,8 @@ };

if (this.str.length) return;
return --this.prevIndents < 0
? new Token('eos')
: new Token('outdent');
if (this.indentStack.length) {
this.indentStack.shift();
return new Token('outdent');
} else {
return new Token('eos');
}
},

@@ -478,3 +482,3 @@

/**
* -?[a-zA-Z] [-\w\d]* '('
* -?[a-zA-Z$] [-\w\d$]* '('
*/

@@ -484,3 +488,3 @@

var captures;
if (captures = /^(-?[a-zA-Z][-\w\d]*)\(( *)/.exec(this.str)) {
if (captures = /^(-?[a-zA-Z$][-\w\d$]*)\(( *)/.exec(this.str)) {
var name = captures[1];

@@ -496,3 +500,3 @@ this.skip(captures);

/**
* -?[a-zA-Z] [-\w\d]*
* -?[a-zA-Z$] [-\w\d$]*
*/

@@ -502,3 +506,3 @@

var captures;
if (captures = /^(-?[a-zA-Z][-\w\d]*)/.exec(this.str)) {
if (captures = /^(-?[a-zA-Z$][-\w\d$]*)/.exec(this.str)) {
var name = captures[1];

@@ -515,13 +519,36 @@ this.skip(captures);

get newline() {
var captures;
if (captures = /^\n( *)/.exec(this.str)) {
var captures, re;
// we have established the indentation regexp
if (this.indentRe){
captures = this.indentRe.exec(this.str);
// figure out if we are using tabs or spaces
} else {
// try tabs
re = /^\n([\t]*) */;
captures = re.exec(this.str);
// nope, try spaces
if (captures && !captures[1].length) {
re = /^\n( *)/;
captures = re.exec(this.str);
}
// established
if (captures && captures[1].length) this.indentRe = re;
}
if (captures) {
var tok
, spaces = captures[1].length
, indents = spaces / 2;
, indents = captures[1].length;
this.skip(captures);
if (this.str[0] === ' ' || this.str[0] === '\t') {
throw new Error('Invalid indentation, you can use tabs or spaces to indent but not both');
}
// Reset state
this.isVariable = false;
// Blank line

@@ -533,23 +560,12 @@ if ('\n' == this.str[0]) {

// To few spaces
if (0 != spaces % 2) {
var str = 1 == spaces ? 'space' : 'spaces'
, spaces = numberString[spaces] || spaces;
throw new Error('Invalid indentation, got ' + spaces + ' ' + str + ' and expected multiple of two');
// To many spaces
} else if (indents > this.prevIndents + 1) {
var str = 1 == spaces ? 'space' : 'spaces'
, expected = 2 * (this.prevIndents * 2) || 2
, expected = numberString[expected] || expected
, spaces = numberString[spaces] || spaces;
throw new Error('Invalid indentation, got ' + spaces + ' ' + str + ' and expected ' + expected);
// Outdent
} else if (indents < this.prevIndents) {
var n = this.prevIndents - indents;
while (--n) this.stash.push(new Token('outdent'));
this.prevIndents = indents;
tok = new Token('outdent');
if (this.indentStack.length && indents < this.indentStack[0]) {
while (this.indentStack.length && this.indentStack[0] > indents) {
this.stash.push(new Token('outdent'));
this.indentStack.shift();
}
tok = this.stash.pop();
// Indent
} else if (indents != this.prevIndents) {
this.prevIndents = indents;
} else if (indents && indents != this.indentStack[0]) {
this.indentStack.unshift(indents);
tok = new Token('indent');

@@ -556,0 +572,0 @@ // Newline

@@ -43,3 +43,3 @@

Node.prototype.toBoolean = function(){
Unit.prototype.toBoolean = function(){
return nodes.Boolean(this.val);

@@ -180,2 +180,6 @@ };

return new nodes.Unit(b.val, a.type);
} else if (other instanceof nodes.String) {
var val = parseInt(other.val, 10);
if (isNaN(val)) Node.prototype.coerce.call(this, other);
return new nodes.Unit(val);
} else {

@@ -182,0 +186,0 @@ return Node.prototype.coerce.call(this, other);

@@ -782,4 +782,6 @@

if (this.accept('{')) {
this.state.push('interpolation');
segs.push(this.expression);
this.expect('}');
this.state.pop();
} else if (node = this.accept('ident')){

@@ -796,3 +798,3 @@ segs.push(node.val);

/**
* property :? expression
* property ':'? expression
* | ident

@@ -936,7 +938,5 @@ */

get function() {
var ident = this.expect('function').val
, name = this._name = ident.name
, tok
, i = 1
, parens = 1;
var parens = 1
, i = 2
, tok;

@@ -961,3 +961,3 @@ // Lookahead and determine if we are dealing

? this.functionDefinition
: this.functionCall;
: this.expression;
}

@@ -971,5 +971,5 @@ },

get functionCall() {
var name = this.expect('function').val.name;
this.state.push('function arguments');
var name = this._name
, args = this.args;
var args = this.args;
this.expect(')');

@@ -985,6 +985,7 @@ this.state.pop();

get functionDefinition() {
// Params
var name = this.expect('function').val.name;
// params
this.state.push('function params');
var name = this._name
, params = this.params;
var params = this.params;
this.expect(')');

@@ -1323,5 +1324,5 @@ this.state.pop();

case 'function':
return this.function;
return this.functionCall;
}
}
};

@@ -71,5 +71,5 @@

Stack.prototype.lookup = function(name){
var val
, ret
, block = this.currentFrame.block;
var block = this.currentFrame.block
, val
, ret;

@@ -76,0 +76,0 @@ do {

@@ -26,3 +26,3 @@

exports.version = '0.6.5';
exports.version = '0.6.6';

@@ -29,0 +29,0 @@ /**

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�{4��$�$com.macromates.caret{
column = 13;
line = 527;
Mac OS X  2��ATTR�����#�#com.macromates.caret{
column = 6;
line = 604;
}

@@ -30,2 +30,3 @@

* - `compress` Compress the css output, defaults to false
* - `warn` Warn the user of duplicate function definitions etc
*

@@ -46,2 +47,3 @@ * @param {Node} root

this.stack.push(this.global = new Frame(root));
this.warnings = options.warn;
this.setup();

@@ -153,2 +155,31 @@ this.calling = []; // TODO: remove, use stack

/**
* Visit Media.
*/
Evaluator.prototype.visitMedia = function(media){
media.block = this.visit(media.block);
return media;
};
/**
* Visit Function.
*/
Evaluator.prototype.visitFunction = function(fn){
// check local
var local = this.stack.currentFrame.scope.lookup(fn.name);
if (local) this.warn('local ' + local.nodeName + ' "' + fn.name + '" previously defined in this scope on line ' + local.lineno);
// user-defined
var user = this.functions[fn.name];
if (user) this.warn('user-defined function "' + fn.name + '" is already defined');
// BIF
var bif = bifs[fn.name];
if (bif) this.warn('built-in function "' + fn.name + '" is already defined');
return fn;
};
/**
* Visit Each.

@@ -186,4 +217,4 @@ */

Evaluator.prototype.visitCall = function(call){
var ret
, fn = this.lookup(call.name);
var fn = this.lookup(call.name)
, ret;

@@ -530,7 +561,10 @@ // Variable function

// Inject argument scope
// mixin block
var mixinBlock = this.stack.currentFrame.block;
// inject argument scope
var block = new nodes.Block(body.parent);
body.parent = block;
// New block scope
// new block scope
this.stack.push(new Frame(block));

@@ -542,3 +576,8 @@ var scope = this.stack.currentFrame.scope;

// Inject arguments as locals
// mixin scope introspection
scope.add(new nodes.Ident('mixin', this.return
? nodes.false
: new nodes.String(mixinBlock.nodeName)));
// inject arguments as locals
fn.params.nodes.forEach(function(node, i){

@@ -551,3 +590,3 @@ // rest param support

}
// Argument default support
// argument default support
} else {

@@ -560,3 +599,3 @@ var arg = args.nodes[i];

node.val = val;
// Required argument not satisfied
// required argument not satisfied
if (node.val instanceof nodes.Null) {

@@ -570,7 +609,7 @@ throw new Error('argument ' + node + ' required for ' + fn);

// Evaluate
// evaluate
body = this.visit(body);
this.stack.pop();
// Invoke
// invoke
return this.invoke(body);

@@ -734,6 +773,11 @@ };

return node.name;
case 'literal':
case 'string':
return node.val;
case 'expression':
return toString(self.visit(node).first);
var _ = self.return;
self.return = true;
var ret = toString(self.visit(node).first);
self.return = _;
return ret;
}

@@ -773,1 +817,13 @@ }

};
/**
* Warn with the given `msg`.
*
* @param {String} msg
* @api private
*/
Evaluator.prototype.warn = function(msg){
if (!this.warnings) return;
console.warn('\033[33mWarning:\033[0m ' + msg);
};
{ "name": "stylus"
, "description": "Robust, expressive language which compiles to CSS"
, "version": "0.6.5"
, "version": "0.6.6"
, "author": "TJ Holowaychuk <tj@vision-media.ca>"

@@ -5,0 +5,0 @@ , "keywords": ["css", "parser", "style", "stylesheets", "jade", "language"]

@@ -52,2 +52,3 @@

- [importing](stylus/blob/master/docs/import.md) of other stylus sheets
- [introspection api](stylus/blob/master/docs/introspection.md)
- type coercion

@@ -54,0 +55,0 @@ - [conditionals](stylus/blob/master/docs/conditionals.md)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc