@stacksjs/stx
Version:
A performant UI Framework. Powered by Bun.
30 lines • 1.08 kB
TypeScript
import type { StxOptions } from './types';
/**
* Check if a cached version of the template is available and valid
*/
export declare function checkCache(filePath: string, options: StxOptions): Promise<string | null>;
/**
* Cache the processed template
*/
export declare function cacheTemplate(filePath: string, output: string, dependencies: Set<string>, options: StxOptions): Promise<void>;
/**
* Create a hash of the file path for cache filenames
*
* Uses SHA-1 (fast, collision-resistant enough for cache keys) truncated to
* CACHE_HASH_LENGTH characters. The truncated hash still provides strong
* uniqueness guarantees for cache file identification.
*
* @param filePath - Absolute path to the template file
* @returns A 16-character hex string suitable for use as a filename
*/
export declare function hashFilePath(filePath: string): string;
// Memory cache for compiled templates
export declare const templateCache: Map<string, CacheEntry>;
/**
* Cache entry structure
*/
declare interface CacheEntry {
output: string
mtime: number
dependencies: Set<string>
}