Permalink
Browse files

Stylus lib

  • Loading branch information...
1 parent 57f619e commit 5cd25965e6c79d52afebe50b3c1afbe115d8c46d @andreyvit andreyvit committed Dec 12, 2013
Showing with 1,068 additions and 377 deletions.
  1. +0 −4 Stylus.lrplugin/node_modules/stylus/node_modules/debug/.npmignore
  2. +0 −62 Stylus.lrplugin/node_modules/stylus/node_modules/debug/History.md
  3. +0 −9 Stylus.lrplugin/node_modules/stylus/node_modules/debug/component.json
  4. +0 −40 Stylus.lrplugin/node_modules/stylus/node_modules/debug/package.json
  5. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/LICENSE
  6. +1 −0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/Readme.md
  7. +1 −1 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/bin/stylus
  8. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/bm.js
  9. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/index.js
  10. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/browserify.js
  11. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/colors.js
  12. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/convert/css.js
  13. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/errors.js
  14. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/functions/image.js
  15. +113 −26 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/functions/index.js
  16. +14 −6 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/functions/index.styl
  17. +6 −2 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/functions/resolver.js
  18. +2 −1 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/functions/url.js
  19. +48 −8 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/lexer.js
  20. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/middleware.js
  21. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/arguments.js
  22. +11 −1 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/binop.js
  23. +22 −0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/block.js
  24. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/boolean.js
  25. +1 −0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/call.js
  26. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/charset.js
  27. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/comment.js
  28. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/each.js
  29. +11 −4 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/expression.js
  30. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/extend.js
  31. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/fontface.js
  32. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/function.js
  33. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/group.js
  34. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/hsla.js
  35. +3 −2 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/ident.js
  36. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/if.js
  37. +14 −0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/import.js
  38. +2 −0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/index.js
  39. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/jsliteral.js
  40. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/keyframes.js
  41. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/literal.js
  42. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/media.js
  43. +55 −0 Stylus.lrplugin/npm/stylus-0.41.2/lib/nodes/member.js
  44. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/mozdocument.js
  45. +8 −1 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/node.js
  46. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/null.js
  47. +171 −0 Stylus.lrplugin/npm/stylus-0.41.2/lib/nodes/object.js
  48. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/page.js
  49. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/params.js
  50. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/property.js
  51. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/return.js
  52. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/rgba.js
  53. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/root.js
  54. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/selector.js
  55. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/string.js
  56. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/ternary.js
  57. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/unaryop.js
  58. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/nodes/unit.js
  59. +163 −14 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/parser.js
  60. +8 −11 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/renderer.js
  61. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/stack/frame.js
  62. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/stack/index.js
  63. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/stack/scope.js
  64. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/stylus.js
  65. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/token.js
  66. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/units.js
  67. +70 −1 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/utils.js
  68. +5 −72 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/visitor/compiler.js
  69. +210 −27 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/visitor/evaluator.js
  70. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/visitor/index.js
  71. +2 −60 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/lib/visitor/normalizer.js
  72. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/.gitmodules
  73. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/.npmignore
  74. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/README.mdown
  75. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/CSSFontFaceRule.js
  76. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/CSSImportRule.js
  77. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/CSSKeyframeRule.js
  78. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/CSSKeyframesRule.js
  79. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/CSSMediaRule.js
  80. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/CSSRule.js
  81. 0 ....lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/CSSStyleDeclaration.js
  82. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/CSSStyleRule.js
  83. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/CSSStyleSheet.js
  84. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/MediaList.js
  85. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/StyleSheet.js
  86. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/clone.js
  87. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/index.js
  88. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/lib/parse.js
  89. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/cssom/package.json
  90. +4 −4 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/debug/Readme.md
  91. +14 −1 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/debug/debug.js
  92. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/debug/index.js
  93. +13 −0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/debug/lib/debug.js
  94. +45 −0 Stylus.lrplugin/npm/stylus-0.41.2/node_modules/debug/package.json
  95. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/mkdirp/.npmignore
  96. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/mkdirp/.travis.yml
  97. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/mkdirp/LICENSE
  98. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/mkdirp/index.js
  99. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/mkdirp/package.json
  100. 0 ...ylus/node_modules/mkdirp/README.markdown → npm/stylus-0.41.2/node_modules/mkdirp/readme.markdown}
  101. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/sax/AUTHORS
  102. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/sax/LICENSE
  103. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/sax/LICENSE-W3C.html
  104. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/sax/README.md
  105. 0 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/sax/component.json
  106. +33 −7 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/sax/lib/sax.js
  107. +7 −3 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/node_modules/sax/package.json
  108. +8 −4 Stylus.lrplugin/{node_modules/stylus → npm/stylus-0.41.2}/package.json
  109. +0 −6 Stylus.lrplugin/versions.json
  110. +3 −0 install-npm-package
@@ -1,4 +0,0 @@
-support
-test
-examples
-*.sock
@@ -1,62 +0,0 @@
-
-0.7.2 / 2013-02-06
-==================
-
- * fix package.json
- * fix: Mobile Safari (private mode) is broken with debug
- * fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript
-
-0.7.1 / 2013-02-05
-==================
-
- * add repository URL to package.json
- * add DEBUG_COLORED to force colored output
- * add browserify support
- * fix component. Closes #24
-
-0.7.0 / 2012-05-04
-==================
-
- * Added .component to package.json
- * Added debug.component.js build
-
-0.6.0 / 2012-03-16
-==================
-
- * Added support for "-" prefix in DEBUG [Vinay Pulim]
- * Added `.enabled` flag to the node version [TooTallNate]
-
-0.5.0 / 2012-02-02
-==================
-
- * Added: humanize diffs. Closes #8
- * Added `debug.disable()` to the CS variant
- * Removed padding. Closes #10
- * Fixed: persist client-side variant again. Closes #9
-
-0.4.0 / 2012-02-01
-==================
-
- * Added browser variant support for older browsers [TooTallNate]
- * Added `debug.enable('project:*')` to browser variant [TooTallNate]
- * Added padding to diff (moved it to the right)
-
-0.3.0 / 2012-01-26
-==================
-
- * Added millisecond diff when isatty, otherwise UTC string
-
-0.2.0 / 2012-01-22
-==================
-
- * Added wildcard support
-
-0.1.0 / 2011-12-02
-==================
-
- * Added: remove colors unless stderr isatty [TooTallNate]
-
-0.0.1 / 2010-01-03
-==================
-
- * Initial release
@@ -1,9 +0,0 @@
-{
- "name": "debug",
- "repo": "visionmedia/debug",
- "description": "small debugging utility",
- "version": "0.7.2",
- "keywords": ["debug", "log", "debugger"],
- "scripts": ["index.js", "debug.js"],
- "dependencies": {}
-}
@@ -1,40 +0,0 @@
-{
- "name": "debug",
- "version": "0.7.2",
- "repository": {
- "type": "git",
- "url": "git://github.com/visionmedia/debug.git"
- },
- "description": "small debugging utility",
- "keywords": [
- "debug",
- "log",
- "debugger"
- ],
- "author": {
- "name": "TJ Holowaychuk",
- "email": "tj@vision-media.ca"
- },
- "dependencies": {},
- "devDependencies": {
- "mocha": "*"
- },
- "main": "lib/debug.js",
- "browserify": "debug.js",
- "engines": {
- "node": "*"
- },
- "component": {
- "scripts": {
- "debug/index.js": "index.js",
- "debug/debug.js": "debug.js"
- }
- },
- "readme": "\n# debug\n\n tiny node.js debugging utility modelled after node core's debugging technique.\n\n## Installation\n\n```\n$ npm install debug\n```\n\n## Usage\n\n With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.\n \nExample _app.js_:\n\n```js\nvar debug = require('debug')('http')\n , http = require('http')\n , name = 'My App';\n\n// fake app\n\ndebug('booting %s', name);\n\nhttp.createServer(function(req, res){\n debug(req.method + ' ' + req.url);\n res.end('hello\\n');\n}).listen(3000, function(){\n debug('listening');\n});\n\n// fake worker of some kind\n\nrequire('./worker');\n```\n\nExample _worker.js_:\n\n```js\nvar debug = require('debug')('worker');\n\nsetInterval(function(){\n debug('doing some work');\n}, 1000);\n```\n\n The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:\n\n ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png)\n\n ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png)\n\n## Millisecond diff\n\n When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the \"+NNNms\" will show you how much time was spent between calls.\n\n ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png)\n\n When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:\n \n ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png)\n\n## Conventions\n\n If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use \":\" to separate features. For example \"bodyParser\" from Connect would then be \"connect:bodyParser\". \n\n## Wildcards\n\n The \"*\" character may be used as a wildcard. Suppose for example your library has debuggers named \"connect:bodyParser\", \"connect:compress\", \"connect:session\", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.\n\n You can also exclude specific debuggers by prefixing them with a \"-\" character. For example, `DEBUG=* -connect:*` would include all debuggers except those starting with \"connect:\".\n\n## Browser support\n\n Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`. \n\n```js\na = debug('worker:a');\nb = debug('worker:b');\n\nsetInterval(function(){\n a('doing some work');\n}, 1000);\n\nsetInterval(function(){\n a('doing some work');\n}, 1200);\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
- "readmeFilename": "Readme.md",
- "_id": "debug@0.7.2",
- "_from": "debug@*",
- "bugs": {
- "url": "https://github.com/visionmedia/debug/issues"
- }
-}
@@ -118,6 +118,7 @@ form input {
- [Connect](docs/middleware.md)
- [Play! 2.0](https://github.com/patiencelabs/play-stylus)
- [Ruby On Rails](https://github.com/lucasmazza/ruby-stylus)
+ - [Meteor](http://docs.meteor.com/#stylus)
### CMS Support
@@ -124,7 +124,7 @@ var usage = [
, ''
, ' Commands:'
, ''
- , ' help [<type>:]<prop> Opens help info at MDC for <prop> in'
+ , ' help [<type>:]<prop> Opens help info at MDN for <prop> in'
, ' your default browser. Optionally'
, ' searches other resources of <type>:'
, ' safari opera w3c ms caniuse quirksmode'
@@ -380,7 +380,7 @@ exports.rgb = function rgb(red, green, blue){
};
/**
- * Convert a .json file into stylus variables
+ * Convert a .json file into stylus variables or object.
* Nested variable object keys are joined with a dash (-)
*
* Given this sample media-queries.json file:
@@ -395,13 +395,17 @@ exports.rgb = function rgb(red, green, blue){
* Examples:
*
* json('media-queries.json')
- *
+ *
* @media small
* // => @media screen and (max-width:400px)
*
* @media tablet-landscape
* // => @media screen and (min-width:600px) and (orientation:landscape)
- *
+ *
+ * vars = json('vars.json', { hash: true })
+ * body
+ * width: vars.width
+ *
* @param {String} path
* @param {Boolean} [local]
* @param {String} [namePrefix]
@@ -411,6 +415,43 @@ exports.rgb = function rgb(red, green, blue){
exports.json = function(path, local, namePrefix){
utils.assertString(path, 'path');
+ // lookup
+ path = path.string;
+ var found = utils.lookup(path, this.options.paths, this.options.filename);
+ if (!found) throw new Error('failed to locate .json file ' + path);
+
+ // read
+ var json = JSON.parse(fs.readFileSync(found, 'utf8'));
+
+ if (local && 'object' == local.nodeName) {
+ return convert(json);
+ } else {
+ exports['-old-json'].call(this, json, local, namePrefix);
+ }
+
+ function convert(obj){
+ var ret = new nodes.Object();
+ for (var key in obj) {
+ var val = obj[key];
+ if ('object' == typeof val) {
+ ret.set(key, convert(val));
+ } else {
+ val = utils.coerce(val);
+ if ('string' == val.nodeName) val = parseString(val.string);
+ ret.set(key, val);
+ }
+ }
+ return ret;
+ }
+};
+
+/**
+ * Old `json` BIF.
+ *
+ * @api private
+ */
+
+exports['-old-json'] = function(json, local, namePrefix){
if (namePrefix) {
utils.assertString(namePrefix, 'namePrefix');
namePrefix = namePrefix.val;
@@ -420,14 +461,7 @@ exports.json = function(path, local, namePrefix){
local = local ? local.toBoolean() : new nodes.Boolean(local);
var scope = local.isTrue ? this.currentScope : this.global.scope;
- // lookup
- path = path.string;
- var found = utils.lookup(path, this.options.paths, this.options.filename);
- if (!found) throw new Error('failed to locate .json file ' + path);
-
- // read
- var str = fs.readFileSync(found, 'utf8');
- convert.call(this, JSON.parse(str));
+ convert(json);
return;
function convert(obj, prefix){
@@ -436,10 +470,10 @@ exports.json = function(path, local, namePrefix){
var val = obj[key];
var name = prefix + key;
if ('object' == typeof val) {
- convert.call(this, val, name);
+ convert(val, name);
} else {
val = utils.coerce(val);
- if ('string' == val.nodeName) val = parseUnit(val.string) || parseColor(val.string) || new nodes.Literal(val.string);
+ if ('string' == val.nodeName) val = parseString(val.string);
scope.add({ name: namePrefix + name, val: val });
}
}
@@ -571,7 +605,7 @@ exports.match = function match(pattern, val){
utils.assertType(pattern, 'string', 'pattern');
utils.assertString(val, 'val');
var re = new RegExp(pattern.val);
- return nodes.Boolean(re.test(val.string));
+ return new nodes.Boolean(re.test(val.string));
};
/**
@@ -655,9 +689,16 @@ exports.match = function match(pattern, val){
(exports.length = function length(expr){
if (expr) {
- return expr.nodes
- ? utils.unwrap(expr).nodes.length
- : 1;
+ if (expr.nodes) {
+ var nodes = utils.unwrap(expr).nodes;
+ if (1 == nodes.length && 'object' == nodes[0].nodeName) {
+ return nodes[0].length;
+ } else {
+ return nodes.length;
+ }
+ } else {
+ return 1;
+ }
}
return 0;
}).raw = true;
@@ -1020,11 +1061,41 @@ exports['-adjust'] = function adjust(color, prop, amount){
}).raw = true;
/**
+ * Merge the object `dest` with the given args.
+ *
+ * @param {Object} dest
+ * @param {Object} ...
+ * @return {Object} dest
+ * @api public
+ */
+
+(exports.merge = exports.extend = function merge(dest){
+ utils.assertPresent(dest, 'dest');
+ dest = utils.unwrap(dest).first;
+ utils.assertType(dest, 'object', 'dest');
+ for (var i = 1, len = arguments.length; i < len; ++i) {
+ utils.merge(dest.vals, utils.unwrap(arguments[i]).first.vals);
+ }
+ return dest;
+}).raw = true;
+
+/**
+ * Return the current selector.
+ *
+ * @return {String}
+ * @api public
+ */
+
+exports.selector = function selector(){
+ return this.currentSelector;
+};
+
+/**
* Attempt to parse unit `str`.
*
* @param {String} str
* @return {Unit}
- * @api public
+ * @api private
*/
function parseUnit(str){
@@ -1036,17 +1107,21 @@ function parseUnit(str){
}
/**
-* Attempt to parse color
-* @param {String} str
-* @return {RGBA}
-* @api public
-*/
+ * Attempt to parse color.
+ *
+ * @param {String} str
+ * @return {RGBA}
+ * @api private
+ */
function parseColor(str){
- if (str.substr(0,1) === '#'){
- var m = str.match(/\w{2}/g);
+ if (str.substr(0,1) === '#') {
+ // Handle color shorthands (like #abc)
+ var shorthand = str.length === 4,
+ m = str.match(shorthand ? /\w/g : /\w{2}/g);
+
if (!m) return;
- m = m.map(function(s){ return parseInt(s, 16) });
+ m = m.map(function(s) { return parseInt(shorthand ? s+s : s, 16) });
return new nodes.RGBA(m[0],m[1],m[2],1);
}
else if (str.substr(0,3) === 'rgb'){
@@ -1061,3 +1136,15 @@ function parseColor(str){
return new nodes.RGBA(rgb[0], rgb[1], rgb[2], 1);
}
}
+
+/**
+ * Attempt to parse string.
+ *
+ * @param {String} str
+ * @return {Unit|RGBA|Literal}
+ * @api private
+ */
+
+function parseString(str){
+ return parseUnit(str) || parseColor(str) || new nodes.Literal(str);
+}
@@ -217,20 +217,28 @@ invert(color)
last(expr)
expr[length(expr) - 1]
-// return keys in the given pairs
+// return keys in the given pairs or object
keys(pairs)
ret = ()
- for pair in pairs
- push(ret, pair[0]);
+ if type(pairs) == 'object'
+ for key in pairs
+ push(ret, key)
+ else
+ for pair in pairs
+ push(ret, pair[0]);
ret
-// return values in the given pairs
+// return values in the given pairs or object
values(pairs)
ret = ()
- for pair in pairs
- push(ret, pair[1]);
+ if type(pairs) == 'object'
+ for key, val in pairs
+ push(ret, val)
+ else
+ for pair in pairs
+ push(ret, pair[1]);
ret
// join values with the given delimiter
Oops, something went wrong.

0 comments on commit 5cd2596

Please sign in to comment.