Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Support multiple segments in recording meta (#177)

Brendan Allanaae824cb9bb9
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index ede86a6bb..37eb85b18 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -3,7 +3,7 @@
"type": "module",
"scripts": {
"dev": "dotenv -e ../../.env -- tauri dev",
- "localdev": "vinxi dev --port 3001",
+ "localdev": "dotenv -e ../../.env -- vinxi dev --port 3001",
"build": "vinxi build",
"tauri": "tauri"
},
@@ -34,12 +34,12 @@
"@tauri-apps/plugin-dialog": "2.0.0-rc.1",
"@tauri-apps/plugin-fs": "2.0.0-rc.0",
"@tauri-apps/plugin-http": "^2.0.1",
+ "@tauri-apps/plugin-notification": "2.0.0-rc.0",
"@tauri-apps/plugin-os": "2.0.0-rc.1",
"@tauri-apps/plugin-process": "2.0.0-rc.0",
"@tauri-apps/plugin-shell": ">=2.0.0-rc.0",
"@tauri-apps/plugin-store": "2.1.0",
"@tauri-apps/plugin-updater": "2.0.0-rc.0",
- "@tauri-apps/plugin-notification": "2.0.0-rc.0",
"@types/react-tooltip": "^4.2.4",
"cva": "npm:class-variance-authority@^0.7.0",
"effect": "^3.7.2",
@@ -59,7 +59,7 @@
"@iconify/json": "^2.2.239",
"@tauri-apps/cli": ">=2.0.0-rc.0",
"@types/dom-webcodecs": "^0.1.11",
- "typescript": "^5.2.2",
+ "typescript": "^5.7.2",
"vite": "^5.4.3",
"vite-tsconfig-paths": "^5.0.1"
}
diff --git a/apps/desktop/src-tauri/src/auth.rs b/apps/desktop/src-tauri/src/auth.rs
index 8fa536818..44d26d88f 100644
--- a/apps/desktop/src-tauri/src/auth.rs
+++ b/apps/desktop/src-tauri/src/auth.rs
@@ -1,4 +1,3 @@
-
use serde::{Deserialize, Serialize};
use serde_json::json;
use specta::Type;
diff --git a/apps/desktop/src-tauri/src/export.rs b/apps/desktop/src-tauri/src/export.rs
index cf9d481ff..615031e13 100644
--- a/apps/desktop/src-tauri/src/export.rs
+++ b/apps/desktop/src-tauri/src/export.rs
@@ -48,10 +48,9 @@ pub async fn export_video(
.ok();
},
&editor_instance.project_path,
- editor_instance.audio.clone(),
editor_instance.meta(),
editor_instance.render_constants.clone(),
- editor_instance.cursor.clone(),
+ &editor_instance.segments,
)
.await
.map_err(|e| {
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index 6e43158e7..f3eaf78b6 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -19,8 +19,8 @@ mod windows;
use audio::AppSounds;
use auth::{AuthStore, AuthenticationInvalid};
-use cap_editor::{EditorInstance, FRAMES_WS_PATH};
-use cap_editor::{EditorState, ProjectRecordings};
+use cap_editor::EditorState;
+use cap_editor::{EditorInstance, ProjectRecordings, FRAMES_WS_PATH};
use cap_media::feeds::{AudioInputFeed, AudioInputSamplesSender};
use cap_media::sources::CaptureScreen;
use cap_media::{
@@ -751,7 +751,7 @@ async fn create_editor_instance(
let project_config = editor_instance.project_config.1.borrow();
project_config.clone()
},
- recordings: editor_instance.recordings,
+ recordings: editor_instance.recordings.clone(),
path: editor_instance.project_path.clone(),
pretty_name: meta.pretty_name,
})
@@ -1320,13 +1320,16 @@ async fn take_screenshot(app: AppHandle, _state: MutableState<'_, App>) -> Resul
project_path: recording_dir.clone(),
sharing: None,
pretty_name: screenshot_name,
- display: Display {
- path: screenshot_path.clone(),
+ content: cap_project::Content::SingleSegment {
+ segment: cap_project::SingleSegment {
+ display: Display {
+ path: screenshot_path.clone(),
+ },
+ camera: None,
+ audio: None,
+ cursor: None,
+ },
},
- camera: None,
- audio: None,
- segments: vec![],
- cursor: None,
}
.save_for_project();
diff --git a/apps/desktop/src-tauri/src/platform/macos/mod.rs b/apps/desktop/src-tauri/src/platform/macos/mod.rs
index 058984b6d..c94441317 100644
--- a/apps/desktop/src-tauri/src/platform/macos/mod.rs
+++ b/apps/desktop/src-tauri/src/platform/macos/mod.rs
@@ -12,9 +12,6 @@ use objc::{class, msg_send, sel, sel_impl};
pub mod delegates;
-use specta::Type;
-use tauri_specta::Event;
-
#[derive(Debug)]
pub struct Window {
pub window_number: u32,
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rs
index bda7fe907..c4a4a4538 100644
--- a/apps/desktop/src-tauri/src/recording.rs
+++ b/apps/desktop/src-tauri/src/recording.rs
@@ -1,3 +1,5 @@
+use std::time::Instant;
+
use crate::{
audio::AppSounds,
auth::AuthStore,
@@ -12,11 +14,14 @@ use crate::{
RecordingStarted, RecordingStopped, UploadMode,
};
use cap_editor::ProjectRecordings;
+use cap_flags::FLAGS;
use cap_media::feeds::CameraFeed;
use cap_media::sources::{AVFrameCapture, CaptureScreen, CaptureWindow, ScreenCaptureSource};
-use cap_project::{ProjectConfiguration, TimelineConfiguration, TimelineSegment, ZoomSegment};
+use cap_project::{
+ Content, ProjectConfiguration, TimelineConfiguration, TimelineSegment, ZoomSegment,
+};
+use cap_recording::CompletedRecording;
use cap_rendering::ZOOM_DURATION;
-use std::time::Instant;
use tauri::{AppHandle, Manager};
use tauri_specta::Event;
@@ -120,22 +125,24 @@ pub async fn start_recording(app: AppHandle, state: MutableState<'_, App>) -> Re
#[tauri::command]
#[specta::specta]
pub async fn pause_recording(state: MutableState<'_, App>) -> Result<(), String> {
- let state = state.write().await;
+ let mut state = state.write().await;
+
+ if let Some(recording) = state.current_recording.as_mut() {
+ recording.pause().await.map_err(|e| e.to_string())?;
+ }
- // if let Some(recording) = &mut state.current_recording {
- // recording.pause().await.map_err(|e| e.to_string())?;
- // }
Ok(())
}
#[tauri::command]
#[specta::specta]
pub async fn resume_recording(state: MutableState<'_, App>) -> Result<(), String> {
- let state = state.write().await;
+ let mut state = state.write().await;
+
+ if let Some(recording) = state.current_recording.as_mut() {
+ recording.resume().await.map_err(|e| e.to_string())?;
+ }
- // if let Some(recording) = &mut state.current_recording {
- // recording.resume().await.map_err(|e| e.to_string())?;
- // }
Ok(())
}
@@ -152,7 +159,7 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
};
let now = Instant::now();
- let recording = current_recording.stop().await.map_err(|e| e.to_string())?;
+ let completed_recording = current_recording.stop().await.map_err(|e| e.to_string())?;
println!("stopped recording in {:?}", now.elapsed());
if let Some(window) = CapWindowId::InProgressRecording.get(&app) {
@@ -163,17 +170,21 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
window.unminimize().ok();
}
- let screenshots_dir = recording.recording_dir.join("screenshots");
+ let screenshots_dir = completed_recording.recording_dir.join("screenshots");
std::fs::create_dir_all(&screenshots_dir).ok();
+ let display_output_path = match &completed_recording.meta.content {
+ Content::SingleSegment { segment } => {
+ segment.path(&completed_recording.meta, &segment.display.path)
+ }
+ Content::MultipleSegments { inner } => {
+ inner.path(&completed_recording.meta, &inner.segments[0].display.path)
+ }
+ };
+
let display_screenshot = screenshots_dir.join("display.jpg");
let now = Instant::now();
- create_screenshot(
- recording.display_output_path.clone(),
- display_screenshot.clone(),
- None,
- )
- .await?;
+ create_screenshot(display_output_path, display_screenshot.clone(), None).await?;
println!("created screenshot in {:?}", now.elapsed());
// let thumbnail = screenshots_dir.join("thumbnail.png");
@@ -181,7 +192,7 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
// create_thumbnail(display_screenshot, thumbnail, (100, 100)).await?;
// println!("created thumbnail in {:?}", now.elapsed());
- let recording_dir = recording.recording_dir.clone();
+ let recording_dir = completed_recording.recording_dir.clone();
ShowCapWindow::PrevRecordings.show(&app).ok();
@@ -197,60 +208,37 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
.emit(&app)
.ok();
- let recordings = ProjectRecordings::new(&recording.meta);
- let max_duration = recordings.duration();
+ let recordings = ProjectRecordings::new(&completed_recording.meta);
let config = {
let segments = {
let mut segments = vec![];
let mut passed_duration = 0.0;
- for i in (0..recording.segments.len()).step_by(2) {
+ // multi-segment
+ // for segment in &completed_recording.segments {
+ // let start = passed_duration;
+ // passed_duration += segment.end - segment.start;
+ // segments.push(TimelineSegment {
+ // recording_segment: None,
+ // start,
+ // end: passed_duration.min(recordings.duration()),
+ // timescale: 1.0,
+ // });
+ // }
+
+ // single-segment
+ for i in (0..completed_recording.segments.len()).step_by(2) {
let start = passed_duration;
- passed_duration += recording.segments[i + 1] - recording.segments[i];
+ passed_duration +=
+ completed_recording.segments[i + 1] - completed_recording.segments[i];
segments.push(TimelineSegment {
+ recording_segment: None,
start,
end: passed_duration.min(recordings.duration()),
timescale: 1.0,
});
}
- segments
- };
-
- let zoom_segments = {
- let mut segments = vec![];
-
- const ZOOM_SEGMENT_AFTER_CLICK_PADDING: f64 = 1.5;
-
- for click in &recording.cursor_data.clicks {
- let time = click.process_time_ms / 1000.0;
-
- if segments.last().is_none() {
- segments.push(ZoomSegment {
- start: (click.process_time_ms / 1000.0 - (ZOOM_DURATION + 0.2)).max(0.0),
- end: click.process_time_ms / 1000.0 + ZOOM_SEGMENT_AFTER_CLICK_PADDING,
- amount: 2.0,
- });
- } else {
- let last_segment = segments.last_mut().unwrap();
-
- if click.down {
- if last_segment.end > time {
- last_segment.end = (time + ZOOM_SEGMENT_AFTER_CLICK_PADDING)
- .min(recordings.duration());
- } else if time < max_duration - ZOOM_DURATION {
- segments.push(ZoomSegment {
- start: (time - ZOOM_DURATION).max(0.0),
- end: time + ZOOM_SEGMENT_AFTER_CLICK_PADDING,
- amount: 2.0,
- });
- }
- } else {
- last_segment.end =
- (time + ZOOM_SEGMENT_AFTER_CLICK_PADDING).min(recordings.duration());
- }
- }
- }
segments
};
@@ -258,14 +246,17 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
ProjectConfiguration {
timeline: Some(TimelineConfiguration {
segments,
- zoom_segments,
+ zoom_segments: generate_zoom_segments_from_clicks(
+ &completed_recording,
+ &recordings,
+ ),
}),
..Default::default()
}
};
config
- .write(&recording.recording_dir)
+ .write(&completed_recording.recording_dir)
.map_err(|e| e.to_string())?;
AppSounds::StopRecording.play();
@@ -299,7 +290,7 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
export_video(
app.clone(),
- recording.id.clone(),
+ completed_recording.id.clone(),
config,
tauri::ipc::Channel::new(|_| Ok(())),
true,
@@ -310,7 +301,7 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
while retry_count < max_retries {
match upload_exported_video(
app.clone(),
- recording.id.clone(),
+ completed_recording.id.clone(),
UploadMode::Initial {
pre_created_video: Some(pre_created_video.clone()),
},
@@ -344,7 +335,7 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
});
}
} else if settings.open_editor_after_recording {
- open_editor(app.clone(), recording.id);
+ open_editor(app.clone(), completed_recording.id);
}
}
@@ -352,3 +343,51 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
Ok(())
}
+
+fn generate_zoom_segments_from_clicks(
+ recording: &CompletedRecording,
+ recordings: &ProjectRecordings,
+) -> Vec<ZoomSegment> {
+ let mut segments = vec![];
+
+ if !FLAGS.zoom {
+ return vec![];
+ };
+
+ let max_duration = recordings.duration();
+
+ const ZOOM_SEGMENT_AFTER_CLICK_PADDING: f64 = 1.5;
+
+ // single-segment only
+ for click in &recording.cursor_data.clicks {
+ let time = click.process_time_ms / 1000.0;
+
+ if segments.last().is_none() {
+ segments.push(ZoomSegment {
+ start: (click.process_time_ms / 1000.0 - (ZOOM_DURATION + 0.2)).max(0.0),
+ end: click.process_time_ms / 1000.0 + ZOOM_SEGMENT_AFTER_CLICK_PADDING,
+ amount: 2.0,
+ });
+ } else {
+ let last_segment = segments.last_mut().unwrap();
+
+ if click.down {
+ if last_segment.end > time {
+ last_segment.end =
+ (time + ZOOM_SEGMENT_AFTER_CLICK_PADDING).min(recordings.duration());
+ } else if time < max_duration - ZOOM_DURATION {
+ segments.push(ZoomSegment {
+ start: (time - ZOOM_DURATION).max(0.0),
+ end: time + ZOOM_SEGMENT_AFTER_CLICK_PADDING,
+ amount: 2.0,
+ });
+ }
+ } else {
+ last_segment.end =
+ (time + ZOOM_SEGMENT_AFTER_CLICK_PADDING).min(recordings.duration());
+ }
+ }
+ }
+
+ segments
+}
diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsx
index d2c4976d8..153bebe87 100644
--- a/apps/desktop/src/App.tsx
+++ b/apps/desktop/src/App.tsx
@@ -48,20 +48,6 @@ const queryClient = new QueryClient({
export default function App() {
const darkMode = themeStore.isDarkMode;
- onMount(async () => {
- await themeStore.initialize();
-
- const matches = useCurrentMatches();
-
- onMount(() => {
- for (const match of matches()) {
- if (match.route.info?.AUTO_SHOW_WINDOW === false) return;
- }
-
- getCurrentWindow().show();
- });
- });
-
return (
<div class={darkMode() ? "dark" : ""}>
<ErrorBoundary
@@ -85,7 +71,9 @@ export default function App() {
if (match.route.info?.AUTO_SHOW_WINDOW === false) return;
}
- getCurrentWindow().show();
+ themeStore.initialize().then(() => {
+ getCurrentWindow().show();
+ });
});
return <Suspense>{props.children}</Suspense>;
diff --git a/apps/desktop/src/routes/editor/ConfigSidebar.tsx b/apps/desktop/src/routes/editor/ConfigSidebar.tsx
index 70b6091bf..a5e2475de 100644
--- a/apps/desktop/src/routes/editor/ConfigSidebar.tsx
+++ b/apps/desktop/src/routes/editor/ConfigSidebar.tsx
@@ -91,7 +91,9 @@ export function ConfigSidebar() {
{
id: "camera" as const,
icon: IconCapCamera,
- disabled: editorInstance.recordings.camera === null,
+ disabled: editorInstance.recordings.segments.every(
+ (s) => s.camera === null
+ ),
},
// {
// id: "transcript" as const,
diff --git a/apps/desktop/src/routes/editor/Editor.tsx b/apps/desktop/src/routes/editor/Editor.tsx
index 7e209c6d0..92635f6cb 100644
--- a/apps/desktop/src/routes/editor/Editor.tsx
+++ b/apps/desktop/src/routes/editor/Editor.tsx
@@ -318,7 +318,7 @@ function Dialogs() {
size: dialog().size,
});
- const display = editorInstance.recordings.display;
+ const display = editorInstance.recordings.segments[0].display;
const styles = createMemo(() => {
return {
@@ -377,8 +377,8 @@ function Dialogs() {
setCrop({
position: { x: 0, y: 0 },
size: {
- x: editorInstance.recordings.display.width,
- y: editorInstance.recordings.display.height,
+ x: display.width,
+ y: display.height,
},
})
}
@@ -531,8 +531,7 @@ function Dialogs() {
clamp(
original.size.x + diff.x,
MIN_SIZE,
- editorInstance.recordings
- .display.width -
+ display.width -
crop.position.x
)
)
@@ -546,9 +545,7 @@ function Dialogs() {
original.position.x +
diff.x,
0,
- editorInstance.recordings
- .display.width -
- MIN_SIZE
+ display.width - MIN_SIZE
)
)
);
@@ -559,8 +556,7 @@ function Dialogs() {
clamp(
original.size.x - diff.x,
MIN_SIZE,
- editorInstance.recordings
- .display.width
+ display.width
)
)
);
@@ -574,8 +570,7 @@ function Dialogs() {
clamp(
original.size.y + diff.y,
MIN_SIZE,
- editorInstance.recordings
- .display.height -
+ display.height -
crop.position.y
)
)
@@ -589,9 +584,7 @@ function Dialogs() {
original.position.y +
diff.y,
0,
- editorInstance.recordings
- .display.height -
- MIN_SIZE
+ display.height - MIN_SIZE
)
)
);
@@ -602,8 +595,7 @@ function Dialogs() {
clamp(
original.size.y - diff.y,
MIN_SIZE,
- editorInstance.recordings
- .display.height
+ display.height
)
)
);
diff --git a/apps/desktop/src/routes/editor/Player.tsx b/apps/desktop/src/routes/editor/Player.tsx
index a37f1e577..348835ee7 100644
--- a/apps/desktop/src/routes/editor/Player.tsx
+++ b/apps/desktop/src/routes/editor/Player.tsx
@@ -118,7 +118,7 @@ export function Player() {
<EditorButton
leftIcon={<IconCapCrop />}
onClick={() => {
- const display = editorInstance.recordings.display;
+ const display = editorInstance.recordings.segments[0].display;
setDialog({
open: true,
type: "crop",
diff --git a/apps/desktop/src/routes/editor/Timeline.tsx b/apps/desktop/src/routes/editor/Timeline.tsx
index 2bddee747..b80fbd38a 100644
--- a/apps/desktop/src/routes/editor/Timeline.tsx
+++ b/apps/desktop/src/routes/editor/Timeline.tsx
@@ -18,7 +18,7 @@ import { mergeRefs } from "@solid-primitives/refs";
import { createContextProvider } from "@solid-primitives/context";
import { createMemo } from "solid-js";
-import { commands } from "~/utils/tauri";
+import { commands, TimelineSegment } from "~/utils/tauri";
import { useEditorContext } from "./context";
import { formatTime } from "./utils";
@@ -54,7 +54,9 @@ export function Timeline() {
if (!project.timeline) {
const resume = history.pause();
setProject("timeline", {
- segments: [{ timescale: 1, start: 0, end: duration() }],
+ segments: [
+ { timescale: 1, start: 0, end: duration(), recordingSegment: null },
+ ],
});
resume();
}
@@ -62,8 +64,10 @@ export function Timeline() {
const xPadding = 12;
- const segments = () =>
- project.timeline?.segments ?? [{ start: 0, end: duration(), timescale: 1 }];
+ const segments = (): Array<TimelineSegment> =>
+ project.timeline?.segments ?? [
+ { start: 0, end: duration(), timescale: 1, recordingSegment: null },
+ ];
if (window.FLAGS.zoom)
if (
@@ -73,7 +77,14 @@ export function Timeline() {
setProject(
produce((project) => {
project.timeline ??= {
- segments: [{ start: 0, end: duration(), timescale: 1 }],
+ segments: [
+ {
+ start: 0,
+ end: duration(),
+ timescale: 1,
+ recordingSegment: null,
+ },
+ ],
};
})
);
@@ -176,6 +187,7 @@ export function Timeline() {
start: splitTime,
end: segment.end,
timescale: 1,
+ recordingSegment: segment.recordingSegment,
});
segments[i()].end = splitTime;
})
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index b01b364bd..75fac8e70 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -240,6 +240,8 @@ export type HotkeyAction = "startRecording" | "stopRecording" | "restartRecordin
export type HotkeysConfiguration = { show: boolean }
export type HotkeysStore = { hotkeys: { [key in HotkeyAction]: Hotkey } }
export type JsonValue<T> = [T]
+export type MultipleSegment = { display: Display; camera?: CameraMeta | null; audio?: AudioMeta | null; cursor?: string | null }
+export type MultipleSegments = { segments: MultipleSegment[]; cursors: { [key in string]: string } }
export type NewNotification = { title: string; body: string; is_error: boolean }
export type NewRecordingAdded = { path: string }
export type NewScreenshotAdded = { path: string }
@@ -249,13 +251,12 @@ export type OSPermissionsCheck = { screenRecording: OSPermissionStatus; micropho
export type Plan = { upgraded: boolean; last_checked: number }
export type PreCreatedVideo = { id: string; link: string; config: S3UploadMeta }
export type ProjectConfiguration = { aspectRatio: AspectRatio | null; background: BackgroundConfiguration; camera: Camera; audio: AudioConfiguration; cursor: CursorConfiguration; hotkeys: HotkeysConfiguration; timeline?: TimelineConfiguration | null; motionBlur: number | null }
-export type ProjectRecordings = { display: Video; camera: Video | null; audio: Audio | null }
+export type ProjectRecordings = { segments: SegmentRecordings[] }
export type RecordingInfo = { captureTarget: ScreenCaptureTarget }
-export type RecordingMeta = { pretty_name: string; sharing?: SharingMeta | null; display: Display; camera?: CameraMeta | null; audio?: AudioMeta | null; segments?: RecordingSegment[]; cursor: string | null }
+export type RecordingMeta = ({ segment: SingleSegment } | { inner: MultipleSegments }) & { pretty_name: string; sharing?: SharingMeta | null }
export type RecordingMetaChanged = { id: string }
export type RecordingOptions = { captureTarget: ScreenCaptureTarget; cameraLabel: string | null; audioInputName: string | null }
export type RecordingOptionsChanged = null
-export type RecordingSegment = { start: number; end: number }
export type RecordingStarted = null
export type RecordingStopped = { path: string }
export type RenderFrameEvent = { frame_number: number }
@@ -267,11 +268,13 @@ export type RequestStartRecording = null
export type RequestStopRecording = null
export type S3UploadMeta = { id: string; user_id: string; aws_region?: string; aws_bucket?: string }
export type ScreenCaptureTarget = ({ variant: "window" } & CaptureWindow) | ({ variant: "screen" } & CaptureScreen)
+export type SegmentRecordings = { display: Video; camera: Video | null; audio: Audio | null }
export type SerializedEditorInstance = { framesSocketUrl: string; recordingDuration: number; savedProjectConfig: ProjectConfiguration; recordings: ProjectRecordings; path: string; prettyName: string }
export type SharingMeta = { id: string; link: string }
export type ShowCapWindow = "Setup" | "Main" | { Settings: { page: string | null } } | { Editor: { project_id: string } } | "PrevRecordings" | "WindowCaptureOccluder" | { Camera: { ws_port: number } } | { InProgressRecording: { position: [number, number] | null } } | "Upgrade"
+export type SingleSegment = { display: Display; camera?: CameraMeta | null; audio?: AudioMeta | null; cursor?: string | null }
export type TimelineConfiguration = { segments: TimelineSegment[]; zoomSegments?: ZoomSegment[] }
-export type TimelineSegment = { timescale: number; start: number; end: number }
+export type TimelineSegment = { recordingSegment: number | null; timescale: number; start: number; end: number }
export type UploadMode = { Initial: { pre_created_video: PreCreatedVideo | null } } | "Reupload"
export type UploadProgress = { stage: string; progress: number; message: string }
export type UploadResult = { Success: string } | "NotAuthenticated" | "PlanCheckFailed" | "UpgradeRequired"
diff --git a/apps/embed/package.json b/apps/embed/package.json
index 7370a8224..2905fdb53 100644
--- a/apps/embed/package.json
+++ b/apps/embed/package.json
@@ -43,7 +43,7 @@
"eslint-config-next": "14.1.0",
"postcss": "^8.4.23",
"tailwindcss": "^3",
- "typescript": "^5.3.2"
+ "typescript": "^5.7.2"
},
"engines": {
"node": "20"
diff --git a/apps/storybook/package.json b/apps/storybook/package.json
index db8668185..5fede3bf8 100644
--- a/apps/storybook/package.json
+++ b/apps/storybook/package.json
@@ -22,7 +22,7 @@
"storybook": "^8.2.7",
"storybook-solidjs": "^1.0.0-beta.2",
"storybook-solidjs-vite": "^1.0.0-beta.2",
- "typescript": "^5.2.2",
+ "typescript": "^5.7.2",
"vite": "^5.3.4",
"vite-plugin-solid": "^2.10.2"
}
diff --git a/apps/tasks/package.json b/apps/tasks/package.json
index d3386381b..ef7316e54 100644
--- a/apps/tasks/package.json
+++ b/apps/tasks/package.json
@@ -13,6 +13,13 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
+ "@types/cors": "^2.8.17",
+ "@types/express": "^4.17.21",
+ "@types/fluent-ffmpeg": "^2.1.24",
+ "@types/jest": "^29.5.12",
+ "@types/morgan": "^1.9.9",
+ "@types/node": "^20.12.6",
+ "@types/supertest": "^6.0.2",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
@@ -20,14 +27,7 @@
"helmet": "^7.1.0",
"morgan": "^1.10.0",
"ts-node": "^10.9.2",
- "typescript": "^5.4.4",
- "@types/cors": "^2.8.17",
- "@types/express": "^4.17.21",
- "@types/fluent-ffmpeg": "^2.1.24",
- "@types/jest": "^29.5.12",
- "@types/morgan": "^1.9.9",
- "@types/node": "^20.12.6",
- "@types/supertest": "^6.0.2"
+ "typescript": "^5.7.2"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.6.0",
diff --git a/apps/web/package.json b/apps/web/package.json
index 82d70c164..14a42e919 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -78,7 +78,7 @@
"eslint-config-next": "14.1.0",
"postcss": "^8.4.23",
"tailwindcss": "^3",
- "typescript": "^5.3.2"
+ "typescript": "^5.7.2"
},
"engines": {
"node": "20"
diff --git a/crates/editor/src/editor_instance.rs b/crates/editor/src/editor_instance.rs
index 7776790ea..f0eec37dc 100644
--- a/crates/editor/src/editor_instance.rs
+++ b/crates/editor/src/editor_instance.rs
@@ -2,8 +2,11 @@ use crate::editor;
use crate::playback::{self, PlaybackHandle};
use crate::project_recordings::ProjectRecordings;
use cap_media::feeds::AudioData;
-use cap_project::{CursorData, ProjectConfiguration, RecordingMeta, XY};
-use cap_rendering::{ProjectUniforms, RecordingDecoders, RenderOptions, RenderVideoConstants};
+use cap_project::{CursorEvents, ProjectConfiguration, RecordingMeta, XY};
+use cap_rendering::{
+ ProjectUniforms, RecordingSegmentDecoders, RenderOptions, RenderVideoConstants,
+ SegmentVideoPaths,
+};
use std::ops::Deref;
use std::sync::Mutex as StdMutex;
use std::{path::PathBuf, sync::Arc};
@@ -14,10 +17,7 @@ const FPS: u32 = 30;
pub struct EditorInstance {
pub project_path: PathBuf,
pub id: String,
- pub audio: Arc<Option<AudioData>>,
- pub cursor: Arc<CursorData>,
pub ws_port: u16,
- pub decoders: RecordingDecoders,
pub recordings: ProjectRecordings,
pub renderer: Arc<editor::RendererHandle>,
pub render_constants: Arc<RenderVideoConstants>,
@@ -29,6 +29,7 @@ pub struct EditorInstance {
watch::Receiver<ProjectConfiguration>,
),
ws_shutdown: Arc<StdMutex<Option<mpsc::Sender<()>>>>,
+ pub segments: Arc<Vec<Segment>>,
}
impl EditorInstance {
@@ -62,33 +63,77 @@ impl EditorInstance {
let recordings = ProjectRecordings::new(&meta);
let render_options = RenderOptions {
- screen_size: XY::new(recordings.display.width, recordings.display.height),
- camera_size: recordings
+ screen_size: XY::new(
+ recordings.segments[0].display.width,
+ recordings.segments[0].display.height,
+ ),
+ camera_size: recordings.segments[0]
.camera
.as_ref()
.map(|c| XY::new(c.width, c.height)),
};
- let audio = meta.audio.as_ref().map(|meta| {
- let audio_path = project_path.join(&meta.path);
+ let segments =
+ match &meta.content {
+ cap_project::Content::SingleSegment { segment: s } => {
+ let audio =
+ Arc::new(s.audio.as_ref().map(|meta| {
+ AudioData::from_file(project_path.join(&meta.path)).unwrap()
+ }));
+
+ let cursor = Arc::new(s.cursor_data(&meta).into());
+
+ let decoders = RecordingSegmentDecoders::new(
+ &meta,
+ SegmentVideoPaths {
+ display: s.display.path.as_path(),
+ camera: s.camera.as_ref().map(|c| c.path.as_path()),
+ },
+ );
+
+ vec![Segment {
+ audio,
+ cursor,
+ decoders,
+ }]
+ }
+ cap_project::Content::MultipleSegments { inner } => {
+ let mut segments = vec![];
+
+ for s in &inner.segments {
+ let audio = Arc::new(s.audio.as_ref().map(|meta| {
+ AudioData::from_file(project_path.join(&meta.path)).unwrap()
+ }));
+
+ let cursor = Arc::new(s.cursor_events(&meta));
+
+ let decoders = RecordingSegmentDecoders::new(
+ &meta,
+ SegmentVideoPaths {
+ display: s.display.path.as_path(),
+ camera: s.camera.as_ref().map(|c| c.path.as_path()),
+ },
+ );
+
+ segments.push(Segment {
+ audio,
+ cursor,
+ decoders,
+ });
+ }
- AudioData::from_file(audio_path).unwrap()
- });
+ segments
+ }
+ };
let (frame_tx, frame_rx) = tokio::sync::mpsc::channel(4);
let (ws_port, ws_shutdown) = create_frames_ws(frame_rx).await;
- let cursor = Arc::new(meta.cursor_data());
-
let render_constants = Arc::new(
- RenderVideoConstants::new(
- render_options,
- cursor.clone(),
- project_path.clone(), // Add project path argument
- )
- .await
- .unwrap(),
+ RenderVideoConstants::new(render_options, &meta)
+ .await
+ .unwrap(),
);
let renderer = Arc::new(editor::Renderer::spawn(render_constants.clone(), frame_tx));
@@ -98,13 +143,10 @@ impl EditorInstance {
let this = Arc::new(Self {
id: video_id,
project_path,
- decoders: RecordingDecoders::new(&meta),
recordings,
ws_port,
renderer,
render_constants,
- audio: Arc::new(audio),
- cursor,
state: Arc::new(Mutex::new(EditorState {
playhead_position: 0,
playback_task: None,
@@ -114,6 +156,7 @@ impl EditorInstance {
preview_tx,
project_config: watch::channel(meta.project_config()),
ws_shutdown: Arc::new(StdMutex::new(Some(ws_shutdown))),
+ segments: Arc::new(segments),
});
this.state.lock().await.preview_task =
@@ -154,10 +197,6 @@ impl EditorInstance {
println!("Stopping renderer");
self.renderer.stop().await;
- // Stop decoders
- println!("Stopping decoders");
- self.decoders.stop().await;
-
// // Clear audio data
// if self.audio.lock().unwrap().is_some() {
// println!("Clearing audio data");
@@ -187,11 +226,9 @@ impl EditorInstance {
let start_frame_number = state.playhead_position;
let playback_handle = playback::Playback {
- audio: Arc::clone(&self.audio),
+ segments: self.segments.clone(),
renderer: self.renderer.clone(),
render_constants: self.render_constants.clone(),
- decoders: self.decoders.clone(),
- recordings: self.recordings,
start_frame_number,
project: self.project_config.0.subscribe(),
}
@@ -241,17 +278,21 @@ impl EditorInstance {
let project = self.project_config.1.borrow().clone();
- let Some(time) = project
+ let Some((time, segment)) = project
.timeline
.as_ref()
.map(|timeline| timeline.get_recording_time(frame_number as f64 / FPS as f64))
- .unwrap_or(Some(frame_number as f64 / FPS as f64))
+ .unwrap_or(Some((frame_number as f64 / FPS as f64, None)))
else {
continue;
};
- let Some((screen_frame, camera_frame)) =
- self.decoders.get_frames((time * FPS as f64) as u32).await
+ let segment = &self.segments[segment.unwrap_or(0) as usize];
+
+ let Some((screen_frame, camera_frame)) = segment
+ .decoders
+ .get_frames((time * FPS as f64) as u32)
+ .await
else {
continue;
};
@@ -368,3 +409,9 @@ pub enum SocketMessage {
height: u32,
},
}
+
+pub struct Segment {
+ pub audio: Arc<Option<AudioData>>,
+ pub cursor: Arc<CursorEvents>,
+ pub decoders: RecordingSegmentDecoders,
+}
diff --git a/crates/editor/src/lib.rs b/crates/editor/src/lib.rs
index 4329334c5..f3b0532d1 100644
--- a/crates/editor/src/lib.rs
+++ b/crates/editor/src/lib.rs
@@ -3,5 +3,5 @@ mod editor_instance;
mod playback;
mod project_recordings;
-pub use editor_instance::{EditorInstance, EditorState, FRAMES_WS_PATH};
-pub use project_recordings::ProjectRecordings;
+pub use editor_instance::{EditorInstance, EditorState, Segment, FRAMES_WS_PATH};
+pub use project_recordings::{ProjectRecordings, SegmentRecordings};
diff --git a/crates/editor/src/playback.rs b/crates/editor/src/playback.rs
index 140117cb5..64a93799b 100644
--- a/crates/editor/src/playback.rs
+++ b/crates/editor/src/playback.rs
@@ -3,23 +3,22 @@ use std::{sync::Arc, time::Duration};
use cap_media::data::{AudioInfo, FromSampleBytes};
use cap_media::feeds::{AudioData, AudioPlaybackBuffer};
use cap_project::ProjectConfiguration;
-use cap_rendering::{ProjectUniforms, RecordingDecoders, RenderVideoConstants};
+use cap_rendering::{ProjectUniforms, RenderVideoConstants};
use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
BufferSize, SampleFormat,
};
use tokio::{sync::watch, time::Instant};
-use crate::{editor, project_recordings::ProjectRecordings};
+use crate::editor;
+use crate::editor_instance::Segment;
pub struct Playback {
- pub audio: Arc<Option<AudioData>>,
pub renderer: Arc<editor::RendererHandle>,
pub render_constants: Arc<RenderVideoConstants>,
- pub decoders: RecordingDecoders,
pub start_frame_number: u32,
pub project: watch::Receiver<ProjectConfiguration>,
- pub recordings: ProjectRecordings,
+ pub segments: Arc<Vec<Segment>>,
}
const FPS: u32 = 30;
@@ -63,16 +62,16 @@ impl Playback {
.unwrap_or(f64::MAX);
// Lock the mutex and check if audio data is available
- if let Some(audio_data) = self.audio.as_ref() {
- AudioPlayback {
- audio: audio_data.clone(),
- stop_rx: stop_rx.clone(),
- start_frame_number: self.start_frame_number,
- duration,
- project: self.project.clone(),
- }
- .spawn();
- };
+ // if let Some(audio_data) = self.audio.as_ref() {
+ // AudioPlayback {
+ // audio: audio_data.clone(),
+ // stop_rx: stop_rx.clone(),
+ // start_frame_number: self.start_frame_number,
+ // duration,
+ // project: self.project.clone(),
+ // }
+ // .spawn();
+ // };
loop {
if frame_number as f64 > FPS as f64 * duration {
@@ -81,20 +80,22 @@ impl Playback {
let project = self.project.borrow().clone();
- let time = if let Some(timeline) = project.timeline() {
+ let (time, segment) = if let Some(timeline) = project.timeline() {
match timeline.get_recording_time(frame_number as f64 / FPS as f64) {
Some(time) => time,
None => break,
}
} else {
- frame_number as f64 / FPS as f64
+ (frame_number as f64 / FPS as f64, None)
};
+ let segment = &self.segments[segment.unwrap_or(0) as usize];
+
tokio::select! {
_ = stop_rx.changed() => {
break;
},
- Some((screen_frame, camera_frame)) = self.decoders.get_frames((time * FPS as f64) as u32) => {
+ Some((screen_frame, camera_frame)) = segment.decoders.get_frames((time * FPS as f64) as u32) => {
// println!("decoded frame in {:?}", debug.elapsed());
let uniforms = ProjectUniforms::new(&self.render_constants, &project, time as f32);
diff --git a/crates/editor/src/project_recordings.rs b/crates/editor/src/project_recordings.rs
index 04906f6c9..084c7724c 100644
--- a/crates/editor/src/project_recordings.rs
+++ b/crates/editor/src/project_recordings.rs
@@ -56,32 +56,70 @@ impl Audio {
}
}
-#[derive(Debug, Clone, Copy, Serialize, Type)]
+#[derive(Debug, Clone, Serialize, Type)]
pub struct ProjectRecordings {
- pub display: Video,
- pub camera: Option<Video>,
- pub audio: Option<Audio>,
+ pub segments: Vec<SegmentRecordings>,
}
impl ProjectRecordings {
pub fn new(meta: &RecordingMeta) -> Self {
- let display = Video::new(&meta.project_path.join(&meta.display.path));
- let camera = meta
- .camera
- .as_ref()
- .map(|camera| Video::new(&meta.project_path.join(&camera.path)));
- let audio = meta
- .audio
- .as_ref()
- .map(|audio| Audio::new(&meta.project_path.join(&audio.path)));
-
- ProjectRecordings {
- display,
- camera,
- audio,
- }
+ let segments = match &meta.content {
+ cap_project::Content::SingleSegment { segment } => {
+ let display = Video::new(&meta.project_path.join(&segment.display.path));
+ let camera = segment
+ .camera
+ .as_ref()
+ .map(|camera| Video::new(&meta.project_path.join(&camera.path)));
+ let audio = segment
+ .audio
+ .as_ref()
+ .map(|audio| Audio::new(&meta.project_path.join(&audio.path)));
+
+ vec![SegmentRecordings {
+ display,
+ camera,
+ audio,
+ }]
+ }
+ cap_project::Content::MultipleSegments { inner } => inner
+ .segments
+ .iter()
+ .map(|s| {
+ let display = Video::new(&meta.project_path.join(&s.display.path));
+ let camera = s
+ .camera
+ .as_ref()
+ .map(|camera| Video::new(&meta.project_path.join(&camera.path)));
+ let audio = s
+ .audio
+ .as_ref()
+ .map(|audio| Audio::new(&meta.project_path.join(&audio.path)));
+
+ SegmentRecordings {
+ display,
+ camera,
+ audio,
+ }
+ })
+ .collect(),
+ };
+
+ Self { segments }
}
+ pub fn duration(&self) -> f64 {
+ self.segments.iter().map(|s| s.duration()).sum()
+ }
+}
+
+#[derive(Debug, Clone, Serialize, Type)]
+pub struct SegmentRecordings {
+ pub display: Video,
+ pub camera: Option<Video>,
+ pub audio: Option<Audio>,
+}
+
+impl SegmentRecordings {
pub fn duration(&self) -> f64 {
let mut duration_ns = [
Some(self.display.duration),
diff --git a/crates/export/src/lib.rs b/crates/export/src/lib.rs
index f4b41cc8c..d088382eb 100644
--- a/crates/export/src/lib.rs
+++ b/crates/export/src/lib.rs
@@ -1,10 +1,14 @@
+use cap_editor::Segment;
use image::{ImageBuffer, Rgba};
use mp4::Mp4Reader;
use std::{path::PathBuf, sync::Arc};
-use cap_media::feeds::{AudioData, AudioFrameBuffer};
-use cap_project::{CursorData, ProjectConfiguration, RecordingMeta};
-use cap_rendering::{ProjectUniforms, RecordingDecoders, RenderVideoConstants};
+use cap_media::feeds::AudioFrameBuffer;
+use cap_project::{ProjectConfiguration, RecordingMeta};
+use cap_rendering::{
+ ProjectUniforms, RecordingSegmentDecoders, RenderSegment, RenderVideoConstants,
+ SegmentVideoPaths,
+};
struct AudioRender {
buffer: AudioFrameBuffer,
@@ -33,10 +37,9 @@ pub async fn export_video_to_file(
output_path: PathBuf,
on_progress: impl Fn(u32) + Send + 'static,
project_path: &PathBuf,
- audio: Arc<Option<AudioData>>,
meta: RecordingMeta,
render_constants: Arc<RenderVideoConstants>,
- cursor: Arc<CursorData>,
+ segments: &[Segment],
) -> Result<PathBuf, ExportError> {
let (tx_image_data, mut rx_image_data) = tokio::sync::mpsc::channel::<Vec<u8>>(4);
@@ -45,6 +48,41 @@ pub async fn export_video_to_file(
let output_size = ProjectUniforms::get_output_size(&render_constants.options, &project);
+ let (render_segments, audio_segments): (Vec<_>, Vec<_>) = segments
+ .iter()
+ .enumerate()
+ .map(|(i, segment)| match &meta.content {
+ cap_project::Content::SingleSegment { segment: s } => (
+ RenderSegment {
+ cursor: segment.cursor.clone(),
+ decoders: RecordingSegmentDecoders::new(
+ &meta,
+ SegmentVideoPaths {
+ display: s.display.path.as_path(),
+ camera: s.camera.as_ref().map(|c| c.path.as_path()),
+ },
+ ),
+ },
+ segment.audio.clone(),
+ ),
+ cap_project::Content::MultipleSegments { inner } => {
+ let s = &inner.segments[i];
+
+ segment.cursor.clone();
+ RecordingSegmentDecoders::new(
+ &meta,
+ SegmentVideoPaths {
+ display: s.display.path.as_path(),
+ camera: s.camera.as_ref().map(|c| c.path.as_path()),
+ },
+ );
+ segment.audio.clone();
+
+ todo!()
+ }
+ })
+ .unzip();
+
let ffmpeg_handle = tokio::spawn({
let project = project.clone();
let project_path = project_path.clone();
@@ -54,27 +92,28 @@ pub async fn export_video_to_file(
let audio_dir = tempfile::tempdir().unwrap();
let video_dir = tempfile::tempdir().unwrap();
- let mut audio = if let Some(audio_data) = audio.as_ref() {
- let (tx, rx) = tokio::sync::mpsc::channel::<Vec<u8>>(30);
-
- let pipe_path =
- cap_utils::create_channel_named_pipe(rx, audio_dir.path().join("audio.pipe"));
-
- ffmpeg.add_input(cap_ffmpeg_cli::FFmpegRawAudioInput {
- input: pipe_path,
- sample_format: "f64le".to_string(),
- sample_rate: audio_data.info.sample_rate,
- channels: audio_data.info.channels as u16,
- });
-
- let buffer = AudioFrameBuffer::new(audio_data.clone());
- Some(AudioRender {
- buffer,
- pipe_tx: tx,
- })
- } else {
- None
- };
+ let mut audio = None::<AudioRender>;
+ // if let Some(audio_data) = audio.as_ref() {
+ // let (tx, rx) = tokio::sync::mpsc::channel::<Vec<u8>>(30);
+
+ // let pipe_path =
+ // cap_utils::create_channel_named_pipe(rx, audio_dir.path().join("audio.pipe"));
+
+ // ffmpeg.add_input(cap_ffmpeg_cli::FFmpegRawAudioInput {
+ // input: pipe_path,
+ // sample_format: "f64le".to_string(),
+ // sample_rate: audio_data.info.sample_rate,
+ // channels: audio_data.info.channels as u16,
+ // });
+
+ // let buffer = AudioFrameBuffer::new(audio_data.clone());
+ // Some(AudioRender {
+ // buffer,
+ // pipe_tx: tx,
+ // })
+ // } else {
+ // None
+ // };
let video_tx = {
let (tx, rx) = tokio::sync::mpsc::channel::<Vec<u8>>(30);
@@ -215,15 +254,12 @@ pub async fn export_video_to_file(
println!("Rendering video to channel");
- let decoders = RecordingDecoders::new(&meta);
-
cap_rendering::render_video_to_channel(
render_constants.options,
project,
tx_image_data,
- decoders,
- cursor.clone(),
- project_path.clone(),
+ &meta,
+ render_segments,
)
.await?;
diff --git a/crates/flags/src/lib.rs b/crates/flags/src/lib.rs
index bc733321b..0521c3336 100644
--- a/crates/flags/src/lib.rs
+++ b/crates/flags/src/lib.rs
@@ -8,8 +8,8 @@ pub struct Flags {
}
pub const FLAGS: Flags = Flags {
- record_mouse: false, //cfg!(debug_assertions),
- split: false,
- pause_resume: false, //cfg!(debug_assertions),
- zoom: false, //cfg!(debug_assertions),
+ record_mouse: false, // cfg!(debug_assertions),
+ split: false, // cfg!(debug_assertions),
+ pause_resume: cfg!(debug_assertions),
+ zoom: false, // cfg!(debug_assertions),
};
diff --git a/crates/media/src/feeds/audio.rs b/crates/media/src/feeds/audio.rs
index f49a65619..792be1fae 100644
--- a/crates/media/src/feeds/audio.rs
+++ b/crates/media/src/feeds/audio.rs
@@ -82,7 +82,7 @@ impl AudioFrameBuffer {
self.cursor = match maybe_timeline {
Some(timeline) => match timeline.get_recording_time(playhead) {
- Some(time) => self.playhead_to_samples(time) * self.sample_size,
+ Some((time, _)) => self.playhead_to_samples(time) * self.sample_size,
None => self.data.buffer.len(),
},
None => self.elapsed_samples * self.sample_size,
@@ -97,7 +97,7 @@ impl AudioFrameBuffer {
// (corresponding to a trim or split point). Currently this change is at least 0.2 seconds
// - not sure we offer that much precision in the editor even!
let new_cursor = match timeline.get_recording_time(playhead) {
- Some(time) => self.playhead_to_samples(time) * self.sample_size,
+ Some((time, _)) => self.playhead_to_samples(time) * self.sample_size,
None => self.data.buffer.len(),
};
diff --git a/crates/media/src/sources/screen_capture.rs b/crates/media/src/sources/screen_capture.rs
index f95158d88..fa30ea771 100644
--- a/crates/media/src/sources/screen_capture.rs
+++ b/crates/media/src/sources/screen_capture.rs
@@ -157,7 +157,7 @@ impl<T> ScreenCaptureSource<T> {
Options {
fps: self.fps,
- show_cursor: !FLAGS.zoom,
+ show_cursor: !FLAGS.record_mouse,
show_highlight: true,
excluded_targets: Some(excluded_targets),
output_type: if cfg!(windows) {
diff --git a/crates/project/src/configuration.rs b/crates/project/src/configuration.rs
index 2fd099f72..7a2de64c7 100644
--- a/crates/project/src/configuration.rs
+++ b/crates/project/src/configuration.rs
@@ -263,6 +263,7 @@ pub struct HotkeysConfiguration {
#[derive(Type, Serialize, Deserialize, Clone, Debug, Default)]
#[serde(rename_all = "camelCase")]
pub struct TimelineSegment {
+ pub recording_segment: Option<u32>,
pub timescale: f64,
pub start: f64,
pub end: f64,
@@ -300,12 +301,14 @@ pub struct TimelineConfiguration {
}
impl TimelineConfiguration {
- pub fn get_recording_time(&self, tick_time: f64) -> Option<f64> {
+ pub fn get_recording_time(&self, tick_time: f64) -> Option<(f64, Option<u32>)> {
let mut accum_duration = 0.0;
for segment in &self.segments {
if tick_time < accum_duration + segment.duration() {
- return segment.interpolate_time(tick_time - accum_duration);
+ return segment
+ .interpolate_time(tick_time - accum_duration)
+ .map(|t| (t, segment.recording_segment));
}
accum_duration += segment.duration();
diff --git a/crates/project/src/cursor.rs b/crates/project/src/cursor.rs
index 71ba686ba..41309320e 100644
--- a/crates/project/src/cursor.rs
+++ b/crates/project/src/cursor.rs
@@ -26,17 +26,42 @@ pub struct CursorClickEvent {
pub y: f64,
}
+#[derive(Default, Serialize, Deserialize, Debug, Clone)]
+#[serde(transparent)]
+pub struct CursorImages(pub HashMap<String, String>);
+
#[derive(Default, Serialize, Deserialize, Debug, Clone)]
pub struct CursorData {
pub clicks: Vec<CursorClickEvent>,
pub moves: Vec<CursorMoveEvent>,
- pub cursor_images: HashMap<String, String>,
+ pub cursor_images: CursorImages,
}
impl CursorData {
- // Add a helper method to load from a file
pub fn load_from_file(path: &Path) -> Result<Self, String> {
let file = File::open(path).map_err(|e| format!("Failed to open cursor file: {}", e))?;
serde_json::from_reader(file).map_err(|e| format!("Failed to parse cursor data: {}", e))
}
}
+
+#[derive(Default, Serialize, Deserialize, Debug, Clone)]
+pub struct CursorEvents {
+ pub clicks: Vec<CursorClickEvent>,
+ pub moves: Vec<CursorMoveEvent>,
+}
+
+impl CursorEvents {
+ pub fn load_from_file(path: &Path) -> Result<Self, String> {
+ let file = File::open(path).map_err(|e| format!("Failed to open cursor file: {}", e))?;
+ serde_json::from_reader(file).map_err(|e| format!("Failed to parse cursor data: {}", e))
+ }
+}
+
+impl From<CursorData> for CursorEvents {
+ fn from(value: CursorData) -> Self {
+ Self {
+ clicks: value.clicks,
+ moves: value.moves,
+ }
+ }
+}
diff --git a/crates/project/src/lib.rs b/crates/project/src/lib.rs
index 2d8888fee..b87168f0d 100644
--- a/crates/project/src/lib.rs
+++ b/crates/project/src/lib.rs
@@ -1,143 +1,7 @@
mod configuration;
mod cursor;
+mod meta;
pub use configuration::*;
pub use cursor::*;
-
-use either::Either;
-use serde::{Deserialize, Serialize};
-use specta::Type;
-use std::path::PathBuf;
-
-#[derive(Debug, Clone, Serialize, Deserialize, Type)]
-pub struct Display {
- pub path: PathBuf,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Type)]
-pub struct CameraMeta {
- pub path: PathBuf,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Type)]
-pub struct AudioMeta {
- pub path: PathBuf,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Type)]
-pub struct SharingMeta {
- pub id: String,
- pub link: String,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Type)]
-pub struct RecordingSegment {
- pub start: f64,
- pub end: f64,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Type)]
-pub struct RecordingMeta {
- // this field is just for convenience, it shouldn't be persisted
- #[serde(skip_serializing, default)]
- pub project_path: PathBuf,
- pub pretty_name: String,
- #[serde(default)]
- pub sharing: Option<SharingMeta>,
- pub display: Display,
- #[serde(default)]
- pub camera: Option<CameraMeta>,
- #[serde(default)]
- pub audio: Option<AudioMeta>,
- #[serde(default)]
- pub segments: Vec<RecordingSegment>,
- pub cursor: Option<PathBuf>,
-}
-
-impl RecordingMeta {
- pub fn load_for_project(project_path: &PathBuf) -> Result<Self, String> {
- let meta_path = project_path.join("recording-meta.json");
- let meta = match std::fs::read_to_string(&meta_path) {
- Ok(content) => content,
- Err(_) => {
- return Ok(Self {
- project_path: project_path.clone(),
- pretty_name: String::new(),
- sharing: None,
- display: Display {
- path: PathBuf::new(),
- },
- camera: None,
- audio: None,
- segments: Vec::new(),
- cursor: None,
- });
- }
- };
- let mut meta: Self = serde_json::from_str(&meta).map_err(|e| e.to_string())?;
- meta.project_path = project_path.clone();
- Ok(meta)
- }
-
- pub fn save_for_project(&self) -> Result<(), Either<serde_json::Error, std::io::Error>> {
- let meta_path = &self.project_path.join("recording-meta.json");
- let meta = serde_json::to_string_pretty(&self).map_err(Either::Left)?;
- std::fs::write(meta_path, meta).map_err(Either::Right)?;
- Ok(())
- }
-
- pub fn project_config(&self) -> ProjectConfiguration {
- ProjectConfiguration::load(&self.project_path).unwrap_or_default()
- }
-
- pub fn cursor_data(&self) -> CursorData {
- let Some(cursor_path) = &self.cursor else {
- return CursorData::default();
- };
-
- let full_path = self.project_path.join(cursor_path);
- println!("Loading cursor data from: {:?}", full_path);
-
- // Try to load the cursor data
- let mut data = match CursorData::load_from_file(&full_path) {
- Ok(data) => data,
- Err(e) => {
- eprintln!("Failed to load cursor data: {}", e);
- return CursorData::default();
- }
- };
-
- // If cursor_images is empty but cursor files exist, populate it
- let cursors_dir = self.project_path.join("content").join("cursors");
- if data.cursor_images.is_empty() && cursors_dir.exists() {
- println!("Scanning cursors directory: {:?}", cursors_dir);
- if let Ok(entries) = std::fs::read_dir(&cursors_dir) {
- for entry in entries {
- let Ok(entry) = entry else {
- continue;
- };
-
- let filename = entry.file_name();
- let filename_str = filename.to_string_lossy();
- if filename_str.starts_with("cursor_") && filename_str.ends_with(".png") {
- // Extract cursor ID from filename (cursor_X.png -> X)
- if let Some(id) = filename_str
- .strip_prefix("cursor_")
- .and_then(|s| s.strip_suffix(".png"))
- {
- println!("Found cursor image: {} -> {}", id, filename_str);
- data.cursor_images
- .insert(id.to_string(), filename.to_string_lossy().into_owned());
- }
- }
- }
- }
- println!("Found {} cursor images", data.cursor_images.len());
- }
- data
- }
-
- pub fn output_path(&self) -> PathBuf {
- self.project_path.join("output").join("result.mp4")
- }
-}
+pub use meta::*;
diff --git a/crates/project/src/meta.rs b/crates/project/src/meta.rs
new file mode 100644
index 000000000..f13cca564
--- /dev/null
+++ b/crates/project/src/meta.rs
@@ -0,0 +1,344 @@
+use either::Either;
+use serde::{Deserialize, Serialize};
+use specta::Type;
+use std::{
+ collections::HashMap,
+ fs::File,
+ path::{Path, PathBuf},
+};
+
+use crate::{CursorData, CursorEvents, CursorImages, ProjectConfiguration};
+
+#[derive(Debug, Clone, Serialize, Deserialize, Type)]
+pub struct Display {
+ pub path: PathBuf,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Type)]
+pub struct CameraMeta {
+ pub path: PathBuf,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Type)]
+pub struct AudioMeta {
+ pub path: PathBuf,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Type)]
+pub struct SharingMeta {
+ pub id: String,
+ pub link: String,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Type)]
+pub struct RecordingMeta {
+ // this field is just for convenience, it shouldn't be persisted
+ #[serde(skip_serializing, default)]
+ pub project_path: PathBuf,
+ pub pretty_name: String,
+ #[serde(default)]
+ pub sharing: Option<SharingMeta>,
+ #[serde(flatten)]
+ pub content: Content,
+}
+
+impl RecordingMeta {
+ pub fn load_for_project(project_path: &PathBuf) -> Result<Self, String> {
+ let meta_path = project_path.join("recording-meta.json");
+ let mut meta: Self =
+ serde_json::from_str(&std::fs::read_to_string(&meta_path).map_err(|e| e.to_string())?)
+ .map_err(|e| e.to_string())?;
+ meta.project_path = project_path.clone();
+
+ Ok(meta)
+ }
+
+ pub fn save_for_project(&self) -> Result<(), Either<serde_json::Error, std::io::Error>> {
+ let meta_path = &self.project_path.join("recording-meta.json");
+ let meta = serde_json::to_string_pretty(&self).map_err(Either::Left)?;
+ std::fs::write(meta_path, meta).map_err(Either::Right)?;
+ Ok(())
+ }
+
+ pub fn project_config(&self) -> ProjectConfiguration {
+ ProjectConfiguration::load(&self.project_path).unwrap_or_default()
+ }
+
+ pub fn output_path(&self) -> PathBuf {
+ self.project_path.join("output").join("result.mp4")
+ }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Type)]
+#[serde(untagged)]
+pub enum Content {
+ SingleSegment {
+ #[serde(flatten)]
+ segment: SingleSegment,
+ },
+ MultipleSegments {
+ #[serde(flatten)]
+ inner: MultipleSegments,
+ },
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Type)]
+pub struct SingleSegment {
+ pub display: Display,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub camera: Option<CameraMeta>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub audio: Option<AudioMeta>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub cursor: Option<PathBuf>,
+}
+
+impl SingleSegment {
+ pub fn path(&self, meta: &RecordingMeta, path: impl AsRef<Path>) -> PathBuf {
+ meta.project_path.join(path)
+ }
+
+ pub fn cursor_data(&self, meta: &RecordingMeta) -> CursorData {
+ let Some(cursor_path) = &self.cursor else {
+ return CursorData::default();
+ };
+
+ let full_path = self.path(meta, cursor_path);
+ println!("Loading cursor data from: {:?}", full_path);
+
+ // Try to load the cursor data
+ let mut data = match CursorData::load_from_file(&full_path) {
+ Ok(data) => data,
+ Err(e) => {
+ eprintln!("Failed to load cursor data: {}", e);
+ return CursorData::default();
+ }
+ };
+
+ // If cursor_images is empty but cursor files exist, populate it
+ let cursors_dir = self.path(meta, "cursors");
+ if data.cursor_images.0.is_empty() && cursors_dir.exists() {
+ println!("Scanning cursors directory: {:?}", cursors_dir);
+ if let Ok(entries) = std::fs::read_dir(&cursors_dir) {
+ for entry in entries {
+ let Ok(entry) = entry else {
+ continue;
+ };
+
+ let filename = entry.file_name();
+ let filename_str = filename.to_string_lossy();
+ if filename_str.starts_with("cursor_") && filename_str.ends_with(".png") {
+ // Extract cursor ID from filename (cursor_X.png -> X)
+ if let Some(id) = filename_str
+ .strip_prefix("cursor_")
+ .and_then(|s| s.strip_suffix(".png"))
+ {
+ println!("Found cursor image: {} -> {}", id, filename_str);
+ data.cursor_images
+ .0
+ .insert(id.to_string(), filename.to_string_lossy().into_owned());
+ }
+ }
+ }
+ }
+ println!("Found {} cursor images", data.cursor_images.0.len());
+ }
+ data
+ }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Type)]
+pub struct MultipleSegments {
+ pub segments: Vec<MultipleSegment>,
+ #[serde(default, skip_serializing_if = "HashMap::is_empty")]
+ pub cursors: HashMap<String, PathBuf>,
+}
+
+impl MultipleSegments {
+ pub fn path(&self, meta: &RecordingMeta, path: impl AsRef<Path>) -> PathBuf {
+ meta.project_path.join(path)
+ }
+
+ pub fn cursor_images(&self, meta: &RecordingMeta) -> Result<CursorImages, String> {
+ let file = File::open(self.path(meta, "content/cursors.json"))
+ .map_err(|e| format!("Failed to open cursor file: {}", e))?;
+ let cursor_images: CursorImages = serde_json::from_reader(file)
+ .map_err(|e| format!("Failed to parse cursor data: {}", e))?;
+
+ // let cursors_dir = self.path(meta, "content/cursors");
+ // if cursor_images.0.is_empty() && cursors_dir.exists() {
+ // println!("Scanning cursors directory: {:?}", cursors_dir);
+ // if let Ok(entries) = std::fs::read_dir(&cursors_dir) {
+ // for entry in entries {
+ // let Ok(entry) = entry else {
+ // continue;
+ // };
+
+ // let filename = entry.file_name();
+ // let filename_str = filename.to_string_lossy();
+ // if filename_str.starts_with("cursor_") && filename_str.ends_with(".png") {
+ // // Extract cursor ID from filename (cursor_X.png -> X)
+ // if let Some(id) = filename_str
+ // .strip_prefix("cursor_")
+ // .and_then(|s| s.strip_suffix(".png"))
+ // {
+ // println!("Found cursor image: {} -> {}", id, filename_str);
+ // cursor_images
+ // .0
+ // .insert(id.to_string(), filename.to_string_lossy().into_owned());
+ // }
+ // }
+ // }
+ // }
+ // println!("Found {} cursor images", cursor_images.0.len());
+ // }
+
+ Ok(cursor_images)
+ }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Type)]
+pub struct MultipleSegment {
+ pub display: Display,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub camera: Option<CameraMeta>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub audio: Option<AudioMeta>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub cursor: Option<PathBuf>,
+}
+
+impl MultipleSegment {
+ pub fn path(&self, meta: &RecordingMeta, path: impl AsRef<Path>) -> PathBuf {
+ meta.project_path.join(path)
+ }
+
+ pub fn cursor_events(&self, meta: &RecordingMeta) -> CursorEvents {
+ let Some(cursor_path) = &self.cursor else {
+ return CursorEvents::default();
+ };
+
+ let full_path = self.path(meta, cursor_path);
+ println!("Loading cursor data from: {:?}", full_path);
+
+ // Try to load the cursor data
+ match CursorEvents::load_from_file(&full_path) {
+ Ok(data) => data,
+ Err(e) => {
+ eprintln!("Failed to load cursor data: {}", e);
+ CursorEvents::default()
+ }
+ }
+ }
+}
+
+#[cfg(test)]
+mod test {
+ use super::RecordingMeta;
+
+ fn test_meta_deserialize(s: &str) {
+ let _: RecordingMeta = serde_json::from_str(s).unwrap();
+ }
+
+ #[test]
+ fn single_segment() {
+ test_meta_deserialize(
+ r#"{
+ "pretty_name": "Cap 2024-11-15 at 16.35.36",
+ "sharing": null,
+ "display": {
+ "path": "content/display.mp4"
+ },
+ "camera": null,
+ "audio": null,
+ "segments": [
+ {
+ "start": 0.0,
+ "end": 10.683263063430786
+ }
+ ],
+ "cursor": "cursor.json"
+ }"#,
+ );
+
+ test_meta_deserialize(
+ r#"{
+ "pretty_name": "Cap 2024-11-26 at 22.16.36",
+ "sharing": null,
+ "display": {
+ "path": "content/display.mp4"
+ },
+ "camera": {
+ "path": "content/camera.mp4"
+ },
+ "audio": {
+ "path": "content/audio-input.mp3"
+ },
+ "segments": [],
+ "cursor": "cursor.json"
+ }"#,
+ );
+ }
+
+ #[test]
+ fn multi_segment() {
+ // single segment
+ test_meta_deserialize(
+ r#"{
+ "pretty_name": "Cap 2024-11-26 at 22.29.30",
+ "sharing": null,
+ "segments": [
+ {
+ "display": {
+ "path": "content/segments/segment-0/display.mp4"
+ },
+ "camera": {
+ "path": "content/segments/segment-0/camera.mp4"
+ },
+ "audio": {
+ "path": "content/segments/segment-0/audio-input.mp3"
+ }
+ }
+ ],
+ "cursors": {
+ "0": "content/cursors/cursor_0.png",
+ "3": "content/cursors/cursor_3.png",
+ "2": "content/cursors/cursor_2.png",
+ "1": "content/cursors/cursor_1.png"
+ }
+ }"#,
+ );
+
+ // multi segment, no cursor
+ test_meta_deserialize(
+ r#"{
+ "pretty_name": "Cap 2024-11-26 at 22.32.26",
+ "sharing": null,
+ "segments": [
+ {
+ "display": {
+ "path": "content/segments/segment-0/display.mp4"
+ },
+ "camera": {
+ "path": "content/segments/segment-0/camera.mp4"
+ },
+ "audio": {
+ "path": "content/segments/segment-0/audio-input.mp3"
+ }
+ },
+ {
+ "display": {
+ "path": "content/segments/segment-1/display.mp4"
+ },
+ "camera": {
+ "path": "content/segments/segment-1/camera.mp4"
+ },
+ "audio": {
+ "path": "content/segments/segment-1/audio-input.mp3"
+ }
+ }
+ ]
+ }"#,
+ );
+ }
+}
diff --git a/crates/recording/src/actor.rs b/crates/recording/src/actor.rs
index fb11e2c5f..2a53b4ced 100644
--- a/crates/recording/src/actor.rs
+++ b/crates/recording/src/actor.rs
@@ -7,10 +7,9 @@ use cap_media::{
sources::{AudioInputSource, CameraSource, ScreenCaptureSource, ScreenCaptureTarget},
MediaError,
};
-use cap_project::{CursorClickEvent, CursorMoveEvent, RecordingMeta};
+use cap_project::RecordingMeta;
use either::Either;
use std::{
- collections::HashMap,
path::PathBuf,
sync::{atomic::AtomicBool, Arc},
time::{SystemTime, UNIX_EPOCH},
@@ -18,7 +17,10 @@ use std::{
use thiserror::Error;
use tokio::sync::{oneshot, Mutex};
-use crate::{cursor::spawn_cursor_recorder, RecordingOptions};
+use crate::{
+ cursor::{spawn_cursor_recorder, CursorActor},
+ RecordingOptions,
+};
pub enum ActorControlMessage {
Stop(oneshot::Sender<Result<CompletedRecording, RecordingError>>),
@@ -31,8 +33,7 @@ pub struct Actor {
pipeline: RecordingPipeline,
start_time: f64,
stop_signal: Arc<AtomicBool>,
- cursor_moves: oneshot::Receiver<Vec<CursorMoveEvent>>,
- cursor_clicks: oneshot::Receiver<Vec<CursorClickEvent>>,
+ cursor: Option<CursorActor>,
}
pub struct ActorHandle {
@@ -76,6 +77,14 @@ impl ActorHandle {
pub async fn stop(&self) -> Result<CompletedRecording, RecordingError> {
send_message!(self.ctrl_tx, ActorControlMessage::Stop)
}
+
+ pub async fn pause(&self) -> Result<(), RecordingError> {
+ Ok(())
+ }
+
+ pub async fn resume(&self) -> Result<(), RecordingError> {
+ Ok(())
+ }
}
pub async fn spawn_recording_actor(
@@ -107,22 +116,14 @@ pub async fn spawn_recording_actor(
let stop_signal = Arc::new(AtomicBool::new(false));
// Initialize default values for cursor channels
- let (cursor_moves, cursor_clicks) = if FLAGS.record_mouse {
+ let cursor = FLAGS.record_mouse.then(|| {
spawn_cursor_recorder(
- stop_signal.clone(),
screen_source.get_bounds(),
- content_dir,
cursors_dir,
+ Default::default(),
+ 0,
)
- } else {
- // Create dummy channels that will never receive data
- let (move_tx, move_rx) = oneshot::channel();
- let (click_tx, click_rx) = oneshot::channel();
- // Send empty vectors immediately
- move_tx.send(vec![]).unwrap();
- click_tx.send(vec![]).unwrap();
- (move_rx, click_rx)
- };
+ });
tokio::spawn({
let options = options.clone();
@@ -132,8 +133,7 @@ pub async fn spawn_recording_actor(
options,
pipeline,
start_time,
- cursor_moves,
- cursor_clicks,
+ cursor,
stop_signal,
id,
};
@@ -157,9 +157,6 @@ pub async fn spawn_recording_actor(
pub struct CompletedRecording {
pub id: String,
pub recording_dir: PathBuf,
- pub display_output_path: PathBuf,
- pub camera_output_path: Option<PathBuf>,
- pub audio_output_path: Option<PathBuf>,
pub display_source: ScreenCaptureTarget,
pub meta: RecordingMeta,
pub cursor_data: cap_project::CursorData,
@@ -178,54 +175,33 @@ async fn stop_recording(mut actor: Actor) -> Result<CompletedRecording, Recordin
"Cap {}",
chrono::Local::now().format("%Y-%m-%d at %H.%M.%S")
),
- display: Display {
- path: actor
- .pipeline
- .display_output_path
- .strip_prefix(&actor.recording_dir)
- .unwrap()
- .to_owned(),
- },
- camera: actor
- .pipeline
- .camera_output_path
- .as_ref()
- .map(|path| CameraMeta {
- path: path.strip_prefix(&actor.recording_dir).unwrap().to_owned(),
- }),
- audio: actor
- .pipeline
- .audio_output_path
- .as_ref()
- .map(|path| AudioMeta {
- path: path.strip_prefix(&actor.recording_dir).unwrap().to_owned(),
- }),
- segments: {
- let segments = [segment];
-
- let relative_segments = segments
- .iter()
- .map(|(l, r)| (l - segments[0].0, r - segments[0].0))
- .collect::<Vec<_>>();
-
- let mut segments = vec![];
-
- let mut diff = 0.0;
-
- for (i, chunk) in relative_segments.iter().enumerate() {
- if i < relative_segments.len() / 2 {
- segments.push(RecordingSegment {
- start: diff,
- end: chunk.1 - chunk.0 + diff,
- });
- }
-
- diff += chunk.1 - chunk.0;
- }
-
- segments
+ content: Content::SingleSegment {
+ segment: SingleSegment {
+ display: Display {
+ path: actor
+ .pipeline
+ .display_output_path
+ .strip_prefix(&actor.recording_dir)
+ .unwrap()
+ .to_owned(),
+ },
+ camera: actor
+ .pipeline
+ .camera_output_path
+ .as_ref()
+ .map(|path| CameraMeta {
+ path: path.strip_prefix(&actor.recording_dir).unwrap().to_owned(),
+ }),
+ audio: actor
+ .pipeline
+ .audio_output_path
+ .as_ref()
+ .map(|path| AudioMeta {
+ path: path.strip_prefix(&actor.recording_dir).unwrap().to_owned(),
+ }),
+ cursor: Some(PathBuf::from("content/cursor.json")),
+ },
},
- cursor: Some(PathBuf::from("cursor.json")),
};
actor.pipeline.inner.shutdown().await?;
@@ -234,12 +210,27 @@ async fn stop_recording(mut actor: Actor) -> Result<CompletedRecording, Recordin
.stop_signal
.store(true, std::sync::atomic::Ordering::Relaxed);
- let cursor_data = cap_project::CursorData {
- clicks: actor.cursor_clicks.await.unwrap_or_default(),
- moves: actor.cursor_moves.await.unwrap_or_default(),
- cursor_images: HashMap::new(), // This will be populated during recording
+ let cursor_data = if let Some(cursor) = actor.cursor {
+ let resp = cursor.stop().await;
+ cap_project::CursorData {
+ clicks: resp.clicks,
+ moves: resp.moves,
+ cursor_images: CursorImages(
+ resp.cursors
+ .into_values()
+ .map(|(filename, id)| (id.to_string(), filename))
+ .collect(),
+ ),
+ }
+ } else {
+ Default::default()
};
+ std::fs::write(
+ actor.recording_dir.join("content/cursor.json"),
+ serde_json::to_string_pretty(&cursor_data)?,
+ )?;
+
meta.save_for_project()
.map_err(Either::either_into::<RecordingError>)?;
@@ -248,9 +239,6 @@ async fn stop_recording(mut actor: Actor) -> Result<CompletedRecording, Recordin
meta,
cursor_data,
recording_dir: actor.recording_dir,
- display_output_path: actor.pipeline.display_output_path,
- camera_output_path: actor.pipeline.camera_output_path,
- audio_output_path: actor.pipeline.audio_output_path,
display_source: actor.options.capture_target,
segments: vec![segment.0, segment.1],
})
@@ -373,6 +361,7 @@ trait MakeCapturePipeline: 'static {
Self: Sized;
}
+#[cfg(target_os = "macos")]
impl MakeCapturePipeline for cap_media::sources::CMSampleBufferCapture {
fn make_capture_pipeline(
builder: CapturePipelineBuilder,
diff --git a/crates/recording/src/cursor.rs b/crates/recording/src/cursor.rs
index 3bb114345..80268c513 100644
--- a/crates/recording/src/cursor.rs
+++ b/crates/recording/src/cursor.rs
@@ -1,138 +1,151 @@
use std::{
collections::HashMap,
- fs::File,
+ hash::{DefaultHasher, Hash, Hasher},
path::PathBuf,
sync::{atomic::AtomicBool, Arc},
time::{Duration, Instant},
};
use cap_media::platform::Bounds;
-use cap_project::{CursorClickEvent, CursorData, CursorMoveEvent};
+use cap_project::{CursorClickEvent, CursorMoveEvent};
use device_query::{DeviceQuery, DeviceState};
use tokio::sync::oneshot;
-pub fn spawn_cursor_recorder(
+pub type Cursors = HashMap<u64, (String, i32)>;
+
+pub struct CursorActorResponse {
+ // pub cursor_images: HashMap<String, Vec<u8>>,
+ pub cursors: Cursors,
+ pub next_cursor_id: i32,
+ pub moves: Vec<CursorMoveEvent>,
+ pub clicks: Vec<CursorClickEvent>,
+}
+
+pub struct CursorActor {
stop_signal: Arc<AtomicBool>,
+ rx: oneshot::Receiver<CursorActorResponse>,
+}
+
+impl CursorActor {
+ pub async fn stop(self) -> CursorActorResponse {
+ self.stop_signal
+ .store(true, std::sync::atomic::Ordering::Relaxed);
+ self.rx.await.unwrap()
+ }
+}
+
+pub fn spawn_cursor_recorder(
screen_bounds: Bounds,
- content_dir: PathBuf,
cursors_dir: PathBuf,
-) -> (
- oneshot::Receiver<Vec<CursorMoveEvent>>,
- oneshot::Receiver<Vec<CursorClickEvent>>,
-) {
- let (move_tx, move_rx) = oneshot::channel();
- let (click_tx, click_rx) = oneshot::channel();
-
- tokio::spawn(async move {
- let device_state = DeviceState::new();
- let mut last_mouse_state = device_state.get_mouse();
- let start_time = Instant::now();
-
- let mut moves = vec![];
- let mut clicks = vec![];
- let mut cursor_images = HashMap::new();
- let mut seen_cursor_data: HashMap<Vec<u8>, String> = HashMap::new();
- let mut next_cursor_id = 0;
-
- // Create cursors directory if it doesn't exist
- std::fs::create_dir_all(&cursors_dir).unwrap();
-
- while !stop_signal.load(std::sync::atomic::Ordering::Relaxed) {
- let mouse_state = device_state.get_mouse();
- let elapsed = start_time.elapsed().as_secs_f64() * 1000.0;
- let unix_time = chrono::Utc::now().timestamp_millis() as f64;
-
- let cursor_data = get_cursor_image_data();
- let cursor_id = if let Some(data) = cursor_data {
- // Check if we've seen this cursor data before
- if let Some(existing_id) = seen_cursor_data.get(&data) {
- existing_id.clone()
- } else {
- // New cursor data - save it
- let cursor_id = next_cursor_id.to_string();
- let filename = format!("cursor_{}.png", cursor_id);
- let cursor_path = cursors_dir.join(&filename);
-
- println!("Saving new cursor image to: {:?}", cursor_path);
-
- if let Ok(image) = image::load_from_memory(&data) {
- // Convert to RGBA
- let rgba_image = image.into_rgba8();
- if let Err(e) = rgba_image.save(&cursor_path) {
- eprintln!("Failed to save cursor image: {}", e);
- } else {
- println!("Successfully saved cursor image {}", cursor_id);
- cursor_images.insert(cursor_id.clone(), filename.clone());
- seen_cursor_data.insert(data, cursor_id.clone());
- next_cursor_id += 1;
- }
- }
- cursor_id
- }
- } else {
- "default".to_string()
+ prev_cursors: Cursors,
+ next_cursor_id: i32,
+) -> CursorActor {
+ let stop_signal = Arc::new(AtomicBool::new(false));
+ let (tx, rx) = oneshot::channel();
+
+ tokio::spawn({
+ let stop_signal = stop_signal.clone();
+ async move {
+ let device_state = DeviceState::new();
+ let mut last_mouse_state = device_state.get_mouse();
+ let start_time = Instant::now();
+
+ let mut response = CursorActorResponse {
+ cursors: prev_cursors,
+ next_cursor_id,
+ moves: vec![],
+ clicks: vec![],
};
- if mouse_state.coords != last_mouse_state.coords {
- let mouse_event = CursorMoveEvent {
- active_modifiers: vec![],
- cursor_id: cursor_id.clone(),
- process_time_ms: elapsed,
- unix_time_ms: unix_time,
- x: (mouse_state.coords.0 as f64 - screen_bounds.x) / screen_bounds.width,
- y: (mouse_state.coords.1 as f64 - screen_bounds.y) / screen_bounds.height,
- };
- moves.push(mouse_event);
- }
+ // Create cursors directory if it doesn't exist
+ std::fs::create_dir_all(&cursors_dir).unwrap();
+
+ while !stop_signal.load(std::sync::atomic::Ordering::Relaxed) {
+ let mouse_state = device_state.get_mouse();
+ let elapsed = start_time.elapsed().as_secs_f64() * 1000.0;
+ let unix_time = chrono::Utc::now().timestamp_millis() as f64;
+
+ let cursor_data = get_cursor_image_data();
+ let cursor_id = if let Some(data) = cursor_data {
+ let mut hasher = DefaultHasher::default();
+ data.hash(&mut hasher);
+ let id = hasher.finish();
+
+ // Check if we've seen this cursor data before
+ if let Some(existing_id) = response.cursors.get(&id) {
+ existing_id.1.to_string()
+ } else {
+ // New cursor data - save it
+ let cursor_id = response.next_cursor_id.to_string();
+ let filename = format!("cursor_{}.png", cursor_id);
+ let cursor_path = cursors_dir.join(&filename);
+
+ println!("Saving new cursor image to: {:?}", cursor_path);
+
+ if let Ok(image) = image::load_from_memory(&data) {
+ // Convert to RGBA
+ let rgba_image = image.into_rgba8();
+
+ if let Err(e) = rgba_image.save(&cursor_path) {
+ eprintln!("Failed to save cursor image: {}", e);
+ } else {
+ println!("Successfully saved cursor image {}", cursor_id);
+ response
+ .cursors
+ .insert(id, (filename.clone(), response.next_cursor_id));
+ response.next_cursor_id += 1;
+ }
+ }
- for (num, &pressed) in mouse_state.button_pressed.iter().enumerate() {
- let Some(prev) = last_mouse_state.button_pressed.get(num) else {
- continue;
+ cursor_id
+ }
+ } else {
+ "default".to_string()
};
- if pressed == *prev {
- continue;
+ if mouse_state.coords != last_mouse_state.coords {
+ let mouse_event = CursorMoveEvent {
+ active_modifiers: vec![],
+ cursor_id: cursor_id.clone(),
+ process_time_ms: elapsed,
+ unix_time_ms: unix_time,
+ x: (mouse_state.coords.0 as f64 - screen_bounds.x) / screen_bounds.width,
+ y: (mouse_state.coords.1 as f64 - screen_bounds.y) / screen_bounds.height,
+ };
+ response.moves.push(mouse_event);
}
- let mouse_event = CursorClickEvent {
- down: pressed,
- active_modifiers: vec![],
- cursor_num: num as u8,
- cursor_id: cursor_id.clone(),
- process_time_ms: elapsed,
- unix_time_ms: unix_time,
- x: (mouse_state.coords.0 as f64 - screen_bounds.x) / screen_bounds.width,
- y: (mouse_state.coords.1 as f64 - screen_bounds.y) / screen_bounds.height,
- };
- clicks.push(mouse_event);
- }
+ for (num, &pressed) in mouse_state.button_pressed.iter().enumerate() {
+ let Some(prev) = last_mouse_state.button_pressed.get(num) else {
+ continue;
+ };
- last_mouse_state = mouse_state;
- tokio::time::sleep(Duration::from_millis(10)).await;
- }
+ if pressed == *prev {
+ continue;
+ }
- // Save cursor data to cursor.json
- let cursor_data = CursorData {
- clicks: clicks.clone(),
- moves: moves.clone(),
- cursor_images,
- };
+ let mouse_event = CursorClickEvent {
+ down: pressed,
+ active_modifiers: vec![],
+ cursor_num: num as u8,
+ cursor_id: cursor_id.clone(),
+ process_time_ms: elapsed,
+ unix_time_ms: unix_time,
+ x: (mouse_state.coords.0 as f64 - screen_bounds.x) / screen_bounds.width,
+ y: (mouse_state.coords.1 as f64 - screen_bounds.y) / screen_bounds.height,
+ };
+ response.clicks.push(mouse_event);
+ }
- let cursor_json_path = content_dir.join("cursor.json");
- println!("Saving cursor data to: {:?}", cursor_json_path);
- if let Ok(mut file) = File::create(&cursor_json_path) {
- if let Err(e) = serde_json::to_writer_pretty(&mut file, &cursor_data) {
- eprintln!("Failed to save cursor data: {}", e);
- } else {
- println!("Successfully saved cursor data");
+ last_mouse_state = mouse_state;
+ tokio::time::sleep(Duration::from_millis(10)).await;
}
- }
- move_tx.send(moves).unwrap();
- click_tx.send(clicks).unwrap();
+ tx.send(response).ok();
+ }
});
- (move_rx, click_rx)
+ CursorActor { rx, stop_signal }
}
#[cfg(target_os = "macos")]
diff --git a/crates/recording/src/lib.rs b/crates/recording/src/lib.rs
index da36d9d13..edbfd40c2 100644
--- a/crates/recording/src/lib.rs
+++ b/crates/recording/src/lib.rs
@@ -1,8 +1,8 @@
-mod actor;
+pub mod actor;
mod cursor;
-mod segmented_actor;
+pub mod segmented_actor;
-pub use actor::{spawn_recording_actor, ActorHandle, RecordingError};
+pub use actor::{spawn_recording_actor, ActorHandle, CompletedRecording, RecordingError};
use cap_media::sources::*;
use serde::{Deserialize, Serialize};
diff --git a/crates/recording/src/segmented_actor.rs b/crates/recording/src/segmented_actor.rs
index e0e6da210..62c2c40eb 100644
--- a/crates/recording/src/segmented_actor.rs
+++ b/crates/recording/src/segmented_actor.rs
@@ -4,27 +4,35 @@ use std::{
time::{SystemTime, UNIX_EPOCH},
};
+use cap_flags::FLAGS;
use cap_media::{
encoders::{H264Encoder, MP3Encoder, Output},
feeds::{AudioInputFeed, CameraFeed},
filters::VideoFilter,
pipeline::{builder::PipelineBuilder, Pipeline, RealTimeClock},
- sources::{AudioInputSource, CameraSource, ScreenCaptureSource},
+ sources::{AudioInputSource, CameraSource, ScreenCaptureSource, ScreenCaptureTarget},
MediaError,
};
+use cap_project::{CursorEvents, RecordingMeta};
+use either::Either;
use thiserror::Error;
use tokio::sync::{oneshot, Mutex};
-use crate::RecordingOptions;
+use crate::{
+ cursor::{spawn_cursor_recorder, CursorActor, Cursors},
+ RecordingOptions,
+};
enum ActorState {
Recording {
- pipeline: Pipeline<RealTimeClock<()>>,
+ pipeline: RecordingPipeline,
index: u32,
segment_start_time: f64,
},
Paused {
next_index: u32,
+ cursors: Cursors,
+ next_cursor_id: i32,
},
Stopped,
}
@@ -32,13 +40,33 @@ enum ActorState {
pub enum ActorControlMessage {
Pause(oneshot::Sender<Result<(), RecordingError>>),
Resume(oneshot::Sender<Result<(), RecordingError>>),
- Stop(oneshot::Sender<Result<(), RecordingError>>),
+ Stop(oneshot::Sender<Result<CompletedRecording, RecordingError>>),
}
pub struct Actor {
+ id: String,
recording_dir: PathBuf,
options: RecordingOptions,
- segments: Vec<(f64, f64)>,
+ segments: Vec<RecordingSegment>,
+}
+
+pub struct RecordingSegment {
+ pub start: f64,
+ pub end: f64,
+ pipeline: RecordingPipeline,
+}
+
+struct RecordingPipeline {
+ pub inner: Pipeline<RealTimeClock<()>>,
+ pub display_output_path: PathBuf,
+ pub audio_output_path: Option<PathBuf>,
+ pub camera_output_path: Option<PathBuf>,
+ pub cursor: Option<CursorPipeline>,
+}
+
+struct CursorPipeline {
+ output_path: PathBuf,
+ actor: CursorActor,
}
pub struct ActorHandle {
@@ -62,6 +90,12 @@ pub enum RecordingError {
#[error("Actor error: {0}")]
Actor(#[from] ActorError),
+
+ #[error("Serde/{0}")]
+ Serde(#[from] serde_json::Error),
+
+ #[error("IO/{0}")]
+ Io(#[from] std::io::Error),
}
macro_rules! send_message {
@@ -73,7 +107,7 @@ macro_rules! send_message {
}
impl ActorHandle {
- pub async fn stop(&self) -> Result<(), RecordingError> {
+ pub async fn stop(&self) -> Result<CompletedRecording, RecordingError> {
send_message!(self.ctrl_tx, ActorControlMessage::Stop)
}
@@ -86,7 +120,8 @@ impl ActorHandle {
}
}
-pub async fn start_recording_actor(
+pub async fn spawn_recording_actor(
+ id: String,
recording_dir: impl Into<PathBuf>,
options: RecordingOptions,
camera_feed: Option<Arc<Mutex<CameraFeed>>>,
@@ -104,10 +139,13 @@ pub async fn start_recording_actor(
let index = 0;
let pipeline = create_segment_pipeline(
&segments_dir,
+ &cursors_dir,
index,
screen_source.clone(),
camera_feed.as_deref(),
audio_input_feed.as_ref(),
+ Default::default(),
+ 0,
)
.await?;
@@ -119,6 +157,7 @@ pub async fn start_recording_actor(
let options = options.clone();
async move {
let mut actor = Actor {
+ id,
recording_dir,
options,
segments: Vec::new(),
@@ -133,7 +172,7 @@ pub async fn start_recording_actor(
loop {
state = match state {
ActorState::Recording {
- mut pipeline,
+ pipeline,
index,
segment_start_time,
} => loop {
@@ -141,46 +180,102 @@ pub async fn start_recording_actor(
return;
};
- if matches!(
- &msg,
- ActorControlMessage::Pause(_) | ActorControlMessage::Stop(_)
- ) {
+ async fn shutdown(
+ mut pipeline: RecordingPipeline,
+ actor: &mut Actor,
+ segment_start_time: f64,
+ ) -> Result<(Cursors, i32), RecordingError> {
+ pipeline.inner.shutdown().await?;
+
let segment_stop_time = current_time_f64();
- actor.segments.push((segment_start_time, segment_stop_time));
+
+ let cursors = if let Some(cursor) = pipeline.cursor.take() {
+ let res = cursor.actor.stop().await;
+
+ dbg!(&res.cursors);
+
+ std::fs::write(
+ &cursor.output_path,
+ serde_json::to_string_pretty(&CursorEvents {
+ clicks: res.clicks,
+ moves: res.moves,
+ })?,
+ )?;
+
+ (res.cursors, res.next_cursor_id)
+ } else {
+ Default::default()
+ };
+
+ actor.segments.push(RecordingSegment {
+ start: segment_start_time,
+ end: segment_stop_time,
+ pipeline,
+ });
+
+ Ok(cursors)
}
break match msg {
ActorControlMessage::Pause(tx) => {
- let res = pipeline.shutdown().await;
+ let (res, cursors, next_cursor_id) = match shutdown(
+ pipeline,
+ &mut actor,
+ segment_start_time,
+ )
+ .await
+ {
+ Ok((cursors, next_cursor_id)) => {
+ (Ok(()), cursors, next_cursor_id)
+ }
+ Err(e) => (Err(e), Default::default(), 0),
+ };
+
tx.send(res.map_err(Into::into)).ok();
ActorState::Paused {
next_index: index + 1,
+ cursors,
+ next_cursor_id,
}
}
ActorControlMessage::Stop(tx) => {
- tx.send(stop_recording(Some(pipeline)).await).ok();
+ let res = shutdown(pipeline, &mut actor, segment_start_time).await;
+ let res = match res {
+ Ok((cursors, _)) => stop_recording(actor, cursors).await,
+ Err(e) => Err(e),
+ };
+
+ tx.send(res).ok();
+
return;
}
_ => continue,
};
},
- ActorState::Paused { next_index } => loop {
+ ActorState::Paused {
+ next_index,
+ cursors,
+ next_cursor_id,
+ } => loop {
let Ok(msg) = ctrl_rx.recv_async().await else {
return;
};
break match msg {
ActorControlMessage::Stop(tx) => {
- tx.send(stop_recording(None).await).ok();
- ActorState::Stopped
+ tx.send(stop_recording(actor, cursors).await).ok();
+ return;
}
ActorControlMessage::Resume(tx) => {
let (state, res) = match create_segment_pipeline(
&segments_dir,
+ &cursors_dir,
next_index,
screen_source.clone(),
camera_feed.as_deref(),
audio_input_feed.as_ref(),
+ cursors,
+ next_cursor_id,
)
.await
{
@@ -211,14 +306,84 @@ pub async fn start_recording_actor(
Ok(ActorHandle { ctrl_tx, options })
}
+pub struct CompletedRecording {
+ pub id: String,
+ pub recording_dir: PathBuf,
+ pub display_source: ScreenCaptureTarget,
+ pub meta: RecordingMeta,
+ pub cursor_data: cap_project::CursorImages,
+ pub segments: Vec<RecordingSegment>,
+}
+
async fn stop_recording(
- pipeline: Option<Pipeline<RealTimeClock<()>>>,
-) -> Result<(), RecordingError> {
- if let Some(mut pipeline) = pipeline {
- pipeline.shutdown().await?;
- }
+ actor: Actor,
+ cursors: Cursors,
+) -> Result<CompletedRecording, RecordingError> {
+ use cap_project::*;
+
+ let meta = RecordingMeta {
+ project_path: actor.recording_dir.clone(),
+ sharing: None,
+ pretty_name: format!(
+ "Cap {}",
+ chrono::Local::now().format("%Y-%m-%d at %H.%M.%S")
+ ),
+ content: Content::MultipleSegments {
+ inner: MultipleSegments {
+ segments: {
+ actor
+ .segments
+ .iter()
+ .map(|s| MultipleSegment {
+ display: Display {
+ path: s
+ .pipeline
+ .display_output_path
+ .strip_prefix(&actor.recording_dir)
+ .unwrap()
+ .to_owned(),
+ },
+ camera: s
+ .pipeline
+ .camera_output_path
+ .as_ref()
+ .map(|path| CameraMeta {
+ path: path
+ .strip_prefix(&actor.recording_dir)
+ .unwrap()
+ .to_owned(),
+ }),
+ audio: s.pipeline.audio_output_path.as_ref().map(|path| AudioMeta {
+ path: path.strip_prefix(&actor.recording_dir).unwrap().to_owned(),
+ }),
+ cursor: None,
+ })
+ .collect()
+ },
+ cursors: cursors
+ .into_values()
+ .map(|(file_name, id)| {
+ (
+ id.to_string(),
+ PathBuf::from("content/cursors").join(&file_name),
+ )
+ })
+ .collect(),
+ },
+ },
+ };
- Ok(())
+ meta.save_for_project()
+ .map_err(Either::either_into::<RecordingError>)?;
+
+ Ok(CompletedRecording {
+ id: actor.id,
+ meta,
+ cursor_data: Default::default(),
+ recording_dir: actor.recording_dir,
+ display_source: actor.options.capture_target,
+ segments: actor.segments,
+ })
}
fn create_screen_capture(
@@ -244,11 +409,14 @@ fn create_screen_capture(
async fn create_segment_pipeline<TCaptureFormat: MakeCapturePipeline>(
segments_dir: &PathBuf,
+ cursors_dir: &PathBuf,
index: u32,
screen_source: ScreenCaptureSource<TCaptureFormat>,
camera_feed: Option<&Mutex<CameraFeed>>,
audio_input_feed: Option<&AudioInputFeed>,
-) -> Result<Pipeline<RealTimeClock<()>>, MediaError> {
+ prev_cursors: Cursors,
+ next_cursors_id: i32,
+) -> Result<RecordingPipeline, MediaError> {
let camera_feed = match camera_feed.as_ref() {
Some(camera_feed) => Some(camera_feed.lock().await),
None => None,
@@ -264,10 +432,11 @@ async fn create_segment_pipeline<TCaptureFormat: MakeCapturePipeline>(
let mut audio_output_path = None;
let mut camera_output_path = None;
+ let screen_bounds = screen_source.get_bounds();
pipeline_builder = TCaptureFormat::make_capture_pipeline(
pipeline_builder,
screen_source,
- display_output_path,
+ &display_output_path,
)?;
if let Some(mic_source) = audio_input_feed.map(AudioInputSource::init) {
@@ -307,9 +476,29 @@ async fn create_segment_pipeline<TCaptureFormat: MakeCapturePipeline>(
let mut pipeline = pipeline_builder.build().await?;
+ let cursor = FLAGS.record_mouse.then(|| {
+ let cursor = spawn_cursor_recorder(
+ screen_bounds,
+ cursors_dir.clone(),
+ prev_cursors,
+ next_cursors_id,
+ );
+
+ CursorPipeline {
+ output_path: dir.join("cursor.json"),
+ actor: cursor,
+ }
+ });
+
pipeline.play().await?;
- Ok(pipeline)
+ Ok(RecordingPipeline {
+ inner: pipeline,
+ display_output_path,
+ audio_output_path,
+ camera_output_path,
+ cursor,
+ })
}
fn ensure_dir(path: PathBuf) -> Result<PathBuf, MediaError> {
@@ -329,6 +518,7 @@ trait MakeCapturePipeline: 'static {
Self: Sized;
}
+#[cfg(target_os = "macos")]
impl MakeCapturePipeline for cap_media::sources::CMSampleBufferCapture {
fn make_capture_pipeline(
builder: CapturePipelineBuilder,
diff --git a/crates/rendering/src/decoder.rs b/crates/rendering/src/decoder.rs
index 0c5ad774e..adaa9d1f9 100644
--- a/crates/rendering/src/decoder.rs
+++ b/crates/rendering/src/decoder.rs
@@ -2,15 +2,16 @@ use std::{
collections::BTreeMap,
path::PathBuf,
sync::{mpsc, Arc},
+ time::Instant,
};
use ffmpeg::{
- codec,
+ codec::{self, Capabilities},
format::{self},
frame, rescale, Codec, Rational, Rescale,
};
-use ffmpeg_hw_device::{CodecContextExt, HwDevice};
-use ffmpeg_sys_next::{avcodec_find_decoder, AVHWDeviceType};
+use ffmpeg_hw_device::HwDevice;
+use ffmpeg_sys_next::avcodec_find_decoder;
pub type DecodedFrame = Arc<Vec<u8>>;
@@ -57,18 +58,32 @@ impl AsyncVideoDecoder {
// Create a decoder for the video stream
let mut decoder = context.decoder().video().unwrap();
- let hw_device: Option<HwDevice> = {
- #[cfg(target_os = "macos")]
- {
- decoder
- .try_use_hw_device(
- AVHWDeviceType::AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
- Pixel::NV12,
- )
- .ok()
+ {
+ use codec::threading::{Config, Type};
+
+ let capabilities = decoder_codec.capabilities();
+
+ if capabilities.intersects(Capabilities::FRAME_THREADS) {
+ decoder.set_threading(Config::kind(Type::Frame));
+ } else if capabilities.intersects(Capabilities::SLICE_THREADS) {
+ decoder.set_threading(Config::kind(Type::Slice));
+ } else {
+ decoder.set_threading(Config::count(1));
}
+ }
- #[cfg(not(target_os = "macos"))]
+ let hw_device: Option<HwDevice> = {
+ // #[cfg(target_os = "macos")]
+ // {
+ // decoder
+ // .try_use_hw_device(
+ // AVHWDeviceType::AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
+ // Pixel::NV12,
+ // )
+ // .ok()
+ // }
+
+ // #[cfg(not(target_os = "macos"))]
None
};
@@ -108,6 +123,8 @@ impl AsyncVideoDecoder {
while let Ok(r) = peekable_requests.recv() {
match r {
VideoDecoderMessage::GetFrame(requested_frame, sender) => {
+ let time_in = Instant::now();
+
let mut sender = if let Some(cached) = cache.get(&requested_frame) {
sender.send(Some(cached.clone())).ok();
last_sent_frame = Some((requested_frame, cached.clone()));
@@ -163,6 +180,7 @@ impl AsyncVideoDecoder {
last_active_frame = Some(requested_frame);
+ let now = Instant::now();
loop {
if peekable_requests.peek().is_some() {
break;
@@ -289,7 +307,7 @@ impl AsyncVideoDecoder {
}
if let Some(s) = sender.take() {
- s.send(None);
+ s.send(None).ok();
}
}
}
diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs
index 381126979..673da2ed7 100644
--- a/crates/rendering/src/lib.rs
+++ b/crates/rendering/src/lib.rs
@@ -13,14 +13,15 @@ use wgpu::util::DeviceExt;
use wgpu::{CommandEncoder, COPY_BYTES_PER_ROW_ALIGNMENT};
use cap_project::{
- AspectRatio, BackgroundSource, CameraXPosition, CameraYPosition, Crop, CursorAnimationStyle,
- CursorData, CursorMoveEvent, ProjectConfiguration, RecordingMeta, FAST_SMOOTHING_SAMPLES,
- FAST_VELOCITY_THRESHOLD, REGULAR_SMOOTHING_SAMPLES, REGULAR_VELOCITY_THRESHOLD,
- SLOW_SMOOTHING_SAMPLES, SLOW_VELOCITY_THRESHOLD, XY,
+ AspectRatio, BackgroundSource, CameraXPosition, CameraYPosition, Content, Crop,
+ CursorAnimationStyle, CursorClickEvent, CursorData, CursorEvents, CursorMoveEvent,
+ ProjectConfiguration, RecordingMeta, FAST_SMOOTHING_SAMPLES, FAST_VELOCITY_THRESHOLD,
+ REGULAR_SMOOTHING_SAMPLES, REGULAR_VELOCITY_THRESHOLD, SLOW_SMOOTHING_SAMPLES,
+ SLOW_VELOCITY_THRESHOLD, XY,
};
use image::GenericImageView;
-use std::path::PathBuf;
+use std::path::Path;
use std::time::Instant;
pub mod decoder;
@@ -82,18 +83,22 @@ impl From<BackgroundSource> for Background {
}
#[derive(Clone)]
-pub struct RecordingDecoders {
+pub struct RecordingSegmentDecoders {
screen: AsyncVideoDecoderHandle,
camera: Option<AsyncVideoDecoderHandle>,
}
-impl RecordingDecoders {
- pub fn new(meta: &RecordingMeta) -> Self {
- let screen = AsyncVideoDecoder::spawn(meta.project_path.join(&meta.display.path).clone());
- let camera = meta
+pub struct SegmentVideoPaths<'a> {
+ pub display: &'a Path,
+ pub camera: Option<&'a Path>,
+}
+
+impl RecordingSegmentDecoders {
+ pub fn new(meta: &RecordingMeta, segment: SegmentVideoPaths) -> Self {
+ let screen = AsyncVideoDecoder::spawn(meta.project_path.join(segment.display));
+ let camera = segment
.camera
- .as_ref()
- .map(|camera| AsyncVideoDecoder::spawn(meta.project_path.join(&camera.path).clone()));
+ .map(|camera| AsyncVideoDecoder::spawn(meta.project_path.join(camera)));
Self { screen, camera }
}
@@ -109,17 +114,6 @@ impl RecordingDecoders {
screen_frame.map(|f| (f, camera_frame.flatten()))
}
-
- pub async fn stop(&self) {
- // Implement the stop logic for the decoders
- // This might involve stopping any running decoding tasks
- // and cleaning up resources
- if let Some(camera) = &self.camera {
- camera.stop().await;
- }
- self.screen.stop().await;
- println!("Decoders stopped");
- }
}
#[derive(thiserror::Error, Debug)]
@@ -136,15 +130,19 @@ pub enum RenderingError {
ChannelSendFrameFailed(#[from] mpsc::error::SendError<Vec<u8>>),
}
+pub struct RenderSegment {
+ pub cursor: Arc<CursorEvents>,
+ pub decoders: RecordingSegmentDecoders,
+}
+
pub async fn render_video_to_channel(
options: RenderOptions,
project: ProjectConfiguration,
sender: tokio::sync::mpsc::Sender<Vec<u8>>,
- decoders: RecordingDecoders,
- cursor: Arc<CursorData>,
- project_path: PathBuf, // Add project_path parameter
+ meta: &RecordingMeta,
+ segments: Vec<RenderSegment>,
) -> Result<(), RenderingError> {
- let constants = RenderVideoConstants::new(options, cursor, project_path).await?;
+ let constants = RenderVideoConstants::new(options, meta).await?;
println!("Setting up FFmpeg input for screen recording...");
@@ -163,18 +161,21 @@ pub async fn render_video_to_channel(
break;
};
- let time = if let Some(timeline) = project.timeline() {
+ let (time, segment) = if let Some(timeline) = project.timeline() {
match timeline.get_recording_time(frame_number as f64 / 30_f64) {
- Some(time) => time,
+ Some(value) => value,
None => break,
}
} else {
- frame_number as f64 / 30_f64
+ (frame_number as f64 / 30_f64, None)
};
+ let segment = &segments[segment.unwrap_or(0) as usize];
+
let uniforms = ProjectUniforms::new(&constants, &project, time as f32);
- let Some((screen_frame, camera_frame)) = decoders.get_frames((time * 30.0) as u32).await
+ let Some((screen_frame, camera_frame)) =
+ segment.decoders.get_frames((time * 30.0) as u32).await
else {
break;
};
@@ -224,17 +225,12 @@ pub struct RenderVideoConstants {
pub options: RenderOptions,
composite_video_frame_pipeline: CompositeVideoFramePipeline,
gradient_or_color_pipeline: GradientOrColorPipeline,
- pub cursor: Arc<CursorData>,
pub cursor_textures: HashMap<String, wgpu::Texture>,
cursor_pipeline: CursorPipeline,
}
impl RenderVideoConstants {
- pub async fn new(
- options: RenderOptions,
- cursor: Arc<CursorData>,
- project_path: PathBuf, // Add project_path parameter
- ) -> Result<Self, RenderingError> {
+ pub async fn new(options: RenderOptions, meta: &RecordingMeta) -> Result<Self, RenderingError> {
println!("Initializing wgpu...");
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::default());
let adapter = instance
@@ -246,7 +242,7 @@ impl RenderVideoConstants {
.await?;
// Pass project_path to load_cursor_textures
- let cursor_textures = Self::load_cursor_textures(&device, &queue, &cursor, &project_path);
+ let cursor_textures = Self::load_cursor_textures(&device, &queue, meta);
let cursor_pipeline = CursorPipeline::new(&device);
@@ -258,7 +254,6 @@ impl RenderVideoConstants {
queue,
device,
options,
- cursor,
cursor_textures,
cursor_pipeline,
})
@@ -267,20 +262,24 @@ impl RenderVideoConstants {
fn load_cursor_textures(
device: &wgpu::Device,
queue: &wgpu::Queue,
- cursor: &CursorData,
- project_path: &PathBuf, // Add project_path parameter
+ meta: &RecordingMeta,
) -> HashMap<String, wgpu::Texture> {
println!("Starting to load cursor textures");
- println!("Project path: {:?}", project_path);
- println!("Cursor images to load: {:?}", cursor.cursor_images);
+ println!("Project path: {:?}", meta.project_path);
+ // println!("Cursor images to load: {:?}", cursor.cursor_images);
let mut textures = HashMap::new();
// Create the full path to the cursors directory
- let cursors_dir = project_path.join("content").join("cursors");
+ let cursors_dir = meta.project_path.join("content").join("cursors");
println!("Cursors directory: {:?}", cursors_dir);
- for (cursor_id, filename) in &cursor.cursor_images {
+ let cursor_images = match &meta.content {
+ Content::SingleSegment { segment } => segment.cursor_data(meta).cursor_images,
+ Content::MultipleSegments { inner } => inner.cursor_images(meta).unwrap_or_default(),
+ };
+
+ for (cursor_id, filename) in &cursor_images.0 {
println!("Loading cursor image: {} -> {}", cursor_id, filename);
let cursor_path = cursors_dir.join(filename);
@@ -484,8 +483,11 @@ impl ProjectUniforms {
let options = &constants.options;
let output_size = Self::get_output_size(options, project);
- let cursor_position =
- interpolate_cursor_position(&constants.cursor, time, &project.cursor.animation_style);
+ let cursor_position = interpolate_cursor_position(
+ &Default::default(), /*constants.cursor*/
+ time,
+ &project.cursor.animation_style,
+ );
let zoom_keyframes = ZoomKeyframes::new(project);
let current_zoom = zoom_keyframes.get_amount(time as f64);
@@ -889,16 +891,16 @@ pub async fn produce_frame(
output_is_left = !output_is_left;
}
- if FLAGS.zoom {
- // Then render the cursor
- draw_cursor(
- constants,
- uniforms,
- time,
- &mut encoder,
- get_either(texture_views, !output_is_left),
- );
- }
+ // if FLAGS.zoom {
+ // Then render the cursor
+ draw_cursor(
+ constants,
+ uniforms,
+ time,
+ &mut encoder,
+ get_either(texture_views, !output_is_left),
+ );
+ // }
// camera
if let (Some(camera_size), Some(camera_frame), Some(uniforms)) = (
@@ -1052,7 +1054,7 @@ fn draw_cursor(
view: &wgpu::TextureView,
) {
let Some(cursor_position) = interpolate_cursor_position(
- &constants.cursor,
+ &Default::default(), // constants.cursor,
time,
&uniforms.project.cursor.animation_style,
) else {
@@ -1061,7 +1063,7 @@ fn draw_cursor(
// Calculate previous position for velocity
let prev_position = interpolate_cursor_position(
- &constants.cursor,
+ &Default::default(), // constants.cursor,
time - 1.0 / 30.0,
&uniforms.project.cursor.animation_style,
);
@@ -1082,11 +1084,12 @@ fn draw_cursor(
let speed = (velocity[0] * velocity[0] + velocity[1] * velocity[1]).sqrt();
let motion_blur_amount = (speed * 0.3).min(1.0) * uniforms.project.motion_blur.unwrap_or(0.8);
- let cursor_event = find_cursor_event(&constants.cursor, time);
+ let cursor = Default::default();
+ let cursor_event = find_cursor_event(&cursor /* constants.cursor */, time);
- let last_click_time = constants
+ let last_click_time = /* constants
.cursor
- .clicks
+ .clicks */ Vec::<CursorClickEvent>::new()
.iter()
.filter(|click| click.down && click.process_time_ms <= (time as f64) * 1000.0)
.max_by_key(|click| click.process_time_ms as i64)
@@ -1533,17 +1536,6 @@ fn get_either<T>((a, b): (T, T), left: bool) -> T {
}
}
-impl AsyncVideoDecoderHandle {
- // ... (existing methods)
-
- pub async fn stop(&self) {
- // Implement the stop logic for the video decoder
- // This might involve sending a stop signal to a running task
- // or cleaning up resources
- println!("Video decoder stopped");
- }
-}
-
fn interpolate_cursor_position(
cursor: &CursorData,
time_secs: f32,
diff --git a/packages/database/package.json b/packages/database/package.json
index 80bdef348..427419390 100644
--- a/packages/database/package.json
+++ b/packages/database/package.json
@@ -36,7 +36,7 @@
"react-dom": "^18.2.0",
"react-router-dom": "^6.18.0",
"tsconfig": "workspace:*",
- "typescript": "^5.3.2"
+ "typescript": "^5.7.2"
},
"engines": {
"node": "20"
diff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.ts
index 0709a403d..1a8c60b25 100644
--- a/packages/ui-solid/src/auto-imports.d.ts
+++ b/packages/ui-solid/src/auto-imports.d.ts
@@ -61,4 +61,6 @@ declare global {
const IconLucideRotateCcw: typeof import('~icons/lucide/rotate-ccw.jsx')['default']
const IconLucideSearch: typeof import('~icons/lucide/search.jsx')['default']
const IconLucideSquarePlay: typeof import('~icons/lucide/square-play.jsx')['default']
+ const IconLucideVolume2: typeof import('~icons/lucide/volume2.jsx')['default']
+ const IconLucideVolumeX: typeof import('~icons/lucide/volume-x.jsx')['default']
}
diff --git a/packages/ui/package.json b/packages/ui/package.json
index dc2fa3555..3bd2fed70 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -32,7 +32,7 @@
"tauri-plugin-context-menu": "^0.5.0",
"tauri-plugin-positioner-api": "^0.2.7",
"tsconfig": "workspace:*",
- "typescript": "^5.3.2",
+ "typescript": "^5.7.2",
"vite": "^4.4.4",
"vite-tsconfig-paths": "^4.2.1"
},
diff --git a/packages/utils/package.json b/packages/utils/package.json
index afd517664..190dd2b89 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -16,7 +16,7 @@
"react-dom": "^18.2.0",
"react-router-dom": "^6.18.0",
"tsconfig": "workspace:*",
- "typescript": "^5.3.2"
+ "typescript": "^5.7.2"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.485.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 120027b04..f2c4f2ce4 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -15,7 +15,7 @@ importers:
devDependencies:
'@turbo/gen':
specifier: ^1.9.7
- version: 1.13.4(@types/[email protected])([email protected])
+ version: 1.13.4(@types/[email protected])([email protected])
dotenv-cli:
specifier: latest
version: 7.4.2
@@ -183,14 +183,14 @@ importers:
specifier: ^0.1.11
version: 0.1.11
typescript:
- specifier: ^5.2.2
- version: 5.6.2
+ specifier: ^5.7.2
+ version: 5.7.2
vite:
specifier: ^5.4.3
version: 5.4.8(@types/[email protected])([email protected])
vite-tsconfig-paths:
specifier: ^5.0.1
apps/embed:
dependencies:
@@ -284,16 +284,16 @@ importers:
version: 8.57.1
eslint-config-next:
specifier: 14.1.0
postcss:
specifier: ^8.4.23
version: 8.4.47
tailwindcss:
specifier: ^3
typescript:
- specifier: ^5.3.2
- version: 5.6.2
+ specifier: ^5.7.2
+ version: 5.7.2
apps/storybook:
dependencies:
@@ -338,8 +338,8 @@ importers:
specifier: ^1.0.0-beta.2
typescript:
- specifier: ^5.2.2
- version: 5.6.2
+ specifier: ^5.7.2
+ version: 5.7.2
vite:
specifier: ^5.3.4
version: 5.4.8(@types/[email protected])([email protected])
@@ -390,32 +390,32 @@ importers:
version: 1.10.0
ts-node:
specifier: ^10.9.2
- version: 10.9.2(@types/[email protected])([email protected])
+ version: 10.9.2(@types/[email protected])([email protected])
typescript:
- specifier: ^5.4.4
- version: 5.6.2
+ specifier: ^5.7.2
+ version: 5.7.2
devDependencies:
'@typescript-eslint/eslint-plugin':
specifier: ^7.6.0
'@typescript-eslint/parser':
specifier: ^7.6.0
eslint:
specifier: ^8.57.0
version: 8.57.1
eslint-config-airbnb-typescript:
specifier: ^18.0.0
eslint-import-resolver-typescript:
specifier: ^3.6.1
eslint-plugin-import:
specifier: ^2.29.1
jest:
specifier: ^29.7.0
nodemon:
specifier: ^3.1.0
version: 3.1.7
@@ -424,7 +424,7 @@ importers:
version: 6.3.4
ts-jest:
specifier: ^29.1.2
apps/web:
dependencies:
@@ -623,16 +623,16 @@ importers:
version: 8.57.1
eslint-config-next:
specifier: 14.1.0
postcss:
specifier: ^8.4.23
version: 8.4.47
tailwindcss:
specifier: ^3
typescript:
- specifier: ^5.3.2
- version: 5.6.2
+ specifier: ^5.7.2
+ version: 5.7.2
packages/config:
dependencies:
@@ -644,23 +644,23 @@ importers:
version: 4.5.5(@types/[email protected])([email protected])
vite-tsconfig-paths:
specifier: ^4.2.0
devDependencies:
'@types/node':
specifier: ^20.4.5
version: 20.16.9
'@typescript-eslint/eslint-plugin':
specifier: ^5.59.6
'@typescript-eslint/parser':
specifier: ^5.59.6
eslint:
specifier: ^8.41.0
version: 8.57.1
eslint-config-next:
specifier: 13.3.0
eslint-config-prettier:
specifier: ^8.8.0
version: 8.10.0([email protected])
@@ -678,7 +678,7 @@ importers:
version: 4.6.2([email protected])
eslint-plugin-tailwindcss:
specifier: ^3.12.0
eslint-utils:
specifier: ^3.0.0
version: 3.0.0([email protected])
@@ -756,8 +756,8 @@ importers:
specifier: workspace:*
version: link:../tsconfig
typescript:
- specifier: ^5.3.2
- version: 5.6.2
+ specifier: ^5.7.2
+ version: 5.7.2
packages/tsconfig: {}
@@ -768,7 +768,7 @@ importers:
version: link:../utils
'@kobalte/tailwindcss':
specifier: ^0.9.0
'@radix-ui/react-dialog':
specifier: ^1.0.5
@@ -792,7 +792,7 @@ importers:
'@tailwindcss/typography':
specifier: ^0.5.9
class-variance-authority:
specifier: ^0.7.0
version: 0.7.0
@@ -844,13 +844,13 @@ importers:
tailwind-scrollbar:
specifier: ^3.1.0
tailwindcss:
specifier: ^3.3.3
tailwindcss-animate:
specifier: ^1.0.6
tauri-plugin-context-menu:
specifier: ^0.5.0
version: 0.5.0
@@ -861,14 +861,14 @@ importers:
specifier: workspace:*
version: link:../tsconfig
typescript:
- specifier: ^5.3.2
- version: 5.6.2
+ specifier: ^5.7.2
+ version: 5.7.2
vite:
specifier: ^4.4.4
version: 4.5.5(@types/[email protected])([email protected])
vite-tsconfig-paths:
specifier: ^4.2.1
packages/ui-solid:
dependencies:
@@ -883,7 +883,7 @@ importers:
version: 1.9.3
tailwindcss:
specifier: ^3.4.10
devDependencies:
'@fontsource/geist-sans':
specifier: ^5.0.3
@@ -893,10 +893,10 @@ importers:
version: 2.2.253
'@kobalte/tailwindcss':
specifier: ^0.9.0
'@tailwindcss/typography':
specifier: ^0.5.9
autoprefixer:
specifier: ^10.4.20
version: 10.4.20([email protected])
@@ -908,10 +908,10 @@ importers:
tailwind-scrollbar:
specifier: ^3.1.0
tailwindcss-animate:
specifier: ^1.0.6
unplugin-auto-import:
specifier: ^0.18.2
version: 0.18.3([email protected])
@@ -950,8 +950,8 @@ importers:
specifier: workspace:*
version: link:../tsconfig
typescript:
- specifier: ^5.3.2
- version: 5.6.2
+ specifier: ^5.7.2
+ version: 5.7.2
packages/web-api-contract:
dependencies:
@@ -4260,10 +4260,10 @@ packages:
react-dom:
optional: true
- '@storybook/[email protected]':
- resolution: {integrity: sha512-oVS0gm99hqaSXMgOd++Q4GHqTsWBPCUJTEcUyvqUPsbg7CM5ISX6CgDVoCScvfPG8BMU7nRJecjTLkrT+FooTg==}
+ '@storybook/[email protected]':
+ resolution: {integrity: sha512-QnAaY/DJCQRaUY0naOIbNTi+q3bYiQOhh6tV+P6W8vCXCSTKaQWSnmKbTrL+1AEDl03H0z1rKg5TVZViblCbgQ==}
peerDependencies:
- storybook: ^8.5.0-alpha.3
+ storybook: ^8.5.0-alpha.10
vite: ^4.0.0 || ^5.0.0
'@storybook/[email protected]':
@@ -4274,10 +4274,10 @@ packages:
peerDependencies:
storybook: ^8.3.3
- '@storybook/[email protected]':
- resolution: {integrity: sha512-/XU42L0Sk5uzVBWwNLLHROtOyhgQeCsnM8sGEM7s/pJW91WKQ1lg/Zd+eVYm9noPN71sMLMNf3IYIQIKTxqXVQ==}
+ '@storybook/[email protected]':
+ resolution: {integrity: sha512-He8y7nA9r7zNHHEU1LcxdF4S1Y3/Xi7MxlwbvPuDg3gbwkoRA5XXRxwcXQYfLfynlWmJdfcbI53qPI4HrsZxWA==}
peerDependencies:
- storybook: ^8.5.0-alpha.3
+ storybook: ^8.5.0-alpha.10
'@storybook/[email protected]':
resolution: {integrity: sha512-dHYFQH3mA+EtnCkHXzicbLgsvzYjcDJ1JWsogbItZogkPHgSJM/Wr71uMkcvw8v9mmCyP4NpXJuu6bPoVsOnzg==}
@@ -10459,8 +10459,8 @@ packages:
resolution: {integrity: sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==}
engines: {node: '>= 0.4'}
- resolution: {integrity: sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==}
+ resolution: {integrity: sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==}
engines: {node: '>=14.17'}
hasBin: true
@@ -10629,6 +10629,10 @@ packages:
webpack-sources:
optional: true
+ resolution: {integrity: sha512-5liCNPuJW8dqh3+DM6uNM2EI3MLLpCKp/KY+9pB5M2S2SR2qvvDHhKgBOaTWEbZTAws3CXfB0rKTIolWKL05VQ==}
+ engines: {node: '>=14.0.0'}
+
resolution: {integrity: sha512-ARZYTXiC+e8z3lRM7/qY9oyaOkaozCeNd2xoz7sYK9fv7OLGhVsf+BZbmASqiK/HTZ7T6eAlnVq9JynZppyk3w==}
peerDependencies:
@@ -11066,6 +11070,11 @@ packages:
engines: {node: '>= 14'}
hasBin: true
+ resolution: {integrity: sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==}
+ engines: {node: '>= 14'}
+ hasBin: true
+
resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==}
engines: {node: '>=6'}
@@ -12042,7 +12051,7 @@ snapshots:
micromatch: 4.0.8
ts-pattern: 5.5.0
unified: 11.0.5
- yaml: 2.5.1
+ yaml: 2.6.1
zod: 3.23.8
transitivePeerDependencies:
- '@effect-ts/otel-node'
@@ -12763,7 +12772,7 @@ snapshots:
jest-util: 29.7.0
slash: 3.0.0
dependencies:
'@jest/console': 29.7.0
'@jest/reporters': 29.7.0
@@ -12777,7 +12786,7 @@ snapshots:
exit: 0.1.2
graceful-fs: 4.2.11
jest-changed-files: 29.7.0
jest-haste-map: 29.7.0
jest-message-util: 29.7.0
jest-regex-util: 29.6.3
@@ -12978,9 +12987,9 @@ snapshots:
solid-presence: 0.1.8([email protected])
solid-prevent-scroll: 0.1.10([email protected])
dependencies:
dependencies:
@@ -14891,15 +14900,13 @@ snapshots:
react: 18.3.1
react-dom: 18.3.1([email protected])
dependencies:
- '@storybook/csf-plugin': 8.5.0-alpha.3([email protected])
+ '@storybook/csf-plugin': 8.5.0-alpha.10([email protected])
browser-assert: 1.2.1
storybook: 8.3.3
ts-dedent: 2.2.0
- transitivePeerDependencies:
- - webpack-sources
'@storybook/[email protected]':
dependencies:
@@ -14928,12 +14935,10 @@ snapshots:
transitivePeerDependencies:
- webpack-sources
dependencies:
storybook: 8.3.3
- unplugin: 1.15.0
- transitivePeerDependencies:
- - webpack-sources
+ unplugin: 1.16.0
'@storybook/[email protected]':
dependencies:
@@ -14995,13 +15000,13 @@ snapshots:
'@swc/counter': 0.1.3
tslib: 2.7.0
dependencies:
lodash.castarray: 4.4.0
lodash.isplainobject: 4.0.6
lodash.merge: 4.6.2
postcss-selector-parser: 6.0.10
'@tanstack/[email protected]': {}
@@ -15215,7 +15220,7 @@ snapshots:
'@tsconfig/[email protected]': {}
dependencies:
'@turbo/workspaces': 1.13.4
chalk: 2.4.2
@@ -15225,7 +15230,7 @@ snapshots:
minimatch: 9.0.5
node-plop: 0.26.3
proxy-agent: 6.4.0
- ts-node: 10.9.2(@types/[email protected])([email protected])
+ ts-node: 10.9.2(@types/[email protected])([email protected])
update-check: 1.5.4
validate-npm-package-name: 5.0.1
transitivePeerDependencies:
@@ -15500,65 +15505,65 @@ snapshots:
'@types/node': 20.16.9
optional: true
dependencies:
'@eslint-community/regexpp': 4.11.1
- '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
+ '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
'@typescript-eslint/scope-manager': 5.62.0
- '@typescript-eslint/type-utils': 5.62.0([email protected])([email protected])
- '@typescript-eslint/utils': 5.62.0([email protected])([email protected])
+ '@typescript-eslint/type-utils': 5.62.0([email protected])([email protected])
+ '@typescript-eslint/utils': 5.62.0([email protected])([email protected])
debug: 4.3.7([email protected])
eslint: 8.57.1
graphemer: 1.4.0
ignore: 5.3.2
natural-compare-lite: 1.4.0
semver: 7.6.3
- tsutils: 3.21.0([email protected])
+ tsutils: 3.21.0([email protected])
optionalDependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
transitivePeerDependencies:
- supports-color
dependencies:
'@eslint-community/regexpp': 4.11.1
- '@typescript-eslint/parser': 7.18.0([email protected])([email protected])
+ '@typescript-eslint/parser': 7.18.0([email protected])([email protected])
'@typescript-eslint/scope-manager': 7.18.0
- '@typescript-eslint/type-utils': 7.18.0([email protected])([email protected])
- '@typescript-eslint/utils': 7.18.0([email protected])([email protected])
+ '@typescript-eslint/type-utils': 7.18.0([email protected])([email protected])
+ '@typescript-eslint/utils': 7.18.0([email protected])([email protected])
'@typescript-eslint/visitor-keys': 7.18.0
eslint: 8.57.1
graphemer: 1.4.0
ignore: 5.3.2
natural-compare: 1.4.0
- ts-api-utils: 1.3.0([email protected])
+ ts-api-utils: 1.3.0([email protected])
optionalDependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
transitivePeerDependencies:
- supports-color
dependencies:
'@typescript-eslint/scope-manager': 5.62.0
'@typescript-eslint/types': 5.62.0
- '@typescript-eslint/typescript-estree': 5.62.0([email protected])
+ '@typescript-eslint/typescript-estree': 5.62.0([email protected])
debug: 4.3.7([email protected])
eslint: 8.57.1
optionalDependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
transitivePeerDependencies:
- supports-color
dependencies:
'@typescript-eslint/scope-manager': 7.18.0
'@typescript-eslint/types': 7.18.0
- '@typescript-eslint/typescript-estree': 7.18.0([email protected])
+ '@typescript-eslint/typescript-estree': 7.18.0([email protected])
'@typescript-eslint/visitor-keys': 7.18.0
debug: 4.3.7([email protected])
eslint: 8.57.1
optionalDependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
transitivePeerDependencies:
- supports-color
@@ -15572,27 +15577,27 @@ snapshots:
'@typescript-eslint/types': 7.18.0
'@typescript-eslint/visitor-keys': 7.18.0
dependencies:
- '@typescript-eslint/typescript-estree': 5.62.0([email protected])
- '@typescript-eslint/utils': 5.62.0([email protected])([email protected])
+ '@typescript-eslint/typescript-estree': 5.62.0([email protected])
+ '@typescript-eslint/utils': 5.62.0([email protected])([email protected])
debug: 4.3.7([email protected])
eslint: 8.57.1
- tsutils: 3.21.0([email protected])
+ tsutils: 3.21.0([email protected])
optionalDependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
transitivePeerDependencies:
- supports-color
dependencies:
- '@typescript-eslint/typescript-estree': 7.18.0([email protected])
- '@typescript-eslint/utils': 7.18.0([email protected])([email protected])
+ '@typescript-eslint/typescript-estree': 7.18.0([email protected])
+ '@typescript-eslint/utils': 7.18.0([email protected])([email protected])
debug: 4.3.7([email protected])
eslint: 8.57.1
- ts-api-utils: 1.3.0([email protected])
+ ts-api-utils: 1.3.0([email protected])
optionalDependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
transitivePeerDependencies:
- supports-color
@@ -15600,7 +15605,7 @@ snapshots:
'@typescript-eslint/[email protected]': {}
- '@typescript-eslint/[email protected]([email protected])':
+ '@typescript-eslint/[email protected]([email protected])':
dependencies:
'@typescript-eslint/types': 5.62.0
'@typescript-eslint/visitor-keys': 5.62.0
@@ -15608,13 +15613,13 @@ snapshots:
globby: 11.1.0
is-glob: 4.0.3
semver: 7.6.3
- tsutils: 3.21.0([email protected])
+ tsutils: 3.21.0([email protected])
optionalDependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
transitivePeerDependencies:
- supports-color
- '@typescript-eslint/[email protected]([email protected])':
+ '@typescript-eslint/[email protected]([email protected])':
dependencies:
'@typescript-eslint/types': 7.18.0
'@typescript-eslint/visitor-keys': 7.18.0
@@ -15623,20 +15628,20 @@ snapshots:
is-glob: 4.0.3
minimatch: 9.0.5
semver: 7.6.3
- ts-api-utils: 1.3.0([email protected])
+ ts-api-utils: 1.3.0([email protected])
optionalDependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
transitivePeerDependencies:
- supports-color
dependencies:
'@eslint-community/eslint-utils': 4.4.0([email protected])
'@types/json-schema': 7.0.15
'@types/semver': 7.5.8
'@typescript-eslint/scope-manager': 5.62.0
'@typescript-eslint/types': 5.62.0
- '@typescript-eslint/typescript-estree': 5.62.0([email protected])
+ '@typescript-eslint/typescript-estree': 5.62.0([email protected])
eslint: 8.57.1
eslint-scope: 5.1.1
semver: 7.6.3
@@ -15644,12 +15649,12 @@ snapshots:
- supports-color
- typescript
dependencies:
'@eslint-community/eslint-utils': 4.4.0([email protected])
'@typescript-eslint/scope-manager': 7.18.0
'@typescript-eslint/types': 7.18.0
- '@typescript-eslint/typescript-estree': 7.18.0([email protected])
+ '@typescript-eslint/typescript-estree': 7.18.0([email protected])
eslint: 8.57.1
transitivePeerDependencies:
- supports-color
@@ -16707,13 +16712,13 @@ snapshots:
crc-32: 1.2.2
readable-stream: 4.5.2
dependencies:
'@jest/types': 29.6.3
chalk: 4.1.2
exit: 0.1.2
graceful-fs: 4.2.11
jest-util: 29.7.0
prompts: 2.4.2
transitivePeerDependencies:
@@ -17425,57 +17430,57 @@ snapshots:
optionalDependencies:
source-map: 0.6.1
dependencies:
confusing-browser-globals: 1.0.11
eslint: 8.57.1
object.assign: 4.1.5
object.entries: 1.1.8
semver: 6.3.1
dependencies:
- '@typescript-eslint/eslint-plugin': 7.18.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
- '@typescript-eslint/parser': 7.18.0([email protected])([email protected])
+ '@typescript-eslint/eslint-plugin': 7.18.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
+ '@typescript-eslint/parser': 7.18.0([email protected])([email protected])
eslint: 8.57.1
transitivePeerDependencies:
- eslint-plugin-import
dependencies:
'@next/eslint-plugin-next': 13.3.0
'@rushstack/eslint-patch': 1.10.4
- '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
+ '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
- eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected])
eslint-plugin-jsx-a11y: 6.10.0([email protected])
eslint-plugin-react: 7.37.0([email protected])
eslint-plugin-react-hooks: 4.6.2([email protected])
optionalDependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
transitivePeerDependencies:
- eslint-import-resolver-webpack
- eslint-plugin-import-x
- supports-color
dependencies:
'@next/eslint-plugin-next': 14.1.0
'@rushstack/eslint-patch': 1.10.4
- '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
+ '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
eslint-plugin-jsx-a11y: 6.10.0([email protected])
eslint-plugin-react: 7.37.0([email protected])
eslint-plugin-react-hooks: 4.6.2([email protected])
optionalDependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
transitivePeerDependencies:
- eslint-import-resolver-webpack
- eslint-plugin-import-x
@@ -17498,97 +17503,97 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.3.7([email protected])
enhanced-resolve: 5.17.1
eslint: 8.57.1
fast-glob: 3.3.2
get-tsconfig: 4.8.1
is-bun-module: 1.2.1
is-glob: 4.0.3
optionalDependencies:
transitivePeerDependencies:
- '@typescript-eslint/parser'
- eslint-import-resolver-node
- eslint-import-resolver-webpack
- supports-color
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.3.7([email protected])
enhanced-resolve: 5.17.1
eslint: 8.57.1
fast-glob: 3.3.2
get-tsconfig: 4.8.1
is-bun-module: 1.2.1
is-glob: 4.0.3
optionalDependencies:
transitivePeerDependencies:
- '@typescript-eslint/parser'
- eslint-import-resolver-node
- eslint-import-resolver-webpack
- supports-color
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.3.7([email protected])
enhanced-resolve: 5.17.1
eslint: 8.57.1
fast-glob: 3.3.2
get-tsconfig: 4.8.1
is-bun-module: 1.2.1
is-glob: 4.0.3
optionalDependencies:
transitivePeerDependencies:
- '@typescript-eslint/parser'
- eslint-import-resolver-node
- eslint-import-resolver-webpack
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
- '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
+ '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
transitivePeerDependencies:
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
- '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
+ '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
- eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected])
transitivePeerDependencies:
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
- '@typescript-eslint/parser': 7.18.0([email protected])([email protected])
+ '@typescript-eslint/parser': 7.18.0([email protected])([email protected])
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
- eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
+ eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
transitivePeerDependencies:
- supports-color
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.8
@@ -17599,7 +17604,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
hasown: 2.0.2
is-core-module: 2.15.1
is-glob: 4.0.3
@@ -17610,13 +17615,13 @@ snapshots:
semver: 6.3.1
tsconfig-paths: 3.15.0
optionalDependencies:
- '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
+ '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
transitivePeerDependencies:
- eslint-import-resolver-typescript
- eslint-import-resolver-webpack
- supports-color
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.8
@@ -17627,7 +17632,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
hasown: 2.0.2
is-core-module: 2.15.1
is-glob: 4.0.3
@@ -17638,7 +17643,7 @@ snapshots:
semver: 6.3.1
tsconfig-paths: 3.15.0
optionalDependencies:
- '@typescript-eslint/parser': 7.18.0([email protected])([email protected])
+ '@typescript-eslint/parser': 7.18.0([email protected])([email protected])
transitivePeerDependencies:
- eslint-import-resolver-typescript
- eslint-import-resolver-webpack
@@ -17698,11 +17703,11 @@ snapshots:
string.prototype.matchall: 4.0.11
string.prototype.repeat: 1.0.0
dependencies:
fast-glob: 3.3.2
postcss: 8.4.47
dependencies:
@@ -19133,16 +19138,16 @@ snapshots:
- babel-plugin-macros
- supports-color
dependencies:
'@jest/test-result': 29.7.0
'@jest/types': 29.6.3
chalk: 4.1.2
exit: 0.1.2
import-local: 3.2.0
jest-util: 29.7.0
jest-validate: 29.7.0
yargs: 17.7.2
@@ -19152,7 +19157,7 @@ snapshots:
- supports-color
- ts-node
dependencies:
'@babel/core': 7.25.2
'@jest/test-sequencer': 29.7.0
@@ -19178,7 +19183,7 @@ snapshots:
strip-json-comments: 3.1.1
optionalDependencies:
'@types/node': 20.16.9
- ts-node: 10.9.2(@types/[email protected])([email protected])
+ ts-node: 10.9.2(@types/[email protected])([email protected])
transitivePeerDependencies:
- babel-plugin-macros
- supports-color
@@ -19398,12 +19403,12 @@ snapshots:
merge-stream: 2.0.0
supports-color: 8.1.1
dependencies:
'@jest/types': 29.6.3
import-local: 3.2.0
transitivePeerDependencies:
- '@types/node'
- babel-plugin-macros
@@ -21351,13 +21356,13 @@ snapshots:
camelcase-css: 2.0.1
postcss: 8.4.47
dependencies:
lilconfig: 3.1.2
yaml: 2.5.1
optionalDependencies:
postcss: 8.4.47
- ts-node: 10.9.2(@types/[email protected])([email protected])
+ ts-node: 10.9.2(@types/[email protected])([email protected])
dependencies:
@@ -22366,11 +22371,10 @@ snapshots:
dependencies:
- '@storybook/builder-vite': 8.5.0-alpha.3([email protected])([email protected](@types/[email protected])([email protected]))
+ '@storybook/builder-vite': 8.5.0-alpha.10([email protected])([email protected](@types/[email protected])([email protected]))
transitivePeerDependencies:
- storybook
- vite
- - webpack-sources
dependencies:
@@ -22604,15 +22608,15 @@ snapshots:
dependencies:
dependencies:
dependencies:
'@alloc/quick-lru': 5.2.0
arg: 5.0.2
@@ -22631,7 +22635,7 @@ snapshots:
postcss: 8.4.47
postcss-import: 15.1.0([email protected])
postcss-js: 4.0.1([email protected])
postcss-nested: 6.2.0([email protected])
postcss-selector-parser: 6.1.2
resolve: 1.22.8
@@ -22784,26 +22788,26 @@ snapshots:
dependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
dependencies:
bs-logger: 0.2.6
ejs: 3.1.10
fast-json-stable-stringify: 2.1.0
jest-util: 29.7.0
json5: 2.2.3
lodash.memoize: 4.1.2
make-error: 1.3.6
semver: 7.6.3
- typescript: 5.6.2
+ typescript: 5.7.2
yargs-parser: 21.1.1
optionalDependencies:
'@babel/core': 7.25.2
@@ -22811,7 +22815,7 @@ snapshots:
'@jest/types': 29.6.3
babel-jest: 29.7.0(@babel/[email protected])
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@tsconfig/node10': 1.0.11
@@ -22825,15 +22829,15 @@ snapshots:
create-require: 1.1.1
diff: 4.0.2
make-error: 1.3.6
- typescript: 5.6.2
+ typescript: 5.7.2
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
optionalDependencies:
- typescript: 5.6.2
+ typescript: 5.7.2
dependencies:
@@ -22850,10 +22854,10 @@ snapshots:
dependencies:
tslib: 1.14.1
- typescript: 5.6.2
+ typescript: 5.7.2
optional: true
@@ -22949,7 +22953,7 @@ snapshots:
is-typed-array: 1.1.13
possible-typed-array-names: 1.0.0
@@ -23149,6 +23153,11 @@ snapshots:
acorn: 8.14.0
webpack-virtual-modules: 0.6.2
+ dependencies:
+ acorn: 8.14.0
+ webpack-virtual-modules: 0.6.2
+
dependencies:
anymatch: 3.1.3
@@ -23422,22 +23431,22 @@ snapshots:
- supports-color
- utf-8-validate
dependencies:
debug: 4.3.7([email protected])
globrex: 0.1.2
- tsconfck: 3.1.3([email protected])
+ tsconfck: 3.1.3([email protected])
optionalDependencies:
transitivePeerDependencies:
- supports-color
- typescript
dependencies:
debug: 4.3.7([email protected])
globrex: 0.1.2
- tsconfck: 3.1.3([email protected])
+ tsconfck: 3.1.3([email protected])
optionalDependencies:
transitivePeerDependencies:
@@ -23618,6 +23627,8 @@ snapshots:
+
dependencies:
camelcase: 5.3.1