/** * AI Chat Engine - ChatGPT-style infinite chat panel * * Features: * - Bi-directional infinite scrolling (up for history, down for new messages) * - Message streaming (chunk-by-chunk rendering) * - Auto-scroll to bottom on new messages * - Variable message heights (code blocks, images, etc.) * - Real-time updates via WebSocket * - Message grouping/bundling * - Typing indicators * - Message status (sending, sent, delivered, read) */ import type { EngineConfig, VisibleRange } from './types'; export interface ChatMessage { id: string; role: 'user' | 'assistant' | 'system'; content: string; timestamp: number; status?: 'sending' | 'sent' | 'delivered' | 'read' | 'error'; metadata?: { codeBlocks?: number; imageCount?: number; estimatedReadTime?: number; }; } export interface ChatEngineConfig extends EngineConfig { /** Auto-scroll to bottom when new messages arrive */ autoScrollToBottom?: boolean; /** Enable message streaming */ enableStreaming?: boolean; /** Stream chunk size in characters */ streamChunkSize?: number; /** Stream delay in ms */ streamDelay?: number; /** Load more messages threshold */ loadMoreThreshold?: number; /** Enable typing indicators */ enableTypingIndicators?: boolean; /** Enable message grouping */ enableGrouping?: boolean; /** Grouping time threshold (ms) */ groupTimeThreshold?: number; } export interface ChatEngineState { messages: ChatMessage[]; visibleRange: VisibleRange; isLoadingHistory: boolean; isStreaming: boolean; hasMoreHistory: boolean; typingIndicator: boolean; scrollPosition: 'top' | 'middle' | 'bottom'; unreadCount: number; } export declare class ChatEngine { private config; private baseEngine; private state; private messageElements; private streamBuffer; private streamTimeout; private autoScrollEnabled; private userScrolling; private lastScrollTop; constructor(config: ChatEngineConfig); /** * Setup intelligent scroll detection */ private setupScrollDetection; /** * Get container element */ private getContainer; /** * Check if scrolled to bottom */ private isAtBottom; /** * Update scroll position and state */ private updateScrollPosition; /** * Add a new message */ addMessage(message: ChatMessage, fromStream?: boolean): void; /** * Stream message content (ChatGPT-style) */ streamMessage(messageId: string, content: string): void; /** * Load more history (scroll up) */ loadMoreHistory(): Promise; /** * Scroll to bottom */ scrollToBottom(smooth?: boolean): void; /** * Scroll to specific message */ scrollToMessage(messageId: string, position?: 'center' | 'start' | 'end'): void; /** * Update typing indicator */ setTypingIndicator(show: boolean): void; /** * Update message status */ updateMessageStatus(messageId: string, status: ChatMessage['status']): void; /** * Group messages by time */ getGroupedMessages(): ChatMessage[][]; /** * Get visible messages */ getVisibleMessages(): ChatMessage[]; /** * Update visible range */ private updateVisibleRange; /** * Update message element */ private updateMessageElement; /** * Render typing indicator */ private renderTypingIndicator; /** * Render message HTML */ private renderMessage; /** * Render typing animation */ private renderTypingAnimation; /** * Escape HTML */ private escapeHtml; /** * Get engine state */ getState(): ChatEngineState; /** * Destroy engine */ destroy(): void; } //# sourceMappingURL=ChatEngine.d.ts.map