import { C as ClassOccurrence, a as ClasspressoConfig, b as ConsolidationCandidate, c as ClassMapping, F as FileStats, T as TransformResult, O as OptimizationMetrics } from './index-BtYg-usR.js'; export { D as DynamicBasePattern, E as ExcludeConfig, M as MappingManifest, S as ScanResult, d as SourceFileType } from './index-BtYg-usR.js'; export { containsDynamicPrefix, detectMergeablePatterns, isProperSubset, normalizeClassString, scanBuildOutput, shouldExcludeClass } from './scanner.js'; export { buildReplacementMap, createClassMappings, loadMappingManifest, saveMappingManifest } from './consolidator.js'; export { transformBuildOutput } from './transformer.js'; /** * Pattern Detector - Identifies patterns worth consolidating */ /** * Detect patterns that are worth consolidating * Uses sequential naming (cp-a, cp-b, etc.) for shortest possible class names * @param occurrences - Map of pattern occurrences from scanner * @param config - Classpresso configuration * @param mergeablePatterns - Patterns that would be skipped in JS but not HTML (for SSR mode) */ declare function detectConsolidatablePatterns(occurrences: Map, config: ClasspressoConfig, mergeablePatterns?: Set): ConsolidationCandidate[]; /** * Get summary statistics for detected patterns */ declare function getPatternSummary(candidates: ConsolidationCandidate[]): { totalPatterns: number; totalOccurrences: number; totalBytesSaved: number; avgFrequency: number; avgClassesPerPattern: number; }; /** * CSS Generator - Creates consolidated CSS rules */ /** * Parse a Tailwind utility class and return its CSS */ declare function parseUtilityClass(className: string): string[]; /** * Generate CSS for consolidated classes */ declare function generateConsolidatedCSS(mappings: ClassMapping[], buildDir: string, cssLayer?: string | false): Promise; /** * Inject consolidated CSS into the build * Only injects into ONE CSS file (the largest) to avoid duplicating overhead */ declare function injectConsolidatedCSS(buildDir: string, consolidatedCSS: string): Promise; /** * Rehasher - Restore the cache-busting contract for content-hashed assets. * * Bundlers (Vite/Rollup `[hash]`, webpack `[contenthash]`, …) name assets after their * PRE-optimization content. Classpresso rewrites those files in place but keeps the * filename, so the hash in the filename no longer reflects the SERVED content. A returning * client with `Cache-Control: immutable` then keeps serving a stale cached copy after a * redeploy: old `cp-*` rules against new `cp-*` references → broken styling. * * The fix: after all mutations are done, re-hash every content-hashed asset whose content * actually changed, rename it to a new content-hash filename, and rewrite every reference * to it (HTML, JS, CSS `url()`, and bundler manifest JSON) so the build stays internally * consistent. Identical input → identical output, so the names are deterministic. * * Only JS/CSS assets with a hash-shaped filename are renamed. HTML/RSC entry documents are * never renamed (they are served by route, not by hash) but their references are updated. */ interface RehashRename { /** Absolute path before renaming */ fromPath: string; /** Absolute path after renaming */ toPath: string; /** Original filename (basename) */ fromName: string; /** New filename (basename) */ toName: string; } interface RehashResult { /** Assets that were renamed to a new content-hash filename */ renamed: RehashRename[]; /** Number of files whose references were rewritten */ filesUpdated: number; /** Non-fatal errors */ errors: string[]; } /** * Split a filename into { prefix, hash, ext } when it carries a content hash. * Returns null when no hash-shaped segment is present. * * Handles the common forms: * index-D4Gx2k_p.css (Vite/Rollup: name-.ext) * main.1f2e3d4c.js (webpack: name..ext) * D4Gx2k_p.css (filename is the hash itself) */ declare function detectContentHash(basename: string): { prefix: string; hash: string; ext: string; } | null; /** * Snapshot the content hash of every candidate asset BEFORE any mutation. * Compared against the post-mutation state to find what actually changed. */ declare function captureAssetHashes(config: ClasspressoConfig): Promise>; /** * Re-hash modified content-hashed assets and rewrite every reference to them. * * @param originalHashes Snapshot from captureAssetHashes(), taken before mutation. */ declare function rehashAssets(config: ClasspressoConfig, originalHashes: Map): Promise; /** * Metrics - Calculate and format optimization metrics */ /** * Calculate optimization metrics */ declare function calculateMetrics(candidates: ConsolidationCandidate[], originalFiles: FileStats[], transformResult: TransformResult, cssOverhead: number): OptimizationMetrics; /** * Estimate CSS overhead from consolidated classes */ declare function estimateCSSOverhead(candidates: ConsolidationCandidate[]): number; /** * Format bytes for display */ declare function formatBytes(bytes: number): string; /** * Format percentage for display */ declare function formatPercentage(value: number): string; /** * Format time in milliseconds */ declare function formatTime(ms: number): string; /** * Configuration loader for Classpresso */ /** * Default prefixes that indicate dynamically-generated classes from icon/component libraries. * Patterns containing these will be skipped to prevent hydration mismatches. */ declare const DEFAULT_DYNAMIC_PREFIXES: string[]; /** * Default configuration */ declare const DEFAULT_CONFIG: ClasspressoConfig; /** * Load configuration from file or use defaults */ declare function loadConfig(buildDir?: string): Promise; /** * Validate configuration */ declare function validateConfig(config: ClasspressoConfig): string[]; /** * Generate a hash-based class name from a normalized class string * @deprecated Use generateSequentialName for shorter names */ declare function generateHashName(normalizedClassString: string, prefix?: string, length?: number): string; /** * Resolve hash collisions by appending a suffix */ declare function resolveCollisions(candidates: T[]): T[]; /** * Regex utilities for Classpresso */ /** * Escape special regex characters in a string */ declare function escapeRegex(str: string): string; /** * Patterns to match className in various contexts */ declare const CLASS_PATTERNS: { jsxDouble: RegExp; jsxSingle: RegExp; createElementDouble: RegExp; createElementSingle: RegExp; minifiedComma: RegExp; htmlDouble: RegExp; htmlSingle: RegExp; htmlEntityDouble: RegExp; htmlNumericDouble: RegExp; rscPayload: RegExp; vueCreateElementDouble: RegExp; vueCreateElementSingle: RegExp; jsxBacktick: RegExp; createElementBacktick: RegExp; }; /** * All patterns combined for extraction */ declare const ALL_CLASS_PATTERNS: RegExp[]; /** * Check if a class string contains dynamic expressions */ declare function isDynamicClassString(classString: string): boolean; /** * Patterns to extract the static base portion of template literal class names * These capture the static classes before the ${...} dynamic expression */ declare const DYNAMIC_BASE_PATTERNS: RegExp[]; /** * Extract static base patterns from template literals with dynamic expressions * Returns the static class portion before ${...} */ declare function extractDynamicBaseStrings(content: string): string[]; /** * File utilities for Classpresso */ /** * Default file patterns to scan in build output * * These patterns support all major frameworks when pointing to their build directories: * - Next.js: --dir .next * - Astro: --dir dist * - Nuxt: --dir .output * - SvelteKit: --dir build (or .svelte-kit) * - Remix: --dir build * - Solid Start: --dir .output (or dist) * - Qwik: --dir dist * - Angular: --dir dist/[project-name] * - Gatsby: --dir public * - Vite/Vue/React: --dir dist * - Ember: --dir dist * - VitePress: --dir .vitepress/dist * - Docusaurus: --dir build * - Eleventy (11ty): --dir _site * - Hugo: --dir public * - Parcel: --dir dist * - Preact: --dir build (or dist) * - Gridsome: --dir dist * - RedwoodJS: --dir web/dist * - Webpack: --dir dist */ declare const DEFAULT_PATTERNS: string[]; /** * Find files matching patterns in a build directory */ declare function findFiles(buildDir: string, patterns: string[]): Promise; /** * Read file content as string */ declare function readFileContent(filePath: string): Promise; /** * Write content to file */ declare function writeFileContent(filePath: string, content: string): Promise; /** * Get file size in bytes */ declare function getFileSize(filePath: string): Promise; /** * Create a backup of a file */ declare function backupFile(filePath: string): Promise; export { ALL_CLASS_PATTERNS, CLASS_PATTERNS, ClassMapping, ClassOccurrence, ClasspressoConfig, ConsolidationCandidate, DEFAULT_CONFIG, DEFAULT_DYNAMIC_PREFIXES, DEFAULT_PATTERNS, DYNAMIC_BASE_PATTERNS, FileStats, OptimizationMetrics, type RehashRename, type RehashResult, TransformResult, backupFile, calculateMetrics, captureAssetHashes, detectConsolidatablePatterns, detectContentHash, escapeRegex, estimateCSSOverhead, extractDynamicBaseStrings, findFiles, formatBytes, formatPercentage, formatTime, generateConsolidatedCSS, generateHashName, getFileSize, getPatternSummary, injectConsolidatedCSS, isDynamicClassString, loadConfig, parseUtilityClass, readFileContent, rehashAssets, resolveCollisions, validateConfig, writeFileContent };