/** * Core plugin options for initializing the Blurhash cache module. */ export interface BlurhashCoreOptions { /** * Database connection string */ databasePath: string; /** * Absolute path to the project root directory. * Used to resolve relative image paths. */ projectRoot: string; /** * Emit diagnostic logging (skipped-file reasons, dimension probe failures). * Defaults to `false`: rendering stays silent unless asked. */ verbose?: boolean; } /** * Success result type for `get_blurhash` function. */ export interface BlurhashSuccessResult { success: true; blurhash: string; width: number; height: number; /** * Base64-encoded lossy WebP render of the blurhash placeholder (a 32×32 image * encoded with quality=20, effort=6). `null` when the placeholder could not be * baked (e.g. the blurhash failed to decode). */ webpBase64: string | null; } /** * Error result type for `get_blurhash` function. */ export interface BlurhashErrorResult { success: false; error: string; } /** * Union return type for `get_blurhash` function. */ export type BlurhashResult = BlurhashSuccessResult | BlurhashErrorResult; /** * Intrinsic pixel dimensions probed from an image file header (no decode). */ export interface DimensionProbeResult { width: number; height: number; } /** * Success result type for `migrate_webp_placeholders`. */ export interface WebpMigrationSuccessResult { success: true; /** Number of cache rows that received a freshly baked WebP placeholder. */ processed: number; /** Number of cache rows whose WebP bake failed and were left untouched. */ skipped: number; } /** * Error result type for `migrate_webp_placeholders`. */ export interface WebpMigrationErrorResult { success: false; error: string; } /** * Union return type for `migrate_webp_placeholders`. */ export type WebpMigrationResult = WebpMigrationSuccessResult | WebpMigrationErrorResult; /** * Parsed image source information. */ export interface ParsedImageSource { /** Cleaned image path (with size definitions removed) */ cleanSrc: string; /** User-specified render width */ renderWidth: number | null; /** User-specified render height */ renderHeight: number | null; } /** * File validation result. */ export interface FileValidationResult { /** Whether the file should be processed by the native module */ shouldProcess: boolean; /** Resolved absolute path (only if shouldProcess is true) */ resolvedPath?: string; /** Validation failure reason (only if shouldProcess is false) */ reason?: string; } declare module "./load.cjs" { /** * Initialize the Blurhash cache system. Must be called before all other functions. * @param databasePath Database connection string * @param projectRoot Project root directory path * @returns `true` if initialization succeeds, otherwise throws an error */ function initialize_blurhash_cache(databasePath: string, projectRoot: string): boolean; /** * Generate or retrieve cached blurhash, width and height for the specified image. * @param imagePath Image file path (can be absolute or relative to projectRoot) * @returns An object containing blurhash data or error information */ function get_blurhash(imagePath: string): BlurhashResult; /** * Read the intrinsic pixel dimensions of an image file without decoding it. * Covers every raster format `get_blurhash` decodes plus SVG; does not touch * the cache database. * @param imagePath Image file path * @returns An object containing the dimensions or error information */ function probe_image_dimensions(imagePath: string): { success: true; width: number; height: number; } | { success: false; error: string; }; /** * Backfill the baked WebP placeholder for every cached image that is missing one. * * Placeholders are regenerated purely from the cached blurhash string, so source * image files are never read during migration. * @returns An object describing how many rows were processed/skipped, or an error */ function migrate_webp_placeholders(): WebpMigrationResult; /** * Check if the Blurhash cache system is initialized. * @returns `true` if initialized */ function is_initialized(): boolean; /** * Clean up global context and close database connections. * @returns `true` if cleanup succeeds */ function clear_context(): boolean; } /** * Check if a URL is a network URL (starts with http:// or https://). * @param src Image source string * @returns true if it's a network URL */ export declare function isNetworkUrl(src: string): boolean; /** * Check if a file is an SVG image based on its extension. * @param filePath File path to check * @returns true if it's an SVG file */ export declare function isSvgFile(filePath: string): boolean; /** * Validate if the file should be processed by the native module. * @param src Image source path * @param projectRoot Project root directory * @returns Validation result with processing decision */ export declare function validateFile(src: string, projectRoot: string): FileValidationResult; /** * Parse image `src` attribute to separate path and render dimensions. * Syntax: `path/to/image.png =100x200`, `path =100x`, `path =x200` * @param src Original src string from markdown token * @returns Object containing cleaned path and render dimensions */ export declare function parseImageSrc(src: string): ParsedImageSource; /** * Core Blurhash processor class */ export declare class BlurhashCore { private initialized; private options; constructor(options: BlurhashCoreOptions); /** * Initialize the Blurhash cache system */ initialize(): void; /** * Check if the core is initialized */ isInitialized(): boolean; /** * Process an image and get blurhash data * @param src Clean image source path (without size definitions) * @returns Blurhash result or null if processing should be skipped */ processImage(src: string): BlurhashResult | null; /** * Read the intrinsic pixel dimensions of an image file without decoding it. * * Header-only probe via the native module: covers every raster format the * blurhash path decodes, plus SVG (skipped by `processImage`). Intended for * files that will not get a blurhash, skipped or failed, so their fallback * markup can still carry layout hints. Unlike `processImage` there is no * project-root restriction: callers pass resolved paths they already trust. * * @param src Image source path (relative paths resolve against projectRoot) * @returns Dimensions, or `null` when they cannot be determined */ probeDimensions(src: string): DimensionProbeResult | null; /** * Backfill the baked WebP placeholder for every cached image that is missing one. * * This is the migration entry point for databases that pre-date the WebP column * (or whose placeholder bake previously failed). Each missing placeholder is * regenerated from the cached blurhash string; source image files are not read. * * @returns Migration summary (processed/skipped counts) or an error result */ migrateWebpPlaceholders(): WebpMigrationResult; /** * Clean up resources */ cleanup(): boolean; /** * Get project root */ getProjectRoot(): string; }