app: drop the old Tauri front end
tauri-app/ was kept while the native app caught up, and the screens it had are covered now. Its 48 tracked files go; the 7.6 GB of node_modules, dist and target beside them were never tracked and are gone from the working copy too. The docs that said it was still in the tree name two programs now, and the comments that pointed at a file inside it name the old app's file instead, so nothing refers to a folder that is no longer there. The design plans under plans/ keep their wording: they are dated documents, not instructions.
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
# Working in this repository
|
# Working in this repository
|
||||||
|
|
||||||
The repository holds two Rust programs: `record-daemon/` (the recorder) and `app/` (the rune
|
The repository holds two Rust programs: `record-daemon/` (the recorder) and `app/` (the rune
|
||||||
front end). `tauri-app/` is the old front end, kept for reference.
|
front end).
|
||||||
|
|
||||||
## Before every commit
|
## Before every commit
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# League Recorder (rune app)
|
# League Recorder (rune app)
|
||||||
|
|
||||||
The native replacement for `tauri-app`. It talks to `record-daemon` over the daemon's existing
|
The native front end for `record-daemon`. It talks to the daemon over its existing
|
||||||
named-pipe protocol and draws with [rune](https://github.com/anomalyco/rune).
|
named-pipe protocol and draws with [rune](https://github.com/anomalyco/rune).
|
||||||
|
|
||||||
## Run it
|
## Run it
|
||||||
@@ -118,8 +118,6 @@ reading (`history::tests`), highlight clipping (`highlight::tests`) and formatti
|
|||||||
runtime beside the exe. `cargo install cargo-packager --locked && cargo packager --release`.
|
runtime beside the exe. `cargo install cargo-packager --locked && cargo packager --release`.
|
||||||
On the first run the app downloads ffmpeg (`--fetch-ffmpeg` does it from a shell), so clip
|
On the first run the app downloads ffmpeg (`--fetch-ffmpeg` does it from a shell), so clip
|
||||||
export is ready before the first clip. The installer has not been run on a clean VM yet.
|
export is ready before the first clip. The installer has not been run on a clean VM yet.
|
||||||
10. Parity: `tauri-app` is still in the tree. Delete it once the items above are verified on a
|
|
||||||
machine with a live League Client.
|
|
||||||
|
|
||||||
### The recording screen
|
### The recording screen
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Rune app (replaces tauri-app)
|
Rune app
|
||||||
|
|
||||||
Decided
|
Decided
|
||||||
- UI framework: rune (github.com/anomalyco/rune, pin a dev rev). gpui is the
|
- UI framework: rune (github.com/anomalyco/rune, pin a dev rev). gpui is the
|
||||||
@@ -49,17 +49,14 @@ framework, stop and switch to gpui before writing anything else.
|
|||||||
8. Installer: cargo-packager NSIS target with the bundle list below.
|
8. Installer: cargo-packager NSIS target with the bundle list below.
|
||||||
Done when the installer works on a clean Windows VM and the app
|
Done when the installer works on a clean Windows VM and the app
|
||||||
records a real game end to end.
|
records a real game end to end.
|
||||||
9. Parity check against tauri-app, then delete it.
|
|
||||||
|
|
||||||
Stable contracts
|
Stable contracts
|
||||||
- record-daemon does not change. The IPC protocol (IpcCommand serde types
|
- record-daemon does not change. The IPC protocol (IpcCommand serde types
|
||||||
over named pipes) is the versioned interface between app and daemon.
|
over named pipes) is the versioned interface between app and daemon.
|
||||||
- Port tauri-app/src-tauri/src/daemon_ipc.rs (645 lines, pipe client) into
|
- The pipe client came from the old Tauri app's daemon_ipc.rs (645 lines),
|
||||||
app/ nearly as-is; it is plain Rust + tokio.
|
ported into app/ nearly as-is; it is plain Rust + tokio.
|
||||||
- Port the disk-side helpers from src-tauri/src/lib.rs: get_game_history,
|
- The disk-side helpers came from its lib.rs: get_game_history, export_clip,
|
||||||
export_clip, find_video_file and the ffmpeg_sidecar download logic.
|
find_video_file and the ffmpeg_sidecar download logic.
|
||||||
- Keep tauri-app/ working until the native app reaches feature parity.
|
|
||||||
Build app/ as a separate crate; do not mutate tauri-app in place.
|
|
||||||
|
|
||||||
Installer contents
|
Installer contents
|
||||||
- app exe, record-daemon.exe, obs.dll, ffmpeg sidecar, libmpv-2.dll.
|
- app exe, record-daemon.exe, obs.dll, ffmpeg sidecar, libmpv-2.dll.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! Finding, starting and logging the record-daemon process.
|
//! Finding, starting and logging the record-daemon process.
|
||||||
//!
|
//!
|
||||||
//! Ported from `tauri-app/src-tauri/src/daemon_ipc.rs`. The daemon binary ships next to the
|
//! Ported from the old Tauri app's `daemon_ipc.rs`. The daemon binary ships next to the
|
||||||
//! app; inside a checkout it is found in `record-daemon/target/{release,debug}`.
|
//! app; inside a checkout it is found in `record-daemon/target/{release,debug}`.
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//! Clip export with ffmpeg, ported from `export_clip` and `export_clip_precise` in
|
//! Clip export with ffmpeg, ported from `export_clip` and `export_clip_precise` in
|
||||||
//! `tauri-app/src-tauri/src/lib.rs`.
|
//! the old Tauri app's `lib.rs`.
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//! Text formatting shared by the screens, matching `tauri-app/src/types/timeline.ts`.
|
//! Text formatting shared by the screens, matching the old Tauri app's `types/timeline.ts`.
|
||||||
|
|
||||||
use chrono::{DateTime, Local, Utc};
|
use chrono::{DateTime, Local, Utc};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//! Highlight clips from timeline events, ported from `computeHighlights` in
|
//! Highlight clips from timeline events, ported from `computeHighlights` in
|
||||||
//! `tauri-app/src/types/timeline.ts`.
|
//! the old Tauri app's `types/timeline.ts`.
|
||||||
|
|
||||||
use crate::history::{Timeline, TimelineEvent};
|
use crate::history::{Timeline, TimelineEvent};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//! Reading the daemon's timelines from disk and the values the screens show.
|
//! Reading the daemon's timelines from disk and the values the screens show.
|
||||||
//!
|
//!
|
||||||
//! Ported from `tauri-app/src-tauri/src/lib.rs` (`get_game_history`, `get_timeline`,
|
//! Ported from the old Tauri app's `lib.rs` (`get_game_history`, `get_timeline`,
|
||||||
//! `find_video_file`) and the extractors in `tauri-app/src/types/timeline.ts`.
|
//! `find_video_file`) and the extractors in its `types/timeline.ts`.
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! Client for the record-daemon's IPC protocol.
|
//! Client for the record-daemon's IPC protocol.
|
||||||
//!
|
//!
|
||||||
//! Ported from `tauri-app/src-tauri/src/daemon_ipc.rs`. The wire format is the daemon's
|
//! Ported from the old Tauri app's `daemon_ipc.rs`. The wire format is the daemon's
|
||||||
//! (`record-daemon/src/ipc/protocol.rs`): one JSON object per line over a named pipe, a
|
//! (`record-daemon/src/ipc/protocol.rs`): one JSON object per line over a named pipe, a
|
||||||
//! `request` answered by one `response` with the same id.
|
//! `request` answered by one `response` with the same id.
|
||||||
//!
|
//!
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! League Recorder: a native desktop app for the record-daemon.
|
//! League Recorder: a native desktop app for the record-daemon.
|
||||||
//!
|
//!
|
||||||
//! Replaces `tauri-app`. The daemon keeps its IPC protocol; this app is a client of it.
|
//! Replaces the old Tauri app. The daemon keeps its IPC protocol; this app is a client of it.
|
||||||
//! `cargo run` opens the window; `cargo run -- --snap out.png` renders it headless.
|
//! `cargo run` opens the window; `cargo run -- --snap out.png` renders it headless.
|
||||||
//!
|
//!
|
||||||
//! The binary is a windowed app on Windows, so launching it from Explorer, the Run key or the
|
//! The binary is a windowed app on Windows, so launching it from Explorer, the Run key or the
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//! Windows integration that the Tauri app got from plugins: launch at login, one instance,
|
//! Windows integration that the old Tauri app got from plugins: launch at login, one instance,
|
||||||
//! toast notifications and the tray icon.
|
//! toast notifications and the tray icon.
|
||||||
|
|
||||||
/// The app's reverse-DNS id, used for single-instance and notifications.
|
/// The app's reverse-DNS id, used for single-instance and notifications.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ A high-performance League of Legends recording daemon built with Rust and libobs
|
|||||||
- **Game Event Capture**: Captures game events (kills, deaths, objectives) via the League Client API (LQP)
|
- **Game Event Capture**: Captures game events (kills, deaths, objectives) via the League Client API (LQP)
|
||||||
- **Event Timeline**: Maps game events to video timestamps for easy navigation
|
- **Event Timeline**: Maps game events to video timestamps for easy navigation
|
||||||
- **Hardware Encoding**: Supports NVIDIA NVENC, AMD AMF, and software encoding (x264)
|
- **Hardware Encoding**: Supports NVIDIA NVENC, AMD AMF, and software encoding (x264)
|
||||||
- **IPC Interface**: Unix sockets (Linux) / Named pipes (Windows) for configuration and control from a Tauri app
|
- **IPC Interface**: Unix sockets (Linux) / Named pipes (Windows) for configuration and control from the app
|
||||||
- **Configurable Presets**: Quality presets from 720p30 to 1440p60
|
- **Configurable Presets**: Quality presets from 720p30 to 1440p60
|
||||||
- **Cross-Platform**: Supports Windows and Linux
|
- **Cross-Platform**: Supports Windows and Linux
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ crf = 23
|
|||||||
|
|
||||||
## IPC Protocol
|
## IPC Protocol
|
||||||
|
|
||||||
The daemon exposes an IPC server for communication with the Tauri app.
|
The daemon exposes an IPC server for communication with the app.
|
||||||
|
|
||||||
### Socket Location
|
### Socket Location
|
||||||
- Linux: `$XDG_RUNTIME_DIR/record-daemon.sock` (or `/tmp/record-daemon.sock`)
|
- Linux: `$XDG_RUNTIME_DIR/record-daemon.sock` (or `/tmp/record-daemon.sock`)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//! IPC module for communication with the Tauri app.
|
//! IPC module for communication with the app.
|
||||||
//!
|
//!
|
||||||
//! This module provides a Unix socket-based IPC server that allows
|
//! This module provides a Unix socket-based IPC server that allows
|
||||||
//! the Tauri app to configure and control the daemon.
|
//! the app to configure and control the daemon.
|
||||||
|
|
||||||
mod handlers;
|
mod handlers;
|
||||||
mod protocol;
|
mod protocol;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//! IPC server for communication with the Tauri app.
|
//! IPC server for communication with the app.
|
||||||
//!
|
//!
|
||||||
//! Uses Unix domain sockets on Linux and named pipes on Windows.
|
//! Uses Unix domain sockets on Linux and named pipes on Windows.
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ type PlatformListener = tokio::net::UnixListener;
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
type PlatformStream = tokio::net::UnixStream;
|
type PlatformStream = tokio::net::UnixStream;
|
||||||
|
|
||||||
/// IPC server for communication with Tauri app (Linux).
|
/// IPC server for communication with the app (Linux).
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub struct IpcServer {
|
pub struct IpcServer {
|
||||||
/// Server configuration.
|
/// Server configuration.
|
||||||
@@ -306,7 +306,7 @@ impl Clone for IpcServer {
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
|
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
|
||||||
|
|
||||||
/// IPC server for communication with Tauri app (Windows).
|
/// IPC server for communication with the app (Windows).
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub struct IpcServer {
|
pub struct IpcServer {
|
||||||
/// Server configuration.
|
/// Server configuration.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! This daemon automatically records League of Legends matches using libobs,
|
//! This daemon automatically records League of Legends matches using libobs,
|
||||||
//! captures game events via the League Client API (LQP), and exposes
|
//! captures game events via the League Client API (LQP), and exposes
|
||||||
//! configuration via a Unix socket IPC for the Tauri app.
|
//! configuration via a Unix socket IPC for the app.
|
||||||
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
//!
|
//!
|
||||||
//! The record-daemon stores raw API JSON data only — no typed event parsing.
|
//! The record-daemon stores raw API JSON data only — no typed event parsing.
|
||||||
//! Event types are simple string constants derived from the URI, used for
|
//! Event types are simple string constants derived from the URI, used for
|
||||||
//! classification and state machine transitions. The tauri-app parses the
|
//! classification and state machine transitions. The app parses the raw data
|
||||||
//! raw data it needs on the frontend side.
|
//! it needs on the frontend side.
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ pub struct TimestampedEvent {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub description: String,
|
pub description: String,
|
||||||
/// The raw JSON data from the API — the single source of truth.
|
/// The raw JSON data from the API — the single source of truth.
|
||||||
/// The tauri-app parses the values it needs from this data.
|
/// The app parses the values it needs from this data.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub raw_data: serde_json::Value,
|
pub raw_data: serde_json::Value,
|
||||||
/// URI of the endpoint that triggered this event.
|
/// URI of the endpoint that triggered this event.
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
pnpm-debug.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
|
|
||||||
node_modules
|
|
||||||
dist
|
|
||||||
dist-ssr
|
|
||||||
*.local
|
|
||||||
|
|
||||||
# Editor directories and files
|
|
||||||
.vscode/*
|
|
||||||
!.vscode/extensions.json
|
|
||||||
.idea
|
|
||||||
.DS_Store
|
|
||||||
*.suo
|
|
||||||
*.ntvs*
|
|
||||||
*.njsproj
|
|
||||||
*.sln
|
|
||||||
*.sw?
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"recommendations": [
|
|
||||||
"Vue.volar",
|
|
||||||
"tauri-apps.tauri-vscode",
|
|
||||||
"rust-lang.rust-analyzer"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# Tauri + Vue + TypeScript
|
|
||||||
|
|
||||||
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
|
||||||
|
|
||||||
## Recommended IDE Setup
|
|
||||||
|
|
||||||
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
|
|
||||||
|
|
||||||
## Type Support For `.vue` Imports in TS
|
|
||||||
|
|
||||||
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
|
|
||||||
|
|
||||||
1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
|
|
||||||
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
|
|
||||||
|
|
||||||
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>Tauri + Vue + Typescript App</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div id="app"></div>
|
|
||||||
<script type="module" src="/src/main.ts"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "tauri-app",
|
|
||||||
"private": true,
|
|
||||||
"version": "0.3.0",
|
|
||||||
"type": "module",
|
|
||||||
"scripts": {
|
|
||||||
"dev": "vite",
|
|
||||||
"build": "vue-tsc --noEmit && vite build",
|
|
||||||
"preview": "vite preview",
|
|
||||||
"tauri": "tauri"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"vue": "^3.5.13",
|
|
||||||
"@tauri-apps/api": "^2",
|
|
||||||
"@tauri-apps/plugin-opener": "^2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@vitejs/plugin-vue": "^5.2.1",
|
|
||||||
"typescript": "~5.6.2",
|
|
||||||
"vite": "^6.0.3",
|
|
||||||
"vue-tsc": "^2.1.10",
|
|
||||||
"@tauri-apps/cli": "^2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<svg width="206" height="231" viewBox="0 0 206 231" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M143.143 84C143.143 96.1503 133.293 106 121.143 106C108.992 106 99.1426 96.1503 99.1426 84C99.1426 71.8497 108.992 62 121.143 62C133.293 62 143.143 71.8497 143.143 84Z" fill="#FFC131"/>
|
|
||||||
<ellipse cx="84.1426" cy="147" rx="22" ry="22" transform="rotate(180 84.1426 147)" fill="#24C8DB"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M166.738 154.548C157.86 160.286 148.023 164.269 137.757 166.341C139.858 160.282 141 153.774 141 147C141 144.543 140.85 142.121 140.558 139.743C144.975 138.204 149.215 136.139 153.183 133.575C162.73 127.404 170.292 118.608 174.961 108.244C179.63 97.8797 181.207 86.3876 179.502 75.1487C177.798 63.9098 172.884 53.4021 165.352 44.8883C157.82 36.3744 147.99 30.2165 137.042 27.1546C126.095 24.0926 114.496 24.2568 103.64 27.6274C92.7839 30.998 83.1319 37.4317 75.8437 46.1553C74.9102 47.2727 74.0206 48.4216 73.176 49.5993C61.9292 50.8488 51.0363 54.0318 40.9629 58.9556C44.2417 48.4586 49.5653 38.6591 56.679 30.1442C67.0505 17.7298 80.7861 8.57426 96.2354 3.77762C111.685 -1.01901 128.19 -1.25267 143.769 3.10474C159.348 7.46215 173.337 16.2252 184.056 28.3411C194.775 40.457 201.767 55.4101 204.193 71.404C206.619 87.3978 204.374 103.752 197.73 118.501C191.086 133.25 180.324 145.767 166.738 154.548ZM41.9631 74.275L62.5557 76.8042C63.0459 72.813 63.9401 68.9018 65.2138 65.1274C57.0465 67.0016 49.2088 70.087 41.9631 74.275Z" fill="#FFC131"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M38.4045 76.4519C47.3493 70.6709 57.2677 66.6712 67.6171 64.6132C65.2774 70.9669 64 77.8343 64 85.0001C64 87.1434 64.1143 89.26 64.3371 91.3442C60.0093 92.8732 55.8533 94.9092 51.9599 97.4256C42.4128 103.596 34.8505 112.392 30.1816 122.756C25.5126 133.12 23.9357 144.612 25.6403 155.851C27.3449 167.09 32.2584 177.598 39.7906 186.112C47.3227 194.626 57.153 200.784 68.1003 203.846C79.0476 206.907 90.6462 206.743 101.502 203.373C112.359 200.002 122.011 193.568 129.299 184.845C130.237 183.722 131.131 182.567 131.979 181.383C143.235 180.114 154.132 176.91 164.205 171.962C160.929 182.49 155.596 192.319 148.464 200.856C138.092 213.27 124.357 222.426 108.907 227.222C93.458 232.019 76.9524 232.253 61.3736 227.895C45.7948 223.538 31.8055 214.775 21.0867 202.659C10.3679 190.543 3.37557 175.59 0.949823 159.596C-1.47592 143.602 0.768139 127.248 7.41237 112.499C14.0566 97.7497 24.8183 85.2327 38.4045 76.4519ZM163.062 156.711L163.062 156.711C162.954 156.773 162.846 156.835 162.738 156.897C162.846 156.835 162.954 156.773 163.062 156.711Z" fill="#24C8DB"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 2.5 KiB |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.5 KiB |
@@ -1,10 +0,0 @@
|
|||||||
# Generated by Cargo
|
|
||||||
# will have compiled files and executables
|
|
||||||
/target/
|
|
||||||
|
|
||||||
# Generated by Tauri
|
|
||||||
# will have schema files for capabilities auto-completion
|
|
||||||
/gen/schemas
|
|
||||||
|
|
||||||
# Bundled record-daemon binaries (built by build.rs)
|
|
||||||
/binaries/
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "leaguerecorder"
|
|
||||||
version = "0.3.0"
|
|
||||||
description = "A Tauri App"
|
|
||||||
authors = ["you"]
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
# The `_lib` suffix may seem redundant but it is necessary
|
|
||||||
# to make the lib name unique and wouldn't conflict with the bin name.
|
|
||||||
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
|
||||||
name = "tauri_app_lib"
|
|
||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
tauri-build = { version = "2", features = [] }
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
tauri = { version = "2", features = ["protocol-asset"] }
|
|
||||||
tauri-plugin-opener = "2"
|
|
||||||
tauri-plugin-autostart = "2"
|
|
||||||
serde = { version = "1", features = ["derive"] }
|
|
||||||
serde_json = "1"
|
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
|
||||||
uuid = { version = "1", features = ["v4", "serde"] }
|
|
||||||
directories = "6"
|
|
||||||
ffmpeg-sidecar = "2.4"
|
|
||||||
tokio = { version = "1", features = ["net", "io-util", "time", "rt"] }
|
|
||||||
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
fn main() {
|
|
||||||
build_record_daemon();
|
|
||||||
tauri_build::build()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Build the record-daemon in release mode and place it in the binaries/
|
|
||||||
/// directory with the target-triple suffix that Tauri's `externalBin` feature
|
|
||||||
/// expects.
|
|
||||||
///
|
|
||||||
/// The resulting binary is copied to:
|
|
||||||
/// src-tauri/binaries/record-daemon-<target-triple>[.exe]
|
|
||||||
///
|
|
||||||
/// This runs as part of `cargo build`, so the daemon is always available when
|
|
||||||
/// the Tauri bundler needs it. Because record-daemon lives in a separate
|
|
||||||
/// Cargo workspace, invoking `cargo build` from here does not conflict with
|
|
||||||
/// the parent build's lock.
|
|
||||||
fn build_record_daemon() {
|
|
||||||
use std::env;
|
|
||||||
use std::fs;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
let target = env::var("TARGET").unwrap();
|
|
||||||
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
|
||||||
|
|
||||||
// Resolve the record-daemon crate root (../../record-daemon/ from src-tauri/)
|
|
||||||
let daemon_dir = manifest_dir
|
|
||||||
.parent()
|
|
||||||
.expect("CARGO_MANIFEST_DIR has no parent")
|
|
||||||
.parent()
|
|
||||||
.expect("parent of CARGO_MANIFEST_DIR has no parent")
|
|
||||||
.join("record-daemon");
|
|
||||||
|
|
||||||
let daemon_manifest = daemon_dir.join("Cargo.toml");
|
|
||||||
if !daemon_manifest.exists() {
|
|
||||||
eprintln!(
|
|
||||||
"cargo:warning=record-daemon not found at {}, skipping daemon build",
|
|
||||||
daemon_manifest.display()
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the daemon in release mode for the same target triple.
|
|
||||||
// Passing --target ensures the output lands in a predictable directory
|
|
||||||
// and supports cross-compilation.
|
|
||||||
let status = Command::new("cargo")
|
|
||||||
.args([
|
|
||||||
"build",
|
|
||||||
"--release",
|
|
||||||
"--manifest-path",
|
|
||||||
])
|
|
||||||
.arg(&daemon_manifest)
|
|
||||||
.arg("--target")
|
|
||||||
.arg(&target)
|
|
||||||
.status()
|
|
||||||
.expect("Failed to execute cargo build for record-daemon");
|
|
||||||
|
|
||||||
if !status.success() {
|
|
||||||
panic!("Failed to build record-daemon in release mode");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Locate the built binary.
|
|
||||||
// When --target is specified, cargo places output in target/<triple>/release/.
|
|
||||||
let src_name = if target.contains("windows") {
|
|
||||||
"record-daemon.exe"
|
|
||||||
} else {
|
|
||||||
"record-daemon"
|
|
||||||
};
|
|
||||||
let src_binary = daemon_dir
|
|
||||||
.join("target")
|
|
||||||
.join(&target)
|
|
||||||
.join("release")
|
|
||||||
.join(src_name);
|
|
||||||
|
|
||||||
if !src_binary.exists() {
|
|
||||||
panic!(
|
|
||||||
"record-daemon binary not found at {} after successful build",
|
|
||||||
src_binary.display()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy to src-tauri/binaries/record-daemon-<target-triple>[.exe]
|
|
||||||
let binaries_dir = manifest_dir.join("binaries");
|
|
||||||
fs::create_dir_all(&binaries_dir).expect("Failed to create binaries directory");
|
|
||||||
|
|
||||||
let dst_name = if target.contains("windows") {
|
|
||||||
format!("record-daemon-{}.exe", target)
|
|
||||||
} else {
|
|
||||||
format!("record-daemon-{}", target)
|
|
||||||
};
|
|
||||||
let dst_binary = binaries_dir.join(&dst_name);
|
|
||||||
|
|
||||||
fs::copy(&src_binary, &dst_binary).expect("Failed to copy record-daemon binary");
|
|
||||||
fs::copy(daemon_dir
|
|
||||||
.join("target")
|
|
||||||
.join(&target)
|
|
||||||
.join("release")
|
|
||||||
.join("obs.dll"), binaries_dir.join("obs.dll")).expect("Failed to copy record-daemon dummy obs.dll");
|
|
||||||
println!(
|
|
||||||
"cargo:warning=Bundled record-daemon → {}",
|
|
||||||
dst_binary.display()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "../gen/schemas/desktop-schema.json",
|
|
||||||
"identifier": "default",
|
|
||||||
"description": "Capability for the main window",
|
|
||||||
"windows": ["main"],
|
|
||||||
"permissions": [
|
|
||||||
"core:default",
|
|
||||||
"opener:default",
|
|
||||||
"autostart:allow-enable",
|
|
||||||
"autostart:allow-disable",
|
|
||||||
"autostart:allow-is-enabled"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 903 B |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 229 KiB |
|
Before Width: | Height: | Size: 797 KiB |
@@ -1,645 +0,0 @@
|
|||||||
//! IPC client for communicating with the record-daemon.
|
|
||||||
//!
|
|
||||||
//! Connects to the daemon via named pipes on Windows or Unix sockets on Linux,
|
|
||||||
//! using the same JSON-over-newline-delimited protocol.
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Protocol types (mirror of record-daemon IPC protocol)
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// IPC message wrapper.
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct IpcMessage {
|
|
||||||
#[serde(rename = "type")]
|
|
||||||
pub message_type: MessageType,
|
|
||||||
pub id: String,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub command: Option<String>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub payload: Option<serde_json::Value>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Message type.
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
||||||
#[serde(rename_all = "lowercase")]
|
|
||||||
pub enum MessageType {
|
|
||||||
Request,
|
|
||||||
Response,
|
|
||||||
Notification,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// IPC response from the daemon.
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct IpcResponse {
|
|
||||||
pub request_id: String,
|
|
||||||
pub success: bool,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub data: Option<serde_json::Value>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub error: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// IPC commands (camelCase to match daemon's serde rename)
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// IPC command names matching the daemon's `IpcCommand` enum.
|
|
||||||
pub mod commands {
|
|
||||||
pub const GET_SETTINGS: &str = "getSettings";
|
|
||||||
pub const UPDATE_SETTINGS: &str = "updateSettings";
|
|
||||||
pub const RESET_SETTINGS: &str = "resetSettings";
|
|
||||||
pub const GET_STATUS: &str = "getStatus";
|
|
||||||
pub const GET_ENCODERS: &str = "getEncoders";
|
|
||||||
pub const GET_AUDIO_DEVICES: &str = "getAudioDevices";
|
|
||||||
pub const ADD_AUDIO_SOURCE: &str = "addAudioSource";
|
|
||||||
pub const REMOVE_AUDIO_SOURCE: &str = "removeAudioSource";
|
|
||||||
pub const UPDATE_AUDIO_SOURCE: &str = "updateAudioSource";
|
|
||||||
pub const START_RECORDING: &str = "startRecording";
|
|
||||||
pub const STOP_RECORDING: &str = "stopRecording";
|
|
||||||
pub const SHUTDOWN: &str = "shutdown";
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Default socket path (same logic as daemon)
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Default socket path for the IPC server.
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
pub fn default_socket_path() -> PathBuf {
|
|
||||||
PathBuf::from(r"\\.\pipe\record-daemon")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Default socket path for the IPC server.
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
pub fn default_socket_path() -> PathBuf {
|
|
||||||
std::env::var("XDG_RUNTIME_DIR")
|
|
||||||
.map(PathBuf::from)
|
|
||||||
.unwrap_or_else(|_| PathBuf::from("/tmp"))
|
|
||||||
.join("record-daemon.sock")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// IPC Client
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// IPC client for communicating with the record-daemon.
|
|
||||||
pub struct IpcClient {
|
|
||||||
socket_path: PathBuf,
|
|
||||||
timeout: Duration,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IpcClient {
|
|
||||||
/// Create a new IPC client with the default socket path.
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
socket_path: default_socket_path(),
|
|
||||||
timeout: Duration::from_secs(5),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new IPC client with a custom socket path.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn with_socket_path(socket_path: PathBuf) -> Self {
|
|
||||||
Self {
|
|
||||||
socket_path,
|
|
||||||
timeout: Duration::from_secs(5),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send a command to the daemon and return the response.
|
|
||||||
pub async fn send_command(
|
|
||||||
&self,
|
|
||||||
command: &str,
|
|
||||||
payload: Option<serde_json::Value>,
|
|
||||||
) -> Result<IpcResponse, String> {
|
|
||||||
let id = uuid::Uuid::new_v4().to_string();
|
|
||||||
let message = IpcMessage {
|
|
||||||
message_type: MessageType::Request,
|
|
||||||
id: id.clone(),
|
|
||||||
command: Some(command.to_string()),
|
|
||||||
payload,
|
|
||||||
};
|
|
||||||
|
|
||||||
let message_json = serde_json::to_string(&message)
|
|
||||||
.map_err(|e| format!("Failed to serialize message: {}", e))?;
|
|
||||||
|
|
||||||
let response_str = self.send_raw(&message_json).await?;
|
|
||||||
|
|
||||||
let response: IpcResponse = serde_json::from_str(&response_str)
|
|
||||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
|
||||||
|
|
||||||
Ok(response)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send a raw JSON string and read the response.
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
async fn send_raw(&self, message: &str) -> Result<String, String> {
|
|
||||||
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
|
|
||||||
use tokio::net::windows::named_pipe::ClientOptions;
|
|
||||||
|
|
||||||
// Connect to the named pipe
|
|
||||||
let pipe_name = self.socket_path.to_string_lossy().to_string();
|
|
||||||
|
|
||||||
let client = tokio::time::timeout(self.timeout, async {
|
|
||||||
// Try to connect - if the pipe is busy, retry a few times
|
|
||||||
let mut attempts = 0;
|
|
||||||
loop {
|
|
||||||
match ClientOptions::new().open(&pipe_name) {
|
|
||||||
Ok(client) => return Ok(client),
|
|
||||||
Err(e) if e.raw_os_error() == Some(231) => {
|
|
||||||
// ERROR_PIPE_BUSY = 231
|
|
||||||
attempts += 1;
|
|
||||||
if attempts > 5 {
|
|
||||||
return Err(format!("Pipe busy after 5 attempts: {}", e));
|
|
||||||
}
|
|
||||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
|
||||||
}
|
|
||||||
Err(e) => return Err(format!("Failed to connect to daemon: {}", e)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.map_err(|_| "Connection to daemon timed out".to_string())??;
|
|
||||||
|
|
||||||
let (reader, mut writer) = tokio::io::split(client);
|
|
||||||
|
|
||||||
// Send message
|
|
||||||
writer
|
|
||||||
.write_all(message.as_bytes())
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("Failed to write to pipe: {}", e))?;
|
|
||||||
writer
|
|
||||||
.write_all(b"\n")
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("Failed to write newline: {}", e))?;
|
|
||||||
writer
|
|
||||||
.flush()
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("Failed to flush pipe: {}", e))?;
|
|
||||||
|
|
||||||
// Read response
|
|
||||||
let mut lines = BufReader::new(reader).lines();
|
|
||||||
let line = tokio::time::timeout(self.timeout, lines.next_line())
|
|
||||||
.await
|
|
||||||
.map_err(|_| "Reading from daemon timed out".to_string())?
|
|
||||||
.map_err(|e| format!("Failed to read from pipe: {}", e))?;
|
|
||||||
|
|
||||||
match line {
|
|
||||||
Some(line) => Ok(line),
|
|
||||||
None => Err("Daemon closed connection without response".to_string()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send a raw JSON string and read the response (Linux).
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
async fn send_raw(&self, message: &str) -> Result<String, String> {
|
|
||||||
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
|
|
||||||
use tokio::net::UnixStream;
|
|
||||||
|
|
||||||
let stream = tokio::time::timeout(self.timeout, UnixStream::connect(&self.socket_path))
|
|
||||||
.await
|
|
||||||
.map_err(|_| "Connection to daemon timed out".to_string())?
|
|
||||||
.map_err(|e| format!("Failed to connect to daemon: {}", e))?;
|
|
||||||
|
|
||||||
let (reader, mut writer) = stream.into_split();
|
|
||||||
|
|
||||||
// Send message
|
|
||||||
writer
|
|
||||||
.write_all(message.as_bytes())
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("Failed to write to socket: {}", e))?;
|
|
||||||
writer
|
|
||||||
.write_all(b"\n")
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("Failed to write newline: {}", e))?;
|
|
||||||
writer
|
|
||||||
.flush()
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("Failed to flush socket: {}", e))?;
|
|
||||||
|
|
||||||
// Read response
|
|
||||||
let mut lines = BufReader::new(reader).lines();
|
|
||||||
let line = tokio::time::timeout(self.timeout, lines.next_line())
|
|
||||||
.await
|
|
||||||
.map_err(|_| "Reading from daemon timed out".to_string())?
|
|
||||||
.map_err(|e| format!("Failed to read from socket: {}", e))?;
|
|
||||||
|
|
||||||
match line {
|
|
||||||
Some(line) => Ok(line),
|
|
||||||
None => Err("Daemon closed connection without response".to_string()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if the daemon is reachable.
|
|
||||||
pub async fn is_daemon_running(&self) -> bool {
|
|
||||||
self.send_command(commands::GET_STATUS, None).await.is_ok()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Daemon binary discovery & process spawning
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Find the record-daemon binary.
|
|
||||||
///
|
|
||||||
/// Search order:
|
|
||||||
/// 1. Next to the current executable (bundled / installed mode)
|
|
||||||
/// 2. In `<exe_dir>/../resources/` (macOS .app bundle)
|
|
||||||
/// 3. Relative to the executable – walk up to the workspace root and look for
|
|
||||||
/// `record-daemon/target/{release,debug}/` (development mode)
|
|
||||||
/// 4. Relative to the current working directory (fallback for dev mode)
|
|
||||||
fn find_daemon_binary() -> Option<PathBuf> {
|
|
||||||
let exe_name = if cfg!(windows) {
|
|
||||||
"record-daemon.exe"
|
|
||||||
} else {
|
|
||||||
"record-daemon"
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Ok(exe_path) = std::env::current_exe() {
|
|
||||||
// 1. Next to the current executable
|
|
||||||
if let Some(exe_dir) = exe_path.parent() {
|
|
||||||
let candidate = exe_dir.join(exe_name);
|
|
||||||
if candidate.exists() {
|
|
||||||
return Some(candidate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. In <exe_dir>/../resources/
|
|
||||||
if let Some(exe_dir) = exe_path.parent().and_then(|p| p.parent()) {
|
|
||||||
let candidate = exe_dir.join("resources").join(exe_name);
|
|
||||||
if candidate.exists() {
|
|
||||||
return Some(candidate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Development mode – relative to the exe location.
|
|
||||||
// The exe is typically at <workspace>/tauri-app/src-tauri/target/debug/tauri-app.exe
|
|
||||||
// so we walk up to find <workspace>/record-daemon/target/{release,debug}/
|
|
||||||
if let Some(exe_dir) = exe_path.parent() {
|
|
||||||
// Try walking up from the exe directory to find the daemon
|
|
||||||
let dev_suffixes = [
|
|
||||||
Path::new("record-daemon/target/release"),
|
|
||||||
Path::new("record-daemon/target/debug"),
|
|
||||||
];
|
|
||||||
// Walk up at most 6 levels from the exe directory
|
|
||||||
let mut dir = exe_dir.to_path_buf();
|
|
||||||
for _ in 0..6 {
|
|
||||||
for suffix in &dev_suffixes {
|
|
||||||
let candidate = dir.join(suffix).join(exe_name);
|
|
||||||
if candidate.exists() {
|
|
||||||
return Some(candidate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !dir.pop() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Fallback – look relative to the current working directory
|
|
||||||
let cwd_dev_paths = [
|
|
||||||
Path::new("../../record-daemon/target/release"),
|
|
||||||
Path::new("../../record-daemon/target/debug"),
|
|
||||||
Path::new("../record-daemon/target/release"),
|
|
||||||
Path::new("../record-daemon/target/debug"),
|
|
||||||
];
|
|
||||||
for dir in &cwd_dev_paths {
|
|
||||||
let candidate = dir.join(exe_name);
|
|
||||||
if candidate.exists() {
|
|
||||||
return Some(candidate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the log file path for the daemon.
|
|
||||||
///
|
|
||||||
/// Returns a path in the app's data directory.
|
|
||||||
fn get_log_file_path() -> Result<PathBuf, String> {
|
|
||||||
let data_dir = directories::ProjectDirs::from("com", "leaguerecorder", "record-daemon")
|
|
||||||
.ok_or_else(|| "Failed to get app data directory".to_string())?;
|
|
||||||
|
|
||||||
let log_dir = data_dir.data_dir().join("logs");
|
|
||||||
std::fs::create_dir_all(&log_dir)
|
|
||||||
.map_err(|e| format!("Failed to create log directory: {}", e))?;
|
|
||||||
|
|
||||||
Ok(log_dir.join("daemon.log"))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Spawn the record-daemon as a detached background process.
|
|
||||||
///
|
|
||||||
/// Returns `Ok(())` if the process was successfully spawned.
|
|
||||||
fn spawn_daemon() -> Result<(), String> {
|
|
||||||
let binary = find_daemon_binary()
|
|
||||||
.ok_or_else(|| "record-daemon binary not found".to_string())?;
|
|
||||||
|
|
||||||
let log_file = get_log_file_path()?;
|
|
||||||
eprintln!("[daemon] Spawning record-daemon: {}", binary.display());
|
|
||||||
eprintln!("[daemon] Log file: {}", log_file.display());
|
|
||||||
|
|
||||||
let mut cmd = std::process::Command::new(&binary);
|
|
||||||
cmd.arg("--foreground");
|
|
||||||
cmd.arg("--log-file").arg(&log_file);
|
|
||||||
|
|
||||||
// Set the working directory to the daemon binary's directory so it can
|
|
||||||
// find its bundled resources (OBS plugins, etc.) relative to itself.
|
|
||||||
if let Some(bin_dir) = binary.parent() {
|
|
||||||
cmd.current_dir(bin_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detach from the parent process group so the daemon survives if the
|
|
||||||
// Tauri app is restarted.
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
use std::os::windows::process::CommandExt;
|
|
||||||
// CREATE_NEW_PROCESS_GROUP (0x200) | DETACHED_PROCESS (0x8)
|
|
||||||
cmd.creation_flags(0x00000200 | 0x00000008);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
{
|
|
||||||
use std::os::unix::process::CommandExt;
|
|
||||||
// Start in a new session so the daemon gets its own process group
|
|
||||||
cmd.process_group(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redirect stdio so the daemon doesn't inherit our handles
|
|
||||||
cmd.stdin(std::process::Stdio::null())
|
|
||||||
.stdout(std::process::Stdio::null())
|
|
||||||
.stderr(std::process::Stdio::null());
|
|
||||||
|
|
||||||
cmd.spawn()
|
|
||||||
.map_err(|e| format!("Failed to spawn record-daemon: {}", e))?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ensure the record-daemon is running.
|
|
||||||
///
|
|
||||||
/// If the daemon is already reachable via IPC, returns immediately.
|
|
||||||
/// Otherwise, spawns the daemon binary and waits up to `timeout_secs` seconds
|
|
||||||
/// for it to become ready.
|
|
||||||
pub async fn ensure_daemon_running(timeout_secs: u64) -> Result<bool, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
|
|
||||||
// Fast path – already running
|
|
||||||
if client.is_daemon_running().await {
|
|
||||||
return Ok(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spawn the daemon
|
|
||||||
spawn_daemon()?;
|
|
||||||
|
|
||||||
// Poll until the daemon responds or we time out
|
|
||||||
let deadline = tokio::time::Instant::now() + Duration::from_secs(timeout_secs);
|
|
||||||
loop {
|
|
||||||
if client.is_daemon_running().await {
|
|
||||||
return Ok(true);
|
|
||||||
}
|
|
||||||
if tokio::time::Instant::now() >= deadline {
|
|
||||||
return Ok(false);
|
|
||||||
}
|
|
||||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Tauri commands
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Check if the record-daemon is running.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_is_running() -> bool {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
client.is_daemon_running().await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ensure the record-daemon is running, starting it if necessary.
|
|
||||||
///
|
|
||||||
/// Returns `true` if the daemon is running (either already was or just started),
|
|
||||||
/// `false` if it could not be started within the timeout.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_ensure_running() -> Result<bool, String> {
|
|
||||||
ensure_daemon_running(30).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the daemon status.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_get_status() -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::GET_STATUS, None)
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the current daemon settings.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_get_settings() -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::GET_SETTINGS, None)
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
// The daemon wraps settings in { settings: {...} }
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Update daemon settings.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_update_settings(settings: serde_json::Value) -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::UPDATE_SETTINGS, Some(settings))
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Reset daemon settings to defaults.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_reset_settings() -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::RESET_SETTINGS, None)
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get available encoders from the daemon.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_get_encoders() -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::GET_ENCODERS, None)
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Start recording manually via the daemon.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_start_recording() -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::START_RECORDING, None)
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Stop recording via the daemon.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_stop_recording() -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::STOP_RECORDING, None)
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Shutdown the daemon.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_shutdown() -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::SHUTDOWN, None)
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get available audio devices from the daemon.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_get_audio_devices() -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::GET_AUDIO_DEVICES, None)
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add an audio source to the daemon settings.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_add_audio_source(source: serde_json::Value) -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::ADD_AUDIO_SOURCE, Some(source))
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove an audio source from the daemon settings.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_remove_audio_source(id: String) -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::REMOVE_AUDIO_SOURCE, Some(serde_json::json!({ "id": id })))
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Update an audio source in the daemon settings.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn daemon_update_audio_source(source: serde_json::Value) -> Result<serde_json::Value, String> {
|
|
||||||
let client = IpcClient::new();
|
|
||||||
let response = client
|
|
||||||
.send_command(commands::UPDATE_AUDIO_SOURCE, Some(source))
|
|
||||||
.await
|
|
||||||
.map_err(|e| e)?;
|
|
||||||
|
|
||||||
if response.success {
|
|
||||||
Ok(response.data.unwrap_or(serde_json::Value::Null))
|
|
||||||
} else {
|
|
||||||
Err(response.error.unwrap_or_else(|| "Unknown error".to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the daemon log file path.
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn daemon_get_log_path() -> Result<String, String> {
|
|
||||||
get_log_file_path()
|
|
||||||
.map(|p| p.to_string_lossy().to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Read the daemon log file.
|
|
||||||
///
|
|
||||||
/// Returns the last `lines` lines of the log file (default 100, max 1000).
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn daemon_read_logs(lines: Option<usize>) -> Result<String, String> {
|
|
||||||
let log_path = get_log_file_path()?;
|
|
||||||
let max_lines = lines.unwrap_or(100).min(1000);
|
|
||||||
|
|
||||||
let content = std::fs::read_to_string(&log_path)
|
|
||||||
.map_err(|e| format!("Failed to read log file: {}", e))?;
|
|
||||||
|
|
||||||
let lines: Vec<&str> = content.lines().rev().take(max_lines).collect();
|
|
||||||
Ok(lines.into_iter().rev().collect::<Vec<_>>().join("\n"))
|
|
||||||
}
|
|
||||||
@@ -1,455 +0,0 @@
|
|||||||
mod daemon_ipc;
|
|
||||||
|
|
||||||
use ffmpeg_sidecar::{
|
|
||||||
command::{ffmpeg_is_installed, FfmpegCommand},
|
|
||||||
download::auto_download,
|
|
||||||
event::{FfmpegEvent, LogLevel},
|
|
||||||
paths::sidecar_path,
|
|
||||||
};
|
|
||||||
use serde_json::Value;
|
|
||||||
use std::fs;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
/// Get the default output directory for recordings.
|
|
||||||
/// Uses the same directory structure as the record-daemon.
|
|
||||||
fn get_default_output_dir() -> Option<PathBuf> {
|
|
||||||
directories::ProjectDirs::from("com", "leaguerecorder", "record-daemon")
|
|
||||||
.map(|dirs| dirs.data_dir().join("recordings"))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the timeline storage directory.
|
|
||||||
/// Uses the same directory structure as the record-daemon.
|
|
||||||
fn get_timeline_dir() -> PathBuf {
|
|
||||||
get_default_output_dir()
|
|
||||||
.map(|p| p.join("timelines"))
|
|
||||||
.unwrap_or_else(|| PathBuf::from("./recordings/timelines"))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Load all timelines from disk as raw JSON values.
|
|
||||||
fn load_timelines() -> Vec<Value> {
|
|
||||||
let timeline_dir = get_timeline_dir();
|
|
||||||
let mut timelines = Vec::new();
|
|
||||||
|
|
||||||
if !timeline_dir.exists() {
|
|
||||||
return timelines;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Ok(entries) = fs::read_dir(&timeline_dir) {
|
|
||||||
for entry in entries.flatten() {
|
|
||||||
let path = entry.path();
|
|
||||||
if path.extension().map(|e| e == "json").unwrap_or(false) {
|
|
||||||
if let Ok(contents) = fs::read_to_string(&path) {
|
|
||||||
if let Ok(timeline) = serde_json::from_str::<Value>(&contents) {
|
|
||||||
timelines.push(timeline);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort by start time, newest first
|
|
||||||
timelines.sort_by(|a, b| {
|
|
||||||
let a_time = a.get("start_time").and_then(|v| v.as_str()).unwrap_or("");
|
|
||||||
let b_time = b.get("start_time").and_then(|v| v.as_str()).unwrap_or("");
|
|
||||||
b_time.cmp(a_time)
|
|
||||||
});
|
|
||||||
timelines
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get game history - returns full timeline data for each game as raw JSON.
|
|
||||||
#[tauri::command]
|
|
||||||
fn get_game_history() -> Vec<Value> {
|
|
||||||
load_timelines()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get a specific timeline by recording ID as raw JSON.
|
|
||||||
#[tauri::command]
|
|
||||||
fn get_timeline(recording_id: String) -> Option<Value> {
|
|
||||||
let timeline_dir = get_timeline_dir();
|
|
||||||
let path = timeline_dir.join(format!("{}.json", recording_id));
|
|
||||||
|
|
||||||
if path.exists() {
|
|
||||||
if let Ok(contents) = fs::read_to_string(&path) {
|
|
||||||
return serde_json::from_str::<Value>(&contents).ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the recordings directory path.
|
|
||||||
#[tauri::command]
|
|
||||||
fn get_recordings_dir() -> String {
|
|
||||||
get_default_output_dir()
|
|
||||||
.map(|p| p.to_string_lossy().to_string())
|
|
||||||
.unwrap_or_else(|| "./recordings".to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Find a video file in the recordings directory.
|
|
||||||
/// Searches for exact filename match or pattern match.
|
|
||||||
#[tauri::command]
|
|
||||||
fn find_video_file(recordings_dir: String, filename: String) -> Option<String> {
|
|
||||||
let recordings_path = PathBuf::from(&recordings_dir);
|
|
||||||
|
|
||||||
if !recordings_path.exists() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try exact match first
|
|
||||||
let exact_path = recordings_path.join(&filename);
|
|
||||||
if exact_path.exists() {
|
|
||||||
return Some(exact_path.to_string_lossy().to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to find by pattern (date_time_*.mp4)
|
|
||||||
if let Ok(entries) = fs::read_dir(&recordings_path) {
|
|
||||||
for entry in entries.flatten() {
|
|
||||||
let path = entry.path();
|
|
||||||
if path.extension().map(|e| e == "mp4" || e == "mkv" || e == "mov").unwrap_or(false) {
|
|
||||||
let file_name = path.file_name()?.to_string_lossy().to_string();
|
|
||||||
|
|
||||||
// Check if filename starts with the same date/time pattern
|
|
||||||
// filename format: "2026-03-27_16-42-52_unknown.mp4"
|
|
||||||
// We match the date_time prefix
|
|
||||||
if file_name.starts_with(&filename.replace("_unknown.mp4", "")) {
|
|
||||||
return Some(path.to_string_lossy().to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get list of video files in recordings directory.
|
|
||||||
#[tauri::command]
|
|
||||||
fn list_video_files(recordings_dir: String) -> Vec<String> {
|
|
||||||
let recordings_path = PathBuf::from(&recordings_dir);
|
|
||||||
let mut videos = Vec::new();
|
|
||||||
|
|
||||||
if !recordings_path.exists() {
|
|
||||||
return videos;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Ok(entries) = fs::read_dir(&recordings_path) {
|
|
||||||
for entry in entries.flatten() {
|
|
||||||
let path = entry.path();
|
|
||||||
if path.extension().map(|e| e == "mp4" || e == "mkv" || e == "mov").unwrap_or(false) {
|
|
||||||
videos.push(path.to_string_lossy().to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort by modification time, newest first
|
|
||||||
videos.sort_by(|a, b| {
|
|
||||||
let a_time = fs::metadata(a).and_then(|m| m.modified()).ok();
|
|
||||||
let b_time = fs::metadata(b).and_then(|m| m.modified()).ok();
|
|
||||||
b_time.cmp(&a_time)
|
|
||||||
});
|
|
||||||
|
|
||||||
videos
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ensure ffmpeg is available, downloading if necessary.
|
|
||||||
fn ensure_ffmpeg() -> Result<(), String> {
|
|
||||||
if ffmpeg_is_installed() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Auto-download ffmpeg for the current platform
|
|
||||||
auto_download().map_err(|e| format!("Failed to download ffmpeg: {}", e))?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Export a clip from a video using ffmpeg-sidecar (stream copy for speed).
|
|
||||||
#[tauri::command]
|
|
||||||
fn export_clip(
|
|
||||||
video_path: String,
|
|
||||||
start_time: f64,
|
|
||||||
end_time: f64,
|
|
||||||
output_name: String,
|
|
||||||
) -> Result<String, String> {
|
|
||||||
// Ensure ffmpeg is available
|
|
||||||
ensure_ffmpeg()?;
|
|
||||||
|
|
||||||
// Verify input file exists
|
|
||||||
if !PathBuf::from(&video_path).exists() {
|
|
||||||
return Err(format!("Video file not found: {}", video_path));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get output directory
|
|
||||||
let output_dir = get_default_output_dir()
|
|
||||||
.map(|p| p.join("clips"))
|
|
||||||
.unwrap_or_else(|| PathBuf::from("./clips"));
|
|
||||||
|
|
||||||
// Create clips directory if it doesn't exist
|
|
||||||
if !output_dir.exists() {
|
|
||||||
fs::create_dir_all(&output_dir)
|
|
||||||
.map_err(|e| format!("Failed to create clips directory: {}", e))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let output_path = output_dir.join(format!("{}.mp4", output_name));
|
|
||||||
let duration = end_time - start_time;
|
|
||||||
|
|
||||||
// Build ffmpeg command with stream copy (fast, no re-encoding)
|
|
||||||
// Note: Put -ss before -i for fast seeking (input seeking)
|
|
||||||
let iter = FfmpegCommand::new()
|
|
||||||
.arg("-y") // Overwrite output file
|
|
||||||
.arg("-ss").arg(&format!("{:.3}", start_time))
|
|
||||||
.arg("-i").arg(&video_path)
|
|
||||||
.arg("-t").arg(&format!("{:.3}", duration))
|
|
||||||
.arg("-c").arg("copy") // Stream copy for fast export
|
|
||||||
.arg("-avoid_negative_ts").arg("make_zero")
|
|
||||||
.arg(&output_path.to_string_lossy().to_string())
|
|
||||||
.spawn()
|
|
||||||
.map_err(|e| format!("Failed to spawn ffmpeg: {}", e))?
|
|
||||||
.iter()
|
|
||||||
.map_err(|e| format!("Failed to create ffmpeg iterator: {}", e))?;
|
|
||||||
|
|
||||||
// Process the ffmpeg command and collect all errors
|
|
||||||
let mut errors = Vec::new();
|
|
||||||
for event in iter {
|
|
||||||
match event {
|
|
||||||
FfmpegEvent::Error(e) => {
|
|
||||||
errors.push(format!("FFmpeg error: {}", e));
|
|
||||||
}
|
|
||||||
FfmpegEvent::Log(LogLevel::Error, msg) => {
|
|
||||||
errors.push(format!("FFmpeg log error: {}", msg));
|
|
||||||
}
|
|
||||||
FfmpegEvent::Log(LogLevel::Warning, msg) => {
|
|
||||||
// Log warnings but don't fail
|
|
||||||
eprintln!("FFmpeg warning: {}", msg);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if output file was created
|
|
||||||
if !output_path.exists() {
|
|
||||||
return Err(format!(
|
|
||||||
"Export failed - output file not created. Errors: {}",
|
|
||||||
errors.join("; ")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if output file has content
|
|
||||||
let metadata = fs::metadata(&output_path)
|
|
||||||
.map_err(|e| format!("Failed to check output file: {}", e))?;
|
|
||||||
if metadata.len() == 0 {
|
|
||||||
return Err(format!(
|
|
||||||
"Export failed - output file is empty. Errors: {}",
|
|
||||||
errors.join("; ")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(output_path.to_string_lossy().to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Export a clip with re-encoding for more precise cuts.
|
|
||||||
#[tauri::command]
|
|
||||||
fn export_clip_precise(
|
|
||||||
video_path: String,
|
|
||||||
start_time: f64,
|
|
||||||
end_time: f64,
|
|
||||||
output_name: String,
|
|
||||||
quality: String,
|
|
||||||
) -> Result<String, String> {
|
|
||||||
// Ensure ffmpeg is available
|
|
||||||
ensure_ffmpeg()?;
|
|
||||||
|
|
||||||
// Verify input file exists
|
|
||||||
if !PathBuf::from(&video_path).exists() {
|
|
||||||
return Err(format!("Video file not found: {}", video_path));
|
|
||||||
}
|
|
||||||
|
|
||||||
let output_dir = get_default_output_dir()
|
|
||||||
.map(|p| p.join("clips"))
|
|
||||||
.unwrap_or_else(|| PathBuf::from("./clips"));
|
|
||||||
|
|
||||||
if !output_dir.exists() {
|
|
||||||
fs::create_dir_all(&output_dir)
|
|
||||||
.map_err(|e| format!("Failed to create clips directory: {}", e))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let output_path = output_dir.join(format!("{}.mp4", output_name));
|
|
||||||
let duration = end_time - start_time;
|
|
||||||
|
|
||||||
// Quality presets (CRF values - lower is better quality)
|
|
||||||
let crf = match quality.as_str() {
|
|
||||||
"low" => "28",
|
|
||||||
"medium" => "23",
|
|
||||||
"high" => "18",
|
|
||||||
_ => "23",
|
|
||||||
};
|
|
||||||
|
|
||||||
// Build ffmpeg command with re-encoding
|
|
||||||
let iter = FfmpegCommand::new()
|
|
||||||
.arg("-y") // Overwrite output file
|
|
||||||
.arg("-ss").arg(&format!("{:.3}", start_time))
|
|
||||||
.arg("-i").arg(&video_path)
|
|
||||||
.arg("-t").arg(&format!("{:.3}", duration))
|
|
||||||
.arg("-c:v").arg("libx264")
|
|
||||||
.arg("-crf").arg(crf)
|
|
||||||
.arg("-preset").arg("fast")
|
|
||||||
.arg("-c:a").arg("aac")
|
|
||||||
.arg("-b:a").arg("128k")
|
|
||||||
.arg(&output_path.to_string_lossy().to_string())
|
|
||||||
.spawn()
|
|
||||||
.map_err(|e| format!("Failed to spawn ffmpeg: {}", e))?
|
|
||||||
.iter()
|
|
||||||
.map_err(|e| format!("Failed to create ffmpeg iterator: {}", e))?;
|
|
||||||
|
|
||||||
// Process the ffmpeg command and collect all errors
|
|
||||||
let mut errors = Vec::new();
|
|
||||||
for event in iter {
|
|
||||||
match event {
|
|
||||||
FfmpegEvent::Error(e) => {
|
|
||||||
errors.push(format!("FFmpeg error: {}", e));
|
|
||||||
}
|
|
||||||
FfmpegEvent::Log(LogLevel::Error, msg) => {
|
|
||||||
errors.push(format!("FFmpeg log error: {}", msg));
|
|
||||||
}
|
|
||||||
FfmpegEvent::Log(LogLevel::Warning, msg) => {
|
|
||||||
eprintln!("FFmpeg warning: {}", msg);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if output file was created
|
|
||||||
if !output_path.exists() {
|
|
||||||
return Err(format!(
|
|
||||||
"Export failed - output file not created. Errors: {}",
|
|
||||||
errors.join("; ")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if output file has content
|
|
||||||
let metadata = fs::metadata(&output_path)
|
|
||||||
.map_err(|e| format!("Failed to check output file: {}", e))?;
|
|
||||||
if metadata.len() == 0 {
|
|
||||||
return Err(format!(
|
|
||||||
"Export failed - output file is empty. Errors: {}",
|
|
||||||
errors.join("; ")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(output_path.to_string_lossy().to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if ffmpeg is available.
|
|
||||||
#[tauri::command]
|
|
||||||
fn check_ffmpeg() -> bool {
|
|
||||||
ffmpeg_is_installed()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Download ffmpeg if not already installed.
|
|
||||||
#[tauri::command]
|
|
||||||
fn download_ffmpeg() -> Result<String, String> {
|
|
||||||
ensure_ffmpeg()?;
|
|
||||||
Ok(sidecar_path().unwrap_or_default().to_string_lossy().to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get video file metadata using ffprobe.
|
|
||||||
#[tauri::command]
|
|
||||||
fn get_video_metadata(video_path: String) -> Result<Value, String> {
|
|
||||||
// Ensure ffmpeg is available
|
|
||||||
ensure_ffmpeg()?;
|
|
||||||
|
|
||||||
// Use ffprobe via ffmpeg-sidecar
|
|
||||||
let iter = FfmpegCommand::new()
|
|
||||||
.arg("-v").arg("quiet")
|
|
||||||
.arg("-print_format").arg("json")
|
|
||||||
.arg("-show_format")
|
|
||||||
.arg("-show_streams")
|
|
||||||
.arg(&video_path)
|
|
||||||
.spawn()
|
|
||||||
.map_err(|e| format!("Failed to spawn ffprobe: {}", e))?
|
|
||||||
.iter()
|
|
||||||
.map_err(|e| format!("Failed to create ffprobe iterator: {}", e))?;
|
|
||||||
|
|
||||||
let mut json_output = String::new();
|
|
||||||
|
|
||||||
for event in iter {
|
|
||||||
match event {
|
|
||||||
FfmpegEvent::Log(LogLevel::Info, msg) | FfmpegEvent::Log(LogLevel::Unknown, msg) => {
|
|
||||||
// Capture JSON output
|
|
||||||
if msg.trim().starts_with('{') || msg.trim().starts_with('[') {
|
|
||||||
json_output.push_str(&msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FfmpegEvent::Error(e) => {
|
|
||||||
return Err(format!("FFprobe error: {}", e));
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the JSON output
|
|
||||||
serde_json::from_str(&json_output)
|
|
||||||
.map_err(|e| format!("Failed to parse ffprobe output: {}", e))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
||||||
pub fn run() {
|
|
||||||
tauri::Builder::default()
|
|
||||||
.plugin(tauri_plugin_opener::init())
|
|
||||||
.plugin(tauri_plugin_autostart::init(
|
|
||||||
tauri_plugin_autostart::MacosLauncher::LaunchAgent,
|
|
||||||
Some(vec!["--hidden"]),
|
|
||||||
))
|
|
||||||
.setup(|app| {
|
|
||||||
// Auto-start the record-daemon on app launch.
|
|
||||||
// We spawn a background task so the UI isn't blocked while the
|
|
||||||
// daemon boots (it can take a few seconds to initialise OBS).
|
|
||||||
let handle = app.handle().clone();
|
|
||||||
tauri::async_runtime::spawn(async move {
|
|
||||||
match daemon_ipc::ensure_daemon_running(30).await {
|
|
||||||
Ok(true) => {
|
|
||||||
eprintln!("[tauri] record-daemon is running");
|
|
||||||
}
|
|
||||||
Ok(false) => {
|
|
||||||
eprintln!("[tauri] record-daemon did not become ready within the timeout");
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
eprintln!("[tauri] failed to start record-daemon: {}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Drop the handle – no further use
|
|
||||||
drop(handle);
|
|
||||||
});
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
.invoke_handler(tauri::generate_handler![
|
|
||||||
get_game_history,
|
|
||||||
get_timeline,
|
|
||||||
get_recordings_dir,
|
|
||||||
find_video_file,
|
|
||||||
list_video_files,
|
|
||||||
export_clip,
|
|
||||||
export_clip_precise,
|
|
||||||
check_ffmpeg,
|
|
||||||
download_ffmpeg,
|
|
||||||
get_video_metadata,
|
|
||||||
// Daemon IPC commands
|
|
||||||
daemon_ipc::daemon_is_running,
|
|
||||||
daemon_ipc::daemon_ensure_running,
|
|
||||||
daemon_ipc::daemon_get_status,
|
|
||||||
daemon_ipc::daemon_get_settings,
|
|
||||||
daemon_ipc::daemon_update_settings,
|
|
||||||
daemon_ipc::daemon_reset_settings,
|
|
||||||
daemon_ipc::daemon_get_encoders,
|
|
||||||
daemon_ipc::daemon_get_audio_devices,
|
|
||||||
daemon_ipc::daemon_add_audio_source,
|
|
||||||
daemon_ipc::daemon_remove_audio_source,
|
|
||||||
daemon_ipc::daemon_update_audio_source,
|
|
||||||
daemon_ipc::daemon_start_recording,
|
|
||||||
daemon_ipc::daemon_stop_recording,
|
|
||||||
daemon_ipc::daemon_shutdown,
|
|
||||||
daemon_ipc::daemon_get_log_path,
|
|
||||||
daemon_ipc::daemon_read_logs,
|
|
||||||
])
|
|
||||||
.run(tauri::generate_context!())
|
|
||||||
.expect("error while running tauri application");
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
tauri_app_lib::run()
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
|
||||||
"productName": "leaguerecorder",
|
|
||||||
"version": "0.3.0",
|
|
||||||
"identifier": "v.leaguerecorder",
|
|
||||||
"build": {
|
|
||||||
"beforeDevCommand": "npm run dev",
|
|
||||||
"devUrl": "http://localhost:1420",
|
|
||||||
"beforeBuildCommand": "npm run build",
|
|
||||||
"frontendDist": "../dist"
|
|
||||||
},
|
|
||||||
"app": {
|
|
||||||
"windows": [
|
|
||||||
{
|
|
||||||
"title": "League Recorder",
|
|
||||||
"width": 1280,
|
|
||||||
"height": 800,
|
|
||||||
"minWidth": 800,
|
|
||||||
"minHeight": 600
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"security": {
|
|
||||||
"csp": null,
|
|
||||||
"assetProtocol": {
|
|
||||||
"enable": true,
|
|
||||||
"scope": [
|
|
||||||
"$APPDATA/**",
|
|
||||||
"$APPDATA/../**",
|
|
||||||
"C:/Users/**/AppData/Roaming/**"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"bundle": {
|
|
||||||
"active": true,
|
|
||||||
"targets": "all",
|
|
||||||
"icon": [
|
|
||||||
"icons/32x32.png",
|
|
||||||
"icons/128x128.png",
|
|
||||||
"icons/128x128@2x.png",
|
|
||||||
"icons/icon.icns",
|
|
||||||
"icons/icon.ico"
|
|
||||||
],
|
|
||||||
"resources": {
|
|
||||||
"binaries/obs.dll": "obs.dll"
|
|
||||||
},
|
|
||||||
"externalBin": ["binaries/record-daemon"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { ref, onMounted } from "vue";
|
|
||||||
import GameHistory from "./components/GameHistory.vue";
|
|
||||||
import GameReview from "./components/GameReview.vue";
|
|
||||||
import Settings from "./components/Settings.vue";
|
|
||||||
import type { GameHistoryItem } from "./types/timeline";
|
|
||||||
import { fetchLatestDdragonVersion } from "./types/ddragon";
|
|
||||||
|
|
||||||
// Current view state
|
|
||||||
const currentView = ref<"history" | "review" | "settings">("history");
|
|
||||||
const selectedGame = ref<GameHistoryItem | null>(null);
|
|
||||||
|
|
||||||
// Navigate to review view
|
|
||||||
function openReview(game: GameHistoryItem) {
|
|
||||||
selectedGame.value = game;
|
|
||||||
currentView.value = "review";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Navigate back to history
|
|
||||||
function closeReview() {
|
|
||||||
currentView.value = "history";
|
|
||||||
selectedGame.value = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Navigate to settings
|
|
||||||
function openSettings() {
|
|
||||||
currentView.value = "settings";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Navigate back from settings
|
|
||||||
function closeSettings() {
|
|
||||||
currentView.value = "history";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize DDragon version on app mount
|
|
||||||
onMounted(() => {
|
|
||||||
fetchLatestDdragonVersion();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="app">
|
|
||||||
<!-- Navigation bar -->
|
|
||||||
<nav v-if="currentView !== 'review'" class="app-nav">
|
|
||||||
<div class="nav-left">
|
|
||||||
<button
|
|
||||||
:class="['nav-tab', { active: currentView === 'history' }]"
|
|
||||||
@click="currentView = 'history'"
|
|
||||||
>
|
|
||||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
||||||
<rect x="3" y="3" width="7" height="7" rx="1" />
|
|
||||||
<rect x="14" y="3" width="7" height="7" rx="1" />
|
|
||||||
<rect x="3" y="14" width="7" height="7" rx="1" />
|
|
||||||
<rect x="14" y="14" width="7" height="7" rx="1" />
|
|
||||||
</svg>
|
|
||||||
Game History
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
:class="['nav-tab', { active: currentView === 'settings' }]"
|
|
||||||
@click="openSettings"
|
|
||||||
>
|
|
||||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
||||||
<circle cx="12" cy="12" r="3" />
|
|
||||||
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" />
|
|
||||||
</svg>
|
|
||||||
Settings
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<GameHistory
|
|
||||||
v-if="currentView === 'history'"
|
|
||||||
@open-review="openReview"
|
|
||||||
/>
|
|
||||||
<GameReview
|
|
||||||
v-else-if="currentView === 'review' && selectedGame"
|
|
||||||
:game="selectedGame"
|
|
||||||
@back="closeReview"
|
|
||||||
/>
|
|
||||||
<Settings
|
|
||||||
v-else-if="currentView === 'settings'"
|
|
||||||
@back="closeSettings"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
/* Global styles */
|
|
||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
||||||
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar {
|
|
||||||
width: 8px;
|
|
||||||
height: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-track {
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb {
|
|
||||||
background: rgba(255, 255, 255, 0.2);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb:hover {
|
|
||||||
background: rgba(255, 255, 255, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.app {
|
|
||||||
min-height: 100vh;
|
|
||||||
background: #0a0a13;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Navigation bar */
|
|
||||||
.app-nav {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 0 24px;
|
|
||||||
height: 48px;
|
|
||||||
background: rgba(255, 255, 255, 0.03);
|
|
||||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-left {
|
|
||||||
display: flex;
|
|
||||||
gap: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-tab {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 6px;
|
|
||||||
padding: 8px 14px;
|
|
||||||
background: none;
|
|
||||||
border: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
color: #94a3b8;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 500;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.15s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-tab:hover {
|
|
||||||
color: #e2e8f0;
|
|
||||||
background: rgba(255, 255, 255, 0.06);
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-tab.active {
|
|
||||||
color: #f1f5f9;
|
|
||||||
background: rgba(255, 255, 255, 0.08);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 496 B |
@@ -1,721 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { ref, computed, watch } from "vue";
|
|
||||||
import type {
|
|
||||||
HighlightClip,
|
|
||||||
HighlightSettings,
|
|
||||||
HighlightType,
|
|
||||||
} from "../types/timeline";
|
|
||||||
import {
|
|
||||||
DEFAULT_HIGHLIGHT_SETTINGS,
|
|
||||||
getHighlightTypeColor,
|
|
||||||
getHighlightTypeIcon,
|
|
||||||
formatDuration,
|
|
||||||
} from "../types/timeline";
|
|
||||||
|
|
||||||
// Props
|
|
||||||
const props = defineProps<{
|
|
||||||
highlights: HighlightClip[];
|
|
||||||
currentVideoTime: number;
|
|
||||||
videoDuration: number;
|
|
||||||
isPlaying: boolean;
|
|
||||||
isExporting: boolean;
|
|
||||||
exportingClipId: number | null;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
// Emits
|
|
||||||
const emit = defineEmits<{
|
|
||||||
(e: "seek-to", time: number): void;
|
|
||||||
(e: "play-clip", clip: HighlightClip): void;
|
|
||||||
(e: "play-all"): void;
|
|
||||||
(e: "export-clip", clip: HighlightClip): void;
|
|
||||||
(e: "export-all"): void;
|
|
||||||
(e: "settings-changed", settings: HighlightSettings): void;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
// Settings panel state
|
|
||||||
const showSettings = ref(false);
|
|
||||||
const settings = ref<HighlightSettings>({ ...DEFAULT_HIGHLIGHT_SETTINGS });
|
|
||||||
|
|
||||||
// Type filter toggles
|
|
||||||
const typeToggles = ref<Record<HighlightType, boolean>>({
|
|
||||||
kill: DEFAULT_HIGHLIGHT_SETTINGS.included_types.includes("kill"),
|
|
||||||
death: DEFAULT_HIGHLIGHT_SETTINGS.included_types.includes("death"),
|
|
||||||
assist: DEFAULT_HIGHLIGHT_SETTINGS.included_types.includes("assist"),
|
|
||||||
multi_kill: DEFAULT_HIGHLIGHT_SETTINGS.included_types.includes("multi_kill"),
|
|
||||||
trade_kill: DEFAULT_HIGHLIGHT_SETTINGS.included_types.includes("trade_kill"),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Watch type toggles and update settings
|
|
||||||
watch(
|
|
||||||
typeToggles,
|
|
||||||
(toggles) => {
|
|
||||||
const included_types = (Object.entries(toggles) as [HighlightType, boolean][])
|
|
||||||
.filter(([, enabled]) => enabled)
|
|
||||||
.map(([type]) => type);
|
|
||||||
settings.value = { ...settings.value, included_types };
|
|
||||||
emit("settings-changed", settings.value);
|
|
||||||
},
|
|
||||||
{ deep: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
// Watch buffer settings and emit
|
|
||||||
watch(
|
|
||||||
() => [settings.value.buffer_before, settings.value.buffer_after, settings.value.merge_overlapping, settings.value.merge_gap_secs],
|
|
||||||
() => {
|
|
||||||
emit("settings-changed", settings.value);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Currently active clip (the one whose time range contains the current video time)
|
|
||||||
const activeClipId = computed(() => {
|
|
||||||
for (const clip of props.highlights) {
|
|
||||||
if (
|
|
||||||
props.currentVideoTime >= clip.start_time &&
|
|
||||||
props.currentVideoTime <= clip.end_time
|
|
||||||
) {
|
|
||||||
return clip.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Stats
|
|
||||||
const killCount = computed(() => props.highlights.filter(h => h.highlight_type === "kill").length);
|
|
||||||
const deathCount = computed(() => props.highlights.filter(h => h.highlight_type === "death").length);
|
|
||||||
const multiKillCount = computed(() => props.highlights.filter(h => h.highlight_type === "multi_kill").length);
|
|
||||||
const tradeKillCount = computed(() => props.highlights.filter(h => h.highlight_type === "trade_kill").length);
|
|
||||||
const assistCount = computed(() => props.highlights.filter(h => h.highlight_type === "assist").length);
|
|
||||||
const totalDuration = computed(() => {
|
|
||||||
const total = props.highlights.reduce((sum, h) => sum + (h.end_time - h.start_time), 0);
|
|
||||||
return total;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Seek to the start of a clip
|
|
||||||
function seekToClip(clip: HighlightClip) {
|
|
||||||
emit("seek-to", clip.start_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Play a specific clip
|
|
||||||
function playClip(clip: HighlightClip) {
|
|
||||||
emit("play-clip", clip);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Export a single clip
|
|
||||||
function exportClip(clip: HighlightClip) {
|
|
||||||
emit("export-clip", clip);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format clip time range
|
|
||||||
function formatClipTime(clip: HighlightClip): string {
|
|
||||||
return `${formatDuration(clip.start_time)} - ${formatDuration(clip.end_time)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format clip duration
|
|
||||||
function formatClipDuration(clip: HighlightClip): string {
|
|
||||||
return formatDuration(clip.end_time - clip.start_time);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="highlights-panel">
|
|
||||||
<!-- Header -->
|
|
||||||
<div class="highlights-header">
|
|
||||||
<h3>
|
|
||||||
<span class="header-icon">🎬</span>
|
|
||||||
Highlights
|
|
||||||
</h3>
|
|
||||||
<button
|
|
||||||
class="settings-toggle"
|
|
||||||
:class="{ active: showSettings }"
|
|
||||||
@click="showSettings = !showSettings"
|
|
||||||
title="Highlight settings"
|
|
||||||
>
|
|
||||||
⚙️
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Settings Panel (collapsible) -->
|
|
||||||
<div v-if="showSettings" class="settings-panel">
|
|
||||||
<div class="settings-group">
|
|
||||||
<label class="settings-label">Buffer Before</label>
|
|
||||||
<div class="slider-row">
|
|
||||||
<input
|
|
||||||
type="range"
|
|
||||||
min="2"
|
|
||||||
max="30"
|
|
||||||
step="1"
|
|
||||||
v-model.number="settings.buffer_before"
|
|
||||||
class="settings-slider"
|
|
||||||
/>
|
|
||||||
<span class="slider-value">{{ settings.buffer_before }}s</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="settings-group">
|
|
||||||
<label class="settings-label">Buffer After</label>
|
|
||||||
<div class="slider-row">
|
|
||||||
<input
|
|
||||||
type="range"
|
|
||||||
min="2"
|
|
||||||
max="30"
|
|
||||||
step="1"
|
|
||||||
v-model.number="settings.buffer_after"
|
|
||||||
class="settings-slider"
|
|
||||||
/>
|
|
||||||
<span class="slider-value">{{ settings.buffer_after }}s</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="settings-group">
|
|
||||||
<label class="settings-label">Include Types</label>
|
|
||||||
<div class="type-toggles">
|
|
||||||
<label
|
|
||||||
v-for="typeInfo in [
|
|
||||||
{ type: 'kill' as HighlightType, label: 'Kills', icon: '⚔️' },
|
|
||||||
{ type: 'death' as HighlightType, label: 'Deaths', icon: '💀' },
|
|
||||||
{ type: 'assist' as HighlightType, label: 'Assists', icon: '🤝' },
|
|
||||||
{ type: 'multi_kill' as HighlightType, label: 'Multi Kills', icon: '🔥' },
|
|
||||||
{ type: 'trade_kill' as HighlightType, label: 'Trade Kills', icon: '🔄' },
|
|
||||||
]"
|
|
||||||
:key="typeInfo.type"
|
|
||||||
class="type-toggle"
|
|
||||||
:style="{ borderColor: typeToggles[typeInfo.type] ? getHighlightTypeColor(typeInfo.type) : 'rgba(255,255,255,0.1)' }"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
v-model="typeToggles[typeInfo.type]"
|
|
||||||
class="toggle-checkbox"
|
|
||||||
/>
|
|
||||||
<span class="toggle-icon">{{ typeInfo.icon }}</span>
|
|
||||||
<span class="toggle-label">{{ typeInfo.label }}</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="settings-group">
|
|
||||||
<label class="settings-row-label">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
v-model="settings.merge_overlapping"
|
|
||||||
class="toggle-checkbox"
|
|
||||||
/>
|
|
||||||
Merge overlapping clips
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="settings.merge_overlapping" class="settings-group">
|
|
||||||
<label class="settings-label">Merge Gap</label>
|
|
||||||
<div class="slider-row">
|
|
||||||
<input
|
|
||||||
type="range"
|
|
||||||
min="0"
|
|
||||||
max="20"
|
|
||||||
step="1"
|
|
||||||
v-model.number="settings.merge_gap_secs"
|
|
||||||
class="settings-slider"
|
|
||||||
/>
|
|
||||||
<span class="slider-value">{{ settings.merge_gap_secs }}s</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Quick Stats -->
|
|
||||||
<div class="highlights-stats">
|
|
||||||
<div class="stat-pill" v-if="killCount > 0">
|
|
||||||
<span>⚔️</span> {{ killCount }}
|
|
||||||
</div>
|
|
||||||
<div class="stat-pill" v-if="deathCount > 0">
|
|
||||||
<span>💀</span> {{ deathCount }}
|
|
||||||
</div>
|
|
||||||
<div class="stat-pill" v-if="assistCount > 0">
|
|
||||||
<span>🤝</span> {{ assistCount }}
|
|
||||||
</div>
|
|
||||||
<div class="stat-pill" v-if="multiKillCount > 0">
|
|
||||||
<span>🔥</span> {{ multiKillCount }}
|
|
||||||
</div>
|
|
||||||
<div class="stat-pill" v-if="tradeKillCount > 0">
|
|
||||||
<span>🔄</span> {{ tradeKillCount }}
|
|
||||||
</div>
|
|
||||||
<div class="stat-pill total">
|
|
||||||
<span>⏱️</span> {{ formatDuration(totalDuration) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Action Buttons -->
|
|
||||||
<div class="highlights-actions">
|
|
||||||
<button
|
|
||||||
class="action-btn play-all"
|
|
||||||
@click="emit('play-all')"
|
|
||||||
:disabled="highlights.length === 0"
|
|
||||||
>
|
|
||||||
▶ Play All
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="action-btn export-all"
|
|
||||||
@click="emit('export-all')"
|
|
||||||
:disabled="highlights.length === 0 || isExporting"
|
|
||||||
>
|
|
||||||
{{ isExporting ? "Exporting..." : "📦 Export All" }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Empty State -->
|
|
||||||
<div v-if="highlights.length === 0" class="empty-highlights">
|
|
||||||
<div class="empty-icon">🎬</div>
|
|
||||||
<p>No highlights detected</p>
|
|
||||||
<p class="empty-hint">Highlights are generated from kills, deaths, and multi-kills during the game.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Highlights List -->
|
|
||||||
<div v-else class="highlights-list">
|
|
||||||
<div
|
|
||||||
v-for="clip in highlights"
|
|
||||||
:key="clip.id"
|
|
||||||
class="highlight-card"
|
|
||||||
:class="{
|
|
||||||
active: activeClipId === clip.id,
|
|
||||||
[clip.highlight_type]: true,
|
|
||||||
}"
|
|
||||||
@click="seekToClip(clip)"
|
|
||||||
>
|
|
||||||
<div class="highlight-indicator" :style="{ backgroundColor: getHighlightTypeColor(clip.highlight_type) }"></div>
|
|
||||||
|
|
||||||
<div class="highlight-content">
|
|
||||||
<div class="highlight-title-row">
|
|
||||||
<span class="highlight-icon">{{ getHighlightTypeIcon(clip.highlight_type) }}</span>
|
|
||||||
<span class="highlight-title">{{ clip.title }}</span>
|
|
||||||
<span class="highlight-duration">{{ formatClipDuration(clip) }}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="clip.subtitle" class="highlight-subtitle">
|
|
||||||
{{ clip.subtitle }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="highlight-time-row">
|
|
||||||
<span class="highlight-time">{{ formatClipTime(clip) }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="highlight-actions">
|
|
||||||
<button
|
|
||||||
class="mini-btn play"
|
|
||||||
@click.stop="playClip(clip)"
|
|
||||||
title="Play this clip"
|
|
||||||
>
|
|
||||||
▶
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="mini-btn export"
|
|
||||||
@click.stop="exportClip(clip)"
|
|
||||||
:disabled="isExporting && exportingClipId === clip.id"
|
|
||||||
title="Export this clip"
|
|
||||||
>
|
|
||||||
💾
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.highlights-panel {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.75rem;
|
|
||||||
height: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Header */
|
|
||||||
.highlights-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlights-header h3 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 1rem;
|
|
||||||
color: #c8aa6e;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-icon {
|
|
||||||
font-size: 1.1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-toggle {
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
border-radius: 6px;
|
|
||||||
padding: 0.3rem 0.5rem;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
transition: all 0.2s;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-toggle:hover {
|
|
||||||
background: rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-toggle.active {
|
|
||||||
background: rgba(200, 170, 110, 0.15);
|
|
||||||
border-color: #c8aa6e;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Settings Panel */
|
|
||||||
.settings-panel {
|
|
||||||
background: rgba(0, 0, 0, 0.2);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 0.75rem;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-group {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.35rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-label {
|
|
||||||
font-size: 0.75rem;
|
|
||||||
color: #888;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.05em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-row-label {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
color: #ccc;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slider-row {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-slider {
|
|
||||||
flex: 1;
|
|
||||||
height: 4px;
|
|
||||||
-webkit-appearance: none;
|
|
||||||
background: rgba(255, 255, 255, 0.15);
|
|
||||||
border-radius: 2px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-slider::-webkit-slider-thumb {
|
|
||||||
-webkit-appearance: none;
|
|
||||||
width: 14px;
|
|
||||||
height: 14px;
|
|
||||||
background: #c8aa6e;
|
|
||||||
border-radius: 50%;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slider-value {
|
|
||||||
font-family: monospace;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
color: #c8aa6e;
|
|
||||||
min-width: 2.5rem;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.type-toggles {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 0.4rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.type-toggle {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.3rem;
|
|
||||||
padding: 0.3rem 0.6rem;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.type-toggle:hover {
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle-checkbox {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle-icon {
|
|
||||||
font-size: 0.85rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle-label {
|
|
||||||
color: #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Quick Stats */
|
|
||||||
.highlights-stats {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 0.4rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-pill {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.25rem;
|
|
||||||
padding: 0.25rem 0.6rem;
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border-radius: 12px;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
color: #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-pill.total {
|
|
||||||
color: #c8aa6e;
|
|
||||||
background: rgba(200, 170, 110, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Action Buttons */
|
|
||||||
.highlights-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-btn {
|
|
||||||
flex: 1;
|
|
||||||
padding: 0.5rem 0.75rem;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
font-weight: 500;
|
|
||||||
transition: all 0.2s;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-btn:disabled {
|
|
||||||
opacity: 0.4;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-btn.play-all {
|
|
||||||
background: rgba(74, 222, 128, 0.15);
|
|
||||||
border-color: rgba(74, 222, 128, 0.3);
|
|
||||||
color: #4ade80;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-btn.play-all:hover:not(:disabled) {
|
|
||||||
background: rgba(74, 222, 128, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-btn.export-all {
|
|
||||||
background: rgba(200, 170, 110, 0.15);
|
|
||||||
border-color: rgba(200, 170, 110, 0.3);
|
|
||||||
color: #c8aa6e;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-btn.export-all:hover:not(:disabled) {
|
|
||||||
background: rgba(200, 170, 110, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Empty State */
|
|
||||||
.empty-highlights {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 2rem 1rem;
|
|
||||||
color: #666;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-icon {
|
|
||||||
font-size: 2.5rem;
|
|
||||||
margin-bottom: 0.75rem;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-highlights p {
|
|
||||||
margin: 0.25rem 0;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-hint {
|
|
||||||
font-size: 0.75rem !important;
|
|
||||||
color: #555;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Highlights List */
|
|
||||||
.highlights-list {
|
|
||||||
flex: 1;
|
|
||||||
min-height: 0;
|
|
||||||
overflow-y: auto;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.4rem;
|
|
||||||
padding-right: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-card {
|
|
||||||
display: flex;
|
|
||||||
align-items: stretch;
|
|
||||||
gap: 0;
|
|
||||||
min-height: 56px;
|
|
||||||
background: rgba(255, 255, 255, 0.03);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
||||||
border-radius: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s;
|
|
||||||
overflow: hidden;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-card:hover {
|
|
||||||
background: rgba(255, 255, 255, 0.06);
|
|
||||||
border-color: rgba(255, 255, 255, 0.15);
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-card.active {
|
|
||||||
background: rgba(255, 255, 255, 0.08);
|
|
||||||
border-color: rgba(255, 255, 255, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-card.active.kill {
|
|
||||||
border-color: rgba(74, 222, 128, 0.4);
|
|
||||||
background: rgba(74, 222, 128, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-card.active.death {
|
|
||||||
border-color: rgba(248, 113, 113, 0.4);
|
|
||||||
background: rgba(248, 113, 113, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-card.active.assist {
|
|
||||||
border-color: rgba(167, 139, 250, 0.4);
|
|
||||||
background: rgba(167, 139, 250, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-card.active.multi_kill {
|
|
||||||
border-color: rgba(249, 115, 22, 0.4);
|
|
||||||
background: rgba(249, 115, 22, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-indicator {
|
|
||||||
width: 4px;
|
|
||||||
min-height: 100%;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-content {
|
|
||||||
flex: 1;
|
|
||||||
padding: 0.5rem 0.65rem;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-title-row {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.35rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-icon {
|
|
||||||
font-size: 0.85rem;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-title {
|
|
||||||
font-size: 0.85rem;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #fff;
|
|
||||||
flex: 1;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-duration {
|
|
||||||
font-family: monospace;
|
|
||||||
font-size: 0.7rem;
|
|
||||||
color: #888;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-subtitle {
|
|
||||||
font-size: 0.72rem;
|
|
||||||
color: #999;
|
|
||||||
margin-top: 0.15rem;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-time-row {
|
|
||||||
margin-top: 0.2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-time {
|
|
||||||
font-family: monospace;
|
|
||||||
font-size: 0.65rem;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-actions {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 0.25rem;
|
|
||||||
padding: 0.35rem 0.5rem;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-card:hover .highlight-actions,
|
|
||||||
.highlight-card.active .highlight-actions {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mini-btn {
|
|
||||||
background: rgba(255, 255, 255, 0.08);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
|
||||||
border-radius: 4px;
|
|
||||||
padding: 0.2rem 0.4rem;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 0.7rem;
|
|
||||||
transition: all 0.15s;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mini-btn:hover {
|
|
||||||
background: rgba(255, 255, 255, 0.15);
|
|
||||||
}
|
|
||||||
|
|
||||||
.mini-btn.play:hover {
|
|
||||||
background: rgba(74, 222, 128, 0.2);
|
|
||||||
border-color: rgba(74, 222, 128, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.mini-btn.export:hover {
|
|
||||||
background: rgba(200, 170, 110, 0.2);
|
|
||||||
border-color: rgba(200, 170, 110, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.mini-btn:disabled {
|
|
||||||
opacity: 0.4;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
import { createApp } from "vue";
|
|
||||||
import App from "./App.vue";
|
|
||||||
|
|
||||||
createApp(App).mount("#app");
|
|
||||||
@@ -1,178 +0,0 @@
|
|||||||
/**
|
|
||||||
* TypeScript types for daemon settings and status.
|
|
||||||
* Mirrors the Rust types from record-daemon/src/config/ and record-daemon/src/ipc/protocol.rs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Encoder presets
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export interface NvencPreset {
|
|
||||||
type: "nvenc";
|
|
||||||
bitrate: number;
|
|
||||||
cq_level: number;
|
|
||||||
two_pass: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AmfPreset {
|
|
||||||
type: "amf";
|
|
||||||
bitrate: number;
|
|
||||||
quality: "speed" | "balanced" | "quality";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface X264Preset {
|
|
||||||
type: "x264";
|
|
||||||
preset: string;
|
|
||||||
bitrate: number;
|
|
||||||
crf: number | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type EncoderPreset = NvencPreset | AmfPreset | X264Preset;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Quality level
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export type QualityLevel = "low" | "medium" | "high" | "ultra";
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Settings structures
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export interface VideoSettings {
|
|
||||||
encoder_preset: EncoderPreset;
|
|
||||||
quality: QualityLevel;
|
|
||||||
frame_rate: number;
|
|
||||||
hardware_acceleration: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OutputSettings {
|
|
||||||
path: string;
|
|
||||||
naming_pattern: string;
|
|
||||||
container: string;
|
|
||||||
split_size_mb: number;
|
|
||||||
split_time_minutes: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AudioSettings {
|
|
||||||
enabled: boolean;
|
|
||||||
bitrate: number;
|
|
||||||
sample_rate: number;
|
|
||||||
channels: number;
|
|
||||||
capture_game: boolean;
|
|
||||||
game_volume: number;
|
|
||||||
capture_mic: boolean;
|
|
||||||
mic_device: string | null;
|
|
||||||
mic_volume: number;
|
|
||||||
capture_apps: AudioSourceConfig[];
|
|
||||||
apps_volume: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AudioSourceConfig {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
type: AudioSourceType;
|
|
||||||
device: string;
|
|
||||||
enabled: boolean;
|
|
||||||
volume: number | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type AudioSourceType = "application" | "deviceOutput" | "deviceInput";
|
|
||||||
|
|
||||||
export interface AudioDeviceInfo {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
is_default: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GetAudioDevicesResponse {
|
|
||||||
input_devices: AudioDeviceInfo[];
|
|
||||||
output_devices: AudioDeviceInfo[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AudioSourceResponse {
|
|
||||||
source: AudioSourceConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DaemonSettings {
|
|
||||||
auto_record: boolean;
|
|
||||||
monitor_client: boolean;
|
|
||||||
poll_interval_ms: number;
|
|
||||||
socket_path: string | null;
|
|
||||||
log_level: string;
|
|
||||||
save_timeline: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Settings {
|
|
||||||
video: VideoSettings;
|
|
||||||
output: OutputSettings;
|
|
||||||
audio: AudioSettings;
|
|
||||||
daemon: DaemonSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Response wrapper from daemon_get_settings (daemon wraps in { settings: {...} }). */
|
|
||||||
export interface GetSettingsResponse {
|
|
||||||
settings: Settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Daemon status
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export type DaemonStatus = "idle" | "monitoring" | "recording" | "error" | "shutting_down";
|
|
||||||
|
|
||||||
export interface DaemonStatusResponse {
|
|
||||||
status: DaemonStatus;
|
|
||||||
is_recording: boolean;
|
|
||||||
current_game_id: number | null;
|
|
||||||
client_connected: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Encoder info
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export interface EncoderInfo {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
is_hardware: boolean;
|
|
||||||
available: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface EncodersResponse {
|
|
||||||
available: EncoderInfo[];
|
|
||||||
current: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Quality level metadata
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export const QUALITY_LEVELS: { value: QualityLevel; label: string; description: string }[] = [
|
|
||||||
{ value: "low", label: "Low", description: "720p @ 30fps" },
|
|
||||||
{ value: "medium", label: "Medium", description: "1080p @ 30fps" },
|
|
||||||
{ value: "high", label: "High", description: "1080p @ 60fps" },
|
|
||||||
{ value: "ultra", label: "Ultra", description: "1440p @ 60fps" },
|
|
||||||
];
|
|
||||||
|
|
||||||
export const CONTAINER_FORMATS = ["mp4", "mkv", "mov", "flv"] as const;
|
|
||||||
|
|
||||||
export const LOG_LEVELS = ["trace", "debug", "info", "warn", "error"] as const;
|
|
||||||
|
|
||||||
export const X264_PRESETS = [
|
|
||||||
"ultrafast",
|
|
||||||
"superfast",
|
|
||||||
"veryfast",
|
|
||||||
"faster",
|
|
||||||
"fast",
|
|
||||||
"medium",
|
|
||||||
"slow",
|
|
||||||
"slower",
|
|
||||||
"veryslow",
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export const AMF_QUALITIES: { value: "speed" | "balanced" | "quality"; label: string }[] = [
|
|
||||||
{ value: "speed", label: "Speed" },
|
|
||||||
{ value: "balanced", label: "Balanced" },
|
|
||||||
{ value: "quality", label: "Quality" },
|
|
||||||
];
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
/**
|
|
||||||
* DDragon version resolver for Data Dragon asset URLs.
|
|
||||||
*
|
|
||||||
* Resolves the appropriate patch version with the following priority:
|
|
||||||
* 1. Game-specific version (from recorded timeline data)
|
|
||||||
* 2. Latest version fetched from the DDragon API
|
|
||||||
* 3. Hardcoded fallback version
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { ref } from "vue";
|
|
||||||
|
|
||||||
/** DDragon versions API endpoint. */
|
|
||||||
const DDRAGON_VERSIONS_URL = "https://ddragon.leagueoflegends.com/api/versions.json";
|
|
||||||
|
|
||||||
/** Fallback version used when the DDragon API is unreachable. */
|
|
||||||
const FALLBACK_VERSION = "16.10.1";
|
|
||||||
|
|
||||||
/** Latest version from DDragon API (reactive — updates trigger Vue re-renders). */
|
|
||||||
export const ddragonVersion = ref<string>(FALLBACK_VERSION);
|
|
||||||
|
|
||||||
/** Whether the version has been fetched at least once. */
|
|
||||||
let versionInitialized = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch the latest game version from the DDragon API.
|
|
||||||
* Results are cached after the first call — subsequent calls return immediately.
|
|
||||||
* Safe to call multiple times (deduplicated).
|
|
||||||
*/
|
|
||||||
export async function fetchLatestDdragonVersion(): Promise<string> {
|
|
||||||
if (versionInitialized) {
|
|
||||||
return ddragonVersion.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(DDRAGON_VERSIONS_URL);
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP ${response.status}`);
|
|
||||||
}
|
|
||||||
const versions: string[] = await response.json();
|
|
||||||
if (versions.length > 0) {
|
|
||||||
ddragonVersion.value = versions[0];
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.warn("[ddragon] Failed to fetch versions, using fallback:", err);
|
|
||||||
} finally {
|
|
||||||
versionInitialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ddragonVersion.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current DDragon version (synchronous).
|
|
||||||
* Returns the cached latest version, or the fallback if not yet fetched.
|
|
||||||
*/
|
|
||||||
export function getDdragonVersion(): string {
|
|
||||||
return ddragonVersion.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a League game version string to DDragon format.
|
|
||||||
*
|
|
||||||
* The League Client reports versions like "16.10.1" or "16.10.1.1234".
|
|
||||||
* DDragon uses the first three components (e.g., "16.10.1").
|
|
||||||
*
|
|
||||||
* @returns The DDragon-formatted version string, or null if the input is invalid.
|
|
||||||
*/
|
|
||||||
export function gameVersionToDdragonVersion(gameVersion: string | null | undefined): string | null {
|
|
||||||
if (!gameVersion || typeof gameVersion !== "string") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const trimmed = gameVersion.trim();
|
|
||||||
if (!trimmed) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DDragon versions are in the format "XX.YY.ZZ" (e.g., "16.10.1")
|
|
||||||
// The game client may report "XX.YY.ZZ.WWWW" — we take the first 3 parts
|
|
||||||
const parts = trimmed.split(".");
|
|
||||||
if (parts.length >= 3) {
|
|
||||||
return `${parts[0]}.${parts[1]}.${parts[2]}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Two-part version — unlikely but handle gracefully
|
|
||||||
if (parts.length === 2) {
|
|
||||||
return trimmed;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
/// <reference types="vite/client" />
|
|
||||||
|
|
||||||
declare module "*.vue" {
|
|
||||||
import type { DefineComponent } from "vue";
|
|
||||||
const component: DefineComponent<{}, {}, any>;
|
|
||||||
export default component;
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "ES2020",
|
|
||||||
"useDefineForClassFields": true,
|
|
||||||
"module": "ESNext",
|
|
||||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
||||||
"skipLibCheck": true,
|
|
||||||
|
|
||||||
/* Bundler mode */
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"allowImportingTsExtensions": true,
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"isolatedModules": true,
|
|
||||||
"noEmit": true,
|
|
||||||
"jsx": "preserve",
|
|
||||||
|
|
||||||
/* Linting */
|
|
||||||
"strict": true,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"noUnusedParameters": true,
|
|
||||||
"noFallthroughCasesInSwitch": true
|
|
||||||
},
|
|
||||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
|
|
||||||
"references": [{ "path": "./tsconfig.node.json" }]
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"composite": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"allowSyntheticDefaultImports": true
|
|
||||||
},
|
|
||||||
"include": ["vite.config.ts"]
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import { defineConfig } from "vite";
|
|
||||||
import vue from "@vitejs/plugin-vue";
|
|
||||||
|
|
||||||
// @ts-expect-error process is a nodejs global
|
|
||||||
const host = process.env.TAURI_DEV_HOST;
|
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
|
||||||
export default defineConfig(async () => ({
|
|
||||||
plugins: [vue()],
|
|
||||||
|
|
||||||
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
|
||||||
//
|
|
||||||
// 1. prevent vite from obscuring rust errors
|
|
||||||
clearScreen: false,
|
|
||||||
// 2. tauri expects a fixed port, fail if that port is not available
|
|
||||||
server: {
|
|
||||||
port: 1420,
|
|
||||||
strictPort: true,
|
|
||||||
host: host || false,
|
|
||||||
hmr: host
|
|
||||||
? {
|
|
||||||
protocol: "ws",
|
|
||||||
host,
|
|
||||||
port: 1421,
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
watch: {
|
|
||||||
// 3. tell vite to ignore watching `src-tauri`
|
|
||||||
ignored: ["**/src-tauri/**"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}));
|
|
||||||