conversion from php to nodejs started
This commit is contained in:
92
nodejs/node_modules/stylus/lib/nodes/arguments.js
generated
vendored
Normal file
92
nodejs/node_modules/stylus/lib/nodes/arguments.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Arguments
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, nodes = require('../nodes')
|
||||
, utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Initialize a new `Arguments`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Arguments = module.exports = function Arguments(){
|
||||
nodes.Expression.call(this);
|
||||
this.map = {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `nodes.Expression.prototype`.
|
||||
*/
|
||||
|
||||
Arguments.prototype.__proto__ = nodes.Expression.prototype;
|
||||
|
||||
/**
|
||||
* Initialize an `Arguments` object with the nodes
|
||||
* from the given `expr`.
|
||||
*
|
||||
* @param {Expression} expr
|
||||
* @return {Arguments}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Arguments.fromExpression = function(expr){
|
||||
var args = new Arguments
|
||||
, len = expr.nodes.length;
|
||||
args.lineno = expr.lineno;
|
||||
args.column = expr.column;
|
||||
args.isList = expr.isList;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
args.push(expr.nodes[i]);
|
||||
}
|
||||
return args;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Arguments.prototype.clone = function(parent){
|
||||
var clone = nodes.Expression.prototype.clone.call(this, parent);
|
||||
clone.map = {};
|
||||
for (var key in this.map) {
|
||||
clone.map[key] = this.map[key].clone(parent, clone);
|
||||
}
|
||||
clone.isList = this.isList;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Arguments.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Arguments',
|
||||
map: this.map,
|
||||
isList: this.isList,
|
||||
preserve: this.preserve,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename,
|
||||
nodes: this.nodes
|
||||
};
|
||||
};
|
79
nodejs/node_modules/stylus/lib/nodes/atblock.js
generated
vendored
Normal file
79
nodejs/node_modules/stylus/lib/nodes/atblock.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/*!
|
||||
* Stylus - @block
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `@block` node.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Atblock = module.exports = function Atblock(){
|
||||
Node.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return `block` nodes.
|
||||
*/
|
||||
|
||||
Atblock.prototype.__defineGetter__('nodes', function(){
|
||||
return this.block.nodes;
|
||||
});
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Atblock.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Atblock.prototype.clone = function(parent){
|
||||
var clone = new Atblock;
|
||||
clone.block = this.block.clone(parent, clone);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return @block.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Atblock.prototype.toString = function(){
|
||||
return '@block';
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Atblock.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Atblock',
|
||||
block: this.block,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
fileno: this.fileno
|
||||
};
|
||||
};
|
136
nodejs/node_modules/stylus/lib/nodes/atrule.js
generated
vendored
Normal file
136
nodejs/node_modules/stylus/lib/nodes/atrule.js
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
/*!
|
||||
* Stylus - at-rule
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new at-rule node.
|
||||
*
|
||||
* @param {String} type
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Atrule = module.exports = function Atrule(type){
|
||||
Node.call(this);
|
||||
this.type = type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Atrule.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Check if at-rule's block has only properties.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Atrule.prototype.__defineGetter__('hasOnlyProperties', function(){
|
||||
if (!this.block) return false;
|
||||
|
||||
var nodes = this.block.nodes;
|
||||
for (var i = 0, len = nodes.length; i < len; ++i) {
|
||||
var nodeName = nodes[i].nodeName;
|
||||
switch(nodes[i].nodeName) {
|
||||
case 'property':
|
||||
case 'expression':
|
||||
case 'comment':
|
||||
continue;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Atrule.prototype.clone = function(parent){
|
||||
var clone = new Atrule(this.type);
|
||||
if (this.block) clone.block = this.block.clone(parent, clone);
|
||||
clone.segments = this.segments.map(function(node){ return node.clone(parent, clone); });
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Atrule.prototype.toJSON = function(){
|
||||
var json = {
|
||||
__type: 'Atrule',
|
||||
type: this.type,
|
||||
segments: this.segments,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
if (this.block) json.block = this.block;
|
||||
return json;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return @<type>.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Atrule.prototype.toString = function(){
|
||||
return '@' + this.type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the at-rule's block has output nodes.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Atrule.prototype.__defineGetter__('hasOutput', function(){
|
||||
return !!this.block && hasOutput(this.block);
|
||||
});
|
||||
|
||||
function hasOutput(block) {
|
||||
var nodes = block.nodes;
|
||||
|
||||
// only placeholder selectors
|
||||
if (nodes.every(function(node){
|
||||
return 'group' == node.nodeName && node.hasOnlyPlaceholders;
|
||||
})) return false;
|
||||
|
||||
// something visible
|
||||
return nodes.some(function(node) {
|
||||
switch (node.nodeName) {
|
||||
case 'property':
|
||||
case 'literal':
|
||||
case 'import':
|
||||
return true;
|
||||
case 'block':
|
||||
return hasOutput(node);
|
||||
default:
|
||||
if (node.block) return hasOutput(node.block);
|
||||
}
|
||||
});
|
||||
}
|
83
nodejs/node_modules/stylus/lib/nodes/binop.js
generated
vendored
Normal file
83
nodejs/node_modules/stylus/lib/nodes/binop.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
|
||||
/*!
|
||||
* Stylus - BinOp
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `BinOp` with `op`, `left` and `right`.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} left
|
||||
* @param {Node} right
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var BinOp = module.exports = function BinOp(op, left, right){
|
||||
Node.call(this);
|
||||
this.op = op;
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
BinOp.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
BinOp.prototype.clone = function(parent){
|
||||
var clone = new BinOp(this.op);
|
||||
clone.left = this.left.clone(parent, clone);
|
||||
clone.right = this.right && this.right.clone(parent, clone);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
if (this.val) clone.val = this.val.clone(parent, clone);
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return <left> <op> <right>
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
BinOp.prototype.toString = function() {
|
||||
return this.left.toString() + ' ' + this.op + ' ' + this.right.toString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
BinOp.prototype.toJSON = function(){
|
||||
var json = {
|
||||
__type: 'BinOp',
|
||||
left: this.left,
|
||||
right: this.right,
|
||||
op: this.op,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
if (this.val) json.val = this.val;
|
||||
return json;
|
||||
};
|
127
nodejs/node_modules/stylus/lib/nodes/block.js
generated
vendored
Normal file
127
nodejs/node_modules/stylus/lib/nodes/block.js
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Block
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Block` node with `parent` Block.
|
||||
*
|
||||
* @param {Block} parent
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Block = module.exports = function Block(parent, node){
|
||||
Node.call(this);
|
||||
this.nodes = [];
|
||||
this.parent = parent;
|
||||
this.node = node;
|
||||
this.scope = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Block.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Check if this block has properties..
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Block.prototype.__defineGetter__('hasProperties', function(){
|
||||
for (var i = 0, len = this.nodes.length; i < len; ++i) {
|
||||
if ('property' == this.nodes[i].nodeName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Check if this block has @media nodes.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Block.prototype.__defineGetter__('hasMedia', function(){
|
||||
for (var i = 0, len = this.nodes.length; i < len; ++i) {
|
||||
var nodeName = this.nodes[i].nodeName;
|
||||
if ('media' == nodeName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Check if this block is empty.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Block.prototype.__defineGetter__('isEmpty', function(){
|
||||
return !this.nodes.length;
|
||||
});
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Block.prototype.clone = function(parent, node){
|
||||
parent = parent || this.parent;
|
||||
var clone = new Block(parent, node || this.node);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
clone.scope = this.scope;
|
||||
this.nodes.forEach(function(node){
|
||||
clone.push(node.clone(clone, clone));
|
||||
});
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Push a `node` to this block.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Block.prototype.push = function(node){
|
||||
this.nodes.push(node);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Block.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Block',
|
||||
// parent: this.parent,
|
||||
// node: this.node,
|
||||
scope: this.scope,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename,
|
||||
nodes: this.nodes
|
||||
};
|
||||
};
|
117
nodejs/node_modules/stylus/lib/nodes/boolean.js
generated
vendored
Normal file
117
nodejs/node_modules/stylus/lib/nodes/boolean.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Boolean
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, nodes = require('./');
|
||||
|
||||
/**
|
||||
* Initialize a new `Boolean` node with the given `val`.
|
||||
*
|
||||
* @param {Boolean} val
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Boolean = module.exports = function Boolean(val){
|
||||
Node.call(this);
|
||||
if (this.nodeName) {
|
||||
this.val = !!val;
|
||||
} else {
|
||||
return new Boolean(val);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Boolean.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return `this` node.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Boolean.prototype.toBoolean = function(){
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return `true` if this node represents `true`.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Boolean.prototype.__defineGetter__('isTrue', function(){
|
||||
return this.val;
|
||||
});
|
||||
|
||||
/**
|
||||
* Return `true` if this node represents `false`.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Boolean.prototype.__defineGetter__('isFalse', function(){
|
||||
return ! this.val;
|
||||
});
|
||||
|
||||
/**
|
||||
* Negate the value.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Boolean.prototype.negate = function(){
|
||||
return new Boolean(!this.val);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return 'Boolean'.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Boolean.prototype.inspect = function(){
|
||||
return '[Boolean ' + this.val + ']';
|
||||
};
|
||||
|
||||
/**
|
||||
* Return 'true' or 'false'.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Boolean.prototype.toString = function(){
|
||||
return this.val
|
||||
? 'true'
|
||||
: 'false';
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representaiton of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Boolean.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Boolean',
|
||||
val: this.val
|
||||
};
|
||||
};
|
85
nodejs/node_modules/stylus/lib/nodes/call.js
generated
vendored
Normal file
85
nodejs/node_modules/stylus/lib/nodes/call.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Call
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Call` with `name` and `args`.
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Expression} args
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Call = module.exports = function Call(name, args){
|
||||
Node.call(this);
|
||||
this.name = name;
|
||||
this.args = args;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Call.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Call.prototype.clone = function(parent){
|
||||
var clone = new Call(this.name);
|
||||
clone.args = this.args.clone(parent, clone);
|
||||
if (this.block) clone.block = this.block.clone(parent, clone);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return <name>(param1, param2, ...).
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Call.prototype.toString = function(){
|
||||
var args = this.args.nodes.map(function(node) {
|
||||
var str = node.toString();
|
||||
return str.slice(1, str.length - 1);
|
||||
}).join(', ');
|
||||
|
||||
return this.name + '(' + args + ')';
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Call.prototype.toJSON = function(){
|
||||
var json = {
|
||||
__type: 'Call',
|
||||
name: this.name,
|
||||
args: this.args,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
if (this.block) json.block = this.block;
|
||||
return json;
|
||||
};
|
58
nodejs/node_modules/stylus/lib/nodes/charset.js
generated
vendored
Normal file
58
nodejs/node_modules/stylus/lib/nodes/charset.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Charset
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Charset` with the given `val`
|
||||
*
|
||||
* @param {String} val
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Charset = module.exports = function Charset(val){
|
||||
Node.call(this);
|
||||
this.val = val;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Charset.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return @charset "val".
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Charset.prototype.toString = function(){
|
||||
return '@charset ' + this.val;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Charset.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Charset',
|
||||
val: this.val,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
64
nodejs/node_modules/stylus/lib/nodes/comment.js
generated
vendored
Normal file
64
nodejs/node_modules/stylus/lib/nodes/comment.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Comment
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Comment` with the given `str`.
|
||||
*
|
||||
* @param {String} str
|
||||
* @param {Boolean} suppress
|
||||
* @param {Boolean} inline
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Comment = module.exports = function Comment(str, suppress, inline){
|
||||
Node.call(this);
|
||||
this.str = str;
|
||||
this.suppress = suppress;
|
||||
this.inline = inline;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Comment.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Comment.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Comment',
|
||||
str: this.str,
|
||||
suppress: this.suppress,
|
||||
inline: this.inline,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Return comment.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Comment.prototype.toString = function(){
|
||||
return this.str;
|
||||
};
|
75
nodejs/node_modules/stylus/lib/nodes/each.js
generated
vendored
Normal file
75
nodejs/node_modules/stylus/lib/nodes/each.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Each
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, nodes = require('./');
|
||||
|
||||
/**
|
||||
* Initialize a new `Each` node with the given `val` name,
|
||||
* `key` name, `expr`, and `block`.
|
||||
*
|
||||
* @param {String} val
|
||||
* @param {String} key
|
||||
* @param {Expression} expr
|
||||
* @param {Block} block
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Each = module.exports = function Each(val, key, expr, block){
|
||||
Node.call(this);
|
||||
this.val = val;
|
||||
this.key = key;
|
||||
this.expr = expr;
|
||||
this.block = block;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Each.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Each.prototype.clone = function(parent){
|
||||
var clone = new Each(this.val, this.key);
|
||||
clone.expr = this.expr.clone(parent, clone);
|
||||
clone.block = this.block.clone(parent, clone);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Each.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Each',
|
||||
val: this.val,
|
||||
key: this.key,
|
||||
expr: this.expr,
|
||||
block: this.block,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
220
nodejs/node_modules/stylus/lib/nodes/expression.js
generated
vendored
Normal file
220
nodejs/node_modules/stylus/lib/nodes/expression.js
generated
vendored
Normal file
@@ -0,0 +1,220 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Expression
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, nodes = require('../nodes')
|
||||
, utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Initialize a new `Expression`.
|
||||
*
|
||||
* @param {Boolean} isList
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Expression = module.exports = function Expression(isList){
|
||||
Node.call(this);
|
||||
this.nodes = [];
|
||||
this.isList = isList;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the variable has a value.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Expression.prototype.__defineGetter__('isEmpty', function(){
|
||||
return !this.nodes.length;
|
||||
});
|
||||
|
||||
/**
|
||||
* Return the first node in this expression.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Expression.prototype.__defineGetter__('first', function(){
|
||||
return this.nodes[0]
|
||||
? this.nodes[0].first
|
||||
: nodes.null;
|
||||
});
|
||||
|
||||
/**
|
||||
* Hash all the nodes in order.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Expression.prototype.__defineGetter__('hash', function(){
|
||||
return this.nodes.map(function(node){
|
||||
return node.hash;
|
||||
}).join('::');
|
||||
});
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Expression.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Expression.prototype.clone = function(parent){
|
||||
var clone = new this.constructor(this.isList);
|
||||
clone.preserve = this.preserve;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
clone.nodes = this.nodes.map(function(node) {
|
||||
return node.clone(parent, clone);
|
||||
});
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Push the given `node`.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Expression.prototype.push = function(node){
|
||||
this.nodes.push(node);
|
||||
};
|
||||
|
||||
/**
|
||||
* Operate on `right` with the given `op`.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} right
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Expression.prototype.operate = function(op, right, val){
|
||||
switch (op) {
|
||||
case '[]=':
|
||||
var self = this
|
||||
, range = utils.unwrap(right).nodes
|
||||
, val = utils.unwrap(val)
|
||||
, len
|
||||
, node;
|
||||
range.forEach(function(unit){
|
||||
len = self.nodes.length;
|
||||
if ('unit' == unit.nodeName) {
|
||||
var i = unit.val < 0 ? len + unit.val : unit.val
|
||||
, n = i;
|
||||
while (i-- > len) self.nodes[i] = nodes.null;
|
||||
self.nodes[n] = val;
|
||||
} else if (unit.string) {
|
||||
node = self.nodes[0];
|
||||
if (node && 'object' == node.nodeName) node.set(unit.string, val.clone());
|
||||
}
|
||||
});
|
||||
return val;
|
||||
case '[]':
|
||||
var expr = new nodes.Expression
|
||||
, vals = utils.unwrap(this).nodes
|
||||
, range = utils.unwrap(right).nodes
|
||||
, node;
|
||||
range.forEach(function(unit){
|
||||
if ('unit' == unit.nodeName) {
|
||||
node = vals[unit.val < 0 ? vals.length + unit.val : unit.val];
|
||||
} else if ('object' == vals[0].nodeName) {
|
||||
node = vals[0].get(unit.string);
|
||||
}
|
||||
if (node) expr.push(node);
|
||||
});
|
||||
return expr.isEmpty
|
||||
? nodes.null
|
||||
: utils.unwrap(expr);
|
||||
case '||':
|
||||
return this.toBoolean().isTrue
|
||||
? this
|
||||
: right;
|
||||
case 'in':
|
||||
return Node.prototype.operate.call(this, op, right);
|
||||
case '!=':
|
||||
return this.operate('==', right, val).negate();
|
||||
case '==':
|
||||
var len = this.nodes.length
|
||||
, right = right.toExpression()
|
||||
, a
|
||||
, b;
|
||||
if (len != right.nodes.length) return nodes.false;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
a = this.nodes[i];
|
||||
b = right.nodes[i];
|
||||
if (a.operate(op, b).isTrue) continue;
|
||||
return nodes.false;
|
||||
}
|
||||
return nodes.true;
|
||||
break;
|
||||
default:
|
||||
return this.first.operate(op, right, val);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Expressions with length > 1 are truthy,
|
||||
* otherwise the first value's toBoolean()
|
||||
* method is invoked.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Expression.prototype.toBoolean = function(){
|
||||
if (this.nodes.length > 1) return nodes.true;
|
||||
return this.first.toBoolean();
|
||||
};
|
||||
|
||||
/**
|
||||
* Return "<a> <b> <c>" or "<a>, <b>, <c>" if
|
||||
* the expression represents a list.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Expression.prototype.toString = function(){
|
||||
return '(' + this.nodes.map(function(node){
|
||||
return node.toString();
|
||||
}).join(this.isList ? ', ' : ' ') + ')';
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Expression.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Expression',
|
||||
isList: this.isList,
|
||||
preserve: this.preserve,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename,
|
||||
nodes: this.nodes
|
||||
};
|
||||
};
|
69
nodejs/node_modules/stylus/lib/nodes/extend.js
generated
vendored
Normal file
69
nodejs/node_modules/stylus/lib/nodes/extend.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Extend
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Extend` with the given `selectors` array.
|
||||
*
|
||||
* @param {Array} selectors array of the selectors
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Extend = module.exports = function Extend(selectors){
|
||||
Node.call(this);
|
||||
this.selectors = selectors;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Extend.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Extend.prototype.clone = function(){
|
||||
return new Extend(this.selectors);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return `@extend selectors`.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Extend.prototype.toString = function(){
|
||||
return '@extend ' + this.selectors.join(', ');
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Extend.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Extend',
|
||||
selectors: this.selectors,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
84
nodejs/node_modules/stylus/lib/nodes/feature.js
generated
vendored
Normal file
84
nodejs/node_modules/stylus/lib/nodes/feature.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Feature
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Feature` with the given `segs`.
|
||||
*
|
||||
* @param {Array} segs
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Feature = module.exports = function Feature(segs){
|
||||
Node.call(this);
|
||||
this.segments = segs;
|
||||
this.expr = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Feature.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Feature.prototype.clone = function(parent){
|
||||
var clone = new Feature;
|
||||
clone.segments = this.segments.map(function(node){ return node.clone(parent, clone); });
|
||||
if (this.expr) clone.expr = this.expr.clone(parent, clone);
|
||||
if (this.name) clone.name = this.name;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return "<ident>" or "(<ident>: <expr>)"
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Feature.prototype.toString = function(){
|
||||
if (this.expr) {
|
||||
return '(' + this.segments.join('') + ': ' + this.expr.toString() + ')';
|
||||
} else {
|
||||
return this.segments.join('');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Feature.prototype.toJSON = function(){
|
||||
var json = {
|
||||
__type: 'Feature',
|
||||
segments: this.segments,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
if (this.expr) json.expr = this.expr;
|
||||
if (this.name) json.name = this.name;
|
||||
return json;
|
||||
};
|
128
nodejs/node_modules/stylus/lib/nodes/function.js
generated
vendored
Normal file
128
nodejs/node_modules/stylus/lib/nodes/function.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Function
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Function` with `name`, `params`, and `body`.
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Params|Function} params
|
||||
* @param {Block} body
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Function = module.exports = function Function(name, params, body){
|
||||
Node.call(this);
|
||||
this.name = name;
|
||||
this.params = params;
|
||||
this.block = body;
|
||||
if ('function' == typeof params) this.fn = params;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check function arity.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Function.prototype.__defineGetter__('arity', function(){
|
||||
return this.params.length;
|
||||
});
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Function.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return hash.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Function.prototype.__defineGetter__('hash', function(){
|
||||
return 'function ' + this.name;
|
||||
});
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Function.prototype.clone = function(parent){
|
||||
if (this.fn) {
|
||||
var clone = new Function(
|
||||
this.name
|
||||
, this.fn);
|
||||
} else {
|
||||
var clone = new Function(this.name);
|
||||
clone.params = this.params.clone(parent, clone);
|
||||
clone.block = this.block.clone(parent, clone);
|
||||
}
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return <name>(param1, param2, ...).
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Function.prototype.toString = function(){
|
||||
if (this.fn) {
|
||||
return this.name
|
||||
+ '('
|
||||
+ this.fn.toString()
|
||||
.match(/^function *\w*\((.*?)\)/)
|
||||
.slice(1)
|
||||
.join(', ')
|
||||
+ ')';
|
||||
} else {
|
||||
return this.name
|
||||
+ '('
|
||||
+ this.params.nodes.join(', ')
|
||||
+ ')';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Function.prototype.toJSON = function(){
|
||||
var json = {
|
||||
__type: 'Function',
|
||||
name: this.name,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
if (this.fn) {
|
||||
json.fn = this.fn;
|
||||
} else {
|
||||
json.params = this.params;
|
||||
json.block = this.block;
|
||||
}
|
||||
return json;
|
||||
};
|
110
nodejs/node_modules/stylus/lib/nodes/group.js
generated
vendored
Normal file
110
nodejs/node_modules/stylus/lib/nodes/group.js
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Group
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Group`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Group = module.exports = function Group(){
|
||||
Node.call(this);
|
||||
this.nodes = [];
|
||||
this.extends = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Group.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Push the given `selector` node.
|
||||
*
|
||||
* @param {Selector} selector
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Group.prototype.push = function(selector){
|
||||
this.nodes.push(selector);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return this set's `Block`.
|
||||
*/
|
||||
|
||||
Group.prototype.__defineGetter__('block', function(){
|
||||
return this.nodes[0].block;
|
||||
});
|
||||
|
||||
/**
|
||||
* Assign `block` to each selector in this set.
|
||||
*
|
||||
* @param {Block} block
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Group.prototype.__defineSetter__('block', function(block){
|
||||
for (var i = 0, len = this.nodes.length; i < len; ++i) {
|
||||
this.nodes[i].block = block;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Check if this set has only placeholders.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Group.prototype.__defineGetter__('hasOnlyPlaceholders', function(){
|
||||
return this.nodes.every(function(selector) { return selector.isPlaceholder; });
|
||||
});
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Group.prototype.clone = function(parent){
|
||||
var clone = new Group;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
this.nodes.forEach(function(node){
|
||||
clone.push(node.clone(parent, clone));
|
||||
});
|
||||
clone.filename = this.filename;
|
||||
clone.block = this.block.clone(parent, clone);
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Group.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Group',
|
||||
nodes: this.nodes,
|
||||
block: this.block,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
277
nodejs/node_modules/stylus/lib/nodes/hsla.js
generated
vendored
Normal file
277
nodejs/node_modules/stylus/lib/nodes/hsla.js
generated
vendored
Normal file
@@ -0,0 +1,277 @@
|
||||
|
||||
/*!
|
||||
* Stylus - HSLA
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, nodes = require('./');
|
||||
|
||||
/**
|
||||
* Initialize a new `HSLA` with the given h,s,l,a component values.
|
||||
*
|
||||
* @param {Number} h
|
||||
* @param {Number} s
|
||||
* @param {Number} l
|
||||
* @param {Number} a
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var HSLA = exports = module.exports = function HSLA(h,s,l,a){
|
||||
Node.call(this);
|
||||
this.h = clampDegrees(h);
|
||||
this.s = clampPercentage(s);
|
||||
this.l = clampPercentage(l);
|
||||
this.a = clampAlpha(a);
|
||||
this.hsla = this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
HSLA.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return hsla(n,n,n,n).
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
HSLA.prototype.toString = function(){
|
||||
return 'hsla('
|
||||
+ this.h + ','
|
||||
+ this.s.toFixed(0) + '%,'
|
||||
+ this.l.toFixed(0) + '%,'
|
||||
+ this.a + ')';
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
HSLA.prototype.clone = function(parent){
|
||||
var clone = new HSLA(
|
||||
this.h
|
||||
, this.s
|
||||
, this.l
|
||||
, this.a);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
HSLA.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'HSLA',
|
||||
h: this.h,
|
||||
s: this.s,
|
||||
l: this.l,
|
||||
a: this.a,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Return rgba `RGBA` representation.
|
||||
*
|
||||
* @return {RGBA}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
HSLA.prototype.__defineGetter__('rgba', function(){
|
||||
return nodes.RGBA.fromHSLA(this);
|
||||
});
|
||||
|
||||
/**
|
||||
* Return hash.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
HSLA.prototype.__defineGetter__('hash', function(){
|
||||
return this.rgba.toString();
|
||||
});
|
||||
|
||||
/**
|
||||
* Add h,s,l to the current component values.
|
||||
*
|
||||
* @param {Number} h
|
||||
* @param {Number} s
|
||||
* @param {Number} l
|
||||
* @return {HSLA} new node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
HSLA.prototype.add = function(h,s,l){
|
||||
return new HSLA(
|
||||
this.h + h
|
||||
, this.s + s
|
||||
, this.l + l
|
||||
, this.a);
|
||||
};
|
||||
|
||||
/**
|
||||
* Subtract h,s,l from the current component values.
|
||||
*
|
||||
* @param {Number} h
|
||||
* @param {Number} s
|
||||
* @param {Number} l
|
||||
* @return {HSLA} new node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
HSLA.prototype.sub = function(h,s,l){
|
||||
return this.add(-h, -s, -l);
|
||||
};
|
||||
|
||||
/**
|
||||
* Operate on `right` with the given `op`.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} right
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
HSLA.prototype.operate = function(op, right){
|
||||
switch (op) {
|
||||
case '==':
|
||||
case '!=':
|
||||
case '<=':
|
||||
case '>=':
|
||||
case '<':
|
||||
case '>':
|
||||
case 'is a':
|
||||
case '||':
|
||||
case '&&':
|
||||
return this.rgba.operate(op, right);
|
||||
default:
|
||||
return this.rgba.operate(op, right).hsla;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return `HSLA` representation of the given `color`.
|
||||
*
|
||||
* @param {RGBA} color
|
||||
* @return {HSLA}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.fromRGBA = function(rgba){
|
||||
var r = rgba.r / 255
|
||||
, g = rgba.g / 255
|
||||
, b = rgba.b / 255
|
||||
, a = rgba.a;
|
||||
|
||||
var min = Math.min(r,g,b)
|
||||
, max = Math.max(r,g,b)
|
||||
, l = (max + min) / 2
|
||||
, d = max - min
|
||||
, h, s;
|
||||
|
||||
switch (max) {
|
||||
case min: h = 0; break;
|
||||
case r: h = 60 * (g-b) / d; break;
|
||||
case g: h = 60 * (b-r) / d + 120; break;
|
||||
case b: h = 60 * (r-g) / d + 240; break;
|
||||
}
|
||||
|
||||
if (max == min) {
|
||||
s = 0;
|
||||
} else if (l < .5) {
|
||||
s = d / (2 * l);
|
||||
} else {
|
||||
s = d / (2 - 2 * l);
|
||||
}
|
||||
|
||||
h %= 360;
|
||||
s *= 100;
|
||||
l *= 100;
|
||||
|
||||
return new HSLA(h,s,l,a);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adjust lightness by `percent`.
|
||||
*
|
||||
* @param {Number} percent
|
||||
* @return {HSLA} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
HSLA.prototype.adjustLightness = function(percent){
|
||||
this.l = clampPercentage(this.l + this.l * (percent / 100));
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adjust hue by `deg`.
|
||||
*
|
||||
* @param {Number} deg
|
||||
* @return {HSLA} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
HSLA.prototype.adjustHue = function(deg){
|
||||
this.h = clampDegrees(this.h + deg);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Clamp degree `n` >= 0 and <= 360.
|
||||
*
|
||||
* @param {Number} n
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function clampDegrees(n) {
|
||||
n = n % 360;
|
||||
return n >= 0 ? n : 360 + n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp percentage `n` >= 0 and <= 100.
|
||||
*
|
||||
* @param {Number} n
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function clampPercentage(n) {
|
||||
return Math.max(0, Math.min(n, 100));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp alpha `n` >= 0 and <= 1.
|
||||
*
|
||||
* @param {Number} n
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function clampAlpha(n) {
|
||||
return Math.max(0, Math.min(n, 1));
|
||||
}
|
156
nodejs/node_modules/stylus/lib/nodes/ident.js
generated
vendored
Normal file
156
nodejs/node_modules/stylus/lib/nodes/ident.js
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Ident
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, nodes = require('./');
|
||||
|
||||
/**
|
||||
* Initialize a new `Ident` by `name` with the given `val` node.
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Node} val
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Ident = module.exports = function Ident(name, val, mixin){
|
||||
Node.call(this);
|
||||
this.name = name;
|
||||
this.string = name;
|
||||
this.val = val || nodes.null;
|
||||
this.mixin = !!mixin;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the variable has a value.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Ident.prototype.__defineGetter__('isEmpty', function(){
|
||||
return undefined == this.val;
|
||||
});
|
||||
|
||||
/**
|
||||
* Return hash.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Ident.prototype.__defineGetter__('hash', function(){
|
||||
return this.name;
|
||||
});
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Ident.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Ident.prototype.clone = function(parent){
|
||||
var clone = new Ident(this.name);
|
||||
clone.val = this.val.clone(parent, clone);
|
||||
clone.mixin = this.mixin;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
clone.property = this.property;
|
||||
clone.rest = this.rest;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Ident.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Ident',
|
||||
name: this.name,
|
||||
val: this.val,
|
||||
mixin: this.mixin,
|
||||
property: this.property,
|
||||
rest: this.rest,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Return <name>.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Ident.prototype.toString = function(){
|
||||
return this.name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Coerce `other` to an ident.
|
||||
*
|
||||
* @param {Node} other
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Ident.prototype.coerce = function(other){
|
||||
switch (other.nodeName) {
|
||||
case 'ident':
|
||||
case 'string':
|
||||
case 'literal':
|
||||
return new Ident(other.string);
|
||||
case 'unit':
|
||||
return new Ident(other.toString());
|
||||
default:
|
||||
return Node.prototype.coerce.call(this, other);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Operate on `right` with the given `op`.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} right
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Ident.prototype.operate = function(op, right){
|
||||
var val = right.first;
|
||||
switch (op) {
|
||||
case '-':
|
||||
if ('unit' == val.nodeName) {
|
||||
var expr = new nodes.Expression;
|
||||
val = val.clone();
|
||||
val.val = -val.val;
|
||||
expr.push(this);
|
||||
expr.push(val);
|
||||
return expr;
|
||||
}
|
||||
case '+':
|
||||
return new nodes.Ident(this.string + this.coerce(val).string);
|
||||
}
|
||||
return Node.prototype.operate.call(this, op, right);
|
||||
};
|
78
nodejs/node_modules/stylus/lib/nodes/if.js
generated
vendored
Normal file
78
nodejs/node_modules/stylus/lib/nodes/if.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
/*!
|
||||
* Stylus - If
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `If` with the given `cond`.
|
||||
*
|
||||
* @param {Expression} cond
|
||||
* @param {Boolean|Block} negate, block
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var If = module.exports = function If(cond, negate){
|
||||
Node.call(this);
|
||||
this.cond = cond;
|
||||
this.elses = [];
|
||||
if (negate && negate.nodeName) {
|
||||
this.block = negate;
|
||||
} else {
|
||||
this.negate = negate;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
If.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
If.prototype.clone = function(parent){
|
||||
var clone = new If();
|
||||
clone.cond = this.cond.clone(parent, clone);
|
||||
clone.block = this.block.clone(parent, clone);
|
||||
clone.elses = this.elses.map(function(node){ return node.clone(parent, clone); });
|
||||
clone.negate = this.negate;
|
||||
clone.postfix = this.postfix;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
If.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'If',
|
||||
cond: this.cond,
|
||||
block: this.block,
|
||||
elses: this.elses,
|
||||
negate: this.negate,
|
||||
postfix: this.postfix,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
68
nodejs/node_modules/stylus/lib/nodes/import.js
generated
vendored
Normal file
68
nodejs/node_modules/stylus/lib/nodes/import.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Import
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Import` with the given `expr`.
|
||||
*
|
||||
* @param {Expression} expr
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Import = module.exports = function Import(expr, once){
|
||||
Node.call(this);
|
||||
this.path = expr;
|
||||
this.once = once || false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Import.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Import.prototype.clone = function(parent){
|
||||
var clone = new Import();
|
||||
clone.path = this.path.nodeName ? this.path.clone(parent, clone) : this.path;
|
||||
clone.once = this.once;
|
||||
clone.mtime = this.mtime;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Import.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Import',
|
||||
path: this.path,
|
||||
once: this.once,
|
||||
mtime: this.mtime,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
59
nodejs/node_modules/stylus/lib/nodes/index.js
generated
vendored
Normal file
59
nodejs/node_modules/stylus/lib/nodes/index.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
/*!
|
||||
* Stylus - nodes
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructors
|
||||
*/
|
||||
|
||||
exports.Node = require('./node');
|
||||
exports.Root = require('./root');
|
||||
exports.Null = require('./null');
|
||||
exports.Each = require('./each');
|
||||
exports.If = require('./if');
|
||||
exports.Call = require('./call');
|
||||
exports.UnaryOp = require('./unaryop');
|
||||
exports.BinOp = require('./binop');
|
||||
exports.Ternary = require('./ternary');
|
||||
exports.Block = require('./block');
|
||||
exports.Unit = require('./unit');
|
||||
exports.String = require('./string');
|
||||
exports.HSLA = require('./hsla');
|
||||
exports.RGBA = require('./rgba');
|
||||
exports.Ident = require('./ident');
|
||||
exports.Group = require('./group');
|
||||
exports.Literal = require('./literal');
|
||||
exports.Boolean = require('./boolean');
|
||||
exports.Return = require('./return');
|
||||
exports.Media = require('./media');
|
||||
exports.QueryList = require('./query-list');
|
||||
exports.Query = require('./query');
|
||||
exports.Feature = require('./feature');
|
||||
exports.Params = require('./params');
|
||||
exports.Comment = require('./comment');
|
||||
exports.Keyframes = require('./keyframes');
|
||||
exports.Member = require('./member');
|
||||
exports.Charset = require('./charset');
|
||||
exports.Namespace = require('./namespace');
|
||||
exports.Import = require('./import');
|
||||
exports.Extend = require('./extend');
|
||||
exports.Object = require('./object');
|
||||
exports.Function = require('./function');
|
||||
exports.Property = require('./property');
|
||||
exports.Selector = require('./selector');
|
||||
exports.Expression = require('./expression');
|
||||
exports.Arguments = require('./arguments');
|
||||
exports.Atblock = require('./atblock');
|
||||
exports.Atrule = require('./atrule');
|
||||
exports.Supports = require('./supports');
|
||||
|
||||
/**
|
||||
* Singletons.
|
||||
*/
|
||||
|
||||
exports.true = new exports.Boolean(true);
|
||||
exports.false = new exports.Boolean(false);
|
||||
exports.null = new exports.Null;
|
81
nodejs/node_modules/stylus/lib/nodes/keyframes.js
generated
vendored
Normal file
81
nodejs/node_modules/stylus/lib/nodes/keyframes.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Keyframes
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Atrule = require('./atrule');
|
||||
|
||||
/**
|
||||
* Initialize a new `Keyframes` with the given `segs`,
|
||||
* and optional vendor `prefix`.
|
||||
*
|
||||
* @param {Array} segs
|
||||
* @param {String} prefix
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Keyframes = module.exports = function Keyframes(segs, prefix){
|
||||
Atrule.call(this, 'keyframes');
|
||||
this.segments = segs;
|
||||
this.prefix = prefix || 'official';
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Atrule.prototype`.
|
||||
*/
|
||||
|
||||
Keyframes.prototype.__proto__ = Atrule.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Keyframes.prototype.clone = function(parent){
|
||||
var clone = new Keyframes;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
clone.segments = this.segments.map(function(node) { return node.clone(parent, clone); });
|
||||
clone.prefix = this.prefix;
|
||||
clone.block = this.block.clone(parent, clone);
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Keyframes.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Keyframes',
|
||||
segments: this.segments,
|
||||
prefix: this.prefix,
|
||||
block: this.block,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Return `@keyframes name`.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Keyframes.prototype.toString = function(){
|
||||
return '@keyframes ' + this.segments.join('');
|
||||
};
|
112
nodejs/node_modules/stylus/lib/nodes/literal.js
generated
vendored
Normal file
112
nodejs/node_modules/stylus/lib/nodes/literal.js
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Literal
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, nodes = require('./');
|
||||
|
||||
/**
|
||||
* Initialize a new `Literal` with the given `str`.
|
||||
*
|
||||
* @param {String} str
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Literal = module.exports = function Literal(str){
|
||||
Node.call(this);
|
||||
this.val = str;
|
||||
this.string = str;
|
||||
this.prefixed = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Literal.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return hash.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Literal.prototype.__defineGetter__('hash', function(){
|
||||
return this.val;
|
||||
});
|
||||
|
||||
/**
|
||||
* Return literal value.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Literal.prototype.toString = function(){
|
||||
return this.val;
|
||||
};
|
||||
|
||||
/**
|
||||
* Coerce `other` to a literal.
|
||||
*
|
||||
* @param {Node} other
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Literal.prototype.coerce = function(other){
|
||||
switch (other.nodeName) {
|
||||
case 'ident':
|
||||
case 'string':
|
||||
case 'literal':
|
||||
return new Literal(other.string);
|
||||
default:
|
||||
return Node.prototype.coerce.call(this, other);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Operate on `right` with the given `op`.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} right
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Literal.prototype.operate = function(op, right){
|
||||
var val = right.first;
|
||||
switch (op) {
|
||||
case '+':
|
||||
return new nodes.Literal(this.string + this.coerce(val).string);
|
||||
default:
|
||||
return Node.prototype.operate.call(this, op, right);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Literal.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Literal',
|
||||
val: this.val,
|
||||
string: this.string,
|
||||
prefixed: this.prefixed,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
76
nodejs/node_modules/stylus/lib/nodes/media.js
generated
vendored
Normal file
76
nodejs/node_modules/stylus/lib/nodes/media.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Media
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Atrule = require('./atrule');
|
||||
|
||||
/**
|
||||
* Initialize a new `Media` with the given `val`
|
||||
*
|
||||
* @param {String} val
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Media = module.exports = function Media(val){
|
||||
Atrule.call(this, 'media');
|
||||
this.val = val;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Atrule.prototype`.
|
||||
*/
|
||||
|
||||
Media.prototype.__proto__ = Atrule.prototype;
|
||||
|
||||
/**
|
||||
* Clone this node.
|
||||
*
|
||||
* @return {Media}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Media.prototype.clone = function(parent){
|
||||
var clone = new Media;
|
||||
clone.val = this.val.clone(parent, clone);
|
||||
clone.block = this.block.clone(parent, clone);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Media.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Media',
|
||||
val: this.val,
|
||||
block: this.block,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Return @media "val".
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Media.prototype.toString = function(){
|
||||
return '@media ' + this.val;
|
||||
};
|
82
nodejs/node_modules/stylus/lib/nodes/member.js
generated
vendored
Normal file
82
nodejs/node_modules/stylus/lib/nodes/member.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Member
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Member` with `left` and `right`.
|
||||
*
|
||||
* @param {Node} left
|
||||
* @param {Node} right
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Member = module.exports = function Member(left, right){
|
||||
Node.call(this);
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Member.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Member.prototype.clone = function(parent){
|
||||
var clone = new Member;
|
||||
clone.left = this.left.clone(parent, clone);
|
||||
clone.right = this.right.clone(parent, clone);
|
||||
if (this.val) clone.val = this.val.clone(parent, clone);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Member.prototype.toJSON = function(){
|
||||
var json = {
|
||||
__type: 'Member',
|
||||
left: this.left,
|
||||
right: this.right,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
if (this.val) json.val = this.val;
|
||||
return json;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a string representation of this node.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Member.prototype.toString = function(){
|
||||
return this.left.toString()
|
||||
+ '.' + this.right.toString();
|
||||
};
|
60
nodejs/node_modules/stylus/lib/nodes/namespace.js
generated
vendored
Normal file
60
nodejs/node_modules/stylus/lib/nodes/namespace.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/*!
|
||||
* Stylus - Namespace
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Namespace` with the given `val` and `prefix`
|
||||
*
|
||||
* @param {String|Call} val
|
||||
* @param {String} [prefix]
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Namespace = module.exports = function Namespace(val, prefix){
|
||||
Node.call(this);
|
||||
this.val = val;
|
||||
this.prefix = prefix;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Namespace.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return @namespace "val".
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Namespace.prototype.toString = function(){
|
||||
return '@namespace ' + (this.prefix ? this.prefix + ' ' : '') + this.val;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Namespace.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Namespace',
|
||||
val: this.val,
|
||||
prefix: this.prefix,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
250
nodejs/node_modules/stylus/lib/nodes/node.js
generated
vendored
Normal file
250
nodejs/node_modules/stylus/lib/nodes/node.js
generated
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Node
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Evaluator = require('../visitor/evaluator')
|
||||
, utils = require('../utils')
|
||||
, nodes = require('./');
|
||||
|
||||
/**
|
||||
* Initialize a new `CoercionError` with the given `msg`.
|
||||
*
|
||||
* @param {String} msg
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function CoercionError(msg) {
|
||||
this.name = 'CoercionError'
|
||||
this.message = msg
|
||||
Error.captureStackTrace(this, CoercionError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from `Error.prototype`.
|
||||
*/
|
||||
|
||||
CoercionError.prototype.__proto__ = Error.prototype;
|
||||
|
||||
/**
|
||||
* Node constructor.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Node = module.exports = function Node(){
|
||||
this.lineno = nodes.lineno || 1;
|
||||
this.column = nodes.column || 1;
|
||||
this.filename = nodes.filename;
|
||||
};
|
||||
|
||||
Node.prototype = {
|
||||
constructor: Node,
|
||||
|
||||
/**
|
||||
* Return this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
get first() {
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return hash.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
get hash() {
|
||||
return this.val;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return node name.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
get nodeName() {
|
||||
return this.constructor.name.toLowerCase();
|
||||
},
|
||||
|
||||
/**
|
||||
* Return this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
clone: function(){
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
toJSON: function(){
|
||||
return {
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Nodes by default evaluate to themselves.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
eval: function(){
|
||||
return new Evaluator(this).evaluate();
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
toBoolean: function(){
|
||||
return nodes.true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the expression, or wrap this node in an expression.
|
||||
*
|
||||
* @return {Expression}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
toExpression: function(){
|
||||
if ('expression' == this.nodeName) return this;
|
||||
var expr = new nodes.Expression;
|
||||
expr.push(this);
|
||||
return expr;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return false if `op` is generally not coerced.
|
||||
*
|
||||
* @param {String} op
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
shouldCoerce: function(op){
|
||||
switch (op) {
|
||||
case 'is a':
|
||||
case 'in':
|
||||
case '||':
|
||||
case '&&':
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Operate on `right` with the given `op`.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} right
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
operate: function(op, right){
|
||||
switch (op) {
|
||||
case 'is a':
|
||||
if ('string' == right.nodeName) {
|
||||
return nodes.Boolean(this.nodeName == right.val);
|
||||
} else {
|
||||
throw new Error('"is a" expects a string, got ' + right.toString());
|
||||
}
|
||||
case '==':
|
||||
return nodes.Boolean(this.hash == right.hash);
|
||||
case '!=':
|
||||
return nodes.Boolean(this.hash != right.hash);
|
||||
case '>=':
|
||||
return nodes.Boolean(this.hash >= right.hash);
|
||||
case '<=':
|
||||
return nodes.Boolean(this.hash <= right.hash);
|
||||
case '>':
|
||||
return nodes.Boolean(this.hash > right.hash);
|
||||
case '<':
|
||||
return nodes.Boolean(this.hash < right.hash);
|
||||
case '||':
|
||||
return this.toBoolean().isTrue
|
||||
? this
|
||||
: right;
|
||||
case 'in':
|
||||
var vals = utils.unwrap(right).nodes
|
||||
, len = vals && vals.length
|
||||
, hash = this.hash;
|
||||
if (!vals) throw new Error('"in" given invalid right-hand operand, expecting an expression');
|
||||
|
||||
// 'prop' in obj
|
||||
if (1 == len && 'object' == vals[0].nodeName) {
|
||||
return nodes.Boolean(vals[0].has(this.hash));
|
||||
}
|
||||
|
||||
for (var i = 0; i < len; ++i) {
|
||||
if (hash == vals[i].hash) {
|
||||
return nodes.true;
|
||||
}
|
||||
}
|
||||
return nodes.false;
|
||||
case '&&':
|
||||
var a = this.toBoolean()
|
||||
, b = right.toBoolean();
|
||||
return a.isTrue && b.isTrue
|
||||
? right
|
||||
: a.isFalse
|
||||
? this
|
||||
: right;
|
||||
default:
|
||||
if ('[]' == op) {
|
||||
var msg = 'cannot perform '
|
||||
+ this
|
||||
+ '[' + right + ']';
|
||||
} else {
|
||||
var msg = 'cannot perform'
|
||||
+ ' ' + this
|
||||
+ ' ' + op
|
||||
+ ' ' + right;
|
||||
}
|
||||
throw new Error(msg);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Default coercion throws.
|
||||
*
|
||||
* @param {Node} other
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
coerce: function(other){
|
||||
if (other.nodeName == this.nodeName) return other;
|
||||
throw new CoercionError('cannot coerce ' + other + ' to ' + this.nodeName);
|
||||
}
|
||||
};
|
88
nodejs/node_modules/stylus/lib/nodes/null.js
generated
vendored
Normal file
88
nodejs/node_modules/stylus/lib/nodes/null.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Null
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, nodes = require('./');
|
||||
|
||||
/**
|
||||
* Initialize a new `Null` node.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Null = module.exports = function Null(){};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Null.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return 'Null'.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Null.prototype.inspect =
|
||||
Null.prototype.toString = function(){
|
||||
return 'null';
|
||||
};
|
||||
|
||||
/**
|
||||
* Return false.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Null.prototype.toBoolean = function(){
|
||||
return nodes.false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the node is a null node.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Null.prototype.__defineGetter__('isNull', function(){
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
* Return hash.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Null.prototype.__defineGetter__('hash', function(){
|
||||
return null;
|
||||
});
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Null.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Null',
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
213
nodejs/node_modules/stylus/lib/nodes/object.js
generated
vendored
Normal file
213
nodejs/node_modules/stylus/lib/nodes/object.js
generated
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Object
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, nodes = require('./')
|
||||
, nativeObj = {}.constructor;
|
||||
|
||||
/**
|
||||
* Initialize a new `Object`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Object = module.exports = function Object(){
|
||||
Node.call(this);
|
||||
this.vals = {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Object.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Set `key` to `val`.
|
||||
*
|
||||
* @param {String} key
|
||||
* @param {Node} val
|
||||
* @return {Object} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Object.prototype.set = function(key, val){
|
||||
this.vals[key] = val;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return length.
|
||||
*
|
||||
* @return {Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Object.prototype.__defineGetter__('length', function() {
|
||||
return nativeObj.keys(this.vals).length;
|
||||
});
|
||||
|
||||
/**
|
||||
* Get `key`.
|
||||
*
|
||||
* @param {String} key
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Object.prototype.get = function(key){
|
||||
return this.vals[key] || nodes.null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Has `key`?
|
||||
*
|
||||
* @param {String} key
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Object.prototype.has = function(key){
|
||||
return key in this.vals;
|
||||
};
|
||||
|
||||
/**
|
||||
* Operate on `right` with the given `op`.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} right
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Object.prototype.operate = function(op, right){
|
||||
switch (op) {
|
||||
case '.':
|
||||
case '[]':
|
||||
return this.get(right.hash);
|
||||
case '==':
|
||||
var vals = this.vals
|
||||
, a
|
||||
, b;
|
||||
if ('object' != right.nodeName || this.length != right.length)
|
||||
return nodes.false;
|
||||
for (var key in vals) {
|
||||
a = vals[key];
|
||||
b = right.vals[key];
|
||||
if (a.operate(op, b).isFalse)
|
||||
return nodes.false;
|
||||
}
|
||||
return nodes.true;
|
||||
case '!=':
|
||||
return this.operate('==', right).negate();
|
||||
default:
|
||||
return Node.prototype.operate.call(this, op, right);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return Boolean based on the length of this object.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Object.prototype.toBoolean = function(){
|
||||
return nodes.Boolean(this.length);
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert object to string with properties.
|
||||
*
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Object.prototype.toBlock = function(){
|
||||
var str = '{'
|
||||
, key
|
||||
, val;
|
||||
for (key in this.vals) {
|
||||
val = this.get(key);
|
||||
if ('object' == val.first.nodeName) {
|
||||
str += key + ' ' + val.first.toBlock();
|
||||
} else {
|
||||
switch (key) {
|
||||
case '@charset':
|
||||
str += key + ' ' + val.first.toString() + ';';
|
||||
break;
|
||||
default:
|
||||
str += key + ':' + toString(val) + ';';
|
||||
}
|
||||
}
|
||||
}
|
||||
str += '}';
|
||||
return str;
|
||||
|
||||
function toString(node) {
|
||||
if (node.nodes) {
|
||||
return node.nodes.map(toString).join(node.isList ? ',' : ' ');
|
||||
} else if ('literal' == node.nodeName && ',' == node.val) {
|
||||
return '\\,';
|
||||
}
|
||||
return node.toString();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Object.prototype.clone = function(parent){
|
||||
var clone = new Object;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
for (var key in this.vals) {
|
||||
clone.vals[key] = this.vals[key].clone(parent, clone);
|
||||
}
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Object.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Object',
|
||||
vals: this.vals,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Return "{ <prop>: <val> }"
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Object.prototype.toString = function(){
|
||||
var obj = {};
|
||||
for (var prop in this.vals) {
|
||||
obj[prop] = this.vals[prop].toString();
|
||||
}
|
||||
return JSON.stringify(obj);
|
||||
};
|
90
nodejs/node_modules/stylus/lib/nodes/params.js
generated
vendored
Normal file
90
nodejs/node_modules/stylus/lib/nodes/params.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Params
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Params` with `name`, `params`, and `body`.
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Params} params
|
||||
* @param {Expression} body
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Params = module.exports = function Params(){
|
||||
Node.call(this);
|
||||
this.nodes = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Check function arity.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Params.prototype.__defineGetter__('length', function(){
|
||||
return this.nodes.length;
|
||||
});
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Params.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Push the given `node`.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Params.prototype.push = function(node){
|
||||
this.nodes.push(node);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Params.prototype.clone = function(parent){
|
||||
var clone = new Params;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
this.nodes.forEach(function(node){
|
||||
clone.push(node.clone(parent, clone));
|
||||
});
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Params.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Params',
|
||||
nodes: this.nodes,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
||||
|
96
nodejs/node_modules/stylus/lib/nodes/property.js
generated
vendored
Normal file
96
nodejs/node_modules/stylus/lib/nodes/property.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Property
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Property` with the given `segs` and optional `expr`.
|
||||
*
|
||||
* @param {Array} segs
|
||||
* @param {Expression} expr
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Property = module.exports = function Property(segs, expr){
|
||||
Node.call(this);
|
||||
this.segments = segs;
|
||||
this.expr = expr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Property.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Property.prototype.clone = function(parent){
|
||||
var clone = new Property(this.segments);
|
||||
clone.name = this.name;
|
||||
if (this.literal) clone.literal = this.literal;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
clone.segments = this.segments.map(function(node){ return node.clone(parent, clone); });
|
||||
if (this.expr) clone.expr = this.expr.clone(parent, clone);
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Property.prototype.toJSON = function(){
|
||||
var json = {
|
||||
__type: 'Property',
|
||||
segments: this.segments,
|
||||
name: this.name,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
if (this.expr) json.expr = this.expr;
|
||||
if (this.literal) json.literal = this.literal;
|
||||
return json;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return string representation of this node.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Property.prototype.toString = function(){
|
||||
return 'property(' + this.segments.join('') + ', ' + this.expr + ')';
|
||||
};
|
||||
|
||||
/**
|
||||
* Operate on the property expression.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} right
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Property.prototype.operate = function(op, right, val){
|
||||
return this.expr.operate(op, right, val);
|
||||
};
|
108
nodejs/node_modules/stylus/lib/nodes/query-list.js
generated
vendored
Normal file
108
nodejs/node_modules/stylus/lib/nodes/query-list.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
|
||||
/*!
|
||||
* Stylus - QueryList
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `QueryList`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var QueryList = module.exports = function QueryList(){
|
||||
Node.call(this);
|
||||
this.nodes = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
QueryList.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
QueryList.prototype.clone = function(parent){
|
||||
var clone = new QueryList;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
for (var i = 0; i < this.nodes.length; ++i) {
|
||||
clone.push(this.nodes[i].clone(parent, clone));
|
||||
}
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Push the given `node`.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
QueryList.prototype.push = function(node){
|
||||
this.nodes.push(node);
|
||||
};
|
||||
|
||||
/**
|
||||
* Merges this query list with the `other`.
|
||||
*
|
||||
* @param {QueryList} other
|
||||
* @return {QueryList}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
QueryList.prototype.merge = function(other){
|
||||
var list = new QueryList
|
||||
, merged;
|
||||
this.nodes.forEach(function(query){
|
||||
for (var i = 0, len = other.nodes.length; i < len; ++i){
|
||||
merged = query.merge(other.nodes[i]);
|
||||
if (merged) list.push(merged);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return "<a>, <b>, <c>"
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
QueryList.prototype.toString = function(){
|
||||
return '(' + this.nodes.map(function(node){
|
||||
return node.toString();
|
||||
}).join(', ') + ')';
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
QueryList.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'QueryList',
|
||||
nodes: this.nodes,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
170
nodejs/node_modules/stylus/lib/nodes/query.js
generated
vendored
Normal file
170
nodejs/node_modules/stylus/lib/nodes/query.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Query
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Query`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Query = module.exports = function Query(){
|
||||
Node.call(this);
|
||||
this.nodes = [];
|
||||
this.type = '';
|
||||
this.predicate = '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Query.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Query.prototype.clone = function(parent){
|
||||
var clone = new Query;
|
||||
clone.predicate = this.predicate;
|
||||
clone.type = this.type;
|
||||
for (var i = 0, len = this.nodes.length; i < len; ++i) {
|
||||
clone.push(this.nodes[i].clone(parent, clone));
|
||||
}
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Push the given `feature`.
|
||||
*
|
||||
* @param {Feature} feature
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Query.prototype.push = function(feature){
|
||||
this.nodes.push(feature);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return resolved type of this query.
|
||||
*
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Query.prototype.__defineGetter__('resolvedType', function(){
|
||||
if (this.type) {
|
||||
return this.type.nodeName
|
||||
? this.type.string
|
||||
: this.type;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Return resolved predicate of this query.
|
||||
*
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Query.prototype.__defineGetter__('resolvedPredicate', function(){
|
||||
if (this.predicate) {
|
||||
return this.predicate.nodeName
|
||||
? this.predicate.string
|
||||
: this.predicate;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Merges this query with the `other`.
|
||||
*
|
||||
* @param {Query} other
|
||||
* @return {Query}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Query.prototype.merge = function(other){
|
||||
var query = new Query
|
||||
, p1 = this.resolvedPredicate
|
||||
, p2 = other.resolvedPredicate
|
||||
, t1 = this.resolvedType
|
||||
, t2 = other.resolvedType
|
||||
, type, pred;
|
||||
|
||||
// Stolen from Sass :D
|
||||
t1 = t1 || t2;
|
||||
t2 = t2 || t1;
|
||||
if (('not' == p1) ^ ('not' == p2)) {
|
||||
if (t1 == t2) return;
|
||||
type = ('not' == p1) ? t2 : t1;
|
||||
pred = ('not' == p1) ? p2 : p1;
|
||||
} else if (('not' == p1) && ('not' == p2)) {
|
||||
if (t1 != t2) return;
|
||||
type = t1;
|
||||
pred = 'not';
|
||||
} else if (t1 != t2) {
|
||||
return;
|
||||
} else {
|
||||
type = t1;
|
||||
pred = p1 || p2;
|
||||
}
|
||||
query.predicate = pred;
|
||||
query.type = type;
|
||||
query.nodes = this.nodes.concat(other.nodes);
|
||||
return query;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return "<a> and <b> and <c>"
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Query.prototype.toString = function(){
|
||||
var pred = this.predicate ? this.predicate + ' ' : ''
|
||||
, type = this.type || ''
|
||||
, len = this.nodes.length
|
||||
, str = pred + type;
|
||||
if (len) {
|
||||
str += (type && ' and ') + this.nodes.map(function(expr){
|
||||
return expr.toString();
|
||||
}).join(' and ');
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Query.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Query',
|
||||
predicate: this.predicate,
|
||||
type: this.type,
|
||||
nodes: this.nodes,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
63
nodejs/node_modules/stylus/lib/nodes/return.js
generated
vendored
Normal file
63
nodejs/node_modules/stylus/lib/nodes/return.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Return
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, nodes = require('./');
|
||||
|
||||
/**
|
||||
* Initialize a new `Return` node with the given `expr`.
|
||||
*
|
||||
* @param {Expression} expr
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Return = module.exports = function Return(expr){
|
||||
this.expr = expr || nodes.null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Return.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Return.prototype.clone = function(parent){
|
||||
var clone = new Return();
|
||||
clone.expr = this.expr.clone(parent, clone);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Return.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Return',
|
||||
expr: this.expr,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
367
nodejs/node_modules/stylus/lib/nodes/rgba.js
generated
vendored
Normal file
367
nodejs/node_modules/stylus/lib/nodes/rgba.js
generated
vendored
Normal file
@@ -0,0 +1,367 @@
|
||||
|
||||
/*!
|
||||
* Stylus - RGBA
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, HSLA = require('./hsla')
|
||||
, functions = require('../functions')
|
||||
, adjust = functions.adjust
|
||||
, nodes = require('./');
|
||||
|
||||
/**
|
||||
* Initialize a new `RGBA` with the given r,g,b,a component values.
|
||||
*
|
||||
* @param {Number} r
|
||||
* @param {Number} g
|
||||
* @param {Number} b
|
||||
* @param {Number} a
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var RGBA = exports = module.exports = function RGBA(r,g,b,a){
|
||||
Node.call(this);
|
||||
this.r = clamp(r);
|
||||
this.g = clamp(g);
|
||||
this.b = clamp(b);
|
||||
this.a = clampAlpha(a);
|
||||
this.name = '';
|
||||
this.rgba = this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
RGBA.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return an `RGBA` without clamping values.
|
||||
*
|
||||
* @param {Number} r
|
||||
* @param {Number} g
|
||||
* @param {Number} b
|
||||
* @param {Number} a
|
||||
* @return {RGBA}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.withoutClamping = function(r,g,b,a){
|
||||
var rgba = new RGBA(0,0,0,0);
|
||||
rgba.r = r;
|
||||
rgba.g = g;
|
||||
rgba.b = b;
|
||||
rgba.a = a;
|
||||
return rgba;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.prototype.clone = function(){
|
||||
var clone = new RGBA(
|
||||
this.r
|
||||
, this.g
|
||||
, this.b
|
||||
, this.a);
|
||||
clone.raw = this.raw;
|
||||
clone.name = this.name;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'RGBA',
|
||||
r: this.r,
|
||||
g: this.g,
|
||||
b: this.b,
|
||||
a: this.a,
|
||||
raw: this.raw,
|
||||
name: this.name,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Return true.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.prototype.toBoolean = function(){
|
||||
return nodes.true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return `HSLA` representation.
|
||||
*
|
||||
* @return {HSLA}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.prototype.__defineGetter__('hsla', function(){
|
||||
return HSLA.fromRGBA(this);
|
||||
});
|
||||
|
||||
/**
|
||||
* Return hash.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.prototype.__defineGetter__('hash', function(){
|
||||
return this.toString();
|
||||
});
|
||||
|
||||
/**
|
||||
* Add r,g,b,a to the current component values.
|
||||
*
|
||||
* @param {Number} r
|
||||
* @param {Number} g
|
||||
* @param {Number} b
|
||||
* @param {Number} a
|
||||
* @return {RGBA} new node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.prototype.add = function(r,g,b,a){
|
||||
return new RGBA(
|
||||
this.r + r
|
||||
, this.g + g
|
||||
, this.b + b
|
||||
, this.a + a);
|
||||
};
|
||||
|
||||
/**
|
||||
* Subtract r,g,b,a from the current component values.
|
||||
*
|
||||
* @param {Number} r
|
||||
* @param {Number} g
|
||||
* @param {Number} b
|
||||
* @param {Number} a
|
||||
* @return {RGBA} new node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.prototype.sub = function(r,g,b,a){
|
||||
return new RGBA(
|
||||
this.r - r
|
||||
, this.g - g
|
||||
, this.b - b
|
||||
, a == 1 ? this.a : this.a - a);
|
||||
};
|
||||
|
||||
/**
|
||||
* Multiply rgb components by `n`.
|
||||
*
|
||||
* @param {String} n
|
||||
* @return {RGBA} new node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.prototype.multiply = function(n){
|
||||
return new RGBA(
|
||||
this.r * n
|
||||
, this.g * n
|
||||
, this.b * n
|
||||
, this.a);
|
||||
};
|
||||
|
||||
/**
|
||||
* Divide rgb components by `n`.
|
||||
*
|
||||
* @param {String} n
|
||||
* @return {RGBA} new node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.prototype.divide = function(n){
|
||||
return new RGBA(
|
||||
this.r / n
|
||||
, this.g / n
|
||||
, this.b / n
|
||||
, this.a);
|
||||
};
|
||||
|
||||
/**
|
||||
* Operate on `right` with the given `op`.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} right
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.prototype.operate = function(op, right){
|
||||
if ('in' != op) right = right.first
|
||||
|
||||
switch (op) {
|
||||
case 'is a':
|
||||
if ('string' == right.nodeName && 'color' == right.string) {
|
||||
return nodes.true;
|
||||
}
|
||||
break;
|
||||
case '+':
|
||||
switch (right.nodeName) {
|
||||
case 'unit':
|
||||
var n = right.val;
|
||||
switch (right.type) {
|
||||
case '%': return adjust(this, new nodes.String('lightness'), right);
|
||||
case 'deg': return this.hsla.adjustHue(n).rgba;
|
||||
default: return this.add(n,n,n,0);
|
||||
}
|
||||
case 'rgba':
|
||||
return this.add(right.r, right.g, right.b, right.a);
|
||||
case 'hsla':
|
||||
return this.hsla.add(right.h, right.s, right.l);
|
||||
}
|
||||
break;
|
||||
case '-':
|
||||
switch (right.nodeName) {
|
||||
case 'unit':
|
||||
var n = right.val;
|
||||
switch (right.type) {
|
||||
case '%': return adjust(this, new nodes.String('lightness'), new nodes.Unit(-n, '%'));
|
||||
case 'deg': return this.hsla.adjustHue(-n).rgba;
|
||||
default: return this.sub(n,n,n,0);
|
||||
}
|
||||
case 'rgba':
|
||||
return this.sub(right.r, right.g, right.b, right.a);
|
||||
case 'hsla':
|
||||
return this.hsla.sub(right.h, right.s, right.l);
|
||||
}
|
||||
break;
|
||||
case '*':
|
||||
switch (right.nodeName) {
|
||||
case 'unit':
|
||||
return this.multiply(right.val);
|
||||
}
|
||||
break;
|
||||
case '/':
|
||||
switch (right.nodeName) {
|
||||
case 'unit':
|
||||
return this.divide(right.val);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return Node.prototype.operate.call(this, op, right);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return #nnnnnn, #nnn, or rgba(n,n,n,n) string representation of the color.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
RGBA.prototype.toString = function(){
|
||||
function pad(n) {
|
||||
return n < 16
|
||||
? '0' + n.toString(16)
|
||||
: n.toString(16);
|
||||
}
|
||||
|
||||
// special case for transparent named color
|
||||
if ('transparent' == this.name)
|
||||
return this.name;
|
||||
|
||||
if (1 == this.a) {
|
||||
var r = pad(this.r)
|
||||
, g = pad(this.g)
|
||||
, b = pad(this.b);
|
||||
|
||||
// Compress
|
||||
if (r[0] == r[1] && g[0] == g[1] && b[0] == b[1]) {
|
||||
return '#' + r[0] + g[0] + b[0];
|
||||
} else {
|
||||
return '#' + r + g + b;
|
||||
}
|
||||
} else {
|
||||
return 'rgba('
|
||||
+ this.r + ','
|
||||
+ this.g + ','
|
||||
+ this.b + ','
|
||||
+ (+this.a.toFixed(3)) + ')';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a `RGBA` from the given `hsla`.
|
||||
*
|
||||
* @param {HSLA} hsla
|
||||
* @return {RGBA}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.fromHSLA = function(hsla){
|
||||
var h = hsla.h / 360
|
||||
, s = hsla.s / 100
|
||||
, l = hsla.l / 100
|
||||
, a = hsla.a;
|
||||
|
||||
var m2 = l <= .5 ? l * (s + 1) : l + s - l * s
|
||||
, m1 = l * 2 - m2;
|
||||
|
||||
var r = hue(h + 1/3) * 0xff
|
||||
, g = hue(h) * 0xff
|
||||
, b = hue(h - 1/3) * 0xff;
|
||||
|
||||
function hue(h) {
|
||||
if (h < 0) ++h;
|
||||
if (h > 1) --h;
|
||||
if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
|
||||
if (h * 2 < 1) return m2;
|
||||
if (h * 3 < 2) return m1 + (m2 - m1) * (2/3 - h) * 6;
|
||||
return m1;
|
||||
}
|
||||
|
||||
return new RGBA(r,g,b,a);
|
||||
};
|
||||
|
||||
/**
|
||||
* Clamp `n` >= 0 and <= 255.
|
||||
*
|
||||
* @param {Number} n
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function clamp(n) {
|
||||
return Math.max(0, Math.min(n.toFixed(0), 255));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp alpha `n` >= 0 and <= 1.
|
||||
*
|
||||
* @param {Number} n
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function clampAlpha(n) {
|
||||
return Math.max(0, Math.min(n, 1));
|
||||
}
|
96
nodejs/node_modules/stylus/lib/nodes/root.js
generated
vendored
Normal file
96
nodejs/node_modules/stylus/lib/nodes/root.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Root
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Root` node.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Root = module.exports = function Root(){
|
||||
this.nodes = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Root.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Push a `node` to this block.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Root.prototype.push = function(node){
|
||||
this.nodes.push(node);
|
||||
};
|
||||
|
||||
/**
|
||||
* Unshift a `node` to this block.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Root.prototype.unshift = function(node){
|
||||
this.nodes.unshift(node);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Root.prototype.clone = function(){
|
||||
var clone = new Root();
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
this.nodes.forEach(function(node){
|
||||
clone.push(node.clone(clone, clone));
|
||||
});
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return "root".
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Root.prototype.toString = function(){
|
||||
return '[Root]';
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Root.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Root',
|
||||
nodes: this.nodes,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
94
nodejs/node_modules/stylus/lib/nodes/selector.js
generated
vendored
Normal file
94
nodejs/node_modules/stylus/lib/nodes/selector.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Selector
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Block = require('./block')
|
||||
, Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Selector` with the given `segs`.
|
||||
*
|
||||
* @param {Array} segs
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Selector = module.exports = function Selector(segs){
|
||||
Node.call(this);
|
||||
this.inherits = true;
|
||||
this.segments = segs;
|
||||
this.optional = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Selector.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return the selector string.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Selector.prototype.toString = function(){
|
||||
return this.segments.join('') + (this.optional ? ' !optional' : '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if this is placeholder selector.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Selector.prototype.__defineGetter__('isPlaceholder', function(){
|
||||
return this.val && ~this.val.substr(0, 2).indexOf('$');
|
||||
});
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Selector.prototype.clone = function(parent){
|
||||
var clone = new Selector;
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
clone.inherits = this.inherits;
|
||||
clone.val = this.val;
|
||||
clone.segments = this.segments.map(function(node){ return node.clone(parent, clone); });
|
||||
clone.optional = this.optional;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Selector.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Selector',
|
||||
inherits: this.inherits,
|
||||
segments: this.segments,
|
||||
optional: this.optional,
|
||||
val: this.val,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
147
nodejs/node_modules/stylus/lib/nodes/string.js
generated
vendored
Normal file
147
nodejs/node_modules/stylus/lib/nodes/string.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
/*!
|
||||
* Stylus - String
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, sprintf = require('../functions').s
|
||||
, utils = require('../utils')
|
||||
, nodes = require('./');
|
||||
|
||||
/**
|
||||
* Initialize a new `String` with the given `val`.
|
||||
*
|
||||
* @param {String} val
|
||||
* @param {String} quote
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var String = module.exports = function String(val, quote){
|
||||
Node.call(this);
|
||||
this.val = val;
|
||||
this.string = val;
|
||||
this.prefixed = false;
|
||||
if (typeof quote !== 'string') {
|
||||
this.quote = "'";
|
||||
} else {
|
||||
this.quote = quote;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
String.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return quoted string.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
String.prototype.toString = function(){
|
||||
return this.quote + this.val + this.quote;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
String.prototype.clone = function(){
|
||||
var clone = new String(this.val, this.quote);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
String.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'String',
|
||||
val: this.val,
|
||||
quote: this.quote,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Return Boolean based on the length of this string.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
String.prototype.toBoolean = function(){
|
||||
return nodes.Boolean(this.val.length);
|
||||
};
|
||||
|
||||
/**
|
||||
* Coerce `other` to a string.
|
||||
*
|
||||
* @param {Node} other
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
String.prototype.coerce = function(other){
|
||||
switch (other.nodeName) {
|
||||
case 'string':
|
||||
return other;
|
||||
case 'expression':
|
||||
return new String(other.nodes.map(function(node){
|
||||
return this.coerce(node).val;
|
||||
}, this).join(' '));
|
||||
default:
|
||||
return new String(other.toString());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Operate on `right` with the given `op`.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} right
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
String.prototype.operate = function(op, right){
|
||||
switch (op) {
|
||||
case '%':
|
||||
var expr = new nodes.Expression;
|
||||
expr.push(this);
|
||||
|
||||
// constructargs
|
||||
var args = 'expression' == right.nodeName
|
||||
? utils.unwrap(right).nodes
|
||||
: [right];
|
||||
|
||||
// apply
|
||||
return sprintf.apply(null, [expr].concat(args));
|
||||
case '+':
|
||||
var expr = new nodes.Expression;
|
||||
expr.push(new String(this.val + this.coerce(right).val));
|
||||
return expr;
|
||||
default:
|
||||
return Node.prototype.operate.call(this, op, right);
|
||||
}
|
||||
};
|
75
nodejs/node_modules/stylus/lib/nodes/supports.js
generated
vendored
Normal file
75
nodejs/node_modules/stylus/lib/nodes/supports.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/*!
|
||||
* Stylus - supports
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Atrule = require('./atrule');
|
||||
|
||||
/**
|
||||
* Initialize a new supports node.
|
||||
*
|
||||
* @param {Expression} condition
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Supports = module.exports = function Supports(condition){
|
||||
Atrule.call(this, 'supports');
|
||||
this.condition = condition;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Atrule.prototype`.
|
||||
*/
|
||||
|
||||
Supports.prototype.__proto__ = Atrule.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Supports.prototype.clone = function(parent){
|
||||
var clone = new Supports;
|
||||
clone.condition = this.condition.clone(parent, clone);
|
||||
clone.block = this.block.clone(parent, clone);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Supports.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Supports',
|
||||
condition: this.condition,
|
||||
block: this.block,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Return @supports
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Supports.prototype.toString = function(){
|
||||
return '@supports ' + this.condition;
|
||||
};
|
71
nodejs/node_modules/stylus/lib/nodes/ternary.js
generated
vendored
Normal file
71
nodejs/node_modules/stylus/lib/nodes/ternary.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Ternary
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `Ternary` with `cond`, `trueExpr` and `falseExpr`.
|
||||
*
|
||||
* @param {Expression} cond
|
||||
* @param {Expression} trueExpr
|
||||
* @param {Expression} falseExpr
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Ternary = module.exports = function Ternary(cond, trueExpr, falseExpr){
|
||||
Node.call(this);
|
||||
this.cond = cond;
|
||||
this.trueExpr = trueExpr;
|
||||
this.falseExpr = falseExpr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Ternary.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Ternary.prototype.clone = function(parent){
|
||||
var clone = new Ternary();
|
||||
clone.cond = this.cond.clone(parent, clone);
|
||||
clone.trueExpr = this.trueExpr.clone(parent, clone);
|
||||
clone.falseExpr = this.falseExpr.clone(parent, clone);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Ternary.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Ternary',
|
||||
cond: this.cond,
|
||||
trueExpr: this.trueExpr,
|
||||
falseExpr: this.falseExpr,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
66
nodejs/node_modules/stylus/lib/nodes/unaryop.js
generated
vendored
Normal file
66
nodejs/node_modules/stylus/lib/nodes/unaryop.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
/*!
|
||||
* Stylus - UnaryOp
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node');
|
||||
|
||||
/**
|
||||
* Initialize a new `UnaryOp` with `op`, and `expr`.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} expr
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var UnaryOp = module.exports = function UnaryOp(op, expr){
|
||||
Node.call(this);
|
||||
this.op = op;
|
||||
this.expr = expr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
UnaryOp.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
UnaryOp.prototype.clone = function(parent){
|
||||
var clone = new UnaryOp(this.op);
|
||||
clone.expr = this.expr.clone(parent, clone);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
UnaryOp.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'UnaryOp',
|
||||
op: this.op,
|
||||
expr: this.expr,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
214
nodejs/node_modules/stylus/lib/nodes/unit.js
generated
vendored
Normal file
214
nodejs/node_modules/stylus/lib/nodes/unit.js
generated
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
|
||||
/*!
|
||||
* Stylus - Unit
|
||||
* Copyright (c) Automattic <developer.wordpress.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Node = require('./node')
|
||||
, nodes = require('./');
|
||||
|
||||
/**
|
||||
* Unit conversion table.
|
||||
*/
|
||||
|
||||
var FACTOR_TABLE = {
|
||||
'mm': {val: 1, label: 'mm'},
|
||||
'cm': {val: 10, label: 'mm'},
|
||||
'in': {val: 25.4, label: 'mm'},
|
||||
'pt': {val: 25.4/72, label: 'mm'},
|
||||
'ms': {val: 1, label: 'ms'},
|
||||
's': {val: 1000, label: 'ms'},
|
||||
'Hz': {val: 1, label: 'Hz'},
|
||||
'kHz': {val: 1000, label: 'Hz'}
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize a new `Unit` with the given `val` and unit `type`
|
||||
* such as "px", "pt", "in", etc.
|
||||
*
|
||||
* @param {String} val
|
||||
* @param {String} type
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var Unit = module.exports = function Unit(val, type){
|
||||
Node.call(this);
|
||||
this.val = val;
|
||||
this.type = type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from `Node.prototype`.
|
||||
*/
|
||||
|
||||
Unit.prototype.__proto__ = Node.prototype;
|
||||
|
||||
/**
|
||||
* Return Boolean based on the unit value.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Unit.prototype.toBoolean = function(){
|
||||
return nodes.Boolean(this.type
|
||||
? true
|
||||
: this.val);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return unit string.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Unit.prototype.toString = function(){
|
||||
return this.val + (this.type || '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a clone of this node.
|
||||
*
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Unit.prototype.clone = function(){
|
||||
var clone = new Unit(this.val, this.type);
|
||||
clone.lineno = this.lineno;
|
||||
clone.column = this.column;
|
||||
clone.filename = this.filename;
|
||||
return clone;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a JSON representation of this node.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Unit.prototype.toJSON = function(){
|
||||
return {
|
||||
__type: 'Unit',
|
||||
val: this.val,
|
||||
type: this.type,
|
||||
lineno: this.lineno,
|
||||
column: this.column,
|
||||
filename: this.filename
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Operate on `right` with the given `op`.
|
||||
*
|
||||
* @param {String} op
|
||||
* @param {Node} right
|
||||
* @return {Node}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Unit.prototype.operate = function(op, right){
|
||||
var type = this.type || right.first.type;
|
||||
|
||||
// swap color
|
||||
if ('rgba' == right.nodeName || 'hsla' == right.nodeName) {
|
||||
return right.operate(op, this);
|
||||
}
|
||||
|
||||
// operate
|
||||
if (this.shouldCoerce(op)) {
|
||||
right = right.first;
|
||||
// percentages
|
||||
if ('%' != this.type && ('-' == op || '+' == op) && '%' == right.type) {
|
||||
right = new Unit(this.val * (right.val / 100), '%');
|
||||
} else {
|
||||
right = this.coerce(right);
|
||||
}
|
||||
|
||||
switch (op) {
|
||||
case '-':
|
||||
return new Unit(this.val - right.val, type);
|
||||
case '+':
|
||||
// keyframes interpolation
|
||||
type = type || (right.type == '%' && right.type);
|
||||
return new Unit(this.val + right.val, type);
|
||||
case '/':
|
||||
return new Unit(this.val / right.val, type);
|
||||
case '*':
|
||||
return new Unit(this.val * right.val, type);
|
||||
case '%':
|
||||
return new Unit(this.val % right.val, type);
|
||||
case '**':
|
||||
return new Unit(Math.pow(this.val, right.val), type);
|
||||
case '..':
|
||||
case '...':
|
||||
var start = this.val
|
||||
, end = right.val
|
||||
, expr = new nodes.Expression
|
||||
, inclusive = '..' == op;
|
||||
if (start < end) {
|
||||
do {
|
||||
expr.push(new nodes.Unit(start));
|
||||
} while (inclusive ? ++start <= end : ++start < end);
|
||||
} else {
|
||||
do {
|
||||
expr.push(new nodes.Unit(start));
|
||||
} while (inclusive ? --start >= end : --start > end);
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
|
||||
return Node.prototype.operate.call(this, op, right);
|
||||
};
|
||||
|
||||
/**
|
||||
* Coerce `other` unit to the same type as `this` unit.
|
||||
*
|
||||
* Supports:
|
||||
*
|
||||
* mm -> cm | in
|
||||
* cm -> mm | in
|
||||
* in -> mm | cm
|
||||
*
|
||||
* ms -> s
|
||||
* s -> ms
|
||||
*
|
||||
* Hz -> kHz
|
||||
* kHz -> Hz
|
||||
*
|
||||
* @param {Unit} other
|
||||
* @return {Unit}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Unit.prototype.coerce = function(other){
|
||||
if ('unit' == other.nodeName) {
|
||||
var a = this
|
||||
, b = other
|
||||
, factorA = FACTOR_TABLE[a.type]
|
||||
, factorB = FACTOR_TABLE[b.type];
|
||||
|
||||
if (factorA && factorB && (factorA.label == factorB.label)) {
|
||||
var bVal = b.val * (factorB.val / factorA.val);
|
||||
return new nodes.Unit(bVal, a.type);
|
||||
} else {
|
||||
return new nodes.Unit(b.val, a.type);
|
||||
}
|
||||
} else if ('string' == other.nodeName) {
|
||||
// keyframes interpolation
|
||||
if ('%' == other.val) return new nodes.Unit(0, '%');
|
||||
var val = parseFloat(other.val);
|
||||
if (isNaN(val)) Node.prototype.coerce.call(this, other);
|
||||
return new nodes.Unit(val);
|
||||
} else {
|
||||
return Node.prototype.coerce.call(this, other);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user