@molecule/app-audio-recorder-react 1.0.0 → 1.0.2
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/README.md +174 -0
- package/package.json +17 -10
package/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-08-04T01:50:04.657Z
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# @molecule/app-audio-recorder-react
|
|
10
|
+
|
|
11
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
+
|
|
15
|
+
Mic-permission + MediaRecorder UI primitive — emits a `Blob` once the
|
|
16
|
+
user finishes recording. Pure browser API; no upload, no transcription.
|
|
17
|
+
|
|
18
|
+
Used by AI-voice-assistant, AI-meeting-notes (manual capture), and
|
|
19
|
+
AI-customer-service-bot. Wire to any backend by handling `onRecorded`.
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { AudioRecorder } from '@molecule/app-audio-recorder-react'
|
|
25
|
+
|
|
26
|
+
;<AudioRecorder
|
|
27
|
+
maxDurationSeconds={300}
|
|
28
|
+
onRecorded={({ blob, mimeType, durationSeconds }) => {
|
|
29
|
+
console.log(`Captured ${durationSeconds}s of ${mimeType}`)
|
|
30
|
+
uploadVoiceNote(blob)
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Type
|
|
36
|
+
|
|
37
|
+
`feature`
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @molecule/app-audio-recorder-react @molecule/app-i18n @molecule/app-react @molecule/app-ui react
|
|
43
|
+
npm install -D @types/react
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
### Interfaces
|
|
49
|
+
|
|
50
|
+
#### `AudioRecorderProps`
|
|
51
|
+
|
|
52
|
+
Props for {@link AudioRecorder}.
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
interface AudioRecorderProps {
|
|
56
|
+
/**
|
|
57
|
+
* Called once the user stops recording and a Blob is ready. Parents are
|
|
58
|
+
* responsible for uploading or persisting the blob.
|
|
59
|
+
*/
|
|
60
|
+
onRecorded: (rec: AudioRecording) => void
|
|
61
|
+
/**
|
|
62
|
+
* Called whenever a recording error occurs (permission denied, no
|
|
63
|
+
* MediaRecorder support, hardware failure). Optional — the component
|
|
64
|
+
* surfaces a translated error message regardless.
|
|
65
|
+
*/
|
|
66
|
+
onError?: (err: Error) => void
|
|
67
|
+
/**
|
|
68
|
+
* Optional MIME type to request from MediaRecorder. Falls back to the
|
|
69
|
+
* browser's default if unsupported. Common values: `'audio/webm'`,
|
|
70
|
+
* `'audio/mp4'`, `'audio/ogg;codecs=opus'`.
|
|
71
|
+
*/
|
|
72
|
+
mimeType?: string
|
|
73
|
+
/**
|
|
74
|
+
* Maximum recording duration (seconds). When reached, recording stops
|
|
75
|
+
* automatically and `onRecorded` fires. `0` (default) means unlimited.
|
|
76
|
+
*/
|
|
77
|
+
maxDurationSeconds?: number
|
|
78
|
+
/** `data-mol-id` attribute for AI-agent selectors. */
|
|
79
|
+
dataMolId?: string
|
|
80
|
+
/** Extra classes appended via the ClassMap `cn()` helper. */
|
|
81
|
+
className?: string
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### `AudioRecording`
|
|
86
|
+
|
|
87
|
+
Result emitted via `onRecorded` once a recording finishes.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
interface AudioRecording {
|
|
91
|
+
/** The captured audio as a `Blob`. */
|
|
92
|
+
blob: Blob
|
|
93
|
+
/** Audio MIME type (e.g. `'audio/webm'`). */
|
|
94
|
+
mimeType: string
|
|
95
|
+
/** Recording duration in seconds (whole-second precision). */
|
|
96
|
+
durationSeconds: number
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Types
|
|
101
|
+
|
|
102
|
+
#### `AudioRecorderState`
|
|
103
|
+
|
|
104
|
+
Recorder lifecycle states.
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
type AudioRecorderState = 'idle' | 'recording' | 'paused' | 'processed' | 'error'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Functions
|
|
111
|
+
|
|
112
|
+
#### `AudioRecorder(props)`
|
|
113
|
+
|
|
114
|
+
Mic-permission + MediaRecorder UI primitive — emits a `Blob` once the user
|
|
115
|
+
finishes recording. Pure browser API; no upload, no transcription. Wire to
|
|
116
|
+
any backend by listening to `onRecorded` and POST-ing the blob.
|
|
117
|
+
|
|
118
|
+
Renders a status badge, an elapsed-time readout, and three buttons:
|
|
119
|
+
Record (idle/processed) → Pause/Resume + Stop (recording/paused).
|
|
120
|
+
All button labels and status text flow through `t()` with English
|
|
121
|
+
`defaultValue` fallbacks; drop in a companion locale bond to translate.
|
|
122
|
+
|
|
123
|
+
Styling is delegated to `getClassMap()` — no Tailwind / raw class names.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
function AudioRecorder({
|
|
127
|
+
onRecorded,
|
|
128
|
+
onError,
|
|
129
|
+
mimeType,
|
|
130
|
+
maxDurationSeconds = 0,
|
|
131
|
+
dataMolId,
|
|
132
|
+
className,
|
|
133
|
+
}: AudioRecorderProps): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- `props` — Component props.
|
|
137
|
+
|
|
138
|
+
**Returns:** The rendered recorder element.
|
|
139
|
+
|
|
140
|
+
## Injection Notes
|
|
141
|
+
|
|
142
|
+
### Requirements
|
|
143
|
+
|
|
144
|
+
Peer dependencies:
|
|
145
|
+
|
|
146
|
+
- `@molecule/app-i18n` ^1.0.1
|
|
147
|
+
- `@molecule/app-react` ^1.0.1
|
|
148
|
+
- `@molecule/app-ui` ^1.0.1
|
|
149
|
+
- `react` ^18.0.0 || ^19.0.0
|
|
150
|
+
|
|
151
|
+
### Runtime Dependencies
|
|
152
|
+
|
|
153
|
+
- `@molecule/app-i18n`
|
|
154
|
+
- `@molecule/app-react`
|
|
155
|
+
- `@molecule/app-ui`
|
|
156
|
+
- `react`
|
|
157
|
+
|
|
158
|
+
`getUserMedia` only exists in a secure context — the recorder works on
|
|
159
|
+
`https://` and `localhost`, and permanently shows the error state on
|
|
160
|
+
plain HTTP. The requested `mimeType` is best-effort: unsupported types
|
|
161
|
+
silently fall back to the browser default (the actual type is reported
|
|
162
|
+
in `onRecorded`). Reaching `maxDurationSeconds` auto-stops and still
|
|
163
|
+
fires `onRecorded`. The recording dot's pulse uses a `mol-pulse` CSS
|
|
164
|
+
animation shipped in the molecule base stylesheet
|
|
165
|
+
(`@molecule/app-ui-tailwind`'s `base.css`, loaded by every molecule app),
|
|
166
|
+
so the dot animates out of the box; a host that does not load that
|
|
167
|
+
stylesheet can define `@keyframes mol-pulse { 50% { opacity: .4 } }`
|
|
168
|
+
itself (without it the dot is static but recording still works).
|
|
169
|
+
Translations come from the companion
|
|
170
|
+
`@molecule/app-locales-audio-recorder` locale bond.
|
|
171
|
+
|
|
172
|
+
## Translations
|
|
173
|
+
|
|
174
|
+
Translation strings are provided by `@molecule/app-locales-audio-recorder`.
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-audio-recorder-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Mic permission + MediaRecorder wrapper that emits a Blob — voice notes, meeting capture, AI voice agents",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/app-audio-recorder-react",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "dist/index.js",
|
|
7
8
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +18,8 @@
|
|
|
17
18
|
}
|
|
18
19
|
},
|
|
19
20
|
"files": [
|
|
20
|
-
"dist"
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
21
23
|
],
|
|
22
24
|
"keywords": [
|
|
23
25
|
"molecule",
|
|
@@ -27,17 +29,22 @@
|
|
|
27
29
|
"react"
|
|
28
30
|
],
|
|
29
31
|
"license": "Apache-2.0",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
35
|
+
"directory": "packages/app/features/audio-recorder-react"
|
|
36
|
+
},
|
|
30
37
|
"peerDependencies": {
|
|
31
|
-
"@molecule/app-i18n": "^1.0.
|
|
32
|
-
"@molecule/app-react": "^1.0.
|
|
33
|
-
"@molecule/app-ui": "^1.0.
|
|
38
|
+
"@molecule/app-i18n": "^1.0.1",
|
|
39
|
+
"@molecule/app-react": "^1.0.1",
|
|
40
|
+
"@molecule/app-ui": "^1.0.1",
|
|
34
41
|
"react": "^18.0.0 || ^19.0.0"
|
|
35
42
|
},
|
|
36
43
|
"devDependencies": {
|
|
37
|
-
"@molecule/app-i18n": "1.0.
|
|
38
|
-
"@molecule/app-react": "1.
|
|
39
|
-
"@molecule/app-ui": "1.
|
|
40
|
-
"@molecule/app-ui-tailwind": "1.
|
|
44
|
+
"@molecule/app-i18n": "1.0.2",
|
|
45
|
+
"@molecule/app-react": "1.5.1",
|
|
46
|
+
"@molecule/app-ui": "1.1.1",
|
|
47
|
+
"@molecule/app-ui-tailwind": "1.1.3",
|
|
41
48
|
"@testing-library/dom": "10.4.1",
|
|
42
49
|
"@testing-library/react": "16.3.2",
|
|
43
50
|
"@types/node": "26.1.2",
|
|
@@ -47,6 +54,6 @@
|
|
|
47
54
|
"react": "19.2.8",
|
|
48
55
|
"react-dom": "19.2.8",
|
|
49
56
|
"typescript": "6.0.3",
|
|
50
|
-
"vitest": "4.1.
|
|
57
|
+
"vitest": "4.1.11"
|
|
51
58
|
}
|
|
52
59
|
}
|