//#region src/types.d.ts /** * Compiled lookup tables consumed by the engine. Generated by the compiler * (`scripts/compile-tables.mjs`) — flat typed arrays plus string pools; see * the compiler for the encoding. */ interface Tables { /** number of static conflict groups */ GROUP_COUNT: number; /** CSR: node → [start,end) range into edge arrays */ edgeStart: Int32Array; /** CSR: edge → [start,end) range into labelText */ labelStart: Int32Array; /** radix-edge label characters, concatenated */ labelText: string; /** edge → target node */ edgeTarget: Int32Array; /** node → group id (0 = none) offset by 1 */ nodeGroup: Int32Array; /** node → validator-list id (-1 = none) */ nodeVlist: Int32Array; /** CSR: validator-list pattern → [start,end) into vlistOps */ vlistPat: Int32Array; /** validator opcodes */ vlistOps: Int32Array; /** validator-list → op pattern id */ vlistRef: Int32Array; /** flat per-list group ids (delta-coded at generation) */ vlistGroup: Int32Array; /** lifted-literal entry → anchor node */ litAnchor: Int32Array; /** lifted-literal entry → group id */ litGroup: Int32Array; /** lifted-literal entry → pool string id */ litPool: Int32Array; /** pool string id → (offset, length) pairs into poolText */ poolOffsets: Int32Array; /** deduplicated literal tail text */ poolText: string; /** conflict adjacency: row → source group id */ adjGid: Int32Array; /** CSR: row → [start,end) into adjTgt */ adjStart: Int32Array; /** overridden group ids */ adjTgt: Int32Array; /** postfix-extra conflict pairs (conflictingClassGroupModifiers) */ patGid: Int32Array; patTgt: Int32Array; /** groups participating in postfix re-lookup (postfixLookupClassGroups) */ postfixLookupGroups: Int32Array; /** names of validators not compiled to span opcodes (custom configs) */ customValidatorNames: string[]; /** space-separated order-sensitive variant names */ orderSensitiveModifiers: string; /** optional Tailwind v4 prefix baked into the tables */ prefix?: string; } interface EngineOptions { /** whole-string result cache size; 0 disables (default 500) */ cacheSize?: number; /** Tailwind v4 prefix (`tw` matches `tw:hover:p-4`); overrides tables */ prefix?: string; } /** implementations for validators named in `Tables.customValidatorNames` */ type ValidatorImpls = Record boolean>; /** tailwind-merge `twJoin`/`twMerge` argument shape (strings + nested arrays) */ type ClassNameValue = ClassNameArray | string | null | undefined | 0 | 0n | false; type ClassNameArray = readonly ClassNameValue[]; /** clsx argument shape (adds numbers and object syntax) */ type ClassValue = ClassArray | ClassDictionary | string | number | bigint | null | boolean | undefined; type ClassArray = ClassValue[]; interface ClassDictionary { [id: string]: any; } interface Engine { /** variadic merge, `twMerge`-compatible (strings + nested arrays) */ merge: (...inputs: ClassNameValue[]) => string; /** merge one already-joined class string */ mergeString: (input: string) => string; /** merge one string, bypassing the whole-string cache */ mergeUncached: (input: string) => string; } /** the `cn` function shape: clsx arguments, merged output */ type CnFunction = (...inputs: ClassValue[]) => string; //#region src/compiler.d.ts type ClassGroupDef = string | { $v: string; } | { $t: string; } | ((value: string) => boolean) | { [key: string]: ClassGroupDef[]; }; interface CnConfig { theme: Record; classGroups: Record; conflictingClassGroups: Record; conflictingClassGroupModifiers: Record; orderSensitiveModifiers: string[]; postfixLookupClassGroups?: readonly string[]; prefix?: string; } interface ConfigExtension { prefix?: string; cacheSize?: number; override?: Partial>; extend?: Partial>; } /** * Accepted config input: an `{ extend, override, prefix }` extension, a * `(defaultConfig) => config` transform, or a complete config. Lives here * (not in config.ts) so the `index` entry can re-export it without pulling * config.ts into a shared declaration chunk that collides with the * `cn/config` entry's own d.ts filename. */ type CreateCnInput = ConfigExtension | ((config: CnConfig) => CnConfig) | CnConfig; //#region src/engine.d.ts declare const createEngine: (T: Tables, validatorImpls?: ValidatorImpls, options?: EngineOptions) => Engine; /** join-only, `twJoin`-compatible (strings + nested arrays, falsy skipped) */ declare const twJoin: (...inputs: ClassNameValue[]) => string; /** join-only, `clsx`-compatible (no merging) */ declare const clsx: (...inputs: ClassValue[]) => string; //#region src/index.d.ts /** * Merge Tailwind CSS classes with clsx-style arguments (strings, arrays, * objects, conditionals). Drop-in replacement for `twMerge(clsx(...))`. */ declare const cn: CnFunction; /** tailwind-merge–compatible variadic merge (strings + nested arrays). */ declare const twMerge: (...inputs: ClassNameValue[]) => string; export { clsx, cn, createEngine, twJoin, twMerge }; export type { ClassArray, ClassDictionary, ClassNameArray, ClassNameValue, ClassValue, CnConfig, CnFunction, ConfigExtension, CreateCnInput, Engine, EngineOptions, Tables, ValidatorImpls };