@yahoo/uds-icons 2.36.0-beta.1 → 2.36.0-beta.2

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.
Files changed (38) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +30 -0
  2. package/dist/cli/dist/lib/colors.cjs +20 -0
  3. package/dist/cli/dist/lib/colors.js +16 -0
  4. package/dist/cli/dist/lib/colors.js.map +1 -0
  5. package/dist/cli/dist/lib/print.cjs +13 -0
  6. package/dist/cli/dist/lib/print.js +13 -0
  7. package/dist/cli/dist/lib/print.js.map +1 -0
  8. package/dist/cli.cjs +7 -0
  9. package/dist/cli.d.cts +4 -0
  10. package/dist/cli.d.ts +4 -0
  11. package/dist/cli.js +5 -0
  12. package/dist/scripts/colorUtils.cjs +82 -0
  13. package/dist/scripts/colorUtils.js +80 -0
  14. package/dist/scripts/colorUtils.js.map +1 -0
  15. package/dist/scripts/normalizeSvgMarkup.cjs +32 -0
  16. package/dist/scripts/normalizeSvgMarkup.js +32 -0
  17. package/dist/scripts/normalizeSvgMarkup.js.map +1 -0
  18. package/dist/scripts/processIconVariant.cjs +45 -0
  19. package/dist/scripts/processIconVariant.js +46 -0
  20. package/dist/scripts/processIconVariant.js.map +1 -0
  21. package/dist/src/cli/createIconsCommand.cjs +77 -0
  22. package/dist/src/cli/createIconsCommand.d.cts +8 -0
  23. package/dist/src/cli/createIconsCommand.d.cts.map +1 -0
  24. package/dist/src/cli/createIconsCommand.d.ts +8 -0
  25. package/dist/src/cli/createIconsCommand.d.ts.map +1 -0
  26. package/dist/src/cli/createIconsCommand.js +76 -0
  27. package/dist/src/cli/createIconsCommand.js.map +1 -0
  28. package/dist/src/createIconsUtils.cjs +228 -0
  29. package/dist/src/createIconsUtils.d.cts +18 -0
  30. package/dist/src/createIconsUtils.d.cts.map +1 -0
  31. package/dist/src/createIconsUtils.d.ts +18 -0
  32. package/dist/src/createIconsUtils.d.ts.map +1 -0
  33. package/dist/src/createIconsUtils.js +227 -0
  34. package/dist/src/createIconsUtils.js.map +1 -0
  35. package/dist/src/generateBarrelFile.cjs +29 -0
  36. package/dist/src/generateBarrelFile.js +27 -0
  37. package/dist/src/generateBarrelFile.js.map +1 -0
  38. package/package.json +12 -1
@@ -0,0 +1,30 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+
28
+ //#endregion
29
+
30
+ exports.__toESM = __toESM;
@@ -0,0 +1,20 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+
3
+ //#region ../cli/dist/lib/colors.mjs
4
+ /*! © 2026 Yahoo, Inc. UDS CLI v0.0.0-development */
5
+ /**
6
+ * ANSI escape code color utilities for terminal output.
7
+ * Zero dependencies - uses standard ANSI escape sequences.
8
+ */
9
+ const red = (text) => `\x1b[31m${text}\x1b[0m`;
10
+ const green = (text) => `\x1b[32m${text}\x1b[0m`;
11
+ const magenta = (text) => `\x1b[35m${text}\x1b[0m`;
12
+ const cyan = (text) => `\x1b[36m${text}\x1b[0m`;
13
+ const gray = (text) => `\x1b[2m${text}\x1b[0m`;
14
+
15
+ //#endregion
16
+ exports.cyan = cyan;
17
+ exports.gray = gray;
18
+ exports.green = green;
19
+ exports.magenta = magenta;
20
+ exports.red = red;
@@ -0,0 +1,16 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ //#region ../cli/dist/lib/colors.mjs
3
+ /*! © 2026 Yahoo, Inc. UDS CLI v0.0.0-development */
4
+ /**
5
+ * ANSI escape code color utilities for terminal output.
6
+ * Zero dependencies - uses standard ANSI escape sequences.
7
+ */
8
+ const red = (text) => `\x1b[31m${text}\x1b[0m`;
9
+ const green = (text) => `\x1b[32m${text}\x1b[0m`;
10
+ const magenta = (text) => `\x1b[35m${text}\x1b[0m`;
11
+ const cyan = (text) => `\x1b[36m${text}\x1b[0m`;
12
+ const gray = (text) => `\x1b[2m${text}\x1b[0m`;
13
+
14
+ //#endregion
15
+ export { cyan, gray, green, magenta, red };
16
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.js","names":[],"sources":["../../../../../cli/dist/lib/colors.mjs"],"sourcesContent":["/*! © 2026 Yahoo, Inc. UDS CLI v0.0.0-development */\n//#region src/lib/colors.ts\n/**\n* ANSI escape code color utilities for terminal output.\n* Zero dependencies - uses standard ANSI escape sequences.\n*/\nconst red = (text) => `\\x1b[31m${text}\\x1b[0m`;\nconst green = (text) => `\\x1b[32m${text}\\x1b[0m`;\nconst yellow = (text) => `\\x1b[33m${text}\\x1b[0m`;\nconst blue = (text) => `\\x1b[34m${text}\\x1b[0m`;\nconst magenta = (text) => `\\x1b[35m${text}\\x1b[0m`;\nconst cyan = (text) => `\\x1b[36m${text}\\x1b[0m`;\nconst white = (text) => `\\x1b[37m${text}\\x1b[0m`;\nconst gray = (text) => `\\x1b[2m${text}\\x1b[0m`;\nconst bold = (text) => `\\x1b[1m${text}\\x1b[0m`;\nconst dim = (text) => `\\x1b[2m${text}\\x1b[0m`;\n\n//#endregion\nexport { blue, bold, cyan, dim, gray, green, magenta, red, white, yellow };\n//# sourceMappingURL=colors.mjs.map"],"mappings":";;;;;;;AAMA,MAAM,OAAO,SAAS,WAAW,KAAK;AACtC,MAAM,SAAS,SAAS,WAAW,KAAK;AAGxC,MAAM,WAAW,SAAS,WAAW,KAAK;AAC1C,MAAM,QAAQ,SAAS,WAAW,KAAK;AAEvC,MAAM,QAAQ,SAAS,UAAU,KAAK"}
@@ -0,0 +1,13 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+
3
+ //#region ../cli/dist/lib/print.mjs
4
+ /*! © 2026 Yahoo, Inc. UDS CLI v0.0.0-development */
5
+ /**
6
+ * Console output wrapper.
7
+ */
8
+ function print(...args) {
9
+ console.log(...args);
10
+ }
11
+
12
+ //#endregion
13
+ exports.print = print;
@@ -0,0 +1,13 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ //#region ../cli/dist/lib/print.mjs
3
+ /*! © 2026 Yahoo, Inc. UDS CLI v0.0.0-development */
4
+ /**
5
+ * Console output wrapper.
6
+ */
7
+ function print(...args) {
8
+ console.log(...args);
9
+ }
10
+
11
+ //#endregion
12
+ export { print };
13
+ //# sourceMappingURL=print.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print.js","names":[],"sources":["../../../../../cli/dist/lib/print.mjs"],"sourcesContent":["/*! © 2026 Yahoo, Inc. UDS CLI v0.0.0-development */\n//#region src/lib/print.ts\n/**\n* Console output wrapper.\n*/\nfunction print(...args) {\n\tconsole.log(...args);\n}\n\n//#endregion\nexport { print };\n//# sourceMappingURL=print.mjs.map"],"mappings":";;;;;;AAKA,SAAS,MAAM,GAAG,MAAM;AACvB,SAAQ,IAAI,GAAG,KAAK"}
package/dist/cli.cjs ADDED
@@ -0,0 +1,7 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
+ const require_createIconsUtils = require('./src/createIconsUtils.cjs');
4
+ const require_createIconsCommand = require('./src/cli/createIconsCommand.cjs');
5
+
6
+ exports.createIconsFromDirectory = require_createIconsUtils.createIconsFromDirectory;
7
+ exports.makeCreateIconsCommand = require_createIconsCommand.makeCreateIconsCommand;
package/dist/cli.d.cts ADDED
@@ -0,0 +1,4 @@
1
+
2
+ import { createIconsFromDirectory } from "./src/createIconsUtils.cjs";
3
+ import { makeCreateIconsCommand } from "./src/cli/createIconsCommand.cjs";
4
+ export { createIconsFromDirectory, makeCreateIconsCommand };
package/dist/cli.d.ts ADDED
@@ -0,0 +1,4 @@
1
+
2
+ import { createIconsFromDirectory } from "./src/createIconsUtils.js";
3
+ import { makeCreateIconsCommand } from "./src/cli/createIconsCommand.js";
4
+ export { createIconsFromDirectory, makeCreateIconsCommand };
package/dist/cli.js ADDED
@@ -0,0 +1,5 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ import { createIconsFromDirectory } from "./src/createIconsUtils.js";
3
+ import { makeCreateIconsCommand } from "./src/cli/createIconsCommand.js";
4
+
5
+ export { createIconsFromDirectory, makeCreateIconsCommand };
@@ -0,0 +1,82 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let node_fs_promises = require("node:fs/promises");
4
+ node_fs_promises = require_runtime.__toESM(node_fs_promises);
5
+ let node_path = require("node:path");
6
+ node_path = require_runtime.__toESM(node_path);
7
+
8
+ //#region scripts/colorUtils.ts
9
+ /**
10
+ * Color mode specific color mappings for common values
11
+ */
12
+ const COLOR_MODE_MAPPINGS = {
13
+ light: {
14
+ white: "rgb(var(--uds-spectrum-color-gray-0))",
15
+ black: "rgb(var(--uds-spectrum-color-gray-15))"
16
+ },
17
+ dark: {
18
+ white: "rgb(var(--uds-spectrum-color-gray-15))",
19
+ black: "rgb(var(--uds-spectrum-color-gray-0))"
20
+ }
21
+ };
22
+ /**
23
+ * Check if a color value represents white
24
+ */
25
+ function isWhiteColor(color) {
26
+ const upperColor = color.toUpperCase();
27
+ return [
28
+ "WHITE",
29
+ "#FFFFFF",
30
+ "#FFF"
31
+ ].includes(upperColor);
32
+ }
33
+ /**
34
+ * Check if a color value represents black
35
+ */
36
+ function isBlackColor(color) {
37
+ const upperColor = color.toUpperCase();
38
+ return [
39
+ "BLACK",
40
+ "#000000",
41
+ "#000"
42
+ ].includes(upperColor);
43
+ }
44
+ /**
45
+ * Generate all possible hex color format variants
46
+ * @param hex Hex color string in format "#RRGGBB"
47
+ * @returns Array of all possible hex color format variants
48
+ */
49
+ const generateHexColorVariants = (hex) => {
50
+ return [
51
+ hex,
52
+ hex.toUpperCase(),
53
+ hex.toLowerCase(),
54
+ hex.replace("#", ""),
55
+ hex.toLowerCase().replace("#", ""),
56
+ hex.toUpperCase().replace("#", "")
57
+ ];
58
+ };
59
+ function processSvgWithVariables({ svg, colorMap, options = {} }) {
60
+ const { fallback = "current", colorMode = "light" } = options;
61
+ const processColor = (match, attr, color) => {
62
+ if (color === "none" || color === "currentColor" || color.includes("rgb(var(--uds-spectrum-color")) return match;
63
+ if (fallback !== "current") {
64
+ if (isWhiteColor(color)) return `${attr}="${COLOR_MODE_MAPPINGS[colorMode].white}"`;
65
+ if (isBlackColor(color)) return `${attr}="${COLOR_MODE_MAPPINGS[colorMode].black}"`;
66
+ }
67
+ const formats = generateHexColorVariants(color);
68
+ for (const format of formats) {
69
+ const cssVar = colorMap.get(format);
70
+ if (cssVar) return `${attr}="${cssVar}"`;
71
+ }
72
+ switch (fallback) {
73
+ case "preserve": return match;
74
+ case "current": return `${attr}="currentColor"`;
75
+ default: return `${attr}="${fallback}"`;
76
+ }
77
+ };
78
+ return svg.replace(/fill="([^"]+)"/g, (match, color) => processColor(match, "fill", color)).replace(/stroke="([^"]+)"/g, (match, color) => processColor(match, "stroke", color));
79
+ }
80
+
81
+ //#endregion
82
+ exports.processSvgWithVariables = processSvgWithVariables;
@@ -0,0 +1,80 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+
5
+ //#region scripts/colorUtils.ts
6
+ /**
7
+ * Color mode specific color mappings for common values
8
+ */
9
+ const COLOR_MODE_MAPPINGS = {
10
+ light: {
11
+ white: "rgb(var(--uds-spectrum-color-gray-0))",
12
+ black: "rgb(var(--uds-spectrum-color-gray-15))"
13
+ },
14
+ dark: {
15
+ white: "rgb(var(--uds-spectrum-color-gray-15))",
16
+ black: "rgb(var(--uds-spectrum-color-gray-0))"
17
+ }
18
+ };
19
+ /**
20
+ * Check if a color value represents white
21
+ */
22
+ function isWhiteColor(color) {
23
+ const upperColor = color.toUpperCase();
24
+ return [
25
+ "WHITE",
26
+ "#FFFFFF",
27
+ "#FFF"
28
+ ].includes(upperColor);
29
+ }
30
+ /**
31
+ * Check if a color value represents black
32
+ */
33
+ function isBlackColor(color) {
34
+ const upperColor = color.toUpperCase();
35
+ return [
36
+ "BLACK",
37
+ "#000000",
38
+ "#000"
39
+ ].includes(upperColor);
40
+ }
41
+ /**
42
+ * Generate all possible hex color format variants
43
+ * @param hex Hex color string in format "#RRGGBB"
44
+ * @returns Array of all possible hex color format variants
45
+ */
46
+ const generateHexColorVariants = (hex) => {
47
+ return [
48
+ hex,
49
+ hex.toUpperCase(),
50
+ hex.toLowerCase(),
51
+ hex.replace("#", ""),
52
+ hex.toLowerCase().replace("#", ""),
53
+ hex.toUpperCase().replace("#", "")
54
+ ];
55
+ };
56
+ function processSvgWithVariables({ svg, colorMap, options = {} }) {
57
+ const { fallback = "current", colorMode = "light" } = options;
58
+ const processColor = (match, attr, color) => {
59
+ if (color === "none" || color === "currentColor" || color.includes("rgb(var(--uds-spectrum-color")) return match;
60
+ if (fallback !== "current") {
61
+ if (isWhiteColor(color)) return `${attr}="${COLOR_MODE_MAPPINGS[colorMode].white}"`;
62
+ if (isBlackColor(color)) return `${attr}="${COLOR_MODE_MAPPINGS[colorMode].black}"`;
63
+ }
64
+ const formats = generateHexColorVariants(color);
65
+ for (const format of formats) {
66
+ const cssVar = colorMap.get(format);
67
+ if (cssVar) return `${attr}="${cssVar}"`;
68
+ }
69
+ switch (fallback) {
70
+ case "preserve": return match;
71
+ case "current": return `${attr}="currentColor"`;
72
+ default: return `${attr}="${fallback}"`;
73
+ }
74
+ };
75
+ return svg.replace(/fill="([^"]+)"/g, (match, color) => processColor(match, "fill", color)).replace(/stroke="([^"]+)"/g, (match, color) => processColor(match, "stroke", color));
76
+ }
77
+
78
+ //#endregion
79
+ export { processSvgWithVariables };
80
+ //# sourceMappingURL=colorUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorUtils.js","names":[],"sources":["../../scripts/colorUtils.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport type { FigmaColorValue, FigmaVariable, FigmaVariableAlias } from './types';\n\n/**\n * Color mode specific color mappings for common values\n */\nconst COLOR_MODE_MAPPINGS = {\n light: {\n white: 'rgb(var(--uds-spectrum-color-gray-0))',\n black: 'rgb(var(--uds-spectrum-color-gray-15))',\n },\n dark: {\n white: 'rgb(var(--uds-spectrum-color-gray-15))',\n black: 'rgb(var(--uds-spectrum-color-gray-0))',\n },\n} as const;\n\n/**\n * Check if a color value represents white\n */\nfunction isWhiteColor(color: string): boolean {\n const upperColor = color.toUpperCase();\n return ['WHITE', '#FFFFFF', '#FFF'].includes(upperColor);\n}\n\n/**\n * Check if a color value represents black\n */\nfunction isBlackColor(color: string): boolean {\n const upperColor = color.toUpperCase();\n return ['BLACK', '#000000', '#000'].includes(upperColor);\n}\n\nexport interface ColorMode {\n light: string;\n dark: string;\n}\n\nexport interface ColorProcessor {\n addColor: (hex: string, cssVar: string, mode: keyof ColorMode) => void;\n getColorMap: (mode: keyof ColorMode) => Map<string, string>;\n}\n\n/**\n * Convert RGB values to hex color\n * @param r Red value (0-255)\n * @param g Green value (0-255)\n * @param b Blue value (0-255)\n * @returns Hex color string in format \"#RRGGBB\"\n */\nexport function rgbToHex(r: number, g: number, b: number): string {\n const toHex = (n: number) =>\n Math.round(n * 255)\n .toString(16)\n .padStart(2, '0')\n .toUpperCase();\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n}\n\n/**\n * Generate all possible hex color format variants\n * @param hex Hex color string in format \"#RRGGBB\"\n * @returns Array of all possible hex color format variants\n */\nexport const generateHexColorVariants = (hex: string) => {\n return [\n hex,\n hex.toUpperCase(),\n hex.toLowerCase(),\n hex.replace('#', ''),\n hex.toLowerCase().replace('#', ''),\n hex.toUpperCase().replace('#', ''),\n ];\n};\n\n/**\n * Creates a color processor that manages color mappings for light and dark modes\n */\nexport function createColorProcessor(): ColorProcessor {\n const lightModeColors = new Map<string, string>();\n const darkModeColors = new Map<string, string>();\n\n return {\n addColor(hex: string, cssVar: string, mode: keyof ColorMode) {\n const colorMap = mode === 'light' ? lightModeColors : darkModeColors;\n generateHexColorVariants(hex).forEach((format) => colorMap.set(format, cssVar));\n },\n getColorMap(mode: keyof ColorMode) {\n return mode === 'light' ? lightModeColors : darkModeColors;\n },\n };\n}\n\n/**\n * Recursively resolves a variable alias to its final color value\n */\nexport function resolveVariableToFinalColor(\n variables: Record<string, FigmaVariable>,\n variableId: string,\n modeId: string,\n depth = 0,\n): FigmaColorValue | undefined {\n if (depth > 10) {\n console.warn('Max recursion depth reached while resolving variable:', variableId);\n return undefined;\n }\n\n const variable = variables[variableId];\n if (!variable?.valuesByMode) {\n return undefined;\n }\n\n const modeValue = variable.valuesByMode[modeId];\n if (!modeValue) {\n return undefined;\n }\n\n // If it's a direct color value\n if ('r' in modeValue && 'g' in modeValue && 'b' in modeValue) {\n return modeValue as FigmaColorValue;\n }\n\n // If it's an alias, recursively resolve it\n if (modeValue && typeof modeValue === 'object' && 'type' in modeValue) {\n const alias = modeValue as FigmaVariableAlias;\n if (alias.type === 'VARIABLE_ALIAS') {\n return resolveVariableToFinalColor(variables, alias.id, modeId, depth + 1);\n }\n }\n\n return undefined;\n}\n\n/**\n * Predefined fallback strategies for when a color doesn't match any CSS variables\n */\nexport type PredefinedFallback = 'preserve' | 'current';\n\n/**\n * Fallback can be either a predefined strategy or any valid color string\n */\nexport type ColorFallbackStrategy = PredefinedFallback | string;\n\n/**\n * Configuration options for SVG processing\n */\nexport interface SvgProcessingOptions {\n /** How to handle colors that don't match any CSS variables.\n * Can be:\n * - 'current': Use currentColor (default)\n * - 'preserve': Keep the original color\n * - any color string: Use that color as fallback\n * @default 'current'\n */\n fallback?: ColorFallbackStrategy;\n /** The current color mode for color mapping\n * @default 'light'\n */\n colorMode?: 'light' | 'dark';\n}\n\n/**\n * Options for processing an SVG\n */\nexport interface ProcessSvgOptions {\n /** The SVG content to process */\n svg: string;\n /** Map of hex colors to CSS variables */\n colorMap: Map<string, string>;\n /** Processing configuration options */\n options?: SvgProcessingOptions;\n}\n\nexport function processSvgWithVariables({\n svg,\n colorMap,\n options = {},\n}: ProcessSvgOptions): string {\n const { fallback = 'current', colorMode = 'light' } = options;\n\n // Helper function to process color attributes\n const processColor = (match: string, attr: string, color: string) => {\n // Preserve special SVG values:\n // - 'none': Valid SVG attribute meaning no fill/stroke\n // - 'currentColor': React's dynamic color inheritance\n // - CSS variables: Already processed colors\n if (\n color === 'none' ||\n color === 'currentColor' ||\n color.includes('rgb(var(--uds-spectrum-color')\n ) {\n return match;\n }\n\n // Handle color mode specific color mappings for black and white\n // Skip if we're converting everything to currentColor\n if (fallback !== 'current') {\n if (isWhiteColor(color)) {\n return `${attr}=\"${COLOR_MODE_MAPPINGS[colorMode].white}\"`;\n }\n if (isBlackColor(color)) {\n return `${attr}=\"${COLOR_MODE_MAPPINGS[colorMode].black}\"`;\n }\n }\n\n // Try to find a CSS variable for this color\n const formats = generateHexColorVariants(color);\n\n for (const format of formats) {\n const cssVar = colorMap.get(format);\n if (cssVar) {\n return `${attr}=\"${cssVar}\"`;\n }\n }\n\n // Handle unmapped colors based on fallback strategy\n switch (fallback) {\n case 'preserve':\n return match;\n case 'current':\n return `${attr}=\"currentColor\"`;\n default:\n // For any other string, use it as a direct color value\n return `${attr}=\"${fallback}\"`;\n }\n };\n\n // Replace both fill and stroke colors in the SVG\n return svg\n .replace(/fill=\"([^\"]+)\"/g, (match, color) => processColor(match, 'fill', color))\n .replace(/stroke=\"([^\"]+)\"/g, (match, color) => processColor(match, 'stroke', color));\n}\n\n/**\n * Initialize color processor by loading saved color map data from disk\n */\nexport async function initializeColorProcessor(\n assetDir: string,\n): Promise<{ getColorMap: (mode: 'light' | 'dark') => Map<string, string> }> {\n try {\n const colorMapPath = path.join(assetDir, 'color-map.json');\n const colorMapData = JSON.parse(await fs.readFile(colorMapPath, 'utf-8'));\n\n return {\n getColorMap: (mode: 'light' | 'dark') => {\n const modeData = colorMapData[mode] || {};\n return new Map<string, string>(Object.entries(modeData));\n },\n };\n } catch (err) {\n console.warn('Could not load color map data, using empty processor:', err);\n return {\n getColorMap: () => new Map<string, string>(),\n };\n }\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,sBAAsB;CAC1B,OAAO;EACL,OAAO;EACP,OAAO;EACR;CACD,MAAM;EACJ,OAAO;EACP,OAAO;EACR;CACF;;;;AAKD,SAAS,aAAa,OAAwB;CAC5C,MAAM,aAAa,MAAM,aAAa;AACtC,QAAO;EAAC;EAAS;EAAW;EAAO,CAAC,SAAS,WAAW;;;;;AAM1D,SAAS,aAAa,OAAwB;CAC5C,MAAM,aAAa,MAAM,aAAa;AACtC,QAAO;EAAC;EAAS;EAAW;EAAO,CAAC,SAAS,WAAW;;;;;;;AAkC1D,MAAa,4BAA4B,QAAgB;AACvD,QAAO;EACL;EACA,IAAI,aAAa;EACjB,IAAI,aAAa;EACjB,IAAI,QAAQ,KAAK,GAAG;EACpB,IAAI,aAAa,CAAC,QAAQ,KAAK,GAAG;EAClC,IAAI,aAAa,CAAC,QAAQ,KAAK,GAAG;EACnC;;AAqGH,SAAgB,wBAAwB,EACtC,KACA,UACA,UAAU,EAAE,IACgB;CAC5B,MAAM,EAAE,WAAW,WAAW,YAAY,YAAY;CAGtD,MAAM,gBAAgB,OAAe,MAAc,UAAkB;AAKnE,MACE,UAAU,UACV,UAAU,kBACV,MAAM,SAAS,+BAA+B,CAE9C,QAAO;AAKT,MAAI,aAAa,WAAW;AAC1B,OAAI,aAAa,MAAM,CACrB,QAAO,GAAG,KAAK,IAAI,oBAAoB,WAAW,MAAM;AAE1D,OAAI,aAAa,MAAM,CACrB,QAAO,GAAG,KAAK,IAAI,oBAAoB,WAAW,MAAM;;EAK5D,MAAM,UAAU,yBAAyB,MAAM;AAE/C,OAAK,MAAM,UAAU,SAAS;GAC5B,MAAM,SAAS,SAAS,IAAI,OAAO;AACnC,OAAI,OACF,QAAO,GAAG,KAAK,IAAI,OAAO;;AAK9B,UAAQ,UAAR;GACE,KAAK,WACH,QAAO;GACT,KAAK,UACH,QAAO,GAAG,KAAK;GACjB,QAEE,QAAO,GAAG,KAAK,IAAI,SAAS;;;AAKlC,QAAO,IACJ,QAAQ,oBAAoB,OAAO,UAAU,aAAa,OAAO,QAAQ,MAAM,CAAC,CAChF,QAAQ,sBAAsB,OAAO,UAAU,aAAa,OAAO,UAAU,MAAM,CAAC"}
@@ -0,0 +1,32 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+
3
+ //#region scripts/normalizeSvgMarkup.ts
4
+ function stripUnnecessarySvgWhitespace(svg) {
5
+ return svg.trim().replace(/>\s+</g, "><");
6
+ }
7
+ function expandSelfClosingSvgTags(svg) {
8
+ return svg.replace(/<([a-zA-Z][\w:-]*)([^<>]*?)\s*\/\s*>/g, "<$1$2></$1>");
9
+ }
10
+ function normalizeSvgMarkup(svg, name) {
11
+ let result = stripUnnecessarySvgWhitespace(svg);
12
+ result = expandSelfClosingSvgTags(result);
13
+ result = result.replace(/(fill|stroke)="([^"]+)"/gi, (match, attr, value) => {
14
+ if (value === "none") return match;
15
+ if (value === "currentColor") return match;
16
+ const upperValue = value.toUpperCase();
17
+ if ([
18
+ "BLACK",
19
+ "WHITE",
20
+ "#000000",
21
+ "#FFFFFF",
22
+ "#000",
23
+ "#FFF"
24
+ ].includes(upperValue)) return `${attr}="currentColor"`;
25
+ if (name?.toLowerCase().includes("multicolor")) return match;
26
+ return match;
27
+ });
28
+ return stripUnnecessarySvgWhitespace(result);
29
+ }
30
+
31
+ //#endregion
32
+ exports.normalizeSvgMarkup = normalizeSvgMarkup;
@@ -0,0 +1,32 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ //#region scripts/normalizeSvgMarkup.ts
3
+ function stripUnnecessarySvgWhitespace(svg) {
4
+ return svg.trim().replace(/>\s+</g, "><");
5
+ }
6
+ function expandSelfClosingSvgTags(svg) {
7
+ return svg.replace(/<([a-zA-Z][\w:-]*)([^<>]*?)\s*\/\s*>/g, "<$1$2></$1>");
8
+ }
9
+ function normalizeSvgMarkup(svg, name) {
10
+ let result = stripUnnecessarySvgWhitespace(svg);
11
+ result = expandSelfClosingSvgTags(result);
12
+ result = result.replace(/(fill|stroke)="([^"]+)"/gi, (match, attr, value) => {
13
+ if (value === "none") return match;
14
+ if (value === "currentColor") return match;
15
+ const upperValue = value.toUpperCase();
16
+ if ([
17
+ "BLACK",
18
+ "WHITE",
19
+ "#000000",
20
+ "#FFFFFF",
21
+ "#000",
22
+ "#FFF"
23
+ ].includes(upperValue)) return `${attr}="currentColor"`;
24
+ if (name?.toLowerCase().includes("multicolor")) return match;
25
+ return match;
26
+ });
27
+ return stripUnnecessarySvgWhitespace(result);
28
+ }
29
+
30
+ //#endregion
31
+ export { normalizeSvgMarkup };
32
+ //# sourceMappingURL=normalizeSvgMarkup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeSvgMarkup.js","names":[],"sources":["../../scripts/normalizeSvgMarkup.ts"],"sourcesContent":["function stripUnnecessarySvgWhitespace(svg: string): string {\n return svg.trim().replace(/>\\s+</g, '><');\n}\n\nfunction expandSelfClosingSvgTags(svg: string): string {\n return svg.replace(/<([a-zA-Z][\\w:-]*)([^<>]*?)\\s*\\/\\s*>/g, '<$1$2></$1>');\n}\n\nfunction normalizeSvgMarkup(svg: string, name?: string): string {\n let result = stripUnnecessarySvgWhitespace(svg);\n result = expandSelfClosingSvgTags(result);\n\n result = result.replace(/(fill|stroke)=\"([^\"]+)\"/gi, (match, attr, value) => {\n if (value === 'none') {\n return match;\n }\n\n if (value === 'currentColor') {\n return match;\n }\n\n const upperValue = value.toUpperCase();\n if (['BLACK', 'WHITE', '#000000', '#FFFFFF', '#000', '#FFF'].includes(upperValue)) {\n return `${attr}=\"currentColor\"`;\n }\n\n if (name?.toLowerCase().includes('multicolor')) {\n return match;\n }\n\n return match;\n });\n\n return stripUnnecessarySvgWhitespace(result);\n}\n\nexport { normalizeSvgMarkup, stripUnnecessarySvgWhitespace };\n"],"mappings":";;AAAA,SAAS,8BAA8B,KAAqB;AAC1D,QAAO,IAAI,MAAM,CAAC,QAAQ,UAAU,KAAK;;AAG3C,SAAS,yBAAyB,KAAqB;AACrD,QAAO,IAAI,QAAQ,yCAAyC,cAAc;;AAG5E,SAAS,mBAAmB,KAAa,MAAuB;CAC9D,IAAI,SAAS,8BAA8B,IAAI;AAC/C,UAAS,yBAAyB,OAAO;AAEzC,UAAS,OAAO,QAAQ,8BAA8B,OAAO,MAAM,UAAU;AAC3E,MAAI,UAAU,OACZ,QAAO;AAGT,MAAI,UAAU,eACZ,QAAO;EAGT,MAAM,aAAa,MAAM,aAAa;AACtC,MAAI;GAAC;GAAS;GAAS;GAAW;GAAW;GAAQ;GAAO,CAAC,SAAS,WAAW,CAC/E,QAAO,GAAG,KAAK;AAGjB,MAAI,MAAM,aAAa,CAAC,SAAS,aAAa,CAC5C,QAAO;AAGT,SAAO;GACP;AAEF,QAAO,8BAA8B,OAAO"}
@@ -0,0 +1,45 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ const require_colorUtils = require('./colorUtils.cjs');
3
+
4
+ //#region scripts/processIconVariant.ts
5
+ const EMPTY_COLOR_MAP = /* @__PURE__ */ new Map();
6
+ /**
7
+ * Processes an SVG based on its variant type and returns the processed SVG content
8
+ * with appropriate file name.
9
+ */
10
+ function processIconVariant({ svg, component, getColorMap }) {
11
+ const { name, size, variant } = component;
12
+ let colorMode = "light";
13
+ let fallback = "current";
14
+ let filePrefix = variant;
15
+ if (!name || !size || !variant) throw new Error("Missing required component information");
16
+ if (variant === "fill" || variant === "outline") return {
17
+ fileName: `${name}-${variant}-${size}.svg`,
18
+ svg: require_colorUtils.processSvgWithVariables({
19
+ svg,
20
+ colorMap: EMPTY_COLOR_MAP
21
+ })
22
+ };
23
+ if (variant === "light" || variant === "dark") {
24
+ fallback = "preserve";
25
+ colorMode = variant;
26
+ } else if (variant === "multicolor") {
27
+ fallback = "preserve";
28
+ filePrefix = "multicolor";
29
+ }
30
+ const processedSvg = require_colorUtils.processSvgWithVariables({
31
+ svg,
32
+ colorMap: getColorMap(colorMode),
33
+ options: {
34
+ fallback,
35
+ colorMode
36
+ }
37
+ });
38
+ return {
39
+ fileName: `${name}-${filePrefix}-${size}.svg`,
40
+ svg: processedSvg
41
+ };
42
+ }
43
+
44
+ //#endregion
45
+ exports.processIconVariant = processIconVariant;
@@ -0,0 +1,46 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ import { processSvgWithVariables } from "./colorUtils.js";
3
+
4
+ //#region scripts/processIconVariant.ts
5
+ const EMPTY_COLOR_MAP = /* @__PURE__ */ new Map();
6
+ /**
7
+ * Processes an SVG based on its variant type and returns the processed SVG content
8
+ * with appropriate file name.
9
+ */
10
+ function processIconVariant({ svg, component, getColorMap }) {
11
+ const { name, size, variant } = component;
12
+ let colorMode = "light";
13
+ let fallback = "current";
14
+ let filePrefix = variant;
15
+ if (!name || !size || !variant) throw new Error("Missing required component information");
16
+ if (variant === "fill" || variant === "outline") return {
17
+ fileName: `${name}-${variant}-${size}.svg`,
18
+ svg: processSvgWithVariables({
19
+ svg,
20
+ colorMap: EMPTY_COLOR_MAP
21
+ })
22
+ };
23
+ if (variant === "light" || variant === "dark") {
24
+ fallback = "preserve";
25
+ colorMode = variant;
26
+ } else if (variant === "multicolor") {
27
+ fallback = "preserve";
28
+ filePrefix = "multicolor";
29
+ }
30
+ const processedSvg = processSvgWithVariables({
31
+ svg,
32
+ colorMap: getColorMap(colorMode),
33
+ options: {
34
+ fallback,
35
+ colorMode
36
+ }
37
+ });
38
+ return {
39
+ fileName: `${name}-${filePrefix}-${size}.svg`,
40
+ svg: processedSvg
41
+ };
42
+ }
43
+
44
+ //#endregion
45
+ export { processIconVariant };
46
+ //# sourceMappingURL=processIconVariant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processIconVariant.js","names":[],"sources":["../../scripts/processIconVariant.ts"],"sourcesContent":["import { processSvgWithVariables } from './colorUtils';\nimport type { IconComponentInfo } from './types';\n\nconst EMPTY_COLOR_MAP = new Map<string, string>();\n\n/**\n * Options for processing an icon SVG\n */\nexport interface ProcessIconOptions {\n /** The SVG content to process */\n svg: string;\n /** Component information including name, size, and variant */\n component: IconComponentInfo;\n /** Function to get color map for a given mode */\n getColorMap: (mode: 'light' | 'dark') => Map<string, string>;\n}\n\n/**\n * Result of processing an icon SVG\n */\nexport interface ProcessedIcon {\n /** The filename to save the processed SVG as */\n fileName: string;\n /** The processed SVG content */\n svg: string;\n}\n\n/**\n * Processes an SVG based on its variant type and returns the processed SVG content\n * with appropriate file name.\n */\nexport function processIconVariant({\n svg,\n component,\n getColorMap,\n}: ProcessIconOptions): ProcessedIcon {\n const { name, size, variant } = component;\n let colorMode: 'light' | 'dark' = 'light';\n let fallback: 'preserve' | 'current' = 'current';\n let filePrefix = variant;\n\n if (!name || !size || !variant) {\n throw new Error('Missing required component information');\n }\n\n // For fill/outline variants, we want to convert all colors to currentColor\n // without any color mapping\n if (variant === 'fill' || variant === 'outline') {\n return {\n fileName: `${name}-${variant}-${size}.svg`,\n svg: processSvgWithVariables({ svg, colorMap: EMPTY_COLOR_MAP }),\n };\n }\n\n // For multicolor, light, and dark variants, we want to do color mapping\n // Determine color mode and fallback strategy based on variant\n if (variant === 'light' || variant === 'dark') {\n fallback = 'preserve';\n colorMode = variant;\n } else if (variant === 'multicolor') {\n fallback = 'preserve';\n filePrefix = 'multicolor';\n }\n\n // Process SVG with color mapping\n const processedSvg = processSvgWithVariables({\n svg,\n colorMap: getColorMap(colorMode),\n options: { fallback, colorMode },\n });\n\n return {\n fileName: `${name}-${filePrefix}-${size}.svg`,\n svg: processedSvg,\n };\n}\n"],"mappings":";;;;AAGA,MAAM,kCAAkB,IAAI,KAAqB;;;;;AA4BjD,SAAgB,mBAAmB,EACjC,KACA,WACA,eACoC;CACpC,MAAM,EAAE,MAAM,MAAM,YAAY;CAChC,IAAI,YAA8B;CAClC,IAAI,WAAmC;CACvC,IAAI,aAAa;AAEjB,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QACrB,OAAM,IAAI,MAAM,yCAAyC;AAK3D,KAAI,YAAY,UAAU,YAAY,UACpC,QAAO;EACL,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK;EACrC,KAAK,wBAAwB;GAAE;GAAK,UAAU;GAAiB,CAAC;EACjE;AAKH,KAAI,YAAY,WAAW,YAAY,QAAQ;AAC7C,aAAW;AACX,cAAY;YACH,YAAY,cAAc;AACnC,aAAW;AACX,eAAa;;CAIf,MAAM,eAAe,wBAAwB;EAC3C;EACA,UAAU,YAAY,UAAU;EAChC,SAAS;GAAE;GAAU;GAAW;EACjC,CAAC;AAEF,QAAO;EACL,UAAU,GAAG,KAAK,GAAG,WAAW,GAAG,KAAK;EACxC,KAAK;EACN"}
@@ -0,0 +1,77 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ const require_createIconsUtils = require('../createIconsUtils.cjs');
4
+ const require_colors = require('../../cli/dist/lib/colors.cjs');
5
+ const require_print = require('../../cli/dist/lib/print.cjs');
6
+ let node_path = require("node:path");
7
+ node_path = require_runtime.__toESM(node_path);
8
+
9
+ //#region src/cli/createIconsCommand.ts
10
+ const showHelp = () => {
11
+ require_print.print("");
12
+ require_print.print(`${require_colors.green("uds create-icons")} - Generate grouped IconDefinition modules from SVG files`);
13
+ require_print.print("");
14
+ require_print.print(`${require_colors.magenta("Usage:")}`);
15
+ require_print.print(` ${require_colors.cyan("uds create-icons <PATH_TO_INPUT_DIR>")} [options]`);
16
+ require_print.print("");
17
+ require_print.print(`${require_colors.magenta("Arguments:")}`);
18
+ require_print.print(` ${require_colors.cyan("PATH_TO_INPUT_DIR")} Directory containing SVGs named IconName-variant-size.svg`);
19
+ require_print.print("");
20
+ require_print.print(`${require_colors.magenta("Options:")}`);
21
+ require_print.print(` ${require_colors.cyan("--outDir <path>")} Output directory (default: dist)`);
22
+ require_print.print(` ${require_colors.cyan("--format <ts|js>")} Output format (default: ts)`);
23
+ require_print.print(` ${require_colors.cyan("--help, -h")} Show this help message`);
24
+ require_print.print("");
25
+ require_print.print(`${require_colors.magenta("Example:")}`);
26
+ require_print.print(` ${require_colors.gray("uds create-icons ./packages/icons/assets --outDir ./dist/icons")}`);
27
+ require_print.print("");
28
+ };
29
+ function getFormat(value) {
30
+ if (!value || typeof value !== "string") return "ts";
31
+ if (value === "ts" || value === "js") return value;
32
+ return null;
33
+ }
34
+ function getOutDir(optionValue) {
35
+ if (!optionValue || typeof optionValue !== "string") return node_path.default.resolve(process.cwd(), "dist");
36
+ return node_path.default.resolve(process.cwd(), optionValue);
37
+ }
38
+ const makeCreateIconsCommand = () => ({
39
+ name: "create-icons",
40
+ description: "Create grouped IconDefinition modules from SVG assets directory",
41
+ run: async ({ first, options }) => {
42
+ if (options.help === "true" || options.h === "true") {
43
+ showHelp();
44
+ return;
45
+ }
46
+ if (!first) {
47
+ require_print.print(require_colors.red("Missing input directory argument."));
48
+ showHelp();
49
+ process.exitCode = 1;
50
+ return;
51
+ }
52
+ const format = getFormat(options.format);
53
+ if (!format) {
54
+ require_print.print(require_colors.red(`Invalid --format value: ${String(options.format)}. Expected "ts" or "js".`));
55
+ process.exitCode = 1;
56
+ return;
57
+ }
58
+ const inputDir = node_path.default.resolve(process.cwd(), first);
59
+ const outDir = getOutDir(options.outDir);
60
+ try {
61
+ const result = await require_createIconsUtils.createIconsFromDirectory({
62
+ inputDir,
63
+ outDir,
64
+ format
65
+ });
66
+ require_print.print(require_colors.green(`Generated ${result.generatedCount} icon definition file(s) in ${outDir}.`));
67
+ require_print.print(require_colors.green(`Generated barrel file: ${result.barrelFilePath}`));
68
+ if (result.skippedFiles.length > 0) require_print.print(`Skipped ${result.skippedFiles.length} non-matching SVG file(s): ${result.skippedFiles.join(", ")}`);
69
+ } catch (error) {
70
+ require_print.print(require_colors.red(error.message));
71
+ process.exitCode = 1;
72
+ }
73
+ }
74
+ });
75
+
76
+ //#endregion
77
+ exports.makeCreateIconsCommand = makeCreateIconsCommand;
@@ -0,0 +1,8 @@
1
+
2
+ import { Command } from "@yahoo/uds-cli/lib";
3
+
4
+ //#region src/cli/createIconsCommand.d.ts
5
+ declare const makeCreateIconsCommand: () => Command;
6
+ //#endregion
7
+ export { makeCreateIconsCommand };
8
+ //# sourceMappingURL=createIconsCommand.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createIconsCommand.d.cts","names":[],"sources":["../../../src/cli/createIconsCommand.ts"],"mappings":";;;;cAkDM,sBAAA,QAA6B,OAAA"}
@@ -0,0 +1,8 @@
1
+
2
+ import { Command } from "@yahoo/uds-cli/lib";
3
+
4
+ //#region src/cli/createIconsCommand.d.ts
5
+ declare const makeCreateIconsCommand: () => Command;
6
+ //#endregion
7
+ export { makeCreateIconsCommand };
8
+ //# sourceMappingURL=createIconsCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createIconsCommand.d.ts","names":[],"sources":["../../../src/cli/createIconsCommand.ts"],"mappings":";;;;cAkDM,sBAAA,QAA6B,OAAA"}