@ertekinno/human-like
Version:
A sophisticated React typewriter effect library with realistic human typing behavior, mobile/desktop keyboards, and comprehensive theming support
89 lines (88 loc) • 2.92 kB
TypeScript
import { HumanLikeConfig, MistakeInfo, TypingState, TypingEvent, TypingStats, KeyInfo } from '../types';
export declare class TypingEngine {
private config;
private text;
private currentIndex;
private displayText;
private state;
private timeoutId;
private keyTimeouts;
private stats;
private events;
private mistakes;
private correctionQueue;
private isCorrectingMistake;
private charactersTyped;
private fatigueLevel;
private pauseStartTime;
private totalPausedTime;
private keyboardAnalyzer;
private onStateChange?;
private onCharacter?;
private onMistake?;
private onBackspace?;
private onComplete?;
private onProgress?;
private onKey?;
constructor(text: string, config?: Partial<HumanLikeConfig>);
private debug;
private safeCallback;
private initializeStats;
start(): void;
stop(): void;
pause(): void;
resume(): void;
skip(): void;
reset(): void;
private scheduleNextCharacter;
/**
* Calculate character delay using natural keyboard timing
* This revolutionary approach replaces artificial delays with realistic key sequences
*/
private calculateCharacterDelayWithKeyboard;
private shouldMakeMistake;
private makeMistake;
private processNextCorrection;
private correctMistake;
private performBackspaceSequence;
private finishCorrection;
private typeCharacter;
private selectMistakeType;
private generateMistakeChar;
private shouldHaveConcentrationLapse;
private getNextWord;
private getCurrentWord;
private getWordStartIndex;
private isComplexWord;
private shouldMakeLookAheadMistake;
private completeTyping;
private updateProgress;
private updateWPM;
private updateTotalDuration;
private recordEvent;
getText(): string;
getDisplayText(): string;
getState(): TypingState;
getProgress(): number;
getStats(): TypingStats;
getMistakes(): MistakeInfo[];
getEvents(): TypingEvent[];
getCurrentIndex(): number;
isCompleted(): boolean;
isTyping(): boolean;
isPaused(): boolean;
getTotalDuration(): number;
onStateChangeListener(callback: (state: TypingState) => void): void;
onCharacterListener(callback: (char: string, index: number) => void): void;
onMistakeListener(callback: (mistake: MistakeInfo) => void): void;
onBackspaceListener(callback: () => void): void;
onCompleteListener(callback: () => void): void;
onProgressListener(callback: (progress: number) => void): void;
onKeyListener(callback: (keyInfo: KeyInfo) => void): void;
updateConfig(newConfig: Partial<HumanLikeConfig>): void;
updateText(newText: string): void;
getUncorrectedMistakes(): MistakeInfo[];
getCorrectionQueue(): MistakeInfo[];
forceCorrectAllMistakes(): void;
}
//# sourceMappingURL=TypingEngine.d.ts.map