--
This commit is contained in:
parent
24f3d27984
commit
6b60015c02
9588 changed files with 1149251 additions and 49 deletions
1
node_modules/rework-plugin-function/.npmignore
generated
vendored
Normal file
1
node_modules/rework-plugin-function/.npmignore
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
test
|
||||
3
node_modules/rework-plugin-function/.travis.yml
generated
vendored
Normal file
3
node_modules/rework-plugin-function/.travis.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
21
node_modules/rework-plugin-function/LICENSE
generated
vendored
Normal file
21
node_modules/rework-plugin-function/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 reworkcss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
68
node_modules/rework-plugin-function/README.md
generated
vendored
Normal file
68
node_modules/rework-plugin-function/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
rework-plugin-function
|
||||
====================
|
||||
|
||||
[](https://travis-ci.org/reworkcss/rework-plugin-function)
|
||||
|
||||
function() plugin for rework, formerly included in core
|
||||
|
||||
Add user-defined CSS functions.
|
||||
|
||||
For example create `black(0.5)` shortcut, to replace
|
||||
long `rgba(0, 0, 0, 0.5)`.
|
||||
|
||||
```js
|
||||
var rework = require('rework'),
|
||||
var reworkFunction = require('rework-plugin-function');
|
||||
|
||||
var css = rework(css)
|
||||
.use(reworkFunction({ black: black }))
|
||||
.toString()
|
||||
|
||||
function black(opacity) {
|
||||
return 'rgba(0, 0, 0, ' + opacity + ')';
|
||||
}
|
||||
```
|
||||
|
||||
User code will receive CSS arguments and replace user-defined function
|
||||
by returned code.
|
||||
|
||||
```css
|
||||
input {
|
||||
box-shadow: 0 0 5px black(0.7);
|
||||
}
|
||||
```
|
||||
|
||||
yields:
|
||||
|
||||
```css
|
||||
input {
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
|
||||
}
|
||||
```
|
||||
|
||||
Nested functions works well too:
|
||||
|
||||
```javascript
|
||||
var css = rework(css)
|
||||
.use(reworkFunction({
|
||||
subtract: function(a, b) { return a - b },
|
||||
multiply: function(a, b) { return a * b },
|
||||
divide: function(a, b) { return a / b },
|
||||
floor: Math.floor
|
||||
}))
|
||||
.toString()
|
||||
```
|
||||
|
||||
```css
|
||||
input {
|
||||
top: divide(subtract(30, floor(multiply(20, 10))), 2);
|
||||
}
|
||||
```
|
||||
|
||||
Would yield:
|
||||
|
||||
```css
|
||||
input {
|
||||
top: -85;
|
||||
}
|
||||
```
|
||||
102
node_modules/rework-plugin-function/index.js
generated
vendored
Normal file
102
node_modules/rework-plugin-function/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var visit = require('rework-visit');
|
||||
|
||||
/**
|
||||
* Define custom function.
|
||||
*/
|
||||
|
||||
module.exports = function(functions, args) {
|
||||
if (!functions) throw new Error('functions object required');
|
||||
return function(style){
|
||||
var functionMatcher = functionMatcherBuilder(Object.keys(functions).join('|'));
|
||||
|
||||
visit(style, function(declarations){
|
||||
func(declarations, functions, functionMatcher, args);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Visit declarations and apply functions.
|
||||
*
|
||||
* @param {Array} declarations
|
||||
* @param {Object} functions
|
||||
* @param {RegExp} functionMatcher
|
||||
* @param {Boolean} [parseArgs]
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function func(declarations, functions, functionMatcher, parseArgs) {
|
||||
if (!declarations) return;
|
||||
if (false !== parseArgs) parseArgs = true;
|
||||
|
||||
declarations.forEach(function(decl){
|
||||
if ('comment' == decl.type) return;
|
||||
var generatedFuncs = [], result, generatedFunc;
|
||||
|
||||
while (decl.value.match(functionMatcher)) {
|
||||
decl.value = decl.value.replace(functionMatcher, function(_, name, args){
|
||||
if (parseArgs) {
|
||||
args = args.split(/\s*,\s*/).map(strip);
|
||||
} else {
|
||||
args = [strip(args)];
|
||||
}
|
||||
// Ensure result is string
|
||||
result = '' + functions[name].apply(decl, args);
|
||||
|
||||
// Prevent fall into infinite loop like this:
|
||||
//
|
||||
// {
|
||||
// url: function(path) {
|
||||
// return 'url(' + '/some/prefix' + path + ')'
|
||||
// }
|
||||
// }
|
||||
//
|
||||
generatedFunc = {from: name, to: name + getRandomString()};
|
||||
result = result.replace(functionMatcherBuilder(name), generatedFunc.to + '($2)');
|
||||
generatedFuncs.push(generatedFunc);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
generatedFuncs.forEach(function(func) {
|
||||
decl.value = decl.value.replace(func.to, func.from);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Build function regexp
|
||||
*
|
||||
* @param {String} name
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function functionMatcherBuilder(name) {
|
||||
// /(?!\W+)(\w+)\(([^()]+)\)/
|
||||
return new RegExp("(?!\\W+)(" + name + ")\\(([^\(\)]+)\\)");
|
||||
}
|
||||
|
||||
/**
|
||||
* get random string
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function getRandomString() {
|
||||
return Math.random().toString(36).slice(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* strip quotes from string
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function strip(str) {
|
||||
if ('"' == str[0] || "'" == str[0]) return str.slice(1, -1);
|
||||
return str;
|
||||
}
|
||||
108
node_modules/rework-plugin-function/package.json
generated
vendored
Normal file
108
node_modules/rework-plugin-function/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "rework-plugin-function@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "rework-plugin-function",
|
||||
"name": "rework-plugin-function",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/Users/jose/Documents/GitHub/Mods/node_modules/rework-plugin-url"
|
||||
]
|
||||
],
|
||||
"_from": "rework-plugin-function@>=1.0.0 <2.0.0",
|
||||
"_id": "rework-plugin-function@1.0.2",
|
||||
"_inCache": true,
|
||||
"_location": "/rework-plugin-function",
|
||||
"_nodeVersion": "0.10.32",
|
||||
"_npmUser": {
|
||||
"name": "bclinkinbeard",
|
||||
"email": "ben.clinkinbeard@gmail.com"
|
||||
},
|
||||
"_npmVersion": "2.5.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "rework-plugin-function@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "rework-plugin-function",
|
||||
"name": "rework-plugin-function",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/rework-plugin-url"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/rework-plugin-function/-/rework-plugin-function-1.0.2.tgz",
|
||||
"_shasum": "12ce46fb5b29b5d935146683f6b98cf49d2373b9",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "rework-plugin-function@^1.0.0",
|
||||
"_where": "/Users/jose/Documents/GitHub/Mods/node_modules/rework-plugin-url",
|
||||
"author": {
|
||||
"name": "reworkcss"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/reworkcss/rework-plugin-function/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"rework-visit": "^1.0.0"
|
||||
},
|
||||
"description": "function() plugin for rework, formerly included in core",
|
||||
"devDependencies": {
|
||||
"mocha": "^1.17.1",
|
||||
"rework": "^1.0.0",
|
||||
"should": "^3.1.3"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "12ce46fb5b29b5d935146683f6b98cf49d2373b9",
|
||||
"tarball": "https://registry.npmjs.org/rework-plugin-function/-/rework-plugin-function-1.0.2.tgz"
|
||||
},
|
||||
"gitHead": "a5b83c1e3a103bad7ec21afba44c7aa015151e30",
|
||||
"homepage": "https://github.com/reworkcss/rework-plugin-function",
|
||||
"keywords": [
|
||||
"browser",
|
||||
"server",
|
||||
"css",
|
||||
"preprocess",
|
||||
"transform"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "bclinkinbeard",
|
||||
"email": "ben.clinkinbeard@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "conradz",
|
||||
"email": "me@conradz.com"
|
||||
},
|
||||
{
|
||||
"name": "necolas",
|
||||
"email": "nicolasgallagher@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "slexaxton",
|
||||
"email": "alexsexton@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "rework-plugin-function",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/reworkcss/rework-plugin-function.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --require should --reporter spec"
|
||||
},
|
||||
"version": "1.0.2"
|
||||
}
|
||||
Loading…
Reference in a new issue