import {AbsDictation} from 'scriptable-abstract'; interface DictationState { lastText: string | null; lastError: Error | null; } /** * Mock implementation of Scriptable's Dictation global variable * Provides functionality for speech-to-text conversion * * @implements Dictation */ export class MockDictation extends AbsDictation { static get instance(): MockDictation { return super.instance as MockDictation; } constructor() { super({ lastText: null, lastError: null, }); } /** * @inheritdoc */ async start(): Promise { const text = 'Sample dictated text'; this.setState({ lastText: text, lastError: null, }); return text; } /** * @additional * Get the last dictated text */ getLastText(): string | null { return this.state.lastText; } /** * @additional * Get the last error if any */ getLastError(): Error | null { return this.state.lastError; } /** * @additional * Clear dictation history */ clear(): void { this.setState({ lastText: null, lastError: null, }); } }