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,85 @@
1
+ //.CommonJS
2
+ var CSSOM = {
3
+ StyleSheet: require("./StyleSheet").StyleSheet,
4
+ CSSStyleRule: require("./CSSStyleRule").CSSStyleRule
5
+ };
6
+ ///CommonJS
7
+
8
+
9
+ /**
10
+ * @constructor
11
+ * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleSheet
12
+ */
13
+ CSSOM.CSSStyleSheet = function CSSStyleSheet() {
14
+ this.cssRules = [];
15
+ };
16
+
17
+
18
+ CSSOM.CSSStyleSheet.prototype = new CSSOM.StyleSheet;
19
+ CSSOM.CSSStyleSheet.prototype.constructor = CSSOM.CSSStyleSheet;
20
+
21
+
22
+ /**
23
+ * Used to insert a new rule into the style sheet. The new rule now becomes part of the cascade.
24
+ *
25
+ * sheet = new Sheet("body {margin: 0}")
26
+ * sheet.toString()
27
+ * -> "body{margin:0;}"
28
+ * sheet.insertRule("img {border: none}", 0)
29
+ * -> 0
30
+ * sheet.toString()
31
+ * -> "img{border:none;}body{margin:0;}"
32
+ *
33
+ * @param {string} rule
34
+ * @param {number} index
35
+ * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleSheet-insertRule
36
+ * @return {number} The index within the style sheet's rule collection of the newly inserted rule.
37
+ */
38
+ CSSOM.CSSStyleSheet.prototype.insertRule = function(rule, index) {
39
+ if (index < 0 || index > this.cssRules.length) {
40
+ throw new RangeError("INDEX_SIZE_ERR")
41
+ }
42
+ this.cssRules.splice(index, 0, CSSOM.CSSStyleRule.parse(rule));
43
+ return index
44
+ };
45
+
46
+
47
+ /**
48
+ * Used to delete a rule from the style sheet.
49
+ *
50
+ * sheet = new Sheet("img{border:none} body{margin:0}")
51
+ * sheet.toString()
52
+ * -> "img{border:none;}body{margin:0;}"
53
+ * sheet.deleteRule(0)
54
+ * sheet.toString()
55
+ * -> "body{margin:0;}"
56
+ *
57
+ * @param {number} index
58
+ * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleSheet-deleteRule
59
+ * @return {number} The index within the style sheet's rule list of the rule to remove.
60
+ */
61
+ CSSOM.CSSStyleSheet.prototype.deleteRule = function(index) {
62
+ if (index < 0 || index >= this.cssRules.length) {
63
+ throw new RangeError("INDEX_SIZE_ERR");
64
+ }
65
+ this.cssRules.splice(index, 1);
66
+ };
67
+
68
+
69
+ /**
70
+ * NON-STANDARD
71
+ * @return {string} serialize stylesheet
72
+ */
73
+ CSSOM.CSSStyleSheet.prototype.toString = function() {
74
+ var result = "";
75
+ var rules = this.cssRules;
76
+ for (var i=0; i<rules.length; i++) {
77
+ result += rules[i].cssText + "\n";
78
+ }
79
+ return result;
80
+ };
81
+
82
+
83
+ //.CommonJS
84
+ exports.CSSStyleSheet = CSSOM.CSSStyleSheet;
85
+ ///CommonJS
@@ -0,0 +1,61 @@
1
+ //.CommonJS
2
+ var CSSOM = {};
3
+ ///CommonJS
4
+
5
+
6
+ /**
7
+ * @constructor
8
+ * @see http://dev.w3.org/csswg/cssom/#the-medialist-interface
9
+ */
10
+ CSSOM.MediaList = function MediaList(){
11
+ this.length = 0;
12
+ };
13
+
14
+ CSSOM.MediaList.prototype = {
15
+
16
+ constructor: CSSOM.MediaList,
17
+
18
+ /**
19
+ * @return {string}
20
+ */
21
+ get mediaText() {
22
+ return Array.prototype.join.call(this, ", ");
23
+ },
24
+
25
+ /**
26
+ * @param {string} value
27
+ */
28
+ set mediaText(value) {
29
+ var values = value.split(",");
30
+ var length = this.length = values.length;
31
+ for (var i=0; i<length; i++) {
32
+ this[i] = values[i].trim();
33
+ }
34
+ },
35
+
36
+ /**
37
+ * @param {string} medium
38
+ */
39
+ appendMedium: function(medium) {
40
+ if (Array.prototype.indexOf.call(this, medium) == -1) {
41
+ this[this.length] = medium;
42
+ this.length++;
43
+ }
44
+ },
45
+
46
+ /**
47
+ * @param {string} medium
48
+ */
49
+ deleteMedium: function(medium) {
50
+ var index = Array.prototype.indexOf.call(this, medium);
51
+ if (index != -1) {
52
+ Array.prototype.splice.call(this, index, 1);
53
+ }
54
+ }
55
+
56
+ };
57
+
58
+
59
+ //.CommonJS
60
+ exports.MediaList = CSSOM.MediaList;
61
+ ///CommonJS
@@ -0,0 +1,15 @@
1
+ //.CommonJS
2
+ var CSSOM = {};
3
+ ///CommonJS
4
+
5
+
6
+ /**
7
+ * @constructor
8
+ * @see http://dev.w3.org/csswg/cssom/#the-stylesheet-interface
9
+ */
10
+ CSSOM.StyleSheet = function StyleSheet(){};
11
+
12
+
13
+ //.CommonJS
14
+ exports.StyleSheet = CSSOM.StyleSheet;
15
+ ///CommonJS
@@ -0,0 +1,69 @@
1
+ //.CommonJS
2
+ var CSSOM = {
3
+ CSSStyleSheet: require("./CSSStyleSheet").CSSStyleSheet,
4
+ CSSStyleRule: require("./CSSStyleRule").CSSStyleRule,
5
+ CSSMediaRule: require("./CSSMediaRule").CSSMediaRule,
6
+ CSSStyleDeclaration: require("./CSSStyleDeclaration").CSSStyleDeclaration
7
+ };
8
+ ///CommonJS
9
+
10
+
11
+ /**
12
+ * Produces a deep copy of stylesheet — the instance variables of stylesheet are copied recursively.
13
+ * @param {CSSStyleSheet|CSSOM.CSSStyleSheet} stylesheet
14
+ * @nosideeffects
15
+ * @return {CSSOM.CSSStyleSheet}
16
+ */
17
+ CSSOM.clone = function clone(stylesheet) {
18
+
19
+ var cloned = new CSSOM.CSSStyleSheet;
20
+
21
+ var rules = stylesheet.cssRules;
22
+ if (!rules) {
23
+ return cloned;
24
+ }
25
+
26
+ var RULE_TYPES = {
27
+ 1: CSSOM.CSSStyleRule,
28
+ 4: CSSOM.CSSMediaRule
29
+ //FIXME
30
+ //3: CSSOM.CSSImportRule,
31
+ //5: CSSOM.CSSFontFaceRule,
32
+ //6: CSSOM.CSSPageRule,
33
+ };
34
+
35
+ for (var i=0, rulesLength=rules.length; i < rulesLength; i++) {
36
+ var rule = rules[i];
37
+ var ruleClone = cloned.cssRules[i] = new RULE_TYPES[rule.type];
38
+
39
+ var style = rule.style;
40
+ if (style) {
41
+ var styleClone = ruleClone.style = new CSSOM.CSSStyleDeclaration;
42
+ for (var j=0, styleLength=style.length; j < styleLength; j++) {
43
+ var name = styleClone[j] = style[j];
44
+ styleClone[name] = style[name];
45
+ styleClone._importants[name] = style.getPropertyPriority(name);
46
+ }
47
+ styleClone.length = style.length;
48
+ }
49
+
50
+ if ("selectorText" in rule) {
51
+ ruleClone.selectorText = rule.selectorText;
52
+ }
53
+
54
+ if ("mediaText" in rule) {
55
+ ruleClone.mediaText = rule.mediaText;
56
+ }
57
+
58
+ if ("cssRules" in rule) {
59
+ rule.cssRules = clone(rule).cssRules;
60
+ }
61
+ }
62
+
63
+ return cloned;
64
+
65
+ };
66
+
67
+ //.CommonJS
68
+ exports.clone = CSSOM.clone;
69
+ ///CommonJS
@@ -0,0 +1,10 @@
1
+ exports.CSSStyleDeclaration = require("./CSSStyleDeclaration").CSSStyleDeclaration;
2
+ exports.CSSRule = require("./CSSRule").CSSRule;
3
+ exports.CSSStyleRule = require("./CSSStyleRule").CSSStyleRule;
4
+ exports.CSSImportRule = require("./CSSImportRule").CSSImportRule;
5
+ exports.MediaList = require("./MediaList").MediaList;
6
+ exports.CSSMediaRule = require("./CSSMediaRule").CSSMediaRule;
7
+ exports.StyleSheet = require("./StyleSheet").StyleSheet;
8
+ exports.CSSStyleSheet = require("./CSSStyleSheet").CSSStyleSheet;
9
+ exports.parse = require("./parse").parse;
10
+ exports.clone = require("./clone").clone;
@@ -0,0 +1,195 @@
1
+ //.CommonJS
2
+ var CSSOM = {
3
+ CSSStyleSheet: require("./CSSStyleSheet").CSSStyleSheet,
4
+ CSSStyleRule: require("./CSSStyleRule").CSSStyleRule,
5
+ CSSMediaRule: require("./CSSMediaRule").CSSMediaRule
6
+ };
7
+ ///CommonJS
8
+
9
+
10
+ /**
11
+ * @param {string} token
12
+ * @param {Object} [options]
13
+ */
14
+ CSSOM.parse = function parse(token, options) {
15
+
16
+ options = options || {};
17
+ var i = options.startIndex || 0;
18
+ var state = options.state || "selector";
19
+
20
+ var index;
21
+ var j = i;
22
+ var buffer = "";
23
+
24
+ var SIGNIFICANT_WHITESPACE = {
25
+ "selector": true,
26
+ "value": true,
27
+ "atRule": true,
28
+ "atBlock": true
29
+ };
30
+
31
+ var styleSheet = new CSSOM.CSSStyleSheet;
32
+
33
+ // @type CSSStyleSheet|CSSMediaRule
34
+ var currentScope = styleSheet;
35
+
36
+ var selector, name, value, priority="", styleRule, mediaRule;
37
+
38
+ for (var character; character = token.charAt(i); i++) {
39
+
40
+ switch (character) {
41
+
42
+ case " ":
43
+ case "\t":
44
+ case "\r":
45
+ case "\n":
46
+ case "\f":
47
+ if (SIGNIFICANT_WHITESPACE[state]) {
48
+ // Squash 2 or more white-spaces in the row into 1
49
+ switch (token.charAt(i - 1)) {
50
+ case " ":
51
+ case "\t":
52
+ case "\r":
53
+ case "\n":
54
+ case "\f":
55
+ break;
56
+ default:
57
+ buffer += " ";
58
+ break;
59
+ }
60
+ }
61
+ break;
62
+
63
+ // String
64
+ case '"':
65
+ j = i + 1;
66
+ index = token.indexOf('"', j) + 1;
67
+ if (!index) {
68
+ throw '" is missing';
69
+ }
70
+ buffer += token.slice(i, index);
71
+ i = index - 1;
72
+ break;
73
+
74
+ case "'":
75
+ j = i + 1;
76
+ index = token.indexOf("'", j) + 1;
77
+ if (!index) {
78
+ throw "' is missing";
79
+ }
80
+ buffer += token.slice(i, index);
81
+ i = index - 1;
82
+ break;
83
+
84
+ // Comment
85
+ case "/":
86
+ if (token.charAt(i + 1) == "*") {
87
+ i += 2;
88
+ index = token.indexOf("*/", i);
89
+ if (index == -1) {
90
+ throw SyntaxError("Missing */");
91
+ } else {
92
+ i = index + 1;
93
+ }
94
+ } else {
95
+ buffer += character;
96
+ }
97
+ break;
98
+
99
+ // At-rule
100
+ case "@":
101
+ if (token.indexOf("@media", i) == i) {
102
+ state = "atBlock";
103
+ i += "media".length;
104
+ buffer = "";
105
+ break;
106
+ } else if (state == "selector") {
107
+ state = "atRule";
108
+ }
109
+ buffer += character;
110
+ break;
111
+
112
+ case "{":
113
+ if (state == "selector" || state == "atRule") {
114
+ styleRule = new CSSOM.CSSStyleRule;
115
+ styleRule.selectorText = buffer.trim();
116
+ buffer = "";
117
+ state = "name";
118
+ } else if (state == "atBlock") {
119
+ mediaRule = new CSSOM.CSSMediaRule;
120
+ mediaRule.media.mediaText = buffer.trim();
121
+ currentScope = mediaRule;
122
+ buffer = "";
123
+ state = "selector";
124
+ }
125
+ break;
126
+
127
+ case ":":
128
+ if (state == "name") {
129
+ name = buffer.trim();
130
+ buffer = "";
131
+ state = "value";
132
+ } else {
133
+ buffer += character;
134
+ }
135
+ break;
136
+
137
+ case "!":
138
+ if (state == "value" && token.indexOf("!important", i) === i) {
139
+ priority = "important";
140
+ i += "important".length;
141
+ } else {
142
+ buffer += character;
143
+ }
144
+ break;
145
+
146
+ case ";":
147
+ if (state == "value") {
148
+ styleRule.style.setProperty(name, buffer.trim(), priority);
149
+ priority = "";
150
+ buffer = "";
151
+ state = "name";
152
+ } else if (state == "atRule") {
153
+ buffer = "";
154
+ state = "selector";
155
+ } else {
156
+ buffer += character;
157
+ }
158
+ break;
159
+
160
+ case "}":
161
+ if (state == "value") {
162
+ styleRule.style.setProperty(name, buffer.trim(), priority);
163
+ priority = "";
164
+ buffer = "";
165
+ currentScope.cssRules.push(styleRule);
166
+ } else if (state == "name") {
167
+ currentScope.cssRules.push(styleRule);
168
+ buffer = "";
169
+ } else if (state == "selector") {
170
+ // End of media rule.
171
+ // Nesting of media rules isn't supported
172
+ if (!mediaRule) {
173
+ throw "unexpected }";
174
+ }
175
+ styleSheet.cssRules.push(mediaRule);
176
+ currentScope = styleSheet;
177
+ buffer = "";
178
+ }
179
+ state = "selector";
180
+ break;
181
+
182
+ default:
183
+ buffer += character;
184
+ break;
185
+
186
+ }
187
+ }
188
+
189
+ return styleSheet;
190
+ };
191
+
192
+
193
+ //.CommonJS
194
+ exports.parse = CSSOM.parse;
195
+ ///CommonJS
@@ -0,0 +1,17 @@
1
+ <style>
2
+ @media handheld, only screen and (max-device-width: 480px){
3
+ html {
4
+ color: black;
5
+ }
6
+ }
7
+ </style>
8
+
9
+ <script>
10
+ window.onload = function(){
11
+ if (document.styleSheets[0].cssRules[0].cssRules[0].parentRule === document.styleSheets[0].cssRules[0]) {
12
+ document.body.innerHTML = "PASS parentRule";
13
+ } else {
14
+ document.body.innerHTML = "FAIL parentRule";
15
+ }
16
+ }
17
+ </script>