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,55 @@
1
+
2
+ /*!
3
+ * Stylus - If
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 `If` with the given `cond`.
16
+ *
17
+ * @param {Expression} cond
18
+ * @param {Boolean|Block} negate, block
19
+ * @api public
20
+ */
21
+
22
+ var If = module.exports = function If(cond, negate){
23
+ Node.call(this);
24
+ this.cond = cond;
25
+ this.elses = [];
26
+ if (negate && negate.nodeName) {
27
+ this.block = negate;
28
+ } else {
29
+ this.negate = negate;
30
+ }
31
+ };
32
+
33
+ /**
34
+ * Inherit from `Node.prototype`.
35
+ */
36
+
37
+ If.prototype.__proto__ = Node.prototype;
38
+
39
+ /**
40
+ * Return a clone of this node.
41
+ *
42
+ * @return {Node}
43
+ * @api public
44
+ */
45
+
46
+ If.prototype.clone = function(){
47
+ var cond = this.cond.clone()
48
+ , block = this.block.clone();
49
+ var clone = new If(cond, block);
50
+ clone.elses = this.elses.map(function(node){ return node.clone(); });
51
+ clone.negate = this.negate;
52
+ clone.lineno = this.lineno;
53
+ clone.filename = this.filename;
54
+ return clone;
55
+ };
@@ -0,0 +1,30 @@
1
+
2
+ /*!
3
+ * Stylus - Import
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 `Import` with the given `expr`.
16
+ *
17
+ * @param {Expression} expr
18
+ * @api public
19
+ */
20
+
21
+ var Import = module.exports = function Import(expr){
22
+ Node.call(this);
23
+ this.path = expr;
24
+ };
25
+
26
+ /**
27
+ * Inherit from `Node.prototype`.
28
+ */
29
+
30
+ Import.prototype.__proto__ = Node.prototype;
@@ -0,0 +1,52 @@
1
+
2
+ /*!
3
+ * Stylus - nodes
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Constructors
10
+ */
11
+
12
+ exports.Node = require('./node');
13
+ exports.Root = require('./root');
14
+ exports.Null = require('./null');
15
+ exports.Each = require('./each');
16
+ exports.If = require('./if');
17
+ exports.Call = require('./call');
18
+ exports.Page = require('./page');
19
+ exports.FontFace = require('./fontface');
20
+ exports.UnaryOp = require('./unaryop');
21
+ exports.BinOp = require('./binop');
22
+ exports.Ternary = require('./ternary');
23
+ exports.Block = require('./block');
24
+ exports.Unit = require('./unit');
25
+ exports.String = require('./string');
26
+ exports.HSLA = require('./hsla');
27
+ exports.RGBA = require('./rgba');
28
+ exports.Ident = require('./ident');
29
+ exports.Group = require('./group');
30
+ exports.Literal = require('./literal');
31
+ exports.JSLiteral = require('./jsliteral');
32
+ exports.Boolean = require('./boolean');
33
+ exports.Return = require('./return');
34
+ exports.Media = require('./media');
35
+ exports.Params = require('./params');
36
+ exports.Comment = require('./comment');
37
+ exports.Keyframes = require('./keyframes');
38
+ exports.Charset = require('./charset');
39
+ exports.Import = require('./import');
40
+ exports.Function = require('./function');
41
+ exports.Property = require('./property');
42
+ exports.Selector = require('./selector');
43
+ exports.Expression = require('./expression');
44
+ exports.Arguments = require('./arguments');
45
+
46
+ /**
47
+ * Singletons.
48
+ */
49
+
50
+ exports.true = new exports.Boolean(true);
51
+ exports.false = new exports.Boolean(false);
52
+ exports.null = new exports.Null;
@@ -0,0 +1,32 @@
1
+
2
+ /*!
3
+ * Stylus - JSLiteral
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 `JSLiteral` with the given `str`.
17
+ *
18
+ * @param {String} str
19
+ * @api public
20
+ */
21
+
22
+ var JSLiteral = module.exports = function JSLiteral(str){
23
+ Node.call(this);
24
+ this.val = str;
25
+ this.string = str;
26
+ };
27
+
28
+ /**
29
+ * Inherit from `Node.prototype`.
30
+ */
31
+
32
+ JSLiteral.prototype.__proto__ = Node.prototype;
@@ -0,0 +1,78 @@
1
+
2
+ /*!
3
+ * Stylus - Keyframes
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 `Keyframes` with the given `name`,
16
+ * and optional vendor `prefix`.
17
+ *
18
+ * @param {String} name
19
+ * @param {String} prefix
20
+ * @api public
21
+ */
22
+
23
+ var Keyframes = module.exports = function Keyframes(name, prefix){
24
+ Node.call(this);
25
+ this.name = name;
26
+ this.frames = [];
27
+ this.prefix = prefix || 'official';
28
+ };
29
+
30
+ /**
31
+ * Inherit from `Node.prototype`.
32
+ */
33
+
34
+ Keyframes.prototype.__proto__ = Node.prototype;
35
+
36
+ /**
37
+ * Push the given `block` at `pos`.
38
+ *
39
+ * @param {Unit} pos
40
+ * @param {Block} block
41
+ * @api public
42
+ */
43
+
44
+ Keyframes.prototype.push = function(pos, block){
45
+ this.frames.push({
46
+ pos: pos
47
+ , block: block
48
+ });
49
+ };
50
+
51
+ /**
52
+ * Return a clone of this node.
53
+ *
54
+ * @return {Node}
55
+ * @api public
56
+ */
57
+
58
+ Keyframes.prototype.clone = function(){
59
+ var clone = new Keyframes(this.name);
60
+ clone.lineno = this.lineno;
61
+ clone.prefix = this.prefix;
62
+ clone.frames = this.frames.map(function(node){
63
+ node.block = node.block.clone();
64
+ return node;
65
+ });
66
+ return clone;
67
+ };
68
+
69
+ /**
70
+ * Return `@keyframes name`.
71
+ *
72
+ * @return {String}
73
+ * @api public
74
+ */
75
+
76
+ Keyframes.prototype.toString = function(){
77
+ return '@keyframes ' + this.name;
78
+ };
@@ -0,0 +1,92 @@
1
+
2
+ /*!
3
+ * Stylus - Literal
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 `Literal` with the given `str`.
17
+ *
18
+ * @param {String} str
19
+ * @api public
20
+ */
21
+
22
+ var Literal = module.exports = function Literal(str){
23
+ Node.call(this);
24
+ this.val = str;
25
+ this.string = str;
26
+ };
27
+
28
+ /**
29
+ * Inherit from `Node.prototype`.
30
+ */
31
+
32
+ Literal.prototype.__proto__ = Node.prototype;
33
+
34
+ /**
35
+ * Return hash.
36
+ *
37
+ * @return {String}
38
+ * @api public
39
+ */
40
+
41
+ Literal.prototype.__defineGetter__('hash', function(){
42
+ return this.val;
43
+ });
44
+
45
+ /**
46
+ * Return literal value.
47
+ *
48
+ * @return {String}
49
+ * @api public
50
+ */
51
+
52
+ Literal.prototype.toString = function(){
53
+ return this.val;
54
+ };
55
+
56
+ /**
57
+ * Coerce `other` to a literal.
58
+ *
59
+ * @param {Node} other
60
+ * @return {String}
61
+ * @api public
62
+ */
63
+
64
+ Literal.prototype.coerce = function(other){
65
+ switch (other.nodeName) {
66
+ case 'ident':
67
+ case 'string':
68
+ case 'literal':
69
+ return new Literal(other.string);
70
+ default:
71
+ return Node.prototype.coerce.call(this, other);
72
+ }
73
+ };
74
+
75
+ /**
76
+ * Operate on `right` with the given `op`.
77
+ *
78
+ * @param {String} op
79
+ * @param {Node} right
80
+ * @return {Node}
81
+ * @api public
82
+ */
83
+
84
+ Literal.prototype.operate = function(op, right){
85
+ var val = right.first;
86
+ switch (op) {
87
+ case '+':
88
+ return new nodes.Literal(this.string + this.coerce(val).string);
89
+ default:
90
+ return Node.prototype.operate.call(this, op, right);
91
+ }
92
+ };
@@ -0,0 +1,42 @@
1
+
2
+ /*!
3
+ * Stylus - Media
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 `Media` with the given `val`
17
+ *
18
+ * @param {String} val
19
+ * @api public
20
+ */
21
+
22
+ var Media = module.exports = function Media(val){
23
+ Node.call(this);
24
+ this.val = val;
25
+ };
26
+
27
+ /**
28
+ * Inherit from `Node.prototype`.
29
+ */
30
+
31
+ Media.prototype.__proto__ = Node.prototype;
32
+
33
+ /**
34
+ * Return @media "val".
35
+ *
36
+ * @return {String}
37
+ * @api public
38
+ */
39
+
40
+ Media.prototype.toString = function(){
41
+ return '@media ' + this.val;
42
+ };
@@ -0,0 +1,209 @@
1
+
2
+ /*!
3
+ * Stylus - Node
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Evaluator = require('../visitor/evaluator')
13
+ , utils = require('../utils')
14
+ , nodes = require('./');
15
+
16
+ /**
17
+ * Node constructor.
18
+ *
19
+ * @api public
20
+ */
21
+
22
+ var Node = module.exports = function Node(){
23
+ this.lineno = nodes.lineno;
24
+ Object.defineProperty(this, 'filename', { writable: true, value: nodes.filename });
25
+ };
26
+
27
+ /**
28
+ * Return this node.
29
+ *
30
+ * @return {Node}
31
+ * @api public
32
+ */
33
+
34
+ Node.prototype.__defineGetter__('first', function(){
35
+ return this;
36
+ });
37
+
38
+ /**
39
+ * Return hash.
40
+ *
41
+ * @return {String}
42
+ * @api public
43
+ */
44
+
45
+ Node.prototype.__defineGetter__('hash', function(){
46
+ return this.val;
47
+ });
48
+
49
+ /**
50
+ * Return node name.
51
+ *
52
+ * @return {String}
53
+ * @api public
54
+ */
55
+
56
+ Node.prototype.__defineGetter__('nodeName', function(){
57
+ return this.constructor.name.toLowerCase();
58
+ });
59
+
60
+ /**
61
+ * Return this node.
62
+ *
63
+ * @return {Node}
64
+ * @api public
65
+ */
66
+
67
+ Node.prototype.clone = function(){
68
+ return this;
69
+ };
70
+
71
+ /**
72
+ * Nodes by default evaluate to themselves.
73
+ *
74
+ * @return {Node}
75
+ * @api public
76
+ */
77
+
78
+ Node.prototype.eval = function(){
79
+ return new Evaluator(this).evaluate();
80
+ };
81
+
82
+ /**
83
+ * Return true.
84
+ *
85
+ * @return {Boolean}
86
+ * @api public
87
+ */
88
+
89
+ Node.prototype.toBoolean = function(){
90
+ return nodes.true;
91
+ };
92
+
93
+ /**
94
+ * Return false if `op` is generally not coerced.
95
+ *
96
+ * @param {String} op
97
+ * @return {Boolean}
98
+ * @api private
99
+ */
100
+
101
+ Node.prototype.shouldCoerce = function(op){
102
+ switch (op) {
103
+ case 'is a':
104
+ case 'in':
105
+ case '||':
106
+ case '&&':
107
+ return false;
108
+ default:
109
+ return true;
110
+ }
111
+ };
112
+
113
+ /**
114
+ * Operate on `right` with the given `op`.
115
+ *
116
+ * @param {String} op
117
+ * @param {Node} right
118
+ * @return {Node}
119
+ * @api public
120
+ */
121
+
122
+ Node.prototype.operate = function(op, right){
123
+ switch (op) {
124
+ case 'is a':
125
+ if ('string' == right.nodeName) {
126
+ return nodes.Boolean(this.nodeName == right.val);
127
+ } else {
128
+ throw new Error('"is a" expects a string, got ' + right.toString());
129
+ }
130
+ case '==':
131
+ return nodes.Boolean(this.hash == right.hash);
132
+ case '!=':
133
+ return nodes.Boolean(this.hash != right.hash);
134
+ case '>=':
135
+ return nodes.Boolean(this.hash >= right.hash);
136
+ case '<=':
137
+ return nodes.Boolean(this.hash <= right.hash);
138
+ case '>':
139
+ return nodes.Boolean(this.hash > right.hash);
140
+ case '<':
141
+ return nodes.Boolean(this.hash < right.hash);
142
+ case '||':
143
+ return this.toBoolean().isTrue
144
+ ? this
145
+ : right;
146
+ case 'in':
147
+ var vals = utils.unwrap(right).nodes
148
+ , hash = this.hash;
149
+ if (!vals) throw new Error('"in" given invalid right-hand operand, expecting an expression');
150
+ for (var i = 0, len = vals.length; i < len; ++i) {
151
+ if (hash == vals[i].hash) {
152
+ return nodes.true;
153
+ }
154
+ }
155
+ return nodes.false;
156
+ case '&&':
157
+ var a = this.toBoolean()
158
+ , b = right.toBoolean();
159
+ return a.isTrue && b.isTrue
160
+ ? right
161
+ : a.isFalse
162
+ ? this
163
+ : right;
164
+ default:
165
+ if ('[]' == op) {
166
+ var msg = 'cannot perform '
167
+ + this
168
+ + '[' + right + ']';
169
+ } else {
170
+ var msg = 'cannot perform'
171
+ + ' ' + this
172
+ + ' ' + op
173
+ + ' ' + right;
174
+ }
175
+ throw new Error(msg);
176
+ }
177
+ };
178
+
179
+ /**
180
+ * Initialize a new `CoercionError` with the given `msg`.
181
+ *
182
+ * @param {String} msg
183
+ * @api private
184
+ */
185
+
186
+ function CoercionError(msg) {
187
+ this.name = 'CoercionError'
188
+ this.message = msg
189
+ Error.captureStackTrace(this, CoercionError);
190
+ }
191
+
192
+ /**
193
+ * Inherit from `Error.prototype`.
194
+ */
195
+
196
+ CoercionError.prototype.__proto__ = Error.prototype;
197
+
198
+ /**
199
+ * Default coercion throws.
200
+ *
201
+ * @param {Node} other
202
+ * @return {Node}
203
+ * @api public
204
+ */
205
+
206
+ Node.prototype.coerce = function(other){
207
+ if (other.nodeName == this.nodeName) return other;
208
+ throw new CoercionError('cannot coerce ' + other + ' to ' + this.nodeName);
209
+ };