TypeScript Support
Use the SDK with full type safety and autocomplete support in TypeScript projects.
The SDK includes full TypeScript definitions:
import {
VocaFuseSDK,
type SDKConfig,
type UploadResult,
type RecorderOptions,
type RecorderState,
type VoicenoteResult
} from '@vocafuse/frontend-sdk';
const config: SDKConfig = {
tokenEndpoint: '/api/vocafuse-token',
timeout: 30000
};
const sdk = new VocaFuseSDK(config);
await sdk.init();
const options: RecorderOptions = {
maxDuration: 60,
onStateChange: (s: RecorderState) => console.log(s),
onRecordProgress: (seconds: number) => console.log(seconds),
onUploadProgress: (pct: number) => console.log(pct),
onComplete: (result: UploadResult) => console.log(result.voicenote_id)
};
const recorder = sdk.createRecorder(options);
// If you set autoUpload: false, stop() returns a VoicenoteResult
// const raw: VoicenoteResult | UploadResult = await recorder.stop();