/** * Pattern Inventory — cluster a product's bespoke CSS classes into BEM-ish * pattern families and classify each family by where it lives. * * Element-level coverage (product-analyzer) sees `` but is blind to * `
` — which is how most bespoke UI actually manifests. * This module reads `class` attributes from rendered HTML *and* template * sources (regex-level; njk/liquid/vue/jsx/…), reads class selectors from the * product's authored CSS, and joins the two sets: * * - **styled+used** — the real bespoke pattern surface (adoption targets) * - **styled+unused** — dead CSS (delete candidates) * - **used+unstyled** — orphaned class hooks (markup references no CSS ever * styles — invisible to CSS-only scans, and bradfrost.com's actual gap) * * Families carry the raw level-of-effort signals (instances × distinct files) * for the adoption plan's estimate phase. Deterministic and dependency-free. */ import type { NamedFile } from './product-analyzer.js'; export type FamilyClassification = 'styled+used' | 'styled+unused' | 'used+unstyled'; export interface PatternFamily { /** Family root, e.g. "postlist" for postlist/postlist-item/postlist__link. */ family: string; /** Distinct class names in the family (markup ∪ CSS), sorted. */ classes: string[]; classification: FamilyClassification; /** Total markup occurrences across all scanned files (LOE signal). */ instanceCount: number; /** Distinct markup files the family appears in (LOE signal). */ distinctFiles: number; /** Markup files with per-file counts, highest first (capped at 20). */ files: Array<{ file: string; count: number; }>; /** Total CSS rules whose selector mentions a family class. */ cssRuleCount: number; /** Where the styling lives (the file with the most rules), when styled. */ css?: { file: string; lineStart: number; lineEnd: number; }; /** Distinct host tag names the classes were seen on (capped at 10). */ contextTags: string[]; } export interface PatternInventory { families: PatternFamily[]; familiesOmitted?: number; totals: { families: number; styledAndUsed: number; deadCss: number; orphanedHooks: number; classInstances: number; }; excludedPrefixes: string[]; } export interface PatternInventoryOptions { /** Class-name prefixes to exclude (DS-owned, state, obvious third-party). */ excludePrefixes?: string[]; /** Exact class names to exclude (utility noise). */ excludeClasses?: string[]; /** Cap on reported families (default 200; sorted by instance count first). */ maxFamilies?: number; } /** DS-owned, state, and obvious third-party prefixes excluded by default. */ export declare const DEFAULT_EXCLUDED_PREFIXES: string[]; /** * Build the pattern inventory from markup (HTML + template) files and authored * product CSS. Pure — the caller collects the files (see `collectFromPath` * with `includeTemplates: true`). */ export declare function buildPatternInventory(opts: { markupFiles: NamedFile[]; cssFiles: NamedFile[]; options?: PatternInventoryOptions; }): PatternInventory; //# sourceMappingURL=pattern-inventory.d.ts.map