stylus-source 0.15.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/README.md +3 -0
- data/lib/.DS_Store +0 -0
- data/lib/node_modules/cssom/.idea/CSSOM.iml +9 -0
- data/lib/node_modules/cssom/.idea/dictionaries/nv.xml +3 -0
- data/lib/node_modules/cssom/.idea/encodings.xml +5 -0
- data/lib/node_modules/cssom/.idea/misc.xml +17 -0
- data/lib/node_modules/cssom/.idea/modules.xml +9 -0
- data/lib/node_modules/cssom/.idea/projectCodeStyle.xml +82 -0
- data/lib/node_modules/cssom/.idea/vcs.xml +8 -0
- data/lib/node_modules/cssom/.idea/workspace.xml +467 -0
- data/lib/node_modules/cssom/.livereload +19 -0
- data/lib/node_modules/cssom/Jakefile +37 -0
- data/lib/node_modules/cssom/README.mdown +33 -0
- data/lib/node_modules/cssom/Rakefile +23 -0
- data/lib/node_modules/cssom/docs/.livereload +19 -0
- data/lib/node_modules/cssom/docs/bar.css +3 -0
- data/lib/node_modules/cssom/docs/demo.css +0 -0
- data/lib/node_modules/cssom/docs/foo.css +4 -0
- data/lib/node_modules/cssom/docs/parse.html +170 -0
- data/lib/node_modules/cssom/docs/parse2.html +431 -0
- data/lib/node_modules/cssom/index.html +100 -0
- data/lib/node_modules/cssom/lib/CSSImportRule.js +34 -0
- data/lib/node_modules/cssom/lib/CSSMediaRule.js +38 -0
- data/lib/node_modules/cssom/lib/CSSOM.js +3 -0
- data/lib/node_modules/cssom/lib/CSSRule.js +38 -0
- data/lib/node_modules/cssom/lib/CSSStyleDeclaration.js +130 -0
- data/lib/node_modules/cssom/lib/CSSStyleRule.js +187 -0
- data/lib/node_modules/cssom/lib/CSSStyleSheet.js +85 -0
- data/lib/node_modules/cssom/lib/MediaList.js +61 -0
- data/lib/node_modules/cssom/lib/StyleSheet.js +15 -0
- data/lib/node_modules/cssom/lib/clone.js +69 -0
- data/lib/node_modules/cssom/lib/index.js +10 -0
- data/lib/node_modules/cssom/lib/parse.js +195 -0
- data/lib/node_modules/cssom/media.html +17 -0
- data/lib/node_modules/cssom/package.json +30 -0
- data/lib/node_modules/cssom/plugins/toHTML.js +32 -0
- data/lib/node_modules/cssom/server/index.html +22 -0
- data/lib/node_modules/cssom/server/index.js +21 -0
- data/lib/node_modules/cssom/shorthands.html +21 -0
- data/lib/node_modules/cssom/test/CSSStyleDeclaration.test.js +35 -0
- data/lib/node_modules/cssom/test/CSSStyleRule.test.js +12 -0
- data/lib/node_modules/cssom/test/CSSStyleSheet.test.js +16 -0
- data/lib/node_modules/cssom/test/MediaList.test.js +21 -0
- data/lib/node_modules/cssom/test/clone.test.js +38 -0
- data/lib/node_modules/cssom/test/fixtures/dummy.css +3 -0
- data/lib/node_modules/cssom/test/helper.js +97 -0
- data/lib/node_modules/cssom/test/index.html +42 -0
- data/lib/node_modules/cssom/test/parse.test.js +346 -0
- data/lib/node_modules/cssom/test/vendor/qunit.css +189 -0
- data/lib/node_modules/cssom/test/vendor/qunit.js +1341 -0
- data/lib/node_modules/growl/History.md +16 -0
- data/lib/node_modules/growl/Readme.md +74 -0
- data/lib/node_modules/growl/lib/growl.js +82 -0
- data/lib/node_modules/growl/package.json +6 -0
- data/lib/node_modules/growl/test.js +17 -0
- data/lib/stylus/colors.js +156 -0
- data/lib/stylus/convert/css.js +130 -0
- data/lib/stylus/errors.js +58 -0
- data/lib/stylus/functions/image.js +120 -0
- data/lib/stylus/functions/index.js +722 -0
- data/lib/stylus/functions/index.styl +123 -0
- data/lib/stylus/functions/url.js +98 -0
- data/lib/stylus/lexer.js +728 -0
- data/lib/stylus/middleware.js +223 -0
- data/lib/stylus/nodes/arguments.js +65 -0
- data/lib/stylus/nodes/binop.js +54 -0
- data/lib/stylus/nodes/block.js +99 -0
- data/lib/stylus/nodes/boolean.js +103 -0
- data/lib/stylus/nodes/call.js +57 -0
- data/lib/stylus/nodes/charset.js +42 -0
- data/lib/stylus/nodes/comment.js +32 -0
- data/lib/stylus/nodes/each.js +56 -0
- data/lib/stylus/nodes/expression.js +168 -0
- data/lib/stylus/nodes/fontface.js +55 -0
- data/lib/stylus/nodes/function.js +104 -0
- data/lib/stylus/nodes/group.js +79 -0
- data/lib/stylus/nodes/hsla.js +256 -0
- data/lib/stylus/nodes/ident.js +127 -0
- data/lib/stylus/nodes/if.js +55 -0
- data/lib/stylus/nodes/import.js +30 -0
- data/lib/stylus/nodes/index.js +52 -0
- data/lib/stylus/nodes/jsliteral.js +32 -0
- data/lib/stylus/nodes/keyframes.js +78 -0
- data/lib/stylus/nodes/literal.js +92 -0
- data/lib/stylus/nodes/media.js +42 -0
- data/lib/stylus/nodes/node.js +209 -0
- data/lib/stylus/nodes/null.js +72 -0
- data/lib/stylus/nodes/page.js +43 -0
- data/lib/stylus/nodes/params.js +72 -0
- data/lib/stylus/nodes/property.js +72 -0
- data/lib/stylus/nodes/return.js +44 -0
- data/lib/stylus/nodes/rgba.js +335 -0
- data/lib/stylus/nodes/root.js +50 -0
- data/lib/stylus/nodes/selector.js +57 -0
- data/lib/stylus/nodes/string.js +120 -0
- data/lib/stylus/nodes/ternary.js +51 -0
- data/lib/stylus/nodes/unaryop.js +46 -0
- data/lib/stylus/nodes/unit.js +207 -0
- data/lib/stylus/parser.js +1514 -0
- data/lib/stylus/renderer.js +157 -0
- data/lib/stylus/source.rb +7 -0
- data/lib/stylus/stack/frame.js +66 -0
- data/lib/stylus/stack/index.js +146 -0
- data/lib/stylus/stack/scope.js +53 -0
- data/lib/stylus/stylus.js +102 -0
- data/lib/stylus/token.js +53 -0
- data/lib/stylus/utils.js +237 -0
- data/lib/stylus/visitor/compiler.js +472 -0
- data/lib/stylus/visitor/evaluator.js +1070 -0
- data/lib/stylus/visitor/index.js +31 -0
- data/stylus-source.gemspec +15 -0
- metadata +158 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
|
2
|
+
/*!
|
3
|
+
* Stylus - Group
|
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 `Group`.
|
16
|
+
*
|
17
|
+
* @api public
|
18
|
+
*/
|
19
|
+
|
20
|
+
var Group = module.exports = function Group(){
|
21
|
+
Node.call(this);
|
22
|
+
this.nodes = [];
|
23
|
+
};
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Inherit from `Node.prototype`.
|
27
|
+
*/
|
28
|
+
|
29
|
+
Group.prototype.__proto__ = Node.prototype;
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Push the given `selector` node.
|
33
|
+
*
|
34
|
+
* @param {Selector} selector
|
35
|
+
* @api public
|
36
|
+
*/
|
37
|
+
|
38
|
+
Group.prototype.push = function(selector){
|
39
|
+
this.nodes.push(selector);
|
40
|
+
};
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Return this set's `Block`.
|
44
|
+
*/
|
45
|
+
|
46
|
+
Group.prototype.__defineGetter__('block', function(){
|
47
|
+
return this.nodes[0].block;
|
48
|
+
});
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Assign `block` to each selector in this set.
|
52
|
+
*
|
53
|
+
* @param {Block} block
|
54
|
+
* @api public
|
55
|
+
*/
|
56
|
+
|
57
|
+
Group.prototype.__defineSetter__('block', function(block){
|
58
|
+
for (var i = 0, len = this.nodes.length; i < len; ++i) {
|
59
|
+
this.nodes[i].block = block;
|
60
|
+
}
|
61
|
+
});
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Return a clone of this node.
|
65
|
+
*
|
66
|
+
* @return {Node}
|
67
|
+
* @api public
|
68
|
+
*/
|
69
|
+
|
70
|
+
Group.prototype.clone = function(){
|
71
|
+
var clone = new Group;
|
72
|
+
clone.lineno = this.lineno;
|
73
|
+
this.nodes.forEach(function(node){
|
74
|
+
clone.push(node.clone());
|
75
|
+
});
|
76
|
+
clone.filename = this.filename;
|
77
|
+
clone.block = this.block.clone();
|
78
|
+
return clone;
|
79
|
+
};
|
@@ -0,0 +1,256 @@
|
|
1
|
+
|
2
|
+
/*!
|
3
|
+
* Stylus - HSLA
|
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 `HSLA` with the given h,s,l,a component values.
|
17
|
+
*
|
18
|
+
* @param {Number} h
|
19
|
+
* @param {Number} s
|
20
|
+
* @param {Number} l
|
21
|
+
* @param {Number} a
|
22
|
+
* @api public
|
23
|
+
*/
|
24
|
+
|
25
|
+
var HSLA = exports = module.exports = function HSLA(h,s,l,a){
|
26
|
+
Node.call(this);
|
27
|
+
this.h = clampDegrees(h);
|
28
|
+
this.s = clampPercentage(s);
|
29
|
+
this.l = clampPercentage(l);
|
30
|
+
this.a = clampAlpha(a);
|
31
|
+
this.hsla = this;
|
32
|
+
};
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Inherit from `Node.prototype`.
|
36
|
+
*/
|
37
|
+
|
38
|
+
HSLA.prototype.__proto__ = Node.prototype;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Return hsla(n,n,n,n).
|
42
|
+
*
|
43
|
+
* @return {String}
|
44
|
+
* @api public
|
45
|
+
*/
|
46
|
+
|
47
|
+
HSLA.prototype.toString = function(){
|
48
|
+
return 'hsla('
|
49
|
+
+ this.h + ','
|
50
|
+
+ this.s.toFixed(0) + ','
|
51
|
+
+ this.l.toFixed(0) + ','
|
52
|
+
+ this.a + ')';
|
53
|
+
};
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Return a clone of this node.
|
57
|
+
*
|
58
|
+
* @return {Node}
|
59
|
+
* @api public
|
60
|
+
*/
|
61
|
+
|
62
|
+
HSLA.prototype.clone = function(){
|
63
|
+
var clone = new HSLA(
|
64
|
+
this.h
|
65
|
+
, this.s
|
66
|
+
, this.l
|
67
|
+
, this.a);
|
68
|
+
clone.lineno = this.lineno;
|
69
|
+
clone.filename = this.filename;
|
70
|
+
return clone;
|
71
|
+
};
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Return rgba `RGBA` representation.
|
75
|
+
*
|
76
|
+
* @return {RGBA}
|
77
|
+
* @api public
|
78
|
+
*/
|
79
|
+
|
80
|
+
HSLA.prototype.__defineGetter__('rgba', function(){
|
81
|
+
return nodes.RGBA.fromHSLA(this);
|
82
|
+
});
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Return hash.
|
86
|
+
*
|
87
|
+
* @return {String}
|
88
|
+
* @api public
|
89
|
+
*/
|
90
|
+
|
91
|
+
HSLA.prototype.__defineGetter__('hash', function(){
|
92
|
+
return this.rgba.toString();
|
93
|
+
});
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Add h,s,l to the current component values.
|
97
|
+
*
|
98
|
+
* @param {Number} h
|
99
|
+
* @param {Number} s
|
100
|
+
* @param {Number} l
|
101
|
+
* @return {HSLA} new node
|
102
|
+
* @api public
|
103
|
+
*/
|
104
|
+
|
105
|
+
HSLA.prototype.add = function(h,s,l){
|
106
|
+
return new HSLA(
|
107
|
+
this.h + h
|
108
|
+
, this.s + s
|
109
|
+
, this.l + l
|
110
|
+
, this.a);
|
111
|
+
};
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Subtract h,s,l from the current component values.
|
115
|
+
*
|
116
|
+
* @param {Number} h
|
117
|
+
* @param {Number} s
|
118
|
+
* @param {Number} l
|
119
|
+
* @return {HSLA} new node
|
120
|
+
* @api public
|
121
|
+
*/
|
122
|
+
|
123
|
+
HSLA.prototype.sub = function(h,s,l){
|
124
|
+
return this.add(-h, -s, -l);
|
125
|
+
};
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Operate on `right` with the given `op`.
|
129
|
+
*
|
130
|
+
* @param {String} op
|
131
|
+
* @param {Node} right
|
132
|
+
* @return {Node}
|
133
|
+
* @api public
|
134
|
+
*/
|
135
|
+
|
136
|
+
HSLA.prototype.operate = function(op, right){
|
137
|
+
switch (op) {
|
138
|
+
case '==':
|
139
|
+
case '!=':
|
140
|
+
case '<=':
|
141
|
+
case '>=':
|
142
|
+
case '<':
|
143
|
+
case '>':
|
144
|
+
case 'is a':
|
145
|
+
case '||':
|
146
|
+
case '&&':
|
147
|
+
return this.rgba.operate(op, right);
|
148
|
+
default:
|
149
|
+
return this.rgba.operate(op, right).hsla;
|
150
|
+
}
|
151
|
+
};
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Return `HSLA` representation of the given `color`.
|
155
|
+
*
|
156
|
+
* @param {RGBA} color
|
157
|
+
* @return {HSLA}
|
158
|
+
* @api public
|
159
|
+
*/
|
160
|
+
|
161
|
+
exports.fromRGBA = function(rgba){
|
162
|
+
var r = rgba.r / 255
|
163
|
+
, g = rgba.g / 255
|
164
|
+
, b = rgba.b / 255
|
165
|
+
, a = rgba.a;
|
166
|
+
|
167
|
+
var min = Math.min(r,g,b)
|
168
|
+
, max = Math.max(r,g,b)
|
169
|
+
, l = (max + min) / 2
|
170
|
+
, d = max - min
|
171
|
+
, h, s;
|
172
|
+
|
173
|
+
switch (max) {
|
174
|
+
case min: h = 0; break;
|
175
|
+
case r: h = 60 * (g-b) / d; break;
|
176
|
+
case g: h = 60 * (b-r) / d + 120; break;
|
177
|
+
case b: h = 60 * (r-g) / d + 240; break;
|
178
|
+
}
|
179
|
+
|
180
|
+
if (max == min) {
|
181
|
+
s = 0;
|
182
|
+
} else if (l < .5) {
|
183
|
+
s = d / (2 * l);
|
184
|
+
} else {
|
185
|
+
s = d / (2 - 2 * l);
|
186
|
+
}
|
187
|
+
|
188
|
+
h %= 360;
|
189
|
+
s *= 100;
|
190
|
+
l *= 100;
|
191
|
+
|
192
|
+
return new HSLA(h,s,l,a);
|
193
|
+
};
|
194
|
+
|
195
|
+
/**
|
196
|
+
* Adjust lightness by `percent`.
|
197
|
+
*
|
198
|
+
* @param {Number} percent
|
199
|
+
* @return {HSLA} for chaining
|
200
|
+
* @api public
|
201
|
+
*/
|
202
|
+
|
203
|
+
HSLA.prototype.adjustLightness = function(percent){
|
204
|
+
this.l = clampPercentage(this.l + this.l * (percent / 100));
|
205
|
+
return this;
|
206
|
+
};
|
207
|
+
|
208
|
+
/**
|
209
|
+
* Adjust hue by `deg`.
|
210
|
+
*
|
211
|
+
* @param {Number} deg
|
212
|
+
* @return {HSLA} for chaining
|
213
|
+
* @api public
|
214
|
+
*/
|
215
|
+
|
216
|
+
HSLA.prototype.adjustHue = function(deg){
|
217
|
+
this.h = clampDegrees(this.h + deg);
|
218
|
+
return this;
|
219
|
+
};
|
220
|
+
|
221
|
+
/**
|
222
|
+
* Clamp degree `n` >= 0 and <= 360.
|
223
|
+
*
|
224
|
+
* @param {Number} n
|
225
|
+
* @return {Number}
|
226
|
+
* @api private
|
227
|
+
*/
|
228
|
+
|
229
|
+
function clampDegrees(n) {
|
230
|
+
n = n % 360;
|
231
|
+
return n >= 0 ? n : 360 + n;
|
232
|
+
}
|
233
|
+
|
234
|
+
/**
|
235
|
+
* Clamp percentage `n` >= 0 and <= 100.
|
236
|
+
*
|
237
|
+
* @param {Number} n
|
238
|
+
* @return {Number}
|
239
|
+
* @api private
|
240
|
+
*/
|
241
|
+
|
242
|
+
function clampPercentage(n) {
|
243
|
+
return Math.max(0, Math.min(n, 100));
|
244
|
+
}
|
245
|
+
|
246
|
+
/**
|
247
|
+
* Clamp alpha `n` >= 0 and <= 1.
|
248
|
+
*
|
249
|
+
* @param {Number} n
|
250
|
+
* @return {Number}
|
251
|
+
* @api private
|
252
|
+
*/
|
253
|
+
|
254
|
+
function clampAlpha(n) {
|
255
|
+
return Math.max(0, Math.min(n, 1));
|
256
|
+
}
|
@@ -0,0 +1,127 @@
|
|
1
|
+
|
2
|
+
/*!
|
3
|
+
* Stylus - Ident
|
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 `Ident` by `name` with the given `val` node.
|
17
|
+
*
|
18
|
+
* @param {String} name
|
19
|
+
* @param {Node} val
|
20
|
+
* @api public
|
21
|
+
*/
|
22
|
+
|
23
|
+
var Ident = module.exports = function Ident(name, val){
|
24
|
+
Node.call(this);
|
25
|
+
this.name = name;
|
26
|
+
this.string = name;
|
27
|
+
this.val = val || nodes.null;
|
28
|
+
};
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Check if the variable has a value.
|
32
|
+
*
|
33
|
+
* @return {Boolean}
|
34
|
+
* @api public
|
35
|
+
*/
|
36
|
+
|
37
|
+
Ident.prototype.__defineGetter__('isEmpty', function(){
|
38
|
+
return undefined == this.val;
|
39
|
+
});
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Return hash.
|
43
|
+
*
|
44
|
+
* @return {String}
|
45
|
+
* @api public
|
46
|
+
*/
|
47
|
+
|
48
|
+
Ident.prototype.__defineGetter__('hash', function(){
|
49
|
+
return this.name;
|
50
|
+
});
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Inherit from `Node.prototype`.
|
54
|
+
*/
|
55
|
+
|
56
|
+
Ident.prototype.__proto__ = Node.prototype;
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Return a clone of this node.
|
60
|
+
*
|
61
|
+
* @return {Node}
|
62
|
+
* @api public
|
63
|
+
*/
|
64
|
+
|
65
|
+
Ident.prototype.clone = function(){
|
66
|
+
var clone = new Ident(this.name, this.val.clone());
|
67
|
+
clone.lineno = this.lineno;
|
68
|
+
clone.filename = this.filename;
|
69
|
+
clone.property = this.property;
|
70
|
+
return clone;
|
71
|
+
};
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Return <name>.
|
75
|
+
*
|
76
|
+
* @return {String}
|
77
|
+
* @api public
|
78
|
+
*/
|
79
|
+
|
80
|
+
Ident.prototype.toString = function(){
|
81
|
+
return this.name;
|
82
|
+
};
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Coerce `other` to an ident.
|
86
|
+
*
|
87
|
+
* @param {Node} other
|
88
|
+
* @return {String}
|
89
|
+
* @api public
|
90
|
+
*/
|
91
|
+
|
92
|
+
Ident.prototype.coerce = function(other){
|
93
|
+
switch (other.nodeName) {
|
94
|
+
case 'ident':
|
95
|
+
case 'string':
|
96
|
+
case 'literal':
|
97
|
+
return new Ident(other.string);
|
98
|
+
default:
|
99
|
+
return Node.prototype.coerce.call(this, other);
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Operate on `right` with the given `op`.
|
105
|
+
*
|
106
|
+
* @param {String} op
|
107
|
+
* @param {Node} right
|
108
|
+
* @return {Node}
|
109
|
+
* @api public
|
110
|
+
*/
|
111
|
+
|
112
|
+
Ident.prototype.operate = function(op, right){
|
113
|
+
var val = right.first;
|
114
|
+
switch (op) {
|
115
|
+
case '-':
|
116
|
+
if ('unit' == val.nodeName) {
|
117
|
+
var expr = new nodes.Expression;
|
118
|
+
val.val = -val.val;
|
119
|
+
expr.push(this);
|
120
|
+
expr.push(val);
|
121
|
+
return expr;
|
122
|
+
}
|
123
|
+
case '+':
|
124
|
+
return new nodes.Ident(this.string + this.coerce(val).string);
|
125
|
+
}
|
126
|
+
return Node.prototype.operate.call(this, op, right);
|
127
|
+
};
|