import { Keyboard } from './types/keyboard.js'; import { ConstructorTypingOptions, CustomUpdateSetup, EraseTypingOptions, FactoryTypingOptions, NamedPartEntry, SentanceTypingOptions, WaitTypingOptions } from './types/options.js'; export declare class Typed { private readonly _setupUpdater?; /** * Creates a factory function that can be used to create Typed instances with a custom setup. * This is useful if you do not want to rely on a callback function to update the text, but rather on a different data structure. * @param customOptions The custom setup options. * @returns A factory function that can be used to create Typed instances with a custom setup. * @example * ```ts * const typedFactory = Typed.factory({ * setUp: () => new BehaviorSubject(''), * update: (textSubj, text) => textSubj.next(text) * }); * // Create a new Typed instance with the custom setup * const typed = typedFactory({ * // some options * }); * // access the text BehaviorSubject * typed.text.subscribe(text => console.log(text)); * ``` */ static factory(customOptions: CustomUpdateSetup): (options?: FactoryTypingOptions) => Typed; /** * Returns the text data structure that was configured using the factory function. * @throws If the factory function was not used to create this instance. */ get text(): Updater; private readonly _resetter; private readonly _randomChars; private readonly _options; private readonly _typeQueue; private readonly _ffQueue; private _queue; private _resultItems; private _fastForward; private _lettersSinceLastError; private readonly _endResultItems; private readonly _fastForwardOptions; constructor(options: ConstructorTypingOptions); private getOptions; /** * Adds a new keyboard layout to the list of available keyboards. * @param locale The locale of the keyboard layout. * @param keyboard The keyboard layout. * @example * ``` * typed.addKeyboard('de', { * lower: ['1234567890ß', 'qwertzuiopü+', 'asdfghjklöä#', 'yxcvbnm,.-', ' '], * upper: ['!"§$%&/()=?', 'QWERTZUIOPÜ*', "ASDFGHJKLÖÄ'", 'YXCVBNM;:_', ' '] * }); * ``` * More info [here](https://github.com/LoaderB0T/typed.ts#Add-your-own-keyboard-layouts) */ addKeyboard(locale: string, keyboard: Keyboard): void; /** * Stops the current animation. * @param clearTexts Whether to clear the texts or not. * @returns A promise that resolves when the animation has stopped and can be started again. */ reset(clearTexts?: boolean): Promise; /** * Adds a string that will be typed out to the end of the queue. * @param sentance The string to type out. * @param options The options for typing. * @returns The Typed instance. */ type>(sentance: string, options?: SentanceTypingOptions): Typed; /** * Adds the deletion of a number of letters to the end of the queue. * @param length The number of letters to delete. * @param options The options for erasing. * @returns The Typed instance. */ backspace>(length: number, options?: EraseTypingOptions): Typed; /** * Adds a delay to the end of the queue. * @param delay The delay in milliseconds. * @returns The Typed instance. */ wait>(delay: number, options?: WaitTypingOptions): Typed; /** * Runs the configured animation (queue). * @returns A promise that resolves when the animation has finished. */ run(): Promise; /** * Fast forwards the current animation. Skipping all delays and only typing characters that are relevant for the end result. * @returns A promise that resolves when the animation has finished. */ fastForward(): void; private ff; private getTextAtIndex; private doSingleAction; private doQueueActionForPart; private doQueueAction; private typeLetter; private typeBackspace; private waitItem; private incrementQueue; private shouldError; private maybeDoError; private calculateErrorProbability; private addLetter; private addLetterTo; private deleteLetter; private deleteLetterFrom; private updateText; private getPartText; private getCurrentText; }