Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32e258dee7 | ||
|
|
777d54ba5b | ||
|
|
ae1612547a | ||
|
|
d2dd2f9c27 | ||
|
|
bde7d78c3d | ||
|
|
355a798c34 | ||
|
|
7a4ba815fe | ||
|
|
6839fdbf47 | ||
|
|
78fc2951a8 | ||
|
|
dd91910f98 | ||
|
|
ea21eef396 | ||
|
|
64e058ad2e | ||
|
|
7be5517d18 | ||
|
|
9c221cb101 | ||
|
|
a2800c3664 | ||
|
|
50ab1cd54a | ||
|
|
826e07adf5 | ||
|
|
03b35868a8 | ||
|
|
cb8eeea9cf | ||
|
|
4c3dec9304 |
No files matched your search
@@ -0,0 +1,45 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Bug Report template
|
||||
title: "[Bug]: "
|
||||
labels: bug, enhancement
|
||||
assignees: Alvin-Zilverstand
|
||||
|
||||
---
|
||||
|
||||
## Bug Description
|
||||
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
## Steps to Reproduce
|
||||
|
||||
1. Go to '...'
|
||||
2. Click on '...'
|
||||
3. Scroll down to '...'
|
||||
4. See error
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
## Actual Behavior
|
||||
|
||||
What actually happened (include error messages, screenshots, etc.)
|
||||
|
||||
## Environment
|
||||
|
||||
- **OS**: Windows 10/11 (version)
|
||||
- **ClipForge Version**: (e.g., v0.1.0)
|
||||
- **GPU**: NVIDIA/AMD/Intel (model)
|
||||
- **Game**: (if game-specific)
|
||||
|
||||
## Logs
|
||||
|
||||
Please attach relevant logs:
|
||||
- Application logs (if available)
|
||||
- Windows Event Viewer entries
|
||||
- FFmpeg output (if capture-related)
|
||||
|
||||
## Additional Context
|
||||
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
name: Feature Request
|
||||
about: Feature Request template
|
||||
title: "[Feature]: "
|
||||
labels: enhancement
|
||||
assignees: Alvin-Zilverstand
|
||||
|
||||
---
|
||||
|
||||
## Feature Description
|
||||
|
||||
A clear and concise description of the feature you'd like to see.
|
||||
|
||||
## Problem/Use Case
|
||||
|
||||
What problem does this solve? What's the use case?
|
||||
|
||||
## Proposed Solution
|
||||
|
||||
Describe how you'd like this feature to work.
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
Any alternative solutions or workarounds you've considered.
|
||||
|
||||
## Additional Context
|
||||
|
||||
Add any other context, mockups, or screenshots here.
|
||||
|
||||
## Implementation Ideas
|
||||
|
||||
If you have technical ideas on how to implement this, share them here.
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
name: Pull Request
|
||||
description: Template for pull requests
|
||||
title: "[PR]: "
|
||||
labels: []
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
Brief description of changes.
|
||||
|
||||
## Type of Change
|
||||
|
||||
- [ ] Bug fix
|
||||
- [ ] New feature
|
||||
- [ ] Breaking change
|
||||
- [ ] Documentation update
|
||||
- [ ] Refactoring
|
||||
- [ ] Tests
|
||||
- [ ] CI/CD
|
||||
|
||||
## Related Issues
|
||||
|
||||
Fixes #(issue number)
|
||||
|
||||
## Testing
|
||||
|
||||
- [ ] All existing tests pass (`cargo test`)
|
||||
- [ ] New tests added for changes
|
||||
- [ ] Manual testing performed
|
||||
- [ ] UI builds successfully (`pnpm run build`)
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] Code follows project style (`cargo fmt`, `pnpm run lint`)
|
||||
- [ ] Clippy clean (`cargo clippy`)
|
||||
- [ ] No new warnings
|
||||
- [ ] Documentation updated (if applicable)
|
||||
- [ ] CHANGELOG updated (if applicable)
|
||||
|
||||
## Screenshots (if UI changes)
|
||||
|
||||
## Additional Notes
|
||||
@@ -32,6 +32,31 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: Rust tests
|
||||
runs-on: windows-latest
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: pwsh
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: |
|
||||
.
|
||||
src-tauri
|
||||
|
||||
- name: Run Rust tests
|
||||
run: cargo test
|
||||
|
||||
windows-installer:
|
||||
name: Windows installer
|
||||
runs-on: windows-latest
|
||||
@@ -81,9 +106,6 @@ jobs:
|
||||
- name: Install frontend dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run Rust tests
|
||||
run: cargo test
|
||||
|
||||
- name: Build Windows desktop installers
|
||||
run: pnpm run desktop:build
|
||||
|
||||
@@ -124,6 +146,7 @@ jobs:
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.release.outputs.tag }}
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
src-tauri/target/release/bundle/msi/*.msi
|
||||
src-tauri/target/release/bundle/nsis/*.exe
|
||||
@@ -0,0 +1,127 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for
|
||||
moderation decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
alvin@alvnx.xyz.
|
||||
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][mozilla coc].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[mozilla coc]: https://github.com/mozilla/diversity
|
||||
@@ -0,0 +1,151 @@
|
||||
# Contributing to ClipForge
|
||||
|
||||
Thank you for your interest in contributing to ClipForge! This document provides guidelines for contributing to the project.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- **Rust** (stable toolchain) - install via [rustup](https://rustup.rs/)
|
||||
- **Node.js** (v22+) and **pnpm** (v11+) - install via [corepack](https://github.com/nodejs/corepack)
|
||||
- **Windows** (Windows 10/11) - ClipForge is Windows-first
|
||||
- **Visual Studio 2022** with C++ workload (for MSVC toolchain)
|
||||
|
||||
### Building from Source
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/Alvin-Zilverstand/clipforge-game-clipper.git
|
||||
cd clipforge-game-clipper
|
||||
|
||||
# Install frontend dependencies
|
||||
pnpm install
|
||||
|
||||
# Build the frontend
|
||||
pnpm run build
|
||||
|
||||
# Build the Tauri app (debug)
|
||||
pnpm run tauri dev
|
||||
|
||||
# Build the Tauri app (release installers)
|
||||
pnpm run desktop:build
|
||||
```
|
||||
|
||||
Installers will be created in `src-tauri/target/release/bundle/`.
|
||||
|
||||
### Running Tests
|
||||
|
||||
```bash
|
||||
# Run all Rust tests
|
||||
cargo test
|
||||
|
||||
# Run only library tests
|
||||
cargo test --lib
|
||||
|
||||
# Run specific test
|
||||
cargo test test_name
|
||||
```
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Branching Strategy
|
||||
|
||||
- `master` - Protected branch, only updated via PR merges
|
||||
- Feature branches: `feat/description` or `feature/description`
|
||||
- Bug fix branches: `fix/description` or `bugfix/description`
|
||||
- Documentation: `docs/description`
|
||||
|
||||
### Commit Messages
|
||||
|
||||
Follow [Conventional Commits](https://www.conventionalcommits.org/):
|
||||
|
||||
```
|
||||
type(scope): short description
|
||||
|
||||
Longer description if needed.
|
||||
|
||||
Fixes #123
|
||||
```
|
||||
|
||||
Types:
|
||||
- `feat`: New feature
|
||||
- `fix`: Bug fix
|
||||
- `docs`: Documentation changes
|
||||
- `style`: Code style (formatting, etc.)
|
||||
- `refactor`: Code refactoring
|
||||
- `test`: Adding/updating tests
|
||||
- `chore`: Maintenance tasks
|
||||
|
||||
### Pull Request Process
|
||||
|
||||
1. Fork the repository
|
||||
2. Create a feature branch from `master`
|
||||
3. Make your changes with tests
|
||||
4. Ensure all tests pass (`cargo test`)
|
||||
5. Ensure code is formatted (`cargo fmt`)
|
||||
6. Ensure clippy is clean (`cargo clippy`)
|
||||
7. Open a PR against `master`
|
||||
8. Wait for review and CI checks
|
||||
|
||||
### Code Style
|
||||
|
||||
- Rust: `cargo fmt` (standard rustfmt)
|
||||
- TypeScript: `pnpm run lint` (ESLint + Prettier)
|
||||
- Run `cargo clippy` before committing
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
```
|
||||
clipforge-game-clipper/
|
||||
├── src/ # Rust library (core logic)
|
||||
│ ├── capture.rs # FFmpeg capture backends
|
||||
│ ├── native_wgc.rs # Windows Graphics Capture
|
||||
│ ├── native_audio.rs # WASAPI audio capture
|
||||
│ ├── recorder.rs # Replay buffer, auto-clipping
|
||||
│ ├── integrations.rs # League/Valve GSI events
|
||||
│ ├── library.rs # Clip library (SQLite)
|
||||
│ ├── upload.rs # Upload providers
|
||||
│ ├── settings.rs # Versioned settings
|
||||
│ └── ...
|
||||
├── src-tauri/ # Tauri desktop shell
|
||||
│ └── src/main.rs # Tauri commands, app setup
|
||||
├── ui/ # TypeScript/Vite frontend
|
||||
│ └── src/main.ts # Single-page UI
|
||||
└── scripts/ # Build scripts
|
||||
```
|
||||
|
||||
## Adding Features
|
||||
|
||||
### New Capture Backend
|
||||
|
||||
1. Implement `CaptureBackend` trait in `src/capture.rs`
|
||||
2. Add to `start_best_capture_backend` in `src-tauri/src/main.rs`
|
||||
3. Add tests
|
||||
|
||||
### New Game Integration
|
||||
|
||||
1. Add game profile in `src/game_detection.rs`
|
||||
2. Implement `GameIntegration` trait in `src/integrations.rs`
|
||||
3. Add event normalization
|
||||
4. Update `default_auto_clip_events_for_game` in `src-tauri/src/main.rs`
|
||||
5. Add UI entries in `ui/src/main.ts`
|
||||
|
||||
### New Upload Provider
|
||||
|
||||
1. Implement `Uploader` trait in `src/upload.rs`
|
||||
2. Add to `upload_clip_with_settings` in `src-tauri/src/main.rs`
|
||||
3. Add UI in `ui/src/main.ts` (Uploads view)
|
||||
|
||||
## Reporting Issues
|
||||
|
||||
Use the GitHub issue templates:
|
||||
- [Bug Report](.github/ISSUE_TEMPLATE/bug_report.md)
|
||||
- [Feature Request](.github/ISSUE_TEMPLATE/feature_request.md)
|
||||
|
||||
## Security
|
||||
|
||||
See [SECURITY.md](SECURITY.md) for reporting security vulnerabilities.
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree that your contributions will be licensed under the [MIT License](LICENSE).
|
||||
@@ -85,8 +85,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clipforge"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"reqwest",
|
||||
"rusqlite",
|
||||
"serde",
|
||||
@@ -136,6 +137,27 @@ version = "0.8.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "5.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.7"
|
||||
@@ -505,6 +527,15 @@ version = "0.2.189"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6480ccc157a1389bb2e4891b24751b0f798ba640d22386f23143fbcc89da195a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsqlite3-sys"
|
||||
version = "0.30.1"
|
||||
@@ -609,6 +640,12 @@ version = "1.21.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||
|
||||
[[package]]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.5"
|
||||
@@ -682,7 +719,7 @@ dependencies = [
|
||||
"rustc-hash",
|
||||
"rustls",
|
||||
"socket2",
|
||||
"thiserror",
|
||||
"thiserror 2.0.20",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"web-time",
|
||||
@@ -704,7 +741,7 @@ dependencies = [
|
||||
"rustls",
|
||||
"rustls-pki-types",
|
||||
"slab",
|
||||
"thiserror",
|
||||
"thiserror 2.0.20",
|
||||
"tinyvec",
|
||||
"tracing",
|
||||
"web-time",
|
||||
@@ -794,6 +831,17 @@ dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
||||
dependencies = [
|
||||
"getrandom 0.2.17",
|
||||
"libredox",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.12.28"
|
||||
@@ -1073,13 +1121,33 @@ dependencies = [
|
||||
"windows 0.57.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||
dependencies = [
|
||||
"thiserror-impl 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
"thiserror-impl 2.0.20",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1277,7 +1345,7 @@ checksum = "ee144c215d8d31e94c1a599fbaf540ca82a7017e4f1786816b179f334fac751d"
|
||||
dependencies = [
|
||||
"log",
|
||||
"num-integer",
|
||||
"thiserror",
|
||||
"thiserror 2.0.20",
|
||||
"windows 0.62.2",
|
||||
"windows-core 0.62.2",
|
||||
]
|
||||
@@ -1401,7 +1469,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143"
|
||||
dependencies = [
|
||||
"windows-core 0.57.0",
|
||||
"windows-targets",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1424,7 +1492,7 @@ checksum = "09046acbe9b6d039cde50e8c8178d95bb0f9b33ed7feccc4465dadc5404b31b4"
|
||||
dependencies = [
|
||||
"parking_lot",
|
||||
"rayon",
|
||||
"thiserror",
|
||||
"thiserror 2.0.20",
|
||||
"windows 0.62.2",
|
||||
"windows-future",
|
||||
]
|
||||
@@ -1447,7 +1515,7 @@ dependencies = [
|
||||
"windows-implement 0.57.0",
|
||||
"windows-interface 0.57.0",
|
||||
"windows-result 0.1.2",
|
||||
"windows-targets",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1540,7 +1608,7 @@ version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1561,13 +1629,22 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1579,20 +1656,35 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.48.5",
|
||||
"windows_aarch64_msvc 0.48.5",
|
||||
"windows_i686_gnu 0.48.5",
|
||||
"windows_i686_msvc 0.48.5",
|
||||
"windows_x86_64_gnu 0.48.5",
|
||||
"windows_x86_64_gnullvm 0.48.5",
|
||||
"windows_x86_64_msvc 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_aarch64_gnullvm 0.52.6",
|
||||
"windows_aarch64_msvc 0.52.6",
|
||||
"windows_i686_gnu 0.52.6",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
"windows_i686_msvc 0.52.6",
|
||||
"windows_x86_64_gnu 0.52.6",
|
||||
"windows_x86_64_gnullvm 0.52.6",
|
||||
"windows_x86_64_msvc 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1604,18 +1696,36 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
@@ -1628,24 +1738,48 @@ version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "clipforge"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
description = "Windows-first local game clipping app scaffold with replay buffer and event auto-clipping core."
|
||||
license = "MIT"
|
||||
@@ -18,6 +18,7 @@ reqwest = { version = "0.12", default-features = false, features = ["blocking",
|
||||
rusqlite = { version = "0.32", features = ["bundled"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
dirs = "5"
|
||||
sysinfo = "0.31"
|
||||
wasapi = "0.24.0"
|
||||
windows-capture = "2.0.1"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 ClipForge Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,66 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
We release security updates for the following versions:
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 0.1.x | :white_check_mark: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
**Please do not report security vulnerabilities through public GitHub issues.**
|
||||
|
||||
Instead, please report them via email to: **alvin@alvnx.xyz**
|
||||
|
||||
You should receive a response within 48 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
|
||||
|
||||
Please include the following information:
|
||||
- Type of issue (e.g., buffer overflow, injection, information disclosure)
|
||||
- Full paths of source file(s) related to the vulnerability
|
||||
- Steps to reproduce the issue
|
||||
- Proof-of-concept or exploit code (if possible)
|
||||
- Impact of the vulnerability
|
||||
|
||||
## Disclosure Policy
|
||||
|
||||
- We will acknowledge receipt of your vulnerability report within 48 hours
|
||||
- We will provide a timeline for a fix within 5 business days
|
||||
- We will keep you informed of progress
|
||||
- We will credit you in the release notes (unless you prefer anonymity)
|
||||
- We will not take legal action against you for good-faith security research
|
||||
|
||||
## Security Considerations
|
||||
|
||||
ClipForge is a local-first application with the following security characteristics:
|
||||
|
||||
### Data Handling
|
||||
- All clips and metadata stored locally (SQLite + filesystem)
|
||||
- No telemetry or analytics
|
||||
- No account system or cloud sync
|
||||
- Upload is explicitly user-initiated (or via opt-in auto-upload)
|
||||
|
||||
### Network
|
||||
- League Live Client Data: HTTPS to localhost (127.0.0.1:2999) with cert verification disabled (Riot's self-signed cert)
|
||||
- Valve GSI: HTTP receiver on 127.0.0.1:49321 (local only)
|
||||
- Upload providers: HTTPS to Catbox/Litterbox/custom endpoints
|
||||
- No outbound connections except explicit uploads
|
||||
|
||||
### Permissions
|
||||
- Requires Windows screen capture permission (Windows Graphics Capture)
|
||||
- Requires microphone permission (if enabled)
|
||||
- Runs as standard user (not elevated)
|
||||
|
||||
### Known Attack Surface
|
||||
1. **GSI HTTP Receiver** - Local-only, but could be accessed by other local processes
|
||||
2. **FFmpeg subprocess** - User-controlled arguments sanitized, but FFmpeg itself is a large attack surface
|
||||
3. **SQLite database** - Local file, no network exposure
|
||||
4. **Tauri IPC** - Commands validated server-side
|
||||
|
||||
## Security Best Practices for Users
|
||||
|
||||
- Keep ClipForge updated
|
||||
- Only enable auto-upload to trusted providers
|
||||
- Review custom upload endpoints before use
|
||||
- Run on supported Windows versions with latest patches
|
||||
@@ -36,30 +36,58 @@
|
||||
- The UI Upload button uses the selected upload provider and saved provider configuration, including Catbox userhash, Litterbox expiry, custom endpoint, response path, and custom headers.
|
||||
- Auto-upload is persisted and, when enabled, attempts upload after manual and event clips while preserving local clips on failure.
|
||||
- Upload attempts are recorded in SQLite upload history.
|
||||
- The Uploads screen shows recent upload history with retry buttons for failed uploads, refreshed from the backend on load and after uploads.
|
||||
- Screenshot capture is implemented: F9 takes a PNG screenshot via bundled FFmpeg into `~/Pictures/ClipForge`, the recording bar has a Screenshot button, and the Library shows recent screenshots with an Open-in-Explorer action.
|
||||
- Storage guardrails are wired: recording refuses to start below 2 GB free and a backend worker stops an active recording and flags `StorageLow` when available disk drops to critical; the recording bar shows free disk space and a low-disk warning.
|
||||
- Panic reporting writes crash reports with stack traces to the logs folder (`library/logs`), prunes old entries, and the Settings screen can open the logs folder.
|
||||
- Native Windows Graphics Capture now downscales the captured window/monitor to the configured resolution cap (e.g. 720p) with even dimensions while preserving aspect ratio; covered by unit tests.
|
||||
- Capture quality and storage settings are exposed: the Settings screen can change resolution, FPS, bitrate, buffer storage cap, excluded window titles, and the separate-audio-tracks toggle via the `set_capture_settings` command, and current values are shown in DesktopStatus.
|
||||
- Per-game capture quality overrides can be set from the Recording screen per detected game title, saved in settings, and applied automatically by the recorder when that game is active.
|
||||
- The configured storage cap is enforced by a backend worker that prunes the oldest rolling buffer segments once the buffer exceeds `storage_limit_gb`.
|
||||
- SQLite schema uses versioned migrations tracked via `PRAGMA user_version`; legacy databases (missing tables or the `title` column) are repaired and upgraded in place, with migration tests.
|
||||
- Valve GSI event mapping enriches CS2 round, bomb, and match-start events with round number, map scores, and plant-region metadata; Dota 2 game-state transitions map to match-start bookmarks and match-end events carrying final radiant/dire scores. These events are unit tested against realistic JSON payloads.
|
||||
- A GitHub Actions release workflow (`.github/workflows/release.yml`) builds MSI and NSIS installers on tag push or manual dispatch and publishes them to a GitHub Release, ready for the auto-updater to pick up.
|
||||
- Auto-update checks the GitHub repo releases (`Alvin-Zilverstand/clipforge-game-clipper`) for the latest MSI/NSIS installer, compares it against the running version, downloads it to temp, launches the installer, and exits the app to finish; version comparison, asset selection, and parsing are unit tested plus one ignored live test against the GitHub API.
|
||||
- A GitHub Actions release workflow publishes MSI/NSIS assets on tag push; auto-update will pick up newer releases automatically once the repo ships a tag newer than the running app version.
|
||||
- The Settings screen shows the current version, checks for updates, and offers a Download & install button when a newer release exists.
|
||||
- First-run onboarding wizard walks new installs through privacy/audio, capture-source, storage, and hotkey setup before showing the main app; it uses the defaults already saved in `settings.json` so existing users are unaffected.
|
||||
- The default clip library root is `~/Documents/ClipForge` (rather than the process working directory), and a first-run migration moves any legacy `clipforge-library` folder found in the CWD into the new location while rewriting stored clip paths in the SQLite database.
|
||||
- Capture capabilities (bundled FFmpeg discovery, WASAPI/ddagrab support) are detected once at startup and cached, so background workers (`refresh_detected_game` every 2s, UI status poll every 3s) never spawn FFmpeg; all FFmpeg/console subprocesses are launched with a hidden console window on Windows, preventing the app from freezing and flashing a terminal repeatedly.
|
||||
- Vite TypeScript UI builds and has interactive Library, Recording, Auto Clip, Uploads, and Settings views.
|
||||
- Tauri's asset protocol is enabled and scoped to `$DOCUMENT/ClipForge/**` and `$PICTURE/ClipForge/**`, so `convertFileSrc` URLs load for clip thumbnails, video previews, and screenshot images (previously returned blocked asset responses).
|
||||
- Screenshot thumbnails use `object-fit: contain` so the full screenshot is shown without cropping.
|
||||
- An opt-in "Minimize to tray" setting keeps ClipForge running in the system tray when the main window is closed; closing the window hides it, and the tray menu offers "Open ClipForge" to restore it or "Quit ClipForge" to exit fully. The toggle is under Settings > Tray and defaults to off.
|
||||
- Library search, event/upload filters, and grid/list switching are functional in the UI.
|
||||
- User-visible notices are shown for major actions and failures instead of relying only on console output.
|
||||
- Versions are bumped to `0.1.1` across root `Cargo.toml`, `src-tauri/Cargo.toml`, `tauri.conf.json`, `package.json`, and the frontend `appVersion` constant.
|
||||
- The updater now requires both a newer release and a published installer asset before offering a download; the UI always shows "Check for updates" and only shows a Download button when an installer is available.
|
||||
- The clip folder can be changed at runtime via `set_clip_directory`; the library root and asset-protocol scope are rebuilt without restarting the app.
|
||||
- An optional auto-prune toggle deletes the oldest non-manual clips once the saved library exceeds the configured storage limit.
|
||||
- Free disk space and storage-limit status are cached for 10 seconds, reducing repeated FS calls from the background and UI polls.
|
||||
- A RAM-backed clip buffer (512 MB cap) keeps recent segments in memory and merges them with disk segments when manual, auto, or hotkey clips are saved; this lowers disk I/O and lets clips span RAM-only material.
|
||||
- Clip-related commands (`save_manual_clip`, `start_capture`, `stop_capture`, `trim_clip`, `upload_clip`, `take_screenshot`) now run as async Tauri commands so they execute off the main thread.
|
||||
- The recording toggle flips optimistically in the UI and rolls back on error.
|
||||
- The backend emits `clip-saved`, `clip-deleted`, `screenshots-changed`, and `storage-cleanup` events; the UI listens for them and refreshes clips and screenshots on demand.
|
||||
- A modal viewer opens for clips and screenshots; when a clip's MP4 cannot load, the modal shows the file path and a Reveal-in-Explorer button instead of a broken `<video>` element.
|
||||
- Bitrate settings now offer a preset dropdown (Low / Medium / Stream-ready / High / Ultra) plus a custom numeric input.
|
||||
- Auto Clip rules are displayed per game with an Enable / Disable toggle per game, plus Enable all / Disable all / Restore defaults buttons.
|
||||
- The app icon source is now a checked-in SVG (`src-tauri/icons/icon.svg`); all platform raster icons and `icon.ico` are regenerated from a 1024×1024 PNG rendered from that SVG.
|
||||
|
||||
## Not Fully Working Yet
|
||||
|
||||
- Native Windows Graphics Capture is wired for rolling replay capture with native audio; resolution downscaling still needs more work.
|
||||
- Native WASAPI audio is mixed into a single AAC track for MVP clips; separate audio tracks and per-process audio capture are still future work.
|
||||
- Capture has not yet been manually QA-tested on real NVIDIA/AMD/Intel gaming systems.
|
||||
- Upload retry controls and a visible upload-history screen are not complete yet.
|
||||
- Valve GSI receiver is a lightweight MVP receiver; config templates can be generated from the Auto Clip screen, but richer event mapping per game is still needed.
|
||||
- Native Windows Graphics Capture and FFmpeg capture finalization have not yet been manually QA-tested on real NVIDIA/AMD/Intel gaming systems.
|
||||
- Native WASAPI audio is mixed into a single AAC track for MVP clips; separate audio tracks are now honored by the FFmpeg recording backend (routing around the single-track native WGC encoder), while per-process audio capture remains future work.
|
||||
- Valve GSI receiver is a lightweight MVP receiver; config templates can be generated from the Auto Clip screen. CS2 round/bomb/match-start and Dota 2 match-start/match-end transitions are mapped, but per-player kill/death/objective event detection for Dota 2 and other Source titles is still needed.
|
||||
- Auto start/stop is conservative but live: when auto-record is enabled, supported detected games can start recording and stop when the game disappears.
|
||||
- Trim still uses timestamp text inputs instead of draggable timeline handles.
|
||||
- Hotkeys are still hardcoded; editable hotkey registration is future work.
|
||||
- Screenshot capture is still not implemented.
|
||||
- Capture source, quality, storage cap, excluded windows, and per-game override UI are still incomplete.
|
||||
- Storage critical-low-disk guardrails are not fully wired into recording start/stop behavior.
|
||||
- Recorder service still runs inside the Tauri process instead of a separate background service process.
|
||||
- Installer onboarding, auto-update, and crash logging are still not implemented.
|
||||
- Auto-update requires a GitHub release whose tag is newer than the running app version and that ships MSI/NSIS assets (the existing `v0.0.1` release carries 0.1.0 assets, so it correctly reports up to date).
|
||||
- RAM-backed clipping reduces disk churn but cannot eliminate it entirely; FFmpeg still writes final clips to disk, and very large segment histories may briefly exceed the RAM cap before pruning.
|
||||
- SVG icon rasterization depends on the sharp-based tooling used during development; the generated `icon.ico` and PNGs are checked in so normal builds do not require it.
|
||||
|
||||
## Next Engineering Steps
|
||||
|
||||
1. Extend native Windows Graphics Capture with resolution downscaling and richer capture-source selection.
|
||||
2. Add separate audio tracks and optional per-process loopback capture.
|
||||
3. Expand CS2/Dota GSI event mapping beyond the current MVP event parser.
|
||||
4. Add installer/onboarding screens for privacy, capture source, storage, and hotkeys.
|
||||
5. Run manual QA on Windows gaming hardware and tune CPU/GPU overhead.
|
||||
1. Add per-process loopback capture so individual application audio can be captured independently of the system mix.
|
||||
2. Add per-player kill/death/objective event detection for Dota 2 and other Source titles beyond the current match-level transitions.
|
||||
3. Split the recorder service into a separate background process so capture survives app restarts.
|
||||
4. Run manual QA on Windows gaming hardware and tune CPU/GPU overhead.
|
||||
5. Exercise the GitHub Actions release workflow with the `v0.1.1` tag push and verify the published assets appear in a GitHub Release.
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clipforge",
|
||||
"version": "0.1.0",
|
||||
"name": "clipforge",
|
||||
"version": "0.1.1",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@11.19.0",
|
||||
"type": "module",
|
||||
|
||||
@@ -358,8 +358,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clipforge"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"dirs 5.0.1",
|
||||
"reqwest 0.12.28",
|
||||
"rusqlite",
|
||||
"serde",
|
||||
@@ -371,7 +372,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clipforge-desktop"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"clipforge",
|
||||
"serde",
|
||||
@@ -666,13 +667,34 @@ dependencies = [
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "5.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
||||
dependencies = [
|
||||
"dirs-sys 0.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
"dirs-sys 0.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users 0.4.6",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -683,7 +705,7 @@ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"redox_users 0.5.2",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
@@ -1441,6 +1463,12 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-range"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573"
|
||||
|
||||
[[package]]
|
||||
name = "httparse"
|
||||
version = "1.10.1"
|
||||
@@ -2749,6 +2777,17 @@ dependencies = [
|
||||
"bitflags 2.13.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
||||
dependencies = [
|
||||
"getrandom 0.2.17",
|
||||
"libredox",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.5.2"
|
||||
@@ -3550,7 +3589,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"cookie",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
"embed_plist",
|
||||
"getrandom 0.3.4",
|
||||
@@ -3558,6 +3597,7 @@ dependencies = [
|
||||
"gtk",
|
||||
"heck 0.5.0",
|
||||
"http",
|
||||
"http-range",
|
||||
"jni",
|
||||
"libc",
|
||||
"log",
|
||||
@@ -3600,7 +3640,7 @@ checksum = "bc9ce40b16101cb6ea63d3e221567affd1c3a9205f95d7bc574941a10636b632"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo_toml",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"glob",
|
||||
"heck 0.5.0",
|
||||
"json-patch",
|
||||
@@ -4117,7 +4157,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "045979e3f037cd18ad1cb2a419dfda133c5c29c9f3453370079f2255d46c257e"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"libappindicator",
|
||||
"muda",
|
||||
"objc2",
|
||||
@@ -4834,6 +4874,15 @@ dependencies = [
|
||||
"windows-targets 0.42.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
@@ -4876,6 +4925,21 @@ dependencies = [
|
||||
"windows_x86_64_msvc 0.42.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.48.5",
|
||||
"windows_aarch64_msvc 0.48.5",
|
||||
"windows_i686_gnu 0.48.5",
|
||||
"windows_i686_msvc 0.48.5",
|
||||
"windows_x86_64_gnu 0.48.5",
|
||||
"windows_x86_64_gnullvm 0.48.5",
|
||||
"windows_x86_64_msvc 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
@@ -4925,6 +4989,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
@@ -4937,6 +5007,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
@@ -4949,6 +5025,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
@@ -4967,6 +5049,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
@@ -4979,6 +5067,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
@@ -4991,6 +5085,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
@@ -5003,6 +5103,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
@@ -5065,7 +5171,7 @@ dependencies = [
|
||||
"block2",
|
||||
"cookie",
|
||||
"crossbeam-channel",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"dom_query",
|
||||
"dpi",
|
||||
"dunce",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "clipforge-desktop"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
description = "Tauri desktop shell for ClipForge."
|
||||
license = "MIT"
|
||||
@@ -11,10 +11,9 @@ tauri-build = { version = "2.5.3", features = [] }
|
||||
[dependencies]
|
||||
clipforge = { path = ".." }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
tauri = { version = "2.9.5", features = [] }
|
||||
tauri = { version = "2.9.5", features = ["protocol-asset", "tray-icon"] }
|
||||
tauri-plugin-global-shortcut = "2"
|
||||
|
||||
[profile.release]
|
||||
lto = "thin"
|
||||
codegen-units = 1
|
||||
strip = true
|
||||
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 8.0 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#fff</color>
|
||||
</resources>
|
||||
|
After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1,12 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#2b6cff"/>
|
||||
<stop offset="100%" stop-color="#8b5cf6"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="1024" height="1024" rx="224" fill="url(#bg)"/>
|
||||
<text x="512" y="718" font-family="Arial, Helvetica, sans-serif" font-size="560" font-weight="800" text-anchor="middle" fill="#ffffff">CF</text>
|
||||
<circle cx="766" cy="264" r="66" fill="#34d399"/>
|
||||
<circle cx="766" cy="264" r="28" fill="#191d26"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 605 B |
|
After Width: | Height: | Size: 925 B |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 8.4 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "ClipForge",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"identifier": "app.clipforge.desktop",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm run dev",
|
||||
@@ -21,7 +21,15 @@
|
||||
],
|
||||
"withGlobalTauri": true,
|
||||
"security": {
|
||||
"csp": null
|
||||
"csp": null,
|
||||
"assetProtocol": {
|
||||
"enable": true,
|
||||
"scope": [
|
||||
"$DOCUMENT/ClipForge/**",
|
||||
"$PICTURE/ClipForge/**",
|
||||
"$HOME/.clipforge/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::proc::hidden_command;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum AudioDeviceKind {
|
||||
@@ -14,7 +14,7 @@ pub struct AudioDevice {
|
||||
}
|
||||
|
||||
pub fn list_ffmpeg_dshow_audio_inputs(ffmpeg: &Path) -> Vec<AudioDevice> {
|
||||
let Ok(output) = Command::new(ffmpeg)
|
||||
let Ok(output) = hidden_command(ffmpeg)
|
||||
.args([
|
||||
"-hide_banner",
|
||||
"-list_devices",
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use crate::proc::hidden_command;
|
||||
use std::fmt;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::process::{Child, Command, Stdio};
|
||||
use std::process::{Child, Stdio};
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
@@ -114,7 +115,7 @@ pub fn find_ffmpeg_executable() -> Option<PathBuf> {
|
||||
|
||||
let candidates = ["ffmpeg.exe", "ffmpeg"];
|
||||
for candidate in candidates {
|
||||
if Command::new(candidate).arg("-version").output().is_ok() {
|
||||
if hidden_command(candidate).arg("-version").output().is_ok() {
|
||||
return Some(PathBuf::from(candidate));
|
||||
}
|
||||
}
|
||||
@@ -127,7 +128,7 @@ pub fn ffmpeg_is_available() -> bool {
|
||||
}
|
||||
|
||||
pub fn ffmpeg_supports_input_device(executable: &std::path::Path, device: &str) -> bool {
|
||||
let Ok(output) = Command::new(executable)
|
||||
let Ok(output) = hidden_command(executable)
|
||||
.args(["-hide_banner", "-devices"])
|
||||
.output()
|
||||
else {
|
||||
@@ -144,7 +145,7 @@ pub fn ffmpeg_supports_input_device(executable: &std::path::Path, device: &str)
|
||||
}
|
||||
|
||||
pub fn ffmpeg_supports_filter(executable: &std::path::Path, filter: &str) -> bool {
|
||||
let Ok(output) = Command::new(executable)
|
||||
let Ok(output) = hidden_command(executable)
|
||||
.args(["-hide_banner", "-filters"])
|
||||
.output()
|
||||
else {
|
||||
@@ -160,6 +161,23 @@ pub fn ffmpeg_supports_filter(executable: &std::path::Path, filter: &str) -> boo
|
||||
.any(|line| line.split_whitespace().any(|part| part == filter))
|
||||
}
|
||||
|
||||
/// Returns true when the single-track native WGC encoder can satisfy the requested audio
|
||||
/// configuration. windows-capture exposes one mixed audio channel, so distinct system/mic
|
||||
/// tracks are only achievable through the FFmpeg backend and route there instead.
|
||||
pub fn native_capture_can_honor_audio(
|
||||
system_audio_enabled: bool,
|
||||
mic_enabled: bool,
|
||||
separate_audio_tracks: bool,
|
||||
native_system_audio_available: bool,
|
||||
native_mic_available: bool,
|
||||
) -> bool {
|
||||
if system_audio_enabled && mic_enabled && separate_audio_tracks {
|
||||
return false;
|
||||
}
|
||||
(!system_audio_enabled || native_system_audio_available)
|
||||
&& (!mic_enabled || native_mic_available)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct FfmpegRecordingPlan {
|
||||
pub executable: PathBuf,
|
||||
@@ -298,9 +316,9 @@ fn base_desktop_input_args(config: &CaptureConfig) -> Vec<String> {
|
||||
args.extend([
|
||||
"-map".to_string(),
|
||||
format!("{}:a?", input_idx),
|
||||
"-c:a:{}".to_string(), idx.to_string(),
|
||||
format!("-c:a:{idx}"),
|
||||
"aac".to_string(),
|
||||
"-b:a:{}".to_string(), idx.to_string(),
|
||||
format!("-b:a:{idx}"),
|
||||
"160k".to_string(),
|
||||
]);
|
||||
}
|
||||
@@ -351,7 +369,7 @@ impl CaptureBackend for FfmpegCaptureBackend {
|
||||
}
|
||||
|
||||
let plan = self.plan(&config);
|
||||
let child = Command::new(&plan.executable)
|
||||
let child = hidden_command(&plan.executable)
|
||||
.args(&plan.args)
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::null())
|
||||
@@ -457,7 +475,7 @@ impl Drop for FfmpegReplayCaptureBackend {
|
||||
}
|
||||
|
||||
fn spawn_ffmpeg(plan: &FfmpegRecordingPlan) -> Result<Child, CaptureError> {
|
||||
Command::new(&plan.executable)
|
||||
hidden_command(&plan.executable)
|
||||
.args(&plan.args)
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::null())
|
||||
@@ -572,4 +590,82 @@ mod tests {
|
||||
"wasapi"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn separate_tracks_map_distinct_audio_inputs() {
|
||||
let config = CaptureConfig {
|
||||
source: CaptureSource::Desktop,
|
||||
method: CaptureMethod::DesktopDuplication,
|
||||
width: 1280,
|
||||
height: 720,
|
||||
fps: 30,
|
||||
bitrate_kbps: 6000,
|
||||
encoder: EncoderPreference::HardwareH264,
|
||||
system_audio_enabled: true,
|
||||
mic_enabled: true,
|
||||
system_audio_device: None,
|
||||
mic_device: Some("Microphone".to_string()),
|
||||
separate_audio_tracks: true,
|
||||
};
|
||||
|
||||
let plan = FfmpegRecordingPlan::for_windows_desktop_segments(
|
||||
"ffmpeg",
|
||||
"segment-%05d.mp4",
|
||||
&config,
|
||||
Duration::from_secs(5),
|
||||
);
|
||||
|
||||
assert!(plan.args.iter().any(|arg| arg == "-map"));
|
||||
assert!(plan.args.windows(2).any(|pair| pair == ["-map", "1:a?"]));
|
||||
assert!(plan.args.windows(2).any(|pair| pair == ["-map", "2:a?"]));
|
||||
assert!(plan.args.iter().any(|arg| arg == "-c:a:0"));
|
||||
assert!(plan.args.iter().any(|arg| arg == "-c:a:1"));
|
||||
assert!(plan.args.iter().any(|arg| arg == "wasapi"));
|
||||
assert!(plan.args.iter().any(|arg| arg.contains("Microphone")));
|
||||
assert!(!plan.args.windows(3).any(|triple| triple == ["-c:a", "aac", "-b:a"]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_mixed_audio_keeps_single_track_encoding_when_separate_tracks_off() {
|
||||
let config = CaptureConfig {
|
||||
source: CaptureSource::Desktop,
|
||||
method: CaptureMethod::GdiGrab,
|
||||
width: 1280,
|
||||
height: 720,
|
||||
fps: 30,
|
||||
bitrate_kbps: 6000,
|
||||
encoder: EncoderPreference::HardwareH264,
|
||||
system_audio_enabled: true,
|
||||
mic_enabled: true,
|
||||
system_audio_device: None,
|
||||
mic_device: Some("Microphone".to_string()),
|
||||
separate_audio_tracks: false,
|
||||
};
|
||||
|
||||
let plan = FfmpegRecordingPlan::for_windows_desktop("ffmpeg", "out.mp4", &config);
|
||||
|
||||
assert!(plan.args.windows(2).any(|pair| pair == ["-map", "1:a?"]));
|
||||
assert!(plan.args.windows(2).any(|pair| pair == ["-map", "2:a?"]));
|
||||
assert!(plan.args.windows(3).any(|triple| triple == ["-c:a", "aac", "-b:a"]));
|
||||
assert!(!plan.args.iter().any(|arg| arg == "-c:a:0"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_capture_cannot_honor_separate_tracks() {
|
||||
assert!(!native_capture_can_honor_audio(true, true, true, true, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_capture_honors_single_source_combinations() {
|
||||
assert!(native_capture_can_honor_audio(true, false, true, true, false));
|
||||
assert!(native_capture_can_honor_audio(false, true, true, false, true));
|
||||
assert!(native_capture_can_honor_audio(true, true, false, true, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_capture_requires_available_native_sources() {
|
||||
assert!(!native_capture_can_honor_audio(true, false, false, false, true));
|
||||
assert!(!native_capture_can_honor_audio(false, true, false, true, false));
|
||||
assert!(native_capture_can_honor_audio(false, false, true, false, false));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
const MAX_CRASH_FILES: u64 = 5;
|
||||
|
||||
pub fn install_panic_hook(log_dir: impl Into<PathBuf>) {
|
||||
let log_dir = log_dir.into();
|
||||
let _ = fs::create_dir_all(&log_dir);
|
||||
let guard_path = log_dir.join("latest-crash.txt");
|
||||
|
||||
std::panic::set_hook(Box::new(move |panic_info| {
|
||||
let now = SystemTime::now();
|
||||
let timestamp = now
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_secs();
|
||||
let payload = panic_info
|
||||
.payload()
|
||||
.downcast_ref::<&str>()
|
||||
.map(|value| value.to_string())
|
||||
.or_else(|| {
|
||||
panic_info
|
||||
.payload()
|
||||
.downcast_ref::<String>()
|
||||
.map(Clone::clone)
|
||||
})
|
||||
.unwrap_or_else(|| "unknown panic payload".to_string());
|
||||
let location = panic_info
|
||||
.location()
|
||||
.map(|location| format!("{}:{}", location.file(), location.line()))
|
||||
.unwrap_or_else(|| "unknown location".to_string());
|
||||
|
||||
let mut body = String::new();
|
||||
body.push_str("ClipForge crash report\n");
|
||||
body.push_str(&format!("time: {timestamp}\n"));
|
||||
body.push_str(&format!("thread: {}\n", thread_name()));
|
||||
body.push_str(&format!("location: {location}\n"));
|
||||
body.push_str(&format!("message: {payload}\n"));
|
||||
body.push_str("\nBacktrace:\n");
|
||||
body.push_str(&backtrace());
|
||||
|
||||
let _ = fs::write(&guard_path, &body);
|
||||
let file = log_dir.join(format!("crash-{timestamp}.log"));
|
||||
let _ = fs::write(&file, &body);
|
||||
prune_crash_files(&log_dir);
|
||||
|
||||
eprint!("{body}");
|
||||
}));
|
||||
}
|
||||
|
||||
fn thread_name() -> String {
|
||||
std::thread::current()
|
||||
.name()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_else(|| "<unnamed>".to_string())
|
||||
}
|
||||
|
||||
fn backtrace() -> String {
|
||||
let backtrace = std::backtrace::Backtrace::force_capture();
|
||||
format!("{backtrace}")
|
||||
}
|
||||
|
||||
fn prune_crash_files(log_dir: &Path) {
|
||||
let Ok(entries) = fs::read_dir(log_dir) else {
|
||||
return;
|
||||
};
|
||||
let mut files = entries
|
||||
.filter_map(|entry| entry.ok())
|
||||
.map(|entry| entry.path())
|
||||
.filter(|path| {
|
||||
path.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.map(|name| name.starts_with("crash-") && name.ends_with(".log"))
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
files.sort();
|
||||
while files.len() as u64 > MAX_CRASH_FILES {
|
||||
let oldest = files.remove(0);
|
||||
let _ = fs::remove_file(oldest);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn panic_hook_writes_crash_file() {
|
||||
let log_dir = std::env::temp_dir().join(format!(
|
||||
"clipforge-crashlog-{}",
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_nanos()
|
||||
));
|
||||
fs::create_dir_all(&log_dir).expect("log dir");
|
||||
install_panic_hook(&log_dir);
|
||||
|
||||
let result = std::panic::catch_unwind(|| {
|
||||
let before = fs::read_dir(&log_dir).expect("read").count();
|
||||
assert_eq!(before, 0);
|
||||
panic!("intentional-test-panic");
|
||||
});
|
||||
assert!(result.is_err());
|
||||
drop(std::panic::take_hook());
|
||||
|
||||
let crash_files = fs::read_dir(&log_dir)
|
||||
.expect("read")
|
||||
.filter_map(|entry| entry.ok())
|
||||
.map(|entry| entry.path())
|
||||
.filter(|path| {
|
||||
path.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.map(|name| name.starts_with("crash-"))
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
assert!(!crash_files.is_empty(), "expected a crash log file");
|
||||
let body = fs::read_to_string(&crash_files[0]).expect("crash body");
|
||||
assert!(body.contains("intentional-test-panic"));
|
||||
|
||||
let _ = fs::remove_dir_all(log_dir);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,46 @@
|
||||
use crate::models::{Clip, ClipSource, GameEventType, UploadProvider};
|
||||
use crate::models::{Clip, ClipSource, GameEventType, UploadHistoryEntry, UploadProvider};
|
||||
use rusqlite::{params, Connection};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
const CURRENT_SCHEMA_VERSION: u32 = MIGRATIONS.len() as u32;
|
||||
|
||||
const MIGRATIONS: &[&str] = &[
|
||||
// v1: initial clips table (also used to repair databases predating versioned migrations).
|
||||
"
|
||||
CREATE TABLE IF NOT EXISTS clips (
|
||||
id TEXT PRIMARY KEY NOT NULL,
|
||||
title TEXT,
|
||||
session_id TEXT NOT NULL,
|
||||
game_id TEXT NOT NULL,
|
||||
path TEXT NOT NULL,
|
||||
thumbnail_path TEXT,
|
||||
created_at_ms INTEGER NOT NULL,
|
||||
duration_ms INTEGER NOT NULL,
|
||||
source TEXT NOT NULL,
|
||||
event_type TEXT,
|
||||
tags_json TEXT NOT NULL,
|
||||
upload_url TEXT,
|
||||
upload_provider TEXT
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS clips_created_at_idx ON clips(created_at_ms DESC);
|
||||
CREATE INDEX IF NOT EXISTS clips_game_id_idx ON clips(game_id);
|
||||
",
|
||||
// v2: upload history bookkeeping.
|
||||
"
|
||||
CREATE TABLE IF NOT EXISTS upload_history (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
clip_id TEXT NOT NULL,
|
||||
provider TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
url TEXT,
|
||||
error TEXT,
|
||||
attempted_at_ms INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS upload_history_clip_id_idx ON upload_history(clip_id);
|
||||
",
|
||||
];
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ClipDatabase {
|
||||
connection: Connection,
|
||||
@@ -22,42 +60,32 @@ impl ClipDatabase {
|
||||
}
|
||||
|
||||
pub fn init(&self) -> rusqlite::Result<()> {
|
||||
self.connection.execute_batch(
|
||||
"
|
||||
CREATE TABLE IF NOT EXISTS clips (
|
||||
id TEXT PRIMARY KEY NOT NULL,
|
||||
title TEXT,
|
||||
session_id TEXT NOT NULL,
|
||||
game_id TEXT NOT NULL,
|
||||
path TEXT NOT NULL,
|
||||
thumbnail_path TEXT,
|
||||
created_at_ms INTEGER NOT NULL,
|
||||
duration_ms INTEGER NOT NULL,
|
||||
source TEXT NOT NULL,
|
||||
event_type TEXT,
|
||||
tags_json TEXT NOT NULL,
|
||||
upload_url TEXT,
|
||||
upload_provider TEXT
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS clips_created_at_idx ON clips(created_at_ms DESC);
|
||||
CREATE INDEX IF NOT EXISTS clips_game_id_idx ON clips(game_id);
|
||||
CREATE TABLE IF NOT EXISTS upload_history (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
clip_id TEXT NOT NULL,
|
||||
provider TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
url TEXT,
|
||||
error TEXT,
|
||||
attempted_at_ms INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS upload_history_clip_id_idx ON upload_history(clip_id);
|
||||
",
|
||||
)?;
|
||||
self.migrate()?;
|
||||
if !self.column_exists("clips", "title")? {
|
||||
self.connection
|
||||
.execute("ALTER TABLE clips ADD COLUMN title TEXT", [])?;
|
||||
}
|
||||
self.connection.pragma_update(None, "user_version", 2)
|
||||
if self.user_version()? != CURRENT_SCHEMA_VERSION {
|
||||
self.connection
|
||||
.pragma_update(None, "user_version", CURRENT_SCHEMA_VERSION)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn migrate(&self) -> rusqlite::Result<()> {
|
||||
let mut version = self.user_version()?;
|
||||
while (version as usize) < MIGRATIONS.len() {
|
||||
self.connection.execute_batch(MIGRATIONS[version as usize])?;
|
||||
version += 1;
|
||||
self.connection
|
||||
.pragma_update(None, "user_version", version)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn user_version(&self) -> rusqlite::Result<u32> {
|
||||
self.connection
|
||||
.query_row("PRAGMA user_version", [], |row| row.get(0))
|
||||
}
|
||||
|
||||
pub fn load_clips(&self) -> rusqlite::Result<Vec<Clip>> {
|
||||
@@ -144,6 +172,16 @@ impl ClipDatabase {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn rewrite_path_prefix(&self, old_prefix: &str, new_prefix: &str) -> rusqlite::Result<usize> {
|
||||
self.connection.execute(
|
||||
"UPDATE clips SET
|
||||
path = REPLACE(path, ?1, ?2),
|
||||
thumbnail_path = REPLACE(thumbnail_path, ?1, ?2)
|
||||
WHERE path LIKE ?1 || '%' OR thumbnail_path LIKE ?1 || '%'",
|
||||
params![old_prefix, new_prefix],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn insert_upload_history(
|
||||
&self,
|
||||
clip_id: &str,
|
||||
@@ -176,6 +214,31 @@ impl ClipDatabase {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn load_upload_history(&self) -> rusqlite::Result<Vec<UploadHistoryEntry>> {
|
||||
let mut statement = self.connection.prepare(
|
||||
"
|
||||
SELECT id, clip_id, provider, status, url, error, attempted_at_ms
|
||||
FROM upload_history
|
||||
ORDER BY attempted_at_ms DESC
|
||||
LIMIT 200
|
||||
",
|
||||
)?;
|
||||
|
||||
let rows = statement.query_map([], |row| {
|
||||
Ok(UploadHistoryEntry {
|
||||
id: row.get(0)?,
|
||||
clip_id: row.get(1)?,
|
||||
provider: row.get(2)?,
|
||||
status: row.get(3)?,
|
||||
url: row.get(4)?,
|
||||
error: row.get(5)?,
|
||||
attempted_at: millis_to_system_time(row.get(6)?),
|
||||
})
|
||||
})?;
|
||||
|
||||
rows.collect()
|
||||
}
|
||||
|
||||
fn column_exists(&self, table: &str, column: &str) -> rusqlite::Result<bool> {
|
||||
let mut statement = self
|
||||
.connection
|
||||
@@ -256,12 +319,89 @@ fn millis_to_system_time(millis: i64) -> SystemTime {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trips_clip_records() {
|
||||
let db_path = std::env::temp_dir().join(format!(
|
||||
"clipforge-db-{}.sqlite",
|
||||
fn temp_database_path(name: &str) -> PathBuf {
|
||||
let path = std::env::temp_dir().join(format!(
|
||||
"clipforge-db-{name}-{}.sqlite",
|
||||
system_time_to_millis(SystemTime::now())
|
||||
));
|
||||
let _ = std::fs::remove_file(&path);
|
||||
path
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fresh_database_walks_to_current_version() {
|
||||
let db_path = temp_database_path("fresh");
|
||||
let database = ClipDatabase::open(&db_path).expect("database");
|
||||
assert_eq!(database.user_version().expect("version"), CURRENT_SCHEMA_VERSION);
|
||||
database.connection.execute("SELECT 1 FROM upload_history", []).expect("v2 table exists");
|
||||
let _ = std::fs::remove_file(db_path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opening_is_idempotent_and_does_not_downgrade() {
|
||||
let db_path = temp_database_path("idempotent");
|
||||
let first = ClipDatabase::open(&db_path).expect("database");
|
||||
let second = ClipDatabase::open(&db_path).expect("database re-open");
|
||||
assert_eq!(
|
||||
first.user_version().expect("version"),
|
||||
CURRENT_SCHEMA_VERSION
|
||||
);
|
||||
assert_eq!(
|
||||
second.user_version().expect("version"),
|
||||
CURRENT_SCHEMA_VERSION
|
||||
);
|
||||
let _ = std::fs::remove_file(db_path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_database_is_repaired_and_upgraded() {
|
||||
let db_path = temp_database_path("legacy");
|
||||
{
|
||||
let connection = Connection::open(&db_path).expect("raw connection");
|
||||
connection
|
||||
.execute_batch(
|
||||
"
|
||||
CREATE TABLE clips (
|
||||
id TEXT PRIMARY KEY NOT NULL,
|
||||
session_id TEXT NOT NULL,
|
||||
game_id TEXT NOT NULL,
|
||||
path TEXT NOT NULL,
|
||||
thumbnail_path TEXT,
|
||||
created_at_ms INTEGER NOT NULL,
|
||||
duration_ms INTEGER NOT NULL,
|
||||
source TEXT NOT NULL,
|
||||
event_type TEXT,
|
||||
tags_json TEXT NOT NULL,
|
||||
upload_url TEXT,
|
||||
upload_provider TEXT
|
||||
);
|
||||
",
|
||||
)
|
||||
.expect("legacy clips table");
|
||||
connection
|
||||
.pragma_update(None, "user_version", 0)
|
||||
.expect("version 0");
|
||||
}
|
||||
let database = ClipDatabase::open(&db_path).expect("open with repair");
|
||||
assert_eq!(database.user_version().expect("version"), CURRENT_SCHEMA_VERSION);
|
||||
assert!(database.column_exists("clips", "title").expect("column lookup"));
|
||||
assert!(database.column_exists("clips", "id").expect("column lookup"));
|
||||
database
|
||||
.insert_upload_history(
|
||||
"clip-old",
|
||||
"catbox",
|
||||
"uploaded",
|
||||
Some("https://example.test/old.mp4"),
|
||||
None,
|
||||
SystemTime::now(),
|
||||
)
|
||||
.expect("v2 table usable");
|
||||
let _ = std::fs::remove_file(db_path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn round_trips_clip_records() {
|
||||
let db_path = temp_database_path("roundtrip");
|
||||
let database = ClipDatabase::open(&db_path).expect("database");
|
||||
let clip = Clip {
|
||||
id: "clip-1".to_string(),
|
||||
@@ -293,8 +433,52 @@ mod tests {
|
||||
SystemTime::now(),
|
||||
)
|
||||
.expect("upload history");
|
||||
let history = database.load_upload_history().expect("load upload history");
|
||||
assert_eq!(history.len(), 1);
|
||||
assert_eq!(history[0].clip_id, "clip-1");
|
||||
database.delete_clip("clip-1").expect("delete");
|
||||
assert!(database.load_clips().expect("load empty").is_empty());
|
||||
let _ = std::fs::remove_file(db_path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rewrites_stored_paths_to_new_library_root() {
|
||||
let db_path = temp_database_path("rewrite");
|
||||
let database = ClipDatabase::open(&db_path).expect("database");
|
||||
let clip = Clip {
|
||||
id: "clip-1".to_string(),
|
||||
title: None,
|
||||
session_id: "session-1".to_string(),
|
||||
game_id: "counter-strike-2".to_string(),
|
||||
path: PathBuf::from("C:/Old/ClipForge/clips/counter-strike-2/2026-09/clip-1.mp4"),
|
||||
thumbnail_path: Some(PathBuf::from(
|
||||
"C:/Old/ClipForge/thumbs/clip-1.jpg",
|
||||
)),
|
||||
created_at: UNIX_EPOCH + Duration::from_secs(10),
|
||||
duration: Duration::from_secs(60),
|
||||
source: ClipSource::ManualHotkey,
|
||||
event_type: None,
|
||||
tags: Vec::new(),
|
||||
upload_url: None,
|
||||
upload_provider: None,
|
||||
};
|
||||
database.upsert_clip(&clip).expect("upsert");
|
||||
|
||||
let updated = database
|
||||
.rewrite_path_prefix("C:/Old/ClipForge", "C:/Users/alvin/Documents/ClipForge")
|
||||
.expect("rewrite");
|
||||
assert_eq!(updated, 1);
|
||||
|
||||
let loaded = database.load_clips().expect("load");
|
||||
assert_eq!(loaded.len(), 1);
|
||||
assert_eq!(
|
||||
loaded[0].path,
|
||||
PathBuf::from("C:/Users/alvin/Documents/ClipForge/clips/counter-strike-2/2026-09/clip-1.mp4")
|
||||
);
|
||||
assert_eq!(
|
||||
loaded[0].thumbnail_path.as_deref(),
|
||||
Some(Path::new("C:/Users/alvin/Documents/ClipForge/thumbs/clip-1.jpg"))
|
||||
);
|
||||
let _ = std::fs::remove_file(db_path);
|
||||
}
|
||||
}
|
||||
@@ -170,6 +170,8 @@ impl GameIntegration for ValveGsiIntegration {
|
||||
GameEventType::RoundWin
|
||||
} else if lower.contains("match_end") {
|
||||
GameEventType::MatchWin
|
||||
} else if lower.contains("match_start") {
|
||||
GameEventType::Bookmark
|
||||
} else if lower.contains("bomb") {
|
||||
GameEventType::Objective
|
||||
} else if lower.contains("mvp") {
|
||||
@@ -194,6 +196,10 @@ pub fn valve_gsi_raw_events(
|
||||
let mut events = Vec::new();
|
||||
|
||||
// Round events
|
||||
let round_number = value
|
||||
.pointer("/map/round")
|
||||
.and_then(Value::as_u64)
|
||||
.unwrap_or_default();
|
||||
if let Some(round_phase) = value
|
||||
.pointer("/round/phase")
|
||||
.and_then(Value::as_str)
|
||||
@@ -206,7 +212,19 @@ pub fn valve_gsi_raw_events(
|
||||
name: "round_win".to_string(),
|
||||
timestamp: now,
|
||||
player: None,
|
||||
metadata: [("win_team".to_string(), win_team.to_string())].into(),
|
||||
metadata: [
|
||||
("win_team".to_string(), win_team.to_string()),
|
||||
("round".to_string(), round_number.to_string()),
|
||||
(
|
||||
"ct_score".to_string(),
|
||||
map_stat_string(&value, "/map/team_ct/score"),
|
||||
),
|
||||
(
|
||||
"t_score".to_string(),
|
||||
map_stat_string(&value, "/map/team_t/score"),
|
||||
),
|
||||
]
|
||||
.into(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -216,11 +234,33 @@ pub fn valve_gsi_raw_events(
|
||||
name: "round_start".to_string(),
|
||||
timestamp: now,
|
||||
player: None,
|
||||
metadata: BTreeMap::new(),
|
||||
metadata: [("round".to_string(), round_number.to_string())].into(),
|
||||
});
|
||||
}
|
||||
"live" => {
|
||||
// Round is live, could track bomb events
|
||||
// Round is live, could track bomb events. A fresh match is live on round 1.
|
||||
if round_number == 1 {
|
||||
events.push(RawGameEvent {
|
||||
event_id: format!("match_start:{}", millis(now)),
|
||||
name: "match_start".to_string(),
|
||||
timestamp: now,
|
||||
player: value
|
||||
.pointer("/player/name")
|
||||
.and_then(Value::as_str)
|
||||
.map(ToString::to_string),
|
||||
metadata: [
|
||||
(
|
||||
"map".to_string(),
|
||||
map_stat_string(&value, "/map/name"),
|
||||
),
|
||||
(
|
||||
"mode".to_string(),
|
||||
map_stat_string(&value, "/map/mode"),
|
||||
),
|
||||
]
|
||||
.into(),
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -228,6 +268,15 @@ pub fn valve_gsi_raw_events(
|
||||
|
||||
// Bomb events (CS2)
|
||||
if let Some(bomb_state) = value.pointer("/round/bomb").and_then(Value::as_str) {
|
||||
let bomb_region = map_stat_string(&value, "/map/region");
|
||||
let bomb_metadata = |region: String| {
|
||||
let mut metadata = BTreeMap::new();
|
||||
metadata.insert("round".to_string(), round_number.to_string());
|
||||
if !region.is_empty() {
|
||||
metadata.insert("region".to_string(), region);
|
||||
}
|
||||
metadata
|
||||
};
|
||||
match bomb_state {
|
||||
"planted" => {
|
||||
events.push(RawGameEvent {
|
||||
@@ -238,7 +287,7 @@ pub fn valve_gsi_raw_events(
|
||||
.pointer("/player/name")
|
||||
.and_then(Value::as_str)
|
||||
.map(ToString::to_string),
|
||||
metadata: BTreeMap::new(),
|
||||
metadata: bomb_metadata(bomb_region),
|
||||
});
|
||||
}
|
||||
"defused" => {
|
||||
@@ -250,7 +299,7 @@ pub fn valve_gsi_raw_events(
|
||||
.pointer("/player/name")
|
||||
.and_then(Value::as_str)
|
||||
.map(ToString::to_string),
|
||||
metadata: BTreeMap::new(),
|
||||
metadata: bomb_metadata(bomb_region),
|
||||
});
|
||||
}
|
||||
"exploded" => {
|
||||
@@ -259,7 +308,7 @@ pub fn valve_gsi_raw_events(
|
||||
name: "bomb_exploded".to_string(),
|
||||
timestamp: now,
|
||||
player: None,
|
||||
metadata: BTreeMap::new(),
|
||||
metadata: bomb_metadata(bomb_region),
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
@@ -344,6 +393,54 @@ pub fn valve_gsi_raw_events(
|
||||
}
|
||||
}
|
||||
|
||||
// Dota 2 game-state transitions (GSI posts a periodic snapshot; the auto-clip merge
|
||||
// window collapses repeated posts into a single event)
|
||||
if let Some(game_state) = value.pointer("/map/game_state").and_then(Value::as_str) {
|
||||
let game_time = value
|
||||
.pointer("/map/game_time")
|
||||
.and_then(Value::as_u64)
|
||||
.unwrap_or_default();
|
||||
match game_state {
|
||||
"DOTA_GAMERULES_STATE_GAME_IN_PROGRESS" if game_time < 10 => {
|
||||
events.push(RawGameEvent {
|
||||
event_id: format!("dota_match_start:{}", millis(now)),
|
||||
name: "match_start".to_string(),
|
||||
timestamp: now,
|
||||
player: None,
|
||||
metadata: [
|
||||
("map".to_string(), map_stat_string(&value, "/map/name")),
|
||||
("game_time".to_string(), game_time.to_string()),
|
||||
]
|
||||
.into(),
|
||||
});
|
||||
}
|
||||
"DOTA_GAMERULES_STATE_POST_GAME" => {
|
||||
events.push(RawGameEvent {
|
||||
event_id: format!("dota_match_end:{}", millis(now)),
|
||||
name: "match_end".to_string(),
|
||||
timestamp: now,
|
||||
player: None,
|
||||
metadata: [
|
||||
(
|
||||
"radiant_score".to_string(),
|
||||
map_stat_string(&value, "/map/radiant_score"),
|
||||
),
|
||||
(
|
||||
"dire_score".to_string(),
|
||||
map_stat_string(&value, "/map/dire_score"),
|
||||
),
|
||||
(
|
||||
"win_team".to_string(),
|
||||
map_stat_string(&value, "/map/win_team"),
|
||||
),
|
||||
]
|
||||
.into(),
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
// Match end events
|
||||
if let Some(phase) = value.pointer("/map/phase").and_then(Value::as_str) {
|
||||
if phase == "gameover" {
|
||||
@@ -432,6 +529,18 @@ fn millis(time: SystemTime) -> u128 {
|
||||
.as_millis()
|
||||
}
|
||||
|
||||
fn map_stat_string(value: &Value, pointer: &str) -> String {
|
||||
match value.pointer(pointer) {
|
||||
Some(inner) => inner
|
||||
.as_str()
|
||||
.map(ToString::to_string)
|
||||
.or_else(|| inner.as_u64().map(|n| n.to_string()))
|
||||
.or_else(|| inner.as_i64().map(|n| n.to_string()))
|
||||
.unwrap_or_default(),
|
||||
None => String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -486,4 +595,157 @@ mod tests {
|
||||
assert_eq!(events[0].name, "triple_kill");
|
||||
assert_eq!(events[0].player.as_deref(), Some("Alvin"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_valve_gsi_round_metadata_and_match_start() {
|
||||
let body = r#"{
|
||||
"round": {"phase": "over", "win_team": "CT"},
|
||||
"map": {
|
||||
"round": 5,
|
||||
"phase": "live",
|
||||
"name": "de_mirage",
|
||||
"mode": "competitive",
|
||||
"team_ct": {"score": 3},
|
||||
"team_t": {"score": 2}
|
||||
}
|
||||
}"#;
|
||||
|
||||
let events = valve_gsi_raw_events(body, SystemTime::UNIX_EPOCH).expect("events");
|
||||
|
||||
let round_win = events
|
||||
.iter()
|
||||
.find(|event| event.name == "round_win")
|
||||
.expect("round win event");
|
||||
assert_eq!(round_win.metadata.get("win_team").map(String::as_str), Some("CT"));
|
||||
assert_eq!(round_win.metadata.get("round").map(String::as_str), Some("5"));
|
||||
assert_eq!(
|
||||
round_win.metadata.get("ct_score").map(String::as_str),
|
||||
Some("3")
|
||||
);
|
||||
assert_eq!(
|
||||
round_win.metadata.get("t_score").map(String::as_str),
|
||||
Some("2")
|
||||
);
|
||||
assert!(!events.iter().any(|event| event.name == "match_start"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_valve_gsi_match_start_on_fresh_live_round() {
|
||||
let body = r#"{
|
||||
"round": {"phase": "live"},
|
||||
"map": {"round": 1, "phase": "live", "name": "de_inferno", "mode": "casual"},
|
||||
"player": {"name": "Alvin"}
|
||||
}"#;
|
||||
|
||||
let events = valve_gsi_raw_events(body, SystemTime::UNIX_EPOCH).expect("events");
|
||||
|
||||
let match_start = events
|
||||
.iter()
|
||||
.find(|event| event.name == "match_start")
|
||||
.expect("match start event");
|
||||
assert_eq!(match_start.player.as_deref(), Some("Alvin"));
|
||||
assert_eq!(
|
||||
match_start.metadata.get("map").map(String::as_str),
|
||||
Some("de_inferno")
|
||||
);
|
||||
assert_eq!(
|
||||
match_start.metadata.get("mode").map(String::as_str),
|
||||
Some("casual")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_valve_gsi_bomb_plant_region() {
|
||||
let body = r#"{
|
||||
"round": {"phase": "live", "bomb": "planted"},
|
||||
"map": {"round": 2, "region": "b"},
|
||||
"player": {"name": "Alvin"}
|
||||
}"#;
|
||||
|
||||
let events = valve_gsi_raw_events(body, SystemTime::UNIX_EPOCH).expect("events");
|
||||
|
||||
let bomb = events
|
||||
.iter()
|
||||
.find(|event| event.name == "bomb_planted")
|
||||
.expect("bomb planted event");
|
||||
assert_eq!(bomb.player.as_deref(), Some("Alvin"));
|
||||
assert_eq!(
|
||||
bomb.metadata.get("region").map(String::as_str),
|
||||
Some("b")
|
||||
);
|
||||
assert_eq!(bomb.metadata.get("round").map(String::as_str), Some("2"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_dota2_match_end_with_score_metadata() {
|
||||
let body = r#"{
|
||||
"map": {
|
||||
"game_state": "DOTA_GAMERULES_STATE_POST_GAME",
|
||||
"game_time": 2543,
|
||||
"name": "dota",
|
||||
"radiant_score": 28,
|
||||
"dire_score": 14,
|
||||
"win_team": "radiant"
|
||||
}
|
||||
}"#;
|
||||
|
||||
let events = valve_gsi_raw_events(body, SystemTime::UNIX_EPOCH).expect("events");
|
||||
|
||||
let match_end = events
|
||||
.iter()
|
||||
.find(|event| event.name == "match_end")
|
||||
.expect("match_end event");
|
||||
assert_eq!(
|
||||
match_end.metadata.get("radiant_score").map(String::as_str),
|
||||
Some("28")
|
||||
);
|
||||
assert_eq!(
|
||||
match_end.metadata.get("dire_score").map(String::as_str),
|
||||
Some("14")
|
||||
);
|
||||
assert_eq!(
|
||||
match_end.metadata.get("win_team").map(String::as_str),
|
||||
Some("radiant")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_dota2_match_start_on_game_in_progress() {
|
||||
let body = r#"{
|
||||
"map": {
|
||||
"game_state": "DOTA_GAMERULES_STATE_GAME_IN_PROGRESS",
|
||||
"game_time": 4,
|
||||
"name": "dota"
|
||||
}
|
||||
}"#;
|
||||
|
||||
let events = valve_gsi_raw_events(body, SystemTime::UNIX_EPOCH).expect("events");
|
||||
|
||||
let start = events
|
||||
.iter()
|
||||
.find(|event| event.name == "match_start")
|
||||
.expect("match_start event");
|
||||
assert_eq!(
|
||||
start.metadata.get("map").map(String::as_str),
|
||||
Some("dota")
|
||||
);
|
||||
assert_eq!(
|
||||
start.metadata.get("game_time").map(String::as_str),
|
||||
Some("4")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dota2_ignores_match_start_after_initial_snapshot() {
|
||||
let body = r#"{
|
||||
"map": {
|
||||
"game_state": "DOTA_GAMERULES_STATE_GAME_IN_PROGRESS",
|
||||
"game_time": 30
|
||||
}
|
||||
}"#;
|
||||
|
||||
let events = valve_gsi_raw_events(body, SystemTime::UNIX_EPOCH).expect("events");
|
||||
|
||||
assert!(!events.iter().any(|event| event.name == "match_start"));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
pub mod screenshot;
|
||||
pub mod audio;
|
||||
pub mod capture;
|
||||
pub mod crashlog;
|
||||
pub mod database;
|
||||
pub mod game_detection;
|
||||
pub mod ram_buffer;
|
||||
pub mod game_watcher;
|
||||
pub mod gsi_config;
|
||||
pub mod hotkeys;
|
||||
@@ -12,9 +15,11 @@ pub mod media;
|
||||
pub mod models;
|
||||
pub mod native_audio;
|
||||
pub mod native_wgc;
|
||||
pub mod proc;
|
||||
pub mod recorder;
|
||||
pub mod settings;
|
||||
pub mod storage;
|
||||
pub mod updater;
|
||||
pub mod upload;
|
||||
|
||||
pub use models::{Clip, ClipSource, GameEvent, GameEventType, RecordingStatus, UploadProvider};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::proc::hidden_command;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -96,7 +96,7 @@ pub fn concat_segments(
|
||||
}
|
||||
fs::write(&list_path, list)?;
|
||||
|
||||
let status = Command::new(ffmpeg)
|
||||
let status = hidden_command(ffmpeg)
|
||||
.args([
|
||||
"-y",
|
||||
"-hide_banner",
|
||||
@@ -137,7 +137,7 @@ pub fn trim_clip(
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
|
||||
let status = Command::new(ffmpeg)
|
||||
let status = hidden_command(ffmpeg)
|
||||
.args([
|
||||
"-y",
|
||||
"-hide_banner",
|
||||
@@ -168,7 +168,7 @@ pub fn generate_thumbnail(ffmpeg: &Path, input: &Path, output: &Path) -> Result<
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
|
||||
let status = Command::new(ffmpeg)
|
||||
let status = hidden_command(ffmpeg)
|
||||
.args([
|
||||
"-y",
|
||||
"-hide_banner",
|
||||
|
||||
@@ -111,6 +111,17 @@ pub struct Clip {
|
||||
pub upload_provider: Option<UploadProvider>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct UploadHistoryEntry {
|
||||
pub id: i64,
|
||||
pub clip_id: String,
|
||||
pub provider: String,
|
||||
pub status: String,
|
||||
pub url: Option<String>,
|
||||
pub error: Option<String>,
|
||||
pub attempted_at: SystemTime,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum RecordingStatus {
|
||||
WaitingForGame,
|
||||
|
||||
@@ -1,6 +1,33 @@
|
||||
use crate::capture::{CaptureBackend, CaptureConfig, CaptureError};
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub(crate) fn downscale_to_cap(
|
||||
width: u32,
|
||||
height: u32,
|
||||
cap_width: u32,
|
||||
cap_height: u32,
|
||||
) -> (u32, u32) {
|
||||
if width == 0 || height == 0 || cap_width == 0 || cap_height == 0 {
|
||||
return (even_capped_dimension(width, cap_width), even_capped_dimension(height, cap_height));
|
||||
}
|
||||
let scale = (cap_width as f32 / width as f32).min(cap_height as f32 / height as f32);
|
||||
if scale >= 1.0 {
|
||||
return (
|
||||
even_capped_dimension(width, cap_width),
|
||||
even_capped_dimension(height, cap_height),
|
||||
);
|
||||
}
|
||||
(
|
||||
even_capped_dimension((width as f32 * scale).round() as u32, cap_width),
|
||||
even_capped_dimension((height as f32 * scale).round() as u32, cap_height),
|
||||
)
|
||||
}
|
||||
|
||||
fn even_capped_dimension(value: u32, cap: u32) -> u32 {
|
||||
let value = value.min(cap).max(2);
|
||||
value - (value % 2)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
mod windows_impl {
|
||||
use super::*;
|
||||
@@ -488,10 +515,6 @@ mod windows_impl {
|
||||
}
|
||||
}
|
||||
|
||||
fn even_dimension(value: u32) -> u32 {
|
||||
value.saturating_sub(value % 2).max(2)
|
||||
}
|
||||
|
||||
fn find_window_for_source(
|
||||
source: &crate::capture::CaptureSource,
|
||||
) -> Result<Option<Window>, HandlerError> {
|
||||
@@ -526,25 +549,24 @@ mod windows_impl {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn window_size(window: Window, fallback_width: u32, fallback_height: u32) -> (u32, u32) {
|
||||
fn window_size(window: Window, cap_width: u32, cap_height: u32) -> (u32, u32) {
|
||||
let width = window
|
||||
.width()
|
||||
.ok()
|
||||
.and_then(|value| u32::try_from(value.max(0)).ok())
|
||||
.unwrap_or(fallback_width);
|
||||
.unwrap_or(cap_width);
|
||||
let height = window
|
||||
.height()
|
||||
.ok()
|
||||
.and_then(|value| u32::try_from(value.max(0)).ok())
|
||||
.unwrap_or(fallback_height);
|
||||
(even_dimension(width), even_dimension(height))
|
||||
.unwrap_or(cap_height);
|
||||
downscale_to_cap(width, height, cap_width, cap_height)
|
||||
}
|
||||
|
||||
fn monitor_size(monitor: Monitor, fallback_width: u32, fallback_height: u32) -> (u32, u32) {
|
||||
(
|
||||
even_dimension(monitor.width().unwrap_or(fallback_width)),
|
||||
even_dimension(monitor.height().unwrap_or(fallback_height)),
|
||||
)
|
||||
fn monitor_size(monitor: Monitor, cap_width: u32, cap_height: u32) -> (u32, u32) {
|
||||
let width = monitor.width().unwrap_or(cap_width);
|
||||
let height = monitor.height().unwrap_or(cap_height);
|
||||
downscale_to_cap(width, height, cap_width, cap_height)
|
||||
}
|
||||
|
||||
fn recording_settings<T: TryInto<GraphicsCaptureItemType> + Send + 'static>(
|
||||
@@ -669,6 +691,34 @@ impl CaptureBackend for NativeWgcReplayCaptureBackend {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod downscale_tests {
|
||||
use super::downscale_to_cap;
|
||||
|
||||
#[test]
|
||||
fn keeps_resolution_at_or_below_the_cap() {
|
||||
assert_eq!(downscale_to_cap(2560, 1440, 1280, 720), (1280, 720));
|
||||
assert_eq!(downscale_to_cap(1920, 1080, 1280, 720), (1280, 720));
|
||||
assert_eq!(downscale_to_cap(3840, 2160, 1920, 1080), (1920, 1080));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leaves_smaller_sources_unchanged() {
|
||||
assert_eq!(downscale_to_cap(800, 600, 1280, 720), (800, 600));
|
||||
assert_eq!(downscale_to_cap(1280, 720, 1280, 720), (1280, 720));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preserves_aspect_ratio_and_even_dimensions_when_downscaling() {
|
||||
let (width, height) = downscale_to_cap(2000, 1000, 1000, 600);
|
||||
assert_eq!(width % 2, 0);
|
||||
assert_eq!(height % 2, 0);
|
||||
assert!(width <= 1000);
|
||||
assert!(height <= 600);
|
||||
assert_eq!(width as f32 / height as f32, 2000.0 / 1000.0);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, target_os = "windows"))]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
/// Builds a `Command` that never shows a console window on Windows. FFmpeg and other
|
||||
/// console subprocesses otherwise flash a terminal window each time they start from a
|
||||
/// GUI (Tauri) process, which looks like the app constantly opening and closing.
|
||||
pub fn hidden_command(program: impl AsRef<Path>) -> Command {
|
||||
let mut command = Command::new(program.as_ref());
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::process::CommandExt;
|
||||
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
||||
command.creation_flags(CREATE_NO_WINDOW);
|
||||
}
|
||||
command
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
/// One finished replay segment held entirely in memory. Encoders write to a
|
||||
/// file path, so a background worker moves each completed segment from disk
|
||||
/// into RAM (and removes the on-disk copy) right after it is finalized.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RamSegment {
|
||||
pub file_name: String,
|
||||
pub modified_at: SystemTime,
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct RamReplayBuffer {
|
||||
segments: Vec<RamSegment>,
|
||||
}
|
||||
|
||||
/// Hard ceiling so the in-memory replay buffer can never exhaust the
|
||||
/// machine's RAM, even if the replay window grows well beyond the default.
|
||||
pub const DEFAULT_RAM_CAP_BYTES: usize = 512 * 1024 * 1024;
|
||||
|
||||
impl RamReplayBuffer {
|
||||
pub fn insert(&mut self, file_name: String, modified_at: SystemTime, data: Vec<u8>) {
|
||||
self.segments.retain(|segment| segment.file_name != file_name);
|
||||
self.segments.push(RamSegment {
|
||||
file_name,
|
||||
modified_at,
|
||||
data,
|
||||
});
|
||||
self.segments
|
||||
.sort_by(|left, right| left.modified_at.cmp(&right.modified_at));
|
||||
}
|
||||
|
||||
pub fn contains(&self, file_name: &str) -> bool {
|
||||
self.segments
|
||||
.iter()
|
||||
.any(|segment| segment.file_name == file_name)
|
||||
}
|
||||
|
||||
/// Keeps only segments younger than the replay window plus one segment of
|
||||
/// slack, mirroring the disk-side policy in `prune_old_segments`.
|
||||
pub fn prune_to_window(
|
||||
&mut self,
|
||||
window: Duration,
|
||||
segment_duration: Duration,
|
||||
now: SystemTime,
|
||||
) {
|
||||
let cutoff = now
|
||||
.checked_sub(window + segment_duration)
|
||||
.unwrap_or(SystemTime::UNIX_EPOCH);
|
||||
self.segments.retain(|segment| segment.modified_at >= cutoff);
|
||||
}
|
||||
|
||||
/// Safety net: drops the oldest segments until the retained bytes fit
|
||||
/// under `cap`. Independent of the configured replay window.
|
||||
pub fn cap_bytes(&mut self, cap: usize) {
|
||||
let mut total: usize = self.segments.iter().map(|segment| segment.data.len()).sum();
|
||||
while total > cap {
|
||||
let Some(oldest) = self.segments.first() else {
|
||||
break;
|
||||
};
|
||||
total = total.saturating_sub(oldest.data.len());
|
||||
self.segments.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.segments.clear();
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.segments.is_empty()
|
||||
}
|
||||
|
||||
pub fn buffered_bytes(&self) -> usize {
|
||||
self.segments.iter().map(|segment| segment.data.len()).sum()
|
||||
}
|
||||
}
|
||||
|
||||
/// A save candidate that may live either on disk (not yet ingested into RAM)
|
||||
/// or strictly in RAM.
|
||||
#[derive(Debug)]
|
||||
pub struct MergedSegment {
|
||||
pub modified_at: SystemTime,
|
||||
pub file_name: String,
|
||||
pub on_disk: Option<PathBuf>,
|
||||
pub in_ram: Option<RamSegment>,
|
||||
}
|
||||
|
||||
/// Merges the rolling segments for a save operation: everything still on disk
|
||||
/// plus everything held in RAM, deduplicated by file name (a segment is either
|
||||
/// on disk or already ingested), and sorted oldest-first. When `window` is
|
||||
/// provided only segments inside the window are kept; `None` selects the whole
|
||||
/// buffer (used when finishing a session recording).
|
||||
pub fn merged_segments(
|
||||
ram: &RamReplayBuffer,
|
||||
buffer_dir: &Path,
|
||||
window: Option<Duration>,
|
||||
segment_duration: Duration,
|
||||
now: SystemTime,
|
||||
) -> io::Result<Vec<MergedSegment>> {
|
||||
let cutoff = match window {
|
||||
Some(window) => now
|
||||
.checked_sub(window + segment_duration)
|
||||
.unwrap_or(SystemTime::UNIX_EPOCH),
|
||||
None => SystemTime::UNIX_EPOCH,
|
||||
};
|
||||
|
||||
let mut merged: Vec<MergedSegment> = collect_disk_segments(buffer_dir)?
|
||||
.into_iter()
|
||||
.filter(|segment| segment.modified_at >= cutoff)
|
||||
.map(|segment| MergedSegment {
|
||||
modified_at: segment.modified_at,
|
||||
file_name: segment.file_name,
|
||||
on_disk: Some(segment.path),
|
||||
in_ram: None,
|
||||
})
|
||||
.collect();
|
||||
|
||||
for ram_segment in ram
|
||||
.segments
|
||||
.iter()
|
||||
.filter(|segment| segment.modified_at >= cutoff)
|
||||
{
|
||||
if let Some(disk) = merged
|
||||
.iter_mut()
|
||||
.find(|candidate| candidate.file_name == ram_segment.file_name)
|
||||
{
|
||||
disk.in_ram = Some(ram_segment.clone());
|
||||
} else {
|
||||
merged.push(MergedSegment {
|
||||
modified_at: ram_segment.modified_at,
|
||||
file_name: ram_segment.file_name.clone(),
|
||||
on_disk: None,
|
||||
in_ram: Some(ram_segment.clone()),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
merged.sort_by(|left, right| left.modified_at.cmp(&right.modified_at));
|
||||
Ok(merged)
|
||||
}
|
||||
|
||||
/// Materializes RAM-held segments into real files inside `staging_dir` so that
|
||||
/// FFmpeg can concatenate them, and returns the ordered list of paths covering
|
||||
/// the whole merge (disk files are used in place, never copied).
|
||||
pub fn spool_merged(
|
||||
staging_dir: &Path,
|
||||
prefix: &str,
|
||||
merged: &[MergedSegment],
|
||||
) -> io::Result<Vec<PathBuf>> {
|
||||
if merged.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
fs::create_dir_all(staging_dir)?;
|
||||
let mut paths = Vec::with_capacity(merged.len());
|
||||
for (index, segment) in merged.iter().enumerate() {
|
||||
if let Some(path) = &segment.on_disk {
|
||||
paths.push(path.clone());
|
||||
} else if let Some(segment) = &segment.in_ram {
|
||||
let staged = staging_dir.join(format!(
|
||||
"{prefix}-{index:04}-{}",
|
||||
sanitize_file_name(&segment.file_name)
|
||||
));
|
||||
fs::write(&staged, &segment.data)?;
|
||||
paths.push(staged);
|
||||
}
|
||||
}
|
||||
Ok(paths)
|
||||
}
|
||||
|
||||
fn sanitize_file_name(name: &str) -> String {
|
||||
name.chars()
|
||||
.map(|character| {
|
||||
if character.is_ascii_alphanumeric() || matches!(character, '-' | '_' | '.') {
|
||||
character
|
||||
} else {
|
||||
'_'
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Lists `.mp4` files directly inside a buffer directory (current session only).
|
||||
pub fn collect_disk_segments(buffer_dir: &Path) -> io::Result<Vec<DiskSegmentFile>> {
|
||||
let mut segments = Vec::new();
|
||||
if !buffer_dir.exists() {
|
||||
return Ok(segments);
|
||||
}
|
||||
for entry in fs::read_dir(buffer_dir)? {
|
||||
let entry = entry?;
|
||||
let path = entry.path();
|
||||
if path.extension().and_then(|value| value.to_str()) != Some("mp4") {
|
||||
continue;
|
||||
}
|
||||
let file_name = entry.file_name().to_string_lossy().into_owned();
|
||||
let modified_at = entry.metadata()?.modified().unwrap_or(SystemTime::UNIX_EPOCH);
|
||||
segments.push(DiskSegmentFile {
|
||||
file_name,
|
||||
path,
|
||||
modified_at,
|
||||
});
|
||||
}
|
||||
segments.sort_by(|left, right| left.modified_at.cmp(&right.modified_at));
|
||||
Ok(segments)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct DiskSegmentFile {
|
||||
pub file_name: String,
|
||||
pub path: PathBuf,
|
||||
pub modified_at: SystemTime,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn segment(file_name: &str, age: u64, now: SystemTime) -> RamSegment {
|
||||
RamSegment {
|
||||
file_name: file_name.to_string(),
|
||||
modified_at: now - Duration::from_secs(age),
|
||||
data: file_name.as_bytes().to_vec(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn window_prune_drops_only_stale_segments() {
|
||||
let now = SystemTime::now();
|
||||
let mut ram = RamReplayBuffer::default();
|
||||
ram.insert("a.mp4".to_string(), now - Duration::from_secs(60), vec![1]);
|
||||
ram.insert("b.mp4".to_string(), now - Duration::from_secs(20), vec![2]);
|
||||
ram.insert("c.mp4".to_string(), now - Duration::from_secs(2), vec![3]);
|
||||
|
||||
ram.prune_to_window(Duration::from_secs(30), Duration::from_secs(5), now);
|
||||
|
||||
let remaining: Vec<&str> = ram
|
||||
.segments
|
||||
.iter()
|
||||
.map(|segment| segment.file_name.as_str())
|
||||
.collect();
|
||||
assert_eq!(remaining, vec!["b.mp4", "c.mp4"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn byte_cap_frees_oldest_first() {
|
||||
let now = SystemTime::now();
|
||||
let mut ram = RamReplayBuffer::default();
|
||||
ram.insert("a.mp4".to_string(), now - Duration::from_secs(30), vec![0; 100]);
|
||||
ram.insert("b.mp4".to_string(), now - Duration::from_secs(20), vec![0; 100]);
|
||||
ram.insert("c.mp4".to_string(), now - Duration::from_secs(10), vec![0; 100]);
|
||||
|
||||
ram.cap_bytes(250);
|
||||
|
||||
let first = ram.segments.first().map(|segment| segment.file_name.as_str());
|
||||
assert_eq!(first, Some("b.mp4"));
|
||||
assert_eq!(ram.buffered_bytes(), 200);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn merge_prefers_disk_copy_and_is_sorted() {
|
||||
let root = std::env::temp_dir().join(format!(
|
||||
"clipforge-ram-{}",
|
||||
crate::media::timestamp_millis(SystemTime::now())
|
||||
));
|
||||
fs::create_dir_all(&root).expect("test root");
|
||||
let now = SystemTime::now();
|
||||
fs::write(root.join("disk.mp4"), b"disk").expect("disk file");
|
||||
// The disk file's real mtime is essentially "now", so it sorts after
|
||||
// the RAM-held segment that claims to be 6 seconds old.
|
||||
let disk_modified_at = fs::metadata(root.join("disk.mp4"))
|
||||
.expect("disk metadata")
|
||||
.modified()
|
||||
.expect("disk modified");
|
||||
|
||||
let mut ram = RamReplayBuffer::default();
|
||||
ram.insert(
|
||||
"disk.mp4".to_string(),
|
||||
now - Duration::from_secs(10),
|
||||
b"ram-copy".to_vec(),
|
||||
);
|
||||
ram.insert(
|
||||
"ram-only.mp4".to_string(),
|
||||
now - Duration::from_secs(6),
|
||||
b"ram-only".to_vec(),
|
||||
);
|
||||
ram.insert(
|
||||
"old.mp4".to_string(),
|
||||
now - Duration::from_secs(120),
|
||||
b"old".to_vec(),
|
||||
);
|
||||
|
||||
let merged = merged_segments(
|
||||
&ram,
|
||||
&root,
|
||||
Some(Duration::from_secs(60)),
|
||||
Duration::from_secs(5),
|
||||
now,
|
||||
)
|
||||
.expect("merge");
|
||||
|
||||
let file_names: Vec<String> = merged
|
||||
.iter()
|
||||
.map(|segment| segment.file_name.clone())
|
||||
.collect();
|
||||
// Sorted oldest-first: ram-only (6s old) before the just-written disk.mp4.
|
||||
assert_eq!(file_names, vec!["ram-only.mp4", "disk.mp4"]);
|
||||
// The disk file wins over the identical RAM copy.
|
||||
let disk_merge = &merged[1];
|
||||
assert!(disk_merge.on_disk.is_some());
|
||||
assert_eq!(
|
||||
disk_merge.on_disk.as_ref().unwrap().file_name().unwrap().to_str(),
|
||||
Some("disk.mp4")
|
||||
);
|
||||
assert!(disk_merge.modified_at >= disk_modified_at);
|
||||
|
||||
let spool = root.join("staging");
|
||||
let paths = spool_merged(&spool, "clip", &merged).expect("spool");
|
||||
assert_eq!(paths.len(), 2);
|
||||
let _ = fs::remove_dir_all(root);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
use crate::capture::{CaptureConfig, CaptureError, CaptureMethod, CaptureSource, EncoderPreference};
|
||||
use crate::proc::hidden_command;
|
||||
use dirs;
|
||||
use std::path::PathBuf;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
impl Default for ScreenshotCapture {
|
||||
fn default() -> Self {
|
||||
let output_dir = default_screenshot_dir();
|
||||
Self {
|
||||
executable: default_ffmpeg_executable(),
|
||||
output_dir,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_ffmpeg_executable() -> PathBuf {
|
||||
let bundled = std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|path| path.parent().map(|parent| parent.to_path_buf()))
|
||||
.map(|parent| parent.join("ffmpeg-x86_64-pc-windows-msvc.exe"));
|
||||
if let Some(path) = bundled {
|
||||
if path.exists() {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
PathBuf::from("ffmpeg")
|
||||
}
|
||||
|
||||
fn default_screenshot_dir() -> PathBuf {
|
||||
let home = dirs::home_dir().unwrap_or_else(|| PathBuf::from("."));
|
||||
home.join("Pictures").join("ClipForge")
|
||||
}
|
||||
|
||||
pub fn screenshot_dir() -> PathBuf {
|
||||
default_screenshot_dir()
|
||||
}
|
||||
|
||||
pub fn list_screenshots() -> Vec<PathBuf> {
|
||||
let dir = default_screenshot_dir();
|
||||
let Ok(entries) = std::fs::read_dir(&dir) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let mut screenshots = entries
|
||||
.flatten()
|
||||
.map(|entry| entry.path())
|
||||
.filter(|path| {
|
||||
path.is_file()
|
||||
&& path
|
||||
.extension()
|
||||
.map(|ext| {
|
||||
ext.eq_ignore_ascii_case("png")
|
||||
|| ext.eq_ignore_ascii_case("jpg")
|
||||
|| ext.eq_ignore_ascii_case("jpeg")
|
||||
})
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
screenshots.sort_by_key(|path| {
|
||||
std::fs::metadata(path)
|
||||
.and_then(|meta| meta.created())
|
||||
.ok()
|
||||
});
|
||||
screenshots
|
||||
}
|
||||
|
||||
pub fn take_screenshot() -> Result<PathBuf, CaptureError> {
|
||||
let capture = ScreenshotCapture::default();
|
||||
let config = CaptureConfig {
|
||||
source: CaptureSource::Desktop,
|
||||
method: CaptureMethod::DesktopDuplication,
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
fps: 30,
|
||||
bitrate_kbps: 6000,
|
||||
encoder: EncoderPreference::HardwareH264,
|
||||
system_audio_enabled: false,
|
||||
mic_enabled: false,
|
||||
system_audio_device: None,
|
||||
mic_device: None,
|
||||
separate_audio_tracks: false,
|
||||
};
|
||||
capture.capture(&config)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ScreenshotCapture {
|
||||
executable: PathBuf,
|
||||
output_dir: PathBuf,
|
||||
}
|
||||
|
||||
impl ScreenshotCapture {
|
||||
pub fn new(executable: impl Into<PathBuf>, output_dir: impl Into<PathBuf>) -> Self {
|
||||
Self {
|
||||
executable: executable.into(),
|
||||
output_dir: output_dir.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn capture(&self, config: &CaptureConfig) -> Result<PathBuf, CaptureError> {
|
||||
let now = SystemTime::now();
|
||||
let timestamp = now.duration_since(UNIX_EPOCH).unwrap_or_default().as_millis();
|
||||
let output_path = self.output_dir.join(format!("screenshot-{}.png", timestamp));
|
||||
|
||||
std::fs::create_dir_all(&self.output_dir).map_err(|e| CaptureError::DeviceUnavailable(e.to_string()))?;
|
||||
|
||||
let size = format!("{}x{}", config.width, config.height);
|
||||
let fps = config.fps.to_string();
|
||||
|
||||
let mut args = vec![
|
||||
"-y".to_string(),
|
||||
"-hide_banner".to_string(),
|
||||
"-loglevel".to_string(),
|
||||
"error".to_string(),
|
||||
];
|
||||
|
||||
match config.method {
|
||||
CaptureMethod::DesktopDuplication => {
|
||||
args.extend([
|
||||
"-f".to_string(),
|
||||
"lavfi".to_string(),
|
||||
"-i".to_string(),
|
||||
format!("ddagrab=framerate={fps}:video_size={size},hwdownload,format=bgra"),
|
||||
]);
|
||||
}
|
||||
CaptureMethod::GdiGrab => {
|
||||
args.extend([
|
||||
"-f".to_string(),
|
||||
"gdigrab".to_string(),
|
||||
"-framerate".to_string(),
|
||||
fps,
|
||||
"-video_size".to_string(),
|
||||
size,
|
||||
"-i".to_string(),
|
||||
"desktop".to_string(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
args.extend([
|
||||
"-vframes".to_string(),
|
||||
"1".to_string(),
|
||||
"-update".to_string(),
|
||||
"1".to_string(),
|
||||
output_path.display().to_string(),
|
||||
]);
|
||||
|
||||
let status = hidden_command(&self.executable)
|
||||
.args(&args)
|
||||
.status()
|
||||
.map_err(|e| CaptureError::DeviceUnavailable(e.to_string()))?;
|
||||
|
||||
if !status.success() {
|
||||
return Err(CaptureError::DeviceUnavailable("FFmpeg screenshot failed".to_string()));
|
||||
}
|
||||
|
||||
Ok(output_path)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::capture::{CaptureMethod, CaptureSource, EncoderPreference};
|
||||
|
||||
#[test]
|
||||
fn test_screenshot_args() {
|
||||
let _config = CaptureConfig {
|
||||
source: CaptureSource::Desktop,
|
||||
method: CaptureMethod::GdiGrab,
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
fps: 30,
|
||||
bitrate_kbps: 6000,
|
||||
encoder: EncoderPreference::HardwareH264,
|
||||
system_audio_enabled: false,
|
||||
mic_enabled: false,
|
||||
system_audio_device: None,
|
||||
mic_device: None,
|
||||
separate_audio_tracks: false,
|
||||
};
|
||||
|
||||
let capture = ScreenshotCapture::new("ffmpeg", "screenshots");
|
||||
assert_eq!(capture.output_dir, PathBuf::from("screenshots"));
|
||||
assert_eq!(capture.executable, PathBuf::from("ffmpeg"));
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,10 @@ pub struct AutoClipSettings {
|
||||
pub pre_roll: Duration,
|
||||
pub post_roll: Duration,
|
||||
pub merge_window: Duration,
|
||||
#[serde(default)]
|
||||
pub enabled_events_by_game: BTreeMap<String, BTreeSet<String>>,
|
||||
#[serde(default)]
|
||||
pub disabled_games: BTreeSet<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -89,6 +92,14 @@ pub struct AppSettings {
|
||||
pub auto_clip: AutoClipSettings,
|
||||
#[serde(default)]
|
||||
pub upload: UploadSettings,
|
||||
#[serde(default)]
|
||||
pub quality_overrides_by_game: BTreeMap<String, QualityPreset>,
|
||||
#[serde(default)]
|
||||
pub onboarding_complete: bool,
|
||||
#[serde(default)]
|
||||
pub minimize_to_tray_enabled: bool,
|
||||
#[serde(default)]
|
||||
pub auto_prune_old_clips: bool,
|
||||
}
|
||||
|
||||
impl AppSettings {
|
||||
@@ -132,11 +143,22 @@ impl AppSettings {
|
||||
post_roll: Duration::from_secs(8),
|
||||
merge_window: Duration::from_secs(12),
|
||||
enabled_events_by_game: BTreeMap::new(),
|
||||
disabled_games: BTreeSet::new(),
|
||||
},
|
||||
upload: UploadSettings::default(),
|
||||
quality_overrides_by_game: BTreeMap::new(),
|
||||
onboarding_complete: false,
|
||||
minimize_to_tray_enabled: false,
|
||||
auto_prune_old_clips: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn effective_quality_for(&self, game_id: &str) -> &QualityPreset {
|
||||
self.quality_overrides_by_game
|
||||
.get(game_id)
|
||||
.unwrap_or(&self.quality)
|
||||
}
|
||||
|
||||
pub fn clamp_replay_buffer(&mut self) {
|
||||
self.replay_buffer = self
|
||||
.replay_buffer
|
||||
@@ -219,6 +241,36 @@ mod tests {
|
||||
let _ = fs::remove_dir_all(root);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn quality_overrides_round_trip_and_apply_per_game() {
|
||||
let root = std::env::temp_dir().join(format!(
|
||||
"clipforge-settings-overrides-{}",
|
||||
SystemTimeCompat::millis()
|
||||
));
|
||||
let mut settings = AppSettings::default_for_root(&root);
|
||||
settings.quality_overrides_by_game.insert(
|
||||
"counter-strike-2".to_string(),
|
||||
QualityPreset {
|
||||
name: "Competitive 1080p60".to_string(),
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
fps: 60,
|
||||
bitrate_kbps: 12_000,
|
||||
},
|
||||
);
|
||||
|
||||
save_settings(&root, &settings).expect("save");
|
||||
let loaded = load_or_create_settings(&root).expect("load");
|
||||
|
||||
let override_quality = loaded
|
||||
.effective_quality_for("counter-strike-2");
|
||||
assert_eq!(override_quality.width, 1920);
|
||||
assert_eq!(override_quality.fps, 60);
|
||||
assert_eq!(loaded.effective_quality_for("league-of-leagues").width, 1280);
|
||||
assert!(loaded.quality_overrides_by_game.contains_key("counter-strike-2"));
|
||||
let _ = fs::remove_dir_all(root);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_settings_migrate_upload_defaults() {
|
||||
let root = std::env::temp_dir().join(format!(
|
||||
@@ -247,6 +299,31 @@ mod tests {
|
||||
let _ = fs::remove_dir_all(root);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_install_starts_onboarding_and_legacy_config_upgrades_it() {
|
||||
let root = std::env::temp_dir().join(format!(
|
||||
"clipforge-settings-onboarding-{}",
|
||||
SystemTimeCompat::millis()
|
||||
));
|
||||
fs::create_dir_all(&root).expect("settings root");
|
||||
let mut value =
|
||||
serde_json::to_value(AppSettings::default_for_root(&root)).expect("settings json");
|
||||
value
|
||||
.as_object_mut()
|
||||
.expect("settings object")
|
||||
.remove("onboarding_complete");
|
||||
fs::write(
|
||||
settings_path(&root),
|
||||
serde_json::to_string_pretty(&value).expect("legacy settings"),
|
||||
)
|
||||
.expect("write legacy settings");
|
||||
|
||||
let loaded = load_or_create_settings(&root).expect("load migrated settings");
|
||||
|
||||
assert!(!loaded.onboarding_complete);
|
||||
let _ = fs::remove_dir_all(root);
|
||||
}
|
||||
|
||||
struct SystemTimeCompat;
|
||||
|
||||
impl SystemTimeCompat {
|
||||
|
||||
@@ -23,6 +23,18 @@ impl LibraryPaths {
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds paths while honoring a user-selected clip directory. Thumbs,
|
||||
/// sessions, and the rolling buffer stay under the library root.
|
||||
pub fn with_clip_root(root: impl Into<PathBuf>, clip_root: impl Into<PathBuf>) -> Self {
|
||||
let root = root.into();
|
||||
Self {
|
||||
clip_root: clip_root.into(),
|
||||
thumbs_root: root.join("thumbs"),
|
||||
sessions_root: root.join("sessions"),
|
||||
buffer_root: root.join("buffer"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ensure(&self) -> io::Result<()> {
|
||||
fs::create_dir_all(&self.clip_root)?;
|
||||
fs::create_dir_all(&self.thumbs_root)?;
|
||||
@@ -114,6 +126,69 @@ pub struct StorageCleanupReport {
|
||||
pub remaining_bytes: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum StorageLevel {
|
||||
Ok,
|
||||
Warning,
|
||||
Critical,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct StorageSpace {
|
||||
pub total_bytes: u64,
|
||||
pub available_bytes: u64,
|
||||
pub level: StorageLevel,
|
||||
}
|
||||
|
||||
impl StorageSpace {
|
||||
pub fn free_gb(&self) -> f64 {
|
||||
self.available_bytes as f64 / (1024.0 * 1024.0 * 1024.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_storage_space(root: &Path) -> StorageSpace {
|
||||
let disks = sysinfo::Disks::new_with_refreshed_list();
|
||||
let mount = disks
|
||||
.list()
|
||||
.iter()
|
||||
.find(|disk| path_is_on_mount(root, disk.mount_point()))
|
||||
.or_else(|| disks.list().first());
|
||||
let valid = |disk: Option<&sysinfo::Disk>| -> Option<(u64, u64)> {
|
||||
disk.map(|disk| (disk.total_space(), disk.available_space()))
|
||||
};
|
||||
let (total, available) = valid(mount).unwrap_or((0, 0));
|
||||
let warning_at = bytes_for_gb(5);
|
||||
let critical_at = bytes_for_gb(2);
|
||||
let level = if available < critical_at {
|
||||
StorageLevel::Critical
|
||||
} else if available < warning_at {
|
||||
StorageLevel::Warning
|
||||
} else {
|
||||
StorageLevel::Ok
|
||||
};
|
||||
StorageSpace {
|
||||
total_bytes: total,
|
||||
available_bytes: available,
|
||||
level,
|
||||
}
|
||||
}
|
||||
|
||||
fn bytes_for_gb(gb: u64) -> u64 {
|
||||
gb * 1024 * 1024 * 1024
|
||||
}
|
||||
|
||||
fn path_is_on_mount(path: &Path, mount: &Path) -> bool {
|
||||
let path = path
|
||||
.to_str()
|
||||
.map(|value| value.to_ascii_lowercase())
|
||||
.unwrap_or_default();
|
||||
let mount = mount
|
||||
.to_str()
|
||||
.map(|value| value.to_ascii_lowercase())
|
||||
.unwrap_or_default();
|
||||
path == mount || path.starts_with(&mount)
|
||||
}
|
||||
|
||||
pub fn cleanup_oldest_files_until_under_limit(
|
||||
root: &Path,
|
||||
max_bytes: u64,
|
||||
@@ -173,6 +248,82 @@ fn collect_files(root: &Path) -> io::Result<Vec<FileFact>> {
|
||||
Ok(files)
|
||||
}
|
||||
|
||||
pub fn default_library_root() -> PathBuf {
|
||||
dirs::document_dir()
|
||||
.map(|docs| docs.join("ClipForge"))
|
||||
.or_else(|| dirs::home_dir().map(|home| home.join("ClipForge")))
|
||||
.unwrap_or_else(|| {
|
||||
std::env::current_dir()
|
||||
.unwrap_or_else(|_| PathBuf::from("."))
|
||||
.join("clipforge-library")
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LibraryResolution {
|
||||
pub root: PathBuf,
|
||||
pub migrated_from: Option<PathBuf>,
|
||||
}
|
||||
|
||||
pub fn resolve_library_root() -> io::Result<LibraryResolution> {
|
||||
let target = default_library_root();
|
||||
let legacy = legacy_library_in_working_dir();
|
||||
if let Some(legacy) = legacy {
|
||||
if legacy != target && !library_has_content(&target) {
|
||||
migrate_library(&legacy, &target)?;
|
||||
return Ok(LibraryResolution {
|
||||
root: target,
|
||||
migrated_from: Some(legacy),
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(LibraryResolution {
|
||||
root: target,
|
||||
migrated_from: None,
|
||||
})
|
||||
}
|
||||
|
||||
fn legacy_library_in_working_dir() -> Option<PathBuf> {
|
||||
let cwd = std::env::current_dir().ok()?;
|
||||
let candidate = cwd.join("clipforge-library");
|
||||
candidate.is_dir().then_some(candidate)
|
||||
}
|
||||
|
||||
fn library_has_content(path: &Path) -> bool {
|
||||
if path.join("settings.json").exists() || path.join("library.sqlite").exists() {
|
||||
return true;
|
||||
}
|
||||
if let Ok(mut entries) = fs::read_dir(path) {
|
||||
return entries.next().is_some();
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn migrate_library(from: &Path, to: &Path) -> io::Result<()> {
|
||||
if let Some(parent) = to.parent() {
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
if fs::rename(from, to).is_ok() {
|
||||
return Ok(());
|
||||
}
|
||||
copy_dir_all(from, to)?;
|
||||
fs::remove_dir_all(from)
|
||||
}
|
||||
|
||||
fn copy_dir_all(from: &Path, to: &Path) -> io::Result<()> {
|
||||
fs::create_dir_all(to)?;
|
||||
for entry in fs::read_dir(from)? {
|
||||
let entry = entry?;
|
||||
let target = to.join(entry.file_name());
|
||||
if entry.file_type()?.is_dir() {
|
||||
copy_dir_all(&entry.path(), &target)?;
|
||||
} else {
|
||||
fs::copy(entry.path(), &target)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -206,4 +357,69 @@ mod tests {
|
||||
assert_eq!(report.remaining_bytes, 10);
|
||||
let _ = fs::remove_dir_all(root);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn storage_space_reports_metrics_for_root() {
|
||||
let root = env::temp_dir();
|
||||
let space = check_storage_space(&root);
|
||||
assert!(space.total_bytes > 0);
|
||||
assert!(space.available_bytes <= space.total_bytes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn path_is_on_mount_matches_drive_prefix() {
|
||||
let root = if cfg!(windows) {
|
||||
Path::new("C:/Users/ClipForge/Clips")
|
||||
} else {
|
||||
Path::new("/home/clipforge/clips")
|
||||
};
|
||||
let mount = if cfg!(windows) {
|
||||
Path::new("C:")
|
||||
} else {
|
||||
Path::new("/home")
|
||||
};
|
||||
assert!(path_is_on_mount(root, mount));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_library_root_prefers_documents_dir() {
|
||||
let root = default_library_root();
|
||||
let docs = dirs::document_dir().expect("documents dir");
|
||||
let expected = docs.join("ClipForge");
|
||||
assert_eq!(root, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn migrates_legacy_library_to_target() {
|
||||
let temp_ns = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_nanos();
|
||||
let from = std::env::temp_dir().join(format!("clipforge-from-{temp_ns}"));
|
||||
let to = std::env::temp_dir().join(format!("clipforge-to-{temp_ns}"));
|
||||
fs::create_dir_all(&from).expect("from");
|
||||
fs::write(from.join("settings.json"), "{}").expect("settings");
|
||||
fs::create_dir_all(to.parent().unwrap()).expect("parent");
|
||||
assert!(from.exists());
|
||||
assert!(!to.exists());
|
||||
|
||||
migrate_library(&from, &to).expect("migrate");
|
||||
|
||||
assert!(!from.exists());
|
||||
assert!(to.join("settings.json").exists());
|
||||
assert!(library_has_content(&to));
|
||||
let _ = fs::remove_dir_all(to);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn library_has_content_reports_empty_directory() {
|
||||
let temp_ns = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_nanos();
|
||||
let dir = std::env::temp_dir().join(format!("clipforge-hascontent-{temp_ns}"));
|
||||
fs::create_dir_all(&dir).expect("dir");
|
||||
assert!(!library_has_content(&dir));
|
||||
let _ = fs::remove_dir_all(dir);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
|
||||
pub const DEFAULT_UPDATE_REPO: &str = "Alvin-Zilverstand/clipforge-game-clipper";
|
||||
const UPDATE_TIMEOUT_SECS: u64 = 30;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct GitHubRelease {
|
||||
pub tag_name: String,
|
||||
#[serde(default)]
|
||||
pub published_at: Option<String>,
|
||||
#[serde(default)]
|
||||
pub body: Option<String>,
|
||||
#[serde(default)]
|
||||
pub assets: Vec<GitHubAsset>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct GitHubAsset {
|
||||
pub name: String,
|
||||
#[serde(default)]
|
||||
pub size: Option<u64>,
|
||||
pub browser_download_url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
pub struct UpdateCheck {
|
||||
pub update_available: bool,
|
||||
pub latest_version: String,
|
||||
pub installer_file: Option<String>,
|
||||
pub download_url: Option<String>,
|
||||
pub published_at: Option<String>,
|
||||
pub release_notes: Option<String>,
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum UpdateCheckError {
|
||||
Http(String),
|
||||
Json(String),
|
||||
NoReleaseFound,
|
||||
NoInstallerAsset(String),
|
||||
Io(io::Error),
|
||||
}
|
||||
|
||||
impl fmt::Display for UpdateCheckError {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Http(message) => write!(formatter, "Update check HTTP error: {message}"),
|
||||
Self::Json(message) => write!(formatter, "Could not parse update response: {message}"),
|
||||
Self::NoReleaseFound => write!(formatter, "No published releases found yet."),
|
||||
Self::NoInstallerAsset(version) => write!(
|
||||
formatter,
|
||||
"Release {version} has no MSI or NSIS installer asset."
|
||||
),
|
||||
Self::Io(error) => write!(formatter, "Update file error: {error}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for UpdateCheckError {}
|
||||
|
||||
impl From<io::Error> for UpdateCheckError {
|
||||
fn from(error: io::Error) -> Self {
|
||||
Self::Io(error)
|
||||
}
|
||||
}
|
||||
|
||||
fn http_client(current_version: &str) -> Result<reqwest::blocking::Client, UpdateCheckError> {
|
||||
reqwest::blocking::Client::builder()
|
||||
.user_agent(format!("ClipForge/{current_version}"))
|
||||
.timeout(Duration::from_secs(UPDATE_TIMEOUT_SECS))
|
||||
.build()
|
||||
.map_err(|error| UpdateCheckError::Http(error.to_string()))
|
||||
}
|
||||
|
||||
pub fn check_for_updates(
|
||||
repo: &str,
|
||||
current_version: &str,
|
||||
) -> Result<UpdateCheck, UpdateCheckError> {
|
||||
let client = http_client(current_version)?;
|
||||
let url = format!("https://api.github.com/repos/{repo}/releases/latest");
|
||||
let response = client
|
||||
.get(&url)
|
||||
.send()
|
||||
.map_err(|error| UpdateCheckError::Http(error.to_string()))?;
|
||||
|
||||
if response.status() == reqwest::StatusCode::NOT_FOUND {
|
||||
return Err(UpdateCheckError::NoReleaseFound);
|
||||
}
|
||||
if !response.status().is_success() {
|
||||
return Err(UpdateCheckError::Http(format!(
|
||||
"GitHub returned {} for {}",
|
||||
response.status(),
|
||||
url
|
||||
)));
|
||||
}
|
||||
|
||||
let release: GitHubRelease = response
|
||||
.json()
|
||||
.map_err(|error| UpdateCheckError::Json(error.to_string()))?;
|
||||
|
||||
build_update_check(current_version, &release)
|
||||
}
|
||||
|
||||
pub fn build_update_check(
|
||||
current_version: &str,
|
||||
release: &GitHubRelease,
|
||||
) -> Result<UpdateCheck, UpdateCheckError> {
|
||||
let latest_version = normalize_version(&release.tag_name);
|
||||
let newer_release_exists = compare_versions(current_version, &latest_version) == Ordering::Less;
|
||||
let installer = select_installer_asset(&release.assets);
|
||||
|
||||
// A newer tag without a published installer is not something the user can
|
||||
// download, so never claim the app is installable in that state.
|
||||
let update_available = newer_release_exists && installer.is_some();
|
||||
|
||||
let message = if !newer_release_exists {
|
||||
"You are on the latest version.".to_string()
|
||||
} else if installer.is_none() {
|
||||
format!(
|
||||
"A newer version ({latest_version}) exists, but no installer has been published for it yet."
|
||||
)
|
||||
} else {
|
||||
let file = installer
|
||||
.as_ref()
|
||||
.map(|asset| asset.name.as_str())
|
||||
.unwrap_or("installer");
|
||||
format!(
|
||||
"A newer version ({latest_version}) is available — {file}, ready to download."
|
||||
)
|
||||
};
|
||||
|
||||
Ok(UpdateCheck {
|
||||
update_available,
|
||||
latest_version,
|
||||
installer_file: installer.as_ref().map(|asset| asset.name.clone()),
|
||||
download_url: installer.map(|asset| asset.browser_download_url),
|
||||
published_at: release.published_at.clone(),
|
||||
release_notes: release.body.clone(),
|
||||
message,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn select_installer_asset(assets: &[GitHubAsset]) -> Option<GitHubAsset> {
|
||||
assets
|
||||
.iter()
|
||||
.find(|asset| asset.name.ends_with(".msi"))
|
||||
.or_else(|| {
|
||||
assets.iter().find(|asset| {
|
||||
asset.name.ends_with(".exe") && !asset.name.to_lowercase().contains("uninstall")
|
||||
})
|
||||
})
|
||||
.cloned()
|
||||
}
|
||||
|
||||
pub fn download_installer(
|
||||
url: &str,
|
||||
destination_dir: &Path,
|
||||
file_name: &str,
|
||||
current_version: &str,
|
||||
) -> Result<PathBuf, UpdateCheckError> {
|
||||
std::fs::create_dir_all(destination_dir)?;
|
||||
let destination = destination_dir.join(file_name);
|
||||
let client = http_client(current_version)?;
|
||||
let mut response = client
|
||||
.get(url)
|
||||
.send()
|
||||
.map_err(|error| UpdateCheckError::Http(error.to_string()))?;
|
||||
if !response.status().is_success() {
|
||||
return Err(UpdateCheckError::Http(format!(
|
||||
"Download failed with {}",
|
||||
response.status()
|
||||
)));
|
||||
}
|
||||
|
||||
let mut file = std::fs::File::create(&destination)?;
|
||||
io::copy(&mut response, &mut file)
|
||||
.map_err(|error| UpdateCheckError::Io(error))?;
|
||||
Ok(destination)
|
||||
}
|
||||
|
||||
pub fn normalize_version(tag: &str) -> String {
|
||||
tag.trim().trim_start_matches('v').to_string()
|
||||
}
|
||||
|
||||
pub fn compare_versions(current: &str, latest: &str) -> Ordering {
|
||||
numeric_parts(current).cmp(&numeric_parts(latest))
|
||||
}
|
||||
|
||||
fn numeric_parts(version: &str) -> Vec<u32> {
|
||||
version
|
||||
.trim_start_matches('v')
|
||||
.split('.')
|
||||
.map(|segment| {
|
||||
segment
|
||||
.chars()
|
||||
.take_while(|character| character.is_ascii_digit())
|
||||
.collect::<String>()
|
||||
.parse::<u32>()
|
||||
.unwrap_or(0)
|
||||
})
|
||||
.take(3)
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn new_version_is_newer_than_current() {
|
||||
assert_eq!(compare_versions("0.1.0", "0.2.0"), Ordering::Less);
|
||||
assert_eq!(compare_versions("0.1.9", "0.2.0"), Ordering::Less);
|
||||
assert_eq!(compare_versions("0.9.9", "1.0.0"), Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_version_is_not_newer() {
|
||||
assert_eq!(compare_versions("0.2.0", "0.1.0"), Ordering::Greater);
|
||||
assert_eq!(compare_versions("0.3.0", "0.3.0"), Ordering::Equal);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn installed_040_detects_published_050_as_available_update() {
|
||||
let release = GitHubRelease {
|
||||
tag_name: "v0.0.5".to_string(),
|
||||
published_at: Some("2026-09-08T00:00:00Z".to_string()),
|
||||
body: None,
|
||||
assets: vec![GitHubAsset {
|
||||
name: "ClipForge_0.1.1_x64_en-US.msi".to_string(),
|
||||
size: Some(1_000_000),
|
||||
browser_download_url: "https://example.test/ClipForge_0.1.1.msi".to_string(),
|
||||
}],
|
||||
};
|
||||
let check = build_update_check("0.0.4", &release).expect("check");
|
||||
|
||||
assert!(check.update_available, "v0.0.4 must see v0.0.5 as an update");
|
||||
assert_eq!(check.latest_version, "0.0.5");
|
||||
assert_eq!(
|
||||
check.installer_file.as_deref(),
|
||||
Some("ClipForge_0.1.1_x64_en-US.msi")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn same_version_is_reported_as_up_to_date() {
|
||||
let release = GitHubRelease {
|
||||
tag_name: "v0.1.1".to_string(),
|
||||
published_at: None,
|
||||
body: None,
|
||||
assets: vec![GitHubAsset {
|
||||
name: "ClipForge_0.1.1_x64-setup.exe".to_string(),
|
||||
size: None,
|
||||
browser_download_url: "https://example.test/setup.exe".to_string(),
|
||||
}],
|
||||
};
|
||||
let check = build_update_check("0.1.1", &release).expect("check");
|
||||
|
||||
assert!(!check.update_available);
|
||||
assert_eq!(check.message, "You are on the latest version.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn newer_tag_without_installer_is_not_offered_for_download() {
|
||||
let release = GitHubRelease {
|
||||
tag_name: "v0.9.0".to_string(),
|
||||
published_at: Some("2026-09-09T00:00:00Z".to_string()),
|
||||
body: Some("notes".to_string()),
|
||||
assets: vec![GitHubAsset {
|
||||
name: "checksums.txt".to_string(),
|
||||
size: Some(128),
|
||||
browser_download_url: "https://example.test/checksums.txt".to_string(),
|
||||
}],
|
||||
};
|
||||
let check = build_update_check("0.1.1", &release).expect("check");
|
||||
|
||||
assert!(!check.update_available);
|
||||
assert!(check.download_url.is_none());
|
||||
assert!(check.message.contains("no installer has been published"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn patch_versions_compare_numerically_not_lexically() {
|
||||
assert_eq!(compare_versions("0.0.9", "0.0.10"), Ordering::Less);
|
||||
assert_eq!(compare_versions("0.0.10", "0.0.10"), Ordering::Equal);
|
||||
assert_eq!(compare_versions("0.0.11", "0.0.10"), Ordering::Greater);
|
||||
assert_eq!(compare_versions("0.1.0", "0.1.1"), Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn older_tag_backports_do_not_mask_newer_release() {
|
||||
assert_eq!(compare_versions("0.2.0", "0.1.1"), Ordering::Greater);
|
||||
assert_eq!(compare_versions("0.1.1", "0.2.0"), Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leading_v_and_prerelease_tags_are_ignored() {
|
||||
assert_eq!(compare_versions("v0.1.0", "v0.2.0"), Ordering::Less);
|
||||
assert_eq!(compare_versions("v0.2.0", "0.2.0"), Ordering::Equal);
|
||||
assert_eq!(compare_versions("0.2.0", "0.2.0-beta.1"), Ordering::Equal);
|
||||
assert_eq!(compare_versions("0.1.0", "0.2.0-beta.1"), Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn msi_asset_is_preferred_over_exe() {
|
||||
let assets = vec![
|
||||
GitHubAsset {
|
||||
name: "ClipForge_0.2.0_x64-setup.exe".to_string(),
|
||||
size: Some(1),
|
||||
browser_download_url: "https://example.test/setup.exe".to_string(),
|
||||
},
|
||||
GitHubAsset {
|
||||
name: "ClipForge_0.2.0_x64_en-US.msi".to_string(),
|
||||
size: Some(2),
|
||||
browser_download_url: "https://example.test/setup.msi".to_string(),
|
||||
},
|
||||
];
|
||||
let selected = select_installer_asset(&assets).expect("asset");
|
||||
assert_eq!(selected.name, "ClipForge_0.2.0_x64_en-US.msi");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exe_asset_is_selected_when_no_msi_exists() {
|
||||
let assets = vec![GitHubAsset {
|
||||
name: "ClipForge_0.2.0_x64-setup.exe".to_string(),
|
||||
size: Some(1),
|
||||
browser_download_url: "https://example.test/setup.exe".to_string(),
|
||||
}];
|
||||
let selected = select_installer_asset(&assets).expect("asset");
|
||||
assert_eq!(selected.name, "ClipForge_0.2.0_x64-setup.exe");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uninstaller_and_unknown_assets_are_rejected() {
|
||||
let assets = vec![
|
||||
GitHubAsset {
|
||||
name: "ClipForge_0.2.0_x64_uninstall.exe".to_string(),
|
||||
size: Some(1),
|
||||
browser_download_url: "https://example.test/uninstall.exe".to_string(),
|
||||
},
|
||||
GitHubAsset {
|
||||
name: "linux-port.AppImage".to_string(),
|
||||
size: Some(1),
|
||||
browser_download_url: "https://example.test/linux.AppImage".to_string(),
|
||||
},
|
||||
GitHubAsset {
|
||||
name: "checksums.txt".to_string(),
|
||||
size: Some(1),
|
||||
browser_download_url: "https://example.test/checksums.txt".to_string(),
|
||||
},
|
||||
];
|
||||
assert!(select_installer_asset(&assets).is_none());
|
||||
assert_eq!(normalize_version("v0.2.0"), "0.2.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn update_check_marks_latest_github_release_as_available() {
|
||||
let release = GitHubRelease {
|
||||
tag_name: "v0.2.0".to_string(),
|
||||
published_at: Some("2026-09-01T00:00:00Z".to_string()),
|
||||
body: Some("Update notes".to_string()),
|
||||
assets: vec![GitHubAsset {
|
||||
name: "ClipForge_0.2.0_x64-setup.exe".to_string(),
|
||||
size: Some(1_000_000),
|
||||
browser_download_url: "https://example.test/ClipForge_0.2.0.exe".to_string(),
|
||||
}],
|
||||
};
|
||||
let check = build_update_check("0.1.0", &release).expect("check");
|
||||
assert!(check.update_available);
|
||||
assert_eq!(check.latest_version, "0.2.0");
|
||||
assert_eq!(
|
||||
check.installer_file.as_deref(),
|
||||
Some("ClipForge_0.2.0_x64-setup.exe")
|
||||
);
|
||||
assert_eq!(check.published_at.as_deref(), Some("2026-09-01T00:00:00Z"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires live network access to the GitHub API"]
|
||||
fn live_check_against_github_repo() {
|
||||
let check = check_for_updates(DEFAULT_UPDATE_REPO, "0.0.1").expect("check");
|
||||
assert!(
|
||||
check.download_url.as_deref().filter(|value| !value.is_empty()).is_some()
|
||||
|| !check.update_available
|
||||
);
|
||||
assert!(!check.latest_version.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -164,6 +164,11 @@ h3 {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.status-pill.warn {
|
||||
background: #7f1d1d;
|
||||
color: #fecaca;
|
||||
}
|
||||
|
||||
.icon-button,
|
||||
.record-button,
|
||||
.actions button {
|
||||
@@ -275,6 +280,14 @@ h3 {
|
||||
color: #9ba7b8;
|
||||
}
|
||||
|
||||
.settings-panel .warn {
|
||||
color: #e6b116;
|
||||
background: rgba(230, 177, 22, 0.08);
|
||||
border-left: 3px solid #e6b116;
|
||||
padding: 8px 10px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.file-path {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
@@ -322,6 +335,11 @@ h3 {
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.screenshot-thumb img {
|
||||
object-fit: contain;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.thumb.kill {
|
||||
background: linear-gradient(135deg, #1f2937, #7f1d1d);
|
||||
}
|
||||
@@ -427,6 +445,19 @@ textarea {
|
||||
color: #f5f7fb;
|
||||
}
|
||||
|
||||
.field-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.field-row label {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -448,7 +479,44 @@ textarea {
|
||||
|
||||
.event-list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.auto-clip-group {
|
||||
margin-top: 18px;
|
||||
padding: 14px;
|
||||
border: 1px solid #2c3140;
|
||||
border-radius: 10px;
|
||||
background: #12161d;
|
||||
}
|
||||
|
||||
.auto-clip-group.disabled {
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.auto-clip-group-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.auto-clip-group-head .toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.auto-clip-group .event-list {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.auto-clip-global-actions {
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.event-row {
|
||||
@@ -470,6 +538,39 @@ textarea {
|
||||
color: #9ba7b8;
|
||||
}
|
||||
|
||||
.upload-history {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.upload-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
border: 1px solid #2c3140;
|
||||
border-radius: 8px;
|
||||
background: #12161d;
|
||||
}
|
||||
|
||||
.upload-row-main {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.upload-row.failed {
|
||||
border-color: #7f1d1d;
|
||||
}
|
||||
|
||||
.upload-row.uploaded {
|
||||
border-color: #14532d;
|
||||
}
|
||||
|
||||
.upload-row .status-pill {
|
||||
justify-self: start;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.app-shell,
|
||||
.content-grid,
|
||||
@@ -490,3 +591,234 @@ textarea {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
/* Onboarding wizard */
|
||||
.onboarding-shell {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.onboarding-workspace {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 40px 20px;
|
||||
}
|
||||
|
||||
.wizard-card {
|
||||
width: min(560px, 100%);
|
||||
background: #17191f;
|
||||
border: 1px solid #2a2e38;
|
||||
border-radius: 16px;
|
||||
padding: 28px;
|
||||
}
|
||||
|
||||
.wizard-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
|
||||
.wizard-header h1 {
|
||||
margin: 0;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.wizard-steps {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
padding: 0;
|
||||
margin: 0 0 22px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.wizard-steps li {
|
||||
flex: 1;
|
||||
padding: 8px 6px;
|
||||
border-radius: 8px;
|
||||
background: #242a36;
|
||||
color: #9ca3af;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wizard-steps li.active {
|
||||
background: #064e3b;
|
||||
color: #6ee7b7;
|
||||
}
|
||||
|
||||
.wizard-steps li.done {
|
||||
color: #34d399;
|
||||
}
|
||||
|
||||
.wizard-body h2 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.wizard-body .muted {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.wizard-options {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
margin: 18px 0;
|
||||
}
|
||||
|
||||
.wizard-actions {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.ghost-button,
|
||||
.primary-button {
|
||||
padding: 10px 18px;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ghost-button {
|
||||
background: transparent;
|
||||
border: 1px solid #374151;
|
||||
color: #d1d5db;
|
||||
}
|
||||
|
||||
.primary-button {
|
||||
background: #10b981;
|
||||
border: 1px solid #10b981;
|
||||
color: #06281f;
|
||||
}
|
||||
|
||||
.primary-button:hover {
|
||||
background: #34d399;
|
||||
}
|
||||
|
||||
.hotkey-list {
|
||||
list-style: none;
|
||||
margin: 18px 0 0;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.hotkey-list li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
background: #242a36;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.hotkey-list kbd {
|
||||
background: #101114;
|
||||
border: 1px solid #374151;
|
||||
border-bottom-width: 2px;
|
||||
border-radius: 6px;
|
||||
padding: 4px 10px;
|
||||
font-size: 12px;
|
||||
color: #f5f7fb;
|
||||
}
|
||||
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 50;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: rgba(10, 12, 16, 0.75);
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.modal {
|
||||
width: min(880px, 100%);
|
||||
max-height: 92vh;
|
||||
overflow-y: auto;
|
||||
background: #191d26;
|
||||
border: 1px solid #2c3442;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 14px 18px;
|
||||
border-bottom: 1px solid #2c3442;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background: #191d26;
|
||||
}
|
||||
|
||||
.modal-header h2 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
background: #2c3442;
|
||||
border: 1px solid #3a4556;
|
||||
border-radius: 8px;
|
||||
color: #e7edfb;
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
padding: 6px 12px;
|
||||
cursor: pointer;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.modal-close:hover {
|
||||
background: #38445a;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 18px;
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.modal-body video {
|
||||
width: 100%;
|
||||
max-height: 56vh;
|
||||
background: #000;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.modal-body img {
|
||||
max-width: 100%;
|
||||
max-height: 56vh;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.modal-body label,
|
||||
.modal-body input {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.video-error {
|
||||
border: 1px dashed rgba(231, 237, 251, 0.25);
|
||||
border-radius: 8px;
|
||||
padding: 18px;
|
||||
background: #141821;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.video-error h3 {
|
||||
margin: 0;
|
||||
color: #f87171;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.video-error-detail {
|
||||
color: #9ba7b8;
|
||||
}
|
||||