Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(tauri): add editor clips backend APIs and specta bindings
Richie McIlroy4e003440b44f
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex 976c83327..d127affb2 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -11,6 +11,7 @@ mod camera_legacy;mod camera_native;mod captions;mod cli;+mod clip_thumbnails;mod crash_sentinel;mod deeplink_actions;mod editor_window;@@ -113,8 +114,8 @@ use upload::{create_or_get_video, upload_image, upload_video};use web_api::AuthedApiError;use web_api::ManagerExt as WebManagerExt;use windows::{- CapWindowId, EditorWindowIds, ScreenshotEditorWindowIds, ShowCapWindow, hide_overlay,- set_window_transparent, show_overlay,+ CapWindowId, EditorRecordingTarget, EditorWindowIds, ScreenshotEditorWindowIds, ShowCapWindow,+ hide_overlay, set_window_transparent, show_overlay,};use crate::{recording::start_recording, upload::build_video_meta};@@ -2131,6 +2132,12 @@ pub struct NewStudioRecordingAdded {path: PathBuf,}+#[derive(Deserialize, specta::Type, Serialize, tauri_specta::Event, Debug, Clone)]+pub struct EditorRecordingAdded {+ pub editor_path: PathBuf,+ pub recording_path: PathBuf,+}+#[derive(Deserialize, specta::Type, tauri_specta::Event, Debug, Clone, Serialize)]pub struct RecordingDeleted {path: PathBuf,@@ -2851,6 +2858,16 @@ async fn get_editor_meta(editor: WindowEditorInstance) -> Result<RecordingMeta,async fn get_recording_meta_by_path(project_path: PathBuf) -> Result<RecordingMeta, String> {RecordingMeta::load_for_project(&project_path).map_err(|e| e.to_string())}++#[tauri::command]+#[specta::specta]+async fn set_editor_recording_target(+ app: AppHandle,+ project_path: Option<PathBuf>,+) -> Result<(), String> {+ EditorRecordingTarget::set(&app, project_path);+ Ok(())+}#[tauri::command]#[specta::specta]#[instrument(skip(editor))]@@ -3409,6 +3426,8 @@ pub struct RecordingMetaWithMetadata {// THESE MUST COME AFTER `inner` to override flattened fields with the same namepub mode: RecordingMode,pub status: StudioRecordingStatus,+ // Number of recorded takes (segments) the recording is made up of.+ pub clip_count: u32,}impl RecordingMetaWithMetadata {@@ -3418,6 +3437,13 @@ impl RecordingMetaWithMetadata {RecordingMetaInner::Studio(_) => RecordingMode::Studio,RecordingMetaInner::Instant(_) => RecordingMode::Instant,},+ clip_count: match &inner.inner {+ RecordingMetaInner::Studio(meta) => match &**meta {+ StudioRecordingMeta::MultipleSegments { inner } => inner.segments.len() as u32,+ StudioRecordingMeta::SingleSegment { .. } => 1,+ },+ RecordingMetaInner::Instant(_) => 1,+ },status: match &inner.inner {RecordingMetaInner::Studio(meta) => match &**meta {StudioRecordingMeta::MultipleSegments { inner } => inner@@ -3509,6 +3535,24 @@ fn list_recordings(app: AppHandle) -> Result<Vec<(PathBuf, RecordingMetaWithMetaOk(result)}+#[tauri::command]+#[specta::specta]+#[instrument(skip(app))]+async fn delete_recording_directory(app: AppHandle, path: PathBuf) -> Result<(), String> {+ let recordings_dir = recordings_path(&app);+ if !path.starts_with(&recordings_dir) {+ return Err("Path is not inside the recordings directory".to_string());+ }++ if path.exists() {+ std::fs::remove_dir_all(&path).map_err(|e| format!("Failed to delete recording: {e}"))?;+ }++ let _ = RecordingDeleted { path }.emit(&app);++ Ok(())+}+#[tauri::command]#[specta::specta]#[instrument(skip(app))]@@ -4293,6 +4337,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {is_camera_window_open,seek_to,get_display_frame_for_cropping,+ clip_thumbnails::get_clip_thumbnail,windows::position_traffic_lights,windows::set_theme,windows::apply_macos_liquid_glass_background,@@ -4307,6 +4352,8 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {set_window_transparent,get_editor_meta,get_recording_meta_by_path,+ set_editor_recording_target,+ delete_recording_directory,set_pretty_name,set_server_url,set_camera_preview_state,@@ -4347,6 +4394,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {.events(tauri_specta::collect_events![RecordingOptionsChanged,NewStudioRecordingAdded,+ EditorRecordingAdded,NewScreenshotAdded,RenderFrameEvent,EditorStateChanged,@@ -4542,6 +4590,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {app.manage(target_select_overlay::WindowFocusManager::default());app.manage(EditorWindowIds::default());app.manage(ScreenshotEditorWindowIds::default());+ app.manage(EditorRecordingTarget::default());#[cfg(target_os = "macos")]app.manage(crate::platform::ScreenCapturePrewarmer::default());#[cfg(target_os = "macos")]@@ -5812,7 +5861,7 @@ async fn create_editor_instance_impl(Ok((instance, event_id))}-async fn wait_for_recording_ready(app: &AppHandle, path: &Path) -> Result<(), String> {+pub(crate) async fn wait_for_recording_ready(app: &AppHandle, path: &Path) -> Result<(), String> {let finalizing_state = app.state::<FinalizingRecordings>();if let Some(mut rx) = finalizing_state.is_finalizing(path) {diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex a1eb5452d..072107856 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -272,6 +272,9 @@ async seekTo(frameNumber: number) : Promise<null> {async getDisplayFrameForCropping(fps: number) : Promise<number[]> {return await TAURI_INVOKE("get_display_frame_for_cropping", { fps });},+async getClipThumbnail(recordingSegment: number, time: number) : Promise<string> {+ return await TAURI_INVOKE("get_clip_thumbnail", { recordingSegment, time });+},async positionTrafficLights(controlsInset: [number, number] | null) : Promise<void> {await TAURI_INVOKE("position_traffic_lights", { controlsInset });},@@ -319,6 +322,12 @@ async getEditorMeta() : Promise<RecordingMeta> {async getRecordingMetaByPath(projectPath: string) : Promise<RecordingMeta> {return await TAURI_INVOKE("get_recording_meta_by_path", { projectPath });},+async setEditorRecordingTarget(projectPath: string | null) : Promise<null> {+ return await TAURI_INVOKE("set_editor_recording_target", { projectPath });+},+async deleteRecordingDirectory(path: string) : Promise<null> {+ return await TAURI_INVOKE("delete_recording_directory", { path });+},async setPrettyName(prettyName: string) : Promise<null> {return await TAURI_INVOKE("set_pretty_name", { prettyName });},@@ -437,6 +446,7 @@ audioInputLevelChange: AudioInputLevelChange,currentRecordingChanged: CurrentRecordingChanged,devicesUpdated: DevicesUpdated,downloadProgress: DownloadProgress,+editorRecordingAdded: EditorRecordingAdded,editorStateChanged: EditorStateChanged,newNotification: NewNotification,newScreenshotAdded: NewScreenshotAdded,@@ -463,6 +473,7 @@ audioInputLevelChange: "audio-input-level-change",currentRecordingChanged: "current-recording-changed",devicesUpdated: "devices-updated",downloadProgress: "download-progress",+editorRecordingAdded: "editor-recording-added",editorStateChanged: "editor-state-changed",newNotification: "new-notification",newScreenshotAdded: "new-screenshot-added",@@ -553,7 +564,16 @@ export type CaptionSegment = { id: string; start: number; end: number; text: strexport type CaptionSettings = { enabled: boolean; font: string; size: number; color: string; backgroundColor: string; backgroundOpacity: number; position: string; italic: boolean; fontWeight: number; outline: boolean; outlineColor: string; exportWithSubtitles: boolean; highlightColor: string; fadeDuration: number; lingerDuration: number; wordTransitionDuration: number; activeWordHighlight: boolean; manualPosition: XY<number> | null }export type CaptionTrackSegment = { id: string; start: number; end: number; text: string; words?: CaptionWord[]; fadeDurationOverride?: number | null; lingerDurationOverride?: number | null; positionOverride?: string | null; colorOverride?: string | null; backgroundColorOverride?: string | null; fontSizeOverride?: number | null }export type CaptionWord = { text: string; start: number; end: number }-export type CaptionsData = { segments: CaptionSegment[]; settings: CaptionSettings }+export type CaptionsData = { segments: CaptionSegment[]; settings: CaptionSettings;+/**+ * When true, `segments` are stored in source/recording time and the+ * rendered `timeline.caption_segments` are derived by projecting them+ * through the current edit list, so captions stay aligned to their spoken+ * content as clips are trimmed, deleted, reordered, or inserted. Legacy+ * projects (false) stored segments in already-edited output time and are+ * migrated to source time on first load.+ */+sourceTimed?: boolean }export type CaptureDisplay = { id: DisplayId; name: string; refresh_rate: number }export type CaptureDisplayWithThumbnail = { id: DisplayId; name: string; refresh_rate: number; thumbnail: string | null }export type CaptureTargetKind = "display" | "window" | "area"@@ -587,6 +607,7 @@ export type DisplayId = stringexport type DisplayInformation = { name: string | null; physical_size: PhysicalSize | null; logical_size: LogicalSize | null; logical_bounds: LogicalBounds | null; refresh_rate: string }export type DownloadProgress = { progress: number; message: string }export type EditorPreviewQuality = "quarter" | "half" | "full"+export type EditorRecordingAdded = { editor_path: string; recording_path: string }export type EditorStateChanged = { playhead_position: number }export type ExportCompression = "Maximum" | "Social" | "Web" | "Potato"export type ExportDestination = "projectFolder" | { customPath: { dir: string } }@@ -668,7 +689,7 @@ export type RecordingDeleted = { path: string }export type RecordingEvent = { variant: "Countdown"; value: number } | { variant: "Started" } | { variant: "Stopped" } | { variant: "Paused" } | { variant: "Resumed" } | { variant: "Failed"; error: string } | { variant: "InputLost"; input: RecordingInputKind } | { variant: "InputRestored"; input: RecordingInputKind } | { variant: "Degraded"; reason: string } | { variant: "Recovered" }export type RecordingInputKind = "microphone" | "camera"export type RecordingMeta = (StudioRecordingMeta | InstantRecordingMeta) & { platform?: Platform | null; pretty_name: string; sharing?: SharingMeta | null; upload?: UploadMeta | null }-export type RecordingMetaWithMetadata = ((StudioRecordingMeta | InstantRecordingMeta) & { platform?: Platform | null; pretty_name: string; sharing?: SharingMeta | null; upload?: UploadMeta | null }) & { mode: RecordingMode; status: StudioRecordingStatus }+export type RecordingMetaWithMetadata = ((StudioRecordingMeta | InstantRecordingMeta) & { platform?: Platform | null; pretty_name: string; sharing?: SharingMeta | null; upload?: UploadMeta | null }) & { mode: RecordingMode; status: StudioRecordingStatus; clip_count: number }export type RecordingMode = "studio" | "instant" | "screenshot"export type RecordingOptionsChanged = nullexport type RecordingSettingsStore = { target: ScreenCaptureTarget | null; micName: string | null; cameraId: DeviceOrModelID | null; mode: RecordingMode | null; systemAudio: boolean; organizationId: string | null; cameraDeviceSettings: { [key in string]: CameraDeviceSettings }; microphoneDeviceSettings: { [key in string]: MicrophoneDeviceSettings } }@@ -709,7 +730,7 @@ export type SystemDiagnostics = { macosVersion: MacOSVersionInfo | null; availabexport type TargetUnderCursor = { display_id: DisplayId | null; window: WindowUnderCursor | null }export type TextSegment = { start: number; end: number; track?: number; enabled?: boolean; content?: string; center?: XY<number>; size?: XY<number>; fontFamily?: string; fontSize?: number; fontWeight?: number; italic?: boolean; color?: string; fadeDuration?: number }export type TimelineConfiguration = { segments: TimelineSegment[]; zoomSegments: ZoomSegment[]; sceneSegments?: SceneSegment[]; maskSegments?: MaskSegment[]; textSegments?: TextSegment[]; captionSegments?: CaptionTrackSegment[]; keyboardSegments?: KeyboardTrackSegment[] }-export type TimelineSegment = { recordingSegment?: number; timescale: number; start: number; end: number }+export type TimelineSegment = { recordingSegment?: number; timescale: number; start: number; end: number; name?: string | null }export type TranscriptionEngine = "Whisper" | "Parakeet"export type Trigger = "screenshotTaken" | "studioRecordingFinished" | "instantRecordingFinished" | "recordingStarted" | "uploadCompleted" | "videoImported" | "recordingDeleted"export type UploadMeta = { state: "MultipartUpload"; video_id: string; file_path: string; pre_created_video: VideoUploadInfo; recording_dir: string } | { state: "SinglePartUpload"; video_id: string; recording_dir: string; file_path: string; screenshot_path: string } | { state: "SegmentUpload"; video_id: string; pre_created_video: VideoUploadInfo; recording_dir: string } | { state: "Failed"; error: string } | { state: "Complete" }