/** * Tailwind Utility Class Expander — Spec 22 R1.2 (compile-probe) * * Validates Tailwind class names against the project's own installed * `tailwindcss` package as the oracle. Zero hand-curated dictionaries — * the project's compiler IS the authority on what classes exist. * * **Primary (v4):** Uses `compile()` with `@apply` probe stylesheets. * **Fallback (v3):** Uses `resolveConfig()` + theme generation. * **Structural parsing:** Arbitrary values, variant prefixes, opacity * modifiers, and negative utilities are parsed via structural regex * patterns — never enumerated. * * **Fail-open rule:** If the probe can't initialize (no tailwindcss found, * compile fails), `configFailed` is true. The caller MUST emit a visible * warning and disable the undefined-class detector. */ /** * Result of resolving a Tailwind utility class against the validation pipeline. */ export interface UtilityClassResolution { /** Is this a known/valid utility class? */ valid: boolean; /** * Which tier resolved it: * 'probe' — validated by compile-probe (v4) or config generation (v3) * 'arbitrary-value' — matches `prefix-[...]` grammar * 'none' — no match found */ tier: 'probe' | 'arbitrary-value' | 'none'; } /** * Configuration for the Tailwind utility class expander. */ export interface TailwindExpanderConfig { /** Project root for loading Tailwind config / locating node_modules. */ projectRoot?: string; /** If true, attempt to load and use project Tailwind config. */ useProjectConfig?: boolean; /** User-supplied class names (use when useProjectConfig would fail — * the caller pre-resolves and passes them in). */ customClasses?: Set; } /** * Tailwind utility class expander backed by compile-probe. * * Validation pipeline: * 1. Probe cache (compile-probe or config-generation validated classes) * 2. User-supplied custom classes * 3. Opacity-modifier syntax (`utility/opacity`) * 4. Arbitrary-value grammar (`prefix-[...]`) * 5. Negative-utility syntax (`-utility`) * 6. Variant prefix stripping + retry against all of the above * * Fail-open: if the probe fails to initialize, configFailed is true. * The caller is responsible for emitting a visible warning and * potentially disabling the undefined-class detector. */ export declare class TailwindUtilityExpander { private probe; private customClasses; private _configFailed; private _configFailureReason; /** * Initialize the expander with optional project config. * Call once per audit. Async because it may compile-probe Tailwind. */ init(config?: TailwindExpanderConfig): Promise; /** Did the probe initialization fail? */ get configFailed(): boolean; /** Why did probe initialization fail? */ get configFailureReason(): string | null; /** Whether the probe is ready (initialized successfully). */ get probeReady(): boolean; /** Human-readable source of validation data. */ get probeSource(): string | null; /** * Validate a batch of unknown class names against the compile-probe. * Call this BEFORE resolve() to pre-populate the validation cache. * * Classes that pass validation are cached internally; resolve() will * find them on subsequent calls. * * Returns the full set of all validated classes (including previously * cached ones). */ validateBatch(candidates: string[]): Promise>; /** * Resolve a single class name against the validation pipeline. * Synchronous — only checks cached data + structural patterns. * Call validateBatch() first to populate the cache for unknown classes. */ resolve(className: string): UtilityClassResolution; /** * Check whether a class matches the arbitrary-value grammar: * `{prefix}-[...]` — any word prefix followed by `-[...]`. * * Structural check only — does not enumerate valid prefixes. * The Tailwind compiler is the authority on whether a prefix * actually accepts arbitrary values; our job is to not false-positive * on obviously-arbitrary syntax. */ private matchesArbitraryValue; /** * Check opacity-modifier syntax: `{utility}/{opacity}`. * * Split on the LAST `/` to avoid confusing fractional widths * (e.g. `w-1/2`). The prefix must be a known utility, suffix * must be a numeric opacity (0-100). */ private checkOpacityModifier; /** * Check negative-utility syntax: `-{utility}`. * * Structural check — strips the leading `-` and verifies the positive * utility itself is valid. No hand-curated allowed-prefixes list. */ private checkNegativeUtility; /** * Strip a Tailwind variant prefix from a class name. * Uses structural regex — matches any `word:` or `word-word:` prefix. * * E.g., "hover:bg-blue-500" → "bg-blue-500" * "md:w-full" → "w-full" * "group-hover:text-red" → "text-red" * "[&_>_a]:text-blue" → "text-blue" (arbitrary variant) * * Returns the original if no variant prefix is matched. */ stripVariantPrefix(className: string): string; /** * Check if a class has a variant prefix at all. */ hasVariantPrefix(className: string): boolean; /** Reset state (useful for testing). */ reset(): void; } export declare function getTailwindExpander(): TailwindUtilityExpander; export declare function resetTailwindExpander(): void; //# sourceMappingURL=tailwindUtilityExpander.d.ts.map