UNPKG

@agentman/chat-widget

Version:

Agentman Chat Widget for easy integration with web applications

114 lines (113 loc) 3.08 kB
import type { ViewManager } from '../components/ViewManager'; import type { EventBus } from '../utils/EventBus'; /** * Configuration options for LoadingManager */ export interface LoadingManagerConfig { debug?: boolean; defaultTimeout?: number; allowContinueAfterTimeout?: boolean; } /** * LoadingManager - Manages loading states and indicators * * This handler manages: * - Loading indicator display * - Multiple concurrent loading operations * - Loading timeout handling * - Progress tracking for file uploads * - Loading state events */ export declare class LoadingManager { private viewManager; private eventBus; private logger; private activeLoadingOperations; private loadingTimeouts; private loadingStartTimes; private config; constructor(viewManager: ViewManager, eventBus: EventBus, config?: LoadingManagerConfig | boolean); /** * Start a loading operation */ startLoading(operation: 'message_send' | 'agent_init' | 'file_upload' | 'conversation_load', options?: { timeout?: number; message?: string; showIndicator?: boolean; allowContinueAfterTimeout?: boolean; }): string; /** * Complete a loading operation */ completeLoading(operationId: string, success?: boolean, error?: Error): void; /** * Check if any loading operations are active */ isLoading(): boolean; /** * Check if a specific operation type is loading */ isOperationLoading(operation: string): boolean; /** * Get all active loading operations */ getActiveOperations(): string[]; /** * Cancel a specific loading operation */ cancelLoading(operationId: string): void; /** * Cancel all loading operations */ cancelAllLoading(): void; /** * Update loading progress (for file uploads, etc.) */ updateProgress(operationId: string, progress: number, message?: string): void; /** * Set a custom loading message */ setLoadingMessage(message: string): void; /** * Show loading indicator in the UI */ private showLoadingIndicator; /** * Hide loading indicator in the UI */ private hideLoadingIndicator; /** * Update loading progress in the UI */ private updateLoadingProgress; /** * Update loading message in the UI */ private updateLoadingMessage; /** * Handle loading timeout * @param operationId - The operation ID * @param operation - The type of operation * @param allowContinue - Whether to allow the operation to continue after timeout */ private handleLoadingTimeout; /** * Extract operation type from operation ID */ private getOperationFromId; /** * Get loading statistics */ getLoadingStats(): { activeCount: number; operations: { id: string; duration: number; operation: string; }[]; }; /** * Clean up resources */ destroy(): void; }