@vidtreo/recorder 1.4.0 → 1.5.0

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.
Files changed (4) hide show
  1. package/README.md +137 -14
  2. package/dist/index.d.ts +2484 -2138
  3. package/dist/index.js +1739 -308
  4. package/package.json +2 -1
package/README.md CHANGED
@@ -58,6 +58,7 @@ Creates a new recorder instance with the specified configuration.
58
58
  - `config.onUploadComplete` (optional): Callback invoked when upload completes successfully
59
59
  - `config.onUploadProgress` (optional): Callback invoked during upload with progress value (0-1)
60
60
  - `config.onUploadError` (optional): Callback invoked when upload fails
61
+ - `config.onAudioWarning` (optional): Callback invoked when an audio issue is detected during recording. Receives an `AudioWarning` object. See [Audio Warnings](#audio-warnings) for details
61
62
  - `config.onRecordingStart` (optional): Callback invoked when recording starts
62
63
  - `config.onRecordingStop` (optional): Callback invoked when recording stops
63
64
  - `config.onError` (optional): Callback invoked when a stream error occurs
@@ -218,6 +219,7 @@ interface VidtreoRecorderConfig {
218
219
  onUploadError?: (error: Error) => void;
219
220
  onRecordingStart?: () => void;
220
221
  onRecordingStop?: () => void;
222
+ onAudioWarning?: (warning: AudioWarning) => void;
221
223
  onError?: (error: Error) => void;
222
224
  }
223
225
  ```
@@ -267,6 +269,17 @@ interface AvailableDevices {
267
269
  }
268
270
  ```
269
271
 
272
+ ### AudioWarning
273
+
274
+ ```typescript
275
+ type AudioWarning =
276
+ | { code: 'audio.no-signal'; durationMs: number }
277
+ | { code: 'audio.no-chunks'; durationMs: number }
278
+ | { code: 'audio.low-signal'; peak: number; rms: number }
279
+ | { code: 'audio.track-ended' }
280
+ | { code: 'audio.track-muted-by-browser' };
281
+ ```
282
+
270
283
  ### CameraConstraints
271
284
 
272
285
  ```typescript
@@ -277,6 +290,112 @@ interface CameraConstraints {
277
290
  }
278
291
  ```
279
292
 
293
+ ## User-Facing Messages
294
+
295
+ The SDK emits structured events for common issues. Your app should listen and display appropriate UX for each.
296
+
297
+ ### Audio Warnings
298
+
299
+ Set `onAudioWarning` in the constructor config. Each warning fires **once per recording session** (deduped by code). Use these to show real-time feedback to the user.
300
+
301
+ | Code | Meaning | Suggested UX |
302
+ |------|---------|-------------|
303
+ | `audio.no-signal` | Mic is producing silence for an extended period. `durationMs` indicates how long. | "Microphone not detected. Check your mic is plugged in and selected." |
304
+ | `audio.no-chunks` | No audio data received from the microphone for an extended period. `durationMs` indicates how long. | "No microphone input. Check microphone permissions and connection." |
305
+ | `audio.low-signal` | Audio level is very low. `peak` and `rms` contain measured levels (0–1 range). | "Audio is very quiet. Speak louder or move closer to the microphone." |
306
+ | `audio.track-ended` | The audio track ended unexpectedly (device disconnected or revoked). | "Microphone disconnected. Reconnect and restart recording." |
307
+ | `audio.track-muted-by-browser` | Browser muted the track automatically (e.g., browser-level mute or policy). | "Microphone muted by browser. Check browser mic settings." |
308
+
309
+ Example:
310
+
311
+ ```typescript
312
+ const recorder = new VidtreoRecorder({
313
+ apiKey: 'your-api-key',
314
+ onAudioWarning: (warning) => {
315
+ switch (warning.code) {
316
+ case 'audio.no-signal':
317
+ case 'audio.no-chunks':
318
+ showToast('No microphone input detected. Check your mic.');
319
+ break;
320
+ case 'audio.low-signal':
321
+ showToast('Audio is very quiet. Speak louder or check your mic.');
322
+ break;
323
+ case 'audio.track-ended':
324
+ showToast('Microphone disconnected. Reconnect and try again.');
325
+ break;
326
+ case 'audio.track-muted-by-browser':
327
+ showToast('Microphone muted by browser. Check browser settings.');
328
+ break;
329
+ }
330
+ },
331
+ });
332
+ ```
333
+
334
+ ### No Video Signal
335
+
336
+ The SDK emits an error via `onError` when no video frames arrive from the camera:
337
+
338
+ - Error message contains `video-first-frame-timeout`
339
+ - Cause: camera in use by another app, camera permission revoked, or hardware failure
340
+ - Suggested UX: "Camera not responding. Close other apps using the camera and try again."
341
+
342
+ ```typescript
343
+ const recorder = new VidtreoRecorder({
344
+ apiKey: 'your-api-key',
345
+ onError: (error) => {
346
+ if (error.message.includes('video-first-frame-timeout')) {
347
+ showToast('Camera not responding. Close other apps using the camera.');
348
+ }
349
+ },
350
+ });
351
+ ```
352
+
353
+ ### Storage Restricted
354
+
355
+ Storage issues surface in two ways:
356
+
357
+ 1. **Quota exceeded** during upload queue write: error message contains `Storage quota exceeded`. Suggested UX: "Device storage is full. Free up space to save recordings."
358
+ 2. **Proactive quota check** via `QuotaManager` (exported from this package):
359
+
360
+ ```typescript
361
+ import { QuotaManager } from '@vidtreo/recorder';
362
+
363
+ const quotaManager = new QuotaManager();
364
+ const quota = await quotaManager.getQuota();
365
+
366
+ if (await quotaManager.shouldWarn()) {
367
+ showToast(`Storage usage at ${Math.round(quota.percentage)}%. Free up space.`);
368
+ }
369
+
370
+ if (await quotaManager.isCritical()) {
371
+ showToast('Storage critically low. Recording may fail to save.');
372
+ }
373
+ ```
374
+
375
+ - `shouldWarn()` triggers at 80% usage (configurable threshold)
376
+ - `isCritical()` triggers at 95% usage (configurable threshold)
377
+
378
+ ### Unsupported Browser
379
+
380
+ Use `validateBrowserSupport()` before initializing the recorder:
381
+
382
+ ```typescript
383
+ import { validateBrowserSupport } from '@vidtreo/recorder';
384
+
385
+ try {
386
+ validateBrowserSupport();
387
+ } catch (error) {
388
+ // error.code === 'browser.unsupported'
389
+ // error.browserName — detected browser name
390
+ // error.browserVersion — detected version
391
+ // error.missingCapabilities — list of missing APIs
392
+ // error.resolutionStage — 'policy' (known unsupported) or 'feature-preflight' (missing API)
393
+ showToast('Your browser is not supported. Use Chrome, Edge, or Safari 26+.');
394
+ }
395
+ ```
396
+
397
+ For richer error text, use `getBrowserErrorText()` and `getCameraErrorText()` from `@vidtreo/recorder` with your own translations (see exported types `AudioErrorTranslations`, `BrowserErrorLinkContent`).
398
+
280
399
  ## Usage Examples
281
400
 
282
401
  ### Basic Recording Workflow
@@ -824,14 +943,12 @@ The following browsers support all features including real-time MP4 transcoding:
824
943
  - **Opera 80+** - Full support, Chromium-based
825
944
  - **Brave 1.30+** - Full support, Chromium-based
826
945
  - **Vivaldi 5.0+** - Full support, Chromium-based
827
- - **Firefox 130+** - Full WebCodecs support
828
946
  - **Safari (macOS/iOS) 26.0+** - Full WebCodecs support
829
947
 
830
948
  ### Partial Support (Core Features Only)
831
949
 
832
950
  The following browsers support core recording features but may have limitations:
833
951
 
834
- - **Firefox 76-129** - AudioWorklet supported, but WebCodecs not available. Real-time MP4 transcoding unavailable; falls back to MediaRecorder (WebM format)
835
952
  - **Safari (macOS/iOS) 16.4-25.x** - Partial WebCodecs support; some codecs may not be available
836
953
 
837
954
  ### Required Browser APIs
@@ -851,20 +968,23 @@ The following browsers support core recording features but may have limitations:
851
968
 
852
969
  ### Feature Support by Browser
853
970
 
854
- | Feature | Chrome 94+ | Edge 94+ | Firefox 130+ | Safari 26.0+ | Firefox 76-129 | Safari 16.4-25.x |
855
- |---------|------------|---------|--------------|--------------|---------------|------------------|
856
- | Camera Recording | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
857
- | Screen Recording | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
858
- | Real-time MP4 Transcoding | ✅ | ✅ | ✅ | ✅ | ❌ (WebM) | ⚠️ (Partial) |
859
- | Audio Level Analysis | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
860
- | Source Switching | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
861
- | Device Switching | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
862
- | Persistent Upload Queue | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
971
+ | Feature | Chrome 94+ | Edge 94+ | Safari 26.0+ | Safari 16.4-25.x |
972
+ |---------|------------|---------|--------------|------------------|
973
+ | Camera Recording | ✅ | ✅ | ✅ | ✅ |
974
+ | Screen Recording | ✅ | ✅ | ✅ | ✅ |
975
+ | Real-time MP4 Transcoding | ✅ | ✅ | ✅ | ⚠️ (Partial) |
976
+ | Audio Level Analysis | ✅ | ✅ | ✅ | ✅ |
977
+ | Source Switching | ✅ | ✅ | ✅ | ✅ |
978
+ | Device Switching | ✅ | ✅ | ✅ | ✅ |
979
+ | Persistent Upload Queue | ✅ | ✅ | ✅ | ✅ |
863
980
 
864
981
  ### Unsupported Browsers
865
982
 
866
983
  - Internet Explorer (all versions)
867
- - Firefox < 76 (missing AudioWorklet)
984
+ - Firefox (all versions)
985
+ - Samsung Internet
986
+ - Android WebView and in-app browsers
987
+ - Google App browser
868
988
  - Safari < 14.1 (missing AudioWorklet)
869
989
  - Safari < 16.4 (missing OffscreenCanvas and WebCodecs)
870
990
  - Edge Legacy (pre-Chromium)
@@ -873,10 +993,13 @@ The following browsers support core recording features but may have limitations:
873
993
  ### Mobile Browser Support
874
994
 
875
995
  - **Chrome Android 94+** - Full support
876
- - **Samsung Internet 18.0+** - Full support
877
- - **Firefox Android 130+** - Full support
996
+ - **Edge Android 94+** - Full support
878
997
  - **Safari iOS 16.4+** - Partial support (WebCodecs partial)
879
998
  - **Safari iOS 26.0+** - Full support
999
+ - **Samsung Internet** - Not supported
1000
+ - **Android WebView and in-app browsers** - Not supported
1001
+ - **Google App browser** - Not supported
1002
+ - **Firefox Android** - Not supported
880
1003
 
881
1004
  ### Important Notes
882
1005