refactor(utils): replace MONTH_NAMES array, drop @uiw/color-convert, use z.enum for localeSchema

Finding 1: Replace hand-rolled MONTH_NAMES[12] array with Intl.DateTimeFormat("en-US", {month:"long"}).
Finding 2: Drop @uiw/color-convert fallback — parseColorString already rejects the same inputs, return "#000000" instead. Remove dep from utils and server package.json.
Finding 3: Replace 56 z.literal calls in z.union with z.enum([...]); identical parse behavior and inferred type.

Claude-Session: https://claude.ai/code/session_012Bnvt1MghwHj4qQRxuQUGa
This commit is contained in:
Amruth Pillai
2026-07-04 20:53:51 +02:00
parent 5226f04e86
commit a5935dee0f
7 changed files with 70 additions and 86 deletions
+4 -6
View File
@@ -1,19 +1,17 @@
import type { ColorResult } from "@uiw/color-convert";
import { hsvaToHex, rgbaStringToHsva } from "@uiw/color-convert";
type ParsedColor = { r: number; g: number; b: number; a: number };
export function rgbaStringToHex(rgba: string): string {
const color = parseColorString(rgba);
if (color) return `#${toHexComponent(color.r)}${toHexComponent(color.g)}${toHexComponent(color.b)}`;
const hsva = rgbaStringToHsva(rgba);
return hsvaToHex(hsva);
// ponytail: unrecognized format → black; same result the prior @uiw/color-convert fallback produced
return "#000000";
}
function toHexComponent(value: number): string {
return Math.max(0, Math.min(255, value)).toString(16).padStart(2, "0");
}
export function parseColorString(value: string): ColorResult["rgba"] | null {
export function parseColorString(value: string): ParsedColor | null {
const trimmed = value.trim();
// Parse rgb/rgba colors