stylus-source 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,50 @@
1
+
2
+ /*!
3
+ * Stylus - Root
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 `Root` node.
16
+ *
17
+ * @api public
18
+ */
19
+
20
+ var Root = module.exports = function Root(){
21
+ this.nodes = [];
22
+ };
23
+
24
+ /**
25
+ * Inherit from `Node.prototype`.
26
+ */
27
+
28
+ Root.prototype.__proto__ = Node.prototype;
29
+
30
+ /**
31
+ * Push a `node` to this block.
32
+ *
33
+ * @param {Node} node
34
+ * @api public
35
+ */
36
+
37
+ Root.prototype.push = function(node){
38
+ this.nodes.push(node);
39
+ };
40
+
41
+ /**
42
+ * Return "root".
43
+ *
44
+ * @return {String}
45
+ * @api public
46
+ */
47
+
48
+ Root.prototype.toString = function(){
49
+ return '[Root]';
50
+ };
@@ -0,0 +1,57 @@
1
+
2
+ /*!
3
+ * Stylus - Selector
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Block = require('./block')
13
+ , Node = require('./node');
14
+
15
+ /**
16
+ * Initialize a new `Selector` with the given `segs`.
17
+ *
18
+ * @param {Array} segs
19
+ * @api public
20
+ */
21
+
22
+ var Selector = module.exports = function Selector(segs){
23
+ Node.call(this);
24
+ this.segments = segs;
25
+ };
26
+
27
+ /**
28
+ * Inherit from `Node.prototype`.
29
+ */
30
+
31
+ Selector.prototype.__proto__ = Node.prototype;
32
+
33
+ /**
34
+ * Return the selector string.
35
+ *
36
+ * @return {String}
37
+ * @api public
38
+ */
39
+
40
+ Selector.prototype.toString = function(){
41
+ return this.segments.join('');
42
+ };
43
+
44
+ /**
45
+ * Return a clone of this node.
46
+ *
47
+ * @return {Node}
48
+ * @api public
49
+ */
50
+
51
+ Selector.prototype.clone = function(){
52
+ var clone = new Selector;
53
+ clone.lineno = this.lineno;
54
+ clone.filename = this.filename;
55
+ clone.segments = this.segments.map(function(node){ return node.clone(); });
56
+ return clone;
57
+ };
@@ -0,0 +1,120 @@
1
+
2
+ /*!
3
+ * Stylus - String
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
+ , sprintf = require('../functions').s
14
+ , utils = require('../utils')
15
+ , nodes = require('./');
16
+
17
+ /**
18
+ * Initialize a new `String` with the given `val`.
19
+ *
20
+ * @param {String} val
21
+ * @api public
22
+ */
23
+
24
+ var String = module.exports = function String(val){
25
+ Node.call(this);
26
+ this.val = val;
27
+ this.string = val;
28
+ };
29
+
30
+ /**
31
+ * Inherit from `Node.prototype`.
32
+ */
33
+
34
+ String.prototype.__proto__ = Node.prototype;
35
+
36
+ /**
37
+ * Return quoted string.
38
+ *
39
+ * @return {String}
40
+ * @api public
41
+ */
42
+
43
+ String.prototype.toString = function(){
44
+ return '"' + this.val + '"';
45
+ };
46
+
47
+ /**
48
+ * Return a clone of this node.
49
+ *
50
+ * @return {Node}
51
+ * @api public
52
+ */
53
+
54
+ String.prototype.clone = function(){
55
+ var clone = new String(this.val);
56
+ clone.lineno = this.lineno;
57
+ clone.filename = this.filename;
58
+ return clone;
59
+ };
60
+
61
+ /**
62
+ * Return Boolean based on the length of this string.
63
+ *
64
+ * @return {Boolean}
65
+ * @api public
66
+ */
67
+
68
+ String.prototype.toBoolean = function(){
69
+ return nodes.Boolean(this.val.length);
70
+ };
71
+
72
+ /**
73
+ * Coerce `other` to a string.
74
+ *
75
+ * @param {Node} other
76
+ * @return {String}
77
+ * @api public
78
+ */
79
+
80
+ String.prototype.coerce = function(other){
81
+ switch (other.nodeName) {
82
+ case 'string':
83
+ return other;
84
+ case 'expression':
85
+ return new String(other.nodes.map(function(node){
86
+ return this.coerce(node).val;
87
+ }, this).join(' '));
88
+ default:
89
+ return new String(other.toString());
90
+ }
91
+ };
92
+
93
+ /**
94
+ * Operate on `right` with the given `op`.
95
+ *
96
+ * @param {String} op
97
+ * @param {Node} right
98
+ * @return {Node}
99
+ * @api public
100
+ */
101
+
102
+ String.prototype.operate = function(op, right){
103
+ switch (op) {
104
+ case '%':
105
+ var expr = new nodes.Expression;
106
+ expr.push(this);
107
+
108
+ // constructargs
109
+ var args = 'expression' == right.nodeName
110
+ ? utils.unwrap(right).nodes
111
+ : [right];
112
+
113
+ // apply
114
+ return sprintf.apply(null, [expr].concat(args));
115
+ case '+':
116
+ return new String(this.val + this.coerce(right).val);
117
+ default:
118
+ return Node.prototype.operate.call(this, op, right);
119
+ }
120
+ };
@@ -0,0 +1,51 @@
1
+
2
+ /*!
3
+ * Stylus - Ternary
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 `Ternary` with `cond`, `trueExpr` and `falseExpr`.
16
+ *
17
+ * @param {Expression} cond
18
+ * @param {Expression} trueExpr
19
+ * @param {Expression} falseExpr
20
+ * @api public
21
+ */
22
+
23
+ var Ternary = module.exports = function Ternary(cond, trueExpr, falseExpr){
24
+ Node.call(this);
25
+ this.cond = cond;
26
+ this.trueExpr = trueExpr;
27
+ this.falseExpr = falseExpr;
28
+ };
29
+
30
+ /**
31
+ * Inherit from `Node.prototype`.
32
+ */
33
+
34
+ Ternary.prototype.__proto__ = Node.prototype;
35
+
36
+ /**
37
+ * Return a clone of this node.
38
+ *
39
+ * @return {Node}
40
+ * @api public
41
+ */
42
+
43
+ Ternary.prototype.clone = function(){
44
+ var clone = new Ternary(
45
+ this.cond.clone()
46
+ , this.trueExpr.clone()
47
+ , this.falseExpr.clone());
48
+ clone.lineno = this.lineno;
49
+ clone.filename = this.filename;
50
+ return clone;
51
+ };
@@ -0,0 +1,46 @@
1
+
2
+ /*!
3
+ * Stylus - UnaryOp
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 `UnaryOp` with `op`, and `expr`.
16
+ *
17
+ * @param {String} op
18
+ * @param {Node} expr
19
+ * @api public
20
+ */
21
+
22
+ var UnaryOp = module.exports = function UnaryOp(op, expr){
23
+ Node.call(this);
24
+ this.op = op;
25
+ this.expr = expr;
26
+ };
27
+
28
+ /**
29
+ * Inherit from `Node.prototype`.
30
+ */
31
+
32
+ UnaryOp.prototype.__proto__ = Node.prototype;
33
+
34
+ /**
35
+ * Return a clone of this node.
36
+ *
37
+ * @return {Node}
38
+ * @api public
39
+ */
40
+
41
+ UnaryOp.prototype.clone = function(){
42
+ var clone = new UnaryOp(this.op, this.expr.clone());
43
+ clone.lineno = this.lineno;
44
+ clone.filename = this.filename;
45
+ return clone;
46
+ };
@@ -0,0 +1,207 @@
1
+
2
+ /*!
3
+ * Stylus - Unit
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 `Unit` with the given `val` and unit `type`
17
+ * such as "px", "pt", "in", etc.
18
+ *
19
+ * @param {String} val
20
+ * @param {String} type
21
+ * @api public
22
+ */
23
+
24
+ var Unit = module.exports = function Unit(val, type){
25
+ Node.call(this);
26
+ this.val = val;
27
+ this.type = type;
28
+ };
29
+
30
+ /**
31
+ * Inherit from `Node.prototype`.
32
+ */
33
+
34
+ Unit.prototype.__proto__ = Node.prototype;
35
+
36
+ /**
37
+ * Return Boolean based on the unit value.
38
+ *
39
+ * @return {Boolean}
40
+ * @api public
41
+ */
42
+
43
+ Unit.prototype.toBoolean = function(){
44
+ return nodes.Boolean(this.type
45
+ ? true
46
+ : this.val);
47
+ };
48
+
49
+ /**
50
+ * Return unit string.
51
+ *
52
+ * @return {String}
53
+ * @api public
54
+ */
55
+
56
+ Unit.prototype.toString = function(){
57
+ var n = this.val;
58
+ if ('px' == this.type) n = n.toFixed(0);
59
+ return n + (this.type || '');
60
+ };
61
+
62
+ /**
63
+ * Return a clone of this node.
64
+ *
65
+ * @return {Node}
66
+ * @api public
67
+ */
68
+
69
+ Unit.prototype.clone = function(){
70
+ var clone = new Unit(this.val, this.type);
71
+ clone.lineno = this.lineno;
72
+ clone.filename = this.filename;
73
+ return clone;
74
+ };
75
+
76
+ /**
77
+ * Operate on `right` with the given `op`.
78
+ *
79
+ * @param {String} op
80
+ * @param {Node} right
81
+ * @return {Node}
82
+ * @api public
83
+ */
84
+
85
+ Unit.prototype.operate = function(op, right){
86
+ var type = this.type || right.type;
87
+
88
+ // swap color
89
+ if ('rgba' == right.nodeName || 'hsla' == right.nodeName) {
90
+ return right.operate(op, this);
91
+ }
92
+
93
+ // operate
94
+ if (this.shouldCoerce(op)) {
95
+ // percentages
96
+ if (('-' == op || '+' == op) && '%' == right.type) {
97
+ right.val = this.val * (right.val / 100);
98
+ } else {
99
+ right = this.coerce(right.first);
100
+ }
101
+
102
+ switch (op) {
103
+ case '-':
104
+ return new Unit(this.val - right.val, type);
105
+ case '+':
106
+ return new Unit(this.val + right.val, type);
107
+ case '/':
108
+ return new Unit(this.val / right.val, type);
109
+ case '*':
110
+ return new Unit(this.val * right.val, type);
111
+ case '%':
112
+ return new Unit(this.val % right.val, type);
113
+ case '**':
114
+ return new Unit(Math.pow(this.val, right.val), type);
115
+ case '..':
116
+ case '...':
117
+ var start = this.val
118
+ , end = right.val
119
+ , expr = new nodes.Expression
120
+ , inclusive = '..' == op;
121
+ do {
122
+ expr.push(new nodes.Unit(start));
123
+ } while (inclusive ? ++start <= end : ++start < end);
124
+ return expr;
125
+ }
126
+ }
127
+
128
+ return Node.prototype.operate.call(this, op, right);
129
+ };
130
+
131
+ /**
132
+ * Coerce `other` unit to the same type as `this` unit.
133
+ *
134
+ * Supports:
135
+ *
136
+ * mm -> cm | in
137
+ * cm -> mm | in
138
+ * in -> mm | cm
139
+ *
140
+ * ms -> s
141
+ * s -> ms
142
+ *
143
+ * Hz -> kHz
144
+ * kHz -> Hz
145
+ *
146
+ * @param {Unit} other
147
+ * @return {Unit}
148
+ * @api public
149
+ */
150
+
151
+ Unit.prototype.coerce = function(other){
152
+ if ('unit' == other.nodeName) {
153
+ var a = this
154
+ , b = other;
155
+ switch (a.type) {
156
+ case 'mm':
157
+ switch (b.type) {
158
+ case 'cm':
159
+ return new nodes.Unit(b.val * 2.54, 'mm');
160
+ case 'in':
161
+ return new nodes.Unit(b.val * 25.4, 'mm');
162
+ }
163
+ case 'cm':
164
+ switch (b.type) {
165
+ case 'mm':
166
+ return new nodes.Unit(b.val / 10, 'cm');
167
+ case 'in':
168
+ return new nodes.Unit(b.val * 2.54, 'cm');
169
+ }
170
+ case 'in':
171
+ switch (b.type) {
172
+ case 'mm':
173
+ return new nodes.Unit(b.val / 25.4, 'in');
174
+ case 'cm':
175
+ return new nodes.Unit(b.val / 2.54, 'in');
176
+ }
177
+ case 'ms':
178
+ switch (b.type) {
179
+ case 's':
180
+ return new nodes.Unit(b.val * 1000, 'ms');
181
+ }
182
+ case 's':
183
+ switch (b.type) {
184
+ case 'ms':
185
+ return new nodes.Unit(b.val / 1000, 's');
186
+ }
187
+ case 'Hz':
188
+ switch (b.type) {
189
+ case 'kHz':
190
+ return new nodes.Unit(b.val * 1000, 'Hz');
191
+ }
192
+ case 'kHz':
193
+ switch (b.type) {
194
+ case 'Hz':
195
+ return new nodes.Unit(b.val / 1000, 'kHz');
196
+ }
197
+ default:
198
+ return new nodes.Unit(b.val, a.type);
199
+ }
200
+ } else if ('string' == other.nodeName) {
201
+ var val = parseInt(other.val, 10);
202
+ if (isNaN(val)) Node.prototype.coerce.call(this, other);
203
+ return new nodes.Unit(val);
204
+ } else {
205
+ return Node.prototype.coerce.call(this, other);
206
+ }
207
+ };