-
TypeScript types included β Full type definitions ship with the package.
addCallbackenforces correct callback signatures per event type. -
ESM/CJS/IIFE module support β Works with
import,require(), and<script>tags. -
getState()method β Returns'idle','listening', or'paused'. -
stateproperty (on default export) β Getter that returns the current state. -
addCallbackreturns an unsubscribe function β Previously returnedundefined. Now returns a function you can call to remove that specific callback:const unsub = annyang.addCallback('start', myFunc); unsub(); // removes myFunc from 'start' callbacks
-
trigger()works independently of speech recognition βtrigger()can now be used regardless of whether annyang is listening, paused, aborted, or even in browsers that don't support speech recognition. If you need the previous behavior, checkisListening()before callingtrigger()or within the triggered command's callback. -
Safe to use in unsupported browsers β Methods like
start(),addCommands(), andsetLanguage()no longer throw when SpeechRecognition is unavailable. Speech recognition simply won't activate, but command registration andtrigger()still work. -
if (annyang)no longer detects browser support β Starting in v3, the annyang object is always defined. Useannyang.isSpeechRecognitionSupported()instead:// v2 if (annyang) { annyang.start(); } // v3 if (annyang.isSpeechRecognitionSupported()) { annyang.start(); }
-
init()deprecated β annyang initializes automatically when needed. Callinginit()now logs a deprecation warning. Remove any calls toinit(). -
String-based command callbacks removed β Passing function names as strings (e.g.
{'hello': 'myFunc'}) is no longer supported. Pass functions directly:{'hello': myFunc}. -
Duplicate command phrases now overwrite β In v2, adding a command with the same phrase would register both callbacks. In v3, the new callback replaces the old one.
- Switched bundler from Rollup to tsup
- Migrated source to TypeScript with strict mode
- Tests migrated to Vitest
parseResultsrefactored to usefor...ofwith early return