use-vibes
Version:
Transform any DOM element into an AI-powered micro-app
62 lines (61 loc) • 2.71 kB
TypeScript
import { ImageGenOptions } from 'call-ai';
import { ModuleState, ImageDocument, VersionInfo, PromptEntry } from './types';
export declare const MODULE_STATE: ModuleState;
export declare const cleanupRequestKey: (key: string) => void;
/**
* Synchronous hash function to create a key from the prompt string and options
* @param prompt The prompt string to hash
* @param options Optional image generation options
* @returns A hash string for the input
*/
export declare function hashInput(prompt: string, options?: ImageGenOptions): string;
export declare function base64ToFile(base64Data: string, filename: string): File;
/**
* Generate a version ID for the file namespace
* @param versionNumber - The numeric version (1-based)
* @returns A formatted version string like "v1", "v2", etc.
*/
export declare function generateVersionId(versionNumber: number): string;
/**
* Get all version information from a document, or create a default if none exists
* @param document - The image document
* @returns Array of version info objects
*/
export declare function getVersionsFromDocument(document: Partial<ImageDocument>): {
versions: Array<VersionInfo>;
currentVersion: number;
};
/**
* Generate a prompt key for the prompts namespace
* @param promptNumber - The numeric prompt (1-based)
* @returns A formatted prompt string like "p1", "p2", etc.
*/
export declare function generatePromptKey(promptNumber: number): string;
/**
* Get all prompt information from a document, or create a default if none exists
* @param document - The image document
* @returns Object with prompts record and currentPromptKey
*/
export declare function getPromptsFromDocument(document: Partial<ImageDocument>): {
prompts: Record<string, PromptEntry>;
currentPromptKey: string;
};
/**
* Add a new version to an image document
* @param document - The existing image document
* @param newImageFile - The new image file to add as a version
* @param newPrompt - Optional new prompt to use for this version
* @returns Updated document with the new version added
*/
export declare function addNewVersion(document: Partial<ImageDocument>, newImageFile: File, newPrompt?: string): ImageDocument;
/**
* Extract only the options properties that matter for image generation
* to avoid unnecessary re-renders or regenerations
*/
export declare function getRelevantOptions(options?: ImageGenOptions): Record<string, unknown>;
/**
* Generate a safe filename based on prompt text and timestamp
* @param promptText - The prompt text to include in the filename
* @returns A formatted filename like "prompt-text-20250518-2117.png"
*/
export declare function generateSafeFilename(promptText: string): string;