@stacksjs/stx
Version:
A performant UI Framework. Powered by Bun.
54 lines • 1.77 kB
TypeScript
/**
* Lazily load the Crosswind module
* Returns null if Crosswind is not installed
*/
export declare function loadCrosswind(): Promise<CrosswindModule | null>;
/**
* Reset the Crosswind module cache (useful for testing)
*/
export declare function resetCrosswindCache(): void;
/**
* Load crosswind config from the working directory
*/
export declare function loadCrosswindConfig(cwd: string): Promise<CrosswindConfig | null>;
/**
* Build Crosswind CSS using the build() API
* This scans content files and generates CSS for all used classes
*/
export declare function buildCrosswindCSS(cwd: string): Promise<string>;
/**
* Rebuild Crosswind CSS (called on file changes)
*/
export declare function rebuildCrosswindCSS(cwd: string): Promise<void>;
/**
* Get the cached CSS (for serving)
*/
export declare function getCachedCSS(): string;
/**
* Extract all CSS class names from HTML content
*/
export declare function extractClassNames(htmlContent: string): Set<string>;
/**
* Extract utility classes from HTML content and generate CSS using Crosswind
*/
export declare function generateCrosswindCSS(htmlContent: string): Promise<string>;
/**
* Inject generated CSS into HTML content
* Tries to inject before </head>, falls back to <body> or prepends
*/
export declare function injectCrosswindCSS(htmlContent: string): Promise<string>;
// Type for Crosswind module
declare interface CrosswindModule {
CSSGenerator: new (config: CrosswindConfig) => CSSGenerator
config: CrosswindConfig
build?: (config: CrosswindConfig) => Promise<CrosswindBuildResult>
defaultConfig?: CrosswindConfig
}
declare interface CrosswindConfig {
content?: string[]
output?: string
preflight?: boolean
minify?: boolean
preflights?: unknown[]
safelist?: string[]
}