/** * Design tokens — programmatic access to the canonical token JSON. * For generated platform files, see the `generated/` directory. * For the canonical JSON source, see `tokens/bytelyst.tokens.json`. */ import { readFileSync } from 'node:fs'; import { dirname, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = dirname(fileURLToPath(import.meta.url)); export interface DesignTokens { meta: { name: string; version: string; updatedAt: string; scale: string }; color: { palette: Record>; semantic: { dark: Record; light: Record; }; brain: Record; }; typography: { fontFamily: Record; fontWeight: Record; fontSize: Record; lineHeight: Record; letterSpacing: Record; }; spacing: Record; radius: Record; elevation: Record; motion: { duration: Record; easing: Record; }; breakpoints: Record; layout: Record; } let _cached: DesignTokens | null = null; export function loadTokens(): DesignTokens { if (_cached) return _cached; const tokenPath = resolve(__dirname, '../tokens/bytelyst.tokens.json'); const raw = readFileSync(tokenPath, 'utf-8'); _cached = JSON.parse(raw) as DesignTokens; return _cached; }