@uxf/icons-generator 11.24.2 → 11.45.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/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
- "name": "@uxf/icons-generator",
3
- "version": "11.24.2",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {
7
- "build": "npm run-script clean && npm run-script compile",
8
- "clean": "rm -rf ./dist",
9
- "compile": "tsc -P tsconfig.json",
10
- "test": "NODE_MODULES_PATH=../../node_modules ts-node ./bin/icons-gen.ts --configFile=tests/icons.config.js",
11
- "typecheck": "tsc --noEmit --skipLibCheck"
12
- },
13
- "publishConfig": {
14
- "access": "public"
15
- },
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://gitlab.com/uxf-npm/icons-generator.git"
19
- },
20
- "dependencies": {
21
- "fast-xml-parser": "4.3.5"
22
- },
23
- "author": "",
24
- "license": "ISC",
25
- "bin": {
26
- "icons-gen": "./bin/icons-gen.js"
27
- },
28
- "bugs": {
29
- "url": "https://gitlab.com/uxf-npm/icons-generator/issues"
30
- },
31
- "homepage": "https://gitlab.com/uxf-npm/icons-generator#readme",
32
- "devDependencies": {
33
- "@fortawesome/fontawesome-pro": "^6.5.2"
34
- }
35
- }
2
+ "name": "@uxf/icons-generator",
3
+ "version": "11.45.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "build": "npm run-script clean && npm run-script compile",
8
+ "clean": "rm -rf ./dist",
9
+ "compile": "tsc -P tsconfig.json",
10
+ "test": "NODE_MODULES_PATH=../../node_modules ts-node ./bin/icons-gen.ts --configFile=tests/icons.config.js",
11
+ "typecheck": "tsc --noEmit --skipLibCheck"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://gitlab.com/uxf-npm/icons-generator.git"
19
+ },
20
+ "dependencies": {
21
+ "fast-xml-parser": "4.5.0"
22
+ },
23
+ "author": "",
24
+ "license": "ISC",
25
+ "bin": {
26
+ "icons-gen": "./bin/icons-gen.js"
27
+ },
28
+ "bugs": {
29
+ "url": "https://gitlab.com/uxf-npm/icons-generator/issues"
30
+ },
31
+ "homepage": "https://gitlab.com/uxf-npm/icons-generator#readme",
32
+ "devDependencies": {
33
+ "@fortawesome/fontawesome-pro": "6.5.2"
34
+ }
35
+ }
@@ -2,6 +2,7 @@
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.faPro = void 0;
5
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
5
6
  const fs_1 = require("fs");
6
7
  const _generateAdapterFallback_1 = require("../utils/_generateAdapterFallback");
7
8
  const _getIconNameForProvider_1 = require("../utils/_getIconNameForProvider");
@@ -12,8 +13,9 @@ const addFillAttribute = (str) => str.replace(/\/>/g, ' fill="currentColor"/>');
12
13
  const parseDimensions = (str) => {
13
14
  const viewBox = str.match(/viewBox="([^"]*)"/);
14
15
  let width, height;
15
- if (viewBox && viewBox[1]) {
16
- [, , width, height] = viewBox[1].split(" ");
16
+ const viewBoxValue = viewBox === null || viewBox === void 0 ? void 0 : viewBox.at(1);
17
+ if ((0, is_not_nil_1.isNotNil)(viewBoxValue)) {
18
+ [, , width, height] = viewBoxValue.split(" ");
17
19
  }
18
20
  if (!width || !height) {
19
21
  throw new Error("Can't parse width or height.");
@@ -38,6 +40,7 @@ const getIcon = (iconName, config) => {
38
40
  const fileContent = (0, fs_1.readFileSync)(fallbackPath).toString();
39
41
  const icon = JSON.parse(fileContent)[iconName];
40
42
  return { width: Number(icon.width), height: Number(icon.height), path: decodeURIComponent(icon.path) };
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
44
  }
42
45
  catch (e) {
43
46
  throw new Error(`Can't find icon "${iconName}" in "${KEY}" fallback file.`);
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
3
4
  const _generateDefinitionFile_1 = require("../utils/_generateDefinitionFile");
4
5
  const _generateSeparateIconFiles_1 = require("../utils/_generateSeparateIconFiles");
5
6
  const _generateSpriteFile_1 = require("../utils/_generateSpriteFile");
@@ -17,4 +18,3 @@ function default_1(config) {
17
18
  (0, _generateSeparateIconFiles_1._generateSeparateIconFiles)(config);
18
19
  console.log("Separate icons generated.");
19
20
  }
20
- exports.default = default_1;
package/src/types.d.ts CHANGED
@@ -10,15 +10,6 @@ export type SimpleIcon = {
10
10
  width: number;
11
11
  };
12
12
  export type SizedIcon = Record<number, string>;
13
- export type IconFromProviderFunction = (config: _IconsConfig) => {
14
- width: number;
15
- height: number;
16
- path: string;
17
- };
18
- export type IconProvider<T extends string> = {
19
- adapter: (icons: T[]) => Record<string, IconFromProviderFunction>;
20
- icon: (iconName: T) => IconFromProviderFunction;
21
- };
22
13
  type IconsByMode = {
23
14
  icons: Record<string, SimpleIcon | SizedIcon | IconFromProviderFunction>;
24
15
  };
@@ -37,6 +28,15 @@ export type _IconsConfig = {
37
28
  typeName: string;
38
29
  typescript: boolean;
39
30
  } & IconsByMode;
31
+ export type IconFromProviderFunction = (config: _IconsConfig) => {
32
+ width: number;
33
+ height: number;
34
+ path: string;
35
+ };
36
+ export type IconProvider<T extends string> = {
37
+ adapter: (icons: T[]) => Record<string, IconFromProviderFunction>;
38
+ icon: (iconName: T) => IconFromProviderFunction;
39
+ };
40
40
  export type IconsConfig = {
41
41
  configDirectory?: string;
42
42
  customDefinitionContent?: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._createDefinitionFileContent = void 0;
3
+ exports._createDefinitionFileContent = _createDefinitionFileContent;
4
4
  const _iconTypeResolver_1 = require("./_iconTypeResolver");
5
5
  const get_md5_from_file_1 = require("./get-md5-from-file");
6
6
  function _createDefinitionFileContent(config) {
@@ -41,4 +41,3 @@ ${iconNames.map((iconName) => ` "${iconName}": true;`).join("\n")}
41
41
  }
42
42
  ${config.customDefinitionContent ? `\n${config.customDefinitionContent}\n` : ""}`;
43
43
  }
44
- exports._createDefinitionFileContent = _createDefinitionFileContent;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._createIconContent = void 0;
3
+ exports._createIconContent = _createIconContent;
4
4
  function _createIconContent({ width, height, content }) {
5
5
  return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}">${content}</svg>`;
6
6
  }
7
- exports._createIconContent = _createIconContent;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._createPath = void 0;
3
+ exports._createPath = _createPath;
4
4
  const fs_1 = require("fs");
5
5
  function _createPath(path, isFile = true) {
6
6
  const arr = path.split("/");
@@ -12,4 +12,3 @@ function _createPath(path, isFile = true) {
12
12
  (0, fs_1.mkdirSync)(dirPath, { recursive: true });
13
13
  }
14
14
  }
15
- exports._createPath = _createPath;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._createSpriteContent = void 0;
3
+ exports._createSpriteContent = _createSpriteContent;
4
4
  const _iconTypeResolver_1 = require("./_iconTypeResolver");
5
5
  function _createSpriteContent(config) {
6
6
  let spriteTextContent = `<svg xmlns="http://www.w3.org/2000/svg">`;
@@ -29,4 +29,3 @@ function _createSpriteContent(config) {
29
29
  spriteTextContent += `</svg>`;
30
30
  return spriteTextContent;
31
31
  }
32
- exports._createSpriteContent = _createSpriteContent;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._generateAdapterFallback = void 0;
3
+ exports._generateAdapterFallback = _generateAdapterFallback;
4
4
  const fs_1 = require("fs");
5
5
  const _createPath_1 = require("./_createPath");
6
6
  function _generateAdapterFallback(key, iconName, iconDefinition, config) {
@@ -12,4 +12,3 @@ function _generateAdapterFallback(key, iconName, iconDefinition, config) {
12
12
  content[iconName] = iconDefinition;
13
13
  (0, fs_1.writeFileSync)(filePath, JSON.stringify(content));
14
14
  }
15
- exports._generateAdapterFallback = _generateAdapterFallback;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._generateDefinitionFile = void 0;
3
+ exports._generateDefinitionFile = _generateDefinitionFile;
4
4
  const fs_1 = require("fs");
5
5
  const _createDefinitionFileContent_1 = require("./_createDefinitionFileContent");
6
6
  const _createPath_1 = require("./_createPath");
@@ -9,4 +9,3 @@ function _generateDefinitionFile(config) {
9
9
  (0, _createPath_1._createPath)(config.definitionFile);
10
10
  (0, fs_1.writeFileSync)(config.definitionFile, newIcons);
11
11
  }
12
- exports._generateDefinitionFile = _generateDefinitionFile;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._generateSeparateIconFiles = void 0;
3
+ exports._generateSeparateIconFiles = _generateSeparateIconFiles;
4
4
  const fs_1 = require("fs");
5
5
  const _createIconContent_1 = require("./_createIconContent");
6
6
  const _createPath_1 = require("./_createPath");
@@ -39,4 +39,3 @@ function _generateSeparateIconFiles(config) {
39
39
  throw new Error("Unknown icon format.");
40
40
  });
41
41
  }
42
- exports._generateSeparateIconFiles = _generateSeparateIconFiles;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._generateSpriteFile = void 0;
3
+ exports._generateSpriteFile = _generateSpriteFile;
4
4
  const fs_1 = require("fs");
5
5
  const _createPath_1 = require("./_createPath");
6
6
  const _createSpriteContent_1 = require("./_createSpriteContent");
@@ -8,4 +8,3 @@ function _generateSpriteFile(config) {
8
8
  (0, _createPath_1._createPath)(config.configFile);
9
9
  (0, fs_1.writeFileSync)(config.spriteFile, (0, _createSpriteContent_1._createSpriteContent)(config));
10
10
  }
11
- exports._generateSpriteFile = _generateSpriteFile;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._getConfig = void 0;
3
+ exports._getConfig = _getConfig;
4
+ const empty_object_1 = require("@uxf/core/constants/empty-object");
4
5
  function _getModuleDefinition(data) {
5
6
  if (!data) {
6
7
  return undefined;
@@ -12,17 +13,17 @@ function _getModuleDefinition(data) {
12
13
  };
13
14
  }
14
15
  function _getConfig(confFile) {
15
- /* eslint-disable-next-line @typescript-eslint/no-var-requires */
16
+ /* eslint-disable-next-line @typescript-eslint/no-require-imports */
16
17
  const loadedConfig = require(process.cwd() + "/" + confFile);
17
18
  const config = {
18
19
  configDirectory: loadedConfig.configDirectory || "/src/config/",
19
- icons: loadedConfig.icons || {},
20
+ icons: loadedConfig.icons || empty_object_1.EMPTY_OBJECT,
20
21
  spriteFileName: loadedConfig.spriteFileName || "_icon-sprite.svg",
21
22
  typeName: loadedConfig.typeName || "IconsSet",
22
23
  typescript: loadedConfig.typescript || true,
23
24
  customDefinitionContent: loadedConfig.customDefinitionContent || undefined,
24
25
  moduleDefinition: _getModuleDefinition(loadedConfig.moduleDefinition),
25
- adapters: loadedConfig.adapters || {},
26
+ adapters: loadedConfig.adapters || empty_object_1.EMPTY_OBJECT,
26
27
  };
27
28
  const ext = config.typescript ? "ts" : "js";
28
29
  const fallbackFilesDirectory = process.cwd() + config.configDirectory + `icons-fallbacks/`;
@@ -42,4 +43,3 @@ function _getConfig(confFile) {
42
43
  spriteFile,
43
44
  };
44
45
  }
45
- exports._getConfig = _getConfig;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._removeUnusedSeparateIconFiles = void 0;
3
+ exports._removeUnusedSeparateIconFiles = _removeUnusedSeparateIconFiles;
4
4
  const fs_1 = require("fs");
5
5
  const _createPath_1 = require("./_createPath");
6
6
  function _removeUnusedSeparateIconFiles(config) {
@@ -13,4 +13,3 @@ function _removeUnusedSeparateIconFiles(config) {
13
13
  }
14
14
  });
15
15
  }
16
- exports._removeUnusedSeparateIconFiles = _removeUnusedSeparateIconFiles;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._validateSourceData = void 0;
3
+ exports._validateSourceData = _validateSourceData;
4
4
  const fast_xml_parser_1 = require("fast-xml-parser");
5
5
  const _iconTypeResolver_1 = require("./_iconTypeResolver");
6
6
  function _validateSourceData(config) {
@@ -30,4 +30,3 @@ function _validateSourceData(config) {
30
30
  throw new Error("Unknown icon format.");
31
31
  });
32
32
  }
33
- exports._validateSourceData = _validateSourceData;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getMd5FromFile = void 0;
6
+ exports.getMd5FromFile = getMd5FromFile;
7
7
  const crypto_1 = __importDefault(require("crypto"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  function getMd5FromFile(filename) {
@@ -12,4 +12,3 @@ function getMd5FromFile(filename) {
12
12
  hashSum.update(fileBuffer);
13
13
  return hashSum.digest("hex");
14
14
  }
15
- exports.getMd5FromFile = getMd5FromFile;