Files
chatkit/dist/react/VoiceRecorder.d.ts
CatoandClaude be943e2647 feat(messenger): voice messages people find, and that play everywhere (0.37.0) (#102)
The empty box's send slot records a voice message in the box's place; one
tap sends it. A voice note plays in the thread in the bubble's own colours.
AAC in MP4 first, so every phone plays it. Its length travels with it.

Fix: the timer rounded to 0:01 at half a second and a short take was
dropped without a word.


Claude-Session: https://claude.ai/code/session_019MDtmsmMXvM981mcszxEA6

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-15 01:41:03 +01:00

62 lines
2.8 KiB
TypeScript

import type { MessengerLabels } from "./messenger-labels.js";
/** The longest voice message: five minutes. Past it the take ends by itself. */
export declare const VOICE_MESSAGE_MAX_MS: number;
/** Shorter than this is a slip of the finger, not a message. */
export declare const VOICE_MESSAGE_MIN_MS = 500;
/**
* The container the browser records a voice in, best first.
*
* AAC in MP4 first: it is the one recording every phone plays, iPhones
* included. A voice recorded as WebM on an Android phone and sent to an
* iPhone is a message the other person may not be able to open. Opus in WebM
* where AAC is not offered (Firefox), then whatever is left.
*/
export declare function voiceMimeType(supported?: (type: string) => boolean): string | null;
/** Can this browser record a voice message at all? */
export declare function canRecordVoice(): boolean;
/** "voice-2026-11-13-2004.m4a": a name a person can find again in a folder. */
export declare function voiceFileName(at: Date, mimeType: string): string;
export type VoiceTake = {
file: File;
durationMs: number;
};
export type VoiceRecording = {
phase: "idle" | "opening" | "recording" | "failed";
elapsedMs: number;
start: () => Promise<void>;
/** Stop and hand over the take, or null for one too short or empty. */
finish: () => Promise<VoiceTake | null>;
/** Stop and throw the take away. */
cancel: () => void;
};
/**
* Recording a voice, without any markup: the microphone is open only while
* recording and is closed on every way out (finish, cancel, the five-minute
* limit, the component going away). One request at a time, so a second tap
* while the microphone is still opening cannot open a second one.
*/
export declare function useVoiceRecording(maxMs?: number): VoiceRecording;
/**
* The message box while a voice is recorded: Delete, the time with a red
* dot, Send. It takes the box's place, so the thread above stays where it
* was and the thumb that started the recording ends it in the same spot.
* Recording starts as soon as it is shown.
*/
export declare function VoiceBar({ onSend, onClose, onTooShort, labels, maxMs, }: {
onSend: (take: VoiceTake) => void;
onClose: () => void;
/** Send was tapped before there was anything to send. Never silent. */
onTooShort?: () => void;
labels: MessengerLabels;
maxMs?: number;
}): import("react").JSX.Element;
/**
* The recorder in a sheet: start, stop, listen, then add. For an app with its
* own arrangement; the Messenger itself records in the box (`VoiceBar`).
*/
export declare function VoiceRecorder({ onDone, labels, maxMs, }: {
onDone: (file: File, durationMs?: number) => void;
labels: MessengerLabels;
maxMs?: number;
}): import("react").JSX.Element;
//# sourceMappingURL=VoiceRecorder.d.ts.map