Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(desktop): add render_screenshot_project_for_export command
Richie McIlroyad64ee0e0bee
diff --git a/apps/desktop/src-tauri/src/screenshot_editor.rs b/apps/desktop/src-tauri/src/screenshot_editor.rsindex cdbd1bc02..19e24b7b8 100644--- a/apps/desktop/src-tauri/src/screenshot_editor.rs+++ b/apps/desktop/src-tauri/src/screenshot_editor.rs@@ -102,7 +102,7 @@ impl<'de, R: Runtime> CommandArg<'de, R> for WindowScreenshotEditorInstance {}impl ScreenshotEditorInstances {- async fn create_instance(+ async fn create_standalone_instance(app_handle: &AppHandle,path: PathBuf,) -> Result<Arc<ScreenshotEditorInstance>, String> {@@ -517,7 +517,7 @@ impl ScreenshotEditorInstances {}}- let instance = Self::create_instance(window.app_handle(), path).await?;+ let instance = Self::create_standalone_instance(window.app_handle(), path).await?;entry.insert(instance.clone());Ok(instance)}@@ -597,7 +597,7 @@ impl PendingScreenshotEditorInstances {}tokio::spawn(async move {- let result = ScreenshotEditorInstances::create_instance(&app, path).await;+ let result = ScreenshotEditorInstances::create_standalone_instance(&app, path).await;tx.send(Some(result)).ok();});}@@ -703,6 +703,15 @@ pub struct SerializedScreenshotEditorInstance {pub image_height: u32,}+#[derive(Serialize, Type, Debug)]+#[serde(rename_all = "camelCase")]+pub struct ScreenshotProjectExport {+ pub image_bytes: Vec<u8>,+ pub config: ProjectConfiguration,+ pub image_width: u32,+ pub image_height: u32,+}+#[derive(Clone, Copy, Deserialize, Serialize, Type, Debug)]#[serde(rename_all = "camelCase")]pub struct ScreenshotOcrRegion {@@ -1453,6 +1462,30 @@ pub async fn render_screenshot_for_export(render_screenshot_png(&instance).await}+#[tauri::command]+#[specta::specta]+pub async fn render_screenshot_project_for_export(+ app: AppHandle,+ path: PathBuf,+) -> Result<ScreenshotProjectExport, String> {+ let instance = ScreenshotEditorInstances::create_standalone_instance(&app, path).await?;+ let config = instance.config_tx.borrow().config.clone();+ let image_width = instance.image_width;+ let image_height = instance.image_height;++ let result =+ render_screenshot_png(&instance)+ .await+ .map(|image_bytes| ScreenshotProjectExport {+ image_bytes,+ config,+ image_width,+ image_height,+ });+ instance.dispose().await;+ result+}+pub async fn render_screenshot_png(instance: &ScreenshotEditorInstance) -> Result<Vec<u8>, String> {let path = instance.path.clone();let config = instance.config_tx.borrow().config.clone();