@ttt-productions/file-input 0.11.8 → 0.11.10
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/dist/lib/validate-upload-kind.d.ts +12 -1
- package/dist/lib/validate-upload-kind.d.ts.map +1 -1
- package/dist/lib/validate-upload-kind.js +7 -1
- package/dist/lib/validate-upload-kind.js.map +1 -1
- package/dist/react/components/file-input.js +3 -3
- package/dist/react/components/file-input.js.map +1 -1
- package/dist/react/components/image-cropper-modal.d.ts.map +1 -1
- package/dist/react/components/image-cropper-modal.js +9 -12
- package/dist/react/components/image-cropper-modal.js.map +1 -1
- package/dist/react/components/media-input.d.ts.map +1 -1
- package/dist/react/components/media-input.js +35 -16
- package/dist/react/components/media-input.js.map +1 -1
- package/dist/react/components/photo-capture-modal.d.ts.map +1 -1
- package/dist/react/components/photo-capture-modal.js +23 -17
- package/dist/react/components/photo-capture-modal.js.map +1 -1
- package/dist/react/components/record-dialog.d.ts.map +1 -1
- package/dist/react/components/record-dialog.js +33 -6
- package/dist/react/components/record-dialog.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-dialog.js","sourceRoot":"","sources":["../../../src/react/components/record-dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,iBAAiB,EACj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,KAAC,WAAW,IAAC,IAAI,EAAE,kBAAkB,EAAE,YAAY,EAAE,qBAAqB,YACxE,MAAC,kBAAkB,eACjB,MAAC,iBAAiB,eAChB,KAAC,gBAAgB,qCAAsC,EACvD,KAAC,sBAAsB,gGAEE,IACP,EACpB,MAAC,iBAAiB,eAChB,KAAC,iBAAiB,iCAAmC,EACrD,KAAC,iBAAiB,IAAC,OAAO,EAAE,sBAAsB,wBAE9B,IACF,IACD,GACT,IACb,CACJ,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Camera, Video, Mic, X, RotateCcw, Check } from \"lucide-react\";\nimport { startWaveformLoop } from \"@ttt-productions/media-viewer\";\nimport { MediaPreview } from \"@ttt-productions/media-viewer/react\";\nimport { ensureFileWithContentType } from \"../../lib/infer-content-type.js\";\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from \"@ttt-productions/ui-core/react\";\n\ntype RecorderState = \"idle\" | \"recording\" | \"preview\";\n\n// Explicit MediaRecorder container preferences, probed via isTypeSupported.\n// A no-argument MediaRecorder leaves the container to the browser (Chrome\n// reports \"audio/webm;codecs=opus\" for audio); requesting an explicit\n// supported type keeps the recorded container deterministic. Safari has no\n// webm support and falls through to mp4. When isTypeSupported is unavailable\n// or nothing matches (test environments), we fall back to the no-argument\n// constructor and normalize whatever the recorder produced.\nconst RECORDER_MIME_CANDIDATES: Record<\"audio\" | \"video\", readonly string[]> = {\n audio: [\"audio/webm;codecs=opus\", \"audio/webm\", \"audio/mp4\"],\n video: [\"video/webm;codecs=vp9,opus\", \"video/webm\", \"video/mp4\"],\n};\n\nfunction pickRecorderMimeType(kind: \"audio\" | \"video\"): string | undefined {\n if (\n typeof MediaRecorder === \"undefined\" ||\n typeof MediaRecorder.isTypeSupported !== \"function\"\n ) {\n return undefined;\n }\n for (const candidate of RECORDER_MIME_CANDIDATES[kind]) {\n try {\n if (MediaRecorder.isTypeSupported(candidate)) return candidate;\n } catch {\n // Treat probe errors as \"unsupported\" and keep trying.\n }\n }\n return undefined;\n}\n\n// Name the recording after its actual container so the filename never\n// contradicts the emitted contentType (a webm-named mp4 would mislead any\n// extension-based fallback downstream). The mp4 container holds either audio\n// (.m4a → audio/mp4) or video (.mp4 → video/mp4), and — unlike webm/ogg — mp4\n// is NOT in the extension-inference ambiguous map (a user-picked .mp4 is trusted\n// as video). Here the RecordDialog's selected `kind` IS authoritative: an audio\n// recording uses an audio-only, `video: false` getUserMedia stream, so no video\n// track can exist. A surprising `video/mp4` mimeType on that audio recording is\n// therefore still named `.m4a`; ensureFileWithContentType distrusts the\n// kind-mismatched video/mp4 type and the `.m4a` extension yields audio/mp4.\nfunction recordingFileName(mime: string, kind: \"audio\" | \"video\"): string {\n const base = mime.split(\";\")[0].trim().toLowerCase();\n const ext =\n base === \"audio/mp4\" || base === \"video/mp4\"\n ? kind === \"audio\"\n ? \"m4a\"\n : \"mp4\"\n : base === \"audio/ogg\" || base === \"video/ogg\"\n ? \"ogg\"\n : \"webm\";\n return `recording.${ext}`;\n}\n\n// A MediaRecorder blob is always a little LONGER than the wall-clock window\n// between start() and stop(). Three effects stack, all in the same direction:\n// 1. stop() flushes whatever the encoder/muxer still had buffered, so the\n// last written packet extends past the stop() call (Chromium's webm muxer\n// and Firefox's are both in the tens-to-low-hundreds of ms here; typical\n// observed flush is well under 500ms).\n// 2. The container duration is the END of the final frame/packet, not the\n// moment capture stopped — one video frame is ~33ms at 30fps and one Opus\n// packet is 20ms, and both readers round that way (the client gate's\n// seek-to-end duration and ffprobe on the server agree with the container).\n// 3. setTimeout fires LATE, never early — a busy main thread encoding video\n// routinely adds tens of ms, more under load or in a hidden tab.\n//\n// Both duration gates are exact — the client upload gate (validateMediaDuration:\n// `duration <= maxDurationSec`) and the server processor\n// (media-processing-core validateDuration: `durationSec <= maxDurationSec`) —\n// with no tolerance. So stopping the recorder exactly AT the cap produced blobs\n// the product then rejected as its own \"Media too long. Max N seconds.\" error.\n// Stopping early by 750ms clears all three effects above with headroom for\n// timer jitter, and costs 1.25% of the smallest real cap (60s).\nconst AUTO_STOP_SAFETY_MARGIN_MS = 750;\n\n// The auto-stop delay for a cap. The clamp keeps the margin from swallowing a\n// very short cap (a 1s cap would otherwise stop at 250ms); real caps are >= 60s,\n// where the clamp never applies.\nexport function autoStopDelayMs(maxRecordDurationSec: number): number {\n const capMs = Math.floor(maxRecordDurationSec * 1000);\n return Math.max(capMs - AUTO_STOP_SAFETY_MARGIN_MS, Math.ceil(capMs / 2));\n}\n\ninterface RecordDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n initialKind: \"audio\" | \"video\";\n canPhoto: boolean;\n canRecVideo: boolean;\n canRecAudio: boolean;\n cameraFacingMode?: \"user\" | \"environment\";\n maxRecordDurationSec?: number;\n disabled?: boolean;\n isLoading?: boolean;\n /** `recordedKind` is the kind of the ACTUAL recording session (the dialog's\n * own state at Save time, which tracks the requested MediaStream — audio\n * requests `video:false`). It feeds the STRONG `media-recorder` client\n * claim, so it must never be re-derived from the blob's reported MIME. */\n onRecorded: (file: File, previewUrl: string, recordedKind: \"audio\" | \"video\") => void | Promise<void>;\n onRequestPhoto?: () => void;\n}\n\nfunction formatDuration(ms: number): string {\n const totalSec = Math.max(0, Math.floor(ms / 1000));\n const m = Math.floor(totalSec / 60);\n const s = totalSec % 60;\n return `${m}:${s.toString().padStart(2, \"0\")}`;\n}\n\nexport function RecordDialog({\n open,\n onOpenChange,\n initialKind,\n canPhoto,\n canRecVideo,\n canRecAudio,\n cameraFacingMode,\n maxRecordDurationSec,\n disabled = false,\n isLoading = false,\n onRecorded,\n onRequestPhoto,\n}: RecordDialogProps) {\n const [recordKind, setRecordKind] = useState<\"audio\" | \"video\">(initialKind);\n const [recorderState, setRecorderState] = useState<RecorderState>(\"idle\");\n const [recordPreviewUrl, setRecordPreviewUrl] = useState<string | null>(null);\n const [recordedFile, setRecordedFile] = useState<File | null>(null);\n const [elapsedMs, setElapsedMs] = useState(0);\n const [discardConfirmOpen, setDiscardConfirmOpen] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const mediaRecorderRef = useRef<MediaRecorder | null>(null);\n const recordStreamRef = useRef<MediaStream | null>(null);\n const liveStreamKindRef = useRef<\"audio\" | \"video\" | null>(null);\n const recordChunksRef = useRef<BlobPart[]>([]);\n const lastRecordUrlRef = useRef<string | null>(null);\n const livePreviewRef = useRef<HTMLVideoElement | null>(null);\n const autoStopTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const startedAtRef = useRef<number>(0);\n const elapsedIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const audioContextRef = useRef<AudioContext | null>(null);\n const audioAnalyserRef = useRef<AnalyserNode | null>(null);\n const audioSourceRef = useRef<MediaStreamAudioSourceNode | null>(null);\n const waveformStopRef = useRef<(() => void) | null>(null);\n const waveformCanvasRef = useRef<HTMLCanvasElement | null>(null);\n\n // Reset all transient state whenever the dialog opens.\n useEffect(() => {\n if (open) {\n setRecordKind(initialKind);\n setRecorderState(\"idle\");\n setRecordedFile(null);\n setRecordPreviewUrl(null);\n setElapsedMs(0);\n setDiscardConfirmOpen(false);\n setError(null);\n }\n }, [open, initialKind]);\n\n const revokeLastRecordUrl = useCallback(() => {\n if (!lastRecordUrlRef.current) return;\n try {\n URL.revokeObjectURL(lastRecordUrlRef.current);\n } catch {}\n lastRecordUrlRef.current = null;\n }, []);\n\n const makeRecordUrl = useCallback(\n (blob: Blob) => {\n revokeLastRecordUrl();\n const url = URL.createObjectURL(blob);\n lastRecordUrlRef.current = url;\n return url;\n },\n [revokeLastRecordUrl]\n );\n\n const stopElapsedTimer = useCallback(() => {\n if (elapsedIntervalRef.current) {\n clearInterval(elapsedIntervalRef.current);\n elapsedIntervalRef.current = null;\n }\n }, []);\n\n const startElapsedTimer = useCallback(() => {\n stopElapsedTimer();\n startedAtRef.current = Date.now();\n setElapsedMs(0);\n elapsedIntervalRef.current = setInterval(() => {\n setElapsedMs(Date.now() - startedAtRef.current);\n }, 100);\n }, [stopElapsedTimer]);\n\n const stopWaveform = useCallback(() => {\n waveformStopRef.current?.();\n waveformStopRef.current = null;\n try {\n audioSourceRef.current?.disconnect();\n } catch {}\n audioSourceRef.current = null;\n audioAnalyserRef.current = null;\n const ctx = audioContextRef.current;\n audioContextRef.current = null;\n if (ctx && ctx.state !== \"closed\") {\n ctx.close().catch(() => {});\n }\n }, []);\n\n const startWaveform = useCallback(\n (stream: MediaStream) => {\n stopWaveform();\n try {\n const AudioCtx: typeof AudioContext =\n (window as any).AudioContext || (window as any).webkitAudioContext;\n if (!AudioCtx) return;\n\n const ctx = new AudioCtx();\n const source = ctx.createMediaStreamSource(stream);\n const analyser = ctx.createAnalyser();\n analyser.fftSize = 256;\n source.connect(analyser);\n\n audioContextRef.current = ctx;\n audioSourceRef.current = source;\n audioAnalyserRef.current = analyser;\n\n // Draw loop is the shared media-viewer engine (the same one the\n // playback AudioPlayer uses) in oscilloscope mode — one waveform\n // implementation across recording and playback.\n waveformStopRef.current = startWaveformLoop({\n analyser,\n getCanvas: () => waveformCanvasRef.current,\n mode: \"line\",\n });\n } catch {\n // Waveform is best-effort; silent failures are acceptable.\n }\n },\n [stopWaveform]\n );\n\n // Teardown MediaRecorder / MediaStream / auto-stop timeout / timer / waveform.\n // Leaves recorderState alone — callers decide the next state.\n const teardownCapture = useCallback(() => {\n if (autoStopTimeoutRef.current) {\n clearTimeout(autoStopTimeoutRef.current);\n autoStopTimeoutRef.current = null;\n }\n mediaRecorderRef.current = null;\n\n const s = recordStreamRef.current;\n recordStreamRef.current = null;\n liveStreamKindRef.current = null;\n if (s) s.getTracks().forEach((t) => t.stop());\n\n if (livePreviewRef.current) {\n livePreviewRef.current.srcObject = null;\n }\n\n recordChunksRef.current = [];\n\n stopElapsedTimer();\n stopWaveform();\n }, [stopElapsedTimer, stopWaveform]);\n\n // Acquire camera/mic and attach the live preview (video) or waveform (audio)\n // WITHOUT starting the recorder. Returns the live stream for reuse on Start.\n const acquireStream = useCallback(\n async (kind: \"audio\" | \"video\") => {\n const wantVideo = kind === \"video\";\n const facingMode = cameraFacingMode ?? \"user\";\n const stream = await navigator.mediaDevices.getUserMedia({\n audio: true,\n video: wantVideo ? { facingMode } : false,\n });\n recordStreamRef.current = stream;\n liveStreamKindRef.current = kind;\n setError(null);\n if (wantVideo && livePreviewRef.current) {\n livePreviewRef.current.srcObject = stream;\n livePreviewRef.current.muted = true;\n try {\n await livePreviewRef.current.play();\n } catch {}\n } else if (!wantVideo) {\n startWaveform(stream);\n }\n return stream;\n },\n [cameraFacingMode, startWaveform]\n );\n\n // Start a live preview for the given kind (used on open and on kind switch),\n // tearing down any existing stream first. Surfaces permission errors inline.\n const startLivePreview = useCallback(\n async (kind: \"audio\" | \"video\") => {\n teardownCapture();\n try {\n await acquireStream(kind);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Camera/microphone access denied.\");\n }\n },\n [teardownCapture, acquireStream]\n );\n\n // Request camera/mic as soon as the dialog opens (parity with PhotoCaptureModal)\n // so the permission prompt fires on open and the user sees a live preview before\n // pressing Start. Release all devices when the dialog closes or unmounts.\n useEffect(() => {\n if (open) {\n void startLivePreview(initialKind);\n }\n return () => {\n teardownCapture();\n revokeLastRecordUrl();\n };\n }, [open, initialKind, startLivePreview, teardownCapture, revokeLastRecordUrl]);\n\n const startRecording = useCallback(\n async (kind: \"audio\" | \"video\") => {\n // Discard any previous preview before starting fresh.\n revokeLastRecordUrl();\n setRecordPreviewUrl(null);\n setRecordedFile(null);\n setRecordKind(kind);\n\n const wantVideo = kind === \"video\";\n\n // Reuse the live-preview stream when it matches the requested kind;\n // otherwise acquire a fresh one (also (re)triggers the permission prompt).\n let stream = recordStreamRef.current;\n if (!stream || liveStreamKindRef.current !== kind) {\n try {\n stream = await acquireStream(kind);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Camera/microphone access denied.\");\n return;\n }\n }\n if (!stream) return;\n\n // Request an explicit, supported container so mr.mimeType is\n // deterministic; fall back to the browser default when the explicit\n // request is unavailable or rejected.\n const preferredMimeType = pickRecorderMimeType(kind);\n let mr: MediaRecorder;\n try {\n mr = preferredMimeType\n ? new MediaRecorder(stream, { mimeType: preferredMimeType })\n : new MediaRecorder(stream);\n } catch {\n mr = new MediaRecorder(stream);\n }\n mediaRecorderRef.current = mr;\n recordChunksRef.current = [];\n\n mr.ondataavailable = (e) => {\n if (e.data && e.data.size > 0) recordChunksRef.current.push(e.data);\n };\n\n mr.onstop = () => {\n const blob = new Blob(recordChunksRef.current, {\n type:\n mr.mimeType ||\n preferredMimeType ||\n (wantVideo ? \"video/webm\" : \"audio/webm\"),\n });\n\n const rawFile = new File([blob], recordingFileName(blob.type, kind), { type: blob.type });\n // Normalize to the valid, parameter-less base type\n // (\"audio/webm;codecs=opus\" → \"audio/webm\"). The chosen kind is\n // authoritative: an audio recording must never emit a video/* type\n // even if the recorder reports a surprising container.\n const file = ensureFileWithContentType(rawFile, wantVideo ? \"video\" : \"audio\");\n const url = makeRecordUrl(file);\n\n setRecordedFile(file);\n setRecordPreviewUrl(url);\n setRecorderState(\"preview\");\n\n // Release devices but keep the recorded file/url in state.\n teardownCapture();\n };\n\n mr.start();\n setRecorderState(\"recording\");\n startElapsedTimer();\n\n // Hard cap. Stops with deliberate headroom (autoStopDelayMs) so the blob\n // this produces lands legally UNDER maxRecordDurationSec at both gates.\n if (maxRecordDurationSec && maxRecordDurationSec > 0) {\n autoStopTimeoutRef.current = setTimeout(() => {\n try {\n if (mediaRecorderRef.current && mediaRecorderRef.current.state === \"recording\") {\n mediaRecorderRef.current.stop();\n }\n } catch {}\n }, autoStopDelayMs(maxRecordDurationSec));\n }\n },\n [\n acquireStream,\n maxRecordDurationSec,\n makeRecordUrl,\n revokeLastRecordUrl,\n teardownCapture,\n startElapsedTimer,\n ]\n );\n\n const stopRecording = useCallback(() => {\n const mr = mediaRecorderRef.current;\n if (mr && mr.state === \"recording\") {\n try {\n mr.stop();\n } catch {\n teardownCapture();\n setRecorderState(\"idle\");\n }\n } else {\n teardownCapture();\n setRecorderState(\"idle\");\n }\n }, [teardownCapture]);\n\n const handleReRecord = useCallback(() => {\n revokeLastRecordUrl();\n setRecordPreviewUrl(null);\n setRecordedFile(null);\n setElapsedMs(0);\n setError(null);\n setRecorderState(\"idle\");\n void startLivePreview(recordKind);\n }, [revokeLastRecordUrl, startLivePreview, recordKind]);\n\n // Switching kind in idle restarts the live preview for the new kind so the\n // correct device prompt/preview shows before recording.\n const handleSelectKind = useCallback(\n (kind: \"audio\" | \"video\") => {\n setRecordKind(kind);\n setError(null);\n void startLivePreview(kind);\n },\n [startLivePreview]\n );\n\n const handleSave = useCallback(async () => {\n if (!recordedFile || !recordPreviewUrl) return;\n await onRecorded(recordedFile, recordPreviewUrl, recordKind);\n onOpenChange(false);\n }, [recordedFile, recordPreviewUrl, recordKind, onRecorded, onOpenChange]);\n\n // Close the dialog for real (no confirmation). Used for idle/recording\n // states and as the \"Discard\" action in the confirm AlertDialog.\n const closeDialogImmediately = useCallback(() => {\n const mr = mediaRecorderRef.current;\n if (mr && mr.state === \"recording\") {\n try {\n mr.stop();\n } catch {}\n }\n teardownCapture();\n revokeLastRecordUrl();\n setRecordedFile(null);\n setRecordPreviewUrl(null);\n setElapsedMs(0);\n setRecorderState(\"idle\");\n setDiscardConfirmOpen(false);\n onOpenChange(false);\n }, [teardownCapture, revokeLastRecordUrl, onOpenChange]);\n\n // Dialog close requests. In \"preview\" state we ask for confirmation\n // (the user has unsaved work). Other states close immediately.\n const handleDialogOpenChange = useCallback(\n (v: boolean) => {\n if (v) return; // opening is parent-driven via the `open` prop\n if (recorderState === \"preview\") {\n setDiscardConfirmOpen(true);\n return;\n }\n closeDialogImmediately();\n },\n [recorderState, closeDialogImmediately]\n );\n\n const isRecording = recorderState === \"recording\";\n const isPreview = recorderState === \"preview\";\n const isIdle = recorderState === \"idle\";\n\n // The label shows the REAL cap (\"0:42 / 1:00\"), not the earlier auto-stop\n // point — the promise to the user is the cap; the margin is internal.\n const elapsedLabel = maxRecordDurationSec\n ? `${formatDuration(elapsedMs)} / ${formatDuration(maxRecordDurationSec * 1000)}`\n : formatDuration(elapsedMs);\n\n return (\n <>\n <Dialog open={open} onOpenChange={handleDialogOpenChange}>\n <DialogContent className=\"max-w-md\">\n <DialogHeader>\n <DialogTitle>Record</DialogTitle>\n <DialogDescription>\n {isIdle && \"Choose audio or video, then press Start.\"}\n {isRecording && \"Recording…\"}\n {isPreview && \"Review your recording. Save to upload, or Re-record to try again.\"}\n </DialogDescription>\n </DialogHeader>\n\n {/* Kind toggle — only active in idle state */}\n <div className=\"flex flex-wrap gap-2\">\n {canRecVideo && (\n <Button\n variant={recordKind === \"video\" ? \"default\" : \"secondary\"}\n onClick={() => handleSelectKind(\"video\")}\n disabled={!isIdle}\n >\n <Video className=\"mr-2 icon-xs\" />\n Video\n </Button>\n )}\n {canRecAudio && (\n <Button\n variant={recordKind === \"audio\" ? \"default\" : \"secondary\"}\n onClick={() => handleSelectKind(\"audio\")}\n disabled={!isIdle}\n >\n <Mic className=\"mr-2 icon-xs\" />\n Audio\n </Button>\n )}\n {canPhoto && onRequestPhoto && (\n <Button\n variant=\"secondary\"\n onClick={() => {\n onRequestPhoto();\n onOpenChange(false);\n }}\n disabled={!isIdle}\n >\n <Camera className=\"mr-2 icon-xs\" />\n Photo\n </Button>\n )}\n </div>\n\n {/* Live video preview — rendered in idle+recording states for video kind */}\n {recordKind === \"video\" && !isPreview && (\n <div className=\"mt-2 rounded-md overflow-hidden bg-black aspect-video\">\n <video\n ref={livePreviewRef}\n className=\"w-full h-full object-contain\"\n playsInline\n muted\n />\n </div>\n )}\n\n {/* Audio waveform — live mic level (idle = ready indicator, recording = active) */}\n {recordKind === \"audio\" && !isPreview && (\n <div className=\"mt-2 rounded-md bg-muted p-2 text-primary\">\n <canvas\n ref={waveformCanvasRef}\n width={480}\n height={80}\n className=\"w-full h-20\"\n aria-label=\"Audio waveform\"\n />\n </div>\n )}\n\n {error && (\n <p className=\"text-sm text-destructive\" role=\"alert\">\n {error}\n </p>\n )}\n\n {/* Recording indicator + elapsed timer */}\n {isRecording && (\n <div className=\"flex items-center gap-2 text-sm\" aria-live=\"polite\">\n <span\n className=\"inline-block h-2.5 w-2.5 rounded-full bg-red-500 animate-pulse\"\n aria-label=\"Recording\"\n />\n <span className=\"tabular-nums\">{elapsedLabel}</span>\n </div>\n )}\n\n {/* Recorded preview — only in preview state */}\n {isPreview && recordPreviewUrl && (\n <div className=\"mt-2\">\n <MediaPreview\n url={recordPreviewUrl}\n type={recordKind}\n controls\n priority\n className=\"w-full rounded-md\"\n />\n </div>\n )}\n\n <DialogFooter className=\"flex-row justify-between gap-2\">\n <Button\n variant=\"destructive\"\n onClick={() => handleDialogOpenChange(false)}\n >\n <X className=\"mr-2 icon-xs\" />\n Close\n </Button>\n\n {isIdle && (\n <Button\n variant=\"default\"\n onClick={() => startRecording(recordKind)}\n disabled={disabled || isLoading}\n >\n {recordKind === \"video\" ? <Video className=\"mr-2 icon-xs\" /> : <Mic className=\"mr-2 icon-xs\" />}\n Start\n </Button>\n )}\n\n {isRecording && (\n <Button variant=\"default\" onClick={stopRecording}>\n Stop\n </Button>\n )}\n\n {isPreview && (\n <div className=\"flex gap-2\">\n <Button variant=\"secondary\" onClick={handleReRecord}>\n <RotateCcw className=\"mr-2 icon-xs\" />\n Re-record\n </Button>\n <Button variant=\"default\" onClick={handleSave} disabled={disabled || isLoading}>\n <Check className=\"mr-2 icon-xs\" />\n Save\n </Button>\n </div>\n )}\n </DialogFooter>\n </DialogContent>\n </Dialog>\n\n <AlertDialog open={discardConfirmOpen} onOpenChange={setDiscardConfirmOpen}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Discard recording?</AlertDialogTitle>\n <AlertDialogDescription>\n You have a recorded clip that hasn't been saved. Closing now will discard it.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Keep recording</AlertDialogCancel>\n <AlertDialogAction onClick={closeDialogImmediately}>\n Discard\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"record-dialog.js","sourceRoot":"","sources":["../../../src/react/components/record-dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,EACP,cAAc,GACf,MAAM,gCAAgC,CAAC;AAIxC,4EAA4E;AAC5E,0EAA0E;AAC1E,sEAAsE;AACtE,2EAA2E;AAC3E,6EAA6E;AAC7E,0EAA0E;AAC1E,4DAA4D;AAC5D,MAAM,wBAAwB,GAAiD;IAC7E,KAAK,EAAE,CAAC,wBAAwB,EAAE,YAAY,EAAE,WAAW,CAAC;IAC5D,KAAK,EAAE,CAAC,4BAA4B,EAAE,YAAY,EAAE,WAAW,CAAC;CACjE,CAAC;AAEF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AAC,KAAK,IAAC,SAAS,EAAC,SAAS,GAAG,qBAG5B,IACL,CACP,IACY,IACD,GACT,EAET,KAAC,WAAW,IAAC,IAAI,EAAE,kBAAkB,EAAE,YAAY,EAAE,qBAAqB,YACxE,MAAC,kBAAkB,eACjB,MAAC,iBAAiB,eAChB,KAAC,gBAAgB,qCAAsC,EACvD,KAAC,sBAAsB,gGAEE,IACP,EACpB,MAAC,iBAAiB,eAChB,KAAC,iBAAiB,iCAAmC,EACrD,KAAC,iBAAiB,IAAC,OAAO,EAAE,sBAAsB,wBAE9B,IACF,IACD,GACT,IACb,CACJ,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Camera, Video, Mic, X, RotateCcw, Check } from \"lucide-react\";\nimport { startWaveformLoop } from \"@ttt-productions/media-viewer\";\nimport { MediaPreview } from \"@ttt-productions/media-viewer/react\";\nimport { ensureFileWithContentType } from \"../../lib/infer-content-type.js\";\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n Spinner,\n useAsyncAction,\n} from \"@ttt-productions/ui-core/react\";\n\ntype RecorderState = \"idle\" | \"recording\" | \"preview\";\n\n// Explicit MediaRecorder container preferences, probed via isTypeSupported.\n// A no-argument MediaRecorder leaves the container to the browser (Chrome\n// reports \"audio/webm;codecs=opus\" for audio); requesting an explicit\n// supported type keeps the recorded container deterministic. Safari has no\n// webm support and falls through to mp4. When isTypeSupported is unavailable\n// or nothing matches (test environments), we fall back to the no-argument\n// constructor and normalize whatever the recorder produced.\nconst RECORDER_MIME_CANDIDATES: Record<\"audio\" | \"video\", readonly string[]> = {\n audio: [\"audio/webm;codecs=opus\", \"audio/webm\", \"audio/mp4\"],\n video: [\"video/webm;codecs=vp9,opus\", \"video/webm\", \"video/mp4\"],\n};\n\nfunction pickRecorderMimeType(kind: \"audio\" | \"video\"): string | undefined {\n if (\n typeof MediaRecorder === \"undefined\" ||\n typeof MediaRecorder.isTypeSupported !== \"function\"\n ) {\n return undefined;\n }\n for (const candidate of RECORDER_MIME_CANDIDATES[kind]) {\n try {\n if (MediaRecorder.isTypeSupported(candidate)) return candidate;\n } catch {\n // Treat probe errors as \"unsupported\" and keep trying.\n }\n }\n return undefined;\n}\n\n// Name the recording after its actual container so the filename never\n// contradicts the emitted contentType (a webm-named mp4 would mislead any\n// extension-based fallback downstream). The mp4 container holds either audio\n// (.m4a → audio/mp4) or video (.mp4 → video/mp4), and — unlike webm/ogg — mp4\n// is NOT in the extension-inference ambiguous map (a user-picked .mp4 is trusted\n// as video). Here the RecordDialog's selected `kind` IS authoritative: an audio\n// recording uses an audio-only, `video: false` getUserMedia stream, so no video\n// track can exist. A surprising `video/mp4` mimeType on that audio recording is\n// therefore still named `.m4a`; ensureFileWithContentType distrusts the\n// kind-mismatched video/mp4 type and the `.m4a` extension yields audio/mp4.\nfunction recordingFileName(mime: string, kind: \"audio\" | \"video\"): string {\n const base = mime.split(\";\")[0].trim().toLowerCase();\n const ext =\n base === \"audio/mp4\" || base === \"video/mp4\"\n ? kind === \"audio\"\n ? \"m4a\"\n : \"mp4\"\n : base === \"audio/ogg\" || base === \"video/ogg\"\n ? \"ogg\"\n : \"webm\";\n return `recording.${ext}`;\n}\n\n// A MediaRecorder blob is always a little LONGER than the wall-clock window\n// between start() and stop(). Three effects stack, all in the same direction:\n// 1. stop() flushes whatever the encoder/muxer still had buffered, so the\n// last written packet extends past the stop() call (Chromium's webm muxer\n// and Firefox's are both in the tens-to-low-hundreds of ms here; typical\n// observed flush is well under 500ms).\n// 2. The container duration is the END of the final frame/packet, not the\n// moment capture stopped — one video frame is ~33ms at 30fps and one Opus\n// packet is 20ms, and both readers round that way (the client gate's\n// seek-to-end duration and ffprobe on the server agree with the container).\n// 3. setTimeout fires LATE, never early — a busy main thread encoding video\n// routinely adds tens of ms, more under load or in a hidden tab.\n//\n// Both duration gates are exact — the client upload gate (validateMediaDuration:\n// `duration <= maxDurationSec`) and the server processor\n// (media-processing-core validateDuration: `durationSec <= maxDurationSec`) —\n// with no tolerance. So stopping the recorder exactly AT the cap produced blobs\n// the product then rejected as its own \"Media too long. Max N seconds.\" error.\n// Stopping early by 750ms clears all three effects above with headroom for\n// timer jitter, and costs 1.25% of the smallest real cap (60s).\nconst AUTO_STOP_SAFETY_MARGIN_MS = 750;\n\n// The auto-stop delay for a cap. The clamp keeps the margin from swallowing a\n// very short cap (a 1s cap would otherwise stop at 250ms); real caps are >= 60s,\n// where the clamp never applies.\nexport function autoStopDelayMs(maxRecordDurationSec: number): number {\n const capMs = Math.floor(maxRecordDurationSec * 1000);\n return Math.max(capMs - AUTO_STOP_SAFETY_MARGIN_MS, Math.ceil(capMs / 2));\n}\n\ninterface RecordDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n initialKind: \"audio\" | \"video\";\n canPhoto: boolean;\n canRecVideo: boolean;\n canRecAudio: boolean;\n cameraFacingMode?: \"user\" | \"environment\";\n maxRecordDurationSec?: number;\n disabled?: boolean;\n isLoading?: boolean;\n /** `recordedKind` is the kind of the ACTUAL recording session (the dialog's\n * own state at Save time, which tracks the requested MediaStream — audio\n * requests `video:false`). It feeds the STRONG `media-recorder` client\n * claim, so it must never be re-derived from the blob's reported MIME. */\n onRecorded: (file: File, previewUrl: string, recordedKind: \"audio\" | \"video\") => void | Promise<void>;\n onRequestPhoto?: () => void;\n}\n\nfunction formatDuration(ms: number): string {\n const totalSec = Math.max(0, Math.floor(ms / 1000));\n const m = Math.floor(totalSec / 60);\n const s = totalSec % 60;\n return `${m}:${s.toString().padStart(2, \"0\")}`;\n}\n\nexport function RecordDialog({\n open,\n onOpenChange,\n initialKind,\n canPhoto,\n canRecVideo,\n canRecAudio,\n cameraFacingMode,\n maxRecordDurationSec,\n disabled = false,\n isLoading = false,\n onRecorded,\n onRequestPhoto,\n}: RecordDialogProps) {\n const [recordKind, setRecordKind] = useState<\"audio\" | \"video\">(initialKind);\n const [recorderState, setRecorderState] = useState<RecorderState>(\"idle\");\n const [recordPreviewUrl, setRecordPreviewUrl] = useState<string | null>(null);\n const [recordedFile, setRecordedFile] = useState<File | null>(null);\n const [elapsedMs, setElapsedMs] = useState(0);\n const [discardConfirmOpen, setDiscardConfirmOpen] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [acquiring, setAcquiring] = useState(false);\n\n const mediaRecorderRef = useRef<MediaRecorder | null>(null);\n const recordStreamRef = useRef<MediaStream | null>(null);\n const liveStreamKindRef = useRef<\"audio\" | \"video\" | null>(null);\n const recordChunksRef = useRef<BlobPart[]>([]);\n const lastRecordUrlRef = useRef<string | null>(null);\n const livePreviewRef = useRef<HTMLVideoElement | null>(null);\n const autoStopTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n // Bumped by every teardown. An acquisition that resolves after a teardown (dialog\n // closed, kind switched, re-record) belongs to nobody and must not be attached.\n const acquireGenRef = useRef(0);\n const previewReqRef = useRef(0);\n\n const startedAtRef = useRef<number>(0);\n const elapsedIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const audioContextRef = useRef<AudioContext | null>(null);\n const audioAnalyserRef = useRef<AnalyserNode | null>(null);\n const audioSourceRef = useRef<MediaStreamAudioSourceNode | null>(null);\n const waveformStopRef = useRef<(() => void) | null>(null);\n const waveformCanvasRef = useRef<HTMLCanvasElement | null>(null);\n\n // Reset all transient state whenever the dialog opens.\n useEffect(() => {\n if (open) {\n setRecordKind(initialKind);\n setRecorderState(\"idle\");\n setRecordedFile(null);\n setRecordPreviewUrl(null);\n setElapsedMs(0);\n setDiscardConfirmOpen(false);\n setError(null);\n }\n }, [open, initialKind]);\n\n const revokeLastRecordUrl = useCallback(() => {\n if (!lastRecordUrlRef.current) return;\n try {\n URL.revokeObjectURL(lastRecordUrlRef.current);\n } catch {}\n lastRecordUrlRef.current = null;\n }, []);\n\n const makeRecordUrl = useCallback(\n (blob: Blob) => {\n revokeLastRecordUrl();\n const url = URL.createObjectURL(blob);\n lastRecordUrlRef.current = url;\n return url;\n },\n [revokeLastRecordUrl]\n );\n\n const stopElapsedTimer = useCallback(() => {\n if (elapsedIntervalRef.current) {\n clearInterval(elapsedIntervalRef.current);\n elapsedIntervalRef.current = null;\n }\n }, []);\n\n const startElapsedTimer = useCallback(() => {\n stopElapsedTimer();\n startedAtRef.current = Date.now();\n setElapsedMs(0);\n elapsedIntervalRef.current = setInterval(() => {\n setElapsedMs(Date.now() - startedAtRef.current);\n }, 100);\n }, [stopElapsedTimer]);\n\n const stopWaveform = useCallback(() => {\n waveformStopRef.current?.();\n waveformStopRef.current = null;\n try {\n audioSourceRef.current?.disconnect();\n } catch {}\n audioSourceRef.current = null;\n audioAnalyserRef.current = null;\n const ctx = audioContextRef.current;\n audioContextRef.current = null;\n if (ctx && ctx.state !== \"closed\") {\n ctx.close().catch(() => {});\n }\n }, []);\n\n const startWaveform = useCallback(\n (stream: MediaStream) => {\n stopWaveform();\n try {\n const AudioCtx: typeof AudioContext =\n (window as any).AudioContext || (window as any).webkitAudioContext;\n if (!AudioCtx) return;\n\n const ctx = new AudioCtx();\n const source = ctx.createMediaStreamSource(stream);\n const analyser = ctx.createAnalyser();\n analyser.fftSize = 256;\n source.connect(analyser);\n\n audioContextRef.current = ctx;\n audioSourceRef.current = source;\n audioAnalyserRef.current = analyser;\n\n // Draw loop is the shared media-viewer engine (the same one the\n // playback AudioPlayer uses) in oscilloscope mode — one waveform\n // implementation across recording and playback.\n waveformStopRef.current = startWaveformLoop({\n analyser,\n getCanvas: () => waveformCanvasRef.current,\n mode: \"line\",\n });\n } catch {\n // Waveform is best-effort; silent failures are acceptable.\n }\n },\n [stopWaveform]\n );\n\n // Teardown MediaRecorder / MediaStream / auto-stop timeout / timer / waveform.\n // Leaves recorderState alone — callers decide the next state.\n const teardownCapture = useCallback(() => {\n acquireGenRef.current += 1;\n if (autoStopTimeoutRef.current) {\n clearTimeout(autoStopTimeoutRef.current);\n autoStopTimeoutRef.current = null;\n }\n mediaRecorderRef.current = null;\n\n const s = recordStreamRef.current;\n recordStreamRef.current = null;\n liveStreamKindRef.current = null;\n if (s) s.getTracks().forEach((t) => t.stop());\n\n if (livePreviewRef.current) {\n livePreviewRef.current.srcObject = null;\n }\n\n recordChunksRef.current = [];\n\n stopElapsedTimer();\n stopWaveform();\n }, [stopElapsedTimer, stopWaveform]);\n\n // Acquire camera/mic and attach the live preview (video) or waveform (audio)\n // WITHOUT starting the recorder. Returns the live stream for reuse on Start.\n const acquireStream = useCallback(\n async (kind: \"audio\" | \"video\") => {\n const wantVideo = kind === \"video\";\n const facingMode = cameraFacingMode ?? \"user\";\n const gen = acquireGenRef.current;\n const stream = await navigator.mediaDevices.getUserMedia({\n audio: true,\n video: wantVideo ? { facingMode } : false,\n });\n if (gen !== acquireGenRef.current) {\n stream.getTracks().forEach((t) => t.stop());\n return null;\n }\n recordStreamRef.current = stream;\n liveStreamKindRef.current = kind;\n setError(null);\n if (wantVideo && livePreviewRef.current) {\n livePreviewRef.current.srcObject = stream;\n livePreviewRef.current.muted = true;\n try {\n await livePreviewRef.current.play();\n } catch {}\n } else if (!wantVideo) {\n startWaveform(stream);\n }\n return stream;\n },\n [cameraFacingMode, startWaveform]\n );\n\n // Start a live preview for the given kind (used on open and on kind switch),\n // tearing down any existing stream first. Surfaces permission errors inline.\n const startLivePreview = useCallback(\n async (kind: \"audio\" | \"video\") => {\n teardownCapture();\n const req = ++previewReqRef.current;\n setAcquiring(true);\n try {\n await acquireStream(kind);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Camera/microphone access denied.\");\n } finally {\n if (req === previewReqRef.current) setAcquiring(false);\n }\n },\n [teardownCapture, acquireStream]\n );\n\n // Request camera/mic as soon as the dialog opens (parity with PhotoCaptureModal)\n // so the permission prompt fires on open and the user sees a live preview before\n // pressing Start. Release all devices when the dialog closes or unmounts.\n useEffect(() => {\n if (open) {\n void startLivePreview(initialKind);\n }\n return () => {\n teardownCapture();\n revokeLastRecordUrl();\n };\n }, [open, initialKind, startLivePreview, teardownCapture, revokeLastRecordUrl]);\n\n const startRecording = useCallback(\n async (kind: \"audio\" | \"video\") => {\n // Discard any previous preview before starting fresh.\n revokeLastRecordUrl();\n setRecordPreviewUrl(null);\n setRecordedFile(null);\n setRecordKind(kind);\n\n const wantVideo = kind === \"video\";\n\n // Reuse the live-preview stream when it matches the requested kind;\n // otherwise acquire a fresh one (also (re)triggers the permission prompt).\n let stream = recordStreamRef.current;\n if (!stream || liveStreamKindRef.current !== kind) {\n try {\n stream = await acquireStream(kind);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Camera/microphone access denied.\");\n return;\n }\n }\n if (!stream) return;\n\n // Request an explicit, supported container so mr.mimeType is\n // deterministic; fall back to the browser default when the explicit\n // request is unavailable or rejected.\n const preferredMimeType = pickRecorderMimeType(kind);\n let mr: MediaRecorder;\n try {\n mr = preferredMimeType\n ? new MediaRecorder(stream, { mimeType: preferredMimeType })\n : new MediaRecorder(stream);\n } catch {\n mr = new MediaRecorder(stream);\n }\n mediaRecorderRef.current = mr;\n recordChunksRef.current = [];\n\n mr.ondataavailable = (e) => {\n if (e.data && e.data.size > 0) recordChunksRef.current.push(e.data);\n };\n\n mr.onstop = () => {\n const blob = new Blob(recordChunksRef.current, {\n type:\n mr.mimeType ||\n preferredMimeType ||\n (wantVideo ? \"video/webm\" : \"audio/webm\"),\n });\n\n const rawFile = new File([blob], recordingFileName(blob.type, kind), { type: blob.type });\n // Normalize to the valid, parameter-less base type\n // (\"audio/webm;codecs=opus\" → \"audio/webm\"). The chosen kind is\n // authoritative: an audio recording must never emit a video/* type\n // even if the recorder reports a surprising container.\n const file = ensureFileWithContentType(rawFile, wantVideo ? \"video\" : \"audio\");\n const url = makeRecordUrl(file);\n\n setRecordedFile(file);\n setRecordPreviewUrl(url);\n setRecorderState(\"preview\");\n\n // Release devices but keep the recorded file/url in state.\n teardownCapture();\n };\n\n mr.start();\n setRecorderState(\"recording\");\n startElapsedTimer();\n\n // Hard cap. Stops with deliberate headroom (autoStopDelayMs) so the blob\n // this produces lands legally UNDER maxRecordDurationSec at both gates.\n if (maxRecordDurationSec && maxRecordDurationSec > 0) {\n autoStopTimeoutRef.current = setTimeout(() => {\n try {\n if (mediaRecorderRef.current && mediaRecorderRef.current.state === \"recording\") {\n mediaRecorderRef.current.stop();\n }\n } catch {}\n }, autoStopDelayMs(maxRecordDurationSec));\n }\n },\n [\n acquireStream,\n maxRecordDurationSec,\n makeRecordUrl,\n revokeLastRecordUrl,\n teardownCapture,\n startElapsedTimer,\n ]\n );\n\n const stopRecording = useCallback(() => {\n const mr = mediaRecorderRef.current;\n if (mr && mr.state === \"recording\") {\n try {\n mr.stop();\n } catch {\n teardownCapture();\n setRecorderState(\"idle\");\n }\n } else {\n teardownCapture();\n setRecorderState(\"idle\");\n }\n }, [teardownCapture]);\n\n const handleReRecord = useCallback(() => {\n revokeLastRecordUrl();\n setRecordPreviewUrl(null);\n setRecordedFile(null);\n setElapsedMs(0);\n setError(null);\n setRecorderState(\"idle\");\n void startLivePreview(recordKind);\n }, [revokeLastRecordUrl, startLivePreview, recordKind]);\n\n // Switching kind in idle restarts the live preview for the new kind so the\n // correct device prompt/preview shows before recording.\n const handleSelectKind = useCallback(\n (kind: \"audio\" | \"video\") => {\n setRecordKind(kind);\n setError(null);\n void startLivePreview(kind);\n },\n [startLivePreview]\n );\n\n const reportError = useCallback((e: unknown) => {\n setError(e instanceof Error ? e.message : \"Something went wrong with the recording.\");\n }, []);\n\n // Start may need to acquire a device first; pending covers that and a repeat click\n // is ignored, so two clicks can never start two recorders.\n const start = useAsyncAction((kind: \"audio\" | \"video\") => startRecording(kind), { onError: reportError });\n\n // Save hands the recording off (the consumer validates and emits it). Pending covers\n // the hand-off and a repeat click is ignored, so a double click can never emit twice.\n const save = useAsyncAction(\n async () => {\n if (!recordedFile || !recordPreviewUrl) return;\n await onRecorded(recordedFile, recordPreviewUrl, recordKind);\n onOpenChange(false);\n },\n { onError: reportError },\n );\n\n // Close the dialog for real (no confirmation). Used for idle/recording\n // states and as the \"Discard\" action in the confirm AlertDialog.\n const closeDialogImmediately = useCallback(() => {\n const mr = mediaRecorderRef.current;\n if (mr && mr.state === \"recording\") {\n try {\n mr.stop();\n } catch {}\n }\n teardownCapture();\n revokeLastRecordUrl();\n setRecordedFile(null);\n setRecordPreviewUrl(null);\n setElapsedMs(0);\n setRecorderState(\"idle\");\n setDiscardConfirmOpen(false);\n onOpenChange(false);\n }, [teardownCapture, revokeLastRecordUrl, onOpenChange]);\n\n // Dialog close requests. In \"preview\" state we ask for confirmation\n // (the user has unsaved work). Other states close immediately.\n const handleDialogOpenChange = useCallback(\n (v: boolean) => {\n if (v) return; // opening is parent-driven via the `open` prop\n if (save.pending) return; // never drop a recording mid-hand-off\n if (recorderState === \"preview\") {\n setDiscardConfirmOpen(true);\n return;\n }\n closeDialogImmediately();\n },\n [recorderState, save.pending, closeDialogImmediately]\n );\n\n const isRecording = recorderState === \"recording\";\n const isPreview = recorderState === \"preview\";\n const isIdle = recorderState === \"idle\";\n\n // The label shows the REAL cap (\"0:42 / 1:00\"), not the earlier auto-stop\n // point — the promise to the user is the cap; the margin is internal.\n const elapsedLabel = maxRecordDurationSec\n ? `${formatDuration(elapsedMs)} / ${formatDuration(maxRecordDurationSec * 1000)}`\n : formatDuration(elapsedMs);\n\n return (\n <>\n <Dialog open={open} onOpenChange={handleDialogOpenChange}>\n <DialogContent className=\"max-w-md\">\n <DialogHeader>\n <DialogTitle>Record</DialogTitle>\n <DialogDescription>\n {isIdle && \"Choose audio or video, then press Start.\"}\n {isRecording && \"Recording…\"}\n {isPreview && \"Review your recording. Save to upload, or Re-record to try again.\"}\n </DialogDescription>\n </DialogHeader>\n\n {/* Kind toggle — only active in idle state */}\n <div className=\"flex flex-wrap gap-2\">\n {canRecVideo && (\n <Button\n variant={recordKind === \"video\" ? \"default\" : \"secondary\"}\n onClick={() => handleSelectKind(\"video\")}\n disabled={!isIdle || acquiring}\n icon={<Video className=\"icon-xs\" />}\n >\n Video\n </Button>\n )}\n {canRecAudio && (\n <Button\n variant={recordKind === \"audio\" ? \"default\" : \"secondary\"}\n onClick={() => handleSelectKind(\"audio\")}\n disabled={!isIdle || acquiring}\n icon={<Mic className=\"icon-xs\" />}\n >\n Audio\n </Button>\n )}\n {canPhoto && onRequestPhoto && (\n <Button\n variant=\"secondary\"\n onClick={() => {\n onRequestPhoto();\n onOpenChange(false);\n }}\n disabled={!isIdle}\n icon={<Camera className=\"icon-xs\" />}\n >\n Photo\n </Button>\n )}\n </div>\n\n {/* Live video preview — rendered in idle+recording states for video kind */}\n {recordKind === \"video\" && !isPreview && (\n <div className=\"relative mt-2 rounded-md overflow-hidden bg-black aspect-video\">\n <video\n ref={livePreviewRef}\n className=\"w-full h-full object-contain\"\n playsInline\n muted\n />\n {acquiring && (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <Spinner size=\"lg\" label=\"Starting camera\" />\n </div>\n )}\n </div>\n )}\n\n {/* Audio waveform — live mic level (idle = ready indicator, recording = active) */}\n {recordKind === \"audio\" && !isPreview && (\n <div className=\"relative mt-2 rounded-md bg-muted p-2 text-primary\">\n <canvas\n ref={waveformCanvasRef}\n width={480}\n height={80}\n className=\"w-full h-20\"\n aria-label=\"Audio waveform\"\n />\n {acquiring && (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <Spinner size=\"lg\" label=\"Starting microphone\" />\n </div>\n )}\n </div>\n )}\n\n {error && (\n <p className=\"text-sm text-destructive\" role=\"alert\">\n {error}\n </p>\n )}\n\n {/* Recording indicator + elapsed timer */}\n {isRecording && (\n <div className=\"flex items-center gap-2 text-sm\" aria-live=\"polite\">\n <span\n className=\"inline-block h-2.5 w-2.5 rounded-full bg-red-500 animate-pulse\"\n aria-label=\"Recording\"\n />\n <span className=\"tabular-nums\">{elapsedLabel}</span>\n </div>\n )}\n\n {/* Recorded preview — only in preview state */}\n {isPreview && recordPreviewUrl && (\n <div className=\"mt-2\">\n <MediaPreview\n url={recordPreviewUrl}\n type={recordKind}\n controls\n priority\n className=\"w-full rounded-md\"\n />\n </div>\n )}\n\n <DialogFooter className=\"flex-row justify-between gap-2\">\n <Button\n variant=\"destructive\"\n onClick={() => handleDialogOpenChange(false)}\n disabled={save.pending}\n icon={<X className=\"icon-xs\" />}\n >\n Close\n </Button>\n\n {isIdle && (\n <Button\n variant=\"default\"\n onClick={() => void start.run(recordKind)}\n disabled={disabled || isLoading || acquiring}\n pending={start.pending}\n icon={recordKind === \"video\" ? <Video className=\"icon-xs\" /> : <Mic className=\"icon-xs\" />}\n >\n Start\n </Button>\n )}\n\n {isRecording && (\n <Button variant=\"default\" onClick={stopRecording}>\n Stop\n </Button>\n )}\n\n {isPreview && (\n <div className=\"flex gap-2\">\n <Button variant=\"secondary\" onClick={handleReRecord} disabled={save.pending} icon={<RotateCcw className=\"icon-xs\" />}>\n Re-record\n </Button>\n <Button\n variant=\"default\"\n onClick={() => void save.run()}\n disabled={disabled || isLoading}\n pending={save.pending}\n icon={<Check className=\"icon-xs\" />}\n >\n Save\n </Button>\n </div>\n )}\n </DialogFooter>\n </DialogContent>\n </Dialog>\n\n <AlertDialog open={discardConfirmOpen} onOpenChange={setDiscardConfirmOpen}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Discard recording?</AlertDialogTitle>\n <AlertDialogDescription>\n You have a recorded clip that hasn't been saved. Closing now will discard it.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Keep recording</AlertDialogCancel>\n <AlertDialogAction onClick={closeDialogImmediately}>\n Discard\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </>\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttt-productions/file-input",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.10",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ttt-productions/ttt-packages.git",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"prepublishOnly": "npm run clean && npm run build"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ttt-productions/ui-core": "^0.11.
|
|
34
|
+
"@ttt-productions/ui-core": "^0.11.15",
|
|
35
35
|
"@ttt-productions/media-schemas": "^0.14.5",
|
|
36
|
-
"@ttt-productions/media-viewer": "^0.10.
|
|
36
|
+
"@ttt-productions/media-viewer": "^0.10.12",
|
|
37
37
|
"react-easy-crop": "^5.5.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|