@untemps/react-vocal 2.0.0-beta.6 → 2.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +23 -5
- package/dist/index.es.js +233 -759
- package/dist/index.js +2 -4
- package/package.json +7 -6
- package/.github/workflows/publish.yml +0 -32
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.prettierignore +0 -3
- package/.prettierrc +0 -29
- package/CLAUDE.md +0 -59
- package/assets/icon-idle.png +0 -0
- package/assets/icon-listening.png +0 -0
- package/assets/microphone.png +0 -0
- package/assets/react-vocal.png +0 -0
- package/commitlint.config.js +0 -7
- package/dev/index.html +0 -24
- package/dev/package.json +0 -18
- package/dev/public/index.html +0 -24
- package/dev/src/index.jsx +0 -66
- package/dev/vite.config.js +0 -10
- package/dev/yarn.lock +0 -325
- package/dist/index.es.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.umd.js +0 -9
- package/dist/index.umd.js.map +0 -1
- package/src/components/Icon.jsx +0 -24
- package/src/components/Vocal.jsx +0 -261
- package/src/components/__tests__/Icon.test.jsx +0 -38
- package/src/components/__tests__/Vocal.test.jsx +0 -748
- package/src/components/__tests__/VocalWithMockedUseVocal.test.jsx +0 -38
- package/src/components/__tests__/__snapshots__/Icon.test.jsx.snap +0 -21
- package/src/components/__tests__/__snapshots__/Vocal.test.jsx.snap +0 -28
- package/src/hooks/__tests__/useCommands.test.js +0 -115
- package/src/hooks/__tests__/useTimeout.test.js +0 -69
- package/src/hooks/__tests__/useVocal.test.js +0 -207
- package/src/hooks/useCommands.js +0 -75
- package/src/hooks/useTimeout.js +0 -21
- package/src/hooks/useVocal.js +0 -56
- package/src/index.js +0 -7
- package/vite.config.js +0 -36
- package/vitest.setup.js +0 -83
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
# [2.0.0-beta.8](https://github.com/untemps/react-vocal/compare/v2.0.0-beta.7...v2.0.0-beta.8) (2026-05-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Migrate to @untemps/vocal 2.x functional API ([#146](https://github.com/untemps/react-vocal/issues/146)) ([582575f](https://github.com/untemps/react-vocal/commit/582575f391472e0e95b0c793b57c7c3edca71939))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* `isSupported` is now a function instead of a boolean snapshot. Consumers must call it as `isSupported()`.
|
|
12
|
+
Migration:
|
|
13
|
+
// before
|
|
14
|
+
import { isSupported } from '@untemps/react-vocal'
|
|
15
|
+
if (isSupported) { ... }
|
|
16
|
+
// after
|
|
17
|
+
import { isSupported } from '@untemps/react-vocal'
|
|
18
|
+
if (isSupported()) { ... }
|
|
19
|
+
The function form is SSR-safe — it returns `false` when `window` is undefined, so consumers no longer need a manual `typeof window` guard before checking support.
|
|
20
|
+
* UMD bundle is no longer published.
|
|
21
|
+
`dist/index.umd.js` is removed from the release artifacts and from the npm tarball. Consumers loading react-vocal via `<script src="…/dist/index.umd.js">` or an AMD loader must migrate to the ES bundle (`dist/index.es.js`) via a module-aware loader (or use a bundler). The CJS bundle (`dist/index.js`) remains available for Node-style require().
|
|
22
|
+
|
|
23
|
+
# [2.0.0-beta.7](https://github.com/untemps/react-vocal/compare/v2.0.0-beta.6...v2.0.0-beta.7) (2026-05-13)
|
|
24
|
+
|
|
1
25
|
# [2.0.0-beta.6](https://github.com/untemps/react-vocal/compare/v2.0.0-beta.5...v2.0.0-beta.6) (2026-05-12)
|
|
2
26
|
|
|
3
27
|
|
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ timeout elapses.
|
|
|
33
33
|
Some browsers supports the `SpeechRecognition` API but not all the related APIs.
|
|
34
34
|
For example, browsers on iOS 14.5, the `SpeechGrammar` and `SpeechGrammarList` and `Permissions` APIs are not supported.
|
|
35
35
|
|
|
36
|
-
Although the lack of `SpeechGrammar` and `SpeechGrammarList` is handled by the
|
|
36
|
+
Although the lack of `SpeechGrammar` and `SpeechGrammarList` is handled by the underlying `@untemps/vocal` library, you need to deal with `Permissions` by yourself.
|
|
37
37
|
|
|
38
38
|
## Requirements
|
|
39
39
|
|
|
@@ -237,6 +237,7 @@ fuse.js is an optional peer dependency — install it separately to enable fuzzy
|
|
|
237
237
|
| onResult | func | null | Handler called when a result is recognized |
|
|
238
238
|
| onError | func | null | Handler called when an error occurs |
|
|
239
239
|
| onNoMatch | func | null | Handler called when no result can be recognized |
|
|
240
|
+
| signal | AbortSignal | null | Optional `AbortSignal` propagated to the underlying `start()` call. Aborting it cancels the in-flight start (e.g. while waiting for microphone permission). |
|
|
240
241
|
|
|
241
242
|
### `useVocal` hook
|
|
242
243
|
|
|
@@ -315,28 +316,45 @@ useVocal(lang, grammars, maxAlternatives, continuous)
|
|
|
315
316
|
#### Return value
|
|
316
317
|
|
|
317
318
|
```
|
|
318
|
-
const [ref, { start, stop, abort, subscribe, unsubscribe, clean }]
|
|
319
|
+
const [ref, { start, stop, abort, subscribe, unsubscribe, clean, isRecording }]
|
|
319
320
|
```
|
|
320
321
|
|
|
321
322
|
| Args | Type | Description |
|
|
322
323
|
| ----------- | ---- | ---------------------------------------------------- |
|
|
323
|
-
| ref | Ref | React ref to the
|
|
324
|
-
| start | func | Function to start the recognition
|
|
324
|
+
| ref | Ref | React ref to the underlying `@untemps/vocal` instance |
|
|
325
|
+
| start | func | Function to start the recognition. Accepts an optional `{ signal }` argument — an `AbortSignal` propagated to the underlying `start()` call. Returns the underlying `vocal.start()` promise (resolves once the session starts, rejects on microphone/permission errors). |
|
|
325
326
|
| stop | func | Function to stop the recognition |
|
|
326
327
|
| abort | func | Function to abort the recognition |
|
|
327
328
|
| subscribe | func | Function to subscribe to recognition events |
|
|
328
329
|
| unsubscribe | func | Function to unsubscribe to recognition events |
|
|
329
330
|
| clean | func | Function to clean subscription to recognition events |
|
|
331
|
+
| isRecording | bool | Reactive flag mirroring whether a session is active. `true` between `start()` and the next `end`/`error` event. Updated optimistically on `start()` so the UI re-renders at click time. |
|
|
332
|
+
|
|
333
|
+
#### Cancelling a start in flight
|
|
334
|
+
|
|
335
|
+
Both `<Vocal signal={...}>` and `useVocal().start({ signal })` accept an `AbortSignal`. Aborting the controller while the browser is still resolving microphone permission cancels the start cleanly — no `start` event is dispatched.
|
|
336
|
+
|
|
337
|
+
```javascript
|
|
338
|
+
const controller = new AbortController()
|
|
339
|
+
|
|
340
|
+
// Cancel pending recognition after 2s of waiting for permission
|
|
341
|
+
setTimeout(() => controller.abort(), 2000)
|
|
342
|
+
|
|
343
|
+
const [, { start }] = useVocal('en-US')
|
|
344
|
+
start({ signal: controller.signal })
|
|
345
|
+
```
|
|
330
346
|
|
|
331
347
|
### Browser support flag
|
|
332
348
|
|
|
333
349
|
#### Basic usage
|
|
334
350
|
|
|
351
|
+
`isSupported` is a function that returns `true` when the browser supports the Web Speech API (along with the Permissions and MediaDevices APIs that `@untemps/vocal` relies on). It is safe to call during server-side rendering — it returns `false` when `window` is undefined.
|
|
352
|
+
|
|
335
353
|
```javascript
|
|
336
354
|
import Vocal, { isSupported } from '@untemps/react-vocal'
|
|
337
355
|
|
|
338
356
|
const App = () => {
|
|
339
|
-
return isSupported ? <Vocal /> : <p>Your browser does not support Web Speech API</p>
|
|
357
|
+
return isSupported() ? <Vocal /> : <p>Your browser does not support Web Speech API</p>
|
|
340
358
|
}
|
|
341
359
|
```
|
|
342
360
|
|