stylus-source 0.15.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/.DS_Store +0 -0
  2. data/README.md +3 -0
  3. data/lib/.DS_Store +0 -0
  4. data/lib/node_modules/cssom/.idea/CSSOM.iml +9 -0
  5. data/lib/node_modules/cssom/.idea/dictionaries/nv.xml +3 -0
  6. data/lib/node_modules/cssom/.idea/encodings.xml +5 -0
  7. data/lib/node_modules/cssom/.idea/misc.xml +17 -0
  8. data/lib/node_modules/cssom/.idea/modules.xml +9 -0
  9. data/lib/node_modules/cssom/.idea/projectCodeStyle.xml +82 -0
  10. data/lib/node_modules/cssom/.idea/vcs.xml +8 -0
  11. data/lib/node_modules/cssom/.idea/workspace.xml +467 -0
  12. data/lib/node_modules/cssom/.livereload +19 -0
  13. data/lib/node_modules/cssom/Jakefile +37 -0
  14. data/lib/node_modules/cssom/README.mdown +33 -0
  15. data/lib/node_modules/cssom/Rakefile +23 -0
  16. data/lib/node_modules/cssom/docs/.livereload +19 -0
  17. data/lib/node_modules/cssom/docs/bar.css +3 -0
  18. data/lib/node_modules/cssom/docs/demo.css +0 -0
  19. data/lib/node_modules/cssom/docs/foo.css +4 -0
  20. data/lib/node_modules/cssom/docs/parse.html +170 -0
  21. data/lib/node_modules/cssom/docs/parse2.html +431 -0
  22. data/lib/node_modules/cssom/index.html +100 -0
  23. data/lib/node_modules/cssom/lib/CSSImportRule.js +34 -0
  24. data/lib/node_modules/cssom/lib/CSSMediaRule.js +38 -0
  25. data/lib/node_modules/cssom/lib/CSSOM.js +3 -0
  26. data/lib/node_modules/cssom/lib/CSSRule.js +38 -0
  27. data/lib/node_modules/cssom/lib/CSSStyleDeclaration.js +130 -0
  28. data/lib/node_modules/cssom/lib/CSSStyleRule.js +187 -0
  29. data/lib/node_modules/cssom/lib/CSSStyleSheet.js +85 -0
  30. data/lib/node_modules/cssom/lib/MediaList.js +61 -0
  31. data/lib/node_modules/cssom/lib/StyleSheet.js +15 -0
  32. data/lib/node_modules/cssom/lib/clone.js +69 -0
  33. data/lib/node_modules/cssom/lib/index.js +10 -0
  34. data/lib/node_modules/cssom/lib/parse.js +195 -0
  35. data/lib/node_modules/cssom/media.html +17 -0
  36. data/lib/node_modules/cssom/package.json +30 -0
  37. data/lib/node_modules/cssom/plugins/toHTML.js +32 -0
  38. data/lib/node_modules/cssom/server/index.html +22 -0
  39. data/lib/node_modules/cssom/server/index.js +21 -0
  40. data/lib/node_modules/cssom/shorthands.html +21 -0
  41. data/lib/node_modules/cssom/test/CSSStyleDeclaration.test.js +35 -0
  42. data/lib/node_modules/cssom/test/CSSStyleRule.test.js +12 -0
  43. data/lib/node_modules/cssom/test/CSSStyleSheet.test.js +16 -0
  44. data/lib/node_modules/cssom/test/MediaList.test.js +21 -0
  45. data/lib/node_modules/cssom/test/clone.test.js +38 -0
  46. data/lib/node_modules/cssom/test/fixtures/dummy.css +3 -0
  47. data/lib/node_modules/cssom/test/helper.js +97 -0
  48. data/lib/node_modules/cssom/test/index.html +42 -0
  49. data/lib/node_modules/cssom/test/parse.test.js +346 -0
  50. data/lib/node_modules/cssom/test/vendor/qunit.css +189 -0
  51. data/lib/node_modules/cssom/test/vendor/qunit.js +1341 -0
  52. data/lib/node_modules/growl/History.md +16 -0
  53. data/lib/node_modules/growl/Readme.md +74 -0
  54. data/lib/node_modules/growl/lib/growl.js +82 -0
  55. data/lib/node_modules/growl/package.json +6 -0
  56. data/lib/node_modules/growl/test.js +17 -0
  57. data/lib/stylus/colors.js +156 -0
  58. data/lib/stylus/convert/css.js +130 -0
  59. data/lib/stylus/errors.js +58 -0
  60. data/lib/stylus/functions/image.js +120 -0
  61. data/lib/stylus/functions/index.js +722 -0
  62. data/lib/stylus/functions/index.styl +123 -0
  63. data/lib/stylus/functions/url.js +98 -0
  64. data/lib/stylus/lexer.js +728 -0
  65. data/lib/stylus/middleware.js +223 -0
  66. data/lib/stylus/nodes/arguments.js +65 -0
  67. data/lib/stylus/nodes/binop.js +54 -0
  68. data/lib/stylus/nodes/block.js +99 -0
  69. data/lib/stylus/nodes/boolean.js +103 -0
  70. data/lib/stylus/nodes/call.js +57 -0
  71. data/lib/stylus/nodes/charset.js +42 -0
  72. data/lib/stylus/nodes/comment.js +32 -0
  73. data/lib/stylus/nodes/each.js +56 -0
  74. data/lib/stylus/nodes/expression.js +168 -0
  75. data/lib/stylus/nodes/fontface.js +55 -0
  76. data/lib/stylus/nodes/function.js +104 -0
  77. data/lib/stylus/nodes/group.js +79 -0
  78. data/lib/stylus/nodes/hsla.js +256 -0
  79. data/lib/stylus/nodes/ident.js +127 -0
  80. data/lib/stylus/nodes/if.js +55 -0
  81. data/lib/stylus/nodes/import.js +30 -0
  82. data/lib/stylus/nodes/index.js +52 -0
  83. data/lib/stylus/nodes/jsliteral.js +32 -0
  84. data/lib/stylus/nodes/keyframes.js +78 -0
  85. data/lib/stylus/nodes/literal.js +92 -0
  86. data/lib/stylus/nodes/media.js +42 -0
  87. data/lib/stylus/nodes/node.js +209 -0
  88. data/lib/stylus/nodes/null.js +72 -0
  89. data/lib/stylus/nodes/page.js +43 -0
  90. data/lib/stylus/nodes/params.js +72 -0
  91. data/lib/stylus/nodes/property.js +72 -0
  92. data/lib/stylus/nodes/return.js +44 -0
  93. data/lib/stylus/nodes/rgba.js +335 -0
  94. data/lib/stylus/nodes/root.js +50 -0
  95. data/lib/stylus/nodes/selector.js +57 -0
  96. data/lib/stylus/nodes/string.js +120 -0
  97. data/lib/stylus/nodes/ternary.js +51 -0
  98. data/lib/stylus/nodes/unaryop.js +46 -0
  99. data/lib/stylus/nodes/unit.js +207 -0
  100. data/lib/stylus/parser.js +1514 -0
  101. data/lib/stylus/renderer.js +157 -0
  102. data/lib/stylus/source.rb +7 -0
  103. data/lib/stylus/stack/frame.js +66 -0
  104. data/lib/stylus/stack/index.js +146 -0
  105. data/lib/stylus/stack/scope.js +53 -0
  106. data/lib/stylus/stylus.js +102 -0
  107. data/lib/stylus/token.js +53 -0
  108. data/lib/stylus/utils.js +237 -0
  109. data/lib/stylus/visitor/compiler.js +472 -0
  110. data/lib/stylus/visitor/evaluator.js +1070 -0
  111. data/lib/stylus/visitor/index.js +31 -0
  112. data/stylus-source.gemspec +15 -0
  113. metadata +158 -0
@@ -0,0 +1,57 @@
1
+
2
+ /*!
3
+ * Stylus - Call
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Node = require('./node');
13
+
14
+ /**
15
+ * Initialize a new `Call` with `name` and `args`.
16
+ *
17
+ * @param {String} name
18
+ * @param {Expression} args
19
+ * @api public
20
+ */
21
+
22
+ var Call = module.exports = function Call(name, args){
23
+ Node.call(this);
24
+ this.name = name;
25
+ this.args = args;
26
+ };
27
+
28
+ /**
29
+ * Inherit from `Node.prototype`.
30
+ */
31
+
32
+ Call.prototype.__proto__ = Node.prototype;
33
+
34
+ /**
35
+ * Return a clone of this node.
36
+ *
37
+ * @return {Node}
38
+ * @api public
39
+ */
40
+
41
+ Call.prototype.clone = function(){
42
+ var clone = new Call(this.name, this.args.clone());
43
+ clone.lineno = this.lineno;
44
+ clone.filename = this.filename;
45
+ return clone;
46
+ };
47
+
48
+ /**
49
+ * Return <name>().
50
+ *
51
+ * @return {String}
52
+ * @api public
53
+ */
54
+
55
+ Call.prototype.toString = function(){
56
+ return this.name + '()';
57
+ };
@@ -0,0 +1,42 @@
1
+
2
+ /*!
3
+ * Stylus - Charset
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Node = require('./node')
13
+ , nodes = require('./');
14
+
15
+ /**
16
+ * Initialize a new `Charset` with the given `val`
17
+ *
18
+ * @param {String} val
19
+ * @api public
20
+ */
21
+
22
+ var Charset = module.exports = function Charset(val){
23
+ Node.call(this);
24
+ this.val = val;
25
+ };
26
+
27
+ /**
28
+ * Inherit from `Node.prototype`.
29
+ */
30
+
31
+ Charset.prototype.__proto__ = Node.prototype;
32
+
33
+ /**
34
+ * Return @charset "val".
35
+ *
36
+ * @return {String}
37
+ * @api public
38
+ */
39
+
40
+ Charset.prototype.toString = function(){
41
+ return '@charset ' + this.val;
42
+ };
@@ -0,0 +1,32 @@
1
+
2
+ /*!
3
+ * Stylus - Comment
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Node = require('./node');
13
+
14
+ /**
15
+ * Initialize a new `Comment` with the given `str`.
16
+ *
17
+ * @param {String} str
18
+ * @param {Boolean} suppress
19
+ * @api public
20
+ */
21
+
22
+ var Comment = module.exports = function Comment(str, suppress){
23
+ Node.call(this);
24
+ this.str = str;
25
+ this.suppress = suppress;
26
+ };
27
+
28
+ /**
29
+ * Inherit from `Node.prototype`.
30
+ */
31
+
32
+ Comment.prototype.__proto__ = Node.prototype;
@@ -0,0 +1,56 @@
1
+
2
+ /*!
3
+ * Stylus - Each
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Node = require('./node')
13
+ , nodes = require('./');
14
+
15
+ /**
16
+ * Initialize a new `Each` node with the given `val` name,
17
+ * `key` name, `expr`, and `block`.
18
+ *
19
+ * @param {String} val
20
+ * @param {String} key
21
+ * @param {Expression} expr
22
+ * @param {Block} block
23
+ * @api public
24
+ */
25
+
26
+ var Each = module.exports = function Each(val, key, expr, block){
27
+ Node.call(this);
28
+ this.val = val;
29
+ this.key = key;
30
+ this.expr = expr;
31
+ this.block = block;
32
+ };
33
+
34
+ /**
35
+ * Inherit from `Node.prototype`.
36
+ */
37
+
38
+ Each.prototype.__proto__ = Node.prototype;
39
+
40
+ /**
41
+ * Return a clone of this node.
42
+ *
43
+ * @return {Node}
44
+ * @api public
45
+ */
46
+
47
+ Each.prototype.clone = function(){
48
+ var clone = new Each(
49
+ this.val
50
+ , this.key
51
+ , this.expr.clone()
52
+ , this.block.clone());
53
+ clone.lineno = this.lineno;
54
+ clone.filename = this.filename;
55
+ return clone;
56
+ };
@@ -0,0 +1,168 @@
1
+
2
+ /*!
3
+ * Stylus - Expression
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Node = require('./node')
13
+ , nodes = require('../nodes')
14
+ , utils = require('../utils');
15
+
16
+ /**
17
+ * Initialize a new `Expression`.
18
+ *
19
+ * @param {Boolean} isList
20
+ * @api public
21
+ */
22
+
23
+ var Expression = module.exports = function Expression(isList){
24
+ Node.call(this);
25
+ this.nodes = [];
26
+ this.isList = isList;
27
+ };
28
+
29
+ /**
30
+ * Check if the variable has a value.
31
+ *
32
+ * @return {Boolean}
33
+ * @api public
34
+ */
35
+
36
+ Expression.prototype.__defineGetter__('isEmpty', function(){
37
+ return !this.nodes.length;
38
+ });
39
+
40
+ /**
41
+ * Return the first node in this expression.
42
+ *
43
+ * @return {Node}
44
+ * @api public
45
+ */
46
+
47
+ Expression.prototype.__defineGetter__('first', function(){
48
+ return this.nodes[0]
49
+ ? this.nodes[0].first
50
+ : nodes.null;
51
+ });
52
+
53
+ /**
54
+ * Hash all the nodes in order.
55
+ *
56
+ * @return {String}
57
+ * @api public
58
+ */
59
+
60
+ Expression.prototype.__defineGetter__('hash', function(){
61
+ return this.nodes.map(function(node){
62
+ return node.hash;
63
+ }).join('::');
64
+ });
65
+
66
+ /**
67
+ * Inherit from `Node.prototype`.
68
+ */
69
+
70
+ Expression.prototype.__proto__ = Node.prototype;
71
+
72
+ /**
73
+ * Return a clone of this node.
74
+ *
75
+ * @return {Node}
76
+ * @api public
77
+ */
78
+
79
+ Expression.prototype.clone = function(){
80
+ var clone = new this.constructor(this.isList);
81
+ clone.preserve = this.preserve;
82
+ clone.lineno = this.lineno;
83
+ clone.filename = this.filename;
84
+ for (var i = 0; i < this.nodes.length; ++i) {
85
+ clone.push(this.nodes[i].clone());
86
+ }
87
+ return clone;
88
+ };
89
+
90
+ /**
91
+ * Push the given `node`.
92
+ *
93
+ * @param {Node} node
94
+ * @api public
95
+ */
96
+
97
+ Expression.prototype.push = function(node){
98
+ this.nodes.push(node);
99
+ };
100
+
101
+ /**
102
+ * Operate on `right` with the given `op`.
103
+ *
104
+ * @param {String} op
105
+ * @param {Node} right
106
+ * @return {Node}
107
+ * @api public
108
+ */
109
+
110
+ Expression.prototype.operate = function(op, right, val){
111
+ switch (op) {
112
+ case '[]=':
113
+ var self = this
114
+ , range = utils.unwrap(right).nodes
115
+ , val = utils.unwrap(val)
116
+ , len;
117
+ range.forEach(function(unit){
118
+ len = self.nodes.length;
119
+ if ('unit' == unit.nodeName) {
120
+ var i = unit.val;
121
+ while (i-- > len) self.nodes[i] = nodes.null;
122
+ self.nodes[unit.val] = val;
123
+ }
124
+ });
125
+ return val;
126
+ case '[]':
127
+ var expr = new nodes.Expression
128
+ , vals = utils.unwrap(this).nodes
129
+ , range = utils.unwrap(right).nodes;
130
+ range.forEach(function(unit){
131
+ if ('unit' == unit.nodeName) {
132
+ var node = vals[unit.val];
133
+ if (node) expr.push(node);
134
+ }
135
+ });
136
+ return expr.isEmpty
137
+ ? nodes.null
138
+ : utils.unwrap(expr);
139
+ case '||':
140
+ // we consider lists with length > 1 truth,
141
+ // for example (0 1 2)
142
+ if (this.nodes.length > 1) return this;
143
+
144
+ // check the return value, and return the lhs expr
145
+ // as a whole rather than the first item
146
+ var ret = this.first.operate(op, right, val);
147
+ return ret == this.nodes[0] ? this : right;
148
+ case 'in':
149
+ return Node.prototype.operate.call(this, op, right);
150
+ default:
151
+ return this.first.operate(op, right, val);
152
+ }
153
+ };
154
+
155
+ /**
156
+ * Return "<a> <b> <c>" or "<a>, <b>, <c>" if
157
+ * the expression represents a list.
158
+ *
159
+ * @return {String}
160
+ * @api public
161
+ */
162
+
163
+ Expression.prototype.toString = function(){
164
+ return '(' + this.nodes.map(function(node){
165
+ return node.toString();
166
+ }).join(this.isList ? ', ' : ' ') + ')';
167
+ };
168
+
@@ -0,0 +1,55 @@
1
+
2
+ /*!
3
+ * Stylus - FontFace
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Node = require('./node');
13
+
14
+ /**
15
+ * Initialize a new `FontFace` with the given `block`.
16
+ *
17
+ * @param {Block} block
18
+ * @api public
19
+ */
20
+
21
+ var FontFace = module.exports = function FontFace(block){
22
+ Node.call(this);
23
+ this.block = block;
24
+ };
25
+
26
+ /**
27
+ * Inherit from `Node.prototype`.
28
+ */
29
+
30
+ FontFace.prototype.__proto__ = Node.prototype;
31
+
32
+ /**
33
+ * Return a clone of this node.
34
+ *
35
+ * @return {Node}
36
+ * @api public
37
+ */
38
+
39
+ FontFace.prototype.clone = function(){
40
+ var clone = new FontFace(this.block.clone());
41
+ clone.lineno = this.lineno;
42
+ clone.filename = this.filename;
43
+ return clone;
44
+ };
45
+
46
+ /**
47
+ * Return `@oage name`.
48
+ *
49
+ * @return {String}
50
+ * @api public
51
+ */
52
+
53
+ FontFace.prototype.toString = function(){
54
+ return '@font-face';
55
+ };
@@ -0,0 +1,104 @@
1
+
2
+ /*!
3
+ * Stylus - Function
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Node = require('./node');
13
+
14
+ /**
15
+ * Initialize a new `Function` with `name`, `params`, and `body`.
16
+ *
17
+ * @param {String} name
18
+ * @param {Params|Function} params
19
+ * @param {Block} body
20
+ * @api public
21
+ */
22
+
23
+ var Function = module.exports = function Function(name, params, body){
24
+ Node.call(this);
25
+ this.name = name;
26
+ this.params = params;
27
+ this.block = body;
28
+ if ('function' == typeof params) this.fn = params;
29
+ };
30
+
31
+ /**
32
+ * Check function arity.
33
+ *
34
+ * @return {Boolean}
35
+ * @api public
36
+ */
37
+
38
+ Function.prototype.__defineGetter__('arity', function(){
39
+ return this.params.length;
40
+ });
41
+
42
+ /**
43
+ * Inherit from `Node.prototype`.
44
+ */
45
+
46
+ Function.prototype.__proto__ = Node.prototype;
47
+
48
+ /**
49
+ * Return hash.
50
+ *
51
+ * @return {String}
52
+ * @api public
53
+ */
54
+
55
+ Function.prototype.__defineGetter__('hash', function(){
56
+ return 'function ' + this.name;
57
+ });
58
+
59
+ /**
60
+ * Return a clone of this node.
61
+ *
62
+ * @return {Node}
63
+ * @api public
64
+ */
65
+
66
+ Function.prototype.clone = function(){
67
+ if (this.fn) {
68
+ var clone = new Function(
69
+ this.name
70
+ , this.fn);
71
+ } else {
72
+ var clone = new Function(
73
+ this.name
74
+ , this.params.clone()
75
+ , this.block.clone());
76
+ }
77
+ clone.lineno = this.lineno;
78
+ clone.filename = this.filename;
79
+ return clone;
80
+ };
81
+
82
+ /**
83
+ * Return <name>(param1, param2, ...).
84
+ *
85
+ * @return {String}
86
+ * @api public
87
+ */
88
+
89
+ Function.prototype.toString = function(){
90
+ if (this.fn) {
91
+ return this.name
92
+ + '('
93
+ + this.fn.toString()
94
+ .match(/^function *\((.*?)\)/)
95
+ .slice(1)
96
+ .join(', ')
97
+ + ')';
98
+ } else {
99
+ return this.name
100
+ + '('
101
+ + this.params.nodes.join(', ')
102
+ + ')';
103
+ }
104
+ };