color-2-name 1.4.2 → 1.4.3
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts", "../../src/data/colorSet.ts", "../../src/common.ts", "../../src/rgb-utils.ts", "../../src/hex-utils.ts", "../../src/hsl-utils.ts", "../../src/color-utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { getColor, getColors } from \"./color-utils.js\";\nimport {\n\tBLACKANDWHITE,\n\tRGBSET,\n\thexRegex,\n\thslRegex,\n\trgbRegex,\n} from \"./common.js\";\nimport colorSet from \"./data/colorSet.js\";\nimport { hexToRgb, parseHex, valuesToHex } from \"./hex-utils.js\";\nimport { hslToRgb, parseHsl } from \"./hsl-utils.js\";\nimport { getRgbValues, parseRgb } from \"./rgb-utils.js\";\nimport type {\n\tCOLORDEF,\n\tCOLORSTRING,\n\tColorParsers,\n\tHEX,\n\tRGBCOLORDEF,\n\tRGBDEF,\n\tRGBVALUE,\n} from \"./types.js\";\n\nexport const colorParsers: ColorParsers[] = [\n\t{ regex: hexRegex, parser: parseHex, converter: hexToRgb },\n\t{ regex: rgbRegex, parser: parseRgb, converter: getRgbValues },\n\t{ regex: hslRegex, parser: parseHsl, converter: hslToRgb },\n];\n\n/**\n * Given a color string, it returns the closest corresponding name of the color.\n * Uses the Euclidean distance formula to calculate the distance between colors in the RGB color space.\n *\n * @param {string} color - the color string you want to find the closest color name\n * @param {Object} set - the color set that will be used to find the closest color\n * @param {Object} args - Set a non nullish value to return some additional information (like the distance between the colors, or the hex color value)\n * @param args.info - Set a non nullish value to return some additional information (like the distance between the colors, or the hex color value) about the closest color.\n *\n * @return {Object} the closest color name and rgb value\n *\n * @example // Returns the closest color name and rgb value given a css color string\n * closest('#f00'); // { name: 'red', color: 'rgb(255,0,0)' }\n *\n * closest('#f00', undefined, {info:true}); // { name: 'red', color: 'rgb(255,0,0)', hex: '#ff0000', hsl: 'hsl(0, 100%, 50%)', distance: 0 ) }\n */\nfunction closest(\n\tcolor: string | COLORSTRING,\n\tset: RGBCOLORDEF[] | undefined = colorSet as RGBCOLORDEF[],\n\targs?: { info?: boolean },\n): COLORDEF {\n\tlet closestGap = Number.MAX_SAFE_INTEGER;\n\tconst closestColor: COLORDEF = { name: \"error\", color: \"#F00\" };\n\n\tif (set.length < 1) {\n\t\treturn closestColor;\n\t}\n\n\tconst rgbColorValues = Object.values(parseColor(color));\n\tconst colorSetLength = set.length;\n\t// Precompute RGB values if needed\n\tconst precomputedRGBValues = set.map((item) => [item[0], item[1], item[2]]);\n\n\t// Find the closest color in the color set\n\tfor (let i = 0; i < colorSetLength; i++) {\n\t\tconst tested = precomputedRGBValues[i];\n\t\tconst gap = distance(rgbColorValues as RGBDEF, tested, true);\n\t\tif (gap < closestGap) {\n\t\t\tclosestGap = gap;\n\t\t\tclosestColor.name = set[i][3];\n\t\t\tclosestColor.color = `rgb(${set[i][0]},${set[i][1]},${set[i][2]})`;\n\t\t}\n\n\t\t// Break if exact match found\n\t\tif (gap === 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (args?.info) {\n\t\tconst colorValue = getColor(closestColor.name, set);\n\t\treturn {\n\t\t\t...colorValue,\n\t\t\t...closestColor,\n\t\t\tgap: Math.sqrt(closestGap),\n\t\t};\n\t}\n\n\treturn closestColor;\n}\n\n/**\n * This function takes a string representing a color (color) and uses regular expressions to check if it matches any of the following formats: hex, hex+alpha, RGB, RGBA, HSL, or HSLA.\n * If the color string matches one of these formats, the function returns an object with the type of color and the value of the color.\n * If the color string does not match any of the formats, the function throws an error.\n *\n * @param {string} colorString - the color string to test and convert to rgb values\n *\n * @return {Object|Error} the object with rgb values of that color\n */\nexport function parseColor(colorString: string): RGBVALUE {\n\tfor (const { regex, parser, converter } of colorParsers) {\n\t\tif (regex.test(colorString)) {\n\t\t\tconst result = parser(colorString as COLORSTRING);\n\t\t\treturn converter(result);\n\t\t}\n\t}\n\n\t// If the color string does not match any of the regular expressions, return an error\n\tthrow new Error(`Invalid color: ${colorString}`);\n}\n\n/**\n * Given a color returns if the color is light (by light is meant more mathematically closer to white)\n *\n * @param {string} color - The color to check\n *\n * @returns {boolean} true when the color is light, false otherwise\n *\n * @example isLight('#ddd'); // true\n */\nfunction isLight(color: string): boolean {\n\treturn closest(color, BLACKANDWHITE).name === \"white\";\n}\n\n/**\n * Given a color returns if the color is dark (by dark is meant more mathematically closer to black)\n *\n * @param {string} color - The color to check\n *\n * @returns {boolean} true when the color is dark, false otherwise\n *\n * @example isDark('#333'); // true\n */\nfunction isDark(color: string): boolean {\n\treturn closest(color, BLACKANDWHITE).name === \"black\";\n}\n\n/**\n * Given a color returns if the color is closer to \"red\", \"green\" or \"blue\".\n *\n * @param {string} color - The color to check\n *\n * @returns {string} light when the color is close to white, dark otherwise\n *\n * @example closestRGB('#f00'); // 'red'\n */\nfunction closestRGB(color: string): string {\n\treturn closest(color, RGBSET).name;\n}\n\n/**\n * Compute the distance between the two RGB values\n * There are two modes:\n * fast = true -> the distance is calculated without using the Euclidean formula completely, it is reliable but its result is exponential\n * fast = false -> the distance is calculated with the Euclidean formula, its result is linear\n *\n * @param rgb1 - The RGB value of the first color to compare\n * @param rgb2 - The RGB value of the second color to compare\n * @param fast - If you want to calculate the distance without calculating the square root, the result will be exponential otherwise is linear\n *\n * @return {number} the distance between the two RGB values\n *\n * @example distance([10, 20, 30], [120, 120, 120]); // 173.78147196982766\n */\nfunction distance(\n\trgb1: [number, number, number],\n\trgb2: [number, number, number, string] | number[],\n\tfast = false,\n): number {\n\tconst [rDiff, gDiff, bDiff] = [\n\t\trgb2[0] - rgb1[0],\n\t\trgb2[1] - rgb1[1],\n\t\trgb2[2] - rgb1[2],\n\t];\n\tconst dist = rDiff * rDiff + gDiff * gDiff + bDiff * bDiff;\n\treturn fast ? dist : Math.sqrt(dist);\n}\n\n/**\n * Given a color string it returns the hex representation\n *\n * @param rgbString - the rgb color string to convert to hex\n *\n * @return {string} the corresponding color hex\n *\n * @example rgbToHex(\"rgba(100% 0 0 / .5)\"); // #FF0000\n */\nfunction rgbToHex(rgbString: string): HEX | Error {\n\t// if is a rgb string\n\tif (rgbRegex.test(rgbString)) {\n\t\tconst rgb = parseRgb(rgbString);\n\t\tconst RgbValues = getRgbValues(rgb);\n\t\treturn valuesToHex(RgbValues);\n\t}\n\tthrow new Error(`Invalid color: ${rgbString}`);\n}\n\nexport {\n\tclosest,\n\trgbToHex,\n\tdistance,\n\tisLight,\n\tisDark,\n\tclosestRGB,\n\tgetColor,\n\tgetColors,\n};\n", "const colorSet = [\n [255, 255, 255, \"white\"],\n [0, 0, 0, \"black\"],\n [255, 0, 0, \"red\"],\n [0, 128, 0, \"green\"],\n [0, 0, 255, \"blue\"],\n [255, 165, 0, \"orange\"],\n [128, 128, 128, \"grey\"],\n [255, 255, 0, \"yellow\"],\n [255, 0, 255, \"magenta\"],\n [154, 205, 50, \"yellowgreen\"],\n [192, 192, 192, \"silver\"],\n [0, 255, 0, \"lime\"],\n [128, 0, 128, \"purple\"],\n [255, 99, 71, \"tomato\"],\n [64, 224, 208, \"turquoise\"],\n [255, 127, 80, \"coral\"],\n [0, 255, 255, \"cyan\"],\n [255, 250, 240, \"floralwhite\"],\n [255, 192, 203, \"pink\"],\n [34, 139, 34, \"forestgreen\"],\n [245, 245, 220, \"beige\"],\n [255, 0, 255, \"fuchsia\"],\n [220, 220, 220, \"gainsboro\"],\n [248, 248, 255, \"ghostwhite\"],\n [255, 215, 0, \"gold\"],\n [218, 165, 32, \"goldenrod\"],\n [173, 255, 47, \"greenyellow\"],\n [238, 130, 238, \"violet\"],\n [245, 222, 179, \"wheat\"],\n [245, 245, 245, \"whitesmoke\"],\n [139, 0, 0, \"darkred\"],\n [240, 248, 255, \"aliceblue\"],\n [205, 92, 92, \"indianred\"],\n [75, 0, 130, \"indigo\"],\n [250, 235, 215, \"antiquewhite\"],\n [0, 255, 255, \"aqua\"],\n [127, 255, 212, \"aquamarine\"],\n [240, 255, 255, \"azure\"],\n [255, 228, 196, \"bisque\"],\n [255, 235, 205, \"blanchedalmond\"],\n [138, 43, 226, \"blueviolet\"],\n [165, 42, 42, \"brown\"],\n [222, 184, 135, \"burlywood\"],\n [95, 158, 160, \"cadetblue\"],\n [127, 255, 0, \"chartreuse\"],\n [210, 105, 30, \"chocolate\"],\n [100, 149, 237, \"cornflowerblue\"],\n [255, 248, 220, \"cornsilk\"],\n [220, 20, 60, \"crimson\"],\n [0, 0, 139, \"darkblue\"],\n [0, 139, 139, \"darkcyan\"],\n [184, 134, 11, \"darkgoldenrod\"],\n [169, 169, 169, \"darkgrey\"],\n [0, 100, 0, \"darkgreen\"],\n [189, 183, 107, \"darkkhaki\"],\n [139, 0, 139, \"darkmagenta\"],\n [85, 107, 47, \"darkolivegreen\"],\n [255, 140, 0, \"darkorange\"],\n [153, 50, 204, \"darkorchid\"],\n [233, 150, 122, \"darksalmon\"],\n [143, 188, 143, \"darkseagreen\"],\n [72, 61, 139, \"darkslateblue\"],\n [47, 79, 79, \"darkslategrey\"],\n [0, 206, 209, \"darkturquoise\"],\n [148, 0, 211, \"darkviolet\"],\n [255, 20, 147, \"deeppink\"],\n [0, 191, 255, \"deepskyblue\"],\n [105, 105, 105, \"dimgrey\"],\n [30, 144, 255, \"dodgerblue\"],\n [178, 34, 34, \"firebrick\"],\n [240, 255, 240, \"honeydew\"],\n [255, 105, 180, \"hotpink\"],\n [255, 255, 240, \"ivory\"],\n [240, 230, 140, \"khaki\"],\n [230, 230, 250, \"lavender\"],\n [255, 240, 245, \"lavenderblush\"],\n [124, 252, 0, \"lawngreen\"],\n [255, 250, 205, \"lemonchiffon\"],\n [173, 216, 230, \"lightblue\"],\n [240, 128, 128, \"lightcoral\"],\n [224, 255, 255, \"lightcyan\"],\n [250, 250, 210, \"lightgoldenrodyellow\"],\n [144, 238, 144, \"lightgreen\"],\n [211, 211, 211, \"lightgrey\"],\n [255, 182, 193, \"lightpink\"],\n [255, 160, 122, \"lightsalmon\"],\n [32, 178, 170, \"lightseagreen\"],\n [135, 206, 250, \"lightskyblue\"],\n [119, 136, 153, \"lightslategrey\"],\n [176, 196, 222, \"lightsteelblue\"],\n [255, 255, 224, \"lightyellow\"],\n [50, 205, 50, \"limegreen\"],\n [250, 240, 230, \"linen\"],\n [128, 0, 0, \"maroon\"],\n [102, 205, 170, \"mediumaquamarine\"],\n [0, 0, 205, \"mediumblue\"],\n [186, 85, 211, \"mediumorchid\"],\n [147, 112, 219, \"mediumpurple\"],\n [60, 179, 113, \"mediumseagreen\"],\n [123, 104, 238, \"mediumslateblue\"],\n [0, 250, 154, \"mediumspringgreen\"],\n [72, 209, 204, \"mediumturquoise\"],\n [199, 21, 133, \"mediumvioletred\"],\n [25, 25, 112, \"midnightblue\"],\n [245, 255, 250, \"mintcream\"],\n [255, 228, 225, \"mistyrose\"],\n [255, 228, 181, \"moccasin\"],\n [255, 222, 173, \"navajowhite\"],\n [0, 0, 128, \"navy\"],\n [253, 245, 230, \"oldlace\"],\n [128, 128, 0, \"olive\"],\n [107, 142, 35, \"olivedrab\"],\n [255, 69, 0, \"orangered\"],\n [218, 112, 214, \"orchid\"],\n [238, 232, 170, \"palegoldenrod\"],\n [152, 251, 152, \"palegreen\"],\n [175, 238, 238, \"paleturquoise\"],\n [219, 112, 147, \"palevioletred\"],\n [255, 239, 213, \"papayawhip\"],\n [255, 218, 185, \"peachpuff\"],\n [205, 133, 63, \"peru\"],\n [221, 160, 221, \"plum\"],\n [176, 224, 230, \"powderblue\"],\n [102, 51, 153, \"rebeccapurple\"],\n [188, 143, 143, \"rosybrown\"],\n [65, 105, 225, \"royalblue\"],\n [139, 69, 19, \"saddlebrown\"],\n [250, 128, 114, \"salmon\"],\n [244, 164, 96, \"sandybrown\"],\n [46, 139, 87, \"seagreen\"],\n [255, 245, 238, \"seashell\"],\n [160, 82, 45, \"sienna\"],\n [135, 206, 235, \"skyblue\"],\n [106, 90, 205, \"slateblue\"],\n [112, 128, 144, \"slategrey\"],\n [255, 250, 250, \"snow\"],\n [0, 255, 127, \"springgreen\"],\n [70, 130, 180, \"steelblue\"],\n [210, 180, 140, \"tan\"],\n [0, 128, 128, \"teal\"],\n [216, 191, 216, \"thistle\"],\n];\n\nexport default colorSet;\n", "// Regular expressions to match different color formats\nimport type { RGBCOLORDEF } from \"./types.js\";\n\n/** The maximum distance possible between colors */\nexport const MAXDISTANCE = 441.6729559300637;\n\n/** A regex to match hex colors */\nexport const hexRegex: RegExp = /^#([\\da-f]{3,8})/i;\n/** A regex to match rgb colors */\nexport const rgbRegex: RegExp = /^rgba?\\(([^)]+)\\)/i;\n/** A regex to match hsl colors */\nexport const hslRegex: RegExp = /^hsla?\\(([^)]+)\\)/i;\n/** A regex to match strings that are only valid numbers with and without decimals and the number can be negative and without the 0 in the beginning */\nexport const isNumeric: RegExp = /^-?\\d*\\.?\\d+$/i;\n/** Remove comments from string */\nexport const stripComments: RegExp = /(\\/\\*[^*]*\\*\\/)|(\\/\\/[^*]*)/g;\n\n/**\n * This set is used to detect if the color is bright or dark\n *\n * @note the set has been corrected to get pure RGB values (eg. pure red, pure green) in the \"bright\" area\n */\nexport const BLACKANDWHITE: RGBCOLORDEF[] = [\n\t[255, 255, 255, \"white\"],\n\t[1, 1, 1, \"black\"],\n];\n\n/**\n * This set is used to detect the nearest rgb color\n */\nexport const RGBSET: RGBCOLORDEF[] = [\n\t[255, 0, 0, \"red\"],\n\t[0, 255, 0, \"green\"],\n\t[0, 0, 255, \"blue\"],\n];\n\n/**\n * split the content of rgb and hsl colors depending on the parsed value of the css property\n *\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb#syntax\n *\n * @param {string} rawValues - the value inside the rgb(.*) css color definition\n *\n * @return {Array} the array of rgb values found inside the passed string\n */\nexport function splitValues(rawValues: string): string[] {\n\treturn rawValues\n\t\t.split(rawValues.includes(\",\") ? \",\" : \" \")\n\t\t.map((s) => s.trim());\n}\n\n/**\n * If the value is an angle in degrees, convert it to the 0-360 range\n *\n * @param {string} angle - the degrees to convert into a number\n *\n * @return {number} the converted value\n */\nexport function normalizeDegrees(angle: string): number {\n\t// Strip label and convert to degrees (if necessary)\n\tlet degAngle = Number.parseFloat(angle) || 0;\n\tif (angle.indexOf(\"deg\") > -1) {\n\t\tdegAngle = Number.parseFloat(angle.substring(0, angle.length - 3));\n\t} else if (angle.indexOf(\"rad\") > -1) {\n\t\tdegAngle = Math.round(\n\t\t\tNumber.parseFloat(angle.substring(0, angle.length - 3)) * (180 / Math.PI),\n\t\t);\n\t} else if (angle.indexOf(\"turn\") > -1) {\n\t\tdegAngle = Math.round(\n\t\t\tNumber.parseFloat(angle.substring(0, angle.length - 4)) * 360,\n\t\t);\n\t}\n\n\twhile (degAngle < 0) {\n\t\tdegAngle += 360;\n\t}\n\n\t// Make sure it's a number between 0 and 360\n\tif (degAngle >= 360) degAngle %= 360;\n\n\treturn degAngle;\n}\n\n/**\n * Returns a value that is limited between a minimum and maximum value.\n *\n * @param {number} value - The value to be limited.\n * @param {number} min - The minimum allowed value (default is 0).\n * @param {number} max - The maximum allowed value (default is 0).\n * @return {number} The limited value.\n */\nexport function limitValue(value: number, min = 0, max = 0): number {\n\treturn Math.min(Math.max(Math.round(value), min), max);\n}\n\n/**\n * Calculates the value based on a given string and multiplier.\n *\n * @param {string} valueString - The string representing the value to be calculated.\n * @param {number} multiplier - The multiplier to be applied to the calculated value.\n * @return {number} The calculated value.\n */\nexport function calculateValue(\n\tvalueString: string,\n\tmultiplier: number,\n): number {\n\t// Regular expression to match the calc() function and extract the numerical value\n\tconst regex = /calc\\(([^)]+)\\)/;\n\n\t// Match the calc() function in the CSS string\n\tconst match = valueString.match(regex);\n\n\treturn convertToInt8(match ? match[1] : valueString, multiplier);\n}\n\n/**\n * Removes comments from the input string and extracts the content between the first opening parenthesis\n * and the last closing parenthesis.\n *\n * @param {string} string - The input string.\n * @return {string} The content between the first opening parenthesis and the last closing parenthesis.\n */\nexport function cleanDefinition(string: string): string {\n\t// Remove comments from the string\n\tconst cleanString = string.replace(stripComments, \"\");\n\n\t// Find the positions of the first opening and the last closing parentheses\n\tconst firstParenthesisIndex = cleanString.indexOf(\"(\");\n\tconst lastParenthesisIndex = cleanString.lastIndexOf(\")\");\n\n\t// Extract the content between the parentheses\n\treturn cleanString\n\t\t.slice(firstParenthesisIndex + 1, lastParenthesisIndex)\n\t\t.trim();\n}\n\n/**\n * Normalizes a percentage value by dividing it by 100 and multiplying it by a given multiplier.\n *\n * @param {string} value - The percentage value to be normalized.\n * @param {number} multiplier - The number to multiply the normalized percentage by.\n * @return {number} The normalized percentage value.\n */\nexport function normalizePercentage(value: string, multiplier: number): number {\n\treturn (Number.parseFloat(value) / 100) * multiplier;\n}\n\n/**\n * Calculates the color value fallbacks for a given value.\n *\n * @param {string} value - The color value to calculate fallbacks for.\n * @param {string} [err] - An optional error message to display.\n * @return {number} - The calculated color value fallbacks.\n */\nexport function colorValueFallbacks(value: string, err?: string): number {\n\tif (value === \"infinity\") {\n\t\tconsole.warn(\n\t\t\terr || `Positive infinity value has been set to 255: ${value}`,\n\t\t);\n\t\treturn 255;\n\t}\n\n\tif (value === \"currentColor\")\n\t\tconsole.warn(err || `The \"currentColor\" value has been set to 0: ${value}`);\n\tif (value === \"transparent\")\n\t\tconsole.warn(err || `The \"transparent\" value has been set to 0: ${value}`);\n\tif (value === \"NaN\")\n\t\tconsole.warn(err || `\"NaN\" value has been set to 0: ${value}`);\n\tif (value === \"-infinity\")\n\t\tconsole.warn(\n\t\t\terr || `\"Negative\" infinity value has been set to 0: ${value}`,\n\t\t);\n\tif (value === \"none\")\n\t\tconsole.warn(\n\t\t\terr || `The none keyword is invalid in legacy color syntax: ${value}`,\n\t\t);\n\treturn 0;\n}\n\n/**\n * Takes a string with a css value that could be a number or percentage or an angle in degrees and returns the corresponding 8bit value\n *\n * @param value - a valid value for the css color definition (like 255, \"100%\", \"324deg\", etc.) *\n * @param multiplier - the number that represent the maximum - default is 255 decimal - 100 hex\n *\n * @example convertToInt8('100%'); // 255\n *\n * @return {string} the corresponding value in 8-bit format\n */\nexport function convertToInt8(\n\tvalue: string | unknown,\n\tmultiplier = 255,\n): number {\n\tconst newValue = typeof value === \"string\" ? value?.trim() : \"0\";\n\tif (isNumeric.test(newValue)) {\n\t\t// limit the min and the max newValue\n\t\treturn limitValue(Number.parseFloat(newValue) || 0, 0, multiplier);\n\t}\n\tif (newValue.endsWith(\"%\")) {\n\t\t// If the newValue is a percentage, divide it by 100 to get a newValue from 0 to 1\n\t\t// and then multiply it by 255 to get a newValue from 0 to 255\n\t\treturn normalizePercentage(newValue, multiplier) || 0;\n\t}\n\tif (\n\t\tnewValue.endsWith(\"deg\") ||\n\t\tnewValue.endsWith(\"rad\") ||\n\t\tnewValue.endsWith(\"turn\")\n\t) {\n\t\treturn normalizeDegrees(newValue);\n\t}\n\tif (newValue.startsWith(\"calc\")) {\n\t\t// get the newValue from the calc function\n\t\treturn limitValue(calculateValue(newValue, multiplier), 0, multiplier);\n\t}\n\n\t// If the value is not a percentage or an angle in degrees, it is invalid\n\treturn colorValueFallbacks(newValue, `Invalid value: ${value}`);\n}\n", "import {\n\tcleanDefinition,\n\tconvertToInt8,\n\tlimitValue,\n\tsplitValues,\n} from \"./common.js\";\nimport type { RGBVALUE } from \"./types.js\";\n\nexport function fallbackRGB(\n\trgb: string[],\n\terr = \"Invalid RGB color\",\n): string[] {\n\tconsole.warn(err);\n\treturn [rgb[0] ?? 0, rgb[1] ?? 0, rgb[2]];\n}\n\n/**\n * Get the values of the rgb string\n *\n * @param rgbAsString - the rgb color as string split into values\n *\n * @return {Array} the values of the rgb string as Array of strings that represent the rgb color\n */\nexport function parseRgb(rgbAsString: string): string[] {\n\tconst rgbvalue = cleanDefinition(rgbAsString);\n\n\tconst rgb: string[] = splitValues(rgbvalue);\n\n\tif (rgb.length !== 3 && rgb.length !== 4) {\n\t\treturn fallbackRGB(\n\t\t\trgb,\n\t\t\t`Too few values to define rgb: ${rgbAsString} -> ${rgbvalue}`,\n\t\t);\n\t}\n\treturn [rgb[0], rgb[1], rgb[2]];\n}\n\n/**\n * This function takes an array of strings and returns and object with the rgb values converted into INT8 (0-255)\n *\n * @param {Array} rgb - rgb color as Array of strings\n *\n * @return {Object} an object that contains the r, g and b values as INT8\n */\nexport function getRgbValues(rgb: string[]): RGBVALUE {\n\t// use the channel key as the new array key\n\treturn {\n\t\tr: limitValue(Math.round(convertToInt8(rgb[0])), 0, 255) || 0,\n\t\tg: limitValue(Math.round(convertToInt8(rgb[1])), 0, 255) || 0,\n\t\tb: limitValue(Math.round(convertToInt8(rgb[2])), 0, 255) || 0,\n\t};\n}\n\n/**\n * returns a string representation of the rgb values\n *\n * @param {Object} rgb the rgb color object\n *\n * @return {string} a string representation of the rgb values\n */\nexport function RGB(rgb: RGBVALUE): string {\n\treturn `rgb(${rgb.r},${rgb.g},${rgb.b})`;\n}\n", "import { fallbackRGB } from \"./rgb-utils.js\";\nimport type { COLORSTRING, HEX, RGBVALUE } from \"./types.js\";\n\n/**\n * It returns an object with the hex values of the 3 digit hex color\n *\n * @param {string} value 3 digit hex\n * @return {string[]} 6 digit hex\n */\nexport function shortHexToLongHex(value: string): string[] {\n\t// split the string in to an array of digits then return an array that contains that digit doubled for each item\n\treturn Array.from(value).map((v: string) => (v + v).toUpperCase());\n}\n\n/**\n * Checks if a given string represents a hexadecimal number.\n *\n * @param {string} num - The string to be checked.\n * @return {boolean} Returns true if the string is a valid hexadecimal number, false otherwise.\n */\nexport function isHex(num: string): boolean {\n\treturn Boolean(num.match(/^[0-9a-f]+$/i));\n}\n\n/**\n * Get the hex value of the color and convert it to an Object of R G And B values (still in hex format)\n *\n * @param value the string that contains the color in hex format\n *\n * @return {string[]} an array of 6 digit hex values in a triplet of R G and B (HEX format)\n */\nexport function parseHex(value: COLORSTRING): string[] {\n\t// remove # at the beginning of the hex color\n\tconst hexColor: string = value.substring(1);\n\n\t/**\n\t * then if the number of digits is greater than 2 (so it's something like 123 or abc456)\n\t * breakdown the string into an object that contains the r g and b values in hex\n\t */\n\tlet hexArray: string[] = [];\n\tif (hexColor) {\n\t\tif (hexColor.length === 3 || hexColor.length === 4) {\n\t\t\thexArray = shortHexToLongHex(hexColor);\n\t\t} else if (hexColor.length === 6 || hexColor.length === 8) {\n\t\t\t// match the hex value in groups of 2\n\t\t\thexArray = (hexColor.match(/../g) || []).map((value: string) => value);\n\t\t}\n\t}\n\n\tif (hexArray.length) {\n\t\thexArray?.forEach((value, index) => {\n\t\t\tif (isHex(value)) {\n\t\t\t\thexArray[index] = value.toUpperCase();\n\t\t\t} else {\n\t\t\t\tconsole.warn(`Invalid Hex value: ${value}`);\n\t\t\t}\n\t\t});\n\n\t\treturn hexArray;\n\t}\n\n\tconsole.warn(`Invalid Hex: ${value}`);\n\treturn fallbackRGB(hexArray);\n}\n\n/**\n * Converts a Hex color to rgb\n *\n * @param {string} hex a tuple of hex values\n *\n * @return {string} the rgb color values for the given hex color\n */\nexport function hexToRgb(hex: string[]): RGBVALUE {\n\t// Extract the RGB values from the hex string\n\treturn {\n\t\tr: Number.parseInt(hex[0], 16),\n\t\tg: Number.parseInt(hex[1], 16),\n\t\tb: Number.parseInt(hex[2], 16),\n\t};\n}\n\n/**\n * Convert a INT8 value to HEX\n *\n * @param {number} int8 - the integer value to convert\n *\n * @return {string} the hex string\n */\nexport function toHex(int8: number): string {\n\treturn int8.toString(16).padStart(2, \"0\");\n}\n\n/**\n * Convert rgb values to hex color\n *\n * @param {Object} rgb an object with the rgb values\n *\n * @return {string} the hex string\n */\nexport function valuesToHex(rgb: RGBVALUE): HEX {\n\t// Extract the RGB values from the hex string\n\treturn `#${toHex(rgb?.r)}${toHex(rgb?.g)}${toHex(rgb?.b)}`;\n}\n", "import {\n\tcleanDefinition,\n\tcolorValueFallbacks,\n\tconvertToInt8,\n\tnormalizeDegrees,\n\tsplitValues,\n} from \"./common.js\";\nimport type { HSLVALUE, RGBVALUE } from \"./types.js\";\n\nexport function fallbackHSL(\n\thsl: string[],\n\terr = \"Invalid HSL color\",\n): string[] {\n\tconsole.warn(err);\n\treturn [hsl[0] ?? 0, hsl[1] ?? 0, hsl[2]];\n}\n\n/**\n * Get the values of the hsl string\n *\n * @param {string} hslAsString - the valid hsl color string\n * @return {string[]} the values of the hsl string\n */\nexport function parseHsl(hslAsString: string): string[] {\n\tconst hslvalue = cleanDefinition(hslAsString);\n\n\tlet hsl: string[] = splitValues(hslvalue);\n\n\tif (hsl.length !== 3 && hsl.length !== 4) {\n\t\thsl = fallbackHSL(hsl);\n\t}\n\treturn [hsl[0], hsl[1], hsl[2]];\n}\n\n/**\n * The error message for invalid angle\n * @param value - the invalid angle\n */\nconst angleError = (value: string): string =>\n\t`Invalid angle: ${value} - The none keyword is invalid in legacy color syntax `;\n\n/**\n * This function takes an array of strings and returns and object with the hsl values converted into INT8 (0-255)\n *\n * @param {string[]} hsl - the hsl values to parse from string to int8 values\n *\n */\nexport function getHslValues(hsl: string[]): HSLVALUE {\n\treturn {\n\t\th:\n\t\t\tcolorValueFallbacks(hsl[0], angleError(hsl[0])) ||\n\t\t\tMath.round(normalizeDegrees(hsl[0])) ||\n\t\t\t0,\n\t\ts: colorValueFallbacks(hsl[1]) || convertToInt8(hsl[1], 100) || 0,\n\t\tl: colorValueFallbacks(hsl[2]) || convertToInt8(hsl[2], 100) || 0,\n\t};\n}\n\n/**\n * Takes the hsl values and returns the rgb values\n * @param c chroma\n * @param x X\n * @param h Y\n */\nfunction getHue(c: number, x: number, h: number): [number, number, number] {\n\tif (h < 60) return [c, x, 0];\n\tif (h < 120) return [x, c, 0];\n\tif (h < 180) return [0, c, x];\n\tif (h < 240) return [0, x, c];\n\tif (h < 300) return [x, 0, c];\n\treturn [c, 0, x];\n}\n\n/**\n * Given the HSL color it convert the color into RGB\n *\n * @param {string[]} hslColor the HSL value to parse\n * @return {Object} rgb value\n */\nexport function hslToRgb(hslColor: string[]): RGBVALUE {\n\tconst hsl = getHslValues(hslColor);\n\tconst s = hsl.s / 100;\n\tconst l = hsl.l / 100;\n\n\tconst c = (1 - Math.abs(2 * l - 1)) * s;\n\tconst x = c * (1 - Math.abs(((hsl.h / 60) % 2) - 1));\n\tconst m = l - c / 2;\n\n\tlet [r, g, b] = getHue(c, x, hsl.h);\n\n\tr = Math.round((r + m) * 255);\n\tg = Math.round((g + m) * 255);\n\tb = Math.round((b + m) * 255);\n\n\treturn { r, g, b };\n}\n\n/**\n * Given the RGB color it convert the color into HSL\n *\n * @param {number} r - red\n * @param {number} g - green\n * @param {number} b - blue\n *\n * @return {Object} hsl value\n */\nexport function valuesToHsl({ r, g, b }: RGBVALUE): string {\n\t// Make r, g, and b fractions of 1\n\tr /= 255;\n\tg /= 255;\n\tb /= 255;\n\n\t// Find greatest and smallest channel values\n\tconst cmin = Math.min(r, g, b);\n\tconst cmax = Math.max(r, g, b);\n\tconst delta = cmax - cmin;\n\tlet h = 0;\n\tlet s = 0;\n\tlet l = 0;\n\n\t// Calculate hue\n\tif (delta === 0) {\n\t\t// No difference\n\t\th = 0;\n\t} else if (cmax === r) {\n\t\t// Red is max\n\t\th = ((g - b) / delta) % 6;\n\t} else if (cmax === g) {\n\t\t// Green is max\n\t\th = (b - r) / delta + 2;\n\t} else {\n\t\th = (r - g) / delta + 4;\n\t} // Blue is max\n\n\th = Math.round(h * 60);\n\n\t// Make negative hues positive behind 360\u00B0\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\t// Calculate lightness\n\tl = (cmax + cmin) / 2;\n\n\t// Calculate saturation\n\ts = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));\n\n\t// Multiply l and s by 100\n\ts = +(s * 100).toFixed(1);\n\tl = +(l * 100).toFixed(1);\n\n\treturn HSL({ h, s, l });\n}\n\n/**\n * Converts an HSL color object to a string representation.\n *\n * @param {Object} hsl - Object containing the HSL color values.\n * @param {number} hsl.h - The hue value of the color.\n * @param {number} hsl.s - The saturation value of the color.\n * @param {number} hsl.l - The lightness value of the color.\n * @return {string} The HSL color as a string.\n */\nexport function HSL(hsl: { h: number; s: number; l: number }): string {\n\treturn `hsl(${hsl.h},${hsl.s}%,${hsl.l}%)`;\n}\n", "import colorSet from \"./data/colorSet\";\nimport { valuesToHex } from \"./hex-utils.js\";\nimport { valuesToHsl } from \"./hsl-utils.js\";\nimport { RGB } from \"./rgb-utils.js\";\nimport type { RGBCOLORDEF } from \"./types.js\";\n\n/**\n * This function was the opposite of the name of the repo and returns the color of the colorSet given the name\n *\n * @param {string} searchedColor -the name of the color to search for\n * @param {Array} set - the colorSet to search in\n */\nexport function getColor(\n\tsearchedColor: string,\n\tset: RGBCOLORDEF[] | undefined = colorSet as RGBCOLORDEF[],\n) {\n\tconst color: RGBCOLORDEF | undefined = set.find(\n\t\t(color: RGBCOLORDEF) => color[3] === searchedColor,\n\t);\n\n\tif (typeof color !== \"undefined\") {\n\t\tconst [r, g, b] = color;\n\t\treturn {\n\t\t\thex: valuesToHex({ r, g, b }),\n\t\t\trgb: RGB({ r, g, b }),\n\t\t\thsl: valuesToHsl({ r, g, b }),\n\t\t};\n\t}\n\n\tthrow new Error(`Error: invalid color ${searchedColor} or empty colorSet`);\n}\n\n/**\n * Get all the colors from the colorSet\n */\nexport function getColors() {\n\treturn colorSet.map((colorData) => {\n\t\treturn {\n\t\t\tname: colorData[3],\n\t\t\t...getColor(colorData[3] as string),\n\t\t};\n\t});\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { getColor, getColors } from \"./color-utils.js\";\nimport {\n\tBLACKANDWHITE,\n\tRGBSET,\n\thexRegex,\n\thslRegex,\n\trgbRegex,\n} from \"./common.js\";\nimport colorSet from \"./data/colorSet.js\";\nimport { hexToRgb, parseHex, valuesToHex } from \"./hex-utils.js\";\nimport { hslToRgb, parseHsl } from \"./hsl-utils.js\";\nimport { getRgbValues, parseRgb } from \"./rgb-utils.js\";\nimport type {\n\tCOLORDEF,\n\tCOLORSTRING,\n\tColorParsers,\n\tHEX,\n\tRGBCOLORDEF,\n\tRGBDEF,\n\tRGBVALUE,\n} from \"./types.js\";\n\nexport const colorParsers: ColorParsers[] = [\n\t{ regex: hexRegex, parser: parseHex, converter: hexToRgb },\n\t{ regex: rgbRegex, parser: parseRgb, converter: getRgbValues },\n\t{ regex: hslRegex, parser: parseHsl, converter: hslToRgb },\n];\n\n/**\n * Given a color string, it returns the closest corresponding name of the color.\n * Uses the Euclidean distance formula to calculate the distance between colors in the RGB color space.\n *\n * @param {string} color - the color string you want to find the closest color name\n * @param {Object} set - the color set that will be used to find the closest color\n * @param {Object} args - Set a non nullish value to return some additional information (like the distance between the colors, or the hex color value)\n * @param args.info - Set a non nullish value to return some additional information (like the distance between the colors, or the hex color value) about the closest color.\n *\n * @return {Object} the closest color name and rgb value\n *\n * @example // Returns the closest color name and rgb value given a css color string\n * closest('#f00'); // { name: 'red', color: 'rgb(255,0,0)' }\n *\n * closest('#f00', undefined, {info:true}); // { name: 'red', color: 'rgb(255,0,0)', hex: '#ff0000', hsl: 'hsl(0, 100%, 50%)', distance: 0 ) }\n */\nfunction closest(\n\tcolor: string | COLORSTRING,\n\tset: RGBCOLORDEF[] | undefined = colorSet as RGBCOLORDEF[],\n\targs?: { info?: boolean },\n): COLORDEF {\n\tlet closestGap = Number.MAX_SAFE_INTEGER;\n\tconst closestColor: COLORDEF = { name: \"error\", color: \"#F00\" };\n\n\tif (set.length < 1) {\n\t\treturn closestColor;\n\t}\n\n\tconst rgbColorValues = Object.values(parseColor(color));\n\tconst colorSetLength = set.length;\n\t// Precompute RGB values if needed\n\tconst precomputedRGBValues = set.map((item) => [item[0], item[1], item[2]]);\n\n\t// Find the closest color in the color set\n\tfor (let i = 0; i < colorSetLength; i++) {\n\t\tconst tested = precomputedRGBValues[i];\n\t\tconst gap = distance(rgbColorValues as RGBDEF, tested, true);\n\t\tif (gap < closestGap) {\n\t\t\tclosestGap = gap;\n\t\t\tclosestColor.name = set[i][3];\n\t\t\tclosestColor.color = `rgb(${set[i][0]},${set[i][1]},${set[i][2]})`;\n\t\t}\n\n\t\t// Break if exact match found\n\t\tif (gap === 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (args?.info) {\n\t\tconst colorValue = getColor(closestColor.name, set);\n\t\treturn {\n\t\t\t...colorValue,\n\t\t\t...closestColor,\n\t\t\tgap: Math.sqrt(closestGap),\n\t\t};\n\t}\n\n\treturn closestColor;\n}\n\n/**\n * This function takes a string representing a color (color) and uses regular expressions to check if it matches any of the following formats: hex, hex+alpha, RGB, RGBA, HSL, or HSLA.\n * If the color string matches one of these formats, the function returns an object with the type of color and the value of the color.\n * If the color string does not match any of the formats, the function throws an error.\n *\n * @param {string} colorString - the color string to test and convert to rgb values\n *\n * @return {Object|Error} the object with rgb values of that color\n */\nexport function parseColor(colorString: string): RGBVALUE {\n\tfor (const { regex, parser, converter } of colorParsers) {\n\t\tif (regex.test(colorString)) {\n\t\t\tconst result = parser(colorString as COLORSTRING);\n\t\t\treturn converter(result);\n\t\t}\n\t}\n\n\t// If the color string does not match any of the regular expressions, return an error\n\tthrow new Error(`Invalid color: ${colorString}`);\n}\n\n/**\n * Given a color returns if the color is light (by light is meant more mathematically closer to white)\n *\n * @param {string} color - The color to check\n *\n * @returns {boolean} true when the color is light, false otherwise\n *\n * @example isLight('#ddd'); // true\n */\nfunction isLight(color: string): boolean {\n\treturn closest(color, BLACKANDWHITE).name === \"white\";\n}\n\n/**\n * Given a color returns if the color is dark (by dark is meant more mathematically closer to black)\n *\n * @param {string} color - The color to check\n *\n * @returns {boolean} true when the color is dark, false otherwise\n *\n * @example isDark('#333'); // true\n */\nfunction isDark(color: string): boolean {\n\treturn closest(color, BLACKANDWHITE).name === \"black\";\n}\n\n/**\n * Given a color returns if the color is closer to \"red\", \"green\" or \"blue\".\n *\n * @param {string} color - The color to check\n *\n * @returns {string} light when the color is close to white, dark otherwise\n *\n * @example closestRGB('#f00'); // 'red'\n */\nfunction closestRGB(color: string): string {\n\treturn closest(color, RGBSET).name;\n}\n\n/**\n * Compute the distance between the two RGB values\n * There are two modes:\n * fast = true -> the distance is calculated without using the Euclidean formula completely, it is reliable but its result is exponential\n * fast = false -> the distance is calculated with the Euclidean formula, its result is linear\n *\n * @param rgb1 - The RGB value of the first color to compare\n * @param rgb2 - The RGB value of the second color to compare\n * @param fast - If you want to calculate the distance without calculating the square root, the result will be exponential otherwise is linear\n *\n * @return {number} the distance between the two RGB values\n *\n * @example distance([10, 20, 30], [120, 120, 120]); // 173.78147196982766\n */\nfunction distance(\n\trgb1: [number, number, number],\n\trgb2: [number, number, number, string] | number[],\n\tfast = false,\n): number {\n\tconst [rDiff, gDiff, bDiff] = [\n\t\trgb2[0] - rgb1[0],\n\t\trgb2[1] - rgb1[1],\n\t\trgb2[2] - rgb1[2],\n\t];\n\tconst dist = rDiff * rDiff + gDiff * gDiff + bDiff * bDiff;\n\treturn fast ? dist : Math.sqrt(dist);\n}\n\n/**\n * Given a color string it returns the hex representation\n *\n * @param rgbString - the rgb color string to convert to hex\n *\n * @return {string} the corresponding color hex\n *\n * @example rgbToHex(\"rgba(100% 0 0 / .5)\"); // #FF0000\n */\nfunction rgbToHex(rgbString: string): HEX | Error {\n\t// if is a rgb string\n\tif (rgbRegex.test(rgbString)) {\n\t\tconst rgb = parseRgb(rgbString);\n\t\tconst RgbValues = getRgbValues(rgb);\n\t\treturn valuesToHex(RgbValues);\n\t}\n\tthrow new Error(`Invalid color: ${rgbString}`);\n}\n\nexport {\n\tclosest,\n\trgbToHex,\n\tdistance,\n\tisLight,\n\tisDark,\n\tclosestRGB,\n\tgetColor,\n\tgetColors,\n};\n", "const colorSet = [\n [255, 255, 255, \"white\"],\n [0, 0, 0, \"black\"],\n [255, 0, 0, \"red\"],\n [0, 128, 0, \"green\"],\n [0, 0, 255, \"blue\"],\n [255, 165, 0, \"orange\"],\n [128, 128, 128, \"grey\"],\n [255, 255, 0, \"yellow\"],\n [255, 0, 255, \"magenta\"],\n [154, 205, 50, \"yellowgreen\"],\n [192, 192, 192, \"silver\"],\n [0, 255, 0, \"lime\"],\n [128, 0, 128, \"purple\"],\n [255, 99, 71, \"tomato\"],\n [64, 224, 208, \"turquoise\"],\n [255, 127, 80, \"coral\"],\n [0, 255, 255, \"cyan\"],\n [255, 250, 240, \"floralwhite\"],\n [255, 192, 203, \"pink\"],\n [34, 139, 34, \"forestgreen\"],\n [245, 245, 220, \"beige\"],\n [255, 0, 255, \"fuchsia\"],\n [220, 220, 220, \"gainsboro\"],\n [248, 248, 255, \"ghostwhite\"],\n [255, 215, 0, \"gold\"],\n [218, 165, 32, \"goldenrod\"],\n [173, 255, 47, \"greenyellow\"],\n [238, 130, 238, \"violet\"],\n [245, 222, 179, \"wheat\"],\n [245, 245, 245, \"whitesmoke\"],\n [139, 0, 0, \"darkred\"],\n [240, 248, 255, \"aliceblue\"],\n [205, 92, 92, \"indianred\"],\n [75, 0, 130, \"indigo\"],\n [250, 235, 215, \"antiquewhite\"],\n [0, 255, 255, \"aqua\"],\n [127, 255, 212, \"aquamarine\"],\n [240, 255, 255, \"azure\"],\n [255, 228, 196, \"bisque\"],\n [255, 235, 205, \"blanchedalmond\"],\n [138, 43, 226, \"blueviolet\"],\n [165, 42, 42, \"brown\"],\n [222, 184, 135, \"burlywood\"],\n [95, 158, 160, \"cadetblue\"],\n [127, 255, 0, \"chartreuse\"],\n [210, 105, 30, \"chocolate\"],\n [100, 149, 237, \"cornflowerblue\"],\n [255, 248, 220, \"cornsilk\"],\n [220, 20, 60, \"crimson\"],\n [0, 0, 139, \"darkblue\"],\n [0, 139, 139, \"darkcyan\"],\n [184, 134, 11, \"darkgoldenrod\"],\n [169, 169, 169, \"darkgrey\"],\n [0, 100, 0, \"darkgreen\"],\n [189, 183, 107, \"darkkhaki\"],\n [139, 0, 139, \"darkmagenta\"],\n [85, 107, 47, \"darkolivegreen\"],\n [255, 140, 0, \"darkorange\"],\n [153, 50, 204, \"darkorchid\"],\n [233, 150, 122, \"darksalmon\"],\n [143, 188, 143, \"darkseagreen\"],\n [72, 61, 139, \"darkslateblue\"],\n [47, 79, 79, \"darkslategrey\"],\n [0, 206, 209, \"darkturquoise\"],\n [148, 0, 211, \"darkviolet\"],\n [255, 20, 147, \"deeppink\"],\n [0, 191, 255, \"deepskyblue\"],\n [105, 105, 105, \"dimgrey\"],\n [30, 144, 255, \"dodgerblue\"],\n [178, 34, 34, \"firebrick\"],\n [240, 255, 240, \"honeydew\"],\n [255, 105, 180, \"hotpink\"],\n [255, 255, 240, \"ivory\"],\n [240, 230, 140, \"khaki\"],\n [230, 230, 250, \"lavender\"],\n [255, 240, 245, \"lavenderblush\"],\n [124, 252, 0, \"lawngreen\"],\n [255, 250, 205, \"lemonchiffon\"],\n [173, 216, 230, \"lightblue\"],\n [240, 128, 128, \"lightcoral\"],\n [224, 255, 255, \"lightcyan\"],\n [250, 250, 210, \"lightgoldenrodyellow\"],\n [144, 238, 144, \"lightgreen\"],\n [211, 211, 211, \"lightgrey\"],\n [255, 182, 193, \"lightpink\"],\n [255, 160, 122, \"lightsalmon\"],\n [32, 178, 170, \"lightseagreen\"],\n [135, 206, 250, \"lightskyblue\"],\n [119, 136, 153, \"lightslategrey\"],\n [176, 196, 222, \"lightsteelblue\"],\n [255, 255, 224, \"lightyellow\"],\n [50, 205, 50, \"limegreen\"],\n [250, 240, 230, \"linen\"],\n [128, 0, 0, \"maroon\"],\n [102, 205, 170, \"mediumaquamarine\"],\n [0, 0, 205, \"mediumblue\"],\n [186, 85, 211, \"mediumorchid\"],\n [147, 112, 219, \"mediumpurple\"],\n [60, 179, 113, \"mediumseagreen\"],\n [123, 104, 238, \"mediumslateblue\"],\n [0, 250, 154, \"mediumspringgreen\"],\n [72, 209, 204, \"mediumturquoise\"],\n [199, 21, 133, \"mediumvioletred\"],\n [25, 25, 112, \"midnightblue\"],\n [245, 255, 250, \"mintcream\"],\n [255, 228, 225, \"mistyrose\"],\n [255, 228, 181, \"moccasin\"],\n [255, 222, 173, \"navajowhite\"],\n [0, 0, 128, \"navy\"],\n [253, 245, 230, \"oldlace\"],\n [128, 128, 0, \"olive\"],\n [107, 142, 35, \"olivedrab\"],\n [255, 69, 0, \"orangered\"],\n [218, 112, 214, \"orchid\"],\n [238, 232, 170, \"palegoldenrod\"],\n [152, 251, 152, \"palegreen\"],\n [175, 238, 238, \"paleturquoise\"],\n [219, 112, 147, \"palevioletred\"],\n [255, 239, 213, \"papayawhip\"],\n [255, 218, 185, \"peachpuff\"],\n [205, 133, 63, \"peru\"],\n [221, 160, 221, \"plum\"],\n [176, 224, 230, \"powderblue\"],\n [102, 51, 153, \"rebeccapurple\"],\n [188, 143, 143, \"rosybrown\"],\n [65, 105, 225, \"royalblue\"],\n [139, 69, 19, \"saddlebrown\"],\n [250, 128, 114, \"salmon\"],\n [244, 164, 96, \"sandybrown\"],\n [46, 139, 87, \"seagreen\"],\n [255, 245, 238, \"seashell\"],\n [160, 82, 45, \"sienna\"],\n [135, 206, 235, \"skyblue\"],\n [106, 90, 205, \"slateblue\"],\n [112, 128, 144, \"slategrey\"],\n [255, 250, 250, \"snow\"],\n [0, 255, 127, \"springgreen\"],\n [70, 130, 180, \"steelblue\"],\n [210, 180, 140, \"tan\"],\n [0, 128, 128, \"teal\"],\n [216, 191, 216, \"thistle\"],\n];\n\nexport default colorSet;\n", "// Regular expressions to match different color formats\nimport type { RGBCOLORDEF } from \"./types.js\";\n\n/** The maximum distance possible between colors */\nexport const MAXDISTANCE = 441.6729559300637;\n\n/** A regex to match hex colors */\nexport const hexRegex: RegExp = /^#([\\da-f]{3,8})/i;\n/** A regex to match rgb colors */\nexport const rgbRegex: RegExp = /^rgba?\\(([^)]+)\\)/i;\n/** A regex to match hsl colors */\nexport const hslRegex: RegExp = /^hsla?\\(([^)]+)\\)/i;\n/** A regex to match strings that are only valid numbers with and without decimals and the number can be negative and without the 0 in the beginning */\nexport const isNumeric: RegExp = /^-?\\d*\\.?\\d+$/i;\n/** Remove comments from string */\nexport const stripComments: RegExp = /(\\/\\*[^*]*\\*\\/)|(\\/\\/[^*]*)/g;\n\n/**\n * This set is used to detect if the color is bright or dark\n *\n * @note the set has been corrected to get pure RGB values (eg. pure red, pure green) in the \"bright\" area\n */\nexport const BLACKANDWHITE: RGBCOLORDEF[] = [\n\t[255, 255, 255, \"white\"],\n\t[1, 1, 1, \"black\"],\n];\n\n/**\n * This set is used to detect the nearest rgb color\n */\nexport const RGBSET: RGBCOLORDEF[] = [\n\t[255, 0, 0, \"red\"],\n\t[0, 255, 0, \"green\"],\n\t[0, 0, 255, \"blue\"],\n];\n\n/**\n * split the content of rgb and hsl colors depending on the parsed value of the css property\n *\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb#syntax\n *\n * @param {string} rawValues - the value inside the rgb(.*) css color definition\n *\n * @return {Array} the array of rgb values found inside the passed string\n */\nexport function splitValues(rawValues: string): string[] {\n\treturn rawValues\n\t\t.split(rawValues.includes(\",\") ? \",\" : \" \")\n\t\t.map((s) => s.trim());\n}\n\n/**\n * If the value is an angle in degrees, convert it to the 0-360 range\n *\n * @param {string} angle - the degrees to convert into a number\n *\n * @return {number} the converted value\n */\nexport function normalizeDegrees(angle: string): number {\n\t// Strip label and convert to degrees (if necessary)\n\tlet degAngle = Number.parseFloat(angle) || 0;\n\tif (angle.indexOf(\"deg\") > -1) {\n\t\tdegAngle = Number.parseFloat(angle.substring(0, angle.length - 3));\n\t} else if (angle.indexOf(\"rad\") > -1) {\n\t\tdegAngle = Math.round(\n\t\t\tNumber.parseFloat(angle.substring(0, angle.length - 3)) * (180 / Math.PI),\n\t\t);\n\t} else if (angle.indexOf(\"turn\") > -1) {\n\t\tdegAngle = Math.round(\n\t\t\tNumber.parseFloat(angle.substring(0, angle.length - 4)) * 360,\n\t\t);\n\t}\n\n\twhile (degAngle < 0) {\n\t\tdegAngle += 360;\n\t}\n\n\t// Make sure it's a number between 0 and 360\n\tif (degAngle >= 360) degAngle %= 360;\n\n\treturn degAngle;\n}\n\n/**\n * Returns a value that is limited between a minimum and maximum value.\n *\n * @param {number} value - The value to be limited.\n * @param {number} min - The minimum allowed value (default is 0).\n * @param {number} max - The maximum allowed value (default is 0).\n * @return {number} The limited value.\n */\nexport function limitValue(value: number, min = 0, max = 0): number {\n\treturn Math.min(Math.max(Math.round(value), min), max);\n}\n\n/**\n * Calculates the value based on a given string and multiplier.\n *\n * @param {string} valueString - The string representing the value to be calculated.\n * @param {number} multiplier - The multiplier to be applied to the calculated value.\n * @return {number} The calculated value.\n */\nexport function calculateValue(\n\tvalueString: string,\n\tmultiplier: number,\n): number {\n\t// Regular expression to match the calc() function and extract the numerical value\n\tconst regex = /calc\\(([^)]+)\\)/;\n\n\t// Match the calc() function in the CSS string\n\tconst match = valueString.match(regex);\n\n\treturn convertToInt8(match ? match[1] : valueString, multiplier);\n}\n\n/**\n * Removes comments from the input string and extracts the content between the first opening parenthesis\n * and the last closing parenthesis.\n *\n * @param {string} string - The input string.\n * @return {string} The content between the first opening parenthesis and the last closing parenthesis.\n */\nexport function cleanDefinition(string: string): string {\n\t// Remove comments from the string\n\tconst cleanString = string.replace(stripComments, \"\");\n\n\t// Find the positions of the first opening and the last closing parentheses\n\tconst firstParenthesisIndex = cleanString.indexOf(\"(\");\n\tconst lastParenthesisIndex = cleanString.lastIndexOf(\")\");\n\n\t// Extract the content between the parentheses\n\treturn cleanString\n\t\t.slice(firstParenthesisIndex + 1, lastParenthesisIndex)\n\t\t.trim();\n}\n\n/**\n * Normalizes a percentage value by dividing it by 100 and multiplying it by a given multiplier.\n *\n * @param {string} value - The percentage value to be normalized.\n * @param {number} multiplier - The number to multiply the normalized percentage by.\n * @return {number} The normalized percentage value.\n */\nexport function normalizePercentage(value: string, multiplier: number): number {\n\treturn (Number.parseFloat(value) / 100) * multiplier;\n}\n\n/**\n * Calculates the color value fallbacks for a given value.\n *\n * @param {string} value - The color value to calculate fallbacks for.\n * @param {string} [err] - An optional error message to display.\n * @return {number} - The calculated color value fallbacks.\n */\nexport function colorValueFallbacks(value: string, err?: string): number {\n\tif (value === \"infinity\") {\n\t\tconsole.warn(\n\t\t\terr || `Positive infinity value has been set to 255: ${value}`,\n\t\t);\n\t\treturn 255;\n\t}\n\n\tif (value === \"currentColor\")\n\t\tconsole.warn(err || `The \"currentColor\" value has been set to 0: ${value}`);\n\tif (value === \"transparent\")\n\t\tconsole.warn(err || `The \"transparent\" value has been set to 0: ${value}`);\n\tif (value === \"NaN\")\n\t\tconsole.warn(err || `\"NaN\" value has been set to 0: ${value}`);\n\tif (value === \"-infinity\")\n\t\tconsole.warn(\n\t\t\terr || `\"Negative\" infinity value has been set to 0: ${value}`,\n\t\t);\n\tif (value === \"none\")\n\t\tconsole.warn(\n\t\t\terr || `The none keyword is invalid in legacy color syntax: ${value}`,\n\t\t);\n\treturn 0;\n}\n\n/**\n * Takes a string with a css value that could be a number or percentage or an angle in degrees and returns the corresponding 8bit value\n *\n * @param value - a valid value for the css color definition (like 255, \"100%\", \"324deg\", etc.) *\n * @param multiplier - the number that represent the maximum - default is 255 decimal - 100 hex\n *\n * @example convertToInt8('100%'); // 255\n *\n * @return {string} the corresponding value in 8-bit format\n */\nexport function convertToInt8(\n\tvalue: string | unknown,\n\tmultiplier = 255,\n): number {\n\tconst newValue = typeof value === \"string\" ? value?.trim() : \"0\";\n\tif (isNumeric.test(newValue)) {\n\t\t// limit the min and the max newValue\n\t\treturn limitValue(Number.parseFloat(newValue) || 0, 0, multiplier);\n\t}\n\tif (newValue.endsWith(\"%\")) {\n\t\t// If the newValue is a percentage, divide it by 100 to get a newValue from 0 to 1\n\t\t// and then multiply it by 255 to get a newValue from 0 to 255\n\t\treturn normalizePercentage(newValue, multiplier) || 0;\n\t}\n\tif (\n\t\tnewValue.endsWith(\"deg\") ||\n\t\tnewValue.endsWith(\"rad\") ||\n\t\tnewValue.endsWith(\"turn\")\n\t) {\n\t\treturn normalizeDegrees(newValue);\n\t}\n\tif (newValue.startsWith(\"calc\")) {\n\t\t// get the newValue from the calc function\n\t\treturn limitValue(calculateValue(newValue, multiplier), 0, multiplier);\n\t}\n\n\t// If the value is not a percentage or an angle in degrees, it is invalid\n\treturn colorValueFallbacks(newValue, `Invalid value: ${value}`);\n}\n", "import {\n\tcleanDefinition,\n\tconvertToInt8,\n\tlimitValue,\n\tsplitValues,\n} from \"./common.js\";\nimport type { RGBVALUE } from \"./types.js\";\n\nexport function fallbackRGB(\n\trgb: string[],\n\terr = \"Invalid RGB color\",\n): string[] {\n\tconsole.warn(err);\n\treturn [rgb[0] ?? 0, rgb[1] ?? 0, rgb[2]];\n}\n\n/**\n * Get the values of the rgb string\n *\n * @param rgbAsString - the rgb color as string split into values\n *\n * @return {Array} the values of the rgb string as Array of strings that represent the rgb color\n */\nexport function parseRgb(rgbAsString: string): string[] {\n\tconst rgbvalue = cleanDefinition(rgbAsString);\n\n\tconst rgb: string[] = splitValues(rgbvalue);\n\n\tif (rgb.length !== 3 && rgb.length !== 4) {\n\t\treturn fallbackRGB(\n\t\t\trgb,\n\t\t\t`Too few values to define rgb: ${rgbAsString} -> ${rgbvalue}`,\n\t\t);\n\t}\n\treturn [rgb[0], rgb[1], rgb[2]];\n}\n\n/**\n * This function takes an array of strings and returns and object with the rgb values converted into INT8 (0-255)\n *\n * @param {Array} rgb - rgb color as Array of strings\n *\n * @return {Object} an object that contains the r, g and b values as INT8\n */\nexport function getRgbValues(rgb: string[]): RGBVALUE {\n\t// use the channel key as the new array key\n\treturn {\n\t\tr: limitValue(Math.round(convertToInt8(rgb[0])), 0, 255) || 0,\n\t\tg: limitValue(Math.round(convertToInt8(rgb[1])), 0, 255) || 0,\n\t\tb: limitValue(Math.round(convertToInt8(rgb[2])), 0, 255) || 0,\n\t};\n}\n\n/**\n * returns a string representation of the rgb values\n *\n * @param {Object} rgb the rgb color object\n *\n * @return {string} a string representation of the rgb values\n */\nexport function RGB(rgb: RGBVALUE): string {\n\treturn `rgb(${rgb.r},${rgb.g},${rgb.b})`;\n}\n", "import { fallbackRGB } from \"./rgb-utils.js\";\nimport type { COLORSTRING, HEX, RGBVALUE } from \"./types.js\";\n\n/**\n * It returns an object with the hex values of the 3 digit hex color\n *\n * @param {string} value 3 digit hex\n * @return {string[]} 6 digit hex\n */\nexport function shortHexToLongHex(value: string): string[] {\n\t// split the string in to an array of digits then return an array that contains that digit doubled for each item\n\treturn Array.from(value).map((v: string) => (v + v).toUpperCase());\n}\n\n/**\n * Checks if a given string represents a hexadecimal number.\n *\n * @param {string} num - The string to be checked.\n * @return {boolean} Returns true if the string is a valid hexadecimal number, false otherwise.\n */\nexport function isHex(num: string): boolean {\n\treturn Boolean(num.match(/^[0-9a-f]+$/i));\n}\n\n/**\n * Get the hex value of the color and convert it to an Object of R G And B values (still in hex format)\n *\n * @param value the string that contains the color in hex format\n *\n * @return {string[]} an array of 6 digit hex values in a triplet of R G and B (HEX format)\n */\nexport function parseHex(value: COLORSTRING): string[] {\n\t// remove # at the beginning of the hex color\n\tconst hexColor: string = value.substring(1);\n\n\t/**\n\t * then if the number of digits is greater than 2 (so it's something like 123 or abc456)\n\t * breakdown the string into an object that contains the r g and b values in hex\n\t */\n\tlet hexArray: string[] = [];\n\tif (hexColor) {\n\t\tif (hexColor.length === 3 || hexColor.length === 4) {\n\t\t\thexArray = shortHexToLongHex(hexColor);\n\t\t} else if (hexColor.length === 6 || hexColor.length === 8) {\n\t\t\t// match the hex value in groups of 2\n\t\t\thexArray = (hexColor.match(/../g) || []).map((value: string) => value);\n\t\t}\n\t}\n\n\tif (hexArray.length) {\n\t\thexArray?.forEach((value, index) => {\n\t\t\tif (isHex(value)) {\n\t\t\t\thexArray[index] = value.toUpperCase();\n\t\t\t} else {\n\t\t\t\tconsole.warn(`Invalid Hex value: ${value}`);\n\t\t\t}\n\t\t});\n\n\t\treturn hexArray;\n\t}\n\n\tconsole.warn(`Invalid Hex: ${value}`);\n\treturn fallbackRGB(hexArray);\n}\n\n/**\n * Converts a Hex color to rgb\n *\n * @param {string} hex a tuple of hex values\n *\n * @return {string} the rgb color values for the given hex color\n */\nexport function hexToRgb(hex: string[]): RGBVALUE {\n\t// Extract the RGB values from the hex string\n\treturn {\n\t\tr: Number.parseInt(hex[0], 16),\n\t\tg: Number.parseInt(hex[1], 16),\n\t\tb: Number.parseInt(hex[2], 16),\n\t};\n}\n\n/**\n * Convert a INT8 value to HEX\n *\n * @param {number} int8 - the integer value to convert\n *\n * @return {string} the hex string\n */\nexport function toHex(int8: number): string {\n\treturn int8.toString(16).padStart(2, \"0\");\n}\n\n/**\n * Convert rgb values to hex color\n *\n * @param {Object} rgb an object with the rgb values\n *\n * @return {string} the hex string\n */\nexport function valuesToHex(rgb: RGBVALUE): HEX {\n\t// Extract the RGB values from the hex string\n\treturn `#${toHex(rgb?.r)}${toHex(rgb?.g)}${toHex(rgb?.b)}`;\n}\n", "import {\n\tcleanDefinition,\n\tcolorValueFallbacks,\n\tconvertToInt8,\n\tnormalizeDegrees,\n\tsplitValues,\n} from \"./common.js\";\nimport type { HSLVALUE, RGBVALUE } from \"./types.js\";\n\nexport function fallbackHSL(\n\thsl: string[],\n\terr = \"Invalid HSL color\",\n): string[] {\n\tconsole.warn(err);\n\treturn [hsl[0] ?? 0, hsl[1] ?? 0, hsl[2]];\n}\n\n/**\n * Get the values of the hsl string\n *\n * @param {string} hslAsString - the valid hsl color string\n * @return {string[]} the values of the hsl string\n */\nexport function parseHsl(hslAsString: string): string[] {\n\tconst hslvalue = cleanDefinition(hslAsString);\n\n\tlet hsl: string[] = splitValues(hslvalue);\n\n\tif (hsl.length !== 3 && hsl.length !== 4) {\n\t\thsl = fallbackHSL(hsl);\n\t}\n\treturn [hsl[0], hsl[1], hsl[2]];\n}\n\n/**\n * The error message for invalid angle\n * @param value - the invalid angle\n */\nconst angleError = (value: string): string =>\n\t`Invalid angle: ${value} - The none keyword is invalid in legacy color syntax `;\n\n/**\n * This function takes an array of strings and returns and object with the hsl values converted into INT8 (0-255)\n *\n * @param {string[]} hsl - the hsl values to parse from string to int8 values\n *\n */\nexport function getHslValues(hsl: string[]): HSLVALUE {\n\treturn {\n\t\th:\n\t\t\tcolorValueFallbacks(hsl[0], angleError(hsl[0])) ||\n\t\t\tMath.round(normalizeDegrees(hsl[0])) ||\n\t\t\t0,\n\t\ts: colorValueFallbacks(hsl[1]) || convertToInt8(hsl[1], 100) || 0,\n\t\tl: colorValueFallbacks(hsl[2]) || convertToInt8(hsl[2], 100) || 0,\n\t};\n}\n\n/**\n * Takes the hsl values and returns the rgb values\n * @param c chroma\n * @param x X\n * @param h Y\n */\nfunction getHue(c: number, x: number, h: number): [number, number, number] {\n\tif (h < 60) return [c, x, 0];\n\tif (h < 120) return [x, c, 0];\n\tif (h < 180) return [0, c, x];\n\tif (h < 240) return [0, x, c];\n\tif (h < 300) return [x, 0, c];\n\treturn [c, 0, x];\n}\n\n/**\n * Given the HSL color it convert the color into RGB\n *\n * @param {string[]} hslColor the HSL value to parse\n * @return {Object} rgb value\n */\nexport function hslToRgb(hslColor: string[]): RGBVALUE {\n\tconst hsl = getHslValues(hslColor);\n\tconst s = hsl.s / 100;\n\tconst l = hsl.l / 100;\n\n\tconst c = (1 - Math.abs(2 * l - 1)) * s;\n\tconst x = c * (1 - Math.abs(((hsl.h / 60) % 2) - 1));\n\tconst m = l - c / 2;\n\n\tlet [r, g, b] = getHue(c, x, hsl.h);\n\n\tr = Math.round((r + m) * 255);\n\tg = Math.round((g + m) * 255);\n\tb = Math.round((b + m) * 255);\n\n\treturn { r, g, b };\n}\n\n/**\n * Given the RGB color it convert the color into HSL\n *\n * @param {number} r - red\n * @param {number} g - green\n * @param {number} b - blue\n *\n * @return {Object} hsl value\n */\nexport function valuesToHsl({ r, g, b }: RGBVALUE): string {\n\t// Make r, g, and b fractions of 1\n\tr /= 255;\n\tg /= 255;\n\tb /= 255;\n\n\t// Find greatest and smallest channel values\n\tconst cmin = Math.min(r, g, b);\n\tconst cmax = Math.max(r, g, b);\n\tconst delta = cmax - cmin;\n\tlet h = 0;\n\tlet s = 0;\n\tlet l = 0;\n\n\t// Calculate hue\n\tif (delta === 0) {\n\t\t// No difference\n\t\th = 0;\n\t} else if (cmax === r) {\n\t\t// Red is max\n\t\th = ((g - b) / delta) % 6;\n\t} else if (cmax === g) {\n\t\t// Green is max\n\t\th = (b - r) / delta + 2;\n\t} else {\n\t\th = (r - g) / delta + 4;\n\t} // Blue is max\n\n\th = Math.round(h * 60);\n\n\t// Make negative hues positive behind 360\u00B0\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\t// Calculate lightness\n\tl = (cmax + cmin) / 2;\n\n\t// Calculate saturation\n\ts = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));\n\n\t// Multiply l and s by 100\n\ts = +(s * 100).toFixed(1);\n\tl = +(l * 100).toFixed(1);\n\n\treturn HSL({ h, s, l });\n}\n\n/**\n * Converts an HSL color object to a string representation.\n *\n * @param {Object} hsl - Object containing the HSL color values.\n * @param {number} hsl.h - The hue value of the color.\n * @param {number} hsl.s - The saturation value of the color.\n * @param {number} hsl.l - The lightness value of the color.\n * @return {string} The HSL color as a string.\n */\nexport function HSL(hsl: { h: number; s: number; l: number }): string {\n\treturn `hsl(${hsl.h},${hsl.s}%,${hsl.l}%)`;\n}\n", "import colorSet from \"./data/colorSet.js\";\nimport { valuesToHex } from \"./hex-utils.js\";\nimport { valuesToHsl } from \"./hsl-utils.js\";\nimport { RGB } from \"./rgb-utils.js\";\nimport type { RGBCOLORDEF } from \"./types.js\";\n\n/**\n * This function was the opposite of the name of the repo and returns the color of the colorSet given the name\n *\n * @param {string} searchedColor -the name of the color to search for\n * @param {Array} set - the colorSet to search in\n */\nexport function getColor(\n\tsearchedColor: string,\n\tset: RGBCOLORDEF[] | undefined = colorSet as RGBCOLORDEF[],\n) {\n\tconst color: RGBCOLORDEF | undefined = set.find(\n\t\t(color: RGBCOLORDEF) => color[3] === searchedColor,\n\t);\n\n\tif (typeof color !== \"undefined\") {\n\t\tconst [r, g, b] = color;\n\t\treturn {\n\t\t\thex: valuesToHex({ r, g, b }),\n\t\t\trgb: RGB({ r, g, b }),\n\t\t\thsl: valuesToHsl({ r, g, b }),\n\t\t};\n\t}\n\n\tthrow new Error(`Error: invalid color ${searchedColor} or empty colorSet`);\n}\n\n/**\n * Get all the colors from the colorSet\n */\nexport function getColors() {\n\treturn colorSet.map((colorData) => {\n\t\treturn {\n\t\t\tname: colorData[3],\n\t\t\t...getColor(colorData[3] as string),\n\t\t};\n\t});\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,MAAM,WAAW;AAAA,IACf,CAAC,KAAK,KAAK,KAAK,OAAO;AAAA,IACvB,CAAC,GAAG,GAAG,GAAG,OAAO;AAAA,IACjB,CAAC,KAAK,GAAG,GAAG,KAAK;AAAA,IACjB,CAAC,GAAG,KAAK,GAAG,OAAO;AAAA,IACnB,CAAC,GAAG,GAAG,KAAK,MAAM;AAAA,IAClB,CAAC,KAAK,KAAK,GAAG,QAAQ;AAAA,IACtB,CAAC,KAAK,KAAK,KAAK,MAAM;AAAA,IACtB,CAAC,KAAK,KAAK,GAAG,QAAQ;AAAA,IACtB,CAAC,KAAK,GAAG,KAAK,SAAS;AAAA,IACvB,CAAC,KAAK,KAAK,IAAI,aAAa;AAAA,IAC5B,CAAC,KAAK,KAAK,KAAK,QAAQ;AAAA,IACxB,CAAC,GAAG,KAAK,GAAG,MAAM;AAAA,IAClB,CAAC,KAAK,GAAG,KAAK,QAAQ;AAAA,IACtB,CAAC,KAAK,IAAI,IAAI,QAAQ;AAAA,IACtB,CAAC,IAAI,KAAK,KAAK,WAAW;AAAA,IAC1B,CAAC,KAAK,KAAK,IAAI,OAAO;AAAA,IACtB,CAAC,GAAG,KAAK,KAAK,MAAM;AAAA,IACpB,CAAC,KAAK,KAAK,KAAK,aAAa;AAAA,IAC7B,CAAC,KAAK,KAAK,KAAK,MAAM;AAAA,IACtB,CAAC,IAAI,KAAK,IAAI,aAAa;AAAA,IAC3B,CAAC,KAAK,KAAK,KAAK,OA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B;AAChD,eAAO,UAAU,MAAM;AAAA,MACxB;AAAA,IACD;AAGA,UAAM,IAAI,MAAM,kBAAkB,WAAW,EAAE;AAAA,EAChD;AAWA,WAAS,QAAQ,OAAwB;AACxC,WAAO,QAAQ,OAAO,aAAa,EAAE,SAAS;AAAA,EAC/C;AAWA,WAAS,OAAO,OAAwB;AACvC,WAAO,QAAQ,OAAO,aAAa,EAAE,SAAS;AAAA,EAC/C;AAWA,WAAS,WAAW,OAAuB;AAC1C,WAAO,QAAQ,OAAO,MAAM,EAAE;AAAA,EAC/B;AAgBA,WAAS,SACR,MACA,MACA,OAAO,OACE;AACT,UAAM,CAAC,OAAO,OAAO,KAAK,IAAI;AAAA,MAC7B,KAAK,CAAC,IAAI,KAAK,CAAC;AAAA,MAChB,KAAK,CAAC,IAAI,KAAK,CAAC;AAAA,MAChB,KAAK,CAAC,IAAI,KAAK,CAAC;AAAA,IACjB;AACA,UAAM,OAAO,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ;AACrD,WAAO,OAAO,OAAO,KAAK,KAAK,IAAI;AAAA,EACpC;AAWA,WAAS,SAAS,WAAgC;AAEjD,QAAI,SAAS,KAAK,SAAS,GAAG;AAC7B,YAAM,MAAM,SAAS,SAAS;AAC9B,YAAM,YAAY,aAAa,GAAG;AAClC,aAAO,YAAY,SAAS;AAAA,IAC7B;AACA,UAAM,IAAI,MAAM,kBAAkB,SAAS,EAAE;AAAA,EAC9C;",
|
|
6
6
|
"names": ["value", "color"]
|
|
7
7
|
}
|
package/lib/color-utils.cjs
CHANGED
package/lib/color-utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "color-2-name",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"author": "Erik <erik@codekraft.it>",
|
|
5
5
|
"description": "Finds the closest color name to a given hex, rgb and hsl color (with and without alpha). It uses the Euclidean distance formula to calculate the distance between colors in the RGB color space",
|
|
6
6
|
"homepage": "https://wp-blocks.github.io/color-2-name/",
|