UNPKG

scriptable-testlab

Version:

A lightweight, efficient tool designed to manage and update scripts for Scriptable.

65 lines (57 loc) 1.15 kB
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<DictationState> { static get instance(): MockDictation { return super.instance as MockDictation; } constructor() { super({ lastText: null, lastError: null, }); } /** * @inheritdoc */ async start(): Promise<string> { 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, }); } }