@siteed/expo-audio-studio 2.18.4 → 2.18.6
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 +19 -1
- package/android/src/main/java/net/siteed/audiostream/AudioDeviceManager.kt +19 -3
- package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +117 -73
- package/android/src/main/java/net/siteed/audiostream/AudioRecordingService.kt +1 -0
- package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +1 -1
- package/build/cjs/AudioAnalysis/extractAudioAnalysis.js +6 -1
- package/build/cjs/AudioAnalysis/extractAudioAnalysis.js.map +1 -1
- package/build/cjs/AudioAnalysis/extractAudioData.js +10 -1
- package/build/cjs/AudioAnalysis/extractAudioData.js.map +1 -1
- package/build/cjs/AudioAnalysis/extractMelSpectrogram.js +5 -1
- package/build/cjs/AudioAnalysis/extractMelSpectrogram.js.map +1 -1
- package/build/cjs/trimAudio.js +3 -1
- package/build/cjs/trimAudio.js.map +1 -1
- package/build/cjs/useAudioRecorder.js +3 -2
- package/build/cjs/useAudioRecorder.js.map +1 -1
- package/build/cjs/utils/cleanNativeOptions.js +22 -0
- package/build/cjs/utils/cleanNativeOptions.js.map +1 -0
- package/build/esm/AudioAnalysis/extractAudioAnalysis.js +6 -1
- package/build/esm/AudioAnalysis/extractAudioAnalysis.js.map +1 -1
- package/build/esm/AudioAnalysis/extractAudioData.js +10 -1
- package/build/esm/AudioAnalysis/extractAudioData.js.map +1 -1
- package/build/esm/AudioAnalysis/extractMelSpectrogram.js +5 -1
- package/build/esm/AudioAnalysis/extractMelSpectrogram.js.map +1 -1
- package/build/esm/trimAudio.js +3 -1
- package/build/esm/trimAudio.js.map +1 -1
- package/build/esm/useAudioRecorder.js +3 -2
- package/build/esm/useAudioRecorder.js.map +1 -1
- package/build/esm/utils/cleanNativeOptions.js +19 -0
- package/build/esm/utils/cleanNativeOptions.js.map +1 -0
- package/build/types/AudioAnalysis/extractAudioAnalysis.d.ts.map +1 -1
- package/build/types/AudioAnalysis/extractAudioData.d.ts.map +1 -1
- package/build/types/AudioAnalysis/extractMelSpectrogram.d.ts.map +1 -1
- package/build/types/trimAudio.d.ts.map +1 -1
- package/build/types/useAudioRecorder.d.ts.map +1 -1
- package/build/types/utils/cleanNativeOptions.d.ts +15 -0
- package/build/types/utils/cleanNativeOptions.d.ts.map +1 -0
- package/ios/AudioDeviceManager.swift +9 -5
- package/ios/AudioStreamManager.swift +66 -39
- package/ios/ExpoAudioStreamModule.swift +9 -3
- package/package.json +1 -2
- package/src/AudioAnalysis/extractAudioAnalysis.ts +12 -1
- package/src/AudioAnalysis/extractAudioData.ts +12 -1
- package/src/AudioAnalysis/extractMelSpectrogram.ts +11 -1
- package/src/trimAudio.ts +5 -1
- package/src/useAudioRecorder.tsx +3 -2
- package/src/utils/cleanNativeOptions.ts +18 -0
package/src/useAudioRecorder.tsx
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
AudioEventPayload,
|
|
22
22
|
addRecordingInterruptionListener,
|
|
23
23
|
} from './events'
|
|
24
|
+
import { cleanNativeOptions } from './utils/cleanNativeOptions'
|
|
24
25
|
|
|
25
26
|
export interface UseAudioRecorderProps {
|
|
26
27
|
logger?: ConsoleLike
|
|
@@ -516,7 +517,7 @@ export function useAudioRecorder({
|
|
|
516
517
|
onAudioStreamRef.current = null
|
|
517
518
|
}
|
|
518
519
|
// Strip undefined values and functions that can't cross the native bridge
|
|
519
|
-
const cleanOptions =
|
|
520
|
+
const cleanOptions = cleanNativeOptions(options)
|
|
520
521
|
const startResult: StartRecordingResult =
|
|
521
522
|
await ExpoAudioStream.startRecording(cleanOptions)
|
|
522
523
|
dispatch({ type: 'START' })
|
|
@@ -572,7 +573,7 @@ export function useAudioRecorder({
|
|
|
572
573
|
}
|
|
573
574
|
|
|
574
575
|
// Strip undefined values and functions that can't cross the native bridge
|
|
575
|
-
const cleanOptions =
|
|
576
|
+
const cleanOptions = cleanNativeOptions(options)
|
|
576
577
|
// Call the native prepareRecording method
|
|
577
578
|
await ExpoAudioStream.prepareRecording(cleanOptions)
|
|
578
579
|
logger?.debug(`recording prepared successfully`)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips non-serializable values (functions, ArrayBuffer, undefined) from
|
|
3
|
+
* option objects before passing them to Expo native modules.
|
|
4
|
+
*
|
|
5
|
+
* Android's Kotlin bridge crashes with "Cannot convert '[object Object]' to a
|
|
6
|
+
* Kotlin type" when it receives non-plain values such as `logger`, `ArrayBuffer`,
|
|
7
|
+
* or `undefined` fields. The JSON round-trip removes all of these safely.
|
|
8
|
+
*
|
|
9
|
+
* Only use this for small config objects (never for large audio buffers).
|
|
10
|
+
*
|
|
11
|
+
* NOTE: structuredClone() is intentionally NOT used here — it preserves
|
|
12
|
+
* undefined values and non-JSON types, which is exactly what we need to strip.
|
|
13
|
+
*/
|
|
14
|
+
export function cleanNativeOptions<T>(options: T): T {
|
|
15
|
+
// NOSONAR: JSON round-trip is deliberate — it strips undefined, functions,
|
|
16
|
+
// and non-serializable values that structuredClone would preserve.
|
|
17
|
+
return JSON.parse(JSON.stringify(options)) // NOSONAR
|
|
18
|
+
}
|