/* * Copyright 2026 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ // Ambient declarations for parts of the Web Speech API missing from TypeScript's // lib.dom.d.ts: the recognizer constructor, its vendor-prefixed alias, event // types, and the User-Agent Client Hints surface used for the Chromium browser // allowlist. SpeechRecognitionAlternative, SpeechRecognitionResult, and // SpeechRecognitionResultList ARE provided by lib.dom and are not redeclared. // Spec: https://wicg.github.io/speech-api/ type SpeechRecognitionErrorCode = | 'no-speech' | 'aborted' | 'audio-capture' | 'network' | 'not-allowed' | 'service-not-allowed' | 'language-not-supported' | 'phrases-not-supported'; interface SpeechRecognitionEvent extends Event { readonly resultIndex: number; readonly results: SpeechRecognitionResultList; } interface SpeechRecognitionErrorEvent extends Event { readonly error: SpeechRecognitionErrorCode; readonly message: string; } interface SpeechRecognition extends EventTarget { lang: string; continuous: boolean; interimResults: boolean; maxAlternatives: number; start(): void; stop(): void; abort(): void; onaudiostart: ((this: SpeechRecognition, ev: Event) => void) | null; onsoundstart: ((this: SpeechRecognition, ev: Event) => void) | null; onspeechstart: ((this: SpeechRecognition, ev: Event) => void) | null; onspeechend: ((this: SpeechRecognition, ev: Event) => void) | null; onsoundend: ((this: SpeechRecognition, ev: Event) => void) | null; onaudioend: ((this: SpeechRecognition, ev: Event) => void) | null; onresult: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => void) | null; onnomatch: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => void) | null; onerror: ((this: SpeechRecognition, ev: SpeechRecognitionErrorEvent) => void) | null; onstart: ((this: SpeechRecognition, ev: Event) => void) | null; onend: ((this: SpeechRecognition, ev: Event) => void) | null; } interface SpeechRecognitionConstructor { new (): SpeechRecognition; } interface Window { SpeechRecognition?: SpeechRecognitionConstructor; webkitSpeechRecognition?: SpeechRecognitionConstructor; } // User-Agent Client Hints — present in Chromium, absent in Safari/Firefox. interface NavigatorUABrandVersion { readonly brand: string; readonly version: string; } interface NavigatorUAData { readonly brands: ReadonlyArray; readonly platform?: string; } interface Navigator { readonly userAgentData?: NavigatorUAData; }