Web version, stage 2: Stockfish 19 in workers, live analysis, game review on N workers, My games, files, keys
game-review: what the job does for one target (the full search, the second best without the move played, the shallow ones) becomes a machine without I/O (job/work.rs), driven by the engine processes on a computer (job/engines.rs, the same searches as before) and by Web Workers in a browser (job/workers.rs: a dispatcher polled from the frames, never blocking). The analysis cache goes through a CacheStore (a folder, or the program's files of the platform). The browser's engine: Stockfish.js 19.0.1 (npm stockfish, GPL-3.0), its single-threaded build served beside /app/ (engine/, build.sh checks the package's sha512), its 99 MB wasm downloaded only through the engine offer, checked against its SHA-256 and kept in Cache Storage; workers get it as a blob: address. Live analysis (lines, arrows, the bar) and the review run on it; the review uses one worker per logical CPU, at most 8. My games (the web version): a PGN in the browser's storage, always on the shelf; Ctrl+S puts a game there (its own record, or a new one); deleting with undo. chess-core's store gives the bytes of append/replace/remove/restore, so the platform writes them into the browser's files; on a computer the files are written as before. Settings: Browser data (used and free space, keeping the data for good, Download all as PGN, deleting the engine). Files: a file of the last visit offers Choose the file again; Keep a copy in the browser (refused with the room it needs when the browser gives too little); files over 1 GB are not opened, with a word on why. No reference tab and no search by position in the web version. Keys: Alt+Left, plain 1-6, Ctrl+C, N in the library (the browser keeps Ctrl+W/N/1-6/Shift+C). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4ccf8099a5
commit
61ccd763bc
34 changed files with 2063 additions and 253 deletions
|
|
@ -23,6 +23,7 @@ use web as imp;
|
|||
pub mod clipboard;
|
||||
pub mod files;
|
||||
pub mod fs;
|
||||
pub mod pgn_store;
|
||||
|
||||
/// What the platform offers the interface: a feature it lacks is not shown.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
|
@ -46,6 +47,9 @@ pub struct Caps {
|
|||
pub training: bool,
|
||||
/// Saving a game is a download of its PGN (the browser's files are not written).
|
||||
pub download_pgn: bool,
|
||||
/// The reference tab (what was played here in the databases) and the search of a
|
||||
/// position in a database (not in the light web version).
|
||||
pub reference: bool,
|
||||
}
|
||||
|
||||
/// The features of this platform.
|
||||
|
|
@ -60,6 +64,7 @@ pub const CAPS: Caps = Caps {
|
|||
engine_programs: true,
|
||||
training: true,
|
||||
download_pgn: false,
|
||||
reference: true,
|
||||
};
|
||||
|
||||
/// The features of this platform: the light web version (`docs/decisions.md`, «Веб-версия»).
|
||||
|
|
@ -74,6 +79,7 @@ pub const CAPS: Caps = Caps {
|
|||
engine_programs: false,
|
||||
training: false,
|
||||
download_pgn: true,
|
||||
reference: false,
|
||||
};
|
||||
|
||||
/// The program's settings (`~/.config/chesspenguin`; in a browser, its storage).
|
||||
|
|
@ -105,6 +111,27 @@ pub fn spawn(name: &str, job: impl FnOnce() + Send + 'static) -> std::io::Result
|
|||
imp::spawn(name, job)
|
||||
}
|
||||
|
||||
/// Bytes the browser still gives the site to keep (its quota less what is used); `None`
|
||||
/// on a computer and until the browser answered.
|
||||
pub fn storage_free() -> Option<u64> {
|
||||
#[cfg(web)]
|
||||
return web::storage::usage().map(|(used, quota)| quota.saturating_sub(used));
|
||||
#[cfg(not(web))]
|
||||
None
|
||||
}
|
||||
|
||||
/// A size for people: "340 KB", "96 MB", "9.6 GB".
|
||||
pub fn size_text(bytes: u64) -> String {
|
||||
let b = bytes as f64;
|
||||
if b >= 1e9 {
|
||||
format!("{:.1} GB", b / 1e9)
|
||||
} else if b >= 1e6 {
|
||||
format!("{:.0} MB", b / 1e6)
|
||||
} else {
|
||||
format!("{:.0} KB", (b / 1e3).max(1.0))
|
||||
}
|
||||
}
|
||||
|
||||
/// A line for the program's log (`chesspenguin.log`; in a browser its console).
|
||||
pub fn log(line: &str) {
|
||||
#[cfg(not(web))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue