expo-pro-video-editor 0.2.6 → 0.2.7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceRecorder.d.ts","sourceRoot":"","sources":["../../src/ui/VoiceRecorder.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"VoiceRecorder.d.ts","sourceRoot":"","sources":["../../src/ui/VoiceRecorder.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAqDtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC,CAAC;AAUH;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B;;4DAEwD;IACxD,QAAQ,CAAC,EAAE;QACT,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB;;4EAEoE;QACpE,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,KAAK,IAAI,CAAC;KACnE,CAAC;IACF,mEAAmE;IACnE,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,+BA6KA"}
|
|
@@ -11,12 +11,17 @@ const styles = {
|
|
|
11
11
|
base: 'gap-4 rounded-t-2xl bg-white p-5 dark:bg-video-editor-surface',
|
|
12
12
|
variants: {
|
|
13
13
|
// For a caller embedding this inside their own sheet component (which
|
|
14
|
-
// already provides its own background
|
|
15
|
-
// painting both stacks two slightly different
|
|
16
|
-
// seam between them (this component's own
|
|
17
|
-
// the outer sheet's own themed background).
|
|
18
|
-
//
|
|
19
|
-
|
|
14
|
+
// already provides its own background, rounded top corners, and
|
|
15
|
+
// vertical spacing) — painting both stacks two slightly different
|
|
16
|
+
// surfaces with a visible seam between them (this component's own
|
|
17
|
+
// white/dark box on top of the outer sheet's own themed background).
|
|
18
|
+
// `bare` drops the background/rounding/vertical padding this
|
|
19
|
+
// component would otherwise add on top of the outer sheet's own, but
|
|
20
|
+
// keeps horizontal padding — the outer sheet only supplies its own
|
|
21
|
+
// top/bottom inset (e.g. handle spacing, safe-area), not left/right,
|
|
22
|
+
// so this content still needs its own side margins from the sheet's
|
|
23
|
+
// edges.
|
|
24
|
+
bare: { true: 'gap-4 bg-transparent px-5 py-0' },
|
|
20
25
|
},
|
|
21
26
|
}),
|
|
22
27
|
title: tv({ base: 'text-base font-semibold text-video-editor-text' }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceRecorder.js","sourceRoot":"","sources":["../../src/ui/VoiceRecorder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gCAAgC,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC5I,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC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,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EACxD;QAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,CACF,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CACjD;UAAA,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,EACnC;QAAA,EAAE,IAAI,CAAC,CACR,CACH;IAAA,EAAE,gBAAgB,CAAC,CACpB,CAAC;AACJ,CAAC","sourcesContent":["import { RecordingPresets, requestRecordingPermissionsAsync, setAudioModeAsync, useAudioRecorder, useAudioRecorderState } from 'expo-audio';\nimport { Mic, Square } from 'lucide-react-native';\nimport type { ComponentType, ReactNode } from 'react';\nimport { useEffect, useState } from 'react';\nimport { Modal, Text, TouchableOpacity, View } from 'react-native';\nimport { tv } from 'tailwind-variants';\n\nimport { RecordingIndicator } from './RecordingIndicator';\n\nconst RECORDING_OPTIONS = { ...RecordingPresets.HIGH_QUALITY, isMeteringEnabled: true };\n\nconst styles = {\n backdrop: tv({ base: 'flex-1 justify-end bg-black/45' }),\n sheet: tv({\n base: 'gap-4 rounded-t-2xl bg-white p-5 dark:bg-video-editor-surface',\n variants: {\n // For a caller embedding this inside their own sheet component (which\n // already provides its own background/padding/rounded-top-corners) —\n // painting both stacks two slightly different surfaces with a visible\n // seam between them (this component's own white/dark box on top of\n // the outer sheet's own themed background). `bare` drops all of that,\n // leaving just this component's content.\n bare: { true: 'gap-4 bg-transparent p-0' },\n },\n }),\n title: tv({ base: 'text-base font-semibold text-video-editor-text' }),\n errorText: tv({ base: 'text-center text-[13px] text-video-editor-text-muted' }),\n controlsRow: tv({ base: 'flex-row items-center justify-center gap-6 py-2' }),\n controlSpacer: tv({ base: 'w-10' }),\n recordButtonRing: tv({\n base: 'h-[76px] w-[76px] items-center justify-center rounded-full border-4 border-video-editor-border',\n variants: { disabled: { true: 'opacity-50' } },\n }),\n recordCircle: tv({\n base: 'h-[60px] w-[60px] items-center justify-center rounded-full bg-video-editor-accent',\n variants: { disabled: { true: 'bg-video-editor-bar-unplayed' } },\n }),\n discardButton: tv({\n base: 'h-10 w-10 items-center justify-center rounded-full border-[0.5px] border-video-editor-border bg-video-editor-surface',\n }),\n discardButtonText: tv({ base: 'text-base text-video-editor-text' }),\n bottomBar: tv({ base: 'flex-row items-center justify-between' }),\n cancelText: tv({ base: 'text-sm text-video-editor-text' }),\n doneButton: tv({\n base: 'h-[38px] items-center justify-center rounded-full bg-video-editor-accent px-5',\n variants: { disabled: { true: 'opacity-40' } },\n }),\n doneButtonText: tv({ base: 'text-sm font-semibold text-white' }),\n};\n\nexport type VoiceRecorderResult = {\n uri: string;\n durationSeconds: number;\n};\n\n/**\n * The container a `VoiceRecorder` presents in — defaults to a plain React\n * Native `Modal` rendered as a bottom sheet. Pass a real bottom-sheet\n * component (e.g. `@gorhom/bottom-sheet`'s `BottomSheetModal`, or a wrapper\n * like `@niibase/bottom-sheet-manager`'s `BottomSheet`) to get native sheet\n * behavior (drag-to-dismiss, snap points) instead — this package has no\n * opinion on which sheet library you use, and doesn't depend on one.\n */\nexport type VoiceRecorderContainer = ComponentType<{\n visible: boolean;\n onRequestClose: () => void;\n children: ReactNode;\n}>;\n\nfunction DefaultContainer(props: { visible: boolean; onRequestClose: () => void; children: ReactNode }) {\n return (\n <Modal visible={props.visible} transparent animationType=\"slide\" onRequestClose={props.onRequestClose}>\n <View className={styles.backdrop()}>{props.children}</View>\n </Modal>\n );\n}\n\n/**\n * A record/stop/discard/done voice recorder, presented as a bottom sheet.\n * Renders on top of whatever the caller passes as `backgroundContent` (e.g.\n * an editor's own video preview, kept alive and playing behind the sheet) —\n * or nothing, for a recorder with no visual context (e.g. a chat app).\n *\n * `progress`, if provided, drives a `RecordingIndicator` in `'filmstrip'`\n * mode (a video's own frames with a moving playhead) so the user can see a\n * fixed-length recording's end coming. Without it, the indicator falls back\n * to a live mic-amplitude waveform — no video required.\n */\nexport function VoiceRecorder(props: {\n visible: boolean;\n onCancel: () => void;\n onConfirm: (result: VoiceRecorderResult) => void;\n title?: string;\n width: number;\n backgroundContent?: ReactNode;\n /** Ties the recording indicator to a video's own playhead (filmstrip\n * mode) and auto-stops the take once the video reaches its end. Omit for\n * a plain live-amplitude waveform with no fixed end. */\n progress?: {\n videoUri: string | null;\n currentTime: number;\n totalDuration: number;\n /** Called every render while recording so the caller can drive its own\n * video player in lockstep (play on record, pause/rewind on\n * stop/discard) — this component has no video player of its own. */\n onPlaybackRequest: (action: 'play' | 'pause' | 'restart') => void;\n };\n /** Sheet container to present in — defaults to a plain `Modal`. */\n Container?: VoiceRecorderContainer;\n /**\n * Set when embedding this inside a caller-provided sheet component that\n * already supplies its own background, padding, and rounded top corners\n * (e.g. via a custom `Container`) — drops this component's own matching\n * styling so the two don't stack into two slightly different, visibly\n * seamed surfaces. Leave unset for the default `Modal` presentation.\n */\n bare?: boolean;\n}) {\n const { visible, onCancel, onConfirm, title = 'Voice-over', width, backgroundContent, progress, Container = DefaultContainer, bare = false } = props;\n const [permissionError, setPermissionError] = useState<string | null>(null);\n const [recordedUri, setRecordedUri] = useState<string | null>(null);\n const [recordedDurationSeconds, setRecordedDurationSeconds] = useState(0);\n /**\n * Where the filmstrip's played-overlay should freeze once a take is\n * stopped. The live `progress.currentTime` keeps moving after that — a\n * caller's own trim-preview effect may rewind its player once it reaches\n * the end — so the overlay needs its own frozen snapshot instead of\n * reading the live position, to stay put where the recording actually\n * ended.\n */\n const [frozenTime, setFrozenTime] = useState<number | null>(null);\n\n const recorder = useAudioRecorder(RECORDING_OPTIONS);\n const recorderState = useAudioRecorderState(recorder, 100);\n\n useEffect(() => {\n if (!visible) return;\n let cancelled = false;\n\n requestRecordingPermissionsAsync().then(async ({ granted }) => {\n if (cancelled) return;\n if (!granted) {\n setPermissionError('Microphone access is required to record.');\n return;\n }\n /**\n * The audio session defaults to `allowsRecording: false` — record()\n * rejects with RecordingDisabledException until this is set, even\n * with the OS permission already granted. `playsInSilentMode` keeps\n * any background playback and the mic recording both alive together\n * rather than one silencing the other.\n */\n await setAudioModeAsync({ allowsRecording: true, playsInSilentMode: true });\n });\n\n return () => {\n cancelled = true;\n };\n }, [visible]);\n\n /**\n * Reset to a clean slate every time the sheet opens, computed during\n * render (not an effect) since this component stays mounted across\n * open/close rather than remounting.\n */\n const [wasVisible, setWasVisible] = useState(visible);\n if (visible !== wasVisible) {\n setWasVisible(visible);\n if (visible) {\n setRecordedUri(null);\n setRecordedDurationSeconds(0);\n setFrozenTime(null);\n }\n }\n\n // Don't start playing anything until the user actually presses record.\n useEffect(() => {\n if (!visible) return;\n progress?.onPlaybackRequest('pause');\n progress?.onPlaybackRequest('restart');\n }, [visible]);\n\n async function stopRecording() {\n setFrozenTime(progress?.currentTime ?? 0);\n await recorder.stop();\n progress?.onPlaybackRequest('pause');\n setRecordedUri(recorder.uri);\n setRecordedDurationSeconds(recorderState.durationMillis / 1000);\n }\n\n async function handleToggleRecording() {\n if (recorderState.isRecording) {\n await stopRecording();\n return;\n }\n\n setRecordedUri(null);\n setFrozenTime(null);\n /**\n * Fully pause/rewind before asking AVAudioRecorder to prepare — starting\n * playback and preparing the recorder in the same tick can leave the two\n * contending for the audio session on-device (\"Failed to prepare\n * recorder\"). Only once the recorder is confirmed ready do both\n * playback and recording start together.\n */\n progress?.onPlaybackRequest('pause');\n progress?.onPlaybackRequest('restart');\n /**\n * Re-passing the preset (instead of calling prepareToRecordAsync() bare)\n * forces the native side to build a brand-new AVAudioRecorder at a fresh\n * file path every take. With no options, prepare() reuses the same\n * recorder instance from the previous take at its original file — after\n * a take had already been stopped once, re-preparing that same instance\n * produced a file with no audio data on the second take.\n */\n await recorder.prepareToRecordAsync(RECORDING_OPTIONS);\n recorder.record();\n progress?.onPlaybackRequest('play');\n }\n\n /**\n * A fixed-length recording context (e.g. narrating over a video) auto-stops\n * the take once that context reaches its end, capping it at exactly one\n * pass instead of freezing progress without ever stopping the recording.\n */\n useEffect(() => {\n if (!visible || !progress || !recorderState.isRecording) return;\n if (progress.totalDuration > 0 && progress.currentTime >= progress.totalDuration - 0.05) {\n queueMicrotask(stopRecording);\n }\n }, [visible, recorderState.isRecording, progress?.currentTime, progress?.totalDuration]);\n\n function handleDiscard() {\n setRecordedUri(null);\n setRecordedDurationSeconds(0);\n setFrozenTime(null);\n progress?.onPlaybackRequest('restart');\n progress?.onPlaybackRequest('play');\n }\n\n function handleDone() {\n if (!recordedUri) return;\n onConfirm({ uri: recordedUri, durationSeconds: recordedDurationSeconds });\n }\n\n return (\n <Container visible={visible} onRequestClose={onCancel}>\n {backgroundContent}\n <View className={styles.sheet({ bare })}>\n <Text className={styles.title()}>{title}</Text>\n\n {permissionError ? <Text className={styles.errorText()}>{permissionError}</Text> : null}\n\n {progress ? (\n <RecordingIndicator\n mode=\"filmstrip\"\n uri={progress.videoUri}\n durationSeconds={progress.totalDuration}\n currentTime={frozenTime ?? progress.currentTime}\n width={width}\n />\n ) : (\n <RecordingIndicator mode=\"waveform\" metering={recorderState.metering} isRecording={recorderState.isRecording} width={width} />\n )}\n\n <View className={styles.controlsRow()}>\n {recordedUri ? (\n <>\n <View className={styles.controlSpacer()} />\n <RecordButton isRecording={false} disabled onPress={handleToggleRecording} />\n <TouchableOpacity className={styles.discardButton()} onPress={handleDiscard}>\n <Text className={styles.discardButtonText()}>✕</Text>\n </TouchableOpacity>\n </>\n ) : (\n <RecordButton isRecording={recorderState.isRecording} disabled={!!permissionError} onPress={handleToggleRecording} />\n )}\n </View>\n\n <View className={styles.bottomBar()}>\n <TouchableOpacity onPress={onCancel}>\n <Text className={styles.cancelText()}>Cancel</Text>\n </TouchableOpacity>\n <TouchableOpacity className={styles.doneButton({ disabled: !recordedUri })} onPress={handleDone} disabled={!recordedUri}>\n <Text className={styles.doneButtonText()}>Done</Text>\n </TouchableOpacity>\n </View>\n </View>\n </Container>\n );\n}\n\nconst ICON_COLOR = '#ffffff';\n\nfunction RecordButton(props: { isRecording: boolean; disabled: boolean; onPress: () => void }) {\n const { isRecording, disabled, onPress } = props;\n return (\n <TouchableOpacity className={styles.recordButtonRing({ disabled })} onPress={onPress} disabled={disabled}>\n {isRecording ? (\n <View className={styles.recordCircle()}>\n <Square size={20} color={ICON_COLOR} fill={ICON_COLOR} />\n </View>\n ) : (\n <View className={styles.recordCircle({ disabled })}>\n <Mic size={26} color={ICON_COLOR} />\n </View>\n )}\n </TouchableOpacity>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"VoiceRecorder.js","sourceRoot":"","sources":["../../src/ui/VoiceRecorder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gCAAgC,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC5I,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,iBAAiB,GAAG,EAAE,GAAG,gBAAgB,CAAC,YAAY,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;AAExF,MAAM,MAAM,GAAG;IACb,QAAQ,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,gCAAgC,EAAE,CAAC;IACxD,KAAK,EAAE,EAAE,CAAC;QACR,IAAI,EAAE,+DAA+D;QACrE,QAAQ,EAAE;YACR,sEAAsE;YACtE,gEAAgE;YAChE,kEAAkE;YAClE,kEAAkE;YAClE,qEAAqE;YACrE,6DAA6D;YAC7D,qEAAqE;Y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M,CAAC,cAAc,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CACtD;UAAA,EAAE,gBAAgB,CACpB;QAAA,EAAE,IAAI,CACR;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAG,SAAS,CAAC;AAE7B,SAAS,YAAY,CAAC,KAAuE;IAC3F,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACjD,OAAO,CACL,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACvG;MAAA,CAAC,WAAW,CAAC,CAAC,CAAC,CACb,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CACrC;UAAA,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EACxD;QAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,CACF,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CACjD;UAAA,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,EACnC;QAAA,EAAE,IAAI,CAAC,CACR,CACH;IAAA,EAAE,gBAAgB,CAAC,CACpB,CAAC;AACJ,CAAC","sourcesContent":["import { RecordingPresets, requestRecordingPermissionsAsync, setAudioModeAsync, useAudioRecorder, useAudioRecorderState } from 'expo-audio';\nimport { Mic, Square } from 'lucide-react-native';\nimport type { ComponentType, ReactNode } from 'react';\nimport { useEffect, useState } from 'react';\nimport { Modal, Text, TouchableOpacity, View } from 'react-native';\nimport { tv } from 'tailwind-variants';\n\nimport { RecordingIndicator } from './RecordingIndicator';\n\nconst RECORDING_OPTIONS = { ...RecordingPresets.HIGH_QUALITY, isMeteringEnabled: true };\n\nconst styles = {\n backdrop: tv({ base: 'flex-1 justify-end bg-black/45' }),\n sheet: tv({\n base: 'gap-4 rounded-t-2xl bg-white p-5 dark:bg-video-editor-surface',\n variants: {\n // For a caller embedding this inside their own sheet component (which\n // already provides its own background, rounded top corners, and\n // vertical spacing) — painting both stacks two slightly different\n // surfaces with a visible seam between them (this component's own\n // white/dark box on top of the outer sheet's own themed background).\n // `bare` drops the background/rounding/vertical padding this\n // component would otherwise add on top of the outer sheet's own, but\n // keeps horizontal padding — the outer sheet only supplies its own\n // top/bottom inset (e.g. handle spacing, safe-area), not left/right,\n // so this content still needs its own side margins from the sheet's\n // edges.\n bare: { true: 'gap-4 bg-transparent px-5 py-0' },\n },\n }),\n title: tv({ base: 'text-base font-semibold text-video-editor-text' }),\n errorText: tv({ base: 'text-center text-[13px] text-video-editor-text-muted' }),\n controlsRow: tv({ base: 'flex-row items-center justify-center gap-6 py-2' }),\n controlSpacer: tv({ base: 'w-10' }),\n recordButtonRing: tv({\n base: 'h-[76px] w-[76px] items-center justify-center rounded-full border-4 border-video-editor-border',\n variants: { disabled: { true: 'opacity-50' } },\n }),\n recordCircle: tv({\n base: 'h-[60px] w-[60px] items-center justify-center rounded-full bg-video-editor-accent',\n variants: { disabled: { true: 'bg-video-editor-bar-unplayed' } },\n }),\n discardButton: tv({\n base: 'h-10 w-10 items-center justify-center rounded-full border-[0.5px] border-video-editor-border bg-video-editor-surface',\n }),\n discardButtonText: tv({ base: 'text-base text-video-editor-text' }),\n bottomBar: tv({ base: 'flex-row items-center justify-between' }),\n cancelText: tv({ base: 'text-sm text-video-editor-text' }),\n doneButton: tv({\n base: 'h-[38px] items-center justify-center rounded-full bg-video-editor-accent px-5',\n variants: { disabled: { true: 'opacity-40' } },\n }),\n doneButtonText: tv({ base: 'text-sm font-semibold text-white' }),\n};\n\nexport type VoiceRecorderResult = {\n uri: string;\n durationSeconds: number;\n};\n\n/**\n * The container a `VoiceRecorder` presents in — defaults to a plain React\n * Native `Modal` rendered as a bottom sheet. Pass a real bottom-sheet\n * component (e.g. `@gorhom/bottom-sheet`'s `BottomSheetModal`, or a wrapper\n * like `@niibase/bottom-sheet-manager`'s `BottomSheet`) to get native sheet\n * behavior (drag-to-dismiss, snap points) instead — this package has no\n * opinion on which sheet library you use, and doesn't depend on one.\n */\nexport type VoiceRecorderContainer = ComponentType<{\n visible: boolean;\n onRequestClose: () => void;\n children: ReactNode;\n}>;\n\nfunction DefaultContainer(props: { visible: boolean; onRequestClose: () => void; children: ReactNode }) {\n return (\n <Modal visible={props.visible} transparent animationType=\"slide\" onRequestClose={props.onRequestClose}>\n <View className={styles.backdrop()}>{props.children}</View>\n </Modal>\n );\n}\n\n/**\n * A record/stop/discard/done voice recorder, presented as a bottom sheet.\n * Renders on top of whatever the caller passes as `backgroundContent` (e.g.\n * an editor's own video preview, kept alive and playing behind the sheet) —\n * or nothing, for a recorder with no visual context (e.g. a chat app).\n *\n * `progress`, if provided, drives a `RecordingIndicator` in `'filmstrip'`\n * mode (a video's own frames with a moving playhead) so the user can see a\n * fixed-length recording's end coming. Without it, the indicator falls back\n * to a live mic-amplitude waveform — no video required.\n */\nexport function VoiceRecorder(props: {\n visible: boolean;\n onCancel: () => void;\n onConfirm: (result: VoiceRecorderResult) => void;\n title?: string;\n width: number;\n backgroundContent?: ReactNode;\n /** Ties the recording indicator to a video's own playhead (filmstrip\n * mode) and auto-stops the take once the video reaches its end. Omit for\n * a plain live-amplitude waveform with no fixed end. */\n progress?: {\n videoUri: string | null;\n currentTime: number;\n totalDuration: number;\n /** Called every render while recording so the caller can drive its own\n * video player in lockstep (play on record, pause/rewind on\n * stop/discard) — this component has no video player of its own. */\n onPlaybackRequest: (action: 'play' | 'pause' | 'restart') => void;\n };\n /** Sheet container to present in — defaults to a plain `Modal`. */\n Container?: VoiceRecorderContainer;\n /**\n * Set when embedding this inside a caller-provided sheet component that\n * already supplies its own background, padding, and rounded top corners\n * (e.g. via a custom `Container`) — drops this component's own matching\n * styling so the two don't stack into two slightly different, visibly\n * seamed surfaces. Leave unset for the default `Modal` presentation.\n */\n bare?: boolean;\n}) {\n const { visible, onCancel, onConfirm, title = 'Voice-over', width, backgroundContent, progress, Container = DefaultContainer, bare = false } = props;\n const [permissionError, setPermissionError] = useState<string | null>(null);\n const [recordedUri, setRecordedUri] = useState<string | null>(null);\n const [recordedDurationSeconds, setRecordedDurationSeconds] = useState(0);\n /**\n * Where the filmstrip's played-overlay should freeze once a take is\n * stopped. The live `progress.currentTime` keeps moving after that — a\n * caller's own trim-preview effect may rewind its player once it reaches\n * the end — so the overlay needs its own frozen snapshot instead of\n * reading the live position, to stay put where the recording actually\n * ended.\n */\n const [frozenTime, setFrozenTime] = useState<number | null>(null);\n\n const recorder = useAudioRecorder(RECORDING_OPTIONS);\n const recorderState = useAudioRecorderState(recorder, 100);\n\n useEffect(() => {\n if (!visible) return;\n let cancelled = false;\n\n requestRecordingPermissionsAsync().then(async ({ granted }) => {\n if (cancelled) return;\n if (!granted) {\n setPermissionError('Microphone access is required to record.');\n return;\n }\n /**\n * The audio session defaults to `allowsRecording: false` — record()\n * rejects with RecordingDisabledException until this is set, even\n * with the OS permission already granted. `playsInSilentMode` keeps\n * any background playback and the mic recording both alive together\n * rather than one silencing the other.\n */\n await setAudioModeAsync({ allowsRecording: true, playsInSilentMode: true });\n });\n\n return () => {\n cancelled = true;\n };\n }, [visible]);\n\n /**\n * Reset to a clean slate every time the sheet opens, computed during\n * render (not an effect) since this component stays mounted across\n * open/close rather than remounting.\n */\n const [wasVisible, setWasVisible] = useState(visible);\n if (visible !== wasVisible) {\n setWasVisible(visible);\n if (visible) {\n setRecordedUri(null);\n setRecordedDurationSeconds(0);\n setFrozenTime(null);\n }\n }\n\n // Don't start playing anything until the user actually presses record.\n useEffect(() => {\n if (!visible) return;\n progress?.onPlaybackRequest('pause');\n progress?.onPlaybackRequest('restart');\n }, [visible]);\n\n async function stopRecording() {\n setFrozenTime(progress?.currentTime ?? 0);\n await recorder.stop();\n progress?.onPlaybackRequest('pause');\n setRecordedUri(recorder.uri);\n setRecordedDurationSeconds(recorderState.durationMillis / 1000);\n }\n\n async function handleToggleRecording() {\n if (recorderState.isRecording) {\n await stopRecording();\n return;\n }\n\n setRecordedUri(null);\n setFrozenTime(null);\n /**\n * Fully pause/rewind before asking AVAudioRecorder to prepare — starting\n * playback and preparing the recorder in the same tick can leave the two\n * contending for the audio session on-device (\"Failed to prepare\n * recorder\"). Only once the recorder is confirmed ready do both\n * playback and recording start together.\n */\n progress?.onPlaybackRequest('pause');\n progress?.onPlaybackRequest('restart');\n /**\n * Re-passing the preset (instead of calling prepareToRecordAsync() bare)\n * forces the native side to build a brand-new AVAudioRecorder at a fresh\n * file path every take. With no options, prepare() reuses the same\n * recorder instance from the previous take at its original file — after\n * a take had already been stopped once, re-preparing that same instance\n * produced a file with no audio data on the second take.\n */\n await recorder.prepareToRecordAsync(RECORDING_OPTIONS);\n recorder.record();\n progress?.onPlaybackRequest('play');\n }\n\n /**\n * A fixed-length recording context (e.g. narrating over a video) auto-stops\n * the take once that context reaches its end, capping it at exactly one\n * pass instead of freezing progress without ever stopping the recording.\n */\n useEffect(() => {\n if (!visible || !progress || !recorderState.isRecording) return;\n if (progress.totalDuration > 0 && progress.currentTime >= progress.totalDuration - 0.05) {\n queueMicrotask(stopRecording);\n }\n }, [visible, recorderState.isRecording, progress?.currentTime, progress?.totalDuration]);\n\n function handleDiscard() {\n setRecordedUri(null);\n setRecordedDurationSeconds(0);\n setFrozenTime(null);\n progress?.onPlaybackRequest('restart');\n progress?.onPlaybackRequest('play');\n }\n\n function handleDone() {\n if (!recordedUri) return;\n onConfirm({ uri: recordedUri, durationSeconds: recordedDurationSeconds });\n }\n\n return (\n <Container visible={visible} onRequestClose={onCancel}>\n {backgroundContent}\n <View className={styles.sheet({ bare })}>\n <Text className={styles.title()}>{title}</Text>\n\n {permissionError ? <Text className={styles.errorText()}>{permissionError}</Text> : null}\n\n {progress ? (\n <RecordingIndicator\n mode=\"filmstrip\"\n uri={progress.videoUri}\n durationSeconds={progress.totalDuration}\n currentTime={frozenTime ?? progress.currentTime}\n width={width}\n />\n ) : (\n <RecordingIndicator mode=\"waveform\" metering={recorderState.metering} isRecording={recorderState.isRecording} width={width} />\n )}\n\n <View className={styles.controlsRow()}>\n {recordedUri ? (\n <>\n <View className={styles.controlSpacer()} />\n <RecordButton isRecording={false} disabled onPress={handleToggleRecording} />\n <TouchableOpacity className={styles.discardButton()} onPress={handleDiscard}>\n <Text className={styles.discardButtonText()}>✕</Text>\n </TouchableOpacity>\n </>\n ) : (\n <RecordButton isRecording={recorderState.isRecording} disabled={!!permissionError} onPress={handleToggleRecording} />\n )}\n </View>\n\n <View className={styles.bottomBar()}>\n <TouchableOpacity onPress={onCancel}>\n <Text className={styles.cancelText()}>Cancel</Text>\n </TouchableOpacity>\n <TouchableOpacity className={styles.doneButton({ disabled: !recordedUri })} onPress={handleDone} disabled={!recordedUri}>\n <Text className={styles.doneButtonText()}>Done</Text>\n </TouchableOpacity>\n </View>\n </View>\n </Container>\n );\n}\n\nconst ICON_COLOR = '#ffffff';\n\nfunction RecordButton(props: { isRecording: boolean; disabled: boolean; onPress: () => void }) {\n const { isRecording, disabled, onPress } = props;\n return (\n <TouchableOpacity className={styles.recordButtonRing({ disabled })} onPress={onPress} disabled={disabled}>\n {isRecording ? (\n <View className={styles.recordCircle()}>\n <Square size={20} color={ICON_COLOR} fill={ICON_COLOR} />\n </View>\n ) : (\n <View className={styles.recordCircle({ disabled })}>\n <Mic size={26} color={ICON_COLOR} />\n </View>\n )}\n </TouchableOpacity>\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-pro-video-editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Native video composition (trim, filters, text/image overlays, audio mixing) for Expo/React Native, adapted from pro_video_editor's AVFoundation and Media3 Transformer implementation.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
package/src/ui/VoiceRecorder.tsx
CHANGED
|
@@ -15,12 +15,17 @@ const styles = {
|
|
|
15
15
|
base: 'gap-4 rounded-t-2xl bg-white p-5 dark:bg-video-editor-surface',
|
|
16
16
|
variants: {
|
|
17
17
|
// For a caller embedding this inside their own sheet component (which
|
|
18
|
-
// already provides its own background
|
|
19
|
-
// painting both stacks two slightly different
|
|
20
|
-
// seam between them (this component's own
|
|
21
|
-
// the outer sheet's own themed background).
|
|
22
|
-
//
|
|
23
|
-
|
|
18
|
+
// already provides its own background, rounded top corners, and
|
|
19
|
+
// vertical spacing) — painting both stacks two slightly different
|
|
20
|
+
// surfaces with a visible seam between them (this component's own
|
|
21
|
+
// white/dark box on top of the outer sheet's own themed background).
|
|
22
|
+
// `bare` drops the background/rounding/vertical padding this
|
|
23
|
+
// component would otherwise add on top of the outer sheet's own, but
|
|
24
|
+
// keeps horizontal padding — the outer sheet only supplies its own
|
|
25
|
+
// top/bottom inset (e.g. handle spacing, safe-area), not left/right,
|
|
26
|
+
// so this content still needs its own side margins from the sheet's
|
|
27
|
+
// edges.
|
|
28
|
+
bare: { true: 'gap-4 bg-transparent px-5 py-0' },
|
|
24
29
|
},
|
|
25
30
|
}),
|
|
26
31
|
title: tv({ base: 'text-base font-semibold text-video-editor-text' }),
|