MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getRecognitionCtor

Function getRecognitionCtor

packages/@react-spectrum/ai/src/useVoiceInput.ts:65–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63
64/** Resolves the recognizer constructor, applying the Chromium brand allowlist. */
65const getRecognitionCtor = (): SpeechRecognitionConstructor | null => {
66 if (typeof window === 'undefined') {
67 return null;
68 }
69 const ctor = window.SpeechRecognition ?? window.webkitSpeechRecognition ?? null;
70 if (!ctor) {
71 return null;
72 }
73 const brands = navigator.userAgentData?.brands;
74 if (brands && !brands.some(b => VOICE_INPUT_CHROMIUM_BROWSERS.has(b.brand))) {
75 return null;
76 }
77 return ctor;
78};
79
80/** SpeechRecognition requires a secure context (HTTPS / localhost). */
81const isSecureVoiceContext = (): boolean =>

Callers 1

useVoiceInputFunction · 0.85

Calls 1

hasMethod · 0.65

Tested by

no test coverage detected