@uxf/icons-generator 11.15.1 → 11.23.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.
@@ -0,0 +1,3 @@
1
+ import type { FaProIconName } from "../fa-pro-types";
2
+ import { type IconProvider } from "../types";
3
+ export declare const faPro: IconProvider<FaProIconName>;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getFaProIcon = void 0;
4
+ exports.faPro = void 0;
5
5
  const fs_1 = require("fs");
6
+ const _generateAdapterFallback_1 = require("../utils/_generateAdapterFallback");
7
+ const _getIconNameForProvider_1 = require("../utils/_getIconNameForProvider");
8
+ const KEY = "faPro";
6
9
  const removeComments = (str) => str.replace(/<!--([\s\S]*?)-->/g, "");
7
10
  const removeSvg = (str) => str.replace(/<svg[^>]*>/, "").replace(/<\/svg>/, "");
8
11
  const addFillAttribute = (str) => str.replace(/\/>/g, ' fill="currentColor"/>');
@@ -15,10 +18,10 @@ const parseDimensions = (str) => {
15
18
  if (!width || !height) {
16
19
  throw new Error("Can't parse width or height.");
17
20
  }
18
- return { width, height };
21
+ return { width: Number(width), height: Number(height) };
19
22
  };
20
23
  const NODE_MODULES_PATH = (_a = process.env.NODE_MODULES_PATH) !== null && _a !== void 0 ? _a : "./node_modules";
21
- const getFaProIcon = (adapterKey) => (iconName, config) => {
24
+ const getIcon = (iconName, config) => {
22
25
  if ((0, fs_1.existsSync)(NODE_MODULES_PATH + "/@fortawesome/fontawesome-pro")) {
23
26
  const [namespace, icon] = iconName.split(".");
24
27
  let svg = (0, fs_1.readFileSync)(`${NODE_MODULES_PATH}/@fortawesome/fontawesome-pro/svgs/${namespace}/${icon}.svg`).toString();
@@ -26,16 +29,26 @@ const getFaProIcon = (adapterKey) => (iconName, config) => {
26
29
  const { width, height } = parseDimensions(svg);
27
30
  svg = removeSvg(svg);
28
31
  svg = addFillAttribute(svg);
29
- return { width, height, path: svg };
32
+ const iconDefinition = { width, height, path: svg };
33
+ (0, _generateAdapterFallback_1._generateAdapterFallback)(KEY, iconName, iconDefinition, config);
34
+ return iconDefinition;
30
35
  }
31
36
  try {
32
- const fallbackPath = config.fallbackFilesDirectory + adapterKey + ".json";
37
+ const fallbackPath = config.fallbackFilesDirectory + KEY + ".json";
33
38
  const fileContent = (0, fs_1.readFileSync)(fallbackPath).toString();
34
39
  const icon = JSON.parse(fileContent)[iconName];
35
- return { width: icon.width, height: icon.height, path: decodeURIComponent(icon.path) };
40
+ return { width: Number(icon.width), height: Number(icon.height), path: decodeURIComponent(icon.path) };
36
41
  }
37
42
  catch (e) {
38
- throw new Error(`Can't find icon "${iconName}" in "${adapterKey}" fallback file.`);
43
+ throw new Error(`Can't find icon "${iconName}" in "${KEY}" fallback file.`);
39
44
  }
40
45
  };
41
- exports.getFaProIcon = getFaProIcon;
46
+ const icon = (iconName) => (config) => getIcon(iconName, config);
47
+ exports.faPro = {
48
+ icon(iconName) {
49
+ return (config) => getIcon(iconName, config);
50
+ },
51
+ adapter(icons) {
52
+ return Object.fromEntries(icons.map((iconName) => [(0, _getIconNameForProvider_1._getIconNameForProvider)(KEY, iconName), icon(iconName)]));
53
+ },
54
+ };
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const _generateAdaptersFallbackFiles_1 = require("../utils/_generateAdaptersFallbackFiles");
4
3
  const _generateDefinitionFile_1 = require("../utils/_generateDefinitionFile");
5
4
  const _generateSeparateIconFiles_1 = require("../utils/_generateSeparateIconFiles");
6
5
  const _generateSpriteFile_1 = require("../utils/_generateSpriteFile");
@@ -17,7 +16,5 @@ function default_1(config) {
17
16
  console.log("Removed unused separate icon files.");
18
17
  (0, _generateSeparateIconFiles_1._generateSeparateIconFiles)(config);
19
18
  console.log("Separate icons generated.");
20
- (0, _generateAdaptersFallbackFiles_1._generateAdaptersFallbackFiles)(config);
21
- console.log("Fallback files for adapters was generated.");
22
19
  }
23
20
  exports.default = default_1;
package/src/types.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export type Mode = "simple" | "sizes";
2
1
  export type ModuleDefinitionFormat = "type" | "interface";
3
2
  export type ModuleDefinition = {
4
3
  moduleName: string;
@@ -11,25 +10,19 @@ export type SimpleIcon = {
11
10
  width: number;
12
11
  };
13
12
  export type SizedIcon = Record<number, string>;
14
- type IconsByMode = {
15
- icons: Record<string, SimpleIcon>;
16
- mode: "simple";
17
- } | {
18
- icons: Record<string, SizedIcon>;
19
- mode: "sizes";
13
+ export type IconFromProviderFunction = (config: _IconsConfig) => {
14
+ width: number;
15
+ height: number;
16
+ path: string;
20
17
  };
21
- export type AdapterType<T extends string> = {
22
- icons: T[];
23
- getIcon: (iconName: T, config: _IconsConfig<Record<any, any>>) => {
24
- width: number;
25
- height: number;
26
- path: string;
27
- };
18
+ export type IconProvider<T extends string> = {
19
+ adapter: (icons: T[]) => Record<string, IconFromProviderFunction>;
20
+ icon: (iconName: T) => IconFromProviderFunction;
21
+ };
22
+ type IconsByMode = {
23
+ icons: Record<string, SimpleIcon | SizedIcon | IconFromProviderFunction>;
28
24
  };
29
- export type AdaptersType<T extends Record<string, string>> = Record<keyof T, {
30
- [K in keyof T]: AdapterType<T[K]>;
31
- }[keyof T]>;
32
- export type _IconsConfig<T extends Record<string, string> = Record<string, string>> = {
25
+ export type _IconsConfig = {
33
26
  configDirectory: string;
34
27
  configFile: string;
35
28
  customDefinitionContent?: string;
@@ -43,9 +36,8 @@ export type _IconsConfig<T extends Record<string, string> = Record<string, strin
43
36
  spriteFileName: string;
44
37
  typeName: string;
45
38
  typescript: boolean;
46
- adapters?: AdaptersType<T>;
47
39
  } & IconsByMode;
48
- export type IconsConfig<T extends Record<string, string> = Record<string, string>> = {
40
+ export type IconsConfig = {
49
41
  configDirectory?: string;
50
42
  customDefinitionContent?: string;
51
43
  moduleDefinition?: ModuleDefinition;
@@ -53,7 +45,6 @@ export type IconsConfig<T extends Record<string, string> = Record<string, string
53
45
  spriteFileName?: string;
54
46
  typeName?: string;
55
47
  typescript?: boolean;
56
- adapters?: AdaptersType<T>;
57
48
  } & (IconsByMode | {
58
49
  icons?: never;
59
50
  mode?: never;
@@ -1,27 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._createDefinitionFileContent = void 0;
4
- const _getIconFromAdapterName_1 = require("./_getIconFromAdapterName");
4
+ const _iconTypeResolver_1 = require("./_iconTypeResolver");
5
5
  const get_md5_from_file_1 = require("./get-md5-from-file");
6
6
  function _createDefinitionFileContent(config) {
7
- var _a;
8
7
  const iconDefinitions = [];
9
8
  const iconNames = [];
10
9
  Object.keys(config.icons).map((name) => {
11
10
  iconNames.push(name);
12
- iconDefinitions.push(config.mode === "sizes"
13
- ? ` "${name}": [${Object.keys(config.icons[name]).join(", ")}],`
14
- : ` "${name}": { w: ${config.icons[name].width}, h: ${config.icons[name].height} },`);
11
+ const icon = config.icons[name];
12
+ if (_iconTypeResolver_1._iconTypeResolver.isSimpleIcon(icon)) {
13
+ iconDefinitions.push(` "${name}": { w: ${icon.width}, h: ${icon.height} },`);
14
+ return;
15
+ }
16
+ if (_iconTypeResolver_1._iconTypeResolver.isSizedIcon(icon)) {
17
+ iconDefinitions.push(` "${name}": [${Object.keys(icon).join(", ")}],`);
18
+ return;
19
+ }
20
+ if (_iconTypeResolver_1._iconTypeResolver.isFromAdapter(icon)) {
21
+ const svg = icon(config);
22
+ iconDefinitions.push(` "${name}": { w: ${svg.width}, h: ${svg.height} },`);
23
+ return;
24
+ }
25
+ throw new Error("Unknown icon format.");
15
26
  });
16
- if (config.adapters) {
17
- Object.entries((_a = config.adapters) !== null && _a !== void 0 ? _a : []).map(([adapterName, adapter]) => {
18
- adapter.icons.map((iconName) => {
19
- iconNames.push((0, _getIconFromAdapterName_1._getIconFromAdapterName)(adapterName, iconName));
20
- const icon = adapter.getIcon(iconName, config);
21
- iconDefinitions.push(` "${(0, _getIconFromAdapterName_1._getIconFromAdapterName)(adapterName, iconName)}": { w: ${icon.width}, h: ${icon.height} },`);
22
- });
23
- });
24
- }
25
27
  return `// this file is generated automatically, do not change anything manually in the contents of this file
26
28
 
27
29
  export const ICONS_VERSION = "${(0, get_md5_from_file_1.getMd5FromFile)(config.spriteFile)}";
@@ -1,5 +1,5 @@
1
1
  export declare function _createIconContent({ width, height, content }: {
2
- width: string;
3
- height: string;
2
+ width: number;
3
+ height: number;
4
4
  content: string;
5
5
  }): string;
@@ -1,42 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._createSpriteContent = void 0;
4
- const _getIconFromAdapterName_1 = require("./_getIconFromAdapterName");
4
+ const _iconTypeResolver_1 = require("./_iconTypeResolver");
5
5
  function _createSpriteContent(config) {
6
6
  let spriteTextContent = `<svg xmlns="http://www.w3.org/2000/svg">`;
7
- switch (config.mode) {
8
- case "simple":
9
- Object.keys(config.icons).map((name) => {
10
- const svg = config.icons[name];
11
- spriteTextContent += `<symbol id="icon-sprite--${name}" viewBox="0 0 ${svg.width} ${svg.height}">`;
12
- spriteTextContent += svg.data;
13
- spriteTextContent += `</symbol>`;
7
+ Object.keys(config.icons).map((name) => {
8
+ const icon = config.icons[name];
9
+ if (_iconTypeResolver_1._iconTypeResolver.isSimpleIcon(icon)) {
10
+ spriteTextContent += `<symbol id="icon-sprite--${name}" viewBox="0 0 ${icon.width} ${icon.height}">`;
11
+ spriteTextContent += icon.data;
12
+ spriteTextContent += `</symbol>`;
13
+ return;
14
+ }
15
+ if (_iconTypeResolver_1._iconTypeResolver.isSizedIcon(icon)) {
16
+ Object.keys(icon).map((s) => {
17
+ const svg = icon[Number(s)];
18
+ spriteTextContent += `<symbol id="icon-sprite--${name}_${s}" viewBox="0 0 ${s} ${s}">${svg}</symbol>`;
14
19
  });
15
- break;
16
- case "sizes":
17
- Object.keys(config.icons).map((name) => {
18
- const sizes = config.icons[name];
19
- return Object.keys(sizes).map((s) => {
20
- const svg = sizes[s];
21
- spriteTextContent += `<symbol id="icon-sprite--${name}_${s}" viewBox="0 0 ${s} ${s}">${svg}</symbol>`;
22
- });
23
- });
24
- break;
25
- default:
26
- throw new Error("Unknown mode ");
27
- }
28
- if (config.adapters) {
29
- Object.keys(config.adapters).map((adapterName) => {
30
- var _a;
31
- const adapter = (_a = config.adapters) === null || _a === void 0 ? void 0 : _a[adapterName];
32
- adapter === null || adapter === void 0 ? void 0 : adapter.icons.map((iconName) => {
33
- const icon = adapter.getIcon(iconName, config);
34
- spriteTextContent += `<symbol id="icon-sprite--${(0, _getIconFromAdapterName_1._getIconFromAdapterName)(adapterName, iconName)}" viewBox="0 0 ${icon.width} ${icon.height}">`;
35
- spriteTextContent += icon.path;
36
- spriteTextContent += `</symbol>`;
37
- });
38
- });
39
- }
20
+ return;
21
+ }
22
+ if (_iconTypeResolver_1._iconTypeResolver.isFromAdapter(icon)) {
23
+ const svg = icon(config);
24
+ spriteTextContent += `<symbol id="icon-sprite--${name}}" viewBox="0 0 ${svg.width} ${svg.height}">${svg.path}</symbol>`;
25
+ return;
26
+ }
27
+ throw new Error("Unknown icon format.");
28
+ });
40
29
  spriteTextContent += `</svg>`;
41
30
  return spriteTextContent;
42
31
  }
@@ -0,0 +1,6 @@
1
+ import { _IconsConfig } from "../types";
2
+ export declare function _generateAdapterFallback(key: string, iconName: string, iconDefinition: {
3
+ width: number;
4
+ height: number;
5
+ path: string;
6
+ }, config: _IconsConfig): void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._generateAdapterFallback = void 0;
4
+ const fs_1 = require("fs");
5
+ const _createPath_1 = require("./_createPath");
6
+ function _generateAdapterFallback(key, iconName, iconDefinition, config) {
7
+ (0, _createPath_1._createPath)(config.configFile);
8
+ (0, _createPath_1._createPath)(config.fallbackFilesDirectory);
9
+ const filePath = config.fallbackFilesDirectory + key + ".json";
10
+ const currentContent = (0, fs_1.readFileSync)(filePath).toString();
11
+ const content = currentContent ? JSON.parse(currentContent) : {};
12
+ content[iconName] = iconDefinition;
13
+ (0, fs_1.writeFileSync)(filePath, JSON.stringify(content));
14
+ }
15
+ exports._generateAdapterFallback = _generateAdapterFallback;
@@ -4,49 +4,39 @@ exports._generateSeparateIconFiles = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const _createIconContent_1 = require("./_createIconContent");
6
6
  const _createPath_1 = require("./_createPath");
7
- const _getIconFromAdapterName_1 = require("./_getIconFromAdapterName");
7
+ const _iconTypeResolver_1 = require("./_iconTypeResolver");
8
8
  function _generateSeparateIconFiles(config) {
9
9
  (0, _createPath_1._createPath)(config.generatedDirectory, false);
10
- switch (config.mode) {
11
- case "simple":
12
- Object.keys(config.icons).map((name) => {
13
- const svg = config.icons[name];
14
- // TODO po správném otypování tu neseděj typy ... :-)
15
- const content = (0, _createIconContent_1._createIconContent)({
16
- width: svg.width,
17
- height: svg.height,
18
- content: svg.data,
19
- });
20
- (0, fs_1.writeFileSync)(config.generatedDirectory + name + ".svg", content);
10
+ Object.keys(config.icons).map((name) => {
11
+ const icon = config.icons[name];
12
+ if (_iconTypeResolver_1._iconTypeResolver.isSimpleIcon(icon)) {
13
+ const content = (0, _createIconContent_1._createIconContent)({
14
+ width: icon.width,
15
+ height: icon.height,
16
+ content: icon.data,
21
17
  });
22
- break;
23
- case "sizes":
24
- Object.keys(config.icons).map((name) => {
25
- const size = config.icons[name];
26
- Object.keys(size).map((s) => {
27
- const svg = size[s];
28
- const content = (0, _createIconContent_1._createIconContent)({ width: s, height: s, content: svg });
29
- (0, fs_1.writeFileSync)(config.generatedDirectory + name + "_" + s + ".svg", content);
30
- });
18
+ (0, fs_1.writeFileSync)(config.generatedDirectory + name + ".svg", content);
19
+ return;
20
+ }
21
+ if (_iconTypeResolver_1._iconTypeResolver.isSizedIcon(icon)) {
22
+ Object.keys(icon).map((s) => {
23
+ const svg = icon[Number(s)];
24
+ const content = (0, _createIconContent_1._createIconContent)({ width: Number(s), height: Number(s), content: svg });
25
+ (0, fs_1.writeFileSync)(config.generatedDirectory + name + "_" + s + ".svg", content);
31
26
  });
32
- break;
33
- default:
34
- throw new Error("Unknown mode ");
35
- }
36
- if (config.adapters) {
37
- Object.keys(config.adapters).map((adapterName) => {
38
- var _a;
39
- const adapter = (_a = config.adapters) === null || _a === void 0 ? void 0 : _a[adapterName];
40
- adapter === null || adapter === void 0 ? void 0 : adapter.icons.map((iconName) => {
41
- const icon = adapter.getIcon(iconName, config);
42
- const content = (0, _createIconContent_1._createIconContent)({
43
- width: icon.width.toString(),
44
- height: icon.height.toString(),
45
- content: icon.path,
46
- });
47
- (0, fs_1.writeFileSync)(config.generatedDirectory + (0, _getIconFromAdapterName_1._getIconFromAdapterName)(adapterName, iconName) + ".svg", content);
27
+ return;
28
+ }
29
+ if (_iconTypeResolver_1._iconTypeResolver.isFromAdapter(icon)) {
30
+ const svg = icon(config);
31
+ const content = (0, _createIconContent_1._createIconContent)({
32
+ width: svg.width,
33
+ height: svg.height,
34
+ content: svg.path,
48
35
  });
49
- });
50
- }
36
+ (0, fs_1.writeFileSync)(config.generatedDirectory + name + ".svg", content);
37
+ return;
38
+ }
39
+ throw new Error("Unknown icon format.");
40
+ });
51
41
  }
52
42
  exports._generateSeparateIconFiles = _generateSeparateIconFiles;
@@ -1,2 +1,2 @@
1
1
  import { _IconsConfig } from "../types";
2
- export declare function _getConfig(confFile: string): _IconsConfig<Record<string, string>>;
2
+ export declare function _getConfig(confFile: string): _IconsConfig;
@@ -17,7 +17,6 @@ function _getConfig(confFile) {
17
17
  const config = {
18
18
  configDirectory: loadedConfig.configDirectory || "/src/config/",
19
19
  icons: loadedConfig.icons || {},
20
- mode: loadedConfig.mode || "simple",
21
20
  spriteFileName: loadedConfig.spriteFileName || "_icon-sprite.svg",
22
21
  typeName: loadedConfig.typeName || "IconsSet",
23
22
  typescript: loadedConfig.typescript || true,
@@ -0,0 +1 @@
1
+ export declare const _getIconNameForProvider: (providerKey: string, iconName: string) => string;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._getIconNameForProvider = void 0;
4
+ const _getIconNameForProvider = (providerKey, iconName) => `${providerKey}_${iconName}`;
5
+ exports._getIconNameForProvider = _getIconNameForProvider;
@@ -0,0 +1,6 @@
1
+ import type { IconFromProviderFunction, SimpleIcon, SizedIcon } from "../types";
2
+ export declare const _iconTypeResolver: {
3
+ isSimpleIcon: (icon: any) => icon is SimpleIcon;
4
+ isSizedIcon: (icon: any) => icon is SizedIcon;
5
+ isFromAdapter: (icon: any) => icon is IconFromProviderFunction;
6
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._iconTypeResolver = void 0;
4
+ exports._iconTypeResolver = {
5
+ isSimpleIcon: (icon) => "data" in icon,
6
+ isSizedIcon: (icon) => icon.constructor === Object &&
7
+ Object.keys(icon).every((key) => !isNaN(Number(key)) && typeof icon[key] === "string"),
8
+ isFromAdapter: (icon) => typeof icon === "function",
9
+ };
@@ -3,20 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._removeUnusedSeparateIconFiles = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const _createPath_1 = require("./_createPath");
6
- const _getIconFromAdapterName_1 = require("./_getIconFromAdapterName");
7
6
  function _removeUnusedSeparateIconFiles(config) {
8
7
  (0, _createPath_1._createPath)(config.generatedDirectory, false);
9
8
  const dir = (0, fs_1.readdirSync)(config.generatedDirectory, { withFileTypes: true });
10
9
  const allIconNames = Object.keys(config.icons);
11
- if (config.adapters) {
12
- Object.keys(config.adapters).map((adapterName) => {
13
- var _a;
14
- const adapter = (_a = config.adapters) === null || _a === void 0 ? void 0 : _a[adapterName];
15
- adapter === null || adapter === void 0 ? void 0 : adapter.icons.map((iconName) => {
16
- allIconNames.push((0, _getIconFromAdapterName_1._getIconFromAdapterName)(adapterName, iconName));
17
- });
18
- });
19
- }
20
10
  dir.map((file) => {
21
11
  if (file.isFile() && !allIconNames.includes(file.name) && file.name !== config.spriteFileName) {
22
12
  (0, fs_1.unlinkSync)(config.generatedDirectory + file.name);
@@ -2,29 +2,32 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._validateSourceData = void 0;
4
4
  const fast_xml_parser_1 = require("fast-xml-parser");
5
+ const _iconTypeResolver_1 = require("./_iconTypeResolver");
5
6
  function _validateSourceData(config) {
6
- switch (config.mode) {
7
- case "simple":
8
- Object.keys(config.icons).map((name) => {
9
- const svg = config.icons[name];
10
- if (fast_xml_parser_1.XMLValidator.validate(`<svg>${svg.data}</svg>`) !== true) {
7
+ Object.keys(config.icons).map((name) => {
8
+ const icon = config.icons[name];
9
+ if (_iconTypeResolver_1._iconTypeResolver.isSimpleIcon(icon)) {
10
+ if (fast_xml_parser_1.XMLValidator.validate(`<svg>${icon.data}</svg>`) !== true) {
11
+ throw new Error(`Invalid SVG data for icon "${name}"`);
12
+ }
13
+ return;
14
+ }
15
+ if (_iconTypeResolver_1._iconTypeResolver.isSizedIcon(icon)) {
16
+ Object.keys(icon).map((s) => {
17
+ const svg = icon[Number(s)];
18
+ if (fast_xml_parser_1.XMLValidator.validate(`<svg>${svg}</svg>`) !== true) {
11
19
  throw new Error(`Invalid SVG data for icon "${name}"`);
12
20
  }
13
21
  });
14
- break;
15
- case "sizes":
16
- Object.keys(config.icons).map((name) => {
17
- const sizes = config.icons[name];
18
- return Object.keys(sizes).map((s) => {
19
- const svg = sizes[s];
20
- if (fast_xml_parser_1.XMLValidator.validate(`<svg>${svg}</svg>`) !== true) {
21
- throw new Error(`Invalid SVG data for icon "${name}"`);
22
- }
23
- });
24
- });
25
- break;
26
- default:
27
- throw new Error("Unknown mode ");
28
- }
22
+ return;
23
+ }
24
+ if (_iconTypeResolver_1._iconTypeResolver.isFromAdapter(icon)) {
25
+ if (fast_xml_parser_1.XMLValidator.validate(`<svg>${icon(config).path}</svg>`) !== true) {
26
+ throw new Error(`Invalid SVG data for icon "${name}"`);
27
+ }
28
+ return;
29
+ }
30
+ throw new Error("Unknown icon format.");
31
+ });
29
32
  }
30
33
  exports._validateSourceData = _validateSourceData;
@@ -1,20 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fa_pro_1 = require("../src/adapters/fa-pro");
1
+ const { faPro } = require("../src/providers/fa-pro");
2
+
3
+ /** @type {import('@uxf/icons-generator/src/types').IconsConfig} */
4
4
  const config = {
5
- mode: "simple",
6
5
  typescript: true,
7
6
  configDirectory: "/tests/__snapshots/config/",
8
7
  generatedDirectory: "/tests/__snapshots/public/",
9
8
  spriteFileName: "_icon-sprite.svg",
10
9
  typeName: "MySuperIconsType",
11
- adapters: {
12
- faPro: {
13
- icons: ["regular.calendar-check", "brands.500px", "thin.percent"],
14
- getIcon: (0, fa_pro_1.getFaProIcon)("faPro"),
15
- },
16
- },
17
10
  icons: {
11
+ ...faPro.adapter(["regular.calendar-check", "brands.500px", "thin.percent"]),
12
+ testOverride: faPro.icon("brands.linkedin"),
18
13
  flame: {
19
14
  width: 43,
20
15
  height: 48,
@@ -53,6 +48,11 @@ const config = {
53
48
  </clipPath>
54
49
  </defs>`,
55
50
  },
51
+ sized: {
52
+ 24: `<path d="m23.916 6 1.125-1.123c3.14-3.06 7.49-4.454 11.765-3.742A13.397 13.397 0 0 1 48 14.353v.544c0 3.89-1.612 7.613-4.462 10.266L26.597 40.978A3.806 3.806 0 0 1 24 42a3.806 3.806 0 0 1-2.597-1.022L4.462 25.163A14.038 14.038 0 0 1 0 14.897v-.543a13.4 13.4 0 0 1 11.194-13.22c4.19-.71 8.625.682 11.681 3.743L23.915 6Zm0 4.247-3.16-3.253a10.413 10.413 0 0 0-9.065-2.9c-5.015.836-8.775 5.178-8.775 10.26v.543c0 3.066 1.354 5.981 3.592 8.072l16.939 15.816c.15.14.347.215.469.215.29 0 .487-.075.637-.215l16.94-15.816A11.059 11.059 0 0 0 45 14.897v-.543c0-5.082-3.675-9.424-8.69-10.26-3.394-.553-6.694.53-9.066 2.9l-3.328 3.253Z" fill="#fff" />`,
53
+ 48: `<path d="m31.14 1.608-12 36.63c-.21.634-.893.916-1.523.771a1.235 1.235 0 0 1-.757-1.549l12-36.625a1.2 1.2 0 0 1 1.523-.772c.622.213.9.904.757 1.545Zm-18.345 9.068-9.789 8.86 9.789 8.851c.495.45.54 1.221.037 1.725-.375.503-1.2.55-1.627.099L.403 20.383C.147 20.215 0 19.887 0 19.535c0-.35.147-.679.403-.915l10.802-9.768c.428-.442 1.252-.396 1.627.107.503.435.458 1.274-.037 1.717Zm24-1.824 10.8 9.768c.255.236.405.564.405.847 0 .42-.15.748-.405.916l-10.8 9.828a1.185 1.185 0 0 1-1.695-.1 1.243 1.243 0 0 1 .105-1.724l9.788-8.92-9.788-8.79c-.495-.444-.54-1.283-.105-1.718.442-.503 1.2-.55 1.695-.107Z" fill="#fff" />`,
54
+ },
56
55
  },
57
56
  };
57
+
58
58
  module.exports = config;
@@ -1,6 +0,0 @@
1
- import { _IconsConfig } from "../types";
2
- export declare const getFaProIcon: (adapterKey: string) => (iconName: string, config: _IconsConfig) => {
3
- width: any;
4
- height: any;
5
- path: string;
6
- };
@@ -1,2 +0,0 @@
1
- import { _IconsConfig } from "../types";
2
- export declare function _generateAdaptersFallbackFiles(config: _IconsConfig<Record<string, string>>): void;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._generateAdaptersFallbackFiles = void 0;
4
- const fs_1 = require("fs");
5
- const _createPath_1 = require("./_createPath");
6
- function _generateAdaptersFallbackFiles(config) {
7
- (0, _createPath_1._createPath)(config.configFile);
8
- if (config.adapters) {
9
- const adaptersKeys = Object.keys(config.adapters);
10
- adaptersKeys.forEach((adapterKey) => {
11
- var _a;
12
- let content = "{\n";
13
- const adapter = (_a = config.adapters) === null || _a === void 0 ? void 0 : _a[adapterKey];
14
- adapter === null || adapter === void 0 ? void 0 : adapter.icons.forEach((iconKey) => {
15
- const iconData = adapter.getIcon(iconKey, config);
16
- content += ` "${iconKey}": { "width": "${iconData.width}", "height": "${iconData.height}", "path": "${encodeURIComponent(iconData.path)}" },\n`;
17
- });
18
- content += "}\n";
19
- content = content.split("").reverse().join("").replace(",", "").split("").reverse().join("");
20
- (0, _createPath_1._createPath)(config.fallbackFilesDirectory);
21
- (0, fs_1.writeFileSync)(config.fallbackFilesDirectory + adapterKey + ".json", content);
22
- });
23
- }
24
- }
25
- exports._generateAdaptersFallbackFiles = _generateAdaptersFallbackFiles;
@@ -1 +0,0 @@
1
- export declare const _getIconFromAdapterName: (adapterName: string, iconName: string) => string;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._getIconFromAdapterName = void 0;
4
- const _getIconFromAdapterName = (adapterName, iconName) => `${adapterName}_${iconName}`;
5
- exports._getIconFromAdapterName = _getIconFromAdapterName;
@@ -1 +0,0 @@
1
- export {};