Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: Emoji react/comments wip + new share layout
Richie McIlroy526d8b745f65
diff --git a/apps/desktop/public/fonts/Geist-Medium.woff2 b/apps/desktop/public/fonts/Geist-Medium.woff2new file mode 100644index 000000000..76edd1051Binary files /dev/null and b/apps/desktop/public/fonts/Geist-Medium.woff2 differdiff --git a/apps/desktop/src-tauri/Cargo.lock b/apps/desktop/src-tauri/Cargo.lockindex 9799f400a..95e38907f 100644--- a/apps/desktop/src-tauri/Cargo.lock+++ b/apps/desktop/src-tauri/Cargo.lock@@ -501,6 +501,7 @@ dependencies = ["ffmpeg-sidecar","futures","image",+ "notify","regex","reqwest","serde",@@ -1369,6 +1370,15 @@ dependencies = ["percent-encoding",]+[[package]]+name = "fsevent-sys"+version = "4.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2"+dependencies = [+ "libc",+]+[[package]]name = "futf"version = "0.1.5"@@ -2103,6 +2113,26 @@ dependencies = ["cfb",]+[[package]]+name = "inotify"+version = "0.9.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff"+dependencies = [+ "bitflags 1.3.2",+ "inotify-sys",+ "libc",+]++[[package]]+name = "inotify-sys"+version = "0.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb"+dependencies = [+ "libc",+]+[[package]]name = "instant"version = "0.1.12"@@ -2259,6 +2289,26 @@ dependencies = ["treediff",]+[[package]]+name = "kqueue"+version = "1.0.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c"+dependencies = [+ "kqueue-sys",+ "libc",+]++[[package]]+name = "kqueue-sys"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b"+dependencies = [+ "bitflags 1.3.2",+ "libc",+]+[[package]]name = "kuchikiki"version = "0.8.2"@@ -2532,6 +2582,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09"dependencies = ["libc",+ "log","wasi 0.11.0+wasi-snapshot-preview1","windows-sys 0.48.0",]@@ -2650,6 +2701,25 @@ dependencies = ["minimal-lexical",]+[[package]]+name = "notify"+version = "6.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d"+dependencies = [+ "bitflags 2.4.2",+ "crossbeam-channel",+ "filetime",+ "fsevent-sys",+ "inotify",+ "kqueue",+ "libc",+ "log",+ "mio",+ "walkdir",+ "windows-sys 0.48.0",+]+[[package]]name = "notify-rust"version = "4.10.0"diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.tomlindex f8d5942cf..be062d641 100644--- a/apps/desktop/src-tauri/Cargo.toml+++ b/apps/desktop/src-tauri/Cargo.toml@@ -36,6 +36,7 @@ bytemuck = "1.14.3"regex = "1"capture = { path = "./src/capture" }image = "0.24.9"+notify = "6.1.1"[features]# this feature is used for production builds or when `devPath` points to the filesystemdiff --git a/apps/desktop/src-tauri/src/media.rs b/apps/desktop/src-tauri/src/media.rsindex cf82f63c8..6ed132775 100644--- a/apps/desktop/src-tauri/src/media.rs+++ b/apps/desktop/src-tauri/src/media.rs@@ -15,6 +15,7 @@ use tokio::sync::{mpsc, Mutex};use crate::recording::RecordingOptions;use crate::utils::{ffmpeg_path_as_str};+use crate::upload::upload_file;use capture::{Capturer, Display};const FRAME_RATE: u64 = 30;@@ -54,7 +55,7 @@ impl MediaRecorder {}pub async fn start_media_recording(&mut self, options: RecordingOptions, audio_file_path: &str, video_file_path: &str, screenshot_file_path: &str, custom_device: Option<&str>) -> Result<(), String> {- self.options = Some(options);+ self.options = Some(options.clone());let host = cpal::default_host();let devices = host.devices().expect("Failed to get devices");@@ -259,7 +260,7 @@ impl MediaRecorder {let video_start_time_clone = Arc::clone(&video_start_time);let screenshot_file_path_owned = format!("{}/screen-capture.jpg", screenshot_file_path);let capture_frame_at = Duration::from_secs(3);-+std::thread::spawn(move || {println!("Starting video recording capture thread...");@@ -272,31 +273,60 @@ impl MediaRecorder {let start_time = Instant::now();let mut time_next = Instant::now() + spf;let mut screenshot_captured: bool = false;-+while !should_stop.load(Ordering::SeqCst) {- let now = Instant::now();+ let options_clone = options.clone();+ let now = Instant::now();if now >= time_next {if now - start_time >= capture_frame_at && !screenshot_captured {if let Ok(frame) = capturer.frame() {screenshot_captured = true;- let path = Path::new(&screenshot_file_path_owned);- let mut rgba_frame: Vec<u8> = vec![0; frame.len()];- for (i, chunk) in frame.chunks_exact(4).enumerate() {- rgba_frame[i * 4] = chunk[2];- rgba_frame[i * 4 + 1] = chunk[1];- rgba_frame[i * 4 + 2] = chunk[0];- rgba_frame[i * 4 + 3] = chunk[3];- }- let image: ImageBuffer<Rgba<u8>, Vec<u8>> = ImageBuffer::from_raw(- w.try_into().unwrap(),- adjusted_height.try_into().unwrap(),- rgba_frame- ).expect("Failed to create image buffer");- image.save_with_format(&path, image::ImageFormat::Jpeg).expect("Failed to save screenshot");-- println!("Screenshot captured and saved to {:?}", path);+ let screenshot_file_path_owned_cloned = screenshot_file_path_owned.clone();+ let w_cloned = w.clone();++ let frame_clone = frame.to_vec();+ std::thread::spawn(move || {+ let mut frame_data = Vec::with_capacity(capture_size);+ let stride = frame_clone[..capture_size].len() / adjusted_height;+ let rt = tokio::runtime::Runtime::new().unwrap();++ for row in 0..h {+ let start = row * stride;+ let end = start + stride;+ let mut row_data = frame_clone[start..end].to_vec();+ for chunk in row_data.chunks_mut(4) {+ chunk.swap(0, 2);+ }+ frame_data.extend_from_slice(&row_data);+ }++ let path = Path::new(&screenshot_file_path_owned_cloned);+ let image: ImageBuffer<Rgba<u8>, Vec<u8>> = ImageBuffer::from_raw(+ w_cloned.try_into().unwrap(),+ h.try_into().unwrap(),+ frame_data+ ).expect("Failed to create image buffer");+ match image.save_with_format(&path, image::ImageFormat::Jpeg) {+ Ok(_) => {+ rt.block_on(async {+ let upload_task = tokio::spawn(upload_file(Some(options_clone), screenshot_file_path_owned_cloned.clone(), "screenshot".to_string()));+ match upload_task.await {+ Ok(result) => {+ match result {+ Ok(_) => println!("Screenshot captured and saved to {:?}", path),+ Err(e) => eprintln!("Failed to upload file: {}", e),+ }+ },+ Err(e) => eprintln!("Failed to join task: {}", e),+ }+ });+ println!("Screenshot captured and saved to {:?}", path);+ },+ Err(e) => eprintln!("Failed to save screenshot: {}", e),+ }+ });}}diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex 2305b46de..bd6e272e5 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -79,8 +79,8 @@ pub async fn start_dual_recording(state_guard.video_uploading_finished = Arc::new(AtomicBool::new(false));state_guard.audio_uploading_finished = Arc::new(AtomicBool::new(false));- let screen_upload = start_upload_loop(video_chunks_dir.clone(), Some(screenshot_dir.clone()), options.clone(), "video".to_string(), shutdown_flag.clone(), state_guard.video_uploading_finished.clone());- let audio_upload = start_upload_loop(audio_chunks_dir, None, options.clone(), "audio".to_string(), shutdown_flag.clone(), state_guard.audio_uploading_finished.clone());+ let screen_upload = start_upload_loop(video_chunks_dir.clone(), options.clone(), "video".to_string(), shutdown_flag.clone(), state_guard.video_uploading_finished.clone());+ let audio_upload = start_upload_loop(audio_chunks_dir, options.clone(), "audio".to_string(), shutdown_flag.clone(), state_guard.audio_uploading_finished.clone());drop(state_guard);@@ -147,7 +147,6 @@ fn clean_and_create_dir(dir: &Path) -> Result<(), String> {async fn start_upload_loop(chunks_dir: PathBuf,- screenshot_dir: Option<PathBuf>,options: RecordingOptions,video_type: String,shutdown_flag: Arc<AtomicBool>,@@ -155,7 +154,6 @@ async fn start_upload_loop() -> Result<(), String> {let mut watched_segments: HashSet<String> = HashSet::new();let mut is_final_loop = false;- let mut screenshot_uploaded = false;loop {let mut upload_tasks = vec![];@@ -178,7 +176,6 @@ async fn start_upload_loop(let options_clone = options.clone();let video_type_clone = video_type.clone();let segment_path_clone = segment_path.clone();- // Create a task for each file to be uploadedupload_tasks.push(tokio::spawn(async move {let filepath_str = segment_path_clone.to_str().unwrap_or_default().to_owned();println!("Uploading video for {}: {}", video_type_clone, filepath_str);@@ -188,28 +185,11 @@ async fn start_upload_loop(watched_segments.insert(segment_filename.clone());}- if let Some(screenshot_dir) = &screenshot_dir {- let screenshot_path = screenshot_dir.join("screen-capture.jpg");- if !screenshot_uploaded && screenshot_path.is_file() {- let options_clone = options.clone();- let video_type_clone = video_type.clone();- let screenshot_path_clone = screenshot_path.clone();- upload_tasks.push(tokio::spawn(async move {- let filepath_str = screenshot_path_clone.to_str().unwrap_or_default().to_owned();- println!("Uploading screenshot for {}: {}", video_type_clone, filepath_str);- tokio::time::sleep(Duration::from_secs(1)).await;- upload_file(Some(options_clone), filepath_str, "screenshot".to_string()).await.map(|_| ())- }));- screenshot_uploaded = true;- }- }-- // Await all initiated upload tasks in parallelif !upload_tasks.is_empty() {let _ = join_all(upload_tasks).await;}- tokio::time::sleep(Duration::from_millis(100)).await;+ tokio::time::sleep(Duration::from_millis(50)).await;}uploading_finished.store(true, Ordering::SeqCst);Ok(())diff --git a/apps/desktop/src/app/styles.css b/apps/desktop/src/app/styles.cssindex 5c90cacb6..cb77ebfdc 100644--- a/apps/desktop/src/app/styles.css+++ b/apps/desktop/src/app/styles.css@@ -6,6 +6,14 @@font-family: "Geist";src: url("/fonts/Geist-SemiBold.woff2") format("woff2"),url("/fonts/Geist-SemiBold.woff") format("woff");+ font-weight: 600;+ font-style: normal;+ font-display: swap;+}++@font-face {+ font-family: "Geist";+ src: url("/fonts/Geist-Medium.woff2") format("woff2");font-weight: 500;font-style: normal;font-display: swap;@@ -145,6 +153,7 @@ body {-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: antialiased;font-smooth: always;+ text-rendering: optimizeLegibility;width: 100%;height: 100%;border: none;diff --git a/apps/desktop/src/components/windows/Permissions.tsx b/apps/desktop/src/components/windows/Permissions.tsxindex dfb72a5f4..8719ae9a9 100644--- a/apps/desktop/src/components/windows/Permissions.tsx+++ b/apps/desktop/src/components/windows/Permissions.tsx@@ -80,7 +80,7 @@ export const Permissions = () => {<div className="flex items-center"><div></div><div>- <p className="font-bold text-sm capitalize">{permission}</p>+ <p className="font-semibold text-sm capitalize">{permission}</p><p className="text-xs">To share your {permission}</p></div></div>diff --git a/apps/desktop/src/components/windows/inner/Recorder.tsx b/apps/desktop/src/components/windows/inner/Recorder.tsxindex 01ec7791e..b3d69410c 100644--- a/apps/desktop/src/components/windows/inner/Recorder.tsx+++ b/apps/desktop/src/components/windows/inner/Recorder.tsx@@ -33,6 +33,7 @@ export const Recorder = () => {useState("Stopping Recording");const [recordingTime, setRecordingTime] = useState("00:00");const [canStopRecording, setCanStopRecording] = useState(false);+ const [hasStartedRecording, setHasStartedRecording] = useState(false);const handleContextClick = async (option: string) => {const { showMenu } = await import("tauri-plugin-context-menu");@@ -135,9 +136,14 @@ export const Recorder = () => {aws_region: string;aws_bucket: string;}) => {+ if (hasStartedRecording) {+ console.log("Recording has already started.");+ return;+ }console.log("Starting dual recording...");setIsRecording(true);setStartingRecording(false);+ setHasStartedRecording(true);await invoke("start_dual_recording", {options: {user_id: videoData.user_id,@@ -166,7 +172,6 @@ export const Recorder = () => {} catch (error) {console.error("Error starting recordings:", error);setStartingRecording(false);- // setCountdownActive(false);}};@@ -194,7 +199,7 @@ export const Recorder = () => {await openLinkInBrowser(url);setIsRecording(false);- // setCountdownActive(false);+ setHasStartedRecording(false);setStoppingRecording(false);} catch (error) {console.error("Error stopping recording:", error);diff --git a/apps/web/app/share/[videoId]/Share.tsx b/apps/web/app/share/[videoId]/Share.tsxindex fcbb418fa..166bb3575 100644--- a/apps/web/app/share/[videoId]/Share.tsx+++ b/apps/web/app/share/[videoId]/Share.tsx@@ -1,6 +1,5 @@"use client";-import moment from "moment";import { ShareHeader } from "./_components/ShareHeader";import { ShareVideo } from "./_components/ShareVideo";import { videos } from "@cap/database/schema";@@ -19,16 +18,8 @@ export const Share = ({<div className="space-y-6"><ShareHeader data={data} /><ShareVideo data={data} />- <div className="flex items-center justify-between">- <div>- <h1 className="text-2xl">{data.name}</h1>- <p className="text-gray-400">- about {moment(data.createdAt).fromNow()}- </p>- </div>- <div className="flex">- <Toolbar />- </div>+ <div className="flex justify-center">+ <Toolbar /></div></div></div>diff --git a/apps/web/app/share/[videoId]/_components/ShareHeader.tsx b/apps/web/app/share/[videoId]/_components/ShareHeader.tsxindex 4ced0ab83..6c3ae4544 100644--- a/apps/web/app/share/[videoId]/_components/ShareHeader.tsx+++ b/apps/web/app/share/[videoId]/_components/ShareHeader.tsx@@ -1,15 +1,24 @@-import { Logo } from "@cap/ui";+import { LogoBadge } from "@cap/ui";import { videos } from "@cap/database/schema";+import moment from "moment";export const ShareHeader = ({ data }: { data: typeof videos.$inferSelect }) => {return (<div>- <div>- <div className="flex items-center space-x-1">- <Logo className="w-[75px] h-auto" />- <span className="text-[9px] font-medium text-gray-400">- v{process.env.appVersion}- </span>+ <div className="flex items-center space-x-6">+ <div>+ <a+ href={`${process.env.NEXT_PUBLIC_URL}?referrer=${data.id}`}+ target="_blank"+ >+ <LogoBadge className="w-8 h-auto" />+ </a>+ </div>+ <div>+ <h1 className="text-2xl">{data.name}</h1>+ <p className="text-gray-400 text-sm">+ about {moment(data.createdAt).fromNow()}+ </p></div></div></div>diff --git a/apps/web/app/share/[videoId]/_components/Toolbar.tsx b/apps/web/app/share/[videoId]/_components/Toolbar.tsxindex b30fdfc84..52ae61412 100644--- a/apps/web/app/share/[videoId]/_components/Toolbar.tsx+++ b/apps/web/app/share/[videoId]/_components/Toolbar.tsx@@ -1,6 +1,8 @@"use client";import { useEffect, useRef, useState } from "react";+import { MessageSquare } from "lucide-react";+// million-ignoreexport const Toolbar = () => {const [currentEmoji, setCurrentEmoji] = useState<{emoji: string;@@ -58,7 +60,7 @@ export const Toolbar = () => {return (<>- <div className="bg-white border border-gray-300 rounded-full mx-auto mt-4 mb-4">+ <div className="bg-white border border-gray-200 rounded-full mx-auto shadow-lg"><div className="grid items-center justify-start"><div className="p-2"><div className="grid items-center justify-start grid-flow-col">@@ -69,6 +71,13 @@ export const Toolbar = () => {label={reaction.label}/>))}+ <div className="w-[2px] bg-gray-200 h-full mx-2"></div>+ <div className="flex items-center">+ <button className="text-sm font-medium bg-transparent py-1 px-2 relative transition-bg-color duration-600 flex justify-center items-center rounded-full ease-in-out hover:bg-gray-200 active:bg-gray-400 active:duration-0">+ <MessageSquare className="w-[22px] h-auto" />+ <span className="ml-1">Comment</span>+ </button>+ </div></div></div></div>diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex f6ea6bc9f..ae2b166e9 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -27,6 +27,7 @@"react-dom": "^18.2.0","react-router-dom": "^6.18.0","tailwindcss": "^3.3.3",+ "tailwindcss-animate": "^1.0.6","tauri-plugin-context-menu": "^0.5.0","tauri-plugin-positioner-api": "^0.2.7","tsconfig": "workspace:*",diff --git a/packages/ui/style/tailwind.config.js b/packages/ui/style/tailwind.config.jsindex 16b91e89b..62f80da57 100644--- a/packages/ui/style/tailwind.config.js+++ b/packages/ui/style/tailwind.config.js@@ -8,6 +8,18 @@ module.exports = function (app, options) {"../../packages/*/src/**/*.{ts,tsx,html,stories.tsx}",],theme: {+ fontWeight: {+ thin: "300",+ hairline: "300",+ extralight: "300",+ light: "300",+ normal: "400",+ medium: "500",+ semibold: "600",+ bold: "600",+ extrabold: "600",+ "extra-bold": "600",+ },extend: {colors: {border: "hsl(var(--border))",@@ -65,9 +77,24 @@ module.exports = function (app, options) {fontFamily: {primary: ["Geist", "sans-serif"],},+ keyframes: {+ flyEmoji: {+ "0%": {+ transform: "translateY(0) scale(1)",+ opacity: "0.7",+ },+ "100%": {+ transform: "translateY(-150px) scale(2)",+ opacity: "0",+ },+ },+ },+ animation: {+ flyEmoji: "flyEmoji 1s forwards",+ },},},- plugins: [],+ plugins: [require("tailwindcss-animate")],};return config;};diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex f884f9e07..7f59c96ad 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -441,6 +441,9 @@ importers:tailwindcss:specifier: ^3.3.3version: 3.4.1+ tailwindcss-animate:+ specifier: ^1.0.6+ version: 1.0.7([email protected])tauri-plugin-context-menu:specifier: ^0.5.0version: 0.5.0@@ -9320,6 +9323,14 @@ packages:'@babel/runtime': 7.23.8dev: false+ resolution: {integrity: sha512-bl6mpH3T7I3UFxuvDEXLxy/VuFxBk5bbzplh7tXI68mwMokNYd1t9qPBHlnyTwfa4JGC4zP516I1hYYtQ/vspA==}+ peerDependencies:+ tailwindcss: '>=3.0.0 || insiders'+ dependencies:+ tailwindcss: 3.4.1+ dev: true+resolution: {integrity: sha512-qAYmXRfk3ENzuPBakNK0SRrUDipP8NQnEY6772uDhflcQz5EhRdD7JNZxyrFHVQNCwULPBn6FNPp9brpO7ctcA==}engines: {node: '>=14.0.0'}