@agentman/chat-widget
Version:
Agentman Chat Widget for easy integration with web applications
101 lines (100 loc) • 2.63 kB
TypeScript
import type { ViewManager } from '../components/ViewManager';
import type { EventBus } from '../utils/EventBus';
/**
* 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;
constructor(viewManager: ViewManager, eventBus: EventBus, debug?: boolean);
/**
* Start a loading operation
*/
startLoading(operation: 'message_send' | 'agent_init' | 'file_upload' | 'conversation_load', options?: {
timeout?: number;
message?: string;
showIndicator?: 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
*/
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;
}