// One-shot: classify every top-level recipe key in base.ts against the naming canon. import { readFileSync } from 'node:fs'; const src = readFileSync('src/uix/eidos/lib/recipes/base.ts', 'utf8').replace(/\r\n/g, '\n'); const blocks = [...src.matchAll(/^\t'?([a-z0-9-]+)'?: \{/gm)].map((m) => ({ name: m[1], at: m.index! })); const MODS = ['hover', 'active', 'selected', 'disabled', 'checked', 'open', 'focus', 'invalid']; const out: Record> = { trailingMod: new Set(), colorSegment: new Set(), both: new Set() }; const perComp = new Map(); let total = 0; for (let i = 0; i < blocks.length; i++) { const end = i + 1 < blocks.length ? blocks[i + 1].at : src.length; const body = src.slice(blocks[i].at, end); for (const k of body.matchAll(/^\t\t'?(_?[a-z0-9-]+)'?\s*:/gm)) { const key = k[1]; if (key.startsWith('_')) continue; total++; const trailing = MODS.some( (m) => key.endsWith('-' + m) || MODS.some((m2) => key.endsWith('-' + m + '-' + m2)) ); const colorSeg = /(^|-)color(-|$)/.test(key) && !/^color-scheme/.test(key); const tag = blocks[i].name + '.' + key; if (trailing && colorSeg) out.both.add(tag); else if (trailing) out.trailingMod.add(tag); else if (colorSeg) out.colorSegment.add(tag); if (trailing || colorSeg) perComp.set(blocks[i].name, (perComp.get(blocks[i].name) ?? 0) + 1); } } console.log('total public keys:', total); console.log( 'trailing modifier:', out.trailingMod.size, '| color segment:', out.colorSegment.size, '| both:', out.both.size ); console.log('components affected:', perComp.size); console.log( [...perComp.entries()] .sort((a, b) => b[1] - a[1]) .slice(0, 15) .map(([c, n]) => `${c}:${n}`) .join(' ') ); console.log('sample colorSegment:', [...out.colorSegment].slice(0, 8).join(', ')); console.log('sample both:', [...out.both].slice(0, 6).join(', '));