@agentman/chat-widget
Version:
Agentman Chat Widget for easy integration with web applications
74 lines (73 loc) • 1.83 kB
TypeScript
import type { EventBus } from '../utils/EventBus';
/**
* Loading state types
*/
export declare enum LoadingType {
NONE = "none",
INITIAL = "initial",// Wave loading indicator (5 dots)
STREAMING = "streaming"
}
/**
* Unified loading state configuration
*/
export interface UnifiedLoadingConfig {
debug?: boolean;
transitionDelay?: number;
}
/**
* UnifiedLoadingManager - Manages loading states to prevent multiple indicators
*
* This manager ensures only one loading indicator is shown at a time by:
* - Tracking the current loading state
* - Validating state transitions
* - Coordinating with UI components
* - Emitting events for state changes
*/
export declare class UnifiedLoadingManager {
private eventBus;
private logger;
private currentState;
private config;
private transitionTimeout;
constructor(eventBus: EventBus, config?: UnifiedLoadingConfig);
/**
* Get the current loading state
*/
getLoadingState(): LoadingType;
/**
* Set the loading state with validation
*/
setLoadingState(newState: LoadingType): boolean;
/**
* Transition to a new state (convenience method)
*/
transitionTo(newState: LoadingType): boolean;
/**
* Check if currently in a loading state
*/
isLoading(): boolean;
/**
* Check if in a specific loading state
*/
isInState(state: LoadingType): boolean;
/**
* Reset to no loading state
*/
reset(): void;
/**
* Validate state transitions
*/
private isValidTransition;
/**
* Apply the state transition
*/
private applyStateTransition;
/**
* Get human-readable description of current state
*/
getStateDescription(): string;
/**
* Clean up resources
*/
destroy(): void;
}