This commit is contained in:
22
node_modules/generic-names/LICENSE
generated
vendored
Normal file
22
node_modules/generic-names/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Alexey Litvinov
|
||||
|
||||
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.
|
||||
|
||||
9
node_modules/generic-names/generic-names.iml
generated
vendored
Normal file
9
node_modules/generic-names/generic-names.iml
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
13
node_modules/generic-names/index.d.ts
generated
vendored
Normal file
13
node_modules/generic-names/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
interface Options {
|
||||
context: string;
|
||||
hashPrefix: string;
|
||||
}
|
||||
|
||||
type Generator = (localName: string, filepath: string) => string;
|
||||
|
||||
declare function createGenerator(
|
||||
pattern: string,
|
||||
options?: Partial<Options>
|
||||
): Generator;
|
||||
|
||||
export = createGenerator;
|
||||
47
node_modules/generic-names/index.js
generated
vendored
Normal file
47
node_modules/generic-names/index.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
|
||||
var interpolateName = require("loader-utils/lib/interpolateName");
|
||||
var path = require("path");
|
||||
|
||||
/**
|
||||
* @param {string} pattern
|
||||
* @param {object} options
|
||||
* @param {string} options.context
|
||||
* @param {string} options.hashPrefix
|
||||
* @return {function}
|
||||
*/
|
||||
module.exports = function createGenerator(pattern, options) {
|
||||
options = options || {};
|
||||
var context =
|
||||
options && typeof options.context === "string"
|
||||
? options.context
|
||||
: process.cwd();
|
||||
var hashPrefix =
|
||||
options && typeof options.hashPrefix === "string" ? options.hashPrefix : "";
|
||||
|
||||
/**
|
||||
* @param {string} localName Usually a class name
|
||||
* @param {string} filepath Absolute path
|
||||
* @return {string}
|
||||
*/
|
||||
return function generate(localName, filepath) {
|
||||
var name = pattern.replace(/\[local\]/gi, localName);
|
||||
var loaderContext = {
|
||||
resourcePath: filepath,
|
||||
};
|
||||
|
||||
var loaderOptions = {
|
||||
content:
|
||||
hashPrefix +
|
||||
path.relative(context, filepath).replace(/\\/g, "/") +
|
||||
"\x00" +
|
||||
localName,
|
||||
context: context,
|
||||
};
|
||||
|
||||
var genericName = interpolateName(loaderContext, name, loaderOptions);
|
||||
return genericName
|
||||
.replace(new RegExp("[^a-zA-Z0-9\\-_\u00A0-\uFFFF]", "g"), "-")
|
||||
.replace(/^((-?[0-9])|--)/, "_$1");
|
||||
};
|
||||
};
|
||||
31
node_modules/generic-names/package.json
generated
vendored
Normal file
31
node_modules/generic-names/package.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "generic-names",
|
||||
"version": "4.0.0",
|
||||
"description": "Helper for building generic names, similar to webpack",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/css-modules/generic-names.git"
|
||||
},
|
||||
"keywords": [
|
||||
"css-modules",
|
||||
"postcss-modules-scope",
|
||||
"webpack"
|
||||
],
|
||||
"author": "Alexey Litvinov",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/css-modules/generic-names/issues"
|
||||
},
|
||||
"homepage": "https://github.com/css-modules/generic-names#readme",
|
||||
"devDependencies": {
|
||||
"tape": "^4.6.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"loader-utils": "^3.2.0"
|
||||
}
|
||||
}
|
||||
17
node_modules/generic-names/readme.md
generated
vendored
Normal file
17
node_modules/generic-names/readme.md
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
generic-names
|
||||
=============
|
||||
|
||||
Helper for building generic names, similar to webpack. Designed to be used with [postcss‑modules‑scope](https://github.com/css-modules/postcss-modules-scope).
|
||||
|
||||
Uses [interpolateName](https://github.com/webpack/loader-utils#interpolatename) from the webpack/loader-utils.
|
||||
|
||||
## API
|
||||
|
||||
```javascript
|
||||
var genericNames = require('generic-names');
|
||||
var generate = genericNames('[name]__[local]___[hash:base64:5]', {
|
||||
context: process.cwd()
|
||||
});
|
||||
|
||||
generate('foo', '/case/source.css'); // 'source__foo___3mRq8'
|
||||
```
|
||||
Reference in New Issue
Block a user