imagenai
Version:
Core client library for Imagenai image generation API
75 lines (74 loc) • 1.91 kB
TypeScript
import { ImagenaiClient } from './client';
import { GeneratedImage } from './types';
export interface AltTagConfig {
prompt: string;
size?: '1024x1024' | '1024x1536' | '1536x1024';
quality?: 'low' | 'medium' | 'high';
}
export interface ProcessingOptions {
autoProcess?: boolean;
showLoading?: boolean;
onImageGenerated?: (img: HTMLImageElement, result: GeneratedImage) => void;
onError?: (img: HTMLImageElement, error: Error) => void;
placeholderImage?: string;
loadingImage?: string;
}
export declare class ImagenaiAltTagProcessor {
private client;
private options;
private processedImages;
private observer;
constructor(client: ImagenaiClient, options?: ProcessingOptions);
/**
* Start automatic processing of alt tags
*/
startAutoProcessing(): void;
/**
* Stop automatic processing
*/
stopAutoProcessing(): void;
/**
* Process all images with [IMAGENAI] alt tags
*/
processAltTags(): Promise<void>;
/**
* Process a single image
*/
processImage(img: HTMLImageElement): Promise<void>;
/**
* Parse alt text for [IMAGENAI:...] syntax
*/
private parseAltTag;
/**
* Show loading state for an image
*/
private showLoadingState;
/**
* Show error state for an image
*/
private showErrorState;
/**
* Replace image with generated result
*/
private replaceImage;
/**
* Start observing DOM changes for new images
*/
private startObserver;
/**
* Get processing statistics
*/
getStats(): {
totalProcessed: number;
processedImages: {
src: string;
alt: string;
generatedId: string | undefined;
generatedAt: string | undefined;
}[];
};
/**
* Clear processing history
*/
clearHistory(): void;
}