95d031fef9
Marks keeps one verdict per exe: on ("This is a game") or off ("This is
not a game"). detect: Launched > marked off (None) > marked on (Marked,
with the library game if any) > InstallDir. Serde writes
{"on": [...], "off": [...]} and still reads the plain array as on;
an exe in both lists is refused, MAX_MARKS counts both.
Also: collapsible-if for clippy, rustfmt, README and FORMATS updated.
Checked: cargo test -p arena-core (183 passed), clippy -D warnings,
fmt --check, check for wasm32-unknown-unknown and aarch64-linux-android.
110 lines
5.5 KiB
Markdown
110 lines
5.5 KiB
Markdown
# ArenaPublic
|
|
|
|
The open core of Arena Domi, the Domi game library: pure Rust parsers for game launcher files (Steam
|
|
`libraryfolders.vdf` and `appmanifest_<id>.acf`, Epic `.item`, GOG entries), the library model, and the
|
|
overlay's pure logic (frametime statistics, game detection, the shortcut); later the replay-ring logic. No I/O:
|
|
inputs are bytes or values, outputs are data. Builds for Windows, Android and WebAssembly.
|
|
|
|
## Licence
|
|
|
|
ArenaPublic is licensed under the **Common Public Attribution License 1.0** (SPDX `CPAL-1.0`); see `LICENSE`.
|
|
|
|
Anyone who redistributes ArenaPublic, or a Larger Work built on it, must show the Exhibit B credit wherever
|
|
CPAL §14 asks for it (display in Larger Works is required):
|
|
|
|
| Field | Value |
|
|
| :-- | :-- |
|
|
| Attribution Copyright Notice | Copyright (c) 2026 Marek Novák |
|
|
| Attribution Phrase | Built on Domi |
|
|
| Attribution URL | https://aula.marek-novak.cz |
|
|
| Graphic Image | none |
|
|
|
|
Versions before this change (up to and including tag `core-v0.1.0`) stay available under MPL-2.0 to those who
|
|
received them; from this commit on, the code is under CPAL-1.0.
|
|
|
|
## Crates
|
|
|
|
| Crate | Lib | What it holds |
|
|
| :-- | :-- | :-- |
|
|
| `crates/arena-core` | `arena_core` | launcher parsers, `WinPath`, `GameId`, `Launch`, the `Game` / `Library` model, `merge`; for the overlay `frames`, `detect`, `hotkey` |
|
|
|
|
## `arena-core` in one screen
|
|
|
|
Pure: no `std::fs`, `std::process`, network, environment, registry or clock. The window app reads the files and
|
|
registry values (capped) and hands the bytes or values in. Every parser treats its input as hostile: caps on size,
|
|
depth, lengths and counts, typed errors, no panics, `#![forbid(unsafe_code)]`.
|
|
|
|
```rust
|
|
use arena_core::{merge, steam, epic, gog, manual, domi, DomiLaunch, WinPath, Launch};
|
|
|
|
// Steam: the library folders, then one manifest per installed app.
|
|
let libraries: Vec<WinPath> = steam::library_folders(&vdf_bytes)?;
|
|
let game = steam::app_manifest(&acf_bytes, &libraries[0])?; // Err(NotAGame) for redistributables
|
|
let id = steam::app_id_from_manifest_name("appmanifest_10.acf"); // Some(10): filter a folder listing
|
|
|
|
// Epic: one `.item` JSON manifest per app.
|
|
let game = epic::item(&item_bytes)?; // Err(NotAGame) for add-ons
|
|
|
|
// GOG: registry values the app read.
|
|
let game = gog::game(&gog::GogEntry { game_id, name, path, exe, working_dir, launch_params })?;
|
|
|
|
// A game the user picked, and a Domi game from the Atrium registry.
|
|
let game = manual::game(r"D:\Games\Old\old.exe", None)?;
|
|
let game = domi::game("lapilli", "Lapilli", DomiLaunch::Link { app: "lapilli" })?;
|
|
let game = domi::game("rosea", "Rosea", DomiLaunch::Web { url, allowed_hosts: &["rosea.example.org"] })?;
|
|
|
|
// One library: the same id once, the same install folder kept for the best source
|
|
// (Steam > Epic > GOG > Domi > Manual), ordered by title.
|
|
let library = merge(vec![steam_games, epic_games, gog_games, domi_games, manual_games]);
|
|
|
|
// Launching: a URI for the protocol variants, built only from validated fields.
|
|
match &game.launch {
|
|
Launch::Exe { exe, working_dir, args } => { /* Command::new(exe).current_dir(working_dir).args(args) */ }
|
|
Launch::Url(_) => { let uri = game.launch.uri_checked(&allowed_hosts); }
|
|
other => { let uri = other.uri(); } // steam://, com.epicgames.launcher://, domi-<app>://
|
|
}
|
|
```
|
|
|
|
| Type | Rule |
|
|
| :-- | :-- |
|
|
| `GameId` | `<source>:<native>`, `[a-z0-9:._-]`, at most 96 bytes, checked per source; `Display` + strict `FromStr` |
|
|
| `WinPath` | absolute with a drive letter; no UNC, `\\?\`, `..`, NUL, device names; at most 260 UTF-16 units |
|
|
| `Launch` | `SteamRunGameId(u32)`, `Epic { app_name }`, `Exe { exe, working_dir, args }`, `DomiLink { app }`, `Url` |
|
|
| `Game` | `{ id, source, title, install_dir, launch, cover }`; serde round trip validates every field |
|
|
| `ParseError` | typed, `Display`, never carries input text |
|
|
|
|
For the overlay agent (0.2.0):
|
|
|
|
```rust
|
|
use arena_core::{frames, detect::{self, Detection, How, Marks}, hotkey::{self, Hotkey}};
|
|
|
|
// Frametimes in ms → avg FPS (frames / time), 1 % and 0.1 % lows (nearest-rank percentile, capped at the
|
|
// average), stutters (>= 2.5 x the median of the 60 frames before and >= 25 ms). None for empty or bad input.
|
|
let st: Option<frames::FrameStats> = frames::stats(&frametimes_ms);
|
|
|
|
// Launched by Arena > marked off ("not a game": None) > marked on > inside an install_dir (deepest wins).
|
|
// Outside every install_dir and not marked on: never a game. Whole path components, ignoring case.
|
|
marks.set(exe.clone(), true)?; // the "This is a game" toggle; false = off
|
|
let d: Option<Detection> = detect::detect(&exe, launched_by_arena, &library.games, &marks);
|
|
|
|
// "Ctrl+Shift+G" ⇄ Hotkey; refuses bare letters and Windows-reserved keys; Win32 values for RegisterHotKey.
|
|
let h: Hotkey = hotkey::parse("Ctrl+Shift+G")?;
|
|
let (fs_modifiers, vk) = (h.win32_modifiers(), h.virtual_key());
|
|
```
|
|
|
|
`Game`, `Library`, `GameId`, `WinPath` and `Launch` serialise with serde, and deserialising runs the same checks
|
|
as the parsers, so a tampered `library.json` cannot smuggle in a bad path or launch string. The same holds for
|
|
`Marks` (`{"on": [...], "off": [...]}` exe paths in the agent's `overlay.json`) and `Hotkey` (its text form in
|
|
`settings.json`).
|
|
|
|
Docs: [`docs/FORMATS.md`](docs/FORMATS.md) (what each parser accepts and refuses, every cap) and
|
|
[`docs/PORTABILITY.md`](docs/PORTABILITY.md) (the target checks).
|
|
|
|
## Commands
|
|
|
|
```
|
|
cargo test # unit, hostile, property, launch and dedupe tests
|
|
cargo clippy --all-targets -- -D warnings
|
|
cargo fmt --check
|
|
```
|