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,157 @@
1
+
2
+ /*!
3
+ * Stylus - Renderer
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Parser = require('./parser')
13
+ , Compiler = require('./visitor/compiler')
14
+ , Evaluator = require('./visitor/evaluator')
15
+ , utils = require('./utils')
16
+ , nodes = require('./nodes')
17
+ , path = require('path')
18
+ , join = path.join;
19
+
20
+ /**
21
+ * Initialize a new `Renderer` with the given `str` and `options`.
22
+ *
23
+ * @param {String} str
24
+ * @param {Object} options
25
+ * @api public
26
+ */
27
+
28
+ var Renderer = module.exports = function Renderer(str, options) {
29
+ options = options || {};
30
+ options.globals = {};
31
+ options.functions = {};
32
+ options.imports = [join(__dirname, 'functions')];
33
+ options.paths = options.paths || [];
34
+ options.filename = options.filename || 'stylus';
35
+ this.options = options;
36
+ this.str = str;
37
+ };
38
+
39
+ /**
40
+ * Parse and evaluate AST, then callback `fn(err, css, js)`.
41
+ *
42
+ * @param {Function} fn
43
+ * @api public
44
+ */
45
+
46
+ Renderer.prototype.render = function(fn){
47
+ var parser = this.parser = new Parser(this.str, this.options);
48
+ try {
49
+ nodes.filename = this.options.filename;
50
+ var ast = parser.parse();
51
+ this.evaluator = new Evaluator(ast, this.options);
52
+ ast = this.evaluator.evaluate();
53
+ var compiler = new Compiler(ast, this.options)
54
+ , css = compiler.compile()
55
+ , js = compiler.js;
56
+ fn(null, css, js);
57
+ } catch (err) {
58
+ var options = {};
59
+ options.input = err.input || this.str;
60
+ options.filename = err.filename || this.options.filename;
61
+ options.lineno = err.lineno || parser.lexer.lineno;
62
+ fn(utils.formatException(err, options));
63
+ }
64
+ };
65
+
66
+ /**
67
+ * Set option `key` to `val`.
68
+ *
69
+ * @param {String} key
70
+ * @param {Mixed} val
71
+ * @return {Renderer} for chaining
72
+ * @api public
73
+ */
74
+
75
+ Renderer.prototype.set = function(key, val){
76
+ this.options[key] = val;
77
+ return this;
78
+ };
79
+
80
+ /**
81
+ * Get option `key`.
82
+ *
83
+ * @param {String} key
84
+ * @return {Mixed} val
85
+ * @api public
86
+ */
87
+
88
+ Renderer.prototype.get = function(key){
89
+ return this.options[key];
90
+ };
91
+
92
+ /**
93
+ * Include the given `path` to the lookup paths array.
94
+ *
95
+ * @param {String} path
96
+ * @return {Renderer} for chaining
97
+ * @api public
98
+ */
99
+
100
+ Renderer.prototype.include = function(path){
101
+ this.options.paths.push(path);
102
+ return this;
103
+ };
104
+
105
+ /**
106
+ * Use the given `fn`.
107
+ *
108
+ * This allows for plugins to alter the renderer in
109
+ * any way they wish, exposing paths etc.
110
+ *
111
+ * @param {Function}
112
+ * @return {Renderer} for chaining
113
+ * @api public
114
+ */
115
+
116
+ Renderer.prototype.use = function(fn){
117
+ fn.call(this, this);
118
+ return this;
119
+ };
120
+
121
+ /**
122
+ * Define function or global var with the given `name`. Optionally
123
+ * the function may accept full expressions, by setting `raw`
124
+ * to `true`.
125
+ *
126
+ * @param {String} name
127
+ * @param {Function|Node} fn
128
+ * @return {Renderer} for chaining
129
+ * @api public
130
+ */
131
+
132
+ Renderer.prototype.define = function(name, fn, raw){
133
+ if (fn.nodeName) {
134
+ this.options.globals[name] = fn;
135
+ return this;
136
+ }
137
+
138
+ // function
139
+ this.options.functions[name] = fn;
140
+ if (undefined != raw) fn.raw = raw;
141
+ return this;
142
+ };
143
+
144
+ /**
145
+ * Import the given `file`.
146
+ *
147
+ * @param {String} file
148
+ * @return {Renderer} for chaining
149
+ * @api public
150
+ */
151
+
152
+ Renderer.prototype.import = function(file){
153
+ this.options.imports.push(file);
154
+ return this;
155
+ };
156
+
157
+
@@ -0,0 +1,7 @@
1
+ module Stylus
2
+ module Source
3
+ def self.bundled_path
4
+ File.expand_path("../stylus.js", __FILE__)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,66 @@
1
+
2
+ /*!
3
+ * Stylus - stack - Frame
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Scope = require('./scope')
13
+ , blocks = require('../nodes');
14
+
15
+ /**
16
+ * Initialize a new `Frame` with the given `block`.
17
+ *
18
+ * @param {Block} block
19
+ * @api private
20
+ */
21
+
22
+ var Frame = module.exports = function Frame(block) {
23
+ this._scope = false === block.scope
24
+ ? null
25
+ : new Scope;
26
+ this.block = block;
27
+ };
28
+
29
+ /**
30
+ * Return this frame's scope or the parent scope
31
+ * for scope-less blocks.
32
+ *
33
+ * @return {Scope}
34
+ * @api public
35
+ */
36
+
37
+ Frame.prototype.__defineGetter__('scope', function(){
38
+ return this._scope || this.parent.scope;
39
+ });
40
+
41
+ /**
42
+ * Lookup the given local variable `name`.
43
+ *
44
+ * @param {String} name
45
+ * @return {Node}
46
+ * @api private
47
+ */
48
+
49
+ Frame.prototype.lookup = function(name){
50
+ return this.scope.lookup(name)
51
+ };
52
+
53
+ /**
54
+ * Custom inspect.
55
+ *
56
+ * @return {String}
57
+ * @api public
58
+ */
59
+
60
+ Frame.prototype.inspect = function(){
61
+ return '[Frame '
62
+ + (false === this.block.scope
63
+ ? 'scope-less'
64
+ : this.scope.inspect())
65
+ + ']';
66
+ };
@@ -0,0 +1,146 @@
1
+
2
+ /*!
3
+ * Stylus - Stack
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Frame = require('./frame');
13
+
14
+ /**
15
+ * Initialize a new `Stack`.
16
+ *
17
+ * @api private
18
+ */
19
+
20
+ var Stack = module.exports = function Stack() {
21
+ Array.apply(this, arguments);
22
+ };
23
+
24
+ /**
25
+ * Inherit from `Array.prototype`.
26
+ */
27
+
28
+ Stack.prototype.__proto__ = Array.prototype;
29
+
30
+ /**
31
+ * Push the given `frame`.
32
+ *
33
+ * @param {Frame} frame
34
+ * @api public
35
+ */
36
+
37
+ Stack.prototype.push = function(frame){
38
+ frame.stack = this;
39
+ frame.parent = this.currentFrame;
40
+ return [].push.apply(this, arguments);
41
+ };
42
+
43
+ /**
44
+ * Return the current stack `Frame`.
45
+ *
46
+ * @return {Frame}
47
+ * @api private
48
+ */
49
+
50
+ Stack.prototype.__defineGetter__('currentFrame', function(){
51
+ return this[this.length - 1];
52
+ });
53
+
54
+ /**
55
+ * Lookup stack frame for the given `block`.
56
+ *
57
+ * @param {Block} block
58
+ * @return {Frame}
59
+ * @api private
60
+ */
61
+
62
+ Stack.prototype.getBlockFrame = function(block){
63
+ for (var i = 0; i < this.length; ++i) {
64
+ if (block == this[i].block) {
65
+ return this[i];
66
+ }
67
+ }
68
+ };
69
+
70
+ /**
71
+ * Lookup the given local variable `name`, relative
72
+ * to the lexical scope of the current frame's `Block`.
73
+ *
74
+ * When the result of a lookup is an identifier
75
+ * a recursive lookup is performed, defaulting to
76
+ * returning the identifier itself.
77
+ *
78
+ * @param {String} name
79
+ * @return {Node}
80
+ * @api private
81
+ */
82
+
83
+ Stack.prototype.lookup = function(name){
84
+ var block = this.currentFrame.block
85
+ , val
86
+ , ret;
87
+
88
+ do {
89
+ var frame = this.getBlockFrame(block);
90
+ if (frame && (val = frame.lookup(name))) {
91
+ switch (val.first.nodeName) {
92
+ case 'ident':
93
+ return this.lookup(val.first.name) || val;
94
+ default:
95
+ return val;
96
+ }
97
+ }
98
+ } while (block = block.parent);
99
+ };
100
+
101
+ /**
102
+ * Custom inspect.
103
+ *
104
+ * @return {String}
105
+ * @api private
106
+ */
107
+
108
+ Stack.prototype.inspect = function(){
109
+ return this.reverse().map(function(frame){
110
+ return frame.inspect();
111
+ }).join('\n');
112
+ };
113
+
114
+ /**
115
+ * Return stack string formatted as:
116
+ *
117
+ * at <context> (<filename>:<lineno>)
118
+ *
119
+ * @return {String}
120
+ * @api private
121
+ */
122
+
123
+ Stack.prototype.toString = function(){
124
+ var block
125
+ , node
126
+ , buf = []
127
+ , location
128
+ , len = this.length;
129
+
130
+ while (len--) {
131
+ block = this[len].block;
132
+ if (node = block.node) {
133
+ location = '(' + node.filename + ':' + (node.lineno + 1) + ')';
134
+ switch (node.nodeName) {
135
+ case 'function':
136
+ buf.push(' at ' + node.name + '() ' + location);
137
+ break;
138
+ case 'group':
139
+ buf.push(' at "' + node.nodes[0].val + '" ' + location);
140
+ break;
141
+ }
142
+ }
143
+ }
144
+
145
+ return buf.join('\n');
146
+ };
@@ -0,0 +1,53 @@
1
+
2
+ /*!
3
+ * Stylus - stack - Scope
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Initialize a new `Scope`.
10
+ *
11
+ * @api private
12
+ */
13
+
14
+ var Scope = module.exports = function Scope() {
15
+ this.locals = {};
16
+ };
17
+
18
+ /**
19
+ * Add `ident` node to the current scope.
20
+ *
21
+ * @param {Ident} ident
22
+ * @api private
23
+ */
24
+
25
+ Scope.prototype.add = function(ident){
26
+ this.locals[ident.name] = ident.val;
27
+ };
28
+
29
+ /**
30
+ * Lookup the given local variable `name`.
31
+ *
32
+ * @param {String} name
33
+ * @return {Node}
34
+ * @api private
35
+ */
36
+
37
+ Scope.prototype.lookup = function(name){
38
+ return this.locals[name];
39
+ };
40
+
41
+ /**
42
+ * Custom inspect.
43
+ *
44
+ * @return {String}
45
+ * @api public
46
+ */
47
+
48
+ Scope.prototype.inspect = function(){
49
+ var keys = Object.keys(this.locals).map(function(key){ return '@' + key; });
50
+ return '[Scope'
51
+ + (keys.length ? ' ' + keys.join(', ') : '')
52
+ + ']';
53
+ };
@@ -0,0 +1,102 @@
1
+
2
+ /*!
3
+ * Stylus
4
+ * Copyright(c) 2010 LearnBoost <dev@learnboost.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * Module dependencies.
10
+ */
11
+
12
+ var Renderer = require('./renderer')
13
+ , Parser = require('./parser')
14
+ , nodes = require('./nodes')
15
+ , utils = require('./utils');
16
+
17
+ /**
18
+ * Export render as the module.
19
+ */
20
+
21
+ exports = module.exports = render;
22
+
23
+ /**
24
+ * Library version.
25
+ */
26
+
27
+ exports.version = '0.15.4';
28
+
29
+ /**
30
+ * Expose nodes.
31
+ */
32
+
33
+ exports.nodes = nodes;
34
+
35
+ /**
36
+ * Expose BIFs.
37
+ */
38
+
39
+ exports.functions = require('./functions');
40
+
41
+ /**
42
+ * Expose utils.
43
+ */
44
+
45
+ exports.utils = require('./utils');
46
+
47
+ /**
48
+ * Expose middleware.
49
+ */
50
+
51
+ exports.middleware = require('./middleware');
52
+
53
+ /**
54
+ * Expose constructors.
55
+ */
56
+
57
+ exports.Visitor = require('./visitor');
58
+ exports.Parser = require('./parser');
59
+ exports.Evaluator = require('./visitor/evaluator');
60
+
61
+ /**
62
+ * Convert the given `css` to `stylus` source.
63
+ *
64
+ * @param {String} css
65
+ * @return {String}
66
+ * @api public
67
+ */
68
+
69
+ exports.convertCSS = require('./convert/css');
70
+
71
+ /**
72
+ * Render the given `str` with `options` and callback `fn(err, css)`.
73
+ *
74
+ * @param {String} str
75
+ * @param {Object|Function} options
76
+ * @param {Function} fn
77
+ * @api public
78
+ */
79
+
80
+ exports.render = function(str, options, fn){
81
+ if ('function' == typeof options) fn = options, options = {};
82
+ new Renderer(str, options).render(fn);
83
+ };
84
+
85
+ /**
86
+ * Return a new `Renderer` for the given `str` and `options`.
87
+ *
88
+ * @param {String} str
89
+ * @param {Object} options
90
+ * @return {Renderer}
91
+ * @api public
92
+ */
93
+
94
+ function render(str, options) {
95
+ return new Renderer(str, options);
96
+ }
97
+
98
+ /**
99
+ * Expose optional functions.
100
+ */
101
+
102
+ exports.url = require('./functions/url');