Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/CapSoftware/cap
Browse files Browse the repository at this point in the history
  • Loading branch information
richiemcilroy committed Nov 27, 2024
2 parents 6b646d1 + 043318b commit c6065d2
Show file tree
Hide file tree
Showing 58 changed files with 1,891 additions and 1,220 deletions.
80 changes: 78 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -30,16 +30,17 @@
"@solidjs/router": "^0.14.2",
"@solidjs/start": "^1.0.6",
"@tanstack/solid-query": "^5.51.21",
"@tauri-apps/api": ">=2.0.0-rc.0",
"@tauri-apps/api": "^2.1.1",
"@tauri-apps/plugin-clipboard-manager": "^2.0.0",
"@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",
Expand All @@ -58,8 +59,9 @@
"@fontsource/geist-sans": "^5.0.3",
"@iconify/json": "^2.2.239",
"@tauri-apps/cli": ">=2.0.0-rc.0",
"@total-typescript/ts-reset": "^0.6.1",
"@types/dom-webcodecs": "^0.1.11",
"typescript": "^5.2.2",
"typescript": "^5.7.2",
"vite": "^5.4.3",
"vite-tsconfig-paths": "^5.0.1"
}
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "desktop"
version = "0.3.0-beta.9.3"
version = "0.3.0-beta.10"
description = "Beautiful, shareable screen recordings."
authors = ["you"]
edition = "2021"
Expand Down Expand Up @@ -77,6 +77,7 @@ cap-flags = { path = "../../../crates/flags" }
cap-recording = { path = "../../../crates/recording" }
cap-export = { path = "../../../crates/export" }
tauri-plugin-window-state = "2.0.2"
tauri-plugin-clipboard-manager = "2.0.2"

[target.'cfg(target_os = "macos")'.dependencies]
core-graphics = "0.24.0"
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{
"identifier": "http:default",
"allow": [{ "url": "https://cap.so" }]
}
},
"clipboard-manager:allow-write-text"
]
}
3 changes: 1 addition & 2 deletions apps/desktop/src-tauri/src/auth.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use serde::{Deserialize, Serialize};
use serde_json::json;
use specta::Type;
Expand All @@ -12,7 +11,7 @@ use crate::web_api;
#[derive(Serialize, Deserialize, Type, Debug)]
pub struct AuthStore {
pub token: String,
pub user_id: String,
pub user_id: Option<String>,
pub expires: i32,
pub plan: Option<Plan>,
}
Expand Down
3 changes: 1 addition & 2 deletions apps/desktop/src-tauri/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
6 changes: 6 additions & 0 deletions apps/desktop/src-tauri/src/fake_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub async fn remove_fake_window(
}

pub fn spawn_fake_window_listener(app: AppHandle, window: WebviewWindow) {
window.set_ignore_cursor_events(true).ok();

tokio::spawn(async move {
let state = app.state::<FakeWindowBounds>();

Expand Down Expand Up @@ -91,3 +93,7 @@ pub fn spawn_fake_window_listener(app: AppHandle, window: WebviewWindow) {
}
});
}

pub fn init(app: &AppHandle) {
app.manage(FakeWindowBounds(Default::default()));
}
50 changes: 36 additions & 14 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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,
})
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -1666,6 +1669,18 @@ async fn check_notification_permissions(app: AppHandle) {
}
}

#[tauri::command]
#[specta::specta]
fn set_window_theme(window: tauri::Window, dark: bool) {
window
.set_theme(Some(if dark {
tauri::Theme::Dark
} else {
tauri::Theme::Light
}))
.ok();
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub async fn run() {
let specta_builder = tauri_specta::Builder::new()
Expand Down Expand Up @@ -1720,7 +1735,7 @@ pub async fn run() {
windows::position_traffic_lights,
global_message_dialog,
show_window,
platform::macos::write_string_to_pasteboard,
set_window_theme,
])
.events(tauri_specta::collect_events![
RecordingOptionsChanged,
Expand Down Expand Up @@ -1785,13 +1800,21 @@ pub async fn run() {
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_notification::init())
.plugin(tauri_plugin_clipboard_manager::init())
.plugin(
tauri_plugin_window_state::Builder::new()
.with_state_flags({
use tauri_plugin_window_state::StateFlags;
let mut flags = StateFlags::all();
flags.remove(StateFlags::VISIBLE);
flags
})
.with_denylist(&[
CapWindowId::Setup.label().as_str(),
CapWindowId::WindowCaptureOccluder.label().as_str(),
CapWindowId::Camera.label().as_str(),
CapWindowId::PrevRecordings.label().as_str(),
CapWindowId::InProgressRecording.label().as_str(),
])
.map_label(|label| match label {
label if label.starts_with("editor-") => "editor",
Expand All @@ -1806,11 +1829,12 @@ pub async fn run() {
specta_builder.mount_events(&app);
hotkeys::init(&app);
general_settings::init(&app);
fake_window::init(&app);

if let Ok(Some(auth)) = AuthStore::load(&app) {
sentry::configure_scope(|scope| {
scope.set_user(Some(sentry::User {
id: Some(auth.user_id),
scope.set_user(auth.user_id.map(|id| sentry::User {
id: Some(id),
..Default::default()
}));
});
Expand Down Expand Up @@ -1861,8 +1885,6 @@ pub async fn run() {
pre_created_video: None,
})));

app.manage(FakeWindowBounds(Arc::new(RwLock::new(HashMap::new()))));

tray::create_tray(&app).unwrap();

RequestStartRecording::listen_any_spawn(&app, |_, app| async move {
Expand Down
5 changes: 0 additions & 5 deletions apps/desktop/src-tauri/src/platform/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -55,8 +52,6 @@ extern "C" {
rect: *mut CGRect,
) -> boolean_t;
}
#[tauri::command]
#[specta::specta]
pub fn write_string_to_pasteboard(string: &str) {
use cocoa::appkit::NSPasteboard;
use cocoa::base::{id, nil};
Expand Down
Loading

1 comment on commit c6065d2

@vercel
Copy link

@vercel vercel bot commented on c6065d2 Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.