@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/vitest.setup.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest'
|
|
2
|
-
import '@testing-library/jest-dom/vitest'
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(global, 'navigator', {
|
|
5
|
-
value: { userAgent: 'node.js' },
|
|
6
|
-
writable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
})
|
|
9
|
-
global.PermissionStatus = vi.fn(function () {
|
|
10
|
-
return {
|
|
11
|
-
state: 'granted',
|
|
12
|
-
addEventListener: vi.fn(),
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
global.Permissions = vi.fn(function () {
|
|
16
|
-
return {
|
|
17
|
-
query: vi.fn().mockResolvedValue(new PermissionStatus()),
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
Object.defineProperty(global.navigator, 'permissions', {
|
|
21
|
-
value: new Permissions(),
|
|
22
|
-
writable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
})
|
|
25
|
-
global.MediaDevices = vi.fn(function () {
|
|
26
|
-
return {
|
|
27
|
-
getUserMedia: vi.fn().mockResolvedValue('foo'),
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
Object.defineProperty(global.navigator, 'mediaDevices', {
|
|
31
|
-
value: new MediaDevices(),
|
|
32
|
-
writable: true,
|
|
33
|
-
configurable: true,
|
|
34
|
-
})
|
|
35
|
-
global.SpeechGrammarList = vi.fn(function () {
|
|
36
|
-
return {
|
|
37
|
-
length: 0,
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
global.SpeechRecognition = vi.fn(function () {
|
|
41
|
-
const handlers = {}
|
|
42
|
-
let accumulatedResults = []
|
|
43
|
-
return {
|
|
44
|
-
addEventListener: vi.fn(function (type, callback) {
|
|
45
|
-
handlers[type] = callback
|
|
46
|
-
}),
|
|
47
|
-
removeEventListener: vi.fn(),
|
|
48
|
-
dispatchEvent: vi.fn(),
|
|
49
|
-
start: vi.fn(function () {
|
|
50
|
-
accumulatedResults = []
|
|
51
|
-
handlers.start?.()
|
|
52
|
-
}),
|
|
53
|
-
stop: vi.fn(function () {
|
|
54
|
-
handlers.end?.()
|
|
55
|
-
}),
|
|
56
|
-
abort: vi.fn(function () {
|
|
57
|
-
handlers.end?.()
|
|
58
|
-
}),
|
|
59
|
-
say: vi.fn(function (input) {
|
|
60
|
-
handlers.speechstart?.()
|
|
61
|
-
|
|
62
|
-
const newSegments = Array.isArray(input) ? input : input ? [[{ transcript: input }]] : []
|
|
63
|
-
const resultIndex = accumulatedResults.length
|
|
64
|
-
accumulatedResults = [...accumulatedResults, ...newSegments]
|
|
65
|
-
|
|
66
|
-
const resultEvent = new Event('result')
|
|
67
|
-
resultEvent.resultIndex = resultIndex
|
|
68
|
-
resultEvent.results = accumulatedResults
|
|
69
|
-
handlers.speechend?.()
|
|
70
|
-
if (input) {
|
|
71
|
-
handlers.result?.(resultEvent)
|
|
72
|
-
} else {
|
|
73
|
-
handlers.nomatch?.()
|
|
74
|
-
}
|
|
75
|
-
}),
|
|
76
|
-
end: vi.fn(function () {
|
|
77
|
-
handlers.end?.()
|
|
78
|
-
}),
|
|
79
|
-
error: vi.fn(function (err) {
|
|
80
|
-
handlers.error?.(err)
|
|
81
|
-
}),
|
|
82
|
-
}
|
|
83
|
-
})
|