postcss-modules 7.0.0 → 8.3.0

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.
package/build/Parser.js CHANGED
@@ -1,74 +1,76 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.default = void 0;
7
- var _icssUtils = require("icss-utils");
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Parser;
9
+ }
10
+ });
11
+ const _icssutils = require("icss-utils");
8
12
  // Initially copied from https://github.com/css-modules/css-modules-loader-core
9
-
10
13
  const importRegexp = /^:import\((.+)\)$/;
11
14
  class Parser {
12
- constructor(pathFetcher, trace) {
13
- this.pathFetcher = pathFetcher;
14
- this.plugin = this.plugin.bind(this);
15
- this.exportTokens = {};
16
- this.translations = {};
17
- this.trace = trace;
18
- }
19
- plugin() {
20
- const parser = this;
21
- return {
22
- postcssPlugin: "css-modules-parser",
23
- async OnceExit(css) {
24
- await Promise.all(parser.fetchAllImports(css));
25
- parser.linkImportedSymbols(css);
26
- return parser.extractExports(css);
27
- }
28
- };
29
- }
30
- fetchAllImports(css) {
31
- let imports = [];
32
- css.each(node => {
33
- if (node.type == "rule" && node.selector.match(importRegexp)) {
34
- imports.push(this.fetchImport(node, css.source.input.from, imports.length));
35
- }
36
- });
37
- return imports;
38
- }
39
- linkImportedSymbols(css) {
40
- (0, _icssUtils.replaceSymbols)(css, this.translations);
41
- }
42
- extractExports(css) {
43
- css.each(node => {
44
- if (node.type == "rule" && node.selector == ":export") this.handleExport(node);
45
- });
46
- }
47
- handleExport(exportNode) {
48
- exportNode.each(decl => {
49
- if (decl.type == "decl") {
50
- Object.keys(this.translations).forEach(translation => {
51
- decl.value = decl.value.replace(translation, this.translations[translation]);
15
+ constructor(pathFetcher, trace){
16
+ this.pathFetcher = pathFetcher;
17
+ this.plugin = this.plugin.bind(this);
18
+ this.exportTokens = {};
19
+ this.translations = {};
20
+ this.trace = trace;
21
+ }
22
+ plugin() {
23
+ const parser = this;
24
+ return {
25
+ postcssPlugin: "css-modules-parser",
26
+ async OnceExit (css) {
27
+ await Promise.all(parser.fetchAllImports(css));
28
+ parser.linkImportedSymbols(css);
29
+ return parser.extractExports(css);
30
+ }
31
+ };
32
+ }
33
+ fetchAllImports(css) {
34
+ let imports = [];
35
+ css.each((node)=>{
36
+ if (node.type == "rule" && node.selector.match(importRegexp)) {
37
+ imports.push(this.fetchImport(node, css.source.input.from, imports.length));
38
+ }
39
+ });
40
+ return imports;
41
+ }
42
+ linkImportedSymbols(css) {
43
+ (0, _icssutils.replaceSymbols)(css, this.translations);
44
+ }
45
+ extractExports(css) {
46
+ css.each((node)=>{
47
+ if (node.type == "rule" && node.selector == ":export") this.handleExport(node);
52
48
  });
53
- this.exportTokens[decl.prop] = decl.value;
54
- }
55
- });
56
- exportNode.remove();
57
- }
58
- async fetchImport(importNode, relativeTo, depNr) {
59
- const file = importNode.selector.match(importRegexp)[1];
60
- const depTrace = this.trace + String.fromCharCode(depNr);
61
- const exports = await this.pathFetcher(file, relativeTo, depTrace);
62
- try {
63
- importNode.each(decl => {
64
- if (decl.type == "decl") {
65
- this.translations[decl.prop] = exports[decl.value];
49
+ }
50
+ handleExport(exportNode) {
51
+ exportNode.each((decl)=>{
52
+ if (decl.type == "decl") {
53
+ Object.keys(this.translations).forEach((translation)=>{
54
+ decl.value = decl.value.replace(translation, this.translations[translation]);
55
+ });
56
+ this.exportTokens[decl.prop] = decl.value;
57
+ }
58
+ });
59
+ exportNode.remove();
60
+ }
61
+ async fetchImport(importNode, relativeTo, depNr) {
62
+ const file = importNode.selector.match(importRegexp)[1];
63
+ const depTrace = this.trace + String.fromCharCode(depNr);
64
+ const exports1 = await this.pathFetcher(file, relativeTo, depTrace);
65
+ try {
66
+ importNode.each((decl)=>{
67
+ if (decl.type == "decl") {
68
+ this.translations[decl.prop] = exports1[decl.value];
69
+ }
70
+ });
71
+ importNode.remove();
72
+ } catch (err) {
73
+ console.log(err);
66
74
  }
67
- });
68
- importNode.remove();
69
- } catch (err) {
70
- console.log(err);
71
75
  }
72
- }
73
76
  }
74
- exports.default = Parser;
package/build/fs.js CHANGED
@@ -1,22 +1,33 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get getFileSystem () {
13
+ return getFileSystem;
14
+ },
15
+ get setFileSystem () {
16
+ return setFileSystem;
17
+ }
5
18
  });
6
- exports.getFileSystem = getFileSystem;
7
- exports.setFileSystem = setFileSystem;
8
19
  let fileSystem = {
9
- readFile: () => {
10
- throw Error("readFile not implemented");
11
- },
12
- writeFile: () => {
13
- throw Error("writeFile not implemented");
14
- }
20
+ readFile: ()=>{
21
+ throw Error("readFile not implemented");
22
+ },
23
+ writeFile: ()=>{
24
+ throw Error("writeFile not implemented");
25
+ }
15
26
  };
16
27
  function setFileSystem(fs) {
17
- fileSystem.readFile = fs.readFile;
18
- fileSystem.writeFile = fs.writeFile;
28
+ fileSystem.readFile = fs.readFile;
29
+ fileSystem.writeFile = fs.writeFile;
19
30
  }
20
31
  function getFileSystem() {
21
- return fileSystem;
22
- }
32
+ return fileSystem;
33
+ }
package/build/index.js CHANGED
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
-
3
- var _fs = require("fs");
4
- var _fs2 = require("./fs");
5
- var _pluginFactory = require("./pluginFactory");
6
- (0, _fs2.setFileSystem)({
7
- readFile: _fs.readFile,
8
- writeFile: _fs.writeFile
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
9
4
  });
10
- module.exports = (opts = {}) => (0, _pluginFactory.makePlugin)(opts);
11
- module.exports.postcss = true;
5
+ const _fs = require("fs");
6
+ const _fs1 = require("./fs");
7
+ const _pluginFactory = require("./pluginFactory");
8
+ (0, _fs1.setFileSystem)({
9
+ readFile: _fs.readFile,
10
+ writeFile: _fs.writeFile
11
+ });
12
+ module.exports = (opts = {})=>(0, _pluginFactory.makePlugin)(opts);
13
+ module.exports.postcss = true;
@@ -1,38 +1,58 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.makeLocalsConventionReducer = makeLocalsConventionReducer;
7
- var _lodash = _interopRequireDefault(require("lodash.camelcase"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
5
+ Object.defineProperty(exports, "makeLocalsConventionReducer", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return makeLocalsConventionReducer;
9
+ }
10
+ });
11
+ const _lodashcamelcase = /*#__PURE__*/ _interop_require_default(require("lodash.camelcase"));
12
+ function _interop_require_default(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
9
17
  function dashesCamelCase(string) {
10
- return string.replace(/-+(\w)/g, (_, firstLetter) => firstLetter.toUpperCase());
18
+ return string.replace(/-+(\w)/g, (_, firstLetter)=>firstLetter.toUpperCase());
11
19
  }
12
20
  function makeLocalsConventionReducer(localsConvention, inputFile) {
13
- const isFunc = typeof localsConvention === "function";
14
- return (tokens, [className, value]) => {
15
- if (isFunc) {
16
- const convention = localsConvention(className, value, inputFile);
17
- tokens[convention] = value;
18
- return tokens;
19
- }
20
- switch (localsConvention) {
21
- case "camelCase":
22
- tokens[className] = value;
23
- tokens[(0, _lodash.default)(className)] = value;
24
- break;
25
- case "camelCaseOnly":
26
- tokens[(0, _lodash.default)(className)] = value;
27
- break;
28
- case "dashes":
29
- tokens[className] = value;
30
- tokens[dashesCamelCase(className)] = value;
31
- break;
32
- case "dashesOnly":
33
- tokens[dashesCamelCase(className)] = value;
34
- break;
35
- }
36
- return tokens;
37
- };
38
- }
21
+ const isFunc = typeof localsConvention === "function";
22
+ return (tokens, [className, value])=>{
23
+ if (isFunc) {
24
+ const convention = localsConvention(className, value, inputFile);
25
+ if (Array.isArray(convention)) {
26
+ convention.forEach((name)=>tokens[name] = value);
27
+ return tokens;
28
+ }
29
+ tokens[convention] = value;
30
+ return tokens;
31
+ }
32
+ switch(localsConvention){
33
+ case "none":
34
+ tokens[className] = value;
35
+ break;
36
+ case "all":
37
+ tokens[className] = value;
38
+ tokens[(0, _lodashcamelcase.default)(className)] = value;
39
+ tokens[dashesCamelCase(className)] = value;
40
+ break;
41
+ case "camelCase":
42
+ tokens[className] = value;
43
+ tokens[(0, _lodashcamelcase.default)(className)] = value;
44
+ break;
45
+ case "camelCaseOnly":
46
+ tokens[(0, _lodashcamelcase.default)(className)] = value;
47
+ break;
48
+ case "dashes":
49
+ tokens[className] = value;
50
+ tokens[dashesCamelCase(className)] = value;
51
+ break;
52
+ case "dashesOnly":
53
+ tokens[dashesCamelCase(className)] = value;
54
+ break;
55
+ }
56
+ return tokens;
57
+ };
58
+ }
@@ -1,84 +1,95 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.makePlugin = makePlugin;
7
- var _postcss = _interopRequireDefault(require("postcss"));
8
- var _unquote = _interopRequireDefault(require("./unquote"));
9
- var _Parser = _interopRequireDefault(require("./Parser"));
10
- var _saveJSON = _interopRequireDefault(require("./saveJSON"));
11
- var _localsConvention = require("./localsConvention");
12
- var _FileSystemLoader = _interopRequireDefault(require("./FileSystemLoader"));
13
- var _scoping = require("./scoping");
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
5
+ Object.defineProperty(exports, "makePlugin", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return makePlugin;
9
+ }
10
+ });
11
+ const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
12
+ const _unquote = /*#__PURE__*/ _interop_require_default(require("./unquote"));
13
+ const _Parser = /*#__PURE__*/ _interop_require_default(require("./Parser"));
14
+ const _saveJSON = /*#__PURE__*/ _interop_require_default(require("./saveJSON"));
15
+ const _localsConvention = require("./localsConvention");
16
+ const _FileSystemLoader = /*#__PURE__*/ _interop_require_default(require("./FileSystemLoader"));
17
+ const _scoping = require("./scoping");
18
+ function _interop_require_default(obj) {
19
+ return obj && obj.__esModule ? obj : {
20
+ default: obj
21
+ };
22
+ }
15
23
  const PLUGIN_NAME = "postcss-modules";
16
24
  function isGlobalModule(globalModules, inputFile) {
17
- return globalModules.some(regex => inputFile.match(regex));
25
+ return globalModules.some((regex)=>inputFile.match(regex));
18
26
  }
19
27
  function getDefaultPluginsList(opts, inputFile) {
20
- const globalModulesList = opts.globalModulePaths || null;
21
- const exportGlobals = opts.exportGlobals || false;
22
- const defaultBehaviour = (0, _scoping.getDefaultScopeBehaviour)(opts.scopeBehaviour);
23
- const generateScopedName = (0, _scoping.getScopedNameGenerator)(opts.generateScopedName, opts.hashPrefix);
24
- if (globalModulesList && isGlobalModule(globalModulesList, inputFile)) {
28
+ const globalModulesList = opts.globalModulePaths || null;
29
+ const exportGlobals = opts.exportGlobals || false;
30
+ const defaultBehaviour = (0, _scoping.getDefaultScopeBehaviour)(opts.scopeBehaviour);
31
+ const generateScopedName = (0, _scoping.getScopedNameGenerator)(opts.generateScopedName, opts.hashPrefix);
32
+ if (globalModulesList && isGlobalModule(globalModulesList, inputFile)) {
33
+ return (0, _scoping.getDefaultPlugins)({
34
+ behaviour: _scoping.behaviours.GLOBAL,
35
+ generateScopedName,
36
+ exportGlobals
37
+ });
38
+ }
25
39
  return (0, _scoping.getDefaultPlugins)({
26
- behaviour: _scoping.behaviours.GLOBAL,
27
- generateScopedName,
28
- exportGlobals
40
+ behaviour: defaultBehaviour,
41
+ generateScopedName,
42
+ exportGlobals
29
43
  });
30
- }
31
- return (0, _scoping.getDefaultPlugins)({
32
- behaviour: defaultBehaviour,
33
- generateScopedName,
34
- exportGlobals
35
- });
36
44
  }
37
45
  function getLoader(opts, plugins) {
38
- const root = typeof opts.root === "undefined" ? "/" : opts.root;
39
- return typeof opts.Loader === "function" ? new opts.Loader(root, plugins, opts.resolve) : new _FileSystemLoader.default(root, plugins, opts.resolve);
46
+ const root = typeof opts.root === "undefined" ? "/" : opts.root;
47
+ return typeof opts.Loader === "function" ? new opts.Loader(root, plugins, opts.resolve) : new _FileSystemLoader.default(root, plugins, opts.resolve);
40
48
  }
41
49
  function isOurPlugin(plugin) {
42
- return plugin.postcssPlugin === PLUGIN_NAME;
50
+ return plugin.postcssPlugin === PLUGIN_NAME;
43
51
  }
44
52
  function makePlugin(opts) {
45
- return {
46
- postcssPlugin: PLUGIN_NAME,
47
- async OnceExit(css, {
48
- result
49
- }) {
50
- const getJSON = opts.getJSON || _saveJSON.default;
51
- const inputFile = css.source.input.file;
52
- const pluginList = getDefaultPluginsList(opts, inputFile);
53
- const resultPluginIndex = result.processor.plugins.findIndex(plugin => isOurPlugin(plugin));
54
- if (resultPluginIndex === -1) {
55
- throw new Error("Plugin missing from options.");
56
- }
57
- const earlierPlugins = result.processor.plugins.slice(0, resultPluginIndex);
58
- const loaderPlugins = [...earlierPlugins, ...pluginList];
59
- const loader = getLoader(opts, loaderPlugins);
60
- const fetcher = async (file, relativeTo, depTrace) => {
61
- const unquoteFile = (0, _unquote.default)(file);
62
- return loader.fetch.call(loader, unquoteFile, relativeTo, depTrace);
63
- };
64
- const parser = new _Parser.default(fetcher);
65
- await (0, _postcss.default)([...pluginList, parser.plugin()]).process(css, {
66
- from: inputFile
67
- });
68
- const out = loader.finalSource;
69
- if (out) css.prepend(out);
70
- if (opts.localsConvention) {
71
- const reducer = (0, _localsConvention.makeLocalsConventionReducer)(opts.localsConvention, inputFile);
72
- parser.exportTokens = Object.entries(parser.exportTokens).reduce(reducer, {});
73
- }
74
- result.messages.push({
75
- type: "export",
76
- plugin: "postcss-modules",
77
- exportTokens: parser.exportTokens
78
- });
79
-
80
- // getJSON may return a promise
81
- return getJSON(css.source.input.file, parser.exportTokens, result.opts.to);
82
- }
83
- };
84
- }
53
+ return {
54
+ postcssPlugin: PLUGIN_NAME,
55
+ async OnceExit (css, { result }) {
56
+ const getJSON = opts.getJSON || _saveJSON.default;
57
+ const inputFile = css.source.input.file;
58
+ const pluginList = getDefaultPluginsList(opts, inputFile);
59
+ const resultPluginIndex = result.processor.plugins.findIndex((plugin)=>isOurPlugin(plugin));
60
+ if (resultPluginIndex === -1) {
61
+ throw new Error("Plugin missing from options.");
62
+ }
63
+ const earlierPlugins = result.processor.plugins.slice(0, resultPluginIndex);
64
+ const loaderPlugins = [
65
+ ...earlierPlugins,
66
+ ...pluginList
67
+ ];
68
+ const loader = getLoader(opts, loaderPlugins);
69
+ const fetcher = async (file, relativeTo, depTrace)=>{
70
+ const unquoteFile = (0, _unquote.default)(file);
71
+ return loader.fetch.call(loader, unquoteFile, relativeTo, depTrace);
72
+ };
73
+ const parser = new _Parser.default(fetcher);
74
+ await (0, _postcss.default)([
75
+ ...pluginList,
76
+ parser.plugin()
77
+ ]).process(css, {
78
+ from: inputFile
79
+ });
80
+ const out = loader.finalSource;
81
+ if (out) css.prepend(out);
82
+ if (opts.localsConvention) {
83
+ const reducer = (0, _localsConvention.makeLocalsConventionReducer)(opts.localsConvention, inputFile);
84
+ parser.exportTokens = Object.entries(parser.exportTokens).reduce(reducer, {});
85
+ }
86
+ result.messages.push({
87
+ type: "export",
88
+ plugin: "postcss-modules",
89
+ exportTokens: parser.exportTokens
90
+ });
91
+ // getJSON may return a promise
92
+ return getJSON(css.source.input.file, parser.exportTokens, result.opts.to);
93
+ }
94
+ };
95
+ }
package/build/saveJSON.js CHANGED
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.default = saveJSON;
7
- var _fs = require("./fs");
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return saveJSON;
9
+ }
10
+ });
11
+ const _fs = require("./fs");
8
12
  function saveJSON(cssFile, json) {
9
- return new Promise((resolve, reject) => {
10
- const {
11
- writeFile
12
- } = (0, _fs.getFileSystem)();
13
- writeFile(`${cssFile}.json`, JSON.stringify(json), e => e ? reject(e) : resolve(json));
14
- });
15
- }
13
+ return new Promise((resolve, reject)=>{
14
+ const { writeFile } = (0, _fs.getFileSystem)();
15
+ writeFile(`${cssFile}.json`, JSON.stringify(json), (e)=>e ? reject(e) : resolve(json));
16
+ });
17
+ }
package/build/scoping.js CHANGED
@@ -1,61 +1,86 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.behaviours = void 0;
7
- exports.getDefaultPlugins = getDefaultPlugins;
8
- exports.getDefaultScopeBehaviour = getDefaultScopeBehaviour;
9
- exports.getScopedNameGenerator = getScopedNameGenerator;
10
- var _postcssModulesExtractImports = _interopRequireDefault(require("postcss-modules-extract-imports"));
11
- var _genericNames = _interopRequireDefault(require("generic-names"));
12
- var _postcssModulesLocalByDefault = _interopRequireDefault(require("postcss-modules-local-by-default"));
13
- var _postcssModulesScope = _interopRequireDefault(require("postcss-modules-scope"));
14
- var _stringHash = _interopRequireDefault(require("string-hash"));
15
- var _postcssModulesValues = _interopRequireDefault(require("postcss-modules-values"));
16
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
- const behaviours = exports.behaviours = {
18
- LOCAL: "local",
19
- GLOBAL: "global"
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get behaviours () {
13
+ return behaviours;
14
+ },
15
+ get getDefaultPlugins () {
16
+ return getDefaultPlugins;
17
+ },
18
+ get getDefaultScopeBehaviour () {
19
+ return getDefaultScopeBehaviour;
20
+ },
21
+ get getScopedNameGenerator () {
22
+ return getScopedNameGenerator;
23
+ }
24
+ });
25
+ const _postcssmodulesextractimports = /*#__PURE__*/ _interop_require_default(require("postcss-modules-extract-imports"));
26
+ const _genericnames = /*#__PURE__*/ _interop_require_default(require("generic-names"));
27
+ const _postcssmoduleslocalbydefault = /*#__PURE__*/ _interop_require_default(require("postcss-modules-local-by-default"));
28
+ const _postcssmodulesscope = /*#__PURE__*/ _interop_require_default(require("postcss-modules-scope"));
29
+ const _stringhash = /*#__PURE__*/ _interop_require_default(require("string-hash"));
30
+ const _postcssmodulesvalues = /*#__PURE__*/ _interop_require_default(require("postcss-modules-values"));
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ const behaviours = {
37
+ LOCAL: "local",
38
+ GLOBAL: "global"
20
39
  };
21
- function getDefaultPlugins({
22
- behaviour,
23
- generateScopedName,
24
- exportGlobals
25
- }) {
26
- const scope = (0, _postcssModulesScope.default)({
27
- generateScopedName,
28
- exportGlobals
29
- });
30
- const plugins = {
31
- [behaviours.LOCAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
32
- mode: "local"
33
- }), _postcssModulesExtractImports.default, scope],
34
- [behaviours.GLOBAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
35
- mode: "global"
36
- }), _postcssModulesExtractImports.default, scope]
37
- };
38
- return plugins[behaviour];
40
+ function getDefaultPlugins({ behaviour, generateScopedName, exportGlobals }) {
41
+ const scope = (0, _postcssmodulesscope.default)({
42
+ generateScopedName,
43
+ exportGlobals
44
+ });
45
+ const plugins = {
46
+ [behaviours.LOCAL]: [
47
+ _postcssmodulesvalues.default,
48
+ (0, _postcssmoduleslocalbydefault.default)({
49
+ mode: "local"
50
+ }),
51
+ _postcssmodulesextractimports.default,
52
+ scope
53
+ ],
54
+ [behaviours.GLOBAL]: [
55
+ _postcssmodulesvalues.default,
56
+ (0, _postcssmoduleslocalbydefault.default)({
57
+ mode: "global"
58
+ }),
59
+ _postcssmodulesextractimports.default,
60
+ scope
61
+ ]
62
+ };
63
+ return plugins[behaviour];
39
64
  }
40
65
  function isValidBehaviour(behaviour) {
41
- return Object.keys(behaviours).map(key => behaviours[key]).indexOf(behaviour) > -1;
66
+ return Object.keys(behaviours).map((key)=>behaviours[key]).indexOf(behaviour) > -1;
42
67
  }
43
68
  function getDefaultScopeBehaviour(scopeBehaviour) {
44
- return scopeBehaviour && isValidBehaviour(scopeBehaviour) ? scopeBehaviour : behaviours.LOCAL;
69
+ return scopeBehaviour && isValidBehaviour(scopeBehaviour) ? scopeBehaviour : behaviours.LOCAL;
45
70
  }
46
71
  function generateScopedNameDefault(name, filename, css) {
47
- const i = css.indexOf(`.${name}`);
48
- const lineNumber = css.substr(0, i).split(/[\r\n]/).length;
49
- const hash = (0, _stringHash.default)(css).toString(36).substr(0, 5);
50
- return `_${name}_${hash}_${lineNumber}`;
72
+ const i = css.indexOf(`.${name}`);
73
+ const lineNumber = css.substr(0, i).split(/[\r\n]/).length;
74
+ const hash = (0, _stringhash.default)(css).toString(36).substr(0, 5);
75
+ return `_${name}_${hash}_${lineNumber}`;
51
76
  }
52
77
  function getScopedNameGenerator(generateScopedName, hashPrefix) {
53
- const scopedNameGenerator = generateScopedName || generateScopedNameDefault;
54
- if (typeof scopedNameGenerator === "function") {
55
- return scopedNameGenerator;
56
- }
57
- return (0, _genericNames.default)(scopedNameGenerator, {
58
- context: process.cwd(),
59
- hashPrefix: hashPrefix
60
- });
61
- }
78
+ const scopedNameGenerator = generateScopedName || generateScopedNameDefault;
79
+ if (typeof scopedNameGenerator === "function") {
80
+ return scopedNameGenerator;
81
+ }
82
+ return (0, _genericnames.default)(scopedNameGenerator, {
83
+ context: process.cwd(),
84
+ hashPrefix: hashPrefix
85
+ });
86
+ }